diff --git a/branches/fceux-2.2.2/COPYING b/COPYING similarity index 100% rename from branches/fceux-2.2.2/COPYING rename to COPYING diff --git a/trunk/ChangeLog b/ChangeLog similarity index 100% rename from trunk/ChangeLog rename to ChangeLog diff --git a/branches/fceux-2.2.2/INSTALL b/INSTALL similarity index 100% rename from branches/fceux-2.2.2/INSTALL rename to INSTALL diff --git a/trunk/Makefile.am b/Makefile.am similarity index 100% rename from trunk/Makefile.am rename to Makefile.am diff --git a/trunk/NEWS b/NEWS similarity index 100% rename from trunk/NEWS rename to NEWS diff --git a/branches/fceux-2.2.2/NewPPUtests.txt b/NewPPUtests.txt similarity index 100% rename from branches/fceux-2.2.2/NewPPUtests.txt rename to NewPPUtests.txt diff --git a/trunk/README b/README similarity index 100% rename from trunk/README rename to README diff --git a/trunk/SConstruct b/SConstruct similarity index 100% rename from trunk/SConstruct rename to SConstruct diff --git a/branches/fceux-2.2.2/STYLE-GUIDELINES-SDL b/STYLE-GUIDELINES-SDL similarity index 100% rename from branches/fceux-2.2.2/STYLE-GUIDELINES-SDL rename to STYLE-GUIDELINES-SDL diff --git a/branches/fceux-2.2.2/TODO-SDL b/TODO-SDL similarity index 100% rename from branches/fceux-2.2.2/TODO-SDL rename to TODO-SDL diff --git a/branches/fceux-2.2.2/attic/.gitignore b/attic/.gitignore similarity index 100% rename from branches/fceux-2.2.2/attic/.gitignore rename to attic/.gitignore diff --git a/branches/fceux-2.2.2/attic/BUGS b/attic/BUGS similarity index 100% rename from branches/fceux-2.2.2/attic/BUGS rename to attic/BUGS diff --git a/branches/fceux-2.2.2/attic/ChangeLog.older b/attic/ChangeLog.older similarity index 100% rename from branches/fceux-2.2.2/attic/ChangeLog.older rename to attic/ChangeLog.older diff --git a/branches/fceux-2.2.2/attic/Makefile.am b/attic/Makefile.am similarity index 100% rename from branches/fceux-2.2.2/attic/Makefile.am rename to attic/Makefile.am diff --git a/branches/fceux-2.2.2/attic/SConstruct.pre1.0 b/attic/SConstruct.pre1.0 similarity index 100% rename from branches/fceux-2.2.2/attic/SConstruct.pre1.0 rename to attic/SConstruct.pre1.0 diff --git a/branches/fceux-2.2.2/attic/TODO-SDL-2.1.6.md b/attic/TODO-SDL-2.1.6.md similarity index 100% rename from branches/fceux-2.2.2/attic/TODO-SDL-2.1.6.md rename to attic/TODO-SDL-2.1.6.md diff --git a/branches/fceux-2.2.2/attic/acinclude.m4 b/attic/acinclude.m4 similarity index 100% rename from branches/fceux-2.2.2/attic/acinclude.m4 rename to attic/acinclude.m4 diff --git a/branches/fceux-2.2.2/attic/aclocal.m4 b/attic/aclocal.m4 similarity index 100% rename from branches/fceux-2.2.2/attic/aclocal.m4 rename to attic/aclocal.m4 diff --git a/branches/fceux-2.2.2/attic/authors b/attic/authors similarity index 100% rename from branches/fceux-2.2.2/attic/authors rename to attic/authors diff --git a/branches/fceux-2.2.2/attic/changelog b/attic/changelog similarity index 100% rename from branches/fceux-2.2.2/attic/changelog rename to attic/changelog diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/CMakeLists.txt b/attic/cmake-stuff/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/CMakeLists.txt rename to attic/cmake-stuff/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt b/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt rename to attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt b/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt rename to attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake b/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake rename to attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt b/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt rename to attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt diff --git a/trunk/attic/cmake-stuff/cmake/fceux.cmake b/attic/cmake-stuff/cmake/fceux.cmake similarity index 100% rename from trunk/attic/cmake-stuff/cmake/fceux.cmake rename to attic/cmake-stuff/cmake/fceux.cmake diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/CMakeLists.txt b/attic/cmake-stuff/cmake/native/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/CMakeLists.txt rename to attic/cmake-stuff/cmake/native/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt b/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt rename to attic/cmake-stuff/cmake/native/debug/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/fceux_native.cmake b/attic/cmake-stuff/cmake/native/fceux_native.cmake similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/fceux_native.cmake rename to attic/cmake-stuff/cmake/native/fceux_native.cmake diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/release/CMakeLists.txt b/attic/cmake-stuff/cmake/native/release/CMakeLists.txt similarity index 100% rename from branches/fceux-2.2.2/attic/cmake-stuff/cmake/native/release/CMakeLists.txt rename to attic/cmake-stuff/cmake/native/release/CMakeLists.txt diff --git a/branches/fceux-2.2.2/attic/compile b/attic/compile similarity index 100% rename from branches/fceux-2.2.2/attic/compile rename to attic/compile diff --git a/branches/fceux-2.2.2/attic/config.guess b/attic/config.guess similarity index 100% rename from branches/fceux-2.2.2/attic/config.guess rename to attic/config.guess diff --git a/branches/fceux-2.2.2/attic/config.sub b/attic/config.sub similarity index 100% rename from branches/fceux-2.2.2/attic/config.sub rename to attic/config.sub diff --git a/branches/fceux-2.2.2/attic/configure-mingw32 b/attic/configure-mingw32 similarity index 100% rename from branches/fceux-2.2.2/attic/configure-mingw32 rename to attic/configure-mingw32 diff --git a/branches/fceux-2.2.2/attic/configure.ac b/attic/configure.ac similarity index 100% rename from branches/fceux-2.2.2/attic/configure.ac rename to attic/configure.ac diff --git a/branches/fceux-2.2.2/attic/depcomp b/attic/depcomp similarity index 100% rename from branches/fceux-2.2.2/attic/depcomp rename to attic/depcomp diff --git a/branches/fceux-2.2.2/attic/fceu-svga.6 b/attic/fceu-svga.6 similarity index 100% rename from branches/fceux-2.2.2/attic/fceu-svga.6 rename to attic/fceu-svga.6 diff --git a/branches/fceux-2.2.2/attic/install-sh b/attic/install-sh similarity index 100% rename from branches/fceux-2.2.2/attic/install-sh rename to attic/install-sh diff --git a/branches/fceux-2.2.2/attic/missing b/attic/missing similarity index 100% rename from branches/fceux-2.2.2/attic/missing rename to attic/missing diff --git a/branches/fceux-2.2.2/attic/mkinstalldirs b/attic/mkinstalldirs similarity index 100% rename from branches/fceux-2.2.2/attic/mkinstalldirs rename to attic/mkinstalldirs diff --git a/branches/fceux-2.2.2/attic/readme b/attic/readme similarity index 100% rename from branches/fceux-2.2.2/attic/readme rename to attic/readme diff --git a/trunk/autogen.sh b/autogen.sh similarity index 100% rename from trunk/autogen.sh rename to autogen.sh diff --git a/branches/fceux-2.2.2/Authors b/branches/fceux-2.2.2/Authors deleted file mode 100644 index 799599be..00000000 --- a/branches/fceux-2.2.2/Authors +++ /dev/null @@ -1,72 +0,0 @@ -Authors -======= - -A list of people who have contributed code to FCE Ultra, or have had their code -placed in FCE Ultra by others. - -Pre-2.0 FCE / FCE Ultra Contributors ------------------------------------- -_These authors contributed exclusively to pre-2.0 versions, -but much of their code remains in 2.0 builds_ - -* BERO - bero at geocities.co.jp - Base FCE code. - -* Xodnizel - Most of the base FCE Ultra code - -* Aaron Oneal - http://www.morphgear.com - Many changes to compile with MSVC and first frame skipping code - -* Joe Nahmias - Man pages - -* Paul Kuliniewicz - kuliniew at purdue.edu - Various code for the original SDL port. - -* Quietust - quietust at ircN dot org - VRC7 "translation" code. - -* Ben Parnell - Windows debugging tools - -* Parasyte & bbitmaster - Enhanced Windows debugging tools - -* blip & nitsuja - Rerecording support - -FCEUX >= 2.0 Contributors -------------------------- -* SP - document thyself (sf:rheiny) - Enhanced Windows debugging tools - -* zeromus - mgambrell at gmail dot com (sf:zeromus) - Core architecture refactoring and merging - Windows driver maintenance - -* adelikat - document thyself (sf:adelikat) - UI cleanup, project management, Win32 features & maintenance, TAS tools, documentation - -* CaH4e3 - CaH4e3 at mail dot ru (sf: cah4e3) - Mappers - -* Luke Gustafson - (sf:???) - Windows TAS and movie recording enhancements - -* qfox - (sf:qfox) - lua scripting fucntions, luabot, basicbot (no longer implemented), various lua scripts - -* _mz - document thyself (mauzus) - Windows driver maintenance and cleanup - -* UncombedCoconut - UncombedCoconut at gmail dot com (sf:jeblanchard) - Build system and cross-compilation support - Driver maintenance and refactoring - -* DWEdit - Debugger additions - -* AnS - ansstuff at yandex dot ru (sf:ansstuff) - Win32 features & maintenance, TAS Editor, debugging tools, documentation - -FCEUX (>=2.0) Linux/SDL Developers ----------------------------------- -_These guys concentrated on keeping fceux the premiere linux/portable nes emu._ - -* Lukas Sabota - ltsmooth42 at gmail dot com (sf:punkrockguy318) - Head FceuX-SDL developer - GTK GUI, complete overhaul of SDL port, build scripts; maintainence; docs - -* Shinydoofy - sf:shinydoofy - SDL maintenence - -* Soules - gimmedonutnow at gmail dot com (sf:gimmedonutnow) - Linux SDL driver maintenance - -* radsaq - radsaq at gmail dot com (sf:radsaq) - Build system, testing, and random cleanups - -* Bryan Cain - sf:plombo - Patch to embed SDL in the GTK+ GUI, miscellaneous other SDL and GTK+ contributions - -Included components: --------------------- -* Mitsutaka Okazaki - YM2413 emulator. - -* Andrea Mazzoleni - Scale2x/Scale3x scalers - -* Gilles Vollant - unzip.c PKZIP fileio diff --git a/branches/fceux-2.2.2/README-SDL b/branches/fceux-2.2.2/README-SDL deleted file mode 100644 index 92dbac5b..00000000 --- a/branches/fceux-2.2.2/README-SDL +++ /dev/null @@ -1,116 +0,0 @@ -FCEUX SDL 2.2.1 SDL README -========================== -By Lukas Sabota (sf: punkrockguy318) - -http://www.fceux.com - -Last Modified: March 10, 2013 - -Table of Contents ------------------ - -1. Requirements -2. Installation -3. Compile-time options -4. GUI -5. LUA Scripting -5. FAQ -6. Contact - -1 - Requirements ----------------- -* libsdl1.2 - It is strongly recommended that you upgrade to the latest - version of sdl (1.2.15 at the time of writing). -* scons - Required to build fceux. -* libgtk2.0 (optional) - version >= 2.24 recommended -* libgtk3.0 (optional) - this compiles as of fceux 2.2.0 -* liblua5.1 (optional) -* minizip (optional) - you may chose to use the version of minizip on your system by enabling SYSTEM_MINIZIP in the SConstruct -* c++ compiler -- you may use g++ from gcc or clang++ from llvm. - -2 - Installation ----------------- -Fceux can be compiled and built using the scons build system. To compile, run: - - scons - -After a sucessful compilation, the fceux binary will be generated to -./src/fceux . You can install fceux to your system with the following command: - - scons install - -You can optionally define a prefix: - - scons --prefix=/usr/local install - -You can choose to install the lua scripts (located in output/luaScripts) to a directory of your choosing: - - cp -R output/luaScripts /usr/local/some/directory/that/i/will/find/later - -If you would like to clean the temporary scons files to perform a 'make clean' like function, you can do the following: - - scons -c && rm -rf .scon* - -3 - Compile-time options ------------------------- -You can enable and disable certain features of fceux at build time. -To edit these options, edit the "BoolOptions" following the "opts.AddVariables" method -at the head of the "SConstruct" file in this source directory. The -default options will be fine for most users, but power users may want to -tweak some of these options. - -4 - GUI -------- -You can enable the GTK GUI by setting GTK to 1 in the SConstruct build file. -GfceuX is deprecatiated in favor of the new GTK GUI. You can disable the GTK GUI at -run-time by passing the --nogui option, or disable it at build-time by setting -GTK to 0 in the SConstruct file. If you prefer GTK3 to GTK2, you can set the -GTK3 BoolVariable to 1 in the SConstruct. - -5 - LUA Scripting ------------------ -FCEUX provides a LUA 5.1 engine that allows for in-game scripting capabilities. LUA can be enabled or disabled at build time by adjusting the "LUA" BoolVariable in the SConstruct file. - -A collection of LUA scripts are provided with the source distribuition in the output directory: - - $source_directory/output/luaScripts - -You should be able to run most of the scripts in this directory out of the box. However, some of the the lua scripts require functionality from the "auxlib.lua" library. This file can be copied from "./bin/auxlib.lua" or "./src/auxlib.lua". You will need to place this file in the LUA library search path if a script bombs out looking for auxlib.lua. If the script bombs out, the console output will let you know what the search path are (/usr/local/lib/lua/5.1/ on my particular system). You can simply copy the auxlib to a preferred location to utilize the functions in the auxiliary lua library. - -In addition, some of the lua scripts require functionality from the "iup" GUI library. You can obtain binaries and source for "iup" upstream (http://www.tecgraf.puc-rio.br/iup/), but I would recommend obtaining packages from your Linux distribution if you are able, as it can be difficult to compile or get the binaries working correctly on a given system. - -You will need to add the location that the libiup*.so files to the LUA_CPATH. This can be done with the following command (please note that the location where iup is installed with vary based on how you installed iup): - - export LUA_CPATH="/path/to/iup/lib/lib?51.so;" - -For example, if libiuplua51.so is located in '/usr/lib', you can run the following command before executing fceux to place the library in the search path: - - export LUA_CPATH="/usr/lib/lib?51.so;" - -Finally, if any scripts complaints about "attempt to index global 'iup' (a nil value)", this means that "iup" needs to be explicitly loaded into the script. You can add the following line to the head of script to manually load "iup": - - require("iuplua") - -The latest version of iup (3.5 at the time of writing) is recomended. - -6 - FAQ -------- - -* Q. Im having issues with my sound! -* A. First of all, for the best sound quality be sure you are using SDL 1.2.14 or later. Versions 1.2.13 and earlier are known to have problems with fceux! Next, try different SDL audio drivers to see if this makes any difference. You can do this by using this command before running fceux: - - export SDL_AUDIODRIVER=driver - -where driver is either: 'pulse' for pulseaudio;' alsa' for ALSA; 'dsp' for OSS; 'esd' for ESD; see SDL documentation for details (http://www.libsdl.org/docs/html/sdlenvvars.html) - -There are sound options that you can tweak at runtime through command line switches: - -* -soundq x internal sound quality hack value (0 off) -* -soundrate x sound rate (sane values: 28000 48000 -* -soundbuffersize x (in ms) sane values (30, 50, 100, 120) - -Running fceux through esddsp is known to fix some audio issues with pulseaudio on some older Ubuntu versions. - -7 - Contact ------------ -If you have an issue with fceux, report it in the sourceforge bug tracker (see fceux.com). If you would like to contact the author of this readme personally, e-mail LTsmooth42 gmail com. You can also check us out at #fceu on irc.freenode.net. diff --git a/branches/fceux-2.2.2/SConstruct b/branches/fceux-2.2.2/SConstruct deleted file mode 100644 index cb513e33..00000000 --- a/branches/fceux-2.2.2/SConstruct +++ /dev/null @@ -1,241 +0,0 @@ -# -# SConstruct - build script for the SDL port of fceux -# -# You can adjust the BoolVariables below to include/exclude features -# at compile-time. You may also use arguments to specify the parameters. -# ie: scons RELEASE=1 GTK3=1 -# -# Use "scons" to compile and "scons install" to install. -# - -import os -import sys -import platform - -opts = Variables(None, ARGUMENTS) -opts.AddVariables( - BoolVariable('DEBUG', 'Build with debugging symbols', 1), - BoolVariable('RELEASE', 'Set to 1 to build for release', 0), - BoolVariable('FRAMESKIP', 'Enable frameskipping', 1), - BoolVariable('OPENGL', 'Enable OpenGL support', 1), - BoolVariable('LUA', 'Enable Lua support', 1), - BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1), - BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 0), - BoolVariable('NEWPPU', 'Enable new PPU core', 1), - BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1), - BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', 1), - BoolVariable('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 1), - BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0), - BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1), - BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0), - BoolVariable('SDL2', 'Compile using SDL2 instead of SDL 1.2 (experimental/non-functional)', 0) -) -AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix') - -prefix = GetOption('prefix') -env = Environment(options = opts) - -if env['RELEASE']: - env.Append(CPPDEFINES=["PUBLIC_RELEASE"]) - env['DEBUG'] = 0 - -# LSB_FIRST must be off for PPC to compile -if platform.system == "ppc": - env['LSB_FIRST'] = 0 - -# Default compiler flags: -env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare']) - -if os.environ.has_key('PLATFORM'): - env.Replace(PLATFORM = os.environ['PLATFORM']) -if os.environ.has_key('CC'): - env.Replace(CC = os.environ['CC']) -if os.environ.has_key('CXX'): - env.Replace(CXX = os.environ['CXX']) -if os.environ.has_key('WINDRES'): - env.Replace(WINDRES = os.environ['WINDRES']) -if os.environ.has_key('CFLAGS'): - env.Append(CCFLAGS = os.environ['CFLAGS'].split()) -if os.environ.has_key('CXXFLAGS'): - env.Append(CXXFLAGS = os.environ['CXXFLAGS'].split()) -if os.environ.has_key('CPPFLAGS'): - env.Append(CPPFLAGS = os.environ['CPPFLAGS'].split()) -if os.environ.has_key('LDFLAGS'): - env.Append(LINKFLAGS = os.environ['LDFLAGS'].split()) - -print "platform: ", env['PLATFORM'] - -# compile with clang -if env['CLANG']: - env.Replace(CC='clang') - env.Replace(CXX='clang++') - -# special flags for cygwin -# we have to do this here so that the function and lib checks will go through mingw -if env['PLATFORM'] == 'cygwin': - env.Append(CCFLAGS = " -mno-cygwin") - env.Append(LINKFLAGS = " -mno-cygwin") - env['LIBS'] = ['wsock32']; - -if env['PLATFORM'] == 'win32': - env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"]) - env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"]) - env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"]) -else: - conf = Configure(env) - # If libdw is available, compile in backward-cpp support - if conf.CheckLib('dw'): - conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1") - conf.env.Append(LINKFLAGS = "-ldw") - if conf.CheckFunc('asprintf'): - conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF") - if env['SYSTEM_MINIZIP']: - assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip" - assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib" - env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"]) - else: - assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib" - if env['SDL2']: - if not conf.CheckLib('SDL2'): - print 'Did not find libSDL2 or SDL2.lib, exiting!' - Exit(1) - env.Append(CPPDEFINES=["_SDL2"]) - env.ParseConfig('pkg-config sdl2 --cflags --libs') - else: - if not conf.CheckLib('SDL'): - print 'Did not find libSDL or SDL.lib, exiting!' - Exit(1) - env.ParseConfig('sdl-config --cflags --libs') - if env['GTK']: - if not conf.CheckLib('gtk-x11-2.0'): - print 'Could not find libgtk-2.0, exiting!' - Exit(1) - # Add compiler and linker flags from pkg-config - config_string = 'pkg-config --cflags --libs gtk+-2.0' - if env['PLATFORM'] == 'darwin': - config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string - env.ParseConfig(config_string) - env.Append(CPPDEFINES=["_GTK2"]) - env.Append(CCFLAGS = ["-D_GTK"]) - if env['GTK3']: - # Add compiler and linker flags from pkg-config - config_string = 'pkg-config --cflags --libs gtk+-3.0' - if env['PLATFORM'] == 'darwin': - config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string - env.ParseConfig(config_string) - env.Append(CPPDEFINES=["_GTK3"]) - env.Append(CCFLAGS = ["-D_GTK"]) - - ### Lua platform defines - ### Applies to all files even though only lua needs it, but should be ok - if env['LUA']: - env.Append(CPPDEFINES=["_S9XLUA_H"]) - if env['PLATFORM'] == 'darwin': - # Define LUA_USE_MACOSX otherwise we can't bind external libs from lua - env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"]) - if env['PLATFORM'] == 'posix': - # If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading. - # Should work on any *nix - env.Append(CCFLAGS = ["-DLUA_USE_LINUX"]) - lua_available = False - if conf.CheckLib('lua5.1'): - env.Append(LINKFLAGS = ["-ldl", "-llua5.1"]) - env.Append(CCFLAGS = ["-I/usr/include/lua5.1"]) - lua_available = True - elif conf.CheckLib('lua'): - env.Append(LINKFLAGS = ["-ldl", "-llua"]) - env.Append(CCFLAGS = ["-I/usr/include/lua"]) - lua_available = True - if lua_available == False: - print 'Could not find liblua, exiting!' - Exit(1) - # "--as-needed" no longer available on OSX (probably BSD as well? TODO: test) - if env['PLATFORM'] != 'darwin': - env.Append(LINKFLAGS=['-Wl,--as-needed']) - - ### Search for gd if we're not in Windows - if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']: - gd = conf.CheckLib('gd', autoadd=1) - if gd == 0: - env['LOGO'] = 0 - print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.' - - if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1): - conf.env.Append(CCFLAGS = "-DOPENGL") - conf.env.Append(CPPDEFINES = ['PSS_STYLE=1']) - - env = conf.Finish() - -if sys.byteorder == 'little' or env['PLATFORM'] == 'win32': - env.Append(CPPDEFINES = ['LSB_FIRST']) - -if env['FRAMESKIP']: - env.Append(CPPDEFINES = ['FRAMESKIP']) - -print "base CPPDEFINES:",env['CPPDEFINES'] -print "base CCFLAGS:",env['CCFLAGS'] - -if env['DEBUG']: - env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g', '-O0']) -else: - env.Append(CCFLAGS = ['-O2']) - -if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']: - env.Append(CPPDEFINES=["CREATE_AVI"]) -else: - env['CREATE_AVI']=0; - -Export('env') -fceux = SConscript('src/SConscript') -env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"]) - -# Installation rules -if prefix == None: - prefix = "/usr/local" - -exe_suffix = '' -if env['PLATFORM'] == 'win32': - exe_suffix = '.exe' - -fceux_src = 'src/fceux' + exe_suffix -fceux_dst = 'bin/fceux' + exe_suffix - -fceux_net_server_src = 'fceux-net-server' + exe_suffix -fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix - -auxlib_src = 'src/auxlib.lua' -auxlib_dst = 'bin/auxlib.lua' -auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua' - -fceux_h_src = 'output/fceux.chm' -fceux_h_dst = 'bin/fceux.chm' - -env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)]) -env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)]) -env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)]) -env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)]) - -man_src = 'documentation/fceux.6' -man_net_src = 'documentation/fceux-net-server.6' -man_dst = prefix + '/share/man/man6/fceux.6' -man_net_dst = prefix + '/share/man/man6/fceux-net-server.6' - -share_src = 'output/' -share_dst = prefix + '/share/fceux/' - -image_src = 'fceux.png' -image_dst = prefix + '/share/pixmaps' - -desktop_src = 'fceux.desktop' -desktop_dst = prefix + '/share/applications/' - -env.Install(prefix + "/bin/", fceux) -env.Install(prefix + "/bin/", "fceux-net-server") -# TODO: Where to put auxlib on "scons install?" -env.Alias('install', env.Command(auxlib_inst_dst, auxlib_src, [Copy(auxlib_inst_dst, auxlib_src)])) -env.Alias('install', env.Command(share_dst, share_src, [Copy(share_dst, share_src)])) -env.Alias('install', env.Command(man_dst, man_src, [Copy(man_dst, man_src)])) -env.Alias('install', env.Command(man_net_dst, man_net_src, [Copy(man_net_dst, man_net_src)])) -env.Alias('install', env.Command(image_dst, image_src, [Copy(image_dst, image_src)])) -env.Alias('install', env.Command(desktop_dst, desktop_src, [Copy(desktop_dst, desktop_src)])) -env.Alias('install', (prefix + "/bin/")) diff --git a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/fceux.cmake b/branches/fceux-2.2.2/attic/cmake-stuff/cmake/fceux.cmake deleted file mode 100644 index 6d1a5191..00000000 --- a/branches/fceux-2.2.2/attic/cmake-stuff/cmake/fceux.cmake +++ /dev/null @@ -1,476 +0,0 @@ -#TODO: install generated exe's, appropriately named, in bin/ -include(CheckFunctionExists) -include(TestBigEndian) - -option(FCEUX_FORCE_LE "Build for a little-endian target" OFF) -option(FCEUX_FORCE_BE "Build for a big-endian target" OFF) -option(FCEUX_FRAMESKIP "Build legacy frameskip code" OFF) - -if(WIN32) - OPTION (NOWIN32 "Replace Win32 support with SDL" OFF) - if (NOWIN32) - set(WIN32 OFF) - endif(NOWIN32) -endif(WIN32) - -if (NOT WIN32) - option(FCEUX_SDL_OPENGL "Build with OpenGL support" ON) - find_package(SDL REQUIRED) - find_package(ZLIB REQUIRED) - if(FCEUX_SDL_OPENGL) - find_package(OpenGL REQUIRED) - endif(FCEUX_SDL_OPENGL) -endif(NOT WIN32) - -set(SRC_CORE - ${CMAKE_SOURCE_DIR}/src/asm.cpp - ${CMAKE_SOURCE_DIR}/src/cart.cpp - ${CMAKE_SOURCE_DIR}/src/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/conddebug.cpp - ${CMAKE_SOURCE_DIR}/src/config.cpp - ${CMAKE_SOURCE_DIR}/src/debug.cpp - ${CMAKE_SOURCE_DIR}/src/drawing.cpp - ${CMAKE_SOURCE_DIR}/src/fceu.cpp - ${CMAKE_SOURCE_DIR}/src/fds.cpp - ${CMAKE_SOURCE_DIR}/src/file.cpp - ${CMAKE_SOURCE_DIR}/src/emufile.cpp - ${CMAKE_SOURCE_DIR}/src/filter.cpp - ${CMAKE_SOURCE_DIR}/src/ines.cpp - ${CMAKE_SOURCE_DIR}/src/input.cpp - ${CMAKE_SOURCE_DIR}/src/movie.cpp - ${CMAKE_SOURCE_DIR}/src/netplay.cpp - ${CMAKE_SOURCE_DIR}/src/nsf.cpp - ${CMAKE_SOURCE_DIR}/src/oldmovie.cpp - ${CMAKE_SOURCE_DIR}/src/palette.cpp - ${CMAKE_SOURCE_DIR}/src/ppu.cpp - ${CMAKE_SOURCE_DIR}/src/sound.cpp - ${CMAKE_SOURCE_DIR}/src/state.cpp - ${CMAKE_SOURCE_DIR}/src/unif.cpp - ${CMAKE_SOURCE_DIR}/src/video.cpp - ${CMAKE_SOURCE_DIR}/src/vsuni.cpp - ${CMAKE_SOURCE_DIR}/src/wave.cpp - ${CMAKE_SOURCE_DIR}/src/x6502.cpp - ${CMAKE_SOURCE_DIR}/src/boards/01-222.cpp - ${CMAKE_SOURCE_DIR}/src/boards/103.cpp - ${CMAKE_SOURCE_DIR}/src/boards/106.cpp - ${CMAKE_SOURCE_DIR}/src/boards/108.cpp - ${CMAKE_SOURCE_DIR}/src/boards/112.cpp - ${CMAKE_SOURCE_DIR}/src/boards/117.cpp - ${CMAKE_SOURCE_DIR}/src/boards/120.cpp - ${CMAKE_SOURCE_DIR}/src/boards/121.cpp - ${CMAKE_SOURCE_DIR}/src/boards/15.cpp - ${CMAKE_SOURCE_DIR}/src/boards/164.cpp - ${CMAKE_SOURCE_DIR}/src/boards/175.cpp - ${CMAKE_SOURCE_DIR}/src/boards/176.cpp - ${CMAKE_SOURCE_DIR}/src/boards/177.cpp - ${CMAKE_SOURCE_DIR}/src/boards/178.cpp - ${CMAKE_SOURCE_DIR}/src/boards/179.cpp - ${CMAKE_SOURCE_DIR}/src/boards/183.cpp - ${CMAKE_SOURCE_DIR}/src/boards/185.cpp - ${CMAKE_SOURCE_DIR}/src/boards/186.cpp - ${CMAKE_SOURCE_DIR}/src/boards/187.cpp - ${CMAKE_SOURCE_DIR}/src/boards/189.cpp - ${CMAKE_SOURCE_DIR}/src/boards/199.cpp - ${CMAKE_SOURCE_DIR}/src/boards/208.cpp - ${CMAKE_SOURCE_DIR}/src/boards/222.cpp - ${CMAKE_SOURCE_DIR}/src/boards/23.cpp - ${CMAKE_SOURCE_DIR}/src/boards/235.cpp - ${CMAKE_SOURCE_DIR}/src/boards/253.cpp - ${CMAKE_SOURCE_DIR}/src/boards/3d-block.cpp - ${CMAKE_SOURCE_DIR}/src/boards/411120-c.cpp - ${CMAKE_SOURCE_DIR}/src/boards/43.cpp - ${CMAKE_SOURCE_DIR}/src/boards/57.cpp - ${CMAKE_SOURCE_DIR}/src/boards/603-5052.cpp - ${CMAKE_SOURCE_DIR}/src/boards/68.cpp - ${CMAKE_SOURCE_DIR}/src/boards/8157.cpp - ${CMAKE_SOURCE_DIR}/src/boards/8237.cpp - ${CMAKE_SOURCE_DIR}/src/boards/830118C.cpp - ${CMAKE_SOURCE_DIR}/src/boards/88.cpp - ${CMAKE_SOURCE_DIR}/src/boards/90.cpp - ${CMAKE_SOURCE_DIR}/src/boards/95.cpp - ${CMAKE_SOURCE_DIR}/src/boards/__dummy_mapper.cpp - ${CMAKE_SOURCE_DIR}/src/boards/a9711.cpp - ${CMAKE_SOURCE_DIR}/src/boards/a9746.cpp - ${CMAKE_SOURCE_DIR}/src/boards/addrlatch.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ax5705.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bandai.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc13in1jy110.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc42in1r.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc64in1nr.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc70in1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bonza.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bs-5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/onebus.cpp - ${CMAKE_SOURCE_DIR}/src/boards/datalatch.cpp - ${CMAKE_SOURCE_DIR}/src/boards/deirom.cpp - ${CMAKE_SOURCE_DIR}/src/boards/dream.cpp - ${CMAKE_SOURCE_DIR}/src/boards/edu2000.cpp - ${CMAKE_SOURCE_DIR}/src/boards/fk23c.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ghostbusters63in1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/gs-2004.cpp - ${CMAKE_SOURCE_DIR}/src/boards/gs-2013.cpp - ${CMAKE_SOURCE_DIR}/src/boards/h2288.cpp - ${CMAKE_SOURCE_DIR}/src/boards/karaoke.cpp - ${CMAKE_SOURCE_DIR}/src/boards/kof97.cpp - ${CMAKE_SOURCE_DIR}/src/boards/vrc5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ks7032.cpp - ${CMAKE_SOURCE_DIR}/src/boards/malee.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc3.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n-c22m.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n106.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n625092.cpp - ${CMAKE_SOURCE_DIR}/src/boards/novel.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sachen.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sc-127.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sheroes.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sl1632.cpp - ${CMAKE_SOURCE_DIR}/src/boards/smb2j.cpp - ${CMAKE_SOURCE_DIR}/src/boards/subor.cpp - ${CMAKE_SOURCE_DIR}/src/boards/super24.cpp - ${CMAKE_SOURCE_DIR}/src/boards/supervision.cpp - ${CMAKE_SOURCE_DIR}/src/boards/t-227-1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/t-262.cpp - ${CMAKE_SOURCE_DIR}/src/boards/tengen.cpp - ${CMAKE_SOURCE_DIR}/src/boards/tf-1201.cpp - ${CMAKE_SOURCE_DIR}/src/input/arkanoid.cpp - ${CMAKE_SOURCE_DIR}/src/input/bworld.cpp - ${CMAKE_SOURCE_DIR}/src/input/cursor.cpp - ${CMAKE_SOURCE_DIR}/src/input/fkb.cpp - ${CMAKE_SOURCE_DIR}/src/input/ftrainer.cpp - ${CMAKE_SOURCE_DIR}/src/input/hypershot.cpp - ${CMAKE_SOURCE_DIR}/src/input/mahjong.cpp - ${CMAKE_SOURCE_DIR}/src/input/mouse.cpp - ${CMAKE_SOURCE_DIR}/src/input/oekakids.cpp - ${CMAKE_SOURCE_DIR}/src/input/powerpad.cpp - ${CMAKE_SOURCE_DIR}/src/input/quiz.cpp - ${CMAKE_SOURCE_DIR}/src/input/shadow.cpp - ${CMAKE_SOURCE_DIR}/src/input/suborkb.cpp - ${CMAKE_SOURCE_DIR}/src/input/toprider.cpp - ${CMAKE_SOURCE_DIR}/src/input/zapper.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/151.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/16.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/17.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/18.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/193.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/201.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/202.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/203.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/204.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/21.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/212.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/213.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/214.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/215.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/217.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/22.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/225.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/227.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/228.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/229.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/230.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/231.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/232.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/234.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/241.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/242.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/244.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/246.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/24and26.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/25.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/255.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/27.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/32.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/33.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/40.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/41.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/42.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/46.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/50.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/51.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/59.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/6.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/60.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/61.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/62.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/65.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/67.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/69.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/71.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/72.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/73.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/75.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/76.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/77.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/79.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/8.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/80.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/82.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/83.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/85.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/86.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/89.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/91.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/92.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/97.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/99.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/emu2413.c - ${CMAKE_SOURCE_DIR}/src/mappers/mmc2and4.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/simple.cpp - ${CMAKE_SOURCE_DIR}/src/utils/ConvertUTF.c - ${CMAKE_SOURCE_DIR}/src/utils/crc32.cpp - ${CMAKE_SOURCE_DIR}/src/utils/endian.cpp - ${CMAKE_SOURCE_DIR}/src/utils/general.cpp - ${CMAKE_SOURCE_DIR}/src/utils/guid.cpp - ${CMAKE_SOURCE_DIR}/src/utils/md5.cpp - ${CMAKE_SOURCE_DIR}/src/utils/memory.cpp - ${CMAKE_SOURCE_DIR}/src/utils/unzip.cpp - ${CMAKE_SOURCE_DIR}/src/utils/xstring.cpp -) - -set(SRC_DRIVERS_COMMON - ${CMAKE_SOURCE_DIR}/src/drivers/common/args.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/configSys.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/hq2x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/hq3x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scale2x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scale3x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scalebit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/vidblit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/nes_ntsc.c -) - -set(SRC_DRIVERS_SDL - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/input.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-joystick.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-sound.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-throttle.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-video.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/unix-netplay.cpp -) - -if(FCEUX_SDL_OPENGL) - set(SRC_DRIVERS_SDL ${SRC_DRIVERS_SDL} ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-opengl.cpp) -endif(FCEUX_SDL_OPENGL) - -set(SRC_DRIVERS_WIN - ${CMAKE_SOURCE_DIR}/src/lua-engine.cpp - ${CMAKE_SOURCE_DIR}/src/lua/src/lapi.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lauxlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lbaselib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lcode.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldblib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldebug.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldo.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldump.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lfunc.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lgc.c - ${CMAKE_SOURCE_DIR}/src/lua/src/linit.c - ${CMAKE_SOURCE_DIR}/src/lua/src/liolib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/llex.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lmathlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lmem.c - ${CMAKE_SOURCE_DIR}/src/lua/src/loadlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lobject.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lopcodes.c - ${CMAKE_SOURCE_DIR}/src/lua/src/loslib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lparser.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstate.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstring.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstrlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltable.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltablib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltm.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lundump.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lvm.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lzio.c - ${CMAKE_SOURCE_DIR}/src/lua/src/print.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/archive.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/args.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/aviout.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/cdlogger.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/common.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/debugger.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/debuggersp.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/directories.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/gui.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/guiconfig.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/help.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/input.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/joystick.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/keyboard.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/log.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/luaconsole.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/main.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/mapinput.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memviewsp.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memwatch.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/movieoptions.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/monitor.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/netplay.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ntview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/OutputDS.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/palette.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ppuview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/pref.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ram_search.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ramwatch.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/replay.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - ${CMAKE_SOURCE_DIR}/src/drivers/win/sound.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/state.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/tasedit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/taseditproj.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/greenzone.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/bookmark.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/bookmarks.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/inputhistory.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/inputsnapshot.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/playback.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/markers.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/texthook.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/throttle.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/timing.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/tracer.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/video.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/wave.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/window.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/Win32InputBox.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/adler32.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/compress.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/crc32.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/deflate.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/gzio.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infblock.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infcodes.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inffast.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inflate.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inftrees.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infutil.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/trees.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/uncompr.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/zutil.c - # ${CMAKE_SOURCE_DIR}/src/drivers/res.rc -) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories( ${CMAKE_SOURCE_DIR}/src ) -add_definitions( -DNETWORK ) - -if(WIN32) - set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_WIN}) - include_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib ) - add_definitions( - -DWIN32 - -DFCEUDEF_DEBUGGER - -D_USE_SHARED_MEMORY_ - -DPSS_STYLE=2 - -DNOMINMAX - -D_S9XLUA_H - ) - link_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ) -else(WIN32) - set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL}) - include_directories( ${SDL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) - add_definitions( ${SDL_DEFINITIONS} ${ZLIB_DEFINITIONS} ) - if(FCEUX_SDL_OPENGL) - add_definitions( -DOPENGL ) - include_directories( ${OPENGL_INCLUDE_DIR} ) - endif(FCEUX_SDL_OPENGL) -endif(WIN32) - -if(APPLE) - add_definitions( -DPSS_STYLE=4 ) -else(APPLE) - if(UNIX) - add_definitions( -DPSS_STYLE=1 ) - endif(UNIX) -endif(APPLE) - -if(MINGW) - add_definitions( -DNEED_MINGW_HACKS -D_WIN32_IE=0x0600 ) -endif(MINGW) -if(CMAKE_BUILD_TYPE STREQUAL "debug") - add_definitions( -D_DEBUG ) -endif(CMAKE_BUILD_TYPE STREQUAL "debug") -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wno-write-strings -Wno-sign-compare") -endif(CMAKE_COMPILER_IS_GNUCXX) - -if(FCEUX_FRAMESKIP) - add_definitions( -DFRAMESKIP ) -endif(FCEUX_FRAMESKIP) - -if(NOT FCEUX_FORCE_BE) - if(FCEUX_FORCE_LE) - add_definitions( -DLSB_FIRST ) - else(FCEUX_FORCE_LE) - test_big_endian(SYS_IS_BE) - if(NOT SYS_IS_BE) - add_definitions( -DLSB_FIRST ) - endif(NOT SYS_IS_BE) - endif(FCEUX_FORCE_LE) -endif(NOT FCEUX_FORCE_BE) - -check_function_exists(asprintf HAVE_ASPRINTF) -# HACK: cmake seems to cache HAVE_ASPRINTF and I don't know how to ask it -# to forget--even if your compiler changes. So tell it mingw=>no. -if(HAVE_ASPRINTF AND NOT MINGW) - add_definitions( -DHAVE_ASPRINTF ) -endif(HAVE_ASPRINTF AND NOT MINGW) - -add_executable( ${FCEUX_EXE_NAME} ${SOURCES} ) - -if(WIN32) - add_dependencies( ${FCEUX_EXE_NAME} InstallHelpFile ) - #add_dependencies( ${FCEUX_EXE_NAME} res.o) - #add_custom_command( - # OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/res.o - # COMMAND windres - # ARGS ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc ${CMAKE_CURRENT_BINARY_DIR}/res.o --use-temp-file -D_WIN_IE=0x300 - # MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - #) - set(OUTPUT_RES_RC_O CMakeFiles/${FCEUX_EXE_NAME}.dir/__/__/__/src/drivers/win/res.rc.o) - add_custom_command( - OUTPUT ${OUTPUT_RES_RC_O} - COMMAND windres -o ${OUTPUT_RES_RC_O} ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - DEPENDS ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - VERBATIM - ) - add_custom_target( - BuildResourceFileFor${FCEUX_EXE_NAME} - DEPENDS ${OUTPUT_RES_RC_O} - ) - set(DEFINED_BUILD_RESOURCE_FILE TRUE CACHE GLOBAL "This is a hack to get CMake to build the .rc file") - - add_dependencies( ${FCEUX_EXE_NAME} BuildResourceFileFor${FCEUX_EXE_NAME} ) - set_property( - TARGET ${FCEUX_EXE_NAME} - PROPERTY LINK_FLAGS "${OUTPUT_RES_RC_O} -mwindows" - ) - - target_link_libraries( ${FCEUX_EXE_NAME} rpcrt4 comctl32 vfw32 winmm ws2_32 - comdlg32 ole32 gdi32 - dsound dxguid ddraw dinput - ) - if(MINGW) - include_directories(${CMAKE_SOURCE_DIR}/src/drivers/win/lua/include/) - else(MINGW) - target_link_libraries( ${FCEUX_EXE_NAME} htmlhelp) - endif(MINGW) -else(WIN32) - target_link_libraries( ${FCEUX_EXE_NAME} ${SDL_LIBRARY} ${ZLIB_LIBRARIES} ) - if(FCEUX_SDL_OPENGL) - target_link_libraries( ${FCEUX_EXE_NAME} ${OPENGL_gl_LIBRARY} ) - endif(FCEUX_SDL_OPENGL) -endif(WIN32) - - diff --git a/branches/fceux-2.2.2/changelog.txt b/branches/fceux-2.2.2/changelog.txt deleted file mode 100644 index 4eebbd5d..00000000 --- a/branches/fceux-2.2.2/changelog.txt +++ /dev/null @@ -1,817 +0,0 @@ - -23-Sep-2013 - AnS - Tracer: do not clear window log when stopping the logging -22-Sep-2013 - AnS - Tracer: the dialog window can be resized -21-Sep-2013 - AnS - Debugger: newly created Bookmarks inherit existing symbolic name by default -20-Sep-2013 - AnS - Debugger, Tracer: clicking on Symbolic names works as well as clicking on addresses -17-Sep-2013 - zeromus - fixed "Single Instance Mode" -16-Sep-2013 - AnS - PPU Viewer: added "Mask unused graphics" and "Invert the mask" checkboxes; fixed window layout when using big fonts -15-Sep-2013 - feos - Lua: added tobitstring(), memory.readword(int address1 [, int address2]), memory.readwordsigned(int address1 [, int address2]) functions -15-Sep-2013 - CaH4e3 - mapper 002 - workaround for "Top Gun" issue #621, needs testing if this broke something else; mapper 012 - added hardware dip for language select; UNIF PEC-586 - fixed render finally, added 512K cartridges suppport, TODO: PEC keyboard -13-Sep-2013 - AnS - debuggerFontSize and hexeditorFontSize can be specified in fceux.cfg -13-Sep-2013 - AnS - Debugger: "Symbolic Debug" state is now saved in global fceux.cfg instead of different .deb files -12-Sep-2013 - AnS - Tracer: added mouse wheel support -12-Sep-2013 - AnS - Tracer: clicking any address select the address; double-clicking any address brings Debugger at the address -12-Sep-2013 - AnS - Tracer: added Symbolic Debug naming by right-clicking any address -10-Sep-2013 - feos - Hexeditor: Symbolic Debug naming by right-clicking address -10-Sep-2013 - AnS - Debugger: added Symbolic Debug naming by right-clicking any address -05-Sep-2013 - AnS - Debugger: fixed Cycles counter reset when loading an earlier savestate -15-Aug-2013 - CaH4e3 - fixed bandai mapper emulation -04-Aug-2013 - AnS - Hexeditor: added "Highlighting" submenu and "Highlight Activity" feature -04-Aug-2013 - AnS - Taseditor: an experiment with somewhat different colors for HotChanges -04-Aug-2013 - AnS - Auto-disable "Game Genie ROM" feature when no "gg.rom" file is found -16-Jul-2013 - AnS - Debugger: highlight PC pointer line when a breakpoint is hit -05-Jul-2013 - AnS - RAM Search: added "Hex Editor" button and right-click -04-Jul-2013 - AnS - Debugger: added CDL data column in place of left panel. It helps to distinguish executed branches of code from not logged code -04-Jul-2013 - AnS - Debugger: clever autoscrolling when stepping/seeking to PC. It maintains relative position of the ">" pointer inside the Disassembly window -03-Jul-2013 - AnS - RAM Watch: fixed epic bug when contents of old .wch file mixed with the newly saved data because of "r+b" mode (changed it to "w+b") -03-Jul-2013 - AnS - Taseditor: Greenzone: always keep Greenzone.lagLog in touch with history.currentSnapshot.laglog (fixes workflow with "Auto-adjust" disabled) -03-Jul-2013 - AnS - Tracer: only output "from $XXXX" when the subroutine was called by JSR (fixes possible errors in those cases when the subroutine was called using stack magic) -03-Jul-2013 - AnS - Debugger: do not reload ram.nl every time automatically -21-Jun-2013 - CaH4e3 - PPU Viewer: when CDLogger is on, display unused graphics in a dim palette -15-Jun-2013 - AnS - Movie recording: fixed bug when emulator allowed recording commands outside the range of FM2 specs -15-Jun-2013 - AnS - Movie recording: added ability to record "Insert coin" command (for VS games) -15-Jun-2013 - AnS - Movie recording: remember last Author name when creating a new movie -08-Jun-2013 - AnS - A couple of fixes which deal with "multiple ROMs in a single archive" case. The loading procedure now takes into account actual ROM name when loading ROM from an archive containing multiple files. This affects PAL/NTSC detection (in case there were ROMs of different regions inside a single zip). Also, "auto-resume play" now loads actual ROM on startup (instead of prompting a list of archived files to choose). Also, NL files (symbolic debug) are named correctly when debugging a ROM from such an archive, etc. -08-Jun-2013 - AnS - Hexeditor: fixed bugs when saving files while working with ROMs in archives -27-May-2013 - AnS - Hexeditor: specify Data bank condition when adding a Breakpoint by context menu -26-May-2013 - AnS - Debugger: added 'T' condition (checks the bank of the data accessed) -26-May-2013 - AnS - Win32: fixed storing and loading .deb files when working with archived ROMs -26-May-2013 - AnS - new Lua functions: debugger.hitbreakpoint(), debugger.getcyclescount(), debugger.getinstructionscount(), debugger.resetcyclescount(), debugger.resetinstructionscount() -26-May-2013 - AnS - Win32: when no script is currently running, Shift+L loads the most recent Lua script -26-May-2013 - CaH4e3 - fixed mapper 183 -14-May-2013 - CaH4e3 - fixed mapper 253 -13-May-2013 - CaH4e3 - mapper 43 -09-May-2013 - AnS - Video config: changed "Disable hardware acceleration" option to a drop-down list with 3 options: a) No hardware acceleration; b) Create surface in RAM; c) Hardware acceleration. Because it appears that some video cards still blur textures even when stored in RAM. -29-Apr-2013 - AnS - added checking if archive file has any files in it, because new 7z.dll confuses FDS files with archives (it recognizes the first "F" as a signature of an archive) -19-Apr-2013 - AnS - Video config: added "Square pixels" option -19-Apr-2013 - AnS - Video config: added aspect ratio fields for customizing "TV Aspect" ratio, by default it's 4:3 -17-Apr-2013 - AnS - "Auto-resume old play session" now also works with NSFs -17-Apr-2013 - zeromus - properly savestate NSF -17-Apr-2013 - zeromus - add missing mmc5 savestate variables -16-Apr-2013 - AnS - Tracer: added "Log Cycles count" and "Log Instructions count" options -13-Apr-2013 - AnS - Debugger: scrolling up/down by whole instructions -12-Apr-2013 - gocha - Lua: fix wrong frequency calculation in sound.get() -07-Apr-2013 - AnS - Taseditor: comply with Lua movie.rerecordcounting() setting -01-Apr-2013 - CaH4e3 - mapper 154 - fixed -26-Mar-2013 - CaH4e3 - mapper 53 - supported ines format of SUPERVISION UNIF board; UNIF 8157 - fix according to hw; UNIF T-262 - fix according to hw -24-Mar-2013 - CaH4e3 - UNIF DANCE2000 - now emulated properly -20-Mar-2013 - gocha - link to lua51.dll instead of static linking -19-Mar-2013 - zeromus - bring some improvements to newppu from bizhawk, and fix vtoggle5/6 back to vtoggle -19-Mar-2013 - zeromus - fix mapper 28 -17-Mar-2013 - AnS - Replay: removed redundant window update when using "Browse" (fixes #585) -17-Mar-2013 - CaH4e3 - UNIF DSOUNDV1 - removed due to duplicate of 178 mapper; mapper 178 - added more features of 8/16M carts with 32K SRAM; UNIF 09-034A - added support for a new SMB2j Lite version -14-Mar-2013 - AnS - Debugger: ported "smart scrolling" from an obscure version of FCEUXD 1.1 -14-Mar-2013 - CaH4e3 - palette ram reading fix for old ppu - ----r2869 - FCEUX 2.2.1 Released--- ----March 10 2013--- - -10-Mar-2013 - prg - SDL: added option to use system minizip -10-Mar-2013 - prg - updated to use minizip v1.2.7 -10-Mar-2013 - CaH4e3 - CDLogger: improved CHR logging, now it also logs the data when using Old PPU -02-Mar-2013 - AnS - Hexeditor: fixed ROM coloring when using CDLogger data -28-Feb-2013 - AnS - PPU/PAL/Input type changing is now disabled when a movie is playing -28-Feb-2013 - AnS - Cheats: update the window when ROM is changed -28-Feb-2013 - AnS - show the number of active cheats when a ROM is loaded -27-Feb-2013 - CaH4e3 - CDLogger: added "Auto-load .CDL when opening the window" option -27-Feb-2013 - CaH4e3 - MMC5 refixed -24-Feb-2013 - AnS - CDLogger: added "Auto-save .CDL when closing ROMs" and "Auto-resume logging when loading ROMs" options -23-Feb-2013 - AnS - Hexeditor: show symbolic names in the window caption -18-Feb-2013 - CaH4e3 - various mapper improvements; UNIF MALISB - Mali Splash Bomb dump; mapper 19 - Dream Master mirror fix -18-Feb-2013 - CaH4e3 - fixed mapper 69 low quality sound issue -11-Feb-2013 - AnS - fixed possible crash when saving the ROM in Hex Editor -11-Feb-2013 - AnS - Moved "Config->Game Genie" to "Config->Enable->Game Genie ROM" -03-Feb-2013 - AnS - win32: speed up screen blitting -02-Feb-2013 - AnS - Added "TV Aspect (4:3)" to Video Config -21-Jan-2013 - AnS - Taseditor: fixed Bookmarks List height on Windows 7 -21-Jan-2013 - AnS - Taseditor: fixed bug with adding new item to History Log -20-Jan-2013 - AnS - Taseditor: changed the logic by which the Piano Roll follows Playback cursor, now it doesn't follow it while seeking -15-Jan-2013 - AnS - Lua: removed "shadow pixels" from gui.text(), made gui.parsecolor() function available for users -10-Jan-2013 - AnS - Taseditor: Config->Project file saving options -01-Jan-2013 - zeromus - NameTableViewer: do something reasonable if a 4-screen, table2, table3 mirror mode is chosen when the corresponding nametable ram is not available on the cart (instead of crashing) -31-Dec-2012 - CaH4e3 - fixed mappers 24, 26, 115 -29-Dec-2012 - AnS - Taseditor: Changed "Compact save" dialog, added 4 options of Greenzone saving -29-Dec-2012 - AnS - Cheats: added "Add from CHT file..." button -29-Dec-2012 - AnS - win32: force the entire client area to be invalidated at the beginning of WM_PAINT; this fixes the rare bug with DIRECTDRAWCLIPPER sometimes calculating wrong region (was noticed on some video cards) -27-Dec-2012 - AnS - Play movie dialog shows New PPU in red if the required setting does not match -27-Dec-2012 - thezlomus - RAM Search: added "Search ROM" checkbox -19-Dec-2012 - AnS - win32: remodel "Video config" dialog -19-Dec-2012 - AnS - win32: fixed restoring maximized window after switching from fullscreen -18-Dec-2012 - CaH4e3 - fixed mapper 018 and 198 -15-Dec-2012 - AnS - win32: added Config->Enable->Auto-resume old play session -13-Dec-2012 - AnS - win32: added Emulation Speed->Set custom speed for FrameAdvance -13-Dec-2012 - AnS - win32: added NES->Emulation Speed->Set FrameAdvance Delay -13-Dec-2012 - AnS - win32: added NES->Emulation Speed->Set Custom Speed -12-Dec-2012 - CaH4e3 - finish with mapper to boards conversion -07-Dec-2012 - CaH4e3 - Tracer: fixed RAM-located code logging when CDLogger options are enabled -05-Dec-2012 - AnS - fixed zapper and mouse positioning in fullscreen -04-Dec-2012 - AnS - speed up HUD text drawing -04-Dec-2012 - AnS - Taseditor: speed up consecutive Recordings (when combining) -03-Dec-2012 - AnS - Taseditor: fixed accelerators when editing Notes -03-Dec-2012 - AnS - fixed "X" button in the "Enter New Input" dialog (Hotkey Mapping); changed "Cancel" button to "OK" -03-Dec-2012 - CaH4e3 - fixed mapper 99 -29-Nov-2012 - zeromus - fix "you ling xing dong" by assigning to mapper 192 - ----r2768 - FCEUX 2.2.0 Released--- ----November 27 2012--- - -24-Nov-2012 - AnS - when the New PPU is on, it displays "(NewPPU)" in the window caption -20-Nov-2012 - AnS - Taseditor: added "Ungreenzone" item to context menu; added "Config->Enable Greenzoning" -13-Nov-2012 - AnS - Taseditor: changed fm3 format to version 3 -10-Nov-2012 - AnS - win32 hotkeys mapping: added the condition that both commands must have the same EMUCMDFLAG_TASEDITOR, or else they are not considered conflicting -10-Nov-2012 - AnS - win32 hotkeys: disallow unwanted hits of e.g. F1 after pressing Shift+F1 and quickly releasing Shift -05-Nov-2012 - zeromus - support mapper 028 -05-Nov-2012 - AnS - Taseditor: fixed lag adjustments when dealing with previously unknown lag state -30-Oct-2012 - zeromus - default stack pointer to $FD instead of $FF -29-Oct-2012 - CaH4e3 - mapper 252 added -29-Oct-2012 - AnS - Taseditor: update RAM Search and RAM Watch when jumping causes game state to change -21-Oct-2012 - CaH4e3 - sync mappers with fceu-mm -30-Sep-2012 - AnS - added "(Europe)" and "(PAL)" strings to region detection -28-Sep-2012 - AnS - Hexeditor: Ctrl+F opens Find dialog -28-Sep-2012 - AnS - Hexeditor: display 0x5000-0x5FFF contents -28-Sep-2012 - AnS - Tracer: fixed crash when logging undefined opcodes -26-Sep-2012 - AnS - Debugger: "Name" button in Bookmarks, total revamp of Bookmarks -26-Sep-2012 - AnS - Debugger: single click on any address copies this address to the "Seek To" field and "Bookmark Add" field -26-Sep-2012 - AnS - Fixed replay engine bug that doubles the last input of the movie -26-Sep-2012 - AnS - Tracer: "RTS" instructions now output the subroutine address/name -23-Sep-2012 - AnS - Lua: clear previous frame drawings at the beginning of every frame -23-Sep-2012 - AnS - Debugger: fixed mouseover when using Symbolic debug; mouseover works for the disassembly window too -23-Sep-2012 - CaH4e3 - CDLogger: Now can log VROM access (CHR banks of the ROM) when NewPPU is enabled -22-Sep-2012 - AnS - Tracer: added "Symbolic trace", "Log current Frame number", "Log emulator messages", "Log breakpoint hits" options -11-Sep-2012 - AnS - new Lua function: emu.setlagflag() -11-Sep-2012 - AnS - Debugger: deleting a breakpoint leaves selection in the Breakpoints list -06-Sep-2012 - AnS - added "Use Custom Palette" checkbox to Palette config -06-Sep-2012 - AnS - Debugger: special strings (NMI/IRQ/etc) can be also used in "Seek To" field and Bookmarks -01-Sep-2012 - AnS - fixed movie savestates logic, loading post-movie savestates is not allowed in read-only -31-Aug-2012 - zeromus - update mapper 156 from fceu-mm sources -30-Aug-2012 - AnS - fixed savestates filenaming bug when working with a movie -29-Aug-2012 - AnS - added "Force Grayscale" checkbox to Palette config -26-Aug-2012 - AnS - Taseditor: History Log highlights items related to current item -25-Aug-2012 - AnS - Taseditor: fixed AdjustLag feature and changed fm3 version to v2 -22-Aug-2012 - AnS - added "Clear" button to Message Log -20-Aug-2012 - AnS - "Switch fullscreen by double-click" option in GUI config -20-Aug-2012 - AnS - "Hide mouse cursor" and "Use console BG color for empty areas" options -20-Aug-2012 - AnS - total revamp of Video config stuff, Best Fit also works for fullscreen mode -19-Aug-2012 - AnS - win32: "Maintain aspect ratio (best fit)" option in Video config -12-Aug-2012 - AnS - Debugger: "Display ROM offsets" option -12-Aug-2012 - AnS - Debugger: double-click breakpoint also adds current bank number to breakpoint condition -12-Aug-2012 - AnS - Added FPS display to Win32 port (Config->Display->FPS) -10-Aug-2012 - prg - gtk: reset video on video dialog close -10-Aug-2012 - prg - gtk: add gui option for showfps -10-Aug-2012 - prg - sdl: add runtime option for controling drawing fps (SDL.ShowFPS) -10-Aug-2012 - prg - core: move showfps from build option to runtime option -10-Aug-2012 - prg - sdl: fix and enable SHOWFPS build option (TODO: make runtime option) -10-Aug-2012 - AnS - Debugger: "Address Bookmark Add" field follows disassembly window scrolling position -08-Aug-2012 - AnS - Taseditor: frame counter display is auto-on when Taseditor launches -08-Aug-2012 - AnS - Debugger: improved stack display -08-Aug-2012 - AnS - Debugger: doubleclick on the disassembly prompts "Add Execute breakpoint" dialog -08-Aug-2012 - AnS - Debugger: fixed RAM peek by a rightclick on left pane -08-Aug-2012 - AnS - Debugger: ">" points at current line in disassembly -08-Aug-2012 - AnS - Debugger: show the number of breakpoints (enabled and total) above the breakpoints list -06-Aug-2012 - CaH4e3 - fixed bug when loading UNF games (#525 ) -06-Aug-2012 - AnS - Tracer also updates its window when user pauses the game, not just when Debugger snaps -06-Aug-2012 - AnS - Tracer: added "Use Stack Pointer for code tabbing" option and added "To the left from disassembly text" option -05-Aug-2012 - AnS - Debugger: .DEB file now also stores the state of "Break on Bad Opcode" and "Break when exceed" checkboxes/editfields -05-Aug-2012 - AnS - Debugger: added "CPU cycles" and "Instructions" counters (request #527) and added "Break when exceed" breakpoints -05-Aug-2012 - AnS - Debugger: window layout cleanup -06-Aug-2012 - prg - gtk: added hotkey gui config -04-Aug-2012 - prg - all: updated FSF address -04-Aug-2012 - prg - sdl: added SDL.Input.EnableOppositeDirectional option. allows/disallows simultaneous right+left / up+down. -03-Aug-2012 - AnS - Debugger: highlighting breakpoint item in BPs list when it's triggered -03-Aug-2012 - AnS - Debugger: allow Frame Advancing when Debugger is in breakpoint state -03-Aug-2012 - AnS - Debugger: don't update Debugger window at the beginning of Step command (it will update at at the end of Step) - fixes #528 -25-Jul-2012 - AnS - Taseditor: auto-starting Note editing when creating Marker by double-click -19-Jul-2012 - AnS - Taseditor: Lua registermanual allows changing the "Run function" button caption; Markers are always restored when deploying Bookmarks -01-Jul-2012 - AnS - new hotkey "Run Manual Lua function" -24-Jun-2012 - AnS - Taseditor: drawing selected_slot border in Branches Tree -24-Jun-2012 - zeromus - add ability for CNROM games to choose whether they have bus conflicts (fixes Colorful Dragon (Unl) (Sachen), since it flakes out if bus conflicts are emulated) -23-Jun-2012 - zeromus - add m116 from fceu-mm; fix mapper 178 big PRG support -20-Jun-2012 - zeromus - fix savestate engine to throw errors when a buggy SFORMAT is passed to AddExState, and fix those errors in m015 and m253 -19-Jun-2012 - AnS - added TASEDITOR type of hotkeys -19-Jun-2012 - AnS - Taseditor: 2 new hotkeys: "Switch Auto-restoring" (Ctrl+Spacebar), "Switch current Multitracking mode" (W) -16-Jun-2012 - AnS - Taseditor: drawing patterns with Alt held; no more row_last_clicked -15-Jun-2012 - AnS - Taseditor: added "rewatch from Selection to Playback" feature for Ctrl+middle click action -14-Jun-2012 - AnS - Taseditor: combining consecutive AdjustLag operations -13-Jun-2012 - AnS - Taseditor: truncated Greenzone is drawn by pale colors, not just white -12-Jun-2012 - AnS - Taseditor: "Auto-adjust Input due to lag" checkbox -11-Jun-2012 - AnS - Taseditor: green arrow doesn't disappear when Playback cursor goes through it -11-Jun-2012 - AnS - Taseditor: changed icons column in Piano Roll, now can show both Bookmark and arrow -09-Jun-2012 - zeromus - win32-support funny languages for opening roms, through drag&drop, at least -06-Jun-2012 - AnS - Taseditor: small fix for Branches Tree - among bookmarks with equal jump_frame the cursor must be pointing at current branch -06-Jun-2012 - zeromus - support mapper 176. mapper 176 no longer maps to BMCFK23C. BMCFK23C is still accessible through crc or unif? test case would be welcome. it is unclear to me why mapper 176 control was removed from 176.cpp and given to BMCFK23C -06-Jun-2012 - AnS - Taseditor: autosave works only when project has a filename -26-May-2012 - AnS - Taseditor: Ctrl+Space accelerator = toggle "Auto-restore last position" checkbox; remapped "Restore Playback" hotkey to Spacebar; "Restore Playback" also pauses seeking; mid-click = "Restore Playback" when possible -08-May-2012 - AnS - Taseditor: changed "lost_position" logic -01-May-2012 - AnS - Lua functions emu.pause() and emu.unpause() don't yield and don't reset emulator speed anymore -30-Apr-2012 - AnS - Taseditor: Ctrl + mid click = run to Selection cursor; Shift + mid click = run to nearest Marker -26-Apr-2012 - AnS - Taseditor: fixed filename logic when user creates project from an fm2 or a corrupted fm3 -23-Apr-2012 - AnS - Taseditor: menus overhaul -19-Apr-2012 - AnS - RAM Watch: fixed loading Data Size and Data Type from a .wch, now corrupted .wch won't crash -17-Apr-2012 - zeromus - fix bug in mapper 164 savestates which caused wram to be lost, also make mapper 164 sram work -17-Apr-2012 - AnS - Taseditor: gradual History Log autocompression when idle -14-Apr-2012 - zeromus - add hash database entry for Rasaaru Ishii no Childs Quest (J), whose extant roms specify both the wrong mapper and the wrong mirroring -14-Apr-2012 - zeromus - change mapper 12 (mmc3 variant) to specify MMC3A chip version -14-Apr-2012 - AnS - Taseditor: rightclicks in Branches Tree -14-Apr-2012 - AnS - "Play Movie" dialog doesn't search in fceux root folder anymore -10-Apr-2012 - AnS - bold items in some context menus -10-Apr-2012 - zeromus - fix mapper 115 (actually to fix mapper 248 for Bao Qing Tian) -09-Apr-2012 - zeromus - remove vram protection from mapper 227 -09-Apr-2012 - AnS - Taseditor: all GUI buttons fire off at mousedown; disabled Spacebar and enabled Middle mouse button on GUI buttons -09-Apr-2012 - AnS - Taseditor: clicks in Branches Tree -07-Apr-2012 - AnS - Taseditor: version data in fm3 -07-Apr-2012 - AnS - Taseditor: much better way of calculating Branches Tree; hinting full timelines; miniarrow showing current Playback cursor position in Branches Tree; "Bookmark#" modtype, undo/redo works for Bookmarks -07-Apr-2012 - AnS - Taseditor: applying PAL and PPU flags when loading projects -05-Apr-2012 - zeromus - fix mapper 242 (dragon quest 8 UNL) -26-Mar-2012 - AnS - Taseditor: Alt+Wheel = jump across gaps in Input/Markers -25-Mar-2012 - AnS - returned default mapping of Frame Advance hotkey to Backslash -25-Mar-2012 - AnS - Taseditor: BookmarksList clicks apply on buttonup only -22-Mar-2012 - AnS - Config->Combine consecutive Recordings/Draws -18-Mar-2012 - AnS - new hotkey "Cancel Seeking (TAS Editor)" (Esc) -18-Mar-2012 - AnS - Taseditor: Config->Autopause at the end of Movie -17-Mar-2012 - CaH4e3 - varous bugfixes, xstring trimming functions logic bugs, etc -17-Mar-2012 - AnS - Taseditor: showing row_last_clicked when Shift or Alt is held -17-Mar-2012 - AnS - Taseditor: no more "allow keys in Piano Roll"; new accelerators: Ctrl + arrows, Shift + arrows, Home/End/Page Up/Page Down, Ctrl + Home/End, Shift + Home/End -17-Mar-2012 - AnS - Taseditor: selection by dragging from Frame# -17-Mar-2012 - AnS - Taseditor: set/pick Markers by doubleclick, throw Markers away -14-Mar-2012 - AnS - Taseditor: drawing input; holding Shift when drawing -14-Mar-2012 - AnS - Taseditor: fixed known WinXP bug with scrollbar arrows -14-Mar-2012 - AnS - Taseditor: moving Markers by drag'n'drop, "Marker Drag" and "Marker Swap" operations -14-Mar-2012 - AnS - Taseditor: dragging blue arrow (moving Playback cursor) -14-Mar-2012 - AnS - Taseditor: observing Piano Roll by dragging cursor outside -11-Mar-2012 - AnS - Taseditor: double-tapping Shift/Ctrl scrolls Piano Roll to respective cursor -09-Mar-2012 - AnS - Taseditor: Config->Deselect on doubleclick -09-Mar-2012 - AnS - Taseditor: checking ROM checksum when saving/loading projects -09-Mar-2012 - AnS - Taseditor: TAS Editor can have mouse wheel input even when keyboard focus is on FCEUX window -09-Mar-2012 - AnS - disabled FCEUX context menu when TAS Editor is engaged -06-mar-2012 - prg - fceux no longer segfaults when opening gamepadconfig with GTK < 2.24 - a message is printed to the console -06-mar-2012 - prg - supports loading of configuration files in $FCEUXDIR/cfg.d/* -01-Mar-2012 - AnS - Taseditor: changing history size doesn't reset history -28-feb-2012 - AnS - Taseditor: "Deselect" option in menus -26-feb-2012 - AnS - Small save/load state speedup, noticeable only in TAS Editor or lua bots -21-feb-2012 - AnS - Taseditor: header lights on mouseover -21-feb-2012 - AnS - Taseditor: registering click at buttondown; Alt+click on input = set pattern -20-feb-2012 - AnS - Taseditor: Right button + wheel = Playback rewind/forward; Shift/Ctrl + wheel = jump via Markers with Playback/Selection cursor -20-feb-2012 - AnS - Taseditor: middle button pauses/unpauses emulation -18-feb-2012 - AnS - PATTERNS menu, loading data from "tools\taseditor_patterns.txt" -18-feb-2012 - AnS - "Use pattern" checkbox in Recorder; Config->ColumnSet Pattern skips Lag -18-feb-2012 - AnS - Taseditor: "Frame#" lights when Alt key is being held, not entering menu by Alt -18-feb-2012 - AnS - Changed some checkboxes to radiobuttons in FCEUX menu -13-feb-2012 - AnS - Taseditor: when clicking text fields, Piano Roll scrolls to corresponding Marker, not to cursor -13-feb-2012 - AnS - Replay dialog speedup, now movie is not loaded into memory when checking md5 -06-feb-2012 - AnS - new Lua scripts: SoundDisplay.lua, TrackNoise.lua -06-feb-2012 - AnS - refined Recording, now can safely record commands (Power, Reset, Insert, Switch) -02-feb-2012 - AnS - uploaded HelpNDoc3 project file -02-feb-2012 - AnS - added Lua scripts demonstrating some TAS Editor library functions -02-feb-2012 - AnS - new Lua function in TAS Editor library: getsuperimpose() -02-feb-2012 - AnS - new Lua function in Joypad library: getimmediate() -30-jan-2012 - AnS - Taseditor: 9 new Lua functions in TAS Editor library -30-jan-2012 - AnS - Taseditor: Added "Restore Playback (TAS Editor)" hotkey (Enter by default) -30-jan-2012 - AnS - Taseditor: Help->Show Tooltips -30-jan-2012 - AnS - Taseditor: quicksave/quickload hotkeys save/load current branch -23-jan-2012 - prg - sdl: pause will now show/ungrab cursor in fullscreen. this can be disabled with the SDL.NoFullscreenCursor option -12-jan-2012 - AnS - Tasedit: File->New Project, INPUT_TYPE_1P -12-jan-2012 - AnS - Tasedit: resizing TAS Editor window -08-jan-2012 - prg - sdl: switched advance one frame key from "\" to "`" -08-jan-2012 - AnS - changed default mapping of Frame Advance to Tilde -08-jan-2012 - AnS - fixed recording bug where "length" tag appeared in fm2s -08-jan-2012 - AnS - Tasedit: Lua panel; 5 new Lua functions -08-jan-2012 - AnS - Tasedit: refactoring; Config->Silent autosave -04-jan-2012 - AnS - Tasedit: colored marker captions; pale yellow and bright yellow when "Bind Markers" is off/on -27-dec-2011 - AnS - Tasedit: "About" window -27-dec-2011 - AnS - Tasedit: searching Markers with similar Notes ("Similar" and "More" buttons) -26-dec-2011 - AnS - Tasedit: Find Note dialog (Ctrl-F) -26-dec-2011 - AnS - new Lua functions (TAS Editor library) -19-dec-2011 - AnS - Tasedit: listview header lights -19-dec-2011 - AnS - Tasedit: Recording checkbox instead of radiobutton; Config->Use Input keys for ColumnSet -19-dec-2011 - AnS - Tasedit: Export dialog: "Convert Marker Notes to Movie Subtitles" -16-dec-2011 - AnS - Tasedit: new accelerators: Ctrl-PgUp/Ctrl-PgDn/Shift-PgUp/Shift-PgDn; Config->Allow keyboard controls in Listview -16-dec-2011 - AnS - Tasedit: View->Display Branch Tooltips -16-dec-2011 - AnS - Tasedit: Markers notes; View->Follow Marker Note context -16-dec-2011 - AnS - changed ".tas" extension to ".fm3" -10-dec-2011 - AnS - loading TAS Editor projects by drag-n-drop -10-dec-2011 - AnS - Tasedit: File->Save Compact dialog -09-dec-2011 - AnS - Replaying TAS Editor project files in FCEUX (win32 and SDL) -07-dec-2011 - AnS - disabled changing PPU/PAL/input_type when Taseditor is engaged -07-dec-2011 - AnS - Tasedit: File->Recent projects -07-dec-2011 - AnS - enhanced Reload hotkey (Ctrl-F1), now it loads last ROM or last TAS Editor project -05-dec-2011 - AnS - Tasedit: Import input, Export to FM2 -04-dec-2011 - AnS - Tasedit: branches autofind best parent, "Set Marker"/"Remove marker" in context menu, checking clipboard at selection.init() and retrieving info -29-nov-2011 - AnS - Tasedit: MsgBox about not working with movies starting from savestate -26-nov-2011 - aquanull - win32: fixed graphic-tearing WITH vertical sync enabled in windowed mode. It used to wait for V-Blank too early so that the V-Blank would end too soon before the blitting could be finished. -26-nov-2011 - AnS - Fixed crash when using machine with no sound card -26-nov-2011 - zeromus - Fixed wrong default palette entry -25-nov-2011 - zeromus - add nestopia palette files -25-nov-2011 - AnS - Tasedit: selection << and >>, Turbo Seek checkbox, PasteInsert, Config->Superimpose affects copy/paste, Editing info texts -23-nov-2011 - zeromus - fix [3441099] printf bug in SwapSaveState() -21-nov-2011 - AnS - Tasedit: multitrack recording, "Superimpose" checkbox, Config->Use 1P keys for all single recordings, Config->Combine consecutive Recordings -19-nov-2011 - AnS - Tasedit: selection strobe, soft reset and power switch messages, messages when saving/loading Branches -17-nov-2011 - AnS - Tasedit: selection history, undo/redo, Reselect Clipboard, saving/loading selection history to .tas -17-nov-2011 - AnS - Tasedit: input hotchanges -14-nov-2011 - zeromus - straighten out bandai m159/m016 handling and add valid null-EEPROM emulation to get those games booting. -12-nov-2011 - adelikat - win32 - cheat search - slight GUI tweak -12-nov-2011 - AnS - Tasedit: project autosaving -10-nov-2011 - AnS - Tasedit: Branches show saved screenshot on mouseover (alpha-fade popup window) -7-nov-2011 - AnS - Tasedit: Drawing Branches Tree (using GDI), animations, transitions, mouseover -04-nov-2011 - prg318 - gtk: added option for frameskipping and made label case consistent in gui -1-nov-2011 - zeromus - debugger - fix mysterious out of bounds condition while editing breakpoints -31-oct-2011 - zeromus - add winapi lua library -31-oct-2011 - zeromus - fix newppu bug; chr ram was not getting initialized to anything -28-oct-2011 - AnS - Switching Tasedit Bg input on/off when Tasedit gets/loses focus -27-oct-2011 - AnS - "Toggle Rerecord Display" hotkey (M), "Play Movie From Beginning" hotkey also works in Tasedit -27-oct-2011 - AnS - Tasedit: Bookmarks/Branches -23-oct-2011 - prg318 - sdl: fix a bug where alt key would get "stuck" when alt tabbing to window -21-oct-2011 - AnS - Tasedit: gradual greenzone cleaning -19-oct-2011 - prg318 - scons: "scons install" now installs auxlib and manpage -19-oct-2011 - prg318 - scons: added --prefix option to build system and improved "install" target -18-oct-2011 - prg318 - sdl: new hotkeys added - statestatenext savestateprev - useful for scrolling through savestates on a gamepad. mapped to pgup and pgdown by default -18-oct-2011 - prg318 - gtk: new video option for double buffering and ClipSides -18-oct-2011 - prg318 - sdl: GTK3 support is now functional. Set GTK3 to 1 in the SConstruct to try it out. -18-oct-2011 - prg318 - no longer use depreciated gtk2 functions -18-oct-2011 - prg318 - getSDLKey tool added to assist in remapping hotkeys -17-oct-2011 - prg318 - some segfaults fixed, also fixed some build errors -17-oct-2011 - prg318 - sdl netplay fixed -15-oct-2011 - zeromus - don't lose cheat compare value when toggle cheat enables through UI -14-oct-2011 - AnS - added rewind hotkey (~), works only in Taseditor -14-oct-2011 - AnS - Tasedit: execute lua functions when jumping inside greenzone -13-oct-2011 - AnS - Tasedit: major refactoring -9-oct-2011 - AnS - Tasedit: input history, undo, redo; greenzone reduces only from the point where actual differences were found -07-oct-2011 - prg318 - sdl: fixed some issues with --nogui . "--nogui" no longer requires an argument and can be used like this "$ fceux --nogui rom.nes" -07-oct-2011 - prg318 - gtk: support mouseclicks (ie zapper) -03-oct-2011 - AnS - Tasedit: Clone Frame(s) -02-oct-2011 - AnS - Tasedit: Markers -30-sept-2011 - AnS - logging all display messages to Message Log -30-sept-2011 - AnS - Tasedit: special method of inserting frames; progressbar updating when loading/saving large projects; moved "Follow cursor" checkbox from View menu to main TASEdit window -30-sept-2011 - AnS - Tasedit: View->Show dot in empty cells; ClearFrames (Del), Cut operation clears frames instead of deleting; checking unsaved project on Exit and Open project -28-sept-2011 - CaH4e3 - resetexstate crash fix -27-sept-2011 - AnS - Fixed old bug with "Play Movie From Beginning" -26-sept-2011 - AnS - added support for "Enable HUD recording" option to SDL version -25-sept-2011 - AnS - Tasedit: progressbar; holding "<" and ">" buttons -25-sept-2011 - zeromus - newppu-fix bug in scroll reg logic causing mis-scrolls in p'radikus conflict -24-sept-2011 - CaH4e3 - latest mapper changes; code/data logger now can log data access from the RAM code; the new button to save unused data to the code/data logger -24-sept-2011 - AnS - Tasedit: changed control scheme to single click instead of double click -23-sept-2011 - AnS - File->AVI/Wav->Enable HUD recording -23-sept-2011 - AnS - moved "Display movie status icon" from Config->Movie options to Config->Display -23-sept-2011 - AnS - Config->Display->Rerecord counter; no more TweakCount -23-sept-2011 - AnS - Config->Movie options->Always suggest Read-Only replay (for Replay dialog) -22-sept-2011 - AnS - deleted "Lag Counter Reset" hotkey; added "Open TAS Edit" hotkey -22-sept-2011 - AnS - fixed long "savestate" messages containing path -22-sept-2011 - AnS - Tasedit: auto clear "Disable speed throttling" and "Run in background", auto set "Set high-priority thread" when entering TASEdit; FCEUX runs in bg when TASEdit has focus; Config->"Mute Turbo" check -19-sept-2011 - AnS - Tasedit: accelerator table; Config->"Set greenzone capacity"; pauseframe is shown by flashing color -18-sept-2011 - zeromus - datalatch mapper-fix bug where wramless games would be able to do something mysterious to unmapped host emulator memory -17-sept-2011 - AnS - Tasedit: forced read-only behaviour when seeking or holding turbo -17-sept-2011 - AnS - Tasedit: "Auto-restore last position" checkbox in playback controls -17-sept-2011 - AnS - Tasedit: fixed item drawing method, no more flicker and slowdowns -12-sept-2011 - prg318 - sdl: rename InputType to CurInputType due to variable of same name in src/movie.h -12-sept-2011 - AnS - Tasedit: rewrote project save/load functions, various bugfixes -6-sept-2011 - AnS - Tasedit: red lines for lag frames -6-sept-2011 - AnS - fixed bug when trying to open Replay dialog without having ROM loaded -3-sept-2011 - AnS - Tasedit: tweaks and bugfixes -3-sept-2011 - CaH4e3 - fixed bus conflict emulation, no kage no densetsu bug anymore -31-Aug-2011 - AnS - Tasedit: Added 4 pads support; also now current frame is shown by blue line; minor cleanups -30-Aug-2011 - mart0258 - Ram Search updates list when emulator is paused (on Power, or when resetting search) -25-Aug-2011 - zeromus - win32: fix context menus to use rightclicks in context menus correctly -19-Aug-2011 - CaH4e3 - PAL/NTSC noise fixed -18-Jul-2011 - zeromus - slightly improve hud text rendering wrapping -16-Jul-2011 - adelikat - Add Button Count lua script written by Brandon Evans -15-Jul-2011 - prg318 - sdl: patch to resolve 'XKeysymToString' complication errors on debian sid and osx (thanks antonio ospite!) -6-Jul-2011 - plombo - sdl: fixed --nogui option and removed SDL.NoGUI from fceux.cfg -5-Jul-2011 - FatRatKnight - Lua console now gets the proper file path when selecting a file from the recent menu. - ----r2206 - FCEUX 2.1.5 Released--- ----June 21 2011--- - -16-Jun-2011 - zeromus - win32: poll hotkeys while no rom is loaded -1-jun-2011 - prg318 - sdl - print usage when --help is passed even if SDL fails -plombo - added stock icons to menu items -plombo - added new gamepad configuration dialog -19-mar-2011 - prg318 - gtk - added hard reset option (renamed reset->soft reset) -18-mar-2011 - prg318 - sdl - removed GTK_LITE; --nogui made it obsolete -12-feb-2010 - mart0258 - Fix input selection for Famicom Expansion port -25-jan-2010 - prg318 - gtk - filechooser now remembers last file opened -25-jan-2010 - prg318 - gtk - fixed xscale/yscale spinbuttons not changing config -24-jan-2010 - prg318 - gtk - game window integrated into sdl window (thanks bryan!) -11-nov-2010 - mart0258 - TasEdit - Invalidate greenzone when re-recording earlier portions of a movie. -09-oct-2010 - zeromus - fix bug in new ppu that made some intensify bits not get applied to output (fixes flashing siren screen in werefolf -09-oct-2010 - gocha - win32 - Ram Watch - fix the multiple selection of watches -09-oct-2010 - gocha - Win32 - Ram Search - multiple selection of addresses, fix restoration of the selection range -09-oct-2010 - gocha - Win32 - Ram Search - fix restoration of the selection range -01-oct-2010 - qeed - Fix many segfaults related to file handling -22-sept-2010 - adelikat - win32 - Hex Editor - ask before removing all bookmarks -04-sept-2010 - adelikat - Win32 - Ramwatch - fix displaying of 2 byte values -26-aug-2010 - mart0258 - Win32 - fix crash when re-opening debugging window -20-aug-2010 - adelikat - Win32 - Display movie name at the top of the main window -09-july-2010 - mart0258 - TasEdit - cleanup; prevent crash when truncating while turbo -13-june-2010 - adelikat - Win32 - avi capture commandline argument and related parameters -12-june-2010 - adelikat - Save Turbo frame skip amount to config so that it can be customized by user -12-june-2010 - adelikat - Lua - fix speed.mode() so that normal turns off turbo -12-june-2010 - CaH4e3 - Fix Young Indiana Jones Chronicals -10-june-2010 - Deign - Fix Ram Search to only display valid RAM addresses (0000-07FF and 6000-7FFF) -10-june-2010 - zeromus - add luasocket to built in lua library -09-june-2010 - adelikat - Movies - Fixed read-only loadstate error logic & messages -07-june-2010 - mart0258 - Movie loading now faster - TAS savestates moved from class MovieRecord to class MovieData -07-june-2010 - adelikat - Lua - new function: gui.screenshotas() -07-june-2010 - Deign/adelikat - Win32 - Added a SavestateAs Menu item -06-june-2010 - FatRatKnight - Added a return value to gui.text: The X position where the function would paint the next character. -02-june-2010 - adelikat - Win32 - Movie Options Dialog - Fix so Full Savestate Load checkbox is updated on load - ----r1984 - FCEUX 2.1.4a Released--- ----June 1 2010--- - -01-june-2010 - zeromus - fix crash bug in fcm convert -01-june-2010 - adelikat - fix logic error in read-only loadstate of movies, should not improperly report savestate after movie errors - ----r1977 - FCEUX 2.1.4 Released--- ----May 31 2010--- - -29-may-2010 - Cah4e3 - Added zapper autodetection for Gotcha! -28-may-2010 - adelikat - Added lua function movie.getfilename() which returns the current movie filename without the path included -27-may-2010 - ugetab - Win32 - Debugger - Made debugger able to break on and distinguish Stack reads/writes -24-may-2010 - adelikat - Win32 - Memwatch - ignore spaces at the beginnign of an address in the address boxes -24-may-2010 - mart0258 - Disable auto-savestates during turbo -24-may-2010 - mart0258 - Prevent .zip files containing no recognized files from causing crash -23-may-2010 - adelikat - Win32 - Replay dialog - fix bug that was causing it to always report savestate movies as soft-reset -23-may-2010 - adelikat - Fix PlayMovieFromBeginning when using a movie that starts from savestate -23-may-2010 - cah4e3 - mapper 19 savestate fix mirroring for "Dream Master (J)" corrected to "four-screen" by CRC check -23-may-2010 - ugetab - Win32 - Fixed bug involving pausing emulation outside of the debugger, then trying to use the debugger commands, and having teh CPU registers become corrupted. -22-may-2010 - ugetab - Win32 - Made cheat menu's Pause When Active effect immediate. -22-may-2010 - ugetab - Win32 - Enabled multi-select for Cheat menu to allow multiple toggles and deletes. -20-may-2010 - ugetab - Added NTSC 2x scalar option with some CFG config options of it's own -20-may-2010 - Cah4e3 - Win32 - CDLogger - fixed bug preventing correct interrupt vectors from logging -19-may-2010 - ugetab/adelikat - Win32 - Added single-instance mode, which makes starting a second copy of FCEUX load the file into the first, then exit.Mode off by default, togglable under Config -> GUI -18-may-2010 - adelikat - Movie + loadstate errors are handled more gracefully now, more informative error messages and the movie doesn't have to stop -18-may-2010 - adelikat - Implemented a "full savestate-movie load" mode similar to the implementation in VBA-rr & SNES9x-rr. In this mode loading a savestate in read+write doesn't truncate the movie to its frame count immediately. Instead it waits until input is recording into the movie (next frame). For win32 this feature is togglable in movie options and the context menu. For SDL this is off by default and a toggle will need to be added. -17-may-2010 - adelikat - Made gamepad 2 off by default. -17-may-2010 - adelikat - Movies - fully implemented "bulletproof" read-only -17-may-2010 - zeromus - Movie loading (& movie-savestate saving/loading) should now be faster due to the use of a emufile class instead of std::ostream for dumping -16-may-2010 - ugetab - Added player 3 and 4 to autohold notification window. Made FCEU_DispMessage able to display to different screen locations to do it. Made sure to update SDL with the change. Hope SDL still compiles ok. -15-may-2010 - ugetab - Win32 - Added option for palette selection as color for LUA colors. Included an LUA script to display all choices with the value used to pick displayed color. -14-may-2010 - adelikat - Win32 - Replay dialog, when selecting a movie in a relative path (.\movies for example), the recent movies list stores an absolute path instead. -14-may-2010 - adelikat - Win32 - When recording a movie, add it to recent movies -14-may-2010 - adelikat - Win32 - Replay dialog shows PAL flag & New PPU flag -14-may-2010 - adelikat - New PPU flag in movie headers (doesn't change an emulators PPU state when loading a movie) -13-may-2010 - adelikat - input display overhaul - a more desmume style system which shows both keys held the previous frame and immiately held keys that will be put in on the next frame -12-may-2010 - ugetab - Win32 - Added rudamentry Between-Frames input display code for adelikat to customize. -12-may-2010 - adelikat - Input Display - displays a silver color when input is from a movie rather than the user -12-may-2010 - ugetab - Win32 - With special scaler in window mode, it's possible to resize to anything above the minimum. -12-may-2010 - adelikat - Movies now have a "finished" option. If a playback stops the movie isn't cleared from memory, and can be replayed or a state loaded. Similar functionality as DeSmuME and GENS rerecording -11-may-2010 - adelikat - Loadstate updates input display -11-may-2010 - ugetab - Win32 - Added Ram Search hotkeys for the first 6 search types in the list. -10-may-2010 - ugetab - Added gui.getpixel() which gets any gui.pixel() set pixel colors, and possibly other functions. Added emu.getscreenpixel() which gets the RGB and Palette of any pixel on the screen. -08-may-2010 - ugetab - Added savestate.object() which is savestate.create() with intuitive numbering under windows -08-may-2010 - ugetab - Added emu.addgamegenie() and emu.delgamegenie() LUA functions. -07-may-2010 - ugetab - Win32 - Added context menu to Cheat Dialog Cheat Listbox, populated list with Toggle Cheat, Poke Cheat Value, and Goto In Hex Editor -07-may-2010 - ugetab - Win32 - Made enabling/disabling cheats no longer deselect the selected cheat. -06-may-2010 - ugetab - win32 - Add Cheat buttons for Ram Search and Ram Watch -06-may-2010 - ugetab - win32 - Hex editor - Made the Hex Editor display the Frozen, Bookmarked, etc. status of the selected address, and made the Frozen color override the Bookmarked color. -04-may-2010 - ugetab - Win32 - Added "Goto" command for hex editor. -28-april-2010 - ugetab - Added microphone support option. When enabled, Port 2 Start activates the Microphone. Movies also support this. -25-april-2010 - FatRatKnight - Fixed a potential desync that plays out an extra frame without an update to the frame count involving heavy lua use, joypad.get, and a loadstate. -23-april-2010 - ugetab - Win32 - Added Tools>GUI option to partially disable visual themes, so the emulator can be made to look like it did in 2.1.1 and earlier releases. -20-april-2010 - adelikat - New lua functions movie.ispoweron() and movie.isfromsavestate() -20-april-2010 - adelikat - Win32 - Drag & Drop - if dropping a .fcm with no ROM loaded, prompt for one (same functionality that was added to .fm2 files) -08-april-2010 - ugetab - Win32 - Added conditional debugging option 'K', for bank PC is on -07-april-2010 - adelikat - fix bug that caused zapper.read() to crash when movie playback ends - ----r1767 - FCEUX 2.1.3 Released--- ----April 7 2010--- - -07-april-2010 - sgrunt - Lua - gui.text now has out of bounds checking -07-april-2010 - adelikat - Win32 - Lua console - filename updates when lua scripts are dragged to emulator or recent filenames invoked -07-april-2010 - adelikat - Lua no longer unpauses the emulator when a script is loaded -30-march-2010 - ugetab - Win32 - Closing minimized windows no longer moves them the next time they get opened -28-march-2010 - adelikat - lua - fixed zapper.read() to read movie data if a movie is playing. Also changed the struct values to x,y,fire. This breaks lua scripts that used it previous, sorry. -04-march-2010 - prockguy - added menu buttons for loading nsf files -03-march-2010 - adelikat - Win32 - If .fm2 drag & dropped with no ROM load, the open ROM dialog will appear -03-march-2010 - prockguy - fceux - now prints the name of the mapper on rom load -03-march-2010 - prockguy - SDL - VS unisystem keys now configable -03-march-2010 - prcokguy - SDL - changed default hotkeys and keys to match w32 -03-march-2010 - prockguy - SDL - fixed dpad/joyhat support -01-march-2010 - adelikat - Movie file format header now has a FDS flag -01-march-2010 - adelikat - win32 - cheats dialog - toggling a cheat in the cheats list now updates the active cheats count -01-march-2010 - adelikat - win32 - a disable movie messages menu item -25-feb-2010 - prockguy - unix netplay is now functional; gtk network gui created -24-feb-2010 - prockguy - GTK - added basic movie controls -24-feb-2010 - prockguy - GTK - added file filters; added Load FDS function -24-feb-2010 - prockguy - GTK - added palette config dialog -23-feb-2010 - prockguy - GTK - added UI elemnts for x/y scale; added lowpass UI option -23-feb-2010 - prockguy - GTK - added GUI for color/tint/hue -23-feb-2010 - prockguy - GTK - implemented sound mixer dialog (for square1, 2, triangle, etc) -22-feb-2010 - prockguy - SDL - ported to SDL 1.3; compatibility maintained with 1.2 -18-feb-2010 - prockguy - GTK - a lot of options added to GTK gui; relatively stable; added GUI for gamepad config and sound config. -02-feb-2010 - ugetab - Win32 - Added window positions bounds checks. Accounts for -32000 positions & less out-of-range too -08-jan-2010 - rheiny - Win32 - Trace Logger - Trace logger now logs the values of the stack pointer register -31-dec-2009 - prg318 - added gtk gui -08-dec-2009 - Zeromus - Fix Name Table Viewer - Fix for use with New PPU -08-dec-2009 - - mart0258 - FDS - show name of missing bios file in error message -07-dec-2009 - qeed - NewPPU - fixed sprite hit before 255 and for non transparent hits only, thanks to dwedit for providing the fix -06-dec-2009 - Zeromus - SDL - disallow --inputcfg gamepad0 and gamepad5 -??-???-2009 - CaH4e3 - fixed mappers 82, 25, 21, and 18. Games such as SD Kiji Blader, Ganbare Goemon Gaiden, and Ganbare Goemon Gaiden 2, Jajamaru Gekimadden are now playable -17-nov-2009 - adelikat - Win32 - Cheats - Pause while active checkbox installed -17-nov-2009 - adelikat - Win32 - Fix debug window so it doesn't crash if unminimized with no game loaded. -13-nov-2009 - mart0258 - Win32 - TASEdit - Added interface functionality (save/load, running TASEdit mid-movie, etc.) -13-nov-2009 - adelikat - made savestate compression togglable -13-nov-2009 - adelikat - made savestate backups togglable -08-nov-2009 - gocha - Win32 - Lua console - added a menu -08-nov-2009 - gocha - change gui.line, gui.box, joypad.get to function like GENS rerecording -08-nov-2009 - gocha - New lua functions: gui.parsecolor, joypad.getup, joypad.getdown, emu.emulating. -08-nov-2009 - CaH4e3 - Fixes for mappers 253 & 226 - fixes games such as Fire Emblem (J) and Fire Emblem Gaiden (J) -08-nov-2009 - CaH4e3 - Fix crashing on game loading for any battery backed roms with mappers from MapInitTab (fixes Esper Dream 2 - Aratanaru Tatakai (J) -04-nov-2009 - adelikat - win32 - debugger - added an auto-load feature - ----r1527 - FCEUX 2.1.2 Released--- ----November 3, 2009--- - -02-nov-2009 - qeed - fixed mapper 226, 76-in-1 seems to work now, also super 42 also seems to work with this fix, but people with save states with this game should make a new one. Since the the save state format for this game was changed a little. -31-oct-2009 - adelikat - win32 - Memwatch - Save Changes prompt - Selecting yes will do quicksave first, save as 2nd (instead of always defaulting to save as) -19-oct-2009 - qeed - Mapper 253 mostly implemented, known game [ES-1064] Qi Long Zhu (C) is mostly playable (some minor graphic glitches). Thanks to VirtualNESEX for reverse engineering this, gil for giving me the mapper src for implementation reference, and Dead_Body for figuring out this game had to use chr-ram -10-oct-2009 - qeed - fixed dragon's lair the mapper 4 europe version in new PPU -10-oct-2009 - zeromus - fixed Tecmo Super Bowl in new PPU -08-oct-2009 - ugetab - win32 - fixed a debugger crash error, Unif/FDS filename issue, and enabled debugger bank display -01-oct-2009 - gocha - win32 - movie play dialog displays movie time based on ~60.1 (~50.1 PAL) instead of 60 & 50 -26-sept-2009 - qeed - fixed action 52 game that was broken in fceux >2.0.3 -16-sept-2009 - ugetab - win32 - Restored DPCM Logging when Code/Data Logger is active -sept-2009 - FatRatKnight - Finally got in that "invert" value for joypad.set. This value simply inverts the player input. Actually, any string will invert it, since we have not used strings for anything else in joypad.set. -15-sept-2009 - FatRatKnight - Reworked how input is taken from lua, and generally everything related to joypad.set and what it affects. Now setting stuff to false will: Prevent user control for exactly one frame, and allow more than one false button as a time. Yeah, bug fixes. Hopefully runs a little faster now. -22-aug-2009 - adelikat - Win32 - Map Hotkeys Dialog - Fixed but where "X" and Alt+F4 would not close dialog -22-aug-2009 - adelikat - Win32 - Added a Save Config File menu item -12-aug-2009 - adelikat - Win32 - Added a menu item to toggle to New PPU -10-aug-2009 - adelikat - fixed bug that caused new movies be created in /movie instead of /movies -08-aug-2009 - qeed - mappers - fixed mapper irq count, dragon ball z 3 -should be playable again. -07-aug-2009 - ugetab - win32 - imported NSF features from FCEU-XDSP-NSF -05-aug-2009 - adelikat - win32 - fixed an erroneous assumption made in 2.1.1 that caused the recent roms menu to be grayed out even when there were recent roms (however, it uncovered an underlying bug in the recent menu saving that needs to be fixed at some point). - ----r1375 - FCEUX 2.1.1--- ----July 29, 2009--- - -01-july-2009 - adelikat - win32 - texthooker - drag & drop for table files -01-july-2009 - adelikat - win32 - drag & drop for cheat (.cht) files -25-jun-2009 - qeed - sound/ppu - fixed the noise value, it seems that the noise logic was shifting the values to the left by 1 when reloading, but this doesnt work for PAL since one of the PAL reload value is odd, so fix the logic and used the old tables. Revert a stupid CPU ignore logic in PPU. Sorry about that. -25-jun-2009 - adelikat - Win32 - CD Logger - Drag and Drop for .cdl files -24-jun-2009 - qeed - sound/ppu - reverted to old noise table value since this seems to get correct sound for double -dragon 2. Also added experimental $2004 reading support to play micro machines with (little) shakes, and fixed some -timing in the new PPU. -24-jun-2009 - adelikat - win32 - memory watch - option to bind to main window, if checked it gives GENS dialog style control, where there is no extra task bar item, and it minimizes when FCEUX is minimized -24-jun-2009 - adelikat - win32 - palette commandline options -24-jun-2009 - adelikat - win32 - Sound Dialog - cleanup, when sound is off, all controls are grayed out -24-jun-2009 - adelikat - win32 - Hex Editor - Drag & Drop for .tbl files -24-jun-2009 - adelikat - win32 - Drag & Drop for .fcm, it converts and then loads the converted movie automatically -24-jun-2009 - adelikat - win32 - Drag & Drop support for palette files -23-jun-2009 - adelikat - win32 - Drag & Drop support for savestates -22-jun-2009 - qeed - Revert IRQ inhibit fix, since this seems to break Dragon - Warrior 4, added palette reading cases for the new PPU. -21-jun-2009 - adelikat - win32 - memwatch - save menu item is grayed if file hasn't changed -20-jun-2009 - adelikat - win32 - memwatch - fixed a regression I made in 2.0.1 that broke the Save As menu item -17-jun-2009 - qeed - Sound core fix, updated with the correct values for the noise and DMC table, - and also fixed the IRQ inhibit behavior for register $4017. Also fixed the CPU - unofficial opcode ATX, ORing with correct constant $FF instead of $EE, as tested - by blargg's. These fixes passes the IRQ flags test from blargg, and also one more - opcode test from blargg's cpu.nes test. -16-jun-2009 - adelikat - sound core fix - square 1 & square 2 volume controls no longer backwards -11-jun-2009 - zeromus - sound core fix, length counters for APU now correct variables -11-jun-2009 - adelikat - Win32 - Hex Editor - changed ROM values again dsiplay as red, saved in the config as RomFreezeColor -06-jun-2009 - rheiny - Fixed reported issue 2746924 (md5_asciistr() doesn't produce correct string) -23-may-2009 - adelikat - win32 - hex editor - freeze/unfreeze ram addresses now causes the colors to update immediately, but only with groups of addresses highlighted at once (single ones still don't yet update) -23-may-2009 - adelikat - win32 - context menu - Save Movie As... menu item (for when a movie is loaded in read+write mode) -23-may-2009 - adelikat - win32 - added opton to remove a recent item to the roms, lua, and movie recent menus -23-may-2009 - adelikat - win32 - Added a remove recent item function and hooked it up to memwatch recent menu, now if a bad recent item is clicked, the user has a choice to remove it from the list -23-may-2009 - adelikat - win32 - Load Last Movie context menu item added -23-may-2009 - adelikat - win32 - Recent Movie Menu added -22-may-2009 - adelikat - win32 - "Disable screen saver" gui option now also diables the monitor powersave -22-may-2009 - adelikat - win32 - Debugger - Step type functions now update other dialogs such as ppu, nametable, code/data, trace logger, etc. -22-may-2009 - adelikat - win32 - Hex Editor - Save Rom As... menu option enabled and implemented -22-may-2009 - adelikat - win32 - Window caption shows the name of the ROM loaded -22-may-2009 - adelikat - win32 - Hex Editor - allowed the user to customize the color scheme by use of RGB values stored in the .cfg file -21-may-2009 - adelikat - win32 - reverted fixedFontHeight to 13 instead of 14. Gave the option of adjusting the height by modifying RowHeightBorder in the .cfg file -21-may-2009 - adelikat - win32 - made fullscreen toggle (Alt+Enter) remappable -15-may-2009 - shinydoofy - sdl - added --subtitles -10-may-2009 - shinydoofy - sdl - fixed Four Score movie playback -02-may-2009 - adelikat - win32 - stop movie at frame x feature - fixed off by 1 error -23-apr-2009 - shinydoofy - sdl - added --ripsubs for converting fm2 movie subtitles to an srt file -15-apr-2009 - shinydoofy - sdl - Lua is optional again, fixed the real issue -14-apr-2009 - punkrockguy - sdl - LUA is NO longer optional, so the SConscripts have been updated to reflect that change. This fixes the mysterious non-working input issue. -12-apr-2009 - shinydoofy - sdl - implemented saving/loading a savestate from a specific file on Alt+S/L -11-apr-2009 - shinydoofy - sdl - implemented starting an FM2 movie on Alt+R -11-apr-2009 - adelikat - made default save slot 0 instead of 1, Win32 - remember last slot used -11-apr-2009 - shinydoofy - sdl - added --pauseframe to pause movie playback on frame x -11-apr-2009 - shinydoofy - sdl - dropped UTFConverter.c from SDL build and added hotkey Q for toggling read-only/read+write movie playback - ---version 2.1.0a released---- -04-apr-2009 - shinydoofy - fixed fcm->fm2 code once again (this time for good, hopefully). Thanks to Bisqwit! -04-apr-2009 - shinydoofy - Reverted UTF8<->UTF32 code changes to fix up the win32 build for now - ----version 2.1.0 released--- -29-mar-2009 - adelikat - Win32 - reverted acmlm's /dll folder change -28-mar-2009 - shinydoofy - sdl - added hotkey Del to toggle mute avi capturing -28-mar-2009 - shinydoofy - sdl - fix fm2 playback and fcm->fm2 conversion crash at the cost of ugly 0x00 bytes behind the author's comment line -28-mar-2009 - adelikat - Lua - added FCEU.poweron() and FCEU.softreset() -27-mar-2009 - shinydoofy - sdl - added --no-config -23-mar-2009 - adelikat - Win32 - blocked "hotkey explosion" by rshift on some laptops -22-mar-2009 - shinydoofy - sdl - added hotkey I and --inputdisplay {0|1|2|4} for toggling input display. -22-mar-2009 - shinydoofy - sdl - added commandline options for sound channels' volumes -22-mar-2009 - shinydoofy - sdl - updated window title -19-mar-2009 - adelikat - Win32 - make Video - windowed mode - disable hardware accel the default setting. Made high quality sound the default setting. -16-mar-2009 - adelikat - Win32 - GUI Dialog - added an option to disable the context menu -15-mar-2009 - adelikat - Lua - added movie.rerecordcount(), movie.length(), movie.getname(), movie.playbeginning(), FCEU.getreadonly(), FCEU.setreadonly() -14-mar-2009 - adelikat - Lua - added movie.active() - returns a bool value based on whether a movie is currently loaded -14-mar-2009 - adelikat - Fixed Joypad.set, it uses 3 values instead of 2 now. True will take control of a button and make it on, False will take control and make it off, and Nil will not take control (allowing the user to press the button) -14-mar-2009 - adelikat - Fix major crash issue where NROM game savestates were writing erroneous information if a non NROM game was loaded prior -13-mar-2009 - adelikat - Closing game / Opening new game resets the frame counter -13-mar-2009 - adelikat - Win32 - Debugger - Scanlines and PPU Pixels are displayed even in vblank (lines 240-261) -12-mar-2009 - shinydoofy - sdl - fixed compilation error and reactivated the mouse pointer in the SDL window -12-mar-2009 - adelikat - Win32 - Trace Logger - fixed bug where user can't scroll the log window while it is auto-updating -11-mar-2009 - adelikat - Win32 - Trace Logger - changed message about F2 pause (left over from FCEUXDSP) to display the current hotkey mapping -11-mar-2009 - adelikat - Added frame counter to savestates -08-mar-2009 - adelikat - Lua - added input.get() function -08-mar-2009 - adelikat - Lua - memory.readbyte will recognize frozen addresses -08-mar-2009 - adelikat - Lua - added FCEU.lagged() function -08-mar-2009 - adelikat - Lua - added zapper.read() function -07-mar-2009 - adelikat - Lua - added FCEU.lagcount() function -04-mar-2009 - adelikat - win32 - Fix bug so that Escape can now be assigned as a hotkey -03-mar-2009 - adelikat - win32 - Fix Directory Overrides so to allow users to have no override. Also fixes directory override reset bug -02-mar-2009 - adelikat - win32 - Drag & Drop for Memwatch dialog (.txt files) -01-mar-2009 - adelikat - win32 - Drag & Drop Lua files -25-feb-2009 - adelikat - win32 - Memwatch - added cancel to save changes? message box -22-feb-2009 - adelikat - win32 - Lua - made speedmode("turbo") turn on turbo (which employs frameskipping) rather than max speed -22-feb-2009 - adelikat - Increased lua gui.text height (and DrawTextTransWH() height) -21-feb-2009 - adelikat - win32 - Lua - Added -lua commandline argment, loads a lua script on startup -21-feb-2009 - adelikat - win32 - Debugger - Added pixel display after scanline display - Thanks to DWEdit for this patch -21-feb-2009 - adelikat - win32 - Debugger - Added Run Line, Run 128 Lines buttons - Thanks to DWEdit for this patch -21-feb-2009 - adelikat - win32 - Message Log - remembers X,Y position -19-feb-2009 - adelikat - win32 - Memory Watch - fixed recent file menu - no longer crashes when attempting to load a non existent recent file -07-feb-2009 - adelikat - win32 - Fix bug in screenshot numbering that caused numbering to not reset when changing ROMs -06-feb-2009 - adelikat - win32 - Hex editor - remembers window size -06-feb-2009 - adelikat - Win32 - sound config dialog - added sliders for individual sound channel volume control -06-feb-2009 - zeromus - Force processor affinity, fixes throttling problem on AMD dualcore machines -06-feb-2009 - adelikat - Sound channels now have individual volume control -01-jan-2009 - adelikat - Win32 - Timing - "disable throttling when sound is off" now only affects FCEUX when sound is off -26-dec-2008 - adelikat - Metadata - remember window position -24-dec-2008 - adelikat - auto-save fixes, prevent loading an auto-save from previous session. Win32 - added flags for enabling auto-save menu item. -24-dec-2008 - adelikat - added undo/redo savestate hotkey. Win32 - made undo/redo default key mapping Ctrl+Z -24-dec-2008 - adelikat - win32 - added Last ROM used context menu item when no game loaded -24-dec-2008 - shinydoofy - sdl - added option to mute FCEUX for avi capturing, check the docs for more detail -23-dec-2008 - adelikat - Win32 - Undo/redo loadstate and Undo/redo savestate context menu items added -23-dec-2008 - adelikat - undo/redo loadstate and undo/redo savestate implemented -22-dec-2008 - adelikat - backupSavestate system added. -22-dec-2008 - shinydoofy - sdl - added Shift+M for toggling automatic movie backups for SDL -22-dec-2008 - adelikat - Movie auto-backup feature implemented -22-dec-2008 - adelikat - win32 - moved movie related menu items to a movie options dialog box -22-dec-2008 - adelikat - Win32 - context menu item "create backup" for backing up movie files -21-dec-2008 - adelikat - Win32 - Name Table Viewer - Refresh value default to 15, Refresh value stored in config file -21-dec-2008 - adelikat - Win32 - PPU Viewer - Refresh value default to 15, Refresh value stored in config file -19-dec-2008 - adelikat - Loadbackup function added, Win32 - Undo Loadstate context menu item -19-dec-2008 - adelikat - Backup savestate is made before loading a state -18-dec-2008 - adelikat - win32 - turbo bypasses sound better if muteturbo is checked -18-dec-2008 - shinydoofy - sdl - fixed compiling errors for SDL due to r1037 -18-dec-2008 - adelikat - win32 - fullscreen mode fixed (both enters and returns to fullscreen just fine) -16-dec-2008 - adelikat - win32 - debugger - added "Restore original window size" button -16-dec-2008 - adelikat - win32 - debugger - fixed SF2073113 - Debugger now has a minimum valid size -15-dec-2008 - adelikat - win32 - cheats - number of active cheats listed, freezing ram addresses in hex editor automatically updates cheats dialog -15-dec-2008 - adelikat - win32 - hexeditor - added minimize & maximize buttons -14-dec-2008 - adelikat - win32 - memwatch - frozen addresses will display as blue -14-dec-2008 - adelikat - win32 - hexeditor - prevent the user from freezing more than 256 addresses at once -14-dec-2008 - adelikat - win32 - memwatch - collapsable to 1 column -08-dec-2008 - adelikat - win32 - stop lua menu item gray if no lua script is running -08-dec-2008 - adelikat - win32 - fix bug where no sound + mute turbo caused chirps when toggling -08-dec-2008 - adelikat - win32 - sound dialog - disabling sound disabled sound options -08-dec-2008 - adelikat - win32 - opening a rom runs closerom first, fixes bug where new sav file was not getting loaded -07-dec-2008 - adelikat - win32 - turbo now employs frame skip -30-nov-2008 - punkrockguy - commit 1000 -30-nov-2008 - punkrockguy - fixed gcc compile error -30-nov-2008 - punkrockguy - moved around some hotkeys to be consistent with docs -30-nov-2008 - punkrockguy - major update to sdl documentation -24-nov-2008 - qfox - win32 - fixed two position checks for memwatch and debugger that could cause these windows to "disappear" (moved far out of reach). -24-nov-2008 - adelikat - win32 - right click context menus installed -24-nov-2008 - adelikat - win32 - added lots of mappable hotkey items as Menu items -23-nov-2008 - adelikat - Win32 - fixed some errors in my AVI directory override code -23-nov-2008 - shinydoofy - movie subs now have a toggle button in the SDL build (F10 by default) -23-nov-2008 - adelikat - movie subtitle system installed -22-nov-2008 - adelikat - Win32 - added help menu item to TASEdit and Hex Editor, Minor TASEdit clean up -22-nov-2008 - adelikat - Win32 - fixed so that turbo works with VBlank sync settings -21-nov-2008 - qfox - Lua - added joypad.write and joypad.get for naming consistency. Added plane display toggle for lua: FCEU.fceu_setrenderplanes(sprites, background) which accepts two boolean args and toggles the drawing of those planes from Lua. Changed movie.framecount() to always return a number, even when no movie is playing. Should return the same number as in view; the number of frames since last reset, if no movie is playing. -17-nov-2008 - adelikat - added Open Cheats hotkey (currently a windows only function) -16-nov-2008 - adelikat - Win32 - menu items that are hotkey mappable show the current hotkey mapping -15-nov-2008 - adelikat - Win32 - memwatch - implemented RamChange() - monitors the behavior of ram addresses -15-nov-2008 - adelikat - Win32 - re-enabled sound buffer time -15-nov-2008 - adelikat - Clip Left and Right sides taken into account when drawing on screen (record/play/pause, lag & frame counters, messages, etc) -15-nov-2008 - adelikat - win32 - Implemented Drap & Drop for movie files -14-nov-2008 - adelikat - win32 Hex Editor - Dump Rom & Dump PPU to file Dialog - uses ROM to build default filename -14-nov-2008 - adelikat - Win32 Memwatch - Save as dialog - uses ROM name to build default memwatch filename if there is no last used memwatch filename -14-nov-2008 - adelikat - Win32 Text Hooker fixes - Init error checking reinstated, save .tht file no longer crashes, Dialog updates as ROM plays, Remembers window position, fix bug where canceling save as produces an error message, Save As produces default filename based on loaded ROM -14-nov-2008 - adelikat - fixed but when aspect correction and special scaling 3x are set, video was getting resized incorrectly -14-nov-2008 - adelikat - fixed a bug introduced in previous commit, frame display toggle now works when no movie is present -12-nov-2008 - adelikat - allowed frame counter to display even with no movie present -11-nov-2008 - punkrockguy - sdl - savestate slots now mappable [2175167] -10-nov-2008 - adelikat - win32 - removed accel keys from main window -10-nov-2008 - adelikat - Win32 - added Open & Close ROM mappable hotkeys, removed accel functions -10-nov-2008 - punkrockguy - improved the sdl sound code; drasticaly improves quality of sound. -09-nov-2008 - adelikat - minor memory watch menu clean up, removed Ctrl+W hotkey for close (and placed Alt+F4 on the menu name) -08-nov-2008 - zeromus - big endian wasnt compiling. fix issues. -02-nov-2008 - shinydoofy - added --fcmconvert for SDL -02-nov-2008 - zeromus - emulua - add rom.readbyte and rom.readbytesigned - - ----version 2.0.3 released--- - -02-nov-2008 - zeromus - fix fcm conversion, recording, and playback of reset and power commands -25-oct-2008 - shinydoofy - added support for AVI creation for SDL, see documentation/Videolog.txt for more -19-oct-2008 - shinydoofy - toggle lag frame counter for SDL, default hotkey F8 -19-oct-2008 - shinydoofy - toggle skipping of lag frames for SDL, default hotkey F6 -19-oct-2008 - shinydoofy - [ 2179829 ] user ability to toggle "bind savestates to movie" added for SDL, default hotkey F2 -19-oct-2008 - adelikat - win32 - added a toggle for binding savestates to movies -18-oct-2008 - adelikat - win32 - added -cfg (config file) command line argument -08-oct-2008 - zeromus - SF [ 2073113 ] Child windows inside debugging window get invalid sizes -08-oct-2008 - zeromus - SF [ 2153843 ] Lua ignores second joypad.set() -24-sep-2008 - punkrockguy318 - made the input config window more usable -24-sep-2008 - punkrockguy318 - --inputcfg can now be used without a filename -24-sep-2008 - punkrockguy318 - [ 2085437 ] should fix issues with missing author field crashing fceux -24-sep-2008 - punkrockguy318 - [ 2047057 ] added uninstall script for gfceux -24-sep-2008 - punkrockguy318 - [ 2062823 ] fixed ppc build errors and added LSB_FIRST option to build scripts -24-sep-2008 - punkrockguy318 - [ 2057006 ] --newppu option added to sdl, disabled by default -24-sep-2008 - punkrockguy318 - [ 2057008 ] lua is now optional, thanks shinydoofy for a patch. also fixed some build issues. -22-sep-2008 - punkrockguy318 - [ 2008437 ] fixed an issue where flawed movie would crash fceux on every startup -21-aug-2008 - punkrockguy318 - sdl - fixed issue where windowed mode would always be set to 32 bpp -18-aug-2008 - zeromus - windows - SF [ 2058942 ] Load state as... does not use the savestate override dir (fixed; now, it does) -18-aug-2008 - zeromus - windows - permit user optionally to proceed through the movie savestate mismatch error condition, in case he knows what he is doing. -18-aug-2008 - zeromus - fix a bug in the savestate recovery code which prevent aborted savestate loads from recovering emulator state correctly. -18-aug-2008 - zeromus - windows - bind a menu option for display framecounter -17-aug-2008 - zeromus - windows - fix problem where replay dialog couldnt work when the process current directory had changed to something other than emulator base directory -17-aug-2008 - zeromus - windows - autoload the only useful rom or movie from an archive, in cases where there is only one -17-aug-2008 - zeromus - gracefully handle non-convertible broken utf-8 text without crashing -17-aug-2008 - zeromus - windows - don't read every archive file when scanning for replay dialog. scan them, and only look for *.fm2 -17-aug-2008 - zeromus - debugger - fix issue where keyboard keys get stuck when switching between debugger window and main window -15-aug-2008 - adelikat - fixed an oversight on my part. Sound config dialog will now look to see if Mute Turbo should be checked - ----version 2.0.2 released--- - -14-aug-2008 - punkrockguy318 - SDL: prevent frame advance from crashing emulator -14-aug-2008 - punkrockguy318 - SDL build scripts now look for lua5.1 and lua (distributions package lua differently) -14-aug-2008 - zeromus - restore savestate error recovery functionality. This should have the side effect of guaranteeing that ( SF [ 2040761 ] Wrong savestate bug - crashes FCEUX) is resolved. -14-aug-2008 - zeromus - SF [ 2047001 ] Low speeds crash FCEUX -14-aug-2008 - zeromus - SF [ 2050371 ] FCM>FM2 converter should release file handle -13-aug-2008 - zeromus - restore ungzipping (and unzipping in sdl) capability which was lost when archive support was added -13-aug-2008 - zeromus - add FORBID breakpoints - regions which block breakpoints from happening if they contain the PC -13-aug-2008 - punkrockguy318 - SDL: fixed --input(1-4) options. input1 and 2 are regular inputs, input3 and 4 are famicom expansion inputs -12-aug-2008 - zeromus - fix SDL configfile woes. configfile now goes to ~/.fceux/fceux.cfg -12-aug-2008 - zeromus - SF [ 2047986 ] palflag 1 in .fm2 files crashes fceux -12-aug-2008 - adelikat - movie replay dialog displays fractions of a second -12-aug-2008 - punkrockguy318 - SDL: fixed segfault when opening .fcm files -12-aug-2008 - punkrockguy318 - SDL: Saner sound defaults for less choppy sound -12-aug-2008 - punkrockguy318 - SF [ 2047050 ] SDL: "--special" option fixed for special video scaling filters -12-aug-2008 - zeromus - SF [ 2046984 ] Player 3 inputs when not used -12-aug-2008 - zeromus - print a special message when trying to open an FCM reminding user to convert. (finishes SF [ 2011832 ] Opening non movie file crashes FCEUX) -12-aug-2008 - zeromus - SF [ 2046985 ] SRAM not wiped on power cycle (during movies) -11-aug-2008 - zeromus - restore IPS patching capability which was lost when archive support was added -11-aug-2008 - zeromus - SF [ 2011550 ] Buffer overflow (change vsprintf to vsnprintf) -11-aug-2008 - zeromus - SF [ 2047004 ] Moviefilenames without extension don't automatically get fm2 -10-aug-2008 - zeromus - upgrade to cah4e3's latest mapper 163&164 code to fix a crash in a game -10-aug-2008 - zeromus - remove cnrom chr rom size limit for homebrew roms -10-aug-2008 - punkrockguy318 - SDL: cleaned up the SConsruct -10-aug-2008 - punkrockguy318 - SDL: fixed issue where fceu would lock up when file dialogs were opened during fullscreen -10-aug-2008 - punkrockguy318 - SDL: fixed bug where fceux would close when file dialogs were closed -10-aug-2008 - punkrockguy318 - SDL: File open dialog is now used to movie playback -10-aug-2008 - punkrockguy318 - SDL: File open wrapper now takes a titlebar argument -10-aug-2008 - punkrockguy318 - SDL: Cleanup of usage -10-aug-2008 - punkrockguy318 - SDL: rename options --no8lim -> --nospritelim and --color -> --ntsccolor -10-aug-2008 - punkrockguy318 - SDL: Screenshots now always prepend the game name. -10-aug-2008 - punkrockguy318 - SDL: Changed default A/B from numpad 2 and 3 to j and k. -10-aug-2008 - punkrockguy318 - SDL: Enable frameskip by default -10-aug-2008 - punkrockguy318 - SDL: Fixed a bug that would crash fceux if the emulation speed was overincreased -10-aug-2008 - punkrockguy318 - SDL: New default hotkeys to more closely match win32 defaults -10-aug-2008 - punkrockguy318 - SDL: Added lua script loading hotkey (f3). Non win32 SDL requires zenity for this to function. -10-aug-2008 - punkrockguy318 - SDL: Build script cleanup; also added option for DEBUG builds. -10-aug-2008 - zeromus - SF [ 2030405 ] Avi recording: no sound b0rks format -10-aug-2008 - zeromus - SF [ 2037878 ] Convert .fcm doesn't do special characters -09-aug-2008 - zeromus - SF [ 2040463 ] Add an "author" text field in the record movie dialog -09-aug-2008 - zeromus - re-enable support for old-format savestates. -09-aug-2008 - zeromus - SF [ 2041944 ] Savestates remember Lua painting -09-aug-2008 - zeromus - support loading movies from archives -08-aug-2008 - adelikat - added input display to the FCEUX main menu -08-aug-2008 - adelikat - fixed the (null) in the default lua directory listing -08-aug-2008 - adelikat - added shift+L as default hotkey for reload lua script -08-aug-2008 - adelikat - removed accel ctrl+x (prevented cut from working in accel dialogs) -08-aug-2008 - zeromus - fiddle with nametable viewer to display correct NT,CHR,ATTR data in more cases (specifically, including some exotic mmc5 cases). -08-aug-2008 - zeromus - fix a new bug in windows build which caused fourscore emulation to fail in some cases -07-aug-2008 - zeromus - add an option to pick a constant color to draw in place of BG when BG rendering is disabled (look for gNoBGFillColor in config; 255 means to use palette[0]) -07-aug-2008 - adelikat - added a mute turbo option in sound config -07-aug-2008 - adelikat - new toggle - frame adv. - lag skip (menu item + hotkey mapping + saved in config) -07-aug-2008 - adelikat - put in -32000 protection on all dialogs that remember x,y -06-aug-2008 - adelikat - change config filename from fceu98.cfg to fceux.cfg -06-aug-2008 - zeromus - add lagcounter and lagflag to savestate -06-aug-2008 - zeromus - SF [ 2040448 ] View Slots bug - does not include new savestate naming -06-aug-2008 - zeromus - restore the debugger snap functionality -06-aug-2008 - zeromus - add memory.readbyterange to emulua -06-aug-2008 - zeromus - auto-fill .fcs extension in save state as dialog -06-aug-2008 - zeromus - mmc5 - 64KB WRAM games now work correctly -06-aug-2008 - zeromus - mmc5 - use of chr A regs for BG in sprite 8x8 mode is fixed -06-aug-2008 - zeromus - debugger - debugger window is now resizeable - ----version 2.0.1 released--- - -04-aug-2008 - reorganize display toggle options in the menu -04-aug-2008 - adelikat - autofire fix -04-aug-2008 - zeromus - homebrew mmc5 games now have 64KB of exwram instead of only 8KB -04-aug-2008 - zeromus - fix crash related to player2 in lua scripts -03-aug-2008 - qfox - fixed player2 in lua scripts - ----version 2.0.0 released--- diff --git a/branches/fceux-2.2.2/documentation/fceux-net-server.6 b/branches/fceux-2.2.2/documentation/fceux-net-server.6 deleted file mode 100644 index a3cf7fd2..00000000 --- a/branches/fceux-2.2.2/documentation/fceux-net-server.6 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" (C) Copyright 2012 Joe Nahmias -.\" -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH FCEUX-NET-SERVER 6 "October 12, 2012" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -fceux-net-server \- FCE Ultra game server -.SH SYNOPSIS -.B fceux-net-server -.RI [ options ] -.SH DESCRIPTION -This manual page documents briefly the -.B fceux-net-server -command. -.PP -\fBfceux-net-server\fP is the game server for multiplayer use of the FCE Ultra -family of NES emulators. This server will first look in -\fI/etc/fceux-server.conf\fP for options. If that file does not exist, it will -use the defaults given here. Any argument given directly will override any -default values. -.SH OPTIONS -These programs follow the usual GNU command line syntax, with long -options starting with two dashes (`-'). -A summary of options is included below. -.TP -.B \-h, \-\-help -Displays a help message. -.TP -.B \-v, \-\-version -Displays the version number and quits. -.TP -.B \-p, \-\-port -Starts server on given port (default = \fI4046\fP). -.TP -.B \-w, \-\-password -Specifies a password for entry. -.TP -.B \-m, \-\-maxclients -Specifies the maximum number of clients allowed to access the -server (default = \fI100\fP). -.TP -.B \-t, \-\-timeout -Specifies the number of seconds before the server times out (default = \fI5\fP). -.TP -.B \-f, \-\-framedivisor -Specifies frame divisor, which controls the number of updates sent to client; -calculated as: 60 / framedivisor = updates per second (default = \fI1\fP). -.TP -.B \-c, \-\-configfile -Loads the given configuration file (default = \fI/etc/fceux\-server.conf\fP). -.SH SEE ALSO -.BR fceux (6), -The -.B FCEUX -project homepage -.RI < http://fceux.com/ >. -.SH AUTHOR -This manual page was written by Joe Nahmias -for the Debian GNU/Linux system (but may be used by others). - diff --git a/branches/fceux-2.2.2/documentation/fceux.6 b/branches/fceux-2.2.2/documentation/fceux.6 deleted file mode 100644 index 98c4182c..00000000 --- a/branches/fceux-2.2.2/documentation/fceux.6 +++ /dev/null @@ -1,353 +0,0 @@ -.\" t Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH FCEUX 6 "June 24, 2012" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -fceux \- An emulator for the original (8-bit) Nintendo / Famicom game console. -.SH SYNOPSIS -.B fceux -.RI [ options ] -"filename" -.SH DESCRIPTION -.B FCEUX -is an emulator for the original (8-bit) Nintendo Entertainment System (NES). -It has a robust color palette rendering engine that is fully customizable, -along with excellent sound and joystick support, and even supports movie -recording and playback. -.SH OPTIONS -.SS Misc. Options -.TP -.B \--no-config {0|1} -Use default config file and do not save to it, when enabled. -.TP -.B \-g {0|1}, \--gamegenie {0|1} -Enable or disable emulated Game Genie. -.TP -.B \--nogui {0|1} -Enable or disable the GTK GUI. -.TP -.B \--loadlua FILE -Loads lua script from filename FILE. -.SS Emulation Options -.TP -.B \--pal {0|1} -Enable or disable PAL mode. -.SS Input Options -.TP -.B \-i DEV, \--inputcfg DEV -Configures input device DEV on startup. -Devices: gamepad powerpad hypershot quizking -.TP -.B \--input{1|2} DEV -Set which input device to emulate for input 1 or 2. -Devices: gamepad zapper powerpad.0 powerpad.1 arkanoid -.TP -.B \--input{3|4} DEV -Set the famicom expansion device to emulate for input 3 or 4. -Devices: quizking hypershot mahjong toprider ftrainer familykeyboard -oekakids arkanoid shadow bworld 4player -.TP -.B \--inputdisplay {0|1} -Enable or disable input display. -.TP -.B \--fourscore {0|1} -Enable or disable fourscore emulation. -.SS Graphics Options -.TP -.B \--newppu {0|1} -Enable or disable the new PPU core. (WARNING: May break savestates) -.TP -.B \--frameskip NUM -Set NUM of frames to skip per emulated frame. -.TP -.B \--clipsides {0|1} -Enable or disable clipping of the leftmost and rightmost 8 columns of -the video output. -.TP -.B \--slstart SCANLINE -Set the first scanline to be rendered. -.TP -.B \--slend SCANLINE -Set the last scanline to be rendered. -.TP -.B \--nospritelim {0|1} -When set to 0, this disables the normal 8 sprites per scanline limitation. -When set to 1, this enables the normal 8 sprites per scanline limitation. -NOTE: Yes, this option is 'backwards'. -.TP -.B \-x XRES, \--xres XRES -Set horizontal resolution for full screen mode. -.TP -.B \-y YRES, \--yres YRES -Set vertical resolution for full screen mode. -.TP -.B \--doublebuf {0|1} -Enable or disable double buffering. -.TP -.B \--autoscale {0|1} -Enable or disable autoscaling in fullscreen. -.TP -.B \--keepratio {0|1} -Keep native NES aspect ratio when autoscaling. -.TP -.B \--{x|y}scale VAL -Multiply width/height by VAL. -(Real numbers > 0 with OpenGL, otherwise integers > 0). -.TP -.B \--{x|y}stretch {0|1} -Stretch to fill surface on x/y axis (OpenGL only). -.TP -.B \-b {8|16|24|32}, \--bpp {8|16|24|32} -Set bits per pixel. -.TP -.B \--opengl {0|1} -Enable or disable OpenGL support. -.TP -.B \--openglip {0|1} -Enable or disable OpenGL linear interpolation. -.TP -.B \-f {0|1}, \--fullscreen {0|1} -Enable or disable full-screen mode. -.TP -.B \--noframe {0|1} -Hide title bar and window decorations. -.TP -.B \--special {1-4} -Use special video scaling filters. -(1 = hq2x 2 = Scale2x 3 = NTSC 2x 4 = hq3x 5 = Scale3x) -.TP -.B \-p FILE, \--palette FILE -Use the custom palette in FILE. -.TP -.B \--ntsccolor {0|1} -Enable or disable NTSC NES colors. -.TP -.B \--tint VAL -Set the NTSC tint. -.TP -.B \--hue VAL -Set the NTSC hue. -.SS Sound Options -.TP -.B \-s {0|1}, \--sound {0|1} -Enable or disable sound. -.TP -.B \--soundrate RATE -Set the sound playback sample rate (0 == off?). -.TP -.B \--soundq {0|1|2} -Set sound quality. (0 = Low 1 = High 2 = Very High) -.TP -.B \--soundbufsize MS -Set sound buffer size to MS milliseconds. -.TP -.B \--volume {0-256} -Sets the sound volume to the given value, where 256 is max volume. -.TP -.B \--trianglevol {0-256} -Sets the sound volume of the triangle wave to the given value, where 256 is max volume. -.TP -.B \--square1vol {0-256} -Sets the sound volume of square wave 1 to the given value, where 256 is max volume. -.TP -.B \--square2vol {0-256} -Sets the sound volume of square wave 2 to the given value, where 256 is max volume. -.TP -.B \--noisevol {0-256} -Sets the sound volume of the noise generator to the given value, where 256 is max volume. -.TP -.B \--lowpass {0|1} -Enables or disables lowpass filtering of the sound. -.TP -.B \--soundrecord FILE -Record sound to file FILE. -.SS Movie Options -.TP -.B \--playmov FILE -Play back a recorded FCM/FM2 movie from filename FILE. -.TP -.B \--pauseframe FRAME -Pause movie playback at frame FRAME. -.TP -.B \--moviemsg {0|1} -Enable or disable movie messages. -.TP -.B \--fcmconvert FILE -Convert fcm movie file FILE to fm2. -.TP -.B \--ripsubs FILE -Convert movie's subtitles to srt. -.TP -.B \--subtitles {0|1} -Enable or disable subtitle display. -.SS Networking Options -.TP -.B \-n SRV, \--net SRV -Connect to server SRV for TCP/IP network play. -.TP -.B \--port PORT -Use TCP/IP port PORT for network play. -.TP -.B \-u NICK, \--user NICK -Set the nickname to use in network play. -.TP -.B \-w PASS, \--pass PASS -Set password to use for connecting to the server. -.TP -.B \-k NETKEY, \--netkey NETKEY -Use string NETKEY to create a unique session for the game loaded. -.TP -.B \--players NUM -Set the number of local players. -.TP -.B \--rp2mic {0|1} -If enabled, replace Port 2 Start with microphone (Famicom). -.TP -.B \--videolog c -Calls mencoder to grab the video and audio streams to encode them. Check the documentation for more on this.? -.TP -.B \--mute {0|1} -Mutes FCEUX while still passing the audio stream to mencoder. -.TP -.SH KEYBOARD COMMANDS -.B FCEUX -has a number of commands available within the emulator. -It also includes default keyboard bindings when emulating game pads or power pads. -.SS Gamepad Keyboard Bindings -.TS -center box; -cb | cb, c | ci. -NES Gamepad Keyboard -= -Up Keypad Up -Down Keypad Down -Left Keypad Left -Right Keypad Right -A F -B D -Select S -Start Enter -.TE -.SS Other Commands -.PP -.TP 15 -.BI -Toggle full-screen mode. -.TP 15 -.BI -Cheat menu (command-line only). -.TP 15 -.BI -Toggle savestate binding to movies. -.TP 15 -.BI -Load LUA script. -.TP 15 -.BI -Toggles background rendering. -.TP 15 -.BI -Save game state into current slot (set using number keys). -.TP 15 -.BI -Restore game state from current slot (set using number keys). -.TP 15 -.BI -Toggle movie subtitles. -.TP 15 -.BI -Reset NES. -.TP 15 -.BI -Save screen snapshot. -.TP 15 -.BI Shift + -Beging recording video. -.TP 15 -.BI Shift + -Load recorded video. -.TP 15 -.BI 0-9 -Select save state slot. -.TP 15 -.BI Page Up/Page Down -Select next/previous state. -.TP 15 -.BI \- -Decrease emulation speed. -.TP 15 -.BI = -Increase emulation speed. -.TP 15 -.BI Tab -Hold for turbo emulation speed. -.TP 15 -.BI Pause -Pause emulation. -.TP 15 -.BI \e -Advance a single frame. -.TP 15 -.BI . -Toggle movie frame counter. -.TP 15 -.BI , -Toggle input display. -.TP 15 -.BI q -Toggle movie read-only. -.TP 15 -.BI ' -Advance a single frame. -.TP 15 -.BI / -Lag counter display. -.TP 15 -.BI Delete -Frame advance lag skip display. -.TP 15 -.BR -Quit -.B FCEUX. -.SS VS Unisystem Commands -.PP -.TP 15 -.BI -Insert coin. -.TP 15 -.BI -Show/Hide dip switches. -.TP 15 -.BI 1-8 -Toggle dip switches (when dip switches are shown). -.SS Famicom Disk System Commands -.PP -.TP 15 -.BI -Select disk and disk side. -.TP 15 -.BI -Eject or insert disk. -.TP -.I http://fceux.com/ -The -.B FCEUX -project homepage. -.SH AUTHOR -This manual page was written by Joe Nahmias , -Lukas Sabota and Alexander Toresson - for the Debian GNU/Linux system -(but may be used by others). diff --git a/branches/fceux-2.2.2/output/fceux.chm b/branches/fceux-2.2.2/output/fceux.chm deleted file mode 100644 index 93fd80bc..00000000 Binary files a/branches/fceux-2.2.2/output/fceux.chm and /dev/null differ diff --git a/branches/fceux-2.2.2/src/asm.cpp b/branches/fceux-2.2.2/src/asm.cpp deleted file mode 100644 index 5131a14d..00000000 --- a/branches/fceux-2.2.2/src/asm.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/// \file -/// \brief 6502 assembler and disassembler - -#include "types.h" -#include "utils/xstring.h" -#include "debug.h" -#include "asm.h" -#include "x6502.h" - -#include -#include -#include -///assembles the string to an instruction located at addr, storing opcodes in output buffer -int Assemble(unsigned char *output, int addr, char *str) { - //unsigned char opcode[3] = { 0,0,0 }; - output[0] = output[1] = output[2] = 0; - char astr[128],ins[4]; - int len = strlen(str); - if ((!len) || (len > 0x127)) return 1; - - strcpy(astr,str); - str_ucase(astr); - sscanf(astr,"%3s",ins); //get instruction - if (strlen(ins) != 3) return 1; - strcpy(astr,strstr(astr,ins)+3); //heheh, this is probably a bad idea, but let's do it anyway! - if ((astr[0] != ' ') && (astr[0] != 0)) return 1; - - //remove all whitespace - str_strip(astr,STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF); - - //repair syntax - chr_replace(astr,'[','('); //brackets - chr_replace(astr,']',')'); - chr_replace(astr,'{','('); - chr_replace(astr,'}',')'); - chr_replace(astr,';',0); //comments - str_replace(astr,"0X","$"); //miscellaneous - - //This does the following: - // 1) Sets opcode[0] on success, else returns 1. - // 2) Parses text in *astr to build the rest of the assembled - // data in 'opcode', else returns 1 on error. - - if (!strlen(astr)) { - //Implied instructions - if (!strcmp(ins,"BRK")) output[0] = 0x00; - else if (!strcmp(ins,"PHP")) output[0] = 0x08; - else if (!strcmp(ins,"ASL")) output[0] = 0x0A; - else if (!strcmp(ins,"CLC")) output[0] = 0x18; - else if (!strcmp(ins,"PLP")) output[0] = 0x28; - else if (!strcmp(ins,"ROL")) output[0] = 0x2A; - else if (!strcmp(ins,"SEC")) output[0] = 0x38; - else if (!strcmp(ins,"RTI")) output[0] = 0x40; - else if (!strcmp(ins,"PHA")) output[0] = 0x48; - else if (!strcmp(ins,"LSR")) output[0] = 0x4A; - else if (!strcmp(ins,"CLI")) output[0] = 0x58; - else if (!strcmp(ins,"RTS")) output[0] = 0x60; - else if (!strcmp(ins,"PLA")) output[0] = 0x68; - else if (!strcmp(ins,"ROR")) output[0] = 0x6A; - else if (!strcmp(ins,"SEI")) output[0] = 0x78; - else if (!strcmp(ins,"DEY")) output[0] = 0x88; - else if (!strcmp(ins,"TXA")) output[0] = 0x8A; - else if (!strcmp(ins,"TYA")) output[0] = 0x98; - else if (!strcmp(ins,"TXS")) output[0] = 0x9A; - else if (!strcmp(ins,"TAY")) output[0] = 0xA8; - else if (!strcmp(ins,"TAX")) output[0] = 0xAA; - else if (!strcmp(ins,"CLV")) output[0] = 0xB8; - else if (!strcmp(ins,"TSX")) output[0] = 0xBA; - else if (!strcmp(ins,"INY")) output[0] = 0xC8; - else if (!strcmp(ins,"DEX")) output[0] = 0xCA; - else if (!strcmp(ins,"CLD")) output[0] = 0xD8; - else if (!strcmp(ins,"INX")) output[0] = 0xE8; - else if (!strcmp(ins,"NOP")) output[0] = 0xEA; - else if (!strcmp(ins,"SED")) output[0] = 0xF8; - else return 1; - } - else { - //Instructions with Operands - if (!strcmp(ins,"ORA")) output[0] = 0x01; - else if (!strcmp(ins,"ASL")) output[0] = 0x06; - else if (!strcmp(ins,"BPL")) output[0] = 0x10; - else if (!strcmp(ins,"JSR")) output[0] = 0x20; - else if (!strcmp(ins,"AND")) output[0] = 0x21; - else if (!strcmp(ins,"BIT")) output[0] = 0x24; - else if (!strcmp(ins,"ROL")) output[0] = 0x26; - else if (!strcmp(ins,"BMI")) output[0] = 0x30; - else if (!strcmp(ins,"EOR")) output[0] = 0x41; - else if (!strcmp(ins,"LSR")) output[0] = 0x46; - else if (!strcmp(ins,"JMP")) output[0] = 0x4C; - else if (!strcmp(ins,"BVC")) output[0] = 0x50; - else if (!strcmp(ins,"ADC")) output[0] = 0x61; - else if (!strcmp(ins,"ROR")) output[0] = 0x66; - else if (!strcmp(ins,"BVS")) output[0] = 0x70; - else if (!strcmp(ins,"STA")) output[0] = 0x81; - else if (!strcmp(ins,"STY")) output[0] = 0x84; - else if (!strcmp(ins,"STX")) output[0] = 0x86; - else if (!strcmp(ins,"BCC")) output[0] = 0x90; - else if (!strcmp(ins,"LDY")) output[0] = 0xA0; - else if (!strcmp(ins,"LDA")) output[0] = 0xA1; - else if (!strcmp(ins,"LDX")) output[0] = 0xA2; - else if (!strcmp(ins,"BCS")) output[0] = 0xB0; - else if (!strcmp(ins,"CPY")) output[0] = 0xC0; - else if (!strcmp(ins,"CMP")) output[0] = 0xC1; - else if (!strcmp(ins,"DEC")) output[0] = 0xC6; - else if (!strcmp(ins,"BNE")) output[0] = 0xD0; - else if (!strcmp(ins,"CPX")) output[0] = 0xE0; - else if (!strcmp(ins,"SBC")) output[0] = 0xE1; - else if (!strcmp(ins,"INC")) output[0] = 0xE6; - else if (!strcmp(ins,"BEQ")) output[0] = 0xF0; - else return 1; - - { - //Parse Operands - // It's not the sexiest thing ever, but it works well enough! - - //TODO: - // Add branches. - // Fix certain instructions. (Setting bits is not 100% perfect.) - // Fix instruction/operand matching. (Instructions like "jmp ($94),Y" are no good!) - // Optimizations? - int tmpint; - char tmpchr,tmpstr[20]; - - if (sscanf(astr,"#$%2X%c",&tmpint,&tmpchr) == 1) { //#Immediate - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of #Immediate - case 0x66: case 0x81: case 0x84: case 0x86: - case 0xC6: case 0xE6: - return 1; - default: - //cheap hack for certain instructions - switch (output[0]) { - case 0xA0: case 0xA2: case 0xC0: case 0xE0: - break; - default: - output[0] |= 0x08; - break; - } - output[1] = tmpint; - break; - } - } - else if (sscanf(astr,"$%4X%c",&tmpint,&tmpchr) == 1) { //Absolute, Zero Page, Branch, or Jump - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - break; - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - tmpint -= (addr+2); - if ((tmpint < -128) || (tmpint > 127)) return 1; - output[1] = (tmpint & 0xFF); - break; - //return 1; //FIX ME - default: - if (tmpint > 0xFF) { //Absolute - output[0] |= 0x0C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - output[0] |= 0x04; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else if (sscanf(astr,"$%4X%s",&tmpint,tmpstr) == 2) { //Absolute,X, Zero Page,X, Absolute,Y or Zero Page,Y - if (!strcmp(tmpstr,",X")) { //Absolute,X or Zero Page,X - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x24: case 0x86: case 0xA2: case 0xC0: //Other instructions incapable of Absolute,X or Zero Page,X - case 0xE0: - return 1; - default: - if (tmpint > 0xFF) { //Absolute - if (output[0] == 0x84) return 1; //No STY Absolute,X! - output[0] |= 0x1C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - output[0] |= 0x14; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else if (!strcmp(tmpstr,",Y")) { //Absolute,Y or Zero Page,Y - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Absolute,Y or Zero Page,Y - case 0x66: case 0x84: case 0x86: case 0xA0: - case 0xC0: case 0xC6: case 0xE0: case 0xE6: - return 1; - case 0xA2: //cheap hack for LDX - output[0] |= 0x04; - default: - if (tmpint > 0xFF) { //Absolute - if (output[0] == 0x86) return 1; //No STX Absolute,Y! - output[0] |= 0x18; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - if ((output[0] != 0x86) && (output[0] != 0xA2)) return 1; //only STX and LDX Absolute,Y! - output[0] |= 0x10; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else return 1; - } - else if (sscanf(astr,"($%4X%s",&tmpint,tmpstr) == 2) { //Jump (Indirect), (Indirect,X) or (Indirect),Y - switch (output[0]) { - case 0x20: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Jump (Indirect), (Indirect,X) or (Indirect),Y - case 0x66: case 0x84: case 0x86: case 0xA0: - case 0xA2: case 0xC0: case 0xC6: case 0xE0: - case 0xE6: - return 1; - default: - if ((!strcmp(tmpstr,")")) && (output[0] == 0x4C)) { //Jump (Indirect) - output[0] = 0x6C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else if ((!strcmp(tmpstr,",X)")) && (tmpint <= 0xFF) && (output[0] != 0x4C)) { //(Indirect,X) - output[1] = (tmpint & 0xFF); - } - else if ((!strcmp(tmpstr,"),Y")) && (tmpint <= 0xFF) && (output[0] != 0x4C)) { //(Indirect),Y - output[0] |= 0x10; - output[1] = (tmpint & 0xFF); - } - else return 1; - break; - } - } - else return 1; - } - } - - return 0; -} - -///disassembles the opcodes in the buffer assuming the provided address. Uses GetMem() and 6502 current registers to query referenced values. returns a static string buffer. -char *Disassemble(int addr, uint8 *opcode) { - static char str[64]={0},chr[5]={0}; - uint16 tmp,tmp2; - - //these may be replaced later with passed-in values to make a lighter-weight disassembly mode that may not query the referenced values - #define RX (X.X) - #define RY (X.Y) - - switch (opcode[0]) { - #define relative(a) { \ - if (((a)=opcode[1])&0x80) (a) = addr-(((a)-1)^0xFF); \ - else (a)+=addr; \ - } - #define absolute(a) { \ - (a) = opcode[1] | opcode[2]<<8; \ - } - #define zpIndex(a,i) { \ - (a) = opcode[1]+(i); \ - } - #define indirectX(a) { \ - (a) = (opcode[1]+RX)&0xFF; \ - (a) = GetMem((a)) | (GetMem((a)+1))<<8; \ - } - #define indirectY(a) { \ - (a) = GetMem(opcode[1]) | (GetMem(opcode[1]+1))<<8; \ - (a) += RY; \ - } - - - //odd, 1-byte opcodes - case 0x00: strcpy(str,"BRK"); break; - case 0x08: strcpy(str,"PHP"); break; - case 0x0A: strcpy(str,"ASL"); break; - case 0x18: strcpy(str,"CLC"); break; - case 0x28: strcpy(str,"PLP"); break; - case 0x2A: strcpy(str,"ROL"); break; - case 0x38: strcpy(str,"SEC"); break; - case 0x40: strcpy(str,"RTI"); break; - case 0x48: strcpy(str,"PHA"); break; - case 0x4A: strcpy(str,"LSR"); break; - case 0x58: strcpy(str,"CLI"); break; - case 0x60: strcpy(str,"RTS"); break; - case 0x68: strcpy(str,"PLA"); break; - case 0x6A: strcpy(str,"ROR"); break; - case 0x78: strcpy(str,"SEI"); break; - case 0x88: strcpy(str,"DEY"); break; - case 0x8A: strcpy(str,"TXA"); break; - case 0x98: strcpy(str,"TYA"); break; - case 0x9A: strcpy(str,"TXS"); break; - case 0xA8: strcpy(str,"TAY"); break; - case 0xAA: strcpy(str,"TAX"); break; - case 0xB8: strcpy(str,"CLV"); break; - case 0xBA: strcpy(str,"TSX"); break; - case 0xC8: strcpy(str,"INY"); break; - case 0xCA: strcpy(str,"DEX"); break; - case 0xD8: strcpy(str,"CLD"); break; - case 0xE8: strcpy(str,"INX"); break; - case 0xEA: strcpy(str,"NOP"); break; - case 0xF8: strcpy(str,"SED"); break; - - //(Indirect,X) - case 0x01: strcpy(chr,"ORA"); goto _indirectx; - case 0x21: strcpy(chr,"AND"); goto _indirectx; - case 0x41: strcpy(chr,"EOR"); goto _indirectx; - case 0x61: strcpy(chr,"ADC"); goto _indirectx; - case 0x81: strcpy(chr,"STA"); goto _indirectx; - case 0xA1: strcpy(chr,"LDA"); goto _indirectx; - case 0xC1: strcpy(chr,"CMP"); goto _indirectx; - case 0xE1: strcpy(chr,"SBC"); goto _indirectx; - _indirectx: - indirectX(tmp); - sprintf(str,"%s ($%02X,X) @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - break; - - //Zero Page - case 0x05: strcpy(chr,"ORA"); goto _zeropage; - case 0x06: strcpy(chr,"ASL"); goto _zeropage; - case 0x24: strcpy(chr,"BIT"); goto _zeropage; - case 0x25: strcpy(chr,"AND"); goto _zeropage; - case 0x26: strcpy(chr,"ROL"); goto _zeropage; - case 0x45: strcpy(chr,"EOR"); goto _zeropage; - case 0x46: strcpy(chr,"LSR"); goto _zeropage; - case 0x65: strcpy(chr,"ADC"); goto _zeropage; - case 0x66: strcpy(chr,"ROR"); goto _zeropage; - case 0x84: strcpy(chr,"STY"); goto _zeropage; - case 0x85: strcpy(chr,"STA"); goto _zeropage; - case 0x86: strcpy(chr,"STX"); goto _zeropage; - case 0xA4: strcpy(chr,"LDY"); goto _zeropage; - case 0xA5: strcpy(chr,"LDA"); goto _zeropage; - case 0xA6: strcpy(chr,"LDX"); goto _zeropage; - case 0xC4: strcpy(chr,"CPY"); goto _zeropage; - case 0xC5: strcpy(chr,"CMP"); goto _zeropage; - case 0xC6: strcpy(chr,"DEC"); goto _zeropage; - case 0xE4: strcpy(chr,"CPX"); goto _zeropage; - case 0xE5: strcpy(chr,"SBC"); goto _zeropage; - case 0xE6: strcpy(chr,"INC"); goto _zeropage; - _zeropage: - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%04X = #$%02X", chr,opcode[1],GetMem(opcode[1])); - // ################################## End of SP CODE ########################### - break; - - //#Immediate - case 0x09: strcpy(chr,"ORA"); goto _immediate; - case 0x29: strcpy(chr,"AND"); goto _immediate; - case 0x49: strcpy(chr,"EOR"); goto _immediate; - case 0x69: strcpy(chr,"ADC"); goto _immediate; - //case 0x89: strcpy(chr,"STA"); goto _immediate; //baka, no STA #imm!! - case 0xA0: strcpy(chr,"LDY"); goto _immediate; - case 0xA2: strcpy(chr,"LDX"); goto _immediate; - case 0xA9: strcpy(chr,"LDA"); goto _immediate; - case 0xC0: strcpy(chr,"CPY"); goto _immediate; - case 0xC9: strcpy(chr,"CMP"); goto _immediate; - case 0xE0: strcpy(chr,"CPX"); goto _immediate; - case 0xE9: strcpy(chr,"SBC"); goto _immediate; - _immediate: - sprintf(str,"%s #$%02X", chr,opcode[1]); - break; - - //Absolute - case 0x0D: strcpy(chr,"ORA"); goto _absolute; - case 0x0E: strcpy(chr,"ASL"); goto _absolute; - case 0x2C: strcpy(chr,"BIT"); goto _absolute; - case 0x2D: strcpy(chr,"AND"); goto _absolute; - case 0x2E: strcpy(chr,"ROL"); goto _absolute; - case 0x4D: strcpy(chr,"EOR"); goto _absolute; - case 0x4E: strcpy(chr,"LSR"); goto _absolute; - case 0x6D: strcpy(chr,"ADC"); goto _absolute; - case 0x6E: strcpy(chr,"ROR"); goto _absolute; - case 0x8C: strcpy(chr,"STY"); goto _absolute; - case 0x8D: strcpy(chr,"STA"); goto _absolute; - case 0x8E: strcpy(chr,"STX"); goto _absolute; - case 0xAC: strcpy(chr,"LDY"); goto _absolute; - case 0xAD: strcpy(chr,"LDA"); goto _absolute; - case 0xAE: strcpy(chr,"LDX"); goto _absolute; - case 0xCC: strcpy(chr,"CPY"); goto _absolute; - case 0xCD: strcpy(chr,"CMP"); goto _absolute; - case 0xCE: strcpy(chr,"DEC"); goto _absolute; - case 0xEC: strcpy(chr,"CPX"); goto _absolute; - case 0xED: strcpy(chr,"SBC"); goto _absolute; - case 0xEE: strcpy(chr,"INC"); goto _absolute; - _absolute: - absolute(tmp); - sprintf(str,"%s $%04X = #$%02X", chr,tmp,GetMem(tmp)); - break; - - //branches - case 0x10: strcpy(chr,"BPL"); goto _branch; - case 0x30: strcpy(chr,"BMI"); goto _branch; - case 0x50: strcpy(chr,"BVC"); goto _branch; - case 0x70: strcpy(chr,"BVS"); goto _branch; - case 0x90: strcpy(chr,"BCC"); goto _branch; - case 0xB0: strcpy(chr,"BCS"); goto _branch; - case 0xD0: strcpy(chr,"BNE"); goto _branch; - case 0xF0: strcpy(chr,"BEQ"); goto _branch; - _branch: - relative(tmp); - sprintf(str,"%s $%04X", chr,tmp); - break; - - //(Indirect),Y - case 0x11: strcpy(chr,"ORA"); goto _indirecty; - case 0x31: strcpy(chr,"AND"); goto _indirecty; - case 0x51: strcpy(chr,"EOR"); goto _indirecty; - case 0x71: strcpy(chr,"ADC"); goto _indirecty; - case 0x91: strcpy(chr,"STA"); goto _indirecty; - case 0xB1: strcpy(chr,"LDA"); goto _indirecty; - case 0xD1: strcpy(chr,"CMP"); goto _indirecty; - case 0xF1: strcpy(chr,"SBC"); goto _indirecty; - _indirecty: - indirectY(tmp); - sprintf(str,"%s ($%02X),Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - break; - - //Zero Page,X - case 0x15: strcpy(chr,"ORA"); goto _zeropagex; - case 0x16: strcpy(chr,"ASL"); goto _zeropagex; - case 0x35: strcpy(chr,"AND"); goto _zeropagex; - case 0x36: strcpy(chr,"ROL"); goto _zeropagex; - case 0x55: strcpy(chr,"EOR"); goto _zeropagex; - case 0x56: strcpy(chr,"LSR"); goto _zeropagex; - case 0x75: strcpy(chr,"ADC"); goto _zeropagex; - case 0x76: strcpy(chr,"ROR"); goto _zeropagex; - case 0x94: strcpy(chr,"STY"); goto _zeropagex; - case 0x95: strcpy(chr,"STA"); goto _zeropagex; - case 0xB4: strcpy(chr,"LDY"); goto _zeropagex; - case 0xB5: strcpy(chr,"LDA"); goto _zeropagex; - case 0xD5: strcpy(chr,"CMP"); goto _zeropagex; - case 0xD6: strcpy(chr,"DEC"); goto _zeropagex; - case 0xF5: strcpy(chr,"SBC"); goto _zeropagex; - case 0xF6: strcpy(chr,"INC"); goto _zeropagex; - _zeropagex: - zpIndex(tmp,RX); - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%02X,X @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - // ################################## End of SP CODE ########################### - break; - - //Absolute,Y - case 0x19: strcpy(chr,"ORA"); goto _absolutey; - case 0x39: strcpy(chr,"AND"); goto _absolutey; - case 0x59: strcpy(chr,"EOR"); goto _absolutey; - case 0x79: strcpy(chr,"ADC"); goto _absolutey; - case 0x99: strcpy(chr,"STA"); goto _absolutey; - case 0xB9: strcpy(chr,"LDA"); goto _absolutey; - case 0xBE: strcpy(chr,"LDX"); goto _absolutey; - case 0xD9: strcpy(chr,"CMP"); goto _absolutey; - case 0xF9: strcpy(chr,"SBC"); goto _absolutey; - _absolutey: - absolute(tmp); - tmp2=(tmp+RY); - sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); - break; - - //Absolute,X - case 0x1D: strcpy(chr,"ORA"); goto _absolutex; - case 0x1E: strcpy(chr,"ASL"); goto _absolutex; - case 0x3D: strcpy(chr,"AND"); goto _absolutex; - case 0x3E: strcpy(chr,"ROL"); goto _absolutex; - case 0x5D: strcpy(chr,"EOR"); goto _absolutex; - case 0x5E: strcpy(chr,"LSR"); goto _absolutex; - case 0x7D: strcpy(chr,"ADC"); goto _absolutex; - case 0x7E: strcpy(chr,"ROR"); goto _absolutex; - case 0x9D: strcpy(chr,"STA"); goto _absolutex; - case 0xBC: strcpy(chr,"LDY"); goto _absolutex; - case 0xBD: strcpy(chr,"LDA"); goto _absolutex; - case 0xDD: strcpy(chr,"CMP"); goto _absolutex; - case 0xDE: strcpy(chr,"DEC"); goto _absolutex; - case 0xFD: strcpy(chr,"SBC"); goto _absolutex; - case 0xFE: strcpy(chr,"INC"); goto _absolutex; - _absolutex: - absolute(tmp); - tmp2=(tmp+RX); - sprintf(str,"%s $%04X,X @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); - break; - - //jumps - case 0x20: strcpy(chr,"JSR"); goto _jump; - case 0x4C: strcpy(chr,"JMP"); goto _jump; - case 0x6C: absolute(tmp); sprintf(str,"JMP ($%04X) = $%04X", tmp,GetMem(tmp)|GetMem(tmp+1)<<8); break; - _jump: - absolute(tmp); - sprintf(str,"%s $%04X", chr,tmp); - break; - - //Zero Page,Y - case 0x96: strcpy(chr,"STX"); goto _zeropagey; - case 0xB6: strcpy(chr,"LDX"); goto _zeropagey; - _zeropagey: - zpIndex(tmp,RY); - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - // ################################## End of SP CODE ########################### - break; - - //UNDEFINED - default: strcpy(str,"ERROR"); break; - - } - - return str; -} diff --git a/branches/fceux-2.2.2/src/boards/01-222.cpp b/branches/fceux-2.2.2/src/boards/01-222.cpp deleted file mode 100644 index 64d2c960..00000000 --- a/branches/fceux-2.2.2/src/boards/01-222.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * TXC mappers, originally much complex banksitching - * - * 01-22111-000 (05-00002-010) (132, 22211) - MGC-001 Qi Wang - * 01-22110-000 (52S ) - MGC-002 2-in-1 Gun - * 01-22111-100 (02-00002-010) (173 ) - MGC-008 Mahjong Block - * (079 ) - MGC-012 Poke Block - * 01-22110-200 (05-00002-010) (036 ) - MGC-014 Strike Wolf - * 01-22000-400 (05-00002-010) (036 ) - MGC-015 Policeman - * 01-22017-000 (05-PT017-080) (189 ) - MGC-017 Thunder Warrior - * 01-11160-000 (04-02310-000) ( , 11160) - MGC-023 6-in-1 - * 01-22270-000 (05-00002-010) (132, 22211) - MGC-xxx Creatom - * 01-22200-400 (------------) (079 ) - ET.03 F-15 City War - * (172 ) - 1991 Du Ma Racing - * - */ - -#include "mapinc.h" - -static uint8 reg[4], cmd, is172, is173; -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { &cmd, 1, "CMD" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, (reg[2] >> 2) & 1); - if (is172) - setchr8((((cmd ^ reg[2]) >> 3) & 2) | (((cmd ^ reg[2]) >> 5) & 1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to - // rearrange CHR banks for normal UNIF board and mapper 172 is unneccessary - else - setchr8(reg[2] & 3); -} - -static DECLFW(UNL22211WriteLo) { -// FCEU_printf("bs %04x %02x\n",A,V); - reg[A & 3] = V; -} - -static DECLFW(UNL22211WriteHi) { -// FCEU_printf("bs %04x %02x\n",A,V); - cmd = V; - Sync(); -} - -static DECLFR(UNL22211ReadLo) { - return (reg[1] ^ reg[2]) | (is173 ? 0x01 : 0x40); -// if(reg[3]) -// return reg[2]; -// else -// return X.DB; -} - -static void UNL22211Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4100, 0x4100, UNL22211ReadLo); - SetWriteHandler(0x4100, 0x4103, UNL22211WriteLo); - SetWriteHandler(0x8000, 0xFFFF, UNL22211WriteHi); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNL22211_Init(CartInfo *info) { - is172 = 0; - is173 = 0; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper172_Init(CartInfo *info) { - is172 = 1; - is173 = 0; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper173_Init(CartInfo *info) { - is172 = 0; - is173 = 1; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/fceux-2.2.2/src/boards/112.cpp b/branches/fceux-2.2.2/src/boards/112.cpp deleted file mode 100644 index 6c184b12..00000000 --- a/branches/fceux-2.2.2/src/boards/112.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * NTDEC, ASDER games - * - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd, bank; -static uint8 *WRAM = NULL; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { &mirror, 1, "MIRR" }, - { &bank, 1, "BANK" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirror ^ 1); - setprg8(0x8000, reg[0]); - setprg8(0xA000, reg[1]); - setchr2(0x0000, (reg[2] >> 1)); - setchr2(0x0800, (reg[3] >> 1)); - setchr1(0x1000, ((bank & 0x10) << 4) | reg[4]); - setchr1(0x1400, ((bank & 0x20) << 3) | reg[5]); - setchr1(0x1800, ((bank & 0x40) << 2) | reg[6]); - setchr1(0x1C00, ((bank & 0x80) << 1) | reg[7]); -} - -static DECLFW(M112Write) { - switch (A) { - case 0xe000: mirror = V & 1; Sync();; break; - case 0x8000: cmd = V & 7; break; - case 0xa000: reg[cmd] = V; Sync(); break; - case 0xc000: bank = V; Sync(); break; - } -} - -static void M112Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M112Power(void) { - bank = 0; - setprg16(0xC000, ~0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M112Write); - SetWriteHandler(0x4020, 0x5FFF, M112Write); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper112_Init(CartInfo *info) { - info->Power = M112Power; - info->Close = M112Close; - GameStateRestore = StateRestore; - WRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartPRGMapping(0x10, WRAM, 8192, 1); - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/12in1.cpp b/branches/fceux-2.2.2/src/boards/12in1.cpp deleted file mode 100644 index 15f6c079..00000000 --- a/branches/fceux-2.2.2/src/boards/12in1.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * 7-in-1 Darkwing Duck, Snake, MagicBlock (PCB marked as "12 in 1") - */ - -#include "mapinc.h" - -static uint8 reg[4]; -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { 0 } -}; - -static void Sync(void) { - uint8 bank = (reg[3] & 3) << 3; - setchr4(0x0000, (reg[1] >> 3) | (bank << 2)); - setchr4(0x1000, (reg[2] >> 3) | (bank << 2)); - if (reg[3] & 8) { - setprg32(0x8000, ((reg[2] & 7) >> 1) | bank); - } else { - setprg16(0x8000, (reg[1] & 7) | bank); - setprg16(0xc000, 7 | bank); - } - setmirror(((reg[3] & 4) >> 2) ^ 1); -} - -static DECLFW(BMC12IN1Write) { - switch (A) { - case 0xafff: reg[0] = V; break; - case 0xbfff: reg[1] = V; break; - case 0xdfff: reg[2] = V; break; - case 0xefff: reg[3] = V; break; - } - Sync(); -} - -static void BMC12IN1Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, BMC12IN1Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void BMC12IN1_Init(CartInfo *info) { - info->Power = BMC12IN1Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/15.cpp b/branches/fceux-2.2.2/src/boards/15.cpp deleted file mode 100644 index 4aee608a..00000000 --- a/branches/fceux-2.2.2/src/boards/15.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint16 latchea; -static uint8 latched; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static SFORMAT StateRegs[] = -{ - { &latchea, 2, "AREG" }, - { &latched, 1, "DREG" }, - { 0 } -}; - -static void Sync(void) { - int i; - setmirror(((latched >> 6) & 1) ^ 1); - switch (latchea) { - case 0x8000: - for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7)); - break; - case 0x8002: - for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7)); - break; - case 0x8001: - case 0x8003: - for (i = 0; i < 4; i++) { - unsigned int b; - b = latched & 0x7F; - if (i >= 2 && !(latchea & 0x2)) - b = 0x7F; - setprg8(0x8000 + (i << 13), (i & 1) + ((b << 1) ^ (latched >> 7))); - } - break; - } -} - -static DECLFW(M15Write) { - latchea = A; - latched = V; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -static void M15Power(void) { - latchea = 0x8000; - latched = 0; - setchr8(0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M15Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - Sync(); -} - -static void M15Reset(void) { - latchea = 0x8000; - latched = 0; - Sync(); -} - -static void M15Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper15_Init(CartInfo *info) { - info->Power = M15Power; - info->Reset = M15Reset; - info->Close = M15Close; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/fceux-2.2.2/src/boards/156.cpp b/branches/fceux-2.2.2/src/boards/156.cpp deleted file mode 100644 index d682f305..00000000 --- a/branches/fceux-2.2.2/src/boards/156.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chrlo[8], chrhi[8], prg, mirr, mirrisused = 0; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &prg, 1, "PREG" }, - { chrlo, 8, "CRGL" }, - { chrhi, 8, "CRGH" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - uint32 i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chrlo[i] | (chrhi[i] << 8)); - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, prg); - setprg16(0xC000, ~0); - if (mirrisused) - setmirror(mirr ^ 1); - else - setmirror(MI_0); -} - -static DECLFW(M156Write) { - switch (A) { - case 0xC000: - case 0xC001: - case 0xC002: - case 0xC003: chrlo[A & 3] = V; Sync(); break; - case 0xC004: - case 0xC005: - case 0xC006: - case 0xC007: chrhi[A & 3] = V; Sync(); break; - case 0xC008: - case 0xC009: - case 0xC00A: - case 0xC00B: chrlo[4 + (A & 3)] = V; Sync(); break; - case 0xC00C: - case 0xC00D: - case 0xC00E: - case 0xC00F: chrhi[4 + (A & 3)] = V; Sync(); break; - case 0xC010: prg = V; Sync(); break; - case 0xC014: mirr = V; mirrisused = 1; Sync(); break; - } -} - -static void M156Reset(void) { - uint32 i; - for (i = 0; i < 8; i++) { - chrlo[i] = 0; - chrhi[i] = 0; - } - prg = 0; - mirr = 0; - mirrisused = 0; -} - -static void M156Power(void) { - M156Reset(); - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0xC000, 0xCFFF, M156Write); -} - -static void M156Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper156_Init(CartInfo *info) { - info->Reset = M156Reset; - info->Power = M156Power; - info->Close = M156Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/164.cpp b/branches/fceux-2.2.2/src/boards/164.cpp deleted file mode 100644 index 7cde0a3a..00000000 --- a/branches/fceux-2.2.2/src/boards/164.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * It seems that 162/163/164 mappers are the same mapper with just different - * mapper modes enabled or disabled in software or hardware, need more nanjing - * carts - */ - -#include "mapinc.h" - -static uint8 laststrobe, trigger; -static uint8 reg[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static writefunc pcmwrite; - -static void (*WSync)(void); - -static SFORMAT StateRegs[] = -{ - { &laststrobe, 1, "STB" }, - { &trigger, 1, "TRG" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, (reg[0] << 4) | (reg[1] & 0xF)); - setchr8(0); -} - -static void StateRestore(int version) { - WSync(); -} - -static DECLFR(ReadLow) { - switch (A & 0x7700) { - case 0x5100: return reg[2] | reg[0] | reg[1] | reg[3] ^ 0xff; break; - case 0x5500: - if (trigger) - return reg[2] | reg[1]; // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games - else - return 0; - } - return 4; -} - -static void M163HB(void) { - if (reg[1] & 0x80) { - if (scanline == 239) { - setchr4(0x0000, 0); - setchr4(0x1000, 0); - } else if (scanline == 127) { - setchr4(0x0000, 1); - setchr4(0x1000, 1); - } -/* - if(scanline>=127) // Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it - { - setchr4(0x0000,1); - setchr4(0x1000,1); - } - else - { - setchr4(0x0000,0); - setchr4(0x1000,0); - } -*/ - } -} - -static DECLFW(Write) { - switch (A & 0x7300) { - case 0x5100: reg[0] = V; WSync(); break; - case 0x5000: reg[1] = V; WSync(); break; - case 0x5300: reg[2] = V; break; - case 0x5200: reg[3] = V; WSync(); break; - } -} - -static void Power(void) { - memset(reg, 0, 8); - reg[1] = 0xFF; - SetWriteHandler(0x5000, 0x5FFF, Write); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -static void Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper164_Init(CartInfo *info) { - info->Power = Power; - info->Close = Close; - WSync = Sync; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -static DECLFW(Write2) { - if (A == 0x5101) { - if (laststrobe && !V) { - trigger ^= 1; - } - laststrobe = V; - } else if (A == 0x5100 && V == 6) //damn thoose protected games - setprg32(0x8000, 3); - else - switch (A & 0x7300) { - case 0x5200: reg[0] = V; WSync(); break; - case 0x5000: reg[1] = V; WSync(); if (!(reg[1] & 0x80) && (scanline < 128)) setchr8(0); /* setchr8(0); */ break; - case 0x5300: reg[2] = V; break; - case 0x5100: reg[3] = V; WSync(); break; - } -} - -static void Power2(void) { - memset(reg, 0, 8); - laststrobe = 1; - pcmwrite = GetWriteHandler(0x4011); - SetReadHandler(0x5000, 0x5FFF, ReadLow); - SetWriteHandler(0x5000, 0x5FFF, Write2); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -void Mapper163_Init(CartInfo *info) { - info->Power = Power2; - info->Close = Close; - WSync = Sync; - GameHBIRQHook = M163HB; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -static void Sync3(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - switch (reg[3] & 7) { - case 0: - case 2: setprg32(0x8000, (reg[0] & 0xc) | (reg[1] & 2) | ((reg[2] & 0xf) << 4)); break; - case 1: - case 3: setprg32(0x8000, (reg[0] & 0xc) | (reg[2] & 0xf) << 4); break; - case 4: - case 6: setprg32(0x8000, (reg[0] & 0xe) | ((reg[1] >> 1) & 1) | ((reg[2] & 0xf) << 4)); break; - case 5: - case 7: setprg32(0x8000, (reg[0] & 0xf) | ((reg[2] & 0xf) << 4)); break; - } -} - -static DECLFW(Write3) { -// FCEU_printf("bs %04x %02x\n",A,V); - reg[(A >> 8) & 3] = V; - WSync(); -} - -static void Power3(void) { - reg[0] = 3; - reg[1] = 0; - reg[2] = 0; - reg[3] = 7; - SetWriteHandler(0x5000, 0x5FFF, Write3); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -void UNLFS304_Init(CartInfo *info) { - info->Power = Power3; - info->Close = Close; - WSync = Sync3; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/168.cpp b/branches/fceux-2.2.2/src/boards/168.cpp deleted file mode 100644 index 5ec8e897..00000000 --- a/branches/fceux-2.2.2/src/boards/168.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setchr4r(0x10, 0x0000, 0); - setchr4r(0x10, 0x1000, reg & 0x0f); - setprg16(0x8000, reg >> 6); - setprg16(0xc000, ~0); -} - -static DECLFW(M168Write) { - reg = V; - Sync(); -} - -static DECLFW(M168Dummy) { -} - -static void M168Power(void) { - reg = 0; - Sync(); - SetWriteHandler(0x4020, 0x7fff, M168Dummy); - SetWriteHandler(0xB000, 0xB000, M168Write); - SetWriteHandler(0xF000, 0xF000, M168Dummy); - SetWriteHandler(0xF080, 0xF080, M168Dummy); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void MNNNClose(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper168_Init(CartInfo *info) { - info->Power = M168Power; - info->Close = MNNNClose; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); - - CHRRAMSIZE = 8192 * 8; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); -} diff --git a/branches/fceux-2.2.2/src/boards/176.cpp b/branches/fceux-2.2.2/src/boards/176.cpp deleted file mode 100644 index 37309eb3..00000000 --- a/branches/fceux-2.2.2/src/boards/176.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * Copyright (C) 2012 FCEUX team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -extern uint32 ROM_size; - -static uint8 prg[4], chr, sbw, we_sram; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[]= -{ - {prg, 4, "PRG"}, - {&chr, 1, "CHR"}, - {&sbw, 1, "SBW"}, - {0} -}; - -static void Sync(void) -{ - setprg8r(0x10,0x6000,0); - setprg8(0x8000,prg[0]); - setprg8(0xA000,prg[1]); - setprg8(0xC000,prg[2]); - setprg8(0xE000,prg[3]); - - setchr8(chr); -} - -static DECLFW(M176Write_5001) -{ - printf("%04X = $%02X\n",A,V); - if(sbw) - { - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - } - Sync(); -} - -static DECLFW(M176Write_5010) -{ - printf("%04X = $%02X\n",A,V); - if(V == 0x24) sbw = 1; - Sync(); -} - -static DECLFW(M176Write_5011) -{ - printf("%04X = $%02X\n",A,V); - V >>= 1; - if(sbw) - { - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - } - Sync(); -} - -static DECLFW(M176Write_5FF1) -{ - printf("%04X = $%02X\n",A,V); - V >>= 1; - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - Sync(); -} - -static DECLFW(M176Write_5FF2) -{ - printf("%04X = $%02X\n",A,V); - chr = V; - Sync(); -} - -static DECLFW(M176Write_A001) -{ - we_sram = V & 0x03; -} - -static DECLFW(M176Write_WriteSRAM) -{ -// if(we_sram) - CartBW(A,V); -} - -static void M176Power(void) -{ - SetReadHandler(0x6000,0x7fff,CartBR); - SetWriteHandler(0x6000,0x7fff,M176Write_WriteSRAM); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0xA001,0xA001,M176Write_A001); - SetWriteHandler(0x5001,0x5001,M176Write_5001); - SetWriteHandler(0x5010,0x5010,M176Write_5010); - SetWriteHandler(0x5011,0x5011,M176Write_5011); - SetWriteHandler(0x5ff1,0x5ff1,M176Write_5FF1); - SetWriteHandler(0x5ff2,0x5ff2,M176Write_5FF2); - - we_sram = 0; - sbw = 0; - prg[0] = 0; - prg[1] = 1; - prg[2] = (ROM_size-2)&63; - prg[3] = (ROM_size-1)&63; - Sync(); -} - - -static void M176Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper176_Init(CartInfo *info) -{ - info->Power=M176Power; - info->Close=M176Close; - - GameStateRestore=StateRestore; - - WRAMSIZE=8192; - WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/177.cpp b/branches/fceux-2.2.2/src/boards/177.cpp deleted file mode 100644 index 04fd9c84..00000000 --- a/branches/fceux-2.2.2/src/boards/177.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, reg & 0x1f); - setmirror(((reg & 0x20) >> 5) ^ 1); -} - -static DECLFW(M177Write) { - reg = V; - Sync(); -} - -static void M177Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M177Write); -} - -static void M177Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper177_Init(CartInfo *info) { - info->Power = M177Power; - info->Close = M177Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/178.cpp b/branches/fceux-2.2.2/src/boards/178.cpp deleted file mode 100644 index cfd0392d..00000000 --- a/branches/fceux-2.2.2/src/boards/178.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2013 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * DSOUNDV1/FL-TR8MA boards (32K WRAM, 8/16M), 178 mapper boards (8K WRAM, 4/8M) - * Various Education Cartridges - * - */ - -#include "mapinc.h" - -static uint8 reg[4]; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -// SND Registers -static uint8 pcm_enable = 0; -static int16 pcm_latch = 0x3F6, pcm_clock = 0x3F6; -static writefunc pcmwrite; - -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { 0 } -}; - -static int16 step_size[49] = { - 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, - 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, - 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, - 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552 -}; //49 items -static int32 step_adj[16] = { -1, -1, -1, -1, 2, 5, 7, 9, -1, -1, -1, -1, 2, 5, 7, 9 }; - -//decode stuff -static int32 jedi_table[16 * 49]; -static int32 acc = 0; //ADPCM accumulator, initial condition must be 0 -static int32 decstep = 0; //ADPCM decoding step, initial condition must be 0 - -static void jedi_table_init() { - int step, nib; - - for (step = 0; step < 49; step++) { - for (nib = 0; nib < 16; nib++) { - int value = (2 * (nib & 0x07) + 1) * step_size[step] / 8; - jedi_table[step * 16 + nib] = ((nib & 0x08) != 0) ? -value : value; - } - } -} - -static uint8 decode(uint8 code) { - acc += jedi_table[decstep + code]; - if ((acc & ~0x7ff) != 0) // acc is > 2047 - acc |= ~0xfff; - else acc &= 0xfff; - decstep += step_adj[code & 7] * 16; - if (decstep < 0) decstep = 0; - if (decstep > 48 * 16) decstep = 48 * 16; - return (acc >> 8) & 0xff; -} - -static void Sync(void) { - uint32 sbank = reg[1] & 0x7; - uint32 bbank = reg[2]; - setchr8(0); - setprg8r(0x10, 0x6000, reg[3] & 3); - if (reg[0] & 2) { // UNROM mode - setprg16(0x8000, (bbank << 3) | sbank); - if (reg[0] & 4) - setprg16(0xC000, (bbank << 3) | 6 | (reg[1] & 1)); - else - setprg16(0xC000, (bbank << 3) | 7); - } else { // NROM mode - uint32 bank = (bbank << 3) | sbank; - if (reg[0] & 4) { - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } else - setprg32(0x8000, bank >> 1); - } - setmirror((reg[0] & 1) ^ 1); -} - -static DECLFW(M178Write) { - reg[A & 3] = V; -// FCEU_printf("cmd %04x:%02x\n", A, V); - Sync(); -} - -static DECLFW(M178WriteSnd) { - if (A == 0x5800) { - if (V & 0xF0) { - pcm_enable = 1; -// pcmwrite(0x4011, (V & 0xF) << 3); - pcmwrite(0x4011, decode(V & 0xf)); - } else - pcm_enable = 0; - } else - FCEU_printf("misc %04x:%02x\n", A, V); -} - -static DECLFR(M178ReadSnd) { - if (A == 0x5800) - return (X.DB & 0xBF) | ((pcm_enable ^ 1) << 6); - else - return X.DB; -} - -static void M178Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = 0; - Sync(); - pcmwrite = GetWriteHandler(0x4011); - SetWriteHandler(0x4800, 0x4fff, M178Write); - SetWriteHandler(0x5800, 0x5fff, M178WriteSnd); - SetReadHandler(0x5800, 0x5fff, M178ReadSnd); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xffff, CartBR); -} - -static void M178SndClk(int a) { - if (pcm_enable) { - pcm_latch -= a; - if (pcm_latch <= 0) { - pcm_latch += pcm_clock; - pcm_enable = 0; - } - } -} - -static void M178Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper178_Init(CartInfo *info) { - info->Power = M178Power; - info->Close = M178Close; - GameStateRestore = StateRestore; - MapIRQHook = M178SndClk; - - jedi_table_init(); - - WRAMSIZE = 32768; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/18.cpp b/branches/fceux-2.2.2/src/boards/18.cpp deleted file mode 100644 index dcec0dc1..00000000 --- a/branches/fceux-2.2.2/src/boards/18.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[4], creg[8]; -static uint8 IRQa, mirr; -static int32 IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - if (mirr & 2) - setmirror(MI_0); - else - setmirror(mirr & 1); -} - -static DECLFW(M18WriteIRQ) { - switch (A & 0xF003) { - case 0xE000: IRQLatch &= 0xFFF0; IRQLatch |= (V & 0x0f) << 0x0; break; - case 0xE001: IRQLatch &= 0xFF0F; IRQLatch |= (V & 0x0f) << 0x4; break; - case 0xE002: IRQLatch &= 0xF0FF; IRQLatch |= (V & 0x0f) << 0x8; break; - case 0xE003: IRQLatch &= 0x0FFF; IRQLatch |= (V & 0x0f) << 0xC; break; - case 0xF000: IRQCount = IRQLatch; break; - case 0xF001: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF002: mirr = V & 3; Sync(); break; - } -} - -static DECLFW(M18WritePrg) { - uint32 i = ((A >> 1) & 1) | ((A - 0x8000) >> 11); - preg[i] &= (0xF0) >> ((A & 1) << 2); - preg[i] |= (V & 0xF) << ((A & 1) << 2); - Sync(); -} - -static DECLFW(M18WriteChr) { - uint32 i = ((A >> 1) & 1) | ((A - 0xA000) >> 11); - creg[i] &= (0xF0) >> ((A & 1) << 2); - creg[i] |= (V & 0xF) << ((A & 1) << 2); - Sync(); -} - -static void M18Power(void) { - IRQa = 0; - preg[0] = 0; - preg[1] = 1; - preg[2] = ~1; - preg[3] = ~0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0x9FFF, M18WritePrg); - SetWriteHandler(0xA000, 0xDFFF, M18WriteChr); - SetWriteHandler(0xE000, 0xFFFF, M18WriteIRQ); -} - -static void M18IRQHook(int a) { - if (IRQa && IRQCount) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = 0; - IRQa = 0; - } - } -} - -static void M18Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper18_Init(CartInfo *info) { - info->Power = M18Power; - info->Close = M18Close; - MapIRQHook = M18IRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/fceux-2.2.2/src/boards/186.cpp b/branches/fceux-2.2.2/src/boards/186.cpp deleted file mode 100644 index 137beaa9..00000000 --- a/branches/fceux-2.2.2/src/boards/186.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Family Study Box by Fukutake Shoten - */ - -#include "mapinc.h" - -static uint8 SWRAM[3072]; -static uint8 *WRAM = NULL; -static uint8 regs[4]; - -static SFORMAT StateRegs[] = -{ - { regs, 4, "DREG" }, - { SWRAM, 3072, "SWRM" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, regs[0] >> 6); - setprg16(0x8000, regs[1]); - setprg16(0xc000, 0); -} - -static DECLFW(M186Write) { - if (A & 0x4203) regs[A & 3] = V; - Sync(); -} - -static DECLFR(M186Read) { - switch (A) { - case 0x4200: return 0x00; break; - case 0x4201: return 0x00; break; - case 0x4202: return 0x40; break; - case 0x4203: return 0x00; break; - } - return 0xFF; -} - -static DECLFR(ASWRAM) { - return(SWRAM[A - 0x4400]); -} -static DECLFW(BSWRAM) { - SWRAM[A - 0x4400] = V; -} - -static void M186Power(void) { - setchr8(0); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, CartBW); - SetReadHandler(0x4200, 0x43FF, M186Read); - SetWriteHandler(0x4200, 0x43FF, M186Write); - SetReadHandler(0x4400, 0x4FFF, ASWRAM); - SetWriteHandler(0x4400, 0x4FFF, BSWRAM); - regs[0] = regs[1] = regs[2] = regs[3]; - Sync(); -} - -static void M186Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M186Restore(int version) { - Sync(); -} - -void Mapper186_Init(CartInfo *info) { - info->Power = M186Power; - info->Close = M186Close; - GameStateRestore = M186Restore; - WRAM = (uint8*)FCEU_gmalloc(32768); - SetupCartPRGMapping(0x10, WRAM, 32768, 1); - AddExState(WRAM, 32768, 0, "WRAM"); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/225.cpp b/branches/fceux-2.2.2/src/boards/225.cpp deleted file mode 100644 index 9df7d518..00000000 --- a/branches/fceux-2.2.2/src/boards/225.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 prot[4], prg, mode, chr, mirr; - -static SFORMAT StateRegs[] = -{ - { prot, 4, "PROT" }, - { &prg, 1, "PRG" }, - { &chr, 1, "CHR" }, - { &mode, 1, "MODE" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - if (mode) { - setprg16(0x8000, prg); - setprg16(0xC000, prg); - } else - setprg32(0x8000, prg >> 1); - setchr8(chr); - setmirror(mirr); -} - -static DECLFW(M225Write) { - uint32 bank = (A >> 14) & 1; - mirr = (A >> 13) & 1; - mode = (A >> 12) & 1; - chr = (A & 0x3f) | (bank << 6); - prg = ((A >> 6) & 0x3f) | (bank << 6); - Sync(); -} - -static DECLFW(M225LoWrite) { -} - -static DECLFR(M225LoRead) { - return 0; -} - -static void M225Power(void) { - prg = 0; - mode = 0; - Sync(); - SetReadHandler(0x5000, 0x5FFF, M225LoRead); - SetWriteHandler(0x5000, 0x5FFF, M225LoWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M225Write); -} - -static void M225Reset(void) { - prg = 0; - mode = 0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper225_Init(CartInfo *info) { - info->Reset = M225Reset; - info->Power = M225Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/246.cpp b/branches/fceux-2.2.2/src/boards/246.cpp deleted file mode 100644 index 2c46acc7..00000000 --- a/branches/fceux-2.2.2/src/boards/246.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 regs[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg2r(0x10, 0x6800, 0); - setprg8(0x8000, regs[0]); - setprg8(0xA000, regs[1]); - setprg8(0xC000, regs[2]); - setprg8(0xE000, regs[3]); - setchr2(0x0000, regs[4]); - setchr2(0x0800, regs[5]); - setchr2(0x1000, regs[6]); - setchr2(0x1800, regs[7]); -} - -static DECLFW(M246Write) { - regs[A & 7] = V; - Sync(); -} - -static void M246Power(void) { - regs[0] = regs[1] = regs[2] = regs[3] = ~0; - Sync(); - SetWriteHandler(0x6000, 0x67FF, M246Write); - SetReadHandler(0x6800, 0x6FFF, CartBR); - SetWriteHandler(0x6800, 0x6FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void M246Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper246_Init(CartInfo *info) { - info->Power = M246Power; - info->Close = M246Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 2048; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/252.cpp b/branches/fceux-2.2.2/src/boards/252.cpp deleted file mode 100644 index 2c4b24b1..00000000 --- a/branches/fceux-2.2.2/src/boards/252.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 creg[8], preg[2]; -static int32 IRQa, IRQCount, IRQClock, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { creg, 8, "CREG" }, - { preg, 2, "PREG" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { &IRQClock, 4, "IRQK" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xa000, preg[1]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) - if ((creg[i] == 6) || (creg[i] == 7)) - setchr1r(0x10, i << 10, creg[i] & 1); - else - setchr1(i << 10, creg[i]); -} - -static DECLFW(M252Write) { - if ((A >= 0xB000) && (A <= 0xEFFF)) { - uint8 ind = ((((A & 8) | (A >> 8)) >> 3) + 2) & 7; - uint8 sar = A & 4; - creg[ind] = (creg[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - Sync(); - } else - switch (A & 0xF00C) { - case 0x8000: - case 0x8004: - case 0x8008: - case 0x800C: preg[0] = V; Sync(); break; - case 0xA000: - case 0xA004: - case 0xA008: - case 0xA00C: preg[1] = V; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF004: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF008: X6502_IRQEnd(FCEU_IQEXT); IRQClock = 0; IRQCount = IRQLatch; IRQa = V & 2; break; - } -} - -static void M252Power(void) { - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M252Write); -} - -static void M252IRQ(int a) { - #define LCYCS 341 - if (IRQa) { - IRQClock += a * 3; - if (IRQClock >= LCYCS) { - while (IRQClock >= LCYCS) { - IRQClock -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void M252Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - if (CHRRAM) - FCEU_gfree(CHRRAM); - WRAM = CHRRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper252_Init(CartInfo *info) { - info->Power = M252Power; - info->Close = M252Close; - MapIRQHook = M252IRQ; - - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/253.cpp b/branches/fceux-2.2.2/src/boards/253.cpp deleted file mode 100644 index e79662a7..00000000 --- a/branches/fceux-2.2.2/src/boards/253.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chrlo[8], chrhi[8], prg[2], mirr, vlock; -static int32 IRQa, IRQCount, IRQLatch, IRQClock; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { chrlo, 8, "CHRL" }, - { chrhi, 8, "CHRH" }, - { prg, 2, "PRGR" }, - { &mirr, 1, "MIRR" }, - { &vlock, 1, "VLCK" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { &IRQClock, 4, "IRQK" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, prg[0]); - setprg8(0xa000, prg[1]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) { - uint32 chr = chrlo[i] | (chrhi[i] << 8); - if (((chrlo[i] == 4) || (chrlo[i] == 5)) && !vlock) - setchr1r(0x10, i << 10, chr & 1); - else - setchr1(i << 10, chr); - } - switch (mirr) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M253Write) { - if ((A >= 0xB000) && (A <= 0xE00C)) { - uint8 ind = ((((A & 8) | (A >> 8)) >> 3) + 2) & 7; - uint8 sar = A & 4; - uint8 clo = (chrlo[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - chrlo[ind] = clo; - if (ind == 0) { - if (clo == 0xc8) - vlock = 0; - else if (clo == 0x88) - vlock = 1; - } - if (sar) - chrhi[ind] = V >> 4; - Sync(); - } else - switch (A) { - case 0x8010: prg[0] = V; Sync(); break; - case 0xA010: prg[1] = V; Sync(); break; - case 0x9400: mirr = V & 3; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF004: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF008: X6502_IRQEnd(FCEU_IQEXT); IRQClock = 0; IRQCount = IRQLatch; IRQa = V & 2; break; - } -} - -static void M253Power(void) { - vlock = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M253Write); -} - -static void M253Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - if (CHRRAM) - FCEU_gfree(CHRRAM); - WRAM = CHRRAM = NULL; -} - -static void M253IRQ(int a) { - #define LCYCS 341 - if (IRQa) { - IRQClock += a * 3; - if (IRQClock >= LCYCS) { - while (IRQClock >= LCYCS) { - IRQClock -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper253_Init(CartInfo *info) { - info->Power = M253Power; - info->Close = M253Close; - MapIRQHook = M253IRQ; - GameStateRestore = StateRestore; - - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/28.cpp b/branches/fceux-2.2.2/src/boards/28.cpp deleted file mode 100644 index c787b8c3..00000000 --- a/branches/fceux-2.2.2/src/boards/28.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - Copyright (C) 2012 FCEUX team - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file 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 the this software. If not, see . -*/ - -#include "mapinc.h" - -// http://wiki.nesdev.com/w/index.php/INES_Mapper_028 - -//config -static int prg_mask_16k; - -// state -uint8 reg; -uint8 chr; -uint8 prg; -uint8 mode; -uint8 outer; - -void SyncMirror() -{ - switch (mode & 3) - { - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - } -} - -void Mirror(uint8 value) -{ - if ((mode & 2) == 0) - { - mode &= 0xfe; - mode |= value >> 4 & 1; - } - SyncMirror(); -} - - -static void Sync() -{ - int prglo; - int prghi; - - int outb = outer << 1; - //this can probably be rolled up, but i have no motivation to do so - //until it's been tested - switch (mode & 0x3c) - { - //32K modes - case 0x00: - case 0x04: - prglo = outb; - prghi = outb | 1; - break; - case 0x10: - case 0x14: - prglo = outb & ~2 | prg << 1 & 2; - prghi = outb & ~2 | prg << 1 & 2 | 1; - break; - case 0x20: - case 0x24: - prglo = outb & ~6 | prg << 1 & 6; - prghi = outb & ~6 | prg << 1 & 6 | 1; - break; - case 0x30: - case 0x34: - prglo = outb & ~14 | prg << 1 & 14; - prghi = outb & ~14 | prg << 1 & 14 | 1; - break; - //bottom fixed modes - case 0x08: - prglo = outb; - prghi = outb | prg & 1; - break; - case 0x18: - prglo = outb; - prghi = outb & ~2 | prg & 3; - break; - case 0x28: - prglo = outb; - prghi = outb & ~6 | prg & 7; - break; - case 0x38: - prglo = outb; - prghi = outb & ~14 | prg & 15; - break; - //top fixed modes - case 0x0c: - prglo = outb | prg & 1; - prghi = outb | 1; - break; - case 0x1c: - prglo = outb & ~2 | prg & 3; - prghi = outb | 1; - break; - case 0x2c: - prglo = outb & ~6 | prg & 7; - prghi = outb | 1; - break; - case 0x3c: - prglo = outb & ~14 | prg & 15; - prghi = outb | 1; - break; - } - prglo &= prg_mask_16k; - prghi &= prg_mask_16k; - - setprg16(0x8000, prglo); - setprg16(0xC000, prghi); - setchr8(chr); -} - -static DECLFW(WriteEXP) -{ - uint32 addr = A; - uint8 value = V; - reg = value & 0x81; -} - -static DECLFW(WritePRG) -{ - uint32 addr = A; - uint8 value = V; - switch (reg) - { - case 0x00: - chr = value & 3; - Mirror(value); - break; - case 0x01: - prg = value & 15; - Mirror(value); - Sync(); - break; - case 0x80: - mode = value & 63; - SyncMirror(); - Sync(); - break; - case 0x81: - outer = value & 63; - Sync(); - break; - } -} - - - -static void M28Reset(void) -{ - outer = 63; - prg = 15; - Sync(); -} - - -static void M28Power(void) -{ - prg_mask_16k = PRGsize[0] - 1; - - //EXP - SetWriteHandler(0x5000,0x5FFF,WriteEXP); - - //PRG - SetWriteHandler(0x8000,0xFFFF,WritePRG); - SetReadHandler(0x8000,0xFFFF,CartBR); - - //WRAM - SetReadHandler(0x6000,0x7FFF,CartBR); - SetWriteHandler(0x6000,0x7FFF,CartBW); - - M28Reset(); -} - -static void M28Close(void) -{ -} - -static SFORMAT StateRegs[]= -{ - {®, 1, "REG"}, - {&chr, 1, "CHR"}, - {&prg, 1, "PRG"}, - {&mode, 1, "MODE"}, - {&outer, 1, "OUTR"}, - {0} -}; - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper28_Init(CartInfo* info) -{ - info->Power=M28Power; - info->Reset=M28Reset; - info->Close=M28Close; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/32.cpp b/branches/fceux-2.2.2/src/boards/32.cpp deleted file mode 100644 index 0c34402e..00000000 --- a/branches/fceux-2.2.2/src/boards/32.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[2], creg[8], mirr; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - uint16 swap = ((mirr & 2) << 13); - setmirror((mirr & 1) ^ 1); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000 ^ swap, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000 ^ swap, ~1); - setprg8(0xE000, ~0); - uint8 i; - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); -} - -static DECLFW(M32Write0) { - preg[0] = V; - Sync(); -} - -static DECLFW(M32Write1) { - mirr = V; - Sync(); -} - -static DECLFW(M32Write2) { - preg[1] = V; - Sync(); -} - -static DECLFW(M32Write3) { - creg[A & 7] = V; - Sync(); -} - -static void M32Power(void) { - Sync(); - SetReadHandler(0x6000,0x7fff,CartBR); - SetWriteHandler(0x6000,0x7fff,CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x8FFF, M32Write0); - SetWriteHandler(0x9000, 0x9FFF, M32Write1); - SetWriteHandler(0xA000, 0xAFFF, M32Write2); - SetWriteHandler(0xB000, 0xBFFF, M32Write3); -} - -static void M32Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper32_Init(CartInfo *info) { - info->Power = M32Power; - info->Close = M32Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/34.cpp b/branches/fceux-2.2.2/src/boards/34.cpp deleted file mode 100644 index 71f1b300..00000000 --- a/branches/fceux-2.2.2/src/boards/34.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Many-in-one hacked mapper crap. - * - * Original BNROM is actually AxROM variations without mirroring control, - * and haven't SRAM on-board, so it must be removed from here - * - * Difficult banking is what NINA board doing, most hacks for 34 mapper are - * NINA hacks, so this is actually 34 mapper - * - */ - -#include "mapinc.h" - -static uint8 regs[3]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 3, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, regs[0]); - setchr4(0x0000, regs[1]); - setchr4(0x1000, regs[2]); -} - -static DECLFW(M34Write) { - if (A >= 0x8000) - regs[0] = V; - else - switch (A) { - case 0x7ffd: regs[0] = V; break; - case 0x7ffe: regs[1] = V; break; - case 0x7fff: regs[2] = V; break; - } - Sync(); -} - -static void M34Power(void) { - regs[0] = regs[1] = 0; - regs[2] = 1; - Sync(); - SetReadHandler(0x6000, 0x7ffc, CartBR); - SetWriteHandler(0x6000, 0x7ffc, CartBW); - SetReadHandler(0x8000, 0xffff, CartBR); - SetWriteHandler(0x7ffd, 0xffff, M34Write); -} - -static void M34Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper34_Init(CartInfo *info) { - info->Power = M34Power; - info->Close = M34Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/36.cpp b/branches/fceux-2.2.2/src/boards/36.cpp deleted file mode 100644 index 209d777e..00000000 --- a/branches/fceux-2.2.2/src/boards/36.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * TXC/Micro Genius simplified mapper - */ - -#include "mapinc.h" - -static uint8 latche; - -static SFORMAT StateRegs[] = -{ - { &latche, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xf); -} - -static DECLFW(M36Write) { - latche = V; - Sync(); -} - -static DECLFR(M36Read) { - return latche; // Need by Strike Wolf, being simplified mapper, this cart still uses some TCX mapper features andrely on it -} - -static void M36Power(void) { - latche = 0; - Sync(); - SetReadHandler(0x4100, 0x4100, M36Read); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFE, M36Write); // Actually, BUS conflict there preventing from triggering the wrong banks -} - -static void M36Restore(int version) { - Sync(); -} - -void Mapper36_Init(CartInfo *info) { - info->Power = M36Power; - GameStateRestore = M36Restore; - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/68.cpp b/branches/fceux-2.2.2/src/boards/68.cpp deleted file mode 100644 index a38e567e..00000000 --- a/branches/fceux-2.2.2/src/boards/68.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chr_reg[4]; -static uint8 kogame, prg_reg, nt1, nt2, mirr; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE, count; - -static SFORMAT StateRegs[] = -{ - { &nt1, 1, "NT1" }, - { &nt2, 1, "NT2" }, - { &mirr, 1, "MIRR" }, - { &prg_reg, 1, "PRG" }, - { &kogame, 1, "KGME" }, - { &count, 4, "CNT" }, - { chr_reg, 4, "CHR" }, - { 0 } -}; - -static void M68NTfix(void) { - if ((!UNIFchrrama) && (mirr & 0x10)) { - PPUNTARAM = 0; - switch (mirr & 3) { - case 0: - vnapage[0] = vnapage[2] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - vnapage[1] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - case 1: - vnapage[0] = vnapage[1] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - vnapage[2] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - case 2: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - break; - case 3: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - } - } else - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static void Sync(void) { - setchr2(0x0000, chr_reg[0]); - setchr2(0x0800, chr_reg[1]); - setchr2(0x1000, chr_reg[2]); - setchr2(0x1800, chr_reg[3]); - setprg8r(0x10, 0x6000, 0); - setprg16r((PRGptr[1]) ? kogame : 0, 0x8000, prg_reg); - setprg16(0xC000, ~0); -} - -static DECLFR(M68Read) { - if (!(kogame & 8)) { - count++; - if (count == 1784) - setprg16r(0, 0x8000, prg_reg); - } - return CartBR(A); -} - -static DECLFW(M68WriteLo) { - if (!V) { - count = 0; - setprg16r((PRGptr[1]) ? kogame : 0, 0x8000, prg_reg); - } - CartBW(A, V); -} - -static DECLFW(M68WriteCHR) { - chr_reg[(A >> 12) & 3] = V; - Sync(); -} - -static DECLFW(M68WriteNT1) { - nt1 = V; - M68NTfix(); -} - -static DECLFW(M68WriteNT2) { - nt2 = V; - M68NTfix(); -} - -static DECLFW(M68WriteMIR) { - mirr = V; - M68NTfix(); -} - -static DECLFW(M68WriteROM) { - prg_reg = V & 7; - kogame = ((V >> 3) & 1) ^ 1; - Sync(); -} - -static void M68Power(void) { - prg_reg = 0; - kogame = 0; - Sync(); - M68NTfix(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xBFFF, M68Read); - SetReadHandler(0xC000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, M68WriteCHR); - SetWriteHandler(0xC000, 0xCFFF, M68WriteNT1); - SetWriteHandler(0xD000, 0xDFFF, M68WriteNT2); - SetWriteHandler(0xE000, 0xEFFF, M68WriteMIR); - SetWriteHandler(0xF000, 0xFFFF, M68WriteROM); - SetWriteHandler(0x6000, 0x6000, M68WriteLo); - SetWriteHandler(0x6001, 0x7FFF, CartBW); -} - -static void M68Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); - M68NTfix(); -} - -void Mapper68_Init(CartInfo *info) { - info->Power = M68Power; - info->Close = M68Close; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/69.cpp b/branches/fceux-2.2.2/src/boards/69.cpp deleted file mode 100644 index c289c9df..00000000 --- a/branches/fceux-2.2.2/src/boards/69.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmdreg, preg[4], creg[8], mirr; -static uint8 IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &cmdreg, 1, "CMDR" }, - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - if ((preg[3] & 0xC0) == 0xC0) - setprg8r(0x10, 0x6000, 0); - else - setprg8(0x6000, preg[3] & 0x3F); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M69WRAMWrite) { - if ((preg[3] & 0xC0) == 0xC0) - CartBW(A, V); -} - -static DECLFR(M69WRAMRead) { - if ((preg[3] & 0xC0) == 0x40) - return X.DB; - else - return CartBR(A); -} - -static DECLFW(M69Write0) { - cmdreg = V & 0xF; -} - -static DECLFW(M69Write1) { - switch (cmdreg) { - case 0x0: creg[0] = V; Sync(); break; - case 0x1: creg[1] = V; Sync(); break; - case 0x2: creg[2] = V; Sync(); break; - case 0x3: creg[3] = V; Sync(); break; - case 0x4: creg[4] = V; Sync(); break; - case 0x5: creg[5] = V; Sync(); break; - case 0x6: creg[6] = V; Sync(); break; - case 0x7: creg[7] = V; Sync(); break; - case 0x8: preg[3] = V; Sync(); break; - case 0x9: preg[0] = V; Sync(); break; - case 0xA: preg[1] = V; Sync(); break; - case 0xB: preg[2] = V; Sync(); break; - case 0xC: mirr = V & 3; Sync();break; - case 0xD: IRQa = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xE: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF: IRQCount &= 0x00FF; IRQCount |= V << 8; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -// SUNSOFT-5/FME-7 Sound - -static void AYSound(int Count); -static void AYSoundHQ(void); -static void DoAYSQ(int x); -static void DoAYSQHQ(int x); - -static uint8 sndcmd, sreg[14]; -static int32 vcount[3]; -static int32 dcount[3]; -static int CAYBC[3]; - -static SFORMAT SStateRegs[] = -{ - { &sndcmd, 1, "SCMD" }, - { sreg, 14, "SREG" }, - { 0 } -}; - -static DECLFW(M69SWrite0) { - sndcmd = V % 14; -} - -static DECLFW(M69SWrite1) { - int x; - GameExpSound.Fill = AYSound; - GameExpSound.HiFill = AYSoundHQ; - if (FSettings.SndRate) - switch (sndcmd) { - case 0: - case 1: - case 8: if (FSettings.soundq >= 1) DoAYSQHQ(0); else DoAYSQ(0); break; - case 2: - case 3: - case 9: if (FSettings.soundq >= 1) DoAYSQHQ(1); else DoAYSQ(1); break; - case 4: - case 5: - case 10: if (FSettings.soundq >= 1) DoAYSQHQ(2); else DoAYSQ(2); break; - case 7: - for (x = 0; x < 2; x++) - if (FSettings.soundq >= 1) DoAYSQHQ(x); else DoAYSQ(x); - break; - } - sreg[sndcmd] = V; -} - -static void DoAYSQ(int x) { - int32 freq = ((sreg[x << 1] | ((sreg[(x << 1) + 1] & 15) << 8)) + 1) << (4 + 17); - int32 amp = (sreg[0x8 + x] & 15) << 2; - int32 start, end; - int V; - - amp += amp >> 1; - - start = CAYBC[x]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - CAYBC[x] = end; - - if (amp && !(sreg[0x7] & (1 << x))) - for (V = start; V < end; V++) { - if (dcount[x]) - Wave[V >> 4] += amp; - vcount[x] -= nesincsize; - while (vcount[x] <= 0) { - dcount[x] ^= 1; - vcount[x] += freq; - } - } -} - -static void DoAYSQHQ(int x) { - uint32 V; - int32 freq = ((sreg[x << 1] | ((sreg[(x << 1) + 1] & 15) << 8)) + 1) << 4; - int32 amp = (sreg[0x8 + x] & 15) << 6; - - amp += amp >> 1; - - if (!(sreg[0x7] & (1 << x))) { - for (V = CAYBC[x]; V < SOUNDTS; V++) { - if (dcount[x]) - WaveHi[V] += amp; - vcount[x]--; - if (vcount[x] <= 0) { - dcount[x] ^= 1; - vcount[x] = freq; - } - } - } - CAYBC[x] = SOUNDTS; -} - -static void AYSound(int Count) { - int x; - DoAYSQ(0); - DoAYSQ(1); - DoAYSQ(2); - for (x = 0; x < 3; x++) - CAYBC[x] = Count; -} - -static void AYSoundHQ(void) { - DoAYSQHQ(0); - DoAYSQHQ(1); - DoAYSQHQ(2); -} - -static void AYHiSync(int32 ts) { - int x; - - for (x = 0; x < 3; x++) - CAYBC[x] = ts; -} - -void Mapper69_ESI(void) { - GameExpSound.RChange = Mapper69_ESI; - GameExpSound.HiSync = AYHiSync; - memset(dcount, 0, sizeof(dcount)); - memset(vcount, 0, sizeof(vcount)); - memset(CAYBC, 0, sizeof(CAYBC)); - AddExState(&SStateRegs, ~0, 0, 0); -} - -// SUNSOFT-5/FME-7 Sound - -static void M69Power(void) { - cmdreg = sndcmd = 0; - IRQCount = 0xFFFF; - IRQa = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, M69WRAMRead); - SetWriteHandler(0x6000, 0x7FFF, M69WRAMWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x9FFF, M69Write0); - SetWriteHandler(0xA000, 0xBFFF, M69Write1); - SetWriteHandler(0xC000, 0xDFFF, M69SWrite0); - SetWriteHandler(0xE000, 0xFFFF, M69SWrite1); -} - -static void M69Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M69IRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); IRQa = 0; IRQCount = 0xFFFF; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper69_Init(CartInfo *info) { - info->Power = M69Power; - info->Close = M69Close; - MapIRQHook = M69IRQHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - Mapper69_ESI(); - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFAY_Init(void) { - sndcmd = 0; - SetWriteHandler(0xC000, 0xDFFF, M69SWrite0); - SetWriteHandler(0xE000, 0xFFFF, M69SWrite1); - Mapper69_ESI(); -} diff --git a/branches/fceux-2.2.2/src/boards/82.cpp b/branches/fceux-2.2.2/src/boards/82.cpp deleted file mode 100644 index 033e6ff6..00000000 --- a/branches/fceux-2.2.2/src/boards/82.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Taito X1-017 board, battery backed - * - */ - -#include "mapinc.h" - -static uint8 regs[9], ctrl; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 9, "REGS" }, - { &ctrl, 1, "CTRL" }, - { 0 } -}; - -static void Sync(void) { - uint32 swap = ((ctrl & 2) << 11); - setchr2(0x0000 ^ swap, regs[0] >> 1); - setchr2(0x0800 ^ swap, regs[1] >> 1); - setchr1(0x1000 ^ swap, regs[2]); - setchr1(0x1400 ^ swap, regs[3]); - setchr1(0x1800 ^ swap, regs[4]); - setchr1(0x1c00 ^ swap, regs[5]); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, regs[6]); - setprg8(0xA000, regs[7]); - setprg8(0xC000, regs[8]); - setprg8(0xE000, ~0); - setmirror(ctrl & 1); -} - -static DECLFW(M82Write) { - if (A <= 0x7ef5) - regs[A & 7] = V; - else - switch (A) { - case 0x7ef6: ctrl = V & 3; break; - case 0x7efa: regs[6] = V >> 2; break; - case 0x7efb: regs[7] = V >> 2; break; - case 0x7efc: regs[8] = V >> 2; break; - } - Sync(); -} - -static void M82Power(void) { - Sync(); - SetReadHandler(0x6000, 0xffff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetWriteHandler(0x7ef0, 0x7efc, M82Write); // external WRAM might end at $73FF -} - -static void M82Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper82_Init(CartInfo *info) { - info->Power = M82Power; - info->Close = M82Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/99.cpp b/branches/fceux-2.2.2/src/boards/99.cpp deleted file mode 100644 index caf5cff8..00000000 --- a/branches/fceux-2.2.2/src/boards/99.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 latch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static writefunc old4016; - -static SFORMAT StateRegs[] = -{ - { &latch, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setchr8((latch >> 2) & 1); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, 0); - setprg8(0x8000, latch & 4); /* Special for VS Gumshoe */ -} - -static DECLFW(M99Write) { - latch = V; - Sync(); - old4016(A, V); -} - -static void M99Power(void) { - latch = 0; - Sync(); - old4016 = GetWriteHandler(0x4016); - SetWriteHandler(0x4016, 0x4016, M99Write); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); -} - -static void M99Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper99_Init(CartInfo *info) { - info->Power = M99Power; - info->Close = M99Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/addrlatch.cpp b/branches/fceux-2.2.2/src/boards/addrlatch.cpp deleted file mode 100644 index 299f6e46..00000000 --- a/branches/fceux-2.2.2/src/boards/addrlatch.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint16 latche, latcheinit; -static uint16 addrreg0, addrreg1; -static uint8 dipswitch; -static void (*WSync)(void); -static readfunc defread; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static DECLFW(LatchWrite) { - latche = A; - WSync(); -} - -static void LatchReset(void) { - latche = latcheinit; - WSync(); -} - -static void LatchPower(void) { - latche = latcheinit; - WSync(); - if (WRAM) { - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } else - SetReadHandler(0x6000, 0xFFFF, defread); - SetWriteHandler(addrreg0, addrreg1, LatchWrite); -} - -static void LatchClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16 linit, uint16 adr0, uint16 adr1, uint8 wram) { - latcheinit = linit; - addrreg0 = adr0; - addrreg1 = adr1; - WSync = proc; - if (func != NULL) - defread = func; - else - defread = CartBROB; - info->Power = LatchPower; - info->Reset = LatchReset; - info->Close = LatchClose; - if (wram) { - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - GameStateRestore = StateRestore; - AddExState(&latche, 2, 0, "LATC"); -} - -//------------------ BMCD1038 --------------------------- - -static void BMCD1038Sync(void) { - if (latche & 0x80) { - setprg16(0x8000, (latche & 0x70) >> 4); - setprg16(0xC000, (latche & 0x70) >> 4); - } else - setprg32(0x8000, (latche & 0x60) >> 5); - setchr8(latche & 7); - setmirror(((latche & 8) >> 3) ^ 1); -} - -static DECLFR(BMCD1038Read) { - if (latche & 0x100) - return dipswitch; - else - return CartBR(A); -} - -static void BMCD1038Reset(void) { - dipswitch++; - dipswitch &= 3; -} - -void BMCD1038_Init(CartInfo *info) { - Latch_Init(info, BMCD1038Sync, BMCD1038Read, 0x0000, 0x8000, 0xFFFF, 0); - info->Reset = BMCD1038Reset; - AddExState(&dipswitch, 1, 0, "DIPSW"); -} - -//------------------ UNL43272 --------------------------- -// mapper much complex, including 16K bankswitching -static void UNL43272Sync(void) { - if ((latche & 0x81) == 0x81) { - setprg32(0x8000, (latche & 0x38) >> 3); - } else - FCEU_printf("unrecognized command %04!\n", latche); - setchr8(0); - setmirror(0); -} - -static DECLFR(UNL43272Read) { - if (latche & 0x400) - return CartBR(A & 0xFE); - else - return CartBR(A); -} - -static void UNL43272Reset(void) { - latche = 0; - UNL43272Sync(); -} - -void UNL43272_Init(CartInfo *info) { - Latch_Init(info, UNL43272Sync, UNL43272Read, 0x0081, 0x8000, 0xFFFF, 0); - info->Reset = UNL43272Reset; - AddExState(&dipswitch, 1, 0, "DIPSW"); -} - -//------------------ Map 058 --------------------------- - -static void BMCGK192Sync(void) { - if (latche & 0x40) { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - } else - setprg32(0x8000, (latche >> 1) & 3); - setchr8((latche >> 3) & 7); - setmirror(((latche & 0x80) >> 7) ^ 1); -} - -void BMCGK192_Init(CartInfo *info) { - Latch_Init(info, BMCGK192Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 059 --------------------------- -// One more forgotten mapper -static void M59Sync(void) { - setprg32(0x8000, (latche >> 4) & 7); - setchr8(latche & 0x7); - setmirror((latche >> 3) & 1); -} - -static DECLFR(M59Read) { - if (latche & 0x100) - return 0; - else - return CartBR(A); -} - -void Mapper59_Init(CartInfo *info) { - Latch_Init(info, M59Sync, M59Read, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 061 --------------------------- -static void M61Sync(void) { - if (((latche & 0x10) << 1) ^ (latche & 0x20)) { - setprg16(0x8000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); - setprg16(0xC000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); - } else - setprg32(0x8000, latche & 0xF); - setchr8(0); - setmirror(((latche >> 7) & 1) ^ 1); -} - -void Mapper61_Init(CartInfo *info) { - Latch_Init(info, M61Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 092 --------------------------- -// Another two-in-one mapper, two Jaleco carts uses similar -// hardware, but with different wiring. -// Original code provided by LULU -// Additionally, PCB contains DSP extra sound chip, used for voice samples (unemulated) - -static void M92Sync(void) { - uint8 reg = latche & 0xF0; - setprg16(0x8000, 0); - if (latche >= 0x9000) { - switch (reg) { - case 0xD0: setprg16(0xc000, latche & 15); break; - case 0xE0: setchr8(latche & 15); break; - } - } else { - switch (reg) { - case 0xB0: setprg16(0xc000, latche & 15); break; - case 0x70: setchr8(latche & 15); break; - } - } -} - -void Mapper92_Init(CartInfo *info) { - Latch_Init(info, M92Sync, NULL, 0x80B0, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 200 --------------------------- - -static void M200Sync(void) { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - setchr8(latche & 7); - setmirror((latche & 8) >> 3); -} - -void Mapper200_Init(CartInfo *info) { - Latch_Init(info, M200Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 201 --------------------------- - -static void M201Sync(void) { - if (latche & 8) { - setprg32(0x8000, latche & 3); - setchr8(latche & 3); - } else { - setprg32(0x8000, 0); - setchr8(0); - } -} - -void Mapper201_Init(CartInfo *info) { - Latch_Init(info, M201Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 202 --------------------------- - -static void M202Sync(void) { - // According to more carefull hardware tests and PCB study - int32 mirror = latche & 1; - int32 bank = (latche >> 1) & 0x7; - int32 select = (mirror & (bank >> 2)); - setprg16(0x8000, select ? (bank & 6) | 0 : bank); - setprg16(0xc000, select ? (bank & 6) | 1 : bank); - setmirror(mirror ^ 1); - setchr8(bank); -} - -void Mapper202_Init(CartInfo *info) { - Latch_Init(info, M202Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 204 --------------------------- - -static void M204Sync(void) { - int32 tmp2 = latche & 0x6; - int32 tmp1 = tmp2 + ((tmp2 == 0x6) ? 0 : (latche & 1)); - setprg16(0x8000, tmp1); - setprg16(0xc000, tmp2 + ((tmp2 == 0x6) ? 1 : (latche & 1))); - setchr8(tmp1); - setmirror(((latche >> 4) & 1) ^ 1); -} - -void Mapper204_Init(CartInfo *info) { - Latch_Init(info, M204Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 212 --------------------------- - -static DECLFR(M212Read) { - uint8 ret = CartBROB(A); - if ((A & 0xE010) == 0x6000) - ret |= 0x80; - return ret; -} - -static void M212Sync(void) { - if (latche & 0x4000) { - setprg32(0x8000, (latche >> 1) & 3); - } else { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - } - setchr8(latche & 7); - setmirror(((latche >> 3) & 1) ^ 1); -} - -void Mapper212_Init(CartInfo *info) { - Latch_Init(info, M212Sync, M212Read, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 213 --------------------------- - -static void M213Sync(void) { - setprg32(0x8000, (latche >> 1) & 3); - setchr8((latche >> 3) & 7); -} - -void Mapper213_Init(CartInfo *info) { - Latch_Init(info, M213Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 214 --------------------------- - -static void M214Sync(void) { - setprg16(0x8000, (latche >> 2) & 3); - setprg16(0xC000, (latche >> 2) & 3); - setchr8(latche & 3); -} - -void Mapper214_Init(CartInfo *info) { - Latch_Init(info, M214Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 217 --------------------------- - -static void M217Sync(void) { - setprg32(0x8000, (latche >> 2) & 3); - setchr8(latche & 7); -} - -void Mapper217_Init(CartInfo *info) { - Latch_Init(info, M217Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 227 --------------------------- - -static void M227Sync(void) { - uint32 S = latche & 1; - uint32 p = ((latche >> 2) & 0x1F) + ((latche & 0x100) >> 3); - uint32 L = (latche >> 9) & 1; - - if ((latche >> 7) & 1) { - if (S) { - setprg32(0x8000, p >> 1); - } else { - setprg16(0x8000, p); - setprg16(0xC000, p); - } - } else { - if (S) { - if (L) { - setprg16(0x8000, p & 0x3E); - setprg16(0xC000, p | 7); - } else { - setprg16(0x8000, p & 0x3E); - setprg16(0xC000, p & 0x38); - } - } else { - if (L) { - setprg16(0x8000, p); - setprg16(0xC000, p | 7); - } else { - setprg16(0x8000, p); - setprg16(0xC000, p & 0x38); - } - } - } - - setmirror(((latche >> 1) & 1) ^ 1); - setchr8(0); - setprg8r(0x10, 0x6000, 0); -} - -void Mapper227_Init(CartInfo *info) { - Latch_Init(info, M227Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); -} - -//------------------ Map 229 --------------------------- - -static void M229Sync(void) { - setchr8(latche); - if (!(latche & 0x1e)) - setprg32(0x8000, 0); - else { - setprg16(0x8000, latche & 0x1F); - setprg16(0xC000, latche & 0x1F); - } - setmirror(((latche >> 5) & 1) ^ 1); -} - -void Mapper229_Init(CartInfo *info) { - Latch_Init(info, M229Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 231 --------------------------- - -static void M231Sync(void) { - setchr8(0); - if (latche & 0x20) - setprg32(0x8000, (latche >> 1) & 0x0F); - else { - setprg16(0x8000, latche & 0x1E); - setprg16(0xC000, latche & 0x1E); - } - setmirror(((latche >> 7) & 1) ^ 1); -} - -void Mapper231_Init(CartInfo *info) { - Latch_Init(info, M231Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 242 --------------------------- - -static void M242Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, (latche >> 3) & 0xf); - setmirror(((latche >> 1) & 1) ^ 1); -} - -void Mapper242_Init(CartInfo *info) { - Latch_Init(info, M242Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); -} - -//------------------ 190in1 --------------------------- - -static void BMC190in1Sync(void) { - setprg16(0x8000, (latche >> 2) & 7); - setprg16(0xC000, (latche >> 2) & 7); - setchr8((latche >> 2) & 7); - setmirror((latche & 1) ^ 1); -} - -void BMC190in1_Init(CartInfo *info) { - Latch_Init(info, BMC190in1Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMC810544-C-A1 ------------------------ - -static void BMC810544CA1Sync(void) { - uint32 bank = latche >> 7; - if (latche & 0x40) - setprg32(0x8000, bank); - else { - setprg16(0x8000, (bank << 1) | ((latche >> 5) & 1)); - setprg16(0xC000, (bank << 1) | ((latche >> 5) & 1)); - } - setchr8(latche & 0x0f); - setmirror(((latche >> 4) & 1) ^ 1); -} - -void BMC810544CA1_Init(CartInfo *info) { - Latch_Init(info, BMC810544CA1Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMCNTD-03 ------------------------ - -static void BMCNTD03Sync(void) { - // 1PPP Pmcc spxx xccc - // 1000 0000 0000 0000 v - // 1001 1100 0000 0100 h - // 1011 1010 1100 0100 - uint32 prg = ((latche >> 10) & 0x1e); - uint32 chr = ((latche & 0x0300) >> 5) | (latche & 7); - if (latche & 0x80) { - setprg16(0x8000, prg | ((latche >> 6) & 1)); - setprg16(0xC000, prg | ((latche >> 6) & 1)); - } else - setprg32(0x8000, prg >> 1); - setchr8(chr); - setmirror(((latche >> 10) & 1) ^ 1); -} - -void BMCNTD03_Init(CartInfo *info) { - Latch_Init(info, BMCNTD03Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMCG-146 ------------------------ - -static void BMCG146Sync(void) { - setchr8(0); - if (latche & 0x800) { // UNROM mode - setprg16(0x8000, (latche & 0x1F) | (latche & ((latche & 0x40) >> 6))); - setprg16(0xC000, (latche & 0x18) | 7); - } else { - if (latche & 0x40) { // 16K mode - setprg16(0x8000, latche & 0x1F); - setprg16(0xC000, latche & 0x1F); - } else { - setprg32(0x8000, (latche >> 1) & 0x0F); - } - } - setmirror(((latche & 0x80) >> 7) ^ 1); -} - -void BMCG146_Init(CartInfo *info) { - Latch_Init(info, BMCG146Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/bandai.cpp b/branches/fceux-2.2.2/src/boards/bandai.cpp deleted file mode 100644 index 98f849c5..00000000 --- a/branches/fceux-2.2.2/src/boards/bandai.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * Copyright (C) 2011 FCEUX team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Bandai mappers - * - */ - -#include "mapinc.h" - -static uint8 reg[16], is153, x24c02; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { reg, 16, "REGS" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, // need for Famicom Jump II - Saikyou no 7 Nin (J) [!] - { 0 } -}; - -// x24C0x interface - -#define X24C0X_STANDBY 0 -#define X24C0X_ADDRESS 1 -#define X24C0X_WORD 2 -#define X24C0X_READ 3 -#define X24C0X_WRITE 4 - -static uint8 x24c0x_data[256], x24c0x_state; -static uint8 x24c0x_addr, x24c0x_word, x24c0x_latch, x24c0x_bitcount; -static uint8 x24c0x_sda, x24c0x_scl, x24c0x_out, x24c0x_oe; - -static SFORMAT x24c0xStateRegs[] = -{ - { &x24c0x_addr, 1, "ADDR" }, - { &x24c0x_word, 1, "WORD" }, - { &x24c0x_latch, 1, "LATC" }, - { &x24c0x_bitcount, 1, "BITC" }, - { &x24c0x_sda, 1, "SDA" }, - { &x24c0x_scl, 1, "SCL" }, - { &x24c0x_out, 1, "OUT" }, - { &x24c0x_oe, 1, "OE" }, - { &x24c0x_state, 1, "STAT" }, - { 0 } -}; - -static void x24c0x_init() { - x24c0x_addr = x24c0x_word = x24c0x_latch = x24c0x_bitcount = x24c0x_sda = x24c0x_scl = x24c0x_oe = 0; - x24c0x_state = X24C0X_STANDBY; -} - -static void x24c0x_write(uint8 data) { - uint8 sda = (data >> 6) & 1; - uint8 scl = (data >> 5) & 1; - x24c0x_oe = (data >> 7); - - if(x24c0x_scl && scl) { - if(x24c0x_sda && !sda) { // START - x24c0x_state = X24C0X_ADDRESS; - x24c0x_bitcount = 0; - x24c0x_addr = 0; - } else if(!x24c0x_sda && sda) { //STOP - x24c0x_state = X24C0X_STANDBY; - } - } else if(!x24c0x_scl && scl) { // RISING EDGE - switch(x24c0x_state) { - case X24C0X_ADDRESS: - if(x24c0x_bitcount < 7) { - x24c0x_addr <<= 1; - x24c0x_addr |= sda; - } else { - if(!x24c02) // X24C01 mode - x24c0x_word = x24c0x_addr; - if(sda) { // READ COMMAND - x24c0x_state = X24C0X_READ; - } else { // WRITE COMMAND - if(x24c02) // X24C02 mode - x24c0x_state = X24C0X_WORD; - else - x24c0x_state = X24C0X_WRITE; - } - } - x24c0x_bitcount++; - break; - case X24C0X_WORD: - if(x24c0x_bitcount == 8) { // ACK - x24c0x_word = 0; - x24c0x_out = 0; - } else { // WORD ADDRESS INPUT - x24c0x_word <<= 1; - x24c0x_word |= sda; - if(x24c0x_bitcount == 16) { // END OF ADDRESS INPUT - x24c0x_bitcount = 7; - x24c0x_state = X24C0X_WRITE; - } - } - x24c0x_bitcount++; - break; - case X24C0X_READ: - if (x24c0x_bitcount == 8) { // ACK - x24c0x_out = 0; - x24c0x_latch = x24c0x_data[x24c0x_word]; - x24c0x_bitcount = 0; - } else { // REAL OUTPUT - x24c0x_out = x24c0x_latch >> 7; - x24c0x_latch <<= 1; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_word++; - x24c0x_word &= 0xff; - } - } - break; - case X24C0X_WRITE: - if (x24c0x_bitcount == 8) { // ACK - x24c0x_out = 0; - x24c0x_latch = 0; - x24c0x_bitcount = 0; - } else { // REAL INPUT - x24c0x_latch <<= 1; - x24c0x_latch |= sda; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_data[x24c0x_word] = x24c0x_latch; - x24c0x_word++; - x24c0x_word &= 0xff; - } - } - break; - } - } - - x24c0x_sda = sda; - x24c0x_scl = scl; -} - -static uint8 x24c0x_read() { - return x24c0x_out << 4; -} - -// - -static void Sync(void) { - if (is153) { - int base = (reg[0] & 1) << 4; - setchr8(0); - setprg16(0x8000, (reg[8] & 0x0F) | base); - setprg16(0xC000, 0x0F | base); - } else { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, reg[i]); - setprg16(0x8000, reg[8]); - setprg16(0xC000, ~0); - } - switch (reg[9] & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(BandaiWrite) { - A &= 0x0F; - if (A < 0x0A) { - reg[A & 0x0F] = V; - Sync(); - } else - switch (A) { - case 0x0A: X6502_IRQEnd(FCEU_IQEXT); IRQa = V & 1; IRQCount = IRQLatch; break; - case 0x0B: IRQLatch &= 0xFF00; IRQLatch |= V; break; - case 0x0C: IRQLatch &= 0xFF; IRQLatch |= V << 8; break; - case 0x0D: x24c0x_write(V); break; - } -} - -static DECLFR(BandaiRead) { - return (X.DB & 0xEF) | x24c0x_read(); -} - -static void BandaiIRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount < 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = -1; - } - } -} - -static void BandaiPower(void) { - IRQa = 0; - x24c0x_init(); - Sync(); - SetReadHandler(0x6000, 0x7FFF, BandaiRead); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, BandaiWrite); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper16_Init(CartInfo *info) { - x24c02 = 1; - is153 = 0; - info->Power = BandaiPower; - MapIRQHook = BandaiIRQHook; - - info->battery = 1; - info->SaveGame[0] = x24c0x_data; - info->SaveGameLen[0] = 256; - AddExState(x24c0x_data, 256, 0, "DATA"); - - GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper159_Init(CartInfo *info) { - x24c02 = 0; - is153 = 0; - info->Power = BandaiPower; - MapIRQHook = BandaiIRQHook; - - info->battery = 1; - info->SaveGame[0] = x24c0x_data; - info->SaveGameLen[0] = 128; - AddExState(x24c0x_data, 128, 0, "DATA"); - - GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); - AddExState(&StateRegs, ~0, 0, 0); -} - -// Famicom jump 2: -// 0-7: Lower bit of data selects which 256KB PRG block is in use. -// This seems to be a hack on the developers' part, so I'll make emulation -// of it a hack(I think the current PRG block would depend on whatever the -// lowest bit of the CHR bank switching register that corresponds to the -// last CHR address read). - -static void M153Power(void) { - Sync(); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, BandaiWrite); -} - - -static void M153Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper153_Init(CartInfo *info) { - is153 = 1; - info->Power = M153Power; - info->Close = M153Close; - MapIRQHook = BandaiIRQHook; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -// Datach Barcode Battler - -static uint8 BarcodeData[256]; -static int BarcodeReadPos; -static int BarcodeCycleCount; -static uint32 BarcodeOut; - -int FCEUI_DatachSet(const uint8 *rcode) { - int prefix_parity_type[10][6] = { - { 0, 0, 0, 0, 0, 0 }, { 0, 0, 1, 0, 1, 1 }, { 0, 0, 1, 1, 0, 1 }, { 0, 0, 1, 1, 1, 0 }, - { 0, 1, 0, 0, 1, 1 }, { 0, 1, 1, 0, 0, 1 }, { 0, 1, 1, 1, 0, 0 }, { 0, 1, 0, 1, 0, 1 }, - { 0, 1, 0, 1, 1, 0 }, { 0, 1, 1, 0, 1, 0 } - }; - int data_left_odd[10][7] = { - { 0, 0, 0, 1, 1, 0, 1 }, { 0, 0, 1, 1, 0, 0, 1 }, { 0, 0, 1, 0, 0, 1, 1 }, { 0, 1, 1, 1, 1, 0, 1 }, - { 0, 1, 0, 0, 0, 1, 1 }, { 0, 1, 1, 0, 0, 0, 1 }, { 0, 1, 0, 1, 1, 1, 1 }, { 0, 1, 1, 1, 0, 1, 1 }, - { 0, 1, 1, 0, 1, 1, 1 }, { 0, 0, 0, 1, 0, 1, 1 } - }; - int data_left_even[10][7] = { - { 0, 1, 0, 0, 1, 1, 1 }, { 0, 1, 1, 0, 0, 1, 1 }, { 0, 0, 1, 1, 0, 1, 1 }, { 0, 1, 0, 0, 0, 0, 1 }, - { 0, 0, 1, 1, 1, 0, 1 }, { 0, 1, 1, 1, 0, 0, 1 }, { 0, 0, 0, 0, 1, 0, 1 }, { 0, 0, 1, 0, 0, 0, 1 }, - { 0, 0, 0, 1, 0, 0, 1 }, { 0, 0, 1, 0, 1, 1, 1 } - }; - int data_right[10][7] = { - { 1, 1, 1, 0, 0, 1, 0 }, { 1, 1, 0, 0, 1, 1, 0 }, { 1, 1, 0, 1, 1, 0, 0 }, { 1, 0, 0, 0, 0, 1, 0 }, - { 1, 0, 1, 1, 1, 0, 0 }, { 1, 0, 0, 1, 1, 1, 0 }, { 1, 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 0, 1, 0, 0 }, - { 1, 0, 0, 1, 0, 0, 0 }, { 1, 1, 1, 0, 1, 0, 0 } - }; - uint8 code[13 + 1]; - uint32 tmp_p = 0; - int i, j; - int len; - - for (i = len = 0; i < 13; i++) { - if (!rcode[i]) break; - if ((code[i] = rcode[i] - '0') > 9) - return(0); - len++; - } - if (len != 13 && len != 12 && len != 8 && len != 7) return(0); - - #define BS(x) BarcodeData[tmp_p] = x; tmp_p++ - - for (j = 0; j < 32; j++) { - BS(0x00); - } - - /* Left guard bars */ - BS(1); BS(0); BS(1); - - if (len == 13 || len == 12) { - uint32 csum; - - for (i = 0; i < 6; i++) - if (prefix_parity_type[code[0]][i]) { - for (j = 0; j < 7; j++) { - BS(data_left_even[code[i + 1]][j]); - } - } else - for (j = 0; j < 7; j++) { - BS(data_left_odd[code[i + 1]][j]); - } - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for (i = 7; i < 12; i++) - for (j = 0; j < 7; j++) { - BS(data_right[code[i]][j]); - } - csum = 0; - for (i = 0; i < 12; i++) csum += code[i] * ((i & 1) ? 3 : 1); - csum = (10 - (csum % 10)) % 10; - for (j = 0; j < 7; j++) { - BS(data_right[csum][j]); - } - } else if (len == 8 || len == 7) { - uint32 csum = 0; - - for (i = 0; i < 7; i++) csum += (i & 1) ? code[i] : (code[i] * 3); - - csum = (10 - (csum % 10)) % 10; - - for (i = 0; i < 4; i++) - for (j = 0; j < 7; j++) { - BS(data_left_odd[code[i]][j]); - } - - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for (i = 4; i < 7; i++) - for (j = 0; j < 7; j++) { - BS(data_right[code[i]][j]); - } - - for (j = 0; j < 7; j++) { - BS(data_right[csum][j]); - } - } - - /* Right guard bars */ - BS(1); BS(0); BS(1); - - for (j = 0; j < 32; j++) { - BS(0x00); - } - - BS(0xFF); - - #undef BS - - BarcodeReadPos = 0; - BarcodeOut = 0x8; - BarcodeCycleCount = 0; - return(1); -} - -static void BarcodeIRQHook(int a) { - BandaiIRQHook(a); - - BarcodeCycleCount += a; - - if (BarcodeCycleCount >= 1000) { - BarcodeCycleCount -= 1000; - if (BarcodeData[BarcodeReadPos] == 0xFF) { - BarcodeOut = 0; - } else { - BarcodeOut = (BarcodeData[BarcodeReadPos] ^ 1) << 3; - BarcodeReadPos++; - } - } -} - -static DECLFR(BarcodeRead) { - return BarcodeOut; -} - -static void M157Power(void) { - IRQa = 0; - BarcodeData[0] = 0xFF; - BarcodeReadPos = 0; - BarcodeOut = 0; - BarcodeCycleCount = 0; - - Sync(); - - SetWriteHandler(0x6000, 0xFFFF, BandaiWrite); - SetReadHandler(0x6000, 0x7FFF, BarcodeRead); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -void Mapper157_Init(CartInfo *info) { - is153 = 1; - info->Power = M157Power; - MapIRQHook = BarcodeIRQHook; - - GameInfo->cspecial = SIS_DATACH; - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/dance2000.cpp b/branches/fceux-2.2.2/src/boards/dance2000.cpp deleted file mode 100644 index eb1841d4..00000000 --- a/branches/fceux-2.2.2/src/boards/dance2000.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 prg, mode; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint32 lastnt = 0; - -static SFORMAT StateRegs[] = -{ - { &prg, 1, "REGS" }, - { &mode, 1, "MODE" }, - { &lastnt, 4, "LSNT" }, - { 0 } -}; - -static void Sync(void) { - setmirror((mode ^ 1) & 1); - setprg8r(0x10, 0x6000, 0); - setchr4(0x0000, lastnt); - setchr4(0x1000, 1); - if (mode & 4) - setprg32(0x8000, prg & 7); - else { - setprg16(0x8000, prg & 0x0f); - setprg16(0xC000, 0); - } -} - -static DECLFW(UNLD2000Write) { - switch (A) { - case 0x5000: prg = V; Sync(); break; - case 0x5200: mode = V; if (mode & 4) Sync(); break; - } -} - -static DECLFR(UNLD2000Read) { - if (prg & 0x40) - return X.DB; - else - return CartBR(A); -} - -static void UNLD2000Power(void) { - prg = mode = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, UNLD2000Read); - SetWriteHandler(0x5000, 0x5FFF, UNLD2000Write); -} - -static void UNL2000Hook(uint32 A) { - if (mode & 2) { - if ((A & 0x3000) == 0x2000) { - uint32 curnt = A & 0x800; - if (curnt != lastnt) { - setchr4(0x0000, curnt >> 11); - lastnt = curnt; - } - } - } else { - lastnt = 0; - setchr4(0x0000, 0); - } -} - -static void UNLD2000Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLD2000_Init(CartInfo *info) { - info->Power = UNLD2000Power; - info->Close = UNLD2000Close; - PPU_hook = UNL2000Hook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/datalatch.cpp b/branches/fceux-2.2.2/src/boards/datalatch.cpp deleted file mode 100644 index 4b0177fe..00000000 --- a/branches/fceux-2.2.2/src/boards/datalatch.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "../ines.h" - -static uint8 latche, latcheinit, bus_conflict; -static uint16 addrreg0, addrreg1; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static void (*WSync)(void); - -static DECLFW(LatchWrite) { -// FCEU_printf("bs %04x %02x\n",A,V); - if (bus_conflict) - latche = (V == CartBR(A)) ? V : 0; - else - latche = V; - WSync(); -} - -static void LatchPower(void) { - latche = latcheinit; - WSync(); - if (WRAM) { - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } else { - SetReadHandler(0x8000, 0xFFFF, CartBR); - } - SetWriteHandler(addrreg0, addrreg1, LatchWrite); -} - -static void LatchClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram, uint8 busc) { - bus_conflict = busc; - latcheinit = init; - addrreg0 = adr0; - addrreg1 = adr1; - WSync = proc; - info->Power = LatchPower; - info->Close = LatchClose; - GameStateRestore = StateRestore; - if (wram) { - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - AddExState(&latche, 1, 0, "LATC"); - AddExState(&bus_conflict, 1, 0, "BUSC"); -} - -//------------------ Map 0 --------------------------- - -#ifdef DEBUG_MAPPER -static DECLFW(NROMWrite) { - FCEU_printf("bs %04x %02x\n", A, V); - CartBW(A, V); -} -#endif - -static void NROMPower(void) { - setprg8r(0x10, 0x6000, 0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); - - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - #ifdef DEBUG_MAPPER - SetWriteHandler(0x4020, 0xFFFF, NROMWrite); - #endif -} - -void NROM_Init(CartInfo *info) { - info->Power = NROMPower; - info->Close = LatchClose; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); -} - -//------------------ Map 2 --------------------------- - -static void UNROMSync(void) { - static uint32 mirror_in_use = 0; - if (PRGsize[0] <= 128 * 1024) { - setprg16(0x8000, latche & 0x7); - if (latche & 8) mirror_in_use = 1; - if (mirror_in_use) - setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper - } else - setprg16(0x8000, latche & 0xf); - setprg16(0xc000, ~0); - setchr8(0); -} - -void UNROM_Init(CartInfo *info) { - Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0, 1); -} - -//------------------ Map 3 --------------------------- - -static void CNROMSync(void) { - setchr8(latche); - setprg32(0x8000, 0); - setprg8r(0x10, 0x6000, 0); // Hayauchy IGO uses 2Kb or RAM -} - -void CNROM_Init(CartInfo *info) { - Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, 1); -} - -//------------------ Map 7 --------------------------- - -static void ANROMSync() { - setprg32(0x8000, latche & 0xF); - setmirror(MI_0 + ((latche >> 4) & 1)); - setchr8(0); -} - -void ANROM_Init(CartInfo *info) { - Latch_Init(info, ANROMSync, 0, 0x4020, 0xFFFF, 0, 0); -} - -//------------------ Map 8 --------------------------- - -static void M8Sync() { - setprg16(0x8000, latche >> 3); - setprg16(0xc000, 1); - setchr8(latche & 3); -} - -void Mapper8_Init(CartInfo *info) { - Latch_Init(info, M8Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 11 --------------------------- - -static void M11Sync(void) { - setprg32(0x8000, latche & 0xF); - setchr8(latche >> 4); -} - -void Mapper11_Init(CartInfo *info) { - Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -void Mapper144_Init(CartInfo *info) { - Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0, 0); -} - -//------------------ Map 13 --------------------------- - -static void CPROMSync(void) { - setchr4(0x0000, 0); - setchr4(0x1000, latche & 3); - setprg32(0x8000, 0); -} - -void CPROM_Init(CartInfo *info) { - Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 38 --------------------------- - -static void M38Sync(void) { - setprg32(0x8000, latche & 3); - setchr8(latche >> 2); -} - -void Mapper38_Init(CartInfo *info) { - Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0, 0); -} - -//------------------ Map 66 --------------------------- - -static void MHROMSync(void) { - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xF); -} - -void MHROM_Init(CartInfo *info) { - Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 70 --------------------------- - -static void M70Sync() { - setprg16(0x8000, latche >> 4); - setprg16(0xc000, ~0); - setchr8(latche & 0xf); -} - -void Mapper70_Init(CartInfo *info) { - Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 78 --------------------------- -/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */ -static void M78Sync() { - setprg16(0x8000, (latche & 7)); - setprg16(0xc000, ~0); - setchr8(latche >> 4); - setmirror(MI_0 + ((latche >> 3) & 1)); -} - -void Mapper78_Init(CartInfo *info) { - Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 86 --------------------------- - -static void M86Sync(void) { - setprg32(0x8000, (latche >> 4) & 3); - setchr8((latche & 3) | ((latche >> 4) & 4)); -} - -void Mapper86_Init(CartInfo *info) { - Latch_Init(info, M86Sync, ~0, 0x6000, 0x6FFF, 0, 0); -} - -//------------------ Map 87 --------------------------- - -static void M87Sync(void) { - setprg32(0x8000, 0); - setchr8(((latche >> 1) & 1) | ((latche << 1) & 2)); -} - -void Mapper87_Init(CartInfo *info) { - Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0, 0); -} - -//------------------ Map 89 --------------------------- - -static void M89Sync(void) { - setprg16(0x8000, (latche >> 4) & 7); - setprg16(0xc000, ~0); - setchr8((latche & 7) | ((latche >> 4) & 8)); - setmirror(MI_0 + ((latche >> 3) & 1)); -} - -void Mapper89_Init(CartInfo *info) { - Latch_Init(info, M89Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 93 --------------------------- - -static void SSUNROMSync(void) { - setprg16(0x8000, latche >> 4); - setprg16(0xc000, ~0); - setchr8(0); -} - -void SUNSOFT_UNROM_Init(CartInfo *info) { - Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 94 --------------------------- - -static void M94Sync(void) { - setprg16(0x8000, latche >> 2); - setprg16(0xc000, ~0); - setchr8(0); -} - -void Mapper94_Init(CartInfo *info) { - Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 97 --------------------------- - -static void M97Sync(void) { - setchr8(0); - setprg16(0x8000, ~0); - setprg16(0xc000, latche & 15); - switch (latche >> 6) { - case 0: break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_V); break; - case 3: break; - } - setchr8(((latche >> 1) & 1) | ((latche << 1) & 2)); -} - -void Mapper97_Init(CartInfo *info) { - Latch_Init(info, M97Sync, ~0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 101 --------------------------- - -static void M101Sync(void) { - setprg32(0x8000, 0); - setchr8(latche); -} - -void Mapper101_Init(CartInfo *info) { - Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 107 --------------------------- - -static void M107Sync(void) { - setprg32(0x8000, (latche >> 1) & 3); - setchr8(latche & 7); -} - -void Mapper107_Init(CartInfo *info) { - Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 113 --------------------------- - -static void M113Sync(void) { - setprg32(0x8000, (latche >> 3) & 7); - setchr8(((latche >> 3) & 8) | (latche & 7)); -// setmirror(latche>>7); // only for HES 6in1 -} - -void Mapper113_Init(CartInfo *info) { - Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0, 0); -} - -//------------------ Map 140 --------------------------- - -void Mapper140_Init(CartInfo *info) { - Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 152 --------------------------- - -static void M152Sync() { - setprg16(0x8000, (latche >> 4) & 7); - setprg16(0xc000, ~0); - setchr8(latche & 0xf); - setmirror(MI_0 + ((latche >> 7) & 1)); /* Saint Seiya...hmm. */ -} - -void Mapper152_Init(CartInfo *info) { - Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 180 --------------------------- - -static void M180Sync(void) { - setprg16(0x8000, 0); - setprg16(0xc000, latche); - setchr8(0); -} - -void Mapper180_Init(CartInfo *info) { - Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 184 --------------------------- - -static void M184Sync(void) { - setchr4(0x0000, latche); - setchr4(0x1000, latche >> 4); - setprg32(0x8000, 0); -} - -void Mapper184_Init(CartInfo *info) { - Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 203 --------------------------- - -static void M203Sync(void) { - setprg16(0x8000, (latche >> 2) & 3); - setprg16(0xC000, (latche >> 2) & 3); - setchr8(latche & 3); -} - -void Mapper203_Init(CartInfo *info) { - Latch_Init(info, M203Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 240 --------------------------- - -static void M240Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xF); -} - -void Mapper240_Init(CartInfo *info) { - Latch_Init(info, M240Sync, 0, 0x4020, 0x5FFF, 1, 0); -} - -//------------------ Map 241 --------------------------- -// Mapper 7 mostly, but with SRAM or maybe prot circuit -// figure out, which games do need 5xxx area reading - -static void M241Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - if (latche & 0x80) - setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall? - else - setprg32(0x8000, latche); -} - -void Mapper241_Init(CartInfo *info) { - Latch_Init(info, M241Sync, 0, 0x8000, 0xFFFF, 1, 0); -} - -//------------------ A65AS --------------------------- - -// actually, there is two cart in one... First have extra mirroring -// mode (one screen) and 32K bankswitching, second one have only -// 16 bankswitching mode and normal mirroring... But there is no any -// correlations between modes and they can be used in one mapper code. - -static void BMCA65ASSync(void) { - if (latche & 0x40) - setprg32(0x8000, (latche >> 1) & 0x0F); - else { - setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7)); - setprg16(0xC000, ((latche & 0x30) >> 1) | 7); - } - setchr8(0); - if (latche & 0x80) - setmirror(MI_0 + (((latche >> 5) & 1))); - else - setmirror(((latche >> 3) & 1) ^ 1); -} - -void BMCA65AS_Init(CartInfo *info) { - Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ BMC-11160 --------------------------- -// Simple BMC discrete mapper by TXC - -static void BMC11160Sync(void) { - uint32 bank = (latche >> 4) & 7; - setprg32(0x8000, bank); - setchr8((bank << 2) | (latche & 3)); - setmirror((latche >> 7) & 1); -} - -void BMC11160_Init(CartInfo *info) { - Latch_Init(info, BMC11160Sync, 0, 0x8000, 0xFFFF, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/edu2000.cpp b/branches/fceux-2.2.2/src/boards/edu2000.cpp deleted file mode 100644 index a8726391..00000000 --- a/branches/fceux-2.2.2/src/boards/edu2000.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 *WRAM = NULL; -static uint8 reg; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, (reg & 0xC0) >> 6); - setprg32(0x8000, reg & 0x1F); -// setmirror(((reg&0x20)>>5)); -} - -static DECLFW(UNLEDU2000HiWrite) { -// FCEU_printf("%04x:%02x\n",A,V); - reg = V; - Sync(); -} - -static void UNLEDU2000Power(void) { - setmirror(MI_0); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, UNLEDU2000HiWrite); - reg = 0; - Sync(); -} - -static void UNLEDU2000Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void UNLEDU2000Restore(int version) { - Sync(); -} - -void UNLEDU2000_Init(CartInfo *info) { - info->Power = UNLEDU2000Power; - info->Close = UNLEDU2000Close; - GameStateRestore = UNLEDU2000Restore; - WRAM = (uint8*)FCEU_gmalloc(32768); - SetupCartPRGMapping(0x10, WRAM, 32768, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = 32768; - } - AddExState(WRAM, 32768, 0, "WRAM"); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/famicombox.cpp b/branches/fceux-2.2.2/src/boards/famicombox.cpp deleted file mode 100644 index 05c6a629..00000000 --- a/branches/fceux-2.2.2/src/boards/famicombox.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 regs[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg2r(0x10, 0x0800, 0); - setprg2r(0x10, 0x1000, 1); - setprg2r(0x10, 0x1800, 2); - setprg8r(0x10, 0x6000, 1); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); -} - -//static DECLFW(SSSNROMWrite) -//{ -// CartBW(A,V); -//} - -static DECLFW(SSSNROMWrite) { -// FCEU_printf("write %04x %02x\n",A,V); -// regs[A&7] = V; -} - -static DECLFR(SSSNROMRead) { -// FCEU_printf("read %04x\n",A); - switch (A & 7) { - case 0: return regs[0] = 0xff; // clear all exceptions - case 2: return 0xc0; // DIP selftest + freeplay - case 3: return 0x00; // 0, 1 - attract - // 2 - // 4 - menu - // 8 - self check and game casette check - // 10 - lock? - // 20 - game title & count display - case 7: return 0x22; // TV type, key not turned, relay B - default: return 0; - } -} - -static void SSSNROMPower(void) { - regs[0] = regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = regs[6] = 0; - regs[7] = 0xff; - Sync(); - memset(WRAM, 0x00, WRAMSIZE); -// SetWriteHandler(0x0000,0x1FFF,SSSNROMRamWrite); - SetReadHandler(0x0800, 0x1FFF, CartBR); - SetWriteHandler(0x0800, 0x1FFF, CartBW); - SetReadHandler(0x5000, 0x5FFF, SSSNROMRead); - SetWriteHandler(0x5000, 0x5FFF, SSSNROMWrite); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void SSSNROMReset(void) { - regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = regs[6] = 0; -} - -static void SSSNROMClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void SSSNROMIRQHook(void) { -// X6502_IRQBegin(FCEU_IQEXT); -} - -static void StateRestore(int version) { - Sync(); -} - -void SSSNROM_Init(CartInfo *info) { - info->Reset = SSSNROMReset; - info->Power = SSSNROMPower; - info->Close = SSSNROMClose; - GameHBIRQHook = SSSNROMIRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 16384; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/ffe.cpp b/branches/fceux-2.2.2/src/boards/ffe.cpp deleted file mode 100644 index da354114..00000000 --- a/branches/fceux-2.2.2/src/boards/ffe.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FFE Copier Mappers - * - */ - -#include "mapinc.h" - -static uint8 preg[4], creg[8], latch, ffemode; -static uint8 IRQa, mirr; -static int32 IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - if (ffemode) { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, preg[3]); - } else { - setchr8(latch & 3); - setprg16(0x8000, (latch >> 2) & 0x3F); - setprg16(0xc000, 0x7); - } - switch (mirr) { - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - } -} - -static DECLFW(FFEWriteMirr) { - mirr = ((A << 1) & 2) | ((V >> 4) & 1); - Sync(); -} - -static DECLFW(FFEWriteIRQ) { - switch (A) { - case 0x4501: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x4502: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x4503: IRQCount &= 0x00FF; IRQCount |= V << 8; IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -static DECLFW(FFEWritePrg) { - preg[A & 3] = V; - Sync(); -} - -static DECLFW(FFEWriteChr) { - creg[A & 7] = V; - Sync(); -} - -static DECLFW(FFEWriteLatch) { - latch = V; - Sync(); -} - -static void FFEPower(void) { - preg[3] = ~0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x42FE, 0x42FF, FFEWriteMirr); - SetWriteHandler(0x4500, 0x4503, FFEWriteIRQ); - SetWriteHandler(0x4504, 0x4507, FFEWritePrg); - SetWriteHandler(0x4510, 0x4517, FFEWriteChr); - SetWriteHandler(0x4510, 0x4517, FFEWriteChr); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, FFEWriteLatch); -} - -static void FFEIRQHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount >= 0x10000) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = 0; - } - } -} - -static void FFEClose(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper6_Init(CartInfo *info) { - ffemode = 0; - mirr = ((info->mirror & 1) ^ 1) | 2; - - info->Power = FFEPower; - info->Close = FFEClose; - MapIRQHook = FFEIRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper17_Init(CartInfo *info) { - ffemode = 1; - Mapper6_Init(info); -} diff --git a/branches/fceux-2.2.2/src/boards/fk23c.cpp b/branches/fceux-2.2.2/src/boards/fk23c.cpp deleted file mode 100644 index 604d5160..00000000 --- a/branches/fceux-2.2.2/src/boards/fk23c.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" -#include "../ines.h" - -static bool is_BMCFK23CA; -static uint8 unromchr; -static uint32 dipswitch; -static uint8 *CHRRAM=NULL; -static uint32 CHRRAMSize; - -static void BMCFK23CCW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x40) - setchr8(EXPREGS[2]|unromchr); - else if(EXPREGS[0]&0x20) { - setchr1r(0x10, A, V); - } - else - { - uint16 base=(EXPREGS[2]&0x7F)<<3; - if(EXPREGS[3]&2) - { - int cbase=(MMC3_cmd&0x80)<<5; - setchr1(A,V|base); - setchr1(0x0000^cbase,DRegBuf[0]|base); - setchr1(0x0400^cbase,EXPREGS[6]|base); - setchr1(0x0800^cbase,DRegBuf[1]|base); - setchr1(0x0c00^cbase,EXPREGS[7]|base); - } - else - setchr1(A,V|base); - } -} - -//some games are wired differently, and this will need to be changed. -//all the WXN games require prg_bonus = 1, and cah4e3's multicarts require prg_bonus = 0 -//we'll populate this from a game database -static int prg_bonus; -static int prg_mask; - -//prg_bonus = 0 -//4-in-1 (FK23C8021)[p1][!].nes -//4-in-1 (FK23C8033)[p1][!].nes -//4-in-1 (FK23C8043)[p1][!].nes -//4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes - -//prg_bonus = 1 -//[m176]大富ç¿2-上海大亨.wxn.nes -//[m176]宠物翡翠.fix.nes -//[m176]格兰å¸äºš.wxn.nes -//[m176]梦幻之星.wxn.nes -//[m176]水浒神兽.fix.nes -//[m176]西楚霸王.fix.nes -//[m176]超级大富ç¿.wxn.nes -//[m176]雄霸天下.wxn.nes - -//works as-is under virtuanes m176 -//[m176]三侠五义.wxn.nes -//[m176]å£è¢‹é‡‘.fix.nes -//[m176]爆笑三国.fix.nes - -//needs other tweaks -//[m176]三国忠烈传.wxn.nes -//[m176]破釜沉舟.fix.nes - -//PRG wrapper -static void BMCFK23CPW(uint32 A, uint8 V) -{ - uint32 bank = (EXPREGS[1] & 0x1F); - uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0); - uint32 block = (EXPREGS[1] & 0x60) | hiblock; - uint32 extra = (EXPREGS[3] & 2); - - if((EXPREGS[0]&7)==4) - setprg32(0x8000,EXPREGS[1]>>1); - else if ((EXPREGS[0]&7)==3) - { - setprg16(0x8000,EXPREGS[1]); - setprg16(0xC000,EXPREGS[1]); - } - else - { - if(EXPREGS[0]&3) - { - uint32 blocksize = (6)-(EXPREGS[0]&3); - uint32 mask = (1<Power=BMCFK23CPower; - info->Reset=BMCFK23CReset; - AddExState(EXPREGS, 8, 0, "EXPR"); - AddExState(&unromchr, 1, 0, "UCHR"); - AddExState(&dipswitch, 1, 0, "DPSW"); - - prg_bonus = 1; - if(MasterRomInfoParams.find("bonus") != MasterRomInfoParams.end()) - prg_bonus = atoi(MasterRomInfoParams["bonus"].c_str()); - - prg_mask = 0x7F>>(prg_bonus); -} - -void BMCFK23CA_Init(CartInfo *info) -{ - is_BMCFK23CA = true; - - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap=BMCFK23CCW; - pwrap=BMCFK23CPW; - info->Power=BMCFK23CAPower; - info->Reset=BMCFK23CReset; - info->Close=BMCFK23CAClose; - - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CRAM"); - - AddExState(EXPREGS, 8, 0, "EXPR"); - AddExState(&unromchr, 1, 0, "UCHR"); - AddExState(&dipswitch, 1, 0, "DPSW"); - - prg_bonus = 1; - if(MasterRomInfoParams.find("bonus") != MasterRomInfoParams.end()) - prg_bonus = atoi(MasterRomInfoParams["bonus"].c_str()); - prg_mask = 0x7F>>(prg_bonus); -} diff --git a/branches/fceux-2.2.2/src/boards/ks7012.cpp b/branches/fceux-2.2.2/src/boards/ks7012.cpp deleted file mode 100644 index feaa7542..00000000 --- a/branches/fceux-2.2.2/src/boards/ks7012.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, reg & 1); - setchr8(0); -} - -static DECLFW(UNLKS7012Write) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A) { - case 0xE0A0: reg = 0; Sync(); break; - case 0xEE36: reg = 1; Sync(); break; - } -} - -static void UNLKS7012Power(void) { - reg = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLKS7012Write); -} - -static void UNLKS7012Reset(void) { - reg = ~0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -static void UNLKS7012Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void UNLKS7012_Init(CartInfo *info) { - info->Power = UNLKS7012Power; - info->Reset = UNLKS7012Reset; - info->Close = UNLKS7012Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/ks7017.cpp b/branches/fceux-2.2.2/src/boards/ks7017.cpp deleted file mode 100644 index 29c02037..00000000 --- a/branches/fceux-2.2.2/src/boards/ks7017.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg, mirr; -static int32 IRQa, IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &mirr, 1, "MIRR" }, - { ®, 1, "REGS" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, reg); - setprg16(0xC000, 2); - setmirror(mirr); -} - -static DECLFW(UNLKS7017Write) { -// FCEU_printf("bs %04x %02x\n",A,V); - if ((A & 0xFF00) == 0x4A00) { - reg = ((A >> 2) & 3) | ((A >> 4) & 4); - } else if ((A & 0xFF00) == 0x5100) { - Sync(); - } else if (A == 0x4020) { - X6502_IRQEnd(FCEU_IQEXT); - IRQCount &= 0xFF00; - IRQCount |= V; - } else if (A == 0x4021) { - X6502_IRQEnd(FCEU_IQEXT); - IRQCount &= 0xFF; - IRQCount |= V << 8; - IRQa = 1; - } else if (A == 0x4025) { - mirr = ((V & 8) >> 3) ^ 1; - } -} -static DECLFR(FDSRead4030) { - X6502_IRQEnd(FCEU_IQEXT); - return X.IRQlow & FCEU_IQEXT ? 1 : 0; -} - -static void UNL7017IRQ(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void UNLKS7017Power(void) { - Sync(); - setchr8(0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4030, 0x4030, FDSRead4030); - SetWriteHandler(0x4020, 0x5FFF, UNLKS7017Write); -} - -static void UNLKS7017Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7017_Init(CartInfo *info) { - info->Power = UNLKS7017Power; - info->Close = UNLKS7017Close; - MapIRQHook = UNL7017IRQ; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/ks7037.cpp b/branches/fceux-2.2.2/src/boards/ks7037.cpp deleted file mode 100644 index efe43f21..00000000 --- a/branches/fceux-2.2.2/src/boards/ks7037.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg[8], cmd; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static void (*WSync)(void); - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void SyncKS7037(void) { - setprg4r(0x10, 0x6000, 0); - setprg4(0x7000, 15); - setprg8(0x8000, reg[6]); - setprg4(0xA000, ~3); - setprg4r(0x10, 0xB000, 1); - setprg8(0xC000, reg[7]); - setprg8(0xE000, ~0); - setchr8(0); - setmirrorw(reg[2] & 1, reg[4] & 1, reg[3] & 1, reg[5] & 1); -} - -static void SyncLH10(void) { - setprg8(0x6000, ~1); - setprg8(0x8000, reg[6]); - setprg8(0xA000, reg[7]); - setprg8r(0x10, 0xC000, 0); - setprg8(0xE000, ~0); - setchr8(0); - setmirror(0); -} - -static DECLFW(UNLKS7037Write) { - switch (A & 0xE001) { - case 0x8000: cmd = V & 7; break; - case 0x8001: reg[cmd] = V; WSync(); break; - } -} - -static void UNLKS7037Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = reg[4] = reg[5] = reg[6] = reg[7] = 0; - WSync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0x9FFF, UNLKS7037Write); - SetWriteHandler(0xA000, 0xBFFF, CartBW); - SetWriteHandler(0xC000, 0xFFFF, UNLKS7037Write); -} - -static void LH10Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = reg[4] = reg[5] = reg[6] = reg[7] = 0; - WSync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, UNLKS7037Write); - SetWriteHandler(0xC000, 0xDFFF, CartBW); - SetWriteHandler(0xE000, 0xFFFF, UNLKS7037Write); -} - -static void Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -void UNLKS7037_Init(CartInfo *info) { - info->Power = UNLKS7037Power; - info->Close = Close; - - WSync = SyncKS7037; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void LH10_Init(CartInfo *info) { - info->Power = LH10Power; - info->Close = Close; - - WSync = SyncLH10; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/lh32.cpp b/branches/fceux-2.2.2/src/boards/lh32.cpp deleted file mode 100644 index 2150aee2..00000000 --- a/branches/fceux-2.2.2/src/boards/lh32.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg); - setprg8(0x8000, ~3); - setprg8(0xa000, ~2); - setprg8r(0x10, 0xc000, 0); - setprg8(0xe000, ~0); - setchr8(0); -} - -static DECLFW(LH32Write) { - reg = V; - Sync(); -} - -static void LH32Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0xC000, 0xDFFF, CartBW); - SetWriteHandler(0x6000, 0x6000, LH32Write); -} - -static void LH32Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void LH32_Init(CartInfo *info) { - info->Power = LH32Power; - info->Close = LH32Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/lh53.cpp b/branches/fceux-2.2.2/src/boards/lh53.cpp deleted file mode 100644 index 7626dca5..00000000 --- a/branches/fceux-2.2.2/src/boards/lh53.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg, IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8(0x6000, reg); - setprg8(0x8000, 0xc); - setprg4(0xa000, (0xd << 1)); - setprg2(0xb000, (0xd << 2) + 2); - setprg2r(0x10, 0xb800, 4); - setprg2r(0x10, 0xc000, 5); - setprg2r(0x10, 0xc800, 6); - setprg2r(0x10, 0xd000, 7); - setprg2(0xd800, (0xe << 2) + 3); - setprg8(0xe000, 0xf); -} - -static DECLFW(LH53RamWrite) { - WRAM[(A - 0xB800) & 0x1FFF] = V; -} - -static DECLFW(LH53Write) { - reg = V; - Sync(); -} - -static DECLFW(LH53IRQaWrite) { - IRQa = V & 2; - IRQCount = 0; - if (!IRQa) - X6502_IRQEnd(FCEU_IQEXT); -} - -static void LH53IRQ(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount > 7560) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void LH53Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0xB800, 0xD7FF, LH53RamWrite); - SetWriteHandler(0xE000, 0xEFFF, LH53IRQaWrite); - SetWriteHandler(0xF000, 0xFFFF, LH53Write); -} - -static void LH53Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void LH53_Init(CartInfo *info) { - info->Power = LH53Power; - info->Close = LH53Close; - MapIRQHook = LH53IRQ; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/mmc1.cpp b/branches/fceux-2.2.2/src/boards/mmc1.cpp deleted file mode 100644 index 17fab418..00000000 --- a/branches/fceux-2.2.2/src/boards/mmc1.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static void GenMMC1Power(void); -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery); - -static uint8 DRegs[4]; -static uint8 Buffer, BufferShift; - -static int mmc1opts; - -static void (*MMC1CHRHook4)(uint32 A, uint8 V); -static void (*MMC1PRGHook16)(uint32 A, uint8 V); - -static uint8 *WRAM = NULL; -static uint8 *CHRRAM = NULL; -static int is155, is171; - -static DECLFW(MBWRAM) { - if (!(DRegs[3] & 0x10) || is155) - Page[A >> 11][A] = V; // WRAM is enabled. -} - -static DECLFR(MAWRAM) { - if ((DRegs[3] & 0x10) && !is155) - return X.DB; // WRAM is disabled - return(Page[A >> 11][A]); -} - -static void MMC1CHR(void) { - if (mmc1opts & 4) { - if (DRegs[0] & 0x10) - setprg8r(0x10, 0x6000, (DRegs[1] >> 4) & 1); - else - setprg8r(0x10, 0x6000, (DRegs[1] >> 3) & 1); - } - - if (MMC1CHRHook4) { - if (DRegs[0] & 0x10) { - MMC1CHRHook4(0x0000, DRegs[1]); - MMC1CHRHook4(0x1000, DRegs[2]); - } else { - MMC1CHRHook4(0x0000, (DRegs[1] & 0xFE)); - MMC1CHRHook4(0x1000, DRegs[1] | 1); - } - } else { - if (DRegs[0] & 0x10) { - setchr4(0x0000, DRegs[1]); - setchr4(0x1000, DRegs[2]); - } else - setchr8(DRegs[1] >> 1); - } -} - -static void MMC1PRG(void) { - uint8 offs = DRegs[1] & 0x10; - if (MMC1PRGHook16) { - switch (DRegs[0] & 0xC) { - case 0xC: - MMC1PRGHook16(0x8000, (DRegs[3] + offs)); - MMC1PRGHook16(0xC000, 0xF + offs); - break; - case 0x8: - MMC1PRGHook16(0xC000, (DRegs[3] + offs)); - MMC1PRGHook16(0x8000, offs); - break; - case 0x0: - case 0x4: - MMC1PRGHook16(0x8000, ((DRegs[3] & ~1) + offs)); - MMC1PRGHook16(0xc000, ((DRegs[3] & ~1) + offs + 1)); - break; - } - } else { - switch (DRegs[0] & 0xC) { - case 0xC: - setprg16(0x8000, (DRegs[3] + offs)); - setprg16(0xC000, 0xF + offs); - break; - case 0x8: - setprg16(0xC000, (DRegs[3] + offs)); - setprg16(0x8000, offs); - break; - case 0x0: - case 0x4: - setprg16(0x8000, ((DRegs[3] & ~1) + offs)); - setprg16(0xc000, ((DRegs[3] & ~1) + offs + 1)); - break; - } - } -} - -static void MMC1MIRROR(void) { - if (!is171) - switch (DRegs[0] & 3) { - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - } -} - -static uint64 lreset; -static DECLFW(MMC1_write) { - int n = (A >> 13) - 4; - - /* The MMC1 is busy so ignore the write. */ - /* As of version FCE Ultra 0.81, the timestamp is only - increased before each instruction is executed(in other words - precision isn't that great), but this should still work to - deal with 2 writes in a row from a single RMW instruction. - */ - if ((timestampbase + timestamp) < (lreset + 2)) - return; -// FCEU_printf("Write %04x:%02x\n",A,V); - if (V & 0x80) { - DRegs[0] |= 0xC; - BufferShift = Buffer = 0; - MMC1PRG(); - lreset = timestampbase + timestamp; - return; - } - - Buffer |= (V & 1) << (BufferShift++); - - if (BufferShift == 5) { - DRegs[n] = Buffer; - BufferShift = Buffer = 0; - switch (n) { - case 0: MMC1MIRROR(); MMC1CHR(); MMC1PRG(); break; - case 1: MMC1CHR(); MMC1PRG(); break; - case 2: MMC1CHR(); break; - case 3: MMC1PRG(); break; - } - } -} - -static void MMC1_Restore(int version) { - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); - lreset = 0; // timestamp(base) is not stored in save states. -} - -static void MMC1CMReset(void) { - int i; - - for (i = 0; i < 4; i++) - DRegs[i] = 0; - Buffer = BufferShift = 0; - DRegs[0] = 0x1F; - - DRegs[1] = 0; - DRegs[2] = 0; // Should this be something other than 0? - DRegs[3] = 0; - - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); -} - -static int DetectMMC1WRAMSize(uint32 crc32) { - switch (crc32) { - case 0xc6182024: // Romance of the 3 Kingdoms - case 0x2225c20f: // Genghis Khan - case 0x4642dda6: // Nobunaga's Ambition - case 0x29449ba9: // "" "" (J) - case 0x2b11e0b0: // "" "" (J) - case 0xb8747abf: // Best Play Pro Yakyuu Special (J) - case 0xc9556b36: // Final Fantasy I & II (J) [!] - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(16); - break; - default: return(8); - } -} - -static uint32 NWCIRQCount; -static uint8 NWCRec; -#define NWCDIP 0xE - -static void NWCIRQHook(int a) { - if (!(NWCRec & 0x10)) { - NWCIRQCount += a; - if ((NWCIRQCount | (NWCDIP << 25)) >= 0x3e000000) { - NWCIRQCount = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void NWCCHRHook(uint32 A, uint8 V) { - if ((V & 0x10)) { // && !(NWCRec&0x10)) - NWCIRQCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - } - - NWCRec = V; - if (V & 0x08) - MMC1PRG(); - else - setprg32(0x8000, (V >> 1) & 3); -} - -static void NWCPRGHook(uint32 A, uint8 V) { - if (NWCRec & 0x8) - setprg16(A, 8 | (V & 0x7)); - else - setprg32(0x8000, (NWCRec >> 1) & 3); -} - -static void NWCPower(void) { - GenMMC1Power(); - setchr8r(0, 0); -} - -void Mapper105_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 8, 0); - MMC1CHRHook4 = NWCCHRHook; - MMC1PRGHook16 = NWCPRGHook; - MapIRQHook = NWCIRQHook; - info->Power = NWCPower; -} - -static void GenMMC1Power(void) { - lreset = 0; - if (mmc1opts & 1) { - FCEU_CheatAddRAM(8, 0x6000, WRAM); - if (mmc1opts & 4) - FCEU_dwmemset(WRAM, 0, 8192) - else if (!(mmc1opts & 2)) - FCEU_dwmemset(WRAM, 0, 8192); - } - SetWriteHandler(0x8000, 0xFFFF, MMC1_write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - if (mmc1opts & 1) { - SetReadHandler(0x6000, 0x7FFF, MAWRAM); - SetWriteHandler(0x6000, 0x7FFF, MBWRAM); - setprg8r(0x10, 0x6000, 0); - } - - MMC1CMReset(); -} - -static void GenMMC1Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - if (WRAM) - FCEU_gfree(WRAM); - CHRRAM = WRAM = NULL; -} - -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) { - is155 = 0; - - info->Close = GenMMC1Close; - MMC1PRGHook16 = MMC1CHRHook4 = 0; - mmc1opts = 0; - PRGmask16[0] &= (prg >> 14) - 1; - CHRmask4[0] &= (chr >> 12) - 1; - CHRmask8[0] &= (chr >> 13) - 1; - - if (wram) { - WRAM = (uint8*)FCEU_gmalloc(wram * 1024); - //mbg 17-jun-08 - this shouldve been cleared to re-initialize save ram - //ch4 10-dec-08 - nope, this souldn't - //mbg 29-mar-09 - no time to debate this, we need to keep from breaking some old stuff. - //we really need to make up a policy for how compatibility and accuracy can be resolved. - memset(WRAM, 0, wram * 1024); - mmc1opts |= 1; - if (wram > 8) mmc1opts |= 4; - SetupCartPRGMapping(0x10, WRAM, wram * 1024, 1); - AddExState(WRAM, wram * 1024, 0, "WRAM"); - if (battery) { - mmc1opts |= 2; - info->SaveGame[0] = WRAM + ((mmc1opts & 4) ? 8192 : 0); - info->SaveGameLen[0] = 8192; - } - } - if (!chr) { - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - } - AddExState(DRegs, 4, 0, "DREG"); - - info->Power = GenMMC1Power; - GameStateRestore = MMC1_Restore; - AddExState(&lreset, 8, 1, "LRST"); - AddExState(&Buffer, 1, 1, "BFFR"); - AddExState(&BufferShift, 1, 1, "BFRS"); -} - -void Mapper1_Init(CartInfo *info) { - int ws = DetectMMC1WRAMSize(info->CRC32); - GenMMC1Init(info, 512, 256, ws, info->battery); -} - -/* Same as mapper 1, without respect for WRAM enable bit. */ -void Mapper155_Init(CartInfo *info) { - GenMMC1Init(info, 512, 256, 8, info->battery); - is155 = 1; -} - -/* Same as mapper 1, with different (or without) mirroring control. */ -/* Kaiser KS7058 board, KS203 custom chip */ -void Mapper171_Init(CartInfo *info) { - GenMMC1Init(info, 32, 32, 0, 0); - is171 = 1; -} - -void SAROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 64, 8, info->battery); -} - -void SBROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 64, 0, 0); -} - -void SCROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 128, 0, 0); -} - -void SEROM_Init(CartInfo *info) { - GenMMC1Init(info, 32, 64, 0, 0); -} - -void SGROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 0, 0); -} - -void SKROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 64, 8, info->battery); -} - -void SLROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 128, 0, 0); -} - -void SL1ROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 128, 0, 0); -} - -/* Begin unknown - may be wrong - perhaps they use different MMC1s from the - similarly functioning boards? -*/ - -void SL2ROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SFROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SHROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -/* End unknown */ -/* */ -/* */ - -void SNROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 8, info->battery); -} - -void SOROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 16, info->battery); -} - - diff --git a/branches/fceux-2.2.2/src/boards/mmc2and4.cpp b/branches/fceux-2.2.2/src/boards/mmc2and4.cpp deleted file mode 100644 index e2c3d7ea..00000000 --- a/branches/fceux-2.2.2/src/boards/mmc2and4.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 is10; -static uint8 creg[4], latch0, latch1, preg, mirr; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { creg, 4, "CREG" }, - { &preg, 1, "PREG" }, - { &mirr, 1, "MIRR" }, - { &latch0, 1, "LAT0" }, - { &latch1, 1, "LAT1" }, - { 0 } -}; - -static void Sync(void) { - if (is10) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - } else { - setprg8(0x8000, preg); - setprg8(0xA000, ~2); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - } - setchr4(0x0000, creg[latch0]); - setchr4(0x1000, creg[latch1 + 2]); - setmirror(mirr); -} - -DECLFW(MMC2and4Write) { - switch (A & 0xF000) { - case 0xA000: preg = V; Sync(); break; - case 0xB000: creg[0] = V; Sync(); break; - case 0xC000: creg[1] = V; Sync(); break; - case 0xD000: creg[2] = V; Sync(); break; - case 0xE000: creg[3] = V; Sync(); break; - case 0xF000: mirr = (V & 1) ^ 1; Sync(); break; - } -} - -static void MMC2and4PPUHook(uint32 A) { - uint8 l, h = A >> 8; - if (h >= 0x20 || ((h & 0xF) != 0xF)) - return; - l = A & 0xF0; - if (h < 0x10) { - if (l == 0xD0) { - latch0 = 0; - setchr4(0x0000, creg[0]); - } else if (l == 0xE0) { - latch0 = 1; - setchr4(0x0000, creg[1]); - } - } else { - if (l == 0xD0) { - latch1 = 0; - setchr4(0x1000, creg[2]); - } else if (l == 0xE0) { - latch1 = 1; - setchr4(0x1000, creg[3]); - } - } -} - -static void MMC2and4Power(void) { - preg = 0; - latch0 = latch1 = 1; - Sync(); - if (is10) { - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0xA000, 0xFFFF, MMC2and4Write); -} - -static void StateRestore(int version) { - Sync(); -} - -static void MMC2and4Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper9_Init(CartInfo *info) { - is10 = 0; - info->Power = MMC2and4Power; - PPU_hook = MMC2and4PPUHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper10_Init(CartInfo *info) { - is10 = 1; - info->Power = MMC2and4Power; - info->Close = MMC2and4Close; - PPU_hook = MMC2and4PPUHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/mmc3.cpp b/branches/fceux-2.2.2/src/boards/mmc3.cpp deleted file mode 100644 index 775a6766..00000000 --- a/branches/fceux-2.2.2/src/boards/mmc3.cpp +++ /dev/null @@ -1,1328 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2003 Xodnizel - * Mapper 12 code Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,165,205,245,249,250,254 -*/ - -#include "mapinc.h" -#include "mmc3.h" - -uint8 MMC3_cmd; -uint8 *WRAM; -uint32 WRAMSIZE; -uint8 *CHRRAM; -uint32 CHRRAMSIZE; -uint8 DRegBuf[8]; -uint8 EXPREGS[8]; /* For bootleg games, mostly. */ -uint8 A000B, A001B; -uint8 mmc3opts = 0; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -uint8 IRQCount, IRQLatch, IRQa; -uint8 IRQReload; - -static SFORMAT MMC3_StateRegs[] = -{ - { DRegBuf, 8, "REGS" }, - { &MMC3_cmd, 1, "CMD" }, - { &A000B, 1, "A000" }, - { &A001B, 1, "A001" }, - { &IRQReload, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static int isRevB = 1; - -void (*pwrap)(uint32 A, uint8 V); -void (*cwrap)(uint32 A, uint8 V); -void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); - -// ---------------------------------------------------------------------- -// ------------------------- Generic MM3 Code --------------------------- -// ---------------------------------------------------------------------- - -void FixMMC3PRG(int V) { - if (V & 0x40) { - pwrap(0xC000, DRegBuf[6]); - pwrap(0x8000, ~1); - } else { - pwrap(0x8000, DRegBuf[6]); - pwrap(0xC000, ~1); - } - pwrap(0xA000, DRegBuf[7]); - pwrap(0xE000, ~0); -} - -void FixMMC3CHR(int V) { - int cbase = (V & 0x80) << 5; - - cwrap((cbase ^ 0x000), DRegBuf[0] & (~1)); - cwrap((cbase ^ 0x400), DRegBuf[0] | 1); - cwrap((cbase ^ 0x800), DRegBuf[1] & (~1)); - cwrap((cbase ^ 0xC00), DRegBuf[1] | 1); - - cwrap(cbase ^ 0x1000, DRegBuf[2]); - cwrap(cbase ^ 0x1400, DRegBuf[3]); - cwrap(cbase ^ 0x1800, DRegBuf[4]); - cwrap(cbase ^ 0x1c00, DRegBuf[5]); - - if (mwrap) mwrap(A000B); -} - -void MMC3RegReset(void) { - IRQCount = IRQLatch = IRQa = MMC3_cmd = 0; - - DRegBuf[0] = 0; - DRegBuf[1] = 2; - DRegBuf[2] = 4; - DRegBuf[3] = 5; - DRegBuf[4] = 6; - DRegBuf[5] = 7; - DRegBuf[6] = 0; - DRegBuf[7] = 1; - - FixMMC3PRG(0); - FixMMC3CHR(0); -} - -DECLFW(MMC3_CMDWrite) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A & 0xE001) { - case 0x8000: - if ((V & 0x40) != (MMC3_cmd & 0x40)) - FixMMC3PRG(V); - if ((V & 0x80) != (MMC3_cmd & 0x80)) - FixMMC3CHR(V); - MMC3_cmd = V; - break; - case 0x8001: - { - int cbase = (MMC3_cmd & 0x80) << 5; - DRegBuf[MMC3_cmd & 0x7] = V; - switch (MMC3_cmd & 0x07) { - case 0: - cwrap((cbase ^ 0x000), V & (~1)); - cwrap((cbase ^ 0x400), V | 1); - break; - case 1: - cwrap((cbase ^ 0x800), V & (~1)); - cwrap((cbase ^ 0xC00), V | 1); - break; - case 2: - cwrap(cbase ^ 0x1000, V); - break; - case 3: - cwrap(cbase ^ 0x1400, V); - break; - case 4: - cwrap(cbase ^ 0x1800, V); - break; - case 5: - cwrap(cbase ^ 0x1C00, V); - break; - case 6: - if (MMC3_cmd & 0x40) - pwrap(0xC000, V); - else - pwrap(0x8000, V); - break; - case 7: - pwrap(0xA000, V); - break; - } - break; - } - case 0xA000: - if (mwrap) mwrap(V); - break; - case 0xA001: - A001B = V; - break; - } -} - -DECLFW(MMC3_IRQWrite) { -// FCEU_printf("%04x:%04x\n",A,V); - switch (A & 0xE001) { - case 0xC000: IRQLatch = V; break; - case 0xC001: IRQReload = 1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xE001: IRQa = 1; break; - } -} - -static void ClockMMC3Counter(void) { - int count = IRQCount; - if (!count || IRQReload) { - IRQCount = IRQLatch; - IRQReload = 0; - } else - IRQCount--; - if ((count | isRevB) && !IRQCount) { - if (IRQa) { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void MMC3_hb(void) { - ClockMMC3Counter(); -} - -static void MMC3_hb_KickMasterHack(void) { - if (scanline == 238) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -static void MMC3_hb_PALStarWarsHack(void) { - if (scanline == 240) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -void GenMMC3Restore(int version) { - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void GENCWRAP(uint32 A, uint8 V) { - setchr1(A, V); // Business Wars NEEDS THIS for 8K CHR-RAM -} - -static void GENPWRAP(uint32 A, uint8 V) { - setprg8(A, V & 0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken -} - -static void GENMWRAP(uint8 V) { - A000B = V; - setmirror((V & 1) ^ 1); -} - -static void GENNOMWRAP(uint8 V) { - A000B = V; -} - -static DECLFW(MBWRAMMMC6) { - WRAM[A & 0x3ff] = V; -} - -static DECLFR(MAWRAMMMC6) { - return(WRAM[A & 0x3ff]); -} - -void GenMMC3Power(void) { - if (UNIFchrrama) setchr8(0); - - SetWriteHandler(0x8000, 0xBFFF, MMC3_CMDWrite); - SetWriteHandler(0xC000, 0xFFFF, MMC3_IRQWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - A001B = A000B = 0; - setmirror(1); - if (mmc3opts & 1) { - if (WRAMSIZE == 1024) { - FCEU_CheatAddRAM(1, 0x7000, WRAM); - SetReadHandler(0x7000, 0x7FFF, MAWRAMMMC6); - SetWriteHandler(0x7000, 0x7FFF, MBWRAMMMC6); - } else { - FCEU_CheatAddRAM((WRAMSIZE & 0x1fff) >> 10, 0x6000, WRAM); - SetWriteHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBW); - SetReadHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBR); - setprg8r(0x10, 0x6000, 0); - } - if (!(mmc3opts & 2)) - FCEU_dwmemset(WRAM, 0, WRAMSIZE); - } - MMC3RegReset(); - if (CHRRAM) - FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE); -} - -static void GenMMC3Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - if (WRAM) - FCEU_gfree(WRAM); - CHRRAM = WRAM = NULL; -} - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) { - pwrap = GENPWRAP; - cwrap = GENCWRAP; - mwrap = GENMWRAP; - - WRAMSIZE = wram << 10; - - PRGmask8[0] &= (prg >> 13) - 1; - CHRmask1[0] &= (chr >> 10) - 1; - CHRmask2[0] &= (chr >> 11) - 1; - - if (wram) { - mmc3opts |= 1; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - - if (battery) { - mmc3opts |= 2; - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(MMC3_StateRegs, ~0, 0, 0); - - info->Power = GenMMC3Power; - info->Reset = MMC3RegReset; - info->Close = GenMMC3Close; - - if (info->CRC32 == 0x5104833e) // Kick Master - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if (info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20)// Shougi Meikan '92/'93 - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if (info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. - GameHBIRQHook = MMC3_hb_PALStarWarsHack; - else - GameHBIRQHook = MMC3_hb; - GameStateRestore = GenMMC3Restore; -} - -// ---------------------------------------------------------------------- -// -------------------------- MMC3 Based Code --------------------------- -// ---------------------------------------------------------------------- - -// ---------------------------- Mapper 4 -------------------------------- - -static int hackm4 = 0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/ - -static void M4Power(void) { - GenMMC3Power(); - A000B = (hackm4 ^ 1) & 1; - setmirror(hackm4); -} - -void Mapper4_Init(CartInfo *info) { - int ws = 8; - - if ((info->CRC32 == 0x93991433 || info->CRC32 == 0xaf65aa84)) { - FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); - ws = 0; - } - GenMMC3_Init(info, 512, 256, ws, info->battery); - info->Power = M4Power; - hackm4 = info->mirror; -} - -// ---------------------------- Mapper 12 ------------------------------- - -static void M12CW(uint32 A, uint8 V) { - setchr1(A, (EXPREGS[(A & 0x1000) >> 12] << 8) + V); -} - -static DECLFW(M12Write) { - EXPREGS[0] = V & 0x01; - EXPREGS[1] = (V & 0x10) >> 4; -} - -static DECLFR(M12Read) { - return EXPREGS[2]; -} - -static void M12Power(void) { - EXPREGS[0] = EXPREGS[1] = 0; - EXPREGS[2] = 1; // chinese is default - GenMMC3Power(); - SetWriteHandler(0x4100, 0x5FFF, M12Write); - SetReadHandler(0x4100, 0x5FFF, M12Read); -} - -static void M12Reset(void) { - EXPREGS[0] = EXPREGS[1] = 0; - EXPREGS[2] ^= 1; - MMC3RegReset(); -} - -void Mapper12_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M12CW; - isRevB = 0; - - info->Power = M12Power; - info->Reset = M12Reset; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 37 ------------------------------- - -static void M37PW(uint32 A, uint8 V) { - if (EXPREGS[0] != 2) - V &= 0x7; - else - V &= 0xF; - V |= EXPREGS[0] << 3; - setprg8(A, V); -} - -static void M37CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= EXPREGS[0] << 6; - setchr1(A, NV); -} - -static DECLFW(M37Write) { - EXPREGS[0] = (V & 6) >> 1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M37Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -static void M37Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M37Write); -} - -void Mapper37_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap = M37PW; - cwrap = M37CW; - info->Power = M37Power; - info->Reset = M37Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 44 ------------------------------- - -static void M44PW(uint32 A, uint8 V) { - uint32 NV = V; - if (EXPREGS[0] >= 6) NV &= 0x1F; - else NV &= 0x0F; - NV |= EXPREGS[0] << 4; - setprg8(A, NV); -} - -static void M44CW(uint32 A, uint8 V) { - uint32 NV = V; - if (EXPREGS[0] < 6) NV &= 0x7F; - NV |= EXPREGS[0] << 7; - setchr1(A, NV); -} - -static DECLFW(M44Write) { - if (A & 1) { - EXPREGS[0] = V & 7; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - MMC3_CMDWrite(A, V); -} - -static void M44Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0xA000, 0xBFFF, M44Write); -} - -void Mapper44_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M44CW; - pwrap = M44PW; - info->Power = M44Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 45 ------------------------------- - -static void M45CW(uint32 A, uint8 V) { - if (!UNIFchrrama) { - uint32 NV = V; - if (EXPREGS[2] & 8) - NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1; - else - if (EXPREGS[2]) - NV &= 0; // hack ;( don't know exactly how it should be - NV |= EXPREGS[0] | ((EXPREGS[2] & 0xF0) << 4); - setchr1(A, NV); - } -} - -static void M45PW(uint32 A, uint8 V) { - V &= (EXPREGS[3] & 0x3F) ^ 0x3F; - V |= EXPREGS[1]; - setprg8(A, V); -} - -static DECLFW(M45Write) { - if (EXPREGS[3] & 0x40) { - WRAM[A - 0x6000] = V; - return; - } - EXPREGS[EXPREGS[4]] = V; - EXPREGS[4] = (EXPREGS[4] + 1) & 3; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static DECLFR(M45Read) { - uint32 addr = 1 << (EXPREGS[5] + 4); - if (A & (addr | (addr - 1))) - return X.DB | 1; - else - return X.DB; -} - -static void M45Reset(void) { - EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = 0; - EXPREGS[5]++; - EXPREGS[5] &= 7; - MMC3RegReset(); -} - -static void M45Power(void) { - setchr8(0); - GenMMC3Power(); - EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = EXPREGS[5] = 0; - SetWriteHandler(0x5000, 0x7FFF, M45Write); - SetReadHandler(0x5000, 0x5FFF, M45Read); -} - -void Mapper45_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M45CW; - pwrap = M45PW; - info->Reset = M45Reset; - info->Power = M45Power; - AddExState(EXPREGS, 5, 0, "EXPR"); -} - -// ---------------------------- Mapper 47 ------------------------------- - -static void M47PW(uint32 A, uint8 V) { - V &= 0xF; - V |= EXPREGS[0] << 4; - setprg8(A, V); -} - -static void M47CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= EXPREGS[0] << 7; - setchr1(A, NV); -} - -static DECLFW(M47Write) { - EXPREGS[0] = V & 1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M47Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M47Write); -// SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper47_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); - pwrap = M47PW; - cwrap = M47CW; - info->Power = M47Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 49 ------------------------------- - -static void M49PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 1) { - V &= 0xF; - V |= (EXPREGS[0] & 0xC0) >> 2; - setprg8(A, V); - } else - setprg32(0x8000, (EXPREGS[0] >> 4) & 3); -} - -static void M49CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= (EXPREGS[0] & 0xC0) << 1; - setchr1(A, NV); -} - -static DECLFW(M49Write) { - if (A001B & 0x80) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } -} - -static void M49Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -static void M49Power(void) { - M49Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M49Write); - SetReadHandler(0x6000, 0x7FFF, 0); -} - -void Mapper49_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 0, 0); - cwrap = M49CW; - pwrap = M49PW; - info->Reset = M49Reset; - info->Power = M49Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 52 ------------------------------- -static void M52PW(uint32 A, uint8 V) { - uint32 mask = 0x1F ^ ((EXPREGS[0] & 8) << 1); - uint32 bank = ((EXPREGS[0] & 6) | ((EXPREGS[0] >> 3) & EXPREGS[0] & 1)) << 4; - setprg8(A, bank | (V & mask)); -} - -static void M52CW(uint32 A, uint8 V) { - uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1); -// uint32 bank = (((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - uint32 bank = (((EXPREGS[0] >> 4) & 2) | (EXPREGS[0] & 4) | ((EXPREGS[0] >> 6) & (EXPREGS[0] >> 4) & 1)) << 7; // actually 256K CHR banks index bits is inverted! - setchr1(A, bank | (V & mask)); -} - -static DECLFW(M52Write) { - if (EXPREGS[1]) { - WRAM[A - 0x6000] = V; - return; - } - EXPREGS[1] = V & 0x80; - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M52Reset(void) { - EXPREGS[0] = EXPREGS[1] = 0; - MMC3RegReset(); -} - -static void M52Power(void) { - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M52Write); -} - -void Mapper52_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap = M52CW; - pwrap = M52PW; - info->Reset = M52Reset; - info->Power = M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 76 ------------------------------- - -static void M76CW(uint32 A, uint8 V) { - if (A >= 0x1000) - setchr2((A & 0xC00) << 1, V); -} - -void Mapper76_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - cwrap = M76CW; -} - -// ---------------------------- Mapper 74 ------------------------------- - -static void M74CW(uint32 A, uint8 V) { - if ((V == 8) || (V == 9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper74_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M74CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 114 ------------------------------ - -static uint8 cmdin; -uint8 m114_perm[8] = { 0, 3, 1, 5, 6, 7, 2, 4 }; - -static void M114PWRAP(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { -// FCEU_printf("8000-C000:%02X\n",EXPREGS[0]&0xF); - setprg16(0x8000, EXPREGS[0] & 0xF); - setprg16(0xC000, EXPREGS[0] & 0xF); - } else { -// FCEU_printf("%04X:%02X\n",A,V&0x3F); - setprg8(A, V & 0x3F); - } -} - -static DECLFW(M114Write) { - switch (A & 0xE001) { - case 0x8001: MMC3_CMDWrite(0xA000, V); break; - case 0xA000: MMC3_CMDWrite(0x8000, (V & 0xC0) | (m114_perm[V & 7])); cmdin = 1; break; - case 0xC000: if (!cmdin) break; MMC3_CMDWrite(0x8001, V); cmdin = 0; break; - case 0xA001: IRQLatch = V; break; - case 0xC001: IRQReload = 1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xE001: IRQa = 1; break; - } -} - -static DECLFW(M114ExWrite) { - if (A <= 0x7FFF) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void M114Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, M114Write); - SetWriteHandler(0x5000, 0x7FFF, M114ExWrite); -} - -static void M114Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -void Mapper114_Init(CartInfo *info) { - isRevB = 0; - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M114PWRAP; - info->Power = M114Power; - info->Reset = M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDI"); -} - -// ---------------------------- Mapper 115 KN-658 board ------------------------------ - -static void M115PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { - if (EXPREGS[0] & 0x20) - setprg32(0x8000, (EXPREGS[0] & 0x0F) >> 1); // real hardware tests, info 100% now lol - else { - setprg16(0x8000, (EXPREGS[0] & 0x0F)); - setprg16(0xC000, (EXPREGS[0] & 0x0F)); - } - } else - setprg8(A, V); -} - -static void M115CW(uint32 A, uint8 V) { - setchr1(A, (uint32)V | ((EXPREGS[1] & 1) << 8)); -} - -static DECLFW(M115Write) { - if (A == 0x5080) - EXPREGS[2] = V; // Extra prot hardware 2-in-1 mode - else if (A == 0x6000) - EXPREGS[0] = V; - else if (A == 0x6001) - EXPREGS[1] = V; - FixMMC3PRG(MMC3_cmd); -} - -static DECLFR(M115Read) { - return EXPREGS[2]; -} - -static void M115Power(void) { - GenMMC3Power(); - SetWriteHandler(0x4100, 0x7FFF, M115Write); - SetReadHandler(0x5000, 0x5FFF, M115Read); -} - -void Mapper115_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap = M115CW; - pwrap = M115PW; - info->Power = M115Power; - AddExState(EXPREGS, 3, 0, "EXPR"); -} - -// ---------------------------- Mapper 118 ------------------------------ - -static uint8 PPUCHRBus; -static uint8 TKSMIR[8]; - -static void TKSPPU(uint32 A) { - A &= 0x1FFF; - A >>= 10; - PPUCHRBus = A; - setmirror(MI_0 + TKSMIR[A]); -} - -static void TKSWRAP(uint32 A, uint8 V) { - TKSMIR[A >> 10] = V >> 7; - setchr1(A, V & 0x7F); - if (PPUCHRBus == (A >> 10)) - setmirror(MI_0 + (V >> 7)); -} - -// ---------------------------- Mapper 119 ------------------------------ - -static void TQWRAP(uint32 A, uint8 V) { - setchr1r((V & 0x40) >> 2, A, V & 0x3F); -} - -void Mapper119_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap = TQWRAP; - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); -} - -// ---------------------------- Mapper 134 ------------------------------ - -static void M134PW(uint32 A, uint8 V) { - setprg8(A, (V & 0x1F) | ((EXPREGS[0] & 2) << 4)); -} - -static void M134CW(uint32 A, uint8 V) { - setchr1(A, (V & 0xFF) | ((EXPREGS[0] & 0x20) << 3)); -} - -static DECLFW(M134Write) { - EXPREGS[0] = V; - FixMMC3CHR(MMC3_cmd); - FixMMC3PRG(MMC3_cmd); -} - -static void M134Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6001, 0x6001, M134Write); -} - -static void M134Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -void Mapper134_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M134PW; - cwrap = M134CW; - info->Power = M134Power; - info->Reset = M134Reset; - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 165 ------------------------------ - -static void M165CW(uint32 A, uint8 V) { - if (V == 0) - setchr4r(0x10, A, 0); - else - setchr4(A, V >> 2); -} - -static void M165PPUFD(void) { - if (EXPREGS[0] == 0xFD) { - M165CW(0x0000, DRegBuf[0]); - M165CW(0x1000, DRegBuf[2]); - } -} - -static void M165PPUFE(void) { - if (EXPREGS[0] == 0xFE) { - M165CW(0x0000, DRegBuf[1]); - M165CW(0x1000, DRegBuf[4]); - } -} - -static void M165CWM(uint32 A, uint8 V) { - if (((MMC3_cmd & 0x7) == 0) || ((MMC3_cmd & 0x7) == 2)) - M165PPUFD(); - if (((MMC3_cmd & 0x7) == 1) || ((MMC3_cmd & 0x7) == 4)) - M165PPUFE(); -} - -static void M165PPU(uint32 A) { - if ((A & 0x1FF0) == 0x1FD0) { - EXPREGS[0] = 0xFD; - M165PPUFD(); - } else if ((A & 0x1FF0) == 0x1FE0) { - EXPREGS[0] = 0xFE; - M165PPUFE(); - } -} - -static void M165Power(void) { - EXPREGS[0] = 0xFD; - GenMMC3Power(); -} - -void Mapper165_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 128, 8, info->battery); - cwrap = M165CWM; - PPU_hook = M165PPU; - info->Power = M165Power; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 191 ------------------------------ - -static void M191CW(uint32 A, uint8 V) { - setchr1r((V & 0x80) >> 3, A, V); -} - -void Mapper191_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap = M191CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 192 ------------------------------- - -static void M192CW(uint32 A, uint8 V) { - //Ying Lie Qun Xia Zhuan (Chinese), - //You Ling Xing Dong (China) (Unl) [this will be mistakenly headered as m074 sometimes] - if ((V == 8) || (V == 9) || (V == 0xA) || (V == 0xB)) - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper192_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M192CW; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 194 ------------------------------- - -static void M194CW(uint32 A, uint8 V) { - if (V <= 1) //Dai-2-Ji - Super Robot Taisen (As).nes - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper194_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M194CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 195 ------------------------------- -static void M195CW(uint32 A, uint8 V) { - if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -static void M195Power(void) { - GenMMC3Power(); - setprg4r(0x10, 0x5000, 2); - SetWriteHandler(0x5000, 0x5fff, CartBW); - SetReadHandler(0x5000, 0x5fff, CartBR); -} - -void Mapper195_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 16, info->battery); - cwrap = M195CW; - info->Power = M195Power; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 196 ------------------------------- -// MMC3 board with optional command address line connection, allows to -// make three-four different wirings to IRQ address lines and separately to -// CMD address line, Mali Boss additionally check if wiring are correct for -// game - -static void M196PW(uint32 A, uint8 V) { - if (EXPREGS[0]) - setprg32(0x8000, EXPREGS[1]); - else - setprg8(A, V); -} - -static DECLFW(Mapper196Write) { - if (A >= 0xC000) { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1); - MMC3_IRQWrite(A, V); - } else { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1) | ((A >> 1) & 1); - MMC3_CMDWrite(A, V); - } -} - -static DECLFW(Mapper196WriteLo) { - EXPREGS[0] = 1; - EXPREGS[1] = (V & 0xf) | (V >> 4); - FixMMC3PRG(MMC3_cmd); -} - -static void Mapper196Power(void) { - GenMMC3Power(); - EXPREGS[0] = EXPREGS[1] = 0; - SetWriteHandler(0x6000, 0x6FFF, Mapper196WriteLo); - SetWriteHandler(0x8000, 0xFFFF, Mapper196Write); -} - -void Mapper196_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = M196PW; - info->Power = Mapper196Power; -} - -// ---------------------------- Mali Splash Bomb---------------------------- -// The same board as for 196 mapper games, but with additional data bit swap -// Also, it is impossible to work on the combined 196 mapper source with -// all data bits merged, because it's using one of them as 8000 reg... - -static void UNLMaliSBPW(uint32 A, uint8 V) { - setprg8(A, (V & 3) | ((V & 8) >> 1) | ((V & 4) << 1)); -} - -static void UNLMaliSBCW(uint32 A, uint8 V) { - setchr1(A, (V & 0xDD) | ((V & 0x20) >> 4) | ((V & 2) << 4)); -} - -static DECLFW(UNLMaliSBWrite) { - if (A >= 0xC000) { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1); - MMC3_IRQWrite(A, V); - } else { - A = (A & 0xFFFE) | ((A >> 3) & 1); - MMC3_CMDWrite(A, V); - } -} - -static void UNLMaliSBPower(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, UNLMaliSBWrite); -} - -void UNLMaliSB_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = UNLMaliSBPW; - cwrap = UNLMaliSBCW; - info->Power = UNLMaliSBPower; -} - -// ---------------------------- Mapper 197 ------------------------------- - -static void M197CW(uint32 A, uint8 V) { - if (A == 0x0000) - setchr4(0x0000, V >> 1); - else if (A == 0x1000) - setchr2(0x1000, V); - else if (A == 0x1400) - setchr2(0x1800, V); -} - -void Mapper197_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 8, 0); - cwrap = M197CW; -} - -// ---------------------------- Mapper 198 ------------------------------- - -static void M198PW(uint32 A, uint8 V) { - if (V >= 0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg8(A, V & 0x4F); - else - setprg8(A, V); -} - -void Mapper198_Init(CartInfo *info) { - GenMMC3_Init(info, 1024, 0, 16, info->battery); - pwrap = M198PW; - info->Power = M195Power; -} - -// ---------------------------- Mapper 205 ------------------------------ -// GN-45 BOARD - -static void M205PW(uint32 A, uint8 V) { -// GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü 1F + àïïàðàòíûé ïåðåêëþ÷àòåëü íà øèíå àäðåñà - setprg8(A, (V & 0x0f) | EXPREGS[0]); -} - -static void M205CW(uint32 A, uint8 V) { -// GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü FF - setchr1(A, (V & 0x7F) | (EXPREGS[0] << 3)); -} - -static DECLFW(M205Write0) { - if (EXPREGS[2] == 0) { - EXPREGS[0] = A & 0x30; - EXPREGS[2] = A & 0x80; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - CartBW(A, V); -} - -static DECLFW(M205Write1) { - if (EXPREGS[2] == 0) { - EXPREGS[0] = V & 0x30; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - CartBW(A, V); -} - -static void M205Reset(void) { - EXPREGS[0] = EXPREGS[2] = 0; - MMC3RegReset(); -} - -static void M205Power(void) { - GenMMC3Power(); - SetWriteHandler(0x6000, 0x6fff, M205Write0); - SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein -} - -void Mapper205_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = M205PW; - cwrap = M205CW; - info->Power = M205Power; - info->Reset = M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 245 ------------------------------ - -static void M245CW(uint32 A, uint8 V) { - if (!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart - setchr1(A, V & 7); - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); -} - -static void M245PW(uint32 A, uint8 V) { - setprg8(A, (V & 0x3F) | ((EXPREGS[0] & 2) << 5)); -} - -static void M245Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); -} - -void Mapper245_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M245CW; - pwrap = M245PW; - info->Power = M245Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 249 ------------------------------ - -static void M249PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x2) { - if (V < 0x20) - V = (V & 1) | ((V >> 3) & 2) | ((V >> 1) & 4) | ((V << 2) & 8) | ((V << 2) & 0x10); - else { - V -= 0x20; - V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0); - } - } - setprg8(A, V); -} - -static void M249CW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x2) - V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0); - setchr1(A, V); -} - -static DECLFW(M249Write) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M249Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x5000, 0x5000, M249Write); -} - -void Mapper249_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M249CW; - pwrap = M249PW; - info->Power = M249Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 250 ------------------------------ - -static DECLFW(M250Write) { - MMC3_CMDWrite((A & 0xE000) | ((A & 0x400) >> 10), A & 0xFF); -} - -static DECLFW(M250IRQWrite) { - MMC3_IRQWrite((A & 0xE000) | ((A & 0x400) >> 10), A & 0xFF); -} - -static void M250_Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xBFFF, M250Write); - SetWriteHandler(0xC000, 0xFFFF, M250IRQWrite); -} - -void Mapper250_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - info->Power = M250_Power; -} - -// ---------------------------- Mapper 254 ------------------------------ - -static DECLFR(MR254WRAM) { - if (EXPREGS[0]) - return WRAM[A - 0x6000]; - else - return WRAM[A - 0x6000] ^ EXPREGS[1]; -} - -static DECLFW(M254Write) { - switch (A) { - case 0x8000: EXPREGS[0] = 0xff; break; - case 0xA001: EXPREGS[1] = V; break; - } - MMC3_CMDWrite(A, V); -} - -static void M254_Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xBFFF, M254Write); - SetReadHandler(0x6000, 0x7FFF, MR254WRAM); -} - -void Mapper254_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, info->battery); - info->Power = M254_Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- UNIF Boards ----------------------------- - -void TBROM_Init(CartInfo *info) { - GenMMC3_Init(info, 64, 64, 0, 0); -} - -void TEROM_Init(CartInfo *info) { - GenMMC3_Init(info, 32, 32, 0, 0); -} - -void TFROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); -} - -void TGROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 0, 0, 0); -} - -void TKROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); -} - -void TLROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 0, 0); -} - -void TSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); -} - -void TLSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap = TKSWRAP; - mwrap = GENNOMWRAP; - PPU_hook = TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TKSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = TKSWRAP; - mwrap = GENNOMWRAP; - PPU_hook = TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TQROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap = TQWRAP; - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); -} - -void HKROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 512, 1, info->battery); -} diff --git a/branches/fceux-2.2.2/src/boards/mmc5.cpp b/branches/fceux-2.2.2/src/boards/mmc5.cpp deleted file mode 100644 index d7703f4e..00000000 --- a/branches/fceux-2.2.2/src/boards/mmc5.cpp +++ /dev/null @@ -1,874 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* None of this code should use any of the iNES bank switching wrappers. */ - -#include "mapinc.h" - -static void (*sfun)(int P); -static void (*psfun)(void); - -void MMC5RunSound(int Count); -void MMC5RunSoundHQ(void); - -static INLINE void MMC5SPRVROM_BANK1(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask1[0]; - MMC5SPRVPage[(A) >> 10] = &CHRptr[0][(V) << 10] - (A); - } -} - -static INLINE void MMC5BGVROM_BANK1(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask1[0]; MMC5BGVPage[(A) >> 10] = &CHRptr[0][(V) << 10] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK2(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask2[0]; MMC5SPRVPage[(A) >> 10] = MMC5SPRVPage[((A) >> 10) + 1] = &CHRptr[0][(V) << 11] - (A); - } -} -static INLINE void MMC5BGVROM_BANK2(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask2[0]; MMC5BGVPage[(A) >> 10] = MMC5BGVPage[((A) >> 10) + 1] = &CHRptr[0][(V) << 11] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK4(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask4[0]; MMC5SPRVPage[(A) >> 10] = MMC5SPRVPage[((A) >> 10) + 1] = MMC5SPRVPage[((A) >> 10) + 2] = MMC5SPRVPage[((A) >> 10) + 3] = &CHRptr[0][(V) << 12] - (A); - } -} -static INLINE void MMC5BGVROM_BANK4(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask4[0]; MMC5BGVPage[(A) >> 10] = MMC5BGVPage[((A) >> 10) + 1] = MMC5BGVPage[((A) >> 10) + 2] = MMC5BGVPage[((A) >> 10) + 3] = &CHRptr[0][(V) << 12] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK8(uint32 V) { - if (CHRptr[0]) { - V &= CHRmask8[0]; MMC5SPRVPage[0] = MMC5SPRVPage[1] = MMC5SPRVPage[2] = MMC5SPRVPage[3] = MMC5SPRVPage[4] = MMC5SPRVPage[5] = MMC5SPRVPage[6] = MMC5SPRVPage[7] = &CHRptr[0][(V) << 13]; - } -} -static INLINE void MMC5BGVROM_BANK8(uint32 V) { - if (CHRptr[0]) { - V &= CHRmask8[0]; MMC5BGVPage[0] = MMC5BGVPage[1] = MMC5BGVPage[2] = MMC5BGVPage[3] = MMC5BGVPage[4] = MMC5BGVPage[5] = MMC5BGVPage[6] = MMC5BGVPage[7] = &CHRptr[0][(V) << 13]; - } -} - -static uint8 PRGBanks[4]; -static uint8 WRAMPage; -static uint16 CHRBanksA[8], CHRBanksB[4]; -static uint8 WRAMMaskEnable[2]; -uint8 mmc5ABMode; /* A=0, B=1 */ - -static uint8 IRQScanline, IRQEnable; -static uint8 CHRMode, NTAMirroring, NTFill, ATFill; - -static uint8 MMC5IRQR; -static uint8 MMC5LineCounter; -static uint8 mmc5psize, mmc5vsize; -static uint8 mul[2]; - -static uint8 *WRAM = NULL; -static uint8 *MMC5fill = NULL; -static uint8 *ExRAM = NULL; - -static uint8 MMC5WRAMsize; //configuration, not state -static uint8 MMC5WRAMIndex[8]; //configuration, not state - -static uint8 MMC5ROMWrProtect[4]; -static uint8 MMC5MemIn[5]; - -static void MMC5CHRA(void); -static void MMC5CHRB(void); - -typedef struct __cartdata { - uint32 crc32; - uint8 size; -} cartdata; - -#define Sprite16 (PPU[0]& 0x20) //Sprites 8x16/8x8 -//#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V)>>10][(V)] -static inline uint8 * MMC5BGVRAMADR(uint32 A) { - if (!Sprite16) { - if (mmc5ABMode == 0) - return &MMC5SPRVPage[(A) >> 10][(A)]; - else - return &MMC5BGVPage[(A) >> 10][(A)]; - } else return &MMC5BGVPage[(A) >> 10][(A)]; -} - -static void mmc5_PPUWrite(uint32 A, uint8 V) { - uint32 tmp = A; - extern uint8 PALRAM[0x20]; - - if (tmp >= 0x3F00) { - // hmmm.... - if (!(tmp & 0xf)) - PALRAM[0x00] = PALRAM[0x04] = PALRAM[0x08] = PALRAM[0x0C] = V & 0x3F; - else if (tmp & 3) PALRAM[(tmp & 0x1f)] = V & 0x3f; - } else if (tmp < 0x2000) { - if (PPUCHRRAM & (1 << (tmp >> 10))) - VPage[tmp >> 10][tmp] = V; - } else { - if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10))) - vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V; - } -} - -uint8 FASTCALL mmc5_PPURead(uint32 A) { - if (A < 0x2000) { - if (ppuphase == PPUPHASE_BG) - return *MMC5BGVRAMADR(A); - else return MMC5SPRVPage[(A) >> 10][(A)]; - } else { - return vnapage[(A >> 10) & 0x3][A & 0x3FF]; - } -} - -cartdata MMC5CartList[] = -{ - { 0x6f4e4312, 4 }, /* Aoki Ookami to Shiroki Mejika - Genchou Hishi */ - { 0x15fe6d0f, 2 }, /* Bandit Kings of Ancient China */ - { 0x671f23a8, 0 }, /* Castlevania III - Dracula's Curse (E) */ - { 0xcd4e7430, 0 }, /* Castlevania III - Dracula's Curse (KC) */ - { 0xed2465be, 0 }, /* Castlevania III - Dracula's Curse (U) */ - { 0xfe3488d1, 2 }, /* Daikoukai Jidai */ - { 0x0ec6c023, 1 }, /* Gemfire */ - { 0x0afb395e, 0 }, /* Gun Sight */ - { 0x1ced086f, 2 }, /* Ishin no Arashi */ - { 0x9cbadc25, 1 }, /* Just Breed */ - { 0x6396b988, 2 }, /* L'Empereur (J) */ - { 0x9c18762b, 2 }, /* L'Empereur (U) */ - { 0xb0480ae9, 0 }, /* Laser Invasion */ - { 0xb4735fac, 0 }, /* Metal Slader Glory */ - { 0xf540677b, 4 }, /* Nobunaga no Yabou - Bushou Fuuun Roku */ - { 0xeee9a682, 2 }, /* Nobunaga no Yabou - Sengoku Gunyuu Den (J) (PRG0) */ - { 0xf9b4240f, 2 }, /* Nobunaga no Yabou - Sengoku Gunyuu Den (J) (PRG1) */ - { 0x8ce478db, 2 }, /* Nobunaga's Ambition 2 */ - { 0xf011e490, 4 }, /* Romance of The Three Kingdoms II */ - { 0xbc80fb52, 1 }, /* Royal Blood */ - { 0x184c2124, 4 }, /* Sangokushi II (J) (PRG0) */ - { 0xee8e6553, 4 }, /* Sangokushi II (J) (PRG1) */ - { 0xd532e98f, 1 }, /* Shin 4 Nin Uchi Mahjong - Yakuman Tengoku */ - { 0x39f2ce4b, 2 }, /* Suikoden - Tenmei no Chikai */ - { 0xbb7f829a, 0 }, /* Uchuu Keibitai SDF */ - { 0xaca15643, 2 }, /* Uncharted Waters */ -}; - -#define MMC5_NOCARTS (sizeof(MMC5CartList) / sizeof(MMC5CartList[0])) -int DetectMMC5WRAMSize(uint32 crc32) { - int x; - for (x = 0; x < MMC5_NOCARTS; x++) { - if (crc32 == MMC5CartList[x].crc32) { - if(MMC5CartList[x].size > 1) - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(MMC5CartList[x].size * 8); - } - } - return 64; -} - -static void BuildWRAMSizeTable(void) { - int x; - for (x = 0; x < 8; x++) { - switch (MMC5WRAMsize) { - case 0: MMC5WRAMIndex[x] = 255; break; //X,X,X,X,X,X,X,X - case 1: MMC5WRAMIndex[x] = (x > 3) ? 255 : 0; break; //0,0,0,0,X,X,X,X - case 2: MMC5WRAMIndex[x] = (x & 4) >> 2; break; //0,0,0,0,1,1,1,1 - case 4: MMC5WRAMIndex[x] = (x > 3) ? 255 : (x & 3); break; //0,1,2,3,X,X,X,X - case 8: MMC5WRAMIndex[x] = x; break; //0,1,2,3,4,5,6,7 - } - } -} - -static void MMC5CHRA(void) { - int x; - switch (mmc5vsize & 3) { - case 0: - setchr8(CHRBanksA[7]); - MMC5SPRVROM_BANK8(CHRBanksA[7]); - break; - case 1: - setchr4(0x0000, CHRBanksA[3]); - setchr4(0x1000, CHRBanksA[7]); - MMC5SPRVROM_BANK4(0x0000, CHRBanksA[3]); - MMC5SPRVROM_BANK4(0x1000, CHRBanksA[7]); - break; - case 2: - setchr2(0x0000, CHRBanksA[1]); - setchr2(0x0800, CHRBanksA[3]); - setchr2(0x1000, CHRBanksA[5]); - setchr2(0x1800, CHRBanksA[7]); - MMC5SPRVROM_BANK2(0x0000, CHRBanksA[1]); - MMC5SPRVROM_BANK2(0x0800, CHRBanksA[3]); - MMC5SPRVROM_BANK2(0x1000, CHRBanksA[5]); - MMC5SPRVROM_BANK2(0x1800, CHRBanksA[7]); - break; - case 3: - for (x = 0; x < 8; x++) { - setchr1(x << 10, CHRBanksA[x]); - MMC5SPRVROM_BANK1(x << 10, CHRBanksA[x]); - } - break; - } -} - -static void MMC5CHRB(void) { - int x; - switch (mmc5vsize & 3) { - case 0: - setchr8(CHRBanksB[3]); - MMC5BGVROM_BANK8(CHRBanksB[3]); - break; - case 1: - setchr4(0x0000, CHRBanksB[3]); - setchr4(0x1000, CHRBanksB[3]); - MMC5BGVROM_BANK4(0x0000, CHRBanksB[3]); - MMC5BGVROM_BANK4(0x1000, CHRBanksB[3]); - break; - case 2: - setchr2(0x0000, CHRBanksB[1]); - setchr2(0x0800, CHRBanksB[3]); - setchr2(0x1000, CHRBanksB[1]); - setchr2(0x1800, CHRBanksB[3]); - MMC5BGVROM_BANK2(0x0000, CHRBanksB[1]); - MMC5BGVROM_BANK2(0x0800, CHRBanksB[3]); - MMC5BGVROM_BANK2(0x1000, CHRBanksB[1]); - MMC5BGVROM_BANK2(0x1800, CHRBanksB[3]); - break; - case 3: - for (x = 0; x < 8; x++) { - setchr1(x << 10, CHRBanksB[x & 3]); - MMC5BGVROM_BANK1(x << 10, CHRBanksB[x & 3]); - } - break; - } -} - -static void MMC5WRAM(uint32 A, uint32 V) { - V = MMC5WRAMIndex[V & 7]; - if (V != 255) { - setprg8r(0x10, A, V); - MMC5MemIn[(A - 0x6000) >> 13] = 1; - } else - MMC5MemIn[(A - 0x6000) >> 13] = 0; -} - -static void MMC5PRG(void) { - int x; - switch (mmc5psize & 3) { - case 0: - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = MMC5ROMWrProtect[2] = MMC5ROMWrProtect[3] = 1; - setprg32(0x8000, ((PRGBanks[1] & 0x7F) >> 2)); - for (x = 0; x < 4; x++) - MMC5MemIn[1 + x] = 1; - break; - case 1: - if (PRGBanks[1] & 0x80) { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 1; - setprg16(0x8000, (PRGBanks[1] >> 1)); - MMC5MemIn[1] = MMC5MemIn[2] = 1; - } else { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 0; - MMC5WRAM(0x8000, PRGBanks[1] & 7 & 0xFE); - MMC5WRAM(0xA000, (PRGBanks[1] & 7 & 0xFE) + 1); - } - MMC5MemIn[3] = MMC5MemIn[4] = 1; - MMC5ROMWrProtect[2] = MMC5ROMWrProtect[3] = 1; - setprg16(0xC000, (PRGBanks[3] & 0x7F) >> 1); - break; - case 2: - if (PRGBanks[1] & 0x80) { - MMC5MemIn[1] = MMC5MemIn[2] = 1; - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 1; - setprg16(0x8000, (PRGBanks[1] & 0x7F) >> 1); - } else { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 0; - MMC5WRAM(0x8000, PRGBanks[1] & 7 & 0xFE); - MMC5WRAM(0xA000, (PRGBanks[1] & 7 & 0xFE) + 1); - } - if (PRGBanks[2] & 0x80) { - MMC5ROMWrProtect[2] = 1; - MMC5MemIn[3] = 1; - setprg8(0xC000, PRGBanks[2] & 0x7F); - } else { - MMC5ROMWrProtect[2] = 0; - MMC5WRAM(0xC000, PRGBanks[2] & 7); - } - MMC5MemIn[4] = 1; - MMC5ROMWrProtect[3] = 1; - setprg8(0xE000, PRGBanks[3] & 0x7F); - break; - case 3: - for (x = 0; x < 3; x++) - if (PRGBanks[x] & 0x80) { - MMC5ROMWrProtect[x] = 1; - setprg8(0x8000 + (x << 13), PRGBanks[x] & 0x7F); - MMC5MemIn[1 + x] = 1; - } else { - MMC5ROMWrProtect[x] = 0; - MMC5WRAM(0x8000 + (x << 13), PRGBanks[x] & 7); - } - MMC5MemIn[4] = 1; - MMC5ROMWrProtect[3] = 1; - setprg8(0xE000, PRGBanks[3] & 0x7F); - break; - } -} - -static DECLFW(Mapper5_write) { - switch (A) { - case 0x5100: - mmc5psize = V; - MMC5PRG(); - break; - case 0x5101: - mmc5vsize = V; - if (!mmc5ABMode) { - MMC5CHRB(); - MMC5CHRA(); - } else { - MMC5CHRA(); - MMC5CHRB(); - } - break; - case 0x5102: - WRAMMaskEnable[0] = V; - break; - case 0x5103: - WRAMMaskEnable[1] = V; - break; - case 0x5104: - CHRMode = V; - MMC5HackCHRMode = V & 3; - break; - case 0x5105: - { - int x; - for (x = 0; x < 4; x++) { - switch ((V >> (x << 1)) & 3) { - case 0: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM; break; - case 1: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM + 0x400; break; - case 2: PPUNTARAM |= 1 << x; vnapage[x] = ExRAM; break; - case 3: PPUNTARAM &= ~(1 << x); vnapage[x] = MMC5fill; break; - } - } - NTAMirroring = V; - break; - } - case 0x5106: - if (V != NTFill) - FCEU_dwmemset(MMC5fill, (V | (V << 8) | (V << 16) | (V << 24)), 0x3c0); - NTFill = V; - break; - case 0x5107: - if (V != ATFill) { - unsigned char moop = V | (V << 2) | (V << 4) | (V << 6); - FCEU_dwmemset(MMC5fill + 0x3c0, moop | (moop << 8) | (moop << 16) | (moop << 24), 0x40); - } - ATFill = V; - break; - case 0x5113: - WRAMPage = V; - MMC5WRAM(0x6000, V & 7); - break; - case 0x5114: - case 0x5115: - case 0x5116: - case 0x5117: - PRGBanks[A & 3] = V; - MMC5PRG(); - break; - case 0x5120: - case 0x5121: - case 0x5122: - case 0x5123: - case 0x5124: - case 0x5125: - case 0x5126: - case 0x5127: - mmc5ABMode = 0; - CHRBanksA[A & 7] = V | ((MMC50x5130 & 0x3) << 8); - MMC5CHRA(); - break; - case 0x5128: - case 0x5129: - case 0x512a: - case 0x512b: - mmc5ABMode = 1; - CHRBanksB[A & 3] = V | ((MMC50x5130 & 0x3) << 8); - MMC5CHRB(); - break; - case 0x5130: MMC50x5130 = V; break; - case 0x5200: MMC5HackSPMode = V; break; - case 0x5201: MMC5HackSPScroll = (V >> 3) & 0x1F; break; - case 0x5202: MMC5HackSPPage = V & 0x3F; break; - case 0x5203: X6502_IRQEnd(FCEU_IQEXT); IRQScanline = V; break; - case 0x5204: X6502_IRQEnd(FCEU_IQEXT); IRQEnable = V & 0x80; break; - case 0x5205: mul[0] = V; break; - case 0x5206: mul[1] = V; break; - } -} - -static DECLFR(MMC5_ReadROMRAM) { - if (MMC5MemIn[(A - 0x6000) >> 13]) - return Page[A >> 11][A]; - else - return X.DB; -} - -static DECLFW(MMC5_WriteROMRAM) { - if ((A >= 0x8000) && (MMC5ROMWrProtect[(A - 0x8000) >> 13])) - return; - if (MMC5MemIn[(A - 0x6000) >> 13]) - if (((WRAMMaskEnable[0] & 3) | ((WRAMMaskEnable[1] & 3) << 2)) == 6) - Page[A >> 11][A] = V; -} - -static DECLFW(MMC5_ExRAMWr) { - if (MMC5HackCHRMode != 3) - ExRAM[A & 0x3ff] = V; -} - -static DECLFR(MMC5_ExRAMRd) { - return ExRAM[A & 0x3ff]; -} - -static DECLFR(MMC5_read) { - switch (A) { - case 0x5204: { - uint8 x; - X6502_IRQEnd(FCEU_IQEXT); - x = MMC5IRQR; - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - MMC5IRQR &= 0x40; - return x; - } - case 0x5205: - return(mul[0] * mul[1]); - case 0x5206: - return((mul[0] * mul[1]) >> 8); - } - return(X.DB); -} - -void MMC5Synco(void) { - int x; - - MMC5PRG(); - for (x = 0; x < 4; x++) { - switch ((NTAMirroring >> (x << 1)) & 3) { - case 0: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM; break; - case 1: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM + 0x400; break; - case 2: PPUNTARAM |= 1 << x; vnapage[x] = ExRAM; break; - case 3: PPUNTARAM &= ~(1 << x); vnapage[x] = MMC5fill; break; - } - } - MMC5WRAM(0x6000, WRAMPage & 7); - if (!mmc5ABMode) { - MMC5CHRB(); - MMC5CHRA(); - } else { - MMC5CHRA(); - MMC5CHRB(); - } - - //in case the fill register changed, we need to overwrite the fill buffer - FCEU_dwmemset(MMC5fill, NTFill | (NTFill << 8) | (NTFill << 16) | (NTFill << 24), 0x3c0); - { - unsigned char moop = ATFill | (ATFill << 2) | (ATFill << 4) | (ATFill << 6); - FCEU_dwmemset(MMC5fill + 0x3c0, moop | (moop << 8) | (moop << 16) | (moop << 24), 0x40); - } - - MMC5HackCHRMode = CHRMode & 3; - - //zero 17-apr-2013 - why the heck should this happen here? anything in a `synco` should be depending on the state. - //im going to leave it commented out to see what happens - //X6502_IRQEnd(FCEU_IQEXT); -} - -void MMC5_hb(int scanline) { - if (scanline == 240) { - MMC5LineCounter = 0; - MMC5IRQR = 0x40; - return; - } - if (MMC5LineCounter < 240) { - if (MMC5LineCounter == IRQScanline) { - MMC5IRQR |= 0x80; - if (IRQEnable & 0x80) - X6502_IRQBegin(FCEU_IQEXT); - } - MMC5LineCounter++; - } - if (MMC5LineCounter == 240) - MMC5IRQR = 0; -} - -void MMC5_StateRestore(int version) { - MMC5Synco(); -} - -typedef struct { - uint16 wl[2]; - uint8 env[2]; - uint8 enable; - uint8 running; - uint8 raw; - uint8 rawcontrol; - int32 dcount[2]; - int32 BC[3]; - int32 vcount[2]; -} MMC5APU; - -static MMC5APU MMC5Sound; - - -static void Do5PCM() { - int32 V; - int32 start, end; - - start = MMC5Sound.BC[2]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - MMC5Sound.BC[2] = end; - - if (!(MMC5Sound.rawcontrol & 0x40) && MMC5Sound.raw) - for (V = start; V < end; V++) - Wave[V >> 4] += MMC5Sound.raw << 1; -} - -static void Do5PCMHQ() { - uint32 V; - if (!(MMC5Sound.rawcontrol & 0x40) && MMC5Sound.raw) - for (V = MMC5Sound.BC[2]; V < SOUNDTS; V++) - WaveHi[V] += MMC5Sound.raw << 5; - MMC5Sound.BC[2] = SOUNDTS; -} - - -static DECLFW(Mapper5_SW) { - A &= 0x1F; - - GameExpSound.Fill = MMC5RunSound; - GameExpSound.HiFill = MMC5RunSoundHQ; - - switch (A) { - case 0x10: if (psfun) psfun(); MMC5Sound.rawcontrol = V; break; - case 0x11: if (psfun) psfun(); MMC5Sound.raw = V; break; - - case 0x0: - case 0x4: - if (sfun) sfun(A >> 2); - MMC5Sound.env[A >> 2] = V; - break; - case 0x2: - case 0x6: - if (sfun) sfun(A >> 2); - MMC5Sound.wl[A >> 2] &= ~0x00FF; - MMC5Sound.wl[A >> 2] |= V & 0xFF; - break; - case 0x3: - case 0x7: - MMC5Sound.wl[A >> 2] &= ~0x0700; - MMC5Sound.wl[A >> 2] |= (V & 0x07) << 8; - MMC5Sound.running |= 1 << (A >> 2); - break; - case 0x15: - if (sfun) { - sfun(0); - sfun(1); - } - MMC5Sound.running &= V; - MMC5Sound.enable = V; - break; - } -} - -static void Do5SQ(int P) { - static int tal[4] = { 1, 2, 4, 6 }; - int32 V, amp, rthresh, wl; - int32 start, end; - - start = MMC5Sound.BC[P]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - MMC5Sound.BC[P] = end; - - wl = MMC5Sound.wl[P] + 1; - amp = (MMC5Sound.env[P] & 0xF) << 4; - rthresh = tal[(MMC5Sound.env[P] & 0xC0) >> 6]; - - if (wl >= 8 && (MMC5Sound.running & (P + 1))) { - int dc, vc; - - wl <<= 18; - dc = MMC5Sound.dcount[P]; - vc = MMC5Sound.vcount[P]; - - for (V = start; V < end; V++) { - if (dc < rthresh) - Wave[V >> 4] += amp; - vc -= nesincsize; - while (vc <= 0) { - vc += wl; - dc = (dc + 1) & 7; - } - } - MMC5Sound.dcount[P] = dc; - MMC5Sound.vcount[P] = vc; - } -} - -static void Do5SQHQ(int P) { - static int tal[4] = { 1, 2, 4, 6 }; - uint32 V; - int32 amp, rthresh, wl; - - wl = MMC5Sound.wl[P] + 1; - amp = ((MMC5Sound.env[P] & 0xF) << 8); - rthresh = tal[(MMC5Sound.env[P] & 0xC0) >> 6]; - - if (wl >= 8 && (MMC5Sound.running & (P + 1))) { - int dc, vc; - - wl <<= 1; - - dc = MMC5Sound.dcount[P]; - vc = MMC5Sound.vcount[P]; - for (V = MMC5Sound.BC[P]; V < SOUNDTS; V++) { - if (dc < rthresh) - WaveHi[V] += amp; - vc--; - if (vc <= 0) { /* Less than zero when first started. */ - vc = wl; - dc = (dc + 1) & 7; - } - } - MMC5Sound.dcount[P] = dc; - MMC5Sound.vcount[P] = vc; - } - MMC5Sound.BC[P] = SOUNDTS; -} - -void MMC5RunSoundHQ(void) { - Do5SQHQ(0); - Do5SQHQ(1); - Do5PCMHQ(); -} - -void MMC5HiSync(int32 ts) { - int x; - for (x = 0; x < 3; x++) - MMC5Sound.BC[x] = ts; -} - -void MMC5RunSound(int Count) { - int x; - Do5SQ(0); - Do5SQ(1); - Do5PCM(); - for (x = 0; x < 3; x++) - MMC5Sound.BC[x] = Count; -} - -void Mapper5_ESI(void) { - GameExpSound.RChange = Mapper5_ESI; - if (FSettings.SndRate) { - if (FSettings.soundq >= 1) { - sfun = Do5SQHQ; - psfun = Do5PCMHQ; - } else { - sfun = Do5SQ; - psfun = Do5PCM; - } - } else { - sfun = 0; - psfun = 0; - } - memset(MMC5Sound.BC, 0, sizeof(MMC5Sound.BC)); - memset(MMC5Sound.vcount, 0, sizeof(MMC5Sound.vcount)); - GameExpSound.HiSync = MMC5HiSync; -} - -void NSFMMC5_Init(void) { - memset(&MMC5Sound, 0, sizeof(MMC5Sound)); - mul[0] = mul[1] = 0; - ExRAM = (uint8*)FCEU_gmalloc(1024); - Mapper5_ESI(); - SetWriteHandler(0x5c00, 0x5fef, MMC5_ExRAMWr); - SetReadHandler(0x5c00, 0x5fef, MMC5_ExRAMRd); - MMC5HackCHRMode = 2; - SetWriteHandler(0x5000, 0x5015, Mapper5_SW); - SetWriteHandler(0x5205, 0x5206, Mapper5_write); - SetReadHandler(0x5205, 0x5206, MMC5_read); -} - -void NSFMMC5_Close(void) { - FCEU_gfree(ExRAM); - ExRAM = 0; -} - -static void GenMMC5Reset(void) { - int x; - - for (x = 0; x < 4; x++) PRGBanks[x] = ~0; - for (x = 0; x < 8; x++) CHRBanksA[x] = ~0; - for (x = 0; x < 4; x++) CHRBanksB[x] = ~0; - WRAMMaskEnable[0] = WRAMMaskEnable[1] = ~0; - - mmc5psize = mmc5vsize = 3; - CHRMode = 0; - - NTAMirroring = NTFill = ATFill = 0xFF; - - MMC5Synco(); - - SetWriteHandler(0x4020, 0x5bff, Mapper5_write); - SetReadHandler(0x4020, 0x5bff, MMC5_read); - - SetWriteHandler(0x5c00, 0x5fff, MMC5_ExRAMWr); - SetReadHandler(0x5c00, 0x5fff, MMC5_ExRAMRd); - - SetWriteHandler(0x6000, 0xFFFF, MMC5_WriteROMRAM); - SetReadHandler(0x6000, 0xFFFF, MMC5_ReadROMRAM); - - SetWriteHandler(0x5000, 0x5015, Mapper5_SW); - SetWriteHandler(0x5205, 0x5206, Mapper5_write); - SetReadHandler(0x5205, 0x5206, MMC5_read); - -// GameHBIRQHook=MMC5_hb; - FCEU_CheatAddRAM(8, 0x6000, WRAM); - FCEU_CheatAddRAM(1, 0x5c00, ExRAM); -} - -static SFORMAT MMC5_StateRegs[] = { - { PRGBanks, 4, "PRGB" }, - { CHRBanksA, 16, "CHRA" }, - { CHRBanksB, 8, "CHRB" }, - { &WRAMPage, 1, "WRMP" }, - { WRAMMaskEnable, 2, "WRME" }, - { &mmc5ABMode, 1, "ABMD" }, - { &IRQScanline, 1, "IRQS" }, - { &IRQEnable, 1, "IRQE" }, - { &CHRMode, 1, "CHRM" }, - { &NTAMirroring, 1, "NTAM" }, - { &NTFill, 1, "NTFL" }, - { &ATFill, 1, "ATFL" }, - - //zero 17-apr-2013 - added - { &MMC5IRQR, 1, "IRQR" }, - { &MMC5LineCounter, 1, "LCTR" }, - { &mmc5psize, 1, "PSIZ" }, - { &mmc5vsize, 1, "VSIZ" }, - { mul, 2, "MUL2" }, - { MMC5ROMWrProtect, 4, "WRPR" }, - { MMC5MemIn, 5, "MEMI" }, - - { &MMC5Sound.wl[0], 2 | FCEUSTATE_RLSB, "SDW0" }, - { &MMC5Sound.wl[1], 2 | FCEUSTATE_RLSB, "SDW1" }, - { MMC5Sound.env, 2, "SDEV" }, - { &MMC5Sound.enable, 1, "SDEN" }, - { &MMC5Sound.running, 1, "SDRU" }, - { &MMC5Sound.raw, 1, "SDRW" }, - { &MMC5Sound.rawcontrol, 1, "SDRC" }, - - //zero 17-apr-2013 - added - { &MMC5Sound.dcount[0], 4 | FCEUSTATE_RLSB, "DCT0" }, - { &MMC5Sound.dcount[1], 4 | FCEUSTATE_RLSB, "DCT1" }, - { &MMC5Sound.BC[0], 4 | FCEUSTATE_RLSB, "BC00" }, - { &MMC5Sound.BC[1], 4 | FCEUSTATE_RLSB, "BC01" }, - { &MMC5Sound.BC[2], 4 | FCEUSTATE_RLSB, "BC02" }, - { &MMC5Sound.vcount[0], 4 | FCEUSTATE_RLSB, "VCT0" }, - { &MMC5Sound.vcount[1], 4 | FCEUSTATE_RLSB, "VCT1" }, - { 0 } -}; - -static void GenMMC5_Init(CartInfo *info, int wsize, int battery) { - if (wsize) { - WRAM = (uint8*)FCEU_gmalloc(wsize * 1024); - SetupCartPRGMapping(0x10, WRAM, wsize * 1024, 1); - AddExState(WRAM, wsize * 1024, 0, "WRAM"); - } - - MMC5fill = (uint8*)FCEU_gmalloc(1024); - ExRAM = (uint8*)FCEU_gmalloc(1024); - - AddExState(ExRAM, 1024, 0, "ERAM"); - AddExState(&MMC5HackSPMode, 1, 0, "SPLM"); - AddExState(&MMC5HackSPScroll, 1, 0, "SPLS"); - AddExState(&MMC5HackSPPage, 1, 0, "SPLP"); - AddExState(&MMC50x5130, 1, 0, "5130"); - AddExState(MMC5_StateRegs, ~0, 0, 0); - - MMC5WRAMsize = wsize / 8; - BuildWRAMSizeTable(); - GameStateRestore = MMC5_StateRestore; - info->Power = GenMMC5Reset; - - if (battery) { - info->SaveGame[0] = WRAM; - if (wsize <= 16) - info->SaveGameLen[0] = 8192; - else - info->SaveGameLen[0] = 32768; - } - - MMC5HackVROMMask = CHRmask4[0]; - MMC5HackExNTARAMPtr = ExRAM; - MMC5Hack = 1; - MMC5HackVROMPTR = CHRptr[0]; - MMC5HackCHRMode = 0; - MMC5HackSPMode = MMC5HackSPScroll = MMC5HackSPPage = 0; - Mapper5_ESI(); - - FFCEUX_PPURead = mmc5_PPURead; - FFCEUX_PPUWrite = mmc5_PPUWrite; -} - -void Mapper5_Init(CartInfo *info) { - GenMMC5_Init(info, DetectMMC5WRAMSize(info->CRC32), info->battery); -} - -// ELROM seems to have 0KB of WRAM -// EKROM seems to have 8KB of WRAM, battery-backed -// ETROM seems to have 16KB of WRAM, battery-backed -// EWROM seems to have 32KB of WRAM, battery-backed - -void ELROM_Init(CartInfo *info) { - GenMMC5_Init(info, 0, 0); -} - -void EKROM_Init(CartInfo *info) { - GenMMC5_Init(info, 8, info->battery); -} - -void ETROM_Init(CartInfo *info) { - GenMMC5_Init(info, 16, info->battery); -} - -void EWROM_Init(CartInfo *info) { - GenMMC5_Init(info, 32, info->battery); -} diff --git a/branches/fceux-2.2.2/src/boards/onebus.cpp b/branches/fceux-2.2.2/src/boards/onebus.cpp deleted file mode 100644 index 96ce0265..00000000 --- a/branches/fceux-2.2.2/src/boards/onebus.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007-2010 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VR02/VT03 Console and OneBus System - * - * Street Dance (Dance pad) (Unl) - * 101-in-1 Arcade Action II - * DreamGEAR 75-in-1, etc. - * - */ - -#include "mapinc.h" - -// General Purpose Registers -static uint8 cpu410x[16], ppu201x[16], apu40xx[64]; - -// IRQ Registers -static uint8 IRQCount, IRQa, IRQReload; -#define IRQLatch cpu410x[0x1] - -// MMC3 Registers -static uint8 inv_hack = 0; // some OneBus Systems have swapped PRG reg commans in MMC3 inplementation, - // trying to autodetect unusual behavior, due not to add a new mapper. -#define mmc3cmd cpu410x[0x5] -#define mirror cpu410x[0x6] - -// APU Registers -static uint8 pcm_enable = 0, pcm_irq = 0; -static int16 pcm_addr, pcm_size, pcm_latch, pcm_clock = 0xF6; - -static writefunc defapuwrite[64]; -static readfunc defapuread[64]; - -static SFORMAT StateRegs[] = -{ - { cpu410x, 16, "REGC" }, - { ppu201x, 16, "REGS" }, - { apu40xx, 64, "REGA" }, - { &IRQReload, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { &pcm_enable, 1, "PCME" }, - { &pcm_irq, 1, "PCMI" }, - { &pcm_addr, 2, "PCMA" }, - { &pcm_size, 2, "PCMS" }, - { &pcm_latch, 2, "PCML" }, - { &pcm_clock, 2, "PCMC" }, - { 0 } -}; - -static void PSync(void) { - uint8 bankmode = cpu410x[0xb] & 7; - uint8 mask = (bankmode == 0x7) ? (0xff) : (0x3f >> bankmode); - uint32 block = ((cpu410x[0x0] & 0xf0) << 4) + (cpu410x[0xa] & (~mask)); - uint32 pswap = (mmc3cmd & 0x40) << 8; - -// uint8 bank0 = (cpu410x[0xb] & 0x40)?(~1):(cpu410x[0x7]); -// uint8 bank1 = cpu410x[0x8]; -// uint8 bank2 = (cpu410x[0xb] & 0x40)?(cpu410x[0x9]):(~1); -// uint8 bank3 = ~0; - uint8 bank0 = cpu410x[0x7 ^ inv_hack]; - uint8 bank1 = cpu410x[0x8 ^ inv_hack]; - uint8 bank2 = (cpu410x[0xb] & 0x40) ? (cpu410x[0x9]) : (~1); - uint8 bank3 = ~0; - -// FCEU_printf(" PRG: %04x [%02x]",0x8000^pswap,block | (bank0 & mask)); - setprg8(0x8000 ^ pswap, block | (bank0 & mask)); -// FCEU_printf(" %04x [%02x]",0xa000^pswap,block | (bank1 & mask)); - setprg8(0xa000, block | (bank1 & mask)); -// FCEU_printf(" %04x [%02x]",0xc000^pswap,block | (bank2 & mask)); - setprg8(0xc000 ^ pswap, block | (bank2 & mask)); -// FCEU_printf(" %04x [%02x]\n",0xe000^pswap,block | (bank3 & mask)); - setprg8(0xe000, block | (bank3 & mask)); -} - -static void CSync(void) { - static const uint8 midx[8] = { 0, 1, 2, 0, 3, 4, 5, 0 }; - uint8 mask = 0xff >> midx[ppu201x[0xa] & 7]; - uint32 block = ((cpu410x[0x0] & 0x0f) << 11) + ((ppu201x[0x8] & 0x70) << 4) + (ppu201x[0xa] & (~mask)); - uint32 cswap = (mmc3cmd & 0x80) << 5; - - uint8 bank0 = ppu201x[0x6] & (~1); - uint8 bank1 = ppu201x[0x6] | 1; - uint8 bank2 = ppu201x[0x7] & (~1); - uint8 bank3 = ppu201x[0x7] | 1; - uint8 bank4 = ppu201x[0x2]; - uint8 bank5 = ppu201x[0x3]; - uint8 bank6 = ppu201x[0x4]; - uint8 bank7 = ppu201x[0x5]; - - setchr1(0x0000 ^ cswap, block | (bank0 & mask)); - setchr1(0x0400 ^ cswap, block | (bank1 & mask)); - setchr1(0x0800 ^ cswap, block | (bank2 & mask)); - setchr1(0x0c00 ^ cswap, block | (bank3 & mask)); - setchr1(0x1000 ^ cswap, block | (bank4 & mask)); - setchr1(0x1400 ^ cswap, block | (bank5 & mask)); - setchr1(0x1800 ^ cswap, block | (bank6 & mask)); - setchr1(0x1c00 ^ cswap, block | (bank7 & mask)); - - setmirror((mirror & 1) ^ 1); -} - -static void Sync(void) { - PSync(); - CSync(); -} - -static DECLFW(UNLOneBusWriteCPU410X) { -// FCEU_printf("CPU %04x:%04x\n",A,V); - switch (A & 0xf) { - case 0x1: IRQLatch = V & 0xfe; break; - case 0x2: IRQReload = 1; break; - case 0x3: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0x4: IRQa = 1; break; - default: - cpu410x[A & 0xf] = V; - Sync(); - } -} - -static DECLFW(UNLOneBusWritePPU201X) { -// FCEU_printf("PPU %04x:%04x\n",A,V); - ppu201x[A & 0x0f] = V; - Sync(); -} - -static DECLFW(UNLOneBusWriteMMC3) { -// FCEU_printf("MMC %04x:%04x\n",A,V); - switch (A & 0xe001) { - case 0x8000: mmc3cmd = (mmc3cmd & 0x38) | (V & 0xc7); Sync(); break; - case 0x8001: - { - switch (mmc3cmd & 7) { - case 0: ppu201x[0x6] = V; CSync(); break; - case 1: ppu201x[0x7] = V; CSync(); break; - case 2: ppu201x[0x2] = V; CSync(); break; - case 3: ppu201x[0x3] = V; CSync(); break; - case 4: ppu201x[0x4] = V; CSync(); break; - case 5: ppu201x[0x5] = V; CSync(); break; - case 6: cpu410x[0x7] = V; PSync(); break; - case 7: cpu410x[0x8] = V; PSync(); break; - } - break; - } - case 0xa000: mirror = V; CSync(); break; - case 0xc000: IRQLatch = V & 0xfe; break; - case 0xc001: IRQReload = 1; break; - case 0xe000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xe001: IRQa = 1; break; - } -} - -static void UNLOneBusIRQHook(void) { - uint32 count = IRQCount; - if (!count || IRQReload) { - IRQCount = IRQLatch; - IRQReload = 0; - } else - IRQCount--; - if (count && !IRQCount) { - if (IRQa) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static DECLFW(UNLOneBusWriteAPU40XX) { -// FCEU_printf("APU %04x:%04x\n",A,V); - apu40xx[A & 0x3f] = V; - switch (A & 0x3f) { - case 0x12: - if (apu40xx[0x30] & 0x10) { - pcm_addr = V << 6; - } - case 0x13: - if (apu40xx[0x30] & 0x10) { - pcm_size = (V << 4) + 1; - } - case 0x15: - if (apu40xx[0x30] & 0x10) { - pcm_enable = V & 0x10; - if (pcm_irq) { - X6502_IRQEnd(FCEU_IQEXT); - pcm_irq = 0; - } - if (pcm_enable) - pcm_latch = pcm_clock; - V &= 0xef; - } - } - defapuwrite[A & 0x3f](A, V); -} - -static DECLFR(UNLOneBusReadAPU40XX) { - uint8 result = defapuread[A & 0x3f](A); -// FCEU_printf("read %04x, %02x\n",A,result); - switch (A & 0x3f) { - case 0x15: - if (apu40xx[0x30] & 0x10) { - result = (result & 0x7f) | pcm_irq; - } - } - return result; -} - -static void UNLOneBusCpuHook(int a) { - if (pcm_enable) { - pcm_latch -= a; - if (pcm_latch <= 0) { - pcm_latch += pcm_clock; - pcm_size--; - if (pcm_size < 0) { - pcm_irq = 0x80; - pcm_enable = 0; - X6502_IRQBegin(FCEU_IQEXT); - } else { - uint8 raw_pcm = ARead[pcm_addr](pcm_addr) >> 1; - defapuwrite[0x11](0x4011, raw_pcm); - pcm_addr++; - pcm_addr &= 0x7FFF; - } - } - } -} - -static void UNLOneBusPower(void) { - uint32 i; - IRQReload = IRQCount = IRQa = 0; - - memset(cpu410x, 0x00, sizeof(cpu410x)); - memset(ppu201x, 0x00, sizeof(ppu201x)); - memset(apu40xx, 0x00, sizeof(apu40xx)); - - SetupCartCHRMapping(0, PRGptr[0], PRGsize[0], 0); - - for (i = 0; i < 64; i++) { - defapuread[i] = GetReadHandler(0x4000 | i); - defapuwrite[i] = GetWriteHandler(0x4000 | i); - } - SetReadHandler(0x4000, 0x403f, UNLOneBusReadAPU40XX); - SetWriteHandler(0x4000, 0x403f, UNLOneBusWriteAPU40XX); - - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x2010, 0x201f, UNLOneBusWritePPU201X); - SetWriteHandler(0x4100, 0x410f, UNLOneBusWriteCPU410X); - SetWriteHandler(0x8000, 0xffff, UNLOneBusWriteMMC3); - - Sync(); -} - -static void UNLOneBusReset(void) { - IRQReload = IRQCount = IRQa = 0; - - memset(cpu410x, 0x00, sizeof(cpu410x)); - memset(ppu201x, 0x00, sizeof(ppu201x)); - memset(apu40xx, 0x00, sizeof(apu40xx)); - - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLOneBus_Init(CartInfo *info) { - info->Power = UNLOneBusPower; - info->Reset = UNLOneBusReset; - - if (((*(uint32*)&(info->MD5)) == 0x305fcdc3) || // PowerJoy Supermax Carts - ((*(uint32*)&(info->MD5)) == 0x6abfce8e)) - inv_hack = 0xf; - - GameHBIRQHook = UNLOneBusIRQHook; - MapIRQHook = UNLOneBusCpuHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/pec-586.cpp b/branches/fceux-2.2.2/src/boards/pec-586.cpp deleted file mode 100644 index 6de80af7..00000000 --- a/branches/fceux-2.2.2/src/boards/pec-586.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint32 lastnt = 0; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { reg, 2, "REG" }, - { &lastnt, 4, "LNT" }, - { 0 } -}; - -static uint8 bs_tbl[128] = { - 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 00 - 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 10 - 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 20 - 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 30 - 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, // 40 - 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 50 - 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x00, 0x10, 0x20, 0x30, // 60 - 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 70 -}; - -static uint8 br_tbl[16] = { - 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - if(PRGsize[0] == 512 * 1024) { - if(reg[0] & 0x010) { - setprg32(0x8000, reg[0] & 7); - } else { - if(reg[0] & 0x40) - setprg8(0x8000, (reg[0] & 0x0F) | 0x20 | ((reg[0] & 0x20) >> 1)); - } - if((reg[0] & 0x18) == 0x18) - setmirror(MI_H); - else - setmirror(MI_V); - } else { - setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4); - setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf); - setmirror(MI_V); - } -} - -static DECLFW(UNLPEC586Write) { - reg[(A & 0x700) >> 8] = V; - PEC586Hack = (reg[0] & 0x80) >> 7; -// FCEU_printf("bs %04x %02x\n", A, V); - Sync(); -} - -static DECLFR(UNLPEC586Read) { -// FCEU_printf("read %04x\n", A); - return (X.DB & 0xD8) | br_tbl[reg[4] >> 4]; -} - -static DECLFR(UNLPEC586ReadHi) { - if((reg[0] & 0x10) || ((reg[0] & 0x40) && (A < 0xA000))) - return CartBR(A); - else - return PRGptr[0][((0x0107 | ((A >> 7) & 0x0F8)) << 10) | (A & 0x3FF)]; -} - -static void UNLPEC586Power(void) { - if(PRGsize[0] == 512 * 1024) - reg[0] = 0x00; - else - reg[0] = 0x0E; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - if(PRGsize[0] == 512 * 1024) - SetReadHandler(0x8000, 0xFFFF, UNLPEC586ReadHi); - else - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write); - SetReadHandler(0x5000, 0x5fff, UNLPEC586Read); -} - -static void UNLPEC586Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLPEC586Init(CartInfo *info) { - info->Power = UNLPEC586Power; - info->Close = UNLPEC586Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/sc-127.cpp b/branches/fceux-2.2.2/src/boards/sc-127.cpp deleted file mode 100644 index ed466ca1..00000000 --- a/branches/fceux-2.2.2/src/boards/sc-127.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Wario Land II (Kirby hack) - */ - -#include "mapinc.h" - -static uint8 reg[8], chr[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint16 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { reg, 8, "REGS" }, - { chr, 8, "CHRS" }, - { &IRQCount, 16, "IRQc" }, - { &IRQa, 16, "IRQa" }, - { 0 } -}; - -static void Sync(void) { - int i; - setprg8(0x8000, reg[0]); - setprg8(0xA000, reg[1]); - setprg8(0xC000, reg[2]); - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - setmirror(reg[3] ^ 1); -} - -static DECLFW(UNLSC127Write) { - switch (A) { - case 0x8000: reg[0] = V; break; - case 0x8001: reg[1] = V; break; - case 0x8002: reg[2] = V; break; - case 0x9000: chr[0] = V; break; - case 0x9001: chr[1] = V; break; - case 0x9002: chr[2] = V; break; - case 0x9003: chr[3] = V; break; - case 0x9004: chr[4] = V; break; - case 0x9005: chr[5] = V; break; - case 0x9006: chr[6] = V; break; - case 0x9007: chr[7] = V; break; - case 0xC002: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xC005: IRQCount = V; break; - case 0xC003: IRQa = 1; break; - case 0xD001: reg[3] = V; break; - } - Sync(); -} - -static void UNLSC127Power(void) { - Sync(); - setprg8r(0x10, 0x6000, 0); - setprg8(0xE000, ~0); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLSC127Write); -} - -static void UNLSC127IRQ(void) { - if (IRQa) { - IRQCount--; - if (IRQCount == 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - } - } -} - -static void UNLSC127Reset(void) { -} - -static void UNLSC127Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLSC127_Init(CartInfo *info) { - info->Reset = UNLSC127Reset; - info->Power = UNLSC127Power; - info->Close = UNLSC127Close; - GameHBIRQHook = UNLSC127IRQ; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/transformer.cpp b/branches/fceux-2.2.2/src/boards/transformer.cpp deleted file mode 100644 index 0f9c4a60..00000000 --- a/branches/fceux-2.2.2/src/boards/transformer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -unsigned int *GetKeyboard(void); // FIXME: 10/28 - now implemented in SDL as well. should we rename this to a FCEUI_* function? - -static unsigned int *TransformerKeys, oldkeys[256]; -static int TransformerCycleCount, TransformerChar = 0; - -static void TransformerIRQHook(int a) { - TransformerCycleCount += a; - if (TransformerCycleCount >= 1000) { - uint32 i; - TransformerCycleCount -= 1000; - TransformerKeys = GetKeyboard(); - - for (i = 0; i < 256; i++) { - if (oldkeys[i] != TransformerKeys[i]) { - if (oldkeys[i] == 0) - TransformerChar = i; - else - TransformerChar = i | 0x80; - X6502_IRQBegin(FCEU_IQEXT); - memcpy((void*)&oldkeys[0], (void*)TransformerKeys, sizeof(oldkeys)); - break; - } - } - } -} - -static DECLFR(TransformerRead) { - uint8 ret = 0; - switch (A & 3) { - case 0: ret = TransformerChar & 15; break; - case 1: ret = (TransformerChar >> 4); break; - case 2: break; - case 4: break; - } - X6502_IRQEnd(FCEU_IQEXT); - return ret; -} - -static void TransformerPower(void) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); - - SetReadHandler(0x5000, 0x5004, TransformerRead); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - MapIRQHook = TransformerIRQHook; -} - -static void TransformerClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Transformer_Init(CartInfo *info) { - info->Power = TransformerPower; - info->Close = TransformerClose; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); -} diff --git a/branches/fceux-2.2.2/src/boards/vrc2and4.cpp b/branches/fceux-2.2.2/src/boards/vrc2and4.cpp deleted file mode 100644 index 58e6d868..00000000 --- a/branches/fceux-2.2.2/src/boards/vrc2and4.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 isPirate, is22; -static uint16 IRQCount; -static uint8 IRQLatch, IRQa; -static uint8 prgreg[2], chrreg[8]; -static uint16 chrhi[8]; -static uint8 regcmd, irqcmd, mirr, big_bank; -static uint16 acount = 0; -static uint16 weirdo = 0; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { prgreg, 2, "PREG" }, - { chrreg, 8, "CREG" }, - { chrhi, 16, "CRGH" }, - { ®cmd, 1, "CMDR" }, - { &irqcmd, 1, "CMDI" }, - { &mirr, 1, "MIRR" }, - { &big_bank, 1, "BIGB" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static void Sync(void) { - if (regcmd & 2) { - setprg8(0xC000, prgreg[0] | big_bank); - setprg8(0x8000, ((~1) & 0x1F) | big_bank); - } else { - setprg8(0x8000, prgreg[0] | big_bank); - setprg8(0xC000, ((~1) & 0x1F) | big_bank); - } - setprg8(0xA000, prgreg[1] | big_bank); - setprg8(0xE000, ((~0) & 0x1F) | big_bank); - if (UNIFchrrama) - setchr8(0); - else{ - uint8 i; - if(!weirdo) - for (i = 0; i < 8; i++) - setchr1(i << 10, (chrhi[i] | chrreg[i]) >> is22); - else { - setchr1(0x0000, 0xFC); - setchr1(0x0400, 0xFD); - setchr1(0x0800, 0xFF); - weirdo--; - } - } - switch (mirr & 0x3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC24Write) { - A &= 0xF003; - if ((A >= 0xB000) && (A <= 0xE003)) { - if (UNIFchrrama) - big_bank = (V & 8) << 2; // my personally many-in-one feature ;) just for support pirate cart 2-in-1 - else{ - uint16 i = ((A >> 1) & 1) | ((A - 0xB000) >> 11); - uint16 nibble = ((A & 1) << 2); - chrreg[i] = (chrreg[i] & (0xF0 >> nibble)) | ((V & 0xF) << nibble); - if(nibble) - chrhi[i] = (V & 0x10) << 4; // another one many in one feature from pirate carts - } - Sync(); - } else - switch (A & 0xF003) { - case 0x8000: - case 0x8001: - case 0x8002: - case 0x8003: - if (!isPirate) { - prgreg[0] = V & 0x1F; - Sync(); - } - break; - case 0xA000: - case 0xA001: - case 0xA002: - case 0xA003: - if (!isPirate) - prgreg[1] = V & 0x1F; - else{ - prgreg[0] = (V & 0x1F) << 1; - prgreg[1] = ((V & 0x1F) << 1) | 1; - } - Sync(); - break; - case 0x9000: - case 0x9001: if (V != 0xFF) mirr = V; Sync(); break; - case 0x9002: - case 0x9003: regcmd = V; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF001: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF002: X6502_IRQEnd(FCEU_IQEXT); acount = 0; IRQCount = IRQLatch; IRQa = V & 2; irqcmd = V & 1; break; - case 0xF003: X6502_IRQEnd(FCEU_IQEXT); IRQa = irqcmd; break; - } -} - -static DECLFW(M21Write) { - A = (A & 0xF000) | ((A >> 1) & 0x3); // Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] isn't mapper 21 actually, - // it's mapper 23 by wirings - VRC24Write(A, V); -} - -static DECLFW(M22Write) { - if (A == 0xC007) { // Ganbare Goemon Gaiden does strange things!!! at the end credits - weirdo = 8; // quick dirty hack, seems there is no other games with such PCB, so - // we never know if it will not work for something else lol - } - A |= ((A >> 2) & 0x3); // It's just swapped lines from 21 mapper - // - VRC24Write((A & 0xF000) | ((A >> 1) & 1) | ((A << 1) & 2), V); -} - -static DECLFW(M23Write) { - A |= ((A >> 2) & 0x3) | ((A >> 4) & 0x3) | ((A >> 6) & 0x3);// actually there is many-in-one mapper source, some pirate or - // licensed games use various address bits for registers - VRC24Write(A, V); -} - -static void M21Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M21Write); -} - -static void M22Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M22Write); -} - -static void M23Power(void) { - big_bank = 0x20; - Sync(); - setprg8r(0x10, 0x6000, 0); // Only two Goemon games are have battery backed RAM, three more shooters - // (Parodius Da!, Gradius 2 and Crisis Force uses 2k or SRAM at 6000-67FF only - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M23Write); -} - -static void M25Power(void) { - big_bank = 0x20; - Sync(); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M22Write); -} - -void VRC24IRQHook(int a) { - #define LCYCS 341 - if (IRQa) { - acount += a * 3; - if (acount >= LCYCS) { - while (acount >= LCYCS) { - acount -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -static void VRC24Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper21_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M21Power; - MapIRQHook = VRC24IRQHook; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper22_Init(CartInfo *info) { - isPirate = 0; - is22 = 1; - info->Power = M22Power; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} - -void VRC24_Init(CartInfo *info) { - info->Close = VRC24Close; - MapIRQHook = VRC24IRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if(info->battery) { - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper23_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M23Power; - VRC24_Init(info); -} - -void Mapper25_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M25Power; - VRC24_Init(info); -} - -void UNLT230_Init(CartInfo *info) { - isPirate = 1; - is22 = 0; - info->Power = M23Power; - VRC24_Init(info); -} diff --git a/branches/fceux-2.2.2/src/boards/vrc3.cpp b/branches/fceux-2.2.2/src/boards/vrc3.cpp deleted file mode 100644 index 8369100e..00000000 --- a/branches/fceux-2.2.2/src/boards/vrc3.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-3 - * - */ - -#include "mapinc.h" - -static uint8 preg; -static uint8 IRQx; //autoenable -static uint8 IRQm; //mode -static uint8 IRQa; -static uint16 IRQReload, IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &IRQa, 1, "IRQA" }, - { &IRQx, 1, "IRQX" }, - { &IRQm, 1, "IRQM" }, - { &IRQReload, 2, "IRQR" }, - { &IRQCount, 2, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - setchr8(0); -} - -static DECLFW(M73Write) { - switch (A & 0xF000) { - case 0x8000: IRQReload &= 0xFFF0; IRQReload |= (V & 0xF) << 0; break; - case 0x9000: IRQReload &= 0xFF0F; IRQReload |= (V & 0xF) << 4; break; - case 0xA000: IRQReload &= 0xF0FF; IRQReload |= (V & 0xF) << 8; break; - case 0xB000: IRQReload &= 0x0FFF; IRQReload |= (V & 0xF) << 12; break; - case 0xC000: - IRQm = V & 4; - IRQx = V & 1; - IRQa = V & 2; - if (IRQa) { - if (IRQm) { - IRQCount &= 0xFFFF; - IRQCount |= (IRQReload & 0xFF); - } else - IRQCount = IRQReload; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xD000: X6502_IRQEnd(FCEU_IQEXT); IRQa = IRQx; break; - case 0xF000: preg = V; Sync(); break; - } -} - -static void M73IRQHook(int a) { - int32 i; - if (!IRQa) return; - for (i = 0; i < a; i++) { - if (IRQm) { - uint16 temp = IRQCount; - temp &= 0xFF; - IRQCount &= 0xFF00; - if (temp == 0xFF) { - IRQCount = IRQReload; - IRQCount |= (uint16)(IRQReload & 0xFF); - X6502_IRQBegin(FCEU_IQEXT); - } else { - temp++; - IRQCount |= temp; - } - } else { - //16 bit mode - if (IRQCount == 0xFFFF) { - IRQCount = IRQReload; - X6502_IRQBegin(FCEU_IQEXT); - } else - IRQCount++; - } - } -} - -static void M73Power(void) { - IRQReload = IRQm = IRQx = 0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M73Write); -} - -static void M73Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper73_Init(CartInfo *info) { - info->Power = M73Power; - info->Close = M73Close; - MapIRQHook = M73IRQHook; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/fceux-2.2.2/src/boards/vrc5.cpp b/branches/fceux-2.2.2/src/boards/vrc5.cpp deleted file mode 100644 index 0b439370..00000000 --- a/branches/fceux-2.2.2/src/boards/vrc5.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-5 (CAI Shogakko no Sansu) - * - */ - -#include "mapinc.h" - -static uint8 QTAINTRAM[2048]; -static writefunc old2007wrap; - -static uint16 CHRSIZE = 8192; -static uint16 WRAMSIZE = 8192 + 4096; -static uint8 *CHRRAM = NULL; -static uint8 *WRAM = NULL; - -static uint8 IRQa, K4IRQ; -static uint32 IRQLatch, IRQCount; - -static uint8 regs[16]; -//static uint8 test[8]; -static SFORMAT StateRegs[] = -{ - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { &K4IRQ, 1, "KIRQ" }, - { regs, 16, "REGS" }, - { 0 } -}; - -static void chrSync(void) { - setchr4r(0x10, 0x0000, regs[5] & 1); - setchr4r(0x10, 0x1000, 0); -} - -static void Sync(void) { - chrSync(); -// if(regs[0xA]&0x10) -// { -/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3); - setchr1r(0x10,0x1000,0); - setchr1r(0x10,0x1400,1); - setchr1r(0x10,0x1800,2); - setchr1r(0x10,0x1c00,3);*/ -/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3); - setchr1r(0x10,0x1000,(((regs[5]&1)^1)<<2)+4); - setchr1r(0x10,0x1400,(((regs[5]&1)^1)<<2)+5); - setchr1r(0x10,0x1800,(((regs[5]&1)^1)<<2)+6); - setchr1r(0x10,0x1c00,(((regs[5]&1)^1)<<2)+7); -*/ -// } -// else -// { -/* - setchr1r(0x10,0x0000,(((regs[5]&1)^1)<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1)^1)<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1)^1)<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1)^1)<<2)+3); - setchr1r(0x10,0x1000,(((regs[5]&1))<<2)+4); - setchr1r(0x10,0x1400,(((regs[5]&1))<<2)+5); - setchr1r(0x10,0x1800,(((regs[5]&1))<<2)+6); - setchr1r(0x10,0x1c00,(((regs[5]&1))<<2)+7); -// } -//*/ -/* setchr1r(1,0x0000,test[0]); - setchr1r(1,0x0400,test[1]); - setchr1r(1,0x0800,test[2]); - setchr1r(1,0x0c00,test[3]); - setchr1r(1,0x1000,test[4]); - setchr1r(1,0x1400,test[5]); - setchr1r(1,0x1800,test[6]); - setchr1r(1,0x1c00,test[7]); -*/ - setprg4r(0x10, 0x6000, regs[0] & 1); - if (regs[2] >= 0x40) - setprg8r(1, 0x8000, (regs[2] - 0x40)); - else - setprg8r(0, 0x8000, (regs[2] & 0x3F)); - if (regs[3] >= 0x40) - setprg8r(1, 0xA000, (regs[3] - 0x40)); - else - setprg8r(0, 0xA000, (regs[3] & 0x3F)); - if (regs[4] >= 0x40) - setprg8r(1, 0xC000, (regs[4] - 0x40)); - else - setprg8r(0, 0xC000, (regs[4] & 0x3F)); - - setprg8r(1, 0xE000, ~0); - setmirror(MI_V); -} - -/*static DECLFW(TestWrite) -{ - test[A&7] = V; - Sync(); -}*/ - -static DECLFW(M190Write) { -// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp); - regs[(A & 0x0F00) >> 8] = V; - switch (A) { - case 0xd600: IRQLatch &= 0xFF00; IRQLatch |= V; break; - case 0xd700: IRQLatch &= 0x00FF; IRQLatch |= V << 8; break; - case 0xd900: IRQCount = IRQLatch; IRQa = V & 2; K4IRQ = V & 1; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xd800: IRQa = K4IRQ; X6502_IRQEnd(FCEU_IQEXT); break; - } - Sync(); -} - -static DECLFR(M190Read) { -// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp); - return regs[(A & 0x0F00) >> 8] + regs[0x0B]; -} -static void VRC5IRQ(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount & 0x10000) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } -} - -//static void Mapper190_PPU(uint32 A) -//{ -// if(A<0x2000) -// setchr4r(0x10,0x1000,QTAINTRAM[A&0x1FFF]&1); -// else -// chrSync(); -//} - -static DECLFW(M1902007Wrap) { - if (A >= 0x2000) { - if (regs[0xA] & 1) - QTAINTRAM[A & 0x1FFF] = V; - else - old2007wrap(A, V); - } -} - - -static void M190Power(void) { -/* test[0]=0; - test[1]=1; - test[2]=2; - test[3]=3; - test[4]=4; - test[5]=5; - test[6]=6; - test[7]=7; -*/ - setprg4r(0x10, 0x7000, 2); - - old2007wrap = GetWriteHandler(0x2007); - SetWriteHandler(0x2007, 0x2007, M1902007Wrap); - - SetReadHandler(0x6000, 0xFFFF, CartBR); -// SetWriteHandler(0x5000,0x5007,TestWrite); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M190Write); - SetReadHandler(0xDC00, 0xDC00, M190Read); - SetReadHandler(0xDD00, 0xDD00, M190Read); - Sync(); -} - -static void M190Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper190_Init(CartInfo *info) { - info->Power = M190Power; - info->Close = M190Close; - GameStateRestore = StateRestore; - - MapIRQHook = VRC5IRQ; -// PPU_hook=Mapper190_PPU; - - CHRRAM = (uint8*)FCEU_gmalloc(CHRSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRSIZE, 1); - AddExState(CHRRAM, CHRSIZE, 0, "CRAM"); - - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE - 4096; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/boards/vrc6.cpp b/branches/fceux-2.2.2/src/boards/vrc6.cpp deleted file mode 100644 index 66b45651..00000000 --- a/branches/fceux-2.2.2/src/boards/vrc6.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-6 - * - */ - -#include "mapinc.h" - -static uint8 is26; -static uint8 prg[2], chr[8], mirr; -static uint8 IRQLatch, IRQa, IRQd; -static int32 IRQCount, CycleCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { prg, 2, "PRG" }, - { chr, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQd, 1, "IRQD" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQCount, 4, "IRQC" }, - { &CycleCount, 4, "CYCC" }, - { 0 } -}; - -static void(*sfun[3]) (void); -static uint8 vpsg1[8]; -static uint8 vpsg2[4]; -static int32 cvbc[3]; -static int32 vcount[3]; -static int32 dcount[2]; - -static SFORMAT SStateRegs[] = -{ - { vpsg1, 8, "PSG1" }, - { vpsg2, 4, "PSG2" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - if (is26) - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, prg[0]); - setprg8(0xc000, prg[1]); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC6SW) { - A &= 0xF003; - if (A >= 0x9000 && A <= 0x9002) { - vpsg1[A & 3] = V; - if (sfun[0]) sfun[0](); - } else if (A >= 0xA000 && A <= 0xA002) { - vpsg1[4 | (A & 3)] = V; - if (sfun[1]) sfun[1](); - } else if (A >= 0xB000 && A <= 0xB002) { - vpsg2[A & 3] = V; - if (sfun[2]) sfun[2](); - } -} - -static DECLFW(VRC6Write) { - if (is26) - A = (A & 0xFFFC) | ((A >> 1) & 1) | ((A << 1) & 2); - if (A >= 0x9000 && A <= 0xB002) { - VRC6SW(A, V); - return; - } - switch (A & 0xF003) { - case 0x8000: prg[0] = V; Sync(); break; - case 0xB003: mirr = (V >> 2) & 3; Sync(); break; - case 0xC000: prg[1] = V; Sync(); break; - case 0xD000: chr[0] = V; Sync(); break; - case 0xD001: chr[1] = V; Sync(); break; - case 0xD002: chr[2] = V; Sync(); break; - case 0xD003: chr[3] = V; Sync(); break; - case 0xE000: chr[4] = V; Sync(); break; - case 0xE001: chr[5] = V; Sync(); break; - case 0xE002: chr[6] = V; Sync(); break; - case 0xE003: chr[7] = V; Sync(); break; - case 0xF000: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF001: - IRQa = V & 2; - IRQd = V & 1; - if (V & 2) - IRQCount = IRQLatch; - CycleCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF002: - IRQa = IRQd; - X6502_IRQEnd(FCEU_IQEXT); - } -} - -static void VRC6Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, VRC6Write); -} - -static void VRC6IRQHook(int a) { - if (IRQa) { - CycleCount += a * 3; - while(CycleCount >= 341) { - CycleCount -= 341; - IRQCount++; - if (IRQCount == 0x100) { - IRQCount = IRQLatch; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void VRC6Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -// VRC6 Sound - -static void DoSQV1(void); -static void DoSQV2(void); -static void DoSawV(void); - -static INLINE void DoSQV(int x) { - int32 V; - int32 amp = (((vpsg1[x << 2] & 15) << 8) * 6 / 8) >> 4; - int32 start, end; - - start = cvbc[x]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - cvbc[x] = end; - - if (vpsg1[(x << 2) | 0x2] & 0x80) { - if (vpsg1[x << 2] & 0x80) { - for (V = start; V < end; V++) - Wave[V >> 4] += amp; - } else { - int32 thresh = (vpsg1[x << 2] >> 4) & 7; - int32 freq = ((vpsg1[(x << 2) | 0x1] | ((vpsg1[(x << 2) | 0x2] & 15) << 8)) + 1) << 17; - for (V = start; V < end; V++) { - if (dcount[x] > thresh) - Wave[V >> 4] += amp; - vcount[x] -= nesincsize; - while (vcount[x] <= 0) { - vcount[x] += freq; - dcount[x] = (dcount[x] + 1) & 15; - } - } - } - } -} - -static void DoSQV1(void) { - DoSQV(0); -} - -static void DoSQV2(void) { - DoSQV(1); -} - -static void DoSawV(void) { - int V; - int32 start, end; - - start = cvbc[2]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - cvbc[2] = end; - - if (vpsg2[2] & 0x80) { - static int32 saw1phaseacc = 0; - uint32 freq3; - static uint8 b3 = 0; - static int32 phaseacc = 0; - static uint32 duff = 0; - - freq3 = (vpsg2[1] + ((vpsg2[2] & 15) << 8) + 1); - - for (V = start; V < end; V++) { - saw1phaseacc -= nesincsize; - if (saw1phaseacc <= 0) { - int32 t; - rea: - t = freq3; - t <<= 18; - saw1phaseacc += t; - phaseacc += vpsg2[0] & 0x3f; - b3++; - if (b3 == 7) { - b3 = 0; - phaseacc = 0; - } - if (saw1phaseacc <= 0) - goto rea; - duff = (((phaseacc >> 3) & 0x1f) << 4) * 6 / 8; - } - Wave[V >> 4] += duff; - } - } -} - -static INLINE void DoSQVHQ(int x) { - int32 V; - int32 amp = ((vpsg1[x << 2] & 15) << 8) * 6 / 8; - - if (vpsg1[(x << 2) | 0x2] & 0x80) { - if (vpsg1[x << 2] & 0x80) { - for (V = cvbc[x]; V < (int)SOUNDTS; V++) - WaveHi[V] += amp; - } else { - int32 thresh = (vpsg1[x << 2] >> 4) & 7; - for (V = cvbc[x]; V < (int)SOUNDTS; V++) { - if (dcount[x] > thresh) - WaveHi[V] += amp; - vcount[x]--; - if (vcount[x] <= 0) { - vcount[x] = (vpsg1[(x << 2) | 0x1] | ((vpsg1[(x << 2) | 0x2] & 15) << 8)) + 1; - dcount[x] = (dcount[x] + 1) & 15; - } - } - } - } - cvbc[x] = SOUNDTS; -} - -static void DoSQV1HQ(void) { - DoSQVHQ(0); -} - -static void DoSQV2HQ(void) { - DoSQVHQ(1); -} - -static void DoSawVHQ(void) { - static uint8 b3 = 0; - static int32 phaseacc = 0; - int32 V; - - if (vpsg2[2] & 0x80) { - for (V = cvbc[2]; V < (int)SOUNDTS; V++) { - WaveHi[V] += (((phaseacc >> 3) & 0x1f) << 8) * 6 / 8; - vcount[2]--; - if (vcount[2] <= 0) { - vcount[2] = (vpsg2[1] + ((vpsg2[2] & 15) << 8) + 1) << 1; - phaseacc += vpsg2[0] & 0x3f; - b3++; - if (b3 == 7) { - b3 = 0; - phaseacc = 0; - } - } - } - } - cvbc[2] = SOUNDTS; -} - - -void VRC6Sound(int Count) { - int x; - - DoSQV1(); - DoSQV2(); - DoSawV(); - for (x = 0; x < 3; x++) - cvbc[x] = Count; -} - -void VRC6SoundHQ(void) { - DoSQV1HQ(); - DoSQV2HQ(); - DoSawVHQ(); -} - -void VRC6SyncHQ(int32 ts) { - int x; - for (x = 0; x < 3; x++) cvbc[x] = ts; -} - -static void VRC6_ESI(void) { - GameExpSound.RChange = VRC6_ESI; - GameExpSound.Fill = VRC6Sound; - GameExpSound.HiFill = VRC6SoundHQ; - GameExpSound.HiSync = VRC6SyncHQ; - - memset(cvbc, 0, sizeof(cvbc)); - memset(vcount, 0, sizeof(vcount)); - memset(dcount, 0, sizeof(dcount)); - if (FSettings.SndRate) { - if (FSettings.soundq >= 1) { - sfun[0] = DoSQV1HQ; - sfun[1] = DoSQV2HQ; - sfun[2] = DoSawVHQ; - } else { - sfun[0] = DoSQV1; - sfun[1] = DoSQV2; - sfun[2] = DoSawV; - } - } else - memset(sfun, 0, sizeof(sfun)); - AddExState(&SStateRegs, ~0, 0, 0); -} - -// VRC6 Sound - -void Mapper24_Init(CartInfo *info) { - is26 = 0; - info->Power = VRC6Power; - MapIRQHook = VRC6IRQHook; - VRC6_ESI(); - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper26_Init(CartInfo *info) { - is26 = 1; - info->Power = VRC6Power; - info->Close = VRC6Close; - MapIRQHook = VRC6IRQHook; - VRC6_ESI(); - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFVRC6_Init(void) { - VRC6_ESI(); - SetWriteHandler(0x8000, 0xbfff, VRC6SW); -} diff --git a/branches/fceux-2.2.2/src/boards/vrc7.cpp b/branches/fceux-2.2.2/src/boards/vrc7.cpp deleted file mode 100644 index 39154efa..00000000 --- a/branches/fceux-2.2.2/src/boards/vrc7.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 vrc7idx, preg[3], creg[8], mirr; -static uint8 IRQLatch, IRQa, IRQd; -static int32 IRQCount, CycleCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &vrc7idx, 1, "VRCI" }, - { preg, 3, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQd, 1, "IRQD" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQCount, 4, "IRQC" }, - { &CycleCount, 4, "CYCC" }, - { 0 } -}; - -// VRC7 Sound - -#include "emu2413.h" - -static int32 dwave = 0; -static OPLL *VRC7Sound = NULL; - -void DoVRC7Sound(void) { - int32 z, a; - if (FSettings.soundq >= 1) - return; - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - OPLL_fillbuf(VRC7Sound, &Wave[dwave], a, 1); - dwave += a; -} - -void UpdateOPLNEO(int32 *Wave, int Count) { - OPLL_fillbuf(VRC7Sound, Wave, Count, 4); -} - -void UpdateOPL(int Count) { - int32 z, a; - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - if (VRC7Sound && a) - OPLL_fillbuf(VRC7Sound, &Wave[dwave], a, 1); - dwave = 0; -} - -static void VRC7SC(void) { - if (VRC7Sound) - OPLL_set_rate(VRC7Sound, FSettings.SndRate); -} - -static void VRC7SKill(void) { - if (VRC7Sound) - OPLL_delete(VRC7Sound); - VRC7Sound = NULL; -} - -static void VRC7_ESI(void) { - GameExpSound.RChange = VRC7SC; - GameExpSound.Kill = VRC7SKill; - VRC7Sound = OPLL_new(3579545, FSettings.SndRate ? FSettings.SndRate : 44100); - OPLL_reset(VRC7Sound); - OPLL_reset(VRC7Sound); -} - -// VRC7 Sound - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC7SW) { - if (FSettings.SndRate) { - OPLL_writeReg(VRC7Sound, vrc7idx, V); - GameExpSound.Fill = UpdateOPL; - GameExpSound.NeoFill = UpdateOPLNEO; - } -} - -static DECLFW(VRC7Write) { - A |= (A & 8) << 1; // another two-in-oooone - if (A >= 0xA000 && A <= 0xDFFF) { - A &= 0xF010; - creg[((A >> 4) & 1) | ((A - 0xA000) >> 11)] = V; - Sync(); - } else if (A == 0x9030) { - VRC7SW(A, V); - } else switch (A & 0xF010) { - case 0x8000: preg[0] = V; Sync(); break; - case 0x8010: preg[1] = V; Sync(); break; - case 0x9000: preg[2] = V; Sync(); break; - case 0x9010: vrc7idx = V; break; - case 0xE000: mirr = V & 3; Sync(); break; - case 0xE010: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF000: - IRQa = V & 2; - IRQd = V & 1; - if (V & 2) - IRQCount = IRQLatch; - CycleCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF010: - IRQa = IRQd; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void VRC7Power(void) { - Sync(); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, VRC7Write); -} - -static void VRC7Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void VRC7IRQHook(int a) { - if (IRQa) { - CycleCount += a * 3; - while(CycleCount >= 341) { - CycleCount -= 341; - IRQCount++; - if (IRQCount == 0x100) { - IRQCount = IRQLatch; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper85_Init(CartInfo *info) { - info->Power = VRC7Power; - info->Close = VRC7Close; - MapIRQHook = VRC7IRQHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - VRC7_ESI(); - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFVRC7_Init(void) { - SetWriteHandler(0x9010, 0x901F, VRC7Write); - SetWriteHandler(0x9030, 0x903F, VRC7Write); - VRC7_ESI(); -} diff --git a/branches/fceux-2.2.2/src/boards/yoko.cpp b/branches/fceux-2.2.2/src/boards/yoko.cpp deleted file mode 100644 index d2b4e05b..00000000 --- a/branches/fceux-2.2.2/src/boards/yoko.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * YOKO mapper, almost the same as 83, TODO: figure out difference - * Mapper 83 - 30-in-1 mapper, two modes for single game carts, one mode for - * multigame Dragon Ball Z Party - * - * Mortal Kombat 2 YOKO - * N-CXX(M), XX - PRG+CHR, 12 - 128+256, 22 - 256+256, 14 - 128+512 - * - */ - -#include "mapinc.h" - -static uint8 mode, bank, reg[11], low[4], dip, IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static uint8 is2kbank, isnot2kbank; - -static SFORMAT StateRegs[] = -{ - { &mode, 1, "MODE" }, - { &bank, 1, "BANK" }, - { &IRQCount, 4, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { reg, 11, "REGS" }, - { low, 4, "LOWR" }, - { &is2kbank, 1, "IS2K" }, - { &isnot2kbank, 1, "NT2K" }, - { 0 } -}; - -static void UNLYOKOSync(void) { - setmirror((mode & 1) ^ 1); - setchr2(0x0000, reg[3]); - setchr2(0x0800, reg[4]); - setchr2(0x1000, reg[5]); - setchr2(0x1800, reg[6]); - if (mode & 0x10) { - uint32 base = (bank & 8) << 1; - setprg8(0x8000, (reg[0] & 0x0f) | base); - setprg8(0xA000, (reg[1] & 0x0f) | base); - setprg8(0xC000, (reg[2] & 0x0f) | base); - setprg8(0xE000, 0x0f | base); - } else { - if (mode & 8) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, ~0); - } - } -} - -static void M83Sync(void) { - switch (mode & 3) { // check if it is truth - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } - if (is2kbank && !isnot2kbank) { - setchr2(0x0000, reg[0]); - setchr2(0x0800, reg[1]); - setchr2(0x1000, reg[6]); - setchr2(0x1800, reg[7]); - } else { - int x; - for (x = 0; x < 8; x++) - setchr1(x << 10, reg[x] | ((bank & 0x30) << 4)); - } - setprg8r(0x10, 0x6000, 0); - if (mode & 0x40) { - setprg16(0x8000, (bank & 0x3F)); // DBZ Party [p1] - setprg16(0xC000, (bank & 0x30) | 0xF); - } else { - setprg8(0x8000, reg[8]); - setprg8(0xA000, reg[9]); - setprg8(0xC000, reg[10]); - setprg8(0xE000, ~0); - } -} - -static DECLFW(UNLYOKOWrite) { - switch (A & 0x8C17) { - case 0x8000: bank = V; UNLYOKOSync(); break; - case 0x8400: mode = V; UNLYOKOSync(); break; - case 0x8800: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x8801: IRQa = mode & 0x80; IRQCount &= 0xFF; IRQCount |= V << 8; break; - case 0x8c00: reg[0] = V; UNLYOKOSync(); break; - case 0x8c01: reg[1] = V; UNLYOKOSync(); break; - case 0x8c02: reg[2] = V; UNLYOKOSync(); break; - case 0x8c10: reg[3] = V; UNLYOKOSync(); break; - case 0x8c11: reg[4] = V; UNLYOKOSync(); break; - case 0x8c16: reg[5] = V; UNLYOKOSync(); break; - case 0x8c17: reg[6] = V; UNLYOKOSync(); break; - } -} - -static DECLFW(M83Write) { - switch (A) { - case 0x8000: is2kbank = 1; - case 0xB000: // Dragon Ball Z Party [p1] BMC - case 0xB0FF: // Dragon Ball Z Party [p1] BMC - case 0xB1FF: bank = V; mode |= 0x40; M83Sync(); break; // Dragon Ball Z Party [p1] BMC - case 0x8100: mode = V | (mode & 0x40); M83Sync(); break; - case 0x8200: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x8201: IRQa = mode & 0x80; IRQCount &= 0xFF; IRQCount |= V << 8; break; - case 0x8300: reg[8] = V; mode &= 0xBF; M83Sync(); break; - case 0x8301: reg[9] = V; mode &= 0xBF; M83Sync(); break; - case 0x8302: reg[10] = V; mode &= 0xBF; M83Sync(); break; - case 0x8310: reg[0] = V; M83Sync(); break; - case 0x8311: reg[1] = V; M83Sync(); break; - case 0x8312: reg[2] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8313: reg[3] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8314: reg[4] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8315: reg[5] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8316: reg[6] = V; M83Sync(); break; - case 0x8317: reg[7] = V; M83Sync(); break; - } -} - -static DECLFR(UNLYOKOReadDip) { - return (X.DB & 0xFC) | dip; -} - -static DECLFR(UNLYOKOReadLow) { - return low[A & 3]; -} - -static DECLFW(UNLYOKOWriteLow) { - low[A & 3] = V; -} - -static void UNLYOKOPower(void) { - mode = bank = 0; - dip = 3; - UNLYOKOSync(); - SetReadHandler(0x5000, 0x53FF, UNLYOKOReadDip); - SetReadHandler(0x5400, 0x5FFF, UNLYOKOReadLow); - SetWriteHandler(0x5400, 0x5FFF, UNLYOKOWriteLow); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLYOKOWrite); -} - -static void M83Power(void) { - is2kbank = 0; - isnot2kbank = 0; - mode = bank = 0; - dip = 0; - M83Sync(); - SetReadHandler(0x5000, 0x5000, UNLYOKOReadDip); - SetReadHandler(0x5100, 0x5103, UNLYOKOReadLow); - SetWriteHandler(0x5100, 0x5103, UNLYOKOWriteLow); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); // Pirate Dragon Ball Z Party [p1] used if for saves instead of seraial EEPROM - SetReadHandler(0x8000, 0xffff, CartBR); - SetWriteHandler(0x8000, 0xffff, M83Write); -} - -static void UNLYOKOReset(void) { - dip = (dip + 1) & 3; - mode = bank = 0; - UNLYOKOSync(); -} - -static void M83Reset(void) { - dip ^= 1; - M83Sync(); -} - -static void M83Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void UNLYOKOIRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount < 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = 0xFFFF; - } - } -} - -static void UNLYOKOStateRestore(int version) { - UNLYOKOSync(); -} - -static void M83StateRestore(int version) { - M83Sync(); -} - -void UNLYOKO_Init(CartInfo *info) { - info->Power = UNLYOKOPower; - info->Reset = UNLYOKOReset; - MapIRQHook = UNLYOKOIRQHook; - GameStateRestore = UNLYOKOStateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper83_Init(CartInfo *info) { - info->Power = M83Power; - info->Reset = M83Reset; - info->Close = M83Close; - MapIRQHook = UNLYOKOIRQHook; - GameStateRestore = M83StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/fceux-2.2.2/src/cart.h b/branches/fceux-2.2.2/src/cart.h deleted file mode 100644 index e5670c54..00000000 --- a/branches/fceux-2.2.2/src/cart.h +++ /dev/null @@ -1,94 +0,0 @@ -typedef struct { - // Set by mapper/board code: - void (*Power)(void); - void (*Reset)(void); - void (*Close)(void); - uint8 *SaveGame[4]; // Pointers to memory to save/load. - uint32 SaveGameLen[4]; // How much memory to save/load. - - // Set by iNES/UNIF loading code. - int mirror; // As set in the header or chunk. - // iNES/UNIF specific. Intended - // to help support games like "Karnov" - // that are not really MMC3 but are - // set to mapper 4. - int battery; // Presence of an actual battery. - uint8 MD5[16]; - uint32 CRC32; // Should be set by the iNES/UNIF loading - // code, used by mapper/board code, maybe - // other code in the future. -} CartInfo; - -void FCEU_SaveGameSave(CartInfo *LocalHWInfo); -void FCEU_LoadGameSave(CartInfo *LocalHWInfo); -void FCEU_ClearGameSave(CartInfo *LocalHWInfo); - -extern uint8 *Page[32], *VPage[8], *MMC5SPRVPage[8], *MMC5BGVPage[8]; - -void ResetCartMapping(void); -void SetupCartPRGMapping(int chip, uint8 *p, uint32 size, int ram); -void SetupCartCHRMapping(int chip, uint8 *p, uint32 size, int ram); -void SetupCartMirroring(int m, int hard, uint8 *extra); - -DECLFR(CartBROB); -DECLFR(CartBR); -DECLFW(CartBW); - -extern uint8 PRGram[32]; -extern uint8 CHRram[32]; - -extern uint8 *PRGptr[32]; -extern uint8 *CHRptr[32]; - -extern uint32 PRGsize[32]; -extern uint32 CHRsize[32]; - -extern uint32 PRGmask2[32]; -extern uint32 PRGmask4[32]; -extern uint32 PRGmask8[32]; -extern uint32 PRGmask16[32]; -extern uint32 PRGmask32[32]; - -extern uint32 CHRmask1[32]; -extern uint32 CHRmask2[32]; -extern uint32 CHRmask4[32]; -extern uint32 CHRmask8[32]; - -void setprg2(uint32 A, uint32 V); -void setprg4(uint32 A, uint32 V); -void setprg8(uint32 A, uint32 V); -void setprg16(uint32 A, uint32 V); -void setprg32(uint32 A, uint32 V); - -void setprg2r(int r, unsigned int A, unsigned int V); -void setprg4r(int r, unsigned int A, unsigned int V); -void setprg8r(int r, unsigned int A, unsigned int V); -void setprg16r(int r, unsigned int A, unsigned int V); -void setprg32r(int r, unsigned int A, unsigned int V); - -void setchr1r(int r, unsigned int A, unsigned int V); -void setchr2r(int r, unsigned int A, unsigned int V); -void setchr4r(int r, unsigned int A, unsigned int V); -void setchr8r(int r, unsigned int V); - -void setchr1(unsigned int A, unsigned int V); -void setchr2(unsigned int A, unsigned int V); -void setchr4(unsigned int A, unsigned int V); -void setchr8(unsigned int V); - -void setmirror(int t); -void setmirrorw(int a, int b, int c, int d); -void setntamem(uint8 *p, int ram, uint32 b); - -#define MI_H 0 -#define MI_V 1 -#define MI_0 2 -#define MI_1 3 - -extern int geniestage; - -void FCEU_GeniePower(void); - -bool FCEU_OpenGenie(void); -void FCEU_CloseGenie(void); -void FCEU_KillGenie(void); diff --git a/branches/fceux-2.2.2/src/cheat.cpp b/branches/fceux-2.2.2/src/cheat.cpp deleted file mode 100644 index 051ecb58..00000000 --- a/branches/fceux-2.2.2/src/cheat.cpp +++ /dev/null @@ -1,964 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "types.h" -#include "x6502.h" -#include "cheat.h" -#include "fceu.h" -#include "file.h" -#include "cart.h" -#include "driver.h" -#include "utils/memory.h" - -#include -#include -#include -#include -#include - -using namespace std; - -static uint8 *CheatRPtrs[64]; - -vector FrozenAddresses; //List of addresses that are currently frozen -void UpdateFrozenList(void); //Function that populates the list of frozen addresses -unsigned int FrozenAddressCount=0; //Keeps up with the Frozen address count, necessary for using in other dialogs (such as hex editor) - -void FCEU_CheatResetRAM(void) -{ - int x; - - for(x=0;x<64;x++) - CheatRPtrs[x]=0; -} - -void FCEU_CheatAddRAM(int s, uint32 A, uint8 *p) -{ - uint32 AB=A>>10; - int x; - - for(x=s-1;x>=0;x--) - CheatRPtrs[AB+x]=p-A; -} - - -struct CHEATF { - struct CHEATF *next; - char *name; - uint16 addr; - uint8 val; - int compare; /* -1 for no compare. */ - int type; /* 0 for replace, 1 for substitute(GG). */ - int status; -}; - -typedef struct { - uint16 addr; - uint8 val; - int compare; - readfunc PrevRead; -} CHEATF_SUBFAST; - - -static CHEATF_SUBFAST SubCheats[256]; -static int numsubcheats=0; -struct CHEATF *cheats=0,*cheatsl=0; - - -#define CHEATC_NONE 0x8000 -#define CHEATC_EXCLUDED 0x4000 -#define CHEATC_NOSHOW 0xC000 - -static uint16 *CheatComp = 0; -int savecheats = 0; - -static DECLFR(SubCheatsRead) -{ - CHEATF_SUBFAST *s=SubCheats; - int x=numsubcheats; - - do - { - if(s->addr==A) - { - if(s->compare>=0) - { - uint8 pv=s->PrevRead(A); - - if(pv==s->compare) - return(s->val); - else return(pv); - } - else return(s->val); - } - s++; - } while(--x); - return(0); /* We should never get here. */ -} - -void RebuildSubCheats(void) -{ - int x; - struct CHEATF *c=cheats; - for(x=0;xtype==1 && c->status) - { - if(GetReadHandler(c->addr)==SubCheatsRead) - { - /* Prevent a catastrophe by this check. */ - //FCEU_DispMessage("oops",0); - } - else - { - SubCheats[numsubcheats].PrevRead=GetReadHandler(c->addr); - SubCheats[numsubcheats].addr=c->addr; - SubCheats[numsubcheats].val=c->val; - SubCheats[numsubcheats].compare=c->compare; - SetReadHandler(c->addr,c->addr,SubCheatsRead); - numsubcheats++; - } - } - c=c->next; - } - FrozenAddressCount = numsubcheats; //Update the frozen address list - UpdateFrozenList(); - //FCEUI_DispMessage("Active Cheats: %d",0, FrozenAddresses.size()/*FrozenAddressCount*/); //Debug -} - -void FCEU_PowerCheats() -{ - numsubcheats=0; /* Quick hack to prevent setting of ancient read addresses. */ - RebuildSubCheats(); -} - -static int AddCheatEntry(char *name, uint32 addr, uint8 val, int compare, int status, int type); -static void CheatMemErr(void) -{ - FCEUD_PrintError("Error allocating memory for cheat data."); -} - -/* This function doesn't allocate any memory for "name" */ -static int AddCheatEntry(char *name, uint32 addr, uint8 val, int compare, int status, int type) -{ - struct CHEATF *temp; - if(!(temp=(struct CHEATF *)FCEU_dmalloc(sizeof(struct CHEATF)))) - { - CheatMemErr(); - return(0); - } - temp->name=name; - temp->addr=addr; - temp->val=val; - temp->status=status; - temp->compare=compare; - temp->type=type; - temp->next=0; - - if(cheats) - { - cheatsl->next=temp; - cheatsl=temp; - } - else - cheats=cheatsl=temp; - - return(1); -} - -void FCEU_LoadGameCheats(FILE *override) -{ - FILE *fp; - unsigned int addr; - unsigned int val; - unsigned int status; - unsigned int type; - unsigned int compare; - int x; - - char linebuf[2048]; - char *namebuf; - int tc=0; - char *fn; - - numsubcheats=savecheats=0; - - if(override) - fp = override; - else - { - fn=strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str()); - fp=FCEUD_UTF8fopen(fn,"rb"); - free(fn); - if(!fp) return; - } - - FCEU_DispMessage("Cheats file loaded.",0); //Tells user a cheats file was loaded. - while(fgets(linebuf,2048,fp)>0) - { - char *tbuf=linebuf; - int doc=0; - - addr=val=compare=status=type=0; - - if(tbuf[0]=='S') - { - tbuf++; - type=1; - } - else type=0; - - if(tbuf[0]=='C') - { - tbuf++; - doc=1; - } - - if(tbuf[0]==':') - { - tbuf++; - status=0; - } - else status=1; - - if(doc) - { - char *neo=&tbuf[4+2+2+1+1+1]; - if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3) - continue; - if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1))) - return; - strcpy(namebuf,neo); - } - else - { - char *neo=&tbuf[4+2+1+1]; - if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2) - continue; - if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1))) - return; - strcpy(namebuf,neo); - } - - for(x=0;x<(int)strlen(namebuf);x++) - { - if(namebuf[x]==10 || namebuf[x]==13) - { - namebuf[x]=0; - break; - } - else if(namebuf[x] > 0x00 && namebuf[x] < 0x20) - namebuf[x]=0x20; - } - - AddCheatEntry(namebuf,addr,val,doc?compare:-1,status,type); - tc++; - } - RebuildSubCheats(); - if(!override) - fclose(fp); -} - -void FCEU_FlushGameCheats(FILE *override, int nosave) -{ - if(CheatComp) - { - free(CheatComp); - CheatComp=0; - } - if((!savecheats || nosave) && !override) /* Always save cheats if we're being overridden. */ - { - if(cheats) - { - struct CHEATF *next=cheats; - for(;;) - { - struct CHEATF *last=next; - next=next->next; - free(last->name); - free(last); - if(!next) break; - } - cheats=cheatsl=0; - } - } - else - { - char *fn = 0; - - if(!override) - fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str()); - - if(cheats) - { - struct CHEATF *next=cheats; - FILE *fp; - - if(override) - fp = override; - else - fp=FCEUD_UTF8fopen(fn,"wb"); - - if(fp) - { - for(;;) - { - struct CHEATF *t; - if(next->type) - fputc('S',fp); - if(next->compare>=0) - fputc('C',fp); - - if(!next->status) - fputc(':',fp); - - if(next->compare>=0) - fprintf(fp,"%04x:%02x:%02x:%s\n",next->addr,next->val,next->compare,next->name); - else - fprintf(fp,"%04x:%02x:%s\n",next->addr,next->val,next->name); - - free(next->name); - t=next; - next=next->next; - free(t); - if(!next) break; - } - if(!override) - fclose(fp); - } - else - FCEUD_PrintError("Error saving cheats."); - cheats=cheatsl=0; - } - else if(!override) - remove(fn); - if(!override) - free(fn); - } - - RebuildSubCheats(); /* Remove memory handlers. */ - -} - - -int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type) -{ - char *t; - - if(!(t=(char *)FCEU_dmalloc(strlen(name)+1))) - { - CheatMemErr(); - return(0); - } - strcpy(t,name); - if(!AddCheatEntry(t,addr,val,compare,1,type)) - { - free(t); - return(0); - } - savecheats=1; - RebuildSubCheats(); - - return(1); -} - -int FCEUI_DelCheat(uint32 which) -{ - struct CHEATF *prev; - struct CHEATF *cur; - uint32 x=0; - - for(prev=0,cur=cheats;;) - { - if(x==which) // Remove this cheat. - { - if(prev) // Update pointer to this cheat. - { - if(cur->next) // More cheats. - prev->next=cur->next; - else // No more. - { - prev->next=0; - cheatsl=prev; // Set the previous cheat as the last cheat. - } - } - else // This is the first cheat. - { - if(cur->next) // More cheats - cheats=cur->next; - else - cheats=cheatsl=0; // No (more) cheats. - } - free(cur->name); // Now that all references to this cheat are removed, - free(cur); // free the memory. - break; - } // *END REMOVE THIS CHEAT* - - - if(!cur->next) // No more cheats to go through(this shouldn't ever happen...) - return(0); - prev=cur; - cur=prev->next; - x++; - } - - savecheats=1; - RebuildSubCheats(); - return(1); -} - -void FCEU_ApplyPeriodicCheats(void) -{ - struct CHEATF *cur=cheats; - if(!cur) return; - - for(;;) - { - if(cur->status && !(cur->type)) - if(CheatRPtrs[cur->addr>>10]) - CheatRPtrs[cur->addr>>10][cur->addr]=cur->val; - if(cur->next) - cur=cur->next; - else - break; - } -} - - -void FCEUI_ListCheats(int (*callb)(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data), void *data) -{ - struct CHEATF *next=cheats; - - while(next) - { - if(!callb(next->name,next->addr,next->val,next->compare,next->status,next->type,data)) break; - next=next->next; - } -} - -int FCEUI_GetCheat(uint32 which, char **name, uint32 *a, uint8 *v, int *compare, int *s, int *type) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - if(name) - *name=next->name; - if(a) - *a=next->addr; - if(v) - *v=next->val; - if(s) - *s=next->status; - if(compare) - *compare=next->compare; - if(type) - *type=next->type; - return(1); - } - next=next->next; - x++; - } - return(0); -} - -static int GGtobin(char c) -{ - static char lets[16]={'A','P','Z','L','G','I','T','Y','E','O','X','U','K','S','V','N'}; - int x; - - for(x=0;x<16;x++) - if(lets[x] == toupper(c)) return(x); - return(0); -} - -/* Returns 1 on success, 0 on failure. Sets *a,*v,*c. */ -int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c) -{ - uint16 A; - uint8 V,C; - uint8 t; - int s; - - A=0x8000; - V=0; - C=0; - - s=strlen(str); - if(s!=6 && s!=8) return(0); - - t=GGtobin(*str++); - V|=(t&0x07); - V|=(t&0x08)<<4; - - t=GGtobin(*str++); - V|=(t&0x07)<<4; - A|=(t&0x08)<<4; - - t=GGtobin(*str++); - A|=(t&0x07)<<4; - //if(t&0x08) return(0); /* 8-character code?! */ - - t=GGtobin(*str++); - A|=(t&0x07)<<12; - A|=(t&0x08); - - t=GGtobin(*str++); - A|=(t&0x07); - A|=(t&0x08)<<8; - - if(s==6) - { - t=GGtobin(*str++); - A|=(t&0x07)<<8; - V|=(t&0x08); - - *a=A; - *v=V; - *c=-1; - return(1); - } - else - { - t=GGtobin(*str++); - A|=(t&0x07)<<8; - C|=(t&0x08); - - t=GGtobin(*str++); - C|=(t&0x07); - C|=(t&0x08)<<4; - - t=GGtobin(*str++); - C|=(t&0x07)<<4; - V|=(t&0x08); - *a=A; - *v=V; - *c=C; - return(1); - } - return(0); -} - -int FCEUI_DecodePAR(const char *str, int *a, int *v, int *c, int *type) -{ - int boo[4]; - if(strlen(str)!=8) return(0); - - sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3); - - *c=-1; - - if(1) - { - *a=(boo[3]<<8)|(boo[2]+0x7F); - *v=0; - } - else - { - *v=boo[3]; - *a=boo[2]|(boo[1]<<8); - } - /* Zero-page addressing modes don't go through the normal read/write handlers in FCEU, so - we must do the old hacky method of RAM cheats. - */ - if(*a<0x0100) - *type=0; - else - *type=1; - return(1); -} - -/* name can be NULL if the name isn't going to be changed. */ -/* same goes for a, v, and s(except the values of each one must be <0) */ - -int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int c, int s, int type) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - if(name) - { - char *t; - if((t=(char *)realloc(next->name, strlen(name)+1))) - { - next->name=t; - strcpy(next->name,name); - } - else - return(0); - } - if(a>=0) - next->addr=a; - if(v>=0) - next->val=v; - if(s>=0) - next->status=s; - if(c>=-1) - next->compare=c; - next->type=type; - - savecheats=1; - RebuildSubCheats(); - - return(1); - } - next=next->next; - x++; - } - return(0); -} - -/* Convenience function. */ -int FCEUI_ToggleCheat(uint32 which) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - next->status=!next->status; - savecheats=1; - RebuildSubCheats(); - return(next->status); - } - next=next->next; - x++; - } - - return(-1); -} - -static int InitCheatComp(void) -{ - uint32 x; - - CheatComp=(uint16*)FCEU_dmalloc(65536*sizeof(uint16)); - if(!CheatComp) - { - CheatMemErr(); - return(0); - } - for(x=0;x<65536;x++) - CheatComp[x]=CHEATC_NONE; - - return(1); -} - -void FCEUI_CheatSearchSetCurrentAsOriginal(void) -{ - uint32 x; - - if(!CheatComp) - { - if(InitCheatComp()) - { - CheatMemErr(); - return; - } - } - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatRPtrs[x>>10]) - CheatComp[x]=CheatRPtrs[x>>10][x]; - else - CheatComp[x]|=CHEATC_NONE; - } -} - -void FCEUI_CheatSearchShowExcluded(void) -{ - uint32 x; - - for(x=0x000;x<0x10000;x++) - CheatComp[x]&=~CHEATC_EXCLUDED; -} - - -int32 FCEUI_CheatSearchGetCount(void) -{ - uint32 x,c=0; - - if(CheatComp) - { - for(x=0x0000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - c++; - } - - return c; -} -/* This function will give the initial value of the search and the current value at a location. */ - -void FCEUI_CheatSearchGet(int (*callb)(uint32 a, uint8 last, uint8 current, void *data),void *data) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - CheatMemErr(); - return; - } - - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - if(!callb(x,CheatComp[x],CheatRPtrs[x>>10][x],data)) - break; -} - -void FCEUI_CheatSearchGetRange(uint32 first, uint32 last, int (*callb)(uint32 a, uint8 last, uint8 current)) -{ - uint32 x; - uint32 in=0; - - if(!CheatComp) - { - if(!InitCheatComp()) - CheatMemErr(); - return; - } - - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - { - if(in>=first) - if(!callb(x,CheatComp[x],CheatRPtrs[x>>10][x])) - break; - in++; - if(in>last) return; - } -} - -void FCEUI_CheatSearchBegin(void) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - { - CheatMemErr(); - return; - } - } - for(x=0;x<0x10000;x++) - { - if(CheatRPtrs[x>>10]) - CheatComp[x]=CheatRPtrs[x>>10][x]; - else - CheatComp[x]=CHEATC_NONE; - } -} - - -static int INLINE CAbs(int x) -{ - if(x<0) - return(0-x); - return x; -} - -void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - { - CheatMemErr(); - return; - } - } - - - if(!type) // Change to a specific value. - { - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]==v1 && CheatRPtrs[x>>10][x]==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==1) // Search for relative change(between values). - { - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]==v1 && CAbs(CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==2) // Purely relative change. - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CAbs(CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==3) // Any change. - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]!=CheatRPtrs[x>>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==4) // new value = known - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatRPtrs[x>>10][x]==v1) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==5) // new value greater than - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==6) // new value less than - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]>CheatRPtrs[x>>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==7) // new value greater than by known value - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if((CheatRPtrs[x>>10][x]-CheatComp[x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==8) // new value less than by known value - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if((CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } -} - -int FCEU_CheatGetByte(uint32 A) -{ - // if(CheatRPtrs[A>>10]) - // return CheatRPtrs[A>>10][A]; //adelikat-commenting this stuff out so that lua can see frozen addresses, I hope this doesn't bork stuff. - /*else*/ if(A < 0x10000) - return ARead[A](A); - else - return 0; -} - -void FCEU_CheatSetByte(uint32 A, uint8 V) -{ - if(CheatRPtrs[A>>10]) - CheatRPtrs[A>>10][A]=V; - else if(A < 0x10000) - BWrite[A](A, V); -} - -void UpdateFrozenList(void) -{ - //The purpose of this function is to keep an up to date list of addresses that are currently frozen - //and make these accessible to other dialogs that deal with memory addresses such as - //memwatch, hex editor, ramfilter, etc. - - int x; - FrozenAddresses.clear(); //Clear vector and repopulate - for(x=0;x Connect -* Connect -> Compare {('||' | '&&') Compare} -* Compare -> Sum {('==' | '!=' | '<=' | '>=' | '<' | '>') Sum} -* Sum -> Product {('+' | '-') Product} -* Product -> Primitive {('*' | '/') Primitive} -* Primitive -> Number | Address | Register | Flag | PC Bank | '(' Connect ')' -* Number -> '#' [1-9A-F]* -* Address -> '$' [1-9A-F]* | '$' '[' Connect ']' -* Register -> 'A' | 'X' | 'Y' | 'P' -* Flag -> 'N' | 'C' | 'Z' | 'I' | 'B' | 'V' -* PC Bank -> 'K' -* Data Bank -> 'T' -*/ - -#include "types.h" -#include "conddebug.h" -#include "utils/memory.h" - -#include -#include -#include -#include -#include - -// hack: this address is used by 'T' condition -uint16 addressOfTheLastAccessedData = 0; -// Next non-whitespace character in string -char next; - -int ishex(char c) -{ - return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); -} - -void scan(const char** str) -{ - do - { - next = **str; - (*str)++; - } while (isspace(next)); -} - -// Frees a condition and all of it's sub conditions -void freeTree(Condition* c) -{ - if (c->lhs) freeTree(c->lhs); - if (c->rhs) freeTree(c->rhs); - - free(c); -} - -// Generic function to handle all infix operators but the last one in the precedence hierarchy. : '(' E ')' -Condition* InfixOperator(const char** str, Condition(*nextPart(const char**)), int(*operators)(const char**)) -{ - Condition* t = nextPart(str); - Condition* t1; - Condition* mid; - int op; - - while ((op = operators(str))) - { - scan(str); - - t1 = nextPart(str); - - if (t1 == 0) - { - if(t) - freeTree(t); - return 0; - } - - mid = (Condition*)FCEU_dmalloc(sizeof(Condition)); - if (!mid) - return NULL; - memset(mid, 0, sizeof(Condition)); - - mid->lhs = t; - mid->rhs = t1; - mid->op = op; - - t = mid; - } - - return t; -} - -// Generic handler for two-character operators -int TwoCharOperator(const char** str, char c1, char c2, int op) -{ - if (next == c1 && **str == c2) - { - scan(str); - return op; - } - else - { - return 0; - } -} - -// Determines if a character is a flag -int isFlag(char c) -{ - return c == 'N' || c == 'I' || c == 'C' || c == 'V' || c == 'Z' || c == 'B' || c == 'U' || c == 'D'; -} - -// Determines if a character is a register -int isRegister(char c) -{ - return c == 'A' || c == 'X' || c == 'Y' || c == 'P'; -} - -// Determines if a character is for PC bank -int isPCBank(char c) -{ - return c == 'K'; -} - -// Determines if a character is for Data bank -int isDataBank(char c) -{ - return c == 'T'; -} - -// Reads a hexadecimal number from str -int getNumber(unsigned int* number, const char** str) -{ -// char buffer[5]; - - if (sscanf(*str, "%X", number) == EOF || *number > 0xFFFF) - { - return 0; - } - -// Older, inferior version which doesn't work with leading zeros -// sprintf(buffer, "%X", *number); -// *str += strlen(buffer); - while (ishex(**str)) (*str)++; - scan(str); - - return 1; -} - -Condition* Connect(const char** str); - -// Handles the following part of the grammar: '(' E ')' -Condition* Parentheses(const char** str, Condition* c, char openPar, char closePar) -{ - if (next == openPar) - { - scan(str); - - c->lhs = Connect(str); - - if (!c) return 0; - - if (next == closePar) - { - scan(str); - return c; - } - else - { - return 0; - } - } - - return 0; -} - -/* -* Check for primitives -* Flags, Registers, Numbers, Addresses and parentheses -*/ -Condition* Primitive(const char** str, Condition* c) -{ - if (isFlag(next)) /* Flags */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_FLAG; - c->value1 = next; - } - else - { - c->type2 = TYPE_FLAG; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isRegister(next)) /* Registers */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_REG; - c->value1 = next; - } - else - { - c->type2 = TYPE_REG; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isPCBank(next)) /* PC Bank */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_PC_BANK; - c->value1 = next; - } - else - { - c->type2 = TYPE_PC_BANK; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isDataBank(next)) /* Data Bank */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_DATA_BANK; - c->value1 = next; - } - else - { - c->type2 = TYPE_DATA_BANK; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (next == '#') /* Numbers */ - { - unsigned int number = 0; - if (!getNumber(&number, str)) - { - return 0; - } - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_NUM; - c->value1 = number; - } - else - { - c->type2 = TYPE_NUM; - c->value2 = number; - } - - return c; - } - else if (next == '$') /* Addresses */ - { - if ((**str >= '0' && **str <= '9') || (**str >= 'A' && **str <= 'F')) /* Constant addresses */ - { - unsigned int number = 0; - if (!getNumber(&number, str)) - { - return 0; - } - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_ADDR; - c->value1 = number; - } - else - { - c->type2 = TYPE_ADDR; - c->value2 = number; - } - - return c; - } - else if (**str == '[') /* Dynamic addresses */ - { - scan(str); - Parentheses(str, c, '[', ']'); - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_ADDR; - } - else - { - c->type2 = TYPE_ADDR; - } - - return c; - } - else - { - return 0; - } - } - else if (next == '(') - { - return Parentheses(str, c, '(', ')'); - } - - return 0; -} - -/* Handle * and / operators */ -Condition* Term(const char** str) -{ - Condition* t; - Condition* t1; - Condition* mid; - - t = (Condition*)FCEU_dmalloc(sizeof(Condition)); - if (!t) - return NULL; - - memset(t, 0, sizeof(Condition)); - - if (!Primitive(str, t)) - { - freeTree(t); - return 0; - } - - while (next == '*' || next == '/') - { - int op = next == '*' ? OP_MULT : OP_DIV; - - scan(str); - - if (!(t1 = (Condition*)FCEU_dmalloc(sizeof(Condition)))) - return NULL; - - memset(t1, 0, sizeof(Condition)); - - if (!Primitive(str, t1)) - { - freeTree(t); - freeTree(t1); - return 0; - } - - if (!(mid = (Condition*)FCEU_dmalloc(sizeof(Condition)))) - return NULL; - - memset(mid, 0, sizeof(Condition)); - - mid->lhs = t; - mid->rhs = t1; - mid->op = op; - - t = mid; - } - - return t; -} - -/* Check for + and - operators */ -int SumOperators(const char** str) -{ - switch (next) - { - case '+': return OP_PLUS; - case '-': return OP_MINUS; - default: return OP_NO; - } -} - -/* Handle + and - operators */ -Condition* Sum(const char** str) -{ - return InfixOperator(str, Term, SumOperators); -} - -/* Check for <=, =>, ==, !=, > and < operators */ -int CompareOperators(const char** str) -{ - int val = TwoCharOperator(str, '=', '=', OP_EQ); - if (val) return val; - - val = TwoCharOperator(str, '!', '=', OP_NE); - if (val) return val; - - val = TwoCharOperator(str, '>', '=', OP_GE); - if (val) return val; - - val = TwoCharOperator(str, '<', '=', OP_LE); - if (val) return val; - - val = next == '>' ? OP_G : 0; - if (val) return val; - - val = next == '<' ? OP_L : 0; - if (val) return val; - - return OP_NO; -} - -/* Handle <=, =>, ==, !=, > and < operators */ -Condition* Compare(const char** str) -{ - return InfixOperator(str, Sum, CompareOperators); -} - -/* Check for || or && operators */ -int ConnectOperators(const char** str) -{ - int val = TwoCharOperator(str, '|', '|', OP_OR); - if(val) return val; - - val = TwoCharOperator(str, '&', '&', OP_AND); - if(val) return val; - - return OP_NO; -} - -/* Handle || and && operators */ -Condition* Connect(const char** str) -{ - return InfixOperator(str, Compare, ConnectOperators); -} - -/* Root of the parser generator */ -Condition* generateCondition(const char* str) -{ - Condition* c; - - scan(&str); - c = Connect(&str); - - if (!c || next != 0) return 0; - else return c; -} diff --git a/branches/fceux-2.2.2/src/conddebug.h b/branches/fceux-2.2.2/src/conddebug.h deleted file mode 100644 index 92ea6334..00000000 --- a/branches/fceux-2.2.2/src/conddebug.h +++ /dev/null @@ -1,65 +0,0 @@ -/* FCEUXD SP - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 Sebastian Porst - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef CONDDEBUG_H -#define CONDDEBUG_H - -#define TYPE_NO 0 -#define TYPE_REG 1 -#define TYPE_FLAG 2 -#define TYPE_NUM 3 -#define TYPE_ADDR 4 -#define TYPE_PC_BANK 5 -#define TYPE_DATA_BANK 6 - -#define OP_NO 0 -#define OP_EQ 1 -#define OP_NE 2 -#define OP_GE 3 -#define OP_LE 4 -#define OP_G 5 -#define OP_L 6 -#define OP_PLUS 7 -#define OP_MINUS 8 -#define OP_MULT 9 -#define OP_DIV 10 -#define OP_OR 11 -#define OP_AND 12 - -extern uint16 addressOfTheLastAccessedData; -//mbg merge 7/18/06 turned into sane c++ -struct Condition -{ - Condition* lhs; - Condition* rhs; - - unsigned int type1; - unsigned int value1; - - unsigned int op; - - unsigned int type2; - unsigned int value2; -}; - -void freeTree(Condition* c); -Condition* generateCondition(const char* str); - -#endif diff --git a/branches/fceux-2.2.2/src/config.cpp b/branches/fceux-2.2.2/src/config.cpp deleted file mode 100644 index de66a1ec..00000000 --- a/branches/fceux-2.2.2/src/config.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/// \file -/// \brief Contains methods related to the build configuration - -#include "types.h" -#include "version.h" -#include "fceu.h" -#include "driver.h" -#include "utils/memory.h" - -#include -#include -#include - -static char *aboutString = 0; - -// returns a string suitable for use in an aboutbox -char *FCEUI_GetAboutString() { - const char *aboutTemplate = - FCEU_NAME_AND_VERSION "\n\n" - "Administrators:\n" - "zeromus, adelikat, AnS\n\n" - "Current Contributors:\n" - "punkrockguy318 (Lukas Sabota)\n" - "CaH4e3, gocha, xhainingx, feos\n" - "\n" - "FCEUX 2.0:\n" - "mz, nitsujrehtona, SP, Ugly Joe,\n" - "Plombo, qeed, QFox, Shinydoofy\n" - "ugetab, Acmlm, DWEdit\n" - "\n" - "Previous versions:\n" - "FCE - Bero\n" - "FCEU - Xodnizel\n" - "FCEU XD - Bbitmaster & Parasyte\n" - "FCEU XD SP - Sebastian Porst\n" - "FCEU MM - CaH4e3\n" - "FCEU TAS - blip & nitsuja\n" - "FCEU TAS+ - Luke Gustafson\n" - "\n" - "FCEUX is dedicated to the fallen heroes\n" - "of NES emulation. In Memoriam --\n" - "ugetab\n" - "\n" - __TIME__ " " __DATE__ "\n"; - - if(aboutString) return aboutString; - - const char *compilerString = FCEUD_GetCompilerString(); - - //allocate the string and concatenate the template with the compiler string - if (!(aboutString = (char*)FCEU_dmalloc(strlen(aboutTemplate) + strlen(compilerString) + 1))) - return NULL; - - sprintf(aboutString,"%s%s",aboutTemplate,compilerString); - return aboutString; -} diff --git a/branches/fceux-2.2.2/src/config.h b/branches/fceux-2.2.2/src/config.h deleted file mode 100644 index e69de29b..00000000 diff --git a/branches/fceux-2.2.2/src/debug.cpp b/branches/fceux-2.2.2/src/debug.cpp deleted file mode 100644 index c71274c4..00000000 --- a/branches/fceux-2.2.2/src/debug.cpp +++ /dev/null @@ -1,800 +0,0 @@ -/// \file -/// \brief Implements core debugging facilities -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "cart.h" -#include "ines.h" -#include "debug.h" -#include "driver.h" -#include "ppu.h" - -#include "x6502abbrev.h" - -#include -#include - - -int vblankScanLines = 0; //Used to calculate scanlines 240-261 (vblank) -int vblankPixel = 0; //Used to calculate the pixels in vblank - -int offsetStringToInt(unsigned int type, const char* offsetBuffer) -{ - int offset = -1; - - if (sscanf(offsetBuffer,"%4X",&offset) == EOF) - { - return -1; - } - - if (type & BT_P) - { - return offset & 0x3FFF; - } - else if (type & BT_S) - { - return offset & 0x00FF; - } - else // BT_C - { - if (GameInfo->type == GIT_NSF) { //NSF Breakpoint keywords - if (strcmp(offsetBuffer,"LOAD") == 0) return (NSFHeader.LoadAddressLow | (NSFHeader.LoadAddressHigh<<8)); - if (strcmp(offsetBuffer,"INIT") == 0) return (NSFHeader.InitAddressLow | (NSFHeader.InitAddressHigh<<8)); - if (strcmp(offsetBuffer,"PLAY") == 0) return (NSFHeader.PlayAddressLow | (NSFHeader.PlayAddressHigh<<8)); - } - else if (GameInfo->type == GIT_FDS) { //FDS Breakpoint keywords - if (strcmp(offsetBuffer,"NMI1") == 0) return (GetMem(0xDFF6) | (GetMem(0xDFF7)<<8)); - if (strcmp(offsetBuffer,"NMI2") == 0) return (GetMem(0xDFF8) | (GetMem(0xDFF9)<<8)); - if (strcmp(offsetBuffer,"NMI3") == 0) return (GetMem(0xDFFA) | (GetMem(0xDFFB)<<8)); - if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xDFFC) | (GetMem(0xDFFD)<<8)); - if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xDFFE) | (GetMem(0xDFFF)<<8)); - } - else { //NES Breakpoint keywords - if ((strcmp(offsetBuffer,"NMI") == 0) || (strcmp(offsetBuffer,"VBL") == 0)) return (GetMem(0xFFFA) | (GetMem(0xFFFB)<<8)); - if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xFFFC) | (GetMem(0xFFFD)<<8)); - if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xFFFE) | (GetMem(0xFFFF)<<8)); - } - } - - return offset; -} - -// Returns the value of a given type or register - -int getValue(int type) -{ - switch (type) - { - case 'A': return _A; - case 'X': return _X; - case 'Y': return _Y; - case 'N': return _P & N_FLAG ? 1 : 0; - case 'V': return _P & V_FLAG ? 1 : 0; - case 'U': return _P & U_FLAG ? 1 : 0; - case 'B': return _P & B_FLAG ? 1 : 0; - case 'D': return _P & D_FLAG ? 1 : 0; - case 'I': return _P & I_FLAG ? 1 : 0; - case 'Z': return _P & Z_FLAG ? 1 : 0; - case 'C': return _P & C_FLAG ? 1 : 0; - case 'P': return _PC; - } - - return 0; -} - - -/** -* Checks whether a breakpoint condition is syntactically valid -* and creates a breakpoint condition object if everything's OK. -* -* @param condition Condition to parse -* @param num Number of the breakpoint in the BP list the condition belongs to -* @return 0 in case of an error; 2 if everything went fine -**/ -int checkCondition(const char* condition, int num) -{ - const char* b = condition; - - // Check if the condition isn't just all spaces. - - int onlySpaces = 1; - - while (*b) - { - if (*b != ' ') - { - onlySpaces = 0; - break; - } - - ++b; - } - - - // If there's an actual condition create the BP condition object now - - if (*condition && !onlySpaces) - { - Condition* c = generateCondition(condition); - - // Remove the old breakpoint condition before adding a new condition. - if (watchpoint[num].cond) - { - freeTree(watchpoint[num].cond); - free(watchpoint[num].condText); - watchpoint[num].cond = 0; - watchpoint[num].condText = 0; - } - - // If the creation of the BP condition object was succesful - // the condition is apparently valid. It can be added to the - // breakpoint now. - - if (c) - { - watchpoint[num].cond = c; - watchpoint[num].condText = (char*)malloc(strlen(condition) + 1); - if (!watchpoint[num].condText) - return 0; - strcpy(watchpoint[num].condText, condition); - } - else - { - watchpoint[num].cond = 0; - } - - return watchpoint[num].cond == 0 ? 2 : 0; - } - else - { - // Remove the old breakpoint condition - if (watchpoint[num].cond) - { - freeTree(watchpoint[num].cond); - free(watchpoint[num].condText); - watchpoint[num].cond = 0; - watchpoint[num].condText = 0; - } - return 0; - } -} - -/** -* Adds a new breakpoint. -* -* @param hwndDlg Handle of the debugger window -* @param num Number of the breakpoint -* @param -**/ -unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable) -{ - // Finally add breakpoint to the list - watchpoint[num].address = start; - watchpoint[num].endaddress = 0; - - // Optional end address found - if (end != -1) - { - watchpoint[num].endaddress = end; - } - - // Get the breakpoint flags - watchpoint[num].flags = 0; - if (enable) watchpoint[num].flags|=WP_E; - if (type & WP_R) watchpoint[num].flags|=WP_R; - if (type & WP_F) watchpoint[num].flags|=WP_F; - if (type & WP_W) watchpoint[num].flags|=WP_W; - if (type & WP_X) watchpoint[num].flags|=WP_X; - if (type & BT_P) { - watchpoint[num].flags|=BT_P; - watchpoint[num].flags&=~WP_X; //disable execute flag! - } - if (type & BT_S) { - watchpoint[num].flags|=BT_S; - watchpoint[num].flags&=~WP_X; //disable execute flag! - } - - if (watchpoint[num].desc) - free(watchpoint[num].desc); - - watchpoint[num].desc = (char*)malloc(strlen(name) + 1); - strcpy(watchpoint[num].desc, name); - - return checkCondition(condition, num); -} - -int GetPRGAddress(int A){ - int result; - if(A > 0xFFFF) - return -1; - result = &Page[A>>11][A]-PRGptr[0]; - if((result > (int)PRGsize[0]) || (result < 0)) - return -1; - else - return result; -} - -/** -* Returns the bank for a given offset. -* Technically speaking this function does not calculate the actual bank -* where the offset resides but the 0x4000 bytes large chunk of the ROM of the offset. -* -* @param offs The offset -* @return The bank of that offset or -1 if the offset is not part of the ROM. -**/ -int getBank(int offs) -{ - //NSF data is easy to overflow the return on. - //Anything over FFFFF will kill it. - - //GetNesFileAddress doesn't work well with Unif files - int addr = GetNesFileAddress(offs)-16; - - if (GameInfo && GameInfo->type==GIT_NSF) - return addr != -1 ? addr / 0x1000 : -1; - return addr != -1 ? addr / 0x4000 : -1; -} - -int GetNesFileAddress(int A){ - int result; - if((A < 0x8000) || (A > 0xFFFF))return -1; - result = &Page[A>>11][A]-PRGptr[0]; - if((result > (int)(PRGsize[0])) || (result < 0))return -1; - else return result+16; //16 bytes for the header remember -} - -int GetRomAddress(int A){ - int i; - uint8 *p = GetNesPRGPointer(A-=16); - for(i = 16;i < 32;i++){ - if((&Page[i][i<<11] <= p) && (&Page[i][(i+1)<<11] > p))break; - } - if(i == 32)return -1; //not found - - return (i<<11) + (p-&Page[i][i<<11]); -} - -uint8 *GetNesPRGPointer(int A){ - return PRGptr[0]+A; -} - -uint8 *GetNesCHRPointer(int A){ - return CHRptr[0]+A; -} - -uint8 GetMem(uint16 A) { - if ((A >= 0x2000) && (A < 0x4000)) { - switch (A&7) { - case 0: return PPU[0]; - case 1: return PPU[1]; - case 2: return PPU[2]|(PPUGenLatch&0x1F); - case 3: return PPU[3]; - case 4: return SPRAM[PPU[3]]; - case 5: return XOffset; - case 6: return RefreshAddr&0xFF; - case 7: return VRAMBuffer; - } - } else if ((A >= 0x4000) && (A < 0x5000)) return 0xFF; // AnS: changed the range, so MMC5 ExRAM can be watched in the Hexeditor - if (GameInfo) return ARead[A](A); //adelikat: 11/17/09: Prevent crash if this is called with no game loaded. - else return 0; -} - -uint8 GetPPUMem(uint8 A) { - uint16 tmp=RefreshAddr&0x3FFF; - - if (tmp<0x2000) return VPage[tmp>>10][tmp]; - if (tmp>=0x3F00) return PALRAM[tmp&0x1F]; - return vnapage[(tmp>>10)&0x3][tmp&0x3FF]; -} - -//--------------------- - -// Evaluates a condition -int evaluate(Condition* c) -{ - int f = 0; - - int value1, value2; - - if (c->lhs) - { - value1 = evaluate(c->lhs); - } - else - { - switch(c->type1) - { - case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code - case TYPE_NUM: value1 = c->value1; break; - default: value1 = getValue(c->value1); break; - } - } - - switch(c->type1) - { - case TYPE_ADDR: value1 = GetMem(value1); break; - case TYPE_PC_BANK: value1 = getBank(_PC); break; - case TYPE_DATA_BANK: value1 = getBank(addressOfTheLastAccessedData); break; - } - - f = value1; - - if (c->op) - { - if (c->rhs) - { - value2 = evaluate(c->rhs); - } - else - { - switch(c->type2) - { - case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code - case TYPE_NUM: value2 = c->value2; break; - default: value2 = getValue(c->type2); break; - } - } - - switch(c->type2) - { - case TYPE_ADDR: value2 = GetMem(value2); break; - case TYPE_PC_BANK: value2 = getBank(_PC); break; - case TYPE_DATA_BANK: value2 = getBank(addressOfTheLastAccessedData); break; - } - - switch (c->op) - { - case OP_EQ: f = value1 == value2; break; - case OP_NE: f = value1 != value2; break; - case OP_GE: f = value1 >= value2; break; - case OP_LE: f = value1 <= value2; break; - case OP_G: f = value1 > value2; break; - case OP_L: f = value1 < value2; break; - case OP_MULT: f = value1 * value2; break; - case OP_DIV: f = value1 / value2; break; - case OP_PLUS: f = value1 + value2; break; - case OP_MINUS: f = value1 - value2; break; - case OP_OR: f = value1 || value2; break; - case OP_AND: f = value1 && value2; break; - } - } - - return f; -} - -int condition(watchpointinfo* wp) -{ - return wp->cond == 0 || evaluate(wp->cond); -} - - -//--------------------- - -volatile int codecount, datacount, undefinedcount; -unsigned char *cdloggerdata; -unsigned int cdloggerdataSize = 0; -static int indirectnext; - -int debug_loggingCD; - -//called by the cpu to perform logging if CDLogging is enabled -void LogCDVectors(int which){ - int j; - j = GetPRGAddress(which); - if(j == -1) return; - - if(!(cdloggerdata[j] & 2)){ - cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } - j++; - - if(!(cdloggerdata[j] & 2)){ - cdloggerdata[j] |= 0x0E; - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } -} - -void LogCDData(uint8 *opcode, uint16 A, int size) { - int i, j; - uint8 memop = 0; - - if((j = GetPRGAddress(_PC)) != -1) - for (i = 0; i < size; i++) { - if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip - cdloggerdata[j+i] |= 1; - cdloggerdata[j+i] |=((_PC+i)>>11)&0x0c; - if(indirectnext)cdloggerdata[j+i] |= 0x10; - codecount++; - if(!(cdloggerdata[j+i] & 2))undefinedcount--; - } - - //log instruction jumped to in an indirect jump - if(opcode[0] == 0x6c) - indirectnext = 1; - else - indirectnext = 0; - - switch (optype[opcode[0]]) { - case 1: - case 4: memop = 0x20; break; - } - - if((j = GetPRGAddress(A)) != -1) { - if(!(cdloggerdata[j] & 2)) { - cdloggerdata[j] |= 2; - cdloggerdata[j] |=(A>>11)&0x0c; - cdloggerdata[j] |= memop; - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } - } -} - -//-----------debugger stuff - -watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over -int iaPC; -uint32 iapoffset; //mbg merge 7/18/06 changed from int -int u; //deleteme -int skipdebug; //deleteme -int numWPs; - -bool break_asap = false; -// for CPU cycles and Instructions counters -uint64 total_cycles_base = 0; -uint64 delta_cycles_base = 0; -bool break_on_cycles = false; -uint64 break_cycles_limit = 0; -uint64 total_instructions = 0; -uint64 delta_instructions = 0; -bool break_on_instructions = false; -uint64 break_instructions_limit = 0; - -static DebuggerState dbgstate; - -DebuggerState &FCEUI_Debugger() { return dbgstate; } - -void ResetDebugStatisticsCounters() -{ - ResetCyclesCounter(); - ResetInstructionsCounter(); -} -void ResetCyclesCounter() -{ - total_cycles_base = delta_cycles_base = timestampbase + (uint64)timestamp; -} -void ResetInstructionsCounter() -{ - total_instructions = delta_instructions = 0; -} -void ResetDebugStatisticsDeltaCounters() -{ - delta_cycles_base = timestampbase + (uint64)timestamp; - delta_instructions = 0; -} -void IncrementInstructionsCounters() -{ - total_instructions++; - delta_instructions++; -} - -void BreakHit(int bp_num, bool force) -{ - if(!force) - { - //check to see whether we fall in any forbid zone - for (int i = 0; i < numWPs; i++) - { - watchpointinfo& wp = watchpoint[i]; - if(!(wp.flags & WP_F) || !(wp.flags & WP_E)) - continue; - - if (condition(&wp)) - { - if (wp.endaddress) { - if( (wp.address <= _PC) && (wp.endaddress >= _PC) ) - return; //forbid - } else { - if(wp.address == _PC) - return; //forbid - } - } - } - } - - FCEUI_SetEmulationPaused(EMULATIONPAUSED_PAUSED); //mbg merge 7/19/06 changed to use EmulationPaused() - -#ifdef WIN32 - FCEUD_DebugBreakpoint(bp_num); -#endif -} - -uint8 StackAddrBackup = X.S; -uint16 StackNextIgnorePC = 0xFFFF; - -///fires a breakpoint -static void breakpoint(uint8 *opcode, uint16 A, int size) { - int i, j; - uint8 brk_type; - uint8 stackop=0; - uint8 stackopstartaddr,stackopendaddr; - - if (break_asap) - { - break_asap = false; - BreakHit(BREAK_TYPE_LUA, true); - } - - if (break_on_cycles && ((timestampbase + (uint64)timestamp - total_cycles_base) > break_cycles_limit)) - BreakHit(BREAK_TYPE_CYCLES_EXCEED, true); - if (break_on_instructions && (total_instructions > break_instructions_limit)) - BreakHit(BREAK_TYPE_INSTRUCTIONS_EXCEED, true); - - //if the current instruction is bad, and we are breaking on bad opcodes, then hit the breakpoint - if(dbgstate.badopbreak && (size == 0)) - BreakHit(BREAK_TYPE_BADOP, true); - - //if we're stepping out, track the nest level - if (dbgstate.stepout) { - if (opcode[0] == 0x20) dbgstate.jsrcount++; - else if (opcode[0] == 0x60) { - if (dbgstate.jsrcount) - dbgstate.jsrcount--; - else { - dbgstate.stepout = false; - dbgstate.step = true; - return; - } - } - } - - //if we're stepping, then we'll always want to break - if (dbgstate.step) { - dbgstate.step = false; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - - //if we're running for a scanline, we want to check if we've hit the cycle limit - if (dbgstate.runline) { - uint64 ts = timestampbase; - ts+=timestamp; - int diff = dbgstate.runline_end_time-ts; - if (diff<=0) - { - dbgstate.runline=false; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - } - - //check the step over address and break if we've hit it - if ((watchpoint[64].address == _PC) && (watchpoint[64].flags)) { - watchpoint[64].address = 0; - watchpoint[64].flags = 0; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - - brk_type = opbrktype[opcode[0]] | WP_X; - - switch (opcode[0]) { - //Push Ops - case 0x08: //Fall to next - case 0x48: stackopstartaddr=stackopendaddr=X.S-1; stackop=WP_W; StackAddrBackup = X.S; StackNextIgnorePC=_PC+1; break; - //Pull Ops - case 0x28: //Fall to next - case 0x68: stackopstartaddr=stackopendaddr=X.S+1; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=_PC+1; break; - //JSR (Includes return address - 1) - case 0x20: stackopstartaddr=stackopendaddr=X.S-1; stackop=WP_W; StackAddrBackup = X.S; StackNextIgnorePC=(opcode[1]|opcode[2]<<8); break; - //RTI (Includes processor status, and exact return address) - case 0x40: stackopstartaddr=X.S+1; stackopendaddr=X.S+3; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=(GetMem(X.S+2|0x0100)|GetMem(X.S+3|0x0100)<<8); break; - //RTS (Includes return address - 1) - case 0x60: stackopstartaddr=X.S+1; stackopendaddr=X.S+2; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=(GetMem(stackopstartaddr|0x0100)|GetMem(stackopendaddr|0x0100)<<8)+1; break; - } - - for (i = 0; i < numWPs; i++) - { -// ################################## Start of SP CODE ########################### - if ((watchpoint[i].flags & WP_E) && condition(&watchpoint[i])) - { -// ################################## End of SP CODE ########################### - if (watchpoint[i].flags & BT_P) - { - // PPU Mem breaks - if ((watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 7)) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= RefreshAddr) && (watchpoint[i].endaddress >= RefreshAddr)) - BreakHit(i); - } else - { - if (watchpoint[i].address == RefreshAddr) - BreakHit(i); - } - } - } else if (watchpoint[i].flags & BT_S) - { - // Sprite Mem breaks - if ((watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 4)) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= PPU[3]) && (watchpoint[i].endaddress >= PPU[3])) - BreakHit(i); - } else - { - if (watchpoint[i].address == PPU[3]) - BreakHit(i); - } - } else if ((watchpoint[i].flags & WP_W) && (A == 0x4014)) - { - // Sprite DMA! :P - BreakHit(i); - } - } else - { - // CPU mem breaks - if ((watchpoint[i].flags & brk_type)) - { - if (watchpoint[i].endaddress) - { - if (((watchpoint[i].flags & (WP_R | WP_W)) && (watchpoint[i].address <= A) && (watchpoint[i].endaddress >= A)) || - ((watchpoint[i].flags & WP_X) && (watchpoint[i].address <= _PC) && (watchpoint[i].endaddress >= _PC))) - BreakHit(i); - } else - { - if (((watchpoint[i].flags & (WP_R | WP_W)) && (watchpoint[i].address == A)) || - ((watchpoint[i].flags & WP_X) && (watchpoint[i].address == _PC))) - BreakHit(i); - } - } else - { - // brk_type independant coding - if (stackop > 0) - { - // Announced stack mem breaks - // PHA, PLA, PHP, and PLP affect the stack data. - // TXS and TSX only deal with the pointer. - if (watchpoint[i].flags & stackop) - { - for (j = (stackopstartaddr|0x0100); j <= (stackopendaddr|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } - if (StackNextIgnorePC == _PC) - { - // Used to make it ignore the unannounced stack code one time - StackNextIgnorePC = 0xFFFF; - } else - { - if ((X.S < StackAddrBackup) && (stackop==0)) - { - // Unannounced stack mem breaks - // Pushes to stack - if (watchpoint[i].flags & WP_W) - { - for (j = (X.S|0x0100); j < (StackAddrBackup|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } else if ((StackAddrBackup < X.S) && (stackop==0)) - { - // Pulls from stack - if (watchpoint[i].flags & WP_R) - { - for (j = (StackAddrBackup|0x0100); j < (X.S|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } - } - - } - } -// ################################## Start of SP CODE ########################### - } -// ################################## End of SP CODE ########################### - } - - //Update the stack address with the current one, now that changes have registered. - StackAddrBackup = X.S; -} -//bbit edited: this is the end of the inserted code - -void DebugCycle() -{ - uint8 opcode[3] = {0}; - uint16 A = 0; - int size; - - if (scanline == 240) - { - vblankScanLines = (PAL?int((double)timestamp / ((double)341 / (double)3.2)):timestamp / 114); //114 approximates the number of timestamps per scanline during vblank. Approx 2508. NTSC: (341 / 3.0) PAL: (341 / 3.2). Uses (3.? * cpu_cycles) / 341.0, and assumes 1 cpu cycle. - if (vblankScanLines) vblankPixel = 341 / vblankScanLines; //341 pixels per scanline - //FCEUI_printf("vbPixel = %d",vblankPixel); //Debug - //FCEUI_printf("ts: %d line: %d\n", timestamp, vblankScanLines); //Debug - } - else - vblankScanLines = 0; - - if (GameInfo->type==GIT_NSF) - { - if ((_PC >= 0x3801) && (_PC <= 0x3824)) return; - } - - opcode[0] = GetMem(_PC); - size = opsize[opcode[0]]; - switch (size) - { - case 2: - opcode[1] = GetMem(_PC + 1); - break; - case 3: - opcode[1] = GetMem(_PC + 1); - opcode[2] = GetMem(_PC + 2); - break; - } - - switch (optype[opcode[0]]) - { - case 0: break; - case 1: - A = (opcode[1] + _X) & 0xFF; - A = GetMem(A) | (GetMem(A + 1) << 8); - break; - case 2: A = opcode[1]; break; - case 3: A = opcode[1] | (opcode[2] << 8); break; - case 4: A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1) << 8)) + _Y; break; - case 5: A = opcode[1] + _X; break; - case 6: A = (opcode[1] | (opcode[2] << 8)) + _Y; break; - case 7: A = (opcode[1] | (opcode[2] << 8)) + _X; break; - case 8: A = opcode[1] + _Y; break; - } - addressOfTheLastAccessedData = A; - - if (numWPs || dbgstate.step || dbgstate.runline || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak || break_on_cycles || break_on_instructions || break_asap) - breakpoint(opcode, A, size); - - if(debug_loggingCD) - LogCDData(opcode, A, size); - -#ifdef WIN32 - //This needs to be windows only or else the linux build system will fail since logging is declared in a - //windows source file - FCEUD_TraceInstruction(opcode, size); -#endif - -} diff --git a/branches/fceux-2.2.2/src/debug.h b/branches/fceux-2.2.2/src/debug.h deleted file mode 100644 index 09c10177..00000000 --- a/branches/fceux-2.2.2/src/debug.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - -#include "conddebug.h" -#include "git.h" -#include "nsf.h" - -//watchpoint stuffs -#define WP_E 0x01 //watchpoint, enable -#define WP_W 0x02 //watchpoint, write -#define WP_R 0x04 //watchpoint, read -#define WP_X 0x08 //watchpoint, execute -#define WP_F 0x10 //watchpoint, forbid - -#define BT_C 0x00 //break type, cpu mem -#define BT_P 0x20 //break type, ppu mem -#define BT_S 0x40 //break type, sprite mem - -#define BREAK_TYPE_STEP -1 -#define BREAK_TYPE_BADOP -2 -#define BREAK_TYPE_CYCLES_EXCEED -3 -#define BREAK_TYPE_INSTRUCTIONS_EXCEED -4 -#define BREAK_TYPE_LUA -5 - -//opbrktype is used to grab the breakpoint type that each instruction will cause. -//WP_X is not used because ALL opcodes will have the execute bit set. -static const uint8 opbrktype[256] = { - /*0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F*/ -/*0x00*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x10*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x20*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x30*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x40*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x50*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x60*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x70*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x80*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, 0, 0, 0, WP_W, WP_W, WP_W, 0, -/*0x90*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, WP_W, 0, 0, 0, WP_W, 0, 0, -/*0xA0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xB0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xC0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xD0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0xE0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xF0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0 -}; - - -typedef struct { - uint16 address; - uint16 endaddress; - uint8 flags; -// ################################## Start of SP CODE ########################### - - Condition* cond; - char* condText; - char* desc; - -// ################################## End of SP CODE ########################### -} watchpointinfo; - -//mbg merge 7/18/06 had to make this extern -extern watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over - -int getBank(int offs); -int GetNesFileAddress(int A); -int GetPRGAddress(int A); -int GetRomAddress(int A); -//int GetEditHex(HWND hwndDlg, int id); -uint8 *GetNesPRGPointer(int A); -uint8 *GetNesCHRPointer(int A); -void KillDebugger(); -uint8 GetMem(uint16 A); -uint8 GetPPUMem(uint8 A); - -//---------CDLogger -void LogCDVectors(int which); -void LogCDData(uint8 *opcode, uint16 A, int size); -extern volatile int codecount, datacount, undefinedcount; -extern unsigned char *cdloggerdata; -extern unsigned int cdloggerdataSize; - -extern int debug_loggingCD; -static INLINE void FCEUI_SetLoggingCD(int val) { debug_loggingCD = val; } -static INLINE int FCEUI_GetLoggingCD() { return debug_loggingCD; } -//------- - -//-------tracing -//we're letting the win32 driver handle this ittself for now -//extern int debug_tracing; -//static INLINE void FCEUI_SetTracing(int val) { debug_tracing = val; } -//static INLINE int FCEUI_GetTracing() { return debug_tracing; } -//--------- - -//--------debugger -extern int iaPC; -extern uint32 iapoffset; //mbg merge 7/18/06 changed from int -void DebugCycle(); -void BreakHit(int bp_num, bool force = false); - -extern bool break_asap; -extern uint64 total_cycles_base; -extern uint64 delta_cycles_base; -extern bool break_on_cycles; -extern uint64 break_cycles_limit; -extern uint64 total_instructions; -extern uint64 delta_instructions; -extern bool break_on_instructions; -extern uint64 break_instructions_limit; -extern void ResetDebugStatisticsCounters(); -extern void ResetCyclesCounter(); -extern void ResetInstructionsCounter(); -extern void ResetDebugStatisticsDeltaCounters(); -extern void IncrementInstructionsCounters(); -//------------- - -//internal variables that debuggers will want access to -extern uint8 *vnapage[4],*VPage[8]; -extern uint8 PPU[4],PALRAM[0x20],SPRAM[0x100],VRAMBuffer,PPUGenLatch,XOffset; -extern uint32 RefreshAddr; - -extern int debug_loggingCD; -extern int numWPs; - -///encapsulates the operational state of the debugger core -class DebuggerState { -public: - ///indicates whether the debugger is stepping through a single instruction - bool step; - ///indicates whether the debugger is stepping out of a function call - bool stepout; - ///indicates whether the debugger is running one line - bool runline; - ///target timestamp for runline to stop at - uint64 runline_end_time; - ///indicates whether the debugger should break on bad opcodes - bool badopbreak; - ///counts the nest level of the call stack while stepping out - int jsrcount; - - ///resets the debugger state to an empty, non-debugging state - void reset() { - numWPs = 0; - step = false; - stepout = false; - jsrcount = 0; - } -}; - -extern NSF_HEADER NSFHeader; - -///retrieves the core's DebuggerState -DebuggerState &FCEUI_Debugger(); - -//#define CPU_BREAKPOINT 1 -//#define PPU_BREAKPOINT 2 -//#define SPRITE_BREAKPOINT 4 -//#define READ_BREAKPOINT 8 -//#define WRITE_BREAKPOINT 16 -//#define EXECUTE_BREAKPOINT 32 - -int offsetStringToInt(unsigned int type, const char* offsetBuffer); -unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable); - -#endif diff --git a/branches/fceux-2.2.2/src/driver.h b/branches/fceux-2.2.2/src/driver.h deleted file mode 100644 index d7474aa5..00000000 --- a/branches/fceux-2.2.2/src/driver.h +++ /dev/null @@ -1,349 +0,0 @@ -#ifndef __DRIVER_H_ -#define __DRIVER_H_ - -#include "types.h" -#include "git.h" -#include "file.h" - -#include -#include -#include - -FILE *FCEUD_UTF8fopen(const char *fn, const char *mode); -inline FILE *FCEUD_UTF8fopen(const std::string &n, const char *mode) { return FCEUD_UTF8fopen(n.c_str(),mode); } -EMUFILE_FILE* FCEUD_UTF8_fstream(const char *n, const char *m); -inline EMUFILE_FILE* FCEUD_UTF8_fstream(const std::string &n, const char *m) { return FCEUD_UTF8_fstream(n.c_str(),m); } -FCEUFILE* FCEUD_OpenArchiveIndex(ArchiveScanRecord& asr, std::string& fname, int innerIndex); -FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename); -ArchiveScanRecord FCEUD_ScanArchive(std::string fname); - -//mbg 7/23/06 -const char *FCEUD_GetCompilerString(); - -//This makes me feel dirty for some reason. -void FCEU_printf(char *format, ...); -#define FCEUI_printf FCEU_printf - -//Video interface -void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b); -void FCEUD_GetPalette(uint8 i,uint8 *r, uint8 *g, uint8 *b); - -//Displays an error. Can block or not. -void FCEUD_PrintError(const char *s); -void FCEUD_Message(const char *s); - -//Network interface - -//Call only when a game is loaded. -int FCEUI_NetplayStart(int nlocal, int divisor); - -// Call when network play needs to stop. -void FCEUI_NetplayStop(void); - -//Note: YOU MUST NOT CALL ANY FCEUI_* FUNCTIONS WHILE IN FCEUD_SendData() or FCEUD_RecvData(). - -//Return 0 on failure, 1 on success. -int FCEUD_SendData(void *data, uint32 len); -int FCEUD_RecvData(void *data, uint32 len); - -//Display text received over the network. -void FCEUD_NetplayText(uint8 *text); - -//Encode and send text over the network. -void FCEUI_NetplayText(uint8 *text); - -//Called when a fatal error occurred and network play can't continue. This function -//should call FCEUI_NetplayStop() after it has deinitialized the network on the driver -//side. -void FCEUD_NetworkClose(void); - -bool FCEUI_BeginWaveRecord(const char *fn); -int FCEUI_EndWaveRecord(void); - -void FCEUI_ResetNES(void); -void FCEUI_PowerNES(void); - -void FCEUI_NTSCSELHUE(void); -void FCEUI_NTSCSELTINT(void); -void FCEUI_NTSCDEC(void); -void FCEUI_NTSCINC(void); -void FCEUI_GetNTSCTH(int *tint, int *hue); -void FCEUI_SetNTSCTH(int n, int tint, int hue); - -void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib); -void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib); - -//tells the emulator whether a fourscore is attached -void FCEUI_SetInputFourscore(bool attachFourscore); -//tells whether a fourscore is attached -bool FCEUI_GetInputFourscore(); -//tells whether the microphone is used -bool FCEUI_GetInputMicrophone(); - -void FCEUI_UseInputPreset(int preset); - - -//New interface functions - -//0 to order screen snapshots numerically(0.png), 1 to order them file base-numerically(smb3-0.png). -//this variable isn't used at all, snap is always name-based -//void FCEUI_SetSnapName(bool a); - -//0 to keep 8-sprites limitation, 1 to remove it -void FCEUI_DisableSpriteLimitation(int a); - -void FCEUI_SetRenderPlanes(bool sprites, bool bg); -void FCEUI_GetRenderPlanes(bool& sprites, bool& bg); - -//name=path and file to load. returns null if it failed -FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode, bool silent = false); - -//same as FCEUI_LoadGame, except that it can load from a tempfile. -//name is the logical path to open; archiveFilename is the archive which contains name -FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silent = false); - -//general purpose emulator initialization. returns true if successful -bool FCEUI_Initialize(); - -//Emulates a frame. -void FCEUI_Emulate(uint8 **, int32 **, int32 *, int); - -//Closes currently loaded game -void FCEUI_CloseGame(void); - -//Deallocates all allocated memory. Call after FCEUI_Emulate() returns. -void FCEUI_Kill(void); - -//Enable/Disable game genie. a=true->enabled -void FCEUI_SetGameGenie(bool a); - -//Set video system a=0 NTSC, a=1 PAL -void FCEUI_SetVidSystem(int a); - -//Convenience function; returns currently emulated video system(0=NTSC, 1=PAL). -int FCEUI_GetCurrentVidSystem(int *slstart, int *slend); - -#ifdef FRAMESKIP -/* Should be called from FCEUD_BlitScreen(). Specifies how many frames - to skip until FCEUD_BlitScreen() is called. FCEUD_BlitScreenDummy() - will be called instead of FCEUD_BlitScreen() when when a frame is skipped. -*/ -void FCEUI_FrameSkip(int x); -#endif - -//First and last scanlines to render, for ntsc and pal emulation. -void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); - -//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory. -void FCEUI_SetBaseDirectory(std::string const & dir); - -//Tells FCE Ultra to copy the palette data pointed to by pal and use it. -//Data pointed to by pal needs to be 64*3 bytes in length. -void FCEUI_SetPaletteArray(uint8 *pal); - -//Sets up sound code to render sound at the specified rate, in samples -//per second. Only sample rates of 44100, 48000, and 96000 are currently supported. -//If "Rate" equals 0, sound is disabled. -void FCEUI_Sound(int Rate); -void FCEUI_SetSoundVolume(uint32 volume); -void FCEUI_SetTriangleVolume(uint32 volume); -void FCEUI_SetSquare1Volume(uint32 volume); -void FCEUI_SetSquare2Volume(uint32 volume); -void FCEUI_SetNoiseVolume(uint32 volume); -void FCEUI_SetPCMVolume(uint32 volume); - -void FCEUI_SetSoundQuality(int quality); - -void FCEUD_SoundToggle(void); -void FCEUD_SoundVolumeAdjust(int); - -int FCEUI_SelectState(int, int); -extern void FCEUI_SelectStateNext(int); - -//"fname" overrides the default save state filename code if non-NULL. -void FCEUI_SaveState(const char *fname, bool display_message=true); -void FCEUI_LoadState(const char *fname, bool display_message=true); - -void FCEUD_SaveStateAs(void); -void FCEUD_LoadStateFrom(void); - -//at the minimum, you should call FCEUI_SetInput, FCEUI_SetInputFC, and FCEUI_SetInputFourscore -//you may also need to maintain your own internal state -void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp); - - -void FCEUD_MovieRecordTo(void); -void FCEUD_MovieReplayFrom(void); -void FCEUD_LuaRunFrom(void); - -int32 FCEUI_GetDesiredFPS(void); -void FCEUI_SaveSnapshot(void); -void FCEUI_SaveSnapshotAs(void); -void FCEU_DispMessage(char *format, int disppos, ...); -#define FCEUI_DispMessage FCEU_DispMessage - -int FCEUI_DecodePAR(const char *code, int *a, int *v, int *c, int *type); -int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c); -int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type); -int FCEUI_DelCheat(uint32 which); -int FCEUI_ToggleCheat(uint32 which); - -int32 FCEUI_CheatSearchGetCount(void); -void FCEUI_CheatSearchGetRange(uint32 first, uint32 last, int (*callb)(uint32 a, uint8 last, uint8 current)); -void FCEUI_CheatSearchGet(int (*callb)(uint32 a, uint8 last, uint8 current, void *data), void *data); -void FCEUI_CheatSearchBegin(void); -void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2); -void FCEUI_ListCheats(int (*callb)(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data), void *data); - -int FCEUI_GetCheat(uint32 which, char **name, uint32 *a, uint8 *v, int *compare, int *s, int *type); -int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare,int s, int type); - -void FCEUI_CheatSearchShowExcluded(void); -void FCEUI_CheatSearchSetCurrentAsOriginal(void); - -//.rom -#define FCEUIOD_ROMS 0 //Roms -#define FCEUIOD_NV 1 //NV = nonvolatile. save data. -#define FCEUIOD_STATES 2 //savestates -#define FCEUIOD_FDSROM 3 //disksys.rom -#define FCEUIOD_SNAPS 4 //screenshots -#define FCEUIOD_CHEATS 5 //cheats -#define FCEUIOD_MOVIES 6 //.fm2 files -#define FCEUIOD_MEMW 7 //memory watch fiels -#define FCEUIOD_BBOT 8 //basicbot, obsolete -#define FCEUIOD_MACRO 9 //macro files - old TASEdit v0.1 paradigm, not implemented, probably obsolete -#define FCEUIOD_INPUT 10 //input presets -#define FCEUIOD_LUA 11 //lua scripts -#define FCEUIOD_AVI 12 //default file for avi output -#define FCEUIOD__COUNT 13 //base directory override? - -void FCEUI_SetDirOverride(int which, char *n); - -void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v)); -uint8 FCEUI_MemSafePeek(uint16 A); -void FCEUI_MemPoke(uint16 a, uint8 v, int hl); -void FCEUI_NMI(void); -void FCEUI_IRQ(void); -uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo); -void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi); - -uint32 FCEUI_CRC32(uint32 crc, uint8 *buf, uint32 len); - -void FCEUI_SetLowPass(int q); - -void FCEUI_NSFSetVis(int mode); -int FCEUI_NSFChange(int amount); -int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen); - -void FCEUI_VSUniToggleDIPView(void); -void FCEUI_VSUniToggleDIP(int w); -uint8 FCEUI_VSUniGetDIPs(void); -void FCEUI_VSUniSetDIP(int w, int state); -void FCEUI_VSUniCoin(void); - -void FCEUI_FDSInsert(void); //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN -//int FCEUI_FDSEject(void); -void FCEUI_FDSSelect(void); - -int FCEUI_DatachSet(const uint8 *rcode); - -///returns a flag indicating whether emulation is paused -int FCEUI_EmulationPaused(); -///returns a flag indicating whether a one frame step has been requested -int FCEUI_EmulationFrameStepped(); -///clears the framestepped flag. use it after youve stepped your one frame -void FCEUI_ClearEmulationFrameStepped(); -///sets the EmulationPaused flags -void FCEUI_SetEmulationPaused(int val); -///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses -void FCEUI_ToggleEmulationPause(); - -//indicates whether input aids should be drawn (such as crosshairs, etc; usually in fullscreen mode) -bool FCEUD_ShouldDrawInputAids(); - -///called when the emulator closes a game -void FCEUD_OnCloseGame(void); - -void FCEUI_FrameAdvance(void); -void FCEUI_FrameAdvanceEnd(void); - -//AVI Output -int FCEUI_AviBegin(const char* fname); -void FCEUI_AviEnd(void); -void FCEUI_AviVideoUpdate(const unsigned char* buffer); -void FCEUI_AviSoundUpdate(void* soundData, int soundLen); -bool FCEUI_AviIsRecording(); -bool FCEUI_AviEnableHUDrecording(); -void FCEUI_SetAviEnableHUDrecording(bool enable); -bool FCEUI_AviDisableMovieMessages(); -void FCEUI_SetAviDisableMovieMessages(bool disable); - -void FCEUD_AviRecordTo(void); -void FCEUD_AviStop(void); - -///A callback that the emu core uses to poll the state of a given emulator command key -typedef int TestCommandState(int cmd); -///Signals the emu core to poll for emulator commands and take actions -void FCEUI_HandleEmuCommands(TestCommandState* testfn); - - -//Emulation speed -enum EMUSPEED_SET -{ - EMUSPEED_SLOWEST=0, - EMUSPEED_SLOWER, - EMUSPEED_NORMAL, - EMUSPEED_FASTER, - EMUSPEED_FASTEST -}; -void FCEUD_SetEmulationSpeed(int cmd); -void FCEUD_TurboOn(void); -void FCEUD_TurboOff(void); -void FCEUD_TurboToggle(void); - -int FCEUD_ShowStatusIcon(void); -void FCEUD_ToggleStatusIcon(void); -void FCEUD_HideMenuToggle(void); - -///signals the driver to perform a file open GUI operation -void FCEUD_CmdOpen(void); - -//new merge-era driver routines here: - -///signals that the cpu core hit a breakpoint. this function should not return until the core is ready for the next cycle -void FCEUD_DebugBreakpoint(int bp_num); - -///the driver should log the current instruction, if it wants (we should move the code in the win driver that does this to the shared area) -void FCEUD_TraceInstruction(uint8 *opcode, int size); - -///the driver might should update its NTView (only used if debugging support is compiled in) -void FCEUD_UpdateNTView(int scanline, bool drawall); - -///the driver might should update its PPUView (only used if debugging support is compiled in) -void FCEUD_UpdatePPUView(int scanline, int drawall); - -///I am dissatisfied with this method of getting an option from the driver to the core. but that is what we're using for now -bool FCEUD_PauseAfterPlayback(); - -///called when fceu changes something in the video system you might be interested in -void FCEUD_VideoChanged(); - -enum EFCEUI -{ - FCEUI_STOPAVI, FCEUI_QUICKSAVE, FCEUI_QUICKLOAD, FCEUI_SAVESTATE, FCEUI_LOADSTATE, - FCEUI_NEXTSAVESTATE,FCEUI_PREVIOUSSAVESTATE,FCEUI_VIEWSLOTS, - FCEUI_STOPMOVIE, FCEUI_RECORDMOVIE, FCEUI_PLAYMOVIE, - FCEUI_OPENGAME, FCEUI_CLOSEGAME, - FCEUI_TASEDITOR, - FCEUI_RESET, FCEUI_POWER, FCEUI_PLAYFROMBEGINNING, FCEUI_EJECT_DISK, FCEUI_SWITCH_DISK, FCEUI_INSERT_COIN -}; - -//checks whether an EFCEUI is valid right now -bool FCEU_IsValidUI(EFCEUI ui); - -#ifdef __cplusplus -extern "C" -#endif -FILE *FCEUI_UTF8fopen_C(const char *n, const char *m); - -#endif //__DRIVER_H_ diff --git a/branches/fceux-2.2.2/src/drivers/common/args.cpp b/branches/fceux-2.2.2/src/drivers/common/args.cpp deleted file mode 100644 index 4167b8f5..00000000 --- a/branches/fceux-2.2.2/src/drivers/common/args.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/****************************************************************/ -/* FCE Ultra */ -/* */ -/* This file contains code for parsing command-line */ -/* options. */ -/* */ -/****************************************************************/ - -#include -#include -#include - -#include "../../types.h" -#include "args.h" - -int ParseEA(int x, int argc, char *argv[], ARGPSTRUCT *argsps) -{ - int y=0; - int ret=1; - - do - { - if(!argsps[y].name) - { - ParseEA(x,argc,argv,(ARGPSTRUCT*)argsps[y].var); - y++; - continue; - } - if(!strcmp(argv[x],argsps[y].name)) // A match. - { - //ret++; - if(argsps[y].subs) - { - if((x+1)>=argc) - break; - ret++; - if(argsps[y].substype&0x2000) - { - ((void (*)(char *))argsps[y].subs)(argv[x+1]); - } - else if(argsps[y].substype&0x8000) - { - *(int *)argsps[y].subs&=~(argsps[y].substype&(~0x8000)); - *(int *)argsps[y].subs|=atoi(argv[x+1])?(argsps[y].substype&(~0x8000)):0; - } - else - switch(argsps[y].substype&(~0x4000)) - { - case 0: // Integer - *(int *)argsps[y].subs=atoi(argv[x+1]); - break; - case 2: // Double float - *(double *)argsps[y].subs=atof(argv[x+1]); - break; - case 1: // String - if(argsps[y].substype&0x4000) - { - if(*(char **)argsps[y].subs) - free(*(char **)argsps[y].subs); - if(!( *(char **)argsps[y].subs=(char*)malloc(strlen(argv[x+1])+1) )) - break; - } - strcpy(*(char **)argsps[y].subs,argv[x+1]); - break; - } - } - if(argsps[y].var) - *argsps[y].var=1; - } - y++; - } while(argsps[y].var || argsps[y].subs); - return ret; -} - -int ParseArguments(int argc, char *argv[], ARGPSTRUCT *argsps) -{ - int x; - - for(x=0;xbase_palette || setup->palette) - -#include "nes_ntsc_impl.h" - -// CUSTOM: Added this for dynamic support -int OutputMultiplier = 2; -int OutputDepth = 32; - -/* 3 input pixels -> 8 composite samples */ -pixel_info_t const nes_ntsc_pixels [alignment_count] = { - { PIXEL_OFFSET( -4, -9 ), { 1, 1, .6667f, 0 } }, - { PIXEL_OFFSET( -2, -7 ), { .3333f, 1, 1, .3333f } }, - { PIXEL_OFFSET( 0, -5 ), { 0, .6667f, 1, 1 } }, -}; - -static void merge_kernel_fields( nes_ntsc_rgb_t* io ) -{ - int n; - for ( n = burst_size; n; --n ) - { - nes_ntsc_rgb_t p0 = io [burst_size * 0] + rgb_bias; - nes_ntsc_rgb_t p1 = io [burst_size * 1] + rgb_bias; - nes_ntsc_rgb_t p2 = io [burst_size * 2] + rgb_bias; - /* merge colors without losing precision */ - io [burst_size * 0] = - ((p0 + p1 - ((p0 ^ p1) & nes_ntsc_rgb_builder)) >> 1) - rgb_bias; - io [burst_size * 1] = - ((p1 + p2 - ((p1 ^ p2) & nes_ntsc_rgb_builder)) >> 1) - rgb_bias; - io [burst_size * 2] = - ((p2 + p0 - ((p2 ^ p0) & nes_ntsc_rgb_builder)) >> 1) - rgb_bias; - ++io; - } -} - -static void correct_errors( nes_ntsc_rgb_t color, nes_ntsc_rgb_t* out ) -{ - int n; - for ( n = burst_count; n; --n ) - { - unsigned i; - for ( i = 0; i < rgb_kernel_size / 2; i++ ) - { - nes_ntsc_rgb_t error = color - - out [i ] - out [(i+12)%14+14] - out [(i+10)%14+28] - - out [i + 7] - out [i + 5 +14] - out [i + 3 +28]; - DISTRIBUTE_ERROR( i+3+28, i+5+14, i+7 ); - } - out += alignment_count * rgb_kernel_size; - } -} - -void nes_ntsc_init( nes_ntsc_t* ntsc, nes_ntsc_setup_t const* setup, int bpp, int multiplier ) -{ - int merge_fields; - int entry; - init_t impl; - float gamma_factor; - - OutputMultiplier = multiplier; - OutputDepth = bpp * 8; - - if ( !setup ) - setup = &nes_ntsc_composite; - init( &impl, setup ); - - /* setup fast gamma */ - { - float gamma = (float) setup->gamma * -0.5f; - if ( STD_HUE_CONDITION( setup ) ) - gamma += 0.1333f; - - gamma_factor = (float) pow( (float) fabs( gamma ), 0.73f ); - if ( gamma < 0 ) - gamma_factor = -gamma_factor; - } - - merge_fields = setup->merge_fields; - if ( setup->artifacts <= -1 && setup->fringing <= -1 ) - merge_fields = 1; - - for ( entry = 0; entry < nes_ntsc_palette_size; entry++ ) - { - /* Base 64-color generation */ - static float const lo_levels [4] = { -0.12f, 0.00f, 0.31f, 0.72f }; - static float const hi_levels [4] = { 0.40f, 0.68f, 1.00f, 1.00f }; - int level = entry >> 4 & 0x03; - float lo = lo_levels [level]; - float hi = hi_levels [level]; - - int color = entry & 0x0F; - if ( color == 0 ) - lo = hi; - if ( color == 0x0D ) - hi = lo; - if ( color > 0x0D ) - hi = lo = 0.0f; - - { - /* phases [i] = cos( i * PI / 6 ) */ - static float const phases [0x10 + 3] = { - -1.0f, -0.866025f, -0.5f, 0.0f, 0.5f, 0.866025f, - 1.0f, 0.866025f, 0.5f, 0.0f, -0.5f, -0.866025f, - -1.0f, -0.866025f, -0.5f, 0.0f, 0.5f, 0.866025f, - 1.0f - }; - #define TO_ANGLE_SIN( color ) phases [color] - #define TO_ANGLE_COS( color ) phases [(color) + 3] - - /* Convert raw waveform to YIQ */ - float sat = (hi - lo) * 0.5f; - float i = TO_ANGLE_SIN( color ) * sat; - float q = TO_ANGLE_COS( color ) * sat; - float y = (hi + lo) * 0.5f; - - /* Optionally use base palette instead */ - if ( setup->base_palette ) - { - unsigned char const* in = &setup->base_palette [(entry & 0x3F) * 3]; - static float const to_float = 1.0f / 0xFF; - float r = to_float * in [0]; - float g = to_float * in [1]; - float b = to_float * in [2]; - q = RGB_TO_YIQ( r, g, b, y, i ); - } - - /* Apply color emphasis */ - #ifdef NES_NTSC_EMPHASIS - { - int tint = entry >> 6 & 7; - if ( tint && color <= 0x0D ) - { - static float const atten_mul = 0.79399f; - static float const atten_sub = 0.0782838f; - - if ( tint == 7 ) - { - y = y * (atten_mul * 1.13f) - (atten_sub * 1.13f); - } - else - { - static unsigned char const tints [8] = { 0, 6, 10, 8, 2, 4, 0, 0 }; - int const tint_color = tints [tint]; - float sat = hi * (0.5f - atten_mul * 0.5f) + atten_sub * 0.5f; - y -= sat * 0.5f; - if ( tint >= 3 && tint != 4 ) - { - /* combined tint bits */ - sat *= 0.6f; - y -= sat; - } - i += TO_ANGLE_SIN( tint_color ) * sat; - q += TO_ANGLE_COS( tint_color ) * sat; - } - } - } - #endif - - /* Optionally use palette instead */ - if ( setup->palette ) - { - unsigned char const* in = &setup->palette [entry * 3]; - static float const to_float = 1.0f / 0xFF; - float r = to_float * in [0]; - float g = to_float * in [1]; - float b = to_float * in [2]; - q = RGB_TO_YIQ( r, g, b, y, i ); - } - - /* Apply brightness, contrast, and gamma */ - y *= (float) setup->contrast * 0.5f + 1; - /* adjustment reduces error when using input palette */ - y += (float) setup->brightness * 0.5f - 0.5f / 256; - - { - float r, g, b = YIQ_TO_RGB( y, i, q, default_decoder, float, r, g ); - - /* fast approximation of n = pow( n, gamma ) */ - r = (r * gamma_factor - gamma_factor) * r + r; - g = (g * gamma_factor - gamma_factor) * g + g; - b = (b * gamma_factor - gamma_factor) * b + b; - - q = RGB_TO_YIQ( r, g, b, y, i ); - } - - i *= rgb_unit; - q *= rgb_unit; - y *= rgb_unit; - y += rgb_offset; - - /* Generate kernel */ - { - int r, g, b = YIQ_TO_RGB( y, i, q, impl.to_rgb, int, r, g ); - /* blue tends to overflow, so clamp it */ - nes_ntsc_rgb_t rgb = PACK_RGB( r, g, (b < 0x3E0 ? b: 0x3E0) ); - - if ( setup->palette_out ) - RGB_PALETTE_OUT( rgb, &setup->palette_out [entry * 3] ); - - if ( ntsc ) - { - nes_ntsc_rgb_t* kernel = ntsc->table [entry]; - gen_kernel( &impl, y, i, q, kernel ); - if ( merge_fields ) - merge_kernel_fields( kernel ); - correct_errors( rgb, kernel ); - } - } - } - } -} - -#ifndef NES_NTSC_NO_BLITTERS - -void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, long in_row_width, - int burst_phase, int in_width, int in_height, void* rgb_out, long out_pitch ) -{ - int chunk_count = (in_width - 1) / nes_ntsc_in_chunk; - - int TempMultiplier = OutputMultiplier * 3; - if (TempMultiplier > 7) - TempMultiplier = 7; - - for ( ; in_height; --in_height ) - { - int out; - for ( out = OutputMultiplier; out; --out ) { - NES_NTSC_IN_T const* line_in = input; - NES_NTSC_BEGIN_ROW( ntsc, burst_phase, nes_ntsc_black, nes_ntsc_black, NES_NTSC_ADJ_IN( *line_in ) ); - nes_ntsc_out_t* restrict line_out = (nes_ntsc_out_t*) rgb_out; - int n; - ++line_in; - - for ( n = chunk_count; n; --n ) - { - - /* order of input and output pixels must not be altered */ - NES_NTSC_COLOR_IN( 0, NES_NTSC_ADJ_IN( line_in [0] ) ); - NES_NTSC_RGB_OUT( 0, line_out [0], OutputDepth ); - NES_NTSC_RGB_OUT( 1, line_out [1], OutputDepth ); - - NES_NTSC_COLOR_IN( 1, NES_NTSC_ADJ_IN( line_in [1] ) ); - NES_NTSC_RGB_OUT( 2, line_out [2], OutputDepth ); - NES_NTSC_RGB_OUT( 3, line_out [3], OutputDepth ); - - NES_NTSC_COLOR_IN( 2, NES_NTSC_ADJ_IN( line_in [2] ) ); - NES_NTSC_RGB_OUT( 4, line_out [4], OutputDepth ); - NES_NTSC_RGB_OUT( 5, line_out [5], OutputDepth ); - NES_NTSC_RGB_OUT( 6, line_out [6], OutputDepth ); - - line_in += 3; - line_out += rescale_out; - } - - /* finish final pixels */ - NES_NTSC_COLOR_IN( 0, nes_ntsc_black ); - NES_NTSC_RGB_OUT( 0, line_out [0], OutputDepth ); - NES_NTSC_RGB_OUT( 1, line_out [1], OutputDepth ); - - NES_NTSC_COLOR_IN( 1, nes_ntsc_black ); - NES_NTSC_RGB_OUT( 2, line_out [2], OutputDepth ); - NES_NTSC_RGB_OUT( 3, line_out [3], OutputDepth ); - - NES_NTSC_COLOR_IN( 2, nes_ntsc_black ); - NES_NTSC_RGB_OUT( 4, line_out [4], OutputDepth ); - NES_NTSC_RGB_OUT( 5, line_out [5], OutputDepth ); - NES_NTSC_RGB_OUT( 6, line_out [6], OutputDepth ); - rgb_out = (char*) rgb_out + out_pitch; - } - - burst_phase = (burst_phase + 1) % nes_ntsc_burst_count; - input += in_row_width; - } -} - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/common/nes_ntsc.h b/branches/fceux-2.2.2/src/drivers/common/nes_ntsc.h deleted file mode 100644 index dba8476d..00000000 --- a/branches/fceux-2.2.2/src/drivers/common/nes_ntsc.h +++ /dev/null @@ -1,192 +0,0 @@ -/* NES NTSC video filter */ - -/* nes_ntsc 0.2.2 */ -#ifndef NES_NTSC_H -#define NES_NTSC_H - -#include "nes_ntsc_config.h" - -#ifdef __cplusplus - extern "C" { -#endif - -/* Image parameters, ranging from -1.0 to 1.0. Actual internal values shown -in parenthesis and should remain fairly stable in future versions. */ -typedef struct nes_ntsc_setup_t -{ - /* Basic parameters */ - double hue; /* -1 = -180 degrees +1 = +180 degrees */ - double saturation; /* -1 = grayscale (0.0) +1 = oversaturated colors (2.0) */ - double contrast; /* -1 = dark (0.5) +1 = light (1.5) */ - double brightness; /* -1 = dark (0.5) +1 = light (1.5) */ - double sharpness; /* edge contrast enhancement/blurring */ - - /* Advanced parameters */ - double gamma; /* -1 = dark (1.5) +1 = light (0.5) */ - double resolution; /* image resolution */ - double artifacts; /* artifacts caused by color changes */ - double fringing; /* color artifacts caused by brightness changes */ - double bleed; /* color bleed (color resolution reduction) */ - int merge_fields; /* if 1, merges even and odd fields together to reduce flicker */ - float const* decoder_matrix; /* optional RGB decoder matrix, 6 elements */ - - unsigned char* palette_out; /* optional RGB palette out, 3 bytes per color */ - - /* You can replace the standard NES color generation with an RGB palette. The - first replaces all color generation, while the second replaces only the core - 64-color generation and does standard color emphasis calculations on it. */ - unsigned char const* palette;/* optional 512-entry RGB palette in, 3 bytes per color */ - unsigned char const* base_palette;/* optional 64-entry RGB palette in, 3 bytes per color */ -} nes_ntsc_setup_t; - -/* Video format presets */ -extern nes_ntsc_setup_t const nes_ntsc_composite; /* color bleeding + artifacts */ -extern nes_ntsc_setup_t const nes_ntsc_svideo; /* color bleeding only */ -extern nes_ntsc_setup_t const nes_ntsc_rgb; /* crisp image */ -extern nes_ntsc_setup_t const nes_ntsc_monochrome;/* desaturated + artifacts */ - -#ifdef NES_NTSC_EMPHASIS - enum { nes_ntsc_palette_size = 64 * 8 }; -#else - enum { nes_ntsc_palette_size = 64 }; -#endif - -/* Initializes and adjusts parameters. Can be called multiple times on the same -nes_ntsc_t object. Can pass NULL for either parameter. */ -typedef struct nes_ntsc_t nes_ntsc_t; -void nes_ntsc_init( nes_ntsc_t* ntsc, nes_ntsc_setup_t const* setup, int bpp, int multiplier ); - -/* Filters one or more rows of pixels. Input pixels are 6/9-bit palette indicies. -In_row_width is the number of pixels to get to the next input row. Out_pitch -is the number of *bytes* to get to the next output row. Output pixel format -is set by NES_NTSC_OUT_DEPTH (defaults to 16-bit RGB). */ -void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* nes_in, - long in_row_width, int burst_phase, int in_width, int in_height, - void* rgb_out, long out_pitch ); - -/* Number of output pixels written by blitter for given input width. Width might -be rounded down slightly; use NES_NTSC_IN_WIDTH() on result to find rounded -value. Guaranteed not to round 256 down at all. */ -#define NES_NTSC_OUT_WIDTH( in_width ) \ - ((((in_width) - 1) / nes_ntsc_in_chunk + 1) * nes_ntsc_out_chunk) - -/* Number of input pixels that will fit within given output width. Might be -rounded down slightly; use NES_NTSC_OUT_WIDTH() on result to find rounded -value. */ -#define NES_NTSC_IN_WIDTH( out_width ) \ - (((out_width) / nes_ntsc_out_chunk - 1) * nes_ntsc_in_chunk + 1) - - -/* Interface for user-defined custom blitters */ - -enum { nes_ntsc_in_chunk = 3 }; /* number of input pixels read per chunk */ -//enum { nes_ntsc_out_chunk = 3 }; /* number of output pixels generated per chunk */ -enum { nes_ntsc_black = 15 }; /* palette index for black */ -enum { nes_ntsc_burst_count = 3 }; /* burst phase cycles through 0, 1, and 2 */ - -/* Begins outputting row and starts three pixels. First pixel will be cut off a bit. -Use nes_ntsc_black for unused pixels. Declares variables, so must be before first -statement in a block (unless you're using C++). */ -#define NES_NTSC_BEGIN_ROW( ntsc, burst, pixel0, pixel1, pixel2 ) \ - char const* const ktable = \ - (char const*) (ntsc)->table [0] + burst * (nes_ntsc_burst_size * sizeof (nes_ntsc_rgb_t));\ - NES_NTSC_BEGIN_ROW_6_( pixel0, pixel1, pixel2, NES_NTSC_ENTRY_, ktable ) - -/* Begins input pixel */ -#define NES_NTSC_COLOR_IN( in_index, color_in ) \ - NES_NTSC_COLOR_IN_( in_index, color_in, NES_NTSC_ENTRY_, ktable ) - -/* Generates output pixel. Bits can be 24, 16, 15, 32 (treated as 24), or 0: -24: RRRRRRRR GGGGGGGG BBBBBBBB (8-8-8 RGB) -16: RRRRRGGG GGGBBBBB (5-6-5 RGB) -15: RRRRRGG GGGBBBBB (5-5-5 RGB) - 0: xxxRRRRR RRRxxGGG GGGGGxxB BBBBBBBx (native internal format; x = junk bits) */ -#define NES_NTSC_RGB_OUT( index, rgb_out, bits ) \ - NES_NTSC_RGB_OUT_14_( index, rgb_out, bits, 0 ) - - -/* private */ -enum { nes_ntsc_entry_size = 128 }; -typedef unsigned long nes_ntsc_rgb_t; -struct nes_ntsc_t { - nes_ntsc_rgb_t table [nes_ntsc_palette_size] [nes_ntsc_entry_size]; -}; -enum { nes_ntsc_burst_size = nes_ntsc_entry_size / nes_ntsc_burst_count }; - -#define NES_NTSC_ENTRY_( ktable, n ) \ - (nes_ntsc_rgb_t const*) (ktable + (n) * (nes_ntsc_entry_size * sizeof (nes_ntsc_rgb_t))) - -/* deprecated */ -#define NES_NTSC_RGB24_OUT( x, out ) NES_NTSC_RGB_OUT( x, out, 24 ) -#define NES_NTSC_RGB16_OUT( x, out ) NES_NTSC_RGB_OUT( x, out, 16 ) -#define NES_NTSC_RGB15_OUT( x, out ) NES_NTSC_RGB_OUT( x, out, 15 ) -#define NES_NTSC_RAW_OUT( x, out ) NES_NTSC_RGB_OUT( x, out, 0 ) - -enum { nes_ntsc_min_in_width = 256 }; -//enum { nes_ntsc_min_out_width = NES_NTSC_OUT_WIDTH( nes_ntsc_min_in_width ) }; - -enum { nes_ntsc_640_in_width = 271 }; -//enum { nes_ntsc_640_out_width = NES_NTSC_OUT_WIDTH( nes_ntsc_640_in_width ) }; -enum { nes_ntsc_640_overscan_left = 8 }; -enum { nes_ntsc_640_overscan_right = nes_ntsc_640_in_width - 256 - nes_ntsc_640_overscan_left }; - -enum { nes_ntsc_full_in_width = 283 }; -//enum { nes_ntsc_full_out_width = NES_NTSC_OUT_WIDTH( nes_ntsc_full_in_width ) }; -enum { nes_ntsc_full_overscan_left = 16 }; -enum { nes_ntsc_full_overscan_right = nes_ntsc_full_in_width - 256 - nes_ntsc_full_overscan_left }; - -/* common 3->7 ntsc macros */ -#define NES_NTSC_BEGIN_ROW_6_( pixel0, pixel1, pixel2, ENTRY, table ) \ - unsigned const nes_ntsc_pixel0_ = (pixel0);\ - nes_ntsc_rgb_t const* kernel0 = ENTRY( table, nes_ntsc_pixel0_ );\ - unsigned const nes_ntsc_pixel1_ = (pixel1);\ - nes_ntsc_rgb_t const* kernel1 = ENTRY( table, nes_ntsc_pixel1_ );\ - unsigned const nes_ntsc_pixel2_ = (pixel2);\ - nes_ntsc_rgb_t const* kernel2 = ENTRY( table, nes_ntsc_pixel2_ );\ - nes_ntsc_rgb_t const* kernelx0;\ - nes_ntsc_rgb_t const* kernelx1 = kernel0;\ - nes_ntsc_rgb_t const* kernelx2 = kernel0 - -#define NES_NTSC_RGB_OUT_14_( x, rgb_out, bits, shift ) {\ - nes_ntsc_rgb_t raw_ =\ - kernel0 [x ] + kernel1 [(x+12)%7+14] + kernel2 [(x+10)%7+28] +\ - kernelx0 [(x+7)%14] + kernelx1 [(x+ 5)%7+21] + kernelx2 [(x+ 3)%7+35];\ - NES_NTSC_CLAMP_( raw_, shift );\ - NES_NTSC_RGB_OUT_( rgb_out, bits, shift );\ -} - -/* common ntsc macros */ -#define nes_ntsc_rgb_builder ((1L << 21) | (1 << 11) | (1 << 1)) -#define nes_ntsc_clamp_mask (nes_ntsc_rgb_builder * 3 / 2) -#define nes_ntsc_clamp_add (nes_ntsc_rgb_builder * 0x101) -#define NES_NTSC_CLAMP_( io, shift ) {\ - nes_ntsc_rgb_t sub = (io) >> (9-(shift)) & nes_ntsc_clamp_mask;\ - nes_ntsc_rgb_t clamp = nes_ntsc_clamp_add - sub;\ - io |= clamp;\ - clamp -= sub;\ - io &= clamp;\ -} - -#define NES_NTSC_COLOR_IN_( index, color, ENTRY, table ) {\ - unsigned color_;\ - kernelx##index = kernel##index;\ - kernel##index = (color_ = (color), ENTRY( table, color_ ));\ -} - -/* x is always zero except in snes_ntsc library */ -#define NES_NTSC_RGB_OUT_( rgb_out, bits, x ) {\ - if ( bits == 16 )\ - rgb_out = (raw_>>(13-x)& 0xF800)|(raw_>>(8-x)&0x07E0)|(raw_>>(4-x)&0x001F);\ - if ( bits == 24 || bits == 32 )\ - rgb_out = (raw_>>(5-x)&0xFF0000)|(raw_>>(3-x)&0xFF00)|(raw_>>(1-x)&0xFF);\ - if ( bits == 15 )\ - rgb_out = (raw_>>(14-x)& 0x7C00)|(raw_>>(9-x)&0x03E0)|(raw_>>(4-x)&0x001F);\ - if ( bits == 0 )\ - rgb_out = raw_ << x;\ -} - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/common/nes_ntsc_config.h b/branches/fceux-2.2.2/src/drivers/common/nes_ntsc_config.h deleted file mode 100644 index 76b2c43a..00000000 --- a/branches/fceux-2.2.2/src/drivers/common/nes_ntsc_config.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Configure library by modifying this file */ - -#ifndef NES_NTSC_CONFIG_H -#define NES_NTSC_CONFIG_H - -/* Uncomment to enable emphasis support and use a 512 color palette instead -of the base 64 color palette. */ -/*#define NES_NTSC_EMPHASIS 1*/ - -/* The following affect the built-in blitter only; a custom blitter can -handle things however it wants. */ - -// CUSTOM: Made this use a variable, so it can be changed for output. -/* Bits per pixel of output. Can be 15, 16, 32, or 24 (same as 32). */ -//#define NES_NTSC_OUT_DEPTH OutputDepth - -/* Type of input pixel values. You'll probably use unsigned short -if you enable emphasis above. */ -#define NES_NTSC_IN_T unsigned char - -// CUSTOM: (XBuf uses bit 0x80, and has palettes above 0x3f for LUA) -/* Each raw pixel input value is passed through this. You might want to mask -the pixel index if you use the high bits as flags, etc. */ -#define NES_NTSC_ADJ_IN( in ) in & 0x3f - -/* For each pixel, this is the basic operation: -output_color = color_palette [NES_NTSC_ADJ_IN( NES_NTSC_IN_T )] */ - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/common/vidblit.cpp b/branches/fceux-2.2.2/src/drivers/common/vidblit.cpp deleted file mode 100644 index dc5ab30d..00000000 --- a/branches/fceux-2.2.2/src/drivers/common/vidblit.cpp +++ /dev/null @@ -1,911 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "scalebit.h" -#include "hq2x.h" -#include "hq3x.h" - -#include "../../types.h" -#include "../../utils/memory.h" -#include "nes_ntsc.h" - -nes_ntsc_t* nes_ntsc; -uint8 burst_phase = 0; - -static uint32 CBM[3]; -static uint32 *palettetranslate=0; - -static uint16 *specbuf=NULL; // 8bpp -> 16bpp, pre hq2x/hq3x -static uint32 *specbuf32bpp = NULL; // Buffer to hold output - // of hq2x/hq3x when converting - // to 16bpp and 24bpp -static int backBpp, backshiftr[3], backshiftl[3]; -//static uint32 backmask[3]; - -static uint8 *specbuf8bpp = NULL; // For 2xscale, 3xscale. -uint8 *ntscblit = NULL; // For nes_ntsc - -static int silt; - -static int Bpp; // BYTES per pixel -static int highefx; - -#define BLUR_RED 20 -#define BLUR_GREEN 20 -#define BLUR_BLUE 10 - -#define FVB_SCANLINES 1 - -/* The blur effect is only available for bpp>=16. It could be easily modified - to look like what happens on the real NES and TV, but lack of decent - synchronization to the vertical retrace period makes it look rather - blah. -*/ -#define FVB_BLUR 2 - -static void CalculateShift(uint32 *CBM, int *cshiftr, int *cshiftl) -{ - int a,x,z,y; - cshiftl[0]=cshiftl[1]=cshiftl[2]=-1; - for(a=0;a<3;a++) - { - for(x=0,y=-1,z=0;x<32;x++) - { - if(CBM[a]&(1<16->(hq2x)->32-> 24 or 16. YARGH. - { - uint32 tmpCBM[3]; - backBpp = b; - tmpCBM[0]=rmask; - tmpCBM[1]=gmask; - tmpCBM[2]=bmask; - - CalculateShift(tmpCBM, backshiftr, backshiftl); - - if(b == 2) - { - // ark - backshiftr[0] += 16; - backshiftr[1] += 8; - backshiftr[2] += 0; - - // Begin iffy code(requires 16bpp and 32bpp to have same RGB order) - //backmask[0] = (rmask>>backshiftl[0]) << (backshiftr[0]); - //backmask[1] = (gmask>>backshiftl[1]) << (backshiftr[1]); - //backmask[2] = (bmask>>backshiftl[2]) << (backshiftr[2]); - - //int x; - //for(x=0;x<3;x++) - // backshiftr[x] -= backshiftl[x]; - // End iffy code - } - // -Video Modes Tag- - if(specfilt == 1) specbuf32bpp = (uint32*)FCEU_dmalloc(256*240*4*sizeof(uint32)); //mbg merge 7/17/06 added cast - else if(specfilt == 4) specbuf32bpp = (uint32*)FCEU_dmalloc(256*240*9*sizeof(uint32)); //mbg merge 7/17/06 added cast - } - - efx=0; - b=2; - rmask=0x1F<<11; - gmask=0x3F<<5; - bmask=0x1F; - - // -Video Modes Tag- - if(specfilt == 4) - hq3x_InitLUTs(); - else - hq2x_InitLUTs(); - - specbuf=(uint16*)FCEU_dmalloc(256*240*sizeof(uint16)); //mbg merge 7/17/06 added cast - } - - silt = specfilt; - - Bpp=b; - - highefx=efx; - - if(Bpp<=1 || Bpp>4) - return(0); - - if(efx&FVB_BLUR) - { - if(Bpp==2) - palettetranslate=(uint32 *)FCEU_dmalloc(65536*4); - else if(Bpp>=3) - palettetranslate=(uint32 *)FCEU_dmalloc(65536*4); - } else - { - if(Bpp==2) - palettetranslate=(uint32*)FCEU_dmalloc(65536*4); - else if(Bpp>=3) - palettetranslate=(uint32*)FCEU_dmalloc(256*4); - } - - if(!palettetranslate) - return(0); - - - CBM[0]=rmask; - CBM[1]=gmask; - CBM[2]=bmask; - return(1); -} - -void KillBlitToHigh(void) -{ - if(palettetranslate) - { - free(palettetranslate); - palettetranslate=NULL; - } - - if(specbuf8bpp) - { - free(specbuf8bpp); - specbuf8bpp = NULL; - } - if(specbuf32bpp) - { - free(specbuf32bpp); - specbuf32bpp = NULL; - } - if(specbuf) - { - // -Video Modes Tag- - if(silt == 4) - hq3x_Kill(); - else - hq2x_Kill(); - specbuf=NULL; - } - if (nes_ntsc) { - free(nes_ntsc); - nes_ntsc = NULL; - } - if (ntscblit) { - free(ntscblit); - ntscblit = NULL; - } -} - - -void SetPaletteBlitToHigh(uint8 *src) -{ - int cshiftr[3]; - int cshiftl[3]; - int x,y; - - CalculateShift(CBM, cshiftr, cshiftl); - - switch(Bpp) - { - case 2: - if(highefx&FVB_BLUR) - { - for(x=0;x<256;x++) - { - uint32 r,g,b; - for(y=0;y<256;y++) - { - r=src[x<<2]*(100-BLUR_RED); - g=src[(x<<2)+1]*(100-BLUR_GREEN); - b=src[(x<<2)+2]*(100-BLUR_BLUE); - - r+=src[y<<2]*BLUR_RED; - g+=src[(y<<2)+1]*BLUR_GREEN; - b+=src[(y<<2)+2]*BLUR_BLUE; - r/=100; - g/=100; - b/=100; - - if(r>255) r=255; if(g>255) g=255; if(b>255) b=255; - palettetranslate[x|(y<<8)]=((r>>cshiftr[0])<>cshiftr[1])<>cshiftr[2])<>cshiftr[0])<>cshiftr[1])<>cshiftr[2])<>8)<<2)]>>cshiftr[0])<>8)<<2)+1]>>cshiftr[1])<>8)<<2)+2]>>cshiftr[2])<255) r=255; if(g>255) g=255; if(b>255) b=255; - - palettetranslate[x|(y<<8)]=(r<>8; - dest++; - *dest = tmp>>16; - dest++; - src++; - } - dest += dpitch / 3 - xr; - } -} - - -void Blit32to16(uint32 *src, uint16 *dest, int xr, int yr, int dpitch, - int shiftr[3], int shiftl[3]) -{ - int x,y; - //printf("%d\n",shiftl[1]); - for(y=yr;y;y--) - { - for(x=xr;x;x--) - { - uint32 tmp = *src; - uint16 dtmp; - - // Begin iffy code - //dtmp = (tmp & backmask[2]) >> shiftr[2]; - //dtmp |= (tmp & backmask[1]) >> shiftr[1]; - //dtmp |= (tmp & backmask[0]) >> shiftr[0]; - // End iffy code - - // Begin non-iffy code - dtmp = ((tmp&0x0000FF) >> shiftr[2]) << shiftl[2]; - dtmp |= ((tmp&0x00FF00) >> shiftr[1]) << shiftl[1]; - dtmp |= ((tmp&0xFF0000) >> shiftr[0]) << shiftl[0]; - // End non-iffy code - - //dtmp = ((tmp&0x0000FF) >> 3); - //dtmp |= ((tmp&0x00FC00) >>5); - //dtmp |= ((tmp&0xF80000) >>8); - - *dest = dtmp; - src++; - dest++; - } - dest += dpitch / 2 - xr; - } -} - - -void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale, int efx, int special) -{ - int x,y; - int pinc; - - // -Video Modes Tag- - if(special==3) //NTSC 2x - return; //Incompatible with 8-bit output. This is here for SDL. - - // -Video Modes Tag- - if(special==2) - { - if(xscale!=2 || yscale!=2) return; - - scale(2,dest,pitch,src,256,1,xr,yr); - return; - } - - // -Video Modes Tag- - if(special==5) - { - if(xscale!=3 || yscale!=3) return; - scale(3,dest,pitch,src,256,1,xr,yr); - return; - } - - pinc=pitch-(xr*xscale); - if(xscale!=1 || yscale!=1) - { - if(efx&FVB_SCANLINES) - { - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale-(yscale>>1); - do - { - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint8 *)dest=*(uint8 *)src; - dest++; - } while(--too); - } - src-=xr; - dest+=pinc; - } while(--doo); - //src-=xr*(yscale-(yscale>>1)); - dest+=pitch*(yscale>>1); - - src+=xr; - } - - } - else - { - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - do - { - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint8 *)dest=*(uint8 *)src; - dest++; - } while(--too); - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - } - } - - } - else - { - for(y=yr;y;y--,dest+=pinc,src+=256-xr) - for(x=xr;x;x-=4,dest+=4,src+=4) - *(uint32 *)dest=*(uint32 *)src; - } -} - -/* Todo: Make sure 24bpp code works right with big-endian cpus */ - -void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, - int xscale, int yscale) -{ - int x,y; - int pinc; - uint8 *destbackup = NULL; /* For hq2x */ - int pitchbackup = 0; - - //static int google=0; - //google^=1; - - if(specbuf8bpp) // 2xscale/3xscale - { - int mult; - int base; - - // -Video Modes Tag- - if(silt == 2) mult = 2; - else mult = 3; - - Blit8To8(src, specbuf8bpp, xr, yr, 256*mult, xscale, yscale, 0, silt); - - xr *= mult; - yr *= mult; - xscale=yscale=1; - src = specbuf8bpp; - base = 256*mult; - - switch(Bpp) - { - case 4: - pinc=pitch-(xr<<2); - for(y=yr;y;y--,src+=base-xr) - { - for(x=xr;x;x--) - { - *(uint32 *)dest=palettetranslate[(uint32)*src]; - dest+=4; - src++; - } - dest+=pinc; - } - break; - case 3: - pinc=pitch-(xr+xr+xr); - for(y=yr;y;y--,src+=base-xr) - { - for(x=xr;x;x--) - { - uint32 tmp=palettetranslate[(uint32)*src]; - *(uint8 *)dest=tmp; - *((uint8 *)dest+1)=tmp>>8; - *((uint8 *)dest+2)=tmp>>16; - dest+=3; - src++; - src++; - } - dest+=pinc; - } - break; - case 2: - pinc=pitch-(xr<<1); - - for(y=yr;y;y--,src+=base-xr) - { - for(x=xr>>1;x;x--) - { - *(uint32 *)dest=palettetranslate[*(uint16 *)src]; - dest+=4; - src+=2; - } - dest+=pinc; - } - break; - } - return; - } - else if(specbuf) - { - destbackup=dest; - dest=(uint8 *)specbuf; - pitchbackup=pitch; - - pitch=xr*sizeof(uint16); - xscale=1; - yscale=1; - } - - if(highefx&FVB_BLUR) // DONE - { - if(xscale!=1 || yscale!=1 || (highefx&FVB_SCANLINES)) // DONE - { - switch(Bpp) - { - case 4: - pinc=pitch-((xr*xscale)<<2); - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx&FVB_SCANLINES) - doo-=yscale>>1; - do - { - uint8 last=0x00; - - //if(doo == 1 && google) dest+=4; - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint32 *)dest=palettetranslate[*src|(last<<8)]; - dest+=4; - } while(--too); - last=*src; - } - //if(doo == 1 && google) dest-=4; - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - break; - case 3: - pinc=pitch-((xr*xscale)*3); - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx&FVB_SCANLINES) - doo-=yscale>>1; - do - { - uint8 last=0x00; - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint32 *)dest=palettetranslate[*src|(last<<8)]; - dest+=3; - } while(--too); - last=*src; - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - break; - - case 2: - pinc=pitch-((xr*xscale)<<1); - - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx& FVB_SCANLINES) - doo-=yscale>>1; - do - { - uint8 last=0x00; - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint16 *)dest=palettetranslate[*src|(last<<8)]; - dest+=2; - } while(--too); - last=*src; - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - break; - } - } - else // No scaling, no scanlines, just blurring. - DONE - switch(Bpp) - { - case 4: - pinc=pitch-(xr<<2); - for(y=yr;y;y--,src+=256-xr) - { - uint8 last=0x00; - for(x=xr;x;x--) - { - *(uint32 *)dest=palettetranslate[*src|(last<<8)]; - last=*src; - dest+=4; - src++; - } - dest+=pinc; - } - break; - case 3: - pinc=pitch-(xr+xr+xr); - for(y=yr;y;y--,src+=256-xr) - { - uint8 last=0x00; - for(x=xr;x;x--) - { - uint32 tmp=palettetranslate[*src|(last<<8)]; - last=*src; - *(uint8 *)dest=tmp; - *((uint8 *)dest+1)=tmp>>8; - *((uint8 *)dest+2)=tmp>>16; - dest+=3; - src++; - } - dest+=pinc; - } - break; - case 2: - pinc=pitch-(xr<<1); - for(y=yr;y;y--,src+=256-xr) - { - uint8 last=0x00; - for(x=xr;x;x--) - { - *(uint16 *)dest=palettetranslate[*src|(last<<8)]; - last=*src; - dest+=2; - src++; - } - dest+=pinc; - } - break; - } - } - else // No blur effects. - { - if(xscale!=1 || yscale!=1 || (highefx&FVB_SCANLINES)) - { - switch(Bpp) - { - case 4: - if ( nes_ntsc ) { - burst_phase ^= 1; - nes_ntsc_blit( nes_ntsc, (unsigned char*)src, xr, burst_phase, - xr, yr, ntscblit, xr * Bpp * xscale ); - - //Multiply 4 by the multiplier on output, because it's 4 bpp - //Top 2 lines = line 3, due to distracting flicker - //memcpy(dest,ntscblit+(Bpp * xscale)+(Bpp * xr * xscale),(Bpp * xr * xscale)); - //memcpy(dest+(Bpp * xr * xscale),ntscblit+(Bpp * xscale)+(Bpp * xr * xscale * 2),(Bpp * xr * xscale)); - memcpy(dest+(Bpp * xr * xscale),ntscblit+(Bpp * xscale),(xr*yr*Bpp*xscale*yscale)); - } else { - pinc=pitch-((xr*xscale)<<2); - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx& FVB_SCANLINES) - doo-=yscale>>1; - do - { - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint32 *)dest=palettetranslate[*src]; - dest+=4; - } while(--too); - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - } - break; - - case 3: - pinc=pitch-((xr*xscale)*3); - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx& FVB_SCANLINES) - doo-=yscale>>1; - do - { - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - uint32 tmp=palettetranslate[(uint32)*src]; - *(uint8 *)dest=tmp; - *((uint8 *)dest+1)=tmp>>8; - *((uint8 *)dest+2)=tmp>>16; - dest+=3; - - //*(uint32 *)dest=palettetranslate[*src]; - //dest+=4; - } while(--too); - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - break; - - case 2: - pinc=pitch-((xr*xscale)<<1); - - for(y=yr;y;y--,src+=256-xr) - { - int doo=yscale; - - if(highefx& FVB_SCANLINES) - doo-=yscale>>1; - do - { - for(x=xr;x;x--,src++) - { - int too=xscale; - do - { - *(uint16 *)dest=palettetranslate[*src]; - dest+=2; - } while(--too); - } - src-=xr; - dest+=pinc; - } while(--doo); - src+=xr; - if(highefx&FVB_SCANLINES) - dest+=pitch*(yscale>>1); - } - break; - } - } - else - switch(Bpp) - { - case 4: - pinc=pitch-(xr<<2); - for(y=yr;y;y--,src+=256-xr) - { - for(x=xr;x;x--) - { - *(uint32 *)dest=palettetranslate[(uint32)*src]; - dest+=4; - src++; - } - dest+=pinc; - } - break; - case 3: - pinc=pitch-(xr+xr+xr); - for(y=yr;y;y--,src+=256-xr) - { - for(x=xr;x;x--) - { - uint32 tmp=palettetranslate[(uint32)*src]; - *(uint8 *)dest=tmp; - *((uint8 *)dest+1)=tmp>>8; - *((uint8 *)dest+2)=tmp>>16; - dest+=3; - src++; - } - dest+=pinc; - } - break; - case 2: - pinc=pitch-(xr<<1); - - for(y=yr;y;y--,src+=256-xr) - { - for(x=xr>>1;x;x--) - { - *(uint32 *)dest=palettetranslate[*(uint16 *)src]; - dest+=4; - src+=2; - } - dest+=pinc; - } - break; - } - } - - if(specbuf) - { - if(specbuf32bpp) - { - // -Video Modes Tag- - int mult = (silt == 4)?3:2; - - if(silt == 4) - hq3x_32((uint8 *)specbuf,(uint8*)specbuf32bpp,xr,yr,xr*3*sizeof(uint32)); - else - hq2x_32((uint8 *)specbuf,(uint8*)specbuf32bpp,xr,yr,xr*2*sizeof(uint32)); - - if(backBpp == 2) - Blit32to16(specbuf32bpp, (uint16*)destbackup, xr*mult, yr*mult, pitchbackup, backshiftr,backshiftl); - else // == 3 - Blit32to24(specbuf32bpp, (uint8*)destbackup, xr*mult, yr*mult, pitchbackup); - } - else - { - // -Video Modes Tag- - if(silt == 4) - hq3x_32((uint8 *)specbuf,destbackup,xr,yr,pitchbackup); - else - hq2x_32((uint8 *)specbuf,destbackup,xr,yr,pitchbackup); - } - } -} diff --git a/branches/fceux-2.2.2/src/drivers/common/vidblit.h b/branches/fceux-2.2.2/src/drivers/common/vidblit.h deleted file mode 100644 index 94c531cf..00000000 --- a/branches/fceux-2.2.2/src/drivers/common/vidblit.h +++ /dev/null @@ -1,29 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int eefx, int specfilt, int specfilteropt); -void SetPaletteBlitToHigh(uint8 *src); -void KillBlitToHigh(void); -void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale); -void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale, int efx, int special); - -void Blit32to24(uint32 *src, uint8 *dest, int xr, int yr, int dpitch); -void Blit32to16(uint32 *src, uint16 *dest, int xr, int yr, int dpitch, - int shiftr[3], int shiftl[3]); diff --git a/branches/fceux-2.2.2/src/drivers/sdl/SConscript b/branches/fceux-2.2.2/src/drivers/sdl/SConscript deleted file mode 100644 index 7a53b077..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/SConscript +++ /dev/null @@ -1,30 +0,0 @@ -# Fix compliation error about 'XKeysymToString' by linking X11 explicitly -# Thanks Antonio Ospite! -Import('env') -config_string = 'pkg-config --cflags --libs x11' -if env['PLATFORM'] == 'darwin': - config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string -env.ParseConfig(config_string) -Export('env') - -source_list = Split( - """ - input.cpp - config.cpp - sdl.cpp - sdl-joystick.cpp - sdl-sound.cpp - sdl-throttle.cpp - sdl-video.cpp - unix-netplay.cpp - """) - -Import('env') -if 'GL' in env['LIBS']: - source_list.append('sdl-opengl.cpp') - -if env['GTK'] or env['GTK3']: - source_list.append('gui.cpp') - -source_list = ['drivers/sdl/' + source for source in source_list] -Return('source_list') diff --git a/branches/fceux-2.2.2/src/drivers/sdl/config.cpp b/branches/fceux-2.2.2/src/drivers/sdl/config.cpp deleted file mode 100644 index 0dbb2a92..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/config.cpp +++ /dev/null @@ -1,441 +0,0 @@ -#include "main.h" -#include "throttle.h" -#include "config.h" - -#include "../common/cheat.h" - -#include "input.h" -#include "dface.h" - -#include "sdl.h" -#include "sdl-video.h" -#include "unix-netplay.h" - -#ifdef WIN32 -#include -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * Read a custom pallete from a file and load it into the core. - */ -int -LoadCPalette(const std::string &file) -{ - uint8 tmpp[192]; - FILE *fp; - - if(!(fp = FCEUD_UTF8fopen(file.c_str(), "rb"))) { - char errorMsg[256]; - strcpy(errorMsg, "Error loading custom palette from file: "); - strcat(errorMsg, file.c_str()); - FCEUD_PrintError(errorMsg); - return 0; - } - size_t result = fread(tmpp, 1, 192, fp); - if(result != 192) { - char errorMsg[256]; - strcpy(errorMsg, "Error loading custom palette from file: "); - strcat(errorMsg, file.c_str()); - FCEUD_PrintError(errorMsg); - return 0; - } - FCEUI_SetPaletteArray(tmpp); - fclose(fp); - return 1; -} - -/** - * Creates the subdirectories used for saving snapshots, movies, game - * saves, etc. Hopefully obsolete with new configuration system. - */ -static void -CreateDirs(const std::string &dir) -{ - char *subs[8]={"fcs","snaps","gameinfo","sav","cheats","movies","cfg.d"}; - std::string subdir; - int x; - -#if defined(WIN32) || defined(NEED_MINGW_HACKS) - mkdir(dir.c_str()); - chmod(dir.c_str(), 755); - for(x = 0; x < 6; x++) { - subdir = dir + PSS + subs[x]; - mkdir(subdir.c_str()); - } -#else - mkdir(dir.c_str(), S_IRWXU); - for(x = 0; x < 6; x++) { - subdir = dir + PSS + subs[x]; - mkdir(subdir.c_str(), S_IRWXU); - } -#endif -} - -/** - * Attempts to locate FCEU's application directory. This will - * hopefully become obsolete once the new configuration system is in - * place. - */ -static void -GetBaseDirectory(std::string &dir) -{ - char *home = getenv("HOME"); - if(home) { - dir = std::string(home) + "/.fceux"; - } else { -#ifdef WIN32 - home = new char[MAX_PATH + 1]; - GetModuleFileName(NULL, home, MAX_PATH + 1); - - char *lastBS = strrchr(home,'\\'); - if(lastBS) { - *lastBS = 0; - } - - dir = std::string(home); - delete[] home; -#else - dir = ""; -#endif - } -} - -// returns a config structure with default options -// also creates config base directory (ie: /home/user/.fceux as well as subdirs -Config * -InitConfig() -{ - std::string dir, prefix; - Config *config; - - GetBaseDirectory(dir); - - FCEUI_SetBaseDirectory(dir.c_str()); - CreateDirs(dir); - - config = new Config(dir); - - // sound options - config->addOption('s', "sound", "SDL.Sound", 1); - config->addOption("volume", "SDL.Sound.Volume", 150); - config->addOption("trianglevol", "SDL.Sound.TriangleVolume", 256); - config->addOption("square1vol", "SDL.Sound.Square1Volume", 256); - config->addOption("square2vol", "SDL.Sound.Square2Volume", 256); - config->addOption("noisevol", "SDL.Sound.NoiseVolume", 256); - config->addOption("pcmvol", "SDL.Sound.PCMVolume", 256); - config->addOption("soundrate", "SDL.Sound.Rate", 44100); - config->addOption("soundq", "SDL.Sound.Quality", 1); - config->addOption("soundrecord", "SDL.Sound.RecordFile", ""); - config->addOption("soundbufsize", "SDL.Sound.BufSize", 128); - config->addOption("lowpass", "SDL.Sound.LowPass", 0); - - config->addOption('g', "gamegenie", "SDL.GameGenie", 0); - config->addOption("pal", "SDL.PAL", 0); - config->addOption("frameskip", "SDL.Frameskip", 0); - config->addOption("clipsides", "SDL.ClipSides", 0); - config->addOption("nospritelim", "SDL.DisableSpriteLimit", 1); - - // color control - config->addOption('p', "palette", "SDL.Palette", ""); - config->addOption("tint", "SDL.Tint", 56); - config->addOption("hue", "SDL.Hue", 72); - config->addOption("ntsccolor", "SDL.NTSCpalette", 0); - - // scanline settings - config->addOption("slstart", "SDL.ScanLineStart", 0); - config->addOption("slend", "SDL.ScanLineEnd", 239); - - // video controls - config->addOption('f', "fullscreen", "SDL.Fullscreen", 0); - - // set x/y res to 0 for automatic fullscreen resolution detection (no change) - config->addOption('x', "xres", "SDL.XResolution", 0); - config->addOption('y', "yres", "SDL.YResolution", 0); - config->addOption("SDL.LastXRes", 0); - config->addOption("SDL.LastYRes", 0); - config->addOption('b', "bpp", "SDL.BitsPerPixel", 32); - config->addOption("doublebuf", "SDL.DoubleBuffering", 0); - config->addOption("autoscale", "SDL.AutoScale", 1); - config->addOption("keepratio", "SDL.KeepRatio", 1); - config->addOption("xscale", "SDL.XScale", 1.0); - config->addOption("yscale", "SDL.YScale", 1.0); - config->addOption("xstretch", "SDL.XStretch", 0); - config->addOption("ystretch", "SDL.YStretch", 0); - config->addOption("noframe", "SDL.NoFrame", 0); - config->addOption("special", "SDL.SpecialFilter", 0); - config->addOption("showfps", "SDL.ShowFPS", 0); - - // OpenGL options - config->addOption("opengl", "SDL.OpenGL", 0); - config->addOption("openglip", "SDL.OpenGLip", 0); - config->addOption("SDL.SpecialFilter", 0); - config->addOption("SDL.SpecialFX", 0); - config->addOption("SDL.Vsync", 1); - - // network play options - netplay is broken - config->addOption("server", "SDL.NetworkIsServer", 0); - config->addOption('n', "net", "SDL.NetworkIP", ""); - config->addOption('u', "user", "SDL.NetworkUsername", ""); - config->addOption('w', "pass", "SDL.NetworkPassword", ""); - config->addOption('k', "netkey", "SDL.NetworkGameKey", ""); - config->addOption("port", "SDL.NetworkPort", 4046); - config->addOption("players", "SDL.NetworkPlayers", 1); - - // input configuration options - config->addOption("input1", "SDL.Input.0", "GamePad.0"); - config->addOption("input2", "SDL.Input.1", "GamePad.1"); - config->addOption("input3", "SDL.Input.2", "Gamepad.2"); - config->addOption("input4", "SDL.Input.3", "Gamepad.3"); - - // allow for input configuration - config->addOption('i', "inputcfg", "SDL.InputCfg", InputCfg); - - // display input - config->addOption("inputdisplay", "SDL.InputDisplay", 0); - - // enable / disable opposite directionals (left + right or up + down simultaneously) - config->addOption("opposite-directionals", "SDL.Input.EnableOppositeDirectionals", 1); - - // pause movie playback at frame x - config->addOption("pauseframe", "SDL.PauseFrame", 0); - config->addOption("recordhud", "SDL.RecordHUD", 1); - config->addOption("moviemsg", "SDL.MovieMsg", 1); - - // overwrite the config file? - config->addOption("no-config", "SDL.NoConfig", 0); - - config->addOption("autoresume", "SDL.AutoResume", 0); - - // video playback - config->addOption("playmov", "SDL.Movie", ""); - config->addOption("subtitles", "SDL.SubtitleDisplay", 1); - - config->addOption("fourscore", "SDL.FourScore", 0); - - config->addOption("nofscursor", "SDL.NoFullscreenCursor", 1); - - #ifdef _S9XLUA_H - // load lua script - config->addOption("loadlua", "SDL.LuaScript", ""); - #endif - - #ifdef CREATE_AVI - config->addOption("videolog", "SDL.VideoLog", ""); - config->addOption("mute", "SDL.MuteCapture", 0); - #endif - - // auto load/save on gameload/close - config->addOption("loadstate", "SDL.AutoLoadState", INVALID_STATE); - config->addOption("savestate", "SDL.AutoSaveState", INVALID_STATE); - - //TODO implement this - config->addOption("periodicsaves", "SDL.PeriodicSaves", 0); - - - #ifdef _GTK - char* home_dir = getenv("HOME"); - // prefixed with _ because they are internal (not cli options) - config->addOption("_lastopenfile", "SDL.LastOpenFile", home_dir); - config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", home_dir); - config->addOption("_lastopennsf", "SDL.LastOpenNSF", home_dir); - config->addOption("_lastsavestateas", "SDL.LastSaveStateAs", home_dir); - config->addOption("_lastloadlua", "SDL.LastLoadLua", home_dir); - #endif - - // fcm -> fm2 conversion - config->addOption("fcmconvert", "SDL.FCMConvert", ""); - - // fm2 -> srt conversion - config->addOption("ripsubs", "SDL.RipSubs", ""); - - // enable new PPU core - config->addOption("newppu", "SDL.NewPPU", 0); - - // quit when a+b+select+start is pressed - config->addOption("4buttonexit", "SDL.ABStartSelectExit", 0); - - // GamePad 0 - 3 - for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { - char buf[64]; - snprintf(buf, 20, "SDL.Input.GamePad.%d.", i); - prefix = buf; - - config->addOption(prefix + "DeviceType", DefaultGamePadDevice[i]); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < GAMEPAD_NUM_BUTTONS; j++) { - config->addOption(prefix + GamePadNames[j], DefaultGamePad[i][j]); - } - } - - // PowerPad 0 - 1 - for(unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) { - char buf[64]; - snprintf(buf, 20, "SDL.Input.PowerPad.%d.", i); - prefix = buf; - - config->addOption(prefix + "DeviceType", DefaultPowerPadDevice[i]); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < POWERPAD_NUM_BUTTONS; j++) { - config->addOption(prefix +PowerPadNames[j], DefaultPowerPad[i][j]); - } - } - - // QuizKing - prefix = "SDL.Input.QuizKing."; - config->addOption(prefix + "DeviceType", DefaultQuizKingDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < QUIZKING_NUM_BUTTONS; j++) { - config->addOption(prefix + QuizKingNames[j], DefaultQuizKing[j]); - } - - // HyperShot - prefix = "SDL.Input.HyperShot."; - config->addOption(prefix + "DeviceType", DefaultHyperShotDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < HYPERSHOT_NUM_BUTTONS; j++) { - config->addOption(prefix + HyperShotNames[j], DefaultHyperShot[j]); - } - - // Mahjong - prefix = "SDL.Input.Mahjong."; - config->addOption(prefix + "DeviceType", DefaultMahjongDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < MAHJONG_NUM_BUTTONS; j++) { - config->addOption(prefix + MahjongNames[j], DefaultMahjong[j]); - } - - // TopRider - prefix = "SDL.Input.TopRider."; - config->addOption(prefix + "DeviceType", DefaultTopRiderDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < TOPRIDER_NUM_BUTTONS; j++) { - config->addOption(prefix + TopRiderNames[j], DefaultTopRider[j]); - } - - // FTrainer - prefix = "SDL.Input.FTrainer."; - config->addOption(prefix + "DeviceType", DefaultFTrainerDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < FTRAINER_NUM_BUTTONS; j++) { - config->addOption(prefix + FTrainerNames[j], DefaultFTrainer[j]); - } - - // FamilyKeyBoard - prefix = "SDL.Input.FamilyKeyBoard."; - config->addOption(prefix + "DeviceType", DefaultFamilyKeyBoardDevice); - config->addOption(prefix + "DeviceNum", 0); - for(unsigned int j = 0; j < FAMILYKEYBOARD_NUM_BUTTONS; j++) { - config->addOption(prefix + FamilyKeyBoardNames[j], - DefaultFamilyKeyBoard[j]); - } - - // for FAMICOM microphone in pad 2 pad 1 didn't have it - // Takeshi no Chousenjou uses it for example. - prefix = "SDL.Input.FamicomPad2."; - config->addOption("rp2mic", prefix + "EnableMic", 0); - - // TODO: use a better data structure to store the hotkeys or something - // improve this code overall in the future to make it - // easier to maintain - const int Hotkeys[HK_MAX] = { - SDLK_F1, // cheat menu - SDLK_F2, // bind state - SDLK_F3, // load lua - SDLK_F4, // toggleBG - SDLK_F5, // save state - SDLK_F6, // fds select - SDLK_F7, // load state - SDLK_F8, // fds eject - SDLK_F6, // VS insert coin - SDLK_F8, // VS toggle dipswitch - SDLK_PERIOD, // toggle frame display - SDLK_F10, // toggle subtitle - SDLK_F11, // reset - SDLK_F12, // screenshot - SDLK_PAUSE, // pause - SDLK_MINUS, // speed++ - SDLK_EQUALS, // speed-- - SDLK_BACKSLASH, //frame advnace - SDLK_TAB, // turbo - SDLK_COMMA, // toggle input display - SDLK_q, // toggle movie RW - SDLK_QUOTE, // toggle mute capture - 0, // quit // edit 10/11/11 - don't map to escape, it causes ugly things to happen to sdl. can be manually appended to config - SDLK_DELETE, // frame advance lag skip - SDLK_SLASH, // lag counter display - SDLK_0, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, - SDLK_6, SDLK_7, SDLK_8, SDLK_9, - SDLK_PAGEUP, // select state next - SDLK_PAGEDOWN}; // select state prev - - prefix = "SDL.Hotkeys."; - for(int i=0; i < HK_MAX; i++) - config->addOption(prefix + HotkeyStrings[i], Hotkeys[i]); - // All mouse devices - config->addOption("SDL.OekaKids.0.DeviceType", "Mouse"); - config->addOption("SDL.OekaKids.0.DeviceNum", 0); - - config->addOption("SDL.Arkanoid.0.DeviceType", "Mouse"); - config->addOption("SDL.Arkanoid.0.DeviceNum", 0); - - config->addOption("SDL.Shadow.0.DeviceType", "Mouse"); - config->addOption("SDL.Shadow.0.DeviceNum", 0); - - config->addOption("SDL.Zapper.0.DeviceType", "Mouse"); - config->addOption("SDL.Zapper.0.DeviceNum", 0); - - return config; -} - -void -UpdateEMUCore(Config *config) -{ - int ntsccol, ntsctint, ntschue, flag, start, end; - std::string cpalette; - - config->getOption("SDL.NTSCpalette", &ntsccol); - config->getOption("SDL.Tint", &ntsctint); - config->getOption("SDL.Hue", &ntschue); - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - - config->getOption("SDL.Palette", &cpalette); - if(cpalette.size()) { - LoadCPalette(cpalette); - } - - config->getOption("SDL.PAL", &flag); - FCEUI_SetVidSystem(flag ? 1 : 0); - - config->getOption("SDL.GameGenie", &flag); - FCEUI_SetGameGenie(flag ? 1 : 0); - - config->getOption("SDL.Sound.LowPass", &flag); - FCEUI_SetLowPass(flag ? 1 : 0); - - config->getOption("SDL.DisableSpriteLimit", &flag); - FCEUI_DisableSpriteLimitation(flag ? 1 : 0); - - config->getOption("SDL.ScanLineStart", &start); - config->getOption("SDL.ScanLineEnd", &end); - -#if DOING_SCANLINE_CHECKS - for(int i = 0; i < 2; x++) { - if(srendlinev[x]<0 || srendlinev[x]>239) srendlinev[x]=0; - if(erendlinev[x]239) erendlinev[x]=239; - } -#endif - - FCEUI_SetRenderedLines(start + 8, end - 8, start, end); -} - diff --git a/branches/fceux-2.2.2/src/drivers/sdl/config.h b/branches/fceux-2.2.2/src/drivers/sdl/config.h deleted file mode 100644 index aa4f09e0..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/config.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CONFIG_H_HF128 -#define CONFIG_H_HF128 - -#include "../common/configSys.h" - -Config *InitConfig(void); -void UpdateEMUCore(Config *); -int LoadCPalette(const std::string &file); - -// hotkey definitions -// TODO: encapsulate this in an improved data structure -enum HOTKEY { HK_CHEAT_MENU=0, HK_BIND_STATE, HK_LOAD_LUA, HK_TOGGLE_BG, - HK_SAVE_STATE, HK_FDS_SELECT, HK_LOAD_STATE, HK_FDS_EJECT , - HK_VS_INSERT_COIN, HK_VS_TOGGLE_DIPSWITCH, - HK_TOGGLE_FRAME_DISPLAY, HK_TOGGLE_SUBTITLE, HK_RESET, HK_SCREENSHOT, - HK_PAUSE, HK_DECREASE_SPEED, HK_INCREASE_SPEED, HK_FRAME_ADVANCE, HK_TURBO, - HK_TOGGLE_INPUT_DISPLAY, HK_MOVIE_TOGGLE_RW, HK_MUTE_CAPTURE, HK_QUIT, - HK_FA_LAG_SKIP, HK_LAG_COUNTER_DISPLAY, - HK_SELECT_STATE_0, HK_SELECT_STATE_1, HK_SELECT_STATE_2, HK_SELECT_STATE_3, - HK_SELECT_STATE_4, HK_SELECT_STATE_5, HK_SELECT_STATE_6, HK_SELECT_STATE_7, - HK_SELECT_STATE_8, HK_SELECT_STATE_9, - HK_SELECT_STATE_NEXT, HK_SELECT_STATE_PREV, HK_MAX}; - - -static const char* HotkeyStrings[HK_MAX] = { - "CheatMenu", - "BindState", - "LoadLua", - "ToggleBG", - "SaveState", - "FDSSelect", - "LoadState", - "FDSEject", - "VSInsertCoin", - "VSToggleDip", - "MovieToggleFrameDisplay", - "SubtitleDisplay", - "Reset", - "Screenshot", - "Pause", - "DecreaseSpeed", - "IncreaseSpeed", - "FrameAdvance", - "Turbo", - "ToggleInputDisplay", - "ToggleMovieRW", - "MuteCapture", - "Quit", - "FrameAdvanceLagSkip", - "LagCounterDisplay", - "SelectState0", "SelectState1", "SelectState2", "SelectState3", - "SelectState4", "SelectState5", "SelectState6", "SelectState7", - "SelectState8", "SelectState9", "SelectStateNext", "SelectStatePrev" }; -#endif - diff --git a/branches/fceux-2.2.2/src/drivers/sdl/gui.cpp b/branches/fceux-2.2.2/src/drivers/sdl/gui.cpp deleted file mode 100644 index 98d4471a..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/gui.cpp +++ /dev/null @@ -1,2535 +0,0 @@ -#include "../../types.h" -#include "../../fceu.h" -#include "../../driver.h" -#include "../../version.h" -#include "../../movie.h" -#include "../../palette.h" -#include "../../fds.h" -#include "../common/configSys.h" - -#include "sdl.h" -#include "gui.h" -#include "dface.h" -#include "input.h" -#include "config.h" -#include "icon.xpm" - -#ifdef _S9XLUA_H -#include "../../fceulua.h" -#endif - -#include -#include -#include - -#ifdef _GTK3 -#include -#endif - -#include -#include -#include - -// Fix compliation errors for older version of GTK (Ubuntu 10.04 LTS) -#if GTK_MINOR_VERSION < 24 && GTK_MAJOR_VERSION == 2 - #define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX - #define gtk_combo_box_text_new gtk_combo_box_new - #define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text - #define gtk_combo_box_text_append_text gtk_combo_box_append_text -#endif - -void toggleSound(GtkWidget* check, gpointer data); -void loadGame (); -void closeGame(); -extern Config *g_config; - -GtkWidget* MainWindow = NULL; -GtkWidget* evbox = NULL; -GtkWidget* padNoCombo = NULL; -GtkWidget* configNoCombo = NULL; -GtkWidget* buttonMappings[10]; -GtkRadioAction* stateSlot = NULL; -bool gtkIsStarted = false; - -// check to see if a particular GTK version is available -// 2.24 is required for most of the dialogs -- ie: checkGTKVersion(2,24); -bool checkGTKVersion(int major_required, int minor_required) -{ - int major = GTK_MAJOR_VERSION; - int minor = GTK_MINOR_VERSION; - - if(major > major_required) - { - return true; - } else if (major == major_required) - { - if(minor >= minor_required) - { - return true; - } - else - { - return false; - } - } else - { - return false; - } -} - -// This function configures a single hotkey -int configHotkey(char* hotkeyString) -{ - SDL_Surface *screen; - SDL_Event event; - KillVideo(); -#if SDL_VERSION_ATLEAST(2, 0, 0) - return 0; // TODO - SDL 2.0 -#else - screen = SDL_SetVideoMode(420, 200, 8, 0); - //SDL_WM_SetCaption("Press a key to bind...", 0); - - int newkey = 0; - while(1) - { - SDL_WaitEvent(&event); - - switch (event.type) - { - case SDL_KEYDOWN: - newkey = event.key.keysym.sym; - g_config->setOption(hotkeyString, newkey); - extern FCEUGI *GameInfo; - InitVideo(GameInfo); - return 0; - } - } - - return 0; -#endif -} -// This function configures a single button on a gamepad -int configGamepadButton(GtkButton* button, gpointer p) -{ - gint x = ((gint)(glong)(p)); - //gint x = GPOINTER_TO_INT(p); - int padNo = atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(padNoCombo))) - 1; - int configNo = atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(configNoCombo))) - 1; - - char buf[256]; - std::string prefix; - - // only configure when the "Change" button is pressed in, not when it is unpressed - if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) - return 0; - - ButtonConfigBegin(); - - snprintf(buf, sizeof(buf), "SDL.Input.GamePad.%d", padNo); - prefix = buf; - DWaitButton(NULL, &GamePadConfig[padNo][x], configNo); - - g_config->setOption(prefix + GamePadNames[x], GamePadConfig[padNo][x].ButtonNum[configNo]); - - if(GamePadConfig[padNo][x].ButtType[0] == BUTTC_KEYBOARD) - { - g_config->setOption(prefix + "DeviceType", "Keyboard"); - } else if(GamePadConfig[padNo][x].ButtType[0] == BUTTC_JOYSTICK) { - g_config->setOption(prefix + "DeviceType", "Joystick"); - } else { - g_config->setOption(prefix + "DeviceType", "Unknown"); - } - g_config->setOption(prefix + "DeviceNum", GamePadConfig[padNo][x].DeviceNum[configNo]); - - snprintf(buf, sizeof(buf), "%s", ButtonName(&GamePadConfig[padNo][x], configNo)); - gtk_label_set_markup(GTK_LABEL(buttonMappings[x]), buf); - - ButtonConfigEnd(); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - - return 0; -} - -void resetVideo() -{ - KillVideo(); - InitVideo(GameInfo); -} - -void closeVideoWin(GtkWidget* w, GdkEvent* e, gpointer p) -{ - resetVideo(); - gtk_widget_destroy(w); -} - -void closeDialog(GtkWidget* w, GdkEvent* e, gpointer p) -{ - gtk_widget_destroy(w); -} -void toggleLowPass(GtkWidget* w, gpointer p) -{ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) - { - g_config->setOption("SDL.Sound.LowPass", 1); - FCEUI_SetLowPass(1); - } - else - { - g_config->setOption("SDL.Sound.LowPass", 0); - FCEUI_SetLowPass(0); - } - g_config->save(); -} - -// Wrapper for pushing GTK options into the config file -// p : pointer to the string that names the config option -// w : toggle widget -void toggleOption(GtkWidget* w, gpointer p) -{ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) - g_config->setOption((char*)p, 1); - else - g_config->setOption((char*)p, 0); - - g_config->save(); - UpdateEMUCore(g_config); -} - -int setTint(GtkWidget* w, gpointer p) -{ - int v = gtk_range_get_value(GTK_RANGE(w)); - g_config->setOption("SDL.Tint", v); - g_config->save(); - int c, h; - g_config->getOption("SDL.NTSCpalette", &c); - g_config->getOption("SDL.Hue", &h); - FCEUI_SetNTSCTH(c, v, h); - - return 0; -} -int setHue(GtkWidget* w, gpointer p) -{ - int v = gtk_range_get_value(GTK_RANGE(w)); - g_config->setOption("SDL.Hue", v); - g_config->save(); - int c, t; - g_config->getOption("SDL.Tint", &t); - g_config->getOption("SDL.SDL.NTSCpalette", &c); - FCEUI_SetNTSCTH(c, t, v); - - return 0; -} -void loadPalette (GtkWidget* w, gpointer p) -{ - GtkWidget* fileChooser; - - fileChooser = gtk_file_chooser_dialog_new ("Open NES Palette", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), "/usr/share/fceux/palettes"); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - g_config->setOption("SDL.Palette", filename); - g_config->setOption("SDL.SDL.NTSCpalette", 0); - LoadCPalette(filename); - - gtk_entry_set_text(GTK_ENTRY(p), filename); - - } - gtk_widget_destroy (fileChooser); -} - -void clearPalette(GtkWidget* w, gpointer p) -{ - g_config->setOption("SDL.Palette", 0); - gtk_entry_set_text(GTK_ENTRY(p), ""); -} - -void openPaletteConfig() -{ - GtkWidget* win; - GtkWidget* vbox; - GtkWidget* paletteFrame; - GtkWidget* paletteHbox; - GtkWidget* paletteButton; - GtkWidget* paletteEntry; - GtkWidget* clearButton; - GtkWidget* ntscColorChk; - GtkWidget* slidersFrame; - GtkWidget* slidersVbox; - GtkWidget* tintFrame; - GtkWidget* tintHscale; - GtkWidget* hueFrame; - GtkWidget* hueHscale; - - win = gtk_dialog_new_with_buttons("Palette Options", - GTK_WINDOW(MainWindow), - (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CLOSE, - GTK_RESPONSE_OK, - NULL); - gtk_window_set_icon_name(GTK_WINDOW(win), GTK_STOCK_SELECT_COLOR); - vbox = gtk_dialog_get_content_area(GTK_DIALOG(win)); - - paletteFrame = gtk_frame_new("Custom palette: "); - paletteHbox = gtk_hbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(paletteHbox), 5); - gtk_container_add(GTK_CONTAINER(paletteFrame), paletteHbox); - paletteButton = gtk_button_new_from_stock(GTK_STOCK_OPEN); - gtk_button_set_label(GTK_BUTTON(paletteButton), "Open palette"); - paletteEntry = gtk_entry_new(); - gtk_editable_set_editable(GTK_EDITABLE(paletteEntry), FALSE); - - clearButton = gtk_button_new_from_stock(GTK_STOCK_CLEAR); - - gtk_box_pack_start(GTK_BOX(paletteHbox), paletteButton, FALSE, FALSE, 2); - gtk_box_pack_start(GTK_BOX(paletteHbox), paletteEntry, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(paletteHbox), clearButton, FALSE, FALSE, 0); - - g_signal_connect(paletteButton, "clicked", G_CALLBACK(loadPalette), paletteEntry); - g_signal_connect(clearButton, "clicked", G_CALLBACK(clearPalette), paletteEntry); - - // sync with config - std::string fn; - g_config->getOption("SDL.Palette", &fn); - gtk_entry_set_text(GTK_ENTRY(paletteEntry), fn.c_str()); - - // ntsc color check - ntscColorChk = gtk_check_button_new_with_label("Use NTSC palette"); - - g_signal_connect(ntscColorChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.NTSCpalette"); - - int b; - // sync with config - g_config->getOption("SDL.NTSCpalette", &b); - if(b) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ntscColorChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ntscColorChk), 0); - - // color / tint / hue sliders - slidersFrame = gtk_frame_new("NTSC palette controls"); - slidersVbox = gtk_vbox_new(FALSE, 2); - tintFrame = gtk_frame_new("Tint"); - tintHscale = gtk_hscale_new_with_range(0, 128, 1); - gtk_container_add(GTK_CONTAINER(tintFrame), tintHscale); - hueFrame = gtk_frame_new("Hue"); - hueHscale = gtk_hscale_new_with_range(0, 128, 1); - gtk_container_add(GTK_CONTAINER(hueFrame), hueHscale); - - g_signal_connect(tintHscale, "button-release-event", G_CALLBACK(setTint), NULL); - g_signal_connect(hueHscale, "button-release-event", G_CALLBACK(setHue), NULL); - - // sync with config - int h, t; - g_config->getOption("SDL.Hue", &h); - g_config->getOption("SDL.Tint", &t); - - gtk_range_set_value(GTK_RANGE(hueHscale), h); - gtk_range_set_value(GTK_RANGE(tintHscale), t); - - gtk_container_add(GTK_CONTAINER(slidersFrame), slidersVbox); - gtk_box_pack_start(GTK_BOX(slidersVbox), ntscColorChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(slidersVbox), tintFrame, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(slidersVbox), hueFrame, FALSE, TRUE, 5); - - gtk_box_pack_start(GTK_BOX(vbox), paletteFrame, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), slidersFrame, FALSE, TRUE, 5); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); - g_signal_connect(win, "response", G_CALLBACK(closeDialog), NULL); - - gtk_widget_show_all(win); - - return; -} - - -GtkWidget* ipEntry; -GtkWidget* portSpin; -GtkWidget* pwEntry; - -void launchNet(GtkWidget* w, gpointer p) -{ - char* ip = (char*)gtk_entry_get_text(GTK_ENTRY(ipEntry)); - char* pw = (char*)gtk_entry_get_text(GTK_ENTRY(pwEntry)); - int port = (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(portSpin)); - - g_config->setOption("SDL.NetworkIP", ip); - g_config->setOption("SDL.NetworkPassword", pw); - g_config->setOption("SDL.NetworkPort", port); - - gtk_widget_destroy(GTK_WIDGET(w)); - - loadGame(); -} - -void setUsername(GtkWidget* w, gpointer p) -{ - char* s = (char*)gtk_entry_get_text(GTK_ENTRY(w)); - g_config->setOption("SDL.NetworkUsername", s); -} - -void netResponse(GtkWidget* w, gint response_id, gpointer p) -{ - if(response_id == GTK_RESPONSE_OK) - launchNet(w, p); - else - gtk_widget_destroy(w); -} - -void openNetworkConfig() -{ - GtkWidget* win; - GtkWidget* box; - GtkWidget* userBox; - GtkWidget* userEntry; - GtkWidget* userLbl; - GtkWidget* frame; - GtkWidget* vbox; - GtkWidget* ipBox; - GtkWidget* ipLbl; - - GtkWidget* portBox; - GtkWidget* portLbl; - - //GtkWidget* localPlayersCbo; - GtkWidget* pwBox; - GtkWidget* pwLbl; - - win = gtk_dialog_new_with_buttons("Network Options",GTK_WINDOW(MainWindow), (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_CONNECT, GTK_RESPONSE_OK, NULL); - gtk_window_set_icon_name(GTK_WINDOW(win), GTK_STOCK_NETWORK); - box = gtk_dialog_get_content_area(GTK_DIALOG(win)); - - userBox = gtk_hbox_new(FALSE, 3); - userLbl = gtk_label_new("Username:"); - userEntry = gtk_entry_new(); - std::string s; - g_config->getOption("SDL.NetworkUsername", &s); - gtk_entry_set_text(GTK_ENTRY(userEntry), s.c_str()); - - g_signal_connect(userEntry, "changed", G_CALLBACK(setUsername), NULL); - - frame = gtk_frame_new("Network options"); - vbox = gtk_vbox_new(FALSE, 5); - ipBox = gtk_hbox_new(FALSE, 5); - ipLbl = gtk_label_new("Server IP:"); - ipEntry = gtk_entry_new(); - portBox = gtk_hbox_new(FALSE, 5); - portLbl = gtk_label_new("Server port:"); - portSpin = gtk_spin_button_new_with_range(0, 999999, 1); - //localPlayersCbo = gtk_combo_box_new_text(); - pwBox = gtk_hbox_new(FALSE, 3); - pwLbl = gtk_label_new("Server password:"); - pwEntry = gtk_entry_new(); - - gtk_spin_button_set_value(GTK_SPIN_BUTTON(portSpin), 4046); - - gtk_box_pack_start(GTK_BOX(userBox), userLbl, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(userBox), userEntry, TRUE , TRUE, 3); - - gtk_box_pack_start(GTK_BOX(portBox), portLbl, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(portBox), portSpin, FALSE , FALSE, 3); - - gtk_box_pack_start(GTK_BOX(ipBox), ipLbl, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(ipBox), ipEntry, TRUE , TRUE, 3); - - gtk_box_pack_start(GTK_BOX(pwBox), pwLbl, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(pwBox), pwEntry, TRUE , TRUE, 3); - - gtk_box_pack_start(GTK_BOX(vbox), ipBox, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(vbox), portBox, FALSE, FALSE, 3); - //gtk_box_pack_start_defaults(GTK_BOX(vbox), localPlayersCbo); - gtk_box_pack_start(GTK_BOX(vbox), pwBox, FALSE, FALSE, 3); - - gtk_container_add(GTK_CONTAINER(frame), vbox); - - gtk_box_pack_start(GTK_BOX(box), userBox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0); - - gtk_widget_show_all(win); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); - g_signal_connect(win, "response", G_CALLBACK(netResponse), NULL); -} - -// handler prototype -static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data); - -void flushGtkEvents() -{ - while (gtk_events_pending ()) - gtk_main_iteration_do (FALSE); - - return; -} - -GtkWidget* HotkeyWin; - -// creates and opens hotkey config window -void openHotkeyConfig() -{ - enum - { - COMMAND_COLUMN, - KEY_COLUMN, - N_COLUMNS - }; - GtkWidget* win = gtk_dialog_new_with_buttons("Hotkey Configuration", - GTK_WINDOW(MainWindow), (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CLOSE, - GTK_RESPONSE_OK, - NULL); - gtk_window_set_default_size(GTK_WINDOW(win), 400, 800); - HotkeyWin = win; - GtkWidget *tree; - GtkWidget *vbox; - GtkWidget *scroll; - - - - vbox = gtk_dialog_get_content_area(GTK_DIALOG(win)); - - GtkTreeStore *hotkey_store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); - - std::string prefix = "SDL.Hotkeys."; - GtkTreeIter iter; // parent - GtkTreeIter iter2; // child - - gtk_tree_store_append(hotkey_store, &iter, NULL); // aquire iter - - int keycode; - for(int i=0; igetOption(optionName, &keycode); - gtk_tree_store_set(hotkey_store, &iter, - COMMAND_COLUMN, optionName, - KEY_COLUMN, -#if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_GetKeyName(keycode), -#else - SDL_GetKeyName((SDLKey)keycode), -#endif - -1); - gtk_tree_store_append(hotkey_store, &iter, NULL); // acquire child iterator - } - - tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(hotkey_store)); - GtkCellRenderer *renderer; - GtkTreeViewColumn* column; - - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes("Command", renderer, "text", COMMAND_COLUMN, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); - column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", KEY_COLUMN, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); - scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(scroll), tree); - gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 5); - gtk_widget_show_all(win); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); - g_signal_connect(win, "response", G_CALLBACK(closeDialog), NULL); - - GtkTreeSelection *select; - - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)); - gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); - g_signal_connect ( G_OBJECT (select), "changed", G_CALLBACK (tree_selection_changed_cb), - NULL); - gtk_tree_selection_unselect_all (select); -} - -static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data) -{ - GtkTreeIter iter; - GtkTreeModel *model; - char* hotkey; - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, 0, &hotkey, -1); - - gtk_widget_hide(HotkeyWin); - - flushGtkEvents(); - - configHotkey(hotkey); - - g_signal_emit_by_name(HotkeyWin, "destroy-event"); - - openHotkeyConfig(); - - g_free (hotkey); - - } -} - -GtkWidget* typeCombo; - -// TODO: finish this -int setInputDevice(GtkWidget* w, gpointer p) -{ - std::string s = "SDL.Input."; - s = s + (char*)p; - printf("%s", s.c_str()); - g_config->setOption(s, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(typeCombo))); - g_config->save(); - - return 1; -} - -void updateGamepadConfig(GtkWidget* w, gpointer p) -{ - int i; - char strBuf[128]; - int padNo = atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(padNoCombo))) - 1; - int configNo = atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(configNoCombo))) - 1; - - for(i=0; i<10; i++) - { - GtkWidget* mappedKey = buttonMappings[i]; - if(GamePadConfig[padNo][i].ButtType[configNo] == BUTTC_KEYBOARD) - { -#if SDL_VERSION_ATLEAST(2, 0, 0) - snprintf(strBuf, sizeof(strBuf), "%s", - SDL_GetKeyName(GamePadConfig[padNo][i].ButtonNum[configNo])); -#else - snprintf(strBuf, sizeof(strBuf), "%s", - SDL_GetKeyName((SDLKey)GamePadConfig[padNo][i].ButtonNum[configNo])); -#endif - } - else // FIXME: display joystick button/hat/axis names properly - strncpy(strBuf, "Joystick", sizeof(strBuf)); - - gtk_label_set_text(GTK_LABEL(mappedKey), strBuf); - gtk_label_set_use_markup(GTK_LABEL(mappedKey), TRUE); - } -} - -// creates and opens the gamepad config window (requires GTK 2.24) -void openGamepadConfig() -{ - // GTK 2.24 required for this dialog - if (checkGTKVersion(2, 24) == false) - { - // TODO: present this in a GTK MessageBox? - printf(" Warning: GTK >= 2.24 required for this dialog.\nTo configure the gamepads, use \"--inputcfg\" from the command line (ie: \"fceux --inputcfg gamepad1\").\n"); - return; - } - - GtkWidget* win; - GtkWidget* vbox; - GtkWidget* hboxPadNo; - GtkWidget* padNoLabel; - GtkWidget* configNoLabel; - GtkWidget* fourScoreChk; - GtkWidget* oppositeDirChk; - GtkWidget* buttonFrame; - GtkWidget* buttonTable; - - win = gtk_dialog_new_with_buttons("Controller Configuration", - GTK_WINDOW(MainWindow), - (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CLOSE, - GTK_RESPONSE_OK, - NULL); - gtk_window_set_title(GTK_WINDOW(win), "Controller Configuration"); - gtk_window_set_icon_name(GTK_WINDOW(win), "input-gaming"); - gtk_widget_set_size_request(win, 350, 500); - - vbox = gtk_dialog_get_content_area(GTK_DIALOG(win)); - gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); - - hboxPadNo = gtk_hbox_new(FALSE, 0); - padNoLabel = gtk_label_new("Port:"); - configNoLabel = gtk_label_new("Config Number:"); - fourScoreChk = gtk_check_button_new_with_label("Enable Four Score"); - oppositeDirChk = gtk_check_button_new_with_label("Allow Up+Down / Left+Right"); - - typeCombo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(typeCombo), "gamepad"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(typeCombo), "zapper"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(typeCombo), "powerpad.0"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(typeCombo), "powerpad.1"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(typeCombo), "arkanoid"); - - gtk_combo_box_set_active(GTK_COMBO_BOX(typeCombo), 0); - - - padNoCombo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(padNoCombo), "1"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(padNoCombo), "2"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(padNoCombo), "3"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(padNoCombo), "4"); - gtk_combo_box_set_active(GTK_COMBO_BOX(padNoCombo), 0); - g_signal_connect(padNoCombo, "changed", G_CALLBACK(updateGamepadConfig), NULL); - - configNoCombo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(configNoCombo), "1"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(configNoCombo), "2"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(configNoCombo), "3"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(configNoCombo), "4"); - gtk_combo_box_set_active(GTK_COMBO_BOX(configNoCombo), 0); - g_signal_connect(padNoCombo, "changed", G_CALLBACK(updateGamepadConfig), NULL); - - - g_signal_connect(typeCombo, "changed", G_CALLBACK(setInputDevice), - gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(typeCombo))); - - // sync with config - int buf = 0; - g_config->getOption("SDL.FourScore", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fourScoreChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fourScoreChk), 0); - g_config->getOption("SDL.Input.EnableOppositeDirectionals", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oppositeDirChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oppositeDirChk), 0); - - g_signal_connect(fourScoreChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.FourScore"); - g_signal_connect(oppositeDirChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.Input.EnableOppositeDirectionals"); - - gtk_box_pack_start(GTK_BOX(hboxPadNo), padNoLabel, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(hboxPadNo), padNoCombo, TRUE, TRUE, 5); - //gtk_box_pack_start(GTK_BOX(hboxPadNo), configNoLabel, TRUE, TRUE, 5); - //gtk_box_pack_start(GTK_BOX(hboxPadNo), configNoCombo, TRUE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hboxPadNo, FALSE, TRUE, 5); - //gtk_box_pack_start_defaults(GTK_BOX(vbox), typeCombo); - - gtk_box_pack_start(GTK_BOX(vbox), fourScoreChk, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), oppositeDirChk, FALSE, TRUE, 5); - - - // create gamepad buttons - buttonFrame = gtk_frame_new("Buttons"); - gtk_label_set_use_markup(GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(buttonFrame))), TRUE); - buttonTable = gtk_table_new(10, 3, FALSE); - gtk_table_set_col_spacings(GTK_TABLE(buttonTable), 5); - gtk_container_add(GTK_CONTAINER(buttonFrame), buttonTable); - for(int i=0; i<10; i++) - { - GtkWidget* buttonName = gtk_label_new(GamePadNames[i]); - GtkWidget* mappedKey = gtk_label_new(NULL); - GtkWidget* changeButton = gtk_toggle_button_new(); - char strBuf[128]; - - sprintf(strBuf, "%s:", GamePadNames[i]); - gtk_label_set_text(GTK_LABEL(buttonName), strBuf); - gtk_misc_set_alignment(GTK_MISC(buttonName), 1.0, 0.5); - - gtk_misc_set_alignment(GTK_MISC(mappedKey), 0.0, 0.5); - - gtk_button_set_label(GTK_BUTTON(changeButton), "Change"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(changeButton), FALSE); - - gtk_table_attach(GTK_TABLE(buttonTable), buttonName, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach(GTK_TABLE(buttonTable), mappedKey, 1, 2, i, i+1, - (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), 0, 0); - gtk_table_attach(GTK_TABLE(buttonTable), changeButton, 2, 3, i, i+1, - (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); - - g_signal_connect(changeButton, "clicked", G_CALLBACK(configGamepadButton), GINT_TO_POINTER(i)); - buttonMappings[i] = mappedKey; - } - - // display the button mappings for the currently selected configuration - updateGamepadConfig(NULL, NULL); - - gtk_box_pack_start(GTK_BOX(vbox), buttonFrame, TRUE, TRUE, 5); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); - g_signal_connect(win, "response", G_CALLBACK(closeDialog), NULL); - - gtk_widget_show_all(win); - - return; -} - -int setBufSize(GtkWidget* w, gpointer p) -{ - int x = gtk_range_get_value(GTK_RANGE(w)); - g_config->setOption("SDL.Sound.BufSize", x); - // reset sound subsystem for changes to take effect - KillSound(); - InitSound(); - return false; -} - -void setRate(GtkWidget* w, gpointer p) -{ - char* str = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w)); - g_config->setOption("SDL.Sound.Rate", atoi(str)); - // reset sound subsystem for changes to take effect - KillSound(); - InitSound(); - g_config->save(); - return; -} - -void setQuality(GtkWidget* w, gpointer p) -{ - char* str = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w)); - if(!strcmp(str, "Very High")) - g_config->setOption("SDL.Sound.Quality", 2); - if(!strcmp(str, "High")) - g_config->setOption("SDL.Sound.Quality", 1); - if(!strcmp(str, "Low")) - g_config->setOption("SDL.Sound.Quality", 0); - // reset sound subsystem for changes to take effect - KillSound(); - InitSound(); - g_config->save(); - return; -} - -void resizeGtkWindow() -{ - if(GameInfo == 0) - { - double xscale, yscale; - g_config->getOption("SDL.XScale", &xscale); - g_config->getOption("SDL.YScale", &yscale); - gtk_widget_set_size_request(evbox, 256*xscale, 224*yscale); - GtkRequisition req; - gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); - gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); - } - return; -} - -void setScaler(GtkWidget* w, gpointer p) -{ - int x = gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - g_config->setOption("SDL.SpecialFilter", x); - - // 1 - hq2x 2 - Scale2x 3 - NTSC2x 4 - hq3x 5 - Scale3x - if (x >= 1 && x <= 3) - { - g_config->setOption("SDL.XScale", 2.0); - g_config->setOption("SDL.YScale", 2.0); - resizeGtkWindow(); - } - if (x >= 4 && x < 6) - { - g_config->setOption("SDL.XScale", 3.0); - g_config->setOption("SDL.YScale", 3.0); - resizeGtkWindow(); - } - g_config->save(); - -} - - -int setXscale(GtkWidget* w, gpointer p) -{ - double v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); - g_config->setOption("SDL.XScale", v); - g_config->save(); - resizeGtkWindow(); - return 0; -} - -int setYscale(GtkWidget* w, gpointer p) -{ - double v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); - g_config->setOption("SDL.YScale", v); - g_config->save(); - resizeGtkWindow(); - return 0; -} - -#ifdef OPENGL -void setGl(GtkWidget* w, gpointer p) -{ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) - g_config->setOption("SDL.OpenGL", 1); - else - g_config->setOption("SDL.OpenGL", 0); - g_config->save(); -} - -void setDoubleBuffering(GtkWidget* w, gpointer p) -{ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) - g_config->setOption("SDL.DoubleBuffering", 1); - else - g_config->setOption("SDL.DoubleBuffering", 0); - g_config->save(); -} -#endif - -void openVideoConfig() -{ - GtkWidget* win; - GtkWidget* vbox; - GtkWidget* lbl; - GtkWidget* hbox1; - GtkWidget* scalerLbl; - GtkWidget* scalerCombo; - GtkWidget* glChk; - GtkWidget* linearChk; - GtkWidget* dbChk; - GtkWidget* palChk; - GtkWidget* ppuChk; - GtkWidget* spriteLimitChk; - GtkWidget* frameskipChk; - GtkWidget* clipSidesChk; - GtkWidget* xscaleSpin; - GtkWidget* yscaleSpin; - GtkWidget* xscaleLbl; - GtkWidget* yscaleLbl; - GtkWidget* xscaleHbox; - GtkWidget* yscaleHbox; - GtkWidget* showFpsChk; - - win = gtk_dialog_new_with_buttons("Video Preferences", - GTK_WINDOW(MainWindow), - (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_icon_name(GTK_WINDOW(win), "video-display"); - //gtk_widget_set_size_request(win, 250, 250); - - vbox = gtk_dialog_get_content_area(GTK_DIALOG(win)); - - lbl = gtk_label_new("Video options will not take\neffect until the emulator is restarted."); - - // scalar widgets - hbox1 = gtk_hbox_new(FALSE, 3); - scalerLbl = gtk_label_new("Special Scaler: "); - scalerCombo = gtk_combo_box_text_new(); - // -Video Modes Tag- - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "none"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "hq2x"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "scale2x"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "NTSC 2x"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "hq3x"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(scalerCombo), "scale3x"); - - // sync with cfg - int buf; - g_config->getOption("SDL.SpecialFilter", &buf); - gtk_combo_box_set_active(GTK_COMBO_BOX(scalerCombo), buf); - - g_signal_connect(scalerCombo, "changed", G_CALLBACK(setScaler), NULL); - gtk_box_pack_start(GTK_BOX(hbox1), scalerLbl, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox1), scalerCombo, FALSE, FALSE, 5); -#ifdef OPENGL - // openGL check - glChk = gtk_check_button_new_with_label("Enable OpenGL"); - g_signal_connect(glChk, "clicked", G_CALLBACK(setGl), NULL); - - // sync with config - buf = 0; - g_config->getOption("SDL.OpenGL", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glChk), 0); - - // openGL linear filter check - linearChk = gtk_check_button_new_with_label("Enable OpenGL linear filter"); - g_signal_connect(linearChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.OpenGLip"); - - // sync with config - buf = 0; - g_config->getOption("SDL.OpenGLip", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linearChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linearChk), 0); - - // DoubleBuffering check - dbChk = gtk_check_button_new_with_label("Enable double buffering"); - g_signal_connect(dbChk, "clicked", G_CALLBACK(setDoubleBuffering), NULL); - - // sync with config - buf = 0; - g_config->getOption("SDL.DoubleBuffering", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dbChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dbChk), 0); -#endif - - - // PAL check - palChk = gtk_check_button_new_with_label("Enable PAL mode"); - g_signal_connect(palChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.PAL"); - - // sync with config - buf = 0; - g_config->getOption("SDL.PAL", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(palChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(palChk), 0); - - // New PPU check - ppuChk = gtk_check_button_new_with_label("Enable new PPU"); - g_signal_connect(ppuChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.NewPPU"); - - // sync with config - buf = 0; - g_config->getOption("SDL.NewPPU", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppuChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppuChk), 0); - - // "disable 8 sprite limit" check - spriteLimitChk = gtk_check_button_new_with_label("Disable sprite limit"); - g_signal_connect(spriteLimitChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.DisableSpriteLimit"); - - // sync with config - buf = 0; - g_config->getOption("SDL.DisableSpriteLimit", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spriteLimitChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spriteLimitChk), 0); - - // frameskip check - frameskipChk = gtk_check_button_new_with_label("Enable frameskip"); - g_signal_connect(frameskipChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.Frameskip"); - - // sync with config - buf = 0; - g_config->getOption("SDL.Frameskip", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frameskipChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frameskipChk), 0); - - - // clip sides check - clipSidesChk = gtk_check_button_new_with_label("Clip sides"); - g_signal_connect(clipSidesChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.ClipSides"); - - // sync with config - buf = 0; - g_config->getOption("SDL.ClipSides", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clipSidesChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clipSidesChk), 0); - - // xscale / yscale - xscaleHbox = gtk_hbox_new(FALSE, 5); - xscaleLbl = gtk_label_new("X scaling factor"); - xscaleSpin = gtk_spin_button_new_with_range(1.0, 10.0, .1); - yscaleHbox = gtk_hbox_new(FALSE, 5); - yscaleLbl = gtk_label_new("Y scaling factor"); - yscaleSpin = gtk_spin_button_new_with_range(1.0, 10.0, .1); - - gtk_box_pack_start(GTK_BOX(xscaleHbox), xscaleLbl, FALSE, FALSE, 2); - gtk_box_pack_start(GTK_BOX(xscaleHbox), xscaleSpin, FALSE, FALSE, 2); - gtk_box_pack_start(GTK_BOX(yscaleHbox), yscaleLbl, FALSE, FALSE, 2); - gtk_box_pack_start(GTK_BOX(yscaleHbox), yscaleSpin, FALSE, FALSE, 2); - - g_signal_connect(xscaleSpin, "value-changed", G_CALLBACK(setXscale), NULL); - g_signal_connect(yscaleSpin, "value-changed", G_CALLBACK(setYscale), NULL); - - double f; - // sync with config - g_config->getOption("SDL.XScale", &f); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(xscaleSpin), f); - g_config->getOption("SDL.YScale", &f); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(yscaleSpin), f); - - // show FPS check - showFpsChk = gtk_check_button_new_with_label("Show FPS"); - g_signal_connect(showFpsChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.ShowFPS"); - - // sync with config - buf = 0; - g_config->getOption("SDL.ShowFPS", &buf); - if(buf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showFpsChk), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showFpsChk), 0); - - - - gtk_box_pack_start(GTK_BOX(vbox), lbl, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 5); -#ifdef OPENGL - gtk_box_pack_start(GTK_BOX(vbox), glChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), linearChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), dbChk, FALSE, FALSE, 5); -#endif - gtk_box_pack_start(GTK_BOX(vbox), palChk, FALSE, FALSE,5); - gtk_box_pack_start(GTK_BOX(vbox), ppuChk, FALSE, FALSE, 5); -#ifdef FRAMESKIP - gtk_box_pack_start(GTK_BOX(vbox), frameskipChk, FALSE, FALSE, 5); -#endif - gtk_box_pack_start(GTK_BOX(vbox), spriteLimitChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), clipSidesChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), xscaleHbox, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), yscaleHbox, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), showFpsChk, FALSE, FALSE, 5); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeVideoWin), NULL); - g_signal_connect(win, "response", G_CALLBACK(closeVideoWin), NULL); - - gtk_widget_show_all(win); - - return; -} -const char* mixerStrings[6] = {"Volume", "Triangle", "Square1", "Square2", "Noise", "PCM"}; - -int mixerChanged(GtkWidget* w, gpointer p) -{ - int v = gtk_range_get_value(GTK_RANGE(w)); - GtkWidget* parent = gtk_widget_get_parent(w); - char* lbl = (char*)gtk_frame_get_label(GTK_FRAME(parent)); - if(strcmp(lbl, "Volume") == 0) - { - g_config->setOption("SDL.Sound.Volume", v); - FCEUI_SetSoundVolume(v); - } - if(strcmp(lbl, "Triangle") == 0) - { - g_config->setOption("SDL.Sound.TriangleVolume", v); - FCEUI_SetTriangleVolume(v); - } - if(strcmp(lbl, "Square1") == 0) - { - g_config->setOption("SDL.Sound.Square1Volume", v); - FCEUI_SetSquare1Volume(v); - } - if(strcmp(lbl, "Square2") == 0) - { - g_config->setOption("SDL.Sound.Square2Volume", v); - FCEUI_SetSquare2Volume(v); - } - if(strcmp(lbl, "Noise") == 0) - { - g_config->setOption("SDL.Sound.NoiseVolume", v); - FCEUI_SetNoiseVolume(v); - } - if(strcmp(lbl, "PCM") == 0) - { - g_config->setOption("SDL.Sound.PCMVolume", v); - FCEUI_SetPCMVolume(v); - } - - return 0; -} - -void openSoundConfig() -{ - GtkWidget* win; - GtkWidget* main_hbox; - GtkWidget* vbox; - GtkWidget* soundChk; - GtkWidget* lowpassChk; - GtkWidget* hbox1; - GtkWidget* qualityCombo; - GtkWidget* qualityLbl; - GtkWidget* hbox2; - GtkWidget* rateCombo; - GtkWidget* rateLbl; - GtkWidget* hbox3; - GtkWidget* bufferLbl; - GtkWidget* bufferHscale; - GtkWidget* mixerFrame; - GtkWidget* mixerHbox; - GtkWidget* mixers[6]; - GtkWidget* mixerFrames[6]; - - win = gtk_dialog_new_with_buttons("Sound Preferences", - GTK_WINDOW(MainWindow), - (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_CLOSE, - GTK_RESPONSE_OK, - NULL); - gtk_window_set_icon_name(GTK_WINDOW(win), "audio-x-generic"); - main_hbox = gtk_hbox_new(FALSE, 15); - vbox = gtk_vbox_new(False, 5); - - // sound enable check - soundChk = gtk_check_button_new_with_label("Enable sound"); - - // sync with cfg - int cfgBuf; - g_config->getOption("SDL.Sound", &cfgBuf); - if(cfgBuf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(soundChk), TRUE); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(soundChk), FALSE); - - g_signal_connect(soundChk, "clicked", G_CALLBACK(toggleSound), NULL); - - // low pass filter check - lowpassChk = gtk_check_button_new_with_label("Enable low pass filter"); - - // sync with cfg - g_config->getOption("SDL.Sound.LowPass", &cfgBuf); - if(cfgBuf) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lowpassChk), TRUE); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lowpassChk), FALSE); - - g_signal_connect(lowpassChk, "clicked", G_CALLBACK(toggleLowPass), NULL); - - // sound quality combo box - hbox1 = gtk_hbox_new(FALSE, 3); - qualityCombo = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(qualityCombo), "Low"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(qualityCombo), "High"); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(qualityCombo), "Very High"); - - // sync widget with cfg - g_config->getOption("SDL.Sound.Quality", &cfgBuf); - if(cfgBuf == 2) - gtk_combo_box_set_active(GTK_COMBO_BOX(qualityCombo), 2); - else if(cfgBuf == 1) - gtk_combo_box_set_active(GTK_COMBO_BOX(qualityCombo), 1); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(qualityCombo), 0); - - g_signal_connect(qualityCombo, "changed", G_CALLBACK(setQuality), NULL); - - qualityLbl = gtk_label_new("Quality: "); - - gtk_box_pack_start(GTK_BOX(hbox1), qualityLbl, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox1), qualityCombo, FALSE, FALSE, 5); - - // sound rate widgets - hbox2 = gtk_hbox_new(FALSE, 3); - rateCombo = gtk_combo_box_text_new(); - - const int rates[5] = {11025, 22050, 44100, 48000, 96000}; - - char buf[8]; - for(int i=0; i<5;i++) - { - sprintf(buf, "%d", rates[i]); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(rateCombo), buf); - } - - // sync widget with cfg - g_config->getOption("SDL.Sound.Rate", &cfgBuf); - for(int i=0; i<5; i++) - if(cfgBuf == rates[i]) - gtk_combo_box_set_active(GTK_COMBO_BOX(rateCombo), i); - - g_signal_connect(rateCombo, "changed", G_CALLBACK(setRate), NULL); - - // sound rate widgets - rateLbl = gtk_label_new("Rate (Hz): "); - - gtk_box_pack_start(GTK_BOX(hbox2), rateLbl, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox2), rateCombo, FALSE, FALSE, 5); - - hbox3 = gtk_hbox_new(FALSE, 2); - bufferHscale = gtk_hscale_new_with_range(15, 200, 2); - bufferLbl = gtk_label_new("Buffer size (in ms)"); - - // sync widget with cfg - g_config->getOption("SDL.Sound.BufSize", &cfgBuf); - gtk_range_set_value(GTK_RANGE(bufferHscale), cfgBuf); - - g_signal_connect(bufferHscale, "button-release-event", G_CALLBACK(setBufSize), NULL); - - // mixer - mixerFrame = gtk_frame_new("Mixer:"); - mixerHbox = gtk_hbox_new(TRUE, 5); - for(int i=0; i<6; i++) - { - mixers[i] = gtk_vscale_new_with_range(0, 256, 1); - gtk_range_set_inverted(GTK_RANGE(mixers[i]), TRUE); - mixerFrames[i] = gtk_frame_new(mixerStrings[i]); - gtk_container_add(GTK_CONTAINER(mixerFrames[i]), mixers[i]); - gtk_box_pack_start(GTK_BOX(mixerHbox), mixerFrames[i], FALSE, TRUE, 5); - g_signal_connect(mixers[i], "button-release-event", G_CALLBACK(mixerChanged), (gpointer)i); - } - - // sync with cfg - int v; - g_config->getOption("SDL.Sound.Volume", &v); - gtk_range_set_value(GTK_RANGE(mixers[0]), v); - g_config->getOption("SDL.Sound.TriangleVolume", &v); - gtk_range_set_value(GTK_RANGE(mixers[1]), v); - g_config->getOption("SDL.Sound.Square1Volume", &v); - gtk_range_set_value(GTK_RANGE(mixers[2]), v); - g_config->getOption("SDL.Sound.Square2Volume", &v); - gtk_range_set_value(GTK_RANGE(mixers[3]), v); - g_config->getOption("SDL.Sound.NoiseVolume", &v); - gtk_range_set_value(GTK_RANGE(mixers[4]), v); - g_config->getOption("SDL.Sound.PCMVolume", &v); - gtk_range_set_value(GTK_RANGE(mixers[5]), v); - - - // packing some boxes - - gtk_box_pack_start(GTK_BOX(main_hbox), vbox, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), soundChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), lowpassChk, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), bufferLbl, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), bufferHscale, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(main_hbox), mixerFrame, TRUE, TRUE, 5); - gtk_container_add(GTK_CONTAINER(mixerFrame), mixerHbox); - - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(win))), main_hbox, TRUE, TRUE, 0); - - g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); - g_signal_connect(win, "response", G_CALLBACK(closeDialog), NULL); - - gtk_widget_show_all(win); - - return; -} - -void quit () -{ - // manually flush GTK event queue - while(gtk_events_pending()) - gtk_main_iteration_do(FALSE); - // this is not neccesary to be explicitly called - // it raises a GTK-Critical when its called - //gtk_main_quit(); - FCEUI_CloseGame(); - FCEUI_Kill(); - // LoadGame() checks for an IP and if it finds one begins a network session - // clear the NetworkIP field so this doesn't happen unintentionally - g_config->setOption("SDL.NetworkIP", ""); - g_config->save(); - SDL_Quit(); - exit(0); -} -const char* Authors[]= { - "Linux/SDL Developers:", - " Lukas Sabota", " Soules", " Bryan Cain", " radsaq", " Shinydoofy", - "FceuX 2.0 Developers:", - " SP", " zeromus", " adelikat", " caH4e3", " qfox", - " Luke Gustafson", " _mz", " UncombedCoconut", " DwEdit", " AnS", - "Pre 2.0 Guys:", - " Bero", " Xodnizel", " Aaron Oneal", " Joe Nahmias", - " Paul Kuliniewicz", " Quietust", " Ben Parnell", " Parasyte & bbitmaster", - " blip & nitsuja", - NULL}; - -void openAbout () -{ - GdkPixbuf* logo = gdk_pixbuf_new_from_xpm_data(icon_xpm); - - gtk_show_about_dialog(GTK_WINDOW(MainWindow), - "program-name", "fceuX", - "version", FCEU_VERSION_STRING, - "copyright", "© 2012 FceuX development team", - "license", "GPL-2; See COPYING", - //"license-type", GTK_LICENSE_GPL_2_0, - "website", "http://fceux.com", - "authors", Authors, - "logo", logo, NULL); -} - -void toggleSound(GtkWidget* check, gpointer data) -{ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) - { - g_config->setOption("SDL.Sound", 1); - if(GameInfo) - InitSound(); - } - else - { - g_config->setOption("SDL.Sound", 0); - KillSound(); - } -} - -void emuReset () -{ - if(isloaded) - ResetNES(); -} - -void hardReset () -{ - if(isloaded) - { - closeGame(); - const char* lastFile; - g_config->getOption("SDL.LastOpenFile", &lastFile); - LoadGame(lastFile); - resizeGtkWindow(); - } -} - -void enableFullscreen () -{ - if(isloaded) - ToggleFS(); -} - -void toggleAutoResume (GtkToggleAction *action) -{ - bool autoResume = gtk_toggle_action_get_active(action); - - g_config->setOption("SDL.AutoResume", (int)autoResume); - AutoResumePlay = autoResume; -} - -void recordMovie() -{ - if(isloaded) - { - char* movie_fname = const_cast(FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str()); - FCEUI_printf("Recording movie to %s\n", movie_fname); - FCEUI_SaveMovie(movie_fname, MOVIE_FLAG_NONE, L""); - } - - return; -} -void recordMovieAs () -{ - if(!isloaded) - { - return; - } - GtkWidget* fileChooser; - - GtkFileFilter* filterFm2; - GtkFileFilter* filterAll; - - filterFm2 = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterFm2, "*.fm2"); - gtk_file_filter_set_name(filterFm2, "FM2 Movies"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - fileChooser = gtk_file_chooser_dialog_new ("Save FM2 movie for recording", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(fileChooser), ".fm2"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterFm2); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), getcwd(NULL, 0)); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - std::string fname; - - fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - if (!fname.size()) - return; // no filename selected, quit the whole thing - char* movie_fname = const_cast(FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str()); - - std::string s = GetUserText("Author name"); - std::wstring author(s.begin(), s.end()); - - - FCEUI_SaveMovie(fname.c_str(), MOVIE_FLAG_NONE, author); - } - gtk_widget_destroy (fileChooser); -} - -void loadMovie () -{ - GtkWidget* fileChooser; - - GtkFileFilter* filterMovies; - GtkFileFilter* filterFm2; - GtkFileFilter* filterAll; - - filterMovies = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterMovies, "*.fm2"); - gtk_file_filter_add_pattern(filterMovies, "*.FM2f"); - gtk_file_filter_add_pattern(filterMovies, "*.fm3"); - gtk_file_filter_set_name(filterMovies, "FM2 Movies, TAS Editor Projects"); - - filterFm2 = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterFm2, "*.fm2"); - gtk_file_filter_add_pattern(filterFm2, "*.FM2f"); - gtk_file_filter_set_name(filterFm2, "FM2 Movies"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - fileChooser = gtk_file_chooser_dialog_new ("Open FM2 Movie", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterMovies); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterFm2); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), getcwd(NULL, 0)); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* fname; - - fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - static int pauseframe; - g_config->getOption("SDL.PauseFrame", &pauseframe); - g_config->setOption("SDL.PauseFrame", 0); - FCEUI_printf("Playing back movie located at %s\n", fname); - if(FCEUI_LoadMovie(fname, false, pauseframe ? pauseframe : false) == FALSE) - { - GtkWidget* d; - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Could not open the movie file."); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - } - } - gtk_widget_destroy (fileChooser); -} - -#ifdef _S9XLUA_H -void loadLua () -{ - GtkWidget* fileChooser; - GtkFileFilter* filterLua; - GtkFileFilter* filterAll; - - filterLua = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterLua, "*.lua"); - gtk_file_filter_add_pattern(filterLua, "*.LUA"); - gtk_file_filter_set_name(filterLua, "Lua scripts"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - fileChooser = gtk_file_chooser_dialog_new ("Open LUA Script", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterLua); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - const char* last_file; - g_config->getOption("SDL.LastLoadLua", &last_file); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_file); - - if(strcmp(last_file, "") == 0) - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), "/usr/share/fceux/luaScripts"); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - g_config->setOption("SDL.LastLoadLua", filename); - gtk_widget_destroy(fileChooser); - if(FCEU_LoadLuaCode(filename) == 0) - { - // This is necessary because lua scripts do not use FCEUD_PrintError to print errors. - GtkWidget* d; - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Could not open the selected lua script."); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - } - g_free(filename); - } - else - gtk_widget_destroy (fileChooser); -} -#endif - - -void loadFdsBios () -{ - GtkWidget* fileChooser; - GtkFileFilter* filterDiskSys; - GtkFileFilter* filterRom; - GtkFileFilter* filterAll; - - - filterDiskSys = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterDiskSys, "disksys.rom"); - gtk_file_filter_set_name(filterDiskSys, "disksys.rom"); - - filterRom = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterRom, "*.rom"); - gtk_file_filter_set_name(filterRom, "*.rom"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - - fileChooser = gtk_file_chooser_dialog_new ("Load FDS BIOS (disksys.rom)", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterDiskSys); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterRom); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), getcwd(NULL, 0)); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - // copy BIOS file to proper place (~/.fceux/disksys.rom) - std::ifstream fdsBios (filename,std::fstream::binary); - std::string output_filename = FCEU_MakeFName(FCEUMKF_FDSROM, 0, ""); - std::ofstream outFile (output_filename.c_str(),std::fstream::trunc|std::fstream::binary); - outFile<setOption("SDL.GameGenie", enabled); - g_config->save(); - FCEUI_SetGameGenie(enabled); -} - -void toggleGameGenie(GtkToggleAction *action) -{ - enableGameGenie(gtk_toggle_action_get_active(action)); -} - -void togglePause(GtkAction *action) -{ - SDL_Event sdlev; - int paused; - - if(isloaded) - { - paused = FCEUI_EmulationPaused(); - - sdlev.type = SDL_FCEU_HOTKEY_EVENT; - sdlev.user.code = HK_PAUSE; - if(SDL_PushEvent(&sdlev) < 0) - { - FCEU_printf("Failed to push SDL event to %s game.\n", paused ? "resume" : "pause"); - return; - } - gtk_action_set_label(action, paused ? "Pause" : "Resume"); - gtk_action_set_stock_id(action, paused ? GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_PLAY); - } -} - -void loadGameGenie () -{ - GtkWidget* fileChooser; - GtkFileFilter* filterGG; - GtkFileFilter* filterRom; - GtkFileFilter* filterNes; - GtkFileFilter* filterAll; - - - filterGG = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterGG, "gg.rom"); - gtk_file_filter_set_name(filterGG, "gg.rom"); - - filterRom = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterRom, "*.rom"); - gtk_file_filter_set_name(filterRom, "*.rom"); - - filterNes = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterNes, "*.nes"); - gtk_file_filter_set_name(filterNes, "*.nes"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - - fileChooser = gtk_file_chooser_dialog_new ("Load Game Genie ROM", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterGG); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterRom); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNes); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), getcwd(NULL, 0)); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - // copy file to proper place (~/.fceux/gg.rom) - std::ifstream f1 (filename,std::fstream::binary); - std::string fn_out = FCEU_MakeFName(FCEUMKF_GGROM, 0, ""); - std::ofstream f2 (fn_out.c_str(),std::fstream::trunc|std::fstream::binary); - gtk_widget_destroy (fileChooser); - GtkWidget* d; - enableGameGenie(TRUE); - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, - "Game Genie ROM copied to: '%s'.", fn_out.c_str()); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - - f2<getOption("SDL.LastOpenNSF", &last_dir); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNSF); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterZip); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - gtk_widget_destroy (fileChooser); - LoadGame(filename); - // no longer required with GTK FCEUD_PrintError implementation - /*if(LoadGame(filename) == 0) - { - - GtkWidget* d; - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Could not open the selected NSF file."); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - }*/ - g_config->setOption("SDL.LastOpenNSF", filename); - g_free(filename); - } - else - gtk_widget_destroy (fileChooser); -} - -void closeGame() -{ - GdkColor bg = {0, 0, 0, 0}; - gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &bg); - CloseGame(); -} - -void loadGame () -{ - GtkWidget* fileChooser; - GtkFileFilter* filterFCEU; - GtkFileFilter* filterNes; - GtkFileFilter* filterFds; - GtkFileFilter* filterNSF; - GtkFileFilter* filterZip; - GtkFileFilter* filterAll; - - filterFCEU = gtk_file_filter_new(); - filterNes = gtk_file_filter_new(); - filterFds = gtk_file_filter_new(); - filterNSF = gtk_file_filter_new(); - filterZip = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterFCEU, "*.nes"); - gtk_file_filter_add_pattern(filterFCEU, "*.NES"); - gtk_file_filter_add_pattern(filterFCEU, "*.fds"); - gtk_file_filter_add_pattern(filterFCEU, "*.FDS"); - gtk_file_filter_add_pattern(filterFCEU, "*.zip"); - gtk_file_filter_add_pattern(filterFCEU, "*.ZIP"); - gtk_file_filter_add_pattern(filterFCEU, "*.Nes"); - gtk_file_filter_add_pattern(filterFCEU, "*.Fds"); - gtk_file_filter_add_pattern(filterFCEU, "*.Zip"); - gtk_file_filter_add_pattern(filterFCEU, "*.nsf"); - gtk_file_filter_add_pattern(filterFCEU, "*.NSF"); - gtk_file_filter_add_pattern(filterNes, "*.nes"); - gtk_file_filter_add_pattern(filterNes, "*.NES"); - gtk_file_filter_add_pattern(filterFds, "*.fds"); - gtk_file_filter_add_pattern(filterFds, "*.FDS"); - gtk_file_filter_add_pattern(filterNSF, "*.nsf"); - gtk_file_filter_add_pattern(filterNSF, "*.NSF"); - gtk_file_filter_add_pattern(filterZip, "*.zip"); - gtk_file_filter_add_pattern(filterZip, "*.zip"); - gtk_file_filter_set_name(filterFCEU, "*.nes;*.fds;*.nsf;*.zip"); - gtk_file_filter_set_name(filterNes, "NES ROM files"); - gtk_file_filter_set_name(filterFds, "FDS ROM files"); - gtk_file_filter_set_name(filterNSF, "NSF sound files"); - gtk_file_filter_set_name(filterZip, "Zip archives"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - - - fileChooser = gtk_file_chooser_dialog_new ("Open ROM", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - const char* last_dir; - g_config->getOption("SDL.LastOpenFile", &last_dir); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterFCEU); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNes); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterFds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNSF); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterZip); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - gtk_widget_destroy (fileChooser); - g_config->setOption("SDL.LastOpenFile", filename); - closeGame(); - LoadGame(filename); - // Error dialog no longer required with GTK implementation of FCEUD_PrintError() - /*if(LoadGame(filename) == 0) - { - - GtkWidget* d; - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Could not open the selected ROM file."); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - }*/ - resizeGtkWindow(); - g_free(filename); - } - else - gtk_widget_destroy (fileChooser); -} - -void saveStateAs() -{ - GtkWidget* fileChooser; - GtkFileFilter* filterSav; - GtkFileFilter* filterAll; - - filterSav = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterSav, "*.sav"); - gtk_file_filter_add_pattern(filterSav, "*.SAV"); - gtk_file_filter_set_name(filterSav, "SAV files"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - const char* last_dir; - g_config->getOption("SDL.LastSaveStateAs", &last_dir); - - fileChooser = gtk_file_chooser_dialog_new ("Save State As", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileChooser), last_dir); - - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(fileChooser), ".sav"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - FCEUI_SaveState(filename); - g_config->setOption("SDL.LastSaveStateAs", filename); - g_free(filename); - } - gtk_widget_destroy (fileChooser); - - -} - -void loadStateFrom() -{ - GtkWidget* fileChooser; - GtkFileFilter* filterFcs; - GtkFileFilter* filterSav; - GtkFileFilter* filterAll; - - filterSav = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterSav, "*.sav"); - gtk_file_filter_add_pattern(filterSav, "*.SAV"); - gtk_file_filter_set_name(filterSav, "SAV files"); - - filterFcs = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterFcs, "*.fc?"); - gtk_file_filter_add_pattern(filterFcs, "*.FC?"); - gtk_file_filter_set_name(filterFcs, "FCS files"); - - filterAll = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filterAll, "*"); - gtk_file_filter_set_name(filterAll, "All Files"); - - fileChooser = gtk_file_chooser_dialog_new ("Load State From", GTK_WINDOW(MainWindow), - GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - - const char* last_dir; - g_config->getOption("SDL.LastLoadStateFrom", &last_dir); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterFcs); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll); - - if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT) - { - char* filename; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - FCEUI_LoadState(filename); - g_config->setOption("SDL.LastLoadStateFrom", filename); - g_free(filename); - } - gtk_widget_destroy (fileChooser); -} - -void quickLoad() -{ - FCEUI_LoadState(NULL); -} - -void quickSave() -{ - FCEUI_SaveState(NULL); -} - -void changeState(GtkAction *action, GtkRadioAction *current, gpointer data) -{ - FCEUI_SelectState(gtk_radio_action_get_current_value(current), 0); -} -#if SDL_VERSION_ATLEAST(2, 0, 0) -// SDL 1.2/2.0 compatibility macros -#define SDLK_SCROLLOCK SDLK_SCROLLLOCK -#define SDLK_PRINT SDLK_PRINTSCREEN -#define SDLK_BREAK 0 -#define SDLK_COMPOSE 0 -#define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR -#define SDLK_KP0 SDLK_KP_0 -#define SDLK_KP1 SDLK_KP_1 -#define SDLK_KP2 SDLK_KP_2 -#define SDLK_KP3 SDLK_KP_3 -#define SDLK_KP4 SDLK_KP_4 -#define SDLK_KP5 SDLK_KP_5 -#define SDLK_KP6 SDLK_KP_6 -#define SDLK_KP7 SDLK_KP_7 -#define SDLK_KP8 SDLK_KP_8 -#define SDLK_KP9 SDLK_KP_9 -#define SDLK_LSUPER SDLK_LGUI -#define SDLK_RSUPER SDLK_RGUI -#define SDLK_LMETA 0 -#define SDLK_RMETA 0 -#endif -// Adapted from Gens/GS. Converts a GDK key value into an SDL key value. -unsigned short GDKToSDLKeyval(int gdk_key) -{ - if (!(gdk_key & 0xFF00)) - { - // ASCII symbol. - // SDL and GDK use the same values for these keys. - - // Make sure the key value is lowercase. - gdk_key = tolower(gdk_key); - - // Return the key value. - return gdk_key; - } - - if (gdk_key & 0xFFFF0000) - { - // Extended X11 key. Not supported by SDL. -#ifdef GDK_WINDOWING_X11 - fprintf(stderr, "Unhandled extended X11 key: 0x%08X (%s)", gdk_key, XKeysymToString(gdk_key)); -#else - fprintf(stderr, "Unhandled extended key: 0x%08X\n", gdk_key); -#endif - return 0; - } - - // Non-ASCII symbol. - static const uint16_t gdk_to_sdl_table[0x100] = - { - // 0x00 - 0x0F - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - SDLK_BACKSPACE, SDLK_TAB, SDLK_RETURN, SDLK_CLEAR, - 0x0000, SDLK_RETURN, 0x0000, 0x0000, - - // 0x10 - 0x1F - 0x0000, 0x0000, 0x0000, SDLK_PAUSE, - SDLK_SCROLLOCK, SDLK_SYSREQ, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, SDLK_ESCAPE, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x20 - 0x2F - SDLK_COMPOSE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x30 - 0x3F [Japanese keys] - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x40 - 0x4F [unused] - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x50 - 0x5F - SDLK_HOME, SDLK_LEFT, SDLK_UP, SDLK_RIGHT, - SDLK_DOWN, SDLK_PAGEUP, SDLK_PAGEDOWN, SDLK_END, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x60 - 0x6F - 0x0000, SDLK_PRINT, 0x0000, SDLK_INSERT, - SDLK_UNDO, 0x0000, 0x0000, SDLK_MENU, - 0x0000, SDLK_HELP, SDLK_BREAK, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0x70 - 0x7F [mostly unused, except for Alt Gr and Num Lock] - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, SDLK_MODE, SDLK_NUMLOCK, - - // 0x80 - 0x8F [mostly unused, except for some numeric keypad keys] - SDLK_KP5, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, SDLK_KP_ENTER, 0x0000, 0x0000, - - // 0x90 - 0x9F - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, SDLK_KP7, SDLK_KP4, SDLK_KP8, - SDLK_KP6, SDLK_KP2, SDLK_KP9, SDLK_KP3, - SDLK_KP1, SDLK_KP5, SDLK_KP0, SDLK_KP_PERIOD, - - // 0xA0 - 0xAF - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, SDLK_KP_MULTIPLY, SDLK_KP_PLUS, - 0x0000, SDLK_KP_MINUS, SDLK_KP_PERIOD, SDLK_KP_DIVIDE, - - // 0xB0 - 0xBF - SDLK_KP0, SDLK_KP1, SDLK_KP2, SDLK_KP3, - SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP7, - SDLK_KP8, SDLK_KP9, 0x0000, 0x0000, - 0x0000, SDLK_KP_EQUALS, SDLK_F1, SDLK_F2, - - // 0xC0 - 0xCF - SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, - SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, - SDLK_F11, SDLK_F12, SDLK_F13, SDLK_F14, - SDLK_F15, 0x0000, 0x0000, 0x0000, - - // 0xD0 - 0xDF [L* and R* function keys] - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - - // 0xE0 - 0xEF - 0x0000, SDLK_LSHIFT, SDLK_RSHIFT, SDLK_LCTRL, - SDLK_RCTRL, SDLK_CAPSLOCK, 0x0000, SDLK_LMETA, - SDLK_RMETA, SDLK_LALT, SDLK_RALT, SDLK_LSUPER, - SDLK_RSUPER, 0x0000, 0x0000, 0x0000, - - // 0xF0 - 0xFF [mostly unused, except for Delete] - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, SDLK_DELETE, - }; - - unsigned short sdl_key = gdk_to_sdl_table[gdk_key & 0xFF]; - if (sdl_key == 0) - { - // Unhandled GDK key. - fprintf(stderr, "Unhandled GDK key: 0x%04X (%s)", gdk_key, gdk_keyval_name(gdk_key)); - return 0; - } - - // ignore pause and screenshot hotkeys since they is handled by GTK+ as accelerators - if (sdl_key == Hotkeys[HK_PAUSE] || sdl_key == Hotkeys[HK_SCREENSHOT] || - sdl_key == Hotkeys[HK_SAVE_STATE] || sdl_key == Hotkeys[HK_LOAD_STATE]) - return 0; - - return sdl_key; -} - - -// Function adapted from Gens/GS (source/gens/input/input_sdl.c) -gint convertKeypress(GtkWidget *grab, GdkEventKey *event, gpointer user_data) -{ - SDL_Event sdlev; - int keystate; -#if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_Keycode sdlkey; -#else - SDLKey sdlkey; -#endif - switch (event->type) - { - case GDK_KEY_PRESS: - sdlev.type = SDL_KEYDOWN; - sdlev.key.state = SDL_PRESSED; - keystate = 1; - break; - - case GDK_KEY_RELEASE: - sdlev.type = SDL_KEYUP; - sdlev.key.state = SDL_RELEASED; - keystate = 0; - break; - - default: - fprintf(stderr, "Unhandled GDK event type: %d", event->type); - return FALSE; - } - - // Convert this keypress from GDK to SDL. -#if SDL_VERSION_ATLEAST(2, 0, 0) - sdlkey = GDKToSDLKeyval(event->keyval); -#else - sdlkey = (SDLKey)GDKToSDLKeyval(event->keyval); -#endif - - // Create an SDL event from the keypress. - sdlev.key.keysym.sym = sdlkey; - if (sdlkey != 0) - { - SDL_PushEvent(&sdlev); - - // Only let the emulator handle the key event if this window has the input focus. - if(keystate == 0 || gtk_window_is_active(GTK_WINDOW(MainWindow))) - { - #if SDL_VERSION_ATLEAST(2, 0, 0) - // Not sure how to do this yet with SDL 2.0 - // TODO - SDL 2.0 - //SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey(sdlkey)] = keystate; - #else - SDL_GetKeyState(NULL)[sdlkey] = keystate; - #endif - } - } - - // Allow GTK+ to process this key. - return FALSE; -} - -// Our menu, in the XML markup format used by GtkUIManager -static char* menuXml = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " -#ifdef _S9XLUA_H - " " -#endif - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - ""; - -// Menu items, as an array of GtkActionEntry structures that define each item -static GtkActionEntry normal_entries[] = { - {"FileMenuAction", NULL, "_File"}, - {"OpenRomAction", GTK_STOCK_OPEN, "_Open ROM", "O", NULL, G_CALLBACK(loadGame)}, - {"CloseRomAction", GTK_STOCK_CLOSE, "_Close ROM", "C", NULL, G_CALLBACK(closeGame)}, - {"PlayNsfAction", GTK_STOCK_OPEN, "_Play NSF", "N", NULL, G_CALLBACK(loadNSF)}, - {"LoadStateFromAction", GTK_STOCK_OPEN, "Load State _From", "", NULL, G_CALLBACK(loadStateFrom)}, - {"SaveStateAsAction", GTK_STOCK_SAVE_AS, "Save State _As", NULL, NULL, G_CALLBACK(saveStateAs)}, - {"QuickLoadAction", "go-jump", "Quick _Load", "F7", NULL, G_CALLBACK(quickLoad)}, - {"QuickSaveAction", GTK_STOCK_SAVE, "Qu_ick Save", "F5", NULL, G_CALLBACK(quickSave)}, - {"ChangeStateMenuAction", NULL, "C_hange State"}, -#ifdef _S9XLUA_H - {"LoadLuaScriptAction", GTK_STOCK_OPEN, "Load L_ua Script", "", NULL, G_CALLBACK(loadLua)}, -#endif - {"ScreenshotAction", NULL, "_Screenshot", "F12", NULL, G_CALLBACK(FCEUI_SaveSnapshot)}, - {"QuitAction", GTK_STOCK_QUIT, "_Quit", "Q", NULL, G_CALLBACK(quit)}, - - {"OptionsMenuAction", NULL, "_Options"}, -#if GTK_MAJOR_VERSION == 3 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24) - {"GamepadConfigAction", "input-gaming", "_Gamepad Config", NULL, NULL, G_CALLBACK(openGamepadConfig)}, -#endif - {"HotkeyConfigAction", "input", "_Hotkey Config", NULL, NULL, G_CALLBACK(openHotkeyConfig)}, - {"SoundConfigAction", "audio-x-generic", "_Sound Config", NULL, NULL, G_CALLBACK(openSoundConfig)}, - {"VideoConfigAction", "video-display", "_Video Config", NULL, NULL, G_CALLBACK(openVideoConfig)}, - {"PaletteConfigAction", GTK_STOCK_SELECT_COLOR, "_Palette Config", NULL, NULL, G_CALLBACK(openPaletteConfig)}, - {"NetworkConfigAction", GTK_STOCK_NETWORK, "_Network Config", NULL, NULL, G_CALLBACK(openNetworkConfig)}, - {"FullscreenAction", GTK_STOCK_FULLSCREEN, "_Fullscreen", "Return", NULL, G_CALLBACK(enableFullscreen)}, - {"EmulationMenuAction", NULL, "_Emulation"}, - {"PowerAction", NULL, "P_ower", NULL, NULL, G_CALLBACK(FCEUI_PowerNES)}, - {"SoftResetAction", GTK_STOCK_REFRESH, "_Soft Reset", NULL, NULL, G_CALLBACK(emuReset)}, - {"ResetAction", GTK_STOCK_REFRESH, "_Reset", NULL, NULL, G_CALLBACK(hardReset)}, - {"PauseToggleAction", GTK_STOCK_MEDIA_PAUSE, "_Pause", "Pause", NULL, G_CALLBACK(togglePause)}, - {"FdsMenuAction", GTK_STOCK_FLOPPY, "_FDS"}, - {"SwitchDiskAction", "go-jump", "_Switch Disk", NULL, NULL, G_CALLBACK(FCEU_FDSSelect)}, - {"EjectDiskAction", "media-eject", "_Eject Disk", NULL, NULL, G_CALLBACK(FCEU_FDSInsert)}, - {"LoadBiosAction", GTK_STOCK_OPEN, "Load _BIOS File", "", NULL, G_CALLBACK(loadFdsBios)}, - {"LoadGameGenieAction", GTK_STOCK_OPEN, "_Load Game Genie ROM", "", NULL, G_CALLBACK(loadGameGenie)}, - {"InsertCoinAction", NULL, "_Insert Coin", NULL, NULL, G_CALLBACK(FCEUI_VSUniCoin)}, - - {"MovieMenuAction", NULL, "_Movie"}, - {"OpenMovieAction", GTK_STOCK_OPEN, "_Open", "F7", NULL, G_CALLBACK(loadMovie)}, - {"StopMovieAction", GTK_STOCK_MEDIA_STOP, "S_top", NULL, NULL, G_CALLBACK(FCEUI_StopMovie)}, - {"RecordMovieAction", GTK_STOCK_MEDIA_RECORD, "_Record", "F5", NULL, G_CALLBACK(recordMovie)}, - {"RecordMovieAsAction", NULL, "Record _As", NULL, NULL, G_CALLBACK(recordMovieAs)}, - - {"HelpMenuAction", NULL, "_Help"}, - {"AboutAction", GTK_STOCK_ABOUT, "_About", NULL, NULL, G_CALLBACK(openAbout)}, -}; - -// Menu items with a check box that can be toggled on or off -static GtkToggleActionEntry toggle_entries[] = { - {"GameGenieToggleAction", NULL, "Enable Game _Genie", NULL, NULL, G_CALLBACK(toggleGameGenie), FALSE}, - {"AutoResumeAction", NULL, "Auto-Resume Play", NULL, NULL, G_CALLBACK(toggleAutoResume), FALSE}, -}; - -// Menu items for selecting a save state slot using radio buttons -static GtkRadioActionEntry radio_entries[] = { - {"State0Action", NULL, "0", NULL, NULL, 0}, - {"State1Action", NULL, "1", NULL, NULL, 1}, - {"State2Action", NULL, "2", NULL, NULL, 2}, - {"State3Action", NULL, "3", NULL, NULL, 3}, - {"State4Action", NULL, "4", NULL, NULL, 4}, - {"State5Action", NULL, "5", NULL, NULL, 5}, - {"State6Action", NULL, "6", NULL, NULL, 6}, - {"State7Action", NULL, "7", NULL, NULL, 7}, - {"State8Action", NULL, "8", NULL, NULL, 8}, - {"State9Action", NULL, "9", NULL, NULL, 9}, -}; - -static GtkWidget* CreateMenubar( GtkWidget* window) -{ - GtkUIManager *ui_manager; - GtkActionGroup *action_group; - GtkAccelGroup* accel_group; - GError *error = NULL; - GtkAction* state; - - /* Make an UIManager (which makes a menubar). */ - ui_manager = gtk_ui_manager_new (); - - /* Add the menu items to the UIManager as a GtkActionGroup. */ - action_group = gtk_action_group_new ("MenubarActions"); - gtk_action_group_add_actions (action_group, normal_entries, G_N_ELEMENTS (normal_entries), NULL); - gtk_action_group_add_toggle_actions (action_group, toggle_entries, G_N_ELEMENTS (toggle_entries), NULL); - gtk_action_group_add_radio_actions (action_group, radio_entries, G_N_ELEMENTS (radio_entries), 0, G_CALLBACK(changeState), NULL); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - /* Read the menu layout from the XML markup. */ - gtk_ui_manager_add_ui_from_string (ui_manager, menuXml, -1, &error); - if (error) - { - fprintf (stderr, "Unable to create menu bar: %s\n", error->message); - g_error_free (error); - } - - /* Attach the new accelerator group to the window. */ - accel_group = gtk_ui_manager_get_accel_group (ui_manager); - gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); - - /* Get an action that can be used to change the active state slot selection. */ - state = gtk_action_group_get_action (action_group, "State0Action"); - if (state && GTK_IS_RADIO_ACTION (state)) - stateSlot = GTK_RADIO_ACTION (state); - - /* Set the autoResume checkbox */ - GtkCheckMenuItem* auto_resume_chk = (GtkCheckMenuItem*) gtk_ui_manager_get_widget ( ui_manager, "/Menubar/OptionsMenuAction/AutoResumeAction"); - gtk_check_menu_item_set_active (auto_resume_chk, (bool)AutoResumePlay); - - /* Finally, return the actual menu bar created by the UIManager. */ - return gtk_ui_manager_get_widget (ui_manager, "/Menubar"); -} - - -void pushOutputToGTK(const char* str) -{ - // we don't really do anything with the output right now - return; -} - -void showGui(bool b) -{ - if(b) - gtk_widget_show_all(MainWindow); - else - gtk_widget_hide(MainWindow); -} - -int GtkMouseData[3] = {0,0,0}; - -gint handleMouseClick(GtkWidget* widget, GdkEvent *event, gpointer callback_data) -{ - GtkMouseData[0] = ((GdkEventButton*)event)->x; - GtkMouseData[1] = ((GdkEventButton*)event)->y; - int button = ((GdkEventButton*)event)->button; - if(!(((GdkEventButton*)event)->type == GDK_BUTTON_PRESS)) - GtkMouseData[2] = 0; - else - { - if(button == 1) - GtkMouseData[2] |= 0x1; - if(button == 3) - GtkMouseData[2] |= 0x3; - } - - // this doesn't work because we poll the mouse position rather - // than use events - /* - SDL_Event sdlev; - sdlev.type = SDL_MOUSEBUTTONDOWN; - if(((GdkEventButton*)event)->type == GDK_BUTTON_PRESS) - sdlev.button.type = SDL_MOUSEBUTTONDOWN; - else - sdlev.button.type = SDL_MOUSEBUTTONUP; - sdlev.button.button = ((GdkEventButton*)event)->button; - sdlev.button.state = ((GdkEventButton*)event)->state; - sdlev.button.x = ((GdkEventButton*)event)->x; - sdlev.button.y = ((GdkEventButton*)event)->y; - - SDL_PushEvent(&sdlev); - */ - - return 0; -} -// NES resolution = 256x240 -const int NES_WIDTH=256; -const int NES_HEIGHT=240; - -void handle_resize(GtkWindow* win, GdkEvent* event, gpointer data) -{ - // TODO this is a stub atm - // this should handle resizing so the emulation takes up as much - // of the GTK window as possible - - - // get new window width/height - int width, height; - width = event->configure.width; - height = event->configure.height; - printf("DEBUG: new window size: %dx%d\n", width, height); - - // get width/height multipliers - double xscale = width / (double)NES_WIDTH; - double yscale = height / (double)NES_HEIGHT; - - // TODO check KeepRatio (where is this) - // do this to keep aspect ratio - if(xscale > yscale) - xscale = yscale; - if(yscale > xscale) - yscale = xscale; - - //TODO if openGL make these integers - g_config->setOption("SDL.XScale", xscale); - g_config->setOption("SDL.YScale", yscale); - //gtk_widget_realize(evbox); - flushGtkEvents(); - if(GameInfo != 0) - { - KillVideo(); - InitVideo(GameInfo); - } - gtk_widget_set_size_request(evbox, (int)(NES_WIDTH*xscale), (int)(NES_HEIGHT*yscale)); - GdkColor black; - black.red = 0; - black.green = 0; - black.blue = 0; -// gtk_widget_modify_bg(GTK_WIDGET(win), GTK_STATE_NORMAL, &black); - - printf("DEBUG: new xscale: %f yscale: %f\n", xscale, yscale); - - return; -} - -int InitGTKSubsystem(int argc, char** argv) -{ - GtkWidget* Menubar; - GtkWidget* vbox; - - MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); -// gtk_window_set_policy (GTK_WINDOW (MainWindow), FALSE, FALSE, TRUE); - gtk_window_set_resizable(GTK_WINDOW(MainWindow), TRUE); - gtk_window_set_title(GTK_WINDOW(MainWindow), FCEU_NAME_AND_VERSION); - gtk_window_set_default_size(GTK_WINDOW(MainWindow), NES_WIDTH, NES_HEIGHT); - - GdkPixbuf* icon = gdk_pixbuf_new_from_xpm_data(icon_xpm); - gtk_window_set_default_icon(icon); - gtk_window_set_icon(GTK_WINDOW(MainWindow), icon); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(MainWindow), vbox); - - Menubar = CreateMenubar(MainWindow); - // turn of game genie by default, since its off by default in the menu - enableGameGenie(0); - - gtk_box_pack_start (GTK_BOX(vbox), Menubar, FALSE, TRUE, 0); - - // PRG: this code here is the the windowID "hack" to render SDL - // in a GTK window. however, I can't get it to work right now - // so i'm commenting it out and haivng a seperate GTK2 window with - // controls - // 12/21/09 - // --- - // uncommented and fixed by Bryan Cain - // 1/24/11 - // - // prg - Bryan Cain, you are the man! - - evbox = gtk_event_box_new(); - gtk_box_pack_start (GTK_BOX(vbox), evbox, TRUE, TRUE, 0); - - double xscale, yscale; - g_config->getOption("SDL.XScale", &xscale); - g_config->getOption("SDL.YScale", &yscale); - - gtk_widget_set_size_request(evbox, NES_WIDTH*xscale, NES_HEIGHT*yscale); - gtk_widget_realize(evbox); - gtk_widget_show(evbox); - gtk_widget_show_all(vbox); - - GdkColor bg = {0, 0, 0, 0}; - gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &bg); - - // set up keypress "snooper" to convert GDK keypress events into SDL keypresses - gtk_key_snooper_install(convertKeypress, NULL); - - // pass along mouse data from GTK to SDL - g_signal_connect(G_OBJECT(evbox), "button-press-event", G_CALLBACK(handleMouseClick), NULL); - g_signal_connect(G_OBJECT(evbox), "button-release-event", G_CALLBACK(handleMouseClick), NULL); - - - // signal handlers - g_signal_connect(MainWindow, "delete-event", quit, NULL); - g_signal_connect(MainWindow, "destroy-event", quit, NULL); - // resize handler -// g_signal_connect(MainWindow, "configure-event", G_CALLBACK(handle_resize), NULL); - - gtk_widget_show_all(MainWindow); - - GtkRequisition req; - gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); - gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); - gtkIsStarted = true; - - return 0; -} - diff --git a/branches/fceux-2.2.2/src/drivers/sdl/gui.h b/branches/fceux-2.2.2/src/drivers/sdl/gui.h deleted file mode 100644 index a4989cf6..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/gui.h +++ /dev/null @@ -1,119 +0,0 @@ -// gui.h -// -// Copyright 2009 Lukas -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// 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., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301, USA. - -#ifndef FCEUX_GUI_H -#define FCEUX_GUI_H - -#define GTK - -#ifdef _GTK -#include -#endif -extern GtkWidget* MainWindow; -extern GtkWidget* evbox; -extern GtkRadioAction* stateSlot; -extern int GtkMouseData[3]; -extern bool gtkIsStarted; - -int InitGTKSubsystem(int argc, char** argv); -void pushOutputToGTK(const char* str); -void showGui(bool b); - -bool checkGTKVersion(int major_required, int minor_required); - -int configHotkey(char* hotkeyString); -int configGamepadButton(GtkButton* button, gpointer p); - -void resetVideo(); -void closeVideoWin(GtkWidget* w, GdkEvent* e, gpointer p); -void closeDialog(GtkWidget* w, GdkEvent* e, gpointer p); - -void toggleLowPass(GtkWidget* w, gpointer p); -void toggleOption(GtkWidget* w, gpointer p); - -int setTint(GtkWidget* w, gpointer p); -int setHue(GtkWidget* w, gpointer p); -void loadPalette (GtkWidget* w, gpointer p); -void clearPalette(GtkWidget* w, gpointer p); -void openPaletteConfig(); - -void launchNet(GtkWidget* w, gpointer p); -void setUsername(GtkWidget* w, gpointer p); -void netResponse(GtkWidget* w, gint response_id, gpointer p); -void openNetworkConfig(); -void flushGtkEvents(); - -void openHotkeyConfig(); -int setInputDevice(GtkWidget* w, gpointer p); -void updateGamepadConfig(GtkWidget* w, gpointer p); -void openGamepadConfig(); - -int setBufSize(GtkWidget* w, gpointer p); -void setRate(GtkWidget* w, gpointer p); -void setQuality(GtkWidget* w, gpointer p); -void resizeGtkWindow(); -void setScaler(GtkWidget* w, gpointer p); -int setXscale(GtkWidget* w, gpointer p); -int setYscale(GtkWidget* w, gpointer p); - -#ifdef OPENGL -void setGl(GtkWidget* w, gpointer p); -void setDoubleBuffering(GtkWidget* w, gpointer p); -#endif - -void openVideoConfig(); -int mixerChanged(GtkWidget* w, gpointer p); -void openSoundConfig(); -void quit (); -void openAbout (); -void toggleSound(GtkWidget* check, gpointer data); - -void emuReset (); -void hardReset (); -void enableFullscreen (); -void toggleAutoResume (GtkToggleAction *action); - -void recordMovie(); -void recordMovieAs (); -void loadMovie (); -#ifdef _S9XLUA_H -void loadLua (); -#endif -void loadFdsBios (); - -void enableGameGenie(int enabled); -void toggleGameGenie(GtkToggleAction *action); -void togglePause(GtkAction *action); -void loadGameGenie (); - -void loadNSF (); -void closeGame(); -void loadGame (); -void saveStateAs(); -void loadStateFrom(); -void quickLoad(); -void quickSave(); -void changeState(GtkAction *action, GtkRadioAction *current, gpointer data); -unsigned short GDKToSDLKeyval(int gdk_key); -gint convertKeypress(GtkWidget *grab, GdkEventKey *event, gpointer user_data); -gint handleMouseClick(GtkWidget* widget, GdkEvent *event, gpointer callback_data); -void handle_resize(GtkWindow* win, GdkEvent* event, gpointer data); -int InitGTKSubsystem(int argc, char** argv); - -#endif // ifndef FCEUX_GUI_H diff --git a/branches/fceux-2.2.2/src/drivers/sdl/input.cpp b/branches/fceux-2.2.2/src/drivers/sdl/input.cpp deleted file mode 100644 index c371b2fe..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/input.cpp +++ /dev/null @@ -1,2395 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "main.h" -#include "dface.h" -#include "input.h" -#include "config.h" - - -#include "sdl-video.h" -#include "sdl.h" - -#include "../common/cheat.h" -#include "../../movie.h" -#include "../../fceu.h" -#include "../../driver.h" -#include "../../utils/xstring.h" -#ifdef _S9XLUA_H -#include "../../fceulua.h" -#endif - -#ifdef _GTK -#include "gui.h" -#ifdef SDL_VIDEO_DRIVER_X11 -#include -#endif -#endif - - -#include -#include - -/** GLOBALS **/ -int NoWaiting = 1; -extern Config *g_config; -extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay; - - -/* UsrInputType[] is user-specified. CurInputType[] is current - (game loading can override user settings) -*/ -static int UsrInputType[NUM_INPUT_DEVICES]; -static int CurInputType[NUM_INPUT_DEVICES]; -static int cspec = 0; - -extern int gametype; - -/** - * Necessary for proper GUI functioning (configuring when a game isn't loaded). - */ -void -InputUserActiveFix () -{ - int x; - for (x = 0; x < 3; x++) - { - CurInputType[x] = UsrInputType[x]; - } -} - -/** - * Parse game information and configure the input devices accordingly. - */ -void -ParseGIInput (FCEUGI * gi) -{ - gametype = gi->type; - - CurInputType[0] = UsrInputType[0]; - CurInputType[1] = UsrInputType[1]; - CurInputType[2] = UsrInputType[2]; - - if (gi->input[0] >= 0) - { - CurInputType[0] = gi->input[0]; - } - if (gi->input[1] >= 0) - { - CurInputType[1] = gi->input[1]; - } - if (gi->inputfc >= 0) - { - CurInputType[2] = gi->inputfc; - } - cspec = gi->cspecial; -} - - -static uint8 QuizKingData = 0; -static uint8 HyperShotData = 0; -static uint32 MahjongData = 0; -static uint32 FTrainerData = 0; -static uint8 TopRiderData = 0; -static uint8 BWorldData[1 + 13 + 1]; - -static void UpdateFKB (void); -static void UpdateGamepad (void); -static void UpdateQuizKing (void); -static void UpdateHyperShot (void); -static void UpdateMahjong (void); -static void UpdateFTrainer (void); -static void UpdateTopRider (void); - -static uint32 JSreturn = 0; - -/** - * Configure cheat devices (game genie, etc.). Restarts the keyboard - * and video subsystems. - */ -static void -DoCheatSeq () -{ - SilenceSound (1); - KillVideo (); - - DoConsoleCheatConfig (); - InitVideo (GameInfo); - SilenceSound (0); -} - -#include "keyscan.h" -static uint8 *g_keyState = 0; -static int DIPS = 0; - -static uint8 keyonce[MKK_COUNT]; -#define KEY(__a) g_keyState[MKK(__a)] - -static int -_keyonly (int a) -{ - // check for valid key - if (a > SDLK_LAST + 1 || a < 0) - return 0; -#if SDL_VERSION_ATLEAST(2, 0, 0) - if (g_keyState[SDL_GetScancodeFromKey (a)]) -#else - if (g_keyState[a]) -#endif - { - if (!keyonce[a]) - { - keyonce[a] = 1; - return 1; - } - } - else { - keyonce[a] = 0; - } - return 0; -} - -#define keyonly(__a) _keyonly(MKK(__a)) - -static int g_fkbEnabled = 0; - -// this function loads the sdl hotkeys from the config file into the -// global scope. this elimates the need for accessing the config file - -int Hotkeys[HK_MAX] = { 0 }; - -// on every cycle of keyboardinput() -void -setHotKeys () -{ - std::string prefix = "SDL.Hotkeys."; - for (int i = 0; i < HK_MAX; i++) - { - g_config->getOption (prefix + HotkeyStrings[i], &Hotkeys[i]); - } - return; -} - -/*** - * This function is a wrapper for FCEUI_ToggleEmulationPause that handles - * releasing/capturing mouse pointer during pause toggles - * */ -void -TogglePause () -{ - FCEUI_ToggleEmulationPause (); - - int no_cursor; - g_config->getOption("SDL.NoFullscreenCursor", &no_cursor); - int fullscreen; - g_config->getOption ("SDL.Fullscreen", &fullscreen); - - // Don't touch grab when in windowed mode - if(fullscreen == 0) - return; - -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL2 -#else - if (FCEUI_EmulationPaused () == 0) - { - SDL_WM_GrabInput (SDL_GRAB_ON); - if(no_cursor) - SDL_ShowCursor (0); - } - else { - SDL_WM_GrabInput (SDL_GRAB_OFF); - SDL_ShowCursor (1); - } -#endif - return; -} - -/*** - * This function opens a file chooser dialog and returns the filename the - * user selected. - * */ -std::string GetFilename (const char *title, bool save, const char *filter) -{ - if (FCEUI_EmulationPaused () == 0) - FCEUI_ToggleEmulationPause (); - std::string fname = ""; - -#ifdef WIN32 - OPENFILENAME ofn; // common dialog box structure - char szFile[260]; // buffer for file name - HWND hwnd; // owner window - HANDLE hf; // file handle - - // Initialize OPENFILENAME - memset (&ofn, 0, sizeof (ofn)); - ofn.lStructSize = sizeof (ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFile = szFile; - // Set lpstrFile[0] to '\0' so that GetOpenFileName does not - // use the contents of szFile to initialize itself. - ofn.lpstrFile[0] = '\0'; - ofn.nMaxFile = sizeof (szFile); - ofn.lpstrFilter = "All\0*.*\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFileTitle = NULL; - ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - // Display the Open dialog box. - fname = GetOpenFileName (&ofn); - -#endif -#ifdef _GTK - int fullscreen = 0; - g_config->getOption ("SDL.Fullscreen", &fullscreen); - if (fullscreen) - ToggleFS (); - - GtkWidget *fileChooser; - - GtkFileFilter *filterX; - GtkFileFilter *filterAll; - - filterX = gtk_file_filter_new (); - gtk_file_filter_add_pattern (filterX, filter); - gtk_file_filter_set_name (filterX, filter); - - - filterAll = gtk_file_filter_new (); - gtk_file_filter_add_pattern (filterAll, "*"); - gtk_file_filter_set_name (filterAll, "All Files"); - - if (save) - fileChooser = gtk_file_chooser_dialog_new ("Save as", NULL, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE_AS, - GTK_RESPONSE_ACCEPT, NULL); - else - fileChooser = gtk_file_chooser_dialog_new ("Open", NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, - GTK_RESPONSE_ACCEPT, NULL); - - // TODO: make file filters case insensitive - //gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterX); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fileChooser), filterAll); - int response = gtk_dialog_run (GTK_DIALOG (fileChooser)); - - // flush gtk events - while (gtk_events_pending ()) - gtk_main_iteration_do (TRUE); - - if (response == GTK_RESPONSE_ACCEPT) - fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)); - - gtk_widget_destroy (fileChooser); - - while (gtk_events_pending ()) - gtk_main_iteration_do (TRUE); -#endif - FCEUI_ToggleEmulationPause (); - return fname; -} - -/** - * This function opens a text entry dialog and returns the user's input - */ -std::string GetUserText (const char *title) -{ -#ifdef _GTK -/* prg318 - 10/13/11 - this is broken in recent build and causes - * segfaults/very weird behavior i'd rather remove it for now than it cause - * accidental segfaults - * TODO fix it -*/ -#if 0 - - GtkWidget* d; - GtkWidget* entry; - - d = gtk_dialog_new_with_buttons(title, NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK); - - entry = gtk_entry_new(); - - GtkWidget* vbox = gtk_dialog_get_content_area(GTK_DIALOG(d)); - - gtk_container_add(GTK_CONTAINER(vbox), entry); - - gtk_widget_show_all(d); - - gtk_dialog_run(GTK_DIALOG(d)); - - // flush gtk events - while(gtk_events_pending()) - gtk_main_iteration_do(TRUE); - - std::string input = gtk_entry_get_text(GTK_ENTRY(entry)); - - if (FCEUI_EmulationPaused() == 0) - FCEUI_ToggleEmulationPause(); // pause emulation - - int fullscreen = 0; - g_config->getOption("SDL.Fullscreen", &fullscreen); - if(fullscreen) - ToggleFS(); // disable fullscreen emulation - - FILE *fpipe; - std::string command = "zenity --entry --title=\""; - command.append(title); - command.append("\" --text=\""); - command.append(title); - command.append(":\""); - - if (!(fpipe = (FILE*)popen(command.c_str(),"r"))) // If fpipe is NULL - FCEUD_PrintError("Pipe error on opening zenity"); - int c; - std::string input; - while((c = fgetc(fpipe))) - { - if (c == EOF || c == '\n') - break; - input += c; - } - pclose(fpipe); - gtk_widget_destroy(d); - - - while(gtk_events_pending()) - gtk_main_iteration_do(TRUE); - - FCEUI_ToggleEmulationPause(); // unpause emulation - return input; -#endif // #if 0 -#endif - return ""; -} - - -/** -* Lets the user start a new .fm2 movie file -**/ -void FCEUD_MovieRecordTo () -{ - std::string fname = GetFilename ("Save FM2 movie for recording", true, "FM2 movies|*.fm2"); - if (!fname.size ()) - return; // no filename selected, quit the whole thing - std::wstring author = mbstowcs (GetUserText ("Author name")); // the author can be empty, so no need to check here - - FCEUI_SaveMovie (fname.c_str (), MOVIE_FLAG_FROM_POWERON, author); -} - - -/** -* Lets the user save a savestate to a specific file -**/ -void FCEUD_SaveStateAs () -{ - std::string fname = GetFilename ("Save savestate as...", true, "Savestates|*.fc0"); - if (!fname.size ()) - return; // no filename selected, quit the whole thing - - FCEUI_SaveState (fname.c_str ()); -} - -/** -* Lets the user load a savestate from a specific file -*/ -void FCEUD_LoadStateFrom () -{ - std::string fname = GetFilename ("Load savestate from...", false, "Savestates|*.fc?"); - if (!fname.size ()) - return; // no filename selected, quit the whole thing - - FCEUI_LoadState (fname.c_str ()); -} - -/** -* Hook for transformer board -*/ -unsigned int *GetKeyboard(void) -{ - int size = 256; -#if SDL_VERSION_ATLEAST(2, 0, 0) - Uint8* keystate = (Uint8*)SDL_GetKeyboardState(&size); -#else - Uint8* keystate = SDL_GetKeyState(&size); -#endif - return (unsigned int*)(keystate); -} - -/** - * Parse keyboard commands and execute accordingly. - */ -static void KeyboardCommands () -{ - int is_shift, is_alt; - - char *movie_fname = ""; - // get the keyboard input -#if SDL_VERSION_ATLEAST(1, 3, 0) - g_keyState = (Uint8*)SDL_GetKeyboardState (NULL); -#else - g_keyState = SDL_GetKeyState (NULL); -#endif - - // check if the family keyboard is enabled - if (CurInputType[2] == SIFC_FKB) - { -#if SDL_VERSION_ATLEAST(1, 3, 0) - // TODO - SDL2 - if (0) -#else - if (keyonly (SCROLLLOCK)) -#endif - { - g_fkbEnabled ^= 1; - FCEUI_DispMessage ("Family Keyboard %sabled.", 0, - g_fkbEnabled ? "en" : "dis"); - } -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL2 -#else - SDL_WM_GrabInput (g_fkbEnabled ? SDL_GRAB_ON : SDL_GRAB_OFF); -#endif - if (g_fkbEnabled) - { - return; - } - } - -#if SDL_VERSION_ATLEAST(2, 0, 0) - if (g_keyState[SDL_GetScancodeFromKey (SDLK_LSHIFT)] - || g_keyState[SDL_GetScancodeFromKey (SDLK_RSHIFT)]) -#else - if (g_keyState[SDLK_LSHIFT] || g_keyState[SDLK_RSHIFT]) -#endif - is_shift = 1; - else - is_shift = 0; -#if SDL_VERSION_ATLEAST(2, 0, 0) - if (g_keyState[SDL_GetScancodeFromKey (SDLK_LALT)] - || g_keyState[SDL_GetScancodeFromKey (SDLK_RALT)]) -#else - if (g_keyState[SDLK_LALT] || g_keyState[SDLK_RALT]) -#endif - { - is_alt = 1; -#if !SDL_VERSION_ATLEAST(2, 0, 0) - // workaround for GDK->SDL in GTK problems where ALT release is never - // getting sent - // I know this is sort of an ugly hack to fix this, but the bug is - // rather annoying - // prg318 10/23/11 - int fullscreen; - g_config->getOption ("SDL.Fullscreen", &fullscreen); - if (!fullscreen) - { - g_keyState[SDLK_LALT] = 0; - g_keyState[SDLK_RALT] = 0; - } -#endif - } - else - is_alt = 0; - - - if (_keyonly (Hotkeys[HK_TOGGLE_BG])) - { - if (is_shift) - { - FCEUI_SetRenderPlanes (true, false); - } - else - { - FCEUI_SetRenderPlanes (true, true); - } - } - - // Alt-Enter to toggle full-screen - if (keyonly (ENTER) && is_alt) - { - ToggleFS (); - } - - - - // Toggle Movie auto-backup - if (keyonly (M) && is_shift) - { - autoMovieBackup ^= 1; - FCEUI_DispMessage ("Automatic movie backup %sabled.", 0, - autoMovieBackup ? "en" : "dis"); - } - - // Start recording an FM2 movie on Alt+R - if (keyonly (R) && is_alt) - { - FCEUD_MovieRecordTo (); - } - - // Save a state from a file - if (keyonly (S) && is_alt) - { - FCEUD_SaveStateAs (); - } - - // Load a state from a file - if (keyonly (L) && is_alt) - { - FCEUD_LoadStateFrom (); - } - - // Famicom disk-system games - if (gametype == GIT_FDS) - { - if (_keyonly (Hotkeys[HK_FDS_SELECT])) - { - FCEUI_FDSSelect (); - } - if (_keyonly (Hotkeys[HK_FDS_EJECT])) - { - FCEUI_FDSInsert (); - } - } - - if (_keyonly (Hotkeys[HK_SCREENSHOT])) - { - FCEUI_SaveSnapshot (); - } - - // if not NES Sound Format - if (gametype != GIT_NSF) - { - if (_keyonly (Hotkeys[HK_CHEAT_MENU])) - { - DoCheatSeq (); - } - - // f5 (default) save key, hold shift to save movie - if (_keyonly (Hotkeys[HK_SAVE_STATE])) - { - if (is_shift) - { - movie_fname = - const_cast (FCEU_MakeFName (FCEUMKF_MOVIE, 0, 0).c_str ()); - FCEUI_printf ("Recording movie to %s\n", movie_fname); - FCEUI_SaveMovie (movie_fname, MOVIE_FLAG_NONE, L""); - } - else - { - FCEUI_SaveState (NULL); - } - } - - // f7 to load state, Shift-f7 to load movie - if (_keyonly (Hotkeys[HK_LOAD_STATE])) - { - if (is_shift) - { - FCEUI_StopMovie (); - std::string fname; - fname = - GetFilename ("Open FM2 movie for playback...", false, - "FM2 movies|*.fm2"); - if (fname != "") - { - if (fname.find (".fm2") != std::string::npos - || fname.find (".fm3") != std::string::npos) - { - FCEUI_printf ("Playing back movie located at %s\n", - fname.c_str ()); - FCEUI_LoadMovie (fname.c_str (), false, false); - } - else - { - FCEUI_printf - ("Only .fm2 and .fm3 movies are supported.\n"); - } - } - } - else - { - FCEUI_LoadState(NULL); - } - } - } - - - if (_keyonly (Hotkeys[HK_DECREASE_SPEED])) - { - DecreaseEmulationSpeed (); - } - - if (_keyonly (Hotkeys[HK_INCREASE_SPEED])) - { - IncreaseEmulationSpeed (); - } - - if (_keyonly (Hotkeys[HK_TOGGLE_FRAME_DISPLAY])) - { - FCEUI_MovieToggleFrameDisplay (); - } - - if (_keyonly (Hotkeys[HK_TOGGLE_INPUT_DISPLAY])) - { - FCEUI_ToggleInputDisplay (); - extern int input_display; - g_config->setOption ("SDL.InputDisplay", input_display); - } - - if (_keyonly (Hotkeys[HK_MOVIE_TOGGLE_RW])) - { - FCEUI_SetMovieToggleReadOnly (!FCEUI_GetMovieToggleReadOnly ()); - } - -#ifdef CREATE_AVI - if (_keyonly (Hotkeys[HK_MUTE_CAPTURE])) - { - extern int mutecapture; - mutecapture ^= 1; - } -#endif - - if (_keyonly (Hotkeys[HK_PAUSE])) - { - //FCEUI_ToggleEmulationPause(); - // use the wrapper function instead of the fceui function directly - // so we can handle cursor grabbage - TogglePause (); - } - - // Toggle throttling - NoWaiting &= ~1; - if (g_keyState[Hotkeys[HK_TURBO]]) - { - NoWaiting |= 1; - } - - static bool frameAdvancing = false; - if (g_keyState[Hotkeys[HK_FRAME_ADVANCE]]) - { - if (frameAdvancing == false) - { - FCEUI_FrameAdvance (); - frameAdvancing = true; - } - } - else - { - if (frameAdvancing) - { - FCEUI_FrameAdvanceEnd (); - frameAdvancing = false; - } - } - - if (_keyonly (Hotkeys[HK_RESET])) - { - FCEUI_ResetNES (); - } - //if(_keyonly(Hotkeys[HK_POWER])) { - // FCEUI_PowerNES(); - //} - if (_keyonly (Hotkeys[HK_QUIT])) - { - if (noGui == 1) - { - CloseGame (); - } - else - { - CloseGame(); - FCEUI_Kill(); - SDL_Quit(); - exit(0); - } - } - else -#ifdef _S9XLUA_H - if (_keyonly (Hotkeys[HK_LOAD_LUA])) - { - std::string fname; - fname = GetFilename ("Open LUA script...", false, "Lua scripts|*.lua"); - if (fname != "") - FCEU_LoadLuaCode (fname.c_str ()); - } -#endif - - for (int i = 0; i < 10; i++) - if (_keyonly (Hotkeys[HK_SELECT_STATE_0 + i])) - { -#ifdef _GTK - gtk_radio_action_set_current_value (stateSlot, i); -#endif - FCEUI_SelectState (i, 1); - } - - if (_keyonly (Hotkeys[HK_SELECT_STATE_NEXT])) - { - FCEUI_SelectStateNext (1); - } - - if (_keyonly (Hotkeys[HK_SELECT_STATE_PREV])) - { - FCEUI_SelectStateNext (-1); - } - - if (_keyonly (Hotkeys[HK_BIND_STATE])) - { - bindSavestate ^= 1; - FCEUI_DispMessage ("Savestate binding to movie %sabled.", 0, - bindSavestate ? "en" : "dis"); - } - - if (_keyonly (Hotkeys[HK_FA_LAG_SKIP])) - { - frameAdvanceLagSkip ^= 1; - FCEUI_DispMessage ("Skipping lag in Frame Advance %sabled.", 0, - frameAdvanceLagSkip ? "en" : "dis"); - } - - if (_keyonly (Hotkeys[HK_LAG_COUNTER_DISPLAY])) - { - lagCounterDisplay ^= 1; - } - - if (_keyonly (Hotkeys[HK_TOGGLE_SUBTITLE])) - { - extern int movieSubtitles; - movieSubtitles ^= 1; - FCEUI_DispMessage ("Movie subtitles o%s.", 0, - movieSubtitles ? "n" : "ff"); - } - - // VS Unisystem games - if (gametype == GIT_VSUNI) - { - // insert coin - if (_keyonly (Hotkeys[HK_VS_INSERT_COIN])) - FCEUI_VSUniCoin (); - - // toggle dipswitch display - if (_keyonly (Hotkeys[HK_VS_TOGGLE_DIPSWITCH])) - { - DIPS ^= 1; - FCEUI_VSUniToggleDIPView (); - } - if (!(DIPS & 1)) - goto DIPSless; - - // toggle the various dipswitches - for(int i=1; i<=8;i++) - { - if(keyonly(i)) - FCEUI_VSUniToggleDIP(i-1); - } - } - else - { - static uint8 bbuf[32]; - static int bbuft; - static int barcoder = 0; - - if (keyonly (H)) - FCEUI_NTSCSELHUE (); - if (keyonly (T)) - FCEUI_NTSCSELTINT (); - - if (_keyonly (Hotkeys[HK_DECREASE_SPEED])) - FCEUI_NTSCDEC (); - if (_keyonly (Hotkeys[HK_INCREASE_SPEED])) - FCEUI_NTSCINC (); - - if ((CurInputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) - { - if (keyonly (F8)) - { - barcoder ^= 1; - if (!barcoder) - { - if (CurInputType[2] == SIFC_BWORLD) - { - strcpy ((char *) &BWorldData[1], (char *) bbuf); - BWorldData[0] = 1; - } - else - { - FCEUI_DatachSet (bbuf); - } - FCEUI_DispMessage ("Barcode Entered", 0); - } - else - { - bbuft = 0; - FCEUI_DispMessage ("Enter Barcode", 0); - } - } - } - else - { - barcoder = 0; - } - -#define SSM(x) \ -do { \ - if(barcoder) { \ - if(bbuft < 13) { \ - bbuf[bbuft++] = '0' + x; \ - bbuf[bbuft] = 0; \ - } \ - FCEUI_DispMessage("Barcode: %s",0, bbuf); \ - } \ -} while(0) - - DIPSless: - for(int i=0; i<10;i++) - { - if (keyonly (i)) - SSM (i); - } -#undef SSM - } -} - -/** - * Return the state of the mouse buttons. Input 'd' is an array of 3 - * integers that store . - */ -void // removed static for a call in lua-engine.cpp -GetMouseData (uint32 (&d)[3]) -{ - int x, y; - uint32 t; - - // Don't get input when a movie is playing back - if (FCEUMOV_Mode (MOVIEMODE_PLAY)) - return; - - // retrieve the state of the mouse from SDL - t = SDL_GetMouseState (&x, &y); -#ifdef _GTK - if (noGui == 0) - { - // don't ask for gtk mouse info when in fullscreen - // we can use sdl directly in fullscreen - int fullscreen = 0; - g_config->getOption ("SDL.Fullscreen", &fullscreen); - if (fullscreen == 0) - { - x = GtkMouseData[0]; - y = GtkMouseData[1]; - t = GtkMouseData[2]; - } - } -#endif - - d[2] = 0; - if (t & SDL_BUTTON (1)) - { - d[2] |= 0x1; - } - if (t & SDL_BUTTON (3)) - { - d[2] |= 0x2; - } - - // get the mouse position from the SDL video driver - t = PtoV (x, y); - d[0] = t & 0xFFFF; - d[1] = (t >> 16) & 0xFFFF; - // debug print - // printf("mouse %d %d %d\n", d[0], d[1], d[2]); -} - -/** - * Handles outstanding SDL events. - */ -static void -UpdatePhysicalInput () -{ - SDL_Event event; - - // loop, handling all pending events - while (SDL_PollEvent (&event)) - { - switch (event.type) - { - case SDL_QUIT: - CloseGame (); - puts ("Quit"); - break; - case SDL_FCEU_HOTKEY_EVENT: - switch (event.user.code) - { - case HK_PAUSE: - TogglePause (); - break; - default: - FCEU_printf ("Warning: unknown hotkey event %d\n", - event.user.code); - } - default: - break; - } - } - //SDL_PumpEvents(); -} - - -static int bcpv, bcpj; - -/** - * Begin configuring the buttons by placing the video and joystick - * subsystems into a well-known state. Button configuration really - * needs to be cleaned up after the new config system is in place. - */ -int ButtonConfigBegin () -{ -//dont shut down video subsystem if we are using gtk to prevent the sdl window from becoming detached to GTK window -// prg318 - 10-2-2011 -#ifdef _GTK - int noGui; - g_config->getOption ("SDL.NoGUI", &noGui); - if (noGui == 1) - { - SDL_QuitSubSystem (SDL_INIT_VIDEO); - bcpv = KillVideo (); - } -#else - // XXX soules - why are we doing this right before KillVideo()? - SDL_QuitSubSystem (SDL_INIT_VIDEO); - - // shut down the video and joystick subsystems - bcpv = KillVideo (); -#endif - SDL_Surface *screen; - - bcpj = KillJoysticks (); - - // reactivate the video subsystem - if (!SDL_WasInit (SDL_INIT_VIDEO)) - { - if (!bcpv) - { - InitVideo (GameInfo); - } - else - { -#if defined(_GTK) && defined(SDL_VIDEO_DRIVER_X11) - if (noGui == 0) - { - while (gtk_events_pending ()) - gtk_main_iteration_do (FALSE); - - char SDL_windowhack[128]; - if (gtk_widget_get_window (evbox)) - sprintf (SDL_windowhack, "SDL_WINDOWID=%u", - (unsigned int) GDK_WINDOW_XID (gtk_widget_get_window (evbox))); -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL2 -#else - SDL_putenv (SDL_windowhack); -#endif - } -#endif - if (SDL_InitSubSystem (SDL_INIT_VIDEO) == -1) - { - FCEUD_Message (SDL_GetError ()); - return 0; - } - - // set the screen and notify the user of button configuration -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL2 -#else - screen = SDL_SetVideoMode (420, 200, 8, 0); - SDL_WM_SetCaption ("Button Config", 0); -#endif - } - } - - // XXX soules - why did we shut this down? - // initialize the joystick subsystem - InitJoysticks (); - - return 1; -} - -/** - * Finish configuring the buttons by reverting the video and joystick - * subsystems to their previous state. Button configuration really - * needs to be cleaned up after the new config system is in place. - */ -void -ButtonConfigEnd () -{ - // shutdown the joystick and video subsystems - KillJoysticks (); - //SDL_QuitSubSystem(SDL_INIT_VIDEO); - - // re-initialize joystick and video subsystems if they were active before - /*if(!bcpv) { - InitVideo(GameInfo); - } */ - if (!bcpj) - { - InitJoysticks (); - } -} - -/** - * Tests to see if a specified button is currently pressed. - */ -static int -DTestButton (ButtConfig * bc) -{ - int x; - - for (x = 0; x < bc->NumC; x++) - { - if (bc->ButtType[x] == BUTTC_KEYBOARD) - { -#if SDL_VERSION_ATLEAST(2, 0, 0) - if (g_keyState[SDL_GetScancodeFromKey (bc->ButtonNum[x])]) - { -#else - if (g_keyState[bc->ButtonNum[x]]) - { -#endif - return 1; - } - } - else if (bc->ButtType[x] == BUTTC_JOYSTICK) - { - if (DTestButtonJoy (bc)) - { - return 1; - } - } - } - return 0; -} - - -#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1} -#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2} -#define MKZ() {{0},{0},{0},0} -#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()} - -ButtConfig GamePadConfig[4][10] = { -#if SDL_VERSION_ATLEAST(2, 0, 0) -/* Gamepad 1 */ - {MK (KP_3), MK (KP_2), MK (SLASH), MK (ENTER), - MK (W), MK (Z), MK (A), MK (S), MKZ (), MKZ ()}, -#else - /* Gamepad 1 */ - {MK (KP3), MK (KP2), MK (SLASH), MK (ENTER), - MK (W), MK (Z), MK (A), MK (S), MKZ (), MKZ ()}, -#endif - - /* Gamepad 2 */ - GPZ (), - - /* Gamepad 3 */ - GPZ (), - - /* Gamepad 4 */ - GPZ () -}; - -/** - * Update the status of the gamepad input devices. - */ -static void -UpdateGamepad(void) -{ - // don't update during movie playback - if (FCEUMOV_Mode (MOVIEMODE_PLAY)) - { - return; - } - - static int rapid = 0; - uint32 JS = 0; - int x; - int wg; - - rapid ^= 1; - - int opposite_dirs; - g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs); - - // go through each of the four game pads - for (wg = 0; wg < 4; wg++) - { - bool left = false; - bool up = false; - // a, b, select, start, up, down, left, right - for (x = 0; x < 8; x++) - { - if (DTestButton (&GamePadConfig[wg][x])) - { - if(opposite_dirs == 0) - { - // test for left+right and up+down - if(x == 4){ - up = true; - } - if((x == 5) && (up == true)){ - continue; - } - if(x == 6){ - left = true; - } - if((x == 7) && (left == true)){ - continue; - } - } - JS |= (1 << x) << (wg << 3); - } - } - - int four_button_exit; - g_config->getOption("SDL.ABStartSelectExit", &four_button_exit); - // if a+b+start+select is pressed, exit - if (four_button_exit && JS == 15) { - FCEUI_printf("all buttons pressed, exiting\n"); - CloseGame(); - FCEUI_Kill(); - exit(0); - } - - // rapid-fire a, rapid-fire b - if (rapid) - { - for (x = 0; x < 2; x++) - { - if (DTestButton (&GamePadConfig[wg][8 + x])) - { - JS |= (1 << x) << (wg << 3); - } - } - } - } - -// for(x=0;x<32;x+=8) /* Now, test to see if anything weird(up+down at same time) -// is happening, and correct */ -// { -// if((JS & (0xC0<ButtType[which]) - { - case BUTTC_KEYBOARD: -#if SDL_VERSION_ATLEAST(2,0,0) - return SDL_GetKeyName (bc->ButtonNum[which]); -#else - return SDL_GetKeyName ((SDLKey) bc->ButtonNum[which]); -#endif - case BUTTC_JOYSTICK: - int joyNum, inputNum; - const char *inputType, *inputDirection; - - joyNum = bc->DeviceNum[which]; - - if (bc->ButtonNum[which] & 0x8000) - { - inputType = "Axis"; - inputNum = bc->ButtonNum[which] & 0x3FFF; - inputDirection = bc->ButtonNum[which] & 0x4000 ? "-" : "+"; - } - else if (bc->ButtonNum[which] & 0x2000) - { - int inputValue; - char direction[128] = ""; - - inputType = "Hat"; - inputNum = (bc->ButtonNum[which] >> 8) & 0x1F; - inputValue = bc->ButtonNum[which] & 0xF; - - if (inputValue & SDL_HAT_UP) - strncat (direction, "Up ", sizeof (direction)); - if (inputValue & SDL_HAT_DOWN) - strncat (direction, "Down ", sizeof (direction)); - if (inputValue & SDL_HAT_LEFT) - strncat (direction, "Left ", sizeof (direction)); - if (inputValue & SDL_HAT_RIGHT) - strncat (direction, "Right ", sizeof (direction)); - - if (direction[0]) - inputDirection = direction; - else - inputDirection = "Center"; - } - else - { - inputType = "Button"; - inputNum = bc->ButtonNum[which]; - inputDirection = ""; - } - } - - return name; -} - -/** - * Waits for a button input and returns the information as to which - * button was pressed. Used in button configuration. - */ -int DWaitButton (const uint8 * text, ButtConfig * bc, int wb) -{ - SDL_Event event; - static int32 LastAx[64][64]; - int x, y; - - if (text) - { - std::string title = "Press a key for "; - title += (const char *) text; -#if SDL_VERSION_ATLEAST(2,0,0) - // TODO - SDL2 -#else - SDL_WM_SetCaption (title.c_str (), 0); -#endif - puts ((const char *) text); - } - - for (x = 0; x < 64; x++) - { - for (y = 0; y < 64; y++) - { - LastAx[x][y] = 0x100000; - } - } - - while (1) - { - int done = 0; -#ifdef _GTK - while (gtk_events_pending ()) - gtk_main_iteration_do (FALSE); -#endif - while (SDL_PollEvent (&event)) - { - done++; - switch (event.type) - { - case SDL_KEYDOWN: - bc->ButtType[wb] = BUTTC_KEYBOARD; - bc->DeviceNum[wb] = 0; - bc->ButtonNum[wb] = event.key.keysym.sym; - return (1); - case SDL_JOYBUTTONDOWN: - bc->ButtType[wb] = BUTTC_JOYSTICK; - bc->DeviceNum[wb] = event.jbutton.which; - bc->ButtonNum[wb] = event.jbutton.button; - return (1); - case SDL_JOYHATMOTION: - if (event.jhat.value == SDL_HAT_CENTERED) - done--; - else - { - bc->ButtType[wb] = BUTTC_JOYSTICK; - bc->DeviceNum[wb] = event.jhat.which; - bc->ButtonNum[wb] = - (0x2000 | ((event.jhat.hat & 0x1F) << 8) | event. - jhat.value); - return (1); - } - break; - case SDL_JOYAXISMOTION: - if (LastAx[event.jaxis.which][event.jaxis.axis] == 0x100000) - { - if (abs (event.jaxis.value) < 1000) - { - LastAx[event.jaxis.which][event.jaxis.axis] = - event.jaxis.value; - } - done--; - } - else - { - if (abs - (LastAx[event.jaxis.which][event.jaxis.axis] - - event.jaxis.value) >= 8192) - { - bc->ButtType[wb] = BUTTC_JOYSTICK; - bc->DeviceNum[wb] = event.jaxis.which; - bc->ButtonNum[wb] = (0x8000 | event.jaxis.axis | - ((event.jaxis.value < 0) - ? 0x4000 : 0)); - return (1); - } - else - done--; - } - break; - default: - done--; - } - } - if (done) - break; - } - - return (0); -} - -/** - * This function takes in button inputs until either it sees two of - * the same button presses in a row or gets four inputs and then saves - * the total number of button presses. Each of the keys pressed is - * used as input for the specified button, thus allowing up to four - * possible settings for each input button. - */ - void -ConfigButton (char *text, ButtConfig * bc) -{ - uint8 buf[256]; - int wc; - - for (wc = 0; wc < MAXBUTTCONFIG; wc++) - { - sprintf ((char *) buf, "%s (%d)", text, wc + 1); - DWaitButton (buf, bc, wc); - - if (wc && - bc->ButtType[wc] == bc->ButtType[wc - 1] && - bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] && - bc->ButtonNum[wc] == bc->ButtonNum[wc - 1]) - { - break; - } - } - bc->NumC = wc; -} - -/** - * Update the button configuration for a specified device. - */ -extern Config *g_config; - -void ConfigDevice (int which, int arg) -{ - char buf[256]; - int x; - std::string prefix; - char *str[10] = - { "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A", - "Rapid B" - }; - - // XXX soules - set the configuration options so that later calls - // don't override these. This is a temp hack until I - // can clean up this file. - - ButtonConfigBegin (); - switch (which) - { - case FCFGD_QUIZKING: - prefix = "SDL.Input.QuizKing."; - for (x = 0; x < 6; x++) - { - sprintf (buf, "Quiz King Buzzer #%d", x + 1); - ConfigButton (buf, &QuizKingButtons[x]); - - g_config->setOption (prefix + QuizKingNames[x], - QuizKingButtons[x].ButtonNum[0]); - } - - if (QuizKingButtons[0].ButtType[0] == BUTTC_KEYBOARD) - { - g_config->setOption (prefix + "DeviceType", "Keyboard"); - } - else if (QuizKingButtons[0].ButtType[0] == BUTTC_JOYSTICK) - { - g_config->setOption (prefix + "DeviceType", "Joystick"); - } - else - { - g_config->setOption (prefix + "DeviceType", "Unknown"); - } - g_config->setOption (prefix + "DeviceNum", - QuizKingButtons[0].DeviceNum[0]); - break; - case FCFGD_HYPERSHOT: - prefix = "SDL.Input.HyperShot."; - for (x = 0; x < 4; x++) - { - sprintf (buf, "Hyper Shot %d: %s", - ((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN"); - ConfigButton (buf, &HyperShotButtons[x]); - - g_config->setOption (prefix + HyperShotNames[x], - HyperShotButtons[x].ButtonNum[0]); - } - - if (HyperShotButtons[0].ButtType[0] == BUTTC_KEYBOARD) - { - g_config->setOption (prefix + "DeviceType", "Keyboard"); - } - else if (HyperShotButtons[0].ButtType[0] == BUTTC_JOYSTICK) - { - g_config->setOption (prefix + "DeviceType", "Joystick"); - } - else - { - g_config->setOption (prefix + "DeviceType", "Unknown"); - } - g_config->setOption (prefix + "DeviceNum", - HyperShotButtons[0].DeviceNum[0]); - break; - case FCFGD_POWERPAD: - snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1)); - prefix = buf; - for (x = 0; x < 12; x++) - { - sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11); - ConfigButton (buf, &powerpadsc[arg & 1][x]); - - g_config->setOption (prefix + PowerPadNames[x], - powerpadsc[arg & 1][x].ButtonNum[0]); - } - - if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_KEYBOARD) - { - g_config->setOption (prefix + "DeviceType", "Keyboard"); - } - else if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_JOYSTICK) - { - g_config->setOption (prefix + "DeviceType", "Joystick"); - } - else - { - g_config->setOption (prefix + "DeviceType", "Unknown"); - } - g_config->setOption (prefix + "DeviceNum", - powerpadsc[arg & 1][0].DeviceNum[0]); - break; - - case FCFGD_GAMEPAD: - snprintf (buf, 256, "SDL.Input.GamePad.%d", arg); - prefix = buf; - for (x = 0; x < 10; x++) - { - sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]); - ConfigButton (buf, &GamePadConfig[arg][x]); - - g_config->setOption (prefix + GamePadNames[x], - GamePadConfig[arg][x].ButtonNum[0]); - } - - if (GamePadConfig[arg][0].ButtType[0] == BUTTC_KEYBOARD) - { - g_config->setOption (prefix + "DeviceType", "Keyboard"); - } - else if (GamePadConfig[arg][0].ButtType[0] == BUTTC_JOYSTICK) - { - g_config->setOption (prefix + "DeviceType", "Joystick"); - } - else - { - g_config->setOption (prefix + "DeviceType", "Unknown"); - } - g_config->setOption (prefix + "DeviceNum", - GamePadConfig[arg][0].DeviceNum[0]); - break; - } - - ButtonConfigEnd (); -} - - -/** - * Update the button configuration for a device, specified by a text string. - */ -void InputCfg (const std::string & text) -{ -#ifdef _GTK - // enable noGui to prevent the gtk x11 hack from executing - noGui = 1; - // this is only called at the begininng of execution; make sure the video subsystem is initialized - InitVideo (GameInfo); -#endif - - if (noGui) - { - if (text.find ("gamepad") != std::string::npos) - { - int device = (text[strlen ("gamepad")] - '1'); - if (device < 0 || device > 3) - { - FCEUD_PrintError - ("Invalid gamepad device specified; must be one of gamepad1 through gamepad4"); - exit (-1); - } - ConfigDevice (FCFGD_GAMEPAD, device); - } - else if (text.find ("powerpad") != std::string::npos) - { - int device = (text[strlen ("powerpad")] - '1'); - if (device < 0 || device > 1) - { - FCEUD_PrintError - ("Invalid powerpad device specified; must be powerpad1 or powerpad2"); - exit (-1); - } - ConfigDevice (FCFGD_POWERPAD, device); - } - else if (text.find ("hypershot") != std::string::npos) - { - ConfigDevice (FCFGD_HYPERSHOT, 0); - } - else if (text.find ("quizking") != std::string::npos) - { - ConfigDevice (FCFGD_QUIZKING, 0); - } - } - else - printf ("Please run \"fceux --nogui\" before using --inputcfg\n"); - -} - - -/** - * Hack to map the new configuration onto the existing button - * configuration management. Will probably want to change this in the - * future - soules. - */ - void -UpdateInput (Config * config) -{ - char buf[64]; - std::string device, prefix; - - for (unsigned int i = 0; i < 3; i++) - { - snprintf (buf, 64, "SDL.Input.%d", i); - config->getOption (buf, &device); - - if (device == "None") - { - UsrInputType[i] = SI_NONE; - } - else if (device.find ("GamePad") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_GAMEPAD : (int) SIFC_NONE; - } - else if (device.find ("PowerPad.0") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_POWERPADA : (int) SIFC_NONE; - } - else if (device.find ("PowerPad.1") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_POWERPADB : (int) SIFC_NONE; - } - else if (device.find ("QuizKing") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_QUIZKING; - } - else if (device.find ("HyperShot") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_HYPERSHOT; - } - else if (device.find ("Mahjong") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_MAHJONG; - } - else if (device.find ("TopRider") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_TOPRIDER; - } - else if (device.find ("FTrainer") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_FTRAINERA; - } - else if (device.find ("FamilyKeyBoard") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_FKB; - } - else if (device.find ("OekaKids") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_OEKAKIDS; - } - else if (device.find ("Arkanoid") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_ARKANOID : (int) SIFC_ARKANOID; - } - else if (device.find ("Shadow") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_SHADOW; - } - else if (device.find ("Zapper") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_ZAPPER : (int) SIFC_NONE; - } - else if (device.find ("BWorld") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_BWORLD; - } - else if (device.find ("4Player") != std::string::npos) - { - UsrInputType[i] = (i < 2) ? (int) SI_NONE : (int) SIFC_4PLAYER; - } - else - { - // Unknown device - UsrInputType[i] = SI_NONE; - } - } - - // update each of the devices' configuration structure - // XXX soules - this is temporary until this file is cleaned up to - // simplify the interface between configuration and - // structure data. This will likely include the - // removal of multiple input buttons for a single - // input device key. - int type, devnum, button; - - // gamepad 0 - 3 - for (unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) - { - char buf[64]; - snprintf (buf, 20, "SDL.Input.GamePad.%d.", i); - prefix = buf; - - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < GAMEPAD_NUM_BUTTONS; j++) - { - config->getOption (prefix + GamePadNames[j], &button); - - GamePadConfig[i][j].ButtType[0] = type; - GamePadConfig[i][j].DeviceNum[0] = devnum; - GamePadConfig[i][j].ButtonNum[0] = button; - GamePadConfig[i][j].NumC = 1; - } - } - - // PowerPad 0 - 1 - for (unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) - { - char buf[64]; - snprintf (buf, 20, "SDL.Input.PowerPad.%d.", i); - prefix = buf; - - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < POWERPAD_NUM_BUTTONS; j++) - { - config->getOption (prefix + PowerPadNames[j], &button); - - powerpadsc[i][j].ButtType[0] = type; - powerpadsc[i][j].DeviceNum[0] = devnum; - powerpadsc[i][j].ButtonNum[0] = button; - powerpadsc[i][j].NumC = 1; - } - } - - // QuizKing - prefix = "SDL.Input.QuizKing."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < QUIZKING_NUM_BUTTONS; j++) - { - config->getOption (prefix + QuizKingNames[j], &button); - - QuizKingButtons[j].ButtType[0] = type; - QuizKingButtons[j].DeviceNum[0] = devnum; - QuizKingButtons[j].ButtonNum[0] = button; - QuizKingButtons[j].NumC = 1; - } - - // HyperShot - prefix = "SDL.Input.HyperShot."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < HYPERSHOT_NUM_BUTTONS; j++) - { - config->getOption (prefix + HyperShotNames[j], &button); - - HyperShotButtons[j].ButtType[0] = type; - HyperShotButtons[j].DeviceNum[0] = devnum; - HyperShotButtons[j].ButtonNum[0] = button; - HyperShotButtons[j].NumC = 1; - } - - // Mahjong - prefix = "SDL.Input.Mahjong."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < MAHJONG_NUM_BUTTONS; j++) - { - config->getOption (prefix + MahjongNames[j], &button); - - MahjongButtons[j].ButtType[0] = type; - MahjongButtons[j].DeviceNum[0] = devnum; - MahjongButtons[j].ButtonNum[0] = button; - MahjongButtons[j].NumC = 1; - } - - // TopRider - prefix = "SDL.Input.TopRider."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < TOPRIDER_NUM_BUTTONS; j++) - { - config->getOption (prefix + TopRiderNames[j], &button); - - TopRiderButtons[j].ButtType[0] = type; - TopRiderButtons[j].DeviceNum[0] = devnum; - TopRiderButtons[j].ButtonNum[0] = button; - TopRiderButtons[j].NumC = 1; - } - - // FTrainer - prefix = "SDL.Input.FTrainer."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < FTRAINER_NUM_BUTTONS; j++) - { - config->getOption (prefix + FTrainerNames[j], &button); - - FTrainerButtons[j].ButtType[0] = type; - FTrainerButtons[j].DeviceNum[0] = devnum; - FTrainerButtons[j].ButtonNum[0] = button; - FTrainerButtons[j].NumC = 1; - } - - // FamilyKeyBoard - prefix = "SDL.Input.FamilyKeyBoard."; - config->getOption (prefix + "DeviceType", &device); - if (device.find ("Keyboard") != std::string::npos) - { - type = BUTTC_KEYBOARD; - } - else if (device.find ("Joystick") != std::string::npos) - { - type = BUTTC_JOYSTICK; - } - else - { - type = 0; - } - config->getOption (prefix + "DeviceNum", &devnum); - for (unsigned int j = 0; j < FAMILYKEYBOARD_NUM_BUTTONS; j++) - { - config->getOption (prefix + FamilyKeyBoardNames[j], &button); - - fkbmap[j].ButtType[0] = type; - fkbmap[j].DeviceNum[0] = devnum; - fkbmap[j].ButtonNum[0] = button; - fkbmap[j].NumC = 1; - } -} - -// Definitions from main.h: -// GamePad defaults -const char *GamePadNames[GAMEPAD_NUM_BUTTONS] = { "A", "B", "Select", "Start", - "Up", "Down", "Left", "Right", "TurboA", "TurboB" -}; -const char *DefaultGamePadDevice[GAMEPAD_NUM_DEVICES] = -{ "Keyboard", "None", "None", "None" }; -const int DefaultGamePad[GAMEPAD_NUM_DEVICES][GAMEPAD_NUM_BUTTONS] = -{ {SDLK_F, SDLK_D, SDLK_S, SDLK_RETURN, - SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, 0, 0}, -{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -{0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -}; - -// PowerPad defaults -const char *PowerPadNames[POWERPAD_NUM_BUTTONS] = -{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B" }; -const char *DefaultPowerPadDevice[POWERPAD_NUM_DEVICES] = -{ "Keyboard", "None" }; -const int DefaultPowerPad[POWERPAD_NUM_DEVICES][POWERPAD_NUM_BUTTONS] = -{ {SDLK_o, SDLK_p, SDLK_LEFTBRACKET, SDLK_RIGHTBRACKET, - SDLK_k, SDLK_l, SDLK_SEMICOLON, SDLK_QUOTE, - SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH}, -{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -}; - -// QuizKing defaults -const char *QuizKingNames[QUIZKING_NUM_BUTTONS] = -{ "0", "1", "2", "3", "4", "5" }; -const char *DefaultQuizKingDevice = "Keyboard"; -const int DefaultQuizKing[QUIZKING_NUM_BUTTONS] = -{ SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y }; - -// HyperShot defaults -const char *HyperShotNames[HYPERSHOT_NUM_BUTTONS] = { "0", "1", "2", "3" }; - -const char *DefaultHyperShotDevice = "Keyboard"; -const int DefaultHyperShot[HYPERSHOT_NUM_BUTTONS] = -{ SDLK_q, SDLK_w, SDLK_e, SDLK_r }; - -// Mahjong defaults -const char *MahjongNames[MAHJONG_NUM_BUTTONS] = -{ "00", "01", "02", "03", "04", "05", "06", "07", - "08", "09", "10", "11", "12", "13", "14", "15", - "16", "17", "18", "19", "20" -}; - -const char *DefaultMahjongDevice = "Keyboard"; -const int DefaultMahjong[MAHJONG_NUM_BUTTONS] = -{ SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_a, SDLK_s, SDLK_d, - SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_z, SDLK_x, - SDLK_c, SDLK_v, SDLK_b, SDLK_n, SDLK_m -}; - -// TopRider defaults -const char *TopRiderNames[TOPRIDER_NUM_BUTTONS] = -{ "0", "1", "2", "3", "4", "5", "6", "7" }; -const char *DefaultTopRiderDevice = "Keyboard"; -const int DefaultTopRider[TOPRIDER_NUM_BUTTONS] = -{ SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i }; - -// FTrainer defaults -const char *FTrainerNames[FTRAINER_NUM_BUTTONS] = -{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B" }; -const char *DefaultFTrainerDevice = "Keyboard"; -const int DefaultFTrainer[FTRAINER_NUM_BUTTONS] = -{ SDLK_o, SDLK_p, SDLK_LEFTBRACKET, SDLK_RIGHTBRACKET, - SDLK_k, SDLK_l, SDLK_SEMICOLON, SDLK_QUOTE, - SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH -}; - -// FamilyKeyBoard defaults -const char *FamilyKeyBoardNames[FAMILYKEYBOARD_NUM_BUTTONS] = -{ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", - "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", - "MINUS", "EQUAL", "BACKSLASH", "BACKSPACE", - "ESCAPE", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", - "P", "GRAVE", "BRACKET_LEFT", "ENTER", - "LEFTCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", - "L", "SEMICOLON", "APOSTROPHE", "BRACKET_RIGHT", "INSERT", - "LEFTSHIFT", "Z", "X", "C", "V", "B", "N", "M", "COMMA", - "PERIOD", "SLASH", "RIGHTALT", "RIGHTSHIFT", "LEFTALT", "SPACE", - "DELETE", "END", "PAGEDOWN", - "CURSORUP", "CURSORLEFT", "CURSORRIGHT", "CURSORDOWN" -}; - -const char *DefaultFamilyKeyBoardDevice = "Keyboard"; -const int DefaultFamilyKeyBoard[FAMILYKEYBOARD_NUM_BUTTONS] = -{ SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, - SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, - SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, - SDLK_MINUS, SDLK_EQUALS, SDLK_BACKSLASH, SDLK_BACKSPACE, - SDLK_ESCAPE, SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, - SDLK_i, SDLK_o, SDLK_p, SDLK_BACKQUOTE, SDLK_LEFTBRACKET, SDLK_RETURN, - SDLK_LCTRL, SDLK_a, SDLK_s, SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, - SDLK_k, SDLK_l, SDLK_SEMICOLON, SDLK_QUOTE, SDLK_RIGHTBRACKET, - SDLK_INSERT, SDLK_LSHIFT, SDLK_z, SDLK_x, SDLK_c, SDLK_v, SDLK_b, - SDLK_n, SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_RALT, - SDLK_RSHIFT, SDLK_LALT, SDLK_SPACE, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN, - SDLK_UP, SDLK_LEFT, SDLK_RIGHT, SDLK_DOWN -}; diff --git a/branches/fceux-2.2.2/src/drivers/sdl/main.h b/branches/fceux-2.2.2/src/drivers/sdl/main.h deleted file mode 100644 index fc9fefd5..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/main.h +++ /dev/null @@ -1,98 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __FCEU_SDL_MAIN_H -#define __FCEU_SDL_MAIN_H - -#include "../../driver.h" -#include "../common/config.h" -#include "../common/args.h" - -extern int eoptions; -#define EO_NO8LIM 1 -#define EO_SUBASE 2 -#define EO_CLIPSIDES 8 -#define EO_SNAPNAME 16 -#define EO_FOURSCORE 32 -#define EO_NOTHROTTLE 64 -#define EO_GAMEGENIE 128 -#define EO_PAL 256 -#define EO_LOWPASS 512 -#define EO_AUTOHIDE 1024 - -extern int _sound; -extern long soundrate; -extern long soundbufsize; - -int CLImain(int argc, char *argv[]); - -// Device management defaults -#define NUM_INPUT_DEVICES 3 - -// GamePad defaults -#define GAMEPAD_NUM_DEVICES 4 -#define GAMEPAD_NUM_BUTTONS 10 -extern const char *GamePadNames[GAMEPAD_NUM_BUTTONS]; -extern const char *DefaultGamePadDevice[GAMEPAD_NUM_DEVICES]; -extern const int DefaultGamePad[GAMEPAD_NUM_DEVICES][GAMEPAD_NUM_BUTTONS]; - -// PowerPad defaults -#define POWERPAD_NUM_DEVICES 2 -#define POWERPAD_NUM_BUTTONS 12 -extern const char *PowerPadNames[POWERPAD_NUM_BUTTONS]; -extern const char *DefaultPowerPadDevice[POWERPAD_NUM_DEVICES]; -extern const int DefaultPowerPad[POWERPAD_NUM_DEVICES][POWERPAD_NUM_BUTTONS]; - -// QuizKing defaults -#define QUIZKING_NUM_BUTTONS 6 -extern const char *QuizKingNames[QUIZKING_NUM_BUTTONS]; -extern const char *DefaultQuizKingDevice; -extern const int DefaultQuizKing[QUIZKING_NUM_BUTTONS]; - -// HyperShot defaults -#define HYPERSHOT_NUM_BUTTONS 4 -extern const char *HyperShotNames[HYPERSHOT_NUM_BUTTONS]; -extern const char *DefaultHyperShotDevice; -extern const int DefaultHyperShot[HYPERSHOT_NUM_BUTTONS]; - -// Mahjong defaults -#define MAHJONG_NUM_BUTTONS 21 -extern const char *MahjongNames[MAHJONG_NUM_BUTTONS]; -extern const char *DefaultMahjongDevice; -extern const int DefaultMahjong[MAHJONG_NUM_BUTTONS]; - -// TopRider defaults -#define TOPRIDER_NUM_BUTTONS 8 -extern const char *TopRiderNames[TOPRIDER_NUM_BUTTONS]; -extern const char *DefaultTopRiderDevice; -extern const int DefaultTopRider[TOPRIDER_NUM_BUTTONS]; - -// FTrainer defaults -#define FTRAINER_NUM_BUTTONS 12 -extern const char *FTrainerNames[FTRAINER_NUM_BUTTONS]; -extern const char *DefaultFTrainerDevice; -extern const int DefaultFTrainer[FTRAINER_NUM_BUTTONS]; - -// FamilyKeyBoard defaults -#define FAMILYKEYBOARD_NUM_BUTTONS 0x48 -extern const char *FamilyKeyBoardNames[FAMILYKEYBOARD_NUM_BUTTONS]; -extern const char *DefaultFamilyKeyBoardDevice; -extern const int DefaultFamilyKeyBoard[FAMILYKEYBOARD_NUM_BUTTONS]; - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/sdl/sdl-sound.cpp b/branches/fceux-2.2.2/src/drivers/sdl/sdl-sound.cpp deleted file mode 100644 index 55ef7679..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/sdl-sound.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/// \file -/// \brief Handles sound emulation using the SDL. - -#include "sdl.h" - -#include "../common/configSys.h" -#include "../../utils/memory.h" - -#include -#include -#include - -extern Config *g_config; - -static volatile int *s_Buffer = 0; -static unsigned int s_BufferSize; -static unsigned int s_BufferRead; -static unsigned int s_BufferWrite; -static volatile unsigned int s_BufferIn; - -static int s_mute = 0; - - -/** - * Callback from the SDL to get and play audio data. - */ -static void -fillaudio(void *udata, - uint8 *stream, - int len) -{ - int16 *tmps = (int16*)stream; - len >>= 1; - while(len) { - int16 sample = 0; - if(s_BufferIn) { - sample = s_Buffer[s_BufferRead]; - s_BufferRead = (s_BufferRead + 1) % s_BufferSize; - s_BufferIn--; - } else { - sample = 0; - } - - *tmps = sample; - tmps++; - len--; - } -} - -/** - * Initialize the audio subsystem. - */ -int -InitSound() -{ - int sound, soundrate, soundbufsize, soundvolume, soundtrianglevolume, soundsquare1volume, soundsquare2volume, soundnoisevolume, soundpcmvolume, soundq; - SDL_AudioSpec spec; - - g_config->getOption("SDL.Sound", &sound); - if(!sound) { - return 0; - } - - memset(&spec, 0, sizeof(spec)); - if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - puts(SDL_GetError()); - KillSound(); - return 0; - } - char driverName[8]; -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL 2 -#else - SDL_AudioDriverName(driverName, 8); - fprintf(stderr, "Loading SDL sound with %s driver...\n", driverName); -#endif - - // load configuration variables - g_config->getOption("SDL.Sound.Rate", &soundrate); - g_config->getOption("SDL.Sound.BufSize", &soundbufsize); - g_config->getOption("SDL.Sound.Volume", &soundvolume); - g_config->getOption("SDL.Sound.Quality", &soundq); - g_config->getOption("SDL.Sound.TriangleVolume", &soundtrianglevolume); - g_config->getOption("SDL.Sound.Square1Volume", &soundsquare1volume); - g_config->getOption("SDL.Sound.Square2Volume", &soundsquare2volume); - g_config->getOption("SDL.Sound.NoiseVolume", &soundnoisevolume); - g_config->getOption("SDL.Sound.PCMVolume", &soundpcmvolume); - - spec.freq = soundrate; - spec.format = AUDIO_S16SYS; - spec.channels = 1; - spec.samples = 512; - spec.callback = fillaudio; - spec.userdata = 0; - - s_BufferSize = soundbufsize * soundrate / 1000; - - // For safety, set a bare minimum: - if (s_BufferSize < spec.samples * 2) - s_BufferSize = spec.samples * 2; - - s_Buffer = (int *)FCEU_dmalloc(sizeof(int) * s_BufferSize); - if (!s_Buffer) - return 0; - s_BufferRead = s_BufferWrite = s_BufferIn = 0; - - if(SDL_OpenAudio(&spec, 0) < 0) - { - puts(SDL_GetError()); - KillSound(); - return 0; - } - SDL_PauseAudio(0); - - FCEUI_SetSoundVolume(soundvolume); - FCEUI_SetSoundQuality(soundq); - FCEUI_Sound(soundrate); - FCEUI_SetTriangleVolume(soundtrianglevolume); - FCEUI_SetSquare1Volume(soundsquare1volume); - FCEUI_SetSquare2Volume(soundsquare2volume); - FCEUI_SetNoiseVolume(soundnoisevolume); - FCEUI_SetPCMVolume(soundpcmvolume); - return 1; -} - - -/** - * Returns the size of the audio buffer. - */ -uint32 -GetMaxSound(void) -{ - return(s_BufferSize); -} - -/** - * Returns the amount of free space in the audio buffer. - */ -uint32 -GetWriteSound(void) -{ - return(s_BufferSize - s_BufferIn); -} - -/** - * Send a sound clip to the audio subsystem. - */ -void -WriteSound(int32 *buf, - int Count) -{ - extern int EmulationPaused; - if (EmulationPaused == 0) - while(Count) - { - while(s_BufferIn == s_BufferSize) - { - SDL_Delay(1); - } - - s_Buffer[s_BufferWrite] = *buf; - Count--; - s_BufferWrite = (s_BufferWrite + 1) % s_BufferSize; - - SDL_LockAudio(); - s_BufferIn++; - SDL_UnlockAudio(); - - buf++; - } -} - -/** - * Pause (1) or unpause (0) the audio output. - */ -void -SilenceSound(int n) -{ - SDL_PauseAudio(n); -} - -/** - * Shut down the audio subsystem. - */ -int -KillSound(void) -{ - FCEUI_Sound(0); - SDL_CloseAudio(); - SDL_QuitSubSystem(SDL_INIT_AUDIO); - if(s_Buffer) { - free((void *)s_Buffer); - s_Buffer = 0; - } - return 0; -} - - -/** - * Adjust the volume either down (-1), up (1), or to the default (0). - * Unmutes if mute was active before. - */ -void -FCEUD_SoundVolumeAdjust(int n) -{ - int soundvolume; - g_config->getOption("SDL.SoundVolume", &soundvolume); - - switch(n) { - case -1: - soundvolume -= 10; - if(soundvolume < 0) { - soundvolume = 0; - } - break; - case 0: - soundvolume = 100; - break; - case 1: - soundvolume += 10; - if(soundvolume > 150) { - soundvolume = 150; - } - break; - } - - s_mute = 0; - FCEUI_SetSoundVolume(soundvolume); - g_config->setOption("SDL.SoundVolume", soundvolume); - - FCEU_DispMessage("Sound volume %d.",0, soundvolume); -} - -/** - * Toggles the sound on or off. - */ -void -FCEUD_SoundToggle(void) -{ - if(s_mute) { - int soundvolume; - g_config->getOption("SDL.SoundVolume", &soundvolume); - - s_mute = 0; - FCEUI_SetSoundVolume(soundvolume); - FCEU_DispMessage("Sound mute off.",0); - } else { - s_mute = 1; - FCEUI_SetSoundVolume(0); - FCEU_DispMessage("Sound mute on.",0); - } -} diff --git a/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.cpp b/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.cpp deleted file mode 100644 index 88aacd3f..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.cpp +++ /dev/null @@ -1,841 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/// \file -/// \brief Handles the graphical game display for the SDL implementation. - -#include "sdl.h" -#include "sdl-opengl.h" -#include "../common/vidblit.h" -#include "../../fceu.h" -#include "../../version.h" -#include "../../video.h" - -#include "../../utils/memory.h" - -#include "sdl-icon.h" -#include "dface.h" - -#include "../common/configSys.h" -#include "sdl-video.h" - -#ifdef CREATE_AVI -#include "../videolog/nesvideos-piece.h" -#endif - -#ifdef _GTK -#include "gui.h" -#include -#endif - -#include -#include -#include - -// GLOBALS -extern Config *g_config; - -// STATIC GLOBALS -extern SDL_Surface *s_screen; - -static SDL_Surface *s_BlitBuf; // Buffer when using hardware-accelerated blits. -static SDL_Surface *s_IconSurface = NULL; - -static int s_curbpp; -static int s_srendline, s_erendline; -static int s_tlines; -static int s_inited; - -#ifdef OPENGL -static int s_useOpenGL; -#endif -static double s_exs, s_eys; -static int s_eefx; -static int s_clipSides; -static int s_fullscreen; -static int noframe; -static int s_nativeWidth = -1; -static int s_nativeHeight = -1; - -#define NWIDTH (256 - (s_clipSides ? 16 : 0)) -#define NOFFSET (s_clipSides ? 8 : 0) - -static int s_paletterefresh; - -extern bool MaxSpeed; - -/** - * Attempts to destroy the graphical video display. Returns 0 on - * success, -1 on failure. - */ - -//draw input aids if we are fullscreen -bool FCEUD_ShouldDrawInputAids() -{ - return s_fullscreen!=0; -} - -int -KillVideo() -{ - // if the IconSurface has been initialized, destroy it - if(s_IconSurface) { - SDL_FreeSurface(s_IconSurface); - s_IconSurface=0; - } - - // return failure if the video system was not initialized - if(s_inited == 0) - return -1; - - // if the rest of the system has been initialized, shut it down -#ifdef OPENGL - // check for OpenGL and shut it down - if(s_useOpenGL) - KillOpenGL(); - else -#endif - // shut down the system that converts from 8 to 16/32 bpp - if(s_curbpp > 8) - KillBlitToHigh(); - - // shut down the SDL video sub-system - SDL_QuitSubSystem(SDL_INIT_VIDEO); - - s_inited = 0; - return 0; -} - - -// this variable contains information about the special scaling filters -static int s_sponge; - -/** - * These functions determine an appropriate scale factor for fullscreen/ - */ -inline double GetXScale(int xres) -{ - return ((double)xres) / NWIDTH; -} -inline double GetYScale(int yres) -{ - return ((double)yres) / s_tlines; -} -void FCEUD_VideoChanged() -{ - int buf; - g_config->getOption("SDL.PAL", &buf); - if(buf) - PAL = 1; - else - PAL = 0; -} - -#if SDL_VERSION_ATLEAST(2, 0, 0) -int InitVideo(FCEUGI *gi) -{ - // This is a big TODO. Stubbing this off into its own function, - // as the SDL surface routines have changed drastically in SDL2 - // TODO - SDL2 -} -#else -/** - * Attempts to initialize the graphical video display. Returns 0 on - * success, -1 on failure. - */ -int -InitVideo(FCEUGI *gi) -{ - // XXX soules - const? is this necessary? - const SDL_VideoInfo *vinf; - int error, flags = 0; - int doublebuf, xstretch, ystretch, xres, yres, show_fps; - - FCEUI_printf("Initializing video..."); - - // load the relevant configuration variables - g_config->getOption("SDL.Fullscreen", &s_fullscreen); - g_config->getOption("SDL.DoubleBuffering", &doublebuf); -#ifdef OPENGL - g_config->getOption("SDL.OpenGL", &s_useOpenGL); -#endif - g_config->getOption("SDL.SpecialFilter", &s_sponge); - g_config->getOption("SDL.XStretch", &xstretch); - g_config->getOption("SDL.YStretch", &ystretch); - g_config->getOption("SDL.LastXRes", &xres); - g_config->getOption("SDL.LastYRes", &yres); - g_config->getOption("SDL.ClipSides", &s_clipSides); - g_config->getOption("SDL.NoFrame", &noframe); - g_config->getOption("SDL.ShowFPS", &show_fps); - - // check the starting, ending, and total scan lines - FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline); - s_tlines = s_erendline - s_srendline + 1; - - // check if we should auto-set x/y resolution - - // check for OpenGL and set the global flags -#if OPENGL - if(s_useOpenGL && !s_sponge) { - flags = SDL_OPENGL; - } -#endif - - // initialize the SDL video subsystem if it is not already active - if(!SDL_WasInit(SDL_INIT_VIDEO)) { - error = SDL_InitSubSystem(SDL_INIT_VIDEO); - if(error) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } - } - s_inited = 1; - - // shows the cursor within the display window - SDL_ShowCursor(1); - - // determine if we can allocate the display on the video card - vinf = SDL_GetVideoInfo(); - if(vinf->hw_available) { - flags |= SDL_HWSURFACE; - } - - // get the monitor's current resolution if we do not already have it - if(s_nativeWidth < 0) { - s_nativeWidth = vinf->current_w; - } - if(s_nativeHeight < 0) { - s_nativeHeight = vinf->current_h; - } - - // check to see if we are showing FPS - FCEUI_SetShowFPS(show_fps); - - // check if we are rendering fullscreen - if(s_fullscreen) { - int no_cursor; - g_config->getOption("SDL.NoFullscreenCursor", &no_cursor); - flags |= SDL_FULLSCREEN; - SDL_ShowCursor(!no_cursor); - } - else { - SDL_ShowCursor(1); - } - - if(noframe) { - flags |= SDL_NOFRAME; - } - - // gives the SDL exclusive palette control... ensures the requested colors - flags |= SDL_HWPALETTE; - - // enable double buffering if requested and we have hardware support -#ifdef OPENGL - if(s_useOpenGL) { - FCEU_printf("Initializing with OpenGL (Disable with '--opengl 0').\n"); - if(doublebuf) { - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - } - } else -#endif - if(doublebuf && (flags & SDL_HWSURFACE)) { - flags |= SDL_DOUBLEBUF; - } - - if(s_fullscreen) { - int desbpp, autoscale; - g_config->getOption("SDL.BitsPerPixel", &desbpp); - g_config->getOption("SDL.AutoScale", &autoscale); - if (autoscale) - { - double auto_xscale = GetXScale(xres); - double auto_yscale = GetYScale(yres); - double native_ratio = ((double)NWIDTH) / s_tlines; - double screen_ratio = ((double)xres) / yres; - int keep_ratio; - - g_config->getOption("SDL.KeepRatio", &keep_ratio); - - // Try to choose resolution - if (screen_ratio < native_ratio) - { - // The screen is narrower than the original. Maximizing width will not clip - auto_xscale = auto_yscale = GetXScale(xres); - if (keep_ratio) - auto_yscale = GetYScale(yres); - } - else - { - auto_yscale = auto_xscale = GetYScale(yres); - if (keep_ratio) - auto_xscale = GetXScale(xres); - } - s_exs = auto_xscale; - s_eys = auto_yscale; - } - else - { - g_config->getOption("SDL.XScale", &s_exs); - g_config->getOption("SDL.YScale", &s_eys); - } - g_config->getOption("SDL.SpecialFX", &s_eefx); - -#ifdef OPENGL - if(!s_useOpenGL) { - s_exs = (int)s_exs; - s_eys = (int)s_eys; - } else { - desbpp = 0; - } - - // -Video Modes Tag- - if(s_sponge) { - if(s_sponge == 4 || s_sponge == 5) { - s_exs = s_eys = 3; - } else { - s_exs = s_eys = 2; - } - s_eefx = 0; - if(s_sponge == 1 || s_sponge == 4) { - desbpp = 32; - } - } - - if((s_useOpenGL && !xstretch) || !s_useOpenGL) -#endif - if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) { - FCEUD_PrintError("xscale out of bounds."); - KillVideo(); - return -1; - } - -#ifdef OPENGL - if((s_useOpenGL && !ystretch) || !s_useOpenGL) -#endif - if(yres < s_tlines * s_eys || s_eys <= 0.01) { - FCEUD_PrintError("yscale out of bounds."); - KillVideo(); - return -1; - } - -#ifdef OPENGL - s_screen = SDL_SetVideoMode(s_useOpenGL ? s_nativeWidth : xres, - s_useOpenGL ? s_nativeHeight : yres, - desbpp, flags); -#else - s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags); -#endif - - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } - } else { - int desbpp; - g_config->getOption("SDL.BitsPerPixel", &desbpp); - - g_config->getOption("SDL.XScale", &s_exs); - g_config->getOption("SDL.YScale", &s_eys); - g_config->getOption("SDL.SpecialFX", &s_eefx); - - // -Video Modes Tag- - if(s_sponge) { - if(s_sponge >= 4) { - s_exs = s_eys = 3; - } else { - s_exs = s_eys = 2; - } - s_eefx = 0; - } - -#ifdef OPENGL - if(!s_useOpenGL) { - s_exs = (int)s_exs; - s_eys = (int)s_eys; - } - if(s_exs <= 0.01) { - FCEUD_PrintError("xscale out of bounds."); - KillVideo(); - return -1; - } - if(s_eys <= 0.01) { - FCEUD_PrintError("yscale out of bounds."); - KillVideo(); - return -1; - } - if(s_sponge && s_useOpenGL) { - FCEUD_PrintError("scalers not compatible with openGL mode."); - KillVideo(); - return -1; - } -#endif - -#if defined(_GTK) && defined(SDL_VIDEO_DRIVER_X11) - if(noGui == 0) - { - while (gtk_events_pending()) - gtk_main_iteration_do(FALSE); - - char SDL_windowhack[128]; - sprintf(SDL_windowhack, "SDL_WINDOWID=%u", (unsigned int)GDK_WINDOW_XID(gtk_widget_get_window(evbox))); - SDL_putenv(SDL_windowhack); - - // init SDL video - if (SDL_WasInit(SDL_INIT_VIDEO)) - SDL_QuitSubSystem(SDL_INIT_VIDEO); - if ( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) - { - fprintf(stderr, "Couldn't init SDL video: %s\n", SDL_GetError()); - gtk_main_quit(); - } - } -#endif - - s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs), - (int)(s_tlines * s_eys), - desbpp, flags); - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - return -1; - } - -#ifdef _GTK - if(noGui == 0) - { - GtkRequisition req; - gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); - gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); - } -#endif - } - s_curbpp = s_screen->format->BitsPerPixel; - if(!s_screen) { - FCEUD_PrintError(SDL_GetError()); - KillVideo(); - return -1; - } - -#if 0 - // XXX soules - this would be creating a surface on the video - // card, but was commented out for some reason... - s_BlitBuf = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 240, - s_screen->format->BitsPerPixel, - s_screen->format->Rmask, - s_screen->format->Gmask, - s_screen->format->Bmask, 0); -#endif - - FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n", - s_screen->w, s_screen->h, s_screen->format->BitsPerPixel, - s_fullscreen ? "full screen" : ""); - - if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) { - FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp); - KillVideo(); - return -1; - } - - // if the game being run has a name, set it as the window name - if(gi) - { - if(gi->name) { - SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name); - } else { - SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra"); - } - } - - // create the surface for displaying graphical messages -#ifdef LSB_FIRST - s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, - 32, 32, 24, 32 * 3, - 0xFF, 0xFF00, 0xFF0000, 0x00); -#else - s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, - 32, 32, 24, 32 * 3, - 0xFF0000, 0xFF00, 0xFF, 0x00); -#endif - SDL_WM_SetIcon(s_IconSurface,0); - s_paletterefresh = 1; - - // XXX soules - can't SDL do this for us? - // if using more than 8bpp, initialize the conversion routines - if(s_curbpp > 8) { - InitBlitToHigh(s_curbpp >> 3, - s_screen->format->Rmask, - s_screen->format->Gmask, - s_screen->format->Bmask, - s_eefx, s_sponge, 0); -#ifdef OPENGL - if(s_useOpenGL) - { - int openGLip; - g_config->getOption("SDL.OpenGLip", &openGLip); - - if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0), - s_srendline, s_erendline + 1, - s_exs, s_eys, s_eefx, - openGLip, xstretch, ystretch, s_screen)) - { - FCEUD_PrintError("Error initializing OpenGL."); - KillVideo(); - return -1; - } - } -#endif - } - return 0; -} -#endif - -/** - * Toggles the full-screen display. - */ -void ToggleFS() -{ - // pause while we we are making the switch - bool paused = FCEUI_EmulationPaused(); - if(!paused) - FCEUI_ToggleEmulationPause(); - - int error, fullscreen = s_fullscreen; - - // shut down the current video system - KillVideo(); - - // flip the fullscreen flag - g_config->setOption("SDL.Fullscreen", !fullscreen); -#ifdef _GTK - if(noGui == 0) - { - if(!fullscreen) - showGui(0); - else - showGui(1); - } -#endif - // try to initialize the video - error = InitVideo(GameInfo); - if(error) { - // if we fail, just continue with what worked before - g_config->setOption("SDL.Fullscreen", fullscreen); - InitVideo(GameInfo); - } - // if we paused to make the switch; unpause - if(!paused) - FCEUI_ToggleEmulationPause(); -} - -static SDL_Color s_psdl[256]; - -/** - * Sets the color for a particular index in the palette. - */ -void -FCEUD_SetPalette(uint8 index, - uint8 r, - uint8 g, - uint8 b) -{ - s_psdl[index].r = r; - s_psdl[index].g = g; - s_psdl[index].b = b; - - s_paletterefresh = 1; -} - -/** - * Gets the color for a particular index in the palette. - */ -void -FCEUD_GetPalette(uint8 index, - uint8 *r, - uint8 *g, - uint8 *b) -{ - *r = s_psdl[index].r; - *g = s_psdl[index].g; - *b = s_psdl[index].b; -} - -/** - * Pushes the palette structure into the underlying video subsystem. - */ -static void RedoPalette() -{ -#ifdef OPENGL - if(s_useOpenGL) - SetOpenGLPalette((uint8*)s_psdl); - else -#endif - { - if(s_curbpp > 8) { - SetPaletteBlitToHigh((uint8*)s_psdl); - } else - { -#if SDL_VERSION_ATLEAST(2, 0, 0) - //TODO - SDL2 -#else - SDL_SetPalette(s_screen, SDL_PHYSPAL, s_psdl, 0, 256); -#endif - } - } -} -// XXX soules - console lock/unlock unimplemented? - -///Currently unimplemented. -void LockConsole(){} - -///Currently unimplemented. -void UnlockConsole(){} - -/** - * Pushes the given buffer of bits to the screen. - */ -void -BlitScreen(uint8 *XBuf) -{ - SDL_Surface *TmpScreen; - uint8 *dest; - int xo = 0, yo = 0; - - if(!s_screen) { - return; - } - - // refresh the palette if required - if(s_paletterefresh) { - RedoPalette(); - s_paletterefresh = 0; - } - -#ifdef OPENGL - // OpenGL is handled separately - if(s_useOpenGL) { - BlitOpenGL(XBuf); - return; - } -#endif - - // XXX soules - not entirely sure why this is being done yet - XBuf += s_srendline * 256; - - if(s_BlitBuf) { - TmpScreen = s_BlitBuf; - } else { - TmpScreen = s_screen; - } - - // lock the display, if necessary - if(SDL_MUSTLOCK(TmpScreen)) { - if(SDL_LockSurface(TmpScreen) < 0) { - return; - } - } - - dest = (uint8*)TmpScreen->pixels; - - if(s_fullscreen) { - xo = (int)(((TmpScreen->w - NWIDTH * s_exs)) / 2); - dest += xo * (s_curbpp >> 3); - if(TmpScreen->h > (s_tlines * s_eys)) { - yo = (int)((TmpScreen->h - s_tlines * s_eys) / 2); - dest += yo * TmpScreen->pitch; - } - } - - // XXX soules - again, I'm surprised SDL can't handle this - // perform the blit, converting bpp if necessary - if(s_curbpp > 8) { - if(s_BlitBuf) { - Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, 1, 1); - } else { - Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, (int)s_exs, (int)s_eys); - } - } else { - if(s_BlitBuf) { - Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, 1, 1, 0, s_sponge); - } else { - Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines, - TmpScreen->pitch, (int)s_exs, (int)s_eys, - s_eefx, s_sponge); - } - } - - // unlock the display, if necessary - if(SDL_MUSTLOCK(TmpScreen)) { - SDL_UnlockSurface(TmpScreen); - } - - // if we have a hardware video buffer, do a fast video->video copy - if(s_BlitBuf) { - SDL_Rect srect; - SDL_Rect drect; - - srect.x = 0; - srect.y = 0; - srect.w = NWIDTH; - srect.h = s_tlines; - - drect.x = 0; - drect.y = 0; - drect.w = (Uint16)(s_exs * NWIDTH); - drect.h = (Uint16)(s_eys * s_tlines); - - SDL_BlitSurface(s_BlitBuf, &srect, s_screen, &drect); - } - - // ensure that the display is updated -#if SDL_VERSION_ATLEAST(2, 0, 0) - //TODO - SDL2 -#else - SDL_UpdateRect(s_screen, xo, yo, - (Uint32)(NWIDTH * s_exs), (Uint32)(s_tlines * s_eys)); -#endif - -#ifdef CREATE_AVI -#if 0 /* PAL INTO NTSC HACK */ - { int fps = FCEUI_GetDesiredFPS(); - if(FCEUI_GetDesiredFPS() == 838977920) fps = 1008307711; - NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp); - if(FCEUI_GetDesiredFPS() == 838977920) - { - static unsigned dup=0; - if(++dup==5) { dup=0; - NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp); } - } } -#else - { int fps = FCEUI_GetDesiredFPS(); - static unsigned char* result = NULL; - static unsigned resultsize = 0; - int width = NWIDTH, height = s_tlines; - if(!result || resultsize != width*height*3*2) - { - if(result) free(result); - result = (unsigned char*) FCEU_dmalloc(resultsize = width*height*3*2); - } - switch(s_curbpp) - { - #if 0 - case 24: case 32: case 15: case 16: - /* Convert to I420 if possible, because our I420 conversion is optimized - * and it'll produce less network traffic, hence faster throughput than - * anything else. And H.264 eats only I420, so it'd be converted sooner - * or later anyway if we didn't do it. Win-win situation. - */ - switch(s_curbpp) - { - case 32: Convert32To_I420Frame(s_screen->pixels, &result[0], width*height, width); break; - case 24: Convert24To_I420Frame(s_screen->pixels, &result[0], width*height, width); break; - case 15: Convert15To_I420Frame(s_screen->pixels, &result[0], width*height, width); break; - case 16: Convert16To_I420Frame(s_screen->pixels, &result[0], width*height, width); break; - } - NESVideoLoggingVideo(&result[0], width,height, fps, 12); - break; - #endif - default: - NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp); - } - } -#endif - -#if REALTIME_LOGGING - { - static struct timeval last_time; - static int first_time=1; - extern long soundrate; - - struct timeval cur_time; - gettimeofday(&cur_time, NULL); - - double timediff = - (cur_time.tv_sec *1e6 + cur_time.tv_usec - - (last_time.tv_sec *1e6 + last_time.tv_usec)) / 1e6; - - int nframes = timediff * 60 - 1; - if(first_time) - first_time = 0; - else while(nframes > 0) - { - static const unsigned char Buf[800*4] = {0}; - NESVideoLoggingVideo(screen->pixels, 256,tlines, FCEUI_GetDesiredFPS(), s_curbpp); - NESVideoLoggingAudio(Buf, soundrate,16,1, soundrate/60.0); - --nframes; - } - memcpy(&last_time, &cur_time, sizeof(last_time)); - } -#endif -#endif - -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO -#else - // have to flip the displayed buffer in the case of double buffering - if(s_screen->flags & SDL_DOUBLEBUF) { - SDL_Flip(s_screen); - } -#endif -} - -/** - * Converts an x-y coordinate in the window manager into an x-y - * coordinate on FCEU's screen. - */ -uint32 -PtoV(uint16 x, - uint16 y) -{ - y = (uint16)((double)y / s_eys); - x = (uint16)((double)x / s_exs); - if(s_clipSides) { - x += 8; - } - y += s_srendline; - return (x | (y << 16)); -} - -bool enableHUDrecording = false; -bool FCEUI_AviEnableHUDrecording() -{ - if (enableHUDrecording) - return true; - - return false; -} -void FCEUI_SetAviEnableHUDrecording(bool enable) -{ - enableHUDrecording = enable; -} - -bool disableMovieMessages = false; -bool FCEUI_AviDisableMovieMessages() -{ - if (disableMovieMessages) - return true; - - return false; -} -void FCEUI_SetAviDisableMovieMessages(bool disable) -{ - disableMovieMessages = disable; -} diff --git a/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.h b/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.h deleted file mode 100644 index ac1ff415..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/sdl-video.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __FCEU_SDL_VIDEO_H -#define __FCEU_SDL_VIDEO_H -#ifdef _SDL2 -#include -#else -#include -#endif - -uint32 PtoV(uint16 x, uint16 y); -bool FCEUD_ShouldDrawInputAids(); -bool FCEUI_AviDisableMovieMessages(); -static SDL_Surface *s_screen; -bool FCEUI_AviEnableHUDrecording(); -void FCEUI_SetAviEnableHUDrecording(bool enable); -bool FCEUI_AviDisableMovieMessages(); -void FCEUI_SetAviDisableMovieMessages(bool disable); -#endif - diff --git a/branches/fceux-2.2.2/src/drivers/sdl/sdl.cpp b/branches/fceux-2.2.2/src/drivers/sdl/sdl.cpp deleted file mode 100644 index d23e5a64..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/sdl.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -#include "main.h" -#include "throttle.h" -#include "config.h" - -#include "../common/cheat.h" -#include "../../fceu.h" -#include "../../movie.h" -#include "../../version.h" -#ifdef _S9XLUA_H -#include "../../fceulua.h" -#endif - -#include "input.h" -#include "dface.h" - -#include "sdl.h" -#include "sdl-video.h" -#include "unix-netplay.h" - -#include "../common/configSys.h" -#include "../../oldmovie.h" -#include "../../types.h" - -#ifdef CREATE_AVI -#include "../videolog/nesvideos-piece.h" -#endif - -#ifdef WIN32 -#include -#endif - -#ifdef _GTK -#include -#include "gui.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -extern double g_fpsScale; - -extern bool MaxSpeed; - -int isloaded; - -bool turbo = false; - -int closeFinishedMovie = 0; - -int eoptions=0; - -static int inited = 0; - -static void DriverKill(void); -static int DriverInitialize(FCEUGI *gi); -uint64 FCEUD_GetTime(); -int gametype = 0; -#ifdef CREATE_AVI -int mutecapture; -#endif -static int noconfig; - -// -Video Modes Tag- : See --special -static const char *DriverUsage= -"Option Value Description\n" -"--pal {0|1} Use PAL timing.\n" -"--newppu {0|1} Enable the new PPU core. (WARNING: May break savestates)\n" -"--inputcfg d Configures input device d on startup.\n" -"--input(1,2) d Set which input device to emulate for input 1 or 2.\n" -" Devices: gamepad zapper powerpad.0 powerpad.1\n" -" arkanoid\n" -"--input(3,4) d Set the famicom expansion device to emulate for\n" -" input(3, 4)\n" -" Devices: quizking hypershot mahjong toprider ftrainer\n" -" familykeyboard oekakids arkanoid shadow bworld\n" -" 4player\n" -"--gamegenie {0|1} Enable emulated Game Genie.\n" -"--frameskip x Set # of frames to skip per emulated frame.\n" -"--xres x Set horizontal resolution for full screen mode.\n" -"--yres x Set vertical resolution for full screen mode.\n" -"--autoscale {0|1} Enable autoscaling in fullscreen. \n" -"--keepratio {0|1} Keep native NES aspect ratio when autoscaling. \n" -"--(x/y)scale x Multiply width/height by x. \n" -" (Real numbers >0 with OpenGL, otherwise integers >0).\n" -"--(x/y)stretch {0|1} Stretch to fill surface on x/y axis (OpenGL only).\n" -"--bpp {8|16|32} Set bits per pixel.\n" -"--opengl {0|1} Enable OpenGL support.\n" -"--fullscreen {0|1} Enable full screen mode.\n" -"--noframe {0|1} Hide title bar and window decorations.\n" -"--special {1-4} Use special video scaling filters\n" -" (1 = hq2x 2 = Scale2x 3 = NTSC 2x 4 = hq3x\n" -" 5 = Scale3x)\n" -"--palette f Load custom global palette from file f.\n" -"--sound {0|1} Enable sound.\n" -"--soundrate x Set sound playback rate to x Hz.\n" -"--soundq {0|1|2} Set sound quality. (0 = Low 1 = High 2 = Very High)\n" -"--soundbufsize x Set sound buffer size to x ms.\n" -"--volume {0-256} Set volume to x.\n" -"--soundrecord f Record sound to file f.\n" -"--playmov f Play back a recorded FCM/FM2/FM3 movie from filename f.\n" -"--pauseframe x Pause movie playback at frame x.\n" -"--fcmconvert f Convert fcm movie file f to fm2.\n" -"--ripsubs f Convert movie's subtitles to srt\n" -"--subtitles {0|1} Enable subtitle display\n" -"--fourscore {0|1} Enable fourscore emulation\n" -"--no-config {0|1} Use default config file and do not save\n" -"--net s Connect to server 's' for TCP/IP network play.\n" -"--port x Use TCP/IP port x for network play.\n" -"--user x Set the nickname to use in network play.\n" -"--pass x Set password to use for connecting to the server.\n" -"--netkey s Use string 's' to create a unique session for the\n" -" game loaded.\n" -"--players x Set the number of local players in a network play\n" -" session.\n" -"--rp2mic {0|1} Replace Port 2 Start with microphone (Famicom).\n" -"--nogui Don't load the GTK GUI\n" -"--4buttonexit {0|1} exit the emulator when A+B+Select+Start is pressed\n" -"--loadstate {0-9|>9} load from the given state when the game is loaded\n" -"--savestate {0-9|>9} save to the given state when the game is closed\n" -" to not save/load automatically provide a number\n" -" greater than 9\n" -"--periodicsaves {0|1} enable automatic periodic saving. This will save to\n" -" the state passed to --savestate\n"; - - -// these should be moved to the man file -//--nospritelim {0|1} Disables the 8 sprites per scanline limitation.\n -//--trianglevol {0-256} Sets Triangle volume.\n -//--square1vol {0-256} Sets Square 1 volume.\n -//--square2vol {0-256} Sets Square 2 volume.\n -//--noisevol {0-256} Sets Noise volume.\n -//--pcmvol {0-256} Sets PCM volume.\n -//--lowpass {0|1} Enables low-pass filter if x is nonzero.\n -//--doublebuf {0|1} Enables SDL double-buffering if x is nonzero.\n -//--slend {0-239} Sets the last drawn emulated scanline.\n -//--ntsccolor {0|1} Emulates an NTSC TV's colors.\n -//--hue x Sets hue for NTSC color emulation.\n -//--tint x Sets tint for NTSC color emulation.\n -//--slstart {0-239} Sets the first drawn emulated scanline.\n -//--clipsides {0|1} Clips left and rightmost 8 columns of pixels.\n - -// global configuration object -Config *g_config; - -static void ShowUsage(char *prog) -{ - printf("\nUsage is as follows:\n%s filename\n\n",prog); - puts(DriverUsage); -#ifdef _S9XLUA_H - puts ("--loadlua f Loads lua script from filename f."); -#endif -#ifdef CREATE_AVI - puts ("--videolog c Calls mencoder to grab the video and audio streams to\n encode them. Check the documentation for more on this."); - puts ("--mute {0|1} Mutes FCEUX while still passing the audio stream to\n mencoder during avi creation."); -#endif - puts(""); - printf("Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL ); -#if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_version* v; - SDL_GetVersion(v); -#else - const SDL_version* v = SDL_Linked_Version(); -#endif - printf("Linked with SDL version %d.%d.%d\n", v->major, v->minor, v->patch); -#ifdef GTK - printf("Compiled with GTK version %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION ); - //printf("Linked with GTK version %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION ); -#endif - -} - -/** - * Loads a game, given a full path/filename. The driver code must be - * initialized after the game is loaded, because the emulator code - * provides data necessary for the driver code(number of scanlines to - * render, what virtual input devices to use, etc.). - */ -int LoadGame(const char *path) -{ - if (isloaded){ - CloseGame(); - } - if(!FCEUI_LoadGame(path, 1)) { - return 0; - } - - int state_to_load; - g_config->getOption("SDL.AutoLoadState", &state_to_load); - if (state_to_load >= 0 && state_to_load < 10){ - FCEUI_SelectState(state_to_load, 0); - FCEUI_LoadState(NULL, false); - } - - ParseGIInput(GameInfo); - RefreshThrottleFPS(); - - if(!DriverInitialize(GameInfo)) { - return(0); - } - - // set pal/ntsc - int id; - g_config->getOption("SDL.PAL", &id); - if(id) - FCEUI_SetVidSystem(1); - else - FCEUI_SetVidSystem(0); - - std::string filename; - g_config->getOption("SDL.Sound.RecordFile", &filename); - if(filename.size()) { - if(!FCEUI_BeginWaveRecord(filename.c_str())) { - g_config->setOption("SDL.Sound.RecordFile", ""); - } - } - isloaded = 1; - - FCEUD_NetworkConnect(); - return 1; -} - -/** - * Closes a game. Frees memory, and deinitializes the drivers. - */ -int -CloseGame() -{ - std::string filename; - - if(!isloaded) { - return(0); - } - - int state_to_save; - g_config->getOption("SDL.AutoSaveState", &state_to_save); - if (state_to_save < 10 && state_to_save >= 0){ - FCEUI_SelectState(state_to_save, 0); - FCEUI_SaveState(NULL, false); - } - FCEUI_CloseGame(); - - DriverKill(); - isloaded = 0; - GameInfo = 0; - - g_config->getOption("SDL.Sound.RecordFile", &filename); - if(filename.size()) { - FCEUI_EndWaveRecord(); - } - - InputUserActiveFix(); - return(1); -} - -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); - -static void DoFun(int frameskip, int periodic_saves) -{ - uint8 *gfx; - int32 *sound; - int32 ssize; - static int fskipc = 0; - static int opause = 0; - - //TODO peroidic saves, working on it right now - if (periodic_saves && FCEUD_GetTime() % PERIODIC_SAVE_INTERVAL < 30){ - FCEUI_SaveState(NULL, false); - } -#ifdef FRAMESKIP - fskipc = (fskipc + 1) % (frameskip + 1); -#endif - - if(NoWaiting) { - gfx = 0; - } - FCEUI_Emulate(&gfx, &sound, &ssize, fskipc); - FCEUD_Update(gfx, sound, ssize); - - if(opause!=FCEUI_EmulationPaused()) { - opause=FCEUI_EmulationPaused(); - SilenceSound(opause); - } -} - - -/** - * Initialize all of the subsystem drivers: video, audio, and joystick. - */ -static int -DriverInitialize(FCEUGI *gi) -{ - if(InitVideo(gi) < 0) return 0; - inited|=4; - - if(InitSound()) - inited|=1; - - if(InitJoysticks()) - inited|=2; - - int fourscore=0; - g_config->getOption("SDL.FourScore", &fourscore); - eoptions &= ~EO_FOURSCORE; - if(fourscore) - eoptions |= EO_FOURSCORE; - - InitInputInterface(); - return 1; -} - -/** - * Shut down all of the subsystem drivers: video, audio, and joystick. - */ -static void -DriverKill() -{ - if (!noconfig) - g_config->save(); - - if(inited&2) - KillJoysticks(); - if(inited&4) - KillVideo(); - if(inited&1) - KillSound(); - inited=0; -} - -/** - * Update the video, audio, and input subsystems with the provided - * video (XBuf) and audio (Buffer) information. - */ -void -FCEUD_Update(uint8 *XBuf, - int32 *Buffer, - int Count) -{ - extern int FCEUDnetplay; - - #ifdef CREATE_AVI - if(LoggingEnabled == 2 || (eoptions&EO_NOTHROTTLE)) - { - if(LoggingEnabled == 2) - { - int16* MonoBuf = new int16[Count]; - int n; - for(n=0; n GetWriteSound()) Count = GetWriteSound(); - if (!mutecapture) - if(Count > 0 && Buffer) WriteSound(Buffer,Count); - } - if(inited & 2) - FCEUD_UpdateInput(); - if(XBuf && (inited & 4)) BlitScreen(XBuf); - - //SpeedThrottle(); - return; - } - #endif - - int ocount = Count; - // apply frame scaling to Count - Count = (int)(Count / g_fpsScale); - if(Count) { - int32 can=GetWriteSound(); - static int uflow=0; - int32 tmpcan; - - // don't underflow when scaling fps - if(can >= GetMaxSound() && g_fpsScale==1.0) uflow=1; /* Go into massive underflow mode. */ - - if(can > Count) can=Count; - else uflow=0; - - #ifdef CREATE_AVI - if (!mutecapture) - #endif - WriteSound(Buffer,can); - - //if(uflow) puts("Underflow"); - tmpcan = GetWriteSound(); - // don't underflow when scaling fps - if(g_fpsScale>1.0 || ((tmpcan < Count*0.90) && !uflow)) { - if(XBuf && (inited&4) && !(NoWaiting & 2)) - BlitScreen(XBuf); - Buffer+=can; - Count-=can; - if(Count) { - if(NoWaiting) { - can=GetWriteSound(); - if(Count>can) Count=can; - #ifdef CREATE_AVI - if (!mutecapture) - #endif - WriteSound(Buffer,Count); - } else { - while(Count>0) { - #ifdef CREATE_AVI - if (!mutecapture) - #endif - WriteSound(Buffer,(Count= (Count * 1.8))) { - if(Count > tmpcan) Count=tmpcan; - while(tmpcan > 0) { - // printf("Overwrite: %d\n", (Count <= tmpcan)?Count : tmpcan); - #ifdef CREATE_AVI - if (!mutecapture) - #endif - WriteSound(Buffer, (Count <= tmpcan)?Count : tmpcan); - tmpcan -= Count; - } - } - - } else { - if(!NoWaiting && (!(eoptions&EO_NOTHROTTLE) || FCEUI_EmulationPaused())) - while (SpeedThrottle()) - { - FCEUD_UpdateInput(); - } - if(XBuf && (inited&4)) { - BlitScreen(XBuf); - } - } - FCEUD_UpdateInput(); - //if(!Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE)) - // SpeedThrottle(); - //if(XBuf && (inited&4)) - //{ - // BlitScreen(XBuf); - //} - //if(Count) - // WriteSound(Buffer,Count,NoWaiting); - //FCEUD_UpdateInput(); -} - -/** - * Opens a file to be read a byte at a time. - */ -EMUFILE_FILE* FCEUD_UTF8_fstream(const char *fn, const char *m) -{ - std::ios_base::openmode mode = std::ios_base::binary; - if(!strcmp(m,"r") || !strcmp(m,"rb")) - mode |= std::ios_base::in; - else if(!strcmp(m,"w") || !strcmp(m,"wb")) - mode |= std::ios_base::out | std::ios_base::trunc; - else if(!strcmp(m,"a") || !strcmp(m,"ab")) - mode |= std::ios_base::out | std::ios_base::app; - else if(!strcmp(m,"r+") || !strcmp(m,"r+b")) - mode |= std::ios_base::in | std::ios_base::out; - else if(!strcmp(m,"w+") || !strcmp(m,"w+b")) - mode |= std::ios_base::in | std::ios_base::out | std::ios_base::trunc; - else if(!strcmp(m,"a+") || !strcmp(m,"a+b")) - mode |= std::ios_base::in | std::ios_base::out | std::ios_base::app; - return new EMUFILE_FILE(fn, m); - //return new std::fstream(fn,mode); -} - -/** - * Opens a file, C++ style, to be read a byte at a time. - */ -FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) -{ - return(fopen(fn,mode)); -} - -static char *s_linuxCompilerString = "g++ " __VERSION__; -/** - * Returns the compiler string. - */ -const char *FCEUD_GetCompilerString() { - return (const char *)s_linuxCompilerString; -} - -/** - * Unimplemented. - */ -void FCEUD_DebugBreakpoint() { - return; -} - -/** - * Unimplemented. - */ -void FCEUD_TraceInstruction() { - return; -} - - -#ifdef _GTK - int noGui = 0; -#else - int noGui = 1; -#endif - - -/** - * The main loop for the SDL. - */ -int main(int argc, char *argv[]) -{ - // this is a hackish check for the --help arguemnts - // these are normally processed by the config parser, but SDL_Init - // must be run before the config parser: so if even SDL_Init fails, - // these six lines will still print the help output - if(argc > 1) - { - if(!strcmp(argv[1], "--help") || !strcmp(argv[1],"-h")) - { - ShowUsage(argv[0]); - return 0; - } - } - - int error, frameskip; - - FCEUD_Message("Starting " FCEU_NAME_AND_VERSION "...\n"); - -#ifdef WIN32 - /* Taken from win32 sdl_main.c */ - SDL_SetModuleHandle(GetModuleHandle(NULL)); -#endif - - /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */ - if(SDL_Init(SDL_INIT_VIDEO)) { - printf("Could not initialize SDL: %s.\n", SDL_GetError()); - return(-1); - } - -#ifdef OPENGL - SDL_GL_LoadLibrary(0); -#endif - - // Initialize the configuration system - g_config = InitConfig(); - - if(!g_config) { - SDL_Quit(); - return -1; - } - - // initialize the infrastructure - error = FCEUI_Initialize(); - if(error != 1) { - ShowUsage(argv[0]); - SDL_Quit(); - return -1; - } - - // check for --help or -h and display usage; also check for --nogui - for(int i=0; iparse(argc, argv); - - // This is here so that a default fceux.cfg will be created on first - // run, even without a valid ROM to play. - // Unless, of course, there's actually --no-config given - // mbg 8/23/2008 - this is also here so that the inputcfg routines can have - // a chance to dump the new inputcfg to the fceux.cfg in case you didnt - // specify a rom filename - g_config->getOption("SDL.NoConfig", &noconfig); - if (!noconfig) - g_config->save(); - - std::string s; - - g_config->getOption("SDL.InputCfg", &s); - if(s.size() != 0) - { - InitVideo(GameInfo); - InputCfg(s); - } - // set the FAMICOM PAD 2 Mic thing - { - int t; - g_config->getOption("SDL.Input.FamicomPad2.EnableMic", &t); - if(t) - replaceP2StartWithMicrophone = t; - } - - // update the input devices - UpdateInput(g_config); - - // check for a .fcm file to convert to .fm2 - g_config->getOption ("SDL.FCMConvert", &s); - g_config->setOption ("SDL.FCMConvert", ""); - if (!s.empty()) - { - int okcount = 0; - std::string infname = s.c_str(); - // produce output filename - std::string outname; - size_t dot = infname.find_last_of ("."); - if (dot == std::string::npos) - outname = infname + ".fm2"; - else - outname = infname.substr(0,dot) + ".fm2"; - - MovieData md; - EFCM_CONVERTRESULT result = convert_fcm (md, infname); - - if (result == FCM_CONVERTRESULT_SUCCESS) { - okcount++; - // *outf = new EMUFILE; - EMUFILE_FILE* outf = FCEUD_UTF8_fstream (outname, "wb"); - md.dump (outf,false); - delete outf; - FCEUD_Message ("Your file has been converted to FM2.\n"); - } - else { - FCEUD_Message ("Something went wrong while converting your file...\n"); - } - - DriverKill(); - SDL_Quit(); - return 0; - } - - // If x/y res set to 0, store current display res in SDL.LastX/YRes - int yres, xres; - g_config->getOption("SDL.XResolution", &xres); - g_config->getOption("SDL.YResolution", &yres); -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO _ SDL 2.0 -#else - const SDL_VideoInfo* vid_info = SDL_GetVideoInfo(); - if(xres == 0) - { - if(vid_info != NULL) - { - g_config->setOption("SDL.LastXRes", vid_info->current_w); - } - else - { - g_config->setOption("SDL.LastXRes", 512); - } - } - else - { - g_config->setOption("SDL.LastXRes", xres); - } - if(yres == 0) - { - if(vid_info != NULL) - { - g_config->setOption("SDL.LastYRes", vid_info->current_h); - } - else - { - g_config->setOption("SDL.LastYRes", 448); - } - } - else - { - g_config->setOption("SDL.LastYRes", yres); - } -#endif - - int autoResume; - g_config->getOption("SDL.AutoResume", &autoResume); - if(autoResume) - { - AutoResumePlay = true; - } - else - { - AutoResumePlay = false; - } - // check to see if recording HUD to AVI is enabled - int rh; - g_config->getOption("SDL.RecordHUD", &rh); - if( rh == 0) - FCEUI_SetAviEnableHUDrecording(true); - else - FCEUI_SetAviEnableHUDrecording(false); - - // check to see if movie messages are disabled - int mm; - g_config->getOption("SDL.MovieMsg", &mm); - if( mm == 0) - FCEUI_SetAviDisableMovieMessages(true); - else - FCEUI_SetAviDisableMovieMessages(false); - - - // check for a .fm2 file to rip the subtitles - g_config->getOption("SDL.RipSubs", &s); - g_config->setOption("SDL.RipSubs", ""); - if (!s.empty()) - { - MovieData md; - std::string infname; - infname = s.c_str(); - FCEUFILE *fp = FCEU_fopen(s.c_str(), 0, "rb", 0); - - // load the movie and and subtitles - extern bool LoadFM2(MovieData&, EMUFILE*, int, bool); - LoadFM2(md, fp->stream, INT_MAX, false); - LoadSubtitles(md); // fill subtitleFrames and subtitleMessages - delete fp; - - // produce .srt file's name and open it for writing - std::string outname; - size_t dot = infname.find_last_of ("."); - if (dot == std::string::npos) - outname = infname + ".srt"; - else - outname = infname.substr(0,dot) + ".srt"; - FILE *srtfile; - srtfile = fopen(outname.c_str(), "w"); - - if (srtfile != NULL) - { - extern std::vector subtitleFrames; - extern std::vector subtitleMessages; - float fps = (md.palFlag == 0 ? 60.0988 : 50.0069); // NTSC vs PAL - float subduration = 3; // seconds for the subtitles to be displayed - for (int i = 0; i < subtitleFrames.size(); i++) - { - fprintf(srtfile, "%i\n", i+1); // starts with 1, not 0 - double seconds, ms, endseconds, endms; - seconds = subtitleFrames[i]/fps; - if (i+1 < subtitleFrames.size()) // there's another subtitle coming after this one - { - if (subtitleFrames[i+1]-subtitleFrames[i] < subduration*fps) // avoid two subtitles at the same time - { - endseconds = (subtitleFrames[i+1]-1)/fps; // frame x: subtitle1; frame x+1 subtitle2 - } else { - endseconds = seconds+subduration; - } - } else { - endseconds = seconds+subduration; - } - ms = modf(seconds, &seconds); - endms = modf(endseconds, &endseconds); - // this is just beyond ugly, don't show it to your kids - fprintf(srtfile, - "%02.0f:%02d:%02d,%03d --> %02.0f:%02d:%02d,%03d\n", // hh:mm:ss,ms --> hh:mm:ss,ms - floor(seconds/3600), (int)floor(seconds/60 ) % 60, (int)floor(seconds) % 60, (int)(ms*1000), - floor(endseconds/3600), (int)floor(endseconds/60) % 60, (int)floor(endseconds) % 60, (int)(endms*1000)); - fprintf(srtfile, "%s\n\n", subtitleMessages[i].c_str()); // new line for every subtitle - } - fclose(srtfile); - printf("%d subtitles have been ripped.\n", (int)subtitleFrames.size()); - } else { - FCEUD_Message("Couldn't create output srt file...\n"); - } - - DriverKill(); - SDL_Quit(); - return 0; - } - - - // if we're not compiling w/ the gui, exit if a rom isn't specified -#ifndef _GTK - if(romIndex <= 0) { - - ShowUsage(argv[0]); - FCEUD_Message("\nError parsing command line arguments\n"); - SDL_Quit(); - return -1; - } -#endif - - - // update the emu core - UpdateEMUCore(g_config); - - - #ifdef CREATE_AVI - g_config->getOption("SDL.VideoLog", &s); - g_config->setOption("SDL.VideoLog", ""); - if(!s.empty()) - { - NESVideoSetVideoCmd(s.c_str()); - LoggingEnabled = 1; - g_config->getOption("SDL.MuteCapture", &mutecapture); - } else { - mutecapture = 0; - } - #endif - - { - int id; - g_config->getOption("SDL.InputDisplay", &id); - extern int input_display; - input_display = id; - // not exactly an id as an true/false switch; still better than creating another int for that - g_config->getOption("SDL.SubtitleDisplay", &id); - extern int movieSubtitles; - movieSubtitles = id; - } - - // load the hotkeys from the config life - setHotKeys(); - -#ifdef _GTK - if(noGui == 0) - { - gtk_init(&argc, &argv); - InitGTKSubsystem(argc, argv); - while(gtk_events_pending()) - gtk_main_iteration_do(FALSE); - } -#endif - - if(romIndex >= 0) - { - // load the specified game - error = LoadGame(argv[romIndex]); - if(error != 1) { - DriverKill(); - SDL_Quit(); - return -1; - } - g_config->setOption("SDL.LastOpenFile", argv[romIndex]); - g_config->save(); - - } - - // movie playback - g_config->getOption("SDL.Movie", &s); - g_config->setOption("SDL.Movie", ""); - if (s != "") - { - if(s.find(".fm2") != std::string::npos || s.find(".fm3") != std::string::npos) - { - static int pauseframe; - g_config->getOption("SDL.PauseFrame", &pauseframe); - g_config->setOption("SDL.PauseFrame", 0); - FCEUI_printf("Playing back movie located at %s\n", s.c_str()); - FCEUI_LoadMovie(s.c_str(), false, pauseframe ? pauseframe : false); - } - else - { - FCEUI_printf("Sorry, I don't know how to play back %s\n", s.c_str()); - } - } - - int periodic_saves; - int save_state; - g_config->getOption("SDL.PeriodicSaves", &periodic_saves); - g_config->getOption("SDL.AutoSaveState", &save_state); - if(periodic_saves && save_state < 10 && save_state >= 0){ - FCEUI_SelectState(save_state, 0); - } else { - periodic_saves = 0; - } - -#ifdef _S9XLUA_H - // load lua script if option passed - g_config->getOption("SDL.LuaScript", &s); - g_config->setOption("SDL.LuaScript", ""); - if (s != "") - { - FCEU_LoadLuaCode(s.c_str()); - } -#endif - - { - int id; - g_config->getOption("SDL.NewPPU", &id); - if (id) - newppu = 1; - } - - g_config->getOption("SDL.Frameskip", &frameskip); - // loop playing the game -#ifdef _GTK - if(noGui == 0) - { - while(1) - { - if(GameInfo) - DoFun(frameskip, periodic_saves); - else - SDL_Delay(1); - while(gtk_events_pending()) - gtk_main_iteration_do(FALSE); - } - } - else - { - while(GameInfo) - DoFun(frameskip, periodic_saves); - } -#else - while(GameInfo) - { - DoFun(frameskip, periodic_saves); - } -#endif - CloseGame(); - - // exit the infrastructure - FCEUI_Kill(); - SDL_Quit(); - return 0; -} - -/** - * Get the time in ticks. - */ -uint64 -FCEUD_GetTime() -{ - return SDL_GetTicks(); -} - -/** - * Get the tick frequency in Hz. - */ -uint64 -FCEUD_GetTimeFreq(void) -{ - // SDL_GetTicks() is in milliseconds - return 1000; -} - -/** -* Prints a textual message without adding a newline at the end. -* -* @param text The text of the message. -* -* TODO: This function should have a better name. -**/ -void FCEUD_Message(const char *text) -{ - fputs(text, stdout); -#ifdef _GTK - pushOutputToGTK(text); -#endif -} - -/** -* Shows an error message in a message box. -* (For now: prints to stderr.) -* -* If running in GTK mode, display a dialog message box of the error. -* -* @param errormsg Text of the error message. -**/ -void FCEUD_PrintError(const char *errormsg) -{ -#ifdef GTK - if(gtkIsStarted == true && noGui == 0) - { - GtkWidget* d; - d = gtk_message_dialog_new(GTK_WINDOW(MainWindow), GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", errormsg); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - } -#endif - - fprintf(stderr, "%s\n", errormsg); -} - - -// dummy functions - -#define DUMMY(__f) \ - void __f(void) {\ - printf("%s\n", #__f);\ - FCEU_DispMessage("Not implemented.",0);\ - } -DUMMY(FCEUD_HideMenuToggle) -DUMMY(FCEUD_MovieReplayFrom) -DUMMY(FCEUD_ToggleStatusIcon) -DUMMY(FCEUD_AviRecordTo) -DUMMY(FCEUD_AviStop) -void FCEUI_AviVideoUpdate(const unsigned char* buffer) { } -int FCEUD_ShowStatusIcon(void) {return 0;} -bool FCEUI_AviIsRecording(void) {return false;} -void FCEUI_UseInputPreset(int preset) { } -bool FCEUD_PauseAfterPlayback() { return false; } -// These are actually fine, but will be unused and overriden by the current UI code. -void FCEUD_TurboOn (void) { NoWaiting|= 1; } -void FCEUD_TurboOff (void) { NoWaiting&=~1; } -void FCEUD_TurboToggle(void) { NoWaiting^= 1; } -FCEUFILE* FCEUD_OpenArchiveIndex(ArchiveScanRecord& asr, std::string &fname, int innerIndex) { return 0; } -FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename) { return 0; } -ArchiveScanRecord FCEUD_ScanArchive(std::string fname) { return ArchiveScanRecord(); } - diff --git a/branches/fceux-2.2.2/src/drivers/sdl/sdl.h b/branches/fceux-2.2.2/src/drivers/sdl/sdl.h deleted file mode 100644 index 0dc6b251..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/sdl.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __FCEU_SDL_H -#define __FCEU_SDL_H - -#if _SDL2 -#include -#else -#include -#endif - -#include "main.h" -#include "dface.h" -#include "input.h" - -// I'm using this as a #define so the compiler can optimize the -// modulo operation -#define PERIODIC_SAVE_INTERVAL 5000 // milliseconds - -const int INVALID_STATE = 99; - -extern int noGui; -extern int isloaded; - -int LoadGame(const char *path); -int CloseGame(void); -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); -uint64 FCEUD_GetTime(); - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/sdl/throttle.h b/branches/fceux-2.2.2/src/drivers/sdl/throttle.h deleted file mode 100644 index 59984fba..00000000 --- a/branches/fceux-2.2.2/src/drivers/sdl/throttle.h +++ /dev/null @@ -1,2 +0,0 @@ -void RefreshThrottleFPS(void); -int SpeedThrottle(void); diff --git a/branches/fceux-2.2.2/src/drivers/win/args.cpp b/branches/fceux-2.2.2/src/drivers/win/args.cpp deleted file mode 100644 index 81d088a5..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/args.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "main.h" -#include "args.h" -#include "common.h" -#include "../common/args.h" - -char* MovieToLoad = 0; //Loads a movie file on startup -char* StateToLoad = 0; //Loads a savestate on startup (after a movie is loaded, if any) -char* ConfigToLoad = 0; //Loads a specific .cfg file (loads before any other commandline options -char* LuaToLoad = 0; //Loads a specific lua file -char* PaletteToLoad = 0; //Loads a specific palette file -char* AviToLoad = 0; //Starts an avi capture at startup - -extern bool turbo; - -// TODO: Parsing arguments needs to be improved a lot. A LOT. - -//------------------------------------------------------------- -// Parses commandline arguments -//------------------------------------------------------------- -char *ParseArgies(int argc, char *argv[]) -{ - static ARGPSTRUCT FCEUArgs[]={ - {"-pal",&pal_setting_specified,&pal_emulation,0}, - {"-noicon",0,&status_icon,0}, - {"-gg",0,&genie,0}, - {"-no8lim",0,&eoptions,0x8000|EO_NOSPRLIM}, - //{"-nofs",0,&eoptions,0}, - {"-clipsides",0,&eoptions,0x8000|EO_CLIPSIDES}, - {"-nothrottle",0,&eoptions,0x8000|EO_NOTHROTTLE}, - {"-playmovie",0,&MovieToLoad,0x4001}, - {"-lua",0,&LuaToLoad,0x4001}, - {"-palette",0,&PaletteToLoad,0x4001}, - {"-loadstate",0,&StateToLoad,0x4001}, - {"-readonly",0,&replayReadOnlySetting,0}, - {"-stopframe",0,&replayStopFrameSetting,0}, - {"-framedisplay",0,&frame_display,0}, - {"-inputdisplay",0,&input_display,0}, - {"-allowUDLR",0,&allowUDLR,0}, - {"-stopmovie",0,&pauseAfterPlayback,0}, - {"-shutmovie",0,&closeFinishedMovie,0}, - {"-bginput",0,&EnableBackgroundInput,0}, - {"-turbo",0,&turbo,0}, - {"-pause",0,&PauseAfterLoad,0}, - {"-cfg",0,&ConfigToLoad,0x4001}, - {"-avi",0,&AviToLoad,0x4001}, - {"-avicapture",0,&AVICapture,0}, - {0, 0, 0, 0}, - }; - - if(argc <= 1) - { - return(0); - } - - int used = ParseArguments(argc-1, &argv[1], FCEUArgs); - - return(argv[used+1]); -} diff --git a/branches/fceux-2.2.2/src/drivers/win/args.h b/branches/fceux-2.2.2/src/drivers/win/args.h deleted file mode 100644 index 40ff263c..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/args.h +++ /dev/null @@ -1,11 +0,0 @@ -extern char* MovieToLoad; //Contains the filename of the savestate specified in the command line arguments -extern char* StateToLoad; //Contains the filename of the movie file specified in the command line arguments -extern char* ConfigToLoad; //Contains the filename of the config file specified in the command line arguments -extern char* LuaToLoad; //Contains the filename of the lua script specified in the command line arguments -extern char* PaletteToLoad; //Contains the filename of the palette file specified in the command line arguments -extern char* AviToLoad; //Contains the filename of the Avi to be captured specified in the command line arguments -extern bool replayReadOnlySetting; -extern int replayStopFrameSetting; -extern int PauseAfterLoad; -extern int AVICapture; //This initiates AVI capture mode with a frame number, on that frame number the AVI will stop, FCEUX will close, and a special return value will be set -char *ParseArgies(int argc, char *argv[]); diff --git a/branches/fceux-2.2.2/src/drivers/win/cdlogger.cpp b/branches/fceux-2.2.2/src/drivers/win/cdlogger.cpp deleted file mode 100644 index 7c64ed9a..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/cdlogger.cpp +++ /dev/null @@ -1,593 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include "../../fceu.h" -#include "../../cart.h" //mbg merge 7/18/06 moved beneath fceu.h -#include "../../x6502.h" -#include "../../debug.h" -#include "debugger.h" -#include "tracer.h" -#include "cdlogger.h" -#include "main.h" //for GetRomName() -#include "utils/xstring.h" - -#define INESPRIV -#include "../../ines.h" - -#include "../../nsf.h" - -using namespace std; - -bool LoadCDLog(const char* nameo); -void LoadCDLogFile(); -void SaveCDLogFileAs(); -void SaveCDLogFile(); -void SaveStrippedROM(int invert); -void CDLoggerROMClosed(); -void CDLoggerROMChanged(); -bool PauseCDLogging(); -void StartCDLogging(); -void FreeCDLog(); -void InitCDLog(); -void ResetCDLog(); -void RenameCDLog(const char* newName); - -extern iNES_HEADER head; //defined in ines.c -extern uint8 *trainerpoo; - -//---------CDLogger VROM -extern volatile int rendercount, vromreadcount, undefinedvromcount; -extern unsigned char *cdloggervdata; -extern unsigned int cdloggerVideoDataSize; -extern int newppu; - -extern uint8 *NSFDATA; -extern int NSFMaxBank; -static uint8 NSFLoadLow; -static uint8 NSFLoadHigh; - -HWND hCDLogger; -int CDLogger_wndx=0, CDLogger_wndy=0; -bool autosaveCDL = true; -bool autoloadCDL = true; -bool autoresumeCDLogging = false; -char loadedcdfile[2048] = {0}; - -BOOL CALLBACK CDLoggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_DROPFILES: - { - UINT len; - char *ftmp; - - len=DragQueryFile((HDROP)wParam,0,0,0)+1; - if((ftmp=(char*)malloc(len))) - { - DragQueryFile((HDROP)wParam,0,ftmp,len); - string fileDropped = ftmp; - //adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking - //------------------------------------------------------- - //Check if .tbl - //------------------------------------------------------- - if (!(fileDropped.find(".cdl") == string::npos) && (fileDropped.find(".cdl") == fileDropped.length()-4)) - { - if(!LoadCDLog(fileDropped.c_str())) - FCEUD_PrintError("Error Opening CDL File!"); - } - else - { - std::string str = "Could not open " + fileDropped; - MessageBox(hwndDlg, str.c_str(), "File error", 0); - } - } - } - - break; - - case WM_MOVE: - { - if (!IsIconic(hwndDlg)) - { - RECT wrect; - GetWindowRect(hwndDlg,&wrect); - CDLogger_wndx = wrect.left; - CDLogger_wndy = wrect.top; - WindowBoundsCheckNoResize(CDLogger_wndx,CDLogger_wndy,wrect.right); - } - break; - }; - case WM_INITDIALOG: - if (CDLogger_wndx==-32000) CDLogger_wndx=0; //Just in case - if (CDLogger_wndy==-32000) CDLogger_wndy=0; - SetWindowPos(hwndDlg, 0, CDLogger_wndx, CDLogger_wndy, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - hCDLogger = hwndDlg; - InitCDLog(); - ResetCDLog(); - RenameCDLog(""); - if (autoloadCDL) - { - char nameo[2048]; - strcpy(nameo, GetRomPath()); - strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - strcat(nameo, ".cdl"); - LoadCDLog(nameo); - } - SetDlgItemText(hCDLogger, ID_CDLFILENAME, loadedcdfile); - CheckDlgButton(hCDLogger, IDC_AUTOSAVECDL, autosaveCDL ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hCDLogger, IDC_AUTOLOADCDL, autoloadCDL ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hCDLogger, IDC_AUTORESUMECDLOGGING, autoresumeCDLogging ? BST_CHECKED : BST_UNCHECKED); - break; - case WM_CLOSE: - case WM_QUIT: - if (PauseCDLogging()) - { - if (autosaveCDL) - SaveCDLogFile(); - FreeCDLog(); - RenameCDLog(""); - hCDLogger = 0; - EndDialog(hwndDlg, 0); - } - break; - case WM_COMMAND: - switch(HIWORD(wParam)) - { - case BN_CLICKED: - { - switch(LOWORD(wParam)) - { - case BTN_CDLOGGER_RESET: - { - ResetCDLog(); - UpdateCDLogger(); - break; - } - case BTN_CDLOGGER_LOAD: - LoadCDLogFile(); - break; - case BTN_CDLOGGER_START_PAUSE: - if (FCEUI_GetLoggingCD()) - PauseCDLogging(); - else - StartCDLogging(); - break; - case BTN_CDLOGGER_SAVE_AS: - SaveCDLogFileAs(); - break; - case BTN_CDLOGGER_SAVE: - SaveCDLogFile(); - break; - case BTN_CDLOGGER_SAVE_STRIPPED: - SaveStrippedROM(0); - break; - case BTN_CDLOGGER_SAVE_UNUSED: - SaveStrippedROM(1); - break; - case IDC_AUTOSAVECDL: - autosaveCDL = (IsDlgButtonChecked(hCDLogger, IDC_AUTOSAVECDL) == BST_CHECKED); - break; - case IDC_AUTOLOADCDL: - autoloadCDL = (IsDlgButtonChecked(hCDLogger, IDC_AUTOLOADCDL) == BST_CHECKED); - break; - case IDC_AUTORESUMECDLOGGING: - autoresumeCDLogging = (IsDlgButtonChecked(hCDLogger, IDC_AUTORESUMECDLOGGING) == BST_CHECKED); - break; - } - break; - } - } - break; - case WM_MOVING: - break; - } - return FALSE; -} - -bool LoadCDLog(const char* nameo) -{ - FILE *FP; - int i,j; - - FP = fopen(nameo, "rb"); - if (FP == NULL) - return false; - - for(i = 0;i < (int)cdloggerdataSize;i++) - { - j = fgetc(FP); - if (j == EOF) - break; - if ((j & 1) && !(cdloggerdata[i] & 1)) - codecount++; //if the new byte has something logged and - if ((j & 2) && !(cdloggerdata[i] & 2)) - datacount++; //and the old one doesn't. Then increment - if ((j & 3) && !(cdloggerdata[i] & 3)) - undefinedcount--; //the appropriate counter. - cdloggerdata[i] |= j; - } - - if(cdloggerVideoDataSize != 0) - { - for(i = 0;i < (int)cdloggerVideoDataSize;i++) - { - j = fgetc(FP); - if(j == EOF)break; - if((j & 1) && !(cdloggervdata[i] & 1))rendercount++; //if the new byte has something logged and - if((j & 2) && !(cdloggervdata[i] & 2))vromreadcount++; //if the new byte has something logged and - if((j & 3) && !(cdloggervdata[i] & 3))undefinedvromcount--; //the appropriate counter. - cdloggervdata[i] |= j; - } - } - - fclose(FP); - RenameCDLog(nameo); - UpdateCDLogger(); - return true; -} - -void LoadCDLogFile() -{ - const char filter[]="Code Data Log File (*.CDL)\0*.cdl\0\0"; - char nameo[2048]; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Load Code Data Log File..."; - ofn.lpstrFilter=filter; - nameo[0]=0; - ofn.lpstrFile=nameo; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hCDLogger; - if (!GetOpenFileName(&ofn)) - return; - if(!LoadCDLog(nameo)) - FCEUD_PrintError("Error Opening CDL File!"); -} - -void SaveCDLogFileAs() -{ - const char filter[]="Code Data Log File (*.CDL)\0*.cdl\0All Files (*.*)\0*.*\0\0"; - char nameo[2048] = {0}; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save Code Data Log File As..."; - ofn.lpstrFilter=filter; - if (loadedcdfile[0]) - { - strcpy(nameo, loadedcdfile); - } else - { - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - strcat(nameo, ".cdl"); - } - ofn.lpstrDefExt = "cdl"; - ofn.lpstrFile = nameo; - ofn.nMaxFile = 256; - ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hCDLogger; - if (!GetSaveFileName(&ofn)) - return; - RenameCDLog(nameo); - SaveCDLogFile(); -} - -void SaveCDLogFile() -{ - if (loadedcdfile[0] == 0) - { - char nameo[2048]; - strcpy(nameo, GetRomPath()); - strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - strcat(nameo, ".cdl"); - RenameCDLog(nameo); - } - - FILE *FP; - FP = fopen(loadedcdfile, "wb"); - if (FP == NULL) - { - FCEUD_PrintError("Error Saving File"); - return; - } - fwrite(cdloggerdata, cdloggerdataSize, 1, FP); - if(cdloggerVideoDataSize != 0) - fwrite(cdloggervdata, cdloggerVideoDataSize, 1, FP); - fclose(FP); -} - -// returns false if refused to start -bool DoCDLogger() -{ - if (!GameInfo) - { - FCEUD_PrintError("You must have a game loaded before you can use the Code Data Logger."); - return false; - } - - if(!hCDLogger) - { - CreateDialog(fceu_hInstance,"CDLOGGER",NULL,CDLoggerCallB); - } else - { - ShowWindow(hCDLogger, SW_SHOWNORMAL); - SetForegroundWindow(hCDLogger); - } - return true; -} - -void UpdateCDLogger() -{ - if(!hCDLogger) return; - - char str[50]; - float fcodecount = codecount; - float fdatacount = datacount; - float frendercount = rendercount; - float fvromreadcount = vromreadcount; - float fundefinedcount = undefinedcount; - float fundefinedvromcount = undefinedvromcount; - float fromsize = cdloggerdataSize; - float fvromsize = (cdloggerVideoDataSize != 0) ? cdloggerVideoDataSize : 1; - - sprintf(str,"0x%06x %.2f%%", codecount, (fcodecount / fromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_CODECOUNT, str); - sprintf(str,"0x%06x %.2f%%", datacount,(fdatacount / fromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_DATACOUNT, str); - sprintf(str,"0x%06x %.2f%%", undefinedcount, (fundefinedcount / fromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_UNDEFCOUNT, str); - - sprintf(str,"0x%06x %.2f%%", rendercount, (frendercount / fvromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_RENDERCOUNT, str); - sprintf(str,"0x%06x %.2f%%", vromreadcount, (fvromreadcount / fvromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_VROMREADCOUNT, str); - sprintf(str,"0x%06x %.2f%%", undefinedvromcount, (fundefinedvromcount / fvromsize) * 100); - SetDlgItemText(hCDLogger, LBL_CDLOGGER_UNDEFVROMCOUNT, str); - return; -} - -void SaveStrippedROM(int invert) -{ - //this is based off of iNesSave() - //todo: make this support NSFs - const char NESfilter[]="Stripped iNes Rom file (*.NES)\0*.nes\0All Files (*.*)\0*.*\0\0"; - const char NSFfilter[]="Stripped NSF file (*.NSF)\0*.nsf\0All Files (*.*)\0*.*\0\0"; - char sromfilename[MAX_PATH]; - FILE *fp; - OPENFILENAME ofn; - iNES_HEADER cdlhead; - int i; - - if (!GameInfo) - return; - - if (GameInfo->type==GIT_NSF) - { - MessageBox(NULL, "Sorry, you're not allowed to save optimized NSFs yet. Please don't optimize individual banks, as there are still some issues with several NSFs to be fixed, and it is easier to fix those issues with as much of the bank data intact as possible.", "Disallowed", MB_OK); - return; - } - - if(codecount == 0) - { - MessageBox(NULL, "Unable to Generate Stripped ROM. Get Something Logged and try again.", "Error", MB_OK); - return; - } - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save Stripped File As..."; - strcpy(sromfilename, mass_replace(GetRomName(), "|", ".").c_str()); - if (GameInfo->type==GIT_NSF) { - ofn.lpstrFilter=NSFfilter; - ofn.lpstrDefExt = "nsf"; - } else { - ofn.lpstrFilter=NESfilter; - ofn.lpstrDefExt = "nes"; - } - ofn.lpstrFile=sromfilename; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hCDLogger; - if(!GetSaveFileName(&ofn))return; - - fp = fopen(sromfilename,"wb"); - - if(GameInfo->type==GIT_NSF) - { - //Not used because if bankswitching, the addresses involved - //could still end up being used through writes - //static uint16 LoadAddr; - //LoadAddr=NSFHeader.LoadAddressLow; - //LoadAddr|=(NSFHeader.LoadAddressHigh&0x7F)<<8; - - //Simple store/restore for writing a working NSF header - NSFLoadLow = NSFHeader.LoadAddressLow; - NSFLoadHigh = NSFHeader.LoadAddressHigh; - NSFHeader.LoadAddressLow=0; - NSFHeader.LoadAddressHigh&=0xF0; - fwrite(&NSFHeader,1,0x8,fp); - NSFHeader.LoadAddressLow = NSFLoadLow; - NSFHeader.LoadAddressHigh = NSFLoadHigh; - - fseek(fp,0x8,SEEK_SET); - for(i = 0;i < ((NSFMaxBank+1)*4096);i++){ - unsigned char pchar; - if(cdloggerdata[i] & 3) - pchar = invert?0:NSFDATA[i]; - else - pchar = invert?NSFDATA[i]:0; - fputc(pchar, fp); - } - - } - else - { - cdlhead.ID[0] = 'N'; - cdlhead.ID[1] = 'E'; - cdlhead.ID[2] = 'S'; - cdlhead.ID[3] = 0x1A; - - cdlhead.ROM_size = cdloggerdataSize >> 14; - cdlhead.VROM_size = cdloggerVideoDataSize >> 13; - - fwrite(&cdlhead,1,16,fp); - - for(i = 0; i < (int)cdloggerdataSize; i++){ - unsigned char pchar; - if(cdloggerdata[i] & 3) - pchar = invert?0:PRGptr[0][i]; - else - pchar = invert?PRGptr[0][i]:0; - fputc(pchar, fp); - } - - if(cdloggerVideoDataSize != 0) - { - // since the OldPPU at least logs the $2007 read accesses, we should save the data anyway - for(i = 0; i < (int)cdloggerVideoDataSize; i++) { - unsigned char vchar; - if(cdloggervdata[i] & 3) - vchar = invert?0:CHRptr[0][i]; - else - vchar = invert?CHRptr[0][i]:0; - fputc(vchar, fp); - } - } - } - fclose(fp); -} - -void CDLoggerROMClosed() -{ - if (hCDLogger) - { - PauseCDLogging(); - if (autosaveCDL) - SaveCDLogFile(); - } -} - -void CDLoggerROMChanged() -{ - if (hCDLogger) - { - FreeCDLog(); - InitCDLog(); - ResetCDLog(); - RenameCDLog(""); - UpdateCDLogger(); - } - - if (!autoresumeCDLogging) - return; - - // try to load respective CDL file - char nameo[2048]; - strcpy(nameo, GetRomPath()); - strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - strcat(nameo, ".cdl"); - - FILE *FP; - FP = fopen(nameo, "rb"); - if (FP != NULL) - { - // .cdl file with this ROM name exists - fclose(FP); - if (!hCDLogger) - DoCDLogger(); - if (LoadCDLog(nameo)) - StartCDLogging(); - } -} - -bool PauseCDLogging() -{ - // can't pause while Trace Logger is using - if ((logging) && (logging_options & LOG_NEW_INSTRUCTIONS)) - { - MessageBox(hCDLogger, "The Trace Logger is currently using this for some of its features.\nPlease turn the Trace Logger off and try again.","Unable to Pause Code/Data Logger", MB_OK); - return false; - } - FCEUI_SetLoggingCD(0); - EnableTracerMenuItems(); - SetDlgItemText(hCDLogger, BTN_CDLOGGER_START_PAUSE, "Start"); - return true; -} - -void StartCDLogging() -{ - FCEUI_SetLoggingCD(1); - EnableTracerMenuItems(); - SetDlgItemText(hCDLogger, BTN_CDLOGGER_START_PAUSE, "Pause"); -} - -void FreeCDLog() -{ - if (cdloggerdata) - { - free(cdloggerdata); - cdloggerdata = 0; - cdloggerdataSize = 0; - } - if (cdloggervdata) - { - free(cdloggervdata); - cdloggervdata = 0; - cdloggerVideoDataSize = 0; - } -} - -void InitCDLog() -{ - cdloggerdataSize = PRGsize[0]; - cdloggerdata = (unsigned char*)malloc(cdloggerdataSize); - if(!CHRram[0] || (CHRptr[0] == PRGptr[0])) { // Some kind of workaround for my OneBus VRAM hack, will remove it if I find another solution for that - cdloggerVideoDataSize = CHRsize[0]; - cdloggervdata = (unsigned char*)malloc(cdloggerVideoDataSize); - } else - cdloggerVideoDataSize = 0; -} - -void ResetCDLog() -{ - codecount = datacount = rendercount = vromreadcount = 0; - undefinedcount = cdloggerdataSize; - ZeroMemory(cdloggerdata, cdloggerdataSize); - if(cdloggerVideoDataSize != 0) - { - undefinedvromcount = cdloggerVideoDataSize; - ZeroMemory(cdloggervdata, cdloggerVideoDataSize); - } -} - -void RenameCDLog(const char* newName) -{ - strcpy(loadedcdfile, newName); - if (hCDLogger) - { - SetDlgItemText(hCDLogger, ID_CDLFILENAME, loadedcdfile); - } -} diff --git a/branches/fceux-2.2.2/src/drivers/win/cdlogger.h b/branches/fceux-2.2.2/src/drivers/win/cdlogger.h deleted file mode 100644 index 882bf678..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/cdlogger.h +++ /dev/null @@ -1,10 +0,0 @@ -//#include -// -bool DoCDLogger(); -void UpdateCDLogger(); -//void LogPCM(int romaddress); //No longer used -// -extern HWND hCDLogger; -//extern volatile int codecount, datacount, undefinedcount; -//extern volatile int loggingcodedata; -//extern unsigned char *cdloggerdata; diff --git a/branches/fceux-2.2.2/src/drivers/win/cheat.cpp b/branches/fceux-2.2.2/src/drivers/win/cheat.cpp deleted file mode 100644 index 09c5e4d2..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/cheat.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include "cheat.h" -#include "memview.h" -#include "memwatch.h" -#include "debugger.h" -#include "../../fceu.h" -#include "../../cart.h" -#include "../../cheat.h" // For FCEU_LoadGameCheats() - -static HWND pwindow = 0; //Handle to Cheats dialog -HWND hCheat = 0; //mbg merge 7/19/06 had to add -static HMENU hCheatcontext; //Handle to context menu -static HMENU hCheatcontextsub; //Handle to context sub menu - -void InitializeCheatsAdded(HWND hwndDlg); - -bool pauseWhileActive = false; //For checkbox "Pause while active" -extern bool wasPausedByCheats; - -int CheatWindow; -int CheatStyle=1; - -#define GGLISTSIZE 128 //hopefully this is enough for all cases - -int selcheat; -int selcheatcount; -int ChtPosX,ChtPosY; -int GGConv_wndx=0, GGConv_wndy=0; -static HFONT hFont,hNewFont; - -static int scrollindex; -static int scrollnum; -static int scrollmax; - -int lbfocus=0; -int searchdone; -static int knownvalue=0; - -int GGaddr, GGcomp, GGval; -char GGcode[10]; -int GGlist[GGLISTSIZE]; -static int dontupdateGG; //this eliminates recursive crashing - -bool dodecode; - -HWND hGGConv; - -void EncodeGG(char *str, int a, int v, int c); -void ListGGAddresses(); - -uint16 StrToU16(char *s) -{ - unsigned int ret=0; - sscanf(s,"%4x",&ret); - return ret; -} - -uint8 StrToU8(char *s) -{ - unsigned int ret=0; - sscanf(s,"%2x",&ret); - return ret; -} - -char *U16ToStr(uint16 a) -{ - static char str[5]; - sprintf(str,"%04X",a); - return str; -} - -char *U8ToStr(uint8 a) -{ - static char str[3]; - sprintf(str,"%02X",a); - return str; -} - -static HWND hwndLB; -//int RedoCheatsCallB(char *name, uint32 a, uint8 v, int s) { //bbit edited: this commented out line was changed to the below for the new fceud -int RedoCheatsCallB(char *name, uint32 a, uint8 v, int c, int s, int type, void*data) -{ - char str[259] = { 0 }; - - strcpy(str,(s?"* ":" ")); - if(name[0] == 0) { - if(a >= 0x8000) { - EncodeGG(str+2, a, v, c); - } else { - if(c == -1) sprintf(str+2,"%04X:%02X",(int)a,(int)v); - else sprintf(str+2,"%04X?%02X:%02X",(int)a,(int)c,(int)v); - } - } - else strcat(str,name); - - SendDlgItemMessage(hwndLB,IDC_LIST_CHEATS,LB_ADDSTRING,0,(LPARAM)(LPSTR)str); - return 1; -} - -void RedoCheatsLB(HWND hwndDlg) -{ - SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LB_RESETCONTENT, 0, 0); - hwndLB = hwndDlg; - FCEUI_ListCheats(RedoCheatsCallB, 0); - - if (selcheat >= 0) - { - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_DEL), TRUE); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_UPD), TRUE); - } else - { - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_DEL), FALSE); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_UPD), FALSE); - } -} - -int ShowResultsCallB(uint32 a, uint8 last, uint8 current) -{ - char temp[16]; - - sprintf(temp,"$%04X: %02X | %02X",(unsigned int)a,last,current); - SendDlgItemMessage(hwndLB,IDC_CHEAT_LIST_POSSIBILITIES,LB_ADDSTRING,0,(LPARAM)(LPSTR)temp); - return 1; -} - -void ShowResults(HWND hwndDlg) -{ - int n=FCEUI_CheatSearchGetCount(); - int t; - char str[20]; - - scrollnum=n; - scrollindex=-32768; - - hwndLB=hwndDlg; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,0,0); - FCEUI_CheatSearchGetRange(0,16,ShowResultsCallB); - - t=-32768+n-17; - if (t<-32768) t=-32768; - scrollmax=t; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETRANGE,-32768,t); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,-32768,1); - - sprintf(str,"%d Possibilities",n); - SetDlgItemText(hwndDlg,IDC_CHEAT_BOX_POSSIBILITIES,str); -} - -void EnableCheatButtons(HWND hwndDlg, int enable) -{ - EnableWindow(GetDlgItem(hwndDlg,IDC_CHEAT_VAL_KNOWN),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_KNOWN),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_EQ),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_NE),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_GT),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_LT),enable); -} - -BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - LOGFONT lf; - RECT wrect; - - char str[259] = { 0 },str2[259] = { 0 }; - - char *name; - uint32 a; - uint8 v; - int c; - int s; - - switch (uMsg) - { - case WM_INITDIALOG: - if (ChtPosX==-32000) ChtPosX=0; //Just in case - if (ChtPosY==-32000) ChtPosY=0; - SetWindowPos(hwndDlg,0,ChtPosX,ChtPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - - CheckDlgButton(hwndDlg, IDC_CHEAT_PAUSEWHENACTIVE, pauseWhileActive ? MF_CHECKED : MF_UNCHECKED); - - //setup font - hFont = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0); - GetObject(hFont, sizeof(LOGFONT), &lf); - strcpy(lf.lfFaceName,"Courier New"); - hNewFont = CreateFontIndirect(&lf); - - SendDlgItemMessage(hwndDlg,IDC_CHEAT_ADDR,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_COM,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_KNOWN,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_NE_BY,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_GT_BY,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_LT_BY,WM_SETFONT,(WPARAM)hNewFont,FALSE); - - //text limits - SendDlgItemMessage(hwndDlg,IDC_CHEAT_ADDR,EM_SETLIMITTEXT,4,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_COM,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_NAME,EM_SETLIMITTEXT,256,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_KNOWN,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_NE_BY,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_GT_BY,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_VAL_LT_BY,EM_SETLIMITTEXT,2,0); - - //disable or enable buttons - EnableWindow(GetDlgItem(hwndDlg,IDC_CHEAT_VAL_KNOWN),FALSE); - if (scrollnum) - { - EnableCheatButtons(hwndDlg,TRUE); - ShowResults(hwndDlg); - sprintf(str,"%d Possibilities",(int)FCEUI_CheatSearchGetCount()); - SetDlgItemText(hwndDlg,IDC_CHEAT_BOX_POSSIBILITIES,str); - } - else EnableCheatButtons(hwndDlg,FALSE); - - //misc setup - searchdone=0; - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL_KNOWN,(LPTSTR)U8ToStr(knownvalue)); - // Enable Context Sub-Menus - hCheatcontext = LoadMenu(fceu_hInstance,"CHEATCONTEXTMENUS"); - - break; - - case WM_KILLFOCUS: - break; - - case WM_NCACTIVATE: - if (pauseWhileActive) - { - if (EmulationPaused == 0) - { - EmulationPaused = 1; - wasPausedByCheats = true; - FCEU_printf("Emulation paused: %d\n", EmulationPaused); - } - - } - if ((CheatStyle) && (scrollnum)) { - if ((!wParam) && (searchdone)) { - searchdone=0; - FCEUI_CheatSearchSetCurrentAsOriginal(); - } - ShowResults(hwndDlg); - } - break; - - case WM_CLOSE: - case WM_QUIT: - CheatWindow=0; - hCheat = 0; - if (CheatStyle) DestroyWindow(hwndDlg); - else EndDialog(hwndDlg,0); - DeleteObject(hFont); - DeleteObject(hNewFont); - if (searchdone) FCEUI_CheatSearchSetCurrentAsOriginal(); - break; - - case WM_MOVE: - if (!IsIconic(hwndDlg)) { - GetWindowRect(hwndDlg,&wrect); - ChtPosX = wrect.left; - ChtPosY = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(ChtPosX,ChtPosY,wrect.right); - #endif - } - break; - - case WM_VSCROLL: - if (scrollnum > 16) { - switch (LOWORD(wParam)) { - case SB_TOP: - scrollindex=-32768; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,16,0); - FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+16,ShowResultsCallB); - break; - case SB_BOTTOM: - scrollindex=scrollmax; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,16,0); - FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+16,ShowResultsCallB); - break; - case SB_LINEUP: - if (scrollindex > -32768) { - scrollindex--; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,16,0); - FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+16,ShowResultsCallB); - } - break; - case SB_PAGEUP: - scrollindex-=17; - if(scrollindex<-32768) scrollindex=-32768; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,16,0); - FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+16,ShowResultsCallB); - break; - - case SB_LINEDOWN: - if (scrollindexscrollmax) scrollindex=scrollmax; - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,0,0); - FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+16,ShowResultsCallB); - break; - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - scrollindex=(short int)HIWORD(wParam); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_SCRL_POSSIBILITIES,SBM_SETPOS,scrollindex,1); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_RESETCONTENT,0,0); - FCEUI_CheatSearchGetRange(32768+scrollindex,32768+scrollindex+16,ShowResultsCallB); - break; - } - - } - break; - - case WM_VKEYTOITEM: - if (lbfocus) { - int real; - - real=SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_GETCURSEL,0,0); - switch (LOWORD(wParam)) { - case VK_UP: - // mmmm....recursive goodness - if (real == 0) SendMessage(hwndDlg,WM_VSCROLL,SB_LINEUP,0); - return -1; - break; - case VK_DOWN: - if (real == 16) { - SendMessage(hwndDlg,WM_VSCROLL,SB_LINEDOWN,0); - SendDlgItemMessage(hwndDlg,IDC_CHEAT_LIST_POSSIBILITIES,LB_SETCURSEL,real,0); - } - return -1; - break; - case VK_PRIOR: - SendMessage(hwndDlg,WM_VSCROLL,SB_PAGEUP,0); - break; - case VK_NEXT: - SendMessage(hwndDlg,WM_VSCROLL,SB_PAGEDOWN,0); - break; - case VK_HOME: - SendMessage(hwndDlg,WM_VSCROLL,SB_TOP,0); - break; - case VK_END: - SendMessage(hwndDlg,WM_VSCROLL,SB_BOTTOM,0); - break; - } - return -2; - } - break; - - case WM_CONTEXTMENU: - { - // Handle certain subborn context menus for nearly incapable controls. - - if (wParam == (uint32)GetDlgItem(hwndDlg,IDC_LIST_CHEATS)) { - // Only open the menu if a cheat is selected - if (selcheat >= 0) { - // Open IDC_LIST_CHEATS Context Menu - hCheatcontextsub = GetSubMenu(hCheatcontext,0); - SetMenuDefaultItem(hCheatcontextsub, CHEAT_CONTEXT_TOGGLECHEAT, false); - if (lParam != -1) - TrackPopupMenu(hCheatcontextsub,TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,hwndDlg,0); //Create menu - else { // Handle the context menu keyboard key - GetWindowRect(GetDlgItem(hwndDlg,IDC_LIST_CHEATS), &wrect); - TrackPopupMenu(hCheatcontextsub,TPM_RIGHTBUTTON,wrect.left + int((wrect.right - wrect.left) / 3),wrect.top + int((wrect.bottom - wrect.top) / 3),0,hwndDlg,0); //Create menu - } - - } - } - - } - break; - - case WM_COMMAND: - switch (HIWORD(wParam)) { - case BN_CLICKED: - switch (LOWORD(wParam)) { - case CHEAT_CONTEXT_TOGGLECHEAT: - CheatConsoleCallB(hwndDlg, WM_COMMAND, (LBN_DBLCLK * 0x10000) | (IDC_LIST_CHEATS), lParam); - break; - case CHEAT_CONTEXT_POKECHEATVALUE: - FCEUI_GetCheat(selcheat,&name,&a,&v,NULL,&s,NULL); - BWrite[a](a,v); - break; - case CHEAT_CONTEXT_GOTOINHEXEDITOR: - DoMemView(); - FCEUI_GetCheat(selcheat,&name,&a,&v,NULL,&s,NULL); - SetHexEditorAddress(a); - break; - case IDC_CHEAT_PAUSEWHENACTIVE: - pauseWhileActive ^= 1; - if ((EmulationPaused == 1 ? true : false) != pauseWhileActive) - { - EmulationPaused = (pauseWhileActive ? 1 : 0); - wasPausedByCheats = pauseWhileActive; - if (EmulationPaused) - FCEU_printf("Emulation paused: %d\n", EmulationPaused); - } - break; - case IDC_BTN_CHEAT_ADD: - dodecode = true; - - GetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,str,5); - if(str[0] != 0) dodecode = false; - a=StrToU16(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL,str,3); - if(str[0] != 0) dodecode = false; - v=StrToU8(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_COM,str,3); - if(str[0] != 0) dodecode = false; - c=(str[0] == 0)?-1:StrToU8(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_NAME,str,256); - if(dodecode && (strlen(str) == 6 || strlen(str) == 8)) { - if(FCEUI_DecodeGG(str, &GGaddr, &GGval, &GGcomp)) { - a = GGaddr; - v = GGval; - c = GGcomp; - } - } -// if (FCEUI_AddCheat(str,a,v)) { //bbit edited: replaced this with the line below - if (FCEUI_AddCheat(str,a,v,c,1)) { - if(str[0] == 0) { - if(a >= 0x8000) EncodeGG(str, a, v, c); - else { - if(c == -1) sprintf(str,"%04X:%02X",(int)a,(int)v); //bbit edited: added this line to give your cheat a name if you didn't supply one - else sprintf(str,"%04X?%02X:%02X",(int)a,(int)c,(int)v); - } - } - strcpy(str2,"* "); - strcat(str2,str); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_ADDSTRING,0,(LPARAM)(LPSTR)str2); - selcheat = (SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETCOUNT,0,0) - 1); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETSEL,(WPARAM)1,selcheat); - - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_NAME,(LPTSTR)""); - } - if (hMemView) UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well - UpdateCheatsAdded(); - break; - case ID_CHEATLISTPOPUP_DELETESELECTEDCHEATS: - case IDC_BTN_CHEAT_DEL: - if (selcheatcount > 1) - { - if (IDYES == MessageBox(hwndDlg, "Multiple cheats selected. Continue with delete?", "Delete multiple cheats?", MB_ICONQUESTION | MB_YESNO)) { //Get message box - selcheat=-1; - for (int selcheattemp=SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETCOUNT,0,0)-1;selcheattemp>=0;selcheattemp--) { - if (SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETSEL,selcheattemp,0)) { - FCEUI_DelCheat(selcheattemp); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_DELETESTRING,selcheattemp,0); - } - } - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_NAME,(LPTSTR)""); - if (hMemView) UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well - UpdateCheatsAdded(); - } - } else { - if (selcheat >= 0) { - FCEUI_DelCheat(selcheat); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_DELETESTRING,selcheat,0); - selcheat=-1; - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - SetDlgItemText(hwndDlg,IDC_CHEAT_NAME,(LPTSTR)""); - } - if (hMemView) UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well - UpdateCheatsAdded(); - } - break; - case IDC_BTN_CHEAT_UPD: - dodecode = true; - - if (selcheat < 0) break; - GetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,str,5); - if(str[0] != 0) dodecode = false; - a=StrToU16(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL,str,3); - if(str[0] != 0) dodecode = false; - v=StrToU8(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_COM,str,3); - if(str[0] != 0) dodecode = false; - c=(str[0] == 0)?-1:StrToU8(str); - GetDlgItemText(hwndDlg,IDC_CHEAT_NAME,str,256); - if(dodecode && (strlen(str) == 6 || strlen(str) == 8)) { - if(FCEUI_DecodeGG(str, &GGaddr, &GGval, &GGcomp)) { - a = GGaddr; - v = GGval; - c = GGcomp; - } - } -// FCEUI_SetCheat(selcheat,str,a,v,-1); //bbit edited: replaced this with the line below - FCEUI_SetCheat(selcheat,str,a,v,c,-1,1); -// FCEUI_GetCheat(selcheat,&name,&a,&v,&s); //bbit edited: replaced this with the line below - FCEUI_GetCheat(selcheat,&name,&a,&v,&c,&s,NULL); - strcpy(str2,(s?"* ":" ")); - if(str[0] == 0) { - if(a >= 0x8000) EncodeGG(str, a, v, c); - else { - if(c == -1) sprintf(str,"%04X:%02X",(int)a,(int)v); //bbit edited: added this line to give your cheat a name if you didn't supply one - else sprintf(str,"%04X?%02X:%02X",(int)a,(int)c,(int)v); - } - } - strcat(str2,str); - - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_DELETESTRING,selcheat,0); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_INSERTSTRING,selcheat,(LPARAM)(LPSTR)str2); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETSEL,(WPARAM)1,selcheat); - - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)U16ToStr(a)); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)U8ToStr(v)); - if(c == -1) SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - else SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)U8ToStr(c)); - if(hMemView)UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well - break; - case IDC_BTN_CHEAT_ADDFROMFILE: - { - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndDlg; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Open Cheats file"; - const char filter[] = "Cheat files (*.cht)\0*.cht\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFilter = filter; - - char nameo[2048] = {0}; - ofn.lpstrFile = nameo; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; - std::string initdir = FCEU_GetPath(FCEUMKF_CHEAT); - ofn.lpstrInitialDir = initdir.c_str(); - - if (GetOpenFileName(&ofn)) - { - FILE* file = FCEUD_UTF8fopen(nameo, "rb"); - if (file) - { - FCEU_LoadGameCheats(file); - if (hMemView) UpdateColorTable(); //if the memory viewer is open then update any blue freeze locations in it as well - UpdateCheatsAdded(); - savecheats = 1; - } - } - break; - } - case IDC_BTN_CHEAT_RESET: - FCEUI_CheatSearchBegin(); - ShowResults(hwndDlg); - EnableCheatButtons(hwndDlg,TRUE); - break; - case IDC_BTN_CHEAT_KNOWN: - searchdone=1; - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL_KNOWN,str,3); - knownvalue=StrToU8(str); - FCEUI_CheatSearchEnd(4,knownvalue,0); - ShowResults(hwndDlg); - break; - case IDC_BTN_CHEAT_EQ: - searchdone=1; - FCEUI_CheatSearchEnd(2,0,0); - ShowResults(hwndDlg); - break; - case IDC_BTN_CHEAT_NE: - searchdone=1; - if (IsDlgButtonChecked(hwndDlg,IDC_CHEAT_CHECK_NE_BY) == BST_CHECKED) { - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL_NE_BY,str,3); - FCEUI_CheatSearchEnd(2,0,StrToU8(str)); - } - else FCEUI_CheatSearchEnd(3,0,0); - ShowResults(hwndDlg); - break; - case IDC_BTN_CHEAT_GT: - searchdone=1; - if (IsDlgButtonChecked(hwndDlg,IDC_CHEAT_CHECK_GT_BY) == BST_CHECKED) { - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL_GT_BY,str,3); - FCEUI_CheatSearchEnd(7,0,StrToU8(str)); - } - else FCEUI_CheatSearchEnd(5,0,0); - ShowResults(hwndDlg); - break; - case IDC_BTN_CHEAT_LT: - searchdone=1; - if (IsDlgButtonChecked(hwndDlg,IDC_CHEAT_CHECK_LT_BY) == BST_CHECKED) { - GetDlgItemText(hwndDlg,IDC_CHEAT_VAL_LT_BY,str,3); - FCEUI_CheatSearchEnd(8,0,StrToU8(str)); - } - else FCEUI_CheatSearchEnd(6,0,0); - ShowResults(hwndDlg); - break; - } - break; - case LBN_DBLCLK: - switch (LOWORD(wParam)) { //disable/enable cheat - case IDC_CHEAT_LIST_POSSIBILITIES: - if (EmulationPaused == 1) //We only want to send info to memwatch if paused - { //otherwise we will be sending info while it is updating causing unpredictable behavior - lbfocus=1; - SendDlgItemMessage(hwndDlg, - IDC_CHEAT_LIST_POSSIBILITIES, - LB_GETTEXT, - SendDlgItemMessage(hwndDlg, - IDC_CHEAT_LIST_POSSIBILITIES, - LB_GETCURSEL,0,0), - (LPARAM)(LPCTSTR)str); - strcpy(str2,str+1); - str2[4] = 0; - AddMemWatch(str2); - } - break; - case IDC_LIST_CHEATS: - //SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETSEL,(WPARAM)x,(LPARAM)0); - for (int selcheattemp=SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETCOUNT,0,0)-1;selcheattemp>=0;selcheattemp--) { - if (SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_GETSEL,selcheattemp,0)) { -// FCEUI_GetCheat(selcheattemp,&name,&a,&v,&s); //bbit edited: replaced this with the line below - FCEUI_GetCheat(selcheattemp,&name,&a,&v,&c,&s,NULL); -// FCEUI_SetCheat(selcheattemp,0,-1,-1,s^=1);//bbit edited: replaced this with the line below - FCEUI_SetCheat(selcheattemp,0,-1,-1,-2,s^=1,1); - strcpy(str,(s?"* ":" ")); - if(name[0] == 0) { - if(a >= 0x8000) EncodeGG(str+2, a, v, c); - else { - if(c == -1) sprintf(str+2,"%04X:%02X",(int)a,(int)v); //bbit edited: added this line to give your cheat a name if you didn't supply one - else sprintf(str+2,"%04X?%02X:%02X",(int)a,(int)c,(int)v); - } - } - else strcat(str,name); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_DELETESTRING,selcheattemp,0); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_INSERTSTRING,selcheattemp,(LPARAM)(LPSTR)str); - } - } - UpdateCheatsAdded(); - UpdateColorTable(); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0); - SendDlgItemMessage(hwndDlg,IDC_LIST_CHEATS,LB_SETSEL,(WPARAM)1,selcheat); - break; - } - break; - case LBN_SELCHANGE: - switch (LOWORD(wParam)) { - case IDC_LIST_CHEATS: - selcheat = SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LB_GETCURSEL, 0, 0); - selcheatcount = SendDlgItemMessage(hwndDlg, IDC_LIST_CHEATS, LB_GETSELCOUNT, 0, 0); - if (selcheat < 0) break; - - FCEUI_GetCheat(selcheat,&name,&a,&v,&c,&s,NULL); - SetDlgItemText(hwndDlg,IDC_CHEAT_NAME,(LPTSTR)name); - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)U16ToStr(a)); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)U8ToStr(v)); - if (c == -1) - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - else - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)U8ToStr(c)); - - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_DEL),TRUE); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_UPD),TRUE); - break; - case IDC_CHEAT_LIST_POSSIBILITIES: - lbfocus=1; - SendDlgItemMessage(hwndDlg, - IDC_CHEAT_LIST_POSSIBILITIES, - LB_GETTEXT, - SendDlgItemMessage(hwndDlg, - IDC_CHEAT_LIST_POSSIBILITIES, - LB_GETCURSEL,0,0), - (LPARAM)(LPCTSTR)str); - strcpy(str2,str+1); - str2[4] = 0; - SetDlgItemText(hwndDlg,IDC_CHEAT_ADDR,(LPTSTR)str2); - strcpy(str2,str+13); - SetDlgItemText(hwndDlg,IDC_CHEAT_VAL,(LPTSTR)str2); - SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - break; - } - break; - case LBN_SELCANCEL: - switch(LOWORD(wParam)) { - case IDC_LIST_CHEATS: - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_DEL),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_CHEAT_UPD),FALSE); - break; - case IDC_CHEAT_LIST_POSSIBILITIES: - lbfocus=0; - break; - } - break; - - } - break; - } - return 0; -} - - -void ConfigCheats(HWND hParent) -{ - if (!GameInfo) - { - FCEUD_PrintError("You must have a game loaded before you can manipulate cheats."); - return; - } - //if (GameInfo->type==GIT_NSF) { - // FCEUD_PrintError("Sorry, you can't cheat with NSFs."); - // return; - //} - - if (!CheatWindow) - { - selcheat=-1; - CheatWindow=1; - if (CheatStyle) - pwindow = hCheat = CreateDialog(fceu_hInstance, "CHEATCONSOLE", NULL, CheatConsoleCallB); - else - DialogBox(fceu_hInstance,"CHEATCONSOLE",hParent,CheatConsoleCallB); - UpdateCheatsAdded(); - } else - { - ShowWindow(hCheat, SW_SHOWNORMAL); - SetForegroundWindow(hCheat); - } -} - -void UpdateCheatList() -{ - if(!pwindow) - return; - else - ShowResults(pwindow); -} - -//Used by cheats and external dialogs such as hex editor to update items in the cheat search dialog -void UpdateCheatsAdded() -{ - char temp[64]; - if (FrozenAddressCount < 256) - { - sprintf(temp,"Active Cheats %d", FrozenAddressCount); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADD), TRUE); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADDFROMFILE), TRUE); - } else if (FrozenAddressCount == 256) - { - sprintf(temp,"Active Cheats %d (Max Limit)", FrozenAddressCount); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADD), FALSE); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADDFROMFILE), FALSE); - } - else - { - sprintf(temp,"%d Error: Too many cheats loaded!", FrozenAddressCount); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADD), FALSE); - EnableWindow(GetDlgItem(hCheat, IDC_BTN_CHEAT_ADDFROMFILE), FALSE); - } - - SetDlgItemText(hCheat,201,temp); - RedoCheatsLB(hCheat); -} - -BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - char str[100]; - int i; - - switch(uMsg) { - case WM_MOVE: { - if (!IsIconic(hwndDlg)) { - RECT wrect; - GetWindowRect(hwndDlg,&wrect); - GGConv_wndx = wrect.left; - GGConv_wndy = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(GGConv_wndx,GGConv_wndy,wrect.right); - #endif - } - break; - }; - case WM_INITDIALOG: - //todo: set text limits - if (GGConv_wndx==-32000) GGConv_wndx=0; //Just in case - if (GGConv_wndy==-32000) GGConv_wndy=0; - SetWindowPos(hwndDlg,0,GGConv_wndx,GGConv_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - break; - case WM_CREATE: - - break; - case WM_PAINT: - break; - case WM_CLOSE: - case WM_QUIT: - DestroyWindow(hGGConv); - hGGConv = 0; - break; - - case WM_COMMAND: - switch(HIWORD(wParam)) { - case EN_UPDATE: - if(dontupdateGG)break; - dontupdateGG = 1; - switch(LOWORD(wParam)){ //lets find out what edit control got changed - case IDC_GAME_GENIE_CODE: //The Game Genie Code - in this case decode it. - GetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode,9); - if((strlen(GGcode) != 8) && (strlen(GGcode) != 6))break; - - FCEUI_DecodeGG(GGcode, &GGaddr, &GGval, &GGcomp); - - sprintf(str,"%04X",GGaddr); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str); - - if(GGcomp != -1) - sprintf(str,"%02X",GGcomp); - else str[0] = 0; - SetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str); - - sprintf(str,"%02X",GGval); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str); - //ListGGAddresses(); - break; - - case IDC_GAME_GENIE_ADDR: - case IDC_GAME_GENIE_COMP: - case IDC_GAME_GENIE_VAL: - - GetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str,5); - if(strlen(str) != 4) break; - - GetDlgItemText(hGGConv,IDC_GAME_GENIE_VAL,str,5); - if(strlen(str) != 2) {GGval = -1; break;} - - GGaddr = GetEditHex(hGGConv,IDC_GAME_GENIE_ADDR); - GGval = GetEditHex(hGGConv,IDC_GAME_GENIE_VAL); - - GetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str,5); - if(strlen(str) != 2) GGcomp = -1; - else GGcomp = GetEditHex(hGGConv,IDC_GAME_GENIE_COMP); - - EncodeGG(GGcode, GGaddr, GGval, GGcomp); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode); - //ListGGAddresses(); - break; - } - ListGGAddresses(); - dontupdateGG = 0; - break; - case BN_CLICKED: - switch (LOWORD(wParam)) { - case IDC_BTN_ADD_TO_CHEATS: - //ConfigCheats(fceu_hInstance); - - if(GGaddr < 0x8000)GGaddr += 0x8000; - - if (FCEUI_AddCheat(GGcode,GGaddr,GGval,GGcomp,1) && (hCheat != 0)) { - strcpy(str,"* "); - strcat(str,GGcode); - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_ADDSTRING,0,(LPARAM)(LPSTR)str); - selcheat = (SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_GETCOUNT,0,0) - 1); - SendDlgItemMessage(hCheat,IDC_LIST_CHEATS,LB_SETCURSEL,selcheat,0); - - SetDlgItemText(hCheat,IDC_CHEAT_ADDR,(LPTSTR)U16ToStr(GGaddr)); - SetDlgItemText(hCheat,IDC_CHEAT_VAL,(LPTSTR)U8ToStr(GGval)); - if(GGcomp == -1) SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)""); - else SetDlgItemText(hwndDlg,IDC_CHEAT_COM,(LPTSTR)U8ToStr(GGcomp)); - - EnableWindow(GetDlgItem(hCheat,IDC_BTN_CHEAT_DEL),TRUE); - EnableWindow(GetDlgItem(hCheat,IDC_BTN_CHEAT_UPD),TRUE); - } - } - break; - - case LBN_DBLCLK: - switch (LOWORD(wParam)) { - case IDC_LIST_GGADDRESSES: - i = SendDlgItemMessage(hwndDlg,IDC_LIST_GGADDRESSES,LB_GETCURSEL,0,0); - ChangeMemViewFocus(2,GGlist[i],-1); - break; - } - break; - } - break; - case WM_MOUSEMOVE: - break; - case WM_HSCROLL: - break; - } - return FALSE; -} - -//The code in this function is a modified version -//of Chris Covell's work - I'd just like to point that out -void EncodeGG(char *str, int a, int v, int c) -{ - uint8 num[8]; - static char lets[16]={'A','P','Z','L','G','I','T','Y','E','O','X','U','K','S','V','N'}; - int i; - if(a > 0x8000)a-=0x8000; - - num[0]=(v&7)+((v>>4)&8); - num[1]=((v>>4)&7)+((a>>4)&8); - num[2]=((a>>4)&7); - num[3]=(a>>12)+(a&8); - num[4]=(a&7)+((a>>8)&8); - num[5]=((a>>8)&7); - - if (c == -1){ - num[5]+=v&8; - for(i = 0;i < 6;i++)str[i] = lets[num[i]]; - str[6] = 0; - } else { - num[2]+=8; - num[5]+=c&8; - num[6]=(c&7)+((c>>4)&8); - num[7]=((c>>4)&7)+(v&8); - for(i = 0;i < 8;i++)str[i] = lets[num[i]]; - str[8] = 0; - } - return; -} - -void ListGGAddresses() -{ - uint32 i, j = 0; //mbg merge 7/18/06 changed from int - char str[20]; - SendDlgItemMessage(hGGConv,IDC_LIST_GGADDRESSES,LB_RESETCONTENT,0,0); - - //also enable/disable the add GG button here - GetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode,9); - - if((GGaddr < 0) || ((strlen(GGcode) != 8) && (strlen(GGcode) != 6)))EnableWindow(GetDlgItem(hGGConv,IDC_BTN_ADD_TO_CHEATS),FALSE); - else EnableWindow(GetDlgItem(hGGConv,IDC_BTN_ADD_TO_CHEATS),TRUE); - - for(i = 0;i < PRGsize[0];i+=0x2000){ - if((PRGptr[0][i+(GGaddr&0x1FFF)] == GGcomp) || (GGcomp == -1)){ - GGlist[j] = i+(GGaddr&0x1FFF)+0x10; - if(++j > GGLISTSIZE)return; - sprintf(str,"%06X",i+(GGaddr&0x1FFF)+0x10); - SendDlgItemMessage(hGGConv,IDC_LIST_GGADDRESSES,LB_ADDSTRING,0,(LPARAM)(LPSTR)str); - } - } -} - -//A different model for this could be to have everything -//set in the INITDIALOG message based on the internal -//variables, and have this simply call that. -void SetGGConvFocus(int address,int compare) -{ - char str[10]; - if(!hGGConv)DoGGConv(); - GGaddr = address; - GGcomp = compare; - - dontupdateGG = 1; //little hack to fix a nasty bug - - sprintf(str,"%04X",address); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_ADDR,str); - - dontupdateGG = 0; - - sprintf(str,"%02X",GGcomp); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_COMP,str); - - - if(GGval < 0)SetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,""); - else { - EncodeGG(GGcode, GGaddr, GGval, GGcomp); - SetDlgItemText(hGGConv,IDC_GAME_GENIE_CODE,GGcode); - } - - SetFocus(GetDlgItem(hGGConv,IDC_GAME_GENIE_VAL)); - - return; -} - -void DoGGConv() -{ - if (hGGConv) - { - ShowWindow(hGGConv, SW_SHOWNORMAL); - SetForegroundWindow(hGGConv); - } else - { - hGGConv = CreateDialog(fceu_hInstance,"GGCONV",NULL,GGConvCallB); - } - return; -} - -/* -void ListBox::OnRButtonDown(UINT nFlags, CPoint point) -{ -CPoint test = point; -} */ \ No newline at end of file diff --git a/branches/fceux-2.2.2/src/drivers/win/common.h b/branches/fceux-2.2.2/src/drivers/win/common.h deleted file mode 100644 index 191c117f..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/common.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef WIN_COMMON_H -#define WIN_COMMON_H - -#include -#include -#include -#include //bbit edited:this line added //mbg merge 7/17/06 removing conditional compiles - -#ifndef WIN32 -#define WIN32 -#endif -#undef WINNT -#define NONAMELESSUNION - -#define DIRECTSOUND_VERSION 0x0700 -#define DIRECTDRAW_VERSION 0x0700 -#define DIRECTINPUT_VERSION 0x700 - -//#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 removing conditional compiles -#include "../../types.h" -#include "../../file.h" -#include "../../driver.h" -#include "../common/vidblit.h" //mbg merge 7/17/06 added -#include "../common/config.h" -#include "resource.h" //mbg merge 7/18/06 added - -/* Message logging(non-netplay messages, usually) for all. */ -#include "log.h" -extern HWND hAppWnd; -extern HINSTANCE fceu_hInstance; - -extern int NoWaiting; - -extern int eoptions; - -#define EO_BGRUN 1 - -#define EO_CPALETTE 4 -#define EO_NOSPRLIM 8 -#define EO_FSAFTERLOAD 32 -#define EO_FOAFTERSTART 64 -#define EO_NOTHROTTLE 128 -#define EO_CLIPSIDES 256 -#define EO_HIDEMENU 2048 -#define EO_HIGHPRIO 4096 -#define EO_FORCEASPECT 8192 -#define EO_FORCEISCALE 16384 -#define EO_FOURSCORE 32768 -#define EO_BESTFIT 65536 -#define EO_BGCOLOR 131072 -#define EO_HIDEMOUSE 262144 -#define EO_TVASPECT 524288 -#define EO_SQUAREPIXELS 1048576 - -enum WINDOW_ITEM_RESIZE_TYPES -{ - WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, - WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - WINDOW_ITEM_RESIZE_TYPE_CENTER_ALIGNED, - WINDOW_ITEM_RESIZE_TYPE_MULTIPLY, - // --- - WINDOW_ITEM_RESIZE_TYPES_TOTAL -}; - -bool directoryExists(const char* dirname); -void WindowBoundsCheckResize(int &windowPosX, int &windowPosY, int windowSizeX, long windowRight); -void WindowBoundsCheckNoResize(int &windowPosX, int &windowPosY, long windowRight); -int recalculateResizedItemCoordinate(int initialValue, int initialBase, int newBase, unsigned int resizingType); -void AddExtensionIfMissing(char * name,unsigned int maxsize,const char * extension); -void AddExtensionIfMissing(std::string &name,const char * extension); -std::string GetPath(std::string filename); -bool IsRelativePath(char* name); -bool IsRelativePath(const char* name); -bool IsRelativePath(std::string name); -std::string ConvertRelativePath(std::string name); -#endif diff --git a/branches/fceux-2.2.2/src/drivers/win/config.cpp b/branches/fceux-2.2.2/src/drivers/win/config.cpp deleted file mode 100644 index ea23aee4..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/config.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/****************************************************************/ -/* FCE Ultra */ -/* */ -/* This file contains code to interface to the standard */ -/* FCE Ultra configuration file saving/loading code. */ -/* */ -/****************************************************************/ - -#include "config.h" -#include "common.h" -#include "main.h" -#include "window.h" -#include "video.h" -#include "memwatch.h" -#include "fceu.h" -#include "file.h" -#include "texthook.h" -#include "movieoptions.h" -#include "ramwatch.h" -#include "debugger.h" -#include "taseditor/taseditor_config.h" - -#include "../../state.h" //adelikat: For bool backupSavestates - -extern CFGSTRUCT NetplayConfig[]; -extern CFGSTRUCT InputConfig[]; -extern CFGSTRUCT HotkeyConfig[]; -extern int autoHoldKey, autoHoldClearKey; -extern int frameAdvance_Delay; -extern int EnableAutosave, AutosaveQty, AutosaveFrequency; -extern int AFon, AFoff, AutoFireOffset; -extern int DesynchAutoFire; -extern bool lagCounterDisplay; -extern bool frameAdvanceLagSkip; -extern int ClipSidesOffset; -extern bool movieSubtitles; -extern bool subtitlesOnAVI; -extern bool autoMovieBackup; -extern bool bindSavestate; -extern int PPUViewRefresh; -extern int NTViewRefresh; -extern uint8 gNoBGFillColor; -extern bool rightClickEnabled; -extern bool fullscreenByDoubleclick; -extern int CurrentState; -extern bool pauseWhileActive; //adelikat: Cheats dialog -extern bool enableHUDrecording; -extern bool disableMovieMessages; -extern bool replaceP2StartWithMicrophone; -extern bool SingleInstanceOnly; -extern bool Show_FPS; -extern bool oldInputDisplay; -extern bool fullSaveStateLoads; -extern int frameSkipAmt; -extern int32 fps_scale_frameadvance; -extern bool symbDebugEnabled; - -extern TASEDITOR_CONFIG taseditorConfig; -extern char* recentProjectsArray[]; -// Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator -char* taseditorConfigLastAuthorName; -char* ResumeROM; - -//window positions and sizes: -extern int ChtPosX,ChtPosY; -extern int DbgPosX,DbgPosY; -extern int DbgSizeX,DbgSizeY; -extern int MemViewSizeX,MemViewSizeY; -extern int MemView_wndx, MemView_wndy; -extern bool MemView_HighlightActivity; -extern unsigned int MemView_HighlightActivity_FadingPeriod; -extern bool MemView_HighlightActivity_FadeWhenPaused; -extern int MemFind_wndx, MemFind_wndy; -extern int NTViewPosX,NTViewPosY; -extern int PPUViewPosX, PPUViewPosY; -extern bool PPUView_maskUnusedGraphics; -extern bool PPUView_invertTheMask; -extern int MainWindow_wndx, MainWindow_wndy; -extern int MemWatch_wndx, MemWatch_wndy; -extern int Monitor_wndx, Monitor_wndy; -extern int logging_options; -extern int log_lines_option; -extern int Tracer_wndx, Tracer_wndy; -extern int Tracer_wndWidth, Tracer_wndHeight; -extern int CDLogger_wndx, CDLogger_wndy; -extern bool autoresumeCDLogging; -extern bool autosaveCDL; -extern bool autoloadCDL; -extern int GGConv_wndx, GGConv_wndy; -extern int MetaPosX,MetaPosY; -extern int MLogPosX,MLogPosY; - -extern int HexRowHeightBorder; -extern int HexBackColorR; -extern int HexBackColorG; -extern int HexBackColorB; -extern int HexForeColorR; -extern int HexForeColorG; -extern int HexForeColorB; -extern int HexFreezeColorR; -extern int HexFreezeColorG; -extern int HexFreezeColorB; -extern int RomFreezeColorR; -extern int RomFreezeColorG; -extern int RomFreezeColorB; - -//adelikat: Hacky fix for Ram Watch recent menu -char* ramWatchRecent[] = {0, 0, 0, 0, 0}; - -//Structure that contains configuration information -static CFGSTRUCT fceuconfig[] = -{ - ACS(recent_files[0]), - ACS(recent_files[1]), - ACS(recent_files[2]), - ACS(recent_files[3]), - ACS(recent_files[4]), - ACS(recent_files[5]), - ACS(recent_files[6]), - ACS(recent_files[7]), - ACS(recent_files[8]), - ACS(recent_files[9]), - - ACS(memw_recent_files[0]), - ACS(memw_recent_files[1]), - ACS(memw_recent_files[2]), - ACS(memw_recent_files[3]), - ACS(memw_recent_files[4]), - - ACS(recent_lua[0]), - ACS(recent_lua[1]), - ACS(recent_lua[2]), - ACS(recent_lua[3]), - ACS(recent_lua[4]), - - ACS(recent_movie[0]), - ACS(recent_movie[1]), - ACS(recent_movie[2]), - ACS(recent_movie[3]), - ACS(recent_movie[4]), - - ACS(ramWatchRecent[0]), - ACS(ramWatchRecent[1]), - ACS(ramWatchRecent[2]), - ACS(ramWatchRecent[3]), - ACS(ramWatchRecent[4]), - - ACS(recentProjectsArray[0]), - ACS(recentProjectsArray[1]), - ACS(recentProjectsArray[2]), - ACS(recentProjectsArray[3]), - ACS(recentProjectsArray[4]), - ACS(recentProjectsArray[5]), - ACS(recentProjectsArray[6]), - ACS(recentProjectsArray[7]), - ACS(recentProjectsArray[8]), - ACS(recentProjectsArray[9]), - - AC(AutoResumePlay), - ACS(ResumeROM), - - AC(gNoBGFillColor), - AC(ntsccol),AC(ntsctint),AC(ntschue), - AC(force_grayscale), - - NAC("palyo",pal_emulation), - NAC("genie",genie), - NAC("fs",fullscreen), - NAC("vgamode",vmod), - NAC("sound",soundo), - NAC("sicon",status_icon), - - AC(newppu), - - NACS("odroms",directory_names[0]), - NACS("odnonvol",directory_names[1]), - NACS("odstates",directory_names[2]), - NACS("odfdsrom",directory_names[3]), - NACS("odsnaps",directory_names[4]), - NACS("odcheats",directory_names[5]), - NACS("odmovies",directory_names[6]), - NACS("odmemwatch",directory_names[7]), - NACS("odmacro",directory_names[9]), - NACS("odinput",directory_names[10]), - NACS("odlua",directory_names[11]), - NACS("odavi",directory_names[12]), - NACS("odbase",directory_names[13]), - - AC(winspecial), - AC(NTSCwinspecial), - AC(winsizemulx), - AC(winsizemuly), - AC(tvAspectX), - AC(tvAspectY), - - AC(soundrate), - AC(soundbuftime), - AC(soundoptions), - AC(soundquality), - AC(soundvolume), - AC(soundTrianglevol), - AC(soundSquare1vol), - AC(soundSquare2vol), - AC(soundNoisevol), - AC(soundPCMvol), - AC(muteTurbo), - - AC(goptions), - NAC("eoptions",eoptions), - NACA("cpalette",cpalette), - - NACA("InputType",InputType), - - NAC("vmcx",vmodes[0].x), - NAC("vmcy",vmodes[0].y), - NAC("vmcb",vmodes[0].bpp), - NAC("vmcf",vmodes[0].flags), - NAC("vmcxs",vmodes[0].xscale), - NAC("vmcys",vmodes[0].yscale), - NAC("vmspecial",vmodes[0].special), - - NAC("srendline",srendlinen), - NAC("erendline",erendlinen), - NAC("srendlinep",srendlinep), - NAC("erendlinep",erendlinep), - - AC(directDrawModeWindowed), - AC(directDrawModeFullscreen), - AC(winsync), - NAC("988fssync",fssync), - - AC(ismaximized), - AC(maxconbskip), - AC(ffbskip), - - ADDCFGSTRUCT(NetplayConfig), - ADDCFGSTRUCT(InputConfig), - ADDCFGSTRUCT(HotkeyConfig), - - AC(autoHoldKey), - AC(autoHoldClearKey), - AC(frame_display), - AC(rerecord_display), - AC(input_display), - ACS(MemWatchDir), - AC(EnableBackgroundInput), - AC(MemWatchLoadOnStart), - AC(MemWatchLoadFileOnStart), - AC(MemWCollapsed), - AC(BindToMain), - AC(frameAdvance_Delay), - AC(EnableAutosave), - AC(AutosaveQty), - AC(AutosaveFrequency), - AC(frameAdvanceLagSkip), - AC(debuggerAutoload), - AC(allowUDLR), - AC(symbDebugEnabled), - AC(debuggerSaveLoadDEBFiles), - AC(debuggerDisplayROMoffsets), - AC(debuggerFontSize), - AC(hexeditorFontSize), - AC(fullSaveStateLoads), - AC(frameSkipAmt), - AC(fps_scale_frameadvance), - - //window positions - AC(ChtPosX), - AC(ChtPosY), - AC(DbgPosX), - AC(DbgPosY), - AC(DbgSizeX), - AC(DbgSizeY), - AC(MemViewSizeX), - AC(MemViewSizeY), - AC(MemView_wndx), - AC(MemView_wndy), - AC(MemView_HighlightActivity), - AC(MemView_HighlightActivity_FadingPeriod), - AC(MemView_HighlightActivity_FadeWhenPaused), - AC(MemFind_wndx), - AC(MemFind_wndy), - AC(NTViewPosX), - AC(NTViewPosY), - AC(PPUViewPosX), - AC(PPUViewPosY), - AC(PPUView_maskUnusedGraphics), - AC(PPUView_invertTheMask), - AC(MainWindow_wndx), - AC(MainWindow_wndy), - AC(MemWatch_wndx), - AC(MemWatch_wndy), - AC(Monitor_wndx), - AC(Monitor_wndy), - AC(logging_options), - AC(log_lines_option), - AC(Tracer_wndx), - AC(Tracer_wndy), - AC(Tracer_wndWidth), - AC(Tracer_wndHeight), - AC(CDLogger_wndx), - AC(CDLogger_wndy), - AC(autosaveCDL), - AC(autoloadCDL), - AC(autoresumeCDLogging), - AC(GGConv_wndx), - AC(GGConv_wndy), - AC(TextHookerPosX), - AC(TextHookerPosY), - AC(MetaPosX), - AC(MetaPosY), - AC(MLogPosX), - AC(MLogPosY), - - AC(pauseAfterPlayback), - AC(closeFinishedMovie), - AC(suggestReadOnlyReplay), - AC(AFon), - AC(AFoff), - AC(AutoFireOffset), - AC(DesynchAutoFire), - AC(taseditorConfig.windowX), - AC(taseditorConfig.windowY), - AC(taseditorConfig.windowWidth), - AC(taseditorConfig.windowHeight), - AC(taseditorConfig.savedWindowX), - AC(taseditorConfig.savedWindowY), - AC(taseditorConfig.savedWindowWidth), - AC(taseditorConfig.savedWindowHeight), - AC(taseditorConfig.windowIsMaximized), - AC(taseditorConfig.findnoteWindowX), - AC(taseditorConfig.findnoteWindowY), - AC(taseditorConfig.findnoteMatchCase), - AC(taseditorConfig.findnoteSearchUp), - AC(taseditorConfig.followPlaybackCursor), - AC(taseditorConfig.turboSeek), - AC(taseditorConfig.autoRestoreLastPlaybackPosition), - AC(taseditorConfig.superimpose), - AC(taseditorConfig.recordingUsePattern), - AC(taseditorConfig.enableLuaAutoFunction), - AC(taseditorConfig.displayBranchesTree), - AC(taseditorConfig.displayBranchScreenshots), - AC(taseditorConfig.displayBranchDescriptions), - AC(taseditorConfig.enableHotChanges), - AC(taseditorConfig.followUndoContext), - AC(taseditorConfig.followMarkerNoteContext), - AC(taseditorConfig.greenzoneCapacity), - AC(taseditorConfig.maxUndoLevels), - AC(taseditorConfig.enableGreenzoning), - AC(taseditorConfig.autofirePatternSkipsLag), - AC(taseditorConfig.autoAdjustInputAccordingToLag), - AC(taseditorConfig.drawInputByDragging), - AC(taseditorConfig.combineConsecutiveRecordingsAndDraws), - AC(taseditorConfig.use1PKeysForAllSingleRecordings), - AC(taseditorConfig.useInputKeysForColumnSet), - AC(taseditorConfig.bindMarkersToInput), - AC(taseditorConfig.emptyNewMarkerNotes), - AC(taseditorConfig.oldControlSchemeForBranching), - AC(taseditorConfig.branchesRestoreEntireMovie), - AC(taseditorConfig.HUDInBranchScreenshots), - AC(taseditorConfig.autopauseAtTheEndOfMovie), - AC(taseditorConfig.lastExportedInputType), - AC(taseditorConfig.lastExportedSubtitlesStatus), - AC(taseditorConfig.projectSavingOptions_SaveInBinary), - AC(taseditorConfig.projectSavingOptions_SaveMarkers), - AC(taseditorConfig.projectSavingOptions_SaveBookmarks), - AC(taseditorConfig.projectSavingOptions_SaveHistory), - AC(taseditorConfig.projectSavingOptions_SavePianoRoll), - AC(taseditorConfig.projectSavingOptions_SaveSelection), - AC(taseditorConfig.projectSavingOptions_GreenzoneSavingMode), - AC(taseditorConfig.saveCompact_SaveInBinary), - AC(taseditorConfig.saveCompact_SaveMarkers), - AC(taseditorConfig.saveCompact_SaveBookmarks), - AC(taseditorConfig.saveCompact_SaveHistory), - AC(taseditorConfig.saveCompact_SavePianoRoll), - AC(taseditorConfig.saveCompact_SaveSelection), - AC(taseditorConfig.saveCompact_GreenzoneSavingMode), - AC(taseditorConfig.autosaveEnabled), - AC(taseditorConfig.autosavePeriod), - AC(taseditorConfig.autosaveSilent), - AC(taseditorConfig.tooltipsEnabled), - AC(taseditorConfig.currentPattern), - ACS(taseditorConfigLastAuthorName), - AC(lagCounterDisplay), - AC(oldInputDisplay), - AC(movieSubtitles), - AC(subtitlesOnAVI), - AC(bindSavestate), - AC(autoMovieBackup), - AC(ClipSidesOffset), - AC(PPUViewRefresh), - AC(NTViewRefresh), - AC(rightClickEnabled), - AC(fullscreenByDoubleclick), - AC(CurrentState), - AC(HexRowHeightBorder), - AC(HexBackColorR), - AC(HexBackColorG), - AC(HexBackColorB), - AC(HexForeColorR), - AC(HexForeColorG), - AC(HexForeColorB), - AC(HexFreezeColorR), - AC(HexFreezeColorG), - AC(HexFreezeColorB), - AC(RomFreezeColorR), - AC(RomFreezeColorG), - AC(RomFreezeColorB), - //ACS(memwLastfile[2048]), - - AC(AutoRWLoad), - AC(RWSaveWindowPos), - AC(ramw_x), - AC(ramw_y), - - AC(backupSavestates), - AC(compressSavestates), - AC(pauseWhileActive), - AC(enableHUDrecording), - AC(disableMovieMessages), - AC(replaceP2StartWithMicrophone), - AC(SingleInstanceOnly), - AC(Show_FPS), - - ENDCFGSTRUCT -}; - -void SaveConfig(const char *filename) -{ - //adelikat: Hacky fix for Ram Watch recent menu - for (int x = 0; x < 5; x++) - { - ramWatchRecent[x] = rw_recent_files[x]; - } - // Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator - taseditorConfigLastAuthorName = taseditorConfig.lastAuthorName; - ResumeROM = romNameWhenClosingEmulator; - //----------------------------------- - - SaveFCEUConfig(filename,fceuconfig); -} - -void LoadConfig(const char *filename) -{ - FCEUI_GetNTSCTH(&ntsctint, &ntschue); - - LoadFCEUConfig(filename, fceuconfig); - - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - - //adelikat:Hacky fix for Ram Watch recent menu - for (int x = 0; x < 5; x++) - { - if(ramWatchRecent[x]) - { - strncpy(rw_recent_files[x], ramWatchRecent[x], 1024); - free(ramWatchRecent[x]); - ramWatchRecent[x] = 0; - } - else - { - rw_recent_files[x][0] = 0; - } - } - - // Hacky fix for taseditor_config.last_author and rom_name_when_closing_emulator - if (taseditorConfigLastAuthorName) - { - strncpy(taseditorConfig.lastAuthorName, taseditorConfigLastAuthorName, AUTHOR_NAME_MAX_LEN - 1); - taseditorConfig.lastAuthorName[AUTHOR_NAME_MAX_LEN - 1] = 0; - } else - { - taseditorConfig.lastAuthorName[0] = 0; - } - - if (ResumeROM) - strcpy(romNameWhenClosingEmulator, ResumeROM); - else - romNameWhenClosingEmulator[0] = 0; - - //----------------------------------- -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/debugger.cpp b/branches/fceux-2.2.2/src/drivers/win/debugger.cpp deleted file mode 100644 index e7c97822..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/debugger.cpp +++ /dev/null @@ -1,2361 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include "../../utils/xstring.h" -#include "../../types.h" -#include "debugger.h" -#include "../../x6502.h" -#include "../../fceu.h" -#include "../../debug.h" -#include "../../nsf.h" -#include "../../cart.h" -#include "../../ines.h" -#include "../../asm.h" -#include "tracer.h" -#include "memview.h" -#include "cheat.h" -#include "gui.h" -#include "ntview.h" -#include "cdlogger.h" -#include "ppuview.h" - -// ################################## Start of SP CODE ########################### - -#include "debuggersp.h" - -extern Name* lastBankNames; -extern Name* loadedBankNames; -extern Name* ramBankNames; -extern bool ramBankNamesLoaded; -extern int lastBank; -extern int loadedBank; -extern int myNumWPs; - -// ################################## End of SP CODE ########################### - -extern int vblankScanLines; -extern int vblankPixel; -extern bool DebuggerWasUpdated; - -int childwnd; - -extern readfunc ARead[0x10000]; -int DbgPosX,DbgPosY; -int DbgSizeX=-1,DbgSizeY=-1; -int WP_edit=-1; -int ChangeWait=0,ChangeWait2=0; -uint8 debugger_open=0; -HWND hDebug; -static HMENU hDebugcontext; //Handle to context menu -static HMENU hDebugcontextsub; //Handle to context sub menu -WNDPROC IDC_DEBUGGER_DISASSEMBLY_oldWndProc = 0; - -static HFONT hFont; -static SCROLLINFO si; - -bool debuggerAutoload = false; -bool debuggerSaveLoadDEBFiles = true; -bool debuggerDisplayROMoffsets = false; - -char debug_str[35000] = {0}; -char debug_cdl_str[500] = {0}; -char debug_str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; -char* debug_decoration_comment; -char* debug_decoration_comment_end_pos; - -// this is used to keep track of addresses that lines of Disassembly window correspond to -std::vector disassembly_addresses; -// this is used to keep track of addresses in operands of each printed instruction -std::vector> disassembly_operands; -// this is used to autoscroll the Disassembly window while keeping relative position of the ">" pointer inside this window -unsigned int PC_pointerOffset = 0; -// this is used for dirty, but unavoidable hack, which is necessary to ensure the ">" pointer is visible when stepping/seeking to PC -bool PCPointerWasDrawn = false; -// and another hack... -int beginningOfPCPointerLine = -1; // index of the first char within debug_str[] string, where the ">" line starts - -#define INVALID_START_OFFSET 1 -#define INVALID_END_OFFSET 2 - -#define MAX_NAME_SIZE 200 -#define MAX_CONDITION_SIZE 200 - -void UpdateOtherDebuggingDialogs() -{ - //adelikat: This updates all the other dialogs such as ppu, nametable, logger, etc in one function, should be applied to all the step type buttons - NTViewDoBlit(0); //Nametable Viewer - UpdateLogWindow(); //Trace Logger - UpdateCDLogger(); //Code/Data Logger - PPUViewDoBlit(); //PPU Viewer -} - -void RestoreSize(HWND hwndDlg) -{ - //If the dialog dimensions are changed those changes need to be reflected here. - adelikat - const int DEFAULT_WIDTH = 820; //Original width - const int DEFAULT_HEIGHT = 560; //Original height - - SetWindowPos(hwndDlg,HWND_TOP,DbgPosX,DbgPosY,DEFAULT_WIDTH,DEFAULT_HEIGHT,SWP_SHOWWINDOW); -} - -unsigned int NewBreakWindows(HWND hwndDlg, unsigned int num, bool enable) -{ - char startOffsetBuffer[5] = {0}; - char endOffsetBuffer[5] = {0}; - unsigned int type = 0; - - GetDlgItemText(hwndDlg, IDC_ADDBP_ADDR_START, startOffsetBuffer, sizeof(startOffsetBuffer)); - GetDlgItemText(hwndDlg, IDC_ADDBP_ADDR_END, endOffsetBuffer, sizeof(endOffsetBuffer)); - - if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MEM_CPU)) - type |= BT_C; - else if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MEM_PPU)) - type |= BT_P; - else - type |= BT_S; - - if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MODE_R)) - type |= WP_R; - - if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MODE_W)) - type |= WP_W; - - if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MODE_X)) - type |= WP_X; - - //this overrides all - if (IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MODE_F)) - type = WP_F; - - int start = offsetStringToInt(type, startOffsetBuffer); - - if (start == -1) - { - return INVALID_START_OFFSET; - } - - int end = offsetStringToInt(type, endOffsetBuffer); - - if (*endOffsetBuffer && end == -1) - { - return INVALID_END_OFFSET; - } - - // Handle breakpoint conditions - char name[MAX_NAME_SIZE] = {0}; - GetDlgItemText(hwndDlg, IDC_ADDBP_NAME, name, MAX_NAME_SIZE); - - char condition[MAX_CONDITION_SIZE] = {0}; - GetDlgItemText(hwndDlg, IDC_ADDBP_CONDITION, condition, MAX_CONDITION_SIZE); - - return NewBreak(name, start, end, type, condition, num, enable); -} - -/** -* Adds a new breakpoint to the breakpoint list -* -* @param hwndDlg Handle of the debugger window -* @return 0 (success), 1 (Too many breakpoints), 2 (???), 3 (Invalid breakpoint condition) -**/ -unsigned int AddBreak(HWND hwndDlg) -{ - if (numWPs == MAXIMUM_NUMBER_OF_BREAKPOINTS) - { - return TOO_MANY_BREAKPOINTS; - } - - unsigned val = NewBreakWindows(hwndDlg,numWPs,1); - - if (val == 1) - { - return 2; - } - else if (val == 2) - { - return INVALID_BREAKPOINT_CONDITION; - } - - numWPs++; - myNumWPs++; - return 0; -} - -// This function is for "smart" scrolling... -// it attempts to scroll up one line by a whole instruction -int InstructionUp(int from) -{ - int i = std::min(16, from), j; - - while (i > 0) - { - j = i; - while (j > 0) - { - if (GetMem(from - j) == 0x00) - break; // BRK usually signifies data - if (opsize[GetMem(from - j)] == 0) - break; // invalid instruction! - if (opsize[GetMem(from - j)] > j) - break; // instruction is too long! - if (opsize[GetMem(from - j)] == j) - return (from - j); // instruction is just right! :D - j -= opsize[GetMem(from - j)]; - } - i--; - } - - // if we get here, no suitable instruction was found - if ((from >= 2) && (GetMem(from - 2) == 0x00)) - return (from - 2); // if a BRK instruction is possible, use that - if (from) - return (from - 1); // else, scroll up one byte - return 0; // of course, if we can't scroll up, just return 0! -} -int InstructionDown(int from) -{ - int tmp = opsize[GetMem(si.nPos)]; - if ((tmp)) - return from + tmp; - else - return from + 1; // this is data or undefined instruction -} - -static void UpdateDialog(HWND hwndDlg) { - BOOL forbid = IsDlgButtonChecked(hwndDlg, IDC_ADDBP_MODE_F); - BOOL enable = !forbid; - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_R),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_W),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_X),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MEM_CPU),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MEM_PPU),enable); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MEM_SPR),enable); - //nah.. lets leave these checked - //CheckDlgButton(hwndDlg,IDC_ADDBP_MODE_R,BST_UNCHECKED); - //CheckDlgButton(hwndDlg,IDC_ADDBP_MODE_W,BST_UNCHECKED); - //CheckDlgButton(hwndDlg,IDC_ADDBP_MODE_X,BST_UNCHECKED); - //CheckDlgButton(hwndDlg,IDC_ADDBP_MEM_CPU,BST_UNCHECKED); - //CheckDlgButton(hwndDlg,IDC_ADDBP_MEM_PPU,BST_UNCHECKED); - //CheckDlgButton(hwndDlg,IDC_ADDBP_MEM_SPR,BST_UNCHECKED); -} - -BOOL CALLBACK AddbpCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - char str[8] = {0}; - int tmp; - - switch(uMsg) - { - case WM_INITDIALOG: - CenterWindow(hwndDlg); - SendDlgItemMessage(hwndDlg,IDC_ADDBP_ADDR_START,EM_SETLIMITTEXT,4,0); - SendDlgItemMessage(hwndDlg,IDC_ADDBP_ADDR_END,EM_SETLIMITTEXT,4,0); - if (WP_edit >= 0) - { - SetWindowText(hwndDlg,"Edit Breakpoint..."); - - sprintf(str,"%04X",watchpoint[WP_edit].address); - SetDlgItemText(hwndDlg,IDC_ADDBP_ADDR_START,str); - sprintf(str,"%04X",watchpoint[WP_edit].endaddress); - if (strcmp(str,"0000") != 0) SetDlgItemText(hwndDlg,IDC_ADDBP_ADDR_END,str); - if (watchpoint[WP_edit].flags&WP_R) CheckDlgButton(hwndDlg, IDC_ADDBP_MODE_R, BST_CHECKED); - if (watchpoint[WP_edit].flags&WP_W) CheckDlgButton(hwndDlg, IDC_ADDBP_MODE_W, BST_CHECKED); - if (watchpoint[WP_edit].flags&WP_X) CheckDlgButton(hwndDlg, IDC_ADDBP_MODE_X, BST_CHECKED); - if (watchpoint[WP_edit].flags&WP_F) CheckDlgButton(hwndDlg, IDC_ADDBP_MODE_F, BST_CHECKED); - - if (watchpoint[WP_edit].flags&BT_P) { - CheckDlgButton(hwndDlg, IDC_ADDBP_MEM_PPU, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_X),FALSE); - } - else if (watchpoint[WP_edit].flags&BT_S) { - CheckDlgButton(hwndDlg, IDC_ADDBP_MEM_SPR, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_X),FALSE); - } - else CheckDlgButton(hwndDlg, IDC_ADDBP_MEM_CPU, BST_CHECKED); - - UpdateDialog(hwndDlg); - -// ################################## Start of SP CODE ########################### - - SendDlgItemMessage(hwndDlg,IDC_ADDBP_CONDITION,EM_SETLIMITTEXT,200,0); - SendDlgItemMessage(hwndDlg,IDC_ADDBP_NAME,EM_SETLIMITTEXT,200,0); - - if (watchpoint[WP_edit].cond) - { - SetDlgItemText(hwndDlg, IDC_ADDBP_CONDITION, watchpoint[WP_edit].condText); - } - else - { - SetDlgItemText(hwndDlg, IDC_ADDBP_CONDITION, ""); - } - - if (watchpoint[WP_edit].desc) - { - SetDlgItemText(hwndDlg, IDC_ADDBP_NAME, watchpoint[WP_edit].desc); - } - else - { - SetDlgItemText(hwndDlg, IDC_ADDBP_NAME, ""); - } - -// ################################## End of SP CODE ########################### - } else - { - CheckDlgButton(hwndDlg, IDC_ADDBP_MEM_CPU, BST_CHECKED); - // if lParam is not 0 then we should suggest to add PC breakpoint - if (lParam) - { - CheckDlgButton(hwndDlg, IDC_ADDBP_MODE_X, BST_CHECKED); - sprintf(str, "%04X", lParam); - SetDlgItemText(hwndDlg,IDC_ADDBP_ADDR_START,str); - // also set the condition to only break at this Bank - sprintf(str, "K==#%02X", getBank(lParam)); - SetDlgItemText(hwndDlg, IDC_ADDBP_CONDITION, str); - } - } - break; - case WM_CLOSE: - case WM_QUIT: - break; - case WM_COMMAND: - switch(HIWORD(wParam)) { - case BN_CLICKED: - switch(LOWORD(wParam)) { - case IDC_ADDBP_MODE_F: { - UpdateDialog(hwndDlg); - break; - } - - case IDOK: - if (WP_edit >= 0) { - int tmp = NewBreakWindows(hwndDlg,WP_edit,(BOOL)(watchpoint[WP_edit].flags&WP_E)); - if (tmp == 2 || tmp == INVALID_BREAKPOINT_CONDITION) - { - MessageBox(hwndDlg, "Invalid breakpoint condition", "Error", MB_OK); - break; - } - EndDialog(hwndDlg,1); - break; - } - if ((tmp=AddBreak(hwndDlg)) == TOO_MANY_BREAKPOINTS) { - MessageBox(hwndDlg, "Too many breakpoints, please delete one and try again", "Breakpoint Error", MB_OK); - goto endaddbrk; - } - if (tmp == 2) goto endaddbrk; - else if (tmp == INVALID_BREAKPOINT_CONDITION) - { - MessageBox(hwndDlg, "Invalid breakpoint condition", "Error", MB_OK); - break; - } - EndDialog(hwndDlg,1); - break; - case IDCANCEL: - endaddbrk: - EndDialog(hwndDlg,0); - break; - case IDC_ADDBP_MEM_CPU: - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_X),TRUE); - break; - case IDC_ADDBP_MEM_PPU: - case IDC_ADDBP_MEM_SPR: - EnableWindow(GetDlgItem(hwndDlg,IDC_ADDBP_MODE_X),FALSE); - break; - } - break; - } - break; - } - return FALSE; //TRUE; -} - -void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) -{ - char chr[40] = {0}; - int size; - uint8 opcode[3]; - unsigned int instruction_addr; - - disassembly_addresses.resize(0); - PCPointerWasDrawn = false; - beginningOfPCPointerLine = -1; - - if (symbDebugEnabled) - { - loadNameFiles(); - disassembly_operands.resize(0); - } - - si.nPos = addr; - SetScrollInfo(GetDlgItem(hWnd,scrollid),SB_CTL,&si,TRUE); - - //figure out how many lines we can draw - RECT rect; - GetClientRect(GetDlgItem(hWnd, id), &rect); - int lines = (rect.bottom-rect.top) / debugSystem->fixedFontHeight; - - debug_str[0] = 0; - unsigned int instructions_count = 0; - for (int i = 0; i < lines; i++) - { - // PC pointer - if (addr > 0xFFFF) break; - - instruction_addr = addr; - - if (symbDebugEnabled) - { - // insert Name and Comment lines if needed - Name* node = findNode(getNamesPointerForAddress(addr), addr); - if (node) - { - if (node->name) - { - strcat(debug_str, node->name); - strcat(debug_str, ":\r\n"); - // we added one line to the disassembly window - disassembly_addresses.push_back(addr); - disassembly_operands.resize(i + 1); - i++; - } - if (node->comment) - { - // make a copy - strcpy(debug_str_decoration_comment, node->comment); - strcat(debug_str_decoration_comment, "\r\n"); - // divide the debug_str_decoration_comment into strings (Comment1, Comment2, ...) - debug_decoration_comment = debug_str_decoration_comment; - debug_decoration_comment_end_pos = strstr(debug_decoration_comment, "\r\n"); - while (debug_decoration_comment_end_pos) - { - debug_decoration_comment_end_pos[0] = 0; // set \0 instead of \r - strcat(debug_str, "; "); - strcat(debug_str, debug_decoration_comment); - strcat(debug_str, "\r\n"); - // we added one line to the disassembly window - disassembly_addresses.push_back(addr); - disassembly_operands.resize(i + 1); - i++; - - debug_decoration_comment_end_pos += 2; - debug_decoration_comment = debug_decoration_comment_end_pos; - debug_decoration_comment_end_pos = strstr(debug_decoration_comment_end_pos, "\r\n"); - } - } - } - } - - if (addr == X.PC) - { - PC_pointerOffset = instructions_count; - PCPointerWasDrawn = true; - beginningOfPCPointerLine = strlen(debug_str); - strcat(debug_str, ">"); - } else - { - strcat(debug_str, " "); - } - - if (addr >= 0x8000) - { - if (debuggerDisplayROMoffsets && GetNesFileAddress(addr) != -1) - { - sprintf(chr, " %06X:", GetNesFileAddress(addr)); - } else - { - sprintf(chr, "%02X:%04X:", getBank(addr), addr); - } - } else - { - sprintf(chr, " :%04X:", addr); - } - - // Add address - strcat(debug_str, chr); - disassembly_addresses.push_back(addr); - if (symbDebugEnabled) - disassembly_operands.resize(i + 1); - - size = opsize[GetMem(addr)]; - if (size == 0) - { - sprintf(chr, "%02X UNDEFINED", GetMem(addr++)); - strcat(debug_str, chr); - } else - { - char* a; - if ((addr + size) > 0xFFFF) - { - while (addr < 0xFFFF) - { - sprintf(chr, "%02X OVERFLOW\r\n", GetMem(addr++)); - strcat(debug_str, chr); - } - break; - } - for (int j = 0; j < size; j++) - { - sprintf(chr, "%02X ", opcode[j] = GetMem(addr++)); - strcat(debug_str, chr); - } - while (size < 3) - { - strcat(debug_str, " "); //pad output to align ASM - size++; - } - - a = Disassemble(addr, opcode); - - if (symbDebugEnabled) - { - replaceNames(ramBankNames, a, &disassembly_operands[i]); - replaceNames(loadedBankNames, a, &disassembly_operands[i]); - replaceNames(lastBankNames, a, &disassembly_operands[i]); - } - - // special case: an RTS opcode - if (GetMem(instruction_addr) == 0x60) - { - // add "----------" to emphasize the end of subroutine - strcat(a, " "); - for (int j = strlen(a); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j) - a[j] = '-'; - a[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; - } - - // append the disassembly to current line - strcat(strcat(debug_str, " "), a); - } - strcat(debug_str, "\r\n"); - instructions_count++; - } - SetDlgItemText(hWnd, id, debug_str); - - // fill the left panel data - debug_cdl_str[0] = 0; - if (cdloggerdataSize) - { - uint8 cdl_data; - lines = disassembly_addresses.size(); - for (int i = 0; i < lines; ++i) - { - instruction_addr = GetNesFileAddress(disassembly_addresses[i]) - 16; - if (instruction_addr >= 0 && instruction_addr < cdloggerdataSize) - { - cdl_data = cdloggerdata[instruction_addr] & 3; - if (cdl_data == 3) - strcat(debug_cdl_str, "cd\r\n"); // both Code and Data - else if (cdl_data == 2) - strcat(debug_cdl_str, " d\r\n"); // Data - else if (cdl_data == 1) - strcat(debug_cdl_str, "c\r\n"); // Code - else - strcat(debug_cdl_str, "\r\n"); // not logged - } else - { - strcat(debug_cdl_str, "\r\n"); // cannot be logged - } - } - } - SetDlgItemText(hWnd, IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL, debug_cdl_str); -} -void PrintOffsetToSeekAndBookmarkFields(int offset) -{ - if (offset >= 0 && hDebug) - { - char offsetBuffer[5]; - sprintf(offsetBuffer, "%04X", offset); - // send the address to "Seek To" field - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PCSEEK, offsetBuffer); - // send the address to "Bookmark Add" field - SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, offsetBuffer); - } -} - -char *DisassembleLine(int addr) { - static char str[64]={0},chr[25]={0}; - char *c; - int size,j; - uint8 opcode[3]; - - sprintf(str, "%02X:%04X:", getBank(addr),addr); - size = opsize[GetMem(addr)]; - if (size == 0) - { - sprintf(chr, "%02X UNDEFINED", GetMem(addr++)); - strcat(str,chr); - } - else { - if ((addr+size) > 0x10000) { - sprintf(chr, "%02X OVERFLOW", GetMem(addr)); - strcat(str,chr); - } - else { - for (j = 0; j < size; j++) { - sprintf(chr, "%02X ", opcode[j] = GetMem(addr++)); - strcat(str,chr); - } - while (size < 3) { - strcat(str," "); //pad output to align ASM - size++; - } - strcat(strcat(str," "),Disassemble(addr,opcode)); - } - } - if ((c=strchr(str,'='))) *(c-1) = 0; - if ((c=strchr(str,'@'))) *(c-1) = 0; - return str; -} - -char *DisassembleData(int addr, uint8 *opcode) { - static char str[64]={0},chr[25]={0}; - char *c; - int size,j; - - sprintf(str, "%02X:%04X:", getBank(addr), addr); - size = opsize[opcode[0]]; - if (size == 0) - { - sprintf(chr, "%02X UNDEFINED", opcode[0]); - strcat(str,chr); - } else - { - if ((addr+size) > 0x10000) - { - sprintf(chr, "%02X OVERFLOW", opcode[0]); - strcat(str,chr); - } else - { - for (j = 0; j < size; j++) - { - sprintf(chr, "%02X ", opcode[j]); - addr++; - strcat(str,chr); - } - while (size < 3) - { - strcat(str," "); //pad output to align ASM - size++; - } - strcat(strcat(str," "),Disassemble(addr,opcode)); - } - } - if ((c=strchr(str,'='))) *(c-1) = 0; - if ((c=strchr(str,'@'))) *(c-1) = 0; - return str; -} - - -int GetEditHex(HWND hwndDlg, int id) { - char str[9]; - int tmp; - GetDlgItemText(hwndDlg,id,str,9); - tmp = strtol(str,NULL,16); - return tmp; -} - -int *GetEditHexData(HWND hwndDlg, int id){ - static int data[31]; - char str[60]; - int i,j, k; - - GetDlgItemText(hwndDlg,id,str,60); - memset(data,0,31*sizeof(int)); - j=0; - for(i = 0;i < 60;i++){ - if(str[i] == 0)break; - if((str[i] >= '0') && (str[i] <= '9'))j++; - if((str[i] >= 'A') && (str[i] <= 'F'))j++; - if((str[i] >= 'a') && (str[i] <= 'f'))j++; - } - - j=j&1; - for(i = 0;i < 60;i++){ - if(str[i] == 0)break; - k = -1; - if((str[i] >= '0') && (str[i] <= '9'))k=str[i]-'0'; - if((str[i] >= 'A') && (str[i] <= 'F'))k=(str[i]-'A')+10; - if((str[i] >= 'a') && (str[i] <= 'f'))k=(str[i]-'a')+10; - if(k != -1){ - if(j&1)data[j>>1] |= k; - else data[j>>1] |= k<<4; - j++; - } - } - data[j>>1]=-1; - return data; -} - -void UpdateRegs(HWND hwndDlg) { - if (DebuggerWasUpdated) { - X.A = GetEditHex(hwndDlg,IDC_DEBUGGER_VAL_A); - X.X = GetEditHex(hwndDlg,IDC_DEBUGGER_VAL_X); - X.Y = GetEditHex(hwndDlg,IDC_DEBUGGER_VAL_Y); - X.PC = GetEditHex(hwndDlg,IDC_DEBUGGER_VAL_PC); - } -} - -///indicates whether we're under the control of the debugger -bool inDebugger = false; - -//this code enters the debugger when a breakpoint was hit -void FCEUD_DebugBreakpoint(int bp_num) -{ - // log the Breakpoint Hit into Trace Logger log if needed - if (logging) - { - log_old_emu_paused = false; // force Trace Logger update - if (logging_options & LOG_MESSAGES) - { - char str_temp[500]; - if (bp_num >= 0) - { - // normal breakpoint - sprintf(str_temp, "Breakpoint %u Hit at $%04X: ", bp_num, X.PC); - strcat(str_temp, BreakToText(bp_num)); - //watchpoint[num].condText - OutputLogLine(str_temp); - } else if (bp_num == BREAK_TYPE_BADOP) - { - sprintf(str_temp, "Bad Opcode Breakpoint Hit at $%04X", X.PC); - OutputLogLine(str_temp); - } else if (bp_num == BREAK_TYPE_CYCLES_EXCEED) - { - sprintf(str_temp, "Breakpoint Hit at $%04X: cycles count %lu exceeds %lu", X.PC, (long)(timestampbase + timestamp - total_cycles_base), (long)break_cycles_limit); - OutputLogLine(str_temp); - } else if (bp_num == BREAK_TYPE_INSTRUCTIONS_EXCEED) - { - sprintf(str_temp, "Breakpoint Hit at $%04X: instructions count %lu exceeds %lu", X.PC, (long)total_instructions, (long)break_instructions_limit); - OutputLogLine(str_temp); - } - } - } - - DoDebug(0); - UpdateOtherDebuggingDialogs(); // Keeps the debugging windows updating smoothly when stepping - - // highlight the ">" line - if (bp_num != BREAK_TYPE_STEP) - if (beginningOfPCPointerLine >= 0) - SendMessage(GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY), EM_SETSEL, beginningOfPCPointerLine + 1, beginningOfPCPointerLine + 8); - - // highlight breakpoint - if (bp_num >= 0) - { - // highlight bp_num item in IDC_DEBUGGER_BP_LIST - SendDlgItemMessage(hDebug, IDC_DEBUGGER_BP_LIST, LB_SETCURSEL, (WPARAM)bp_num, 0); - EnableWindow(GetDlgItem(hDebug, IDC_DEBUGGER_BP_DEL), TRUE); - EnableWindow(GetDlgItem(hDebug, IDC_DEBUGGER_BP_EDIT), TRUE); - } else - { - // remove any selection from IDC_DEBUGGER_BP_LIST - SendDlgItemMessage(hDebug, IDC_DEBUGGER_BP_LIST, LB_SETCURSEL, (WPARAM)(-1), 0); - EnableWindow(GetDlgItem(hDebug, IDC_DEBUGGER_BP_DEL), FALSE); - EnableWindow(GetDlgItem(hDebug, IDC_DEBUGGER_BP_EDIT), FALSE); - // highlight IDC_DEBUGGER_VAL_CYCLES_COUNT or IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT if needed - if (bp_num == BREAK_TYPE_CYCLES_EXCEED) - SendMessage(GetDlgItem(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT), EM_SETSEL, 0, -1); - else if (bp_num == BREAK_TYPE_INSTRUCTIONS_EXCEED) - SendMessage(GetDlgItem(hDebug, IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT), EM_SETSEL, 0, -1); - } - - void win_debuggerLoop(); // HACK to let user interact with the Debugger while emulator isn't updating - win_debuggerLoop(); - - // since we unfreezed emulation, reset delta_cycles counter - ResetDebugStatisticsDeltaCounters(); -} - -void UpdateBreakpointsCaption() -{ - char str[32]; - // calculate the number of enabled breakpoints - int tmp = 0; - for (int i = 0; i < numWPs; i++) - if (watchpoint[i].flags & WP_E) - tmp++; - sprintf(str, "Breakpoints %02X of %02X", tmp, numWPs); - SetDlgItemText(hDebug, IDC_DEBUGGER_BREAKPOINTS, str); -} - -void UpdateDebugger(bool jump_to_pc) -{ - //don't do anything if the debugger is not visible - if(!hDebug) - return; - - //but if the debugger IS visible, then focus it - ShowWindow(hDebug, SW_SHOWNORMAL); - SetForegroundWindow(hDebug); - - char str[512] = {0}, str2[512] = {0}, chr[8]; - int tmp, ret, i, starting_address; - - if (jump_to_pc || disassembly_addresses.size() == 0) - { - starting_address = X.PC; - - // ensure that PC pointer will be visible even after the window was resized - RECT rect; - GetClientRect(GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY), &rect); - unsigned int lines = (rect.bottom-rect.top) / debugSystem->fixedFontHeight; - if (PC_pointerOffset >= lines) - PC_pointerOffset = 0; - - // keep the relative position of the ">" pointer inside the Disassembly window - for (int i = PC_pointerOffset; i > 0; i--) - { - starting_address = InstructionUp(starting_address); - } - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, starting_address); - - // HACK, but I don't see any other way to ensure the ">" pointer is visible when "Symbolic debug" is enabled - if (!PCPointerWasDrawn && PC_pointerOffset) - { - // we've got a problem, probably due to Symbolic info taking so much space that PC pointer couldn't be seen with (PC_pointerOffset > 0) - PC_pointerOffset = 0; - starting_address = X.PC; - // retry with (PC_pointerOffset = 0) now - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, starting_address); - } - - starting_address = X.PC; - } else - { - starting_address = disassembly_addresses[0]; - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, starting_address); - } - - - // "Address Bookmark Add" follows the address - //sprintf(str, "%04X", starting_address); - //SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str); - - sprintf(str, "%02X", X.A); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_A, str); - sprintf(str, "%02X", X.X); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_X, str); - sprintf(str, "%02X", X.Y); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_Y, str); - sprintf(str, "%04X", (int)X.PC); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PC, str); - - sprintf(str, "%04X", (int)RefreshAddr); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PPU, str); - sprintf(str, "%02X", PPU[3]); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_SPR, str); - - extern int linestartts; - #define GETLASTPIXEL (PAL?((timestamp*48-linestartts)/15) : ((timestamp*48-linestartts)/16) ) - - int ppupixel = GETLASTPIXEL; - - if (ppupixel>341) //maximum number of pixels per scanline - ppupixel = 0; //Currently pixel display is borked until Run 128 lines is clicked, this keeps garbage from displaying - - // If not in the 0-239 pixel range, make special cases for display - if (scanline == 240 && vblankScanLines < (PAL?72:22)) - { - if (!vblankScanLines) - { - // Idle scanline (240) - sprintf(str, "%d", scanline); // was "Idle %d" - } else if (scanline + vblankScanLines == (PAL?311:261)) - { - // Pre-render - sprintf(str, "-1"); // was "Prerender -1" - } else - { - // Vblank lines (241-260/310) - sprintf(str, "%d", scanline + vblankScanLines); // was "Vblank %d" - } - sprintf(str2, "%d", vblankPixel); - } else - { - // Scanlines 0 - 239 - sprintf(str, "%d", scanline); - sprintf(str2, "%d", ppupixel); - } - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_SLINE, str); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PPUPIXEL, str2); - - // update counters - int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base; - if (counter_value < 0) // sanity check - { - ResetDebugStatisticsCounters(); - counter_value = 0; - } - sprintf(str, "%llu", counter_value); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT, str); - counter_value = timestampbase + (uint64)timestamp - delta_cycles_base; - if (counter_value < 0) // sanity check - { - ResetDebugStatisticsCounters(); - counter_value = 0; - } - sprintf(str, "(+%llu)", counter_value); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT2, str); - sprintf(str, "%llu", total_instructions); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT, str); - sprintf(str, "(+%llu)", delta_instructions); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2, str); - - UpdateBreakpointsCaption(); - - tmp = X.S|0x0100; - sprintf(str, "Stack $%04X", tmp); - SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_S, str); - str[0] = 0; - tmp++; - if (tmp <= 0x1FF) - { - sprintf(str, "%02X", GetMem(tmp)); - for (i = 1; i < 128; i++) - { - //tmp = ((tmp+1)|0x0100)&0x01FF; //increment and fix pointer to $0100-$01FF range - tmp++; - if (tmp > 0x1FF) - break; - if ((i & 3) == 0) - sprintf(chr, ",\r\n%02X", GetMem(tmp)); - else - sprintf(chr, ",%02X", GetMem(tmp)); - strcat(str, chr); - } - } - SetDlgItemText(hDebug, IDC_DEBUGGER_STACK_CONTENTS, str); - - GetDlgItemText(hDebug,IDC_DEBUGGER_VAL_PCSEEK,str,5); - if (((ret = sscanf(str,"%4X",&tmp)) == EOF) || (ret != 1)) tmp = 0; - sprintf(str,"%04X",tmp); - SetDlgItemText(hDebug,IDC_DEBUGGER_VAL_PCSEEK,str); - - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_N, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_V, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_U, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_B, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_D, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_I, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_Z, BST_UNCHECKED); - CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_C, BST_UNCHECKED); - - tmp = X.P; - if (tmp & N_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_N, BST_CHECKED); - if (tmp & V_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_V, BST_CHECKED); - if (tmp & U_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_U, BST_CHECKED); - if (tmp & B_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_B, BST_CHECKED); - if (tmp & D_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_D, BST_CHECKED); - if (tmp & I_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_I, BST_CHECKED); - if (tmp & Z_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_Z, BST_CHECKED); - if (tmp & C_FLAG) CheckDlgButton(hDebug, IDC_DEBUGGER_FLAG_C, BST_CHECKED); - - DebuggerWasUpdated = true; -} - -char* BreakToText(unsigned int num) -{ - static char str[300], chr[8]; - - sprintf(str, "$%04X", watchpoint[num].address); - if (watchpoint[num].endaddress) { - sprintf(chr, "-%04X", watchpoint[num].endaddress); - strcat(str,chr); - } - if (watchpoint[num].flags&WP_E) strcat(str,":E"); else strcat(str,":-"); - if (watchpoint[num].flags&BT_P) strcat(str,"P"); else if (watchpoint[num].flags&BT_S) strcat(str,"S"); else strcat(str,"C"); - if (watchpoint[num].flags&WP_R) strcat(str,"R"); else strcat(str,"-"); - if (watchpoint[num].flags&WP_W) strcat(str,"W"); else strcat(str,"-"); - if (watchpoint[num].flags&WP_X) strcat(str,"X"); else strcat(str,"-"); - if (watchpoint[num].flags&WP_F) strcat(str,"F"); else strcat(str,"-"); - -// ################################## Start of SP CODE ########################### - - if (watchpoint[num].desc && strlen(watchpoint[num].desc)) - { - strcat(str, " "); - strcat(str, watchpoint[num].desc); - strcat(str, " "); - } - - if (watchpoint[num].condText && strlen(watchpoint[num].condText)) - { - strcat(str, " Condition:"); - strcat(str, watchpoint[num].condText); - } -// ################################## End of SP CODE ########################### - - return str; -} - -void AddBreakList() { - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,-1,(LPARAM)(LPSTR)BreakToText(numWPs-1)); -} - -void EditBreakList() { - if(WP_edit < 0) return; - if(WP_edit >= numWPs) return; - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,WP_edit,0); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,WP_edit,(LPARAM)(LPSTR)BreakToText(WP_edit)); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_SETCURSEL,WP_edit,0); -} - -void FillBreakList(HWND hwndDlg) -{ - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_RESETCONTENT,0,0); - for (int i = 0; i < numWPs; i++) - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,-1,(LPARAM)(LPSTR)BreakToText(i)); -} - -void EnableBreak(int sel) -{ - if(sel<0) return; - if(sel>=numWPs) return; - watchpoint[sel].flags^=WP_E; - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,sel,0); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,sel,(LPARAM)(LPSTR)BreakToText(sel)); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_SETCURSEL,sel,0); - UpdateBreakpointsCaption(); -} - -void DeleteBreak(int sel) -{ - if(sel<0) return; - if(sel>=numWPs) return; - if (watchpoint[sel].cond) - freeTree(watchpoint[sel].cond); - if (watchpoint[sel].condText) - free(watchpoint[sel].condText); - if (watchpoint[sel].desc) - free(watchpoint[sel].desc); - // move all BP items up in the list - for (int i = sel; i < numWPs; i++) { - watchpoint[i].address = watchpoint[i+1].address; - watchpoint[i].endaddress = watchpoint[i+1].endaddress; - watchpoint[i].flags = watchpoint[i+1].flags; -// ################################## Start of SP CODE ########################### - watchpoint[i].cond = watchpoint[i+1].cond; - watchpoint[i].condText = watchpoint[i+1].condText; - watchpoint[i].desc = watchpoint[i+1].desc; -// ################################## End of SP CODE ########################### - } - // erase last BP item - watchpoint[numWPs].address = 0; - watchpoint[numWPs].endaddress = 0; - watchpoint[numWPs].flags = 0; - watchpoint[numWPs].cond = 0; - watchpoint[numWPs].condText = 0; - watchpoint[numWPs].desc = 0; - numWPs--; -// ################################## Start of SP CODE ########################### - myNumWPs--; -// ################################## End of SP CODE ########################### - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,sel,0); - // select next item in the list - if (numWPs) - { - if (sel >= (numWPs - 1)) - // select last item - SendDlgItemMessage(hDebug, IDC_DEBUGGER_BP_LIST, LB_SETCURSEL, numWPs - 1, 0); - else - SendDlgItemMessage(hDebug, IDC_DEBUGGER_BP_LIST, LB_SETCURSEL, sel, 0); - } else - { - EnableWindow(GetDlgItem(hDebug,IDC_DEBUGGER_BP_DEL),FALSE); - EnableWindow(GetDlgItem(hDebug,IDC_DEBUGGER_BP_EDIT),FALSE); - } - UpdateBreakpointsCaption(); -} - -void KillDebugger() { - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_RESETCONTENT,0,0); - FCEUI_Debugger().reset(); - FCEUI_SetEmulationPaused(0); //mbg merge 7/18/06 changed from userpause -} - - -int AddAsmHistory(HWND hwndDlg, int id, char *str) { - int index; - index = SendDlgItemMessage(hwndDlg,id,CB_FINDSTRINGEXACT,-1,(LPARAM)(LPSTR)str); - if (index == CB_ERR) { - SendDlgItemMessage(hwndDlg,id,CB_INSERTSTRING,-1,(LPARAM)(LPSTR)str); - return 0; - } - return 1; -} - -BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - int romaddr,count,i,j; - char str[128],*dasm; - static int patchlen,applied,saved,lastundo; - static uint8 patchdata[64][3],undodata[64*3]; - uint8 *ptr; - - switch(uMsg) { - case WM_INITDIALOG: - CenterWindow(hwndDlg); - - //set font - SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - - //set limits - SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_HISTORY,CB_LIMITTEXT,20,0); - - SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(iaPC)); - SetFocus(GetDlgItem(hwndDlg,IDC_ASSEMBLER_HISTORY)); - - patchlen = 0; - applied = 0; - saved = 0; - lastundo = 0; - break; - case WM_CLOSE: - case WM_QUIT: - EndDialog(hwndDlg,0); - break; - case WM_COMMAND: - { - switch (HIWORD(wParam)) - { - case BN_CLICKED: - { - switch (LOWORD(wParam)) - { - case IDC_ASSEMBLER_APPLY: - if (patchlen) { - ptr = GetNesPRGPointer(GetNesFileAddress(iaPC)-16); - count = 0; - for (i = 0; i < patchlen; i++) { - for (j = 0; j < opsize[patchdata[i][0]]; j++) { - if (count == lastundo) undodata[lastundo++] = ptr[count]; - ptr[count++] = patchdata[i][j]; - } - } - SetWindowText(hwndDlg, "Inline Assembler *Patches Applied*"); - //MessageBeep(MB_OK); - applied = 1; - } - break; - case IDC_ASSEMBLER_SAVE: - if (applied) { - count = romaddr = GetNesFileAddress(iaPC); - for (i = 0; i < patchlen; i++) - { - count += opsize[patchdata[i][0]]; - } - if (patchlen) sprintf(str,"Write patch data to file at addresses 0x%06X - 0x%06X?",romaddr,count-1); - else sprintf(str,"Undo all previously applied patches?"); - if (MessageBox(hwndDlg, str, "Save changes to file?", MB_YESNO|MB_ICONINFORMATION) == IDYES) { - if (iNesSave()) { - saved = 1; - applied = 0; - } - else MessageBox(hwndDlg, "Unable to save changes to file", "Error saving to file", MB_OK); - } - } - break; - case IDC_ASSEMBLER_UNDO: - if ((count = SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_GETCOUNT,0,0))) { - SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_DELETESTRING,count-1,0); - patchlen--; - count = 0; - for (i = 0; i < patchlen; i++) - { - count += opsize[patchdata[i][0]]; - } - if (count < lastundo) { - ptr = GetNesPRGPointer(GetNesFileAddress(iaPC)-16); - j = opsize[patchdata[patchlen][0]]; - for (i = count; i < (count+j); i++) { - ptr[i] = undodata[i]; - } - lastundo -= j; - applied = 1; - } - SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(iaPC+count)); - } - break; - case IDC_ASSEMBLER_DEFPUSHBUTTON: - count = 0; - for (i = 0; i < patchlen; i++) - { - count += opsize[patchdata[i][0]]; - } - GetDlgItemText(hwndDlg,IDC_ASSEMBLER_HISTORY,str,21); - if (!Assemble(patchdata[patchlen],(iaPC+count),str)) { - count = iaPC; - for (i = 0; i <= patchlen; i++) - { - count += opsize[patchdata[i][0]]; - } - if (count > 0x10000) { //note: don't use 0xFFFF! - MessageBox(hwndDlg, "Patch data cannot exceed address 0xFFFF", "Address error", MB_OK); - break; - } - SetDlgItemText(hwndDlg,IDC_ASSEMBLER_HISTORY,""); - if (count < 0x10000) SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(count)); - else SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,"OVERFLOW"); - dasm = DisassembleData((count-opsize[patchdata[patchlen][0]]),patchdata[patchlen]); - SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_INSERTSTRING,-1,(LPARAM)(LPSTR)dasm); - AddAsmHistory(hwndDlg,IDC_ASSEMBLER_HISTORY,dasm+16); - SetWindowText(hwndDlg, "Inline Assembler"); - patchlen++; - } - else { //ERROR! - SetWindowText(hwndDlg, "Inline Assembler *Syntax Error*"); - MessageBeep(MB_ICONEXCLAMATION); - } - break; - } - SetFocus(GetDlgItem(hwndDlg,IDC_ASSEMBLER_HISTORY)); //set focus to combo box after anything is pressed! - break; - } - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK PatcherCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - char str[64]; //mbg merge 7/18/06 changed from unsigned char - uint8 *c; - int i; - int *p; - - switch(uMsg) { - case WM_INITDIALOG: - CenterWindow(hwndDlg); - - //set limits - SendDlgItemMessage(hwndDlg,IDC_ROMPATCHER_OFFSET,EM_SETLIMITTEXT,6,0); - SendDlgItemMessage(hwndDlg,IDC_ROMPATCHER_PATCH_DATA,EM_SETLIMITTEXT,30,0); - UpdatePatcher(hwndDlg); - - if(iapoffset != -1){ - CheckDlgButton(hwndDlg, IDC_ROMPATCHER_DOTNES_OFFSET, BST_CHECKED); - sprintf((char*)str,"%X",iapoffset); //mbg merge 7/18/06 added cast - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_OFFSET,str); - } - - SetFocus(GetDlgItem(hwndDlg,IDC_ROMPATCHER_OFFSET_BOX)); - break; - case WM_CLOSE: - case WM_QUIT: - EndDialog(hwndDlg,0); - break; - case WM_COMMAND: - switch(HIWORD(wParam)) { - case BN_CLICKED: - switch(LOWORD(wParam)) { - case IDC_ROMPATCHER_BTN_EDIT: //todo: maybe get rid of this button and cause iapoffset to update every time you change the text - if(IsDlgButtonChecked(hwndDlg,IDC_ROMPATCHER_DOTNES_OFFSET) == BST_CHECKED) - iapoffset = GetEditHex(hwndDlg,IDC_ROMPATCHER_OFFSET); - else - iapoffset = GetNesFileAddress(GetEditHex(hwndDlg,IDC_ROMPATCHER_OFFSET)); - if((iapoffset < 16) && (iapoffset != -1)){ - MessageBox(hDebug, "Sorry, iNes Header editing isn't supported", "Error", MB_OK); - iapoffset = -1; - } - if((iapoffset > PRGsize[0]) && (iapoffset != -1)){ - MessageBox(hDebug, "Error: .Nes offset outside of PRG rom", "Error", MB_OK); - iapoffset = -1; - } - UpdatePatcher(hwndDlg); - break; - case IDC_ROMPATCHER_BTN_APPLY: - p = GetEditHexData(hwndDlg,IDC_ROMPATCHER_PATCH_DATA); - i=0; - c = GetNesPRGPointer(iapoffset-16); - while(p[i] != -1){ - c[i] = p[i]; - i++; - } - UpdatePatcher(hwndDlg); - break; - case IDC_ROMPATCHER_BTN_SAVE: - if (!iNesSave()) - MessageBox(NULL, "Error Saving", "Error", MB_OK); - break; - } - break; - } - break; - } - return FALSE; -} - -extern char *iNesShortFName(); - -void DebuggerExit() -{ - FCEUI_Debugger().badopbreak = 0; - debugger_open = 0; - inDebugger = false; - DestroyWindow(hDebug); - hDebug=0; -} - -static RECT currDebuggerRect; -static RECT newDebuggerRect; - -//used to move all child items in the dialog when you resize (except for the dock fill controls which are resized) -BOOL CALLBACK DebuggerEnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - int dx = (newDebuggerRect.right-newDebuggerRect.left)-(currDebuggerRect.right-currDebuggerRect.left); //Calculate & store difference in width of old size vs new size - int dy = (newDebuggerRect.bottom-newDebuggerRect.top)-(currDebuggerRect.bottom-currDebuggerRect.top); //ditto wtih height - - HWND editbox = GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY); //Get handle for Disassembly list box (large guy on the left) - HWND icontray = GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL); //Get handle for Icontray, vertical column to the left of disassembly - HWND addrline = GetDlgItem(hDebug, IDC_DEBUGGER_ADDR_LINE); //Get handle of address line (text area under the disassembly - HWND vscr = GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY_VSCR); //Get handle for disassembly Vertical Scrollbar - - char str[8] = {0}; - - RECT crect; - GetWindowRect(hwnd,&crect); //Get rect of current child to be resized - ScreenToClient(hDebug,(LPPOINT)&crect); //Convert rect coordinates to client area coordinates - ScreenToClient(hDebug,((LPPOINT)&crect)+1); - - if(hwnd == editbox) - { - crect.right += dx; - crect.bottom += dy; - SetWindowPos(hwnd,0,0,0,crect.right-crect.left,crect.bottom-crect.top,SWP_NOZORDER | SWP_NOMOVE); - GetScrollInfo(GetDlgItem(hDebug,IDC_DEBUGGER_DISASSEMBLY_VSCR),SB_CTL,&si); - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, si.nPos); - } else if(hwnd == icontray) - { - crect.bottom += dy; - SetWindowPos(hwnd,0,0,0,crect.right-crect.left,crect.bottom-crect.top,SWP_NOZORDER | SWP_NOMOVE); - } else if(hwnd == addrline) - { - crect.top += dy; - crect.bottom += dy; - crect.right += dx; - SetWindowPos(hwnd,0,crect.left,crect.top,crect.right-crect.left,crect.bottom-crect.top,SWP_NOZORDER); - } else if(hwnd == vscr) - { - crect.bottom += dy; - crect.left += dx; - crect.right += dx; - SetWindowPos(hwnd,0,crect.left,crect.top,crect.right-crect.left,crect.bottom-crect.top,SWP_NOZORDER); - } else - { - crect.left += dx; - //if (crect.left < 256) crect.left = 256; //Limit how far left the remaining child windows will move - SetWindowPos(hwnd,0,crect.left,crect.top,0,0,SWP_NOZORDER | SWP_NOSIZE); - } - return TRUE; -} - -void LoadGameDebuggerData(HWND hwndDlg = hDebug) -{ - if (!hwndDlg) - return; - - numWPs = myNumWPs; - FillDebuggerBookmarkListbox(hwndDlg); - FillBreakList(hwndDlg); -} - -// returns the address, or EOF if selection cursor points to something else -int Debugger_CheckClickingOnAnAddressOrSymbolicName(unsigned int lineNumber, bool onlyCheckWhenNothingSelected) -{ - // debug_str contains the text in the disassembly window - int sel_start = 0, sel_end = 0; - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - if (onlyCheckWhenNothingSelected) - if (sel_end > sel_start) - return EOF; - - // find the ":" or "$" before sel_start - int i = sel_start - 1; - for (; i > sel_start - 6; i--) - if (i >= 0 && debug_str[i] == ':' || debug_str[i] == '$') - break; - if (i > sel_start - 6) - { - char offsetBuffer[5]; - strncpy(offsetBuffer, debug_str + i + 1, 4); - offsetBuffer[4] = 0; - // invalidate the string if a space or \r is found in it - char* firstspace = strstr(offsetBuffer, " "); - if (!firstspace) - firstspace = strstr(offsetBuffer, "\r"); - if (!firstspace) - { - unsigned int offset; - if (sscanf(offsetBuffer, "%4X", &offset) != EOF) - { - // select the text - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 5)); - PrintOffsetToSeekAndBookmarkFields(offset); - return (int)offset; - } - } - } - - if (symbDebugEnabled && lineNumber < disassembly_addresses.size()) - { - uint16 addr; - Name* node; - char* name; - int nameLen; - char* start_pos; - char* pos; - - // first, try finding the name of disassembly_addresses[lineNumber] - addr = disassembly_addresses[lineNumber]; - node = findNode(getNamesPointerForAddress(addr), addr); - if (node && node->name && *(node->name)) - { - name = node->name; - nameLen = strlen(name); - if (sel_start - nameLen <= 0) - start_pos = debug_str; - else - start_pos = debug_str + (sel_start - nameLen); - pos = strstr(start_pos, name); - if (pos && pos <= debug_str + sel_start) - { - // clicked on the Name - // select the text - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(int)(pos - debug_str), (LPARAM)((int)(pos - debug_str) + nameLen)); - PrintOffsetToSeekAndBookmarkFields(addr); - return (int)addr; - } - } - - // then, try finding the name of disassembly_operands - for (i = disassembly_operands[lineNumber].size() - 1; i >= 0; i--) - { - addr = disassembly_operands[lineNumber][i]; - node = findNode(getNamesPointerForAddress(addr), addr); - if (node && node->name && *(node->name)) - { - name = node->name; - nameLen = strlen(name); - if (sel_start - nameLen <= 0) - start_pos = debug_str; - else - start_pos = debug_str + (sel_start - nameLen); - pos = strstr(start_pos, name); - if (pos && pos <= debug_str + sel_start) - { - // clicked on the operand name - // select the text - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(int)(pos - debug_str), (LPARAM)((int)(pos - debug_str) + nameLen)); - PrintOffsetToSeekAndBookmarkFields(addr); - return (int)addr; - } - } - } - } - - return EOF; -} - -BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_LBUTTONDBLCLK: - { - int offset = Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, false); - if (offset != EOF) - { - // bring "Add Breakpoint" dialog - childwnd = 1; - if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, offset)) - AddBreakList(); - childwnd = 0; - UpdateDebugger(false); - } - return 0; - } - case WM_LBUTTONUP: - { - Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, true); - break; - } - case WM_RBUTTONDOWN: - { - // if nothing is selected, simulate Left-click - int sel_start, sel_end; - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - if (sel_start == sel_end) - { - CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); - CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); - return 0; - } - break; - } - case WM_RBUTTONUP: - { - // save current selection - int sel_start = 0, sel_end = 0; - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - // simulate a click - CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); - CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); - // try bringing Symbolic Debug Naming dialog - int offset = Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, false); - if (offset != EOF) - { - if (DoSymbolicDebugNaming(offset, hDebug)) - { - // enable "Symbolic Debug" if not yet enabled - if (!symbDebugEnabled) - { - symbDebugEnabled = true; - CheckDlgButton(hDebug, IDC_DEBUGGER_ENABLE_SYMBOLIC, BST_CHECKED); - } - UpdateDebugger(false); - } else - { - // then restore old selection - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); - } - return 0; - } else - { - // then restore old selection - SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); - } - break; - } - case WM_MOUSEMOVE: - { - char str[256] = {0}, *ptr, dotdot[4]; - int tmp, i; - int mouse_x, mouse_y; - - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - - tmp = mouse_y / debugSystem->fixedFontHeight; - if (tmp < (int)disassembly_addresses.size()) - { - i = disassembly_addresses[tmp]; - if (i >= 0x8000) - { - dotdot[0] = 0; - ptr = iNesShortFName(); - if (!ptr) - ptr = "..."; - if (strlen(ptr) > 60) - strcpy(dotdot, "..."); - if (GetNesFileAddress(i) == -1) - sprintf(str,"CPU Address $%04X, Error retreiving ROM File Address!",i); - else - sprintf(str,"CPU Address %02X:%04X, Offset 0x%06X in file \"%.40s%s\" (NL file: %X)",getBank(i),i,GetNesFileAddress(i),ptr,dotdot,getBank(i)); - SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE,str); - } else - { - SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Double-click on any address to prompt Add Breakpoint."); - } - } else - { - SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Double-click on any address to prompt Add Breakpoint."); - } - break; - } - case WM_MOUSEWHEEL: - { - SendMessage(GetDlgItem(hDebug, IDC_DEBUGGER_DISASSEMBLY_VSCR), uMsg, wParam, lParam); - return 0; - } - } - return CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, uMsg, wParam, lParam); -} - -BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT wrect; - char str[256] = {0}; - int tmp; - int mouse_x, mouse_y; - int i; - - //these messages get handled at any time - switch(uMsg) - { - case WM_INITDIALOG: - { - CheckDlgButton(hwndDlg, IDC_DEBUGGER_BREAK_ON_CYCLES, break_on_cycles ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS, break_on_instructions ? BST_CHECKED : BST_UNCHECKED); - sprintf(str, "%d", break_cycles_limit); - SetDlgItemText(hwndDlg, IDC_DEBUGGER_CYCLES_EXCEED, str); - sprintf(str, "%d", break_instructions_limit); - SetDlgItemText(hwndDlg, IDC_DEBUGGER_INSTRUCTIONS_EXCEED, str); - - CheckDlgButton(hwndDlg, IDC_DEBUGGER_BREAK_ON_BAD_OP, FCEUI_Debugger().badopbreak ? BST_CHECKED : BST_UNCHECKED); - - CheckDlgButton(hwndDlg, DEBUGLOADDEB, debuggerSaveLoadDEBFiles ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, DEBUGAUTOLOAD, debuggerAutoload ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DEBUGGER_ROM_OFFSETS, debuggerDisplayROMoffsets ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DEBUGGER_ENABLE_SYMBOLIC, symbDebugEnabled ? BST_CHECKED : BST_UNCHECKED); - - if (DbgPosX==-32000) DbgPosX=0; //Just in case - if (DbgPosY==-32000) DbgPosY=0; - SetWindowPos(hwndDlg,0,DbgPosX,DbgPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - - GetWindowRect(hwndDlg,&currDebuggerRect); - - si.cbSize = sizeof(SCROLLINFO); - si.fMask = SIF_ALL; - si.nMin = 0; - si.nMax = 0x10000; - si.nPos = 0; - si.nPage = 8; - SetScrollInfo(GetDlgItem(hwndDlg,IDC_DEBUGGER_DISASSEMBLY_VSCR),SB_CTL,&si,TRUE); - - //setup font - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_DISASSEMBLY,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - //SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_A,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - //SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_X,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - //SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_Y,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - //SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PC,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_STACK_CONTENTS,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - //SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,WM_SETFONT,(WPARAM)debugSystem->hFixedFont,FALSE); - - //text limits - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_A,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_X,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_Y,EM_SETLIMITTEXT,2,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PC,EM_SETLIMITTEXT,4,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_STACK_CONTENTS,EM_SETLIMITTEXT,383,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,EM_SETLIMITTEXT,4,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PPU,EM_SETLIMITTEXT,4,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_SPR,EM_SETLIMITTEXT,2,0); - - //I'm lazy, disable the controls which I can't mess with right now - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_PPU,EM_SETREADONLY,TRUE,0); - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_VAL_SPR,EM_SETREADONLY,TRUE,0); - -// ################################## Start of SP CODE ########################### - - SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BOOKMARK,EM_SETLIMITTEXT,4,0); - - LoadGameDebuggerData(hwndDlg); - - debuggerWasActive = 1; - -// ################################## End of SP CODE ########################### - - // Enable Context Sub-Menus - hDebugcontext = LoadMenu(fceu_hInstance,"DEBUGCONTEXTMENUS"); - - // subclass editfield - IDC_DEBUGGER_DISASSEMBLY_oldWndProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_DEBUGGER_DISASSEMBLY), GWL_WNDPROC, (LONG)IDC_DEBUGGER_DISASSEMBLY_WndProc); - - debugger_open = 1; - inDebugger = true; - break; - } - case WM_SIZE: - { - if(wParam == SIZE_RESTORED) //If dialog was resized - { - GetWindowRect(hwndDlg,&newDebuggerRect); //Get new size - //Force a minimum Dialog size------------------------------- - if (newDebuggerRect.right - newDebuggerRect.left < 368 || newDebuggerRect.bottom - newDebuggerRect.top < 150) //If either x or y is too small run the force size routine - { - if (newDebuggerRect.right - newDebuggerRect.left < 367) //If width is too small reset to previous width - { - newDebuggerRect.right = currDebuggerRect.right; - newDebuggerRect.left = currDebuggerRect.left; - - } - if (newDebuggerRect.bottom - newDebuggerRect.top < 150) //If heigth is too small reset to previous height - { - newDebuggerRect.top = currDebuggerRect.top; - newDebuggerRect.bottom = currDebuggerRect.bottom; - } - SetWindowPos(hwndDlg,HWND_TOPMOST,newDebuggerRect.left,newDebuggerRect.top,(newDebuggerRect.right-newDebuggerRect.left),(newDebuggerRect.bottom-newDebuggerRect.top),SWP_SHOWWINDOW); - } - //Else run normal resizing procedure------------------------- - else - { - DbgSizeX = newDebuggerRect.right-newDebuggerRect.left; //Store new size (this will be used to store in the .cfg file) - DbgSizeY = newDebuggerRect.bottom-newDebuggerRect.top; - EnumChildWindows(hwndDlg,DebuggerEnumWindowsProc,0); //Initiate callback for resizing child windows - currDebuggerRect = newDebuggerRect; //Store current debugger window size (for future calculations in EnumChildWindows - InvalidateRect(hwndDlg,0,TRUE); - UpdateWindow(hwndDlg); - } - } - break; - } - - - case WM_CLOSE: - case WM_QUIT: - //exitdebug: - DebuggerExit(); - break; - case WM_MOVING: - break; - case WM_MOVE: - if (!IsIconic(hwndDlg)) { - GetWindowRect(hwndDlg,&wrect); - DbgPosX = wrect.left; - DbgPosY = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckResize(DbgPosX,DbgPosY,DbgSizeX,wrect.right); - #endif - } - break; - - //adelikat: Buttons that don't need a rom loaded to do something, such as autoload - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case DEBUGAUTOLOAD: - debuggerAutoload ^= 1; - break; - case DEBUGLOADDEB: - debuggerSaveLoadDEBFiles = !debuggerSaveLoadDEBFiles; - break; - case IDC_DEBUGGER_CYCLES_EXCEED: - { - if (HIWORD(wParam) == EN_CHANGE) - { - GetDlgItemText(hwndDlg, IDC_DEBUGGER_CYCLES_EXCEED, str, 16); - break_cycles_limit = strtoul(str, NULL, 10); - } - break; - } - case IDC_DEBUGGER_INSTRUCTIONS_EXCEED: - { - if (HIWORD(wParam) == EN_CHANGE) - { - GetDlgItemText(hwndDlg, IDC_DEBUGGER_INSTRUCTIONS_EXCEED, str, 16); - break_instructions_limit = strtoul(str, NULL, 10); - } - break; - } - } - break; - } - } - - //these messages only get handled when a game is loaded - if (GameInfo) - { - switch(uMsg) - { - case WM_ACTIVATE: - { - //Prevents numerous situations where the debugger is out of date with the data - if (LOWORD(wParam) != WA_INACTIVE) - { - UpdateDebugger(false); - } else - { - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - } - break; - } - case WM_VSCROLL: - { - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - if (lParam) - { - GetScrollInfo((HWND)lParam,SB_CTL,&si); - switch(LOWORD(wParam)) - { - case SB_ENDSCROLL: - case SB_TOP: - case SB_BOTTOM: break; - case SB_LINEUP: - { - si.nPos = InstructionUp(si.nPos); - break; - } - case SB_LINEDOWN: - { - si.nPos = InstructionDown(si.nPos); - break; - } - case SB_PAGEUP: - { - for (int i = si.nPage; i > 0; i--) - { - si.nPos = InstructionUp(si.nPos); - if (si.nPos < si.nMin) - { - si.nPos = si.nMin; - break; - } - } - break; - } - case SB_PAGEDOWN: - { - for (int i = si.nPage; i > 0; i--) - { - si.nPos = InstructionDown(si.nPos); - if ((si.nPos + (int)si.nPage) > si.nMax) - { - si.nPos = si.nMax - si.nPage; - break; - } - } - break; - } - case SB_THUMBPOSITION: //break; - case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; - } - if (si.nPos < si.nMin) - si.nPos = si.nMin; - if ((si.nPos + (int)si.nPage) > si.nMax) - si.nPos = si.nMax - si.nPage; - SetScrollInfo((HWND)lParam,SB_CTL,&si,TRUE); - - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, si.nPos); - // "Address Bookmark Add" follows the address - sprintf(str,"%04X", si.nPos); - SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str); - } - break; - } - case WM_CONTEXTMENU: - { - // Handle certain stubborn context menus for nearly incapable controls. - - if (wParam == (uint32)GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_LIST)) { - // Only open the menu if a cheat is selected - if (SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0) >= 0) { - // Open IDC_LIST_CHEATS Context Menu - hDebugcontextsub = GetSubMenu(hDebugcontext,0); - SetMenuDefaultItem(hDebugcontextsub, DEBUGGER_CONTEXT_TOGGLEBREAK, false); - if (lParam != -1) - TrackPopupMenu(hDebugcontextsub,TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,hwndDlg,0); //Create menu - else { // Handle the context menu keyboard key - GetWindowRect(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_LIST), &wrect); - TrackPopupMenu(hDebugcontextsub,TPM_RIGHTBUTTON,wrect.left + int((wrect.right - wrect.left) / 3),wrect.top + int((wrect.bottom - wrect.top) / 3),0,hwndDlg,0); //Create menu - } - - } - } - break; - } - case WM_MOUSEWHEEL: - { - GetScrollInfo((HWND)lParam,SB_CTL,&si); - i = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; - if (i < 0) - { - for (i *= -(int)si.nPage; i > 0; i--) - { - si.nPos = InstructionDown(si.nPos); - if ((si.nPos + (int)si.nPage) > si.nMax) - { - si.nPos = si.nMax - si.nPage; - break; - } - } - } else if (i > 0) - { - for (i *= si.nPage; i > 0; i--) - { - si.nPos = InstructionUp(si.nPos); - if (si.nPos < si.nMin) - { - si.nPos = si.nMin; - break; - } - } - } - SetScrollInfo((HWND)lParam,SB_CTL,&si,TRUE); - - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, si.nPos); - // "Address Bookmark Add" follows the address - sprintf(str,"%04X", si.nPos); - SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str); - break; - } - case WM_KEYDOWN: - MessageBox(hwndDlg,"Die!","I'm dead!",MB_YESNO|MB_ICONINFORMATION); - break; - - case WM_MOUSEMOVE: - { - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - - bool setString = false; - if ((mouse_x > 6) && (mouse_x < 30) && (mouse_y > 10)) - { - setString = true; - RECT rectDisassembly; - GetClientRect(GetDlgItem(hDebug,IDC_DEBUGGER_DISASSEMBLY),&rectDisassembly); - int height = rectDisassembly.bottom-rectDisassembly.top; - tmp = mouse_y - 10; - if(tmp > height) - setString = false; - tmp /= debugSystem->fixedFontHeight; - } - - if (setString) - SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Leftclick = Inline Assembler. Midclick = Game Genie. Rightclick = Hexeditor."); - else - SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, ""); - break; - } - case WM_LBUTTONDOWN: - { - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); -// ################################## Start of SP CODE ########################### - - // mouse_y < 538 - // > 33) tmp = 33 - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused() && (mouse_x > 6) && (mouse_x < 30) && (mouse_y > 10)) - { - tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; -// ################################## End of SP CODE ########################### - if (tmp < (int)disassembly_addresses.size()) - { - i = disassembly_addresses[tmp]; - //DoPatcher(GetNesFileAddress(i),hwndDlg); - iaPC=i; - if (iaPC >= 0x8000) - { - DialogBox(fceu_hInstance,"ASSEMBLER",hwndDlg,AssemblerCallB); - UpdateDebugger(false); - } - } - } - break; - } - case WM_RBUTTONDOWN: - { - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused() && (mouse_x > 6) && (mouse_x < 30) && (mouse_y > 10)) - { - tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; - if (tmp < (int)disassembly_addresses.size()) - { - i = disassembly_addresses[tmp]; - if (i >= 0x8000) - // show ROM data in Hexeditor - ChangeMemViewFocus(2, GetNesFileAddress(i), -1); - else - // show RAM data in Hexeditor - ChangeMemViewFocus(0, i, -1); - } - } - break; - } - case WM_MBUTTONDOWN: - { - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused() && (mouse_x > 6) && (mouse_x < 30) && (mouse_y > 10)) - { - tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; - if (tmp < (int)disassembly_addresses.size()) - { - i = disassembly_addresses[tmp]; - SetGGConvFocus(i,GetMem(i)); - } - } - break; - } - case WM_INITMENUPOPUP: - case WM_INITMENU: - break; - case WM_COMMAND: - { - switch(HIWORD(wParam)) - { - case BN_CLICKED: - switch(LOWORD(wParam)) { - case IDC_DEBUGGER_RESTORESIZE: - RestoreSize(hwndDlg); - break; - case IDC_DEBUGGER_BP_ADD: - childwnd = 1; - if (DialogBoxParam(fceu_hInstance,"ADDBP",hwndDlg,AddbpCallB, 0)) AddBreakList(); - childwnd = 0; - UpdateDebugger(false); - break; - case IDC_DEBUGGER_BP_DEL: - DeleteBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0)); - break; - case IDC_DEBUGGER_BP_EDIT: - WP_edit = SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0); - if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, 0)) EditBreakList(); - WP_edit = -1; - UpdateDebugger(false); - break; - case IDC_DEBUGGER_RUN: - //mbg merge 7/18/06 changed pausing check and set - if (FCEUI_EmulationPaused()) { - UpdateRegs(hwndDlg); - FCEUI_ToggleEmulationPause(); - //DebuggerWasUpdated = false done in above function; - } - break; - case IDC_DEBUGGER_STEP_IN: - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - FCEUI_Debugger().step = true; - FCEUI_SetEmulationPaused(0); - UpdateOtherDebuggingDialogs(); - - break; - case IDC_DEBUGGER_RUN_LINE: - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - FCEUI_Debugger().runline = true; - { - uint64 ts=timestampbase; - ts+=timestamp; - ts+=341/3; - //if (scanline == 240) vblankScanLines++; - //else vblankScanLines = 0; - FCEUI_Debugger().runline_end_time=ts; - } - FCEUI_SetEmulationPaused(0); - UpdateOtherDebuggingDialogs(); - break; - case IDC_DEBUGGER_RUN_FRAME2: - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - FCEUI_Debugger().runline = true; - { - uint64 ts=timestampbase; - ts+=timestamp; - ts+=128*341/3; - FCEUI_Debugger().runline_end_time=ts; - //if (scanline+128 >= 240 && scanline+128 <= 257) vblankScanLines = (scanline+128)-240; - //else vblankScanLines = 0; - } - FCEUI_SetEmulationPaused(0); - UpdateOtherDebuggingDialogs(); - break; - case IDC_DEBUGGER_STEP_OUT: - //mbg merge 7/18/06 changed pausing check and set - if (FCEUI_EmulationPaused() > 0) { - DebuggerState &dbgstate = FCEUI_Debugger(); - UpdateRegs(hwndDlg); - if ((dbgstate.stepout) && (MessageBox(hwndDlg,"Step Out is currently in process. Cancel it and setup a new Step Out watch?","Step Out Already Active",MB_YESNO|MB_ICONINFORMATION) != IDYES)) break; - if (GetMem(X.PC) == 0x20) dbgstate.jsrcount = 1; - else dbgstate.jsrcount = 0; - dbgstate.stepout = 1; - FCEUI_SetEmulationPaused(0); - } - break; - case IDC_DEBUGGER_STEP_OVER: - //mbg merge 7/18/06 changed pausing check and set - if (FCEUI_EmulationPaused()) { - UpdateRegs(hwndDlg); - if (GetMem(tmp=X.PC) == 0x20) { - if ((watchpoint[64].flags) && (MessageBox(hwndDlg,"Step Over is currently in process. Cancel it and setup a new Step Over watch?","Step Over Already Active",MB_YESNO|MB_ICONINFORMATION) != IDYES)) break; - watchpoint[64].address = (tmp+3); - watchpoint[64].flags = WP_E|WP_X; - } - else FCEUI_Debugger().step = true; - FCEUI_SetEmulationPaused(0); - } - break; - case IDC_DEBUGGER_SEEK_PC: - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused()) - { - UpdateRegs(hwndDlg); - UpdateDebugger(true); - } - break; - case IDC_DEBUGGER_SEEK_TO: - { - //mbg merge 7/18/06 changed pausing check - if (FCEUI_EmulationPaused()) - UpdateRegs(hwndDlg); - GetDlgItemText(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,str,5); - tmp = offsetStringToInt(BT_C, str); - if (tmp != -1) - { - sprintf(str,"%04X", tmp); - SetDlgItemText(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,str); - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, tmp); - // "Address Bookmark Add" follows the address - sprintf(str,"%04X", si.nPos); - SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str); - } - break; - } - case IDC_DEBUGGER_BREAK_ON_BAD_OP: //Break on bad opcode - FCEUI_Debugger().badopbreak ^= 1; - break; - case IDC_DEBUGGER_FLAG_N: X.P^=N_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_V: X.P^=V_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_U: X.P^=U_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_B: X.P^=B_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_D: X.P^=D_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_I: X.P^=I_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_Z: X.P^=Z_FLAG; UpdateDebugger(false); break; - case IDC_DEBUGGER_FLAG_C: X.P^=C_FLAG; UpdateDebugger(false); break; - - case IDC_DEBUGGER_RESET_COUNTERS: - { - ResetDebugStatisticsCounters(); - UpdateDebugger(false); - break; - } - case IDC_DEBUGGER_BREAK_ON_CYCLES: - { - break_on_cycles ^= 1; - break; - } - case IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS: - { - break_on_instructions ^= 1; - break; - } - -// ################################## Start of SP CODE ########################### - - case IDC_DEBUGGER_RELOAD_SYMS: - { - ramBankNamesLoaded = false; - lastBank = loadedBank = -1; - loadNameFiles(); - UpdateDebugger(false); - break; - } - case IDC_DEBUGGER_BOOKMARK_ADD: AddDebuggerBookmark(hwndDlg); break; - case IDC_DEBUGGER_BOOKMARK_DEL: DeleteDebuggerBookmark(hwndDlg); break; - case IDC_DEBUGGER_BOOKMARK_NAME: NameDebuggerBookmark(hwndDlg); break; - case IDC_DEBUGGER_ENABLE_SYMBOLIC: - { - symbDebugEnabled ^= 1; - CheckDlgButton(hwndDlg, IDC_DEBUGGER_ENABLE_SYMBOLIC, symbDebugEnabled ? BST_CHECKED : BST_UNCHECKED); - UpdateDebugger(false); - break; - } - -// ################################## End of SP CODE ########################### - - case IDC_DEBUGGER_ROM_OFFSETS: - { - debuggerDisplayROMoffsets ^= 1; - UpdateDebugger(false); - break; - } - case IDC_DEBUGGER_ROM_PATCHER: DoPatcher(-1,hwndDlg); break; - case DEBUGGER_CONTEXT_TOGGLEBREAK: DebuggerCallB(hwndDlg, WM_COMMAND, (LBN_DBLCLK * 0x10000) | (IDC_DEBUGGER_BP_LIST), lParam); break; - } - break; - case LBN_DBLCLK: - switch(LOWORD(wParam)) { - case IDC_DEBUGGER_BP_LIST: - EnableBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0)); - break; -// ################################## Start of SP CODE ########################### - - case LIST_DEBUGGER_BOOKMARKS: GoToDebuggerBookmark(hwndDlg); break; - -// ################################## End of SP CODE ########################### - } - break; - case LBN_SELCANCEL: - switch(LOWORD(wParam)) { - case IDC_DEBUGGER_BP_LIST: - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_DEL),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_EDIT),FALSE); - break; - } - break; - case LBN_SELCHANGE: - switch(LOWORD(wParam)) - { - case IDC_DEBUGGER_BP_LIST: - { - if (SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0) >= 0) - { - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_DEL),TRUE); - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_EDIT),TRUE); - } else - { - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_DEL),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_EDIT),FALSE); - } - break; - } - } - break; - } - break; - } - } - } - - - return FALSE; //TRUE; -} - -extern void iNESGI(GI h); - -void DoPatcher(int address, HWND hParent) -{ - iapoffset = address; - if (GameInterface == iNESGI) - DialogBox(fceu_hInstance, "ROMPATCHER", hParent, PatcherCallB); - else - MessageBox(hDebug, "Sorry, The Patcher only works on INES rom images", "Error", MB_OK); - UpdateDebugger(false); -} - -void UpdatePatcher(HWND hwndDlg){ - char str[75]; //mbg merge 7/18/06 changed from unsigned - uint8 *p; - if(iapoffset != -1){ - EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_PATCH_DATA),TRUE); - EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_BTN_APPLY),TRUE); - - if(GetRomAddress(iapoffset) != -1)sprintf(str,"Current Data at NES ROM Address: %04X, .NES file Address: %04X",GetRomAddress(iapoffset),iapoffset); - else sprintf(str,"Current Data at .NES file Address: %04X",iapoffset); - - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_CURRENT_DATA_BOX,str); - - sprintf(str,"%04X",GetRomAddress(iapoffset)); - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_DISASSEMBLY,str); - - if(GetRomAddress(iapoffset) != -1)SetDlgItemText(hwndDlg,IDC_ROMPATCHER_DISASSEMBLY,DisassembleLine(GetRomAddress(iapoffset))); - else SetDlgItemText(hwndDlg,IDC_ROMPATCHER_DISASSEMBLY,"Not Currently Loaded in ROM for disassembly"); - - p = GetNesPRGPointer(iapoffset-16); - sprintf(str,"%02X %02X %02X %02X %02X %02X %02X %02X", - p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]); - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_CURRENT_DATA,str); - - } else { - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_CURRENT_DATA_BOX,"No Offset Selected"); - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_CURRENT_DATA,""); - SetDlgItemText(hwndDlg,IDC_ROMPATCHER_DISASSEMBLY,""); - EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_PATCH_DATA),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_BTN_APPLY),FALSE); - } - if(GameInfo->type != GIT_CART)EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_BTN_SAVE),FALSE); - else EnableWindow(GetDlgItem(hwndDlg,IDC_ROMPATCHER_BTN_SAVE),TRUE); -} - -/// Updates debugger controls that should be enabled/disabled if a game is loaded. -/// @param enable Flag that indicates whether the menus should be enabled (1) or disabled (0). -void updateGameDependentMenusDebugger(unsigned int enable) { - if (!hDebug) - return; - - //EnableWindow(GetDlgItem(hDebug,DEBUGLOADDEB),(enable ? 0 : 1)); -} - -void DoDebug(uint8 halt) -{ - if (!debugger_open) - { - hDebug = CreateDialog(fceu_hInstance,"DEBUGGER",NULL,DebuggerCallB); - if(DbgSizeX != -1 && DbgSizeY != -1) - SetWindowPos(hDebug,0,0,0,DbgSizeX,DbgSizeY,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER); - } - if (hDebug) - { - //SetWindowPos(hDebug,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); - ShowWindow(hDebug, SW_SHOWNORMAL); - SetForegroundWindow(hDebug); - - updateGameDependentMenusDebugger(GameInfo != 0); - - if (GameInfo) - UpdateDebugger(true); - } -} - -//----------------------------------------- -DebugSystem* debugSystem; -unsigned int debuggerFontSize = 15; -unsigned int hexeditorFontSize = 15; - -DebugSystem::DebugSystem() -{ -} - -void DebugSystem::init() -{ - hFixedFont = CreateFont(debuggerFontSize, debuggerFontSize / 2, /*Height,Width*/ - 0,0, /*escapement,orientation*/ - FW_REGULAR,FALSE,FALSE,FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET,OUT_DEVICE_PRECIS,CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Courier New"); /*font name*/ - - hHexeditorFont = CreateFont(hexeditorFontSize, hexeditorFontSize / 2, /*Height,Width*/ - 0,0, /*escapement,orientation*/ - FW_REGULAR,FALSE,FALSE,FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET,OUT_DEVICE_PRECIS,CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Courier"); /*font name*/ - - HDC hdc = GetDC(GetDesktopWindow()); - HGDIOBJ old = SelectObject(hdc,hFixedFont); - TEXTMETRIC tm; - GetTextMetrics(hdc,&tm); - fixedFontHeight = tm.tmHeight; - fixedFontWidth = tm.tmAveCharWidth; - //printf("fixed font height: %d\n",fixedFontHeight); - //printf("fixed font width: %d\n",fixedFontWidth); - SelectObject(hdc, hHexeditorFont); - GetTextMetrics(hdc,&tm); - HexeditorFontHeight = tm.tmHeight; - HexeditorFontWidth = tm.tmAveCharWidth; - SelectObject(hdc,old); - DeleteDC(hdc); -} - -DebugSystem::~DebugSystem() -{ - if (hFixedFont) - { - DeleteObject(hFixedFont); - hFixedFont = 0; - } - if (hHexeditorFont) - { - DeleteObject(hHexeditorFont); - hHexeditorFont = 0; - } -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/debugger.h b/branches/fceux-2.2.2/src/drivers/win/debugger.h deleted file mode 100644 index fc204a47..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/debugger.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef DEBUGGER_H -#define DEBUGGER_H - -//#define GetMem(x) (((x < 0x2000) || (x >= 0x4020))?ARead[x](x):0xFF) -#include -//#include "debug.h" - -// TODO: Maybe change breakpoint array to std::vector -// Maximum number of breakpoints supported -#define MAXIMUM_NUMBER_OF_BREAKPOINTS 64 - -// Return values for AddBreak -#define TOO_MANY_BREAKPOINTS 1 -#define INVALID_BREAKPOINT_CONDITION 3 - -//extern volatile int userpause; //mbg merge 7/18/06 removed for merging -extern int scanline; //current scanline! :D -extern HWND hDebug; - -extern int childwnd,numWPs; //mbg merge 7/18/06 had to make extern -extern bool debuggerAutoload; -extern bool debuggerSaveLoadDEBFiles; -extern bool debuggerDisplayROMoffsets; - -extern unsigned int debuggerFontSize; -extern unsigned int hexeditorFontSize; - -void CenterWindow(HWND hwndDlg); -void DoPatcher(int address,HWND hParent); -void UpdatePatcher(HWND hwndDlg); -int GetEditHex(HWND hwndDlg, int id); - -extern void AddBreakList(); -extern char* BreakToText(unsigned int num); - -void UpdateDebugger(bool jump_to_pc = true); -void DoDebug(uint8 halt); -void DebuggerExit(); -void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr); -void PrintOffsetToSeekAndBookmarkFields(int offset); - -void LoadGameDebuggerData(HWND hwndDlg); -void updateGameDependentMenusDebugger(unsigned int enable); - -extern bool inDebugger; - -extern class DebugSystem { -public: - DebugSystem(); - ~DebugSystem(); - - void init(); - - HFONT hFixedFont; - int fixedFontWidth; - int fixedFontHeight; - - HFONT hHexeditorFont; - int HexeditorFontWidth; - int HexeditorFontHeight; - -} *debugSystem; - - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/win/debuggersp.cpp b/branches/fceux-2.2.2/src/drivers/win/debuggersp.cpp deleted file mode 100644 index 17552300..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/debuggersp.cpp +++ /dev/null @@ -1,1052 +0,0 @@ -/* FCEUXD SP - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 Sebastian Porst - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include "utils/xstring.h" -#include "debuggersp.h" -#include "debugger.h" -#include "../../fceu.h" -#include "../../debug.h" -#include "../../conddebug.h" - -#include -#include -#include - -int GetNesFileAddress(int A); - -Name* lastBankNames = 0; -Name* loadedBankNames = 0; -Name* ramBankNames = 0; -bool ramBankNamesLoaded = false; -int lastBank = -1; -int loadedBank = -1; -extern char LoadedRomFName[2048]; -char NLfilename[2048]; -bool symbDebugEnabled = true; -int debuggerWasActive = 0; -char temp_chr[40] = {0}; -char delimiterChar[2] = "#"; - -extern BOOL CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -extern char bookmarkDescription[]; - -/** -* Tests whether a char is a valid hexadecimal character. -* -* @param c The char to test -* @return True or false. -**/ -int isHex(char c) -{ - return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); -} - -/** -* Parses a line from a NL file. -* @param line The line to parse -* @param n The name structure to write the information to -* -* @return 0 if everything went OK. Otherwise an error code is returned. -**/ -int parseLine(char* line, Name* n) -{ - char* pos; - int llen; - - // Check parameters - - if (!line) - { - MessageBox(0, "Invalid parameter \"line\" in function parseLine", "Error", MB_OK | MB_ICONERROR); - return 1; - } - - if (!n) - { - MessageBox(0, "Invalid parameter \"n\" in function parseLine", "Error", MB_OK | MB_ICONERROR); - return 2; - } - - // Allow empty lines - if (*line == '\r' || *line == '\n') - { - return -1; - } - - // Attempt to tokenize the given line - - pos = strstr(line, delimiterChar); - - if (!pos) - { - // Found an invalid line - return 3; - } - - // Check if the first tokenized part (the offset) is valid - - *pos = 0; - - llen = (int)strlen(line); - - if (llen == 5) // Offset size of normal lines of the form $XXXX - { - if (line[0] != '$' - || !isHex(line[1]) - || !isHex(line[2]) - || !isHex(line[3]) - || !isHex(line[4]) - ) - { - return 4; - } - } - else if (llen >= 7) // Offset size of array definition lines of the form $XXXX/YY - { - int i; - if (line[0] != '$' - || !isHex(line[1]) - || !isHex(line[2]) - || !isHex(line[3]) - || !isHex(line[4]) - || line[5] != '/' - ) - { - return 5; - } - - for (i=6;line[i];i++) - { - if (!isHex(line[i])) - { - return 6; - } - } - } - else // Lines that have an invalid size - { - return 7; - } - - - // TODO: Validate if the offset is in the correct NL file. - - // After validating the offset it's OK to store it - n->offset = (char*)malloc(strlen(line) + 1); - strcpy(n->offset, line); - line = pos + 1; - - // Attempt to tokenize the string again to find the name of the address - - pos = strstr(line, delimiterChar); - - if (!pos) - { - // Found an invalid line - return 8; - } - - *pos = 0; - - if (*line) - { - if (strlen(line) > NL_MAX_NAME_LEN) - line[NL_MAX_NAME_LEN + 1] = 0; - n->name = (char*)malloc(strlen(line) + 1); - strcpy(n->name, line); - } - else - { - // Properly initialize zero-length names too - n->name = 0; - } - - // Now it's clear that the line was valid. The rest of the line is the comment - // that belongs to that line. Once again a real string is required though. - - line = pos + 1; - - if (*line > 0x0D) - { - if (strlen(line) > NL_MAX_MULTILINE_COMMENT_LEN) - line[NL_MAX_MULTILINE_COMMENT_LEN + 1] = 0; - // remove all backslashes after \r\n - char* crlf_pos = strstr(line, "\r\n\\"); - while (crlf_pos) - { - strcpy(crlf_pos + 2, crlf_pos + 3); - crlf_pos = strstr(crlf_pos + 2, "\r\n\\"); - } - - n->comment = (char*)malloc(strlen(line) + 1); - strcpy(n->comment, line); - } - else - { - // Properly initialize zero-length comments too - n->comment = 0; - } - - // Everything went fine. - return 0; -} - -/** -* Parses an array of lines read from a NL file. -* @param lines The lines to parse -* @param filename The name of the file the lines were read from. -* -* @return A pointer to the first Name structure built from the parsed lines. -**/ -Name* parse(char* lines, const char* filename) -{ - char* pos, *size; - Name* prev = 0, *cur, *first = 0; - - // Check the parameters - if (!lines) - { - MessageBox(0, "Invalid parameter \"lines\" in function parse", "Error", MB_OK | MB_ICONERROR); - return 0; - } - - if (!filename) - { - MessageBox(0, "Invalid parameter \"filename\" in function parse", "Error", MB_OK | MB_ICONERROR); - return 0; - } - - // Begin the actual parsing - - do - { - int fail; - - // Allocate a name structure to hold the parsed data from the next line - - cur = (Name*)malloc(sizeof(Name)); - cur->offsetNumeric = 0; - cur->offset = 0; - cur->next = 0; - cur->name = 0; - cur->comment = 0; - - pos = lines; - - // This first loop attempts to read potential multi-line comments and add them - // into a single comment. - for(;;) - { - // Get the end of the next line - pos = strstr(pos, "\n"); - - // If there's no end of line or if the next line does not begin with a \ character - // we can stop. - if (!pos || pos[1] != '\\') break; - - // At this point we have the following situation. pos[0] and pos[1] can be overwritten - /* - pos -1 0 1 2 - ? \n \ ? - */ - - // \r\n is needed in text boxes - if (pos[-1] != '\r') - { - pos[0] = '\r'; - pos[1] = '\n'; - } - pos += 2; - } - - if (!pos) - { - // All lines were parsed - break; - } - - if (pos[-1] == '\r') - pos[-1] = 0; - else - *pos = 0; - - // Attempt to parse the current line - fail = parseLine(lines, cur); - - if (fail == -1) - { - continue; - } else if (fail) - { - // Show an error to allow the user to correct the defect line - const char* fmtString = "Error (Code: %d): Invalid line \"%s\" in NL file \"%s\"\n"; - char* msg = (char*)malloc(strlen(fmtString) + 8 + strlen(lines) + strlen(filename) + 1); - sprintf(msg, fmtString, fail, lines, filename); - MessageBox(0, msg, "Error", MB_OK | MB_ICONERROR); - free(msg); - lines = pos + 1; - //MessageBox(0, lines, "Error", MB_OK | MB_ICONERROR); - continue; - } - - lines = pos + 1; - - // Check if the line is an array definition line - - size = strstr(cur->offset, "/"); - - if (size) // Array definition line - { - int arrlen, offset; - - *size = 0; - - // Attempt to read the length of the array and the array offset - if (sscanf(size + 1, "%x", &arrlen) > 0 && sscanf(cur->offset + 1, "%x", &offset) > 0) - { - Name* nn = 0; - int i; - - // Create a node for each element of the array - for (i=0;i<=arrlen;i++) - { - char numbuff[10] = {0}; - - nn = (Name*)malloc(sizeof(Name)); - nn->next = 0; - - // The comment is the same for each array element - nn->comment = strdup(cur->comment); - - // The offset of the node - nn->offset = (char*)malloc(6); - sprintf(nn->offset, "$%04X", offset + i); - nn->offsetNumeric = offset + i; - - // The name of an array address is of the form NAME[INDEX] - sprintf(numbuff, "[%X]", i); - - nn->name = (char*)malloc(strlen(cur->name) + strlen(numbuff) + 1); - strcpy(nn->name, cur->name); - strcat(nn->name, numbuff); - - // Add the new node to the list of address nodes - if (prev) - { - prev->next = nn; - prev = prev->next; - } else - { - first = prev = nn; - } - } - - // Free the allocated node - free(cur->name); - free(cur->comment); - free(cur->offset); - free(cur); - - cur = nn; - } - else - { - // I don't think it's possible to get here as the validity of - // offset and array size has already been validated in parseLine - continue; - } - } else - { - sscanf(cur->offset, "%*[$]%4X", &(cur->offsetNumeric)); - // Add the node to the list of address nodes - if (prev) - { - prev->next = cur; - prev = prev->next; - } - else - { - first = prev = cur; - } - } - } while (pos); - - // Return the first node in the list of address nodes - return first; -} - -/** -* Load and parse an entire NL file -* @param filename Name of the file to parse -* -* @return A pointer to the first Name structure built from the file data. -**/ -Name* parseNameFile(const char* filename) -{ - char* buffer; - Name* n = 0; - - // Attempt to read the file - FILE* f = fopen(filename, "rb"); - - if (f) - { -// __asm (".byte 0xcc"); - // Get the file size - int lSize; - fseek (f , 0 , SEEK_END); - lSize = ftell(f) + 1; - - // Allocate sufficient buffer space - rewind (f); - - buffer = (char*)malloc(lSize); - - if (buffer) - { - // Read the file and parse it - memset(buffer, 0, lSize); - fread(buffer, 1, lSize - 1, f); - n = parse(buffer, filename); - - fclose(f); - - free(buffer); - } - } - - return n; -} - -/** -* Frees an entire list of Name nodes starting with the given node. -* -* @param n The node to start with (0 is a valid value) -**/ -void freeList(Name* n) -{ - Name* next; - - while (n) - { - if (n->offset) free(n->offset); - if (n->name) free(n->name); - if (n->comment) free(n->comment); - - next = n->next; - free(n); - n = next; - } -} - -/** -* Replaces all offsets in a string with the names that were given to those offsets -* The caller needs to make sure that str is large enough. -* -* @param list NL list of address definitions -* @param str The string where replacing takes place. -* @param addressesLog Vector for collecting addresses that were replaced by names -**/ -void replaceNames(Name* list, char* str, std::vector* addressesLog) -{ - static char buff[1001]; - char* pos; - char* src; - - while (list) - { - if (list->name) - { - // find and replace substrings - *buff = 0; - src = str; - - while ((pos = strstr(src, list->offset))) - { - *pos = 0; - strcat(buff, src); - strcat(buff, list->name); - src = pos + 5; // 5 = strlen(beg->offset), because all offsets are in "$XXXX" format - if (addressesLog) - addressesLog->push_back(list->offsetNumeric); - } - // if any offsets were changed, replace str by buff - if (*buff) - { - strcat(buff, src); - // replace whole str - strcpy(str, buff); - } - } - list = list->next; - } -} - -/** -* Searches an address node in a list of address nodes. The found node -* has the same offset as the passed parameter offs. -* -* @param node The address node list -* @offs The offset to search -* @return The node that has the given offset or 0. -**/ -Name* findNode(Name* node, const char* offset) -{ - while (node) - { - if (!strcmp(node->offset, offset)) - return node; - - node = node->next; - } - return 0; -} -// same, but with offsetNumeric -Name* findNode(Name* node, uint16 offsetNumeric) -{ - while (node) - { - if (node->offsetNumeric == offsetNumeric) - return node; - - node = node->next; - } - return 0; -} - -char* generateNLFilenameForAddress(uint16 address) -{ - if (address < 0x8000) - { - // The NL file for the RAM addresses has the name nesrom.nes.ram.nl - strcpy(NLfilename, mass_replace(LoadedRomFName, "|", ".").c_str()); - strcat(NLfilename, ".ram.nl"); - } else - { - sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), getBank(address)); - } - return NLfilename; -} -Name* getNamesPointerForAddress(uint16 address) -{ - // this function is called very often (when using "Symbolic trace"), so this is sorted by frequency - if (address >= 0xC000) - { - return lastBankNames; - } else if (address >= 0x8000) - { - return loadedBankNames; - } else - { - return ramBankNames; - } -} -void setNamesPointerForAddress(uint16 address, Name* newNode) -{ - if (address < 0x8000) - { - ramBankNames = newNode; - } else if (address < 0xC000) - { - loadedBankNames = newNode; - } else - { - lastBankNames = newNode; - } -} - -/** -* Loads the necessary NL files -**/ -// TODO: instead of loading from disk every time the "loadedBankNames" changes, it's better to cache loaded linkedlists in memory -void loadNameFiles() -{ - int cb; - - if (!ramBankNamesLoaded) - { - ramBankNamesLoaded = true; - // load RAM names - if (ramBankNames) - free(ramBankNames); - - // Load the address descriptions for the RAM addresses - ramBankNames = parseNameFile(generateNLFilenameForAddress(0x0000)); - } - - // Find out which bank is loaded at 0xC000 - cb = getBank(0xC000); - if (cb == -1) // No bank was loaded at that offset - { - free(lastBankNames); - lastBankNames = 0; - } else if (cb != lastBank) - { - // If the bank changed since loading the NL files the last time it's necessary - // to load the address descriptions of the new bank. - lastBank = cb; - - if (lastBankNames) - freeList(lastBankNames); - - // Load new address definitions - lastBankNames = parseNameFile(generateNLFilenameForAddress(0xC000)); - } - - // Find out which bank is loaded at 0x8000 - cb = getBank(0x8000); - if (cb == -1) // No bank is loaded at that offset - { - free(loadedBankNames); - loadedBankNames = 0; - } else if (cb != loadedBank) - { - // If the bank changed since loading the NL files the last time it's necessary - // to load the address descriptions of the new bank. - - loadedBank = cb; - - if (loadedBankNames) - freeList(loadedBankNames); - - // Load new address definitions - loadedBankNames = parseNameFile(generateNLFilenameForAddress(0x8000)); - } -} - -// bookmarks -std::vector bookmarks_addr; -std::vector bookmarks_name; - -/** -* Returns the bookmark address of a CPU bookmark identified by its index. -* The caller must make sure that the index is valid. -* -* @param hwnd HWND of the debugger window -* @param index Index of the bookmark -**/ -unsigned int getBookmarkAddress(unsigned int index) -{ - if (index < bookmarks_addr.size()) - return bookmarks_addr[index]; - else - return 0; -} - -/** -* Adds a debugger bookmark to the list on the debugger window. -* -* @param hwnd HWMD of the debugger window -* @param buffer Text of the debugger bookmark -**/ -void AddDebuggerBookmark2(HWND hwnd, unsigned int addr) -{ - int index = bookmarks_addr.size(); - bookmarks_addr.push_back(addr); - // try to find Symbolic name for this address - Name* node = findNode(getNamesPointerForAddress(addr), addr); - if (node && node->name) - bookmarks_name.push_back(node->name); - else - bookmarks_name.push_back(""); - - // add new item to ListBox - char buffer[256]; - sprintf(buffer, "%04X %s", bookmarks_addr[index], bookmarks_name[index].c_str()); - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer); - // select this item - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, index, 0); -} - -/** -* Takes the offset from the debugger bookmark edit field and adds a debugger -* bookmark with that offset to the bookmark list if the offset is valid. -* -* @param hwnd HWMD of the debugger window -**/ -void AddDebuggerBookmark(HWND hwnd) -{ - int n; - char buffer[5] = {0}; - - GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5); - n = offsetStringToInt(BT_C, buffer); - // Make sure the offset is valid - if (n == -1 || n > 0xFFFF) - { - MessageBox(hwnd, "Invalid offset", "Error", MB_OK | MB_ICONERROR); - return; - } - AddDebuggerBookmark2(hwnd, n); -} - -/** -* Removes a debugger bookmark -* -* @param hwnd HWND of the debugger window -**/ -void DeleteDebuggerBookmark(HWND hwnd) -{ - // Get the selected bookmark - unsigned int selectedItem = SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETCURSEL, 0, 0); - - if (selectedItem == LB_ERR) - { - MessageBox(hwnd, "Please select a bookmark from the list", "Error", MB_OK | MB_ICONERROR); - return; - } else - { - // Erase the selected bookmark - bookmarks_addr.erase(bookmarks_addr.begin() + selectedItem); - bookmarks_name.erase(bookmarks_name.begin() + selectedItem); - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_DELETESTRING, selectedItem, 0); - // Select next item - if (selectedItem >= (bookmarks_addr.size() - 1)) - // select last item - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, bookmarks_addr.size() - 1, 0); - else - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, selectedItem, 0); - - } -} - -void NameDebuggerBookmark(HWND hwnd) -{ - // Get the selected bookmark - int selectedItem = SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETCURSEL, 0, 0); - if (selectedItem == LB_ERR || selectedItem >= (int)bookmarks_name.size()) - { - MessageBox(hwnd, "Please select a bookmark from the list", "Error", MB_OK | MB_ICONERROR); - return; - } else - { - if (bookmarks_name[selectedItem].size()) - { - strcpy(bookmarkDescription, bookmarks_name[selectedItem].c_str()); - } else - { - bookmarkDescription[0] = 0; - // try to find the same address in bookmarks - for (int i = bookmarks_addr.size() - 1; i>= 0; i--) - { - if (i != selectedItem && bookmarks_addr[i] == bookmarks_addr[selectedItem] && bookmarks_name[i].size()) - { - strcpy(bookmarkDescription, bookmarks_name[i].c_str()); - break; - } - } - } - // Show the bookmark name dialog - if (DialogBox(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB)) - { - // Rename the selected bookmark - bookmarks_name[selectedItem] = bookmarkDescription; - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_DELETESTRING, selectedItem, 0); - char buffer[256]; - sprintf(buffer, "%04X %s", bookmarks_addr[selectedItem], bookmarks_name[selectedItem].c_str()); - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_INSERTSTRING, selectedItem, (LPARAM)buffer); - // Reselect the item (selection disappeared when it was deleted) - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_SETCURSEL, selectedItem, 0); - } - } -} - -void DeleteAllDebuggerBookmarks() -{ - bookmarks_addr.resize(0); - bookmarks_name.resize(0); -} - -void FillDebuggerBookmarkListbox(HWND hwnd) -{ - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_RESETCONTENT, 0, 0); - char buffer[256]; - for (unsigned int i = 0; i < bookmarks_addr.size(); ++i) - { - sprintf(buffer, "%04X %s", bookmarks_addr[i], bookmarks_name[i].c_str()); - SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer); - } -} - -/** -* Shows the code at the bookmark address in the disassembly window -* -* @param hwnd HWND of the debugger window -**/ -void GoToDebuggerBookmark(HWND hwnd) -{ - int selectedItem = SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETCURSEL, 0, 0); - // If no bookmark is selected just return - if (selectedItem == LB_ERR) return; - unsigned int n = getBookmarkAddress(selectedItem); - Disassemble(hwnd, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, n); -} - -BOOL CALLBACK SymbolicNamingCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - { - CenterWindow(hwndDlg); - unsigned int newAddress = lParam; - // filename - generateNLFilenameForAddress(newAddress); - SetDlgItemText(hwndDlg, IDC_SYMBOLIC_FILENAME, NLfilename); - // offset - sprintf(temp_chr, "$%04X", newAddress); - SetDlgItemText(hwndDlg, IDC_SYMBOLIC_ADDRESS, temp_chr); - Name* node = findNode(getNamesPointerForAddress(newAddress), newAddress); - if (node) - { - SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_NAME, EM_SETLIMITTEXT, NL_MAX_NAME_LEN, 0); - if (node->name && node->name[0]) - SetDlgItemText(hwndDlg, IDC_SYMBOLIC_NAME, node->name); - SendDlgItemMessage(hwndDlg, IDC_SYMBOLIC_COMMENT, EM_SETLIMITTEXT, NL_MAX_MULTILINE_COMMENT_LEN, 0); - if (node->comment && node->comment[0]) - SetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, node->comment); - } - // set focus to IDC_SYMBOLIC_NAME - SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwndDlg, IDC_SYMBOLIC_NAME), true); - break; - } - case WM_CLOSE: - case WM_QUIT: - break; - case WM_COMMAND: - { - switch(HIWORD(wParam)) - { - case BN_CLICKED: - { - switch(LOWORD(wParam)) - { - case IDOK: - { - unsigned int newAddress = 0; - char newOffset[6] = {0}; - GetDlgItemText(hwndDlg, IDC_SYMBOLIC_ADDRESS, newOffset, 6); - if (sscanf(newOffset, "%*[$]%4X", &newAddress) != EOF) - { - char newName[NL_MAX_NAME_LEN + 1] = {0}; - GetDlgItemText(hwndDlg, IDC_SYMBOLIC_NAME, newName, NL_MAX_NAME_LEN + 1); - char newComment[NL_MAX_MULTILINE_COMMENT_LEN + 1] = {0}; - GetDlgItemText(hwndDlg, IDC_SYMBOLIC_COMMENT, newComment, NL_MAX_MULTILINE_COMMENT_LEN + 1); - - AddNewSymbolicName(newAddress, newOffset, newName, newComment); - WriteNameFileToDisk(generateNLFilenameForAddress(newAddress), getNamesPointerForAddress(newAddress)); - } - EndDialog(hwndDlg, 1); - break; - } - case IDCANCEL: - { - EndDialog(hwndDlg, 0); - break; - } - } - break; - } - } - break; - } - } - return FALSE; -} - -// returns true if user pressed OK, false if Cancel -bool DoSymbolicDebugNaming(int offset, HWND parentHWND) -{ - if (!FCEUI_EmulationPaused()) - FCEUI_ToggleEmulationPause(); - loadNameFiles(); - if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_SYMBOLIC_DEBUG_NAMING), parentHWND, SymbolicNamingCallB, offset)) - return true; - return false; -} - -void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment) -{ - Name* initialNode = getNamesPointerForAddress(newAddress); - Name* node = initialNode; - - // remove all delimiterChars from name and comment - char* pos = newName; - while (pos < newName + strlen(newName)) - { - pos = strstr(pos, delimiterChar); - if (pos) - strcpy(pos, pos + 1); - else - break; - } - pos = newComment; - while (pos < newComment + strlen(newComment)) - { - pos = strstr(pos, delimiterChar); - if (pos) - strcpy(pos, pos + 1); - else - break; - } - - if (*newName) - { - if (!initialNode) - { - // no previous data, create new list - node = (Name*)malloc(sizeof(Name)); - node->offset = (char*)malloc(strlen(newOffset) + 1); - strcpy(node->offset, newOffset); - node->offsetNumeric = newAddress; - node->name = (char*)malloc(strlen(newName) + 1); - strcpy(node->name, newName); - if (strlen(newComment)) - { - node->comment = (char*)malloc(strlen(newComment) + 1); - strcpy(node->comment, newComment); - } else - { - node->comment = 0; - } - node->next = 0; - setNamesPointerForAddress(newAddress, node); - } else - { - // search the list - while (node) - { - if (node->offsetNumeric == newAddress) - { - // found matching address - replace its name and comment - if (node->name) - free(node->name); - node->name = (char*)malloc(strlen(newName) + 1); - strcpy(node->name, newName); - if (node->comment) - { - free(node->comment); - node->comment = 0; - } - if (strlen(newComment)) - { - node->comment = (char*)malloc(strlen(newComment) + 1); - strcpy(node->comment, newComment); - } - break; - } - if (node->next) - { - node = node->next; - } else - { - // this is the last node in the list - so just append the address - Name* newNode = (Name*)malloc(sizeof(Name)); - node->next = newNode; - newNode->offset = (char*)malloc(strlen(newOffset) + 1); - strcpy(newNode->offset, newOffset); - newNode->offsetNumeric = newAddress; - newNode->name = (char*)malloc(strlen(newName) + 1); - strcpy(newNode->name, newName); - if (strlen(newComment)) - { - newNode->comment = (char*)malloc(strlen(newComment) + 1); - strcpy(newNode->comment, newComment); - } else - { - newNode->comment = 0; - } - newNode->next = 0; - break; - } - } - } - } else - { - // name field is empty - remove the address from the list - Name* previousNode = 0; - while (node) - { - if (node->offsetNumeric == newAddress) - { - // found matching address - delete it - if (node->offset) - free(node->offset); - if (node->name) - free(node->name); - if (node->comment) - free(node->comment); - if (previousNode) - previousNode->next = node->next; - if (node == initialNode) - setNamesPointerForAddress(newAddress, node->next); - free(node); - break; - } - previousNode = node; - node = node->next; - } - } -} - -void WriteNameFileToDisk(const char* filename, Name* node) -{ - FILE* f = fopen(filename, "wb"); - char tempComment[NL_MAX_MULTILINE_COMMENT_LEN + 10]; - if (f) - { - char tempString[10 + 1 + NL_MAX_NAME_LEN + 1 + NL_MAX_MULTILINE_COMMENT_LEN + 1]; - while (node) - { - strcpy(tempString, node->offset); - strcat(tempString, delimiterChar); - if (node->name) - strcat(tempString, node->name); - strcat(tempString, delimiterChar); - if (node->comment) - { - // dump multiline comment - strcpy(tempComment, node->comment); - char* remainder_pos = tempComment; - char* crlf_pos = strstr(tempComment, "\r\n"); - while (crlf_pos) - { - *crlf_pos = 0; - strcat(tempString, remainder_pos); - strcat(tempString, "\r\n\\"); - crlf_pos = remainder_pos = crlf_pos + 2; - crlf_pos = strstr(crlf_pos, "\r\n"); - } - strcat(tempString, remainder_pos); - strcat(tempString, "\r\n"); - } else - { - strcat(tempString, "\r\n"); - } - // write to the file - fwrite(tempString, 1, strlen(tempString), f); - node = node->next; - } - fclose(f); - } -} - - diff --git a/branches/fceux-2.2.2/src/drivers/win/debuggersp.h b/branches/fceux-2.2.2/src/drivers/win/debuggersp.h deleted file mode 100644 index 46b1732e..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/debuggersp.h +++ /dev/null @@ -1,63 +0,0 @@ -/* FCEUXD SP - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 Sebastian Porst - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#define NL_MAX_NAME_LEN 30 -#define NL_MAX_MULTILINE_COMMENT_LEN 1000 - -//mbg merge 7/17/06 made struct sane c++ -struct Name -{ - Name* next; - uint16 offsetNumeric; - char* offset; - char* name; - char* comment; -}; - -extern bool symbDebugEnabled; -extern std::vector bookmarks_addr; -extern std::vector bookmarks_name; -extern int debuggerWasActive; - -int checkCondition(const char* buffer, int num); - -Name* findNode(Name* node, const char* offset); -Name* findNode(Name* node, uint16 offsetNumeric); - -char* generateNLFilenameForAddress(uint16 address); -Name* getNamesPointerForAddress(uint16 address); -void setNamesPointerForAddress(uint16 address, Name* newNode); -void loadNameFiles(); -void replaceNames(Name* list, char* str, std::vector* addressesLog = 0); -void AddDebuggerBookmark(HWND hwnd); -void AddDebuggerBookmark2(HWND hwnd, unsigned int addr); -void DeleteDebuggerBookmark(HWND hwnd); -void NameDebuggerBookmark(HWND hwnd); -void DeleteAllDebuggerBookmarks(); -void FillDebuggerBookmarkListbox(HWND hwnd); - -void GoToDebuggerBookmark(HWND hwnd); -int isHex(char c); - -bool DoSymbolicDebugNaming(int offset, HWND parentHWND); -void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newComment); -void WriteNameFileToDisk(const char* filename, Name* node); diff --git a/branches/fceux-2.2.2/src/drivers/win/guiconfig.cpp b/branches/fceux-2.2.2/src/drivers/win/guiconfig.cpp deleted file mode 100644 index 2fc1b1ac..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/guiconfig.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include "common.h" -#include "main.h" -#include "gui.h" - -extern bool rightClickEnabled; //Declared in window.cpp and only an extern here -extern bool fullscreenByDoubleclick; -extern bool SingleInstanceOnly; -char ManifestFilePath[2048]; - -bool ManifestFileExists() -{ - long endPos = 0; - - FILE * stream = fopen( ManifestFilePath, "r" ); - if (stream) { - fseek( stream, 0L, SEEK_END ); - endPos = ftell( stream ); - fclose( stream ); - } - - return (endPos > 0); -} - -/** -* Processes information from the GUI options dialog after -* the dialog was closed. -* -* @param hwndDlg Handle of the dialog window. -**/ -void CloseGuiDialog(HWND hwndDlg) -{ - if(IsDlgButtonChecked(hwndDlg, CB_LOAD_FILE_OPEN) == BST_CHECKED) - { - eoptions |= EO_FOAFTERSTART; - } - else - { - eoptions &= ~EO_FOAFTERSTART; - } - - if(IsDlgButtonChecked(hwndDlg, CB_AUTO_HIDE_MENU) == BST_CHECKED) - { - eoptions |= EO_HIDEMENU; - } - else - { - eoptions &= ~EO_HIDEMENU; - } - - goptions &= ~(GOO_CONFIRMEXIT | GOO_DISABLESS); - - if(IsDlgButtonChecked(hwndDlg, CB_ASK_EXIT)==BST_CHECKED) - { - goptions |= GOO_CONFIRMEXIT; - } - - if(IsDlgButtonChecked(hwndDlg, CB_DISABLE_SCREEN_SAVER)==BST_CHECKED) - { - goptions |= GOO_DISABLESS; - } - - if(IsDlgButtonChecked(hwndDlg, CB_ENABLECONTEXTMENU)==BST_CHECKED) - rightClickEnabled = true; - else - rightClickEnabled = false; - - if(IsDlgButtonChecked(hwndDlg, CB_FS_BY_DOUBLECLICK)==BST_CHECKED) - fullscreenByDoubleclick = true; - else - fullscreenByDoubleclick = false; - - if(IsDlgButtonChecked(hwndDlg, IDC_SINGLEINSTANCE)==BST_CHECKED) - SingleInstanceOnly = true; - else - SingleInstanceOnly = false; - - if(IsDlgButtonChecked(hwndDlg, CB_PARTIALVISUALTHEME)==BST_CHECKED) - { - FILE * stream = fopen( ManifestFilePath, "w" ); - if (stream) { - fputs ("<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"\?>\n\n\nFCEUX\n\n",stream); - fclose(stream); - } - } - - else - { - remove(ManifestFilePath); - } - - - EndDialog(hwndDlg,0); -} - -/** -* Message loop of the GUI configuration dialog. -**/ -BOOL CALLBACK GUIConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - - if(eoptions & EO_FOAFTERSTART) - { - CheckDlgButton(hwndDlg, CB_LOAD_FILE_OPEN, BST_CHECKED); - } - - if(eoptions&EO_HIDEMENU) - { - CheckDlgButton(hwndDlg, CB_AUTO_HIDE_MENU, BST_CHECKED); - } - - if(goptions & GOO_CONFIRMEXIT) - { - CheckDlgButton(hwndDlg, CB_ASK_EXIT, BST_CHECKED); - } - - if(goptions & GOO_DISABLESS) - { - CheckDlgButton(hwndDlg, CB_DISABLE_SCREEN_SAVER, BST_CHECKED); - } - - if(rightClickEnabled) - CheckDlgButton(hwndDlg, CB_ENABLECONTEXTMENU, BST_CHECKED); - - if(fullscreenByDoubleclick) - CheckDlgButton(hwndDlg, CB_FS_BY_DOUBLECLICK, BST_CHECKED); - - GetModuleFileName(0, ManifestFilePath, 2048); - - strcat((char*)ManifestFilePath,".manifest"); - - if(ManifestFileExists()) { - CheckDlgButton(hwndDlg, CB_PARTIALVISUALTHEME, BST_CHECKED); - } - - if(SingleInstanceOnly){ - CheckDlgButton(hwndDlg, IDC_SINGLEINSTANCE, BST_CHECKED); - } - - CenterWindowOnScreen(hwndDlg); - - break; - - case WM_CLOSE: - case WM_QUIT: - CloseGuiDialog(hwndDlg); - - case WM_COMMAND: - if(!(wParam >> 16)) - { - switch(wParam & 0xFFFF) - { - case BUTTON_CLOSE: - CloseGuiDialog(hwndDlg); - } - } - } - - return 0; -} - -/** -* Shows the GUI configuration dialog. -**/ -void ConfigGUI() -{ - DialogBox(fceu_hInstance, "GUICONFIG", hAppWnd, GUIConCallB); -} \ No newline at end of file diff --git a/branches/fceux-2.2.2/src/drivers/win/input.cpp b/branches/fceux-2.2.2/src/drivers/win/input.cpp deleted file mode 100644 index 420d01aa..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/input.cpp +++ /dev/null @@ -1,1742 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -// For commctrl.h below -#define _WIN32_IE 0x0550 - -#include "../../version.h" - -#include "common.h" -#include "dinput.h" -#include -#include - -#include "input.h" -#include "keyboard.h" -#include "joystick.h" -#include "gui.h" -#include "fceu.h" -#include "movie.h" -#include "window.h" -#include "sound.h" -#include "keyscan.h" - -LPDIRECTINPUT7 lpDI=0; - -void InitInputPorts(bool fourscore); - -int tempwinsync = 0; //Temp variable used by turbo to turn of sync settings -int tempsoundquality = 0; //Temp variable used by turbo to turn of sound quality settings -extern int winsync; -extern int soundquality; -extern bool replaceP2StartWithMicrophone; -//UsrInputType[] is user-specified. InputType[] is current -// (game/savestate/movie loading can override user settings) - -//int UsrInputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE}; -int InputType[3]={SI_GAMEPAD,SI_NONE,SIFC_NONE}; - -int InitDInput(void) -{ - HRESULT ddrval; - - ddrval=DirectInputCreateEx(fceu_hInstance,DIRECTINPUT_VERSION,IID_IDirectInput7,(LPVOID *)&lpDI,0); - if(ddrval!=DI_OK) - { - FCEUD_PrintError("DirectInput: Error creating DirectInput object."); - return 0; - } - return 1; -} -static void PresetExport(int preset); -static void PresetImport(int preset); - -static uint32 MouseData[3]; - -//force the input types suggested by the game -void ParseGIInput(FCEUGI *gi) -{ - if(gi) - { - if(gi->input[0]!=SI_UNSET) - InputType[0]=gi->input[0]; - if(gi->input[1]!=SI_UNSET) - InputType[1]=gi->input[1]; - if(gi->inputfc!=SIFC_UNSET) - InputType[2]=gi->inputfc; - - InitInputPorts((eoptions & EO_FOURSCORE)!=0); - } -} - - -static uint8 QuizKingData=0; -static uint8 HyperShotData=0; -static uint32 MahjongData=0; -static uint32 FTrainerData=0; -static uint8 TopRiderData=0; - -static uint8 BWorldData[1+13+1]; - -static void UpdateFKB(void); -static void UpdateSuborKB(void); -void UpdateGamepad(void); -static void UpdateQuizKing(void); -static void UpdateHyperShot(void); -static void UpdateMahjong(void); -static void UpdateFTrainer(void); -static void UpdateTopRider(void); - -static uint32 JSreturn=0; -int NoWaiting=0; -bool turbo = false; - -#include "keyscan.h" -static unsigned int *keys=0; -static unsigned int *keys_nr=0; -static int DIPS=0; - -//#define KEY(__a) keys_nr[MKK(__a)] - -int cidisabled=0; -int allowUDLR=0; - -#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1} -#define MC(x) {{BUTTC_KEYBOARD},{0},{x},1} -#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2} - -#define MKZ() {{0},{0},{0},0} - -#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()} - -ButtConfig GamePadConfig[4][10]={ - //Gamepad 1 - { - MK(F), MK(D), MK(S), MK(ENTER), MK(BL_CURSORUP), - MK(BL_CURSORDOWN),MK(BL_CURSORLEFT),MK(BL_CURSORRIGHT) - }, - - //Gamepad 2 - GPZ(), - - //Gamepad 3 - GPZ(), - - //Gamepad 4 - GPZ() -}; - -ButtConfig GamePadPreset1[4][10]={GPZ(),GPZ(),GPZ(),GPZ()}; -ButtConfig GamePadPreset2[4][10]={GPZ(),GPZ(),GPZ(),GPZ()}; -ButtConfig GamePadPreset3[4][10]={GPZ(),GPZ(),GPZ(),GPZ()}; -char *InputPresetDir = 0; - -extern int rapidAlternator; // for auto-fire / autofire -int DesynchAutoFire=0; // A and B not at same time -uint32 JSAutoHeld=0, JSAutoHeldAffected=0; // for auto-hold -uint8 autoHoldOn=0, autoHoldReset=0, autoHoldRefire=0; // for auto-hold - -void SetAutoFireDesynch(int DesynchOn) -{ - if(DesynchOn) - { - DesynchAutoFire = 1; - } - else - { - DesynchAutoFire = 0; - } -} - -int GetAutoFireDesynch() -{ - return DesynchAutoFire; -} - -// Test button state using current keyboard data. -// Clone of DTestButton, but uses local variables. -int DTestButtonImmediate(ButtConfig *bc) -{ - uint32 x;//mbg merge 7/17/06 changed to uint - - static unsigned int *keys_im=GetKeyboard_nr(); - - for(x=0;xNumC;x++) - { - if(bc->ButtType[x]==BUTTC_KEYBOARD) - { - if(keys_im[bc->ButtonNum[x]]) - { - return(1); - } - } - } - if(DTestButtonJoy(bc)) return(1); // Needs joystick.h. Tested with PPJoy mapped with Print Screen - return(0); -} - -uint32 GetGamepadPressedImmediate() -{ - // Get selected joypad buttons, ignoring NES polling - // Basically checks for immediate gamepad input. - //extern ButtConfig GamePadConfig[4][10]; - //extern int allowUDLR; - - uint32 JSButtons=0; - int x; - int wg; - - for(wg=0;wg<4;wg++) - { - - for(x=0;x<8;x++) - if(DTestButtonImmediate(&GamePadConfig[wg][x])) - JSButtons|=(1<NumC;x++) - { - if(bc->ButtType[x]==BUTTC_KEYBOARD) - { - if(keys_nr[bc->ButtonNum[x]]) - { - return(1); - } - } - } - if(DTestButtonJoy(bc)) return(1); - return(0); -} - -void UpdateGamepad() -{ - if(FCEUMOV_Mode(MOVIEMODE_PLAY)) - return; - - uint32 JS=0; - int x; - int wg; - if(FCEUMOV_Mode(MOVIEMODE_RECORD)) - AutoFire(); - - for(wg=0;wg<4;wg++) - { - for(x=0;x<8;x++) - if(DTestButton(&GamePadConfig[wg][x])) - JS|=(1<':' ', (c&0x20)?'v':' ', - (c&0x01)?'A':' ', (c&0x02)?'B':' ', (c&0x08)?'S':' ', (c&0x04)?'s':' ', - (c&0x4000)?'<':' ', (c&0x1000)?'^':' ', (c&0x8000)?'>':' ', (c&0x2000)?'v':' ', - (c&0x0100)?'A':' ', (c&0x0200)?'B':' ', (c&0x0800)?'S':' ', (c&0x0400)?'s':' ', - (c&0x400000)?'<':' ', (c&0x100000)?'^':' ', (c&0x800000)?'>':' ', (c&0x200000)?'v':' ', - (c&0x010000)?'A':' ', (c&0x020000)?'B':' ', (c&0x080000)?'S':' ', (c&0x040000)?'s':' ', - (c&0x40000000)?'<':' ', (c&0x10000000)?'^':' ', (c&0x80000000)?'>':' ', (c&0x20000000)?'v':' ', - (c&0x01000000)?'A':' ', (c&0x02000000)?'B':' ', (c&0x08000000)?'S':' ', (c&0x04000000)?'s':' '); - if(!(c&0xffffff00)) { - inputstr[9] = '\0'; - disppos = 30; - } - else if(!(c&0xffff0000)) { - inputstr[19] = '\0'; - disppos = 30; - } - else if(!(c&0xff000000)) { - inputstr[30] = '\0'; - } - } - FCEU_DispMessage("Held:\n%s", disppos, inputstr); - } - else - { - JSAutoHeldAffected = 0; - autoHoldRefire = 0; - } - - if(autoHoldReset) - { - FCEU_DispMessage("Held: ",30); - JSAutoHeld = 0; - JSAutoHeldAffected = 0; - autoHoldRefire = 0; - } - - // apply auto-hold - if(JSAutoHeld) - JS ^= JSAutoHeld; - - JSreturn=JS; -} - -ButtConfig powerpadsc[2][12]={ - { - MK(O),MK(P),MK(BRACKET_LEFT), - MK(BRACKET_RIGHT), - - MK(K),MK(L),MK(SEMICOLON), - MK(APOSTROPHE), - MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) - }, - { - MK(O),MK(P),MK(BRACKET_LEFT), - MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON), - MK(APOSTROPHE), - MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) - } -}; - -static uint32 powerpadbuf[2]; - -static uint32 UpdatePPadData(int w) -{ - uint32 r=0; - ButtConfig *ppadtsc=powerpadsc[w]; - int x; - - for(x=0;x<12;x++) - if(DTestButton(&ppadtsc[x])) r|=1<NumC;x++) - { - if(x) strcat(tmpstr, ", "); - - if(bc->ButtType[x] == BUTTC_KEYBOARD) - { - strcat(tmpstr,"KB: "); - if(!GetKeyNameText(((bc->ButtonNum[x] & 0x7F) << 16) | ((bc->ButtonNum[x] & 0x80) << 17), tmpstr+strlen(tmpstr), 16)) - { - // GetKeyNameText wasn't able to provide a name for the key, then just show scancode - sprintf(tmpstr+strlen(tmpstr),"%03d",bc->ButtonNum[x]); - } - } - else if(bc->ButtType[x] == BUTTC_JOYSTICK) - { - strcat(tmpstr,"JS "); - sprintf(tmpstr+strlen(tmpstr), "%d ", bc->DeviceNum[x]); - if(bc->ButtonNum[x] & 0x8000) - { - char *asel[3]={"x","y","z"}; - sprintf(tmpstr+strlen(tmpstr), "axis %s%s", asel[bc->ButtonNum[x] & 3],(bc->ButtonNum[x]&0x4000)?"-":"+"); - } - else if(bc->ButtonNum[x] & 0x2000) - { - sprintf(tmpstr+strlen(tmpstr), "hat %d:%d", (bc->ButtonNum[x] >> 4)&3, - bc->ButtonNum[x]&3); - } - else - { - sprintf(tmpstr+strlen(tmpstr), "button %d", bc->ButtonNum[x] & 127); - } - - } - } - - astr=(char*)malloc(strlen(tmpstr) + 1); //mbg merge 7/17/06 added cast - strcpy(astr,tmpstr); - return(astr); -} - - -static int DWBStarted; -static ButtConfig *DWBButtons; -static const uint8 *DWBText; - -static HWND die; - -static BOOL CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - - switch(uMsg) { - case WM_DESTROY: - die = NULL; - return(0); - case WM_TIMER: - { - uint8 devicenum; - uint16 buttonnum; - GUID guid; - - if(DoJoyWaitTest(&guid, &devicenum, &buttonnum)) - { - ButtConfig *bc = DWBButtons; - char *nstr; - int wc; - if(DWBStarted) - { - ButtConfig *bc = DWBButtons; - bc->NumC = 0; - DWBStarted = 0; - } - wc = bc->NumC; - //FCEU_printf("%d: %d\n",devicenum,buttonnum); - bc->ButtType[wc]=BUTTC_JOYSTICK; - bc->DeviceNum[wc]=devicenum; - bc->ButtonNum[wc]=buttonnum; - bc->DeviceInstance[wc] = guid; - - /* Stop config if the user pushes the same button twice in a row. */ - if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && - bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) - goto gornk; - - bc->NumC++; - - /* Stop config if we reached our maximum button limit. */ - if(bc->NumC >= MAXBUTTCONFIG) - goto gornk; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - } - break; - case WM_USER + 666: - //SetFocus(GetDlgItem(hwndDlg,LBL_DWBDIALOG_TEXT)); - if(DWBStarted) - { - char *nstr; - ButtConfig *bc = DWBButtons; - bc->NumC = 0; - DWBStarted = 0; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - - { - ButtConfig *bc = DWBButtons; - int wc = bc->NumC; - char *nstr; - - bc->ButtType[wc]=BUTTC_KEYBOARD; - bc->DeviceNum[wc]=0; - bc->ButtonNum[wc]=lParam&255; - - //Stop config if the user pushes the same button twice in a row. - if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && - bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) - goto gornk; - - bc->NumC++; - //Stop config if we reached our maximum button limit. - if(bc->NumC >= MAXBUTTCONFIG) - goto gornk; - - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - break; - case WM_INITDIALOG: - SetWindowText(hwndDlg, (char*)DWBText); //mbg merge 7/17/06 added cast - BeginJoyWait(hwndDlg); - SetTimer(hwndDlg,666,25,0); //Every 25ms. - { - char *nstr = MakeButtString(DWBButtons); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - - - - break; - case WM_CLOSE: - case WM_QUIT: goto gornk; - - case WM_COMMAND: - switch(wParam&0xFFFF) - { - case BTN_CLEAR: - { - ButtConfig *bc = DWBButtons; - char *nstr; - bc->NumC = 0; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - break; - case BTN_CLOSE: -gornk: - KillTimer(hwndDlg,666); - EndJoyWait(hAppWnd); - SetForegroundWindow(GetParent(hwndDlg)); - DestroyWindow(hwndDlg); - break; - } - } - return 0; -} - -int DWaitButton(HWND hParent, const uint8 *text, ButtConfig *bc) -{ - DWBText=text; - DWBButtons = bc; - DWBStarted = 1; - - die = CreateDialog(fceu_hInstance, "DWBDIALOG", hParent, DWBCallB); - - EnableWindow(hParent, 0); - - ShowWindow(die, 1); - - while(die) - { - MSG msg; - while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) - { - if(GetMessage(&msg, 0, 0, 0) > 0) - { - if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) - { - LPARAM tmpo; - - tmpo = ((msg.lParam >> 16) & 0x7F) | ((msg.lParam >> 17) & 0x80); - PostMessage(die,WM_USER+666,0,tmpo); - continue; - } - if(msg.message == WM_SYSCOMMAND) continue; - if(!IsDialogMessage(die, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - Sleep(10); - } - - EnableWindow(hParent, 1); - return 0; //mbg merge TODO 7/17/06 - had to add this return value--is it right? -} - -int DWaitSimpleButton(HWND hParent, const uint8 *text) -{ - DWBStarted = 1; - int ret = 0; - - die = CreateDialog(fceu_hInstance, "DWBDIALOGSIMPLE", hParent, NULL); - SetWindowText(die, (char*)text); //mbg merge 7/17/06 added cast - EnableWindow(hParent, 0); - - ShowWindow(die, 1); - - while(die) - { - MSG msg; - while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) - { - if(GetMessage(&msg, 0, 0, 0) > 0) - { - if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) - { - LPARAM tmpo; - - tmpo=((msg.lParam>>16)&0x7F)|((msg.lParam>>17)&0x80); - ret = tmpo; - goto done; - } - if(msg.message == WM_SYSCOMMAND) continue; - if(!IsDialogMessage(die, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - Sleep(10); - } -done: - EndDialog(die,0); - EnableWindow(hParent, 1); - - if(ret == 1) // convert Esc to nothing (why is it 1 and not VK_ESCAPE?) - ret = 0; - return ret; -} - - -static ButtConfig *DoTBButtons=0; -static const char *DoTBTitle=0; -static int DoTBMax=0; -static int DoTBType=0,DoTBPort=0; - -static BOOL CALLBACK DoTBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) { - case WM_INITDIALOG: - if(DoTBType == SI_GAMEPAD) - { - char buf[32]; - sprintf(buf,"Virtual Gamepad %d",DoTBPort+1); - SetDlgItemText(hwndDlg, GRP_GAMEPAD1,buf); - - sprintf(buf,"Virtual Gamepad %d",DoTBPort+3); - SetDlgItemText(hwndDlg, GRP_GAMEPAD2, buf); - } - SetWindowText(hwndDlg, DoTBTitle); - break; - case WM_CLOSE: - case WM_QUIT: goto gornk; - - case WM_COMMAND: - { - int b; - b=wParam&0xFFFF; - if(b>= 300 && b < (300 + DoTBMax)) - { - char btext[128]; - btext[0]=0; - GetDlgItemText(hwndDlg, b, btext, 128); - DWaitButton(hwndDlg, (uint8*)btext,&DoTBButtons[b - 300]); //mbg merge 7/17/06 added cast - } - else switch(wParam&0xFFFF) - { - case BTN_CLOSE: -gornk: - - EndDialog(hwndDlg,0); - break; - } - } - } - return 0; -} - -static void DoTBConfig(HWND hParent, const char *text, char *_template, ButtConfig *buttons, int max) -{ - DoTBTitle=text; - DoTBButtons = buttons; - DoTBMax = max; - DialogBox(fceu_hInstance,_template,hParent,DoTBCallB); -} - - -const unsigned int NUMBER_OF_PORTS = 2; -const unsigned int NUMBER_OF_NES_DEVICES = SI_COUNT + 1; -const static unsigned int NUMBER_OF_FAMICOM_DEVICES = SIFC_COUNT + 1; -//these are unfortunate lists. they match the ESI and ESIFC enums -static const int configurable_nes[NUMBER_OF_NES_DEVICES]= { 0, 1, 0, 1, 1, 0 }; -static const int configurable_fam[NUMBER_OF_FAMICOM_DEVICES]= { 0,0,0,0, 1,1,0,1, 1,1,1,0, 0,0 }; -const unsigned int FAMICOM_POSITION = 2; - -static void UpdateComboPad(HWND hwndDlg, WORD id) -{ - unsigned int sel_input = id - COMBO_PAD1; - - // Update the user input type - InputType[sel_input] = - SendDlgItemMessage( - hwndDlg, - id, - CB_GETCURSEL, - 0, - (LPARAM)(LPSTR)0 - ); - - // Enable or disable the configuration button - EnableWindow( - GetDlgItem(hwndDlg, id + 2), - configurable_nes[InputType[sel_input]] - ); - - // Update the text field - SetDlgItemText( - hwndDlg, - TXT_PAD1 + sel_input, - (LPTSTR)ESI_Name((ESI)InputType[sel_input]) - ); -} - -static void UpdateComboFam(HWND hwndDlg) -{ -// Update the user input type of the famicom - InputType[FAMICOM_POSITION] = - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, - CB_GETCURSEL, - 0, - (LPARAM)(LPSTR)0 - ); - - // Enable or disable the configuration button - EnableWindow( - GetDlgItem(hwndDlg, BTN_FAM), - configurable_fam[InputType[FAMICOM_POSITION]] - ); - - // Update the text field - SetDlgItemText( - hwndDlg, - TXT_FAM, - (LPTSTR)ESIFC_Name((ESIFC)InputType[FAMICOM_POSITION]) - ); -} - - -static void UpdateFourscoreState(HWND dlg) -{ - //(inverse logic:) - BOOL enable = (eoptions & EO_FOURSCORE)?FALSE:TRUE; - - EnableWindow(GetDlgItem(dlg,BTN_PORT1),enable); - EnableWindow(GetDlgItem(dlg,BTN_PORT2),enable); - EnableWindow(GetDlgItem(dlg,COMBO_PAD1),enable); - EnableWindow(GetDlgItem(dlg,COMBO_PAD2),enable); - EnableWindow(GetDlgItem(dlg,TXT_PAD1),enable); - EnableWindow(GetDlgItem(dlg,TXT_PAD2),enable); - - //change the inputs to gamepad - if(!enable) - { - SendMessage(GetDlgItem(dlg,COMBO_PAD1),CB_SETCURSEL,SI_GAMEPAD,0); - SendMessage(GetDlgItem(dlg,COMBO_PAD2),CB_SETCURSEL,SI_GAMEPAD,0); - UpdateComboPad(dlg,COMBO_PAD1); - UpdateComboPad(dlg,COMBO_PAD2); - SetDlgItemText(dlg,TXT_PAD1,ESI_Name(SI_GAMEPAD)); - SetDlgItemText(dlg,TXT_PAD2,ESI_Name(SI_GAMEPAD)); - } -} - -//Callback function of the input configuration dialog. -BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - // Update the disable UDLR checkbox based on the current value - CheckDlgButton(hwndDlg,BTN_ALLOW_LRUD,allowUDLR?BST_CHECKED:BST_UNCHECKED); - - //update the fourscore checkbox - CheckDlgButton(hwndDlg,CHECK_ENABLE_FOURSCORE,(eoptions & EO_FOURSCORE)?BST_CHECKED:BST_UNCHECKED); - - //update the microphone checkbox - CheckDlgButton(hwndDlg,CHECK_ENABLE_MICROPHONE,replaceP2StartWithMicrophone?BST_CHECKED:BST_UNCHECKED); - - // Initialize the controls for the input ports - for(unsigned int port = 0; port < NUMBER_OF_PORTS; port++) - { - // Initialize the combobox - for(unsigned int current_device = 0; current_device < NUMBER_OF_NES_DEVICES; current_device++) - { - SendDlgItemMessage(hwndDlg, - COMBO_PAD1 + port, - CB_ADDSTRING, 0, - (LPARAM)(LPSTR)ESI_Name((ESI)current_device) - ); - } - - // Fix to deal with corrupted config. - if (InputType[port]>SI_COUNT || InputType[port]<0) - InputType[port]=SI_UNSET; - - // Update the combobox selection according to the - // currently selected input mode. - SendDlgItemMessage(hwndDlg, - COMBO_PAD1 + port, - CB_SETCURSEL, - InputType[port], - (LPARAM)(LPSTR)0 - ); - - // Enable the configuration button if necessary. - EnableWindow( - GetDlgItem(hwndDlg, BTN_PORT1 + port), - configurable_nes[InputType[port]] - ); - - // Update the label that displays the input device. - SetDlgItemText( - hwndDlg, - TXT_PAD1 + port, - (LPTSTR)ESI_Name((ESI)InputType[port]) - ); - } - - // Initialize the Famicom combobox - for(unsigned current_device = 0; current_device < NUMBER_OF_FAMICOM_DEVICES; current_device++) - { - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, - CB_ADDSTRING, - 0, - (LPARAM)(LPSTR)ESIFC_Name((ESIFC)current_device) - ); - } - - if (InputType[FAMICOM_POSITION]>SIFC_COUNT || InputType[FAMICOM_POSITION]<0) - InputType[FAMICOM_POSITION]=SIFC_UNSET; - - // Update the combobox selection according to the - // currently selected input mode. - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, - CB_SETCURSEL, - InputType[FAMICOM_POSITION], - (LPARAM)(LPSTR)0 - ); - - // Enable the configuration button if necessary. - EnableWindow( - GetDlgItem(hwndDlg, BTN_FAM), - configurable_fam[InputType[FAMICOM_POSITION]] - ); - - // Update the label that displays the input device. - SetDlgItemText( - hwndDlg, - TXT_FAM, - (LPTSTR)ESIFC_Name((ESIFC)InputType[FAMICOM_POSITION]) - ); - - // Initialize the auto key controls - extern int autoHoldKey, autoHoldClearKey; - char btext[128]; - if (autoHoldKey) - { - if (!GetKeyNameText(autoHoldKey << 16, btext, 128)) - sprintf(btext, "KB: %d", autoHoldKey); - } else - { - sprintf(btext, "not assigned"); - } - SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); - - if (autoHoldClearKey) - { - if (!GetKeyNameText(autoHoldClearKey << 16, btext, 128)) - sprintf(btext, "KB: %d", autoHoldClearKey); - } else - { - sprintf(btext, "not assigned"); - } - SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); - - CenterWindowOnScreen(hwndDlg); - UpdateFourscoreState(hwndDlg); - - if (!FCEUMOV_Mode(MOVIEMODE_INACTIVE)) - { - // disable changing fourscore and Input ports while a movie is recorded/played - EnableWindow(GetDlgItem(hwndDlg, CHECK_ENABLE_FOURSCORE), false); - EnableWindow(GetDlgItem(hwndDlg, CHECK_ENABLE_MICROPHONE), false); - EnableWindow(GetDlgItem(hwndDlg, COMBO_PAD1), false); - EnableWindow(GetDlgItem(hwndDlg, COMBO_PAD2), false); - EnableWindow(GetDlgItem(hwndDlg, COMBO_FAM), false); - } - - break; - - case WM_CLOSE: - case WM_QUIT: - EndDialog(hwndDlg, 0); - - case WM_COMMAND: - // Handle disable UD/LR option - if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == BTN_ALLOW_LRUD) - { - FCEU_printf("Allow UDLR toggled.\n"); - allowUDLR = !allowUDLR; - } - - //Handle the fourscore button - if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == CHECK_ENABLE_FOURSCORE) - { - eoptions ^= EO_FOURSCORE; - FCEU_printf("Fourscore toggled to %s\n",(eoptions & EO_FOURSCORE)?"ON":"OFF"); - UpdateFourscoreState(hwndDlg); - } - - //Handle the fourscore button - if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == CHECK_ENABLE_MICROPHONE) - { - replaceP2StartWithMicrophone = !replaceP2StartWithMicrophone; - FCEU_printf("Microphone toggled to %s\n",replaceP2StartWithMicrophone?"ON":"OFF"); - } - - - if(HIWORD(wParam) == CBN_SELENDOK) - { - switch(LOWORD(wParam)) - { - case COMBO_PAD1: - case COMBO_PAD2: - UpdateComboPad(hwndDlg, LOWORD(wParam)); - break; - - case COMBO_FAM: - UpdateComboFam(hwndDlg); - break; - } - - } - - if( !(wParam >> 16) ) - { - switch(wParam & 0xFFFF) - { - case BTN_FAM: - { - const char *text = ESIFC_Name((ESIFC)InputType[FAMICOM_POSITION]); - - DoTBType = DoTBPort = 0; - - switch(InputType[FAMICOM_POSITION]) - { - case SIFC_FTRAINERA: - case SIFC_FTRAINERB: - DoTBConfig(hwndDlg, text, "POWERPADDIALOG", FTrainerButtons, 12); - break; - case SIFC_FKB: - DoTBConfig(hwndDlg, text, "FKBDIALOG", fkbmap, 0x48); - break; - case SIFC_SUBORKB: - DoTBConfig(hwndDlg, text, "SUBORKBDIALOG", suborkbmap, 0x60); - break; - case SIFC_MAHJONG: - DoTBConfig(hwndDlg, text, "MAHJONGDIALOG", MahjongButtons, 21); - break; - case SIFC_QUIZKING: - DoTBConfig(hwndDlg, text, "QUIZKINGDIALOG", QuizKingButtons, 6); - break; - } - } - - break; - - case BTN_PORT2: - case BTN_PORT1: - { - int which = (wParam & 0xFFFF) - BTN_PORT1; - const char *text = ESI_Name((ESI)InputType[which]); - - DoTBType = DoTBPort = 0; - - switch(InputType[which]) - { - case SI_GAMEPAD: - { - ButtConfig tmp[10 + 10]; - - memcpy(tmp, GamePadConfig[which], 10 * sizeof(ButtConfig)); - memcpy(&tmp[10], GamePadConfig[which + 2], 10 * sizeof(ButtConfig)); - - DoTBType = SI_GAMEPAD; - DoTBPort = which; - DoTBConfig(hwndDlg, text, "GAMEPADDIALOG", tmp, 10 + 10); - - memcpy(GamePadConfig[which], tmp, 10 * sizeof(ButtConfig)); - memcpy(GamePadConfig[which + 2], &tmp[10], 10 * sizeof(ButtConfig)); - } - break; - - case SI_POWERPADA: - case SI_POWERPADB: - DoTBConfig(hwndDlg, text, "POWERPADDIALOG", powerpadsc[which], 12); - break; - } - } - - break; - - case BTN_PRESET_SET1: - MessageBox(0, "Current input configuration has been set as Preset 1.", FCEU_NAME, MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset1, GamePadConfig, sizeof(GamePadConfig)); - break; - case BTN_PRESET_SET2: - MessageBox(0, "Current input configuration has been set as Preset 2.", FCEU_NAME, MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset2, GamePadConfig, sizeof(GamePadConfig)); - break; - case BTN_PRESET_SET3: - MessageBox(0, "Current input configuration has been set as Preset 3.", FCEU_NAME, MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset3, GamePadConfig, sizeof(GamePadConfig)); - break; - - case BTN_PRESET_EXPORT1: PresetExport(1); break; - case BTN_PRESET_EXPORT2: PresetExport(2); break; - case BTN_PRESET_EXPORT3: PresetExport(3); break; - - case BTN_PRESET_IMPORT1: PresetImport(1); break; - case BTN_PRESET_IMPORT2: PresetImport(2); break; - case BTN_PRESET_IMPORT3: PresetImport(3); break; - - case BTN_AUTO_HOLD: // auto-hold button - { - char btext[128] = { 0 }; - - GetDlgItemText(hwndDlg, BTN_AUTO_HOLD, btext, sizeof(btext) ); - - int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 - - if(button) - { - if(!GetKeyNameText(button << 16, btext, 128)) - { - sprintf(btext, "KB: %d", button); - } - } - else - { - sprintf(btext, "not assigned"); - } - - extern int autoHoldKey; - autoHoldKey = button; - SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); - } - break; - - case BTN_CLEAR_AH: // auto-hold clear button - { - char btext[128] = { 0 }; - - GetDlgItemText(hwndDlg, BTN_CLEAR_AH, btext, 128); - - int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 added cast - - if(button) - { - if( !GetKeyNameText(button << 16, btext, sizeof(btext))) - { - sprintf(btext, "KB: %d", button); - } - } - else - { - sprintf(btext, "not assigned"); - } - - extern int autoHoldClearKey; - autoHoldClearKey = button; - - SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); - } - break; - - case BTN_CLOSE: - EndDialog(hwndDlg, 0); - break; - } - } - } - - return 0; -} - -//Shows the input configuration dialog. -void ConfigInput(HWND hParent) -{ - DialogBox(fceu_hInstance, "INPUTCONFIG", hParent, InputConCallB); - - //in case the input config changes while a game is running, reconfigure the input ports - if(GameInfo) - { - InitInputPorts((eoptions & EO_FOURSCORE)!=0); - } -} - -void DestroyInput(void) -{ - if(lpDI) - { - KillJoysticks(); - KeyboardClose(); - IDirectInput7_Release(lpDI); - } -} - -int FCEUD_CommandMapping[EMUCMD_MAX]; - -CFGSTRUCT HotkeyConfig[]={ - AC(FCEUD_CommandMapping), - ENDCFGSTRUCT -}; - -int FCEUD_TestCommandState(int c) -{ - int cmd=FCEUD_CommandMapping[c]; - int cmdmask=cmd&CMD_KEY_MASK; - - // allow certain commands be affected by key repeat - if(c == EMUCMD_FRAME_ADVANCE/* - || c == EMUCMD_SOUND_VOLUME_UP - || c == EMUCMD_SOUND_VOLUME_DOWN - || c == EMUCMD_SPEED_SLOWER - || c == EMUCMD_SPEED_FASTER*/) - { - keys=GetKeyboard_nr(); - /* if((cmdmask & CMD_KEY_LALT) == CMD_KEY_LALT - || (cmdmask & CMD_KEY_RALT) == CMD_KEY_RALT - || (cmdmask & CMD_KEY_LALT) == CMD_KEY_LALT - || (cmdmask & CMD_KEY_LCTRL) == CMD_KEY_LCTRL - || (cmdmask & CMD_KEY_RCTRL) == CMD_KEY_RCTRL - || (cmdmask & CMD_KEY_LSHIFT) == CMD_KEY_LSHIFT - || (cmdmask & CMD_KEY_RSHIFT) == CMD_KEY_RSHIFT)*/ - keys_nr=GetKeyboard_nr(); - // else - // keys_nr=GetKeyboard_nr(); - } - else if(c != EMUCMD_SPEED_TURBO && c != EMUCMD_TASEDITOR_REWIND) // TODO: this should be made more general by detecting if the command has an "off" function - { - keys=GetKeyboard_jd(); - keys_nr=GetKeyboard_nr(); - } - else - { - keys=GetKeyboard_nr(); - keys_nr=GetKeyboard_nr(); - } - - /* test CTRL, SHIFT, ALT */ - if (cmd & CMD_KEY_ALT) - { - int ctlstate = (cmd & CMD_KEY_LALT) ? keys_nr[SCAN_LEFTALT] : 0; - ctlstate |= (cmd & CMD_KEY_RALT) ? keys_nr[SCAN_RIGHTALT] : 0; - if (!ctlstate) - return 0; - } - else if((cmdmask != SCAN_LEFTALT && keys_nr[SCAN_LEFTALT]) || (cmdmask != SCAN_RIGHTALT && keys_nr[SCAN_RIGHTALT])) - return 0; - - if (cmd & CMD_KEY_CTRL) - { - int ctlstate = (cmd & CMD_KEY_LCTRL) ? keys_nr[SCAN_LEFTCONTROL] : 0; - ctlstate |= (cmd & CMD_KEY_RCTRL) ? keys_nr[SCAN_RIGHTCONTROL] : 0; - if (!ctlstate) - return 0; - } - else if((cmdmask != SCAN_LEFTCONTROL && keys_nr[SCAN_LEFTCONTROL]) || (cmdmask != SCAN_RIGHTCONTROL && keys_nr[SCAN_RIGHTCONTROL])) - return 0; - - if (cmd & CMD_KEY_SHIFT) - { - int ctlstate = (cmd & CMD_KEY_LSHIFT) ? keys_nr[SCAN_LEFTSHIFT] : 0; - ctlstate |= (cmd & CMD_KEY_RSHIFT) ? keys_nr[SCAN_RIGHTSHIFT] : 0; - if (!ctlstate) - return 0; - } - else if((cmdmask != SCAN_LEFTSHIFT && keys_nr[SCAN_LEFTSHIFT]) || (cmdmask != SCAN_RIGHTSHIFT && keys_nr[SCAN_RIGHTSHIFT])) - return 0; - - return keys[cmdmask] ? 1 : 0; -} - -void FCEUD_TurboOn (void) - { - tempwinsync = winsync; //Store winsync setting - winsync = 0; //turn off winsync for turbo (so that turbo can function even with VBlank sync methods - tempsoundquality = soundquality; //Store sound quality settings - FCEUI_SetSoundQuality(0); //Turn sound quality to low - turbo = true; - if (muteTurbo && soundo) TrashSound(); - } -void FCEUD_TurboOff (void) - { - winsync = tempwinsync; //Restore winsync setting - soundquality = tempsoundquality; //Restore sound quality settings - FCEUI_SetSoundQuality(soundquality); - turbo = false; - if (muteTurbo && soundo) InitSound(); - } -void FCEUD_TurboToggle(void) -{ - if (turbo) { - winsync = tempwinsync; //If turbo was on, restore winsync - soundquality = tempsoundquality; //and restore sound quality setting - FCEUI_SetSoundQuality(soundquality); - } - else - { - tempwinsync = winsync; //Store video sync settings - tempsoundquality = soundquality; //Store sound quality settings - winsync = 0; //If turbo was off, turn off winsync (so that turbo can function even with VBlank sync methods - FCEUI_SetSoundQuality(0); //Set sound quality to low - } - - turbo = !turbo; - if (muteTurbo && soundo) - { - if (turbo) TrashSound(); - if (!turbo) InitSound(); - } -} - -void FCEUI_UseInputPreset(int preset) -{ - switch(preset) - { - case 0: memcpy(GamePadConfig, GamePadPreset1, sizeof(GamePadPreset1)); break; - case 1: memcpy(GamePadConfig, GamePadPreset2, sizeof(GamePadPreset2)); break; - case 2: memcpy(GamePadConfig, GamePadPreset3, sizeof(GamePadPreset3)); break; - } - FCEU_DispMessage("Using input preset %d.",0,preset+1); -} - -static void PresetExport(int preset) -{ - const char filter[]="Input Preset File (*.pre)\0*.pre\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Export Input Preset To..."; - ofn.lpstrFilter=filter; - nameo[0]=0; //No default filename - ofn.lpstrFile=nameo; - ofn.lpstrDefExt="pre"; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; - std::string initdir = FCEU_GetPath(FCEUMKF_INPUT).c_str(); - ofn.lpstrInitialDir=initdir.c_str(); - if(GetSaveFileName(&ofn)) - { - //Save the directory - if(ofn.nFileOffset < 1024) - { - free(InputPresetDir); - InputPresetDir=(char*)malloc(strlen(ofn.lpstrFile)+1); - strcpy(InputPresetDir,ofn.lpstrFile); - InputPresetDir[ofn.nFileOffset]=0; - } - - FILE *fp=FCEUD_UTF8fopen(nameo,"w"); - switch(preset) - { - case 1: fwrite(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break; - case 2: fwrite(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break; - case 3: fwrite(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break; - } - fclose(fp); - } -} - -static void PresetImport(int preset) -{ - const char filter[]="Input Preset File (*.pre)\0*.pre\0\0"; - char nameo[2048]; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Import Input Preset......"; - ofn.lpstrFilter=filter; - nameo[0]=0; - ofn.lpstrFile=nameo; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - std::string initdir = FCEU_GetPath(FCEUMKF_INPUT); - ofn.lpstrInitialDir=initdir.c_str(); - - if(GetOpenFileName(&ofn)) - { - //Save the directory - if(ofn.nFileOffset < 1024) - { - free(InputPresetDir); - InputPresetDir=(char*)malloc(strlen(ofn.lpstrFile)+1); - strcpy(InputPresetDir,ofn.lpstrFile); - InputPresetDir[ofn.nFileOffset]=0; - } - - FILE *fp=FCEUD_UTF8fopen(nameo,"r"); - switch(preset) - { - case 1: fread(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break; - case 2: fread(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break; - case 3: fread(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break; - } - fclose(fp); - } -} - - -//commandline input config. not being used right now -//--------------------------- -//static void FCExp(char *text) -//{ -// static char *fccortab[12]={"none","arkanoid","shadow","4player","fkb","suborkb", -// "hypershot","mahjong","quizking","ftrainera","ftrainerb","oekakids"}; -// -// static int fccortabi[12]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW, -// SIFC_4PLAYER,SIFC_FKB,SIFC_SUBORKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING, -// SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS}; -// int y; -// for(y=0;y<12;y++) -// if(!strcmp(fccortab[y],text)) -// UsrInputType[2]=fccortabi[y]; -//} -//static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"}; -//static int cortabi[6]={SI_NONE,SI_GAMEPAD, -// SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID}; -//static void Input1(char *text) -//{ -// int y; -// -// for(y=0;y<6;y++) -// if(!strcmp(cortab[y],text)) -// UsrInputType[0]=cortabi[y]; -//} -// -//static void Input2(char *text) -//{ -// int y; -// -// for(y=0;y<6;y++) -// if(!strcmp(cortab[y],text)) -// UsrInputType[1]=cortabi[y]; -//} -//ARGPSTRUCT InputArgs[]={ -// {"-fcexp",0,(void *)FCExp,0x2000}, -// {"-input1",0,(void *)Input1,0x2000}, -// {"-input2",0,(void *)Input2,0x2000}, -// {0,0,0,0} -//}; diff --git a/branches/fceux-2.2.2/src/drivers/win/log.cpp b/branches/fceux-2.2.2/src/drivers/win/log.cpp deleted file mode 100644 index d7692b39..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/log.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include -#include "common.h" -#include "tracer.h" - -static HWND logwin = 0; - -static char *logtext[MAXIMUM_NUMBER_OF_LOGS]; -static int logcount=0; - -int MLogPosX=0,MLogPosY=0; //X,Y coordinates of dialog - -unsigned int truncated_logcount() -{ - return logcount & ( MAXIMUM_NUMBER_OF_LOGS - 1 ); -} - -/** -* Concatenates formerly logged messages into a single string and -* displays that string in the log window. -**/ -void RedoText(void) -{ - char textbuf[65536] = { 0 }; - int x; - int tbs=0; // textbuf size - int cs; // current log size - - // TODO: This if can be made much simpler. - if(logcount >= MAXIMUM_NUMBER_OF_LOGS) - { - - x = truncated_logcount(); - - for(;;) - { - cs=strlen(logtext[x]); - if (tbs+cs>=65536) - { - //SetDlgItemText(logwin, LBL_LOG_TEXT, textbuf); - //SendDlgItemMessage(logwin, LBL_LOG_TEXT, EM_LINESCROLL, 0, 200); - //textbuf[0]='\0'; - //tbs=0; - break; - } - strcat(textbuf+tbs, logtext[x]); - tbs+=cs; - x = ( x + 1 ) & ( MAXIMUM_NUMBER_OF_LOGS - 1 ); - - if(x == truncated_logcount()) - { - break; - } - } - } - else - { - for(x = 0; x < logcount; x++) - { - cs=strlen(logtext[x]); - if (tbs+cs>=65536) - { - break; - } - strcat(textbuf+tbs,logtext[x]); - tbs+=cs; - } - } - - SetDlgItemText(logwin, LBL_LOG_TEXT, textbuf); - SendDlgItemMessage(logwin, LBL_LOG_TEXT, EM_LINESCROLL, 0, MAXIMUM_NUMBER_OF_LOGS); -} - -/** -* Callback function for the log window. -**/ -BOOL CALLBACK LogCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT wrect; //For remembering window position - switch(uMsg) - { - case WM_INITDIALOG: - if (MLogPosX==-32000) MLogPosX=0; //Just in case - if (MLogPosY==-32000) MLogPosY=0; - SetWindowPos(hwndDlg,0,MLogPosX,MLogPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - break; - case WM_MOVE: - if (!IsIconic(hwndDlg)) { - GetWindowRect(hwndDlg,&wrect); //Remember X,Y coordinates - MLogPosX = wrect.left; - MLogPosY = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(MLogPosX,MLogPosY,wrect.right); - #endif - } - break; - case WM_COMMAND: - { - if (HIWORD(wParam) == BN_CLICKED) - { - if (LOWORD(wParam) == CLEAR_LOG) - { - ClearLog(); - } else - { - DestroyWindow(hwndDlg); - // Clear the handle - logwin = 0; - } - } - break; - } - } - - return 0; -} - -/** -* Creates the log window if it's not already open. -**/ -void MakeLogWindow(void) -{ - if(!logwin) - { - logwin = CreateDialog(fceu_hInstance, "MESSAGELOG" , 0, LogCon); - RedoText(); // XXX jeblanchard Why didn't this work in WM_INITDIALOG? - } else - { - ShowWindow(logwin, SW_SHOWNORMAL); - SetForegroundWindow(logwin); - } -} - -void ClearLog() -{ - for (logcount--; logcount >= 0; logcount--) - free(logtext[truncated_logcount()]); - logcount = 0; - if (logwin) - RedoText(); -} - -/** -* Adds a textual log message to the message buffer. -* -* @param text Message to add. -* @param add_newline Either DO_ADD_NEWLINE or DONT_ADD_NEWLINE -**/ -void AddLogText(const char *text, unsigned int add_newline) -{ - // Used to count the number of new line characters in text - int number_of_newlines; - - // Used to iterate over the text - const char *text_iterator_c; - - // Used to iterate over the message log created in this function - char* msg_iterator; - - // Free a log message if more messages than necessary were logged. - if(logcount >= MAXIMUM_NUMBER_OF_LOGS) - { - free(logtext[truncated_logcount()]); - } - - number_of_newlines = 0; - text_iterator_c = text; - - // Count the number of \n characters in the text - while(*text_iterator_c) - { - if(*text_iterator_c == '\n') - { - number_of_newlines++; - } - - text_iterator_c++; - } - - unsigned int necessary_size = strlen(text) // len(text) - + 1 // 0-byte - + number_of_newlines // Space for additional \r characters - + 2 * add_newline; // \r\n if a newline was requested - - //mbg merge 7/17/06 added cast - logtext[truncated_logcount()] = (char*)malloc(necessary_size); - - // Apparently there's no memory left. - if(!logtext[truncated_logcount()]) - { - return; - } - - msg_iterator = logtext[truncated_logcount()]; - - // Copy the characters from text to the allocated buffer - while(*text) - { - // Replace \n with \r\n - if(*text == '\n') - { - *msg_iterator='\r'; - msg_iterator++; - } - - *msg_iterator = *text; - - msg_iterator++; - text++; - } - - // Add a final newline if requested - if (add_newline) - { - *msg_iterator = '\r'; - msg_iterator++; - *msg_iterator = '\n'; - msg_iterator++; - } - - // Terminating 0-byte - *msg_iterator = 0; - - // also log the text into Trace Logger log if needed - if (logging && (logging_options & LOG_MESSAGES)) - { - OutputLogLine(strdup(logtext[truncated_logcount()]), 0, add_newline != 0); - log_old_emu_paused = false; // force Trace Logger update - } - - // Keep track of the added log - logcount++; - - if(logwin) - { - RedoText(); - } -} - -/** -* Adds a textual message to the message buffer without adding a newline at the end. -* -* @param text The text of the message to add. -* -* TODO: This function should have a better name. -**/ -void FCEUD_Message(const char *text) -{ - AddLogText(text, DONT_ADD_NEWLINE); -} diff --git a/branches/fceux-2.2.2/src/drivers/win/main.cpp b/branches/fceux-2.2.2/src/drivers/win/main.cpp deleted file mode 100644 index 1814d42a..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/main.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "common.h" - -// I like hacks. -#define uint8 __UNO492032 -#include -#include "ddraw.h" -#undef LPCWAVEFORMATEX -#include "dsound.h" -#include "dinput.h" -#include -#include -#include // For directories configuration dialog. -#undef uint8 - -#include - -#include "../../version.h" -#include "../../types.h" -#include "../../fceu.h" -#include "../../state.h" -#include "../../debug.h" -#include "../../movie.h" -#include "../../fceulua.h" - -#include "archive.h" -#include "input.h" -#include "netplay.h" -#include "memwatch.h" -#include "joystick.h" -#include "keyboard.h" -#include "ppuview.h" -#include "debugger.h" -#include "cheat.h" -#include "debug.h" -#include "ntview.h" -#include "ram_search.h" -#include "ramwatch.h" -#include "memview.h" -#include "tracer.h" -#include "cdlogger.h" -#include "throttle.h" -#include "replay.h" -#include "palette.h" //For the SetPalette function -#include "main.h" -#include "args.h" -#include "config.h" -#include "sound.h" -#include "wave.h" -#include "video.h" -#include "utils/xstring.h" -#include -#include "taseditor.h" -#include "taseditor/taseditor_window.h" - -extern TASEDITOR_WINDOW taseditorWindow; -extern bool taseditorEnableAcceleratorKeys; - -//--------------------------- -//mbg merge 6/29/06 - new aboutbox - -#if defined(MSVC) - #ifdef _M_X64 - #define _MSVC_ARCH "x64" - #else - #define _MSVC_ARCH "x86" - #endif - #ifdef _DEBUG - #define _MSVC_BUILD "debug" - #else - #define _MSVC_BUILD "release" - #endif - #define __COMPILER__STRING__ "msvc " _Py_STRINGIZE(_MSC_VER) " " _MSVC_ARCH " " _MSVC_BUILD - #define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) - #define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X - #define _Py_STRINGIZE2(X) #X - //re: http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5 -#elif defined(__GNUC__) - #ifdef _DEBUG - #define _GCC_BUILD "debug" - #else - #define _GCC_BUILD "release" - #endif - #define __COMPILER__STRING__ "gcc " __VERSION__ " " _GCC_BUILD -#else - #define __COMPILER__STRING__ "unknown" -#endif - -// External functions -extern std::string cfgFile; //Contains the filename of the config file used. -extern bool turbo; //Is game in turbo mode? -void ResetVideo(void); -void ShowCursorAbs(int w); -void HideFWindow(int h); -void FixWXY(int pref, bool shift_held); -void SetMainWindowStuff(void); -int GetClientAbsRect(LPRECT lpRect); -void UpdateFCEUWindow(void); -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); -void ApplyDefaultCommandMapping(void); - -// Internal variables -int frameSkipAmt = 18; -uint8 *xbsave = NULL; -int eoptions = EO_BGRUN | EO_FORCEISCALE | EO_BESTFIT | EO_BGCOLOR | EO_SQUAREPIXELS; - -//global variables -int soundoptions = SO_SECONDARY | SO_GFOCUS; -int soundrate = 44100; -int soundbuftime = 50; -int soundquality = 1; - -//Sound volume controls (range 0-150 by 10's)j----- -int soundvolume = 150; //Master sound volume -int soundTrianglevol = 256; //Sound channel Triangle - volume control -int soundSquare1vol = 256; //Sound channel Square1 - volume control -int soundSquare2vol = 256; //Sound channel Square2 - volume control -int soundNoisevol = 256; //Sound channel Noise - volume control -int soundPCMvol = 256; //Sound channel PCM - volume control -//------------------------------------------------- - -int KillFCEUXonFrame = 0; //TODO: clean up, this is used in fceux, move it over there? - -double winsizemulx = 1.0, winsizemuly = 1.0; -double tvAspectX = TV_ASPECT_DEFAULT_X, tvAspectY = TV_ASPECT_DEFAULT_Y; -int genie = 0; -int pal_emulation = 0; -int pal_setting_specified = 0; -int ntsccol = 0, ntsctint, ntschue; -std::string BaseDirectory; -int PauseAfterLoad; -unsigned int skippy = 0; //Frame skip -int frameSkipCounter = 0; //Counter for managing frame skip -// Contains the names of the overridden standard directories -// in the order roms, nonvol, states, fdsrom, snaps, cheats, movies, memwatch, macro, input presets, lua scripts, base -char *directory_names[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -std::string cfgFile = "fceux.cfg"; -//Handle of the main window. -HWND hAppWnd = 0; - -uint32 goptions = GOO_DISABLESS; - -// Some timing-related variables (now ignored). -int maxconbskip = 32; //Maximum consecutive blit skips. -int ffbskip = 32; //Blit skips per blit when FF-ing - -HINSTANCE fceu_hInstance; -HACCEL fceu_hAccel; - -HRESULT ddrval; - -static char TempArray[2048]; - -static int exiting = 0; -static volatile int moocow = 0; - -int windowedfailed = 0; -int fullscreen = 0; //Windows files only, variable that keeps track of fullscreen status - -static volatile int _userpause = 0; //mbg merge 7/18/06 changed tasbuild was using this only in a couple of places - -extern int autoHoldKey, autoHoldClearKey; -extern int frame_display, input_display; - -int soundo = 1; - -int srendlinen = 8; -int erendlinen = 231; -int srendlinep = 0; -int erendlinep = 239; - -//mbg 6/30/06 - indicates that the main loop should close the game as soon as it can -bool closeGame = false; - -// Counts the number of frames that have not been displayed. -// Used for the bot, to skip frames (makes things faster). -int BotFramesSkipped = 0; - -// Instantiated FCEUX stuff: -bool SingleInstanceOnly=false; // Enable/disable option -bool DoInstantiatedExit=false; -HWND DoInstantiatedExitWindow; - -// Internal functions -void SetDirs() -{ - int x; - - static int jlist[14]= { - FCEUIOD_ROMS, - FCEUIOD_NV, - FCEUIOD_STATES, - FCEUIOD_FDSROM, - FCEUIOD_SNAPS, - FCEUIOD_CHEATS, - FCEUIOD_MOVIES, - FCEUIOD_MEMW, - FCEUIOD_BBOT, - FCEUIOD_MACRO, - FCEUIOD_INPUT, - FCEUIOD_LUA, - FCEUIOD_AVI, - FCEUIOD__COUNT}; - -// FCEUI_SetSnapName((eoptions & EO_SNAPNAME)!=0); - - for(x=0; x < sizeof(jlist) / sizeof(*jlist); x++) - { - FCEUI_SetDirOverride(jlist[x], directory_names[x]); - } - - if(directory_names[13]) - { - FCEUI_SetBaseDirectory(directory_names[13]); - } - else - { - FCEUI_SetBaseDirectory(BaseDirectory); - } -} - -/// Creates a directory. -/// @param dirname Name of the directory to create. -void DirectoryCreator(const char* dirname) -{ - CreateDirectory(dirname, 0); -} - -/// Removes a directory. -/// @param dirname Name of the directory to remove. -void DirectoryRemover(const char* dirname) -{ - RemoveDirectory(dirname); -} - -/// Used to walk over the default directories array. -/// @param callback Callback function that's called for every default directory name. -void DefaultDirectoryWalker(void (*callback)(const char*)) -{ - unsigned int curr_dir; - - for(curr_dir = 0; curr_dir < NUMBER_OF_DEFAULT_DIRECTORIES; curr_dir++) - { - if(!directory_names[curr_dir]) - { - sprintf( - TempArray, - "%s\\%s", - directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] ? directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] : BaseDirectory.c_str(), - default_directory_names[curr_dir] - ); - - callback(TempArray); - } - } -} - -/// Remove empty, unused directories. -void RemoveDirs() -{ - DefaultDirectoryWalker(DirectoryRemover); -} - -///Creates the default directories. -void CreateDirs() -{ - DefaultDirectoryWalker(DirectoryCreator); -} - - - -//Fills the BaseDirectory string -//TODO: Potential buffer overflow caused by limited size of BaseDirectory? -void GetBaseDirectory(void) -{ - char temp[2048]; - GetModuleFileName(0, temp, 2048); - BaseDirectory = temp; - - size_t truncate_at = BaseDirectory.find_last_of("\\/"); - if(truncate_at != std::string::npos) - BaseDirectory = BaseDirectory.substr(0,truncate_at); -} - -int BlockingCheck() -{ - MSG msg; - moocow = 1; - - while( PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ) ) - { - if( GetMessage( &msg, 0, 0, 0)>0 ) - { - //other accelerator capable dialogs could be added here - extern HWND hwndMemWatch; - - int handled = 0; - - if(hCheat) - if(IsChild(hCheat, msg.hwnd)) - handled = IsDialogMessage(hCheat, &msg); - if(!handled && hMemFind) - { - if(IsChild(hMemFind, msg.hwnd)) - handled = IsDialogMessage(hMemFind, &msg); - } - if(!handled && hwndMemWatch) - { - if(IsChild(hwndMemWatch,msg.hwnd)) - handled = TranslateAccelerator(hwndMemWatch,fceu_hAccel,&msg); - if(!handled) - handled = IsDialogMessage(hwndMemWatch,&msg); - } - if(!handled && RamSearchHWnd) - { - handled = IsDialogMessage(RamSearchHWnd, &msg); - } - if(!handled && RamWatchHWnd) - { - if(IsDialogMessage(RamWatchHWnd, &msg)) - { - if(msg.message == WM_KEYDOWN) // send keydown messages to the dialog (for accelerators, and also needed for the Alt key to work) - SendMessage(RamWatchHWnd, msg.message, msg.wParam, msg.lParam); - handled = true; - } - } - - if(!handled && taseditorWindow.hwndTASEditor && taseditorEnableAcceleratorKeys) - { - if(IsChild(taseditorWindow.hwndTASEditor, msg.hwnd)) - handled = TranslateAccelerator(taseditorWindow.hwndTASEditor, fceu_hAccel, &msg); - } - if(!handled && taseditorWindow.hwndFindNote) - { - if(IsChild(taseditorWindow.hwndFindNote, msg.hwnd)) - handled = IsDialogMessage(taseditorWindow.hwndFindNote, &msg); - } - /* //adelikat - Currently no accel keys are used in the main window. Uncomment this block to activate them. - if(!handled) - if(msg.hwnd == hAppWnd) - { - handled = TranslateAccelerator(hAppWnd,fceu_hAccel,&msg); - if(handled) - { - int zzz=9; - } - } - */ - if(!handled) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - - moocow = 0; - - return exiting ? 0 : 1; -} - -void UpdateRendBounds() -{ - FCEUI_SetRenderedLines(srendlinen, erendlinen, srendlinep, erendlinep); -} - -/// Shows an error message in a message box. -///@param errormsg Text of the error message. -void FCEUD_PrintError(const char *errormsg) -{ - AddLogText(errormsg, 1); - - if (fullscreen && (eoptions & EO_HIDEMOUSE)) - ShowCursorAbs(1); - - MessageBox(0, errormsg, FCEU_NAME" Error", MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - - if (fullscreen && (eoptions & EO_HIDEMOUSE)) - ShowCursorAbs(0); -} - -///Generates a compiler identification string. -/// @return Compiler identification string -const char *FCEUD_GetCompilerString() -{ - return __COMPILER__STRING__; -} - -//Displays the about box -void ShowAboutBox() -{ - MessageBox(hAppWnd, FCEUI_GetAboutString(), FCEU_NAME, MB_OK); -} - -//Exits FCE Ultra -void DoFCEUExit() -{ - if(exiting) //Eh, oops. I'll need to try to fix this later. - return; - - // If user was asked to save changes in TAS Editor and chose cancel, don't close FCEUX - extern bool exitTASEditor(); - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && !exitTASEditor()) - return; - - if (CloseMemoryWatch() && AskSave()) //If user was asked to save changes in the memory watch dialog or ram watch, and chose cancel, don't close FCEUX! - { - if(goptions & GOO_CONFIRMEXIT) - { - //Wolfenstein 3D had cute exit messages. - const char * const emsg[7]={"Are you sure you want to leave? I'll become lonely!", - "A strange game. The only winning move is not to play. How about a nice game of chess?", - "If you exit, I'll... EAT YOUR MOUSE.", - "You can never really exit, you know.", - "E.X.I.T?", - "I'm sorry, you missed your exit. There is another one in 19 miles", - "Silly Exit Message goes here" - - }; - - if(IDYES != MessageBox(hAppWnd, emsg[rand() & 6], "Exit FCE Ultra?", MB_ICONQUESTION | MB_YESNO) ) - { - return; - } - } - - KillDebugger(); //mbg merge 7/19/06 added - - FCEUI_StopMovie(); - FCEUD_AviStop(); -#ifdef _S9XLUA_H - FCEU_LuaStop(); // kill lua script before the gui dies -#endif - - exiting = 1; - closeGame = true;//mbg 6/30/06 - for housekeeping purposes we need to exit after the emulation cycle finishes - // remember the ROM name - extern char LoadedRomFName[2048]; - if (GameInfo) - strcpy(romNameWhenClosingEmulator, LoadedRomFName); - else - romNameWhenClosingEmulator[0] = 0; - } -} - -void FCEUD_OnCloseGame() -{ -} - -//Changes the thread priority of the main thread. -void DoPriority() -{ - if(eoptions & EO_HIGHPRIO) - { - if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)) - { - AddLogText("Error setting thread priority to THREAD_PRIORITY_HIGHEST.", 1); - } - } - else - { - if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)) - { - AddLogText("Error setting thread priority to THREAD_PRIORITY_NORMAL.", 1); - } - } -} - -int DriverInitialize() -{ - if(soundo) - soundo = InitSound(); - - SetVideoMode(fullscreen); - InitInputStuff(); /* Initialize DInput interfaces. */ - - return 1; -} - -static void DriverKill(void) -{ - // Save config file - //sprintf(TempArray, "%s/fceux.cfg", BaseDirectory.c_str()); - sprintf(TempArray, "%s/%s", BaseDirectory.c_str(),cfgFile.c_str()); - SaveConfig(TempArray); - - DestroyInput(); - - ResetVideo(); - - if(soundo) - { - TrashSoundNow(); - } - - CloseWave(); - - ByebyeWindow(); -} - -void do_exit() -{ - DriverKill(); - timeEndPeriod(1); - FCEUI_Kill(); -} - -//Puts the default directory names into the elements of the directory_names array that aren't already defined. -//adelikat: commenting out this function, we don't need this. This turns the idea of directory overrides to directory assignment -/* -void initDirectories() -{ - for (unsigned int i = 0; i < NUMBER_OF_DEFAULT_DIRECTORIES; i++) - { - if (directory_names[i] == 0) - { - sprintf( - TempArray, - "%s\\%s", - directory_names[i] ? directory_names[i] : BaseDirectory.c_str(), - default_directory_names[i] - ); - - directory_names[i] = (char*)malloc(strlen(TempArray) + 1); - strcpy(directory_names[i], TempArray); - } - } - - if (directory_names[NUMBER_OF_DIRECTORIES - 1] == 0) - { - directory_names[NUMBER_OF_DIRECTORIES - 1] = (char*)malloc(BaseDirectory.size() + 1); - strcpy(directory_names[NUMBER_OF_DIRECTORIES - 1], BaseDirectory.c_str()); - } -} -*/ - -static BOOL CALLBACK EnumCallbackFCEUXInstantiated(HWND hWnd, LPARAM lParam) -{ - //LPSTR lpClassName = '\0'; - std::string TempString; - char buf[512]; - - GetClassName(hWnd, buf, 511); - //Console.WriteLine(lpClassName.ToString()); - - TempString = buf; - - if (TempString != "FCEUXWindowClass") - return true; - - //zero 17-sep-2013 - removed window caption test which wasnt really making a lot of sense to me and was broken in any event - if (hWnd != hAppWnd) - { - DoInstantiatedExit = true; - DoInstantiatedExitWindow = hWnd; - } - - //printf("[%03i] Found '%s'\n", ++WinCount, buf); - return true; -} - -#include "x6502.h" -int main(int argc,char *argv[]) -{ - { -#ifdef MULTITHREAD_STDLOCALE_WORKAROUND - // Note: there's a known threading bug regarding std::locale with MSVC according to - // http://connect.microsoft.com/VisualStudio/feedback/details/492128/std-locale-constructor-modifies-global-locale-via-setlocale - int iPreviousFlag = ::_configthreadlocale(_ENABLE_PER_THREAD_LOCALE); -#endif - using std::locale; - locale::global(locale(locale::classic(), "", locale::collate | locale::ctype)); - -#ifdef MULTITHREAD_STDLOCALE_WORKAROUND - if (iPreviousFlag > 0 ) - ::_configthreadlocale(iPreviousFlag); -#endif - } - - SetThreadAffinityMask(GetCurrentThread(),1); - - //printf("%08x",opsize); //AGAIN?! - - char *t; - - initArchiveSystem(); - - if(timeBeginPeriod(1) != TIMERR_NOERROR) - { - AddLogText("Error setting timer granularity to 1ms.", DO_ADD_NEWLINE); - } - - InitCommonControls(); - - if(!FCEUI_Initialize()) - { - do_exit(); - return 1; - } - - ApplyDefaultCommandMapping(); - - fceu_hInstance = GetModuleHandle(0); - fceu_hAccel = LoadAccelerators(fceu_hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1)); - - // Get the base directory - GetBaseDirectory(); - - // load fceux.cfg - sprintf(TempArray,"%s\\%s",BaseDirectory.c_str(),cfgFile.c_str()); - LoadConfig(TempArray); - //initDirectories(); - - // Parse the commandline arguments - t = ParseArgies(argc, argv); - - int saved_pal_setting = !!pal_emulation; - - if (ConfigToLoad) - { - // alternative config file specified - cfgFile.assign(ConfigToLoad); - // Load the config information - sprintf(TempArray,"%s\\%s",BaseDirectory.c_str(),cfgFile.c_str()); - LoadConfig(TempArray); - } - - //Bleh, need to find a better place for this. - { - FCEUI_SetGameGenie(genie!=0); - - fullscreen = !!fullscreen; - soundo = !!soundo; - frame_display = !!frame_display; - allowUDLR = !!allowUDLR; - pauseAfterPlayback = !!pauseAfterPlayback; - closeFinishedMovie = !!closeFinishedMovie; - EnableBackgroundInput = !!EnableBackgroundInput; - - KeyboardSetBackgroundAccess(EnableBackgroundInput!=0); - JoystickSetBackgroundAccess(EnableBackgroundInput!=0); - - FCEUI_SetSoundVolume(soundvolume); - FCEUI_SetSoundQuality(soundquality); - FCEUI_SetTriangleVolume(soundTrianglevol); - FCEUI_SetSquare1Volume(soundSquare1vol); - FCEUI_SetSquare2Volume(soundSquare2vol); - FCEUI_SetNoiseVolume(soundNoisevol); - FCEUI_SetPCMVolume(soundPCMvol); - } - - //Since a game doesn't have to be loaded before the GUI can be used, make - //sure the temporary input type variables are set. - ParseGIInput(NULL); - - // Initialize default directories - CreateDirs(); - SetDirs(); - - DoVideoConfigFix(); - DoTimingConfigFix(); - - if(eoptions & EO_CPALETTE) - { - FCEUI_SetPaletteArray(cpalette); - } - - if(!t) - { - fullscreen=0; - } - - CreateMainWindow(); - - // Do single instance coding, since we now know if the user wants it, - // and we have a source window to send from - // http://wiki.github.com/ffi/ffi/windows-examples - if (SingleInstanceOnly) { - // Checks window names / hWnds, decides if there's going to be a conflict. - EnumDesktopWindows(NULL, EnumCallbackFCEUXInstantiated, (LPARAM)0); - - if (DoInstantiatedExit) { - - if(t) - { - COPYDATASTRUCT cData; - DATA tData; - - sprintf(tData.strFilePath,"%s",t); - - cData.dwData = 1; - cData.cbData = sizeof ( tData ); - cData.lpData = &tData; - - SendMessage(DoInstantiatedExitWindow,WM_COPYDATA,(WPARAM)(HWND)hAppWnd, (LPARAM)(LPVOID) &cData); - do_exit(); - return 0; - } - else - { - //kill this one, activate the other one - SetActiveWindow(DoInstantiatedExitWindow); - do_exit(); - return 0; - } - } - } - - if(!InitDInput()) - { - do_exit(); - return 1; - } - - if(!DriverInitialize()) - { - do_exit(); - return 1; - } - - debugSystem = new DebugSystem(); - debugSystem->init(); - - InitSpeedThrottle(); - - if (t) - { - ALoad(t); - } else - { - if (AutoResumePlay && romNameWhenClosingEmulator && romNameWhenClosingEmulator[0]) - ALoad(romNameWhenClosingEmulator, 0, true); - if (eoptions & EO_FOAFTERSTART) - LoadNewGamey(hAppWnd, 0); - } - - if (pal_setting_specified) - { - // Force the PAL setting specified in the command line - pal_emulation = saved_pal_setting; - FCEUI_SetVidSystem(pal_emulation); - } - - if(PaletteToLoad) - { - SetPalette(PaletteToLoad); - free(PaletteToLoad); - PaletteToLoad = NULL; - } - - if(GameInfo && MovieToLoad) - { - //switch to readonly mode if the file is an archive - if(FCEU_isFileInArchive(MovieToLoad)) - replayReadOnlySetting = true; - - FCEUI_LoadMovie(MovieToLoad, replayReadOnlySetting, replayStopFrameSetting != 0); - FCEUX_LoadMovieExtras(MovieToLoad); - free(MovieToLoad); - MovieToLoad = NULL; - } - if(GameInfo && StateToLoad) - { - FCEUI_LoadState(StateToLoad); - free(StateToLoad); - StateToLoad = NULL; - } - if(GameInfo && LuaToLoad) - { - FCEU_LoadLuaCode(LuaToLoad); - free(LuaToLoad); - LuaToLoad = NULL; - } - - //Initiates AVI capture mode, will set up proper settings, and close FCUEX once capturing is finished - if(AVICapture && AviToLoad) //Must be used in conjunction with AviToLoad - { - //We want to disable flags that will pause the emulator - PauseAfterLoad = 0; - pauseAfterPlayback = 0; - KillFCEUXonFrame = AVICapture; - } - - if(AviToLoad) - { - FCEUI_AviBegin(AviToLoad); - free(AviToLoad); - AviToLoad = NULL; - } - - if (MemWatchLoadOnStart) CreateMemWatch(); - if (PauseAfterLoad) FCEUI_ToggleEmulationPause(); - SetAutoFirePattern(AFon, AFoff); - UpdateCheckedMenuItems(); -doloopy: - UpdateFCEUWindow(); - if(GameInfo) - { - while(GameInfo) - { - uint8 *gfx=0; ///contains framebuffer - int32 *sound=0; ///contains sound data buffer - int32 ssize=0; ///contains sound samples count - - if (turbo) - { - if (!frameSkipCounter) - { - frameSkipCounter = frameSkipAmt; - skippy = 0; - } - else - { - frameSkipCounter--; - if (muteTurbo) skippy = 2; //If mute turbo is on, we want to bypass sound too, so set it to 2 - else skippy = 1; //Else set it to 1 to just frameskip - } - - } - else skippy = 0; - - FCEUI_Emulate(&gfx, &sound, &ssize, skippy); //emulate a single frame - FCEUD_Update(gfx, sound, ssize); //update displays and debug tools - - //mbg 6/30/06 - close game if we were commanded to by calls nested in FCEUI_Emulate() - if (closeGame) - { - FCEUI_CloseGame(); - GameInfo = NULL; - } - - } - //xbsave = NULL; - RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE); - } - else - UpdateRawInputAndHotkeys(); - Sleep(50); - if(!exiting) - goto doloopy; - - DriverKill(); - timeEndPeriod(1); - FCEUI_Kill(); - - delete debugSystem; - - return(0); -} - -void FCEUX_LoadMovieExtras(const char * fname) { - UpdateReplayCommentsSubs(fname); -} - -//mbg merge 7/19/06 - the function that contains the code that used to just be UpdateFCEUWindow() and FCEUD_UpdateInput() -void _updateWindow() -{ - UpdateFCEUWindow(); - PPUViewDoBlit(); - UpdateMemoryView(0); - UpdateCDLogger(); - UpdateLogWindow(); //adelikat: Moved to FCEUI_Emulate; AnS: moved back - UpdateMemWatch(); - NTViewDoBlit(0); - //UpdateTasEditor(); //AnS: moved to FCEUD_Update -} - -void win_debuggerLoop() -{ - //delay until something causes us to unpause. - //either a hotkey or a debugger command - while(FCEUI_EmulationPaused() && !FCEUI_EmulationFrameStepped()) - { - Sleep(50); - FCEUD_UpdateInput(); - _updateWindow(); - // HACK: break when Frame Advance is pressed - extern bool frameAdvanceRequested; - extern int frameAdvance_Delay_count, frameAdvance_Delay; - if (frameAdvanceRequested) - { - if (frameAdvance_Delay_count == 0 || frameAdvance_Delay_count >= frameAdvance_Delay) - FCEUI_SetEmulationPaused(EMULATIONPAUSED_FA); - if (frameAdvance_Delay_count < frameAdvance_Delay) - frameAdvance_Delay_count++; - } - } - int zzz=9; -} - -// Update the game and gamewindow with a new frame -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count) -{ - win_SoundSetScale(fps_scale); //If turboing and mute turbo is true, bypass this - - //write all the sound we generated. - if(soundo && Buffer && Count && !(muteTurbo && turbo)) { - win_SoundWriteData(Buffer,Count); //If turboing and mute turbo is true, bypass this - } - - //blit the framebuffer - if(XBuf) - FCEUD_BlitScreen(XBuf); - - //update debugging displays - _updateWindow(); - // update TAS Editor - updateTASEditor(); - - extern bool JustFrameAdvanced; - - //MBG TODO - think about this logic - //throttle - - bool throttle = true; - if( (eoptions&EO_NOTHROTTLE) ) - { - if(!soundo) throttle = false; - } - - if(throttle) //if throttling is enabled.. - if(!turbo) //and turbo is disabled.. - if(!FCEUI_EmulationPaused() - ||JustFrameAdvanced - ) - //then throttle - while(SpeedThrottle()) { - FCEUD_UpdateInput(); - _updateWindow(); - } - - - //sleep just to be polite - if(!JustFrameAdvanced && FCEUI_EmulationPaused()) { - Sleep(50); - } - - //while(EmulationPaused==1 && inDebugger) - //{ - // Sleep(50); - // BlockingCheck(); - // FCEUD_UpdateInput(); //should this update the CONTROLS??? or only the hotkeys etc? - //} - - ////so, we're not paused anymore. - - ////something of a hack, but straightforward: - ////if we were paused, but not in the debugger, then unpause ourselves and step. - ////this is so that the cpu won't cut off execution due to being paused, but the debugger _will_ - ////cut off execution as soon as it makes it into the main cpu cycle loop - //if(FCEUI_EmulationPaused() && !inDebugger) { - // FCEUI_ToggleEmulationPause(); - // FCEUI_Debugger().step = 1; - // FCEUD_DebugBreakpoint(); - //} - - //make sure to update the input once per frame - FCEUD_UpdateInput(); - - -} - -static void FCEUD_MakePathDirs(const char *fname) -{ - char path[MAX_PATH]; - const char* div = fname; - - do - { - const char* fptr = strchr(div, '\\'); - - if(!fptr) - { - fptr = strchr(div, '/'); - } - - if(!fptr) - { - break; - } - - int off = fptr - fname; - strncpy(path, fname, off); - path[off] = '\0'; - mkdir(path); - - div = fptr + 1; - - while(div[0] == '\\' || div[0] == '/') - { - div++; - } - - } while(1); -} - -EMUFILE_FILE* FCEUD_UTF8_fstream(const char *n, const char *m) -{ - if(strchr(m, 'w') || strchr(m, '+')) - { - FCEUD_MakePathDirs(n); - } - - EMUFILE_FILE *fs = new EMUFILE_FILE(n,m); - if(!fs->is_open()) { - delete fs; - return 0; - } else return fs; -} - -FILE *FCEUD_UTF8fopen(const char *n, const char *m) -{ - if(strchr(m, 'w') || strchr(m, '+')) - { - FCEUD_MakePathDirs(n); - } - - return(fopen(n, m)); -} - -int status_icon = 1; - -int FCEUD_ShowStatusIcon(void) -{ - return status_icon; -} - -void FCEUD_ToggleStatusIcon(void) -{ - status_icon = !status_icon; - UpdateCheckedMenuItems(); -} - -char *GetRomName() -{ - //The purpose of this function is to format the ROM name stored in LoadedRomFName - //And return a char array with just the name with path or extension - //The purpose of this function is to populate a save as dialog with the ROM name as a default filename - extern char LoadedRomFName[2048]; //Contains full path of ROM - std::string Rom; //Will contain the formatted path - if(GameInfo) //If ROM is loaded - { - char drv[PATH_MAX], dir[PATH_MAX], name[PATH_MAX], ext[PATH_MAX]; - splitpath(LoadedRomFName,drv,dir,name,ext); //Extract components of the ROM path - Rom = name; //Pull out the Name only - } - else - Rom = ""; - char*mystring = (char*)malloc(2048*sizeof(char)); - strcpy(mystring, Rom.c_str()); //Convert string to char* - - return mystring; -} - -char *GetRomPath() -{ - //The purpose of this function is to format the ROM name stored in LoadedRomFName - //And return a char array with just the name with path or extension - //The purpose of this function is to populate a save as dialog with the ROM name as a default filename - extern char LoadedRomFName[2048]; //Contains full path of ROM - std::string Rom; //Will contain the formatted path - if(GameInfo) //If ROM is loaded - { - char drv[PATH_MAX], dir[PATH_MAX], name[PATH_MAX], ext[PATH_MAX]; - splitpath(LoadedRomFName,drv,dir,name,ext); //Extract components of the ROM path - Rom = drv; //Pull out the Path only - Rom.append(dir); - } - else - Rom = ""; - char*mystring = (char*)malloc(2048*sizeof(char)); - strcpy(mystring, Rom.c_str()); //Convert string to char* - - return mystring; -} diff --git a/branches/fceux-2.2.2/src/drivers/win/main.h b/branches/fceux-2.2.2/src/drivers/win/main.h deleted file mode 100644 index 7b71077e..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/main.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef WIN_MAIN_H -#define WIN_MAIN_H - -#include "common.h" -#include - -// #defines - -#define MAX(x,y) ((x)<(y)?(y):(x)) -#define MIN(x,y) ((x)>(y)?(y):(x)) - -#define VNSCLIP ((eoptions&EO_CLIPSIDES)?8:0) -#define VNSWID ((eoptions&EO_CLIPSIDES)?240:256) - -#define SO_FORCE8BIT 1 -#define SO_SECONDARY 2 -#define SO_GFOCUS 4 -#define SO_D16VOL 8 -#define SO_MUTEFA 16 -#define SO_OLDUP 32 - -#define GOO_DISABLESS 1 /* Disable screen saver when game is loaded. */ -#define GOO_CONFIRMEXIT 2 /* Confirmation before exiting. */ -#define GOO_POWERRESET 4 /* Confirm on power/reset. */ - -//For single instance mode, transfers with WM_COPYDATA -//http://www.go4expert.com/forums/showthread.php?t=19730 -typedef struct WMCopyStruct -{ - char strFilePath[2048]; -} DATA; - -extern int maxconbskip; -extern int ffbskip; -extern void LoadNewGamey(HWND hParent, const char *initialdir); -extern void CloseGame(); -extern int fullscreen; //Windows files only, keeps track of fullscreen status - -// Flag that indicates whether Game Genie is enabled or not. -extern int genie; - -// Flag that indicates whether PAL Emulation is enabled or not. -extern int pal_emulation; -extern int pal_setting_specified; -extern int status_icon; -extern int frame_display; -extern int rerecord_display; -extern int input_display; -extern int allowUDLR; -extern int pauseAfterPlayback; -extern int closeFinishedMovie; -extern int suggestReadOnlyReplay; -extern int EnableBackgroundInput; -extern int AFon; -extern int AFoff; -extern int AutoFireOffset; - -extern int vmod; - -extern char* directory_names[14]; - -char *GetRomName(); //Checks if rom is loaded, if so, outputs the Rom name with no directory path or file extension -char *GetRomPath(); //Checks if rom is loaded, if so, outputs the Rom path only - -///Contains the names of the default directories. -static const char *default_directory_names[13] = { - "", // roms - "sav", // nonvol - "fcs", // states - "", // fdsrom - "snaps", // snaps - "cheats", // cheats - "movies", // movies - "tools", // memwatch - "tools", // macro - "tools", // input presets - "tools", // lua scripts - "", // avi output - "" // adelikat - adding a dummy one here ( [13] but only 12 entries) -}; - -#define NUMBER_OF_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names) -#define NUMBER_OF_DEFAULT_DIRECTORIES sizeof(default_directory_names) / sizeof(*default_directory_names) - -#define TV_ASPECT_DEFAULT_X 4.0 -#define TV_ASPECT_DEFAULT_Y 3.0 - -extern double winsizemulx, winsizemuly; -extern double tvAspectX, tvAspectY; - -extern int ismaximized; -extern int soundoptions; -extern int soundrate; -extern int soundbuftime; -extern int soundvolume; //Master volume control -extern int soundTrianglevol;//Sound channel Triangle - volume control -extern int soundSquare1vol; //Sound channel Square1 - volume control -extern int soundSquare2vol; //Sound channel Square2 - volume control -extern int soundNoisevol; //Sound channel Noise - volume control -extern int soundPCMvol; //Sound channel PCM - volume control - -extern int soundquality; -extern bool muteTurbo; - -extern uint8 cpalette[192]; -extern int srendlinen; -extern int erendlinen; -extern int srendlinep; -extern int erendlinep; - -extern int ntsccol, ntsctint, ntschue; -extern bool force_grayscale; - -//mbg merge 7/17/06 did these have to be unsigned? -//static int srendline, erendline; - -static int changerecursive=0; - -/// Contains the base directory of FCE -extern std::string BaseDirectory; - -extern int soundo; -extern int eoptions; -extern int soundoptions; -extern uint8 *xbsave; -extern HRESULT ddrval; -extern int windowedfailed; -extern uint32 goptions; - -void DoFCEUExit(); -void ShowAboutBox(); -int BlockingCheck(); -void DoPriority(); -void RemoveDirs(); -void CreateDirs(); -void SetDirs(); -void FCEUX_LoadMovieExtras(const char * fname); -//void initDirectories(); //adelikat 03/02/09 - commenting out reference to a directory that I commented out - -#endif diff --git a/branches/fceux-2.2.2/src/drivers/win/memview.cpp b/branches/fceux-2.2.2/src/drivers/win/memview.cpp deleted file mode 100644 index a1cf6387..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/memview.cpp +++ /dev/null @@ -1,2286 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Ben Parnell -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include - -#include "common.h" -#include "../../types.h" -#include "../../debug.h" -#include "../../fceu.h" -#include "../../cheat.h" -#include "../../cart.h" -#include "../../ines.h" -#include "memview.h" -#include "debugger.h" -#include "cdlogger.h" -#include "memviewsp.h" -#include "debuggersp.h" -#include "cheat.h" -#include -#include "main.h" -#include "string.h" -#include "help.h" -#include "Win32InputBox.h" -#include "utils/xstring.h" - -extern Name* lastBankNames; -extern Name* loadedBankNames; -extern Name* ramBankNames; - -extern unsigned char *cdloggervdata; -extern unsigned int cdloggerVideoDataSize; - -extern bool JustFrameAdvanced; - -using namespace std; - -#define MODE_NES_MEMORY 0 -#define MODE_NES_PPU 1 -#define MODE_NES_FILE 2 - -#define ID_ADDRESS_FRZ_SUBMENU 1 -#define ID_ADDRESS_ADDBP_R 2 -#define ID_ADDRESS_ADDBP_W 3 -#define ID_ADDRESS_ADDBP_X 4 -#define ID_ADDRESS_SEEK_IN_ROM 5 -#define ID_ADDRESS_CREATE_GG_CODE 6 -#define ID_ADDRESS_BOOKMARK 20 -#define ID_ADDRESS_SYMBOLIC_NAME 30 -#define BOOKMARKS_SUBMENU_POS 4 - -#define ID_ADDRESS_FRZ_TOGGLE_STATE 1 -#define ID_ADDRESS_FRZ_FREEZE 50 -#define ID_ADDRESS_FRZ_UNFREEZE 51 -#define ID_ADDRESS_FRZ_SEP 52 -#define ID_ADDRESS_FRZ_UNFREEZE_ALL 53 - -#define HIGHLIGHT_ACTIVITY_MIN_VALUE 0 -#define HIGHLIGHT_ACTIVITY_NUM_COLORS 16 -#define PREVIOUS_VALUE_UNDEFINED -1 - -COLORREF highlightActivityColors[HIGHLIGHT_ACTIVITY_NUM_COLORS] = { 0x0, 0x004035, 0x185218, 0x5e5c34, 0x804c00, 0xba0300, 0xd10038, 0xb21272, 0xba00ab, 0x6f00b0, 0x3700c2, 0x000cba, 0x002cc9, 0x0053bf, 0x0072cf, 0x3c8bc7 }; - -string memviewhelp = "HexEditor"; //Hex Editor Help Page - -int HexRowHeightBorder = 0; //adelikat: This will determine the number of pixels between rows in the hex editor, to alter this, the user can change it in the .cfg file, changing one will revert to the way FCEUX2.1.0 did it -int HexCharSpacing = 1; // pixels between chars - -// Partial List of Color Definitions -int HexBackColorR = 255; // White -int HexBackColorG = 255; -int HexBackColorB = 255; -int HexForeColorR = 0; // Black -int HexForeColorG = 0; -int HexForeColorB = 0; -int HexFreezeColorR = 0; // Blue -int HexFreezeColorG = 0; -int HexFreezeColorB = 255; -int RomFreezeColorR = 255; // Red -int RomFreezeColorG = 0; -int RomFreezeColorB = 0; - -// This defines all of our right click popup menus -struct -{ - int minaddress; //The minimum address where this popup will appear - int maxaddress; //The maximum address where this popup will appear - int editingmode; //The editing mode which this popup appears in - int id; //The menu ID for this popup - char *text; //the text for the menu item (some of these need to be dynamic) -} -popupmenu[] = -{ - {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SYMBOLIC_NAME, "Add symbolic debug name"}, - {0x0000,0x2000, MODE_NES_MEMORY,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, - {0x6000,0x7FFF, MODE_NES_MEMORY,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, - {0x0000,0x3FFF, MODE_NES_PPU,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, - {0x0000,0x3FFF, MODE_NES_PPU,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_X,"Add Debugger Execute Breakpoint"}, - {0x8000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_SEEK_IN_ROM,"Go Here In ROM File"}, - {0x8000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_CREATE_GG_CODE,"Create Game Genie Code At This Address"}, - {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"}, -} ; - -#define POPUPNUM (sizeof popupmenu / sizeof popupmenu[0]) - -int LoadTableFile(); -void UnloadTableFile(); -void InputData(char *input); -int GetMemViewData(uint32 i); -int UpdateCheatColorCallB(char *name, uint32 a, uint8 v, int compare,int s,int type, void *data); //mbg merge 6/29/06 - added arg -int DeleteCheatCallB(char *name, uint32 a, uint8 v, int compare,int s,int type); //mbg merge 6/29/06 - added arg -// ################################## Start of SP CODE ########################### -void FreezeRam(int address, int mode, int final); -// ################################## End of SP CODE ########################### -int GetHexScreenCoordx(int offset); -int GetHexScreenCoordy(int offset); -int GetAddyFromCoord(int x,int y); -void AutoScrollFromCoord(int x,int y); -LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -BOOL CALLBACK MemFindCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -void FindNext(); -void OpenFindDialog(); -static int GetFileData(uint32 offset); -static int WriteFileData(uint32 offset,int data); - - -HWND hMemView, hMemFind; -HDC mDC; -//int tempdummy; -//char dummystr[100]; -int CurOffset; -int ClientHeight; -int NoColors; -int EditingMode; -int EditingText; -int AddyWasText; //used by the GetAddyFromCoord() function. -int TableFileLoaded; - -int MemView_wndx, MemView_wndy; -int MemFind_wndx, MemFind_wndy; -bool MemView_HighlightActivity = true; -unsigned int MemView_HighlightActivity_FadingPeriod = HIGHLIGHT_ACTIVITY_NUM_COLORS; -bool MemView_HighlightActivity_FadeWhenPaused = false; -int MemViewSizeX = 630, MemViewSizeY = 300; -static RECT newMemViewRect; - -static char chartable[256]; - -//SCROLLINFO memsi; -//HBITMAP HDataBmp; -//HGDIOBJ HDataObj; -HDC HDataDC; -int CursorX=2, CursorY=9; -int CursorStartAddy, CursorEndAddy = PREVIOUS_VALUE_UNDEFINED; -int CursorDragPoint;//, CursorShiftPoint = -1; -//int CursorStartNibble=1, CursorEndNibble; //1 means that only half of the byte is selected -int TempData = PREVIOUS_VALUE_UNDEFINED; -int DataAmount; -int MaxSize; - -COLORREF *BGColorList; -COLORREF *TextColorList; -int PreviousCurOffset; -int *PreviousValues; // for HighlightActivity feature and for speedhack too -unsigned int *HighlightedBytes; - -int lbuttondown, lbuttondownx, lbuttondowny; -int mousex, mousey; - -int FindAsText; -int FindDirectionUp; -char FindTextBox[60]; - -int temp_offset; - -extern iNES_HEADER head; - -//undo structure -struct UNDOSTRUCT { - int addr; - int size; - unsigned char *data; - UNDOSTRUCT *last; //mbg merge 7/18/06 removed struct qualifier -}; - -struct UNDOSTRUCT *undo_list=0; - -void resetHighlightingActivityLog() -{ - // clear the HighlightActivity data - for (int i = 0; i < DataAmount; ++i) - { - PreviousValues[i] = PREVIOUS_VALUE_UNDEFINED; - HighlightedBytes[i] = HIGHLIGHT_ACTIVITY_MIN_VALUE; - } -} - -void ApplyPatch(int addr,int size, uint8* data){ - UNDOSTRUCT *tmp=(UNDOSTRUCT*)malloc(sizeof(UNDOSTRUCT)); //mbg merge 7/18/06 removed struct qualifiers and added cast - - int i; - - //while(tmp != 0){tmp=tmp->next;x++;}; - //tmp = malloc(sizeof(struct UNDOSTRUCT)); - //sprintf(str,"%d",x); - //MessageBox(hMemView,str,"info", MB_OK); - tmp->addr = addr; - tmp->size = size; - tmp->data = (uint8*)malloc(sizeof(uint8)*size); - tmp->last=undo_list; - - for(i = 0;i < size;i++){ - tmp->data[i] = GetFileData((uint32)addr+i); - WriteFileData((uint32)addr+i,data[i]); - } - - undo_list=tmp; - - //UpdateColorTable(); - return; -} - -void UndoLastPatch(){ - struct UNDOSTRUCT *tmp=undo_list; - int i; - if(undo_list == 0)return; - //while(tmp->next != 0){tmp=tmp->next;}; //traverse to the one before the last one - - for(i = 0;i < tmp->size;i++){ - WriteFileData((uint32)tmp->addr+i,tmp->data[i]); - } - - undo_list=undo_list->last; - - ChangeMemViewFocus(2,tmp->addr, -1); //move to the focus to where we are undoing at. - - free(tmp->data); - free(tmp); - return; -} - -void GotoAddress(HWND hwnd) { - char* gotoaddressstring; - int gotoaddress; - char* gototitle; - - gototitle = (char*)malloc(18); - gotoaddressstring = (char*)malloc(8); - gotoaddressstring[0] = '\0'; - sprintf(gototitle, "%s%X%s", "Goto (0-", MaxSize-1, ")"); - if(CWin32InputBox::InputBox(gototitle, "Goto which address:", gotoaddressstring, 8, false, hwnd) == IDOK) - { - if(EOF != sscanf(gotoaddressstring, "%x", &gotoaddress)) - { - SetHexEditorAddress(gotoaddress); - } - } -} - -void SetHexEditorAddress(int gotoaddress) -{ - - if (gotoaddress < 0) - gotoaddress = 0; - if (gotoaddress > (MaxSize-1)) - gotoaddress = (MaxSize-1); - - CursorStartAddy = gotoaddress; - CursorEndAddy = -1; - ChangeMemViewFocus(EditingMode, CursorStartAddy, -1); -} - -static void FlushUndoBuffer(){ - struct UNDOSTRUCT *tmp; - while(undo_list!= 0){ - tmp=undo_list; - undo_list=undo_list->last; - free(tmp->data); - free(tmp); - } - UpdateColorTable(); - return; -} - - -static int GetFileData(uint32 offset){ - if(offset < 16) return *((unsigned char *)&head+offset); - if(offset < 16+PRGsize[0])return PRGptr[0][offset-16]; - if(offset < 16+PRGsize[0]+CHRsize[0])return CHRptr[0][offset-16-PRGsize[0]]; - return -1; -} - -static int WriteFileData(uint32 addr,int data){ - if (addr < 16)MessageBox(hMemView,"Sorry", "Go bug bbit if you really want to edit the header.", MB_OK); - if((addr >= 16) && (addr < PRGsize[0]+16)) *(uint8 *)(GetNesPRGPointer(addr-16)) = data; - if((addr >= PRGsize[0]+16) && (addr < CHRsize[0]+PRGsize[0]+16)) *(uint8 *)(GetNesCHRPointer(addr-16-PRGsize[0])) = data; - - return 0; -} - -static int GetRomFileSize(){ //todo: fix or remove this? - return 0; -} - -void SaveRomAs() -{ - const char filter[]="NES ROM file (*.nes)\0*.nes\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save Nes ROM as..."; - ofn.lpstrFilter=filter; - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - ofn.lpstrFile=nameo; - ofn.lpstrDefExt="nes"; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hMemView; - if (GetSaveFileName(&ofn)) - iNesSaveAs(nameo); -} - -int LoadTable(const char* nameo) -{ - char str[50]; - FILE *FP; - int i, line, charcode1, charcode2; - - for(i = 0;i < 256;i++){ - chartable[i] = 0; - } - - FP = fopen(nameo,"r"); - line = 0; - while((fgets(str, 45, FP)) != NULL){/* get one line from the file */ - line++; - - if(strlen(str) < 3)continue; - - charcode1 = charcode2 = -1; - - if((str[0] >= 'a') && (str[0] <= 'f')) charcode1 = str[0]-('a'-0xA); - if((str[0] >= 'A') && (str[0] <= 'F')) charcode1 = str[0]-('A'-0xA); - if((str[0] >= '0') && (str[0] <= '9')) charcode1 = str[0]-'0'; - - if((str[1] >= 'a') && (str[1] <= 'f')) charcode2 = str[1]-('a'-0xA); - if((str[1] >= 'A') && (str[1] <= 'F')) charcode2 = str[1]-('A'-0xA); - if((str[1] >= '0') && (str[1] <= '9')) charcode2 = str[1]-'0'; - - if(charcode1 == -1){ - UnloadTableFile(); - fclose(FP); - return line; //we have an error getting the first input - } - - if(charcode2 != -1) charcode1 = (charcode1<<4)|charcode2; - - for(i = 0;i < (int)strlen(str);i++)if(str[i] == '=')break; - - if(i == strlen(str)){ - UnloadTableFile(); - fclose(FP); - return line; //error no '=' found - } - - i++; - //ORing i with 32 just converts it to lowercase if it isn't - if(((str[i]|32) == 'r') && ((str[i+1]|32) == 'e') && ((str[i+2]|32) == 't')) - charcode2 = 0x0D; - else charcode2 = str[i]; - - chartable[charcode1] = charcode2; - } - TableFileLoaded = 1; - fclose(FP); - return -1; -} - -//should return -1, otherwise returns the line number it had the error on -int LoadTableFile() -{ - const char filter[]="Table Files (*.TBL)\0*.tbl\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Load Table File..."; - ofn.lpstrFilter=filter; - nameo[0]=0; - ofn.lpstrFile=nameo; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hMemView; - if(!GetOpenFileName(&ofn))return -1; - - int result = LoadTable(nameo); - return result; -} - -void UnloadTableFile(){ - int i, j; - for(i = 0;i < 256;i++){ - j = i; - if(j < 0x20)j = 0x2E; - //if(j > 0x7e)j = 0x2E; - chartable[i] = j; - } - TableFileLoaded = 0; - return; -} -void UpdateMemoryView(int draw_all) -{ - if (!hMemView) return; - int MemFontWidth = debugSystem->HexeditorFontWidth + HexCharSpacing; - int MemFontHeight = debugSystem->HexeditorFontHeight + HexRowHeightBorder; - - int i, j; - int byteValue; - int byteHighlightingValue; - //LPVOID lpMsgBuf; - //int curlength; - char str[100]; - - if (PreviousCurOffset != CurOffset) - resetHighlightingActivityLog(); - - /* - if(draw_all){ - for(i = CurOffset;i < CurOffset+DataAmount;i+=16){ - MoveToEx(HDataDC,0,MemFontHeight*((i-CurOffset)/16),NULL); - sprintf(str,"%06X: ",i); - for(j = 0;j < 16;j++){ - sprintf(str2,"%02X ",GetMem(i+j)); - strcat(str,str2); - } - strcat(str," : "); - k = strlen(str); - for(j = 0;j < 16;j++){ - str[k+j] = GetMem(i+j); - if(str[k+j] < 0x20)str[k+j] = 0x2E; - if(str[k+j] > 0x7e)str[k+j] = 0x2E; - } - str[k+16] = 0; - TextOut(HDataDC,0,0,str,strlen(str)); - } - } else {*/ - for (i = CurOffset; i < CurOffset + DataAmount; i += 16) - { - if ((PreviousCurOffset != CurOffset) || draw_all) - { - MoveToEx(HDataDC,0,MemFontHeight*((i-CurOffset)/16),NULL); - SetTextColor(HDataDC,RGB(HexForeColorR,HexForeColorG,HexForeColorB)); //addresses text color 000 = black, 255255255 = white - SetBkColor(HDataDC,RGB(HexBackColorR,HexBackColorG,HexBackColorB)); //addresses back color - sprintf(str,"%06X: ",i); - TextOut(HDataDC,0,0,str,strlen(str)); - } - for(j = 0;j < 16;j++) - { - byteValue = GetMemViewData(i+j); - if (MemView_HighlightActivity && ((PreviousValues[i+j-CurOffset] != byteValue) && (PreviousValues[i+j-CurOffset] != PREVIOUS_VALUE_UNDEFINED))) - byteHighlightingValue = HighlightedBytes[i+j-CurOffset] = MemView_HighlightActivity_FadingPeriod; - else - byteHighlightingValue = HighlightedBytes[i+j-CurOffset]; - - if ((CursorEndAddy == -1) && (CursorStartAddy == i+j)) - { - //print up single highlighted text - MoveToEx(HDataDC, 8 * MemFontWidth + (j * 3 * MemFontWidth), MemFontHeight * ((i - CurOffset) / 16), NULL); - if(TempData != PREVIOUS_VALUE_UNDEFINED) - { - // User is typing New Data - // 1st nybble - sprintf(str,"%X",TempData); - SetBkColor(HDataDC,RGB(255,255,255)); - SetTextColor(HDataDC,RGB(255,0,0)); - TextOut(HDataDC,0,0,str,1); - // 2nd nybble - MoveToEx(HDataDC, MemFontWidth + 8 * MemFontWidth + (j * 3 * MemFontWidth), MemFontHeight * ((i - CurOffset) / 16), NULL); - sprintf(str,"%X", byteValue % 16); - SetTextColor(HDataDC,RGB(HexBackColorR,HexBackColorG,HexBackColorB)); - SetBkColor(HDataDC,RGB(HexForeColorR,HexForeColorG,HexForeColorB)); - TextOut(HDataDC, 0, 0, str, 1); - } else - { - // Selecting a Single Byte - sprintf(str,"%X",(int)(byteValue / 16)); - SetTextColor(HDataDC,RGB(255,255,255)); //single address highlight - SetBkColor(HDataDC,RGB(0,0,0)); - TextOut(HDataDC,0,0,str,1); - // 2nd nybble - MoveToEx(HDataDC, MemFontWidth + 8 * MemFontWidth + (j * 3 * MemFontWidth), MemFontHeight * ((i - CurOffset) / 16), NULL); - sprintf(str,"%X", byteValue % 16); - SetTextColor(HDataDC,TextColorList[i+j-CurOffset]); - SetBkColor(HDataDC,BGColorList[i+j-CurOffset]); - TextOut(HDataDC,0,0,str,1); - } - //TextOut(HDataDC,0,0," ",1); - - // single address highlight - right column - SetTextColor(HDataDC,RGB(255,255,255)); - SetBkColor(HDataDC,RGB(0,0,0)); - MoveToEx(HDataDC, (59 + j) * MemFontWidth, MemFontHeight * ((i - CurOffset) / 16), NULL); //todo: try moving this above the for loop - str[0] = chartable[byteValue]; - if(str[0] < 0x20)str[0] = 0x2E; - //if(str[0] > 0x7e)str[0] = 0x2E; - str[1] = 0; - TextOut(HDataDC,0,0,str,1); - - PreviousValues[i+j-CurOffset] = PREVIOUS_VALUE_UNDEFINED; //set it to redraw this one next time - } else if (draw_all || (PreviousValues[i+j-CurOffset] != byteValue) || byteHighlightingValue) - { - // print up normal text - if (byteHighlightingValue) - { - // fade out 1 step - if (MemView_HighlightActivity_FadeWhenPaused || !FCEUI_EmulationPaused() || JustFrameAdvanced) - byteHighlightingValue = (--HighlightedBytes[i+j-CurOffset]); - - if (byteHighlightingValue > 0) - { - if (byteHighlightingValue == MemView_HighlightActivity_FadingPeriod - 1 || byteHighlightingValue >= HIGHLIGHT_ACTIVITY_NUM_COLORS) - // if the byte was changed in current frame, use brightest color, even if the "fading period" demands different color - // also use the last color if byteHighlightingValue points outside the array of predefined colors - SetTextColor(HDataDC, highlightActivityColors[HIGHLIGHT_ACTIVITY_NUM_COLORS - 1]); - else - SetTextColor(HDataDC, highlightActivityColors[byteHighlightingValue]); - - } else - { - SetTextColor(HDataDC,TextColorList[i+j-CurOffset]); - } - } else - { - SetTextColor(HDataDC,TextColorList[i+j-CurOffset]);//(8+j*3)*MemFontWidth - } - SetBkColor(HDataDC,BGColorList[i+j-CurOffset]); - MoveToEx(HDataDC, 8 * MemFontWidth + (j * 3 * MemFontWidth), MemFontHeight * ((i - CurOffset) / 16),NULL); - sprintf(str,"%X", (int)(byteValue / 16)); - TextOut(HDataDC, 0, 0, str, 1); - MoveToEx(HDataDC, MemFontWidth + 8 * MemFontWidth + (j * 3 * MemFontWidth), MemFontHeight * ((i - CurOffset) / 16),NULL); - sprintf(str,"%X", byteValue % 16); - TextOut(HDataDC, 0, 0, str, 1); - - MoveToEx(HDataDC,(59+j)*MemFontWidth,MemFontHeight*((i-CurOffset)/16),NULL); //todo: try moving this above the for loop - str[0] = chartable[byteValue]; - if(str[0] < 0x20)str[0] = 0x2E; - //if(str[0] > 0x7e)str[0] = 0x2E; - str[1] = 0; - TextOut(HDataDC,0,0,str,1); - - PreviousValues[i+j-CurOffset] = byteValue; - } - } - - if(draw_all) - { - MoveToEx(HDataDC,56*MemFontWidth,MemFontHeight*((i-CurOffset)/16),NULL); - SetTextColor(HDataDC,RGB(HexForeColorR,HexForeColorG,HexForeColorB)); //Column separator - SetBkColor(HDataDC,RGB(HexBackColorR,HexBackColorG,HexBackColorB)); - TextOut(HDataDC,0,0," : ",3); - } - /* - for(j = 0;j < 16;j++){ - if((OldValues[i+j-CurOffset] != GetMem(i+j)) || draw_all){ - MoveToEx(HDataDC,(59+j)*MemFontWidth,MemFontHeight*((i-CurOffset)/16),NULL); //todo: try moving this above the for loop - SetTextColor(HDataDC,TextColorList[i+j-CurOffset]); - SetBkColor(HDataDC,BGColorList[i+j-CurOffset]); - str[0] = GetMem(i+j); - if(str[0] < 0x20)str[0] = 0x2E; - if(str[0] > 0x7e)str[0] = 0x2E; - str[1] = 0; - TextOut(HDataDC,0,0,str,1); - if(CursorStartAddy != i+j)OldValues[i+j-CurOffset] = GetMem(i+j); - } - } - */ - } - // } - - SetTextColor(HDataDC,RGB(0,0,0)); - SetBkColor(HDataDC,RGB(0,0,0)); - - MoveToEx(HDataDC,0,0,NULL); - PreviousCurOffset = CurOffset; - return; -} - -char EditString[3][20] = {"RAM","PPU","ROM"}; - -void UpdateCaption() -{ - static char str[1000]; - - if (CursorEndAddy == -1) - { - if (EditingMode == MODE_NES_FILE) - { - if (CursorStartAddy < 16) - sprintf(str, "Hex Editor - ROM Header Offset 0x%06x", CursorStartAddy); - else if (CursorStartAddy - 16 < (int)PRGsize[0]) - sprintf(str, "Hex Editor - (PRG) ROM Offset 0x%06x", CursorStartAddy); - else if (CursorStartAddy - 16 - PRGsize[0] < (int)CHRsize[0]) - sprintf(str, "Hex Editor - (CHR) ROM Offset 0x%06x", CursorStartAddy); - } else - { - sprintf(str, "Hex Editor - %s Offset 0x%06x", EditString[EditingMode], CursorStartAddy); - } - - if (EditingMode == MODE_NES_MEMORY && symbDebugEnabled) - { - // when watching RAM we may as well see Symbolic Debug names - Name* node = findNode(getNamesPointerForAddress(CursorStartAddy), CursorStartAddy); - if (node) - { - strcat(str, " - "); - strcat(str, node->name); - } - } - } else - { - sprintf(str, "Hex Editor - %s Offset 0x%06x - 0x%06x, 0x%x bytes selected ", - EditString[EditingMode], CursorStartAddy, CursorEndAddy, CursorEndAddy - CursorStartAddy + 1); - } - SetWindowText(hMemView,str); - return; -} - -int GetMemViewData(uint32 i) -{ - if (EditingMode == MODE_NES_MEMORY) - return GetMem(i); - - if (EditingMode == MODE_NES_PPU) - { - i &= 0x3FFF; - if(i < 0x2000)return VPage[(i)>>10][(i)]; - //NSF PPU Viewer crash here (UGETAB) (Also disabled by 'MaxSize = 0x2000') - if (GameInfo->type==GIT_NSF) - { - return (0); - } else - { - if(i < 0x3F00) - return vnapage[(i>>10)&0x3][i&0x3FF]; - return PALRAM[i&0x1F]; - } - } - - if (EditingMode == MODE_NES_FILE) - { - //todo: use getfiledata() here - if(i < 16) return *((unsigned char *)&head+i); - if(i < 16+PRGsize[0])return PRGptr[0][i-16]; - if(i < 16+PRGsize[0]+CHRsize[0])return CHRptr[0][i-16-PRGsize[0]]; - } - return 0; -} - -void UpdateColorTable() -{ - UNDOSTRUCT *tmp; //mbg merge 7/18/06 removed struct qualifier - int i,j; - if(!hMemView)return; - for(i = 0;i < DataAmount;i++) - { - if((i+CurOffset >= CursorStartAddy) && (i+CurOffset <= CursorEndAddy)) - { - BGColorList[i] = RGB(HexForeColorR,HexForeColorG,HexForeColorB); //Highlighter color bg - 2 columns - TextColorList[i] = RGB(HexBackColorR,HexBackColorG,HexBackColorB); //Highlighter color text - 2 columns - continue; - } - - BGColorList[i] = RGB(HexBackColorR,HexBackColorG,HexBackColorB); //Regular color bb - 2columns - TextColorList[i] = RGB(HexForeColorR,HexForeColorG,HexForeColorB); //Regular color text - 2 columns - } - - // ################################## Start of SP CODE ########################### - - for (j=0;j= CurOffset) && ((int)hexBookmarks[j].address < CurOffset+DataAmount)) - TextColorList[hexBookmarks[j].address - CurOffset] = RGB(0,0xCC,0); // Green for Bookmarks - } - - // ################################## End of SP CODE ########################### - - //mbg merge 6/29/06 - added argument - if (EditingMode == MODE_NES_MEMORY) - FCEUI_ListCheats(UpdateCheatColorCallB, 0); - - if(EditingMode == MODE_NES_FILE) - { - if (cdloggerdataSize) - { - for (i = 0; i < DataAmount; i++) - { - temp_offset = CurOffset + i - 16; // (minus iNES header) - if (temp_offset >= 0) - { - if ((unsigned int)temp_offset < cdloggerdataSize) - { - // PRG - if ((cdloggerdata[temp_offset] & 3) == 3) - { - // the byte is both Code and Data - green - TextColorList[i]=RGB(0,190,0); - } else if((cdloggerdata[temp_offset] & 3) == 1) - { - // the byte is Code - dark-yellow - TextColorList[i]=RGB(160,140,0); - } else if((cdloggerdata[temp_offset] & 3) == 2) - { - // the byte is Data - blue/cyan - if (cdloggerdata[temp_offset] & 0x40) - // PCM data - cyan - TextColorList[i]=RGB(0,130,160); - else - // non-PCM data - blue - TextColorList[i]=RGB(0,0,210); - } - } else - { - temp_offset -= cdloggerdataSize; - if (((unsigned int)temp_offset < cdloggerVideoDataSize)) - { - // CHR - if ((cdloggervdata[temp_offset] & 3) == 3) - { - // the byte was both rendered and read programmatically - light-green - TextColorList[i]=RGB(5,255,5); - } else if ((cdloggervdata[temp_offset] & 3) == 1) - { - // the byte was rendered - yellow - TextColorList[i]=RGB(210,190,0); - } else if ((cdloggervdata[temp_offset] & 3) == 2) - { - // the byte was read programmatically - light-blue - TextColorList[i]=RGB(15,15,255); - } - } - } - } - } - } - - tmp = undo_list; - while(tmp!= 0) - { - //if((tmp->addr < CurOffset+DataAmount) && (tmp->addr+tmp->size > CurOffset)) - for(i = tmp->addr;i < tmp->addr+tmp->size;i++){ - if((i > CurOffset) && (i < CurOffset+DataAmount)) - TextColorList[i-CurOffset] = RGB(RomFreezeColorR,RomFreezeColorG,RomFreezeColorB); - } - tmp=tmp->last; - } - } - - UpdateMemoryView(1); //anytime the colors change, the memory viewer needs to be completely redrawn -} - -//mbg merge 6/29/06 - added argument -int UpdateCheatColorCallB(char *name, uint32 a, uint8 v, int compare,int s,int type, void *data) { - - if((a >= (uint32)CurOffset) && (a < (uint32)CurOffset+DataAmount)){ - if(s)TextColorList[a-CurOffset] = RGB(HexFreezeColorR,HexFreezeColorG,HexFreezeColorB); - } - return 1; -} - -int addrtodelete; // This is a very ugly hackish method of doing this -int cheatwasdeleted; // but it works and that is all that matters here. -int DeleteCheatCallB(char *name, uint32 a, uint8 v, int compare,int s,int type, void *data){ //mbg merge 6/29/06 - added arg - if(cheatwasdeleted == -1)return 1; - cheatwasdeleted++; - if(a == addrtodelete){ - FCEUI_DelCheat(cheatwasdeleted-1); - cheatwasdeleted = -1; - return 0; - } - return 1; -} - -// ################################## Start of SP CODE ########################### - -void dumpToFile(const char* buffer, unsigned int size) -{ - char name[513] = {0}; - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save to file ..."; - ofn.lpstrFilter="Binary File (*.BIN)\0*.bin\0All Files (*.*)\0*.*\0\0"; - strcpy(name, mass_replace(GetRomName(), "|", ".").c_str()); - ofn.lpstrFile=name; - ofn.lpstrDefExt="bin"; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY; - - if (GetSaveFileName(&ofn)) - { - FILE* memfile = fopen(name, "wb"); - - if (!memfile || fwrite(buffer, 1, size, memfile) != size) - { - MessageBox(0, "Saving failed", "Error", 0); - } - - if (memfile) - fclose(memfile); - } -} - -void UnfreezeAllRam() { - - int i=0; - - char * Cname; - uint32 Caddr; - int Ctype; - - // Get last cheat number + 1 - while (FCEUI_GetCheat(i,NULL,NULL,NULL,NULL,NULL,NULL)) { - i = i + 1; - } - - // Subtract 1 to be on last cheat - i = i - 1; - - while (i >= 0) { - - // Since this is automated, only remove unnamed variables, as they - // would be added by the freeze command. Manual unfreeze should let them - // make that mistake once or twice, in case they like it that way. - FCEUI_GetCheat(i,&Cname,&Caddr,NULL,NULL,NULL,&Ctype); - if ((Cname[0] == '\0') && ((Caddr < 0x2000) || ((Caddr >= 0x6000) && (Caddr < 0x8000))) && (Ctype == 1)) { - // Already Added, so consider it a success - FreezeRam(Caddr,-1,1); - - } - - i = i - 1; - } - - return; -} - - -void FreezeRam(int address, int mode, int final){ - // mode: -1 == Unfreeze; 0 == Toggle; 1 == Freeze - // ################################## End of SP CODE ########################### - if(FrozenAddressCount <= 256 && (address < 0x2000) || ((address >= 0x6000) && (address <= 0x7FFF))){ - //adelikat: added FrozenAddressCount check to if statement to prevent user from freezing more than 256 address (unfreezing when > 256 crashes) - addrtodelete = address; - cheatwasdeleted = 0; - - // ################################## Start of SP CODE ########################### - if (mode == 0 || mode == -1) - { - //mbg merge 6/29/06 - added argument - FCEUI_ListCheats(DeleteCheatCallB,0); - if(mode == 0 && cheatwasdeleted != -1)FCEUI_AddCheat("",address,GetMem(address),-1,1); - } - else - { - //mbg merge 6/29/06 - added argument - FCEUI_ListCheats(DeleteCheatCallB,0); - FCEUI_AddCheat("",address,GetMem(address),-1,1); - } - // ################################## End of SP CODE ########################### - - //if (final) - //{ - //if(hCheat)RedoCheatsLB(hCheat); - UpdateColorTable(); - //} - - UpdateCheatsAdded(); - } -} - -//input is expected to be an ASCII string -void InputData(char *input){ - //CursorEndAddy = -1; - int addr, i, j, datasize = 0; - unsigned char *data; - char inputc; - //char str[100]; - //mbg merge 7/18/06 added cast: - data = (uint8 *)malloc(strlen(input) + 1); //it can't be larger than the input string, so use that as the size - - for(i = 0;input[i] != 0;i++){ - if(!EditingText){ - inputc = -1; - if((input[i] >= 'a') && (input[i] <= 'f')) inputc = input[i]-('a'-0xA); - if((input[i] >= 'A') && (input[i] <= 'F')) inputc = input[i]-('A'-0xA); - if((input[i] >= '0') && (input[i] <= '9')) inputc = input[i]-'0'; - if(inputc == -1)continue; - - if(TempData != PREVIOUS_VALUE_UNDEFINED) - { - data[datasize++] = inputc|(TempData<<4); - TempData = PREVIOUS_VALUE_UNDEFINED; - } else - { - TempData = inputc; - } - } else { - for(j = 0;j < 256;j++)if(chartable[j] == input[i])break; - if(j == 256)continue; - data[datasize++] = j; - } - } - - if(datasize+CursorStartAddy >= MaxSize){ //too big - datasize = MaxSize-CursorStartAddy; - //free(data); - //return; - } - - //its possible for this loop not to get executed at all - // for(addr = CursorStartAddy;addr < datasize+CursorStartAddy;addr++){ - //sprintf(str,"datasize = %d",datasize); - //MessageBox(hMemView,str, "debug", MB_OK); - - for(i = 0;i < datasize;i++){ - addr = CursorStartAddy+i; - - if (EditingMode == MODE_NES_MEMORY) - { - // RAM (system bus) - BWrite[addr](addr,data[i]); - } else if (EditingMode == MODE_NES_PPU) - { - // PPU - addr &= 0x3FFF; - if(addr < 0x2000) - VPage[addr>>10][addr] = data[i]; //todo: detect if this is vrom and turn it red if so - if((addr >= 0x2000) && (addr < 0x3F00)) - vnapage[(addr>>10)&0x3][addr&0x3FF] = data[i]; //todo: this causes 0x3000-0x3f00 to mirror 0x2000-0x2f00, is this correct? - if((addr >= 0x3F00) && (addr < 0x3FFF)) - PALRAM[addr&0x1F] = data[i]; - } else if (EditingMode == MODE_NES_FILE) - { - // ROM - ApplyPatch(addr,datasize,data); - break; - } - } - CursorStartAddy+=datasize; - CursorEndAddy=-1; - if(CursorStartAddy >= MaxSize)CursorStartAddy = MaxSize-1; - - free(data); - ChangeMemViewFocus(EditingMode, CursorStartAddy, -1); - UpdateColorTable(); - return; -} -/* -if(!EditingText){ -if((input >= 'a') && (input <= 'f')) input-=('a'-0xA); -if((input >= 'A') && (input <= 'F')) input-=('A'-0xA); -if((input >= '0') && (input <= '9')) input-='0'; -if(input > 0xF)return; - -if(TempData != -1){ -addr = CursorStartAddy; -data = input|(TempData<<4); -if(EditingMode == MODE_NES_MEMORY)BWrite[addr](addr,data); -if(EditingMode == MODE_NES_PPU){ -addr &= 0x3FFF; -if(addr < 0x2000)VPage[addr>>10][addr] = data; //todo: detect if this is vrom and turn it red if so -if((addr > 0x2000) && (addr < 0x3F00))vnapage[(addr>>10)&0x3][addr&0x3FF] = data; //todo: this causes 0x3000-0x3f00 to mirror 0x2000-0x2f00, is this correct? -if((addr > 0x3F00) && (addr < 0x3FFF))PALRAM[addr&0x1F] = data; -} -if(EditingMode == MODE_NES_FILE)ApplyPatch(addr,1,(uint8 *)&data); -CursorStartAddy++; -TempData = PREVIOUS_VALUE_UNDEFINED; -} else { -TempData = input; -} -} else { -for(i = 0;i < 256;i++)if(chartable[i] == input)break; -if(i == 256)return; - -addr = CursorStartAddy; -data = i; -if(EditingMode == MODE_NES_MEMORY)BWrite[addr](addr,data); -if(EditingMode == MODE_NES_FILE)ApplyPatch(addr,1,(uint8 *)&data); -CursorStartAddy++; -} -*/ - - -void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset){ - SCROLLINFO si; - - //if (GameInfo->type==GIT_NSF) { - // FCEUD_PrintError("Sorry, you can't yet use the Memory Viewer with NSFs."); - // return; - //} - - if(!hMemView)DoMemView(); - if(EditingMode != newEditingMode) - MemViewCallB(hMemView,WM_COMMAND,MENU_MV_VIEW_RAM+newEditingMode,0); //let the window handler change this for us - - if((EndOffset == StartOffset) || (EndOffset == -1)){ - CursorEndAddy = -1; - CursorStartAddy = StartOffset; - } else { - CursorStartAddy = std::min(StartOffset,EndOffset); - CursorEndAddy = std::max(StartOffset,EndOffset); - } - - - if(std::min(StartOffset,EndOffset) >= MaxSize)return; //this should never happen - - if(StartOffset < CurOffset){ - CurOffset = (StartOffset/16)*16; - } - - if(StartOffset >= CurOffset+DataAmount){ - CurOffset = ((StartOffset/16)*16)-DataAmount+0x10; - if(CurOffset < 0)CurOffset = 0; - } - - SetFocus(hMemView); - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_POS; - si.cbSize = sizeof(SCROLLINFO); - si.nPos = CurOffset/16; - SetScrollInfo(hMemView,SB_VERT,&si,TRUE); - UpdateCaption(); - UpdateColorTable(); - return; -} - - -int GetHexScreenCoordx(int offset) -{ - return (8 * (debugSystem->HexeditorFontWidth + HexCharSpacing)) + ((offset % 16) * 3 * (debugSystem->HexeditorFontWidth + HexCharSpacing)); //todo: add Curoffset to this and to below function -} - -int GetHexScreenCoordy(int offset) -{ - return (offset / 16) * (debugSystem->HexeditorFontHeight + HexRowHeightBorder); -} - -//0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................ - -//if the mouse is in the text field, this function will set AddyWasText to 1 otherwise it is 0 -//if the mouse wasn't in any range, this function returns -1 -int GetAddyFromCoord(int x,int y) -{ - int MemFontWidth = debugSystem->HexeditorFontWidth + HexCharSpacing; - int MemFontHeight = debugSystem->HexeditorFontHeight + HexRowHeightBorder; - - if(y < 0)y = 0; - if(x < 8*MemFontWidth)x = 8*MemFontWidth+1; - - if(y > DataAmount*MemFontHeight) return -1; - - if(x < 55*MemFontWidth){ - AddyWasText = 0; - return ((y/MemFontHeight)*16)+((x-(8*MemFontWidth))/(3*MemFontWidth))+CurOffset; - } - - if((x > 59*MemFontWidth) && (x < 75*MemFontWidth)){ - AddyWasText = 1; - return ((y/MemFontHeight)*16)+((x-(59*MemFontWidth))/(MemFontWidth))+CurOffset; - } - - return -1; -} - -void AutoScrollFromCoord(int x,int y) -{ - SCROLLINFO si; - if(y < 0){ - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_ALL; - si.cbSize = sizeof(SCROLLINFO); - GetScrollInfo(hMemView,SB_VERT,&si); - si.nPos += y / 16; - if (si.nPos < si.nMin) si.nPos = si.nMin; - if ((si.nPos+(int)si.nPage) > si.nMax) si.nPos = si.nMax-si.nPage; - CurOffset = si.nPos*16; - SetScrollInfo(hMemView,SB_VERT,&si,TRUE); - return; - } - - if(y > ClientHeight){ - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_ALL; - si.cbSize = sizeof(SCROLLINFO); - GetScrollInfo(hMemView,SB_VERT,&si); - si.nPos -= (ClientHeight-y) / 16; - if (si.nPos < si.nMin) si.nPos = si.nMin; - if ((si.nPos+(int)si.nPage) > si.nMax) si.nPos = si.nMax-si.nPage; - CurOffset = si.nPos*16; - SetScrollInfo(hMemView,SB_VERT,&si,TRUE); - return; - } -} - -void KillMemView() -{ - ReleaseDC(hMemView,mDC); - DestroyWindow(hMemView); - UnregisterClass("MEMVIEW",fceu_hInstance); - hMemView = 0; - hMemFind = 0; - return; -} - -LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - HGLOBAL hGlobal ; - PTSTR pGlobal ; - HMENU hMenu; - MENUITEMINFO MenuInfo; - POINT point; - PAINTSTRUCT ps ; - TEXTMETRIC tm; - SCROLLINFO si; - int x, y, i, j; - int bank = -1; - int tempAddy; - const int MemFontWidth = debugSystem->HexeditorFontWidth; - const int MemFontHeight = debugSystem->HexeditorFontHeight + HexRowHeightBorder; - - char c[2]; - char str[100]; - // ################################## Start of SP CODE ########################### - extern int debuggerWasActive; - // ################################## End of SP CODE ########################### - - switch (message) { - - case WM_ENTERMENULOOP:return 0; - case WM_INITMENUPOPUP: - if(undo_list != 0)EnableMenuItem(GetMenu(hMemView),MENU_MV_EDIT_UNDO,MF_BYCOMMAND | MF_ENABLED); - else EnableMenuItem(GetMenu(hMemView),MENU_MV_EDIT_UNDO,MF_BYCOMMAND | MF_GRAYED); - - if(TableFileLoaded)EnableMenuItem(GetMenu(hMemView),MENU_MV_FILE_UNLOAD_TBL,MF_BYCOMMAND | MF_ENABLED); - else EnableMenuItem(GetMenu(hMemView),MENU_MV_FILE_UNLOAD_TBL,MF_BYCOMMAND | MF_GRAYED); - - return 0; - - case WM_CREATE: - SetWindowPos(hwnd,0,MemView_wndx,MemView_wndy,MemViewSizeX,MemViewSizeY,SWP_NOZORDER|SWP_NOOWNERZORDER); - - // ################################## Start of SP CODE ########################### - debuggerWasActive = 1; - // ################################## End of SP CODE ########################### - mDC = GetDC(hwnd); - HDataDC = mDC;//deleteme - SelectObject (HDataDC, debugSystem->hHexeditorFont); - SetTextAlign(HDataDC,TA_UPDATECP | TA_TOP | TA_LEFT); - - GetTextMetrics (HDataDC, &tm); - - MaxSize = 0x10000; - //Allocate Memory for color lists - DataAmount = 0x100; - //mbg merge 7/18/06 added casts: - TextColorList = (COLORREF*)malloc(DataAmount*sizeof(COLORREF)); - BGColorList = (COLORREF*)malloc(DataAmount*sizeof(COLORREF)); - PreviousValues = (int*)malloc(DataAmount*sizeof(int)); - HighlightedBytes = (unsigned int*)malloc(DataAmount*sizeof(unsigned int)); - resetHighlightingActivityLog(); - EditingText = CurOffset = 0; - EditingMode = MODE_NES_MEMORY; - - //set the default table - UnloadTableFile(); - UpdateColorTable(); //draw it - - // update menus - for (i = MODE_NES_MEMORY; i <= MODE_NES_FILE; i++) - { - CheckMenuItem(GetMenu(hwnd), MENU_MV_VIEW_RAM + i, (EditingMode == i) ? MF_CHECKED : MF_UNCHECKED); - } - CheckMenuItem(GetMenu(hwnd), ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY, (MemView_HighlightActivity) ? MF_CHECKED: MF_UNCHECKED); - CheckMenuItem(GetMenu(hwnd), ID_HIGHLIGHTING_FADEWHENPAUSED, (MemView_HighlightActivity_FadeWhenPaused) ? MF_CHECKED: MF_UNCHECKED); - - updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS)); - return 0; - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - EndPaint(hwnd, &ps); - UpdateMemoryView(1); - return 0; - - case WM_DROPFILES: - { - UINT len; - char *ftmp; - - len=DragQueryFile((HDROP)wParam,0,0,0)+1; - if((ftmp=(char*)malloc(len))) - { - DragQueryFile((HDROP)wParam,0,ftmp,len); - string fileDropped = ftmp; - //adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking - //------------------------------------------------------- - //Check if .tbl - //------------------------------------------------------- - if (!(fileDropped.find(".tbl") == string::npos) && (fileDropped.find(".tbl") == fileDropped.length()-4)) - { - LoadTable(fileDropped.c_str()); - } - else - { - std::string str = "Could not open " + fileDropped; - MessageBox(hwnd, str.c_str(), "File error", 0); - } - } - } - break; - case WM_VSCROLL: - - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_ALL; - si.cbSize = sizeof(SCROLLINFO); - GetScrollInfo(hwnd,SB_VERT,&si); - switch(LOWORD(wParam)) { - case SB_ENDSCROLL: - case SB_TOP: - case SB_BOTTOM: break; - case SB_LINEUP: si.nPos--; break; - case SB_LINEDOWN:si.nPos++; break; - case SB_PAGEUP: si.nPos-=si.nPage; break; - case SB_PAGEDOWN: si.nPos+=si.nPage; break; - case SB_THUMBPOSITION: //break; - case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; - } - if (si.nPos < si.nMin) si.nPos = si.nMin; - if ((si.nPos+(int)si.nPage) > si.nMax) si.nPos = si.nMax-si.nPage; //mbg merge 7/18/06 added cast - CurOffset = si.nPos*16; - SetScrollInfo(hwnd,SB_VERT,&si,TRUE); - UpdateColorTable(); - return 0; - case WM_CHAR: - if(GetKeyState(VK_CONTROL) & 0x8000)return 0; //prevents input when pressing ctrl+c - c[0] = (char)(wParam&0xFF); - c[1] = 0; - //sprintf(str,"c[0] = %c c[1] = %c",c[0],c[1]); - //MessageBox(hMemView,str, "debug", MB_OK); - InputData(c); - UpdateColorTable(); - UpdateCaption(); - return 0; - - case WM_KEYDOWN: - //if((wParam >= 0x30) && (wParam <= 0x39))InputData(wParam-0x30); - //if((wParam >= 0x41) && (wParam <= 0x46))InputData(wParam-0x41+0xA); - /*if(!((GetKeyState(VK_LSHIFT) & 0x8000) || (GetKeyState(VK_RSHIFT) & 0x8000))){ - //MessageBox(hMemView,"nobody", "mouse wheel dance!", MB_OK); - CursorShiftPoint = -1; - } - if(((GetKeyState(VK_LSHIFT) & 0x8000) || (GetKeyState(VK_RSHIFT) & 0x8000)) && - (CursorShiftPoint == -1)){ - CursorShiftPoint = CursorStartAddy; - //MessageBox(hMemView,"somebody", "mouse wheel dance!", MB_OK); - }*/ - - if(GetKeyState(VK_CONTROL) & 0x8000){ - - // ################################## Start of SP CODE ########################### - - if (wParam >= '0' && wParam <= '9') - { - int newValue = handleBookmarkMenu(wParam - '0'); - - if (newValue != -1) - { - CurOffset = newValue; - CursorEndAddy = -1; - CursorStartAddy = hexBookmarks[wParam - '0'].address; - UpdateColorTable(); - } - } - - // ################################## End of SP CODE ########################### - - switch(wParam){ - case 0x43: //Ctrl+C - MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_COPY,0); //recursion at work - return 0; - case 0x56: //Ctrl+V - MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_PASTE,0); - return 0; - case 0x5a: //Ctrl+Z - UndoLastPatch(); break; - case 0x41: //Ctrl+A - // Fall through to Ctrl+G - case 0x47: //Ctrl+G - GotoAddress(hwnd); break; - case 0x46: //Ctrl+F - OpenFindDialog(); break; - } - } - - //if(CursorShiftPoint == -1){ - if(wParam == VK_LEFT)CursorStartAddy--; - if(wParam == VK_RIGHT)CursorStartAddy++; - if(wParam == VK_UP)CursorStartAddy-=16; - if(wParam == VK_DOWN)CursorStartAddy+=16; - /*} else { - if(wParam == VK_LEFT)CursorShiftPoint--; - if(wParam == VK_RIGHT)CursorShiftPoint++; - if(wParam == VK_UP)CursorShiftPoint-=16; - if(wParam == VK_DOWN)CursorShiftPoint+=16; - if(CursorShiftPoint < CursorStartAddy){ - if(CursorEndAddy == -1)CursorEndAddy = CursorStartAddy; - CursorStartAddy = CursorShiftPoint; - } - //if(CursorShiftPoint > CursorEndAddy)CursorEndAddy = CursorShiftPoint; - }*/ - - //if(CursorStartAddy == CursorEndAddy)CursorEndAddy = -1; - if(CursorStartAddy < 0)CursorStartAddy = 0; - if(CursorStartAddy >= MaxSize)CursorStartAddy = MaxSize-1; //todo: fix this up when I add support for editing more stuff - - if((wParam == VK_DOWN) || (wParam == VK_UP) || - (wParam == VK_RIGHT) || (wParam == VK_LEFT)){ - CursorEndAddy = -1; - TempData = PREVIOUS_VALUE_UNDEFINED; - if(CursorStartAddy < CurOffset) CurOffset = (CursorStartAddy/16)*16; - if(CursorStartAddy > CurOffset+DataAmount-0x10)CurOffset = ((CursorStartAddy-DataAmount+0x10)/16)*16; - } - - if(wParam == VK_PRIOR)CurOffset-=DataAmount; - if(wParam == VK_NEXT)CurOffset+=DataAmount; - if(CurOffset < 0)CurOffset = 0; - if(CurOffset >= MaxSize)CurOffset = MaxSize-1; - /* - if((wParam == VK_PRIOR) || (wParam == VK_NEXT)){ - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_ALL; - si.cbSize = sizeof(SCROLLINFO); - GetScrollInfo(hwnd,SB_VERT,&si); - if(wParam == VK_PRIOR)si.nPos-=si.nPage; - if(wParam == VK_NEXT)si.nPos+=si.nPage; - if (si.nPos < si.nMin) si.nPos = si.nMin; - if ((si.nPos+si.nPage) > si.nMax) si.nPos = si.nMax-si.nPage; - CurOffset = si.nPos*16; - } - */ - - //This updates the scroll bar to curoffset - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_POS; - si.cbSize = sizeof(SCROLLINFO); - si.nPos = CurOffset/16; - SetScrollInfo(hwnd,SB_VERT,&si,TRUE); - UpdateColorTable(); - UpdateCaption(); - return 0; - /* case WM_KEYUP: - if((wParam == VK_LSHIFT) || (wParam == VK_RSHIFT)){ - CursorShiftPoint = -1; - } - return 0;*/ - case WM_LBUTTONDOWN: - //CursorShiftPoint = -1; - SetCapture(hwnd); - lbuttondown = 1; - x = GET_X_LPARAM(lParam); - y = GET_Y_LPARAM(lParam); - if((i = GetAddyFromCoord(x,y)) == -1)return 0; - EditingText = AddyWasText; - lbuttondownx = x; - lbuttondowny = y; - CursorStartAddy = CursorDragPoint = i; - CursorEndAddy = -1; - UpdateCaption(); - UpdateColorTable(); - return 0; - case WM_RBUTTONDOWN: - { - if (!lbuttondown && CursorEndAddy == -1) - { - x = GET_X_LPARAM(lParam); - y = GET_Y_LPARAM(lParam); - i = GetAddyFromCoord(x,y); - if (i != -1) - { - EditingText = AddyWasText; - CursorStartAddy = i; - UpdateCaption(); - UpdateColorTable(); - return 0; - } - } - break; - } - case WM_MOUSEMOVE: - mousex = x = GET_X_LPARAM(lParam); - mousey = y = GET_Y_LPARAM(lParam); - if(lbuttondown){ - AutoScrollFromCoord(x,y); - i = GetAddyFromCoord(x,y); - if (i >= MaxSize)i = MaxSize-1; - EditingText = AddyWasText; - if(i != -1){ - CursorStartAddy = std::min(i,CursorDragPoint); - CursorEndAddy = std::max(i,CursorDragPoint); - if(CursorEndAddy == CursorStartAddy)CursorEndAddy = -1; - } - - UpdateCaption(); - UpdateColorTable(); - } - //sprintf(str,"%d %d",mousex, mousey); - //SetWindowText(hMemView,str); - return 0; - case WM_LBUTTONUP: - lbuttondown = 0; - if(CursorEndAddy == CursorStartAddy)CursorEndAddy = -1; - if((CursorEndAddy < CursorStartAddy) && (CursorEndAddy != -1)){ //this reverses them if they're not right - i = CursorStartAddy; - CursorStartAddy = CursorEndAddy; - CursorEndAddy = i; - } - UpdateCaption(); - UpdateColorTable(); - ReleaseCapture(); - return 0; - case WM_CONTEXTMENU: - { - point.x = x = GET_X_LPARAM(lParam); - point.y = y = GET_Y_LPARAM(lParam); - ScreenToClient(hMemView,&point); - mousex = point.x; - mousey = point.y; - j = GetAddyFromCoord(mousex,mousey); - bank = getBank(j); - //sprintf(str,"x = %d, y = %d, j = %d",mousex,mousey,j); - //MessageBox(hMemView,str, "mouse wheel dance!", MB_OK); - hMenu = CreatePopupMenu(); - for(i = 0;i < POPUPNUM;i++) - { - if((j >= popupmenu[i].minaddress) && (j <= popupmenu[i].maxaddress) && (EditingMode == popupmenu[i].editingmode)) - { - memset(&MenuInfo,0,sizeof(MENUITEMINFO)); - switch(popupmenu[i].id) - { - //this will set the text for the menu dynamically based on the id - // ################################## Start of SP CODE ########################### - case ID_ADDRESS_FRZ_SUBMENU: - { - HMENU sub = CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT)sub, "Freeze / Unfreeze Address"); - AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_TOGGLE_STATE, "Toggle state"); - AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_FREEZE, "Freeze"); - AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_UNFREEZE, "Unfreeze"); - AppendMenu(sub, MF_SEPARATOR, ID_ADDRESS_FRZ_SEP, "-"); - AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_UNFREEZE_ALL, "Unfreeze all"); - - if (CursorEndAddy == -1) tempAddy = CursorStartAddy; - else tempAddy = CursorEndAddy; //This is necessary because CursorEnd = -1 if only 1 address is selected - if (tempAddy - CursorStartAddy + FrozenAddressCount > 255) //There is a limit of 256 possible frozen addresses, therefore if the user has selected more than this limit, disable freeze menu items - { - EnableMenuItem(sub,ID_ADDRESS_FRZ_TOGGLE_STATE,MF_GRAYED); - EnableMenuItem(sub,ID_ADDRESS_FRZ_FREEZE,MF_GRAYED); - } - continue; - } - // ################################## End of SP CODE ########################### - case ID_ADDRESS_ADDBP_R: - { - // We want this to give the address to add the read breakpoint for - if ((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Read Breakpoint For Address %02X:%04X-%02X:%04X", bank, CursorStartAddy, bank, CursorEndAddy); - else - sprintf(str,"Add Read Breakpoint For Address %04X-%04X", CursorStartAddy, CursorEndAddy); - } else - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Read Breakpoint For Address %02X:%04X", bank, j); - else - sprintf(str,"Add Read Breakpoint For Address %04X", j); - } - popupmenu[i].text = str; - break; - } - case ID_ADDRESS_ADDBP_W: - { - if ((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Write Breakpoint For Address %02X:%04X-%02X:%04X", bank, CursorStartAddy, bank, CursorEndAddy); - else - sprintf(str,"Add Write Breakpoint For Address %04X-%04X", CursorStartAddy, CursorEndAddy); - } else - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Write Breakpoint For Address %02X:%04X", bank, j); - else - sprintf(str,"Add Write Breakpoint For Address %04X", j); - } - popupmenu[i].text = str; - break; - } - case ID_ADDRESS_ADDBP_X: - { - if ((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Execute Breakpoint For Address %02X:%04X-%02X:%04X", bank, CursorStartAddy, bank, CursorEndAddy); - else - sprintf(str,"Add Execute Breakpoint For Address %04X-%04X", CursorStartAddy, CursorEndAddy); - } else - { - if (j >= 0x8000 && bank != -1) - sprintf(str,"Add Execute Breakpoint For Address %02X:%04X", bank, j); - else - sprintf(str,"Add Execute Breakpoint For Address %04X", j); - } - popupmenu[i].text = str; - break; - } - } - MenuInfo.cbSize = sizeof(MENUITEMINFO); - MenuInfo.fMask = MIIM_TYPE | MIIM_ID | MIIM_DATA; - MenuInfo.fType = MF_STRING; - MenuInfo.dwTypeData = popupmenu[i].text; - MenuInfo.cch = strlen(popupmenu[i].text); - MenuInfo.wID = popupmenu[i].id; - InsertMenuItem(hMenu,i+1,1,&MenuInfo); - } - } - if (i != 0) - i = TrackPopupMenuEx(hMenu, TPM_RETURNCMD | TPM_RIGHTBUTTON, x, y, hMemView, NULL); - switch(i) - { - case ID_ADDRESS_FRZ_TOGGLE_STATE: - // ################################## Start of SP CODE ########################### - { - int n; - for (n=CursorStartAddy;(CursorEndAddy == -1 && n == CursorStartAddy) || n<=CursorEndAddy;n++) - { - FreezeRam(n, 0, n == CursorEndAddy); - } - break; - } - case ID_ADDRESS_FRZ_FREEZE: - { - int n; - for (n=CursorStartAddy;(CursorEndAddy == -1 && n == CursorStartAddy) || n<=CursorEndAddy;n++) - { - FreezeRam(n, 1, n == CursorEndAddy); - } - break; - } - case ID_ADDRESS_FRZ_UNFREEZE: - { - int n; - for (n=CursorStartAddy;(CursorEndAddy == -1 && n == CursorStartAddy) || n<=CursorEndAddy;n++) - { - FreezeRam(n, -1, n == CursorEndAddy); - } - break; - } - case ID_ADDRESS_FRZ_UNFREEZE_ALL: - { - UnfreezeAllRam(); - break; - } - // ################################## End of SP CODE ########################### - break; - - case ID_ADDRESS_ADDBP_R: - { - if (numWPs < MAXIMUM_NUMBER_OF_BREAKPOINTS) - { - watchpoint[numWPs].flags = WP_E | WP_R; - if (EditingMode == MODE_NES_PPU) - watchpoint[numWPs].flags |= BT_P; - if ((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - watchpoint[numWPs].address = CursorStartAddy; - watchpoint[numWPs].endaddress = CursorEndAddy; - } else - { - watchpoint[numWPs].address = j; - watchpoint[numWPs].endaddress = 0; - } - char condition[10] = {0}; - if (EditingMode == MODE_NES_MEMORY) - { - // only break at this Bank - if (j >= 0x8000 && bank != -1) - sprintf(condition, "T==#%02X", bank); - } - checkCondition(condition, numWPs); - - numWPs++; - // ################################## Start of SP CODE ########################### - { extern int myNumWPs; - myNumWPs++; } - // ################################## End of SP CODE ########################### - if (hDebug) - AddBreakList(); - else - DoDebug(0); - } - break; - } - case ID_ADDRESS_ADDBP_W: - { - if (numWPs < MAXIMUM_NUMBER_OF_BREAKPOINTS) - { - watchpoint[numWPs].flags = WP_E | WP_W; - if (EditingMode == MODE_NES_PPU) - watchpoint[numWPs].flags |= BT_P; - if ((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - watchpoint[numWPs].address = CursorStartAddy; - watchpoint[numWPs].endaddress = CursorEndAddy; - } else - { - watchpoint[numWPs].address = j; - watchpoint[numWPs].endaddress = 0; - } - char condition[10] = {0}; - if (EditingMode == MODE_NES_MEMORY) - { - // only break at this Bank - if (j >= 0x8000 && bank != -1) - sprintf(condition, "T==#%02X", bank); - } - checkCondition(condition, numWPs); - - numWPs++; - // ################################## Start of SP CODE ########################### - { extern int myNumWPs; - myNumWPs++; } - // ################################## End of SP CODE ########################### - if (hDebug) - AddBreakList(); - else - DoDebug(0); - } - break; - } - case ID_ADDRESS_ADDBP_X: - { - if (numWPs < MAXIMUM_NUMBER_OF_BREAKPOINTS) - { - watchpoint[numWPs].flags = WP_E | WP_X; - if((j <= CursorEndAddy) && (j >= CursorStartAddy)) - { - watchpoint[numWPs].address = CursorStartAddy; - watchpoint[numWPs].endaddress = CursorEndAddy; - } else - { - watchpoint[numWPs].address = j; - watchpoint[numWPs].endaddress = 0; - } - char condition[10] = {0}; - if (EditingMode == MODE_NES_MEMORY) - { - // only break at this Bank - if (j >= 0x8000 && bank != -1) - sprintf(condition, "T==#%02X", bank); - } - checkCondition(condition, numWPs); - - numWPs++; - // ################################## Start of SP CODE ########################### - { extern int myNumWPs; - myNumWPs++; } - // ################################## End of SP CODE ########################### - if (hDebug) - AddBreakList(); - else - DoDebug(0); - } - break; - } - case ID_ADDRESS_SEEK_IN_ROM: - ChangeMemViewFocus(2,GetNesFileAddress(j),-1); - break; - case ID_ADDRESS_CREATE_GG_CODE: - SetGGConvFocus(j,GetMem(j)); - break; - // ################################## Start of SP CODE ########################### - case ID_ADDRESS_BOOKMARK: - { - if (toggleBookmark(hwnd, CursorStartAddy)) - { - MessageBox(hDebug, "Can't set more than 64 breakpoints", "Error", MB_OK | MB_ICONERROR); - } - else - { - updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS)); - UpdateColorTable(); - } - break; - } - // ################################## End of SP CODE ########################### - case ID_ADDRESS_SYMBOLIC_NAME: - { - if (DoSymbolicDebugNaming(j, hMemView)) - { - // enable "Symbolic Debug" if not yet enabled - if (!symbDebugEnabled) - { - symbDebugEnabled = true; - if (hDebug) - CheckDlgButton(hDebug, IDC_DEBUGGER_ENABLE_SYMBOLIC, BST_CHECKED); - } - UpdateCaption(); - } - break; - } - break; - } - //6 = Create GG Code - - return 0; - } - case WM_MBUTTONDOWN: - { - x = GET_X_LPARAM(lParam); - y = GET_Y_LPARAM(lParam); - i = GetAddyFromCoord(x,y); - if(i == -1)return 0; - // ################################## Start of SP CODE ########################### - FreezeRam(i, 0, 1); - // ################################## End of SP CODE ########################### - return 0; - } - case WM_MOUSEWHEEL: - i = (short)HIWORD(wParam);///WHEEL_DELTA; - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.fMask = SIF_ALL; - si.cbSize = sizeof(SCROLLINFO); - GetScrollInfo(hwnd,SB_VERT,&si); - if(i < 0)si.nPos+=si.nPage; - if(i > 0)si.nPos-=si.nPage; - if (si.nPos < si.nMin) si.nPos = si.nMin; - if ((si.nPos+(int)si.nPage) > si.nMax) si.nPos = si.nMax-si.nPage; //added cast - CurOffset = si.nPos*16; - SetScrollInfo(hwnd,SB_VERT,&si,TRUE); - UpdateColorTable(); - return 0; - - case WM_SIZE: - if(wParam == SIZE_RESTORED) //If dialog was resized - { - GetWindowRect(hwnd,&newMemViewRect); //Get new size - MemViewSizeX = newMemViewRect.right-newMemViewRect.left; //Store new size (this will be used to store in the .cfg file) - MemViewSizeY = newMemViewRect.bottom-newMemViewRect.top; - } - ClientHeight = HIWORD (lParam); - if (DataAmount != ((ClientHeight/MemFontHeight)*16)) - { - DataAmount = ((ClientHeight/MemFontHeight)*16); - if (CurOffset > MaxSize - DataAmount) - CurOffset = MaxSize - DataAmount; - //mbg merge 7/18/06 added casts: - TextColorList = (COLORREF*)realloc(TextColorList,DataAmount*sizeof(COLORREF)); - BGColorList = (COLORREF*)realloc(BGColorList,DataAmount*sizeof(COLORREF)); - PreviousValues = (int*)realloc(PreviousValues,(DataAmount)*sizeof(int)); - HighlightedBytes = (unsigned int*)realloc(HighlightedBytes,(DataAmount)*sizeof(unsigned int)); - resetHighlightingActivityLog(); - } - //Set vertical scroll bar range and page size - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.cbSize = sizeof (si) ; - si.fMask = (SIF_RANGE|SIF_PAGE) ; - si.nMin = 0 ; - si.nMax = MaxSize/16 ; - si.nPage = ClientHeight/MemFontHeight; - SetScrollInfo (hwnd, SB_VERT, &si, TRUE); - UpdateColorTable(); - return 0 ; - - case WM_COMMAND: - - switch(wParam) - { - case MENU_MV_FILE_SAVE: - FlushUndoBuffer(); - iNesSave(); - UpdateColorTable(); - return 0; - - case MENU_MV_FILE_SAVE_AS: - SaveRomAs(); - return 0; - - case MENU_MV_FILE_LOAD_TBL: - if((i = LoadTableFile()) != -1){ - sprintf(str,"Error Loading Table File At Line %d",i); - MessageBox(hMemView, str, "error", MB_OK); - } - UpdateColorTable(); - return 0; - - case MENU_MV_FILE_UNLOAD_TBL: - UnloadTableFile(); - UpdateColorTable(); - return 0; - - // ################################## Start of SP CODE ########################### - case MENU_MV_FILE_DUMP_RAM: - { - char bar[0x800]; - unsigned int i; - for (i=0;i>10][(i)]; - else if(i < 0x3F00) bar[i] = vnapage[(i>>10)&0x3][i&0x3FF]; - else bar[i] = PALRAM[i&0x1F]; - } - dumpToFile(bar, sizeof(bar)); - return 0; - } - // ################################## End of SP CODE ########################### - - case ID_MEMWVIEW_FILE_CLOSE: - KillMemView(); - return 0; - - case MENU_MV_FILE_GOTO_ADDRESS: - GotoAddress(hwnd); - return 0; - - case MENU_MV_EDIT_UNDO: - UndoLastPatch(); - return 0; - - case MENU_MV_EDIT_COPY: - if(CursorEndAddy == -1)i = 1; - else i = CursorEndAddy-CursorStartAddy+1; - - hGlobal = GlobalAlloc (GHND, - (i*2)+1); //i*2 is two characters per byte, plus terminating null - - pGlobal = (char*)GlobalLock (hGlobal) ; //mbg merge 7/18/06 added cast - if(!EditingText){ - for(j = 0;j < i;j++){ - str[0] = 0; - sprintf(str,"%02X",GetMemViewData((uint32)j+CursorStartAddy)); - strcat(pGlobal,str); - } - } else { - for(j = 0;j < i;j++){ - str[0] = 0; - sprintf(str,"%c",chartable[GetMemViewData(j+CursorStartAddy)]); - strcat(pGlobal,str); - } - } - GlobalUnlock (hGlobal); - OpenClipboard (hwnd) ; - EmptyClipboard () ; - SetClipboardData (CF_TEXT, hGlobal) ; - CloseClipboard () ; - return 0; - - case MENU_MV_EDIT_PASTE: - - OpenClipboard(hwnd); - hGlobal = GetClipboardData(CF_TEXT); - if(hGlobal == NULL){ - CloseClipboard(); - return 0; - } - pGlobal = (char*)GlobalLock (hGlobal) ; //mbg merge 7/18/06 added cast - //for(i = 0;pGlobal[i] != 0;i++){ - InputData(pGlobal); - //} - GlobalUnlock (hGlobal); - CloseClipboard(); - return 0; - - case MENU_MV_EDIT_FIND: - OpenFindDialog(); - return 0; - - - case MENU_MV_VIEW_RAM: - case MENU_MV_VIEW_PPU: - case MENU_MV_VIEW_ROM: - EditingMode = wParam - MENU_MV_VIEW_RAM; - for (i = MODE_NES_MEMORY; i <= MODE_NES_FILE; i++) - { - CheckMenuItem(GetMenu(hMemView), MENU_MV_VIEW_RAM + i, (EditingMode == i) ? MF_CHECKED : MF_UNCHECKED); - } - if (EditingMode == MODE_NES_MEMORY) - MaxSize = 0x10000; - if (EditingMode == MODE_NES_PPU) - { - if (GameInfo->type==GIT_NSF) {MaxSize = 0x2000;} //Also disabled under GetMemViewData - else {MaxSize = 0x4000;} - } - if (EditingMode == MODE_NES_FILE) - MaxSize = 16+CHRsize[0]+PRGsize[0]; //todo: add trainer size - if(DataAmount+CurOffset > MaxSize)CurOffset = MaxSize-DataAmount; - if(CursorEndAddy > MaxSize)CursorEndAddy = -1; - if(CursorStartAddy > MaxSize)CursorStartAddy= MaxSize-1; - - //Set vertical scroll bar range and page size - ZeroMemory(&si, sizeof(SCROLLINFO)); - si.cbSize = sizeof (si) ; - si.fMask = (SIF_RANGE|SIF_PAGE) ; - si.nMin = 0 ; - si.nMax = MaxSize/16 ; - si.nPage = ClientHeight/MemFontHeight; - SetScrollInfo (hwnd, SB_VERT, &si, TRUE); - - resetHighlightingActivityLog(); - UpdateColorTable(); - UpdateCaption(); - return 0; - - case ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY: - { - MemView_HighlightActivity ^= 1; - CheckMenuItem(GetMenu(hMemView), ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY, (MemView_HighlightActivity) ? MF_CHECKED: MF_UNCHECKED); - resetHighlightingActivityLog(); - if (!MemView_HighlightActivity) - UpdateMemoryView(1); - return 0; - } - case ID_HIGHLIGHTING_SETFADINGPERIOD: - { - int newValue = MemView_HighlightActivity_FadingPeriod - 1; - if (CWin32InputBox::GetInteger("Highlighting fading period", "Highlight changed bytes for how many frames?", newValue, hMemView) == IDOK) - { - if (newValue <= 0) - newValue = HIGHLIGHT_ACTIVITY_NUM_COLORS; - else - newValue++; - - if (MemView_HighlightActivity_FadingPeriod != newValue) - { - MemView_HighlightActivity_FadingPeriod = newValue; - resetHighlightingActivityLog(); - } - } - return 0; - } - case ID_HIGHLIGHTING_FADEWHENPAUSED: - { - MemView_HighlightActivity_FadeWhenPaused ^= 1; - CheckMenuItem(GetMenu(hMemView), ID_HIGHLIGHTING_FADEWHENPAUSED, (MemView_HighlightActivity_FadeWhenPaused) ? MF_CHECKED: MF_UNCHECKED); - resetHighlightingActivityLog(); - return 0; - } - - // ################################## Start of SP CODE ########################### - case MENU_MV_BOOKMARKS_RM_ALL: - if (nextBookmark) - { - if (MessageBox(hwnd, "Remove All Bookmarks?", "Bookmarks", MB_YESNO) == IDYES) - { - removeAllBookmarks(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS)); - UpdateColorTable(); - } - } - return 0; - - case MENU_MV_HELP: - OpenHelpWindow(memviewhelp); - return 0; - - default: - if (wParam >= ID_FIRST_BOOKMARK && wParam < (ID_FIRST_BOOKMARK + 64)) - { - int newValue = handleBookmarkMenu(wParam - ID_FIRST_BOOKMARK); - - if (newValue != -1) - { - CurOffset = newValue; - CursorEndAddy = -1; - CursorStartAddy = hexBookmarks[wParam - ID_FIRST_BOOKMARK].address; - UpdateColorTable(); - } - return 0; - } - // ################################## End of SP CODE ########################### - } - - case WM_MOVE: { - if (!IsIconic(hwnd)) { - RECT wrect; - GetWindowRect(hwnd,&wrect); - MemView_wndx = wrect.left; - MemView_wndy = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckResize(MemView_wndx,MemView_wndy,MemViewSizeX,wrect.right); - #endif - } - return 0; - } - - case WM_CLOSE: - KillMemView(); - //ReleaseDC (hwnd, mDC) ; - //DestroyWindow(hMemView); - //UnregisterClass("MEMVIEW",fceu_hInstance); - //hMemView = 0; - return 0; - } - return DefWindowProc (hwnd, message, wParam, lParam) ; -} - - - -void DoMemView() -{ - WNDCLASSEX wndclass ; - //static RECT al; - - if (!GameInfo) { - FCEUD_PrintError("You must have a game loaded before you can use the Hex Editor."); - return; - } - //if (GameInfo->type==GIT_NSF) { - // FCEUD_PrintError("Sorry, you can't yet use the Memory Viewer with NSFs."); - // return; - //} - - if (!hMemView) - { - memset(&wndclass,0,sizeof(wndclass)); - wndclass.cbSize=sizeof(WNDCLASSEX); - wndclass.style = CS_HREDRAW | CS_VREDRAW ; - wndclass.lpfnWndProc = MemViewCallB ; - wndclass.cbClsExtra = 0 ; - wndclass.cbWndExtra = 0 ; - wndclass.hInstance = fceu_hInstance; - wndclass.hIcon = LoadIcon(fceu_hInstance, "ICON_1"); - wndclass.hIconSm = LoadIcon(fceu_hInstance, "ICON_1"); - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wndclass.lpszMenuName = "MEMVIEWMENU"; - wndclass.lpszClassName = "MEMVIEW"; - - if(!RegisterClassEx(&wndclass)) {FCEUD_PrintError("Error Registering MEMVIEW Window Class."); return;} - - hMemView = CreateWindowEx(0,"MEMVIEW","Memory Editor", - //WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS, /* Style */ - WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME|WS_VSCROLL, - CW_USEDEFAULT,CW_USEDEFAULT,580,248, /* X,Y ; Width, Height */ - NULL,NULL,fceu_hInstance,NULL ); - ShowWindow (hMemView, SW_SHOW) ; - UpdateCaption(); - } else - { - //SetWindowPos(hMemView, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); - ShowWindow(hMemView, SW_SHOWNORMAL); - SetForegroundWindow(hMemView); - UpdateCaption(); - } - - DragAcceptFiles(hMemView, 1); - - if (hMemView) - { - //UpdateMemView(0); - //MemViewDoBlit(); - } -} - -BOOL CALLBACK MemFindCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - - switch(uMsg) { - case WM_INITDIALOG: - SetWindowPos(hwndDlg,0,MemFind_wndx,MemFind_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - - if(FindDirectionUp) CheckDlgButton(hwndDlg, IDC_MEMVIEWFIND_DIR_UP, BST_CHECKED); - else CheckDlgButton(hwndDlg, IDC_MEMVIEWFIND_DIR_DOWN, BST_CHECKED); - - if(FindAsText) CheckDlgButton(hwndDlg, IDC_MEMVIEWFIND_TYPE_TEXT, BST_CHECKED); - else CheckDlgButton(hwndDlg, IDC_MEMVIEWFIND_TYPE_HEX, BST_CHECKED); - - if(FindTextBox[0])SetDlgItemText(hwndDlg,IDC_MEMVIEWFIND_WHAT,FindTextBox); - - SendDlgItemMessage(hwndDlg,IDC_MEMVIEWFIND_WHAT,EM_SETLIMITTEXT,59,0); - break; - case WM_CREATE: - - break; - case WM_PAINT: - break; - case WM_CLOSE: - case WM_QUIT: - GetDlgItemText(hwndDlg,IDC_MEMVIEWFIND_WHAT,FindTextBox,59); - DestroyWindow(hwndDlg); - hMemFind = 0; - hwndDlg = 0; - break; - case WM_MOVING: - break; - case WM_MOVE: { - if (!IsIconic(hwndDlg)) { - RECT wrect; - GetWindowRect(hwndDlg,&wrect); - MemFind_wndx = wrect.left; - MemFind_wndy = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(MemFind_wndx,MemFind_wndy,wrect.right); - #endif - } - break; - } - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - break; - case WM_MOUSEMOVE: - break; - - case WM_COMMAND: - switch(HIWORD(wParam)) { - case BN_CLICKED: - switch(LOWORD(wParam)) { - case IDC_MEMVIEWFIND_TYPE_HEX : - FindAsText=0; - break; - case IDC_MEMVIEWFIND_TYPE_TEXT : - FindAsText=1; - break; - - case IDC_MEMVIEWFIND_DIR_UP : - FindDirectionUp = 1; - break; - case IDC_MEMVIEWFIND_DIR_DOWN : - FindDirectionUp = 0; - break; - case IDC_MEMVIEWFIND_NEXT : - FindNext(); - break; - } - break; - } - break; - case WM_HSCROLL: - break; - } - return FALSE; -} -void FindNext(){ - char str[60]; - unsigned char data[60]; - int datasize = 0, i, j, inputc = -1, found; - - if(hMemFind) GetDlgItemText(hMemFind,IDC_MEMVIEWFIND_WHAT,str,59); - else strcpy(str,FindTextBox); - - for(i = 0;str[i] != 0;i++){ - if(!FindAsText){ - if(inputc == -1){ - if((str[i] >= 'a') && (str[i] <= 'f')) inputc = str[i]-('a'-0xA); - if((str[i] >= 'A') && (str[i] <= 'F')) inputc = str[i]-('A'-0xA); - if((str[i] >= '0') && (str[i] <= '9')) inputc = str[i]-'0'; - } else { - if((str[i] >= 'a') && (str[i] <= 'f')) inputc = (inputc<<4)|(str[i]-('a'-0xA)); - if((str[i] >= 'A') && (str[i] <= 'F')) inputc = (inputc<<4)|(str[i]-('A'-0xA)); - if((str[i] >= '0') && (str[i] <= '9')) inputc = (inputc<<4)|(str[i]-'0'); - - if(((str[i] >= 'a') && (str[i] <= 'f')) || - ((str[i] >= 'A') && (str[i] <= 'F')) || - ((str[i] >= '0') && (str[i] <= '9'))){ - data[datasize++] = inputc; - inputc = -1; - } - } - } else { - for(j = 0;j < 256;j++)if(chartable[j] == str[i])break; - if(j == 256)continue; - data[datasize++] = j; - } - } - - if(datasize < 1){ - MessageBox(hMemView,"Invalid String","Error", MB_OK); - return; - } - if(!FindDirectionUp){ - for(i = CursorStartAddy+1;i+datasize < MaxSize;i++){ - found = 1; - for(j = 0;j < datasize;j++){ - if(GetMemViewData(i+j) != data[j])found = 0; - } - if(found == 1){ - ChangeMemViewFocus(EditingMode,i, i+datasize-1); - return; - } - } - for(i = 0;i < CursorStartAddy;i++){ - found = 1; - for(j = 0;j < datasize;j++){ - if(GetMemViewData(i+j) != data[j])found = 0; - } - if(found == 1){ - ChangeMemViewFocus(EditingMode,i, i+datasize-1); - return; - } - } - } else { //FindDirection is up - for(i = CursorStartAddy-1;i > 0;i--){ - found = 1; - for(j = 0;j < datasize;j++){ - if(GetMemViewData(i+j) != data[j])found = 0; - } - if(found == 1){ - ChangeMemViewFocus(EditingMode,i, i+datasize-1); - return; - } - } - for(i = MaxSize-datasize;i > CursorStartAddy;i--){ - found = 1; - for(j = 0;j < datasize;j++){ - if(GetMemViewData(i+j) != data[j])found = 0; - } - if(found == 1){ - ChangeMemViewFocus(EditingMode,i, i+datasize-1); - return; - } - } - } - - - MessageBox(hMemView,"String Not Found","Error", MB_OK); - return; -} - - -void OpenFindDialog() -{ - if (!hMemView) - return; - if (hMemFind) - // set focus to the text field - SendMessage(hMemFind, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMemFind, IDC_MEMVIEWFIND_WHAT), true); - else - hMemFind = CreateDialog(fceu_hInstance,"MEMVIEWFIND",hMemView,MemFindCallB); - return; -} diff --git a/branches/fceux-2.2.2/src/drivers/win/memview.h b/branches/fceux-2.2.2/src/drivers/win/memview.h deleted file mode 100644 index 599b4388..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/memview.h +++ /dev/null @@ -1,14 +0,0 @@ -void DoMemView(); -void KillMemView(); -void UpdateMemoryView(int draw_all); -void UpdateColorTable(); -void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset); -void UpdateCaption(); - -void ApplyPatch(int addr,int size, uint8* data); -void UndoLastPatch(); - -void SetHexEditorAddress(int gotoaddress); - -extern HWND hMemView, hMemFind; -extern int EditingMode; diff --git a/branches/fceux-2.2.2/src/drivers/win/memviewsp.cpp b/branches/fceux-2.2.2/src/drivers/win/memviewsp.cpp deleted file mode 100644 index 66624ca0..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/memviewsp.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* FCEUXD SP - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 Sebastian Porst - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include "memviewsp.h" -#include "common.h" - -HexBookmark hexBookmarks[64]; -int nextBookmark = 0; - -/// Finds the bookmark for a given address -/// @param address The address to find. -/// @return The index of the bookmark at that address or -1 if there's no bookmark at that address. -int findBookmark(unsigned int address) -{ - int i; - - if (address > 0xFFFF) - { - MessageBox(0, "Error: Invalid address was specified as parameter to findBookmark", "Error", MB_OK | MB_ICONERROR); - return -1; - } - - for (i=0;i>tmp)&1; - p |= ((chr1>>tmp)&1)<<1; - p = palcache[p+(pal*4)]; - tmp--; - - *(uint8*)(pbitmap++) = palo[p].b; - *(uint8*)(pbitmap++) = palo[p].g; - *(uint8*)(pbitmap++) = palo[p].r; - } - index++; - pbitmap += (NTWIDTH*3)-24; - } - //index+=8; - //pbitmap -= (((PALETTEBITWIDTH>>2)<<3)-24); -} - -void DrawNameTable(int scanline, int ntnum, bool invalidateCache) { - - NTCache &c = cache[ntnum]; - uint8 *bitmap = c.bitmap, *tablecache = c.cache; - - uint8 *table = vnapage[ntnum]; - if(table == NULL) - table = vnapage[ntnum&1]; - - int a, ptable=0; - uint8 *pbitmap = bitmap; - - if(PPU[0]&0x10){ //use the correct pattern table based on this bit - ptable=0x1000; - } - - bool invalid = invalidateCache; - //if we werent asked to invalidate the cache, maybe we need to invalidate it anyway due to vnapage changing - if(!invalid) - invalid = (c.curr_vnapage != vnapage[ntnum]); - c.curr_vnapage = vnapage[ntnum]; - - //HACK: never cache anything - invalid = true; - - pbitmap = bitmap; - for(int y=0;y<30;y++){ - for(int x=0;x<32;x++){ - int ntaddr = (y*32)+x; - int attraddr = 0x3C0+((y>>2)<<3)+(x>>2); - if(invalid - || (table[ntaddr] != tablecache[ntaddr]) - || (table[attraddr] != tablecache[attraddr])) { - redrawtables = true; - int temp = (((y&2)<<1)+(x&2)); - a = (table[attraddr] & (3<> temp; - - //the commented out code below is all allegedly equivalent to the single line above: - //tmpx = x>>2; - //tmpy = y>>2; - //a = 0x3C0+(tmpy*8)+tmpx; - //if((((x>>1)&1) == 0) && (((y>>1)&1) == 0)) a = table[a]&0x3; - //if((((x>>1)&1) == 1) && (((y>>1)&1) == 0)) a = (table[a]&0xC)>>2; - //if((((x>>1)&1) == 0) && (((y>>1)&1) == 1)) a = (table[a]&0x30)>>4; - //if((((x>>1)&1) == 1) && (((y>>1)&1) == 1)) a = (table[a]&0xC0)>>6; - - int chr = table[ntaddr]*16; - - extern int FCEUPPU_GetAttr(int ntnum, int xt, int yt); - - //test.. instead of pretending that the nametable is a screen at 0,0 we pretend that it is at the current xscroll and yscroll - //int xpos = ((RefreshAddr & 0x400) >> 2) | ((RefreshAddr & 0x1F) << 3) | XOffset; - //int ypos = ((RefreshAddr & 0x3E0) >> 2) | ((RefreshAddr & 0x7000) >> 12); - //if(RefreshAddr & 0x800) ypos += 240; - //int refreshaddr = (xpos/8+x)+(ypos/8+y)*32; - - int refreshaddr = (x)+(y)*32; - - a = FCEUPPU_GetAttr(ntnum,x,y); - - //a good way to do it: - DrawChr(pbitmap,FCEUPPU_GetCHR(ptable+chr,refreshaddr),a); - - tablecache[ntaddr] = table[ntaddr]; - tablecache[attraddr] = table[attraddr]; - //one could comment out the line above... - //since there are so many fewer attribute values than NT values, it might be best just to refresh the whole attr table below with the memcpy - - //obviously this whole scheme of nt cache doesnt work if an mmc5 game is playing tricks with the attribute table - } - pbitmap += (8*3); - } - pbitmap += 7*((NTWIDTH*3)); - } - - //this copies the attribute tables to the cache if needed. but we arent using it now because - //if(redrawtables){ - // memcpy(tablecache+0x3c0,table+0x3c0,0x40); - //} -} - -void FCEUD_UpdateNTView(int scanline, bool drawall) { - if(!NTViewer) return; - if(scanline != -1 && scanline != NTViewScanline) return; - - //uint8 *pbitmap = ppuv_palette; - if (!hNTView) return; - - ppu_getScroll(xpos,ypos); - - - //char str[50]; - //sprintf(str,"%d,%d,%d",horzscroll,vertscroll,ntmirroring); - //sprintf(str,"%08X %08X",TempAddr, RefreshAddr); - //SetDlgItemText(hNTView, IDC_NTVIEW_PROPERTIES_LINE_1, str); - - if (NTViewSkip < NTViewRefresh) return; - - if(chrchanged) drawall = 1; - - //update palette only if required - if (memcmp(palcache,PALRAM,32) != 0) { - memcpy(palcache,PALRAM,32); - drawall = 1; //palette has changed, so redraw all - } - - ntmirroring = NT_NONE; - if(vnapage[0] == vnapage[1])ntmirroring = NT_HORIZONTAL; - if(vnapage[0] == vnapage[2])ntmirroring = NT_VERTICAL; - if((vnapage[0] != vnapage[1]) && (vnapage[0] != vnapage[2]))ntmirroring = NT_FOUR_SCREEN; - - if((vnapage[0] == vnapage[1]) && (vnapage[1] == vnapage[2]) && (vnapage[2] == vnapage[3])){ - if(vnapage[0] == &NTARAM[0x000])ntmirroring = NT_SINGLE_SCREEN_TABLE_0; - if(vnapage[0] == &NTARAM[0x400])ntmirroring = NT_SINGLE_SCREEN_TABLE_1; - if(vnapage[0] == ExtraNTARAM)ntmirroring = NT_SINGLE_SCREEN_TABLE_2; - if(vnapage[0] == ExtraNTARAM+0x400)ntmirroring = NT_SINGLE_SCREEN_TABLE_3; - } - - if(oldntmirroring != ntmirroring){ - UpdateMirroringButtons(); - oldntmirroring = ntmirroring; - } - - for(int i=0;i<4;i++) - DrawNameTable(scanline,i,drawall); - - chrchanged = 0; - - return; -} - -void KillNTView() { - //GDI cleanup - for(int i=0;i<4;i++) { - DeleteObject(cache[i].hbmp); - SelectObject(cache[i].hdc,cache[i].tmpobj); - DeleteDC(cache[i].hdc); - } - - ReleaseDC(hNTView,pDC); - - DeleteObject (SelectObject (pDC, GetStockObject (BLACK_PEN))) ; - - DestroyWindow(hNTView); - hNTView=NULL; - NTViewer=0; - NTViewSkip=0; -} - -BOOL CALLBACK NTViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - RECT wrect; - char str[50]; - int TileID, TileX, TileY, NameTable, PPUAddress; - - switch(uMsg) { - case WM_INITDIALOG: - if (NTViewPosX==-32000) NTViewPosX=0; //Just in case - if (NTViewPosY==-32000) NTViewPosY=0; - SetWindowPos(hwndDlg,0,NTViewPosX,NTViewPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - - //prepare the bitmap attributes - //pattern tables - memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER)); - bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmInfo.bmiHeader.biWidth = NTWIDTH; - bmInfo.bmiHeader.biHeight = -NTHEIGHT; - bmInfo.bmiHeader.biPlanes = 1; - bmInfo.bmiHeader.biBitCount = 24; - - //create memory dcs - pDC = GetDC(hwndDlg); // GetDC(GetDlgItem(hwndDlg,IDC_NTVIEW_TABLE_BOX)); - for(int i=0;i<4;i++) { - NTCache &c = cache[i]; - c.hdc = CreateCompatibleDC(pDC); - c.hbmp = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&c.bitmap,0,0); - c.tmpobj = SelectObject(c.hdc,c.hbmp); - } - - //Refresh Trackbar - SendDlgItemMessage(hwndDlg,IDC_NTVIEW_REFRESH_TRACKBAR,TBM_SETRANGE,0,(LPARAM)MAKELONG(0,25)); - SendDlgItemMessage(hwndDlg,IDC_NTVIEW_REFRESH_TRACKBAR,TBM_SETPOS,1,NTViewRefresh); - - //Set Text Limit - SendDlgItemMessage(hwndDlg,IDC_NTVIEW_SCANLINE,EM_SETLIMITTEXT,3,0); - - //force redraw the first time the PPU Viewer is opened - NTViewSkip=100; - - SelectObject (pDC, CreatePen (PS_SOLID, 2, RGB (255, 255, 255))) ; - - CheckDlgButton(hwndDlg, IDC_NTVIEW_SHOW_SCROLL_LINES, BST_CHECKED); - //clear cache - //memset(palcache,0,32); - //memset(ntcache0,0,0x400); - //memset(ntcache1,0,0x400); - //memset(ntcache2,0,0x400); - //memset(ntcache3,0,0x400); - - NTViewer=1; - break; - case WM_PAINT: - NTViewDoBlit(1); - break; - case WM_CLOSE: - case WM_QUIT: - KillNTView(); - break; - case WM_MOVING: - break; - case WM_MOVE: - if (!IsIconic(hwndDlg)) { - GetWindowRect(hwndDlg,&wrect); - NTViewPosX = wrect.left; - NTViewPosY = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(NTViewPosX,NTViewPosY,wrect.right); - #endif - } - break; - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - /*if (((mouse_x >= PATTERNDESTX) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) { - if (pindex0 == 7) pindex0 = 0; - else pindex0++; - } - else if (((mouse_x >= PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)*2+1))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) { - if (pindex1 == 7) pindex1 = 0; - else pindex1++; - } - UpdatePPUView(0); - PPUViewDoBlit();*/ - break; - case WM_MOUSEMOVE: - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - if((mouse_x > NTDESTX) && (mouse_x < NTDESTX+(NTWIDTH*2)) - && (mouse_y > NTDESTY) && (mouse_y < NTDESTY+(NTHEIGHT*2))){ - TileX = (mouse_x-NTDESTX)/8; - TileY = (mouse_y-NTDESTY)/8; - sprintf(str,"X / Y: %0d / %0d",TileX,TileY); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_2,str); - NameTable = (TileX/32)+((TileY/30)*2); - PPUAddress = 0x2000+(NameTable*0x400)+((TileY%30)*32)+(TileX%32); - sprintf(str,"PPU Address: %04X",PPUAddress); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_3,str); - TileID = vnapage[(PPUAddress>>10)&0x3][PPUAddress&0x3FF]; - sprintf(str,"Tile ID: %02X",TileID); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_1,str); - } - -/* if (((mouse_x >= PATTERNDESTX) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) { - mouse_x = (mouse_x-PATTERNDESTX)/(8*ZOOM); - mouse_y = (mouse_y-PATTERNDESTY)/(8*ZOOM); - sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_1,str); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_2,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_3,"Palettes"); - } - else if (((mouse_x >= PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)*2+1))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) { - mouse_x = (mouse_x-(PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1))/(8*ZOOM); - mouse_y = (mouse_y-PATTERNDESTY)/(8*ZOOM); - sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_2,str); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_1,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_3,"Palettes"); - } - else if (((mouse_x >= PALETTEDESTX) && (mouse_x < (PALETTEDESTX+PALETTEWIDTH))) && (mouse_y >= PALETTEDESTY) && (mouse_y < (PALETTEDESTY+PALETTEHEIGHT))) { - mouse_x = (mouse_x-PALETTEDESTX)/32; - mouse_y = (mouse_y-PALETTEDESTY)/32; - sprintf(str,"Palette: $%02X",palcache[(mouse_y<<4)|mouse_x]); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_1,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_2,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_3,str); - } - else { - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_1,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_2,"Tile:"); - SetDlgItemText(hwndDlg,IDC_NTVIEW_PROPERTIES_LINE_3,"Palettes"); - } -*/ - break; - case WM_NCACTIVATE: - sprintf(str,"%d",NTViewScanline); - SetDlgItemText(hwndDlg,IDC_NTVIEW_SCANLINE,str); - break; - case WM_COMMAND: - switch(HIWORD(wParam)) { - case EN_UPDATE: - GetDlgItemText(hwndDlg,IDC_NTVIEW_SCANLINE,str,4); - sscanf(str,"%d",&NTViewScanline); - if (NTViewScanline > 239) NTViewScanline = 239; - chrchanged = 1; - break; - case BN_CLICKED: - switch(LOWORD(wParam)) { - case IDC_NTVIEW_MIRROR_HORIZONTAL : - case IDC_NTVIEW_MIRROR_VERTICAL : - case IDC_NTVIEW_MIRROR_FOUR_SCREEN : - case IDC_NTVIEW_MIRROR_SS_TABLE_0 : - case IDC_NTVIEW_MIRROR_SS_TABLE_1 : - case IDC_NTVIEW_MIRROR_SS_TABLE_2 : - case IDC_NTVIEW_MIRROR_SS_TABLE_3 : - oldntmirroring = ntmirroring = NT_MirrorType(LOWORD(wParam)-IDC_NTVIEW_MIRROR_TYPE_0); - ChangeMirroring(); - break; - case IDC_NTVIEW_SHOW_SCROLL_LINES : - scrolllines ^= 1; - chrchanged = 1; - break; - } - break; - } - break; - case WM_HSCROLL: - if (lParam) { //refresh trackbar - NTViewRefresh = SendDlgItemMessage(hwndDlg,IDC_NTVIEW_REFRESH_TRACKBAR,TBM_GETPOS,0,0); - } - break; - } - return FALSE; -} - -void DoNTView() -{ - if (!GameInfo) { - FCEUD_PrintError("You must have a game loaded before you can use the Name Table Viewer."); - return; - } - if (GameInfo->type==GIT_NSF) { - FCEUD_PrintError("Sorry, you can't use the Name Table Viewer with NSFs."); - return; - } - - if (!hNTView) - { - hNTView = CreateDialog(fceu_hInstance,"NTVIEW",NULL,NTViewCallB); - new(cache) NTCache[4]; //reinitialize NTCache - } - if (hNTView) - { - //SetWindowPos(hNTView,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); - ShowWindow(hNTView, SW_SHOWNORMAL); - SetForegroundWindow(hNTView); - FCEUD_UpdateNTView(-1,true); - NTViewDoBlit(1); - } -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/palette.cpp b/branches/fceux-2.2.2/src/drivers/win/palette.cpp deleted file mode 100644 index 0917f134..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/palette.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "../../version.h" -#include "common.h" -#include "main.h" -#include "window.h" -#include "gui.h" - -uint8 cpalette[192] = {0}; - -bool SetPalette(const char* nameo) -{ - FILE *fp; - if((fp = FCEUD_UTF8fopen(nameo, "rb"))) - { - fread(cpalette, 1, 192, fp); - fclose(fp); - FCEUI_SetPaletteArray(cpalette); - eoptions |= EO_CPALETTE; - return true; - } - else - { - FCEUD_PrintError("Error opening palette file!"); - return false; - } -} - -/** -* Prompts the user for a palette file and opens that file. -* -* @return Flag that indicates failure (0) or success (1) -**/ -int LoadPaletteFile() -{ - const char filter[]="All usable files (*.pal)\0*.pal\0All Files (*.*)\0*.*\0\0"; - - bool success = false; - char nameo[2048]; - - // Display open file dialog - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = FCEU_NAME" Open Palette File..."; - ofn.lpstrFilter = filter; - nameo[0] = 0; - ofn.lpstrFile = nameo; - ofn.nMaxFile = 256; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.lpstrInitialDir = 0; - - if(GetOpenFileName(&ofn)) - { - success = SetPalette(nameo); - } - - return success; -} - -/** -* Callback function for the palette configuration dialog. -**/ -BOOL CALLBACK PaletteConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - - if(ntsccol) - CheckDlgButton(hwndDlg, CHECK_PALETTE_ENABLED, BST_CHECKED); - - SendDlgItemMessage(hwndDlg, CTL_TINT_TRACKBAR, TBM_SETRANGE, 1, MAKELONG(0, 128)); - SendDlgItemMessage(hwndDlg, CTL_HUE_TRACKBAR, TBM_SETRANGE, 1, MAKELONG(0, 128)); - - FCEUI_GetNTSCTH(&ntsctint, &ntschue); - - SendDlgItemMessage(hwndDlg, CTL_TINT_TRACKBAR, TBM_SETPOS, 1, ntsctint); - SendDlgItemMessage(hwndDlg, CTL_HUE_TRACKBAR, TBM_SETPOS, 1, ntschue); - - if(force_grayscale) - CheckDlgButton(hwndDlg, CHECK_PALETTE_GRAYSCALE, BST_CHECKED); - - if (eoptions & EO_CPALETTE) - CheckDlgButton(hwndDlg, CHECK_PALETTE_CUSTOM, BST_CHECKED); - - CenterWindowOnScreen(hwndDlg); - - break; - - case WM_HSCROLL: - ntsctint = SendDlgItemMessage(hwndDlg, CTL_TINT_TRACKBAR, TBM_GETPOS, 0, (LPARAM)(LPSTR)0); - ntschue = SendDlgItemMessage(hwndDlg, CTL_HUE_TRACKBAR, TBM_GETPOS, 0, (LPARAM)(LPSTR)0); - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - break; - - case WM_CLOSE: - case WM_QUIT: - goto gornk; - - case WM_COMMAND: - if(!(wParam>>16)) - { - switch(wParam&0xFFFF) - { - case CHECK_PALETTE_ENABLED: - ntsccol ^= 1; - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - break; - - case CHECK_PALETTE_GRAYSCALE: - force_grayscale ^= 1; - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - break; - - case BTN_PALETTE_LOAD: - if(LoadPaletteFile()) - CheckDlgButton(hwndDlg, CHECK_PALETTE_CUSTOM, BST_CHECKED); - break; - - case CHECK_PALETTE_CUSTOM: - { - if (eoptions & EO_CPALETTE) - { - // switch back to default palette - FCEUI_SetPaletteArray(0); - eoptions &= ~EO_CPALETTE; - } else - { - // switch to custom, even if it isn't loaded yet - FCEUI_SetPaletteArray(cpalette); - eoptions |= EO_CPALETTE; - } - break; - } - - case BUTTON_CLOSE: -gornk: - DestroyWindow(hwndDlg); - pwindow = 0; // Yay for user race conditions. - break; - } - } - } - - return 0; -} - -/** -* Shows palette configuration dialog. -**/ -void ConfigPalette() -{ - if(!pwindow) - { - pwindow=CreateDialog(fceu_hInstance, "PALCONFIG" ,0 , PaletteConCallB); - } - else - { - SetFocus(pwindow); - } -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/ppuview.cpp b/branches/fceux-2.2.2/src/drivers/win/ppuview.cpp deleted file mode 100644 index c3119215..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/ppuview.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" -#include "ppuview.h" -#include "../../palette.h" -#include "../../fceu.h" -#include "../../cart.h" - -HWND hPPUView; - -extern uint8 *VPage[8]; -extern uint8 PALRAM[0x20]; - -int PPUViewPosX, PPUViewPosY; -bool PPUView_maskUnusedGraphics = true; -bool PPUView_invertTheMask = false; - -uint8 palcache[32] = { 0xFF }; //palette cache -uint8 chrcache0[0x1000], chrcache1[0x1000], logcache0[0x1000], logcache1[0x1000]; //cache CHR, fixes a refresh problem when right-clicking -uint8 *pattern0, *pattern1; //pattern table bitmap arrays -uint8 *ppuv_palette; -static int pindex0 = 0, pindex1 = 0; -int PPUViewScanline = 0, PPUViewer = 0; -int PPUViewSkip; -int PPUViewRefresh = 15; -int mouse_x, mouse_y; - -#define PATTERNWIDTH 128 -#define PATTERNHEIGHT 128 -#define PATTERNBITWIDTH PATTERNWIDTH*3 -#define PATTERNDESTX_BASE 7 -#define PATTERNDESTY_BASE 18 -#define ZOOM 2 - -#define PALETTEWIDTH 32*4*4 -#define PALETTEHEIGHT 32*2 -#define PALETTEBITWIDTH PALETTEWIDTH*3 -#define PALETTEDESTX_BASE 7 -#define PALETTEDESTY_BASE 18 - -#define TBM_SETPOS (WM_USER+5) -#define TBM_SETRANGE (WM_USER+6) -#define TBM_GETPOS (WM_USER) - -int patternDestX = PATTERNDESTX_BASE; -int patternDestY = PATTERNDESTY_BASE; -int paletteDestX = PALETTEDESTX_BASE; -int paletteDestY = PALETTEDESTY_BASE; - -BITMAPINFO bmInfo; -HDC pDC,TmpDC0,TmpDC1; -HBITMAP TmpBmp0,TmpBmp1; -HGDIOBJ TmpObj0,TmpObj1; - -BITMAPINFO bmInfo2; -HDC TmpDC2,TmpDC3; -HBITMAP TmpBmp2,TmpBmp3; -HGDIOBJ TmpObj2,TmpObj3; - - -void PPUViewDoBlit() -{ - if (!hPPUView) - return; - if (PPUViewSkip < PPUViewRefresh) - { - PPUViewSkip++; - return; - } - PPUViewSkip = 0; - - StretchBlt(pDC, patternDestX, patternDestY, PATTERNWIDTH * ZOOM, PATTERNHEIGHT * ZOOM, TmpDC0, 0, PATTERNHEIGHT - 1, PATTERNWIDTH, -PATTERNHEIGHT, SRCCOPY); - StretchBlt(pDC, patternDestX + (PATTERNWIDTH * ZOOM) + 1, patternDestY, PATTERNWIDTH * ZOOM, PATTERNHEIGHT * ZOOM, TmpDC1, 0, PATTERNHEIGHT - 1, PATTERNWIDTH, -PATTERNHEIGHT, SRCCOPY); - StretchBlt(pDC, paletteDestX, paletteDestY, PALETTEWIDTH, PALETTEHEIGHT, TmpDC2, 0, PALETTEHEIGHT - 1, PALETTEWIDTH, -PALETTEHEIGHT, SRCCOPY); -} - -//---------CDLogger VROM -extern unsigned char *cdloggervdata; -extern unsigned int cdloggerVideoDataSize; - -void DrawPatternTable(uint8 *bitmap, uint8 *table, uint8 *log, uint8 pal) -{ - int i,j,x,y,index=0; - int p=0,tmp; - uint8 chr0,chr1,logs; - uint8 *pbitmap = bitmap; - - pal <<= 2; - for (i = 0; i < 16; i++) //Columns - { - for (j = 0; j < 16; j++) //Rows - { - //----------------------------------------------- - // 8x8 sprite - for (y = 0; y < 8; y++) - { - chr0 = table[index]; - chr1 = table[index + 8]; - logs = log[index] & log[index + 8]; - tmp = 7; - if (PPUView_maskUnusedGraphics && cdloggerVideoDataSize && (((logs & 3) != 0) == PPUView_invertTheMask)) - { - // draw pixel ~8x darker - for (x = 0; x < 8; x++) - { - p = (chr0 >> tmp) & 1; - p |= ((chr1 >> tmp) & 1) << 1; - p = palcache[p | pal]; - tmp--; - *(uint8*)(pbitmap++) = palo[p].b >> 3; - *(uint8*)(pbitmap++) = palo[p].g >> 3; - *(uint8*)(pbitmap++) = palo[p].r >> 3; - } - } else - { - for (x = 0; x < 8; x++) - { - p = (chr0 >> tmp) & 1; - p |= ((chr1 >> tmp) & 1) << 1; - p = palcache[p | pal]; - tmp--; - *(uint8*)(pbitmap++) = palo[p].b; - *(uint8*)(pbitmap++) = palo[p].g; - *(uint8*)(pbitmap++) = palo[p].r; - } - } - index++; - pbitmap += ((PALETTEBITWIDTH>>2)-24); - } - //------------------------------------------------ - index+=8; - pbitmap -= (((PALETTEBITWIDTH>>2)<<3)-24); - } - pbitmap += ((PALETTEBITWIDTH>>2)*7); - } -} - -void FCEUD_UpdatePPUView(int scanline, int refreshchr) -{ - if(!PPUViewer) return; - if(scanline != -1 && scanline != PPUViewScanline) return; - - int x,y,i; - uint8 *pbitmap = ppuv_palette; - - if(!hPPUView) return; - if(PPUViewSkip < PPUViewRefresh) return; - - if(refreshchr) - { - for (i = 0, x=0x1000; i < 0x1000; i++, x++) - { - chrcache0[i] = VPage[i>>10][i]; - chrcache1[i] = VPage[x>>10][x]; - if (cdloggerVideoDataSize) - { - int addr; - addr = &VPage[i >> 10][i] - CHRptr[0]; - if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize)) - logcache0[i] = cdloggervdata[addr]; - addr = &VPage[x >> 10][x] - CHRptr[0]; - if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize)) - logcache1[i] = cdloggervdata[addr]; - } else - { - logcache0[i] = 0; - logcache1[i] = 0; - } - } - } - - // update palette only if required - if (memcmp(palcache, PALRAM, 32) != 0) - { - // bbit note: let para know that this if is useless and - // will not work because of the lines below that change - // palcache which will make it not equal next time - - // cache palette content - memcpy(palcache,PALRAM,32); - palcache[0x10] = palcache[0x00]; - palcache[0x14] = palcache[0x00]; - palcache[0x18] = palcache[0x00]; - palcache[0x1C] = palcache[0x00]; - - //draw palettes - for (y = 0; y < PALETTEHEIGHT; y++) - { - for (x = 0; x < PALETTEWIDTH; x++) - { - i = (((y>>5)<<4)+(x>>5)); - *(uint8*)(pbitmap++) = palo[palcache[i]].b; - *(uint8*)(pbitmap++) = palo[palcache[i]].g; - *(uint8*)(pbitmap++) = palo[palcache[i]].r; - } - } - - //draw line seperators on palette - pbitmap = (ppuv_palette+PALETTEBITWIDTH*31); - for (x = 0; x < PALETTEWIDTH*2; x++) - { - *(uint8*)(pbitmap++) = 0; - *(uint8*)(pbitmap++) = 0; - *(uint8*)(pbitmap++) = 0; - } - pbitmap = (ppuv_palette-3); - for (y = 0; y < 64*3; y++) - { - if (!(y%3)) pbitmap += (32*4*3); - for (x = 0; x < 6; x++) - { - *(uint8*)(pbitmap++) = 0; - } - pbitmap += ((32*4*3)-6); - } - memcpy(palcache,PALRAM,32); //palcache which will make it not equal next time - } - - DrawPatternTable(pattern0,chrcache0,logcache0,pindex0); - DrawPatternTable(pattern1,chrcache1,logcache1,pindex1); - - //PPUViewDoBlit(); -} - -void KillPPUView() -{ - //GDI cleanup - DeleteObject(TmpBmp0); - SelectObject(TmpDC0,TmpObj0); - DeleteDC(TmpDC0); - DeleteObject(TmpBmp1); - SelectObject(TmpDC1,TmpObj1); - DeleteDC(TmpDC1); - DeleteObject(TmpBmp2); - SelectObject(TmpDC2,TmpObj2); - DeleteDC(TmpDC2); - ReleaseDC(hPPUView,pDC); - - DestroyWindow(hPPUView); - hPPUView=NULL; - PPUViewer=0; - PPUViewSkip=0; -} - -BOOL CALLBACK PPUViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT wrect; - char str[20]; - - switch(uMsg) - { - case WM_INITDIALOG: - { - if (PPUViewPosX==-32000) PPUViewPosX=0; //Just in case - if (PPUViewPosY==-32000) PPUViewPosY=0; - SetWindowPos(hwndDlg,0,PPUViewPosX,PPUViewPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER); - - // calculate bitmaps positions relative to their groupboxes - RECT rect; - POINT pt; - GetWindowRect(GetDlgItem(hwndDlg, GRP_PPUVIEW_TABLES), &rect); - pt.x = rect.left; - pt.y = rect.top; - ScreenToClient(hwndDlg, &pt); - patternDestX = pt.x + PATTERNDESTX_BASE; - patternDestY = pt.y + PATTERNDESTY_BASE; - GetWindowRect(GetDlgItem(hwndDlg, LBL_PPUVIEW_PALETTES), &rect); - pt.x = rect.left; - pt.y = rect.top; - ScreenToClient(hwndDlg, &pt); - paletteDestX = pt.x + PALETTEDESTX_BASE; - paletteDestY = pt.y + PALETTEDESTY_BASE; - - //prepare the bitmap attributes - //pattern tables - memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER)); - bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmInfo.bmiHeader.biWidth = PATTERNWIDTH; - bmInfo.bmiHeader.biHeight = PATTERNHEIGHT; - bmInfo.bmiHeader.biPlanes = 1; - bmInfo.bmiHeader.biBitCount = 24; - - //palettes - memset(&bmInfo2.bmiHeader,0,sizeof(BITMAPINFOHEADER)); - bmInfo2.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmInfo2.bmiHeader.biWidth = PALETTEWIDTH; - bmInfo2.bmiHeader.biHeight = PALETTEHEIGHT; - bmInfo2.bmiHeader.biPlanes = 1; - bmInfo2.bmiHeader.biBitCount = 24; - - //create memory dcs - pDC = GetDC(hwndDlg); // GetDC(GetDlgItem(hwndDlg,GRP_PPUVIEW_TABLES)); - TmpDC0 = CreateCompatibleDC(pDC); //pattern table 0 - TmpDC1 = CreateCompatibleDC(pDC); //pattern table 1 - TmpDC2 = CreateCompatibleDC(pDC); //palettes - - //create bitmaps and select them into the memory dc's - TmpBmp0 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern0,0,0); - TmpObj0 = SelectObject(TmpDC0,TmpBmp0); - TmpBmp1 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern1,0,0); - TmpObj1 = SelectObject(TmpDC1,TmpBmp1); - TmpBmp2 = CreateDIBSection(pDC,&bmInfo2,DIB_RGB_COLORS,(void**)&ppuv_palette,0,0); - TmpObj2 = SelectObject(TmpDC2,TmpBmp2); - - //Refresh Trackbar - SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETRANGE,0,(LPARAM)MAKELONG(0,25)); - SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETPOS,1,PPUViewRefresh); - - CheckDlgButton(hwndDlg, IDC_MASK_UNUSED_GRAPHICS, PPUView_maskUnusedGraphics ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_INVERT_THE_MASK, PPUView_invertTheMask ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_INVERT_THE_MASK), PPUView_maskUnusedGraphics ? true : false); - - //Set Text Limit - SendDlgItemMessage(hwndDlg,IDC_PPUVIEW_SCANLINE,EM_SETLIMITTEXT,3,0); - - //force redraw the first time the PPU Viewer is opened - PPUViewSkip=100; - - //clear cache - memset(palcache,0,32); - memset(chrcache0,0,0x1000); - memset(chrcache1,0,0x1000); - memset(logcache0,0,0x1000); - memset(logcache1,0,0x1000); - - PPUViewer=1; - break; - } - case WM_PAINT: - PPUViewDoBlit(); - break; - case WM_CLOSE: - case WM_QUIT: - KillPPUView(); - break; - case WM_MOVING: - break; - case WM_MOVE: - if (!IsIconic(hwndDlg)) { - GetWindowRect(hwndDlg,&wrect); - PPUViewPosX = wrect.left; - PPUViewPosY = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(PPUViewPosX,PPUViewPosY,wrect.right); - #endif - } - break; - case WM_LBUTTONDBLCLK: - case WM_LBUTTONDOWN: - { - // redraw now - PPUViewSkip = PPUViewRefresh; - FCEUD_UpdatePPUView(-1, 0); - PPUViewDoBlit(); - break; - } - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - { - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - if(((mouse_x >= patternDestX) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM)))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) - { - if (pindex0 == 7) - pindex0 = 0; - else - pindex0++; - } else if(((mouse_x >= patternDestX + (PATTERNWIDTH * ZOOM) + 1) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM) * 2 + 1))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) - { - if (pindex1 == 7) - pindex1 = 0; - else - pindex1++; - } - // redraw now - PPUViewSkip = PPUViewRefresh; - FCEUD_UpdatePPUView(-1, 0); - PPUViewDoBlit(); - break; - } - case WM_MOUSEMOVE: - mouse_x = GET_X_LPARAM(lParam); - mouse_y = GET_Y_LPARAM(lParam); - if (((mouse_x >= patternDestX) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM)))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) - { - mouse_x = (mouse_x - patternDestX) / (8 * ZOOM); - mouse_y = (mouse_y - patternDestY) / (8 * ZOOM); - sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,str); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes"); - } else if (((mouse_x >= patternDestX + (PATTERNWIDTH * ZOOM) + 1) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM) * 2 + 1))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) - { - mouse_x = (mouse_x - (patternDestX + (PATTERNWIDTH * ZOOM) + 1)) / (8 * ZOOM); - mouse_y = (mouse_y - patternDestY) / (8 * ZOOM); - sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,str); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes"); - } - else if(((mouse_x >= paletteDestX) && (mouse_x < (paletteDestX + PALETTEWIDTH))) && (mouse_y >= paletteDestY) && (mouse_y < (paletteDestY + PALETTEHEIGHT))) - { - mouse_x = (mouse_x - paletteDestX) / 32; - mouse_y = (mouse_y - paletteDestY) / 32; - sprintf(str,"Palette: $%02X",palcache[(mouse_y<<4)|mouse_x]); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,str); - } else - { - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:"); - SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes"); - } - break; - case WM_NCACTIVATE: - sprintf(str,"%d",PPUViewScanline); - SetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str); - break; - case WM_COMMAND: - { - switch(HIWORD(wParam)) - { - case EN_UPDATE: - { - GetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str,4); - sscanf(str,"%d",&PPUViewScanline); - if(PPUViewScanline > 239) PPUViewScanline = 239; - break; - } - case BN_CLICKED: - { - switch(LOWORD(wParam)) - { - case IDC_MASK_UNUSED_GRAPHICS: - { - PPUView_maskUnusedGraphics ^= 1; - CheckDlgButton(hwndDlg, IDC_MASK_UNUSED_GRAPHICS, PPUView_maskUnusedGraphics ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_INVERT_THE_MASK), PPUView_maskUnusedGraphics ? true : false); - // redraw now - PPUViewSkip = PPUViewRefresh; - FCEUD_UpdatePPUView(-1, 0); - PPUViewDoBlit(); - break; - } - case IDC_INVERT_THE_MASK: - { - PPUView_invertTheMask ^= 1; - CheckDlgButton(hwndDlg, IDC_INVERT_THE_MASK, PPUView_invertTheMask ? BST_CHECKED : BST_UNCHECKED); - // redraw now - PPUViewSkip = PPUViewRefresh; - FCEUD_UpdatePPUView(-1, 0); - PPUViewDoBlit(); - break; - } - } - } - } - break; - } - case WM_HSCROLL: - if(lParam) - { - //refresh trackbar - PPUViewRefresh = SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_GETPOS,0,0); - } - break; - } - return FALSE; -} - -void DoPPUView() -{ - if(!GameInfo) { - FCEUD_PrintError("You must have a game loaded before you can use the PPU Viewer."); - return; - } - if(GameInfo->type==GIT_NSF) { - FCEUD_PrintError("Sorry, you can't use the PPU Viewer with NSFs."); - return; - } - - if(!hPPUView) hPPUView = CreateDialog(fceu_hInstance,"PPUVIEW",NULL,PPUViewCallB); - if(hPPUView) - { - //SetWindowPos(hPPUView,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); - ShowWindow(hPPUView, SW_SHOWNORMAL); - SetForegroundWindow(hPPUView); - // redraw now - PPUViewSkip = PPUViewRefresh; - FCEUD_UpdatePPUView(-1,1); - PPUViewDoBlit(); - } -} diff --git a/branches/fceux-2.2.2/src/drivers/win/ppuview.h b/branches/fceux-2.2.2/src/drivers/win/ppuview.h deleted file mode 100644 index 9ea092dd..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/ppuview.h +++ /dev/null @@ -1,6 +0,0 @@ -extern int PPUViewScanline; -extern int PPUViewer; -extern int scanline; -void DoPPUView(); -void PPUViewDoBlit(); - diff --git a/branches/fceux-2.2.2/src/drivers/win/res.rc b/branches/fceux-2.2.2/src/drivers/win/res.rc deleted file mode 100644 index 223661e5..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/res.rc +++ /dev/null @@ -1,2487 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Íåéòðàëüíûé resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON3 ICON "res\\taseditor-icon.ico" -IDI_ICON4 ICON "res\\taseditor-icon32.ico" -ICON_1 ICON "res/ICON_1.ico" -ICON_2 ICON "res/ICON_2.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -FCEUMENU MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Open...", MENU_OPEN_FILE - MENUITEM "&Close", MENU_CLOSE_FILE - MENUITEM "&Recent", MENU_RECENT_FILES - MENUITEM SEPARATOR - POPUP "&Savestate" - BEGIN - MENUITEM "&Load State", MENU_LOADSTATE - MENUITEM "&Save State", MENU_SAVESTATE - MENUITEM "Load State &From...", MENU_LOAD_STATE - MENUITEM "Save State &As...", MENU_SAVE_STATE - MENUITEM SEPARATOR - MENUITEM "&Next save slot", MENU_NEXTSAVESTATE - MENUITEM "&Previous save slot", MENU_PREVIOUSSAVESTATE - MENUITEM "&View save slots", MENU_VIEWSAVESLOTS - END - POPUP "&Movie" - BEGIN - MENUITEM "Recent", MENU_MOVIE_RECENT - MENUITEM "&Record Movie...", MENU_RECORD_MOVIE - MENUITEM "&Play Movie...", MENU_REPLAY_MOVIE - MENUITEM "&Stop Movie", MENU_STOP_MOVIE - MENUITEM "Play from &Beginning", ID_FILE_PLAYMOVIEFROMBEGINNING - MENUITEM SEPARATOR - MENUITEM "&Read-only", ID_FILE_MOVIE_TOGGLEREAD - END - POPUP "&AVI/Wav" - BEGIN - MENUITEM "&Record AVI...", MENU_RECORD_AVI - MENUITEM "&Stop AVI", MENU_STOP_AVI - MENUITEM "&Record WAV...", MENU_RECORD_WAV - MENUITEM "&Stop WAV", MENU_STOP_WAV - MENUITEM SEPARATOR - MENUITEM "Enable HUD recording", ID_AVI_ENABLEHUDRECORDING - MENUITEM "Disable messages recording", ID_AVI_DISMOVIEMESSAGE - END - POPUP "&Lua" - BEGIN - MENUITEM "&Recent", MENU_LUA_RECENT - MENUITEM "&New Lua Script Window...", ID_FILE_OPENLUAWINDOW - MENUITEM "&Close All Script Windows", ID_FILE_CLOSELUAWINDOWS - END - MENUITEM "&Screenshot", ID_FILE_SCREENSHOT - MENUITEM "Save Screenshot As...", ID_FILE_SAVESCREENSHOTAS - MENUITEM SEPARATOR - MENUITEM "E&xit\tAlt+F4", MENU_EXIT - END - POPUP "&NES" - BEGIN - MENUITEM "&Reset", MENU_RESET - MENUITEM "&Power", MENU_POWER - MENUITEM SEPARATOR - MENUITEM "&Eject/Insert Disk", MENU_EJECT_DISK - MENUITEM "&Switch Disk Side", MENU_SWITCH_DISK - MENUITEM "&Insert Coin", MENU_INSERT_COIN - MENUITEM SEPARATOR - POPUP "E&mulation Speed" - BEGIN - MENUITEM "Speed &Up", ID_NES_SPEEDUP - MENUITEM "Slow &Down", ID_NES_SLOWDOWN - MENUITEM SEPARATOR - MENUITEM "&Pause", ID_NES_PAUSE - MENUITEM "&Slowest Speed", ID_NES_SLOWESTSPEED - MENUITEM "&Normal Speed", ID_NES_NORMALSPEED - MENUITEM "&Turbo", ID_NES_TURBO - MENUITEM "Set &Custom Speed", ID_EMULATIONSPEED_CUSTOMSPEED - MENUITEM SEPARATOR - MENUITEM "Set FrameAdvance Delay", ID_EMULATIONSPEED_SETFRAMEADVANCEDELAY - MENUITEM "Set custom speed for FrameAdvance", ID_EMULATIONSPEED_SETCUSTOMSPEEDFORFRAMEADVANCE - END - END - POPUP "&Config" - BEGIN - MENUITEM "&Hide Menu", MENU_HIDE_MENU - POPUP "&Enable" - BEGIN - MENUITEM "&Run in Background", MENU_RUN_IN_BACKGROUND - MENUITEM "&Background Input", MENU_BACKGROUND_INPUT - MENUITEM "&Auto-savestates", MENU_ENABLE_AUTOSAVE - MENUITEM "&Frame Adv. - Skip Lag", MENU_DISPLAY_FA_LAGSKIP - MENUITEM "Backup Savestates", ID_ENABLE_BACKUPSAVESTATES - MENUITEM "Compress Savestates", ID_ENABLE_COMPRESSSAVESTATES - MENUITEM "&Game Genie ROM", MENU_GAME_GENIE - MENUITEM "Auto-resume old play session", ID_ENABLE_AUTORESUME - END - POPUP "&Display" - BEGIN - POPUP "&Input Display" - BEGIN - MENUITEM "&Off", MENU_INPUTDISPLAY_0 - MENUITEM "&1 player", MENU_INPUTDISPLAY_1 - MENUITEM "&2 player", MENU_INPUTDISPLAY_2 - MENUITEM "&4 player", MENU_INPUTDISPLAY_4 - MENUITEM SEPARATOR - MENUITEM "old style disp.", ID_INPUTDISPLAY_OLDSTYLEDISP - END - MENUITEM "&Lag Counter", MENU_DISPLAY_LAGCOUNTER - MENUITEM "&Frame Counter", ID_DISPLAY_FRAMECOUNTER - MENUITEM "&Rerecord Counter", ID_DISPLAY_RERECORDCOUNTER - MENUITEM "&Movie status icon", ID_DISPLAY_MOVIESTATUSICON - MENUITEM "FPS", ID_DISPLAY_FPS - MENUITEM SEPARATOR - MENUITEM "Graphics: &BG", MENU_DISPLAY_BG - MENUITEM "Graphics: &OBJ", MENU_DISPLAY_OBJ - END - MENUITEM SEPARATOR - MENUITEM "&PAL Emulation", MENU_PAL - POPUP "PPU" - BEGIN - MENUITEM "Old PPU", ID_OLDPPU - MENUITEM "New PPU (slow!)", ID_NEWPPU - END - MENUITEM SEPARATOR - MENUITEM "&Directories...", MENU_DIRECTORIES - MENUITEM "&GUI...", MENU_GUI_OPTIONS - MENUITEM "&Input...", MENU_INPUT - MENUITEM "&Network Play...", MENU_NETWORK - MENUITEM "&Palette...", MENU_PALETTE - MENUITEM "&Sound...", MENU_SOUND - MENUITEM "&Timing...", MENU_TIMING - MENUITEM "&Video...", MENU_VIDEO - MENUITEM "&Movie options...", MENU_MOVIEOPTIONS - MENUITEM "&Map Hotkeys...", MENU_HOTKEYS - MENUITEM SEPARATOR - MENUITEM "Save Config File", ID_CONFIG_SAVECONFIGFILE - END - POPUP "&Tools" - BEGIN - MENUITEM "&Cheats...", MENU_CHEATS - MENUITEM "RAM Search...", ID_RAM_SEARCH - MENUITEM "RAM Watch...", ID_RAM_WATCH - MENUITEM "&Memory Watch...", MENU_MEMORY_WATCH - MENUITEM "&TAS Editor...", MENU_TASEDITOR - MENUITEM "Convert &FCM...", MENU_CONVERT_MOVIE - MENUITEM SEPARATOR - POPUP "Autofire &Pattern" - BEGIN - MENUITEM "1 on, 1 off", MENU_AUTOFIRE_PATTERN_1 - MENUITEM "1 on, 2 off", MENU_AUTOFIRE_PATTERN_2 - MENUITEM "1 on, 3 off", MENU_AUTOFIRE_PATTERN_3 - MENUITEM "1 on, 4 off", ID_DEBUG_DEBUGGER - MENUITEM "1 on, 5 off", ID_DEBUG_PPUVIEWER - MENUITEM "2 on, 1 off", ID_DEBUG_NAMETABLEVIEWER - MENUITEM "2 on, 2 off", ID_DEBUG_HEXEDITOR - MENUITEM "2 on, 3 off", ID_DEBUG_TRACELOGGER - MENUITEM "2 on, 4 off", MENU_AUTOFIRE_PATTERN_9 - MENUITEM "3 on, 1 off", ID_DEBUG_GAMEGENIEDECODER - MENUITEM "3 on, 2 off", ID_DEBUG_CDLOGGER - MENUITEM "3 on, 3 off", MENU_AUTOFIRE_PATTERN_12 - MENUITEM "4 on, 1 off", MENU_AUTOFIRE_PATTERN_13 - MENUITEM "4 on, 2 off", MENU_AUTOFIRE_PATTERN_14 - MENUITEM "5 on, 1 off", MENU_AUTOFIRE_PATTERN_15 - END - POPUP "Autofire &Offset" - BEGIN - MENUITEM "0 frames", MENU_AUTOFIRE_OFFSET_1 - MENUITEM "1 frame", MENU_AUTOFIRE_OFFSET_2 - MENUITEM "2 frames", MENU_AUTOFIRE_OFFSET_3 - MENUITEM "3 frames", MENU_AUTOFIRE_OFFSET_4 - MENUITEM "4 frames", MENU_AUTOFIRE_OFFSET_5 - MENUITEM "5 frames", MENU_AUTOFIRE_OFFSET_6 - END - MENUITEM "&Alternate A and B", MENU_ALTERNATE_AB - MENUITEM SEPARATOR - MENUITEM "Te&xt Hooker...", ID_TOOLS_TEXTHOOKER - END - POPUP "&Debug" - BEGIN - MENUITEM "&Debugger...", MENU_DEBUGGER - MENUITEM "&PPU Viewer...", MENU_PPUVIEWER - MENUITEM "&Name Table Viewer...", MENU_NAMETABLEVIEWER - MENUITEM "&Hex Editor...", MENU_HEXEDITOR - MENUITEM "&Trace Logger...", MENU_TRACELOGGER - MENUITEM "&Code/Data Logger...", MENU_CDLOGGER - MENUITEM "&Game Genie Decoder/Encoder...", MENU_GAMEGENIEDECODER - END - POPUP "&Help" - BEGIN - MENUITEM "&Help...", MENU_HELP - MENUITEM "&Message Log", MENU_MSGLOG - MENUITEM SEPARATOR - MENUITEM "&About", MENU_ABOUT - END -END - -TASEDITORMENU MENUEX -BEGIN - POPUP "File", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "New", ID_FILE_NEW,MFT_STRING,MFS_ENABLED - MENUITEM "Open", ID_FILE_OPENPROJECT,MFT_STRING,MFS_ENABLED - MENUITEM "Save\tCtrl+S", ID_FILE_SAVEPROJECT,MFT_STRING,MFS_ENABLED - MENUITEM "Save As", ID_FILE_SAVEPROJECTAS,MFT_STRING,MFS_ENABLED - MENUITEM "Save Compact", ID_FILE_SAVECOMPACT,MFT_STRING,MFS_ENABLED - MENUITEM "Recent", ID_FILE_RECENT,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Import Input", ID_FILE_IMPORT,MFT_STRING,MFS_ENABLED - MENUITEM "Export to FM2", ID_FILE_EXPORTFM2,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Close\tAlt+F4", ID_FILE_CLOSE,MFT_STRING,MFS_ENABLED - END - POPUP "Edit", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "Undo\tCtrl+Z", ID_EDIT_UNDO,MFT_STRING,MFS_ENABLED - MENUITEM "Redo\tCtrl+Y", ID_EDIT_REDO,MFT_STRING,MFS_ENABLED - MENUITEM "Selection Undo\tCtrl+Q", ID_EDIT_SELECTIONUNDO,MFT_STRING,MFS_ENABLED - MENUITEM "Selection Redo\tCtrl+W", ID_EDIT_SELECTIONREDO,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Deselect", ID_EDIT_DESELECT,MFT_STRING,MFS_ENABLED - MENUITEM "Select All", ID_EDIT_SELECTALL,MFT_STRING,MFS_ENABLED - MENUITEM "Select between Markers\tCtrl+A", ID_EDIT_SELECTMIDMARKERS,MFT_STRING,MFS_ENABLED - MENUITEM "Reselect Clipboard\tCtrl+B", ID_EDIT_RESELECTCLIPBOARD,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Copy\tCtrl+C", ID_EDIT_COPY,MFT_STRING,MFS_ENABLED - MENUITEM "Paste\tCtrl+V", ID_EDIT_PASTE,MFT_STRING,MFS_ENABLED - MENUITEM "PasteInsert\tCtrl+Shift+V", ID_EDIT_PASTEINSERT,MFT_STRING,MFS_ENABLED - MENUITEM "Cut\tCtrl+X", ID_EDIT_CUT,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Clear\tDel", ID_EDIT_CLEAR,MFT_STRING,MFS_ENABLED - MENUITEM "Delete\tCtrl+Del", ID_EDIT_DELETE,MFT_STRING,MFS_ENABLED - MENUITEM "Clone\tCtrl+Ins", ID_EDIT_CLONEFRAMES,MFT_STRING,MFS_ENABLED - MENUITEM "Insert\tCtrl+Shift+Ins", ID_EDIT_INSERTFRAMES,MFT_STRING,MFS_ENABLED - MENUITEM "Insert # of Frames\tIns", ID_EDIT_INSERT,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Truncate movie", ID_EDIT_TRUNCATE,MFT_STRING,MFS_ENABLED - END - POPUP "View", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "Find Note window\tCtrl+F", ID_VIEW_FINDNOTE,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Display Branch Screenshots", ID_VIEW_SHOWBRANCHSCREENSHOTS,MFT_STRING,MFS_ENABLED - MENUITEM "Display Branch Descriptions", ID_VIEW_SHOWBRANCHTOOLTIPS,MFT_STRING,MFS_ENABLED - MENUITEM "Enable Hot Changes", ID_VIEW_ENABLEHOTCHANGES,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Follow Undo context", ID_VIEW_JUMPWHENMAKINGUNDO,MFT_STRING,MFS_ENABLED - MENUITEM "Follow Marker Note context", ID_VIEW_FOLLOWMARKERNOTECONTEXT,MFT_STRING,MFS_ENABLED - END - POPUP "Config", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "Project file saving options", ID_CONFIG_SAVING_OPTIONS,MFT_STRING,MFS_ENABLED - MENUITEM "Set max Undo levels", ID_CONFIG_SETMAXUNDOLEVELS,MFT_STRING,MFS_ENABLED - MENUITEM "Set Greenzone capacity", ID_CONFIG_SETGREENZONECAPACITY,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Enable Greenzoning", ID_CONFIG_ENABLEGREENZONING,MFT_STRING,MFS_ENABLED - MENUITEM "Autofire Pattern skips Lag", ID_CONFIG_PATTERNSKIPSLAG,MFT_STRING,MFS_ENABLED - MENUITEM "Auto-adjust Input according to Lag", ID_CONFIG_ADJUSTLAG,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Draw Input by dragging", ID_CONFIG_DRAWINPUTBYDRAGGING,MFT_STRING,MFS_ENABLED - MENUITEM "Combine consecutive Recordings/Draws", ID_CONFIG_COMBINECONSECUTIVERECORDINGS,MFT_STRING,MFS_ENABLED - MENUITEM "Use 1P keys for all single Recordings", ID_CONFIG_USE1PFORRECORDING,MFT_STRING,MFS_ENABLED - MENUITEM "Use Input keys for Column Set", ID_CONFIG_USEINPUTKEYSFORCOLUMNSET,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Bind Markers to Input", ID_CONFIG_BINDMARKERSTOINPUT,MFT_STRING,MFS_ENABLED - MENUITEM "Empty new Marker Notes", ID_CONFIG_EMPTYNEWMARKERNOTES,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Old control scheme for Branching", ID_CONFIG_OLDBRANCHINGCONTROLS,MFT_STRING,MFS_ENABLED - MENUITEM "Branches restore entire Movie", ID_CONFIG_BRANCHESRESTOREFULLMOVIE,MFT_STRING,MFS_ENABLED - MENUITEM "HUD in Branch screenshots", ID_CONFIG_HUDINBRANCHSCREENSHOTS,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "Autopause at the end of Movie", ID_CONFIG_AUTOPAUSEATTHEENDOFMOVIE,MFT_STRING,MFS_ENABLED - END - POPUP "Help", 65535,MFT_STRING,MFS_ENABLED - BEGIN - MENUITEM "Open TAS Editor Manual", ID_HELP_OPEN_MANUAL,MFT_STRING,MFS_ENABLED - MENUITEM "Enable Tooltips", ID_HELP_TOOLTIPS,MFT_STRING,MFS_ENABLED - MENUITEM MFT_SEPARATOR - MENUITEM "About", ID_HELP_ABOUT,MFT_STRING,MFS_ENABLED - END - POPUP "Pattern", 65535,MFT_STRING | MFT_RIGHTJUSTIFY,MFS_ENABLED - BEGIN - MENUITEM "Dummy", ID_PATTERN_TEST,MFT_STRING,MFS_ENABLED - END -END - -MEMVIEWMENU MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Save Rom", MENU_MV_FILE_SAVE - MENUITEM "S&ave Rom As...", MENU_MV_FILE_SAVE_AS - MENUITEM "&Load *.TBL File", MENU_MV_FILE_LOAD_TBL - MENUITEM "&Unload *.TBL file", MENU_MV_FILE_UNLOAD_TBL - POPUP "&Dump to file" - BEGIN - MENUITEM "&Ram", MENU_MV_FILE_DUMP_RAM - MENUITEM "&PPU Memory", MENU_MV_FILE_DUMP_PPU - END - MENUITEM "&Goto Address\tCtrl+A", MENU_MV_FILE_GOTO_ADDRESS - MENUITEM SEPARATOR - MENUITEM "&Close\tAlt+F4", ID_MEMWVIEW_FILE_CLOSE - END - POPUP "&Edit" - BEGIN - MENUITEM "&Undo\tCtrl+Z", MENU_MV_EDIT_UNDO - MENUITEM SEPARATOR - MENUITEM "&Copy", MENU_MV_EDIT_COPY - MENUITEM "&Paste", MENU_MV_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "&Find...", MENU_MV_EDIT_FIND - END - POPUP "&View" - BEGIN - MENUITEM "&NES Memory", MENU_MV_VIEW_RAM - MENUITEM "&PPU Memory", MENU_MV_VIEW_PPU - MENUITEM "&ROM File", MENU_MV_VIEW_ROM - END - POPUP "Highlighting" - BEGIN - MENUITEM "Highlight Activity", ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY - MENUITEM "Set fading period...", ID_HIGHLIGHTING_SETFADINGPERIOD - MENUITEM "Fade when paused", ID_HIGHLIGHTING_FADEWHENPAUSED - END - POPUP "&Bookmarks" - BEGIN - MENUITEM "&Remove all bookmarks", MENU_MV_BOOKMARKS_RM_ALL - END - POPUP "Help" - BEGIN - MENUITEM "&Help...", MENU_MV_HELP - END -END - -MEMWATCHMENU MENU -BEGIN - POPUP "&File " - BEGIN - MENUITEM "&New...\tCtrl+N", MEMW_FILE_NEW - MENUITEM "&Open...\tCtrl+O", MEMW_FILE_OPEN - MENUITEM "&Save\tCtrl+S", MEMW_FILE_SAVE - MENUITEM "S&ave As..\tCtrl+Shift+S", MEMW_FILE_SAVEAS - MENUITEM "&Recent", ID_FILE_RECENT - MENUITEM SEPARATOR - MENUITEM "&Close\tAlt+F4", MEMW_FILE_CLOSE - END - POPUP "&Options" - BEGIN - MENUITEM "&Load on Startup", MEMW_OPTIONS_LOADSTART - MENUITEM "Load Last &File on Startup", MEMW_OPTIONS_LOADLASTFILE - MENUITEM SEPARATOR - MENUITEM "&Collapse to 1 column", MEMW_OPTIONS_EXPANDCOLLAPSE - MENUITEM SEPARATOR - MENUITEM "Bind to Main Window", ID_OPTIONS_BINDTOMAINWINDOW - END - POPUP "&Help" - BEGIN - MENUITEM "&MemWatch Commands", MEMW_HELP_WCOMMANDS - END -END - -TASEDITORCONTEXTMENUS MENU -BEGIN - POPUP "Selected" - BEGIN - MENUITEM "Set Markers\tDbl-Clk", ID_SELECTED_SETMARKERS - MENUITEM "Remove Markers", ID_SELECTED_REMOVEMARKERS - MENUITEM SEPARATOR - MENUITEM "Deselect", ID_SELECTED_DESELECT - MENUITEM "Select between Markers\tCtrl+A", ID_SELECTED_SELECTMIDMARKERS - MENUITEM SEPARATOR - MENUITEM "Ungreenzone", ID_SELECTED_UNGREENZONE - MENUITEM SEPARATOR - MENUITEM "Clear\tDel", ID_CONTEXT_SELECTED_CLEARFRAMES - MENUITEM "Delete\tCtrl+Del", ID_CONTEXT_SELECTED_DELETEFRAMES - MENUITEM "Clone\tCtrl+Ins", ID_SELECTED_CLONE - MENUITEM "Insert\tCtrl+Shift+Ins", ID_CONTEXT_SELECTED_INSERTFRAMES - MENUITEM "Insert # of Frames\tIns", ID_CONTEXT_SELECTED_INSERTFRAMES2 - MENUITEM SEPARATOR - MENUITEM "Truncate movie", ID_CONTEXT_SELECTED_TRUNCATE - END -END - -FCEUCONTEXTMENUS MENU -BEGIN - POPUP "Game+Movie+readonly" - BEGIN - MENUITEM "Toggle to read+write", FCEUX_CONTEXT_READONLYTOGGLE - MENUITEM "Play Movie from Beginning", FCEU_CONTEXT_PLAYMOVIEFROMBEGINNING - MENUITEM "Stop Movie Replay", FCEU_CONTEXT_STOPMOVIE - MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES - MENUITEM SEPARATOR - MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE - MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO - MENUITEM SEPARATOR - MENUITEM "Help....", FCEU_CONTEXT_MOVIEHELP - MENUITEM SEPARATOR - MENUITEM "Use Config > Gui to get zapper right click", FCEUX_CONTEXT_GUICONFIG - END - POPUP "Game+NoMovie" - BEGIN - MENUITEM "Play Movie...", FCEUX_CONTEXT_REPLAYMOVIE - MENUITEM "Record Movie...", FCEUX_CONTEXT_RECORDMOVIE - MENUITEM "Load Last Movie", FCEUX_CONTEXT_LOADLASTMOVIE - MENUITEM SEPARATOR - MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE - MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE - MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO - MENUITEM "Screenshot", FCEUX_CONTEXT_SCREENSHOT - MENUITEM SEPARATOR - MENUITEM "Close ROM", FCEU_CONTEXT_CLOSEROM - MENUITEM SEPARATOR - MENUITEM "Use Config > Gui to get zapper right click", FCEUX_CONTEXT_GUICONFIG - END - POPUP "NoGame" - BEGIN - MENUITEM "Open ROM", FCEU_CONTEXT_OPENROM - MENUITEM "Last ROM used", FCEUX_CONTEXT_RECENTROM1 - MENUITEM SEPARATOR - MENUITEM "Help...", FCEU_CONTEXT_FCEUHELP - MENUITEM SEPARATOR - MENUITEM "Use Config > Gui to get zapper right click", FCEUX_CONTEXT_GUICONFIG - END - POPUP "Game+Movie+readwrite" - BEGIN - MENUITEM "Toggle to Read-only", FCEUX_CONTEXT_READONLYTOGGLE - MENUITEM "Play Movie From Beginning", FCEU_CONTEXT_PLAYMOVIEFROMBEGINNING - MENUITEM "Stop Movie Recording", FCEU_CONTEXT_STOPMOVIE - MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES - MENUITEM "Make backup", FCEUX_CONTEXT_MAKEBACKUP - MENUITEM "Save Movie As...", FCEUX_CONTEXT_SAVEMOVIEAS - MENUITEM SEPARATOR - MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE - MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE - MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO - MENUITEM SEPARATOR - MENUITEM "&Mode: Full state-movie loads", ID_CONTEXT_FULLSAVESTATES - MENUITEM SEPARATOR - MENUITEM "Help...", FCEU_CONTEXT_MOVIEHELP - MENUITEM SEPARATOR - MENUITEM "Use Config > Gui to get zapper right click", FCEUX_CONTEXT_GUICONFIG - END -END - -RAMWATCH_MENU MENU -BEGIN - POPUP "File" - BEGIN - MENUITEM "&New list\tCtrl N", RAMMENU_FILE_NEW - MENUITEM "&Open...\tCtrl O", RAMMENU_FILE_OPEN - MENUITEM "&Save\tCtrl S", RAMMENU_FILE_SAVE - MENUITEM "Sa&ve As...\tCtrl Shift S", RAMMENU_FILE_SAVEAS - MENUITEM "&Append file...", RAMMENU_FILE_APPEND - MENUITEM "Recent", RAMMENU_FILE_RECENT - MENUITEM SEPARATOR - MENUITEM "Auto-&load", RAMMENU_FILE_AUTOLOAD - MENUITEM "Save Window Position", RAMMENU_FILE_SAVEWINDOW - MENUITEM SEPARATOR - MENUITEM "&Close\tAlt F4", IDCANCEL - END - POPUP "Watches" - BEGIN - MENUITEM "&New Watch\tN", IDC_C_WATCH - MENUITEM "&Edit Watch\tE", IDC_C_WATCH_EDIT - MENUITEM "&Remove Watch\tR", IDC_C_WATCH_REMOVE - MENUITEM "Duplicate Watch\tA", IDC_C_WATCH_DUPLICATE - MENUITEM "Add &Separator\tS", IDC_C_WATCH_SEPARATE - MENUITEM SEPARATOR - MENUITEM "Move Up\tU", IDC_C_WATCH_UP - MENUITEM "Move Down\tD", IDC_C_WATCH_DOWN - END -END - -CHEATCONTEXTMENUS MENU -BEGIN - POPUP "CheatListPopup" - BEGIN - MENUITEM "Toggle selected Cheats\tDbl-Clk", CHEAT_CONTEXT_TOGGLECHEAT - MENUITEM "Poke Cheat Value", CHEAT_CONTEXT_POKECHEATVALUE - MENUITEM "Goto in Hex Editor", CHEAT_CONTEXT_GOTOINHEXEDITOR - MENUITEM "Delete selected Cheats", ID_CHEATLISTPOPUP_DELETESELECTEDCHEATS - END -END - -DEBUGCONTEXTMENUS MENU -BEGIN - POPUP "DebugListPopup" - BEGIN - MENUITEM "Toggle Breakpoint\tDbl-Clk", DEBUGGER_CONTEXT_TOGGLEBREAK - END -END - -LUAWINDOW_MENU MENU -BEGIN - POPUP "Console" - BEGIN - MENUITEM "&Font...", IDC_LUACONSOLE_CHOOSEFONT - MENUITEM "Clear", IDC_LUACONSOLE_CLEAR - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -DIRCONFIG DIALOGEX 63, 7, 305, 255 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Directories Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",CLOSE_BUTTON,175,230,56,14 - PUSHBUTTON "Cancel",BTN_CANCEL,239,230,56,14 - EDITTEXT 113,71,9,158,12,ES_AUTOHSCROLL - EDITTEXT EDIT_ROMS,71,27,158,12,ES_AUTOHSCROLL - EDITTEXT 101,71,45,158,12,ES_AUTOHSCROLL - EDITTEXT 102,71,63,158,12,ES_AUTOHSCROLL - EDITTEXT 103,71,81,158,12,ES_AUTOHSCROLL - EDITTEXT 104,71,99,158,12,ES_AUTOHSCROLL - EDITTEXT 105,71,117,158,12,ES_AUTOHSCROLL - EDITTEXT 106,71,135,158,12,ES_AUTOHSCROLL - EDITTEXT 107,71,153,158,12,ES_AUTOHSCROLL - EDITTEXT 110,71,171,158,12,ES_AUTOHSCROLL - EDITTEXT 111,71,189,158,12,ES_AUTOHSCROLL - EDITTEXT 112,71,207,158,12,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",213,239,8,56,14 - PUSHBUTTON "Browse...",BUTTON_ROMS,239,26,56,14 - PUSHBUTTON "Browse...",201,239,44,56,14 - PUSHBUTTON "Browse...",202,239,62,56,14 - PUSHBUTTON "Browse...",203,239,80,56,14 - PUSHBUTTON "Browse...",204,239,98,56,14 - PUSHBUTTON "Browse...",205,239,116,56,14 - PUSHBUTTON "Browse...",206,239,134,56,14 - PUSHBUTTON "Browse...",207,239,152,56,14 - PUSHBUTTON "Browse...",210,239,170,56,14 - PUSHBUTTON "Browse...",211,239,188,56,14 - PUSHBUTTON "Browse...",212,239,206,56,14 - LTEXT "Base Directory",IDC_STATIC,10,10,47,8 - LTEXT "Roms",IDC_STATIC,10,28,19,8 - LTEXT "Battery Saves",IDC_STATIC,10,46,45,8 - LTEXT "Save States",IDC_STATIC,10,64,41,9 - LTEXT "FDS Bios Rom",IDC_STATIC,10,82,47,8 - LTEXT "Screenshots",IDC_STATIC,10,100,40,8 - LTEXT "Cheats",IDC_STATIC,10,118,23,8 - LTEXT "Movies",IDC_STATIC,10,136,24,8 - LTEXT "Memory Watch",IDC_STATIC,10,154,52,9 - LTEXT "Input Presets",IDC_STATIC,10,172,42,8 - LTEXT "Lua Scripts",IDC_STATIC,10,190,36,8 - LTEXT "Avi Output",IDC_STATIC,10,208,34,8 -END - -DWBDIALOG DIALOG 33, 99, 250, 56 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "DWB!" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Text",LBL_DWBDIALOG_TEXT,7,9,237,8 - PUSHBUTTON "Clear",BTN_CLEAR,64,32,50,14 - PUSHBUTTON "Close",BTN_CLOSE,188,33,50,14 -END - -FKBDIALOG DIALOG 13, 72, 402, 194 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Family Keyboard Configuration" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,320,170,56,14 - LTEXT "Remember to push the ""Scroll Lock"" key during emulation to enable Family Keyboard input.",65503,18,6,370,12 - GROUPBOX "",65502,11,22,380,133,WS_GROUP - PUSHBUTTON "F1",300,22,43,32,12 - PUSHBUTTON "1",308,30,59,16,12 - PUSHBUTTON "F2",301,60,43,32,12 - PUSHBUTTON "F3",302,98,43,32,12 - PUSHBUTTON "F4",303,136,43,32,12 - PUSHBUTTON "F5",304,174,43,32,12 - PUSHBUTTON "F6",305,212,43,32,12 - PUSHBUTTON "F7",306,250,43,32,12 - PUSHBUTTON "F8",307,288,43,32,12 - PUSHBUTTON "2",309,49,59,16,12 - PUSHBUTTON "3",310,68,59,16,12 - PUSHBUTTON "4",311,87,59,16,12 - PUSHBUTTON "5",312,106,59,16,12 - PUSHBUTTON "6",313,125,59,16,12 - PUSHBUTTON "7",314,144,59,16,12 - PUSHBUTTON "8",315,163,59,16,12 - PUSHBUTTON "9",316,182,59,16,12 - PUSHBUTTON "0",317,201,59,16,12 - PUSHBUTTON "-",318,220,59,16,12 - PUSHBUTTON "^",319,239,59,16,12 - PUSHBUTTON "\\",320,258,59,16,12 - PUSHBUTTON "STP",321,277,59,16,12 - PUSHBUTTON "ESC",322,22,75,16,12 - PUSHBUTTON "Q",323,41,75,16,12 - PUSHBUTTON "W",324,60,75,16,12 - PUSHBUTTON "E",325,79,75,16,12 - PUSHBUTTON "R",326,98,75,16,12 - PUSHBUTTON "T",327,117,75,16,12 - PUSHBUTTON "Y",328,136,75,16,12 - PUSHBUTTON "U",329,155,75,16,12 - PUSHBUTTON "I",330,174,75,16,12 - PUSHBUTTON "O",331,193,75,16,12 - PUSHBUTTON "P",332,212,75,16,12 - PUSHBUTTON "@",333,231,75,16,12 - PUSHBUTTON "[",334,250,75,16,12 - PUSHBUTTON "RETURN",335,272,75,32,12 - PUSHBUTTON "CTR",336,26,91,16,12 - PUSHBUTTON "A",337,45,91,16,12 - PUSHBUTTON "S",338,64,91,16,12 - PUSHBUTTON "D",339,83,91,16,12 - PUSHBUTTON "F",340,102,91,16,12 - PUSHBUTTON "G",341,121,91,16,12 - PUSHBUTTON "H",342,140,91,16,12 - PUSHBUTTON "J",343,159,91,16,12 - PUSHBUTTON "K",344,178,91,16,12 - PUSHBUTTON "L",345,197,91,16,12 - PUSHBUTTON ";",346,216,91,16,12 - PUSHBUTTON ":",347,235,91,16,12 - PUSHBUTTON "]",348,254,91,16,12 - PUSHBUTTON "KANA",349,273,91,16,12 - PUSHBUTTON "Z",351,55,107,16,12 - PUSHBUTTON "X",352,74,107,16,12 - PUSHBUTTON "C",353,93,107,16,12 - PUSHBUTTON "V",354,112,107,16,12 - PUSHBUTTON "B",355,131,107,16,12 - PUSHBUTTON "N",356,150,107,16,12 - PUSHBUTTON "M",357,169,107,16,12 - PUSHBUTTON ",",358,188,107,16,12 - PUSHBUTTON ".",359,207,107,16,12 - PUSHBUTTON "/",360,226,107,16,12 - PUSHBUTTON "",361,245,107,16,12 - PUSHBUTTON "SHIFT",350,19,107,32,12 - PUSHBUTTON "SHIFT",362,265,107,32,12 - PUSHBUTTON "GRPH",363,74,123,16,12 - PUSHBUTTON "SPACE",364,93,123,149,12 - PUSHBUTTON "CLR",365,316,67,16,12 - PUSHBUTTON "INS",366,335,67,16,12 - PUSHBUTTON "DEL",367,354,67,16,12 - PUSHBUTTON "UP",368,327,83,32,12 - PUSHBUTTON "LEFT",369,310,99,32,12 - PUSHBUTTON "RIGHT",370,346,99,32,12 - PUSHBUTTON "DOWN",371,327,115,32,12 -END - -GAMEPADDIALOG DIALOGEX 4, 109, 243, 220 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Gamepad Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,173,196,56,14 - GROUPBOX "",GRP_GAMEPAD1,4,8,232,82,WS_GROUP - PUSHBUTTON "Up",304,35,27,24,12 - PUSHBUTTON "Left",306,9,45,25,12 - PUSHBUTTON "Right",307,60,45,24,12 - PUSHBUTTON "Down",305,35,64,24,12 - PUSHBUTTON "Select",302,91,45,26,12 - PUSHBUTTON "Start",303,126,45,26,12 - PUSHBUTTON "B",301,169,45,16,12 - PUSHBUTTON "A",300,195,45,16,12 - PUSHBUTTON "Turbo B",309,154,29,32,12 - PUSHBUTTON "Turbo A",308,195,29,32,12 - GROUPBOX "",GRP_GAMEPAD2,4,101,232,82,WS_GROUP - PUSHBUTTON "Up",314,35,120,24,12 - PUSHBUTTON "Left",316,9,138,25,12 - PUSHBUTTON "Right",317,60,138,24,12 - PUSHBUTTON "Down",315,35,157,24,12 - PUSHBUTTON "Select",312,91,138,26,12 - PUSHBUTTON "Start",313,126,138,26,12 - PUSHBUTTON "B",311,169,138,16,12 - PUSHBUTTON "A",310,195,138,16,12 - PUSHBUTTON "Turbo B",319,154,122,32,12 - PUSHBUTTON "Turbo A",318,195,122,32,12 -END - -GUICONFIG DIALOGEX 16, 123, 184, 158 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "GUI Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",BUTTON_CLOSE,65,136,56,14 - CONTROL "Load ""File Open"" dialog when FCEUX starts.",CB_LOAD_FILE_OPEN, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,8,168,12 - CONTROL "Automatically hide menu on game load.",CB_AUTO_HIDE_MENU, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,23,168,12 - CONTROL "Ask confirmation on exit attempt.",CB_ASK_EXIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,38,168,12 - CONTROL "Disable screen saver while game is loaded.",CB_DISABLE_SCREEN_SAVER, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,53,168,12 - CONTROL "Enable right-click context menu",CB_ENABLECONTEXTMENU, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,68,168,12 - CONTROL "Switch fullscreen by double-click",CB_FS_BY_DOUBLECLICK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,84,168,12 - CONTROL "Partially disable Visual Themes (Requires restart)",CB_PARTIALVISUALTHEME, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,100,168,12 - CONTROL "Single Instance Mode",IDC_SINGLEINSTANCE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,117,167,10 -END - -INPUTCONFIG DIALOGEX 122, 105, 349, 199 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Input Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "Port 1:",102,20,31,152,50 - COMBOBOX COMBO_PAD1,27,57,71,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "Configure",BTN_PORT1,109,43,56,14 - GROUPBOX "Port 2:",103,176,31,152,50 - COMBOBOX COMBO_PAD2,183,57,71,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "Configure",BTN_PORT2,265,41,56,14 - GROUPBOX "NES-style Input Ports",108,10,8,328,83 - GROUPBOX "Famicom Expansion Port:",109,176,93,162,50 - COMBOBOX COMBO_FAM,183,122,84,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "Configure",BTN_FAM,275,105,56,14 - CONTROL "",65487,"Static",SS_BLACKFRAME,27,41,71,12 - CONTROL "",65486,"Static",SS_BLACKFRAME,183,41,71,12 - CONTROL "",65485,"Static",SS_BLACKFRAME,183,106,84,12 - CTEXT "",TXT_PAD1,30,42,65,10 - CTEXT "",TXT_PAD2,186,42,65,10 - CTEXT "",TXT_FAM,186,107,78,10 - PUSHBUTTON "Set",BTN_AUTO_HOLD,19,157,45,13 - LTEXT "not assigned",LBL_AUTO_HOLD,71,159,87,8 - PUSHBUTTON "Clear",BTN_CLEAR_AH,19,172,45,13 - LTEXT "not assigned",LBL_CLEAR_AH,71,174,87,8 - DEFPUSHBUTTON "Close",BTN_CLOSE,282,177,56,14 - GROUPBOX "Input Presets",113,10,93,162,50 - CONTROL "Allow Left+Right / Up+Down",BTN_ALLOW_LRUD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,183,157,107,10 - PUSHBUTTON "Set",BTN_PRESET_SET1,34,103,37,11 - PUSHBUTTON "Set",BTN_PRESET_SET2,34,115,37,11 - PUSHBUTTON "Set",BTN_PRESET_SET3,34,127,37,11 - PUSHBUTTON "Import",BTN_PRESET_IMPORT1,84,103,37,11 - PUSHBUTTON "Import",BTN_PRESET_IMPORT2,84,115,37,11 - PUSHBUTTON "Import",BTN_PRESET_IMPORT3,84,127,37,11 - PUSHBUTTON "Export",BTN_PRESET_EXPORT1,123,103,37,11 - PUSHBUTTON "Export",BTN_PRESET_EXPORT2,123,115,37,11 - PUSHBUTTON "Export",BTN_PRESET_EXPORT3,123,127,37,11 - GROUPBOX "Auto-Hold",118,10,146,162,44 - GROUPBOX "Emulation",119,176,146,162,25 - CTEXT "1",IDC_STATIC,18,105,8,8 - CTEXT "2",IDC_STATIC,18,116,8,8 - CTEXT "3",IDC_STATIC,18,128,8,8 - CONTROL "Attach four-score (implies four gamepads)",CHECK_ENABLE_FOURSCORE, - "Button",BS_AUTOCHECKBOX,18,18,142,12 - CONTROL "Replace Port 2 Start With Microphone",CHECK_ENABLE_MICROPHONE, - "Button",BS_AUTOCHECKBOX,174,18,142,12 -END - -MAHJONGDIALOG DIALOG 65510, 106, 340, 110 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "mahjong" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,277,91,56,14 - GROUPBOX "",321,8,8,324,73,WS_GROUP - PUSHBUTTON "A",300,14,42,16,12 - PUSHBUTTON "B",301,36,42,16,12 - PUSHBUTTON "C",302,58,42,16,12 - PUSHBUTTON "D",303,80,42,16,12 - PUSHBUTTON "E",304,102,42,16,12 - PUSHBUTTON "F",305,124,42,16,12 - PUSHBUTTON "G",306,146,42,16,12 - PUSHBUTTON "H",307,168,42,16,12 - PUSHBUTTON "I",308,190,42,16,12 - PUSHBUTTON "J",309,212,42,16,12 - PUSHBUTTON "K",310,234,42,16,12 - PUSHBUTTON "L",311,256,42,16,12 - PUSHBUTTON "M",312,278,42,16,12 - PUSHBUTTON " ",313,302,40,20,15 - PUSHBUTTON "SEL",314,124,58,16,12 - PUSHBUTTON "ST",315,146,58,16,12 - PUSHBUTTON " ",316,168,58,16,12 - PUSHBUTTON " ",317,190,58,16,12 - PUSHBUTTON " ",318,212,58,16,12 - PUSHBUTTON " ",319,234,58,16,12 - PUSHBUTTON " ",320,256,58,16,12 -END - -MAPINPUT DIALOGEX 0, 0, 318, 294 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Hotkeys" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,261,274,50,14 - PUSHBUTTON "Cancel",BTN_CANCEL,205,274,50,14 - CONTROL "List2",LV_MAPPING,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,304,243 - PUSHBUTTON "Restore Defaults",BTN_RESTORE_DEFAULTS,7,274,75,14 - COMBOBOX COMBO_FILTER,32,255,279,193,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Filter:",65484,6,255,21,12,SS_CENTERIMAGE | NOT WS_GROUP -END - -MESSAGELOG DIALOGEX 33, 38, 197, 229 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Message Log" -FONT 9, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - EDITTEXT LBL_LOG_TEXT,1,1,194,208,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - PUSHBUTTON "Clear",CLEAR_LOG,94,211,47,14 - PUSHBUTTON "Close",CLOSE_LOG,146,211,47,14 -END - -NETMOO DIALOGEX 44, 59, 365, 209 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Network Play" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_NETMOO_CMD_INPUT,10,137,347,12,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_OEMCONVERT | ES_WANTRETURN - EDITTEXT IDC_NETMOO_STATUS,10,8,347,130,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - RTEXT "Remote Host:",65481,13,167,44,8 - EDITTEXT IDC_NETMOO_HOST,60,165,90,12 - EDITTEXT IDC_NETMOO_PORT,151,165,27,12 - GROUPBOX "Settings",100,10,154,347,47,WS_GROUP - DEFPUSHBUTTON "Connect",BTN_NETMOO_CONNECT,296,163,56,14 - EDITTEXT IDC_NETMOO_NICK,282,182,70,12,ES_AUTOHSCROLL - RTEXT "Local Players:",65480,187,167,46,8 - RTEXT "Nickname:",65479,238,184,40,8 - COMBOBOX COMBO_NETMOO_LOCAL_PLAYERS,238,165,28,51,CBS_DROPDOWNLIST | WS_TABSTOP - RTEXT "Game Key:",65478,127,184,39,8 - EDITTEXT IDC_NETMOO_KEY,169,182,67,12 - RTEXT "Password:",65477,19,184,37,8 - EDITTEXT IDC_NETMOO_PASS,60,182,67,12,ES_PASSWORD -END - -NEWINPUT DIALOGEX 0, 0, 186, 66 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Enter New Input" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CTEXT "Press a key",LBL_KEY_COMBO,31,14,122,20 - PUSHBUTTON "Clear",BTN_CLEAR,95,45,50,14 - PUSHBUTTON "OK",BTN_OK,40,45,50,14 -END - -PALCONFIG DIALOGEX 16, 81, 228, 116 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Palette Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",BUTTON_CLOSE,162,94,56,14 - GROUPBOX "NES Palette",302,10,8,102,81,WS_GROUP - DEFPUSHBUTTON "&Load Palette...",BTN_PALETTE_LOAD,18,40,58,14 - CONTROL "Enabled",CHECK_PALETTE_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,22,87,12 - CONTROL "Tint",CTL_TINT_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,121,44,91,11 - GROUPBOX "NTSC Color Emulation",101,115,8,103,81,WS_GROUP - CONTROL "Hue",CTL_HUE_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,121,69,91,11 - CTEXT "Hue",64395,124,59,85,8 - CTEXT "Tint",65463,123,34,85,8 - CONTROL "Force Grayscale",CHECK_PALETTE_GRAYSCALE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,67,85,12 - CONTROL "Use Custom Palette",CHECK_PALETTE_CUSTOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,22,85,12 -END - -POWERPADDIALOG DIALOG 30, 123, 131, 119 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Power Pad Configuration" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,34,95,56,14 - GROUPBOX "",312,8,10,114,74,WS_GROUP - PUSHBUTTON "1",300,21,23,16,12 - PUSHBUTTON "2",301,43,23,16,12 - PUSHBUTTON "3",302,70,23,16,12 - PUSHBUTTON "4",303,91,23,16,12 - PUSHBUTTON "5",304,21,41,16,12 - PUSHBUTTON "6",305,43,41,16,12 - PUSHBUTTON "7",306,70,41,16,12 - PUSHBUTTON "8",307,91,41,16,12 - PUSHBUTTON "9",308,21,59,16,12 - PUSHBUTTON "10",309,43,59,16,12 - PUSHBUTTON "11",310,70,59,16,12 - PUSHBUTTON "12",311,91,59,16,12 -END - -QUIZKINGDIALOG DIALOG 30, 123, 160, 74 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "quiz king" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,54,56,56,14 - GROUPBOX "Buzzers",312,8,7,144,39,WS_GROUP - PUSHBUTTON "1",300,16,23,16,12 - PUSHBUTTON "2",301,38,23,16,12 - PUSHBUTTON "3",302,60,23,16,12 - PUSHBUTTON "4",303,82,23,16,12 - PUSHBUTTON "5",304,104,23,16,12 - PUSHBUTTON "6",305,126,23,16,12 -END - -SOUNDCONFIG DIALOGEX 8, 95, 334, 282 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Sound Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",BTN_CLOSE,280,260,44,14 - GROUPBOX "Output/Output Format:",302,10,9,131,93,WS_GROUP - CONTROL "Sound enabled.",CHECK_SOUND_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,22,117,12 - CONTROL "Force 8-bit sound.",CHECK_SOUND_8BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,38,117,11 - LTEXT "Rate:",65461,17,81,22,10 - LTEXT "Hz",65460,108,81,15,9 - GROUPBOX "Buffering:",127,150,9,131,93,WS_GROUP - CONTROL "Use Global Focus",124,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,22,100,12 - CTEXT "Sound Latency",65459,162,50,107,8 - CONTROL "",CTL_LATENCY_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,162,70,107,13 - GROUPBOX "Master",125,19,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,27,150,28,83 - LTEXT "15 ms",65458,160,87,20,8 - LTEXT "200 ms",65457,250,87,25,8 - LTEXT "ms",65456,211,60,19,8 - COMBOBOX COMBO_SOUND_RATE,50,78,53,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX COMBO_SOUND_QUALITY,50,54,67,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Quality:",65455,17,54,27,10 - CONTROL "Mute frame advance.",CHECK_SOUND_MUTEFA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,110,87,11 - CONTROL "Mute Turbo.",CHECK_SOUND_MUTETURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,111,55,10 - GROUPBOX "Triangle",131,70,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR_TRIANGLE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,78,150,28,83 - GROUPBOX "Square1",132,121,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR_SQUARE1,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,129,150,28,83 - GROUPBOX "Square2",133,170,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR_SQUARE2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,178,150,28,83 - GROUPBOX "Noise",134,221,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR_NOISE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,229,150,28,83 - GROUPBOX "PCM",135,271,142,44,93,WS_GROUP - CONTROL "",CTL_VOLUME_TRACKBAR_PCM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,279,150,28,83 - GROUPBOX "Volume Control",IDC_VOLUMEGROUP,10,127,314,127 - PUSHBUTTON "Restore defaults",IDC_SOUND_RESTOREDEFAULTVOL,19,238,56,11 - LTEXT "",ID_SOUND_TRITOP,76,135,38,8 - LTEXT "",ID_SOUND_QUALITYNOTIFY,170,133,144,8 -END - -TIMINGCONFIG DIALOGEX 23, 157, 203, 60 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Timing Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",1,137,38,56,14 - CONTROL "Disable speed throttling used when sound is disabled.",CB_DISABLE_SPEED_THROTTLING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,8,183,12 - CONTROL "Set high-priority thread.",CB_SET_HIGH_PRIORITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,24,146,12 -END - -MOVIEOPTIONS DIALOGEX 65520, 76, 147, 222 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Movie Options" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "Close",IDC_MOVIE_CLOSE,48,200,49,14,BS_CENTER - CONTROL "Pause after playback",IDC_MOVIE_PAUSEAFTERPLAYBACK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,26,110,10 - CONTROL "Bind savestates to movies",IDC_MOVIE_BINDSAVESTATES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,64,111,10 - CONTROL "Display movie subtitles",IDC_MOVIE_DISPLAYSUBTITLES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,83,102,10 - CONTROL "Put movie subtitles in AVI",IDC_MOVIE_SUBTITLESINAVI, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,101,102,10 - CONTROL "Automatically backup movies",IDC_MOVIE_AUTOBACKUP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,122,114,10 - CONTROL "Load full savestate-movies:",IDC_FULLSAVESTATES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,141,110,10 - LTEXT "Loading states in record mode",IDC_STATIC,25,153,106,8 - LTEXT "will not immediately truncate",IDC_STATIC,25,163,107,8 - LTEXT "movie, next frame input will.",IDC_STATIC,25,173,108,8 - CONTROL "Close after playback",IDC_MOVIE_CLOSEAFTERPLAYBACK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,45,89,10 - CONTROL "Always suggest Read-Only replay",IDC_MOVIE_SUGGEST_READONLY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,8,125,10 - LTEXT "(VBA-rr and SNES9x style)",IDC_STATIC,25,184,93,8 -END - -DWBDIALOGSIMPLE DIALOGEX 33, 99, 250, 39 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "DWBS!" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "Type a key, or press Escape to disable.",65429,53,14,125,8 -END - -MEMWATCH DIALOGEX 0, 0, 261, 270 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Memory Watch" -MENU MEMWATCHMENU -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "",IDC_STATIC,3,0,126,200 - GROUPBOX "",IDC_STATIC,131,0,128,200 - EDITTEXT MW_ADDR00,6,17,30,14 - EDITTEXT 1000,41,17,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR01,6,32,30,14 - EDITTEXT 1003,41,32,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR02,6,47,30,14 - EDITTEXT 1006,41,47,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR03,6,62,30,14 - EDITTEXT 1009,41,62,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR04,6,77,30,14 - EDITTEXT 1012,41,77,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR05,6,92,30,14 - EDITTEXT 1015,41,92,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR06,6,107,30,14 - EDITTEXT 1018,41,107,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR07,6,122,30,14 - EDITTEXT 1021,41,122,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR08,6,137,30,14 - EDITTEXT 1024,41,137,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR09,6,152,30,14 - EDITTEXT 1027,41,152,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR10,6,167,30,14 - EDITTEXT 1030,41,167,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR11,6,182,30,14 - EDITTEXT 1033,41,182,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR12,135,17,30,14 - EDITTEXT 1036,171,17,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR13,135,32,30,14 - EDITTEXT 1039,171,32,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR14,135,47,30,14 - EDITTEXT 1042,171,47,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR15,135,62,30,14 - EDITTEXT 1045,171,62,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR16,135,77,30,14 - EDITTEXT 1048,171,77,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR17,135,92,30,14 - EDITTEXT 1051,171,92,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR18,135,107,30,14 - EDITTEXT 1054,171,107,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR19,135,122,30,14 - EDITTEXT 1057,171,122,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR20,135,137,30,14 - EDITTEXT 1060,171,137,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR21,135,152,30,14 - EDITTEXT 1063,171,152,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR22,135,167,30,14 - EDITTEXT 1066,171,167,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR23,135,182,30,14 - EDITTEXT 1069,171,182,55,14,ES_AUTOHSCROLL - LTEXT "Name",65428,41,7,20,8 - LTEXT "Address",65427,6,7,26,8 - LTEXT "Value",MW_ValueLabel1,101,7,19,8 - LTEXT "Name",65425,171,7,20,8 - LTEXT "Address",65424,135,7,26,8 - LTEXT "Value",MW_ValueLabel2,231,7,19,8 - LTEXT " ",EDIT00_RESULTS,89,225,26,8 - GROUPBOX "Memory Change Monitoring",IDC_STATIC,0,202,129,57,BS_CENTER - LTEXT "Address",IDC_STATIC,6,213,26,8 - LTEXT "Count",IDC_STATIC,90,213,20,8 - LTEXT "Formula",IDC_STATIC,47,213,26,8 - LTEXT " ",MEMW_EDIT00RMADDRESS,7,225,24,8 - PUSHBUTTON " ",MEMW_EDIT00RESET,115,225,11,7 - LTEXT "reset",IDC_STATIC,112,213,16,8 - COMBOBOX MEMW_EDIT00FORMULA,37,223,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT " ",MEMW_EDIT01RMADDRESS,7,241,24,8 - COMBOBOX MEMW_EDIT01FORMULA,37,241,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT " ",EDIT01_RESULTS,89,241,25,8 - PUSHBUTTON " ",MEMW_EDIT01RESET,115,241,11,7 - LTEXT " ",EDIT02_RESULTS,217,225,26,8 - LTEXT "Address",IDC_STATIC,133,213,26,8 - LTEXT "Formula",IDC_STATIC,173,213,26,8 - LTEXT " ",MEMW_EDIT02RMADDRESS,135,225,24,8 - PUSHBUTTON " ",MEMW_EDIT02RESET,242,225,11,7 - LTEXT "reset",IDC_STATIC,239,213,16,8 - COMBOBOX MEMW_EDIT02FORMULA,165,223,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT " ",MEMW_EDIT03RMADDRESS,135,241,24,8 - COMBOBOX MEMW_EDIT03FORMULA,165,241,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT " ",EDIT03_RESULTS,217,241,28,8 - PUSHBUTTON " ",MEMW_EDIT03RESET,242,241,11,7 - GROUPBOX "Memory Change Monitoring",IDC_STATIC,131,202,129,57,BS_CENTER - LTEXT "Count",IDC_STATIC,217,213,20,8 - PUSHBUTTON "<",MEMW_EXPANDCOLLAPSE,1,259,11,10 -END - -DEBUGGER DIALOGEX 54, 74, 545, 322 -STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "6502 Debugger" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_DEBUGGER_DISASSEMBLY,18,5,316,301,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL - SCROLLBAR IDC_DEBUGGER_DISASSEMBLY_VSCR,334,5,11,301,SBS_VERT - GROUPBOX "Status Flags",401,434,140,106,35,WS_TABSTOP - CONTROL "N",IDC_DEBUGGER_FLAG_N,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,149,18,12 - CONTROL "V",IDC_DEBUGGER_FLAG_V,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,466,149,18,12 - CONTROL "U",IDC_DEBUGGER_FLAG_U,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,149,18,12 - CONTROL "B",IDC_DEBUGGER_FLAG_B,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,516,149,18,12 - CONTROL "D",IDC_DEBUGGER_FLAG_D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,161,18,12 - CONTROL "I",IDC_DEBUGGER_FLAG_I,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,466,161,18,12 - CONTROL "Z",IDC_DEBUGGER_FLAG_Z,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,161,18,12 - CONTROL "C",IDC_DEBUGGER_FLAG_C,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,516,161,18,12 - GROUPBOX "Breakpoints",IDC_DEBUGGER_BREAKPOINTS,434,2,106,138,WS_TABSTOP - LISTBOX IDC_DEBUGGER_BP_LIST,438,11,98,96,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL - PUSHBUTTON "Add",IDC_DEBUGGER_BP_ADD,438,109,31,15 - PUSHBUTTON "Delete",IDC_DEBUGGER_BP_DEL,472,109,31,15,WS_DISABLED - PUSHBUTTON "Edit",IDC_DEBUGGER_BP_EDIT,505,109,31,15,WS_DISABLED - PUSHBUTTON "Run",IDC_DEBUGGER_RUN,351,5,38,14 - PUSHBUTTON "Step Into",IDC_DEBUGGER_STEP_IN,392,5,39,14 - PUSHBUTTON "Step Out",IDC_DEBUGGER_STEP_OUT,351,21,38,14 - PUSHBUTTON "Step Over",IDC_DEBUGGER_STEP_OVER,392,21,39,14 - LTEXT "A:",IDC_STATIC,351,92,9,8 - LTEXT "X:",65534,378,92,9,8 - LTEXT "Y:",65533,406,92,9,8 - LTEXT "PC:",65532,351,74,13,8 - EDITTEXT IDC_DEBUGGER_VAL_A,359,90,15,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_DEBUGGER_VAL_X,387,90,15,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_DEBUGGER_VAL_Y,415,90,15,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_DEBUGGER_VAL_PC,363,72,25,12,ES_UPPERCASE | ES_WANTRETURN - GROUPBOX "Stack",IDC_DEBUGGER_VAL_S,349,104,81,71,WS_TABSTOP - EDITTEXT IDC_DEBUGGER_STACK_CONTENTS,353,113,73,58,ES_MULTILINE | ES_UPPERCASE | ES_NOHIDESEL | ES_READONLY | WS_VSCROLL - PUSHBUTTON "Seek PC",IDC_DEBUGGER_SEEK_PC,392,71,39,14 - PUSHBUTTON "Seek To:",IDC_DEBUGGER_SEEK_TO,351,54,38,14 - EDITTEXT IDC_DEBUGGER_VAL_PCSEEK,392,55,38,12,ES_UPPERCASE | ES_WANTRETURN - LTEXT "PPU:",65531,353,179,17,10 - LTEXT "Sprite:",65530,353,191,20,10 - LTEXT "Scanline:",IDC_STATIC,353,203,31,8 - LTEXT "Pixel:",IDC_STATIC,353,216,17,8 - EDITTEXT IDC_DEBUGGER_VAL_PPU,372,179,25,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_SPR,375,191,15,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_SLINE,384,203,14,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_PPUPIXEL,373,216,14,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT - GROUPBOX "",IDC_DEBUGGER_VAL_S2,349,174,51,53,WS_TABSTOP - EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT,443,179,47,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT2,491,179,54,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT,442,204,47,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT - EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2,490,204,55,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT - CONTROL "",IDC_DEBUGGER_ADDR_LINE,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,4,309,341,11 - CONTROL "Break on Bad Opcodes",IDC_DEBUGGER_BREAK_ON_BAD_OP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,126,94,10 - CONTROL "Symbolic debug",IDC_DEBUGGER_ENABLE_SYMBOLIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,473,261,62,10 - PUSHBUTTON "Reload Symbols",IDC_DEBUGGER_RELOAD_SYMS,472,272,64,14 - GROUPBOX "Address Bookmarks",45535,349,228,115,78 - LISTBOX LIST_DEBUGGER_BOOKMARKS,353,238,76,64,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_DEBUGGER_BOOKMARK,432,238,28,14,ES_AUTOHSCROLL - PUSHBUTTON "Add",IDC_DEBUGGER_BOOKMARK_ADD,431,256,30,14 - PUSHBUTTON "Delete",IDC_DEBUGGER_BOOKMARK_DEL,431,272,30,14 - PUSHBUTTON "Rom Patcher",IDC_DEBUGGER_ROM_PATCHER,472,288,64,14 - PUSHBUTTON "",IDC_DEBUGGER_RESTORESIZE,349,308,13,10 - LTEXT "Default window size",IDC_STATIC,364,309,68,9 - PUSHBUTTON "Run Line",IDC_DEBUGGER_RUN_LINE,351,37,38,14 - PUSHBUTTON "128 Lines",IDC_DEBUGGER_RUN_FRAME2,392,37,39,14 - CONTROL ".DEB files",DEBUGLOADDEB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,307,46,13 - CONTROL "Auto-open",DEBUGAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,439,307,47,13 - LTEXT "CPU cycles:",IDC_STATIC,403,179,39,8 - PUSHBUTTON "Reset counters",IDC_DEBUGGER_RESET_COUNTERS,470,229,68,14 - CONTROL "Break when exceed",IDC_DEBUGGER_BREAK_ON_CYCLES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,405,191,78,10 - EDITTEXT IDC_DEBUGGER_CYCLES_EXCEED,484,190,55,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER - LTEXT "Instructions:",IDC_STATIC,403,204,39,8 - CONTROL "Break when exceed",IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,405,216,78,10 - EDITTEXT IDC_DEBUGGER_INSTRUCTIONS_EXCEED,484,215,55,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER - GROUPBOX "",IDC_STATIC,468,241,72,65 - CONTROL "ROM offsets",IDC_DEBUGGER_ROM_OFFSETS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,473,249,62,10 - PUSHBUTTON "Name",IDC_DEBUGGER_BOOKMARK_NAME,431,288,30,14 - EDITTEXT IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL,4,5,14,301,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED -END - -TRACER DIALOGEX 0, 0, 317, 181 -STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Trace Logger" -FONT 8, "MS Sans Serif", 400, 0, 0x0 -BEGIN - EDITTEXT IDC_TRACER_LOG,3,3,300,44,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL - SCROLLBAR IDC_SCRL_TRACER_LOG,303,3,11,44,SBS_VERT - CONTROL "Log last",IDC_RADIO_LOG_LAST,"Button",BS_AUTORADIOBUTTON | BS_LEFT,9,53,38,10 - COMBOBOX IDC_TRACER_LOG_SIZE,49,52,46,13,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "lines",IDC_TEXT_LINES_TO_THIS_WINDOW,97,54,20,10 - DEFPUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,126,51,65,15,BS_CENTER | BS_VCENTER - CONTROL "Log to File",IDC_RADIO_LOG_TO_FILE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,9,70,46,10 - PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,56,68,39,14,BS_CENTER | BS_VCENTER - CONTROL "Automatically update this window while logging",IDC_CHECK_LOG_UPDATE_WINDOW, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,70,156,10 - GROUPBOX "Log Options",IDC_GROUP_LOG_OPTIONS,3,85,311,65 - CONTROL "Log state of registers",IDC_CHECK_LOG_REGISTERS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,96,99,10 - CONTROL "Log Processor status flags",IDC_CHECK_LOG_PROCESSOR_STATUS, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,96,96,10 - CONTROL "To the left from disassembly",IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,211,96,100,10 - CONTROL "Log Frames count",IDC_CHECK_LOG_FRAMES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,109,98,10 - CONTROL "Log Cycles count",IDC_CHECK_LOG_CYCLES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,109,94,10 - CONTROL "Log Instructions count",IDC_CHECK_LOG_INSTRUCTIONS_COUNT, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,211,109,98,10 - CONTROL "Log emulator messages",IDC_CHECK_LOG_MESSAGES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,122,97,10 - CONTROL "Log breakpoint hits",IDC_CHECK_LOG_BREAKPOINTS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,122,91,10 - CONTROL "Symbolic trace",IDC_CHECK_SYMBOLIC_TRACING,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,135,96,10 - CONTROL "Use Stack Pointer for code tabbing (nesting visualization)",IDC_CHECK_CODE_TABBING, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,113,135,196,10 - GROUPBOX "Extra Log Options that work with the Code/Data Logger",IDC_EXTRA_LOG_OPTIONS,3,151,311,26 - CONTROL "Only log newly mapped code",IDC_CHECK_LOG_NEW_INSTRUCTIONS, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,8,162,102,10 - CONTROL "Only log code that accesses newly mapped data",IDC_CHECK_LOG_NEW_DATA, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,112,162,171,10 -END - -ADDBP DIALOGEX 66, 83, 196, 130 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Add Breakpoint..." -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "Address:",-1,14,5,30,10 - CTEXT "-",65534,78,5,8,8 - EDITTEXT IDC_ADDBP_ADDR_START,48,4,30,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_ADDBP_ADDR_END,83,4,30,12,ES_UPPERCASE | ES_WANTRETURN - CONTROL "Read",IDC_ADDBP_MODE_R,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,25,35,12 - CONTROL "Write",IDC_ADDBP_MODE_W,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,49,25,35,12 - CONTROL "Execute",IDC_ADDBP_MODE_X,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,86,25,40,12 - DEFPUSHBUTTON "&OK",IDOK,99,113,42,13 - PUSHBUTTON "&Cancel",IDCANCEL,147,114,42,13 - GROUPBOX "Memory",108,9,39,174,24,WS_TABSTOP - CONTROL "CPU Mem",IDC_ADDBP_MEM_CPU,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,49,50,10 - CONTROL "PPU Mem",IDC_ADDBP_MEM_PPU,"Button",BS_AUTORADIOBUTTON,68,49,50,10 - CONTROL "Sprite Mem",IDC_ADDBP_MEM_SPR,"Button",BS_AUTORADIOBUTTON,124,49,50,10 - EDITTEXT IDC_ADDBP_CONDITION,43,72,136,14,ES_AUTOHSCROLL - LTEXT "Condition",65533,7,74,30,8 - LTEXT "Name",65532,8,92,20,8 - EDITTEXT IDC_ADDBP_NAME,43,89,136,14,ES_AUTOHSCROLL - CONTROL "Forbid",IDC_ADDBP_MODE_F,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,145,6,40,12 - GROUPBOX "",112,3,18,185,50,WS_TABSTOP -END - -NTVIEW DIALOGEX 44, 38, 355, 402 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Name Table Viewer" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "Name Tables",IDC_NTVIEW_TABLE_BOX,0,0,354,310,WS_TABSTOP - LTEXT "Tile ID:",IDC_NTVIEW_PROPERTIES_LINE_1,237,346,93,10 - CONTROL "",IDC_NTVIEW_REFRESH_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,227,318,106,11 - LTEXT "Refresh: More",-1,177,318,50,10 - LTEXT "Less",65534,333,318,18,10 - LTEXT "Display on scanline:",65533,7,318,65,10 - EDITTEXT IDC_NTVIEW_SCANLINE,73,315,24,12 - LTEXT "X / Y:",IDC_NTVIEW_PROPERTIES_LINE_2,238,355,75,8 - CONTROL "Vertical",IDC_NTVIEW_MIRROR_VERTICAL,"Button",BS_AUTORADIOBUTTON,15,355,39,10 - CONTROL "Four Screen",IDC_NTVIEW_MIRROR_FOUR_SCREEN,"Button",BS_AUTORADIOBUTTON,15,367,55,10 - CONTROL "Single Screen (Table 0)",IDC_NTVIEW_MIRROR_SS_TABLE_0, - "Button",BS_AUTORADIOBUTTON,113,345,90,10 - CONTROL "Single Screen (Table 1)",IDC_NTVIEW_MIRROR_SS_TABLE_1, - "Button",BS_AUTORADIOBUTTON,113,356,90,10 - CONTROL "Single Screen (Table 2)",IDC_NTVIEW_MIRROR_SS_TABLE_2, - "Button",BS_AUTORADIOBUTTON,113,366,90,10 - CONTROL "Single Screen (Table 3)",IDC_NTVIEW_MIRROR_SS_TABLE_3, - "Button",BS_AUTORADIOBUTTON,113,377,90,10 - GROUPBOX "Current Mirroring",65532,7,332,214,58 - CONTROL "Show Scroll Lines",IDC_NTVIEW_SHOW_SCROLL_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,101,319,69,10 - CONTROL "Horizontal",IDC_NTVIEW_MIRROR_HORIZONTAL,"Button",BS_AUTORADIOBUTTON,15,344,47,10 - GROUPBOX "Properties",65531,227,336,122,60 - LTEXT "PPU Address:",IDC_NTVIEW_PROPERTIES_LINE_3,237,363,75,8 - LTEXT "Mirror:",IDC_NTVIEW_PROPERTIES_LINE_4,237,372,75,8 -END - -ROMPATCHER DIALOGEX 84, 67, 304, 135 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Rom Data Editor" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_ROMPATCHER_CURRENT_DATA,7,47,282,12,ES_READONLY - PUSHBUTTON "Apply",IDC_ROMPATCHER_BTN_APPLY,185,92,54,14 - PUSHBUTTON "Save Rom File...",IDC_ROMPATCHER_BTN_SAVE,4,114,65,14,WS_DISABLED - EDITTEXT IDC_ROMPATCHER_PATCH_DATA,7,93,172,13,ES_AUTOHSCROLL - GROUPBOX "Current Data At Offset",IDC_ROMPATCHER_CURRENT_DATA_BOX,3,36,292,43 - GROUPBOX "Offset",IDC_ROMPATCHER_OFFSET_BOX,4,4,291,27 - EDITTEXT IDC_ROMPATCHER_OFFSET,83,12,47,14,ES_AUTOHSCROLL - CONTROL ".Nes File Address",IDC_ROMPATCHER_DOTNES_OFFSET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,14,71,10 - PUSHBUTTON "Edit This Offset",IDC_ROMPATCHER_BTN_EDIT,135,12,65,14 - LTEXT "Disassembled: ",106,7,63,45,12 - EDITTEXT IDC_ROMPATCHER_DISASSEMBLY,56,62,234,14,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Patch Data",108,3,81,292,30 -END - -GGCONV DIALOGEX 84, 67, 186, 146 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Game Gene Encoder/Decoder Tool" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_GAME_GENIE_CODE,115,22,53,14,ES_AUTOHSCROLL - GROUPBOX "Game Genie Code",-1,107,5,69,42 - GROUPBOX "Address/Compare/Value",65534,9,5,91,75 - LTEXT "Address:",65533,18,24,35,8 - EDITTEXT IDC_GAME_GENIE_ADDR,50,21,36,14,ES_AUTOHSCROLL - EDITTEXT IDC_GAME_GENIE_COMP,64,38,22,14,ES_AUTOHSCROLL - EDITTEXT IDC_GAME_GENIE_VAL,64,56,22,14,ES_AUTOHSCROLL - LTEXT "Compare:",65532,17,41,37,8 - LTEXT "Value:",65531,18,58,32,8 - GROUPBOX "Possible Affected Rom File Addresses",65530,8,83,169,58 - LISTBOX IDC_LIST_GGADDRESSES,67,95,54,40,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Add To Cheat List",IDC_BTN_ADD_TO_CHEATS,108,58,68,14,WS_DISABLED -END - -MONITOR DIALOGEX 0, 0, 316, 343 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "RAM Filter" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Rules",-1,7,7,295,182 - GROUPBOX "Results",-1,10,193,292,135 - LTEXT "1st rule",-1,16,20,40,8 - LTEXT "2nd rule",-1,16,36,40,8 - LTEXT "3rd rule",-1,16,55,40,8 - LTEXT "4th rule",-1,16,71,40,8 - LTEXT "5th rule",-1,16,89,40,8 - COMBOBOX 3000,66,17,135,85,CBS_DROPDOWNLIST | WS_TABSTOP - COMBOBOX 3001,66,34,135,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX 3002,66,50,135,97,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX 3003,66,68,135,101,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX 3004,66,84,135,122,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3010,208,18,26,12,ES_AUTOHSCROLL - EDITTEXT 3011,208,34,26,13,ES_AUTOHSCROLL - EDITTEXT 3012,208,50,26,12,ES_AUTOHSCROLL - EDITTEXT 3013,208,68,26,13,ES_AUTOHSCROLL - EDITTEXT 3014,208,84,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3021,240,34,50,13 - PUSHBUTTON "Apply rule",3022,240,50,50,14 - PUSHBUTTON "Apply rule",3023,240,68,50,14 - PUSHBUTTON "Apply rule",3024,240,84,50,14 - LISTBOX 3100,18,206,272,102,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Apply rule",3020,240,17,50,14 - LTEXT "6th rule",-1,16,105,40,8 - COMBOBOX 3005,66,102,135,122,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3015,208,102,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3025,240,102,50,14 - LTEXT "7th rule",-1,16,121,40,8 - COMBOBOX 3006,66,119,135,122,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3016,208,119,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3026,240,119,50,14 - LTEXT "9th rule",-1,16,156,40,8 - COMBOBOX 3008,66,153,135,122,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3018,208,153,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3028,240,153,50,14 - LTEXT "8th rule",-1,16,140,40,8 - COMBOBOX 3007,66,135,135,122,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3017,208,135,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3027,240,135,50,14 - LTEXT "10th rule",-1,16,172,40,8 - COMBOBOX 3009,66,169,135,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT 3019,208,170,26,12,ES_AUTOHSCROLL - PUSHBUTTON "Apply rule",3029,240,169,50,14 - LTEXT "Number of results:",-1,19,313,60,8 - LTEXT "",3101,90,313,60,8 -END - -MEMVIEWFIND DIALOGEX 0, 0, 282, 81 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Find" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - EDITTEXT IDC_MEMVIEWFIND_WHAT,47,7,171,14,ES_AUTOHSCROLL - LTEXT "Find What:",-1,7,9,38,8 - GROUPBOX "Type",-1,83,29,187,45 - CONTROL "Hex",IDC_MEMVIEWFIND_TYPE_HEX,"Button",BS_AUTORADIOBUTTON | WS_GROUP,93,43,29,10 - CONTROL "Text (Uses Currently Loaded Table as Reference)",IDC_MEMVIEWFIND_TYPE_TEXT, - "Button",BS_AUTORADIOBUTTON,93,56,172,10 - GROUPBOX "Direction",-1,9,29,65,44 - CONTROL "Up",IDC_MEMVIEWFIND_DIR_UP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,18,43,25,10 - CONTROL "Down",IDC_MEMVIEWFIND_DIR_DOWN,"Button",BS_AUTORADIOBUTTON,18,56,35,10 - DEFPUSHBUTTON "Find Next",IDC_MEMVIEWFIND_NEXT,225,7,50,14 -END - -IDD_RECORDINP DIALOGEX 0, 0, 276, 86 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Record input" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",1,167,66,50,14 - GROUPBOX "",65501,3,0,269,60 - RTEXT "File:",65500,28,11,24,10,SS_CENTERIMAGE | NOT WS_GROUP,WS_EX_RIGHT - PUSHBUTTON "Cancel",2,221,66,50,14 - EDITTEXT IDC_EDIT_FILENAME,55,10,189,12,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_BUTTON_BROWSEFILE,249,10,18,14 - COMBOBOX IDC_COMBO_RECORDFROM,55,25,189,154,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Record From:",65498,9,27,43,8,0,WS_EX_RIGHT - EDITTEXT IDC_EDIT_AUTHOR,55,41,189,14,ES_AUTOHSCROLL - RTEXT "Author:",65502,18,43,34,10,SS_CENTERIMAGE | NOT WS_GROUP,WS_EX_RIGHT -END - -IDD_REPLAYINP DIALOGEX 0, 0, 300, 202 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Play Movie" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",1,189,183,50,14 - GROUPBOX "",65497,3,0,293,179 - RTEXT "File:",65498,8,11,24,10,SS_CENTERIMAGE | NOT WS_GROUP - COMBOBOX IDC_COMBO_FILENAME,35,10,257,128,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Cancel",2,243,183,50,14 - RTEXT "Length:",64397,10,67,59,8 - RTEXT "Frames:",65496,10,78,59,8 - RTEXT "Record Count:",65495,10,89,59,8 - RTEXT "ROM Used:",65493,10,111,59,8 - RTEXT "ROM Checksum:",65492,10,122,59,8 - RTEXT "Recorded From:",65491,10,100,59,8 - RTEXT "Emulator Used:",65490,10,144,59,8 - RTEXT "Current ROM Sum:",65489,8,133,61,8 - CONTROL "Pause movie at frame",IDC_CHECK_STOPMOVIE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,49,83,10 - EDITTEXT IDC_EDIT_STOPFRAME,103,47,39,12,ES_AUTOHSCROLL | ES_NUMBER - GROUPBOX "Parameters",IDC_STATIC,13,25,278,40 - PUSHBUTTON "Metadata...",IDC_BUTTON_METADATA,239,71,50,14 - EDITTEXT IDC_LABEL_EMULATORUSED,76,144,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_CURRCHECKSUM,76,133,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_ROMCHECKSUM,76,122,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_ROMUSED,76,111,187,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_RECORDEDFROM,76,100,123,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - CONTROL "Open &Read-Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,36,69,10 - EDITTEXT IDC_LABEL_UNDOCOUNT,76,89,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_FRAMES,76,78,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - EDITTEXT IDC_LABEL_LENGTH,76,67,59,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - RTEXT "Pal:",65494,10,155,59,8 - EDITTEXT IDC_LABEL_PALUSED,76,155,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP - RTEXT "New PPU:",65499,10,166,59,8 - EDITTEXT IDC_LABEL_NEWPPUUSED,76,166,155,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP -END - -TASEDITOR DIALOGEX 0, 0, 326, 348 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "TAS Editor" -MENU TASEDITORMENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_PROGRESS_BUTTON,"Button",BS_OWNERDRAW,200,36,116,12 - CONTROL "",IDC_BRANCHES_BUTTON,"Button",BS_OWNERDRAW,207,167,104,10 - CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER,5,13,187,316 - GROUPBOX " Playback ",IDC_PLAYBACK_BOX,197,0,123,62,BS_CENTER,WS_EX_RIGHT - GROUPBOX " Recorder ",IDC_RECORDER_BOX,197,63,123,46,BS_CENTER,WS_EX_RIGHT - GROUPBOX " Splicer ",IDC_SPLICER_BOX,197,110,123,30,BS_CENTER,WS_EX_RIGHT - GROUPBOX " Lua ",IDC_LUA_BOX,197,141,123,26,BS_CENTER,WS_EX_RIGHT - GROUPBOX " Bookmarks ",IDC_BOOKMARKS_BOX,197,168,123,102,BS_CENTER,WS_EX_RIGHT - GROUPBOX " History ",IDC_HISTORY_BOX,197,271,123,53,BS_CENTER,WS_EX_RIGHT - PUSHBUTTON "<<",TASEDITOR_REWIND_FULL,201,9,23,14,NOT WS_TABSTOP - PUSHBUTTON "<",TASEDITOR_REWIND,224,9,23,14,NOT WS_TABSTOP - PUSHBUTTON "||",TASEDITOR_PLAYSTOP,247,9,23,14,NOT WS_TABSTOP - PUSHBUTTON ">",TASEDITOR_FORWARD,270,9,23,14,NOT WS_TABSTOP - PUSHBUTTON ">>",TASEDITOR_FORWARD_FULL,293,9,23,14,NOT WS_TABSTOP - CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,201,39,115,6 - CONTROL " Follow cursor",CHECK_FOLLOW_CURSOR,"Button",BS_AUTOCHECKBOX,203,25,56,12 - CONTROL " Auto-restore last position",CHECK_AUTORESTORE_PLAYBACK, - "Button",BS_AUTOCHECKBOX,203,48,109,12 - CONTROL "",IDC_BOOKMARKSLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSCROLL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | NOT WS_VISIBLE | WS_BORDER,202,177,113,89 - CONTROL "",IDC_HISTORYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER,202,280,113,40 - CONTROL " All",IDC_RADIO_ALL,"Button",BS_AUTORADIOBUTTON,291,71,24,10 - CONTROL " 1P",IDC_RADIO_1P,"Button",BS_AUTORADIOBUTTON,203,83,25,10 - CONTROL " 2P",IDC_RADIO_2P,"Button",BS_AUTORADIOBUTTON,232,83,25,10 - CONTROL " 3P",IDC_RADIO_3P,"Button",BS_AUTORADIOBUTTON,262,83,24,10 - CONTROL " 4P",IDC_RADIO_4P,"Button",BS_AUTORADIOBUTTON,291,83,24,10 - CONTROL " Superimpose",IDC_SUPERIMPOSE,"Button",BS_AUTO3STATE,203,96,55,10 - PUSHBUTTON "<<",TASEDITOR_PREV_MARKER,202,328,23,14,NOT WS_TABSTOP - PUSHBUTTON "Similar",TASEDITOR_FIND_BEST_SIMILAR_MARKER,225,328,34,14,NOT WS_TABSTOP - PUSHBUTTON "More",TASEDITOR_FIND_NEXT_SIMILAR_MARKER,259,328,34,14,NOT WS_TABSTOP - PUSHBUTTON ">>",TASEDITOR_NEXT_MARKER,292,328,23,14,NOT WS_TABSTOP - EDITTEXT IDC_PLAYBACK_MARKER_EDIT,65,0,127,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP - RTEXT "Marker 0",IDC_PLAYBACK_MARKER,3,2,60,10,SS_NOTIFY,WS_EX_RIGHT - EDITTEXT IDC_SELECTION_MARKER_EDIT,65,329,127,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP - RTEXT "Marker 99999",IDC_SELECTION_MARKER,3,331,60,10,SS_NOTIFY,WS_EX_RIGHT - CONTROL "",IDC_BRANCHES_BITMAP,"Static",SS_OWNERDRAW | SS_NOTIFY | SS_REALSIZEIMAGE | NOT WS_VISIBLE,202,177,113,89 - CONTROL " Turbo seek",CHECK_TURBO_SEEK,"Button",BS_AUTOCHECKBOX,263,25,50,12 - LTEXT "Selection: 0 rows, 16 columns",IDC_TEXT_SELECTION,204,118,112,10,SS_NOTIFY - LTEXT "Clipboard: 0 rows, 16 columns",IDC_TEXT_CLIPBOARD,203,128,114,10,SS_NOTIFY - CONTROL " Recording",IDC_RECORDING,"Button",BS_AUTO3STATE,203,71,81,10 - PUSHBUTTON "Run function",TASEDITOR_RUN_MANUAL,202,150,54,14,WS_DISABLED | NOT WS_TABSTOP - CONTROL "Auto function",IDC_RUN_AUTO,"Button",BS_AUTOCHECKBOX,261,152,55,10 - CONTROL " Use pattern",IDC_USEPATTERN,"Button",BS_AUTOCHECKBOX,262,96,53,10 -END - -IDD_TASEDITOR_ABOUT DIALOGEX 0, 0, 238, 78 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDCANCEL,94,55,50,14 - ICON IDI_ICON4,IDC_STATIC,11,11,20,20 - LTEXT "TAS Editor",IDC_TASEDITOR_NAME,43,8,84,13 - LTEXT "Version 1.01",IDC_STATIC,60,25,45,8 - LTEXT "Created by AnS",IDC_STATIC,138,12,58,8 - LTEXT "Originated from TASEdit",IDC_STATIC,138,25,85,9,SS_NOPREFIX - LTEXT "made by zeromus & adelikat",IDC_STATIC,138,35,96,9,SS_NOPREFIX -END - -IDD_TASEDITOR_NEWPROJECT DIALOGEX 0, 0, 171, 100 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Create New Project" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,7,80,50,14 - PUSHBUTTON "Cancel",IDCANCEL,114,80,50,14 - CONTROL " Copy current Input",IDC_COPY_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,80,14,75,10 - CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON,16,14,45,10 - CONTROL " 2 players",IDC_RADIO_2PLAYERS,"Button",BS_AUTORADIOBUTTON,16,27,45,10 - CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,16,40,45,10 - CONTROL " Copy current Markers",IDC_COPY_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,80,27,83,10 - GROUPBOX "Input type",IDC_STATIC,5,3,67,52,BS_CENTER - EDITTEXT IDC_EDIT_AUTHOR,36,61,127,13,ES_AUTOHSCROLL - LTEXT "Author:",IDC_STATIC,8,63,26,9 -END - -IDD_TASEDITOR_EXPORT DIALOGEX 0, 0, 158, 86 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Export to FM2" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Export",IDOK,7,66,50,14 - PUSHBUTTON "Cancel",IDCANCEL,100,66,50,14 - CONTROL " 1 player",IDC_RADIO_1PLAYER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,8,8,47,10 - CONTROL " 2 players",IDC_RADIO_2PLAYERS,"Button",BS_AUTORADIOBUTTON,8,21,47,10 - CONTROL " Fourscore",IDC_RADIO_FOURSCORE,"Button",BS_AUTORADIOBUTTON,8,35,47,10 - CONTROL " Convert Marker Notes to Movie Subtitles",IDC_NOTES_TO_SUBTITLES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,50,146,10 -END - -IDD_TASEDITOR_FINDNOTE DIALOGEX 0, 0, 228, 49 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Find Note" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Find next",IDOK,171,5,51,14 - PUSHBUTTON "Close",IDCANCEL,171,23,51,14 - EDITTEXT IDC_NOTE_TO_FIND,6,6,160,12,ES_AUTOHSCROLL - CONTROL " Match case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,23,53,10 - GROUPBOX "Direction",IDC_STATIC,82,20,83,24,BS_CENTER - CONTROL " Up",IDC_RADIO_UP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,90,30,29,10 - CONTROL " Down",IDC_RADIO_DOWN,"Button",BS_AUTORADIOBUTTON,125,30,32,10 -END - -IDD_TASEDITOR_SAVECOMPACT DIALOGEX 0, 0, 123, 197 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Save Compact" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Save",IDOK,8,176,50,14 - PUSHBUTTON "Cancel",IDCANCEL,66,176,50,14 - CONTROL " Binary format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,8,89,10 - CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,23,67,10 - CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,38,67,10 - CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,53,67,10 - CONTROL " Piano Roll",IDC_CHECK_PIANO_ROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,68,67,10 - CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,83,67,10 - GROUPBOX "Greenzone saving options",IDC_STATIC,13,98,97,72 - CONTROL " all frames",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,23,109,77,10 - CONTROL " every 16th frame",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,23,124,77,10 - CONTROL " marked frames",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,23,139,77,10 - CONTROL " don't save",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,23,154,77,10 -END - -ASSEMBLER DIALOGEX 0, 0, 202, 135 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Inline Assembler" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - EDITTEXT IDC_ASSEMBLER_DISASSEMBLY,27,9,167,12,ES_READONLY - COMBOBOX IDC_ASSEMBLER_HISTORY,15,25,180,54,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Apply",IDC_ASSEMBLER_APPLY,159,114,36,14 - LTEXT "PC:",-1,15,10,12,10 - LTEXT "Patch:",-1,15,41,26,9 - PUSHBUTTON "Save...",IDC_ASSEMBLER_SAVE,117,114,36,14 - PUSHBUTTON "Undo",IDC_ASSEMBLER_UNDO,15,114,35,14 - DEFPUSHBUTTON "Def",IDC_ASSEMBLER_DEFPUSHBUTTON,55,116,16,12,NOT WS_VISIBLE - LISTBOX IDC_ASSEMBLER_PATCH_DISASM,15,50,180,59,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP -END - -NAMEBOOKMARKDLG DIALOGEX 0, 0, 186, 73 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Bookmark name" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "Bookmark name",IDC_BOOKMARK_NAME_TEXT,68,14,58,8 - EDITTEXT IDC_BOOKMARK_DESCRIPTION,7,28,172,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "&OK",IDOK,67,52,50,14 -END - -CDLOGGER DIALOGEX 0, 0, 307, 254 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Code Data Logger" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - PUSHBUTTON "Load...",BTN_CDLOGGER_LOAD,7,122,50,14 - PUSHBUTTON "Save",BTN_CDLOGGER_SAVE,249,105,50,14 - GROUPBOX "Code/Data Log Status",-1,3,5,300,195,BS_CENTER - DEFPUSHBUTTON "Start",BTN_CDLOGGER_START_PAUSE,127,105,50,14 - GROUPBOX "Address Label Logger",65534,3,201,300,49,BS_CENTER - PUSHBUTTON "Load...",111,7,231,50,14,WS_DISABLED - PUSHBUTTON "Start",112,127,231,50,14,WS_DISABLED - PUSHBUTTON "Save...",113,249,231,50,14,WS_DISABLED - LTEXT "4067 - 29.5%",LBL_CDLOGGER_CODECOUNT,34,27,72,11 - GROUPBOX "PRG Logged as Code",65533,25,16,84,27 - GROUPBOX "PRG Logged as Data",65532,113,16,84,27 - LTEXT "7092 - 37.2%",LBL_CDLOGGER_DATACOUNT,122,27,71,9 - GROUPBOX "PRG not Logged",65531,201,16,79,27 - LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFCOUNT,210,27,66,8 - LTEXT "Itsa me, the Code/Data Logger! Press Start to play!",65530,67,78,172,11 - PUSHBUTTON "Reset Log",BTN_CDLOGGER_RESET,7,105,50,14 - PUSHBUTTON "Save as...",BTN_CDLOGGER_SAVE_AS,250,122,50,14 - PUSHBUTTON "Save Stripped Data...",BTN_CDLOGGER_SAVE_STRIPPED,196,155,90,14 - PUSHBUTTON "Save Unused Data...",BTN_CDLOGGER_SAVE_UNUSED,196,172,90,14 - LTEXT "4067 - 29.5%",LBL_CDLOGGER_RENDERCOUNT,34,56,72,11 - GROUPBOX "CHR Rendered",ID_CHR1,25,45,84,27 - GROUPBOX "CHR Logged as Data",ID_CHR2,113,45,84,27 - LTEXT "7092 - 37.2%",LBL_CDLOGGER_VROMREADCOUNT,122,56,71,9 - GROUPBOX "CHR not Logged",ID_CHR3,201,45,79,27 - LTEXT "6072 - 32.7%",LBL_CDLOGGER_UNDEFVROMCOUNT,210,56,66,9 - LTEXT "CDL file:",ID_STATIC,12,92,29,11 - LTEXT "",ID_CDLFILENAME,43,92,252,11,SS_PATHELLIPSIS - CONTROL " Auto-resume logging when loading ROMs",IDC_AUTORESUMECDLOGGING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,179,153,11 - CONTROL " Auto-save .CDL when closing ROMs",IDC_AUTOSAVECDL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,153,143,11 - CONTROL " Auto-load .CDL when opening this window",IDC_AUTOLOADCDL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,166,154,11 - GROUPBOX "Generate ROM",65529,183,142,116,52 - GROUPBOX "Logging workflow options",65528,8,142,171,52 -END - -PPUVIEW DIALOGEX 44, 38, 355, 260 -STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "PPU Viewer" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,351,205,WS_TABSTOP - LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,170,50,9 - LTEXT "Tile:",LBL_PPUVIEW_TILE2,177,170,50,9 - CONTROL "",CTL_PPUVIEW_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,227,179,106,11 - LTEXT "Refresh: More",-1,177,179,50,9 - LTEXT "Less",-1,334,179,18,10 - GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,204,351,54,WS_TABSTOP - LTEXT "Display on scanline:",-1,6,179,65,9 - EDITTEXT IDC_PPUVIEW_SCANLINE,72,177,27,12 - CONTROL "Mask unused graphics (needs Code/Data Logger)",IDC_MASK_UNUSED_GRAPHICS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,190,169,10 - CONTROL "Invert the mask",IDC_INVERT_THE_MASK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,177,190,61,10 -END - -ARCHIVECHOOSERDIALOG DIALOGEX 0, 0, 265, 159 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Choose File From Archive" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,146,138,50,14 - PUSHBUTTON "Cancel",IDCANCEL,208,138,50,14 - LISTBOX IDC_LIST1,7,7,251,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP -END - -TEXTHOOKER DIALOGEX 0, 0, 456, 327 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Text Hooker" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Selection Window",1,0,0,183,164,0,WS_EX_NOPARENTNOTIFY - EDITTEXT 102,207,13,216,94,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL,WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE - GROUPBOX "Hooked Text",103,200,0,229,131,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Load Table",104,3,169,60,14,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Clear Selection",105,67,169,60,14,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Pause",106,67,190,60,14,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Snap",107,130,169,60,35,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Clear Buffer",108,208,111,60,14,0,WS_EX_NOPARENTNOTIFY - EDITTEXT 111,5,249,115,14,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE - PUSHBUTTON "Save Selection",112,130,249,60,14,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Save Table",113,3,190,60,14,0,WS_EX_NOPARENTNOTIFY - PUSHBUTTON "Load Selection",114,130,268,60,14,0,WS_EX_NOPARENTNOTIFY - GROUPBOX "Translated Text",115,200,140,229,117,0,WS_EX_NOPARENTNOTIFY - EDITTEXT 116,207,156,214,95,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL,WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE - PUSHBUTTON "Excite.co.jp",117,281,111,60,14,0,WS_EX_NOPARENTNOTIFY - LTEXT "Scanline:",118,5,210,50,8,0,WS_EX_NOPARENTNOTIFY - LTEXT "Update every x frames:",119,68,210,79,8,0,WS_EX_NOPARENTNOTIFY - EDITTEXT 120,5,220,52,14,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE - EDITTEXT 121,68,220,52,14,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE - PUSHBUTTON "Trim",122,351,111,60,14 - COMBOBOX 109,5,269,115,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Japanese:",-1,5,283,47,9 - EDITTEXT 131,5,292,115,14,ES_AUTOHSCROLL - LTEXT "English:",-1,130,283,47,9 - EDITTEXT 132,130,292,115,14,ES_AUTOHSCROLL - PUSHBUTTON "Add Definition",133,253,292,60,14 - CONTROL "Selection Window",341,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,324,261,80,9 - CONTROL "Word Substitution",342,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,324,274,80,9 - LTEXT "(han)dakuten mark position:",-1,324,286,92,8 - CONTROL "Above",343,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,324,297,37,10 - CONTROL "Right",344,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,363,297,33,10 - LTEXT "New Selection Name:",-1,5,240,68,8 -END - -CHEATCONSOLE DIALOGEX 0, 0, 379, 189 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Cheat Search" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Active Cheats",201,5,2,129,182,WS_TABSTOP - GROUPBOX "Cheat Search",202,140,2,233,182,WS_TABSTOP - LISTBOX IDC_LIST_CHEATS,11,11,118,98,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL - LTEXT "Name:",IDC_STATIC,12,114,22,10 - LTEXT "Addr:",IDC_STATIC,12,130,18,10 - LTEXT "Val:",IDC_STATIC,61,130,12,10 - LTEXT "Cmp:",IDC_STATIC,95,130,16,10 - EDITTEXT IDC_CHEAT_NAME,35,112,94,12,ES_AUTOHSCROLL | ES_WANTRETURN - EDITTEXT IDC_CHEAT_ADDR,31,128,25,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_CHEAT_VAL,74,128,16,12,ES_UPPERCASE | ES_WANTRETURN - EDITTEXT IDC_CHEAT_COM,113,128,16,12,ES_UPPERCASE | ES_WANTRETURN - DEFPUSHBUTTON "Add",IDC_BTN_CHEAT_ADD,11,144,36,16 - PUSHBUTTON "Delete",IDC_BTN_CHEAT_DEL,52,144,36,16 - PUSHBUTTON "Update",IDC_BTN_CHEAT_UPD,93,144,36,16 - PUSHBUTTON "Reset",IDC_BTN_CHEAT_RESET,146,12,55,15 - PUSHBUTTON "Known Value:",IDC_BTN_CHEAT_KNOWN,146,31,55,15 - LTEXT "0x",IDC_STATIC,205,34,9,8 - EDITTEXT IDC_CHEAT_VAL_KNOWN,215,32,18,12,ES_UPPERCASE - GROUPBOX "Previous Compare",204,145,49,113,115 - PUSHBUTTON "Equal",IDC_BTN_CHEAT_EQ,151,62,55,15,WS_GROUP - PUSHBUTTON "Not Equal",IDC_BTN_CHEAT_NE,151,87,55,15 - CONTROL "By:",IDC_CHEAT_CHECK_NE_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,90,22,10 - EDITTEXT IDC_CHEAT_VAL_NE_BY,234,89,18,12,ES_UPPERCASE | ES_WANTRETURN - PUSHBUTTON "Greater Than",IDC_BTN_CHEAT_GT,151,114,55,15 - CONTROL "By:",IDC_CHEAT_CHECK_GT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,117,22,10 - EDITTEXT IDC_CHEAT_VAL_GT_BY,234,116,18,12,ES_UPPERCASE | ES_WANTRETURN - PUSHBUTTON "Less Than",IDC_BTN_CHEAT_LT,151,141,55,15 - CONTROL "By:",IDC_CHEAT_CHECK_LT_BY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,210,144,22,10 - EDITTEXT IDC_CHEAT_VAL_LT_BY,234,143,18,12,ES_UPPERCASE | ES_WANTRETURN - GROUPBOX "Possibilities",IDC_CHEAT_BOX_POSSIBILITIES,263,8,105,156,WS_TABSTOP - LISTBOX IDC_CHEAT_LIST_POSSIBILITIES,268,18,85,142,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT | WS_TABSTOP - SCROLLBAR IDC_CHEAT_SCRL_POSSIBILITIES,354,18,10,142,SBS_VERT - CONTROL " Pause emulation when this window is active",IDC_CHEAT_PAUSEWHENACTIVE, - "Button",BS_AUTOCHECKBOX,147,169,157,10 - PUSHBUTTON "Add from CHT file...",IDC_BTN_CHEAT_ADDFROMFILE,23,163,93,16 -END - -IDD_LUA DIALOGEX 0, 0, 270, 150 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_APPWINDOW -CAPTION "Lua Script" -MENU LUAWINDOW_MENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - PUSHBUTTON "&Browse...",IDC_BUTTON_LUABROWSE,7,31,48,16 - PUSHBUTTON "&Run",IDC_BUTTON_LUARUN,213,31,50,16 - PUSHBUTTON "&Stop",IDC_BUTTON_LUASTOP,160,31,50,16 - EDITTEXT IDC_EDIT_LUAPATH,7,16,256,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_LUAARGS,47,50,216,14,ES_AUTOHSCROLL - EDITTEXT IDC_LUACONSOLE,7,80,256,60,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - LTEXT "Output Console:",IDC_STATIC,7,70,56,8 - LTEXT "Script File:",IDC_STATIC,7,7,36,8 - LTEXT "Arguments:",IDC_STATIC,7,52,40,8 - PUSHBUTTON "Edit",IDC_BUTTON_LUAEDIT,58,31,46,16 -END - -VIDEOCONFIG DIALOGEX 65520, 76, 511, 170 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Video Configuration" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "Full Screen Settings",65453,5,3,171,141,WS_GROUP - CONTROL "Full Screen (Alt + Enter or double-click)",IDC_VIDEOCONFIG_FS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,15,157,12 - CONTROL "Enter full screen mode after game is loaded",IDC_VIDEOCONFIG_AUTO_FS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,29,154,12 - LTEXT "Sync method:",65452,11,108,46,10 - COMBOBOX IDC_VIDEOCONFIG_SYNC_METHOD_FS,59,106,105,50,CBS_DROPDOWNLIST | WS_TABSTOP - LTEXT "Mode:",13,11,67,23,9 - EDITTEXT IDC_VIDEOCONFIG_XRES,36,65,27,13,ES_RIGHT - LTEXT "by",12,67,67,11,9 - EDITTEXT IDC_VIDEOCONFIG_YRES,79,65,27,13,ES_RIGHT - LTEXT "@",11,110,67,11,9 - COMBOBOX IDC_VIDEOCONFIG_BPP,122,65,32,12,CBS_DROPDOWNLIST | WS_TABSTOP - LTEXT "bpp",10,157,67,14,9 - LTEXT "Special Filter:",65444,11,91,46,9 - COMBOBOX IDC_VIDEOCONFIG_SCALER_FS,59,89,105,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Windowed Settings",65441,182,3,164,141,WS_GROUP - LTEXT "Size Multiplier:",65440,190,22,50,8 - CTEXT "X:",65439,253,10,26,8 - CTEXT "Y:",65438,304,10,26,8 - EDITTEXT IDC_WINSIZE_MUL_X,244,20,44,12,ES_AUTOHSCROLL - EDITTEXT IDC_WINSIZE_MUL_Y,295,20,44,12,ES_AUTOHSCROLL - CONTROL "Force integral scaling factors",IDC_FORCE_INT_VIDEO_SCALARS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,195,50,136,12 - CONTROL "Force aspect ratio correction",IDC_FORCE_ASPECT_CORRECTION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,195,64,136,12 - LTEXT "Special Filter:",65429,188,91,46,9 - COMBOBOX IDC_VIDEOCONFIG_SCALER_WIN,236,89,103,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Sync method:",65437,188,108,46,9 - COMBOBOX IDC_VIDEOCONFIG_SYNC_METHOD_WIN,236,106,103,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Drawing Area",65494,351,50,154,65,WS_GROUP - LTEXT "First line:",65436,367,68,40,9 - LTEXT "Last line:",65435,367,84,40,9 - CTEXT "NTSC",65434,413,57,27,8 - CTEXT "PAL",65433,465,57,27,8 - EDITTEXT IDC_SCANLINE_FIRST_NTSC,414,66,27,12,ES_RIGHT - EDITTEXT IDC_SCANLINE_LAST_NTSC,414,83,27,12,ES_RIGHT - EDITTEXT IDC_SCANLINE_FIRST_PAL,465,66,27,12,ES_RIGHT - EDITTEXT IDC_SCANLINE_LAST_PAL,465,83,27,12,ES_RIGHT - CONTROL "Clip left and right sides (8 px on each)",IDC_VIDEOCONFIG_CLIPSIDES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,357,98,140,12 - DEFPUSHBUTTON "Close",ID_CANCEL,449,150,56,14 - CONTROL "Allow more than 8 sprites per scanline",IDC_VIDEOCONFIG_NO8LIM, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,357,128,138,11 - GROUPBOX "Emulation",65430,351,117,154,27,WS_GROUP - CONTROL "Best Fit",IDC_VIDEOCONFIG_BESTFIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,357,14,41,12 - CONTROL "Hide mouse cursor",IDC_VIDEOCONFIG_HIDEMOUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,43,87,12 - GROUPBOX "Aspect ratio",65495,351,3,154,45,WS_GROUP - CONTROL "BG color",IDC_VIDEOCONFIG_CONSOLE_BGCOLOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,401,14,44,12 - CONTROL "TV Aspect",IDC_VIDEOCONFIG_TVASPECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,357,29,48,12 - GROUPBOX "When resizing the window",65431,188,38,152,43,WS_GROUP - CONTROL "Square pixels",IDC_VIDEOCONFIG_SQUARE_PIXELS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,448,14,55,12 - EDITTEXT IDC_TVASPECT_X,407,28,41,12,ES_AUTOHSCROLL - EDITTEXT IDC_TVASPECT_Y,458,28,41,12,ES_AUTOHSCROLL - CTEXT "/",IDC_STATIC_SLASHTEXT,449,31,8,8 - LTEXT "DirectDraw:",65454,11,126,46,10 - LTEXT "DirectDraw:",65455,188,125,46,10 - COMBOBOX IDC_VIDEOCONFIG_DIRECTDRAW_FS,59,123,105,50,CBS_DROPDOWNLIST | WS_TABSTOP - COMBOBOX IDC_VIDEOCONFIG_DIRECTDRAW_WIN,236,123,103,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP -END - -IDD_RAMSEARCH DIALOGEX 0, 0, 287, 292 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION " RAM Search" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_RAMLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,214,151,WS_EX_CLIENTEDGE - PUSHBUTTON "&Search",IDC_C_SEARCH,226,9,52,16 - PUSHBUTTON "&Add Cheat",IDC_C_ADDCHEAT,226,130,52,14,WS_DISABLED - PUSHBUTTON "&Watch",IDC_C_WATCH,226,114,52,14 - PUSHBUTTON "&Reset",IDC_C_RESET,226,27,52,16 - PUSHBUTTON "&Eliminate",IDC_C_ELIMINATE,226,98,52,14 - GROUPBOX "Comparison Operator",IDC_STATIC,10,166,102,120,0,WS_EX_TRANSPARENT - CONTROL "Less Than",IDC_LESSTHAN,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,178,95,11 - CONTROL "Greater Than",IDC_MORETHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,191,95,11 - CONTROL "Less Than or Equal To",IDC_NOMORETHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,204,95,11 - CONTROL "Greater Than or Equal To",IDC_NOLESSTHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,217,95,11 - CONTROL "Equal To",IDC_EQUALTO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,230,95,11 - CONTROL "Not Equal To",IDC_DIFFERENTFROM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,243,95,11 - CONTROL "Different By:",IDC_DIFFERENTBY,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,256,52,11 - CONTROL "Modulo",IDC_MODULO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,269,35,11 - EDITTEXT IDC_EDIT_DIFFBY,69,255,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED - EDITTEXT IDC_EDIT_MODBY,51,267,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED - GROUPBOX "Compare To / By",IDC_STATIC,118,166,153,60,0,WS_EX_TRANSPARENT - CONTROL "Previous Value",IDC_PREVIOUSVALUE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,121,176,67,10 - CONTROL "Specific Value:",IDC_SPECIFICVALUE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,188,67,10 - CONTROL "Specific Address:",IDC_SPECIFICADDRESS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,200,67,10 - CONTROL "Number of Changes:",IDC_NUMBEROFCHANGES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,212,76,10 - EDITTEXT IDC_EDIT_COMPAREVALUE,203,187,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED - EDITTEXT IDC_EDIT_COMPAREADDRESS,203,199,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED - EDITTEXT IDC_EDIT_COMPARECHANGES,203,211,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED - GROUPBOX "Data Type / Display",IDC_STATIC,196,228,75,45,0,WS_EX_TRANSPARENT - CONTROL "Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,200,238,67,9 - CONTROL "Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,200,249,67,9 - CONTROL "Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,200,260,67,9 - CONTROL "Autosearch",IDC_C_AUTOSEARCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,275,57,11 - GROUPBOX "Data Size",IDC_STATIC,117,228,73,58,0,WS_EX_TRANSPARENT - CONTROL "1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,121,238,61,11 - CONTROL "2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,249,61,11 - CONTROL "4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,260,61,11 - CONTROL "Check Misaligned",IDC_MISALIGN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,121,273,65,8 - PUSHBUTTON "&Clear Change Counts",IDC_C_RESET_CHANGES,226,45,52,20,BS_MULTILINE - PUSHBUTTON "&Undo",IDC_C_UNDO,226,67,52,16,WS_DISABLED - LTEXT "Is",IDC_STATIC,92,270,12,8 - CONTROL "Search ROM",IDC_C_SEARCHROM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,227,85,54,11 - PUSHBUTTON "&Hex Editor",IDC_C_HEXEDITOR,226,146,52,14 -END - -IDD_RAMWATCH DIALOGEX 0, 0, 269, 298 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION " RAM Watch" -MENU RAMWATCH_MENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_WATCHLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,210,279,WS_EX_CLIENTEDGE - PUSHBUTTON "Edit",IDC_C_WATCH_EDIT,226,66,34,14 - PUSHBUTTON "Remove",IDC_C_WATCH_REMOVE,226,83,34,14 - PUSHBUTTON "New",IDC_C_WATCH,226,100,34,14 - PUSHBUTTON "Duplicate",IDC_C_WATCH_DUPLICATE,226,117,34,14 - PUSHBUTTON "Add Cheat",IDC_C_ADDCHEAT,223,168,42,16,WS_DISABLED - GROUPBOX "Watches",IDC_STATIC,222,11,42,145 - CONTROL "",ID_WATCHES_UPDOWN,"msctls_updown32",WS_TABSTOP,232,23,19,36 - PUSHBUTTON "Separator",IDC_C_WATCH_SEPARATE,225,137,36,14 -END - -IDD_EDITWATCH DIALOGEX 0, 0, 181, 95 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION " Edit Watch" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CTEXT "Address:",IDC_SPECIFICADDRESS,18,12,35,10 - EDITTEXT IDC_EDIT_COMPAREADDRESS,55,10,65,12,ES_UPPERCASE | ES_AUTOHSCROLL - CTEXT "Notes:",IDC_PROMPT_TEXT,18,24,45,10 - EDITTEXT IDC_PROMPT_EDIT,55,22,65,12,ES_AUTOHSCROLL - GROUPBOX "Data Type",IDC_STATIC,14,37,75,42,0,WS_EX_TRANSPARENT - CONTROL "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,18,47,67,9 - CONTROL "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,57,67,9 - CONTROL "&Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,67,67,9 - GROUPBOX "Data Size",IDC_STATIC,94,37,73,42,0,WS_EX_TRANSPARENT - CONTROL "&1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,98,47,61,11 - CONTROL "&2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,57,61,11 - CONTROL "&4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,67,61,11 - DEFPUSHBUTTON "&OK",IDOK,66,80,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,120,80,50,14 -END - -IDD_PROMPT DIALOG 0, 0, 186, 68 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Input Prompt" -FONT 8, "Ms Shell Dlg 2" -BEGIN - DEFPUSHBUTTON "OK",IDOK,100,43,50,14 - PUSHBUTTON "Cancel",IDCANCEL,37,42,50,14 - EDITTEXT IDC_PROMPT_EDIT,10,15,167,14,ES_AUTOHSCROLL -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - "DIRCONFIG", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 295 - TOPMARGIN, 8 - END - - "DWBDIALOG", DIALOG - BEGIN - END - - "FKBDIALOG", DIALOG - BEGIN - END - - "GUICONFIG", DIALOG - BEGIN - END - - "INPUTCONFIG", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 338 - TOPMARGIN, 8 - BOTTOMMARGIN, 191 - END - - "MAPINPUT", DIALOG - BEGIN - END - - "MESSAGELOG", DIALOG - BEGIN - END - - "NETMOO", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 357 - TOPMARGIN, 8 - BOTTOMMARGIN, 201 - END - - "NEWINPUT", DIALOG - BEGIN - END - - "PALCONFIG", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 218 - TOPMARGIN, 8 - BOTTOMMARGIN, 108 - END - - "SOUNDCONFIG", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 324 - TOPMARGIN, 8 - BOTTOMMARGIN, 274 - END - - "TIMINGCONFIG", DIALOG - BEGIN - LEFTMARGIN, 10 - RIGHTMARGIN, 193 - TOPMARGIN, 8 - BOTTOMMARGIN, 52 - END - - "MOVIEOPTIONS", DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 138 - TOPMARGIN, 8 - BOTTOMMARGIN, 217 - END - - "DWBDIALOGSIMPLE", DIALOG - BEGIN - END - - "MEMWATCH", DIALOG - BEGIN - RIGHTMARGIN, 260 - BOTTOMMARGIN, 269 - END - - "DEBUGGER", DIALOG - BEGIN - END - - "TRACER", DIALOG - BEGIN - END - - "ADDBP", DIALOG - BEGIN - RIGHTMARGIN, 185 - BOTTOMMARGIN, 121 - END - - "NTVIEW", DIALOG - BEGIN - END - - "ROMPATCHER", DIALOG - BEGIN - END - - "GGCONV", DIALOG - BEGIN - END - - "MONITOR", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 312 - TOPMARGIN, 7 - BOTTOMMARGIN, 336 - END - - "MEMVIEWFIND", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 275 - TOPMARGIN, 7 - BOTTOMMARGIN, 74 - END - - "IDD_RECORDINP", DIALOG - BEGIN - BOTTOMMARGIN, 66 - END - - "IDD_REPLAYINP", DIALOG - BEGIN - BOTTOMMARGIN, 198 - END - - "TASEDITOR", DIALOG - BEGIN - END - - IDD_TASEDITOR_ABOUT, DIALOG - BEGIN - END - - IDD_TASEDITOR_NEWPROJECT, DIALOG - BEGIN - END - - IDD_TASEDITOR_EXPORT, DIALOG - BEGIN - END - - IDD_TASEDITOR_FINDNOTE, DIALOG - BEGIN - END - - IDD_TASEDITOR_SAVECOMPACT, DIALOG - BEGIN - END - - "ASSEMBLER", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 195 - TOPMARGIN, 7 - BOTTOMMARGIN, 128 - END - - "NAMEBOOKMARKDLG", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 66 - END - - "CDLOGGER", DIALOG - BEGIN - END - - "PPUVIEW", DIALOG - BEGIN - BOTTOMMARGIN, 258 - END - - "ARCHIVECHOOSERDIALOG", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 258 - TOPMARGIN, 7 - BOTTOMMARGIN, 152 - END - - "TEXTHOOKER", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 449 - TOPMARGIN, 7 - BOTTOMMARGIN, 320 - END - - "CHEATCONSOLE", DIALOG - BEGIN - BOTTOMMARGIN, 188 - END - - IDD_LUA, DIALOG - BEGIN - END - - "VIDEOCONFIG", DIALOG - BEGIN - END - - IDD_RAMSEARCH, DIALOG - BEGIN - END - - IDD_PROMPT, DIALOG - BEGIN - END -END -#endif // APSTUDIO_INVOKED - -#endif // Íåéòðàëüíûé resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Ðóññêèé (Ðîññèÿ) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_TASEDITOR_SAVINGOPTIONS DIALOGEX 0, 0, 223, 208 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Project file saving options" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,109,187,50,14 - PUSHBUTTON "Cancel",IDCANCEL,165,187,50,14 - CONTROL " Binary format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,17,89,10 - CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,32,67,10 - CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,47,67,10 - CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,62,67,10 - CONTROL " Piano Roll",IDC_CHECK_PIANO_ROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,77,67,10 - CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,92,67,10 - GROUPBOX "File contents",IDC_STATIC,105,4,111,177 - GROUPBOX "Greenzone saving options",IDC_STATIC,112,106,97,69 - CONTROL " all frames",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,122,117,77,10 - CONTROL " every 16th frame",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,122,131,77,10 - CONTROL " marked frames",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,122,145,77,10 - CONTROL " don't save",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,122,159,77,10 - CONTROL " Autosave project",IDC_AUTOSAVE_PROJECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,17,81,10 - CONTROL " silently",IDC_SILENT_AUTOSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,47,42,10 - LTEXT "every",IDC_STATIC,14,32,21,8 - EDITTEXT IDC_AUTOSAVE_PERIOD,36,30,24,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "minutes",IDC_STATIC,64,32,28,8 - GROUPBOX "Settings",IDC_STATIC,6,4,91,177 -END - -IDD_SYMBOLIC_DEBUG_NAMING DIALOGEX 0, 0, 245, 83 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Symbolic Debug Naming" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,132,62,50,14 - PUSHBUTTON "Cancel",IDCANCEL,189,62,50,14 - LTEXT "File",IDC_STATIC,7,7,15,9 - EDITTEXT IDC_SYMBOLIC_ADDRESS,38,24,33,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP - LTEXT "Address",IDC_STATIC,6,26,30,10 - EDITTEXT IDC_SYMBOLIC_NAME,107,24,132,13,ES_AUTOHSCROLL - LTEXT "Name",IDC_STATIC,83,26,22,10 - LTEXT "Comment",IDC_STATIC,6,45,37,10 - EDITTEXT IDC_SYMBOLIC_COMMENT,45,43,194,13,ES_AUTOHSCROLL - EDITTEXT IDC_SYMBOLIC_FILENAME,24,6,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_TASEDITOR_SAVINGOPTIONS, DIALOG - BEGIN - END - - IDD_SYMBOLIC_DEBUG_NAMING, DIALOG - BEGIN - BOTTOMMARGIN, 82 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Ðóññêèé (Ðîññèÿ) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Àíãëèéñêèé (ÑØÀ) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_REPLAY_METADATA DIALOGEX 0, 0, 325, 250 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Movie Metadata" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDCANCEL,268,229,50,14 - CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,311,214 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - "IDD_REPLAY_METADATA", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 318 - TOPMARGIN, 7 - BOTTOMMARGIN, 243 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_TASEDITOR_ACCELERATORS ACCELERATORS -BEGIN - "A", ACCEL_CTRL_A, VIRTKEY, CONTROL, NOINVERT - "B", ACCEL_CTRL_B, VIRTKEY, CONTROL, NOINVERT - "C", ACCEL_CTRL_C, VIRTKEY, CONTROL, NOINVERT - VK_DELETE, ACCEL_CTRL_DELETE, VIRTKEY, CONTROL, NOINVERT - VK_DOWN, ACCEL_CTRL_DOWN, VIRTKEY, CONTROL, NOINVERT - VK_END, ACCEL_CTRL_END, VIRTKEY, CONTROL, NOINVERT - "F", ACCEL_CTRL_F, VIRTKEY, CONTROL, NOINVERT - VK_HOME, ACCEL_CTRL_HOME, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ACCEL_CTRL_INSERT, VIRTKEY, CONTROL, NOINVERT - VK_LEFT, ACCEL_CTRL_LEFT, VIRTKEY, CONTROL, NOINVERT - VK_NEXT, ACCEL_CTRL_PGDN, VIRTKEY, CONTROL, NOINVERT - VK_PRIOR, ACCEL_CTRL_PGUP, VIRTKEY, CONTROL, NOINVERT - "Q", ACCEL_CTRL_Q, VIRTKEY, CONTROL, NOINVERT - VK_RIGHT, ACCEL_CTRL_RIGHT, VIRTKEY, CONTROL, NOINVERT - "S", ACCEL_CTRL_S, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ACCEL_CTRL_SHIFT_INS, VIRTKEY, SHIFT, CONTROL, NOINVERT - "V", ACCEL_CTRL_SHIFT_V, VIRTKEY, SHIFT, CONTROL, NOINVERT - VK_UP, ACCEL_CTRL_UP, VIRTKEY, CONTROL, NOINVERT - "V", ACCEL_CTRL_V, VIRTKEY, CONTROL, NOINVERT - "W", ACCEL_CTRL_W, VIRTKEY, CONTROL, NOINVERT - "X", ACCEL_CTRL_X, VIRTKEY, CONTROL, NOINVERT - "Y", ACCEL_CTRL_Y, VIRTKEY, CONTROL, NOINVERT - "Z", ACCEL_CTRL_Z, VIRTKEY, CONTROL, NOINVERT - VK_DELETE, ACCEL_DEL, VIRTKEY, NOINVERT - VK_END, ACCEL_END, VIRTKEY, NOINVERT - VK_HOME, ACCEL_HOME, VIRTKEY, NOINVERT - VK_INSERT, ACCEL_INS, VIRTKEY, NOINVERT - VK_NEXT, ACCEL_PGDN, VIRTKEY, NOINVERT - VK_PRIOR, ACCEL_PGUP, VIRTKEY, NOINVERT - VK_DOWN, ACCEL_SHIFT_DOWN, VIRTKEY, SHIFT, NOINVERT - VK_END, ACCEL_SHIFT_END, VIRTKEY, SHIFT, NOINVERT - VK_HOME, ACCEL_SHIFT_HOME, VIRTKEY, SHIFT, NOINVERT - VK_LEFT, ACCEL_SHIFT_LEFT, VIRTKEY, SHIFT, NOINVERT - VK_NEXT, ACCEL_SHIFT_PGDN, VIRTKEY, SHIFT, NOINVERT - VK_PRIOR, ACCEL_SHIFT_PGUP, VIRTKEY, SHIFT, NOINVERT - VK_RIGHT, ACCEL_SHIFT_RIGHT, VIRTKEY, SHIFT, NOINVERT - VK_UP, ACCEL_SHIFT_UP, VIRTKEY, SHIFT, NOINVERT -END - -IDR_RWACCELERATOR ACCELERATORS -BEGIN - "N", RAMMENU_FILE_NEW, VIRTKEY, CONTROL - "O", RAMMENU_FILE_OPEN, VIRTKEY, CONTROL - "S", RAMMENU_FILE_SAVE, VIRTKEY, CONTROL - "S", RAMMENU_FILE_SAVEAS, VIRTKEY, SHIFT, CONTROL - "A", IDC_C_WATCH_DUPLICATE, VIRTKEY - "E", IDC_C_WATCH_EDIT, VIRTKEY - "D", IDC_C_WATCH_DOWN, VIRTKEY - "U", IDC_C_WATCH_UP, VIRTKEY - "N", IDC_C_WATCH, VIRTKEY - "R", IDC_C_WATCH_REMOVE, VIRTKEY -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_BITMAP0 BITMAP "res\\te_0.bmp" -IDB_BITMAP1 BITMAP "res\\te_1.bmp" -IDB_BITMAP2 BITMAP "res\\te_2.bmp" -IDB_BITMAP3 BITMAP "res\\te_3.bmp" -IDB_BITMAP4 BITMAP "res\\te_4.bmp" -IDB_BITMAP5 BITMAP "res\\te_5.bmp" -IDB_BITMAP6 BITMAP "res\\te_6.bmp" -IDB_BITMAP7 BITMAP "res\\te_7.bmp" -IDB_BITMAP8 BITMAP "res\\te_8.bmp" -IDB_BITMAP9 BITMAP "res\\te_9.bmp" -IDB_BITMAP10 BITMAP "res\\te_10.bmp" -IDB_BITMAP11 BITMAP "res\\te_11.bmp" -IDB_BITMAP12 BITMAP "res\\te_12.bmp" -IDB_BITMAP13 BITMAP "res\\te_13.bmp" -IDB_BITMAP14 BITMAP "res\\te_14.bmp" -IDB_BITMAP15 BITMAP "res\\te_15.bmp" -IDB_BITMAP16 BITMAP "res\\te_16.bmp" -IDB_BITMAP17 BITMAP "res\\te_17.bmp" -IDB_BITMAP18 BITMAP "res\\te_18.bmp" -IDB_BITMAP19 BITMAP "res\\te_19.bmp" -IDB_TE_ARROW BITMAP "res\\te_arrow.bmp" -IDB_TE_GREEN_ARROW BITMAP "res\\te_green_arrow.bmp" -IDB_TE_GREEN_BLUE_ARROW BITMAP "res\\te_green_blue_arrow.bmp" -IDB_PIANO_0 BITMAP "res\\te_piano_0.bmp" -IDB_PIANO_1 BITMAP "res\\te_piano_1.bmp" -IDB_PIANO_2 BITMAP "res\\te_piano_2.bmp" -IDB_PIANO_3 BITMAP "res\\te_piano_3.bmp" -IDB_PIANO_4 BITMAP "res\\te_piano_4.bmp" -IDB_PIANO_5 BITMAP "res\\te_piano_5.bmp" -IDB_PIANO_6 BITMAP "res\\te_piano_6.bmp" -IDB_PIANO_7 BITMAP "res\\te_piano_7.bmp" -IDB_PIANO_8 BITMAP "res\\te_piano_8.bmp" -IDB_PIANO_9 BITMAP "res\\te_piano_9.bmp" -IDB_PIANO_10 BITMAP "res\\te_piano_10.bmp" -IDB_PIANO_11 BITMAP "res\\te_piano_11.bmp" -IDB_PIANO_12 BITMAP "res\\te_piano_12.bmp" -IDB_PIANO_13 BITMAP "res\\te_piano_13.bmp" -IDB_PIANO_14 BITMAP "res\\te_piano_14.bmp" -IDB_PIANO_15 BITMAP "res\\te_piano_15.bmp" -IDB_PIANO_16 BITMAP "res\\te_piano_16.bmp" -IDB_PIANO_17 BITMAP "res\\te_piano_17.bmp" -IDB_PIANO_18 BITMAP "res\\te_piano_18.bmp" -IDB_PIANO_19 BITMAP "res\\te_piano_19.bmp" -IDB_PIANO_PLAYBACK_0 BITMAP "res\\te_piano_0_playback.bmp" -IDB_PIANO_PLAYBACK_1 BITMAP "res\\te_piano_1_playback.bmp" -IDB_PIANO_PLAYBACK_2 BITMAP "res\\te_piano_2_playback.bmp" -IDB_PIANO_PLAYBACK_3 BITMAP "res\\te_piano_3_playback.bmp" -IDB_PIANO_PLAYBACK_4 BITMAP "res\\te_piano_4_playback.bmp" -IDB_PIANO_PLAYBACK_5 BITMAP "res\\te_piano_5_playback.bmp" -IDB_PIANO_PLAYBACK_6 BITMAP "res\\te_piano_6_playback.bmp" -IDB_PIANO_PLAYBACK_7 BITMAP "res\\te_piano_7_playback.bmp" -IDB_PIANO_PLAYBACK_8 BITMAP "res\\te_piano_8_playback.bmp" -IDB_PIANO_PLAYBACK_9 BITMAP "res\\te_piano_9_playback.bmp" -IDB_PIANO_PLAYBACK_10 BITMAP "res\\te_piano_10_playback.bmp" -IDB_PIANO_PLAYBACK_11 BITMAP "res\\te_piano_11_playback.bmp" -IDB_PIANO_PLAYBACK_12 BITMAP "res\\te_piano_12_playback.bmp" -IDB_PIANO_PLAYBACK_13 BITMAP "res\\te_piano_13_playback.bmp" -IDB_PIANO_PLAYBACK_14 BITMAP "res\\te_piano_14_playback.bmp" -IDB_PIANO_PLAYBACK_15 BITMAP "res\\te_piano_15_playback.bmp" -IDB_PIANO_PLAYBACK_16 BITMAP "res\\te_piano_16_playback.bmp" -IDB_PIANO_PLAYBACK_17 BITMAP "res\\te_piano_17_playback.bmp" -IDB_PIANO_PLAYBACK_18 BITMAP "res\\te_piano_18_playback.bmp" -IDB_PIANO_PLAYBACK_19 BITMAP "res\\te_piano_19_playback.bmp" -IDB_PIANO_LOSTPOS_0 BITMAP "res\\te_piano_0_lostpos.bmp" -IDB_PIANO_LOSTPOS_1 BITMAP "res\\te_piano_1_lostpos.bmp" -IDB_PIANO_LOSTPOS_2 BITMAP "res\\te_piano_2_lostpos.bmp" -IDB_PIANO_LOSTPOS_3 BITMAP "res\\te_piano_3_lostpos.bmp" -IDB_PIANO_LOSTPOS_4 BITMAP "res\\te_piano_4_lostpos.bmp" -IDB_PIANO_LOSTPOS_5 BITMAP "res\\te_piano_5_lostpos.bmp" -IDB_PIANO_LOSTPOS_6 BITMAP "res\\te_piano_6_lostpos.bmp" -IDB_PIANO_LOSTPOS_7 BITMAP "res\\te_piano_7_lostpos.bmp" -IDB_PIANO_LOSTPOS_8 BITMAP "res\\te_piano_8_lostpos.bmp" -IDB_PIANO_LOSTPOS_9 BITMAP "res\\te_piano_9_lostpos.bmp" -IDB_PIANO_LOSTPOS_10 BITMAP "res\\te_piano_10_lostpos.bmp" -IDB_PIANO_LOSTPOS_11 BITMAP "res\\te_piano_11_lostpos.bmp" -IDB_PIANO_LOSTPOS_12 BITMAP "res\\te_piano_12_lostpos.bmp" -IDB_PIANO_LOSTPOS_13 BITMAP "res\\te_piano_13_lostpos.bmp" -IDB_PIANO_LOSTPOS_14 BITMAP "res\\te_piano_14_lostpos.bmp" -IDB_PIANO_LOSTPOS_15 BITMAP "res\\te_piano_15_lostpos.bmp" -IDB_PIANO_LOSTPOS_16 BITMAP "res\\te_piano_16_lostpos.bmp" -IDB_PIANO_LOSTPOS_17 BITMAP "res\\te_piano_17_lostpos.bmp" -IDB_PIANO_LOSTPOS_18 BITMAP "res\\te_piano_18_lostpos.bmp" -IDB_PIANO_LOSTPOS_19 BITMAP "res\\te_piano_19_lostpos.bmp" -IDB_BITMAP_SELECTED0 BITMAP "res\\te_0_selected.bmp" -IDB_BITMAP_SELECTED1 BITMAP "res\\te_1_selected.bmp" -IDB_BITMAP_SELECTED2 BITMAP "res\\te_2_selected.bmp" -IDB_BITMAP_SELECTED3 BITMAP "res\\te_3_selected.bmp" -IDB_BITMAP_SELECTED4 BITMAP "res\\te_4_selected.bmp" -IDB_BITMAP_SELECTED5 BITMAP "res\\te_5_selected.bmp" -IDB_BITMAP_SELECTED6 BITMAP "res\\te_6_selected.bmp" -IDB_BITMAP_SELECTED7 BITMAP "res\\te_7_selected.bmp" -IDB_BITMAP_SELECTED8 BITMAP "res\\te_8_selected.bmp" -IDB_BITMAP_SELECTED9 BITMAP "res\\te_9_selected.bmp" -IDB_BITMAP_SELECTED10 BITMAP "res\\te_10_selected.bmp" -IDB_BITMAP_SELECTED11 BITMAP "res\\te_11_selected.bmp" -IDB_BITMAP_SELECTED12 BITMAP "res\\te_12_selected.bmp" -IDB_BITMAP_SELECTED13 BITMAP "res\\te_13_selected.bmp" -IDB_BITMAP_SELECTED14 BITMAP "res\\te_14_selected.bmp" -IDB_BITMAP_SELECTED15 BITMAP "res\\te_15_selected.bmp" -IDB_BITMAP_SELECTED16 BITMAP "res\\te_16_selected.bmp" -IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp" -IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp" -IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp" -IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp" -#endif // Àíãëèéñêèé (ÑØÀ) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/branches/fceux-2.2.2/src/drivers/win/resource.h b/branches/fceux-2.2.2/src/drivers/win/resource.h deleted file mode 100644 index bcf526c9..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/resource.h +++ /dev/null @@ -1,1220 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by res.rc -// -#define CLOSE_BUTTON 1 -#define BUTTON_CLOSE 1 -#define BTN_CLOSE 1 -#define IDB_CLOSE_LOG 1 -#define MENU_OPEN_FILE 100 -#define EDIT_ROMS 100 -#define LBL_LOG_TEXT 100 -#define LBL_KEY_COMBO 100 -#define LBL_CDLOGGER_CODECOUNT 100 -#define CHECK_PALETTE_ENABLED 100 -#define LBL_DWBDIALOG_TEXT 100 -#define GRP_GAMEPAD1 100 -#define IDC_TRACER_LOG 100 -#define MENU_MV_FILE_SAVE 100 -#define IDC_VIDEOCONFIG_MODE 100 -#define IDC_ROMPATCHER_OFFSET_BOX 100 -#define IDC_ASSEMBLER_HISTORY 100 -#define MENU_CLOSE_FILE 101 -#define IDI_ICON1 101 -#define CB_DISABLE_SPEED_THROTTLING 101 -#define LBL_CDLOGGER_DATACOUNT 101 -#define GRP_PPUVIEW_TABLES 101 -#define IDC_NETMOO_STATUS 101 -#define GRP_GAMEPAD2 101 -#define IDC_LIST_CHEATS 101 -#define IDC_SCRL_TRACER_LOG 101 -#define MENU_MV_FILE_SAVE_AS 101 -#define IDC_VIDEOCONFIG_FS 101 -#define IDC_DEBUGGER_BP_ADD 101 -#define IDC_ROMPATCHER_DOTNES_OFFSET 101 -#define IDC_NTVIEW_TABLE_BOX 101 -#define IDC_ASSEMBLER_DISASSEMBLY 101 -#define IDI_ICON2 102 -#define MENU_RECENT_FILES 102 -#define CB_LOAD_FILE_OPEN 102 -#define LBL_CDLOGGER_UNDEFCOUNT 102 -#define IDC_PPUVIEW_SCANLINE 102 -#define IDC_NETMOO_CMD_INPUT 102 -#define IDC_CHEAT_ADDR 102 -#define IDC_BTN_START_STOP_LOGGING 102 -#define MENU_MV_FILE_LOAD_TBL 102 -#define IDC_VIDEOCONFIG_AUTO_FS 102 -#define IDC_DEBUGGER_BP_DEL 102 -#define IDC_ADDBP_MODE_R 102 -#define IDC_ROMPATCHER_OFFSET 102 -#define IDC_NTVIEW_SCANLINE 102 -#define IDC_ASSEMBLER_PATCH_DISASM 102 -#define CHECK_PALETTE_GRAYSCALE 102 -#define BTN_CDLOGGER_RESET 103 -#define LBL_PPUVIEW_TILE1 103 -#define IDC_CHEAT_VAL 103 -#define IDC_RADIO_LOG_LAST 103 -#define MENU_MV_FILE_UNLOAD_TBL 103 -#define IDC_DEBUGGER_BP_EDIT 103 -#define IDC_ADDBP_MODE_W 103 -#define IDC_ROMPATCHER_BTN_EDIT 103 -#define IDC_NTVIEW_PROPERTIES_LINE_1 103 -#define IDC_VIDEOCONFIG_HIDEMOUSE 103 -#define CB_AUTO_HIDE_MENU 104 -#define COMBO_PAD1 104 -#define BTN_CDLOGGER_LOAD 104 -#define LBL_PPUVIEW_TILE2 104 -#define IDC_CHEAT_NAME 104 -#define IDC_RADIO_LOG_TO_FILE 104 -#define MENU_MV_FILE_DUMP_RAM 104 -#define IDC_VIDEOCONFIG_SYNC_METHOD_WIN 104 -#define IDC_DEBUGGER_RUN 104 -#define IDC_ADDBP_MODE_X 104 -#define IDC_ROMPATCHER_CURRENT_DATA_BOX 104 -#define IDC_NTVIEW_PROPERTIES_LINE_2 104 -#define CHECK_PALETTE_CUSTOM 104 -#define COMBO_PAD2 105 -#define CB_SET_HIGH_PRIORITY 105 -#define BTN_CDLOGGER_START_PAUSE 105 -#define LBL_PPUVIEW_PALETTES 105 -#define IDC_CHEAT_VAL_KNOWN 105 -#define MENU_MV_FILE_DUMP_PPU 105 -#define IDC_VIDEOCONFIG_SYNC_METHOD_FS 105 -#define IDC_DEBUGGER_STEP_IN 105 -#define IDC_TRACER_LOG_SIZE 105 -#define IDC_ADDBP_MEM_CPU 105 -#define IDC_ROMPATCHER_CURRENT_DATA 105 -#define IDC_NTVIEW_PROPERTIES_LINE_3 105 -#define BTN_PORT1 106 -#define BTN_CDLOGGER_SAVE_AS 106 -#define IDC_CHEAT_LIST_POSSIBILITIES 106 -#define IDC_VIDEOCONFIG_CLIPSIDES 106 -#define IDC_DEBUGGER_STEP_OUT 106 -#define IDC_ADDBP_MEM_PPU 106 -#define IDC_NTVIEW_PROPERTIES_LINE_4 106 -#define IDC_TEXT_LINES_TO_THIS_WINDOW 106 -#define BTN_PORT2 107 -#define BTN_CDLOGGER_SAVE 107 -#define IDC_CHEAT_SCRL_POSSIBILITIES 107 -#define IDC_DEBUGGER_STEP_OVER 107 -#define IDC_ADDBP_MEM_SPR 107 -#define IDC_ROMPATCHER_DISASSEMBLY 107 -#define IDC_VIDEOCONFIG_BESTFIT 107 -#define IDR_ACCELERATOR1 108 -#define BTN_CDLOGGER_SAVE_STRIPPED 108 -#define IDC_CHEAT_VAL_NE_BY 108 -#define IDC_DEBUGGER_SEEK_PC 108 -#define IDR_TASEDITOR_ACCELERATORS 108 -#define IDC_VIDEOCONFIG_CONSOLE_BGCOLOR 108 -#define IDC_CHEAT_VAL_GT_BY 109 -#define IDC_DEBUGGER_SEEK_TO 109 -#define IDC_ROMPATCHER_PATCH_DATA 109 -#define IDC_ADDBP_MODE_X2 109 -#define IDC_ADDBP_MODE_F 109 -#define BTN_CDLOGGER_SAVE_UNUSED 109 -#define IDC_VIDEOCONFIG_43 109 -#define IDC_VIDEOCONFIG_TVASPECT 109 -#define IDC_GROUP_LOG_OPTIONS 109 -#define IDC_CHEAT_VAL_LT_BY 110 -#define MENU_SAVE_STATE 110 -#define CB_ASK_EXIT 110 -#define COMBO_FAM 110 -#define IDB_TE_ARROW 110 -#define IDC_CHECK_LOG_REGISTERS 110 -#define IDC_DEBUGGER_BREAK_ON_BAD_OP 110 -#define IDC_ROMPATCHER_BTN_APPLY 110 -#define LBL_CDLOGGER_RENDERCOUNT 110 -#define IDC_VIDEOCONFIG_SQUARE_PIXELS 110 -#define MENU_LOAD_STATE 111 -#define CB_DISABLE_SCREEN_SAVER 111 -#define BTN_FAM 111 -#define IDC_CHECK_LOG_PROCESSOR_STATUS 111 -#define IDC_DEBUGGER_RELOAD_SYMS 111 -#define IDC_ROMPATCHER_BTN_SAVE 111 -#define IDC_CHEAT_VAL2 111 -#define IDC_CHEAT_COM 111 -#define IDC_VIDEOCONFIG_DIRECTDRAW_FS 111 -#define BTN_AUTO_HOLD 112 -#define IDC_BTN_LOG_BROWSE 112 -#define IDC_DEBUGGER_BOOKMARK_ADD 112 -#define IDC_VIDEOCONFIG_DIRECTDRAW_WIN 112 -#define IDC_DEBUGGER_BOOKMARK_DEL 113 -#define IDC_EXTRA_LOG_OPTIONS 113 -#define BTN_CLEAR_AH 114 -#define IDC_CHECK_LOG_NEW_INSTRUCTIONS 114 -#define IDD_DIALOG1 114 -#define IDC_DEBUGGER_RUN_LINE 114 -#define LBL_CDLOGGER_VROMREADCOUNT 114 -#define LBL_AUTO_HOLD 115 -#define IDC_CHECK_LOG_NEW_DATA 115 -#define IDD_DIALOG2 115 -#define IDC_DEBUGGER_STEP_OUT3 115 -#define IDC_DEBUGGER_RUN_FRAME2 115 -#define LBL_CDLOGGER_UNDEFVROMCOUNT 115 -#define LBL_CLEAR_AH 116 -#define IDC_CHECK_LOG_UPDATE_WINDOW 116 -#define IDC_DEBUGGER_RESET_CYCLES_COUNTER 116 -#define IDC_DEBUGGER_RESET_COUNTERS 116 -#define CHEAT_CONTEXT_TOGGLECHEAT 117 -#define IDC_DEBUGGER_RESET_ON_STEP 117 -#define IDC_DEBUGGER_BREAK_ON_CYCLES 117 -#define IDC_CHECK_LINES_TABBING 117 -#define IDC_CHECK_CODE_TABBING 117 -#define CHEAT_CONTEXT_POKECHEATVALUE 118 -#define IDC_DEBUGGER_RESET_ON_BP0 118 -#define IDC_CHECK_LOG_STATUSES_TO_THE_LEFT 118 -#define IDC_DEBUGGER_BOOKMARK_DEL2 118 -#define IDC_DEBUGGER_BOOKMARK_NAME 118 -#define CHEAT_CONTEXT_GOTOINHEXEDITOR 119 -#define IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS 119 -#define IDC_CHECK_LOG_FRAME_NUMBER 119 -#define IDC_CHECK_LOG_FRAMES_COUNT 119 -#define IDC_CHECK_LOG_CYCLES_COUNT 120 -#define IDC_CHECK_LOG_FRAME_NUMBER3 121 -#define IDC_CHECK_LOG_INSTRUCTIONS_COUNT 121 -#define CHECK_SOUND_8BIT 122 -#define IDD_DIALOG3 123 -#define IDC_CHECK_SYMBOLIC_TRACING 123 -#define CHECK_SOUND_GLOBAL_FOCUS 124 -#define INSERTCOMMENTSUBTITLE 124 -#define IDC_CHECK_LOG_MESSAGES 124 -#define IDC_CHECK_LOG_BREAKPOINTS 125 -#define CHECK_SOUND_ENABLED 126 -#define CTL_LATENCY_TRACKBAR 128 -#define COMBO_SOUND_QUALITY 129 -#define CHECK_SOUND_MUTEFA 130 -#define IDC_DISABLE_HW_ACCEL_WIN 130 -#define IDC_DISABLE_HW_ACCEL_FS 131 -#define DEBUGGER_CONTEXT_TOGGLEBREAK 132 -#define MENU_RECORD_MOVIE 141 -#define MENU_REPLAY_MOVIE 142 -#define MENU_STOP_MOVIE 143 -#define MENU_RECORD_AVI 151 -#define MENU_STOP_AVI 152 -#define MENU_EXIT 153 -#define IDD_RAMSEARCH 154 -#define IDD_RAMWATCH 155 -#define IDD_EDITWATCH 156 -#define IDD_PROMPT 157 -#define IDR_RWACCELERATOR 158 -#define IDD_LUA 159 -#define IDB_BITMAP0 163 -#define IDB_BITMAP1 164 -#define IDB_BITMAP2 165 -#define IDB_BITMAP3 166 -#define IDB_BITMAP4 167 -#define IDB_BITMAP5 168 -#define IDB_BITMAP6 169 -#define IDB_BITMAP7 170 -#define IDB_BITMAP8 171 -#define IDB_BITMAP9 172 -#define IDB_BITMAP10 173 -#define IDB_BITMAP11 174 -#define IDB_BITMAP12 175 -#define IDB_BITMAP13 176 -#define IDB_BITMAP14 177 -#define IDB_BITMAP15 178 -#define IDB_BITMAP16 179 -#define IDB_BITMAP17 180 -#define IDB_BITMAP18 181 -#define IDB_BITMAP19 182 -#define IDB_BRANCH_SPRITESHEET 184 -#define IDD_TASEDITOR_SAVECOMPACT 195 -#define IDD_TASEDITOR_EXPORT 196 -#define IDI_ICON3 197 -#define IDD_TASEDITOR_FINDNOTE 198 -#define IDD_TASEDITOR_ABOUT 199 -#define MENU_RESET 200 -#define BUTTON_ROMS 200 -#define TXT_PAD1 200 -#define BTN_RESTORE_DEFAULTS 200 -#define BTN_CLEAR 200 -#define IDC_EDIT_FILENAME 200 -#define IDC_COMBO_FILENAME 200 -#define BTN_PALETTE_LOAD 200 -#define IDC_NETMOO_HOST 200 -#define COMBO_SOUND_RATE 200 -#define MENU_MV_EDIT_UNDO 200 -#define IDC_VIDEOCONFIG_XRES 200 -#define IDC_DEBUGGER_FLAG_N 200 -#define IDC_ADDBP_ADDR_START 200 -#define MENU_POWER 201 -#define TXT_PAD2 201 -#define IDC_BUTTON_BROWSEFILE 201 -#define IDC_CHECK_READONLY 201 -#define BTN_PALETTE_RESET 201 -#define CTL_PPUVIEW_TRACKBAR 201 -#define IDC_NETMOO_PORT 201 -#define MENU_MV_EDIT_COPY 201 -#define IDC_VIDEOCONFIG_YRES 201 -#define IDC_DEBUGGER_FLAG_V 201 -#define IDC_ADDBP_ADDR_END 201 -#define IDC_NTVIEW_REFRESH_TRACKBAR 201 -#define IDC_ASSEMBLER_APPLY 201 -#define IDI_ICON4 201 -#define BTN_OK 201 -#define MENU_EJECT_DISK 202 -#define TXT_FAM 202 -#define MENU_MV_EDIT_PASTE 202 -#define IDC_VIDEOCONFIG_BPP 202 -#define IDC_DEBUGGER_FLAG_U 202 -#define IDC_ADDBP_CONDITION 202 -#define IDC_ASSEMBLER_SAVE 202 -#define IDD_TASEDITOR_NEWPROJECT 202 -#define MENU_SWITCH_DISK 203 -#define IDC_NETMOO_NICK 203 -#define IDC_CHEAT_BOX_POSSIBILITIES 203 -#define MENU_MV_EDIT_FIND 203 -#define IDC_DEBUGGER_FLAG_B 203 -#define IDC_ADDBP_NAME 203 -#define IDC_ASSEMBLER_UNDO 203 -#define MENU_INSERT_COIN 204 -#define COMBO_NETMOO_LOCAL_PLAYERS 204 -#define MENU_MV_EDIT_FIND_NEXT 204 -#define IDC_DEBUGGER_FLAG_D 204 -#define IDC_NETMOO_KEY 205 -#define IDC_DEBUGGER_FLAG_I 205 -#define IDB_BITMAP20 205 -#define IDB_TE_GREEN_ARROW 205 -#define IDC_NETMOO_PASS 206 -#define IDC_DEBUGGER_FLAG_Z 206 -#define IDC_DEBUGGER_FLAG_C 207 -#define IDC_DEBUGGER_ENABLE_SYMBOLIC 208 -#define IDB_TE_GREEN_BLUE_ARROW 208 -#define IDB_PIANO_0 209 -#define IDC_DEBUGGER_ROM_OFFSETS 209 -#define IDB_PIANO_1 210 -#define IDB_PIANO_2 211 -#define IDB_PIANO_3 212 -#define IDB_PIANO_4 213 -#define IDB_PIANO_5 214 -#define IDB_PIANO_6 215 -#define IDB_PIANO_7 216 -#define IDB_PIANO_8 217 -#define IDB_PIANO_9 218 -#define IDB_PIANO_10 219 -#define IDB_PIANO_11 220 -#define IDB_PIANO_12 221 -#define IDB_PIANO_13 222 -#define IDB_PIANO_14 223 -#define IDB_PIANO_15 224 -#define IDB_PIANO_16 225 -#define IDB_PIANO_17 226 -#define IDB_PIANO_18 227 -#define IDB_PIANO_19 228 -#define IDB_PIANO_PLAYBACK_0 229 -#define IDB_PIANO_PLAYBACK_1 230 -#define IDB_PIANO_PLAYBACK_2 231 -#define IDB_PIANO_PLAYBACK_3 232 -#define IDB_PIANO_PLAYBACK_4 233 -#define IDB_PIANO_PLAYBACK_5 234 -#define IDB_PIANO_PLAYBACK_6 235 -#define IDB_PIANO_PLAYBACK_7 236 -#define IDB_PIANO_PLAYBACK_8 237 -#define IDB_PIANO_PLAYBACK_9 238 -#define IDB_PIANO_PLAYBACK_10 239 -#define IDB_PIANO_PLAYBACK_11 240 -#define IDB_PIANO_PLAYBACK_12 241 -#define IDB_PIANO_PLAYBACK_13 242 -#define IDB_PIANO_PLAYBACK_14 243 -#define IDB_PIANO_PLAYBACK_15 244 -#define IDB_PIANO_PLAYBACK_16 245 -#define IDB_PIANO_PLAYBACK_17 246 -#define IDB_PIANO_PLAYBACK_18 247 -#define IDB_PIANO_PLAYBACK_19 248 -#define IDB_PIANO_LOSTPOS_0 249 -#define IDB_PIANO_LOSTPOS_1 250 -#define BTN_NETMOO_CONNECT 250 -#define IDB_PIANO_LOSTPOS_2 251 -#define IDB_PIANO_LOSTPOS_3 252 -#define IDB_PIANO_LOSTPOS_4 253 -#define IDB_PIANO_LOSTPOS_5 254 -#define IDB_PIANO_LOSTPOS_6 255 -#define IDB_PIANO_LOSTPOS_7 256 -#define IDB_PIANO_LOSTPOS_8 257 -#define IDB_PIANO_LOSTPOS_9 258 -#define IDB_PIANO_LOSTPOS_10 259 -#define IDB_PIANO_LOSTPOS_11 260 -#define IDB_PIANO_LOSTPOS_12 261 -#define IDB_PIANO_LOSTPOS_13 262 -#define IDB_PIANO_LOSTPOS_14 263 -#define IDB_PIANO_LOSTPOS_15 264 -#define IDB_PIANO_LOSTPOS_16 265 -#define IDB_PIANO_LOSTPOS_17 266 -#define IDB_PIANO_LOSTPOS_18 267 -#define IDB_PIANO_LOSTPOS_19 268 -#define IDB_BITMAP_SELECTED0 269 -#define IDB_BITMAP_SELECTED1 270 -#define IDB_BITMAP_SELECTED2 271 -#define IDB_BITMAP_SELECTED3 272 -#define IDB_BITMAP_SELECTED4 273 -#define IDB_BITMAP_SELECTED5 274 -#define IDB_BITMAP_SELECTED6 275 -#define IDB_BITMAP_SELECTED7 276 -#define IDB_BITMAP_SELECTED8 277 -#define IDB_BITMAP_SELECTED9 278 -#define IDB_BITMAP_SELECTED10 279 -#define IDB_BITMAP_SELECTED11 280 -#define IDB_BITMAP_SELECTED12 281 -#define IDB_BITMAP_SELECTED13 282 -#define IDB_BITMAP_SELECTED14 283 -#define IDB_BITMAP_SELECTED15 284 -#define IDB_BITMAP_SELECTED16 285 -#define IDB_BITMAP_SELECTED17 286 -#define IDB_BITMAP_SELECTED18 287 -#define IDB_BITMAP_SELECTED19 288 -#define IDD_TASEDITOR_SAVINGOPTIONS 289 -#define IDD_SYMBOLIC_DEBUG_NAMING 290 -#define MENU_HIDE_MENU 300 -#define COMBO_FILTER 300 -#define IDC_EDIT_AUTHORINFO 300 -#define IDC_LABEL_LENGTH 300 -#define MENU_MV_VIEW_RAM 300 -#define IDC_RADIO_SCALE 300 -#define IDC_DEBUGGER_DISASSEMBLY 300 -#define IDC_ASSEMBLER_DEFPUSHBUTTON 300 -#define MENU_RUN_IN_BACKGROUND 301 -#define IDC_COMBO_RECORDFROM 301 -#define IDC_LABEL_FRAMES 301 -#define IDC_BTN_CHEAT_ADD 301 -#define MENU_MV_VIEW_PPU 301 -#define IDC_RADIO_STRETCH 301 -#define IDC_DEBUGGER_DISASSEMBLY_VSCR 301 -#define MENU_BACKGROUND_INPUT 302 -#define IDC_LABEL_UNDOCOUNT 302 -#define IDC_BTN_CHEAT_DEL 302 -#define MENU_MV_VIEW_ROM 302 -#define IDC_VIDEOCONFIG_XSCALE 302 -#define IDC_DEBUGGER_BP_LIST 302 -#define MENU_SHOW_STATUS_ICON 303 -#define IDC_LABEL_AUTHORINFO 303 -#define IDC_BTN_CHEAT_UPD 303 -#define IDC_VIDEOCONFIG_YSCALE 303 -#define IDC_DEBUGGER_DISASSEMBLY2 303 -#define IDC_DEBUGGER_DISASSEMBLY_LEFT_PANEL 303 -#define MENU_ENABLE_AUTOSAVE 304 -#define IDC_LABEL_ROMUSED 304 -#define IDC_BTN_CHEAT_RESET 304 -#define IDC_VIDEOCONFIG_SCALER_FS 304 -#define IDC_DEBUGGER_VAL_A 304 -#define IDC_LABEL_ROMCHECKSUM 305 -#define IDC_BTN_CHEAT_KNOWN 305 -#define IDC_DEBUGGER_VAL_X 305 -#define IDC_LABEL_RECORDEDFROM 306 -#define IDC_BTN_CHEAT_EQ 306 -#define IDC_DEBUGGER_VAL_Y 306 -#define IDC_LABEL_EMULATORUSED 307 -#define IDC_BTN_CHEAT_NE 307 -#define IDC_DEBUGGER_VAL_PC 307 -#define IDC_LABEL_CURRCHECKSUM 308 -#define IDC_BTN_CHEAT_GT 308 -#define IDC_DEBUGGER_STACK_CONTENTS 308 -#define IDC_BTN_CHEAT_LT 309 -#define IDC_DEBUGGER_VAL_PCSEEK 309 -#define IDC_LABEL_PALUSED 309 -#define MENU_GAME_GENIE 310 -#define IDC_DEBUGGER_VAL_PPU 310 -#define IDC_LABEL_PALUSED2 310 -#define IDC_LABEL_NEWPPUUSED 310 -#define MENU_PAL 311 -#define IDC_DEBUGGER_VAL_SPR 311 -#define IDC_LABEL_TWEAKCOUNT 311 -#define IDC_BTN_CHEAT_ADDFROMFILE 311 -#define IDC_DEBUGGER_BOOKMARK 312 -#define IDC_DEBUGGER_CYCLES_EXCEED 313 -#define IDC_DEBUGGER_INSTRUCTIONS_EXCEED 314 -#define MENU_DIRECTORIES 320 -#define MENU_INPUT 321 -#define MENU_GUI_OPTIONS 327 -#define CHECK_DISABLE_FOURSCORE 400 -#define MENU_MV_BOOKMARKS_RM_ALL 400 -#define IDC_WINSIZE_MUL_X 400 -#define IDC_CHEAT_CHECK_NE_BY 401 -#define IDC_WINSIZE_MUL_Y 401 -#define CHECK_ENABLE_FOURSCORE 401 -#define IDC_CHEAT_CHECK_GT_BY 402 -#define IDC_FORCE_INT_VIDEO_SCALARS 402 -#define IDC_DEBUGGER_BREAKPOINTS 402 -#define IDC_CHEAT_CHECK_LT_BY 403 -#define IDC_FORCE_ASPECT_CORRECTION 403 -#define IDC_DEBUGGER_VAL_S 403 -#define IDC_VIDEOCONFIG_ASPECT_X 404 -#define IDC_TVASPECT_X 404 -#define IDC_VIDEOCONFIG_ASPECT_Y 405 -#define IDC_DEBUGGER_VAL_S2 405 -#define IDC_TVASPECT_Y 405 -#define IDC_VIDEOCONFIG_SCALER_WIN 406 -#define CHECK_ENABLE_MICROPHONE 407 -#define CTL_TINT_TRACKBAR 500 -#define CTL_VOLUME_TRACKBAR 500 -#define IDC_SCANLINE_FIRST_NTSC 500 -#define IDC_SCANLINE_LAST_NTSC 501 -#define CTL_HUE_TRACKBAR 501 -#define IDC_DEBUGGER_VAL_SLINE 501 -#define CTL_VOLUME_TRACKBAR_TRIANGLE 501 -#define IDC_SCANLINE_FIRST_PAL 502 -#define IDC_DEBUGGER_ADDR_LINE 502 -#define CTL_VOLUME_TRACKBAR_SQUARE1 502 -#define IDC_SCANLINE_LAST_PAL 503 -#define CTL_VOLUME_TRACKBAR_SQUARE2 503 -#define IDC_DEBUGGER_VAL_CYCLES_COUNT 503 -#define CTL_VOLUME_TRACKBAR_NOISE 504 -#define IDC_DEBUGGER_VAL_PPUPIXEL 504 -#define IDC_SCANLINE_FIRST_NTSC2 504 -#define CTL_VOLUME_TRACKBAR_NOISE2 505 -#define CTL_VOLUME_TRACKBAR_PCM 505 -#define IDC_DEBUGGER_VAL_CYCLES_COUNT2 505 -#define IDC_DEBUGGER_VAL_CYCLES_COUNT3 506 -#define IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT 506 -#define IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2 507 -#define IDC_VIDEOCONFIG_NO8LIM 600 -#define IDC_DEBUGGER_ROM_PATCHER 602 -#define LIST_DEBUGGER_BOOKMARKS 701 -#define BTN_CANCEL 800 -#define IDC_EDIT_OFFSET 1000 -#define IDC_GAME_GENIE_CODE 1000 -#define IDC_MEMVIEWFIND_WHAT 1000 -#define IDC_BOOKMARK_DESCRIPTION 1000 -#define MW_ADDR00 1001 -#define IDC_EDIT_FROM 1001 -#define IDC_GAME_GENIE_ADDR 1001 -#define IDC_MEMVIEWFIND_TYPE_HEX 1001 -#define IDC_NTVIEW_MIRROR_HORIZONTAL 1001 -#define IDC_CHECK_STOPMOVIE 1002 -#define IDC_GAME_GENIE_COMP 1002 -#define IDC_TRACER_STATS 1002 -#define IDC_MEMVIEWFIND_TYPE_TEXT 1002 -#define IDC_NTVIEW_MIRROR_VERTICAL 1002 -#define LV_MAPPING 1003 -#define IDC_EDIT_STOPFRAME 1003 -#define IDC_GAME_GENIE_VAL 1003 -#define IDC_MEMVIEWFIND_DIR_UP 1003 -#define IDC_NTVIEW_MIRROR_FOUR_SCREEN 1003 -#define MW_ADDR01 1004 -#define IDC_LIST_GGADDRESSES 1004 -#define IDC_MEMVIEWFIND_DIR_DOWN 1004 -#define IDC_NTVIEW_MIRROR_SS_TABLE_0 1004 -#define IDC_BTN_ADD_TO_CHEATS 1005 -#define IDC_MEMVIEWFIND_NEXT 1005 -#define IDC_NTVIEW_MIRROR_SS_TABLE_1 1005 -#define IDC_NTVIEW_MIRROR_SS_TABLE_2 1006 -#define MW_ADDR02 1007 -#define IDC_NTVIEW_MIRROR_SS_TABLE_3 1007 -#define IDC_NTVIEW_SHOW_SCROLL_LINES 1008 -#define MW_ADDR03 1010 -#define MW_ADDR04 1013 -#define MW_ADDR05 1016 -#define MW_ADDR06 1019 -#define MW_ADDR07 1022 -#define GUI_BOT_BOTMODE 1025 -#define MW_ADDR08 1025 -#define MW_ADDR09 1028 -#define MW_ADDR10 1031 -#define MW_ADDR11 1034 -#define MW_ADDR12 1037 -#define MW_ADDR13 1040 -#define MW_ADDR14 1043 -#define MW_ADDR15 1046 -#define MW_ADDR16 1049 -#define MW_ADDR17 1052 -#define MW_ADDR18 1055 -#define MW_ADDR19 1058 -#define MW_ADDR20 1061 -#define MW_ADDR21 1064 -#define MW_ADDR22 1067 -#define MW_ADDR23 1070 -#define GUI_BOT_PART_LAST 1090 -#define BTN_ALLOW_LRUD 1117 -#define BTN_PRESET_SET1 1119 -#define BTN_PRESET_SET2 1120 -#define BTN_PRESET_SET3 1121 -#define BTN_PRESET_IMPORT1 1122 -#define BTN_PRESET_IMPORT2 1123 -#define BTN_PRESET_IMPORT3 1124 -#define BTN_PRESET_EXPORT1 1125 -#define BTN_PRESET_EXPORT2 1126 -#define BTN_PRESET_EXPORT3 1127 -#define IDC_LIST1 1130 -#define IDC_HACKY2 1131 -#define IDC_HACKY1 1132 -#define IDC_BUTTON_METADATA 1132 -#define IDC_HACKYEXPORT 1133 -#define IDC_BUTTON1 1133 -#define MEMW_EXPANDCOLLAPSE 1133 -#define IDC_SOUND_RESTOREDEFAULTVOL 1133 -#define TASEDITOR_REWIND 1133 -#define IDC_BUTTON2 1134 -#define TASEDITOR_FORWARD 1134 -#define IDC_BUTTON3 1135 -#define TASEDITOR_REWIND_FULL 1135 -#define IDC_BUTTON4 1136 -#define TASEDITOR_FORWARD_FULL 1136 -#define TASEDITOR_PLAYSTOP 1137 -#define IDC_RADIO1 1138 -#define IDC_RADIO_UP 1138 -#define IDC_RADIO2 1139 -#define IDC_RADIO_ALL 1139 -#define IDC_RADIO3 1140 -#define IDC_RADIO_1P 1140 -#define IDC_RADIO4 1141 -#define IDC_RADIO_2P 1141 -#define MEMW_EDIT00FORMULA 1142 -#define IDC_RADIO5 1142 -#define IDC_RADIO_3P 1142 -#define MEMW_EDIT01FORMULA 1143 -#define IDC_RADIO6 1143 -#define IDC_RADIO_4P 1143 -#define IDC_PROGRESS_BUTTON 1144 -#define MEMW_EDIT02FORMULA 1144 -#define IDC_BUTTON7 1145 -#define MEMW_EDIT03FORMULA 1145 -#define TASEDITOR_PREV_MARKER 1145 -#define IDC_BUTTON8 1146 -#define TASEDITOR_FIND_BEST_SIMILAR_MARKER 1146 -#define IDC_EDIT1 1147 -#define IDC_SELECTION_MARKER_EDIT 1147 -#define IDC_NOTE_TO_FIND 1147 -#define IDC_AUTOSAVE_PERIOD 1147 -#define IDC_BUTTON9 1148 -#define TASEDITOR_FIND_NEXT_SIMILAR_MARKER 1148 -#define IDC_SYMBOLIC_ADDRESS 1148 -#define IDC_HISTORYLIST 1149 -#define IDC_SYMBOLIC_NAME 1149 -#define IDC_BOOKMARKSLIST 1150 -#define IDC_SYMBOLIC_FILENAME 1150 -#define TASEDITOR_NEXT_MARKER 1151 -#define IDC_SYMBOLIC_COMMENT 1151 -#define IDC_BRANCHES_BUTTON 1152 -#define IDC_JUMP_PLAYBACK_BUTTON 1153 -#define IDC_EDIT2 1154 -#define IDC_PLAYBACK_MARKER_EDIT 1154 -#define IDC_JUMP_SELECTION_BUTTON 1155 -#define TASEDITOR_RUN_MANUAL 1156 -#define CHECK_SOUND_MUTETURBO 1179 -#define IDC_EDIT_AUTHOR 1180 -#define MEMW_STATIC 1181 -#define MEMW_RESULTS 1184 -#define MEMW_EDIT00RESET 1184 -#define MEMW_EDIT01RESET 1185 -#define MEMW_EDIT02RESET 1186 -#define MEMW_EDIT03RESET 1187 -#define MEMW_EDIT00RMADDRESS 1188 -#define MEMW_EDIT01RMADDRESS 1189 -#define MEMW_EDIT02RMADDRESS 1190 -#define MEMW_EDIT03RMADDRESS 1191 -#define IDC_DEBUGGER_RESTORESIZE 1191 -#define MEMW_EDIT04RMADDRESS 1192 -#define IDC_MOVIE_CLOSE 1192 -#define EDIT00_RESULTS 1193 -#define IDC_MOVIE_PAUSEAFTERPLAYBACK 1193 -#define EDIT01_RESULTS 1194 -#define IDC_MOVIE_BINDSAVESTATES 1194 -#define EDIT02_RESULTS 1195 -#define IDC_MOVIE_DISPLAYSTATUSICON 1195 -#define EDIT03_RESULTS 1196 -#define IDC_MOVIE_DISPLAYSUBTITLES 1196 -#define IDC_MOVIE_SUBTITLESINAVI 1197 -#define IDC_MOVIE_AUTOBACKUP 1198 -#define IDC_SOUNDS_RESTOREDEFAULTS 1199 -#define BTN_CANCELED 1200 -#define ID_SOUND_TRITOP 1201 -#define IDC_MOVIE_SUGGEST_READONLY 1201 -#define ID_SOUND_QUALITYNOTIFY 1202 -#define IDC_CHECK1 1203 -#define CB_ENABLECONTEXTMENU 1203 -#define DEBUGAUTOLOAD 1203 -#define IDC_CHEAT_PAUSEWHENACTIVE 1203 -#define IDC_FULLSAVESTATES 1203 -#define IDC_SUPERIMPOSE 1203 -#define IDC_CHECK_BINARY 1203 -#define IDC_NOTES_TO_SUBTITLES 1203 -#define IDC_MATCH_CASE 1203 -#define IDC_COPY_INPUT 1203 -#define IDC_AUTORESUMECDLOGGING 1203 -#define IDC_MASK_UNUSED_GRAPHICS 1203 -#define IDC_VOLUMEGROUP 1204 -#define IDC_OMITBLANK 1204 -#define IDC_CHECK3 1204 -#define IDC_CHECK_MARKERS 1204 -#define IDC_RECORDING 1204 -#define IDC_COPY_MARKERS 1204 -#define IDC_AUTORESUMECDLOGGING2 1204 -#define IDC_AUTOSAVECDL 1204 -#define IDC_INVERT_THE_MASK 1204 -#define IDC_RAMLIST 1205 -#define IDC_CHECK4 1205 -#define IDC_CHECK_BOOKMARKS 1205 -#define IDC_SUPERIMPOSE2 1205 -#define IDC_RUN_AUTO 1205 -#define IDC_AUTOLOADCDL 1205 -#define IDC_C_SEARCH 1206 -#define IDC_CHECK5 1206 -#define IDC_CHECK_GREENZONE 1206 -#define IDC_USEPATTERN 1206 -#define IDC_C_ADDCHEAT 1207 -#define IDC_CHECK6 1207 -#define IDC_CHECK_HISTORY 1207 -#define IDC_C_WATCH 1208 -#define IDC_CHECK7 1208 -#define IDC_CHECK_SELECTION 1208 -#define IDC_C_RESET 1209 -#define IDC_CHECK8 1209 -#define IDC_CHECK_PIANO_ROLL 1209 -#define IDC_C_ELIMINATE 1210 -#define IDC_LESSTHAN 1211 -#define IDC_MORETHAN 1212 -#define IDC_NOMORETHAN 1213 -#define IDC_NOLESSTHAN 1214 -#define IDC_EQUALTO 1215 -#define IDC_DIFFERENTFROM 1216 -#define IDC_DIFFERENTBY 1217 -#define IDC_MODULO 1218 -#define IDC_EDIT_DIFFBY 1219 -#define IDC_EDIT_MODBY 1220 -#define IDC_PREVIOUSVALUE 1221 -#define IDC_SPECIFICVALUE 1222 -#define IDC_SPECIFICADDRESS 1223 -#define IDC_NUMBEROFCHANGES 1224 -#define IDC_EDIT_COMPAREVALUE 1225 -#define IDC_EDIT_COMPAREADDRESS 1226 -#define IDC_EDIT_COMPARECHANGES 1227 -#define IDC_SIGNED 1228 -#define IDC_UNSIGNED 1229 -#define IDC_HEX 1230 -#define IDC_C_AUTOSEARCH 1231 -#define IDC_1_BYTE 1232 -#define IDC_2_BYTES 1233 -#define IDC_4_BYTES 1234 -#define IDC_MISALIGN 1235 -#define IDC_C_RESET_CHANGES 1236 -#define IDC_C_UNDO 1237 -#define IDC_WATCHLIST 1238 -#define IDC_C_ELIMINATE2 1238 -#define IDC_C_HEXEDITOR 1238 -#define IDC_C_WATCH_EDIT 1239 -#define IDC_C_WATCH_REMOVE 1240 -#define IDC_C_WATCH_DUPLICATE 1241 -#define ID_WATCHES_UPDOWN 1242 -#define IDC_C_WATCH_UP 1243 -#define IDC_C_WATCH_DUPLICATE2 1243 -#define IDC_C_WATCH_Separator 1243 -#define IDC_C_WATCH_DOWN 1244 -#define IDC_PROMPT_TEXT 1245 -#define IDC_PROMPT_TEXT2 1246 -#define IDC_PROMPT_EDIT 1247 -#define IDC_BUTTON_LUABROWSE 1248 -#define IDC_BUTTON_LUARUN 1249 -#define IDC_BUTTON_LUASTOP 1250 -#define IDC_EDIT_LUAPATH 1251 -#define IDC_LUACONSOLE 1252 -#define IDC_BUTTON_LUAEDIT 1253 -#define IDC_LUACONSOLE_CLEAR 1254 -#define IDC_LUACONSOLE_CHOOSEFONT 1255 -#define IDC_EDIT_LUAARGS 1256 -#define CB_PARTIALVISUALTHEME 1257 -#define DEBUGLOADDEB 1258 -#define IDC_C_SEARCHROM 1258 -#define IDC_SINGLEINSTANCE 1258 -#define IDC_MOVIE_CLOSEAFTERPLAYBACK 1258 -#define IDC_C_WATCH_SEPARATE 1259 -#define IDC_TWEAKCOUNT 1260 -#define CHECK_AUTORESTORE_PLAYBACK 1261 -#define CB_FS_BY_DOUBLECLICK 1261 -#define IDC_PROGRESS1 1262 -#define CHECK_FOLLOW_CURSOR 1263 -#define IDC_BOOKMARKS_BOX 1264 -#define IDC_BRANCHES_BITMAP 1265 -#define IDC_SCREENSHOT_BITMAP 1266 -#define CHECK_TURBO_SEEK 1266 -#define IDC_TEXT_SELECTION 1267 -#define IDC_TEXT_CLIPBOARD 1268 -#define IDC_RADIO_1PLAYER 1269 -#define IDC_TEXT_SELECTION2 1269 -#define CHECK_AUTOADJUSTINPUTDUETOLAG 1269 -#define IDC_RADIO_2PLAYERS 1270 -#define IDC_PLAYBACK_MARKER 1270 -#define IDC_RADIO_FOURSCORE 1271 -#define IDC_SELECTION_MARKER 1271 -#define IDC_NOTE_TOOLTIP_EDIT 1272 -#define IDC_SELECTION_MARKER2 1272 -#define IDC_RADIO_DOWN 1273 -#define IDC_PLAYBACK_BOX 1275 -#define IDC_RECORDER_BOX 1276 -#define IDC_SPLICER_BOX 1277 -#define IDC_LUA_BOX 1278 -#define IDC_HISTORY_BOX 1279 -#define IDC_TASEDITOR_NAME 1280 -#define ID_CANCEL 1281 -#define IDC_AUTOSAVE_PROJECT 1282 -#define IDC_SILENT_AUTOSAVE 1283 -#define ID_CHR1 1283 -#define ID_CHR2 1284 -#define ID_CHR3 1285 -#define ID_STATIC 1286 -#define ID_CDL_OPTIONS 1287 -#define ID_CDL_GENERATEROM 1288 -#define MENU_NETWORK 40040 -#define MENU_PALETTE 40041 -#define MENU_SOUND 40042 -#define MENU_TIMING 40043 -#define MENU_VIDEO 40044 -#define MENU_HOTKEYS 40045 -#define MENU_ABOUT 40046 -#define MENU_MSGLOG 40047 -#define MENU_CHEATS 40048 -#define MENU_BASIC_BOT 40049 -#define MENU_AUTOFIRE_PATTERN_1 40050 -#define MENU_AUTOFIRE_PATTERN_2 40051 -#define MENU_AUTOFIRE_PATTERN_3 40052 -#define ID_DEBUG_DEBUGGER 40053 -#define MENU_AUTOFIRE_PATTERN_4 40053 -#define ID_DEBUG_PPUVIEWER 40054 -#define MENU_AUTOFIRE_PATTERN_5 40054 -#define ID_DEBUG_NAMETABLEVIEWER 40055 -#define MENU_AUTOFIRE_PATTERN_6 40055 -#define ID_DEBUG_HEXEDITOR 40056 -#define MENU_AUTOFIRE_PATTERN_7 40056 -#define ID_DEBUG_TRACELOGGER 40057 -#define MENU_AUTOFIRE_PATTERN_8 40057 -#define MENU_AUTOFIRE_PATTERN_9 40058 -#define ID_DEBUG_GAMEGENIEDECODER 40059 -#define MENU_AUTOFIRE_PATTERN_10 40059 -#define ID_DEBUG_CDLOGGER 40060 -#define MENU_AUTOFIRE_PATTERN_11 40060 -#define MENU_AUTOFIRE_PATTERN_12 40061 -#define MENU_AUTOFIRE_PATTERN_13 40062 -#define MENU_AUTOFIRE_PATTERN_14 40063 -#define MENU_AUTOFIRE_PATTERN_15 40064 -#define MENU_AUTOFIRE_OFFSET_1 40065 -#define MENU_AUTOFIRE_OFFSET_2 40066 -#define MENU_AUTOFIRE_OFFSET_3 40067 -#define MENU_AUTOFIRE_OFFSET_4 40068 -#define MENU_AUTOFIRE_OFFSET_5 40069 -#define MENU_AUTOFIRE_OFFSET_6 40070 -#define MENU_ALTERNATE_AB 40071 -#define MENU_EXTERNAL_INPUT 40072 -#define MENU_PPUVIEWER 40074 -#define MENU_NAMETABLEVIEWER 40075 -#define MENU_HEXEDITOR 40076 -#define MENU_TRACELOGGER 40077 -#define MENU_CDLOGGER 40078 -#define MENU_GAMEGENIEDECODER 40079 -#define MENU_DEBUGGER 40080 -#define MENU_MEMORY_WATCH 40081 -#define MENU_RAMFILTER 40082 -#define MEMW_FILE_NEW 40103 -#define MEMW_FILE_OPEN 40104 -#define MEMW_FILE_SAVE 40105 -#define MEMW_FILE_SAVEAS 40106 -#define MEMW_FILE_RECENT 40107 -#define MEMW_FILE_CLOSE 40108 -#define MEMW_OPTIONS_LOADSTART 40109 -#define MEMW_HELP_WCOMMANDS 40113 -#define MEMW_OPTIONS_LOADLASTFILE 40114 -#define ID_FILE_RECENT 40117 -#define MENU_RECORD_WAV 40120 -#define MENU_STOP_WAV 40121 -#define MENU_TASEDIT 40124 -#define MENU_PAUSEAFTERPLAYBACK 40126 -#define ACCEL_CTRL_O 40130 -#define ACCEL_CTRL_E 40131 -#define ACCEL_CTRL_W 40132 -#define ACCEL_CTRL_S 40134 -#define ACCEL_CTRL_SHIFT_S 40135 -#define ACCEL_CTRL_N 40136 -#define ACCEL_CTRL_C 40138 -#define MENU_HELP 40140 -#define ID_FILE_OOADFM2 40141 -#define ID_FILE_OPENFM2 40142 -#define ID_FILE_SAVEFM2 40143 -#define ID_TWEAKS_DISPLAYBG 40144 -#define ID_TWEAKS_DISPLAYOBJ 40145 -#define ID_ 40146 -#define MENU_DISPLAY_BG 40147 -#define MENU_DISPLAY_OBJ 40148 -#define ID_FILE_CONVERTMOVIE 40149 -#define MENU_CONVERT_MOVIE 40150 -#define ID_STRAY_INSERTFRAMES 40151 -#define MENU_INSERTFRAMES 40152 -#define ID_SELECTED_INSERTFRAME 40153 -#define ID_SELECTED_DELETEFRAME 40154 -#define MENU_DELETEFRAME 40155 -#define MENU_DELETEFRAMES 40156 -#define MENU_STRAY_INSERTFRAMES 40157 -#define ID_TOOLS_TEXTHOOKER 40158 -#define ID_Menu 40159 -#define ID_STRAY_TRUNCATE 40160 -#define ID_SELECTED_BRANCH 40161 -#define ID_SELECTED_INSERTMARKER 40162 -#define ID_SELECTED_CREATEMACRO 40163 -#define ID_EDIT 40164 -#define ID_EDIT_COPY40165 40165 -#define ID_EDIT_PASTE40166 40166 -#define ID_EDIT_CUT40167 40167 -#define ID_EDIT_COPYTONEW 40168 -#define ID_EDIT_DELETE 40169 -#define ID_HELP_TASEDITHELP 40170 -#define ID_FILE_NEWPROJECTCTRL 40171 -#define ID_FILE_SAVEPROJECT 40172 -#define ID_FILE_SAVEAS 40173 -#define ID_FILE_CLOSECTRL 40174 -#define ID_Menu40175 40175 -#define ID_Menu40176 40176 -#define ID_EDIT_TRUNCATE 40177 -#define ID_FILE_IMPORT 40178 -#define ID_FILE_NEWPROJECT 40179 -#define ID_FILE_OPEN_PROJECT 40180 -#define ID_FILE_OPENPROJECT 40181 -#define ID_FILE_SAVEPROJECTAS 40182 -#define ID_FILE_EXPORTFM2 40183 -#define ACCEL_CTRL_X 40184 -#define ACCEL_CTRL_V 40195 -#define ACCEL_CTRL_SHIFT_V 40196 -#define ACCEL_CTRL_DELETE 40197 -#define ID_ACCEL_CTRL_T 40198 -#define ACCEL_CTRL_T 40198 -#define ACCEL_CTRL_B 40199 -#define ID_CONTEXT_SELECTED_TRUNCATE 40200 -#define ID_CONTEXT_STRAY_TRUNCATE 40201 -#define ID_VIEW 40202 -#define MENU_CONTEXT_STRAY_INSERTFRAMES 40203 -#define ID_CONTEXT_SELECTED_INSERTFRAMES 40204 -#define ID_CONTEXT_SELECTED_DELETEFRAMES 40205 -#define ID_SELECTED_REMOVEMARKER 40206 -#define ID_CONTEXT_SELECTED_PASTETONEW 40207 -#define ID_CONTEXT_SELECTED_BRANCH 40210 -#define ID_EDIT_BRANCHCTRL 40211 -#define ID_EDIT_BRANCH 40212 -#define ID_EDIT_SELECTALL 40214 -#define ID_EDIT_REMOVEMARKER 40215 -#define ID_FILE_CLOSECTRL40216 40216 -#define ID_MEMWVIEW_FILE_CLOSE 40217 -#define ID_FILE_CLOSE40218 40218 -#define MENU_MV_FILE_GOTO_ADDRESS 40219 -#define MENU_BASIC_BOT2 40220 -#define ID_FILE_OPENLUAWINDOW 40229 -#define ID_FILE_CLOSELUAWINDOWS 40230 -#define ID_CONFIG_DISPLAY 40231 -#define ID_DISPLAY_INPUTDISPLAY 40232 -#define ID_DISPLAY_LAGCOUNTER 40233 -#define FCUE_DISPLAY_INPUTDISPLAY 40234 -#define FCEU_DISPLAY_LAGCOUNTER 40235 -#define MENU_DISPLAY_INPUTDISPLAY 40236 -#define MENU_DISPLAY_LAGCOUNTER 40237 -#define ID_DISPLAY_FRAMEADV 40238 -#define MENU_DISPLAY_FA_LAGSKIP 40239 -#define ID_DISPLAY_INPUTDISPLAY40240 40240 -#define ID_LAGCOUNTER_OFF 40241 -#define ID_LAGCOUNTER_1PLAYER 40242 -#define ID_LAGCOUNTER_2PLAYER 40243 -#define ID_LAGCOUNTER_4PLAYER 40244 -#define ID_DISPLAY_LAGCOUNTER40245 40245 -#define MENU_INPUTDISPLAY_OFF 40246 -#define MENU_INPUTDISPLAY_1P 40247 -#define MENU_INPUTDISPLAY_2P 40248 -#define MENU_INPUTDISPLAY_4P 40249 -#define MENU_INPUTDISPLAY_0 40250 -#define MENU_INPUTDISPLAY_1 40251 -#define MENU_INPUTDISPLAY_2 40252 -#define MENU_INPUTDISPLAY_4 40253 -#define ID_DISPLAY_FRAMECOUNTER 40254 -#define ID_CONFIG_BINDSAVESTATESTOMOVIE 40255 -#define MENU_CONFIG_BINDSAVES 40256 -#define MEMVIEW_HELP 40257 -#define MENU_MV_HELP 40258 -#define ID_DISPLAY_MOVESUBTITLES 40259 -#define ID_DISPLAY_MOVIESUBTITLES 40260 -#define ID_DISPLAY_MOVIESUBTITLESINAVI 40261 -#define ID_DISPLAY_MOVIESUBTITLES_AVI 40262 -#define ID_NES_PAUSE 40263 -#define ID_NES_FRAMEADVANCE 40264 -#define ID_NES_SPEEDUP 40265 -#define ID_NES_SLOWDOWN 40266 -#define ID_NES_FASTESTSPEED 40267 -#define ID_NES_NORMALSPEED 40268 -#define ID_NES_TURBO 40269 -#define ID_NES_SLOWESTSPEED 40270 -#define ID_NES_EMULATIONSPEED 40271 -#define ID_FILE_SCREENSHOT 40272 -#define ID_FILE_RESTARTMOVIE 40273 -#define ID_FILE_PLAYMOVIEFROMBEGINNING 40274 -#define ID_GAME_INSERTSUBTITLE 40275 -#define ID_GAME_INSERTCOMMENT 40276 -#define ID_GAME_HELP 40277 -#define ID_GAME_REPLAYMOVIE 40278 -#define ID_GAME_HELP40279 40279 -#define FCEU_CONTEXT_INSERTSUBTITLE 40280 -#define FCEU_CONTEXT_MOVIEHELP 40281 -#define FCEUX_CONTEXT_REPLAYMOVIE 40282 -#define FCEU_CONTEXT_ROMHELP 40283 -#define ID_NOGAME_OPENROM 40284 -#define ID_NOGAME_HELP 40285 -#define FCEU_CONTEXT_OPENROM 40286 -#define FCEU_CONTEXT_FCEUHELP 40287 -#define FCEU_CONTEXT_INSERTCOMMENT 40288 -#define ID_FILE_MOVIE 40289 -#define ID_FILE_RECORDAVI 40290 -#define ID_FILE_LUA 40291 -#define ID_NES_EMULATION 40292 -#define ID_GAME_PLAYMOVIEFROMBEGINNING 40293 -#define ID_GAME_STOPMOVIE 40294 -#define FCEU_CONTEXT_PLAYMOVIEFROMBEGINNING 40295 -#define FCEU_CONTEXT_STOPMOVIE 40296 -#define ID_GAME_CLOSEROM 40297 -#define FCEU_CONTEXT_CLOSEROM 40298 -#define ID_GAME_PLAYMOVIEFROMBEGINNING40299 40299 -#define ID_GAME_STOPMOVIERECORDING 40300 -#define ID_GAME_HELP40301 40301 -#define ID_GAME_RECORDMOVIE 40302 -#define FCEUX_CONTEXT_RECORDMOVIE 40303 -#define ID_GAME_SCREENSHOT 40304 -#define FCEUX_CONTEXT_SCREENSHOT 40305 -#define ID_GAME_REWINDTOLASTAUTO 40306 -#define FCEUX_CONTEXT_REWINDTOLASTAUTO 40307 -#define ID_GAME_REWINDTOLASTAUTO40308 40308 -#define ID_GAME_REWINDTOLASTAUTO40309 40309 -#define ID_GAME_VIEWCOMMENTSSUBTITLES 40310 -#define FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES 40311 -#define ID_GAME_VIEWCOMMENTSSUBTITLES40312 40312 -#define ID_OPTIONS_COLLAPSETO1COLUMN 40313 -#define MEMW_OPTIONS_EXPANDCOLLAPSE 40314 -#define ID_GAME_UNDOLOADSTATE 40315 -#define FCEUX_CONTEXT_UNDOLOADSTATE 40316 -#define ID_GAME_UNDOLOADSTATE40317 40317 -#define ID_GAME_UNDOLOADSTATE40318 40318 -#define ID_GAME_MAKEBACKUP 40319 -#define FCEUX_CONTEXT_MAKEBACKUP 40320 -#define ID_CONFIG_MOVIEOPTIONS 40321 -#define MENU_MOVIEOPTIONS 40322 -#define ID_GAME_UNDOSAVESTATE 40323 -#define FCEUX_CONTEXT_UNDOSAVESTATE 40324 -#define ID_GAME_UNDOSAVESTATE40325 40325 -#define ID_GAME_UNDOSAVESTATE40326 40326 -#define ID_NOGAME_OPENMOSTRECENTROM 40327 -#define FCEUX_CONTEXT_RECENTROM1 40328 -#define ID_NES_EMULATION40329 40329 -#define ID_MOVIE_TOGGLEREAD 40330 -#define ID_FILE_MOVIE_TOGGLEREAD 40331 -#define ID_LUA_RELOADLUASCRIPT 40332 -#define ID_FILE_LUA_RELOADLUASCRIPT 40333 -#define ID_GAME_SWITCHTOREAD 40334 -#define FCEUX_CONTEXT_READONLYTOGGLE 40335 -#define ID_GAME_TOGGLETOREAD 40336 -#define ID_FILE_SAVESTATE 40337 -#define ID_CONFIG_ENABLE 40338 -#define ID_SAVESTATE_QUICKSAVE 40339 -#define ID_SAVESTATE_QUICKLOAD 40340 -#define ID_SAVESTATE 40341 -#define ID_LOADSTATE 40342 -#define MENU_LOADSTATE 40343 -#define MENU_SAVESTATE 40344 -#define ID_SAVESTATE_NEXTSAVESLOT 40345 -#define ID_SAVESTATE_PREVIOUSSAVESLOT 40346 -#define MENU_NEXTSAVESTATE 40347 -#define MENU_PREVIOUSSAVESTATE 40348 -#define ID_SAVESTATE_VIEWSAVESLOTS 40349 -#define MENU_VIEWSAVESLOTS 40350 -#define ID_LUA_RECENT 40351 -#define MENU_LUA_RECENT 40352 -#define ID_Menu40353 40353 -#define MENU_MOVIE_RECENT 40354 -#define ID_GAME_LOADLASTMOVIE 40355 -#define FCEUX_CONTEXT_LOADLASTMOVIE 40356 -#define ID_GAME_SAVEMOVIEAS 40357 -#define FCEUX_CONTEXT_SAVEMOVIEAS 40358 -#define ID_OPTIONS_BINDTOMAINWINDOW 40361 -#define ID_CONFIG_PPU 40362 -#define ID_PPU_NEWPPU 40363 -#define ID_PPU_OLDPPU 40364 -#define ID_NEWPPU 40365 -#define ID_OLDPPU 40366 -#define ID_CONFIG_SAVECONFIGFILE 40367 -#define RAMMENU_FILE_AUTOLOAD 40368 -#define RAMMENU_FILE_SAVEWINDOW 40369 -#define RAMMENU_FILE_SAVE 40370 -#define RAMMENU_FILE_SAVEAS 40371 -#define RAMMENU_FILE_OPEN 40372 -#define RAMMENU_FILE_APPEND 40373 -#define RAMMENU_FILE_NEW 40374 -#define RAMMENU_FILE_RECENT 40375 -#define ID_RAM_SEARCH 40376 -#define ID_RAM_WATCH 40377 -#define RW_MENU_FIRST_RECENT_FILE 40380 -#define RW_MENU_LAST_RECENT_FILE 40400 -#define ID_ENABLE_BACKUPSAVESTATES 40401 -#define ID_ENABLE_COMPRESSSAVESTATES 40402 -#define ID_AVI_DISABLEMOV 40403 -#define ID_AVI_DISMOVIEMESS 40404 -#define ID_AVI_DISMOVIEMESSAGE 40405 -#define ID_INPUTDISPLAY_OLDSTYLEDISP 40406 -#define ID_GAME_RECOVERY 40407 -#define ID_SAVESTATE_RECOVERY 40408 -#define ID_CONTEXT_FULLSAVESTATES 40409 -#define ID_CHEATLISTPOPUP_DELETESELECTEDCHEATS 40410 -#define ID_FILE_SAVESCREENSHOTAS 40411 -#define ID_WATCHES_ADDSEPARATOR 40412 -#define ID_WATCHES_SEPARATOR 40413 -#define IDC_C_WATCHES_SEPARATOR 40414 -#define IDC_C_WATCH_SEPARATORS 40415 -#define IDC_C_WATCH_Separa 40416 -#define ID_GAME_USECONFIG 40417 -#define FCEUX_CONTEXT_GUICONFIG 40418 -#define ID_SELECTED_INSERTFRAMES 40422 -#define ID_CONTEXT_SELECTED_INSERTFRAME 40423 -#define ID_SELECTED_INSERTFRAMES40424 40424 -#define ID_CONTEXT_SELECTED_INSERTFRAMES2 40425 -#define ACCEL_CTRL_F 40429 -#define ACCEL_CTRL_P 40430 -#define ID_CONFIG_SETGREENZONECAPACITY 40432 -#define ACCEL_CTRL_INSERT 40433 -#define ID_DISPLAY_RERECORDCOUNTER 40436 -#define ID_DISPLAY_MOVIESTATUSICON 40437 -#define ID_AVI_DISPLAYHUD 40438 -#define ID_AVI_STOPWAV 40439 -#define ID_AVI_ENABLEHUDRECORDING 40440 -#define ID_VIEW_SHOWDOTINEMPTYCELLS 40441 -#define ACCEL_INS 40442 -#define ACCEL_DEL 40443 -#define ID_SELECTED_CLEARSELECTION 40445 -#define ID_CONTEXT_SELECTED_CLEARSELECTION 40446 -#define ID_CONTEXT_SELECTED_CLEARFRAMES 40447 -#define ID_VIEW_SHOW 40448 -#define ID_EDIT_CLEAR 40450 -#define ID_EDIT_INSERTFRAMES 40451 -#define ID_EDIT_INSERT 40452 -#define ID_EDIT_SELECTBETWEENMARKERS 40453 -#define ID_CONFIG_BINDMARKERSTOINPUT 40454 -#define ACCEL_CTRL_A 40455 -#define ID_EDIT_SELECTMIDMARKERS 40457 -#define ID_SELECTED_SELECTMIDMARKERS 40458 -#define ID_EDIT_CLONEFRAME 40459 -#define ID_EDIT_CLONEFRAMES 40460 -#define ACCEL_SHIFT_INS 40461 -#define ACCEL_CTRL_SHIFT_INS 40461 -#define ID_SELECTED_CLONE 40463 -#define ID_CONFIG_Q 40464 -#define ACCEL_CTRL_Z 40465 -#define ACCEL_CTRL_Y 40466 -#define ID_EDIT_UNDO 40468 -#define ID_EDIT_REDO 40469 -#define ID_CONFIG_SETMAXUNDOLEVELS 40470 -#define ID_VIEW_X 40471 -#define ID_VIEW_JUMPWHENMAKINGUNDO 40472 -#define ID_CONFIG_BRANCHESRESTOREFULLMOVIE 40473 -#define ID_CONFIG_OLDBRANCHINGCONTROLS 40474 -#define ID_CONFIG_HUDINBRANCHSCREENSHOTS 40475 -#define ID_CONFIG_SETAUTOSAVEPERIOD 40476 -#define ACCEL_CTRL_Q 40478 -#define ID_EDIT_SELECTIONUNDO 40481 -#define ID_EDIT_SELECTIONREDO 40482 -#define ID_EDIT_RESELECTCLIPBOARD 40483 -#define ID_FILE_SAVECOMPACT 40484 -#define ID_HELP_ABOUT 40485 -#define ID_VIEW_ENABLEHOTCHANGES 40488 -#define ID_VIEW_SHOWBRANCHSCREENSHOTS 40489 -#define ID_CONFIG_USE1PFORRECORDING2P 40490 -#define ID_CONFIG_USE1PFORRECORDING 40491 -#define ID_CONFIG_COMBINECONSECUTIVERECORDINGS 40492 -#define ACCEL_SHIFT_V 40493 -#define ID_EDIT_PASTEINSERT 40495 -#define ID_SELECTED_SETMARKER 40498 -#define ID_SELECTED_CLEARMARKER 40499 -#define ID_SELECTED_REMOVEMARKER40500 40500 -#define ID_CONFIG_KEYBOARDCONTROLSINPIANOROLL 40501 -#define ACCEL_CTRL_PGUP 40502 -#define ACCEL_CTRL_PGDN 40503 -#define ACCEL_SHIFT_PGUP 40504 -#define ACCEL_SHIFT_PGDN 40505 -#define ID_ACCELERATOR40506 40506 -#define ID_VIEW_FOLLOWMARKERNOTECONTEXT 40507 -#define ID_VIEW_SHOWBRANCHTOOLTIPS 40508 -#define ID_CONFIG_USEINPUTKEYSFORCOLUMNSET 40509 -#define ID_CONFIG_EMPTYNEWMARKERNOTES 40510 -#define ID_EDIT_FINDNOTE 40513 -#define ID_CONFIG_REAPPEARINGFINDNOTEDIALOG 40514 -#define ID_VIEW_FINDNOTE 40515 -#define ID_CONFIG_SILENTAUTOSAVE 40516 -#define ID_FILE_CLOSE 40517 -#define ID_EDIT_PASTE 40520 -#define ID_EDIT_COPY 40521 -#define ID_EDIT_CUT 40522 -#define ID_HELP_TASEDITORHELP 40523 -#define MENU_TASEDITOR 40524 -#define ID_FILE_NEW 40525 -#define ID_HELP_SHOWTOOLTIPS 40526 -#define ID_HELP_TOOLTIPS 40527 -#define ID_STRAY_UNPAUSEEMULATOR 40528 -#define ID_STRAY_UNPAUSE 40529 -#define ID_STRAY_TRUNCATE40530 40530 -#define ID_PATTERN 40531 -#define ID_PATTERN_TESTPATTERN 40532 -#define ID_PATTERN40533 40533 -#define ID_PATTERN_TEST 40534 -#define ID_CONFIG_COLUMNSETPATTERNSKIPSLAG 40535 -#define ID_EDIT_DESELECT 40536 -#define ID_SELECTED_DESELECT 40537 -#define ID_CONFIG_DRAWINPUTBYDRAGGING 40539 -#define ID_CONFIG_DOUBLECLICKONFRAME 40540 -#define ACCEL_CTRL_UP 40541 -#define ACCEL_CTRL_DOWN 40542 -#define ACCEL_CTRL_LEFT 40543 -#define ACCEL_CTRL_RIGHT 40544 -#define ACCEL_HOME 40545 -#define ACCEL_END 40546 -#define ACCEL_PGUP 40547 -#define ACCEL_PGDN 40548 -#define ACCEL_CTRL_HOME 40550 -#define ACCEL_CTRL_END 40551 -#define ACCEL_SHIFT_HOME 40552 -#define ACCEL_SHIFT_END 40553 -#define ACCEL_SHIFT_UP 40554 -#define ACCEL_SHIFT_DOWN 40555 -#define ACCEL_SHIFT_LEFT 40556 -#define ACCEL_SHIFT_RIGHT 40557 -#define ID_CONFIG_AUTOPAUSEATTHEENDOFMOVIE 40559 -#define ID_SELECTED_SETMARKERS 40560 -#define ID_SELECTED_REMOVEMARKERS 40561 -#define ACCEL_CTRL_SPACEBAR 40563 -#define ACCEL_CTRL_SPACE 40563 -#define ID_HELP_OPEN_MANUAL 40564 -#define ID_DISPLAY_FPS 40565 -#define ID_CONFIG_AUTO 40566 -#define ID_CONFIG_ADJUSTLAG 40567 -#define ID_CONFIG_PATTERNSKIPSLAG 40568 -#define CLEAR_LOG 40569 -#define CLOSE_LOG 40570 -#define ID_SELECTED_UNGREENZONE 40571 -#define ID_SELECTED_F 40572 -#define ID_CONFIG_ENABLEGREENZONING 40573 -#define ID_EMULATIONSPEED_SETFRAMEADVANCEDELAY 40574 -#define ID_Menu40575 40575 -#define ID_EMULATIONSPEED_SETCUSTOMSPEEDFORFRAMEADVANCE 40576 -#define ID_EMULATIONSPEED_CUSTOMSPEED 40577 -#define ID_ENABLE_AUTO 40578 -#define ID_ENABLE_AUTORESUME 40579 -#define ID_CONFIG_COMPACTQUICKSAVING 40580 -#define ID_CONFIG_SAVING_OPTIONS 40581 -#define ID_CDLFILENAME 40582 -#define ID_VIEW_A 40583 -#define ID_VIEW_HIGHLIGHT 40584 -#define ID_VIEW_HIGHLIGHT_ACTIVITY 40585 -#define ID_HIGHLIGHTING_FADEWHENPAUSED 40586 -#define ID_HIGHLIGHTING_SETFADINGPERIOD 40587 -#define ID_HIGHLIGHTING_HIGHLIGHT_ACTIVITY 40588 -#define IDC_DEBUGGER_ICONTRAY 55535 -#define MW_ValueLabel2 65423 -#define MW_ValueLabel1 65426 -#define IDC_STATIC_SLASHTEXT 65442 -#define IDC_BOOKMARK_NAME_TEXT 65535 -#define ID_CDL 65535 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 291 -#define _APS_NEXT_COMMAND_VALUE 40589 -#define _APS_NEXT_CONTROL_VALUE 1290 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/branches/fceux-2.2.2/src/drivers/win/sound.cpp b/branches/fceux-2.2.2/src/drivers/win/sound.cpp deleted file mode 100644 index cc4abcb8..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/sound.cpp +++ /dev/null @@ -1,835 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel and zeromus -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -//todo - config synchronization guards -//todo - use correct framerate instead of 60 -//todo - find out why fast forwarding at 96khz causes buffering to glitch? - -#include -#include "common.h" -#include "main.h" - -extern bool turbo; //If turbo is running - -/// controls whether playback is muted -static bool mute = false; -/// indicates whether we've been coerced into outputting 8bit audio -static int bits; - -#undef min -#undef max -#include "oakra.h" - -OAKRA_Module_OutputDS *dsout; -bool muteTurbo = true; - -//prototypes -void UpdateSoundChannelQualityMode(HWND hwndDlg); //Updates the sound channel volume sliders, disables and renames them for low quality - -//manages a set of small buffers which together work as one large buffer capable of resizing itsself and -//shrinking when a larger buffer is no longer necessary -class BufferSet { -public: - - static const int BufferSize = 1024; - static const int BufferSizeBits = 10; - static const int BufferSizeBitmask = 1023; - - class Buffer { - public: - int decay, size, length; - Buffer(int size) { length = 0; this->size = size; data = OAKRA_Module::malloc(size); } - int getRemaining() { return size-length; } - void *data; - ~Buffer() { delete data; } - }; - - std::vector liveBuffers; - std::vector freeBuffers; - int length; - int offset; //offset of beginning of addressing into current buffer - int bufferCount; - - BufferSet() { - offset = length = bufferCount = 0; - } - - //causes the oldest free buffer to decay one unit. kills it if it gets too old - void decay(int threshold) { - if(freeBuffers.empty()) return; - if(freeBuffers[0]->decay++>=threshold) { - delete freeBuffers[0]; - freeBuffers.erase(freeBuffers.begin()); - } - } - - Buffer *getBuffer() { - //try to get a buffer from the free pool first - //if theres nothing in the free pool, get a new buffer - if(!freeBuffers.size()) return getNewBuffer(); - //otherwise, return the last thing in the free pool (most recently freed) - Buffer *ret = *--freeBuffers.end(); - freeBuffers.erase(--freeBuffers.end()); - return ret; - } - - //adds the buffer to the free list - void freeBuffer(Buffer *buf) { - freeBuffers.push_back(buf); - buf->decay = 0; - buf->length = 0; - } - - Buffer *getNewBuffer() { - bufferCount++; - return new Buffer(BufferSize); - } - - short getShortAtIndex(int addr) { - addr <<= 1; //shorts are 2bytes - int buffer = (addr+offset)>>BufferSizeBits; - int ofs = (addr+offset) & BufferSizeBitmask; - return *(short*)((char*)liveBuffers[buffer]->data+ofs); - } - - //dequeues the specified number of bytes - void dequeue(int length) { - offset += length; - while(offset >= BufferSize) { - Buffer *front = liveBuffers[0]; - freeBuffer(front); - liveBuffers.erase(liveBuffers.begin()); - offset -= BufferSize; - } - this->length -= length; - } - - //not being used now: - - //tries to lock the specified number of bytes for reading. - //not all the bytes you asked for will be locked (no more than one buffer-full) - //try again if you didnt get enough. - //returns the number of bytes locked. - //int lock(int length, void **ptr) { - // int remain = BufferSize-offset; - // *ptr = (char*)liveBuffers[0]->data + offset; - // if(lengthgetRemaining()); - memcpy((char*)end->data + end->length,(char*)data + done,available); - end->length += available; - todo -= available; - done += available; - - //we're going to need another buffer - if(todo != 0) - liveBuffers.push_back(getBuffer()); - } - - this->length += length; - } -}; - -class Player : public OAKRA_Module { -public: - - int cursor; - BufferSet buffers; - int scale; - - //not interpolating! someday it will! - int generate(int samples, void *buf) { - - int64 incr = 256; - int64 bufferSamples = buffers.length>>1; - - //if we're we're too far behind, playback faster - if(bufferSamples > soundrate*3/60) { - int64 behind = bufferSamples - soundrate/60; - incr = behind*256*60/soundrate/2; - //we multiply our playback rate by 1/2 the number of frames we're behind - } - if(incr<256) - { - //sanity check: should never be less than 256 - FCEU_printf("OHNO -- %d -- shouldnt be less than 256!\n", incr); - } - - incr = (incr*scale)>>8; //apply scaling factor - - //figure out how many dest samples we can generate at this rate without running out of source samples - int destSamplesCanGenerate = (bufferSamples<<8) / incr; - - int todo = std::min(destSamplesCanGenerate,samples); - short *sbuf = (short*)buf; - for(int i=0;i>8); - cursor += incr; - } - buffers.dequeue((cursor>>8)<<1); - cursor &= 255; - - //perhaps mute - if(mute) memset(sbuf,0,samples<<1); - else memset(sbuf+todo,0,(samples-todo)<<1); - - return samples; - } - - void receive(int bytes, void *buf) { - dsout->lock(); - buffers.enqueue(bytes,buf); - buffers.decay(60); - dsout->unlock(); - } - - void throttle() { - //wait for the buffer to be satisfactorily low before continuing - for(;;) { - dsout->lock(); - int remain = buffers.length>>1; - dsout->unlock(); - if(remainlock(); - this->scale = scale; - dsout->unlock(); - } - - Player() { - scale = 256; - cursor = 0; - } -}; - -//this class just converts the primary 16bit audio stream to 8bit -class Player8 : public OAKRA_Module { -public: - Player *player; - Player8(Player *player) { this->player = player; } - int generate(int samples, void *buf) { - int half = samples>>1; - //retrieve first half of 16bit samples - player->generate(half,buf); - //and convert to 8bit - unsigned char *dbuf = (unsigned char*)buf; - short *sbuf = (short*)buf; - for(int i=0;i>8)^0x80; - //now retrieve second half - int remain = samples-half; - short *halfbuf = (short*)alloca(remain<<1); - player->generate(remain,halfbuf); - dbuf += half; - for(int i=0;i>8)^0x80; - return samples; - } -}; - -static Player *player; -static Player8 *player8; - -static bool trashPending = false; - -void TrashSound() { - trashPending = true; -} - -void DoTrashSound() { - if(dsout) delete dsout; - if(player) delete player; - if(player8) delete player8; - dsout = 0; - player = 0; - player8 = 0; - trashPending = false; -} - - -void TrashSoundNow() { - DoTrashSound(); - //is this safe? -} - - - -bool CheckTrashSound() { - if(trashPending) - { - DoTrashSound(); - return true; - } - else return false; -} - -void win_Throttle() { - if(CheckTrashSound()) return; - if(player) - player->throttle(); -} - -static bool killsound; -void win_SoundInit(int bits) { - killsound = false; - dsout = new OAKRA_Module_OutputDS(); - if(soundoptions&SO_GFOCUS) - dsout->start(0); - else - dsout->start(hAppWnd); - - dsout->beginThread(); - OAKRA_Format fmt; - fmt.format = bits==8?OAKRA_U8:OAKRA_S16; - fmt.channels = 1; - fmt.rate = soundrate; - fmt.size = OAKRA_Module::calcSize(fmt); - OAKRA_Voice *voice = dsout->getVoice(fmt); - if(!voice) - { - killsound = true; - FCEUD_PrintError("Couldn't initialize sound buffers. Sound disabled"); - } - - player = new Player(); - player8 = new Player8(player); - - if(voice) - { - dsout->lock(); - if(bits == 8) voice->setSource(player8); - else voice->setSource(player); - dsout->unlock(); - } -} - - -int InitSound() { - bits = 8; - - if(!(soundoptions&SO_FORCE8BIT)) - { - //no modern system should have this problem, and we dont use primary buffer - /*if( (!(dscaps.dwFlags&DSCAPS_PRIMARY16BIT) && !(soundoptions&SO_SECONDARY)) || - (!(dscaps.dwFlags&DSCAPS_SECONDARY16BIT) && (soundoptions&SO_SECONDARY))) - FCEUD_PrintError("DirectSound: 16-bit sound is not supported. Forcing 8-bit sound.");*/ - - //if(dscaps.dwFlags&DSCAPS_SECONDARY16BIT) - bits = 16; - //else - // FCEUD_PrintError("DirectSound: 16-bit sound is not supported. Forcing 8-bit sound.") - } - - win_SoundInit(bits); - if(killsound) - TrashSound(); - - FCEUI_Sound(soundrate); - return 1; -} - - -void win_SoundSetScale(int scale) { - if(CheckTrashSound()) return; - if(player) - player->scale = scale; -} - -void win_SoundWriteData(int32 *buffer, int count) { - //mbg 8/30/07 - this used to be done here, but now its gtting called from somewhere else... - //FCEUI_AviSoundUpdate((void*)MBuffer, Count); - if(CheckTrashSound()) return; - void *tempbuf = alloca(2*count); - short *sbuf = (short *)tempbuf; - for(int i=0;ireceive(count*2,tempbuf); -} - - -//-------- -//GUI and control APIs - -static HWND uug=0; - -static void UpdateSD(HWND hwndDlg) -{ - int t; - - CheckDlgButton(hwndDlg,CHECK_SOUND_ENABLED,soundo?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg,CHECK_SOUND_8BIT,(soundoptions&SO_FORCE8BIT)?BST_CHECKED:BST_UNCHECKED); - // The option formerly flagged by SO_SECONDARY can no longer be disabled. - // CheckDlgButton(hwndDlg,123,(soundoptions&SO_SECONDARY)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg,CHECK_SOUND_GLOBAL_FOCUS,(soundoptions&SO_GFOCUS)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg,CHECK_SOUND_MUTEFA,(soundoptions&SO_MUTEFA)?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg,CHECK_SOUND_MUTETURBO,(muteTurbo)?BST_CHECKED:BST_UNCHECKED); - // The option formerly flagged by SO_OLDUP can no longer be enabled. - // CheckDlgButton(hwndDlg,131,(soundoptions&SO_OLDUP)?BST_CHECKED:BST_UNCHECKED); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_SETCURSEL,soundquality,(LPARAM)(LPSTR)0); - t=0; - if(soundrate==22050) t=1; - else if(soundrate==44100) t=2; - else if(soundrate==48000) t=3; - else if(soundrate==96000) t=4; - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_SETCURSEL,t,(LPARAM)(LPSTR)0); - - if (!soundo) - { - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTETURBO),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTEFA),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_8BIT),FALSE); - EnableWindow(GetDlgItem(hwndDlg,COMBO_SOUND_QUALITY),FALSE); - EnableWindow(GetDlgItem(hwndDlg,COMBO_SOUND_RATE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_LATENCY_TRACKBAR),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_PCM),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_SOUND_RESTOREDEFAULTVOL),FALSE); - EnableWindow(GetDlgItem(hwndDlg,124),FALSE); - //Slider group boxes - EnableWindow(GetDlgItem(hwndDlg,125),FALSE); - EnableWindow(GetDlgItem(hwndDlg,131),FALSE); - EnableWindow(GetDlgItem(hwndDlg,132),FALSE); - EnableWindow(GetDlgItem(hwndDlg,133),FALSE); - EnableWindow(GetDlgItem(hwndDlg,134),FALSE); - EnableWindow(GetDlgItem(hwndDlg,135),FALSE); - //Static text boxes in volume group box - EnableWindow(GetDlgItem(hwndDlg,ID_SOUND_QUALITYNOTIFY),FALSE); - EnableWindow(GetDlgItem(hwndDlg,ID_SOUND_TRITOP),FALSE); - //Volume group box - EnableWindow(GetDlgItem(hwndDlg,IDC_VOLUMEGROUP),FALSE); - //Buffer group box - EnableWindow(GetDlgItem(hwndDlg,127),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65459),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65456),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65458),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65457),FALSE); - //Misc. Output Format group - EnableWindow(GetDlgItem(hwndDlg,65455),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65461),FALSE); - EnableWindow(GetDlgItem(hwndDlg,65460),FALSE); - - } - else - { - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTETURBO),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTEFA),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_8BIT),TRUE); - EnableWindow(GetDlgItem(hwndDlg,COMBO_SOUND_QUALITY),TRUE); - EnableWindow(GetDlgItem(hwndDlg,COMBO_SOUND_RATE),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_LATENCY_TRACKBAR),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_PCM),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR),TRUE); - EnableWindow(GetDlgItem(hwndDlg,IDC_SOUND_RESTOREDEFAULTVOL),TRUE); - EnableWindow(GetDlgItem(hwndDlg,124),TRUE); - //Slider group boxes - EnableWindow(GetDlgItem(hwndDlg,125),TRUE); - EnableWindow(GetDlgItem(hwndDlg,131),TRUE); - EnableWindow(GetDlgItem(hwndDlg,132),TRUE); - EnableWindow(GetDlgItem(hwndDlg,133),TRUE); - EnableWindow(GetDlgItem(hwndDlg,134),TRUE); - EnableWindow(GetDlgItem(hwndDlg,135),TRUE); - //Static text boxes in volume group box - EnableWindow(GetDlgItem(hwndDlg,ID_SOUND_QUALITYNOTIFY),TRUE); - EnableWindow(GetDlgItem(hwndDlg,ID_SOUND_TRITOP),TRUE); - //Volume group box - EnableWindow(GetDlgItem(hwndDlg,IDC_VOLUMEGROUP),TRUE); - //Buffer group box - EnableWindow(GetDlgItem(hwndDlg,127),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65459),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65456),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65458),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65457),TRUE); - //Misc. Output Format group - EnableWindow(GetDlgItem(hwndDlg,65455),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65461),TRUE); - EnableWindow(GetDlgItem(hwndDlg,65460),TRUE); - - } - - UpdateSoundChannelQualityMode(hwndDlg); -} - -BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - - switch(uMsg) { -case WM_NCRBUTTONDOWN: -case WM_NCMBUTTONDOWN: -case WM_NCLBUTTONDOWN:break; - -case WM_INITDIALOG: - //Volume Trackbars-------------------------------------------------------------- - //Master - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_SETRANGE,1,MAKELONG(0,150)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_SETTICFREQ,25,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_SETPOS,1,150-soundvolume); - //Triangle - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_SETRANGE,1,MAKELONG(0,256)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_SETTICFREQ,32,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_SETPOS,1,256-soundTrianglevol); - //Square1 - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_SETRANGE,1,MAKELONG(0,256)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_SETTICFREQ,32,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_SETPOS,1,256-soundSquare1vol); - - //Square2 - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_SETRANGE,1,MAKELONG(0,256)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_SETTICFREQ,32,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_SETPOS,1,256-soundSquare2vol); - - //Noise - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_SETRANGE,1,MAKELONG(0,256)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_SETTICFREQ,32,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_SETPOS,1,256-soundNoisevol); - - //PCM - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_SETRANGE,1,MAKELONG(0,256)); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_SETTICFREQ,32,0); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_SETPOS,1,256-soundPCMvol); - - /* buffer size time trackbar */ - SendDlgItemMessage(hwndDlg,CTL_LATENCY_TRACKBAR,TBM_SETRANGE,1,MAKELONG(15,200)); - SendDlgItemMessage(hwndDlg,CTL_LATENCY_TRACKBAR,TBM_SETTICFREQ,1,0); - SendDlgItemMessage(hwndDlg,CTL_LATENCY_TRACKBAR,TBM_SETPOS,1,soundbuftime); - - { - char tbuf[8]; - sprintf(tbuf,"%d",soundbuftime); - SetDlgItemText(hwndDlg,666,(LPTSTR)tbuf); - } - - SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Low"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_ADDSTRING,0,(LPARAM)(LPSTR)"High"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Highest"); - - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_ADDSTRING,0,(LPARAM)(LPSTR)"11025"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_ADDSTRING,0,(LPARAM)(LPSTR)"22050"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_ADDSTRING,0,(LPARAM)(LPSTR)"44100"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_ADDSTRING,0,(LPARAM)(LPSTR)"48000"); - SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_ADDSTRING,0,(LPARAM)(LPSTR)"96000"); - - UpdateSD(hwndDlg); - break; -case WM_VSCROLL: - { - if (LOWORD(wParam) == SB_ENDSCROLL) - return true; - int i = CTL_VOLUME_TRACKBAR; - while (GetDlgItem(hwndDlg,i) != (HWND) lParam) - i++; - switch (i) - { - case CTL_VOLUME_TRACKBAR: - soundvolume=150-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_GETPOS,0,0); - FCEUI_SetSoundVolume(soundvolume); - break; - case CTL_VOLUME_TRACKBAR_TRIANGLE: - soundTrianglevol=256-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_GETPOS,0,0); - FCEUI_SetTriangleVolume(soundTrianglevol); - break; - case CTL_VOLUME_TRACKBAR_SQUARE1: - soundSquare1vol=256-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_GETPOS,0,0); - FCEUI_SetSquare1Volume(soundSquare1vol); - break; - case CTL_VOLUME_TRACKBAR_SQUARE2: - soundSquare2vol=256-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_GETPOS,0,0); - FCEUI_SetSquare2Volume(soundSquare2vol); - break; - case CTL_VOLUME_TRACKBAR_NOISE: - soundNoisevol=256-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_GETPOS,0,0); - FCEUI_SetNoiseVolume(soundNoisevol); - break; - case CTL_VOLUME_TRACKBAR_PCM: - soundPCMvol=256-SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_GETPOS,0,0); - FCEUI_SetPCMVolume(soundPCMvol); - break; - default: - break; - } - return true; - } -case WM_HSCROLL: - { - char tbuf[8]; - soundbuftime=SendDlgItemMessage(hwndDlg,CTL_LATENCY_TRACKBAR,TBM_GETPOS,0,0); - sprintf(tbuf,"%d",soundbuftime); - SetDlgItemText(hwndDlg,666,(LPTSTR)tbuf); - //soundbufsize=(soundbuftime*soundrate/1000); - } - break; -case WM_CLOSE: -case WM_QUIT: goto gornk; -case WM_COMMAND: - switch(HIWORD(wParam)) - { - case CBN_SELENDOK: - switch(LOWORD(wParam)) - { - case COMBO_SOUND_RATE: - { - int tmp; - tmp=SendDlgItemMessage(hwndDlg,COMBO_SOUND_RATE,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - if(tmp==0) tmp=11025; - else if(tmp==1) tmp=22050; - else if(tmp==2) tmp=44100; - else if(tmp==3) tmp=48000; - else tmp=96000; - if(tmp!=soundrate) - { - soundrate=tmp; - if(soundrate<44100) - { - soundquality=0; - if (!turbo) FCEUI_SetSoundQuality(0); ///If turbo is running, don't do this call, turbo will handle it instead - UpdateSD(hwndDlg); - } - if(soundo) - { - TrashSoundNow(); - soundo=InitSound(); - UpdateSD(hwndDlg); - } - } - } - break; - - case COMBO_SOUND_QUALITY: - soundquality=SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - if(soundrate<44100) soundquality=0; - if (!turbo) FCEUI_SetSoundQuality(soundquality); //If turbo is running, don't do this call, turbo will handle it instead - UpdateSD(hwndDlg); - break; - } - break; - - case BN_CLICKED: - switch(LOWORD(wParam)) - { - case CHECK_SOUND_8BIT:soundoptions^=SO_FORCE8BIT; - if(soundo) - { - TrashSoundNow(); - soundo=InitSound(); - UpdateSD(hwndDlg); - } - break; - // The option formerly flagged by SO_SECONDARY can no longer be disabled. -#if 0 - case 123:soundoptions^=SO_SECONDARY; - if(soundo) - { - TrashSoundNow(); - soundo=InitSound(); - UpdateSD(hwndDlg); - } - break; -#endif - case CHECK_SOUND_GLOBAL_FOCUS:soundoptions^=SO_GFOCUS; - if(soundo) - { - TrashSoundNow(); - soundo=InitSound(); - UpdateSD(hwndDlg); - } - break; - case CHECK_SOUND_MUTEFA:soundoptions^=SO_MUTEFA; - break; - // The option formerly flagged by SO_OLDUP can no longer be enabled. -#if 0 - case 131:soundoptions^=SO_OLDUP; - if(soundo) - { - TrashSoundNow(); - soundo=InitSound(); - UpdateSD(hwndDlg); - } - break; -#endif - case CHECK_SOUND_MUTETURBO: - muteTurbo ^= 1; - break; - case CHECK_SOUND_ENABLED:soundo=!soundo; - if(!soundo) TrashSound(); - else soundo=InitSound(); - UpdateSD(hwndDlg); - break; - case IDC_SOUND_RESTOREDEFAULTVOL: - //Restore default values - soundvolume = 150; - soundTrianglevol = 256; - soundSquare1vol = 256; - soundSquare2vol = 256; - soundNoisevol = 256; - soundPCMvol = 256; - //Update trackbars - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_SETPOS,1,150-soundvolume); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_SETPOS,1,256-soundTrianglevol); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_SETPOS,1,256-soundSquare1vol); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_SETPOS,1,256-soundSquare2vol); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_SETPOS,1,256-soundNoisevol); - SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_SETPOS,1,256-soundPCMvol); - - //Set sound volumes - FCEUI_SetSoundVolume(soundvolume); - FCEUI_SetTriangleVolume(soundTrianglevol); - FCEUI_SetSquare1Volume(soundSquare1vol); - FCEUI_SetSquare2Volume(soundSquare2vol); - FCEUI_SetNoiseVolume(soundNoisevol); - FCEUI_SetPCMVolume(soundPCMvol); - break; - } - } - - if(!(wParam>>16)) - switch(wParam&0xFFFF) - { - case BTN_CLOSE: -gornk: - DestroyWindow(hwndDlg); - uug=0; - break; - } - } - return 0; -} - -void UpdateSoundChannelQualityMode(HWND hwndDlg) -{ - //If high quality, enable all - //If low quality, we only have two sliders, sq1 and triangle, rename them and disable the others - - if (soundquality) //If high or highest - { - //Enable sliders & corresponding group boxes - if (soundo) - { - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE),TRUE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_PCM),TRUE); - //Enable group boxes - EnableWindow(GetDlgItem(hwndDlg,133),TRUE); - EnableWindow(GetDlgItem(hwndDlg,134),TRUE); - EnableWindow(GetDlgItem(hwndDlg,135),TRUE); - } - //Set text for group boxes - SetDlgItemText(hwndDlg, ID_SOUND_TRITOP, ""); //Hacky, a static text box above the group box so I have more text space - SetDlgItemText(hwndDlg, 131, "Triangle"); - SetDlgItemText(hwndDlg, 132, "Square 1"); - SetDlgItemText(hwndDlg, 133, "Square 2"); - SetDlgItemText(hwndDlg, 134, "Noise"); - SetDlgItemText(hwndDlg, 135, "PCM"); - //Set quality message off - SetDlgItemText(hwndDlg, ID_SOUND_QUALITYNOTIFY, ""); - } - else //If low - { - //Disable sliders - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,CTL_VOLUME_TRACKBAR_PCM),FALSE); - //Disable group boxes - EnableWindow(GetDlgItem(hwndDlg,133),FALSE); - EnableWindow(GetDlgItem(hwndDlg,134),FALSE); - EnableWindow(GetDlgItem(hwndDlg,135),FALSE); - //Set text for group boxes - //These disabled until there is some control for pcm & triangle in low quality setting - //SetDlgItemText(hwndDlg, ID_SOUND_TRITOP, "Triangle/"); //Hacky, a static text box above the group box so I have more text space - //SetDlgItemText(hwndDlg, 131, "noise/pcm"); - SetDlgItemText(hwndDlg, 131, "Noise"); - SetDlgItemText(hwndDlg, 132, "Square"); - SetDlgItemText(hwndDlg, 133, "Disabled"); //Set Square 2 to disabled - SetDlgItemText(hwndDlg, 134, "Disabled"); //Set Noise to disabled - SetDlgItemText(hwndDlg, 135, "Disabled"); //Set PCM to disabled - //Set quality message on - SetDlgItemText(hwndDlg, ID_SOUND_QUALITYNOTIFY, "(To enable these, use a higher quality setting)"); - } - - return; -} - - - -/// Shows the sounds configuration dialog. -void ConfigSound() -{ - if(!uug) - { - uug = CreateDialog(fceu_hInstance, "SOUNDCONFIG", 0, SoundConCallB); - } - else - { - SetFocus(uug); - } -} - -void FCEUD_SoundToggle(void) -{ - if(mute) - { - mute = false; - FCEU_DispMessage("Sound unmuted",0); - } - else - { - mute = true; - FCEU_DispMessage("Sound muted",0); - } -} - -void FCEUD_SoundVolumeAdjust(int n) -{ - switch(n) - { - case -1: soundvolume-=10; if(soundvolume<0) soundvolume=0; break; - case 0: soundvolume=100; break; - case 1: soundvolume+=10; if(soundvolume>150) soundvolume=150; break; - } - mute = false; - FCEUI_SetSoundVolume(soundvolume); - FCEU_DispMessage("Sound volume %d.",0, soundvolume); -} diff --git a/branches/fceux-2.2.2/src/drivers/win/taseditor.cpp b/branches/fceux-2.2.2/src/drivers/win/taseditor.cpp deleted file mode 100644 index 6104e3af..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/taseditor.cpp +++ /dev/null @@ -1,1015 +0,0 @@ -/* --------------------------------------------------------------------------------- -Main TAS Editor file -Copyright (c) 2011-2013 AnS - -(The MIT License) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------- -Main - Main gate between emulator and Taseditor -[Single instance] - -* the point of launching TAS Editor from emulator -* the point of quitting from TAS Editor -* regularly (at the end of every frame) updates all modules that need regular update -* implements operations of the "File" menu: creating New project, opening a file, saving, compact saving, import, export -* handles some FCEUX hotkeys ------------------------------------------------------------------------------------- */ - -#include "taseditor/taseditor_project.h" -#include "utils/xstring.h" -#include "main.h" // for GetRomName -#include "taseditor.h" -#include "window.h" -#include "../../input.h" -#include "../keyboard.h" -#include "../joystick.h" - -using namespace std; - -// TAS Editor data -bool mustEngageTaseditor = false; -bool mustRewindNow = false; -bool mustCallManualLuaFunction = false; -bool taseditorEnableAcceleratorKeys = false; - -// all Taseditor functional modules -TASEDITOR_CONFIG taseditorConfig; -TASEDITOR_WINDOW taseditorWindow; -TASEDITOR_PROJECT project; -HISTORY history; -PLAYBACK playback; -RECORDER recorder; -GREENZONE greenzone; -MARKERS_MANAGER markersManager; -BOOKMARKS bookmarks; -BRANCHES branches; -POPUP_DISPLAY popupDisplay; -PIANO_ROLL pianoRoll; -TASEDITOR_LUA taseditor_lua; -SELECTION selection; -SPLICER splicer; -EDITOR editor; - -extern int joysticksPerFrame[INPUT_TYPES_TOTAL]; -extern bool turbo; -extern int pal_emulation; -extern int newppu; -extern void PushCurrentVideoSettings(); -extern void RefreshThrottleFPS(); -extern bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader); -// temporarily saved FCEUX config -int saved_eoptions; -int saved_EnableAutosave; -extern int EnableAutosave; -int saved_frame_display; -// FCEUX -extern EMOVIEMODE movieMode; // maybe we need normal setter for movieMode, to encapsulate it -// lua engine -extern void TaseditorAutoFunction(); -extern void TaseditorManualFunction(); - -// returns true if Taseditor is engaged at the end of the function -bool enterTASEditor() -{ - if (taseditorWindow.hwndTASEditor) - { - // TAS Editor is already engaged, just set focus to its window - if (!taseditorConfig.windowIsMaximized) - ShowWindow(taseditorWindow.hwndTASEditor, SW_SHOWNORMAL); - SetForegroundWindow(taseditorWindow.hwndTASEditor); - return true; - } else if (FCEU_IsValidUI(FCEUI_TASEDITOR)) - { - // start TAS Editor - // create window - taseditorWindow.init(); - if (taseditorWindow.hwndTASEditor) - { - enableGeneralKeyboardInput(); - // save "eoptions" - saved_eoptions = eoptions; - // set "Run in background" - eoptions |= EO_BGRUN; - // "Set high-priority thread" - eoptions |= EO_HIGHPRIO; - DoPriority(); - // switch off autosaves - saved_EnableAutosave = EnableAutosave; - EnableAutosave = 0; - // switch on frame_display - saved_frame_display = frame_display; - frame_display = 1; - UpdateCheckedMenuItems(); - - // init modules - editor.init(); - pianoRoll.init(); - selection.init(); - splicer.init(); - playback.init(); - greenzone.init(); - recorder.init(); - markersManager.init(); - project.init(); - bookmarks.init(); - branches.init(); - popupDisplay.init(); - history.init(); - taseditor_lua.init(); - // either start new movie or use current movie - if (!FCEUMOV_Mode(MOVIEMODE_RECORD|MOVIEMODE_PLAY) || currMovieData.savestate.size() != 0) - { - if (currMovieData.savestate.size() != 0) - FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate."); - // create new movie - FCEUI_StopMovie(); - movieMode = MOVIEMODE_TASEDITOR; - FCEUMOV_CreateCleanMovie(); - playback.restartPlaybackFromZeroGround(); - } else - { - // use current movie to create a new project - FCEUI_StopMovie(); - movieMode = MOVIEMODE_TASEDITOR; - } - // if movie length is less or equal to currFrame, pad it with empty frames - if (((int)currMovieData.records.size() - 1) < currFrameCounter) - currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1)); - // ensure that movie has correct set of ports/fourscore - setInputType(currMovieData, getInputType(currMovieData)); - // force the input configuration stored in the movie to apply to FCEUX config - applyMovieInputConfig(); - // reset some modules that need MovieData info - pianoRoll.reset(); - recorder.reset(); - // create initial snapshot in history - history.reset(); - // reset Taseditor variables - mustCallManualLuaFunction = false; - - SetFocus(history.hwndHistoryList); // set focus only once, to show blue selection cursor - SetFocus(pianoRoll.hwndList); - FCEU_DispMessage("TAS Editor engaged", 0); - taseditorWindow.redraw(); - return true; - } else - { - // couldn't init window - return false; - } - } else - { - // right now TAS Editor launch is not allowed by emulator - return true; - } -} - -bool exitTASEditor() -{ - if (!askToSaveProject()) return false; - - // destroy window - taseditorWindow.exit(); - disableGeneralKeyboardInput(); - // release memory - editor.free(); - pianoRoll.free(); - markersManager.free(); - greenzone.free(); - bookmarks.free(); - branches.free(); - popupDisplay.free(); - history.free(); - playback.stopSeeking(); - selection.free(); - - // restore "eoptions" - eoptions = saved_eoptions; - // restore autosaves - EnableAutosave = saved_EnableAutosave; - DoPriority(); - // restore frame_display - frame_display = saved_frame_display; - UpdateCheckedMenuItems(); - // switch off TAS Editor mode - movieMode = MOVIEMODE_INACTIVE; - FCEU_DispMessage("TAS Editor disengaged", 0); - FCEUMOV_CreateCleanMovie(); - return true; -} - -// everyframe function -void updateTASEditor() -{ - if (taseditorWindow.hwndTASEditor) - { - // TAS Editor is engaged - // update all modules that need to be updated every frame - // the order is somewhat important, e.g. Greenzone must update before Bookmark Set, Piano Roll must update before Selection - taseditorWindow.update(); - greenzone.update(); - recorder.update(); - pianoRoll.update(); - markersManager.update(); - playback.update(); - bookmarks.update(); - branches.update(); - popupDisplay.update(); - selection.update(); - splicer.update(); - history.update(); - project.update(); - // run Lua functions if needed - if (taseditorConfig.enableLuaAutoFunction) - TaseditorAutoFunction(); - if (mustCallManualLuaFunction) - { - TaseditorManualFunction(); - mustCallManualLuaFunction = false; - } - } else - { - // TAS Editor is not engaged - TaseditorAutoFunction(); // but we still should run Lua auto function - if (mustEngageTaseditor) - { - char fullname[1000]; - strcpy(fullname, curMovieFilename); - if (enterTASEditor()) - loadProject(fullname); - mustEngageTaseditor = false; - } - } -} - -BOOL CALLBACK newProjectProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - static struct NewProjectParameters* p = NULL; - switch (message) - { - case WM_INITDIALOG: - p = (struct NewProjectParameters*)lParam; - p->inputType = getInputType(currMovieData); - p->copyCurrentInput = p->copyCurrentMarkers = false; - if (strlen(taseditorConfig.lastAuthorName)) - { - // convert UTF8 char* string to Unicode wstring - wchar_t savedAuthorName[AUTHOR_NAME_MAX_LEN] = {0}; - MultiByteToWideChar(CP_UTF8, 0, taseditorConfig.lastAuthorName, -1, savedAuthorName, AUTHOR_NAME_MAX_LEN); - p->authorName = savedAuthorName; - } else - { - p->authorName = L""; - } - switch (p->inputType) - { - case INPUT_TYPE_1P: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_1PLAYER), BST_CHECKED); - break; - } - case INPUT_TYPE_2P: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_2PLAYERS), BST_CHECKED); - break; - } - case INPUT_TYPE_FOURSCORE: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_FOURSCORE), BST_CHECKED); - break; - } - } - SendMessage(GetDlgItem(hwndDlg, IDC_EDIT_AUTHOR), CCM_SETUNICODEFORMAT, TRUE, 0); - SetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPCWSTR)(p->authorName.c_str())); - return 0; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_RADIO_1PLAYER: - p->inputType = INPUT_TYPE_1P; - break; - case IDC_RADIO_2PLAYERS: - p->inputType = INPUT_TYPE_2P; - break; - case IDC_RADIO_FOURSCORE: - p->inputType = INPUT_TYPE_FOURSCORE; - break; - case IDC_COPY_INPUT: - p->copyCurrentInput ^= 1; - CheckDlgButton(hwndDlg, IDC_COPY_INPUT, p->copyCurrentInput?MF_CHECKED : MF_UNCHECKED); - break; - case IDC_COPY_MARKERS: - p->copyCurrentMarkers ^= 1; - CheckDlgButton(hwndDlg, IDC_COPY_MARKERS, p->copyCurrentMarkers?MF_CHECKED : MF_UNCHECKED); - break; - case IDOK: - { - // save author name in params and in taseditor_config (converted to multibyte char*) - wchar_t authorName[AUTHOR_NAME_MAX_LEN] = {0}; - GetDlgItemTextW(hwndDlg, IDC_EDIT_AUTHOR, (LPWSTR)authorName, AUTHOR_NAME_MAX_LEN); - p->authorName = authorName; - if (p->authorName == L"") - taseditorConfig.lastAuthorName[0] = 0; - else - // convert Unicode wstring to UTF8 char* string - WideCharToMultiByte(CP_UTF8, 0, (p->authorName).c_str(), -1, taseditorConfig.lastAuthorName, AUTHOR_NAME_MAX_LEN, 0, 0); - EndDialog(hwndDlg, 1); - return TRUE; - } - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - } - break; - } - return FALSE; -} - -void createNewProject() -{ - if (!askToSaveProject()) return; - - static struct NewProjectParameters params; - if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_NEWPROJECT), taseditorWindow.hwndTASEditor, newProjectProc, (LPARAM)¶ms) > 0) - { - FCEUMOV_CreateCleanMovie(); - // apply selected options - setInputType(currMovieData, params.inputType); - applyMovieInputConfig(); - if (params.copyCurrentInput) - // copy Input from current snapshot (from history) - history.getCurrentSnapshot().inputlog.toMovie(currMovieData); - if (!params.copyCurrentMarkers) - markersManager.reset(); - if (params.authorName != L"") currMovieData.comments.push_back(L"author " + params.authorName); - - // reset Taseditor - project.init(); // new project has blank name - greenzone.reset(); - if (params.copyCurrentInput) - // copy LagLog from current snapshot (from history) - greenzone.lagLog = history.getCurrentSnapshot().laglog; - playback.reset(); - playback.restartPlaybackFromZeroGround(); - bookmarks.reset(); - branches.reset(); - history.reset(); - pianoRoll.reset(); - selection.reset(); - editor.reset(); - splicer.reset(); - recorder.reset(); - popupDisplay.reset(); - taseditorWindow.redraw(); - taseditorWindow.updateCaption(); - } -} - -void openProject() -{ - if (!askToSaveProject()) return; - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = taseditorWindow.hwndTASEditor; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Open TAS Editor Project"; - const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFilter = filter; - - char nameo[2048]; - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames - - ofn.lpstrFile = nameo; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - ofn.lpstrInitialDir = initdir.c_str(); - - if (GetOpenFileName(&ofn)) // If it is a valid filename - { - loadProject(nameo); - } -} -bool loadProject(const char* fullname) -{ - // try to load project - if (project.load(fullname)) - { - // loaded successfully - applyMovieInputConfig(); - // add new file to Recent menu - taseditorWindow.updateRecentProjectsArray(fullname); - taseditorWindow.redraw(); - taseditorWindow.updateCaption(); - return true; - } else - { - // failed to load - taseditorWindow.redraw(); - taseditorWindow.updateCaption(); - return false; - } -} - -// Saves current project -bool saveProjectAs(bool save_compact) -{ - const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0"; - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = taseditorWindow.hwndTASEditor; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Save TAS Editor Project As..."; - ofn.lpstrFilter = filter; - - char nameo[2048]; - if (project.getProjectName().empty()) - { - // suggest ROM name for this project - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames - // add .fm3 extension - strncat(nameo, ".fm3", 2047); - } else - { - // suggest current name - strncpy(nameo, project.getProjectName().c_str(), 2047); - } - - ofn.lpstrFile = nameo; - ofn.lpstrDefExt = "fm3"; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory - ofn.lpstrInitialDir = initdir.c_str(); - - if (GetSaveFileName(&ofn)) // if it is a valid filename - { - project.renameProject(nameo, true); - if (save_compact) - project.save(nameo, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection); - else - project.save(nameo, taseditorConfig.projectSavingOptions_SaveInBinary, taseditorConfig.projectSavingOptions_SaveMarkers, taseditorConfig.projectSavingOptions_SaveBookmarks, taseditorConfig.projectSavingOptions_GreenzoneSavingMode, taseditorConfig.projectSavingOptions_SaveHistory, taseditorConfig.projectSavingOptions_SavePianoRoll, taseditorConfig.projectSavingOptions_SaveSelection); - taseditorWindow.updateRecentProjectsArray(nameo); - // saved successfully - remove * mark from caption - taseditorWindow.updateCaption(); - } else return false; - return true; -} -bool saveProject(bool save_compact) -{ - if (project.getProjectFile().empty()) - { - return saveProjectAs(save_compact); - } else - { - if (save_compact) - project.save(0, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection); - else - project.save(0, taseditorConfig.projectSavingOptions_SaveInBinary, taseditorConfig.projectSavingOptions_SaveMarkers, taseditorConfig.projectSavingOptions_SaveBookmarks, taseditorConfig.projectSavingOptions_GreenzoneSavingMode, taseditorConfig.projectSavingOptions_SaveHistory, taseditorConfig.projectSavingOptions_SavePianoRoll, taseditorConfig.projectSavingOptions_SaveSelection); - taseditorWindow.updateCaption(); - } - return true; -} -// -------------------------------------------------- -void SaveCompact_SetDialogItems(HWND hwndDlg) -{ - CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditorConfig.saveCompact_SaveInBinary?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditorConfig.saveCompact_SaveMarkers?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditorConfig.saveCompact_SaveBookmarks?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditorConfig.saveCompact_SaveHistory?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditorConfig.saveCompact_SavePianoRoll?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditorConfig.saveCompact_SaveSelection?BST_CHECKED : BST_UNCHECKED); - CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditorConfig.saveCompact_GreenzoneSavingMode % GREENZONE_SAVING_MODES_TOTAL)); -} -void SaveCompact_GetDialogItems(HWND hwndDlg) -{ - taseditorConfig.saveCompact_SaveInBinary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.saveCompact_SaveMarkers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.saveCompact_SaveBookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.saveCompact_SaveHistory = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.saveCompact_SavePianoRoll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.saveCompact_SaveSelection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED); - if (SendDlgItemMessage(hwndDlg, IDC_RADIO1, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_ALL; - else if (SendDlgItemMessage(hwndDlg, IDC_RADIO2, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_16TH; - else if (SendDlgItemMessage(hwndDlg, IDC_RADIO3, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_MARKED; - else - taseditorConfig.saveCompact_GreenzoneSavingMode = GREENZONE_SAVING_MODE_NO; -} -BOOL CALLBACK SaveCompactProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - SetWindowPos(hwndDlg, 0, taseditorConfig.windowX + 100, taseditorConfig.windowY + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); - SaveCompact_SetDialogItems(hwndDlg); - return TRUE; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - SaveCompact_GetDialogItems(hwndDlg); - EndDialog(hwndDlg, 1); - return TRUE; - case IDCANCEL: - SaveCompact_GetDialogItems(hwndDlg); - EndDialog(hwndDlg, 0); - return TRUE; - } - break; - } - case WM_CLOSE: - case WM_QUIT: - { - SaveCompact_GetDialogItems(hwndDlg); - break; - } - } - return FALSE; -} -void saveCompact() -{ - if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_SAVECOMPACT), taseditorWindow.hwndTASEditor, SaveCompactProc) > 0) - { - const char filter[] = "TAS Editor Projects (*.fm3)\0*.fm3\0All Files (*.*)\0*.*\0\0"; - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = taseditorWindow.hwndTASEditor; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Save Compact"; - ofn.lpstrFilter = filter; - - char nameo[2048]; - if (project.getProjectName().empty()) - // suggest ROM name for this project - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); //convert | to . for archive filenames - else - // suggest current name - strcpy(nameo, project.getProjectName().c_str()); - // add "-compact" if there's no such suffix - if (!strstr(nameo, "-compact")) - strcat(nameo, "-compact"); - - ofn.lpstrFile = nameo; - ofn.lpstrDefExt = "fm3"; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory - ofn.lpstrInitialDir = initdir.c_str(); - - if (GetSaveFileName(&ofn)) - { - project.save(nameo, taseditorConfig.saveCompact_SaveInBinary, taseditorConfig.saveCompact_SaveMarkers, taseditorConfig.saveCompact_SaveBookmarks, taseditorConfig.saveCompact_GreenzoneSavingMode, taseditorConfig.saveCompact_SaveHistory, taseditorConfig.saveCompact_SavePianoRoll, taseditorConfig.saveCompact_SaveSelection); - taseditorWindow.updateCaption(); - } - } -} -// -------------------------------------------------- -// returns false if user doesn't want to exit -bool askToSaveProject() -{ - bool changesFound = false; - if (project.getProjectChanged()) - changesFound = true; - - // ask saving project - if (changesFound) - { - int answer = MessageBox(taseditorWindow.hwndTASEditor, "Save Project changes?", "TAS Editor", MB_YESNOCANCEL); - if (answer == IDYES) - return saveProject(); - return (answer != IDCANCEL); - } - return true; -} - -void importInputData() -{ - const char filter[] = "FCEUX Movie Files (*.fm2), TAS Editor Projects (*.fm3)\0*.fm2;*.fm3\0All Files (*.*)\0*.*\0\0"; - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = taseditorWindow.hwndTASEditor; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Import"; - ofn.lpstrFilter = filter; - char nameo[2048] = {0}; - ofn.lpstrFile = nameo; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; - string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - ofn.lpstrInitialDir = initdir.c_str(); - - if (GetOpenFileName(&ofn)) - { - EMUFILE_FILE ifs(nameo, "rb"); - // Load Input to temporary moviedata - MovieData md; - if (LoadFM2(md, &ifs, ifs.size(), false)) - { - // loaded successfully, now register Input changes - char drv[512], dir[512], name[1024], ext[512]; - splitpath(nameo, drv, dir, name, ext); - strcat(name, ext); - int result = history.registerImport(md, name); - if (result >= 0) - { - greenzone.invalidateAndUpdatePlayback(result); - greenzone.lagLog.invalidateFromFrame(result); - // keep current snapshot laglog in touch - history.getCurrentSnapshot().laglog.invalidateFromFrame(result); - } else - { - MessageBox(taseditorWindow.hwndTASEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK); - } - } else - { - FCEUD_PrintError("Error loading movie data!"); - } - } -} - -BOOL CALLBACK aboutWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - SendMessage(GetDlgItem(hWnd, IDC_TASEDITOR_NAME), WM_SETFONT, (WPARAM)pianoRoll.hTaseditorAboutFont, 0); - break; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDCANCEL: - EndDialog(hWnd, 0); - return TRUE; - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK savingOptionsWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - CheckDlgButton(hwndDlg, IDC_AUTOSAVE_PROJECT, taseditorConfig.autosaveEnabled?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SILENT_AUTOSAVE, taseditorConfig.autosaveSilent?BST_CHECKED : BST_UNCHECKED); - char buf[16] = {0}; - sprintf(buf, "%u", taseditorConfig.autosavePeriod); - SetDlgItemText(hwndDlg, IDC_AUTOSAVE_PERIOD, buf); - CheckDlgButton(hwndDlg, IDC_CHECK_BINARY, taseditorConfig.projectSavingOptions_SaveInBinary?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_MARKERS, taseditorConfig.projectSavingOptions_SaveMarkers?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_BOOKMARKS, taseditorConfig.projectSavingOptions_SaveBookmarks?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_HISTORY, taseditorConfig.projectSavingOptions_SaveHistory?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_PIANO_ROLL, taseditorConfig.projectSavingOptions_SavePianoRoll?BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_SELECTION, taseditorConfig.projectSavingOptions_SaveSelection?BST_CHECKED : BST_UNCHECKED); - CheckRadioButton(hwndDlg, IDC_RADIO1, IDC_RADIO4, IDC_RADIO1 + (taseditorConfig.projectSavingOptions_GreenzoneSavingMode % GREENZONE_SAVING_MODES_TOTAL)); - return TRUE; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - { - taseditorConfig.autosaveEnabled = (SendDlgItemMessage(hwndDlg, IDC_AUTOSAVE_PROJECT, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.autosaveSilent = (SendDlgItemMessage(hwndDlg, IDC_SILENT_AUTOSAVE, BM_GETCHECK, 0, 0) == BST_CHECKED); - char buf[16] = {0}; - GetDlgItemText(hwndDlg, IDC_AUTOSAVE_PERIOD, buf, 16 * sizeof(char)); - int new_period = taseditorConfig.autosavePeriod; - sscanf(buf, "%u", &new_period); - if (new_period < AUTOSAVE_PERIOD_MIN) - new_period = AUTOSAVE_PERIOD_MIN; - else if (new_period > AUTOSAVE_PERIOD_MAX) - new_period = AUTOSAVE_PERIOD_MAX; - taseditorConfig.autosavePeriod = new_period; - project.sheduleNextAutosave(); - taseditorConfig.projectSavingOptions_SaveInBinary = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BINARY, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.projectSavingOptions_SaveMarkers = (SendDlgItemMessage(hwndDlg, IDC_CHECK_MARKERS, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.projectSavingOptions_SaveBookmarks = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BOOKMARKS, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.projectSavingOptions_SaveHistory = (SendDlgItemMessage(hwndDlg, IDC_CHECK_HISTORY, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.projectSavingOptions_SavePianoRoll = (SendDlgItemMessage(hwndDlg, IDC_CHECK_PIANO_ROLL, BM_GETCHECK, 0, 0) == BST_CHECKED); - taseditorConfig.projectSavingOptions_SaveSelection = (SendDlgItemMessage(hwndDlg, IDC_CHECK_SELECTION, BM_GETCHECK, 0, 0) == BST_CHECKED); - if (SendDlgItemMessage(hwndDlg, IDC_RADIO1, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_ALL; - else if (SendDlgItemMessage(hwndDlg, IDC_RADIO2, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_16TH; - else if (SendDlgItemMessage(hwndDlg, IDC_RADIO3, BM_GETCHECK, 0, 0) == BST_CHECKED) - taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_MARKED; - else - taseditorConfig.projectSavingOptions_GreenzoneSavingMode = GREENZONE_SAVING_MODE_NO; - EndDialog(hwndDlg, 1); - return TRUE; - } - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK ExportProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - SetWindowPos(hwndDlg, 0, taseditorConfig.windowX + 100, taseditorConfig.windowY + 200, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); - switch (taseditorConfig.lastExportedInputType) - { - case INPUT_TYPE_1P: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_1PLAYER), BST_CHECKED); - break; - } - case INPUT_TYPE_2P: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_2PLAYERS), BST_CHECKED); - break; - } - case INPUT_TYPE_FOURSCORE: - { - Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_FOURSCORE), BST_CHECKED); - break; - } - } - CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditorConfig.lastExportedSubtitlesStatus?MF_CHECKED : MF_UNCHECKED); - return TRUE; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_RADIO_1PLAYER: - taseditorConfig.lastExportedInputType = INPUT_TYPE_1P; - break; - case IDC_RADIO_2PLAYERS: - taseditorConfig.lastExportedInputType = INPUT_TYPE_2P; - break; - case IDC_RADIO_FOURSCORE: - taseditorConfig.lastExportedInputType = INPUT_TYPE_FOURSCORE; - break; - case IDC_NOTES_TO_SUBTITLES: - taseditorConfig.lastExportedSubtitlesStatus ^= 1; - CheckDlgButton(hwndDlg, IDC_NOTES_TO_SUBTITLES, taseditorConfig.lastExportedSubtitlesStatus?MF_CHECKED : MF_UNCHECKED); - break; - case IDOK: - EndDialog(hwndDlg, 1); - return TRUE; - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - } - break; - } - return FALSE; -} - -void exportToFM2() -{ - if (DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_EXPORT), taseditorWindow.hwndTASEditor, ExportProc) > 0) - { - const char filter[] = "FCEUX Movie File (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0"; - char fname[2048]; - strcpy(fname, project.getFM2Name().c_str()); - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = taseditorWindow.hwndTASEditor; - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Export to FM2"; - ofn.lpstrFilter = filter; - ofn.lpstrFile = fname; - ofn.lpstrDefExt = "fm2"; - ofn.nMaxFile = 2048; - ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; - std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - ofn.lpstrInitialDir = initdir.c_str(); - if (GetSaveFileName(&ofn)) - { - EMUFILE* osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); - // create copy of current movie data - MovieData temp_md = currMovieData; - // modify the copy according to selected type of export - setInputType(temp_md, taseditorConfig.lastExportedInputType); - temp_md.loadFrameCount = -1; - // also add subtitles if needed - if (taseditorConfig.lastExportedSubtitlesStatus) - { - // convert Marker Notes to Movie Subtitles - char framenum[11]; - std::string subtitle; - int markerID; - for (int i = 0; i < markersManager.getMarkersArraySize(); ++i) - { - markerID = markersManager.getMarkerAtFrame(i); - if (markerID) - { - _itoa(i, framenum, 10); - strcat(framenum, " "); - subtitle = framenum; - subtitle.append(markersManager.getNoteCopy(markerID)); - temp_md.subtitles.push_back(subtitle); - } - } - } - // dump to disk - temp_md.dump(osRecordingMovie, false); - delete osRecordingMovie; - osRecordingMovie = 0; - } - } -} - -int getInputType(MovieData& md) -{ - if (md.fourscore) - return INPUT_TYPE_FOURSCORE; - else if (md.ports[0] == md.ports[1] == SI_GAMEPAD) - return INPUT_TYPE_2P; - else - return INPUT_TYPE_1P; -} -void setInputType(MovieData& md, int newInputType) -{ - switch (newInputType) - { - case INPUT_TYPE_1P: - { - md.fourscore = false; - md.ports[0] = SI_GAMEPAD; - md.ports[1] = SI_NONE; - break; - } - case INPUT_TYPE_2P: - { - md.fourscore = false; - md.ports[0] = SI_GAMEPAD; - md.ports[1] = SI_GAMEPAD; - break; - } - case INPUT_TYPE_FOURSCORE: - { - md.fourscore = true; - md.ports[0] = SI_GAMEPAD; - md.ports[1] = SI_GAMEPAD; - break; - } - } -} - -void applyMovieInputConfig() -{ - // update FCEUX input config - FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]); - // update PAL flag - pal_emulation = currMovieData.palFlag; - FCEUI_SetVidSystem(pal_emulation); - RefreshThrottleFPS(); - PushCurrentVideoSettings(); - // update PPU type - newppu = currMovieData.PPUflag; - SetMainWindowText(); - // return focus to TAS Editor window - SetFocus(taseditorWindow.hwndTASEditor); -} - -// this getter contains formula to decide whether to record or replay movie -bool isTaseditorRecording() -{ - if (movie_readonly || playback.getPauseFrame() >= 0 || (taseditorConfig.oldControlSchemeForBranching && !recorder.stateWasLoadedInReadWriteMode)) - return false; // replay - return true; // record -} -void recordInputByTaseditor() -{ - recorder.recordInput(); -} - -// this gate handles some FCEUX hotkeys (EMUCMD) -void handleEmuCmdByTaseditor(int command) -{ - switch (command) - { - case EMUCMD_SAVE_SLOT_0: - case EMUCMD_SAVE_SLOT_1: - case EMUCMD_SAVE_SLOT_2: - case EMUCMD_SAVE_SLOT_3: - case EMUCMD_SAVE_SLOT_4: - case EMUCMD_SAVE_SLOT_5: - case EMUCMD_SAVE_SLOT_6: - case EMUCMD_SAVE_SLOT_7: - case EMUCMD_SAVE_SLOT_8: - case EMUCMD_SAVE_SLOT_9: - { - if (taseditorConfig.oldControlSchemeForBranching) - bookmarks.command(COMMAND_SELECT, command - EMUCMD_SAVE_SLOT_0); - else - bookmarks.command(COMMAND_JUMP, command - EMUCMD_SAVE_SLOT_0); - break; - } - case EMUCMD_SAVE_SLOT_NEXT: - { - int slot = bookmarks.getSelectedSlot() + 1; - if (slot >= TOTAL_BOOKMARKS) slot = 0; - bookmarks.command(COMMAND_SELECT, slot); - break; - } - case EMUCMD_SAVE_SLOT_PREV: - { - int slot = bookmarks.getSelectedSlot() - 1; - if (slot < 0) slot = TOTAL_BOOKMARKS - 1; - bookmarks.command(COMMAND_SELECT, slot); - break; - } - case EMUCMD_SAVE_STATE: - bookmarks.command(COMMAND_SET); - break; - case EMUCMD_SAVE_STATE_SLOT_0: - case EMUCMD_SAVE_STATE_SLOT_1: - case EMUCMD_SAVE_STATE_SLOT_2: - case EMUCMD_SAVE_STATE_SLOT_3: - case EMUCMD_SAVE_STATE_SLOT_4: - case EMUCMD_SAVE_STATE_SLOT_5: - case EMUCMD_SAVE_STATE_SLOT_6: - case EMUCMD_SAVE_STATE_SLOT_7: - case EMUCMD_SAVE_STATE_SLOT_8: - case EMUCMD_SAVE_STATE_SLOT_9: - bookmarks.command(COMMAND_SET, command - EMUCMD_SAVE_STATE_SLOT_0); - break; - case EMUCMD_LOAD_STATE: - bookmarks.command(COMMAND_DEPLOY); - break; - case EMUCMD_LOAD_STATE_SLOT_0: - case EMUCMD_LOAD_STATE_SLOT_1: - case EMUCMD_LOAD_STATE_SLOT_2: - case EMUCMD_LOAD_STATE_SLOT_3: - case EMUCMD_LOAD_STATE_SLOT_4: - case EMUCMD_LOAD_STATE_SLOT_5: - case EMUCMD_LOAD_STATE_SLOT_6: - case EMUCMD_LOAD_STATE_SLOT_7: - case EMUCMD_LOAD_STATE_SLOT_8: - case EMUCMD_LOAD_STATE_SLOT_9: - bookmarks.command(COMMAND_DEPLOY, command - EMUCMD_LOAD_STATE_SLOT_0); - break; - case EMUCMD_MOVIE_PLAY_FROM_BEGINNING: - movie_readonly = true; - playback.jump(0); - break; - case EMUCMD_RELOAD: - taseditorWindow.loadRecentProject(0); - break; - case EMUCMD_TASEDITOR_RESTORE_PLAYBACK: - playback.restoreLastPosition(); - break; - case EMUCMD_TASEDITOR_CANCEL_SEEKING: - playback.cancelSeeking(); - break; - case EMUCMD_TASEDITOR_SWITCH_AUTORESTORING: - taseditorConfig.autoRestoreLastPlaybackPosition ^= 1; - taseditorWindow.updateCheckedItems(); - break; - case EMUCMD_TASEDITOR_SWITCH_MULTITRACKING: - recorder.multitrackRecordingJoypadNumber++; - if (recorder.multitrackRecordingJoypadNumber > joysticksPerFrame[getInputType(currMovieData)]) - recorder.multitrackRecordingJoypadNumber = 0; - break; - case EMUCMD_TASEDITOR_RUN_MANUAL_LUA: - // the function will be called in next window update - mustCallManualLuaFunction = true; - break; - - } -} -// these functions allow/disallow some FCEUX hotkeys and TAS Editor accelerators -void enableGeneralKeyboardInput() -{ - taseditorEnableAcceleratorKeys = true; - // set "Background TAS Editor input" - KeyboardSetBackgroundAccessBit(KEYBACKACCESS_TASEDITOR); - JoystickSetBackgroundAccessBit(JOYBACKACCESS_TASEDITOR); -} -void disableGeneralKeyboardInput() -{ - taseditorEnableAcceleratorKeys = false; - // clear "Background TAS Editor input" - KeyboardClearBackgroundAccessBit(KEYBACKACCESS_TASEDITOR); - JoystickClearBackgroundAccessBit(JOYBACKACCESS_TASEDITOR); -} diff --git a/branches/fceux-2.2.2/src/drivers/win/taseditor/bookmarks.cpp b/branches/fceux-2.2.2/src/drivers/win/taseditor/bookmarks.cpp deleted file mode 100644 index 084b8969..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/taseditor/bookmarks.cpp +++ /dev/null @@ -1,874 +0,0 @@ -/* --------------------------------------------------------------------------------- -Implementation file of Bookmarks class -Copyright (c) 2011-2013 AnS - -(The MIT License) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------- -Bookmarks/Branches - Manager of Bookmarks -[Single instance] - -* stores 10 Bookmarks -* implements all operations with Bookmarks: initialization, setting Bookmarks, jumping to Bookmarks, deploying Branches -* saves and loads the data from a project file. On error: resets all Bookmarks and Branches -* implements the working of Bookmarks List: creating, redrawing, mouseover, clicks -* regularly updates flashings in Bookmarks List -* on demand: updates colors of rows in Bookmarks List, reflecting conditions of respective Piano Roll rows -* stores resources: save id, ids of commands, captions for panel, gradients for flashings, id of default slot ------------------------------------------------------------------------------------- */ - -#include "taseditor_project.h" -#include "utils/xstring.h" -#include "zlib.h" - -#pragma comment(lib, "msimg32.lib") - -LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -WNDPROC hwndBookmarksList_oldWndProc; - -extern TASEDITOR_CONFIG taseditorConfig; -extern TASEDITOR_WINDOW taseditorWindow; -extern POPUP_DISPLAY popupDisplay; -extern PLAYBACK playback; -extern RECORDER recorder; -extern SELECTION selection; -extern GREENZONE greenzone; -extern TASEDITOR_PROJECT project; -extern HISTORY history; -extern PIANO_ROLL pianoRoll; -extern MARKERS_MANAGER markersManager; -extern BRANCHES branches; - -// resources -char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS"; -char bookmarks_skipsave_id[BOOKMARKS_ID_LEN] = "BOOKMARKX"; -char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " }; -// color tables for flashing when saving/loading bookmarks -COLORREF bookmark_flash_colors[TOTAL_BOOKMARK_COMMANDS][FLASH_PHASE_MAX+1] = { - // set - //0x122330, 0x1b3541, 0x254753, 0x2e5964, 0x376b75, 0x417e87, 0x4a8f97, 0x53a1a8, 0x5db3b9, 0x66c5cb, 0x70d7dc, 0x79e9ed, - 0x0d1241, 0x111853, 0x161e64, 0x1a2575, 0x1f2b87, 0x233197, 0x2837a8, 0x2c3db9, 0x3144cb, 0x354adc, 0x3a50ed, 0x3f57ff, - // jump - 0x14350f, 0x1c480f, 0x235a0f, 0x2a6c0f, 0x317f10, 0x38910f, 0x3fa30f, 0x46b50f, 0x4dc80f, 0x54da0f, 0x5bec0f, 0x63ff10, - // deploy - 0x43171d, 0x541d21, 0x652325, 0x762929, 0x872f2c, 0x983530, 0xa93b34, 0xba4137, 0xcb463b, 0xdc4c3f, 0xed5243, 0xff5947 }; - -BOOKMARKS::BOOKMARKS() -{ - // fill TrackMouseEvent struct - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = NULL; - tmeList.cbSize = sizeof(tme); - tmeList.dwFlags = TME_LEAVE; - tmeList.hwndTrack = NULL; -} - -void BOOKMARKS::init() -{ - free(); - hwndBookmarksList = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKSLIST); - hwndBranchesBitmap = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BRANCHES_BITMAP); - hwndBookmarks = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKS_BOX); - - // prepare bookmarks listview - ListView_SetExtendedListViewStyleEx(hwndBookmarksList, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); - // subclass the listview - hwndBookmarksList_oldWndProc = (WNDPROC)SetWindowLong(hwndBookmarksList, GWL_WNDPROC, (LONG)BookmarksListWndProc); - // setup images for the listview - hImgList = ImageList_Create(11, 13, ILC_COLOR8 | ILC_MASK, 1, 1); - HBITMAP bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP0)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP2)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP3)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP4)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP5)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP6)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP7)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP8)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP9)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP10)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP11)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP12)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP13)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP14)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP15)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP16)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP17)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP18)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP19)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED0)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED1)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED2)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED3)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED4)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED5)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED6)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED7)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED8)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED9)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED10)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED11)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED12)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED13)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED14)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED15)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED16)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED17)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED18)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED19)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - ListView_SetImageList(hwndBookmarksList, hImgList, LVSIL_SMALL); - // setup columns - LVCOLUMN lvc; - // icons column - lvc.mask = LVCF_WIDTH; - lvc.cx = BOOKMARKSLIST_COLUMN_ICONS_WIDTH; - ListView_InsertColumn(hwndBookmarksList, 0, &lvc); - // keyframe column - lvc.mask = LVCF_WIDTH | LVCF_FMT; - lvc.fmt = LVCFMT_CENTER; - lvc.cx = BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH; - ListView_InsertColumn(hwndBookmarksList, 1, &lvc); - // time column - lvc.cx = BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH; - ListView_InsertColumn(hwndBookmarksList, 2, &lvc); - // create 10 rows - ListView_SetItemCountEx(hwndBookmarksList, TOTAL_BOOKMARKS, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL); - - reset(); - selectedSlot = DEFAULT_SLOT; - // find the top/height of the "Time" cell of the 1st row (for mouseover hittest calculations) - RECT temp_rect, wrect; - if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top) - { - listTopMargin = temp_rect.top; - listRowLeft = temp_rect.left; - listRowHeight = temp_rect.bottom - temp_rect.top; - } else - { - // couldn't get rect, set default values - listTopMargin = 0; - listRowLeft = BOOKMARKSLIST_COLUMN_ICONS_WIDTH + BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH; - listRowHeight = 14; - } - // calculate the needed height of client area (so that all 10 rows fir the screen) - int total_list_height = listTopMargin + listRowHeight * TOTAL_BOOKMARKS; - // find the difference between Bookmarks List window and Bookmarks List client area - GetWindowRect(hwndBookmarksList, &wrect); - GetClientRect(hwndBookmarksList, &temp_rect); - total_list_height += (wrect.bottom - wrect.top) - (temp_rect.bottom - temp_rect.top); - // change the height - taseditorWindow.changeBookmarksListHeight(total_list_height); - - - - redrawBookmarksSectionCaption(); -} -void BOOKMARKS::free() -{ - bookmarksArray.resize(0); - if (hImgList) - { - ImageList_Destroy(hImgList); - hImgList = 0; - } -} -void BOOKMARKS::reset() -{ - // delete all commands if there are any - commands.resize(0); - // init bookmarks - bookmarksArray.resize(0); - bookmarksArray.resize(TOTAL_BOOKMARKS); - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - bookmarksArray[i].init(); - reset_vars(); -} -void BOOKMARKS::reset_vars() -{ - mouseX = mouseY = -1; - itemUnderMouse = ITEM_UNDER_MOUSE_NONE; - mouseOverBranchesBitmap = false; - mustCheckItemUnderMouse = true; - bookmarkLeftclicked = bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; - nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK; -} - -void BOOKMARKS::update() -{ - // execute all commands accumulated during last frame - for (int i = 0; (i + 1) < (int)commands.size(); ) // FIFO - { - int command_id = commands[i++]; - int slot = commands[i++]; - switch (command_id) - { - case COMMAND_SET: - set(slot); - break; - case COMMAND_JUMP: - jump(slot); - break; - case COMMAND_DEPLOY: - deploy(slot); - break; - case COMMAND_SELECT: - if (selectedSlot != slot) - { - int old_selected_slot = selectedSlot; - selectedSlot = slot; - redrawBookmark(old_selected_slot); - redrawBookmark(selectedSlot); - } - break; - } - } - commands.resize(0); - - // once per 100 milliseconds update bookmark flashes - if (clock() > nextFlashUpdateTime) - { - nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK; - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - { - if (bookmarkRightclicked == i || bookmarkLeftclicked == i) - { - if (bookmarksArray[i].flashPhase != FLASH_PHASE_BUTTONHELD) - { - bookmarksArray[i].flashPhase = FLASH_PHASE_BUTTONHELD; - redrawBookmark(i); - branches.mustRedrawBranchesBitmap = true; // because border of branch digit has changed - } - } else - { - if (bookmarksArray[i].flashPhase > 0) - { - bookmarksArray[i].flashPhase--; - redrawBookmark(i); - branches.mustRedrawBranchesBitmap = true; // because border of branch digit has changed - } - } - } - } - - // controls - if (mustCheckItemUnderMouse) - { - if (editMode == EDIT_MODE_BRANCHES) - itemUnderMouse = branches.findItemUnderMouse(mouseX, mouseY); - else if (editMode == EDIT_MODE_BOTH) - itemUnderMouse = findItemUnderMouse(); - else - itemUnderMouse = ITEM_UNDER_MOUSE_NONE; - mustCheckItemUnderMouse = false; - } -} - -// stores commands in array for update() function -void BOOKMARKS::command(int command_id, int slot) -{ - if (slot < 0) - slot = selectedSlot; - if (slot >= 0 && slot < TOTAL_BOOKMARKS) - { - commands.push_back(command_id); - commands.push_back(slot); - } -} - -void BOOKMARKS::set(int slot) -{ - if (slot < 0 || slot >= TOTAL_BOOKMARKS) return; - - // First save changes in edited note (in case it's being currently edited) - markersManager.updateEditedMarkerNote(); - - int previous_frame = bookmarksArray[slot].snapshot.keyFrame; - if (bookmarksArray[slot].isDifferentFromCurrentMovie()) - { - BOOKMARK backup_copy(bookmarksArray[slot]); - bookmarksArray[slot].set(); - // rebuild Branches Tree - int old_current_branch = branches.getCurrentBranch(); - branches.handleBookmarkSet(slot); - if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD) - { - // current_branch was switched to slot, redraw Bookmarks List to change the color of digits - pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame); - redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame); - } - // also redraw List rows - if (previous_frame >= 0 && previous_frame != currFrameCounter) - { - pianoRoll.redrawRow(previous_frame); - redrawChangedBookmarks(previous_frame); - } - pianoRoll.redrawRow(currFrameCounter); - redrawChangedBookmarks(currFrameCounter); - // if screenshot of the slot is currently shown - reinit and redraw the picture - if (popupDisplay.currentlyDisplayedBookmark == slot) - popupDisplay.currentlyDisplayedBookmark = ITEM_UNDER_MOUSE_NONE; - - history.registerBookmarkSet(slot, backup_copy, old_current_branch); - mustCheckItemUnderMouse = true; - FCEU_DispMessage("Branch %d saved.", 0, slot); - } -} - -void BOOKMARKS::jump(int slot) -{ - if (slot < 0 || slot >= TOTAL_BOOKMARKS) return; - if (bookmarksArray[slot].notEmpty) - { - int frame = bookmarksArray[slot].snapshot.keyFrame; - playback.jump(frame); - bookmarksArray[slot].handleJump(); - } -} - -void BOOKMARKS::deploy(int slot) -{ - recorder.stateWasLoadedInReadWriteMode = true; - if (taseditorConfig.oldControlSchemeForBranching && movie_readonly) - { - jump(slot); - return; - } - if (slot < 0 || slot >= TOTAL_BOOKMARKS) return; - if (!bookmarksArray[slot].notEmpty) return; - - int keyframe = bookmarksArray[slot].snapshot.keyFrame; - bool markers_changed = false; - // revert Markers to the Bookmarked state - if (bookmarksArray[slot].snapshot.areMarkersDifferentFromCurrentMarkers()) - { - bookmarksArray[slot].snapshot.copyToCurrentMarkers(); - markers_changed = true; - } - // revert current movie data to the Bookmarked state - if (taseditorConfig.branchesRestoreEntireMovie) - { - bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData); - } else - { - // restore movie up to and not including bookmarked frame (simulating old TASing method) - if (keyframe) - bookmarksArray[slot].snapshot.inputlog.toMovie(currMovieData, 0, keyframe - 1); - else - currMovieData.truncateAt(0); - // add empty frame at the end (at keyframe) - currMovieData.insertEmpty(-1, 1); - } - - int first_change = history.registerBranching(slot, markers_changed); // this also reverts Greenzone's LagLog if needed - if (first_change >= 0) - { - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - pianoRoll.updateLinesCount(); - greenzone.invalidate(first_change); - bookmarksArray[slot].handleDeploy(); - } else if (markers_changed) - { - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - bookmarksArray[slot].handleDeploy(); - } else - { - // didn't change anything in current movie - bookmarksArray[slot].handleJump(); - } - - // jump to the target (bookmarked frame) - if (greenzone.isSavestateEmpty(keyframe)) - greenzone.writeSavestateForFrame(keyframe, bookmarksArray[slot].savestate); - playback.jump(keyframe, true); - // switch current branch to this branch - int old_current_branch = branches.getCurrentBranch(); - branches.handleBookmarkDeploy(slot); - if (slot != old_current_branch && old_current_branch != ITEM_UNDER_MOUSE_CLOUD) - { - pianoRoll.redrawRow(bookmarksArray[old_current_branch].snapshot.keyFrame); - redrawChangedBookmarks(bookmarksArray[old_current_branch].snapshot.keyFrame); - pianoRoll.redrawRow(keyframe); - redrawChangedBookmarks(keyframe); - } - FCEU_DispMessage("Branch %d loaded.", 0, slot); - pianoRoll.redraw(); // even though the Greenzone invalidation most likely have already sent the command to redraw -} - -void BOOKMARKS::save(EMUFILE *os, bool really_save) -{ - if (really_save) - { - // write "BOOKMARKS" string - os->fwrite(bookmarks_save_id, BOOKMARKS_ID_LEN); - // write all 10 bookmarks - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - bookmarksArray[i].save(os); - // write branches - branches.save(os); - } else - { - // write "BOOKMARKX" string - os->fwrite(bookmarks_skipsave_id, BOOKMARKS_ID_LEN); - } -} -// returns true if couldn't load -bool BOOKMARKS::load(EMUFILE *is, unsigned int offset) -{ - if (offset) - { - if (is->fseek(offset, SEEK_SET)) goto error; - } else - { - reset(); - branches.reset(); - return false; - } - // read "BOOKMARKS" string - char save_id[BOOKMARKS_ID_LEN]; - if ((int)is->fread(save_id, BOOKMARKS_ID_LEN) < BOOKMARKS_ID_LEN) goto error; - if (!strcmp(bookmarks_skipsave_id, save_id)) - { - // string says to skip loading Bookmarks - FCEU_printf("No Bookmarks in the file\n"); - reset(); - branches.reset(); - return false; - } - if (strcmp(bookmarks_save_id, save_id)) goto error; // string is not valid - // read all 10 bookmarks - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - if (bookmarksArray[i].load(is)) goto error; - // read branches - if (branches.load(is)) goto error; - // all ok - reset_vars(); - redrawBookmarksSectionCaption(); - return false; -error: - FCEU_printf("Error loading Bookmarks\n"); - reset(); - branches.reset(); - return true; -} -// ---------------------------------------------------------- -void BOOKMARKS::redrawBookmarksSectionCaption() -{ - int prev_edit_mode = editMode; - if (taseditorConfig.displayBranchesTree) - { - editMode = EDIT_MODE_BRANCHES; - ShowWindow(hwndBookmarksList, SW_HIDE); - ShowWindow(hwndBranchesBitmap, SW_SHOW); - } else if (taseditorConfig.oldControlSchemeForBranching && movie_readonly) - { - editMode = EDIT_MODE_BOOKMARKS; - ShowWindow(hwndBranchesBitmap, SW_HIDE); - ShowWindow(hwndBookmarksList, SW_SHOW); - redrawBookmarksList(); - } else - { - editMode = EDIT_MODE_BOTH; - ShowWindow(hwndBranchesBitmap, SW_HIDE); - ShowWindow(hwndBookmarksList, SW_SHOW); - redrawBookmarksList(); - } - if (prev_edit_mode != editMode) - mustCheckItemUnderMouse = true; - SetWindowText(hwndBookmarks, bookmarksCaption[editMode]); -} -void BOOKMARKS::redrawBookmarksList(bool eraseBG) -{ - if (editMode != EDIT_MODE_BRANCHES) - InvalidateRect(hwndBookmarksList, 0, eraseBG); -} -void BOOKMARKS::redrawChangedBookmarks(int frame) -{ - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - { - if (bookmarksArray[i].snapshot.keyFrame == frame) - redrawBookmark(i); - } -} -void BOOKMARKS::redrawBookmark(int bookmarkNumber) -{ - redrawBookmarksListRow((bookmarkNumber + TOTAL_BOOKMARKS - 1) % TOTAL_BOOKMARKS); -} -void BOOKMARKS::redrawBookmarksListRow(int rowIndex) -{ - ListView_RedrawItems(hwndBookmarksList, rowIndex, rowIndex); -} - -void BOOKMARKS::handleMouseMove(int newX, int newY) -{ - mouseX = newX; - mouseY = newY; - mustCheckItemUnderMouse = true; -} -int BOOKMARKS::findItemUnderMouse() -{ - int item = ITEM_UNDER_MOUSE_NONE; - RECT wrect; - GetClientRect(hwndBookmarksList, &wrect); - if (mouseX >= listRowLeft && mouseX < wrect.right - wrect.left && mouseY >= listTopMargin && mouseY < wrect.bottom - wrect.top) - { - int row_under_mouse = (mouseY - listTopMargin) / listRowHeight; - if (row_under_mouse >= 0 && row_under_mouse < TOTAL_BOOKMARKS) - item = (row_under_mouse + 1) % TOTAL_BOOKMARKS; - } - return item; -} - -int BOOKMARKS::getSelectedSlot() -{ - return selectedSlot; -} -// ---------------------------------------------------------------------------------------- -void BOOKMARKS::getDispInfo(NMLVDISPINFO* nmlvDispInfo) -{ - LVITEM& item = nmlvDispInfo->item; - if (item.mask & LVIF_TEXT) - { - switch(item.iSubItem) - { - case BOOKMARKSLIST_COLUMN_ICON: - { - if ((item.iItem + 1) % TOTAL_BOOKMARKS == branches.getCurrentBranch()) - item.iImage = ((item.iItem + 1) % TOTAL_BOOKMARKS) + TOTAL_BOOKMARKS; - else - item.iImage = (item.iItem + 1) % TOTAL_BOOKMARKS; - if (taseditorConfig.oldControlSchemeForBranching) - { - if ((item.iItem + 1) % TOTAL_BOOKMARKS == selectedSlot) - item.iImage += BOOKMARKS_BITMAPS_SELECTED; - } - break; - } - case BOOKMARKSLIST_COLUMN_FRAME: - { - if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty) - U32ToDecStr(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.keyFrame, DIGITS_IN_FRAMENUM); - break; - } - case BOOKMARKSLIST_COLUMN_TIME: - { - if (bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].notEmpty) - strcpy(item.pszText, bookmarksArray[(item.iItem + 1) % TOTAL_BOOKMARKS].snapshot.description); - } - break; - } - } -} - -LONG BOOKMARKS::handleCustomDraw(NMLVCUSTOMDRAW* msg) -{ - int cell_x, cell_y; - switch(msg->nmcd.dwDrawStage) - { - case CDDS_PREPAINT: - return CDRF_NOTIFYITEMDRAW; - case CDDS_ITEMPREPAINT: - return CDRF_NOTIFYSUBITEMDRAW; - case CDDS_SUBITEMPREPAINT: - cell_x = msg->iSubItem; - cell_y = (msg->nmcd.dwItemSpec + 1) % TOTAL_BOOKMARKS; - - // flash with text color when needed - if (bookmarksArray[cell_y].flashPhase) - msg->clrText = bookmark_flash_colors[bookmarksArray[cell_y].flashType][bookmarksArray[cell_y].flashPhase]; - - if (cell_x == BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly && cell_x == BOOKMARKSLIST_COLUMN_TIME)) - { - if (bookmarksArray[cell_y].notEmpty) - { - // frame number - SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont); - int frame = bookmarksArray[cell_y].snapshot.keyFrame; - if (frame == currFrameCounter || frame == (playback.getFlashingPauseFrame() - 1)) - { - // current frame - msg->clrTextBk = CUR_FRAMENUM_COLOR; - } else if (frame < greenzone.getSize()) - { - if (!greenzone.isSavestateEmpty(frame)) - { - if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES) - msg->clrTextBk = LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY8TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY4TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY2ND)) - { - if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES) - msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_BACKGROUND_COLOR; // empty bookmark - } else if (cell_x == BOOKMARKSLIST_COLUMN_TIME) - { - if (bookmarksArray[cell_y].notEmpty) - { - // frame number - SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont); - int frame = bookmarksArray[cell_y].snapshot.keyFrame; - if (frame == currFrameCounter || frame == (playback.getFlashingPauseFrame() - 1)) - { - // current frame - msg->clrTextBk = CUR_INPUT_COLOR1; - } else if (frame < greenzone.getSize()) - { - if (!greenzone.isSavestateEmpty(frame)) - { - if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES) - msg->clrTextBk = LAG_INPUT_COLOR1; - else - msg->clrTextBk = GREENZONE_INPUT_COLOR1; - } else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY8TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY4TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY2ND)) - { - if (greenzone.lagLog.getLagInfoAtFrame(frame) == LAGGED_YES) - msg->clrTextBk = PALE_LAG_INPUT_COLOR1; - else - msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_BACKGROUND_COLOR; // empty bookmark - } - default: - return CDRF_DODEFAULT; - } -} - -void BOOKMARKS::handleLeftClick() -{ - if (columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly)) - command(COMMAND_JUMP, bookmarkLeftclicked); - else if (columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig.oldControlSchemeForBranching || !movie_readonly)) - command(COMMAND_DEPLOY, bookmarkLeftclicked); -} -void BOOKMARKS::handleRightClick() -{ - if (bookmarkRightclicked >= 0) - command(COMMAND_SET, bookmarkRightclicked); -} - -int BOOKMARKS::findBookmarkAtFrame(int frame) -{ - int cur_bookmark = branches.getCurrentBranch(); - if (cur_bookmark != ITEM_UNDER_MOUSE_CLOUD && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame) - return cur_bookmark + TOTAL_BOOKMARKS; // blue digit has highest priority when drawing - for (int i = 0; i < TOTAL_BOOKMARKS; ++i) - { - cur_bookmark = (i + 1) % TOTAL_BOOKMARKS; - if (bookmarksArray[cur_bookmark].notEmpty && bookmarksArray[cur_bookmark].snapshot.keyFrame == frame) - return cur_bookmark; // green digit - } - return -1; // no Bookmarks at the frame -} -// ---------------------------------------------------------------------------------------- -LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - extern BOOKMARKS bookmarks; - switch(msg) - { - case WM_CHAR: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SETFOCUS: - case WM_KILLFOCUS: - return 0; - case WM_MOUSEMOVE: - { - if (!bookmarks.mouseOverBookmarksList) - { - bookmarks.mouseOverBookmarksList = true; - bookmarks.tmeList.hwndTrack = hWnd; - TrackMouseEvent(&bookmarks.tmeList); - } - bookmarks.handleMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); - break; - } - case WM_MOUSELEAVE: - { - bookmarks.mouseOverBookmarksList = false; - bookmarks.handleMouseMove(-1, -1); - break; - } - case WM_LBUTTONDOWN: - case WM_LBUTTONDBLCLK: - { - if (GetFocus() != hWnd) - SetFocus(hWnd); - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - ListView_SubItemHitTest(hWnd, (LPARAM)&info); - if (info.iItem >= 0 && bookmarks.bookmarkRightclicked < 0) - { - bookmarks.bookmarkLeftclicked = (info.iItem + 1) % TOTAL_BOOKMARKS; - bookmarks.columnClicked = info.iSubItem; - if (bookmarks.columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig.oldControlSchemeForBranching && movie_readonly)) - bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_JUMP; - else if (bookmarks.columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig.oldControlSchemeForBranching || !movie_readonly)) - bookmarks.bookmarksArray[bookmarks.bookmarkLeftclicked].flashType = FLASH_TYPE_DEPLOY; - SetCapture(hWnd); - } - return 0; - } - case WM_LBUTTONUP: - { - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - RECT wrect; - GetClientRect(hWnd, &wrect); - if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top) - { - ListView_SubItemHitTest(hWnd, (LPARAM)&info); - if (bookmarks.bookmarkLeftclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem) - bookmarks.handleLeftClick(); - } - ReleaseCapture(); - bookmarks.bookmarkLeftclicked = -1; - return 0; - } - case WM_RBUTTONDOWN: - case WM_RBUTTONDBLCLK: - { - if (GetFocus() != hWnd) - SetFocus(hWnd); - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - ListView_SubItemHitTest(hWnd, (LPARAM)&info); - if (info.iItem >= 0 && bookmarks.bookmarkLeftclicked < 0) - { - bookmarks.bookmarkRightclicked = (info.iItem + 1) % TOTAL_BOOKMARKS; - bookmarks.columnClicked = info.iSubItem; - bookmarks.bookmarksArray[bookmarks.bookmarkRightclicked].flashType = FLASH_TYPE_SET; - SetCapture(hWnd); - } - return 0; - } - case WM_RBUTTONUP: - { - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - RECT wrect; - GetClientRect(hWnd, &wrect); - if (info.pt.x >= 0 && info.pt.x < wrect.right - wrect.left && info.pt.y >= 0 && info.pt.y < wrect.bottom - wrect.top) - { - ListView_SubItemHitTest(hWnd, (LPARAM)&info); - if (bookmarks.bookmarkRightclicked == (info.iItem + 1) % TOTAL_BOOKMARKS && bookmarks.columnClicked == info.iSubItem) - bookmarks.handleRightClick(); - } - ReleaseCapture(); - bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; - return 0; - } - case WM_MBUTTONDOWN: - case WM_MBUTTONDBLCLK: - { - if (GetFocus() != hWnd) - SetFocus(hWnd); - playback.handleMiddleButtonClick(); - return 0; - } - case WM_MOUSEWHEEL: - { - bookmarks.bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; // ensure that accidental rightclick on BookmarksList won't set Bookmarks when user does rightbutton + wheel - return SendMessage(pianoRoll.hwndList, msg, wParam, lParam); - } - } - return CallWindowProc(hwndBookmarksList_oldWndProc, hWnd, msg, wParam, lParam); -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.cpp b/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.cpp deleted file mode 100644 index a78e73ed..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.cpp +++ /dev/null @@ -1,2139 +0,0 @@ -/* --------------------------------------------------------------------------------- -Implementation file of PIANO_ROLL class -Copyright (c) 2011-2013 AnS - -(The MIT License) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------- -Piano Roll - Piano Roll interface -[Single instance] - -* implements the working of Piano Roll List: creating, redrawing, scrolling, mouseover, clicks, drag -* regularly updates the size of the List according to current movie Input -* on demand: scrolls visible area of the List to any given item: to Playback Cursor, to Selection Cursor, to "undo pointer", to a Marker -* saves and loads current position of vertical scrolling from a project file. On error: scrolls the List to the beginning -* implements the working of Piano Roll List Header: creating, redrawing, animating, mouseover, clicks -* regularly updates lights in the Header according to button presses data from Recorder and Alt key state -* on demand: launches flashes in the Header -* implements the working of mouse wheel: List scrolling, Playback cursor movement, Selection cursor movement, scrolling across gaps in Input/Markers -* implements context menu on Right-click -* stores resources: save id, ids of columns, widths of columns, tables of colors, gradient of Hot Changes, gradient of Header flashings, timings of flashes, all fonts used in TAS Editor, images ------------------------------------------------------------------------------------- */ - -#include "taseditor_project.h" -#include "utils/xstring.h" -#include "uxtheme.h" -#include - -#pragma comment(lib, "UxTheme.lib") - -extern int joysticksPerFrame[INPUT_TYPES_TOTAL]; -extern char buttonNames[NUM_JOYPAD_BUTTONS][2]; - -extern TASEDITOR_CONFIG taseditorConfig; -extern TASEDITOR_WINDOW taseditorWindow; -extern BOOKMARKS bookmarks; -extern PLAYBACK playback; -extern RECORDER recorder; -extern GREENZONE greenzone; -extern HISTORY history; -extern MARKERS_MANAGER markersManager; -extern SELECTION selection; -extern EDITOR editor; - -extern int getInputType(MovieData& md); - -LRESULT APIENTRY headerWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -LRESULT APIENTRY listWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -WNDPROC hwndListOldWndProc = 0, hwndHeaderOldWndproc = 0; - -LRESULT APIENTRY markerDragBoxWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -// resources -char pianoRollSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLL"; -char pianoRollSkipSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLX"; -//COLORREF hotChangesColors[16] = { 0x0, 0x495249, 0x666361, 0x855a45, 0xa13620, 0xbd003f, 0xd6006f, 0xcc008b, 0xba00a1, 0x8b00ad, 0x5c00bf, 0x0003d1, 0x0059d6, 0x0077d9, 0x0096db, 0x00aede }; -COLORREF hotChangesColors[16] = { 0x0, 0x004035, 0x185218, 0x5e5c34, 0x804c00, 0xba0300, 0xd10038, 0xb21272, 0xba00ab, 0x6f00b0, 0x3700c2, 0x000cba, 0x002cc9, 0x0053bf, 0x0072cf, 0x3c8bc7 }; -COLORREF headerLightsColors[11] = { 0x0, 0x007313, 0x009100, 0x1daf00, 0x42c700, 0x65d900, 0x91e500, 0xb0f000, 0xdaf700, 0xf0fc7c, 0xfcffba }; - -char markerDragBoxClassName[] = "MarkerDragBox"; - -PIANO_ROLL::PIANO_ROLL() -{ - hwndMarkerDragBox = 0; - // register MARKER_DRAG_BOX window class - winCl.hInstance = fceu_hInstance; - winCl.lpszClassName = markerDragBoxClassName; - winCl.lpfnWndProc = markerDragBoxWndProc; - winCl.style = CS_SAVEBITS| CS_DBLCLKS; - winCl.cbSize = sizeof(WNDCLASSEX); - winCl.hIcon = 0; - winCl.hIconSm = 0; - winCl.hCursor = 0; - winCl.lpszMenuName = 0; - winCl.cbClsExtra = 0; - winCl.cbWndExtra = 0; - winCl.hbrBackground = 0; - if (!RegisterClassEx(&winCl)) - FCEU_printf("Error registering MARKER_DRAG_BOX window class\n"); - - // create blendfunction - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.AlphaFormat = 0; - blend.SourceConstantAlpha = 255; - -} - -void PIANO_ROLL::init() -{ - free(); - // create fonts for main listview - hMainListFont = CreateFont(14, 7, /*Height,Width*/ - 0, 0, /*escapement,orientation*/ - FW_BOLD, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Arial"); /*font name*/ - hMainListSelectFont = CreateFont(15, 10, /*Height,Width*/ - 0, 0, /*escapement,orientation*/ - FW_BOLD, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Courier New"); /*font name*/ - // create fonts for Marker notes fields - hMarkersFont = CreateFont(16, 8, /*Height,Width*/ - 0, 0, /*escapement,orientation*/ - FW_BOLD, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Arial"); /*font name*/ - hMarkersEditFont = CreateFont(16, 7, /*Height,Width*/ - 0, 0, /*escapement,orientation*/ - FW_NORMAL, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Arial"); /*font name*/ - hTaseditorAboutFont = CreateFont(24, 10, /*Height,Width*/ - 0, 0, /*escapement,orientation*/ - FW_NORMAL, FALSE, FALSE, FALSE, /*weight, italic, underline, strikeout*/ - ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_MASK, /*charset, precision, clipping*/ - DEFAULT_QUALITY, DEFAULT_PITCH, /*quality, and pitch*/ - "Arial"); /*font name*/ - - bgBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); - markerDragBoxBrushNormal = CreateSolidBrush(MARKED_FRAMENUM_COLOR); - markerDragBoxBrushBind = CreateSolidBrush(BINDMARKED_FRAMENUM_COLOR); - - hwndList = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_LIST1); - // prepare the main listview - ListView_SetExtendedListViewStyleEx(hwndList, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); - // subclass the header - hwndHeader = ListView_GetHeader(hwndList); - hwndHeaderOldWndproc = (WNDPROC)SetWindowLong(hwndHeader, GWL_WNDPROC, (LONG)headerWndProc); - // subclass the whole listview - hwndListOldWndProc = (WNDPROC)SetWindowLong(hwndList, GWL_WNDPROC, (LONG)listWndProc); - // disable Visual Themes for header - SetWindowTheme(hwndHeader, L"", L""); - // setup images for the listview - hImgList = ImageList_Create(13, 13, ILC_COLOR8 | ILC_MASK, 1, 1); - HBITMAP bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_0)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_1)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_2)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_3)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_4)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_5)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_6)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_7)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_8)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_9)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_10)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_11)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_12)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_13)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_14)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_15)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_16)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_17)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_18)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_19)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_0)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_1)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_2)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_3)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_4)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_5)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_6)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_7)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_8)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_9)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_10)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_11)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_12)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_13)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_14)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_15)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_16)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_17)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_18)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_PLAYBACK_19)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_0)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_1)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_2)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_3)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_4)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_5)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_6)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_7)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_8)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_9)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_10)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_11)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_12)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_13)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_14)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_15)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_16)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_17)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_18)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_PIANO_LOSTPOS_19)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_TE_ARROW)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_TE_GREEN_ARROW)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_TE_GREEN_BLUE_ARROW)); - ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); - DeleteObject(bmp); - ListView_SetImageList(hwndList, hImgList, LVSIL_SMALL); - // setup 0th column - LVCOLUMN lvc; - // icons column - lvc.mask = LVCF_WIDTH; - lvc.cx = COLUMN_ICONS_WIDTH; - ListView_InsertColumn(hwndList, 0, &lvc); - // find rows top/height (for mouseover hittest calculations) - ListView_SetItemCountEx(hwndList, 1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL); - RECT temp_rect; - if (ListView_GetSubItemRect(hwndList, 0, 0, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top) - { - listTopMargin = temp_rect.top; - listRowHeight = temp_rect.bottom - temp_rect.top; - } else - { - // couldn't get rect, set default values - listTopMargin = 20; - listRowHeight = 14; - } - ListView_SetItemCountEx(hwndList, 0, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL); - // find header height - RECT wrect; - if (GetWindowRect(hwndHeader, &wrect)) - listHeaderHeight = wrect.bottom - wrect.top; - else - listHeaderHeight = 20; - - hrMenu = LoadMenu(fceu_hInstance,"TASEDITORCONTEXTMENUS"); - headerColors.resize(TOTAL_COLUMNS); - // fill TrackMouseEvent struct - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hwndHeader; - dragMode = DRAG_MODE_NONE; - rightButtonDragMode = false; -} -void PIANO_ROLL::free() -{ - if (hMainListFont) - { - DeleteObject(hMainListFont); - hMainListFont = 0; - } - if (hMainListSelectFont) - { - DeleteObject(hMainListSelectFont); - hMainListSelectFont = 0; - } - if (hMarkersFont) - { - DeleteObject(hMarkersFont); - hMarkersFont = 0; - } - if (hMarkersEditFont) - { - DeleteObject(hMarkersEditFont); - hMarkersEditFont = 0; - } - if (hTaseditorAboutFont) - { - DeleteObject(hTaseditorAboutFont); - hTaseditorAboutFont = 0; - } - if (bgBrush) - { - DeleteObject(bgBrush); - bgBrush = 0; - } - if (markerDragBoxBrushNormal) - { - DeleteObject(markerDragBoxBrushNormal); - markerDragBoxBrushNormal = 0; - } - if (markerDragBoxBrushBind) - { - DeleteObject(markerDragBoxBrushBind); - markerDragBoxBrushBind = 0; - } - if (hImgList) - { - ImageList_Destroy(hImgList); - hImgList = 0; - } - headerColors.resize(0); -} -void PIANO_ROLL::reset() -{ - mustRedrawList = mustCheckItemUnderMouse = true; - playbackCursorOffset = 0; - shiftHeld = ctrlHeld = altHeld = false; - shiftTimer = ctrlTimer = shiftActionsÑount = ctrlActionsÑount = 0; - nextHeaderUpdateTime = headerItemUnderMouse = 0; - // delete all columns except 0th - while (ListView_DeleteColumn(hwndList, 1)) {} - // setup columns - numColumns = 1; - LVCOLUMN lvc; - // frame number column - lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT; - lvc.fmt = LVCFMT_CENTER; - lvc.cx = COLUMN_FRAMENUM_WIDTH; - lvc.pszText = "Frame#"; - ListView_InsertColumn(hwndList, numColumns++, &lvc); - // pads columns - lvc.cx = COLUMN_BUTTON_WIDTH; - int num_joysticks = joysticksPerFrame[getInputType(currMovieData)]; - for (int joy = 0; joy < num_joysticks; ++joy) - { - for (int btn = 0; btn < NUM_JOYPAD_BUTTONS; ++btn) - { - lvc.pszText = buttonNames[btn]; - ListView_InsertColumn(hwndList, numColumns++, &lvc); - } - } - // add 2nd frame number column if needed - if (numColumns >= NUM_COLUMNS_NEED_2ND_FRAMENUM) - { - - lvc.cx = COLUMN_FRAMENUM_WIDTH; - lvc.pszText = "Frame#"; - ListView_InsertColumn(hwndList, numColumns++, &lvc); - } -} -void PIANO_ROLL::update() -{ - updateLinesCount(); - - // update state of Shift/Ctrl/Alt holding - bool last_shift_held = shiftHeld, last_ctrl_held = ctrlHeld, last_alt_held = altHeld; - shiftHeld = (GetAsyncKeyState(VK_SHIFT) < 0); - ctrlHeld = (GetAsyncKeyState(VK_CONTROL) < 0); - altHeld = (GetAsyncKeyState(VK_MENU) < 0); - // check doubletap of Shift/Ctrl - if (last_shift_held != shiftHeld) - { - if ((int)(shiftTimer + GetDoubleClickTime()) > clock()) - { - shiftActionsÑount++; - if (shiftActionsÑount >= DOUBLETAP_COUNT) - { - if (taseditorWindow.TASEditorIsInFocus) - followPlaybackCursor(); - shiftActionsÑount = ctrlActionsÑount = 0; - } - } else - { - shiftActionsÑount = 0; - } - shiftTimer = clock(); - } - if (last_ctrl_held != ctrlHeld) - { - if ((int)(ctrlTimer + GetDoubleClickTime()) > clock()) - { - ctrlActionsÑount++; - if (ctrlActionsÑount >= DOUBLETAP_COUNT) - { - if (taseditorWindow.TASEditorIsInFocus) - followSelection(); - ctrlActionsÑount = shiftActionsÑount = 0; - } - } else - { - ctrlActionsÑount = 0; - } - ctrlTimer = clock(); - } - - if (mustCheckItemUnderMouse) - { - // find row and column - POINT p; - if (GetCursorPos(&p)) - { - ScreenToClient(hwndList, &p); - // perform hit test - LVHITTESTINFO info; - info.pt.x = p.x; - info.pt.y = p.y; - ListView_SubItemHitTest(hwndList, &info); - rowUnderMouse = info.iItem; - realRowUnderMouse = rowUnderMouse; - if (realRowUnderMouse < 0) - { - realRowUnderMouse = ListView_GetTopIndex(hwndList) + (p.y - listTopMargin) / listRowHeight; - if (realRowUnderMouse < 0) realRowUnderMouse--; - } - columnUnderMouse = info.iSubItem; - } - // and don't check until mouse moves or Piano Roll scrolls - mustCheckItemUnderMouse = false; - taseditorWindow.mustUpdateMouseCursor = true; - } - - // update dragging - if (dragMode != DRAG_MODE_NONE) - { - // check if user released left button - if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON) >= 0) - finishDrag(); - } - if (rightButtonDragMode) - { - // check if user released right button - if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON) >= 0) - rightButtonDragMode = false; - } - // perform drag - switch (dragMode) - { - case DRAG_MODE_PLAYBACK: - { - handlePlaybackCursorDragging(); - break; - } - case DRAG_MODE_MARKER: - { - // if suddenly source frame lost its Marker, abort drag - if (!markersManager.getMarkerAtFrame(markerDragFrameNumber)) - { - if (hwndMarkerDragBox) - { - DestroyWindow(hwndMarkerDragBox); - hwndMarkerDragBox = 0; - } - dragMode = DRAG_MODE_NONE; - break; - } - // when dragging, always show semi-transparent yellow rectangle under mouse - POINT p = {0, 0}; - GetCursorPos(&p); - markerDragBoxX = p.x - markerDragBoxDX; - markerDragBoxY = p.y - markerDragBoxDY; - if (!hwndMarkerDragBox) - { - hwndMarkerDragBox = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT, markerDragBoxClassName, markerDragBoxClassName, WS_POPUP, markerDragBoxX, markerDragBoxY, COLUMN_FRAMENUM_WIDTH, listRowHeight, taseditorWindow.hwndTASEditor, NULL, fceu_hInstance, NULL); - ShowWindow(hwndMarkerDragBox, SW_SHOWNA); - } else - { - SetWindowPos(hwndMarkerDragBox, 0, markerDragBoxX, markerDragBoxY, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); - } - SetLayeredWindowAttributes(hwndMarkerDragBox, 0, MARKER_DRAG_BOX_ALPHA, LWA_ALPHA); - UpdateLayeredWindow(hwndMarkerDragBox, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA); - break; - } - case DRAG_MODE_SET: - case DRAG_MODE_UNSET: - { - POINT p; - if (GetCursorPos(&p)) - { - ScreenToClient(hwndList, &p); - int drawing_current_x = p.x + GetScrollPos(hwndList, SB_HORZ); - int drawing_current_y = p.y + GetScrollPos(hwndList, SB_VERT) * listRowHeight; - // draw (or erase) line from [drawing_current_x, drawing_current_y] to (drawing_last_x, drawing_last_y) - int total_dx = drawingLastX - drawing_current_x, total_dy = drawingLastY - drawing_current_y; - if (!shiftHeld) - { - // when user is not holding Shift, draw only vertical lines - total_dx = 0; - drawing_current_x = drawingLastX; - p.x = drawing_current_x - GetScrollPos(hwndList, SB_HORZ); - } - LVHITTESTINFO info; - int row_index, column_index, joy, bit; - int min_row_index = currMovieData.getNumRecords(), max_row_index = -1; - bool changes_made = false; - if (altHeld) - { - // special mode: draw pattern - int selection_beginning = selection.getCurrentRowsSelectionBeginning(); - if (selection_beginning >= 0) - { - // perform hit test - info.pt.x = p.x; - info.pt.y = p.y; - ListView_SubItemHitTest(hwndList, &info); - row_index = info.iItem; - if (row_index < 0) - row_index = ListView_GetTopIndex(hwndList) + (info.pt.y - listTopMargin) / listRowHeight; - // pad movie size if user tries to draw pattern below Piano Roll limit - if (row_index >= currMovieData.getNumRecords()) - currMovieData.insertEmpty(-1, row_index + 1 - currMovieData.getNumRecords()); - column_index = info.iSubItem; - if (row_index >= 0 && column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) - { - joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - bit = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - editor.setInputUsingPattern(selection_beginning, row_index, joy, bit, drawingStartTimestamp); - } - } - } else - { - double total_len = sqrt((double)(total_dx * total_dx + total_dy * total_dy)); - int drawing_min_line_len = listRowHeight; // = min(list_row_width, list_row_height) in pixels - for (double len = 0; len < total_len; len += drawing_min_line_len) - { - // perform hit test - info.pt.x = p.x + (len / total_len) * total_dx; - info.pt.y = p.y + (len / total_len) * total_dy; - ListView_SubItemHitTest(hwndList, &info); - row_index = info.iItem; - if (row_index < 0) - row_index = ListView_GetTopIndex(hwndList) + (info.pt.y - listTopMargin) / listRowHeight; - // pad movie size if user tries to draw below Piano Roll limit - if (row_index >= currMovieData.getNumRecords()) - currMovieData.insertEmpty(-1, row_index + 1 - currMovieData.getNumRecords()); - column_index = info.iSubItem; - if (row_index >= 0 && column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) - { - joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - bit = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if (dragMode == DRAG_MODE_SET && !currMovieData.records[row_index].checkBit(joy, bit)) - { - currMovieData.records[row_index].setBit(joy, bit); - changes_made = true; - if (min_row_index > row_index) min_row_index = row_index; - if (max_row_index < row_index) max_row_index = row_index; - } else if (dragMode == DRAG_MODE_UNSET && currMovieData.records[row_index].checkBit(joy, bit)) - { - currMovieData.records[row_index].clearBit(joy, bit); - changes_made = true; - if (min_row_index > row_index) min_row_index = row_index; - if (max_row_index < row_index) max_row_index = row_index; - } - } - } - if (changes_made) - { - if (dragMode == DRAG_MODE_SET) - greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_SET, min_row_index, max_row_index, 0, NULL, drawingStartTimestamp)); - else - greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_UNSET, min_row_index, max_row_index, 0, NULL, drawingStartTimestamp)); - } - } - drawingLastX = drawing_current_x; - drawingLastY = drawing_current_y; - } - break; - } - case DRAG_MODE_SELECTION: - { - int new_drag_selection_ending_frame = realRowUnderMouse; - // if trying to select above Piano Roll, select from frame 0 - if (new_drag_selection_ending_frame < 0) - new_drag_selection_ending_frame = 0; - else if (new_drag_selection_ending_frame >= currMovieData.getNumRecords()) - new_drag_selection_ending_frame = currMovieData.getNumRecords() - 1; - if (new_drag_selection_ending_frame >= 0 && new_drag_selection_ending_frame != dragSelectionEndingFrame) - { - // change Selection shape - if (new_drag_selection_ending_frame >= dragSelectionStartingFrame) - { - // selecting from upper to lower - if (dragSelectionEndingFrame < dragSelectionStartingFrame) - { - selection.clearRegionOfRowsSelection(dragSelectionEndingFrame, dragSelectionStartingFrame); - selection.setRegionOfRowsSelection(dragSelectionStartingFrame, new_drag_selection_ending_frame + 1); - } else // both ending_frame and new_ending_frame are >= starting_frame - { - if (dragSelectionEndingFrame > new_drag_selection_ending_frame) - selection.clearRegionOfRowsSelection(new_drag_selection_ending_frame + 1, dragSelectionEndingFrame + 1); - else - selection.setRegionOfRowsSelection(dragSelectionEndingFrame + 1, new_drag_selection_ending_frame + 1); - } - } else - { - // selecting from lower to upper - if (dragSelectionEndingFrame > dragSelectionStartingFrame) - { - selection.clearRegionOfRowsSelection(dragSelectionStartingFrame + 1, dragSelectionEndingFrame + 1); - selection.setRegionOfRowsSelection(new_drag_selection_ending_frame, dragSelectionStartingFrame); - } else // both ending_frame and new_ending_frame are <= starting_frame - { - if (dragSelectionEndingFrame < new_drag_selection_ending_frame) - selection.clearRegionOfRowsSelection(dragSelectionEndingFrame, new_drag_selection_ending_frame); - else - selection.setRegionOfRowsSelection(new_drag_selection_ending_frame, dragSelectionEndingFrame); - } - } - dragSelectionEndingFrame = new_drag_selection_ending_frame; - } - break; - } - case DRAG_MODE_DESELECTION: - { - int new_drag_selection_ending_frame = realRowUnderMouse; - // if trying to deselect above Piano Roll, deselect from frame 0 - if (new_drag_selection_ending_frame < 0) - new_drag_selection_ending_frame = 0; - else if (new_drag_selection_ending_frame >= currMovieData.getNumRecords()) - new_drag_selection_ending_frame = currMovieData.getNumRecords() - 1; - if (new_drag_selection_ending_frame >= 0 && new_drag_selection_ending_frame != dragSelectionEndingFrame) - { - // change Deselection shape - if (new_drag_selection_ending_frame >= dragSelectionStartingFrame) - // deselecting from upper to lower - selection.clearRegionOfRowsSelection(dragSelectionStartingFrame, new_drag_selection_ending_frame + 1); - else - // deselecting from lower to upper - selection.clearRegionOfRowsSelection(new_drag_selection_ending_frame, dragSelectionStartingFrame + 1); - dragSelectionEndingFrame = new_drag_selection_ending_frame; - } - break; - } - } - // update MarkerDragBox when it's flying away - if (hwndMarkerDragBox && dragMode != DRAG_MODE_MARKER) - { - markerDragCountdown--; - if (markerDragCountdown > 0) - { - markerDragBoxDY += MARKER_DRAG_GRAVITY; - markerDragBoxX += markerDragBoxDX; - markerDragBoxY += markerDragBoxDY; - SetWindowPos(hwndMarkerDragBox, 0, markerDragBoxX, markerDragBoxY, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); - SetLayeredWindowAttributes(hwndMarkerDragBox, 0, markerDragCountdown * MARKER_DRAG_ALPHA_PER_TICK, LWA_ALPHA); - UpdateLayeredWindow(hwndMarkerDragBox, 0, 0, 0, 0, 0, 0, &blend, ULW_ALPHA); - } else - { - DestroyWindow(hwndMarkerDragBox); - hwndMarkerDragBox = 0; - } - } - // scroll Piano Roll if user is dragging cursor outside - if (dragMode != DRAG_MODE_NONE || rightButtonDragMode) - { - POINT p; - if (GetCursorPos(&p)) - { - ScreenToClient(hwndList, &p); - RECT wrect; - GetClientRect(hwndList, &wrect); - int scroll_dx = 0, scroll_dy = 0; - if (dragMode != DRAG_MODE_MARKER) // in DRAG_MODE_MARKER user can't scroll Piano Roll horizontally - { - if (p.x < DRAG_SCROLLING_BORDER_SIZE) - scroll_dx = p.x - DRAG_SCROLLING_BORDER_SIZE; - else if (p.x > (wrect.right - wrect.left - DRAG_SCROLLING_BORDER_SIZE)) - scroll_dx = p.x - (wrect.right - wrect.left - DRAG_SCROLLING_BORDER_SIZE); - } - if (p.y < (listHeaderHeight + DRAG_SCROLLING_BORDER_SIZE)) - scroll_dy = p.y - (listHeaderHeight + DRAG_SCROLLING_BORDER_SIZE); - else if (p.y > (wrect.bottom - wrect.top - DRAG_SCROLLING_BORDER_SIZE)) - scroll_dy = p.y - (wrect.bottom - wrect.top - DRAG_SCROLLING_BORDER_SIZE); - if (scroll_dx || scroll_dy) - ListView_Scroll(hwndList, scroll_dx, scroll_dy); - } - } - // redraw list if needed - if (mustRedrawList) - { - InvalidateRect(hwndList, 0, false); - mustRedrawList = false; - } - - // once per 40 milliseconds update colors alpha in the Header - if (clock() > nextHeaderUpdateTime) - { - nextHeaderUpdateTime = clock() + HEADER_LIGHT_UPDATE_TICK; - bool changes_made = false; - int light_value = 0; - // 1 - update Frame# columns' heads - //if (GetAsyncKeyState(VK_MENU) & 0x8000) light_value = HEADER_LIGHT_HOLD; else - if (dragMode == DRAG_MODE_NONE && (headerItemUnderMouse == COLUMN_FRAMENUM || headerItemUnderMouse == COLUMN_FRAMENUM2)) - light_value = (selection.getCurrentRowsSelectionSize() > 0) ? HEADER_LIGHT_MOUSEOVER_SEL : HEADER_LIGHT_MOUSEOVER; - if (headerColors[COLUMN_FRAMENUM] < light_value) - { - headerColors[COLUMN_FRAMENUM]++; - changes_made = true; - } else if (headerColors[COLUMN_FRAMENUM] > light_value) - { - headerColors[COLUMN_FRAMENUM]--; - changes_made = true; - } - headerColors[COLUMN_FRAMENUM2] = headerColors[COLUMN_FRAMENUM]; - // 2 - update Input columns' heads - int i = numColumns-1; - if (i == COLUMN_FRAMENUM2) i--; - for (; i >= COLUMN_JOYPAD1_A; i--) - { - light_value = 0; - if (recorder.currentJoypadData[(i - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS] & (1 << ((i - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS))) - light_value = HEADER_LIGHT_HOLD; - else if (dragMode == DRAG_MODE_NONE && headerItemUnderMouse == i) - light_value = (selection.getCurrentRowsSelectionSize() > 0) ? HEADER_LIGHT_MOUSEOVER_SEL : HEADER_LIGHT_MOUSEOVER; - if (headerColors[i] < light_value) - { - headerColors[i]++; - changes_made = true; - } else if (headerColors[i] > light_value) - { - headerColors[i]--; - changes_made = true; - } - } - // 3 - redraw - if (changes_made) - redrawHeader(); - } - -} - -void PIANO_ROLL::save(EMUFILE *os, bool really_save) -{ - if (really_save) - { - updateLinesCount(); - // write "PIANO_ROLL" string - os->fwrite(pianoRollSaveID, PIANO_ROLL_ID_LEN); - // write current top item - int top_item = ListView_GetTopIndex(hwndList); - write32le(top_item, os); - } else - { - // write "PIANO_ROLX" string - os->fwrite(pianoRollSkipSaveID, PIANO_ROLL_ID_LEN); - } -} -// returns true if couldn't load -bool PIANO_ROLL::load(EMUFILE *is, unsigned int offset) -{ - reset(); - updateLinesCount(); - if (offset) - { - if (is->fseek(offset, SEEK_SET)) goto error; - } else - { - // scroll to the beginning - ListView_EnsureVisible(hwndList, 0, FALSE); - return false; - } - // read "PIANO_ROLL" string - char save_id[PIANO_ROLL_ID_LEN]; - if ((int)is->fread(save_id, PIANO_ROLL_ID_LEN) < PIANO_ROLL_ID_LEN) goto error; - if (!strcmp(pianoRollSkipSaveID, save_id)) - { - // string says to skip loading Piano Roll - FCEU_printf("No Piano Roll data in the file\n"); - // scroll to the beginning - ListView_EnsureVisible(hwndList, 0, FALSE); - return false; - } - if (strcmp(pianoRollSaveID, save_id)) goto error; // string is not valid - // read current top item and scroll Piano Roll there - int top_item; - if (!read32le(&top_item, is)) goto error; - ListView_EnsureVisible(hwndList, currMovieData.getNumRecords() - 1, FALSE); - ListView_EnsureVisible(hwndList, top_item, FALSE); - return false; -error: - FCEU_printf("Error loading Piano Roll data\n"); - // scroll to the beginning - ListView_EnsureVisible(hwndList, 0, FALSE); - return true; -} -// ---------------------------------------------------------------------- -void PIANO_ROLL::redraw() -{ - mustRedrawList = true; - mustCheckItemUnderMouse = true; -} -void PIANO_ROLL::redrawRow(int index) -{ - ListView_RedrawItems(hwndList, index, index); -} -void PIANO_ROLL::redrawHeader() -{ - InvalidateRect(hwndHeader, 0, false); -} - -// ------------------------------------------------------------------------- -void PIANO_ROLL::updateLinesCount() -{ - // update the number of items in the list - int currLVItemCount = ListView_GetItemCount(hwndList); - int movie_size = currMovieData.getNumRecords(); - if (currLVItemCount != movie_size) - ListView_SetItemCountEx(hwndList, movie_size, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL); -} -bool PIANO_ROLL::isLineVisible(int frame) -{ - int top = ListView_GetTopIndex(hwndList); - if (frame >= top && frame < top + ListView_GetCountPerPage(hwndList)) - return true; - return false; -} - -void PIANO_ROLL::centerListAroundLine(int rowIndex) -{ - int numItemsPerPage = ListView_GetCountPerPage(hwndList); - int lowerBorder = (numItemsPerPage - 1) / 2; - int upperBorder = (numItemsPerPage - 1) - lowerBorder; - int index = rowIndex + lowerBorder; - if (index >= currMovieData.getNumRecords()) - index = currMovieData.getNumRecords()-1; - ListView_EnsureVisible(hwndList, index, false); - index = rowIndex - upperBorder; - if (index < 0) - index = 0; - ListView_EnsureVisible(hwndList, index, false); -} -void PIANO_ROLL::setListTopRow(int rowIndex) -{ - ListView_Scroll(hwndList, 0, listRowHeight * (rowIndex - ListView_GetTopIndex(hwndList))); -} - -void PIANO_ROLL::recalculatePlaybackCursorOffset() -{ - int frame = playback.getPauseFrame(); - if (frame < 0) - frame = currFrameCounter; - - playbackCursorOffset = frame - ListView_GetTopIndex(hwndList); - if (playbackCursorOffset < 0) - { - playbackCursorOffset = 0; - } else - { - int numItemsPerPage = ListView_GetCountPerPage(hwndList); - if (playbackCursorOffset > numItemsPerPage - 1) - playbackCursorOffset = numItemsPerPage - 1; - } -} - -void PIANO_ROLL::followPlaybackCursor() -{ - centerListAroundLine(currFrameCounter); -} -void PIANO_ROLL::followPlaybackCursorIfNeeded(bool followPauseframe) -{ - if (taseditorConfig.followPlaybackCursor) - { - if (playback.getPauseFrame() < 0) - ListView_EnsureVisible(hwndList, currFrameCounter, FALSE); - else if (followPauseframe) - ListView_EnsureVisible(hwndList, playback.getPauseFrame(), FALSE); - } -} -void PIANO_ROLL::updatePlaybackCursorPositionInPianoRoll() -{ - if (taseditorConfig.followPlaybackCursor) - { - if (playback.getPauseFrame() < 0) - setListTopRow(currFrameCounter - playbackCursorOffset); - } -} -void PIANO_ROLL::followPauseframe() -{ - if (playback.getPauseFrame() >= 0) - centerListAroundLine(playback.getPauseFrame()); -} -void PIANO_ROLL::followUndoHint() -{ - int keyframe = history.getUndoHint(); - if (taseditorConfig.followUndoContext && keyframe >= 0) - { - if (!isLineVisible(keyframe)) - centerListAroundLine(keyframe); - } -} -void PIANO_ROLL::followSelection() -{ - RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection(); - if (current_selection->size() == 0) return; - - int list_items = ListView_GetCountPerPage(hwndList); - int selection_start = *current_selection->begin(); - int selection_end = *current_selection->rbegin(); - int selection_items = 1 + selection_end - selection_start; - - if (selection_items <= list_items) - { - // selected region can fit in screen - int lower_border = (list_items - selection_items) / 2; - int upper_border = (list_items - selection_items) - lower_border; - int index = selection_end + lower_border; - if (index >= currMovieData.getNumRecords()) - index = currMovieData.getNumRecords()-1; - ListView_EnsureVisible(hwndList, index, false); - index = selection_start - upper_border; - if (index < 0) - index = 0; - ListView_EnsureVisible(hwndList, index, false); - } else - { - // selected region is too big to fit in screen - // oh well, just center at selection_start - centerListAroundLine(selection_start); - } -} -void PIANO_ROLL::followMarker(int markerID) -{ - if (markerID > 0) - { - int frame = markersManager.getMarkerFrameNumber(markerID); - if (frame >= 0) - centerListAroundLine(frame); - } else - { - ListView_EnsureVisible(hwndList, 0, false); - } -} -void PIANO_ROLL::ensureTheLineIsVisible(int rowIndex) -{ - ListView_EnsureVisible(hwndList, rowIndex, false); -} - -void PIANO_ROLL::handleColumnSet(int column, bool altPressed) -{ - if (column == COLUMN_FRAMENUM || column == COLUMN_FRAMENUM2) - { - // user clicked on "Frame#" - apply ColumnSet to Markers - if (altPressed) - { - if (editor.handleColumnSetUsingPattern()) - setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); - } else - { - if (editor.handleColumnSet()) - setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); - } - } else - { - // user clicked on Input column - apply ColumnSet to Input - int joy = (column - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int button = (column - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if (altPressed) - { - if (editor.handleInputColumnSetUsingPattern(joy, button)) - setLightInHeaderColumn(column, HEADER_LIGHT_MAX); - } else - { - if (editor.handleInputColumnSet(joy, button)) - setLightInHeaderColumn(column, HEADER_LIGHT_MAX); - } - } -} - -void PIANO_ROLL::setLightInHeaderColumn(int column, int level) -{ - if (column < COLUMN_FRAMENUM || column >= numColumns || level < 0 || level > HEADER_LIGHT_MAX) - return; - - if (headerColors[column] != level) - { - headerColors[column] = level; - redrawHeader(); - nextHeaderUpdateTime = clock() + HEADER_LIGHT_UPDATE_TICK; - } -} - -void PIANO_ROLL::startDraggingPlaybackCursor() -{ - if (dragMode == DRAG_MODE_NONE) - { - dragMode = DRAG_MODE_PLAYBACK; - // call it once - handlePlaybackCursorDragging(); - } -} -void PIANO_ROLL::startDraggingMarker(int mouseX, int mouseY, int rowIndex, int columnIndex) -{ - if (dragMode == DRAG_MODE_NONE) - { - // start dragging the Marker - dragMode = DRAG_MODE_MARKER; - markerDragFrameNumber = rowIndex; - markerDragCountdown = MARKER_DRAG_COUNTDOWN_MAX; - RECT temp_rect; - if (ListView_GetSubItemRect(hwndList, rowIndex, columnIndex, LVIR_BOUNDS, &temp_rect)) - { - markerDragBoxDX = mouseX - temp_rect.left; - markerDragBoxDY = mouseY - temp_rect.top; - } else - { - markerDragBoxDX = 0; - markerDragBoxDY = 0; - } - // redraw the row to show that Marker was lifted - redrawRow(rowIndex); - } -} -void PIANO_ROLL::startSelectingDrag(int start_frame) -{ - if (dragMode == DRAG_MODE_NONE) - { - dragMode = DRAG_MODE_SELECTION; - dragSelectionStartingFrame = start_frame; - dragSelectionEndingFrame = dragSelectionStartingFrame; // assuming that start_frame is already selected - } -} -void PIANO_ROLL::startDeselectingDrag(int start_frame) -{ - if (dragMode == DRAG_MODE_NONE) - { - dragMode = DRAG_MODE_DESELECTION; - dragSelectionStartingFrame = start_frame; - dragSelectionEndingFrame = dragSelectionStartingFrame; // assuming that start_frame is already deselected - } -} - -void PIANO_ROLL::handlePlaybackCursorDragging() -{ - int target_frame = realRowUnderMouse; - if (target_frame < 0) - target_frame = 0; - if (currFrameCounter != target_frame) - playback.jump(target_frame); -} - -void PIANO_ROLL::finishDrag() -{ - switch (dragMode) - { - case DRAG_MODE_MARKER: - { - // place Marker here - if (markersManager.getMarkerAtFrame(markerDragFrameNumber)) - { - POINT p = {0, 0}; - GetCursorPos(&p); - int mouse_x = p.x, mouse_y = p.y; - ScreenToClient(hwndList, &p); - RECT wrect; - GetClientRect(hwndList, &wrect); - if (p.x < 0 || p.x > (wrect.right - wrect.left) || p.y < 0 || p.y > (wrect.bottom - wrect.top)) - { - // user threw the Marker away - markersManager.removeMarkerFromFrame(markerDragFrameNumber); - redrawRow(markerDragFrameNumber); - history.registerMarkersChange(MODTYPE_MARKER_REMOVE, markerDragFrameNumber); - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - // calculate vector of movement - POINT p = {0, 0}; - GetCursorPos(&p); - markerDragBoxDX = (mouse_x - markerDragBoxDX) - markerDragBoxX; - markerDragBoxDY = (mouse_y - markerDragBoxDY) - markerDragBoxY; - if (markerDragBoxDX || markerDragBoxDY) - { - // limit max speed - double marker_drag_box_speed = sqrt((double)(markerDragBoxDX * markerDragBoxDX + markerDragBoxDY * markerDragBoxDY)); - if (marker_drag_box_speed > MARKER_DRAG_MAX_SPEED) - { - markerDragBoxDX *= MARKER_DRAG_MAX_SPEED / marker_drag_box_speed; - markerDragBoxDY *= MARKER_DRAG_MAX_SPEED / marker_drag_box_speed; - } - } - markerDragCountdown = MARKER_DRAG_COUNTDOWN_MAX; - } else - { - if (rowUnderMouse >= 0 && (columnUnderMouse <= COLUMN_FRAMENUM || columnUnderMouse >= COLUMN_FRAMENUM2)) - { - if (rowUnderMouse == markerDragFrameNumber) - { - // it was just double-click and release - // if Selection points at dragged Marker, set focus to lower Note edit field - int dragged_marker_id = markersManager.getMarkerAtFrame(markerDragFrameNumber); - int selection_marker_id = markersManager.getMarkerAboveFrame(selection.getCurrentRowsSelectionBeginning()); - if (dragged_marker_id == selection_marker_id) - { - SetFocus(selection.hwndSelectionMarkerEditField); - // select all text in case user wants to overwrite it - SendMessage(selection.hwndSelectionMarkerEditField, EM_SETSEL, 0, -1); - } - } else if (markersManager.getMarkerAtFrame(rowUnderMouse)) - { - int dragged_marker_id = markersManager.getMarkerAtFrame(markerDragFrameNumber); - int destination_marker_id = markersManager.getMarkerAtFrame(rowUnderMouse); - // swap Notes of these Markers - char dragged_marker_note[MAX_NOTE_LEN]; - strcpy(dragged_marker_note, markersManager.getNoteCopy(dragged_marker_id).c_str()); - if (strcmp(markersManager.getNoteCopy(destination_marker_id).c_str(), dragged_marker_note)) - { - // notes are different, swap them - markersManager.setNote(dragged_marker_id, markersManager.getNoteCopy(destination_marker_id).c_str()); - markersManager.setNote(destination_marker_id, dragged_marker_note); - history.registerMarkersChange(MODTYPE_MARKER_SWAP, markerDragFrameNumber, rowUnderMouse); - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); - } - } else - { - // move Marker - int new_marker_id = markersManager.setMarkerAtFrame(rowUnderMouse); - if (new_marker_id) - { - markersManager.setNote(new_marker_id, markersManager.getNoteCopy(markersManager.getMarkerAtFrame(markerDragFrameNumber)).c_str()); - // and delete it from old frame - markersManager.removeMarkerFromFrame(markerDragFrameNumber); - history.registerMarkersChange(MODTYPE_MARKER_DRAG, markerDragFrameNumber, rowUnderMouse, markersManager.getNoteCopy(markersManager.getMarkerAtFrame(rowUnderMouse)).c_str()); - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - setLightInHeaderColumn(COLUMN_FRAMENUM, HEADER_LIGHT_MAX); - redrawRow(rowUnderMouse); - } - } - } - redrawRow(markerDragFrameNumber); - if (hwndMarkerDragBox) - { - DestroyWindow(hwndMarkerDragBox); - hwndMarkerDragBox = 0; - } - } - } else - { - // abort drag - if (hwndMarkerDragBox) - { - DestroyWindow(hwndMarkerDragBox); - hwndMarkerDragBox = 0; - } - } - break; - } - } - dragMode = DRAG_MODE_NONE; - mustCheckItemUnderMouse = true; -} - -void PIANO_ROLL::getDispInfo(NMLVDISPINFO* nmlvDispInfo) -{ - LVITEM& item = nmlvDispInfo->item; - if (item.mask & LVIF_TEXT) - { - switch(item.iSubItem) - { - case COLUMN_ICONS: - { - item.iImage = bookmarks.findBookmarkAtFrame(item.iItem); - if (item.iImage < 0) - { - // no bookmark at this frame - if (item.iItem == playback.getLastPosition()) - { - if (item.iItem == currFrameCounter) - item.iImage = GREEN_BLUE_ARROW_IMAGE_ID; - else - item.iImage = GREEN_ARROW_IMAGE_ID; - } else if (item.iItem == currFrameCounter) - { - item.iImage = BLUE_ARROW_IMAGE_ID; - } - } else - { - // bookmark at this frame - if (item.iItem == playback.getLastPosition()) - item.iImage += BOOKMARKS_WITH_GREEN_ARROW; - else if (item.iItem == currFrameCounter) - item.iImage += BOOKMARKS_WITH_BLUE_ARROW; - } - break; - } - case COLUMN_FRAMENUM: - case COLUMN_FRAMENUM2: - { - U32ToDecStr(item.pszText, item.iItem, DIGITS_IN_FRAMENUM); - break; - } - case COLUMN_JOYPAD1_A: case COLUMN_JOYPAD1_B: case COLUMN_JOYPAD1_S: case COLUMN_JOYPAD1_T: - case COLUMN_JOYPAD1_U: case COLUMN_JOYPAD1_D: case COLUMN_JOYPAD1_L: case COLUMN_JOYPAD1_R: - case COLUMN_JOYPAD2_A: case COLUMN_JOYPAD2_B: case COLUMN_JOYPAD2_S: case COLUMN_JOYPAD2_T: - case COLUMN_JOYPAD2_U: case COLUMN_JOYPAD2_D: case COLUMN_JOYPAD2_L: case COLUMN_JOYPAD2_R: - case COLUMN_JOYPAD3_A: case COLUMN_JOYPAD3_B: case COLUMN_JOYPAD3_S: case COLUMN_JOYPAD3_T: - case COLUMN_JOYPAD3_U: case COLUMN_JOYPAD3_D: case COLUMN_JOYPAD3_L: case COLUMN_JOYPAD3_R: - case COLUMN_JOYPAD4_A: case COLUMN_JOYPAD4_B: case COLUMN_JOYPAD4_S: case COLUMN_JOYPAD4_T: - case COLUMN_JOYPAD4_U: case COLUMN_JOYPAD4_D: case COLUMN_JOYPAD4_L: case COLUMN_JOYPAD4_R: - { - int joy = (item.iSubItem - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int bit = (item.iSubItem - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - uint8 data = ((int)currMovieData.records.size() > item.iItem) ? currMovieData.records[item.iItem].joysticks[joy] : 0; - if (data & (1<nmcd.dwDrawStage) - { - case CDDS_PREPAINT: - return CDRF_NOTIFYITEMDRAW; - case CDDS_ITEMPREPAINT: - return CDRF_NOTIFYSUBITEMDRAW; - case CDDS_SUBITEMPREPAINT: - { - int cell_x = msg->iSubItem; - int cell_y = msg->nmcd.dwItemSpec; - if (cell_x > COLUMN_ICONS) - { - int frame_lag = greenzone.lagLog.getLagInfoAtFrame(cell_y); - // text color - if (taseditorConfig.enableHotChanges && cell_x >= COLUMN_JOYPAD1_A && cell_x <= COLUMN_JOYPAD4_R) - msg->clrText = hotChangesColors[history.getCurrentSnapshot().inputlog.getHotChangesInfo(cell_y, cell_x - COLUMN_JOYPAD1_A)]; - else - msg->clrText = NORMAL_TEXT_COLOR; - // bg color and text font - if (cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) - { - // font - if (markersManager.getMarkerAtFrame(cell_y)) - SelectObject(msg->nmcd.hdc, hMainListSelectFont); - else - SelectObject(msg->nmcd.hdc, hMainListFont); - // bg - // frame number - if (cell_y == history.getUndoHint()) - { - // undo hint here - if (markersManager.getMarkerAtFrame(cell_y) && (dragMode != DRAG_MODE_MARKER || markerDragFrameNumber != cell_y)) - { - msg->clrTextBk = (taseditorConfig.bindMarkersToInput) ? BINDMARKED_UNDOHINT_FRAMENUM_COLOR : MARKED_UNDOHINT_FRAMENUM_COLOR; - } else - { - msg->clrTextBk = UNDOHINT_FRAMENUM_COLOR; - } - } else if (cell_y == currFrameCounter || cell_y == (playback.getFlashingPauseFrame() - 1)) - { - // this is current frame - if (markersManager.getMarkerAtFrame(cell_y) && (dragMode != DRAG_MODE_MARKER || markerDragFrameNumber != cell_y)) - { - msg->clrTextBk = (taseditorConfig.bindMarkersToInput) ? CUR_BINDMARKED_FRAMENUM_COLOR : CUR_MARKED_FRAMENUM_COLOR; - } else - { - msg->clrTextBk = CUR_FRAMENUM_COLOR; - } - } else if (markersManager.getMarkerAtFrame(cell_y) && (dragMode != DRAG_MODE_MARKER || markerDragFrameNumber != cell_y)) - { - // this is marked frame - msg->clrTextBk = (taseditorConfig.bindMarkersToInput) ? BINDMARKED_FRAMENUM_COLOR : MARKED_FRAMENUM_COLOR; - } else if (cell_y < greenzone.getSize()) - { - if (!greenzone.isSavestateEmpty(cell_y)) - { - // the frame is normal Greenzone frame - if (frame_lag == LAGGED_YES) - msg->clrTextBk = LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY8TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY4TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY2ND)) - { - // the frame is in a gap (in Greenzone tail) - if (frame_lag == LAGGED_YES) - msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR; - } else - { - // the frame is above Greenzone tail - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_FRAMENUM_COLOR; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_FRAMENUM_COLOR; - else - msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } - } else - { - // the frame is below Greenzone head - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_FRAMENUM_COLOR; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_FRAMENUM_COLOR; - else - msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } - } else if ((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) - { - // pad 1 or 3 - // font: empty cells have "SelectFont" (so that "-" is wide), non-empty have normal font - int joy = (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int bit = (cell_x - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if ((int)currMovieData.records.size() <= cell_y || - ((currMovieData.records[cell_y].joysticks[joy]) & (1<nmcd.hdc, hMainListFont); - else - SelectObject(msg->nmcd.hdc, hMainListSelectFont); - // bg - if (cell_y == history.getUndoHint()) - { - // undo hint here - msg->clrTextBk = UNDOHINT_INPUT_COLOR1; - } else if (cell_y == currFrameCounter || cell_y == (playback.getFlashingPauseFrame() - 1)) - { - // this is current frame - msg->clrTextBk = CUR_INPUT_COLOR1; - } else if (cell_y < greenzone.getSize()) - { - if (!greenzone.isSavestateEmpty(cell_y)) - { - // the frame is normal Greenzone frame - if (frame_lag == LAGGED_YES) - msg->clrTextBk = LAG_INPUT_COLOR1; - else - msg->clrTextBk = GREENZONE_INPUT_COLOR1; - } else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY8TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY4TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY2ND)) - { - // the frame is in a gap (in Greenzone tail) - if (frame_lag == LAGGED_YES) - msg->clrTextBk = PALE_LAG_INPUT_COLOR1; - else - msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR1; - } else - { - // the frame is above Greenzone tail - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR1; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR1; - else - msg->clrTextBk = NORMAL_INPUT_COLOR1; - } - } else - { - // the frame is below Greenzone head - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR1; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR1; - else - msg->clrTextBk = NORMAL_INPUT_COLOR1; - } - } else if ((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) - { - // pad 2 or 4 - // font: empty cells have "SelectFont", non-empty have normal font - int joy = (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int bit = (cell_x - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if ((int)currMovieData.records.size() <= cell_y || - ((currMovieData.records[cell_y].joysticks[joy]) & (1<nmcd.hdc, hMainListFont); - else - SelectObject(msg->nmcd.hdc, hMainListSelectFont); - // bg - if (cell_y == history.getUndoHint()) - { - // undo hint here - msg->clrTextBk = UNDOHINT_INPUT_COLOR2; - } else if (cell_y == currFrameCounter || cell_y == (playback.getFlashingPauseFrame() - 1)) - { - // this is current frame - msg->clrTextBk = CUR_INPUT_COLOR2; - } else if (cell_y < greenzone.getSize()) - { - if (!greenzone.isSavestateEmpty(cell_y)) - { - // the frame is normal Greenzone frame - if (frame_lag == LAGGED_YES) - msg->clrTextBk = LAG_INPUT_COLOR2; - else - msg->clrTextBk = GREENZONE_INPUT_COLOR2; - } else if (!greenzone.isSavestateEmpty(cell_y & EVERY16TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY8TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY4TH) - || !greenzone.isSavestateEmpty(cell_y & EVERY2ND)) - { - // the frame is in a gap (in Greenzone tail) - if (frame_lag == LAGGED_YES) - msg->clrTextBk = PALE_LAG_INPUT_COLOR2; - else - msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR2; - } else - { - // the frame is above Greenzone tail - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR2; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR2; - else - msg->clrTextBk = NORMAL_INPUT_COLOR2; - } - } else - { - // the frame is below Greenzone head - if (frame_lag == LAGGED_YES) - msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR2; - else if (frame_lag == LAGGED_NO) - msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR2; - else - msg->clrTextBk = NORMAL_INPUT_COLOR2; - } - } - } - } - return CDRF_DODEFAULT; - default: - return CDRF_DODEFAULT; - } -} - -LONG PIANO_ROLL::handleHeaderCustomDraw(NMLVCUSTOMDRAW* msg) -{ - switch(msg->nmcd.dwDrawStage) - { - case CDDS_PREPAINT: - SelectObject(msg->nmcd.hdc, hMainListFont); - return CDRF_NOTIFYITEMDRAW; - case CDDS_ITEMPREPAINT: - { - int cell_x = msg->nmcd.dwItemSpec; - if (cell_x < numColumns) - { - int cur_color = headerColors[cell_x]; - if (cur_color) - SetTextColor(msg->nmcd.hdc, headerLightsColors[cur_color]); - } - } - default: - return CDRF_DODEFAULT; - } -} - -// ---------------------------------------------------- -void PIANO_ROLL::handleRightClick(LVHITTESTINFO& info) -{ - if (selection.isRowSelected(info.iItem)) - { - RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection(); - HMENU sub = GetSubMenu(hrMenu, 0); - SetMenuDefaultItem(sub, ID_SELECTED_SETMARKERS, false); - // inspect current Selection and disable inappropriate menu items - RowsSelection::iterator current_selection_begin(current_selection->begin()); - RowsSelection::iterator current_selection_end(current_selection->end()); - bool set_found = false, unset_found = false; - for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++) - { - if (markersManager.getMarkerAtFrame(*it)) - set_found = true; - else - unset_found = true; - } - if (unset_found) - EnableMenuItem(sub, ID_SELECTED_SETMARKERS, MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(sub, ID_SELECTED_SETMARKERS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); - if (set_found) - EnableMenuItem(sub, ID_SELECTED_REMOVEMARKERS, MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(sub, ID_SELECTED_REMOVEMARKERS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); - POINT pt = info.pt; - ClientToScreen(hwndList, &pt); - TrackPopupMenu(sub, 0, pt.x, pt.y, 0, taseditorWindow.hwndTASEditor, 0); - } -} - -bool PIANO_ROLL::checkIfTheresAnIconAtFrame(int frame) -{ - if (frame == currFrameCounter) - return true; - if (frame == playback.getLastPosition()) - return true; - if (frame == playback.getPauseFrame()) - return true; - if (bookmarks.findBookmarkAtFrame(frame) >= 0) - return true; - return false; -} - -void PIANO_ROLL::crossGaps(int zDelta) -{ - POINT p; - if (GetCursorPos(&p)) - { - ScreenToClient(hwndList, &p); - RECT wrect; - GetClientRect(hwndList, &wrect); - if (p.x >= 0 && p.x < wrect.right - wrect.left && p.y >= listTopMargin && p.y < wrect.bottom - wrect.top) - { - // perform hit test - LVHITTESTINFO info; - info.pt.x = p.x; - info.pt.y = p.y; - ListView_SubItemHitTest(hwndList, &info); - int row_index = info.iItem; - int column_index = info.iSubItem; - if (row_index >= 0 && column_index >= COLUMN_ICONS && column_index <= COLUMN_FRAMENUM2) - { - if (column_index == COLUMN_ICONS) - { - // cross gaps in Icons - if (zDelta < 0) - { - // search down - int last_frame = currMovieData.getNumRecords() - 1; - if (row_index < last_frame) - { - int frame = row_index + 1; - bool result_of_closest_frame = checkIfTheresAnIconAtFrame(frame); - while ((++frame) <= last_frame) - { - if (checkIfTheresAnIconAtFrame(frame) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } else - { - // search up - int first_frame = 0; - if (row_index > first_frame) - { - int frame = row_index - 1; - bool result_of_closest_frame = checkIfTheresAnIconAtFrame(frame); - while ((--frame) >= first_frame) - { - if (checkIfTheresAnIconAtFrame(frame) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } - } else if (column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) - { - // cross gaps in Markers - if (zDelta < 0) - { - // search down - int last_frame = currMovieData.getNumRecords() - 1; - if (row_index < last_frame) - { - int frame = row_index + 1; - bool result_of_closest_frame = (markersManager.getMarkerAtFrame(frame) != 0); - while ((++frame) <= last_frame) - { - if ((markersManager.getMarkerAtFrame(frame) != 0) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } else - { - // search up - int first_frame = 0; - if (row_index > first_frame) - { - int frame = row_index - 1; - bool result_of_closest_frame = (markersManager.getMarkerAtFrame(frame) != 0); - while ((--frame) >= first_frame) - { - if ((markersManager.getMarkerAtFrame(frame) != 0) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } - } else - { - // cross gaps in Input - int joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int button = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - if (zDelta < 0) - { - // search down - int last_frame = currMovieData.getNumRecords() - 1; - if (row_index < last_frame) - { - int frame = row_index + 1; - bool result_of_closest_frame = currMovieData.records[frame].checkBit(joy, button); - while ((++frame) <= last_frame) - { - if (currMovieData.records[frame].checkBit(joy, button) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } else - { - // search up - int first_frame = 0; - if (row_index > first_frame) - { - int frame = row_index - 1; - bool result_of_closest_frame = currMovieData.records[frame].checkBit(joy, button); - while ((--frame) >= first_frame) - { - if (currMovieData.records[frame].checkBit(joy, button) != result_of_closest_frame) - { - // found different result, so we crossed the gap - ListView_Scroll(hwndList, 0, listRowHeight * (frame - row_index)); - break; - } - } - } - } - } - } - } - } -} -// ------------------------------------------------------------------------- -LRESULT APIENTRY headerWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - extern PIANO_ROLL pianoRoll; - switch(msg) - { - case WM_SETCURSOR: - // no column resizing cursor, always show arrow - SetCursor(LoadCursor(0, IDC_ARROW)); - return true; - case WM_MOUSEMOVE: - { - // perform hit test on header items - HD_HITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam) + HEADER_DX_FIX; - info.pt.y = GET_Y_LPARAM(lParam); - SendMessage(hWnd, HDM_HITTEST, 0, (LPARAM)&info); - pianoRoll.headerItemUnderMouse = info.iItem; - // ensure that WM_MOUSELEAVE will be catched - TrackMouseEvent(&pianoRoll.tme); - break; - } - case WM_MOUSELEAVE: - { - pianoRoll.headerItemUnderMouse = -1; - break; - } - case WM_LBUTTONDOWN: - case WM_LBUTTONDBLCLK: - { - if (selection.getCurrentRowsSelectionSize()) - { - // perform hit test on header items - HD_HITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam) + HEADER_DX_FIX; - info.pt.y = GET_Y_LPARAM(lParam); - SendMessage(hWnd, HDM_HITTEST, 0, (LPARAM)&info); - if (info.iItem >= COLUMN_FRAMENUM && info.iItem <= COLUMN_FRAMENUM2) - pianoRoll.handleColumnSet(info.iItem, (GetKeyState(VK_MENU) < 0)); - } - } - return true; - } - return CallWindowProc(hwndHeaderOldWndproc, hWnd, msg, wParam, lParam); -} - -// The subclass wndproc for the listview -LRESULT APIENTRY listWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - extern PIANO_ROLL pianoRoll; - switch(msg) - { - case WM_CHAR: - case WM_KILLFOCUS: - return 0; - case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT) - { - pianoRoll.mustCheckItemUnderMouse = true; - return true; - } - break; - case WM_MOUSEMOVE: - { - pianoRoll.mustCheckItemUnderMouse = true; - return 0; - } - case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->hwndFrom == pianoRoll.hwndHeader) - { - switch (((LPNMHDR)lParam)->code) - { - case HDN_BEGINTRACKW: - case HDN_BEGINTRACKA: - case HDN_TRACK: - return true; // no column resizing - case NM_CUSTOMDRAW: - return pianoRoll.handleHeaderCustomDraw((NMLVCUSTOMDRAW*)lParam); - } - } - break; - } - case WM_KEYDOWN: - return 0; - case WM_TIMER: - // disable timer of entering edit mode (there's no edit mode anyway) - return 0; - case WM_LBUTTONDOWN: - case WM_LBUTTONDBLCLK: - { - int fwKeys = GET_KEYSTATE_WPARAM(wParam); - bool alt_pressed = (GetKeyState(VK_MENU) < 0); - // perform hit test - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - ListView_SubItemHitTest(hWnd, &info); - int row_index = info.iItem; - int column_index = info.iSubItem; - if (column_index == COLUMN_ICONS) - { - // clicked on the "icons" column - pianoRoll.startDraggingPlaybackCursor(); - } else if (column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) - { - // clicked on the "Frame#" column - if (row_index >= 0) - { - if (msg == WM_LBUTTONDBLCLK) - { - // doubleclick - set Marker and start dragging it - if (!markersManager.getMarkerAtFrame(row_index)) - { - if (markersManager.setMarkerAtFrame(row_index)) - { - selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; - history.registerMarkersChange(MODTYPE_MARKER_SET, row_index); - pianoRoll.redrawRow(row_index); - } - } - pianoRoll.startDraggingMarker(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), row_index, column_index); - } else - { - if (fwKeys & MK_SHIFT) - { - // select region from selection_beginning to row_index - int selection_beginning = selection.getCurrentRowsSelectionBeginning(); - if (selection_beginning >= 0) - { - if (selection_beginning < row_index) - selection.setRegionOfRowsSelection(selection_beginning, row_index + 1); - else - selection.setRegionOfRowsSelection(row_index, selection_beginning + 1); - } - pianoRoll.startSelectingDrag(row_index); - } else if (alt_pressed) - { - // make Selection by Pattern - int selection_beginning = selection.getCurrentRowsSelectionBeginning(); - if (selection_beginning >= 0) - { - selection.clearAllRowsSelection(); - if (selection_beginning < row_index) - selection.setRegionOfRowsSelectionUsingPattern(selection_beginning, row_index); - else - selection.setRegionOfRowsSelectionUsingPattern(row_index, selection_beginning); - } - if (selection.isRowSelected(row_index)) - pianoRoll.startDeselectingDrag(row_index); - else - pianoRoll.startSelectingDrag(row_index); - } else if (fwKeys & MK_CONTROL) - { - // clone current selection, so that user will be able to revert - if (selection.getCurrentRowsSelectionSize() > 0) - selection.addCurrentSelectionToHistory(); - if (selection.isRowSelected(row_index)) - { - selection.clearSingleRowSelection(row_index); - pianoRoll.startDeselectingDrag(row_index); - } else - { - selection.setRowSelection(row_index); - pianoRoll.startSelectingDrag(row_index); - } - } else // just click - { - selection.clearAllRowsSelection(); - selection.setRowSelection(row_index); - pianoRoll.startSelectingDrag(row_index); - } - } - } - } else if (column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R) - { - // clicked on Input - if (row_index >= 0) - { - if (!alt_pressed && !(fwKeys & MK_SHIFT)) - { - // clicked without Shift/Alt - bring Selection cursor to this row - selection.clearAllRowsSelection(); - selection.setRowSelection(row_index); - } - // toggle Input - pianoRoll.drawingStartTimestamp = clock(); - int joy = (column_index - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; - int button = (column_index - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; - int selection_beginning = selection.getCurrentRowsSelectionBeginning(); - if (alt_pressed && selection_beginning >= 0) - editor.setInputUsingPattern(selection_beginning, row_index, joy, button, pianoRoll.drawingStartTimestamp); - else if ((fwKeys & MK_SHIFT) && selection_beginning >= 0) - editor.toggleInput(selection_beginning, row_index, joy, button, pianoRoll.drawingStartTimestamp); - else - editor.toggleInput(row_index, row_index, joy, button, pianoRoll.drawingStartTimestamp); - // and start dragging/drawing - if (pianoRoll.dragMode == DRAG_MODE_NONE) - { - if (taseditorConfig.drawInputByDragging) - { - // if clicked this click created buttonpress, then start painting, else start erasing - if (currMovieData.records[row_index].checkBit(joy, button)) - pianoRoll.dragMode = DRAG_MODE_SET; - else - pianoRoll.dragMode = DRAG_MODE_UNSET; - pianoRoll.drawingLastX = GET_X_LPARAM(lParam) + GetScrollPos(pianoRoll.hwndList, SB_HORZ); - pianoRoll.drawingLastY = GET_Y_LPARAM(lParam) + GetScrollPos(pianoRoll.hwndList, SB_VERT) * pianoRoll.listRowHeight; - } else - { - pianoRoll.dragMode = DRAG_MODE_OBSERVE; - } - } - } - } - return 0; - } - case WM_MBUTTONDOWN: - case WM_MBUTTONDBLCLK: - { - if (GetFocus() != hWnd) - SetFocus(hWnd); - playback.handleMiddleButtonClick(); - return 0; - } - case WM_MOUSEWHEEL: - { - bool alt_pressed = (GetKeyState(VK_MENU) < 0); - int fwKeys = GET_KEYSTATE_WPARAM(wParam); - int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); - if (fwKeys & MK_SHIFT) - { - // Shift + wheel = Playback rewind full(speed)/forward full(speed) - if (zDelta < 0) - playback.handleForwardFull(-zDelta / WHEEL_DELTA); - else if (zDelta > 0) - playback.handleRewindFull(zDelta / WHEEL_DELTA); - } else if (fwKeys & MK_CONTROL) - { - // Ctrl + wheel = Selection rewind full(speed)/forward full(speed) - if (zDelta < 0) - selection.jumpToNextMarker(-zDelta / WHEEL_DELTA); - else if (zDelta > 0) - selection.jumpToPreviousMarker(zDelta / WHEEL_DELTA); - } else if (fwKeys & MK_RBUTTON) - { - // Right button + wheel = rewind/forward Playback - int delta = zDelta / WHEEL_DELTA; - if (delta < -1 || delta > 1) - delta *= PLAYBACK_WHEEL_BOOST; - int destination_frame; - if (FCEUI_EmulationPaused() || playback.getPauseFrame() < 0) - destination_frame = currFrameCounter - delta; - else - destination_frame = playback.getPauseFrame() - delta; - if (destination_frame < 0) - destination_frame = 0; - playback.jump(destination_frame); - } else if (history.isCursorOverHistoryList()) - { - return SendMessage(history.hwndHistoryList, WM_MOUSEWHEEL_RESENT, wParam, lParam); - } else if (alt_pressed) - { - // cross gaps in Input/Markers - pianoRoll.crossGaps(zDelta); - } else - { - // normal scrolling - make it 2x faster than usual - CallWindowProc(hwndListOldWndProc, hWnd, msg, MAKELONG(fwKeys, zDelta * PIANO_ROLL_SCROLLING_BOOST), lParam); - } - return 0; - } - case WM_RBUTTONDOWN: - case WM_RBUTTONDBLCLK: - pianoRoll.rightButtonDragMode = true; - if (GetFocus() != hWnd) - SetFocus(hWnd); - return 0; - case WM_RBUTTONUP: - { - // perform hit test - LVHITTESTINFO info; - info.pt.x = GET_X_LPARAM(lParam); - info.pt.y = GET_Y_LPARAM(lParam); - ListView_SubItemHitTest(hWnd, &info); - // show context menu if user right-clicked on Frame# - if (info.iSubItem <= COLUMN_FRAMENUM || info.iSubItem >= COLUMN_FRAMENUM2) - pianoRoll.handleRightClick(info); - return 0; - } - case WM_NCLBUTTONDOWN: - { - if (wParam == HTBORDER) - { - POINT p; - p.x = GET_X_LPARAM(lParam); - p.y = GET_Y_LPARAM(lParam); - ScreenToClient(pianoRoll.hwndList, &p); - if (p.x <= 0) - { - // user clicked on left border of the Piano Roll - // consider this as a "misclick" on Piano Roll's first column - pianoRoll.startDraggingPlaybackCursor(); - return 0; - } - } - break; - } - case WM_MOUSEACTIVATE: - { - if (GetFocus() != hWnd) - SetFocus(hWnd); - break; - } - case LVM_ENSUREVISIBLE: - { - // Piano Roll probably scrolls - pianoRoll.mustCheckItemUnderMouse = true; - break; - } - case WM_VSCROLL: - { - // fix for known WinXP bug - if (LOWORD(wParam) == SB_LINEUP) - { - ListView_Scroll(pianoRoll.hwndList, 0, -pianoRoll.listRowHeight); - return 0; - } else if (LOWORD(wParam) == SB_LINEDOWN) - { - ListView_Scroll(pianoRoll.hwndList, 0, pianoRoll.listRowHeight); - return 0; - } - break; - } - case WM_HSCROLL: - { - if (LOWORD(wParam) == SB_LINELEFT) - { - ListView_Scroll(pianoRoll.hwndList, -COLUMN_BUTTON_WIDTH, 0); - return 0; - } else if (LOWORD(wParam) == SB_LINERIGHT) - { - ListView_Scroll(pianoRoll.hwndList, COLUMN_BUTTON_WIDTH, 0); - return 0; - } - break; - } - - } - return CallWindowProc(hwndListOldWndProc, hWnd, msg, wParam, lParam); -} -// ---------------------------------------------------------------------------------------- -LRESULT APIENTRY markerDragBoxWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - extern PIANO_ROLL pianoRoll; - switch(message) - { - case WM_CREATE: - { - // create static bitmap placeholder - char framenum[DIGITS_IN_FRAMENUM + 1]; - U32ToDecStr(framenum, pianoRoll.markerDragFrameNumber, DIGITS_IN_FRAMENUM); - pianoRoll.hwndMarkerDragBoxText = CreateWindow(WC_STATIC, framenum, SS_CENTER| WS_CHILD | WS_VISIBLE, 0, 0, COLUMN_FRAMENUM_WIDTH, pianoRoll.listRowHeight, hwnd, NULL, NULL, NULL); - SendMessage(pianoRoll.hwndMarkerDragBoxText, WM_SETFONT, (WPARAM)pianoRoll.hMainListSelectFont, 0); - return 0; - } - case WM_CTLCOLORSTATIC: - { - // change color of static text fields - if ((HWND)lParam == pianoRoll.hwndMarkerDragBoxText) - { - SetTextColor((HDC)wParam, NORMAL_TEXT_COLOR); - SetBkMode((HDC)wParam, TRANSPARENT); - if (taseditorConfig.bindMarkersToInput) - return (LRESULT)(pianoRoll.markerDragBoxBrushBind); - else - return (LRESULT)(pianoRoll.markerDragBoxBrushNormal); - } - break; - } - } - return DefWindowProc(hwnd, message, wParam, lParam); -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.h b/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.h deleted file mode 100644 index 5e59ef8e..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/taseditor/piano_roll.h +++ /dev/null @@ -1,249 +0,0 @@ -// Specification file for PIANO_ROLL class - -#define PIANO_ROLL_ID_LEN 11 - -#define CDDS_SUBITEMPREPAINT (CDDS_SUBITEM | CDDS_ITEMPREPAINT) -#define CDDS_SUBITEMPOSTPAINT (CDDS_SUBITEM | CDDS_ITEMPOSTPAINT) -#define CDDS_SUBITEMPREERASE (CDDS_SUBITEM | CDDS_ITEMPREERASE) -#define CDDS_SUBITEMPOSTERASE (CDDS_SUBITEM | CDDS_ITEMPOSTERASE) - -#define MAX_NUM_JOYPADS 4 // = max(joysticks_per_frame[]) -#define NUM_JOYPAD_BUTTONS 8 - -#define HEADER_LIGHT_MAX 10 -#define HEADER_LIGHT_HOLD 5 -#define HEADER_LIGHT_MOUSEOVER_SEL 3 -#define HEADER_LIGHT_MOUSEOVER 0 -#define HEADER_LIGHT_UPDATE_TICK 40 // 25FPS -#define HEADER_DX_FIX 4 - -#define PIANO_ROLL_SCROLLING_BOOST 2 -#define PLAYBACK_WHEEL_BOOST 2 - -#define MARKER_DRAG_BOX_ALPHA 180 -#define MARKER_DRAG_COUNTDOWN_MAX 14 -#define MARKER_DRAG_ALPHA_PER_TICK 13 -#define MARKER_DRAG_MAX_SPEED 72 -#define MARKER_DRAG_GRAVITY 2 - -#define DRAG_SCROLLING_BORDER_SIZE 10 // in pixels - -#define DOUBLETAP_COUNT 3 // 3 actions: 1 = quick press, 2 = quick release, 3 = quick press - -enum PIANO_ROLL_COLUMNS -{ - COLUMN_ICONS, - COLUMN_FRAMENUM, - COLUMN_JOYPAD1_A, - COLUMN_JOYPAD1_B, - COLUMN_JOYPAD1_S, - COLUMN_JOYPAD1_T, - COLUMN_JOYPAD1_U, - COLUMN_JOYPAD1_D, - COLUMN_JOYPAD1_L, - COLUMN_JOYPAD1_R, - COLUMN_JOYPAD2_A, - COLUMN_JOYPAD2_B, - COLUMN_JOYPAD2_S, - COLUMN_JOYPAD2_T, - COLUMN_JOYPAD2_U, - COLUMN_JOYPAD2_D, - COLUMN_JOYPAD2_L, - COLUMN_JOYPAD2_R, - COLUMN_JOYPAD3_A, - COLUMN_JOYPAD3_B, - COLUMN_JOYPAD3_S, - COLUMN_JOYPAD3_T, - COLUMN_JOYPAD3_U, - COLUMN_JOYPAD3_D, - COLUMN_JOYPAD3_L, - COLUMN_JOYPAD3_R, - COLUMN_JOYPAD4_A, - COLUMN_JOYPAD4_B, - COLUMN_JOYPAD4_S, - COLUMN_JOYPAD4_T, - COLUMN_JOYPAD4_U, - COLUMN_JOYPAD4_D, - COLUMN_JOYPAD4_L, - COLUMN_JOYPAD4_R, - COLUMN_FRAMENUM2, - - TOTAL_COLUMNS -}; - -enum DRAG_MODES -{ - DRAG_MODE_NONE, - DRAG_MODE_OBSERVE, - DRAG_MODE_PLAYBACK, - DRAG_MODE_MARKER, - DRAG_MODE_SET, - DRAG_MODE_UNSET, - DRAG_MODE_SELECTION, - DRAG_MODE_DESELECTION, -}; - -// when there's too many button columns, there's need for 2nd Frame# column at the end -#define NUM_COLUMNS_NEED_2ND_FRAMENUM COLUMN_JOYPAD4_R - -#define DIGITS_IN_FRAMENUM 7 // should be enough for any TAS movie -#define BOOKMARKS_WITH_BLUE_ARROW 20 -#define BOOKMARKS_WITH_GREEN_ARROW 40 -#define BLUE_ARROW_IMAGE_ID 60 -#define GREEN_ARROW_IMAGE_ID 61 -#define GREEN_BLUE_ARROW_IMAGE_ID 62 - -#define COLUMN_ICONS_WIDTH 17 -#define COLUMN_FRAMENUM_WIDTH 75 -#define COLUMN_BUTTON_WIDTH 21 - -// listview colors -#define NORMAL_TEXT_COLOR 0x0 -#define NORMAL_BACKGROUND_COLOR 0xFFFFFF - -#define NORMAL_FRAMENUM_COLOR 0xFFFFFF -#define NORMAL_INPUT_COLOR1 0xEDEDED -#define NORMAL_INPUT_COLOR2 0xE2E2E2 - -#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD -#define GREENZONE_INPUT_COLOR1 0xC8F7C4 -#define GREENZONE_INPUT_COLOR2 0xADE7AD - -#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4 -#define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2 -#define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA - -#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9FFF9 -#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0FBE0 -#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2F2D2 - -#define LAG_FRAMENUM_COLOR 0xDDDCFF -#define LAG_INPUT_COLOR1 0xD2D0F0 -#define LAG_INPUT_COLOR2 0xC9C6E8 - -#define PALE_LAG_FRAMENUM_COLOR 0xE3E3FF -#define PALE_LAG_INPUT_COLOR1 0xDADAF4 -#define PALE_LAG_INPUT_COLOR2 0xCFCEEA - -#define VERY_PALE_LAG_FRAMENUM_COLOR 0xE9E9FF -#define VERY_PALE_LAG_INPUT_COLOR1 0xE5E5F7 -#define VERY_PALE_LAG_INPUT_COLOR2 0xE0E0F1 - -#define CUR_FRAMENUM_COLOR 0xFCEDCF -#define CUR_INPUT_COLOR1 0xF7E7B5 -#define CUR_INPUT_COLOR2 0xE5DBA5 - -#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6 -#define UNDOHINT_INPUT_COLOR1 0xF7D2E1 -#define UNDOHINT_INPUT_COLOR2 0xE9BED1 - -#define MARKED_FRAMENUM_COLOR 0xAEF0FF -#define CUR_MARKED_FRAMENUM_COLOR 0xCAEDEA -#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xDDE5E9 - -#define BINDMARKED_FRAMENUM_COLOR 0xC9FFF7 -#define CUR_BINDMARKED_FRAMENUM_COLOR 0xD5F2EC -#define BINDMARKED_UNDOHINT_FRAMENUM_COLOR 0xE1EBED - -#define PLAYBACK_MARKER_COLOR 0xC9AF00 - -class PIANO_ROLL -{ -public: - PIANO_ROLL(); - void init(); - void free(); - void reset(); - void update(); - void redraw(); - - void save(EMUFILE *os, bool really_save = true); - bool load(EMUFILE *is, unsigned int offset); - - void redrawRow(int index); - void redrawHeader(); - - void updateLinesCount(); - bool isLineVisible(int frame); - - void recalculatePlaybackCursorOffset(); - - void followPlaybackCursor(); - void followPlaybackCursorIfNeeded(bool followPauseframe = true); - void updatePlaybackCursorPositionInPianoRoll(); - void followPauseframe(); - void followUndoHint(); - void followSelection(); - void followMarker(int markerID); - void ensureTheLineIsVisible(int rowIndex); - - void handleColumnSet(int column, bool altPressed); - - void setLightInHeaderColumn(int column, int level); - - void startDraggingPlaybackCursor(); - void startDraggingMarker(int mouseX, int mouseY, int rowIndex, int columnIndex); - void startSelectingDrag(int startFrame); - void startDeselectingDrag(int startFrame); - - void getDispInfo(NMLVDISPINFO* nmlvDispInfo); - LONG handleCustomDraw(NMLVCUSTOMDRAW* msg); - LONG handleHeaderCustomDraw(NMLVCUSTOMDRAW* msg); - - void handleRightClick(LVHITTESTINFO& info); - - bool checkIfTheresAnIconAtFrame(int frame); - void crossGaps(int zDelta); - - int headerItemUnderMouse; - HWND hwndList, hwndHeader; - TRACKMOUSEEVENT tme; - - int listTopMargin, listRowHeight, listHeaderHeight; - - bool mustCheckItemUnderMouse; - - int rowUnderMouse, realRowUnderMouse, columnUnderMouse; - unsigned int dragMode; - bool rightButtonDragMode; - int markerDragBoxDX, markerDragBoxDY; - int markerDragBoxX, markerDragBoxY; - int markerDragCountdown; - int markerDragFrameNumber; - int drawingLastX, drawingLastY; - int drawingStartTimestamp; - int dragSelectionStartingFrame; - int dragSelectionEndingFrame; - - bool shiftHeld, ctrlHeld, altHeld; - int shiftTimer, ctrlTimer; - int shiftActionsÑount, ctrlActionsÑount; - - HWND hwndMarkerDragBox, hwndMarkerDragBoxText; - // GDI stuff - HFONT hMainListFont, hMainListSelectFont, hMarkersFont, hMarkersEditFont, hTaseditorAboutFont; - HBRUSH bgBrush, markerDragBoxBrushNormal, markerDragBoxBrushBind; - -private: - void centerListAroundLine(int rowIndex); - void setListTopRow(int rowIndex); - - void handlePlaybackCursorDragging(); - void finishDrag(); - - std::vector headerColors; - int numColumns; - int nextHeaderUpdateTime; - - bool mustRedrawList; - int playbackCursorOffset; - - HMENU hrMenu; - - // GDI stuff - HIMAGELIST hImgList; - - WNDCLASSEX winCl; - BLENDFUNCTION blend; - -}; diff --git a/branches/fceux-2.2.2/src/drivers/win/timing.cpp b/branches/fceux-2.2.2/src/drivers/win/timing.cpp deleted file mode 100644 index 502a4dfd..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/timing.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "common.h" -#include "main.h" -#include "gui.h" -#include "resource.h" - -/** -* This function is called when the dialog closes. -* -* @param hwndDlg Handle of the timing dialog. -**/ -void CloseTimingDialog(HWND hwndDlg) -{ - if(IsDlgButtonChecked(hwndDlg, CB_SET_HIGH_PRIORITY) == BST_CHECKED) - { - eoptions |= EO_HIGHPRIO; - } - else - { - eoptions &= ~EO_HIGHPRIO; - } - - if(IsDlgButtonChecked(hwndDlg, CB_DISABLE_SPEED_THROTTLING)==BST_CHECKED) - { - eoptions |= EO_NOTHROTTLE; - } - else - { - eoptions &= ~EO_NOTHROTTLE; - } - - EndDialog(hwndDlg, 0); -} - -/** -* Callback function of the Timing configuration dialog. -**/ -BOOL CALLBACK TimingConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - - // Update controls to the current settings. - if(eoptions & EO_HIGHPRIO) - { - CheckDlgButton(hwndDlg, CB_SET_HIGH_PRIORITY, BST_CHECKED); - } - - if(eoptions & EO_NOTHROTTLE) - { - CheckDlgButton(hwndDlg, CB_DISABLE_SPEED_THROTTLING, BST_CHECKED); - } - - CenterWindowOnScreen(hwndDlg); - - break; - - case WM_CLOSE: - case WM_QUIT: - CloseTimingDialog(hwndDlg); - break; - - case WM_COMMAND: - - if(!(wParam >> 16)) - { - switch(wParam & 0xFFFF) - { - case 1: - CloseTimingDialog(hwndDlg); - break; - } - } - } - - return 0; -} - -void DoTimingConfigFix() -{ - DoPriority(); -} - -/** -* Shows the Timing configuration dialog. -**/ -void ConfigTiming() -{ - DialogBox(fceu_hInstance, "TIMINGCONFIG", hAppWnd, TimingConCallB); - DoTimingConfigFix(); -} - diff --git a/branches/fceux-2.2.2/src/drivers/win/tracer.cpp b/branches/fceux-2.2.2/src/drivers/win/tracer.cpp deleted file mode 100644 index e14e7e2f..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/tracer.cpp +++ /dev/null @@ -1,1187 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "common.h" -#include "debugger.h" -#include "../../x6502.h" -#include "../../fceu.h" -#include "../../cart.h" //mbg merge 7/19/06 moved after fceu.h -#include "../../file.h" -#include "../../debug.h" -#include "../../asm.h" -#include "../../version.h" -#include "cdlogger.h" -#include "tracer.h" -#include "memview.h" -#include "main.h" //for GetRomName() -#include "utils/xstring.h" - -//Used to determine the current hotkey mapping for the pause key in order to display on the dialog -#include "mapinput.h" -#include "input.h" - -using namespace std; - -//#define LOG_SKIP_UNMAPPED 4 -//#define LOG_ADD_PERIODS 8 - -// ################################## Start of SP CODE ########################### - -#include "debuggersp.h" - -extern Name* lastBankNames; -extern Name* loadedBankNames; -extern Name* ramBankNames; - -// ################################## End of SP CODE ########################### - -//int logaxy = 1, logopdata = 1; //deleteme -int logging_options = LOG_REGISTERS | LOG_PROCESSOR_STATUS | LOG_TO_THE_LEFT | LOG_MESSAGES | LOG_BREAKPOINTS | LOG_CODE_TABBING; -int log_update_window = 0; -//int tracer_open=0; -volatile int logtofile = 0, logging = 0; - -HWND hTracer; -bool tracerIsReadyForResizing = false; -int tracerMinWidth = 0; -int tracerMinHeight = 0; -int Tracer_wndx = 0, Tracer_wndy = 0; -int Tracer_wndWidth = 640, Tracer_wndHeight = 500; -int tracerInitialClientWidth = 0, tracerInitialClientHeight = 0; -int tracerCurrentClientWidth = 0, tracerCurrentClientHeight = 0; - -// this structure stores the data of an existing window pos and how it should be resized. The data is calculated at runtime -struct WindowItemPosData -{ - HWND itemHWND; - int initialLeft; - int initialTop; - int initialRight; - int initialBottom; - unsigned int leftResizeType; - unsigned int topResizeType; - unsigned int rightResizeType; - unsigned int bottomResizeType; -}; -std::vector arrayOfWindowItemPosData; // the data is filled in WM_INITDIALOG - -// this structure holds the data how a known item should be resized. The data is prepared -struct KnownWindowItemPosData -{ - int id; - unsigned int leftResizeType; - unsigned int topResizeType; - unsigned int rightResizeType; - unsigned int bottomResizeType; -}; -// not all window items have to be mentioned here, others will be resized by default method (WINDOW_ITEM_RESIZE_TYPE_MULTIPLY, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_MULTIPLY, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED) -KnownWindowItemPosData tracerKnownWindowItems[] = { - IDC_TRACER_LOG, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_SCRL_TRACER_LOG, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_BTN_START_STOP_LOGGING, WINDOW_ITEM_RESIZE_TYPE_CENTER_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_CENTER_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_RADIO_LOG_LAST, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_TRACER_LOG_SIZE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_TEXT_LINES_TO_THIS_WINDOW, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_RADIO_LOG_TO_FILE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, - IDC_BTN_LOG_BROWSE, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_LEFT_ALIGNED, WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED, -}; - -int log_optn_intlst[LOG_OPTION_SIZE] = {3000000, 1000000, 300000, 100000, 30000, 10000, 3000, 1000, 300, 100}; -char *log_optn_strlst[LOG_OPTION_SIZE] = {"3 000 000", "1 000 000", "300 000", "100 000", "30 000", "10 000", "3000", "1000", "300", "100"}; -int log_lines_option = 5; // 10000 lines by default -char *logfilename = 0; -int oldcodecount, olddatacount; - -SCROLLINFO tracesi; - -char **tracelogbuf = 0; -std::vector> tracelogbufAddressesLog; -int tracelogbufsize = 0, tracelogbufpos = 0; -int tracelogbufusedsize = 0; - -char str_axystate[LOG_AXYSTATE_MAX_LEN] = {0}, str_procstatus[LOG_PROCSTATUS_MAX_LEN] = {0}; -char str_tabs[LOG_TABS_MASK+1] = {0}, str_address[LOG_ADDRESS_MAX_LEN] = {0}, str_data[LOG_DATA_MAX_LEN] = {0}, str_disassembly[LOG_DISASSEMBLY_MAX_LEN] = {0}; -char str_result[LOG_LINE_MAX_LEN] = {0}; -char str_temp[LOG_LINE_MAX_LEN] = {0}; -char str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; -char str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 10] = {0}; -char* tracer_decoration_comment; -char* tracer_decoration_comment_end_pos; -std::vector tempAddressesLog; - -bool log_old_emu_paused = true; // thanks to this flag the window only updates once after the game is paused -extern bool JustFrameAdvanced; -extern int currFrameCounter; - -FILE *LOG_FP; - -char trace_str[35000] = {0}; -WNDPROC IDC_TRACER_LOG_oldWndProc = 0; - -void ShowLogDirDialog(void); -void BeginLoggingSequence(void); -void ClearTraceLogBuf(); -void EndLoggingSequence(); -void UpdateLogWindow(void); -void ScrollLogWindowToLastLine(); -void UpdateLogText(void); -void EnableTracerMenuItems(void); -int PromptForCDLogger(void); - -// returns the address, or EOF if selection cursor points to something else -int Tracer_CheckClickingOnAnAddressOrSymbolicName(unsigned int lineNumber, bool onlyCheckWhenNothingSelected) -{ - if (!tracelogbufsize) - return EOF; - - // trace_str contains the text in the log window - int sel_start, sel_end; - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - if (onlyCheckWhenNothingSelected) - if (sel_end > sel_start) - return EOF; - - // find the "$" before sel_start - int i = sel_start - 1; - for (; i > sel_start - 6; i--) - if (i >= 0 && trace_str[i] == '$') - break; - if (i > sel_start - 6) - { - char offsetBuffer[5]; - strncpy(offsetBuffer, trace_str + i + 1, 4); - offsetBuffer[4] = 0; - // invalidate the string if a space or \r is found in it - char* firstspace = strstr(offsetBuffer, " "); - if (!firstspace) - firstspace = strstr(offsetBuffer, "\r"); - if (!firstspace) - { - unsigned int offset; - if (sscanf(offsetBuffer, "%4X", &offset) != EOF) - { - // select the text - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 5)); - if (hDebug) - PrintOffsetToSeekAndBookmarkFields(offset); - return (int)offset; - } - } - } - - if (tracelogbufusedsize == tracelogbufsize) - lineNumber = (tracelogbufpos + lineNumber) % tracelogbufsize; - - if (lineNumber < tracelogbufAddressesLog.size()) - { - uint16 addr; - Name* node; - char* name; - int nameLen; - char* start_pos; - char* pos; - - for (i = tracelogbufAddressesLog[lineNumber].size() - 1; i >= 0; i--) - { - addr = tracelogbufAddressesLog[lineNumber][i]; - node = findNode(getNamesPointerForAddress(addr), addr); - if (node && node->name && *(node->name)) - { - name = node->name; - nameLen = strlen(name); - if (sel_start - nameLen <= 0) - start_pos = trace_str; - else - start_pos = trace_str + (sel_start - nameLen); - pos = strstr(start_pos, name); - if (pos && pos <= trace_str + sel_start) - { - // clicked on the operand name - // select the text - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)(int)(pos - trace_str), (LPARAM)((int)(pos - trace_str) + nameLen)); - if (hDebug) - PrintOffsetToSeekAndBookmarkFields(addr); - return (int)addr; - } - } - } - } - - return EOF; -} - -BOOL CALLBACK IDC_TRACER_LOG_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_LBUTTONDBLCLK: - { - int offset = Tracer_CheckClickingOnAnAddressOrSymbolicName(tracesi.nPos + (GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight), false); - if (offset != EOF) - { - // open Debugger at this address - DoDebug(0); - if (hDebug) - { - Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, offset); - PrintOffsetToSeekAndBookmarkFields(offset); - } - } - return 0; - } - case WM_LBUTTONUP: - { - Tracer_CheckClickingOnAnAddressOrSymbolicName(tracesi.nPos + (GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight), true); - break; - } - case WM_RBUTTONDOWN: - { - // if nothing is selected, simulate Left-click - int sel_start, sel_end; - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - if (sel_start == sel_end) - { - CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); - CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); - return 0; - } - break; - } - case WM_RBUTTONUP: - { - // save current selection - int sel_start, sel_end; - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); - // simulate a click - CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); - CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); - // try bringing Symbolic Debug Naming dialog - int offset = Tracer_CheckClickingOnAnAddressOrSymbolicName(tracesi.nPos + (GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight), false); - if (offset != EOF) - { - if (DoSymbolicDebugNaming(offset, hTracer)) - { - if (hDebug) - UpdateDebugger(false); - if (hMemView) - UpdateCaption(); - } else - { - // then restore old selection - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); - } - return 0; - } else - { - // then restore old selection - SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); - } - break; - } - case WM_MOUSEWHEEL: - { - SendMessage(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), uMsg, wParam, lParam); - return 0; - } - } - return CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, uMsg, wParam, lParam); -} - -BOOL CALLBACK TracerInitialEnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - RECT rect; - POINT p; - - // create new WindowItemPosData with default settings of resizing the item - WindowItemPosData windowItemPosData; - windowItemPosData.itemHWND = hwnd; - GetWindowRect(hwnd, &rect); - p.x = rect.left; - p.y = rect.top; - ScreenToClient(hTracer, &p); - windowItemPosData.initialLeft = p.x; - windowItemPosData.initialTop = p.y; - p.x = rect.right; - p.y = rect.bottom; - ScreenToClient(hTracer, &p); - windowItemPosData.initialRight = p.x; - windowItemPosData.initialBottom = p.y; - windowItemPosData.leftResizeType = WINDOW_ITEM_RESIZE_TYPE_MULTIPLY; - windowItemPosData.topResizeType = WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED; - windowItemPosData.rightResizeType = WINDOW_ITEM_RESIZE_TYPE_MULTIPLY; - windowItemPosData.bottomResizeType = WINDOW_ITEM_RESIZE_TYPE_RIGHT_ALIGNED; - - // try to find the info in tracerKnownWindowItems - int controlID = GetDlgCtrlID(hwnd); - int sizeofKnownWindowItemPosData = sizeof(KnownWindowItemPosData); - int tracerKnownWindowItemsTotal = sizeof(tracerKnownWindowItems) / sizeofKnownWindowItemPosData; - int i; - for (i = 0; i < tracerKnownWindowItemsTotal; ++i) - { - if (tracerKnownWindowItems[i].id == controlID) - break; - } - if (i < tracerKnownWindowItemsTotal) - { - // this item is known, so its resizing method may differ from defaults - windowItemPosData.leftResizeType = tracerKnownWindowItems[i].leftResizeType; - windowItemPosData.topResizeType = tracerKnownWindowItems[i].topResizeType; - windowItemPosData.rightResizeType = tracerKnownWindowItems[i].rightResizeType; - windowItemPosData.bottomResizeType = tracerKnownWindowItems[i].bottomResizeType; - } - - arrayOfWindowItemPosData.push_back(windowItemPosData); - return TRUE; -} -BOOL CALLBACK TracerResizingEnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - // find the data about resizing type - for (int i = arrayOfWindowItemPosData.size() - 1; i >= 0; i--) - { - if (arrayOfWindowItemPosData[i].itemHWND == hwnd) - { - // recalculate the coordinates according to the resizing type of the item - int left = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialLeft, tracerInitialClientWidth, tracerCurrentClientWidth, arrayOfWindowItemPosData[i].leftResizeType); - int top = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialTop, tracerInitialClientHeight, tracerCurrentClientHeight, arrayOfWindowItemPosData[i].topResizeType); - int right = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialRight, tracerInitialClientWidth, tracerCurrentClientWidth, arrayOfWindowItemPosData[i].rightResizeType); - int bottom = recalculateResizedItemCoordinate(arrayOfWindowItemPosData[i].initialBottom, tracerInitialClientHeight, tracerCurrentClientHeight, arrayOfWindowItemPosData[i].bottomResizeType); - SetWindowPos(hwnd, 0, left, top, right - left, bottom - top, SWP_NOZORDER | SWP_NOOWNERZORDER); - return TRUE; - } - } - return TRUE; -} - -BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int i; - switch(uMsg) - { - case WM_INITDIALOG: - { - hTracer = hwndDlg; - // calculate initial size/positions of items - RECT mainRect; - GetClientRect(hTracer, &mainRect); - tracerInitialClientWidth = mainRect.right; - tracerInitialClientHeight = mainRect.bottom; - // set min size of the window to current size - GetWindowRect(hTracer, &mainRect); - tracerMinWidth = mainRect.right - mainRect.left; - tracerMinHeight = mainRect.bottom - mainRect.top; - if (Tracer_wndWidth < tracerMinWidth) - Tracer_wndWidth = tracerMinWidth; - if (Tracer_wndHeight < tracerMinHeight) - Tracer_wndHeight = tracerMinHeight; - // remember initial positions of all items - EnumChildWindows(hTracer, TracerInitialEnumWindowsProc, 0); - // restore position and size from config, also bring the window on top - if (Tracer_wndx==-32000) Tracer_wndx=0; //Just in case - if (Tracer_wndy==-32000) Tracer_wndy=0; - SetWindowPos(hTracer, HWND_TOP, Tracer_wndx, Tracer_wndy, Tracer_wndWidth, Tracer_wndHeight, SWP_NOOWNERZORDER); - - // calculate tracesi.nPage - RECT wrect; - GetClientRect(GetDlgItem(hwndDlg, IDC_TRACER_LOG), &wrect); - tracesi.nPage = wrect.bottom / debugSystem->fixedFontHeight; - - // setup font - SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG, WM_SETFONT, (WPARAM)debugSystem->hFixedFont, FALSE); - - //check the disabled radio button - CheckRadioButton(hwndDlg,IDC_RADIO_LOG_LAST,IDC_RADIO_LOG_TO_FILE,IDC_RADIO_LOG_LAST); - - //EnableWindow(GetDlgItem(hwndDlg,IDC_SCRL_TRACER_LOG),FALSE); - // fill in the options for the log size - for(i = 0;i < LOG_OPTION_SIZE;i++) - { - SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG_SIZE, CB_INSERTSTRING, -1, (LPARAM)(LPSTR)log_optn_strlst[i]); - } - SendDlgItemMessage(hwndDlg, IDC_TRACER_LOG_SIZE, CB_SETCURSEL, (WPARAM)log_lines_option, 0); - strcpy(trace_str, "Welcome to the Trace Logger."); - SetDlgItemText(hwndDlg, IDC_TRACER_LOG, trace_str); - logtofile = 0; - - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_REGISTERS, (logging_options & LOG_REGISTERS) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_PROCESSOR_STATUS, (logging_options & LOG_PROCESSOR_STATUS) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_INSTRUCTIONS, (logging_options & LOG_NEW_INSTRUCTIONS) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_DATA, (logging_options & LOG_NEW_DATA) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, (logging_options & LOG_TO_THE_LEFT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAMES_COUNT, (logging_options & LOG_FRAMES_COUNT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_CYCLES_COUNT, (logging_options & LOG_CYCLES_COUNT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_INSTRUCTIONS_COUNT, (logging_options & LOG_INSTRUCTIONS_COUNT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_MESSAGES, (logging_options & LOG_MESSAGES) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_BREAKPOINTS, (logging_options & LOG_BREAKPOINTS) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_SYMBOLIC_TRACING, (logging_options & LOG_SYMBOLIC) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_CODE_TABBING, (logging_options & LOG_CODE_TABBING) ? BST_CHECKED : BST_UNCHECKED); - - EnableWindow(GetDlgItem(hwndDlg, IDC_TRACER_LOG_SIZE), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_LOG_BROWSE), FALSE); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_UPDATE_WINDOW, log_update_window ? BST_CHECKED : BST_UNCHECKED); - EnableTracerMenuItems(); - - // subclass editfield - IDC_TRACER_LOG_oldWndProc = (WNDPROC)SetWindowLong(GetDlgItem(hwndDlg, IDC_TRACER_LOG), GWL_WNDPROC, (LONG)IDC_TRACER_LOG_WndProc); - break; - } - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS* windowpos = (WINDOWPOS*)lParam; - if (!(windowpos->flags & SWP_NOSIZE)) - { - // window was resized - if (!IsIconic(hwndDlg)) - { - if (arrayOfWindowItemPosData.size()) - { - RECT mainRect; - GetWindowRect(hTracer, &mainRect); - Tracer_wndWidth = mainRect.right - mainRect.left; - Tracer_wndHeight = mainRect.bottom - mainRect.top; - // resize all items - GetClientRect(hTracer, &mainRect); - tracerCurrentClientWidth = mainRect.right; - tracerCurrentClientHeight = mainRect.bottom; - EnumChildWindows(hTracer, TracerResizingEnumWindowsProc, 0); - InvalidateRect(hTracer, 0, TRUE); - } - // recalculate tracesi.nPage - RECT wrect; - GetClientRect(GetDlgItem(hwndDlg, IDC_TRACER_LOG), &wrect); - int newPageSize = wrect.bottom / debugSystem->fixedFontHeight; - if (tracesi.nPage != newPageSize) - { - tracesi.nPage = newPageSize; - if ((tracesi.nPos + (int)tracesi.nPage) > tracesi.nMax) - tracesi.nPos = tracesi.nMax - (int)tracesi.nPage; - if (tracesi.nPos < tracesi.nMin) - tracesi.nPos = tracesi.nMin; - SetScrollInfo(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), SB_CTL, &tracesi, TRUE); - if (!logtofile) - UpdateLogText(); - } - } - } - if (!(windowpos->flags & SWP_NOMOVE)) - { - // window was moved - if (!IsIconic(hwndDlg) && arrayOfWindowItemPosData.size()) - { - RECT mainRect; - GetWindowRect(hTracer, &mainRect); - Tracer_wndWidth = mainRect.right - mainRect.left; - Tracer_wndHeight = mainRect.bottom - mainRect.top; - Tracer_wndx = mainRect.left; - Tracer_wndy = mainRect.top; - WindowBoundsCheckNoResize(Tracer_wndx, Tracer_wndy, mainRect.right); - } - } - break; - } - case WM_GETMINMAXINFO: - { - if (tracerMinWidth) - { - ((MINMAXINFO*)lParam)->ptMinTrackSize.x = tracerMinWidth; - ((MINMAXINFO*)lParam)->ptMinTrackSize.y = tracerMinHeight; - } - break; - } - case WM_CLOSE: - case WM_QUIT: - if (logging) - EndLoggingSequence(); - ClearTraceLogBuf(); - hTracer = 0; - EndDialog(hwndDlg,0); - break; - case WM_COMMAND: - switch(HIWORD(wParam)) - { - case BN_CLICKED: - { - switch(LOWORD(wParam)) - { - case IDC_BTN_START_STOP_LOGGING: - if (logging) - EndLoggingSequence(); - else - BeginLoggingSequence(); - EnableTracerMenuItems(); - break; - case IDC_RADIO_LOG_LAST: - logtofile = 0; - EnableTracerMenuItems(); - break; - case IDC_RADIO_LOG_TO_FILE: - logtofile = 1; - EnableTracerMenuItems(); - break; - case IDC_CHECK_LOG_REGISTERS: - logging_options ^= LOG_REGISTERS; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_REGISTERS, (logging_options & LOG_REGISTERS) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_PROCESSOR_STATUS: - logging_options ^= LOG_PROCESSOR_STATUS; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_PROCESSOR_STATUS, (logging_options & LOG_PROCESSOR_STATUS) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_STATUSES_TO_THE_LEFT: - logging_options ^= LOG_TO_THE_LEFT; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, (logging_options & LOG_TO_THE_LEFT) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_FRAMES_COUNT: - logging_options ^= LOG_FRAMES_COUNT; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAMES_COUNT, (logging_options & LOG_FRAMES_COUNT) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_CYCLES_COUNT: - logging_options ^= LOG_CYCLES_COUNT; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_CYCLES_COUNT, (logging_options & LOG_CYCLES_COUNT) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_INSTRUCTIONS_COUNT: - logging_options ^= LOG_INSTRUCTIONS_COUNT; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_INSTRUCTIONS_COUNT, (logging_options & LOG_INSTRUCTIONS_COUNT) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_MESSAGES: - logging_options ^= LOG_MESSAGES; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_MESSAGES, (logging_options & LOG_MESSAGES) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_BREAKPOINTS: - logging_options ^= LOG_BREAKPOINTS; - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_BREAKPOINTS, (logging_options & LOG_BREAKPOINTS) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_SYMBOLIC_TRACING: - logging_options ^= LOG_SYMBOLIC; - CheckDlgButton(hwndDlg, IDC_CHECK_SYMBOLIC_TRACING, (logging_options & LOG_SYMBOLIC) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_CODE_TABBING: - logging_options ^= LOG_CODE_TABBING; - CheckDlgButton(hwndDlg, IDC_CHECK_CODE_TABBING, (logging_options & LOG_CODE_TABBING) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_NEW_INSTRUCTIONS: - logging_options ^= LOG_NEW_INSTRUCTIONS; - if(logging && (!PromptForCDLogger())) - logging_options &= ~LOG_NEW_INSTRUCTIONS; //turn it back off - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_INSTRUCTIONS, (logging_options & LOG_NEW_INSTRUCTIONS) ? BST_CHECKED : BST_UNCHECKED); - //EnableTracerMenuItems(); - break; - case IDC_CHECK_LOG_NEW_DATA: - logging_options ^= LOG_NEW_DATA; - if(logging && (!PromptForCDLogger())) - logging_options &= ~LOG_NEW_DATA; //turn it back off - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_DATA, (logging_options & LOG_NEW_DATA) ? BST_CHECKED : BST_UNCHECKED); - break; - case IDC_CHECK_LOG_UPDATE_WINDOW: - { - //todo: if this gets unchecked then we need to clear out the window - log_update_window ^= 1; - if(!FCEUI_EmulationPaused() && !log_update_window) - { - // Assemble the message to pause the game. Uses the current hotkey mapping dynamically - strcpy(trace_str, "Pause the game (press "); - strcat(trace_str, GetKeyComboName(FCEUD_CommandMapping[EMUCMD_PAUSE])); - strcat(trace_str, " key or snap the Debugger) to update this window.\r\n"); - SetDlgItemText(hTracer, IDC_TRACER_LOG, trace_str); - } - break; - } - case IDC_BTN_LOG_BROWSE: - ShowLogDirDialog(); - break; - } - break; - } - } - break; - case WM_MOVING: - break; - - case WM_VSCROLL: - { - if (lParam) - { - if (!tracelogbuf) - break; - - if (!FCEUI_EmulationPaused() && !log_update_window) - break; - - GetScrollInfo((HWND)lParam,SB_CTL,&tracesi); - switch(LOWORD(wParam)) - { - case SB_ENDSCROLL: - case SB_TOP: - case SB_BOTTOM: break; - case SB_LINEUP: tracesi.nPos--; break; - case SB_LINEDOWN:tracesi.nPos++; break; - case SB_PAGEUP: tracesi.nPos -= tracesi.nPage; break; - case SB_PAGEDOWN: tracesi.nPos += tracesi.nPage; break; - case SB_THUMBPOSITION: //break; - case SB_THUMBTRACK: tracesi.nPos = tracesi.nTrackPos; break; - } - if ((tracesi.nPos + (int)tracesi.nPage) > tracesi.nMax) - tracesi.nPos = tracesi.nMax - (int)tracesi.nPage; - if (tracesi.nPos < tracesi.nMin) - tracesi.nPos = tracesi.nMin; - SetScrollInfo((HWND)lParam,SB_CTL,&tracesi,TRUE); - UpdateLogText(); - } - break; - } - case WM_MOUSEWHEEL: - { - GetScrollInfo(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), SB_CTL, &tracesi); - i = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; - if (i < -1 || i > 1) - i *= 2; - tracesi.nPos -= i; - if ((tracesi.nPos + (int)tracesi.nPage) > tracesi.nMax) - tracesi.nPos = tracesi.nMax - tracesi.nPage; - if (tracesi.nPos < tracesi.nMin) - tracesi.nPos = tracesi.nMin; - SetScrollInfo(GetDlgItem(hTracer, IDC_SCRL_TRACER_LOG), SB_CTL, &tracesi, TRUE); - UpdateLogText(); - break; - } - } - return FALSE; -} - -void BeginLoggingSequence(void) -{ - char str2[100]; - int i, j; - - if (!PromptForCDLogger()) - return; //do nothing if user selected no and CD Logger is needed - - if (logtofile) - { - if(logfilename == NULL) ShowLogDirDialog(); - if (!logfilename) return; - LOG_FP = fopen(logfilename,"w"); - if (LOG_FP == NULL) - { - sprintf(trace_str, "Error Opening File %s", logfilename); - MessageBox(hTracer, trace_str, "File Error", MB_OK); - return; - } - fprintf(LOG_FP,FCEU_NAME_AND_VERSION" - Trace Log File\n"); //mbg merge 7/19/06 changed string - } else - { - ClearTraceLogBuf(); - // create new log - log_lines_option = SendDlgItemMessage(hTracer, IDC_TRACER_LOG_SIZE, CB_GETCURSEL, 0, 0); - if (log_lines_option == CB_ERR) - log_lines_option = 0; - strcpy(trace_str, "Allocating Memory...\r\n"); - SetDlgItemText(hTracer, IDC_TRACER_LOG, trace_str); - tracelogbufsize = j = log_optn_intlst[log_lines_option]; - tracelogbuf = (char**)malloc(j * sizeof(char *)); - for (i = 0;i < j;i++) - { - tracelogbuf[i] = (char*)malloc(LOG_LINE_MAX_LEN); - tracelogbuf[i][0] = 0; - } - sprintf(str2, "%d Bytes Allocated...\r\n", j * LOG_LINE_MAX_LEN); - strcat(trace_str, str2); - tracelogbufAddressesLog.resize(0); - tracelogbufAddressesLog.resize(tracelogbufsize); - // Assemble the message to pause the game. Uses the current hotkey mapping dynamically - strcat(trace_str, "Pause the game (press "); - strcat(trace_str, GetKeyComboName(FCEUD_CommandMapping[EMUCMD_PAUSE])); - strcat(trace_str, " key or snap the Debugger) to update this window.\r\n"); - SetDlgItemText(hTracer, IDC_TRACER_LOG, trace_str); - tracelogbufpos = tracelogbufusedsize = 0; - } - - oldcodecount = codecount; - olddatacount = datacount; - - logging=1; - SetDlgItemText(hTracer, IDC_BTN_START_STOP_LOGGING,"Stop Logging"); - return; -} - -//todo: really speed this up -void FCEUD_TraceInstruction(uint8 *opcode, int size) -{ - if (!logging) - return; - - unsigned int addr = X.PC; - uint8 tmp; - static int unloggedlines; - - // if instruction executed from the RAM, skip this, log all instead - // TODO: loops folding mame-lyke style - if (GetPRGAddress(addr) != -1) - { - if(((logging_options & LOG_NEW_INSTRUCTIONS) && (oldcodecount != codecount)) || - ((logging_options & LOG_NEW_DATA) && (olddatacount != datacount))) - { - //something new was logged - oldcodecount = codecount; - olddatacount = datacount; - if(unloggedlines > 0) - { - sprintf(str_result, "(%d lines skipped)", unloggedlines); - OutputLogLine(str_result); - unloggedlines = 0; - } - } else - { - if((logging_options & LOG_NEW_INSTRUCTIONS) || - (logging_options & LOG_NEW_DATA)) - { - if(FCEUI_GetLoggingCD()) - unloggedlines++; - return; - } - } - } - - if ((addr + size) > 0xFFFF) - { - sprintf(str_data, "%02X ", opcode[0]); - sprintf(str_disassembly, "OVERFLOW"); - } else - { - char* a = 0; - switch (size) - { - case 0: - sprintf(str_data, "%02X ", opcode[0]); - sprintf(str_disassembly,"UNDEFINED"); - break; - case 1: - { - sprintf(str_data, "%02X ", opcode[0]); - a = Disassemble(addr + 1, opcode); - // special case: an RTS opcode - if (opcode[0] == 0x60) - { - // add the beginning address of the subroutine that we exit from - unsigned int caller_addr = GetMem(((X.S) + 1)|0x0100) + (GetMem(((X.S) + 2)|0x0100) << 8) - 0x2; - if (GetMem(caller_addr) == 0x20) - { - // this was a JSR instruction - take the subroutine address from it - unsigned int call_addr = GetMem(caller_addr + 1) + (GetMem(caller_addr + 2) << 8); - sprintf(str_decoration, " (from $%04X)", call_addr); - strcat(a, str_decoration); - } - } - break; - } - case 2: - sprintf(str_data, "%02X %02X ", opcode[0],opcode[1]); - a = Disassemble(addr + 2, opcode); - break; - case 3: - sprintf(str_data, "%02X %02X %02X ", opcode[0],opcode[1],opcode[2]); - a = Disassemble(addr + 3, opcode); - break; - } - - if (a) - { - if (logging_options & LOG_SYMBOLIC) - { - loadNameFiles(); - tempAddressesLog.resize(0); - // Insert Name and Comment lines if needed - Name* node = findNode(getNamesPointerForAddress(addr), addr); - if (node) - { - if (node->name) - { - strcpy(str_decoration, node->name); - strcat(str_decoration, ":"); - tempAddressesLog.push_back(addr); - OutputLogLine(str_decoration, &tempAddressesLog); - } - if (node->comment) - { - // make a copy - strcpy(str_decoration_comment, node->comment); - strcat(str_decoration_comment, "\r\n"); - tracer_decoration_comment = str_decoration_comment; - // divide the str_decoration_comment into strings (Comment1, Comment2, ...) - char* tracer_decoration_comment_end_pos = strstr(tracer_decoration_comment, "\r\n"); - while (tracer_decoration_comment_end_pos) - { - tracer_decoration_comment_end_pos[0] = 0; // set \0 instead of \r - strcpy(str_decoration, "; "); - strcat(str_decoration, tracer_decoration_comment); - OutputLogLine(str_decoration, &tempAddressesLog); - tracer_decoration_comment_end_pos += 2; - tracer_decoration_comment = tracer_decoration_comment_end_pos; - tracer_decoration_comment_end_pos = strstr(tracer_decoration_comment_end_pos, "\r\n"); - } - } - } - - replaceNames(ramBankNames, a, &tempAddressesLog); - replaceNames(loadedBankNames, a, &tempAddressesLog); - replaceNames(lastBankNames, a, &tempAddressesLog); - } - strncpy(str_disassembly, a, LOG_DISASSEMBLY_MAX_LEN); - str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; - } - } - - if (size == 1 && GetMem(addr) == 0x60) - { - // special case: an RTS opcode - // add "----------" to emphasize the end of subroutine - strcat(str_disassembly, " "); - int i = strlen(str_disassembly); - for (; i < (LOG_DISASSEMBLY_MAX_LEN - 2); ++i) - str_disassembly[i] = '-'; - str_disassembly[i] = 0; - } - // stretch the disassembly string out if we have to output other stuff. - if ((logging_options & (LOG_REGISTERS|LOG_PROCESSOR_STATUS)) && !(logging_options & LOG_TO_THE_LEFT)) - { - for (int i = strlen(str_disassembly); i < (LOG_DISASSEMBLY_MAX_LEN - 1); ++i) - str_disassembly[i] = ' '; - str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; - } - - // Start filling the str_temp line: Frame count, Cycles count, Instructions count, AXYS state, Processor status, Tabs, Address, Data, Disassembly - if (logging_options & LOG_FRAMES_COUNT) - { - sprintf(str_result, "f%-6u ", currFrameCounter); - } else - { - str_result[0] = 0; - } - if (logging_options & LOG_CYCLES_COUNT) - { - int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base; - if (counter_value < 0) // sanity check - { - ResetDebugStatisticsCounters(); - counter_value = 0; - } - sprintf(str_temp, "c%-11llu ", counter_value); - strcat(str_result, str_temp); - } - if (logging_options & LOG_INSTRUCTIONS_COUNT) - { - sprintf(str_temp, "i%-11llu ", total_instructions); - strcat(str_result, str_temp); - } - - if (logging_options & LOG_REGISTERS) - { - sprintf(str_axystate,"A:%02X X:%02X Y:%02X S:%02X ",(X.A),(X.X),(X.Y),(X.S)); - } - - if (logging_options & LOG_PROCESSOR_STATUS) - { - tmp = X.P^0xFF; - sprintf(str_procstatus,"P:%c%c%c%c%c%c%c%c ", - 'N'|(tmp&0x80)>>2, - 'V'|(tmp&0x40)>>1, - 'U'|(tmp&0x20), - 'B'|(tmp&0x10)<<1, - 'D'|(tmp&0x08)<<2, - 'I'|(tmp&0x04)<<3, - 'Z'|(tmp&0x02)<<4, - 'C'|(tmp&0x01)<<5 - ); - } - - if (logging_options & LOG_TO_THE_LEFT) - { - if (logging_options & LOG_REGISTERS) - strcat(str_result, str_axystate); - if (logging_options & LOG_PROCESSOR_STATUS) - strcat(str_result, str_procstatus); - } - - if (logging_options & LOG_CODE_TABBING) - { - // add spaces at the beginning of the line according to stack pointer - int spaces = (0xFF - X.S) & LOG_TABS_MASK; - for (int i = 0; i < spaces; i++) - str_tabs[i] = ' '; - str_tabs[spaces] = 0; - strcat(str_result, str_tabs); - } else if (logging_options & LOG_TO_THE_LEFT) - { - strcat(str_result, " "); - } - - sprintf(str_address, "$%04X:", addr); - strcat(str_result, str_address); - strcat(str_result, str_data); - strcat(str_result, str_disassembly); - - if (!(logging_options & LOG_TO_THE_LEFT)) - { - if (logging_options & LOG_REGISTERS) - strcat(str_result, str_axystate); - if (logging_options & LOG_PROCESSOR_STATUS) - strcat(str_result, str_procstatus); - } - - OutputLogLine(str_result, &tempAddressesLog); - - return; -} - -void OutputLogLine(const char *str, std::vector* addressesLog, bool add_newline) -{ - if (logtofile) - { - fputs(str, LOG_FP); - if (add_newline) - fputs("\n", LOG_FP); - fflush(LOG_FP); - } else - { - if (add_newline) - { - strncpy(tracelogbuf[tracelogbufpos], str, LOG_LINE_MAX_LEN - 3); - tracelogbuf[tracelogbufpos][LOG_LINE_MAX_LEN - 3] = 0; - strcat(tracelogbuf[tracelogbufpos], "\r\n"); - } else - { - strncpy(tracelogbuf[tracelogbufpos], str, LOG_LINE_MAX_LEN - 1); - tracelogbuf[tracelogbufpos][LOG_LINE_MAX_LEN - 1] = 0; - } - - if (addressesLog) - tracelogbufAddressesLog[tracelogbufpos] = (*addressesLog); - else - tracelogbufAddressesLog[tracelogbufpos].resize(0); - - tracelogbufpos++; - if (tracelogbufusedsize < tracelogbufsize) - tracelogbufusedsize++; - tracelogbufpos %= tracelogbufsize; - } -} - -void ClearTraceLogBuf(void) -{ - if (tracelogbuf) - { - int j = tracelogbufsize; - for(int i = 0; i < j;i++) - { - free(tracelogbuf[i]); - } - free(tracelogbuf); - tracelogbuf = 0; - } - tracelogbufAddressesLog.resize(0); -} - -void EndLoggingSequence() -{ - if (logtofile) - { - fclose(LOG_FP); - } else - { - strcpy(str_result, "Logging finished."); - OutputLogLine(str_result); - ScrollLogWindowToLastLine(); - UpdateLogText(); - // do not clear the log window - // ClearTraceLogBuf(); - } - logging = 0; - SetDlgItemText(hTracer, IDC_BTN_START_STOP_LOGGING,"Start Logging"); -} - -void UpdateLogWindow(void) -{ - //we don't want to continue if the trace logger isn't logging, or if its logging to a file. - if ((!logging) || logtofile) - return; - - // only update the window when some emulation occured - // and only update the window when emulator is paused or log_update_window=true - bool emu_paused = (FCEUI_EmulationPaused() != 0); - if ((!emu_paused && !log_update_window) || (log_old_emu_paused && !JustFrameAdvanced)) //mbg merge 7/19/06 changd to use EmulationPaused() - { - log_old_emu_paused = emu_paused; - return; - } - log_old_emu_paused = emu_paused; - - ScrollLogWindowToLastLine(); - UpdateLogText(); - return; -} - -void ScrollLogWindowToLastLine() -{ - tracesi.cbSize = sizeof(SCROLLINFO); - tracesi.fMask = SIF_ALL; - tracesi.nMin = 0; - tracesi.nMax = tracelogbufusedsize; - tracesi.nPos = tracesi.nMax - tracesi.nPage; - if (tracesi.nPos < tracesi.nMin) - tracesi.nPos = tracesi.nMin; - SetScrollInfo(GetDlgItem(hTracer,IDC_SCRL_TRACER_LOG),SB_CTL,&tracesi,TRUE); -} - -void UpdateLogText(void) -{ - int j; - trace_str[0] = 0; - - if (!tracelogbuf || !tracelogbufpos || !tracelogbufsize) - return; - - int last_line = tracesi.nPos + tracesi.nPage; - if (last_line > tracesi.nMax) - last_line = tracesi.nMax; - - int i = tracesi.nPos; - if (i < tracesi.nMin) - i = tracesi.nMin; - - for (; i < last_line; i++) - { - j = i; - if (tracelogbufusedsize == tracelogbufsize) - j = (tracelogbufpos + i) % tracelogbufsize; - strcat(trace_str, tracelogbuf[j]); - } - SetDlgItemText(hTracer, IDC_TRACER_LOG, trace_str); - //sprintf(str,"nPage = %d, nPos = %d, nMax = %d, nMin = %d",tracesi.nPage,tracesi.nPos,tracesi.nMax,tracesi.nMin); - //SetDlgItemText(hTracer, IDC_TRACER_STATS, str); - return; -} - -void EnableTracerMenuItems(void) -{ - if (logging) - { - EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_LAST),FALSE); - EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_TO_FILE),FALSE); - EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),FALSE); - EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),FALSE); - return; - } - - EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_LAST),TRUE); - EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_TO_FILE),TRUE); - EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),TRUE); - EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),TRUE); - EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_NEW_INSTRUCTIONS),TRUE); - - if (logtofile) - { - EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),FALSE); - EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),TRUE); - log_update_window = 0; - EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_UPDATE_WINDOW),FALSE); - } else - { - EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),TRUE); - EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),FALSE); - EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_UPDATE_WINDOW),TRUE); - } - - return; -} - -//this returns 1 if the CD logger is activated when needed, or 0 if the user selected no, not to activate it -int PromptForCDLogger(void) -{ - if ((logging_options & (LOG_NEW_INSTRUCTIONS|LOG_NEW_DATA)) && (!FCEUI_GetLoggingCD())) - { - if (MessageBox(hTracer,"In order for some of the features you have selected to take effect,\ - the Code/Data Logger must also be running.\ - Would you like to Start the Code/Data Logger Now?","Start Code/Data Logger?", - MB_YESNO) == IDYES) - { - if (DoCDLogger()) - { - FCEUI_SetLoggingCD(1); - SetDlgItemText(hCDLogger, BTN_CDLOGGER_START_PAUSE, "Pause"); - return 1; - } - return 0; // CDLogger couldn't start, probably because the game is closed - } - return 0; // user selected no so 0 is returned - } - return 1; -} - -void ShowLogDirDialog(void){ - const char filter[]="6502 Trace Log File (*.log)\0*.log;*.txt\0" "6502 Trace Log File (*.txt)\0*.log;*.txt\0All Files (*.*)\0*.*\0\0"; //'" "' used to prevent octal conversion on the numbers - char nameo[2048]; - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Log Trace As..."; - ofn.lpstrFilter=filter; - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - ofn.lpstrFile=nameo; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hTracer; - if(GetSaveFileName(&ofn)) - { - if (ofn.nFilterIndex == 1) - AddExtensionIfMissing(nameo, sizeof(nameo), ".log"); - else if (ofn.nFilterIndex == 2) - AddExtensionIfMissing(nameo, sizeof(nameo), ".txt"); - if(logfilename) - free(logfilename); - logfilename = (char*)malloc(strlen(nameo)+1); //mbg merge 7/19/06 added cast - strcpy(logfilename,nameo); - } - return; -} - -void DoTracer() -{ - if (!GameInfo) - { - FCEUD_PrintError("You must have a game loaded before you can use the Trace Logger."); - return; - } - //if (GameInfo->type==GIT_NSF) { //todo: NSF support! - // FCEUD_PrintError("Sorry, you can't yet use the Trace Logger with NSFs."); - // return; - //} - - if (!hTracer) - { - arrayOfWindowItemPosData.resize(0); - CreateDialog(fceu_hInstance,"TRACER",NULL,TracerCallB); - //hTracer gets set in WM_INITDIALOG - } else - { - ShowWindow(hTracer, SW_SHOWNORMAL); - SetForegroundWindow(hTracer); - } -} diff --git a/branches/fceux-2.2.2/src/drivers/win/tracer.h b/branches/fceux-2.2.2/src/drivers/win/tracer.h deleted file mode 100644 index f00f8e3a..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/tracer.h +++ /dev/null @@ -1,46 +0,0 @@ -#define LOG_OPTION_SIZE 10 - -#define LOG_REGISTERS 1 -#define LOG_PROCESSOR_STATUS 2 -#define LOG_NEW_INSTRUCTIONS 4 -#define LOG_NEW_DATA 8 -#define LOG_TO_THE_LEFT 16 -#define LOG_FRAMES_COUNT 32 -#define LOG_MESSAGES 64 -#define LOG_BREAKPOINTS 128 -#define LOG_SYMBOLIC 256 -#define LOG_CODE_TABBING 512 -#define LOG_CYCLES_COUNT 1024 -#define LOG_INSTRUCTIONS_COUNT 2048 - -#define LOG_LINE_MAX_LEN 160 -// Frames count - 1+6+1 symbols -// Cycles count - 1+11+1 symbols -// Instructions count - 1+11+1 symbols -// AXYS state - 20 -// Processor status - 11 -// Tabs - 31 -// Address - 6 -// Data - 10 -// Disassembly - 45 -// EOL (/0) - 1 -// ------------------------ -// 148 symbols total -#define LOG_AXYSTATE_MAX_LEN 21 -#define LOG_PROCSTATUS_MAX_LEN 12 -#define LOG_TABS_MASK 31 -#define LOG_ADDRESS_MAX_LEN 7 -#define LOG_DATA_MAX_LEN 11 -#define LOG_DISASSEMBLY_MAX_LEN 46 - -extern HWND hTracer; -extern int log_update_window; -extern volatile int logtofile, logging; -extern int logging_options; -extern bool log_old_emu_paused; - -void EnableTracerMenuItems(void); -void LogInstruction(void); -void DoTracer(); -void UpdateLogWindow(void); -void OutputLogLine(const char *str, std::vector* addressesLog = 0, bool add_newline = true); diff --git a/branches/fceux-2.2.2/src/drivers/win/video.cpp b/branches/fceux-2.2.2/src/drivers/win/video.cpp deleted file mode 100644 index 14ca1aed..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/video.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "video.h" -#include "../../drawing.h" -#include "gui.h" -#include "../../fceu.h" -#include "../../video.h" -#include "input.h" -#include "mapinput.h" -#include - -extern bool fullscreenByDoubleclick; - -static int RecalcCustom(void); -void InputScreenChanged(int fs); -void UpdateRendBounds(); - -static DDCAPS caps; -static int mustrestore=0; -static DWORD CBM[3]; - -static int bpp; -static int vflags; -static int veflags; - -int directDrawModeWindowed = DIRECTDRAW_MODE_SOFTWARE; -int directDrawModeFullscreen = DIRECTDRAW_MODE_FULL; - -int fssync=0; -int winsync=0; - -int winspecial = 0; -int NTSCwinspecial = 0; -int vmod = 0; - -vmdef vmodes[11] = -{ - {0,0,0,VMDF_DXBLT|VMDF_STRFS,1,1,0}, // Custom - set to current resolution at the first launch - {320,240,8,0,1,1,0}, //1 - {512,384,8,0,1,1,0}, //2 - {640,480,32,0,1,1,0}, //3 - {640,480,32,0,1,1,0}, //4 - {640,480,32,0,1,1,0}, //5 - {640,480,32,VMDF_DXBLT,2,2,0}, //6 - {1024,768,32,VMDF_DXBLT,4,3,0}, //7 - {1280,1024,32,VMDF_DXBLT,5,4,0}, //8 - {1600,1200,32,VMDF_DXBLT,6,5,0}, //9 - {800,600,32,VMDF_DXBLT|VMDF_STRFS,0,0} //10 -}; - -extern uint8 PALRAM[0x20]; - -PALETTEENTRY *color_palette; - -static int PaletteChanged=0; - -LPDIRECTDRAWCLIPPER lpClipper=0; -LPDIRECTDRAW lpDD=0; -LPDIRECTDRAW7 lpDD7=0; -LPDIRECTDRAWPALETTE lpddpal = 0; - -DDSURFACEDESC2 ddsd; -DDSURFACEDESC2 ddsdback; - -LPDIRECTDRAWSURFACE7 lpDDSPrimary=0; -LPDIRECTDRAWSURFACE7 lpDDSDBack=0; -LPDIRECTDRAWSURFACE7 lpDDSBack=0; - -DDBLTFX blitfx = { sizeof(DDBLTFX) }; - -RECT bestfitRect = {0}; - -#define RELEASE(x) if(x) { x->Release(); x = 0; } - -static void ShowDDErr(char *s) -{ - char tempo[512]; - sprintf(tempo,"DirectDraw: %s",s); - FCEUD_PrintError(tempo); -} - -int RestoreDD(int w) -{ - if (w == 1) // lpDDSBack - { - if(!lpDDSBack) return 0; - if(IDirectDrawSurface7_Restore(lpDDSBack)!=DD_OK) return 0; - } else // 0 means lpDDSPrimary - { - if(!lpDDSPrimary) return 0; - if(IDirectDrawSurface7_Restore(lpDDSPrimary)!=DD_OK) return 0; - } - veflags|=1; - return 1; -} - -void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b) -{ - if (force_grayscale) - { - // convert the palette entry to grayscale - int gray = ((float)r * 0.299 + (float)g * 0.587 + (float)b * 0.114); - color_palette[index].peRed = gray; - color_palette[index].peGreen = gray; - color_palette[index].peBlue = gray; - } else - { - color_palette[index].peRed = r; - color_palette[index].peGreen = g; - color_palette[index].peBlue = b; - } - PaletteChanged=1; -} - -void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsigned char *b) -{ - *r=color_palette[i].peRed; - *g=color_palette[i].peGreen; - *b=color_palette[i].peBlue; -} - -static bool firstInitialize = true; -static int InitializeDDraw(int fs) -{ - //only init the palette the first time through - if (firstInitialize) - { - firstInitialize = false; - color_palette = (PALETTEENTRY*)malloc(256 * sizeof(PALETTEENTRY)); - } - - if ((fs && directDrawModeFullscreen == DIRECTDRAW_MODE_SOFTWARE) || (!fs && directDrawModeWindowed == DIRECTDRAW_MODE_SOFTWARE)) - ddrval = DirectDrawCreate((GUID FAR *)DDCREATE_EMULATIONONLY, &lpDD, NULL); - else - ddrval = DirectDrawCreate(NULL, &lpDD, NULL); - - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating DirectDraw object."); - FCEU_printf("Error creating DirectDraw object.\n"); - return 0; - } - - //mbg merge 7/17/06 changed: - ddrval = IDirectDraw_QueryInterface(lpDD,IID_IDirectDraw7,(LPVOID *)&lpDD7); - //ddrval = IDirectDraw_QueryInterface(lpDD,&IID_IDirectDraw7,(LPVOID *)&lpDD7); - IDirectDraw_Release(lpDD); - - if (ddrval != DD_OK) - { - //ShowDDErr("Error querying interface."); - FCEU_printf("Error querying interface.\n"); - return 0; - } - - caps.dwSize=sizeof(caps); - if(IDirectDraw7_GetCaps(lpDD7,&caps,0)!=DD_OK) - { - //ShowDDErr("Error getting capabilities."); - FCEU_printf("Error getting capabilities.\n"); - return 0; - } - return 1; -} - -static int GetBPP(void) -{ - DDPIXELFORMAT ddpix; - - memset(&ddpix,0,sizeof(ddpix)); - ddpix.dwSize=sizeof(ddpix); - - ddrval=IDirectDrawSurface7_GetPixelFormat(lpDDSPrimary,&ddpix); - if (ddrval != DD_OK) - { - //ShowDDErr("Error getting primary surface pixel format."); - FCEU_printf("Error getting primary surface pixel format.\n"); - return 0; - } - - if(ddpix.dwFlags&DDPF_RGB) - { - //mbg merge 7/17/06 removed silly dummy union stuff now that we have c++ - bpp=ddpix.dwRGBBitCount; - CBM[0]=ddpix.dwRBitMask; - CBM[1]=ddpix.dwGBitMask; - CBM[2]=ddpix.dwBBitMask; - } - else - { - //ShowDDErr("RGB data not valid."); - FCEU_printf("RGB data not valid.\n"); - return 0; - } - if(bpp==15) bpp=16; - - return 1; -} - -static int InitBPPStuff(int fs) -{ - - int specfilteropt = 0; - switch (winspecial) - { - case 3: - specfilteropt = NTSCwinspecial; - break; - } - - if(bpp >= 16) - { - InitBlitToHigh(bpp >> 3, CBM[0], CBM[1], CBM[2], 0, fs?vmodes[vmod].special:winspecial,specfilteropt); - } - else if(bpp==8) - { - ddrval=IDirectDraw7_CreatePalette( lpDD7, DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_INITIALIZE,color_palette,&lpddpal,NULL); - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating palette object."); - FCEU_printf("Error creating palette object.\n"); - return 0; - } - ddrval=IDirectDrawSurface7_SetPalette(lpDDSPrimary, lpddpal); - if (ddrval != DD_OK) - { - //ShowDDErr("Error setting palette object."); - FCEU_printf("Error setting palette object.\n"); - return 0; - } - } - return 1; -} - -void recalculateBestFitRect(int width, int height) -{ - if (!lpDD7) - return; // DirectDraw isn't initialized yet - - double screen_width = VNSWID; - double screen_height = FSettings.TotalScanlines(); - if (eoptions & EO_TVASPECT) - screen_width = ceil(screen_height * (screen_width / 256) * (tvAspectX / tvAspectY)); - - int center_x = width / 2; - int center_y = height / 2; - - // calculate bestfitRect - double current_aspectratio = (double)width / (double)height; - double needed_aspectratio = screen_width / screen_height; - if (current_aspectratio >= needed_aspectratio) - { - // the window is wider than emulated screen - double new_height = height; - if (eoptions & EO_SQUAREPIXELS) - { - new_height = int((double)height / screen_height) * screen_height; - if (new_height == 0) - new_height = height; - } - bestfitRect.top = center_y - (int)(new_height / 2); - bestfitRect.bottom = bestfitRect.top + new_height; - double new_width = (new_height * needed_aspectratio); - if (eoptions & EO_SQUAREPIXELS && !(eoptions & EO_TVASPECT)) - { - int new_width_integer = int((double)new_width / screen_width) * screen_width; - if (new_width_integer > 0) - new_width = new_width_integer; - } - bestfitRect.left = center_x - (int)(new_width / 2); - bestfitRect.right = bestfitRect.left + new_width; - } else - { - // the window is taller than emulated screen - double new_width = width; - if (eoptions & EO_SQUAREPIXELS) - { - new_width = int((double)width / screen_width) * screen_width; - if (new_width == 0) - new_width = width; - } - bestfitRect.left = center_x - (int)(new_width / 2); - bestfitRect.right = bestfitRect.left + new_width; - double new_height = (new_width / needed_aspectratio); - if (eoptions & EO_SQUAREPIXELS && !(eoptions & EO_TVASPECT)) - { - int new_height_integer = int((double)new_height / screen_height) * screen_height; - if (new_height_integer > 0) - new_height = new_height_integer; - } - bestfitRect.top = center_y - (int)(new_height / 2); - bestfitRect.bottom = bestfitRect.top + new_height; - } -} - -int SetVideoMode(int fs) -{ - int specmul = 1; // Special scaler size multiplier - - if(fs) - if(!vmod) - if(!RecalcCustom()) - return(0); - - vflags=0; - veflags=1; - PaletteChanged=1; - - ResetVideo(); - fullscreen=fs; - - if(!InitializeDDraw(fs)) return(1); // DirectDraw not initialized - - - if(!fs) - { - // -Video Modes Tag- - if(winspecial <= 3 && winspecial >= 1) - specmul = 2; - else if(winspecial >= 4 && winspecial <= 5) - specmul = 3; - else - specmul = 1; - - ShowCursorAbs(1); - windowedfailed=1; - HideFWindow(0); - - ddrval = IDirectDraw7_SetCooperativeLevel ( lpDD7, hAppWnd, DDSCL_NORMAL); - if (ddrval != DD_OK) - { - //ShowDDErr("Error setting cooperative level."); - FCEU_printf("Error setting cooperative level.\n"); - return 1; - } - - //Beginning - memset(&ddsd,0,sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - ddrval = IDirectDraw7_CreateSurface ( lpDD7, &ddsd, &lpDDSPrimary,(IUnknown FAR*)NULL); - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating primary surface."); - FCEU_printf("Error creating primary surface.\n"); - return 1; - } - - memset(&ddsdback,0,sizeof(ddsdback)); - ddsdback.dwSize=sizeof(ddsdback); - ddsdback.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN; - - ddsdback.dwWidth=256 * specmul; - ddsdback.dwHeight=FSettings.TotalScanlines() * specmul; - - if (directDrawModeWindowed == DIRECTDRAW_MODE_SURFACE_IN_RAM) - // create the buffer in system memory - ddsdback.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; - - ddrval = IDirectDraw7_CreateSurface(lpDD7, &ddsdback, &lpDDSBack, (IUnknown FAR*)NULL); - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating secondary surface."); - FCEU_printf("Error creating secondary surface.\n"); - return 0; - } - - if(!GetBPP()) - return 0; - - if(bpp!=16 && bpp!=24 && bpp!=32) - { - //ShowDDErr("Current bit depth not supported!"); - FCEU_printf("Current bit depth not supported!\n"); - return 0; - } - - if(!InitBPPStuff(fs)) - return 0; - - ddrval=IDirectDraw7_CreateClipper(lpDD7,0,&lpClipper,0); - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating clipper."); - FCEU_printf("Error creating clipper.\n"); - return 0; - } - - ddrval=IDirectDrawClipper_SetHWnd(lpClipper,0,hAppWnd); - if (ddrval != DD_OK) - { - //ShowDDErr("Error setting clipper window."); - FCEU_printf("Error setting clipper window.\n"); - return 0; - } - ddrval=IDirectDrawSurface7_SetClipper(lpDDSPrimary,lpClipper); - if (ddrval != DD_OK) - { - //ShowDDErr("Error attaching clipper to primary surface."); - FCEU_printf("Error attaching clipper to primary surface.\n"); - return 0; - } - - windowedfailed=0; - SetMainWindowStuff(); - } else - { - //Following is full-screen - if(vmod == 0) // Custom mode - { - // -Video Modes Tag- - if(vmodes[0].special <= 3 && vmodes[0].special >= 1) - specmul = 2; - else if(vmodes[0].special >= 4 && vmodes[0].special <= 5) - specmul = 3; - else - specmul = 1; - } - HideFWindow(1); - - ddrval = IDirectDraw7_SetCooperativeLevel ( lpDD7, hAppWnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); - if (ddrval != DD_OK) - { - //ShowDDErr("Error setting cooperative level."); - FCEU_printf("Error setting cooperative level.\n"); - return 0; - } - - ddrval = IDirectDraw7_SetDisplayMode(lpDD7, vmodes[vmod].x, vmodes[vmod].y,vmodes[vmod].bpp,0,0); - if (ddrval != DD_OK) - { - //ShowDDErr("Error setting display mode."); - FCEU_printf("Error setting display mode.\n"); - return 0; - } - if(vmodes[vmod].flags&VMDF_DXBLT) - { - memset(&ddsdback,0,sizeof(ddsdback)); - ddsdback.dwSize=sizeof(ddsdback); - ddsdback.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN; - - ddsdback.dwWidth=256 * specmul; //vmodes[vmod].srect.right; - ddsdback.dwHeight=FSettings.TotalScanlines() * specmul; //vmodes[vmod].srect.bottom; - - if (directDrawModeFullscreen == DIRECTDRAW_MODE_SURFACE_IN_RAM) - // create the buffer in system memory - ddsdback.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; - - ddrval = IDirectDraw7_CreateSurface ( lpDD7, &ddsdback, &lpDDSBack, (IUnknown FAR*)NULL); - if(ddrval!=DD_OK) - { - //ShowDDErr("Error creating secondary surface."); - FCEU_printf("Error creating secondary surface.\n"); - return 0; - } - } - - if (eoptions & EO_BESTFIT) - recalculateBestFitRect(vmodes[vmod].x, vmodes[vmod].y); - - // create foreground surface - - memset(&ddsd,0,sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - if(fssync==3) // Double buffering. - { - ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; - ddsd.dwBackBufferCount = 1; - ddsd.ddsCaps.dwCaps |= DDSCAPS_COMPLEX | DDSCAPS_FLIP; - } - - ddrval = IDirectDraw7_CreateSurface ( lpDD7, &ddsd, &lpDDSPrimary,(IUnknown FAR*)NULL); - if (ddrval != DD_OK) - { - //ShowDDErr("Error creating primary surface."); - FCEU_printf("Error creating primary surface.\n"); - return 0; - } - - if(fssync==3) - { - DDSCAPS2 tmp; - - memset(&tmp,0,sizeof(tmp)); - tmp.dwCaps=DDSCAPS_BACKBUFFER; - - if(IDirectDrawSurface7_GetAttachedSurface(lpDDSPrimary,&tmp,&lpDDSDBack)!=DD_OK) - { - //ShowDDErr("Error getting attached surface."); - FCEU_printf("Error getting attached surface.\n"); - return 0; - } - } - - if(!GetBPP()) - return 0; - if(!InitBPPStuff(fs)) - return 0; - - mustrestore=1; - - if (eoptions & EO_HIDEMOUSE) - ShowCursorAbs(0); - } - - fullscreen=fs; - return 1; -} - -//draw input aids if we are fullscreen -bool FCEUD_ShouldDrawInputAids() -{ - return fullscreen!=0; -} - -static void BlitScreenWindow(uint8 *XBuf); -static void BlitScreenFull(uint8 *XBuf); - -static void FCEUD_VerticalSync() -{ - if(!NoWaiting) - { - int ws; - - if(fullscreen) ws=fssync; - else ws = winsync; - - if(ws==1) - IDirectDraw7_WaitForVerticalBlank(lpDD7,DDWAITVB_BLOCKBEGIN,0); - else if(ws == 2) - { - BOOL invb = 0; - - while((DD_OK == IDirectDraw7_GetVerticalBlankStatus(lpDD7,&invb)) && !invb) - Sleep(0); - } - } -} - -//static uint8 *XBSave; -void FCEUD_BlitScreen(uint8 *XBuf) -{ - xbsave = XBuf; - - if(fullscreen) - { - BlitScreenFull(XBuf); - } - else - { - if(!windowedfailed) - BlitScreenWindow(XBuf); - } -} - -static void FixPaletteHi(void) -{ - SetPaletteBlitToHigh((uint8*)color_palette); //mbg merge 7/17/06 added cast -} - -static void BlitScreenWindow(unsigned char *XBuf) -{ - int pitch; - unsigned char *ScreenLoc; - static RECT srect, wrect, blitRect; - int specialmul; - - if (!lpDDSBack) return; - - // -Video Modes Tag- - if(winspecial <= 3 && winspecial >= 1) - specialmul = 2; - else if(winspecial >= 4 && winspecial <= 5) - specialmul = 3; - else specialmul = 1; - - srect.top=srect.left=0; - srect.right=VNSWID * specialmul; - srect.bottom=FSettings.TotalScanlines() * specialmul; - - if(PaletteChanged==1) - { - FixPaletteHi(); - PaletteChanged=0; - } - - if(!GetClientAbsRect(&wrect)) return; - - ddrval=IDirectDrawSurface7_Lock(lpDDSBack,NULL,&ddsdback, 0, NULL); - if (ddrval != DD_OK) - { - if (ddrval == DDERR_SURFACELOST) - RestoreDD(1); - return; - } - - //mbg merge 7/17/06 removing dummyunion stuff - pitch=ddsdback.lPitch; - ScreenLoc=(unsigned char*)ddsdback.lpSurface; //mbg merge 7/17/06 added cst - if(veflags&1) - { - memset(ScreenLoc,0,pitch*ddsdback.dwHeight); - veflags&=~1; - } - Blit8ToHigh(XBuf+FSettings.FirstSLine*256+VNSCLIP,ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,specialmul,specialmul); - - IDirectDrawSurface7_Unlock(lpDDSBack, NULL); - - FCEUD_VerticalSync(); // aquanull 2011-11-28 fix tearing - if (eoptions & EO_BESTFIT && (bestfitRect.top || bestfitRect.left)) - { - // blit with resizing - blitRect.top = wrect.top + bestfitRect.top; - blitRect.bottom = blitRect.top + bestfitRect.bottom - bestfitRect.top; - blitRect.left = wrect.left + bestfitRect.left; - blitRect.right = blitRect.left + bestfitRect.right - bestfitRect.left; - if (IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, lpDDSBack, &srect, DDBLT_ASYNC, 0) != DD_OK) - { - ddrval = IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, lpDDSBack, &srect, DDBLT_WAIT, 0); - if(ddrval != DD_OK) - { - if(ddrval == DDERR_SURFACELOST) - { - RestoreDD(1); - RestoreDD(0); - } - return; - } - } - // clear borders - if (eoptions & EO_BGCOLOR) - { - // fill the surface using BG color from PPU - unsigned char r, g, b; - FCEUD_GetPalette(0x80 | PALRAM[0], &r, &g, &b); - blitfx.dwFillColor = (r << 16) + (g << 8) + b; - } else - { - blitfx.dwFillColor = 0; - } - if (bestfitRect.top) - { - // upper border - blitRect.top = wrect.top; - blitRect.bottom = wrect.top + bestfitRect.top; - blitRect.left = wrect.left; - blitRect.right = wrect.right; - IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - // lower border - blitRect.top += bestfitRect.bottom; - blitRect.bottom = wrect.bottom; - IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - } - if (bestfitRect.left) - { - // left border - blitRect.top = wrect.top; - blitRect.bottom = wrect.bottom; - blitRect.left = wrect.left; - blitRect.right = wrect.left + bestfitRect.left; - IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - // right border - blitRect.left += bestfitRect.right; - blitRect.right = wrect.right; - IDirectDrawSurface7_Blt(lpDDSPrimary, &blitRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - } - } else - { - // blit without resizing - if(IDirectDrawSurface7_Blt(lpDDSPrimary, &wrect, lpDDSBack, &srect, DDBLT_ASYNC, 0) != DD_OK) - { - ddrval = IDirectDrawSurface7_Blt(lpDDSPrimary, &wrect, lpDDSBack, &srect, DDBLT_WAIT, 0); - if(ddrval != DD_OK) - { - if(ddrval == DDERR_SURFACELOST) - { - RestoreDD(1); - RestoreDD(0); - } - return; - } - } - } -} - -static void DD_FillRect(LPDIRECTDRAWSURFACE7 surf, int left, int top, int right, int bottom, DWORD color) -{ - RECT r; - SetRect(&r,left,top,right,bottom); - DDBLTFX fx; - memset(&fx,0,sizeof(DDBLTFX)); - fx.dwSize = sizeof(DDBLTFX); - //fx.dwFillColor = color; - fx.dwFillColor = 0; //color is just for debug - surf->Blt(&r,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&fx); -} - - -static void BlitScreenFull(uint8 *XBuf) -{ - static int pitch; - char *ScreenLoc; - //unsigned long x; //mbg merge 7/17/06 removed - //uint8 y; //mbg merge 7/17/06 removed - RECT srect, drect; - LPDIRECTDRAWSURFACE7 lpDDSVPrimary; - int specmul; // Special scaler size multiplier - // -Video Modes Tag- - if(vmodes[0].special <= 3 && vmodes[0].special >= 1) - specmul = 2; - else if(vmodes[0].special >= 4 && vmodes[0].special <= 5) - specmul = 3; - else - specmul = 1; - - if(fssync==3) - lpDDSVPrimary=lpDDSDBack; - else - lpDDSVPrimary=lpDDSPrimary; - - if (!lpDDSVPrimary) return; - - if(PaletteChanged==1) - { - if(bpp>=16) - FixPaletteHi(); - else - { - ddrval=IDirectDrawPalette_SetEntries(lpddpal,0,0,256,color_palette); - if(ddrval!=DD_OK) - { - if(ddrval==DDERR_SURFACELOST) RestoreDD(0); - return; - } - } - PaletteChanged=0; - } - - if(vmodes[vmod].flags&VMDF_DXBLT) - { - // start rendering into backbuffer - ddrval=IDirectDrawSurface7_Lock(lpDDSBack,NULL,&ddsdback, 0, NULL); - if(ddrval!=DD_OK) - { - if(ddrval==DDERR_SURFACELOST) RestoreDD(1); - return; - } - ScreenLoc=(char *)ddsdback.lpSurface; //mbg merge 7/17/06 added cast - pitch=ddsdback.lPitch; //mbg merge 7/17/06 removed dummyunion stuff - - srect.top=0; - srect.left=0; - srect.right=VNSWID * specmul; - srect.bottom=FSettings.TotalScanlines() * specmul; - - //if(vmodes[vmod].flags&VMDF_STRFS) - //{ - drect.top=0; - drect.left=0; - drect.right=vmodes[vmod].x; - drect.bottom=vmodes[vmod].y; - /* - } - else - { - drect.top=(vmodes[vmod].y-(FSettings.TotalScanlines()*vmodes[vmod].yscale))>>1; - drect.bottom=drect.top+(FSettings.TotalScanlines()*vmodes[vmod].yscale); - drect.left=(vmodes[vmod].x-VNSWID*vmodes[vmod].xscale)>>1; - drect.right=drect.left+VNSWID*vmodes[vmod].xscale; - RECT fullScreen; - fullScreen.left = fullScreen.top = 0; - fullScreen.right = vmodes[vmod].x; - fullScreen.bottom = vmodes[vmod].y; - RECT r; - r = drect; - int left = r.left; - int top = r.top; - int right = r.right; - int bottom = r.bottom; - DD_FillRect(lpDDSVPrimary,0,0,left,top,RGB(255,0,0)); //topleft - DD_FillRect(lpDDSVPrimary,left,0,right,top,RGB(128,0,0)); //topcenter - DD_FillRect(lpDDSVPrimary,right,0,fullScreen.right,top,RGB(0,255,0)); //topright - DD_FillRect(lpDDSVPrimary,0,top,left,bottom,RGB(0,128,0)); //left - DD_FillRect(lpDDSVPrimary,right,top,fullScreen.right,bottom,RGB(0,0,255)); //right - DD_FillRect(lpDDSVPrimary,0,bottom,left,fullScreen.bottom,RGB(0,0,128)); //bottomleft - DD_FillRect(lpDDSVPrimary,left,bottom,right,fullScreen.bottom,RGB(255,0,255)); //bottomcenter - DD_FillRect(lpDDSVPrimary,right,bottom,fullScreen.right,fullScreen.bottom,RGB(0,255,255)); //bottomright - } - */ - } else - { - // start rendering directly to screen - FCEUD_VerticalSync(); - ddrval=IDirectDrawSurface7_Lock(lpDDSVPrimary,NULL,&ddsd, 0, NULL); - if(ddrval!=DD_OK) - { - if(ddrval==DDERR_SURFACELOST) RestoreDD(0); - return; - } - - ScreenLoc=(char*)ddsd.lpSurface; //mbg merge 7/17/06 added cast - pitch=ddsd.lPitch; //mbg merge 7/17/06 removing dummyunion stuff - } - - if(veflags&1) - { - if(vmodes[vmod].flags&VMDF_DXBLT) - { - veflags|=2; - memset((char *)ScreenLoc,0,pitch*srect.bottom); - } - else - { - memset((char *)ScreenLoc,0,pitch*vmodes[vmod].y); - } - PaletteChanged=1; - veflags&=~1; - } - - //mbg 6/29/06 merge -#ifndef MSVC - if(vmod==5) - { - if(eoptions&EO_CLIPSIDES) - { - asm volatile( - "xorl %%edx, %%edx\n\t" - "akoop1:\n\t" - "movb $120,%%al \n\t" - "akoop2:\n\t" - "movb 1(%%esi),%%dl\n\t" - "shl $16,%%edx\n\t" - "movb (%%esi),%%dl\n\t" - "movl %%edx,(%%edi)\n\t" - "addl $2,%%esi\n\t" - "addl $4,%%edi\n\t" - "decb %%al\n\t" - "jne akoop2\n\t" - "addl $16,%%esi\n\t" - "addl %%ecx,%%edi\n\t" - "decb %%bl\n\t" - "jne akoop1\n\t" - : - : "S" (XBuf+FSettings.FirstSLine*256+VNSCLIP), "D" (ScreenLoc+((240-FSettings.TotalScanlines())/2)*pitch+(640-(VNSWID<<1))/2),"b" (FSettings.TotalScanlines()), "c" ((pitch-VNSWID)<<1) - : "%al", "%edx", "%cc" ); - } - else - { - asm volatile( - "xorl %%edx, %%edx\n\t" - "koop1:\n\t" - "movb $128,%%al \n\t" - "koop2:\n\t" - "movb 1(%%esi),%%dl\n\t" - "shl $16,%%edx\n\t" - "movb (%%esi),%%dl\n\t" - "movl %%edx,(%%edi)\n\t" - "addl $2,%%esi\n\t" - "addl $4,%%edi\n\t" - "decb %%al\n\t" - "jne koop2\n\t" - "addl %%ecx,%%edi\n\t" - "decb %%bl\n\t" - "jne koop1\n\t" - : - : "S" (XBuf+FSettings.FirstSLine*256), "D" (ScreenLoc+((240-FSettings.TotalScanlines())/2)*pitch+(640-512)/2),"b" (FSettings.TotalScanlines()), "c" (pitch-512+pitch) - : "%al", "%edx", "%cc" ); - } - } - else if(vmod==4) - { - if(eoptions&EO_CLIPSIDES) - { - asm volatile( - "ayoop1:\n\t" - "movb $120,%%al \n\t" - "ayoop2:\n\t" - "movb 1(%%esi),%%dh\n\t" - "movb %%dh,%%dl\n\t" - "shl $16,%%edx\n\t" - "movb (%%esi),%%dl\n\t" - "movb %%dl,%%dh\n\t" // Ugh - "movl %%edx,(%%edi)\n\t" - "addl $2,%%esi\n\t" - "addl $4,%%edi\n\t" - "decb %%al\n\t" - "jne ayoop2\n\t" - "addl $16,%%esi\n\t" - "addl %%ecx,%%edi\n\t" - "decb %%bl\n\t" - "jne ayoop1\n\t" - : - : "S" (XBuf+FSettings.FirstSLine*256+VNSCLIP), "D" (ScreenLoc+((240-FSettings.TotalScanlines())/2)*pitch+(640-(VNSWID<<1))/2),"b" (FSettings.TotalScanlines()), "c" ((pitch-VNSWID)<<1) - : "%al", "%edx", "%cc" ); - } - else - { - asm volatile( - "yoop1:\n\t" - "movb $128,%%al \n\t" - "yoop2:\n\t" - "movb 1(%%esi),%%dh\n\t" - "movb %%dh,%%dl\n\t" - "shl $16,%%edx\n\t" - "movb (%%esi),%%dl\n\t" - "movb %%dl,%%dh\n\t" // Ugh - "movl %%edx,(%%edi)\n\t" - "addl $2,%%esi\n\t" - "addl $4,%%edi\n\t" - "decb %%al\n\t" - "jne yoop2\n\t" - "addl %%ecx,%%edi\n\t" - "decb %%bl\n\t" - "jne yoop1\n\t" - : - : "S" (XBuf+FSettings.FirstSLine*256), "D" (ScreenLoc+((240-FSettings.TotalScanlines())/2)*pitch+(640-512)/2),"b" (FSettings.TotalScanlines()), "c" (pitch-512+pitch) - : "%al", "%edx", "%cc" ); - } - } - else -#endif - //mbg 6/29/06 merge - { - if(!(vmodes[vmod].flags&VMDF_DXBLT)) - { - // -Video Modes Tag- - if(vmodes[vmod].special) - ScreenLoc += (vmodes[vmod].drect.left*(bpp>>3)) + ((vmodes[vmod].drect.top)*pitch); - else - ScreenLoc+=((vmodes[vmod].x-VNSWID)>>1)*(bpp>>3)+(((vmodes[vmod].y-FSettings.TotalScanlines())>>1))*pitch; - } - - if(bpp>=16) - { - Blit8ToHigh(XBuf+FSettings.FirstSLine*256+VNSCLIP,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,specmul,specmul); //mbg merge 7/17/06 added cast - } - else - { - XBuf+=FSettings.FirstSLine*256+VNSCLIP; - // -Video Modes Tag- - if(vmodes[vmod].special) - Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,vmodes[vmod].xscale,vmodes[vmod].yscale,0,vmodes[vmod].special); //mbg merge 7/17/06 added cast - else - Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,1,1,0,0); //mbg merge 7/17/06 added cast - } - } - - if(vmodes[vmod].flags&VMDF_DXBLT) - { - IDirectDrawSurface7_Unlock(lpDDSBack, NULL); - FCEUD_VerticalSync(); - if (eoptions & EO_BESTFIT && (bestfitRect.top || bestfitRect.left) && !vmod) - { - // blit with resizing - if (IDirectDrawSurface7_Blt(lpDDSVPrimary, &bestfitRect, lpDDSBack, &srect, DDBLT_ASYNC, 0) != DD_OK) - { - ddrval = IDirectDrawSurface7_Blt(lpDDSVPrimary, &bestfitRect, lpDDSBack, &srect, DDBLT_WAIT, 0); - if(ddrval != DD_OK) - { - if(ddrval == DDERR_SURFACELOST) - { - RestoreDD(1); - RestoreDD(0); - } - return; - } - } - // clear borders - if (eoptions & EO_BGCOLOR) - { - // fill the surface using BG color from PPU - unsigned char r, g, b; - FCEUD_GetPalette(0x80 | PALRAM[0], &r, &g, &b); - blitfx.dwFillColor = (r << 16) + (g << 8) + b; - } else - { - blitfx.dwFillColor = 0; - } - static RECT borderRect; - if (bestfitRect.top) - { - // upper border - borderRect.top = drect.top; - borderRect.bottom = drect.top + bestfitRect.top; - borderRect.left = drect.left; - borderRect.right = drect.right; - IDirectDrawSurface7_Blt(lpDDSPrimary, &borderRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - // lower border - borderRect.top += bestfitRect.bottom; - borderRect.bottom = drect.bottom; - IDirectDrawSurface7_Blt(lpDDSPrimary, &borderRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - } - if (bestfitRect.left) - { - // left border - borderRect.top = drect.top; - borderRect.bottom = drect.bottom; - borderRect.left = drect.left; - borderRect.right = drect.left + bestfitRect.left; - IDirectDrawSurface7_Blt(lpDDSPrimary, &borderRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - // right border - borderRect.left += bestfitRect.right; - borderRect.right = drect.right; - IDirectDrawSurface7_Blt(lpDDSPrimary, &borderRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ASYNC, &blitfx); - } - } else - { - /* - if(veflags&2) - { - // clear screen surface (is that really necessary?) - if(IDirectDrawSurface7_Lock(lpDDSVPrimary, NULL, &ddsd, 0, NULL)==DD_OK) - { - memset(ddsd.lpSurface,0,ddsd.lPitch*vmodes[vmod].y); //mbg merge 7/17/06 removing dummyunion stuff - IDirectDrawSurface7_Unlock(lpDDSVPrimary, NULL); - veflags&=~2; - } - } - */ - // blit without resizing - if(IDirectDrawSurface7_Blt(lpDDSVPrimary, NULL, lpDDSBack, &srect, DDBLT_ASYNC,0)!=DD_OK) - { - ddrval=IDirectDrawSurface7_Blt(lpDDSVPrimary, NULL, lpDDSBack, &srect, DDBLT_WAIT,0); - if(ddrval!=DD_OK) - { - if(ddrval==DDERR_SURFACELOST) - { - RestoreDD(1); - RestoreDD(0); - } - return; - } - } - } - } else - { - IDirectDrawSurface7_Unlock(lpDDSVPrimary, NULL); - } - - if(fssync==3) - { - IDirectDrawSurface7_Flip(lpDDSPrimary,0,0); - } -} - -void ResetVideo(void) -{ - ShowCursorAbs(1); - KillBlitToHigh(); - if(lpDD7) - if(mustrestore) - { - IDirectDraw7_RestoreDisplayMode(lpDD7); - mustrestore=0; - } - - RELEASE(lpddpal); - RELEASE(lpDDSBack); - RELEASE(lpDDSPrimary); - RELEASE(lpClipper); - RELEASE(lpDD7); -} - -int specialmlut[5] = {1,2,2,3,3}; - -void ResetCustomMode() -{ - // use current display settings - if (!lpDD7) - return; - - vmdef *cmode = &vmodes[0]; - - DDSURFACEDESC2 temp_ddsd; - temp_ddsd.dwSize = sizeof(DDSURFACEDESC2); - IDirectDraw7_GetDisplayMode(lpDD7, &temp_ddsd); - if (FAILED(ddrval)) - return; - cmode->x = temp_ddsd.dwWidth; - cmode->y = temp_ddsd.dwHeight; - cmode->bpp = temp_ddsd.ddpfPixelFormat.dwRGBBitCount; - cmode->xscale = cmode->yscale = 1; - cmode->flags = VMDF_DXBLT|VMDF_STRFS; -} - -static int RecalcCustom(void) -{ - vmdef *cmode = &vmodes[0]; - - if ((cmode->x <= 0) || (cmode->y <= 0)) - ResetCustomMode(); - - if(cmode->flags&VMDF_STRFS) - { - cmode->flags |= VMDF_DXBLT; - } else if(cmode->xscale!=1 || cmode->yscale!=1 || cmode->special) - { - cmode->flags &= ~VMDF_DXBLT; - if(cmode->special) - { - int mult = specialmlut[cmode->special]; - - if(cmode->xscale < mult) - cmode->xscale = mult; - if(cmode->yscale < mult) - cmode->yscale = mult; - - if(cmode->xscale != mult || cmode->yscale != mult) - cmode->flags|=VMDF_DXBLT; - } - else - cmode->flags|=VMDF_DXBLT; - - - if(VNSWID*cmode->xscale>cmode->x) - { - if(cmode->special) - { - FCEUD_PrintError("Scaled width is out of range."); - return(0); - } - else - { - FCEUD_PrintError("Scaled width is out of range. Reverting to no horizontal scaling."); - cmode->xscale=1; - } - } - if(FSettings.TotalScanlines()*cmode->yscale>cmode->y) - { - if(cmode->special) - { - FCEUD_PrintError("Scaled height is out of range."); - return(0); - } - else - { - FCEUD_PrintError("Scaled height is out of range. Reverting to no vertical scaling."); - cmode->yscale=1; - } - } - - cmode->srect.left=VNSCLIP; - cmode->srect.top=FSettings.FirstSLine; - cmode->srect.right=256-VNSCLIP; - cmode->srect.bottom=FSettings.LastSLine+1; - - cmode->drect.top=(cmode->y-(FSettings.TotalScanlines()*cmode->yscale))>>1; - cmode->drect.bottom=cmode->drect.top+FSettings.TotalScanlines()*cmode->yscale; - - cmode->drect.left=(cmode->x-(VNSWID*cmode->xscale))>>1; - cmode->drect.right=cmode->drect.left+VNSWID*cmode->xscale; - } - - // -Video Modes Tag- - if((cmode->special == 1 || cmode->special == 4) && cmode->bpp == 8) - { - cmode->bpp = 32; - //FCEUD_PrintError("HQ2x/HQ3x requires 16bpp or 32bpp(best)."); - //return(0); - } - - if(cmode->xyflags&VMDF_STRFS)) - { - FCEUD_PrintError("Vertical resolution must not be less than the total number of drawn scanlines."); - return(0); - } - - return(1); -} - -BOOL SetDlgItemDouble(HWND hDlg, int item, double value) -{ - char buf[16]; - sprintf(buf,"%.6f",value); - return SetDlgItemText(hDlg, item, buf); -} - -double GetDlgItemDouble(HWND hDlg, int item) -{ - char buf[16]; - double ret = 0; - - GetDlgItemText(hDlg, item, buf, 15); - sscanf(buf,"%lf",&ret); - return(ret); -} - -BOOL CALLBACK VideoConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static char *vmstr[11]={ - "Custom", - "320x240 Full Screen", - "512x384 Centered", - "640x480 Centered", - "640x480 Scanlines", - "640x480 \"4 per 1\"", - "640x480 2x,2y", - "1024x768 4x,3y", - "1280x1024 5x,4y", - "1600x1200 6x,5y", - "800x600 Stretched" - }; - //int x; - - switch(uMsg) - { - case WM_INITDIALOG: - { - /* - for(x=0;x<11;x++) - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_MODE,CB_ADDSTRING,0,(LPARAM)(LPSTR)vmstr[x]); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_MODE,CB_SETCURSEL,vmod,(LPARAM)(LPSTR)0); - */ - - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_ADDSTRING,0,(LPARAM)(LPSTR)"8"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_ADDSTRING,0,(LPARAM)(LPSTR)"16"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_ADDSTRING,0,(LPARAM)(LPSTR)"24"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_ADDSTRING,0,(LPARAM)(LPSTR)"32"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_SETCURSEL,(vmodes[0].bpp>>3)-1,(LPARAM)(LPSTR)0); - - SetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_XRES,vmodes[0].x,0); - SetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_YRES,vmodes[0].y,0); - - //SetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_XSCALE,vmodes[0].xscale,0); - //SetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_YSCALE,vmodes[0].yscale,0); - //CheckRadioButton(hwndDlg,IDC_RADIO_SCALE,IDC_RADIO_STRETCH,(vmodes[0].flags&VMDF_STRFS)?IDC_RADIO_STRETCH:IDC_RADIO_SCALE); - - // -Video Modes Tag- - char *str[]={"","hq2x","Scale2x","NTSC 2x","hq3x","Scale3x"}; - int x; - for(x=0;x<6;x++) - { - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SCALER_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)str[x]); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SCALER_WIN,CB_ADDSTRING,0,(LPARAM)(LPSTR)str[x]); - } - - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_SCALER_FS, CB_SETCURSEL, vmodes[0].special, (LPARAM)(LPSTR)0); - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_SCALER_WIN, CB_SETCURSEL, winspecial, (LPARAM)(LPSTR)0); - - // Direct Draw modes - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_WIN, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"No hardware acceleration"); - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_WIN, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Create Surface in RAM"); - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_WIN, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Hardware acceleration"); - - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_WIN, CB_SETCURSEL, directDrawModeWindowed, (LPARAM)(LPSTR)0); - - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_FS, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"No hardware acceleration"); - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_FS, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Create Surface in RAM"); - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_FS, CB_ADDSTRING, 0, (LPARAM)(LPSTR)"Hardware acceleration"); - - SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_FS, CB_SETCURSEL, directDrawModeFullscreen, (LPARAM)(LPSTR)0); - - if(eoptions&EO_FSAFTERLOAD) - CheckDlgButton(hwndDlg,IDC_VIDEOCONFIG_AUTO_FS,BST_CHECKED); - - if(eoptions&EO_HIDEMOUSE) - CheckDlgButton(hwndDlg,IDC_VIDEOCONFIG_HIDEMOUSE,BST_CHECKED); - - if(eoptions&EO_CLIPSIDES) - CheckDlgButton(hwndDlg,IDC_VIDEOCONFIG_CLIPSIDES,BST_CHECKED); - - if(eoptions&EO_BESTFIT) - CheckDlgButton(hwndDlg, IDC_VIDEOCONFIG_BESTFIT, BST_CHECKED); - - if(eoptions&EO_BGCOLOR) - CheckDlgButton(hwndDlg,IDC_VIDEOCONFIG_CONSOLE_BGCOLOR,BST_CHECKED); - - if(eoptions&EO_SQUAREPIXELS) - CheckDlgButton(hwndDlg, IDC_VIDEOCONFIG_SQUARE_PIXELS, BST_CHECKED); - - if(eoptions&EO_TVASPECT) - CheckDlgButton(hwndDlg, IDC_VIDEOCONFIG_TVASPECT, BST_CHECKED); - - if(eoptions&EO_FORCEISCALE) - CheckDlgButton(hwndDlg,IDC_FORCE_INT_VIDEO_SCALARS,BST_CHECKED); - - if(eoptions&EO_FORCEASPECT) - CheckDlgButton(hwndDlg,IDC_FORCE_ASPECT_CORRECTION,BST_CHECKED); - - SetDlgItemInt(hwndDlg,IDC_SCANLINE_FIRST_NTSC,srendlinen,0); - SetDlgItemInt(hwndDlg,IDC_SCANLINE_LAST_NTSC,erendlinen,0); - - SetDlgItemInt(hwndDlg,IDC_SCANLINE_FIRST_PAL,srendlinep,0); - SetDlgItemInt(hwndDlg,IDC_SCANLINE_LAST_PAL,erendlinep,0); - - - SetDlgItemDouble(hwndDlg, IDC_WINSIZE_MUL_X, winsizemulx); - SetDlgItemDouble(hwndDlg, IDC_WINSIZE_MUL_Y, winsizemuly); - SetDlgItemDouble(hwndDlg, IDC_TVASPECT_X, tvAspectX); - SetDlgItemDouble(hwndDlg, IDC_TVASPECT_Y, tvAspectY); - - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_WIN,CB_ADDSTRING,0,(LPARAM)(LPSTR)""); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)""); - - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_WIN,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Wait for VBlank"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_WIN,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Lazy wait for VBlank"); - - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Wait for VBlank"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Lazy wait for VBlank"); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Double Buffering"); - - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_WIN,CB_SETCURSEL,winsync,(LPARAM)(LPSTR)0); - SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_SETCURSEL,fssync,(LPARAM)(LPSTR)0); - - if(eoptions&EO_NOSPRLIM) - CheckDlgButton(hwndDlg,IDC_VIDEOCONFIG_NO8LIM,BST_CHECKED); - - char buf[1024] = "Full Screen"; - int c = FCEUD_CommandMapping[EMUCMD_MISC_TOGGLEFULLSCREEN]; - if (c) - { - strcat(buf, " ("); - strcat(buf, GetKeyComboName(c)); - if (fullscreenByDoubleclick) - strcat(buf, " or double-click)"); - else - strcat(buf, ")"); - } else if (fullscreenByDoubleclick) - { - strcat(buf, " (double-click anywhere)"); - } - SetDlgItemText(hwndDlg, IDC_VIDEOCONFIG_FS, buf); - break; - } - case WM_CLOSE: - case WM_QUIT: goto gornk; - case WM_COMMAND: - if(!(wParam>>16)) - switch(wParam&0xFFFF) - { - case ID_CANCEL: -gornk: - - if(IsDlgButtonChecked(hwndDlg,IDC_VIDEOCONFIG_CLIPSIDES)==BST_CHECKED) - { - eoptions|=EO_CLIPSIDES; - ClipSidesOffset = 8; - } - else - { - eoptions&=~EO_CLIPSIDES; - ClipSidesOffset = 0; - } - - if (IsDlgButtonChecked(hwndDlg, IDC_VIDEOCONFIG_BESTFIT) == BST_CHECKED) - eoptions |= EO_BESTFIT; - else - eoptions &= ~EO_BESTFIT; - - if (IsDlgButtonChecked(hwndDlg, IDC_VIDEOCONFIG_CONSOLE_BGCOLOR) == BST_CHECKED) - eoptions |= EO_BGCOLOR; - else - eoptions &= ~EO_BGCOLOR; - - if (IsDlgButtonChecked(hwndDlg, IDC_VIDEOCONFIG_SQUARE_PIXELS) == BST_CHECKED) - eoptions |= EO_SQUAREPIXELS; - else - eoptions &= ~EO_SQUAREPIXELS; - - if (IsDlgButtonChecked(hwndDlg, IDC_VIDEOCONFIG_TVASPECT) == BST_CHECKED) - eoptions |= EO_TVASPECT; - else - eoptions &= ~EO_TVASPECT; - - if(IsDlgButtonChecked(hwndDlg,IDC_VIDEOCONFIG_NO8LIM)==BST_CHECKED) - eoptions|=EO_NOSPRLIM; - else - eoptions&=~EO_NOSPRLIM; - - srendlinen=GetDlgItemInt(hwndDlg,IDC_SCANLINE_FIRST_NTSC,0,0); - erendlinen=GetDlgItemInt(hwndDlg,IDC_SCANLINE_LAST_NTSC,0,0); - srendlinep=GetDlgItemInt(hwndDlg,IDC_SCANLINE_FIRST_PAL,0,0); - erendlinep=GetDlgItemInt(hwndDlg,IDC_SCANLINE_LAST_PAL,0,0); - - - if(erendlinen>239) erendlinen=239; - if(srendlinen>erendlinen) srendlinen=erendlinen; - - if(erendlinep>239) erendlinep=239; - if(srendlinep>erendlinen) srendlinep=erendlinep; - - UpdateRendBounds(); - - /* - if(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STRETCH)==BST_CHECKED) - vmodes[0].flags |= VMDF_STRFS|VMDF_DXBLT; - else - vmodes[0].flags &= ~(VMDF_STRFS|VMDF_DXBLT); - vmod=SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_MODE,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - */ - vmodes[0].x=GetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_XRES,0,0); - vmodes[0].y=GetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_YRES,0,0); - vmodes[0].bpp=(SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_BPP,CB_GETCURSEL,0,(LPARAM)(LPSTR)0)+1)<<3; - - //vmodes[0].xscale=GetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_XSCALE,0,0); - //vmodes[0].yscale=GetDlgItemInt(hwndDlg,IDC_VIDEOCONFIG_YSCALE,0,0); - vmodes[0].special=SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SCALER_FS,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - - winspecial = SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_SCALER_WIN, CB_GETCURSEL, 0, (LPARAM)(LPSTR)0); - directDrawModeWindowed = SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_WIN, CB_GETCURSEL, 0, (LPARAM)(LPSTR)0) % DIRECTDRAW_MODES_TOTAL; - directDrawModeFullscreen = SendDlgItemMessage(hwndDlg, IDC_VIDEOCONFIG_DIRECTDRAW_FS, CB_GETCURSEL, 0, (LPARAM)(LPSTR)0) % DIRECTDRAW_MODES_TOTAL; - - if(IsDlgButtonChecked(hwndDlg,IDC_VIDEOCONFIG_FS)==BST_CHECKED) - fullscreen=1; - else - fullscreen=0; - - if(IsDlgButtonChecked(hwndDlg,IDC_VIDEOCONFIG_AUTO_FS)==BST_CHECKED) - eoptions|=EO_FSAFTERLOAD; - else - eoptions&=~EO_FSAFTERLOAD; - - if(IsDlgButtonChecked(hwndDlg,IDC_VIDEOCONFIG_HIDEMOUSE)==BST_CHECKED) - eoptions|=EO_HIDEMOUSE; - else - eoptions&=~EO_HIDEMOUSE; - - eoptions &= ~(EO_FORCEISCALE | EO_FORCEASPECT); - if(IsDlgButtonChecked(hwndDlg,IDC_FORCE_INT_VIDEO_SCALARS)==BST_CHECKED) - eoptions|=EO_FORCEISCALE; - if(IsDlgButtonChecked(hwndDlg,IDC_FORCE_ASPECT_CORRECTION)==BST_CHECKED) - eoptions|=EO_FORCEASPECT; - - winsizemulx = GetDlgItemDouble(hwndDlg, IDC_WINSIZE_MUL_X); - winsizemuly = GetDlgItemDouble(hwndDlg, IDC_WINSIZE_MUL_Y); - FixWXY(0); - tvAspectX = GetDlgItemDouble(hwndDlg, IDC_TVASPECT_X); - tvAspectY = GetDlgItemDouble(hwndDlg, IDC_TVASPECT_Y); - if (tvAspectX < 0.1) - tvAspectX = 0.1; - if (tvAspectY < 0.1) - tvAspectY = 0.1; - - winsync=SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_WIN,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - fssync=SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SYNC_METHOD_FS,CB_GETCURSEL,0,(LPARAM)(LPSTR)0); - EndDialog(hwndDlg,0); - break; - } - } - return 0; -} - -void SetFSVideoMode() -{ - changerecursive=1; - if(!SetVideoMode(1)) - SetVideoMode(0); - changerecursive=0; -} - - -void DoVideoConfigFix(void) -{ - FCEUI_DisableSpriteLimitation(eoptions&EO_NOSPRLIM); - UpdateRendBounds(); -} - -void PushCurrentVideoSettings() -{ - if(fullscreen) - { - SetFSVideoMode(); - } - else - { - changerecursive = 1; - SetVideoMode(0); - changerecursive = 0; - //SetMainWindowStuff(); // it's already called inside SetVideoMode() - } -} - -//Shows the Video configuration dialog. -void ConfigVideo(void) -{ - if ((vmodes[0].x <= 0) || (vmodes[0].y <= 0)) - ResetCustomMode(); - DialogBox(fceu_hInstance, "VIDEOCONFIG", hAppWnd, VideoConCallB); - DoVideoConfigFix(); - PushCurrentVideoSettings(); -} - -void FCEUD_VideoChanged() -{ - PushCurrentVideoSettings(); -} \ No newline at end of file diff --git a/branches/fceux-2.2.2/src/drivers/win/window.cpp b/branches/fceux-2.2.2/src/drivers/win/window.cpp deleted file mode 100644 index 9c41d173..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/window.cpp +++ /dev/null @@ -1,3058 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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. -*f -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -//http://www.nubaria.com/en/blog/?p=289 - -// File description: Everything relevant for the main window should go here. This -// does not include functions relevant for dialog windows. - -#include "../../input.h" -#include "../../state.h" -#include "../../cheat.h" //adelikat: For FCEU_LoadGameCheats() -#include "../../version.h" -#include "../../video.h" //adelikat: For ScreenshotAs Get/Set functions -#include "window.h" -#include "main.h" -#include "state.h" - -#include "sound.h" -#include "wave.h" -#include "input.h" -#include "video.h" -#include "input.h" -#include "fceu.h" - -#include "ram_search.h" -#include "ramwatch.h" -#include "memwatch.h" -#include "ppuview.h" -#include "debugger.h" -#include "cheat.h" -#include "debug.h" -#include "ntview.h" -#include "memview.h" -#include "tracer.h" -#include "cdlogger.h" -#include "throttle.h" -#include "monitor.h" -#include "keyboard.h" -#include "joystick.h" -#include "oldmovie.h" -#include "movie.h" -#include "texthook.h" -#include "guiconfig.h" -#include "timing.h" -#include "palette.h" -#include "directories.h" -#include "gui.h" -#include "help.h" -#include "movie.h" -#include "fceulua.h" -#include "utils/xstring.h" -#include "file.h" -#include "mapinput.h" -#include "movieoptions.h" -#include "config.h" //adelikat: For SaveConfigFile() - -#include -#include -#include - -#include "taseditor/taseditor_window.h" -#include "taseditor/playback.h" -extern TASEDITOR_WINDOW taseditorWindow; -extern PLAYBACK playback; - -#include "Win32InputBox.h" -extern int32 fps_scale_unpaused; - -//extern void ToggleFullscreen(); - -using namespace std; - -//----Context Menu - Some dynamically added menu items -#define FCEUX_CONTEXT_UNHIDEMENU 60000 -#define FCEUX_CONTEXT_LOADLASTLUA 60001 -#define FCEUX_CONTEXT_CLOSELUAWINDOWS 60002 -#define FCEUX_CONTEXT_TOGGLESUBTITLES 60003 -#define FCEUX_CONTEXT_DUMPSUBTITLES 60004 - - -//******************************************************************************** -//Globals -//******************************************************************************** - -//Handles---------------------------------------------- -static HMENU fceumenu = 0; //Main menu. -HWND pwindow; //Client Area -HMENU recentmenu; //Recent Menu -HMENU recentluamenu; //Recent Lua Files Menu -HMENU recentmoviemenu; //Recent Movie Files Menu -HMENU hfceuxcontext; //Handle to context menu -HMENU hfceuxcontextsub; //Handle to context sub menu -HWND MainhWnd; //Main FCEUX(Parent) window Handle. Dialogs should use GetMainHWND() to get this - -//Extern variables------------------------------------- -extern bool movieSubtitles; -extern FCEUGI *GameInfo; -extern int EnableAutosave; -extern bool frameAdvanceLagSkip; -extern bool turbo; -extern bool movie_readonly; -extern bool AutoSS; //flag for whether an auto-save has been made -extern int newppu; -extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog -extern bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists -extern bool oldInputDisplay; - -//AutoFire----------------------------------------------- -void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add -void MapInput(void); -void SetAutoFirePattern(int onframes, int offframes); -void SetAutoFireOffset(int offset); -static int CheckedAutoFirePattern = MENU_AUTOFIRE_PATTERN_1; -static int CheckedAutoFireOffset = MENU_AUTOFIRE_OFFSET_1; -int GetCheckedAutoFirePattern(); -int GetCheckedAutoFireOffset(); - -//Internal variables------------------------------------- -char *md5_asciistr(uint8 digest[16]); -static int winwidth, winheight; -static volatile int nofocus = 0; -static int tog = 0; //Toggle for Hide Menu -static bool loggingSound = false; -static LONG WindowXC=1<<30,WindowYC; -int MainWindow_wndx, MainWindow_wndy; -static uint32 mousex,mousey,mouseb; -static int vchanged = 0; -int menuYoffset = 0; -bool wasPausedByCheats = false; //For unpausing the emulator if paused by the cheats dialog -bool rightClickEnabled = true; //If set to false, the right click context menu will be disabled. -bool fullscreenByDoubleclick = false; - -//Function Prototypes -void ChangeMenuItemText(int menuitem, string text); //Alters a menu item name -void ChangeContextMenuItemText(int menuitem, string text, HMENU menu); //Alters a context menu item name -void SaveMovieAs(); //Gets a filename for Save Movie As... -void OpenRamSearch(); -void OpenRamWatch(); -void SaveSnapshotAs(); - -//Recent Menu Strings ------------------------------------ -char *recent_files[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -const unsigned int MENU_FIRST_RECENT_FILE = 600; -const unsigned int MAX_NUMBER_OF_RECENT_FILES = sizeof(recent_files)/sizeof(*recent_files); - -//Lua Console -------------------------------------------- -//TODO: these need to be in a header file instead -extern HWND LuaConsoleHWnd; -extern INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); -extern void UpdateLuaConsole(const char* fname); - -//Recent Lua Menu ---------------------------------------- -char *recent_lua[] = { 0, 0, 0, 0, 0 }; -const unsigned int LUA_FIRST_RECENT_FILE = 50000; -const unsigned int MAX_NUMBER_OF_LUA_RECENT_FILES = sizeof(recent_lua)/sizeof(*recent_lua); - -//Recent Movie Menu ------------------------------------- -char *recent_movie[] = { 0, 0, 0, 0, 0 }; -const unsigned int MOVIE_FIRST_RECENT_FILE = 51000; -const unsigned int MAX_NUMBER_OF_MOVIE_RECENT_FILES = sizeof(recent_movie)/sizeof(*recent_movie); - -//Exported variables ------------------------------------ - -int EnableBackgroundInput = 0; -int ismaximized = 0; - -//Help Menu subtopics -string moviehelp = "MovieRecording"; //Movie Recording -string gettingstartedhelp = "Gettingstarted";//Getting Started - -//******************************************************************************** -void SetMainWindowText() -{ - string str = FCEU_NAME_AND_VERSION; - if (newppu) - str.append(" (New PPU)"); - if (GameInfo) - { - //Add the filename to the window caption - extern char FileBase[]; - str.append(": "); - str.append(FileBase); - if (FCEUMOV_IsLoaded()) - { - str.append(" Playing: "); - str.append(StripPath(FCEUI_GetMovieName())); - } - } - SetWindowText(hAppWnd, str.c_str()); -} - -bool HasRecentFiles() -{ - for (int x = 0; x < MAX_NUMBER_OF_RECENT_FILES; x++) - { - if (recent_files[x]) - return true; - } - return false; -} - -HWND GetMainHWND() -{ - return MainhWnd; -} - -int GetCheckedAutoFirePattern() -{ -//adelikat: sorry, I'm sure there is an easier way to accomplish this. -//This function allows the proper check to be displayed on the auto-fire pattern offset at start up when another autofire pattern is saved in config - if (AFon == 1 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_2; - if (AFon == 1 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_3; - if (AFon == 1 && AFoff == 4) return MENU_AUTOFIRE_PATTERN_4; - if (AFon == 1 && AFoff == 5) return MENU_AUTOFIRE_PATTERN_5; - if (AFon == 2 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_6; - if (AFon == 2 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_7; - if (AFon == 2 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_8; - if (AFon == 2 && AFoff == 4) return MENU_AUTOFIRE_PATTERN_9; - if (AFon == 3 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_10; - if (AFon == 3 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_11; - if (AFon == 3 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_12; - if (AFon == 4 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_13; - if (AFon == 4 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_14; - if (AFon == 5 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_15; - -return MENU_AUTOFIRE_PATTERN_1; -} - -int GetCheckedAutoFireOffset() -{ - if (AutoFireOffset == 1) return MENU_AUTOFIRE_OFFSET_2; - if (AutoFireOffset == 2) return MENU_AUTOFIRE_OFFSET_3; - if (AutoFireOffset == 3) return MENU_AUTOFIRE_OFFSET_4; - if (AutoFireOffset == 4) return MENU_AUTOFIRE_OFFSET_5; - if (AutoFireOffset == 5) return MENU_AUTOFIRE_OFFSET_6; - return MENU_AUTOFIRE_OFFSET_1; -} - -// Internal functions - - - -static void ConvertFCM(HWND hwndOwner) -{ - std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE); - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndOwner; - ofn.lpstrFilter = "FCEU <2.0 Movie Files (*.fcm)\0*.fcm\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFile = new char[640*1024]; //640K should be enough for anyone - ofn.lpstrFile[0] = 0; - ofn.nMaxFile = 640*1024; - ofn.lpstrInitialDir = initdir.c_str(); - ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_EXPLORER; - ofn.lpstrDefExt = "fcm"; - ofn.lpstrTitle = "Select old movie(s) for conversion"; - - if(GetOpenFileName(&ofn)) - { - std::vector todo; - - //build a list of movies to convert. this might be one, or it might be many, depending on what the user selected - if(ofn.nFileExtension==0) - { - //multiselect - std::string dir = ofn.lpstrFile; - char* cp = ofn.lpstrFile + dir.size() + 1; - while(*cp) - { - std::string fname = cp; - todo.push_back(dir + "/" + fname); - cp += fname.size() + 1; - } - } - else - { - todo.push_back(ofn.lpstrFile); - } - - SetCursor(LoadCursor(0,IDC_WAIT)); - - //convert each movie - int okcount = 0; - for(uint32 i=0;ileft = 0; - al->top = 0; - al->right = ceil(screen_width * winsizemulx); - al->bottom = menuYoffset + ceil(screen_height * winsizemuly); - - AdjustWindowRectEx(al, - GetWindowLong(hAppWnd, GWL_STYLE), - GetMenu(hAppWnd) != NULL, - GetWindowLong(hAppWnd, GWL_EXSTYLE) - ); - - al->right -= al->left; - al->left = 0; - al->bottom -= al->top; - al->top=0; -} - -/// Updates the menu items that should only be enabled if a game is loaded. -/// @param enable Flag that indicates whether the menus should be enabled (1) or disabled (0). -void updateGameDependentMenus(unsigned int enable) -{ - const int menu_ids[]= { - MENU_CLOSE_FILE, - ID_FILE_SCREENSHOT, - ID_FILE_SAVESCREENSHOTAS, - MENU_RESET, - MENU_POWER, - MENU_INSERT_COIN, - MENU_SWITCH_DISK, - MENU_EJECT_DISK, - MENU_RECORD_AVI, - MENU_STOP_AVI, - MENU_RECORD_WAV, - MENU_STOP_WAV, - MENU_HIDE_MENU, - //MENU_DEBUGGER, - MENU_PPUVIEWER, - MENU_NAMETABLEVIEWER, - MENU_HEXEDITOR, - MENU_TRACELOGGER, - MENU_CDLOGGER, - MENU_GAMEGENIEDECODER, - MENU_CHEATS, - ID_RAM_SEARCH, - ID_RAM_WATCH, - ID_TOOLS_TEXTHOOKER - }; - - for (unsigned int i = 0; i < sizeof(menu_ids) / sizeof(*menu_ids); i++) - { - EnableMenuItem(fceumenu, menu_ids[i], MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED)); - } -} - -//Updates menu items which need to be checked or unchecked. -void UpdateCheckedMenuItems() -{ - bool spr, bg; - FCEUI_GetRenderPlanes(spr,bg); - - static int *polo[] = { &genie, &pal_emulation, &status_icon}; - static int polo2[]={ MENU_GAME_GENIE, MENU_PAL, MENU_SHOW_STATUS_ICON }; - int x; - - // Check or uncheck the necessary menu items - for(x = 0; x < sizeof(polo) / sizeof(*polo); x++) - { - CheckMenuItem(fceumenu, polo2[x], *polo[x] ? MF_CHECKED : MF_UNCHECKED); - } - //File Menu - CheckMenuItem(fceumenu, ID_FILE_MOVIE_TOGGLEREAD, movie_readonly ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_FILE_OPENLUAWINDOW, LuaConsoleHWnd ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_AVI_ENABLEHUDRECORDING, FCEUI_AviEnableHUDrecording() ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_AVI_DISMOVIEMESSAGE, FCEUI_AviDisableMovieMessages() ? MF_CHECKED : MF_UNCHECKED); - - //NES Menu - CheckMenuItem(fceumenu, ID_NES_PAUSE, EmulationPaused ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_NES_TURBO, turbo ? MF_CHECKED : MF_UNCHECKED); - - //Config Menu - CheckMenuItem(fceumenu, MENU_RUN_IN_BACKGROUND, eoptions & EO_BGRUN ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_BACKGROUND_INPUT, EnableBackgroundInput ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_ENABLE_AUTOSAVE, EnableAutosave ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_DISPLAY_FA_LAGSKIP, frameAdvanceLagSkip?MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_CONFIG_BINDSAVES, bindSavestate?MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_ENABLE_BACKUPSAVESTATES, backupSavestates?MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_ENABLE_COMPRESSSAVESTATES, compressSavestates?MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_ENABLE_AUTORESUME, AutoResumePlay?MF_CHECKED : MF_UNCHECKED); - - //Config - Display SubMenu - CheckMenuItem(fceumenu, MENU_DISPLAY_LAGCOUNTER, lagCounterDisplay?MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_DISPLAY_FRAMECOUNTER, frame_display ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_DISPLAY_RERECORDCOUNTER, rerecord_display ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_DISPLAY_FPS, FCEUI_ShowFPS() ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_DISPLAY_MOVIESTATUSICON, status_icon ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_DISPLAY_BG, bg?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(fceumenu, MENU_DISPLAY_OBJ, spr?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(fceumenu, ID_INPUTDISPLAY_OLDSTYLEDISP, oldInputDisplay?MF_CHECKED:MF_UNCHECKED); - - // Tools Menu - CheckMenuItem(fceumenu, MENU_ALTERNATE_AB, GetAutoFireDesynch() ? MF_CHECKED : MF_UNCHECKED); - CheckedAutoFirePattern = GetCheckedAutoFirePattern(); - CheckMenuRadioItem(fceumenu, MENU_AUTOFIRE_PATTERN_1, MENU_AUTOFIRE_PATTERN_15, CheckedAutoFirePattern, MF_BYCOMMAND); - CheckedAutoFireOffset = GetCheckedAutoFireOffset(); - CheckMenuRadioItem(fceumenu, MENU_AUTOFIRE_OFFSET_1, MENU_AUTOFIRE_OFFSET_6, CheckedAutoFireOffset, MF_BYCOMMAND); - - // Check input display - switch (input_display) - { - case 0: // Off - CheckMenuRadioItem(fceumenu, MENU_INPUTDISPLAY_0, MENU_INPUTDISPLAY_4, MENU_INPUTDISPLAY_0, MF_BYCOMMAND); - break; - case 1: // 1 player - CheckMenuRadioItem(fceumenu, MENU_INPUTDISPLAY_0, MENU_INPUTDISPLAY_4, MENU_INPUTDISPLAY_1, MF_BYCOMMAND); - break; - case 2: // 2 player - CheckMenuRadioItem(fceumenu, MENU_INPUTDISPLAY_0, MENU_INPUTDISPLAY_4, MENU_INPUTDISPLAY_2, MF_BYCOMMAND); - break; - // note: input display can actually have a 3 player display option but is skipped in the hotkey toggle so it is skipped here as well - case 4: // 4 player - CheckMenuRadioItem(fceumenu, MENU_INPUTDISPLAY_0, MENU_INPUTDISPLAY_4, MENU_INPUTDISPLAY_4, MF_BYCOMMAND); - break; - default: - break; - } -} - -void UpdateContextMenuItems(HMENU context, int whichContext) -{ - string undoLoadstate = "Undo loadstate"; - string redoLoadstate = "Redo loadstate"; - string undoSavestate = "Undo savestate"; - string redoSavestate = "Redo savestate"; - - CheckMenuItem(context,ID_CONTEXT_FULLSAVESTATES,MF_BYCOMMAND | (fullSaveStateLoads ? MF_CHECKED : MF_UNCHECKED)); - - //Undo Loadstate - if (CheckBackupSaveStateExist() && (undoLS || redoLS)) - EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | MF_GRAYED); - if (redoLS) - ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOLOADSTATE, redoLoadstate, context); - else - ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOLOADSTATE, undoLoadstate, context); - - //Undo Savestate - if (undoSS || redoSS) //If undo or redo, enable Undo savestate, else keep it gray - EnableMenuItem(context,FCEUX_CONTEXT_UNDOSAVESTATE,MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(context,FCEUX_CONTEXT_UNDOSAVESTATE,MF_BYCOMMAND | MF_GRAYED); - if (redoSS) - ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOSAVESTATE, redoSavestate, context); - else - ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOSAVESTATE, undoSavestate, context); - - //Rewind to last auto-save - if(EnableAutosave && AutoSS) - EnableMenuItem(context,FCEUX_CONTEXT_REWINDTOLASTAUTO,MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(context,FCEUX_CONTEXT_REWINDTOLASTAUTO,MF_BYCOMMAND | MF_GRAYED); - - //Load last ROM - if (recent_files[0]) - EnableMenuItem(context,FCEUX_CONTEXT_RECENTROM1,MF_BYCOMMAND | MF_ENABLED); - else - EnableMenuItem(context,FCEUX_CONTEXT_RECENTROM1,MF_BYCOMMAND | MF_GRAYED); - - //Add Lua separator if either lua condition is true (yeah, a little ugly but it works) - #ifdef _S9XLUA_H - if (recent_lua[0] || FCEU_LuaRunning()) - InsertMenu(context, 0xFFFF, MF_SEPARATOR, 0, ""); - - //If a recent lua file exists, add Load Last Lua - if (recent_lua[0]) - InsertMenu(context, 0xFFFF, MF_BYCOMMAND, FCEUX_CONTEXT_LOADLASTLUA, "Load last Lua"); - - //If lua is loaded, add a stop lua item - if (FCEU_LuaRunning()) - InsertMenu(context, 0xFFFF, MF_BYCOMMAND, FCEUX_CONTEXT_CLOSELUAWINDOWS, "Close All Script Windows"); - #endif - - //If menu is hidden, add an Unhide menu option - if (tog) - { - InsertMenu(context, 0xFFFF, MF_SEPARATOR, 0, ""); - InsertMenu(context,0xFFFF, MF_BYCOMMAND, FCEUX_CONTEXT_UNHIDEMENU, "Unhide Menu"); - } - - if ( ( (whichContext == 0) || (whichContext == 3) ) && (currMovieData.subtitles.size()) ){ - // At position 3 is "View comments and subtitles". Insert this there: - - InsertMenu(context,0x3, MF_BYPOSITION, FCEUX_CONTEXT_TOGGLESUBTITLES, movieSubtitles ? "Subtitle Display: On" : "Subtitle Display: Off"); - // At position 4(+1) is after View comments and subtitles. Insert this there: - InsertMenu(context,0x5, MF_BYPOSITION, FCEUX_CONTEXT_DUMPSUBTITLES, "Dump Subtitles to SRT file"); - } -} - - -//adelikat: This removes a recent menu item from any recent menu, and shrinks the list accordingly -//The update recent menu function will need to be run after this -void RemoveRecentItem(unsigned int which, char**bufferArray, const unsigned int MAX) -{ - //which = array item to remove - //buffer = char array of the recent menu - //MAX = max number of array items - - //Just in case - if (which >= MAX) - return; - - //Remove the item - if(bufferArray[which]) - { - free(bufferArray[which]); - } - - //If the item is not the last one in the list, shift the remaining ones up - if (which < (MAX-1)) - { - //Move the remaining items up - for(unsigned int x = which+1; x < MAX; x++) - { - bufferArray[x-1] = bufferArray[x]; //Shift each remaining item up by 1 - } - } - - bufferArray[MAX-1] = 0; //Clear out the last item since it is empty now no matter what -} - -/// Updates recent files / recent directories menu -/// @param menu Menu handle of the main window's menu -/// @param strs Strings to add to the menu -/// @param mitem Menu ID of the recent files / directory menu -/// @param baseid Menu ID of the first subitem -void UpdateRMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid) -{ - // UpdateRMenu(recentmenu, recent_files, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); - - MENUITEMINFO moo; - int x; - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_SUBMENU | MIIM_STATE; - - GetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - moo.hSubMenu = menu; - moo.fState = strs[0] ? MFS_ENABLED : MFS_GRAYED; - - SetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - - // Remove all recent files submenus - for(x = 0; x < MAX_NUMBER_OF_RECENT_FILES; x++) - { - RemoveMenu(menu, baseid + x, MF_BYCOMMAND); - } - - // Recreate the menus - for(x = MAX_NUMBER_OF_RECENT_FILES - 1; x >= 0; x--) - { - // Skip empty strings - if(!strs[x]) - continue; - - std::string tmp = strs[x]; - std::string archiveName, fileName, fileToOpen; - FCEU_SplitArchiveFilename(tmp,archiveName,fileName,fileToOpen); - if(archiveName != "") - tmp = archiveName + " <" + fileName + ">"; - - //clamp this string to 128 chars - if(tmp.size()>128) - tmp = tmp.substr(0,128); - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - - //// Fill in the menu text. - //if(strlen(strs[x]) < 128) - //{ - // sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]); - //} - //else - //{ - // sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127); - //} - - // Insert the menu item - moo.cch = tmp.size(); - moo.fType = 0; - moo.wID = baseid + x; - moo.dwTypeData = (LPSTR)tmp.c_str(); - InsertMenuItem(menu, 0, 1, &moo); - } - - DrawMenuBar(hAppWnd); -} - -/// Helper function to populate the recent directories and recent files arrays. -/// @param addString String to add to the array. -/// @param bufferArray Array where the string will be added. -/// @param arrayLen Length of the bufferArray. -/// @param menu Menu handle of the main menu. -/// @param menuItem -/// @param baseID -void UpdateRecentArray(const char* addString, char** bufferArray, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId) -{ - // Try to find out if the filename is already in the recent files list. - for(unsigned int x = 0; x < arrayLen; x++) - { - if(bufferArray[x]) - { - if(!strcmp(bufferArray[x], addString)) // Item is already in list. - { - // If the filename is in the file list don't add it again. - // Move it up in the list instead. - - int y; - char *tmp; - - // Save pointer. - tmp = bufferArray[x]; - - for(y = x; y; y--) - { - // Move items down. - bufferArray[y] = bufferArray[y - 1]; - } - - // Put item on top. - bufferArray[0] = tmp; - - // Update the recent files menu - UpdateRMenu(menu, bufferArray, menuItem, baseId); - - return; - } - } - } - - // The filename wasn't found in the list. That means we need to add it. - - // If there's no space left in the recent files list, get rid of the last - // item in the list. - if(bufferArray[arrayLen - 1]) - { - free(bufferArray[arrayLen - 1]); - } - - // Move the other items down. - for(unsigned int x = arrayLen - 1; x; x--) - { - bufferArray[x] = bufferArray[x - 1]; - } - - // Add the new item. - bufferArray[0] = (char*)malloc(strlen(addString) + 1); //mbg merge 7/17/06 added cast - strcpy(bufferArray[0], addString); - - // Update the recent files menu - UpdateRMenu(menu, bufferArray, menuItem, baseId); -} - -/// Add a filename to the recent files list. -/// @param filename Name of the file to add. -void AddRecentFile(const char *filename) -{ - UpdateRecentArray(filename, recent_files, MAX_NUMBER_OF_RECENT_FILES, recentmenu, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); -} - -void LoadRecentRom(int slot) -{ - char*& fname = recent_files[slot]; - if(fname) - { - if (!ALoad(fname)) - { - int result = MessageBox(hAppWnd, "Remove from list?", "Could Not Open Recent File", MB_YESNO); - if (result == IDYES) - { - RemoveRecentItem(slot, recent_files, MAX_NUMBER_OF_RECENT_FILES); - UpdateRMenu(recentmenu, recent_files, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); - } - } - } -} - -void UpdateLuaRMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid) -{ - MENUITEMINFO moo; - int x; - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_SUBMENU | MIIM_STATE; - - GetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - moo.hSubMenu = menu; - moo.fState = strs[0] ? MFS_ENABLED : MFS_GRAYED; - - SetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - - // Remove all recent files submenus - for(x = 0; x < MAX_NUMBER_OF_LUA_RECENT_FILES; x++) - { - RemoveMenu(menu, baseid + x, MF_BYCOMMAND); - } - - // Recreate the menus - for(x = MAX_NUMBER_OF_LUA_RECENT_FILES - 1; x >= 0; x--) - { - // Skip empty strings - if(!strs[x]) - continue; - - string tmp = strs[x]; - - //clamp this string to 128 chars - if(tmp.size()>128) - tmp = tmp.substr(0,128); - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - - // Insert the menu item - moo.cch = tmp.size(); - moo.fType = 0; - moo.wID = baseid + x; - moo.dwTypeData = (LPSTR)tmp.c_str(); - InsertMenuItem(menu, 0, 1, &moo); - } - - DrawMenuBar(hAppWnd); -} - -void UpdateRecentLuaArray(const char* addString, char** bufferArray, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId) -{ - // Try to find out if the filename is already in the recent files list. - for(unsigned int x = 0; x < arrayLen; x++) - { - if(bufferArray[x]) - { - if(!strcmp(bufferArray[x], addString)) // Item is already in list. - { - // If the filename is in the file list don't add it again. - // Move it up in the list instead. - - int y; - char *tmp; - - // Save pointer. - tmp = bufferArray[x]; - - for(y = x; y; y--) - { - // Move items down. - bufferArray[y] = bufferArray[y - 1]; - } - - // Put item on top. - bufferArray[0] = tmp; - - // Update the recent files menu - UpdateLuaRMenu(menu, bufferArray, menuItem, baseId); - - return; - } - } - } - - // The filename wasn't found in the list. That means we need to add it. - - // If there's no space left in the recent files list, get rid of the last - // item in the list. - if(bufferArray[arrayLen - 1]) - { - free(bufferArray[arrayLen - 1]); - } - - // Move the other items down. - for(unsigned int x = arrayLen - 1; x; x--) - { - bufferArray[x] = bufferArray[x - 1]; - } - - // Add the new item. - bufferArray[0] = (char*)malloc(strlen(addString) + 1); //mbg merge 7/17/06 added cast - strcpy(bufferArray[0], addString); - - // Update the recent files menu - UpdateLuaRMenu(menu, bufferArray, menuItem, baseId); - -} - -void AddRecentLuaFile(const char *filename) -{ - UpdateRecentLuaArray(filename, recent_lua, MAX_NUMBER_OF_LUA_RECENT_FILES, recentluamenu, MENU_LUA_RECENT, LUA_FIRST_RECENT_FILE); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void UpdateMovieRMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid) -{ - MENUITEMINFO moo; - int x; - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_SUBMENU | MIIM_STATE; - - GetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - moo.hSubMenu = menu; - moo.fState = strs[0] ? MFS_ENABLED : MFS_GRAYED; - - SetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); - - // Remove all recent files submenus - for(x = 0; x < MAX_NUMBER_OF_MOVIE_RECENT_FILES; x++) - { - RemoveMenu(menu, baseid + x, MF_BYCOMMAND); - } - - // Recreate the menus - for(x = MAX_NUMBER_OF_MOVIE_RECENT_FILES - 1; x >= 0; x--) - { - // Skip empty strings - if(!strs[x]) - continue; - - string tmp = strs[x]; - - //clamp this string to 128 chars - if(tmp.size()>128) - tmp = tmp.substr(0,128); - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - - // Insert the menu item - moo.cch = tmp.size(); - moo.fType = 0; - moo.wID = baseid + x; - moo.dwTypeData = (LPSTR)tmp.c_str(); - InsertMenuItem(menu, 0, 1, &moo); - } - - DrawMenuBar(hAppWnd); -} - -void UpdateRecentMovieArray(const char* addString, char** bufferArray, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId) -{ - // Try to find out if the filename is already in the recent files list. - for(unsigned int x = 0; x < arrayLen; x++) - { - if(bufferArray[x]) - { - if(!strcmp(bufferArray[x], addString)) // Item is already in list. - { - // If the filename is in the file list don't add it again. - // Move it up in the list instead. - - int y; - char *tmp; - - // Save pointer. - tmp = bufferArray[x]; - - for(y = x; y; y--) - { - // Move items down. - bufferArray[y] = bufferArray[y - 1]; - } - - // Put item on top. - bufferArray[0] = tmp; - - // Update the recent files menu - UpdateMovieRMenu(menu, bufferArray, menuItem, baseId); - - return; - } - } - } - - // The filename wasn't found in the list. That means we need to add it. - - // If there's no space left in the recent files list, get rid of the last - // item in the list. - if(bufferArray[arrayLen - 1]) - { - free(bufferArray[arrayLen - 1]); - } - - // Move the other items down. - for(unsigned int x = arrayLen - 1; x; x--) - { - bufferArray[x] = bufferArray[x - 1]; - } - - // Add the new item. - bufferArray[0] = (char*)malloc(strlen(addString) + 1); //mbg merge 7/17/06 added cast - strcpy(bufferArray[0], addString); - - // Update the recent files menu - UpdateMovieRMenu(menu, bufferArray, menuItem, baseId); - -} - -void AddRecentMovieFile(const char *filename) -{ - UpdateRecentMovieArray(filename, recent_movie, MAX_NUMBER_OF_MOVIE_RECENT_FILES, recentmoviemenu, MENU_MOVIE_RECENT, MOVIE_FIRST_RECENT_FILE); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// Hides the main menu. -//@param hide_menu Flag to turn the main menu on (0) or off (1) -void HideMenu(unsigned int hide_menu) -{ - if(hide_menu) - { - SetMenu(hAppWnd, 0); - } - else - { - SetMenu(hAppWnd, fceumenu); - } -} - -void HideFWindow(int h) -{ - LONG desa; - - if (h) /* Full-screen. */ - { - RECT bo; - GetWindowRect(hAppWnd, &bo); - WindowXC = bo.left; - WindowYC = bo.top; - - SetMenu(hAppWnd, 0); - desa=WS_POPUP | WS_CLIPSIBLINGS; - } else - { - desa = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS; - HideMenu(tog); - - /* Stupid DirectDraw bug(I think?) requires this. Need to investigate it. */ - SetWindowPos(hAppWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE); - } - - SetWindowLong(hAppWnd, GWL_STYLE, desa | ( GetWindowLong(hAppWnd, GWL_STYLE) & WS_VISIBLE )); - SetWindowPos(hAppWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); -} - -//Toggles the display status of the main menu. -void ToggleHideMenu(void) -{ - if(!fullscreen && !nofocus && (GameInfo || tog)) - { - tog ^= 1; - HideMenu(tog); - SetMainWindowStuff(); - } -} - -//Toggles the display status of the main menu. -//TODO: We could get rid of this one. -void FCEUD_HideMenuToggle(void) -{ - ToggleHideMenu(); -} - -void CloseGame() -{ - if (GameInfo) - { - FCEUI_CloseGame(); - KillMemView(); - updateGameDependentMenus(GameInfo != 0); - updateGameDependentMenusDebugger(GameInfo != 0); - SetMainWindowText(); - } -} - -bool ALoad(const char *nameo, char* innerFilename, bool silent) -{ - int oldPaused = EmulationPaused; - - if (GameInfo) FCEUI_CloseGame(); - - if (FCEUI_LoadGameVirtual(nameo, 1, silent)) - { - pal_emulation = FCEUI_GetCurrentVidSystem(0, 0); - - UpdateCheckedMenuItems(); - - PushCurrentVideoSettings(); - - std::string recentFileName = nameo; - if(GameInfo->archiveFilename && GameInfo->archiveCount>1) - recentFileName = (std::string)GameInfo->archiveFilename + "|" + GameInfo->filename; - else - recentFileName = nameo; - - AddRecentFile(recentFileName.c_str()); - - RefreshThrottleFPS(); - - if(eoptions & EO_HIDEMENU && !tog) - { - ToggleHideMenu(); - } - - if(eoptions & EO_FSAFTERLOAD) - { - SetFSVideoMode(); - } - - - if (AutoRWLoad) - { - OpenRWRecentFile(0); //adelikat: TODO: This command should be called internally from the RamWatch dialog in order for it to be more portable - OpenRamWatch(); - } - if (debuggerAutoload) - { - DoDebug(0); - } - } - else - { - SetWindowText(hAppWnd, FCEU_NAME_AND_VERSION); //adelikat: If game fails to load while a previous one was open, the previous would have been closed, so reflect that in the window caption - return false; - } - - SetMainWindowText(); - ParseGIInput(GameInfo); - - updateGameDependentMenus(GameInfo != 0); - updateGameDependentMenusDebugger(GameInfo != 0); - EmulationPaused = oldPaused; - return true; -} - -/// Shows an Open File dialog and opens the ROM if the user selects a ROM file. -/// @param hParent Handle of the main window -/// @param initialdir Directory that's pre-selected in the Open File dialog. -void LoadNewGamey(HWND hParent, const char *initialdir) -{ - const char filter[] = "All usable files (*.nes,*.nsf,*.fds,*.unf,*.zip,*.rar,*.7z,*.gz)\0*.nes;*.nsf;*.fds;*.unf;*.zip;*.rar;*.7z;*.gz\0All non-compressed usable files (*.nes,*.nsf,*.fds,*.unf)\0*.nes;*.nsf;*.fds;*.unf\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - - // Create the Open File dialog - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle=FCEU_NAME" Open File..."; - ofn.lpstrFilter=filter; - nameo[0]=0; - ofn.hwndOwner=hParent; - ofn.lpstrFile=nameo; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; //OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK; - string stdinitdir = FCEU_GetPath(FCEUMKF_ROMS); - - if (initialdir) //adelikat: If a directory is specified in the function parameter, it should take priority - ofn.lpstrInitialDir = initialdir; - else //adelikat: Else just use the override, if no override it will default to 0 - last directory used. - ofn.lpstrInitialDir = stdinitdir.c_str(); - - // Show the Open File dialog - if(GetOpenFileName(&ofn)) - { - ALoad(nameo); - } -} - -void GetMouseData(uint32 (&md)[3]) -{ - extern RECT bestfitRect; - - double screen_width = VNSWID; - double screen_height = FSettings.TotalScanlines(); - - if (eoptions & EO_BESTFIT && (bestfitRect.top || bestfitRect.left)) - { - if ((int)mousex <= bestfitRect.left) - { - md[0] = 0; - } else if ((int)mousex >= bestfitRect.right) - { - md[0] = screen_width - 1; - } else - { - md[0] = screen_width * (mousex - bestfitRect.left) / (bestfitRect.right - bestfitRect.left); - } - if ((int)mousey <= bestfitRect.top) - { - md[1] = 0; - } else if ((int)mousey >= bestfitRect.bottom) - { - md[1] = screen_height - 1; - } else - { - md[1] = screen_height * (mousey - bestfitRect.top) / (bestfitRect.bottom - bestfitRect.top); - } - } else - { - RECT client_rect; - GetClientRect(hAppWnd, &client_rect); - if ((int)mousex <= client_rect.left) - { - md[0] = 0; - } else if ((int)mousex >= client_rect.right) - { - md[0] = screen_width - 1; - } else - { - md[0] = screen_width * (mousex - client_rect.left) / (client_rect.right - client_rect.left); - } - if ((int)mousey <= client_rect.top) - { - md[1] = 0; - } else if ((int)mousey >= client_rect.bottom) - { - md[1] = screen_height - 1; - } else - { - md[1] = screen_height * (mousey - client_rect.top) / (client_rect.bottom - client_rect.top); - } - } - md[0] += VNSCLIP; - md[1] += FSettings.FirstSLine; - md[2] = ((mouseb == MK_LBUTTON) ? 1 : 0) | (( mouseb == MK_RBUTTON ) ? 2 : 0); -} - -void DumpSubtitles(HWND hWnd) -{ - const char filter[]="Subtitles files (*.srt)\0*.srt\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hWnd; - ofn.lpstrTitle="Save Subtitles as..."; - ofn.lpstrFilter = filter; - strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str()); - ofn.lpstrFile = nameo; - ofn.nMaxFile = 256; - ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.lpstrDefExt = "srt"; - - if (GetSaveFileName(&ofn)) - { - FILE *srtfile; - srtfile = fopen(nameo, "w"); - if (srtfile) - { - extern std::vector subtitleFrames; - extern std::vector subtitleMessages; - float fps = (currMovieData.palFlag == 0 ? 60.0988 : 50.0069); // NTSC vs PAL - float subduration = 3; // seconds for the subtitles to be displayed - - for (unsigned int i = 0; i < subtitleFrames.size(); i++) - { - fprintf(srtfile, "%i\n", i+1); // starts with 1, not 0 - double seconds, ms, endseconds, endms; - seconds = subtitleFrames[i]/fps; - if (i+1 < subtitleFrames.size()) // there's another subtitle coming after this one - { - if (subtitleFrames[i+1]-subtitleFrames[i] < subduration*fps) // avoid two subtitles at the same time - { - endseconds = (subtitleFrames[i+1]-1)/fps; // frame x: subtitle1; frame x+1 subtitle2 - } else { - endseconds = seconds+subduration; - } - } else { - endseconds = seconds+subduration; - } - - ms = modf(seconds, &seconds); - endms = modf(endseconds, &endseconds); - // this is just beyond ugly, don't show it to your kids - fprintf(srtfile, - "%02.0f:%02d:%02d,%03d --> %02.0f:%02d:%02d,%03d\n", // hh:mm:ss,ms --> hh:mm:ss,ms - floor(seconds/3600), (int)floor(seconds/60 ) % 60, (int)floor(seconds) % 60, (int)(ms*1000), - floor(endseconds/3600), (int)floor(endseconds/60) % 60, (int)floor(endseconds) % 60, (int)(endms*1000)); - fprintf(srtfile, "%s\n\n", subtitleMessages[i].c_str()); // new line for every subtitle - } - } - fclose(srtfile); - } - - return; - -} - - -//Message loop of the main window -LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - MainhWnd = hWnd; - int whichContext = 0; - POINT pt; - RECT file_rect; - RECT help_rect; - int x = 0; - - char TempArray[2048]; - PCOPYDATASTRUCT pcData; - - switch(msg) - { - case WM_COPYDATA: - - pcData = (PCOPYDATASTRUCT) lParam; - - switch ( pcData->dwData ) - { - case 1: //cData.dwData = 1; (can use for other types as well) - if (!ALoad((LPSTR) ( (DATA *) (pcData->lpData) )-> strFilePath)) - MessageBox(hWnd,"File from second instance failed to open", "Failed to open file", MB_OK); - break; - } - break; - - case WM_LBUTTONDBLCLK: - { - if (fullscreenByDoubleclick) - { - extern void ToggleFullscreen(); - ToggleFullscreen(); - return 0; - } else - { - mouseb=wParam; - goto proco; - } - break; - } - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_RBUTTONDOWN: - mouseb=wParam; - goto proco; - - case WM_MOUSEWHEEL: - { - // send the message to TAS Editor - if (taseditorWindow.hwndTASEditor) - SendMessage(taseditorWindow.hwndTASEditor, msg, wParam, lParam); - return 0; - } - - case WM_MBUTTONDOWN: - { - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - playback.handleMiddleButtonClick(); - return 0; - } - - case WM_RBUTTONUP: - { - // If TAS Editor is engaged, rightclick shouldn't popup menus, because right button is used with wheel input for TAS Editor's own purposes - if (!FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { - if (rightClickEnabled) - { - //If There is a movie loaded in read only - if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED) && movie_readonly) - whichContext = 0; // Game+Movie+readonly - //If there is a movie loaded in read+write - else if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED) && !movie_readonly) - whichContext = 3; // Game+Movie+readwrite - //If there is a ROM loaded but no movie - else if (GameInfo) - whichContext = 1; // Game+NoMovie - //Else no ROM - else - whichContext = 2; // NoGame - - hfceuxcontext = LoadMenu(fceu_hInstance,"FCEUCONTEXTMENUS"); - hfceuxcontextsub = GetSubMenu(hfceuxcontext, whichContext); - UpdateContextMenuItems(hfceuxcontextsub, whichContext); - pt.x = LOWORD(lParam); //Get mouse x in terms of client area - pt.y = HIWORD(lParam); //Get mouse y in terms of client area - ClientToScreen(hAppWnd, (LPPOINT) &pt); //Convert client area x,y to screen x,y - TrackPopupMenu(hfceuxcontextsub,TPM_RIGHTBUTTON,(pt.x),(pt.y),0,hWnd,0); //Create menu - } else - { - mouseb=wParam; - } - } - goto proco; - } - - case WM_MOVE: - { - if (!IsIconic(hWnd)) { - RECT wrect; - GetWindowRect(hWnd,&wrect); - MainWindow_wndx = wrect.left; - MainWindow_wndy = wrect.top; - - #ifdef WIN32 - WindowBoundsCheckNoResize(MainWindow_wndx,MainWindow_wndy,wrect.right); - #endif - } - goto proco; - } - - case WM_MOUSEMOVE: - { - mousex=LOWORD(lParam); - mousey=HIWORD(lParam); - goto proco; - } - - case WM_ERASEBKGND: - if(xbsave) - return(0); - else - goto proco; - - case WM_PAINT: - if (xbsave) - { - InvalidateRect(hWnd, NULL, false); // AnS: HACK in order to force the entire client area to be redrawn; this fixes the bug with DIRECTDRAWCLIPPER sometimes calculating wrong region - PAINTSTRUCT ps; - BeginPaint(hWnd,&ps); - FCEUD_BlitScreen(xbsave); - EndPaint(hWnd,&ps); - return(0); - } - goto proco; - - case WM_SIZE: - if (!fullscreen && !changerecursive && !windowedfailed) - { - switch(wParam) - { - case SIZE_MAXIMIZED: - ismaximized = 1; - changerecursive = 1; - SetMainWindowStuff(); - changerecursive = 0; - break; - case SIZE_RESTORED: - ismaximized = 0; - changerecursive = 1; - SetMainWindowStuff(); - changerecursive = 0; - break; - } - } - break; - case WM_SIZING: - { - RECT *wrect=(RECT *)lParam; - RECT srect; - - int h=wrect->bottom-wrect->top; - int w=wrect->right-wrect->left; - int how = 0; - - if(wParam == WMSZ_BOTTOM || wParam == WMSZ_TOP) - how = 2; - else if(wParam == WMSZ_LEFT || wParam == WMSZ_RIGHT) - how = 1; - else if(wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT - || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_TOPLEFT) - how = 3; - if(how & 1) - winsizemulx*= (double)w/winwidth; - if(how & 2) - winsizemuly*= (double)h/winheight; - - bool shift_held = (GetAsyncKeyState(VK_SHIFT) < 0); - if(how & 1) - FixWXY(0, shift_held); - else - FixWXY(1, shift_held); - - CalcWindowSize(&srect); - winwidth=srect.right; - winheight=srect.bottom; - wrect->right = wrect->left + srect.right; - wrect->bottom = wrect->top + srect.bottom; - - GetMenuItemRect(hWnd, fceumenu, 0, &file_rect); - GetMenuItemRect(hWnd, fceumenu, 5, &help_rect); - menuYoffset = help_rect.top-file_rect.top; - } - //sizchange=1; - //break; - goto proco; - case WM_DISPLAYCHANGE: - if(!fullscreen && !changerecursive) - vchanged=1; - goto proco; - case WM_DROPFILES: - { - UINT len; - - len=DragQueryFileW((HDROP)wParam,0,0,0)+1; - wchar_t* wftmp = new wchar_t[len]; - { - DragQueryFileW((HDROP)wParam,0,wftmp,len); - std::string fileDropped = wcstombs(wftmp); - delete[] wftmp; - //adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking - - //------------------------------------------------------- - //Check if a cheats (.cht) file - //------------------------------------------------------- - if (!(fileDropped.find(".cht") == string::npos) && (fileDropped.find(".cht") == fileDropped.length()-4)) - { - FILE* file = FCEUD_UTF8fopen(fileDropped.c_str(),"rb"); - FCEU_LoadGameCheats(file); - } - - //------------------------------------------------------- - //Check if .fcm file, if so, convert it and play the resulting .fm2 - //------------------------------------------------------- - else if (!(fileDropped.find(".fcm") == string::npos) && (fileDropped.find(".fcm") == fileDropped.length()-4)) - { - //produce output filename - std::string outname; - size_t dot = fileDropped.find_last_of("."); - if(dot == std::string::npos) - outname = fileDropped + ".fm2"; - else - outname = fileDropped.substr(0,dot) + ".fm2"; - - MovieData md; - EFCM_CONVERTRESULT result = convert_fcm(md, fileDropped.c_str()); - if(result==FCM_CONVERTRESULT_SUCCESS) - { - EMUFILE* outf = FCEUD_UTF8_fstream(outname, "wb"); - md.dump(outf,false); - delete outf; - if (!GameInfo) //If no game is loaded, load the Open Game dialog - LoadNewGamey(hWnd, 0); - FCEUI_LoadMovie(outname.c_str(), 1, false); - FCEUX_LoadMovieExtras(outname.c_str()); - } else - { - std::string msg = "Failure converting " + fileDropped + "\r\n\r\n" + EFCM_CONVERTRESULT_message(result); - MessageBox(hWnd,msg.c_str(),"Failure converting fcm", 0); - } - } - - //------------------------------------------------------- - //Check if Palette file - //------------------------------------------------------- - else if (!(fileDropped.find(".pal") == string::npos) && (fileDropped.find(".pal") == fileDropped.length()-4)) - { - SetPalette(fileDropped.c_str()); - } - - //------------------------------------------------------- - //Check if Movie file - //------------------------------------------------------- - else if (!(fileDropped.find(".fm2") == string::npos) && (fileDropped.find(".fm2") == fileDropped.length()-4)) //ROM is already loaded and .fm2 in filename - { - if (!GameInfo) //If no game is loaded, load the Open Game dialog - LoadNewGamey(hWnd, 0); - if (GameInfo && !(fileDropped.find(".fm2") == string::npos)) - { - //.fm2 is at the end of the filename so that must be the extension - FCEUI_LoadMovie(fileDropped.c_str(), 1, false); //We are convinced it is a movie file, attempt to load it - FCEUX_LoadMovieExtras(fileDropped.c_str()); - } - } - //------------------------------------------------------- - //Check if TAS Editor project file - //------------------------------------------------------- - else if (!(fileDropped.find(".fm3") == string::npos) && (fileDropped.find(".fm3") == fileDropped.length()-4)) //ROM is already loaded and .fm3 in filename - { - if (!GameInfo) //If no game is loaded, load the Open Game dialog - LoadNewGamey(hWnd, 0); - if (GameInfo && !(fileDropped.find(".fm3") == string::npos)) - { - //.fm3 is at the end of the filename so that must be the extension - extern bool enterTASEditor(); - extern bool loadProject(const char* fullname); - extern bool askToSaveProject(); - if (enterTASEditor()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor - if (askToSaveProject()) // in case there's unsaved project - loadProject(fileDropped.c_str()); - } - } - //------------------------------------------------------- - //Check if Savestate file - //------------------------------------------------------- - else if (!(fileDropped.find(".fc") == string::npos)) - { - if (fileDropped.find(".fc") == fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character - { - if (fileDropped[fileDropped.length()-1] >= '0' && fileDropped[fileDropped.length()-1] <= '9') //If last character is 0-9 (making .fc0 - .fc9) - { - FCEUI_LoadState(fileDropped.c_str()); - } - } - } - //------------------------------------------------------- - //Check if Lua file - //------------------------------------------------------- -#ifdef _S9XLUA_H - else if (!(fileDropped.find(".lua") == string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4)) - { - // HACK because luaL_loadfile doesn't work with multibyte paths - char *ftmp; - len = DragQueryFile((HDROP)wParam, 0, 0, 0) + 1; - if ((ftmp=(char*)malloc(len))) - { - DragQueryFile((HDROP)wParam, 0, ftmp, len); - fileDropped = ftmp; - free(ftmp); - } - FCEU_LoadLuaCode(fileDropped.c_str()); - UpdateLuaConsole(fileDropped.c_str()); - } -#endif - //------------------------------------------------------- - //Check if Ram Watch file - //------------------------------------------------------- - else if (!(fileDropped.find(".wch") == string::npos) && (fileDropped.find(".wch") == fileDropped.length()-4)) { - if (GameInfo) { - SendMessage(hWnd, WM_COMMAND, (WPARAM)ID_RAM_WATCH,(LPARAM)(NULL)); - Load_Watches(true, fileDropped.c_str()); - } - } - //------------------------------------------------------- - //If not a movie, Load it as a ROM file - //------------------------------------------------------- - else - { - ALoad(fileDropped.c_str()); - } - } - } - break; - - case WM_COMMAND: - - if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1) - { - wParam &= 0xFFFF; - - // A menu item from the recent files menu was clicked. - if(wParam >= MENU_FIRST_RECENT_FILE && wParam < MENU_FIRST_RECENT_FILE + MAX_NUMBER_OF_RECENT_FILES) - { - LoadRecentRom(wParam - MENU_FIRST_RECENT_FILE); - } - - // A menu item for the recent lua files menu was clicked. - #ifdef _S9XLUA_H - if(wParam >= LUA_FIRST_RECENT_FILE && wParam < LUA_FIRST_RECENT_FILE + MAX_NUMBER_OF_LUA_RECENT_FILES) - { - char*& fname = recent_lua[wParam - LUA_FIRST_RECENT_FILE]; - if(fname) - { - UpdateLuaConsole(fname); - if (!FCEU_LoadLuaCode(fname)) - { - //int result = MessageBox(hWnd,"Remove from list?", "Could Not Open Recent File", MB_YESNO); - //if (result == IDYES) - //{ - // RemoveRecentItem((wParam - LUA_FIRST_RECENT_FILE), recent_lua, MAX_NUMBER_OF_LUA_RECENT_FILES); - // UpdateLuaRMenu(recentluamenu, recent_lua, MENU_LUA_RECENT, LUA_FIRST_RECENT_FILE); - //} - //adelikat: Commenting this code out because it is annoying in context lua scripts since lua scripts will frequently give errors to those developing them. It is frustrating for this to pop up every time. - } - } - } - #endif - - // A menu item for the recent movie files menu was clicked. - if(wParam >= MOVIE_FIRST_RECENT_FILE && wParam < MOVIE_FIRST_RECENT_FILE + MAX_NUMBER_OF_MOVIE_RECENT_FILES) - { - char*& fname = recent_movie[wParam - MOVIE_FIRST_RECENT_FILE]; - if(fname) - { - if (!FCEUI_LoadMovie(fname, 1, false)) - { - int result = MessageBox(hWnd,"Remove from list?", "Could Not Open Recent File", MB_YESNO); - if (result == IDYES) - { - RemoveRecentItem((wParam - MOVIE_FIRST_RECENT_FILE), recent_movie, MAX_NUMBER_OF_MOVIE_RECENT_FILES); - UpdateMovieRMenu(recentmoviemenu, recent_movie, MENU_MOVIE_RECENT, MOVIE_FIRST_RECENT_FILE); - } - } else { - FCEUX_LoadMovieExtras(fname); - } - } - } - - switch(LOWORD(wParam)) - { - //File Menu------------------------------------------------------------- - case FCEU_CONTEXT_OPENROM: - case MENU_OPEN_FILE: - LoadNewGamey(hWnd, 0); - break; - case FCEU_CONTEXT_CLOSEROM: - case MENU_CLOSE_FILE: - CloseGame(); - break; - //Savestate Submenu - case MENU_SAVESTATE: //Save State - FCEUI_SaveState(0); - break; - case MENU_LOADSTATE: //Load State - FCEUI_LoadState(0); - break; - case MENU_SAVE_STATE: //Save state as - FCEUD_SaveStateAs(); - break; - case MENU_LOAD_STATE: //Load state as - FCEUD_LoadStateFrom(); - break; - case MENU_NEXTSAVESTATE: //Next Save slot - FCEUI_SelectStateNext(1); - break; - case MENU_PREVIOUSSAVESTATE: //Previous Save slot - FCEUI_SelectStateNext(-1); - break; - case MENU_VIEWSAVESLOTS: //View save slots - FCEUI_SelectState(CurrentState, 1); - break; - - //Movie submenu - case FCEUX_CONTEXT_RECORDMOVIE: - case MENU_RECORD_MOVIE: - FCEUD_MovieRecordTo(); - break; - case FCEUX_CONTEXT_REPLAYMOVIE: - case MENU_REPLAY_MOVIE: - // Replay movie menu was selected - FCEUD_MovieReplayFrom(); - break; - case FCEU_CONTEXT_STOPMOVIE: - case MENU_STOP_MOVIE: - FCEUI_StopMovie(); - break; - case FCEU_CONTEXT_PLAYMOVIEFROMBEGINNING: - case ID_FILE_PLAYMOVIEFROMBEGINNING: - FCEUI_MoviePlayFromBeginning(); - break; - case FCEUX_CONTEXT_READONLYTOGGLE: - case ID_FILE_MOVIE_TOGGLEREAD: - FCEUI_MovieToggleReadOnly(); - break; - - //Record Avi/Wav submenu - case MENU_RECORD_AVI: - FCEUD_AviRecordTo(); - break; - case MENU_STOP_AVI: - FCEUD_AviStop(); - break; - case MENU_RECORD_WAV: - loggingSound = CreateSoundSave(); - break; - case MENU_STOP_WAV: - CloseWave(); - loggingSound = false; - break; - case ID_AVI_ENABLEHUDRECORDING: - { - bool AVIenableHUDrecording = FCEUI_AviEnableHUDrecording(); - AVIenableHUDrecording ^= 1; - FCEUI_SetAviEnableHUDrecording(AVIenableHUDrecording); - break; - } - case ID_AVI_DISMOVIEMESSAGE: - { - bool AVIdisableMovieMessages = FCEUI_AviDisableMovieMessages(); - AVIdisableMovieMessages ^= 1; - FCEUI_SetAviDisableMovieMessages(AVIdisableMovieMessages); - break; - } - case FCEUX_CONTEXT_SCREENSHOT: - case ID_FILE_SCREENSHOT: - FCEUI_SaveSnapshot(); - break; - case ID_FILE_SAVESCREENSHOTAS: - SaveSnapshotAs(); - break; - - //Lua submenu - case ID_FILE_OPENLUAWINDOW: - if (!LuaConsoleHWnd) - { - LuaConsoleHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) DlgLuaScriptDialog); - } else - { - ShowWindow(LuaConsoleHWnd, SW_SHOWNORMAL); - SetForegroundWindow(LuaConsoleHWnd); - } - break; - case FCEUX_CONTEXT_CLOSELUAWINDOWS: - case ID_FILE_CLOSELUAWINDOWS: - if(LuaConsoleHWnd) - PostMessage(LuaConsoleHWnd, WM_CLOSE, 0, 0); - break; - //Recent Lua 1 - #ifdef _S9XLUA_H - case FCEUX_CONTEXT_LOADLASTLUA: - ShowWindow(LuaConsoleHWnd, SW_SHOWNORMAL); - SetForegroundWindow(LuaConsoleHWnd); - if(recent_lua[0]) - { - if (!FCEU_LoadLuaCode(recent_lua[0])) - { - //int result = MessageBox(hWnd,"Remove from list?", "Could Not Open Recent File", MB_YESNO); - //if (result == IDYES) - //{ - // RemoveRecentItem(0, recent_lua, MAX_NUMBER_OF_LUA_RECENT_FILES); - // UpdateLuaRMenu(recentluamenu, recent_lua, MENU_LUA_RECENT, LUA_FIRST_RECENT_FILE); - //} - //adelikat: Forgot to comment this out for 2.1.2 release. FCEUX shouldn't ask in this case because it is too likely that lua script will error many times for a user developing a lua script. - } - } - break; - #endif - - case MENU_EXIT: - DoFCEUExit(); - break; - - //NES Menu-------------------------------------------------------------- - case MENU_RESET: - FCEUI_ResetNES(); - break; - case MENU_POWER: - FCEUI_PowerNES(); - break; - case MENU_EJECT_DISK: - FCEUI_FDSInsert(); - break; - case MENU_SWITCH_DISK: - FCEUI_FDSSelect(); - break; - case MENU_INSERT_COIN: - FCEUI_VSUniCoin(); - break; - - //Emulation submenu - case ID_NES_PAUSE: - FCEUI_ToggleEmulationPause(); - UpdateCheckedMenuItems(); - break; - case ID_NES_TURBO: - FCEUD_TurboToggle(); - break; - - //Emulation speed submenu - case ID_NES_SPEEDUP: - FCEUD_SetEmulationSpeed(3); - break; - case ID_NES_SLOWDOWN: - FCEUD_SetEmulationSpeed(1); - break; - case ID_NES_SLOWESTSPEED: - FCEUD_SetEmulationSpeed(0); - break; - case ID_NES_NORMALSPEED: - FCEUD_SetEmulationSpeed(2); - break; - case ID_EMULATIONSPEED_CUSTOMSPEED: - { - int new_value = fps_scale / 2.56; - if ((CWin32InputBox::GetInteger("Emulation Speed", "Enter a number of percents from 1 to 1000.", new_value, hWnd) == IDOK)) - { - fps_scale_unpaused = new_value * 2.56 + 1; - if (fps_scale_unpaused / 2.56 > 1000 || fps_scale_unpaused <= 0) - fps_scale_unpaused = 256; - fps_scale = fps_scale_unpaused; - RefreshThrottleFPS(); - FCEU_DispMessage("Emulation speed %d%%", 0, (fps_scale_unpaused * 100) >> 8); - } - break; - } - - case ID_EMULATIONSPEED_SETFRAMEADVANCEDELAY: - { - extern int frameAdvance_Delay; - int new_value = frameAdvance_Delay; - if((CWin32InputBox::GetInteger("FrameAdvance Delay", "How much time should elapse before\nholding the Frame Advance\nunpauses emulation?", new_value, hWnd) == IDOK)) - { - if (new_value < 0) - new_value = FRAMEADVANCE_DELAY_DEFAULT; - frameAdvance_Delay = new_value; - } - break; - } - case ID_EMULATIONSPEED_SETCUSTOMSPEEDFORFRAMEADVANCE: - { - extern int32 fps_scale_frameadvance; - int new_value = fps_scale_frameadvance / 2.56; - if ((CWin32InputBox::GetInteger("FrameAdvance Custom Speed", "Enter 0 to use the current emulation speed when\nthe Frame Advance is held. Or enter the number\nof percents (1-1000) to use different speed.", new_value, hWnd) == IDOK)) - { - if (new_value > 1000) - new_value = 1000; - if (new_value > 0) - { - fps_scale_frameadvance = new_value * 2.56 + 1; - } else - { - fps_scale_frameadvance = 0; - fps_scale = fps_scale_unpaused; - RefreshThrottleFPS(); - } - } - break; - } - - //Config Menu----------------------------------------------------------- - case FCEUX_CONTEXT_UNHIDEMENU: - case MENU_HIDE_MENU: - ToggleHideMenu(); - break; - case MENU_RUN_IN_BACKGROUND: - eoptions ^= EO_BGRUN; - if((eoptions & EO_BGRUN) == 0) - { - EnableBackgroundInput = 0; - KeyboardSetBackgroundAccess(EnableBackgroundInput!=0); - JoystickSetBackgroundAccess(EnableBackgroundInput!=0); - } - UpdateCheckedMenuItems(); - break; - case MENU_BACKGROUND_INPUT: - EnableBackgroundInput ^= 1; - eoptions |= EO_BGRUN * EnableBackgroundInput; - KeyboardSetBackgroundAccess(EnableBackgroundInput!=0); - JoystickSetBackgroundAccess(EnableBackgroundInput!=0); - UpdateCheckedMenuItems(); - break; - case MENU_ENABLE_AUTOSAVE: - EnableAutosave ^= 1; - UpdateCheckedMenuItems(); - break; - case MENU_DISPLAY_FA_LAGSKIP: - frameAdvanceLagSkip ^= 1; - UpdateCheckedMenuItems(); - break; - case ID_ENABLE_BACKUPSAVESTATES: - backupSavestates ^=1; - UpdateCheckedMenuItems(); - break; - case ID_ENABLE_COMPRESSSAVESTATES: - compressSavestates ^=1; - UpdateCheckedMenuItems(); - break; - case ID_ENABLE_AUTORESUME: - AutoResumePlay ^=1; - UpdateCheckedMenuItems(); - break; - - //Display submenu - case MENU_INPUTDISPLAY_0: //Input display off - input_display = 0; - UpdateCheckedMenuItems(); - break; - case MENU_INPUTDISPLAY_1: //Input display - 1 player - input_display = 1; - UpdateCheckedMenuItems(); - break; - case MENU_INPUTDISPLAY_2: //Input display - 2 player - input_display = 2; - UpdateCheckedMenuItems(); - break; - case MENU_INPUTDISPLAY_4: //Input display - 4 player - input_display = 4; - UpdateCheckedMenuItems(); - break; - case ID_INPUTDISPLAY_OLDSTYLEDISP: - oldInputDisplay ^= 1; - UpdateCheckedMenuItems(); - break; - case MENU_DISPLAY_LAGCOUNTER: - LagCounterToggle(); - UpdateCheckedMenuItems(); - break; - case ID_DISPLAY_FRAMECOUNTER: - FCEUI_MovieToggleFrameDisplay(); - UpdateCheckedMenuItems(); - break; - case ID_DISPLAY_RERECORDCOUNTER: - FCEUI_MovieToggleRerecordDisplay(); - UpdateCheckedMenuItems(); - break; - case ID_DISPLAY_MOVIESTATUSICON: - FCEUD_ToggleStatusIcon(); - break; - case ID_DISPLAY_FPS: - FCEUI_ToggleShowFPS(); - break; - case MENU_DISPLAY_BG: - case MENU_DISPLAY_OBJ: - { - bool spr, bg; - FCEUI_GetRenderPlanes(spr,bg); - if(LOWORD(wParam)==MENU_DISPLAY_BG) - bg = !bg; - else - spr = !spr; - FCEUI_SetRenderPlanes(spr,bg); - } - break; - - case ID_NEWPPU: - case ID_OLDPPU: - FCEU_TogglePPU(); - break; - case MENU_GAME_GENIE: - genie ^= 1; - FCEUI_SetGameGenie(genie!=0); - UpdateCheckedMenuItems(); - break; - case MENU_PAL: - pal_emulation ^= 1; - FCEUI_SetVidSystem(pal_emulation); - RefreshThrottleFPS(); - UpdateCheckedMenuItems(); - PushCurrentVideoSettings(); - break; - case MENU_DIRECTORIES: - ConfigDirectories(); - break; - case MENU_GUI_OPTIONS: - ConfigGUI(); - break; - case MENU_INPUT: - ConfigInput(hWnd); - break; - case MENU_NETWORK: - ShowNetplayConsole(); - break; - case MENU_PALETTE: - ConfigPalette(); - break; - case MENU_SOUND: - ConfigSound(); - break; - case MENU_TIMING: - ConfigTiming(); - break; - case MENU_VIDEO: - ConfigVideo(); - break; - case MENU_HOTKEYS: - MapInput(); - break; - case MENU_MOVIEOPTIONS: - OpenMovieOptions(); - break; - - case ID_CONFIG_SAVECONFIGFILE: - { - extern string cfgFile; - sprintf(TempArray, "%s/%s", BaseDirectory.c_str(),cfgFile.c_str()); - SaveConfig(TempArray); - break; - } - - //Tools Menu--------------------------------------------------------------- - case MENU_CHEATS: - ConfigCheats(hWnd); - break; - case MENU_MEMORY_WATCH: - CreateMemWatch(); - break; - - case ID_RAM_SEARCH: - if(!RamSearchHWnd) - { - OpenRamSearch(); - } else - { - ShowWindow(RamSearchHWnd, SW_SHOWNORMAL); - SetForegroundWindow(RamSearchHWnd); - } - break; - - case ID_RAM_WATCH: - if(!RamWatchHWnd) - { - OpenRamWatch(); - } - else - SetForegroundWindow(RamWatchHWnd); - break; - //case MENU_RAMFILTER: - // DoByteMonitor(); - // break; - // Removing this tool since it is redundant to both - case MENU_TASEDITOR: - extern bool enterTASEditor(); - enterTASEditor(); - break; - case MENU_CONVERT_MOVIE: - ConvertFCM(hWnd); - break; - - //AutoFire Pattern submenu - case MENU_AUTOFIRE_PATTERN_1: - SetAutoFirePattern(1,1); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_2: - SetAutoFirePattern(1,2); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_3: - SetAutoFirePattern(1,3); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_4: - SetAutoFirePattern(1,4); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_5: - SetAutoFirePattern(1,5); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_6: - SetAutoFirePattern(2,1); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_7: - SetAutoFirePattern(2,2); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_8: - SetAutoFirePattern(2,3); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_9: - SetAutoFirePattern(2,4); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_10: - SetAutoFirePattern(3,1); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_11: - SetAutoFirePattern(3,2); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_12: - SetAutoFirePattern(3,3); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_13: - SetAutoFirePattern(4,1); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_14: - SetAutoFirePattern(4,2); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_AUTOFIRE_PATTERN_15: - SetAutoFirePattern(5,1); - CheckedAutoFirePattern = wParam; - UpdateCheckedMenuItems(); - break; - //Autofire Offset submenu - case MENU_AUTOFIRE_OFFSET_1: - case MENU_AUTOFIRE_OFFSET_2: - case MENU_AUTOFIRE_OFFSET_3: - case MENU_AUTOFIRE_OFFSET_4: - case MENU_AUTOFIRE_OFFSET_5: - case MENU_AUTOFIRE_OFFSET_6: - SetAutoFireOffset(wParam - MENU_AUTOFIRE_OFFSET_1); - CheckedAutoFireOffset = wParam; - UpdateCheckedMenuItems(); - break; - case MENU_ALTERNATE_AB: - SetAutoFireDesynch(GetAutoFireDesynch()^1); - UpdateCheckedMenuItems(); - break; - case ID_TOOLS_TEXTHOOKER: - DoTextHooker(); - break; - - //Debug Menu------------------------------------------------------------- - case MENU_DEBUGGER: - DoDebug(0); - break; - case MENU_PPUVIEWER: - DoPPUView(); - break; - case MENU_NAMETABLEVIEWER: - DoNTView(); - break; - case MENU_HEXEDITOR: - DoMemView(); - break; - case MENU_TRACELOGGER: - DoTracer(); - break; - case MENU_CDLOGGER: - DoCDLogger(); - break; - case MENU_GAMEGENIEDECODER: - DoGGConv(); - break; - - //Help Menu-------------------------------------------------------------- - case MENU_HELP: - OpenHelpWindow(); - break; - case MENU_MSGLOG: - MakeLogWindow(); - break; - case MENU_ABOUT: - ShowAboutBox(); - break; - - //Context Menus------------------------------------------------------ - - //Recent ROM 1 - case FCEUX_CONTEXT_RECENTROM1: - if(recent_files[0]) - { - if (!ALoad(recent_files[0])) - { - int result = MessageBox(hWnd,"Remove from list?", "Could Not Open Recent File", MB_YESNO); - if (result == IDYES) - { - RemoveRecentItem(0, recent_files, MAX_NUMBER_OF_RECENT_FILES); - UpdateRMenu(recentmenu, recent_files, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); - } - } - } - break; - - //Recent Movie 1 - case FCEUX_CONTEXT_LOADLASTMOVIE: - if(recent_movie[0]) - { - if (!FCEUI_LoadMovie(recent_movie[0], 1, false)) - { - int result = MessageBox(hWnd,"Remove from list?", "Could Not Open Recent File", MB_YESNO); - if (result == IDYES) - { - RemoveRecentItem(0, recent_movie, MAX_NUMBER_OF_MOVIE_RECENT_FILES); - UpdateMovieRMenu(recentmoviemenu, recent_movie, MENU_MOVIE_RECENT, MOVIE_FIRST_RECENT_FILE); - } - } else - { - FCEUX_LoadMovieExtras(recent_movie[0]); - } - } - break; - - //Toggle subtitles - case FCEUX_CONTEXT_TOGGLESUBTITLES: - movieSubtitles ^= 1; - break; - - case FCEUX_CONTEXT_DUMPSUBTITLES: - DumpSubtitles(hWnd); - break; - - //View comments and subtitles - case FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES: - CreateDialog(fceu_hInstance, "IDD_REPLAY_METADATA", hWnd, ReplayMetadataDialogProc); - break; - - //Undo Savestate - case FCEUX_CONTEXT_UNDOSAVESTATE: - if (undoSS || redoSS) - SwapSaveState(); - break; - - //Undo Loadstate - case FCEUX_CONTEXT_UNDOLOADSTATE: - if (CheckBackupSaveStateExist() && redoLS) - RedoLoadState(); - else if (CheckBackupSaveStateExist() && undoLS) - LoadBackup(); - break; - - //Load last auto-save - case FCEUX_CONTEXT_REWINDTOLASTAUTO: - FCEUI_RewindToLastAutosave(); - break; - - //Create a backup movie file - case FCEUX_CONTEXT_MAKEBACKUP: - FCEUI_MakeBackupMovie(true); - break; - - //Create a backup based on user entering a filename - case FCEUX_CONTEXT_SAVEMOVIEAS: - SaveMovieAs(); - break; - - //Game + Movie - Help - case FCEU_CONTEXT_MOVIEHELP: - OpenHelpWindow(moviehelp); - break; - - case ID_CONTEXT_FULLSAVESTATES: - fullSaveStateLoads ^= 1; - break; - - //No Game - Help - case FCEU_CONTEXT_FCEUHELP: - OpenHelpWindow(gettingstartedhelp); - break; - - case FCEUX_CONTEXT_GUICONFIG: - ConfigGUI(); - break; - } - } - break; - - case WM_SYSCOMMAND: - if(GameInfo && wParam == SC_SCREENSAVE && (goptions & GOO_DISABLESS)) - return(0); - - //adelikat: If we are going to disable screensave, we should disable monitor off as well - if(GameInfo && wParam == SC_MONITORPOWER && (goptions & GOO_DISABLESS)) - return(0); - - if(wParam==SC_KEYMENU) - { - if(GameInfo && ((InputType[2]==SIFC_FKB) || (InputType[2]==SIFC_SUBORKB)) && cidisabled) - break; - if(lParam == VK_RETURN || fullscreen || tog) break; - } - goto proco; - case WM_SYSKEYDOWN: - if(GameInfo && ((InputType[2]==SIFC_FKB) || (InputType[2]==SIFC_SUBORKB)) && cidisabled) - break; // Hopefully this won't break DInput... - - if(fullscreen || tog) - { - if(wParam==VK_MENU) - break; - } - - if(wParam==VK_F10) - break; // 11.12.08 CH4 Disable F10 as System Key dammit -/* - if(wParam == VK_RETURN) - { - if(!(lParam&(1<<30))) - { - UpdateCheckedMenuItems(); - changerecursive=1; - if(!SetVideoMode(fullscreen^1)) - SetVideoMode(fullscreen); - changerecursive=0; - } - break; - } -adelikat: Outsourced this to a remappable hotkey -*/ - goto proco; - - case WM_KEYDOWN: - if(GameInfo) - { - //Only disable command keys if a game is loaded(and the other conditions are right, of course). - if(InputType[2]==SIFC_FKB) - { - if(wParam==VK_SCROLL) - { - cidisabled^=1; - FCEUI_DispMessage("Family Keyboard %sabled.",0,cidisabled?"en":"dis"); - } - if(cidisabled) - break; // Hopefully this won't break DInput... - } - if(InputType[2]==SIFC_SUBORKB) - { - if(wParam==VK_SCROLL) - { - cidisabled^=1; - FCEUI_DispMessage("Subor Keyboard %sabled.",0,cidisabled?"en":"dis"); - } - if(cidisabled) - break; - } - } - goto proco; - - case WM_CLOSE: - case WM_DESTROY: - case WM_QUIT: - DoFCEUExit(); - break; - case WM_SETFOCUS: - if (wasPausedByCheats) - { - EmulationPaused = 0; - wasPausedByCheats = false; - } - break; - case WM_ACTIVATEAPP: - if((BOOL)wParam) - nofocus = 0; - else - nofocus = 1; - goto proco; - case WM_ENTERMENULOOP: - UpdateCheckedMenuItems(); - UpdateMenuHotkeys(); - EnableMenuItem(fceumenu,MENU_RESET,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_RESET)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_POWER,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_POWER)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_EJECT_DISK,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_EJECT_DISK)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_SWITCH_DISK,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_SWITCH_DISK)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_INSERT_COIN,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_INSERT_COIN)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_TASEDITOR,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_TASEDITOR)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_CLOSE_FILE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_CLOSEGAME) && GameInfo ?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_RECENT_FILES,MF_BYCOMMAND | ((FCEU_IsValidUI(FCEUI_OPENGAME) && HasRecentFiles()) ?MF_ENABLED:MF_GRAYED)); //adelikat - added && recent_files, otherwise this line prevents recent from ever being gray when TAS Editor is not engaged - EnableMenuItem(fceumenu,MENU_OPEN_FILE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_OPENGAME)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_RECORD_MOVIE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_RECORDMOVIE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_REPLAY_MOVIE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_PLAYMOVIE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_MOVIE_RECENT,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_PLAYMOVIE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_STOP_MOVIE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_STOPMOVIE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,ID_FILE_PLAYMOVIEFROMBEGINNING,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_PLAYFROMBEGINNING)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_SAVESTATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_QUICKSAVE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_LOADSTATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_QUICKLOAD)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_SAVE_STATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_SAVESTATE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_LOAD_STATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_LOADSTATE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_NEXTSAVESTATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_NEXTSAVESTATE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_PREVIOUSSAVESTATE,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_PREVIOUSSAVESTATE)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_VIEWSAVESLOTS,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_VIEWSLOTS)?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_STOP_AVI,MF_BYCOMMAND | (FCEUI_AviIsRecording()?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,MENU_STOP_WAV,MF_BYCOMMAND | (loggingSound?MF_ENABLED:MF_GRAYED)); - EnableMenuItem(fceumenu,ID_FILE_CLOSELUAWINDOWS,MF_BYCOMMAND | (LuaConsoleHWnd?MF_ENABLED:MF_GRAYED)); - // PAL and PPU should not be changed while a movie is recorded/played - if (FCEUMOV_Mode(MOVIEMODE_INACTIVE)) - { - EnableMenuItem(fceumenu, MENU_PAL, MF_ENABLED); - EnableMenuItem(fceumenu, ID_NEWPPU, MF_ENABLED); - EnableMenuItem(fceumenu, ID_OLDPPU, MF_ENABLED); - } else - { - EnableMenuItem(fceumenu, MENU_PAL, MF_GRAYED); - EnableMenuItem(fceumenu, ID_NEWPPU, MF_GRAYED); - EnableMenuItem(fceumenu, ID_OLDPPU, MF_GRAYED); - } - CheckMenuRadioItem(fceumenu, ID_NEWPPU, ID_OLDPPU, newppu ? ID_NEWPPU : ID_OLDPPU, MF_BYCOMMAND); - // when TASEditor is engaged, some settings should not be changeable - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { - EnableMenuItem(fceumenu, MENU_ENABLE_AUTOSAVE, MF_GRAYED); - EnableMenuItem(fceumenu, ID_ENABLE_BACKUPSAVESTATES, MF_GRAYED); - EnableMenuItem(fceumenu, ID_ENABLE_COMPRESSSAVESTATES, MF_GRAYED); - } else - { - EnableMenuItem(fceumenu, MENU_ENABLE_AUTOSAVE, MF_ENABLED); - EnableMenuItem(fceumenu, ID_ENABLE_BACKUPSAVESTATES, MF_ENABLED); - EnableMenuItem(fceumenu, ID_ENABLE_COMPRESSSAVESTATES, MF_ENABLED); - } - - default: -proco: - return DefWindowProc(hWnd,msg,wParam,lParam); - } - return 0; -} - -void FixWXY(int pref, bool shift_held) -{ - if (eoptions & EO_FORCEASPECT) - { - if (pref == 0) - winsizemuly = winsizemulx; - else - winsizemulx = winsizemuly; - } - if (winsizemulx < 0.1) - winsizemulx = 0.1; - if (winsizemuly < 0.1) - winsizemuly = 0.1; - - // round to integer values - if (((eoptions & EO_FORCEISCALE) && !shift_held) || (!(eoptions & EO_FORCEISCALE) && shift_held)) - { - int x,y; - - x = winsizemulx * 2; - y = winsizemuly * 2; - - x = (x>>1) + (x&1); - y = (y>>1) + (y&1); - - if(!x) x=1; - if(!y) y=1; - - winsizemulx = x; - winsizemuly = y; - } - - /* - // is this really necessary? - if (winsizemulx > 100) - winsizemulx = 100; - if (winsizemuly > 100) - winsizemuly = 100; - */ -} - -void UpdateFCEUWindow(void) -{ - if(vchanged && !fullscreen && !changerecursive && !nofocus) - { - SetVideoMode(0); - vchanged = 0; - } - - BlockingCheck(); - - if(!(eoptions & EO_BGRUN)) - { - while(nofocus) - { - - Sleep(75); - BlockingCheck(); - } - } -} - - -//Destroys the main window -void ByebyeWindow() -{ - SetMenu(hAppWnd, 0); - DestroyMenu(fceumenu); - DestroyWindow(hAppWnd); -} - -/// reates the main window. -/// @return Flag that indicates failure (0) or success (1) -int CreateMainWindow() -{ - WNDCLASSEX winclass; - RECT tmp; - - // Create and register the window class - - memset(&winclass, 0, sizeof(winclass)); - winclass.cbSize = sizeof(WNDCLASSEX); - winclass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; // AnS: removed CS_SAVEBITS - winclass.lpfnWndProc = AppWndProc; - winclass.cbClsExtra = 0; - winclass.cbWndExtra = 0; - winclass.hInstance = fceu_hInstance; - winclass.hIcon = LoadIcon(fceu_hInstance, "ICON_1"); - winclass.hIconSm = LoadIcon(fceu_hInstance, "ICON_1"); - winclass.hCursor = LoadCursor(NULL, IDC_ARROW); - winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); //mbg merge 7/17/06 added cast - winclass.lpszClassName = "FCEUXWindowClass"; - - if(!RegisterClassEx(&winclass)) - { - return FALSE; - } - - AdjustWindowRectEx(&tmp, WS_OVERLAPPEDWINDOW, 1, 0); - - fceumenu = LoadMenu(fceu_hInstance,"FCEUMENU"); - - recentmenu = CreateMenu(); - recentluamenu = CreateMenu(); - recentmoviemenu = CreateMenu(); - - // Update recent files menu - UpdateRMenu(recentmenu, recent_files, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); - UpdateLuaRMenu(recentluamenu, recent_lua, MENU_LUA_RECENT, LUA_FIRST_RECENT_FILE); - UpdateMovieRMenu(recentmoviemenu, recent_movie, MENU_MOVIE_RECENT, MOVIE_FIRST_RECENT_FILE); - - updateGameDependentMenus(0); - updateGameDependentMenusDebugger(0); - if (MainWindow_wndx==-32000) MainWindow_wndx=0; //Just in case - if (MainWindow_wndy==-32000) MainWindow_wndy=0; - hAppWnd = CreateWindowEx( - 0, - "FCEUXWindowClass", - FCEU_NAME_AND_VERSION, - WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS, /* Style */ - MainWindow_wndx, - MainWindow_wndy, - 256, - FSettings.TotalScanlines(), /* X,Y ; Width, Height */ - NULL, - fceumenu, - fceu_hInstance, - NULL ); - - //CenterWindowOnScreen(hAppWnd); - DragAcceptFiles(hAppWnd, 1); - - SetMainWindowStuff(); - - return 1; -} - -void SetMainWindowStuff() -{ - RECT tmp; - - GetWindowRect(hAppWnd, &tmp); - - if (ismaximized) - { - winwidth = tmp.right - tmp.left; - winheight = tmp.bottom - tmp.top; - - ShowWindow(hAppWnd, SW_SHOWMAXIMIZED); - } else - { - RECT srect; - - if(WindowXC != ( 1 << 30 )) - { - /* Subtracting and adding for if(eoptions&EO_USERFORCE) below. */ - tmp.bottom -= tmp.top; - tmp.bottom += WindowYC; - - tmp.right -= tmp.left; - tmp.right += WindowXC; - - - tmp.left = WindowXC; - tmp.top = WindowYC; - WindowXC = 1 << 30; - } - - CalcWindowSize(&srect); - - SetWindowPos( - hAppWnd, - HWND_TOP, - tmp.left, - tmp.top, - srect.right, - srect.bottom, - SWP_SHOWWINDOW - ); - - winwidth = srect.right; - winheight = srect.bottom; - - ShowWindow(hAppWnd, SW_SHOWNORMAL); - } - - if (eoptions & EO_BESTFIT && !windowedfailed) - { - RECT client_recr; - GetClientRect(hAppWnd, &client_recr); - recalculateBestFitRect(client_recr.right - client_recr.left, client_recr.bottom - client_recr.top); - } -} - -/// @return Flag that indicates failure (0) or success (1). -int GetClientAbsRect(LPRECT lpRect) -{ - POINT point; - point.x = point.y = 0; - - if(!ClientToScreen(hAppWnd, &point)) - { - return 0; - } - - lpRect->top = point.y; - lpRect->left = point.x; - - //if(ismaximized) - //{ - RECT al; - GetClientRect(hAppWnd, &al); - lpRect->right = point.x + al.right; - lpRect->bottom = point.y + al.bottom; - //} - //else - //{ - // lpRect->right = point.x + VNSWID * winsizemulx; - // lpRect->bottom = point.y + FSettings.TotalScanlines() * winsizemuly; - //} - return 1; -} - -//Shows an Open File menu and starts recording an AVI -void FCEUD_AviRecordTo(void) -{ - OPENFILENAME ofn; - char szChoice[MAX_PATH]; - - string tempFilename, aviFilename; - - std::string aviDirectory = FCEU_GetPath(21); //21 = FCEUMKF_AVI - if (aviDirectory.find_last_of("\\") != (aviDirectory.size()-1)) - aviDirectory.append("\\"); //if directory override has no \ then add one - - //if we are playing a movie, construct the filename from the current movie. - if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD)) //adelikat: TOOD: Think about this. I think MOVIEMODE_FINISHED shouldn't not be included here. Am I wrong? - { - tempFilename = GetMfn(); //get movie filename - tempFilename.erase(0,1); //remove dot - } - //else construct it from the ROM name. - else - tempFilename = mass_replace(GetRomName(), "|", ".").c_str(); - - aviFilename = aviDirectory + tempFilename; //concate avi directory and movie filename - - strcpy(szChoice, aviFilename.c_str()); - char* dot = strrchr(szChoice,'.'); - - if (dot) *dot='\0'; - strcat(szChoice, ".avi"); - - // avi record file browser - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hAppWnd; - ofn.lpstrFilter = "AVI Files (*.avi)\0*.avi\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFile = szChoice; - ofn.lpstrDefExt = "avi"; - ofn.lpstrTitle = "Save AVI as"; - - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - if(GetSaveFileName(&ofn)) - FCEUI_AviBegin(szChoice); -} - -//Stop AVI recording -void FCEUD_AviStop(void) -{ - FCEUI_AviEnd(); -} - -void FCEUD_CmdOpen(void) -{ - LoadNewGamey(hAppWnd, 0); -} - -bool FCEUD_PauseAfterPlayback() -{ - return pauseAfterPlayback!=0; -} - -void ChangeContextMenuItemText(int menuitem, string text, HMENU menu) -{ - MENUITEMINFO moo; - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_TYPE; - moo.cch = NULL; - GetMenuItemInfo(menu, menuitem, FALSE, &moo); - moo.dwTypeData = (LPSTR)text.c_str(); - SetMenuItemInfo(menu, menuitem, FALSE, &moo); -} - -void ChangeMenuItemText(int menuitem, string text) -{ - MENUITEMINFO moo; - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_TYPE; - moo.cch = NULL; - GetMenuItemInfo(fceumenu, menuitem, FALSE, &moo); - moo.dwTypeData = (LPSTR)text.c_str(); - SetMenuItemInfo(fceumenu, menuitem, FALSE, &moo); -} - -void UpdateMenuHotkeys() -{ - //Update all menu items that can be called from a hotkey to include the current hotkey assignment - string combo, combined; - - //-------------------------------FILE--------------------------------------- - //Open ROM - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_OPENROM]); - combined = "&Open ROM...\t" + combo; - ChangeMenuItemText(MENU_OPEN_FILE, combined); - - //Close ROM - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_CLOSEROM]); - combined = "&Close\t" + combo; - ChangeMenuItemText(MENU_CLOSE_FILE, combined); - - //Load State - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_LOAD_STATE]); - combined = "&Load State\t" + combo; - ChangeMenuItemText(MENU_LOADSTATE, combined); - - //Save State - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SAVE_STATE]); - combined = "&Save State\t" + combo; - ChangeMenuItemText(MENU_SAVESTATE, combined); - - //Loadstate from - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_LOAD_STATE_FROM]); - combined = "Load State &From...\t" + combo; - ChangeMenuItemText(MENU_LOAD_STATE, combined); - - //Savestate as - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SAVE_STATE_AS]); - combined = "Save State &As...\t" + combo; - ChangeMenuItemText(MENU_SAVE_STATE, combined); - - //Next Save Slot - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SAVE_SLOT_NEXT]); - combined = "&Next save slot\t" + combo; - ChangeMenuItemText(MENU_NEXTSAVESTATE, combined); - - //Previous Save Slot - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SAVE_SLOT_PREV]); - combined = "&Previous save slot\t" + combo; - ChangeMenuItemText(MENU_PREVIOUSSAVESTATE, combined); - - //View Save Slots - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MISC_SHOWSTATES]); - combined = "&View save slots\t" + combo; - ChangeMenuItemText(MENU_VIEWSAVESLOTS, combined); - - //Record Movie - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_RECORD_TO]); - combined = "&Record Movie...\t" + combo; - ChangeMenuItemText(MENU_RECORD_MOVIE, combined); - - //Play movie - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_REPLAY_FROM]); - combined = "&Play Movie...\t" + combo; - ChangeMenuItemText(MENU_REPLAY_MOVIE, combined); - - //Stop movie - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_STOP]); - combined = "&Stop Movie\t" + combo; - ChangeMenuItemText(MENU_STOP_MOVIE, combined); - - //Play Movie from Beginning - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_PLAY_FROM_BEGINNING]); - combined = "Play from &Beginning\t" + combo; - ChangeMenuItemText(ID_FILE_PLAYMOVIEFROMBEGINNING, combined); - - //Read only - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_READONLY_TOGGLE]); - combined = "&Read only\t" + combo; - ChangeMenuItemText(ID_FILE_MOVIE_TOGGLEREAD, combined); - - //Screenshot - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SCREENSHOT]); - combined = "&Screenshot\t" + combo; - ChangeMenuItemText(ID_FILE_SCREENSHOT, combined); - - //Record AVI - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_AVI_RECORD_AS]); - combined = "&Record AVI...\t" + combo; - ChangeMenuItemText(MENU_RECORD_AVI, combined); - - //Stop AVI - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_AVI_STOP]); - combined = "&Stop AVI\t" + combo; - ChangeMenuItemText(MENU_STOP_AVI, combined); - - //-------------------------------NES---------------------------------------- - //Reset - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_RESET]); - combined = "&Reset\t" + combo; - ChangeMenuItemText(MENU_RESET, combined); - - //Power - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_POWER]); - combined = "&Power\t" + combo; - ChangeMenuItemText(MENU_POWER, combined); - - //Eject/Insert Disk - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_FDS_EJECT_INSERT]); - combined = "&Eject/Insert Disk\t" + combo; - ChangeMenuItemText(MENU_EJECT_DISK, combined); - - //Switch Disk Side - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_FDS_SIDE_SELECT]); - combined = "&Switch Disk Side\t" + combo; - ChangeMenuItemText(MENU_SWITCH_DISK, combined); - - //Insert Coin - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_VSUNI_COIN]); - combined = "&Insert Coin\t" + combo; - ChangeMenuItemText(MENU_INSERT_COIN, combined); - - //Speed Up - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SPEED_FASTER]); - combined = "Speed &Up\t" + combo; - ChangeMenuItemText(ID_NES_SPEEDUP, combined); - - //Slow Down - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SPEED_SLOWER]); - combined = "Slow &Down\t" + combo; - ChangeMenuItemText(ID_NES_SLOWDOWN, combined); - - //Pause - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_PAUSE]); - combined = "&Pause\t" + combo; - ChangeMenuItemText(ID_NES_PAUSE, combined); - - //Slowest Speed - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SPEED_SLOWEST]); - combined = "&Slowest Speed\t" + combo; - ChangeMenuItemText(ID_NES_SLOWESTSPEED, combined); - - //Normal Speed - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SPEED_NORMAL]); - combined = "&Normal Speed\t" + combo; - ChangeMenuItemText(ID_NES_NORMALSPEED, combined); - - //Turbo - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_SPEED_TURBO_TOGGLE]); - combined = "&Turbo\t" + combo; - ChangeMenuItemText(ID_NES_TURBO, combined); - - //-------------------------------Config------------------------------------- - //Hide Menu - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_HIDE_MENU_TOGGLE]); - combined = "&Hide Menu\t" + combo; - ChangeMenuItemText(MENU_HIDE_MENU, combined); - - //Frame Adv. skip lag - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_FRAMEADV_SKIPLAG]); - combined = "&Frame Adv. - Skip Lag\t" + combo; - ChangeMenuItemText(MENU_DISPLAY_FA_LAGSKIP, combined); - - //Lag Counter - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE]); - combined = "&Lag Counter\t" + combo; - ChangeMenuItemText(MENU_DISPLAY_LAGCOUNTER, combined); - - //Frame Counter - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE]); - combined = "&Frame Counter\t" + combo; - ChangeMenuItemText(ID_DISPLAY_FRAMECOUNTER, combined); - - //Rerecord Counter - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_RERECORD_DISPLAY_TOGGLE]); - combined = "&Rerecord Counter\t" + combo; - ChangeMenuItemText(ID_DISPLAY_RERECORDCOUNTER, combined); - - //Movie status icon - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE]); - combined = "&Movie status icon\t" + combo; - ChangeMenuItemText(ID_DISPLAY_MOVIESTATUSICON, combined); - - //FPS counter - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_FPS_DISPLAY_TOGGLE]); - combined = "FPS\t" + combo; - ChangeMenuItemText(ID_DISPLAY_FPS, combined); - - //Graphics: BG - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MISC_DISPLAY_BG_TOGGLE]); - combined = "Graphics: &BG\t" + combo; - ChangeMenuItemText(MENU_DISPLAY_BG, combined); - - //Graphics: OBJ - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MISC_DISPLAY_OBJ_TOGGLE]); - combined = "Graphics: &OBJ\t" + combo; - ChangeMenuItemText(MENU_DISPLAY_OBJ, combined); - - //-------------------------------Tools-------------------------------------- - //Open Cheats - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENCHEATS]); - combined = "&Cheats...\t" + combo; - ChangeMenuItemText(MENU_CHEATS, combined); - - //Open RAM Search - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENRAMSEARCH]); - combined = "&RAM Search...\t" + combo; - ChangeMenuItemText(ID_RAM_SEARCH, combined); - - //Open RAM Watch - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENRAMWATCH]); - combined = "&RAM Watch...\t" + combo; - ChangeMenuItemText(ID_RAM_WATCH, combined); - - //Open Memory Watch - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENMEMORYWATCH]); - combined = "&Memory Watch...\t" + combo; - ChangeMenuItemText(MENU_MEMORY_WATCH, combined); - - //Open TAS Editor - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_MISC_OPENTASEDITOR]); - combined = "&TAS Editor...\t" + combo; - ChangeMenuItemText(MENU_TASEDITOR, combined); - - //-------------------------------Debug-------------------------------------- - //Open Debugger - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENDEBUGGER]); - combined = "&Debugger...\t" + combo; - ChangeMenuItemText(MENU_DEBUGGER, combined); - - //Open PPU Viewer - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENPPU]); - combined = "&PPU Viewer...\t" + combo; - ChangeMenuItemText(MENU_PPUVIEWER, combined); - - //Open Nametable Viewer - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENNTVIEW]); - combined = "&Name table Viewer...\t" + combo; - ChangeMenuItemText(MENU_NAMETABLEVIEWER, combined); - - //Open Hex editor - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENHEX]); - combined = "&Hex Editor...\t" + combo; - ChangeMenuItemText(MENU_HEXEDITOR, combined); - - //Open Trace Logger - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENTRACELOGGER]); - combined = "&Trace Logger...\t" + combo; - ChangeMenuItemText(MENU_TRACELOGGER, combined); - - //Open Code/Data Logger - combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENCDLOGGER]); - combined = "&Code/Data Logger...\t" + combo; - ChangeMenuItemText(MENU_CDLOGGER, combined); -} - -//This function is for the context menu item Save Movie As... -//It gets a filename from the user then calls CreateMovie() -void SaveMovieAs() -{ - const char filter[]="NES Movie file (*.fm2)\0*.fm2\0All Files (*.*)\0*.*\0\0"; - char nameo[2048]; - std::string tempName; - - OPENFILENAME ofn; - memset(&ofn,0,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hInstance=fceu_hInstance; - ofn.lpstrTitle="Save Movie as..."; - ofn.lpstrFilter=filter; - strcpy(nameo,curMovieFilename); - ofn.lpstrFile=nameo; - ofn.lpstrDefExt="fm2"; - ofn.nMaxFile=256; - ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; - ofn.hwndOwner = hMemView; - if (GetSaveFileName(&ofn)) - { - tempName = nameo; - - FCEUI_CreateMovieFile(tempName); - } -} - -void OpenRamSearch() -{ - if (GameInfo) - { - reset_address_info(); - RamSearchHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_RAMSEARCH), MainhWnd, (DLGPROC) RamSearchProc); - } -} - -void OpenRamWatch() -{ - if (GameInfo) - RamWatchHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), MainhWnd, (DLGPROC) RamWatchProc); -} - -void SaveSnapshotAs() -{ - const char filter[] = "Snapshot (*.png)\0*.png\0All Files (*.*)\0*.*\0\0"; - char nameo[512]; - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Save Snapshot As..."; - ofn.lpstrFilter = filter; - strcpy(nameo,FCEU_MakeFName(FCEUMKF_SNAP,0,"png").c_str()); - - nameo[strlen(nameo)-6] = '\0'; - - ofn.lpstrFile = nameo; - ofn.lpstrDefExt = "fcs"; - std::string initdir = FCEU_GetPath(FCEUMKF_SNAP); - ofn.lpstrInitialDir = initdir.c_str(); - ofn.nMaxFile = 256; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.lpstrDefExt = "png"; - - if(GetSaveFileName(&ofn)) - FCEUI_SetSnapshotAsName(nameo); - FCEUI_SaveSnapshotAs(); -} \ No newline at end of file diff --git a/branches/fceux-2.2.2/src/drivers/win/window.h b/branches/fceux-2.2.2/src/drivers/win/window.h deleted file mode 100644 index b600c317..00000000 --- a/branches/fceux-2.2.2/src/drivers/win/window.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef WIN_WINDOW_H -#define WIN_WINDOW_H - -#include "common.h" -#include - -using namespace std; - -// Type definitions - -struct CreateMovieParameters -{ - std::string szFilename; // on Dialog creation, this is the default filename to display. On return, this is the filename that the user chose. - int recordFrom; // 0 = "Power-On", 1 = "Reset", 2 = "Now", 3+ = savestate file in szSavestateFilename - std::string szSavestateFilename; - std::wstring authorName; -}; - -extern char *recent_files[]; -extern char *recent_lua[]; -extern char *recent_movie[]; -extern HWND pwindow; - -HWND GetMainHWND(); - -void SetMainWindowText(); -void HideFWindow(int h); -void SetMainWindowStuff(); -int GetClientAbsRect(LPRECT lpRect); -void FixWXY(int pref, bool shift_held = false); -void ByebyeWindow(); -void DoTimingConfigFix(); -int CreateMainWindow(); -void UpdateCheckedMenuItems(); -bool ALoad(const char* nameo, char* innerFilename = 0, bool silent = false); -void LoadNewGamey(HWND hParent, const char *initialdir); -int BrowseForFolder(HWND hParent, const char *htext, char *buf); -void SetMainWindowStuff(); -void GetMouseData(uint32 (&md)[3]); -//void ChangeMenuItemText(int menuitem, string text); -void UpdateMenuHotkeys(); - -template -inline std::string GetDlgItemText(HWND hDlg, int nIDDlgItem) { - char buf[BUFSIZE]; - GetDlgItemText(hDlg, nIDDlgItem, buf, BUFSIZE); - return buf; -} - -template -inline std::wstring GetDlgItemTextW(HWND hDlg, int nIDDlgItem) { - wchar_t buf[BUFSIZE]; - GetDlgItemTextW(hDlg, nIDDlgItem, buf, BUFSIZE); - return buf; -} - -#endif diff --git a/branches/fceux-2.2.2/src/fceu.cpp b/branches/fceux-2.2.2/src/fceu.cpp deleted file mode 100644 index da418b92..00000000 --- a/branches/fceux-2.2.2/src/fceu.cpp +++ /dev/null @@ -1,1191 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "ppu.h" -#include "sound.h" -#include "netplay.h" -#include "file.h" -#include "utils/endian.h" -#include "utils/memory.h" -#include "utils/crc32.h" - -#include "cart.h" -#include "nsf.h" -#include "fds.h" -#include "ines.h" -#include "unif.h" -#include "cheat.h" -#include "palette.h" -#include "state.h" -#include "movie.h" -#include "video.h" -#include "input.h" -#include "file.h" -#include "vsuni.h" -#include "ines.h" -#ifdef WIN32 -#include "drivers/win/pref.h" -#include "utils/xstring.h" - -extern void CDLoggerROMClosed(); -extern void CDLoggerROMChanged(); -extern void ResetDebugStatisticsCounters(); -extern void SetMainWindowText(); -extern bool isTaseditorRecording(); - -extern int32 fps_scale; -extern int32 fps_scale_unpaused; -extern int32 fps_scale_frameadvance; -extern void RefreshThrottleFPS(); -#endif - -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -//TODO - we really need some kind of global platform-specific options api -#ifdef WIN32 -#include "drivers/win/main.h" -#include "drivers/win/memview.h" -#include "drivers/win/cheat.h" -#include "drivers/win/texthook.h" -#include "drivers/win/ram_search.h" -#include "drivers/win/ramwatch.h" -#include "drivers/win/memwatch.h" -#include "drivers/win/tracer.h" -#else -#include "drivers/sdl/sdl.h" -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace std; - -int AFon = 1, AFoff = 1, AutoFireOffset = 0; //For keeping track of autofire settings -bool justLagged = false; -bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip over lag frame (i.e. it will emulate 2 frames instead of 1) -bool AutoSS = false; //Flagged true when the first auto-savestate is made while a game is loaded, flagged false on game close -bool movieSubtitles = true; //Toggle for displaying movie subtitles -bool DebuggerWasUpdated = false; //To prevent the debugger from updating things without being updated. -bool AutoResumePlay = false; -char romNameWhenClosingEmulator[2048] = {0}; - -FCEUGI::FCEUGI() - : filename(0), - archiveFilename(0) { - //printf("%08x",opsize); // WTF?! -} - -FCEUGI::~FCEUGI() { - if (filename) { - free(filename); - filename = NULL; - } - if (archiveFilename) { - delete archiveFilename; - archiveFilename = NULL; - } -} - -bool CheckFileExists(const char* filename) { - //This function simply checks to see if the given filename exists - if (!filename) return false; - fstream test; - test.open(filename, fstream::in); - - if (test.fail()) { - test.close(); - return false; - } else { - test.close(); - return true; - } -} - -void FCEU_TogglePPU(void) { - newppu ^= 1; - if (newppu) { - FCEU_DispMessage("New PPU loaded", 0); - FCEUI_printf("New PPU loaded"); - } else { - FCEU_DispMessage("Old PPU loaded", 0); - FCEUI_printf("Old PPU loaded"); - } -#ifdef WIN32 - SetMainWindowText(); -#endif -} - -static void FCEU_CloseGame(void) -{ - if (GameInfo) - { - if (AutoResumePlay) - { - // save "-resume" savestate - FCEUSS_Save(FCEU_MakeFName(FCEUMKF_RESUMESTATE, 0, 0).c_str(), false); - } - -#ifdef WIN32 - extern char LoadedRomFName[2048]; - if (storePreferences(mass_replace(LoadedRomFName, "|", ".").c_str())) - FCEUD_PrintError("Couldn't store debugging data"); - CDLoggerROMClosed(); -#endif - - if (FCEUnetplay) { - FCEUD_NetworkClose(); - } - - if (GameInfo->name) { - free(GameInfo->name); - GameInfo->name = NULL; - } - - if (GameInfo->type != GIT_NSF) { - FCEU_FlushGameCheats(0, 0); - } - - GameInterface(GI_CLOSE); - - FCEUI_StopMovie(); - - ResetExState(0, 0); - - //clear screen when game is closed - extern uint8 *XBuf; - if (XBuf) - memset(XBuf, 0, 256 * 256); - - FCEU_CloseGenie(); - - delete GameInfo; - GameInfo = NULL; - - currFrameCounter = 0; - - //Reset flags for Undo/Redo/Auto Savestating //adelikat: TODO: maybe this stuff would be cleaner as a struct or class - lastSavestateMade[0] = 0; - undoSS = false; - redoSS = false; - lastLoadstateMade[0] = 0; - undoLS = false; - redoLS = false; - AutoSS = false; - } -} - - -uint64 timestampbase; - - -FCEUGI *GameInfo = NULL; - -void (*GameInterface)(GI h); -void (*GameStateRestore)(int version); - -readfunc ARead[0x10000]; -writefunc BWrite[0x10000]; -static readfunc *AReadG; -static writefunc *BWriteG; -static int RWWrap = 0; - -//mbg merge 7/18/06 docs -//bit0 indicates whether emulation is paused -//bit1 indicates whether emulation is in frame step mode -int EmulationPaused = 0; -bool frameAdvanceRequested=false; -int frameAdvance_Delay_count = 0; -int frameAdvance_Delay = FRAMEADVANCE_DELAY_DEFAULT; - -//indicates that the emulation core just frame advanced (consumed the frame advance state and paused) -bool JustFrameAdvanced = false; - -static int *AutosaveStatus; //is it safe to load Auto-savestate -static int AutosaveIndex = 0; //which Auto-savestate we're on -int AutosaveQty = 4; // Number of Autosaves to store -int AutosaveFrequency = 256; // Number of frames between autosaves - -// Flag that indicates whether the Auto-save option is enabled or not -int EnableAutosave = 0; - -///a wrapper for unzip.c -extern "C" FILE *FCEUI_UTF8fopen_C(const char *n, const char *m) { - return ::FCEUD_UTF8fopen(n, m); -} - -static DECLFW(BNull) { -} - -static DECLFR(ANull) { - return(X.DB); -} - -int AllocGenieRW(void) { - if (!(AReadG = (readfunc*)FCEU_malloc(0x8000 * sizeof(readfunc)))) - return 0; - if (!(BWriteG = (writefunc*)FCEU_malloc(0x8000 * sizeof(writefunc)))) - return 0; - RWWrap = 1; - return 1; -} - -void FlushGenieRW(void) { - int32 x; - - if (RWWrap) { - for (x = 0; x < 0x8000; x++) { - ARead[x + 0x8000] = AReadG[x]; - BWrite[x + 0x8000] = BWriteG[x]; - } - free(AReadG); - free(BWriteG); - AReadG = NULL; - BWriteG = NULL; - RWWrap = 0; - } -} - -readfunc GetReadHandler(int32 a) { - if (a >= 0x8000 && RWWrap) - return AReadG[a - 0x8000]; - else - return ARead[a]; -} - -void SetReadHandler(int32 start, int32 end, readfunc func) { - int32 x; - - if (!func) - func = ANull; - - if (RWWrap) - for (x = end; x >= start; x--) { - if (x >= 0x8000) - AReadG[x - 0x8000] = func; - else - ARead[x] = func; - } - else - for (x = end; x >= start; x--) - ARead[x] = func; -} - -writefunc GetWriteHandler(int32 a) { - if (RWWrap && a >= 0x8000) - return BWriteG[a - 0x8000]; - else - return BWrite[a]; -} - -void SetWriteHandler(int32 start, int32 end, writefunc func) { - int32 x; - - if (!func) - func = BNull; - - if (RWWrap) - for (x = end; x >= start; x--) { - if (x >= 0x8000) - BWriteG[x - 0x8000] = func; - else - BWrite[x] = func; - } - else - for (x = end; x >= start; x--) - BWrite[x] = func; -} - -uint8 *RAM; - -//--------- -//windows might need to allocate these differently, so we have some special code - -static void AllocBuffers() { - RAM = (uint8*)FCEU_gmalloc(0x800); -} - -static void FreeBuffers() { - FCEU_free(RAM); - RAM = NULL; -} -//------ - -uint8 PAL = 0; - -static DECLFW(BRAML) { - RAM[A] = V; - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(A, 1, V, LUAMEMHOOK_WRITE); - #endif -} - -static DECLFW(BRAMH) { - RAM[A & 0x7FF] = V; - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(A & 0x7FF, 1, V, LUAMEMHOOK_WRITE); - #endif -} - -static DECLFR(ARAML) { - return RAM[A]; -} - -static DECLFR(ARAMH) { - return RAM[A & 0x7FF]; -} - - -void ResetGameLoaded(void) { - if (GameInfo) FCEU_CloseGame(); - EmulationPaused = 0; //mbg 5/8/08 - loading games while paused was bad news. maybe this fixes it - GameStateRestore = 0; - PPU_hook = NULL; - GameHBIRQHook = NULL; - FFCEUX_PPURead = NULL; - FFCEUX_PPUWrite = NULL; - if (GameExpSound.Kill) - GameExpSound.Kill(); - memset(&GameExpSound, 0, sizeof(GameExpSound)); - MapIRQHook = NULL; - MMC5Hack = 0; - PEC586Hack = 0; - PAL &= 1; - pale = 0; -} - -int UNIFLoad(const char *name, FCEUFILE *fp); -int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode); -int FDSLoad(const char *name, FCEUFILE *fp); -int NSFLoad(const char *name, FCEUFILE *fp); - -//char lastLoadedGameName [2048] = {0,}; // hack for movie WRAM clearing on record from poweron - -//name should be UTF-8, hopefully, or else there may be trouble -FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silent) -{ - //---------- - //attempt to open the files - FCEUFILE *fp; - char fullname[2048]; // this name contains both archive name and ROM file name - - const char* romextensions[] = { "nes", "fds", 0 }; - fp = FCEU_fopen(name, 0, "rb", 0, -1, romextensions); - - if (!fp) - { - if (!silent) - FCEU_PrintError("Error opening \"%s\"!", name); - return 0; - } else if (fp->archiveFilename != "") - { - strcpy(fullname, fp->archiveFilename.c_str()); - strcat(fullname, "|"); - strcat(fullname, fp->filename.c_str()); - } else - { - strcpy(fullname, name); - } - - //file opened ok. start loading. - FCEU_printf("Loading %s...\n\n", fullname); - GetFileBase(fp->filename.c_str()); - ResetGameLoaded(); - //reset parameters so they're cleared just in case a format's loader doesn't know to do the clearing - MasterRomInfoParams = TMasterRomInfoParams(); - - if (!AutosaveStatus) - AutosaveStatus = (int*)FCEU_dmalloc(sizeof(int) * AutosaveQty); - for (AutosaveIndex = 0; AutosaveIndex < AutosaveQty; ++AutosaveIndex) - AutosaveStatus[AutosaveIndex] = 0; - - FCEU_CloseGame(); - GameInfo = new FCEUGI(); - memset(GameInfo, 0, sizeof(FCEUGI)); - - GameInfo->filename = strdup(fp->filename.c_str()); - if (fp->archiveFilename != "") - GameInfo->archiveFilename = strdup(fp->archiveFilename.c_str()); - GameInfo->archiveCount = fp->archiveCount; - - GameInfo->soundchan = 0; - GameInfo->soundrate = 0; - GameInfo->name = 0; - GameInfo->type = GIT_CART; - GameInfo->vidsys = GIV_USER; - GameInfo->input[0] = GameInfo->input[1] = SI_UNSET; - GameInfo->inputfc = SIFC_UNSET; - GameInfo->cspecial = SIS_NONE; - - //try to load each different format - bool FCEUXLoad(const char *name, FCEUFILE * fp); - /*if(FCEUXLoad(name,fp)) - goto endlseq;*/ - if (iNESLoad(fullname, fp, OverwriteVidMode)) - goto endlseq; - if (NSFLoad(fullname, fp)) - goto endlseq; - if (UNIFLoad(fullname, fp)) - goto endlseq; - if (FDSLoad(fullname, fp)) - goto endlseq; - - if (!silent) - FCEU_PrintError("An error occurred while loading the file."); - FCEU_fclose(fp); - - delete GameInfo; - GameInfo = 0; - - return 0; - - endlseq: - - FCEU_fclose(fp); - -#ifdef WIN32 -// ################################## Start of SP CODE ########################### - extern char LoadedRomFName[2048]; - extern int loadDebugDataFailed; - - if ((loadDebugDataFailed = loadPreferences(mass_replace(LoadedRomFName, "|", ".").c_str()))) - if (!silent) - FCEU_printf("Couldn't load debugging data.\n"); - -// ################################## End of SP CODE ########################### -#endif - - FCEU_ResetVidSys(); - - if (GameInfo->type != GIT_NSF) - { - if (FSettings.GameGenie) - { - if (FCEU_OpenGenie()) - { - FCEUI_SetGameGenie(false); -#ifdef WIN32 - genie = 0; -#endif - } - } - } - PowerNES(); - - if (GameInfo->type != GIT_NSF) - FCEU_LoadGamePalette(); - - FCEU_ResetPalette(); - FCEU_ResetMessages(); // Save state, status messages, etc. - - if (GameInfo->type != GIT_NSF) - FCEU_LoadGameCheats(0); - - if (AutoResumePlay) - { - // load "-resume" savestate - if (FCEUSS_Load(FCEU_MakeFName(FCEUMKF_RESUMESTATE, 0, 0).c_str(), false)) - FCEU_DispMessage("Old play session resumed.", 0); - } - - ResetScreenshotsCounter(); - -#if defined (WIN32) || defined (WIN64) - DoDebuggerDataReload(); // Reloads data without reopening window - CDLoggerROMChanged(); - if (hMemView) UpdateColorTable(); - if (hCheat) UpdateCheatsAdded(); - if (FrozenAddressCount) - FCEU_DispMessage("%d cheats active", 0, FrozenAddressCount); -#endif - - return GameInfo; -} - -FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode, bool silent) -{ - return FCEUI_LoadGameVirtual(name, OverwriteVidMode, silent); -} - - -//Return: Flag that indicates whether the function was succesful or not. -bool FCEUI_Initialize() { - srand(time(0)); - - if (!FCEU_InitVirtualVideo()) { - return false; - } - - AllocBuffers(); - - // Initialize some parts of the settings structure - //mbg 5/7/08 - I changed the ntsc settings to match pal. - //this is more for precision emulation, instead of entertainment, which is what fceux is all about nowadays - memset(&FSettings, 0, sizeof(FSettings)); - //FSettings.UsrFirstSLine[0]=8; - FSettings.UsrFirstSLine[0] = 0; - FSettings.UsrFirstSLine[1] = 0; - //FSettings.UsrLastSLine[0]=231; - FSettings.UsrLastSLine[0] = 239; - FSettings.UsrLastSLine[1] = 239; - FSettings.SoundVolume = 150; //0-150 scale - FSettings.TriangleVolume = 256; //0-256 scale (256 is max volume) - FSettings.Square1Volume = 256; //0-256 scale (256 is max volume) - FSettings.Square2Volume = 256; //0-256 scale (256 is max volume) - FSettings.NoiseVolume = 256; //0-256 scale (256 is max volume) - FSettings.PCMVolume = 256; //0-256 scale (256 is max volume) - - FCEUPPU_Init(); - - X6502_Init(); - - return true; -} - -void FCEUI_Kill(void) { - #ifdef _S9XLUA_H - FCEU_LuaStop(); - #endif - FCEU_KillVirtualVideo(); - FCEU_KillGenie(); - FreeBuffers(); -} - -int rapidAlternator = 0; -int AutoFirePattern[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; -int AutoFirePatternLength = 2; - -void SetAutoFirePattern(int onframes, int offframes) { - int i; - for (i = 0; i < onframes && i < 8; i++) { - AutoFirePattern[i] = 1; - } - for (; i < 8; i++) { - AutoFirePattern[i] = 0; - } - if (onframes + offframes < 2) { - AutoFirePatternLength = 2; - } else if (onframes + offframes > 8) { - AutoFirePatternLength = 8; - } else { - AutoFirePatternLength = onframes + offframes; - } - AFon = onframes; AFoff = offframes; -} - -void SetAutoFireOffset(int offset) { - if (offset < 0 || offset > 8) return; - AutoFireOffset = offset; -} - -void AutoFire(void) { - static int counter = 0; - if (justLagged == false) - counter = (counter + 1) % (8 * 7 * 5 * 3); - //If recording a movie, use the frame # for the autofire so the offset - //doesn't get screwed up when loading. - if (FCEUMOV_Mode(MOVIEMODE_RECORD | MOVIEMODE_PLAY)) { - rapidAlternator = AutoFirePattern[(AutoFireOffset + FCEUMOV_GetFrame()) % AutoFirePatternLength]; //adelikat: TODO: Think through this, MOVIEMODE_FINISHED should not use movie data for auto-fire? - } else { - rapidAlternator = AutoFirePattern[(AutoFireOffset + counter) % AutoFirePatternLength]; - } -} - -void UpdateAutosave(void); - -///Emulates a single frame. - -///Skip may be passed in, if FRAMESKIP is #defined, to cause this to emulate more than one frame -void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int skip) { - //skip initiates frame skip if 1, or frame skip and sound skip if 2 - int r, ssize; - - JustFrameAdvanced = false; - - if (frameAdvanceRequested) - { - if (frameAdvance_Delay_count == 0 || frameAdvance_Delay_count >= frameAdvance_Delay) - EmulationPaused = EMULATIONPAUSED_FA; - if (frameAdvance_Delay_count < frameAdvance_Delay) - frameAdvance_Delay_count++; - } - - if (EmulationPaused & EMULATIONPAUSED_FA) - { - // the user is holding Frame Advance key - // clear paused flag temporarily - EmulationPaused &= ~EMULATIONPAUSED_PAUSED; -#ifdef WIN32 - // different emulation speed when holding Frame Advance - if (fps_scale_frameadvance > 0) - { - fps_scale = fps_scale_frameadvance; - RefreshThrottleFPS(); - } -#endif - } else - { -#ifdef WIN32 - if (fps_scale_frameadvance > 0) - { - // restore emulation speed when Frame Advance is not held - fps_scale = fps_scale_unpaused; - RefreshThrottleFPS(); - } -#endif - if (EmulationPaused & EMULATIONPAUSED_PAUSED) - { - // emulator is paused - memcpy(XBuf, XBackBuf, 256*256); - FCEU_PutImage(); - *pXBuf = XBuf; - *SoundBuf = WaveFinal; - *SoundBufSize = 0; - return; - } - } - - AutoFire(); - UpdateAutosave(); - -#ifdef _S9XLUA_H - FCEU_LuaFrameBoundary(); -#endif - - FCEU_UpdateInput(); - lagFlag = 1; - -#ifdef _S9XLUA_H - CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); -#endif - - if (geniestage != 1) FCEU_ApplyPeriodicCheats(); - r = FCEUPPU_Loop(skip); - - if (skip != 2) ssize = FlushEmulateSound(); //If skip = 2 we are skipping sound processing - -#ifdef _S9XLUA_H - CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); -#endif - -#ifdef WIN32 - //These Windows only dialogs need to be updated only once per frame so they are included here - UpdateCheatList(); // CaH4e3: can't see why, this is only cause problems with selection - adelikat: selection is only a problem when not paused, it shoudl be paused to select, we want to see the values update - UpdateTextHooker(); - Update_RAM_Search(); // Update_RAM_Watch() is also called. - RamChange(); - //FCEUI_AviVideoUpdate(XBuf); - - extern int KillFCEUXonFrame; - if (KillFCEUXonFrame && (FCEUMOV_GetFrame() >= KillFCEUXonFrame)) - DoFCEUExit(); -#endif - - timestampbase += timestamp; - timestamp = 0; - - *pXBuf = skip ? 0 : XBuf; - if (skip == 2) { //If skip = 2, then bypass sound - *SoundBuf = 0; - *SoundBufSize = 0; - } else { - *SoundBuf = WaveFinal; - *SoundBufSize = ssize; - } - - if ((EmulationPaused & EMULATIONPAUSED_FA) && (!frameAdvanceLagSkip || !lagFlag)) - //Lots of conditions here. EmulationPaused & EMULATIONPAUSED_FA must be true. In addition frameAdvanceLagSkip or lagFlag must be false - // When Frame Advance is held, emulator is automatically paused after emulating one frame (or several lag frames) - { - EmulationPaused = EMULATIONPAUSED_PAUSED; // restore EMULATIONPAUSED_PAUSED flag and clear EMULATIONPAUSED_FA flag - JustFrameAdvanced = true; - #ifdef WIN32 - if (soundoptions & SO_MUTEFA) //mute the frame advance if the user requested it - *SoundBufSize = 0; //keep sound muted - #endif - } - - if (lagFlag) { - lagCounter++; - justLagged = true; - } else justLagged = false; - - if (movieSubtitles) - ProcessSubtitles(); -} - -void FCEUI_CloseGame(void) { - if (!FCEU_IsValidUI(FCEUI_CLOSEGAME)) - return; - - FCEU_CloseGame(); -} - -void ResetNES(void) { - FCEUMOV_AddCommand(FCEUNPCMD_RESET); - if (!GameInfo) return; - GameInterface(GI_RESETM2); - FCEUSND_Reset(); - FCEUPPU_Reset(); - X6502_Reset(); - - // clear back baffer - extern uint8 *XBackBuf; - memset(XBackBuf, 0, 256 * 256); - - FCEU_DispMessage("Reset", 0); -} - -void FCEU_MemoryRand(uint8 *ptr, uint32 size) { - int x = 0; - while (size) { - *ptr = (x & 4) ? 0xFF : 0x00; // Huang Di DEBUG MODE enabled by default - // Cybernoid NO MUSIC by default -// *ptr = (x & 4) ? 0x7F : 0x00; // Huang Di DEBUG MODE enabled by default - // Minna no Taabou no Nakayoshi Daisakusen DOESN'T BOOT - // Cybernoid NO MUSIC by default -// *ptr = (x & 1) ? 0x55 : 0xAA; // F-15 Sity War HISCORE is screwed... - // 1942 SCORE/HISCORE is screwed... -// *ptr = 0xFF; // Work for all cases - x++; - size--; - ptr++; - } -} - -void hand(X6502 *X, int type, uint32 A) { -} - -void PowerNES(void) { - FCEUMOV_AddCommand(FCEUNPCMD_POWER); - if (!GameInfo) return; - - FCEU_CheatResetRAM(); - FCEU_CheatAddRAM(2, 0, RAM); - - FCEU_GeniePower(); - - //dont do this, it breaks some games: Cybernoid; Minna no Taabou no Nakayoshi Daisakusen; and maybe mechanized attack - //memset(RAM,0xFF,0x800); - //this fixes the above, but breaks Huang Di, which expects $100 to be non-zero or else it believes it has debug cheats enabled, giving you moon jump and other great but likely unwanted things - //FCEU_MemoryRand(RAM,0x800); - //this should work better, based on observational evidence. fixes all of the above: - //for(int i=0;i<0x800;i++) if(i&1) RAM[i] = 0xAA; else RAM[i] = 0x55; - //but we're leaving this for now until we collect some more data - FCEU_MemoryRand(RAM, 0x800); - - SetReadHandler(0x0000, 0xFFFF, ANull); - SetWriteHandler(0x0000, 0xFFFF, BNull); - - SetReadHandler(0, 0x7FF, ARAML); - SetWriteHandler(0, 0x7FF, BRAML); - - SetReadHandler(0x800, 0x1FFF, ARAMH); // Part of a little - SetWriteHandler(0x800, 0x1FFF, BRAMH); //hack for a small speed boost. - - InitializeInput(); - FCEUSND_Power(); - FCEUPPU_Power(); - - //Have the external game hardware "powered" after the internal NES stuff. Needed for the NSF code and VS System code. - GameInterface(GI_POWER); - if (GameInfo->type == GIT_VSUNI) - FCEU_VSUniPower(); - - //if we are in a movie, then reset the saveram - extern int disableBatteryLoading; - if (disableBatteryLoading) - GameInterface(GI_RESETSAVE); - - timestampbase = 0; - X6502_Power(); -#ifdef WIN32 - ResetDebugStatisticsCounters(); -#endif - FCEU_PowerCheats(); - LagCounterReset(); - // clear back buffer - extern uint8 *XBackBuf; - memset(XBackBuf, 0, 256 * 256); - -#ifdef WIN32 - Update_RAM_Search(); // Update_RAM_Watch() is also called. -#endif - - FCEU_DispMessage("Power on", 0); -} - -void FCEU_ResetVidSys(void) { - int w; - - if (GameInfo->vidsys == GIV_NTSC) - w = 0; - else if (GameInfo->vidsys == GIV_PAL) - w = 1; - else - w = FSettings.PAL; - - PAL = w ? 1 : 0; - - FCEUPPU_SetVideoSystem(w); - SetSoundVariables(); -} - -FCEUS FSettings; - -void FCEU_printf(char *format, ...) { - char temp[2048]; - - va_list ap; - - va_start(ap, format); - vsnprintf(temp, sizeof(temp), format, ap); - FCEUD_Message(temp); - - va_end(ap); -} - -void FCEU_PrintError(char *format, ...) { - char temp[2048]; - - va_list ap; - - va_start(ap, format); - vsnprintf(temp, sizeof(temp), format, ap); - FCEUD_PrintError(temp); - - va_end(ap); -} - -void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall) { - FSettings.UsrFirstSLine[0] = ntscf; - FSettings.UsrLastSLine[0] = ntscl; - FSettings.UsrFirstSLine[1] = palf; - FSettings.UsrLastSLine[1] = pall; - if (PAL) { - FSettings.FirstSLine = FSettings.UsrFirstSLine[1]; - FSettings.LastSLine = FSettings.UsrLastSLine[1]; - } else { - FSettings.FirstSLine = FSettings.UsrFirstSLine[0]; - FSettings.LastSLine = FSettings.UsrLastSLine[0]; - } -} - -void FCEUI_SetVidSystem(int a) { - FSettings.PAL = a ? 1 : 0; - if (GameInfo) { - FCEU_ResetVidSys(); - FCEU_ResetPalette(); - FCEUD_VideoChanged(); - } -} - -int FCEUI_GetCurrentVidSystem(int *slstart, int *slend) { - if (slstart) - *slstart = FSettings.FirstSLine; - if (slend) - *slend = FSettings.LastSLine; - return(PAL); -} - -//Enable or disable Game Genie option. -void FCEUI_SetGameGenie(bool a) { - FSettings.GameGenie = a; -} - -//this variable isn't used at all, snap is always name-based -//void FCEUI_SetSnapName(bool a) -//{ -// FSettings.SnapName = a; -//} - -int32 FCEUI_GetDesiredFPS(void) { - if (PAL) - return(838977920); // ~50.007 - else - return(1008307711); // ~60.1 -} - -int FCEUI_EmulationPaused(void) -{ - return (EmulationPaused & EMULATIONPAUSED_PAUSED); -} - -int FCEUI_EmulationFrameStepped() -{ - return (EmulationPaused & EMULATIONPAUSED_FA); -} - -void FCEUI_ClearEmulationFrameStepped() -{ - EmulationPaused &= ~EMULATIONPAUSED_FA; -} - -//mbg merge 7/18/06 added -//ideally maybe we shouldnt be using this, but i need it for quick merging -void FCEUI_SetEmulationPaused(int val) { - EmulationPaused = val; -} - -void FCEUI_ToggleEmulationPause(void) -{ - EmulationPaused = (EmulationPaused & EMULATIONPAUSED_PAUSED) ^ EMULATIONPAUSED_PAUSED; - DebuggerWasUpdated = false; -} - -void FCEUI_FrameAdvanceEnd(void) { - frameAdvanceRequested = false; -} - -void FCEUI_FrameAdvance(void) { - frameAdvanceRequested = true; - frameAdvance_Delay_count = 0; -} - -static int AutosaveCounter = 0; - -void UpdateAutosave(void) { - if (!EnableAutosave || turbo) - return; - - char * f; - if (++AutosaveCounter >= AutosaveFrequency) { - AutosaveCounter = 0; - AutosaveIndex = (AutosaveIndex + 1) % AutosaveQty; - f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE, AutosaveIndex, 0).c_str()); - FCEUSS_Save(f, false); - AutoSS = true; //Flag that an auto-savestate was made - free(f); - f = NULL; - AutosaveStatus[AutosaveIndex] = 1; - } -} - -void FCEUI_RewindToLastAutosave(void) { - if (!EnableAutosave || !AutoSS) - return; - - if (AutosaveStatus[AutosaveIndex] == 1) { - char * f; - f = strdup(FCEU_MakeFName(FCEUMKF_AUTOSTATE, AutosaveIndex, 0).c_str()); - FCEUSS_Load(f); - free(f); - f = NULL; - - //Set pointer to previous available slot - if (AutosaveStatus[(AutosaveIndex + AutosaveQty - 1) % AutosaveQty] == 1) { - AutosaveIndex = (AutosaveIndex + AutosaveQty - 1) % AutosaveQty; - } - - //Reset time to next Auto-save - AutosaveCounter = 0; - } -} - -int FCEU_TextScanlineOffset(int y) { - return FSettings.FirstSLine * 256; -} -int FCEU_TextScanlineOffsetFromBottom(int y) { - return (FSettings.LastSLine - y) * 256; -} - -bool FCEU_IsValidUI(EFCEUI ui) { - switch (ui) { - case FCEUI_OPENGAME: - case FCEUI_CLOSEGAME: - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) return false; - break; - case FCEUI_RECORDMOVIE: - case FCEUI_PLAYMOVIE: - case FCEUI_QUICKSAVE: - case FCEUI_QUICKLOAD: - case FCEUI_SAVESTATE: - case FCEUI_LOADSTATE: - case FCEUI_NEXTSAVESTATE: - case FCEUI_PREVIOUSSAVESTATE: - case FCEUI_VIEWSLOTS: - if (!GameInfo) return false; - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) return false; - break; - - case FCEUI_STOPMOVIE: - return(FCEUMOV_Mode(MOVIEMODE_PLAY | MOVIEMODE_RECORD | MOVIEMODE_FINISHED)); - - case FCEUI_PLAYFROMBEGINNING: - return(FCEUMOV_Mode(MOVIEMODE_PLAY | MOVIEMODE_RECORD | MOVIEMODE_TASEDITOR | MOVIEMODE_FINISHED)); - - case FCEUI_STOPAVI: - return FCEUI_AviIsRecording(); - - case FCEUI_TASEDITOR: - if (!GameInfo) return false; - break; - - case FCEUI_RESET: - case FCEUI_POWER: - case FCEUI_EJECT_DISK: - case FCEUI_SWITCH_DISK: - case FCEUI_INSERT_COIN: - if (!GameInfo) return false; - if (FCEUMOV_Mode(MOVIEMODE_RECORD)) return true; -#ifdef WIN32 - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && isTaseditorRecording()) return true; -#endif - if (!FCEUMOV_Mode(MOVIEMODE_INACTIVE)) return false; - break; - } - return true; -} - -//--------------------- -//experimental new mapper and ppu system follows - -class FCEUXCart { -public: -int mirroring; -int chrPages, prgPages; -uint32 chrSize, prgSize; -char* CHR, *PRG; - -FCEUXCart() - : CHR(0) - , PRG(0) { -} - -~FCEUXCart() { - if (CHR) delete[] CHR; - if (PRG) delete[] PRG; -} - -virtual void Power() { -} - -protected: -//void SetReadHandler(int32 start, int32 end, readfunc func) { -}; - -FCEUXCart* cart = 0; - -//uint8 Read_ByteFromRom(uint32 A) { -// if(A>=cart->prgSize) return 0xFF; -// return cart->PRG[A]; -//} -// -//uint8 Read_Unmapped(uint32 A) { -// return 0xFF; -//} - - - -class NROM : FCEUXCart { -public: -virtual void Power() { - SetReadHandler(0x8000, 0xFFFF, CartBR); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); - - vnapage[0] = NTARAM; - vnapage[2] = NTARAM; - vnapage[1] = NTARAM + 0x400; - vnapage[3] = NTARAM + 0x400; - PPUNTARAM = 0xF; -} -}; - -void FCEUXGameInterface(GI command) { - switch (command) { - case GI_POWER: - cart->Power(); - } -} - - - -bool FCEUXLoad(const char *name, FCEUFILE *fp) { - //read ines header - iNES_HEADER head; - if (FCEU_fread(&head, 1, 16, fp) != 16) - return false; - - //validate header - if (memcmp(&head, "NES\x1a", 4)) - return 0; - - int mapper = (head.ROM_type >> 4); - mapper |= (head.ROM_type2 & 0xF0); - - //choose what kind of cart to use. - cart = (FCEUXCart*)new NROM(); - - //fceu ines loading code uses 256 here when the romsize is 0. - cart->prgPages = head.ROM_size; - if (cart->prgPages == 0) { - printf("FCEUX: received zero prgpages\n"); - cart->prgPages = 256; - } - - cart->chrPages = head.VROM_size; - - cart->mirroring = (head.ROM_type & 1); - if (head.ROM_type & 8) cart->mirroring = 2; - - //skip trainer - bool hasTrainer = (head.ROM_type & 4) != 0; - if (hasTrainer) { - FCEU_fseek(fp, 512, SEEK_CUR); - } - - //load data - cart->prgSize = cart->prgPages * 16 * 1024; - cart->chrSize = cart->chrPages * 8 * 1024; - cart->PRG = new char[cart->prgSize]; - cart->CHR = new char[cart->chrSize]; - FCEU_fread(cart->PRG, 1, cart->prgSize, fp); - FCEU_fread(cart->CHR, 1, cart->chrSize, fp); - - //setup the emulator - GameInterface = FCEUXGameInterface; - ResetCartMapping(); - SetupCartPRGMapping(0, (uint8*)cart->PRG, cart->prgSize, 0); - SetupCartCHRMapping(0, (uint8*)cart->CHR, cart->chrSize, 0); - - return true; -} - - -uint8 FCEU_ReadRomByte(uint32 i) { - extern iNES_HEADER head; - if (i < 16) return *((unsigned char*)&head + i); - if (i < 16 + PRGsize[0]) return PRGptr[0][i - 16]; - if (i < 16 + PRGsize[0] + CHRsize[0]) return CHRptr[0][i - 16 - PRGsize[0]]; - return 0; -} diff --git a/branches/fceux-2.2.2/src/fceu.h b/branches/fceux-2.2.2/src/fceu.h deleted file mode 100644 index 2e8d6545..00000000 --- a/branches/fceux-2.2.2/src/fceu.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef _FCEUH -#define _FCEUH - -#include "types.h" - -extern int fceuindbg; -extern int newppu; -void ResetGameLoaded(void); - -extern bool AutoResumePlay; -extern char romNameWhenClosingEmulator[]; - -#define DECLFR(x) uint8 x (uint32 A) -#define DECLFW(x) void x (uint32 A, uint8 V) - -void FCEU_MemoryRand(uint8 *ptr, uint32 size); -void SetReadHandler(int32 start, int32 end, readfunc func); -void SetWriteHandler(int32 start, int32 end, writefunc func); -writefunc GetWriteHandler(int32 a); -readfunc GetReadHandler(int32 a); - -int AllocGenieRW(void); -void FlushGenieRW(void); - -void FCEU_ResetVidSys(void); - -void ResetMapping(void); -void ResetNES(void); -void PowerNES(void); - -void SetAutoFireOffset(int offset); -void SetAutoFirePattern(int onframes, int offframes); -void AutoFire(void); -void FCEUI_RewindToLastAutosave(void); - -//mbg 7/23/06 -char *FCEUI_GetAboutString(); - -extern uint64 timestampbase; -extern uint32 MMC5HackVROMMask; -extern uint8 *MMC5HackExNTARAMPtr; -extern int MMC5Hack, PEC586Hack; -extern uint8 *MMC5HackVROMPTR; -extern uint8 MMC5HackCHRMode; -extern uint8 MMC5HackSPMode; -extern uint8 MMC50x5130; -extern uint8 MMC5HackSPScroll; -extern uint8 MMC5HackSPPage; - - -#define GAME_MEM_BLOCK_SIZE 131072 - -extern uint8 *RAM; //shared memory modifications -extern int EmulationPaused; - -uint8 FCEU_ReadRomByte(uint32 i); - -extern readfunc ARead[0x10000]; -extern writefunc BWrite[0x10000]; - -enum GI { - GI_RESETM2 =1, - GI_POWER =2, - GI_CLOSE =3, - GI_RESETSAVE = 4 -}; - -extern void (*GameInterface)(GI h); -extern void (*GameStateRestore)(int version); - - -#include "git.h" -extern FCEUGI *GameInfo; -extern int GameAttributes; - -extern uint8 PAL; - -//#include "driver.h" - -typedef struct { - int PAL; - int NetworkPlay; - int SoundVolume; //Master volume - int TriangleVolume; - int Square1Volume; - int Square2Volume; - int NoiseVolume; - int PCMVolume; - bool GameGenie; - - //the currently selected first and last rendered scanlines. - int FirstSLine; - int LastSLine; - - //the number of scanlines in the currently selected configuration - int TotalScanlines() { return LastSLine - FirstSLine + 1; } - - //Driver-supplied user-selected first and last rendered scanlines. - //Usr*SLine[0] is for NTSC, Usr*SLine[1] is for PAL. - int UsrFirstSLine[2]; - int UsrLastSLine[2]; - - //this variable isn't used at all, snap is always name-based - //bool SnapName; - uint32 SndRate; - int soundq; - int lowpass; -} FCEUS; - -int FCEU_TextScanlineOffset(int y); -int FCEU_TextScanlineOffsetFromBottom(int y); - -extern FCEUS FSettings; - -bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists - -void FCEU_PrintError(char *format, ...); -void FCEU_printf(char *format, ...); -void FCEU_DispMessage(char *format, int disppos, ...); -void FCEU_DispMessageOnMovie(char *format, ...); -void FCEU_TogglePPU(); - -void SetNESDeemph(uint8 d, int force); -void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor); -void FCEU_PutImage(void); -#ifdef FRAMESKIP -void FCEU_PutImageDummy(void); -#endif - -extern uint8 Exit; -extern uint8 pale; -extern uint8 vsdip; - -//#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 - cleaning out conditional compiles - -#define JOY_A 1 -#define JOY_B 2 -#define JOY_SELECT 4 -#define JOY_START 8 -#define JOY_UP 0x10 -#define JOY_DOWN 0x20 -#define JOY_LEFT 0x40 -#define JOY_RIGHT 0x80 -#endif - -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - -#define EMULATIONPAUSED_PAUSED 1 -#define EMULATIONPAUSED_FA 2 - -#define FRAMEADVANCE_DELAY_DEFAULT 10 - diff --git a/branches/fceux-2.2.2/src/git.h b/branches/fceux-2.2.2/src/git.h deleted file mode 100644 index b785be9c..00000000 --- a/branches/fceux-2.2.2/src/git.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef __FCEU_GIT -#define __FCEU_GIT - -enum EGIT -{ - GIT_CART = 0, //Cart - GIT_VSUNI = 1, //VS Unisystem - GIT_FDS = 2, // Famicom Disk System - GIT_NSF = 3, //NES Sound Format -}; - -enum EGIV -{ - GIV_NTSC = 0, //NTSC emulation. - GIV_PAL = 1, //PAL emulation. - GIV_USER = 2, //What was set by FCEUI_SetVidSys(). -}; - -enum ESIS -{ - SIS_NONE = 0, - SIS_DATACH = 1, - SIS_NWC = 2, - SIS_VSUNISYSTEM = 3, - SIS_NSF = 4, -}; - -//input device types for the standard joystick port -enum ESI -{ - SI_UNSET = -1, - SI_NONE = 0, - SI_GAMEPAD = 1, - SI_ZAPPER = 2, - SI_POWERPADA = 3, - SI_POWERPADB = 4, - SI_ARKANOID = 5, - SI_MOUSE = 6, - - SI_COUNT = SI_MOUSE -}; - -inline const char* ESI_Name(ESI esi) -{ - static const char * const names[] = - { - "", - "Gamepad", - "Zapper", - "Power Pad A", - "Power Pad B", - "Arkanoid Paddle", - "Mouse" - }; - - if(esi >= SI_NONE && esi <= SI_COUNT) - return names[esi]; - else return ""; -} - - -//input device types for the expansion port -enum ESIFC -{ - SIFC_UNSET = -1, - SIFC_NONE = 0, - SIFC_ARKANOID = 1, - SIFC_SHADOW = 2, - SIFC_4PLAYER = 3, - SIFC_FKB = 4, - SIFC_SUBORKB = 5, - SIFC_HYPERSHOT = 6, - SIFC_MAHJONG = 7, - SIFC_QUIZKING = 8, - SIFC_FTRAINERA = 9, - SIFC_FTRAINERB = 10, - SIFC_OEKAKIDS = 11, - SIFC_BWORLD = 12, - SIFC_TOPRIDER = 13, - - SIFC_COUNT = SIFC_TOPRIDER -}; - - -inline const char* ESIFC_Name(ESIFC esifc) -{ - static const char * const names[] = - { - "", - "Arkanoid Paddle", - "Hyper Shot gun", - "4-Player Adapter", - "Family Keyboard", - "Subor Keyboard", - "HyperShot Pads", - "Mahjong", - "Quiz King Buzzers", - "Family Trainer A", - "Family Trainer B", - "Oeka Kids Tablet", - "Barcode World", - "Top Rider" - }; - - if(esifc >= SIFC_NONE && esifc <= SIFC_COUNT) - return names[esifc]; - else return ""; -} - - -#include "utils/md5.h" - -struct FCEUGI -{ - FCEUGI(); - ~FCEUGI(); - - uint8 *name; //Game name, UTF8 encoding - int mappernum; - - EGIT type; - EGIV vidsys; //Current emulated video system; - ESI input[2]; //Desired input for emulated input ports 1 and 2; -1 for unknown desired input. - ESIFC inputfc; //Desired Famicom expansion port device. -1 for unknown desired input. - ESIS cspecial; //Special cart expansion: DIP switches, barcode reader, etc. - - MD5DATA MD5; - - //mbg 6/8/08 - ??? - int soundrate; //For Ogg Vorbis expansion sound wacky support. 0 for default. - int soundchan; //Number of sound channels. - - char* filename; - char* archiveFilename; - int archiveCount; -}; - -#endif diff --git a/branches/fceux-2.2.2/src/ines-bad.h b/branches/fceux-2.2.2/src/ines-bad.h deleted file mode 100644 index 179ab016..00000000 --- a/branches/fceux-2.2.2/src/ines-bad.h +++ /dev/null @@ -1,40 +0,0 @@ -{ 0xecf78d8a13a030a6LL, "Ai Sensei no Oshiete", INESB_HACKED }, -{ 0x4712856d3e12f21fLL, "Akumajou Densetsu", INESB_HACKED }, -{ 0x10f90ba5bd55c22eLL, "Alien Syndrome", INESB_HACKED }, -{ 0x0d69ab3ad28ad1c2LL, "Banana", INESB_INCOMPLETE }, -{ 0x85d2c348a161cdbfLL, "Bio Senshi Dan", INESB_HACKED }, -{ 0x18fdb7c16aa8cb5cLL, "Bucky O'Hare", INESB_CORRUPT }, -{ 0xe27c48302108d11bLL, "Chibi Maruko Chan", INESB_HACKED }, -{ 0x9d1f505c6ba507bfLL, "Contra", INESB_HACKED }, -{ 0x60936436d3ea0ab6LL, "Crisis Force", INESB_HACKED }, -{ 0xcf31097ddbb03c5dLL, "Crystalis (Prototype)", INESB_CORRUPT }, -{ 0x92080a8ce94200eaLL, "Digital Devil Story II", INESB_HACKED }, -{ 0x6c2a2f95c2fe4b6eLL, "Dragon Ball", INESB_HACKED }, -{ 0x767aaff62963c58fLL, "Dragon Ball", INESB_HACKED }, -{ 0x97f133d8bc1c28dbLL, "Dragon Ball", INESB_HACKED }, -{ 0x500b267abb323005LL, "Dragon Warrior 4", INESB_CORRUPT }, -{ 0x02bdcf375704784bLL, "Erika to Satoru no Yume Bouken", INESB_HACKED }, -{ 0xd4fea9d2633b9186LL, "Famista 91", INESB_HACKED }, -{ 0xfdf8c812839b61f0LL, "Famista 92", INESB_HACKED }, -{ 0xb5bb1d0fb47d0850LL, "Famista 93", INESB_HACKED }, -{ 0x30471e773f7cdc89LL, "Famista 94", INESB_HACKED }, -{ 0x76c5c44ffb4a0bd7LL, "Fantasy Zone", INESB_HACKED }, -{ 0xb470bfb90e2b1049LL, "Fire Emblem Gaiden", INESB_HACKED }, -{ 0x27da2b0c500dc346LL, "Fire Emblem", INESB_HACKED }, -{ 0x23214fe456fba2ceLL, "Ganbare Goemon 2", INESB_HACKED }, -{ 0xbf8b22524e8329d9LL, "Ganbare Goemon Gaiden", INESB_HACKED }, -{ 0xa97041c3da0134e3LL, "Gegege no Kitarou 2", INESB_INCOMPLETE }, -{ 0x805db49a86db5449LL, "Goonies", INESB_HACKED }, -{ 0xc5abdaa65ac49b6bLL, "Gradius 2", INESB_HACKED }, -{ 0x04afae4ad480c11cLL, "Gradius 2", INESB_HACKED }, -{ 0x9b4bad37b5498992LL, "Gradius 2", INESB_HACKED }, -{ 0xb068d4ac10ef848eLL, "Highway Star", INESB_HACKED }, -{ 0xbf5175271e5019c3LL, "Kaiketsu Yanchamaru 3", INESB_HACKED }, -{ 0xfb4b508a236bbba3LL, "Salamander", INESB_HACKED }, -{ 0x1895afc6eef26c7dLL, "Super Mario Bros.", INESB_HACKED }, -{ 0x3716c4bebf885344LL, "Super Mario Bros.", INESB_HACKED }, -{ 0xfffda4407d80885aLL, "Sweet Home", INESB_CORRUPT }, -{ 0x103fc85d978b861bLL, "Sweet Home", INESB_CORRUPT }, -{ 0x7979dc51da86f19fLL, "110-in-1", INESB_CORRUPT }, -{ 0x001c0bb9c358252aLL, "110-in-1", INESB_CORRUPT }, -{ 0, 0, 0 } diff --git a/branches/fceux-2.2.2/src/ines-correct.h b/branches/fceux-2.2.2/src/ines-correct.h deleted file mode 100644 index 1fb733c2..00000000 --- a/branches/fceux-2.2.2/src/ines-correct.h +++ /dev/null @@ -1,260 +0,0 @@ - - {0xaf5d7aa2, -1, 0}, /* Clu Clu Land */ - {0xcfb224e6, -1, 1}, /* Dragon Ninja (J) [p1][!].nes */ - {0x4f2f1846, -1, 1}, /* Famista '89 - Kaimaku Han!! (J) */ - {0x82f204ae, -1, 1}, /* Liang Shan Ying Xiong (NJ023) (Ch) [!] */ - {0x684afccd, -1, 1}, /* Space Hunter (J) */ - {0xad9c63e2, -1, 1}, /* Space Shadow (J) */ - {0xe1526228, -1, 1}, /* Quest of Ki */ - {0xaf5d7aa2, -1, 0}, /* Clu Clu Land */ - {0xcfb224e6, -1, 1}, /* Dragon Ninja (J) [p1][!].nes */ - {0x4f2f1846, -1, 1}, /* Famista '89 - Kaimaku Han!! (J) */ - {0xfcdaca80, 0, 0}, /* Elevator Action */ - {0xc05a365b, 0, 0}, /* Exed Exes (J) */ - {0x32fa246f, 0, 0}, /* Tag Team Pro Wrestling */ - {0xb3c30bea, 0, 0}, /* Xevious (J) */ - {0xe492d45a, 0, 0}, /* Zippy Race */ - {0xe28f2596, 0, 1}, /* Pac Land (J) */ - {0xd8ee7669, 1, 8}, /* Adventures of Rad Gravity */ - {0x5b837e8d, 1, 8}, /* Alien Syndrome */ - {0x37ba3261, 1, 8}, /* Back to the Future 2 and 3 */ - {0x5b6ca654, 1, 8}, /* Barbie rev X*/ - {0x61a852ea, 1, 8}, /* Battle Stadium - Senbatsu Pro Yakyuu */ - {0xf6fa4453, 1, 8}, /* Bigfoot */ - {0x391aa1b8, 1, 8}, /* Bloody Warriors (J) */ - {0xa5e8d2cd, 1, 8}, /* Breakthru */ - {0x3f56a392, 1, 8}, /* Captain Ed (J) */ - {0x078ced30, 1, 8}, /* Choujin - Ultra Baseball */ - {0xfe364be5, 1, 8}, /* Deep Dungeon 4 */ - {0x57c12280, 1, 8}, /* Demon Sword */ - {0xd09b74dc, 1, 8}, /* Great Tank (J) */ - {0xe8baa782, 1, 8}, /* Gun Hed (J) */ - {0x970bd9c2, 1, 8}, /* Hanjuku Hero */ - {0xcd7a2fd7, 1, 8}, /* Hanjuku Hero */ - {0x63469396, 1, 8}, /* Hokuto no Ken 4 */ - {0xe94d5181, 1, 8}, /* Mirai Senshi - Lios */ - {0x7156cb4d, 1, 8}, /* Muppet Adventure Carnival thingy */ - {0x70f67ab7, 1, 8}, /* Musashi no Bouken */ - {0x291bcd7d, 1, 8}, /* Pachio Kun 2 */ - {0xa9a4ea4c, 1, 8}, /* Satomi Hakkenden */ - {0xcc3544b0, 1, 8}, /* Triathron */ - {0x934db14a, 1, -1}, /* All-Pro Basketball */ - {0xf74dfc91, 1, -1}, /* Win, Lose, or Draw */ - {0x9ea1dc76, 2, 0}, /* Rainbow Islands */ - {0x6d65cac6, 2, 0}, /* Terra Cresta */ - {0xe1b260da, 2, 1}, /* Argos no Senshi */ - {0x1d0f4d6b, 2, 1}, /* Black Bass thinging */ - {0x266ce198, 2, 1}, /* City Adventure Touch */ - {0x804f898a, 2, 1}, /* Dragon Unit */ - {0x55773880, 2, 1}, /* Gilligan's Island */ - {0x6e0eb43e, 2, 1}, /* Puss n Boots */ - {0x2bb6a0f8, 2, 1}, /* Sherlock Holmes */ - {0x28c11d24, 2, 1}, /* Sukeban Deka */ - {0x02863604, 2, 1}, /* Sukeban Deka */ - {0x419461d0, 2, 1}, /* Super Cars */ - {0xdbf90772, 3, 0}, /* Alpha Mission */ - {0xd858033d, 3, 0}, /* Armored Scrum Object */ - {0x9bde3267, 3, 1}, /* Adventures of Dino Riki */ - {0xd8eff0df, 3, 1}, /* Gradius (J) */ - {0x1d41cc8c, 3, 1}, /* Gyruss */ - {0xcf322bb3, 3, 1}, /* John Elway's Quarterback */ - {0xb5d28ea2, 3, 1}, /* Mystery Quest - mapper 3?*/ - {0x02cc3973, 3, 1}, /* Ninja Kid */ - {0xbc065fc3, 3, 1}, /* Pipe Dream */ - {0xc9ee15a7, 3, -1}, /* 3 is probably best. 41 WILL NOT WORK. */ - {0x22d6d5bd, 4, 1}, - {0xd97c31b0, 4, 1}, //Rasaaru Ishii no Childs Quest (J) - {0x404b2e8b, 4, 2}, /* Rad Racer 2 */ - {0x15141401, 4, 8}, /* Asmik Kun Land */ - {0x4cccd878, 4, 8}, /* Cat Ninden Teyandee */ - {0x59280bec, 4, 8}, /* Jackie Chan */ - {0x7474ac92, 4, 8}, /* Kabuki: Quantum Fighter */ - {0x5337f73c, 4, 8}, /* Niji no Silk Road */ - {0x9eefb4b4, 4, 8}, /* Pachi Slot Adventure 2 */ - {0x21a653c7, 4, -1}, /* Super Sky Kid */ - {0x9cbadc25, 5, 8}, /* JustBreed */ - {0xf518dd58, 7, 8}, /* Captain Skyhawk */ - {0x84382231, 9, 0}, /* Punch Out (J) */ - {0xbe939fce, 9, 1}, /* Punchout*/ - {0x345d3a1a, 11, 1}, /* Castle of Deceit */ - {0x5e66eaea, 13, 1}, /* Videomation */ - {0xcd373baa, 14, -1}, /* Samurai Spirits (Rex Soft) */ - {0xbfc7a2e9, 16, 8}, - {0x6e68e31a, 16, 8}, /* Dragon Ball 3*/ - {0x33b899c9, 16, -1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */ - {0xa262a81f, 16, -1}, /* Rokudenashi Blues (J) */ - {0x286fcd20, 23, -1}, /* Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] */ - {0xe4a291ce, 23, -1}, /* World Hero (Unl) [!] */ - {0x51e9cd33, 23, -1}, /* World Hero (Unl) [b1] */ - {0x105dd586, 27, -1}, /* Mi Hun Che variations... */ - {0xbc9bb6c1, 27, -1}, /* -- */ - {0x43753886, 27, -1}, /* -- */ - {0x5b3de3d1, 27, -1}, /* -- */ - {0x511e73f8, 27, -1}, /* -- */ - {0x5555fca3, 32, 8}, - {0x283ad224, 32, 8}, /* Ai Sensei no Oshiete */ - {0x243a8735, 32, 0x10|4}, /* Major League */ - {0xbc7b1d0f, 33, -1}, /* Bakushou!! Jinsei Gekijou 2 (J) [!] */ - {0xc2730c30, 34, 0}, /* Deadly Towers */ - {0x4c7c1af3, 34, 1}, /* Caesar's Palace */ - {0x932ff06e, 34, 1}, /* Classic Concentration */ - {0xf46ef39a, 37, -1}, /* Super Mario Bros. + Tetris + Nintendo World Cup (E) [!] */ - {0x7ccb12a3, 43, -1}, /* SMB2j */ - {0x6c71feae, 45, -1}, /* Kunio 8-in-1 */ - {0xe2c94bc2, 48, -1}, /* Super Bros 8 (Unl) [!] */ - {0xaebd6549, 48, 8}, /* Bakushou!! Jinsei Gekijou 3 */ - {0x6cdc0cd9, 48, 8}, /* Bubble Bobble 2 */ - {0x99c395f9, 48, 8}, /* Captain Saver */ - {0xa7b0536c, 48, 8}, /* Don Doko Don 2 */ - {0x40c0ad47, 48, 8}, /* Flintstones 2 */ - {0x1500e835, 48, 8}, /* Jetsons (J) */ - {0xa912b064, 51|0x800, 8}, /* 11-in-1 Ball Games(has CHR ROM when it shouldn't) */ - {0xb19a55dd, 64, 8}, /* Road Runner */ - {0xf92be3ec, 64, -1}, /* Rolling Thunder */ - {0xe84274c5, 66, 1}, - {0xbde3ae9b, 66, 1}, /* Doraemon */ - {0x9552e8df, 66, 1}, /* Dragon Ball */ - {0x811f06d9, 66, 1}, /* Dragon Power */ - {0xd26efd78, 66, 1}, /* SMB Duck Hunt */ - {0xdd8ed0f7, 70, 1}, /* Kamen Rider Club */ - {0xbba58be5, 70, -1}, /* Family Trainer - Manhattan Police */ - {0x370ceb65, 70, -1}, /* Family Trainer - Meiro Dai Sakusen */ - {0xe62e3382, 71, -1}, /* Mig-29 Soviet Fighter */ - {0xac7b0742, 71, -1}, /* Golden KTV (Ch) [!], not actually 71, but UNROM without BUS conflict */ - {0x054bd3e9, 74, -1}, /* Di 4 Ci - Ji Qi Ren Dai Zhan (As) */ - {0x496ac8f7, 74, -1}, /* Ji Jia Zhan Shi (As) */ - {0xae854cef, 74, -1}, /* Jia A Fung Yun (Chinese) */ - {0xba51ac6f, 78, 2}, - {0x3d1c3137, 78, 8}, /* Uchuusen - Cosmo Carrier */ - {0xa4fbb438, 79, 0}, - {0xd4a76b07, 79, 0}, /* F-15 City Wars*/ - {0x1eb4a920, 79, 1}, /* Double Strike */ - {0x3e1271d5, 79, 1}, /* Tiles of Fate */ - {0xd2699893, 88, 0}, /* Dragon Spirit */ - {0xbb7c5f7a, 89, 8}, /* Mito Koumon or something similar */ - {0x0da5e32e, 101, -1}, /* new Uruusey Yatsura */ - {0x8eab381c, 113, 1}, /* Death Bots */ - {0x6a03d3f3, 114, -1}, - {0x0d98db53, 114, -1}, /* Pocahontas */ - {0x4e7729ff, 114, -1}, /* Super Donkey Kong */ - {0xc5e5c5b2, 115, -1}, /* Bao Qing Tian (As).nes */ - {0xa1dc16c0, 116, -1}, - {0xe40dfb7e, 116, -1}, /* Somari (P conf.) */ - {0xc9371ebb, 116, -1}, /* Somari (W conf.) */ - {0xcbf4366f, 118, 8}, /* Alien Syndrome (U.S. unlicensed) */ - {0x78b657ac, 118, -1}, /* Armadillo */ - {0x90c773c1, 118, -1}, /* Goal! 2 */ - {0xb9b4d9e0, 118, -1}, /* NES Play Action Football */ - {0x07d92c31, 118, -1}, /* RPG Jinsei Game */ - {0x37b62d04, 118, -1}, /* Ys 3 */ - {0x318e5502, 121, -1}, /* Sonic 3D Blast 6 (Unl) */ - {0xddcfb058, 121, -1}, /* Street Fighter Zero 2 '97 (Unl) [!] */ - {0x5aefbc94, 133, -1}, /* Jovial Race (Sachen) [a1][!] */ - {0xc2df0a00, 140, 1}, /* Bio Senshi Dan(hacked) */ - {0xe46b1c5d, 140, 1}, /* Mississippi Satsujin Jiken */ - {0x3293afea, 140, 1}, /* Mississippi Satsujin Jiken */ - {0x6bc65d7e, 140, 1}, /* Youkai Club*/ - {0x5caa3e61, 144, 1}, /* Death Race */ - {0x48239b42, 146, -1}, /* Mahjong Companion (Sachen) [!] */ - {0xb6a727fa, 146, -1}, /* Papillion (As) [!] */ - {0xa62b79e1, 146, -1}, /* Side Winder (HES) [!] */ - {0xcc868d4e, 149, -1}, /* 16 Mahjong [p1][!] */ - {0x29582ca1, 150, -1}, - {0x40dbf7a2, 150, -1}, - {0x73fb55ac, 150, -1}, /* 2-in-1 Cosmo Cop + Cyber Monster (Sachen) [!] */ - {0xddcbda16, 150, -1}, /* 2-in-1 Tough Cop + Super Tough Cop (Sachen) [!] */ - {0x47918d84, 150, -1}, /* auto-upturn */ - {0x0f141525, 152, 8}, /* Arkanoid 2 (Japanese) */ - {0xbda8f8e4, 152, 8}, /* Gegege no Kitarou 2 */ - {0xb1a94b82, 152, 8}, /* Pocket Zaurus */ - {0x026c5fca, 152, 8}, /* Saint Seiya Ougon Densetsu */ - {0x3f15d20d, 153, 8}, /* Famicom Jump 2 */ - {0xd1691028, 154, 8}, /* Devil Man */ - {0xcfd4a281, 155, 8}, /* Money Game. Yay for money! */ - {0x2f27cdef, 155, 8}, /* Tatakae!! Rahmen Man */ - {0xccc03440, 156, -1}, - {0x983d8175, 157, 8}, /* Datach Battle Rush */ - {0x894efdbc, 157, 8}, /* Datach Crayon Shin Chan */ - {0x19e81461, 157, 8}, /* Datach DBZ */ - {0xbe06853f, 157, 8}, /* Datach J-League */ - {0x0be0a328, 157, 8}, /* Datach SD Gundam Wars */ - {0x5b457641, 157, 8}, /* Datach Ultraman Club */ - {0xf51a7f46, 157, 8}, /* Datach Yuu Yuu Hakusho */ - {0xe170404c, 159, -1}, /* SD Gundam Gaiden - Knight Gundam Monogatari (J) (V1.0) [!] */ - {0x276ac722, 159, -1}, /* SD Gundam Gaiden - Knight Gundam Monogatari (J) (V1.1) [!] */ - {0x0cf42e69, 159, -1}, /* Magical Taruruuto-kun - Fantastic World!! (J) (V1.0) [!] */ - {0xdcb972ce, 159, -1}, /* Magical Taruruuto-kun - Fantastic World!! (J) (V1.1) [!] */ - {0xb7f28915, 159, -1}, /* Magical Taruruuto-kun 2 - Mahou Daibouken (J) */ - {0x183859d2, 159, -1}, /* Dragon Ball Z - Kyoushuu! Saiya Jin (J) [!] */ - {0x58152b42, 160, 1}, /* Pipe 5 (Sachen) */ - {0x1c098942, 162, -1}, /* Xi You Ji Hou Zhuan (Ch) */ - {0x081caaff, 163, -1}, /* Commandos (Ch) */ - {0x02c41438, 176, -1}, /* Xing He Zhan Shi (C) */ - {0x558c0dc3, 178, -1}, /* Super 2in1 (unl)[!] {mapper unsupported} */ - {0xc68363f6, 180, 0}, /* Crazy Climber */ - {0x0f05ff0a, 181, -1}, /* Seicross (redump) */ - {0x96ce586e, 189, 8}, /* Street Fighter 2 YOKO */ - {0x555a555e, 191, -1}, - {0x2cc381f6, 191, -1}, /* Sugoro Quest - Dice no Senshitachi (As) */ - {0xa145fae6, 192, -1}, - {0xa9115bc1, 192, -1}, - {0x4c7bbb0e, 192, -1}, - {0x98c1cd4b, 192, -1}, /* Ying Lie Qun Xia Zhuan (Chinese) */ - {0xee810d55, 192, -1}, /* You Ling Xing Dong (Ch) */ - {0x442f1a29, 192, -1}, /* Young chivalry */ - {0x637134e8, 193, 1}, /* Fighting Hero */ - {0xa925226c, 194, -1}, /* Dai-2-Ji - Super Robot Taisen (As) */ - {0x7f3dbf1b, 195, 0}, - {0xb616885c, 195, 0}, /* CHaos WOrld (Ch)*/ - {0x33c5df92, 195, -1}, - {0x1bc0be6c, 195, -1}, /* Captain Tsubasa Vol 2 - Super Striker (C) */ - {0xd5224fde, 195, -1}, /* Crystalis (c) */ - {0xfdec419f, 196, -1}, /* Street Fighter VI 16 Peoples (Unl) [!] */ - {0x700705f4, 198, -1}, - {0x9a2cf02c, 198, -1}, - {0xd8b401a7, 198, -1}, - {0x28192599, 198, -1}, - {0x19b9e732, 198, -1}, - {0xdd431ba7, 198, -1}, /* Tenchi wo kurau 2 (c) */ - {0xd871d3e6, 199, -1}, /* Dragon Ball Z 2 - Gekishin Freeza! (C) */ - {0xed481b7c, 199, -1}, /* Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) */ - {0x44c20420, 199, -1}, /* San Guo Zhi 2 (C) */ - {0x4e1c1e3c, 206, 0}, /* Karnov */ - {0x276237b3, 206, 0}, /* Karnov */ - {0x7678f1d5, 207, 8}, /* Fudou Myouou Den */ - {0x07eb2c12, 208, -1}, /* Street Fighter IV */ - {0xdd8ced31, 209, -1}, /* Power Rangers 3 */ - {0x063b1151, 209, -1}, /* Power Rangers 4 */ - {0xdd4d9a62, 209, -1}, /* Shin Samurai Spirits 2 */ - {0x0c47946d, 210, 1}, /* Chibi Maruko Chan */ - {0xc247cc80, 210, 1}, /* Family Circuit '91 */ - {0x6ec51de5, 210, 1}, /* Famista '92 */ - {0xadffd64f, 210, 1}, /* Famista '93 */ - {0x429103c9, 210, 1}, /* Famista '94 */ - {0x81b7f1a8, 210, 1}, /* Heisei Tensai Bakabon */ - {0x2447e03b, 210, 1}, /* Top Striker */ - {0x1dc0f740, 210, 1}, /* Wagyan Land 2 */ - {0xd323b806, 210, 1}, /* Wagyan Land 3 */ - {0xbd523011, 210, 0}, /* Dream Master */ - {0x5daae69a, 211, -1}, /* Aladdin - Return of Jaffar, The (Unl) [!] */ - {0x1ec1dfeb, 217, -1}, /* 255-in-1 (Cut version) [p1] */ - {0x046d70cc, 217, -1}, /* 500-in-1 (Anim Splash, Alt Mapper)[p1][!] */ - {0x12f86a4d, 217, -1}, /* 500-in-1 (Static Splash, Alt Mapper)[p1][!] */ - {0xd09f778d, 217, -1}, /* 9999999-in-1 (Static Splash, Alt Mapper)[p1][!] */ - {0x62ef6c79, 232, 8}, /* Quattro Sports -Aladdin */ - {0x2705eaeb, 234, -1}, /* Maxi 15 */ - {0x6f12afc5, 235, -1}, /* Golden Game 150-in-1 */ - {0xfb2b6b10, 241, -1}, /* Fan Kong Jing Ying (Ch) */ - {0xb5e83c9a, 241, -1}, /* Xing Ji Zheng Ba (Ch) */ - {0x2537b3e6, 241, -1}, /* Dance Xtreme - Prima (Unl) */ - {0x11611e89, 241, -1}, /* Darkseed (Unl) [p1] */ - {0x81a37827, 241, -1}, /* Darkseed (Unl) [p1][b1] */ - {0xc2730c30, 241, -1}, /* Deadly Towers (U) [!] */ - {0x368c19a8, 241, -1}, /* LIKO Study Cartridge 3-in-1 (Unl) [!] */ - {0xa21e675c, 241, -1}, /* Mashou (J) [!] */ - {0x54d98b79, 241, -1}, /* Titanic 1912 (Unl) */ - {0x6bea1235, 245, -1}, /* MMC3 cart, but with nobanking applied to CHR-RAM, so let it be there */ - {0x345ee51a, 245, -1}, /* DQ4c */ - {0x57514c6c, 245, -1}, /* Yong Zhe Dou E Long - Dragon Quest VI (Ch) */ - - {0x00000000, -1, -1} diff --git a/branches/fceux-2.2.2/src/ines.cpp b/branches/fceux-2.2.2/src/ines.cpp deleted file mode 100644 index 61a51913..00000000 --- a/branches/fceux-2.2.2/src/ines.cpp +++ /dev/null @@ -1,994 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "cart.h" -#include "ppu.h" - -#include "ines.h" -#include "unif.h" -#include "state.h" -#include "file.h" -#include "utils/general.h" -#include "utils/memory.h" -#include "utils/crc32.h" -#include "utils/md5.h" -#include "utils/xstring.h" -#include "cheat.h" -#include "vsuni.h" -#include "driver.h" - -#include -#include -#include - -extern SFORMAT FCEUVSUNI_STATEINFO[]; - -//mbg merge 6/29/06 - these need to be global -uint8 *trainerpoo = NULL; -uint8 *ROM = NULL; -uint8 *VROM = NULL; -uint8 *ExtraNTARAM = NULL; -iNES_HEADER head; - -static CartInfo iNESCart; - -uint8 Mirroring = 0; -uint32 ROM_size = 0; -uint32 VROM_size = 0; -char LoadedRomFName[2048]; //mbg merge 7/17/06 added - -static int CHRRAMSize = -1; -static int iNES_Init(int num); - -static int MapperNo = 0; - -static DECLFR(TrainerRead) { - return(trainerpoo[A & 0x1FF]); -} - -static void iNES_ExecPower() { - if (CHRRAMSize != -1) - FCEU_MemoryRand(VROM, CHRRAMSize); - - if (iNESCart.Power) - iNESCart.Power(); - - if (trainerpoo) { - int x; - for (x = 0; x < 512; x++) { - X6502_DMW(0x7000 + x, trainerpoo[x]); - if (X6502_DMR(0x7000 + x) != trainerpoo[x]) { - SetReadHandler(0x7000, 0x71FF, TrainerRead); - break; - } - } - } -} - -void iNESGI(GI h) { //bbit edited: removed static keyword - switch (h) { - case GI_RESETSAVE: - FCEU_ClearGameSave(&iNESCart); - break; - - case GI_RESETM2: - if (iNESCart.Reset) - iNESCart.Reset(); - break; - case GI_POWER: - iNES_ExecPower(); - break; - case GI_CLOSE: - { - FCEU_SaveGameSave(&iNESCart); - if (iNESCart.Close) - iNESCart.Close(); - if (ROM) { - free(ROM); - ROM = NULL; - } - if (VROM) { - free(VROM); - VROM = NULL; - } - if (trainerpoo) { - free(trainerpoo); - trainerpoo = NULL; - } - if (ExtraNTARAM) { - free(ExtraNTARAM); - ExtraNTARAM = NULL; - } - } - break; - } -} - -uint32 iNESGameCRC32 = 0; - -struct CRCMATCH { - uint32 crc; - char *name; -}; - -struct INPSEL { - uint32 crc32; - ESI input1; - ESI input2; - ESIFC inputfc; -}; - -static void SetInput(void) { - static struct INPSEL moo[] = - { - {0x19b0a9f1, SI_GAMEPAD, SI_ZAPPER, SIFC_NONE }, // 6-in-1 (MGC-023)(Unl)[!] - {0x29de87af, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Aerobics Studio - {0xd89e5a67, SI_UNSET, SI_UNSET, SIFC_ARKANOID }, // Arkanoid (J) - {0x0f141525, SI_UNSET, SI_UNSET, SIFC_ARKANOID }, // Arkanoid 2(J) - {0x32fb0583, SI_UNSET, SI_ARKANOID, SIFC_NONE }, // Arkanoid(NES) - {0x60ad090a, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERA }, // Athletic World - {0x48ca0ee1, SI_GAMEPAD, SI_GAMEPAD, SIFC_BWORLD }, // Barcode World - {0x4318a2f8, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Barker Bill's Trick Shooting - {0x6cca1c1f, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Dai Undoukai - {0x24598791, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Duck Hunt - {0xd5d6eac4, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Edu (As) - {0xe9a7fe9e, SI_UNSET, SI_MOUSE, SIFC_NONE }, // Educational Computer 2000 - {0x8f7b1669, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // FP BASIC 3.3 by maxzhou88 - {0xf7606810, SI_UNSET, SI_UNSET, SIFC_FKB }, // Family BASIC 2.0A - {0x895037bc, SI_UNSET, SI_UNSET, SIFC_FKB }, // Family BASIC 2.1a - {0xb2530afc, SI_UNSET, SI_UNSET, SIFC_FKB }, // Family BASIC 3.0 - {0xea90f3e2, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Family Trainer: Running Stadium - {0xbba58be5, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Family Trainer: Manhattan Police - {0x3e58a87e, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Freedom Force - {0xd9f45be9, SI_GAMEPAD, SI_GAMEPAD, SIFC_QUIZKING }, // Gimme a Break ... - {0x1545bd13, SI_GAMEPAD, SI_GAMEPAD, SIFC_QUIZKING }, // Gimme a Break ... 2 - {0x4e959173, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Gotcha! - The Sport! - {0xbeb8ab01, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Gumshoe - {0xff24d794, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Hogan's Alley - {0x21f85681, SI_GAMEPAD, SI_GAMEPAD, SIFC_HYPERSHOT }, // Hyper Olympic (Gentei Ban) - {0x980be936, SI_GAMEPAD, SI_GAMEPAD, SIFC_HYPERSHOT }, // Hyper Olympic - {0x915a53a7, SI_GAMEPAD, SI_GAMEPAD, SIFC_HYPERSHOT }, // Hyper Sports - {0x9fae4d46, SI_GAMEPAD, SI_GAMEPAD, SIFC_MAHJONG }, // Ide Yousuke Meijin no Jissen Mahjong - {0x7b44fb2a, SI_GAMEPAD, SI_GAMEPAD, SIFC_MAHJONG }, // Ide Yousuke Meijin no Jissen Mahjong 2 - {0x2f128512, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERA }, // Jogging Race - {0xbb33196f, SI_UNSET, SI_UNSET, SIFC_FKB }, // Keyboard Transformer - {0x8587ee00, SI_UNSET, SI_UNSET, SIFC_FKB }, // Keyboard Transformer - {0x543ab532, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // LIKO Color Lines - {0x368c19a8, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // LIKO Study Cartridge - {0x5ee6008e, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Mechanized Attack - {0x370ceb65, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Meiro Dai Sakusen - {0x3a1694f9, SI_GAMEPAD, SI_GAMEPAD, SIFC_4PLAYER }, // Nekketsu Kakutou Densetsu - {0x9d048ea4, SI_GAMEPAD, SI_GAMEPAD, SIFC_OEKAKIDS }, // Oeka Kids - {0x2a6559a1, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Operation Wolf (J) - {0xedc3662b, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Operation Wolf - {0x912989dc, SI_UNSET, SI_UNSET, SIFC_FKB }, // Playbox BASIC - {0x9044550e, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERA }, // Rairai Kyonshizu - {0xea90f3e2, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Running Stadium - {0x851eb9be, SI_GAMEPAD, SI_ZAPPER, SIFC_NONE }, // Shooting Range - {0x6435c095, SI_GAMEPAD, SI_POWERPADB, SIFC_UNSET }, // Short Order/Eggsplode - {0xc043a8df, SI_UNSET, SI_MOUSE, SIFC_NONE }, // Shu Qi Yu - Shu Xue Xiao Zhuan Yuan (Ch) - {0x2cf5db05, SI_UNSET, SI_MOUSE, SIFC_NONE }, // Shu Qi Yu - Zhi Li Xiao Zhuan Yuan (Ch) - {0xad9c63e2, SI_GAMEPAD, SI_UNSET, SIFC_SHADOW }, // Space Shadow - {0x61d86167, SI_GAMEPAD, SI_POWERPADB, SIFC_UNSET }, // Street Cop - {0xabb2f974, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Study and Game 32-in-1 - {0x41ef9ac4, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Subor - {0x8b265862, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Subor - {0x82f1fb96, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Subor 1.0 Russian - {0x9f8f200a, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERA }, // Super Mogura Tataki!! - Pokkun Moguraa - {0xd74b2719, SI_GAMEPAD, SI_POWERPADB, SIFC_UNSET }, // Super Team Games - {0x74bea652, SI_GAMEPAD, SI_ZAPPER, SIFC_NONE }, // Supergun 3-in-1 - {0x5e073a1b, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // Supor English (Chinese) - {0x589b6b0d, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // SuporV20 - {0x41401c6d, SI_UNSET, SI_UNSET, SIFC_SUBORKB }, // SuporV40 - {0x23d17f5e, SI_GAMEPAD, SI_ZAPPER, SIFC_NONE }, // The Lone Ranger - {0xc3c0811d, SI_GAMEPAD, SI_GAMEPAD, SIFC_OEKAKIDS }, // The two "Oeka Kids" games - {0xde8fd935, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // To the Earth - {0x47232739, SI_GAMEPAD, SI_GAMEPAD, SIFC_TOPRIDER }, // Top Rider - {0x8a12a7d9, SI_GAMEPAD, SI_GAMEPAD, SIFC_FTRAINERB }, // Totsugeki Fuuun Takeshi Jou - {0xb8b9aca3, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Wild Gunman - {0x5112dc21, SI_UNSET, SI_ZAPPER, SIFC_NONE }, // Wild Gunman - {0xaf4010ea, SI_GAMEPAD, SI_POWERPADB, SIFC_UNSET }, // World Class Track Meet - {0x00000000, SI_UNSET, SI_UNSET, SIFC_UNSET } - }; - int x = 0; - - while (moo[x].input1 >= 0 || moo[x].input2 >= 0 || moo[x].inputfc >= 0) { - if (moo[x].crc32 == iNESGameCRC32) { - GameInfo->input[0] = moo[x].input1; - GameInfo->input[1] = moo[x].input2; - GameInfo->inputfc = moo[x].inputfc; - break; - } - x++; - } -} - -#define INESB_INCOMPLETE 1 -#define INESB_CORRUPT 2 -#define INESB_HACKED 4 - -struct BADINF { - uint64 md5partial; - char *name; - uint32 type; -}; - -static struct BADINF BadROMImages[] = -{ - #include "ines-bad.h" -}; - -void CheckBad(uint64 md5partial) { - int32 x = 0; - while (BadROMImages[x].name) { - if (BadROMImages[x].md5partial == md5partial) { - FCEU_PrintError("The copy game you have loaded, \"%s\", is bad, and will not work properly in FCEUX.", BadROMImages[x].name); - return; - } - x++; - } -} - - -struct CHINF { - uint32 crc32; - int32 mapper; - int32 mirror; - const char* params; -}; - -static const TMasterRomInfo sMasterRomInfo[] = { - { 0x62b51b108a01d2beLL, "bonus=0" }, //4-in-1 (FK23C8021)[p1][!].nes - { 0x8bb48490d8d22711LL, "bonus=0" }, //4-in-1 (FK23C8033)[p1][!].nes - { 0xc75888d7b48cd378LL, "bonus=0" }, //4-in-1 (FK23C8043)[p1][!].nes - { 0xf81a376fa54fdd69LL, "bonus=0" }, //4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes - { 0xa37eb9163e001a46LL, "bonus=0" }, //4-in-1 (FK23C8026) [p1][!].nes - { 0xde5ce25860233f7eLL, "bonus=0" }, //4-in-1 (FK23C8045) [p1][!].nes - { 0x5b3aa4cdc484a088LL, "bonus=0" }, //4-in-1 (FK23C8056) [p1][!].nes - { 0x9342bf9bae1c798aLL, "bonus=0" }, //4-in-1 (FK23C8079) [p1][!].nes - { 0x164eea6097a1e313LL, "busc=1" }, //Cybernoid - The Fighting Machine (U)[!].nes -- needs bus conflict emulation -}; -const TMasterRomInfo* MasterRomInfo; -TMasterRomInfoParams MasterRomInfoParams; - -static void CheckHInfo(void) { - /* ROM images that have the battery-backed bit set in the header that really - don't have battery-backed RAM is not that big of a problem, so I'll - treat this differently by only listing games that should have battery-backed RAM. - - Lower 64 bits of the MD5 hash. - */ - - static uint64 savie[] = - { - 0xc04361e499748382LL, /* AD&D Heroes of the Lance */ - 0xb72ee2337ced5792LL, /* AD&D Hillsfar */ - 0x2b7103b7a27bd72fLL, /* AD&D Pool of Radiance */ - 0x498c10dc463cfe95LL, /* Battle Fleet */ - 0x854d7947a3177f57LL, /* Crystalis */ - 0x4a1f5336b86851b6LL, /* DW */ - 0xb0bcc02c843c1b79LL, /* DW */ - 0x2dcf3a98c7937c22LL, /* DW 2 */ - 0x98e55e09dfcc7533LL, /* DW 4*/ - 0x733026b6b72f2470LL, /* Dw 3 */ - 0x6917ffcaca2d8466LL, /* Famista '90 */ - 0x8da46db592a1fcf4LL, /* Faria */ - 0xedba17a2c4608d20LL, /* Final Fantasy */ - 0x91a6846d3202e3d6LL, /* Final Fantasy */ - 0x012df596e2b31174LL, /* Final Fantasy 1+2 */ - 0xf6b359a720549ecdLL, /* Final Fantasy 2 */ - 0x5a30da1d9b4af35dLL, /* Final Fantasy 3 */ - 0xd63dcc68c2b20adcLL, /* Final Fantasy J */ - 0x2ee3417ba8b69706LL, /* Hydlide 3*/ - 0xebbce5a54cf3ecc0LL, /* Justbreed */ - 0x6a858da551ba239eLL, /* Kaijuu Monogatari */ - 0x2db8f5d16c10b925LL, /* Kyonshiizu 2 */ - 0x04a31647de80fdabLL, /* Legend of Zelda */ - 0x94b9484862a26cbaLL, /* Legend of Zelda */ - 0xa40666740b7d22feLL, /* Mindseeker */ - 0x82000965f04a71bbLL, /* Mirai Shinwa Jarvas */ - 0x77b811b2760104b9LL, /* Mouryou Senki Madara */ - 0x11b69122efe86e8cLL, /* RPG Jinsei Game */ - 0x9aa1dc16c05e7de5LL, /* Startropics */ - 0x1b084107d0878bd0LL, /* Startropics 2*/ - 0xa70b495314f4d075LL, /* Ys 3 */ - 0x836c0ff4f3e06e45LL, /* Zelda 2 */ - 0 /* Abandon all hope if the game has 0 in the lower 64-bits of its MD5 hash */ - }; - - static struct CHINF moo[] = - { - #include "ines-correct.h" - }; - int32 tofix = 0, x; - uint64 partialmd5 = 0; - - for (x = 0; x < 8; x++) - partialmd5 |= (uint64)iNESCart.MD5[15 - x] << (x * 8); - CheckBad(partialmd5); - - MasterRomInfo = NULL; - for (int i = 0; i < ARRAY_SIZE(sMasterRomInfo); i++) { - const TMasterRomInfo& info = sMasterRomInfo[i]; - if (info.md5lower != partialmd5) - continue; - - MasterRomInfo = &info; - if (!info.params) break; - - std::vector toks = tokenize_str(info.params, ","); - for (int j = 0; j < (int)toks.size(); j++) { - std::vector parts = tokenize_str(toks[j], "="); - MasterRomInfoParams[parts[0]] = parts[1]; - } - break; - } - - x = 0; - do { - if (moo[x].crc32 == iNESGameCRC32) { - if (moo[x].mapper >= 0) { - if (moo[x].mapper & 0x800 && VROM_size) { - VROM_size = 0; - free(VROM); - VROM = NULL; - tofix |= 8; - } - if (MapperNo != (moo[x].mapper & 0xFF)) { - tofix |= 1; - MapperNo = moo[x].mapper & 0xFF; - } - } - if (moo[x].mirror >= 0) { - if (moo[x].mirror == 8) { - if (Mirroring == 2) { /* Anything but hard-wired(four screen). */ - tofix |= 2; - Mirroring = 0; - } - } else if (Mirroring != moo[x].mirror) { - if (Mirroring != (moo[x].mirror & ~4)) - if ((moo[x].mirror & ~4) <= 2) /* Don't complain if one-screen mirroring - needs to be set(the iNES header can't - hold this information). - */ - tofix |= 2; - Mirroring = moo[x].mirror; - } - } - break; - } - x++; - } while (moo[x].mirror >= 0 || moo[x].mapper >= 0); - - x = 0; - while (savie[x] != 0) { - if (savie[x] == partialmd5) { - if (!(head.ROM_type & 2)) { - tofix |= 4; - head.ROM_type |= 2; - } - } - x++; - } - - /* Games that use these iNES mappers tend to have the four-screen bit set - when it should not be. - */ - if ((MapperNo == 118 || MapperNo == 24 || MapperNo == 26) && (Mirroring == 2)) { - Mirroring = 0; - tofix |= 2; - } - - /* Four-screen mirroring implicitly set. */ - if (MapperNo == 99) - Mirroring = 2; - - if (tofix) { - char gigastr[768]; - strcpy(gigastr, "The iNES header contains incorrect information. For now, the information will be corrected in RAM. "); - if (tofix & 1) - sprintf(gigastr + strlen(gigastr), "The mapper number should be set to %d. ", MapperNo); - if (tofix & 2) { - char *mstr[3] = { "Horizontal", "Vertical", "Four-screen" }; - sprintf(gigastr + strlen(gigastr), "Mirroring should be set to \"%s\". ", mstr[Mirroring & 3]); - } - if (tofix & 4) - strcat(gigastr, "The battery-backed bit should be set. "); - if (tofix & 8) - strcat(gigastr, "This game should not have any CHR ROM. "); - strcat(gigastr, "\n"); - FCEU_printf("%s", gigastr); - } -} - -typedef struct { - int32 mapper; - void (*init)(CartInfo *); -} NewMI; - -//this is for games that is not the a power of 2 -//mapper based for now... -//not really accurate but this works since games -//that are not in the power of 2 tends to come -//in obscure mappers themselves which supports such -//size -static int not_power2[] = -{ - 53, 198, 228 -}; -typedef struct { - char *name; - int32 number; - void (*init)(CartInfo *); -} BMAPPINGLocal; - -static BMAPPINGLocal bmap[] = { - {"NROM", 0, NROM_Init}, - {"MMC1", 1, Mapper1_Init}, - {"UNROM", 2, UNROM_Init}, - {"CNROM", 3, CNROM_Init}, - {"MMC3", 4, Mapper4_Init}, - {"MMC5", 5, Mapper5_Init}, - {"FFE Rev. A", 6, Mapper6_Init}, - {"ANROM", 7, ANROM_Init}, - {"", 8, Mapper8_Init}, // Nogaems, it's worthless - {"MMC2", 9, Mapper9_Init}, - {"MMC4", 10, Mapper10_Init}, - {"Color Dreams", 11, Mapper11_Init}, - {"REX DBZ 5", 12, Mapper12_Init}, - {"CPROM", 13, CPROM_Init}, - {"REX SL-1632", 14, UNLSL1632_Init}, - {"100-in-1", 15, Mapper15_Init}, - {"BANDAI 24C02", 16, Mapper16_Init}, - {"FFE Rev. B", 17, Mapper17_Init}, - {"JALECO SS880006", 18, Mapper18_Init}, // JF-NNX (EB89018-30007) boards - {"Namcot 106", 19, Mapper19_Init}, -// {"", 20, Mapper20_Init}, - {"Konami VRC2/VRC4 A", 21, Mapper21_Init}, - {"Konami VRC2/VRC4 B", 22, Mapper22_Init}, - {"Konami VRC2/VRC4 C", 23, Mapper23_Init}, - {"Konami VRC6 Rev. A", 24, Mapper24_Init}, - {"Konami VRC2/VRC4 D", 25, Mapper25_Init}, - {"Konami VRC6 Rev. B", 26, Mapper26_Init}, - {"CC-21 MI HUN CHE", 27, UNLCC21_Init}, // Former dupe for VRC2/VRC4 mapper, redefined with crc to mihunche boards - {"", 28, Mapper28_Init}, -// {"", 29, Mapper29_Init}, -// {"", 30, Mapper30_Init}, -// {"", 31, Mapper31_Init}, - {"IREM G-101", 32, Mapper32_Init}, - {"TC0190FMC/TC0350FMR", 33, Mapper33_Init}, - {"IREM I-IM/BNROM", 34, Mapper34_Init}, - {"Wario Land 2", 35, UNLSC127_Init}, - {"TXC Policeman", 36, Mapper36_Init}, - {"PAL-ZZ SMB/TETRIS/NWC",37, Mapper37_Init}, - {"Bit Corp.", 38, Mapper38_Init}, // Crime Busters -// {"", 39, Mapper39_Init}, - {"SMB2j FDS", 40, Mapper40_Init}, - {"CALTRON 6-in-1", 41, Mapper41_Init}, - {"BIO MIRACLE FDS", 42, Mapper42_Init}, - {"FDS SMB2j LF36", 43, Mapper43_Init}, - {"MMC3 BMC PIRATE A", 44, Mapper44_Init}, - {"MMC3 BMC PIRATE B", 45, Mapper45_Init}, - {"RUMBLESTATION 15-in-1",46, Mapper46_Init}, - {"NES-QJ SSVB/NWC", 47, Mapper47_Init}, - {"TAITO TCxxx", 48, Mapper48_Init}, - {"MMC3 BMC PIRATE C", 49, Mapper49_Init}, - {"SMB2j FDS Rev. A", 50, Mapper50_Init}, - {"11-in-1 BALL SERIES", 51, Mapper51_Init}, // 1993 year version - {"MMC3 BMC PIRATE D", 52, Mapper52_Init}, - {"SUPERVISION 16-in-1", 53, Supervision16_Init}, -// {"", 54, Mapper54_Init}, -// {"", 55, Mapper55_Init}, -// {"", 56, Mapper56_Init}, - {"SIMBPLE BMC PIRATE A", 57, Mapper57_Init}, - {"SIMBPLE BMC PIRATE B", 58, BMCGK192_Init}, - {"", 59, Mapper59_Init}, // Check this out - {"SIMBPLE BMC PIRATE C", 60, BMCD1038_Init}, - {"20-in-1 KAISER Rev. A",61, Mapper61_Init}, - {"700-in-1", 62, Mapper62_Init}, -// {"", 63, Mapper63_Init}, - {"TENGEN RAMBO1", 64, Mapper64_Init}, - {"IREM-H3001", 65, Mapper65_Init}, - {"MHROM", 66, MHROM_Init}, - {"SUNSOFT-FZII", 67, Mapper67_Init}, - {"Sunsoft Mapper #4", 68, Mapper68_Init}, - {"SUNSOFT-5/FME-7", 69, Mapper69_Init}, - {"BA KAMEN DISCRETE", 70, Mapper70_Init}, - {"CAMERICA BF9093", 71, Mapper71_Init}, - {"JALECO JF-17", 72, Mapper72_Init}, - {"KONAMI VRC3", 73, Mapper73_Init}, - {"TW MMC3+VRAM Rev. A", 74, Mapper74_Init}, - {"KONAMI VRC1", 75, Mapper75_Init}, - {"NAMCOT 108 Rev. A", 76, Mapper76_Init}, - {"IREM LROG017", 77, Mapper77_Init}, - {"Irem 74HC161/32", 78, Mapper78_Init}, - {"AVE/C&E/TXC BOARD", 79, Mapper79_Init}, - {"TAITO X1-005 Rev. A", 80, Mapper80_Init}, -// {"", 81, Mapper81_Init}, - {"TAITO X1-017", 82, Mapper82_Init}, - {"YOKO VRC Rev. B", 83, Mapper83_Init}, -// {"", 84, Mapper84_Init}, - {"KONAMI VRC7", 85, Mapper85_Init}, - {"JALECO JF-13", 86, Mapper86_Init}, - {"74*139/74 DISCRETE", 87, Mapper87_Init}, - {"NAMCO 3433", 88, Mapper88_Init}, - {"SUNSOFT-3", 89, Mapper89_Init}, // SUNSOFT-2 mapper - {"HUMMER/JY BOARD", 90, Mapper90_Init}, - {"EARLY HUMMER/JY BOARD",91, Mapper91_Init}, - {"JALECO JF-19", 92, Mapper92_Init}, - {"SUNSOFT-3R", 93, SUNSOFT_UNROM_Init},// SUNSOFT-2 mapper with VRAM, different wiring - {"HVC-UN1ROM", 94, Mapper94_Init}, - {"NAMCOT 108 Rev. B", 95, Mapper95_Init}, - {"BANDAI OEKAKIDS", 96, Mapper96_Init}, - {"IREM TAM-S1", 97, Mapper97_Init}, -// {"", 98, Mapper98_Init}, - {"VS Uni/Dual- system", 99, Mapper99_Init}, -// {"", 100, Mapper100_Init}, - {"", 101, Mapper101_Init}, -// {"", 102, Mapper102_Init}, - {"FDS DOKIDOKI FULL", 103, Mapper103_Init}, -// {"", 104, Mapper104_Init}, - {"NES-EVENT NWC1990", 105, Mapper105_Init}, - {"SMB3 PIRATE A", 106, Mapper106_Init}, - {"MAGIC CORP A", 107, Mapper107_Init}, - {"FDS UNROM BOARD", 108, Mapper108_Init}, -// {"", 109, Mapper109_Init}, -// {"", 110, Mapper110_Init}, -// {"", 111, Mapper111_Init}, - {"ASDER/NTDEC BOARD", 112, Mapper112_Init}, - {"HACKER/SACHEN BOARD", 113, Mapper113_Init}, - {"MMC3 SG PROT. A", 114, Mapper114_Init}, - {"MMC3 PIRATE A", 115, Mapper115_Init}, - {"MMC1/MMC3/VRC PIRATE",116, UNLSL12_Init}, - {"FUTURE MEDIA BOARD", 117, Mapper117_Init}, - {"TSKROM", 118, TKSROM_Init}, - {"NES-TQROM", 119, Mapper119_Init}, - {"FDS TOBIDASE", 120, Mapper120_Init}, - {"MMC3 PIRATE PROT. A", 121, Mapper121_Init}, -// {"", 122, Mapper122_Init}, - {"MMC3 PIRATE H2288", 123, UNLH2288_Init}, -// {"", 124, Mapper124_Init}, - {"FDS LH32", 125, LH32_Init}, -// {"", 126, Mapper126_Init}, -// {"", 127, Mapper127_Init}, -// {"", 128, Mapper128_Init}, -// {"", 129, Mapper129_Init}, -// {"", 130, Mapper130_Init}, -// {"", 131, Mapper131_Init}, - {"TXC/MGENIUS 22111", 132, UNL22211_Init}, - {"SA72008", 133, SA72008_Init}, - {"MMC3 BMC PIRATE", 134, Mapper134_Init}, -// {"", 135, Mapper135_Init}, - {"TCU02", 136, TCU02_Init}, - {"S8259D", 137, S8259D_Init}, - {"S8259B", 138, S8259B_Init}, - {"S8259C", 139, S8259C_Init}, - {"JALECO JF-11/14", 140, Mapper140_Init}, - {"S8259A", 141, S8259A_Init}, - {"UNLKS7032", 142, UNLKS7032_Init}, - {"TCA01", 143, TCA01_Init}, - {"AGCI 50282", 144, Mapper144_Init}, - {"SA72007", 145, SA72007_Init}, - {"SA0161M", 146, SA0161M_Init}, - {"TCU01", 147, TCU01_Init}, - {"SA0037", 148, SA0037_Init}, - {"SA0036", 149, SA0036_Init}, - {"S74LS374N", 150, S74LS374N_Init}, - {"", 151, Mapper151_Init}, - {"", 152, Mapper152_Init}, - {"BANDAI SRAM", 153, Mapper153_Init}, // Bandai board 16 with SRAM instead of EEPROM - {"", 154, Mapper154_Init}, - {"", 155, Mapper155_Init}, - {"", 156, Mapper156_Init}, - {"BANDAI BARCODE", 157, Mapper157_Init}, -// {"", 158, Mapper158_Init}, - {"BANDAI 24C01", 159, Mapper159_Init}, // Different type of EEPROM on the bandai board - {"SA009", 160, SA009_Init}, -// {"", 161, Mapper161_Init}, - {"", 162, UNLFS304_Init}, - {"", 163, Mapper163_Init}, - {"", 164, Mapper164_Init}, - {"", 165, Mapper165_Init}, - {"SUBOR Rev. A", 166, Mapper166_Init}, - {"SUBOR Rev. B", 167, Mapper167_Init}, - {"", 168, Mapper168_Init}, -// {"", 169, Mapper169_Init}, - {"", 170, Mapper170_Init}, - {"", 171, Mapper171_Init}, - {"", 172, Mapper172_Init}, - {"", 173, Mapper173_Init}, -// {"", 174, Mapper174_Init}, - {"", 175, Mapper175_Init}, - {"BMCFK23C", 176, BMCFK23C_Init}, // zero 26-may-2012 - well, i have some WXN junk games that use 176 for instance ????. i dont know what game uses this BMCFK23C as mapper 176. we'll have to make a note when we find it. - {"", 177, Mapper177_Init}, - {"", 178, Mapper178_Init}, -// {"", 179, Mapper179_Init}, - {"", 180, Mapper180_Init}, - {"", 181, Mapper181_Init}, -// {"", 182, Mapper182_Init}, // Deprecated, dupe - {"", 183, Mapper183_Init}, - {"", 184, Mapper184_Init}, - {"", 185, Mapper185_Init}, - {"", 186, Mapper186_Init}, - {"", 187, Mapper187_Init}, - {"", 188, Mapper188_Init}, - {"", 189, Mapper189_Init}, -// {"", 190, Mapper190_Init}, - {"", 191, Mapper191_Init}, - {"TW MMC3+VRAM Rev. B", 192, Mapper192_Init}, - {"NTDEC TC-112", 193, Mapper193_Init}, // War in the Gulf - {"TW MMC3+VRAM Rev. C", 194, Mapper194_Init}, - {"TW MMC3+VRAM Rev. D", 195, Mapper195_Init}, - {"", 196, Mapper196_Init}, - {"", 197, Mapper197_Init}, - {"TW MMC3+VRAM Rev. E", 198, Mapper198_Init}, - {"", 199, Mapper199_Init}, - {"", 200, Mapper200_Init}, - {"", 201, Mapper201_Init}, - {"", 202, Mapper202_Init}, - {"", 203, Mapper203_Init}, - {"", 204, Mapper204_Init}, - {"", 205, Mapper205_Init}, - {"NAMCOT 108 Rev. C", 206, Mapper206_Init}, // Deprecated, Used to be "DEIROM" whatever it means, but actually simple version of MMC3 - {"TAITO X1-005 Rev. B", 207, Mapper207_Init}, - {"", 208, Mapper208_Init}, - {"", 209, Mapper209_Init}, - {"", 210, Mapper210_Init}, - {"", 211, Mapper211_Init}, - {"", 212, Mapper212_Init}, - {"", 213, Mapper213_Init}, - {"", 214, Mapper214_Init}, - {"", 215, UNL8237_Init}, - {"", 216, Mapper216_Init}, - {"", 217, Mapper217_Init}, // Redefined to a new Discrete BMC mapper -// {"", 218, Mapper218_Init}, - {"UNLA9746", 219, UNLA9746_Init}, - {"Debug Mapper", 220, UNLKS7057_Init}, - {"UNLN625092", 221, UNLN625092_Init}, - {"", 222, Mapper222_Init}, -// {"", 223, Mapper223_Init}, -// {"", 224, Mapper224_Init}, - {"", 225, Mapper225_Init}, - {"BMC 22+20-in-1", 226, Mapper226_Init}, - {"", 227, Mapper227_Init}, - {"", 228, Mapper228_Init}, - {"", 229, Mapper229_Init}, - {"BMC Contra+22-in-1", 230, Mapper230_Init}, - {"", 231, Mapper231_Init}, - {"BMC QUATTRO", 232, Mapper232_Init}, - {"BMC 22+20-in-1 RST", 233, Mapper233_Init}, - {"BMC MAXI", 234, Mapper234_Init}, - {"", 235, Mapper235_Init}, -// {"", 236, Mapper236_Init}, -// {"", 237, Mapper237_Init}, - {"UNL6035052", 238, UNL6035052_Init}, -// {"", 239, Mapper239_Init}, - {"", 240, Mapper240_Init}, - {"", 241, Mapper241_Init}, - {"", 242, Mapper242_Init}, - {"S74LS374NA", 243, S74LS374NA_Init}, - {"DECATHLON", 244, Mapper244_Init}, - {"", 245, Mapper245_Init}, - {"FONG SHEN BANG", 246, Mapper246_Init}, -// {"", 247, Mapper247_Init}, -// {"", 248, Mapper248_Init}, - {"", 249, Mapper249_Init}, - {"", 250, Mapper250_Init}, -// {"", 251, Mapper251_Init}, // No good dumps for this mapper, use UNIF version - {"SAN GUO ZHI PIRATE", 252, Mapper252_Init}, - {"DRAGON BALL PIRATE", 253, Mapper253_Init}, - {"", 254, Mapper254_Init}, -// {"", 255, Mapper255_Init}, // No good dumps for this mapper - {"", 0, NULL} -}; - -int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) { - struct md5_context md5; - - if (FCEU_fread(&head, 1, 16, fp) != 16) - return 0; - - if (memcmp(&head, "NES\x1a", 4)) - return 0; - - head.cleanup(); - - memset(&iNESCart, 0, sizeof(iNESCart)); - - MapperNo = (head.ROM_type >> 4); - MapperNo |= (head.ROM_type2 & 0xF0); - if (head.ROM_type & 8) { - Mirroring = 2; - } else - Mirroring = (head.ROM_type & 1); - - if (!head.ROM_size) - ROM_size = 256; - else - ROM_size = uppow2(head.ROM_size); - - VROM_size = uppow2(head.VROM_size); - - int round = true; - for (int i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) { - //for games not to the power of 2, so we just read enough - //prg rom from it, but we have to keep ROM_size to the power of 2 - //since PRGCartMapping wants ROM_size to be to the power of 2 - //so instead if not to power of 2, we just use head.ROM_size when - //we use FCEU_read - if (not_power2[i] == MapperNo) { - round = false; - break; - } - } - - if ((ROM = (uint8*)FCEU_malloc(ROM_size << 14)) == NULL) - return 0; - memset(ROM, 0xFF, ROM_size << 14); - - if (VROM_size) { - if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) { - free(ROM); - ROM = NULL; - return 0; - } - memset(VROM, 0xFF, VROM_size << 13); - } - - if (head.ROM_type & 4) { /* Trainer */ - trainerpoo = (uint8*)FCEU_gmalloc(512); - FCEU_fread(trainerpoo, 512, 1, fp); - } - - ResetCartMapping(); - ResetExState(0, 0); - - SetupCartPRGMapping(0, ROM, ROM_size << 14, 0); - - FCEU_fread(ROM, 0x4000, (round) ? ROM_size : head.ROM_size, fp); - - if (VROM_size) - FCEU_fread(VROM, 0x2000, VROM_size, fp); - - md5_starts(&md5); - md5_update(&md5, ROM, ROM_size << 14); - - iNESGameCRC32 = CalcCRC32(0, ROM, ROM_size << 14); - - if (VROM_size) { - iNESGameCRC32 = CalcCRC32(iNESGameCRC32, VROM, VROM_size << 13); - md5_update(&md5, VROM, VROM_size << 13); - } - md5_finish(&md5, iNESCart.MD5); - memcpy(&GameInfo->MD5, &iNESCart.MD5, sizeof(iNESCart.MD5)); - - iNESCart.CRC32 = iNESGameCRC32; - - FCEU_printf(" PRG ROM: %3d x 16KiB\n", (round) ? ROM_size: head.ROM_size); - FCEU_printf(" CHR ROM: %3d x 8KiB\n", head.VROM_size); - FCEU_printf(" ROM CRC32: 0x%08lx\n", iNESGameCRC32); - { - int x; - FCEU_printf(" ROM MD5: 0x"); - for(x=0;x<16;x++) - FCEU_printf("%02x",iNESCart.MD5[x]); - FCEU_printf("\n"); - } - - char* mappername = "Not Listed"; - - for (int mappertest = 0; mappertest < (sizeof bmap / sizeof bmap[0]) - 1; mappertest++) { - if (bmap[mappertest].number == MapperNo) { - mappername = bmap[mappertest].name; - break; - } - } - - FCEU_printf(" Mapper #: %d\n", MapperNo); - FCEU_printf(" Mapper name: %s\n", mappername); - FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal"); - FCEU_printf(" Battery-backed: %s\n", (head.ROM_type & 2) ? "Yes" : "No"); - FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No"); - - SetInput(); - CheckHInfo(); - { - int x; - uint64 partialmd5 = 0; - - for (x = 0; x < 8; x++) { - partialmd5 |= (uint64)iNESCart.MD5[7 - x] << (x * 8); - } - - FCEU_VSUniCheck(partialmd5, &MapperNo, &Mirroring); - } - /* Must remain here because above functions might change value of - VROM_size and free(VROM). - */ - if (VROM_size) - SetupCartCHRMapping(0, VROM, VROM_size * 0x2000, 0); - - if (Mirroring == 2) { - ExtraNTARAM = (uint8*)FCEU_gmalloc(2048); - SetupCartMirroring(4, 1, ExtraNTARAM); - } else if (Mirroring >= 0x10) - SetupCartMirroring(2 + (Mirroring & 1), 1, 0); - else - SetupCartMirroring(Mirroring & 1, (Mirroring & 4) >> 2, 0); - - iNESCart.battery = (head.ROM_type & 2) ? 1 : 0; - iNESCart.mirror = Mirroring; - - if (!iNES_Init(MapperNo)) - FCEU_PrintError("iNES mapper #%d is not supported at all.", MapperNo); - - GameInfo->mappernum = MapperNo; - FCEU_LoadGameSave(&iNESCart); - - strcpy(LoadedRomFName, name); //bbit edited: line added - - // Extract Filename only. Should account for Windows/Unix this way. - if (strrchr(name, '/')) { - name = strrchr(name, '/') + 1; - } else if (strrchr(name, '\\')) { - name = strrchr(name, '\\') + 1; - } - - GameInterface = iNESGI; - FCEU_printf("\n"); - - // since apparently the iNES format doesn't store this information, - // guess if the settings should be PAL or NTSC from the ROM name - // TODO: MD5 check against a list of all known PAL games instead? - if (OverwriteVidMode) { - if (strstr(name, "(E)") || strstr(name, "(e)") - || strstr(name, "(Europe)") || strstr(name, "(PAL)") - || strstr(name, "(F)") || strstr(name, "(f)") - || strstr(name, "(G)") || strstr(name, "(g)") - || strstr(name, "(I)") || strstr(name, "(i)")) - FCEUI_SetVidSystem(1); - else - FCEUI_SetVidSystem(0); - } - return 1; -} - -// bbit edited: the whole function below was added -int iNesSave() { - FILE *fp; - char name[2048]; - - if (GameInfo->type != GIT_CART) return 0; - if (GameInterface != iNESGI) return 0; - - strcpy(name, LoadedRomFName); - if (strcmp(name + strlen(name) - 4, ".nes") != 0) { //para edit - strcat(name, ".nes"); - } - - fp = fopen(name, "wb"); - if (!fp) - return 0; - - if (fwrite(&head, 1, 16, fp) != 16) - { - fclose(fp); - return 0; - } - - if (head.ROM_type & 4) - { - /* Trainer */ - fwrite(trainerpoo, 512, 1, fp); - } - - fwrite(ROM, 0x4000, ROM_size, fp); - - if (head.VROM_size) - fwrite(VROM, 0x2000, head.VROM_size, fp); - - fclose(fp); - return 1; -} - -int iNesSaveAs(char* name) -{ - //adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function - FILE *fp; - - if (GameInfo->type != GIT_CART) return 0; - if (GameInterface != iNESGI) return 0; - - fp = fopen(name, "wb"); - if (!fp) - return 0; - - if (fwrite(&head, 1, 16, fp) != 16) - { - fclose(fp); - return 0; - } - - if (head.ROM_type & 4) - { - /* Trainer */ - fwrite(trainerpoo, 512, 1, fp); - } - - fwrite(ROM, 0x4000, ROM_size, fp); - - if (head.VROM_size) - fwrite(VROM, 0x2000, head.VROM_size, fp); - - fclose(fp); - return 1; -} - -//para edit: added function below -char *iNesShortFName() { - char *ret; - - if (!(ret = strrchr(LoadedRomFName, '\\'))) - { - if (!(ret = strrchr(LoadedRomFName, '/'))) - return 0; - } - return ret + 1; -} - -static int iNES_Init(int num) { - BMAPPINGLocal *tmp = bmap; - - CHRRAMSize = -1; - - if (GameInfo->type == GIT_VSUNI) - AddExState(FCEUVSUNI_STATEINFO, ~0, 0, 0); - - while (tmp->init) { - if (num == tmp->number) { - UNIFchrrama = 0; // need here for compatibility with UNIF mapper code - if (!VROM_size) { - switch (num) { // FIXME, mapper or game data base with the board parameters and ROM/RAM sizes - case 13: CHRRAMSize = 16 * 1024; break; - case 6: - case 96: CHRRAMSize = 32 * 1024; break; - case 176: CHRRAMSize = 128 * 1024; break; - default: CHRRAMSize = 8 * 1024; break; - } - if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0; - FCEU_MemoryRand(VROM, CHRRAMSize); - - UNIFchrrama = VROM; - SetupCartCHRMapping(0, VROM, CHRRAMSize, 1); - AddExState(VROM, CHRRAMSize, 0, "CHRR"); - } - if (head.ROM_type & 8) - AddExState(ExtraNTARAM, 2048, 0, "EXNR"); - tmp->init(&iNESCart); - return 1; - } - tmp++; - } - return 0; -} diff --git a/branches/fceux-2.2.2/src/ines.h b/branches/fceux-2.2.2/src/ines.h deleted file mode 100644 index 2913b00b..00000000 --- a/branches/fceux-2.2.2/src/ines.h +++ /dev/null @@ -1,267 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 Bero - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _INES_H_ -#define _INES_H_ -#include -#include -#include - -struct TMasterRomInfo -{ - uint64 md5lower; - const char* params; -}; - -class TMasterRomInfoParams : public std::map -{ -public: - bool ContainsKey(const std::string& key) { return find(key) != end(); } -}; - -//mbg merge 6/29/06 -extern uint8 *ROM; -extern uint8 *VROM; -extern uint32 VROM_size; -extern uint32 ROM_size; -extern uint8 *ExtraNTARAM; -extern int iNesSave(); //bbit Edited: line added -extern int iNesSaveAs(char* name); -extern char LoadedRomFName[2048]; //bbit Edited: line added -extern const TMasterRomInfo* MasterRomInfo; -extern TMasterRomInfoParams MasterRomInfoParams; - -//mbg merge 7/19/06 changed to c++ decl format -struct iNES_HEADER { - char ID[4]; /*NES^Z*/ - uint8 ROM_size; - uint8 VROM_size; - uint8 ROM_type; - uint8 ROM_type2; - uint8 reserve[8]; - - void cleanup() - { - if(!memcmp((char *)(this)+0x7,"DiskDude",8)) - { - memset((char *)(this)+0x7,0,0x9); - } - - if(!memcmp((char *)(this)+0x7,"demiforce",9)) - { - memset((char *)(this)+0x7,0,0x9); - } - - if(!memcmp((char *)(this)+0xA,"Ni03",4)) - { - if(!memcmp((char *)(this)+0x7,"Dis",3)) - memset((char *)(this)+0x7,0,0x9); - else - memset((char *)(this)+0xA,0,0x6); - } - } -}; -extern struct iNES_HEADER head; //for mappers usage - -void NSFVRC6_Init(void); -void NSFMMC5_Init(void); -void NSFAY_Init(void); -void NSFN106_Init(void); -void NSFVRC7_Init(void); - -void Mapper1_Init(CartInfo *); -void Mapper4_Init(CartInfo *); -void Mapper5_Init(CartInfo *); -void Mapper6_Init(CartInfo *); -void Mapper8_Init(CartInfo *); -void Mapper9_Init(CartInfo *); -void Mapper10_Init(CartInfo *); -void Mapper11_Init(CartInfo *); -void Mapper12_Init(CartInfo *); -void Mapper15_Init(CartInfo *); -void Mapper16_Init(CartInfo *); -void Mapper17_Init(CartInfo *); -void Mapper18_Init(CartInfo *); -void Mapper19_Init(CartInfo *); -void Mapper21_Init(CartInfo *); -void Mapper22_Init(CartInfo *); -void Mapper23_Init(CartInfo *); -void Mapper24_Init(CartInfo *); -void Mapper25_Init(CartInfo *); -void Mapper26_Init(CartInfo *); -void Mapper28_Init(CartInfo *); -void Mapper32_Init(CartInfo *); -void Mapper33_Init(CartInfo *); -void Mapper34_Init(CartInfo *); -void Mapper36_Init(CartInfo *); -void Mapper37_Init(CartInfo *); -void Mapper38_Init(CartInfo *); -void Mapper40_Init(CartInfo *); -void Mapper41_Init(CartInfo *); -void Mapper42_Init(CartInfo *); -void Mapper43_Init(CartInfo *); -void Mapper44_Init(CartInfo *); -void Mapper45_Init(CartInfo *); -void Mapper46_Init(CartInfo *); -void Mapper47_Init(CartInfo *); -void Mapper48_Init(CartInfo *); -void Mapper49_Init(CartInfo *); -void Mapper50_Init(CartInfo *); -void Mapper51_Init(CartInfo *); -void Mapper52_Init(CartInfo *); -void Mapper57_Init(CartInfo *); -void Mapper59_Init(CartInfo *); -void Mapper61_Init(CartInfo *); -void Mapper62_Init(CartInfo *); -void Mapper64_Init(CartInfo *); -void Mapper65_Init(CartInfo *); -void Mapper67_Init(CartInfo *); -void Mapper68_Init(CartInfo *); -void Mapper69_Init(CartInfo *); -void Mapper70_Init(CartInfo *); -void Mapper71_Init(CartInfo *); -void Mapper72_Init(CartInfo *); -void Mapper73_Init(CartInfo *); -void Mapper74_Init(CartInfo *); -void Mapper75_Init(CartInfo *); -void Mapper76_Init(CartInfo *); -void Mapper77_Init(CartInfo *); -void Mapper78_Init(CartInfo *); -void Mapper79_Init(CartInfo *); -void Mapper80_Init(CartInfo *); -void Mapper82_Init(CartInfo *); -void Mapper83_Init(CartInfo *); -void Mapper85_Init(CartInfo *); -void Mapper86_Init(CartInfo *); -void Mapper87_Init(CartInfo *); -void Mapper88_Init(CartInfo *); -void Mapper89_Init(CartInfo *); -void Mapper90_Init(CartInfo *); -void Mapper91_Init(CartInfo *); -void Mapper92_Init(CartInfo *); -void Mapper93_Init(CartInfo *); -void Mapper94_Init(CartInfo *); -void Mapper95_Init(CartInfo *); -void Mapper96_Init(CartInfo *); -void Mapper97_Init(CartInfo *); -void Mapper99_Init(CartInfo *); -void Mapper101_Init(CartInfo *); -void Mapper103_Init(CartInfo *); -void Mapper105_Init(CartInfo *); -void Mapper106_Init(CartInfo *); -void Mapper107_Init(CartInfo *); -void Mapper108_Init(CartInfo *); -void Mapper112_Init(CartInfo *); -void Mapper113_Init(CartInfo *); -void Mapper114_Init(CartInfo *); -void Mapper115_Init(CartInfo *); -void Mapper117_Init(CartInfo *); -void Mapper119_Init(CartInfo *); -void Mapper120_Init(CartInfo *); -void Mapper121_Init(CartInfo *); -void Mapper125_Init(CartInfo *); -void Mapper134_Init(CartInfo *); -void Mapper140_Init(CartInfo *); -void Mapper144_Init(CartInfo *); -void Mapper151_Init(CartInfo *); -void Mapper152_Init(CartInfo *); -void Mapper153_Init(CartInfo *); -void Mapper154_Init(CartInfo *); -void Mapper155_Init(CartInfo *); -void Mapper156_Init(CartInfo *); -void Mapper157_Init(CartInfo *); -void Mapper159_Init(CartInfo *); -void Mapper163_Init(CartInfo *); -void Mapper164_Init(CartInfo *); -void Mapper165_Init(CartInfo *); -void Mapper166_Init(CartInfo *); -void Mapper167_Init(CartInfo *); -void Mapper168_Init(CartInfo *); -void Mapper170_Init(CartInfo *); -void Mapper171_Init(CartInfo *); -void Mapper172_Init(CartInfo *); -void Mapper173_Init(CartInfo *); -void Mapper175_Init(CartInfo *); -void Mapper177_Init(CartInfo *); -void Mapper178_Init(CartInfo *); -void Mapper180_Init(CartInfo *); -void Mapper181_Init(CartInfo *); -void Mapper183_Init(CartInfo *); -void Mapper184_Init(CartInfo *); -void Mapper185_Init(CartInfo *); -void Mapper186_Init(CartInfo *); -void Mapper187_Init(CartInfo *); -void Mapper188_Init(CartInfo *); -void Mapper189_Init(CartInfo *); -void Mapper191_Init(CartInfo *); -void Mapper192_Init(CartInfo *); -void Mapper193_Init(CartInfo *); -void Mapper194_Init(CartInfo *); -void Mapper195_Init(CartInfo *); -void Mapper196_Init(CartInfo *); -void Mapper197_Init(CartInfo *); -void Mapper198_Init(CartInfo *); -void Mapper199_Init(CartInfo *); -void Mapper200_Init(CartInfo *); -void Mapper201_Init(CartInfo *); -void Mapper202_Init(CartInfo *); -void Mapper203_Init(CartInfo *); -void Mapper204_Init(CartInfo *); -void Mapper205_Init(CartInfo *); -void Mapper206_Init(CartInfo *); -void Mapper207_Init(CartInfo *); -void Mapper208_Init(CartInfo *); -void Mapper209_Init(CartInfo *); -void Mapper210_Init(CartInfo *); -void Mapper211_Init(CartInfo *); -void Mapper212_Init(CartInfo *); -void Mapper213_Init(CartInfo *); -void Mapper214_Init(CartInfo *); -void Mapper216_Init(CartInfo *); -void Mapper217_Init(CartInfo *); -void Mapper220_Init(CartInfo *); -void Mapper222_Init(CartInfo *); -void Mapper225_Init(CartInfo *); -void Mapper226_Init(CartInfo *); -void Mapper227_Init(CartInfo *); -void Mapper228_Init(CartInfo *); -void Mapper229_Init(CartInfo *); -void Mapper230_Init(CartInfo *); -void Mapper231_Init(CartInfo *); -void Mapper232_Init(CartInfo *); -void Mapper233_Init(CartInfo *); -void Mapper234_Init(CartInfo *); -void Mapper235_Init(CartInfo *); -void Mapper236_Init(CartInfo *); -void Mapper237_Init(CartInfo *); -void Mapper240_Init(CartInfo *); -void Mapper241_Init(CartInfo *); -void Mapper242_Init(CartInfo *); -void Mapper244_Init(CartInfo *); -void Mapper245_Init(CartInfo *); -void Mapper246_Init(CartInfo *); -void Mapper249_Init(CartInfo *); -void Mapper250_Init(CartInfo *); -void Mapper252_Init(CartInfo *); -void Mapper253_Init(CartInfo *); -void Mapper254_Init(CartInfo *); - -#endif diff --git a/branches/fceux-2.2.2/src/input.cpp b/branches/fceux-2.2.2/src/input.cpp deleted file mode 100644 index 864e35e8..00000000 --- a/branches/fceux-2.2.2/src/input.cpp +++ /dev/null @@ -1,1210 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 1998 BERO -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "types.h" -#include "x6502.h" - -#include "fceu.h" -#include "sound.h" -#include "netplay.h" -#include "movie.h" -#include "state.h" -#include "input/zapper.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif -#include "input.h" -#include "vsuni.h" -#include "fds.h" -#include "driver.h" - -#ifdef WIN32 -#include "drivers/win/main.h" -#include "drivers/win/memwatch.h" -#include "drivers/win/cheat.h" -#include "drivers/win/debugger.h" -#include "drivers/win/ppuview.h" -#include "drivers/win/cdlogger.h" -#include "drivers/win/tracer.h" -#include "drivers/win/memview.h" -#include "drivers/win/window.h" -#include "drivers/win/ntview.h" -#include "drivers/win/taseditor.h" - -#include -#include -#include - -extern bool mustRewindNow; -#endif // WIN32 - -//it is easier to declare these input drivers extern here than include a bunch of files -//------------- -extern INPUTC *FCEU_InitZapper(int w); -extern INPUTC *FCEU_InitPowerpadA(int w); -extern INPUTC *FCEU_InitPowerpadB(int w); -extern INPUTC *FCEU_InitArkanoid(int w); - -extern INPUTCFC *FCEU_InitArkanoidFC(void); -extern INPUTCFC *FCEU_InitSpaceShadow(void); -extern INPUTCFC *FCEU_InitFKB(void); -extern INPUTCFC *FCEU_InitSuborKB(void); -extern INPUTCFC *FCEU_InitHS(void); -extern INPUTCFC *FCEU_InitMahjong(void); -extern INPUTCFC *FCEU_InitQuizKing(void); -extern INPUTCFC *FCEU_InitFamilyTrainerA(void); -extern INPUTCFC *FCEU_InitFamilyTrainerB(void); -extern INPUTCFC *FCEU_InitOekaKids(void); -extern INPUTCFC *FCEU_InitTopRider(void); -extern INPUTCFC *FCEU_InitBarcodeWorld(void); -//--------------- - -//global lag variables -unsigned int lagCounter; -bool lagCounterDisplay; -char lagFlag; -extern bool frameAdvanceLagSkip; -extern bool movieSubtitles; -//------------- - -static uint8 joy_readbit[2]; -uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it -static uint8 LastStrobe; - -bool replaceP2StartWithMicrophone = false; - -//This function is a quick hack to get the NSF player to use emulated gamepad input. -uint8 FCEU_GetJoyJoy(void) -{ - return(joy[0]|joy[1]|joy[2]|joy[3]); -} - -extern uint8 coinon; - -//set to true if the fourscore is attached -static bool FSAttached = false; - -JOYPORT joyports[2] = { JOYPORT(0), JOYPORT(1) }; -FCPORT portFC; - -static DECLFR(JPRead) -{ - lagFlag = 0; - uint8 ret=0; - static bool microphone = false; - - ret|=joyports[A&1].driver->Read(A&1); - - // Test if the port 2 start button is being pressed. - // On a famicom, port 2 start shouldn't exist, so this removes it. - // Games can't automatically be checked for NES/Famicom status, - // so it's an all-encompassing change in the input config menu. - if ((replaceP2StartWithMicrophone) && (A&1) && (joy_readbit[1] == 4)) { - // Nullify Port 2 Start Button - ret&=0xFE; - } - - if(portFC.driver) - ret = portFC.driver->Read(A&1,ret); - - // Not verified against hardware. - if (replaceP2StartWithMicrophone) { - if (joy[1]&8) { - microphone = !microphone; - if (microphone) { - ret|=4; - } - } else { - microphone = false; - } - } - - ret|=X.DB&0xC0; - - return(ret); -} - -static DECLFW(B4016) -{ - if(portFC.driver) - portFC.driver->Write(V&7); - - for(int i=0;i<2;i++) - joyports[i].driver->Write(V&1); - - if((LastStrobe&1) && (!(V&1))) - { - //old comment: - //This strobe code is just for convenience. If it were - //with the code in input / *.c, it would more accurately represent - //what's really going on. But who wants accuracy? ;) - //Seriously, though, this shouldn't be a problem. - //new comment: - - //mbg 6/7/08 - I guess he means that the input drivers could track the strobing themselves - //I dont see why it is unreasonable here. - for(int i=0;i<2;i++) - joyports[i].driver->Strobe(i); - if(portFC.driver) - portFC.driver->Strobe(); - } - LastStrobe=V&0x1; -} - -//a main joystick port driver representing the case where nothing is plugged in -static INPUTC DummyJPort={0}; -//and an expansion port driver for the same ting -static INPUTCFC DummyPortFC={0}; - - -//--------4 player driver for expansion port-------- -static uint8 F4ReadBit[2]; -static void StrobeFami4(void) -{ - F4ReadBit[0]=F4ReadBit[1]=0; -} - -static uint8 ReadFami4(int w, uint8 ret) -{ - ret&=1; - - ret |= ((joy[2+w]>>(F4ReadBit[w]))&1)<<1; - if(F4ReadBit[w]>=8) ret|=2; - else F4ReadBit[w]++; - - return(ret); -} - -static INPUTCFC FAMI4C={ReadFami4,0,StrobeFami4,0,0,0}; -//------------------ - -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - -static uint8 ReadGPVS(int w) -{ - uint8 ret=0; - - if(joy_readbit[w]>=8) - ret=1; - else - { - ret = ((joy[w]>>(joy_readbit[w]))&1); - if(!fceuindbg) - joy_readbit[w]++; - } - return ret; -} - -static void UpdateGP(int w, void *data, int arg) -{ - if(w==0) //adelikat, 3/14/09: Changing the joypads to inclusive OR the user's joypad + the Lua joypad, this way lua only takes over the buttons it explicity says to - { //FatRatKnight: Assume lua is always good. If it's doing nothing in particular using my logic, it'll pass-through the values anyway. - #ifdef _S9XLUA_H - joy[0]= *(uint32 *)joyports[0].ptr; - joy[0]= FCEU_LuaReadJoypad(0,joy[0]); - joy[2]= *(uint32 *)joyports[0].ptr >> 16; - joy[2]= FCEU_LuaReadJoypad(2,joy[2]); - #else // without this, there seems to be no input at all without Lua - joy[0] = *(uint32 *)joyports[0].ptr;; - joy[2] = *(uint32 *)joyports[0].ptr >> 16; - #endif - } - else - { - #ifdef _S9XLUA_H - joy[1]= *(uint32 *)joyports[1].ptr >> 8; - joy[1]= FCEU_LuaReadJoypad(1,joy[1]); - joy[3]= *(uint32 *)joyports[1].ptr >> 24; - joy[3]= FCEU_LuaReadJoypad(3,joy[3]); - #else // same goes for the other two pads - joy[1] = *(uint32 *)joyports[1].ptr >> 8; - joy[3] = *(uint32 *)joyports[1].ptr >> 24; - #endif - } - -} - -static void LogGP(int w, MovieRecord* mr) -{ - if(w==0) - { - mr->joysticks[0] = joy[0]; - mr->joysticks[2] = joy[2]; - } - else - { - mr->joysticks[1] = joy[1]; - mr->joysticks[3] = joy[3]; - } -} - -static void LoadGP(int w, MovieRecord* mr) -{ - if(w==0) - { - joy[0] = mr->joysticks[0]; - if(FSAttached) joy[2] = mr->joysticks[2]; - } - else - { - joy[1] = mr->joysticks[1]; - if(FSAttached) joy[3] = mr->joysticks[3]; - } -} - - -//basic joystick port driver -static uint8 ReadGP(int w) -{ - uint8 ret; - - if(joy_readbit[w]>=8) - ret = ((joy[2+w]>>(joy_readbit[w]&7))&1); - else - ret = ((joy[w]>>(joy_readbit[w]))&1); - if(joy_readbit[w]>=16) ret=0; - if(!FSAttached) - { - if(joy_readbit[w]>=8) ret|=1; - } - else - { - if(joy_readbit[w]==19-w) ret|=1; - } - if(!fceuindbg) - joy_readbit[w]++; - return ret; -} - -static void StrobeGP(int w) -{ - joy_readbit[w]=0; -} - -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - -static INPUTC GPC={ReadGP,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP}; -static INPUTC GPCVS={ReadGPVS,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP}; - -void FCEU_DrawInput(uint8 *buf) -{ - for(int pad=0;pad<2;pad++) - joyports[pad].driver->Draw(pad,buf,joyports[pad].attrib); - if(portFC.driver) - portFC.driver->Draw(buf,portFC.attrib); -} - - -void FCEU_UpdateInput(void) -{ - //tell all drivers to poll input and set up their logical states - if(!FCEUMOV_Mode(MOVIEMODE_PLAY)) - { - for(int port=0;port<2;port++){ - joyports[port].driver->Update(port,joyports[port].ptr,joyports[port].attrib); - } - portFC.driver->Update(portFC.ptr,portFC.attrib); - } - - if(GameInfo->type==GIT_VSUNI) - if(coinon) coinon--; - - if(FCEUnetplay) - NetplayUpdate(joy); - - FCEUMOV_AddInputState(); - - //TODO - should this apply to the movie data? should this be displayed in the input hud? - if(GameInfo->type==GIT_VSUNI){ - FCEU_VSUniSwap(&joy[0],&joy[1]); - } -} - -static DECLFR(VSUNIRead0) -{ - lagFlag = 0; - uint8 ret=0; - - ret|=(joyports[0].driver->Read(0))&1; - - ret|=(vsdip&3)<<3; - if(coinon) - ret|=0x4; - return ret; -} - -static DECLFR(VSUNIRead1) -{ - lagFlag = 0; - uint8 ret=0; - - ret|=(joyports[1].driver->Read(1))&1; - ret|=vsdip&0xFC; - return ret; -} - - - -//calls from the ppu; -//calls the SLHook for any driver that needs it -void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final) -{ - for(int port=0;port<2;port++) - joyports[port].driver->SLHook(port,bg,spr,linets,final); - portFC.driver->SLHook(bg,spr,linets,final); -} - -#include -//binds JPorts[pad] to the driver specified in JPType[pad] -static void SetInputStuff(int port) -{ - switch(joyports[port].type) - { - case SI_GAMEPAD: - if(GameInfo->type==GIT_VSUNI){ - joyports[port].driver = &GPCVS; - } else { - joyports[port].driver= &GPC; - } - break; - case SI_ARKANOID: - joyports[port].driver=FCEU_InitArkanoid(port); - break; - case SI_ZAPPER: - joyports[port].driver=FCEU_InitZapper(port); - break; - case SI_POWERPADA: - joyports[port].driver=FCEU_InitPowerpadA(port); - break; - case SI_POWERPADB: - joyports[port].driver=FCEU_InitPowerpadB(port); - break; - case SI_NONE: - joyports[port].driver=&DummyJPort; - break; - } -} - -static void SetInputStuffFC() -{ - switch(portFC.type) - { - case SIFC_NONE: - portFC.driver=&DummyPortFC; - break; - case SIFC_ARKANOID: - portFC.driver=FCEU_InitArkanoidFC(); - break; - case SIFC_SHADOW: - portFC.driver=FCEU_InitSpaceShadow(); - break; - case SIFC_OEKAKIDS: - portFC.driver=FCEU_InitOekaKids(); - break; - case SIFC_4PLAYER: - portFC.driver=&FAMI4C; - memset(&F4ReadBit,0,sizeof(F4ReadBit)); - break; - case SIFC_FKB: - portFC.driver=FCEU_InitFKB(); - break; - case SIFC_SUBORKB: - portFC.driver=FCEU_InitSuborKB(); - break; - case SIFC_HYPERSHOT: - portFC.driver=FCEU_InitHS(); - break; - case SIFC_MAHJONG: - portFC.driver=FCEU_InitMahjong(); - break; - case SIFC_QUIZKING: - portFC.driver=FCEU_InitQuizKing(); - break; - case SIFC_FTRAINERA: - portFC.driver=FCEU_InitFamilyTrainerA(); - break; - case SIFC_FTRAINERB: - portFC.driver=FCEU_InitFamilyTrainerB(); - break; - case SIFC_BWORLD: - portFC.driver=FCEU_InitBarcodeWorld(); - break; - case SIFC_TOPRIDER: - portFC.driver=FCEU_InitTopRider(); - break; - } -} - -void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib) -{ - joyports[port].attrib = attrib; - joyports[port].type = type; - joyports[port].ptr = ptr; - SetInputStuff(port); -} - -void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib) -{ - portFC.attrib = attrib; - portFC.type = type; - portFC.ptr = ptr; - SetInputStuffFC(); -} - - -//initializes the input system to power-on state -void InitializeInput(void) -{ - memset(joy_readbit,0,sizeof(joy_readbit)); - memset(joy,0,sizeof(joy)); - LastStrobe = 0; - - if(GameInfo->type==GIT_VSUNI) - { - SetReadHandler(0x4016,0x4016,VSUNIRead0); - SetReadHandler(0x4017,0x4017,VSUNIRead1); - } - else - SetReadHandler(0x4016,0x4017,JPRead); - - SetWriteHandler(0x4016,0x4016,B4016); - - //force the port drivers to be setup - SetInputStuff(0); - SetInputStuff(1); - SetInputStuffFC(); -} - - -bool FCEUI_GetInputFourscore() -{ - return FSAttached; -} -bool FCEUI_GetInputMicrophone() -{ - return replaceP2StartWithMicrophone; -} -void FCEUI_SetInputFourscore(bool attachFourscore) -{ - FSAttached = attachFourscore; -} - -//mbg 6/18/08 HACK -extern ZAPPER ZD[2]; -SFORMAT FCEUCTRL_STATEINFO[]={ - { joy_readbit, 2, "JYRB"}, - { joy, 4, "JOYS"}, - { &LastStrobe, 1, "LSTS"}, - { &ZD[0].bogo, 1, "ZBG0"}, - { &ZD[1].bogo, 1, "ZBG1"}, - { &lagFlag, 1, "LAGF"}, - { &lagCounter, 4, "LAGC"}, - { &currFrameCounter, 4, "FRAM"}, - { 0 } -}; - -void FCEU_DoSimpleCommand(int cmd) -{ - switch(cmd) - { - case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; - case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; - case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; - case FCEUNPCMD_VSUNIDIP0: - case FCEUNPCMD_VSUNIDIP0+1: - case FCEUNPCMD_VSUNIDIP0+2: - case FCEUNPCMD_VSUNIDIP0+3: - case FCEUNPCMD_VSUNIDIP0+4: - case FCEUNPCMD_VSUNIDIP0+5: - case FCEUNPCMD_VSUNIDIP0+6: - case FCEUNPCMD_VSUNIDIP0+7: FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; - case FCEUNPCMD_POWER: PowerNES();break; - case FCEUNPCMD_RESET: ResetNES();break; - } -} - -void FCEU_QSimpleCommand(int cmd) -{ - if(FCEUnetplay) - FCEUNET_SendCommand(cmd, 0); - else - { - if(!FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) // TAS Editor will do the command himself - FCEU_DoSimpleCommand(cmd); - if(FCEUMOV_Mode(MOVIEMODE_RECORD|MOVIEMODE_TASEDITOR)) - FCEUMOV_AddCommand(cmd); - } -} - -void FCEUI_FDSSelect(void) -{ - if(!FCEU_IsValidUI(FCEUI_SWITCH_DISK)) - return; - - FCEU_DispMessage("Command: Switch disk side", 0); - FCEU_QSimpleCommand(FCEUNPCMD_FDSSELECT); -} - -void FCEUI_FDSInsert(void) -{ - if(!FCEU_IsValidUI(FCEUI_EJECT_DISK)) - return; - - FCEU_DispMessage("Command: Insert/Eject disk", 0); - FCEU_QSimpleCommand(FCEUNPCMD_FDSINSERT); -} - -void FCEUI_VSUniToggleDIP(int w) -{ - FCEU_QSimpleCommand(FCEUNPCMD_VSUNIDIP0 + w); -} - -void FCEUI_VSUniCoin(void) -{ - if(!FCEU_IsValidUI(FCEUI_INSERT_COIN)) - return; - - FCEU_QSimpleCommand(FCEUNPCMD_VSUNICOIN); -} - -//Resets the frame counter if movie inactive and rom is reset or power-cycle -void ResetFrameCounter() -{ -extern EMOVIEMODE movieMode; - if(movieMode == MOVIEMODE_INACTIVE) - currFrameCounter = 0; -} - -//Resets the NES -void FCEUI_ResetNES(void) -{ - if(!FCEU_IsValidUI(FCEUI_RESET)) - return; - - FCEU_DispMessage("Command: Soft reset", 0); - FCEU_QSimpleCommand(FCEUNPCMD_RESET); - ResetFrameCounter(); -} - -//Powers off the NES -void FCEUI_PowerNES(void) -{ - if(!FCEU_IsValidUI(FCEUI_POWER)) - return; - - FCEU_DispMessage("Command: Power switch", 0); - FCEU_QSimpleCommand(FCEUNPCMD_POWER); - ResetFrameCounter(); -} - -const char* FCEUI_CommandTypeNames[]= -{ - "Misc.", - "Speed", - "State", - "Movie", - "Sound", - "AVI", - "FDS", - "VS Sys", - "Tools", - "TAS Editor", -}; - -static void CommandUnImpl(void); -static void CommandToggleDip(void); -static void CommandStateLoad(void); -static void CommandStateSave(void); -static void CommandSelectSaveSlot(void); -static void CommandEmulationSpeed(void); -static void CommandSoundAdjust(void); -static void CommandUsePreset(void); -static void BackgroundDisplayToggle(void); -static void ObjectDisplayToggle(void); -static void ViewSlots(void); -static void LaunchTasEditor(void); -static void LaunchMemoryWatch(void); -static void LaunchCheats(void); -static void LaunchDebugger(void); -static void LaunchPPU(void); -static void LaunchNTView(void); -static void LaunchHex(void); -static void LaunchTraceLogger(void); -static void LaunchCodeDataLogger(void); -static void LaunchRamWatch(void); -static void LaunchRamSearch(void); -static void RamSearchOpLT(void); -static void RamSearchOpGT(void); -static void RamSearchOpLTE(void); -static void RamSearchOpGTE(void); -static void RamSearchOpEQ(void); -static void RamSearchOpNE(void); -static void FA_SkipLag(void); -static void OpenRom(void); -static void CloseRom(void); -static void ReloadRom(void); -static void MovieSubtitleToggle(void); -static void UndoRedoSavestate(void); -static void FCEUI_DoExit(void); -void ToggleFullscreen(); -static void TaseditorRewindOn(void); -static void TaseditorRewindOff(void); -static void TaseditorCommand(void); -extern void FCEUI_ToggleShowFPS(); - -struct EMUCMDTABLE FCEUI_CommandTable[]= -{ - { EMUCMD_POWER, EMUCMDTYPE_MISC, FCEUI_PowerNES, 0, 0, "Power", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_RESET, EMUCMDTYPE_MISC, FCEUI_ResetNES, 0, 0, "Reset", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_PAUSE, EMUCMDTYPE_MISC, FCEUI_ToggleEmulationPause, 0, 0, "Pause", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_FRAME_ADVANCE, EMUCMDTYPE_MISC, FCEUI_FrameAdvance, FCEUI_FrameAdvanceEnd, 0, "Frame Advance", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SCREENSHOT, EMUCMDTYPE_MISC, FCEUI_SaveSnapshot, 0, 0, "Screenshot", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", 0 }, - { EMUCMD_EXIT, EMUCMDTYPE_MISC, FCEUI_DoExit, 0, 0, "Exit", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_SLOWEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Slowest Speed", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_SLOWER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Down", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_NORMAL, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Normal Speed", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_FASTER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Up", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_FASTEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Fastest Speed", 0 }, - { EMUCMD_SPEED_TURBO, EMUCMDTYPE_SPEED, FCEUD_TurboOn, FCEUD_TurboOff, 0, "Turbo", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SPEED_TURBO_TOGGLE, EMUCMDTYPE_SPEED, FCEUD_TurboToggle, 0, 0, "Turbo Toggle", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_SAVE_SLOT_0, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 0", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_1, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 1", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_2, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 2", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_3, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 3", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_4, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 4", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_5, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 5", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_6, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 6", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_7, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 7", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_8, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 8", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_9, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 9", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_NEXT, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Next Savestate Slot", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_SLOT_PREV, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Previous Savestate Slot", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_AS, EMUCMDTYPE_STATE, FCEUD_SaveStateAs, 0, 0, "Save State As...", 0 }, - { EMUCMD_SAVE_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 0", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 1", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 2", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 3", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 4", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 5", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 6", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 7", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 8", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SAVE_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 9", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_FROM, EMUCMDTYPE_STATE, FCEUD_LoadStateFrom, 0, 0, "Load State From...", 0 }, - { EMUCMD_LOAD_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 0", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 1", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 2", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 3", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 4", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 5", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 6", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 7", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 8", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_LOAD_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 9", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_MOVIE_RECORD_TO, EMUCMDTYPE_MOVIE, FCEUD_MovieRecordTo, 0, 0, "Record Movie To...", 0 }, - { EMUCMD_MOVIE_REPLAY_FROM, EMUCMDTYPE_MOVIE, FCEUD_MovieReplayFrom, 0, 0, "Play Movie From...", 0 }, - { EMUCMD_MOVIE_PLAY_FROM_BEGINNING, EMUCMDTYPE_MOVIE, FCEUI_MoviePlayFromBeginning, 0, 0, "Play Movie From Beginning", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MOVIE_STOP, EMUCMDTYPE_MOVIE, FCEUI_StopMovie, 0, 0, "Stop Movie", 0 }, - { EMUCMD_MOVIE_READONLY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleReadOnly, 0, 0, "Toggle Read-Only", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleFrameDisplay, 0, 0, "Toggle Frame Display", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", EMUCMDFLAG_TASEDITOR }, - - #ifdef _S9XLUA_H - { EMUCMD_SCRIPT_RELOAD, EMUCMDTYPE_MISC, FCEU_ReloadLuaCode, 0, 0, "Reload current Lua script", EMUCMDFLAG_TASEDITOR }, - #endif - - { EMUCMD_SOUND_TOGGLE, EMUCMDTYPE_SOUND, FCEUD_SoundToggle, 0, 0, "Sound Mute Toggle", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SOUND_VOLUME_DOWN, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Down", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_SOUND_VOLUME_NORMAL, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Normal", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_AVI_RECORD_AS, EMUCMDTYPE_AVI, FCEUD_AviRecordTo, 0, 0, "Record AVI As...", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_AVI_STOP, EMUCMDTYPE_AVI, FCEUD_AviStop, 0, 0, "Stop AVI", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_FDS_EJECT_INSERT, EMUCMDTYPE_FDS, FCEUI_FDSInsert, 0, 0, "Eject or Insert FDS Disk", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_FDS_SIDE_SELECT, EMUCMDTYPE_FDS, FCEUI_FDSSelect, 0, 0, "Switch FDS Disk Side", EMUCMDFLAG_TASEDITOR }, - - { EMUCMD_VSUNI_COIN, EMUCMDTYPE_VSUNI, FCEUI_VSUniCoin, 0, 0, "Insert Coin", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_VSUNI_TOGGLE_DIP_0, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 0", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_1, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 1", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_2, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 2", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_3, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 3", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_4, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 4", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_5, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 5", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_6, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 6", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_7, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 7", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_8, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 8", 0 }, - { EMUCMD_VSUNI_TOGGLE_DIP_9, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 9", 0 }, - { EMUCMD_MISC_AUTOSAVE, EMUCMDTYPE_MISC, FCEUI_RewindToLastAutosave, 0, 0, "Load Last Auto-save", 0}, - { EMUCMD_MISC_SHOWSTATES, EMUCMDTYPE_MISC, ViewSlots, 0, 0, "View save slots", 0 }, - { EMUCMD_MISC_USE_INPUT_PRESET_1, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 1", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_USE_INPUT_PRESET_2, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 2", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_USE_INPUT_PRESET_3, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 3", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_DISPLAY_BG_TOGGLE, EMUCMDTYPE_MISC, BackgroundDisplayToggle, 0, 0, "Toggle Background Display", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_DISPLAY_OBJ_TOGGLE, EMUCMDTYPE_MISC, ObjectDisplayToggle, 0, 0, "Toggle Object Display", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE,EMUCMDTYPE_MISC, LagCounterToggle, 0, 0, "Lag Counter Toggle", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_OPENTASEDITOR, EMUCMDTYPE_TOOL, LaunchTasEditor, 0, 0, "Open TAS Editor", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENMEMORYWATCH, EMUCMDTYPE_TOOL, LaunchMemoryWatch,0, 0, "Open Memory Watch", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENCHEATS, EMUCMDTYPE_TOOL, LaunchCheats, 0, 0, "Open Cheats", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENDEBUGGER, EMUCMDTYPE_TOOL, LaunchDebugger, 0, 0, "Open Debugger", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENHEX, EMUCMDTYPE_TOOL, LaunchHex, 0, 0, "Open Hex Editor", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENPPU, EMUCMDTYPE_TOOL, LaunchPPU, 0, 0, "Open PPU Viewer", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENNTVIEW, EMUCMDTYPE_TOOL, LaunchNTView, 0, 0, "Open Name Table Viewer", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENTRACELOGGER, EMUCMDTYPE_TOOL, LaunchTraceLogger, 0, 0, "Open Trace Logger", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENCDLOGGER, EMUCMDTYPE_TOOL, LaunchCodeDataLogger, 0, 0, "Open Code/Data Logger", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_FRAMEADV_SKIPLAG, EMUCMDTYPE_MISC, FA_SkipLag, 0, 0, "Frame Adv.-Skip Lag", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_OPENROM, EMUCMDTYPE_TOOL, OpenRom, 0, 0, "Open ROM", 0}, - { EMUCMD_CLOSEROM, EMUCMDTYPE_TOOL, CloseRom, 0, 0, "Close ROM", 0}, - { EMUCMD_RELOAD, EMUCMDTYPE_TOOL, ReloadRom, 0, 0, "Reload ROM or TAS Editor Project", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_DISPLAY_MOVIESUBTITLES, EMUCMDTYPE_MISC, MovieSubtitleToggle,0,0,"Toggle Movie Subtitles", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_MISC_UNDOREDOSAVESTATE, EMUCMDTYPE_MISC, UndoRedoSavestate, 0,0,"Undo/Redo Savestate", 0}, - { EMUCMD_MISC_TOGGLEFULLSCREEN, EMUCMDTYPE_MISC, ToggleFullscreen, 0, 0, "Toggle Fullscreen", 0}, - { EMUCMD_TOOL_OPENRAMWATCH, EMUCMDTYPE_TOOL, LaunchRamWatch, 0, 0, "Open Ram Watch", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_OPENRAMSEARCH, EMUCMDTYPE_TOOL, LaunchRamSearch, 0, 0, "Open Ram Search", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TOOL_RAMSEARCHLT, EMUCMDTYPE_TOOL, RamSearchOpLT, 0, 0, "Ram Search - Less Than", 0}, - { EMUCMD_TOOL_RAMSEARCHGT, EMUCMDTYPE_TOOL, RamSearchOpGT, 0, 0, "Ram Search - Greater Than", 0}, - { EMUCMD_TOOL_RAMSEARCHLTE, EMUCMDTYPE_TOOL, RamSearchOpLTE, 0, 0, "Ram Search - Less Than or Equal", 0}, - { EMUCMD_TOOL_RAMSEARCHGTE, EMUCMDTYPE_TOOL, RamSearchOpGTE, 0, 0, "Ram Search - Greater Than or Equal", 0}, - { EMUCMD_TOOL_RAMSEARCHEQ, EMUCMDTYPE_TOOL, RamSearchOpEQ, 0, 0, "Ram Search - Equal", 0}, - { EMUCMD_TOOL_RAMSEARCHNE, EMUCMDTYPE_TOOL, RamSearchOpNE, 0, 0, "Ram Search - Not Equal", 0}, - { EMUCMD_RERECORD_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_MovieToggleRerecordDisplay, 0, 0, "Toggle Rerecord Display", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_REWIND, EMUCMDTYPE_TASEDITOR, TaseditorRewindOn, TaseditorRewindOff, 0, "Frame Rewind", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_RESTORE_PLAYBACK, EMUCMDTYPE_TASEDITOR, TaseditorCommand, 0, 0, "Restore Playback", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_CANCEL_SEEKING, EMUCMDTYPE_TASEDITOR, TaseditorCommand, 0, 0, "Cancel Seeking", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_SWITCH_AUTORESTORING, EMUCMDTYPE_TASEDITOR, TaseditorCommand, 0, 0, "Switch Auto-restore last position", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_SWITCH_MULTITRACKING, EMUCMDTYPE_TASEDITOR, TaseditorCommand, 0, 0, "Switch current Multitracking mode", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_TASEDITOR_RUN_MANUAL_LUA, EMUCMDTYPE_TASEDITOR, TaseditorCommand, 0, 0, "Run Manual Lua function", EMUCMDFLAG_TASEDITOR }, - { EMUCMD_FPS_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleShowFPS, 0, 0, "Toggle FPS Display", EMUCMDFLAG_TASEDITOR }, -}; - -#define NUM_EMU_CMDS (sizeof(FCEUI_CommandTable)/sizeof(FCEUI_CommandTable[0])) - -static int execcmd, i; - -void FCEUI_HandleEmuCommands(TestCommandState* testfn) -{ - bool taseditor = FCEUMOV_Mode(MOVIEMODE_TASEDITOR); - for(i=0; itype==GIT_VSUNI) - FCEUI_VSUniToggleDIP(execcmd-EMUCMD_VSUNI_TOGGLE_DIP_0); -} - -static void CommandEmulationSpeed(void) -{ - FCEUD_SetEmulationSpeed(EMUSPEED_SLOWEST+(execcmd-EMUCMD_SPEED_SLOWEST)); -} - -void FCEUI_SelectStateNext(int); - -static void ViewSlots(void) -{ - FCEUI_SelectState(CurrentState, 1); -} - -static void CommandSelectSaveSlot(void) -{ - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { -#ifdef WIN32 - handleEmuCmdByTaseditor(execcmd); -#endif - } else - { - if(execcmd <= EMUCMD_SAVE_SLOT_9) - FCEUI_SelectState(execcmd - EMUCMD_SAVE_SLOT_0, 1); - else if(execcmd == EMUCMD_SAVE_SLOT_NEXT) - FCEUI_SelectStateNext(1); - else if(execcmd == EMUCMD_SAVE_SLOT_PREV) - FCEUI_SelectStateNext(-1); - } -} - -static void CommandStateSave(void) -{ - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { -#ifdef WIN32 - handleEmuCmdByTaseditor(execcmd); -#endif - } else - { - // FCEU_PrintError("execcmd=%d, EMUCMD_SAVE_STATE_SLOT_0=%d, EMUCMD_SAVE_STATE_SLOT_9=%d", execcmd,EMUCMD_SAVE_STATE_SLOT_0,EMUCMD_SAVE_STATE_SLOT_9); - if(execcmd >= EMUCMD_SAVE_STATE_SLOT_0 && execcmd <= EMUCMD_SAVE_STATE_SLOT_9) - { - int oldslot=FCEUI_SelectState(execcmd-EMUCMD_SAVE_STATE_SLOT_0, 0); - FCEUI_SaveState(0); - FCEUI_SelectState(oldslot, 0); - } - else - FCEUI_SaveState(0); - } -} - -static void CommandStateLoad(void) -{ - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { -#ifdef WIN32 - handleEmuCmdByTaseditor(execcmd); -#endif - } else - { - if(execcmd >= EMUCMD_LOAD_STATE_SLOT_0 && execcmd <= EMUCMD_LOAD_STATE_SLOT_9) - { - int oldslot=FCEUI_SelectState(execcmd-EMUCMD_LOAD_STATE_SLOT_0, 0); - FCEUI_LoadState(0); - FCEUI_SelectState(oldslot, 0); - } - else - FCEUI_LoadState(0); - } -} - -static void CommandSoundAdjust(void) -{ - int n=0; - switch(execcmd) - { - case EMUCMD_SOUND_VOLUME_UP: n=1; break; - case EMUCMD_SOUND_VOLUME_DOWN: n=-1; break; - case EMUCMD_SOUND_VOLUME_NORMAL: n=0; break; - } - - FCEUD_SoundVolumeAdjust(n); -} - - -static void CommandUsePreset(void) -{ - FCEUI_UseInputPreset(execcmd-EMUCMD_MISC_USE_INPUT_PRESET_1); -} - -static void BackgroundDisplayToggle(void) -{ - bool spr, bg; - FCEUI_GetRenderPlanes(spr,bg); - bg = !bg; - FCEUI_SetRenderPlanes(spr,bg); -} - -static void ObjectDisplayToggle(void) -{ - bool spr, bg; - FCEUI_GetRenderPlanes(spr,bg); - spr = !spr; - FCEUI_SetRenderPlanes(spr,bg); -} - -void LagCounterReset() -{ - lagCounter = 0; -} - -void LagCounterToggle(void) -{ - lagCounterDisplay ^= 1; -} - -static void LaunchTasEditor(void) -{ -#ifdef WIN32 - extern bool enterTASEditor(); - enterTASEditor(); -#endif -} - -static void LaunchMemoryWatch(void) -{ -#ifdef WIN32 - CreateMemWatch(); -#endif -} - -static void LaunchDebugger(void) -{ -#ifdef WIN32 - DoDebug(0); -#endif -} - -static void LaunchNTView(void) -{ -#ifdef WIN32 - DoNTView(); -#endif -} - -static void LaunchPPU(void) -{ -#ifdef WIN32 - DoPPUView(); -#endif -} - -static void LaunchHex(void) -{ -#ifdef WIN32 - DoMemView(); -#endif -} - -static void LaunchTraceLogger(void) -{ -#ifdef WIN32 - DoTracer(); -#endif -} - -static void LaunchCodeDataLogger(void) -{ -#ifdef WIN32 - DoCDLogger(); -#endif -} - -static void LaunchCheats(void) -{ -#ifdef WIN32 - extern HWND pwindow; - ConfigCheats(pwindow); -#endif -} - -static void LaunchRamWatch(void) -{ -#ifdef WIN32 - extern void OpenRamWatch(); //adelikat: Blah blah hacky, I know - OpenRamWatch(); -#endif -} - -static void LaunchRamSearch(void) -{ -#ifdef WIN32 - extern void OpenRamSearch(); - OpenRamSearch(); -#endif -} - -static void RamSearchOpLT(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(0); - DoRamSearchOperation(); - } -#endif -} - -static void RamSearchOpGT(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(1); - DoRamSearchOperation(); - } -#endif -} - -static void RamSearchOpLTE(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(2); - DoRamSearchOperation(); - } -#endif -} - -static void RamSearchOpGTE(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(3); - DoRamSearchOperation(); - } -#endif -} - -static void RamSearchOpEQ(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(4); - DoRamSearchOperation(); - } -#endif -} - -static void RamSearchOpNE(void) { -#ifdef WIN32 - if (GameInfo) - { - extern void SetSearchType(int SearchType); - extern void DoRamSearchOperation(); - SetSearchType(5); - DoRamSearchOperation(); - } -#endif -} - -static void FA_SkipLag(void) -{ - frameAdvanceLagSkip ^= 1; -} - -static void OpenRom(void) -{ -#ifdef WIN32 - extern HWND hAppWnd; - LoadNewGamey(hAppWnd, 0); -#endif -} - -static void CloseRom(void) -{ -#ifdef WIN32 - CloseGame(); -#endif -} - -static void ReloadRom(void) -{ -#ifdef WIN32 - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { - // load most recent project - handleEmuCmdByTaseditor(execcmd); - } else - { - // load most recent ROM - extern void LoadRecentRom(int slot); - LoadRecentRom(0); - } -#endif -} - -static void MovieSubtitleToggle(void) -{ - movieSubtitles ^= 1; - if (movieSubtitles) FCEU_DispMessage("Movie subtitles on",0); - else FCEU_DispMessage("Movie subtitles off",0); -} - -static void UndoRedoSavestate(void) -{ - // FIXME this will always evaluate to true, should this be - // if (*lastSavestateMade...) to check if it holds a string or just - // a '\0'? - if (lastSavestateMade && (undoSS || redoSS)) - SwapSaveState(); -} - -static void FCEUI_DoExit(void) -{ -#ifdef WIN32 - DoFCEUExit(); -#endif -} - -void ToggleFullscreen() -{ -#ifdef WIN32 - extern int SetVideoMode(int fs); //adelikat: Yeah, I know, hacky - extern void UpdateCheckedMenuItems(); - - UpdateCheckedMenuItems(); - changerecursive=1; - - int oldmode = fullscreen; - if(!SetVideoMode(oldmode ^ 1)) - SetVideoMode(oldmode); - changerecursive=0; -#endif -} - -static void TaseditorRewindOn(void) -{ -#ifdef WIN32 - mustRewindNow = true; -#endif -} -static void TaseditorRewindOff(void) -{ -#ifdef WIN32 - mustRewindNow = false; -#endif -} - -static void TaseditorCommand(void) -{ -#ifdef WIN32 - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - handleEmuCmdByTaseditor(execcmd); -#endif -} diff --git a/branches/fceux-2.2.2/src/input.h b/branches/fceux-2.2.2/src/input.h deleted file mode 100644 index 3c895099..00000000 --- a/branches/fceux-2.2.2/src/input.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef _INPUT_H_ -#define _INPUT_H_ - - -#include "git.h" - -#include - -void LagCounterToggle(void); - -class MovieRecord; - -//MBG TODO - COMBINE THESE INPUTC AND INPUTCFC - -//The interface for standard joystick port device drivers -struct INPUTC -{ - //these methods call the function pointers (or not, if they are null) - uint8 Read(int w) { if(_Read) return _Read(w); else return 0; } - void Write(uint8 w) { if(_Write) _Write(w); } - void Strobe(int w) { if(_Strobe) _Strobe(w); } - void Update(int w, void *data, int arg) { if(_Update) _Update(w,data,arg); } - void SLHook(int w, uint8 *bg, uint8 *spr, uint32 linets, int final) { if(_SLHook) _SLHook(w,bg,spr,linets,final); } - void Draw(int w, uint8 *buf, int arg) { if(_Draw) _Draw(w,buf,arg); } - void Log(int w, MovieRecord* mr) { if(_Log) _Log(w,mr); } - void Load(int w, MovieRecord* mr) { if(_Load) _Load(w,mr); } - - uint8 (*_Read)(int w); - void (*_Write)(uint8 v); - void (*_Strobe)(int w); - //update will be called if input is coming from the user. refresh your logical state from user input devices - void (*_Update)(int w, void *data, int arg); - void (*_SLHook)(int w, uint8 *bg, uint8 *spr, uint32 linets, int final); - void (*_Draw)(int w, uint8 *buf, int arg); - - //log is called when you need to put your logical state into a movie record for recording - void (*_Log)(int w, MovieRecord* mr); - //load will be called if input is coming from a movie. refresh your logical state from a movie record - void (*_Load)(int w, MovieRecord* mr); -}; - -//The interface for the expansion port device drivers -struct INPUTCFC -{ - //these methods call the function pointers (or not, if they are null) - uint8 Read(int w, uint8 ret) { if(_Read) return _Read(w,ret); else return ret; } - void Write(uint8 v) { if(_Write) _Write(v); } - void Strobe() { if(_Strobe) _Strobe(); } - void Update(void *data, int arg) { if(_Update) _Update(data,arg); } - void SLHook(uint8 *bg, uint8 *spr, uint32 linets, int final) { if(_SLHook) _SLHook(bg,spr,linets,final); } - void Draw(uint8 *buf, int arg) { if(_Draw) _Draw(buf,arg); } - void Log(MovieRecord* mr) { if(_Log) _Log(mr); } - void Load(MovieRecord* mr) { if(_Load) _Load(mr); } - - uint8 (*_Read)(int w, uint8 ret); - void (*_Write)(uint8 v); - void (*_Strobe)(); - //update will be called if input is coming from the user. refresh your logical state from user input devices - void (*_Update)(void *data, int arg); - void (*_SLHook)(uint8 *bg, uint8 *spr, uint32 linets, int final); - void (*_Draw)(uint8 *buf, int arg); - - //log is called when you need to put your logical state into a movie record for recording - void (*_Log)(MovieRecord* mr); - - //load will be called if input is coming from a movie. refresh your logical state from a movie record - void (*_Load)(MovieRecord* mr); -}; - -extern struct JOYPORT -{ - JOYPORT(int _w) - : w(_w) - {} - - int w; - int attrib; - ESI type; - void* ptr; - INPUTC* driver; - - void log(MovieRecord* mr) { driver->Log(w,mr); } - void load(MovieRecord* mr) { driver->Load(w,mr); } -} joyports[2]; - -extern struct FCPORT -{ - int attrib; - ESIFC type; - void* ptr; - INPUTCFC* driver; -} portFC; - - -void FCEU_DrawInput(uint8 *buf); -void FCEU_UpdateInput(void); -void InitializeInput(void); -void FCEU_UpdateBot(void); -extern void (*PStrobe[2])(void); - -//called from PPU on scanline events. -extern void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final); - -void FCEU_DoSimpleCommand(int cmd); - -enum EMUCMD -{ - EMUCMD_POWER=0, - EMUCMD_RESET, - EMUCMD_PAUSE, - EMUCMD_FRAME_ADVANCE, - EMUCMD_SCREENSHOT, - EMUCMD_HIDE_MENU_TOGGLE, - //fixed: current command key handling handle only command table record index with - //the same as cmd enumerarot index, or else does wrong key mapping, fixed it but placed this enum here anyway - //...i returned it back. - //adelikat, try to find true cause of problem before reversing it - EMUCMD_EXIT, - - EMUCMD_SPEED_SLOWEST, - EMUCMD_SPEED_SLOWER, - EMUCMD_SPEED_NORMAL, - EMUCMD_SPEED_FASTER, - EMUCMD_SPEED_FASTEST, - EMUCMD_SPEED_TURBO, - EMUCMD_SPEED_TURBO_TOGGLE, - - EMUCMD_SAVE_SLOT_0, - EMUCMD_SAVE_SLOT_1, - EMUCMD_SAVE_SLOT_2, - EMUCMD_SAVE_SLOT_3, - EMUCMD_SAVE_SLOT_4, - EMUCMD_SAVE_SLOT_5, - EMUCMD_SAVE_SLOT_6, - EMUCMD_SAVE_SLOT_7, - EMUCMD_SAVE_SLOT_8, - EMUCMD_SAVE_SLOT_9, - EMUCMD_SAVE_SLOT_NEXT, - EMUCMD_SAVE_SLOT_PREV, - EMUCMD_SAVE_STATE, - EMUCMD_SAVE_STATE_AS, - EMUCMD_SAVE_STATE_SLOT_0, - EMUCMD_SAVE_STATE_SLOT_1, - EMUCMD_SAVE_STATE_SLOT_2, - EMUCMD_SAVE_STATE_SLOT_3, - EMUCMD_SAVE_STATE_SLOT_4, - EMUCMD_SAVE_STATE_SLOT_5, - EMUCMD_SAVE_STATE_SLOT_6, - EMUCMD_SAVE_STATE_SLOT_7, - EMUCMD_SAVE_STATE_SLOT_8, - EMUCMD_SAVE_STATE_SLOT_9, - EMUCMD_LOAD_STATE, - EMUCMD_LOAD_STATE_FROM, - EMUCMD_LOAD_STATE_SLOT_0, - EMUCMD_LOAD_STATE_SLOT_1, - EMUCMD_LOAD_STATE_SLOT_2, - EMUCMD_LOAD_STATE_SLOT_3, - EMUCMD_LOAD_STATE_SLOT_4, - EMUCMD_LOAD_STATE_SLOT_5, - EMUCMD_LOAD_STATE_SLOT_6, - EMUCMD_LOAD_STATE_SLOT_7, - EMUCMD_LOAD_STATE_SLOT_8, - EMUCMD_LOAD_STATE_SLOT_9, - - EMUCMD_MOVIE_RECORD_TO, - EMUCMD_MOVIE_REPLAY_FROM, - EMUCMD_MOVIE_PLAY_FROM_BEGINNING, - EMUCMD_MOVIE_STOP, - EMUCMD_MOVIE_READONLY_TOGGLE, - EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, - EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, - EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, - - EMUCMD_SCRIPT_RELOAD, - - EMUCMD_SOUND_TOGGLE, - EMUCMD_SOUND_VOLUME_UP, - EMUCMD_SOUND_VOLUME_DOWN, - EMUCMD_SOUND_VOLUME_NORMAL, - - EMUCMD_AVI_RECORD_AS, - EMUCMD_AVI_STOP, - - EMUCMD_FDS_EJECT_INSERT, - EMUCMD_FDS_SIDE_SELECT, - - EMUCMD_VSUNI_COIN, - EMUCMD_VSUNI_TOGGLE_DIP_0, - EMUCMD_VSUNI_TOGGLE_DIP_1, - EMUCMD_VSUNI_TOGGLE_DIP_2, - EMUCMD_VSUNI_TOGGLE_DIP_3, - EMUCMD_VSUNI_TOGGLE_DIP_4, - EMUCMD_VSUNI_TOGGLE_DIP_5, - EMUCMD_VSUNI_TOGGLE_DIP_6, - EMUCMD_VSUNI_TOGGLE_DIP_7, - EMUCMD_VSUNI_TOGGLE_DIP_8, - EMUCMD_VSUNI_TOGGLE_DIP_9, - EMUCMD_MISC_AUTOSAVE, - EMUCMD_MISC_SHOWSTATES, - EMUCMD_MISC_USE_INPUT_PRESET_1, - EMUCMD_MISC_USE_INPUT_PRESET_2, - EMUCMD_MISC_USE_INPUT_PRESET_3, - EMUCMD_MISC_DISPLAY_BG_TOGGLE, - EMUCMD_MISC_DISPLAY_OBJ_TOGGLE, - EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE, - - //Currently Windows only------ - EMUCMD_MISC_OPENTASEDITOR, - EMUCMD_TOOL_OPENMEMORYWATCH, - EMUCMD_TOOL_OPENCHEATS, - EMUCMD_TOOL_OPENDEBUGGER, - EMUCMD_TOOL_OPENHEX, - EMUCMD_TOOL_OPENPPU, - EMUCMD_TOOL_OPENTRACELOGGER, - EMUCMD_TOOL_OPENCDLOGGER, - //---------------------------- - EMUCMD_FRAMEADV_SKIPLAG, - //Currently only windows (but sdl could easily add onto these) - EMUCMD_OPENROM, - EMUCMD_CLOSEROM, - EMUCMD_RELOAD, - //----------------------------- - EMUCMD_MISC_DISPLAY_MOVIESUBTITLES, - EMUCMD_MISC_UNDOREDOSAVESTATE, - EMUCMD_MISC_TOGGLEFULLSCREEN, - EMUCMD_TOOL_OPENRAMWATCH, - EMUCMD_TOOL_OPENRAMSEARCH, - EMUCMD_TOOL_RAMSEARCHLT, - EMUCMD_TOOL_RAMSEARCHGT, - EMUCMD_TOOL_RAMSEARCHLTE, - EMUCMD_TOOL_RAMSEARCHGTE, - EMUCMD_TOOL_RAMSEARCHEQ, - EMUCMD_TOOL_RAMSEARCHNE, - EMUCMD_TOOL_OPENNTVIEW, - EMUCMD_TASEDITOR_REWIND, - EMUCMD_RERECORD_DISPLAY_TOGGLE, - EMUCMD_TASEDITOR_RESTORE_PLAYBACK, - EMUCMD_TASEDITOR_CANCEL_SEEKING, - EMUCMD_TASEDITOR_SWITCH_AUTORESTORING, - EMUCMD_TASEDITOR_SWITCH_MULTITRACKING, - EMUCMD_TASEDITOR_RUN_MANUAL_LUA, - //----------------------------- - //keep adding these in order of newness or else the hotkey binding configs will get messed up... - EMUCMD_FPS_DISPLAY_TOGGLE, - - EMUCMD_MAX -}; - -enum EMUCMDTYPE -{ - EMUCMDTYPE_MISC=0, - EMUCMDTYPE_SPEED, - EMUCMDTYPE_STATE, - EMUCMDTYPE_MOVIE, - EMUCMDTYPE_SOUND, - EMUCMDTYPE_AVI, - EMUCMDTYPE_FDS, - EMUCMDTYPE_VSUNI, - EMUCMDTYPE_TOOL, //All Tools type are currenty windows only programs - EMUCMDTYPE_TASEDITOR, // Windows-only as well - - EMUCMDTYPE_MAX -}; - -extern const char* FCEUI_CommandTypeNames[]; - -typedef void EMUCMDFN(void); - -enum EMUCMDFLAG -{ - EMUCMDFLAG_NONE = 0, - EMUCMDFLAG_TASEDITOR = 1, -}; - -struct EMUCMDTABLE -{ - int cmd; - int type; - EMUCMDFN* fn_on; - EMUCMDFN* fn_off; - int state; - char* name; - int flags; //EMUCMDFLAG -}; - -extern struct EMUCMDTABLE FCEUI_CommandTable[]; - -extern unsigned int lagCounter; -extern bool lagCounterDisplay; -extern char lagFlag; -extern bool turbo; -void LagCounterReset(); - -#endif //_INPUT_H_ diff --git a/branches/fceux-2.2.2/src/input/fkb.cpp b/branches/fceux-2.2.2/src/input/fkb.cpp deleted file mode 100644 index 0cb7f118..00000000 --- a/branches/fceux-2.2.2/src/input/fkb.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "share.h" -#include "fkb.h" -#define AK2(x,y) ( (FKB_##x) | (FKB_##y <<8) ) -#define AK(x) FKB_##x - -static uint8 bufit[0x49]; -static uint8 ksmode; -static uint8 ksindex; - - -static uint16 matrix[9][2][4]= -{ -{{AK(F8),AK(RETURN),AK(BRACKETLEFT),AK(BRACKETRIGHT)}, - {AK(KANA),AK(RIGHTSHIFT),AK(BACKSLASH),AK(STOP)}}, -{{AK(F7),AK(AT),AK(COLON),AK(SEMICOLON)}, - {AK(UNDERSCORE),AK(SLASH),AK(MINUS),AK(CARET)}}, -{{AK(F6),AK(O),AK(L),AK(K)}, - {AK(PERIOD),AK(COMMA),AK(P),AK(0)}}, -{{AK(F5),AK(I),AK(U),AK(J)}, - {AK(M),AK(N),AK(9),AK(8)}}, -{{AK(F4),AK(Y),AK(G),AK(H)}, - {AK(B),AK(V),AK(7),AK(6)}}, -{{AK(F3),AK(T),AK(R),AK(D)}, - {AK(F),AK(C),AK(5),AK(4)}}, -{{AK(F2),AK(W),AK(S),AK(A)}, - {AK(X),AK(Z),AK(E),AK(3)}}, -{{AK(F1),AK(ESCAPE),AK(Q),AK(CONTROL)}, - {AK(LEFTSHIFT),AK(GRAPH),AK(1),AK(2)}}, -{{AK(CLEAR),AK(UP),AK(RIGHT),AK(LEFT)}, - {AK(DOWN),AK(SPACE),AK(DELETE),AK(INSERT)}}, -}; - -static void FKB_Write(uint8 v) -{ - v>>=1; - if(v&2) - { - if((ksmode&1) && !(v&1)) - ksindex=(ksindex+1)%9; - } - ksmode=v; -} - -static uint8 FKB_Read(int w, uint8 ret) -{ - //printf("$%04x, %d, %d\n",w+0x4016,ksindex,ksmode&1); - if(w) - { - int x; - - ret&=~0x1E; - for(x=0;x<4;x++) - if(bufit[ matrix[ksindex][ksmode&1][x]&0xFF ] || bufit[ matrix[ksindex][ksmode&1][x]>>8]) - { - ret|=1<<(x+1); - } - ret^=0x1E; - } - return(ret); -} - -static void FKB_Strobe(void) -{ - ksmode=0; - ksindex=0; - //printf("strobe\n"); -} - -static void FKB_Update(void *data, int arg) -{ - memcpy(bufit+1,data,0x48); -} - -static INPUTCFC FKB={FKB_Read,FKB_Write,FKB_Strobe,FKB_Update,0,0}; - -INPUTCFC *FCEU_InitFKB(void) -{ - memset(bufit,0,sizeof(bufit)); - ksmode=ksindex=0; - return(&FKB); -} diff --git a/branches/fceux-2.2.2/src/input/fkb.h b/branches/fceux-2.2.2/src/input/fkb.h deleted file mode 100644 index b5dcadd4..00000000 --- a/branches/fceux-2.2.2/src/input/fkb.h +++ /dev/null @@ -1,72 +0,0 @@ -#define FKB_F1 0x01 -#define FKB_F2 0x02 -#define FKB_F3 0x03 -#define FKB_F4 0x04 -#define FKB_F5 0x05 -#define FKB_F6 0x06 -#define FKB_F7 0x07 -#define FKB_F8 0x08 -#define FKB_1 0x09 -#define FKB_2 0x0A -#define FKB_3 0x0B -#define FKB_4 0x0C -#define FKB_5 0x0D -#define FKB_6 0x0E -#define FKB_7 0x0F -#define FKB_8 0x10 -#define FKB_9 0x11 -#define FKB_0 0x12 -#define FKB_MINUS 0x13 -#define FKB_CARET 0x14 -#define FKB_BACKSLASH 0x15 -#define FKB_STOP 0x16 -#define FKB_ESCAPE 0x17 -#define FKB_Q 0x18 -#define FKB_W 0x19 -#define FKB_E 0x1A -#define FKB_R 0x1B -#define FKB_T 0x1C -#define FKB_Y 0x1D -#define FKB_U 0x1E -#define FKB_I 0x1F -#define FKB_O 0x20 -#define FKB_P 0x21 -#define FKB_AT 0x22 -#define FKB_BRACKETLEFT 0x23 -#define FKB_RETURN 0x24 -#define FKB_CONTROL 0x25 -#define FKB_A 0x26 -#define FKB_S 0x27 -#define FKB_D 0x28 -#define FKB_F 0x29 -#define FKB_G 0x2A -#define FKB_H 0x2B -#define FKB_J 0x2C -#define FKB_K 0x2D -#define FKB_L 0x2E -#define FKB_SEMICOLON 0x2F -#define FKB_COLON 0x30 -#define FKB_BRACKETRIGHT 0x31 -#define FKB_KANA 0x32 -#define FKB_LEFTSHIFT 0x33 -#define FKB_Z 0x34 -#define FKB_X 0x35 -#define FKB_C 0x36 -#define FKB_V 0x37 -#define FKB_B 0x38 -#define FKB_N 0x39 -#define FKB_M 0x3A -#define FKB_COMMA 0x3B -#define FKB_PERIOD 0x3C -#define FKB_SLASH 0x3D -#define FKB_UNDERSCORE 0x3E -#define FKB_RIGHTSHIFT 0x3F -#define FKB_GRAPH 0x40 -#define FKB_SPACE 0x41 -#define FKB_CLEAR 0x42 -#define FKB_INSERT 0x43 -#define FKB_DELETE 0x44 -#define FKB_UP 0x45 -#define FKB_LEFT 0x46 -#define FKB_RIGHT 0x47 -#define FKB_DOWN 0x48 diff --git a/branches/fceux-2.2.2/src/input/mouse.cpp b/branches/fceux-2.2.2/src/input/mouse.cpp deleted file mode 100644 index 2f58c733..00000000 --- a/branches/fceux-2.2.2/src/input/mouse.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include "share.h" - -typedef struct { - int32 mzx, mzy, mzxold, mzyold; - uint32 readbit; - uint32 data; -} MOUSE; - -static MOUSE Mouse; - -static void StrobeMOUSE(int w) -{ - Mouse.readbit=0; -} - -static uint8 ReadMOUSE(int w) -{ - uint8 ret=0; - if(Mouse.readbit>=8) - ret|=1; - else - { - ret|=(Mouse.data>>Mouse.readbit)&1; - if(!fceuindbg) - Mouse.readbit++; - } - return(ret); -} - -static void UpdateMOUSE(int w, void *data, int arg) -{ - uint32 *ptr=(uint32*)data; - Mouse.data=0; - Mouse.mzxold=Mouse.mzx; - Mouse.mzyold=Mouse.mzy; - Mouse.mzx=ptr[0]; - Mouse.mzy=ptr[1]; - Mouse.data|=ptr[2]; - if((Mouse.mzxold-Mouse.mzx)>0) - Mouse.data|=0x0C; - else if((Mouse.mzxold-Mouse.mzx)<0) - Mouse.data|=0x04; - if((Mouse.mzyold-Mouse.mzy)>0) - Mouse.data|=0x30; - else if((Mouse.mzyold-Mouse.mzy)<0) - Mouse.data|=0x10; -} - -static INPUTC MOUSEC={ReadMOUSE,0,StrobeMOUSE,UpdateMOUSE,0,0}; - -INPUTC *FCEU_InitMouse(int w) -{ - Mouse.mzx=0; - Mouse.mzy=0; - Mouse.mzxold=0; - Mouse.mzyold=0; - Mouse.data=0; - return(&MOUSEC); -} diff --git a/branches/fceux-2.2.2/src/input/suborkb.cpp b/branches/fceux-2.2.2/src/input/suborkb.cpp deleted file mode 100644 index 41595c23..00000000 --- a/branches/fceux-2.2.2/src/input/suborkb.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include "share.h" -#include "suborkb.h" -#define AK2(x,y) ( (FKB_##x) | (FKB_##y <<8) ) -#define AK(x) FKB_##x - -static uint8 bufit[0x61]; -static uint8 ksmode; -static uint8 ksindex; - - -static uint16 matrix[13][2][4]= -{ -{{AK(4),AK(G),AK(F),AK(C)}, - {AK(F2),AK(E),AK(5),AK(V)}}, -{{AK(2),AK(D),AK(S),AK(END)}, - {AK(F1),AK(W),AK(3),AK(X)}}, -{{AK(INSERT),AK(BACK),AK(NEXT),AK(RIGHT)}, - {AK(F8),AK(PRIOR),AK(DELETE),AK(HOME)}}, -{{AK(9),AK(I),AK(L),AK(COMMA)}, - {AK(F5),AK(O),AK(0),AK(PERIOD)}}, -{{AK(RBRACKET),AK(RETURN),AK(UP),AK(LEFT)}, - {AK(F7),AK(LBRACKET),AK(BACKSLASH),AK(DOWN)}}, -{{AK(Q),AK(CAPITAL),AK(Z),AK(TAB)}, - {AK(ESCAPE),AK(A),AK(1),AK(LCONTROL)}}, -{{AK(7),AK(Y),AK(K),AK(M)}, - {AK(F4),AK(U),AK(8),AK(J)}}, -{{AK(MINUS),AK(SEMICOLON),AK(APOSTROPHE),AK(SLASH)}, - {AK(F6),AK(P),AK(EQUALS),AK(LSHIFT)}}, -{{AK(T),AK(H),AK(N),AK(SPACE)}, - {AK(F3),AK(R),AK(6),AK(B)}}, -{{0,0,0,0}, - {0,0,0,0}}, -{{AK(LMENU),AK(NUMPAD4),AK(NUMPAD7),AK(F11)}, - {AK(F12),AK(NUMPAD1),AK(NUMPAD2),AK(NUMPAD8)}}, -{{AK(SUBTRACT),AK(ADD),AK(MULTIPLY),AK(NUMPAD9)}, - {AK(F10),AK(NUMPAD5),AK(DIVIDE),AK(NUMLOCK)}}, -{{AK(GRAVE),AK(NUMPAD6),AK(PAUSE),AK(SPACE)}, - {AK(F9),AK(NUMPAD3),AK(DECIMAL),AK(NUMPAD0)}}, -}; - -static void SuborKB_Write(uint8 v) -{ - v>>=1; - if(v&2) - { - if((ksmode&1) && !(v&1)) - ksindex=(ksindex+1)%13; - } - ksmode=v; -} - -static uint8 SuborKB_Read(int w, uint8 ret) -{ - if(w) - { - int x; - - ret&=~0x1E; -// if(ksindex==9) -// { -// if(ksmode&1) -// ret|=2; -// } -// else -// { - for(x=0;x<4;x++) - if(bufit[matrix[ksindex][ksmode&1][x]&0xFF]||bufit[matrix[ksindex][ksmode&1][x]>>8]) - ret|=1<<(x+1); -// } - ret^=0x1E; - } - return(ret); -} - -static void SuborKB_Strobe(void) -{ - ksmode=0; - ksindex=0; -} - -static void SuborKB_Update(void *data, int arg) -{ - memcpy(bufit+1,data,0x60); -} - -static INPUTCFC SuborKB={SuborKB_Read,SuborKB_Write,SuborKB_Strobe,SuborKB_Update,0,0}; - -INPUTCFC *FCEU_InitSuborKB(void) -{ - memset(bufit,0,sizeof(bufit)); - ksmode=ksindex=0; - return(&SuborKB); -} diff --git a/branches/fceux-2.2.2/src/input/suborkb.h b/branches/fceux-2.2.2/src/input/suborkb.h deleted file mode 100644 index 735f8204..00000000 --- a/branches/fceux-2.2.2/src/input/suborkb.h +++ /dev/null @@ -1,96 +0,0 @@ -#define FKB_ESCAPE 0x01 -#define FKB_F1 0x02 -#define FKB_F2 0x03 -#define FKB_F3 0x04 -#define FKB_F4 0x05 -#define FKB_F5 0x06 -#define FKB_F6 0x07 -#define FKB_F7 0x08 -#define FKB_F8 0x09 -#define FKB_F9 0x0A -#define FKB_F10 0x0B -#define FKB_F11 0x0C -#define FKB_F12 0x0D -#define FKB_PAUSE 0x0E -#define FKB_GRAVE 0x0F -#define FKB_1 0x10 -#define FKB_2 0x11 -#define FKB_3 0x12 -#define FKB_4 0x13 -#define FKB_5 0x14 -#define FKB_6 0x15 -#define FKB_7 0x16 -#define FKB_8 0x17 -#define FKB_9 0x18 -#define FKB_0 0x19 -#define FKB_MINUS 0x1A -#define FKB_EQUALS 0x1B -#define FKB_BACK 0x1C -#define FKB_INSERT 0x1D -#define FKB_HOME 0x1E -#define FKB_PRIOR 0x1F -#define FKB_NUMLOCK 0x20 -#define FKB_DIVIDE 0x21 -#define FKB_MULTIPLY 0x22 -#define FKB_SUBTRACT 0x23 -#define FKB_TAB 0x24 -#define FKB_Q 0x25 -#define FKB_W 0x26 -#define FKB_E 0x27 -#define FKB_R 0x28 -#define FKB_T 0x29 -#define FKB_Y 0x2A -#define FKB_U 0x2B -#define FKB_I 0x2C -#define FKB_O 0x2D -#define FKB_P 0x2E -#define FKB_LBRACKET 0x2F -#define FKB_RBRACKET 0x30 -#define FKB_RETURN 0x31 -#define FKB_DELETE 0x32 -#define FKB_END 0x33 -#define FKB_NEXT 0x34 -#define FKB_NUMPAD7 0x35 -#define FKB_NUMPAD8 0x36 -#define FKB_NUMPAD9 0x37 -#define FKB_ADD 0x38 -#define FKB_CAPITAL 0x39 -#define FKB_A 0x3A -#define FKB_S 0x3B -#define FKB_D 0x3C -#define FKB_F 0x3D -#define FKB_G 0x3E -#define FKB_H 0x3F -#define FKB_J 0x40 -#define FKB_K 0x41 -#define FKB_L 0x42 -#define FKB_SEMICOLON 0x43 -#define FKB_APOSTROPHE 0x44 -#define FKB_NUMPAD4 0x45 -#define FKB_NUMPAD5 0x46 -#define FKB_NUMPAD6 0x47 -#define FKB_LSHIFT 0x48 -#define FKB_Z 0x49 -#define FKB_X 0x4A -#define FKB_C 0x4B -#define FKB_V 0x4C -#define FKB_B 0x4D -#define FKB_N 0x4E -#define FKB_M 0x4F -#define FKB_COMMA 0x50 -#define FKB_PERIOD 0x51 -#define FKB_SLASH 0x52 -#define FKB_BACKSLASH 0x53 -#define FKB_UP 0x54 -#define FKB_NUMPAD1 0x55 -#define FKB_NUMPAD2 0x56 -#define FKB_NUMPAD3 0x57 -#define FKB_LCONTROL 0x58 -#define FKB_LMENU 0x59 -#define FKB_SPACE 0x5A -#define FKB_LEFT 0x5B -#define FKB_DOWN 0x5C -#define FKB_RIGHT 0x5D -#define FKB_NUMPAD0 0x5E -#define FKB_DECIMAL 0x5F - diff --git a/branches/fceux-2.2.2/src/lua-engine.cpp b/branches/fceux-2.2.2/src/lua-engine.cpp deleted file mode 100644 index 53774f7f..00000000 --- a/branches/fceux-2.2.2/src/lua-engine.cpp +++ /dev/null @@ -1,6013 +0,0 @@ -#ifdef __linux -#include -#define SetCurrentDir chdir -#include -#include -#endif - -#ifdef WIN32 -#include -#define SetCurrentDir _chdir -#endif - -#include "types.h" -#include "fceu.h" -#include "video.h" -#include "debug.h" -#include "sound.h" -#include "drawing.h" -#include "state.h" -#include "movie.h" -#include "driver.h" -#include "cheat.h" -#include "x6502.h" -#include "utils/xstring.h" -#include "utils/memory.h" -#include "fceulua.h" - -#ifdef WIN32 -#include "drivers/win/common.h" -#include "drivers/win/taseditor/selection.h" -#include "drivers/win/taseditor/laglog.h" -#include "drivers/win/taseditor/markers.h" -#include "drivers/win/taseditor/snapshot.h" -#include "drivers/win/taseditor/taseditor_lua.h" -extern TASEDITOR_LUA taseditor_lua; -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "x6502abbrev.h" - -bool CheckLua() -{ -#ifdef WIN32 - HMODULE mod = LoadLibrary("lua51.dll"); - if(!mod) - { - return false; - } - FreeLibrary(mod); - return true; -#else - return true; -#endif -} - -bool DemandLua() -{ -#ifdef WIN32 - if(!CheckLua()) - { - MessageBox(NULL, "lua51.dll was not found. Please get it into your PATH or in the same directory as fceux.exe", "FCEUX", MB_OK | MB_ICONERROR); - return false; - } - return true; -#else - return true; -#endif -} - -extern "C" -{ -#include -#include -#include -#ifdef WIN32 -#include - int iuplua_open(lua_State * L); - int iupcontrolslua_open(lua_State * L); - int luaopen_winapi(lua_State * L); - - //luasocket - int luaopen_socket_core(lua_State *L); - int luaopen_mime_core(lua_State *L); -#endif -} - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#ifndef _MSC_VER - #define stricmp strcasecmp - #define strnicmp strncasecmp - - #ifdef __GNUC__ - #define __forceinline __attribute__ ((always_inline)) - #else - #define __forceinline - #endif -#endif - -#ifdef WIN32 -extern void AddRecentLuaFile(const char *filename); -#endif - -extern bool turbo; - -struct LuaSaveState { - std::string filename; - EMUFILE_MEMORY *data; - bool anonymous, persisted; - LuaSaveState() - : data(0) - , anonymous(false) - , persisted(false) - {} - ~LuaSaveState() { - if(data) delete data; - } - void persist() { - persisted = true; - FILE* outf = fopen(filename.c_str(),"wb"); - fwrite(data->buf(),1,data->size(),outf); - fclose(outf); - } - void ensureLoad() { - if(data) return; - persisted = true; - FILE* inf = fopen(filename.c_str(),"rb"); - fseek(inf,0,SEEK_END); - int len = ftell(inf); - fseek(inf,0,SEEK_SET); - data = new EMUFILE_MEMORY(len); - fread(data->buf(),1,len,inf); - fclose(inf); - } -}; - -static void(*info_print)(int uid, const char* str); -static void(*info_onstart)(int uid); -static void(*info_onstop)(int uid); -static int info_uid; -#ifdef WIN32 -extern HWND LuaConsoleHWnd; -extern INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); -extern void PrintToWindowConsole(int hDlgAsInt, const char* str); -extern void WinLuaOnStart(int hDlgAsInt); -extern void WinLuaOnStop(int hDlgAsInt); -void TaseditorDisableManualFunctionIfNeeded(); -#endif - -static lua_State *L; - -static int luaexiterrorcount = 8; - -// Are we running any code right now? -static char *luaScriptName = NULL; - -// Are we running any code right now? -int luaRunning = FALSE; - -// True at the frame boundary, false otherwise. -static int frameBoundary = FALSE; - -// The execution speed we're running at. -static enum {SPEED_NORMAL, SPEED_NOTHROTTLE, SPEED_TURBO, SPEED_MAXIMUM} speedmode = SPEED_NORMAL; - -// Rerecord count skip mode -static int skipRerecords = FALSE; - -// Used by the registry to find our functions -static const char *frameAdvanceThread = "FCEU.FrameAdvance"; -static const char *guiCallbackTable = "FCEU.GUI"; - -// True if there's a thread waiting to run after a run of frame-advance. -static int frameAdvanceWaiting = FALSE; - -// We save our pause status in the case of a natural death. -static int wasPaused = FALSE; - -// Transparency strength. 255=opaque, 0=so transparent it's invisible -static int transparencyModifier = 255; - -// Our joypads. -static uint8 luajoypads1[4]= { 0xFF, 0xFF, 0xFF, 0xFF }; //x1 -static uint8 luajoypads2[4]= { 0x00, 0x00, 0x00, 0x00 }; //0x -/* Crazy logic stuff. - 11 - true 01 - pass-through (default) - 00 - false 10 - invert */ - -static enum { GUI_USED_SINCE_LAST_DISPLAY, GUI_USED_SINCE_LAST_FRAME, GUI_CLEAR } gui_used = GUI_CLEAR; -static uint8 *gui_data = NULL; -static int gui_saw_current_palette = FALSE; - -// Protects Lua calls from going nuts. -// We set this to a big number like 1000 and decrement it -// over time. The script gets knifed once this reaches zero. -static int numTries; - -// number of registered memory functions (1 per hooked byte) -static unsigned int numMemHooks; - -// Look in fceu.h for macros named like JOY_UP to determine the order. -static const char *button_mappings[] = { - "A", "B", "select", "start", "up", "down", "left", "right" -}; - -#ifdef _MSC_VER - #define snprintf _snprintf - #define vscprintf _vscprintf -#else - #define stricmp strcasecmp - #define strnicmp strncasecmp -#endif - -static const char* luaCallIDStrings [] = -{ - "CALL_BEFOREEMULATION", - "CALL_AFTEREMULATION", - "CALL_BEFOREEXIT", - "CALL_BEFORESAVE", - "CALL_AFTERLOAD", - "CALL_TASEDITOR_AUTO", - "CALL_TASEDITOR_MANUAL", - -}; - -//make sure we have the right number of strings -CTASSERT(sizeof(luaCallIDStrings)/sizeof(*luaCallIDStrings) == LUACALL_COUNT) - -static const char* luaMemHookTypeStrings [] = -{ - "MEMHOOK_WRITE", - "MEMHOOK_READ", - "MEMHOOK_EXEC", - - "MEMHOOK_WRITE_SUB", - "MEMHOOK_READ_SUB", - "MEMHOOK_EXEC_SUB", -}; - -//make sure we have the right number of strings -CTASSERT(sizeof(luaMemHookTypeStrings)/sizeof(*luaMemHookTypeStrings) == LUAMEMHOOK_COUNT) - -static char* rawToCString(lua_State* L, int idx=0); -static const char* toCString(lua_State* L, int idx=0); - -/** - * Resets emulator speed / pause states after script exit. - */ -static void FCEU_LuaOnStop() -{ - luaRunning = FALSE; - for (int i = 0 ; i < 4 ; i++ ){ - luajoypads1[i]= 0xFF; // Set these back to pass-through - luajoypads2[i]= 0x00; - } - gui_used = GUI_CLEAR; - //if (wasPaused && !FCEUI_EmulationPaused()) - // FCEUI_ToggleEmulationPause(); - FCEUD_SetEmulationSpeed(EMUSPEED_NORMAL); //TODO: Ideally lua returns the speed to the speed the user set before running the script - //rather than returning it to normal, and turbo off. Perhaps some flags and a FCEUD_GetEmulationSpeed function - turbo = false; - //FCEUD_TurboOff(); -#ifdef WIN32 - TaseditorDisableManualFunctionIfNeeded(); -#endif -} - - -/** - * Asks Lua if it wants control of the emulator's speed. - * Returns 0 if no, 1 if yes. If yes, caller should also - * consult FCEU_LuaFrameSkip(). - */ -int FCEU_LuaSpeed() { - if (!L || !luaRunning) - return 0; - - //printf("%d\n", speedmode); - - switch (speedmode) { - case SPEED_NOTHROTTLE: - case SPEED_TURBO: - case SPEED_MAXIMUM: - return 1; - case SPEED_NORMAL: - default: - return 0; - } -} - -/** - * Asks Lua if it wants control whether this frame is skipped. - * Returns 0 if no, 1 if frame should be skipped, -1 if it should not be. - */ -int FCEU_LuaFrameSkip() { - if (!L || !luaRunning) - return 0; - - switch (speedmode) { - case SPEED_NORMAL: - return 0; - case SPEED_NOTHROTTLE: - return -1; - case SPEED_TURBO: - return 0; - case SPEED_MAXIMUM: - return 1; - } - return 0; -} - -/** - * Toggle certain rendering planes - * emu.setrenderingplanes(sprites, background) - * Accepts two (lua) boolean values and acts accordingly -*/ -static int emu_setrenderplanes(lua_State *L) { - bool sprites = (lua_toboolean( L, 1 ) == 1); - bool background = (lua_toboolean( L, 2 ) == 1); - FCEUI_SetRenderPlanes(sprites, background); - return 0; -} - -/////////////////////////// - - - -// emu.speedmode(string mode) -// -// Takes control of the emulation speed -// of the system. Normal is normal speed (60fps, 50 for PAL), -// nothrottle disables speed control but renders every frame, -// turbo renders only a few frames in order to speed up emulation, -// maximum renders no frames -// TODO: better enforcement, done in the same way as basicbot... -static int emu_speedmode(lua_State *L) { - const char *mode = luaL_checkstring(L,1); - - if (strcasecmp(mode, "normal")==0) { - speedmode = SPEED_NORMAL; - } else if (strcasecmp(mode, "nothrottle")==0) { - speedmode = SPEED_NOTHROTTLE; - } else if (strcasecmp(mode, "turbo")==0) { - speedmode = SPEED_TURBO; - } else if (strcasecmp(mode, "maximum")==0) { - speedmode = SPEED_MAXIMUM; - } else - luaL_error(L, "Invalid mode %s to emu.speedmode",mode); - - //printf("new speed mode: %d\n", speedmode); - if (speedmode == SPEED_NORMAL) - { - FCEUD_SetEmulationSpeed(EMUSPEED_NORMAL); - FCEUD_TurboOff(); - } - else if (speedmode == SPEED_TURBO) //adelikat: Making turbo actually use turbo. - FCEUD_TurboOn(); //Turbo and max speed are two different results. Turbo employs frame skipping and sound bypassing if mute turbo option is enabled. - //This makes it faster but with frame skipping. Therefore, maximum is still a useful feature, in case the user is recording an avi or making screenshots (or something else that needs all frames) - else - FCEUD_SetEmulationSpeed(EMUSPEED_FASTEST); //TODO: Make nothrottle turn off throttle, or remove the option - return 0; -} - -// emu.poweron() -// -// Executes a power cycle -static int emu_poweron(lua_State *L) { - if (GameInfo) - FCEUI_PowerNES(); - - return 0; -} - -// emu.softreset() -// -// Executes a power cycle -static int emu_softreset(lua_State *L) { - if (GameInfo) - FCEUI_ResetNES(); - - return 0; -} - -// emu.frameadvance() -// -// Executes a frame advance. Occurs by yielding the coroutine, then re-running -// when we break out. -static int emu_frameadvance(lua_State *L) { - // We're going to sleep for a frame-advance. Take notes. - - if (frameAdvanceWaiting) - return luaL_error(L, "can't call emu.frameadvance() from here"); - - frameAdvanceWaiting = TRUE; - - // Now we can yield to the main - return lua_yield(L, 0); - - - // It's actually rather disappointing... -} - -// bool emu.paused() -static int emu_paused(lua_State *L) -{ - lua_pushboolean(L, FCEUI_EmulationPaused() != 0); - return 1; -} - -// emu.pause() -// -// Pauses the emulator. Returns immediately. -static int emu_pause(lua_State *L) -{ - if (!FCEUI_EmulationPaused()) - FCEUI_ToggleEmulationPause(); - return 0; -} - -//emu.unpause() -// -// Unpauses the emulator. Returns immediately. -static int emu_unpause(lua_State *L) -{ - if (FCEUI_EmulationPaused()) - FCEUI_ToggleEmulationPause(); - return 0; -} - - -// emu.message(string msg) -// -// Displays the given message on the screen. -static int emu_message(lua_State *L) { - - const char *msg = luaL_checkstring(L,1); - FCEU_DispMessage("%s",0, msg); - - return 0; - -} - - -static int emu_registerbefore(lua_State *L) { - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L,1); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEMULATION]); - lua_insert(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEMULATION]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} - -static int emu_registerafter(lua_State *L) { - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L,1); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTEREMULATION]); - lua_insert(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTEREMULATION]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} - -static int emu_registerexit(lua_State *L) { - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L,1); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]); - lua_insert(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} - -static int emu_addgamegenie(lua_State *L) { - - const char *msg = luaL_checkstring(L,1); - - // Add a Game Genie code if it hasn't already been added - int GGaddr, GGcomp, GGval; - int i=0; - - uint32 Caddr; - uint8 Cval; - int Ccompare, Ctype; - - if (!FCEUI_DecodeGG(msg, &GGaddr, &GGval, &GGcomp)) { - luaL_error(L, "Failed to decode game genie code"); - lua_pushboolean(L, false); - return 1; - } - - while (FCEUI_GetCheat(i,NULL,&Caddr,&Cval,&Ccompare,NULL,&Ctype)) { - - if ((GGaddr == Caddr) && (GGval == Cval) && (GGcomp == Ccompare) && (Ctype == 1)) { - // Already Added, so consider it a success - lua_pushboolean(L, true); - return 1; - } - - i = i + 1; - } - - if (FCEUI_AddCheat(msg,GGaddr,GGval,GGcomp,1)) { - // Code was added - // Can't manage the display update the way I want, so I won't bother with it - // UpdateCheatsAdded(); - lua_pushboolean(L, true); - return 1; - } else { - // Code didn't get added - lua_pushboolean(L, false); - return 1; - } -} - -static int emu_delgamegenie(lua_State *L) { - - const char *msg = luaL_checkstring(L,1); - - // Remove a Game Genie code. Very restrictive about deleted code. - int GGaddr, GGcomp, GGval; - uint32 i=0; - - char * Cname; - uint32 Caddr; - uint8 Cval; - int Ccompare, Ctype; - - if (!FCEUI_DecodeGG(msg, &GGaddr, &GGval, &GGcomp)) { - luaL_error(L, "Failed to decode game genie code"); - lua_pushboolean(L, false); - return 1; - } - - while (FCEUI_GetCheat(i,&Cname,&Caddr,&Cval,&Ccompare,NULL,&Ctype)) { - - if ((!strcmp(msg,Cname)) && (GGaddr == Caddr) && (GGval == Cval) && (GGcomp == Ccompare) && (Ctype == 1)) { - // Delete cheat code - if (FCEUI_DelCheat(i)) { - lua_pushboolean(L, true); - return 1; - } - else { - lua_pushboolean(L, false); - return 1; - } - } - - i = i + 1; - } - - // Cheat didn't exist, so it's not an error - lua_pushboolean(L, true); - return 1; -} - - -// can't remember what the best way of doing this is... -#if defined(i386) || defined(__i386) || defined(__i386__) || defined(M_I86) || defined(_M_IX86) || defined(WIN32) - #define IS_LITTLE_ENDIAN -#endif - -// push a value's bytes onto the output stack -template -void PushBinaryItem(T item, std::vector& output) -{ - unsigned char* buf = (unsigned char*)&item; -#ifdef IS_LITTLE_ENDIAN - for(int i = sizeof(T); i; i--) - output.push_back(*buf++); -#else - int vecsize = output.size(); - for(int i = sizeof(T); i; i--) - output.insert(output.begin() + vecsize, *buf++); -#endif -} -// read a value from the byte stream and advance the stream by its size -template -T AdvanceByteStream(const unsigned char*& data, unsigned int& remaining) -{ -#ifdef IS_LITTLE_ENDIAN - T rv = *(T*)data; - data += sizeof(T); -#else - T rv; unsigned char* rvptr = (unsigned char*)&rv; - for(int i = sizeof(T)-1; i>=0; i--) - rvptr[i] = *data++; -#endif - remaining -= sizeof(T); - return rv; -} -// advance the byte stream by a certain size without reading a value -void AdvanceByteStream(const unsigned char*& data, unsigned int& remaining, int amount) -{ - data += amount; - remaining -= amount; -} - -#define LUAEXT_TLONG 30 // 0x1E // 4-byte signed integer -#define LUAEXT_TUSHORT 31 // 0x1F // 2-byte unsigned integer -#define LUAEXT_TSHORT 32 // 0x20 // 2-byte signed integer -#define LUAEXT_TBYTE 33 // 0x21 // 1-byte unsigned integer -#define LUAEXT_TNILS 34 // 0x22 // multiple nils represented by a 4-byte integer (warning: becomes multiple stack entities) -#define LUAEXT_TTABLE 0x40 // 0x40 through 0x4F // tables of different sizes: -#define LUAEXT_BITS_1A 0x01 // size of array part fits in a 1-byte unsigned integer -#define LUAEXT_BITS_2A 0x02 // size of array part fits in a 2-byte unsigned integer -#define LUAEXT_BITS_4A 0x03 // size of array part fits in a 4-byte unsigned integer -#define LUAEXT_BITS_1H 0x04 // size of hash part fits in a 1-byte unsigned integer -#define LUAEXT_BITS_2H 0x08 // size of hash part fits in a 2-byte unsigned integer -#define LUAEXT_BITS_4H 0x0C // size of hash part fits in a 4-byte unsigned integer -#define BITMATCH(x,y) (((x) & (y)) == (y)) - -static void PushNils(std::vector& output, int& nilcount) -{ - int count = nilcount; - nilcount = 0; - - static const int minNilsWorthEncoding = 6; // because a LUAEXT_TNILS entry is 5 bytes - - if(count < minNilsWorthEncoding) - { - for(int i = 0; i < count; i++) - output.push_back(LUA_TNIL); - } - else - { - output.push_back(LUAEXT_TNILS); - PushBinaryItem(count, output); - } -} - -static std::vector s_tableAddressStack; // prevents infinite recursion of a table within a table (when cycle is found, print something like table:parent) -static std::vector s_metacallStack; // prevents infinite recursion if something's __tostring returns another table that contains that something (when cycle is found, print the inner result without using __tostring) - -static void LuaStackToBinaryConverter(lua_State* L, int i, std::vector& output) -{ - int type = lua_type(L, i); - - // the first byte of every serialized item says what Lua type it is - output.push_back(type & 0xFF); - - switch(type) - { - default: - { - char errmsg [1024]; - sprintf(errmsg, "values of type \"%s\" are not allowed to be returned from registered save functions.\r\n", luaL_typename(L,i)); - if(info_print) - info_print(info_uid, errmsg); - else - puts(errmsg); - } - break; - case LUA_TNIL: - // no information necessary beyond the type - break; - case LUA_TBOOLEAN: - // serialize as 0 or 1 - output.push_back(lua_toboolean(L,i)); - break; - case LUA_TSTRING: - // serialize as a 0-terminated string of characters - { - const char* str = lua_tostring(L,i); - while(*str) - output.push_back(*str++); - output.push_back('\0'); - } - break; - case LUA_TNUMBER: - { - double num = (double)lua_tonumber(L,i); - int32 inum = (int32)lua_tointeger(L,i); - if(num != inum) - { - PushBinaryItem(num, output); - } - else - { - if((inum & ~0xFF) == 0) - type = LUAEXT_TBYTE; - else if((uint16)(inum & 0xFFFF) == inum) - type = LUAEXT_TUSHORT; - else if((int16)(inum & 0xFFFF) == inum) - type = LUAEXT_TSHORT; - else - type = LUAEXT_TLONG; - output.back() = type; - switch(type) - { - case LUAEXT_TLONG: - PushBinaryItem(static_cast(inum), output); - break; - case LUAEXT_TUSHORT: - PushBinaryItem(static_cast(inum), output); - break; - case LUAEXT_TSHORT: - PushBinaryItem(static_cast(inum), output); - break; - case LUAEXT_TBYTE: - output.push_back(static_cast(inum)); - break; - } - } - } - break; - case LUA_TTABLE: - // serialize as a type that describes how many bytes are used for storing the counts, - // followed by the number of array entries if any, then the number of hash entries if any, - // then a Lua value per array entry, then a (key,value) pair of Lua values per hashed entry - // note that the structure of table references are not faithfully serialized (yet) - { - int outputTypeIndex = output.size() - 1; - int arraySize = 0; - int hashSize = 0; - - if(lua_checkstack(L, 4) && std::find(s_tableAddressStack.begin(), s_tableAddressStack.end(), lua_topointer(L,i)) == s_tableAddressStack.end()) - { - s_tableAddressStack.push_back(lua_topointer(L,i)); - struct Scope { ~Scope(){ s_tableAddressStack.pop_back(); } } scope; - - bool wasnil = false; - int nilcount = 0; - arraySize = lua_objlen(L, i); - int arrayValIndex = lua_gettop(L) + 1; - for(int j = 1; j <= arraySize; j++) - { - lua_rawgeti(L, i, j); - bool isnil = lua_isnil(L, arrayValIndex); - if(isnil) - nilcount++; - else - { - if(wasnil) - PushNils(output, nilcount); - LuaStackToBinaryConverter(L, arrayValIndex, output); - } - lua_pop(L, 1); - wasnil = isnil; - } - if(wasnil) - PushNils(output, nilcount); - - if(arraySize) - lua_pushinteger(L, arraySize); // before first key - else - lua_pushnil(L); // before first key - - int keyIndex = lua_gettop(L); - int valueIndex = keyIndex + 1; - while(lua_next(L, i)) - { -// assert(lua_type(L, keyIndex) && "nil key in Lua table, impossible"); -// assert(lua_type(L, valueIndex) && "nil value in Lua table, impossible"); - LuaStackToBinaryConverter(L, keyIndex, output); - LuaStackToBinaryConverter(L, valueIndex, output); - lua_pop(L, 1); - hashSize++; - } - } - - int outputType = LUAEXT_TTABLE; - if(arraySize & 0xFFFF0000) - outputType |= LUAEXT_BITS_4A; - else if(arraySize & 0xFF00) - outputType |= LUAEXT_BITS_2A; - else if(arraySize & 0xFF) - outputType |= LUAEXT_BITS_1A; - if(hashSize & 0xFFFF0000) - outputType |= LUAEXT_BITS_4H; - else if(hashSize & 0xFF00) - outputType |= LUAEXT_BITS_2H; - else if(hashSize & 0xFF) - outputType |= LUAEXT_BITS_1H; - output[outputTypeIndex] = outputType; - - int insertIndex = outputTypeIndex; - if(BITMATCH(outputType,LUAEXT_BITS_4A) || BITMATCH(outputType,LUAEXT_BITS_2A) || BITMATCH(outputType,LUAEXT_BITS_1A)) - output.insert(output.begin() + (++insertIndex), arraySize & 0xFF); - if(BITMATCH(outputType,LUAEXT_BITS_4A) || BITMATCH(outputType,LUAEXT_BITS_2A)) - output.insert(output.begin() + (++insertIndex), (arraySize & 0xFF00) >> 8); - if(BITMATCH(outputType,LUAEXT_BITS_4A)) - output.insert(output.begin() + (++insertIndex), (arraySize & 0x00FF0000) >> 16), - output.insert(output.begin() + (++insertIndex), (arraySize & 0xFF000000) >> 24); - if(BITMATCH(outputType,LUAEXT_BITS_4H) || BITMATCH(outputType,LUAEXT_BITS_2H) || BITMATCH(outputType,LUAEXT_BITS_1H)) - output.insert(output.begin() + (++insertIndex), hashSize & 0xFF); - if(BITMATCH(outputType,LUAEXT_BITS_4H) || BITMATCH(outputType,LUAEXT_BITS_2H)) - output.insert(output.begin() + (++insertIndex), (hashSize & 0xFF00) >> 8); - if(BITMATCH(outputType,LUAEXT_BITS_4H)) - output.insert(output.begin() + (++insertIndex), (hashSize & 0x00FF0000) >> 16), - output.insert(output.begin() + (++insertIndex), (hashSize & 0xFF000000) >> 24); - - } break; - } -} - - -// complements LuaStackToBinaryConverter -void BinaryToLuaStackConverter(lua_State* L, const unsigned char*& data, unsigned int& remaining) -{ -// assert(s_dbg_dataSize - (data - s_dbg_dataStart) == remaining); - - unsigned char type = AdvanceByteStream(data, remaining); - - switch(type) - { - default: - { - char errmsg [1024]; - if(type <= 10 && type != LUA_TTABLE) - sprintf(errmsg, "values of type \"%s\" are not allowed to be loaded into registered load functions. The save state's Lua save data file might be corrupted.\r\n", lua_typename(L,type)); - else - sprintf(errmsg, "The save state's Lua save data file seems to be corrupted.\r\n"); - if(info_print) - info_print(info_uid, errmsg); - else - puts(errmsg); - } - break; - case LUA_TNIL: - lua_pushnil(L); - break; - case LUA_TBOOLEAN: - lua_pushboolean(L, AdvanceByteStream(data, remaining)); - break; - case LUA_TSTRING: - lua_pushstring(L, (const char*)data); - AdvanceByteStream(data, remaining, strlen((const char*)data) + 1); - break; - case LUA_TNUMBER: - lua_pushnumber(L, AdvanceByteStream(data, remaining)); - break; - case LUAEXT_TLONG: - lua_pushinteger(L, AdvanceByteStream(data, remaining)); - break; - case LUAEXT_TUSHORT: - lua_pushinteger(L, AdvanceByteStream(data, remaining)); - break; - case LUAEXT_TSHORT: - lua_pushinteger(L, AdvanceByteStream(data, remaining)); - break; - case LUAEXT_TBYTE: - lua_pushinteger(L, AdvanceByteStream(data, remaining)); - break; - case LUAEXT_TTABLE: - case LUAEXT_TTABLE | LUAEXT_BITS_1A: - case LUAEXT_TTABLE | LUAEXT_BITS_2A: - case LUAEXT_TTABLE | LUAEXT_BITS_4A: - case LUAEXT_TTABLE | LUAEXT_BITS_1H: - case LUAEXT_TTABLE | LUAEXT_BITS_2H: - case LUAEXT_TTABLE | LUAEXT_BITS_4H: - case LUAEXT_TTABLE | LUAEXT_BITS_1A | LUAEXT_BITS_1H: - case LUAEXT_TTABLE | LUAEXT_BITS_2A | LUAEXT_BITS_1H: - case LUAEXT_TTABLE | LUAEXT_BITS_4A | LUAEXT_BITS_1H: - case LUAEXT_TTABLE | LUAEXT_BITS_1A | LUAEXT_BITS_2H: - case LUAEXT_TTABLE | LUAEXT_BITS_2A | LUAEXT_BITS_2H: - case LUAEXT_TTABLE | LUAEXT_BITS_4A | LUAEXT_BITS_2H: - case LUAEXT_TTABLE | LUAEXT_BITS_1A | LUAEXT_BITS_4H: - case LUAEXT_TTABLE | LUAEXT_BITS_2A | LUAEXT_BITS_4H: - case LUAEXT_TTABLE | LUAEXT_BITS_4A | LUAEXT_BITS_4H: - { - unsigned int arraySize = 0; - if(BITMATCH(type,LUAEXT_BITS_4A) || BITMATCH(type,LUAEXT_BITS_2A) || BITMATCH(type,LUAEXT_BITS_1A)) - arraySize |= AdvanceByteStream(data, remaining); - if(BITMATCH(type,LUAEXT_BITS_4A) || BITMATCH(type,LUAEXT_BITS_2A)) - arraySize |= ((uint16)AdvanceByteStream(data, remaining)) << 8; - if(BITMATCH(type,LUAEXT_BITS_4A)) - arraySize |= ((uint32)AdvanceByteStream(data, remaining)) << 16, - arraySize |= ((uint32)AdvanceByteStream(data, remaining)) << 24; - - unsigned int hashSize = 0; - if(BITMATCH(type,LUAEXT_BITS_4H) || BITMATCH(type,LUAEXT_BITS_2H) || BITMATCH(type,LUAEXT_BITS_1H)) - hashSize |= AdvanceByteStream(data, remaining); - if(BITMATCH(type,LUAEXT_BITS_4H) || BITMATCH(type,LUAEXT_BITS_2H)) - hashSize |= ((uint16)AdvanceByteStream(data, remaining)) << 8; - if(BITMATCH(type,LUAEXT_BITS_4H)) - hashSize |= ((uint32)AdvanceByteStream(data, remaining)) << 16, - hashSize |= ((uint32)AdvanceByteStream(data, remaining)) << 24; - - lua_checkstack(L, 8); - - lua_createtable(L, arraySize, hashSize); - - unsigned int n = 1; - while(n <= arraySize) - { - if(*data == LUAEXT_TNILS) - { - AdvanceByteStream(data, remaining, 1); - n += AdvanceByteStream(data, remaining); - } - else - { - BinaryToLuaStackConverter(L, data, remaining); // push value - lua_rawseti(L, -2, n); // table[n] = value - n++; - } - } - - for(unsigned int h = 1; h <= hashSize; h++) - { - BinaryToLuaStackConverter(L, data, remaining); // push key - BinaryToLuaStackConverter(L, data, remaining); // push value - lua_rawset(L, -3); // table[key] = value - } - } - break; - } -} - -static const unsigned char luaBinaryMajorVersion = 9; -static const unsigned char luaBinaryMinorVersion = 1; - -unsigned char* LuaStackToBinary(lua_State* L, unsigned int& size) -{ - int n = lua_gettop(L); - if(n == 0) - return NULL; - - std::vector output; - output.push_back(luaBinaryMajorVersion); - output.push_back(luaBinaryMinorVersion); - - for(int i = 1; i <= n; i++) - LuaStackToBinaryConverter(L, i, output); - - unsigned char* rv = new unsigned char [output.size()]; - memcpy(rv, &output.front(), output.size()); - size = output.size(); - return rv; -} - -void BinaryToLuaStack(lua_State* L, const unsigned char* data, unsigned int size, unsigned int itemsToLoad) -{ - unsigned char major = *data++; - unsigned char minor = *data++; - size -= 2; - if(luaBinaryMajorVersion != major || luaBinaryMinorVersion != minor) - return; - - while(size > 0 && itemsToLoad > 0) - { - BinaryToLuaStackConverter(L, data, size); - itemsToLoad--; - } -} - -// saves Lua stack into a record and pops it -void LuaSaveData::SaveRecord(lua_State* L, unsigned int key) -{ - if(!L) - return; - - Record* cur = new Record(); - cur->key = key; - cur->data = LuaStackToBinary(L, cur->size); - cur->next = NULL; - - lua_settop(L,0); - - if(cur->size <= 0) - { - delete cur; - return; - } - - Record* last = recordList; - while(last && last->next) - last = last->next; - if(last) - last->next = cur; - else - recordList = cur; -} - -// pushes a record's data onto the Lua stack -void LuaSaveData::LoadRecord(struct lua_State* L, unsigned int key, unsigned int itemsToLoad) const -{ - if(!L) - return; - - Record* cur = recordList; - while(cur) - { - if(cur->key == key) - { -// s_dbg_dataStart = cur->data; -// s_dbg_dataSize = cur->size; - BinaryToLuaStack(L, cur->data, cur->size, itemsToLoad); - return; - } - cur = cur->next; - } -} - -// saves part of the Lua stack (at the given index) into a record and does NOT pop anything -void LuaSaveData::SaveRecordPartial(struct lua_State* L, unsigned int key, int idx) -{ - if(!L) - return; - - if(idx < 0) - idx += lua_gettop(L)+1; - - Record* cur = new Record(); - cur->key = key; - cur->next = NULL; - - if(idx <= lua_gettop(L)) - { - std::vector output; - output.push_back(luaBinaryMajorVersion); - output.push_back(luaBinaryMinorVersion); - - LuaStackToBinaryConverter(L, idx, output); - - unsigned char* rv = new unsigned char [output.size()]; - memcpy(rv, &output.front(), output.size()); - cur->size = output.size(); - cur->data = rv; - } - - if(cur->size <= 0) - { - delete cur; - return; - } - - Record* last = recordList; - while(last && last->next) - last = last->next; - if(last) - last->next = cur; - else - recordList = cur; -} - -void fwriteint(unsigned int value, FILE* file) -{ - for(int i=0;i<4;i++) - { - int w = value & 0xFF; - fwrite(&w, 1, 1, file); - value >>= 8; - } -} -void freadint(unsigned int& value, FILE* file) -{ - int rv = 0; - for(int i=0;i<4;i++) - { - int r = 0; - fread(&r, 1, 1, file); - rv |= r << (i*8); - } - value = rv; -} - -// writes all records to an already-open file -void LuaSaveData::ExportRecords(void* fileV) const -{ - FILE* file = (FILE*)fileV; - if(!file) - return; - - Record* cur = recordList; - while(cur) - { - fwriteint(cur->key, file); - fwriteint(cur->size, file); - fwrite(cur->data, cur->size, 1, file); - cur = cur->next; - } -} - -// reads records from an already-open file -void LuaSaveData::ImportRecords(void* fileV) -{ - FILE* file = (FILE*)fileV; - if(!file) - return; - - ClearRecords(); - - Record rec; - Record* cur = &rec; - Record* last = NULL; - while(1) - { - freadint(cur->key, file); - freadint(cur->size, file); - - if(feof(file) || ferror(file)) - break; - - cur->data = new unsigned char [cur->size]; - fread(cur->data, cur->size, 1, file); - - Record* next = new Record(); - memcpy(next, cur, sizeof(Record)); - next->next = NULL; - - if(last) - last->next = next; - else - recordList = next; - last = next; - } -} - -void LuaSaveData::ClearRecords() -{ - Record* cur = recordList; - while(cur) - { - Record* del = cur; - cur = cur->next; - - delete[] del->data; - delete del; - } - - recordList = NULL; -} - - - - - - -void CallRegisteredLuaSaveFunctions(int savestateNumber, LuaSaveData& saveData) -{ - //lua_State* L = FCEU_GetLuaState(); - if(L) - { - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFORESAVE]); - - if (lua_isfunction(L, -1)) - { - lua_pushinteger(L, savestateNumber); - int ret = lua_pcall(L, 1, LUA_MULTRET, 0); - if (ret != 0) { - // This is grounds for trashing the function - lua_pushnil(L); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFORESAVE]); -#ifdef WIN32 - MessageBox(hAppWnd, lua_tostring(L, -1), "Lua Error in SAVE function", MB_OK); -#else - fprintf(stderr, "Lua error in registersave function: %s\n", lua_tostring(L, -1)); -#endif - } - saveData.SaveRecord(L, LUA_DATARECORDKEY); - } - else - { - lua_pop(L, 1); - } - } -} - - -void CallRegisteredLuaLoadFunctions(int savestateNumber, const LuaSaveData& saveData) -{ - //lua_State* L = FCEU_GetLuaState(); - if(L) - { - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTERLOAD]); - - if (lua_isfunction(L, -1)) - { -#ifdef WIN32 - // since the scriptdata can be very expensive to load - // (e.g. the registered save function returned some huge tables) - // check the number of parameters the registered load function expects - // and don't bother loading the parameters it wouldn't receive anyway - int numParamsExpected = (L->top - 1)->value.gc->cl.l.p->numparams; // NOTE: if this line crashes, that means your Lua headers are out of sync with your Lua lib - if(numParamsExpected) numParamsExpected--; // minus one for the savestate number we always pass in - - int prevGarbage = lua_gc(L, LUA_GCCOUNT, 0); - - lua_pushinteger(L, savestateNumber); - saveData.LoadRecord(L, LUA_DATARECORDKEY, numParamsExpected); -#else - int prevGarbage = lua_gc(L, LUA_GCCOUNT, 0); - - lua_pushinteger(L, savestateNumber); - saveData.LoadRecord(L, LUA_DATARECORDKEY, (unsigned int) -1); -#endif - - int n = lua_gettop(L) - 1; - - int ret = lua_pcall(L, n, 0, 0); - if (ret != 0) { - // This is grounds for trashing the function - lua_pushnil(L); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTERLOAD]); -#ifdef WIN32 - MessageBox(hAppWnd, lua_tostring(L, -1), "Lua Error in LOAD function", MB_OK); -#else - fprintf(stderr, "Lua error in registerload function: %s\n", lua_tostring(L, -1)); -#endif - } - else - { - int newGarbage = lua_gc(L, LUA_GCCOUNT, 0); - if(newGarbage - prevGarbage > 50) - { - // now seems to be a very good time to run the garbage collector - // it might take a while now but that's better than taking 10 whiles 9 loads from now - lua_gc(L, LUA_GCCOLLECT, 0); - } - } - } - else - { - lua_pop(L, 1); - } - } -} - - -static int rom_readbyte(lua_State *L) { - lua_pushinteger(L, FCEU_ReadRomByte(luaL_checkinteger(L,1))); - return 1; -} - -static int rom_readbytesigned(lua_State *L) { - lua_pushinteger(L, (signed char)FCEU_ReadRomByte(luaL_checkinteger(L,1))); - return 1; -} - -static int rom_gethash(lua_State *L) { - const char *type = luaL_checkstring(L, 1); - if(!type) lua_pushstring(L, ""); - else if(!stricmp(type,"md5")) lua_pushstring(L, md5_asciistr(GameInfo->MD5)); - else lua_pushstring(L, ""); - return 1; -} - -static int memory_readbyte(lua_State *L) { - lua_pushinteger(L, FCEU_CheatGetByte(luaL_checkinteger(L,1))); - return 1; -} - -static int memory_readbytesigned(lua_State *L) { - signed char c = (signed char) FCEU_CheatGetByte(luaL_checkinteger(L,1)); - lua_pushinteger(L, c); - return 1; -} - -static int GetWord(lua_State *L, bool isSigned) -{ - // little endian, unless the high byte address is specified as a 2nd parameter - uint16 addressLow = luaL_checkinteger(L, 1); - uint16 addressHigh = addressLow + 1; - if (lua_type(L, 2) == LUA_TNUMBER) - addressHigh = luaL_checkinteger(L, 2); - uint16 result = FCEU_CheatGetByte(addressLow) | (FCEU_CheatGetByte(addressHigh) << 8); - return isSigned ? (int16)result : result; -} - -static int memory_readword(lua_State *L) -{ - lua_pushinteger(L, GetWord(L, false)); - return 1; -} - -static int memory_readwordsigned(lua_State *L) { - lua_pushinteger(L, GetWord(L, true)); - return 1; -} - -static int memory_writebyte(lua_State *L) { - FCEU_CheatSetByte(luaL_checkinteger(L,1), luaL_checkinteger(L,2)); - return 0; -} - -static int memory_readbyterange(lua_State *L) { - - int range_start = luaL_checkinteger(L,1); - int range_size = luaL_checkinteger(L,2); - if(range_size < 0) - return 0; - - char* buf = (char*)alloca(range_size); - for(int i=0;i= 0) { ptr += _n; remaining -= _n; } else { remaining = 0; } } -static void toCStringConverter(lua_State* L, int i, char*& ptr, int& remaining) -{ - if(remaining <= 0) - return; - - const char* str = ptr; // for debugging - - // if there is a __tostring metamethod then call it - int usedMeta = luaL_callmeta(L, i, "__tostring"); - if(usedMeta) - { - std::vector::const_iterator foundCycleIter = std::find(s_metacallStack.begin(), s_metacallStack.end(), lua_topointer(L,i)); - if(foundCycleIter != s_metacallStack.end()) - { - lua_pop(L, 1); - usedMeta = false; - } - else - { - s_metacallStack.push_back(lua_topointer(L,i)); - i = lua_gettop(L); - } - } - - switch(lua_type(L, i)) - { - case LUA_TNONE: break; - case LUA_TNIL: APPENDPRINT "nil" END break; - case LUA_TBOOLEAN: APPENDPRINT lua_toboolean(L,i) ? "true" : "false" END break; - case LUA_TSTRING: APPENDPRINT "%s",lua_tostring(L,i) END break; - case LUA_TNUMBER: APPENDPRINT "%.12Lg",lua_tonumber(L,i) END break; - case LUA_TFUNCTION: - /*if((L->base + i-1)->value.gc->cl.c.isC) - { - //lua_CFunction func = lua_tocfunction(L, i); - //std::map::iterator iter = s_cFuncInfoMap.find(func); - //if(iter == s_cFuncInfoMap.end()) - goto defcase; - //APPENDPRINT "function(%s)", iter->second END - } - else - { - APPENDPRINT "function(" END - Proto* p = (L->base + i-1)->value.gc->cl.l.p; - int numParams = p->numparams + (p->is_vararg?1:0); - for (int n=0; nnumparams; n++) - { - APPENDPRINT "%s", getstr(p->locvars[n].varname) END - if(n != numParams-1) - APPENDPRINT "," END - } - if(p->is_vararg) - APPENDPRINT "..." END - APPENDPRINT ")" END - }*/ - goto defcase; - break; -defcase:default: APPENDPRINT "%s:%p",luaL_typename(L,i),lua_topointer(L,i) END break; - case LUA_TTABLE: - { - // first make sure there's enough stack space - if(!lua_checkstack(L, 4)) - { - // note that even if lua_checkstack never returns false, - // that doesn't mean we didn't need to call it, - // because calling it retrieves stack space past LUA_MINSTACK - goto defcase; - } - - std::vector::const_iterator foundCycleIter = std::find(s_tableAddressStack.begin(), s_tableAddressStack.end(), lua_topointer(L,i)); - if(foundCycleIter != s_tableAddressStack.end()) - { - int parentNum = s_tableAddressStack.end() - foundCycleIter; - if(parentNum > 1) - APPENDPRINT "%s:parent^%d",luaL_typename(L,i),parentNum END - else - APPENDPRINT "%s:parent",luaL_typename(L,i) END - } - else - { - s_tableAddressStack.push_back(lua_topointer(L,i)); - struct Scope { ~Scope(){ s_tableAddressStack.pop_back(); } } scope; - - APPENDPRINT "{" END - - lua_pushnil(L); // first key - int keyIndex = lua_gettop(L); - int valueIndex = keyIndex + 1; - bool first = true; - bool skipKey = true; // true if we're still in the "array part" of the table - lua_Number arrayIndex = (lua_Number)0; - while(lua_next(L, i)) - { - if(first) - first = false; - else - APPENDPRINT ", " END - if(skipKey) - { - arrayIndex += (lua_Number)1; - bool keyIsNumber = (lua_type(L, keyIndex) == LUA_TNUMBER); - skipKey = keyIsNumber && (lua_tonumber(L, keyIndex) == arrayIndex); - } - if(!skipKey) - { - bool keyIsString = (lua_type(L, keyIndex) == LUA_TSTRING); - bool invalidLuaIdentifier = (!keyIsString || !isalphaorunderscore(*lua_tostring(L, keyIndex))); - if(invalidLuaIdentifier) - if(keyIsString) - APPENDPRINT "['" END - else - APPENDPRINT "[" END - - toCStringConverter(L, keyIndex, ptr, remaining); // key - - if(invalidLuaIdentifier) - if(keyIsString) - APPENDPRINT "']=" END - else - APPENDPRINT "]=" END - else - APPENDPRINT "=" END - } - - bool valueIsString = (lua_type(L, valueIndex) == LUA_TSTRING); - if(valueIsString) - APPENDPRINT "'" END - - toCStringConverter(L, valueIndex, ptr, remaining); // value - - if(valueIsString) - APPENDPRINT "'" END - - lua_pop(L, 1); - - if(remaining <= 0) - { - lua_settop(L, keyIndex-1); // stack might not be clean yet if we're breaking early - break; - } - } - APPENDPRINT "}" END - } - } break; - } - - if(usedMeta) - { - s_metacallStack.pop_back(); - lua_pop(L, 1); - } -} - -static const int s_tempStrMaxLen = 64 * 1024; -static char s_tempStr [s_tempStrMaxLen]; - -static char* rawToCString(lua_State* L, int idx) -{ - int a = idx>0 ? idx : 1; - int n = idx>0 ? idx : lua_gettop(L); - - char* ptr = s_tempStr; - *ptr = 0; - - int remaining = s_tempStrMaxLen; - for(int i = a; i <= n; i++) - { - toCStringConverter(L, i, ptr, remaining); - if(i != n) - APPENDPRINT " " END - } - - if(remaining < 3) - { - while(remaining < 6) - remaining++, ptr--; - APPENDPRINT "..." END - } - APPENDPRINT "\r\n" END - // the trailing newline is so print() can avoid having to do wasteful things to print its newline - // (string copying would be wasteful and calling info.print() twice can be extremely slow) - // at the cost of functions that don't want the newline needing to trim off the last two characters - // (which is a very fast operation and thus acceptable in this case) - - return s_tempStr; -} -#undef APPENDPRINT -#undef END - - -// replacement for luaB_tostring() that is able to show the contents of tables (and formats numbers better, and show function prototypes) -// can be called directly from lua via tostring(), assuming tostring hasn't been reassigned -static int tostring(lua_State *L) -{ - char* str = rawToCString(L); - str[strlen(str)-2] = 0; // hack: trim off the \r\n (which is there to simplify the print function's task) - lua_pushstring(L, str); - return 1; -} - -// tobitstring(int value) -// -// Converts byte to binary string -static int tobitstring(lua_State *L) -{ - std::bitset<8> bits (luaL_checkinteger(L, 1)); - std::string temp = bits.to_string().insert(4, " "); - const char * result = temp.c_str(); - lua_pushstring(L,result); - return 1; -} - -// like rawToCString, but will check if the global Lua function tostring() -// has been replaced with a custom function, and call that instead if so -static const char* toCString(lua_State* L, int idx) -{ - int a = idx>0 ? idx : 1; - int n = idx>0 ? idx : lua_gettop(L); - lua_getglobal(L, "tostring"); - lua_CFunction cf = lua_tocfunction(L,-1); - if(cf == tostring) // optimization: if using our own C tostring function, we can bypass the call through Lua and all the string object allocation that would entail - { - lua_pop(L,1); - return rawToCString(L, idx); - } - else // if the user overrided the tostring function, we have to actually call it and store the temporarily allocated string it returns - { - lua_pushstring(L, ""); - for (int i=a; i<=n; i++) { - lua_pushvalue(L, -2); // function to be called - lua_pushvalue(L, i); // value to print - lua_call(L, 1, 1); - if(lua_tostring(L, -1) == NULL) - luaL_error(L, LUA_QL("tostring") " must return a string to " LUA_QL("print")); - lua_pushstring(L, (il_G->mainthread]; - //LuaContextInfo& info = GetCurrentInfo(); - - if(info_print) - info_print(uid, str); - else - puts(str); - - //worry(L, 100); - return 0; -} - -// provides an easy way to copy a table from Lua -// (simple assignment only makes an alias, but sometimes an independent table is desired) -// currently this function only performs a shallow copy, -// but I think it should be changed to do a deep copy (possibly of configurable depth?) -// that maintains the internal table reference structure -static int copytable(lua_State *L) -{ - int origIndex = 1; // we only care about the first argument - int origType = lua_type(L, origIndex); - if(origType == LUA_TNIL) - { - lua_pushnil(L); - return 1; - } - if(origType != LUA_TTABLE) - { - luaL_typerror(L, 1, lua_typename(L, LUA_TTABLE)); - lua_pushnil(L); - return 1; - } - - lua_createtable(L, lua_objlen(L,1), 0); - int copyIndex = lua_gettop(L); - - lua_pushnil(L); // first key - int keyIndex = lua_gettop(L); - int valueIndex = keyIndex + 1; - - while(lua_next(L, origIndex)) - { - lua_pushvalue(L, keyIndex); - lua_pushvalue(L, valueIndex); - lua_rawset(L, copyIndex); // copytable[key] = value - lua_pop(L, 1); - } - - // copy the reference to the metatable as well, if any - if(lua_getmetatable(L, origIndex)) - lua_setmetatable(L, copyIndex); - - return 1; // return the new table -} - -// because print traditionally shows the address of tables, -// and the print function I provide instead shows the contents of tables, -// I also provide this function -// (otherwise there would be no way to see a table's address, AFAICT) -static int addressof(lua_State *L) -{ - const void* ptr = lua_topointer(L,-1); - lua_pushinteger(L, (lua_Integer)ptr); - return 1; -} - -struct registerPointerMap -{ - const char* registerName; - unsigned int* pointer; - int dataSize; -}; - -#define RPM_ENTRY(name,var) {name, (unsigned int*)&var, sizeof(var)}, - -registerPointerMap regPointerMap [] = { - RPM_ENTRY("pc", _PC) - RPM_ENTRY("a", _A) - RPM_ENTRY("x", _X) - RPM_ENTRY("y", _Y) - RPM_ENTRY("s", _S) - RPM_ENTRY("p", _P) - {} -}; - -struct cpuToRegisterMap -{ - const char* cpuName; - registerPointerMap* rpmap; -} -cpuToRegisterMaps [] = -{ - {"", regPointerMap}, -}; - - -//DEFINE_LUA_FUNCTION(memory_getregister, "cpu_dot_registername_string") -static int memory_getregister(lua_State *L) -{ - const char* qualifiedRegisterName = luaL_checkstring(L,1); - lua_settop(L,0); - for(int cpu = 0; cpu < sizeof(cpuToRegisterMaps)/sizeof(*cpuToRegisterMaps); cpu++) - { - cpuToRegisterMap ctrm = cpuToRegisterMaps[cpu]; - int cpuNameLen = strlen(ctrm.cpuName); - if(!strnicmp(qualifiedRegisterName, ctrm.cpuName, cpuNameLen)) - { - qualifiedRegisterName += cpuNameLen; - for(int reg = 0; ctrm.rpmap[reg].dataSize; reg++) - { - registerPointerMap rpm = ctrm.rpmap[reg]; - if(!stricmp(qualifiedRegisterName, rpm.registerName)) - { - switch(rpm.dataSize) - { default: - case 1: lua_pushinteger(L, *(unsigned char*)rpm.pointer); break; - case 2: lua_pushinteger(L, *(unsigned short*)rpm.pointer); break; - case 4: lua_pushinteger(L, *(unsigned long*)rpm.pointer); break; - } - return 1; - } - } - lua_pushnil(L); - return 1; - } - } - lua_pushnil(L); - return 1; -} -//DEFINE_LUA_FUNCTION(memory_setregister, "cpu_dot_registername_string,value") -static int memory_setregister(lua_State *L) -{ - const char* qualifiedRegisterName = luaL_checkstring(L,1); - unsigned long value = (unsigned long)(luaL_checkinteger(L,2)); - lua_settop(L,0); - for(int cpu = 0; cpu < sizeof(cpuToRegisterMaps)/sizeof(*cpuToRegisterMaps); cpu++) - { - cpuToRegisterMap ctrm = cpuToRegisterMaps[cpu]; - int cpuNameLen = strlen(ctrm.cpuName); - if(!strnicmp(qualifiedRegisterName, ctrm.cpuName, cpuNameLen)) - { - qualifiedRegisterName += cpuNameLen; - for(int reg = 0; ctrm.rpmap[reg].dataSize; reg++) - { - registerPointerMap rpm = ctrm.rpmap[reg]; - if(!stricmp(qualifiedRegisterName, rpm.registerName)) - { - switch(rpm.dataSize) - { default: - case 1: *(unsigned char*)rpm.pointer = (unsigned char)(value & 0xFF); break; - case 2: *(unsigned short*)rpm.pointer = (unsigned short)(value & 0xFFFF); break; - case 4: *(unsigned long*)rpm.pointer = value; break; - } - return 0; - } - } - return 0; - } - } - return 0; -} - - -void HandleCallbackError(lua_State* L) -{ - //if(L->errfunc || L->errorJmp) - // luaL_error(L, "%s", lua_tostring(L,-1)); - //else - { - lua_pushnil(L); - lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); - - // Error? -#ifdef WIN32 - MessageBox( hAppWnd, lua_tostring(L,-1), "Lua run error", MB_OK | MB_ICONSTOP); -#else - fprintf(stderr, "Lua thread bombed out: %s\n", lua_tostring(L,-1)); -#endif - - FCEU_LuaStop(); - } -} - - -// the purpose of this structure is to provide a way of -// QUICKLY determining whether a memory address range has a hook associated with it, -// with a bias toward fast rejection because the majority of addresses will not be hooked. -// (it must not use any part of Lua or perform any per-script operations, -// otherwise it would definitely be too slow.) -// calculating the regions when a hook is added/removed may be slow, -// but this is an intentional tradeoff to obtain a high speed of checking during later execution -struct TieredRegion -{ - template - struct Region - { - struct Island - { - unsigned int start; - unsigned int end; -#ifdef NEED_MINGW_HACKS - bool Contains(unsigned int address, int size) const { return address < end && address+size > start; } -#else - __forceinline bool Contains(unsigned int address, int size) const { return address < end && address+size > start; } -#endif - }; - std::vector islands; - - void Calculate(const std::vector& bytes) - { - islands.clear(); - - unsigned int lastEnd = ~0; - - std::vector::const_iterator iter = bytes.begin(); - std::vector::const_iterator end = bytes.end(); - for(; iter != end; ++iter) - { - unsigned int addr = *iter; - if(addr < lastEnd || addr > lastEnd + (long long)maxGap) - { - islands.push_back(Island()); - islands.back().start = addr; - } - islands.back().end = addr+1; - lastEnd = addr+1; - } - } - bool Contains(unsigned int address, int size) const - { - for (size_t i = 0; i != islands.size(); ++i) - { - if (islands[i].Contains(address, size)) - return true; - } - return false; - } - }; - - Region<0xFFFFFFFF> broad; - Region<0x1000> mid; - Region<0> narrow; - - void Calculate(std::vector& bytes) - { - std::sort(bytes.begin(), bytes.end()); - - broad.Calculate(bytes); - mid.Calculate(bytes); - narrow.Calculate(bytes); - } - - TieredRegion() - { - std::vector temp; - Calculate(temp); - } - - __forceinline int NotEmpty() - { - return broad.islands.size(); - } - - // note: it is illegal to call this if NotEmpty() returns 0 - __forceinline bool Contains(unsigned int address, int size) - { - return broad.islands[0].Contains(address,size) && - mid.Contains(address,size) && - narrow.Contains(address,size); - } -}; -TieredRegion hookedRegions [LUAMEMHOOK_COUNT]; - - -static void CalculateMemHookRegions(LuaMemHookType hookType) -{ - std::vector hookedBytes; -// std::map::iterator iter = luaContextInfo.begin(); -// std::map::iterator end = luaContextInfo.end(); -// while(iter != end) -// { -// LuaContextInfo& info = *iter->second; - if(/*info.*/ numMemHooks) - { -// lua_State* L = info.L; - if(L) - { - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]); - lua_pushnil(L); - while(lua_next(L, -2)) - { - if(lua_isfunction(L, -1)) - { - unsigned int addr = lua_tointeger(L, -2); - hookedBytes.push_back(addr); - } - lua_pop(L, 1); - } - lua_settop(L, 0); - } - } -// ++iter; -// } - hookedRegions[hookType].Calculate(hookedBytes); -} - -static void CallRegisteredLuaMemHook_LuaMatch(unsigned int address, int size, unsigned int value, LuaMemHookType hookType) -{ -// std::map::iterator iter = luaContextInfo.begin(); -// std::map::iterator end = luaContextInfo.end(); -// while(iter != end) -// { -// LuaContextInfo& info = *iter->second; - if(/*info.*/ numMemHooks) - { -// lua_State* L = info.L; - if(L/* && !info.panic*/) - { -#ifdef USE_INFO_STACK - infoStack.insert(infoStack.begin(), &info); - struct Scope { ~Scope(){ infoStack.erase(infoStack.begin()); } } scope; -#endif - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]); - for(int i = address; i != address+size; i++) - { - lua_rawgeti(L, -1, i); - if (lua_isfunction(L, -1)) - { - bool wasRunning = (luaRunning!=0) /*info.running*/; - luaRunning /*info.running*/ = true; - //RefreshScriptSpeedStatus(); - lua_pushinteger(L, address); - lua_pushinteger(L, size); - int errorcode = lua_pcall(L, 2, 0, 0); - luaRunning /*info.running*/ = wasRunning; - //RefreshScriptSpeedStatus(); - if (errorcode) - { - HandleCallbackError(L); - //int uid = iter->first; - //HandleCallbackError(L,info,uid,true); - } - break; - } - else - { - lua_pop(L,1); - } - } - lua_settop(L, 0); - } - } -// ++iter; -// } -} -void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType) -{ - // performance critical! (called VERY frequently) - // I suggest timing a large number of calls to this function in Release if you change anything in here, - // before and after, because even the most innocent change can make it become 30% to 400% slower. - // a good amount to test is: 100000000 calls with no hook set, and another 100000000 with a hook set. - // (on my system that consistently took 200 ms total in the former case and 350 ms total in the latter case) - if(hookedRegions[hookType].NotEmpty()) - { - //if((hookType <= LUAMEMHOOK_EXEC) && (address >= 0xE00000)) - // address |= 0xFF0000; // account for mirroring of RAM - if(hookedRegions[hookType].Contains(address, size)) - CallRegisteredLuaMemHook_LuaMatch(address, size, value, hookType); // something has hooked this specific address - } -} - -void CallRegisteredLuaFunctions(LuaCallID calltype) -{ - assert((unsigned int)calltype < (unsigned int)LUACALL_COUNT); - const char* idstring = luaCallIDStrings[calltype]; - - if (!L) - return; - - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, idstring); - - int errorcode = 0; - if (lua_isfunction(L, -1)) - { - errorcode = lua_pcall(L, 0, 0, 0); - if (errorcode) - HandleCallbackError(L); - } - else - { - lua_pop(L, 1); - } -} - -void ForceExecuteLuaFrameFunctions() -{ - FCEU_LuaFrameBoundary(); - CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); - CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); -} - -void TaseditorAutoFunction() -{ - CallRegisteredLuaFunctions(LUACALL_TASEDITOR_AUTO); -} - -void TaseditorManualFunction() -{ - CallRegisteredLuaFunctions(LUACALL_TASEDITOR_MANUAL); -} - -#ifdef WIN32 -void TaseditorDisableManualFunctionIfNeeded() -{ - if (L) - { - // check if LUACALL_TASEDITOR_MANUAL function is not nil - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); - if (!lua_isfunction(L, -1)) - taseditor_lua.disableRunFunction(); - lua_pop(L, 1); - } else taseditor_lua.disableRunFunction(); -} -#endif - -static int memory_registerHook(lua_State* L, LuaMemHookType hookType, int defaultSize) -{ - // get first argument: address - unsigned int addr = luaL_checkinteger(L,1); - //if((addr & ~0xFFFFFF) == ~0xFFFFFF) - // addr &= 0xFFFFFF; - - // get optional second argument: size - int size = defaultSize; - int funcIdx = 2; - if(lua_isnumber(L,2)) - { - size = luaL_checkinteger(L,2); - if(size < 0) - { - size = -size; - addr -= size; - } - funcIdx++; - } - - // check last argument: callback function - bool clearing = lua_isnil(L,funcIdx); - if(!clearing) - luaL_checktype(L, funcIdx, LUA_TFUNCTION); - lua_settop(L,funcIdx); - - // get the address-to-callback table for this hook type of the current script - lua_getfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[hookType]); - - // count how many callback functions we'll be displacing - int numFuncsAfter = clearing ? 0 : size; - int numFuncsBefore = 0; - for(unsigned int i = addr; i != addr+size; i++) - { - lua_rawgeti(L, -1, i); - if(lua_isfunction(L, -1)) - numFuncsBefore++; - lua_pop(L,1); - } - - // put the callback function in the address slots - for(unsigned int i = addr; i != addr+size; i++) - { - lua_pushvalue(L, -2); - lua_rawseti(L, -2, i); - } - - // adjust the count of active hooks - //LuaContextInfo& info = GetCurrentInfo(); - /*info.*/ numMemHooks += numFuncsAfter - numFuncsBefore; - - // re-cache regions of hooked memory across all scripts - CalculateMemHookRegions(hookType); - - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 0; -} - -LuaMemHookType MatchHookTypeToCPU(lua_State* L, LuaMemHookType hookType) -{ - int cpuID = 0; - - int cpunameIndex = 0; - if(lua_type(L,2) == LUA_TSTRING) - cpunameIndex = 2; - else if(lua_type(L,3) == LUA_TSTRING) - cpunameIndex = 3; - - if(cpunameIndex) - { - const char* cpuName = lua_tostring(L, cpunameIndex); - if(!stricmp(cpuName, "sub")) - cpuID = 1; - lua_remove(L, cpunameIndex); - } - - switch(cpuID) - { - case 0: - return hookType; - - case 1: - switch(hookType) - { - case LUAMEMHOOK_WRITE: return LUAMEMHOOK_WRITE_SUB; - case LUAMEMHOOK_READ: return LUAMEMHOOK_READ_SUB; - case LUAMEMHOOK_EXEC: return LUAMEMHOOK_EXEC_SUB; - } - } - return hookType; -} - -static int memory_registerwrite(lua_State *L) -{ - return memory_registerHook(L, MatchHookTypeToCPU(L,LUAMEMHOOK_WRITE), 1); -} -static int memory_registerread(lua_State *L) -{ - return memory_registerHook(L, MatchHookTypeToCPU(L,LUAMEMHOOK_READ), 1); -} -static int memory_registerexec(lua_State *L) -{ - return memory_registerHook(L, MatchHookTypeToCPU(L,LUAMEMHOOK_EXEC), 1); -} - -//adelikat: table pulled from GENS. credz nitsuja! - -#ifdef WIN32 -const char* s_keyToName[256] = -{ - NULL, - "leftclick", - "rightclick", - NULL, - "middleclick", - NULL, - NULL, - NULL, - "backspace", - "tab", - NULL, - NULL, - NULL, - "enter", - NULL, - NULL, - "shift", // 0x10 - "control", - "alt", - "pause", - "capslock", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - "escape", - NULL, - NULL, - NULL, - NULL, - "space", // 0x20 - "pageup", - "pagedown", - "end", - "home", - "left", - "up", - "right", - "down", - NULL, - NULL, - NULL, - NULL, - "insert", - "delete", - NULL, - "0","1","2","3","4","5","6","7","8","9", - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - "A","B","C","D","E","F","G","H","I","J", - "K","L","M","N","O","P","Q","R","S","T", - "U","V","W","X","Y","Z", - NULL, - NULL, - NULL, - NULL, - NULL, - "numpad0","numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9", - "numpad*","numpad+", - NULL, - "numpad-","numpad.","numpad/", - "F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12", - "F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - "numlock", - "scrolllock", - NULL, // 0x92 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, // 0xB9 - "semicolon", - "plus", - "comma", - "minus", - "period", - "slash", - "tilde", - NULL, // 0xC1 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, // 0xDA - "leftbracket", - "backslash", - "rightbracket", - "quote", -}; -#endif - -//adelikat - the code for the keys is copied directly from GENS. Props to nitsuja -// the code for the mouse is simply the same code from zapper.get -// input.get() -// takes no input, returns a lua table of entries representing the current input state, -// independent of the joypad buttons the emulated game thinks are pressed -// for example: -// if the user is holding the W key and the left mouse button -// and has the mouse at the bottom-right corner of the game screen, -// then this would return {W=true, leftclick=true, xmouse=319, ymouse=223} -static int input_get(lua_State *L) { - lua_newtable(L); - -#ifdef WIN32 - // keyboard and mouse button status - { - extern int EnableBackgroundInput; - unsigned char keys [256]; - if(!EnableBackgroundInput) - { - if(GetKeyboardState(keys)) - { - for(int i = 1; i < 255; i++) - { - int mask = (i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL) ? 0x01 : 0x80; - if(keys[i] & mask) - { - const char* name = s_keyToName[i]; - if(name) - { - lua_pushboolean(L, true); - lua_setfield(L, -2, name); - } - } - } - } - } - else // use a slightly different method that will detect background input: - { - for(int i = 1; i < 255; i++) - { - const char* name = s_keyToName[i]; - if(name) - { - int active; - if(i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL) - active = GetKeyState(i) & 0x01; - else - active = GetAsyncKeyState(i) & 0x8000; - if(active) - { - lua_pushboolean(L, true); - lua_setfield(L, -2, name); - } - } - } - } - } -#else - //SDL TODO: implement this for keyboard!! -#endif - - // mouse position in game screen pixel coordinates - - extern void GetMouseData(uint32 (&md)[3]); - - uint32 MouseData[3]; - GetMouseData (MouseData); - int x = MouseData[0]; - int y = MouseData[1]; - int click = MouseData[2]; ///adelikat TODO: remove the ability to store the value 2? Since 2 is right-clicking and not part of zapper input and is used for context menus - - lua_pushinteger(L, x); - lua_setfield(L, -2, "xmouse"); - lua_pushinteger(L, y); - lua_setfield(L, -2, "ymouse"); - lua_pushinteger(L, click); - lua_setfield(L, -2, "click"); - - return 1; -} - -// table zapper.read -//int which unecessary because zapper is always controller 2 -//Reads the zapper coordinates and a click value (1 if clicked, 0 if not, 2 if right click (but this is not used for zapper input) -static int zapper_read(lua_State *L){ - - lua_newtable(L); - int z = 0; - extern void GetMouseData(uint32 (&md)[3]); //adelikat: shouldn't this be ifdef'ed for Win32? - int x,y,click; - if (FCEUMOV_Mode(MOVIEMODE_PLAY)) - { - if (!currFrameCounter) - z = 0; - else - z = currFrameCounter -1; - - x = currMovieData.records[z].zappers[1].x; //adelikat: Used hardcoded port 1 since as far as I know, only port 1 is valid for zappers - y = currMovieData.records[z].zappers[1].y; - click = currMovieData.records[z].zappers[1].b; - } - else - { - uint32 MouseData[3]; - GetMouseData (MouseData); - x = MouseData[0]; - y = MouseData[1]; - click = MouseData[2]; - if (click > 1) - click = 1; //adelikat: This is zapper.read() thus should only give valid zapper input (instead of simply mouse input - } - lua_pushinteger(L, x); - lua_setfield(L, -2, "x"); - lua_pushinteger(L, y); - lua_setfield(L, -2, "y"); - lua_pushinteger(L, click); - lua_setfield(L, -2, "fire"); - return 1; -} - - - -// table joypad.read(int which = 1) -// -// Reads the joypads as inputted by the user. -// TODO: Don't read in *everything*... -static int joy_get_internal(lua_State *L, bool reportUp, bool reportDown) { - - // Reads the joypads as inputted by the user - int which = luaL_checkinteger(L,1); - - if (which < 1 || which > 4) { - luaL_error(L,"Invalid input port (valid range 1-4, specified %d)", which); - } - - // Use the OS-specific code to do the reading. - extern SFORMAT FCEUCTRL_STATEINFO[]; - uint8 buttons = ((uint8 *) FCEUCTRL_STATEINFO[1].v)[which - 1]; - - lua_newtable(L); - - int i; - for (i = 0; i < 8; i++) { - bool pressed = (buttons & (1< 4) - { - luaL_error(L,"Invalid input port (valid range 1-4, specified %d)", which); - } - // Currently only supports Windows, sorry... -#ifdef WIN32 - extern uint32 GetGamepadPressedImmediate(); - uint8 buttons = GetGamepadPressedImmediate() >> ((which - 1) * 8); - - lua_newtable(L); - for (int i = 0; i < 8; ++i) - { - lua_pushboolean(L, (buttons & (1 << i)) != 0); - lua_setfield(L, -2, button_mappings[i]); - } -#else - lua_pushnil(L); -#endif - return 1; -} - - -// joypad.set(int which, table buttons) -// -// Sets the given buttons to be pressed during the next -// frame advance. The table should have the right -// keys (no pun intended) set. -/*FatRatKnight: I changed some of the logic. - Now with 4 options!*/ -static int joypad_set(lua_State *L) { - - // Which joypad we're tampering with - int which = luaL_checkinteger(L,1); - if (which < 1 || which > 4) { - luaL_error(L,"Invalid output port (valid range 1-4, specified %d)", which); - - } - - // And the table of buttons. - luaL_checktype(L,2,LUA_TTABLE); - - // Set up for taking control of the indicated controller - luajoypads1[which-1] = 0xFF; // .1 Reset right bit - luajoypads2[which-1] = 0x00; // 0. Reset left bit - - int i; - for (i=0; i < 8; i++) { - lua_getfield(L, 2, button_mappings[i]); - - //Button is not nil, so find out if it is true/false - if (!lua_isnil(L,-1)) - { - if (lua_toboolean(L,-1)) //True or string - luajoypads2[which-1] |= 1 << i; - if (lua_toboolean(L,-1) == 0 || lua_isstring(L,-1)) //False or string - luajoypads1[which-1] &= ~(1 << i); - } - - else - { - - } - lua_pop(L,1); - } - - return 0; -} - -// Helper function to convert a savestate object to the filename it represents. -static const char *savestateobj2filename(lua_State *L, int offset) { - - // First we get the metatable of the indicated object - int result = lua_getmetatable(L, offset); - - if (!result) - luaL_error(L, "object not a savestate object"); - - // Also check that the type entry is set - lua_getfield(L, -1, "__metatable"); - if (strcmp(lua_tostring(L,-1), "FCEU Savestate") != 0) - luaL_error(L, "object not a savestate object"); - lua_pop(L,1); - - // Now, get the field we want - lua_getfield(L, -1, "filename"); - - // Return it - return lua_tostring(L, -1); -} - -// Helper function for garbage collection. -static int savestate_gc(lua_State *L) { - - LuaSaveState *ss = (LuaSaveState *)lua_touserdata(L, 1); - if(ss->persisted && ss->anonymous) - remove(ss->filename.c_str()); - ss->~LuaSaveState(); - - //// The object we're collecting is on top of the stack - //lua_getmetatable(L,1); - // - //// Get the filename - //const char *filename; - //lua_getfield(L, -1, "filename"); - //filename = lua_tostring(L,-1); - - //// Delete the file - //remove(filename); - // - - // We exit, and the garbage collector takes care of the rest. - return 0; -} - -// Referenced by: -// savestate.create(int which = nil) -// savestate.object(int which = nil) -// -// Creates an object used for savestates. -// The object can be associated with a player-accessible savestate -// ("which" between 1 and 10) or not (which == nil). -static int savestate_create_aliased(lua_State *L, bool newnumbering) { - int which = -1; - if (lua_gettop(L) >= 1) { - which = luaL_checkinteger(L, 1); - if (which < 1 || which > 10) { - luaL_error(L, "invalid player's savestate %d", which); - } - } - - //lets use lua to allocate the memory, since it is effectively a memory pool. - LuaSaveState *ss = new(lua_newuserdata(L,sizeof(LuaSaveState))) LuaSaveState(); - - if (which > 0) { - // Find an appropriate filename. This is OS specific, unfortunately. - // So I turned the filename selection code into my bitch. :) - // Numbers are 0 through 9. - if (newnumbering) //1-9, 10 = 0. QWERTY style. - ss->filename = FCEU_MakeFName(FCEUMKF_STATE, (which % 10), 0); - else // Note: Windows Slots 1-10 = Which 2-10, 1 - ss->filename = FCEU_MakeFName(FCEUMKF_STATE, which - 1, 0); - - // Only ensure load if the file exists - // Also makes it persistent, but files are like that - if (CheckFileExists(ss->filename.c_str())) - ss->ensureLoad(); - - } - else { - //char tempbuf[100] = "snluaXXXXXX"; - //filename = mktemp(tempbuf); - //doesnt work -^ - - //mbg 8/13/08 - this needs to be this way. we'll make a better system later: - ss->filename = tempnam(NULL, "snlua"); - ss->anonymous = true; - } - - - // The metatable we use, protected from Lua and contains garbage collection info and stuff. - lua_newtable(L); - - //// First, we must protect it - lua_pushstring(L, "FCEU Savestate"); - lua_setfield(L, -2, "__metatable"); - // - // - //// Now we need to save the file itself. - //lua_pushstring(L, filename.c_str()); - //lua_setfield(L, -2, "filename"); - - // If it's an anonymous savestate, we must delete the file from disk should it be gargage collected - //if (which < 0) { - lua_pushcfunction(L, savestate_gc); - lua_setfield(L, -2, "__gc"); - //} - - // Set the metatable - lua_setmetatable(L, -2); - - // Awesome. Return the object - return 1; -} - -// object savestate.object(int which = nil) -// -// Creates an object used for savestates. -// The object can be associated with a player-accessible savestate -// ("which" between 1 and 10) or not (which == nil). -// Uses more windows-friendly slot numbering -static int savestate_object(lua_State *L) { - // New Save Slot Numbers: - // 1-9 refer to 1-9, 10 refers to 0. QWERTY style. - return savestate_create_aliased(L,true); -} - -// object savestate.create(int which = nil) -// -// Creates an object used for savestates. -// The object can be associated with a player-accessible savestate -// ("which" between 1 and 10) or not (which == nil). -// Uses original slot numbering -static int savestate_create(lua_State *L) { - // Original Save Slot Numbers: - // 1-10, 1 refers to slot 0, 2-10 refer to 1-9 - return savestate_create_aliased(L,false); -} - - -// savestate.save(object state) -// -// Saves a state to the given object. -static int savestate_save(lua_State *L) { - - //char *filename = savestateobj2filename(L,1); - - LuaSaveState *ss = (LuaSaveState *)lua_touserdata(L, 1); - if (!ss) { - luaL_error(L, "Invalid savestate.save object"); - return 0; - } - - if(ss->data) delete ss->data; - ss->data = new EMUFILE_MEMORY(); - -// printf("saving %s\n", filename); - - // Save states are very expensive. They take time. - numTries--; - - FCEUSS_SaveMS(ss->data,Z_NO_COMPRESSION); - ss->data->fseek(0,SEEK_SET); - return 0; -} - -static int savestate_persist(lua_State *L) { - - LuaSaveState *ss = (LuaSaveState *)lua_touserdata(L, 1); - ss->persist(); - return 0; -} - -// savestate.load(object state) -// -// Loads the given state -static int savestate_load(lua_State *L) { - - //char *filename = savestateobj2filename(L,1); - - LuaSaveState *ss = (LuaSaveState *)lua_touserdata(L, 1); - - if (!ss) { - luaL_error(L, "Invalid savestate.load object"); - return 0; - } - - numTries--; - - /*if (!ss->data) { - luaL_error(L, "Invalid savestate.load data"); - return 0; - } */ - if (FCEUSS_LoadFP(ss->data,SSLOADPARAM_NOBACKUP)) - ss->data->fseek(0,SEEK_SET); - - return 0; - -} - -static int savestate_registersave(lua_State *L) { - - lua_settop(L,1); - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFORESAVE]); - lua_pushvalue(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFORESAVE]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} -static int savestate_registerload(lua_State *L) { - - lua_settop(L,1); - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTERLOAD]); - lua_pushvalue(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_AFTERLOAD]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} - -static int savestate_loadscriptdata(lua_State *L) { - - const char *filename = savestateobj2filename(L,1); - - { - LuaSaveData saveData; - - char luaSaveFilename [512]; - strncpy(luaSaveFilename, filename, 512); - luaSaveFilename[512-(1+7/*strlen(".luasav")*/)] = '\0'; - strcat(luaSaveFilename, ".luasav"); - FILE* luaSaveFile = fopen(luaSaveFilename, "rb"); - if(luaSaveFile) - { - saveData.ImportRecords(luaSaveFile); - fclose(luaSaveFile); - - lua_settop(L, 0); - saveData.LoadRecord(L, LUA_DATARECORDKEY, (unsigned int)-1); - return lua_gettop(L); - } - } - return 0; -} - - -// int emu.framecount() -// -// Gets the frame counter -int emu_framecount(lua_State *L) { - - lua_pushinteger(L, FCEUMOV_GetFrame()); - return 1; -} - -// int emu.lagcount() -// -// Gets the current lag count -int emu_lagcount(lua_State *L) { - - lua_pushinteger(L, FCEUI_GetLagCount()); - return 1; -} - -// emu.lagged() -// -// Returns true if the game is currently on a lag frame -int emu_lagged (lua_State *L) { - - bool Lag_Frame = FCEUI_GetLagged(); - lua_pushboolean(L, Lag_Frame); - return 1; -} - -// emu.setlagflag(bool value) -// -// Returns true if the game is currently on a lag frame -int emu_setlagflag(lua_State *L) -{ - FCEUI_SetLagFlag(lua_toboolean(L, 1) == 1); - return 0; -} - -// boolean emu.emulating() -int emu_emulating(lua_State *L) { - lua_pushboolean(L, GameInfo != NULL); - return 1; -} - -// string movie.mode() -// -// Returns "taseditor", "record", "playback", "finished" or nil -int movie_mode(lua_State *L) -{ - if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - lua_pushstring(L, "taseditor"); - else if (FCEUMOV_IsRecording()) - lua_pushstring(L, "record"); - else if (FCEUMOV_IsFinished()) - lua_pushstring(L, "finished"); //Note: this comes before playback since playback checks for finished as well - else if (FCEUMOV_IsPlaying()) - lua_pushstring(L, "playback"); - else - lua_pushnil(L); - return 1; -} - - -static int movie_rerecordcounting(lua_State *L) { - if (lua_gettop(L) == 0) - luaL_error(L, "no parameters specified"); - - skipRerecords = lua_toboolean(L,1); - return 0; -} - -// movie.stop() -// -// Stops movie playback/recording. Bombs out if movie is not running. -static int movie_stop(lua_State *L) { - if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying()) - luaL_error(L, "no movie"); - - FCEUI_StopMovie(); - return 0; - -} - -// movie.active() -// -//returns a bool value is there is a movie currently open -int movie_isactive (lua_State *L) { - - bool movieactive = (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()); - lua_pushboolean(L, movieactive); - return 1; -} - -// movie.recording() -int movie_isrecording (lua_State *L) { - - lua_pushboolean(L, FCEUMOV_IsRecording()); - return 1; -} - -// movie.playing() -int movie_isplaying (lua_State *L) { - - lua_pushboolean(L, FCEUMOV_IsPlaying()); - return 1; -} - -//movie.rerecordcount() -// -//returns the rerecord count of the current movie -static int movie_rerecordcount (lua_State *L) { - if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying() && !FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - luaL_error(L, "No movie loaded."); - - lua_pushinteger(L, FCEUI_GetMovieRerecordCount()); - - return 1; -} - -//movie.length() -// -//returns an int value representing the total length of the current movie loaded - -static int movie_getlength (lua_State *L) { - if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying() && !FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - luaL_error(L, "No movie loaded."); - - lua_pushinteger(L, FCEUI_GetMovieLength()); - - return 1; -} - -//movie.readonly -// -//returns true is emulator is in read-only mode, false if it is in read+write -static int movie_getreadonly (lua_State *L) { - lua_pushboolean(L, FCEUI_GetMovieToggleReadOnly()); - - return 1; -} - -//movie.setreadonly -// -//Sets readonly / read+write status -static int movie_setreadonly (lua_State *L) { - bool which = (lua_toboolean( L, 1 ) == 1); - FCEUI_SetMovieToggleReadOnly(which); - - return 0; -} - -//movie.getname -// -//returns the filename of the movie loaded -static int movie_getname (lua_State *L) { - - if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying() && !FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - luaL_error(L, "No movie loaded."); - - std::string name = FCEUI_GetMovieName(); - lua_pushstring(L, name.c_str()); - return 1; -} - -//movie.getfilename -// -//returns the filename of movie loaded with no path -static int movie_getfilename (lua_State *L) { - - if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying() && !FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - luaL_error(L, "No movie loaded."); - - std::string name = FCEUI_GetMovieName(); - int x = name.find_last_of("/\\") + 1; - if (x) - name = name.substr(x, name.length()-x); - lua_pushstring(L, name.c_str()); - return 1; -} - -//movie.replay -// -//calls the play movie from beginning function -static int movie_replay (lua_State *L) { - - FCEUI_MoviePlayFromBeginning(); - - return 0; -} - -//movie.ispoweron -// -//If movie is recorded from power-on -static int movie_ispoweron (lua_State *L) { - if (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()) { - return FCEUMOV_FromPoweron(); - } - else - return 0; -} - -//movie.isfromsavestate() -// -//If movie is recorded from a savestate -static int movie_isfromsavestate (lua_State *L) { - if (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()) { - return !FCEUMOV_FromPoweron(); - } - else - return 0; -} - - -#define LUA_SCREEN_WIDTH 256 -#define LUA_SCREEN_HEIGHT 240 - -// Common code by the gui library: make sure the screen array is ready -static void gui_prepare() { - if (!gui_data) - gui_data = (uint8*) FCEU_dmalloc(LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4); - if (gui_used != GUI_USED_SINCE_LAST_DISPLAY) - memset(gui_data, 0, LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4); - gui_used = GUI_USED_SINCE_LAST_DISPLAY; -} - -// pixform for lua graphics -#define BUILD_PIXEL_ARGB8888(A,R,G,B) (((int) (A) << 24) | ((int) (R) << 16) | ((int) (G) << 8) | (int) (B)) -#define DECOMPOSE_PIXEL_ARGB8888(PIX,A,R,G,B) { (A) = ((PIX) >> 24) & 0xff; (R) = ((PIX) >> 16) & 0xff; (G) = ((PIX) >> 8) & 0xff; (B) = (PIX) & 0xff; } -#define LUA_BUILD_PIXEL BUILD_PIXEL_ARGB8888 -#define LUA_DECOMPOSE_PIXEL DECOMPOSE_PIXEL_ARGB8888 -#define LUA_PIXEL_A(PIX) (((PIX) >> 24) & 0xff) -#define LUA_PIXEL_R(PIX) (((PIX) >> 16) & 0xff) -#define LUA_PIXEL_G(PIX) (((PIX) >> 8) & 0xff) -#define LUA_PIXEL_B(PIX) ((PIX) & 0xff) - -template static void swap(T &one, T &two) { - T temp = one; - one = two; - two = temp; -} - -// write a pixel to buffer -static inline void blend32(uint32 *dstPixel, uint32 colour) -{ - uint8 *dst = (uint8*) dstPixel; - int a, r, g, b; - LUA_DECOMPOSE_PIXEL(colour, a, r, g, b); - - if (a == 255 || dst[3] == 0) { - // direct copy - *(uint32*)(dst) = colour; - } - else if (a == 0) { - // do not copy - } - else { - // alpha-blending - int a_dst = ((255 - a) * dst[3] + 128) / 255; - int a_new = a + a_dst; - - dst[0] = (uint8) ((( dst[0] * a_dst + b * a) + (a_new / 2)) / a_new); - dst[1] = (uint8) ((( dst[1] * a_dst + g * a) + (a_new / 2)) / a_new); - dst[2] = (uint8) ((( dst[2] * a_dst + r * a) + (a_new / 2)) / a_new); - dst[3] = (uint8) a_new; - } -} -// check if a pixel is in the lua canvas -static inline bool gui_check_boundary(int x, int y) { - return !(x < 0 || x >= LUA_SCREEN_WIDTH || y < 0 || y >= LUA_SCREEN_HEIGHT); -} - -// write a pixel to gui_data (do not check boundaries for speedup) -static inline void gui_drawpixel_fast(int x, int y, uint32 colour) { - //gui_prepare(); - blend32((uint32*) &gui_data[(y*LUA_SCREEN_WIDTH+x)*4], colour); -} - -// write a pixel to gui_data (check boundaries) -static inline void gui_drawpixel_internal(int x, int y, uint32 colour) { - //gui_prepare(); - if (gui_check_boundary(x, y)) - gui_drawpixel_fast(x, y, colour); -} - -// draw a line on gui_data (checks boundaries) -static void gui_drawline_internal(int x1, int y1, int x2, int y2, bool lastPixel, uint32 colour) { - - //gui_prepare(); - - // Note: New version of Bresenham's Line Algorithm - // http://groups.google.co.jp/group/rec.games.roguelike.development/browse_thread/thread/345f4c42c3b25858/29e07a3af3a450e6?show_docid=29e07a3af3a450e6 - - int swappedx = 0; - int swappedy = 0; - - int xtemp = x1-x2; - int ytemp = y1-y2; - if (xtemp == 0 && ytemp == 0) { - gui_drawpixel_internal(x1, y1, colour); - return; - } - if (xtemp < 0) { - xtemp = -xtemp; - swappedx = 1; - } - if (ytemp < 0) { - ytemp = -ytemp; - swappedy = 1; - } - - int delta_x = xtemp << 1; - int delta_y = ytemp << 1; - - signed char ix = x1 > x2?1:-1; - signed char iy = y1 > y2?1:-1; - - if (lastPixel) - gui_drawpixel_internal(x2, y2, colour); - - if (delta_x >= delta_y) { - int error = delta_y - (delta_x >> 1); - - while (x2 != x1) { - if (error == 0 && !swappedx) - gui_drawpixel_internal(x2+ix, y2, colour); - if (error >= 0) { - if (error || (ix > 0)) { - y2 += iy; - error -= delta_x; - } - } - x2 += ix; - gui_drawpixel_internal(x2, y2, colour); - if (error == 0 && swappedx) - gui_drawpixel_internal(x2, y2+iy, colour); - error += delta_y; - } - } - else { - int error = delta_x - (delta_y >> 1); - - while (y2 != y1) { - if (error == 0 && !swappedy) - gui_drawpixel_internal(x2, y2+iy, colour); - if (error >= 0) { - if (error || (iy > 0)) { - x2 += ix; - error -= delta_y; - } - } - y2 += iy; - gui_drawpixel_internal(x2, y2, colour); - if (error == 0 && swappedy) - gui_drawpixel_internal(x2+ix, y2, colour); - error += delta_x; - } - } -} - -// draw a rect on gui_data -static void gui_drawbox_internal(int x1, int y1, int x2, int y2, uint32 colour) { - - if (x1 > x2) - swap(x1, x2); - if (y1 > y2) - swap(y1, y2); - if (x1 < 0) - x1 = -1; - if (y1 < 0) - y1 = -1; - if (x2 >= LUA_SCREEN_WIDTH) - x2 = LUA_SCREEN_WIDTH; - if (y2 >= LUA_SCREEN_HEIGHT) - y2 = LUA_SCREEN_HEIGHT; - - //gui_prepare(); - - gui_drawline_internal(x1, y1, x2, y1, true, colour); - gui_drawline_internal(x1, y2, x2, y2, true, colour); - gui_drawline_internal(x1, y1, x1, y2, true, colour); - gui_drawline_internal(x2, y1, x2, y2, true, colour); -} - -// draw fill rect on gui_data -static void gui_fillbox_internal(int x1, int y1, int x2, int y2, uint32 colour) -{ - if (x1 > x2) - std::swap(x1, x2); - if (y1 > y2) - std::swap(y1, y2); - if (x1 < 0) - x1 = 0; - if (y1 < 0) - y1 = 0; - if (x2 >= LUA_SCREEN_WIDTH) - x2 = LUA_SCREEN_WIDTH - 1; - if (y2 >= LUA_SCREEN_HEIGHT) - y2 = LUA_SCREEN_HEIGHT - 1; - - //gui_prepare(); - int ix, iy; - for (iy = y1; iy <= y2; iy++) - { - for (ix = x1; ix <= x2; ix++) - { - gui_drawpixel_fast(ix, iy, colour); - } - } -} - -enum -{ - GUI_COLOUR_CLEAR - /* - , GUI_COLOUR_WHITE, GUI_COLOUR_BLACK, GUI_COLOUR_GREY - , GUI_COLOUR_RED, GUI_COLOUR_GREEN, GUI_COLOUR_BLUE - */ -}; -/** - * Returns an index approximating an RGB colour. - * TODO: This is easily improvable in terms of speed and probably - * quality of matches. (gd overlay & transparency code call it a lot.) - * With effort we could also cheat and map indices 0x08 .. 0x3F - * ourselves. - */ -static uint8 gui_colour_rgb(uint8 r, uint8 g, uint8 b) { - static uint8 index_lookup[1 << (3+3+3)]; - int k; - - if (!gui_saw_current_palette) - { - memset(index_lookup, GUI_COLOUR_CLEAR, sizeof(index_lookup)); - gui_saw_current_palette = TRUE; - } - - k = ((r & 0xE0) << 1) | ((g & 0xE0) >> 2) | ((b & 0xE0) >> 5); - uint16 test, best = GUI_COLOUR_CLEAR; - uint32 best_score = 0xffffffffu, test_score; - if (index_lookup[k] != GUI_COLOUR_CLEAR) return index_lookup[k]; - for (test = 0; test < 0xff; test++) - { - uint8 tr, tg, tb; - if (test == GUI_COLOUR_CLEAR) continue; - FCEUD_GetPalette(test, &tr, &tg, &tb); - test_score = abs(r - tr) * 66 + - abs(g - tg) * 129 + - abs(b - tb) * 25; - if (test_score < best_score) best_score = test_score, best = test; - } - index_lookup[k] = best; - return best; -} - -void FCEU_LuaUpdatePalette() -{ - gui_saw_current_palette = FALSE; -} - -// Helper for a simple hex parser -static int hex2int(lua_State *L, char c) { - if (c >= '0' && c <= '9') - return c-'0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - return luaL_error(L, "invalid hex in colour"); -} - -static const struct ColorMapping -{ - const char* name; - unsigned int value; -} -s_colorMapping [] = -{ - {"white", 0xFFFFFFFF}, - {"black", 0x000000FF}, - {"clear", 0x00000000}, - {"gray", 0x7F7F7FFF}, - {"grey", 0x7F7F7FFF}, - {"red", 0xFF0000FF}, - {"orange", 0xFF7F00FF}, - {"yellow", 0xFFFF00FF}, - {"chartreuse",0x7FFF00FF}, - {"green", 0x00FF00FF}, - {"teal", 0x00FF7FFF}, - {"cyan" , 0x00FFFFFF}, - {"blue", 0x0000FFFF}, - {"purple", 0x7F00FFFF}, - {"magenta", 0xFF00FFFF}, -}; - -/** - * Converts an integer or a string on the stack at the given - * offset to a RGB32 colour. Several encodings are supported. - * The user may construct their own RGB value, given a simple colour name, - * or an HTML-style "#09abcd" colour. 16 bit reduction doesn't occur at this time. - * NES palettes added with notation "P00" to "P3F". "P40" to "P7F" denote LUA palettes. - */ -static inline bool str2colour(uint32 *colour, lua_State *L, const char *str) { - if (str[0] == '#') { - int color; - sscanf(str+1, "%X", &color); - int len = strlen(str+1); - int missing = std::max(0, 8-len); - color <<= missing << 2; - if(missing >= 2) color |= 0xFF; - *colour = color; - return true; - } - else if (str[0] == 'P') { - uint8 palette; - uint8 tr, tg, tb; - - if (strlen(str+1) == 2) { - palette = ((hex2int(L, str[1]) * 0x10) + hex2int(L, str[2])); - } else if (strlen(str+1) == 1) { - palette = (hex2int(L, str[1])); - } else { - luaL_error(L, "palettes are defined with P## hex notion"); - return false; - } - - if (palette > 0x7F) { - luaL_error(L, "palettes range from P00 to P7F"); - return false; - } - - FCEUD_GetPalette(palette + 0x80, &tr, &tg, &tb); - // Feeding it RGBA, because it will spit out the right value for me - *colour = LUA_BUILD_PIXEL(tr, tg, tb, 0xFF); - return true; - } - else { - if(!strnicmp(str, "rand", 4)) { - *colour = ((rand()*255/RAND_MAX) << 8) | ((rand()*255/RAND_MAX) << 16) | ((rand()*255/RAND_MAX) << 24) | 0xFF; - return true; - } - for(int i = 0; i < sizeof(s_colorMapping)/sizeof(*s_colorMapping); i++) { - if(!stricmp(str,s_colorMapping[i].name)) { - *colour = s_colorMapping[i].value; - return true; - } - } - } - return false; -} -static inline uint32 gui_getcolour_wrapped(lua_State *L, int offset, bool hasDefaultValue, uint32 defaultColour) { - switch (lua_type(L,offset)) { - case LUA_TSTRING: - { - const char *str = lua_tostring(L,offset); - uint32 colour; - - if (str2colour(&colour, L, str)) - return colour; - else { - if (hasDefaultValue) - return defaultColour; - else - return luaL_error(L, "unknown colour %s", str); - } - } - case LUA_TNUMBER: - { - uint32 colour = (uint32) lua_tointeger(L,offset); - return colour; - } - case LUA_TTABLE: - { - int color = 0xFF; - lua_pushnil(L); // first key - int keyIndex = lua_gettop(L); - int valueIndex = keyIndex + 1; - bool first = true; - while(lua_next(L, offset)) - { - bool keyIsString = (lua_type(L, keyIndex) == LUA_TSTRING); - bool keyIsNumber = (lua_type(L, keyIndex) == LUA_TNUMBER); - int key = keyIsString ? tolower(*lua_tostring(L, keyIndex)) : (keyIsNumber ? lua_tointeger(L, keyIndex) : 0); - int value = lua_tointeger(L, valueIndex); - if(value < 0) value = 0; - if(value > 255) value = 255; - switch(key) - { - case 1: case 'r': color |= value << 24; break; - case 2: case 'g': color |= value << 16; break; - case 3: case 'b': color |= value << 8; break; - case 4: case 'a': color = (color & ~0xFF) | value; break; - } - lua_pop(L, 1); - } - return color; - } break; - case LUA_TFUNCTION: - luaL_error(L, "invalid colour"); // NYI - return 0; - default: - if (hasDefaultValue) - return defaultColour; - else - return luaL_error(L, "invalid colour"); - } -} -static uint32 gui_getcolour(lua_State *L, int offset) { - uint32 colour; - int a, r, g, b; - - colour = gui_getcolour_wrapped(L, offset, false, 0); - a = ((colour & 0xff) * transparencyModifier) / 255; - if (a > 255) a = 255; - b = (colour >> 8) & 0xff; - g = (colour >> 16) & 0xff; - r = (colour >> 24) & 0xff; - return LUA_BUILD_PIXEL(a, r, g, b); -} -static uint32 gui_optcolour(lua_State *L, int offset, uint32 defaultColour) { - uint32 colour; - int a, r, g, b; - uint8 defA, defB, defG, defR; - - LUA_DECOMPOSE_PIXEL(defaultColour, defA, defR, defG, defB); - defaultColour = (defR << 24) | (defG << 16) | (defB << 8) | defA; - - colour = gui_getcolour_wrapped(L, offset, true, defaultColour); - a = ((colour & 0xff) * transparencyModifier) / 255; - if (a > 255) a = 255; - b = (colour >> 8) & 0xff; - g = (colour >> 16) & 0xff; - r = (colour >> 24) & 0xff; - return LUA_BUILD_PIXEL(a, r, g, b); -} - -// gui.pixel(x,y,colour) -static int gui_pixel(lua_State *L) { - - int x = luaL_checkinteger(L, 1); - int y = luaL_checkinteger(L,2); - - uint32 colour = gui_getcolour(L,3); - -// if (!gui_check_boundary(x, y)) -// luaL_error(L,"bad coordinates"); - - gui_prepare(); - - gui_drawpixel_internal(x, y, colour); - - return 0; -} - -// Usage: -// local r,g,b,a = gui.getpixel(255, 223) -// Gets the LUA set pixel color -static int gui_getpixel(lua_State *L) { - - int x = luaL_checkinteger(L, 1); - int y = luaL_checkinteger(L,2); - - int r, g, b, a; - - if (!gui_check_boundary(x, y)) - luaL_error(L,"bad coordinates. Use 0-%d x 0-%d", LUA_SCREEN_WIDTH - 1, LUA_SCREEN_HEIGHT - 1); - - if (!gui_data) { - // Return all 0s, including for alpha. - // If alpha == 0, there was no color data for that spot - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - return 4; - } - - //uint8 *dst = (uint8*) &gui_data[(y*LUA_SCREEN_WIDTH+x)*4]; - - //uint32 color = *(uint32*) &gui_data[(y*LUA_SCREEN_WIDTH+x)*4]; - - LUA_DECOMPOSE_PIXEL(*(uint32*) &gui_data[(y*LUA_SCREEN_WIDTH+x)*4], a, r, g, b); - - lua_pushinteger(L, r); - lua_pushinteger(L, g); - lua_pushinteger(L, b); - lua_pushinteger(L, a); - return 4; - -} - -// Usage: -// local r,g,b,palette = gui.getpixel(255, 255) -// Gets the screen pixel color -// Palette will be 254 on error -static int emu_getscreenpixel(lua_State *L) { - - int x = luaL_checkinteger(L, 1); - int y = luaL_checkinteger(L,2); - bool getemuscreen = (lua_toboolean(L,3) == 1); - - int r, g, b; - int palette; - - if (((x < 0) || (x > 255)) || ((y < 0) || (y > 239))) { - luaL_error(L,"bad coordinates. Use 0-255 x 0-239"); - - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 254); - return 4; - } - - if (!XBuf) { - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 0); - lua_pushinteger(L, 254); - return 4; - } - - uint32 pixelinfo = GetScreenPixel(x,y,getemuscreen); - - LUA_DECOMPOSE_PIXEL(pixelinfo, palette, r, g, b); - palette = GetScreenPixelPalette(x,y,getemuscreen); - - lua_pushinteger(L, r); - lua_pushinteger(L, g); - lua_pushinteger(L, b); - lua_pushinteger(L, palette); - return 4; - -} - -// gui.line(x1,y1,x2,y2,color,skipFirst) -static int gui_line(lua_State *L) { - - int x1,y1,x2,y2; - uint32 color; - x1 = luaL_checkinteger(L,1); - y1 = luaL_checkinteger(L,2); - x2 = luaL_checkinteger(L,3); - y2 = luaL_checkinteger(L,4); - color = gui_optcolour(L,5,LUA_BUILD_PIXEL(255, 255, 255, 255)); - int skipFirst = lua_toboolean(L,6); - - gui_prepare(); - - gui_drawline_internal(x2, y2, x1, y1, !skipFirst, color); - - return 0; -} - -// gui.box(x1, y1, x2, y2, fillcolor, outlinecolor) -static int gui_box(lua_State *L) { - - int x1,y1,x2,y2; - uint32 fillcolor; - uint32 outlinecolor; - - x1 = luaL_checkinteger(L,1); - y1 = luaL_checkinteger(L,2); - x2 = luaL_checkinteger(L,3); - y2 = luaL_checkinteger(L,4); - fillcolor = gui_optcolour(L,5,LUA_BUILD_PIXEL(63, 255, 255, 255)); - outlinecolor = gui_optcolour(L,6,LUA_BUILD_PIXEL(255, LUA_PIXEL_R(fillcolor), LUA_PIXEL_G(fillcolor), LUA_PIXEL_B(fillcolor))); - - if (x1 > x2) - std::swap(x1, x2); - if (y1 > y2) - std::swap(y1, y2); - - gui_prepare(); - - gui_drawbox_internal(x1, y1, x2, y2, outlinecolor); - if ((x2 - x1) >= 2 && (y2 - y1) >= 2) - gui_fillbox_internal(x1+1, y1+1, x2-1, y2-1, fillcolor); - - return 0; -} - -// (old) gui.box(x1, y1, x2, y2, color) -static int gui_box_old(lua_State *L) { - - int x1,y1,x2,y2; - uint32 colour; - - x1 = luaL_checkinteger(L,1); - y1 = luaL_checkinteger(L,2); - x2 = luaL_checkinteger(L,3); - y2 = luaL_checkinteger(L,4); - colour = gui_getcolour(L,5); - -// if (!gui_check_boundary(x1, y1)) -// luaL_error(L,"bad coordinates"); -// -// if (!gui_check_boundary(x2, y2)) -// luaL_error(L,"bad coordinates"); - - gui_prepare(); - - gui_drawbox_internal(x1, y1, x2, y2, colour); - - return 0; -} - -static int gui_parsecolor(lua_State *L) -{ - int r, g, b, a; - uint32 color = gui_getcolour(L,1); - LUA_DECOMPOSE_PIXEL(color, a, r, g, b); - lua_pushinteger(L, r); - lua_pushinteger(L, g); - lua_pushinteger(L, b); - lua_pushinteger(L, a); - return 4; -} - - -// gui.savescreenshotas() -// -// Causes FCEUX to write a screenshot to a file based on a received filename, caution: will overwrite existing screenshot files -// -// Unconditionally retrns 1; any failure in taking a screenshot would be reported on-screen -// from the function ReallySnap(). -static int gui_savescreenshotas(lua_State *L) { - const char* name = NULL; - size_t l; - name = luaL_checklstring(L,1,&l); - lua_pushstring(L, name); - if (name) - FCEUI_SetSnapshotAsName(name); - else - luaL_error(L,"gui.savesnapshotas must have a string parameter"); - FCEUI_SaveSnapshotAs(); - return 1; -} - - -// gui.savescreenshot() -// -// Causes FCEUX to write a screenshot to a file as if the user pressed the associated hotkey. -// -// Unconditionally retrns 1; any failure in taking a screenshot would be reported on-screen -// from the function ReallySnap(). -static int gui_savescreenshot(lua_State *L) { - FCEUI_SaveSnapshot(); - return 1; -} - -// gui.gdscreenshot() -// -// Returns a screen shot as a string in gd's v1 file format. -// This allows us to make screen shots available without gd installed locally. -// Users can also just grab pixels via substring selection. -// -// I think... Does lua support grabbing byte values from a string? // yes, string.byte(str,offset) -// Well, either way, just install gd and do what you like with it. -// It really is easier that way. -// example: gd.createFromGdStr(gui.gdscreenshot()):png("outputimage.png") -static int gui_gdscreenshot(lua_State *L) { - - int width = LUA_SCREEN_WIDTH; - int height = LUA_SCREEN_HEIGHT; - - int size = 11 + width * height * 4; - char* str = new char[size+1]; - str[size] = 0; - unsigned char* ptr = (unsigned char*)str; - - // GD format header for truecolor image (11 bytes) - *ptr++ = (65534 >> 8) & 0xFF; - *ptr++ = (65534 ) & 0xFF; - *ptr++ = (width >> 8) & 0xFF; - *ptr++ = (width ) & 0xFF; - *ptr++ = (height >> 8) & 0xFF; - *ptr++ = (height ) & 0xFF; - *ptr++ = 1; - *ptr++ = 255; - *ptr++ = 255; - *ptr++ = 255; - *ptr++ = 255; - - for (int y=0; y < height; y++) { - for (int x=0; x < width; x++) { - uint8 index = XBuf[(y)*256 + x]; - - // Write A,R,G,B (alpha=0 for us): - *ptr = 0; - FCEUD_GetPalette(index, ptr + 1, ptr + 2, ptr + 3); - ptr += 4; - } - } - - lua_pushlstring(L, str, size); - delete[] str; - return 1; -} - -// gui.opacity(number alphaValue) -// sets the transparency of subsequent draw calls -// 0.0 is completely transparent, 1.0 is completely opaque -// non-integer values are supported and meaningful, as are values greater than 1.0 -// it is not necessary to use this function to get transparency (or the less-recommended gui.transparency() either), -// because you can provide an alpha value in the color argument of each draw call. -// however, it can be convenient to be able to globally modify the drawing transparency -static int gui_setopacity(lua_State *L) { - double opacF = luaL_checknumber(L,1); - transparencyModifier = (int) (opacF * 255); - if (transparencyModifier < 0) - transparencyModifier = 0; - return 0; -} - -// gui.transparency(int strength) -// -// 0 = solid, -static int gui_transparency(lua_State *L) { - double trans = luaL_checknumber(L,1); - transparencyModifier = (int) ((4.0 - trans) / 4.0 * 255); - if (transparencyModifier < 0) - transparencyModifier = 0; - return 0; -} - - -static const uint32 Small_Font_Data[] = -{ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 32 - 0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000000, 0x00000700, 0x00000000, // 33 ! - 0x00000000, 0x00040002, 0x00050003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 34 " - 0x00000000, 0x00040002, 0x00050403, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 35 # - 0x00000000, 0x00040300, 0x00000403, 0x00000500, 0x00070600, 0x00000706, 0x00000000, // 36 $ - 0x00000000, 0x00000002, 0x00050000, 0x00000500, 0x00000005, 0x00080000, 0x00000000, // 37 % - 0x00000000, 0x00000300, 0x00050003, 0x00000500, 0x00070005, 0x00080700, 0x00000000, // 38 & - 0x00000000, 0x00000300, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 39 ' - 0x00000000, 0x00000300, 0x00000003, 0x00000004, 0x00000005, 0x00000700, 0x00000000, // 40 ( - 0x00000000, 0x00000300, 0x00050000, 0x00060000, 0x00070000, 0x00000700, 0x00000000, // 41 ) - 0x00000000, 0x00000000, 0x00000400, 0x00060504, 0x00000600, 0x00080006, 0x00000000, // 42 * - 0x00000000, 0x00000000, 0x00000400, 0x00060504, 0x00000600, 0x00000000, 0x00000000, // 43 + - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000600, 0x00000700, 0x00000007, // 44 , - 0x00000000, 0x00000000, 0x00000000, 0x00060504, 0x00000000, 0x00000000, 0x00000000, // 45 - - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000700, 0x00000000, // 46 . - 0x00030000, 0x00040000, 0x00000400, 0x00000500, 0x00000005, 0x00000006, 0x00000000, // 47 / - 0x00000000, 0x00000300, 0x00050003, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 48 0 - 0x00000000, 0x00000300, 0x00000403, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 49 1 - 0x00000000, 0x00000302, 0x00050000, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 50 2 - 0x00000000, 0x00000302, 0x00050000, 0x00000504, 0x00070000, 0x00000706, 0x00000000, // 51 3 - 0x00000000, 0x00000300, 0x00000003, 0x00060004, 0x00070605, 0x00080000, 0x00000000, // 52 4 - 0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00070000, 0x00000706, 0x00000000, // 53 5 - 0x00000000, 0x00000300, 0x00000003, 0x00000504, 0x00070005, 0x00000700, 0x00000000, // 54 6 - 0x00000000, 0x00040302, 0x00050000, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 55 7 - 0x00000000, 0x00000300, 0x00050003, 0x00000500, 0x00070005, 0x00000700, 0x00000000, // 56 8 - 0x00000000, 0x00000300, 0x00050003, 0x00060500, 0x00070000, 0x00000700, 0x00000000, // 57 9 - 0x00000000, 0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000700, 0x00000000, // 58 : - 0x00000000, 0x00000000, 0x00000000, 0x00000500, 0x00000000, 0x00000700, 0x00000007, // 59 ; - 0x00000000, 0x00040000, 0x00000400, 0x00000004, 0x00000600, 0x00080000, 0x00000000, // 60 < - 0x00000000, 0x00000000, 0x00050403, 0x00000000, 0x00070605, 0x00000000, 0x00000000, // 61 = - 0x00000000, 0x00000002, 0x00000400, 0x00060000, 0x00000600, 0x00000006, 0x00000000, // 62 > - 0x00000000, 0x00000302, 0x00050000, 0x00000500, 0x00000000, 0x00000700, 0x00000000, // 63 ? - 0x00000000, 0x00000300, 0x00050400, 0x00060004, 0x00070600, 0x00000000, 0x00000000, // 64 @ - 0x00000000, 0x00000300, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 65 A - 0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00070005, 0x00000706, 0x00000000, // 66 B - 0x00000000, 0x00040300, 0x00000003, 0x00000004, 0x00000005, 0x00080700, 0x00000000, // 67 C - 0x00000000, 0x00000302, 0x00050003, 0x00060004, 0x00070005, 0x00000706, 0x00000000, // 68 D - 0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00000005, 0x00080706, 0x00000000, // 69 E - 0x00000000, 0x00040302, 0x00000003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 70 F - 0x00000000, 0x00040300, 0x00000003, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 71 G - 0x00000000, 0x00040002, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 72 H - 0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 73 I - 0x00000000, 0x00040000, 0x00050000, 0x00060000, 0x00070005, 0x00000700, 0x00000000, // 74 J - 0x00000000, 0x00040002, 0x00050003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 75 K - 0x00000000, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00080706, 0x00000000, // 76 l - 0x00000000, 0x00040002, 0x00050403, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 77 M - 0x00000000, 0x00000302, 0x00050003, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 78 N - 0x00000000, 0x00040302, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00000000, // 79 O - 0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 80 P - 0x00000000, 0x00040302, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00090000, // 81 Q - 0x00000000, 0x00000302, 0x00050003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 82 R - 0x00000000, 0x00040300, 0x00000003, 0x00000500, 0x00070000, 0x00000706, 0x00000000, // 83 S - 0x00000000, 0x00040302, 0x00000400, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 84 T - 0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00070005, 0x00080706, 0x00000000, // 85 U - 0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00000600, 0x00000700, 0x00000000, // 86 V - 0x00000000, 0x00040002, 0x00050003, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 87 W - 0x00000000, 0x00040002, 0x00050003, 0x00000500, 0x00070005, 0x00080006, 0x00000000, // 88 X - 0x00000000, 0x00040002, 0x00050003, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 89 Y - 0x00000000, 0x00040302, 0x00050000, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 90 Z - 0x00000000, 0x00040300, 0x00000400, 0x00000500, 0x00000600, 0x00080700, 0x00000000, // 91 [ - 0x00000000, 0x00000002, 0x00000400, 0x00000500, 0x00070000, 0x00080000, 0x00000000, // 92 '\' - 0x00000000, 0x00000302, 0x00000400, 0x00000500, 0x00000600, 0x00000706, 0x00000000, // 93 ] - 0x00000000, 0x00000300, 0x00050003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 94 ^ - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080706, 0x00000000, // 95 _ - 0x00000000, 0x00000002, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 96 ` - 0x00000000, 0x00000000, 0x00050400, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 97 a - 0x00000000, 0x00000002, 0x00000003, 0x00000504, 0x00070005, 0x00000706, 0x00000000, // 98 b - 0x00000000, 0x00000000, 0x00050400, 0x00000004, 0x00000005, 0x00080700, 0x00000000, // 99 c - 0x00000000, 0x00040000, 0x00050000, 0x00060500, 0x00070005, 0x00080700, 0x00000000, // 100 d - 0x00000000, 0x00000000, 0x00050400, 0x00060504, 0x00000005, 0x00080700, 0x00000000, // 101 e - 0x00000000, 0x00040300, 0x00000003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 102 f - 0x00000000, 0x00000000, 0x00050400, 0x00060004, 0x00070600, 0x00080000, 0x00000807, // 103 g - 0x00000000, 0x00000002, 0x00000003, 0x00000504, 0x00070005, 0x00080006, 0x00000000, // 104 h - 0x00000000, 0x00000300, 0x00000000, 0x00000500, 0x00000600, 0x00000700, 0x00000000, // 105 i - 0x00000000, 0x00000300, 0x00000000, 0x00000500, 0x00000600, 0x00000700, 0x00000007, // 106 j - 0x00000000, 0x00000002, 0x00000003, 0x00060004, 0x00000605, 0x00080006, 0x00000000, // 107 k - 0x00000000, 0x00000300, 0x00000400, 0x00000500, 0x00000600, 0x00080000, 0x00000000, // 108 l - 0x00000000, 0x00000000, 0x00050003, 0x00060504, 0x00070005, 0x00080006, 0x00000000, // 109 m - 0x00000000, 0x00000000, 0x00000403, 0x00060004, 0x00070005, 0x00080006, 0x00000000, // 110 n - 0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 111 o - 0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00000605, 0x00000006, 0x00000007, // 112 p - 0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070600, 0x00080000, 0x00090000, // 113 q - 0x00000000, 0x00000000, 0x00050003, 0x00000504, 0x00000005, 0x00000006, 0x00000000, // 114 r - 0x00000000, 0x00000000, 0x00050400, 0x00000004, 0x00070600, 0x00000706, 0x00000000, // 115 s - 0x00000000, 0x00000300, 0x00050403, 0x00000500, 0x00000600, 0x00080000, 0x00000000, // 116 t - 0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070005, 0x00080700, 0x00000000, // 117 u - 0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070005, 0x00000700, 0x00000000, // 118 v - 0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00070605, 0x00080006, 0x00000000, // 119 w - 0x00000000, 0x00000000, 0x00050003, 0x00000500, 0x00070005, 0x00080006, 0x00000000, // 120 x - 0x00000000, 0x00000000, 0x00050003, 0x00060004, 0x00000600, 0x00000700, 0x00000007, // 121 y - 0x00000000, 0x00000000, 0x00050403, 0x00000500, 0x00000005, 0x00080706, 0x00000000, // 122 z - 0x00000000, 0x00040300, 0x00000400, 0x00000504, 0x00000600, 0x00080700, 0x00000000, // 123 { - 0x00000000, 0x00000300, 0x00000400, 0x00000000, 0x00000600, 0x00000700, 0x00000000, // 124 | - 0x00000000, 0x00000302, 0x00000400, 0x00060500, 0x00000600, 0x00000706, 0x00000000, // 125 } - 0x00000000, 0x00000302, 0x00050000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // 126 ~ - 0x00000000, 0x00000000, 0x00000400, 0x00060004, 0x00070605, 0x00000000, 0x00000000, // 127  - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -}; - -static void PutTextInternal (const char *str, int len, short x, short y, int color, int backcolor) -{ - int Opac = (color >> 24) & 0xFF; - int backOpac = (backcolor >> 24) & 0xFF; - int origX = x; - - if(!Opac && !backOpac) - return; - - while(*str && len && y < LUA_SCREEN_HEIGHT) - { - int c = *str++; - while (x > LUA_SCREEN_WIDTH && c != '\n') { - c = *str; - if (c == '\0') - break; - str++; - } - if(c == '\n') - { - x = origX; - y += 8; - continue; - } - else if(c == '\t') // just in case - { - const int tabSpace = 8; - x += (tabSpace-(((x-origX)/4)%tabSpace))*4; - continue; - } - if((unsigned int)(c-32) >= 96) - continue; - const unsigned char* Cur_Glyph = (const unsigned char*)&Small_Font_Data + (c-32)*7*4; - - for(int y2 = 0; y2 < 8; y2++) - { - unsigned int glyphLine = *((unsigned int*)Cur_Glyph + y2); - for(int x2 = -1; x2 < 4; x2++) - { - int shift = x2 << 3; - int mask = 0xFF << shift; - int intensity = (glyphLine & mask) >> shift; - - if(intensity && x2 >= 0 && y2 < 7) - { - //int xdraw = std::max(0,std::min(LUA_SCREEN_WIDTH - 1,x+x2)); - //int ydraw = std::max(0,std::min(LUA_SCREEN_HEIGHT - 1,y+y2)); - //gui_drawpixel_fast(xdraw, ydraw, color); - gui_drawpixel_internal(x+x2, y+y2, color); - } - else if(backOpac) - { - for(int y3 = std::max(0,y2-1); y3 <= std::min(6,y2+1); y3++) - { - unsigned int glyphLine = *((unsigned int*)Cur_Glyph + y3); - for(int x3 = std::max(0,x2-1); x3 <= std::min(3,x2+1); x3++) - { - int shift = x3 << 3; - int mask = 0xFF << shift; - intensity |= (glyphLine & mask) >> shift; - if (intensity) - goto draw_outline; // speedup? - } - } -draw_outline: - if(intensity) - { - //int xdraw = std::max(0,std::min(LUA_SCREEN_WIDTH - 1,x+x2)); - //int ydraw = std::max(0,std::min(LUA_SCREEN_HEIGHT - 1,y+y2)); - //gui_drawpixel_fast(xdraw, ydraw, backcolor); - gui_drawpixel_internal(x+x2, y+y2, backcolor); - } - } - } - } - - x += 4; - len--; - } -} - -static int strlinelen(const char* string) -{ - const char* s = string; - while(*s && *s != '\n') - s++; - if(*s) - s++; - return s - string; -} - -static void LuaDisplayString (const char *string, int y, int x, uint32 color, uint32 outlineColor) -{ - if(!string) - return; - - gui_prepare(); - - PutTextInternal(string, strlen(string), x, y, color, outlineColor); -/* - const char* ptr = string; - while(*ptr && y < LUA_SCREEN_HEIGHT) - { - int len = strlinelen(ptr); - int skip = 0; - if(len < 1) len = 1; - - // break up the line if it's too long to display otherwise - if(len > 63) - { - len = 63; - const char* ptr2 = ptr + len-1; - for(int j = len-1; j; j--, ptr2--) - { - if(*ptr2 == ' ' || *ptr2 == '\t') - { - len = j; - skip = 1; - break; - } - } - } - - int xl = 0; - int yl = 0; - int xh = (LUA_SCREEN_WIDTH - 1 - 1) - 4*len; - int yh = LUA_SCREEN_HEIGHT - 1; - int x2 = std::min(std::max(x,xl),xh); - int y2 = std::min(std::max(y,yl),yh); - - PutTextInternal(ptr,len,x2,y2,color,outlineColor); - - ptr += len + skip; - y += 8; - } -*/ -} - - -static uint8 FCEUFont[792] = -{ - 6, 0, 0, 0, 0, 0, 0, 0, // 0x20 - Spacebar - 3, 64, 64, 64, 64, 64, 0, 64, - 5, 80, 80, 80, 0, 0, 0, 0, - 6, 80, 80,248, 80,248, 80, 80, - 6, 32,120,160,112, 40,240, 32, - 6, 64,168, 80, 32, 80,168, 16, - 6, 96,144,160, 64,168,144,104, - 3, 64, 64, 0, 0, 0, 0, 0, - 4, 32, 64, 64, 64, 64, 64, 32, - 4, 64, 32, 32, 32, 32, 32, 64, - 6, 0, 80, 32,248, 32, 80, 0, - 6, 0, 32, 32,248, 32, 32, 0, - 3, 0, 0, 0, 0, 0, 64,128, - 5, 0, 0, 0,240, 0, 0, 0, - 3, 0, 0, 0, 0, 0, 0, 64, - 5, 16, 16, 32, 32, 32, 64, 64, - 6,112,136,136,136,136,136,112, // 0x30 - 0 - 6, 32, 96, 32, 32, 32, 32, 32, - 6,112,136, 8, 48, 64,128,248, - 6,112,136, 8, 48, 8,136,112, - 6, 16, 48, 80,144,248, 16, 16, - 6,248,128,128,240, 8, 8,240, - 6, 48, 64,128,240,136,136,112, - 6,248, 8, 16, 16, 32, 32, 32, - 6,112,136,136,112,136,136,112, - 6,112,136,136,120, 8, 16, 96, - 3, 0, 0, 64, 0, 0, 64, 0, - 3, 0, 0, 64, 0, 0, 64,128, - 4, 0, 32, 64,128, 64, 32, 0, - 5, 0, 0,240, 0,240, 0, 0, - 4, 0,128, 64, 32, 64,128, 0, - 6,112,136, 8, 16, 32, 0, 32, // 0x3F - ? - 6,112,136,136,184,176,128,112, // 0x40 - @ - 6,112,136,136,248,136,136,136, // 0x41 - A - 6,240,136,136,240,136,136,240, - 6,112,136,128,128,128,136,112, - 6,224,144,136,136,136,144,224, - 6,248,128,128,240,128,128,248, - 6,248,128,128,240,128,128,128, - 6,112,136,128,184,136,136,120, - 6,136,136,136,248,136,136,136, - 4,224, 64, 64, 64, 64, 64,224, - 6, 8, 8, 8, 8, 8,136,112, - 6,136,144,160,192,160,144,136, - 6,128,128,128,128,128,128,248, - 6,136,216,168,168,136,136,136, - 6,136,136,200,168,152,136,136, - 7, 48, 72,132,132,132, 72, 48, - 6,240,136,136,240,128,128,128, - 6,112,136,136,136,168,144,104, - 6,240,136,136,240,144,136,136, - 6,112,136,128,112, 8,136,112, - 6,248, 32, 32, 32, 32, 32, 32, - 6,136,136,136,136,136,136,112, - 6,136,136,136, 80, 80, 32, 32, - 6,136,136,136,136,168,168, 80, - 6,136,136, 80, 32, 80,136,136, - 6,136,136, 80, 32, 32, 32, 32, - 6,248, 8, 16, 32, 64,128,248, - 3,192,128,128,128,128,128,192, - 5, 64, 64, 32, 32, 32, 16, 16, - 3,192, 64, 64, 64, 64, 64,192, - 4, 64,160, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 0, 0, 0,248, - 3,128, 64, 0, 0, 0, 0, 0, - 5, 0, 0, 96, 16,112,144,112, // 0x61 - a - 5,128,128,224,144,144,144,224, - 5, 0, 0,112,128,128,128,112, - 5, 16, 16,112,144,144,144,112, - 5, 0, 0, 96,144,240,128,112, - 5, 48, 64,224, 64, 64, 64, 64, - 5, 0,112,144,144,112, 16,224, - 5,128,128,224,144,144,144,144, - 2,128, 0,128,128,128,128,128, - 4, 32, 0, 32, 32, 32, 32,192, - 5,128,128,144,160,192,160,144, - 2,128,128,128,128,128,128,128, - 6, 0, 0,208,168,168,168,168, - 5, 0, 0,224,144,144,144,144, - 5, 0, 0, 96,144,144,144, 96, - 5, 0, 0,224,144,144,224,128, - 5, 0, 0,112,144,144,112, 16, - 5, 0, 0,176,192,128,128,128, - 5, 0, 0,112,128, 96, 16,224, - 4, 64, 64,224, 64, 64, 64, 32, - 5, 0, 0,144,144,144,144,112, - 5, 0, 0,144,144,144,160,192, - 6, 0, 0,136,136,168,168, 80, - 5, 0, 0,144,144, 96,144,144, - 5, 0,144,144,144,112, 16, 96, - 5, 0, 0,240, 32, 64,128,240, - 4, 32, 64, 64,128, 64, 64, 32, - 3, 64, 64, 64, 64, 64, 64, 64, - 4,128, 64, 64, 32, 64, 64,128, - 6, 0,104,176, 0, 0, 0, 0 -}; - -static int FixJoedChar(uint8 ch) -{ - int c = ch; c -= 32; - return (c < 0 || c > 98) ? 0 : c; -} -static int JoedCharWidth(uint8 ch) -{ - return FCEUFont[FixJoedChar(ch)*8]; -} - -void LuaDrawTextTransWH(const char *str, size_t l, int &x, int y, uint32 color, uint32 backcolor) -{ - int Opac = (color >> 24) & 0xFF; - int backOpac = (backcolor >> 24) & 0xFF; - int origX = x; - - if(!Opac && !backOpac) - return; - - size_t len = l; - int defaultAlpha = std::max(0, std::min(transparencyModifier, 255)); - int diffx; - int diffy = std::max(0, std::min(7, LUA_SCREEN_HEIGHT - y)); - - while(*str && len && y < LUA_SCREEN_HEIGHT) - { - int c = *str++; - while (x >= LUA_SCREEN_WIDTH && c != '\n') { - c = *str; - if (c == '\0') - break; - str++; - if (!(--len)) - break; - } - if(c == '\n') - { - x = origX; - y += 8; - diffy = std::max(0, std::min(7, LUA_SCREEN_HEIGHT - y)); - continue; - } - else if(c == '\t') // just in case - { - const int tabSpace = 8; - x += (tabSpace-(((x-origX)/8)%tabSpace))*8; - continue; - } - - diffx = std::max(0, std::min(7, LUA_SCREEN_WIDTH - x)); - int ch = FixJoedChar(c); - int wid = std::min(diffx, JoedCharWidth(c)); - - for(int y2 = 0; y2 < diffy; y2++) - { - uint8 d = FCEUFont[ch*8 + 1+y2]; - for(int x2 = 0; x2 < wid; x2++) - { - int c = (d >> (7-x2)) & 1; - if(c) - gui_drawpixel_internal(x+x2, y+y2, color); - else - gui_drawpixel_internal(x+x2, y+y2, backcolor); - } - } - /* - // shadows :P - if (diffy >= 7) for(int x2 = 0; x2 < wid; x2++) - gui_drawpixel_internal(x+x2, y+7, LUA_BUILD_PIXEL(defaultAlpha, 0, 0, 0)); - if (*str == '\0' || *str == '\n') for(int y2 = 0; y2 < diffy; y2++) - gui_drawpixel_internal(x+wid, y+y2, LUA_BUILD_PIXEL(defaultAlpha, 0, 0, 0)); - */ - - x += wid; - len--; - } -} - - -// gui.text(int x, int y, string msg) -// -// Displays the given text on the screen, using the same font and techniques as the -// main HUD. -static int gui_text(lua_State *L) { - - extern int font_height; - const char *msg; - int x, y; - size_t l; - - x = luaL_checkinteger(L,1); - y = luaL_checkinteger(L,2); - msg = luaL_checklstring(L,3,&l); - - //if (x < 0 || x >= LUA_SCREEN_WIDTH || y < 0 || y >= (LUA_SCREEN_HEIGHT - font_height)) - // luaL_error(L,"bad coordinates"); - -#if 0 - uint32 colour = gui_optcolour(L,4,LUA_BUILD_PIXEL(255, 255, 255, 255)); - uint32 borderColour = gui_optcolour(L,5,LUA_BUILD_PIXEL(255, 0, 0, 0)); - - gui_prepare(); - - LuaDisplayString(msg, y, x, colour, borderColour); -#else - uint32 color = gui_optcolour(L,4,LUA_BUILD_PIXEL(255, 255, 255, 255)); - uint32 bgcolor = gui_optcolour(L,5,LUA_BUILD_PIXEL(255, 27, 18, 105)); - - gui_prepare(); - - LuaDrawTextTransWH(msg, l, x, y, color, bgcolor); - - lua_pushinteger(L, x); -#endif - return 1; - -} - - -// gui.gdoverlay([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0]) -// -// Overlays the given image on the screen. -// example: gui.gdoverlay(gd.createFromPng("myimage.png"):gdStr()) -static int gui_gdoverlay(lua_State *L) { - - int argCount = lua_gettop(L); - - int xStartDst = 0; - int yStartDst = 0; - int xStartSrc = 0; - int yStartSrc = 0; - - int index = 1; - if(lua_type(L,index) == LUA_TNUMBER) - { - xStartDst = lua_tointeger(L,index++); - if(lua_type(L,index) == LUA_TNUMBER) - yStartDst = lua_tointeger(L,index++); - } - - luaL_checktype(L,index,LUA_TSTRING); - const unsigned char* ptr = (const unsigned char*)lua_tostring(L,index++); - - if (ptr[0] != 255 || (ptr[1] != 254 && ptr[1] != 255)) - luaL_error(L, "bad image data"); - bool trueColor = (ptr[1] == 254); - ptr += 2; - int imgwidth = *ptr++ << 8; - imgwidth |= *ptr++; - int width = imgwidth; - int imgheight = *ptr++ << 8; - imgheight |= *ptr++; - int height = imgheight; - if ((!trueColor && *ptr) || (trueColor && !*ptr)) - luaL_error(L, "bad image data"); - ptr++; - int pitch = imgwidth * (trueColor?4:1); - - if ((argCount - index + 1) >= 4) { - xStartSrc = luaL_checkinteger(L,index++); - yStartSrc = luaL_checkinteger(L,index++); - width = luaL_checkinteger(L,index++); - height = luaL_checkinteger(L,index++); - } - - int alphaMul = transparencyModifier; - if(lua_isnumber(L, index)) - alphaMul = (int)(alphaMul * lua_tonumber(L, index++)); - if(alphaMul <= 0) - return 0; - - // since there aren't that many possible opacity levels, - // do the opacity modification calculations beforehand instead of per pixel - int opacMap[256]; - for(int i = 0; i < 128; i++) - { - int opac = 255 - ((i << 1) | (i & 1)); // gdAlphaMax = 127, not 255 - opac = (opac * alphaMul) / 255; - if(opac < 0) opac = 0; - if(opac > 255) opac = 255; - opacMap[i] = opac; - } - for(int i = 128; i < 256; i++) - opacMap[i] = 0; // what should we do for them, actually? - - int colorsTotal = 0; - if (!trueColor) { - colorsTotal = *ptr++ << 8; - colorsTotal |= *ptr++; - } - int transparent = *ptr++ << 24; - transparent |= *ptr++ << 16; - transparent |= *ptr++ << 8; - transparent |= *ptr++; - struct { uint8 r, g, b, a; } pal[256]; - if (!trueColor) for (int i = 0; i < 256; i++) { - pal[i].r = *ptr++; - pal[i].g = *ptr++; - pal[i].b = *ptr++; - pal[i].a = opacMap[*ptr++]; - } - - // some of clippings - if (xStartSrc < 0) { - width += xStartSrc; - xStartDst -= xStartSrc; - xStartSrc = 0; - } - if (yStartSrc < 0) { - height += yStartSrc; - yStartDst -= yStartSrc; - yStartSrc = 0; - } - if (xStartSrc+width >= imgwidth) - width = imgwidth - xStartSrc; - if (yStartSrc+height >= imgheight) - height = imgheight - yStartSrc; - if (xStartDst < 0) { - width += xStartDst; - if (width <= 0) - return 0; - xStartSrc = -xStartDst; - xStartDst = 0; - } - if (yStartDst < 0) { - height += yStartDst; - if (height <= 0) - return 0; - yStartSrc = -yStartDst; - yStartDst = 0; - } - if (xStartDst+width >= LUA_SCREEN_WIDTH) - width = LUA_SCREEN_WIDTH - xStartDst; - if (yStartDst+height >= LUA_SCREEN_HEIGHT) - height = LUA_SCREEN_HEIGHT - yStartDst; - if (width <= 0 || height <= 0) - return 0; // out of screen or invalid size - - gui_prepare(); - - const uint8* pix = (const uint8*)(&ptr[yStartSrc*pitch + (xStartSrc*(trueColor?4:1))]); - int bytesToNextLine = pitch - (width * (trueColor?4:1)); - if (trueColor) - for (int y = yStartDst; y < height+yStartDst && y < LUA_SCREEN_HEIGHT; y++, pix += bytesToNextLine) { - for (int x = xStartDst; x < width+xStartDst && x < LUA_SCREEN_WIDTH; x++, pix += 4) { - gui_drawpixel_fast(x, y, LUA_BUILD_PIXEL(opacMap[pix[0]], pix[1], pix[2], pix[3])); - } - } - else - for (int y = yStartDst; y < height+yStartDst && y < LUA_SCREEN_HEIGHT; y++, pix += bytesToNextLine) { - for (int x = xStartDst; x < width+xStartDst && x < LUA_SCREEN_WIDTH; x++, pix++) { - gui_drawpixel_fast(x, y, LUA_BUILD_PIXEL(pal[*pix].a, pal[*pix].r, pal[*pix].g, pal[*pix].b)); - } - } - - return 0; -} - - -// function gui.register(function f) -// -// This function will be called just before a graphical update. -// More complicated, but doesn't suffer any frame delays. -// Nil will be accepted in place of a function to erase -// a previously registered function, and the previous function -// (if any) is returned, or nil if none. -static int gui_register(lua_State *L) { - - // We'll do this straight up. - - - // First set up the stack. - lua_settop(L,1); - - // Verify the validity of the entry - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - - // Get the old value - lua_getfield(L, LUA_REGISTRYINDEX, guiCallbackTable); - - // Save the new value - lua_pushvalue(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); - - // The old value is on top of the stack. Return it. - return 1; - -} - -// table sound.get() -static int sound_get(lua_State *L) -{ - extern ENVUNIT EnvUnits[3]; - extern int CheckFreq(uint32 cf, uint8 sr); - extern int32 curfreq[2]; - extern uint8 PSG[0x10]; - extern int32 lengthcount[4]; - extern uint8 TriCount; - extern const uint32 *NoiseFreqTable; - extern int32 DMCPeriod; - extern uint8 DMCAddressLatch, DMCSizeLatch; - extern uint8 DMCFormat; - extern char DMCHaveSample; - extern uint8 InitialRawDALatch; - - int freqReg; - double freq; - - lua_newtable(L); - - // rp2a03 start - lua_newtable(L); - // rp2a03 info setup - double nesVolumes[3]; - for (int i = 0; i < 3; i++) - { - if ((EnvUnits[i].Mode & 1) != 0) - nesVolumes[i] = EnvUnits[i].Speed; - else - nesVolumes[i] = EnvUnits[i].decvolume; - nesVolumes[i] /= 15.0; - } - // rp2a03/square1 - lua_newtable(L); - if((curfreq[0] < 8 || curfreq[0] > 0x7ff) || - (CheckFreq(curfreq[0], PSG[1]) == 0) || - (lengthcount[0] == 0)) - lua_pushnumber(L, 0.0); - else - lua_pushnumber(L, nesVolumes[0]); - lua_setfield(L, -2, "volume"); - freq = (39375000.0/352.0) / (curfreq[0] + 1); - lua_pushnumber(L, freq); - lua_setfield(L, -2, "frequency"); - lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69); - lua_setfield(L, -2, "midikey"); - lua_pushinteger(L, (PSG[0] & 0xC0) >> 6); - lua_setfield(L, -2, "duty"); - lua_newtable(L); - lua_pushinteger(L, curfreq[0]); - lua_setfield(L, -2, "frequency"); - lua_setfield(L, -2, "regs"); - lua_setfield(L, -2, "square1"); - // rp2a03/square2 - lua_newtable(L); - if((curfreq[1] < 8 || curfreq[1] > 0x7ff) || - (CheckFreq(curfreq[1], PSG[5]) == 0) || - (lengthcount[1] == 0)) - lua_pushnumber(L, 0.0); - else - lua_pushnumber(L, nesVolumes[1]); - lua_setfield(L, -2, "volume"); - freq = (39375000.0/352.0) / (curfreq[1] + 1); - lua_pushnumber(L, freq); - lua_setfield(L, -2, "frequency"); - lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69); - lua_setfield(L, -2, "midikey"); - lua_pushinteger(L, (PSG[4] & 0xC0) >> 6); - lua_setfield(L, -2, "duty"); - lua_newtable(L); - lua_pushinteger(L, curfreq[1]); - lua_setfield(L, -2, "frequency"); - lua_setfield(L, -2, "regs"); - lua_setfield(L, -2, "square2"); - // rp2a03/triangle - lua_newtable(L); - if(lengthcount[2] == 0 || TriCount == 0) - lua_pushnumber(L, 0.0); - else - lua_pushnumber(L, 1.0); - lua_setfield(L, -2, "volume"); - freqReg = PSG[0xa] | ((PSG[0xb] & 7) << 8); - freq = (39375000.0/704.0) / (freqReg + 1); - lua_pushnumber(L, freq); - lua_setfield(L, -2, "frequency"); - lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69); - lua_setfield(L, -2, "midikey"); - lua_newtable(L); - lua_pushinteger(L, freqReg); - lua_setfield(L, -2, "frequency"); - lua_setfield(L, -2, "regs"); - lua_setfield(L, -2, "triangle"); - // rp2a03/noise - lua_newtable(L); - if(lengthcount[3] == 0) - lua_pushnumber(L, 0.0); - else - lua_pushnumber(L, nesVolumes[2]); - lua_setfield(L, -2, "volume"); - freqReg = PSG[0xE] & 0xF; - lua_pushboolean(L, (PSG[0xE] & 0x80) != 0); - lua_setfield(L, -2, "short"); - freq = (39375000.0/44.0) / NoiseFreqTable[freqReg]; // probably wrong - lua_pushnumber(L, freq); - lua_setfield(L, -2, "frequency"); - lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69); - lua_setfield(L, -2, "midikey"); - lua_newtable(L); - lua_pushinteger(L, freqReg); - lua_setfield(L, -2, "frequency"); - lua_setfield(L, -2, "regs"); - lua_setfield(L, -2, "noise"); - // rp2a03/dpcm - lua_newtable(L); - if (DMCHaveSample == 0) - lua_pushnumber(L, 0.0); - else - lua_pushnumber(L, 1.0); - lua_setfield(L, -2, "volume"); - freq = (39375000.0/2.0) / DMCPeriod; - lua_pushnumber(L, freq); - lua_setfield(L, -2, "frequency"); - lua_pushnumber(L, (log(freq / 440.0) * 12 / log(2.0)) + 69); - lua_setfield(L, -2, "midikey"); - lua_pushinteger(L, 0xC000 + (DMCAddressLatch << 6)); - lua_setfield(L, -2, "dmcaddress"); - lua_pushinteger(L, (DMCSizeLatch << 4) + 1); - lua_setfield(L, -2, "dmcsize"); - lua_pushboolean(L, DMCFormat & 0x40); - lua_setfield(L, -2, "dmcloop"); - lua_pushinteger(L, InitialRawDALatch); - lua_setfield(L, -2, "dmcseed"); - lua_newtable(L); - lua_pushinteger(L, DMCFormat & 0xF); - lua_setfield(L, -2, "frequency"); - lua_setfield(L, -2, "regs"); - lua_setfield(L, -2, "dpcm"); - // rp2a03 end - lua_setfield(L, -2, "rp2a03"); - - return 1; -} - -// Debugger functions library - -// debugger.hitbreakpoint() -static int debugger_hitbreakpoint(lua_State *L) -{ - break_asap = true; - return 0; -} - -// debugger.getcyclescount() -static int debugger_getcyclescount(lua_State *L) -{ - int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base; - if (counter_value < 0) // sanity check - { - ResetDebugStatisticsCounters(); - counter_value = 0; - } - lua_pushinteger(L, counter_value); - return 1; -} - -// debugger.getinstructionscount() -static int debugger_getinstructionscount(lua_State *L) -{ - lua_pushinteger(L, total_instructions); - return 1; -} - -// debugger.resetcyclescount() -static int debugger_resetcyclescount(lua_State *L) -{ - ResetCyclesCounter(); - return 0; -} - -// debugger.resetinstructionscount() -static int debugger_resetinstructionscount(lua_State *L) -{ - ResetInstructionsCounter(); - return 0; -} - -// TAS Editor functions library - -// bool taseditor.registerauto() -static int taseditor_registerauto(lua_State *L) -{ - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L,1); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_AUTO]); - lua_insert(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_AUTO]); - //StopScriptIfFinished(luaStateToUIDMap[L]); - return 1; -} - -// bool taseditor.registermanual(string caption) -static int taseditor_registermanual(lua_State *L) -{ - if (!lua_isnil(L,1)) - luaL_checktype(L, 1, LUA_TFUNCTION); - - const char* caption = NULL; - if (!lua_isnil(L, 2)) - caption = lua_tostring(L, 2); - - lua_settop(L,1); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); - lua_insert(L,1); - lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); -#ifdef WIN32 - taseditor_lua.enableRunFunction(caption); -#endif - return 1; -} - -// bool taseditor.engaged() -static int taseditor_engaged(lua_State *L) -{ -#ifdef WIN32 - lua_pushboolean(L, taseditor_lua.engaged()); -#else - lua_pushboolean(L, false); -#endif - return 1; -} - -// bool taseditor.markedframe(int frame) -static int taseditor_markedframe(lua_State *L) -{ -#ifdef WIN32 - lua_pushboolean(L, taseditor_lua.markedframe(luaL_checkinteger(L, 1))); -#else - lua_pushboolean(L, false); -#endif - return 1; -} - -// int taseditor.getmarker(int frame) -static int taseditor_getmarker(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getmarker(luaL_checkinteger(L, 1))); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// int taseditor.setmarker(int frame) -static int taseditor_setmarker(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.setmarker(luaL_checkinteger(L, 1))); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// taseditor.removemarker(int frame) -static int taseditor_removemarker(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.removemarker(luaL_checkinteger(L, 1)); -#endif - return 0; -} - -// string taseditor.getnote(int index) -static int taseditor_getnote(lua_State *L) -{ -#ifdef WIN32 - lua_pushstring(L, taseditor_lua.getnote(luaL_checkinteger(L, 1))); -#else - lua_pushnil(L); -#endif - return 1; -} - -// taseditor.setnote(int index, string newtext) -static int taseditor_setnote(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.setnote(luaL_checkinteger(L, 1), luaL_checkstring(L, 2)); -#endif - return 0; -} - -// int taseditor.getcurrentbranch() -static int taseditor_getcurrentbranch(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getcurrentbranch()); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// string taseditor.getrecordermode() -static int taseditor_getrecordermode(lua_State *L) -{ -#ifdef WIN32 - lua_pushstring(L, taseditor_lua.getrecordermode()); -#else - lua_pushnil(L); -#endif - return 1; -} - -// int taseditor.getsuperimpose() -static int taseditor_getsuperimpose(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getsuperimpose()); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// int taseditor.getlostplayback() -static int taseditor_getlostplayback(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getlostplayback()); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// int taseditor.getplaybacktarget() -static int taseditor_getplaybacktarget(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getplaybacktarget()); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// taseditor.setplayback(int frame) -static int taseditor_setplayback(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.setplayback(luaL_checkinteger(L, 1)); -#endif - return 0; -} - -// taseditor.stopseeking() -static int taseditor_stopseeking(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.stopseeking(); -#endif - return 0; -} - -// table taseditor.getselection() -static int taseditor_getselection(lua_State *L) -{ -#ifdef WIN32 - // create temp vector and provide its reference to TAS Editor for filling the vector with data - std::vector cur_set; - taseditor_lua.getselection(cur_set); - int size = cur_set.size(); - if (size) - { - lua_createtable(L, size, 0); - for (int i = 0; i < size; ++i) - { - lua_pushinteger(L, cur_set[i]); - lua_rawseti(L, -2, i + 1); - } - } else - { - lua_pushnil(L); - } -#else - lua_pushnil(L); -#endif - return 1; -} - -// taseditor.setselection(table new_set) -static int taseditor_setselection(lua_State *L) -{ -#ifdef WIN32 - std::vector cur_set; - // retrieve new_set data from table to vector - if (!lua_isnil(L, 1)) - { - luaL_checktype(L, 1, LUA_TTABLE); - int max_index = luaL_getn(L, 1); - int i = 1; - while (i <= max_index) - { - lua_rawgeti(L, 1, i); - cur_set.push_back(lua_tonumber(L, -1)); - lua_pop(L, 1); - i++; - } - } - // and provide its reference to TAS Editor for changing selection - taseditor_lua.setselection(cur_set); -#endif - return 0; -} - -// int taseditor.getinput(int frame, int joypad) -static int taseditor_getinput(lua_State *L) -{ -#ifdef WIN32 - lua_pushinteger(L, taseditor_lua.getinput(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2))); -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// taseditor.submitinputchange(int frame, int joypad, int input) -static int taseditor_submitinputchange(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.submitinputchange(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2), luaL_checkinteger(L, 3)); -#endif - return 0; -} - -// taseditor.submitinsertframes(int frame, int joypad, int input) -static int taseditor_submitinsertframes(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.submitinsertframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); -#endif - return 0; -} - -// taseditor.submitdeleteframes(int frame, int joypad, int input) -static int taseditor_submitdeleteframes(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.submitdeleteframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); -#endif - return 0; -} - -// int taseditor.applyinputchanges([string name]) -static int taseditor_applyinputchanges(lua_State *L) -{ -#ifdef WIN32 - if (lua_isnil(L, 1)) - { - lua_pushinteger(L, taseditor_lua.applyinputchanges("")); - } else - { - const char* name = lua_tostring(L, 1); - if (name) - lua_pushinteger(L, taseditor_lua.applyinputchanges(name)); - else - lua_pushinteger(L, taseditor_lua.applyinputchanges("")); - } -#else - lua_pushinteger(L, -1); -#endif - return 1; -} - -// taseditor.clearinputchanges() -static int taseditor_clearinputchanges(lua_State *L) -{ -#ifdef WIN32 - taseditor_lua.clearinputchanges(); -#endif - return 0; -} - - -static int doPopup(lua_State *L, const char* deftype, const char* deficon) { - const char *str = luaL_checkstring(L, 1); - const char* type = lua_type(L,2) == LUA_TSTRING ? lua_tostring(L,2) : deftype; - const char* icon = lua_type(L,3) == LUA_TSTRING ? lua_tostring(L,3) : deficon; - - int itype = -1, iters = 0; - while(itype == -1 && iters++ < 2) - { - if(!stricmp(type, "ok")) itype = 0; - else if(!stricmp(type, "yesno")) itype = 1; - else if(!stricmp(type, "yesnocancel")) itype = 2; - else if(!stricmp(type, "okcancel")) itype = 3; - else if(!stricmp(type, "abortretryignore")) itype = 4; - else type = deftype; - } - assert(itype >= 0 && itype <= 4); - if(!(itype >= 0 && itype <= 4)) itype = 0; - - int iicon = -1; iters = 0; - while(iicon == -1 && iters++ < 2) - { - if(!stricmp(icon, "message") || !stricmp(icon, "notice")) iicon = 0; - else if(!stricmp(icon, "question")) iicon = 1; - else if(!stricmp(icon, "warning")) iicon = 2; - else if(!stricmp(icon, "error")) iicon = 3; - else icon = deficon; - } - assert(iicon >= 0 && iicon <= 3); - if(!(iicon >= 0 && iicon <= 3)) iicon = 0; - - static const char * const titles [] = {"Notice", "Question", "Warning", "Error"}; - const char* answer = "ok"; - -#ifdef WIN32 - static const int etypes [] = {MB_OK, MB_YESNO, MB_YESNOCANCEL, MB_OKCANCEL, MB_ABORTRETRYIGNORE}; - static const int eicons [] = {MB_ICONINFORMATION, MB_ICONQUESTION, MB_ICONWARNING, MB_ICONERROR}; - //StopSound(); //mbg merge 7/27/08 - int ianswer = MessageBox(hAppWnd, str, titles[iicon], etypes[itype] | eicons[iicon]); - switch(ianswer) - { - case IDOK: answer = "ok"; break; - case IDCANCEL: answer = "cancel"; break; - case IDABORT: answer = "abort"; break; - case IDRETRY: answer = "retry"; break; - case IDIGNORE: answer = "ignore"; break; - case IDYES: answer = "yes"; break; - case IDNO: answer = "no"; break; - } - - lua_pushstring(L, answer); - return 1; -#else - - char *t; -#ifdef __linux - - int pid; // appease compiler - - // Before doing any work, verify the correctness of the parameters. - if (strcmp(type, "ok") == 0) - t = "OK:100"; - else if (strcmp(type, "yesno") == 0) - t = "Yes:100,No:101"; - else if (strcmp(type, "yesnocancel") == 0) - t = "Yes:100,No:101,Cancel:102"; - else - return luaL_error(L, "invalid popup type \"%s\"", type); - - // Can we find a copy of xmessage? Search the path. - - char *path = strdup(getenv("PATH")); - - char *current = path; - - char *colon; - - int found = 0; - - while (current) { - colon = strchr(current, ':'); - - // Clip off the colon. - *colon++ = 0; - - int len = strlen(current); - char *filename = (char*)FCEU_dmalloc(len + 12); // always give excess - snprintf(filename, len+12, "%s/xmessage", current); - - if (access(filename, X_OK) == 0) { - free(filename); - found = 1; - break; - } - - // Failed, move on. - current = colon; - free(filename); - - } - - free(path); - - // We've found it? - if (!found) - goto use_console; - - pid = fork(); - if (pid == 0) {// I'm the virgin sacrifice - - // I'm gonna be dead in a matter of microseconds anyways, so wasted memory doesn't matter to me. - // Go ahead and abuse strdup. - char * parameters[] = {"xmessage", "-buttons", t, strdup(str), NULL}; - - execvp("xmessage", parameters); - - // Aw shitty - perror("exec xmessage"); - exit(1); - } - else if (pid < 0) // something went wrong!!! Oh hell... use the console - goto use_console; - else { - // We're the parent. Watch for the child. - int r; - int res = waitpid(pid, &r, 0); - if (res < 0) // wtf? - goto use_console; - - // The return value gets copmlicated... - if (!WIFEXITED(r)) { - luaL_error(L, "don't screw with my xmessage process!"); - } - r = WEXITSTATUS(r); - - // We assume it's worked. - if (r == 0) - { - return 0; // no parameters for an OK - } - if (r == 100) { - lua_pushstring(L, "yes"); - return 1; - } - if (r == 101) { - lua_pushstring(L, "no"); - return 1; - } - if (r == 102) { - lua_pushstring(L, "cancel"); - return 1; - } - - // Wtf? - return luaL_error(L, "popup failed due to unknown results involving xmessage (%d)", r); - } - -use_console: -#endif - - // All else has failed - - if (strcmp(type, "ok") == 0) - t = ""; - else if (strcmp(type, "yesno") == 0) - t = "yn"; - else if (strcmp(type, "yesnocancel") == 0) - t = "ync"; - else - return luaL_error(L, "invalid popup type \"%s\"", type); - - fprintf(stderr, "Lua Message: %s\n", str); - - while (true) { - char buffer[64]; - - // We don't want parameters - if (!t[0]) { - fprintf(stderr, "[Press Enter]"); - fgets(buffer, sizeof(buffer), stdin); - // We're done - return 0; - - } - fprintf(stderr, "(%s): ", t); - fgets(buffer, sizeof(buffer), stdin); - - // Check if the option is in the list - if (strchr(t, tolower(buffer[0]))) { - switch (tolower(buffer[0])) { - case 'y': - lua_pushstring(L, "yes"); - return 1; - case 'n': - lua_pushstring(L, "no"); - return 1; - case 'c': - lua_pushstring(L, "cancel"); - return 1; - default: - luaL_error(L, "internal logic error in console based prompts for gui.popup"); - - } - } - - // We fell through, so we assume the user answered wrong and prompt again. - - } - - // Nothing here, since the only way out is in the loop. -#endif - -} - -static int doOpenFilePopup(lua_State *L, bool saveFile) { -#ifdef WIN32 - char filename[PATH_MAX]; - OPENFILENAME ofn; - ZeroMemory(&ofn, sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hAppWnd; - ofn.lpstrFilter = TEXT("All files (*.*)\0*.*\0\0"); - ofn.nFilterIndex = 0; - filename[0] = TEXT('\0'); - ofn.lpstrFile = filename; - ofn.nMaxFile = PATH_MAX; - ofn.Flags = OFN_NOCHANGEDIR | (saveFile ? OFN_OVERWRITEPROMPT : OFN_FILEMUSTEXIST); - BOOL bResult = saveFile ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn); - lua_newtable(L); - if (bResult) - { - lua_pushstring(L, filename); - lua_rawseti(L, -2, 1); - } -#else - // TODO: more sophisticated interface - char filename[PATH_MAX]; - printf("Enter %s filename: ", saveFile ? "save" : "open"); - fgets(filename, PATH_MAX, stdin); - lua_newtable(L); - lua_pushstring(L, filename); - lua_rawseti(L, -2, 1); -#endif - return 1; -} - -// string gui.popup(string message, string type = "ok", string icon = "message") -// string input.popup(string message, string type = "yesno", string icon = "question") -static int gui_popup(lua_State *L) -{ - return doPopup(L, "ok", "message"); -} -static int input_popup(lua_State *L) -{ - return doPopup(L, "yesno", "question"); -} - -static int input_openfilepopup(lua_State *L) -{ - return doOpenFilePopup(L, false); -} -static int input_savefilepopup(lua_State *L) -{ - return doOpenFilePopup(L, true); -} - -// the following bit operations are ported from LuaBitOp 1.0.1, -// because it can handle the sign bit (bit 31) correctly. - -/* -** Lua BitOp -- a bit operations library for Lua 5.1. -** http://bitop.luajit.org/ -** -** Copyright (C) 2008-2009 Mike Pall. All rights reserved. -** -** Permission is hereby granted, free of charge, to any person obtaining -** a copy of this software and associated documentation files (the -** "Software"), to deal in the Software without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Software, and to -** permit persons to whom the Software is furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be -** included in all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] -*/ - -#ifdef _MSC_VER -/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -#else -#include -#endif - -typedef int32_t SBits; -typedef uint32_t UBits; - -typedef union { - lua_Number n; -#ifdef LUA_NUMBER_DOUBLE - uint64_t b; -#else - UBits b; -#endif -} BitNum; - -/* Convert argument to bit type. */ -static UBits barg(lua_State *L, int idx) -{ - BitNum bn; - UBits b; - bn.n = lua_tonumber(L, idx); -#if defined(LUA_NUMBER_DOUBLE) - bn.n += 6755399441055744.0; /* 2^52+2^51 */ -#ifdef SWAPPED_DOUBLE - b = (UBits)(bn.b >> 32); -#else - b = (UBits)bn.b; -#endif -#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \ - defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \ - defined(LUA_NUMBER_LLONG) - if (sizeof(UBits) == sizeof(lua_Number)) - b = bn.b; - else - b = (UBits)(SBits)bn.n; -#elif defined(LUA_NUMBER_FLOAT) -#error "A 'float' lua_Number type is incompatible with this library" -#else -#error "Unknown number type, check LUA_NUMBER_* in luaconf.h" -#endif - if (b == 0 && !lua_isnumber(L, idx)) - luaL_typerror(L, idx, "number"); - return b; -} - -/* Return bit type. */ -#define BRET(b) lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1; - -static int bit_tobit(lua_State *L) { BRET(barg(L, 1)) } -static int bit_bnot(lua_State *L) { BRET(~barg(L, 1)) } - -#define BIT_OP(func, opr) \ - static int func(lua_State *L) { int i; UBits b = barg(L, 1); \ - for (i = lua_gettop(L); i > 1; i--) b opr barg(L, i); BRET(b) } -BIT_OP(bit_band, &=) -BIT_OP(bit_bor, |=) -BIT_OP(bit_bxor, ^=) - -#define bshl(b, n) (b << n) -#define bshr(b, n) (b >> n) -#define bsar(b, n) ((SBits)b >> n) -#define brol(b, n) ((b << n) | (b >> (32-n))) -#define bror(b, n) ((b << (32-n)) | (b >> n)) -#define BIT_SH(func, fn) \ - static int func(lua_State *L) { \ - UBits b = barg(L, 1); UBits n = barg(L, 2) & 31; BRET(fn(b, n)) } -BIT_SH(bit_lshift, bshl) -BIT_SH(bit_rshift, bshr) -BIT_SH(bit_arshift, bsar) -BIT_SH(bit_rol, brol) -BIT_SH(bit_ror, bror) - -static int bit_bswap(lua_State *L) -{ - UBits b = barg(L, 1); - b = (b >> 24) | ((b >> 8) & 0xff00) | ((b & 0xff00) << 8) | (b << 24); - BRET(b) -} - -static int bit_tohex(lua_State *L) -{ - UBits b = barg(L, 1); - SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2); - const char *hexdigits = "0123456789abcdef"; - char buf[8]; - int i; - if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } - if (n > 8) n = 8; - for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } - lua_pushlstring(L, buf, (size_t)n); - return 1; -} - -static const struct luaL_Reg bit_funcs[] = { - { "tobit", bit_tobit }, - { "bnot", bit_bnot }, - { "band", bit_band }, - { "bor", bit_bor }, - { "bxor", bit_bxor }, - { "lshift", bit_lshift }, - { "rshift", bit_rshift }, - { "arshift", bit_arshift }, - { "rol", bit_rol }, - { "ror", bit_ror }, - { "bswap", bit_bswap }, - { "tohex", bit_tohex }, - { NULL, NULL } -}; - -/* Signed right-shifts are implementation-defined per C89/C99. -** But the de facto standard are arithmetic right-shifts on two's -** complement CPUs. This behaviour is required here, so test for it. -*/ -#define BAD_SAR (bsar(-8, 2) != (SBits)-2) - -bool luabitop_validate(lua_State *L) // originally named as luaopen_bit -{ - UBits b; - lua_pushnumber(L, (lua_Number)1437217655L); - b = barg(L, -1); - if (b != (UBits)1437217655L || BAD_SAR) { /* Perform a simple self-test. */ - const char *msg = "compiled with incompatible luaconf.h"; -#ifdef LUA_NUMBER_DOUBLE -#ifdef WIN32 - if (b == (UBits)1610612736L) - msg = "use D3DCREATE_FPU_PRESERVE with DirectX"; -#endif - if (b == (UBits)1127743488L) - msg = "not compiled with SWAPPED_DOUBLE"; -#endif - if (BAD_SAR) - msg = "arithmetic right-shift broken"; - luaL_error(L, "bit library self-test failed (%s)", msg); - return false; - } - return true; -} - -// LuaBitOp ends here - -static int bit_bshift_emulua(lua_State *L) -{ - int shift = luaL_checkinteger(L,2); - if (shift < 0) { - lua_pushinteger(L, -shift); - lua_replace(L, 2); - return bit_lshift(L); - } - else - return bit_rshift(L); -} - -static int bitbit(lua_State *L) -{ - int rv = 0; - int numArgs = lua_gettop(L); - for(int i = 1; i <= numArgs; i++) { - int where = luaL_checkinteger(L,i); - if (where >= 0 && where < 32) - rv |= (1 << where); - } - lua_settop(L,0); - BRET(rv); -} - -// The function called periodically to ensure Lua doesn't run amok. -static void FCEU_LuaHookFunction(lua_State *L, lua_Debug *dbg) { - - if (numTries-- == 0) { - - int kill = 0; - -#ifdef WIN32 - // Uh oh - //StopSound(); //mbg merge 7/23/08 - int ret = MessageBox(hAppWnd, "The Lua script running has been running a long time. It may have gone crazy. Kill it?\n\n(No = don't check anymore either)", "Lua Script Gone Nuts?", MB_YESNO); - - if (ret == IDYES) { - kill = 1; - } - -#else - fprintf(stderr, "The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n"); - char buffer[64]; - while (TRUE) { - fprintf(stderr, "(y/n): "); - fgets(buffer, sizeof(buffer), stdin); - if (buffer[0] == 'y' || buffer[0] == 'Y') { - kill = 1; - break; - } - - if (buffer[0] == 'n' || buffer[0] == 'N') - break; - } -#endif - - if (kill) { - luaL_error(L, "Killed by user request."); - FCEU_LuaOnStop(); - } - - // else, kill the debug hook. - lua_sethook(L, NULL, 0, 0); - } - - -} - -static void emu_exec_count_hook(lua_State *L, lua_Debug *dbg) { - luaL_error(L, "exec_count timeout"); -} - -static int emu_exec_count(lua_State *L) { - int count = (int)luaL_checkinteger(L,1); - lua_pushvalue(L, 2); - lua_sethook(L, emu_exec_count_hook, LUA_MASKCOUNT, count); - int ret = lua_pcall(L, 0, 0, 0); - lua_sethook(L, NULL, 0, 0); - lua_settop(L,0); - lua_pushinteger(L, ret); - return 1; -} - -#ifdef WIN32 -static HANDLE readyEvent, goEvent; -DWORD WINAPI emu_exec_time_proc(LPVOID lpParameter) -{ - SetEvent(readyEvent); - WaitForSingleObject(goEvent,INFINITE); - lua_State *L = (lua_State *)lpParameter; - lua_pushvalue(L, 2); - int ret = lua_pcall(L, 0, 0, 0); - lua_settop(L,0); - lua_pushinteger(L, ret); - SetEvent(readyEvent); - return 0; -} - -static void emu_exec_time_hook(lua_State *L, lua_Debug *dbg) { - luaL_error(L, "exec_time timeout"); -} - -static int emu_exec_time(lua_State *L) -{ - int count = (int)luaL_checkinteger(L,1); - - readyEvent = CreateEvent(0,true,false,0); - goEvent = CreateEvent(0,true,false,0); - DWORD threadid; - HANDLE thread = CreateThread(0,0,emu_exec_time_proc,(LPVOID)L,0,&threadid); - SetThreadAffinityMask(thread,1); - //wait for the lua thread to start - WaitForSingleObject(readyEvent,INFINITE); - ResetEvent(readyEvent); - //tell the lua thread to proceed - SetEvent(goEvent); - //wait for the lua thread to finish, but no more than the specified amount of time - WaitForSingleObject(readyEvent,count); - - //kill lua (if it hasnt already been killed) - lua_sethook(L, emu_exec_time_hook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); - - //keep on waiting for the lua thread to come back - WaitForSingleObject(readyEvent,count); - - //clear the lua thread-killer - lua_sethook(L, NULL, 0, 0); - - CloseHandle(readyEvent); - CloseHandle(goEvent); - CloseHandle(thread); - - return 1; -} - -#else -static int emu_exec_time(lua_State *L) { return 0; } -#endif - -static const struct luaL_reg emulib [] = { - - {"poweron", emu_poweron}, - {"softreset", emu_softreset}, - {"speedmode", emu_speedmode}, - {"frameadvance", emu_frameadvance}, - {"paused", emu_paused}, - {"pause", emu_pause}, - {"unpause", emu_unpause}, - {"exec_count", emu_exec_count}, - {"exec_time", emu_exec_time}, - {"setrenderplanes", emu_setrenderplanes}, - {"message", emu_message}, - {"framecount", emu_framecount}, - {"lagcount", emu_lagcount}, - {"lagged", emu_lagged}, - {"setlagflag", emu_setlagflag}, - {"emulating", emu_emulating}, - {"registerbefore", emu_registerbefore}, - {"registerafter", emu_registerafter}, - {"registerexit", emu_registerexit}, - {"addgamegenie", emu_addgamegenie}, - {"delgamegenie", emu_delgamegenie}, - {"getscreenpixel", emu_getscreenpixel}, - {"readonly", movie_getreadonly}, - {"setreadonly", movie_setreadonly}, - {"print", print}, // sure, why not - {NULL,NULL} -}; - -static const struct luaL_reg romlib [] = { - {"readbyte", rom_readbyte}, - {"readbytesigned", rom_readbytesigned}, - // alternate naming scheme for unsigned - {"readbyteunsigned", rom_readbyte}, - - {"gethash", rom_gethash}, - {NULL,NULL} -}; - - -static const struct luaL_reg memorylib [] = { - - {"readbyte", memory_readbyte}, - {"readbyterange", memory_readbyterange}, - {"readbytesigned", memory_readbytesigned}, - {"readbyteunsigned", memory_readbyte}, // alternate naming scheme for unsigned - {"readword", memory_readword}, - {"readwordsigned", memory_readwordsigned}, - {"readwordunsigned", memory_readword}, // alternate naming scheme for unsigned - {"writebyte", memory_writebyte}, - {"getregister", memory_getregister}, - {"setregister", memory_setregister}, - - // memory hooks - {"registerwrite", memory_registerwrite}, - //{"registerread", memory_registerread}, TODO - {"registerexec", memory_registerexec}, - // alternate names - {"register", memory_registerwrite}, - {"registerrun", memory_registerexec}, - {"registerexecute", memory_registerexec}, - - {NULL,NULL} -}; - -static const struct luaL_reg joypadlib[] = { - {"get", joypad_get}, - {"getdown", joypad_getdown}, - {"getup", joypad_getup}, - {"getimmediate", joypad_getimmediate}, - {"set", joypad_set}, - // alternative names - {"read", joypad_get}, - {"write", joypad_set}, - {"readdown", joypad_getdown}, - {"readup", joypad_getup}, - {"readimmediate", joypad_getimmediate}, - {NULL,NULL} -}; - -static const struct luaL_reg zapperlib[] = { - {"read", zapper_read}, - {NULL,NULL} -}; - -static const struct luaL_reg inputlib[] = { - {"get", input_get}, - {"popup", input_popup}, - {"openfilepopup", input_openfilepopup}, - {"savefilepopup", input_savefilepopup}, - // alternative names - {"read", input_get}, - {NULL,NULL} -}; - -static const struct luaL_reg savestatelib[] = { - {"create", savestate_create}, - {"object", savestate_object}, - {"save", savestate_save}, - {"persist", savestate_persist}, - {"load", savestate_load}, - - {"registersave", savestate_registersave}, - {"registerload", savestate_registerload}, - {"loadscriptdata", savestate_loadscriptdata}, - - {NULL,NULL} -}; - -static const struct luaL_reg movielib[] = { - - {"framecount", emu_framecount}, // for those familiar with other emulators that have movie.framecount() instead of emulatorname.framecount() - {"mode", movie_mode}, - {"rerecordcounting", movie_rerecordcounting}, - {"stop", movie_stop}, - {"active", movie_isactive}, - {"recording", movie_isrecording}, - {"playing", movie_isplaying}, - {"length", movie_getlength}, - {"rerecordcount", movie_rerecordcount}, - {"name", movie_getname}, - {"filename", movie_getfilename}, - {"readonly", movie_getreadonly}, - {"setreadonly", movie_setreadonly}, - {"replay", movie_replay}, -// {"record", movie_record}, -// {"play", movie_playback}, - - // alternative names - {"close", movie_stop}, - {"getname", movie_getname}, -// {"playback", movie_playback}, - {"playbeginning", movie_replay}, - {"getreadonly", movie_getreadonly}, - {"ispoweron", movie_ispoweron}, //If movie recorded from power-on - {"isfromsavestate", movie_isfromsavestate}, //If movie is recorded from savestate - {NULL,NULL} - -}; - - -static const struct luaL_reg guilib[] = { - - {"pixel", gui_pixel}, - {"getpixel", gui_getpixel}, - {"line", gui_line}, - {"box", gui_box}, - {"text", gui_text}, - - {"parsecolor", gui_parsecolor}, - - {"savescreenshot", gui_savescreenshot}, - {"savescreenshotas", gui_savescreenshotas}, - {"gdscreenshot", gui_gdscreenshot}, - {"gdoverlay", gui_gdoverlay}, - {"opacity", gui_setopacity}, - {"transparency", gui_transparency}, - - {"register", gui_register}, - - {"popup", gui_popup}, - // alternative names - {"drawtext", gui_text}, - {"drawbox", gui_box}, - {"drawline", gui_line}, - {"drawpixel", gui_pixel}, - {"setpixel", gui_pixel}, - {"writepixel", gui_pixel}, - {"rect", gui_box}, - {"drawrect", gui_box}, - {"drawimage", gui_gdoverlay}, - {"image", gui_gdoverlay}, - {NULL,NULL} -}; - -static const struct luaL_reg soundlib[] = { - - {"get", sound_get}, - {NULL,NULL} -}; - -static const struct luaL_reg debuggerlib[] = { - - {"hitbreakpoint", debugger_hitbreakpoint}, - {"getcyclescount", debugger_getcyclescount}, - {"getinstructionscount", debugger_getinstructionscount}, - {"resetcyclescount", debugger_resetcyclescount}, - {"resetinstructionscount", debugger_resetinstructionscount}, - {NULL,NULL} -}; - -static const struct luaL_reg taseditorlib[] = { - - {"registerauto", taseditor_registerauto}, - {"registermanual", taseditor_registermanual}, - {"engaged", taseditor_engaged}, - {"markedframe", taseditor_markedframe}, - {"getmarker", taseditor_getmarker}, - {"setmarker", taseditor_setmarker}, - {"removemarker", taseditor_removemarker}, - {"getnote", taseditor_getnote}, - {"setnote", taseditor_setnote}, - {"getcurrentbranch", taseditor_getcurrentbranch}, - {"getrecordermode", taseditor_getrecordermode}, - {"getsuperimpose", taseditor_getsuperimpose}, - {"getlostplayback", taseditor_getlostplayback}, - {"getplaybacktarget", taseditor_getplaybacktarget}, - {"setplayback", taseditor_setplayback}, - {"stopseeking", taseditor_stopseeking}, - {"getselection", taseditor_getselection}, - {"setselection", taseditor_setselection}, - {"getinput", taseditor_getinput}, - {"submitinputchange", taseditor_submitinputchange}, - {"submitinsertframes", taseditor_submitinsertframes}, - {"submitdeleteframes", taseditor_submitdeleteframes}, - {"applyinputchanges", taseditor_applyinputchanges}, - {"clearinputchanges", taseditor_clearinputchanges}, - {NULL,NULL} -}; - -void CallExitFunction() { - if (!L) - return; - - lua_settop(L, 0); - lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_BEFOREEXIT]); - - int errorcode = 0; - if (lua_isfunction(L, -1)) - { - //chdir(luaCWD); - errorcode = lua_pcall(L, 0, 0, 0); - //_getcwd(luaCWD, _MAX_PATH); - } - - if (errorcode) - HandleCallbackError(L); -} - -void FCEU_LuaFrameBoundary() -{ - //printf("Lua Frame\n"); - - // HA! - if (!L || !luaRunning) - return; - - // Our function needs calling - lua_settop(L,0); - lua_getfield(L, LUA_REGISTRYINDEX, frameAdvanceThread); - lua_State *thread = lua_tothread(L,1); - - // Lua calling C must know that we're busy inside a frame boundary - frameBoundary = TRUE; - frameAdvanceWaiting = FALSE; - - numTries = 1000; - int result = lua_resume(thread, 0); - - if (result == LUA_YIELD) { - // Okay, we're fine with that. - } else if (result != 0) { - // Done execution by bad causes - FCEU_LuaOnStop(); - lua_pushnil(L); - lua_setfield(L, LUA_REGISTRYINDEX, frameAdvanceThread); - - // Error? -#ifdef WIN32 - //StopSound();//StopSound(); //mbg merge 7/23/08 - MessageBox( hAppWnd, lua_tostring(thread,-1), "Lua run error", MB_OK | MB_ICONSTOP); -#else - fprintf(stderr, "Lua thread bombed out: %s\n", lua_tostring(thread,-1)); -#endif - - } else { - FCEU_LuaOnStop(); - FCEU_DispMessage("Script died of natural causes.\n",0); - } - - // Past here, the nes actually runs, so any Lua code is called mid-frame. We must - // not do anything too stupid, so let ourselves know. - frameBoundary = FALSE; - - if (!frameAdvanceWaiting) { - FCEU_LuaOnStop(); - } - -} - -/** - * Loads and runs the given Lua script. - * The emulator MUST be paused for this function to be - * called. Otherwise, all frame boundary assumptions go out the window. - * - * Returns true on success, false on failure. - */ -int FCEU_LoadLuaCode(const char *filename, const char *arg) { - if (!DemandLua()) - { - return 0; - } - - if (filename != luaScriptName) - { - if (luaScriptName) free(luaScriptName); - luaScriptName = strdup(filename); - } - -#if defined(WIN32) || defined(__linux) - std::string getfilepath = filename; - - getfilepath = getfilepath.substr(0,getfilepath.find_last_of("/\\") + 1); - - SetCurrentDir(getfilepath.c_str()); -#endif - - //stop any lua we might already have had running - FCEU_LuaStop(); - - //Reinit the error count - luaexiterrorcount = 8; - - if (!L) { - - L = lua_open(); - luaL_openlibs(L); - #if defined( WIN32) && !defined(NEED_MINGW_HACKS) - iuplua_open(L); - iupcontrolslua_open(L); - luaopen_winapi(L); - - //luasocket - yeah, have to open this in a weird way - lua_pushcfunction(L,luaopen_socket_core); - lua_setglobal(L,"tmp"); - luaL_dostring(L, "package.preload[\"socket.core\"] = _G.tmp"); - lua_pushcfunction(L,luaopen_mime_core); - lua_setglobal(L,"tmp"); - luaL_dostring(L, "package.preload[\"mime.core\"] = _G.tmp"); - #endif - - luaL_register(L, "emu", emulib); // added for better cross-emulator compatibility - luaL_register(L, "FCEU", emulib); // kept for backward compatibility - luaL_register(L, "memory", memorylib); - luaL_register(L, "rom", romlib); - luaL_register(L, "joypad", joypadlib); - luaL_register(L, "zapper", zapperlib); - luaL_register(L, "input", inputlib); - luaL_register(L, "savestate", savestatelib); - luaL_register(L, "movie", movielib); - luaL_register(L, "gui", guilib); - luaL_register(L, "sound", soundlib); - luaL_register(L, "debugger", debuggerlib); - luaL_register(L, "taseditor", taseditorlib); - luaL_register(L, "bit", bit_funcs); // LuaBitOp library - lua_settop(L, 0); // clean the stack, because each call to luaL_register leaves a table on top - - // register a few utility functions outside of libraries (in the global namespace) - lua_register(L, "print", print); - lua_register(L, "tostring", tostring); - lua_register(L, "tobitstring", tobitstring); - lua_register(L, "addressof", addressof); - lua_register(L, "copytable", copytable); - - // old bit operation functions - lua_register(L, "AND", bit_band); - lua_register(L, "OR", bit_bor); - lua_register(L, "XOR", bit_bxor); - lua_register(L, "SHIFT", bit_bshift_emulua); - lua_register(L, "BIT", bitbit); - - if (arg) - { - luaL_Buffer b; - luaL_buffinit(L, &b); - luaL_addstring(&b, arg); - luaL_pushresult(&b); - - lua_setglobal(L, "arg"); - } - - luabitop_validate(L); - - // push arrays for storing hook functions in - for(int i = 0; i < LUAMEMHOOK_COUNT; i++) - { - lua_newtable(L); - lua_setfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[i]); - } - } - - // We make our thread NOW because we want it at the bottom of the stack. - // If all goes wrong, we let the garbage collector remove it. - lua_State *thread = lua_newthread(L); - - // Load the data - int result = luaL_loadfile(L,filename); - - if (result) { -#ifdef WIN32 - // Doing this here caused nasty problems; reverting to MessageBox-from-dialog behavior. - //StopSound();//StopSound(); //mbg merge 7/23/08 - MessageBox(NULL, lua_tostring(L,-1), "Lua load error", MB_OK | MB_ICONSTOP); -#else - fprintf(stderr, "Failed to compile file: %s\n", lua_tostring(L,-1)); -#endif - - // Wipe the stack. Our thread - lua_settop(L,0); - return 0; // Oh shit. - } -#ifdef WIN32 - AddRecentLuaFile(filename); //Add the filename to our recent lua menu -#endif - - // Get our function into it - lua_xmove(L, thread, 1); - - // Save the thread to the registry. This is why I make the thread FIRST. - lua_setfield(L, LUA_REGISTRYINDEX, frameAdvanceThread); - - - // Initialize settings - luaRunning = TRUE; - skipRerecords = FALSE; - numMemHooks = 0; - transparencyModifier = 255; // opaque - - //wasPaused = FCEUI_EmulationPaused(); - //if (wasPaused) FCEUI_ToggleEmulationPause(); - - // And run it right now. :) - //FCEU_LuaFrameBoundary(); - - // Set up our protection hook to be executed once every 10,000 bytecode instructions. - //lua_sethook(thread, FCEU_LuaHookFunction, LUA_MASKCOUNT, 10000); - -#ifdef WIN32 - info_print = PrintToWindowConsole; - info_onstart = WinLuaOnStart; - info_onstop = WinLuaOnStop; - if(!LuaConsoleHWnd) - LuaConsoleHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_LUA), hAppWnd, (DLGPROC) DlgLuaScriptDialog); - info_uid = (int)LuaConsoleHWnd; -#else - info_print = NULL; - info_onstart = NULL; - info_onstop = NULL; -#endif - if (info_onstart) - info_onstart(info_uid); - - // We're done. - return 1; -} - -/** - * Equivalent to repeating the last FCEU_LoadLuaCode() call. - */ -void FCEU_ReloadLuaCode() -{ - if (!luaScriptName) - { -#ifdef WIN32 - // no script currently running, then try loading the most recent - extern char *recent_lua[]; - char*& fname = recent_lua[0]; - extern void UpdateLuaConsole(const char* fname); - if (fname) - { - UpdateLuaConsole(fname); - FCEU_LoadLuaCode(fname); - } else - { - FCEU_DispMessage("There's no script to reload.", 0); - } -#else - FCEU_DispMessage("There's no script to reload.", 0); -#endif - } else - { - FCEU_LoadLuaCode(luaScriptName); - } -} - - -/** - * Terminates a running Lua script by killing the whole Lua engine. - * - * Always safe to call, except from within a lua call itself (duh). - * - */ -void FCEU_LuaStop() { - - if (!CheckLua()) - return; - - //already killed - if (!L) return; - - // Since the script is exiting, we want to prevent an infinite loop. - // CallExitFunction() > HandleCallbackError() > FCEU_LuaStop() > CallExitFunction() ... - if (luaexiterrorcount > 0) { - luaexiterrorcount = luaexiterrorcount - 1; - //execute the user's shutdown callbacks - CallExitFunction(); - } - - luaexiterrorcount = luaexiterrorcount + 1; - - //already killed (after multiple errors) - if (!L) return; - - /*info.*/numMemHooks = 0; - for(int i = 0; i < LUAMEMHOOK_COUNT; i++) - CalculateMemHookRegions((LuaMemHookType)i); - - //sometimes iup uninitializes com - //MBG TODO - test whether this is really necessary. i dont think it is - #ifdef WIN32 - CoInitialize(0); - #endif - - if (info_onstop) - info_onstop(info_uid); - - //lua_gc(L,LUA_GCCOLLECT,0); - - - lua_close(L); // this invokes our garbage collectors for us - L = NULL; - FCEU_LuaOnStop(); -} - -/** - * Returns true if there is a Lua script running. - * - */ -int FCEU_LuaRunning() { - // FIXME: return false when no callback functions are registered. - return (int) (L != NULL); // should return true if callback functions are active. -} - - -/** - * Returns true if Lua would like to steal the given joypad control. - */ -//int FCEU_LuaUsingJoypad(int which) { -// return lua_joypads_used & (1 << which); -//} - -//adelikat: TODO: should I have a FCEU_LuaUsingJoypadFalse? - -/** - * Reads the buttons Lua is feeding for the given joypad, in the same - * format as the OS-specific code. - * - * It may force set or force clear the buttons. It may also simply - * pass the input along or invert it. The act of calling this - * function will reset everything back to pass-through, though. - * Generally means don't call it more than once per frame! - */ -uint8 FCEU_LuaReadJoypad(int which, uint8 joyl) { - joyl = (joyl & luajoypads1[which]) | (~joyl & luajoypads2[which]); - luajoypads1[which] = 0xFF; - luajoypads2[which] = 0x00; - return joyl; -} - -//adelikat: Returns the buttons that will be specifically set to false (as opposed to on or nil) -//This will be used in input.cpp to &(and) against the input to override a button with a false value. This is a work around to allow 3 conditions to be sent be lua, true, false, nil -//uint8 FCEU_LuaReadJoypadFalse(int which) { -// lua_joypads_used_false &= ~(1 << which); -// return lua_joypads_false[which]; -//} - -/** - * If this function returns true, the movie code should NOT increment - * the rerecord count for a load-state. - * - * This function will not return true if a script is not running. - */ -int FCEU_LuaRerecordCountSkip() { - // FIXME: return true if (there are any active callback functions && skipRerecords) - return L && luaRunning && skipRerecords; -} - -/** - * Given an 8-bit screen with the indicated resolution, - * draw the current GUI onto it. - * - * Currently we only support 256x* resolutions. - */ -void FCEU_LuaGui(uint8 *XBuf) -{ - if (!L/* || !luaRunning*/) - return; - - // First, check if we're being called by anybody - lua_getfield(L, LUA_REGISTRYINDEX, guiCallbackTable); - - if (lua_isfunction(L, -1)) { - // We call it now - numTries = 1000; - int ret = lua_pcall(L, 0, 0, 0); - if (ret != 0) { -#ifdef WIN32 - //StopSound();//StopSound(); //mbg merge 7/23/08 - MessageBox(hAppWnd, lua_tostring(L, -1), "Lua Error in GUI function", MB_OK); -#else - fprintf(stderr, "Lua error in gui.register function: %s\n", lua_tostring(L, -1)); -#endif - // This is grounds for trashing the function - lua_pushnil(L); - lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); - - } - } - - // And wreak the stack - lua_settop(L, 0); - - if (gui_used == GUI_CLEAR) - return; - - if (gui_used == GUI_USED_SINCE_LAST_FRAME && !FCEUI_EmulationPaused()) - { - memset(gui_data, 0, LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4); - gui_used = GUI_CLEAR; - return; - } - - gui_used = GUI_USED_SINCE_LAST_FRAME; - - int x, y; - - for (y = 0; y < LUA_SCREEN_HEIGHT; y++) - { - for (x=0; x < LUA_SCREEN_WIDTH; x++) - { - const uint8 gui_alpha = gui_data[(y*LUA_SCREEN_WIDTH+x)*4+3]; - if (gui_alpha == 0) - { - // do nothing - continue; - } - - const uint8 gui_red = gui_data[(y*LUA_SCREEN_WIDTH+x)*4+2]; - const uint8 gui_green = gui_data[(y*LUA_SCREEN_WIDTH+x)*4+1]; - const uint8 gui_blue = gui_data[(y*LUA_SCREEN_WIDTH+x)*4]; - - int r, g, b; - if (gui_alpha == 255) { - // direct copy - r = gui_red; - g = gui_green; - b = gui_blue; - } - else { - // alpha-blending - uint8 scr_red, scr_green, scr_blue; - FCEUD_GetPalette(XBuf[(y)*256+x], &scr_red, &scr_green, &scr_blue); - r = (((int) gui_red - scr_red) * gui_alpha / 255 + scr_red) & 255; - g = (((int) gui_green - scr_green) * gui_alpha / 255 + scr_green) & 255; - b = (((int) gui_blue - scr_blue) * gui_alpha / 255 + scr_blue) & 255; - } - - XBuf[(y)*256+x] = gui_colour_rgb(r, g, b); - } - } - - return; -} - - -lua_State* FCEU_GetLuaState() { - return L; -} -char* FCEU_GetLuaScriptName() { - return luaScriptName; -} diff --git a/branches/fceux-2.2.2/src/movie.cpp b/branches/fceux-2.2.2/src/movie.cpp deleted file mode 100644 index e57d502b..00000000 --- a/branches/fceux-2.2.2/src/movie.cpp +++ /dev/null @@ -1,1681 +0,0 @@ -#include "emufile.h" -#include "version.h" -#include "types.h" -#include "utils/endian.h" -#include "palette.h" -#include "input.h" -#include "fceu.h" -#include "netplay.h" -#include "driver.h" -#include "state.h" -#include "file.h" -#include "video.h" -#include "movie.h" -#include "fds.h" -#include "vsuni.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif -#include "utils/guid.h" -#include "utils/memory.h" -#include "utils/xstring.h" -#include - -#ifdef CREATE_AVI -#include "drivers/videolog/nesvideos-piece.h" -#endif - -#ifdef WIN32 -#include -#include "./drivers/win/common.h" -#include "./drivers/win/window.h" -extern void AddRecentMovieFile(const char *filename); -#include "./drivers/win/taseditor.h" -extern bool mustEngageTaseditor; -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#define MOVIE_VERSION 3 - -extern char FileBase[]; -extern bool AutoSS; //Declared in fceu.cpp, keeps track if a auto-savestate has been made - -std::vector subtitleFrames; //Frame numbers for subtitle messages -std::vector subtitleMessages; //Messages of subtitles - -bool subtitlesOnAVI = false; -bool autoMovieBackup = false; //Toggle that determines if movies should be backed up automatically before altering them -bool freshMovie = false; //True when a movie loads, false when movie is altered. Used to determine if a movie has been altered since opening -bool movieFromPoweron = true; - -static int _currCommand = 0; - -// Function declarations------------------------ - - -//TODO - remove the synchack stuff from the replay gui and require it to be put into the fm2 file -//which the user would have already converted from fcm -//also cleanup the whole emulator version bullshit in replay. we dont support that old stuff anymore - -//todo - better error handling for the compressed savestate - -//todo - consider a MemoryBackedFile class.. -//..a lot of work.. instead lets just read back from the current fcm - -//todo - could we, given a field size, over-read from an inputstream and then parse out an integer? -//that would be faster than several reads, perhaps. - -//sometimes we accidentally produce movie stop signals while we're trying to do other things with movies.. -bool suppressMovieStop=false; - -//----movie engine main state -EMOVIEMODE movieMode = MOVIEMODE_INACTIVE; - -//this should not be set unless we are in MOVIEMODE_RECORD! -//FILE* fpRecordingMovie = 0; -EMUFILE* osRecordingMovie = NULL; - -int currFrameCounter; -uint32 cur_input_display = 0; -int pauseframe = -1; -bool movie_readonly = true; -int input_display = 0; -int frame_display = 0; -int rerecord_display = 0; -bool fullSaveStateLoads = false; //Option for loading a savestates full contents in read+write mode instead of up to the frame count in the savestate (useful as a recovery option) - -SFORMAT FCEUMOV_STATEINFO[]={ - { &currFrameCounter, 4|FCEUSTATE_RLSB, "FCNT"}, - { 0 } -}; - -char curMovieFilename[512] = {0}; -MovieData currMovieData; -MovieData defaultMovieData; - -char lagcounterbuf[32] = {0}; - -void MovieData::clearRecordRange(int start, int len) -{ - for(int i=0;i (int)records.size()) - frames = (int)records.size() - at; - records.erase(records.begin() + at, records.begin() + (at + frames)); - } - } -} - -void MovieData::insertEmpty(int at, int frames) -{ - if (at == -1) - { - records.resize(records.size() + frames); - } else - { - records.insert(records.begin() + at, frames, MovieRecord()); - } -} - -void MovieData::cloneRegion(int at, int frames) -{ - if (at < 0) return; - - records.insert(records.begin() + at, frames, MovieRecord()); - - for(int i = 0; i < frames; i++) - records[i + at].Clone(records[i + at + frames]); -} -// ---------------------------------------------------------------------------- -MovieRecord::MovieRecord() -{ - commands = 0; - *(uint32*)&joysticks = 0; - memset(zappers, 0, sizeof(zappers)); -} - -void MovieRecord::clear() -{ - commands = 0; - *(uint32*)&joysticks = 0; - memset(zappers, 0, sizeof(zappers)); -} - -bool MovieRecord::Compare(MovieRecord& compareRec) -{ - //Joysticks, Zappers, and commands - - if (this->commands != compareRec.commands) - return false; - if ((*(uint32*)&(this->joysticks)) != (*(uint32*)&(compareRec.joysticks))) - return false; - if (memcmp(this->zappers, compareRec.zappers, sizeof(zappers))) - return false; - - /* - if (this->joysticks != compareRec.joysticks) - return false; - - //if new commands are ever recordable, they need to be added here if we go with this method - if(this->command_reset() != compareRec.command_reset()) return false; - if(this->command_power() != compareRec.command_power()) return false; - if(this->command_fds_insert() != compareRec.command_fds_insert()) return false; - if(this->command_fds_select() != compareRec.command_fds_select()) return false; - - if (this->zappers[0].x != compareRec.zappers[0].x) return false; - if (this->zappers[0].y != compareRec.zappers[0].y) return false; - if (this->zappers[0].zaphit != compareRec.zappers[0].zaphit) return false; - if (this->zappers[0].b != compareRec.zappers[0].b) return false; - if (this->zappers[0].bogo != compareRec.zappers[0].bogo) return false; - - if (this->zappers[1].x != compareRec.zappers[1].x) return false; - if (this->zappers[1].y != compareRec.zappers[1].y) return false; - if (this->zappers[1].zaphit != compareRec.zappers[1].zaphit) return false; - if (this->zappers[1].b != compareRec.zappers[1].b) return false; - if (this->zappers[1].bogo != compareRec.zappers[1].bogo) return false; - */ - - return true; -} -void MovieRecord::Clone(MovieRecord& sourceRec) -{ - *(uint32*)&joysticks = *(uint32*)(&(sourceRec.joysticks)); - memcpy(this->zappers, sourceRec.zappers, sizeof(zappers)); - this->commands = sourceRec.commands; -} - -const char MovieRecord::mnemonics[8] = {'A','B','S','T','U','D','L','R'}; - -void MovieRecord::dumpJoy(EMUFILE* os, uint8 joystate) -{ - //these are mnemonics for each joystick bit. - //since we usually use the regular joypad, these will be more helpful. - //but any character other than ' ' or '.' should count as a set bit - //maybe other input types will need to be encoded another way.. - for(int bit=7;bit>=0;bit--) - { - int bitmask = (1<fwrite(&mnemonic,1); - else //otherwise write an unset bit - write8le('.',os); - } -} - -void MovieRecord::parseJoy(EMUFILE* is, uint8& joystate) -{ - char buf[8]; - is->fread(buf,8); - joystate = 0; - for(int i=0;i<8;i++) - { - joystate <<= 1; - joystate |= ((buf[i]=='.'||buf[i]==' ')?0:1); - } -} - -void MovieRecord::parse(MovieData* md, EMUFILE* is) -{ - //by the time we get in here, the initial pipe has already been extracted - - //extract the commands - commands = uint32DecFromIstream(is); - //*is >> commands; - is->fgetc(); //eat the pipe - - //a special case: if fourscore is enabled, parse four gamepads - if(md->fourscore) - { - parseJoy(is,joysticks[0]); is->fgetc(); //eat the pipe - parseJoy(is,joysticks[1]); is->fgetc(); //eat the pipe - parseJoy(is,joysticks[2]); is->fgetc(); //eat the pipe - parseJoy(is,joysticks[3]); is->fgetc(); //eat the pipe - } - else - { - for(int port=0;port<2;port++) - { - if(md->ports[port] == SI_GAMEPAD) - parseJoy(is, joysticks[port]); - else if(md->ports[port] == SI_ZAPPER) - { - zappers[port].x = uint32DecFromIstream(is); - zappers[port].y = uint32DecFromIstream(is); - zappers[port].b = uint32DecFromIstream(is); - zappers[port].bogo = uint32DecFromIstream(is); - zappers[port].zaphit = uint64DecFromIstream(is); - } - - is->fgetc(); //eat the pipe - } - } - - //(no fcexp data is logged right now) - is->fgetc(); //eat the pipe - - //should be left at a newline -} - - -bool MovieRecord::parseBinary(MovieData* md, EMUFILE* is) -{ - commands = (uint8)is->fgetc(); - - //check for eof - if(is->eof()) return false; - - if(md->fourscore) - { - is->fread((char*)&joysticks,4); - } - else - { - for(int port=0;port<2;port++) - { - if(md->ports[port] == SI_GAMEPAD) - joysticks[port] = (uint8)is->fgetc(); - else if(md->ports[port] == SI_ZAPPER) - { - zappers[port].x = (uint8)is->fgetc(); - zappers[port].y = (uint8)is->fgetc(); - zappers[port].b = (uint8)is->fgetc(); - zappers[port].bogo = (uint8)is->fgetc(); - read64le(&zappers[port].zaphit,is); - } - } - } - - return true; -} - - -void MovieRecord::dumpBinary(MovieData* md, EMUFILE* os, int index) -{ - write8le(commands,os); - if(md->fourscore) - { - for(int i=0;i<4;i++) - os->fwrite(&joysticks[i],sizeof(joysticks[i])); - } - else - { - for(int port=0;port<2;port++) - { - if(md->ports[port] == SI_GAMEPAD) - os->fwrite(&joysticks[port],sizeof(joysticks[port])); - else if(md->ports[port] == SI_ZAPPER) - { - write8le(zappers[port].x,os); - write8le(zappers[port].y,os); - write8le(zappers[port].b,os); - write8le(zappers[port].bogo,os); - write64le(zappers[port].zaphit, os); - } - } - } -} - -void MovieRecord::dump(MovieData* md, EMUFILE* os, int index) -{ - // dump the commands - //*os << '|' << setw(1) << (int)commands; - os->fputc('|'); - putdec(os, commands); // "variable length decimal integer" - - //a special case: if fourscore is enabled, dump four gamepads - if(md->fourscore) - { - os->fputc('|'); - dumpJoy(os,joysticks[0]); os->fputc('|'); - dumpJoy(os,joysticks[1]); os->fputc('|'); - dumpJoy(os,joysticks[2]); os->fputc('|'); - dumpJoy(os,joysticks[3]); os->fputc('|'); - } - else - { - for(int port=0;port<2;port++) - { - os->fputc('|'); - if(md->ports[port] == SI_GAMEPAD) - dumpJoy(os, joysticks[port]); - else if(md->ports[port] == SI_ZAPPER) - { - putdec(os,zappers[port].x); os->fputc(' '); - putdec(os,zappers[port].y); os->fputc(' '); - putdec(os,zappers[port].b); os->fputc(' '); - putdec(os,zappers[port].bogo); os->fputc(' '); - putdec(os,zappers[port].zaphit); - } - } - os->fputc('|'); - } - - //(no fcexp data is logged right now) - os->fputc('|'); - - //each frame is on a new line - os->fputc('\n'); -} - -MovieData::MovieData() - : version(MOVIE_VERSION) - , emuVersion(FCEU_VERSION_NUMERIC) - , palFlag(false) - , PPUflag(false) - , rerecordCount(0) - , binaryFlag(false) - , loadFrameCount(-1) - , microphone(false) -{ - memset(&romChecksum,0,sizeof(MD5DATA)); -} - -void MovieData::truncateAt(int frame) -{ - records.resize(frame); -} - -void MovieData::installValue(std::string& key, std::string& val) -{ - //todo - use another config system, or drive this from a little data structure. because this is gross - if(key == "FDS") - installInt(val,fds); - else if(key == "NewPPU") - installBool(val,PPUflag); - else if(key == "version") - installInt(val,version); - else if(key == "emuVersion") - installInt(val,emuVersion); - else if(key == "rerecordCount") - installInt(val,rerecordCount); - else if(key == "palFlag") - installBool(val,palFlag); - else if(key == "romFilename") - romFilename = val; - else if(key == "romChecksum") - StringToBytes(val,&romChecksum,MD5DATA::size); - else if(key == "guid") - guid = FCEU_Guid::fromString(val); - else if(key == "fourscore") - installBool(val,fourscore); - else if(key == "microphone") - installBool(val,microphone); - else if(key == "port0") - installInt(val,ports[0]); - else if(key == "port1") - installInt(val,ports[1]); - else if(key == "port2") - installInt(val,ports[2]); - else if(key == "binary") - installBool(val,binaryFlag); - else if(key == "comment") - comments.push_back(mbstowcs(val)); - else if (key == "subtitle") - subtitles.push_back(val); //mbstowcs(val)); - else if(key == "savestate") - { - int len = Base64StringToBytesLength(val); - if(len == -1) len = HexStringToBytesLength(val); // wasn't base64, try hex - if(len >= 1) - { - savestate.resize(len); - StringToBytes(val,&savestate[0],len); // decodes either base64 or hex - } - } - else if (key == "length") - { - installInt(val, loadFrameCount); - } -} - -int MovieData::dump(EMUFILE *os, bool binary) -{ - int start = os->ftell(); - os->fprintf("version %d\n", version); - os->fprintf("emuVersion %d\n", emuVersion); - os->fprintf("rerecordCount %d\n", rerecordCount); - os->fprintf("palFlag %d\n" , (palFlag?1:0) ); - os->fprintf("romFilename %s\n" , romFilename.c_str() ); - os->fprintf("romChecksum %s\n" , BytesToString(romChecksum.data,MD5DATA::size).c_str() ); - os->fprintf("guid %s\n" , guid.toString().c_str() ); - os->fprintf("fourscore %d\n" , (fourscore?1:0) ); - os->fprintf("microphone %d\n" , (microphone?1:0) ); - os->fprintf("port0 %d\n" , ports[0] ); - os->fprintf("port1 %d\n" , ports[1] ); - os->fprintf("port2 %d\n" , ports[2] ); - os->fprintf("FDS %d\n" , fds?1:0 ); - os->fprintf("NewPPU %d\n" , PPUflag?1:0 ); - - for(uint32 i=0;ifprintf("comment %s\n" , wcstombs(comments[i]).c_str() ); - - for(uint32 i=0;ifprintf("subtitle %s\n" , subtitles[i].c_str() ); - - if(binary) - os->fprintf("binary 1\n" ); - - if(savestate.size()) - os->fprintf("savestate %s\n" , BytesToString(&savestate[0],savestate.size()).c_str() ); - - if (this->loadFrameCount >= 0) - os->fprintf("length %d\n" , this->loadFrameCount); - - if(binary) - { - //put one | to start the binary dump - os->fputc('|'); - for(int i=0;i<(int)records.size();i++) - records[i].dumpBinary(this, os, i); - } else - { - for(int i=0;i<(int)records.size();i++) - records[i].dump(this, os, i); - } - - int end = os->ftell(); - return end-start; -} - -int FCEUMOV_GetFrame(void) -{ - return currFrameCounter; -} - -int FCEUI_GetLagCount(void) -{ - return lagCounter; -} - -bool FCEUI_GetLagged(void) -{ - if (lagFlag) - return true; - else - return false; -} -void FCEUI_SetLagFlag(bool value) -{ - lagFlag = (value) ? 1 : 0; -} - -bool FCEUMOV_ShouldPause(void) -{ - if(pauseframe && currFrameCounter+1 == pauseframe) - { - pauseframe = 0; - return true; - } - else - { - return false; - } -} - -EMOVIEMODE FCEUMOV_Mode() -{ - return movieMode; -} - -bool FCEUMOV_Mode(EMOVIEMODE modemask) -{ - return (movieMode&modemask)!=0; -} - -bool FCEUMOV_Mode(int modemask) -{ - return FCEUMOV_Mode((EMOVIEMODE)modemask); -} - -static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size) -{ - int recordsize = 1; //1 for the command - if(movieData.fourscore) - recordsize += 4; //4 joysticks - else - { - for(int i=0;i<2;i++) - { - switch(movieData.ports[i]) - { - case SI_GAMEPAD: recordsize++; break; - case SI_ZAPPER: recordsize+=12; break; - } - } - } - - //find out how much remains in the file - int curr = fp->ftell(); - fp->fseek(0,SEEK_END); - int end = fp->ftell(); - int flen = end-curr; - fp->fseek(curr,SEEK_SET); - - //the amount todo is the min of the limiting size we received and the remaining contents of the file - int todo = std::min(size, flen); - - int numRecords = todo/recordsize; - if (movieData.loadFrameCount!=-1 && movieData.loadFrameCountftell(); - - if (!stopAfterHeader) - { - // first, look for an fcm signature - char fcmbuf[3]; - fp->fread(fcmbuf,3); - fp->fseek(curr,SEEK_SET); - if(!strncmp(fcmbuf,"FCM",3)) { - FCEU_PrintError("FCM File format is no longer supported. Please use Tools > Convert FCM"); - return false; - } - } - - //movie must start with "version 3" - char buf[9]; - curr = fp->ftell(); - fp->fread(buf,9); - fp->fseek(curr,SEEK_SET); - if(fp->fail()) return false; - if(memcmp(buf,"version 3",9)) - return false; - - std::string key,value; - enum { - NEWLINE, KEY, SEPARATOR, VALUE, RECORD, COMMENT, SUBTITLE - } state = NEWLINE; - bool bail = false; - bool iswhitespace, isrecchar, isnewline; - int c; - for(;;) - { - if(size--<=0) goto bail; - c = fp->fgetc(); - if(c == -1) - goto bail; - iswhitespace = (c==' '||c=='\t'); - isrecchar = (c=='|'); - isnewline = (c==10||c==13); - if(isrecchar && movieData.binaryFlag && !stopAfterHeader) - { - LoadFM2_binarychunk(movieData, fp, size); - return true; - } else if (isnewline && movieData.loadFrameCount == movieData.records.size()) - // exit prematurely if loaded the specified amound of records - return true; - switch(state) - { - case NEWLINE: - if(isnewline) goto done; - if(iswhitespace) goto done; - if(isrecchar) - goto dorecord; - //must be a key - key = ""; - value = ""; - goto dokey; - break; - case RECORD: - { - dorecord: - if (stopAfterHeader) return true; - int currcount = movieData.records.size(); - movieData.records.resize(currcount+1); - int preparse = fp->ftell(); - movieData.records[currcount].parse(&movieData, fp); - int postparse = fp->ftell(); - size -= (postparse-preparse); - state = NEWLINE; - break; - } - - case KEY: - dokey: //dookie - state = KEY; - if(iswhitespace) goto doseparator; - if(isnewline) goto commit; - key += c; - break; - case SEPARATOR: - doseparator: - state = SEPARATOR; - if(isnewline) goto commit; - if(!iswhitespace) goto dovalue; - break; - case VALUE: - dovalue: - state = VALUE; - if(isnewline) goto commit; - value += c; - } - goto done; - - bail: - bail = true; - if(state == VALUE) goto commit; - goto done; - commit: - movieData.installValue(key,value); - state = NEWLINE; - done: ; - if(bail) break; - } - - return true; -} - -/// Stop movie playback. -static void StopPlayback() -{ - FCEU_DispMessageOnMovie("Movie playback stopped."); - movieMode = MOVIEMODE_INACTIVE; -} - -// Stop movie playback without closing the movie. -static void FinishPlayback() -{ - extern int closeFinishedMovie; - if (closeFinishedMovie) - StopPlayback(); - else - { - FCEU_DispMessage("Movie finished playing.",0); - movieMode = MOVIEMODE_FINISHED; - } -} - -static void closeRecordingMovie() -{ - if(osRecordingMovie) - { - delete osRecordingMovie; - osRecordingMovie = 0; - } -} - -/// Stop movie recording -static void StopRecording() -{ - FCEU_DispMessage("Movie recording stopped.",0); - movieMode = MOVIEMODE_INACTIVE; - - closeRecordingMovie(); -} - -void FCEUI_StopMovie() -{ - if(suppressMovieStop) - return; - - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_FINISHED) - StopPlayback(); - else if(movieMode == MOVIEMODE_RECORD) - StopRecording(); - - curMovieFilename[0] = 0; //No longer a current movie filename - freshMovie = false; //No longer a fresh movie loaded - if (bindSavestate) AutoSS = false; //If bind movies to savestates is true, then there is no longer a valid auto-save to load - -#ifdef WIN32 - SetMainWindowText(); -#endif -} - -void poweron(bool shouldDisableBatteryLoading) -{ - //// make a for-movie-recording power-on clear the game's save data, too - //extern char lastLoadedGameName [2048]; - //extern int disableBatteryLoading, suppressAddPowerCommand; - //suppressAddPowerCommand=1; - //if(shouldDisableBatteryLoading) disableBatteryLoading=1; - //suppressMovieStop=true; - //{ - // //we need to save the pause state through this process - // int oldPaused = EmulationPaused; - - // // NOTE: this will NOT write an FCEUNPCMD_POWER into the movie file - // FCEUGI* gi = FCEUI_LoadGame(lastLoadedGameName, 0); - // assert(gi); - // PowerNES(); - - // EmulationPaused = oldPaused; - //} - //suppressMovieStop=false; - //if(shouldDisableBatteryLoading) disableBatteryLoading=0; - //suppressAddPowerCommand=0; - - extern int disableBatteryLoading; - disableBatteryLoading = 1; - PowerNES(); - disableBatteryLoading = 0; -} - -void FCEUMOV_CreateCleanMovie() -{ - currMovieData = MovieData(); - currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0; - currMovieData.romFilename = FileBase; - currMovieData.romChecksum = GameInfo->MD5; - currMovieData.guid.newGuid(); - currMovieData.fourscore = FCEUI_GetInputFourscore(); - currMovieData.microphone = FCEUI_GetInputMicrophone(); - currMovieData.ports[0] = joyports[0].type; - currMovieData.ports[1] = joyports[1].type; - currMovieData.ports[2] = portFC.type; - currMovieData.fds = isFDS; - currMovieData.PPUflag = (newppu != 0); -} -void FCEUMOV_ClearCommands() -{ - _currCommand = 0; -} - -bool FCEUMOV_FromPoweron() -{ - return movieFromPoweron; -} -bool MovieData::loadSavestateFrom(std::vector* buf) -{ - EMUFILE_MEMORY ms(buf); - return FCEUSS_LoadFP(&ms,SSLOADPARAM_BACKUP); -} - -void MovieData::dumpSavestateTo(std::vector* buf, int compressionLevel) -{ - EMUFILE_MEMORY ms(buf); - FCEUSS_SaveMS(&ms,compressionLevel); - ms.trim(); -} - -//begin playing an existing movie -bool FCEUI_LoadMovie(const char *fname, bool _read_only, int _pauseframe) -{ - if(!FCEU_IsValidUI(FCEUI_PLAYMOVIE)) - return true; //adelikat: file did not fail to load, so let's return true here, just do nothing - - assert(fname); - - //mbg 6/10/08 - we used to call StopMovie here, but that cleared curMovieFilename and gave us crashes... - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_FINISHED) - StopPlayback(); - else if(movieMode == MOVIEMODE_RECORD) - StopRecording(); - //-------------- - - currMovieData = MovieData(); - - strcpy(curMovieFilename, fname); - FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0); - if (!fp) return false; - if(fp->isArchive() && !_read_only) { - FCEU_PrintError("Cannot open a movie in read+write from an archive."); - return true; //adelikat: file did not fail to load, so return true (false is only for file not exist/unable to open errors - } - -#ifdef WIN32 - //Fix relative path if necessary and then add to the recent movie menu - extern std::string BaseDirectory; - - string name = fname; - if (IsRelativePath(fname)) - { - name = ConvertRelativePath(name); - } - AddRecentMovieFile(name.c_str()); -#endif - - LoadFM2(currMovieData, fp->stream, fp->size, false); - LoadSubtitles(currMovieData); - delete fp; - - freshMovie = true; //Movie has been loaded, so it must be unaltered - if (bindSavestate) AutoSS = false; //If bind savestate to movie is true, then their isn't a valid auto-save to load, so flag it - //fully reload the game to reinitialize everything before playing any movie - poweron(true); - - if(currMovieData.savestate.size()) - { - //WE NEED TO LOAD A SAVESTATE - movieFromPoweron = false; - bool success = MovieData::loadSavestateFrom(&currMovieData.savestate); - if(!success) return true; //adelikat: I guess return true here? False is only for a bad movie filename, if it got this far the file was good? - } else { - movieFromPoweron = true; - } - - //if there is no savestate, we won't have this crucial piece of information at the start of the movie. - //so, we have to include it with the movie - if(currMovieData.palFlag) - FCEUI_SetVidSystem(1); - else - FCEUI_SetVidSystem(0); - - //force the input configuration stored in the movie to apply - FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]); - - //stuff that should only happen when we're ready to positively commit to the replay - currFrameCounter = 0; - pauseframe = _pauseframe; - movie_readonly = _read_only; - movieMode = MOVIEMODE_PLAY; - - if(movie_readonly) - FCEU_DispMessage("Replay started Read-Only.",0); - else - FCEU_DispMessage("Replay started Read+Write.",0); - -#ifdef WIN32 - SetMainWindowText(); -#endif - - #ifdef CREATE_AVI - if(LoggingEnabled) - { - FCEU_DispMessage("Video recording enabled.\n",0); - LoggingEnabled = 2; - } - #endif - - return true; -} - -static void openRecordingMovie(const char* fname) -{ - osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); - if(!osRecordingMovie) - FCEU_PrintError("Error opening movie output file: %s",fname); - strcpy(curMovieFilename, fname); -#ifdef WIN32 - //Add to the recent movie menu - AddRecentMovieFile(fname); -#endif -} - - -//begin recording a new movie -//TODO - BUG - the record-from-another-savestate doesnt work. -void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author) -{ - if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE)) - return; - - assert(fname); - - FCEUI_StopMovie(); - - openRecordingMovie(fname); - - currFrameCounter = 0; - LagCounterReset(); - FCEUMOV_CreateCleanMovie(); - if(author != L"") currMovieData.comments.push_back(L"author " + author); - - if(flags & MOVIE_FLAG_FROM_POWERON) - { - movieFromPoweron = true; - poweron(true); - } - else - { - movieFromPoweron = false; - MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION); - } - - FCEUMOV_ClearCommands(); - - //we are going to go ahead and dump the header. from now on we will only be appending frames - currMovieData.dump(osRecordingMovie, false); - - movieMode = MOVIEMODE_RECORD; - movie_readonly = false; - - FCEU_DispMessage("Movie recording started.",0); -} - - -//the main interaction point between the emulator and the movie system. -//either dumps the current joystick state or loads one state from the movie -void FCEUMOV_AddInputState() -{ -#ifdef _WIN32 - if (movieMode == MOVIEMODE_TASEDITOR) - { - // if movie length is less or equal to currFrame, pad it with empty frames - if (((int)currMovieData.records.size() - 1) < (currFrameCounter + 1)) - currMovieData.insertEmpty(-1, (currFrameCounter + 1) - ((int)currMovieData.records.size() - 1)); - - MovieRecord* mr = &currMovieData.records[currFrameCounter]; - if (isTaseditorRecording()) - { - // record commands and buttons - mr->commands |= _currCommand; - joyports[0].log(mr); - joyports[1].log(mr); - recordInputByTaseditor(); - } - // replay buttons - joyports[0].load(mr); - joyports[1].load(mr); - // replay commands - if (mr->command_power()) - PowerNES(); - if (mr->command_reset()) - ResetNES(); - if (mr->command_fds_insert()) - FCEU_FDSInsert(); - if (mr->command_fds_select()) - FCEU_FDSSelect(); - if (mr->command_vs_insertcoin()) - FCEU_VSUniCoin(); - _currCommand = 0; - } else -#endif - if (movieMode == MOVIEMODE_PLAY) - { - //stop when we run out of frames - if (currFrameCounter >= (int)currMovieData.records.size()) - { - FinishPlayback(); - //tell all drivers to poll input and set up their logical states - for(int port=0;port<2;port++) - joyports[port].driver->Update(port,joyports[port].ptr,joyports[port].attrib); - portFC.driver->Update(portFC.ptr,portFC.attrib); - } else - { - MovieRecord* mr = &currMovieData.records[currFrameCounter]; - - //reset and power cycle if necessary - if(mr->command_power()) - PowerNES(); - if(mr->command_reset()) - ResetNES(); - if(mr->command_fds_insert()) - FCEU_FDSInsert(); - if(mr->command_fds_select()) - FCEU_FDSSelect(); - if (mr->command_vs_insertcoin()) - FCEU_VSUniCoin(); - - joyports[0].load(mr); - joyports[1].load(mr); - } - - //if we are on the last frame, then pause the emulator if the player requested it - if (currFrameCounter == currMovieData.records.size()-1) - { - if(FCEUD_PauseAfterPlayback()) - { - FCEUI_ToggleEmulationPause(); - } - } - - //pause the movie at a specified frame - if (FCEUMOV_ShouldPause() && FCEUI_EmulationPaused()==0) - { - FCEUI_ToggleEmulationPause(); - FCEU_DispMessage("Paused at specified movie frame",0); - } - - } else if (movieMode == MOVIEMODE_RECORD) - { - MovieRecord mr; - - joyports[0].log(&mr); - joyports[1].log(&mr); - mr.commands = _currCommand; - _currCommand = 0; - - //Adelikat: in normal mode, this is done at the time of loading a savestate in read+write mode - //If the user chooses it can be delayed to here - if (fullSaveStateLoads && (currFrameCounter < (int)currMovieData.records.size())) - currMovieData.truncateAt(currFrameCounter); - - mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size()); // to disk - - currMovieData.records.push_back(mr); - } - - currFrameCounter++; - - extern uint8 joy[4]; - memcpy(&cur_input_display,joy,4); -} - - -//TODO -void FCEUMOV_AddCommand(int cmd) -{ - // do nothing if not recording a movie - if(movieMode != MOVIEMODE_RECORD && movieMode != MOVIEMODE_TASEDITOR) - return; - - // translate "FCEU NetPlay" command to "FCEU Movie" command - switch (cmd) - { - case FCEUNPCMD_RESET: cmd = MOVIECMD_RESET; break; - case FCEUNPCMD_POWER: cmd = MOVIECMD_POWER; break; - case FCEUNPCMD_FDSINSERT: cmd = MOVIECMD_FDS_INSERT; break; - case FCEUNPCMD_FDSSELECT: cmd = MOVIECMD_FDS_SELECT; break; - case FCEUNPCMD_VSUNICOIN: cmd = MOVIECMD_VS_INSERTCOIN; break; - // all other netplay commands (e.g. FCEUNPCMD_VSUNIDIP0) are not supported by movie recorder for now - default: return; - } - - _currCommand |= cmd; -} - -void FCEU_DrawMovies(uint8 *XBuf) -{ - if(frame_display) - { - char counterbuf[32] = {0}; - int color = 0x20; - if(movieMode == MOVIEMODE_PLAY) - sprintf(counterbuf,"%d/%d",currFrameCounter,(int)currMovieData.records.size()); - else if(movieMode == MOVIEMODE_RECORD) - sprintf(counterbuf,"%d",currFrameCounter); - else if (movieMode == MOVIEMODE_FINISHED) - { - sprintf(counterbuf,"%d/%d (finished)",currFrameCounter,(int)currMovieData.records.size()); - color = 0x17; //Show red to get attention - } else if(movieMode == MOVIEMODE_TASEDITOR) - { - sprintf(counterbuf,"%d",currFrameCounter); - } else - sprintf(counterbuf,"%d (no movie)",currFrameCounter); - - if(counterbuf[0]) - DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(30)+1, 256, (uint8*)counterbuf, color+0x80); - } - if(rerecord_display && movieMode != MOVIEMODE_INACTIVE) - { - char counterbuf[32] = {0}; - sprintf(counterbuf,"%d",currMovieData.rerecordCount); - - if(counterbuf[0]) - DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(50)+1, 256, (uint8*)counterbuf, 0x28+0x80); - } -} - -void FCEU_DrawLagCounter(uint8 *XBuf) -{ - if (lagCounterDisplay) - { - // If currently lagging - display red, else display green - uint8 color = (lagFlag) ? (0x16+0x80) : (0x2A+0x80); - sprintf(lagcounterbuf, "%d", lagCounter); - if(lagcounterbuf[0]) - DrawTextTrans(ClipSidesOffset + XBuf + FCEU_TextScanlineOffsetFromBottom(40) + 1, 256, (uint8*)lagcounterbuf, color); - } -} - -int FCEUMOV_WriteState(EMUFILE* os) -{ - //we are supposed to dump the movie data into the savestate - if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_FINISHED) - return currMovieData.dump(os, true); - else return 0; -} - -// returns -int CheckTimelines(MovieData& stateMovie, MovieData& currMovie) -{ - // end_frame = min(urrMovie.records.size(), stateMovie.records.size(), currFrameCounter) - int end_frame = currMovie.records.size(); - if (end_frame > (int)stateMovie.records.size()) - end_frame = stateMovie.records.size(); - if (end_frame > currFrameCounter) - end_frame = currFrameCounter; - - for (int x = 0; x < end_frame; x++) - { - if (!stateMovie.records[x].Compare(currMovie.records[x])) - return x; - } - // no mismatch found - return -1; -} - - -static bool load_successful; - -bool FCEUMOV_ReadState(EMUFILE* is, uint32 size) -{ - load_successful = false; - - if (!movie_readonly) - { - if (currMovieData.loadFrameCount >= 0) - { -#ifdef WIN32 - int result = MessageBox(hAppWnd, "This movie is a TAS Editor project file.\nIt can be modified in TAS Editor only.\n\nOpen it in TAS Editor now?", "Movie Replay", MB_YESNO); - if (result == IDYES) - mustEngageTaseditor = true; -#else - FCEUI_printf("This movie is a TAS Editor project file! It can be modified in TAS Editor only.\nMovie is now Read-Only.\n"); -#endif - movie_readonly = true; - } - if (FCEU_isFileInArchive(curMovieFilename)) - { - //a little rule: cant load states in read+write mode with a movie from an archive. - //so we are going to switch it to readonly mode in that case - FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only."); - movie_readonly = true; - } - } - - MovieData tempMovieData = MovieData(); - std::ios::pos_type curr = is->ftell(); - if(!LoadFM2(tempMovieData, is, size, false)) { - is->fseek((uint32)curr+size,SEEK_SET); - extern bool FCEU_state_loading_old_format; - if(FCEU_state_loading_old_format) { - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_FINISHED) { - //FCEUI_StopMovie(); //No reason to stop the movie, nothing destructive has happened yet. - FCEU_PrintError("You have tried to use an old savestate while playing a movie. This is unsupported (since the old savestate has old-format movie data in it which can't be converted on the fly)"); - } - } - return false; - } - - //---------------- - //complex TAS logic for loadstate - //fully conforms to the savestate logic documented in the Laws of TAS - //http://tasvideos.org/LawsOfTAS/OnSavestates.html - //---------------- - - /* - Playback or Recording + Read-only - - * Check that GUID of movie and savestate-movie must match or else error - o on error: a message informing that the savestate doesn't belong to this movie. This is a GUID mismatch error. Give user a choice to load it anyway. - + failstate: if use declines, loadstate attempt canceled, movie can resume as if not attempted if user has backup savstates enabled else stop movie - * Check that movie and savestate-movie are in same timeline. If not then this is a wrong timeline error. - o on error: a message informing that the savestate doesn't belong to this movie - + failstate: loadstate attempt canceled, movie can resume as if not attempted if user has backup savestates enabled else stop movie - * Check that savestate-movie is not greater than movie. If it's greater then this is a future event error and is not allowed in read-only - o on error: message informing that the savestate is from a frame after the last frame of the movie - + failstate - loadstate attempt cancelled, movie can resume if user has backup savesattes enabled, else stop movie - * Check that savestate framcount <= savestate movie length. If not this is a post-movie savestate and is not allowed in read-only - o on error: message informing that the savestate is from a frame after the last frame of the savestated movie - + failstate - loadstate attempt cancelled, movie can resume if user has backup savesattes enabled, else stop movie - * All error checks have passed, state will be loaded - * Movie contained in the savestate will be discarded - * Movie is now in Playback mode - - Playback, Recording + Read+write - - * Check that GUID of movie and savestate-movie must match or else error - o on error: a message informing that the savestate doesn't belong to this movie. This is a GUID mismatch error. Give user a choice to load it anyway. - + failstate: if use declines, loadstate attempt canceled, movie can resume as if not attempted (stop movie if resume fails)canceled, movie can resume if backup savestates enabled else stopmovie - * Check that savestate framcount <= savestate movie length. If not this is a post-movie savestate - o on post-movie: See post-movie event section. - * savestate passed all error checks and will now be loaded in its entirety and replace movie (note: there will be no truncation yet) - * current framecount will be set to savestate framecount - * on the next frame of input, movie will be truncated to framecount - o (note: savestate-movie can be a future event of the movie timeline, or a completely new timeline and it is still allowed) - * Rerecord count of movie will be incremented - * Movie is now in record mode - - Post-movie savestate event - - * Whan a savestate is loaded and is determined that the savestate-movie length is less than the savestate framecount then it is a post-movie savestate. These occur when a savestate was made during Movie Finished mode. - * If read+write, the entire savestate movie will be loaded and replace current movie. - * If read-only, the savestate movie will be discarded - * Mode will be switched to Move Finished - * Savestate will be loaded - * Current framecount changes to savestate framecount - * User will have control of input as if Movie inactive mode - */ - - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_FINISHED) - { - //handle moviefile mismatch - if(tempMovieData.guid != currMovieData.guid) - { - //mbg 8/18/08 - this code can be used to turn the error message into an OK/CANCEL - #ifdef WIN32 - std::string msg = "There is a mismatch between savestate's movie and current movie.\ncurrent: " + currMovieData.guid.toString() + "\nsavestate: " + tempMovieData.guid.toString() + "\n\nThis means that you have loaded a savestate belonging to a different movie than the one you are playing now.\n\nContinue loading this savestate anyway?"; - extern HWND pwindow; - int result = MessageBox(pwindow,msg.c_str(),"Error loading savestate",MB_OKCANCEL); - if(result == IDCANCEL) - { - if (!backupSavestates) //If backups are disabled we can just resume normally since we can't restore so stop movie and inform user - { - FCEU_PrintError("Unable to restore backup, movie playback stopped."); - FCEUI_StopMovie(); - } - - return false; - } - #else - if (!backupSavestates) //If backups are disabled we can just resume normally since we can't restore so stop movie and inform user - { - FCEU_PrintError("Mismatch between savestate's movie and current movie.\ncurrent: %s\nsavestate: %s\nUnable to restore backup, movie playback stopped.\n",currMovieData.guid.toString().c_str(),tempMovieData.guid.toString().c_str()); - FCEUI_StopMovie(); - } - else - FCEU_PrintError("Mismatch between savestate's movie and current movie.\ncurrent: %s\nsavestate: %s\n",currMovieData.guid.toString().c_str(),tempMovieData.guid.toString().c_str()); - - return false; - #endif - } - - closeRecordingMovie(); - - if (movie_readonly) - { - // currFrameCounter at this point represents the savestate framecount - int frame_of_mismatch = CheckTimelines(tempMovieData, currMovieData); - if (frame_of_mismatch >= 0) - { - // Wrong timeline, do apprioriate logic here - if (!backupSavestates) //If backups are disabled we can just resume normally since we can't restore so stop movie and inform user - { - FCEU_PrintError("Error: Savestate not in the same timeline as movie!\nFrame %d branches from current timeline\nUnable to restore backup, movie playback stopped.", frame_of_mismatch); - FCEUI_StopMovie(); - } else - FCEU_PrintError("Error: Savestate not in the same timeline as movie!\nFrame %d branches from current timeline", frame_of_mismatch); - return false; - } else if (movieMode == MOVIEMODE_FINISHED - && currFrameCounter > (int)currMovieData.records.size() - && currMovieData.records.size() == tempMovieData.records.size()) - { - // special case (in MOVIEMODE_FINISHED mode) - // allow loading post-movie savestates that were made after finishing current movie - - } else if (currFrameCounter > (int)currMovieData.records.size()) - { - // this is future event state, don't allow it - //TODO: turn frame counter to red to get attention - if (!backupSavestates) //If backups are disabled we can just resume normally since we can't restore so stop movie and inform user - { - FCEU_PrintError("Error: Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.\nUnable to restore backup, movie playback stopped.", currFrameCounter, currMovieData.records.size()-1); - FCEUI_StopMovie(); - } else - FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1); - return false; - } else if (currFrameCounter > (int)tempMovieData.records.size()) - { - // this is post-movie savestate, don't allow it - //TODO: turn frame counter to red to get attention - if (!backupSavestates) //If backups are disabled we can just resume normally since we can't restore so stop movie and inform user - { - FCEU_PrintError("Error: Savestate is from a frame (%d) after the final frame in the savestated movie (%d). This is not permitted.\nUnable to restore backup, movie playback stopped.", currFrameCounter, tempMovieData.records.size()-1); - FCEUI_StopMovie(); - } else - FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the savestated movie (%d). This is not permitted.", currFrameCounter, tempMovieData.records.size()-1); - return false; - } else - { - // Finally, this is a savestate file for this movie - movieMode = MOVIEMODE_PLAY; - } - } else - { - //Read+Write mode - if (currFrameCounter > (int)tempMovieData.records.size()) - { - //This is a post movie savestate, handle it differently - //Replace movie contents but then switch to movie finished mode - currMovieData = tempMovieData; - openRecordingMovie(curMovieFilename); - currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/); - FinishPlayback(); - } else - { - //truncate before we copy, just to save some time, unless the user selects a full copy option - if (!fullSaveStateLoads) - //we can only assume this here since we have checked that the frame counter is not greater than the movie data - tempMovieData.truncateAt(currFrameCounter); - - currMovieData = tempMovieData; - FCEUMOV_IncrementRerecordCount(); - openRecordingMovie(curMovieFilename); - currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/); - movieMode = MOVIEMODE_RECORD; - - } - } - } - - load_successful = true; - - return true; -} - -void FCEUMOV_PreLoad(void) -{ - load_successful=0; -} - -bool FCEUMOV_PostLoad(void) -{ - if(movieMode == MOVIEMODE_INACTIVE || movieMode == MOVIEMODE_TASEDITOR) - return true; - else - return load_successful; -} - -void FCEUMOV_IncrementRerecordCount() -{ -#ifdef _S9XLUA_H - if(!FCEU_LuaRerecordCountSkip()) - currMovieData.rerecordCount++; -#else - currMovieData.rerecordCount++; -#endif -} - -void FCEUI_MovieToggleFrameDisplay(void) -{ - frame_display=!frame_display; -} - -void FCEUI_MovieToggleRerecordDisplay() -{ - rerecord_display ^= 1; -} - -void FCEUI_ToggleInputDisplay(void) -{ - switch(input_display) - { - case 0: - input_display = 1; - break; - case 1: - input_display = 2; - break; - case 2: - input_display = 4; - break; - default: - input_display = 0; - break; - } -} - -int FCEUI_GetMovieLength() -{ - return currMovieData.records.size(); -} - -int FCEUI_GetMovieRerecordCount() -{ - return currMovieData.rerecordCount; -} - -bool FCEUI_GetMovieToggleReadOnly() -{ - return movie_readonly; -} - -void FCEUI_SetMovieToggleReadOnly(bool which) -{ - if (which) //If set to readonly - { - if (!movie_readonly) //If not already set - { - movie_readonly = true; - FCEU_DispMessage("Movie is now Read-Only.",0); - } - else //Else restate message - FCEU_DispMessage("Movie is Read-Only.",0); - } - else //If set to read+write - { - if (movie_readonly) //If not already set - { - movie_readonly = false; - FCEU_DispMessage("Movie is now Read+Write.",0); - } - else //Else restate message - FCEU_DispMessage("Movie is Read+Write.",0); - } -} -void FCEUI_MovieToggleReadOnly() -{ - char message[260]; - - if(movie_readonly) - strcpy(message, "Movie is now Read+Write"); - else - strcpy(message, "Movie is now Read-Only"); - - if (movieMode == MOVIEMODE_INACTIVE) - strcat(message, " (no movie)"); - else if (movieMode == MOVIEMODE_FINISHED) - strcat(message, " (finished)"); - - FCEU_DispMessage(message,0); - movie_readonly = !movie_readonly; -} - -void FCEUI_MoviePlayFromBeginning(void) -{ - if (movieMode == MOVIEMODE_TASEDITOR) - { -#ifdef WIN32 - handleEmuCmdByTaseditor(EMUCMD_MOVIE_PLAY_FROM_BEGINNING); -#endif - } else if (movieMode != MOVIEMODE_INACTIVE) - { - if (currMovieData.savestate.empty()) - { - movie_readonly = true; - movieMode = MOVIEMODE_PLAY; - poweron(true); - currFrameCounter = 0; - FCEU_DispMessage("Movie is now Read-Only. Playing from beginning.",0); - } - else - { - // movie starting from savestate - reload movie file - string str = curMovieFilename; - FCEUI_StopMovie(); - if (FCEUI_LoadMovie(str.c_str(), 1, 0)) - { - movieMode = MOVIEMODE_PLAY; - movie_readonly = true; - FCEU_DispMessage("Movie is now Read-Only. Playing from beginning.",0); - } - //currMovieData.loadSavestateFrom(&currMovieData.savestate); //TODO: make something like this work instead so it doesn't have to reload - } - } -#ifdef WIN32 - SetMainWindowText(); -#endif -} - -string FCEUI_GetMovieName(void) -{ - return curMovieFilename; -} - -bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount) -{ - MovieData md; - if(!LoadFM2(md, fp->stream, fp->size, skipFrameCount)) - return false; - - info.movie_version = md.version; - info.poweron = md.savestate.size()==0; - info.reset = false; //Soft-reset isn't used from starting movies anymore, so this will be false, better for FCEUFILE to have that info (as |1| on the first frame indicates it - info.pal = md.palFlag; - info.ppuflag = md.PPUflag; - info.nosynchack = true; - info.num_frames = md.records.size(); - info.md5_of_rom_used = md.romChecksum; - info.emu_version_used = md.emuVersion; - info.name_of_rom_used = md.romFilename; - info.rerecord_count = md.rerecordCount; - info.comments = md.comments; - info.subtitles = md.subtitles; - - return true; -} - -//This function creates an array of frame numbers and corresponding strings for displaying subtitles -void LoadSubtitles(MovieData &moviedata) -{ - subtitleFrames.resize(0); - subtitleMessages.resize(0); - extern std::vector subtitles; - for(uint32 i=0; i < moviedata.subtitles.size() ; i++) - { - std::string& subtitle = moviedata.subtitles[i]; - size_t splitat = subtitle.find_first_of(' '); - std::string key, value; - - //If we can't split them, then don't process this one - if(splitat == std::string::npos) - { - } - //Else split the subtitle into the int and string arrays - else - { - key = subtitle.substr(0,splitat); - value = subtitle.substr(splitat+1); - subtitleFrames.push_back(atoi(key.c_str())); - subtitleMessages.push_back(value); - } - } - -} - -//Every frame, this will be called to determine if a subtitle should be displayed, which one, and then to display it -void ProcessSubtitles(void) -{ - if (movieMode == MOVIEMODE_INACTIVE) return; - - for(uint32 i=0;i 99) - stream << "-" << backNum; //assign backNum to stream - else if (backNum <=99 && backNum >= 10) - stream << "-0"; //Make it 010, etc if two digits - else - stream << "-00" << backNum; //Make it 001, etc if single digit - backupFn.append(stream.str()); //add number to bak filename - backupFn.append(".bak"); //add extension - - exist = CheckFileExists(backupFn.c_str()); //Check if file exists - - if (!exist) - break; //Yeah yeah, I should use a do loop or something - else - { - backupFn = tempFn; //Before we loop again, reset the filename - - if (backNum == 999) //If 999 exists, we have overflowed, let's handle that - { - backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak - overflow = true; //Flag that we have exceeded limit - break; //Just in case - } - } - } - FCEUI_CreateMovieFile(backupFn); - - //TODO, decide if fstream successfully opened the file and print error message if it doesn't - - if (dispMessage) //If we should inform the user - { - if (overflow) - FCEUI_DispMessage("Backup overflow, overwriting %s",0,backupFn.c_str()); //Inform user of overflow - else - FCEUI_DispMessage("%s created",0,backupFn.c_str()); //Inform user of backup filename - } -} - diff --git a/branches/fceux-2.2.2/src/movie.h b/branches/fceux-2.2.2/src/movie.h deleted file mode 100644 index 783e5b9b..00000000 --- a/branches/fceux-2.2.2/src/movie.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef __MOVIE_H_ -#define __MOVIE_H_ - -#include "input/zapper.h" -#include "utils/guid.h" -#include "utils/md5.h" - -#include -#include -#include -#include -#include - -struct FCEUFILE; - -enum EMOVIE_FLAG -{ - MOVIE_FLAG_NONE = 0, - - //an ARCHAIC flag which means the movie was recorded from a soft reset. - //WHY would you do this?? do not create any new movies with this flag - MOVIE_FLAG_FROM_RESET = (1<<1), - - MOVIE_FLAG_PAL = (1<<2), - - //movie was recorded from poweron. the alternative is from a savestate (or from reset) - MOVIE_FLAG_FROM_POWERON = (1<<3), - - // set in newer version, used for old movie compatibility - //TODO - only use this flag to print a warning that the sync might be bad - //so that we can get rid of the sync hack code - MOVIE_FLAG_NOSYNCHACK = (1<<4) -}; - -typedef struct -{ - int movie_version; // version of the movie format in the file - uint32 num_frames; - uint32 rerecord_count; - bool poweron, pal, nosynchack, ppuflag; - bool reset; //mbg 6/21/08 - this flag isnt used anymore.. but maybe one day we can scan it out of the first record in the movie file - uint32 emu_version_used; // 9813 = 0.98.13 - MD5DATA md5_of_rom_used; - std::string name_of_rom_used; - - std::vector comments; - std::vector subtitles; -} MOVIE_INFO; - - -void FCEUMOV_AddInputState(); -void FCEUMOV_AddCommand(int cmd); -void FCEU_DrawMovies(uint8 *); -void FCEU_DrawLagCounter(uint8 *); - -enum EMOVIEMODE -{ - MOVIEMODE_INACTIVE = 1, - MOVIEMODE_RECORD = 2, - MOVIEMODE_PLAY = 4, - MOVIEMODE_TASEDITOR = 8, - MOVIEMODE_FINISHED = 16 -}; - -enum EMOVIECMD -{ - MOVIECMD_RESET = 1, - MOVIECMD_POWER = 2, - MOVIECMD_FDS_INSERT = 4, - MOVIECMD_FDS_SELECT = 8, - MOVIECMD_VS_INSERTCOIN = 16 -}; - -EMOVIEMODE FCEUMOV_Mode(); -bool FCEUMOV_Mode(EMOVIEMODE modemask); -bool FCEUMOV_Mode(int modemask); -inline bool FCEUMOV_IsPlaying() { return (FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_FINISHED)); } -inline bool FCEUMOV_IsRecording() { return FCEUMOV_Mode(MOVIEMODE_RECORD); } -inline bool FCEUMOV_IsFinished() { return FCEUMOV_Mode(MOVIEMODE_FINISHED);} -inline bool FCEUMOV_IsLoaded() { return (FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED)); } - -bool FCEUMOV_ShouldPause(void); -int FCEUMOV_GetFrame(void); -int FCEUI_GetLagCount(void); -bool FCEUI_GetLagged(void); -void FCEUI_SetLagFlag(bool value); - -int FCEUMOV_WriteState(EMUFILE* os); -bool FCEUMOV_ReadState(EMUFILE* is, uint32 size); -void FCEUMOV_PreLoad(); -bool FCEUMOV_PostLoad(); -void FCEUMOV_IncrementRerecordCount(); - -bool FCEUMOV_FromPoweron(); - -void FCEUMOV_CreateCleanMovie(); -void FCEUMOV_ClearCommands(); - -class MovieData; -class MovieRecord -{ - -public: - MovieRecord(); - ValueArray joysticks; - - struct { - uint8 x,y,b,bogo; - uint64 zaphit; - } zappers[2]; - - //misc commands like reset, etc. - //small now to save space; we might need to support more commands later. - //the disk format will support up to 64bit if necessary - uint8 commands; - bool command_reset() { return (commands & MOVIECMD_RESET) != 0; } - bool command_power() { return (commands & MOVIECMD_POWER) != 0; } - bool command_fds_insert() { return (commands & MOVIECMD_FDS_INSERT) != 0; } - bool command_fds_select() { return (commands & MOVIECMD_FDS_SELECT) != 0; } - bool command_vs_insertcoin() { return (commands & MOVIECMD_VS_INSERTCOIN) != 0; } - - void toggleBit(int joy, int bit) - { - joysticks[joy] ^= mask(bit); - } - - void setBit(int joy, int bit) - { - joysticks[joy] |= mask(bit); - } - - void clearBit(int joy, int bit) - { - joysticks[joy] &= ~mask(bit); - } - - void setBitValue(int joy, int bit, bool val) - { - if(val) setBit(joy,bit); - else clearBit(joy,bit); - } - - bool checkBit(int joy, int bit) - { - return (joysticks[joy] & mask(bit))!=0; - } - - bool Compare(MovieRecord& compareRec); - void Clone(MovieRecord& sourceRec); - void clear(); - - void parse(MovieData* md, EMUFILE* is); - bool parseBinary(MovieData* md, EMUFILE* is); - void dump(MovieData* md, EMUFILE* os, int index); - void dumpBinary(MovieData* md, EMUFILE* os, int index); - void parseJoy(EMUFILE* is, uint8& joystate); - void dumpJoy(EMUFILE* os, uint8 joystate); - - static const char mnemonics[8]; - -private: - int mask(int bit) { return 1< savestate; - std::vector records; - std::vector comments; - std::vector subtitles; - //this is the RERECORD COUNT. please rename variable. - int rerecordCount; - FCEU_Guid guid; - - //was the frame data stored in binary? - bool binaryFlag; - // TAS Editor project files contain additional data after input - int loadFrameCount; - - //which ports are defined for the movie - int ports[3]; - //whether fourscore is enabled - bool fourscore; - //whether microphone is enabled - bool microphone; - - int getNumRecords() { return records.size(); } - - class TDictionary : public std::map - { - public: - bool containsKey(std::string key) - { - return find(key) != end(); - } - - void tryInstallBool(std::string key, bool& val) - { - if(containsKey(key)) - val = atoi(operator [](key).c_str())!=0; - } - - void tryInstallString(std::string key, std::string& val) - { - if(containsKey(key)) - val = operator [](key); - } - - void tryInstallInt(std::string key, int& val) - { - if(containsKey(key)) - val = atoi(operator [](key).c_str()); - } - - }; - - void truncateAt(int frame); - void installValue(std::string& key, std::string& val); - int dump(EMUFILE* os, bool binary); - - void clearRecordRange(int start, int len); - void eraseRecords(int at, int frames = 1); - void insertEmpty(int at, int frames); - void cloneRegion(int at, int frames); - - static bool loadSavestateFrom(std::vector* buf); - static void dumpSavestateTo(std::vector* buf, int compressionLevel); - -private: - void installInt(std::string& val, int& var) - { - var = atoi(val.c_str()); - } - - void installBool(std::string& val, bool& var) - { - var = atoi(val.c_str())!=0; - } -}; - -extern MovieData currMovieData; -extern int currFrameCounter; -extern char curMovieFilename[512]; -extern bool subtitlesOnAVI; -extern bool freshMovie; -extern bool movie_readonly; -extern bool autoMovieBackup; -extern bool fullSaveStateLoads; -//-------------------------------------------------- -void FCEUI_MakeBackupMovie(bool dispMessage); -void FCEUI_CreateMovieFile(std::string fn); -void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author); -bool FCEUI_LoadMovie(const char *fname, bool read_only, int _stopframe); -void FCEUI_MoviePlayFromBeginning(void); -void FCEUI_StopMovie(void); -bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount = false); -//char* FCEUI_MovieGetCurrentName(int addSlotNumber); -void FCEUI_MovieToggleReadOnly(void); -bool FCEUI_GetMovieToggleReadOnly(); -void FCEUI_SetMovieToggleReadOnly(bool which); -int FCEUI_GetMovieLength(); -int FCEUI_GetMovieRerecordCount(); -std::string FCEUI_GetMovieName(void); -void FCEUI_MovieToggleFrameDisplay(); -void FCEUI_MovieToggleRerecordDisplay(); -void FCEUI_ToggleInputDisplay(void); - -void LoadSubtitles(MovieData &); -void ProcessSubtitles(void); -void FCEU_DisplaySubtitles(char *format, ...); - -void poweron(bool shouldDisableBatteryLoading); - - -#endif //__MOVIE_H_ diff --git a/branches/fceux-2.2.2/src/netplay.cpp b/branches/fceux-2.2.2/src/netplay.cpp deleted file mode 100644 index ce6d9a3a..00000000 --- a/branches/fceux-2.2.2/src/netplay.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "types.h" -#include "file.h" -#include "utils/endian.h" -#include "netplay.h" -#include "fceu.h" -#include "state.h" -#include "cheat.h" -#include "input.h" -#include "driver.h" -#include "utils/memory.h" - -#include -#include -#include -#include -#include -//#include //mbg merge 7/17/06 removed - -#include - -int FCEUnetplay=0; - -static uint8 netjoy[4]; // Controller cache. -static int numlocal; -static int netdivisor; -static int netdcount; - -//NetError should only be called after a FCEUD_*Data function returned 0, in the function -//that called FCEUD_*Data, to prevent it from being called twice. - -static void NetError(void) -{ - FCEU_DispMessage("Network error/connection lost!",0); - FCEUD_NetworkClose(); -} - -void FCEUI_NetplayStop(void) -{ - if(FCEUnetplay) - { - FCEUnetplay = 0; - FCEU_FlushGameCheats(0,1); //Don't save netplay cheats. - FCEU_LoadGameCheats(0); //Reload our original cheats. - } - else puts("Check your code!"); -} - -int FCEUI_NetplayStart(int nlocal, int divisor) -{ - FCEU_FlushGameCheats(0, 0); //Save our pre-netplay cheats. - FCEU_LoadGameCheats(0); // Load them again, for pre-multiplayer action. - - FCEUnetplay = 1; - memset(netjoy,0,sizeof(netjoy)); - numlocal = nlocal; - netdivisor = divisor; - netdcount = 0; - return(1); -} - -int FCEUNET_SendCommand(uint8 cmd, uint32 len) -{ - //mbg merge 7/17/06 changed to alloca - //uint8 buf[numlocal + 1 + 4]; - uint8 *buf = (uint8*)alloca(numlocal+1+4); - - - buf[0] = 0xFF; - FCEU_en32lsb(&buf[numlocal], len); - buf[numlocal + 4] = cmd; - if(!FCEUD_SendData(buf,numlocal + 1 + 4)) - { - NetError(); - return(0); - } - return(1); -} - -void FCEUI_NetplayText(uint8 *text) -{ - uint32 len; - - len = strlen((char*)text); //mbg merge 7/17/06 added cast - - if(!FCEUNET_SendCommand(FCEUNPCMD_TEXT,len)) return; - - if(!FCEUD_SendData(text,len)) - NetError(); -} - -int FCEUNET_SendFile(uint8 cmd, char *fn) -{ - uint32 len; - uLongf clen; - char *buf, *cbuf; - FILE *fp; - struct stat sb; - - if(!(fp=FCEUD_UTF8fopen(fn,"rb"))) return(0); - - fstat(fileno(fp),&sb); - len = sb.st_size; - buf = (char*)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast - fread(buf, 1, len, fp); - fclose(fp); - - cbuf = (char*)FCEU_dmalloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast - FCEU_en32lsb((uint8*)cbuf, len); //mbg merge 7/17/06 added cast - compress2((uint8*)cbuf + 4, &clen, (uint8*)buf, len, 7); //mbg merge 7/17/06 added casts - free(buf); - - //printf("Sending file: %s, %d, %d\n",fn,len,clen); - - len = clen + 4; - - if(!FCEUNET_SendCommand(cmd,len)) - { - free(cbuf); - return(0); - } - if(!FCEUD_SendData(cbuf, len)) - { - NetError(); - free(cbuf); - return(0); - } - free(cbuf); - - return(1); -} - -static FILE *FetchFile(uint32 remlen) -{ - uint32 clen = remlen; - char *cbuf; - uLongf len; - char *buf; - FILE *fp; - - if(clen > 500000) // Sanity check - { - NetError(); - return(0); - } - - //printf("Receiving file: %d...\n",clen); - if((fp = tmpfile())) - { - cbuf = (char *)FCEU_dmalloc(clen); //mbg merge 7/17/06 added cast - if(!FCEUD_RecvData(cbuf, clen)) - { - NetError(); - fclose(fp); - free(cbuf); - return(0); - } - - len = FCEU_de32lsb((uint8*)cbuf); //mbg merge 7/17/06 added cast - if(len > 500000) // Another sanity check - { - NetError(); - fclose(fp); - free(cbuf); - return(0); - } - buf = (char *)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast - uncompress((uint8*)buf, &len, (uint8*)cbuf + 4, clen - 4); //mbg merge 7/17/06 added casts - - fwrite(buf, 1, len, fp); - free(buf); - fseek(fp, 0, SEEK_SET); - return(fp); - } - return(0); -} - -void NetplayUpdate(uint8 *joyp) -{ - static uint8 buf[5]; /* 4 play states, + command/extra byte */ - static uint8 joypb[4]; - - memcpy(joypb,joyp,4); - - /* This shouldn't happen, but just in case. 0xFF is used as a command escape elsewhere. */ - if(joypb[0] == 0xFF) - joypb[0] = 0xF; - if(!netdcount) - if(!FCEUD_SendData(joypb,numlocal)) - { - NetError(); - return; - } - - if(!netdcount) - { - do - { - if(!FCEUD_RecvData(buf,5)) - { - NetError(); - return; - } - - switch(buf[4]) - { - default: FCEU_DoSimpleCommand(buf[4]);break; - case FCEUNPCMD_TEXT: - { - uint8 *tbuf; - uint32 len = FCEU_de32lsb(buf); - - if(len > 100000) // Insanity check! - { - NetError(); - return; - } - tbuf = (uint8*)malloc(len + 1); //mbg merge 7/17/06 added cast - tbuf[len] = 0; - if(!FCEUD_RecvData(tbuf, len)) - { - NetError(); - free(tbuf); - return; - } - FCEUD_NetplayText(tbuf); - free(tbuf); - } - break; - case FCEUNPCMD_SAVESTATE: - { - //mbg todo netplay - //char *fn; - //FILE *fp; - - ////Send the cheats first, then the save state, since - ////there might be a frame or two in between the two sendfile - ////commands on the server side. - - //fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str()); - - ////why?????? - ////if(! - // FCEUNET_SendFile(FCEUNPCMD_LOADCHEATS,fn); - //// { - //// free(fn); - //// return; - //// } - - //free(fn); - //if(!FCEUnetplay) return; - - //fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP,0,0).c_str()); - //fp = fopen(fn, "wb"); - //if(FCEUSS_SaveFP(fp,Z_BEST_COMPRESSION)) - //{ - // fclose(fp); - // if(!FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn)) - // { - // unlink(fn); - // free(fn); - // return; - // } - // unlink(fn); - // free(fn); - //} - //else - //{ - // fclose(fp); - // FCEUD_PrintError("File error. (K)ill, (M)aim, (D)estroy? Now!"); - // unlink(fn); - // free(fn); - // return; - //} - - } - break; - case FCEUNPCMD_LOADCHEATS: - { - FILE *fp = FetchFile(FCEU_de32lsb(buf)); - if(!fp) return; - FCEU_FlushGameCheats(0,1); - FCEU_LoadGameCheats(fp); - } - break; - //mbg 6/16/08 - netplay doesnt work right now anyway - /*case FCEUNPCMD_LOADSTATE: - { - FILE *fp = FetchFile(FCEU_de32lsb(buf)); - if(!fp) return; - if(FCEUSS_LoadFP(fp,SSLOADPARAM_BACKUP)) - { - fclose(fp); - FCEU_DispMessage("Remote state loaded.",0); - } else FCEUD_PrintError("File error. (K)ill, (M)aim, (D)estroy?"); - } - break;*/ - } - } while(buf[4]); - - netdcount=(netdcount+1)%netdivisor; - - memcpy(netjoy,buf,4); - *(uint32 *)joyp=*(uint32 *)netjoy; - } -} diff --git a/branches/fceux-2.2.2/src/nsf.cpp b/branches/fceux-2.2.2/src/nsf.cpp deleted file mode 100644 index d8c6b902..00000000 --- a/branches/fceux-2.2.2/src/nsf.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/// \file -/// \brief implements a built-in NSF player. This is a perk--not a part of the emu core - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "video.h" -#include "sound.h" -#include "nsf.h" -#include "utils/general.h" -#include "utils/memory.h" -#include "file.h" -#include "fds.h" -#include "cart.h" -#include "input.h" -#include "state.h" -#include "driver.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#include -#include -#include -#include - -static const int FIXED_EXWRAM_SIZE = 32768+8192; - -static uint8 SongReload; -static int32 CurrentSong; - -static DECLFW(NSF_write); -static DECLFR(NSF_read); - -static int vismode=1; //we cant consider this state, because the UI may be controlling it and wouldnt know we loadstated it - -//mbg 7/31/06 todo - no reason this couldnt be assembled on the fly from actual asm source code. thatd be less obscure. -//here it is disassembled, for reference -/* -00:8000:8D F4 3F STA $3FF4 = #$00 -00:8003:A2 FF LDX #$FF -00:8005:9A TXS -00:8006:AD F0 3F LDA $3FF0 = #$00 -00:8009:F0 09 BEQ $8014 -00:800B:AD F1 3F LDA $3FF1 = #$00 -00:800E:AE F3 3F LDX $3FF3 = #$00 -00:8011:20 00 00 JSR $0000 -00:8014:A9 00 LDA #$00 -00:8016:AA TAX -00:8017:A8 TAY -00:8018:20 00 00 JSR $0000 -00:801B:8D F5 EF STA $EFF5 = #$FF -00:801E:90 FE BCC $801E -00:8020:8D F3 3F STA $3FF3 = #$00 -00:8023:18 CLC -00:8024:90 FE BCC $8024 -*/ -static uint8 NSFROM[0x30+6]= -{ - /* 0x00 - NMI */ - 0x8D,0xF4,0x3F, /* Stop play routine NMIs. */ - 0xA2,0xFF,0x9A, /* Initialize the stack pointer. */ - 0xAD,0xF0,0x3F, /* See if we need to init. */ - 0xF0,0x09, /* If 0, go to play routine playing. */ - - 0xAD,0xF1,0x3F, /* Confirm and load A */ - 0xAE,0xF3,0x3F, /* Load X with PAL/NTSC byte */ - - 0x20,0x00,0x00, /* JSR to init routine */ - - 0xA9,0x00, - 0xAA, - 0xA8, - 0x20,0x00,0x00, /* JSR to play routine */ - 0x8D,0xF5,0x3F, /* Start play routine NMIs. */ - 0x90,0xFE, /* Loopie time. */ - - /* 0x20 */ - 0x8D,0xF3,0x3F, /* Init init NMIs */ - 0x18, - 0x90,0xFE /* Loopie time. */ -}; - -static DECLFR(NSFROMRead) -{ - return (NSFROM-0x3800)[A]; -} - -static uint8 doreset=0; //state -static uint8 NSFNMIFlags; //state -uint8 *NSFDATA=0; //configration, loaded from rom? -int NSFMaxBank; //configuration - -static int32 NSFSize; //configuration -static uint8 BSon; //configuration -static uint8 BankCounter; //configuration - -static uint16 PlayAddr; //configuration -static uint16 InitAddr; //configuration -static uint16 LoadAddr; //configuration - -extern char LoadedRomFName[2048]; - -NSF_HEADER NSFHeader; //mbg merge 6/29/06 - needs to be global - -void NSFMMC5_Close(void); -static uint8 *ExWRAM=0; - -void NSFGI(GI h) -{ - switch(h) - { - case GI_CLOSE: - if(NSFDATA) {free(NSFDATA);NSFDATA=0;} - if(ExWRAM) {free(ExWRAM);ExWRAM=0;} - if(NSFHeader.SoundChip&1) { - // NSFVRC6_Init(); - } else if(NSFHeader.SoundChip&2) { - // NSFVRC7_Init(); - } else if(NSFHeader.SoundChip&4) { - // FDSSoundReset(); - } else if(NSFHeader.SoundChip&8) { - NSFMMC5_Close(); - } else if(NSFHeader.SoundChip&0x10) { - // NSFN106_Init(); - } else if(NSFHeader.SoundChip&0x20) { - // NSFAY_Init(); - } - break; - case GI_RESETM2: - case GI_POWER: NSF_init();break; - } -} - -// First 32KB is reserved for sound chip emulation in the iNES mapper code. - -static INLINE void BANKSET(uint32 A, uint32 bank) -{ - bank&=NSFMaxBank; - if(NSFHeader.SoundChip&4) - memcpy(ExWRAM+(A-0x6000),NSFDATA+(bank<<12),4096); - else - setprg4(A,bank); -} - -int NSFLoad(const char *name, FCEUFILE *fp) -{ - int x; - - FCEU_fseek(fp,0,SEEK_SET); - FCEU_fread(&NSFHeader,1,0x80,fp); - if(memcmp(NSFHeader.ID,"NESM\x1a",5)) - return 0; - NSFHeader.SongName[31]=NSFHeader.Artist[31]=NSFHeader.Copyright[31]=0; - - LoadAddr=NSFHeader.LoadAddressLow; - LoadAddr|=NSFHeader.LoadAddressHigh<<8; - - if(LoadAddr<0x6000) - { - FCEUD_PrintError("Invalid load address."); - return(0); - } - InitAddr=NSFHeader.InitAddressLow; - InitAddr|=NSFHeader.InitAddressHigh<<8; - - PlayAddr=NSFHeader.PlayAddressLow; - PlayAddr|=NSFHeader.PlayAddressHigh<<8; - - NSFSize=FCEU_fgetsize(fp)-0x80; - - NSFMaxBank=((NSFSize+(LoadAddr&0xfff)+4095)/4096); - NSFMaxBank=PRGsize[0]=uppow2(NSFMaxBank); - - if(!(NSFDATA=(uint8 *)FCEU_malloc(NSFMaxBank*4096))) - return 0; - - FCEU_fseek(fp,0x80,SEEK_SET); - memset(NSFDATA,0x00,NSFMaxBank*4096); - FCEU_fread(NSFDATA+(LoadAddr&0xfff),1,NSFSize,fp); - - NSFMaxBank--; - - BSon=0; - for(x=0;x<8;x++) - { - BSon|=NSFHeader.BankSwitch[x]; - } - - if(BSon==0) - { - BankCounter=0x00; - - if ((NSFHeader.LoadAddressHigh & 0x70) >= 0x70) - { - //Ice Climber, and other F000 base address tunes need this - BSon=0xFF; - } - else { - for(x=(NSFHeader.LoadAddressHigh & 0x70) / 0x10;x<8;x++) - { - NSFHeader.BankSwitch[x]=BankCounter; - BankCounter+=0x01; - } - BSon=0; - } - } - - for(x=0;x<8;x++) - BSon|=NSFHeader.BankSwitch[x]; - - GameInfo->type=GIT_NSF; - GameInfo->input[0]=GameInfo->input[1]=SI_GAMEPAD; - GameInfo->cspecial=SIS_NSF; - - for(x=0;;x++) - { - if(NSFROM[x]==0x20) - { - NSFROM[x+1]=InitAddr&0xFF; - NSFROM[x+2]=InitAddr>>8; - NSFROM[x+8]=PlayAddr&0xFF; - NSFROM[x+9]=PlayAddr>>8; - break; - } - } - - if(NSFHeader.VideoSystem==0) - GameInfo->vidsys=GIV_NTSC; - else if(NSFHeader.VideoSystem==1) - GameInfo->vidsys=GIV_PAL; - - GameInterface=NSFGI; - - strcpy(LoadedRomFName,name); - - FCEU_printf("\nNSF Loaded.\nFile information:\n"); - FCEU_printf(" Name: %s\n Artist: %s\n Copyright: %s\n\n",NSFHeader.SongName,NSFHeader.Artist,NSFHeader.Copyright); - if(NSFHeader.SoundChip) - { - static char *tab[6]={"Konami VRCVI","Konami VRCVII","Nintendo FDS","Nintendo MMC5","Namco 106","Sunsoft FME-07"}; - - for(x=0;x<6;x++) - if(NSFHeader.SoundChip&(1<=6) - BANKSET(0x6000+(x-6)*4096,NSFHeader.BankSwitch[x]); - BANKSET(0x8000+x*4096,NSFHeader.BankSwitch[x]); - } - } - else - { - int32 x; - for(x=(LoadAddr&0xF000);x<0x10000;x+=0x1000) - BANKSET(x,((x-(LoadAddr&0x7000))>>12)); - } - - SetReadHandler(0xFFFA,0xFFFD,NSFVectorRead); - - SetWriteHandler(0x2000,0x3fff,0); - SetReadHandler(0x2000,0x37ff,0); - SetReadHandler(0x3836,0x3FFF,0); - SetReadHandler(0x3800,0x3835,NSFROMRead); - - SetWriteHandler(0x5ff6,0x5fff,NSF_write); - - SetWriteHandler(0x3ff0,0x3fff,NSF_write); - SetReadHandler(0x3ff0,0x3fff,NSF_read); - - - if(NSFHeader.SoundChip&1) { - NSFVRC6_Init(); - } else if(NSFHeader.SoundChip&2) { - NSFVRC7_Init(); - } else if(NSFHeader.SoundChip&4) { - FDSSoundReset(); - } else if(NSFHeader.SoundChip&8) { - NSFMMC5_Init(); - } else if(NSFHeader.SoundChip&0x10) { - NSFN106_Init(); - } else if(NSFHeader.SoundChip&0x20) { - NSFAY_Init(); - } - CurrentSong=NSFHeader.StartingSong; - SongReload=0xFF; - NSFNMIFlags=0; - - //zero 17-apr-2013 - added - AddExState(StateRegs, ~0, 0, 0); - AddExState(ExWRAM, FIXED_EXWRAM_SIZE, 0, "ERAM"); -} - -static DECLFW(NSF_write) -{ - switch(A) - { - case 0x3FF3:NSFNMIFlags|=1;break; - case 0x3FF4:NSFNMIFlags&=~2;break; - case 0x3FF5:NSFNMIFlags|=2;break; - - case 0x5FF6: - case 0x5FF7:if(!(NSFHeader.SoundChip&4)) return; - case 0x5FF8: - case 0x5FF9: - case 0x5FFA: - case 0x5FFB: - case 0x5FFC: - case 0x5FFD: - case 0x5FFE: - case 0x5FFF:if(!BSon) return; - A&=0xF; - BANKSET((A*4096),V); - break; - } -} - -static DECLFR(NSF_read) -{ - int x; - - switch(A) - { - case 0x3ff0:x=SongReload; - if(!fceuindbg) - SongReload=0; - return x; - case 0x3ff1: - if(!fceuindbg) - { - memset(RAM,0x00,0x800); - - BWrite[0x4015](0x4015,0x0); - for(x=0;x<0x14;x++) - BWrite[0x4000+x](0x4000+x,0); - BWrite[0x4015](0x4015,0xF); - - if(NSFHeader.SoundChip&4) - { - BWrite[0x4017](0x4017,0xC0); /* FDS BIOS writes $C0 */ - BWrite[0x4089](0x4089,0x80); - BWrite[0x408A](0x408A,0xE8); - } - else - { - memset(ExWRAM,0x00,8192); - BWrite[0x4017](0x4017,0xC0); - BWrite[0x4017](0x4017,0xC0); - BWrite[0x4017](0x4017,0x40); - } - - if(BSon) - { - for(x=0;x<8;x++) - BANKSET(0x8000+x*4096,NSFHeader.BankSwitch[x]); - } - #ifdef _S9XLUA_H - //CallRegisteredLuaMemHook(A, 1, V, LUAMEMHOOK_WRITE); FIXME - #endif - return (CurrentSong-1); - } - case 0x3FF3:return PAL; - } - return 0; -} - -uint8 FCEU_GetJoyJoy(void); - -static int special=0; - -void DrawNSF(uint8 *XBuf) -{ - char snbuf[16]; - int x; - - if(vismode==0) return; - - memset(XBuf,0,256*240); - - - { - int32 *Bufpl; - int32 mul=0; - - int l; - l=GetSoundBuffer(&Bufpl); - - if(special==0) - { - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); - for(x=0;x<256;x++) - { - uint32 y; - y=142+((Bufpl[(x*l)>>8]*mul)>>14); - if(y<240) - XBuf[x+y*256]=3; - } - } - else if(special==1) - { - if(FSettings.SoundVolume) - mul=8192*240/(8192*FSettings.SoundVolume/50); - for(x=0;x<256;x++) - { - double r; - uint32 xp,yp; - - r=(Bufpl[(x*l)>>8]*mul)>>14; - xp=128+r*cos(x*M_PI*2/256); - yp=120+r*sin(x*M_PI*2/256); - xp&=255; - yp%=240; - XBuf[xp+yp*256]=3; - } - } - else if(special==2) - { - static double theta=0; - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); - for(x=0;x<128;x++) - { - double xc,yc; - double r,t; - uint32 m,n; - - xc=(double)128-x; - yc=0-((double)( ((Bufpl[(x*l)>>8]) *mul)>>14)); - t=M_PI+atan(yc/xc); - r=sqrt(xc*xc+yc*yc); - - t+=theta; - m=128+r*cos(t); - n=120+r*sin(t); - - if(m<256 && n<240) - XBuf[m+n*256]=3; - - } - for(x=128;x<256;x++) - { - double xc,yc; - double r,t; - uint32 m,n; - - xc=(double)x-128; - yc=(double)((Bufpl[(x*l)>>8]*mul)>>14); - t=atan(yc/xc); - r=sqrt(xc*xc+yc*yc); - - t+=theta; - m=128+r*cos(t); - n=120+r*sin(t); - - if(m<256 && n<240) - XBuf[m+n*256]=3; - - } - theta+=(double)M_PI/256; - } - } - - DrawTextTrans(ClipSidesOffset+XBuf+10*256+4+(((31-strlen((char*)NSFHeader.SongName))<<2)), 256, NSFHeader.SongName, 6); - DrawTextTrans(ClipSidesOffset+XBuf+26*256+4+(((31-strlen((char*)NSFHeader.Artist))<<2)), 256,NSFHeader.Artist, 6); - DrawTextTrans(ClipSidesOffset+XBuf+42*256+4+(((31-strlen((char*)NSFHeader.Copyright))<<2)), 256,NSFHeader.Copyright, 6); - - DrawTextTrans(ClipSidesOffset+XBuf+70*256+4+(((31-strlen("Song:"))<<2)), 256, (uint8*)"Song:", 6); - sprintf(snbuf,"<%d/%d>",CurrentSong,NSFHeader.TotalSongs); - DrawTextTrans(XBuf+82*256+4+(((31-strlen(snbuf))<<2)), 256, (uint8*)snbuf, 6); - - { - static uint8 last=0; - uint8 tmp; - tmp=FCEU_GetJoyJoy(); - if((tmp&JOY_RIGHT) && !(last&JOY_RIGHT)) - { - if(CurrentSong1) - { - CurrentSong--; - SongReload=0xFF; - } - } - else if((tmp&JOY_UP) && !(last&JOY_UP)) - { - CurrentSong+=10; - if(CurrentSong>NSFHeader.TotalSongs) CurrentSong=NSFHeader.TotalSongs; - SongReload=0xFF; - } - else if((tmp&JOY_DOWN) && !(last&JOY_DOWN)) - { - CurrentSong-=10; - if(CurrentSong<1) CurrentSong=1; - SongReload=0xFF; - } - else if((tmp&JOY_START) && !(last&JOY_START)) - SongReload=0xFF; - else if((tmp&JOY_A) && !(last&JOY_A)) - { - special=(special+1)%3; - } - last=tmp; - } -} - -void DoNSFFrame(void) -{ - if(((NSFNMIFlags&1) && SongReload) || (NSFNMIFlags&2)) - TriggerNMI(); -} - -void FCEUI_NSFSetVis(int mode) -{ - vismode=mode; -} - -int FCEUI_NSFChange(int amount) -{ - CurrentSong+=amount; - if(CurrentSong<1) CurrentSong=1; - else if(CurrentSong>NSFHeader.TotalSongs) CurrentSong=NSFHeader.TotalSongs; - SongReload=0xFF; - - return(CurrentSong); -} - -//Returns total songs -int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen) -{ - strncpy((char*)name,(char*)NSFHeader.SongName,maxlen); //mbg merge 7/17/06 added casts - strncpy((char*)artist,(char*)NSFHeader.Artist,maxlen); //mbg merge 7/17/06 added casts - strncpy((char*)copyright,(char*)NSFHeader.Copyright,maxlen); //mbg merge 7/17/06 added casts - return(NSFHeader.TotalSongs); -} diff --git a/branches/fceux-2.2.2/src/palette.cpp b/branches/fceux-2.2.2/src/palette.cpp deleted file mode 100644 index eba1a7b2..00000000 --- a/branches/fceux-2.2.2/src/palette.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002,2003 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "types.h" -#include "file.h" -#include "fceu.h" -#include "driver.h" -#include "boards/mapinc.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -#include "palette.h" -#include "palettes/palettes.h" - - - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#include -#include -#include -#include - -static int ntsccol=0; -static int ntsctint=46+10; -static int ntschue=72; - -bool force_grayscale = false; - -/* These are dynamically filled/generated palettes: */ -pal palettei[64]; // Custom palette for an individual game. -pal palettec[64]; // Custom "global" palette. -pal paletten[64]; // Mathematically generated palette. - -static void CalculatePalette(void); -static void ChoosePalette(void); -static void WritePalette(void); -uint8 pale=0; - -pal *palo; -static pal *palpoint[8]= -{ - palette, - rp2c04001, - rp2c04002, - rp2c04003, - rp2c05004, -}; - -void FCEUI_SetPaletteArray(uint8 *pal) -{ - if(!pal) - palpoint[0]=palette; - else - { - int x; - palpoint[0]=palettec; - for(x=0;x<64;x++) - { - palpoint[0][x].r=*((uint8 *)pal+x+x+x); - palpoint[0][x].g=*((uint8 *)pal+x+x+x+1); - palpoint[0][x].b=*((uint8 *)pal+x+x+x+2); - } - } - FCEU_ResetPalette(); -} - - -void FCEUI_SetNTSCTH(int n, int tint, int hue) -{ - ntsctint=tint; - ntschue=hue; - ntsccol=n; - FCEU_ResetPalette(); -} - -static uint8 lastd=0; -void SetNESDeemph(uint8 d, int force) -{ - static uint16 rtmul[]={ - static_cast(32768*1.239), - static_cast(32768*.794), - static_cast(32768*1.019), - static_cast(32768*.905), - static_cast(32768*1.023), - static_cast(32768*.741), - static_cast(32768*.75) - }; - static uint16 gtmul[]={ - static_cast(32768*.915), - static_cast(32768*1.086), - static_cast(32768*.98), - static_cast(32768*1.026), - static_cast(32768*.908), - static_cast(32768*.987), - static_cast(32768*.75) - }; - static uint16 btmul[]={ - static_cast(32768*.743), - static_cast(32768*.882), - static_cast(32768*.653), - static_cast(32768*1.277), - static_cast(32768*.979), - static_cast(32768*.101), - static_cast(32768*.75) - }; - - uint32 r,g,b; - int x; - - /* If it's not forced(only forced when the palette changes), - don't waste cpu time if the same deemphasis bits are set as the last call. - */ - if(!force) - { - if(d==lastd) - return; - } - else /* Only set this when palette has changed. */ - { - #ifdef _S9XLUA_H - FCEU_LuaUpdatePalette(); - #endif - - r=rtmul[6]; - g=rtmul[6]; - b=rtmul[6]; - - for(x=0;x<0x40;x++) - { - uint32 m,n,o; - m=palo[x].r; - n=palo[x].g; - o=palo[x].b; - m=(m*r)>>15; - n=(n*g)>>15; - o=(o*b)>>15; - if(m>0xff) m=0xff; - if(n>0xff) n=0xff; - if(o>0xff) o=0xff; - FCEUD_SetPalette(x|0xC0,m,n,o); - } - } - if(!d) return; /* No deemphasis, so return. */ - - r=rtmul[d-1]; - g=gtmul[d-1]; - b=btmul[d-1]; - - for(x=0;x<0x40;x++) - { - uint32 m,n,o; - - m=palo[x].r; - n=palo[x].g; - o=palo[x].b; - m=(m*r)>>15; - n=(n*g)>>15; - o=(o*b)>>15; - if(m>0xff) m=0xff; - if(n>0xff) n=0xff; - if(o>0xff) o=0xff; - - FCEUD_SetPalette(x|0x40,m,n,o); - } - - lastd=d; - #ifdef _S9XLUA_H - FCEU_LuaUpdatePalette(); - #endif -} - -// Converted from Kevin Horton's qbasic palette generator. -static void CalculatePalette(void) -{ - int x,z; - int r,g,b; - double s,luma,theta; - static uint8 cols[16]={0,24,21,18,15,12,9,6,3,0,33,30,27,0,0,0}; - static uint8 br1[4]={6,9,12,12}; - static double br2[4]={.29,.45,.73,.9}; - static double br3[4]={0,.24,.47,.77}; - - for(x=0;x<=3;x++) - for(z=0;z<16;z++) - { - s=(double)ntsctint/128; - luma=br2[x]; - if(z==0) {s=0;luma=((double)br1[x])/12;} - - if(z>=13) - { - s=luma=0; - if(z==13) - luma=br3[x]; - } - - theta=(double)M_PI*(double)(((double)cols[z]*10+ (((double)ntschue/2)+300) )/(double)180); - r=(int)((luma+s*sin(theta))*256); - g=(int)((luma-(double)27/53*s*sin(theta)+(double)10/53*s*cos(theta))*256); - b=(int)((luma-s*cos(theta))*256); - - - if(r>255) r=255; - if(g>255) g=255; - if(b>255) b=255; - if(r<0) r=0; - if(g<0) g=0; - if(b<0) b=0; - - paletten[(x<<4)+z].r=r; - paletten[(x<<4)+z].g=g; - paletten[(x<<4)+z].b=b; - } - WritePalette(); -} - -static int ipalette=0; - -void FCEU_LoadGamePalette(void) -{ - uint8 ptmp[192]; - FILE *fp; - char *fn; - - ipalette=0; - - fn=strdup(FCEU_MakeFName(FCEUMKF_PALETTE,0,0).c_str()); - - if((fp=FCEUD_UTF8fopen(fn,"rb"))) - { - int x; - fread(ptmp,1,192,fp); - fclose(fp); - for(x=0;x<64;x++) - { - palettei[x].r=ptmp[x+x+x]; - palettei[x].g=ptmp[x+x+x+1]; - palettei[x].b=ptmp[x+x+x+2]; - } - ipalette=1; - } - free(fn); -} - -void FCEU_ResetPalette(void) -{ - if(GameInfo) - { - ChoosePalette(); - WritePalette(); - } -} - -static void ChoosePalette(void) -{ - if(GameInfo->type==GIT_NSF) - palo=0; - else if(ipalette) - palo=palettei; - else if(ntsccol && !PAL && GameInfo->type!=GIT_VSUNI) - { - palo=paletten; - CalculatePalette(); - } - else - palo=palpoint[pale]; -} - -void WritePalette(void) -{ - int x; - - for(x=0;x<7;x++) - FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); - if(GameInfo->type==GIT_NSF) - { - #ifdef _S9XLUA_H - FCEU_LuaUpdatePalette(); - #endif - //for(x=0;x<128;x++) - // FCEUD_SetPalette(x,x,0,x); - } - else - { - for(x=0;x<64;x++) - FCEUD_SetPalette(128+x,palo[x].r,palo[x].g,palo[x].b); - SetNESDeemph(lastd,1); - } -} - -void FCEUI_GetNTSCTH(int *tint, int *hue) -{ - *tint = ntsctint; - *hue = ntschue; -} - -static int controlselect=0; -static int controllength=0; - -void FCEUI_NTSCDEC(void) -{ - if(ntsccol && GameInfo->type!=GIT_VSUNI &&!PAL && GameInfo->type!=GIT_NSF) - { - int which; - if(controlselect) - { - if(controllength) - { - which=controlselect==1?ntschue:ntsctint; - which--; - if(which<0) which=0; - if(controlselect==1) - ntschue=which; - else ntsctint=which; - CalculatePalette(); - } - controllength=360; - } - } -} - -void FCEUI_NTSCINC(void) -{ - if(ntsccol && GameInfo->type!=GIT_VSUNI && !PAL && GameInfo->type!=GIT_NSF) - if(controlselect) - { - if(controllength) - { - switch(controlselect) - { - case 1:ntschue++; - if(ntschue>128) ntschue=128; - CalculatePalette(); - break; - case 2:ntsctint++; - if(ntsctint>128) ntsctint=128; - CalculatePalette(); - break; - } - } - controllength=360; - } -} - -void FCEUI_NTSCSELHUE(void) -{ - if(ntsccol && GameInfo->type!=GIT_VSUNI && !PAL && GameInfo->type!=GIT_NSF){controlselect=1;controllength=360;} -} - -void FCEUI_NTSCSELTINT(void) -{ - if(ntsccol && GameInfo->type!=GIT_VSUNI && !PAL && GameInfo->type!=GIT_NSF){controlselect=2;controllength=360;} -} - -void FCEU_DrawNTSCControlBars(uint8 *XBuf) -{ - uint8 *XBaf; - int which=0; - int x,x2; - - if(!controllength) return; - controllength--; - if(!XBuf) return; - - if(controlselect==1) - { - DrawTextTrans(XBuf+128-12+180*256, 256, (uint8 *)"Hue", 0x85); - which=ntschue<<1; - } - else if(controlselect==2) - { - DrawTextTrans(XBuf+128-16+180*256, 256, (uint8 *)"Tint", 0x85); - which=ntsctint<<1; - } - - XBaf=XBuf+200*256; - for(x=0;x=-6;x2--) - { - XBaf[x-256*x2]=0x85; - } - } - for(;x<256;x+=2) - { - for(x2=2;x2>=-2;x2--) - XBaf[x-256*x2]=0x85; - } -} diff --git a/branches/fceux-2.2.2/src/palettes/palettes.h b/branches/fceux-2.2.2/src/palettes/palettes.h deleted file mode 100644 index 3149254a..00000000 --- a/branches/fceux-2.2.2/src/palettes/palettes.h +++ /dev/null @@ -1,295 +0,0 @@ -pal rp2c04001[64] = { - #include "rp2c04001.h" -}; - -pal rp2c04002[64] = { - #include "rp2c04002.h" -}; - -pal rp2c04003[64] = { - #include "rp2c04003.h" -}; -pal rp2c05004[64] = { - #include "rp2c05004.h" -}; - -pal unvpalette[7] = { -{ 0x00<<2,0x00<<2,0x00<<2}, // Black -{ 0x3F<<2,0x3F<<2,0x34<<2}, // White -{ 0x00<<2,0x00<<2,0x00<<2}, // Black -{ 0x1d<<2,0x1d<<2,0x24<<2}, // Greyish -{ 190,0,0 }, // Redish -{ 51,255,51}, // Bright green -{ 49,14,200}, -}; - - -// Default palette -pal palette[64] = { - - { 0x1D<<2, 0x1D<<2, 0x1D<<2 }, /* Value 0 */ - { 0x09<<2, 0x06<<2, 0x23<<2 }, /* Value 1 */ - { 0x00<<2, 0x00<<2, 0x2A<<2 }, /* Value 2 */ - { 0x11<<2, 0x00<<2, 0x27<<2 }, /* Value 3 */ - { 0x23<<2, 0x00<<2, 0x1D<<2 }, /* Value 4 */ - { 0x2A<<2, 0x00<<2, 0x04<<2 }, /* Value 5 */ - { 0x29<<2, 0x00<<2, 0x00<<2 }, /* Value 6 */ - { 0x1F<<2, 0x02<<2, 0x00<<2 }, /* Value 7 */ - { 0x10<<2, 0x0B<<2, 0x00<<2 }, /* Value 8 */ - { 0x00<<2, 0x11<<2, 0x00<<2 }, /* Value 9 */ - { 0x00<<2, 0x14<<2, 0x00<<2 }, /* Value 10 */ - { 0x00<<2, 0x0F<<2, 0x05<<2 }, /* Value 11 */ - { 0x06<<2, 0x0F<<2, 0x17<<2 }, /* Value 12 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 13 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 14 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 15 */ - { 0x2F<<2, 0x2F<<2, 0x2F<<2 }, /* Value 16 */ - { 0x00<<2, 0x1C<<2, 0x3B<<2 }, /* Value 17 */ - { 0x08<<2, 0x0E<<2, 0x3B<<2 }, /* Value 18 */ - { 0x20<<2, 0x00<<2, 0x3C<<2 }, /* Value 19 */ - { 0x2F<<2, 0x00<<2, 0x2F<<2 }, /* Value 20 */ - { 0x39<<2, 0x00<<2, 0x16<<2 }, /* Value 21 */ - { 0x36<<2, 0x0A<<2, 0x00<<2 }, /* Value 22 */ - { 0x32<<2, 0x13<<2, 0x03<<2 }, /* Value 23 */ - { 0x22<<2, 0x1C<<2, 0x00<<2 }, /* Value 24 */ - { 0x00<<2, 0x25<<2, 0x00<<2 }, /* Value 25 */ - { 0x00<<2, 0x2A<<2, 0x00<<2 }, /* Value 26 */ - { 0x00<<2, 0x24<<2, 0x0E<<2 }, /* Value 27 */ - { 0x00<<2, 0x20<<2, 0x22<<2 }, /* Value 28 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 29 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 30 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 31 */ - { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 32 */ - { 0x0F<<2, 0x2F<<2, 0x3F<<2 }, /* Value 33 */ - { 0x17<<2, 0x25<<2, 0x3F<<2 }, /* Value 34 */ - { 0x33<<2, 0x22<<2, 0x3F<<2 }, /* Value 35 */ - { 0x3D<<2, 0x1E<<2, 0x3F<<2 }, /* Value 36 */ - { 0x3F<<2, 0x1D<<2, 0x2D<<2 }, /* Value 37 */ - { 0x3F<<2, 0x1D<<2, 0x18<<2 }, /* Value 38 */ - { 0x3F<<2, 0x26<<2, 0x0E<<2 }, /* Value 39 */ - { 0x3C<<2, 0x2F<<2, 0x0F<<2 }, /* Value 40 */ - { 0x20<<2, 0x34<<2, 0x04<<2 }, /* Value 41 */ - { 0x13<<2, 0x37<<2, 0x12<<2 }, /* Value 42 */ - { 0x16<<2, 0x3E<<2, 0x26<<2 }, /* Value 43 */ - { 0x00<<2, 0x3A<<2, 0x36<<2 }, /* Value 44 */ - { 0x1E<<2, 0x1E<<2, 0x1E<<2 }, /* Value 45 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 46 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 47 */ - { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 48 */ - { 0x2A<<2, 0x39<<2, 0x3F<<2 }, /* Value 49 */ - { 0x31<<2, 0x35<<2, 0x3F<<2 }, /* Value 50 */ - { 0x35<<2, 0x32<<2, 0x3F<<2 }, /* Value 51 */ - { 0x3F<<2, 0x31<<2, 0x3F<<2 }, /* Value 52 */ - { 0x3F<<2, 0x31<<2, 0x36<<2 }, /* Value 53 */ - { 0x3F<<2, 0x2F<<2, 0x2C<<2 }, /* Value 54 */ - { 0x3F<<2, 0x36<<2, 0x2A<<2 }, /* Value 55 */ - { 0x3F<<2, 0x39<<2, 0x28<<2 }, /* Value 56 */ - { 0x38<<2, 0x3F<<2, 0x28<<2 }, /* Value 57 */ - { 0x2A<<2, 0x3C<<2, 0x2F<<2 }, /* Value 58 */ - { 0x2C<<2, 0x3F<<2, 0x33<<2 }, /* Value 59 */ - { 0x27<<2, 0x3F<<2, 0x3C<<2 }, /* Value 60 */ - { 0x31<<2, 0x31<<2, 0x31<<2 }, /* Value 61 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 62 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 63 */ - - //luke's .16+ palette - //{0x60, 0x60, 0x60}, /* Value 0 */ - //{0x00, 0x00, 0x70}, /* Value 1 */ - //{0x14, 0x00, 0x80}, /* Value 2 */ - //{0x2C, 0x00, 0x6E}, /* Value 3 */ - //{0x4A, 0x00, 0x4E}, /* Value 4 */ - //{0x6C, 0x00, 0x18}, /* Value 5 */ - //{0x5A, 0x03, 0x02}, /* Value 6 */ - //{0x51, 0x18, 0x00}, /* Value 7 */ - //{0x34, 0x24, 0x00}, /* Value 8 */ - //{0x00, 0x34, 0x00}, /* Value 9 */ - //{0x00, 0x32, 0x00}, /* Value 10 */ - //{0x00, 0x34, 0x20}, /* Value 11 */ - //{0x00, 0x2C, 0x78}, /* Value 12 */ - //{0x00, 0x00, 0x00}, /* Value 13 */ - //{0x02, 0x02, 0x02}, /* Value 14 */ - //{0x02, 0x02, 0x02}, /* Value 15 */ - //{0xC4, 0xC4, 0xC4}, /* Value 16 */ - //{0x00, 0x58, 0xDE}, /* Value 17 */ - //{0x30, 0x1F, 0xFC}, /* Value 18 */ - //{0x7F, 0x14, 0xE0}, /* Value 19 */ - //{0xA8, 0x00, 0xB0}, /* Value 20 */ - //{0xC0, 0x06, 0x5C}, /* Value 21 */ - //{0xC0, 0x2B, 0x0E}, /* Value 22 */ - //{0xA6, 0x40, 0x10}, /* Value 23 */ - //{0x6F, 0x61, 0x00}, /* Value 24 */ - //{0x30, 0x80, 0x00}, /* Value 25 */ - //{0x00, 0x7C, 0x00}, /* Value 26 */ - //{0x00, 0x7C, 0x3C}, /* Value 27 */ - //{0x00, 0x6E, 0x84}, /* Value 28 */ - //{0x14, 0x14, 0x14}, /* Value 29 */ - //{0x04, 0x04, 0x04}, /* Value 30 */ - //{0x04, 0x04, 0x04}, /* Value 31 */ - //{0xF0, 0xF0, 0xF0}, /* Value 32 */ - //{0x4C, 0xAA, 0xFF}, /* Value 33 */ - //{0x6F, 0x73, 0xF5}, /* Value 34 */ - //{0xB0, 0x70, 0xFF}, /* Value 35 */ - //{0xDA, 0x5A, 0xFF}, /* Value 36 */ - //{0xF0, 0x60, 0xC0}, /* Value 37 */ - //{0xF8, 0x83, 0x6D}, /* Value 38 */ - //{0xD0, 0x90, 0x30}, /* Value 39 */ - //{0xD4, 0xC0, 0x30}, /* Value 40 */ - //{0x66, 0xD0, 0x00}, /* Value 41 */ - //{0x26, 0xDD, 0x1A}, /* Value 42 */ - //{0x2E, 0xC8, 0x66}, /* Value 43 */ - //{0x34, 0xC2, 0xBE}, /* Value 44 */ - //{0x54, 0x54, 0x54}, /* Value 45 */ - //{0x06, 0x06, 0x06}, /* Value 46 */ - //{0x06, 0x06, 0x06}, /* Value 47 */ - //{0xFF, 0xFF, 0xFF}, /* Value 48 */ - //{0xB6, 0xDA, 0xFF}, /* Value 49 */ - //{0xC8, 0xCA, 0xFF}, /* Value 50 */ - //{0xDA, 0xC2, 0xFF}, /* Value 51 */ - //{0xF0, 0xBE, 0xFF}, /* Value 52 */ - //{0xFC, 0xBC, 0xEE}, /* Value 53 */ - //{0xFF, 0xD0, 0xB4}, /* Value 54 */ - //{0xFF, 0xDA, 0x90}, /* Value 55 */ - //{0xEC, 0xEC, 0x92}, /* Value 56 */ - //{0xDC, 0xF6, 0x9E}, /* Value 57 */ - //{0xB8, 0xFF, 0xA2}, /* Value 58 */ - //{0xAE, 0xEA, 0xBE}, /* Value 59 */ - //{0x9E, 0xEF, 0xEF}, /* Value 60 */ - //{0xBE, 0xBE, 0xBE}, /* Value 61 */ - //{0x08, 0x08, 0x08}, /* Value 62 */ - //{0x08, 0x08, 0x08}, /* Value 63 */ -/* -// old palette: -74, 74, 74 -24, 18, 8C -00, 00, A8 -44, 00, 9C -8C, 00, 74 -A8, 00, 10 -A4, 00, 00 -7C, 08, 00 -40, 2C, 00 -00, 44, 00 -00, 50, 00 -00, 3C, 14 -18, 3C, 5C -00, 00, 00 -00, 00, 00 -00, 00, 00 -BC, BC, BC -00, 70, EC -20, 38, EC -80, 00, F0 -BC, 00, BC -E4, 00, 58 -D8, 28, 00 -C8, 4C, 0C -88, 70, 00 -00, 94, 00 -00, A8, 00 -00, 90, 38 -00, 80, 88 -00, 00, 00 -00, 00, 00 -00, 00, 00 -FC, FC, FC -3C, BC, FC -5C, 94, FC -40, 88, FC -F4, 78, FC -FC, 74, B4 -FC, 74, 60 -FC, 98, 38 -F0, BC, 3C -80, D0, 10 -4C, DC, 48 -58, F8, 98 -00, E8, D8 -78, 78, 78 -00, 00, 00 -00, 00, 00 -FC, FC, FC -A8, E4, FC -C4, D4, FC -D4, C8, FC -FC, C4, FC -FC, C4, D8 -FC, BC, B0 -FC, D8, A8 -FC, E4, A0 -E0, FC, A0 -A8, F0, BC -B0, FC, CC -9C, FC, F0 -C4, C4, C4 -00, 00, 00 -00, 00, 00 - -slightly better but too dark: -0x5C, 0x5C, 0x5C -0x00, 0x20, 0x74 -0x00, 0x00, 0x98 -0x30, 0x00, 0x84 -0x58, 0x00, 0x68 -0x68, 0x00, 0x30 -0x60, 0x00, 0x00 -0x48, 0x10, 0x00 -0x28, 0x18, 0x00 -0x20, 0x28, 0x00 -0x00, 0x40, 0x00 -0x00, 0x38, 0x30 -0x00, 0x38, 0x48 -0x00, 0x00, 0x00 -0x10, 0x10, 0x10 -0x10, 0x10, 0x10 -0xAA, 0xAA, 0xAA -0x18, 0x54, 0xBC -0x28, 0x30, 0xF8 -0x68, 0x20, 0xD8 -0xA8, 0x00, 0xB8 -0xB8, 0x14, 0x5C -0xB8, 0x18, 0x10 -0x8C, 0x38, 0x0C -0x60, 0x50, 0x00 -0x3C, 0x60, 0x00 -0x00, 0x78, 0x00 -0x00, 0x70, 0x4C -0x00, 0x70, 0x80 -0xFF, 0xFF, 0x10 -0x10, 0xFF, 0xFF -0x10, 0x10, 0xFF -0xFF, 0xFF, 0xFF -0x4C, 0x9C, 0xEC -0x78, 0x80, 0xFF -0xAC, 0x70, 0xFF -0xE0, 0x60, 0xF0 -0xFC, 0x68, 0xA4 -0xFF, 0x70, 0x68 -0xE2, 0x92, 0x38 -0xBB, 0xAB, 0x00 -0x7E, 0xC2, 0x1C -0x40, 0xD0, 0x30 -0x28, 0xC4, 0x80 -0x20, 0xB8, 0xC0 -0x48, 0x48, 0x48 -0x10, 0x10, 0x10 -0x10, 0x10, 0x10 -0xFF, 0xFF, 0xFF -0xB4, 0xD4, 0xFF -0xC0, 0xC8, 0xFF -0xD8, 0xC4, 0xFF -0xF0, 0xC0, 0xFF -0xFF, 0xC4, 0xD8 -0xFF, 0xC8, 0xC0 -0xF8, 0xD4, 0xAC -0xE8, 0xE0, 0x98 -0xD0, 0xE8, 0xA0 -0xB8, 0xF0, 0xA8 -0xA8, 0xE8, 0xD0 -0xA8, 0xE0, 0xE8 -0xB2, 0xB2, 0xB2 -0x10, 0xFF, 0x10 -0xFF, 0x10, 0x10 - -*/ - -}; diff --git a/branches/fceux-2.2.2/src/ppu.cpp b/branches/fceux-2.2.2/src/ppu.cpp deleted file mode 100644 index 06225c84..00000000 --- a/branches/fceux-2.2.2/src/ppu.cpp +++ /dev/null @@ -1,2315 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "ppu.h" -#include "nsf.h" -#include "sound.h" -#include "file.h" -#include "utils/endian.h" -#include "utils/memory.h" - -#include "cart.h" -#include "palette.h" -#include "state.h" -#include "video.h" -#include "input.h" -#include "driver.h" -#include "debug.h" - -#include -#include -#include - -#define VBlankON (PPU[0] & 0x80) //Generate VBlank NMI -#define Sprite16 (PPU[0] & 0x20) //Sprites 8x16/8x8 -#define BGAdrHI (PPU[0] & 0x10) //BG pattern adr $0000/$1000 -#define SpAdrHI (PPU[0] & 0x08) //Sprite pattern adr $0000/$1000 -#define INC32 (PPU[0] & 0x04) //auto increment 1/32 - -#define SpriteON (PPU[1] & 0x10) //Show Sprite -#define ScreenON (PPU[1] & 0x08) //Show screen -#define PPUON (PPU[1] & 0x18) //PPU should operate -#define GRAYSCALE (PPU[1] & 0x01) //Grayscale (AND palette entries with 0x30) - -#define SpriteLeft8 (PPU[1] & 0x04) -#define BGLeft8 (PPU[1] & 0x02) - -#define PPU_status (PPU[2]) - -#define Pal (PALRAM) - -static void FetchSpriteData(void); -static void RefreshLine(int lastpixel); -static void RefreshSprites(void); -static void CopySprites(uint8 *target); - -static void Fixit1(void); -static uint32 ppulut1[256]; -static uint32 ppulut2[256]; -static uint32 ppulut3[128]; - -int test = 0; - -template -struct BITREVLUT { - T* lut; - BITREVLUT() { - int bits = BITS; - int n = 1 << BITS; - lut = new T[n]; - - int m = 1; - int a = n >> 1; - int j = 2; - - lut[0] = 0; - lut[1] = a; - - while (--bits) { - m <<= 1; - a >>= 1; - for (int i = 0; i < m; i++) - lut[j++] = lut[i] + a; - } - } - - T operator[](int index) { - return lut[index]; - } -}; -BITREVLUT bitrevlut; - -struct PPUSTATUS { - int32 sl; - int32 cycle, end_cycle; -}; - -struct SPRITE_READ { - int32 num; - int32 count; - int32 fetch; - int32 found; - int32 found_pos[8]; - int32 ret; - int32 last; - int32 mode; - - void reset() { - num = count = fetch = found = ret = last = mode = 0; - found_pos[0] = found_pos[1] = found_pos[2] = found_pos[3] = 0; - found_pos[4] = found_pos[5] = found_pos[6] = found_pos[7] = 0; - } - - void start_scanline() { - num = 1; - found = 0; - fetch = 1; - count = 0; - last = 64; - mode = 0; - found_pos[0] = found_pos[1] = found_pos[2] = found_pos[3] = 0; - found_pos[4] = found_pos[5] = found_pos[6] = found_pos[7] = 0; - } -}; - -//doesn't need to be savestated as it is just a reflection of the current position in the ppu loop -PPUPHASE ppuphase; - -//this needs to be savestated since a game may be trying to read from this across vblanks -SPRITE_READ spr_read; - -//definitely needs to be savestated -uint8 idleSynch = 1; - -//uses the internal counters concept at http://nesdev.icequake.net/PPU%20addressing.txt -struct PPUREGS { - //normal clocked regs. as the game can interfere with these at any time, they need to be savestated - uint32 fv; //3 - uint32 v; //1 - uint32 h; //1 - uint32 vt; //5 - uint32 ht; //5 - - //temp unlatched regs (need savestating, can be written to at any time) - uint32 _fv, _v, _h, _vt, _ht; - - //other regs that need savestating - uint32 fh; //3 (horz scroll) - uint32 s; //1 ($2000 bit 4: "Background pattern table address (0: $0000; 1: $1000)") - - //other regs that don't need saving - uint32 par; //8 (sort of a hack, just stored in here, but not managed by this system) - - //cached state data. these are always reset at the beginning of a frame and don't need saving - //but just to be safe, we're gonna save it - PPUSTATUS status; - - void reset() { - fv = v = h = vt = ht = 0; - fh = par = s = 0; - _fv = _v = _h = _vt = _ht = 0; - status.cycle = 0; - status.end_cycle = 341; - status.sl = 241; - } - - void install_latches() { - fv = _fv; - v = _v; - h = _h; - vt = _vt; - ht = _ht; - } - - void install_h_latches() { - ht = _ht; - h = _h; - } - - void clear_latches() { - _fv = _v = _h = _vt = _ht = 0; - fh = 0; - } - - void increment_hsc() { - //The first one, the horizontal scroll counter, consists of 6 bits, and is - //made up by daisy-chaining the HT counter to the H counter. The HT counter is - //then clocked every 8 pixel dot clocks (or every 8/3 CPU clock cycles). - ht++; - h += (ht >> 5); - ht &= 31; - h &= 1; - } - - void increment_vs() { - fv++; - int fv_overflow = (fv >> 3); - vt += fv_overflow; - vt &= 31; //fixed tecmo super bowl - if (vt == 30 && fv_overflow == 1) { //caution here (only do it at the exact instant of overflow) fixes p'radikus conflict - v++; - vt = 0; - } - fv &= 7; - v &= 1; - } - - uint32 get_ntread() { - return 0x2000 | (v << 0xB) | (h << 0xA) | (vt << 5) | ht; - } - - uint32 get_2007access() { - return ((fv & 3) << 0xC) | (v << 0xB) | (h << 0xA) | (vt << 5) | ht; - } - - //The PPU has an internal 4-position, 2-bit shifter, which it uses for - //obtaining the 2-bit palette select data during an attribute table byte - //fetch. To represent how this data is shifted in the diagram, letters a..c - //are used in the diagram to represent the right-shift position amount to - //apply to the data read from the attribute data (a is always 0). This is why - //you only see bits 0 and 1 used off the read attribute data in the diagram. - uint32 get_atread() { - return 0x2000 | (v << 0xB) | (h << 0xA) | 0x3C0 | ((vt & 0x1C) << 1) | ((ht & 0x1C) >> 2); - } - - //address line 3 relates to the pattern table fetch occuring (the PPU always makes them in pairs). - uint32 get_ptread() { - return (s << 0xC) | (par << 0x4) | fv; - } - - void increment2007(bool rendering, bool by32) { - - if (rendering) - { - //don't do this: - //if (by32) increment_vs(); - //else increment_hsc(); - //do this instead: - increment_vs(); //yes, even if we're moving by 32 - return; - } - - //If the VRAM address increment bit (2000.2) is clear (inc. amt. = 1), all the - //scroll counters are daisy-chained (in the order of HT, VT, H, V, FV) so that - //the carry out of each counter controls the next counter's clock rate. The - //result is that all 5 counters function as a single 15-bit one. Any access to - //2007 clocks the HT counter here. - // - //If the VRAM address increment bit is set (inc. amt. = 32), the only - //difference is that the HT counter is no longer being clocked, and the VT - //counter is now being clocked by access to 2007. - if (by32) { - vt++; - } else { - ht++; - vt += (ht >> 5) & 1; - } - h += (vt >> 5); - v += (h >> 1); - fv += (v >> 1); - ht &= 31; - vt &= 31; - h &= 1; - v &= 1; - fv &= 7; - } -} ppur; - -static void makeppulut(void) { - int x; - int y; - int cc, xo, pixel; - - - for (x = 0; x < 256; x++) { - ppulut1[x] = 0; - for (y = 0; y < 8; y++) - ppulut1[x] |= ((x >> (7 - y)) & 1) << (y * 4); - ppulut2[x] = ppulut1[x] << 1; - } - - for (cc = 0; cc < 16; cc++) { - for (xo = 0; xo < 8; xo++) { - ppulut3[xo | (cc << 3)] = 0; - for (pixel = 0; pixel < 8; pixel++) { - int shiftr; - shiftr = (pixel + xo) / 8; - shiftr *= 2; - ppulut3[xo | (cc << 3)] |= ((cc >> shiftr) & 3) << (2 + pixel * 4); - } - } - } -} - -static int ppudead = 1; -static int kook = 0; -int fceuindbg = 0; - -//mbg 6/23/08 -//make the no-bg fill color configurable -//0xFF shall indicate to use palette[0] -uint8 gNoBGFillColor = 0xFF; - -int MMC5Hack = 0, PEC586Hack = 0;; -uint32 MMC5HackVROMMask = 0; -uint8 *MMC5HackExNTARAMPtr = 0; -uint8 *MMC5HackVROMPTR = 0; -uint8 MMC5HackCHRMode = 0; -uint8 MMC5HackSPMode = 0; -uint8 MMC50x5130 = 0; -uint8 MMC5HackSPScroll = 0; -uint8 MMC5HackSPPage = 0; - -uint8 VRAMBuffer = 0, PPUGenLatch = 0; -uint8 *vnapage[4]; -uint8 PPUNTARAM = 0; -uint8 PPUCHRRAM = 0; - -//Color deemphasis emulation. Joy... -static uint8 deemp = 0; -static int deempcnt[8]; - -void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void); -void (*PPU_hook)(uint32 A); - -uint8 vtoggle = 0; -uint8 XOffset = 0; - -uint32 TempAddr = 0, RefreshAddr = 0, DummyRead = 0; - -static int maxsprites = 8; - -//scanline is equal to the current visible scanline we're on. -int scanline; -int g_rasterpos; -static uint32 scanlines_per_frame; - -uint8 PPU[4]; -uint8 PPUSPL; -uint8 NTARAM[0x800], PALRAM[0x20], SPRAM[0x100], SPRBUF[0x100]; -uint8 UPALRAM[0x03];//for 0x4/0x8/0xC addresses in palette, the ones in - //0x20 are 0 to not break fceu rendering. - -#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)] -#define VRAMADR(V) &VPage[(V) >> 10][(V)] - -//mbg 8/6/08 - fix a bug relating to -//"When in 8x8 sprite mode, only one set is used for both BG and sprites." -//in mmc5 docs -uint8 * MMC5BGVRAMADR(uint32 V) { - if (!Sprite16) { - extern uint8 mmc5ABMode; /* A=0, B=1 */ - if (mmc5ABMode == 0) - return MMC5SPRVRAMADR(V); - else - return &MMC5BGVPage[(V) >> 10][(V)]; - } else return &MMC5BGVPage[(V) >> 10][(V)]; -} - -//this duplicates logic which is embedded in the ppu rendering code -//which figures out where to get CHR data from depending on various hack modes -//mostly involving mmc5. -//this might be incomplete. -uint8* FCEUPPU_GetCHR(uint32 vadr, uint32 refreshaddr) { - if (MMC5Hack) { - if (MMC5HackCHRMode == 1) { - uint8 *C = MMC5HackVROMPTR; - C += (((MMC5HackExNTARAMPtr[refreshaddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff); - C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer - return C; - } else { - return MMC5BGVRAMADR(vadr); - } - } else return VRAMADR(vadr); -} - -//likewise for ATTR -int FCEUPPU_GetAttr(int ntnum, int xt, int yt) { - int attraddr = 0x3C0 + ((yt >> 2) << 3) + (xt >> 2); - int temp = (((yt & 2) << 1) + (xt & 2)); - int refreshaddr = xt + yt * 32; - if (MMC5Hack && MMC5HackCHRMode == 1) - return (MMC5HackExNTARAMPtr[refreshaddr & 0x3ff] & 0xC0) >> 6; - else - return (vnapage[ntnum][attraddr] & (3 << temp)) >> temp; -} - -//new ppu----- -inline void FFCEUX_PPUWrite_Default(uint32 A, uint8 V) { - uint32 tmp = A; - - if (PPU_hook) PPU_hook(A); - - if (tmp < 0x2000) { - if (PPUCHRRAM & (1 << (tmp >> 10))) - VPage[tmp >> 10][tmp] = V; - } else if (tmp < 0x3F00) { - if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10))) - vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V; - } else { - if (!(tmp & 3)) { - if (!(tmp & 0xC)) - PALRAM[0x00] = PALRAM[0x04] = PALRAM[0x08] = PALRAM[0x0C] = V & 0x3F; - else - UPALRAM[((tmp & 0xC) >> 2) - 1] = V & 0x3F; - } else - PALRAM[tmp & 0x1F] = V & 0x3F; - } -} - -volatile int rendercount, vromreadcount, undefinedvromcount, LogAddress = -1; -unsigned char *cdloggervdata; -unsigned int cdloggerVideoDataSize = 0; - -int GetCHRAddress(int A) { - if (cdloggerVideoDataSize) { - int result = &VPage[A >> 10][A] - CHRptr[0]; - if ((result >= 0) && (result < (int)cdloggerVideoDataSize)) - return result; - } - return -1; -} - -#define RENDER_LOG(tmp) { \ - if (debug_loggingCD) \ - { \ - int addr = GetCHRAddress(tmp); \ - if (addr != -1) \ - { \ - if (!(cdloggervdata[addr] & 1)) \ - { \ - cdloggervdata[addr] |= 1; \ - if (!(cdloggervdata[addr] & 2)) undefinedvromcount--; \ - rendercount++; \ - } \ - } \ - } \ -} - -uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A) { - uint32 tmp = A; - - if (PPU_hook) PPU_hook(A); - - if (tmp < 0x2000) { - return VPage[tmp >> 10][tmp]; - } else if (tmp < 0x3F00) { - return vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF]; - } else { - uint8 ret; - if (!(tmp & 3)) { - if (!(tmp & 0xC)) - ret = PALRAM[0x00]; - else - ret = UPALRAM[((tmp & 0xC) >> 2) - 1]; - } else - ret = PALRAM[tmp & 0x1F]; - - if (GRAYSCALE) - ret &= 0x30; - return ret; - } -} - - -uint8 (FASTCALL *FFCEUX_PPURead)(uint32 A) = 0; -void (*FFCEUX_PPUWrite)(uint32 A, uint8 V) = 0; - -#define CALL_PPUREAD(A) (FFCEUX_PPURead(A)) - -#define CALL_PPUWRITE(A, V) (FFCEUX_PPUWrite ? FFCEUX_PPUWrite(A, V) : FFCEUX_PPUWrite_Default(A, V)) - -//whether to use the new ppu (new PPU doesn't handle MMC5 extra nametables at all -int newppu = 0; - -void ppu_getScroll(int &xpos, int &ypos) { - if (newppu) { - ypos = ppur._vt * 8 + ppur._fv + ppur._v * 256; - xpos = ppur._ht * 8 + ppur.fh + ppur._h * 256; - } else { - xpos = ((RefreshAddr & 0x400) >> 2) | ((RefreshAddr & 0x1F) << 3) | XOffset; - - ypos = ((RefreshAddr & 0x3E0) >> 2) | ((RefreshAddr & 0x7000) >> 12); - if (RefreshAddr & 0x800) ypos += 240; - } -} -//--------------- - -static DECLFR(A2002) { - if (newppu) { - //once we thought we clear latches here, but that caused midframe glitches. - //i think we should only reset the state machine for 2005/2006 - //ppur.clear_latches(); - } - - uint8 ret; - - FCEUPPU_LineUpdate(); - ret = PPU_status; - ret |= PPUGenLatch & 0x1F; - -#ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) -#endif - { - vtoggle = 0; - PPU_status &= 0x7F; - PPUGenLatch = ret; - } - - return ret; -} - -static DECLFR(A2004) { - if (newppu) { - if ((ppur.status.sl < 241) && PPUON) { - // from cycles 0 to 63, the - // 32 byte OAM buffer gets init - // to 0xFF - if (ppur.status.cycle < 64) - return spr_read.ret = 0xFF; - else { - for (int i = spr_read.last; - i != ppur.status.cycle; ++i) { - if (i < 256) { - switch (spr_read.mode) { - case 0: - if (spr_read.count < 2) - spr_read.ret = (PPU[3] & 0xF8) + (spr_read.count << 2); - else - spr_read.ret = spr_read.count << 2; - - spr_read.found_pos[spr_read.found] = spr_read.ret; - spr_read.ret = SPRAM[spr_read.ret]; - - if (i & 1) { - //odd cycle - //see if in range - if (!((ppur.status.sl - 1 - spr_read.ret) & ~(Sprite16 ? 0xF : 0x7))) { - ++spr_read.found; - spr_read.fetch = 1; - spr_read.mode = 1; - } else { - if (++spr_read.count == 64) { - spr_read.mode = 4; - spr_read.count = 0; - } else if (spr_read.found == 8) { - spr_read.fetch = 0; - spr_read.mode = 2; - } - } - } - break; - case 1: //sprite is in range fetch next 3 bytes - if (i & 1) { - ++spr_read.fetch; - if (spr_read.fetch == 4) { - spr_read.fetch = 1; - if (++spr_read.count == 64) { - spr_read.count = 0; - spr_read.mode = 4; - } else if (spr_read.found == 8) { - spr_read.fetch = 0; - spr_read.mode = 2; - } else - spr_read.mode = 0; - } - } - - if (spr_read.count < 2) - spr_read.ret = (PPU[3] & 0xF8) + (spr_read.count << 2); - else - spr_read.ret = spr_read.count << 2; - - spr_read.ret = SPRAM[spr_read.ret | spr_read.fetch]; - break; - case 2: //8th sprite fetched - spr_read.ret = SPRAM[(spr_read.count << 2) | spr_read.fetch]; - if (i & 1) { - if (!((ppur.status.sl - 1 - SPRAM[((spr_read.count << 2) | spr_read.fetch)]) & ~((Sprite16) ? 0xF : 0x7))) { - spr_read.fetch = 1; - spr_read.mode = 3; - } else { - if (++spr_read.count == 64) { - spr_read.count = 0; - spr_read.mode = 4; - } - spr_read.fetch = - (spr_read.fetch + 1) & 3; - } - } - spr_read.ret = spr_read.count; - break; - case 3: //9th sprite overflow detected - spr_read.ret = SPRAM[spr_read.count | spr_read.fetch]; - if (i & 1) { - if (++spr_read.fetch == 4) { - spr_read.count = (spr_read.count + 1) & 63; - spr_read.mode = 4; - } - } - break; - case 4: //read OAM[n][0] until hblank - if (i & 1) - spr_read.count = (spr_read.count + 1) & 63; - spr_read.fetch = 0; - spr_read.ret = SPRAM[spr_read.count << 2]; - break; - } - } else if (i < 320) { - spr_read.ret = (i & 0x38) >> 3; - if (spr_read.found < (spr_read.ret + 1)) { - if (spr_read.num) { - spr_read.ret = SPRAM[252]; - spr_read.num = 0; - } else - spr_read.ret = 0xFF; - } else if ((i & 7) < 4) { - spr_read.ret = - SPRAM[spr_read.found_pos[spr_read.ret] | spr_read.fetch++]; - if (spr_read.fetch == 4) - spr_read.fetch = 0; - } else - spr_read.ret = SPRAM[spr_read.found_pos [spr_read.ret | 3]]; - } else { - if (!spr_read.found) - spr_read.ret = SPRAM[252]; - else - spr_read.ret = SPRAM[spr_read.found_pos[0]]; - break; - } - } - spr_read.last = ppur.status.cycle; - return spr_read.ret; - } - } else - return SPRAM[PPU[3]]; - } else { - FCEUPPU_LineUpdate(); - return PPUGenLatch; - } -} - -static DECLFR(A200x) { /* Not correct for $2004 reads. */ - FCEUPPU_LineUpdate(); - return PPUGenLatch; -} - -static DECLFR(A2007) { - uint8 ret; - uint32 tmp = RefreshAddr & 0x3FFF; - - if (debug_loggingCD) { - if (!DummyRead && (LogAddress != -1)) { - if (!(cdloggervdata[LogAddress] & 2)) { - cdloggervdata[LogAddress] |= 2; - if (!(cdloggervdata[LogAddress] & 1)) undefinedvromcount--; - vromreadcount++; - } - } else - DummyRead = 0; - } - - if (newppu) { - ret = VRAMBuffer; - RefreshAddr = ppur.get_2007access() & 0x3FFF; - if ((RefreshAddr & 0x3F00) == 0x3F00) { - //if it is in the palette range bypass the - //delayed read, and what gets filled in the temp - //buffer is the address - 0x1000, also - //if grayscale is set then the return is AND with 0x30 - //to get a gray color reading - if (!(tmp & 3)) { - if (!(tmp & 0xC)) - ret = PALRAM[0x00]; - else - ret = UPALRAM[((tmp & 0xC) >> 2) - 1]; - } else - ret = PALRAM[tmp & 0x1F]; - if (GRAYSCALE) - ret &= 0x30; - VRAMBuffer = CALL_PPUREAD(RefreshAddr - 0x1000); - } else { - if (debug_loggingCD && (RefreshAddr < 0x2000)) - LogAddress = GetCHRAddress(RefreshAddr); - VRAMBuffer = CALL_PPUREAD(RefreshAddr); - } - ppur.increment2007(ppur.status.sl >= 0 && ppur.status.sl < 241 && PPUON, INC32 != 0); - RefreshAddr = ppur.get_2007access(); - return ret; - } else { - FCEUPPU_LineUpdate(); - - if (tmp >= 0x3F00) { // Palette RAM tied directly to the output data, without VRAM buffer - if (!(tmp & 3)) { - if (!(tmp & 0xC)) - ret = PALRAM[0x00]; - else - ret = UPALRAM[((tmp & 0xC) >> 2) - 1]; - } else - ret = PALRAM[tmp & 0x1F]; - if (GRAYSCALE) - ret &= 0x30; - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - { - if ((tmp - 0x1000) < 0x2000) - VRAMBuffer = VPage[(tmp - 0x1000) >> 10][tmp - 0x1000]; - else - VRAMBuffer = vnapage[((tmp - 0x1000) >> 10) & 0x3][(tmp - 0x1000) & 0x3FF]; - if (PPU_hook) PPU_hook(tmp); - } - } else { - ret = VRAMBuffer; - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - { - if (PPU_hook) PPU_hook(tmp); - PPUGenLatch = VRAMBuffer; - if (tmp < 0x2000) { - if (debug_loggingCD) - LogAddress = GetCHRAddress(tmp); - VRAMBuffer = VPage[tmp >> 10][tmp]; - } else if (tmp < 0x3F00) - VRAMBuffer = vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF]; - } - } - - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - { - if ((ScreenON || SpriteON) && (scanline < 240)) { - uint32 rad = RefreshAddr; - if ((rad & 0x7000) == 0x7000) { - rad ^= 0x7000; - if ((rad & 0x3E0) == 0x3A0) - rad ^= 0xBA0; - else if ((rad & 0x3E0) == 0x3e0) - rad ^= 0x3e0; - else - rad += 0x20; - } else - rad += 0x1000; - RefreshAddr = rad; - } else { - if (INC32) - RefreshAddr += 32; - else - RefreshAddr++; - } - if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff); - } - return ret; - } -} - -static DECLFW(B2000) { - FCEUPPU_LineUpdate(); - PPUGenLatch = V; - - if (!(PPU[0] & 0x80) && (V & 0x80) && (PPU_status & 0x80)) - TriggerNMI2(); - - PPU[0] = V; - TempAddr &= 0xF3FF; - TempAddr |= (V & 3) << 10; - - ppur._h = V & 1; - ppur._v = (V >> 1) & 1; - ppur.s = (V >> 4) & 1; -} - -static DECLFW(B2001) { - FCEUPPU_LineUpdate(); - PPUGenLatch = V; - PPU[1] = V; - if (V & 0xE0) - deemp = V >> 5; -} - -static DECLFW(B2002) { - PPUGenLatch = V; -} - -static DECLFW(B2003) { - PPUGenLatch = V; - PPU[3] = V; - PPUSPL = V & 0x7; -} - -static DECLFW(B2004) { - PPUGenLatch = V; - if (newppu) { - //the attribute upper bits are not connected - //so AND them out on write, since reading them - //should return 0 in those bits. - if ((PPU[3] & 3) == 2) - V &= 0xE3; - SPRAM[PPU[3]] = V; - PPU[3] = (PPU[3] + 1) & 0xFF; - } else { - if (PPUSPL >= 8) { - if (PPU[3] >= 8) - SPRAM[PPU[3]] = V; - } else { - SPRAM[PPUSPL] = V; - } - PPU[3]++; - PPUSPL++; - } -} - -static DECLFW(B2005) { - uint32 tmp = TempAddr; - FCEUPPU_LineUpdate(); - PPUGenLatch = V; - if (!vtoggle) { - tmp &= 0xFFE0; - tmp |= V >> 3; - XOffset = V & 7; - ppur._ht = V >> 3; - ppur.fh = V & 7; - } else { - tmp &= 0x8C1F; - tmp |= ((V & ~0x7) << 2); - tmp |= (V & 7) << 12; - ppur._vt = V >> 3; - ppur._fv = V & 7; - } - TempAddr = tmp; - vtoggle ^= 1; -} - - -static DECLFW(B2006) { - FCEUPPU_LineUpdate(); - - PPUGenLatch = V; - if (!vtoggle) { - TempAddr &= 0x00FF; - TempAddr |= (V & 0x3f) << 8; - - ppur._vt &= 0x07; - ppur._vt |= (V & 0x3) << 3; - ppur._h = (V >> 2) & 1; - ppur._v = (V >> 3) & 1; - ppur._fv = (V >> 4) & 3; - } else { - TempAddr &= 0xFF00; - TempAddr |= V; - - RefreshAddr = TempAddr; - DummyRead = 1; - if (PPU_hook) - PPU_hook(RefreshAddr); - - ppur._vt &= 0x18; - ppur._vt |= (V >> 5); - ppur._ht = V & 31; - - ppur.install_latches(); - } - - vtoggle ^= 1; -} - -static DECLFW(B2007) { - uint32 tmp = RefreshAddr & 0x3FFF; - - if (newppu) { - PPUGenLatch = V; - RefreshAddr = ppur.get_2007access() & 0x3FFF; - CALL_PPUWRITE(RefreshAddr, V); - ppur.increment2007(ppur.status.sl >= 0 && ppur.status.sl < 241 && PPUON, INC32 != 0); - RefreshAddr = ppur.get_2007access(); - } else { - PPUGenLatch = V; - if (tmp < 0x2000) { - if (PPUCHRRAM & (1 << (tmp >> 10))) - VPage[tmp >> 10][tmp] = V; - } else if (tmp < 0x3F00) { - if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10))) - vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V; - } else { - if (!(tmp & 3)) { - if (!(tmp & 0xC)) - PALRAM[0x00] = PALRAM[0x04] = PALRAM[0x08] = PALRAM[0x0C] = V & 0x3F; - else - UPALRAM[((tmp & 0xC) >> 2) - 1] = V & 0x3F; - } else - PALRAM[tmp & 0x1F] = V & 0x3F; - } - if (INC32) - RefreshAddr += 32; - else - RefreshAddr++; - if (PPU_hook) - PPU_hook(RefreshAddr & 0x3fff); - } -} - -static DECLFW(B4014) { - uint32 t = V << 8; - int x; - - for (x = 0; x < 256; x++) - X6502_DMW(0x2004, X6502_DMR(t + x)); -} - -#define PAL(c) ((c) + cc) - -#define GETLASTPIXEL (PAL ? ((timestamp * 48 - linestartts) / 15) : ((timestamp * 48 - linestartts) >> 4)) - -static uint8 *Pline, *Plinef; -static int firsttile; -int linestartts; //no longer static so the debugger can see it -static int tofix = 0; - -static void ResetRL(uint8 *target) { - memset(target, 0xFF, 256); - InputScanlineHook(0, 0, 0, 0); - Plinef = target; - Pline = target; - firsttile = 0; - linestartts = timestamp * 48 + X.count; - tofix = 0; - FCEUPPU_LineUpdate(); - tofix = 1; -} - -static uint8 sprlinebuf[256 + 8]; - -void FCEUPPU_LineUpdate(void) { - if (newppu) - return; - -#ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) -#endif - if (Pline) { - int l = GETLASTPIXEL; - RefreshLine(l); - } -} - -static bool rendersprites = true, renderbg = true; - -void FCEUI_SetRenderPlanes(bool sprites, bool bg) { - rendersprites = sprites; - renderbg = bg; -} - -void FCEUI_GetRenderPlanes(bool& sprites, bool& bg) { - sprites = rendersprites; - bg = renderbg; -} - -static void CheckSpriteHit(int p); - -static void EndRL(void) { - RefreshLine(272); - if (tofix) - Fixit1(); - CheckSpriteHit(272); - Pline = 0; -} - -static int32 sphitx; -static uint8 sphitdata; - -static void CheckSpriteHit(int p) { - int l = p - 16; - int x; - - if (sphitx == 0x100) return; - - for (x = sphitx; x < (sphitx + 8) && x < l; x++) { - if ((sphitdata & (0x80 >> (x - sphitx))) && !(Plinef[x] & 64) && x < 255) { - PPU_status |= 0x40; - sphitx = 0x100; - break; - } - } -} - -//spork the world. Any sprites on this line? Then this will be set to 1. -//Needed for zapper emulation and *gasp* sprite emulation. -static int spork = 0; - -// lasttile is really "second to last tile." -static void RefreshLine(int lastpixel) { - static uint32 pshift[2]; - static uint32 atlatch; - uint32 smorkus = RefreshAddr; - - #define RefreshAddr smorkus - uint32 vofs; - int X1; - - register uint8 *P = Pline; - int lasttile = lastpixel >> 3; - int numtiles; - static int norecurse = 0; // Yeah, recursion would be bad. - // PPU_hook() functions can call - // mirroring/chr bank switching functions, - // which call FCEUPPU_LineUpdate, which call this - // function. - if (norecurse) return; - - if (sphitx != 0x100 && !(PPU_status & 0x40)) { - if ((sphitx < (lastpixel - 16)) && !(sphitx < ((lasttile - 2) * 8))) - lasttile++; - } - - if (lasttile > 34) lasttile = 34; - numtiles = lasttile - firsttile; - - if (numtiles <= 0) return; - - P = Pline; - - vofs = 0; - - if(PEC586Hack) - vofs = ((RefreshAddr & 0x200) << 3) | ((RefreshAddr >> 12) & 7); - else - vofs = ((PPU[0] & 0x10) << 8) | ((RefreshAddr >> 12) & 7); - - if (!ScreenON && !SpriteON) { - uint32 tem; - tem = Pal[0] | (Pal[0] << 8) | (Pal[0] << 16) | (Pal[0] << 24); - tem |= 0x40404040; - FCEU_dwmemset(Pline, tem, numtiles * 8); - P += numtiles * 8; - Pline = P; - - firsttile = lasttile; - - #define TOFIXNUM (272 - 0x4) - if (lastpixel >= TOFIXNUM && tofix) { - Fixit1(); - tofix = 0; - } - - if ((lastpixel - 16) >= 0) { - InputScanlineHook(Plinef, spork ? sprlinebuf : 0, linestartts, lasttile * 8 - 16); - } - return; - } - - //Priority bits, needed for sprite emulation. - Pal[0] |= 64; - Pal[4] |= 64; - Pal[8] |= 64; - Pal[0xC] |= 64; - - //This high-level graphics MMC5 emulation code was written for MMC5 carts in "CL" mode. - //It's probably not totally correct for carts in "SL" mode. - -#define PPUT_MMC5 - if (MMC5Hack && geniestage != 1) { - if (MMC5HackCHRMode == 0 && (MMC5HackSPMode & 0x80)) { - int tochange = MMC5HackSPMode & 0x1F; - tochange -= firsttile; - for (X1 = firsttile; X1 < lasttile; X1++) { - if ((tochange <= 0 && MMC5HackSPMode & 0x40) || (tochange > 0 && !(MMC5HackSPMode & 0x40))) { - #define PPUT_MMC5SP - #include "pputile.inc" - #undef PPUT_MMC5SP - } else { - #include "pputile.inc" - } - tochange--; - } - } else if (MMC5HackCHRMode == 1 && (MMC5HackSPMode & 0x80)) { - int tochange = MMC5HackSPMode & 0x1F; - tochange -= firsttile; - - #define PPUT_MMC5SP - #define PPUT_MMC5CHR1 - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - #undef PPUT_MMC5CHR1 - #undef PPUT_MMC5SP - } else if (MMC5HackCHRMode == 1) { - #define PPUT_MMC5CHR1 - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - #undef PPUT_MMC5CHR1 - } else { - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - } - } - #undef PPUT_MMC5 - else if (PPU_hook) { - norecurse = 1; - #define PPUT_HOOK - if (PEC586Hack) { - #define PPU_BGFETCH - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - #undef PPU_BGFETCH - } else { - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - } - #undef PPUT_HOOK - norecurse = 0; - } else { - if (PEC586Hack) { - #define PPU_BGFETCH - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - #undef PPU_BGFETCH - } else { - for (X1 = firsttile; X1 < lasttile; X1++) { - #include "pputile.inc" - } - } - } - -#undef vofs -#undef RefreshAddr - - //Reverse changes made before. - Pal[0] &= 63; - Pal[4] &= 63; - Pal[8] &= 63; - Pal[0xC] &= 63; - - RefreshAddr = smorkus; - if (firsttile <= 2 && 2 < lasttile && !(PPU[1] & 2)) { - uint32 tem; - tem = Pal[0] | (Pal[0] << 8) | (Pal[0] << 16) | (Pal[0] << 24); - tem |= 0x40404040; - *(uint32*)Plinef = *(uint32*)(Plinef + 4) = tem; - } - - if (!ScreenON) { - uint32 tem; - int tstart, tcount; - tem = Pal[0] | (Pal[0] << 8) | (Pal[0] << 16) | (Pal[0] << 24); - tem |= 0x40404040; - - tcount = lasttile - firsttile; - tstart = firsttile - 2; - if (tstart < 0) { - tcount += tstart; - tstart = 0; - } - if (tcount > 0) - FCEU_dwmemset(Plinef + tstart * 8, tem, tcount * 8); - } - - if (lastpixel >= TOFIXNUM && tofix) { - Fixit1(); - tofix = 0; - } - - //This only works right because of a hack earlier in this function. - CheckSpriteHit(lastpixel); - - if ((lastpixel - 16) >= 0) { - InputScanlineHook(Plinef, spork ? sprlinebuf : 0, linestartts, lasttile * 8 - 16); - } - Pline = P; - firsttile = lasttile; -} - -static INLINE void Fixit2(void) { - if (ScreenON || SpriteON) { - uint32 rad = RefreshAddr; - rad &= 0xFBE0; - rad |= TempAddr & 0x041f; - RefreshAddr = rad; - } -} - -static void Fixit1(void) { - if (ScreenON || SpriteON) { - uint32 rad = RefreshAddr; - - if ((rad & 0x7000) == 0x7000) { - rad ^= 0x7000; - if ((rad & 0x3E0) == 0x3A0) - rad ^= 0xBA0; - else if ((rad & 0x3E0) == 0x3e0) - rad ^= 0x3e0; - else - rad += 0x20; - } else - rad += 0x1000; - RefreshAddr = rad; - } -} - -void MMC5_hb(int); //Ugh ugh ugh. -static void DoLine(void) { - int x; - uint8 *target = XBuf + (scanline << 8); - - if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline); - - X6502_Run(256); - EndRL(); - - if (!renderbg) {// User asked to not display background data. - uint32 tem; - uint8 col; - if (gNoBGFillColor == 0xFF) - col = Pal[0]; - else col = gNoBGFillColor; - tem = col | (col << 8) | (col << 16) | (col << 24); - tem |= 0x40404040; - FCEU_dwmemset(target, tem, 256); - } - - if (SpriteON) - CopySprites(target); - - if (ScreenON || SpriteON) { // Yes, very el-cheapo. - if (PPU[1] & 0x01) { - for (x = 63; x >= 0; x--) - *(uint32*)&target[x << 2] = (*(uint32*)&target[x << 2]) & 0x30303030; - } - } - if ((PPU[1] >> 5) == 0x7) { - for (x = 63; x >= 0; x--) - *(uint32*)&target[x << 2] = ((*(uint32*)&target[x << 2]) & 0x3f3f3f3f) | 0xc0c0c0c0; - } else if (PPU[1] & 0xE0) - for (x = 63; x >= 0; x--) - *(uint32*)&target[x << 2] = (*(uint32*)&target[x << 2]) | 0x40404040; - else - for (x = 63; x >= 0; x--) - *(uint32*)&target[x << 2] = ((*(uint32*)&target[x << 2]) & 0x3f3f3f3f) | 0x80808080; - - sphitx = 0x100; - - if (ScreenON || SpriteON) - FetchSpriteData(); - - if (GameHBIRQHook && (ScreenON || SpriteON) && ((PPU[0] & 0x38) != 0x18)) { - X6502_Run(6); - Fixit2(); - X6502_Run(4); - GameHBIRQHook(); - X6502_Run(85 - 16 - 10); - } else { - X6502_Run(6); // Tried 65, caused problems with Slalom(maybe others) - Fixit2(); - X6502_Run(85 - 6 - 16); - - // A semi-hack for Star Trek: 25th Anniversary - if (GameHBIRQHook && (ScreenON || SpriteON) && ((PPU[0] & 0x38) != 0x18)) - GameHBIRQHook(); - } - - DEBUG(FCEUD_UpdateNTView(scanline, 0)); - - if (SpriteON) - RefreshSprites(); - if (GameHBIRQHook2 && (ScreenON || SpriteON)) - GameHBIRQHook2(); - scanline++; - if (scanline < 240) { - ResetRL(XBuf + (scanline << 8)); - } - X6502_Run(16); -} - -#define V_FLIP 0x80 -#define H_FLIP 0x40 -#define SP_BACK 0x20 - -typedef struct { - uint8 y, no, atr, x; -} SPR; - -typedef struct { - uint8 ca[2], atr, x; -} SPRB; - -void FCEUI_DisableSpriteLimitation(int a) { - maxsprites = a ? 64 : 8; -} - -static uint8 numsprites, SpriteBlurp; -static void FetchSpriteData(void) { - uint8 ns, sb; - SPR *spr; - uint8 H; - int n; - int vofs; - uint8 P0 = PPU[0]; - - spr = (SPR*)SPRAM; - H = 8; - - ns = sb = 0; - - vofs = (uint32)(P0 & 0x8 & (((P0 & 0x20) ^ 0x20) >> 2)) << 9; - H += (P0 & 0x20) >> 2; - - if (!PPU_hook) - for (n = 63; n >= 0; n--, spr++) { - if ((uint32)(scanline - spr->y) >= H) continue; - if (ns < maxsprites) { - if (n == 63) sb = 1; - - { - SPRB dst; - uint8 *C; - int t; - uint32 vadr; - - t = (int)scanline - (spr->y); - - if (Sprite16) - vadr = ((spr->no & 1) << 12) + ((spr->no & 0xFE) << 4); - else - vadr = (spr->no << 4) + vofs; - - if (spr->atr & V_FLIP) { - vadr += 7; - vadr -= t; - vadr += (P0 & 0x20) >> 1; - vadr -= t & 8; - } else { - vadr += t; - vadr += t & 8; - } - - /* Fix this geniestage hack */ - if (MMC5Hack && geniestage != 1) - C = MMC5SPRVRAMADR(vadr); - else - C = VRAMADR(vadr); - - if (SpriteON) - RENDER_LOG(vadr); - dst.ca[0] = C[0]; - if (SpriteON) - RENDER_LOG(vadr + 8); - dst.ca[1] = C[8]; - dst.x = spr->x; - dst.atr = spr->atr; - - *(uint32*)&SPRBUF[ns << 2] = *(uint32*)&dst; - } - - ns++; - } else { - PPU_status |= 0x20; - break; - } - } - else - for (n = 63; n >= 0; n--, spr++) { - if ((uint32)(scanline - spr->y) >= H) continue; - - if (ns < maxsprites) { - if (n == 63) sb = 1; - - { - SPRB dst; - uint8 *C; - int t; - uint32 vadr; - - t = (int)scanline - (spr->y); - - if (Sprite16) - vadr = ((spr->no & 1) << 12) + ((spr->no & 0xFE) << 4); - else - vadr = (spr->no << 4) + vofs; - - if (spr->atr & V_FLIP) { - vadr += 7; - vadr -= t; - vadr += (P0 & 0x20) >> 1; - vadr -= t & 8; - } else { - vadr += t; - vadr += t & 8; - } - - if (MMC5Hack) - C = MMC5SPRVRAMADR(vadr); - else - C = VRAMADR(vadr); - if (SpriteON) - RENDER_LOG(vadr); - dst.ca[0] = C[0]; - if (ns < 8) { - PPU_hook(0x2000); - PPU_hook(vadr); - } - if (SpriteON) - RENDER_LOG(vadr + 8); - dst.ca[1] = C[8]; - dst.x = spr->x; - dst.atr = spr->atr; - - - *(uint32*)&SPRBUF[ns << 2] = *(uint32*)&dst; - } - - ns++; - } else { - PPU_status |= 0x20; - break; - } - } - - //Handle case when >8 sprites per scanline option is enabled. - if (ns > 8) PPU_status |= 0x20; - else if (PPU_hook) { - for (n = 0; n < (8 - ns); n++) { - PPU_hook(0x2000); - PPU_hook(vofs); - } - } - numsprites = ns; - SpriteBlurp = sb; -} - -static void RefreshSprites(void) { - int n; - SPRB *spr; - - spork = 0; - if (!numsprites) return; - - FCEU_dwmemset(sprlinebuf, 0x80808080, 256); - numsprites--; - spr = (SPRB*)SPRBUF + numsprites; - - for (n = numsprites; n >= 0; n--, spr--) { - uint32 pixdata; - uint8 J, atr; - - int x = spr->x; - uint8 *C; - uint8 *VB; - - pixdata = ppulut1[spr->ca[0]] | ppulut2[spr->ca[1]]; - J = spr->ca[0] | spr->ca[1]; - atr = spr->atr; - - if (J) { - if (n == 0 && SpriteBlurp && !(PPU_status & 0x40)) { - sphitx = x; - sphitdata = J; - if (atr & H_FLIP) - sphitdata = ((J << 7) & 0x80) | - ((J << 5) & 0x40) | - ((J << 3) & 0x20) | - ((J << 1) & 0x10) | - ((J >> 1) & 0x08) | - ((J >> 3) & 0x04) | - ((J >> 5) & 0x02) | - ((J >> 7) & 0x01); - } - - C = sprlinebuf + x; - VB = (PALRAM + 0x10) + ((atr & 3) << 2); - - if (atr & SP_BACK) { - if (atr & H_FLIP) { - if (J & 0x80) C[7] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x40) C[6] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x20) C[5] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x10) C[4] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x08) C[3] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x04) C[2] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x02) C[1] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x01) C[0] = VB[pixdata] | 0x40; - } else { - if (J & 0x80) C[0] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x40) C[1] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x20) C[2] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x10) C[3] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x08) C[4] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x04) C[5] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x02) C[6] = VB[pixdata & 3] | 0x40; - pixdata >>= 4; - if (J & 0x01) C[7] = VB[pixdata] | 0x40; - } - } else { - if (atr & H_FLIP) { - if (J & 0x80) C[7] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x40) C[6] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x20) C[5] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x10) C[4] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x08) C[3] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x04) C[2] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x02) C[1] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x01) C[0] = VB[pixdata]; - } else { - if (J & 0x80) C[0] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x40) C[1] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x20) C[2] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x10) C[3] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x08) C[4] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x04) C[5] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x02) C[6] = VB[pixdata & 3]; - pixdata >>= 4; - if (J & 0x01) C[7] = VB[pixdata]; - } - } - } - } - SpriteBlurp = 0; - spork = 1; -} - -static void CopySprites(uint8 *target) { - uint8 n = ((PPU[1] & 4) ^ 4) << 1; - uint8 *P = target; - - if (!spork) return; - spork = 0; - - if (!rendersprites) return; //User asked to not display sprites. - - loopskie: - { - uint32 t = *(uint32*)(sprlinebuf + n); - - if (t != 0x80808080) { - #ifdef LSB_FIRST - if (!(t & 0x80)) { - if (!(t & 0x40) || (P[n] & 0x40)) // Normal sprite || behind bg sprite - P[n] = sprlinebuf[n]; - } - - if (!(t & 0x8000)) { - if (!(t & 0x4000) || (P[n + 1] & 0x40)) // Normal sprite || behind bg sprite - P[n + 1] = (sprlinebuf + 1)[n]; - } - - if (!(t & 0x800000)) { - if (!(t & 0x400000) || (P[n + 2] & 0x40)) // Normal sprite || behind bg sprite - P[n + 2] = (sprlinebuf + 2)[n]; - } - - if (!(t & 0x80000000)) { - if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite - P[n + 3] = (sprlinebuf + 3)[n]; - } - #else - /* TODO: Simplify */ - if (!(t & 0x80000000)) { - if (!(t & 0x40000000)) // Normal sprite - P[n] = sprlinebuf[n]; - else if (P[n] & 64) // behind bg sprite - P[n] = sprlinebuf[n]; - } - - if (!(t & 0x800000)) { - if (!(t & 0x400000)) // Normal sprite - P[n + 1] = (sprlinebuf + 1)[n]; - else if (P[n + 1] & 64) // behind bg sprite - P[n + 1] = (sprlinebuf + 1)[n]; - } - - if (!(t & 0x8000)) { - if (!(t & 0x4000)) // Normal sprite - P[n + 2] = (sprlinebuf + 2)[n]; - else if (P[n + 2] & 64) // behind bg sprite - P[n + 2] = (sprlinebuf + 2)[n]; - } - - if (!(t & 0x80)) { - if (!(t & 0x40)) // Normal sprite - P[n + 3] = (sprlinebuf + 3)[n]; - else if (P[n + 3] & 64) // behind bg sprite - P[n + 3] = (sprlinebuf + 3)[n]; - } - #endif - } - } - n += 4; - if (n) goto loopskie; -} - -void FCEUPPU_SetVideoSystem(int w) { - if (w) { - scanlines_per_frame = 312; - FSettings.FirstSLine = FSettings.UsrFirstSLine[1]; - FSettings.LastSLine = FSettings.UsrLastSLine[1]; - } else { - scanlines_per_frame = 262; - FSettings.FirstSLine = FSettings.UsrFirstSLine[0]; - FSettings.LastSLine = FSettings.UsrLastSLine[0]; - } -} - -//Initializes the PPU -void FCEUPPU_Init(void) { - makeppulut(); -} - -void PPU_ResetHooks() { - FFCEUX_PPURead = FFCEUX_PPURead_Default; -} - -void FCEUPPU_Reset(void) { - VRAMBuffer = PPU[0] = PPU[1] = PPU_status = PPU[3] = 0; - PPUSPL = 0; - PPUGenLatch = 0; - RefreshAddr = TempAddr = 0; - vtoggle = 0; - ppudead = 2; - kook = 0; - idleSynch = 1; - - ppur.reset(); - spr_read.reset(); -} - -void FCEUPPU_Power(void) { - int x; - - memset(NTARAM, 0x00, 0x800); - memset(PALRAM, 0x00, 0x20); - memset(UPALRAM, 0x00, 0x03); - memset(SPRAM, 0x00, 0x100); - FCEUPPU_Reset(); - - for (x = 0x2000; x < 0x4000; x += 8) { - ARead[x] = A200x; - BWrite[x] = B2000; - ARead[x + 1] = A200x; - BWrite[x + 1] = B2001; - ARead[x + 2] = A2002; - BWrite[x + 2] = B2002; - ARead[x + 3] = A200x; - BWrite[x + 3] = B2003; - ARead[x + 4] = A2004; - BWrite[x + 4] = B2004; - ARead[x + 5] = A200x; - BWrite[x + 5] = B2005; - ARead[x + 6] = A200x; - BWrite[x + 6] = B2006; - ARead[x + 7] = A2007; - BWrite[x + 7] = B2007; - } - BWrite[0x4014] = B4014; -} - -int FCEUPPU_Loop(int skip) { - if ((newppu) && (GameInfo->type != GIT_NSF)) { - int FCEUX_PPU_Loop(int skip); - return FCEUX_PPU_Loop(skip); - } - - //Needed for Knight Rider, possibly others. - if (ppudead) { - memset(XBuf, 0x80, 256 * 240); - X6502_Run(scanlines_per_frame * (256 + 85)); - ppudead--; - } else { - X6502_Run(256 + 85); - PPU_status |= 0x80; - - //Not sure if this is correct. According to Matt Conte and my own tests, it is. - //Timing is probably off, though. - //NOTE: Not having this here breaks a Super Donkey Kong game. - PPU[3] = PPUSPL = 0; - - //I need to figure out the true nature and length of this delay. - X6502_Run(12); - if (GameInfo->type == GIT_NSF) - DoNSFFrame(); - else { - if (VBlankON) - TriggerNMI(); - } - X6502_Run((scanlines_per_frame - 242) * (256 + 85) - 12); - PPU_status &= 0x1f; - X6502_Run(256); - - { - int x; - - if (ScreenON || SpriteON) { - if (GameHBIRQHook && ((PPU[0] & 0x38) != 0x18)) - GameHBIRQHook(); - if (PPU_hook) - for (x = 0; x < 42; x++) { - PPU_hook(0x2000); PPU_hook(0); - } - if (GameHBIRQHook2) - GameHBIRQHook2(); - } - X6502_Run(85 - 16); - if (ScreenON || SpriteON) { - RefreshAddr = TempAddr; - if (PPU_hook) PPU_hook(RefreshAddr & 0x3fff); - } - - //Clean this stuff up later. - spork = numsprites = 0; - ResetRL(XBuf); - - X6502_Run(16 - kook); - kook ^= 1; - } - if (GameInfo->type == GIT_NSF) - X6502_Run((256 + 85) * 240); - #ifdef FRAMESKIP - else if (skip) { - int y; - - y = SPRAM[0]; - y++; - - PPU_status |= 0x20; // Fixes "Bee 52". Does it break anything? - if (GameHBIRQHook) { - X6502_Run(256); - for (scanline = 0; scanline < 240; scanline++) { - if (ScreenON || SpriteON) - GameHBIRQHook(); - if (scanline == y && SpriteON) PPU_status |= 0x40; - X6502_Run((scanline == 239) ? 85 : (256 + 85)); - } - } else if (y < 240) { - X6502_Run((256 + 85) * y); - if (SpriteON) PPU_status |= 0x40; // Quick and very dirty hack. - X6502_Run((256 + 85) * (240 - y)); - } else - X6502_Run((256 + 85) * 240); - } - #endif - else { - int x, max, maxref; - - deemp = PPU[1] >> 5; - for (scanline = 0; scanline < 240; ) { //scanline is incremented in DoLine. Evil. :/ - deempcnt[deemp]++; - DEBUG(FCEUD_UpdatePPUView(scanline, 1)); - DoLine(); - } - if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline); - for (x = 1, max = 0, maxref = 0; x < 7; x++) { - if (deempcnt[x] > max) { - max = deempcnt[x]; - maxref = x; - } - deempcnt[x] = 0; - } - SetNESDeemph(maxref, 0); - } - } //else... to if(ppudead) - - #ifdef FRAMESKIP - if (skip) { - FCEU_PutImageDummy(); - return(0); - } else - #endif - { - FCEU_PutImage(); - return(1); - } -} - -int (*PPU_MASTER)(int skip) = FCEUPPU_Loop; - -static uint16 TempAddrT, RefreshAddrT; - -void FCEUPPU_LoadState(int version) { - TempAddr = TempAddrT; - RefreshAddr = RefreshAddrT; -} - -SFORMAT FCEUPPU_STATEINFO[] = { - { NTARAM, 0x800, "NTAR" }, - { PALRAM, 0x20, "PRAM" }, - { SPRAM, 0x100, "SPRA" }, - { PPU, 0x4, "PPUR" }, - { &kook, 1, "KOOK" }, - { &ppudead, 1, "DEAD" }, - { &PPUSPL, 1, "PSPL" }, - { &XOffset, 1, "XOFF" }, - { &vtoggle, 1, "VTGL" }, - { &RefreshAddrT, 2 | FCEUSTATE_RLSB, "RADD" }, - { &TempAddrT, 2 | FCEUSTATE_RLSB, "TADD" }, - { &VRAMBuffer, 1, "VBUF" }, - { &PPUGenLatch, 1, "PGEN" }, - { 0 } -}; - -SFORMAT FCEU_NEWPPU_STATEINFO[] = { - { &idleSynch, 1, "IDLS" }, - { &spr_read.num, 4 | FCEUSTATE_RLSB, "SR_0" }, - { &spr_read.count, 4 | FCEUSTATE_RLSB, "SR_1" }, - { &spr_read.fetch, 4 | FCEUSTATE_RLSB, "SR_2" }, - { &spr_read.found, 4 | FCEUSTATE_RLSB, "SR_3" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx0" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx1" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx2" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx3" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx4" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx5" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx6" }, - { &spr_read.found_pos[0], 4 | FCEUSTATE_RLSB, "SRx7" }, - { &spr_read.ret, 4 | FCEUSTATE_RLSB, "SR_4" }, - { &spr_read.last, 4 | FCEUSTATE_RLSB, "SR_5" }, - { &spr_read.mode, 4 | FCEUSTATE_RLSB, "SR_6" }, - { &ppur.fv, 4 | FCEUSTATE_RLSB, "PFVx" }, - { &ppur.v, 4 | FCEUSTATE_RLSB, "PVxx" }, - { &ppur.h, 4 | FCEUSTATE_RLSB, "PHxx" }, - { &ppur.vt, 4 | FCEUSTATE_RLSB, "PVTx" }, - { &ppur.ht, 4 | FCEUSTATE_RLSB, "PHTx" }, - { &ppur._fv, 4 | FCEUSTATE_RLSB, "P_FV" }, - { &ppur._v, 4 | FCEUSTATE_RLSB, "P_Vx" }, - { &ppur._h, 4 | FCEUSTATE_RLSB, "P_Hx" }, - { &ppur._vt, 4 | FCEUSTATE_RLSB, "P_VT" }, - { &ppur._ht, 4 | FCEUSTATE_RLSB, "P_HT" }, - { &ppur.fh, 4 | FCEUSTATE_RLSB, "PFHx" }, - { &ppur.s, 4 | FCEUSTATE_RLSB, "PSxx" }, - { &ppur.status.sl, 4 | FCEUSTATE_RLSB, "PST0" }, - { &ppur.status.cycle, 4 | FCEUSTATE_RLSB, "PST1" }, - { &ppur.status.end_cycle, 4 | FCEUSTATE_RLSB, "PST2" }, - { 0 } -}; - -void FCEUPPU_SaveState(void) { - TempAddrT = TempAddr; - RefreshAddrT = RefreshAddr; -} - - -//--------------------- -int pputime = 0; -int totpputime = 0; -const int kLineTime = 341; -const int kFetchTime = 2; - -void runppu(int x) { - ppur.status.cycle = (ppur.status.cycle + x) % ppur.status.end_cycle; - X6502_Run(x); -} - -//todo - consider making this a 3 or 4 slot fifo to keep from touching so much memory -struct BGData { - struct Record { - uint8 nt, pecnt, at, pt[2]; - - INLINE void Read() { - RefreshAddr = ppur.get_ntread(); - if (PEC586Hack) - ppur.s = (RefreshAddr & 0x200) >> 9; - pecnt = (RefreshAddr & 1) << 3; - nt = CALL_PPUREAD(RefreshAddr); - runppu(kFetchTime); - - RefreshAddr = ppur.get_atread(); - at = CALL_PPUREAD(RefreshAddr); - - //modify at to get appropriate palette shift - if (ppur.vt & 2) at >>= 4; - if (ppur.ht & 2) at >>= 2; - at &= 0x03; - at <<= 2; - //horizontal scroll clocked at cycle 3 and then - //vertical scroll at 251 - runppu(1); - if (PPUON) { - ppur.increment_hsc(); - if (ppur.status.cycle == 251) - ppur.increment_vs(); - } - runppu(1); - - ppur.par = nt; - RefreshAddr = ppur.get_ptread(); - if (PEC586Hack) { - if (ScreenON) - RENDER_LOG(RefreshAddr | pecnt); - pt[0] = CALL_PPUREAD(RefreshAddr | pecnt); - runppu(kFetchTime); - pt[1] = CALL_PPUREAD(RefreshAddr | pecnt); - runppu(kFetchTime); - } else { - if (ScreenON) - RENDER_LOG(RefreshAddr); - pt[0] = CALL_PPUREAD(RefreshAddr); - runppu(kFetchTime); - RefreshAddr |= 8; - if (ScreenON) - RENDER_LOG(RefreshAddr); - pt[1] = CALL_PPUREAD(RefreshAddr); - runppu(kFetchTime); - } - } - }; - - Record main[34]; //one at the end is junk, it can never be rendered -} bgdata; - -static inline int PaletteAdjustPixel(int pixel) { - if ((PPU[1] >> 5) == 0x7) - return (pixel & 0x3f) | 0xc0; - else if (PPU[1] & 0xE0) - return pixel | 0x40; - else - return (pixel & 0x3F) | 0x80; -} - -int framectr = 0; -int FCEUX_PPU_Loop(int skip) { - //262 scanlines - if (ppudead) { - // not quite emulating all the NES power up behavior - // since it is known that the NES ignores writes to some - // register before around a full frame, but no games - // should write to those regs during that time, it needs - // to wait for vblank - ppur.status.sl = 241; - if (PAL) - runppu(70 * kLineTime); - else - runppu(20 * kLineTime); - ppur.status.sl = 0; - runppu(242 * kLineTime); - --ppudead; - goto finish; - } - - { - PPU_status |= 0x80; - ppuphase = PPUPHASE_VBL; - - //Not sure if this is correct. According to Matt Conte and my own tests, it is. - //Timing is probably off, though. - //NOTE: Not having this here breaks a Super Donkey Kong game. - PPU[3] = PPUSPL = 0; - const int delay = 20; //fceu used 12 here but I couldnt get it to work in marble madness and pirates. - - ppur.status.sl = 241; //for sprite reads - - runppu(delay); //X6502_Run(12); - if (VBlankON) TriggerNMI(); - if (PAL) - runppu(70 * (kLineTime) - delay); - else - runppu(20 * (kLineTime) - delay); - - //this seems to run just before the dummy scanline begins - PPU_status = 0; - //this early out caused metroid to fail to boot. I am leaving it here as a reminder of what not to do - //if(!PPUON) { runppu(kLineTime*242); goto finish; } - - //There are 2 conditions that update all 5 PPU scroll counters with the - //contents of the latches adjacent to them. The first is after a write to - //2006/2. The second, is at the beginning of scanline 20, when the PPU starts - //rendering data for the first time in a frame (this update won't happen if - //all rendering is disabled via 2001.3 and 2001.4). - - //if(PPUON) - // ppur.install_latches(); - - static uint8 oams[2][64][8];//[7] turned to [8] for faster indexing - static int oamcounts[2] = { 0, 0 }; - static int oamslot = 0; - static int oamcount; - - //capture the initial xscroll - //int xscroll = ppur.fh; - //render 241 scanlines (including 1 dummy at beginning) - for (int sl = 0; sl < 241; sl++) { - spr_read.start_scanline(); - - g_rasterpos = 0; - ppur.status.sl = sl; - - const int yp = sl - 1; - ppuphase = PPUPHASE_BG; - - if (sl != 0) { - DEBUG(FCEUD_UpdatePPUView(scanline = yp, 1)); - DEBUG(FCEUD_UpdateNTView(scanline = yp, 1)); - } - - if (sl != 0) if (MMC5Hack && PPUON) MMC5_hb(yp); - - - //twiddle the oam buffers - const int scanslot = oamslot ^ 1; - const int renderslot = oamslot; - oamslot ^= 1; - - oamcount = oamcounts[renderslot]; - - //the main scanline rendering loop: - //32 times, we will fetch a tile and then render 8 pixels. - //two of those tiles were read in the last scanline. - for (int xt = 0; xt < 32; xt++) { - bgdata.main[xt + 2].Read(); - - //ok, we're also going to draw here. - //unless we're on the first dummy scanline - if (sl != 0) { - int xstart = xt << 3; - oamcount = oamcounts[renderslot]; - uint8 * const target = XBuf + (yp << 8) + xstart; - uint8 *ptr = target; - int rasterpos = xstart; - - //check all the conditions that can cause things to render in these 8px - const bool renderspritenow = SpriteON && rendersprites && (xt > 0 || SpriteLeft8); - const bool renderbgnow = ScreenON && renderbg && (xt > 0 || BGLeft8); - for (int xp = 0; xp < 8; xp++, rasterpos++, g_rasterpos++) { - //bg pos is different from raster pos due to its offsetability. - //so adjust for that here - const int bgpos = rasterpos + ppur.fh; - const int bgpx = bgpos & 7; - const int bgtile = bgpos >> 3; - - uint8 pixel = 0, pixelcolor; - - //generate the BG data - if (renderbgnow) { - uint8* pt = bgdata.main[bgtile].pt; - pixel = ((pt[0] >> (7 - bgpx)) & 1) | (((pt[1] >> (7 - bgpx)) & 1) << 1) | bgdata.main[bgtile].at; - } - pixelcolor = PALRAM[pixel]; - - //look for a sprite to be drawn - bool havepixel = false; - for (int s = 0; s < oamcount; s++) { - uint8* oam = oams[renderslot][s]; - int x = oam[3]; - if (rasterpos >= x && rasterpos < x + 8) { - //build the pixel. - //fetch the LSB of the patterns - uint8 spixel = oam[4] & 1; - spixel |= (oam[5] & 1) << 1; - - //shift down the patterns so the next pixel is in the LSB - oam[4] >>= 1; - oam[5] >>= 1; - - if (!renderspritenow) continue; - - //bail out if we already have a pixel from a higher priority sprite - if (havepixel) continue; - - //transparent pixel bailout - if (spixel == 0) continue; - - //spritehit: - //1. is it sprite#0? - //2. is the bg pixel nonzero? - //then, it is spritehit. - if (oam[6] == 0 && (pixel & 3) != 0 && - rasterpos < 255) { - PPU_status |= 0x40; - } - havepixel = true; - - //priority handling - if (oam[2] & 0x20) { - //behind background: - if ((pixel & 3) != 0) continue; - } - - //bring in the palette bits and palettize - spixel |= (oam[2] & 3) << 2; - pixelcolor = PALRAM[0x10 + spixel]; - } - } - - *ptr++ = PaletteAdjustPixel(pixelcolor); - } - } - } - - //look for sprites (was supposed to run concurrent with bg rendering) - oamcounts[scanslot] = 0; - oamcount = 0; - const int spriteHeight = Sprite16 ? 16 : 8; - for (int i = 0; i < 64; i++) { - oams[scanslot][oamcount][7] = 0; - uint8* spr = SPRAM + i * 4; - if (yp >= spr[0] && yp < spr[0] + spriteHeight) { - //if we already have maxsprites, then this new one causes an overflow, - //set the flag and bail out. - if (oamcount >= 8 && PPUON) { - PPU_status |= 0x20; - if (maxsprites == 8) - break; - } - - //just copy some bytes into the internal sprite buffer - for (int j = 0; j < 4; j++) - oams[scanslot][oamcount][j] = spr[j]; - oams[scanslot][oamcount][7] = 1; - - //note that we stuff the oam index into [6]. - //i need to turn this into a struct so we can have fewer magic numbers - oams[scanslot][oamcount][6] = (uint8)i; - oamcount++; - } - } - oamcounts[scanslot] = oamcount; - - //FV is clocked by the PPU's horizontal blanking impulse, and therefore will increment every scanline. - //well, according to (which?) tests, maybe at the end of hblank. - //but, according to what it took to get crystalis working, it is at the beginning of hblank. - - //this is done at cycle 251 - //rendering scanline, it doesn't need to be scanline 0, - //because on the first scanline when the increment is 0, the vs_scroll is reloaded. - //if(PPUON && sl != 0) - // ppur.increment_vs(); - - //todo - think about clearing oams to a predefined value to force deterministic behavior - - ppuphase = PPUPHASE_OBJ; - - //fetch sprite patterns - for (int s = 0; s < maxsprites; s++) { - //if we have hit our eight sprite pattern and we dont have any more sprites, then bail - if (s == oamcount && s >= 8) - break; - - //if this is a real sprite sprite, then it is not above the 8 sprite limit. - //this is how we support the no 8 sprite limit feature. - //not that at some point we may need a virtual CALL_PPUREAD which just peeks and doesnt increment any counters - //this could be handy for the debugging tools also - const bool realSprite = (s < 8); - - uint8* const oam = oams[scanslot][s]; - uint32 line = yp - oam[0]; - if (oam[2] & 0x80) //vflip - line = spriteHeight - line - 1; - - uint32 patternNumber = oam[1]; - uint32 patternAddress; - - //create deterministic dummy fetch pattern - if (!oam[7]) { - patternNumber = 0; - line = 0; - } - - //8x16 sprite handling: - if (Sprite16) { - uint32 bank = (patternNumber & 1) << 12; - patternNumber = patternNumber & ~1; - patternNumber |= (line >> 3); - patternAddress = (patternNumber << 4) | bank; - } else { - patternAddress = (patternNumber << 4) | (SpAdrHI << 9); - } - - //offset into the pattern for the current line. - //tricky: tall sprites have already had lines>8 taken care of by getting a new pattern number above. - //so we just need the line offset for the second pattern - patternAddress += line & 7; - - //garbage nametable fetches - int garbage_todo = 2; - if (PPUON) - { - if (sl == 0 && ppur.status.cycle == 304) - { - runppu(1); - if (PPUON) ppur.install_latches(); - runppu(1); - garbage_todo = 0; - } - if ((sl != 0) && ppur.status.cycle == 256) - { - runppu(1); - //at 257: 3d world runner is ugly if we do this at 256 - if (PPUON) ppur.install_h_latches(); - runppu(1); - garbage_todo = 0; - } - } - if (realSprite) runppu(garbage_todo); - - //Dragon's Lair (Europe version mapper 4) - //does not set SpriteON in the beginning but it does - //set the bg on so if using the conditional SpriteON the MMC3 counter - //the counter will never count and no IRQs will be fired so use PPUON - if (((PPU[0] & 0x38) != 0x18) && s == 2 && PPUON) { - //(The MMC3 scanline counter is based entirely on PPU A12, triggered on rising edges (after the line remains low for a sufficiently long period of time)) - //http://nesdevwiki.org/wiki/index.php/Nintendo_MMC3 - //test cases for timing: SMB3, Crystalis - //crystalis requires deferring this til somewhere in sprite [1,3] - //kirby requires deferring this til somewhere in sprite [2,5.. - //if (PPUON && GameHBIRQHook) { - if (GameHBIRQHook) { - GameHBIRQHook(); - } - } - - if (realSprite) runppu(kFetchTime); - - - //pattern table fetches - RefreshAddr = patternAddress; - if (SpriteON) - RENDER_LOG(RefreshAddr); - oam[4] = CALL_PPUREAD(RefreshAddr); - if (realSprite) runppu(kFetchTime); - - RefreshAddr += 8; - if (SpriteON) - RENDER_LOG(RefreshAddr); - oam[5] = CALL_PPUREAD(RefreshAddr); - if (realSprite) runppu(kFetchTime); - - //hflip - if (!(oam[2] & 0x40)) { - oam[4] = bitrevlut[oam[4]]; - oam[5] = bitrevlut[oam[5]]; - } - } - - ppuphase = PPUPHASE_BG; - - //fetch BG: two tiles for next line - for (int xt = 0; xt < 2; xt++) - bgdata.main[xt].Read(); - - //I'm unclear of the reason why this particular access to memory is made. - //The nametable address that is accessed 2 times in a row here, is also the - //same nametable address that points to the 3rd tile to be rendered on the - //screen (or basically, the first nametable address that will be accessed when - //the PPU is fetching background data on the next scanline). - //(not implemented yet) - runppu(kFetchTime); - if (sl == 0) { - if (idleSynch && PPUON && !PAL) - ppur.status.end_cycle = 340; - else - ppur.status.end_cycle = 341; - idleSynch ^= 1; - } else - ppur.status.end_cycle = 341; - runppu(kFetchTime); - - //After memory access 170, the PPU simply rests for 4 cycles (or the - //equivelant of half a memory access cycle) before repeating the whole - //pixel/scanline rendering process. If the scanline being rendered is the very - //first one on every second frame, then this delay simply doesn't exist. - if (ppur.status.end_cycle == 341) - runppu(1); - } //scanline loop - - if (MMC5Hack && PPUON) MMC5_hb(240); - - //idle for one line - runppu(kLineTime); - framectr++; - } - -finish: - FCEU_PutImage(); - - return 0; -} diff --git a/branches/fceux-2.2.2/src/ppu.h b/branches/fceux-2.2.2/src/ppu.h deleted file mode 100644 index 9b047064..00000000 --- a/branches/fceux-2.2.2/src/ppu.h +++ /dev/null @@ -1,43 +0,0 @@ -void FCEUPPU_Init(void); -void FCEUPPU_Reset(void); -void FCEUPPU_Power(void); -int FCEUPPU_Loop(int skip); - -void FCEUPPU_LineUpdate(); -void FCEUPPU_SetVideoSystem(int w); - -extern void (*PPU_hook)(uint32 A); -extern void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void); - -/* For cart.c and banksw.h, mostly */ -extern uint8 NTARAM[0x800], *vnapage[4]; -extern uint8 PPUNTARAM; -extern uint8 PPUCHRRAM; - -void FCEUPPU_SaveState(void); -void FCEUPPU_LoadState(int version); -uint8* FCEUPPU_GetCHR(uint32 vadr, uint32 refreshaddr); -void ppu_getScroll(int &xpos, int &ypos); - - -#ifdef _MSC_VER -#define FASTCALL __fastcall -#else -#define FASTCALL -#endif - -void PPU_ResetHooks(); -extern uint8 (FASTCALL *FFCEUX_PPURead)(uint32 A); -extern void (*FFCEUX_PPUWrite)(uint32 A, uint8 V); -extern uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A); -void FFCEUX_PPUWrite_Default(uint32 A, uint8 V); - -extern int scanline; -extern int g_rasterpos; -extern uint8 PPU[4]; - -enum PPUPHASE { - PPUPHASE_VBL, PPUPHASE_BG, PPUPHASE_OBJ -}; - -extern PPUPHASE ppuphase; diff --git a/branches/fceux-2.2.2/src/pputile.inc b/branches/fceux-2.2.2/src/pputile.inc deleted file mode 100644 index b935a7ff..00000000 --- a/branches/fceux-2.2.2/src/pputile.inc +++ /dev/null @@ -1,118 +0,0 @@ -uint8 *C; -register uint8 cc; -uint32 vadr; - -#ifndef PPUT_MMC5SP - register uint8 zz; -#else - uint8 xs, ys; - xs = X1; - ys = ((scanline >> 3) + MMC5HackSPScroll) & 0x1F; - if (ys >= 0x1E) ys -= 0x1E; -#endif - -if (X1 >= 2) { - uint8 *S = PALRAM; - uint32 pixdata; - - pixdata = ppulut1[(pshift[0] >> (8 - XOffset)) & 0xFF] | ppulut2[(pshift[1] >> (8 - XOffset)) & 0xFF]; - - pixdata |= ppulut3[XOffset | (atlatch << 3)]; - - P[0] = S[pixdata & 0xF]; - pixdata >>= 4; - P[1] = S[pixdata & 0xF]; - pixdata >>= 4; - P[2] = S[pixdata & 0xF]; - pixdata >>= 4; - P[3] = S[pixdata & 0xF]; - pixdata >>= 4; - P[4] = S[pixdata & 0xF]; - pixdata >>= 4; - P[5] = S[pixdata & 0xF]; - pixdata >>= 4; - P[6] = S[pixdata & 0xF]; - pixdata >>= 4; - P[7] = S[pixdata & 0xF]; - P += 8; -} - -#ifdef PPUT_MMC5SP - vadr = (MMC5HackExNTARAMPtr[xs | (ys << 5)] << 4) + (vofs & 7); -#else - zz = RefreshAddr & 0x1F; - C = vnapage[(RefreshAddr >> 10) & 3]; - vadr = (C[RefreshAddr & 0x3ff] << 4) + vofs; // Fetch name table byte. -#endif - -#ifdef PPUT_HOOK - PPU_hook(0x2000 | (RefreshAddr & 0xfff)); -#endif - -#ifdef PPUT_MMC5SP - cc = MMC5HackExNTARAMPtr[0x3c0 + (xs >> 2) + ((ys & 0x1C) << 1)]; - cc = ((cc >> ((xs & 2) + ((ys & 0x2) << 1))) & 3); -#else - #ifdef PPUT_MMC5CHR1 - cc = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0) >> 6; - #else - cc = C[0x3c0 + (zz >> 2) + ((RefreshAddr & 0x380) >> 4)]; // Fetch attribute table byte. - cc = ((cc >> ((zz & 2) + ((RefreshAddr & 0x40) >> 4))) & 3); - #endif -#endif - -atlatch >>= 2; -atlatch |= cc << 2; - -pshift[0] <<= 8; -pshift[1] <<= 8; - -#ifdef PPUT_MMC5SP - C = MMC5HackVROMPTR + vadr; - C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12); -#else - #ifdef PPUT_MMC5CHR1 - C = MMC5HackVROMPTR; - C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f & MMC5HackVROMMask) << 12) + (vadr & 0xfff); - C += (MMC50x5130 & 0x3) << 18; //11-jun-2009 for kuja_killer - #elif defined(PPUT_MMC5) - C = MMC5BGVRAMADR(vadr); - #else - C = VRAMADR(vadr); - #endif -#endif - -#ifdef PPUT_HOOK - PPU_hook(vadr); -#endif - -#ifdef PPU_BGFETCH - if (RefreshAddr & 1) { - if(ScreenON) - RENDER_LOG(vadr + 8); - pshift[0] |= C[8]; - pshift[1] |= C[8]; - } else { - if(ScreenON) - RENDER_LOG(vadr); - pshift[0] |= C[0]; - pshift[1] |= C[0]; - } -#else - if(ScreenON) - RENDER_LOG(vadr); - pshift[0] |= C[0]; - if(ScreenON) - RENDER_LOG(vadr + 8); - pshift[1] |= C[8]; -#endif - -if ((RefreshAddr & 0x1f) == 0x1f) - RefreshAddr ^= 0x41F; -else - RefreshAddr++; - -#ifdef PPUT_HOOK - PPU_hook(0x2000 | (RefreshAddr & 0xfff)); -#endif - diff --git a/branches/fceux-2.2.2/src/sound.cpp b/branches/fceux-2.2.2/src/sound.cpp deleted file mode 100644 index 4cb74eb1..00000000 --- a/branches/fceux-2.2.2/src/sound.cpp +++ /dev/null @@ -1,1384 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "types.h" -#include "x6502.h" - -#include "fceu.h" -#include "sound.h" -#include "filter.h" -#include "state.h" -#include "wave.h" -#include "debug.h" - -#include -#include -#include - -static uint32 wlookup1[32]; -static uint32 wlookup2[203]; - -int32 Wave[2048+512]; -int32 WaveHi[40000]; -int32 WaveFinal[2048+512]; - -EXPSOUND GameExpSound={0,0,0}; - -/*static*/ uint8 TriCount=0; -static uint8 TriMode=0; - -static int32 tristep=0; - -static int32 wlcount[4]={0,0,0,0}; /* Wave length counters. */ - -static uint8 IRQFrameMode=0; /* $4017 / xx000000 */ -/*static*/ uint8 PSG[0x10]; -static uint8 RawDALatch=0; /* $4011 0xxxxxxx */ -/*static*/ uint8 InitialRawDALatch=0; // used only for lua - -uint8 EnabledChannels=0; /* Byte written to $4015 */ - -/*static*/ ENVUNIT EnvUnits[3]; - -static const int RectDuties[4]={1,2,4,6}; - -static int32 RectDutyCount[2]; -static uint8 sweepon[2]; -/*static*/ int32 curfreq[2]; -static uint8 SweepCount[2]; - -static uint16 nreg=0; - -static uint8 fcnt=0; -static int32 fhcnt=0; -static int32 fhinc=0; - -uint32 soundtsoffs=0; - -/* Variables exclusively for low-quality sound. */ -int32 nesincsize=0; -uint32 soundtsinc=0; -uint32 soundtsi=0; -static int32 sqacc[2]; -/* LQ variables segment ends. */ - -/*static*/ int32 lengthcount[4]; -static const uint8 lengthtable[0x20]= -{ - 10,254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, - 12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30 -}; - - -static const uint32 NoiseFreqTableNTSC[0x10] = -{ - 4, 8, 16, 32, 64, 96, 128, 160, 202, - 254, 380, 508, 762, 1016, 2034, 4068 -}; - -static const uint32 NoiseFreqTablePAL[0x10] = -{ - 4, 7, 14, 30, 60, 88, 118, 148, 188, - 236, 354, 472, 708, 944, 1890, 3778 -}; - -const uint32 *NoiseFreqTable = NoiseFreqTableNTSC; // for lua only - -static const uint32 NTSCDMCTable[0x10]= -{ - 428,380,340,320,286,254,226,214, - 190,160,142,128,106, 84 ,72,54 -}; - -/* Previous values for PAL DMC was value - 1, - * I am not certain if this is if FCEU handled - * PAL differently or not, the NTSC values are right, - * so I am assuming that the current value is handled - * the same way NTSC is handled. */ - -static const uint32 PALDMCTable[0x10]= -{ - 398, 354, 316, 298, 276, 236, 210, 198, - 176, 148, 132, 118, 98, 78, 66, 50 -}; - -// $4010 - Frequency -// $4011 - Actual data outputted -// $4012 - Address register: $c000 + V*64 -// $4013 - Size register: Size in bytes = (V+1)*64 - -/*static*/ int32 DMCacc=1; -/*static*/ int32 DMCPeriod=0; -/*static*/ uint8 DMCBitCount=0; - -/*static*/ uint8 DMCAddressLatch=0,DMCSizeLatch=0; /* writes to 4012 and 4013 */ -/*static*/ uint8 DMCFormat=0; /* Write to $4010 */ - -static uint32 DMCAddress=0; -static int32 DMCSize=0; -static uint8 DMCShift=0; -static uint8 SIRQStat=0; - -static char DMCHaveDMA=0; -static uint8 DMCDMABuf=0; -/*static*/ char DMCHaveSample=0; - -static void Dummyfunc(void) {}; -static void (*DoNoise)(void)=Dummyfunc; -static void (*DoTriangle)(void)=Dummyfunc; -static void (*DoPCM)(void)=Dummyfunc; -static void (*DoSQ1)(void)=Dummyfunc; -static void (*DoSQ2)(void)=Dummyfunc; - -static uint32 ChannelBC[5]; - -//savestate sync hack stuff -int movieSyncHackOn=0,resetDMCacc=0,movieConvertOffset1,movieConvertOffset2; - -#ifdef WIN32 -extern volatile int datacount, undefinedcount; -extern int debug_loggingCD; -extern unsigned char *cdloggerdata; -#endif - -static void LoadDMCPeriod(uint8 V) -{ - if(PAL) - DMCPeriod=PALDMCTable[V]; - else - DMCPeriod=NTSCDMCTable[V]; -} - -static void PrepDPCM() -{ - DMCAddress=0x4000+(DMCAddressLatch<<6); - DMCSize=(DMCSizeLatch<<4)+1; - - #ifdef WIN32 - if(debug_loggingCD)LogDPCM(0x8000+DMCAddress, DMCSize); - #endif - -} - -void LogDPCM(int romaddress, int dpcmsize){ - int i = GetPRGAddress(romaddress); - - if(i == -1)return; - - for (int dpcmstart = i; dpcmstart < (i + dpcmsize); dpcmstart++) { - if(!(cdloggerdata[dpcmstart] & 0x40)) { - cdloggerdata[dpcmstart] |= 0x40; - - if(!(cdloggerdata[dpcmstart] & 2)){ - datacount++; - cdloggerdata[dpcmstart] |= 2; - if(!(cdloggerdata[dpcmstart] & 1))undefinedcount--; - } - } - } -} - -/* Instantaneous? Maybe the new freq value is being calculated all of the time... */ - -/*static*/ int CheckFreq(uint32 cf, uint8 sr) -{ - uint32 mod; - if(!(sr&0x8)) - { - mod=cf>>(sr&7); - if((mod+cf)&0x800) - return(0); - } - return(1); -} - -static void SQReload(int x, uint8 V) -{ - if(EnabledChannels&(1<>3)&0x1f]; - } - - sweepon[x]=PSG[(x<<2)|1]&0x80; - curfreq[x]=PSG[(x<<2)|0x2]|((V&7)<<8); - SweepCount[x]=((PSG[(x<<2)|0x1]>>4)&7)+1; - - RectDutyCount[x]=7; - EnvUnits[x].reloaddec=1; - //reloadfreq[x]=1; -} - -static DECLFW(Write_PSG) -{ - A&=0x1F; - switch(A) - { - case 0x0:DoSQ1(); - EnvUnits[0].Mode=(V&0x30)>>4; - EnvUnits[0].Speed=(V&0xF); - break; - case 0x1: - sweepon[0]=V&0x80; - break; - case 0x2: - DoSQ1(); - curfreq[0]&=0xFF00; - curfreq[0]|=V; - break; - case 0x3: - SQReload(0,V); - break; - case 0x4: - DoSQ2(); - EnvUnits[1].Mode=(V&0x30)>>4; - EnvUnits[1].Speed=(V&0xF); - break; - case 0x5: - sweepon[1]=V&0x80; - break; - case 0x6:DoSQ2(); - curfreq[1]&=0xFF00; - curfreq[1]|=V; - break; - case 0x7: - SQReload(1,V); - break; - case 0xa:DoTriangle(); - break; - case 0xb: - DoTriangle(); - if(EnabledChannels&0x4) - lengthcount[2]=lengthtable[(V>>3)&0x1f]; - TriMode=1; // Load mode - break; - case 0xC:DoNoise(); - EnvUnits[2].Mode=(V&0x30)>>4; - EnvUnits[2].Speed=(V&0xF); - break; - case 0xE:DoNoise(); - break; - case 0xF: - DoNoise(); - if(EnabledChannels&0x8) - lengthcount[3]=lengthtable[(V>>3)&0x1f]; - EnvUnits[2].reloaddec=1; - break; - case 0x10:DoPCM(); - LoadDMCPeriod(V&0xF); - - if(SIRQStat&0x80) - { - if(!(V&0x80)) - { - X6502_IRQEnd(FCEU_IQDPCM); - SIRQStat&=~0x80; - } - else X6502_IRQBegin(FCEU_IQDPCM); - } - break; - } - PSG[A]=V; -} - -static DECLFW(Write_DMCRegs) -{ - A&=0xF; - - switch(A) - { - case 0x00:DoPCM(); - LoadDMCPeriod(V&0xF); - - if(SIRQStat&0x80) - { - if(!(V&0x80)) - { - X6502_IRQEnd(FCEU_IQDPCM); - SIRQStat&=~0x80; - } - else X6502_IRQBegin(FCEU_IQDPCM); - } - DMCFormat=V; - break; - case 0x01:DoPCM(); - InitialRawDALatch=V&0x7F; - RawDALatch=InitialRawDALatch; - break; - case 0x02:DMCAddressLatch=V;break; - case 0x03:DMCSizeLatch=V;break; - } - - -} - -static DECLFW(StatusWrite) -{ - int x; - - DoSQ1(); - DoSQ2(); - DoTriangle(); - DoNoise(); - DoPCM(); - for(x=0;x<4;x++) - if(!(V&(1<0) - lengthcount[2]--; - - if(!(PSG[0xC]&0x20)) /* Make sure loop flag is not set. */ - if(lengthcount[3]>0) - lengthcount[3]--; - - for(P=0;P<2;P++) - { - if(!(PSG[P<<2]&0x20)) /* Make sure loop flag is not set. */ - if(lengthcount[P]>0) - lengthcount[P]--; - - /* Frequency Sweep Code Here */ - /* xxxx 0000 */ - /* xxxx = hz. 120/(x+1)*/ - if(sweepon[P]) - { - int32 mod=0; - - if(SweepCount[P]>0) SweepCount[P]--; - if(SweepCount[P]<=0) - { - SweepCount[P]=((PSG[(P<<2)+0x1]>>4)&7)+1; //+1; - if(PSG[(P<<2)+0x1]&0x8) - { - mod-=(P^1)+((curfreq[P])>>(PSG[(P<<2)+0x1]&7)); - if(curfreq[P] && (PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/) - { - curfreq[P]+=mod; - } - } - else - { - mod=curfreq[P]>>(PSG[(P<<2)+0x1]&7); - if((mod+curfreq[P])&0x800) - { - sweepon[P]=0; - curfreq[P]=0; - } - else - { - if(curfreq[P] && (PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/) - { - curfreq[P]+=mod; - } - } - } - } - } - else /* Sweeping is disabled: */ - { - //curfreq[P]&=0xFF00; - //curfreq[P]|=PSG[(P<<2)|0x2]; //|((PSG[(P<<2)|3]&7)<<8); - } - } - } - - /* Now do envelope decay + linear counter. */ - - if(TriMode) // In load mode? - TriCount=PSG[0x8]&0x7F; - else if(TriCount) - TriCount--; - - if(!(PSG[0x8]&0x80)) - TriMode=0; - - for(P=0;P<3;P++) - { - if(EnvUnits[P].reloaddec) - { - EnvUnits[P].decvolume=0xF; - EnvUnits[P].DecCountTo1=EnvUnits[P].Speed+1; - EnvUnits[P].reloaddec=0; - continue; - } - - if(EnvUnits[P].DecCountTo1>0) EnvUnits[P].DecCountTo1--; - if(EnvUnits[P].DecCountTo1==0) - { - EnvUnits[P].DecCountTo1=EnvUnits[P].Speed+1; - if(EnvUnits[P].decvolume || (EnvUnits[P].Mode&0x2)) - { - EnvUnits[P].decvolume--; - EnvUnits[P].decvolume&=0xF; - } - } - } -} - -void FrameSoundUpdate(void) -{ - // Linear counter: Bit 0-6 of $4008 - // Length counter: Bit 4-7 of $4003, $4007, $400b, $400f - - if(!fcnt && !(IRQFrameMode&0x3)) - { - SIRQStat|=0x40; - X6502_IRQBegin(FCEU_IQFCOUNT); - } - - if(fcnt==3) - { - if(IRQFrameMode&0x2) - fhcnt+=fhinc; - } - FrameSoundStuff(fcnt); - fcnt=(fcnt+1)&3; -} - - -static INLINE void tester(void) -{ - if(DMCBitCount==0) - { - if(!DMCHaveDMA) - DMCHaveSample=0; - else - { - DMCHaveSample=1; - DMCShift=DMCDMABuf; - DMCHaveDMA=0; - } - } -} - -static INLINE void DMCDMA(void) -{ - if(DMCSize && !DMCHaveDMA) - { - X6502_DMR(0x8000+DMCAddress); - X6502_DMR(0x8000+DMCAddress); - X6502_DMR(0x8000+DMCAddress); - DMCDMABuf=X6502_DMR(0x8000+DMCAddress); - DMCHaveDMA=1; - DMCAddress=(DMCAddress+1)&0x7fff; - DMCSize--; - if(!DMCSize) - { - if(DMCFormat&0x40) - PrepDPCM(); - else - { - SIRQStat|=0x80; - if(DMCFormat&0x80) - X6502_IRQBegin(FCEU_IQDPCM); - } - } - } -} - -void FCEU_SoundCPUHook(int cycles) -{ -fhcnt-=cycles*48; - if(fhcnt<=0) - { - FrameSoundUpdate(); - fhcnt+=fhinc; - } - - DMCDMA(); - DMCacc-=cycles; - - while(DMCacc<=0) - { - if(DMCHaveSample) - { - uint8 bah=RawDALatch; - int t=((DMCShift&1)<<2)-2; - - /* Unbelievably ugly hack */ - if(FSettings.SndRate) - { - soundtsoffs+=DMCacc; - DoPCM(); - soundtsoffs-=DMCacc; - } - RawDALatch+=t; - if(RawDALatch&0x80) - RawDALatch=bah; - } - - DMCacc+=DMCPeriod; - DMCBitCount=(DMCBitCount+1)&7; - DMCShift>>=1; - tester(); - } -} - -void RDoPCM(void) -{ - uint32 V; //mbg merge 7/17/06 made uint32 - - for(V=ChannelBC[4];V0x7ff) - goto endit; - if(!CheckFreq(curfreq[x],PSG[(x<<2)|0x1])) - goto endit; - if(!lengthcount[x]) - goto endit; - - if(EnvUnits[x].Mode&0x1) - amp=EnvUnits[x].Speed; - else - amp=EnvUnits[x].decvolume; //Set the volume of the Square Wave - - //Modify Square wave volume based on channel volume modifiers - //adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here) - ampx = x ? FSettings.Square2Volume : FSettings.Square1Volume; // TODO OPTIMIZE ME! - if (ampx != 256) amp = (amp * ampx) / 256; // CaH4e3: fixed - setting up maximum volume for square2 caused complete mute square2 channel - - amp<<=24; - - rthresh=RectDuties[(PSG[(x<<2)]&0xC0)>>6]; - - D=&WaveHi[ChannelBC[x]]; - V=SOUNDTS-ChannelBC[x]; - - currdc=RectDutyCount[x]; - cf=(curfreq[x]+1)*2; - rc=wlcount[x]; - - while(V>0) - { - if(currdc0x7ff) - inie[x]=0; - if(!CheckFreq(curfreq[x],PSG[(x<<2)|0x1])) - inie[x]=0; - if(!lengthcount[x]) - inie[x]=0; - - if(EnvUnits[x].Mode&0x1) - amp[x]=EnvUnits[x].Speed; - else - amp[x]=EnvUnits[x].decvolume; - - //Modify Square wave volume based on channel volume modifiers - //adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here) - ampx = x ? FSettings.Square1Volume : FSettings.Square2Volume; // TODO OPTIMIZE ME! - if (ampx != 256) amp[x] = (amp[x] * ampx) / 256; // CaH4e3: fixed - setting up maximum volume for square2 caused complete mute square2 channel - - if(!inie[x]) amp[x]=0; /* Correct? Buzzing in MM2, others otherwise... */ - - rthresh[x]=RectDuties[(PSG[x*4]&0xC0)>>6]; - - for(y=0;y<8;y++) - { - if(y < rthresh[x]) - ttable[x][y] = amp[x]; - else - ttable[x][y] = 0; - } - freq[x]=(curfreq[x]+1)<<1; - freq[x]<<=17; - } - - totalout = wlookup1[ ttable[0][RectDutyCount[0]] + ttable[1][RectDutyCount[1]] ]; - - if(!inie[0] && !inie[1]) - { - for(V=start;V>4]+=totalout; - } - else - for(V=start;V>4]+=totalout; //tmpamp; - - sqacc[0]-=inie[0]; - sqacc[1]-=inie[1]; - - if(sqacc[0]<=0) - { - rea: - sqacc[0]+=freq[0]; - RectDutyCount[0]=(RectDutyCount[0]+1)&7; - if(sqacc[0]<=0) goto rea; - totalout = wlookup1[ ttable[0][RectDutyCount[0]] + ttable[1][RectDutyCount[1]] ]; - } - - if(sqacc[1]<=0) - { - rea2: - sqacc[1]+=freq[1]; - RectDutyCount[1]=(RectDutyCount[1]+1)&7; - if(sqacc[1]<=0) goto rea2; - totalout = wlookup1[ ttable[0][RectDutyCount[0]] + ttable[1][RectDutyCount[1]] ]; - } - } -} - -static void RDoTriangle(void) -{ - uint32 V; //mbg merge 7/17/06 made uitn32 - int32 tcout; - - tcout=(tristep&0xF); - if(!(tristep&0x10)) tcout^=0xF; - tcout=(tcout*3) << 16; //(tcout<<1); - - if(!lengthcount[2] || !TriCount) - { /* Counter is halted, but we still need to output. */ - /*int32 *start = &WaveHi[ChannelBC[2]]; - int32 count = SOUNDTS - ChannelBC[2]; - while(count--) - { - //Modify volume based on channel volume modifiers - *start += (tcout/256*FSettings.TriangleVolume)&(~0xFFFF); // TODO OPTIMIZE ME NOW DAMMIT! - start++; - }*/ - int32 cout = (tcout/256*FSettings.TriangleVolume)&(~0xFFFF); - for(V=ChannelBC[2];V>0xe)&1]; - - if(PSG[0xE]&0x80) - nshift=8; - else - nshift=13; - - - totalout = wlookup2[tcout+noiseout+RawDALatch]; - - if(inie[0] && inie[1]) - { - for(V=start;V>4]+=totalout; - - triacc-=inie[0]; - noiseacc-=inie[1]; - - if(triacc<=0) - { - rea: - triacc+=freq[0]; //t; - tristep=(tristep+1)&0x1F; - if(triacc<=0) goto rea; - tcout=(tristep&0xF); - if(!(tristep&0x10)) tcout^=0xF; - tcout=tcout*3; - totalout = wlookup2[tcout+noiseout+RawDALatch]; - } - - if(noiseacc<=0) - { - rea2: - //used to added <<(16+2) when the noise table - //values were half. - if(PAL) - noiseacc+=NoiseFreqTablePAL[PSG[0xE]&0xF]<<(16+1); - else - noiseacc+=NoiseFreqTableNTSC[PSG[0xE]&0xF]<<(16+1); - nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1); - nreg&=0x7fff; - noiseout=amptab[(nreg>>0xe)&1]; - if(noiseacc<=0) goto rea2; - totalout = wlookup2[tcout+noiseout+RawDALatch]; - } /* noiseacc<=0 */ - } /* for(V=... */ -} - else if(inie[0]) - { - for(V=start;V>4]+=totalout; - - triacc-=inie[0]; - - if(triacc<=0) - { - area: - triacc+=freq[0]; //t; - tristep=(tristep+1)&0x1F; - if(triacc<=0) goto area; - tcout=(tristep&0xF); - if(!(tristep&0x10)) tcout^=0xF; - tcout=tcout*3; - totalout = wlookup2[tcout+noiseout+RawDALatch]; - } - } - } - else if(inie[1]) - { - for(V=start;V>4]+=totalout; - noiseacc-=inie[1]; - if(noiseacc<=0) - { - area2: - //used to be added <<(16+2) when the noise table - //values were half. - if(PAL) - noiseacc+=NoiseFreqTablePAL[PSG[0xE]&0xF]<<(16+1); - else - noiseacc+=NoiseFreqTableNTSC[PSG[0xE]&0xF]<<(16+1); - nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1); - nreg&=0x7fff; - noiseout=amptab[(nreg>>0xe)&1]; - if(noiseacc<=0) goto area2; - totalout = wlookup2[tcout+noiseout+RawDALatch]; - } /* noiseacc<=0 */ - } - } - else - { - for(V=start;V>4]+=totalout; - } -} - - -static void RDoNoise(void) -{ - uint32 V; //mbg merge 7/17/06 made uint32 - int32 outo; - uint32 amptab[2]; - - if(EnvUnits[2].Mode&0x1) - amptab[0]=EnvUnits[2].Speed; - else - amptab[0]=EnvUnits[2].decvolume; - - //Modfiy Noise channel volume based on channel volume setting - //adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here) - if (FSettings.NoiseVolume != 256) amptab[0] = (amptab[0] * FSettings.NoiseVolume) / 256; // TODO OPTIMIZE ME! - amptab[0]<<=16; - amptab[1]=0; - - amptab[0]<<=1; - - outo=amptab[(nreg>>0xe)&1]; - - if(!lengthcount[3]) - { - outo=amptab[0]=0; - } - - if(PSG[0xE]&0x80) // "short" noise - for(V=ChannelBC[3];V>8)&1)^((nreg>>14)&1); - nreg=(nreg<<1)+feedback; - nreg&=0x7fff; - outo=amptab[(nreg>>0xe)&1]; - } - } - else - for(V=ChannelBC[3];V>13)&1)^((nreg>>14)&1); - nreg=(nreg<<1)+feedback; - nreg&=0x7fff; - outo=amptab[(nreg>>0xe)&1]; - } - } - ChannelBC[3]=SOUNDTS; -} - -DECLFW(Write_IRQFM) -{ - V=(V&0xC0)>>6; - fcnt=0; - if(V&0x2) - FrameSoundUpdate(); - fcnt=1; - fhcnt=fhinc; - X6502_IRQEnd(FCEU_IQFCOUNT); - SIRQStat&=~0x40; - IRQFrameMode=V; -} - -void SetNESSoundMap(void) -{ - SetWriteHandler(0x4000,0x400F,Write_PSG); - SetWriteHandler(0x4010,0x4013,Write_DMCRegs); - SetWriteHandler(0x4017,0x4017,Write_IRQFM); - - SetWriteHandler(0x4015,0x4015,StatusWrite); - SetReadHandler(0x4015,0x4015,StatusRead); -} - -static int32 inbuf=0; -int FlushEmulateSound(void) -{ - int x; - int32 end,left; - - if(!timestamp) return(0); - - if(!FSettings.SndRate) - { - left=0; - end=0; - goto nosoundo; - } - - DoSQ1(); - DoSQ2(); - DoTriangle(); - DoNoise(); - DoPCM(); - - if(FSettings.soundq>=1) - { - int32 *tmpo=&WaveHi[soundtsoffs]; - - if(GameExpSound.HiFill) GameExpSound.HiFill(); - - for(x=timestamp;x;x--) - { - uint32 b=*tmpo; - *tmpo=(b&65535)+wlookup2[(b>>16)&255]+wlookup1[b>>24]; - tmpo++; - } - end=NeoFilterSound(WaveHi,WaveFinal,SOUNDTS,&left); - - memmove(WaveHi,WaveHi+SOUNDTS-left,left*sizeof(uint32)); - memset(WaveHi+left,0,sizeof(WaveHi)-left*sizeof(uint32)); - - if(GameExpSound.HiSync) GameExpSound.HiSync(left); - for(x=0;x<5;x++) - ChannelBC[x]=left; - } - else - { - end=(SOUNDTS<<16)/soundtsinc; - if(GameExpSound.Fill) - GameExpSound.Fill(end&0xF); - - SexyFilter(Wave,WaveFinal,end>>4); - - //if(FSettings.lowpass) - // SexyFilter2(WaveFinal,end>>4); - if(end&0xF) - Wave[0]=Wave[(end>>4)]; - Wave[end>>4]=0; - } - nosoundo: - - if(FSettings.soundq>=1) - { - soundtsoffs=left; - } - else - { - for(x=0;x<5;x++) - ChannelBC[x]=end&0xF; - soundtsoffs = (soundtsinc*(end&0xF))>>16; - end>>=4; - } - inbuf=end; - - FCEU_WriteWaveData(WaveFinal, end); /* This function will just return - if sound recording is off. */ - return(end); -} - -int GetSoundBuffer(int32 **W) -{ - *W=WaveFinal; - return(inbuf); -} - -/* FIXME: Find out what sound registers get reset on reset. I know $4001/$4005 don't, -due to that whole MegaMan 2 Game Genie thing. -*/ - -void FCEUSND_Reset(void) -{ - int x; - - IRQFrameMode=0x0; - fhcnt=fhinc; - fcnt=0; - nreg=1; - - for(x=0;x<2;x++) - { - wlcount[x]=2048; - if(nesincsize) // lq mode - sqacc[x]=((uint32)2048<<17)/nesincsize; - else - sqacc[x]=1; - sweepon[x]=0; - curfreq[x]=0; - } - - wlcount[2]=1; //2048; - wlcount[3]=2048; - - DMCHaveDMA=DMCHaveSample=0; - SIRQStat=0x00; - - RawDALatch=0x00; - TriCount=0; - TriMode=0; - tristep=0; - EnabledChannels=0; - for(x=0;x<4;x++) - lengthcount[x]=0; - - DMCAddressLatch=0; - DMCSizeLatch=0; - DMCFormat=0; - DMCAddress=0; - DMCSize=0; - DMCShift=0; - - // MAJOR BUG WAS HERE: DMCacc and DMCBitCount never got reset... - // so, do some ridiculous hackery if a movie's about to play to keep it in sync... - - - if(movieSyncHackOn) - { - if(resetDMCacc) - { - // no value in movie save state - #ifdef WIN32 - // use editbox fields - DMCacc=movieConvertOffset1; - DMCBitCount=movieConvertOffset2; - #else - // no editbox fields, so leave the values alone - // and print out a warning that says what they are - FCEU_PrintError("Warning: These variables were not found in the save state and will keep their current value: DMCacc=%d, DMCBitCount=%d\n", DMCacc, DMCBitCount); - #endif - } - else - { - // keep values loaded from movie save state or reset earlier - } - } - else - { - // reset these variables like should have done in the first place - DMCacc=1; - DMCBitCount=0; - } - -// FCEU_PrintError("DMCacc=%d, DMCBitCount=%d",DMCacc,DMCBitCount); -} - -void FCEUSND_Power(void) -{ - int x; - - SetNESSoundMap(); - memset(PSG,0x00,sizeof(PSG)); - FCEUSND_Reset(); - - memset(Wave,0,sizeof(Wave)); - memset(WaveHi,0,sizeof(WaveHi)); - memset(&EnvUnits,0,sizeof(EnvUnits)); - - for(x=0;x<5;x++) - ChannelBC[x]=0; - soundtsoffs=0; - LoadDMCPeriod(DMCFormat&0xF); -} - - -void SetSoundVariables(void) -{ - int x; - - fhinc=PAL?16626:14915; // *2 CPU clock rate - fhinc*=24; - - if(FSettings.SndRate) - { - wlookup1[0]=0; - for(x=1;x<32;x++) - { - wlookup1[x]=(double)16*16*16*4*95.52/((double)8128/(double)x+100); - if(!FSettings.soundq) wlookup1[x]>>=4; - } - wlookup2[0]=0; - for(x=1;x<203;x++) - { - wlookup2[x]=(double)16*16*16*4*163.67/((double)24329/(double)x+100); - if(!FSettings.soundq) wlookup2[x]>>=4; - } - if(FSettings.soundq>=1) - { - DoNoise=RDoNoise; - DoTriangle=RDoTriangle; - DoPCM=RDoPCM; - DoSQ1=RDoSQ1; - DoSQ2=RDoSQ2; - } - else - { - DoNoise=DoTriangle=DoPCM=DoSQ1=DoSQ2=Dummyfunc; - DoSQ1=RDoSQLQ; - DoSQ2=RDoSQLQ; - DoTriangle=RDoTriangleNoisePCMLQ; - DoNoise=RDoTriangleNoisePCMLQ; - DoPCM=RDoTriangleNoisePCMLQ; - } - } - else - { - DoNoise=DoTriangle=DoPCM=DoSQ1=DoSQ2=Dummyfunc; - return; - } - - MakeFilters(FSettings.SndRate); - - if(GameExpSound.RChange) - GameExpSound.RChange(); - - nesincsize=(int64)(((int64)1<<17)*(double)(PAL?PAL_CPU:NTSC_CPU)/(FSettings.SndRate * 16)); - memset(sqacc,0,sizeof(sqacc)); - memset(ChannelBC,0,sizeof(ChannelBC)); - - LoadDMCPeriod(DMCFormat&0xF); // For changing from PAL to NTSC - - soundtsinc=(uint32)((uint64)(PAL?(long double)PAL_CPU*65536:(long double)NTSC_CPU*65536)/(FSettings.SndRate * 16)); -} - -void FCEUI_Sound(int Rate) -{ - FSettings.SndRate=Rate; - SetSoundVariables(); -} - -void FCEUI_SetLowPass(int q) -{ - FSettings.lowpass=q; -} - -void FCEUI_SetSoundQuality(int quality) -{ - FSettings.soundq=quality; - SetSoundVariables(); -} - -void FCEUI_SetSoundVolume(uint32 volume) -{ - FSettings.SoundVolume=volume; -} - -void FCEUI_SetTriangleVolume(uint32 volume) -{ - FSettings.TriangleVolume=volume; -} - -void FCEUI_SetSquare1Volume(uint32 volume) -{ - FSettings.Square1Volume=volume; -} - -void FCEUI_SetSquare2Volume(uint32 volume) -{ - FSettings.Square2Volume=volume; -} - -void FCEUI_SetNoiseVolume(uint32 volume) -{ - FSettings.NoiseVolume=volume; -} - -void FCEUI_SetPCMVolume(uint32 volume) -{ - FSettings.PCMVolume=volume; -} - -SFORMAT FCEUSND_STATEINFO[]={ - - { &fhcnt, 4|FCEUSTATE_RLSB,"FHCN"}, - { &fcnt, 1, "FCNT"}, - { PSG, 0x10, "PSG"}, - { &EnabledChannels, 1, "ENCH"}, - { &IRQFrameMode, 1, "IQFM"}, - { &nreg, 2|FCEUSTATE_RLSB, "NREG"}, - { &TriMode, 1, "TRIM"}, - { &TriCount, 1, "TRIC"}, - - { &EnvUnits[0].Speed, 1, "E0SP"}, - { &EnvUnits[1].Speed, 1, "E1SP"}, - { &EnvUnits[2].Speed, 1, "E2SP"}, - - { &EnvUnits[0].Mode, 1, "E0MO"}, - { &EnvUnits[1].Mode, 1, "E1MO"}, - { &EnvUnits[2].Mode, 1, "E2MO"}, - - { &EnvUnits[0].DecCountTo1, 1, "E0D1"}, - { &EnvUnits[1].DecCountTo1, 1, "E1D1"}, - { &EnvUnits[2].DecCountTo1, 1, "E2D1"}, - - { &EnvUnits[0].decvolume, 1, "E0DV"}, - { &EnvUnits[1].decvolume, 1, "E1DV"}, - { &EnvUnits[2].decvolume, 1, "E2DV"}, - - { &lengthcount[0], 4|FCEUSTATE_RLSB, "LEN0"}, - { &lengthcount[1], 4|FCEUSTATE_RLSB, "LEN1"}, - { &lengthcount[2], 4|FCEUSTATE_RLSB, "LEN2"}, - { &lengthcount[3], 4|FCEUSTATE_RLSB, "LEN3"}, - { sweepon, 2, "SWEE"}, - { &curfreq[0], 4|FCEUSTATE_RLSB,"CRF1"}, - { &curfreq[1], 4|FCEUSTATE_RLSB,"CRF2"}, - { SweepCount, 2,"SWCT"}, - - { &SIRQStat, 1, "SIRQ"}, - - { &DMCacc, 4|FCEUSTATE_RLSB, "5ACC"}, - { &DMCBitCount, 1, "5BIT"}, - { &DMCAddress, 4|FCEUSTATE_RLSB, "5ADD"}, - { &DMCSize, 4|FCEUSTATE_RLSB, "5SIZ"}, - { &DMCShift, 1, "5SHF"}, - - { &DMCHaveDMA, 1, "5HVDM"}, - { &DMCHaveSample, 1, "5HVSP"}, - - { &DMCSizeLatch, 1, "5SZL"}, - { &DMCAddressLatch, 1, "5ADL"}, - { &DMCFormat, 1, "5FMT"}, - { &RawDALatch, 1, "RWDA"}, - { 0 } -}; - -void FCEUSND_SaveState(void) -{ - -} - -void FCEUSND_LoadState(int version) -{ - LoadDMCPeriod(DMCFormat&0xF); - RawDALatch&=0x7F; - DMCAddress&=0x7FFF; -} diff --git a/branches/fceux-2.2.2/src/sound.h b/branches/fceux-2.2.2/src/sound.h deleted file mode 100644 index 3d094c21..00000000 --- a/branches/fceux-2.2.2/src/sound.h +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _SOUND_H_ -#define _SOUND_H_ - -typedef struct { - void (*Fill)(int Count); /* Low quality ext sound. */ - - /* NeoFill is for sound devices that are emulated in a more - high-level manner(VRC7) in HQ mode. Interestingly, - this device has slightly better sound quality(updated more - often) in lq mode than in high-quality mode. Maybe that - should be fixed. :) - */ - void (*NeoFill)(int32 *Wave, int Count); - void (*HiFill)(void); - void (*HiSync)(int32 ts); - - void (*RChange)(void); - void (*Kill)(void); -} EXPSOUND; - -extern EXPSOUND GameExpSound; - -extern int32 nesincsize; - -void SetSoundVariables(void); - -int GetSoundBuffer(int32 **W); -int FlushEmulateSound(void); -extern int32 Wave[2048+512]; -extern int32 WaveFinal[2048+512]; -extern int32 WaveHi[]; -extern uint32 soundtsinc; - -#ifdef WIN32 -extern volatile int datacount, undefinedcount; -extern int debug_loggingCD; -extern unsigned char *cdloggerdata; -#endif - -extern uint32 soundtsoffs; -#define SOUNDTS (timestamp + soundtsoffs) - -void SetNESSoundMap(void); -void FrameSoundUpdate(void); - -void FCEUSND_Power(void); -void FCEUSND_Reset(void); -void FCEUSND_SaveState(void); -void FCEUSND_LoadState(int version); - -void FCEU_SoundCPUHook(int); -void Write_IRQFM (uint32 A, uint8 V); //mbg merge 7/17/06 brought over from latest mmbuild - -void LogDPCM(int romaddress, int dpcmsize); - -typedef struct { - uint8 Speed; - uint8 Mode; /* Fixed volume(1), and loop(2) */ - uint8 DecCountTo1; - uint8 decvolume; - int reloaddec; -} ENVUNIT; - -#endif diff --git a/branches/fceux-2.2.2/src/state.cpp b/branches/fceux-2.2.2/src/state.cpp deleted file mode 100644 index 30593544..00000000 --- a/branches/fceux-2.2.2/src/state.cpp +++ /dev/null @@ -1,1163 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -// TODO: Add (better) file io error checking - -#include "version.h" -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "sound.h" -#include "utils/endian.h" -#include "utils/memory.h" -#include "utils/xstring.h" -#include "file.h" -#include "fds.h" -#include "state.h" -#include "movie.h" -#include "ppu.h" -#include "netplay.h" -#include "video.h" -#include "input.h" -#include "zlib.h" -#include "driver.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -//TODO - we really need some kind of global platform-specific options api -#ifdef WIN32 -#include "drivers/win/main.h" -#include "drivers/win/ram_search.h" -#include "drivers/win/ramwatch.h" -#endif - -#include -#include -#include -#include -//#include //mbg merge 7/17/06 removed - -#include -#include - -using namespace std; - -static void (*SPreSave)(void); -static void (*SPostSave)(void); - -static int SaveStateStatus[10]; -static int StateShow; - -//tells the save system innards that we're loading the old format -bool FCEU_state_loading_old_format; - -char lastSavestateMade[2048]; //Stores the filename of the last savestate made (needed for UndoSavestate) -bool undoSS = false; //This will be true if there is lastSavestateMade, it was made since ROM was loaded, a backup state for lastSavestateMade exists -bool redoSS = false; //This will be true if UndoSaveState is run, will turn false when a new savestate is made - -char lastLoadstateMade[2048]; //Stores the filename of the last state loaded (needed for Undo/Redo loadstate) -bool undoLS = false; //This will be true if a backupstate was made and it was made since ROM was loaded -bool redoLS = false; //This will be true if a backupstate was loaded, meaning redoLoadState can be run - -bool internalSaveLoad = false; - -bool backupSavestates = true; -bool compressSavestates = true; //By default FCEUX compresses savestates when a movie is inactive. - -// a temp memory stream. We'll be dumping some data here and then compress -EMUFILE_MEMORY memory_savestate; -// temporary buffer for compressed data of a savestate -std::vector compressed_buf; - -#define SFMDATA_SIZE (64) -static SFORMAT SFMDATA[SFMDATA_SIZE]; -static int SFEXINDEX; - -#define RLSB FCEUSTATE_RLSB //0x80000000 - - -extern SFORMAT FCEUPPU_STATEINFO[]; -extern SFORMAT FCEU_NEWPPU_STATEINFO[]; -extern SFORMAT FCEUSND_STATEINFO[]; -extern SFORMAT FCEUCTRL_STATEINFO[]; -extern SFORMAT FCEUMOV_STATEINFO[]; - -//why two separate CPU structs?? who knows - -SFORMAT SFCPU[]={ - { &X.PC, 2|RLSB, "PC\0"}, - { &X.A, 1, "A\0\0"}, - { &X.X, 1, "X\0\0"}, - { &X.Y, 1, "Y\0\0"}, - { &X.S, 1, "S\0\0"}, - { &X.P, 1, "P\0\0"}, - { &X.DB, 1, "DB"}, - { &RAM, 0x800 | FCEUSTATE_INDIRECT, "RAM", }, - { 0 } -}; - -SFORMAT SFCPUC[]={ - { &X.jammed, 1, "JAMM"}, - { &X.IRQlow, 4|RLSB, "IQLB"}, - { &X.tcount, 4|RLSB, "ICoa"}, - { &X.count, 4|RLSB, "ICou"}, - { ×tampbase, sizeof(timestampbase) | RLSB, "TSBS"}, - { &X.mooPI, 1, "MooP"}, // alternative to the "quick and dirty hack" - { 0 } -}; - -void foo(uint8* test) { (void)test; } - -static int SubWrite(EMUFILE* os, SFORMAT *sf) -{ - uint32 acc=0; - - while(sf->v) - { - if(sf->s==~0) //Link to another struct - { - uint32 tmp; - - if(!(tmp=SubWrite(os,(SFORMAT *)sf->v))) - return(0); - acc+=tmp; - sf++; - continue; - } - - acc+=8; //Description + size - acc+=sf->s&(~FCEUSTATE_FLAGS); - - if(os) //Are we writing or calculating the size of this block? - { - os->fwrite(sf->desc,4); - write32le(sf->s&(~FCEUSTATE_FLAGS),os); - -#ifndef LSB_FIRST - if(sf->s&RLSB) - FlipByteOrder((uint8*)sf->v,sf->s&(~FCEUSTATE_FLAGS)); -#endif - - if(sf->s&FCEUSTATE_INDIRECT) - os->fwrite(*(char **)sf->v,sf->s&(~FCEUSTATE_FLAGS)); - else - os->fwrite((char*)sf->v,sf->s&(~FCEUSTATE_FLAGS)); - - //Now restore the original byte order. -#ifndef LSB_FIRST - if(sf->s&RLSB) - FlipByteOrder((uint8*)sf->v,sf->s&(~FCEUSTATE_FLAGS)); -#endif - } - sf++; - } - - return(acc); -} - -static int WriteStateChunk(EMUFILE* os, int type, SFORMAT *sf) -{ - os->fputc(type); - int bsize = SubWrite((EMUFILE*)0,sf); - write32le(bsize,os); - - if(!SubWrite(os,sf)) - { - return 5; - } - return (bsize+5); -} - -static SFORMAT *CheckS(SFORMAT *sf, uint32 tsize, char *desc) -{ - while(sf->v) - { - if(sf->s==~0) // Link to another SFORMAT structure. - { - SFORMAT *tmp; - if((tmp= CheckS((SFORMAT *)sf->v, tsize, desc) )) - return(tmp); - sf++; - continue; - } - if(!memcmp(desc,sf->desc,4)) - { - if(tsize!=(sf->s&(~FCEUSTATE_FLAGS))) - return(0); - return(sf); - } - sf++; - } - return(0); -} - -static bool ReadStateChunk(EMUFILE* is, SFORMAT *sf, int size) -{ - SFORMAT *tmp; - int temp = is->ftell(); - - while(is->ftell()fread(toa,4)<4) - return false; - - read32le(&tsize,is); - - if((tmp=CheckS(sf,tsize,toa))) - { - if(tmp->s&FCEUSTATE_INDIRECT) - is->fread(*(char **)tmp->v,tmp->s&(~FCEUSTATE_FLAGS)); - else - is->fread((char *)tmp->v,tmp->s&(~FCEUSTATE_FLAGS)); - -#ifndef LSB_FIRST - if(tmp->s&RLSB) - FlipByteOrder((uint8*)tmp->v,tmp->s&(~FCEUSTATE_FLAGS)); -#endif - } - else - is->fseek(tsize,SEEK_CUR); - } // while(...) - return true; -} - -static int read_sfcpuc=0, read_snd=0; - -void FCEUD_BlitScreen(uint8 *XBuf); //mbg merge 7/17/06 YUCKY had to add -void UpdateFCEUWindow(void); //mbg merge 7/17/06 YUCKY had to add -static bool ReadStateChunks(EMUFILE* is, int32 totalsize) -{ - int t; - uint32 size; - bool ret=true; - bool warned=false; - - read_sfcpuc=0; - read_snd=0; - - //mbg 6/16/08 - wtf - //// int moo=X.mooPI; - // if(!scan_chunks) - // X.mooPI=/*X.P*/0xFF; - - while(totalsize > 0) - { - t=is->fgetc(); - if(t==EOF) break; - if(!read32le(&size,is)) break; - totalsize -= size + 5; - - switch(t) - { - case 1:if(!ReadStateChunk(is,SFCPU,size)) ret=false;break; - case 3:if(!ReadStateChunk(is,FCEUPPU_STATEINFO,size)) ret=false;break; - case 31:if(!ReadStateChunk(is,FCEU_NEWPPU_STATEINFO,size)) ret=false;break; - case 4:if(!ReadStateChunk(is,FCEUCTRL_STATEINFO,size)) ret=false;break; - case 7: - if(!FCEUMOV_ReadState(is,size)) { - //allow this to fail in old-format savestates. - if(!FCEU_state_loading_old_format) - ret=false; - } - break; - case 0x10: - if(!ReadStateChunk(is,SFMDATA,size)) - ret=false; - break; - - // now it gets hackier: - case 5: - if(!ReadStateChunk(is,FCEUSND_STATEINFO,size)) - ret=false; - else - read_snd=1; - break; - case 6: - if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED)) - { - if(!ReadStateChunk(is,FCEUMOV_STATEINFO,size)) ret=false; - } - else - { - is->fseek(size,SEEK_CUR); - } - break; - case 8: - // load back buffer - { - extern uint8 *XBackBuf; - if(is->fread((char*)XBackBuf,size) != size) - ret = false; - - //MBG TODO - can this be moved to a better place? - //does it even make sense, displaying XBuf when its XBackBuf we just loaded? -#ifdef WIN32 - else - { - FCEUD_BlitScreen(XBuf); - UpdateFCEUWindow(); - } -#endif - - } - break; - case 2: - { - if(!ReadStateChunk(is,SFCPUC,size)) - ret=false; - else - read_sfcpuc=1; - } break; - default: - // for somebody's sanity's sake, at least warn about it: - if(!warned) - { - char str [256]; - sprintf(str, "Warning: Found unknown save chunk of type %d.\nThis could indicate the save state is corrupted\nor made with a different (incompatible) emulator version.", t); - FCEUD_PrintError(str); - warned=true; - } - //if(fseek(st,size,SEEK_CUR)<0) goto endo;break; - is->fseek(size,SEEK_CUR); - } - } - //endo: - - //mbg 6/16/08 - wtf - // if(X.mooPI==0xFF && !scan_chunks) - // { - //// FCEU_PrintError("prevmoo=%d, p=%d",moo,X.P); - // X.mooPI=X.P; // "Quick and dirty hack." //begone - // } - - extern int resetDMCacc; - if(read_snd) - resetDMCacc=0; - else - resetDMCacc=1; - - return ret; -} - -int CurrentState=0; -extern int geniestage; - - -bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel) -{ - // reinit memory_savestate - // memory_savestate is global variable which already has its vector of bytes, so no need to allocate memory every time we use save/loadstate - memory_savestate.set_len(0); // this also seeks to the beginning - memory_savestate.unfail(); - - EMUFILE* os = &memory_savestate; - - uint32 totalsize = 0; - - FCEUPPU_SaveState(); - FCEUSND_SaveState(); - totalsize=WriteStateChunk(os,1,SFCPU); - totalsize+=WriteStateChunk(os,2,SFCPUC); - totalsize+=WriteStateChunk(os,3,FCEUPPU_STATEINFO); - totalsize+=WriteStateChunk(os,31,FCEU_NEWPPU_STATEINFO); - totalsize+=WriteStateChunk(os,4,FCEUCTRL_STATEINFO); - totalsize+=WriteStateChunk(os,5,FCEUSND_STATEINFO); - if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED)) - { - totalsize+=WriteStateChunk(os,6,FCEUMOV_STATEINFO); - - //MBG TAS Editor HACK HACK HACK! - //do not save the movie state if we are in Taseditor! That would be a huge waste of time and space! - if(!FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) - { - os->fseek(5,SEEK_CUR); - int size = FCEUMOV_WriteState(os); - os->fseek(-(size+5),SEEK_CUR); - os->fputc(7); - write32le(size, os); - os->fseek(size,SEEK_CUR); - - totalsize += 5 + size; - } - } - // save back buffer - { - extern uint8 *XBackBuf; - uint32 size = 256 * 256 + 8; - os->fputc(8); - write32le(size, os); - os->fwrite((char*)XBackBuf,size); - totalsize += 5 + size; - } - - if(SPreSave) SPreSave(); - totalsize+=WriteStateChunk(os,0x10,SFMDATA); - if(SPreSave) SPostSave(); - - //save the length of the file - int len = memory_savestate.size(); - - //sanity check: len and totalsize should be the same - if(len != totalsize) - { - FCEUD_PrintError("sanity violation: len != totalsize"); - return false; - } - - int error = Z_OK; - uint8* cbuf = (uint8*)memory_savestate.buf(); - uLongf comprlen = -1; - if(compressionLevel != Z_NO_COMPRESSION && (compressSavestates || FCEUMOV_Mode(MOVIEMODE_TASEDITOR))) - { - // worst case compression: zlib says "0.1% larger than sourceLen plus 12 bytes" - comprlen = (len>>9)+12 + len; - if (compressed_buf.size() < comprlen) compressed_buf.resize(comprlen); - cbuf = &compressed_buf[0]; - // do compression - error = compress2(cbuf, &comprlen, (uint8*)memory_savestate.buf(), len, compressionLevel); - } - - //dump the header - uint8 header[16]="FCSX"; - FCEU_en32lsb(header+4, totalsize); - FCEU_en32lsb(header+8, FCEU_VERSION_NUMERIC); - FCEU_en32lsb(header+12, comprlen); - - //dump it to the destination file - outstream->fwrite((char*)header,16); - outstream->fwrite((char*)cbuf,comprlen==-1?totalsize:comprlen); - - return error == Z_OK; -} - - -void FCEUSS_Save(const char *fname, bool display_message) -{ - EMUFILE* st = 0; - char fn[2048]; - - if (geniestage==1) - { - if (display_message) - FCEU_DispMessage("Cannot save FCS in GG screen.",0); - return; - } - - if(fname) //If filename is given use it. - { - st = FCEUD_UTF8_fstream(fname, "wb"); - strcpy(fn, fname); - } - else //Else, generate one - { - //FCEU_PrintError("daCurrentState=%d",CurrentState); - strcpy(fn, FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); - - //backup existing savestate first - if (CheckFileExists(fn) && backupSavestates) //adelikat: If the files exists and we are allowed to make backup savestates - { - CreateBackupSaveState(fn); //Make a backup of previous savestate before overwriting it - strcpy(lastSavestateMade,fn); //Remember what the last savestate filename was (for undoing later) - undoSS = true; //Backup was created so undo is possible - } - else - undoSS = false; //so backup made so lastSavestateMade does have a backup file, so no undo - - st = FCEUD_UTF8_fstream(fn,"wb"); - } - - if (st == NULL || st->get_fp() == NULL) - { - if (display_message) - FCEU_DispMessage("State %d save error.", 0, CurrentState); - return; - } - - #ifdef _S9XLUA_H - if (!internalSaveLoad) - { - LuaSaveData saveData; - CallRegisteredLuaSaveFunctions(CurrentState, saveData); - - char luaSaveFilename [512]; - strncpy(luaSaveFilename, fn, 512); - luaSaveFilename[512-(1+7/*strlen(".luasav")*/)] = '\0'; - strcat(luaSaveFilename, ".luasav"); - if(saveData.recordList) - { - FILE* luaSaveFile = fopen(luaSaveFilename, "wb"); - if(luaSaveFile) - { - saveData.ExportRecords(luaSaveFile); - fclose(luaSaveFile); - } - } - else - { - unlink(luaSaveFilename); - } - } - #endif - - if(FCEUMOV_Mode(MOVIEMODE_INACTIVE)) - FCEUSS_SaveMS(st,-1); - else - FCEUSS_SaveMS(st,0); - - delete st; - - if(!fname) - { - SaveStateStatus[CurrentState] = 1; - if (display_message) - FCEU_DispMessage("State %d saved.", 0, CurrentState); - } - redoSS = false; //we have a new savestate so redo is not possible -} - -int FCEUSS_LoadFP_old(EMUFILE* is, ENUM_SSLOADPARAMS params) -{ - //if(params==SSLOADPARAM_DUMMY && suppress_scan_chunks) - // return 1; - - int x; - uint8 header[16]; - int stateversion; - char* fn=0; - - ////Make temporary savestate in case something screws up during the load - //if(params == SSLOADPARAM_BACKUP) - //{ - // fn=FCEU_MakeFName(FCEUMKF_NPTEMP,0,0); - // FILE *fp; - // - // if((fp=fopen(fn,"wb"))) - // { - // if(FCEUSS_SaveFP(fp)) - // { - // fclose(fp); - // } - // else - // { - // fclose(fp); - // unlink(fn); - // free(fn); - // fn=0; - // } - // } - //} - - //if(params!=SSLOADPARAM_DUMMY) - { - FCEUMOV_PreLoad(); - } - is->fread((char*)&header,16); - if(memcmp(header,"FCS",3)) - { - return(0); - } - if(header[3] == 0xFF) - { - stateversion = FCEU_de32lsb(header + 8); - } - else - { - stateversion=header[3] * 100; - } - //if(params == SSLOADPARAM_DUMMY) - //{ - // scan_chunks=1; - //} - x=ReadStateChunks(is,*(uint32*)(header+4)); - //if(params == SSLOADPARAM_DUMMY) - //{ - // scan_chunks=0; - // return 1; - //} - if(read_sfcpuc && stateversion<9500) - { - X.IRQlow=0; - } - if(GameStateRestore) - { - GameStateRestore(stateversion); - } - if(x) - { - FCEUPPU_LoadState(stateversion); - FCEUSND_LoadState(stateversion); - x=FCEUMOV_PostLoad(); - } - if(fn) - { - //if(!x || params == SSLOADPARAM_DUMMY) //is make_backup==2 possible?? oh well. - //{ - // * Oops! Load the temporary savestate */ - // FILE *fp; - // - // if((fp=fopen(fn,"rb"))) - // { - // FCEUSS_LoadFP(fp,SSLOADPARAM_NOBACKUP); - // fclose(fp); - // } - // unlink(fn); - //} - free(fn); - } - - return(x); -} - - -bool FCEUSS_LoadFP(EMUFILE* is, ENUM_SSLOADPARAMS params) -{ - if(!is) return false; - - //maybe make a backup savestate - bool backup = (params == SSLOADPARAM_BACKUP); - EMUFILE_MEMORY msBackupSavestate; - if(backup) - { - FCEUSS_SaveMS(&msBackupSavestate,Z_NO_COMPRESSION); - } - - uint8 header[16]; - //read and analyze the header - is->fread((char*)&header,16); - if(memcmp(header,"FCSX",4)) { - //its not an fceux save file.. perhaps it is an fceu savefile - is->fseek(0,SEEK_SET); - FCEU_state_loading_old_format = true; - bool ret = FCEUSS_LoadFP_old(is,params)!=0; - FCEU_state_loading_old_format = false; - if(!ret && backup) FCEUSS_LoadFP(&msBackupSavestate,SSLOADPARAM_NOBACKUP); - return ret; - } - - int totalsize = FCEU_de32lsb(header + 4); - int stateversion = FCEU_de32lsb(header + 8); - int comprlen = FCEU_de32lsb(header + 12); - - // reinit memory_savestate - // memory_savestate is global variable which already has its vector of bytes, so no need to allocate memory every time we use save/loadstate - if ((int)(memory_savestate.get_vec())->size() < totalsize) - (memory_savestate.get_vec())->resize(totalsize); - memory_savestate.set_len(totalsize); - memory_savestate.unfail(); - memory_savestate.fseek(0, SEEK_SET); - - if(comprlen != -1) - { - // the savestate is compressed: read from is to compressed_buf, then decompress from compressed_buf to memory_savestate.vec - if ((int)compressed_buf.size() < comprlen) compressed_buf.resize(comprlen); - is->fread(&compressed_buf[0], comprlen); - - uLongf uncomprlen = totalsize; - int error = uncompress(memory_savestate.buf(), &uncomprlen, &compressed_buf[0], comprlen); - if(error != Z_OK || uncomprlen != totalsize) - return false; // we dont need to restore the backup here because we havent messed with the emulator state yet - } else - { - // the savestate is not compressed: just read from is to memory_savestate.vec - is->fread(memory_savestate.buf(), totalsize); - } - - FCEUMOV_PreLoad(); - - bool x = (ReadStateChunks(&memory_savestate, totalsize) != 0); - - //mbg 5/24/08 - we don't support old states, so this shouldnt matter. - //if(read_sfcpuc && stateversion<9500) - // X.IRQlow=0; - - if(GameStateRestore) - { - GameStateRestore(stateversion); - } - if (x) - { - FCEUPPU_LoadState(stateversion); - FCEUSND_LoadState(stateversion); - x=FCEUMOV_PostLoad(); - } else if (backup) - { - msBackupSavestate.fseek(0,SEEK_SET); - FCEUSS_LoadFP(&msBackupSavestate,SSLOADPARAM_NOBACKUP); - } - - return x; -} - - -bool FCEUSS_Load(const char *fname, bool display_message) -{ - EMUFILE* st; - char fn[2048]; - - //mbg movie - this needs to be overhauled - ////this fixes read-only toggle problems - //if(FCEUMOV_IsRecording()) { - // FCEUMOV_AddCommand(0); - // MovieFlushHeader(); - //} - - if (geniestage == 1) - { - if (display_message) - FCEU_DispMessage("Cannot load FCS in GG screen.",0); - return false; - } - if (fname) - { - st = FCEUD_UTF8_fstream(fname, "rb"); - strcpy(fn, fname); - } else - { - strcpy(fn, FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname).c_str()); - st=FCEUD_UTF8_fstream(fn,"rb"); - strcpy(lastLoadstateMade,fn); - } - - if (st == NULL || (st->get_fp() == NULL)) - { - if (display_message) - { - FCEU_DispMessage("State %d load error.", 0, CurrentState); - //FCEU_DispMessage("State %d load error. Filename: %s", 0, CurrentState, fn); - } - SaveStateStatus[CurrentState] = 0; - return false; - } - - //If in bot mode, don't do a backup when loading. - //Otherwise you eat at the hard disk, since so many - //states are being loaded. - if (FCEUSS_LoadFP(st, backupSavestates ? SSLOADPARAM_BACKUP : SSLOADPARAM_NOBACKUP)) - { - if (fname) - { - char szFilename[260]={0}; - splitpath(fname, 0, 0, szFilename, 0); - if (display_message) - { - FCEU_DispMessage("State %s loaded.", 0, szFilename); - //FCEU_DispMessage("State %s loaded. Filename: %s", 0, szFilename, fn); - } - } else - { - if (display_message) - { - FCEU_DispMessage("State %d loaded.", 0, CurrentState); - //FCEU_DispMessage("State %d loaded. Filename: %s", 0, CurrentState, fn); - } - SaveStateStatus[CurrentState] = 1; - } - delete st; - - #ifdef _S9XLUA_H - if (!internalSaveLoad) - { - LuaSaveData saveData; - - char luaSaveFilename [512]; - strncpy(luaSaveFilename, fn, 512); - luaSaveFilename[512-(1+7/*strlen(".luasav")*/)] = '\0'; - strcat(luaSaveFilename, ".luasav"); - FILE* luaSaveFile = fopen(luaSaveFilename, "rb"); - if(luaSaveFile) - { - saveData.ImportRecords(luaSaveFile); - fclose(luaSaveFile); - } - - CallRegisteredLuaLoadFunctions(CurrentState, saveData); - } - #endif - -#ifdef WIN32 - Update_RAM_Search(); // Update_RAM_Watch() is also called. -#endif - - //Update input display if movie is loaded - extern uint32 cur_input_display; - extern uint8 FCEU_GetJoyJoy(void); - - cur_input_display = FCEU_GetJoyJoy(); //Input display should show the last buttons pressed (stored in the savestate) - - return true; - } else - { - if(!fname) - SaveStateStatus[CurrentState] = 1; - - if (display_message) - { - FCEU_DispMessage("Error(s) reading state %d!", 0, CurrentState); - //FCEU_DispMessage("Error(s) reading state %d! Filename: %s", 0, CurrentState, fn); - } - delete st; - return 0; - } -} - -void FCEUSS_CheckStates(void) -{ - FILE *st=NULL; - int ssel; - - for(ssel=0;ssel<10;ssel++) - { - st=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_STATE,ssel,0),"rb"); - if(st) - { - SaveStateStatus[ssel]=1; - fclose(st); - } - else - SaveStateStatus[ssel]=0; - } - - CurrentState=1; - StateShow=0; -} - -void ResetExState(void (*PreSave)(void), void (*PostSave)(void)) -{ - int x; - for(x=0;x names; - while(sf->v) - { - char tmp[5] = {0}; - memcpy(tmp,sf->desc,4); - std::string desc = tmp; - if(names.find(desc) != names.end()) - { -#ifdef _MSC_VER - MessageBox(NULL,"OH NO!!! YOU HAVE AN INVALID SFORMAT! POST A BUG TICKET ALONG WITH INFO ON THE ROM YOURE USING\n","OOPS",MB_OK); -#else - printf("OH NO!!! YOU HAVE AN INVALID SFORMAT! POST A BUG TICKET ALONG WITH INFO ON THE ROM YOURE USING\n"); -#endif - exit(0); - } - names[desc] = true; - sf++; - } - } - - if(desc) - { - SFMDATA[SFEXINDEX].desc=(char *)FCEU_malloc(strlen(desc)+1); - strcpy(SFMDATA[SFEXINDEX].desc,desc); - } - else - SFMDATA[SFEXINDEX].desc=0; - SFMDATA[SFEXINDEX].v=v; - SFMDATA[SFEXINDEX].s=s; - if(type) SFMDATA[SFEXINDEX].s|=RLSB; - if(SFEXINDEX0) - CurrentState=(CurrentState+1)%10; - else - CurrentState=(CurrentState+9)%10; - FCEUI_SelectState(CurrentState, 1); -} - -int FCEUI_SelectState(int w, int show) -{ - FCEUSS_CheckStates(); - int oldstate=CurrentState; - if(w == -1) { StateShow = 0; return 0; } //mbg merge 7/17/06 had to make return a value - - CurrentState=w; - if(show) - { - StateShow=180; - FCEU_DispMessage("-select state-",0); - } - return oldstate; -} - -void FCEUI_SaveState(const char *fname, bool display_message) -{ - if(!FCEU_IsValidUI(FCEUI_SAVESTATE)) return; - - StateShow = 0; - - FCEUSS_Save(fname, display_message); -} - -int loadStateFailed = 0; // hack, this function should return a value instead - -bool file_exists(const char * filename) -{ - if (FILE * file = fopen(filename, "r")) //I'm sure, you meant for READING =) - { - fclose(file); - return true; - } - return false; -} -void FCEUI_LoadState(const char *fname, bool display_message) -{ - if(!FCEU_IsValidUI(FCEUI_LOADSTATE)) return; - - StateShow = 0; - loadStateFailed = 0; - - /* For network play, be load the state locally, and then save the state to a temporary file, - and send that. This insures that if an older state is loaded that is missing some - information expected in newer save states, desynchronization won't occur(at least not - from this ;)). - */ - if (backupSavestates) - BackupLoadState(); // If allowed, backup the current state before loading a new one - - if (!movie_readonly && autoMovieBackup && freshMovie) //If auto-backup is on, movie has not been altered this session and the movie is in read+write mode - { - FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages - } - if (fname != NULL && !file_exists(fname)) - { - loadStateFailed = 1; - return; // state doesn't exist; exit cleanly - } - if (FCEUSS_Load(fname, display_message)) - { - //mbg todo netplay -#if 0 - if(FCEUnetplay) - { - char *fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP, 0, 0).c_str()); - FILE *fp; - - if((fp = fopen(fn," wb"))) - { - if(FCEUSS_SaveFP(fp,0)) - { - fclose(fp); - FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn); - } - else - { - fclose(fp); - } - - unlink(fn); - } - - free(fn); - } -#endif - freshMovie = false; //The movie has been altered so it is no longer fresh - } else - { - loadStateFailed = 1; - } -} - -void FCEU_DrawSaveStates(uint8 *XBuf) -{ - if(!StateShow) return; - - FCEU_DrawNumberRow(XBuf,SaveStateStatus,CurrentState); - StateShow--; -} - -//************************************************************************* -//Savestate backup functions -//(Used when making savestates) -//************************************************************************* - -string GenerateBackupSaveStateFn(const char *fname) -{ - //This backup is for the backup "slot" for any savestate made. Example: smb.fc0 becomes smb-bak.fc0 - string filename; - filename = fname; //Convert fname to a string object - int x = filename.find_last_of("."); //Find file extension - filename.insert(x,"-bak"); //add "-bak" before the dot. - - return filename; -} - - -void CreateBackupSaveState(const char *fname) -{ - string newFilename = GenerateBackupSaveStateFn(fname); //Get backup savestate filename - if (CheckFileExists(newFilename.c_str())) //See if backup already exists - remove(newFilename.c_str()) ; //If so, delete it - rename(fname,newFilename.c_str()); //Rename savestate to backup filename - undoSS = true; //There is a backup savestate file to mast last loaded, so undo is possible -} - -void SwapSaveState() -{ - //-------------------------------------------------------------------------------------------- - //Both files must exist - //-------------------------------------------------------------------------------------------- - - if (!lastSavestateMade) - { - FCEUI_DispMessage("Can't Undo",0); - FCEUI_printf("Undo savestate was attempted but unsuccessful because there was not a recently used savestate.\n"); - return; //If there is no last savestate, can't undo - } - string backup = GenerateBackupSaveStateFn(lastSavestateMade); //Get filename of backup state - if (!CheckFileExists(backup.c_str())) - { - FCEUI_DispMessage("Can't Undo",0); - FCEUI_printf("Undo savestate was attempted but unsuccessful because there was not a backup of the last used savestate.\n"); - return; //If no backup, can't undo - } - - //-------------------------------------------------------------------------------------------- - //So both exists, now swap the last savestate and its backup - //-------------------------------------------------------------------------------------------- - string temp = backup; //Put backup filename in temp - temp.append("x"); //Add x - - rename(backup.c_str(),temp.c_str()); //rename backup file to temp file - rename(lastSavestateMade,backup.c_str()); //rename current as backup - rename(temp.c_str(),lastSavestateMade); //rename backup as current - - undoSS = true; //Just in case, if this was run, then there is definately a last savestate and backup - if (redoSS) //This was a redo function, so if run again it will be an undo again - redoSS = false; - else //This was an undo function so next will be redo, so flag it - redoSS = true; - - FCEUI_DispMessage("%s restored",0,backup.c_str()); - FCEUI_printf("%s restored\n",backup.c_str()); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------ -//************************************************************************* -//Loadstate backup functions -//(Used when Loading savestates) -//************************************************************************* - -string GetBackupFileName() -{ - //This backup savestate is a special one specifically made whenever a loadstate occurs so that the user's place in a movie/game is never lost - //particularly from unintentional loadstating - string filename; - int x; - - filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename - x = filename.find_last_of("."); //Find last dot - filename = filename.substr(0,x); //Chop off file extension - filename.append(".bak.fc0"); //add .bak - - return filename; -} - -bool CheckBackupSaveStateExist() -{ - //This function simply checks to see if the backup loadstate exists, the backup loadstate is a special savestate - //That is made before loading any state, so that the user never loses his data - string filename = GetBackupFileName(); //Get backup savestate filename - - //Check if this filename exists - fstream test; - test.open(filename.c_str(),fstream::in); - - if (test.fail()) - { - test.close(); - return false; - } - else - { - test.close(); - return true; - } -} - -void BackupLoadState() -{ - string filename = GetBackupFileName(); - internalSaveLoad = true; - FCEUSS_Save(filename.c_str()); - internalSaveLoad = false; - undoLS = true; -} - -void LoadBackup() -{ - if (!undoLS) return; - string filename = GetBackupFileName(); //Get backup filename - if (CheckBackupSaveStateExist()) - { - //internalSaveLoad = true; - FCEUSS_Load(filename.c_str()); //Load it - //internalSaveLoad = false; - redoLS = true; //Flag redoLoadState - undoLS = false; //Flag that LoadBackup cannot be run again - } - else - FCEUI_DispMessage("Error: Could not load %s",0,filename.c_str()); -} - -void RedoLoadState() -{ - if (!redoLS) return; - if (lastLoadstateMade && redoLS) - { - FCEUSS_Load(lastLoadstateMade); - FCEUI_printf("Redoing %s\n",lastLoadstateMade); - } - redoLS = false; //Flag that RedoLoadState can not be run again - undoLS = true; //Flag that LoadBackup can be run again -} diff --git a/branches/fceux-2.2.2/src/types.h b/branches/fceux-2.2.2/src/types.h deleted file mode 100644 index fca8d8fc..00000000 --- a/branches/fceux-2.2.2/src/types.h +++ /dev/null @@ -1,137 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2001 Aaron Oneal - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __FCEU_TYPES -#define __FCEU_TYPES - -///causes the code fragment argument to be compiled in if the build includes debugging -#ifdef FCEUDEF_DEBUGGER -#define DEBUG(X) X; -#else -#define DEBUG(X) -#endif - -#ifdef MSVC -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; -typedef signed char int8; -typedef signed short int16; -typedef signed int int32; -#define dup _dup -#define stat _stat -#define fstat _fstat -#define mkdir _mkdir -#define alloca _alloca -#define snprintf _snprintf -#if _MSC_VER < 1500 -#define vsnprintf _vsnprintf -#endif -#define W_OK 2 -#define R_OK 2 -#define X_OK 1 -#define F_OK 0 -#define PATH_MAX 260 -#else - -//mingw32 doesnt prototype this for some reason -#ifdef __MINGW32__ -#define alloca __builtin_alloca -#endif - -#include -#include -#include -#include -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -#endif - -#ifdef __GNUC__ - typedef unsigned long long uint64; - typedef uint64 u64; - typedef long long int64; - #define INLINE inline - #define GINLINE inline -#elif MSVC - typedef __int64 int64; - typedef unsigned __int64 uint64; - #define __restrict__ - #define INLINE __inline - #define GINLINE /* Can't declare a function INLINE - and global in MSVC. Bummer. - */ - #define PSS_STYLE 2 /* Does MSVC compile for anything - other than Windows/DOS targets? - */ - - #if _MSC_VER >= 1300 - #pragma warning(disable:4244) //warning C4244: '=' : conversion from 'uint32' to 'uint8', possible loss of data - #pragma warning(disable:4996) //'strdup' was declared deprecated -#endif - - #if _MSC_VER < 1400 - #define vsnprintf _vsnprintf - #endif -#endif - -#if PSS_STYLE==2 - -#define PSS "\\" -#define PS '\\' - -#elif PSS_STYLE==1 - -#define PSS "/" -#define PS '/' - -#elif PSS_STYLE==3 - -#define PSS "\\" -#define PS '\\' - -#elif PSS_STYLE==4 - -#define PSS ":" -#define PS ':' - -#else - -#error PSS_STYLE undefined or invalid; see "types.h" for possible values, and add as compile-time option. - -#endif - - -typedef void (*writefunc)(uint32 A, uint8 V); -typedef uint8 (*readfunc)(uint32 A); - -#ifndef CTASSERT -#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1]; -#endif - -#include "utils/endian.h" - -#endif diff --git a/branches/fceux-2.2.2/src/unif.cpp b/branches/fceux-2.2.2/src/unif.cpp deleted file mode 100644 index 0238d441..00000000 --- a/branches/fceux-2.2.2/src/unif.cpp +++ /dev/null @@ -1,607 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* TODO: Battery backup file saving, mirror force */ -/* **INCOMPLETE** */ -/* Override stuff: CHR RAM instead of CHR ROM, mirroring. */ - -#include "types.h" -#include "fceu.h" -#include "cart.h" -#include "unif.h" -#include "ines.h" -#include "utils/endian.h" -#include "utils/memory.h" -#include "utils/md5.h" -#include "state.h" -#include "file.h" -#include "input.h" -#include "driver.h" - -#include -#include -#include - -typedef struct { - char ID[4]; - uint32 info; -} UNIF_HEADER; - -typedef struct { - char *name; - void (*init)(CartInfo *); - int flags; -} BMAPPING; - -typedef struct { - char *name; - int (*init)(FCEUFILE *fp); -} BFMAPPING; - -static CartInfo UNIFCart; - -static int vramo; -static int mirrortodo; -static uint8 *boardname; -static uint8 *sboardname; - -static uint32 CHRRAMSize; -uint8 *UNIFchrrama = 0; - -static UNIF_HEADER unhead; -static UNIF_HEADER uchead; - - -static uint8 *malloced[32]; -static uint32 mallocedsizes[32]; - -static int FixRomSize(uint32 size, uint32 minimum) { - uint32 x = 1; - - if (size < minimum) - return minimum; - while (x < size) - x <<= 1; - return x; -} - -static void FreeUNIF(void) { - int x; - if (UNIFchrrama) { - free(UNIFchrrama); UNIFchrrama = 0; - } - if (boardname) { - free(boardname); boardname = 0; - } - for (x = 0; x < 32; x++) { - if (malloced[x]) { - free(malloced[x]); malloced[x] = 0; - } - } -} - -static void ResetUNIF(void) { - int x; - for (x = 0; x < 32; x++) - malloced[x] = 0; - vramo = 0; - boardname = 0; - mirrortodo = 0; - memset(&UNIFCart, 0, sizeof(UNIFCart)); - UNIFchrrama = 0; -} - -static uint8 exntar[2048]; - -static void MooMirroring(void) { - if (mirrortodo < 0x4) - SetupCartMirroring(mirrortodo, 1, 0); - else if (mirrortodo == 0x4) { - SetupCartMirroring(4, 1, exntar); - AddExState(exntar, 2048, 0, "EXNR"); - } else - SetupCartMirroring(0, 0, 0); -} - -static int DoMirroring(FCEUFILE *fp) { - int t; - uint32 i; - if (uchead.info == 1) { - if ((t = FCEU_fgetc(fp)) == EOF) - return(0); - mirrortodo = t; - { - static char *stuffo[6] = { "Horizontal", "Vertical", "$2000", "$2400", "\"Four-screen\"", "Controlled by Mapper Hardware" }; - if (t < 6) - FCEU_printf(" Name/Attribute Table Mirroring: %s\n", stuffo[t]); - } - } else { - FCEU_printf(" Incorrect Mirroring Chunk Size (%d). Data is:", uchead.info); - for (i = 0; i < uchead.info; i++) { - if ((t = FCEU_fgetc(fp)) == EOF) - return(0); - FCEU_printf(" %02x", t); - } - FCEU_printf("\n Default Name/Attribute Table Mirroring: Horizontal\n", uchead.info); - mirrortodo = 0; - } - return(1); -} - -static int NAME(FCEUFILE *fp) { - char namebuf[100]; - int index; - int t; - - FCEU_printf(" Name: "); - index = 0; - - while ((t = FCEU_fgetc(fp)) > 0) - if (index < 99) - namebuf[index++] = t; - - namebuf[index] = 0; - FCEU_printf("%s\n", namebuf); - - if (!GameInfo->name) { - GameInfo->name = (uint8*)malloc(strlen(namebuf) + 1); //mbg merge 7/17/06 added cast - strcpy((char*)GameInfo->name, namebuf); //mbg merge 7/17/06 added cast - } - return(1); -} - -static int DINF(FCEUFILE *fp) { - char name[100], method[100]; - uint8 d, m; - uint16 y; - int t; - - if (FCEU_fread(name, 1, 100, fp) != 100) - return(0); - if ((t = FCEU_fgetc(fp)) == EOF) return(0); - d = t; - if ((t = FCEU_fgetc(fp)) == EOF) return(0); - m = t; - if ((t = FCEU_fgetc(fp)) == EOF) return(0); - y = t; - if ((t = FCEU_fgetc(fp)) == EOF) return(0); - y |= t << 8; - if (FCEU_fread(method, 1, 100, fp) != 100) - return(0); - name[99] = method[99] = 0; - FCEU_printf(" Dumped by: %s\n", name); - FCEU_printf(" Dumped with: %s\n", method); - { - char *months[12] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" - }; - FCEU_printf(" Dumped on: %s %d, %d\n", months[(m - 1) % 12], d, y); - } - return(1); -} - -static int CTRL(FCEUFILE *fp) { - int t; - uint32 i; - if (uchead.info == 1) { - if ((t = FCEU_fgetc(fp)) == EOF) - return(0); - /* The information stored in this byte isn't very helpful, but it's - better than nothing...maybe. - */ - - if (t & 1) - GameInfo->input[0] = GameInfo->input[1] = SI_GAMEPAD; - else - GameInfo->input[0] = GameInfo->input[1] = SI_NONE; - if (t & 2) - GameInfo->input[1] = SI_ZAPPER; - } else { - FCEU_printf(" Incorrect Control Chunk Size (%d). Data is:", uchead.info); - for (i = 0; i < uchead.info; i++) { - t = FCEU_fgetc(fp); - FCEU_printf(" %02x", t); - } - FCEU_printf("\n"); - GameInfo->input[0] = GameInfo->input[1] = SI_GAMEPAD; - } - return(1); -} - -static int TVCI(FCEUFILE *fp) { - int t; - if ((t = FCEU_fgetc(fp)) == EOF) - return(0); - if (t <= 2) { - char *stuffo[3] = { "NTSC", "PAL", "NTSC and PAL" }; - if (t == 0) { - GameInfo->vidsys = GIV_NTSC; - FCEUI_SetVidSystem(0); - } else if (t == 1) { - GameInfo->vidsys = GIV_PAL; - FCEUI_SetVidSystem(1); - } - FCEU_printf(" TV Standard Compatibility: %s\n", stuffo[t]); - } - return(1); -} - -static int EnableBattery(FCEUFILE *fp) { - FCEU_printf(" Battery-backed.\n"); - if (FCEU_fgetc(fp) == EOF) - return(0); - UNIFCart.battery = 1; - return(1); -} - -static int LoadPRG(FCEUFILE *fp) { - int z, t; - z = uchead.ID[3] - '0'; - - if (z < 0 || z > 15) - return(0); - FCEU_printf(" PRG ROM %d size: %d", z, (int)uchead.info); - if (malloced[z]) - free(malloced[z]); - t = FixRomSize(uchead.info, 2048); - if (!(malloced[z] = (uint8*)FCEU_malloc(t))) - return(0); - mallocedsizes[z] = t; - memset(malloced[z] + uchead.info, 0xFF, t - uchead.info); - if (FCEU_fread(malloced[z], 1, uchead.info, fp) != uchead.info) { - FCEU_printf("Read Error!\n"); - return(0); - } else - FCEU_printf("\n"); - - SetupCartPRGMapping(z, malloced[z], t, 0); - return(1); -} - -static int SetBoardName(FCEUFILE *fp) { - if (!(boardname = (uint8*)FCEU_malloc(uchead.info + 1))) - return(0); - FCEU_fread(boardname, 1, uchead.info, fp); - boardname[uchead.info] = 0; - FCEU_printf(" Board name: %s\n", boardname); - sboardname = boardname; - if (!memcmp(boardname, "NES-", 4) || !memcmp(boardname, "UNL-", 4) || !memcmp(boardname, "HVC-", 4) || !memcmp(boardname, "BTL-", 4) || !memcmp(boardname, "BMC-", 4)) - sboardname += 4; - return(1); -} - -static int LoadCHR(FCEUFILE *fp) { - int z, t; - z = uchead.ID[3] - '0'; - if (z < 0 || z > 15) - return(0); - FCEU_printf(" CHR ROM %d size: %d", z, (int)uchead.info); - if (malloced[16 + z]) - free(malloced[16 + z]); - t = FixRomSize(uchead.info, 8192); - if (!(malloced[16 + z] = (uint8*)FCEU_malloc(t))) - return(0); - mallocedsizes[16 + z] = t; - memset(malloced[16 + z] + uchead.info, 0xFF, t - uchead.info); - if (FCEU_fread(malloced[16 + z], 1, uchead.info, fp) != uchead.info) { - FCEU_printf("Read Error!\n"); - return(0); - } else - FCEU_printf("\n"); - - SetupCartCHRMapping(z, malloced[16 + z], t, 0); - return(1); -} - -#define BMCFLAG_FORCE4 1 -#define BMCFLAG_16KCHRR 2 -#define BMCFLAG_32KCHRR 4 -#define BMCFLAG_EXPCHRR 8 - -static BMAPPING bmap[] = { - { "11160", BMC11160_Init, 0 }, - { "12-IN-1", BMC12IN1_Init, 0 }, - { "13in1JY110", BMC13in1JY110_Init, 0 }, - { "190in1", BMC190in1_Init, 0 }, - { "22211", UNL22211_Init, 0 }, - { "3D-BLOCK", UNL3DBlock_Init, 0 }, - { "411120-C", BMC411120C_Init, 0 }, - { "42in1ResetSwitch", Mapper226_Init, 0 }, - { "43272", UNL43272_Init, 0 }, - { "603-5052", UNL6035052_Init, 0 }, - { "64in1NoRepeat", BMC64in1nr_Init, 0 }, - { "70in1", BMC70in1_Init, 0 }, - { "70in1B", BMC70in1B_Init, 0 }, - { "810544-C-A1", BMC810544CA1_Init, 0 }, - { "8157", UNL8157_Init, 0 }, - { "8237", UNL8237_Init, 0 }, - { "8237A", UNL8237A_Init, 0 }, - { "830118C", BMC830118C_Init, 0 }, - { "A65AS", BMCA65AS_Init, 0 }, - { "AC08", AC08_Init, 0 }, - { "ANROM", ANROM_Init, 0 }, - { "AX5705", UNLAX5705_Init, 0 }, - { "BB", UNLBB_Init, 0 }, - { "BS-5", BMCBS5_Init, 0 }, - { "CC-21", UNLCC21_Init, 0 }, - { "CITYFIGHT", UNLCITYFIGHT_Init, 0 }, - { "CNROM", CNROM_Init, 0 }, - { "CPROM", CPROM_Init, BMCFLAG_16KCHRR }, - { "D1038", BMCD1038_Init, 0 }, - { "DANCE", UNLOneBus_Init, 0 }, // redundant - { "DANCE2000", UNLD2000_Init, 0 }, - { "DREAMTECH01", DreamTech01_Init, 0 }, - { "EDU2000", UNLEDU2000_Init, 0 }, - { "EKROM", EKROM_Init, 0 }, - { "ELROM", ELROM_Init, 0 }, - { "ETROM", ETROM_Init, 0 }, - { "EWROM", EWROM_Init, 0 }, - { "FK23C", BMCFK23C_Init, BMCFLAG_EXPCHRR }, - { "FK23CA", BMCFK23CA_Init, BMCFLAG_EXPCHRR }, - { "FS304", UNLFS304_Init, 0 }, - { "G-146", BMCG146_Init, 0 }, - { "GK-192", BMCGK192_Init, 0 }, - { "GS-2004", BMCGS2004_Init, 0 }, - { "GS-2013", BMCGS2013_Init, 0 }, - { "Ghostbusters63in1", BMCGhostbusters63in1_Init, 0 }, - { "H2288", UNLH2288_Init, 0 }, - { "HKROM", HKROM_Init, 0 }, - { "KOF97", UNLKOF97_Init, 0 }, - { "KONAMI-QTAI", Mapper190_Init, 0 }, - { "KS7012", UNLKS7012_Init, 0 }, - { "KS7013B", UNLKS7013B_Init, 0 }, - { "KS7017", UNLKS7017_Init, 0 }, - { "KS7030", UNLKS7030_Init, 0 }, - { "KS7031", UNLKS7031_Init, 0 }, - { "KS7032", UNLKS7032_Init, 0 }, - { "KS7037", UNLKS7037_Init, 0 }, - { "KS7057", UNLKS7057_Init, 0 }, - { "LE05", LE05_Init, 0 }, - { "LH10", LH10_Init, 0 }, - { "LH32", LH32_Init, 0 }, - { "LH53", LH53_Init, 0 }, - { "MALISB", UNLMaliSB_Init, 0 }, - { "MARIO1-MALEE2", MALEE_Init, 0 }, - { "MHROM", MHROM_Init, 0 }, - { "N625092", UNLN625092_Init, 0 }, - { "NROM", NROM_Init, 0 }, - { "NROM-128", NROM_Init, 0 }, - { "NROM-256", NROM_Init, 0 }, - { "NTBROM", Mapper68_Init, 0 }, - { "NTD-03", BMCNTD03_Init, 0 }, - { "NovelDiamond9999999in1", Novel_Init, 0 }, - { "OneBus", UNLOneBus_Init, 0 }, - { "PEC-586", UNLPEC586Init, 0 }, - { "RROM", NROM_Init, 0 }, - { "RROM-128", NROM_Init, 0 }, - { "SA-002", TCU02_Init, 0 }, - { "SA-0036", SA0036_Init, 0 }, - { "SA-0037", SA0037_Init, 0 }, - { "SA-009", SA009_Init, 0 }, - { "SA-016-1M", SA0161M_Init, 0 }, - { "SA-72007", SA72007_Init, 0 }, - { "SA-72008", SA72008_Init, 0 }, - { "SA-9602B", SA9602B_Init, BMCFLAG_32KCHRR }, - { "SA-NROM", TCA01_Init, 0 }, - { "SAROM", SAROM_Init, 0 }, - { "SBROM", SBROM_Init, 0 }, - { "SC-127", UNLSC127_Init, 0 }, - { "SCROM", SCROM_Init, 0 }, - { "SEROM", SEROM_Init, 0 }, - { "SGROM", SGROM_Init, 0 }, - { "SHERO", UNLSHeroes_Init, 0 }, - { "SKROM", SKROM_Init, 0 }, - { "SL12", UNLSL12_Init, 0 }, - { "SL1632", UNLSL1632_Init, 0 }, - { "SL1ROM", SL1ROM_Init, 0 }, - { "SLROM", SLROM_Init, 0 }, - { "SMB2J", UNLSMB2J_Init, 0 }, - { "SNROM", SNROM_Init, 0 }, - { "SOROM", SOROM_Init, 0 }, - { "SSS-NROM-256", SSSNROM_Init, 0 }, - { "SUNSOFT_UNROM", SUNSOFT_UNROM_Init, 0 }, // fix me, real pcb name, real pcb type - { "Sachen-74LS374N", S74LS374N_Init, 0 }, - { "Sachen-74LS374NA", S74LS374NA_Init, 0 }, //seems to be custom mapper - { "Sachen-8259A", S8259A_Init, 0 }, - { "Sachen-8259B", S8259B_Init, 0 }, - { "Sachen-8259C", S8259C_Init, 0 }, - { "Sachen-8259D", S8259D_Init, 0 }, - { "Super24in1SC03", Super24_Init, 0 }, - { "SuperHIK8in1", Mapper45_Init, 0 }, - { "Supervision16in1", Supervision16_Init, 0 }, - { "T-227-1", BMCT2271_Init, 0 }, - { "T-230", UNLT230_Init, 0 }, - { "T-262", BMCT262_Init, 0 }, - { "TBROM", TBROM_Init, 0 }, - { "TC-U01-1.5M", TCU01_Init, 0 }, - { "TEK90", Mapper90_Init, 0 }, - { "TEROM", TEROM_Init, 0 }, - { "TF1201", UNLTF1201_Init, 0 }, - { "TFROM", TFROM_Init, 0 }, - { "TGROM", TGROM_Init, 0 }, - { "TKROM", TKROM_Init, 0 }, - { "TKSROM", TKSROM_Init, 0 }, - { "TLROM", TLROM_Init, 0 }, - { "TLSROM", TLSROM_Init, 0 }, - { "TQROM", TQROM_Init, 0 }, - { "TR1ROM", TFROM_Init, BMCFLAG_FORCE4 }, - { "TSROM", TSROM_Init, 0 }, - { "TVROM", TLROM_Init, BMCFLAG_FORCE4 }, - { "Transformer", Transformer_Init, 0 }, - { "UNROM", UNROM_Init, 0 }, - { "UOROM", UNROM_Init, 0 }, - { "VRC7", UNLVRC7_Init, 0 }, - { "YOKO", UNLYOKO_Init, 0 }, - - { 0, 0, 0 } -}; - -static BFMAPPING bfunc[] = { - { "CTRL", CTRL }, - { "TVCI", TVCI }, - { "BATR", EnableBattery }, - { "MIRR", DoMirroring }, - { "PRG", LoadPRG }, - { "CHR", LoadCHR }, - { "NAME", NAME }, - { "MAPR", SetBoardName }, - { "DINF", DINF }, - { NULL, NULL } -}; - -int LoadUNIFChunks(FCEUFILE *fp) { - int x; - int t; - for (;; ) { - t = FCEU_fread(&uchead, 1, 4, fp); - if (t < 4) { - if (t > 0) - return 0; - return 1; - } - if (!(FCEU_read32le(&uchead.info, fp))) - return 0; - t = 0; - x = 0; - while (bfunc[x].name) { - if (!memcmp(&uchead, bfunc[x].name, strlen(bfunc[x].name))) { - if (!bfunc[x].init(fp)) - return 0; - t = 1; - break; - } - x++; - } - if (!t) - if (FCEU_fseek(fp, uchead.info, SEEK_CUR) < 0) - return(0); - } -} - -static int InitializeBoard(void) { - int x = 0; - - if (!sboardname) return(0); - - while (bmap[x].name) { - if (!strcmp((char*)sboardname, (char*)bmap[x].name)) { - if (!malloced[16]) { - if (bmap[x].flags & BMCFLAG_16KCHRR) - CHRRAMSize = 16384; - else if (bmap[x].flags & BMCFLAG_32KCHRR) - CHRRAMSize = 32768; - else if (bmap[x].flags & BMCFLAG_EXPCHRR) - CHRRAMSize = 128 * 1024; - else - CHRRAMSize = 8192; - if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) { - SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1); - AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR"); - } else - return(-1); - } - if (bmap[x].flags & BMCFLAG_FORCE4) - mirrortodo = 4; - MooMirroring(); - bmap[x].init(&UNIFCart); - return(1); - } - x++; - } - FCEU_PrintError("Board type not supported."); - return(0); -} - -static void UNIFGI(GI h) { - switch (h) { - case GI_RESETSAVE: - FCEU_ClearGameSave(&UNIFCart); - break; - - case GI_RESETM2: - if (UNIFCart.Reset) - UNIFCart.Reset(); - break; - case GI_POWER: - if (UNIFCart.Power) - UNIFCart.Power(); - if (UNIFchrrama) memset(UNIFchrrama, 0, 8192); - break; - case GI_CLOSE: - FCEU_SaveGameSave(&UNIFCart); - if (UNIFCart.Close) - UNIFCart.Close(); - FreeUNIF(); - break; - } -} - -int UNIFLoad(const char *name, FCEUFILE *fp) { - FCEU_fseek(fp, 0, SEEK_SET); - FCEU_fread(&unhead, 1, 4, fp); - if (memcmp(&unhead, "UNIF", 4)) - return 0; - - ResetCartMapping(); - - ResetExState(0, 0); - ResetUNIF(); - if (!FCEU_read32le(&unhead.info, fp)) - goto aborto; - if (FCEU_fseek(fp, 0x20, SEEK_SET) < 0) - goto aborto; - if (!LoadUNIFChunks(fp)) - goto aborto; - { - int x; - struct md5_context md5; - - md5_starts(&md5); - - for (x = 0; x < 32; x++) - if (malloced[x]) { - md5_update(&md5, malloced[x], mallocedsizes[x]); - } - md5_finish(&md5, UNIFCart.MD5); - FCEU_printf(" ROM MD5: 0x"); - for (x = 0; x < 16; x++) - FCEU_printf("%02x", UNIFCart.MD5[x]); - FCEU_printf("\n"); - memcpy(&GameInfo->MD5, &UNIFCart.MD5, sizeof(UNIFCart.MD5)); - } - - if (!InitializeBoard()) - goto aborto; - - FCEU_LoadGameSave(&UNIFCart); - - strcpy(LoadedRomFName, name); //For the debugger list - GameInterface = UNIFGI; - return 1; - - aborto: - - FreeUNIF(); - ResetUNIF(); - - - return 0; -} diff --git a/branches/fceux-2.2.2/src/unif.h b/branches/fceux-2.2.2/src/unif.h deleted file mode 100644 index 758a693d..00000000 --- a/branches/fceux-2.2.2/src/unif.h +++ /dev/null @@ -1,147 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -void AC08_Init(CartInfo *info); -void ANROM_Init(CartInfo *info); -void BMC11160_Init(CartInfo *info); -void BMC12IN1_Init(CartInfo *info); -void BMC13in1JY110_Init(CartInfo *info); -void BMC190in1_Init(CartInfo *info); -void BMC411120C_Init(CartInfo *info); -void BMC64in1nr_Init(CartInfo *info); -void BMC70in1B_Init(CartInfo *info); -void BMC70in1_Init(CartInfo *info); -void BMC810544CA1_Init(CartInfo *info); -void BMC830118C_Init(CartInfo *info); -void BMCA65AS_Init(CartInfo *info); -void BMCBS5_Init(CartInfo *info); -void BMCD1038_Init(CartInfo *info); -void BMCFK23CA_Init(CartInfo *info); -void BMCFK23C_Init(CartInfo *info); -void BMCG146_Init(CartInfo *info); -void BMCGK192_Init(CartInfo *info); -void BMCGS2004_Init(CartInfo *info); -void BMCGS2013_Init(CartInfo *info); -void BMCGhostbusters63in1_Init(CartInfo *info); -void BMCNTD03_Init(CartInfo *info); -void BMCT2271_Init(CartInfo *info); -void BMCT262_Init(CartInfo *info); -void CNROM_Init(CartInfo *info); -void CPROM_Init(CartInfo *info); -void DreamTech01_Init(CartInfo *info); -void EKROM_Init(CartInfo *info); -void ELROM_Init(CartInfo *info); -void ETROM_Init(CartInfo *info); -void EWROM_Init(CartInfo *info); -void GNROM_Init(CartInfo *info); -void HKROM_Init(CartInfo *info); -void LE05_Init(CartInfo *info); -void LH10_Init(CartInfo *info); -void LH32_Init(CartInfo *info); -void LH53_Init(CartInfo *info); -void MALEE_Init(CartInfo *info); -void MHROM_Init(CartInfo *info); -void Mapper190_Init(CartInfo *info); -void NROM_Init(CartInfo *info); -void Novel_Init(CartInfo *info); -void S74LS374NA_Init(CartInfo *info); -void S74LS374N_Init(CartInfo *info); -void S8259A_Init(CartInfo *info); -void S8259B_Init(CartInfo *info); -void S8259C_Init(CartInfo *info); -void S8259D_Init(CartInfo *info); -void SA0036_Init(CartInfo *info); -void SA0037_Init(CartInfo *info); -void SA009_Init(CartInfo *info); -void SA0161M_Init(CartInfo *info); -void SA72007_Init(CartInfo *info); -void SA72008_Init(CartInfo *info); -void SA9602B_Init(CartInfo *info); -void SAROM_Init(CartInfo *info); -void SBROM_Init(CartInfo *info); -void SCROM_Init(CartInfo *info); -void SEROM_Init(CartInfo *info); -void SGROM_Init(CartInfo *info); -void SKROM_Init(CartInfo *info); -void SL1ROM_Init(CartInfo *info); -void SLROM_Init(CartInfo *info); -void SNROM_Init(CartInfo *info); -void SOROM_Init(CartInfo *info); -void SSSNROM_Init(CartInfo *info); -void SUNSOFT_UNROM_Init(CartInfo *info); // "Shanghi" original version mapper -void Super24_Init(CartInfo *info); -void Supervision16_Init(CartInfo *info); -void TBROM_Init(CartInfo *info); -void TCA01_Init(CartInfo *info); -void TCU01_Init(CartInfo *info); -void TCU02_Init(CartInfo *info); -void TEROM_Init(CartInfo *info); -void TFROM_Init(CartInfo *info); -void TGROM_Init(CartInfo *info); -void TKROM_Init(CartInfo *info); -void TKSROM_Init(CartInfo *info); -void TLROM_Init(CartInfo *info); -void TLSROM_Init(CartInfo *info); -void TQROM_Init(CartInfo *info); -void TQROM_Init(CartInfo *info); -void TSROM_Init(CartInfo *info); -void Transformer_Init(CartInfo *info); -void UNL22211_Init(CartInfo *info); -void UNL3DBlock_Init(CartInfo *info); -void UNL43272_Init(CartInfo *info); -void UNL6035052_Init(CartInfo *info); -void UNL8157_Init(CartInfo *info); -void UNL8237A_Init(CartInfo *info); -void UNL8237_Init(CartInfo *info); -void UNLA9746_Init(CartInfo *info); -void UNLAX5705_Init(CartInfo *info); -void UNLBB_Init(CartInfo *info); -void UNLCC21_Init(CartInfo *info); -void UNLCITYFIGHT_Init(CartInfo *info); -void UNLD2000_Init(CartInfo *info); -void UNLEDU2000_Init(CartInfo *info); -void UNLFS304_Init(CartInfo *info); -void UNLH2288_Init(CartInfo *info); -void UNLKOF97_Init(CartInfo *info); -void UNLKS7012_Init(CartInfo *info); -void UNLKS7013B_Init(CartInfo *info); -void UNLKS7017_Init(CartInfo *info); -void UNLKS7030_Init(CartInfo *info); -void UNLKS7031_Init(CartInfo *info); -void UNLKS7032_Init(CartInfo *info); -void UNLKS7037_Init(CartInfo *info); -void UNLKS7057_Init(CartInfo *info); -void UNLN625092_Init(CartInfo *info); -void UNLMaliSB_Init(CartInfo *info); -void UNLOneBus_Init(CartInfo *info); -void UNLPEC586Init(CartInfo *info); -void UNLSC127_Init(CartInfo *info); -void UNLSHeroes_Init(CartInfo *info); -void UNLSL12_Init(CartInfo *info); -void UNLSL1632_Init(CartInfo *info); -void UNLSMB2J_Init(CartInfo *info); -void UNLT230_Init(CartInfo *info); -void UNLTF1201_Init(CartInfo *info); -void UNLVRC7_Init(CartInfo *info); -void UNLYOKO_Init(CartInfo *info); -void UNROM_Init(CartInfo *info); - -extern uint8 *UNIFchrrama; // Meh. So I can stop CHR RAM - // bank switcherooing with certain boards... diff --git a/branches/fceux-2.2.2/src/version.h b/branches/fceux-2.2.2/src/version.h deleted file mode 100644 index 1688041c..00000000 --- a/branches/fceux-2.2.2/src/version.h +++ /dev/null @@ -1,67 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2001 Aaron Oneal - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define PUBLIC_RELEASE // uncomment this when making a public release, but comment back before committing - -#ifndef __FCEU_VERSION -#define __FCEU_VERSION - -//todo - everyone will want to support this eventually, i suppose -#ifdef _MSC_VER -#include "svnrev.h" -#else -#ifdef SVN_REV -#define SVN_REV_STR SVN_REV -#else -#define SVN_REV_STR "" -#endif -#endif - -#define FCEU_NAME "FCEUX" - -#define FCEU_FEATURE_STRING "" - -#ifdef _DEBUG -#define FCEU_SUBVERSION_STRING " debug" -#elif defined(PUBLIC_RELEASE) -#define FCEU_SUBVERSION_STRING "" -#else -#define FCEU_SUBVERSION_STRING "-interim svn" SVN_REV_STR -#endif - -#if defined(_MSC_VER) -#define FCEU_COMPILER "" -#define FCEU_COMPILER_DETAIL " msvc " _Py_STRINGIZE(_MSC_VER) -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X -#define _Py_STRINGIZE2(X) #X -//re: http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5 -#else -// TODO: make for others compilers -#define FCEU_COMPILER "" -#define FCEU_COMPILER_DETAIL "" -#endif - -#define FCEU_VERSION_NUMERIC 22020 -#define FCEU_VERSION_STRING "2.2.2" FCEU_SUBVERSION_STRING FCEU_FEATURE_STRING FCEU_COMPILER -#define FCEU_NAME_AND_VERSION FCEU_NAME " " FCEU_VERSION_STRING - -#endif diff --git a/branches/fceux-2.2.2/src/video.cpp b/branches/fceux-2.2.2/src/video.cpp deleted file mode 100644 index 095d4105..00000000 --- a/branches/fceux-2.2.2/src/video.cpp +++ /dev/null @@ -1,779 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "types.h" -#include "video.h" -#include "fceu.h" -#include "file.h" -#include "utils/memory.h" -#include "utils/crc32.h" -#include "state.h" -#include "movie.h" -#include "palette.h" -#include "nsf.h" -#include "input.h" -#include "vsuni.h" -#include "drawing.h" -#include "driver.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -#ifdef WIN32 -#include "drivers/win/common.h" //For DirectX constants -#include "drivers/win/input.h" -#endif - -#ifdef CREATE_AVI -#include "drivers/videolog/nesvideos-piece.h" -#endif - -//no stdint in win32 (but we could add it if we needed to) -#ifndef WIN32 -#include -#endif - -#include -#include -#include -#include -#include - -uint8 *XBuf=NULL; -uint8 *XBackBuf=NULL; -int ClipSidesOffset=0; //Used to move displayed messages when Clips left and right sides is checked -static uint8 *xbsave=NULL; - -GUIMESSAGE guiMessage; -GUIMESSAGE subtitleMessage; - -//for input display -extern int input_display; -extern uint32 cur_input_display; - -bool oldInputDisplay = false; - -unsigned int lastu = 0; - -std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function - -void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; } -std::string FCEUI_GetSnapshotAsName() { return AsSnapshotName; } - -void FCEU_KillVirtualVideo(void) -{ - //mbg merge TODO 7/17/06 temporarily removed - //if(xbsave) - //{ - // free(xbsave); - // xbsave=0; - //} - //if(XBuf) - //{ - //UnmapViewOfFile(XBuf); - //CloseHandle(mapXBuf); - //mapXBuf=NULL; - //} - //if(XBackBuf) - //{ - // free(XBackBuf); - // XBackBuf=0; - //} -} - -/** -* Return: Flag that indicates whether the function was succesful or not. -* -* TODO: This function is Windows-only. It should probably be moved. -**/ -int FCEU_InitVirtualVideo(void) -{ - if(!XBuf) /* Some driver code may allocate XBuf externally. */ - /* 256 bytes per scanline, * 240 scanline maximum, +16 for alignment, - */ - - if(!(XBuf= (uint8*) (FCEU_malloc(256 * 256 + 16))) || - !(XBackBuf= (uint8*) (FCEU_malloc(256 * 256 + 16)))) - { - return 0; - } - - xbsave = XBuf; - - if( sizeof(uint8*) == 4 ) - { - uintptr_t m = (uintptr_t)XBuf; - m = ( 8 - m) & 7; - XBuf+=m; - } - - memset(XBuf,128,256*256); //*240); - memset(XBackBuf,128,256*256); - - return 1; -} - -#ifdef FRAMESKIP -void FCEU_PutImageDummy(void) -{ - ShowFPS(); - if(GameInfo->type!=GIT_NSF) - { - FCEU_DrawNTSCControlBars(XBuf); - FCEU_DrawSaveStates(XBuf); - FCEU_DrawMovies(XBuf); - } - if(guiMessage.howlong) guiMessage.howlong--; /* DrawMessage() */ -} -#endif - -static int dosnapsave=0; -void FCEUI_SaveSnapshot(void) -{ - dosnapsave=1; -} - -void FCEUI_SaveSnapshotAs(void) -{ - dosnapsave=2; -} - -static void ReallySnap(void) -{ - int x=SaveSnapshot(); - if(!x) - FCEU_DispMessage("Error saving screen snapshot.",0); - else - FCEU_DispMessage("Screen snapshot %d saved.",0,x-1); -} - -void FCEU_PutImage(void) -{ - if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this? - { - char nameo[512]; - strcpy(nameo,FCEUI_GetSnapshotAsName().c_str()); - if (nameo[0]) - { - SaveSnapshot(nameo); - FCEU_DispMessage("Snapshot Saved.",0); - } - dosnapsave=0; - } - if(GameInfo->type==GIT_NSF) - { - DrawNSF(XBuf); - - //Save snapshot after NSF screen is drawn. Why would we want to do it before? - if(dosnapsave==1) - { - ReallySnap(); - dosnapsave=0; - } - } - else - { - //Save backbuffer before overlay stuff is written. - if(!FCEUI_EmulationPaused()) - memcpy(XBackBuf, XBuf, 256*256); - - //Some messages need to be displayed before the avi is dumped - DrawMessage(true); - -#ifdef _S9XLUA_H - // Lua gui should draw before the avi is dumped. - FCEU_LuaGui(XBuf); -#endif - - //Save snapshot - if(dosnapsave==1) - { - ReallySnap(); - dosnapsave=0; - } - - if (!FCEUI_AviEnableHUDrecording()) snapAVI(); - - if(GameInfo->type==GIT_VSUNI) - FCEU_VSUniDraw(XBuf); - - FCEU_DrawSaveStates(XBuf); - FCEU_DrawMovies(XBuf); - FCEU_DrawLagCounter(XBuf); - FCEU_DrawNTSCControlBars(XBuf); - FCEU_DrawRecordingStatus(XBuf); - ShowFPS(); - } - - if(FCEUD_ShouldDrawInputAids()) - FCEU_DrawInput(XBuf); - - //Fancy input display code - if(input_display) - { - extern uint32 JSAutoHeld; - uint32 held; - - int controller, c, ci, color; - int i, j; - uint32 on = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0x90:0xA7; //Standard, or Gray depending on movie mode - uint32 oni = 0xA0; //Color for immediate keyboard buttons - uint32 blend = 0xB6; //Blend of immiate and last held buttons - uint32 ahold = 0x87; //Auto hold - uint32 off = 0xCF; - - uint8 *t = XBuf+(FSettings.LastSLine-9)*256 + 20; //mbg merge 7/17/06 changed t to uint8* - if(input_display > 4) input_display = 4; - for(controller = 0; controller < input_display; controller++, t += 56) - { - for(i = 0; i < 34;i++) - for(j = 0; j <9 ; j++) - t[i+j*256] = (t[i+j*256] & 0x30) | 0xC1; - for(i = 3; i < 6; i++) - for(j = 3; j< 6; j++) - t[i+j*256] = 0xCF; - c = cur_input_display >> (controller * 8); - - // This doesn't work in anything except windows for now. - // It doesn't get set anywhere in other ports. -#ifdef WIN32 - if (!oldInputDisplay) ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:GetGamepadPressedImmediate() >> (controller * 8); - else ci = 0; - - if (!oldInputDisplay && !FCEUMOV_Mode(MOVIEMODE_PLAY)) held = (JSAutoHeld >> (controller * 8)); - else held = 0; -#else - // Put other port info here - ci = 0; - held = 0; -#endif - - //adelikat: I apologize to anyone who ever sifts through this color assignment - //A - if (held&1) { //If auto-hold - if (!(ci&1) ) color = ahold; - else - color = (c&1) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&1) color = (ci&1) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&1) ? oni : off; - } - for(i=0; i < 4; i++) - { - for(j = 0; j < 4; j++) - { - if(i%3==0 && j %3 == 0) - continue; - t[30+4*256+i+j*256] = color; - } - } - //B - if (held&2) { //If auto-hold - if (!(ci&2) ) color = ahold; - else - color = (c&2) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&2) color = (ci&2) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&2) ? oni : off; - } - for(i=0; i < 4; i++) - { - for(j = 0; j < 4; j++) - { - if(i%3==0 && j %3 == 0) - continue; - t[24+4*256+i+j*256] = color; - } - } - //Select - if (held&4) { //If auto-hold - if (!(ci&4) ) color = ahold; - else - color = (c&4) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&4) color = (ci&4) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&4) ? oni : off; - } - for(i = 0; i < 4; i++) - { - t[11+5*256+i] = color; - t[11+6*256+i] = color; - } - //Start - if (held&8) { //If auto-hold - if (!(ci&8) ) color = ahold; - else - color = (c&8) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&8) color = (ci&8) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&8) ? oni : off; - } - for(i = 0; i < 4; i++) - { - t[17+5*256+i] = color; - t[17+6*256+i] = color; - } - //Up - if (held&16) { //If auto-hold - if (!(ci&16) ) color = ahold; - else - color = (c&16) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&16) color = (ci&16) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&16) ? oni : off; - } - for(i = 0; i < 3; i++) - { - for(j = 0; j < 3; j++) - { - t[3+i+256*j] = color; - } - } - //Down - if (held&32) { //If auto-hold - if (!(ci&32) ) color = ahold; - else - color = (c&32) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&32) color = (ci&32) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&32) ? oni : off; - } - for(i = 0; i < 3; i++) - { - for(j = 0; j < 3; j++) - { - t[3+i+256*j+6*256] = color; - } - } - //Left - if (held&64) { //If auto-hold - if (!(ci&64) ) color = ahold; - else - color = (c&64) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&64) color = (ci&64) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&64) ? oni : off; - } - for(i = 0; i < 3; i++) - { - for(j = 0; j < 3; j++) - { - t[3*256+i+256*j] = color; - } - } - //Right - if (held&128) { //If auto-hold - if (!(ci&128) ) color = ahold; - else - color = (c&128) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! - } - else { - if (c&128) color = (ci&128) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors - else color = (ci&128) ? oni : off; - } - for(i = 0; i < 3; i++) - { - for(j = 0; j < 3; j++) - { - t[6+3*256+i+256*j] = color; - } - } - } - } - - if (FCEUI_AviEnableHUDrecording()) - { - if (FCEUI_AviDisableMovieMessages()) - { - snapAVI(); - DrawMessage(false); - } else - { - DrawMessage(false); - snapAVI(); - } - } else DrawMessage(false); - -} -void snapAVI() -{ - //Update AVI - if(!FCEUI_EmulationPaused()) - FCEUI_AviVideoUpdate(XBuf); -} - -void FCEU_DispMessageOnMovie(char *format, ...) -{ - va_list ap; - - va_start(ap,format); - vsnprintf(guiMessage.errmsg,sizeof(guiMessage.errmsg),format,ap); - va_end(ap); - - guiMessage.howlong = 180; - guiMessage.isMovieMessage = true; - guiMessage.linesFromBottom = 0; - - if (FCEUI_AviIsRecording() && FCEUI_AviDisableMovieMessages()) - guiMessage.howlong = 0; -} - -void FCEU_DispMessage(char *format, int disppos=0, ...) -{ - va_list ap; - - va_start(ap,disppos); - vsnprintf(guiMessage.errmsg,sizeof(guiMessage.errmsg),format,ap); - va_end(ap); - // also log messages - char temp[2048]; - va_start(ap,disppos); - vsnprintf(temp,sizeof(temp),format,ap); - va_end(ap); - strcat(temp, "\n"); - FCEU_printf(temp); - - guiMessage.howlong = 180; - guiMessage.isMovieMessage = false; - - guiMessage.linesFromBottom = disppos; - - //adelikat: Pretty sure this code fails, Movie playback stopped is done with FCEU_DispMessageOnMovie() - #ifdef CREATE_AVI - if(LoggingEnabled == 2) - { - /* While in AVI recording mode, only display bare minimum - * of messages - */ - if(strcmp(guiMessage.errmsg, "Movie playback stopped.") != 0) - guiMessage.howlong = 0; - } - #endif -} - -void FCEU_ResetMessages() -{ - guiMessage.howlong = 0; - guiMessage.isMovieMessage = false; - guiMessage.linesFromBottom = 0; -} - - -static int WritePNGChunk(FILE *fp, uint32 size, char *type, uint8 *data) -{ - uint32 crc; - - uint8 tempo[4]; - - tempo[0]=size>>24; - tempo[1]=size>>16; - tempo[2]=size>>8; - tempo[3]=size; - - if(fwrite(tempo,4,1,fp)!=1) - return 0; - if(fwrite(type,4,1,fp)!=1) - return 0; - - if(size) - if(fwrite(data,1,size,fp)!=size) - return 0; - - crc=CalcCRC32(0,(uint8 *)type,4); - if(size) - crc=CalcCRC32(crc,data,size); - - tempo[0]=crc>>24; - tempo[1]=crc>>16; - tempo[2]=crc>>8; - tempo[3]=crc; - - if(fwrite(tempo,4,1,fp)!=1) - return 0; - return 1; -} - -uint32 GetScreenPixel(int x, int y, bool usebackup) { - - uint8 r,g,b; - - if (((x < 0) || (x > 255)) || ((y < 0) || (y > 255))) - return -1; - - if (usebackup) - FCEUD_GetPalette(XBackBuf[(y*256)+x],&r,&g,&b); - else - FCEUD_GetPalette(XBuf[(y*256)+x],&r,&g,&b); - - - return ((int) (r) << 16) | ((int) (g) << 8) | (int) (b); -} - -int GetScreenPixelPalette(int x, int y, bool usebackup) { - - if (((x < 0) || (x > 255)) || ((y < 0) || (y > 255))) - return -1; - - if (usebackup) - return XBackBuf[(y*256)+x] & 0x3f; - else - return XBuf[(y*256)+x] & 0x3f; - -} - -int SaveSnapshot(void) -{ - int totallines=FSettings.LastSLine-FSettings.FirstSLine+1; - int x,u,y; - FILE *pp=NULL; - uint8 *compmem=NULL; - uLongf compmemsize=totallines*263+12; - - if(!(compmem=(uint8 *)FCEU_malloc(compmemsize))) - return 0; - - for (u = lastu; u < 99999; ++u) - { - pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb"); - if(pp==NULL) break; - fclose(pp); - } - lastu = u; - - if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb"))) - { - free(compmem); - return 0; - } - - { - static uint8 header[8]={137,80,78,71,13,10,26,10}; - if(fwrite(header,8,1,pp)!=1) - goto PNGerr; - } - - { - uint8 chunko[13]; - - chunko[0]=chunko[1]=chunko[3]=0; - chunko[2]=0x1; // Width of 256 - - chunko[4]=chunko[5]=chunko[6]=0; - chunko[7]=totallines; // Height - - chunko[8]=8; // bit depth - chunko[9]=3; // Color type; indexed 8-bit - chunko[10]=0; // compression: deflate - chunko[11]=0; // Basic adapative filter set(though none are used). - chunko[12]=0; // No interlace. - - if(!WritePNGChunk(pp,13,"IHDR",chunko)) - goto PNGerr; - } - - { - uint8 pdata[256*3]; - for(x=0;x<256;x++) - FCEUD_GetPalette(x,pdata+x*3,pdata+x*3+1,pdata+x*3+2); - if(!WritePNGChunk(pp,256*3,"PLTE",pdata)) - goto PNGerr; - } - - { - uint8 *tmp=XBuf+FSettings.FirstSLine*256; - uint8 *dest,*mal,*mork; - - if(!(mal=mork=dest=(uint8 *)FCEU_dmalloc((totallines<<8)+totallines))) - goto PNGerr; - // mork=dest=XBuf; - - for(y=0;y -#include - -#define IOPTION_GUN 0x1 -#define IOPTION_SWAPDIRAB 0x2 - -#define IOPTION_PREDIP 0x10 -typedef struct { - char *name; - uint64 md5partial; - int mapper; - int mirroring; - int ppu; - int ioption; - int predip; -} VSUNIENTRY; - -VSUNIENTRY *curvs; - -static uint8 DIPS = 0; -uint8 vsdip = 0; - -void FCEUI_VSUniToggleDIPView(void) { - DIPS = !DIPS; -} - -void FCEU_VSUniToggleDIP(int w) { - vsdip ^= 1 << w; -} - -void FCEUI_VSUniSetDIP(int w, int state) { - if (((vsdip >> w) & 1) != state) - FCEUI_VSUniToggleDIP(w); -} - -uint8 FCEUI_VSUniGetDIPs(void) { - return(vsdip); -} - -static uint8 secdata[2][32] = -{ - { - 0xff, 0xbf, 0xb7, 0x97, 0x97, 0x17, 0x57, 0x4f, - 0x6f, 0x6b, 0xeb, 0xa9, 0xb1, 0x90, 0x94, 0x14, - 0x56, 0x4e, 0x6f, 0x6b, 0xeb, 0xa9, 0xb1, 0x90, - 0xd4, 0x5c, 0x3e, 0x26, 0x87, 0x83, 0x13, 0x00 - }, - { - 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, - 0x00, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - } -}; - -static uint8 *secptr; - -static uint8 VSindex; - -static DECLFR(VSSecRead) { - switch (A) { - case 0x5e00: VSindex = 0; return X.DB; - case 0x5e01: return(secptr[(VSindex++) & 0x1F]); - } - return(0x00); -} -uint8 coinon = 0; - -void FCEU_VSUniCoin(void) { - coinon = 6; -} - -static int curppu; -static int64 curmd5; - -#define RP2C04_001 1 -#define RP2C04_002 2 -#define RP2C04_003 3 -#define RP2C05_004 4 -#define RCP2C03B 5 -#define RC2C05_01 6 -#define RC2C05_02 7 -#define RC2C05_03 8 -#define RC2C05_04 9 - -static readfunc OldReadPPU; -static writefunc OldWritePPU[2]; - -static DECLFR(A2002_Gumshoe) { - return((OldReadPPU(A) & ~0x3F) | 0x1C); -} - -static DECLFR(A2002_Topgun) { - return((OldReadPPU(A) & ~0x3F) | 0x1B); -} - -static DECLFR(A2002_MBJ) { // Mighty Bomb Jack - return((OldReadPPU(A) & ~0x3F) | 0x3D); -} - -static DECLFW(B2000_2001_2C05) { - OldWritePPU[(A & 1) ^ 1](A ^ 1, V); -} -static uint8 xevselect = 0; -static DECLFR(XevRead) { - if (A == 0x54FF) { - return(0x5); - } else if (A == 0x5678) { - return(xevselect ? 0 : 1); - } else if (A == 0x578F) { - return(xevselect ? 0xd1 : 0x89); - } else if (A == 0x5567) { - xevselect ^= 1; - return(xevselect ? 0x37 : 0x3E); - } - return(X.DB); -} - -void FCEU_VSUniSwap(uint8 *j0, uint8 *j1) { - if (curvs->ioption & IOPTION_SWAPDIRAB) { - uint16 t = *j0; - *j0 = (*j0 & 0xC) | (*j1 & 0xF3); - *j1 = (*j1 & 0xC) | (t & 0xF3); - } -} - -void FCEU_VSUniPower(void) { - coinon = 0; - VSindex = 0; - - if (secptr) - SetReadHandler(0x5e00, 0x5e01, VSSecRead); - - if (curppu == RC2C05_04) { - OldReadPPU = GetReadHandler(0x2002); - SetReadHandler(0x2002, 0x2002, A2002_Topgun); - } else if (curppu == RC2C05_03) { - OldReadPPU = GetReadHandler(0x2002); - SetReadHandler(0x2002, 0x2002, A2002_Gumshoe); - } else if (curppu == RC2C05_02) { - OldReadPPU = GetReadHandler(0x2002); - SetReadHandler(0x2002, 0x2002, A2002_MBJ); - } - if (curppu == RC2C05_04 || curppu == RC2C05_01 || curppu == RC2C05_03 || curppu == RC2C05_02) { - OldWritePPU[0] = GetWriteHandler(0x2000); - OldWritePPU[1] = GetWriteHandler(0x2001); - SetWriteHandler(0x2000, 0x2001, B2000_2001_2C05); - } - if (curmd5 == 0x2d396247cf58f9faLL) { /* Super Xevious */ - SetReadHandler(0x5400, 0x57FF, XevRead); - } -} - -/* Games that will probably not be supported ever(or for a long time), since they require - dual-system: - - Balloon Fight - VS Mahjong - VS Tennis - Wrecking Crew -*/ - -/* Games/PPU list. Information copied from MAME. ROMs are exchangable, so don't take - this list as "this game must use this PPU". - -RP2C04-001: -- Baseball -- Freedom Force -- Gradius -- Hogan's Alley -- Mach Rider (Japan, Fighting Course) -- Pinball -- Platoon -- Super Xevious - -RP2C04-002: -- Castlevania -- Ladies golf -- Mach Rider (Endurance Course) -- Raid on Bungeling Bay (Japan) -- Slalom -- Stroke N' Match Golf -- Wrecking Crew - -RP2C04-003: -- Dr mario -- Excite Bike -- Goonies -- Soccer -- TKO Boxing - -RP2c05-004: -- Clu Clu Land -- Excite Bike (Japan) -- Ice Climber -- Ice Climber Dual (Japan) -- Super Mario Bros. - -Rcp2c03b: -- Battle City -- Duck Hunt -- Mahjang -- Pinball (Japan) -- Rbi Baseball -- Star Luster -- Stroke and Match Golf (Japan) -- Super Skykid -- Tennis -- Tetris - -RC2C05-01: -- Ninja Jajamaru Kun (Japan) - -RC2C05-02: -- Mighty Bomb Jack (Japan) - -RC2C05-03: -- Gumshoe - -RC2C05-04: -- Top Gun -*/ - -VSUNIENTRY VSUniGames[] = -{ - { "Baseball", 0x691d4200ea42be45LL, 99, 2, RP2C04_001, 0 }, - { "Battle City", 0x8540949d74c4d0ebLL, 99, 2, RP2C04_001, 0 }, - { "Battle City(Bootleg)", 0x8093cbe7137ac031LL, 99, 2, RP2C04_001, 0 }, - - { "Clu Clu Land", 0x1b8123218f62b1eeLL, 99, 2, RP2C05_004, IOPTION_SWAPDIRAB }, - { "Dr Mario", 0xe1af09c477dc0081LL, 1, 0, RP2C04_003, IOPTION_SWAPDIRAB }, - { "Duck Hunt", 0x47735d1e5f1205bbLL, 99, 2, RCP2C03B, IOPTION_GUN }, - { "Excitebike", 0x3dcd1401bcafde77LL, 99, 2, RP2C04_003, 0 }, - { "Excitebike (J)", 0x7ea51c9d007375f0LL, 99, 2, RP2C05_004, 0 }, - { "Freedom Force", 0xed96436bd1b5e688LL, 4, 0, RP2C04_001, IOPTION_GUN }, /* Wrong color in game select screen? */ - { "Stroke and Match Golf", 0x612325606e82bc66LL, 99, 2, RP2C04_002, IOPTION_SWAPDIRAB | IOPTION_PREDIP, 0x01 }, - - { "Goonies", 0xb4032d694e1d2733LL, 151, 1, RP2C04_003, 0 }, - { "Gradius", 0x50687ae63bdad976LL, 151, 1, RP2C04_001, IOPTION_SWAPDIRAB }, - { "Gumshoe", 0x87161f8ee37758d3LL, 99, 2, RC2C05_03, IOPTION_GUN }, - { "Gumshoe", 0xb8500780bf69ce29LL, 99, 2, RC2C05_03, IOPTION_GUN }, - { "Hogan's Alley", 0xd78b7f0bb621fb45LL, 99, 2, RP2C04_001, IOPTION_GUN }, - { "Ice Climber", 0xd21e999513435e2aLL, 99, 2, RP2C05_004, IOPTION_SWAPDIRAB }, - { "Ladies Golf", 0x781b24be57ef6785LL, 99, 2, RP2C04_002, IOPTION_SWAPDIRAB | IOPTION_PREDIP, 0x1 }, - - { "Mach Rider", 0x015672618af06441LL, 99, 2, RP2C04_002, 0 }, - { "Mach Rider (J)", 0xa625afb399811a8aLL, 99, 2, RP2C04_001, 0 }, - { "Mighty Bomb Jack", 0xe6a89f4873fac37bLL, 0, 2, RC2C05_02, 0 }, - { "Ninja Jajamaru Kun", 0xb26a2c31474099c0LL, 99, 2, RC2C05_01, IOPTION_SWAPDIRAB }, - { "Pinball", 0xc5f49d3de7f2e9b8LL, 99, 2, RP2C04_001, IOPTION_PREDIP, 0x01 }, - { "Pinball (J)", 0x66ab1a3828cc901cLL, 99, 2, RCP2C03B, IOPTION_PREDIP, 0x1 }, - { "Platoon", 0x160f237351c19f1fLL, 68, 1, RP2C04_001, 0 }, - { "RBI Baseball", 0x6a02d345812938afLL, 4, 1, RP2C04_001, IOPTION_SWAPDIRAB }, - { "Soccer", 0xd4e7a9058780eda3LL, 99, 2, RP2C04_003, IOPTION_SWAPDIRAB }, - { "Star Luster", 0x8360e134b316d94cLL, 99, 2, RCP2C03B, 0 }, - { "Stroke and Match Golf (J)", 0x869bb83e02509747LL, 99, 2, RCP2C03B, IOPTION_SWAPDIRAB | IOPTION_PREDIP, 0x1 }, - { "Super Sky Kid", 0x78d04c1dd4ec0101LL, 4, 1, RCP2C03B, IOPTION_SWAPDIRAB | IOPTION_PREDIP, 0x20 }, - - { "Super Xevious", 0x2d396247cf58f9faLL, 206, 0, RP2C04_001, 0 }, - { "Tetris", 0x531a5e8eea4ce157LL, 99, 2, RCP2C03B, IOPTION_PREDIP, 0x20 }, - { "Top Gun", 0xf1dea36e6a7b531dLL, 2, 0, RC2C05_04, 0 }, - { "VS Castlevania", 0x92fd6909c81305b9LL, 2, 1, RP2C04_002, 0 }, - { "VS Slalom", 0x4889b5a50a623215LL, 0, 1, RP2C04_002, 0 }, - { "VS Super Mario Bros", 0x39d8cfa788e20b6cLL, 99, 2, RP2C05_004, 0 }, - { "VS Super Mario Bros [a1]", 0xfc182e5aefbce14dLL, 99, 2, RP2C05_004, 0 }, - { "VS TKO Boxing", 0x6e1ee06171d8ce3aLL, 4, 1, RP2C04_003, IOPTION_PREDIP, 0x00 }, - { 0 } -}; - -void FCEU_VSUniCheck(uint64 md5partial, int *MapperNo, uint8 *Mirroring) { - VSUNIENTRY *vs = VSUniGames; - - while (vs->name) { - if (md5partial == vs->md5partial) { - if (vs->ppu < RCP2C03B) pale = vs->ppu; - *MapperNo = vs->mapper; - *Mirroring = vs->mirroring; - GameInfo->type = GIT_VSUNI; - GameInfo->cspecial = SIS_VSUNISYSTEM; - GameInfo->inputfc = SIFC_NONE; - curppu = vs->ppu; - curmd5 = md5partial; - - secptr = 0; - - { - static int64 tko = 0x6e1ee06171d8ce3aULL, rbi = 0x6a02d345812938afULL; - if (md5partial == tko) - secptr = secdata[0]; - if (md5partial == rbi) - secptr = secdata[1]; - } - - vsdip = 0x0; - if (vs->ioption & IOPTION_PREDIP) { - vsdip = vs->predip; - } - if (vs->ioption & IOPTION_GUN) { - GameInfo->input[0] = SI_ZAPPER; - GameInfo->input[1] = SI_NONE; - } else { - GameInfo->input[0] = GameInfo->input[1] = SI_GAMEPAD; - } - curvs = vs; - return; - } - vs++; - } -} - -void FCEU_VSUniDraw(uint8 *XBuf) { - uint32 *dest; - int y, x; - - if (!DIPS) return; - - dest = (uint32*)(XBuf + 256 * 12 + 164); - for (y = 24; y; y--, dest += (256 - 72) >> 2) { - for (x = 72 >> 2; x; x--, dest++) - *dest = 0; - } - - dest = (uint32*)(XBuf + 256 * (12 + 4) + 164 + 6); - for (y = 16; y; y--, dest += (256 >> 2) - 16) - for (x = 8; x; x--) { - *dest = 0x01010101; - dest += 2; - } - - dest = (uint32*)(XBuf + 256 * (12 + 4) + 164 + 6); - for (x = 0; x < 8; x++, dest += 2) { - uint32 *da = dest + (256 >> 2); - - if (!((vsdip >> x) & 1)) - da += (256 >> 2) * 10; - for (y = 4; y; y--, da += 256 >> 2) - *da = 0; - } -} - - -SFORMAT FCEUVSUNI_STATEINFO[] = { - { &vsdip, 1, "vsdp" }, - { &coinon, 1, "vscn" }, - { &VSindex, 1, "vsin" }, - { 0 } -}; diff --git a/branches/fceux-2.2.2/src/x6502.cpp b/branches/fceux-2.2.2/src/x6502.cpp deleted file mode 100644 index e1dfe66e..00000000 --- a/branches/fceux-2.2.2/src/x6502.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "debug.h" -#include "sound.h" -#ifdef _S9XLUA_H -#include "fceulua.h" -#endif - -#include "x6502abbrev.h" - -#include -X6502 X; -uint32 timestamp; -void (*MapIRQHook)(int a); - -#define ADDCYC(x) \ -{ \ - int __x=x; \ - _tcount+=__x; \ - _count-=__x*48; \ - timestamp+=__x; \ -} - -//normal memory read -static INLINE uint8 RdMem(unsigned int A) -{ - return(_DB=ARead[A](A)); -} - -//normal memory write -static INLINE void WrMem(unsigned int A, uint8 V) -{ - BWrite[A](A,V); - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(A, 1, V, LUAMEMHOOK_WRITE); - #endif -} - -static INLINE uint8 RdRAM(unsigned int A) -{ - //bbit edited: this was changed so cheat substituion would work - return(_DB=ARead[A](A)); - // return(_DB=RAM[A]); -} - -static INLINE void WrRAM(unsigned int A, uint8 V) -{ - RAM[A]=V; - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(A, 1, V, LUAMEMHOOK_WRITE); - #endif -} - -uint8 X6502_DMR(uint32 A) -{ - ADDCYC(1); - return(X.DB=ARead[A](A)); -} - -void X6502_DMW(uint32 A, uint8 V) -{ - ADDCYC(1); - BWrite[A](A,V); - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(A, 1, V, LUAMEMHOOK_WRITE); - #endif -} - -#define PUSH(V) \ -{ \ - uint8 VTMP=V; \ - WrRAM(0x100+_S,VTMP); \ - _S--; \ -} - -#define POP() RdRAM(0x100+(++_S)) - -static uint8 ZNTable[256]; -/* Some of these operations will only make sense if you know what the flag - constants are. */ - -#define X_ZN(zort) _P&=~(Z_FLAG|N_FLAG);_P|=ZNTable[zort] -#define X_ZNT(zort) _P|=ZNTable[zort] - -#define JR(cond); \ -{ \ - if(cond) \ - { \ - uint32 tmp; \ - int32 disp; \ - disp=(int8)RdMem(_PC); \ - _PC++; \ - ADDCYC(1); \ - tmp=_PC; \ - _PC+=disp; \ - if((tmp^_PC)&0x100) \ - ADDCYC(1); \ - } \ - else _PC++; \ -} - - -#define LDA _A=x;X_ZN(_A) -#define LDX _X=x;X_ZN(_X) -#define LDY _Y=x;X_ZN(_Y) - -/* All of the freaky arithmetic operations. */ -#define AND _A&=x;X_ZN(_A) -#define BIT _P&=~(Z_FLAG|V_FLAG|N_FLAG);_P|=ZNTable[x&_A]&Z_FLAG;_P|=x&(V_FLAG|N_FLAG) -#define EOR _A^=x;X_ZN(_A) -#define ORA _A|=x;X_ZN(_A) - -#define ADC { \ - uint32 l=_A+x+(_P&1); \ - _P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \ - _P|=((((_A^x)&0x80)^0x80) & ((_A^l)&0x80))>>1; \ - _P|=(l>>8)&C_FLAG; \ - _A=l; \ - X_ZNT(_A); \ - } - -#define SBC { \ - uint32 l=_A-x-((_P&1)^1); \ - _P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \ - _P|=((_A^l)&(_A^x)&0x80)>>1; \ - _P|=((l>>8)&C_FLAG)^C_FLAG; \ - _A=l; \ - X_ZNT(_A); \ - } - -#define CMPL(a1,a2) { \ - uint32 t=a1-a2; \ - X_ZN(t&0xFF); \ - _P&=~C_FLAG; \ - _P|=((t>>8)&C_FLAG)^C_FLAG; \ - } - -/* Special undocumented operation. Very similar to CMP. */ -#define AXS { \ - uint32 t=(_A&_X)-x; \ - X_ZN(t&0xFF); \ - _P&=~C_FLAG; \ - _P|=((t>>8)&C_FLAG)^C_FLAG; \ - _X=t; \ - } - -#define CMP CMPL(_A,x) -#define CPX CMPL(_X,x) -#define CPY CMPL(_Y,x) - -/* The following operations modify the byte being worked on. */ -#define DEC x--;X_ZN(x) -#define INC x++;X_ZN(x) - -#define ASL _P&=~C_FLAG;_P|=x>>7;x<<=1;X_ZN(x) -#define LSR _P&=~(C_FLAG|N_FLAG|Z_FLAG);_P|=x&1;x>>=1;X_ZNT(x) - -/* For undocumented instructions, maybe for other things later... */ -#define LSRA _P&=~(C_FLAG|N_FLAG|Z_FLAG);_P|=_A&1;_A>>=1;X_ZNT(_A) - -#define ROL { \ - uint8 l=x>>7; \ - x<<=1; \ - x|=_P&C_FLAG; \ - _P&=~(Z_FLAG|N_FLAG|C_FLAG); \ - _P|=l; \ - X_ZNT(x); \ - } -#define ROR { \ - uint8 l=x&1; \ - x>>=1; \ - x|=(_P&C_FLAG)<<7; \ - _P&=~(Z_FLAG|N_FLAG|C_FLAG); \ - _P|=l; \ - X_ZNT(x); \ - } - -/* Icky icky thing for some undocumented instructions. Can easily be - broken if names of local variables are changed. -*/ - -/* Absolute */ -#define GetAB(target) \ -{ \ - target=RdMem(_PC); \ - _PC++; \ - target|=RdMem(_PC)<<8; \ - _PC++; \ -} - -/* Absolute Indexed(for reads) */ -#define GetABIRD(target, i) \ -{ \ - unsigned int tmp; \ - GetAB(tmp); \ - target=tmp; \ - target+=i; \ - if((target^tmp)&0x100) \ - { \ - target&=0xFFFF; \ - RdMem(target^0x100); \ - ADDCYC(1); \ - } \ -} - -/* Absolute Indexed(for writes and rmws) */ -#define GetABIWR(target, i) \ -{ \ - unsigned int rt; \ - GetAB(rt); \ - target=rt; \ - target+=i; \ - target&=0xFFFF; \ - RdMem((target&0x00FF)|(rt&0xFF00)); \ -} - -/* Zero Page */ -#define GetZP(target) \ -{ \ - target=RdMem(_PC); \ - _PC++; \ -} - -/* Zero Page Indexed */ -#define GetZPI(target,i) \ -{ \ - target=i+RdMem(_PC); \ - _PC++; \ -} - -/* Indexed Indirect */ -#define GetIX(target) \ -{ \ - uint8 tmp; \ - tmp=RdMem(_PC); \ - _PC++; \ - tmp+=_X; \ - target=RdRAM(tmp); \ - tmp++; \ - target|=RdRAM(tmp)<<8; \ -} - -/* Indirect Indexed(for reads) */ -#define GetIYRD(target) \ -{ \ - unsigned int rt; \ - uint8 tmp; \ - tmp=RdMem(_PC); \ - _PC++; \ - rt=RdRAM(tmp); \ - tmp++; \ - rt|=RdRAM(tmp)<<8; \ - target=rt; \ - target+=_Y; \ - if((target^rt)&0x100) \ - { \ - target&=0xFFFF; \ - RdMem(target^0x100); \ - ADDCYC(1); \ - } \ -} - -/* Indirect Indexed(for writes and rmws) */ -#define GetIYWR(target) \ -{ \ - unsigned int rt; \ - uint8 tmp; \ - tmp=RdMem(_PC); \ - _PC++; \ - rt=RdRAM(tmp); \ - tmp++; \ - rt|=RdRAM(tmp)<<8; \ - target=rt; \ - target+=_Y; \ - target&=0xFFFF; \ - RdMem((target&0x00FF)|(rt&0xFF00)); \ -} - -/* Now come the macros to wrap up all of the above stuff addressing mode functions - and operation macros. Note that operation macros will always operate(redundant - redundant) on the variable "x". -*/ - -#define RMW_A(op) {uint8 x=_A; op; _A=x; break; } /* Meh... */ -#define RMW_AB(op) {unsigned int A; uint8 x; GetAB(A); x=RdMem(A); WrMem(A,x); op; WrMem(A,x); break; } -#define RMW_ABI(reg,op) {unsigned int A; uint8 x; GetABIWR(A,reg); x=RdMem(A); WrMem(A,x); op; WrMem(A,x); break; } -#define RMW_ABX(op) RMW_ABI(_X,op) -#define RMW_ABY(op) RMW_ABI(_Y,op) -#define RMW_IX(op) {unsigned int A; uint8 x; GetIX(A); x=RdMem(A); WrMem(A,x); op; WrMem(A,x); break; } -#define RMW_IY(op) {unsigned int A; uint8 x; GetIYWR(A); x=RdMem(A); WrMem(A,x); op; WrMem(A,x); break; } -#define RMW_ZP(op) {uint8 A; uint8 x; GetZP(A); x=RdRAM(A); op; WrRAM(A,x); break; } -#define RMW_ZPX(op) {uint8 A; uint8 x; GetZPI(A,_X); x=RdRAM(A); op; WrRAM(A,x); break;} - -#define LD_IM(op) {uint8 x; x=RdMem(_PC); _PC++; op; break;} -#define LD_ZP(op) {uint8 A; uint8 x; GetZP(A); x=RdRAM(A); op; break;} -#define LD_ZPX(op) {uint8 A; uint8 x; GetZPI(A,_X); x=RdRAM(A); op; break;} -#define LD_ZPY(op) {uint8 A; uint8 x; GetZPI(A,_Y); x=RdRAM(A); op; break;} -#define LD_AB(op) {unsigned int A; uint8 x; GetAB(A); x=RdMem(A); op; break; } -#define LD_ABI(reg,op) {unsigned int A; uint8 x; GetABIRD(A,reg); x=RdMem(A); op; break;} -#define LD_ABX(op) LD_ABI(_X,op) -#define LD_ABY(op) LD_ABI(_Y,op) -#define LD_IX(op) {unsigned int A; uint8 x; GetIX(A); x=RdMem(A); op; break;} -#define LD_IY(op) {unsigned int A; uint8 x; GetIYRD(A); x=RdMem(A); op; break;} - -#define ST_ZP(r) {uint8 A; GetZP(A); WrRAM(A,r); break;} -#define ST_ZPX(r) {uint8 A; GetZPI(A,_X); WrRAM(A,r); break;} -#define ST_ZPY(r) {uint8 A; GetZPI(A,_Y); WrRAM(A,r); break;} -#define ST_AB(r) {unsigned int A; GetAB(A); WrMem(A,r); break;} -#define ST_ABI(reg,r) {unsigned int A; GetABIWR(A,reg); WrMem(A,r); break; } -#define ST_ABX(r) ST_ABI(_X,r) -#define ST_ABY(r) ST_ABI(_Y,r) -#define ST_IX(r) {unsigned int A; GetIX(A); WrMem(A,r); break; } -#define ST_IY(r) {unsigned int A; GetIYWR(A); WrMem(A,r); break; } - -static uint8 CycTable[256] = -{ -/*0x00*/ 7,6,2,8,3,3,5,5,3,2,2,2,4,4,6,6, -/*0x10*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -/*0x20*/ 6,6,2,8,3,3,5,5,4,2,2,2,4,4,6,6, -/*0x30*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -/*0x40*/ 6,6,2,8,3,3,5,5,3,2,2,2,3,4,6,6, -/*0x50*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -/*0x60*/ 6,6,2,8,3,3,5,5,4,2,2,2,5,4,6,6, -/*0x70*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -/*0x80*/ 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4, -/*0x90*/ 2,6,2,6,4,4,4,4,2,5,2,5,5,5,5,5, -/*0xA0*/ 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4, -/*0xB0*/ 2,5,2,5,4,4,4,4,2,4,2,4,4,4,4,4, -/*0xC0*/ 2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6, -/*0xD0*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -/*0xE0*/ 2,6,3,8,3,3,5,5,2,2,2,2,4,4,6,6, -/*0xF0*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, -}; - -void X6502_IRQBegin(int w) -{ - _IRQlow|=w; -} - -void X6502_IRQEnd(int w) -{ - _IRQlow&=~w; -} - -void TriggerNMI(void) -{ - _IRQlow|=FCEU_IQNMI; -} - -void TriggerNMI2(void) -{ - _IRQlow|=FCEU_IQNMI2; -} - -void X6502_Reset(void) -{ - _IRQlow=FCEU_IQRESET; -} -/** -* Initializes the 6502 CPU -**/ -void X6502_Init(void) -{ - unsigned int i; - - // Initialize the CPU structure - memset((void *)&X,0,sizeof(X)); - - for(i = 0; i < sizeof(ZNTable); i++) - { - if(!i) - { - ZNTable[i] = Z_FLAG; - } - else if ( i & 0x80 ) - { - ZNTable[i] = N_FLAG; - } - else - { - ZNTable[i] = 0; - } - } -} - -void X6502_Power(void) -{ - _count=_tcount=_IRQlow=_PC=_A=_X=_Y=_P=_PI=_DB=_jammed=0; - _S=0xFD; - timestamp=0; - X6502_Reset(); -} - -void X6502_Run(int32 cycles) -{ - if(PAL) - cycles*=15; // 15*4=60 - else - cycles*=16; // 16*4=64 - - _count+=cycles; -extern int test; test++; - while(_count>0) - { - int32 temp; - uint8 b1; - - if(_IRQlow) - { - if(_IRQlow&FCEU_IQRESET) - { - DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFC); ) - _PC=RdMem(0xFFFC); - _PC|=RdMem(0xFFFD)<<8; - _jammed=0; - _PI=_P=I_FLAG; - _IRQlow&=~FCEU_IQRESET; - } - else if(_IRQlow&FCEU_IQNMI2) - { - _IRQlow&=~FCEU_IQNMI2; - _IRQlow|=FCEU_IQNMI; - } - else if(_IRQlow&FCEU_IQNMI) - { - if(!_jammed) - { - ADDCYC(7); - PUSH(_PC>>8); - PUSH(_PC); - PUSH((_P&~B_FLAG)|(U_FLAG)); - _P|=I_FLAG; - DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFA) ); - _PC=RdMem(0xFFFA); - _PC|=RdMem(0xFFFB)<<8; - _IRQlow&=~FCEU_IQNMI; - } - } - else - { - if(!(_PI&I_FLAG) && !_jammed) - { - ADDCYC(7); - PUSH(_PC>>8); - PUSH(_PC); - PUSH((_P&~B_FLAG)|(U_FLAG)); - _P|=I_FLAG; - DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFE) ); - _PC=RdMem(0xFFFE); - _PC|=RdMem(0xFFFF)<<8; - } - } - _IRQlow&=~(FCEU_IQTEMP); - if(_count<=0) - { - _PI=_P; - return; - } //Should increase accuracy without a - //major speed hit. - } - - //will probably cause a major speed decrease on low-end systems - DEBUG( DebugCycle() ); - - IncrementInstructionsCounters(); - - _PI=_P; - b1=RdMem(_PC); - - ADDCYC(CycTable[b1]); - - temp=_tcount; - _tcount=0; - if(MapIRQHook) MapIRQHook(temp); - FCEU_SoundCPUHook(temp); - #ifdef _S9XLUA_H - CallRegisteredLuaMemHook(_PC, 1, 0, LUAMEMHOOK_EXEC); - #endif - _PC++; - switch(b1) - { - #include "ops.inc" - } - } -} - -//-------------------------- -//---Called from debuggers -void FCEUI_NMI(void) -{ - _IRQlow|=FCEU_IQNMI; -} - -void FCEUI_IRQ(void) -{ - _IRQlow|=FCEU_IQTEMP; -} - -void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi) -{ - fceuindbg=1; - - *reset=RdMem(0xFFFC); - *reset|=RdMem(0xFFFD)<<8; - *nmi=RdMem(0xFFFA); - *nmi|=RdMem(0xFFFB)<<8; - *irq=RdMem(0xFFFE); - *irq|=RdMem(0xFFFF)<<8; - fceuindbg=0; -} - -//the opsize table is used to quickly grab the instruction sizes (in bytes) -const uint8 opsize[256] = { -/*0x00*/ 1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0, -/*0x10*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x20*/ 3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0x30*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x40*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, -/*0x50*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x60*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, -/*0x70*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x80*/ 0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0, -/*0x90*/ 2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0, -/*0xA0*/ 2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xB0*/ 2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0, -/*0xC0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xD0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0xE0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xF0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0 -}; - - -//the optype table is a quick way to grab the addressing mode for any 6502 opcode -// -// 0 = Implied\Accumulator\Immediate\Branch\NULL -// 1 = (Indirect,X) -// 2 = Zero Page -// 3 = Absolute -// 4 = (Indirect),Y -// 5 = Zero Page,X -// 6 = Absolute,Y -// 7 = Absolute,X -// 8 = Zero Page,Y -// -const uint8 optype[256] = { -/*0x00*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, -/*0x10*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x20*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0x30*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x40*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, -/*0x50*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x60*/ 0,1,0,0,0,2,2,0,0,0,0,0,3,3,3,0, -/*0x70*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x80*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0x90*/ 0,4,0,0,5,5,8,0,0,6,0,0,0,7,0,0, -/*0xA0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xB0*/ 0,4,0,0,5,5,8,0,0,6,0,0,7,7,6,0, -/*0xC0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0 -}; diff --git a/branches/fceux-2.2.2/src/x6502.h b/branches/fceux-2.2.2/src/x6502.h deleted file mode 100644 index b30e0fb5..00000000 --- a/branches/fceux-2.2.2/src/x6502.h +++ /dev/null @@ -1,91 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _X6502H - -#include "x6502struct.h" - -extern X6502 X; - - -//the opsize table is used to quickly grab the instruction sizes (in bytes) -extern const uint8 opsize[256]; - -//the optype table is a quick way to grab the addressing mode for any 6502 opcode -extern const uint8 optype[256]; - -//----------- -//mbg 6/30/06 - some of this was removed to mimic XD -//#ifdef FCEUDEF_DEBUGGER -void X6502_Debug(void (*CPUHook)(X6502 *), - uint8 (*ReadHook)(X6502 *, unsigned int), - void (*WriteHook)(X6502 *, unsigned int, uint8)); - -//extern void (*X6502_Run)(int32 cycles); -//#else -//void X6502_Run(int32 cycles); -//#endif -void X6502_RunDebug(int32 cycles); -#define X6502_Run(x) X6502_RunDebug(x) -//------------ - -extern uint32 timestamp; - - - -#define N_FLAG 0x80 -#define V_FLAG 0x40 -#define U_FLAG 0x20 -#define B_FLAG 0x10 -#define D_FLAG 0x08 -#define I_FLAG 0x04 -#define Z_FLAG 0x02 -#define C_FLAG 0x01 - -extern void (*MapIRQHook)(int a); - -#define NTSC_CPU 1789772.7272727272727272 -#define PAL_CPU 1662607.125 - -#define FCEU_IQEXT 0x001 -#define FCEU_IQEXT2 0x002 -/* ... */ -#define FCEU_IQRESET 0x020 -#define FCEU_IQNMI2 0x040 // Delayed NMI, gets converted to *_IQNMI -#define FCEU_IQNMI 0x080 -#define FCEU_IQDPCM 0x100 -#define FCEU_IQFCOUNT 0x200 -#define FCEU_IQTEMP 0x800 - -void X6502_Init(void); -void X6502_Reset(void); -void X6502_Power(void); - -void TriggerNMI(void); -void TriggerNMI2(void); - -uint8 X6502_DMR(uint32 A); -void X6502_DMW(uint32 A, uint8 V); - -void X6502_IRQBegin(int w); -void X6502_IRQEnd(int w); - -#define _X6502H -#endif diff --git a/branches/fceux-2.2.2/vc/.gitignore b/branches/fceux-2.2.2/vc/.gitignore deleted file mode 100644 index a2c54f42..00000000 --- a/branches/fceux-2.2.2/vc/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -/Release -/ipch -/vc10_bin_Debug -/vc10_fceux.sdf -/vc10_fceux.vcxproj.user -/vc10_obj_Debug -/vc10_obj_Release -/vc9_bin_Debug -/vc9_fceux.ncb -/vc9_fceux.suo -/vc9_fceux.vcproj.CaH4.CaH4e3.user -/vc9_obj_Debug -/vc9_obj_Release -/vc10_fceux.suo -/vc10_fceux.opensdf -/Release Fastbuild -/vc8_bin_debug -/vc8_fceux.ncb -/vc8_obj_Debug -/vc8_fceux.suo -/*.user diff --git a/branches/fceux-2.2.2/vc/Help/fceux.hnd b/branches/fceux-2.2.2/vc/Help/fceux.hnd deleted file mode 100644 index 9b3b098c..00000000 Binary files a/branches/fceux-2.2.2/vc/Help/fceux.hnd and /dev/null differ diff --git a/branches/fceux-2.2.2/vc/SubWCRev.bat b/branches/fceux-2.2.2/vc/SubWCRev.bat deleted file mode 100644 index aa25c877..00000000 --- a/branches/fceux-2.2.2/vc/SubWCRev.bat +++ /dev/null @@ -1,2 +0,0 @@ -SubWCRev.exe .. "defaultconfig\svnrev_template.h" "userconfig\svnrev.h" -exit 0 \ No newline at end of file diff --git a/branches/fceux-2.2.2/vc/deploy.bat b/branches/fceux-2.2.2/vc/deploy.bat deleted file mode 100644 index 96175153..00000000 --- a/branches/fceux-2.2.2/vc/deploy.bat +++ /dev/null @@ -1,2 +0,0 @@ -call archive.bat -call upload.bat %1 \ No newline at end of file diff --git a/branches/fceux-2.2.2/vc/vc10_fceux.sln b/branches/fceux-2.2.2/vc/vc10_fceux.sln deleted file mode 100644 index 4b61e3c2..00000000 --- a/branches/fceux-2.2.2/vc/vc10_fceux.sln +++ /dev/null @@ -1,24 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fceux", "vc10_fceux.vcxproj", "{6893EF44-FEA3-46DF-B236-C4C200F54294}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.Build.0 = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.ActiveCfg = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.Build.0 = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj b/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj deleted file mode 100644 index 3808a52f..00000000 --- a/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj +++ /dev/null @@ -1,1267 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - fceux - {6893EF44-FEA3-46DF-B236-C4C200F54294} - fceux - Win32Proj - - - - Application - NotSet - true - - - Application - NotSet - - - Application - NotSet - true - - - Application - NotSet - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - vc10_bin_$(Configuration)\ - vc10_obj_$(Configuration)\ - ..\output\ - vc10_obj_$(Configuration)\ - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - SubWCRev.bat - - - Disabled - .;../src/drivers/win/zlib;../src/drivers/win/directx;../src;../src/drivers/win/lua/include;userconfig;defaultconfig;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;MSVC;_CRT_SECURE_NO_DEPRECATE;_WIN32_WINDOWS=0x0410;WINVER=0x0410;NETWORK;LSB_FIRST;_USE_32BIT_TIME_T;FCEUDEF_DEBUGGER;_USE_SHARED_MEMORY_;NOMINMAX;HAS_vsnprintf;_S9XLUA_H;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - false - false - - - Level3 - EditAndContinue - Default - true - - - Rpcrt4.lib;comctl32.lib;vfw32.lib;winmm.lib;ws2_32.lib;htmlhelp.lib;../src/drivers/win/directx/dsound.lib;../src/drivers/win/directx/dxguid.lib;../src/drivers/win/directx/ddraw.lib;../src/drivers/win/directx/dinput.lib;../src/drivers/win/lua/win32/lua51.lib;LuaPerks.lib;psapi.lib;mpr.lib;%(AdditionalDependencies) - true - Console - mainCRTStartup - false - - - true - MachineX86 - lua51.dll - - - $(ProjectDir)../src/drivers/win/fceu_x86.manifest;%(AdditionalManifestFiles) - true - - - xcopy /y /d "$(ProjectDir)\..\src\drivers\win\7z.dll" "$(OutDir)" - - - - - - SubWCRev.bat - write current revision number to placeholders - - - Full - AnySuitable - true - Speed - true - .;../src/drivers/win/zlib;../src/drivers/win/directx;../src;../src/drivers/win/lua/include;userconfig;defaultconfig;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;MSVC;_CRT_SECURE_NO_DEPRECATE;_WIN32_WINDOWS=0x0410;WINVER=0x0410;NETWORK;LSB_FIRST;_USE_32BIT_TIME_T;FCEUDEF_DEBUGGER;_USE_SHARED_MEMORY_;NOMINMAX;HAS_vsnprintf;_S9XLUA_H;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - Default - /MP %(AdditionalOptions) - true - - - Rpcrt4.lib;comctl32.lib;vfw32.lib;winmm.lib;ws2_32.lib;htmlhelp.lib;../src/drivers/win/directx/dsound.lib;../src/drivers/win/directx/dxguid.lib;../src/drivers/win/directx/ddraw.lib;../src/drivers/win/directx/dinput.lib;../src/drivers/win/lua/win32/lua51.lib;luaperks.lib;psapi.lib;mpr.lib;%(AdditionalDependencies) - lua51.dll;%(DelayLoadDLLs) - true - Windows - true - true - mainCRTStartup - false - - - MachineX86 - - - $(ProjectDir)../src/drivers/win/fceu_x86.manifest;%(AdditionalManifestFiles) - - - xcopy /y /d "$(ProjectDir)\..\src\drivers\win\7z.dll" "$(OutDir)" - - - - - - X64 - - - Disabled - ../zlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;MSVC;_CRT_SECURE_NO_DEPRECATE;_WIN32_WINDOWS=0x0410;WINVER=0x0410;NETWORK;LSB_FIRST;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - false - false - - - Level3 - ProgramDatabase - CompileAsC - - - dxguid.lib;winmm.lib;dinput.lib;ws2_32.lib;ddraw.lib;dsound.lib;../src/drivers/win/lua/x64/lua51.lib;%(AdditionalDependencies) - true - Windows - mainCRTStartup - MachineX64 - lua51.dll - - - - - X64 - - - Full - AnySuitable - true - Speed - true - ../zlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;MSVC;_CRT_SECURE_NO_DEPRECATE;_WIN32_WINDOWS=0x0410;WINVER=0x0410;NETWORK;LSB_FIRST;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - dxguid.lib;winmm.lib;dinput.lib;ws2_32.lib;ddraw.lib;dsound.lib;../src/drivers/win/lua/x64/lua51.lib;%(AdditionalDependencies) - true - Windows - true - true - mainCRTStartup - MachineX64 - lua51.dll - - - - - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - false - false - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - - - - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - $(IntDir)%(Filename)2.obj - $(IntDir)%(Filename)2.xdc - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - CompileAsC - CompileAsC - - - - - 4789 - - - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - CompileAsC - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - CompileAsC - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - false - false - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - xcopy /y /d "$(ProjectDir)\..\src\auxlib.lua" "$(OutDir)" - - xcopy /y /d "$(ProjectDir)\..\src\auxlib.lua" "$(OutDir)" - - $(OutDir)auxlib.lua;%(Outputs) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj.filters b/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj.filters deleted file mode 100644 index df76bafe..00000000 --- a/branches/fceux-2.2.2/vc/vc10_fceux.vcxproj.filters +++ /dev/null @@ -1,1807 +0,0 @@ - - - - - {9df8a9c0-b1c6-4cfc-b494-a032de5610dd} - - - {37c56600-9a81-498c-ae95-ad217bb601e7} - - - {4251322f-2a2d-4b6a-9bce-042361a39b04} - - - {aa276048-3e0e-42b0-8562-278c052715a8} - - - {d4ab474f-f74e-4042-8e0a-161e0c89a940} - - - {46e87a33-60b3-41a1-87b1-5fc0b410c0a1} - - - {bfa3a49b-0c30-4093-8119-7e315c80053d} - - - {008e1f62-e23f-4235-bee7-a45a466678e9} - - - {7279627e-c72f-441f-bb8b-48ef8412f051} - - - {8770e1b4-9ef8-4253-bdcd-7c4d5a51461b} - - - {aec82faa-87f7-44b0-963e-01b07ce40e82} - - - {5f356733-cee3-4440-aa40-cf138dcfbd8c} - - - {2a047eb3-7b56-41d4-b228-5df54bc1809d} - - - {b826cbb1-8f65-48a4-89ca-a1b691426971} - - - {19ba9ddc-37b7-4962-a3d7-9eb69929a8dc} - - - {cfac36a2-cdfd-4c0a-be8e-353b1303a909} - - - - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - - - - - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - drivers\win\zlib - - - - - - - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - input - - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - boards - - - - - - - - - - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - - - - - - drivers\common - - - boards - - - drivers\win - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - boards - - - drivers\win\taseditor - - - drivers\win\taseditor - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - boards - - - utils - - - boards - - - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win\lua\include - - - drivers\win\lua\include - - - drivers\win\lua\include - - - drivers\win\lua\include - - - drivers\win\lua\include - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - drivers\win - - - fir - - - fir - - - fir - - - fir - - - fir - - - fir - - - input - - - input - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - drivers\win\lua - - - palettes - - - palettes - - - palettes - - - palettes - - - palettes - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - utils - - - drivers\common - - - drivers\common - - - drivers\common - - - drivers\win - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - drivers\win\taseditor - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - include files - - - utils - - - - - drivers\win - - - - - drivers\win\res - - - drivers\win\res - - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - pix - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - drivers\win\res - - - - - - - \ No newline at end of file diff --git a/branches/fceux-2.2.2/vc/vc8_fceux.sln b/branches/fceux-2.2.2/vc/vc8_fceux.sln deleted file mode 100644 index 638a5f6e..00000000 --- a/branches/fceux-2.2.2/vc/vc8_fceux.sln +++ /dev/null @@ -1,30 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fceux", "vc8_fceux.vcproj", "{6893EF44-FEA3-46DF-B236-C4C200F54294}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release FastBuild|Win32 = Release FastBuild|Win32 - Release FastBuild|x64 = Release FastBuild|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.Build.0 = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release FastBuild|Win32.ActiveCfg = Release Fastbuild|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release FastBuild|Win32.Build.0 = Release Fastbuild|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release FastBuild|x64.ActiveCfg = Release Fastbuild|x64 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release FastBuild|x64.Build.0 = Release Fastbuild|x64 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.ActiveCfg = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.Build.0 = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/branches/fceux-2.2.2/vc/vc8_fceux.vcproj b/branches/fceux-2.2.2/vc/vc8_fceux.vcproj deleted file mode 100644 index 1e22cf4a..00000000 --- a/branches/fceux-2.2.2/vc/vc8_fceux.vcproj +++ /dev/null @@ -1,4861 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/fceux-2.2.2/vc/vc9_fceux.sln b/branches/fceux-2.2.2/vc/vc9_fceux.sln deleted file mode 100644 index 7be2907a..00000000 --- a/branches/fceux-2.2.2/vc/vc9_fceux.sln +++ /dev/null @@ -1,24 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fceux", "vc9_fceux.vcproj", "{6893EF44-FEA3-46DF-B236-C4C200F54294}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.Build.0 = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.ActiveCfg = Debug|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.ActiveCfg = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|Win32.Build.0 = Release|Win32 - {6893EF44-FEA3-46DF-B236-C4C200F54294}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/branches/fceux-2.2.2/vc/vc9_fceux.vcproj b/branches/fceux-2.2.2/vc/vc9_fceux.vcproj deleted file mode 100644 index d5bad547..00000000 --- a/branches/fceux-2.2.2/vc/vc9_fceux.vcproj +++ /dev/null @@ -1,4723 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sdl2/Authors b/branches/sdl2/Authors deleted file mode 100644 index 799599be..00000000 --- a/branches/sdl2/Authors +++ /dev/null @@ -1,72 +0,0 @@ -Authors -======= - -A list of people who have contributed code to FCE Ultra, or have had their code -placed in FCE Ultra by others. - -Pre-2.0 FCE / FCE Ultra Contributors ------------------------------------- -_These authors contributed exclusively to pre-2.0 versions, -but much of their code remains in 2.0 builds_ - -* BERO - bero at geocities.co.jp - Base FCE code. - -* Xodnizel - Most of the base FCE Ultra code - -* Aaron Oneal - http://www.morphgear.com - Many changes to compile with MSVC and first frame skipping code - -* Joe Nahmias - Man pages - -* Paul Kuliniewicz - kuliniew at purdue.edu - Various code for the original SDL port. - -* Quietust - quietust at ircN dot org - VRC7 "translation" code. - -* Ben Parnell - Windows debugging tools - -* Parasyte & bbitmaster - Enhanced Windows debugging tools - -* blip & nitsuja - Rerecording support - -FCEUX >= 2.0 Contributors -------------------------- -* SP - document thyself (sf:rheiny) - Enhanced Windows debugging tools - -* zeromus - mgambrell at gmail dot com (sf:zeromus) - Core architecture refactoring and merging - Windows driver maintenance - -* adelikat - document thyself (sf:adelikat) - UI cleanup, project management, Win32 features & maintenance, TAS tools, documentation - -* CaH4e3 - CaH4e3 at mail dot ru (sf: cah4e3) - Mappers - -* Luke Gustafson - (sf:???) - Windows TAS and movie recording enhancements - -* qfox - (sf:qfox) - lua scripting fucntions, luabot, basicbot (no longer implemented), various lua scripts - -* _mz - document thyself (mauzus) - Windows driver maintenance and cleanup - -* UncombedCoconut - UncombedCoconut at gmail dot com (sf:jeblanchard) - Build system and cross-compilation support - Driver maintenance and refactoring - -* DWEdit - Debugger additions - -* AnS - ansstuff at yandex dot ru (sf:ansstuff) - Win32 features & maintenance, TAS Editor, debugging tools, documentation - -FCEUX (>=2.0) Linux/SDL Developers ----------------------------------- -_These guys concentrated on keeping fceux the premiere linux/portable nes emu._ - -* Lukas Sabota - ltsmooth42 at gmail dot com (sf:punkrockguy318) - Head FceuX-SDL developer - GTK GUI, complete overhaul of SDL port, build scripts; maintainence; docs - -* Shinydoofy - sf:shinydoofy - SDL maintenence - -* Soules - gimmedonutnow at gmail dot com (sf:gimmedonutnow) - Linux SDL driver maintenance - -* radsaq - radsaq at gmail dot com (sf:radsaq) - Build system, testing, and random cleanups - -* Bryan Cain - sf:plombo - Patch to embed SDL in the GTK+ GUI, miscellaneous other SDL and GTK+ contributions - -Included components: --------------------- -* Mitsutaka Okazaki - YM2413 emulator. - -* Andrea Mazzoleni - Scale2x/Scale3x scalers - -* Gilles Vollant - unzip.c PKZIP fileio diff --git a/branches/sdl2/COPYING b/branches/sdl2/COPYING deleted file mode 100644 index d159169d..00000000 --- a/branches/sdl2/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/branches/sdl2/INSTALL b/branches/sdl2/INSTALL deleted file mode 100644 index f1f2a562..00000000 --- a/branches/sdl2/INSTALL +++ /dev/null @@ -1,7 +0,0 @@ -To compile and install FCEUX for SDL, follow the instructions in the README-SDL.md file. - -Users of Microsoft Visual Studio can use the solution files within the vc directory. -These solution files will compile FCEUX and some included libraries for full functionality. - -CMake has been depreciated in favor of scons. However, if you wish to use it you can find the old cmake build files in the attic. - diff --git a/branches/sdl2/NewPPUtests.txt b/branches/sdl2/NewPPUtests.txt deleted file mode 100644 index 6c74c119..00000000 --- a/branches/sdl2/NewPPUtests.txt +++ /dev/null @@ -1,69 +0,0 @@ -NewPPU tests - -Bad -Nightshade (U) - flickering - -Good -3-D Battles of World Runner, The (U) -8 Eyes -10 Yard fight -Advanced Dungeons and Dragons - Pool of Radiance -Adventures of Bayou Billy -Adventures of Lolo 1 -Adventures of Lolo 2 -Advenutres of Lolo 3 -Akira -Akumajou secial - Boku Dracula-kun -Archon -Astyanax -Barbie -Bart vs the Space Mutants -Baseball -Batman - Return of the Joker -Battletoads -Battletoads & Double Dragon -Bee 52 -Bible Adventures -Castlevania -Castlevania II: Simon's Quest -Castlevania III: Dracula's Curse -Championship Pool -Chessmaster -Circus Charlie -Contra (U) -Contra (J) -Dragon Warrior -Dragon Warrior III -Dragon Warrior IV -Double Dragon -Double Dragon 2 -Double Dragon 3 -Donky Kong Classics -Doki Doki panic -Dragon's Lair - [FIXED] Black screen for level 1 (music plays) -Duck Tales -Duck Tales -Earthworm Jim 2 -Excitebike -Eggerland -Final Fantasy -Friday the 13th -Gauntlet -Gauntlet II -Legend of Zelda -Metroid -Mike Tyson's Punch-out!!/Punch-out!! -Power Blade -RBI Baseball -Rygar -Super C -Super Mario Bros 2 JPN -Super Mario Bros 2 USA -Super Mario Bros 3 -Tecmobowl -Tecmo NBA Basketball (U) -Tecmo Super Bowl (U) [!] - [FIXED] Intro screen messed up, menus out of whack, Team selection screen bad, pre game screen, field is messed up. -TMNT -Transformers -Zanac -Zelda II: The Adventure of Link diff --git a/branches/sdl2/README-SDL b/branches/sdl2/README-SDL deleted file mode 100644 index 92dbac5b..00000000 --- a/branches/sdl2/README-SDL +++ /dev/null @@ -1,116 +0,0 @@ -FCEUX SDL 2.2.1 SDL README -========================== -By Lukas Sabota (sf: punkrockguy318) - -http://www.fceux.com - -Last Modified: March 10, 2013 - -Table of Contents ------------------ - -1. Requirements -2. Installation -3. Compile-time options -4. GUI -5. LUA Scripting -5. FAQ -6. Contact - -1 - Requirements ----------------- -* libsdl1.2 - It is strongly recommended that you upgrade to the latest - version of sdl (1.2.15 at the time of writing). -* scons - Required to build fceux. -* libgtk2.0 (optional) - version >= 2.24 recommended -* libgtk3.0 (optional) - this compiles as of fceux 2.2.0 -* liblua5.1 (optional) -* minizip (optional) - you may chose to use the version of minizip on your system by enabling SYSTEM_MINIZIP in the SConstruct -* c++ compiler -- you may use g++ from gcc or clang++ from llvm. - -2 - Installation ----------------- -Fceux can be compiled and built using the scons build system. To compile, run: - - scons - -After a sucessful compilation, the fceux binary will be generated to -./src/fceux . You can install fceux to your system with the following command: - - scons install - -You can optionally define a prefix: - - scons --prefix=/usr/local install - -You can choose to install the lua scripts (located in output/luaScripts) to a directory of your choosing: - - cp -R output/luaScripts /usr/local/some/directory/that/i/will/find/later - -If you would like to clean the temporary scons files to perform a 'make clean' like function, you can do the following: - - scons -c && rm -rf .scon* - -3 - Compile-time options ------------------------- -You can enable and disable certain features of fceux at build time. -To edit these options, edit the "BoolOptions" following the "opts.AddVariables" method -at the head of the "SConstruct" file in this source directory. The -default options will be fine for most users, but power users may want to -tweak some of these options. - -4 - GUI -------- -You can enable the GTK GUI by setting GTK to 1 in the SConstruct build file. -GfceuX is deprecatiated in favor of the new GTK GUI. You can disable the GTK GUI at -run-time by passing the --nogui option, or disable it at build-time by setting -GTK to 0 in the SConstruct file. If you prefer GTK3 to GTK2, you can set the -GTK3 BoolVariable to 1 in the SConstruct. - -5 - LUA Scripting ------------------ -FCEUX provides a LUA 5.1 engine that allows for in-game scripting capabilities. LUA can be enabled or disabled at build time by adjusting the "LUA" BoolVariable in the SConstruct file. - -A collection of LUA scripts are provided with the source distribuition in the output directory: - - $source_directory/output/luaScripts - -You should be able to run most of the scripts in this directory out of the box. However, some of the the lua scripts require functionality from the "auxlib.lua" library. This file can be copied from "./bin/auxlib.lua" or "./src/auxlib.lua". You will need to place this file in the LUA library search path if a script bombs out looking for auxlib.lua. If the script bombs out, the console output will let you know what the search path are (/usr/local/lib/lua/5.1/ on my particular system). You can simply copy the auxlib to a preferred location to utilize the functions in the auxiliary lua library. - -In addition, some of the lua scripts require functionality from the "iup" GUI library. You can obtain binaries and source for "iup" upstream (http://www.tecgraf.puc-rio.br/iup/), but I would recommend obtaining packages from your Linux distribution if you are able, as it can be difficult to compile or get the binaries working correctly on a given system. - -You will need to add the location that the libiup*.so files to the LUA_CPATH. This can be done with the following command (please note that the location where iup is installed with vary based on how you installed iup): - - export LUA_CPATH="/path/to/iup/lib/lib?51.so;" - -For example, if libiuplua51.so is located in '/usr/lib', you can run the following command before executing fceux to place the library in the search path: - - export LUA_CPATH="/usr/lib/lib?51.so;" - -Finally, if any scripts complaints about "attempt to index global 'iup' (a nil value)", this means that "iup" needs to be explicitly loaded into the script. You can add the following line to the head of script to manually load "iup": - - require("iuplua") - -The latest version of iup (3.5 at the time of writing) is recomended. - -6 - FAQ -------- - -* Q. Im having issues with my sound! -* A. First of all, for the best sound quality be sure you are using SDL 1.2.14 or later. Versions 1.2.13 and earlier are known to have problems with fceux! Next, try different SDL audio drivers to see if this makes any difference. You can do this by using this command before running fceux: - - export SDL_AUDIODRIVER=driver - -where driver is either: 'pulse' for pulseaudio;' alsa' for ALSA; 'dsp' for OSS; 'esd' for ESD; see SDL documentation for details (http://www.libsdl.org/docs/html/sdlenvvars.html) - -There are sound options that you can tweak at runtime through command line switches: - -* -soundq x internal sound quality hack value (0 off) -* -soundrate x sound rate (sane values: 28000 48000 -* -soundbuffersize x (in ms) sane values (30, 50, 100, 120) - -Running fceux through esddsp is known to fix some audio issues with pulseaudio on some older Ubuntu versions. - -7 - Contact ------------ -If you have an issue with fceux, report it in the sourceforge bug tracker (see fceux.com). If you would like to contact the author of this readme personally, e-mail LTsmooth42 gmail com. You can also check us out at #fceu on irc.freenode.net. diff --git a/branches/sdl2/SConstruct b/branches/sdl2/SConstruct deleted file mode 100644 index 59e1b7ae..00000000 --- a/branches/sdl2/SConstruct +++ /dev/null @@ -1,245 +0,0 @@ -# -# SConstruct - build script for the SDL port of fceux -# -# You can adjust the BoolVariables below to include/exclude features -# at compile-time. You may also use arguments to specify the parameters. -# ie: scons RELEASE=1 GTK3=1 -# -# Use "scons" to compile and "scons install" to install. -# - -import os -import sys -import platform - -opts = Variables(None, ARGUMENTS) -opts.AddVariables( - BoolVariable('DEBUG', 'Build with debugging symbols', 1), - BoolVariable('RELEASE', 'Set to 1 to build for release', 0), - BoolVariable('FRAMESKIP', 'Enable frameskipping', 1), - BoolVariable('OPENGL', 'Enable OpenGL support (not supported by SDL2 yet)', 0), - BoolVariable('LUA', 'Enable Lua support', 1), - BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1), - BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 0), - BoolVariable('NEWPPU', 'Enable new PPU core', 1), - BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1), - BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', 1), - BoolVariable('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 1), - BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0), - BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1), - BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0), - BoolVariable('SDL2', 'Compile using SDL2 instead of SDL 1.2 (experimental/non-functional)', 1) -) -AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix') - -prefix = GetOption('prefix') -env = Environment(options = opts) - -if env['RELEASE']: - env.Append(CPPDEFINES=["PUBLIC_RELEASE"]) - env['DEBUG'] = 0 - -# LSB_FIRST must be off for PPC to compile -if platform.system == "ppc": - env['LSB_FIRST'] = 0 - -# Default compiler flags: -env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare']) - -if os.environ.has_key('PLATFORM'): - env.Replace(PLATFORM = os.environ['PLATFORM']) -if os.environ.has_key('CC'): - env.Replace(CC = os.environ['CC']) -if os.environ.has_key('CXX'): - env.Replace(CXX = os.environ['CXX']) -if os.environ.has_key('WINDRES'): - env.Replace(WINDRES = os.environ['WINDRES']) -if os.environ.has_key('CFLAGS'): - env.Append(CCFLAGS = os.environ['CFLAGS'].split()) -if os.environ.has_key('CXXFLAGS'): - env.Append(CXXFLAGS = os.environ['CXXFLAGS'].split()) -if os.environ.has_key('CPPFLAGS'): - env.Append(CPPFLAGS = os.environ['CPPFLAGS'].split()) -if os.environ.has_key('LDFLAGS'): - env.Append(LINKFLAGS = os.environ['LDFLAGS'].split()) -if os.environ.has_key('PKG_CONFIG_PATH'): - env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH'] -if os.environ.has_key('PKG_CONFIG_LIBDIR'): - env['ENV']['PKG_CONFIG_LIBDIR'] = os.environ['PKG_CONFIG_LIBDIR'] -if os.environ.has_key('LIBRARY_PATH'): - env['ENV']['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] -if os.environ.has_key('INCLUDE_PATH'): - env['ENV']['INCLUDE_PATH'] = os.environ['INCLUDE_PATH'] - -print "platform: ", env['PLATFORM'] - -# compile with clang -if env['CLANG']: - env.Replace(CC='clang') - env.Replace(CXX='clang++') - -# special flags for cygwin -# we have to do this here so that the function and lib checks will go through mingw -if env['PLATFORM'] == 'cygwin': - env.Append(CCFLAGS = " -mno-cygwin") - env.Append(LINKFLAGS = " -mno-cygwin") - env['LIBS'] = ['wsock32']; - -if env['PLATFORM'] == 'win32': - env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"]) - env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"]) - env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"]) -else: - conf = Configure(env) - # If libdw is available, compile in backward-cpp support - if conf.CheckLib('dw'): - conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1") - conf.env.Append(LINKFLAGS = "-ldw") - if conf.CheckFunc('asprintf'): - conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF") - if env['SYSTEM_MINIZIP']: - assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip" - assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib" - env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"]) - else: - assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib" - if env['SDL2']: - if not conf.CheckLib('SDL2'): - print 'Did not find libSDL2 or SDL2.lib, exiting!' - Exit(1) - env.Append(CPPDEFINES=["_SDL2"]) - env.ParseConfig('pkg-config sdl2 --cflags --libs') - else: - if not conf.CheckLib('SDL'): - print 'Did not find libSDL or SDL.lib, exiting!' - Exit(1) - env.ParseConfig('sdl-config --cflags --libs') - if env['GTK']: - if not conf.CheckLib('gtk-x11-2.0'): - print 'Could not find libgtk-2.0, exiting!' - Exit(1) - # Add compiler and linker flags from pkg-config - config_string = 'pkg-config --cflags --libs gtk+-2.0' - env.ParseConfig(config_string) - env.Append(CPPDEFINES=["_GTK2"]) - env.Append(CCFLAGS = ["-D_GTK"]) - if env['GTK3']: - # Add compiler and linker flags from pkg-config - config_string = 'pkg-config --cflags --libs gtk+-3.0' - env.ParseConfig(config_string) - env.Append(CPPDEFINES=["_GTK3"]) - env.Append(CCFLAGS = ["-D_GTK"]) - - ### Lua platform defines - ### Applies to all files even though only lua needs it, but should be ok - if env['LUA']: - env.Append(CPPDEFINES=["_S9XLUA_H"]) - if env['PLATFORM'] == 'darwin': - # Define LUA_USE_MACOSX otherwise we can't bind external libs from lua - env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"]) - if env['PLATFORM'] == 'posix': - # If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading. - # Should work on any *nix - env.Append(CCFLAGS = ["-DLUA_USE_LINUX"]) - lua_available = False - if conf.CheckLib('lua5.1'): - env.Append(LINKFLAGS = ["-ldl", "-llua5.1"]) - env.Append(CCFLAGS = ["-I/usr/include/lua5.1"]) - lua_available = True - elif conf.CheckLib('lua'): - env.Append(LINKFLAGS = ["-ldl", "-llua"]) - env.Append(CCFLAGS = ["-I/usr/include/lua"]) - lua_available = True - if lua_available == False: - print 'Could not find liblua, exiting!' - Exit(1) - # "--as-needed" no longer available on OSX (probably BSD as well? TODO: test) - if env['PLATFORM'] != 'darwin': - env.Append(LINKFLAGS=['-Wl,--as-needed']) - - ### Search for gd if we're not in Windows - if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']: - gd = conf.CheckLib('gd', autoadd=1) - if gd == 0: - env['LOGO'] = 0 - print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.' - - if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1): - conf.env.Append(CCFLAGS = "-DOPENGL") - conf.env.Append(CPPDEFINES = ['PSS_STYLE=1']) - - env = conf.Finish() - -if sys.byteorder == 'little' or env['PLATFORM'] == 'win32': - env.Append(CPPDEFINES = ['LSB_FIRST']) - -if env['FRAMESKIP']: - env.Append(CPPDEFINES = ['FRAMESKIP']) - -print "base CPPDEFINES:",env['CPPDEFINES'] -print "base CCFLAGS:",env['CCFLAGS'] - -if env['DEBUG']: - env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g', '-O0']) -else: - env.Append(CCFLAGS = ['-O2']) - -if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']: - env.Append(CPPDEFINES=["CREATE_AVI"]) -else: - env['CREATE_AVI']=0; - -Export('env') -fceux = SConscript('src/SConscript') -env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"]) - -# Installation rules -if prefix == None: - prefix = "/usr/local" - -exe_suffix = '' -if env['PLATFORM'] == 'win32': - exe_suffix = '.exe' - -fceux_src = 'src/fceux' + exe_suffix -fceux_dst = 'bin/fceux' + exe_suffix - -fceux_net_server_src = 'fceux-net-server' + exe_suffix -fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix - -auxlib_src = 'src/auxlib.lua' -auxlib_dst = 'bin/auxlib.lua' -auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua' - -fceux_h_src = 'output/fceux.chm' -fceux_h_dst = 'bin/fceux.chm' - -env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)]) -env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)]) -env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)]) -env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)]) - -man_src = 'documentation/fceux.6' -man_net_src = 'documentation/fceux-net-server.6' -man_dst = prefix + '/share/man/man6/fceux.6' -man_net_dst = prefix + '/share/man/man6/fceux-net-server.6' - -share_src = 'output/' -share_dst = prefix + '/share/fceux/' - -image_src = 'fceux.png' -image_dst = prefix + '/share/pixmaps' - -desktop_src = 'fceux.desktop' -desktop_dst = prefix + '/share/applications/' - -env.Install(prefix + "/bin/", fceux) -env.Install(prefix + "/bin/", "fceux-net-server") -# TODO: Where to put auxlib on "scons install?" -env.Alias('install', env.Command(auxlib_inst_dst, auxlib_src, [Copy(auxlib_inst_dst, auxlib_src)])) -env.Alias('install', env.Command(share_dst, share_src, [Copy(share_dst, share_src)])) -env.Alias('install', env.Command(man_dst, man_src, [Copy(man_dst, man_src)])) -env.Alias('install', env.Command(man_net_dst, man_net_src, [Copy(man_net_dst, man_net_src)])) -env.Alias('install', env.Command(image_dst, image_src, [Copy(image_dst, image_src)])) -env.Alias('install', env.Command(desktop_dst, desktop_src, [Copy(desktop_dst, desktop_src)])) -env.Alias('install', (prefix + "/bin/")) diff --git a/branches/sdl2/STYLE-GUIDELINES-SDL b/branches/sdl2/STYLE-GUIDELINES-SDL deleted file mode 100644 index 0ea3db6f..00000000 --- a/branches/sdl2/STYLE-GUIDELINES-SDL +++ /dev/null @@ -1,14 +0,0 @@ -FceuX-SDL Style Guidelines -========================= -Background ----------- -While having style guidelines specific to a directory in a sourcetree is slightly riddiculous, fceuX has a unique elaborate history of the code. I (prg318) have ressurected the majority of the SDL port code and tried to keep some aspects of the style consistant (although not many aspects were that consistent to begin with due to the amount of different people who have contributed to this codebase). Much of the SDL code is compliant to these guidelines so please use this guidelines when going forth and making contributions in src/drivers/sdl. - -Tabs ----- -Hard tabs only! Please! src/drivers/sdl/* entirely consists of hard tabbed code. Please continue to use this convention. Consult the documentation of your text editor documentation for instructions on how to this with your editor. - -Return Statements ------------------ -Please use the "return 0;" style return statements instead of the "return(0);" style return statements. - diff --git a/branches/sdl2/TODO-SDL b/branches/sdl2/TODO-SDL deleted file mode 100644 index 95defb4b..00000000 --- a/branches/sdl2/TODO-SDL +++ /dev/null @@ -1,47 +0,0 @@ -Priorities -========== - * SDL 2.0 RC is released - SDL2.0 compatibility is a goal - * Backwards-cpp still has an issue with clang++; look into this - * Users are reporting crashing issues with hotkey dialog (probably because its a mess!). A huge chunk of the hotkey code should be rewritten (GUI and hotkey structs - or lack there-of) - * GTK File menu quit element has "CTRL-Q" accelerator. This causes confusion with there being another SDL Hotkey for quit. This should be addressed. - * Quit was mapped to '0' to prevent users from accidently quitting. Perhaps a default quit combo could be used. - -Features -======== - * SDL.Vsync - * lets wait on this -- theres no simple way to use the OS default in SDL unless we just dont touch it, which might be the best thing to do here. - -GTK -=== - * Better on-the-fly video resizing with window resize / video config - * Smarter video config (disable widgets that are not used when openGL is enabled) - * Options to investigate: - * bpp - * scanlines - * GUI Cheat editor - -SDL 2.0 -======= - * segfaults when opening a second game - * segfaults on fullscreen entry - * has not been tested in a while - -BUGS -==== - * F1 from terminal-less gui fceux process hangs fceux (since input is required from console in cheat editor) - -OS X -==== - * Single window mode does not work (the XWINDOWID hack does not work in Apples X11 server, so this may never get fixed). - * It is possible to use GTK to build native OS X menus: http://developer.gnome.org/gtk3/3.4/GtkApplication.html . It would be awesome to do this and hide the main GTK window if the top bar is available - * Zapper input is taken from GTK window instead of X11 window (a workaround could be implemented to resolve with with some #ifdef APPLE etc) - * Not an "official" target, but testing should be done before release on OS X - * DMG Static binary download for Intel OS X - * Include needful libaries - * Adjust scons to produce static binary/libraries with an option - * http://www.scons.org/wiki/StaticallyLink - -DOCS -==== - * Be sure to include details about new scons features for package maintainers so that the manpage, luascripts, and auxlib will be included in future packages - * Docs REALLY need a cleanup/rewrite diff --git a/branches/sdl2/attic/.gitignore b/branches/sdl2/attic/.gitignore deleted file mode 100644 index 674deb69..00000000 --- a/branches/sdl2/attic/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# A simulation of Subversion default ignores, generated by reposurgeon. -*.o -*.lo -*.la -*.al -*.libs -*.so -*.so.[0-9]* -*.a -*.pyc -*.pyo -*.rej -*~ -*.#* -.*.swp -.DS_store -# Simulated Subversion default ignores end here diff --git a/branches/sdl2/attic/BUGS b/branches/sdl2/attic/BUGS deleted file mode 100644 index cd938cf8..00000000 --- a/branches/sdl2/attic/BUGS +++ /dev/null @@ -1,12 +0,0 @@ -BUILD SYSTEM BUGS: -Date - Person - Details - - - - -CLOSED * July 30, 2006 - Luke - I'm getting build errors about: -sh: illegal option -l -Started happening when the build system was edited to be more robust. -I'll check it out when i get the chance, or soules if you could take a look at it, that would be grand. -- July 31, 2006 - Luke - checked out to latest revision, all is well. - diff --git a/branches/sdl2/attic/ChangeLog.older b/branches/sdl2/attic/ChangeLog.older deleted file mode 100644 index 027420b3..00000000 --- a/branches/sdl2/attic/ChangeLog.older +++ /dev/null @@ -1,2183 +0,0 @@ -0.98.12: - - Win32: Fixed the behavior of the sound logging function. - - Fixed a bug that was causing 2xscale/3xscale to be broken - when clipping the leftmost and rightmost 8 columns. - - Added an iNES header correction entry for JustBreed. - - Modified the MMC5 "ELROM" board emulation to not emulate WRAM. - - Corrected various pieces of code that were causing compiler warnings. - - Win32: Scaling settings(x, y, stretch to fill screen) are now respected while - using a special scaler in full screen mode, though if x or y scale is - less than what is needed for a particular scaler, it will be - adjusted. - - Win32: The window will be reblitted when it becomes invalidated while - a game is loaded(such as when you're resizing the window). - - When the PPU is in a "dead" state after starting up, the graphics - buffer is now cleared. Previously, particularly in the Windows port, when - a game was closed, and a new game was loaded, the last image from - the previous game would be displayed for a short time. - - Win32: Blit skipping will now occur when sound is disabled and FCE Ultra is - running behind the desired frame rate. - - Win32: Blit-skipping behavior can now be configured to some extent in the "Timing" configuration - window. - - Win32: Added a "Recent Directories" submenu to the "File" menu. - - Removed some debugging code that shouldn't have been enabled in 0.98.11. - -0.98.11: - - Win32: Special scalers are now also supported in windowed mode. For Scale2x/Scale3x, - the fastest "desktop" bit depth is 16bpp. For hq2x/hq3x, it is 32bpp. - - The shared video blitting code(drivers/common/vidblit.c) can now blit using Scale2x - and Scale3x to any target bit depth(8bpp, 16bpp, 24bpp, and 32bpp) instead of just - 8bpp, as it was before. - HQ2x and HQ3x can now blit to 16bpp, 24bpp(untested), and 32bpp. The 16bpp and - 24bpp targets are done doing post-processing conversion, after HQ2x/HQ3x, which - really does hurt speed. - - Changed a few names in the credits section of the documentation to their - aliases. Names you didn't get to pick to have are so troublesome. :b - I also made various fixes/updates to the documentation. - - Updated the FAQ with some information regard video mode bit depths and speed. - - SDL: Disabled the fast-forward-key speed-limiting code. I thought I had - done this before... - - Fixed a major bug in the movie recording code, and added some code to automatically detect - and fix playback of broken movies from earlier versions. - - Did a little swapping thing with mapper 90 and 209. I moved back Mortal Kombat 3 - to mapper 90, and moved Shin Samurai Spirits 2 to mapper 209. Sorry for any confusion. - Mapper 90 should be considered as having the fancy nametable select mode disabled, with - mapper 209 having it enabled. - - Added support for mapper 160, which turns out to be the same hardware as mapper - 90. Joy. - - Improved mapper 90 emulation. This mapper really needs low-level - emulation for IRQs to work right, though. :/ - - Win32: Fixed the "hide left/right 8 video columns" feature. - - Since FCE Ultra is ending(or has already exceeded? :b) its actively-updated life, - I've gone ahead and added per-game hacks for "Kick Master" and the PAL version - of "Star Wars". See the documentation for more details. - - Minor optimizations to the high-quality sound emulation code. The FIR filter - code is the bottleneck, though, so these changes won't have much of an effect - on overall speed. - - Altered MMC3 IRQ emulation(and the hooks in ppu.c for it). - - Fixed a rather major typo in the VRC7-emulation code. - -0.98.10: - - Reimplemented network play. It now requires a standalone network play server, which - will be released as a later time. For fun, "starmen.net" is running this server, - which is publicly accessible. - I also made various code fixes/improvements to allow for network play, particularly - with the command handling code. - - Reworked much of the VS Unisystem emulation code, partially based on information from - MAME. The following games are now supported: - - Battle City - Castlevania - Clu Clu Land - Dr. Mario - Duck Hunt - Excitebike - Excitebike (Japanese) - Freedom Force - Goonies, The - Gradius - Gumshoe - Hogan's Alley - Ice Climber - Ladies Golf - Mach Rider - Mach Rider (Japanese) - Mighty Bomb Jack (Japanese) - Ninja Jajamaru Kun (Japanese) - Pinball - Pinball (Japanese) - Platoon - RBI Baseball - Slalom - Soccer - Star Luster - Stroke and Match Golf - Stroke and Match Golf - Ladies - Stroke and Match Golf (Japanese) - Super Mario Bros. - Super Sky Kid - Super Xevious - Tetris - TKO Boxing - Top Gun - - Win32-native: Fixed a bug in the debugger's breakpoint list that appeared when - one tried to delete a breakpoint(the control accidentally had auto-sort enabled, - causing a discrepancy between what was displayed and what was contained in internal - data structures). - - The current disk image XOR original disk image is now stored in save states. This - should greatly increase compressability(important for network play), and make - it a little more legal to distribute such save states now. - - Modified the save state format to allow for more precise and larger version numbers. - - Various minor code changes. - - Fixed initialization of the FCEUGameInfo structure, which previously led - to problems with sound output on the SexyAL-using ports(Linux). - - Apparently I added support for mapper 255 a while back. Documentation updated. - - Added iNES header correction information for Armored Scrum Object and Alpha Mission. - - Merged banksw.h into ines.c, fixed some of its prototypes in ines.h. - -0.98.9: - - Win32-native: Fixed the speed throttling used when sound is disabled. In previous - 0.98.x Win32-native releases, emulation was running at 1/2 the speed it should - have been when sound was disabled. - - Win32-native: Moved settings in the "Miscellaneous" configuration window - to where they should have been in the first place, and added "GUI" and "Timing" - configuration windows to accommodate some. - - Win32-native: Fixed the handling of the "Scroll Lock" key used to disable and - enable Family BASIC Keyboard input. - - Updated documentation to handle some slight differences in the Win32-native - port("Win32-native" is what the Win32 port using native APIs, as opposed to something - like GTK+ and SDL, will be referred to in documentation now). I also made - some other minor wording adjustments to the documentation. - - Added an iNES header correction for Dragonball. - -0.98.8: - - Fixed a typo in sound.c that caused only part of the sound registers - to be saved in save states. - - Win32: Switched over to the DirectDraw7 interface, from DirectDraw4's. - The surface Flip() method will now block, which results in somewhat - smoother animation/scrolling, especially when combined with the - auto blit-skip implemented in 0.98.6 when sound is enabled. - - Win32: Undid a change made in the last release that limited the - speed of fast-forwarding when using the tilde key. I really do - need to implement some sort of unified timing/blit skip system... - - Win32: Added an option, disabled by default, to ask for confirmation - before exiting FCE Ultra. - - Win32: Added an option, enabled by default, to disable the system - screen saver while a game is loaded. - - Win32: Added a new video synchronization mode, a "lazy" wait for - vblank/vertical retrace. It calls Sleep(0) in its wait loop. This - still uses all available cpu cycles, but it is much more friendly - to other processes than the old-style wait for vblank. - - Win32: Added support for joystick POV hats. - -0.98.7: - - Fixed a bug in the debugger's disassembler when disassembling - opcode 0xBC. - - Fixed the behavior of the right mouse button with zapper emulation, to - correspond with what it is documented as doing. - - Win32: Added proper support for maximizing the window. - - Win32: Rewrote most of the input and input configuration code. - - Win32: Changed the configurable aspect ratio to something sensical, the current - display's pixel aspect ratio, default of 1:1(square pixels). - - Win32: Made the default full-screen video mode the custom video mode. I should have - done this a long time ago to make custom video mode configuration more straighforward - for users... - - Added some JACK audio code to be used by the SDL build. I'll test it and complete - it later. - -0.98.6: Made several code modifications to work with older versions of gcc. - - Fixed more header file network play #ifdef-age. - - Fixed a typo in cart.h. - - Fixed some funky code in FCEU_memmove(). - - Fixed some source code causing compiler warnings. - - Fixed SexyAL's format conversion code to not rely on deprecated casting semantics. - - Readded the native Win32 code, and made many improvements. The major thing - that needs to be done now with it is to rewrite the input handling code and input - configuration code. - -0.98.5: - Added LL to the 64-bit integer constants in ines.c - - Fixed OpenGL support under Mac OS X. - - Added the ability to hide background and/or sprites with the F4 key. - -0.98.4: - Moved NETWORK #ifdef's to netplay.c to simplify things. - - Fixed gzip file loading code(I think). I'm still a bit unsure about the semantics - of dup() and close(), though. - - Corrected FDS code to try loading the FDS image before loading the BIOS. - - Readded "native" SDL sound code, used for Mac OS X(and maybe BeOS). - -0.98.3: - Removed the wxWindows GUI code. GTK+ 2 code will take its place, - once it is ready. - - Added reset and power commands to the movie format. More commands(such as insert - disk, eject disk, flip dip switch, etc.) will be added simultaneously as work - on network play continues. - - Modified SexyAL OSS code to not adjust the number of fragments to a power of 2. - It works fine on my card, allowing finer-grained buffer size control, - but I'm not sure it will work with all chips. - - Fixed parsing of the "-specialfs" command-line argument. - - Added the hq3x scaler. - - Updated to the latest Scale2x code. I also added the Scale3x scaler. - - Changed the keyboard assignments for toggling full screen to "Alt" + "Enter". - - FCEUI_SaveState() and FCEUI_LoadState() changed. Porters should read - driver.h. - - Miscellaneous changes to accommodate new network play plan. It's not close - to being finished. - - Altered RTI emulation. In Paris Dakar Rally's NMI handler, it does "CLI ; RTI". - Previously, FCE Ultra would generate an interrupt right after RTI occured, due to the - presumed latency that RTI had with the I flag. I changed it so there is no latency, so - no interrupt will occur in this case(interrupts kill this game). The interrupt source - is the "frame IRQ", which it never disables, if anyone cares. - This change does break the "Stars SE" demo, though. Hmm. - - "FCEUGameInfo" is now a pointer, rather than just a statically-allocated structure. - This may cause some null-dereferencing-related crashes, but it should help keep - code a little cleaner(maybe?). - - Played around with the FDS FM code some more. It's still not right. Bah. - - Hacked in support for entering Datach/Barcode World barcodes without a GUI, using the - F8 key and the numeric keys. - - Added code to save/load movies. Movie support will only record/play back the - states of the four emulated gamepads. - - Modified the sound code to use timestamp/timestampbase differently. In addition, - timestampbase is now saved in save states("timestamp" doesn't need to be saved, since - it's reset to 0 at the end of each emulated frame). - -0.98.2: - Fixed a few problems with the SDL command-line build code - for Win32. Also, SDL 1.2.7 seems to have a bug that breaks FCE Ultra's - full-screen/windowed switching capabilities(at least under Win32). - Stupid everything. - - Minor SexyAL changes. - - Updated documentation. - -0.98.1: - - Increased the volume of the FME07 sound channels. - - Fixed a bug in the SexyAL endian conversion code. - - Made the SexyAL chunk conversion loop work. - - Replaced the old OPL2 emulator with a modified version of - Mitsutaka Okazaki's YM2413 emulator for the VRC7 sound emulation. - - Decreased the pitch of the FME 07 expansion sound channels by one octave. - - Decreased volume of output of $5011 in MMC5 emulation code. - - -0.98.0: Some changes I made aren't listed below. Ah well. The magnitude - of the changes was too great... - - - Default sound volume is 100(%), which makes a lot more sense than 75%, but not much. - It's multiplied by 3/4 internally now. - - Added support for the Datach barcode reader(GUI interface only). The emulation code - was adapted from the VirtuaNES source code. - - Reassigned the Datach games to mapper 157, from 16, with CRC32 checks. - - Increased the maximum number of screen snapshots in the snapshots directory - to 99999(from 999). - - Reassigned the following games to mapper 210, using CRC32 checks: - Chibi Maruko Chan - Dream Master - Family Circuit '91 - Famista '92 - Famista '93 - Famista '94 - Heisei Tensai Bakabon - Top Striker - Wagyan Land 2 - Wagyan Land 3 - If you use a hack/translation of one or more of these games, you will of course - need to manually change the mapper number in the header for it to work properly in - FCE Ultra. Family Circuit '91 still may not fit in with the rest of these games, - but it's definitely not a "stock" mapper 19 setup. - - Fixed an OpenGL palette bug when using scanlines(previously, I think it was - setting the palette of the scanlines overlay texture instead of the actual image - texture in some instances). The bug showed up on games that make use of the color - deemphasis bits. - - Rewrote a lot of the PPU background rendering code to be more accurate(and - obfuscated!). This eliminates the X-offset hack I made earlier. - - Removed some of the NSF visualization code, and altered the look of the NSF - display slightly. The NSF waveform visualization code will now take into - account the current volume setting. - - Changed the default key bindings for the standard emulated gamepad - to something more compatible with window managers. I may change it back, but probably - not, since it is easily configurable now. - - Updated the MMC5, VRC6, and FME07 low-quality sound emulation code - with the compatible parts of the high-quality sound emulation code for those chips. - - Adjusted timing of horizontal scroll update(near the beginning of hblank. I made - it occur sooner). I also added a hack to allow X-offset(fine X scroll) changes mid - scanline, however, it is extremely ugly, and may not work correctly for everything - (doing it correctly would probably kill speed). - I mainly did it to fix games like F-1 Race and Mach Rider, and other racing - games that are extremely sensitive to horizontal scrolling timing. - - Some FDS IRQ emulation changes to fix some screen corruption problems - in "Kaettekita Mario Bros". - - Removed zlib(the code, not support). - I also removed support for compiling without zlib(it's small, simple, provides - very useful functions, and may provide critical features for fceu in the future). - - *undone, breaks debugger, FIXME.* Replaced some inline functions with macros in x6502.c. - - Increased the speed of Namco 106 sound emulation in HQ sound mode. - - Many many sound emulation changes and adjustments based on blargg's tests. - The default sound volume is about 150% what it was before, because the sound range - has changed(now -soundvol 100 is like -soundvol 200 on older builds), and the - default "soundvol" setting is 75. 100 clips on some Namco games, and 200 clips - on many games, so I'll probably have the configurable volume range as [0:125]. - What exactly is "%" supposed to mean in this case.... 100% of what?! - - When using low-quality sound emulation mode, total emulation speed is about 10% - less than previous builds. The change in speed for high-quality sound emulation - mode is significantly less. - - Added beginnings of SexyAL to source code tree, removed SDL sound support, and - old OSS code. - - Copied over some autoconf/automake stuff from phamicom. It stills needs a bit - of work... - - Fixed DMC IRQ emulation. Fixes many CodeMasters games. Finally. ^_^ - - Restructured a lot of files, changed the interface between driver and - emulator code slightly. - - * Insert stuff here * - -November 28, 2003 - Snapshot - - Removed the DOS, Linux SVGAlib, and Win32 targets. *GASP* - Win32 support will return(eventually), using SDL + wxWindows. - SDL can use svgalib or GGI anyway, so it shouldn't be a huge loss. - DOS support will only return if someone ports SDL to DOS. ^_^ - It would be nice if SDL could accept modelines. Maybe in SDL 2.0... - - Merged fce.c and svga.c into fceu.c, and fce.h and svga.h into fceu.h. - - Reassigned "Mortal Kombat 3 - Special 56 Peoples" to mapper 209. - - Added emulation of the "Oeka Kids" tablet. - - Added emulation of the Family Trainer. - - Added emulation of the "Ultimate Quiz King" buzzers. - - Added emulation of the Mahjong controller. - - Added emulation of HyperShot controllers. - - Fixed loading of NSFs with load addresses below $8000. - - Cleaned and simplified some of the NES APU code. - - Altered mapper 65 emulation. Fixes Kaiketsu Yanchamaru 3. Does it break anything? - - Wrote a small FAQ file. - - Fixed displaying of garbage and other unpleasantness on the first scanline. I need - to clean up that code, though. - - Fixed color deemphasis emulation when all bits are set. For some - reason, I had commented out the code. Bleh. - - NSF player now writes $C0 to $4017 if the FDS is being used(the FDS - BIOS writes $C0 to $4017). $40 for all other NSFs. - - Added support for iNES mapper 58(nnnesterj). - - Added support for iNES mapper 208. - - Reassigned "Fudou Myouou Den" to mapper 207(CRC32 checks). - - Reassigned "Karnov" to mapper 206(CRC32 checks). - - Fixed the mapper 95 code, which was horribly broken. - - Differentiated between mappers 33 and 48. Added CRC checks to assign - some games to mapper 48. "Flintstones 2" and "Don Doko Don 2" are - the games that need to be assigned to 48. Are there others? - - Replaced usage of TriggerIRQ to X6502_IRQBegin/X6502_IRQEnd combos in - various mapper emulation files. 67, 33/48, 40, 73, 42, 65, 6, 182 - Removed function TriggerIRQ() from x6502.c - - Fixed the sound volume of the VRC7 emulation in high-quality sound mode. - Decreased(slightly) the volume of VRC7 emulation in both high-quality sound modes. - - Decreased the volume of the MMC5 expansion sound channels. - - Decreased the volume of the FME-7/mapper 69 expansion sound channels. - - Added FCEU_gmalloc(), which will call exit() if memory allocation fails, - otherwise it is guaranteed to return a memory block. - This will be used in the mapper code mainly. It should only - be used for small memory chunks. The reasoning is that if 64 some like KB of - RAM or less can't be allocated, for example, it'd probably be best to - exit the emulator ASAP. It also helps to simplify code logic, and - help (me) with modularization. - The behavior of this may change in the future. I still need to think about it. - I should probably save the configuration file regularly(or much better, - use the registry) on the Windows port, though. - - Cleaned up the save-state saving/loading code a bit, and added - support for linked save state structures for better modularity and - less code duplication. - - Merged the iNES and UNIF MMC1, MMC3, and MMC5 code more completely. - I may need to sanify CHR RAM and WRAM allocation for pedanticness, - though. Also worked on Tengen RAMBO-1 emulation, and mapper 90 emulation. - ***THIS MAKES SAVE STATES FOR GAMES THAT USE THESE EXPANSION CHIPS INCOMPATIBLE - WITH PREVIOUS VERSIONS*** - I plan on doing the same thing with other mappers/boards in the future, though. - Always on the quest for 1.0... - -November 12, 2003 - 0.97.5 Release - - Windows: Added limited support for arguments that change configuration - to be passed to FCE Ultra. Example: fceu -pal 1 c:\streetgangs.nes - It may be useful in frontends. - - Fixed filename generation for automatic IPS patching when a file - with no extension is loaded. Before this change, FCEU would - look for "game..ips" with a file named "game". - - Converted and updated the cheat guide in(to) HTML. - - Added support for iNES mappers 202,203,231 from info from cah4e3. - Fixed support for mappers 60, 200. - - Fixed various major bugs in the breakpoint deletion code. - - UN*X: Added support for OSS(/dev/dsp) devices that don't support mono - sound. - - Increased PPU startup idle time to 2 frames. Fixes that - unlicensed "Earthworm Jim 3" game. Does it break anything? - -November 9, 2003 - 0.97.4 Release - - Fixed another obscure PPU emulation screen corruption bug. - - Added support for Game Genie cheats in the cheat interface. - - Windows: Reworked the cheat interface, merging the cheat search - and cheat list windows into one. - - Windows: Greatly improved the CPU debugger. - The code still needs a lot of cleaning, though. - - Readjusted VRC6 IRQ emulation timing. - - Added support for the UNIF MMC3 board TEROM. The maximum PRG/CHR sizes - may not be correct in this implementation, though. - -November 8, 2003 - 0.97.3 Release - - Added a control to set the highest quality sound mode in Windows. - This change requires that any users who previously set - "high quality sound" to set it again. - - Fixed the volume of high-quality sound mode again. The changes - I made earlier didn't affect all the filter coefficients. - -November 8, 2003 - 0.97.2 Release - - Made a minor optimization to writes to palette memory. - - Altered VRC6 IRQ emulation timing slightly. - - Fixed a weirdo PPU emulation bug that could cause garbage on the right - side of the screen in certain situations. Thanks to FrenziedPanda for - bugging me enough to make me look into the problem and fix it. - I should be on the lookout to see if the fix breaks anything, though. - - Fixed the volume of high-quality sound mode(-soundq 1). It was - at 1/4 the volume it should have been. I compensated by increasing - the precision of the filter coefficients, which increased the sound - quality of that mode slightly without hurting performance. - -November 7, 2003 - 0.97.1 Release - - Fixed mapper 105 emulation. I had begun merging it into the - rest of the MMC1 code for 0.97, but I hadn't finished it. - - Changed things like RdMem(_PC++); to RdMem(_PC); _PC++; - Darn evil global variables. I need to fix them. Screw speed. - - Expanded checks for the global variable "fceuindbg"(used in debug - mode to prevent reads in the debugger from altering any registers). - -November 6, 2003 - 0.97 Release - * Note: I still had much more I had wanted to get done for 0.97, - but I lost even more interest. The Windows port still doesn't - have a way to enable the "highest" sound emulation mode, nor the - low pass filter code, not to mention that the lowpass filter code - isn't complete(I would need to design a high-order FIR filter from an IIR - filter to work properly-have the correct rolloff, among other - things-at finite playback rates). - - Fixed a bug in the IPS patcher. The recorded size wasn't being updated - after a successful realloc() was made, which could lead to corrupted patch - data from some patches. - - Added support for mappers 200, 201 from submitted code. - - Rewrote mapper 15 support to make more sense(well, depending - on your point of view...). - - Fixed 256KB CHR select support for mapper 115. - - Added support for mapper 12 from code from cah4e3. - -October 16, 2003 - Snapshot - - Fixed support for mapper 245(for nonencrypted/non-smynes-screwed up - ROM images only. Fixes "Yong Zhe Dou E Long [...] Dragon Quest 7". - - Added support for mappers 60, 62, 230, 244 from submitted code. - - Modified mapper 90 emulation to allow game-select on reset - for "Final Fight 3". - - Modified mapper 45 emulation to allow "Super 8-in-1" to work. - - Added a low-pass filter, and an option to enable it(CLI ports). - - 0x00 is now written to $4011 in the NSF player code instead of 0x40. - Fixed some other similar sound register init problems that I had fixed - in Festalon but forgot to fix in FCEU. Grrr. - - Removed some unnecessary 64-bit integer usage from FIR sound filtering - code. - - Added a new sound quality mode. Higher than high, it's highest(in - FCE Ultra, for now). Still need to fix the interface to allow - enabling it in the Windows port. - - Added some code for lower-level MMC3 IRQ emulation. It isn't completed - , and will not work properly as-is. I'm still playing around with - it occasionally. - - Fixed the sprite overflow flag(I think I fixed it), that was broken in an earlier - pre-0.97 release. - - Fixed support for iNES mapper 193. - - Command line arguments "-pal" and "-gg" now take extra arguments(1/0) - and are remembered in the configuration file. - -September 27, 2003 - Snapshot - - Added support for iNES mapper 50. - - Modified the UNIF board initialization code. Hopefully, this - new interface will eventually be used with the iNES code. - - Miscellaneous code cleanups. - - /dev/dsp is now set to 8(previously 9) buffers of 128 samples in length - in the SDL code. - - Tried to make the save state code more expandable and modular. - - Moved a lot of the PPU code into ppu.c. - - Added more extensive debugging code to the 6502 emulator, to allow - for memory read/write hooks(including zero page addressing modes). - - Readadjusted DMC timings when PAL emulation is enabled. It looks - like it was correct before I had made the August 2 change. Thanks - to Bananmos for the information. I think. :/ - - Added support for iNES mapper 193 from information from virtuanes. - I think my dump of it is "bad", though. PRG and CHR pages look - like they are in the wrong order(logical vs physical? Who's to say - what's physical?). - -September 1, 2003 - Snapshot - - Fixed some minor initialization issues with iNES mappers 7 and 34. - - Added support for UNIF board NES-GNROM. - - Removed support for save states created with versions of FCE Ultra - less than 0.56. - - Replaced SDL sound buffering code with a lock-free FIFO implementation - written by David Olofson, with a few modifications by myself. - - Fixed a VRC7 NSF bug(it showed up under the reworked driver/file - loading order in the cli code). - - The board in "Rolling Thunder" has "RAMBO 1" on it, not "RAMBO-1". - -August 9, 2003 - Snapshot - - Removed the old plain text documentation and replaced it with - a new document in HTML. It is not completed yet, though. - - Rewrote the SDL-native audio code to be less wacky and more - thread-safe(hopefully). I'm still waiting for a new SDL audio - API... - - Altered the MMC5 IRQ timing. Fixes minor graphical glitches - in Castlevania 3. Does it break anything? - - Removed some debugging code that got into the last snapshot. - -August 5, 2003 - Snapshot - - Added some code in the IPS patcher to allow for expanding the size of files. - - Fixed a double free() bug with a mapper 51 game(in ines.c). - - Added support for "Alien Syndrome" (US release) as iNES mapper 158. - It looks like a derivative of the normal RAMBO-1 board(or is that - the name of the chip?), similar to TKSROM/TLSROM(mapper 118). - - Improved the "native" SDL sound code. It will now call SDL_Delay(), - among other nice things. The code could probably be improved more, - though. - - Added support for decimal components in xscale/yscale in the SDL - port. Set the default xscale for windowed mode to 2.40(to get a - more correct aspect ratio, assuming the display is currently at - a 4:3 aspect ratio). - - Modified args.c to handle floating-point numbers. - -August 2, 2003 - Snapshot. - - Disabled texture wrapping with OpenGL(there were problems at the edges - of the screen with linear interpolation). Bah. Now the edges - are too bright... - - Improved the accuracy of the DMC timing when PAL emulation is enabled. - I still don't think it's totally correct, though. - - Changed the default settings for the SDL code. Full screen - is now 640x480x8bpp by default, xscale and yscale are 2 for both full - screen and windowed, opengl support is enabled, linear interpolation - for OpenGL is enabled, and X-axis stretching is - enabled(in full screen). - - "Scanlines" were enabled in 8bpp to 8bpp blits in - drivers/common/vidblit.c when they shouldn't have been. Fixed. - - Fixed OpenGL code under big-endian platforms. - -August 1, 2003 - Snapshot. - - Various code clean-ups. - - Played around with adding a GTK+ GUI to the SDL code. - - Rewrote part of the hq sound rectangle wave code. - - Replaced the high-quality sound inline assembly filter code with - slightly faster C code. - - Hacked around with GP32 support. I don't know if the GP32 would - be fast enough, though. - - Skipped frames will now have D5 of $2002 set at the beginning - of the frame. Fixes "Bee 52". I must see if it breaks anything. - - Added OpenGL support to the SDL code. - - Removed the PPU drawing inline assembly code, replacing it with a faster - algorithm written in C. - - "Disabling" the 8-sprite limitation will no longer cause - "Bee 52" to break. However, the "Solstice" wizard will still - have the weird thing growing out of his face in the introduction, - since it depends on no more sprites to be rendered. - - Added entry for that Black Bass game for header corrections in - ines.c - - Strip color burst bit(D0 of $2001) is only "emulated" if bg or - sprite rendering are turned on, at the end of the scanline. - Doing it with pixel/tile granularity would require modifying - the sprite graphics data copying routine, which I don't - feel like doing. Fixes that crazy Sayoonara demo by Chris Covell. - I also modified the NES RAM initialization code. - - Adjusted VRC7 IRQ emulation for better Lagrange Point goodness. - - Added support for iNES mapper 91. (VirtuaNES) - -0.96: - Improved RAMBO-1(mapper 64) emulation. "Skull and Crossbones" is - now playable. - -0.95: - - timestamp and timestampbase are no longer saved/loaded to/from - save states. They were causing too many problems I didn't - want to fix, and I never intended them to be saved in save states - when I wrote the code that uses them. - I think the reason they were being saved was that I wanted to make it - possible to add movie support and network play save state loading - (distributing the save state over the network). So if someone in - the future wants to add these features, the issues(primarily with - zapper emulation and sound emulation) with saving the time stamp will - need to be resolved. - - Fixed some crashing bugs when save states are loaded when - high-quality sound emulation is enabled. It is like patching - holes in a swiss-cheese boat. All the holes may be patched, but - it looks ugly. At least it tastes good... - TODO: Look into saving more data in the save states, especially - data that is based off of "timestamp" and "timestampbase". Also - look into validating this data. Right now, corrupt save state data - might cause memory corruption in FCE Ultra. - - Fixed some bugs in the NSF player. - - Cleaned up more code. - - Reduced the usage of TriggerIRQ(). - - Split the palette code into a new file, palette.c, from svga.c - - Low-G-Man(NTSC and PAL versions) are now recognized by CRC32 value, - and WRAM will be disabled if they are loaded. A warning/status message - will also be printed regarding this issue. - - Decreased the volume of the DMC/PCM channel in low-quality sound - emulation. - - Low-quality sound emulation now uses 32-bit integers for much - better speed. - - FCEUI_CRC32() wasn't returning anything. D'oh. Fixed. - - Added somewhat crude support for games that switch background CHR data - mid-scanline (this is needed in games such as Mother, Pirates!, - Business Wars, and Marble Madness). - - Altered NMI, IRQ, and BRK emulation again. Fixes some games, - like Bases Loaded 2 and Dynamite Bowling, and maybe some others. - I had to increase the size of the IRQlow variable for delayed - NMI execution... I also had to add a delay between PPU reset - and the PPU actually doing anything, to fix "Knight Rider". - - Fixed a mapper 90 save state bug. - - /dev/dsp code now searches for /dev/dsp before /dev/dspX (where X is - a non-negative integer). - - SDL joystick axes configuration is now done from the joystick. - - Tweaked various Konami mappers' IRQ counter emulation. - - Added custom SDL throttle code that gives up time slices instead of - using 100% cpu. - - Fixed an issue with sprite priorities on MSB-first platforms. - - Modified powerpad.c to avoid a symbol conflict when compiling on the - Power PC architecture. - -0.94r3: - sound.c: - Fixed a divide-by-zero bug that occurred when a virtual - reset(like by pressing F10) occurred when sound emulation was - disabled. - -0.94r2: - drivers/common/vidblit.c: - Fixed code for 32bpp blur effect. - - drivers/cli/sdl-video.c: - Added error message for unsupported bit depths. - - mappers/simple.c, ines.c: - Used this bug fix pseudo-release as an excuse to add - support for mapper 107. Information taken from virtuanes. - -0.94(fixed release) ---- - Fixed call to InitUNIXDSPSound in svgalib.c - - Added man pages. - -0.94 ---- - Added support for rapid fire A/B buttons on physical joysticks - in SDL/svgalib/DOS code. - - Implemented "high-quality" Namco 106 emulation(used for hq sound mode). - In this case, "high-quality" means sounding more like it should, - not necessarily cleaner. I'm not certain that it's totally correct, - but it's in the right direction. - - RAM cheats should no longer affect Game Genie emulation. I still - need to completely verify this. There may be some sort of race - condition. - - Removed various minor speed hacks in the name of style and - correctness(and to make maintaining FCE Ultra easier for those - people who are not me). :) - - Removed NSF cpu hacks, as I changed code to make them unnecessary. - - Fixed another FDS IRQ emulation bug. "Famicom Grand Prix II" works - now. - - Fixed a memory leak and a heap corruption bug in "file.c". - - Added support for on-the-fly IPS patching. - Place the IPS file in the same directory as the file to load, - and name it filename.ips. - - Examples: Boat.nes - Boat.nes.ips - Boat.zip - Boat.zip.ips - Boat.nes.gz - Boat.nes.gz.ips - Boat - Boat.ips - - Some operating systems and environments will hide file extensions. - Keep this in mind if you are having trouble. - - Patching is supported for all supported formats(iNES, FDS, UNIF, and - NSF), but it will probably only be useful for the iNES format. It - can be used with the FDS format, but be warned that it will permanently - patch your disk image, as the disk image is written back to disk - when the game is unloaded(unless the disk image is in a zip file, in - which case it isn't written back to disk). UNIF files can't be - patched well with the IPS format because they are chunk-based with no - fixed offsets. Support for a UNIF patching format may be added - in the future(probably by someone else.). - - Added more games to the list in ines.c for having battery-backed - WRAM, for header corrections. - - Copied over the 96KHz filter coefficients from Festalon that I forgot - to do in 0.92. Oops. - - -0.93 ---- - - Reduced the volume of the FDS sound channel. - - Fixed a bug in the FDS IRQ emulation code that caused "Lutter" to not work. - - Fixed a bug in unif.c that would cause a crash if a unif file were - loaded without a board name being specified(as could happen - with a corrupted nsf). - - Fixed a bug in general.c relating to relative filenames(running - fce ultra like "./fceu ../big.nes" would work, but "./fceu ../big" - would not work- it crashed). - - - -0.92r2 ---- - Fixed dpcm irq bug that broke Cobra Triangle. - -.92 ---- - - Removed NSF player background, and added some special effects goodies. - - Changed the NSF player to use the emulated gamepad as input instead - of having special NSF-player-only keys. - - Added support for mapper 249(using nonencrypted games), thanks to SARO - for info. SMYNES sucks. - - Updated video blitting library-thing(vidblit.c) with more special - effects, and removed 24bpp support. - - SDL cleanupification. - - Added support for mapper 61. - - nnnesterj: Added support for mapper 57. - - Fixed mapper number for "Golden Game 150 in 1". Changed it to 235 - from 43. - - DDraw back buffer surfaces are now created in system memory if the - hardware blitter can't do stretching. - - Restructured file wrapping code. - - Added new cheat search methods. - - Fixed a major cheat unloading memory bug(and memory leak). - - Emulated that funky nonlinear DAC effect for hi-quality sound. - - More fixes/cleanups to FDS emulation code. - - Tweaked PPU timing a bit. - - Improved network play. - - Holding the enter key down will no longer do fun stuff to the nsf - player. - - Improved NSF player. It should support streaming pcm nsfs now... - - Changed FDS keyboard keys around a bit. F6 is the disk select key, - and F8 is the disk insert/eject key. - F8 to insert VS Unisystem coin, F6 to view/toggle dip switches. - Hopefully people won't complain after blindly hitting the save state - buttons. :) - - Many fixes and improvements to the Windows port. No more cpu-consuming - wait loops(specifically, sound). Added a message window. - - FDS sound emulation improvements. - - FDS disks are now auto-inserted on power on(or was it loading a new - game...). - - Changed the default last rendered scanline to 231. - - ines header corrections are now printed as status messages, not errors. - - Rearranged input updating code. - - Fixed a sprite transfer bug. Fixes PAL version of Rainbow Islands. - - Debugger hooks added. - - Small optimizations in Refreshline and FetchSpriteData to hopefully - offset the slight slowdown in the cpu core. - - MapperHBIRQHook is now called differently(depending on hi/low bg/spr - addresses). - - Added support for unif board UNL-8237. - - Added support for mapper 144(death race). - - Added partial support for mapper 74. - - Fixed a cpu emulation bug in GETIYWR. It would sometimes set "target" - to 0x10000, which was a BAD THING(overflow; now it wraps). - - Tried to add support for mapper 241. Needs special keyboard emulation. - I think. - - Internal RAM is now initialized to something other than 0. Fixes - Minna no Taabou no Nakayoshi Dai Sakusen. - - Reassigned "The Money Game" to mapper 155. It doesn't seem to - respect the WRAM enable/disable bits. Silly game. And - Tatakae!! Rahmen Man. - - Added support for mapper 115(still needs 256KB CHR select), 241, 114,88. - - Attempted to add support for mappers 91, 187. - - Modified frame IRQ to not break so many damn games. - - Fixed sprite hit detection loop. - - Improved support for mappers 80, 90,117,154, 189. - nnnester and virtuanes. - - Reassigned "Devil Man" to mapper 154. - - Removed bogus Trojan header fix in ines.c. - - - -.81-post: ----- - Fixed/Worked around(?) compilation problems on gcc 3.2.x. - -.81: ----- - - More SDL goodies. - - Renamed "Makefile.olinuxsdl" to "Makefile.unixsdl" - - More SDL fixes and cleanups. - - BeOS port is now compiled with the "-no-fpic" flag, which allows - me to use my inline assembly. The executable work fine as far as - I can tell. - - Added "Makefile.beos". gcc doesn't like my inline assembly - used in RefreshLine(),so this port will likely be slightly slower than - other x86 ports. - - Added a check to make sure SIGBUS is not equal to SIGSEGV in - drivers/cli/main.c. Needed for compiling under BeOS. - - Renamed the "PI" member of the X6502 structure due to conflicts with - a defined symbol with some math header files. - - Merged fcelineasm.h into fceline.h - - Fixed(possibly) a possible problem in fcelineasm.h with input register - clobbering. - - More SDL changes. - - Added speed throttling code to the CLI code, and added a command - line switch "-nothrottle". - - Lots of restructuring/rewriting/merging of the MMC3 code. - - Updated DOS code to use the generic CLI wrapper. - - Reads from $4090 and $4092 now return the current envelope setting - in FDS sound emulation. I'm not sure if this is correct... Affects - "Ai Senshi Nicole" and "Bio Miracle Bokutte Upa". - - Added native SDL sound support to the SDL code. the "olinuxsdl" - now uses this code by default instead of the unixdsp sound code. - - Modified MMC3 IRQ counter emulation. I'll need to watch out to see - if it breaks any games. Fixes: MegaMan 3, Gun Nac, Klax(Japanese). - - Changed a few memory reads in x6502.c to use RdRAM instead of RdMem, - resulting in a slight speed increase. - - Cleaned up mapper 250 emulation code. - - Added support for iNES mapper 51(thanks to Kevin Horton for the - information). - - Merged some iNES mappers corresponding to bootleg multicarts - based on MMC3s with mbshare/mmc3.c. - - Added support for iNES mapper 52(thanks to Kevin Horton for the - information). - - Made some hacks to the MMC3 emulation code so that I can add support - for pirate MMC3 multicarts more easily. I should clean it up later. - Moved mapper 44 emulation code to mbshare/mmc3.c. - - Saving screen snapshots will no longer corrupt the frame buffer - for one frame(unless memory couldn't be allocated). - - Fixed screen snapshot saving(it was sort of broken due to the - changes made to the driver<->emulator interface code; status - messages were being saved to the image). FCEUI_SaveSnapshot() - no longer returns a value(the request to save a screen snapshot is - serviced before status information would be written in the next frame). - - nosprites is now set to 0 before RefreshSprite() returns, to prevent - problems if a game turns off the bg and sprites when FetchSpriteData() - for the next scanline is called but then turns on sprites when - the actual scanline is drawn. - - PPU_hook() is now called more often if PPU_hook is non-null. - Made changes to mappers 118, 95, 9, and 10 to compensate. - No games seem to be broken, and I added support for mapper 96 - (though the games aren't very playable because the special controller - isn't emulated). - - Romance of the 3 Kingdoms is now recognized to use 16KB ex-WRAM. - - Added support for mapper 185...sort of. I think this is another - instance of incompatible hardware being lumped onto one mapper number. - Sigh. - - Added support for "Famicom Jump 2" as iNES mapper 153. - If a good(as far as I can tell) dump is loaded, FCE Ultra will - automatically fix the mapper number. - I also made some changes to the mapper 16 IRQ emulation code. - - BRK now sets the I flag. - - Reads from $4015 no longer reset DPCM IRQ. - - Changed emulation of RTI instruction slightly. - - X.IRQlow is now set to 0 in PowerNES(). - - The VS Unisystem bit in the iNES header is no longer looked at( - I was having too many problems with this bit being set when it - shouldn't have been). Now, VS Unisystem emulation is enabled - when a known VS Unisystem game is loaded. I also rewrote the VS - Unisystem detection function. - - iNES mapper 1 now supports pageable CHR RAM if no CHR ROM is present. - Fixes "Family School". - - Mapper 70 no longer has a mirroring control emulated, and I extended - the number of 8KB CHR pages supported to 16. - - Cleaned up iNES MMC5 save RAM loading/saving code and added - support for MMC1 games with 16KB of RAM(the second 8KB are saved), - via CRC32s(currently only Genghis Khan(USA) and Nobunaga's Ambition( - USA and Japan) are recognized). - - Added support for the MMC5 Koei game "Ishin no Arashi", in the iNES - format(I added an entry with its CRC32 value and the number of 8KB - WRAM banks it needs). - - Better iNES mapper 33/48 IRQ counter emulation. - - Added the game "Uchuusen - Cosmo Carrier" to this list. I'm - beginning to hate the iNES format more and more...or maybe - just Fanwen. :) - - Added the mapper 32 game "Major League" to the list of games - that usually need iNES header correction...but in this case, the - iNES header cannot specify that this game needs to have one-screen - mirroring. - - iNES header information is now printed before any header corrections - are made based on a database. - - Fixed a bug in mapper 32 emulation. "Ai Sensei no Oshiete" - works now. - - Tried to add support for iNES mappers 245 and 249. - - Fixed the MMC5 read handler to return the data last on the data - bus instead of 0xFF when a read was made to an unmapped address. - This seems to fix the lockup problems in "Bandit Kings of Ancient - China". - - Reversed "Modified the time at which the "y scroll" register is updated - during hblank." The changes broke Klax. - - Added an unsigned 64-bit base timestamp variable "timestampbase". - Adding this to the 32-bit variable "timestamp" will return - the number of cycles executed since emulation started(in the future - I'll probably change it to since reset or power toggle). - This allowed me to replace "lastn" hack in the MMC1 code with - something better. - - Changed my mind and undid the removal of support for old save states. - - Removed support for old save states and in general I won't - try to support save states made with previous versions. - - MMC1: Writes to $8000-$FFFF with D7 set will now cause - the first MMC1 register to be OR'ed with 0x0C. I'm not sure - if this is correct, but it doesn't seem to break anything - and it fixes Robocop 3. I'll see if anyone reports games - not working in .81 that worked in .80. - - Worked on a generic driver interface wrapper very similar - to the driver interface FCE Ultra used to use(I'm getting - tired of all of the duplicated driver code). Eventually, - the DOS, SVGAlib, and SDL ports will use this wrapper. - - Similar change to the argument parsing code. - - Changed configuration file saving-loading routines and the - configuration structure to allow for linking config structures - to each other). - - Small fix to the emulation of the MMC5 split screen mode. - - Made Linux SDL code compilable again. - - Changes to MMC5 EXRAM emulation(read/write). - - Fixes to the emulation of the MMC5's split screen mode, based on - observations while using CastleVania 3 and a Game Genie(on a real - NES). - - Fixed a bug in ines.c that caused any calls to AddExState() from - a mapper initialization function to be effectively "erased"(ResetExState() - was called after the mapper was initialized). Fixes the VRC7 sound - state saving/loading stuff. - - Finished adding support for the MMC5's split screen mode(this does - not mean that the support is complete, but at least the intro in - "Uchuu Keibitai SDF" works correctly now). - - Worked on adding support for the MMC5's split screen mode. Not - completed. - - Reverted to .80's FDS sound code. - - Modified the time at which the "y scroll" register is updated - during hblank. - - NSF playing code will now disable FDS sound output on song init - (fixes some problems with the Zelda no Densetsu NSF rip). - - Increased the emulated clock speed of the FDS sound emulation code - to give better quality output. - - Modified NMI to occur a few cycles later. Fixes BattleToads...but - it may have broken other games. Also modified the way NMI's are - handled in x6502.c. - - Modified ines.c to memset() GameMemBlock to 0 on virtual power toggle. - Also, trainers are now loaded into their own buffer instead of - directly into emulated WRAM and copied into emulated WRAM on - power toggle; I've been meaning to do this for quite some time. - - Changes to the way the zapper cursor is drawn on the screen. - - FCEUD_WriteSoundData(), FCEUD_BlitScreen(), and FCEUD_UpdateInput() - have been combined into one function: FCEUD_Update(). - - More fixes to the network play code, and a fix to the Windows network - play driver code that fixes(hopefully) a rather evil bug that caused - lockups when the remote stopped network play. - - Added code to set the battery-backed bit in RAM if a game needs it, - based on CRC32. - - Added more games to the list of games that commonly have bad iNES - headers, in ines.c - - Updated docs and usage.h for DOS and Linux regarding the new video - mode and the new refresh rates. - - Linux: Fixed a bug with video mode 6(a few upper scanlines were being - cut off). Increased the refresh rate of video mode 3 to 120hz. - - Increased the refresh rate of video mode 2 to 65 hz in the Linux port. - - Screen snapshots can now be taken while playing an NSF. - - Added a new sexy tweaked vga mode that I created to the Linux svgalib - port. It's 256x224 at a refresh rate of 103hz. Hopefully it won't - blow up anyone's monitor. ;) - DOS port will follow eventually. - - Modified Makefile.base to produce an executable named "fceu" instead - of "fce". - - The plans(cycle-accurate ppu emulation) for .90 were a bit ambitious, - and I still need to make other fixes before then. - - Fixed some minor(usually) bugs with setting 256x240 tweaked VGA mode - in DOS and Linux ports. - -.80: ----- - - Cleaned/fixed a few things in the mapper 19 emulation code. - Family Circuit '91 still doesn't work quite right... I wonder if - it's a bad dump. - - Added input override code to Windows port. - - Added code to fix iNES header information in RAM and suggest - changes to the user. - - Added support for iNES mapper 152(to be used with games set to - mapper 70, that use one-screen mirroring instead of h/v mirroring). - - Blits using the DirectX blitting function(method?) to the primary - surface are now done with the asynchronous flag set(if that - fails, a "normal" blit is tried). - - The DirectX blit buffer(secondary surface that FCE Ultra writes to - directly and then uses the DirectDraw blit function on to blit - to the primary buffer) is now created without specifying it - should be in system memory or video memory, except in the case - when no hardware blitting is available, and then DDraw is explicitly - told to create the surface in system memory. - - Added Family Keyboard support to the DOS port. - - Cleaned up the VRC7 sound emulation code. I need to find a way - to save the current sound state in a save state. - - Found out the real name of the "Space Shadow" gun; it's - called the "Hyper Shot". I'm still not sure who made it, though. - Possibly Bandai did. The interesting thing is that Konami - also made a Famicom accessory(dual square boxy things with two buttons - on each) with the same name(though there might not be a space in the - name). - - Only the upper two bits read from $4016/$4017 are undefined. - Bit5 is always 0, though. Fixed the bug in "input.c". - Silly kevtris' old documents. New kevtris' brain is always good. - - Family Keyboard support for the Windows port. - - Added support for the Family Basic Keyboard to the Linux port, other - ports todo. - Might want to add support for the tape recorder at some time. - Also mapped the "Scroll Lock" key to disable/enable command keys - so that the FBK is more useable. It doesn't disable CTRL C, - though... - - Changed a lot of inlined functions in x6502.c to macros so that - I could test out some optimization ideas. - - DOS code updates for game input override support. - - Small optimzation to opcode $4c, and relative jumps. - - Added some code to ines.c to set controller information in - FCEUGameInfo(returned by FCEUI_LoadGame()) based on crc32 values. - - Updated user documentation and usage.h for DOS and SVGAlib input - command-line changes. - - Added an option to disable the four-score(to Windows and Linux ports - so far). - - Updated Windows interface to support the new Famicom expansion - devices. - - (Re)Added support for the Famicom 4-player device. - - Improved Zapper emulation...sort of. It still needs a lot of work. :/ - - Added *partial* support for the "Space Shadow" gun. - - Added support for the Arkanoid controller(both NES and Famicom style). - - Added code to support the extension Famicom input devices. - - Added PAL scanline start/end drawing settings to Windows port. - - Added pause emulation key(F2) to Windows port. - - In the process of rewriting/fixing up input code stuff. - - Minor bug fix to Power Pad emulation code. - - VS Hogan's Alley and VS Duck Hunt automatically select the zapper - now(though it only works on the SVGAlib port). - - Undid some FDS sound code changes introduced in 0.76 that totally - screwed up sound. Oops. - - Added code to allow different settings for first/last scanline - drawn while in PAL emulation mode, to the Linux and DOS ports. - - Added convenience(it's not necessary, but it reduces redundant and - confusing code in the driver code) function - FCEUI_GetCurrentVidSystem(int *slstart, int *slend). - - Updated file "TODO". - - Changed #include to #include "zlib/unzip.h" - in file.c. - - NSF 6502 player now initialized the stack pointer on reset. - - Worked on de-emphasis emulation code quite a bit. - The deemphasized palette calculated at the end of the frame is now - based on what deemphasis bits were set for the longest during - the screen(sampling interval is a scanline) update loop. - Added a "static" deemphasized palette at $40-$7F in the palette table. - This corresponds to the colors when all of the deemphasis bits are set. - I did this to fix the PAL game "Noah's Ark", without breaking - anything else. The only downside is a slight speed loss(~2% on - my system when sound is disabled), but this is acceptable to me, - at least. - Maybe it's time to write hi/true-color ppu drawing code... - - - Fixed an out of bounds array access in svga.c in SetNESDeemph(). - The variable "lastd" in svga.c was being initialized to the wrong value. - Thanks to "Jarod CANAL" for pointing this out. - - Removed FCEUI_SetFirstRenderedLine or whatever it was called and - the function to set the last line. Replaced with: - void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); - - Changed SetVidSys(int w) to ResetVidSys() in fce.c. Reenabled - PAL/NTSC emulation overrides based on game loaded(really only useful - for NSFs and UNIFs now). - - UNIF loading code now recognizes the chunk "CTRL" and tries - to use it. Only the svgalib code supports overriding of input - settings based on game loaded, now, though... - The user is still going to have to configure powerpad settings - on his/her own. - - Fixed return values of FCEU_fseek() and fixed a problem in unif.c - related to it. - - Changed mechanism for how FCE Ultra tells the driver - code what type of system is being emulated. A structure of - type "FCEUGI" is returned from FCEUI_LoadGame(). - - Fixed a major mapper 64 emulation bug introduced in 0.76. - - Modified BlitVidHi() in drivers/win/video.c to speed it up. - - Added support for loading the iNES-format Game Genie ROM image. - - Removed ggrom.h and added code to load the Game Genie ROM - image from a file. - - Added Windows netplay.c. (new: the user exiting the emulator - while stuck in a blocking recv() or send() loop now works.) - - Fixed a vram address register bug in fce.c that I created when I got - rid of the pair/dpair data types. - - Added new mappers/92.c - - Removed mappers/92.c until I can contact LULU or rewrite it. - - drivers/win changes. Removed netplay.c until I can rewrite it. - - Got rid of pair/dpair data types. - - Got rid of silly "TempArray" thing. - - Began adding GPL headers to files. FCE Ultra is going to be in - a state of legal limbo for the next few days... - - Replaced crc32.c and crc32.h, and added some #ifdef's and #defines - to use the crc32 code in zlib instead if zlib is linked with - FCE Ultra. - - More fixes to sb.c. - - Cleaned up drawing.h and ggrom.h(even though ggrom.h will *probably* - be removed before the next release). - - Redid frameskip code. - - Rewrote necessary pieces of sb.c and sb.h and fixed quite a few - bugs. I still need to test it on various other sound cards, though. - - Rewrote(more like "recreated in my own image") DOS keyboard driver. - Removed unused "keyscan.h" from drivers/svgalib - - Rewrote part of(the parts that Marat wrote - the connection and - closing parts) the Linux TCP/IP network play code. I guess it works, - but I haven't tested it very much. In any case, it's still dangerous - to use network play in FCE Ultra with SVGAlib, since recv() or send() - might block and since the keyboard is in raw mode, you have a problem. - Maybe a future SVGAlib will fix the general problem of lockups if - keyboard_update() isn't called, though it is only partly SVGAlib's - problem... - - Fixed FCEU_fseek() when used with a compressed file in the PKZIP - format that has been loaded. Fixes a UNIF loading problem. - Also added a check to the return value of FCEU_fseek() in unif.c. - - Replaced Marat's 6502 emulation core with my own. - It should be fully functional, but as always, I don't know if - I implemented the undocumented instructions correctly. - Several things are correct in this new core that were not in - Marat's(D flag is no longer cleared by interrupts, for example). - - Altered mapper 16 irq counter emulation slightly. - - Fixed the behavior of the SXA, SYA, and XAS opcodes based on the - documentation I have. I'm not sure what happens when page crossing - occurs with those instructions on a real NES, though. - Also CHANGED(not fixed) emulation of opcode $8B("XAA"). - - Changed some of the M* functions(absolute indexed and maybe some others) - to perform dummy reads. - - Changed some of the macros in m6502.c to inlined functions so - that I can modify and examine them more easily. - -.77: ----- - - Fixed a silly network play bug(in the global network play code) - that caused excessive lag. - - Added a "niceness" setting to the sound configuration dialog. - Removed obsolete information from the dialog. - - Fixed speed throttling code in Windows port when PAL emulation is - disabled/enabled and a new game hasn't been loaded yet. - - Commented out a printf() to debug stuff in fds.c(oops). - - Applied PK's joystick patch to the osdl code. It allows the user - to map axes and it fixes a joystick button mapping configuration saving - bug. - - Added two command line options new to Linux port to DOS port. - Just need to test them... - - Added some stuff to unif.c to allow for boards that can support - CHR RAM instead of CHR ROM(darn Sachen boards...). Fixes UNIF - version of "Q-Boy". - - Added command line option "-snapname" to Linux port. I'll add it - to the Windows port as well, but probably not to the DOS port. - - Added clip option to Linux port. - - Fixed sound logging(in Windows port) so that multiple recording - sessions now work. - - Added an option to clip the leftmost and rightmost 8 columns - of graphics in the Windows port. - - Added a submenu that lists recently opened files, in the Windows - port. - -.76: ----- - - Updated porting.txt. - - Added speed throttling code to Windows port that's used when sound is - disabled(and an option in the "Miscellaneous" - configuration window to disable it). - - Added cheat interface to DOS build. - - A few tweaks to the text cheat interface code in the cheat listing code. - Added a command to quickly toggle the status of the cheat(though a - cheat can still be disabled/enabled by (M)odifying the cheat). - - Support for UNIF UNL-TC-U01-1.5M board added. Same credits as below. - - Rewrote mapper 228 code just for the heck of it(actually, I couldn't - figure out why some(about two) of the games in the Action 52 cart - weren't working in .75(and .76). I traced it back to .71, where an apparent bug in - the undocumented 6502 opcode emulation allowed it to work, which - was later fixed for the .72 release(opcode 0x7C)). I'm thinking - that the dump is bad... - - Added a few crc32 checks to ines.c to check for and report when - a known(by me) bad(hacked or bad dump) game is loaded. - - Added support for the following UNIF boards. Thanks to Quietust - and Kevin Horton for the information. Some problems still exist - with a few games that use these boards, though... - - UNL-Sachen-8259B - UNL-Sachen-8259A - UNL-Sachen-74LS374N - UNL-SA-016-1M - UNL-SA-72007 - UNL-SA-72008 - UNL-SA-0036 - UNL-SA-0037 - - Fixes to some stuff in cart.c(for example, calling setprg32() when - only 16kb of prg data is present now works). - - Added support for iNES mapper 189. - - Tried to add support for the UNIF board "UNL-H2288". Failed. - - Updated "cheat.txt" to fix a few typos and added an example of finding - and adding a cheat using the Linux port's text interface. The actual - section on the Linux cheat interface still needs to be written, however. - - Changed network play code in the Windows port and fixed a bug. - Fixed a similar bug in the Linux netplay code....sort of. - - A few cosmetic changes to the dialogs in the Windows port. - - Fixed sound initialization on the Windows port(it was being initialized - when FCE Ultra started even if it was disabled by the user. Oops.). - - Joystick button configuration code in Windows port changed slightly - to be more useable. - - Changed reference to video mode 5 in the linux port to "1 per 4". - It may not be very meaningful, but it is certainly better - than "TV Emulation". I'll change the Windows port reference later. - - Documented video mode 7(320x240) for the Linux port. Also added - a check for the FBDev driver in order to use this mode instead - of a tweaked vga mode if that driver is being used. - - Added/Fixed cheat interface for Linux port. It's still not perfect, - though. The code is ugly... - - Callback function for FCEUI_ListCheats() now receives - status information(enabled/disabled). - - Callback functions for cheat functions now must return 0 to - stop listing cheats or 1 to continue. - - Fixed a problem(the cheat code was reading in cheats - for address $0000 from cheat files if any blank lines were present). - - SDL port zlib changes(linked dynamically to zlib now). - - More changes to envelope decay + looping on code. No longer - depends on value @ $4017. It now sounds correct based on some - tests I did with SMB3 and a GG, but Goonies 2 doesn't sound right( - based on a sound file sent to me by another person). - - Added support for iNES mapper 140. Thanks to Quietust for the - information. - - I need to figure out how to deal with the problem of so many - bad NSFs that most people consider good... - - Changed envelope decays a bit. Their behavior now depends on bit - 7 of $4017. I don't know if this is right... - - Addition of debug.c for some debugging stuff. - - Updated zlib to 1.1.4. - - Modified code in various files to allow UNIF games to override - current selected video system emulation(NTSC or PAL). Need to - make sure this really works. - - Changed sound.c to prevent desynchronization during network play. - This might slow down sound emulation slightly, especially when - sound emulation is disabled. I really don't care... - - Updating network play code. More info later... - - Moved the sound/video/etc output code in EmLoop() to the top of the - for(;;) loop so that initialization prior to calling EmLoop() will - be the same as initialization done during a call to a FCEUD_* function. - - A few very small changes to sound emulation in fds.c. - - Changed unlink() to remove() in cheat.c and removed the including - of the header file unistd.h. - - Split up the cc=... statement in RefreshLine() to make it easier - to read and not ambiguous(to Borland's C compiler). - - Changed a lot of the function declarations in cheat.c. I'll need - to verify that cheat searching still works ok and that cheats still work - ok. I'll also need to update the Windows(and Linux console) cheat code - to prevent compiler warnings. - - Fixed various minor code problems(not minor if you want to use a - compiler besides gcc). This is an ongoing process... - - Removed bit fields after reading about and thinking about possible - portability problems, though I kept some optimizations in fceline.h - - Minor code simplification in drivers/win/joystick.c(replaced - "case 200 ... 207" and "case 208 ... 215". - - Modified some code to use bit-fields in the graphics rendering code - in fce.c and fceline.h. gcc seems to be able to optimize the new - code to run faster. - - Fixed m6502.c and fce.c to initialize variables on virtual power - toggle. This should fix network play on the Windows port. - I'm also in the process of cleaning up fce.c. - -.75: ----- - Fixed directories configuration stuff in Windows port(corresponds - to .75r2). - - More changes to square wave channel envelope/volume emulation... - Changes described in the large paragraph some lines down have been - abandoned. - - Added a command line switch to set the volume in the dos port. - - Changed Windows sound configuration dialog. Now buffer length is - specified in time, not samples. I also added a volume control. - - Reduced the volume on 8-bit sound output on all ports by 1/2. - - Added a function FCEUI_SetSoundVolume(). Added support for setting - the volume via the command line in the Linux port, other ports coming - soon. - - Changed FCEUD_WriteSoundData() again. No longer has a "Check" - argument. All clipping(ugh) is done internally now. - - Added a directories configuration dialog to the Windows port. I worked - on it too long and I became a zombie, so it might have a few bugs. - That's what guine...err...users are for. ;) Don't expect me to do - anything like this for any other port, though. I don't feel like - doing it on the DOS port, and the Linux and other UNIXy ports shouldn't - really need it. - - Made some changes to the rectangle/square wave channel emulation to - fix the pops in SMB. I have no idea if what I did is correct. To - be honest, I'm not sure I know EXACTLY what I did, but it's something - like this: Writes to $4003/$4007 now reset the duty cycle count - and reload the cycle counter with the current wavelength. Writes to - $4003/$4007 now do not update the amplitude output of the channels; they - will be updated after the cycle counter hits 0(or below). - - More information in iNES informational output. - - Minor changes to mappers/16.c. - - Increased the volume of the VRC6's sawtooth wave channel. - - Added more information to the RAM cheat guide. - - Changed the triangle wave generation code slightly. I decided - to remove support for the higher-frequency triangle waves, as they - are too cpu-costly to create and are probably not very audible on a - real NES anyway. - - Major changes to how sound is mixed. This necessitated a high pass - DC-offset removing filter, and a low-pass filter just to make things - sound better. ^_^ - Note: FCEUD_WriteSoundData() no longer needs to clear the waveform - data referenced by the passed pointer; it's done internally now. - - Fixed JMP ($xxxx) - now handles wrapping like it occurs on a real 6502 - (hopefully; I'm assuming that the same holds true for the NES' cpu). - - Added the ability to load a custom global palette in the DOS port. - - Fixed bug in drivers/common/unixdsp.c(wrong return value if sample - rate was out of range). - - Many sound fixes... - Frequency sweeps, length counter stuff,... - - Changed Windows port to use IDirectInput7 and IDirectInputDevice7 - interfaces. - - Fixed a Game Genie bug in the core emulation code. It only appeared - in the Windows port, though. (Enabling gg emulation, loading a game, - and then disabling gg emulation and loading a new game while in the - gg code entry screen would cause the new loaded game to not work - correctly). - - Modified windows port to use the config saving/loading stuff in - drivers/common/config.c - - Mapper 45 cleanups/fixes. - - Added the ability to load a custom global palette in the Linux port. - Yay. - - Fixed a large number of overcomplicated code and silly bugs in - drivers/common/config.c. This changes the format of the configuration - structure, too. Also added support for saving/loading strings with - automatic memory allocation when strings are loaded. - - Minor change in InitNetplay(). - - Fixed bad type conversions for pointers to functions and fixed - some bad declarations of functions. - - Reenabled zlib support for the sdl build. I need to pay attention - to patches that modify lines than don't fit on my screen. - - Fixed vidblit.c to not emit so many warnings when compiling. - -.74: ----- - - Stop sound in Windows port when user clicks l/m/r mouse buttons - in the non-client area of the window. - - Added "Drag and drop" file open support to Windows port. - - Various code cleanups. - - mappers/33.c optimization. - - Rewrote the function "FCEU_MakeFName()". - - Removed crc32.h from mappers directory. - - Modified some of the window resizing code in the Windows port. - - Added support for waiting for vblank/double buffering to the Windows - port. - - Added/Fixed support for iNES mapper 248. - - After an NSF file is loaded, information about its header is now - displayed. - - Fixed a typo in the Namco 106 extra ram handling code. - - Improved the quality of the Namco 106's extra sound channels. - - Thank Mamiya and Applepie(real name?) for info. - - When an NSF file is being played, FCE Ultra will no longer go through - its scanline rendering loop. This speeds up NSF playback considerably. - - Updated "porting.txt". - - Moved some stuff from DriverInterface() to their own functions. - - Fixed some iNES mapper 18 IRQ counter emulation bugs. "Ninja Jajamaru - - Ginga Dai Sakusen" now works. - - Rewrote large pieces of the mapper 64 code. "Skull and Crossbones" - still doesn't work, though. - - Changed format of iNES header information output, added "ROM CRC32" info. - - Modified the way cycle timing is done slightly. No change - for NTSC emulation, but PAL emulation is a little more accurate. - - Changed the behavior of indirect indexed(I hope I got that right ;)) - instructions to behave more like a real 6502(junk reads are now - performed). - - A few optimizations/cleanups in m6502.c. - -0.73 ----- - - * Fixed several bugs with sprite emulation. Several games(such - as "Trojan" and "VS Duck Hunt") that were broken in .71 and .72 now - work ok. - * Added support for iNES mapper 82. Thanks to those who work on - "unofficial nester". - * Added support for iNES mapper 250(used by "Time Diver Avenger"). - * Fixed the documentation to show that iNES mappers 48, 83, and 232 - are supported. - * Removed various pieces of stale code and fixed a few minor bugs. - * Fixed a triangle wave channel bug(the channel was sometimes enabled - when it shouldn't have been). - * Writing to $4010 with the upper bit clear now acknowledges the DPCM - IRQ. This appears to fix "Stunt Buggies". - * Rewrote pieces of the Zapper emulation code to be cleaner and more - accurate. - * Rewrote the VS Unisystem dip switch drawing code. - * Simplified the setting of VS Unisystem dip switches. The "V" key - now toggles viewing AND editing of dip switches. - -0.72 ----- - - * Various minor bug fixes. - * Various code cleanups and size and speed optimizations. - * Removed some (apparently) unused MMC5 sound emulation code. - * Changed the behavior of $2003 and $4014 to better simulate what occurs - in a real NES. - * Fixed a few bugs in the undocumented 6502 opcode emulation code. - The Game Genie code "NUTANT" for SMB 3 works correctly now, at - least(previously it caused the game to lock up at the end of levels). - * Rewrote large pieces of the 6502 memory fetching code, resulting - in a slight slowdown in the speed of emulation. Benefits include: - Game Genie emulation now works(again) and 6502 emulation is more - accurate. - * Added support for iNES mapper 72. Thanks to rinao for the information. - * Fixed support for iNES mapper 77(used by Napoleon Senki). - * Fixed/Added support for iNES mapper 226. Apparently I made a mistake - in the documentation. Thanks to Mark K. for the information. - * Added support for iNES mapper 227. Thanks to Mark K. for the - information. - * Added support for iNES mapper 234(used by the Maxi-15). Thanks - to Mark K. for the information. Note that many of the Maxi-15 - ROM images on the Internet have corrupt CHR data(graphics), or the - mapper number is set incorrectly(usually to 11). Use a utility to - fix the mapper number. - * Added support for the following UNIF boards(prefixes omitted): - - EKROM (and fixed the reference to "Gemfire" in the documentation). - - HKROM - * Added the ability to enable and disable individual RAM cheats. - * Fixed some problems with the cheat search code(the NES' internal - RAM was being searched differently than any external RAM, which - was being search incorrectly). - -0.71 ----- - - * Fixed a 6502 emulation bug that was causing some Koei games - (ex: Nobunaga's Ambition, Genghis Khan) to not work. - * Extensive PPU/CPU timing adjustments. - * Fixed support for iNES mapper 40. - * Added support for the following UNIF boards(prefixes omitted): - - ETROM - - ELROM - - EWROM - * Fixed a few bugs in the UNIF code. - * Added support for loading and saving cheat files and an interface - to search for/add/delete/list cheats(no interface yet on Linux/DOS). - * Fixed a few minor bugs in the Windows DX code. - * Command line options to control the number of sound fragments - and the fragment size have been added(Linux). - -0.70 ----- - - * Adjusted PPU/CPU timing. - * Removed(until I understand the problem) a hack to get one of the - games in the Caltron 6-in-1 to work. - * Fixed an MMC3 IRQ emulation bug("Project Q" works better now). - * Fixed a problem/misunderstanding regarding the upper scanline. - It can now be displayed again. - * More accurate sprite hit emulation(fixes the title screen of - "Ultimate Stuntman"). - * VRAM bank switching for iNES mapper 4 is now possible(and enabled - for all mapper 4 games without CHR ROM). Fixes "Tenchi o Kurau 2". - * Added support for the Famicom's four-player adapter and the ability - to enable it(it is disabled by default to prevent compatibility - problems). - * Added an option(under miscellaneous configuration) to automatically - open the "File Open" dialog box when FCE Ultra is started. - * Sound sampling rate is now configurable. - * Fixed some bugs in the DirectSound code. - * Joystick button configuration is a little more user friendly(and - stable, hopefully) (Linux). - -0.62 ----- - - * Added support for the Famicom Disk System's extra sound channel. - * Updated the version of Tatsuyuki Satoh's OPL2 emulator used in - FCE Ultra from .36f to .37a. The sound quality in "Lagrange Point" - seems to have improved. - * Added support for iNES mapper 242(used by "Wai Xing Zhan Shi"). - * Fixed a network play bug that could cause desynchronizations - if more than one network play session occured since FCE Ultra - was started. This bug only showed up on the Windows port, though. - * Increased the volume of the noise and triangle sound channels. - * Fixed a save state loading bug. - * Fixed a small memory leak that was being caused by the VRC7 - state loading code. - * Fixed a bug that could cause FCE Ultra to crash if a virtual disk - was being read and the user ejected the virtual disk. - * Various minor bug fixes/code cleanups. - * NTSC color "emulation" can now be enabled again(the code to - enable it was broken in the last version). (Linux) - -0.61 ----- - - * Speed optimizations in sprite rendering code. - * Screen snapshots are now saved in the PNG format instead of the PCX - format. - * Fixed Game Genie emulation(it wasn't working in the last release). - Also added support for Game Genie emulation to the UNIF code. - * Rewrote command line option parsing code. - * Fixed a problem(if FCE Ultra was configured to connect to a remote - host and the remote host was given as an IP address, and the IP - address couldn't be reverse resolved, which is commonly the case - on home LANs, the connection attempt would fail) in the network - play code. I had misinterpreted the Winsock API documentation - when I wrote the code. (Windows) - -0.60 ----- - - * Various speed optimizations. - * Sound is no longer messed up when a JAM/KIL opcode is emulated. - * Fixed an overflow bug that occured when $4014 was written to - during certain(rare) conditions. - * Fixed a few save state bugs. - * Fixed a MMC1 CHR bank switching bug. - * Added emulation of the MMC5's WRAM write-enable/disable registers. - * Fixed a sound frame IRQ emulation bug. "Qix" works now. - * Added UNIF support. Some of the board emulation is still a bit - buggy, though. Look at the documentation for a list of supported - boards. - * Updated the "Palette Notes" section of the documentation. Also - fixed a few other problems with the documentation. - * Added support for loading files in the PKZIP and gzip - compressed file formats via zlib. - * Added the ability to configure the first scanline and the last - scanline to draw to the screen. Enabling PAL emulation no longer - will cause all 239 scanlines to be displayed, though an option - to override these settings for when PAL emulation is enabled may - be in the next version. - * Fixed a bug that would cause the emulated D-pad of virtual gamepads - emulated through the keyboard to be duplicated through "higher" - virtual gamepads(gamepad 1 would affect 2,3,4; gamepad 2 would - affect 3,4; etc.). (Windows) - -0.55 ----- - * Rewrote window resizing code. The window will now resize itself - to a multiple of the NES' screen dimensions nearest to the user - selected dimensions. (Windows) - * Added an option to use buttons instead of axes on physical joysticks - for the emulated D-Pad. This is useful for some digital joysticks. (Windows) - * Fixed a bug that would cause FCE Ultra to crash if sound were - disabled during emulation. (Windows) - * Added the ability to "fast forward" emulation. - * Added an option to allow more than 8 sprites per scanline to be - displayed. - * Added an option to save all extra non-volatile game data - (such as battery-backed RAM) in a directory under FCE Ultra's - base directory(as opposed to the directory the game is located in). - * Added an option to allow the emulator to change to a full screen - video mode once a new game is loaded. (Windows) - * Rewrote pieces of DirectInput joystick handling code. Hopefully - it should increase compatibility. (Windows) - * Added the ability to automatically obtain button numbers when - configuring joysticks, by pressing buttons on the joystick. - * Added the ability to close the current game(decreases CPU usage). (windows) - * Increased the speed of various function calls by passing - arguments to functions through registers instead of through the - stack. - * Added emulation of the MMC5's raw PCM register. - * Added the ability to save/load save states while network play - is occuring. - * Having PAL emulation enabled will no longer override the - NTSC/PAL settings in NSF headers. - * Fixed a bug that got into the .54 release. Extraneous data was - being returned on reads from $2002, which caused problems - with some games(such as "Choujin Sentai Jetman"). - -0.54 ----- - * Fixed a bug that would cause a wrong battery-backed WRAM file - name to be produced if FCE Ultra was passed a file name without - any directory component(such as "fceu SuperBlah.nes"). - * Fixed an iNES mapper 118 emulation bug that got into the code - in a recent code cleanup. "Armadillo" is playable again. - * Fixed a typo(and bug) in the MMC5 emulation code. - * Data returned from emulated reads to "unmapped" areas or - memory locations where bits are undefined should now be correct. - * Fixed emulation of the sprite memory transfer register $4014. - It now takes into account the last value written to $2003 and - starts the transfer to that location in sprite memory(like on - a real NES). - * Added a video configuration dialog box. (Windows) - * Added the ability to configure a custom video mode. Aspects - that are configurable include width, height, bits per pixel, - and size transforming(stretching and scaling). (Windows) - -0.53 ----- - - * Fixed a bug with joysticks that occured on systems with multiple - joysticks. (Windows) - * Added support for iNES mappers 77 and 92(thanks to LULU for the code for both). - * Added partial(timer is non-configurable) support for iNES mapper 105. - * Changed save state format again. Save states made with previous - versions should still be compatible, though this may change in - future versions. - * Small optimization to sprite emulation code. - * Rewrote color-deemphasis code to use integer math instead of - floating-point math. - * Rewrote and restructured input code. (Linux) - * Added command line option "-f8bit" to force 8-bit sound. (Linux) - * Rewrote and restructured input code. Among other new features, - keyboard keys are now somewhat configurable. (Windows) - * Writes to $4003/$4007 will now reset the emulated square wave - duty cycle generator. - * Added emulation of the Power Pad. - * Rewrote joystick device reading code to use the event-driven - interface. This should fix various problems regarding support - for joysticks with many buttons. (linux) - -0.52 ----- - - * Fixed a PCM emulation bug(digitized voices in "Ikari Warriors 2" - and "The Immortal", among others, work now). - * Fixed noise channel's LSFR update frequencies(hopefully). - * Various minor bug fixes. - -0.51 ----- - - * Added support for iNES mappers 86 and 89. - * Reduced byte size of the NSF player's background. - * Adjusted CPU/PPU timing. - * Fixed sound channel frequency calculations for when PAL emulation is enabled. - * Rewrote large pieces of the sound code and got rid of the sound queue. Sound quality should be slightly better now. - * Various minor bug fixes. - - Windows: - - * Fixed an FDS side reset bug when a new game is loaded. - * Screen width/depth/height changes while FCE Ultra is in windowed mode are handled now. - * Changed the configuration file format. - * Added a palette configuration dialog. - * Added the ability to load a custom NES palette. - * Added an option to double 16-bit sound volume. - * Added an option to force 8-bit sound. - * Added an option to use a secondary sound buffer(versus the primary). - * Added an option to wait for vertical blank if sound is disabled. - * Added an option to run while focus is lost. - -0.50 ----- - - * Many bug fixes. - * Sound code partially rewritten to improve quality(near-perfect - raw PCM now) and eliminate the need for a separate thread. - This created a small problem with network play, though, so read - the network play notes section. Also, synchronizing to - vertical blank has been removed. - * Rewrote other pieces of sound code. No more "buzzing" in MegaMan 2, - Codemasters games' intros, etc. - * Added support for the NES Zapper and the VS Unisystem's light - gun. Be sure to read "Light Gun Notes". - * Changed save state format. Save states should now be much - smaller for most games. Most(not all) save states created with - an older version should work. - * Added support for VS Duck Hunt and VS Hogan's Alley. - diff --git a/branches/sdl2/attic/Makefile.am b/branches/sdl2/attic/Makefile.am deleted file mode 100644 index d397280d..00000000 --- a/branches/sdl2/attic/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = src diff --git a/branches/sdl2/attic/SConstruct.pre1.0 b/branches/sdl2/attic/SConstruct.pre1.0 deleted file mode 100644 index bac63f3d..00000000 --- a/branches/sdl2/attic/SConstruct.pre1.0 +++ /dev/null @@ -1,147 +0,0 @@ -# Use this SConstruct if you are using scons < 1.x -# Just replace the SConstruct file with this one -# cp SConstruct.pre1.0 SConstruct -# -# or just updated scons already - -import os -import sys -import platform - -opts = Options() -opts.AddOptions( - BoolOption('FRAMESKIP', 'Enable frameskipping', 1), - BoolOption('OPENGL', 'Enable OpenGL support', 1), - BoolOption('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1), - BoolOption('DEBUG', 'Build with debugging symbols', 1), - BoolOption('LUA', 'Enable Lua support', 1), - BoolOption('NEWPPU', 'Enable new PPU core', 1), - BoolOption('CREATE_AVI', 'Enable avi creation support (SDL only)', 0), - BoolOption('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'), - BoolOption('GTK', 'Enable GTK2 GUI (SDL only)', 1), - BoolOption('GTK_LITE', 'Enable GTK2 for dialogs only', 0) -) - -env = Environment(options = opts) - -# LSB_FIRST must be off for PPC to compile -if platform.system == "ppc": - env['LSB_FIRST'] = 0 - -# Default compiler flags: -env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-O2', '-Isrc/lua/src']) - -if os.environ.has_key('PLATFORM'): - env.Replace(PLATFORM = os.environ['PLATFORM']) -if os.environ.has_key('CC'): - env.Replace(CC = os.environ['CC']) -if os.environ.has_key('CXX'): - env.Replace(CXX = os.environ['CXX']) -if os.environ.has_key('WINDRES'): - env.Replace(WINDRES = os.environ['WINDRES']) -if os.environ.has_key('CFLAGS'): - env.Append(CCFLAGS = os.environ['CFLAGS'].split()) -if os.environ.has_key('LDFLAGS'): - env.Append(LINKFLAGS = os.environ['LDFLAGS'].split()) - -print "platform: ", env['PLATFORM'] - -# special flags for cygwin -# we have to do this here so that the function and lib checks will go through mingw -if env['PLATFORM'] == 'cygwin': - env.Append(CCFLAGS = " -mno-cygwin") - env.Append(LINKFLAGS = " -mno-cygwin") - env['LIBS'] = ['wsock32']; - -if env['PLATFORM'] == 'win32': - env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"]) - env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"]) - env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"]) -else: - conf = Configure(env) - if not conf.CheckLib('SDL'): - print 'Did not find libSDL or SDL.lib, exiting!' - Exit(1) - if not conf.CheckLib('z', autoadd=1): - print 'Did not find libz or z.lib, exiting!' - Exit(1) - if env['GTK'] or env['GTK_LITE']: - # Add compiler and linker flags from pkg-config - env.ParseConfig('pkg-config --cflags --libs gtk+-2.0') - env.Append(CPPDEFINES=["_GTK2"]) - if env['GTK']: - env.Append(CCFLAGS = ["-D_GTK"]) - env.Append(CCFLAGS =["-D_GTK_LITE"]) - if env['GTK_LITE']: - env.Append(CCFLAGS =["-D_GTK_LITE"]) - - ### Lua platform defines - ### Applies to all files even though only lua needs it, but should be ok - if env['LUA']: - if env['PLATFORM'] == 'darwin': - # Define LUA_USE_MACOSX otherwise we can't bind external libs from lua - env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"]) - if env['PLATFORM'] == 'posix': - # If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading. - # Should work on any *nix - env.Append(CCFLAGS = ["-DLUA_USE_LINUX"]) - - ### Search for gd if we're not in Windows - if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']: - gd = conf.CheckLib('gd', autoadd=1) - if gd == 0: - env['LOGO'] = 0 - print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.' - - if conf.CheckFunc('asprintf'): - conf.env.Append(CCFLAGS = " -DHAVE_ASPRINTF") - if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c++', autoadd=1): - conf.env.Append(CCFLAGS = " -DOPENGL") - conf.env.Append(CPPDEFINES = ['PSS_STYLE=1']) - # parse SDL cflags/libs - env.ParseConfig('sdl-config --cflags --libs') - - env.Append(CPPDEFINES=["_S9XLUA_H"]) - env = conf.Finish() - -if sys.byteorder == 'little' or env['PLATFORM'] == 'win32': - env.Append(CPPDEFINES = ['LSB_FIRST']) - -if env['FRAMESKIP']: - env.Append(CPPDEFINES = ['FRAMESKIP']) - -print "base CPPDEFINES:",env['CPPDEFINES'] -print "base CCFLAGS:",env['CCFLAGS'] - -if env['DEBUG']: - env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g']) - -if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']: - env.Append(CPPDEFINES=["CREATE_AVI"]) -else: - env['CREATE_AVI']=0; - -Export('env') -SConscript('src/SConscript') - -# Install rules -exe_suffix = '' -if env['PLATFORM'] == 'win32': - exe_suffix = '.exe' - -fceux_src = 'src/fceux' + exe_suffix -fceux_dst = 'bin/fceux' + exe_suffix - -auxlib_src = 'src/auxlib.lua' -auxlib_dst = 'bin/auxlib.lua' - -fceux_h_src = 'src/drivers/win/help/fceux.chm' -fceux_h_dst = 'bin/fceux.chm' - -env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)]) -env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)]) -env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)]) - -# TODO: Fix this build script to gracefully install auxlib and the man page -#env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source=("bin/fceux", "bin/auxlib.lua"))) -env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source="bin/fceux")) diff --git a/branches/sdl2/attic/TODO-SDL-2.1.6.md b/branches/sdl2/attic/TODO-SDL-2.1.6.md deleted file mode 100644 index 83f6576e..00000000 --- a/branches/sdl2/attic/TODO-SDL-2.1.6.md +++ /dev/null @@ -1,118 +0,0 @@ -BUGS -==== -Save/Load State Console Print Bug ---------------------------------- -* ie: - -select state- - State -777722344 saved - -* If the root of the bug cannot be determined by release time, just #ifdef the print statement for win32 - -Clip sides bug in BOTH WINDOWED AND FULLSCREEN mode ---------------------------------------------------- -* Go to game genie with clip sides enabled or save a state to see -* Ensure no clip sides is only being enabled during fullscreen - -DONE! Gamepad dialog and others segfault on Ubuntu 10.04 (and older GTK versions) ---------------------------------------------------------------------------------- -* Not planning on using legacy code here (especially with Ubuntu 12.04 on its way) but perhaps -a messagebox can be displayed recommending the user to upgrade their GTK version to prevent -the frustrating segfault. Segfaults need to be avoided like the plague. - -* This is fixed in r2447. FceuX will print a warning to the console that the GTK version is old, and -provide instructions on how to configure the gamepad. -* Maybe we should also provide a GTK MessageBox with this info? - -FEATURES -======== -XDG Standardization of Config ------------------------------ -* fceux currently stores stuff to ~/.fceux by default -* FD.O/XDG recommends default to be ~/.config/fceux (and to check $XDG_whatever) -* If the XDG folder exists, use it. If NO folder exists, use the XDG folder. -* If .fceux exists, display a warning message but use .fceux -* Don't move around people's config files without asking (or at all in this case) - -input.cpp -========= -* This code is a fscking mess! However, now is not the time to clean it. Perhaps set a goal to clean this file up for -2.1.7, but cleaning this for 2.1.6 is not realistic (and would break too many things and require more testing time) - -DISTRO TESTING -============== -Summary -------- -* Out of box working distros: - * Arch Linux - * Ubuntu 10.04 - * Ubuntu 12.04 -* Works, but needs patching: - * Fedora Core 16 -* Couldn't get working - * openSUSE -* Untested: - * Linux Mint - * Debian - - -Arch Linux 64 bit ------------------ -* Flawless installation from fceux-svn in [aur]. No issues other than the ones already noted. -* Dpendencies: sdl, gtk2, scons libz - -Ubuntu 10.04 ------------- -* Compiles/builds without issue. -* Build deps: libsdl1.2-dev, scons, libgtk2.0-dev, zlib-dev, build-essentials -* No issues found in gameplay. -* DONE Some dialogs with segfault FCEUX due to an older version of GTK. Perhaps we can detect the old version of GTK and just prevent the dialog from being opened so the segfault doesnt occur? (bug added). - * DONE Wrote CheckGTKVersion(), which will be used like CheckGTKVersion(2, 24) to check the GTK version before segfaulting on dialogs - * DONE Implement a check for the dialogs that would bomb -- (a hook in init; makes all items under Options inacessible besides fullscreen if under 2.24) - -Ubuntu 12.04 Beta ------------------ -* Compiles/builds without issue. -* GTK3 preferred for Unity -* Build deps: libsdl1.2-dev, scons, libgtk-3-dev, zlib-dev, build-essentials -* No issues AFAICS - -Fedora Core 16 --------------- -* Dependencies: subversion, scons, SDL-devel, gtk2-devel/gtk3-devel, gcc, [glib-devel?] -* You also need to install the "Development Tools" group: - - yum groupinstall "Development Tools" - -* scons bombs out (another missing dependency? - - /usr/bin/ld: src/lua/src/loadlib.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5' - /usr/bin/ld: note: 'dlclose@@GLIBC_2.2.5' is defined in DSO /lib64/libdl.so.2 so try adding it to the linker command line - /lib64/libdl.so.2: could not read symbols: Invalid operation - collect2: ld returned 1 exit status - scons: *** [src/fceux] Error 1 - scons: building terminated because of errors. - - * This was fixed by forcing "-ldl" to the linker command line. This can be done by adding the following - to line 92 of the SConstruct: - - env.Append(LINKFLAGS = ["-ldl"]) - - * TODO Answer some questions: - 1. Is -ldl necessary everywhere? - 2. Should we always use it? If not what can we test for for when to use it? - - * Check the code circa line 92 in SConstruct for a Fedora resolution. - - * Tested with GTK2, runs smoothly in VirtualBox. - -openSUSE 12.1 -------------- -* scons bombs out because can't find libgtk; I can't find gtk headers package - -PROJECT STUFF -============= -* Contact debian package management about inclusion -* Create a sane release procedure script that generates a release ready tarball -* DONE - Create markdown file of README -* Locate important features/changes new to 2.1.6 and summarize them. - diff --git a/branches/sdl2/attic/acinclude.m4 b/branches/sdl2/attic/acinclude.m4 deleted file mode 100644 index a2d04875..00000000 --- a/branches/sdl2/attic/acinclude.m4 +++ /dev/null @@ -1,357 +0,0 @@ -# Configure paths for SDL -# Sam Lantinga 9/21/99 -# stolen from Manish Singh -# stolen back from Frank Belew -# stolen from Manish Singh -# Shamelessly stolen from Owen Taylor - -dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS -dnl -AC_DEFUN(AM_PATH_SDL, -[dnl -dnl Get the cflags and libraries from the sdl-config script -dnl -AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], - sdl_prefix="$withval", sdl_prefix="") -AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], - sdl_exec_prefix="$withval", sdl_exec_prefix="") -AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], - , enable_sdltest=yes) - - if test x$sdl_exec_prefix != x ; then - sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_args="$sdl_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl-config - fi - fi - - AC_PATH_PROG(SDL_CONFIG, sdl-config, no) - min_sdl_version=ifelse([$1], ,0.11.0,$1) - AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) - no_sdl="" - if test "$SDL_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` - - sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x$enable_sdltest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" -dnl -dnl Now check if the installed SDL is sufficiently new. (Also sanity -dnl checks the results of sdl-config to some extent -dnl - rm -f conf.sdltest - AC_TRY_RUN([ -#include -#include -#include -#include - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main (int argc, char *argv[]) -{ - int major, minor, micro; - char *tmp_version; - - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_sdl_version"); - exit(1); - } - - if (($sdl_major_version > major) || - (($sdl_major_version == major) && ($sdl_minor_version > minor)) || - (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_sdl" = x ; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl-config script installed by SDL could not be found" - echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL_CONFIG environment variable to the" - echo "*** full path to sdl-config." - else - if test -f conf.sdltest ; then - : - else - echo "*** Could not run SDL test program, checking why..." - CFLAGS="$CFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding SDL or finding the wrong" - echo "*** version of SDL. If it is not finding SDL, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means SDL was incorrectly installed" - echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - SDL_CFLAGS="" - SDL_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(SDL_CFLAGS) - AC_SUBST(SDL_LIBS) - rm -f conf.sdltest -]) - -/* Steven G. Johnson and Alejandro Forero Cuervo */ -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all. - -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# pthread: Linux, etcetera -# --thread-safe: KAI C++ - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthread or - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: threads are created detached by default - # and the JOINABLE attribute has a nonstandard name (UNDETACHED). - AC_MSG_CHECKING([for joinable pthread attribute]) - AC_TRY_LINK([#include ], - [int attr=PTHREAD_CREATE_JOINABLE;], - ok=PTHREAD_CREATE_JOINABLE, ok=unknown) - if test x"$ok" = xunknown; then - AC_TRY_LINK([#include ], - [int attr=PTHREAD_CREATE_UNDETACHED;], - ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) - fi - if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then - AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, - [Define to the necessary symbol if this constant - uses a non-standard name on your system.]) - fi - AC_MSG_RESULT(${ok}) - if test x"$ok" = xunknown; then - AC_MSG_WARN([we do not know how to create joinable pthreads]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with cc_r - AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/branches/sdl2/attic/aclocal.m4 b/branches/sdl2/attic/aclocal.m4 deleted file mode 100644 index 42e071f0..00000000 --- a/branches/sdl2/attic/aclocal.m4 +++ /dev/null @@ -1,879 +0,0 @@ -# generated automatically by aclocal 1.9.5 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION so it can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.9.5])]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 7 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE]) -AC_SUBST([$1_FALSE]) -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH]) -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 3 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 12 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.58])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AM_PROG_INSTALL_SH -AM_PROG_INSTALL_STRIP -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -]) -]) - - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $1 | $1:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"$am_aux_dir/install-sh"} -AC_SUBST(install_sh)]) - -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Copyright (C) 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# AM_PROG_CC_C_O -# -------------- -# Like AC_PROG_CC_C_O, but changed for automake. -AC_DEFUN([AM_PROG_CC_C_O], -[AC_REQUIRE([AC_PROG_CC_C_O])dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -# FIXME: we rely on the cache variable name because -# there is no other way. -set dummy $CC -ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. -# -# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories -# created by `make install' are always world readable, even if the -# installer happens to have an overly restrictive umask (e.g. 077). -# This was a mistake. There are at least two reasons why we must not -# use `-m 0755': -# - it causes special bits like SGID to be ignored, -# - it may be too restrictive (some setups expect 775 directories). -# -# Do not use -m 0755 and let people choose whatever they expect by -# setting umask. -# -# We cannot accept any implementation of `mkdir' that recognizes `-p'. -# Some implementations (such as Solaris 8's) are not thread-safe: if a -# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' -# concurrently, both version can detect that a/ is missing, but only -# one can create it and the other will error out. Consequently we -# restrict ourselves to GNU make (using the --version option ensures -# this.) -AC_DEFUN([AM_PROG_MKDIR_P], -[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - # We used to keeping the `.' as first argument, in order to - # allow $(mkdir_p) to be used without argument. As in - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. However this is wrong - # for two reasons: - # 1. if the package is installed by a user who cannot write `.' - # make install will fail, - # 2. the above comment should most certainly read - # $(mkdir_p) $(DESTDIR)$(somedir) - # so it does not work when $(somedir) is undefined and - # $(DESTDIR) is not. - # To support the latter case, we have to write - # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), - # so the `.' trick is pointless. - mkdir_p='mkdir -p --' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--version; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi -AC_SUBST([mkdir_p])]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# ------------------------------ -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir - -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([acinclude.m4]) diff --git a/branches/sdl2/attic/authors b/branches/sdl2/attic/authors deleted file mode 100644 index f4220e5a..00000000 --- a/branches/sdl2/attic/authors +++ /dev/null @@ -1,30 +0,0 @@ -A list of people who have contributed code to FCE Ultra follows. -Please note that the "Code Contributions" field may not be all inclusive; -the coder may have done more than what is listed. - -Name/Alias Code Contributions Contact Information ------------------------------------------------------------------------------- -Aaron Oneal Many changes to compile http://www.morphgear.com - with MSVC and first frame - skipping code. - -BERO Base FCE code. bero@geocities.co.jp - -CaH4e3 Some mapper code. CaH4e3 at mail dot ru - -\Firebug\ VGA register setting code. ?? - -Joe Nahmias man pages. - -LULU SDL network play code. ?? - -Paul Various code for the official kuliniew@purdue.edu - Kuliniewicz SDL port. - -Quietust VRC7 "translation" code. quietust@ircN.org - -Tatsuyuki OPL2 emulator. ?? - Satoh - -Xodnizel Most of the FCE Ultra code. http://xodnizel.net/ - diff --git a/branches/sdl2/attic/changelog b/branches/sdl2/attic/changelog deleted file mode 100644 index 359eee9a..00000000 --- a/branches/sdl2/attic/changelog +++ /dev/null @@ -1,1674 +0,0 @@ -November 12, 2003 - 0.97.5 Release - - Windows: Added limited support for arguments that change configuration - to be passed to FCE Ultra. Example: fceu -pal 1 c:\streetgangs.nes - It may be useful in frontends. - - Fixed filename generation for automatic IPS patching when a file - with no extension is loaded. Before this change, FCEU would - look for "game..ips" with a file named "game". - - Converted and updated the cheat guide in(to) HTML. - - Added support for iNES mappers 202,203,231 from info from cah4e3. - Fixed support for mappers 60, 200. - - Fixed various major bugs in the breakpoint deletion code. - - UN*X: Added support for OSS(/dev/dsp) devices that don't support mono - sound. - - Increased PPU startup idle time to 2 frames. Fixes that - unlicensed "Earthworm Jim 3" game. Does it break anything? - -November 9, 2003 - 0.97.4 Release - - Fixed another obscure PPU emulation screen corruption bug. - - Added support for Game Genie cheats in the cheat interface. - - Windows: Reworked the cheat interface, merging the cheat search - and cheat list windows into one. - - Windows: Greatly improved the CPU debugger. - The code still needs a lot of cleaning, though. - - Readjusted VRC6 IRQ emulation timing. - - Added support for the UNIF MMC3 board TEROM. The maximum PRG/CHR sizes - may not be correct in this implementation, though. - -November 8, 2003 - 0.97.3 Release - - Added a control to set the highest quality sound mode in Windows. - This change requires that any users who previously set - "high quality sound" to set it again. - - Fixed the volume of high-quality sound mode again. The changes - I made earlier didn't affect all the filter coefficients. - -November 8, 2003 - 0.97.2 Release - - Made a minor optimization to writes to palette memory. - - Altered VRC6 IRQ emulation timing slightly. - - Fixed a weirdo PPU emulation bug that could cause garbage on the right - side of the screen in certain situations. Thanks to FrenziedPanda for - bugging me enough to make me look into the problem and fix it. - I should be on the lookout to see if the fix breaks anything, though. - - Fixed the volume of high-quality sound mode(-soundq 1). It was - at 1/4 the volume it should have been. I compensated by increasing - the precision of the filter coefficients, which increased the sound - quality of that mode slightly without hurting performance. - -November 7, 2003 - 0.97.1 Release - - Fixed mapper 105 emulation. I had begun merging it into the - rest of the MMC1 code for 0.97, but I hadn't finished it. - - Changed things like RdMem(_PC++); to RdMem(_PC); _PC++; - Darn evil global variables. I need to fix them. Screw speed. - - Expanded checks for the global variable "fceuindbg"(used in debug - mode to prevent reads in the debugger from altering any registers). - -November 6, 2003 - 0.97 Release - * Note: I still had much more I had wanted to get done for 0.97, - but I lost even more interest. The Windows port still doesn't - have a way to enable the "highest" sound emulation mode, nor the - low pass filter code, not to mention that the lowpass filter code - isn't complete(I would need to design a high-order FIR filter from an IIR - filter to work properly-have the correct rolloff, among other - things-at finite playback rates). - - Fixed a bug in the IPS patcher. The recorded size wasn't being updated - after a successful realloc() was made, which could lead to corrupted patch - data from some patches. - - Added support for mappers 200, 201 from submitted code. - - Rewrote mapper 15 support to make more sense(well, depending - on your point of view...). - - Fixed 256KB CHR select support for mapper 115. - - Added support for mapper 12 from code from cah4e3. - -October 16, 2003 - Snapshot - - Fixed support for mapper 245(for nonencrypted/non-smynes-screwed up - ROM images only. Fixes "Yong Zhe Dou E Long [...] Dragon Quest 7". - - Added support for mappers 60, 62, 230, 244 from submitted code. - - Modified mapper 90 emulation to allow game-select on reset - for "Final Fight 3". - - Modified mapper 45 emulation to allow "Super 8-in-1" to work. - - Added a low-pass filter, and an option to enable it(CLI ports). - - 0x00 is now written to $4011 in the NSF player code instead of 0x40. - Fixed some other similar sound register init problems that I had fixed - in Festalon but forgot to fix in FCEU. Grrr. - - Removed some unnecessary 64-bit integer usage from FIR sound filtering - code. - - Added a new sound quality mode. Higher than high, it's highest(in - FCE Ultra, for now). Still need to fix the interface to allow - enabling it in the Windows port. - - Added some code for lower-level MMC3 IRQ emulation. It isn't completed - , and will not work properly as-is. I'm still playing around with - it occasionally. - - Fixed the sprite overflow flag(I think I fixed it), that was broken in an earlier - pre-0.97 release. - - Fixed support for iNES mapper 193. - - Command line arguments "-pal" and "-gg" now take extra arguments(1/0) - and are remembered in the configuration file. - -September 27, 2003 - Snapshot - - Added support for iNES mapper 50. - - Modified the UNIF board initialization code. Hopefully, this - new interface will eventually be used with the iNES code. - - Miscellaneous code cleanups. - - /dev/dsp is now set to 8(previously 9) buffers of 128 samples in length - in the SDL code. - - Tried to make the save state code more expandable and modular. - - Moved a lot of the PPU code into ppu.c. - - Added more extensive debugging code to the 6502 emulator, to allow - for memory read/write hooks(including zero page addressing modes). - - Readadjusted DMC timings when PAL emulation is enabled. It looks - like it was correct before I had made the August 2 change. Thanks - to Bananmos for the information. I think. :/ - - Added support for iNES mapper 193 from information from virtuanes. - I think my dump of it is "bad", though. PRG and CHR pages look - like they are in the wrong order(logical vs physical? Who's to say - what's physical?). - -September 1, 2003 - Snapshot - - Fixed some minor initialization issues with iNES mappers 7 and 34. - - Added support for UNIF board NES-GNROM. - - Removed support for save states created with versions of FCE Ultra - less than 0.56. - - Replaced SDL sound buffering code with a lock-free FIFO implementation - written by David Olofson, with a few modifications by myself. - - Fixed a VRC7 NSF bug(it showed up under the reworked driver/file - loading order in the cli code). - - The board in "Rolling Thunder" has "RAMBO 1" on it, not "RAMBO-1". - -August 9, 2003 - Snapshot - - Removed the old plain text documentation and replaced it with - a new document in HTML. It is not completed yet, though. - - Rewrote the SDL-native audio code to be less wacky and more - thread-safe(hopefully). I'm still waiting for a new SDL audio - API... - - Altered the MMC5 IRQ timing. Fixes minor graphical glitches - in Castlevania 3. Does it break anything? - - Removed some debugging code that got into the last snapshot. - -August 5, 2003 - Snapshot - - Added some code in the IPS patcher to allow for expanding the size of files. - - Fixed a double free() bug with a mapper 51 game(in ines.c). - - Added support for "Alien Syndrome" (US release) as iNES mapper 158. - It looks like a derivative of the normal RAMBO-1 board(or is that - the name of the chip?), similar to TKSROM/TLSROM(mapper 118). - - Improved the "native" SDL sound code. It will now call SDL_Delay(), - among other nice things. The code could probably be improved more, - though. - - Added support for decimal components in xscale/yscale in the SDL - port. Set the default xscale for windowed mode to 2.40(to get a - more correct aspect ratio, assuming the display is currently at - a 4:3 aspect ratio). - - Modified args.c to handle floating-point numbers. - -August 2, 2003 - Snapshot. - - Disabled texture wrapping with OpenGL(there were problems at the edges - of the screen with linear interpolation). Bah. Now the edges - are too bright... - - Improved the accuracy of the DMC timing when PAL emulation is enabled. - I still don't think it's totally correct, though. - - Changed the default settings for the SDL code. Full screen - is now 640x480x8bpp by default, xscale and yscale are 2 for both full - screen and windowed, opengl support is enabled, linear interpolation - for OpenGL is enabled, and X-axis stretching is - enabled(in full screen). - - "Scanlines" were enabled in 8bpp to 8bpp blits in - drivers/common/vidblit.c when they shouldn't have been. Fixed. - - Fixed OpenGL code under big-endian platforms. - -August 1, 2003 - Snapshot. - - Various code clean-ups. - - Played around with adding a GTK+ GUI to the SDL code. - - Rewrote part of the hq sound rectangle wave code. - - Replaced the high-quality sound inline assembly filter code with - slightly faster C code. - - Hacked around with GP32 support. I don't know if the GP32 would - be fast enough, though. - - Skipped frames will now have D5 of $2002 set at the beginning - of the frame. Fixes "Bee 52". I must see if it breaks anything. - - Added OpenGL support to the SDL code. - - Removed the PPU drawing inline assembly code, replacing it with a faster - algorithm written in C. - - "Disabling" the 8-sprite limitation will no longer cause - "Bee 52" to break. However, the "Solstice" wizard will still - have the weird thing growing out of his face in the introduction, - since it depends on no more sprites to be rendered. - - Added entry for that Black Bass game for header corrections in - ines.c - - Strip color burst bit(D0 of $2001) is only "emulated" if bg or - sprite rendering are turned on, at the end of the scanline. - Doing it with pixel/tile granularity would require modifying - the sprite graphics data copying routine, which I don't - feel like doing. Fixes that crazy Sayoonara demo by Chris Covell. - I also modified the NES RAM initialization code. - - Adjusted VRC7 IRQ emulation for better Lagrange Point goodness. - - Added support for iNES mapper 91. (VirtuaNES) - -0.96: - Improved RAMBO-1(mapper 64) emulation. "Skull and Crossbones" is - now playable. - -0.95: - - timestamp and timestampbase are no longer saved/loaded to/from - save states. They were causing too many problems I didn't - want to fix, and I never intended them to be saved in save states - when I wrote the code that uses them. - I think the reason they were being saved was that I wanted to make it - possible to add movie support and network play save state loading - (distributing the save state over the network). So if someone in - the future wants to add these features, the issues(primarily with - zapper emulation and sound emulation) with saving the time stamp will - need to be resolved. - - Fixed some crashing bugs when save states are loaded when - high-quality sound emulation is enabled. It is like patching - holes in a swiss-cheese boat. All the holes may be patched, but - it looks ugly. At least it tastes good... - TODO: Look into saving more data in the save states, especially - data that is based off of "timestamp" and "timestampbase". Also - look into validating this data. Right now, corrupt save state data - might cause memory corruption in FCE Ultra. - - Fixed some bugs in the NSF player. - - Cleaned up more code. - - Reduced the usage of TriggerIRQ(). - - Split the palette code into a new file, palette.c, from svga.c - - Low-G-Man(NTSC and PAL versions) are now recognized by CRC32 value, - and WRAM will be disabled if they are loaded. A warning/status message - will also be printed regarding this issue. - - Decreased the volume of the DMC/PCM channel in low-quality sound - emulation. - - Low-quality sound emulation now uses 32-bit integers for much - better speed. - - FCEUI_CRC32() wasn't returning anything. D'oh. Fixed. - - Added somewhat crude support for games that switch background CHR data - mid-scanline (this is needed in games such as Mother, Pirates!, - Business Wars, and Marble Madness). - - Altered NMI, IRQ, and BRK emulation again. Fixes some games, - like Bases Loaded 2 and Dynamite Bowling, and maybe some others. - I had to increase the size of the IRQlow variable for delayed - NMI execution... I also had to add a delay between PPU reset - and the PPU actually doing anything, to fix "Knight Rider". - - Fixed a mapper 90 save state bug. - - /dev/dsp code now searches for /dev/dsp before /dev/dspX (where X is - a non-negative integer). - - SDL joystick axes configuration is now done from the joystick. - - Tweaked various Konami mappers' IRQ counter emulation. - - Added custom SDL throttle code that gives up time slices instead of - using 100% cpu. - - Fixed an issue with sprite priorities on MSB-first platforms. - - Modified powerpad.c to avoid a symbol conflict when compiling on the - Power PC architecture. - -0.94r3: - sound.c: - Fixed a divide-by-zero bug that occurred when a virtual - reset(like by pressing F10) occurred when sound emulation was - disabled. - -0.94r2: - drivers/common/vidblit.c: - Fixed code for 32bpp blur effect. - - drivers/cli/sdl-video.c: - Added error message for unsupported bit depths. - - mappers/simple.c, ines.c: - Used this bug fix pseudo-release as an excuse to add - support for mapper 107. Information taken from virtuanes. - -0.94(fixed release) ---- - Fixed call to InitUNIXDSPSound in svgalib.c - - Added man pages. - -0.94 ---- - Added support for rapid fire A/B buttons on physical joysticks - in SDL/svgalib/DOS code. - - Implemented "high-quality" Namco 106 emulation(used for hq sound mode). - In this case, "high-quality" means sounding more like it should, - not necessarily cleaner. I'm not certain that it's totally correct, - but it's in the right direction. - - RAM cheats should no longer affect Game Genie emulation. I still - need to completely verify this. There may be some sort of race - condition. - - Removed various minor speed hacks in the name of style and - correctness(and to make maintaining FCE Ultra easier for those - people who are not me). :) - - Removed NSF cpu hacks, as I changed code to make them unnecessary. - - Fixed another FDS IRQ emulation bug. "Famicom Grand Prix II" works - now. - - Fixed a memory leak and a heap corruption bug in "file.c". - - Added support for on-the-fly IPS patching. - Place the IPS file in the same directory as the file to load, - and name it filename.ips. - - Examples: Boat.nes - Boat.nes.ips - Boat.zip - Boat.zip.ips - Boat.nes.gz - Boat.nes.gz.ips - Boat - Boat.ips - - Some operating systems and environments will hide file extensions. - Keep this in mind if you are having trouble. - - Patching is supported for all supported formats(iNES, FDS, UNIF, and - NSF), but it will probably only be useful for the iNES format. It - can be used with the FDS format, but be warned that it will permanently - patch your disk image, as the disk image is written back to disk - when the game is unloaded(unless the disk image is in a zip file, in - which case it isn't written back to disk). UNIF files can't be - patched well with the IPS format because they are chunk-based with no - fixed offsets. Support for a UNIF patching format may be added - in the future(probably by someone else.). - - Added more games to the list in ines.c for having battery-backed - WRAM, for header corrections. - - Copied over the 96KHz filter coefficients from Festalon that I forgot - to do in 0.92. Oops. - - -0.93 ---- - - Reduced the volume of the FDS sound channel. - - Fixed a bug in the FDS IRQ emulation code that caused "Lutter" to not work. - - Fixed a bug in unif.c that would cause a crash if a unif file were - loaded without a board name being specified(as could happen - with a corrupted nsf). - - Fixed a bug in general.c relating to relative filenames(running - fce ultra like "./fceu ../big.nes" would work, but "./fceu ../big" - would not work- it crashed). - - - -0.92r2 ---- - Fixed dpcm irq bug that broke Cobra Triangle. - -.92 ---- - - Removed NSF player background, and added some special effects goodies. - - Changed the NSF player to use the emulated gamepad as input instead - of having special NSF-player-only keys. - - Added support for mapper 249(using nonencrypted games), thanks to SARO - for info. SMYNES sucks. - - Updated video blitting library-thing(vidblit.c) with more special - effects, and removed 24bpp support. - - SDL cleanupification. - - Added support for mapper 61. - - nnnesterj: Added support for mapper 57. - - Fixed mapper number for "Golden Game 150 in 1". Changed it to 235 - from 43. - - DDraw back buffer surfaces are now created in system memory if the - hardware blitter can't do stretching. - - Restructured file wrapping code. - - Added new cheat search methods. - - Fixed a major cheat unloading memory bug(and memory leak). - - Emulated that funky nonlinear DAC effect for hi-quality sound. - - More fixes/cleanups to FDS emulation code. - - Tweaked PPU timing a bit. - - Improved network play. - - Holding the enter key down will no longer do fun stuff to the nsf - player. - - Improved NSF player. It should support streaming pcm nsfs now... - - Changed FDS keyboard keys around a bit. F6 is the disk select key, - and F8 is the disk insert/eject key. - F8 to insert VS Unisystem coin, F6 to view/toggle dip switches. - Hopefully people won't complain after blindly hitting the save state - buttons. :) - - Many fixes and improvements to the Windows port. No more cpu-consuming - wait loops(specifically, sound). Added a message window. - - FDS sound emulation improvements. - - FDS disks are now auto-inserted on power on(or was it loading a new - game...). - - Changed the default last rendered scanline to 231. - - ines header corrections are now printed as status messages, not errors. - - Rearranged input updating code. - - Fixed a sprite transfer bug. Fixes PAL version of Rainbow Islands. - - Debugger hooks added. - - Small optimizations in Refreshline and FetchSpriteData to hopefully - offset the slight slowdown in the cpu core. - - MapperHBIRQHook is now called differently(depending on hi/low bg/spr - addresses). - - Added support for unif board UNL-8237. - - Added support for mapper 144(death race). - - Added partial support for mapper 74. - - Fixed a cpu emulation bug in GETIYWR. It would sometimes set "target" - to 0x10000, which was a BAD THING(overflow; now it wraps). - - Tried to add support for mapper 241. Needs special keyboard emulation. - I think. - - Internal RAM is now initialized to something other than 0. Fixes - Minna no Taabou no Nakayoshi Dai Sakusen. - - Reassigned "The Money Game" to mapper 155. It doesn't seem to - respect the WRAM enable/disable bits. Silly game. And - Tatakae!! Rahmen Man. - - Added support for mapper 115(still needs 256KB CHR select), 241, 114,88. - - Attempted to add support for mappers 91, 187. - - Modified frame IRQ to not break so many damn games. - - Fixed sprite hit detection loop. - - Improved support for mappers 80, 90,117,154, 189. - nnnester and virtuanes. - - Reassigned "Devil Man" to mapper 154. - - Removed bogus Trojan header fix in ines.c. - - - -.81-post: ----- - Fixed/Worked around(?) compilation problems on gcc 3.2.x. - -.81: ----- - - More SDL goodies. - - Renamed "Makefile.olinuxsdl" to "Makefile.unixsdl" - - More SDL fixes and cleanups. - - BeOS port is now compiled with the "-no-fpic" flag, which allows - me to use my inline assembly. The executable work fine as far as - I can tell. - - Added "Makefile.beos". gcc doesn't like my inline assembly - used in RefreshLine(),so this port will likely be slightly slower than - other x86 ports. - - Added a check to make sure SIGBUS is not equal to SIGSEGV in - drivers/cli/main.c. Needed for compiling under BeOS. - - Renamed the "PI" member of the X6502 structure due to conflicts with - a defined symbol with some math header files. - - Merged fcelineasm.h into fceline.h - - Fixed(possibly) a possible problem in fcelineasm.h with input register - clobbering. - - More SDL changes. - - Added speed throttling code to the CLI code, and added a command - line switch "-nothrottle". - - Lots of restructuring/rewriting/merging of the MMC3 code. - - Updated DOS code to use the generic CLI wrapper. - - Reads from $4090 and $4092 now return the current envelope setting - in FDS sound emulation. I'm not sure if this is correct... Affects - "Ai Senshi Nicole" and "Bio Miracle Bokutte Upa". - - Added native SDL sound support to the SDL code. the "olinuxsdl" - now uses this code by default instead of the unixdsp sound code. - - Modified MMC3 IRQ counter emulation. I'll need to watch out to see - if it breaks any games. Fixes: MegaMan 3, Gun Nac, Klax(Japanese). - - Changed a few memory reads in x6502.c to use RdRAM instead of RdMem, - resulting in a slight speed increase. - - Cleaned up mapper 250 emulation code. - - Added support for iNES mapper 51(thanks to Kevin Horton for the - information). - - Merged some iNES mappers corresponding to bootleg multicarts - based on MMC3s with mbshare/mmc3.c. - - Added support for iNES mapper 52(thanks to Kevin Horton for the - information). - - Made some hacks to the MMC3 emulation code so that I can add support - for pirate MMC3 multicarts more easily. I should clean it up later. - Moved mapper 44 emulation code to mbshare/mmc3.c. - - Saving screen snapshots will no longer corrupt the frame buffer - for one frame(unless memory couldn't be allocated). - - Fixed screen snapshot saving(it was sort of broken due to the - changes made to the driver<->emulator interface code; status - messages were being saved to the image). FCEUI_SaveSnapshot() - no longer returns a value(the request to save a screen snapshot is - serviced before status information would be written in the next frame). - - nosprites is now set to 0 before RefreshSprite() returns, to prevent - problems if a game turns off the bg and sprites when FetchSpriteData() - for the next scanline is called but then turns on sprites when - the actual scanline is drawn. - - PPU_hook() is now called more often if PPU_hook is non-null. - Made changes to mappers 118, 95, 9, and 10 to compensate. - No games seem to be broken, and I added support for mapper 96 - (though the games aren't very playable because the special controller - isn't emulated). - - Romance of the 3 Kingdoms is now recognized to use 16KB ex-WRAM. - - Added support for mapper 185...sort of. I think this is another - instance of incompatible hardware being lumped onto one mapper number. - Sigh. - - Added support for "Famicom Jump 2" as iNES mapper 153. - If a good(as far as I can tell) dump is loaded, FCE Ultra will - automatically fix the mapper number. - I also made some changes to the mapper 16 IRQ emulation code. - - BRK now sets the I flag. - - Reads from $4015 no longer reset DPCM IRQ. - - Changed emulation of RTI instruction slightly. - - X.IRQlow is now set to 0 in PowerNES(). - - The VS Unisystem bit in the iNES header is no longer looked at( - I was having too many problems with this bit being set when it - shouldn't have been). Now, VS Unisystem emulation is enabled - when a known VS Unisystem game is loaded. I also rewrote the VS - Unisystem detection function. - - iNES mapper 1 now supports pageable CHR RAM if no CHR ROM is present. - Fixes "Family School". - - Mapper 70 no longer has a mirroring control emulated, and I extended - the number of 8KB CHR pages supported to 16. - - Cleaned up iNES MMC5 save RAM loading/saving code and added - support for MMC1 games with 16KB of RAM(the second 8KB are saved), - via CRC32s(currently only Genghis Khan(USA) and Nobunaga's Ambition( - USA and Japan) are recognized). - - Added support for the MMC5 Koei game "Ishin no Arashi", in the iNES - format(I added an entry with its CRC32 value and the number of 8KB - WRAM banks it needs). - - Better iNES mapper 33/48 IRQ counter emulation. - - Added the game "Uchuusen - Cosmo Carrier" to this list. I'm - beginning to hate the iNES format more and more...or maybe - just Fanwen. :) - - Added the mapper 32 game "Major League" to the list of games - that usually need iNES header correction...but in this case, the - iNES header cannot specify that this game needs to have one-screen - mirroring. - - iNES header information is now printed before any header corrections - are made based on a database. - - Fixed a bug in mapper 32 emulation. "Ai Sensei no Oshiete" - works now. - - Tried to add support for iNES mappers 245 and 249. - - Fixed the MMC5 read handler to return the data last on the data - bus instead of 0xFF when a read was made to an unmapped address. - This seems to fix the lockup problems in "Bandit Kings of Ancient - China". - - Reversed "Modified the time at which the "y scroll" register is updated - during hblank." The changes broke Klax. - - Added an unsigned 64-bit base timestamp variable "timestampbase". - Adding this to the 32-bit variable "timestamp" will return - the number of cycles executed since emulation started(in the future - I'll probably change it to since reset or power toggle). - This allowed me to replace "lastn" hack in the MMC1 code with - something better. - - Changed my mind and undid the removal of support for old save states. - - Removed support for old save states and in general I won't - try to support save states made with previous versions. - - MMC1: Writes to $8000-$FFFF with D7 set will now cause - the first MMC1 register to be OR'ed with 0x0C. I'm not sure - if this is correct, but it doesn't seem to break anything - and it fixes Robocop 3. I'll see if anyone reports games - not working in .81 that worked in .80. - - Worked on a generic driver interface wrapper very similar - to the driver interface FCE Ultra used to use(I'm getting - tired of all of the duplicated driver code). Eventually, - the DOS, SVGAlib, and SDL ports will use this wrapper. - - Similar change to the argument parsing code. - - Changed configuration file saving-loading routines and the - configuration structure to allow for linking config structures - to each other). - - Small fix to the emulation of the MMC5 split screen mode. - - Made Linux SDL code compilable again. - - Changes to MMC5 EXRAM emulation(read/write). - - Fixes to the emulation of the MMC5's split screen mode, based on - observations while using CastleVania 3 and a Game Genie(on a real - NES). - - Fixed a bug in ines.c that caused any calls to AddExState() from - a mapper initialization function to be effectively "erased"(ResetExState() - was called after the mapper was initialized). Fixes the VRC7 sound - state saving/loading stuff. - - Finished adding support for the MMC5's split screen mode(this does - not mean that the support is complete, but at least the intro in - "Uchuu Keibitai SDF" works correctly now). - - Worked on adding support for the MMC5's split screen mode. Not - completed. - - Reverted to .80's FDS sound code. - - Modified the time at which the "y scroll" register is updated - during hblank. - - NSF playing code will now disable FDS sound output on song init - (fixes some problems with the Zelda no Densetsu NSF rip). - - Increased the emulated clock speed of the FDS sound emulation code - to give better quality output. - - Modified NMI to occur a few cycles later. Fixes BattleToads...but - it may have broken other games. Also modified the way NMI's are - handled in x6502.c. - - Modified ines.c to memset() GameMemBlock to 0 on virtual power toggle. - Also, trainers are now loaded into their own buffer instead of - directly into emulated WRAM and copied into emulated WRAM on - power toggle; I've been meaning to do this for quite some time. - - Changes to the way the zapper cursor is drawn on the screen. - - FCEUD_WriteSoundData(), FCEUD_BlitScreen(), and FCEUD_UpdateInput() - have been combined into one function: FCEUD_Update(). - - More fixes to the network play code, and a fix to the Windows network - play driver code that fixes(hopefully) a rather evil bug that caused - lockups when the remote stopped network play. - - Added code to set the battery-backed bit in RAM if a game needs it, - based on CRC32. - - Added more games to the list of games that commonly have bad iNES - headers, in ines.c - - Updated docs and usage.h for DOS and Linux regarding the new video - mode and the new refresh rates. - - Linux: Fixed a bug with video mode 6(a few upper scanlines were being - cut off). Increased the refresh rate of video mode 3 to 120hz. - - Increased the refresh rate of video mode 2 to 65 hz in the Linux port. - - Screen snapshots can now be taken while playing an NSF. - - Added a new sexy tweaked vga mode that I created to the Linux svgalib - port. It's 256x224 at a refresh rate of 103hz. Hopefully it won't - blow up anyone's monitor. ;) - DOS port will follow eventually. - - Modified Makefile.base to produce an executable named "fceu" instead - of "fce". - - The plans(cycle-accurate ppu emulation) for .90 were a bit ambitious, - and I still need to make other fixes before then. - - Fixed some minor(usually) bugs with setting 256x240 tweaked VGA mode - in DOS and Linux ports. - -.80: ----- - - Cleaned/fixed a few things in the mapper 19 emulation code. - Family Circuit '91 still doesn't work quite right... I wonder if - it's a bad dump. - - Added input override code to Windows port. - - Added code to fix iNES header information in RAM and suggest - changes to the user. - - Added support for iNES mapper 152(to be used with games set to - mapper 70, that use one-screen mirroring instead of h/v mirroring). - - Blits using the DirectX blitting function(method?) to the primary - surface are now done with the asynchronous flag set(if that - fails, a "normal" blit is tried). - - The DirectX blit buffer(secondary surface that FCE Ultra writes to - directly and then uses the DirectDraw blit function on to blit - to the primary buffer) is now created without specifying it - should be in system memory or video memory, except in the case - when no hardware blitting is available, and then DDraw is explicitly - told to create the surface in system memory. - - Added Family Keyboard support to the DOS port. - - Cleaned up the VRC7 sound emulation code. I need to find a way - to save the current sound state in a save state. - - Found out the real name of the "Space Shadow" gun; it's - called the "Hyper Shot". I'm still not sure who made it, though. - Possibly Bandai did. The interesting thing is that Konami - also made a Famicom accessory(dual square boxy things with two buttons - on each) with the same name(though there might not be a space in the - name). - - Only the upper two bits read from $4016/$4017 are undefined. - Bit5 is always 0, though. Fixed the bug in "input.c". - Silly kevtris' old documents. New kevtris' brain is always good. - - Family Keyboard support for the Windows port. - - Added support for the Family Basic Keyboard to the Linux port, other - ports todo. - Might want to add support for the tape recorder at some time. - Also mapped the "Scroll Lock" key to disable/enable command keys - so that the FBK is more useable. It doesn't disable CTRL C, - though... - - Changed a lot of inlined functions in x6502.c to macros so that - I could test out some optimization ideas. - - DOS code updates for game input override support. - - Small optimzation to opcode $4c, and relative jumps. - - Added some code to ines.c to set controller information in - FCEUGameInfo(returned by FCEUI_LoadGame()) based on crc32 values. - - Updated user documentation and usage.h for DOS and SVGAlib input - command-line changes. - - Added an option to disable the four-score(to Windows and Linux ports - so far). - - Updated Windows interface to support the new Famicom expansion - devices. - - (Re)Added support for the Famicom 4-player device. - - Improved Zapper emulation...sort of. It still needs a lot of work. :/ - - Added *partial* support for the "Space Shadow" gun. - - Added support for the Arkanoid controller(both NES and Famicom style). - - Added code to support the extension Famicom input devices. - - Added PAL scanline start/end drawing settings to Windows port. - - Added pause emulation key(F2) to Windows port. - - In the process of rewriting/fixing up input code stuff. - - Minor bug fix to Power Pad emulation code. - - VS Hogan's Alley and VS Duck Hunt automatically select the zapper - now(though it only works on the SVGAlib port). - - Undid some FDS sound code changes introduced in 0.76 that totally - screwed up sound. Oops. - - Added code to allow different settings for first/last scanline - drawn while in PAL emulation mode, to the Linux and DOS ports. - - Added convenience(it's not necessary, but it reduces redundant and - confusing code in the driver code) function - FCEUI_GetCurrentVidSystem(int *slstart, int *slend). - - Updated file "TODO". - - Changed #include to #include "zlib/unzip.h" - in file.c. - - NSF 6502 player now initialized the stack pointer on reset. - - Worked on de-emphasis emulation code quite a bit. - The deemphasized palette calculated at the end of the frame is now - based on what deemphasis bits were set for the longest during - the screen(sampling interval is a scanline) update loop. - Added a "static" deemphasized palette at $40-$7F in the palette table. - This corresponds to the colors when all of the deemphasis bits are set. - I did this to fix the PAL game "Noah's Ark", without breaking - anything else. The only downside is a slight speed loss(~2% on - my system when sound is disabled), but this is acceptable to me, - at least. - Maybe it's time to write hi/true-color ppu drawing code... - - - Fixed an out of bounds array access in svga.c in SetNESDeemph(). - The variable "lastd" in svga.c was being initialized to the wrong value. - Thanks to "Jarod CANAL" for pointing this out. - - Removed FCEUI_SetFirstRenderedLine or whatever it was called and - the function to set the last line. Replaced with: - void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); - - Changed SetVidSys(int w) to ResetVidSys() in fce.c. Reenabled - PAL/NTSC emulation overrides based on game loaded(really only useful - for NSFs and UNIFs now). - - UNIF loading code now recognizes the chunk "CTRL" and tries - to use it. Only the svgalib code supports overriding of input - settings based on game loaded, now, though... - The user is still going to have to configure powerpad settings - on his/her own. - - Fixed return values of FCEU_fseek() and fixed a problem in unif.c - related to it. - - Changed mechanism for how FCE Ultra tells the driver - code what type of system is being emulated. A structure of - type "FCEUGI" is returned from FCEUI_LoadGame(). - - Fixed a major mapper 64 emulation bug introduced in 0.76. - - Modified BlitVidHi() in drivers/win/video.c to speed it up. - - Added support for loading the iNES-format Game Genie ROM image. - - Removed ggrom.h and added code to load the Game Genie ROM - image from a file. - - Added Windows netplay.c. (new: the user exiting the emulator - while stuck in a blocking recv() or send() loop now works.) - - Fixed a vram address register bug in fce.c that I created when I got - rid of the pair/dpair data types. - - Added new mappers/92.c - - Removed mappers/92.c until I can contact LULU or rewrite it. - - drivers/win changes. Removed netplay.c until I can rewrite it. - - Got rid of pair/dpair data types. - - Got rid of silly "TempArray" thing. - - Began adding GPL headers to files. FCE Ultra is going to be in - a state of legal limbo for the next few days... - - Replaced crc32.c and crc32.h, and added some #ifdef's and #defines - to use the crc32 code in zlib instead if zlib is linked with - FCE Ultra. - - More fixes to sb.c. - - Cleaned up drawing.h and ggrom.h(even though ggrom.h will *probably* - be removed before the next release). - - Redid frameskip code. - - Rewrote necessary pieces of sb.c and sb.h and fixed quite a few - bugs. I still need to test it on various other sound cards, though. - - Rewrote(more like "recreated in my own image") DOS keyboard driver. - Removed unused "keyscan.h" from drivers/svgalib - - Rewrote part of(the parts that Marat wrote - the connection and - closing parts) the Linux TCP/IP network play code. I guess it works, - but I haven't tested it very much. In any case, it's still dangerous - to use network play in FCE Ultra with SVGAlib, since recv() or send() - might block and since the keyboard is in raw mode, you have a problem. - Maybe a future SVGAlib will fix the general problem of lockups if - keyboard_update() isn't called, though it is only partly SVGAlib's - problem... - - Fixed FCEU_fseek() when used with a compressed file in the PKZIP - format that has been loaded. Fixes a UNIF loading problem. - Also added a check to the return value of FCEU_fseek() in unif.c. - - Replaced Marat's 6502 emulation core with my own. - It should be fully functional, but as always, I don't know if - I implemented the undocumented instructions correctly. - Several things are correct in this new core that were not in - Marat's(D flag is no longer cleared by interrupts, for example). - - Altered mapper 16 irq counter emulation slightly. - - Fixed the behavior of the SXA, SYA, and XAS opcodes based on the - documentation I have. I'm not sure what happens when page crossing - occurs with those instructions on a real NES, though. - Also CHANGED(not fixed) emulation of opcode $8B("XAA"). - - Changed some of the M* functions(absolute indexed and maybe some others) - to perform dummy reads. - - Changed some of the macros in m6502.c to inlined functions so - that I can modify and examine them more easily. - -.77: ----- - - Fixed a silly network play bug(in the global network play code) - that caused excessive lag. - - Added a "niceness" setting to the sound configuration dialog. - Removed obsolete information from the dialog. - - Fixed speed throttling code in Windows port when PAL emulation is - disabled/enabled and a new game hasn't been loaded yet. - - Commented out a printf() to debug stuff in fds.c(oops). - - Applied PK's joystick patch to the osdl code. It allows the user - to map axes and it fixes a joystick button mapping configuration saving - bug. - - Added two command line options new to Linux port to DOS port. - Just need to test them... - - Added some stuff to unif.c to allow for boards that can support - CHR RAM instead of CHR ROM(darn Sachen boards...). Fixes UNIF - version of "Q-Boy". - - Added command line option "-snapname" to Linux port. I'll add it - to the Windows port as well, but probably not to the DOS port. - - Added clip option to Linux port. - - Fixed sound logging(in Windows port) so that multiple recording - sessions now work. - - Added an option to clip the leftmost and rightmost 8 columns - of graphics in the Windows port. - - Added a submenu that lists recently opened files, in the Windows - port. - -.76: ----- - - Updated porting.txt. - - Added speed throttling code to Windows port that's used when sound is - disabled(and an option in the "Miscellaneous" - configuration window to disable it). - - Added cheat interface to DOS build. - - A few tweaks to the text cheat interface code in the cheat listing code. - Added a command to quickly toggle the status of the cheat(though a - cheat can still be disabled/enabled by (M)odifying the cheat). - - Support for UNIF UNL-TC-U01-1.5M board added. Same credits as below. - - Rewrote mapper 228 code just for the heck of it(actually, I couldn't - figure out why some(about two) of the games in the Action 52 cart - weren't working in .75(and .76). I traced it back to .71, where an apparent bug in - the undocumented 6502 opcode emulation allowed it to work, which - was later fixed for the .72 release(opcode 0x7C)). I'm thinking - that the dump is bad... - - Added a few crc32 checks to ines.c to check for and report when - a known(by me) bad(hacked or bad dump) game is loaded. - - Added support for the following UNIF boards. Thanks to Quietust - and Kevin Horton for the information. Some problems still exist - with a few games that use these boards, though... - - UNL-Sachen-8259B - UNL-Sachen-8259A - UNL-Sachen-74LS374N - UNL-SA-016-1M - UNL-SA-72007 - UNL-SA-72008 - UNL-SA-0036 - UNL-SA-0037 - - Fixes to some stuff in cart.c(for example, calling setprg32() when - only 16kb of prg data is present now works). - - Added support for iNES mapper 189. - - Tried to add support for the UNIF board "UNL-H2288". Failed. - - Updated "cheat.txt" to fix a few typos and added an example of finding - and adding a cheat using the Linux port's text interface. The actual - section on the Linux cheat interface still needs to be written, however. - - Changed network play code in the Windows port and fixed a bug. - Fixed a similar bug in the Linux netplay code....sort of. - - A few cosmetic changes to the dialogs in the Windows port. - - Fixed sound initialization on the Windows port(it was being initialized - when FCE Ultra started even if it was disabled by the user. Oops.). - - Joystick button configuration code in Windows port changed slightly - to be more useable. - - Changed reference to video mode 5 in the linux port to "1 per 4". - It may not be very meaningful, but it is certainly better - than "TV Emulation". I'll change the Windows port reference later. - - Documented video mode 7(320x240) for the Linux port. Also added - a check for the FBDev driver in order to use this mode instead - of a tweaked vga mode if that driver is being used. - - Added/Fixed cheat interface for Linux port. It's still not perfect, - though. The code is ugly... - - Callback function for FCEUI_ListCheats() now receives - status information(enabled/disabled). - - Callback functions for cheat functions now must return 0 to - stop listing cheats or 1 to continue. - - Fixed a problem(the cheat code was reading in cheats - for address $0000 from cheat files if any blank lines were present). - - SDL port zlib changes(linked dynamically to zlib now). - - More changes to envelope decay + looping on code. No longer - depends on value @ $4017. It now sounds correct based on some - tests I did with SMB3 and a GG, but Goonies 2 doesn't sound right( - based on a sound file sent to me by another person). - - Added support for iNES mapper 140. Thanks to Quietust for the - information. - - I need to figure out how to deal with the problem of so many - bad NSFs that most people consider good... - - Changed envelope decays a bit. Their behavior now depends on bit - 7 of $4017. I don't know if this is right... - - Addition of debug.c for some debugging stuff. - - Updated zlib to 1.1.4. - - Modified code in various files to allow UNIF games to override - current selected video system emulation(NTSC or PAL). Need to - make sure this really works. - - Changed sound.c to prevent desynchronization during network play. - This might slow down sound emulation slightly, especially when - sound emulation is disabled. I really don't care... - - Updating network play code. More info later... - - Moved the sound/video/etc output code in EmLoop() to the top of the - for(;;) loop so that initialization prior to calling EmLoop() will - be the same as initialization done during a call to a FCEUD_* function. - - A few very small changes to sound emulation in fds.c. - - Changed unlink() to remove() in cheat.c and removed the including - of the header file unistd.h. - - Split up the cc=... statement in RefreshLine() to make it easier - to read and not ambiguous(to Borland's C compiler). - - Changed a lot of the function declarations in cheat.c. I'll need - to verify that cheat searching still works ok and that cheats still work - ok. I'll also need to update the Windows(and Linux console) cheat code - to prevent compiler warnings. - - Fixed various minor code problems(not minor if you want to use a - compiler besides gcc). This is an ongoing process... - - Removed bit fields after reading about and thinking about possible - portability problems, though I kept some optimizations in fceline.h - - Minor code simplification in drivers/win/joystick.c(replaced - "case 200 ... 207" and "case 208 ... 215". - - Modified some code to use bit-fields in the graphics rendering code - in fce.c and fceline.h. gcc seems to be able to optimize the new - code to run faster. - - Fixed m6502.c and fce.c to initialize variables on virtual power - toggle. This should fix network play on the Windows port. - I'm also in the process of cleaning up fce.c. - -.75: ----- - Fixed directories configuration stuff in Windows port(corresponds - to .75r2). - - More changes to square wave channel envelope/volume emulation... - Changes described in the large paragraph some lines down have been - abandoned. - - Added a command line switch to set the volume in the dos port. - - Changed Windows sound configuration dialog. Now buffer length is - specified in time, not samples. I also added a volume control. - - Reduced the volume on 8-bit sound output on all ports by 1/2. - - Added a function FCEUI_SetSoundVolume(). Added support for setting - the volume via the command line in the Linux port, other ports coming - soon. - - Changed FCEUD_WriteSoundData() again. No longer has a "Check" - argument. All clipping(ugh) is done internally now. - - Added a directories configuration dialog to the Windows port. I worked - on it too long and I became a zombie, so it might have a few bugs. - That's what guine...err...users are for. ;) Don't expect me to do - anything like this for any other port, though. I don't feel like - doing it on the DOS port, and the Linux and other UNIXy ports shouldn't - really need it. - - Made some changes to the rectangle/square wave channel emulation to - fix the pops in SMB. I have no idea if what I did is correct. To - be honest, I'm not sure I know EXACTLY what I did, but it's something - like this: Writes to $4003/$4007 now reset the duty cycle count - and reload the cycle counter with the current wavelength. Writes to - $4003/$4007 now do not update the amplitude output of the channels; they - will be updated after the cycle counter hits 0(or below). - - More information in iNES informational output. - - Minor changes to mappers/16.c. - - Increased the volume of the VRC6's sawtooth wave channel. - - Added more information to the RAM cheat guide. - - Changed the triangle wave generation code slightly. I decided - to remove support for the higher-frequency triangle waves, as they - are too cpu-costly to create and are probably not very audible on a - real NES anyway. - - Major changes to how sound is mixed. This necessitated a high pass - DC-offset removing filter, and a low-pass filter just to make things - sound better. ^_^ - Note: FCEUD_WriteSoundData() no longer needs to clear the waveform - data referenced by the passed pointer; it's done internally now. - - Fixed JMP ($xxxx) - now handles wrapping like it occurs on a real 6502 - (hopefully; I'm assuming that the same holds true for the NES' cpu). - - Added the ability to load a custom global palette in the DOS port. - - Fixed bug in drivers/common/unixdsp.c(wrong return value if sample - rate was out of range). - - Many sound fixes... - Frequency sweeps, length counter stuff,... - - Changed Windows port to use IDirectInput7 and IDirectInputDevice7 - interfaces. - - Fixed a Game Genie bug in the core emulation code. It only appeared - in the Windows port, though. (Enabling gg emulation, loading a game, - and then disabling gg emulation and loading a new game while in the - gg code entry screen would cause the new loaded game to not work - correctly). - - Modified windows port to use the config saving/loading stuff in - drivers/common/config.c - - Mapper 45 cleanups/fixes. - - Added the ability to load a custom global palette in the Linux port. - Yay. - - Fixed a large number of overcomplicated code and silly bugs in - drivers/common/config.c. This changes the format of the configuration - structure, too. Also added support for saving/loading strings with - automatic memory allocation when strings are loaded. - - Minor change in InitNetplay(). - - Fixed bad type conversions for pointers to functions and fixed - some bad declarations of functions. - - Reenabled zlib support for the sdl build. I need to pay attention - to patches that modify lines than don't fit on my screen. - - Fixed vidblit.c to not emit so many warnings when compiling. - -.74: ----- - - Stop sound in Windows port when user clicks l/m/r mouse buttons - in the non-client area of the window. - - Added "Drag and drop" file open support to Windows port. - - Various code cleanups. - - mappers/33.c optimization. - - Rewrote the function "FCEU_MakeFName()". - - Removed crc32.h from mappers directory. - - Modified some of the window resizing code in the Windows port. - - Added support for waiting for vblank/double buffering to the Windows - port. - - Added/Fixed support for iNES mapper 248. - - After an NSF file is loaded, information about its header is now - displayed. - - Fixed a typo in the Namco 106 extra ram handling code. - - Improved the quality of the Namco 106's extra sound channels. - - Thank Mamiya and Applepie(real name?) for info. - - When an NSF file is being played, FCE Ultra will no longer go through - its scanline rendering loop. This speeds up NSF playback considerably. - - Updated "porting.txt". - - Moved some stuff from DriverInterface() to their own functions. - - Fixed some iNES mapper 18 IRQ counter emulation bugs. "Ninja Jajamaru - - Ginga Dai Sakusen" now works. - - Rewrote large pieces of the mapper 64 code. "Skull and Crossbones" - still doesn't work, though. - - Changed format of iNES header information output, added "ROM CRC32" info. - - Modified the way cycle timing is done slightly. No change - for NTSC emulation, but PAL emulation is a little more accurate. - - Changed the behavior of indirect indexed(I hope I got that right ;)) - instructions to behave more like a real 6502(junk reads are now - performed). - - A few optimizations/cleanups in m6502.c. - -0.73 ----- - - * Fixed several bugs with sprite emulation. Several games(such - as "Trojan" and "VS Duck Hunt") that were broken in .71 and .72 now - work ok. - * Added support for iNES mapper 82. Thanks to those who work on - "unofficial nester". - * Added support for iNES mapper 250(used by "Time Diver Avenger"). - * Fixed the documentation to show that iNES mappers 48, 83, and 232 - are supported. - * Removed various pieces of stale code and fixed a few minor bugs. - * Fixed a triangle wave channel bug(the channel was sometimes enabled - when it shouldn't have been). - * Writing to $4010 with the upper bit clear now acknowledges the DPCM - IRQ. This appears to fix "Stunt Buggies". - * Rewrote pieces of the Zapper emulation code to be cleaner and more - accurate. - * Rewrote the VS Unisystem dip switch drawing code. - * Simplified the setting of VS Unisystem dip switches. The "V" key - now toggles viewing AND editing of dip switches. - -0.72 ----- - - * Various minor bug fixes. - * Various code cleanups and size and speed optimizations. - * Removed some (apparently) unused MMC5 sound emulation code. - * Changed the behavior of $2003 and $4014 to better simulate what occurs - in a real NES. - * Fixed a few bugs in the undocumented 6502 opcode emulation code. - The Game Genie code "NUTANT" for SMB 3 works correctly now, at - least(previously it caused the game to lock up at the end of levels). - * Rewrote large pieces of the 6502 memory fetching code, resulting - in a slight slowdown in the speed of emulation. Benefits include: - Game Genie emulation now works(again) and 6502 emulation is more - accurate. - * Added support for iNES mapper 72. Thanks to rinao for the information. - * Fixed support for iNES mapper 77(used by Napoleon Senki). - * Fixed/Added support for iNES mapper 226. Apparently I made a mistake - in the documentation. Thanks to Mark K. for the information. - * Added support for iNES mapper 227. Thanks to Mark K. for the - information. - * Added support for iNES mapper 234(used by the Maxi-15). Thanks - to Mark K. for the information. Note that many of the Maxi-15 - ROM images on the Internet have corrupt CHR data(graphics), or the - mapper number is set incorrectly(usually to 11). Use a utility to - fix the mapper number. - * Added support for the following UNIF boards(prefixes omitted): - - EKROM (and fixed the reference to "Gemfire" in the documentation). - - HKROM - * Added the ability to enable and disable individual RAM cheats. - * Fixed some problems with the cheat search code(the NES' internal - RAM was being searched differently than any external RAM, which - was being search incorrectly). - -0.71 ----- - - * Fixed a 6502 emulation bug that was causing some Koei games - (ex: Nobunaga's Ambition, Genghis Khan) to not work. - * Extensive PPU/CPU timing adjustments. - * Fixed support for iNES mapper 40. - * Added support for the following UNIF boards(prefixes omitted): - - ETROM - - ELROM - - EWROM - * Fixed a few bugs in the UNIF code. - * Added support for loading and saving cheat files and an interface - to search for/add/delete/list cheats(no interface yet on Linux/DOS). - * Fixed a few minor bugs in the Windows DX code. - * Command line options to control the number of sound fragments - and the fragment size have been added(Linux). - -0.70 ----- - - * Adjusted PPU/CPU timing. - * Removed(until I understand the problem) a hack to get one of the - games in the Caltron 6-in-1 to work. - * Fixed an MMC3 IRQ emulation bug("Project Q" works better now). - * Fixed a problem/misunderstanding regarding the upper scanline. - It can now be displayed again. - * More accurate sprite hit emulation(fixes the title screen of - "Ultimate Stuntman"). - * VRAM bank switching for iNES mapper 4 is now possible(and enabled - for all mapper 4 games without CHR ROM). Fixes "Tenchi o Kurau 2". - * Added support for the Famicom's four-player adapter and the ability - to enable it(it is disabled by default to prevent compatibility - problems). - * Added an option(under miscellaneous configuration) to automatically - open the "File Open" dialog box when FCE Ultra is started. - * Sound sampling rate is now configurable. - * Fixed some bugs in the DirectSound code. - * Joystick button configuration is a little more user friendly(and - stable, hopefully) (Linux). - -0.62 ----- - - * Added support for the Famicom Disk System's extra sound channel. - * Updated the version of Tatsuyuki Satoh's OPL2 emulator used in - FCE Ultra from .36f to .37a. The sound quality in "Lagrange Point" - seems to have improved. - * Added support for iNES mapper 242(used by "Wai Xing Zhan Shi"). - * Fixed a network play bug that could cause desynchronizations - if more than one network play session occured since FCE Ultra - was started. This bug only showed up on the Windows port, though. - * Increased the volume of the noise and triangle sound channels. - * Fixed a save state loading bug. - * Fixed a small memory leak that was being caused by the VRC7 - state loading code. - * Fixed a bug that could cause FCE Ultra to crash if a virtual disk - was being read and the user ejected the virtual disk. - * Various minor bug fixes/code cleanups. - * NTSC color "emulation" can now be enabled again(the code to - enable it was broken in the last version). (Linux) - -0.61 ----- - - * Speed optimizations in sprite rendering code. - * Screen snapshots are now saved in the PNG format instead of the PCX - format. - * Fixed Game Genie emulation(it wasn't working in the last release). - Also added support for Game Genie emulation to the UNIF code. - * Rewrote command line option parsing code. - * Fixed a problem(if FCE Ultra was configured to connect to a remote - host and the remote host was given as an IP address, and the IP - address couldn't be reverse resolved, which is commonly the case - on home LANs, the connection attempt would fail) in the network - play code. I had misinterpreted the Winsock API documentation - when I wrote the code. (Windows) - -0.60 ----- - - * Various speed optimizations. - * Sound is no longer messed up when a JAM/KIL opcode is emulated. - * Fixed an overflow bug that occured when $4014 was written to - during certain(rare) conditions. - * Fixed a few save state bugs. - * Fixed a MMC1 CHR bank switching bug. - * Added emulation of the MMC5's WRAM write-enable/disable registers. - * Fixed a sound frame IRQ emulation bug. "Qix" works now. - * Added UNIF support. Some of the board emulation is still a bit - buggy, though. Look at the documentation for a list of supported - boards. - * Updated the "Palette Notes" section of the documentation. Also - fixed a few other problems with the documentation. - * Added support for loading files in the PKZIP and gzip - compressed file formats via zlib. - * Added the ability to configure the first scanline and the last - scanline to draw to the screen. Enabling PAL emulation no longer - will cause all 239 scanlines to be displayed, though an option - to override these settings for when PAL emulation is enabled may - be in the next version. - * Fixed a bug that would cause the emulated D-pad of virtual gamepads - emulated through the keyboard to be duplicated through "higher" - virtual gamepads(gamepad 1 would affect 2,3,4; gamepad 2 would - affect 3,4; etc.). (Windows) - -0.55 ----- - * Rewrote window resizing code. The window will now resize itself - to a multiple of the NES' screen dimensions nearest to the user - selected dimensions. (Windows) - * Added an option to use buttons instead of axes on physical joysticks - for the emulated D-Pad. This is useful for some digital joysticks. (Windows) - * Fixed a bug that would cause FCE Ultra to crash if sound were - disabled during emulation. (Windows) - * Added the ability to "fast forward" emulation. - * Added an option to allow more than 8 sprites per scanline to be - displayed. - * Added an option to save all extra non-volatile game data - (such as battery-backed RAM) in a directory under FCE Ultra's - base directory(as opposed to the directory the game is located in). - * Added an option to allow the emulator to change to a full screen - video mode once a new game is loaded. (Windows) - * Rewrote pieces of DirectInput joystick handling code. Hopefully - it should increase compatibility. (Windows) - * Added the ability to automatically obtain button numbers when - configuring joysticks, by pressing buttons on the joystick. - * Added the ability to close the current game(decreases CPU usage). (windows) - * Increased the speed of various function calls by passing - arguments to functions through registers instead of through the - stack. - * Added emulation of the MMC5's raw PCM register. - * Added the ability to save/load save states while network play - is occuring. - * Having PAL emulation enabled will no longer override the - NTSC/PAL settings in NSF headers. - * Fixed a bug that got into the .54 release. Extraneous data was - being returned on reads from $2002, which caused problems - with some games(such as "Choujin Sentai Jetman"). - -0.54 ----- - * Fixed a bug that would cause a wrong battery-backed WRAM file - name to be produced if FCE Ultra was passed a file name without - any directory component(such as "fceu SuperBlah.nes"). - * Fixed an iNES mapper 118 emulation bug that got into the code - in a recent code cleanup. "Armadillo" is playable again. - * Fixed a typo(and bug) in the MMC5 emulation code. - * Data returned from emulated reads to "unmapped" areas or - memory locations where bits are undefined should now be correct. - * Fixed emulation of the sprite memory transfer register $4014. - It now takes into account the last value written to $2003 and - starts the transfer to that location in sprite memory(like on - a real NES). - * Added a video configuration dialog box. (Windows) - * Added the ability to configure a custom video mode. Aspects - that are configurable include width, height, bits per pixel, - and size transforming(stretching and scaling). (Windows) - -0.53 ----- - - * Fixed a bug with joysticks that occured on systems with multiple - joysticks. (Windows) - * Added support for iNES mappers 77 and 92(thanks to LULU for the code for both). - * Added partial(timer is non-configurable) support for iNES mapper 105. - * Changed save state format again. Save states made with previous - versions should still be compatible, though this may change in - future versions. - * Small optimization to sprite emulation code. - * Rewrote color-deemphasis code to use integer math instead of - floating-point math. - * Rewrote and restructured input code. (Linux) - * Added command line option "-f8bit" to force 8-bit sound. (Linux) - * Rewrote and restructured input code. Among other new features, - keyboard keys are now somewhat configurable. (Windows) - * Writes to $4003/$4007 will now reset the emulated square wave - duty cycle generator. - * Added emulation of the Power Pad. - * Rewrote joystick device reading code to use the event-driven - interface. This should fix various problems regarding support - for joysticks with many buttons. (linux) - -0.52 ----- - - * Fixed a PCM emulation bug(digitized voices in "Ikari Warriors 2" - and "The Immortal", among others, work now). - * Fixed noise channel's LSFR update frequencies(hopefully). - * Various minor bug fixes. - -0.51 ----- - - * Added support for iNES mappers 86 and 89. - * Reduced byte size of the NSF player's background. - * Adjusted CPU/PPU timing. - * Fixed sound channel frequency calculations for when PAL emulation is enabled. - * Rewrote large pieces of the sound code and got rid of the sound queue. Sound quality should be slightly better now. - * Various minor bug fixes. - - Windows: - - * Fixed an FDS side reset bug when a new game is loaded. - * Screen width/depth/height changes while FCE Ultra is in windowed mode are handled now. - * Changed the configuration file format. - * Added a palette configuration dialog. - * Added the ability to load a custom NES palette. - * Added an option to double 16-bit sound volume. - * Added an option to force 8-bit sound. - * Added an option to use a secondary sound buffer(versus the primary). - * Added an option to wait for vertical blank if sound is disabled. - * Added an option to run while focus is lost. - -0.50 ----- - - * Many bug fixes. - * Sound code partially rewritten to improve quality(near-perfect - raw PCM now) and eliminate the need for a separate thread. - This created a small problem with network play, though, so read - the network play notes section. Also, synchronizing to - vertical blank has been removed. - * Rewrote other pieces of sound code. No more "buzzing" in MegaMan 2, - Codemasters games' intros, etc. - * Added support for the NES Zapper and the VS Unisystem's light - gun. Be sure to read "Light Gun Notes". - * Changed save state format. Save states should now be much - smaller for most games. Most(not all) save states created with - an older version should work. - * Added support for VS Duck Hunt and VS Hogan's Alley. - diff --git a/branches/sdl2/attic/cmake-stuff/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/CMakeLists.txt deleted file mode 100644 index 49277b50..00000000 --- a/branches/sdl2/attic/cmake-stuff/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(fceux) -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) -add_subdirectory(cmake/native) -if(UNIX) - add_subdirectory(cmake/cross-mingw32) -endif(UNIX) - -add_custom_command( - OUTPUT ${EXECUTABLE_OUTPUT_PATH}/fceux.chm - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/drivers/win/help/fceux.chm ${EXECUTABLE_OUTPUT_PATH}/fceux.chm - DEPENDS ${CMAKE_SOURCE_DIR}/src/drivers/win/help/fceux.chm - VERBATIM -) -add_custom_target( - InstallHelpFile - ALL - DEPENDS ${EXECUTABLE_OUTPUT_PATH}/fceux.chm -) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt deleted file mode 100644 index 9d36cf4b..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(release) -add_subdirectory(debug) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt deleted file mode 100644 index 4ed85291..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/debug/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -project("fceux: cross-mingw32 debug") -set(CMAKE_BUILD_TYPE debug) -set(FCEUX_EXE_NAME fceuxDBG.exe) -include(${CMAKE_SOURCE_DIR}/cmake/cross-mingw32/fceux_cross-mingw32.cmake) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake b/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake deleted file mode 100644 index cb9c34db..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/fceux_cross-mingw32.cmake +++ /dev/null @@ -1,50 +0,0 @@ -include(CheckIncludeFile) - -# Find mingw by looking for windows.h; set HOST accordingly. -find_path(PATH_TO_WINDOWS_H windows.h - /usr/i386-mingw32msvc/mingw/include - /usr/i586-mingw32msvc/mingw/include - /usr/i686-mingw32msvc/mingw/include - /usr/i386-mingw32/mingw/include - /usr/i586-mingw32/mingw/include - /usr/i686-mingw32/mingw/include -) -string(REGEX MATCH "i.86-[^/]*" HOST ${PATH_TO_WINDOWS_H}) - -set(CMAKE_CROSSCOMPILING TRUE) -set(MINGW TRUE) -set(WIN32 TRUE) -set(APPLE FALSE) -set(UNIX FALSE) -set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_C_COMPILER "${HOST}-gcc") -set(CMAKE_CXX_COMPILER "${HOST}-g++") -set(CMAKE_RC_COMPILER "${HOST}-windres") - -set(CMAKE_FIND_ROOT_PATH "/usr/${HOST}") -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -include(${CMAKE_SOURCE_DIR}/cmake/fceux.cmake) -# I cannot fucking believe that I need to do this: -#don't: ENABLE_LANGUAGE(RC) # above -#do: (for cmake-2.6.0 at least) -set(OUTPUT_RES_RC_O CMakeFiles/${FCEUX_EXE_NAME}.dir/__/__/__/src/drivers/win/res.rc.o) -add_custom_command( - OUTPUT ${OUTPUT_RES_RC_O} - COMMAND ${HOST}-windres -Isrc/drivers/win -DLVS_OWNERDATA=0x1000 -o ${OUTPUT_RES_RC_O} ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - DEPENDS ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - VERBATIM -) -add_custom_target( - BuildResourceFileFor${FCEUX_EXE_NAME} - DEPENDS ${OUTPUT_RES_RC_O} -) -set(DEFINED_BUILD_RESOURCE_FILE TRUE CACHE GLOBAL "This is a hack to get CMake to build the .rc file") - -add_dependencies( ${FCEUX_EXE_NAME} BuildResourceFileFor${FCEUX_EXE_NAME} ) -set_property( - TARGET ${FCEUX_EXE_NAME} - PROPERTY LINK_FLAGS ${OUTPUT_RES_RC_O} -) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt deleted file mode 100644 index 0e32033f..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/cross-mingw32/release/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -project("fceux: cross-mingw32 release") -set(CMAKE_BUILD_TYPE release) -set(FCEUX_EXE_NAME fceuxREL.exe) -include(${CMAKE_SOURCE_DIR}/cmake/cross-mingw32/fceux_cross-mingw32.cmake) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/fceux.cmake b/branches/sdl2/attic/cmake-stuff/cmake/fceux.cmake deleted file mode 100644 index 6d1a5191..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/fceux.cmake +++ /dev/null @@ -1,476 +0,0 @@ -#TODO: install generated exe's, appropriately named, in bin/ -include(CheckFunctionExists) -include(TestBigEndian) - -option(FCEUX_FORCE_LE "Build for a little-endian target" OFF) -option(FCEUX_FORCE_BE "Build for a big-endian target" OFF) -option(FCEUX_FRAMESKIP "Build legacy frameskip code" OFF) - -if(WIN32) - OPTION (NOWIN32 "Replace Win32 support with SDL" OFF) - if (NOWIN32) - set(WIN32 OFF) - endif(NOWIN32) -endif(WIN32) - -if (NOT WIN32) - option(FCEUX_SDL_OPENGL "Build with OpenGL support" ON) - find_package(SDL REQUIRED) - find_package(ZLIB REQUIRED) - if(FCEUX_SDL_OPENGL) - find_package(OpenGL REQUIRED) - endif(FCEUX_SDL_OPENGL) -endif(NOT WIN32) - -set(SRC_CORE - ${CMAKE_SOURCE_DIR}/src/asm.cpp - ${CMAKE_SOURCE_DIR}/src/cart.cpp - ${CMAKE_SOURCE_DIR}/src/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/conddebug.cpp - ${CMAKE_SOURCE_DIR}/src/config.cpp - ${CMAKE_SOURCE_DIR}/src/debug.cpp - ${CMAKE_SOURCE_DIR}/src/drawing.cpp - ${CMAKE_SOURCE_DIR}/src/fceu.cpp - ${CMAKE_SOURCE_DIR}/src/fds.cpp - ${CMAKE_SOURCE_DIR}/src/file.cpp - ${CMAKE_SOURCE_DIR}/src/emufile.cpp - ${CMAKE_SOURCE_DIR}/src/filter.cpp - ${CMAKE_SOURCE_DIR}/src/ines.cpp - ${CMAKE_SOURCE_DIR}/src/input.cpp - ${CMAKE_SOURCE_DIR}/src/movie.cpp - ${CMAKE_SOURCE_DIR}/src/netplay.cpp - ${CMAKE_SOURCE_DIR}/src/nsf.cpp - ${CMAKE_SOURCE_DIR}/src/oldmovie.cpp - ${CMAKE_SOURCE_DIR}/src/palette.cpp - ${CMAKE_SOURCE_DIR}/src/ppu.cpp - ${CMAKE_SOURCE_DIR}/src/sound.cpp - ${CMAKE_SOURCE_DIR}/src/state.cpp - ${CMAKE_SOURCE_DIR}/src/unif.cpp - ${CMAKE_SOURCE_DIR}/src/video.cpp - ${CMAKE_SOURCE_DIR}/src/vsuni.cpp - ${CMAKE_SOURCE_DIR}/src/wave.cpp - ${CMAKE_SOURCE_DIR}/src/x6502.cpp - ${CMAKE_SOURCE_DIR}/src/boards/01-222.cpp - ${CMAKE_SOURCE_DIR}/src/boards/103.cpp - ${CMAKE_SOURCE_DIR}/src/boards/106.cpp - ${CMAKE_SOURCE_DIR}/src/boards/108.cpp - ${CMAKE_SOURCE_DIR}/src/boards/112.cpp - ${CMAKE_SOURCE_DIR}/src/boards/117.cpp - ${CMAKE_SOURCE_DIR}/src/boards/120.cpp - ${CMAKE_SOURCE_DIR}/src/boards/121.cpp - ${CMAKE_SOURCE_DIR}/src/boards/15.cpp - ${CMAKE_SOURCE_DIR}/src/boards/164.cpp - ${CMAKE_SOURCE_DIR}/src/boards/175.cpp - ${CMAKE_SOURCE_DIR}/src/boards/176.cpp - ${CMAKE_SOURCE_DIR}/src/boards/177.cpp - ${CMAKE_SOURCE_DIR}/src/boards/178.cpp - ${CMAKE_SOURCE_DIR}/src/boards/179.cpp - ${CMAKE_SOURCE_DIR}/src/boards/183.cpp - ${CMAKE_SOURCE_DIR}/src/boards/185.cpp - ${CMAKE_SOURCE_DIR}/src/boards/186.cpp - ${CMAKE_SOURCE_DIR}/src/boards/187.cpp - ${CMAKE_SOURCE_DIR}/src/boards/189.cpp - ${CMAKE_SOURCE_DIR}/src/boards/199.cpp - ${CMAKE_SOURCE_DIR}/src/boards/208.cpp - ${CMAKE_SOURCE_DIR}/src/boards/222.cpp - ${CMAKE_SOURCE_DIR}/src/boards/23.cpp - ${CMAKE_SOURCE_DIR}/src/boards/235.cpp - ${CMAKE_SOURCE_DIR}/src/boards/253.cpp - ${CMAKE_SOURCE_DIR}/src/boards/3d-block.cpp - ${CMAKE_SOURCE_DIR}/src/boards/411120-c.cpp - ${CMAKE_SOURCE_DIR}/src/boards/43.cpp - ${CMAKE_SOURCE_DIR}/src/boards/57.cpp - ${CMAKE_SOURCE_DIR}/src/boards/603-5052.cpp - ${CMAKE_SOURCE_DIR}/src/boards/68.cpp - ${CMAKE_SOURCE_DIR}/src/boards/8157.cpp - ${CMAKE_SOURCE_DIR}/src/boards/8237.cpp - ${CMAKE_SOURCE_DIR}/src/boards/830118C.cpp - ${CMAKE_SOURCE_DIR}/src/boards/88.cpp - ${CMAKE_SOURCE_DIR}/src/boards/90.cpp - ${CMAKE_SOURCE_DIR}/src/boards/95.cpp - ${CMAKE_SOURCE_DIR}/src/boards/__dummy_mapper.cpp - ${CMAKE_SOURCE_DIR}/src/boards/a9711.cpp - ${CMAKE_SOURCE_DIR}/src/boards/a9746.cpp - ${CMAKE_SOURCE_DIR}/src/boards/addrlatch.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ax5705.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bandai.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc13in1jy110.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc42in1r.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc64in1nr.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bmc70in1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bonza.cpp - ${CMAKE_SOURCE_DIR}/src/boards/bs-5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/onebus.cpp - ${CMAKE_SOURCE_DIR}/src/boards/datalatch.cpp - ${CMAKE_SOURCE_DIR}/src/boards/deirom.cpp - ${CMAKE_SOURCE_DIR}/src/boards/dream.cpp - ${CMAKE_SOURCE_DIR}/src/boards/edu2000.cpp - ${CMAKE_SOURCE_DIR}/src/boards/fk23c.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ghostbusters63in1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/gs-2004.cpp - ${CMAKE_SOURCE_DIR}/src/boards/gs-2013.cpp - ${CMAKE_SOURCE_DIR}/src/boards/h2288.cpp - ${CMAKE_SOURCE_DIR}/src/boards/karaoke.cpp - ${CMAKE_SOURCE_DIR}/src/boards/kof97.cpp - ${CMAKE_SOURCE_DIR}/src/boards/vrc5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/ks7032.cpp - ${CMAKE_SOURCE_DIR}/src/boards/malee.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc3.cpp - ${CMAKE_SOURCE_DIR}/src/boards/mmc5.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n-c22m.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n106.cpp - ${CMAKE_SOURCE_DIR}/src/boards/n625092.cpp - ${CMAKE_SOURCE_DIR}/src/boards/novel.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sachen.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sc-127.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sheroes.cpp - ${CMAKE_SOURCE_DIR}/src/boards/sl1632.cpp - ${CMAKE_SOURCE_DIR}/src/boards/smb2j.cpp - ${CMAKE_SOURCE_DIR}/src/boards/subor.cpp - ${CMAKE_SOURCE_DIR}/src/boards/super24.cpp - ${CMAKE_SOURCE_DIR}/src/boards/supervision.cpp - ${CMAKE_SOURCE_DIR}/src/boards/t-227-1.cpp - ${CMAKE_SOURCE_DIR}/src/boards/t-262.cpp - ${CMAKE_SOURCE_DIR}/src/boards/tengen.cpp - ${CMAKE_SOURCE_DIR}/src/boards/tf-1201.cpp - ${CMAKE_SOURCE_DIR}/src/input/arkanoid.cpp - ${CMAKE_SOURCE_DIR}/src/input/bworld.cpp - ${CMAKE_SOURCE_DIR}/src/input/cursor.cpp - ${CMAKE_SOURCE_DIR}/src/input/fkb.cpp - ${CMAKE_SOURCE_DIR}/src/input/ftrainer.cpp - ${CMAKE_SOURCE_DIR}/src/input/hypershot.cpp - ${CMAKE_SOURCE_DIR}/src/input/mahjong.cpp - ${CMAKE_SOURCE_DIR}/src/input/mouse.cpp - ${CMAKE_SOURCE_DIR}/src/input/oekakids.cpp - ${CMAKE_SOURCE_DIR}/src/input/powerpad.cpp - ${CMAKE_SOURCE_DIR}/src/input/quiz.cpp - ${CMAKE_SOURCE_DIR}/src/input/shadow.cpp - ${CMAKE_SOURCE_DIR}/src/input/suborkb.cpp - ${CMAKE_SOURCE_DIR}/src/input/toprider.cpp - ${CMAKE_SOURCE_DIR}/src/input/zapper.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/151.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/16.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/17.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/18.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/193.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/201.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/202.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/203.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/204.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/21.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/212.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/213.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/214.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/215.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/217.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/22.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/225.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/227.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/228.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/229.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/230.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/231.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/232.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/234.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/241.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/242.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/244.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/246.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/24and26.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/25.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/255.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/27.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/32.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/33.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/40.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/41.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/42.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/46.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/50.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/51.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/59.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/6.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/60.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/61.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/62.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/65.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/67.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/69.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/71.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/72.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/73.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/75.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/76.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/77.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/79.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/8.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/80.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/82.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/83.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/85.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/86.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/89.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/91.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/92.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/97.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/99.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/emu2413.c - ${CMAKE_SOURCE_DIR}/src/mappers/mmc2and4.cpp - ${CMAKE_SOURCE_DIR}/src/mappers/simple.cpp - ${CMAKE_SOURCE_DIR}/src/utils/ConvertUTF.c - ${CMAKE_SOURCE_DIR}/src/utils/crc32.cpp - ${CMAKE_SOURCE_DIR}/src/utils/endian.cpp - ${CMAKE_SOURCE_DIR}/src/utils/general.cpp - ${CMAKE_SOURCE_DIR}/src/utils/guid.cpp - ${CMAKE_SOURCE_DIR}/src/utils/md5.cpp - ${CMAKE_SOURCE_DIR}/src/utils/memory.cpp - ${CMAKE_SOURCE_DIR}/src/utils/unzip.cpp - ${CMAKE_SOURCE_DIR}/src/utils/xstring.cpp -) - -set(SRC_DRIVERS_COMMON - ${CMAKE_SOURCE_DIR}/src/drivers/common/args.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/configSys.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/hq2x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/hq3x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scale2x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scale3x.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/scalebit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/vidblit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/common/nes_ntsc.c -) - -set(SRC_DRIVERS_SDL - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/input.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-joystick.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-sound.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-throttle.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-video.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/sdl/unix-netplay.cpp -) - -if(FCEUX_SDL_OPENGL) - set(SRC_DRIVERS_SDL ${SRC_DRIVERS_SDL} ${CMAKE_SOURCE_DIR}/src/drivers/sdl/sdl-opengl.cpp) -endif(FCEUX_SDL_OPENGL) - -set(SRC_DRIVERS_WIN - ${CMAKE_SOURCE_DIR}/src/lua-engine.cpp - ${CMAKE_SOURCE_DIR}/src/lua/src/lapi.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lauxlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lbaselib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lcode.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldblib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldebug.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldo.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ldump.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lfunc.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lgc.c - ${CMAKE_SOURCE_DIR}/src/lua/src/linit.c - ${CMAKE_SOURCE_DIR}/src/lua/src/liolib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/llex.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lmathlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lmem.c - ${CMAKE_SOURCE_DIR}/src/lua/src/loadlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lobject.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lopcodes.c - ${CMAKE_SOURCE_DIR}/src/lua/src/loslib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lparser.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstate.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstring.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lstrlib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltable.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltablib.c - ${CMAKE_SOURCE_DIR}/src/lua/src/ltm.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lundump.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lvm.c - ${CMAKE_SOURCE_DIR}/src/lua/src/lzio.c - ${CMAKE_SOURCE_DIR}/src/lua/src/print.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/archive.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/args.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/aviout.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/cdlogger.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/cheat.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/common.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/config.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/debugger.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/debuggersp.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/directories.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/gui.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/guiconfig.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/help.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/input.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/joystick.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/keyboard.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/log.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/luaconsole.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/main.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/mapinput.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memviewsp.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/memwatch.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/movieoptions.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/monitor.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/netplay.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ntview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/OutputDS.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/palette.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ppuview.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/pref.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ram_search.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/ramwatch.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/replay.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - ${CMAKE_SOURCE_DIR}/src/drivers/win/sound.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/state.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/tasedit.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/taseditproj.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/greenzone.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/bookmark.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/bookmarks.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/inputhistory.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/inputsnapshot.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/playback.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/taseditlib/markers.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/texthook.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/throttle.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/timing.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/tracer.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/video.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/wave.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/window.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/Win32InputBox.cpp - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/adler32.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/compress.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/crc32.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/deflate.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/gzio.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infblock.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infcodes.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inffast.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inflate.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/inftrees.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/infutil.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/trees.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/uncompr.c - ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib/zutil.c - # ${CMAKE_SOURCE_DIR}/src/drivers/res.rc -) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories( ${CMAKE_SOURCE_DIR}/src ) -add_definitions( -DNETWORK ) - -if(WIN32) - set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_WIN}) - include_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib ) - add_definitions( - -DWIN32 - -DFCEUDEF_DEBUGGER - -D_USE_SHARED_MEMORY_ - -DPSS_STYLE=2 - -DNOMINMAX - -D_S9XLUA_H - ) - link_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ) -else(WIN32) - set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL}) - include_directories( ${SDL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) - add_definitions( ${SDL_DEFINITIONS} ${ZLIB_DEFINITIONS} ) - if(FCEUX_SDL_OPENGL) - add_definitions( -DOPENGL ) - include_directories( ${OPENGL_INCLUDE_DIR} ) - endif(FCEUX_SDL_OPENGL) -endif(WIN32) - -if(APPLE) - add_definitions( -DPSS_STYLE=4 ) -else(APPLE) - if(UNIX) - add_definitions( -DPSS_STYLE=1 ) - endif(UNIX) -endif(APPLE) - -if(MINGW) - add_definitions( -DNEED_MINGW_HACKS -D_WIN32_IE=0x0600 ) -endif(MINGW) -if(CMAKE_BUILD_TYPE STREQUAL "debug") - add_definitions( -D_DEBUG ) -endif(CMAKE_BUILD_TYPE STREQUAL "debug") -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wno-write-strings -Wno-sign-compare") -endif(CMAKE_COMPILER_IS_GNUCXX) - -if(FCEUX_FRAMESKIP) - add_definitions( -DFRAMESKIP ) -endif(FCEUX_FRAMESKIP) - -if(NOT FCEUX_FORCE_BE) - if(FCEUX_FORCE_LE) - add_definitions( -DLSB_FIRST ) - else(FCEUX_FORCE_LE) - test_big_endian(SYS_IS_BE) - if(NOT SYS_IS_BE) - add_definitions( -DLSB_FIRST ) - endif(NOT SYS_IS_BE) - endif(FCEUX_FORCE_LE) -endif(NOT FCEUX_FORCE_BE) - -check_function_exists(asprintf HAVE_ASPRINTF) -# HACK: cmake seems to cache HAVE_ASPRINTF and I don't know how to ask it -# to forget--even if your compiler changes. So tell it mingw=>no. -if(HAVE_ASPRINTF AND NOT MINGW) - add_definitions( -DHAVE_ASPRINTF ) -endif(HAVE_ASPRINTF AND NOT MINGW) - -add_executable( ${FCEUX_EXE_NAME} ${SOURCES} ) - -if(WIN32) - add_dependencies( ${FCEUX_EXE_NAME} InstallHelpFile ) - #add_dependencies( ${FCEUX_EXE_NAME} res.o) - #add_custom_command( - # OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/res.o - # COMMAND windres - # ARGS ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc ${CMAKE_CURRENT_BINARY_DIR}/res.o --use-temp-file -D_WIN_IE=0x300 - # MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - #) - set(OUTPUT_RES_RC_O CMakeFiles/${FCEUX_EXE_NAME}.dir/__/__/__/src/drivers/win/res.rc.o) - add_custom_command( - OUTPUT ${OUTPUT_RES_RC_O} - COMMAND windres -o ${OUTPUT_RES_RC_O} ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - DEPENDS ${CMAKE_SOURCE_DIR}/src/drivers/win/res.rc - VERBATIM - ) - add_custom_target( - BuildResourceFileFor${FCEUX_EXE_NAME} - DEPENDS ${OUTPUT_RES_RC_O} - ) - set(DEFINED_BUILD_RESOURCE_FILE TRUE CACHE GLOBAL "This is a hack to get CMake to build the .rc file") - - add_dependencies( ${FCEUX_EXE_NAME} BuildResourceFileFor${FCEUX_EXE_NAME} ) - set_property( - TARGET ${FCEUX_EXE_NAME} - PROPERTY LINK_FLAGS "${OUTPUT_RES_RC_O} -mwindows" - ) - - target_link_libraries( ${FCEUX_EXE_NAME} rpcrt4 comctl32 vfw32 winmm ws2_32 - comdlg32 ole32 gdi32 - dsound dxguid ddraw dinput - ) - if(MINGW) - include_directories(${CMAKE_SOURCE_DIR}/src/drivers/win/lua/include/) - else(MINGW) - target_link_libraries( ${FCEUX_EXE_NAME} htmlhelp) - endif(MINGW) -else(WIN32) - target_link_libraries( ${FCEUX_EXE_NAME} ${SDL_LIBRARY} ${ZLIB_LIBRARIES} ) - if(FCEUX_SDL_OPENGL) - target_link_libraries( ${FCEUX_EXE_NAME} ${OPENGL_gl_LIBRARY} ) - endif(FCEUX_SDL_OPENGL) -endif(WIN32) - - diff --git a/branches/sdl2/attic/cmake-stuff/cmake/native/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/native/CMakeLists.txt deleted file mode 100644 index 9d36cf4b..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/native/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(release) -add_subdirectory(debug) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt deleted file mode 100644 index d21d1f2b..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/native/debug/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -project("fceux: native debug") -set(CMAKE_BUILD_TYPE debug) -set(FCEUX_EXE_NAME fceuxDBG) -include(${CMAKE_SOURCE_DIR}/cmake/native/fceux_native.cmake) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/native/fceux_native.cmake b/branches/sdl2/attic/cmake-stuff/cmake/native/fceux_native.cmake deleted file mode 100644 index 474a4288..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/native/fceux_native.cmake +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/fceux.cmake) diff --git a/branches/sdl2/attic/cmake-stuff/cmake/native/release/CMakeLists.txt b/branches/sdl2/attic/cmake-stuff/cmake/native/release/CMakeLists.txt deleted file mode 100644 index 4f78c90a..00000000 --- a/branches/sdl2/attic/cmake-stuff/cmake/native/release/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -project("fceux: native release") -set(CMAKE_BUILD_TYPE release) -set(FCEUX_EXE_NAME fceuxREL) -include(${CMAKE_SOURCE_DIR}/cmake/native/fceux_native.cmake) diff --git a/branches/sdl2/attic/compile b/branches/sdl2/attic/compile deleted file mode 100644 index 9bb997a6..00000000 --- a/branches/sdl2/attic/compile +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/sh - -# Wrapper for compilers which do not understand `-c -o'. - -# Copyright 1999, 2000 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Usage: -# compile PROGRAM [ARGS]... -# `-o FOO.o' is removed from the args passed to the actual compile. - -prog=$1 -shift - -ofile= -cfile= -args= -while test $# -gt 0; do - case "$1" in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we do something ugly here. - ofile=$2 - shift - case "$ofile" in - *.o | *.obj) - ;; - *) - args="$args -o $ofile" - ofile= - ;; - esac - ;; - *.c) - cfile=$1 - args="$args $1" - ;; - *) - args="$args $1" - ;; - esac - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$prog" $args -fi - -# Name of file we expect compiler to create. -cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir $lockdir > /dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir $lockdir; exit 1" 1 2 15 - -# Run the compile. -"$prog" $args -status=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -fi - -rmdir $lockdir -exit $status diff --git a/branches/sdl2/attic/config.guess b/branches/sdl2/attic/config.guess deleted file mode 100644 index dff9e481..00000000 --- a/branches/sdl2/attic/config.guess +++ /dev/null @@ -1,1317 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-09-04' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner . -# Please send patches to . -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - sparc*:NetBSD:*) - echo `uname -p`-unknown-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - esac ;; - esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; - esac - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in - big) echo mips-unknown-linux-gnu && exit 0 ;; - little) echo mipsel-unknown-linux-gnu && exit 0 ;; - esac - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - ld_supported_targets=`cd /; ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - cat >$dummy.c < -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-pc-linux-gnu\n", argv[1]); -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-pc-linux-gnuaout\n", argv[1]); -#endif - return 0; -} -EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then - UNAME_MACHINE=pc - fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/branches/sdl2/attic/config.sub b/branches/sdl2/attic/config.sub deleted file mode 100644 index 393f13d3..00000000 --- a/branches/sdl2/attic/config.sub +++ /dev/null @@ -1,1411 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-09-07' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ - | mipsisa32 \ - | mn10200 | mn10300 \ - | ns16k | ns32k \ - | openrisc \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | s390 | s390x \ - | sh | sh[34] | sh[34]eb | shbe | shle \ - | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ - | stormy16 | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 \ - | we32k \ - | x86 | xscale \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alphapca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cray2-* | cydra-* \ - | d10v-* | d30v-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | m32r-* \ - | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ - | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | s390-* | s390x-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ - | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i686-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sparclite-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=t3e-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh3eb | sh4eb) - basic_machine=sh-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto*) - os=-nto-qnx - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/branches/sdl2/attic/configure-mingw32 b/branches/sdl2/attic/configure-mingw32 deleted file mode 100644 index faf8fb03..00000000 --- a/branches/sdl2/attic/configure-mingw32 +++ /dev/null @@ -1 +0,0 @@ -CFLAGS="-mno-cygwin" CXXFLAGS="-mno-cygwin" LDFLAGS="-mno-cygwin" ./configure --host=mingw32 \ No newline at end of file diff --git a/branches/sdl2/attic/configure.ac b/branches/sdl2/attic/configure.ac deleted file mode 100644 index a788deae..00000000 --- a/branches/sdl2/attic/configure.ac +++ /dev/null @@ -1,101 +0,0 @@ -AC_INIT([src/fceu.cpp]) - -AC_CANONICAL_HOST -AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([fceu], $FCEU_VERSION) - -AC_PROG_CC -AC_PROG_CPP -AM_PROG_CC_C_O -AC_PROG_CXX -AC_PROG_CXXCPP -AC_PROG_INSTALL - -AC_DEFINE(_GNU_SOURCE) -AC_CHECK_FUNC(asprintf, AC_DEFINE([HAVE_ASPRINTF]), []) -AC_CHECK_FUNC(alloca, AC_DEFINE([HAVE_ALLOCA]), []) - -dnl Check for zlib -AC_CHECK_LIB([z], [zlibVersion],[], AC_MSG_ERROR([*** zlib not found!])) -LIBS="$LIBS -lz" - -AM_CONDITIONAL(WIN32, false) -AM_CONDITIONAL(UNIX, false) -AM_CONDITIONAL(USE_SEXYAL, false) -AM_CONDITIONAL(OPENGL, false) -AM_CONDITIONAL(HAVE_GTK, false) -AC_DEFINE([NETWORK],[1]) - -if expr x"$target" : 'x.*beos' > /dev/null; then -CFLAGS="-no-fpic $CFLAGS" -CPPFLAGS="-no-fpic $CPPFLAGS" -AC_DEFINE([PSS_STYLE],[1]) -elif expr x"$target" : 'x.*mingw' > /dev/null; then -AC_DEFINE([PSS_STYLE],[2]) -AC_DEFINE([WIN32]) -AM_CONDITIONAL(WIN32, true) - -else -AM_CONDITIONAL(UNIX, true) -AC_DEFINE([UNIX]) -AC_DEFINE([PSS_STYLE],[1]) -AC_DEFINE([NETWORK],[1]) - -dnl AC_CHECK_HEADER([sys/soundcard.h], -dnl AM_CONDITIONAL(USE_SEXYAL, true) -dnl AC_DEFINE([USE_SEXYAL]),[]) -fi - -dnl if expr x"$target" : 'x.*darwin' > /dev/null; then -dnl AC_DEFINE([MACOSX]) -dnl fi - -if test x$use_nativewin32 = xno; then - dnl Check for SDL - SDL_VERSION=1.2.0 - AM_PATH_SDL($SDL_VERSION, [:], - AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])) - - AC_LANG_CPLUSPLUS - LIBS="$LIBS $SDL_LIBS" - CFLAGS="-Wall -fomit-frame-pointer $CFLAGS $SDL_CFLAGS" - CPPFLAGS="-Wall -fomit-frame-pointer $CPPFLAGS $SDL_CFLAGS" - - dnl Check for SDL_net for net play - HAS_SDL_NET=no - dnl AC_CHECK_LIB([SDL_net], [SDLNet_Init],[HAS_SDL_NET=yes]) - dnl if test x$HAS_SDL_NET = xyes; then - dnl AC_DEFINE([NETWORK]) - dnl LIBS="$LIBS -lSDL_net" - dnl fi - - AC_ARG_WITH(opengl, - [AC_HELP_STRING([--with-opengl], - [use OpenGL])], - use_opengl=$withval, - use_opengl="no") - - if [[ "$use_opengl" = "yes" ]] ; then - dnl Check for OpenGL - - AC_CHECK_HEADER([GL/gl.h],[AC_DEFINE([OPENGL]) AM_CONDITIONAL(OPENGL, true)], - [ - AC_CHECK_HEADER([OpenGL/gl.h],[AC_DEFINE([OPENGL]) AM_CONDITIONAL(OPENGL, true)],[]) - AC_DEFINE([APPLEOPENGL]) - ]) - fi - AC_DEFINE([SDL],[1]) -fi - - -if expr match "$target_cpu" 'i.86' > /dev/null; then - AC_DEFINE([C80x86]) -fi - -AC_C_BIGENDIAN([], [AC_DEFINE([LSB_FIRST])]) - - -AC_DEFINE(FRAMESKIP) - -dnl Output Makefiles -AC_OUTPUT([Makefile src/Makefile]) diff --git a/branches/sdl2/attic/depcomp b/branches/sdl2/attic/depcomp deleted file mode 100644 index 807b991f..00000000 --- a/branches/sdl2/attic/depcomp +++ /dev/null @@ -1,423 +0,0 @@ -#! /bin/sh - -# depcomp - compile a program generating dependencies as side-effects -# Copyright 1999, 2000 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# 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., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi -# `libtool' can also be set to `yes' or `no'. - -if test -z "$depfile"; then - base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` - dir=`echo "$object" | sed 's,/.*$,/,'` - if test "$dir" = "$object"; then - dir= - fi - # FIXME: should be _deps on DOS. - depfile="$dir.deps/$base" -fi - -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. This file always lives in the current directory. - # Also, the AIX compiler puts `$object:' at the start of each line; - # $object doesn't have directory information. - stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - outname="$stripped.o" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir.libs/$base.d" - "$@" -Wc,-MD - else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - else - tmpdepfile="$tmpdepfile2" - fi - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a space and a tab in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. We will use -o /dev/null later, - # however we can't do the remplacement now because - # `-o $object' might simply not be used - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - -*) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 diff --git a/branches/sdl2/attic/fceu-svga.6 b/branches/sdl2/attic/fceu-svga.6 deleted file mode 100644 index a2f7e503..00000000 --- a/branches/sdl2/attic/fceu-svga.6 +++ /dev/null @@ -1,135 +0,0 @@ -.\" t Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH FCEU-SVGA 6 "March 27, 2003" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -fceu-svga \- An emulator for the original (8-bit) Nintendo game console. -.SH SYNOPSIS -.B fceu-svga -.RI [ options ] -"filename" -.SH DESCRIPTION -.B FCE Ultra -is an emulator for the original (8-bit) Nintendo Entertainment System (NES). -It has a robust color palette rendering engine that is fully customizable, -along with excellent sound and joystick support, and even includes TCP/IP based -network playing for head-to-head gaming with your friends! -.PP -The emulator is available in two versions for Linux (there are also versions -for DOS and Windows): an SDL-based version, and one based on SVGALIB. The two -versions are essentially the same \-\- use the SVGALIB version for the Linux -console, and the SDL version for playing in X. -.SH OPTIONS -These are some of the more frequently used options in FCE Ultra SVGALIB. Run -fceu-svga without any options for a larger list, or see the README for the full -list. -.TP -.BI \-gg -Enable Game Genie emulation support. -.TP -.BI "\-cpalette " -Use the custom palette in . -.TP -.BI "\-soundvol " -Sets the sound volume to the given percentage. -.TP -.BI "\-sound " -Set the sound playback sample rate (0 == off). -.TP -.BI "\-connect " -Connect as a client (player 2) to for TCP/IP network play. -.TP -.BI \-server -Be a host server (player 1) for a TCP/IP network game. -.TP -.BI "\-netport " -Use for TCP/IP network play. -.SH KEYBOARD COMMANDS -.B FCE Ultra -has a number of commands available within the emulator. -It also includes default keyboard bindings when emulating game pads or power pads. -.SS Gamepad Keyboard Bindings -.TS -center box; -cb | cb, c | ci. -NES Gamepad Keyboard -= -Arrows Cursor Arrows -A Left ALT -B Left CTRL -Select TAB -Start ENTER -.TE -.SS Other Commands -.PP -.TP 15 -.BI -Activate cheat interface. -.TP 15 -.BI -Lock virtual console. -.TP 15 -.BI -Unlock virtual console. -.TP 15 -.BI -Save game state into current slot (set using number keys). -.TP 15 -.BI -Restore game state from current slot (set using number keys). -.TP 15 -.BI -Save screen snapshot. -.TP 15 -.BI -Reset NES. -.TP 15 -.BI -Toggle power to NES. -.TP 15 -.BR ", " -Quit -.B FCE Ultra. -.SH NOTES -This program needs permisison to the video hardware, this normally requires -root access. One way to accomplish this is by making -.BI "fceu-svga " suid-root. -An easy way to do this is using the -.BR dpkg-statoverride -command. For example, as root on a -.I Debian -system run: -.PP -.B dpkg-statoverride --update --add root games 04755 /usr/games/fceu-svga -.PP -This will ensure that the setuid bit is preserved across package upgrades. -.SH SEE ALSO -.BR dpkg-statoverride "(8), " fceu-sdl (6) -.TP -.I /usr/share/doc/fceu-doc/readme-linux.txt.gz -The -.B FCE Ultra README -for linux, available from the -.I fceu-doc -Debian package. -.TP -.I http://fceultra.sourceforge.net/ -The -.B FCE Ultra -project homepage. -.SH AUTHOR -This manual page was written by Joe Nahmias , -for the Debian GNU/Linux system (but may be used by others). diff --git a/branches/sdl2/attic/install-sh b/branches/sdl2/attic/install-sh deleted file mode 100644 index 11870f1b..00000000 --- a/branches/sdl2/attic/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - : -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=$mkdirprog - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f "$src" ] || [ -d "$src" ] - then - : - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - : - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - : - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' - ' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - : - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - : - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/branches/sdl2/attic/missing b/branches/sdl2/attic/missing deleted file mode 100644 index 6a37006e..00000000 --- a/branches/sdl2/attic/missing +++ /dev/null @@ -1,336 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# 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., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing 0.4 - GNU automake" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. - You can get \`$1Help2man' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then - # We have makeinfo, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - tar) - shift - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - fi - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/branches/sdl2/attic/mkinstalldirs b/branches/sdl2/attic/mkinstalldirs deleted file mode 100644 index 8ab885ec..00000000 --- a/branches/sdl2/attic/mkinstalldirs +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case "${1}" in - -h | --help | --h* ) # -h for help - echo "${usage}" 1>&2; exit 0 ;; - -m ) # -m PERM arg - shift - test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } - dirmode="${1}" - shift ;; - -- ) shift; break ;; # stop option processing - -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option - * ) break ;; # first non-opt arg - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in -0) exit 0 ;; -esac - -case $dirmode in -'') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi ;; -*) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi ;; -esac - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 3 -# End: -# mkinstalldirs ends here diff --git a/branches/sdl2/attic/readme b/branches/sdl2/attic/readme deleted file mode 100644 index ca3c2e5b..00000000 --- a/branches/sdl2/attic/readme +++ /dev/null @@ -1,32 +0,0 @@ -FCE Ultra was developed with gcc and GNU make in mind. MSVC will probably -compile the Windows source code with a few modifications, but you'll still -need to make a project file. - -Several pre-made makefiles are provided: - Makefile.beos - BeOS(with SDL and SDL_net) - Makefile.unixsdl - UN*X(FreeBSD/Linux/etc, with SDL) - Makefile.linuxvga - Linux(with svgalib) - Makefile.dos - (MS/PC/DR) DOS - Makefile.win - MS Windows 9x/Me/Xp/2000/etc.(with DirectX). - Makefile.macosx - Mac OS X(with SDL) - -If you want to use Makefile.beos or Makefile.unixsdl for a cpu type other -than 80x86, you will need to remove "-DC80x86" from the defines line -and also remove "-DLSB_FIRST" if your target cpu uses MSB first ordering. -You'll also need to remove/change "-mcpu=xxx". - -For the Windows port, I use MINGW32. http://www.mingw.org - -To compile the DOS port, you'll need to download the DJGPP package. -Any version of gcc >=2.95.3 should compile the code without changes, BUT -the DJGPP versions of gcc have some problems: - gcc 2.95.3 sometimes breaks when compiling the code. gcc 3.0.2 seems to - produce bad code for sound.c. So, I recommend using gcc 3.0.4 for - compiling the DOS version. - -Modifying the "-mcpu=i686" string in the makefiles, to optimize more effectively -for your cpu type, is a good idea. - -Always do a "make -f Makefile. clean" before compiling for a -different platform or if you update via cvs and if you have stale object -files lying around. diff --git a/branches/sdl2/debian-crossbuild.sh b/branches/sdl2/debian-crossbuild.sh deleted file mode 100644 index f0623563..00000000 --- a/branches/sdl2/debian-crossbuild.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -if [ -f /usr/bin/i586-mingw32msvc-windres ]; then HOST=i586-mingw32msvc -else HOST=i586-mingw32 -fi -PLATFORM=win32 CC=${HOST}-gcc CXX=${HOST}-g++ WRC=${HOST}-windres WINDRES=${HOST}-windres scons $@ diff --git a/branches/sdl2/documentation/.gitignore b/branches/sdl2/documentation/.gitignore deleted file mode 100644 index 674deb69..00000000 --- a/branches/sdl2/documentation/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# A simulation of Subversion default ignores, generated by reposurgeon. -*.o -*.lo -*.la -*.al -*.libs -*.so -*.so.[0-9]* -*.a -*.pyc -*.pyo -*.rej -*~ -*.#* -.*.swp -.DS_store -# Simulated Subversion default ignores end here diff --git a/branches/sdl2/documentation/TODO-PROJECT b/branches/sdl2/documentation/TODO-PROJECT deleted file mode 100644 index 6354d36d..00000000 --- a/branches/sdl2/documentation/TODO-PROJECT +++ /dev/null @@ -1,61 +0,0 @@ -Items to be completed before 2.0 release - -FASTAPASS / FP_FASTAPASS / Are these archaic? They suck - ?? - -Separate frameskip/pause from EmulationPaused - zeromus - -Make ALL Debugging code conditional - zeromus - -Doxygen integration - DONE - * website integration - -Linux build - soules - * clean-up of input device code - -Windows build - zeromus - * verify rerecording - * verify debugging - * verify avi writing - -Commandline parsing - lukas - * verify in windows - zeromus - -Configfile parsing - lukas - * verify in windows - zeromus - -Do we really need vc7 project? Cah4e3? - zeromus -Source code docs cleaning - zeromus -Homepage docs - zeromus - -What is the proper gnu way to do CREDITS from the homepage? e.g. Marat Fayzullin - General NES information - -Freenode registration - lukas - * homepage update - -Default hotkey philosophy (there are different philosophies from XD and TAS) - ALL - -Netplay - FUTURE STUFF - Move server code into tree - DONE - Ensure netplay compiles - verify netplay - -----done----- - -Investigate OSX build [ http://www.lamer0.com/ ] - zeromus [posted on blog...] - -Move to scons - DONE - -Merge garnet and sf repos - DONE - * Ensure gnome frontend is in repo - DONE - * Move to sourceforge SVN - DONE - ---strategic-- - -Politics: - * aboutbox credits - * AUTHORS - -Release: - * Press Release - ?? - * Homepage updates - - eliminate old news, add new links diff --git a/branches/sdl2/documentation/Videolog.txt b/branches/sdl2/documentation/Videolog.txt deleted file mode 100644 index 15c349b1..00000000 --- a/branches/sdl2/documentation/Videolog.txt +++ /dev/null @@ -1,48 +0,0 @@ -Since SVN revision 931, FCEUX features a new option to create avi files from a recorded movie and it is relatively easy to use if you know the bare basics of mencoder. -Call "scons CREATE_AVI=1" to activate it. You will, however, most likely need mencoder to use it. - -You get the raw video data via stdin and the audio data from a fifo file. Let's say you want the video to be in the best quality available, no matter how long it takes or how big the avi file might get. In order to get the NES's original video resolution and a good sound quality, you might need to set some settings beforehand or just pass them along while calling mencoder. - - -Here's an example: -./fceux \ - --xscale 1 --yscale 1 --special 0 \ - --pal 0 \ - --sound 1 --soundq 1 --soundrate 48000 --mute 1 \ - --nospritelim 1 \ - --no-config 1 \ - --videolog "mencoder - -o myfirstencodedrun.avi \ - -ovc x264 -x264encopts qp=0 \ - -oac pcm \ - -noskip -nocache -mc 0 -aspect 4/3 - NESVSETTINGS" \ - --playmov mymovie.fm2 myROM.nes - -Now let's see what is done and why we did it: -First of all, we started fceux with "./fceux" and gave it some options: - "--xscale" and "--yscale" determine how much bigger the video in comparison to its regular size. It's no point to use anything other than 1 here because you can always see your video on fullscreen or at least scale it, can't you? As a nice addon, it saves time to create the avi file and also saves valuable space on your hard disk. - "--special" would usually do something fancy to your picture when you're playing a ROM, but again, it's mostly pointless to use for an avi. - "--pal 0" lets the game run at ~60Hz. Set this so 1 if you are using a PAL ROM. - "--sound 1" activates sound. - "--soundq 1" activates high quality sound. - "--soundrate 48000" sets the sound rate to 48kHz. - "--mute 1" mutes FCEUX while still passing the sound to mencoder. This way you can capture a movie and still listen to your music without having the NES sounds in the background. - "--nospritelim" deactivates the NES's 8 sprites per scanlines limit. - "--no-config 1" is used not to destroy your settings when creating an avi movie. - "--videolog" calls mencoder: - "-" states that we're getting the video stream from stdin. - "-o" determines the name of the produced avi file. - "-ovc x264" sets the video codec to be x264 and is highly recommended for quality reasons. However, if you using a version of x264 from Sep 28th 2008 or newer, mplayer will not be able to decode this again properly. Until this is fixed this mplayer, you might want to replace "-ovc x264 -x264encopts qp=0" with "-ovc lavc -lavcopts vcodec=ffv1:format=bgr32:coder=1:vstrict=-1". Watch out, though, as this needs *way* more space than x264 does. - "-x264encopts qp=0" tells the x264 codec to use a quantizer of 0, which results in lossless video quality. - "-oac pcm" saves the audio data uncompressed (this might turn out really big). - "-noskip" makes sure that no frame is dropped during capturing. - "-nocache" is responsible for immediate encoding and not using any cache. - "-mc 0" makes sure that the sound does not go out of sync. - "-aspect 4/3" sets the avi's aspect ratio so you can see it in fullscreen and have no borders to the left and right. - "NESVSETTINGS" takes care of proper recognition of the audio and video data from FCEUX. - "&> mencoder.log" lets mencoders log its output into a file called "mencoder.log" in your current working directory. - "--playmov" reads which movie file we want to load (here it's mymovie.fm2). - Lastly, we load our desired ROM (in this case it's "myROM.nes"). - -To go for faster encoding and thus less quality, change "-ovc x264 -x264encopts qp=0" to "-ovc xvid -xvidencopts bitrate=200" and "-oac pcm" to "-oac mp3lame -lameopts mode=3:preset=60" to create a 200 kbps xvid video with 60 kbps of mono mp3 audio. -Good luck! :) diff --git a/branches/sdl2/documentation/cheat.html b/branches/sdl2/documentation/cheat.html deleted file mode 100644 index a0eac597..00000000 --- a/branches/sdl2/documentation/cheat.html +++ /dev/null @@ -1,313 +0,0 @@ - - - FCE Ultra Cheat Guide - - -

FCE Ultra Cheat Guide

-
Last updated November 12, 2003
Valid as of FCE Ultra 0.97.4
-

- Table of Contents: -

-
-

Introduction

-

- FCE Ultra allows cheating by the periodic "patching" of arbitrary addresses - in the 6502's memory space with arbitrary values, as well as read substitution. - "Read substitution" is the method that would be used on a real NES/Famicom, - such as done by the Game Genie and Pro Action Replay. It is required - to support GG and PAR codes, but since it is relatively slow when done - in emulation, it is not the preferred method when a RAM patch will - suffice. Also, in FCE Ultra, read substitution will not work properly with - zero-page addressing modes(instructions that operate on RAM at $0000 through - $00FF). -

-

- The RAM patches are all applied a short time before the emulated - vertical blanking period. This detail shouldn't concern most people, though. - However, this does mean that cheating with games that use - bank-switched RAM may be problematic. Fortunately, such games are not very - common(in relation to the total number of NES and Famicom games). -

-

Cheat Files

-

- Cheats are stored in the "cheats" subdirectory under the base FCE Ultra - directory. The files are in a simple plain-text format. Each line represents - a one-byte memory patch. The format is as follows(text in brackets [] - represents optional parameters): -

-

-

- [S][C][:]Address(hex):Value(hex):[Compare value:]Description -
- Example: - -
040e:05:Infinite super power.
-

-

- A colon(:) near the beginning of the line is used to disable the cheat. - "S" denotes a cheat that is a read-substitute-style cheat(such as with Game - Genie cheats), and a "C" denotes that the cheat has a compare value. -

- -
-

The Windows Interface

-

- All addresses listed in the cheats window are in unsigned - 16-bit hexadecimal format and all values in these windows are in an - unsigned 8-bit decimal format(the range for values is 0 through 255). -

-

- The cheats window contains the list of cheats for the currently loaded game - on the right side. Existing cheats can be selected, edited, and updated - using the "Update" button. -

-

Cheat Search Interface

-

- The cheat search interface consists of several components: a list of - addresses and associated data for a search, several command buttons, - and the search parameters. -

-

- Each entry in the list is in the format of: -

Address:Original Value:Current Value
-

-

- The address is the location in the 6502's address space, the original - value is the value that was stored at this address when the search was - reset, and the current value is the value that is currently stored at - that address. Selecting an item in this list will automatically cause - the "Address" field in the cheat information box on the right side of the - window to be updated with the selected address. -

-

- The "Reset Search" button resets the search process; all valid addresses - are displayed in the cheat list and the data values at those addresses noted. -

-

- The "Do Search" buttons performs a search based on the search parameters - and removes any non-matching addresses from the address list. -

-

- The "Set Original to Current" button sets the remembered original values - to the current values. It is like the "Reset Search" button, but it does - not affect which addresses are shown in the address list. This command is - especially useful when used in conjunction with the "O!=C" search filter. -

-

- The "Unhide Excluded" button shows all addresses that are excluded as a - result of any previous searches. It is like the "Reset Search" button - except that it does not affect the remembered original values. -

-

- The numbers assigned the names "V1" and "V2" have different meanings based - on which filter is selected. A list of the names of the filters and detailed - information on what they do follows("original value" corresponds to the value - remembered for a given addres and "current value" is the value currently - at that address. Also, if a value is not explicitly said to be shown - under a certain condition, then it is obviously excluded.): -

- "O==V1 && C==V2": -

- Show the address if the original value is equal to "V1" AND - the current value is equal to "V2". -
-

-

- "O==V1 && |O-C|==V2": -

- Show the address if the original value is equal to "V1" AND - the difference between the current value and the original - value is equal to "V2". -
-

-

- "|O-C|==V2": -

- Show the address if the difference between the current value - and the original value is equal to "V2". -
-

-

- "O!=C": -

- Show the address if the original value does not equal the - current value. -
-

-

- The following cheat methods/filters automatically perform the function - of the "Set Original to Current" button after "Do Search" is pressed. -

-

- "Value decreased." -

- Show the address if the value has decreased. -
-

-

- "Value increased." -

- Show the address if the value has increased. -
-

- -
-

Examples

-

"Mega Man 3" Windows Example

-

- This example will give Mega Man unlimited energy. - Immediately after entering the Top Man stage, make your way to the - "Add Cheat" window. Push "Reset Search". - Go back to playing and move right until the first enemy appears. Allow - yourself to be hit twice. Each hit does "2" damage, so you've lost 4 energy - bars. Go to the "Add Cheat" window again and select the third filter - ("|O-C|==V2") and enter the value 4 next to "V2". Then push "Do Search". -

-

- Several addresses will appear in the address list. You can try to find - the address you want through trial and error, or you can narrow the results - down further. We will do the latter. -

-

- Go back to playing MM3 and get hit one more time and make your way back - to the "Add Cheat" window. Your damage is now "6". You can probably - see which address that contains your life(it is 00A2). If not, change - V2 to 6 and push "Do Search" again. This should leave only 00A2. -

-

- Select that entry in the address list. Shift your attention to the "Add - Cheat" box to the right. Type in a meaningful name and the desired value(156; - it was the value when you had no damage, so it's safe to assume it's the - maximum value you can use). Push the "Add" button and a new entry will - appear in the cheats list. The cheat has been added. -

-

"Over Horizon" Text Interface Example

-

- This example will give you infinite lives in the NTSC(Japanese) version - of "Over Horizon". -

-

- Start a new game. Notice that when you press "Start" during gameplay, - the number of lives you have left is indicated. With no cheating, you - start with 3 lives(2 lives left). -

-

- Activate the cheat interface immediately after starting a new game. - Select the "New Cheats" menu and "Reset Search". -

-

- I'll assume that the number of lives left shown in the game is the same number - that's stored in RAM. Now, "Do Search". You're going to use the first search - filter. For V1, enter the value 2. For V2, enter the same value. This, - coupled with the fact that you just reset the search, will allow you to search - for a value "absolutely"(as opposed to changes in the value). -

-

- Now, "Show Results". When I did it, I received 11 results: -

-
-	 1) $0000:002:002
-	 2) $001c:002:002
-	 3) $001e:002:002
-	 4) $009d:002:002
-	 5) $00b9:002:002
-	 6) $00e3:002:002
-	 7) $0405:002:002
-	 8) $0406:002:002
-	 9) $0695:002:002
-	10) $07d5:002:002	
-	11) $07f8:002:002
-
-

- You really can't do much yet(unless you want to spend time doing trial - and error cheat additions). Return to the game. -

-

- After losing a life, go back to the cheat interface, to the "New Cheats" - menu, and "Show Results". Here are my results: -

-
-	 1) $0000:002:002
-	 2) $001c:002:002
-	 3) $001e:002:002
-	 4) $009d:002:002
-	 5) $00b9:002:041
-	 6) $00e3:002:002
-	 7) $0405:002:001
-	 8) $0406:002:002
-	 9) $0695:002:002
-	10) $07d5:002:001
-	11) $07f8:002:002
-
-

- Notice that two addresses seem to hold the number of lives($0405 and - $07d5). You can lose another life and go "Show Results" again, and you - should see that $07d5 is the address that holds the number of lives. -

-

- Now that you know the address that holds the number of lives, you can - add a cheat. You can either type in the number from the cheat results list - corresponding to the address you want to add a cheat for, or you can - remember the address and select "Add Cheat" from the "New Cheats" menu. - Do the former. -

-

- Now you will need to enter a name for the cheat. I suggest something short, - but descriptive. "Infinite lives" will work fine. Next, a prompt for - the address will show up. Since you selected an item from the list, you - can press enter to use the associated address($07d5). Next, you will - need to enter a value. It doesn't need to be large(in fact, it probably - shouldn't be; abnormally high numbers can cause some games to misbehave). - I suggest a value of 2. After this, you should get a prompt that looks like - this: -

-
-   Add cheat "Infinite lives" for address $07d5 with value 002?(Y/N)[N]:
-
-

- Answer "Y". You now have infinite lives. -

-
-

Tips

-

- Games store player information in many different ways. For example, - if you have "3" lives in Super Wacky Dodgeball 1989, the game might store - it in memory as 2, 3, or 4, or perhaps a different number all together. - Also, say that you have 69 life points out of 200 in Mole Mashers. The - game might store how many life points you have, or how much damage you have - taken. Relative value searches are very valuable because you probably - don't know the way that the game stores its player data. -

-

- Some games, especially RPGs, deal with individual numbers greater than - 8-bits in size. Most that I've seen seem to store the multiple-byte data - least significant byte(lower byte of number) first in memory, though - conceivably, it could be stored most significant byte first, or the component - bytes of the number could be non-contiguous, though the latter is very unlikely. - For example, say I have 5304 experience points in Boring Quest for the - Overused Plot Device. To split the number into two eight bit decimal numbers, - take 5304 %(modulus) 256. This will give a number that is the lower 8 bits. - Next, take 5304 / 256. The integral component of your answer will be the - upper 8 bits(or the next 8 bits, if the number is or can be larger than 16 - bits) of 5304. Now you will need to search for these numbers. Fortunately, - most(all?) RPGs seem to store large numbers exactly as they are shown in the - game. -

- - diff --git a/branches/sdl2/documentation/faq b/branches/sdl2/documentation/faq deleted file mode 100644 index 69b2914e..00000000 --- a/branches/sdl2/documentation/faq +++ /dev/null @@ -1,67 +0,0 @@ -FCE Ultra General User's FAQ - preliminary version - Last updated on: Friday 13th, 2003 ------------------- - - -Q: Why do some games make a popping sound(Rad Racer 2, Final Fantasy 3)? -A: These games do a very crude drum imitation by causing a large jump in - the output level for a short period of time via the register at $4011. - The analog filters on a real NES and Famicom make it sound rather decent. - I have not completely emulated these filters. Enabling high-quality - sound emulation will also make these pseudo-drums sound better. See - the next question for more information. - -Q: Why do some games' digitized sounds sound too loud? - Why do the drums in Crystalis and other games sound fuzzy? - -A: The NES' digital to analog converter is faulty, in that it does not output - sound linearly. This effect is most noteable when a games messes with - register $4011, which is added with the triangle wave channel and the noise - channel outputs. When $4011 is set to a large value, the volume - of the triangle wave channel and the noise channel drop significantly. More - Importantly, when digitized sounds are being played and the digitized sample - stream is at a high value, less changes will be noticeable. In other words, - the byte sequence "00 01 00" would be much more audible than the sequence - "7e 7f 7e". This non-linearity is only emulated when high-quality sound - emulation is enabled. - -Q: Why doesn't the NSF work(correctly) on FCE Ultra? -A: Some NSF rips are bad. Some read from addresses that are not specified - in the NSF specifications, expecting certain values to be returned. - Others execute undocumented instructions that have no affect on - less-accurate software NSF players, but will cause problems on NSF players - that emulate these instructions. Also, the playback rate specified - in the NSF header is currently ignored, though I haven't encountered - any problems in doing this. - -Q: Why doesn't the game work(correctly) on FCE Ultra? -A: Many factors can make a game not work on FCE Ultra: - - - If the ROM image is in the iNES format(typically files that have - the extension "nes"), its header may be incorrect. This - incorrectness may also be because of garbage in the - header. Certain utilities used to put text in the reserved - bytes of the iNES header, then those reserved bytes were - later assigned functions. FCE Ultra recognizes and - automatically removes(from the ROM image in RAM, not on the - storage medium) SOME header junk. - - If the game has graphical errors while scrolling, chances are - the mirroring is set incorrectly in the header. - - You can try to edit the header with a utility(in the NES - utilities section at http://zophar.net ) or a hex editor. - - - The on-cart hardware the game uses may not be emulated - correctly. - - - Limitations of the ROM image format may prevent a game from - being emulated correctly without special code to recognize that - game. This occurs quite often with many Koei MMC5(iNES mapper 5) - and MMC1(iNES mapper 1) games in the iNES format. FCE Ultra identifies - and emulates some of these games based on the ROM CRC32 value. - - - The ROM image may be encrypted. The author of SMYNES seems to - have done this intentionally to block other emulators from - playing "SMYNES only" games. diff --git a/branches/sdl2/documentation/fceux-net-server.6 b/branches/sdl2/documentation/fceux-net-server.6 deleted file mode 100644 index a3cf7fd2..00000000 --- a/branches/sdl2/documentation/fceux-net-server.6 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" (C) Copyright 2012 Joe Nahmias -.\" -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH FCEUX-NET-SERVER 6 "October 12, 2012" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -fceux-net-server \- FCE Ultra game server -.SH SYNOPSIS -.B fceux-net-server -.RI [ options ] -.SH DESCRIPTION -This manual page documents briefly the -.B fceux-net-server -command. -.PP -\fBfceux-net-server\fP is the game server for multiplayer use of the FCE Ultra -family of NES emulators. This server will first look in -\fI/etc/fceux-server.conf\fP for options. If that file does not exist, it will -use the defaults given here. Any argument given directly will override any -default values. -.SH OPTIONS -These programs follow the usual GNU command line syntax, with long -options starting with two dashes (`-'). -A summary of options is included below. -.TP -.B \-h, \-\-help -Displays a help message. -.TP -.B \-v, \-\-version -Displays the version number and quits. -.TP -.B \-p, \-\-port -Starts server on given port (default = \fI4046\fP). -.TP -.B \-w, \-\-password -Specifies a password for entry. -.TP -.B \-m, \-\-maxclients -Specifies the maximum number of clients allowed to access the -server (default = \fI100\fP). -.TP -.B \-t, \-\-timeout -Specifies the number of seconds before the server times out (default = \fI5\fP). -.TP -.B \-f, \-\-framedivisor -Specifies frame divisor, which controls the number of updates sent to client; -calculated as: 60 / framedivisor = updates per second (default = \fI1\fP). -.TP -.B \-c, \-\-configfile -Loads the given configuration file (default = \fI/etc/fceux\-server.conf\fP). -.SH SEE ALSO -.BR fceux (6), -The -.B FCEUX -project homepage -.RI < http://fceux.com/ >. -.SH AUTHOR -This manual page was written by Joe Nahmias -for the Debian GNU/Linux system (but may be used by others). - diff --git a/branches/sdl2/documentation/fceux.6 b/branches/sdl2/documentation/fceux.6 deleted file mode 100644 index 98c4182c..00000000 --- a/branches/sdl2/documentation/fceux.6 +++ /dev/null @@ -1,353 +0,0 @@ -.\" t Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH FCEUX 6 "June 24, 2012" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -fceux \- An emulator for the original (8-bit) Nintendo / Famicom game console. -.SH SYNOPSIS -.B fceux -.RI [ options ] -"filename" -.SH DESCRIPTION -.B FCEUX -is an emulator for the original (8-bit) Nintendo Entertainment System (NES). -It has a robust color palette rendering engine that is fully customizable, -along with excellent sound and joystick support, and even supports movie -recording and playback. -.SH OPTIONS -.SS Misc. Options -.TP -.B \--no-config {0|1} -Use default config file and do not save to it, when enabled. -.TP -.B \-g {0|1}, \--gamegenie {0|1} -Enable or disable emulated Game Genie. -.TP -.B \--nogui {0|1} -Enable or disable the GTK GUI. -.TP -.B \--loadlua FILE -Loads lua script from filename FILE. -.SS Emulation Options -.TP -.B \--pal {0|1} -Enable or disable PAL mode. -.SS Input Options -.TP -.B \-i DEV, \--inputcfg DEV -Configures input device DEV on startup. -Devices: gamepad powerpad hypershot quizking -.TP -.B \--input{1|2} DEV -Set which input device to emulate for input 1 or 2. -Devices: gamepad zapper powerpad.0 powerpad.1 arkanoid -.TP -.B \--input{3|4} DEV -Set the famicom expansion device to emulate for input 3 or 4. -Devices: quizking hypershot mahjong toprider ftrainer familykeyboard -oekakids arkanoid shadow bworld 4player -.TP -.B \--inputdisplay {0|1} -Enable or disable input display. -.TP -.B \--fourscore {0|1} -Enable or disable fourscore emulation. -.SS Graphics Options -.TP -.B \--newppu {0|1} -Enable or disable the new PPU core. (WARNING: May break savestates) -.TP -.B \--frameskip NUM -Set NUM of frames to skip per emulated frame. -.TP -.B \--clipsides {0|1} -Enable or disable clipping of the leftmost and rightmost 8 columns of -the video output. -.TP -.B \--slstart SCANLINE -Set the first scanline to be rendered. -.TP -.B \--slend SCANLINE -Set the last scanline to be rendered. -.TP -.B \--nospritelim {0|1} -When set to 0, this disables the normal 8 sprites per scanline limitation. -When set to 1, this enables the normal 8 sprites per scanline limitation. -NOTE: Yes, this option is 'backwards'. -.TP -.B \-x XRES, \--xres XRES -Set horizontal resolution for full screen mode. -.TP -.B \-y YRES, \--yres YRES -Set vertical resolution for full screen mode. -.TP -.B \--doublebuf {0|1} -Enable or disable double buffering. -.TP -.B \--autoscale {0|1} -Enable or disable autoscaling in fullscreen. -.TP -.B \--keepratio {0|1} -Keep native NES aspect ratio when autoscaling. -.TP -.B \--{x|y}scale VAL -Multiply width/height by VAL. -(Real numbers > 0 with OpenGL, otherwise integers > 0). -.TP -.B \--{x|y}stretch {0|1} -Stretch to fill surface on x/y axis (OpenGL only). -.TP -.B \-b {8|16|24|32}, \--bpp {8|16|24|32} -Set bits per pixel. -.TP -.B \--opengl {0|1} -Enable or disable OpenGL support. -.TP -.B \--openglip {0|1} -Enable or disable OpenGL linear interpolation. -.TP -.B \-f {0|1}, \--fullscreen {0|1} -Enable or disable full-screen mode. -.TP -.B \--noframe {0|1} -Hide title bar and window decorations. -.TP -.B \--special {1-4} -Use special video scaling filters. -(1 = hq2x 2 = Scale2x 3 = NTSC 2x 4 = hq3x 5 = Scale3x) -.TP -.B \-p FILE, \--palette FILE -Use the custom palette in FILE. -.TP -.B \--ntsccolor {0|1} -Enable or disable NTSC NES colors. -.TP -.B \--tint VAL -Set the NTSC tint. -.TP -.B \--hue VAL -Set the NTSC hue. -.SS Sound Options -.TP -.B \-s {0|1}, \--sound {0|1} -Enable or disable sound. -.TP -.B \--soundrate RATE -Set the sound playback sample rate (0 == off?). -.TP -.B \--soundq {0|1|2} -Set sound quality. (0 = Low 1 = High 2 = Very High) -.TP -.B \--soundbufsize MS -Set sound buffer size to MS milliseconds. -.TP -.B \--volume {0-256} -Sets the sound volume to the given value, where 256 is max volume. -.TP -.B \--trianglevol {0-256} -Sets the sound volume of the triangle wave to the given value, where 256 is max volume. -.TP -.B \--square1vol {0-256} -Sets the sound volume of square wave 1 to the given value, where 256 is max volume. -.TP -.B \--square2vol {0-256} -Sets the sound volume of square wave 2 to the given value, where 256 is max volume. -.TP -.B \--noisevol {0-256} -Sets the sound volume of the noise generator to the given value, where 256 is max volume. -.TP -.B \--lowpass {0|1} -Enables or disables lowpass filtering of the sound. -.TP -.B \--soundrecord FILE -Record sound to file FILE. -.SS Movie Options -.TP -.B \--playmov FILE -Play back a recorded FCM/FM2 movie from filename FILE. -.TP -.B \--pauseframe FRAME -Pause movie playback at frame FRAME. -.TP -.B \--moviemsg {0|1} -Enable or disable movie messages. -.TP -.B \--fcmconvert FILE -Convert fcm movie file FILE to fm2. -.TP -.B \--ripsubs FILE -Convert movie's subtitles to srt. -.TP -.B \--subtitles {0|1} -Enable or disable subtitle display. -.SS Networking Options -.TP -.B \-n SRV, \--net SRV -Connect to server SRV for TCP/IP network play. -.TP -.B \--port PORT -Use TCP/IP port PORT for network play. -.TP -.B \-u NICK, \--user NICK -Set the nickname to use in network play. -.TP -.B \-w PASS, \--pass PASS -Set password to use for connecting to the server. -.TP -.B \-k NETKEY, \--netkey NETKEY -Use string NETKEY to create a unique session for the game loaded. -.TP -.B \--players NUM -Set the number of local players. -.TP -.B \--rp2mic {0|1} -If enabled, replace Port 2 Start with microphone (Famicom). -.TP -.B \--videolog c -Calls mencoder to grab the video and audio streams to encode them. Check the documentation for more on this.? -.TP -.B \--mute {0|1} -Mutes FCEUX while still passing the audio stream to mencoder. -.TP -.SH KEYBOARD COMMANDS -.B FCEUX -has a number of commands available within the emulator. -It also includes default keyboard bindings when emulating game pads or power pads. -.SS Gamepad Keyboard Bindings -.TS -center box; -cb | cb, c | ci. -NES Gamepad Keyboard -= -Up Keypad Up -Down Keypad Down -Left Keypad Left -Right Keypad Right -A F -B D -Select S -Start Enter -.TE -.SS Other Commands -.PP -.TP 15 -.BI -Toggle full-screen mode. -.TP 15 -.BI -Cheat menu (command-line only). -.TP 15 -.BI -Toggle savestate binding to movies. -.TP 15 -.BI -Load LUA script. -.TP 15 -.BI -Toggles background rendering. -.TP 15 -.BI -Save game state into current slot (set using number keys). -.TP 15 -.BI -Restore game state from current slot (set using number keys). -.TP 15 -.BI -Toggle movie subtitles. -.TP 15 -.BI -Reset NES. -.TP 15 -.BI -Save screen snapshot. -.TP 15 -.BI Shift + -Beging recording video. -.TP 15 -.BI Shift + -Load recorded video. -.TP 15 -.BI 0-9 -Select save state slot. -.TP 15 -.BI Page Up/Page Down -Select next/previous state. -.TP 15 -.BI \- -Decrease emulation speed. -.TP 15 -.BI = -Increase emulation speed. -.TP 15 -.BI Tab -Hold for turbo emulation speed. -.TP 15 -.BI Pause -Pause emulation. -.TP 15 -.BI \e -Advance a single frame. -.TP 15 -.BI . -Toggle movie frame counter. -.TP 15 -.BI , -Toggle input display. -.TP 15 -.BI q -Toggle movie read-only. -.TP 15 -.BI ' -Advance a single frame. -.TP 15 -.BI / -Lag counter display. -.TP 15 -.BI Delete -Frame advance lag skip display. -.TP 15 -.BR -Quit -.B FCEUX. -.SS VS Unisystem Commands -.PP -.TP 15 -.BI -Insert coin. -.TP 15 -.BI -Show/Hide dip switches. -.TP 15 -.BI 1-8 -Toggle dip switches (when dip switches are shown). -.SS Famicom Disk System Commands -.PP -.TP 15 -.BI -Select disk and disk side. -.TP 15 -.BI -Eject or insert disk. -.TP -.I http://fceux.com/ -The -.B FCEUX -project homepage. -.SH AUTHOR -This manual page was written by Joe Nahmias , -Lukas Sabota and Alexander Toresson - for the Debian GNU/Linux system -(but may be used by others). diff --git a/branches/sdl2/documentation/fcs.txt b/branches/sdl2/documentation/fcs.txt deleted file mode 100644 index dbaeec53..00000000 --- a/branches/sdl2/documentation/fcs.txt +++ /dev/null @@ -1,153 +0,0 @@ -FCE Ultra Save State Format - Updated: Mar 9, 2003 ---------------------------------------- - -FCE Ultra's save state format is now designed to be as forward and backwards -compatible as possible. This is achieved through the (over)use of chunks. -All multiple-byte variables are stored LSB(least significant byte)-first. -Data types: - - (u)int8 - (un)signed 8 bit variable(also referred to as "byte") - (u)int16 - (un)signed 16 bit variable - (u)int32 - (un)signed 32 bit variable - --- Main File Header: - -The main file header is 16-bytes in length. The first three bytes contain -the string "FCS". The next byte contains the version of FCE Ultra that saved -this save state. This document only applies to version "53"(.53) and higher. -After the version byte, the size of the entire file in bytes(minus the 16 byte -main file header) is stored. The rest of the header is currently unused -and should be nulled out. Example of relevant parts: - - FCS - --- Section Chunks: - -Sections chunk headers are 5-bytes in length. The first byte defines what -section it is, the next four bytes define the total size of the section -(including the section chunk header). - - - -Section definitions: - - 1 - "CPU" - 2 - "CPUC" - 3 - "PPU" - 4 - "CTLR" - 5 - "SND" - 16 - "EXTRA" - --- Subsection Chunks - -Subsection chunks are stored within section chunks. They contain the actual -state data. Each subsection chunk is composed of an 8-byte header and the data. -The header contains a description(a name) and the size of the data contained -in the chunk: - - -The name is a four-byte string. It does not need to be null-terminated. -If the string is less than four bytes in length, the remaining unused bytes -must be null. - --- Subsection Chunk Description Definitions - -Note that not all subsection chunk description definitions listed below -are guaranteed to be in the section chunk. It's just a list of what CAN -be in a section chunk. This especially applies to the "EXTRA" subsection. - ----- Section "CPU" - - Name: Type: Description: - - PC uint16 Program Counter - A uint8 Accumulator - P uint8 Processor status register - X uint8 X register - Y uint8 Y register - S uint8 Stack pointer - RAM uint8[0x800] 2KB work RAM - ----- Section "CPUC" (emulator specific) - - Name: Type: Description: - - JAMM uint8 Non-zero value if CPU in a "jammed" state - IRQL uint8 Non-zero value if IRQs are to be generated constantly - ICoa int32 Temporary cycle counter - ICou int32 Cycle counter - ----- Section "PPU" - - Name: Type: Description: - - NTAR uint8[0x800] 2 KB of name/attribute table RAM - PRAM uint8[32] 32 bytes of palette index RAM - SPRA uint8[0x100] 256 bytes of sprite RAM - PPU uint8[4] Last values written to $2000 and $2001, the PPU - status register, and the last value written to - $2003. - XOFF uint8 Tile X-offset. - VTOG uint8 Toggle used by $2005 and $2006. - RADD uint16 PPU Address Register(address written to/read from - when $2007 is accessed). - TADD uint16 PPU Address Register - VBUF uint8 VRAM Read Buffer - PGEN uint8 PPU "general" latch. See Ki's document. - ----- Section "CTLR" (somewhat emulator specific) - - Name: Type: Description: - - J1RB uint8 Bit to be returned when first joystick is read. - J2RB uint8 Bit to be returned when second joystick is read. - ----- Section "SND" (somewhat emulator specific) - - NREG uint16 Noise LFSR. - P17 uint8 Last byte written to $4017. - PBIN uint8 DMC bit index. - PAIN uint32 DMC address index(from $8000). - PSIN uint32 DMC length counter(how many bytes left - to fetch). - - - ----- Section "EXTRA" (varying emulator specificness) - - For iNES-format games(incomplete, and doesn't apply to every game): - - Name: Type: Description: - - WRAM uint8[0x2000] 8KB of WRAM at $6000-$7fff - MEXR uint8[0x8000] (very emulator specific) - CHRR uint8[0x2000] 8KB of CHR RAM at $0000-$1fff(in PPU address space). - EXNR uint8[0x800] Extra 2KB of name/attribute table RAM. - MPBY uint8[32] (very emulator specific) - MIRR uint8 Current mirroring: - 0 = "Horizontal" - 1 = "Vertical" - $10 = Mirror from $2000 - $11 = Mirror from $2400 - IRQC uint32 Generic IRQ counter - IQL1 uint32 Generic IRQ latch - IQL2 uint32 Generic IRQ latch - IRQA uint8 Generic IRQ on/off register. - PBL uint8[4] List of 4 8KB ROM banks paged in at $8000-$FFFF - CBL uint8[8] List of 8 1KB VROM banks page in at $0000-$1FFF(PPU). - - For FDS games(incomplete): - - Name: Type: Description: - - DDT uint8[65500] Disk data for side x(0-3). - FDSR uint8[0x8000] 32 KB of work RAM - CHRR uint8[0x2000] 8 KB of CHR RAM - IRQC uint32 IRQ counter - IQL1 uint32 IRQ latch - IRQA uint8 IRQ on/off. - - WAVE uint8[64] Carrier waveform data. - MWAV uint8[32] Modulator waveform data. - AMPL uint8[2] Amplitude data. diff --git a/branches/sdl2/documentation/fm2.txt b/branches/sdl2/documentation/fm2.txt deleted file mode 100644 index 37ec4969..00000000 --- a/branches/sdl2/documentation/fm2.txt +++ /dev/null @@ -1,79 +0,0 @@ -FM2 is ascii plain text. -It consists of several key-value pairs followed by an inputlog section. -The inputlog section can be identified by its starting with a | (pipe). -The inputlog section terminates at eof. -Newlines may be \r\n or \n - -Key-value pairs consist of a key identifier, followed by a space separator, followed by the value text. -Value text is always terminated by a newline, which the value text will not include. -The value text is parsed differently depending on the type of the key. -The key-value pairs may be in any order, except that the first key must be version. - -Integer keys (also used for booleans, with a 1 or 0) will have a value that is a simple integer not to exceed 32bits - - version (required) - the version of the movie file format; for now it is always 3 - - emuVersion (required) - the version of the emulator used to produce the movie - - rerecordCount (optional) - the rerecord count - - palFlag (bool) (optional) - true if the movie uses pal timing - - fourscore (bool) (*note C) - true if a fourscore was used - - port0, port1 (*note C) - indicates the types of input devices. Supported values are: - SI_GAMEPAD = 1, - SI_ZAPPER = 2 - - port2 (required) - indicates the type of the FCExp port device which was attached. Supported values are: - SIFC_NONE = 0 - -String keys have values that consist of the remainder of the key-value pair line. As a consequence, string values cannot contain newlines. - - romFilename (required) - the name of the file used to record the movie - - comment (optional) - simply a memo. - by convention, the first token in the comment value is the subject of the comment. - by convention, subsequent comments with the same subject will have their ordering preserved and may be used to approximate multiline comments. - by convention, the author of the movie should be stored in comment(s) with a subject of: author - -Hex string keys (used for binary blobs) will have a value that is like 0x0123456789ABCDEF... - - romChecksum (required) - the MD5 hash of the rom which was used to record the movie - - savestate (optional) - a fcs savestate blob, in case a movie was recorded from savestate - -GUID keys have a value which is in the standard guid format: 452DE2C3-EF43-2FA9-77AC-0677FC51543B - - guid (required) a unique identifier for a movie, generated when the movie is created, which is used when loading a savestate to make sure it belongs to the current movie. - -The inputlog section consists of lines beginning and ending with a | (pipe). -The fields are as follows, except as noted in note C. -|c|port0|port1|port2| - -field c is a variable length decimal integer which is a bitfield corresponding to miscellaneous input states which are valid at the start of the frame. -Current values for this are -MOVIECMD_RESET = 1 - -the format of port0, port1, port2 depends on which types of devices were attached. -SI_GAMEPAD: - the field consists of eight characters which constitute a bitfield. - any character other than ' ' or '.' means that the button was pressed. - by convention, the following mnemonics will be used in a column to remind us of which button corresponds to which column: - RLDUTSBA (Right,Left,Down,Up,sTart,Select,B,A) - This seemingly arbitrary ordering is actually the reverse of the originally-desired order, which was screwed up in the first release of FCEUX. So we have preserved it for compatibility's sake. -SI_ZAPPER: - XXX YYY B Q Z - XXX: %03d, the x position of the mouse - YYY: %03d, the y position of the mouse - B: %1d, 1 if the mouse button is pressed; 0 if not - Q: %1d, an internal value used by the emulator's zapper code (this is most unfortunate..) - Z: %d, a variable-length decimal integer; an internal value used by the emulator's zapper code (this is even more unfortunate..) -SIFC_NONE: - this field must always be empty. - -* Notes * -A. There is no key-value pair that indicates the length of the movie. This must be read by scanning the inputlog and counting the number of lines. - -B. All movies start from power-on, unless a savestate key-value is present. - -C. -If a fourscore is used, then port0 and port1 are irrelevant and ignored. -The input types must all be gamepads, and the inputlog will be in the following format: - {player1 player2 player3 player4} -|c|RLDUTSBA|RLDUTSBA|RLDUTSBA|RLDUTSBA|port2| -If a fourscore is not used, then port0 and port1 are required. - -D. The emulator uses these framerate constants - - NTSC: 1008307711 /256/65536 = 60.099822938442230224609375 - - PAL : 838977920 /256/65536 = 50.00698089599609375 - -E. The author of this format is curious about what people think of it. Please let him know! \ No newline at end of file diff --git a/branches/sdl2/documentation/porting.txt b/branches/sdl2/documentation/porting.txt deleted file mode 100644 index 63d2b4fc..00000000 --- a/branches/sdl2/documentation/porting.txt +++ /dev/null @@ -1,289 +0,0 @@ -FCE Ultra Porting Guide - Updated: October 4, 2003 - -*Incomplete* - - -***Driver-supplied functions: - These functions will only be called after the driver code calls - FCEUI_LoadGame() or FCEUI_Emulate(). - -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); - Called by FCE Ultra on every emulated frame. This function should - perform the following three things(in any order): - - 1. - Update the data pointed to by the pointers passed to - FCEUI_SetInput() and FCEUI_SetInputFC(). - 2. - Copy contents of XBuf over to video memory(or whatever needs to be - done to make the contents of XBuf visible on screen). - Each line is 256 pixels(and bytes) in width, and there can be 240 - lines. The pitch for each line is 272 bytes. - XBuf will be 0 if the symbol FRAMESKIP is defined and this frame - was skipped. - 3. - Write the contents of "Buffer" to the sound device. "Count" is the - number of samples to write. Only the lower 16-bits of each - sample are used, so each 32-bit sample in "Buffer" can be converted to - signed 16-bit by dropping the upper 16 bits. - When sound was disabled for the frame, "Count" will be 0. - -void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b); - Set palette entry "index" to specified RGB values(value: min=0, max=255). - -void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b); - Get palette entry "index" data. - -void FCEUD_PrintError(char *s); - Print/Display an error message string pointed to by "s". - -void FCEUD_Message(char *s); - Display a status message string. - - -int FCEUD_NetworkConnect(void); - Initialize a network connection. Return 0 if an error occurs. - -int FCEUD_GetDataFromClients(uint8 *data); - -/* Sends 5 bytes of data to all clients. */ -int FCEUD_SendDataToClients(uint8 *data); - -/* Sends 1 byte of data to server, and maybe a command. */ -int FCEUD_SendDataToServer(uint8 v, uint8 cmd); - -/* Gets 5 bytes of data from the server. This function must block. */ -int FCEUD_GetDataFromServer(uint8 *data); - -void FCEUD_NetworkClose(void); - Close the network connection. - - -***FCE Ultra functions(called by the driver code): - The FCEUI_* functions may only be called before FCEUI_Emulate() is - called or after it returns and before it is called again, or after the - following functions are called and before they return: - FCEUD_Update(); - Calling the FCEUI_* functions at any other time may result in - undefined behavior. - -void FCEUI_SetInput(int port, int type, void *ptr, int attrib); - "port" can be either 0 or 1, and corresponds to the physical - ports on the front of a NES. - - "type" may be: - SI_NONE - No input on this port. - SI_GAMEPAD - Standard NES gamepad - SI_ZAPPER - "Zapper" light gun. - SI_POWERPAD - Power-pad mat. - SI_ARKANOID - Arkanoid controller. - -void FCEUI_SetInputFC(int type, void *ptr, int attrib); - Special Famicom devices. - "type" may be: - SIFC_NONE - No input here. - SIFC_ARKANOID - Arkanoid controller. - SIFC_SHADOW - "Space Shadow" gun. - SIFC_4PLAYER - Famicom 4-player adapter - SIFC_FKB - Family Keyboard - -void FCEUI_DisableFourScore(int s); - Disables four-score emulation if s is nonzero. - -void FCEUI_SetSnapName(int a); - 0 to order screen snapshots numerically(0.png), 1 to order them file - base-numerically(smb3-0.png). - -void FCEUI_DisableSpriteLimitation(int a); - Disables the 8-sprite-per-scanline limitation of the NES if "a" - is nonzero. The default behavior is the limitation is enabled. - -void FCEUI_SaveExtraDataUnderBase(int a); - If "a" is nonzero, save extra non-volatile game data(battery-backed - RAM) under FCE Ultra's base directory. Otherwise, the behavior is - to save it under the same directory the game is located in(this is - the default behavior). - -FCEUGI *FCEUI_LoadGame(char *name); - Loads a new file. "name" is the full path of the file to load. - Returns 0 on failure, or a pointer to data type "FCEUGI": - See file "git.h" for more details on this structure. - -int FCEUI_Initialize(void); - Allocates and initializes memory. Should only be called once, before - any calls to other FCEU functions. - -void FCEUI_SetBaseDirectory(void); - Specifies the base FCE Ultra directory. This should be called - immediately after FCEUI_Initialize() and any time afterwards. - -void FCEUI_SetDirOverride(int which, char *n); - - FCEUIOD_CHEATS - Cheats - FCEUIOD_MISC - Miscellaneous stuff(custom game palettes) - FCEUIOD_NV - Non-volatile game data(battery backed RAM) - FCEUIOD_SNAPS - Screen snapshots - FCEUIOD_STATE - Save states - -void FCEUI_Emulate(void); - Enters the emulation loop. This loop will be exited when FCEUI_CloseGame() - is called. This function obviously shouldn't be called if FCEUI_LoadGame() - wasn't called or FCEUI_CloseGame() was called after FCEUI_LoadGame(). - -void FCEUI_CloseGame(void); - Closes the loaded game and frees all memory used to load it. - Also causes FCEUI_Emulate() to return. - -void FCEUI_ResetNES(void); -void FCEUI_PowerNES(void); - -void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); - Sets the first(minimum is 0) and last(NOT the last scanline plus one; - maximum is 239) scanlines of background data to draw, for both NTSC - emulation mode and PAL emulation mode. - - Defaults are as if this function were called with the variables set - up as follows: - ntscf=8, ntscl=231, palf=0, pall=239 - -void FCEUI_SetNetworkPlay(int type); - Sets status of network play according to "type". If type is 0, - then network play is disabled. If type is 1, then we are server. - If type is 2, then we are a client. - -void FCEUI_SelectState(int w); - Selects the state "slot" to save to and load from. - -void FCEUI_SaveState(void); - Saves the current virtual NES state from the "slot" selected by - FCEUI_SelectState(). - -void FCEUI_LoadState(void); - Loads the current virtual NES state from the "slot" selected by - FCEUI_SelectState(). - -void FCEUI_SaveSnapshot(void); - Saves a screen snapshot. - -void FCEUI_DispMessage(char *msg); - Displays a short, one-line message using FCE Ultra's built-in - functions and ASCII font data. - -int32 FCEUI_GetDesiredFPS(void); - Returns the desired FPS based on whether NTSC or PAL emulation is - enabled, shifted left by 24 bits(this is necessary because the real - FPS value is not a whole integer). This function should only be - necessary if sound emulation is disabled. - -int FCEUI_GetCurrentVidSystem(int *slstart, int *slend); - Convenience function(not strictly necessary, but reduces excessive code - duplication); returns currently emulated video system - (0=NTSC, 1=PAL). It will also set the variables pointed to by slstart - and slend to the first and last scanlines to be rendered, respectively, - if slstart and slend are not 0. - -void FCEUI_GetNTSCTH(int *tint, int *hue); -void FCEUI_SetNTSCTH(int n, int tint, int hue); - -int FCEUI_AddCheat(char *name, uint16 addr, uint8 val); - Adds a RAM cheat with the specified name to patch the address "addr" - with the value "val". - -int FCEUI_DelCheat(uint32 which); - Deletes the specified(by number) cheat. - -void FCEUI_ListCheats(void (*callb)(char *name, uint16 a, uint8 v)); - Causes FCE Ultra to go through the list of all cheats loaded for - the current game and call callb() for each cheat with the cheat - information. - -int FCEUI_GetCheat(uint32 which, char **name, int32 *a, int32 *v, int *s); - Gets information on the cheat referenced by "which". - -int FCEUI_SetCheat(uint32 which, char *name, int32 a, int32 v, int s); - Sets information for the cheat referenced by "which". - -void FCEUI_CheatSearchBegin(void); - Begins the cheat search process. Current RAM values are copied - to a buffer to later be processed by the other cheat search functions. - -void FCEUI_CheatSearchEnd(int type, int v1, int v2); - Searches the buffer using the search method specified by "type" - and the parameters "v1" and "v2". - -int32 FCEUI_CheatSearchGetCount(void); - Returns the number of matches from the cheat search. - -void FCEUI_CheatSearchGet(void (*callb)(uint16 a, int last, int current)); - -void FCEUI_CheatSearchGetRange(int first, int last, void (*callb)(uint16 a, int last, int current)); - Like FCEUI_CheatSearchGet(), but you can specify the first and last - matches to get. - -void FCEUI_CheatSearchShowExcluded(void); - Undos any exclusions of valid addresses done by FCEUI_CheatSearchEnd(). - -void FCEUI_CheatSearchSetCurrentAsOriginal(void); - Copies the current values in RAM into the cheat search buffer. - -void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v)); - Callback to dump memory. - -void FCEUI_DumpMem(char *fname, uint32 start, uint32 end); - Dump memory to filename fname. - -void FCEUI_MemPoke(uint16 a, uint8 v, int hl); - Write a byte to specified address. Set hl to 1 to attempt to store - it to ROM("high-level" write). - -void FCEUI_NMI(void); - Triggers(queues) an NMI. - -void FCEUI_IRQ(void); - Triggers(queues) an IRQ. - -void FCEUI_Disassemble(uint16 a, int (*callb)(uint16 a, char *s)); - Text disassembly. - -void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi); - Get current interrupt vectors. - - -***Recognized defined symbols: - -The following defined symbols affect the way FCE Ultra is compiled: - - C80x86 - - Include 80x86 inline assembly in AT&T syntax, if available. Also - use special 80x86-specific C constructs if the compiler is compatible. - - FRAMESKIP - - Include frame skipping code. - - NETWORK - - Include network play code. - - FPS - - Compile code that prints out a number when FCE Ultra exits - that represents the average fps. - - ZLIB - - Compile support for compressed PKZIP-style files AND gzip compressed - files. "unzip.c" will need to be compiled and linked in by you if - this is defined(it's in the zlib subdirectory). - - LSB_FIRST - - Compile code to expect that variables that are greater than 8 bits - in size are stored Least Significant Byte First in memory. - - PSS_STYLE x - - Sets the path separator style to the integer 'x'. Valid styles are: - 1: Only "/" - For UNIX platforms. - 2: Both "/" and "\" - For Windows and MSDOS platforms. - 3: Only "\" - For ???. - 4: Only ":" - For Apple IIs ^_^. - - - - diff --git a/branches/sdl2/documentation/protocol.txt b/branches/sdl2/documentation/protocol.txt deleted file mode 100644 index 0122e498..00000000 --- a/branches/sdl2/documentation/protocol.txt +++ /dev/null @@ -1,90 +0,0 @@ -FCE Ultra 0.91+ network play protocol. -Description v 0.0.1 --------------------------------------- - -In FCE Ultra, all data is sent to the server, and then the server -distributes, every emulated frame(60hz on NTSC), the collated data to the -clients. - -The server should not block when it is receiving UDP data from the clients. -If no UDP data is available, then just go on. - -The clients MUST block until the input data packet comes on every emulated -frame. - -Packets from the server to the client are sent out over both TCP and UDP. -Duplicate packets should be discarded. Out-of-order packets can either -be cached, or discarded(what I recommend, as caching code gets a little -complex and wouldn't yield any benefit from what I've observed). -In the case of client->server UDP communications, the server should just use -the data from the UDP packet that has the highest packet number count, and -the server should then set its internal incoming packet counter to that -number(to prevent out-of-order packets from totally screwing up user input). - -The "magic number"(used with UDP packets) is meant to reduce the chance of a hostile remote host -from disrupting the network play, without resorting to using extreme amounts -of network bandwidth. The server generates the magic number, and it is best -if the magic number is as random as possible. -UDP packets received with an incorrect magic number should be discarded, of -course. - -Initialization, server->client: - -uint32 Local UDP port(what the server is listening on). -uint32 Player number(0-3) for client. -uint32 Magic number(for UDP). - - -Initialization, client->server - -uint32 Local UDP port(that the client is listening on). - - -Structure of UDP packet data: - -uint32 CRC32 - Includes magic number, packet counter, and - data. For reference, CRC32 is calculated - with the zlib function crc32(). -uint32 Magic number -uint32 Packet counter(linear, starts at 0). -uint8[variable] Data. - -Structure of tcp packet data: - -uint32 Packet counter(" "). -uint8[variable] Data. - - - -Data format of server->client communications: - - uint8[4] Controller data - uint8 Command byte. 0 if no command. Otherwise(in decimal): - - 1 Select FDS disk side. - 2 Insert/eject FDS disk. - 10 Toggle VS Unisystem dip switch editing. - 11 ... 18 Toggle VS Unisystem dip switches. - 19 Insert VS Unisystem coin. - 30 Reset NES. - 31 Power toggle NES. - 40 Save state(not implemented correctly). - 41 Load state(not implemented correctly). - 42 ... 50 Select save state slot(minus 42). - - Special message communications occurs if the "Packet counter" is - 0xFFFFFFFF(only with TCP): - - uint32 Length of text data, minus the null character(the null - character is sent, though). - uint8[variable] Text data. Convert all characters <32 to space, and - then display the text message(it's one line) as is. - -Structure of client->server communication: - - uint8 Controller data(for this client). - - Over tcp channel, a text message can be sent. It is one line, - null terminated(remember the data and parse it and display it and - distribute it to the clients once the null byte is received). - Maximum size of message(including the null byte) should be 256 bytes. diff --git a/branches/sdl2/documentation/snes9x-lua.html b/branches/sdl2/documentation/snes9x-lua.html deleted file mode 100644 index 13ab2bb5..00000000 --- a/branches/sdl2/documentation/snes9x-lua.html +++ /dev/null @@ -1,417 +0,0 @@ - -Snes9x Lua Library -This is the API from DeHackEd's version of Lua in ZSnes. At the time of writing, FCUE's Lua was based on this API.

- -

Basics

-Your code will be run alongside the emulator's main loop. You code should -probably look roughly like this: -
-
-- initialization goes here
-while condition do
-   -- Code executed once per frame
- 
-   snes9x.frameadvance()
-
-
-end
-
--- Cleanup goes here
-

- -When Lua execution starts, the emulator will be automatically unpaused if it -is currently paused. If so, it will automatically be paused when the script -exits, voluntarily or otherwise. This allows you to have a script execute -some work on your behalf and then when it exits the emulator will be paused, -ready for the player to continue use. - -
-

Base library

-Handy little things that are not put into a class. Mostly binary operations right now. -
- -
int AND(int arg1, int arg2, ..., int argn)
-Since Lua lacks binary operators and since binary will come up with memory manipulation, -I offer this function. Output is the binary AND of all its parameters together. -Minimum 1 argument, all integers. -

-At a binary level, the AND of two binary bits is 1 if both inputs are 1, and the output -is 0 in any other case. Commonly used to test if a bit is set by ANDing with a number -with only the desired position set to 1. -


- -
int OR(int arg1, int arg2, ..., int argn)
-The OR of two bits is 1 if either of the inputs is 1, and 0 if both inputs are 0. -Typically used to force a single bit to 1, regardless of its current state. -
- -
int XOR(int arg1, int arg2, ..., int argn)
-XOR flips bits. An even number of 1s yields a zero and an odd number of 1s yields a 1. -Commonly used to toggle a bit by XORing. -
- -
int BIT(int which)
-Returns a number with only the given bit set. which is in the range from 0 to 15 since the -SNES is a 16 bit system. BIT(15) == 32768 -

-... Actually this system will accept a range of 0 to 30, but none of the memory access functions will -accept it, so you're on your own for those. 31 is not allowed for now due to signedness risking wreaking havoc. -

snes9x

- -Basic master emulator control. -
- -
snes9x.speedmode(string mode)
-Selects the speed mode snes9x should run at while Lua is in control of frame advance. It must be set to one of the following: - -In modes other than normal, pause will have no effect. - -
- -
snes9x.frameadvance()
-Snes9x executes one frame. This function pauses until the execution finishes. General system slowdown -when running at normal speed (ie. sleeping for 1/60 seconds) also occurs here when not in high speed mode. -

-Warning: Due to the way the code is written, the times this function may be called is restricted. Norably, -it must not be called within a coroutine or under a [x]pcall(). You can use coroutines for -your own purposes, but they must not call this function themselves. Furthermore, this function cannot be called from any -"registered" callback function. An error will occur if you do. -

-


- -
snes9x.message(string msg)
-Displays the indicated string on the user's screen. snes9x.speedmode("normal") is probably the only way this is of any use, -lest the message not be displayed at all -
- -
snes9x.pause()
-v0.05+ only
-Pauses the emulator. This function blocks until the user unpauses. -

-This function is allowed to be called from outside a frame boundary (ie. when it is not allowed to call -snes9x.frameadvance). In this case, the function does not wait for the pause because you can't pause -midway through a frame. Your code will continue to execute and the emulator will be paused at the end -of the current frame. If you are at a frame boundary, this function acts a lot like snes9x.frameadvance() -plus the whole pause thing. -

-It might be smart to reset the speed mode to "normal" if it is not already so. -


- -
snes9x.wait()
-v0.06+ only
-Skips emulation of the next frame. If your script needs to wait for something to happen before proceeding (eg. -input from another application) then you should call this. Otherwise the GUI might jam up and your -application will not appear to be responding and need termination. It is expected that this function -will pause the script for 1/60 of a second without actually running the emulator itself, though it tends to be -OS-dependent right now. -

-If you're not sufficiently confused yet, think of this as pausing for one frame. -

-If you need to do a large amount of calculations -- so much that you risk setting off the rampant script -warning, just call this function every once in a while. -

-Might want to avoid using this if you don't need to. If the emulator is running at normal speed, paused -and the user presses frame-advance, they might be confused when nothing happens. -

-

memory

- -Memory access and manipulation. - -
int memory.readbyte(int address)
-int memory.readword(int address)
-Reads a number of bits (8 or 16) and returns the memory contents. The address must be a fully qualified -memory address. The RAM range is 0x7e0000 through 0x7fffff, but you may use any memory address, including -the ROM data itself. -
-
int memory.readbytesigned(int address)
-int memory.readwordsigned(int address)
v0.04+ only
- -Same as its counterparts, except numbers will be treated as signed. Numbers larger than 127 for bytes and -32767 for words will be translated into the correct negative numbers. For reference, an alternate formula -is to subtract 256 for bytes and 65536 for words from any number equal to or larger than half that number. -For example, a byte at 250 becomes 250-256 = -6. -

- -
memory.writebyte(int address, int value)
-memory.writebyte(int address, int value)
- -Writes a number of bits (8 or 16) to the indicated memory address. The address MUST be in the range of -0x7e0000 through 0x7fffff. - -
-
memory.register(int address, function func)
-When the given memory address is written to (range must be 0x7e0000 to 0x7fffff), the given function will be -called. The execution of the CPU will be paused mid-frame to call the given function. -

-Only one function can be registered with a memory address. 16 bit writes will only trigger the lower address -listener. There is no distinction between 8 and 16 bit writes. func may be nil in order to -delete a function from listening. -

-Code called may not call snes9x.frameadvance() or any savestate save/load functions, and any button -manipulation results are undefined. Those actions are only meaningful at frame boundaries. - - -

-

joypad

- -Access to the gamepads. Note that Lua makes some joysticks do strange things. -Setting joypad inputs causes the user input for that frame to be ignored, but -only for that one frame. -

-Joypads are numbered 1 to 5. -

-Joypad buttons are selected by use of a table with special keys. The table -has keys start, select, up, down, left, right, A, B, X, Y, L, R. Note the -case is sensetive. Buttons that are pressed are set to a non-nil value -(use of the integer 1 is just a convention). Note that "false" is valid, -but discouraged as testing for logical true will fail. -

-Currently reading input from a movie file is not possible, but -a movie will record button presses from Lua. -

table joypad.read(int which)
-Returns a table indicating which buttons are pressed by the user. -This is probably the only way to get input to the script by the user. -This is always user input, even if the joypads have been set by joypad.set. -
-
joypad.set(int which, table buttons)
-Sets the buttons to be pressed. These choices will be made in place of -what the user is pressing during the next frame advance; they are then -discarded, so this must be called once every frame, even if you just want to -keep the same buttons pressed for several frames. - -

-

savestate

-Control over the savestate process. Savestate objects are opaque structures -that represent non-player accessible states (except for the functions that -return "official" savesates). Such an object is garbage collectable, in which -case the savestate is no longer usable. Recycling of existing savestate objects -is highly recommended for disk space concerns lest the garbage collector -grow lazy.

-Each object is basically a savestate file. Anonymous savestates are saved to -your temp directory. - -


-
object savestate.create(int userslot=nil)
-Creates a savestate object for use. If the userslot argument -is given, the state will be accessible via the associated -F-key (F1 through F12 are 1 through 12). If not specified or -nil, an anonymous savestate is created that only Lua can access. -

-Each call to savestate.create() (without parameters) returns -a unique savestate. As such, if you discard the contents of a variable -containing an important savestate, you've just shot yourself in the foot. -

-An object may be used freely once created, saved over and loaded whenever. -

-It is an error to load an anonymous (non-player accessbile) state that -has not been saved yet, since it's empty. -

-Each savestate uses about 120 KB of disk space and the random filename generator -has its limits with regards to how many filenames it can generate. Don't go too -overboard. If you need more than 1000 savestates, maybe you should rethink -your tehcnique. (The actual windows limit is about 32768, Linux is higher). -


savestate.save(object state)
-Saves the current state to the given object. Causes an error if something goes horribly -wrong, or if called within any "registered" callback function. -
savestate.load(object state)
-Loads the given state. Throws an error for all the same bad things that might happen. - -
-
function savestate.registersave(function save)
-v0.06+ only
-Registers a function to be called on a savestate event. This includes both calls to -savestate.save() and users pressing buttons. The function will be called without -parameters. -

-The function called is permitted to return any number of string and number values. -Lua lets you do this by simply writing return 1, 2, 3, "four and five", 6.2, integerVar -

-These variables must be numeric or string. They will be saved into the savestate itself -and returned back to the application via savestate.registerload() should the state ever be loaded -again later. -

-Only one function can be registered. Registering a second function will cause the first function -to be returned back by savestate.registersave() before being discarded. -

-Savestates created with this mechanism are likely to break some savestate features in other emulators. -Don't be surprised if savestates from this version don't work on others if you enable all those -fancy features. Compatible savestates are created if there is no registered save function, or if -the save function returns no parameters at all. -


-
function savestate.registerload(function load)
-v0.06+ only
-The companion to savestate.registersave, this function registers a function to be called during -a load. The function will be passed parameters -- exactly those returned by the function -registered for a save. If the savestate contains no saved data for your script, the function -will be called without parameters. -

-Concept code: - -

function saveState() .... end
-function loadState(arg1, arg2, ...)  ... end
-
-savestate.registersave(saveState)
-savestate.registerload(loadState)
-
-
--- Behind the scenes
-local saved_variables 
-
-
-
--- User presses savestate
-saved_variables = { saveState() } -- All return values saved
-
-
--- Time passes
--- ...
-
-
--- User presses loadstate
-loadState(unpack(saved_variables))
-
-
-

Recommendations for registered savestates

- -

-

movie

-Access to movie information. -
-

-
int movie.framecount()
-Returns the current frame count, or nil if no movie is running. -
-
string movie.mode()
-Returns "record", "playback", or nil, depending on the current movie. -
-
movie.rerecordcounting(boolean counting)
-Select whether rerecording should be counted. If set to false, you can do -all the brute force work you want without inflating the rerecord count. -

-This will automatically be set to true after a script finishes running, so -don't worry about messing up the rerecord count for the player. -


-
movie.stop()
-Stops movie recording/playback. I'm not sure why you'd want to do that, but you can. -
- -

gui

-0.03+ only
-The ability to draw on the surface of the screen is a long sought feature. The surface is 256x239 pixels -(256x224 most of the time though) with (0,0) being in the top-left corner of the screen. -

-The SNES uses a 16 bit colour system. Red and blue both use 5 bits (0 through 31) while green uses -6 bits (0 through 63), in place of the usual 0 to 255 range. If you want to construct your own exact colours, -multiply your red value by 2048, your green value by 32 and leave your blue value untouched. Add these all -together to get a valid colour. Bright red would be 31*2048 = 63488, for example. -

-Some strings are accepted. HTML style encoding such as "#00ff00" for green is accepted. Some simple strings such -as "red", "green", "blue", "white" and "black" are also accepted. -

-The transparent colour is 1 (a VERY dark blue, which is probably not worth using in place of black) or the string -"clear". Remove drawn elements using this colour. -

-Output is delayed by a frame. The graphics are drawn on a separate buffer and then overlayed on the image -during the next refresh, which means allowing for a frame to execute. Also, the buffer is cleared after drawing, -so if you want to keep something on screen, you must keep drawing it on each frame. -

-It is an error to draw outside the drawing area. gdoverlay is the only exception to this rule - images will -be clipped to the visible area. -


-
r,g,b = gui.getpixel(int x, int y)
-Returns the pixel on the indicated coordinate. (0,0) is the top-left corner and (255, 223) is the typical bottom-right corner, -though (255,238) is allowed. The return value range is (0,0,0) to (31,63,31). You get the actual screen surface before -any damage is done by your drawing. Well, unless you call snes9x.wait() in which case your damage is applied and the SNES -hardware doesn't get a chance to draw a new frame. :) -
-
gui.drawpixel(int x, int y, type colour)
-Draw a single pixel on the screen. -
-
gui.drawline(int x1, int y1, int x2, int y2, type colour)
-Draw a line between the two indicated positions. -
-
gui.drawbox(int x1, int y1, int x2, int y2, type colour)
-Draw a box going through the indicated opposite corners. -
-
gui.text(int x, int y, string message)
-Write text on the screen at the indicated position. -

-The coordinates determine the top-left corner of the box that the text fits in. -The font is the same one as the snes9x messages, and you can't control colours or anything. :( -

-The minimum y value is 9 for the font's height and each letter will take around 8 pixels of width. -Text that exceeds the viewing area will be cut short, so ensuring your text will fit would be wise. - -


-
string gui.gdscreenshot()
-0.04+ only
-Takes a screen shot of the image and returns it in the form of a string which can be imported by -the
gd library using the gd.createFromGdStr() function. -

-This function is provided so as to allow snes9x to not carry a copy of the gd library itself. If you -want raw RGB32 access, skip the first 11 bytes (header) and then read pixels as Alpha (always 0), Red, -Green, Blue, left to right then top to bottom, range is 0-255 for all colours. -

-Warning: Storing screen shots in memory is not recommended. Memory usage will blow up pretty quick. -One screen shot string eats around 230 KB of RAM. - -


-
gui.gdoverlay(int x=0, int y=0, string gdimage)
-0.04+ only
-Overlays the given image on top of the screen with the top-left corner in the given screen location. -Transparency is not fully supported -- a pixel must be 100% transparent to actually leave -a hole in the overlayed image or else it will be treated as opaque.

-Naturally, the format for input is the gd file format, version 1. The image MUST be truecolour. - -

-The image will be clipped to fit into the screen area. -


-
gui.transparency(int strength)
-0.04+ only
-Transparency mode. A value of 0 means opaque; a value of 4 means invisible (useful option that one). -As for 1 through 3, I'll let you figure those out.

-All image drawing (including gui.gdoverlay) will have the given transparency level applied from that point -on. Note that drawing on the same point over and over will NOT build up to a higher opacity level. -


-
function gui.register(function func)
-0.04+ only
-Register a function to be called between a frame being prepared for displaying on your screen and -it actually happening. Used when that 1 frame delay for rendering is a pain in the butt. -

This function is not necessarily complicated to use, but it's not recommended to users -new to the whole scripting thing. -

-You may pass nil as the parameter to kill off a registered function. The old function (if any) will be -returned. -


-
string function gui.popup(string message, [string type = "ok"])
-v0.05+ only
-Pops up a dialog to the user with a message, and returns after the user acknowledges the dialog. -type may be any of "ok", "yesno", "yesnocancel". The return value will be "yes", "no" or "cancel" -as the case may be. "ok" is a waste of effort. -

-Linux users might want to install xmessage to perform the work. Otherwise the dialog will -appear on the shell and that's less noticable. -

\ No newline at end of file diff --git a/branches/sdl2/documentation/tech/cpu/4017.txt b/branches/sdl2/documentation/tech/cpu/4017.txt deleted file mode 100644 index 25cb8393..00000000 --- a/branches/sdl2/documentation/tech/cpu/4017.txt +++ /dev/null @@ -1,97 +0,0 @@ -This is an email posted to nesdev by Ki a while back. I have removed one -line at the end regarding the B flag of the cpu(the information was -incorrect, which Ki noted in a later email). - --------------------------------------------------------------------------------- - - By reading Brad's NESSOUND document, we know that there is a -"frame counter" in the NES/FC APU. I would like to post -some more on this. - - The frame counter is reset upon any write to $4017. It is -reset at system power-on as well, but is NOT reset upon -system reset. - - Thanks to Samus Aran, we now know the exact period of the -PPU's single frame. In another words, we are now sure that -the NMI occurs on every 29780 2/3 CPU cycles. - - However, the APU's single frame is NOT 29780 2/3 CPU cycles. -What I mean by "APU's single frame" here is that it is the -number of CPU cycles taken between the frame IRQs. - - The APU's single frame seems to be: - - 1789772.727... / 60 = 29829 6/11 [CPU CYCLE] - - Below is a simple diagram which shows the difference -in periods of the PPU's single frame and the APU's. - - - RESET 29780 2/3 CPU CYCLES NMI -PPU |------------------------------------------| - | 29829 6/11 CPU CYCLES IRQ -APU |----------|----------|----------|----------| - - - Note that if you write $00 to $4017 on every NMI, the frame -IRQ would NEVER go off even if it is enabled. This is because -the the period of NMI is slightly shorter than the period of -the frame IRQ. This causes the frame counter to be reset -before the frame IRQ goes off. - -When you write zero to bit 7 of $4017, the frame counter will -be reset, and the first sound update will be done after 7457 CPU -cycles (i.e. 29829/4). 2nd update will be done 7457 after that, -same goes for 3rd update and 4th update, but the frame IRQ occurs -on 4th update, resetting the frame counter as well. - -When you write 1 to bit 7 of $4017, the frame counter will be -reset, but the first sound update will occur at the same time. -2nd, 3rd, and 4th update will be done after 7457, 14914, 22371 -CPU cycles after the first update respectively, but the 5th -update will be 14914 cycles after the 4th update. This causes -sound output to last 1.25 times longer than that of bit 7 = 0. - - -$4017W: - -o when the MSB of $4017 is 0: - -bit7=0 - |---------|---------|---------|---------|---------|---------|---- - 1st 2nd 3rd 4th 5th(1st) 6th(2nd) - - -o when the MSB of $4017 is 1: - -bit7=1 - |---------|---------|---------|-------------------|---------|---- - 1st 2nd 3rd 4th 5th(1st) 6th(2nd) - - -On 1st, 3rd, 5th, ... updates, the envelope decay and the -linear counter are updated. - -On 2nd, 4th, 6th, ... updates, the envelope decay, the -linear counter, the length counter, and the frequency sweep -are updated. ----- - - The original info was provided by goroh, and verified by me. -However, it could still be wrong. Please tell me if you -find anything wrong. ----- - -(Correction from my last posting) - - I have checked once again and it turned out that the frame IRQ -was NOT disabled upon system reset. What actually prevented the -frame IRQ to occur after system reset was, in fact, the I flag. -I checked this flag shortly after system reset (right after stack -pointer was initialized), and the flag was 1, although I never -executed "sei" after reset. Therefore the I flag of the PR2A03G -is 1 on system reset. - - Thanks Matthew Conte and Samus Aran for pointing out the -inaccuracy. diff --git a/branches/sdl2/documentation/tech/cpu/dmc.txt b/branches/sdl2/documentation/tech/cpu/dmc.txt deleted file mode 100644 index c33f4de8..00000000 --- a/branches/sdl2/documentation/tech/cpu/dmc.txt +++ /dev/null @@ -1,235 +0,0 @@ -Delta modulation channel tutorial 1.0 -Written by Brad Taylor - -Last updated: August 20th, 2000. - -All results were obtained by studying prior information available (from -nestech 1.00, and postings on NESDev from miscellanious people), and through -a series of experiments conducted by me. Results aquired by individuals -prior to my reverse-engineering have been double checked, and final results -have been confirmed. Credit is due to those individual(s) who contributed -any information in regards to the DMC. - -Description ------------ - -The delta modulation channel (DMC) is a complex digital network of counters -and registers used to produce analog sound. It's primary function is to play -"samples" from memory, and have an internal counter connected to a digital -to analog converter (DAC) updated accordingly. The channel is able to be -assigned a pointer to a chunk of memory to be played. At timed intervals, -the DMC will halt the 2A03 (NES's CPU) for 1 clock cycle to retrieve the -sample to pe played. This method of playback will be refered to here on as -direct memory access (DMA). Another method of playback known as pulse code -modulation (PCM) is available by the channel, which requires the constant -updating of one of the DMC's memory-mapped registers. - -Registers ---------- - -The DMC has 5 registers assigned to it. They are as follows: - -$4010: play mode and DMA frequency -$4011: delta counter -$4012: play code's starting address -$4013: length of play code -$4015: DMC/IRQ status - -Note that $4015 is the only R/W register. All others are write only (attempt -to read them will most likely result in a returned 040H, due to heavy -capacitance on the NES's data bus). - -$4010 - Play mode and DMA frequency ------------------------------------ -This register is used to control the frequency of the DMA fetches, and to -control the playback mode. - -Bits ----- -6-7 this is the playback mode. - - 00 - play DMC sample until length counter reaches 0 (see $4013) - x1 - loop the DMC sample (x = immaterial) - 10 - play DMC sample until length counter reaches 0, then generate a CPU -IRQ - -Looping (playback mode "x1") will have the chunk of memory played over and -over, until the channel is disabled (via $4015). In this case, after the -length counter reaches 0, it will be reloaded with the calculated length -value of $4013. - -If playback mode "10" is chosen, an interrupt will be dispached when the -length counter reaches 0 (after the sample is done playing). There are 2 -ways to acknowledge the DMC's interrupt request upon recieving it. The first -is a write to this register ($4010), with the MSB (bit 7) cleared (0). The -second is any write to $4015 (see the $4015 register description for more -details). - -If playback mode "00" is chosen, the sample plays until the length counter -reaches 0. No interrupt is generated. - -5-4 appear to be unused - -3-0 this is the DMC frequency control. Valid values are from 0 - F. The -value of this register determines how many CPU clocks to wait before the DMA -will fetch another byte from memory. The # of clocks to wait -1 is initially -loaded into an internal 12-bit down counter. The down counter is then -decremented at the frequency of the CPU (1.79MHz). The channel fetches the -next DMC sample byte when the count reaches 0, and then reloads the count. -This process repeats until the channel is disabled by $4015, or when the -length counter has reached 0 (if not in the looping playback mode). The -exact number of CPU clock cycles is as follows: - -value CPU -written clocks octave scale -------- ------ ------ ----- -F 1B0 8 C -E 240 7 G -D 2A0 7 E -C 350 7 C -B 400 6 A -A 470 6 G -9 500 6 F -8 5F0 6 D -7 6B0 6 C -6 710 5 B -5 7F0 5 A -4 8F0 5 G -3 A00 5 F -2 AA0 5 E -1 BE0 5 D -0 D60 5 C - -The octave and scale values shown represent the DMC DMA clock cycle rate -equivelant. These values are merely shown for the music enthusiast -programmer, who is more familiar with notes than clock cycles. - -Every fetched byte is loaded into a internal 8-bit shift register. The shift -register is then clocked at 8x the DMA frequency (which means that the CPU -clock count would be 1/8th that of the DMA clock count), or shifted at +3 -the octave of the DMA (same scale). The data shifted out of the register is -in serial form, and the least significant bit (LSB, or bit 0) of the fetched -byte is the first one to be shifted out (then bit 1, bit 2, etc.). - -The bits shifted out are then fed to the UP/DOWN control pin of the internal -delta counter, which will effectively have the counter increment it's -retained value by one on "1" bit samples, and decrement it's value by one on -"0" bit samples. This counter is clocked at the same frequency of the shift -register's. - -The counter is only 6 bits in size, and has it's 6 outputs tied to the 6 MSB -inputs of a 7 bit DAC. The analog output of the DAC is then what you hear -being played by the DMC. - -Wrap around counting is not allowed on this counter. Instead, a "clipping" -behaviour is exhibited. If the internal value of the counter has reached 0, -and the next bit sample is a 0 (instructing a decrement), the counter will -take no action. Likewise, if the counter's value is currently at -1 -(111111B, or 03FH), and the bit sample to be played is a 1, the counter will -not increment. - - -$4011 - Delta counter load register ------------------------------------ - -bits ----- -7 appears to be unused -1-6 the load inputs of the internal delta counter -0 LSB of the DAC - -A write to this register effectively loads the internal delta counter with a -6 bit value, but can be used for 7 bit PCM playback. Bit 0 is connected -directly to the LSB (bit 0) of the DAC, and has no effect on the internal -delta counter. Bit 7 appears to be unused. - -This register can be used to output direct 7-bit digital PCM data to the -DMC's audio output. To use this register for PCM playback, the programmer -would be responsible for making sure that this register is updated at a -constant rate. The rate is completely user-definable. For the regular CD -quality 44100 Hz playback sample rate, this register would have to be -written to approximately every 40 CPU cycles (assuming the 2A03 is running @ -1.79 MHz). - - -$4012 - DMA address load register ----------------------------- - -This register contains the initial address where the DMC is to fetch samples -from memory for playback. The effective address value is $4012 shl 6 or -0C000H. This register is connected to the load pins of the internal DMA -address pointer register (counter). The counter is incremented after every -DMA byte fetch. The counter is 15 bits in size, and has addresses wrap -around from $FFFF to $8000 (not $C000, as you might have guessed). The DMA -address pointer register is reloaded with the initial calculated address, -when the DMC is activated from an inactive state, or when the length counter -has arrived at terminal count (count=0), if in the looping playback mode. - - -$4013 - DMA length register ---------------------------- - -This register contains the length of the chunk of memory to be played by the -DMC, and it's size is measured in bytes. The value of $4013 shl 4 is loaded -into a 12 bit internal down counter, dubbed the length counter. The length -counter is decremented after every DMA fetch, and when it arrives at 0, the -DMC will take action(s) based on the 2 MSB of $4010. This counter will be -loaded with the current calculated address value of $4013 when the DMC is -activated from an inactive state. Because the value that is loaded by the -length counter is $4013 shl 4, this effectively produces a calculated byte -sample length of $4013 shl 4 + 1 (i.e. if $4013=0, sample length is 1 byte -long; if $4013=FF, sample length is $FF1 bytes long). - - -$4015 - DMC status ------------------- - -This contains the current status of the DMC channel. There are 2 read bits, -and 1 write bit. - -bits ----- -7(R) DMC's IRQ status (1=CPU IRQ being caused by DMC) -4(R) DMC is currently enabled (playing a stream of samples) -4(W) enable/disable DMC (1=start/continue playing a sample;0=stop playing) - -When an IRQ goes off inside the 2A03, Bit 7 of $4015 can tell the interrupt -handler if it was caused by the DMC hardware or not. This bit will be set -(1) if the DMC is responsible for the IRQ. Of course, if your program has no -other IRQ-generating hardware going while it's using the DMC, then reading -this register is not neccessary upon IRQ generation. Note that reading this -register will NOT clear bit 7 (meaning that the DMC's IRQ will still NOT be -acknowledged). Also note that if the 2 MSB of $4010 were set to 10, no IRQ -will be generated, and bit 7 will always be 0. - -Upon generation of a IRQ, to let the DMC know that the software has -acknowledged the /IRQ (and to reset the DMC's internal IRQ flag), any write -out to $4015 will reset the flag, or a write out to $4010 with the MSB set -to 0 will do. These practices should be performed inside the IRQ handler -routine. To replay the same sample that just finished, all you need to do is -just write a 1 out to bit 4 of $4015. - -Bit 4 of $4015 reports the real-time status of the DMC. A returned value of -1 denotes that the channel is currently playing a stream of samples. A -returned value of 0 indicates that the channel is inactive. If the -programmer needed to know when a stream of samples was finished playing, but -didn't want to use the IRQ generation feature of the DMC, then polling this -bit would be a valid option. - -Writing a value to $4015's 4th bit has the effect of enabling the channel -(start, or continue playing a stream of samples), or disabling the channel -(stop all DMC activity). Note that writing a 1 to this bit while the channel -is currently enabled, will have no effect on counters or registers internal -to the DMC. - -The conditions that control the time the DMC will stay enabled are -determined by the 2 MSB of $4010, and register $4013 (if applicable). - - -System Reset ------------- - -On system reset, all 7 used bits of $4011 are reset to 0, the IRQ flag is -cleared (disabled), and the channel is disabled. All other registers will -remain unmodified. - diff --git a/branches/sdl2/documentation/tech/cpu/nessound-4th.txt b/branches/sdl2/documentation/tech/cpu/nessound-4th.txt deleted file mode 100644 index c592d2ed..00000000 --- a/branches/sdl2/documentation/tech/cpu/nessound-4th.txt +++ /dev/null @@ -1,551 +0,0 @@ -******************************************* -*2A03 sound channel hardware documentation* -******************************************* -Brad Taylor (big_time_software@hotmail.com) - - 4th release: February 19th, 2K3 - - - All results were obtained by studying prior information available (from nestech 1.00, and postings on NESDev from miscellanious people), and through a series of experiments conducted by me. Results acquired by individuals prior to my reverse-engineering have been double checked, and final results have been confirmed. Credit is due to those individual(s) who contributed miscellanious information in regards to NES sound channel hardware. Such individuals are: - - Goroh - Memblers - FluBBa - Izumi - Chibi-Tech - Quietust - SnowBro - - Kentaro Ishihara (Ki) is responsible for posting (on the NESdev mailing list) differrences in the 2 square wave channels, including the operation of 2A03 hardware publically undocumented (until now) such as the frame IRQ counter, and it's ties with sound hardware. Goroh had originally discovered some of this information, and Ki confirmed it. - - A special thanks goes out to Matthew Conte, for his expertise on pseudo-random number generation (amoung other things), which allowed for the full reverse engineering of the NES's noise channel to take place. Without his help, I would still be trying to find a needle in a haystack, as far as the noise's method of pseudo-random number generation goes. Additionally, his previous findings / reverse engineering work on the NES's sound hardware really got the ball of NES sound emulation rolling. If it weren't for Matt's original work, this document wouldn't exist. - - -**************** -* Introduction * -**************** - The 2A03 (NES's integrated CPU) has 4 internal channels to it that have the ability to generate semi-analog sound, for musical playback purposes. These channels are 2 square wave channels, one triangle wave channel, and a noise generation channel. This document will go into full detail on every aspect of the operation and timing of the mentioned sound channels. - - -******************* -* Channel details * -******************* - Each channel has different characteristics to it that make up it's operation. - - The square channel(s) have the ability to generate a square wave frequency in the range of 54.6 Hz to 12.4 KHz. It's key features are frequency sweep abilities, and output duty cycle adjustment. - - The triangle wave channel has the ability to generate an output triangle wave with a resolution of 4-bits (16 steps), in the range of 27.3 Hz to 55.9 KHz. The key features this channel has is it's analog triangle wave output, and it's linear counter, which can be set to automatically disable the channel's sound after a certain period of time has gone by. - - The noise channel is used for producing random frequencys, which results in a "noisey" sounding output. Output frequencys can range anywhere from 29.3 Hz to 447 KHz. It's key feature is it's pseudo- random number generator, which generates the random output frequencys heard by the channel. - - -***************** -* Frame counter * -***************** - The 2A03 has an internal frame counter. The purpose of it is to generate the various low frequency signals (60, 120, 240 Hz, and 48, 96, 192 Hz) required to clock several of the sound hardware's counters. It also has the ability to generate IRQ's. - - The smallest unit of timing the frame counter operates around is 240Hz; all other frequencies are generated by multiples of this base frequency. A clock divider of 14915 (clocked at twice the CPU speed) is used to get 240Hz (this was the actual measured ratio). - - -+---------------+ -|$4017 operation| -+---------------+ - Writes to register $4017 control operation of both the clock divider, and the frame counter. - - - Any write to $4017 resets both the frame counter, and the clock divider. Sometimes, games will write to this register in order to synchronize the sound hardware's internal timing, to the sound routine's timing (usually tied into the NMI code). The frame IRQ is slightly longer than the PPU's, so you can see why games would desire this syncronization. - - - bit 7 of $4017 controls the frame counter's divide rate. Every time the counter cycles (reaches terminal count (0)), a frame IRQ will be generated, if enabled by clearing bit 6 of $4017. $4015.6 holds the status of the frame counter IRQ; it will be set if the frame counter is responsible for the interrupt. - -$4017.7 divider frame IRQ freq. -------- ------- --------------- -0 4 60 -1 5 48 - - On 2A03 reset, both bits of $4017 (6 & 7) will be cleared, enabling frame IRQ's off the hop. The reason why the existence of frame IRQ's are generally unknown is because the 6502's maskable interrupt is disabled on reset, and this blocks out the frame IRQ's. Most games don't use any IRQ-generating hardware in general, therefore they don't bother enabling maskable interrupts. - - Note that the IRQ line will be held down by the frame counter until it is acknowledged (by reading $4015). Before this, the 6502 will generate an IRQ *every* time interrupts are enabled (either by CLI or RTI), since the IRQ design on the 6502 is level-triggered, and not edge. If you've written a program that does not read $4015 in the IRQ handler, and you execute CLI, the processor will immediately go into a infinite IRQ call-return loop. - - -+-----------------------+ -|Frame counter operation| -+-----------------------+ - Depending on the status of $4017.7, the frame counter will follow 2 different count sequences. These sequences determine when sound hardware counters will be clocked. The sequences are initialized immediately following any write to $4017. - -$4017.7 sequence -------- -------- -0 4, 0,1,2,3, 0,1,2,3,..., etc. -1 0,1,2,3,4, 0,1,2,3,4,..., etc. - - During count sequences 0..3, the linear (triangle) and envelope decay (square & noise) counters recieve a clock for each count. This means that both these counters are clocked once immediately after $4017.7 is written with a value of 1. - - Count sequences 1 & 3 clock (update) the frequency sweep (square), and length (all channels) counters. Even though the length counter's smallest unit of time counting is a frame, it seems that it is actually being clocked twice per frame. That said, you can consider the length counters to contain an extra stage to divide this clock signal by 2. - - No aforementioned sound hardware counters are clocked on count sequence #4. You should now see how this causes the 96, and 192 Hz signals to be generated when $4017.7=1. - - The rest of the document will describe the operation of the sound channels using the $4017.7=0 frequencies (60, 120, and 240 Hz). For $4017.7=1 operation, replace those frequencies with 48, 96, and 192 Hz (respectively). - - -************************ -* Sound hardware delay * -************************ - After resetting the 2A03, the first time any sound channel(s) length counter contains a non-zero value (channel is enabled), there will be a 2048 CPU clock cycle delay before any of the sound hardware is clocked. After the 2K clock cycles go by, the NES sound hardware will be clocked normally. This phenomenon only occurs prior to a system reset, and only occurs during the first 2048 CPU clocks after the activation of any of the 4 basic sound channels. - - The information in regards to this delay is only provided to keep this document accurate with all information that is currently known about the 2A03's sound hardware. I haven't done much tests on the behaviour of this delay (mainly because I don't care, as I view it as a inconvenience anyway), so this information should be taken with a grain of salt. - - -************************ -* Register Assignments * -************************ - The sound hardware internal to the 2A03 has been designated these special memory addresses in the CPU's memory map. - -$4000-$4003 Square wave 1 -$4004-$4007 Square wave 2 (identical to the first, except for upward frequency sweeps (see "sweep unit" section)) -$4008-$400B Triangle -$400C-$400F Noise -$4015 Channel enable / length/frame counter status -$4017 frame counter control - - Note that $4015 (and $4017, but is unrelated to sound hardware) are the only R/W registers. All others are write only (attempt to read them will most likely return the last byte on the bus (usually 040H), due to heavy capacitance on the NES's data bus). Reading a "write only" register, will have no effect on the specific register, or channel. - - Every sound channel has 4 registers affiliated with it. The description of the register sets are as follows: - -+----------------+ -| Register set 1 | -+----------------+ - -$4000(sq1)/$4004(sq2)/$400C(noise) bits ---------------------------------------- -0-3 volume / envelope decay rate -4 envelope decay disable -5 length counter clock disable / envelope decay looping enable -6-7 duty cycle type (unused on noise channel) - -$4008(tri) bits ---------------- -0-6 linear counter load register -7 length counter clock disable / linear counter start - - -+----------------+ -| Register set 2 | -+----------------+ - -$4001(sq1)/$4005(sq2) bits --------------------------- -0-2 right shift amount -3 decrease / increase (1/0) wavelength -4-6 sweep update rate -7 sweep enable - -$4009(tri)/$400D(noise) bits ----------------------------- -0-7 unused - - -+----------------+ -| Register set 3 | -+----------------+ - -$4002(sq1)/$4006(sq2)/$400A(Tri) bits -------------------------------------- -0-7 8 LSB of wavelength - -$400E(noise) bits ------------------ -0-3 playback sample rate -4-6 unused -7 random number type generation - - -+----------------+ -| Register set 4 | -+----------------+ - -$4003(sq1)/$4007(sq2)/$400B(tri)/$400F(noise) bits --------------------------------------------------- -0-2 3 MS bits of wavelength (unused on noise channel) -3-7 length counter load register - - -+--------------------------------+ -| length counter status register | -+--------------------------------+ - -$4015(read) ------------ -0 square wave channel 1 -1 square wave channel 2 -2 triangle wave channel -3 noise channel -4 DMC (see "DMC.TXT" for details) -5-6 unused -7 IRQ status of DMC (see "DMC.TXT" for details) - - -+-------------------------+ -| channel enable register | -+-------------------------+ - -$4015(write) ------------- -0 square wave channel 1 -1 square wave channel 2 -2 triangle wave channel -3 noise channel -4 DMC channel (see "DMC.TXT" for details) -5-7 unused - - -************************ -* Channel architecture * -************************ - This section will describe the internal components making up each individual channel. Each component will then be described in full detail. - -Device Triangle Noise Square ------- -------- ------ ------ -triangle step generator X -linear counter X -programmable timer X X X -length counter X X X -4-bit DAC X X X -volume/envelope decay unit X X -sweep unit X -duty cycle generator X -wavelength converter X -random number generator X - - -+-------------------------+ -| Triangle step generator | -+-------------------------+ - This is a 5-bit, single direction counter, and it is only used in the triangle channel. Each of the 4 LSB outputs of the counter lead to one input on a corresponding mutually exclusive XNOR gate. The 4 XNOR gates have been strobed together, which results in the inverted representation of the 4 LSB of the counter appearing on the outputs of the gates when the strobe is 0, and a non-inverting action taking place when the strobe is 1. The strobe is naturally connected to the MSB of the counter, which effectively produces on the output of the XNOR gates a count sequence which reflects the scenario of a near- ideal triangle step generator (D,E,F,F,E,D,...,2,1,0,0,1,2,...). At this point, the outputs of the XNOR gates will be fed into the input of a 4-bit DAC. - - This 5-bit counter will be halted whenever the Triangle channel's length or linear counter contains a count of 0. This results in a "latching" behaviour; the counter will NOT be reset to any definite state. - - On system reset, this counter is loaded with 0. - - The counter's clock input is connected directly to the terminal count output pin of the 11-bit programmable timer in the triangle channel. As a result of the 5-bit triangle step generator, the output triangle wave frequency will be 32 times less than the frequency of the triangle channel's programmable timer is set to generate. - - -+----------------+ -| Linear counter | -+----------------+ - The linear counter is only found in the triangle channel. It is a 7-bit presettable down counter, with a decoded output condition of 0 available (not exactly the same as terminal count). Here's the bit assignments: - -$4008 bits ----------- -0-6 bits 0-6 of the linear counter load register (NOT the linear counter itself) -7 linear counter start - - The counter is clocked at 240 Hz (1/4 framerate), and the calculated length in frames is 0.25*N, where N is the 7-bit loaded value. The counter is always being clocked, except when 0 appears on the output of the counter. At this point, the linear counter & triangle step counter clocks signals are disabled, which results in both counters latching their current state (the linear counter will stay at 0, and the triangle step counter will stop, and the channel will be silenced due to this). - - The linear counter has 2 modes: load, and count. When the linear counter is in load mode, it essentially becomes transparent (i.e. whatever value is currently in, or being written to $4008, will appear on the output of the counter). Because of this, no count action can occur in load mode. When the mode changes from load to count, the counter will now latch the value currently in it, and start counting down from there. In the count mode, the current value of $4008 is ignored by the counter (but still retained in $4008). Described below is how the mode of the linear counter is set: - - -Writes to $400B ---------------- -cur mode ---- ---- -1 load -0 load (on next linear counter clock), count - - Cur is the current state of the MSB of $4008. - - -Writes to $4008 ---------------- -old new mode ---- --- ---- -0 X count -1 0 no change (during the CPU write cycle), count -1 1 no change - - Old and new represent the state(s) of the MSB of $4008. Old is the value being replaced in the MSB of $4008 on the write, and new is the value replacing the old one. - - "no change" indicates that the mode of the linear counter will not change from the last. - - Note that writes to $400B when $4008.7=0 only loads the linear counter with the value in $4008 on the next *linear* counter clock (and NOT at the end of the CPU write cycle). This is a correction from older versions of this doc. - - -+--------------------+ -| Programmable timer | -+--------------------+ - The programmable timer is a 11-bit presettable down counter, and is found in the square, triangle, and noise channel(s). The bit assignments are as follows: - -$4002(sq1)/$4006(sq2)/$400A(Tri) bits -------------------------------------- -0-7 represent bits 0-7 of the 11-bit wavelength - -$4003(sq1)/$4007(sq2)/$400B(Tri) bits -------------------------------------- -0-2 represent bits 8-A of the 11-bit wavelength - - Note that on the noise channel, the 11 bits are not available directly. See the wavelength converter section, for more details. - - The counter has automatic syncronous reloading upon terminal count (count=0), therefore the counter will count for N+1 (N is the 11-bit loaded value) clock cycles before arriving at terminal count, and reloading. This counter will typically be clocked at the 2A03's internal 6502 speed (1.79 MHz), and produces an output frequency of 1.79 MHz/(N+1). The terminal count's output spike length is typically no longer than half a CPU clock. The TC signal will then be fed to the appropriate device for the particular sound channel (for square, this terminal count spike will lead to the duty cycle generator. For the triangle, the spike will be fed to the triangle step generator. For noise, this signal will go to the random number generator unit). - - -+----------------+ -| Length counter | -+----------------+ - The length counter is found in all sound channels. It is essentially a 7-bit down counter, and is conditionally clocked at a frequency of 60 Hz. - - When the length counter arrives at a count of 0, the counter will be stopped (stay on 0), and the appropriate channel will be silenced. - - The length counter clock disable bit, found in all the channels, can also be used to halt the count sequence of the length counter for the appropriate channel, by writing a 1 out to it. A 0 condition will permit counting (unless of course, the counter's current count = 0). Location(s) of the length counter clock disable bit: - -$4000(sq1)/$4004(sq2)/$400C(noise) bits ---------------------------------------- -5 length counter clock disable - -$4008(tri) bits ---------------- -7 length counter clock disable - - To load the length counter with a specified count, a write must be made out to the length register. Location(s) of the length register: - -$4003(sq1)/$4007(sq2)/$400B(tri)/$400F(noise) bits --------------------------------------------------- -3-7 length - - The 5-bit length value written, determines what 7-bit value the length counter will start counting from. A conversion table here will show how the values are translated. - - +-----------------------+ - | bit3=0 | - +-------+---------------+ - | |frames | - |bits +-------+-------+ - |4-6 |bit7=0 |bit7=1 | - +-------+-------+-------+ - |0 |05 |06 | - |1 |0A |0C | - |2 |14 |18 | - |3 |28 |30 | - |4 |50 |60 | - |5 |1E |24 | - |6 |07 |08 | - |7 |0D |10 | - +-------+-------+-------+ - - +---------------+ - | bit3=1 | - +-------+-------+ - |bits | | - |4-7 |frames | - +-------+-------+ - |0 |7F | - |1 |01 | - |2 |02 | - |3 |03 | - |4 |04 | - |5 |05 | - |6 |06 | - |7 |07 | - |8 |08 | - |9 |09 | - |A |0A | - |B |0B | - |C |0C | - |D |0D | - |E |0E | - |F |0F | - +-------+-------+ - - The length counter's real-time status for each channel can be attained. A 0 is returned for a zero count status in the length counter (channel's sound is disabled), and 1 for a non-zero status. Here's the bit description of the length counter status register: - -$4015(read) ------------ -0 length counter status of square wave channel 1 -1 length counter status of square wave channel 2 -2 length counter status of triangle wave channel -3 length counter status of noise channel -4 length counter status of DMC (see "DMC.TXT" for details) -5 unknown -6 frame IRQ status -7 IRQ status of DMC (see "DMC.TXT" for details) - - Writing a 0 to the channel enable register will force the length counters to always contain a count equal to 0, which renders that specific channel disabled (as if it doesn't exist). Writing a 1 to the channel enable register disables the forced length counter value of 0, but will not change the count itself (it will still be whatever it was prior to the writing of 1). - - Bit description of the channel enable register: - -$4015(write) ------------- -0 enable square wave channel 1 -1 enable square wave channel 2 -2 enable triangle wave channel -3 enable noise channel -4 enable DMC channel (see "DMC.TXT" for details) -5-7 unknown - - Note that all 5 used bits in this register will be set to 0 upon system reset. - - -+-----------+ -| 4-bit DAC | -+-----------+ - This is just a standard 4-bit DAC with 16 steps of output voltage resolution, and is used by all 4 sound channels. On the 2A03, square wave 1 & 2 are mixed together, and are available via pin 1. Triangle & noise are available on pin 2. - - These analog outputs require a negative current source, to attain linear symmetry on the various output voltage levels generated by the channel(s) (moreover, to get the sound to be audible). Instead of current sources, the NES uses external 100 ohm pull-down resistors. This results in the output waveforms having some linear asymmetry (i.e., as the desired output voltage increases on a linear scale, the actual outputted voltage increases less and less each step). - - The side effect of this is that the DMC's 7-bit DAC port ($4011) is able to indirectly control the volume (somewhat) of both triangle & noise channels. While I have not measured the voltage asymmetery, others on the NESdev messageboards have posted their findings. The conclusion is that when $4011 is 0, triangle & noise volume outputs are at maximum. When $4011 = 7F, the triangle & noise channel outputs operate at only 57% total volume. - - The odd thing is that a few games actually take advantage of this "volume" feature, and write values to $4011 in order to regulate the amplitude of the triangle wave channel's output. - - -+------------------------------+ -| Volume / envelope decay unit | -+------------------------------+ - The volume / envelope decay hardware is found only in the square wave and noise channels. - -$4000(sq1)/$4004(sq2)/$400C(noise) ----------------------------------- -0-3 volume / envelope decay rate -4 envelope decay disable -5 envelope decay looping enable - - When the envelope decay disable bit (bit 4) is set (1), the current volume value (bits 0-3) is sent directly to the channel's DAC. However, depending on certain conditions, this 4-bit volume value will be ignored, and a value of 0 will be sent to the DAC instead. This means that while the channel is enabled (producing sound), the output of the channel (what you'll hear from the DAC) will either be the 4-bit volume value, or 0. This also means that a 4-bit volume value of 0 will result in no audible sound. These conditions are as follows: - - - When hardware in the channel wants to disable it's sound output (like the length counter, or sweep unit (square channels only)). - - - On the negative portion of the output frequency signal coming from the duty cycle / random number generator hardware (square wave channel / noise channel). - - When the envelope decay disable bit is cleared, bits 0-3 now control the envelope decay rate, and an internal 4-bit down counter (hereon the envelope decay counter) now controls the channel's volume level. "Envelope decay" is used to describe the action of the channel's audio output volume starting from a certain value, and decreasing by 1 at a fixed (linear) rate (which produces a "fade-out" sounding effect). This fixed decrement rate is controlled by the envelope decay rate (bits 0-3). The calculated decrement rate is 240Hz/(N+1), where N is any value between $0-$F. - - When the channel's envelope decay counter reaches a value of 0, depending on the status of the envelope decay looping enable bit (bit 5, which is shared with the length counter's clock disable bit), 2 different things will happen: - -bit 5 action ------ ------ -0 The envelope decay count will stay at 0 (channel silenced). -1 The envelope decay count will wrap-around to $F (upon the next clock cycle). The envelope decay counter will then continue to count down normally. - - Only a write out to $4003/$4007/$400F will reset the current envelope decay counter to a known state (to $F, the maximum volume level) for the appropriate channel's envelope decay hardware. Otherwise, the envelope decay counter is always counting down (by 1) at the frequency currently contained in the volume / envelope decay rate bits (even when envelope decays are disabled (setting bit 4)), except when the envelope decay counter contains a value of 0, and envelope decay looping (bit 5) is disabled (0). - - -+------------+ -| Sweep unit | -+------------+ - The sweep unit is only found in the square wave channels. The controls for the sweep unit have been mapped in at $4001 for square 1, and $4005 for square 2. - - The controls - ------------ - Bit 7 when this bit is set (1), sweeping is active. This results in real-time increasing or decreasing of the the current wavelength value (the audible frequency will decrease or increase, respectively). The wavelength value in $4002/3 ($4006/7) is constantly read & updated by the sweep. Modifying the contents of $4002/3 will be immediately audible, and will result in the sweep now starting from this new wavelength value. - - Bits 6-4 These 3 bits represent the sweep refresh rate, or the frequency at which $4002/3 is updated with the new calculated wavelength. The refresh rate frequency is 120Hz/(N+1), where N is the value written, between 0 and 7. - - Bit 3 This bit controls the sweep mode. When this bit is set (1), sweeps will decrease the current wavelength value, as a 0 will increase the current wavelength. - - Bits 2-0 These bits control the right shift amount of the new calculated sweep update wavelength. Code that shows how the sweep unit calculates a new sweep wavelength is as follows: - -bit 3 ------ -0 New = Wavelength + (Wavelength >> N) -1 New = Wavelength - (Wavelength >> N) (minus an additional 1, if using square wave channel 1) - - where N is the the shift right value, between 0-7. - - Note that in decrease mode, for subtracting the 2 values: - 1's compliment (NOT) is being used for square wave channel 1 - 2's compliment (NEG) is being used for square wave channel 2 - - This information is currently the only known difference between the 2 square wave channels. - - On each sweep refresh clock, the Wavelength register will be updated with the New value, but only if all 3 of these conditions are met: - - - bit 7 is set (sweeping enabled) - - the shift value (which is N in the formula) does not equal to 0 - - the channel's length counter contains a non-zero value - - Notes - ----- - There are certain conditions that will cause the sweep unit to silence the channel, and halt the sweep refresh clock (which effectively stops sweep action, if any). Note that these conditions pertain regardless of any sweep refresh rate values, or if sweeping is enabled/disabled (via bit 7). - - - an 11-bit wavelength value less than $008 will cause this condition - - if the sweep unit is currently set to increase mode, the New calculated wavelength value will always be tested to see if a carry (bit $B) was generated or not (if sweeping is enabled, this carry will be examined before the Wavelength register is updated) from the shift addition calculation. If carry equals 1, the channel is silenced, and sweep action is halted. - - -+----------------------+ -| Duty cycle generator | -+----------------------+ - The duty cycle generator takes the fequency produced from the 11-bit programmable timer, and uses a 4 bit counter to produce 4 types of duty cycles. The output frequency is then 1/16 that of the programmable timer. The duty cycle hardware is only found in the square wave channels. The bit assignments are as follows: - -$4000(sq1)/$4004(sq2) ---------------------- -6-7 Duty cycle type - - duty (positive/negative) -val in clock cycles ---- --------------- -00 2/14 -01 4/12 -10 8/ 8 -11 12/ 4 - - Where val represents bits 6-7 of $4000/$4004. - - This counter is reset when the length counter of the same channel is written to (via $4003/$4007). - - The output frequency at this point will now be fed to the volume/envelope decay hardware. - - -+----------------------+ -| Wavelength converter | -+----------------------+ - The wavelength converter is only used in the noise channel. It is used to convert a given 4-bit value to an 11-bit wavelength, which then is sent to the noise's own programmable timer. Here is the bit descriptions: - -$400E bits ----------- -0-3 The 4-bit value to be converted - - Below is a conversion chart that shows what 4-bit value will represent the 11-bit wavelength to be fed to the channel's programmable timer: - -value octave scale CPU clock cycles (11-bit wavelength+1) ------ ------ ----- -------------------------------------- -0 15 A 002 -1 14 A 004 -2 13 A 008 -3 12 A 010 -4 11 A 020 -5 11 D 030 -6 10 A 040 -7 10 F 050 -8 10 C 065 -9 9 A 07F -A 9 D 0BE -B 8 A 0FE -C 8 D 17D -D 7 A 1FC -E 6 A 3F9 -F 5 A 7F2 - - Octave and scale information is provided for the music enthusiast programmer who is more familiar with notes than clock cycles. - - -+-------------------------+ -| Random number generator | -+-------------------------+ - The noise channel has a 1-bit pseudo-random number generator. It's based on a 15-bit shift register, and an exclusive or gate. The generator can produce two types of random number sequences: long, and short. The long sequence generates 32,767-bit long number patterns. The short sequence generates 93-bit long number patterns. The 93-bit mode will generally produce higher sounding playback frequencys on the channel. Here is the bit that controls the mode: - -$400E bits ----------- -7 mode - - If mode=0, then 32,767-bit long number sequences will be produced (32K mode), otherwise 93-bit long number sequences will be produced (93-bit mode). - - The following diagram shows where the XOR taps are taken off the shift register to produce the 1-bit pseudo-random number sequences for each mode. - -mode <----- ----- EDCBA9876543210 -32K ** -93-bit * * - - The current result of the XOR will be transferred into bit position 0 of the SR, upon the next shift cycle. The 1-bit random number output is taken from pin E, is inverted, then is sent to the volume/envelope decay hardware for the noise channel. The shift register is shifted upon recieving 2 clock pulses from the programmable timer (the shift frequency will be half that of the frequency from the programmable timer (one octave lower)). - - On system reset, this shift register is loaded with a value of 1. - - -RP2A03E quirk -------------- - I have been informed that revisions of the 2A03 before "F" actually lacked support for the 93-bit looped noise playback mode. While the Famicom's 2A03 went through 4 revisions (E..H), I think that only one was ever used for the front loading NES: "G". Other differences between 2A03 revisions are unknown. - - -EOF \ No newline at end of file diff --git a/branches/sdl2/documentation/tech/cpu/nessound.txt b/branches/sdl2/documentation/tech/cpu/nessound.txt deleted file mode 100644 index bb6d0598..00000000 --- a/branches/sdl2/documentation/tech/cpu/nessound.txt +++ /dev/null @@ -1,697 +0,0 @@ -The NES sound channel guide 1.8 -Written by Brad Taylor. -btmine@hotmail.com - -Last updated: July 27th, 2000. - -All results were obtained by studying prior information available (from -nestech 1.00, and postings on NESDev from miscellanious people), and through -a series of experiments conducted by me. Results acquired by individuals -prior to my reverse-engineering have been double checked, and final results -have been confirmed. Credit is due to those individual(s) who contributed -any information in regards to the the miscellanious sound channels wihtin -the NES. - -A special thanks goes out to Matthew Conte, for his expertise on -pseudo-random number generation (amoung other things), which allowed for the -full reverse engineering of the NES's noise channel to take place. Without -his help, I would still be trying to find a needle in a haystack, as far as -the noise's method of pseudo-random number generation goes. Additionally, -his previous findings / reverse engineering work on the NES's sound hardware -really got the ball of NES sound emulation rolling. If it weren't for Matt's -original work, this document wouldn't exist. - -Thanks to Kentaro Ishihara, for his excellent work on finding the difference -in upward frequency sweep between the 2 square wave channels. - -**************** -* Introduction * -**************** - -The 2A03 (NES's integrated CPU) has 4 internal channels to it that have the -ability to generate semi-analog sound, for musical playback purposes. These -channels are 2 square wave channels, one triangle wave channel, and a noise -generation channel. This document will go into full detail on every aspect -of the operation and timing of the mentioned sound channels. - - -******************* -* Channel details * -******************* - -Each channel has different characteristics to it that make up it's -operation. - -The square channel(s) have the ability to generate a square wave frequency -in the range of 54.6 Hz to 12.4 KHz. It's key features are frequency sweep -abilities, and output duty cycle adjustment. - -The triangle wave channel has the ability to generate an output triangle -wave with a resolution of 4-bits (16 steps), in the range of 27.3 Hz to 55.9 -KHz. The key features this channel has is it's analog triangle wave output, -and it's linear counter, which can be set to automatically disable the -channel's sound after a certain period of time has gone by. - -The noise channel is used for producing random frequencys, which results in -a "noisey" sounding output. Output frequencys can range anywhere from 29.3 -Hz to 447 KHz. It's key feature is it's pseudo- random number generator, -which generates the random output frequencys heard by the channel. - - -***************** -* Frame counter * -***************** - -The 2A03 has an internal frame counter. It has the ability to generate 60 Hz -(1/1 framerate), 120 Hz (1/2 framerate), and 240 Hz (1/4 framerate) signals, -used by some of the sound hardware. The 1/4 framerate is calculated by -taking twice the CPU clock speed (3579545.454545 Hz), and dividing it by -14915 (i.e., the divide-by-14915 counter is decremented on the rising AND -falling edge of the CPU's clock signal). - - -************************ -* Sound hardware delay * -************************ - -After resetting the 2A03, the first time any sound channel(s) length counter -contains a non-zero value (channel is enabled), there will be a 2048 CPU -clock cycle delay before any of the sound hardware is clocked. After the 2K -clock cycles go by, the NES sound hardware will be clocked normally. This -phenomenon only occurs prior to a system reset, and only occurs during the -first 2048 CPU clocks for any sound channel prior to a sound channel being -enabled. - -The information in regards to this delay is only provided to keep this -entire document persistently accurate on the 2A03's sound hardware, but may -not be 100% accurate in itself. I haven't done much tests on the behaviour -of this delay (mainly because I don't care, as I view it as a inconvenience -anyway), so that's why I believe there could be some inaccuracies. - - -************************ -* Register Assignments * -************************ - -The sound hardware internal to the 2A03 has been designated these special -memory addresses in the CPU's memory map. - -$4000-$4003 Square wave 1 -$4004-$4007 Square wave 2 (identical to the first, except for upward -frequency sweeps (see "sweep unit" section)) -$4008-$400B Triangle -$400C-$400F Noise -$4015 Channel enable / length counter status - -Note that $4015 is the only R/W register. All others are write only (attempt -to read them will most likely result in a returned 040H, due to heavy -capacitance on the NES's data bus). Reading a "write only" register, will -have no effect on the specific register, or channel. - -Every sound channel has 4 registers affiliated with it. The description of -the register sets are as follows: - -+----------------+ -| Register set 1 | -+----------------+ - -$4000(sq1)/$4004(sq2)/$400C(noise) bits ---------------------------------------- -0-3 volume / envelope decay rate -4 envelope decay disable -5 length counter clock disable / envelope decay looping enable -6-7 duty cycle type (unused on noise channel) - -$4008(tri) bits ---------------- -0-6 linear counter load register -7 length counter clock disable / linear counter start - - -+----------------+ -| Register set 2 | -+----------------+ - -$4001(sq1)/$4005(sq2) bits --------------------------- -0-2 right shift amount -3 decrease / increase (1/0) wavelength -4-6 sweep update rate -7 sweep enable - -$4009(tri)/$400D(noise) bits ----------------------------- -0-7 unused - - -+----------------+ -| Register set 3 | -+----------------+ - -$4002(sq1)/$4006(sq2)/$400A(Tri) bits -------------------------------------- -0-7 8 LSB of wavelength - -$400E(noise) bits ------------------ -0-3 playback sample rate -4-6 unused -7 random number type generation - - -+----------------+ -| Register set 4 | -+----------------+ - -$4003(sq1)/$4007(sq2)/$400B(tri)/$400F(noise) bits --------------------------------------------------- -0-2 3 MS bits of wavelength (unused on noise channel) -3-7 length counter load register - - -+--------------------------------+ -| length counter status register | -+--------------------------------+ - -$4015(read) ------------ -0 square wave channel 1 -1 square wave channel 2 -2 triangle wave channel -3 noise channel -4 DMC (see "DMC.TXT" for details) -5-6 unused -7 IRQ status of DMC (see "DMC.TXT" for details) - - -+-------------------------+ -| channel enable register | -+-------------------------+ - -$4015(write) ------------- -0 square wave channel 1 -1 square wave channel 2 -2 triangle wave channel -3 noise channel -4 DMC channel (see "DMC.TXT" for details) -5-7 unused - - -************************ -* Channel architecture * -************************ - -This section will describe the internal components making up each individual -channel. Each component will then be described in full detail. - -Device Triangle Noise Square ------- -------- ------ ------ -triangle step generator X -linear counter X -programmable timer X X X -length counter X X X -4-bit DAC X X X -volume/envelope decay unit X X -sweep unit X -duty cycle generator X -wavelength converter X -random number generator X - - -+-------------------------+ -| Triangle step generator | -+-------------------------+ - -This is a 5-bit, single direction counter, and it is only used in the -triangle channel. Each of the 4 LSB outputs of the counter lead to one input -on a corresponding mutually exclusive XNOR gate. The 4 XNOR gates have been -strobed together, which results in the inverted representation of the 4 LSB -of the counter appearing on the outputs of the gates when the strobe is 0, -and a non-inverting action taking place when the strobe is 1. The strobe is -naturally connected to the MSB of the counter, which effectively produces on -the output of the XNOR gates a count sequence which reflects the scenario of -a near- ideal triangle step generator (D,E,F,F,E,D,...,2,1,0,0,1,2,...). At -this point, the outputs of the XNOR gates will be fed into the input of a -4-bit DAC. - -This 5-bit counter will be halted whenever the Triangle channel's length or -linear counter contains a count of 0. This results in a "latching" -behaviour; the counter will NOT be reset to any definite state. - -On system reset, this counter is loaded with 0. - -The counter's clock input is connected directly to the terminal count output -pin of the 11-bit programmable timer in the triangle channel. As a result of -the 5-bit triangle step generator, the output triangle wave frequency will -be 32 times less than the frequency of the triangle channel's programmable -timer is set to generate. - - -+----------------+ -| Linear counter | -+----------------+ - -The linear counter is only found in the triangle channel. It is a 7-bit -presettable down counter, with a decoded output condition of 0 available -(not exactly the same as terminal count). Here's the bit assignments: - -$4008 bits ----------- -0-6 bits 0-6 of the linear counter load register (NOT the linear counter -itself) -7 linear counter start - -The counter is clocked at 240 Hz (1/4 framerate), and the calculated length -in frames is 0.25*N, where N is the 7-bit loaded value. The counter is -always being clocked, except when 0 appears on the output of the counter. At -this point, the linear counter & triangle step counter clocks signals are -disabled, which results in both counters latching their current state (the -linear counter will stay at 0, and the triangle step counter will stop, and -the channel will be silenced due to this). - -The linear counter has 2 modes: load, and count. When the linear counter is -in load mode, it essentially becomes transparent (i.e. whatever value is -currently in, or being written to $4008, will appear on the output of the -counter). Because of this, no count action can occur in load mode. When the -mode changes from load to count, the counter will now latch the value -currently in it, and start counting down from there. In the count mode, the -current value of $4008 is ignored by the counter (but still retained in -$4008). Described below is how the mode of the linear counter is set: - -Writes to $400B ---------------- -cur mode ---- ---- -1 load -0 load (during the write cycle), count - -Cur is the current state of the MSB of $4008. - -Writes to $4008 ---------------- -old new mode ---- --- ---- -0 X count -1 0 no change (during the write cycle), count -1 1 no change - -Old and new represent the state(s) of the MSB of $4008. Old is the value -being replaced in the MSB of $4008 on the write, and new is the value -replacing the old one. - -"no change" indicates that the mode of the linear counter will not change -from the last. - - -+--------------------+ -| Programmable timer | -+--------------------+ - -The programmable timer is a 11-bit presettable down counter, and is found in -the square, triangle, and noise channel(s). The bit assignments are as -follows: - -$4002(sq1)/$4006(sq2)/$400A(Tri) bits -------------------------------------- -0-7 represent bits 0-7 of the 11-bit wavelength - -$4003(sq1)/$4007(sq2)/$400B(Tri) bits -------------------------------------- -0-2 represent bits 8-A of the 11-bit wavelength - -Note that on the noise channel, the 11 bits are not available directly. See -the wavelength converter section, for more details. - -The counter has automatic syncronous reloading upon terminal count -(count=0), therefore the counter will count for N+1 (N is the 11-bit loaded -value) clock cycles before arriving at terminal count, and reloading. This -counter will typically be clocked at the 2A03's internal 6502 speed (1.79 -MHz), and produces an output frequency of 1.79 MHz/(N+1). The terminal -count's output spike length is typically no longer than half a CPU clock. -The TC signal will then be fed to the appropriate device for the particular -sound channel (for square, this terminal count spike will lead to the duty -cycle generator. For the triangle, the spike will be fed to the triangle -step generator. For noise, this signal will go to the random number -generator unit). - - -+----------------+ -| Length counter | -+----------------+ - -The length counter is found in all sound channels. It is essentially a 7-bit -down counter, and is conditionally clocked at a frequency of 60 Hz. - -When the length counter arrives at a count of 0, the counter will be stopped -(stay on 0), and the appropriate channel will be silenced. - -The length counter clock disable bit, found in all the channels, can also be -used to halt the count sequence of the length counter for the appropriate -channel, by writing a 1 out to it. A 0 condition will permit counting -(unless of course, the counter's current count = 0). Location(s) of the -length counter clock disable bit: - -$4000(sq1)/$4004(sq2)/$400C(noise) bits ---------------------------------------- -5 length counter clock disable - -$4008(tri) bits ---------------- -7 length counter clock disable - -To load the length counter with a specified count, a write must be made out -to the length register. Location(s) of the length register: - -$4003(sq1)/$4007(sq2)/$400B(tri)/$400F(noise) bits --------------------------------------------------- -3-7 length - -The 5-bit length value written, determines what 7-bit value the length -counter will start counting from. A conversion table here will show how the -values are translated. - - +-----------------------+ - | bit3=0 | - +-------+---------------+ - | |frames | - |bits +-------+-------+ - |4-6 |bit7=0 |bit7=1 | - +-------+-------+-------+ - |0 |05 |06 | - |1 |0A |0C | - |2 |14 |18 | - |3 |28 |30 | - |4 |50 |60 | - |5 |1E |24 | - |6 |07 |08 | - |7 |0E |10 | - +-------+-------+-------+ - - +---------------+ - | bit3=1 | - +-------+-------+ - |bits | | - |4-7 |frames | - +-------+-------+ - |0 |7F | - |1 |01 | - |2 |02 | - |3 |03 | - |4 |04 | - |5 |05 | - |6 |06 | - |7 |07 | - |8 |08 | - |9 |09 | - |A |0A | - |B |0B | - |C |0C | - |D |0D | - |E |0E | - |F |0F | - +-------+-------+ - -The length counter's real-time status for each channel can be attained. A 0 -is returned for a zero count status in the length counter (channel's sound -is disabled), and 1 for a non-zero status. Here's the bit description of the -length counter status register: - -$4015(read) ------------ -0 length counter status of square wave channel 1 -1 length counter status of square wave channel 2 -2 length counter status of triangle wave channel -3 length counter status of noise channel -4 length counter status of DMC (see "DMC.TXT" for details) -5-6 unused -7 IRQ status of DMC (see "DMC.TXT" for details) - -Writing a 0 to the channel enable register will force the length counters to -always contain a count equal to 0, which renders that specific channel -disabled (as if it doesn't exist). Writing a 1 to the channel enable -register disables the forced length counter value of 0, but will not change -the count itself (it will still be whatever it was prior to the writing of -1). - -Bit description of the channel enable register: - -$4015(write) ------------- -0 enable square wave channel 1 -1 enable square wave channel 2 -2 enable triangle wave channel -3 enable noise channel -4 enable DMC channel (see "DMC.TXT" for details) -5-7 unused - -Note that all 5 used bits in this register will be set to 0 upon system -reset. - - -+-----------+ -| 4-bit DAC | -+-----------+ - -This is just a standard 4-bit DAC with 16 steps of output voltage -resolution, and is used by all 4 sound channels. - -On the 2A03, square wave 1 & 2 are mixed together, and are available via pin -1. Triangle & noise are available on pin 2. These analog outputs require a -negative current source, to attain linear symmetry on the various output -voltage levels generated by the channel(s) (moreover, to get the sound to be -audible). Since the NES just uses external 100 ohm pull-down resistors, this -results in the output waveforms being of very small amplitude, but with -minimal linearity asymmetry. - - -+------------------------------+ -| Volume / envelope decay unit | -+------------------------------+ - -The volume / envelope decay hardware is found only in the square wave and -noise channels. - -$4000(sq1)/$4004(sq2)/$400C(noise) ----------------------------------- -0-3 volume / envelope decay rate -4 envelope decay disable -5 envelope decay looping enable - -When the envelope decay disable bit (bit 4) is set (1), the current volume -value (bits 0-3) is sent directly to the channel's DAC. However, depending -on certain conditions, this 4-bit volume value will be ignored, and a value -of 0 will be sent to the DAC instead. This means that while the channel is -enabled (producing sound), the output of the channel (what you'll hear from -the DAC) will either be the 4-bit volume value, or 0. This also means that a -4-bit volume value of 0 will result in no audible sound. These conditions -are as follows: - -- When hardware in the channel wants to disable it's sound output (like the -length counter, or sweep unit (square channels only)). - -- On the negative portion of the output frequency signal coming from the -duty cycle / random number generator hardware (square wave channel / noise -channel). - -When the envelope decay disable bit is cleared, bits 0-3 now control the -envelope decay rate, and an internal 4-bit down counter (hereon the envelope -decay counter) now controls the channel's volume level. "Envelope decay" is -used to describe the action of the channel's audio output volume starting -from a certain value, and decreasing by 1 at a fixed (linear) rate (which -produces a "fade-out" sounding effect). This fixed decrement rate is -controlled by the envelope decay rate (bits 0-3). The calculated decrement -rate is 240Hz/(N+1), where N is any value between $0-$F. - -When the channel's envelope decay counter reaches a value of 0, depending on -the status of the envelope decay looping enable bit (bit 5, which is shared -with the length counter's clock disable bit), 2 different things will -happen: - -bit 5 action ------ ------ -0 The envelope decay count will stay at 0 (channel silenced). -1 The envelope decay count will wrap-around to $F (upon the next clock -cycle). The envelope decay counter will then continue to count down -normally. - -Only a write out to $4003/$4007/$400F will reset the current envelope decay -counter to a known state (to $F, the maximum volume level) for the -appropriate channel's envelope decay hardware. Otherwise, the envelope decay -counter is always counting down (by 1) at the frequency currently contained -in the volume / envelope decay rate bits (even when envelope decays are -disabled (setting bit 4)), except when the envelope decay counter contains a -value of 0, and envelope decay looping (bit 5) is disabled (0). - - -+------------+ -| Sweep unit | -+------------+ - -The sweep unit is only found in the square wave channels. The controls for -the sweep unit have been mapped in at $4001 for square 1, and $4005 for -square 2. - -The controls ------------- -Bit 7 when this bit is set (1), sweeping is active. This results in -real-time increasing or decreasing of the the current wavelength value (the -audible frequency will decrease or increase, respectively). The wavelength -value in $4002/3 ($4006/7) is constantly read & updated by the sweep. -Modifying the contents of $4002/3 will be immediately audible, and will -result in the sweep now starting from this new wavelength value. - -Bits 6-4 These 3 bits represent the sweep refresh rate, or the frequency at -which $4002/3 is updated with the new calculated wavelength. The refresh -rate frequency is 120Hz/(N+1), where N is the value written, between 0 and -7. - -Bit 3 This bit controls the sweep mode. When this bit is set (1), sweeps -will decrease the current wavelength value, as a 0 will increase the current -wavelength. - -Bits 2-0 These bits control the right shift amount of the new calculated -sweep update wavelength. Code that shows how the sweep unit calculates a new -sweep wavelength is as follows: - -bit 3 ------ -0 New = Wavelength + (Wavelength >> N) -1 New = Wavelength - (Wavelength >> N) (minus an additional 1, if using -square wave channel 1) - -where N is the the shift right value, between 0-7. - -Note that in decrease mode, for subtracting the 2 values: -1's compliment (NOT) is being used for square wave channel 1 -2's compliment (NEG) is being used for square wave channel 2 - -This information is currently the only known difference between the 2 square -wave channels. - -On each sweep refresh clock, the Wavelength register will be updated with -the New value, but only if all 3 of these conditions are met: - -- bit 7 is set (sweeping enabled) -- the shift value (which is N in the formula) does not equal to 0 -- the channel's length counter contains a non-zero value - -Notes ------ -There are certain conditions that will cause the sweep unit to silence the -channel, and halt the sweep refresh clock (which effectively stops sweep -action, if any). Note that these conditions pertain regardless of any sweep -refresh rate values, or if sweeping is enabled/disabled (via bit 7). - -- an 11-bit wavelength value less than $008 will cause this condition -- if the sweep unit is currently set to increase mode, the New calculated -wavelength value will always be tested to see if a carry (bit $B) was -generated or not (if sweeping is enabled, this carry will be examined before -the Wavelength register is updated) from the shift addition calculation. If -carry equals 1, the channel is silenced, and sweep action is halted. - - -+----------------------+ -| Duty cycle generator | -+----------------------+ - -The duty cycle generator takes the fequency produced from the 11-bit -programmable timer, and uses a 4 bit counter to produce 4 types of duty -cycles. The output frequency is then 1/16 that of the programmable timer. -The duty cycle hardware is only found in the square wave channels. The bit -assignments are as follows: - -$4000(sq1)/$4004(sq2) ---------------------- -6-7 Duty cycle type - - duty (positive/negative) -val in clock cycles ---- --------------- -00 2/14 -01 4/12 -10 8/ 8 -11 12/ 4 - -Where val represents bits 6-7 of $4000/$4004. - -The output frequency at this point will now be fed to the volume/envelope -decay hardware. - - -+----------------------+ -| Wavelength converter | -+----------------------+ - -The wavelength converter is only used in the noise channel. It is used to -convert a given 4-bit value to an 11-bit wavelength, which then is sent to -the noise's own programmable timer. Here is the bit descriptions: - -$400E bits ----------- -0-3 The 4-bit value to be converted - -Below is a conversion chart that shows what 4-bit value will represent the -11-bit wavelength to be fed to the channel's programmable timer: - -value octave scale CPU clock cycles (11-bit wavelength+1) ------ ------ ----- -------------------------------------- -0 15 A 002 -1 14 A 004 -2 13 A 008 -3 12 A 010 -4 11 A 020 -5 11 D 030 -6 10 A 040 -7 10 F 050 -8 10 C 065 -9 9 A 07F -A 9 D 0BE -B 8 A 0FE -C 8 D 17D -D 7 A 1FC -E 6 A 3F9 -F 5 A 7F2 - -Octave and scale information is provided for the music enthusiast programmer -who is more familiar with notes than clock cycles. - - -+-------------------------+ -| Random number generator | -+-------------------------+ - -The noise channel has a 1-bit pseudo-random number generator. It's based on -a 15-bit shift register, and an exclusive or gate. The generator can produce -two types of random number sequences: long, and short. The long sequence -generates 32,767-bit long number patterns. The short sequence generates -93-bit long number patterns. The 93-bit mode will generally produce higher -sounding playback frequencys on the channel. Here is the bit that controls -the mode: - -$400E bits ----------- -7 mode - -If mode=0, then 32,767-bit long number sequences will be produced (32K -mode), otherwise 93-bit long number sequences will be produced (93-bit -mode). - -The following diagram shows where the XOR taps are taken off the shift -register to produce the 1-bit pseudo-random number sequences for each mode. - -mode <----- ----- EDCBA9876543210 -32K ** -93-bit * * - -The current result of the XOR will be transferred into bit position 0 of the -SR, upon the next shift cycle. The 1-bit random number output is taken from -pin E, is inverted, then is sent to the volume/envelope decay hardware for -the noise channel. The shift register is shifted upon recieving 2 clock -pulses from the programmable timer (the shift frequency will be half that of -the frequency from the programmable timer (one octave lower)). - -On system reset, this shift register is loaded with a value of 1. - - diff --git a/branches/sdl2/documentation/tech/exp/mmc5-e.txt b/branches/sdl2/documentation/tech/exp/mmc5-e.txt deleted file mode 100644 index eab191af..00000000 --- a/branches/sdl2/documentation/tech/exp/mmc5-e.txt +++ /dev/null @@ -1,250 +0,0 @@ -========= mmc5 infomation ========== -date 1998/05/31 -by goroh -translated May 31, 1998 by Sgt. Bowhack -mail goroh_kun@geocities.co.jp - -5000,5004 ch1,ch2 Pulse Control - bit CCwevvvv - CC Duty Cycle (Positive vs. Negative) - #0:87.5% #1:75.0% #2:50.0% #3:25.0% - w Waveform Hold (e.g. Looping) - 0: Off 1: On - e Envelope Select - 0: Varied 1: Fixed - < e=0 > - vvvv Playback Rate - #0<-fast<--->-slow--> #15 - < e=1 > - vvvv Output Volume - -5002,5006 ch1,ch2 frequency L - bit ffffffff -5003,5007 ch1,ch2 frequency H - bit tttttfff - ttttt sound occurence time - -Objective is to remove the continuous changing of frequency for -square wave setup and do the same to the main part of the square wave -of studying the main part of the famicom. (?- Sgt. Bowhack) - -5010 ch3 synthetic voice business channel - bit -------O - O wave output 0:Off 1:On - -5011 ch4 synthetic voice business channel 2 - bit vvvvvvvv - vvvvvvvv wave size - -5015 sound output channel - bit ------BA - A: ch1 output 1:enable 0:disable - B: ch2 output 1:enable 0:disable - -5100 PRG-page size Setting - bit ------SS - SS PRG-page size - 0: 32k 1:16k 2,3:8k -* Reset is misled the first times for about 8k (?- SB) - -5101 CHR-page size Setting - bit ------SS - SS CHR-page size - 0:8k 1:4k 2:2k 3:1k - -5102 W BBR-RAM Write Protect 1 - bit ------AA -5103 W BBR-RAM Write Protect 2 - bit ------BB - (AA,BB) = (2,1) permitted to write to BBR-RAM only when crowded -*Reset write around becomes prohibited when crowded - -5104 Grafix Mode Setting - $5c00-$5fff decides how it should be used - bit ------MM - #00:Enable only Split Mode - #01:Enable Split Mode & ExGrafix Mode - #02:ExRAM Mode - #03:ExRAM Mode & Write Protect - -Consideration - MMC5 has 2 graphic mode extensions that allow more than 256 characters -on one standard game screen. It uses Split Mode so it can display the -specified CHR-page and scroll position seperate from ExGrafix Mode to -be able to choose a palette, and the other divides it vertically. - -5105 W NameTable Setting - bit ddccbbaa - aa: Select VRAM at 0x2000-0x23ff - bb: Select VRAM at 0x2400-0x27ff - cc: Select VRAM at 0x2800-0x2bff - dd: Select VRAM at 0x2c00-0x2fff - #0:use VRAM 0x000-0x3ff - #1:use VRAM 0x400-0x7ff - #2:use ExVRAM 0x000-0x3ff - #3:use ExNameTable(Fill Mode) - -Consideration - The name table can designate 4 kinds of this resister and be a useful -special quality for this because painting and smashing it with a -character that there is 1 sheet for the remaining sheets can generally -be used. (?-SB) - -5106 W Fill Mode Setting 1 - bit vvvvvvvv - Fill chr-table - For whether it paints or smashes it at any non-designated character - -5107 W Fill Mode Setting 2 - bit ------pp - Whether or not it uses any non-designated palettes - -5113 RAM-page for $6000-$7FFF - bit -----p-- - -5114-5117 Program Bank switch - < page_size=32k > - $5117 [8]-[F] bit pppppp-- - - < page_size=16k > - $5115 [8]-[B] bit ppppppp- - $5117 [C]-[F] bit ppppppp- - - < page_size=8k > - $5114 [8][9] bit pppppppp - $5115 [A][B] bit pppppppp - $5116 [C][D] bit pppppppp - $5117* [E][F] bit pppppppp - -*Reset is around early, Last Page misled - -5120-512b Charactor Bank switch - < page_size=8k > - $5120-$5127 switch to mode A - $5128-$512b switch to mode B - $5127 [0]-[7] modeA - $512b [0]-[7] modeB - - < page_size=4k > - $5120-$5127 switch to mode A - $5128-$512b switch to mode B - $5123 [0]-[3] modeA - $5127 [4]-[7] modeA - $512b [0]-[3],[4]-[7] modeB - - < page_size=2k > - $5120-$5127 switch to mode A - $5128-$512b switch to mode B - $5121 [0]-[1] modeA - $5123 [2]-[3] modeA - $5125 [4]-[5] modeA - $5127 [6]-[7] modeA - $5129 [0]-[1],[4]-[5] modeB - $512b [2]-[3],[6]-[7] modeB - - < page_size=1k > - $5120-$5127 switch to mode A - $5128-$512b switch to mode B - $5120 [0] modeA - $5121 [1] modeA - $5122 [2] modeA - $5123 [3] modeA - $5124 [4] modeA - $5125 [5] modeA - $5126 [6] modeA - $5127 [7] modeA - $5128 [0],[4] modeB - $5129 [1],[5] modeB - $512a [2],[6] modeB - $512b [3],[7] modeB - -Consideration - MMC5 has mode A ,mode B and 2 kinds of CHR-page memory resistors. -They can be used for refreshing it. (?-SB) - -5130 ??? -analyzing it... - -5200 W Split Mode Control 1 - bit Ec-vvvvv - For the E function 0:don't use 1:use - c boundary's side is for using Split Mode extension of graphics - 0: left side 1: right side - vvvvv left boundary is designated with the char. # to count places - -Sample. - 5200 <- #00 - (not?) used yet - 5200 <- #82 - Used for SplitMode GFX extension from left 1-2 character - 5200 <- #c2 - Used for SplitMode GFX extension from the right side 3 chars. - 5200 <- #c0 - Used for SplitMode GFX extension on the whole screen - 5200 <- #d0 - Used for SplitMode GFX extension on the right side of the screen - 5200 <- #90 - Used for SplitMode GFX extension on the left side of the screen - -5201 W SplitMode setup for SplitMode Ext. GFX use 1 - $2005 determines the vertical movement; it can also delay ext. gfx's - vert. movement if necessary. It's written 2 times in bulk in the same - way as it would slip off a grade in $2005 (??-SB) - -5202 W SplitMode setup for SplitMode Ext. GFX use 2 - bit --pppppp - uses vertical division of ext. gfx CHR-page designation - index_size=4k(0x1000byte) -In case it uses a character 0x4000-0x4fff for the ext. gfx in question - $5202 <- 4 - -5203 W scanline break point - For scanline # that it splits and wants to make it designate it in bulk - -5204 WR IRQ enable/disable - W bit I------- - I 1:IRQ Enable 0:IRQ Disable - R bit I------- - I 1:Scanline Hit 0:Scanline not Hit - $5203 is designated as scanline when arrived. - -5205 WR mult input/output -5206 WR mult input/output -($5205in)*($5206in) = $5205,$5206out - -5c00-5fbf ext. gfx business VRAM - shows an attribute of every position character - - - bit PPpppppp - PP: use character palette number - pppppp: use background CHR-PAGE number index=4k - #0-#3F are designations, $0000-$3FFF is CHR-data's range - Use for extension gfx - - - SplitMode uses a Name Table for extension gfx use. - bit pppppppp - pppppppp: use for background char. number designation - - - Used for Extension RAM - -5fc0-5fff - - (not?) used yet - - - SplitMode uses gfx's Attribute Table extension. - PPU uses $23c0-$23ff in the same way as the Attribute Table - - - Used for Extension RAM - -Consideration - 5c00-5fff has 3 uses. - Split Mode and ExGrafix Mode's VBlank is written so as to become - crowded, it writes a 0 and becomes crowded. - Every mode tries to go around ExRAM mode including reading but it - writes it, is effective in bulk and #5c-#5f is the output at times - where it is effective. \ No newline at end of file diff --git a/branches/sdl2/documentation/tech/exp/smb2j.txt b/branches/sdl2/documentation/tech/exp/smb2j.txt deleted file mode 100644 index 074b1d3d..00000000 --- a/branches/sdl2/documentation/tech/exp/smb2j.txt +++ /dev/null @@ -1,112 +0,0 @@ - SMB2j Revision "A". Mapper #50 Info - ----------------------------------- - - -12.09.2000 -V2.00 - -Mapper info by The Mad Dumper ---- - - -This mapper has been assigned the number 50. (that's 50 decimal) - - -Wow, another SMB2j cart! This one is alot different than the last one I -worked on. It has a single 128K PRG ROM and VRAM. The other SMB2j had -64K PRG and 8K CHR. Not much more to say other than this has one very -fucked up mapper circuit on it! - ---- - - -The hardware: - - -It consists of 6 TTL chips (74163, 74157, 74139, 7400, 7474, and a 4020), -1 8K RAM chip for the VRAM, and 1 128K 28 pin ROM. There is some -"M^2L" logic on the board (Mickey-Mouse Logic). It is a 3 input OR gate -made out of 3 diodes and a resistor. - -Also, they swapped D3 and D6, as well as A1 and A3. Why this was done, I -have no idea. It sure mussed up my REing efforts! I desoldered and read -the ROM out through the EPROM programmer as a check and was not happy to -find the data seemingly corrupt! - -After converting the ROM image over via some QBasic, it matched up great. -You do not have to swap the addresses or data bytes; I have done this -already in the released .NES ROM. - ---- - -There are two registers on this cartridge. They are located in the 4000h- -5FFFh block. - -Funny addresses are decoded for the register selection; presumably so they -did not interfere with the FDS or NES registers. - - -A15 ... A0 -------------------- -010x xxxQ x01x xxxx - - -x = Don't Care -0 = must be 0 -1 = must be 1 -Q = register selection bit. 0 = ROM Page; 1 = IRQ Timer Enable - -- - -ROM Page Register: ------------------- - -Accessed when the address lines are in the above state. An example address -would be 4020h. 4021h, 4022h, ... 403Fh, 40A0h, 40A1h, ... are all mirrors -of this register. Writing here stores the desired bank #. - -7 bit 0 ---------- -xxxx DCBA - -These 4 bits are shown below in the ROM memory map. Note that they are -somewhat "scrambled". The value of this register is unknown at powerup. - -- - -IRQ Timer. - -7 bit 0 ---------- -xxxx xxxI - -The IRQ Timer register controls the state of the IRQ timer. Writing here -will turn it on or off. Turning the IRQ timer off resets it to 0. Writing -a 1 here will turn the timer on, while writing a 0 will turn it off. - -The timer is composed of a binary ripple counter. After 4096 M2 cycles, -/IRQ is pulled low. This is about 36 scanlines. The idea behind the timer -is to split the screen for the score bar at the top. You start it at the -beginning of the VBI routine, and then after 36 scanlines, it sends the IRQ -which clears the timer, and resets the scroll registers. The value of this -register is unknown at powerup. - ---- - -ROM Memory Map: - - -Address Range | Bank bits: 3210 -------------------------------- - 6000h-7FFFh 1111 - 8000h-9FFFh 1000 - A000h-BFFFh 1001 - C000h-DFFFh DACB -- Selectable page - E000h-FFFFh 1011 - - -The ROM is composed of 16 8K banks. The 4 bank bits are shown above. Bit 3 -is the MSB while bit 0 is the LSB. 6000h-7FFFh is set to 1111b, or bank 0fh. -All banks are FIXED except the bank at C000h-DFFFh. Only it can be changed. - - diff --git a/branches/sdl2/documentation/tech/exp/tengen.txt b/branches/sdl2/documentation/tech/exp/tengen.txt deleted file mode 100644 index cc84d596..00000000 --- a/branches/sdl2/documentation/tech/exp/tengen.txt +++ /dev/null @@ -1,18 +0,0 @@ -Unknown: - -Alien Syndrome 128KiB/128KiB -Super Sprint - -MIMIC 1: - -Fantasy Zone 64KiB/64KiB -Toobin' 128KiB/64KiB -Vindicators 64KiB/32KiB - - -RAMBO 1(board looks like it can take 256KiB PRG/256KiB CHR max): - -Klax 64KiB PRG/64KiB CHR -Road Runner 64KiB PRG/128KiB CHR -Rolling Thunder 128KiB PRG/128KiB CHR -Skull and Crossbones 128KiB PRG/64KiB CHR diff --git a/branches/sdl2/documentation/tech/exp/vrcvi.txt b/branches/sdl2/documentation/tech/exp/vrcvi.txt deleted file mode 100644 index 52023577..00000000 --- a/branches/sdl2/documentation/tech/exp/vrcvi.txt +++ /dev/null @@ -1,388 +0,0 @@ - VRCVI CHIP INFO - ----- ---- ---- - - By: - - - Kevin Horton - khorton@iquest.net - - - - - The RENES Project: - Reverse-engineering - the world. - - - - -V1.01 08/31/99 teeny fix -V1.00 08/31/99 Complete Version - - - -VRCVI (VRC6) (48 pin standard 600mil wide DIP) ------------- -This chip is used in such games as Konami's CV3j and Madara. It's unique -because it has some extra sound channels on it that get piped through the -Famicom (note this is a fami-only chip and you will not find one in any -NES game). "VI" of "VRCVI" is "6" for the roman numeral challenged. - - -This chip generates its audio via a 6 bit R2R ladder. This is contained -inside a 9 pin resistor network like so: - - - 3K 3K 3K 3K 3K 2K - /------*-\/\/-*-\/\/-*-\/\/-*-\/\/-*-\/\/-*------*-\/\/-\ - | | | | | | | | | - \ \ \ \ \ \ \ | | - / / / / / / / | | - \ 6K \ 6K \ 6K \ 6K \ 6K \ 6K \ 6K | | - / / / / / / / | | - | | | | | | | | | - O O O O O O O O O - - GND D0 D1 D2 D3 D4 D5 Aud In Aud Out - - -Legend: -------- - -(s) means this pin connects to the System -(r) this only connects to the ROM -(w) this is a SRAM/WRAM connection only -AUD : these pass to the resistor network -CHR : these connect to the CHR ROM and/or fami's CHR pins -PRG : these connect to the PRG ROM and/or fami's PRG pins -WRAM : this hooks to the WRAM -CIRAM : the RAM chip which is on the fami board - - .----\/----. - GND - |01 48| - +5V - AUD D1 - |02 47| - AUD D0 - AUD D3 - |03 46| - AUD D2 - AUD D5 - |04 45| - AUD D4 - (s) PRG A12 - |05 44| - PRG A16 (r) - (s) PRG A14 - |06 43| - PRG A13 (s) - (s) M2 - |07 42| - PRG A17 (r) - (r) PRG A14 - |08 41| - PRG A15 (r) - *1 (s) PRG A1 - |09 40| - PRG A13 (r) - *1 (s) PRG A0 - |10 39| - PRG D7 (s) - (s) PRG D0 - |11 38| - PRG D6 (s) - (s) PRG D1 - |12 37| - PRG D5 (s) - (s) PRG D2 - |13 36| - PRG D4 (s) - (r) PRG /CE - |14 35| - PRG D3 (s) - (s) R/W - |15 34| - PRG /CE (s) - *2 (w) WRAM /CE - |16 33| - /IRQ (s) - (r) CHR /CE - |17 32| - CIRAM /CE (s) - (s) CHR /RD - |18 31| - CHR A10 (s) - (s) CHR /A13 - |19 30| - CHR A11 (s) - (r) CHR A16 - |20 29| - CHR A12 (s) - (r) CHR A15 - |21 28| - CHR A17 (r) - (r) CHR A12 - |22 27| - CHR A14 (r) - (r) CHR A11 - |23 26| - CHR A13 (r) - GND - |24 25| - CHR A10 (r) - | | - `----------' - - VRCVI - - -*1: On some VRCVI carts, these are reversed. This affects some registers. - -*2: This passes through a small pulse shaping network consisting of a - resistor, diode, and cap. - - -Registers: (sound related only) ----------- - -regs 9000-9002 are for pulse channel #1 -regs a000-a002 are for pulse channel #2 -regs b000-b002 are for the phase accumulator channel (sawtooth) - -(bits listed 7 through 0) - -9000h: GDDDVVVV - - D - Duty Cycle bits: - - 000 - 1/16th ( 6.25%) - 001 - 2/16ths (12.50%) - 010 - 3/16ths (18.75%) - 011 - 4/16ths (25.00%) - 100 - 5/16ths (31.25%) - 101 - 6/16ths (37.50%) - 110 - 7/16ths (43.75%) - 111 - 8/16ths (50.00%) - - V - Volume bits. 0000b is silence, 1111b is loudest. Volume is - linear. When in "normal" mode (see G bit), this acts as a general - volume control register. When in "digitized" mode, these act as a - 4 bit sample input. - - G - Gate bit. 0=normal operation, 1=digitized. In digi operation, - registers 9001h and 9002h are totally disabled. Only bits 0-3 of - 9000h are used. Whatever binary word is present here is passed on - as a 4 bit digitized output. - - -9002h: FFFFFFFF - - F - Lower 8 bits of frequency data - - -9003h: X---FFFF - - X - Channel disable. 0=channel disabled, 1=channel enabled. - - F - Upper 4 bits of frequency data - - -A000h-A002h are identical in operation to 9000h-9002h. One note: this chip -will mix both digitized outputs (if the G bits are both set) into one -added output. (see in-depth chip operation below) - -B000h: --PPPPPP - - P - Phase accumulator input bits - -B001h: FFFFFFFF - - F - Lower 8 bits of frequency data - -B002h: X---FFFF - - X - Channel disable. 0=channel disabled, 1=channel enabled. - - F - Upper 4 bits of frequency data - - - -How the sounds are formed: --------------------------- - -This chip is pretty cool. It outputs a 6 bit binary word for the sound -which is passed through a DAC and finally to the NES/Fami. Because of this, -the sound can be emulated *very* close to the original. - - -I used my scope to figure all this out as well as my meter and logic probe -so it should be 100% accurate. - - - -Block diagrams of the VRCVI: (as reverse engineered by me) ----------------------------- - - - | F bits | | D bits| | V bits | - | (12) | | (3) | | (4) | - \___________/ \_______/ \________/ -+-----+ +----------------+ +-----------+ +------------+ -| | | | | | | |--\ -| OSC |-->|Divider (12 bit)|-->| Duty Cycle|-->| AND array |(4)> chan out -|(M2) | | | | Generator | | |--/ -+-----+ +----------------+ +-----------+ +------------+ - ^ ^ - | | - | | - G X - - One Pulse channel (both are identical) - -------------------------------------- - - -How it works: The oscillator (in the NES, the clock arrives on the M2 line -and is about 1.78Mhz) generates our starting frequency. This is passed -first into a divide by 1 to 4096 divider to generate a base frequency. -This is then passed to the duty cycle generator. The duty cycle generator -generates the desired duty cycle for the output waveform. The "D" input -controls the duty cycle generator's duty cycle. If the "G" bit is -a "1", it forces the output of the duty cycle generator to a "1" also. If -the "X" bit is "0", it forces the output of the duty cycle generator to "0", -which effectively disables the channel. Note that this input has precidence -over the "G" bit. - -The AND array is just that- an array of 4 AND gates. If the output of -the duty cycle generator is a "0", then the "chan out" outputs will all be -forced to "0". If the output of the duty cycle generator is a "1", then -the chan out outputs will follow the V bit inputs. - -Note that the output of this generator is a 4 bit binary word. - - ---- - - - | F bits | | P bits| - | (12) | | (6) | - \___________/ \_______/ -+-----+ +----------------+ +-----------+ -| | | | | |--\ -| OSC |-->|Divider (12 bit)|-->| Phase |(5)> chan out -|(M2) | | | |Accumulator|--/ -+-----+ +----------------+ +-----------+ - ^ - | - | - X - - The Sawtooth (ramp) channel - --------------------------- - - -This one is pretty similar to the above when it comes to frequency selection. -The output frequency will be the same relative to the square wave channels. -OK, the tough part will be explaining the phase accumulator. :-) What it is -is just an adder tied to a latch. Every clock it adds a constant to the -latch. In the case of the VRCVI, what you do is this: - -The ramp is generated over the course of 7 evenly spaced cycles, generated -from the divider. Every clock from the divider causes the phase accumulator -to add once. So... let's say we have 03h in the P bits. Every 7 cycles -the phase accumulator (which is 8 bits) is reset to 00h. - - -cycle: accumulator: chan out: notes: ------------------------------------------ -0 00h 00h On the first cycle, the acc. is reset to 0 -1 03h 00h We add 3 to 0 to get 3 -2 06h 00h We add 3 to 3 to get 6 -3 09h 01h -4 0ch 01h -5 0fh 01h -6 12h 02h -7 00h 00h Reset the acc. back to 0 and do it again - - -This will look like so: (as viewed on an oscilloscope) - - - - - - - 2 - --- --- --- 1 ---- --- --- 0 - | -012345601234560123456-+ - - - -Note: if you enter a value that is too large (i.e. 30h) the accumulator -*WILL WRAP*. Yes, this doesn't sound very good at all and you no longer -have a sawtooth. ;-) - - -The upper 5 bits of said accumulator are run to the "chan out" outputs. -The lower 3 bits are not run anywhere. - -"X" disables the phase accumulator and forces all outputs to "0". -Note that the output of this generator is a 5 bit word. - - ---- - -Now that the actual sound generation is out of the way, here's how the -channels are combined into the final 6 bit binary output: - - -+---------+ -| Pulse | -|Generator| -| #1 | Final 6 Bit -+---------+ Output - | (4) | / \ - \ / | (6) | -+---------+ +---------+ +---------+ -| 4 Bit |--\ | 5 Bit | /--|Sawtooth | -| Binary |(5)>| Binary |<(5)|Generator| -| Adder |--/ | Adder | \--| | -+---------+ +---------+ +---------+ - / \ - | (4) | -+---------+ -| Pulse | -|Generator| -| #2 | -+---------+ - - Channel Combining - ----------------- - - -The three channels are finally added together through a series of adders -to produce the final output word. The two pulse chans are most likely added -first since they are 4 bit words, and that 5 bit result is most likely -added to the sawtooth's output. (The actual adding order is not known, -but I can make a *very* good guess. The above illustrated way uses the least -amount of transistors). In the end it does not matter the order in which -the words are added; the final word will always be the same. - -The final 6 bit output word is run through an "R2R" resistor ladder which -turns the digital bits into a 64 level analog representation. The ladder -is binarally weighted and works like the DAC on your soundcard. :-) -(so take heart emulator authours: just run the finished 6 bit word to -your soundcard and it will sound right ;-). - - - -Frequency Generation: ---------------------- - -The chip generates all its output frequencies based on M2, which is -colourburst divided by two (1789772.7272Hz). This signal is passed -directly into the programmable dividers (the 12 bit frequency regs). - -Squares: --------- - -These take the output of the programmable divider and then run it through -the duty cycle generator, which in the process of generating the duty cycle, -divides the frequency by 16. - - -To calculate output frequency: - - 1789772.7272 -Fout = ---------------- - (freq_in+1) * 16 - - -This will tell you the exact frequency in Hz. (note that the * 16 is to -compensate for the divide by 16 duty cycle generator.) - -Saw: ----- - -This is similar to the above, however the duty cycle generator is replaced -with a phase accumulator which divides the output frequency by 14. - - -To calculate output frequency: - - 1789772.7272 -Fout = ---------------- - (freq_in+1) * 14 - - -This will tell you the exact frequency in Hz. (note that the * 14 is to -compensate for the phase accumulator.) - - - -So how accurate is this info, anyways? --------------------------------------- - -I believe the info to be 100% accurate. I have extensively tested the -output of the actual VRCVI chip to this spec and everything fits perfectly. -I did this by using a register dump and a QBASIC program I wrote which -takes the register dump and produces a WAV file. All frequency and -duty cycle measurements were taken with a Fluke 83 multimeter, and all -waveform data was culled from my oscilloscope measuring the real chip. - - - - ----EOF--- diff --git a/branches/sdl2/documentation/tech/exp/vrcvii.txt b/branches/sdl2/documentation/tech/exp/vrcvii.txt deleted file mode 100644 index fc07d05e..00000000 --- a/branches/sdl2/documentation/tech/exp/vrcvii.txt +++ /dev/null @@ -1,321 +0,0 @@ - VRCVII CHIP INFO - ------ ---- ---- - - By: - - - Kevin Horton - khorton@iquest.net - - - - - The RENES Project: - Reverse-engineering - the world. - - - -V0.10 11/05/99 Document started, pinned out chip and audio thingy -V0.20 11/10/99 Added very, very, very preliminary register findings -v1.00 11/14/99 First release version of this doc - -VRCVII (VRC7) (48 pin standard 600mil wide DIP) -------------- - -This chip is used in only one Konami game that I know of- Lagrange Point. -I heard rumours it was used in another game, so if someone could provide -info and/or a ROM image, that would help immensely. It handles ROM -bankswitching as well as sound generation. The sound generation is done -using FM synthesis, so the music sounds like "Adlib" OPL2 music. Due to -extra sound, this is a Famicom-only chip like its cousin the -VRCVI. (See the VRCVI doc for more info) - -"VII" of "VRCVII" is "7" for the roman numeral challenged. - - -This chip appears to generate all of its audio internally, which is then -fed to a small hybrid (aka "black blob") that does the audio interfacing -to the Famicom proper. It is physically a small ceramic substrate with -an 8 pin SMD chip on it (probably an op-amp), and what appears to be three -0805 sized SMD chip parts (capacitors most likely, since resistors can be -formed on the substrate). The whole works is then coated with a black -dipped epoxy coating, and the smooth side (opposite the parts) is then -marked with an identifying part number and the pin 1 dot. - - -Here's the pinout for it: - - Front Side (parts facing away) - - +-----------------+ 1- Audio in from Famicom - | 054002 | 2- Audio out to Famicom - |@ | 3,7 - Ground - +-----------------+ 4-6 - NC - | | | | | | | | | 8- Audio from VRCVII - 1 2 3 4 5 6 7 8 9 9- +5V - - - - - -Legend: -------- - -(s) means this pin connects to the System -(r) this only connects to the ROM -(w) this is a SRAM/WRAM connection only -PRG : these connect to the PRG ROM and/or fami's PRG pins -WRAM : this hooks to the WRAM - -Note: There is a 3.58Mhz ceramic resonator connected to the "X1" and "X2" -pins. it is the three-pin style with internal caps tied to the third pin -which is grounded. - -Chip is physically marked: "VRV VII 053982" - - .----\/----. - *1 (RAM&s) CHR /OE - |01 48| - NC - *1 (RAM&s) CHR /CE - |02 47| - M2 (s) - GND - |03 46| - /CE WRAM (w) - (s) R/W - |04 45| - PRG /A15 (s) (aka /CE) - (s) /IRQ - |05 44| - PRG ROM /CE (r) - (s) CIRAM A11 - |06 43| - Audio Out - (s) PD0 - |07 42| - +5V - (s) PD1 - |08 41| - NC - (s) PD2 - |09 40| - NC - (s) PD3 - |10 39| - NC - (s) PD4 - |11 38| - NC - (s) PD5 - |12 37| - NC - (s) PD6 - |13 36| - CHR RAM A12 - (s) PD7 - |14 35| - CHR RAM A11 - +5V - |15 34| - CHR RAM A10 - (s) PRG A5 - |16 33| - CHR A12 (s) - Crystal X2 - |17 32| - CHR A11 (s) - Crystal X1 - |18 31| - CHR A10 (s) - (s) PRG A4 - |19 30| - +5V - (r) PRG ROM A13 - |20 29| - PRG A14 (s) - (r) PRG ROM A14 - |21 28| - PRG A13 (s) - (r) PRG ROM A15 - |22 27| - PRG A12 (s) - (r) PRG ROM A16 - |23 26| - PRG ROM A18 (r) - GND - |24 25| - PRG ROM A17 (r) - | | - `----------' - - VRCVII - - -*1: these connect to both the CHR RAM's pins and the card edge. - -Note: the NC pins 37-41 most likely for CHR ROM bankswitching. Since this -cart uses CHR RAM these obviously weren't used ;-) - -Registers: (sound related only) ----------- - -All sound registers are accessed through only two physical registers. - -9010: ------ - -This is the index register. You write the desired register number here. - -9030: ------ - -This is the data register. Data written here is stored in the register -pointed to by the above index register. - -There are 6 channels, each containing three registers, and 8 custom -instrument control registers. - - -Sound Registers: ----------------- - -00h - 07h : Custom instrument registers. See below for info. - ---- - -10h - 15h : ffffffff - -f: Lower 8 bits of frequency - ---- - -20h - 25h : ???tooof - -f: Upper bit of frequency -o: Octave Select -t: Channel trigger. -?: Dunno what these do yet (No audible effect) - ---- - -30h - 35h : iiiivvvv - -i: Instrument number -v: Volume - -Instrument numbers 01h-0fh are fixed and cannot be changed. - -Instrument number 00h is the "programmable" one. - -To program the custom instrument, you load registers 00h-07h with the -desired parameters for it. All channels set to instrument 00h will -then use this instrument. Note that you can only program one custom -instrument at a time. - - - -How do the frequency registers work? ------------------------------------- - -To generate a tone, you must select an octave and a frequency value. The -frequency values stay the same for say, the note "C", while the octave -bits determine which octave "C" lies in. This makes your note lookup table -quite small. - -o = 000 is octave 0 -o = 001 is octave 1 -. -. -. -o = 111 is octave 7 - - - 49722*freqval -F = ------------- - 2^(19-octave) - - -Where: - -F = output frequency in Hz -freqval = frequency register value -octave = desired octave (starting at 0) - - -Custom Instrument Registers (00-07) ------------------------------------ - -Note: I will not provide too extensive documentation of the instrument -registers since their functions are identical to those of the OPL2 chip, -commonly found on Adlib/Soundblaster/compatible cards, and there is alot -of information out on how to program these. I will use terminology -similar to that found in said documents. My VRC7 "emulator" test program -I wrote simply re-arranged and tweaked the register writes to correspond -with the OPL2 registers. - -Here's a link to a good document about this chip: - -http://www.ccms.net/~aomit/oplx/ - -The tremolo depth is set to 4.3db and the vibrato depth is set to 14 cent -(in reguards to OPL2 settings; to achieve this you would write 0C0h to -OPL register 0BDh). All operator connections are fixed in FM mode. (Where -Modulator modulates the Carrier). - ---- - - -00 (Modulator) - tvskmmmm -01 (Carrier) - -t: Tremolo Enable -v: Vibrato Enable -s: Sustain Enable -k: KSR -m: Multiplier - ---- - -02 - kkoooooo - -k: Key Scale Level -o: Output Level - ---- - -03 - ---qweee - --: Not used: Write 0's -q: Carrier Waveform -w: Modulator Waveform - -Note: There are only two waveforms available. Sine and rectified sine (only - the positive cycle of the sine; negative cycle "chopped off".) - -e: Feedback Control - ---- - -04 (Modulator) - aaaadddd -05 (Carrier) - -a: Attack -d: Decay - ---- - -06 (Modulator) - ssssrrrr -07 (Carrier) - -s: Sustain -r: Release - - - -Register Settings for the 15 fixed instruments. ------------------------------------------------ - -*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION* -C C -A These instruments are not 100% correct! There is no way to extract A -U the register settings from the chip short of an electron microscope. U -T I have "tuned" these instruments best I could, though I know a couple T -I are not exactly right. Use them at your own perl! If someone wants I -O to waste all day tuning a new set, please let me know what you get. O -N N -*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION*CAUTION* - - - Register - -------- - - 00 01 02 03 04 05 06 07 - ----------------------- - 0 | -- -- -- -- -- -- -- -- - 1 | 05 03 10 06 74 A1 13 F4 - 2 | 05 01 16 00 F9 A2 15 F5 - 3 | 01 41 11 00 A0 A0 83 95 - 4 | 01 41 17 00 60 F0 83 95 - 5 | 24 41 1F 00 50 B0 94 94 - 6 | 05 01 0B 04 65 A0 54 95 - 7 | 11 41 0E 04 70 C7 13 10 - Instrument 8 | 02 44 16 06 E0 E0 31 35 - ---------- 9 | 48 22 22 07 50 A1 A5 F4 - A | 05 A1 18 00 A2 A2 F5 F5 - B | 07 81 2B 05 A5 A5 03 03 - C | 01 41 08 08 A0 A0 83 95 - D | 21 61 12 00 93 92 74 75 - E | 21 62 21 00 84 85 34 15 - F | 21 62 0E 00 A1 A0 34 15 - - - - -So how accurate is this info, anyways? --------------------------------------- - -I believe the info to be 100% accurate. The pinout was generated with the -help of a multimeter and my Super-8 with both an NES cart and the Fami cart -plugged in. (this allows me to measure between my known "control" board -with the unknown "experimental" board to generate the connections). -Register info was gleaned via writing test code and listening and capturing -the resultant audio stream for analysis. - - - - ----EOF--- diff --git a/branches/sdl2/documentation/tech/nsfspec.txt b/branches/sdl2/documentation/tech/nsfspec.txt deleted file mode 100644 index 2ef526d2..00000000 --- a/branches/sdl2/documentation/tech/nsfspec.txt +++ /dev/null @@ -1,336 +0,0 @@ - NES Music Format Spec - --------------------- - - -By: Kevin Horton khorton@iquest.net - - -NOTE: ------ - - -Remember that I am very willing to add stuff and update this spec. If -you find a new sound chip or other change let me know and I will get back -with you. E-mail to the above address. - - -V1.61 - 06/27/2000 Updated spec a bit -V1.60 - 06/01/2000 Updated Sunsoft, MMC5, and Namco chip information -V1.50 - 05/28/2000 Updated FDS, added Sunsoft and Namco chips -V1.32 - 11/27/1999 Added MMC5 register locations -V1.30 - 11/14/1999 Added MMC5 audio bit, added some register info -V1.20 - 09/12/1999 VRC and FDS prelim sound info added -V1.00 - 05/11/1999 First official NSF specification file - - - -This file encompasses a way to transfer NES music data in a small, easy to -use format. - -The basic idea is one rips the music/sound code from an NES game and prepends -a small header to the data. - -A program of some form (6502/sound emulator) then takes the data and loads -it into the proper place into the 6502's address space, then inits and plays -the tune. - -Here's an overview of the header: - -offset # of bytes Function ----------------------------- - -0000 5 STRING "NESM",01Ah ; denotes an NES sound format file -0005 1 BYTE Version number (currently 01h) -0006 1 BYTE Total songs (1=1 song, 2=2 songs, etc) -0007 1 BYTE Starting song (1= 1st song, 2=2nd song, etc) -0008 2 WORD (lo/hi) load address of data (8000-FFFF) -000a 2 WORD (lo/hi) init address of data (8000-FFFF) -000c 2 WORD (lo/hi) play address of data (8000-FFFF) -000e 32 STRING The name of the song, null terminated -002e 32 STRING The artist, if known, null terminated -004e 32 STRING The Copyright holder, null terminated -006e 2 WORD (lo/hi) speed, in 1/1000000th sec ticks, NTSC (see text) -0070 8 BYTE Bankswitch Init Values (see text, and FDS section) -0078 2 WORD (lo/hi) speed, in 1/1000000th sec ticks, PAL (see text) -007a 1 BYTE PAL/NTSC bits: - bit 0: if clear, this is an NTSC tune - bit 0: if set, this is a PAL tune - bit 1: if set, this is a dual PAL/NTSC tune - bits 2-7: not used. they *must* be 0 -007b 1 BYTE Extra Sound Chip Support - bit 0: if set, this song uses VRCVI - bit 1: if set, this song uses VRCVII - bit 2: if set, this song uses FDS Sound - bit 3: if set, this song uses MMC5 audio - bit 4: if set, this song uses Namco 106 - bit 5: if set, this song uses Sunsoft FME-07 - bits 6,7: future expansion: they *must* be 0 -007c 4 ---- 4 extra bytes for expansion (must be 00h) -0080 nnn ---- The music program/data follows - -This may look somewhat familiar; if so that's because this is somewhat -sorta of based on the PSID file format for C64 music/sound. - - -Loading a tune into RAM ------------------------ - -If offsets 0070h to 0077h have 00h in them, then bankswitching is *not* -used. If one or more bytes are something other than 00h then bankswitching -is used. If bankswitching is used then the load address is still used, -but you now use (ADDRESS AND 0FFFh) to determine where on the first bank -to load the data. - - -Each bank is 4K in size, and that means there are 8 of them for the -entire 08000h-0ffffh range in the 6502's address space. You determine where -in memory the data goes by setting bytes 070h thru 077h in the file. -These determine the inital bank values that will be used, and hence where -the data will be loaded into the address space. - -Here's an example: - -METROID.NSF will be used for the following explaination. - -The file is set up like so: (starting at 070h in the file) - - -0070: 05 05 05 05 05 05 05 05 - 00 00 00 00 00 00 00 00 -0080: ... music data goes here... - -Since 0070h-0077h are something other than 00h, then we know that this -tune uses bankswitching. The load address for the data is specified as -08000h. We take this AND 0fffh and get 0000h, so we will load data in -at byte 0 of bank 0, since data is loaded into the banks sequentially -starting from bank 0 up until the music data is fully loaded. - -Metroid has 6 4K banks in it, numbered 0 through 5. The 6502's address -space has 8 4K bankswitchable blocks on it, starting at 08000h-08fffh, -09000h-09fffh, 0a000h-0afffh ... 0f000h-0ffffh. Each one of these is 4K in -size, and the current bank is controlled by writes to 05ff8h thru 05fffh, -one byte per bank. So, 05ff8h controls the 08000h-08fffh range, 05ff9h -controls the 09000h-09fffh range, etc. up to 05fffh which controls the -0f000h-0ffffh range. When the song is loaded into RAM, it is loaded into -the banks and not the 6502's address space. Once this is done, then the -bank control registers are written to set up the inital bank values. -To do this, the value at 0070h in the file is written to 05ff8h, 0071h -is written to 05ff9h, etc. all the way to 0077h is written to 05fffh. -This is should be done before every call to the init routine. - -If the tune was not bankswitched, then it is simply loaded in at the -specified load address, until EOF - - -Initalizing a tune ------------------- - -This is pretty simple. Load the desired song # into the accumulator, -minus 1 and set the X register to specify PAL (X=1) or NTSC (X=0). -If this is a single standard tune (i.e. PAL *or* NTSC but not both) -then the X register contents should not matter. Once the song # and -optional PAL/NTSC standard are loaded, simply call the INIT address. -Once init is done, it should perform an RTS. - - -Playing a tune --------------- - -Once the tune has been initalized, it can now be played. To do this, -simply call the play address several times a second. How many times -per second is determined by offsets 006eh and 006fh in the file. -These bytes denote the speed of playback in 1/1000000ths of a second. -For the "usual" 60Hz playback rate, set this to 411ah. - -To generate a differing playback rate, use this formula: - - - 1000000 -PBRATE= --------- - speed - -Where PBRATE is the value you stick into 006e/006fh in the file, and -speed is the desired speed in hertz. - - -"Proper" way to load the tune ------------------------------ - -1) If the tune is bankswitched, go to #3. - -2) Load the data into the 6502's address space starting at the specified - load address. Go to #4. - -3) Load the data into a RAM area, starting at (start_address AND 0fffh). - -4) Tune load is done. - - -"Proper" way to init a tune ---------------------------- - -1) Clear all RAM at 0000h-07ffh. - -2) Clear all RAM at 6000h-7fffh. - -3) Init the sound registers by writing 00h to 04000-0400Fh, 10h to 4010h, - and 00h to 4011h-4013h. - -4) Set volume register 04015h to 00fh. - -5) If this is a banked tune, load the bank values from the header into - 5ff8-5fffh. - -6) Set the accumulator and X registers for the desired song. - -7) Call the music init routine. - - -"Proper" way to play a tune ---------------------------- - -1) Call the play address of the music at periodic intervals determined - by the speed words. Which word to use is determined by which mode - you are in- PAL or NTSC. - - -Sound Chip Support ------------------- - -Byte 007bh of the file stores the sound chip flags. If a particular flag -is set, those sound registers should be enabled. If the flag is clear, -then those registers should be disabled. - -* VRCVI Uses registers 9000-9002, A000-A002, and B000-B002, write only. - -Caveats: 1) The above registers are *write only* and must not disrupt music - code that happens to be stored there. - - 2) Major caveat: The A0 and A1 lines are flipped on a few games!! - If you rip the music and it sounds all funny, flip around - the xxx1 and xxx2 register pairs. (i.e. 9001 and 9002) 9000 - and 9003 can be left untouched. I decided to do this since it - would make things easier all around, and this means you only - will have to change the music code in a very few places (6). - Esper2 and Madara will need this change, while Castlevania 3j - will not for instance. - - 3) See my VRCVI.TXT doc for a complete register description. - -* VRCVII Uses registers 9010 and 9030, write only. - -Caveats: 1) Same caveat as #1, above. - - 2) See my VRCVII.TXT doc for a complete register description. - -* FDS Sound uses registers from 4040 through 4092. - -Caveats: 1) 6000-DFFF is assumed to be RAM, since 6000-DFFF is RAM on the - FDS. E000-FFFF is usually not included in FDS games because - it is the BIOS ROM. However, it can be used on FDS rips to help - the ripper (for modified play/init addresses). - - 2) Bankswitching operates slightly different on FDS tunes. - 5FF6 and 5FF7 control the banks 6000-6FFF and 7000-7FFF - respectively. NSF header offsets 76h and 77h correspond to - *both* 6000-7FFF *AND* E000-FFFF. Keep this in mind! - -* MMC5 Sound Uses registers 5000-5015, write only as well as 5205 and 5206, - and 5C00-5FF5 - -Caveats: 1) Generating a proper doc file. Be patient. - - 2) 5205 and 5206 are a hardware 8*8 multiplier. The idea being - you write your two bytes to be multiplied into 5205 and 5206 - and after doing so, you read the result back out. Still working - on what exactly triggers it (I think a write to either 5205 - or 5206 triggers the multiply). - - 3) 5C00-5FF5 should be RAM to emulate EXRAM while in MMC5 mode. - -Note: Thanks to Mamiya for the EXRAM info. - - -* Namco 106 Sound Uses registers 4800 and F800. - - This works similar to VRC7. 4800 is the "data" port which is - readable and writable, while F800 is the "address" port and is - writable only. - - The address is 7 bits plus a "mode" bit. Bit 7 controls - address auto-incrementing. If bit 7 is set, the address will - auto-increment after a byte of data is read or written from/to - 4800. - - $40 ffffffff f:frequency L - $42 ffffffff f:frequency M - $44 ---sssff f:frequency H s:tone length (8-s)*4 in 4bit-samples - $46 tttttttt t:tone address(4bit-address,$41 means high-4bits of $20) - $47 -cccvvvv v:linear volume 1+c:number of channels in use($7F only) - $40-47:ch1 $48-4F:ch2 ... $78-7F:ch8 - ch2-ch8 same to ch1 - - $00-3F(8ch)...77(1ch) hhhhllll tone data - h:odd address data(signed 4bit) - l:even address data(signed 4bit) - - real frequency = (f * NES_BASECYCLES) / (40000h * (c+1) * (8-s)*4 * 45) - NES_BASECYCLES 21477270(Hz) - -Note: Very Special thanks to Mamiya for this information! - - -* Sunsoft FME-07 Sound uses registers C000 and E000 - - This is similar to the common AY 3-8910 sound chip that is - used on tons of arcade machines, and in the Intellivision. - - C000 is the address port - E000 is the data port - - Both are write-only, and behave like the AY 3-8910. - -Note: Special thanks to Mamiya for this information as well - - -Caveats -------- - -1) The starting song number and maximum song numbers start counting at - 1, while the init address of the tune starts counting at 0. To - "fix", simply pass the desired song number minus 1 to the init - routine. - -2) The NTSC speed word is used *only* for NTSC tunes, or dual PAL/NTSC tunes. - The PAL speed word is used *only* for PAL tunes, or dual PAL/NTSC tunes. - -3) The length of the text in the name, artist, and copyright fields must - be 31 characters or less! There has to be at least a single NULL byte - (00h) after the text, between fields. - -4) If a field is not known (name, artist, copyright) then the field must - contain the string "" (without quotes). - -5) There should be 8K of RAM present at 6000-7FFFh. MMC5 tunes need RAM at - 5C00-5FF7 to emulate its EXRAM. 8000-FFFF Should be read-only (not - writable) after a tune has loaded. The only time this area should be - writable is if an FDS tune is being played. - -6) Do not assume the state of *anything* on entry to the init routine - except A and X. Y can be anything, as can the flags. - -7) Do not assume the state of *anything* on entry to the play routine either. - Flags, X, A, and Y could be at any state. I've fixed about 10 tunes - because of this problem and the problem, above. - -8) The stack sits at 1FFh and grows down. Make sure the tune does not - attempt to use 1F0h-1FFh for variables. (Armed Dragon Villigust did and - I had to relocate its RAM usage to 2xx) - -9) Variables should sit in the 0000h-07FFh area *only*. If the tune writes - outside this range, say 1400h this is bad and should be relocated. - (Terminator 3 did this and I relocated it to 04xx). - -That's it! - - - diff --git a/branches/sdl2/documentation/tech/ppu/2c02 technical operation.txt b/branches/sdl2/documentation/tech/ppu/2c02 technical operation.txt deleted file mode 100644 index 3a79008b..00000000 --- a/branches/sdl2/documentation/tech/ppu/2c02 technical operation.txt +++ /dev/null @@ -1,296 +0,0 @@ -******************************* -*NTSC 2C02 technical operation* -******************************* -Brad Taylor (big_time_software@hotmail.com) - -1st release: Sept 25th, Y2K -2nd release: Jan 27th, 2K3 -3rd release: Feb 4th, 2K3 -4th release: Feb 19th, 2K3 - - - This document describes the low-level operation and technical details of the 2C02, the NES's PPU. In general, it contains important information in regards to PPU timing, which no NES coder/emulator author should be without. This document assumes that you already understand the basics of how the PPU works, like how the playfield/object images are generated, and the behaviour of scroll/address counters during playfield rendering. - - Alot of the concepts behind how the PPU works described here have been extracted from Nintendo's patent documentation (U.S.#4,824,106). With block diagrams of the PPU's architecture (and even some schematics), these papers will definetely aid in the comprehension of this complex device. - - Since the first release, this document has been given a major overhaul. Most sections of the document have been reworked, and new information has been added just about everywhere. If you've read the old version of this document before, I recommend that you read this new one in it's entirity; there's new information even in sections which may look like they haven't changed much. - - Topics discussed hereon are as follows. - - - Video signal generation - - PPU base timing - - Miscellanious PPU info - - PPU memory access cycles - - Frame rendering details - - Scanline rendering details - - In-range object evaluation - - Details of playfield render pipeline - - Details of object pattern fetch & render - - Extra cycle frames - - The MMC3's scanline counter - - PPU pixel priority quirk - - Graphical enhancements - - -+-------+ -|History| -+-------+ - On the weekend of Sept. 25th, Y2K, I setup an experiment with my NTSC NES MB & my PC so's I could RE the PPU's timing. What I did was (using a PC interface) analyse the changes that occur on the PPU's address and data pins on every rising & falling edge of the PPU's clock. I was not planning on removing the PPU from the motherboard (yet), so basically I just kept everything intact (minus the stuff I added onto the MB so I could monitor the PPU's signals), and popped in a game, so that it would initialize the PPU for me (I used DK classics, since it was only taking somthing like 4 frames before it was turning on the background/sprites). - - The only change I made was taking out the 21 MHz clock generator circuitry. To replace the clock signal, I connected a port controlled latch to the NES's main clock line instead. Now, by writing a 0 or a 1 out to an PC ISA port of my choice (I was using $104), I was able to control the 21 MHz clockline of the NES. After I would create a rise or a fall on the NES's clock line, I would then read in the data that appeared on the PPU's address and data pins, which included monitoring what PPU registers the game read/wrote to (& the data that was read/written). - - -+-----------------------+ -|Video signal generation| -+-----------------------+ - A 21.48 MHz clock signal is fed into the PPU. This is the NES's main clock line, which is shared by the CPU. - - Inside the PPU, the 21.48 MHz signal is used to clock a three-stage Johnson counter. The complimentery outputs of both master and slave portions of each stage are used to form 12 mutually exclusive output phases- all 3.58 MHz each (the NTSC colorburst). These 12 different phases form the basis of all color generation for the PPU's composite video output. - - Naturally, when the user programs the lower 4-bits of a palette register, they are essentially selecting any 1 of 12 phases to be routed to the PPU's video out pin (this corresponds to chrominance (tint/hue) video information) when the appropriate pixel indexes it. Other chrominance combinations (0 & 13) are simply hardwired to a 1 or 0 to generate grayscale pixels. - - Bits 4 & 5 of a palette entry selects 1 of 4 linear DC voltage offsets to apply to the selected chrominance signal (this corresponds to luminance (brightness) video information) for a pixel. - - Chrominance values 14 & 15 yield a black pixel color, regardless of any luminance value setting. - - Luminance value 0, mixed with chrominance value 13 yield a "blacker than black" pixel color. This super black pixel has an output voltage level close to the vertical/horizontal syncronization pulses. Because of this, some video monitors will display warped/distorted screens for games which use this color for black (Game Genie is the best example of this). Essentially what is happening is the video monitor's horizontal timing is compromised by what it thinks are extra syncronization pulses in the scanline. This is not damaging to the monitors which are effected by it, but use of the super black color should be avoided, due to the graphical distortion it causes. - - The amplitude of the selected chrominance signal (via the 4 lower bits of a palette register) remain constant regardless of bits 4 or 5. Thus it is not possible to adjust the saturation level of a particular color. - - -+---------------+ -|PPU base timing| -+---------------+ - Other than the 3-stage Johnson counter, the 21.48 MHz signal is not used directly by any other PPU hardware. Instead, the signal is divided by 4 to get 5.37 MHz, and is used as the smallest unit of timing in the PPU. All following references to PPU clock cycle (abbr. "cc") timing in this document will be in respect to this timing base, unless otherwise indicated. - - - Pixels are rendered at the same rate as the base PPU clock. In other words, 1 clock cycle= 1 pixel. - - - 341 PPU cc's make up the time of a typical scanline (or 341/3 CPU cc's). - - - One frame consists of 262 scanlines. This equals 341*262 PPU cc's per frame (divide by 3 for # of CPU cc's). - - -+------------------------+ -|PPU memory access cycles| -+------------------------+ - All PPU memory access cycles are 2 clocks long, and can be made back-to-back (typically done during rendering). Here's how the access breaks down: - - At the beginning of the access cycle, PPU address lines 8..13 are updated with the target address. This data remains here until the next time an access cycle occurs. - - The lower 8-bits of the PPU address lines are multiplexed with the data bus, to reduce the PPU's pin count. On the first clock cycle of the access, A0..A7 are put on the PPU's data bus, and the ALE (address latch enable) line is activated for the first half of the cycle. This loads the lower 8-bit address into an external 8-bit transparent latch strobed by ALE (74LS373 is used). - - On the second clock cycle, the /RD (or /WR) line is activated, and stays active for the entire cycle. Appropriate data is driven onto the bus during this time. - - -+----------------------+ -|Miscellanious PPU info| -+----------------------+ - - Sprite DMA is 1536 clock cycles long (512 CPU cc's). 256 individual transfers are made from CPU memory to a temp register inside the CPU, then from the CPU's temp reg, to $2004. - - - The PPU makes NO external access to the PPU bus, unless the playfield or objects are enabled during a scanline outside vblank. This means that the PPU's address and data busses are dead while in this state. - - - palette RAM is accessed internally during playfield rendering (i.e., the palette address/data is never put on the PPU bus during this time). Additionally, when the programmer accesses palette RAM via $2006/7, the palette address accessed actually does show up on the PPU address bus, but the PPU's /RD & /WR flags are not activated. This is required; to prevent writing over name table data falling under the approprite mirrored area (since the name table RAM's address decoder simply consists of an inverter connected to the A13 line- effectively decoding all addresses in $2000-$3FFF). - - - the VINT impulse (NMI) and bit $2002.7 are set simultaniously. Reading $2002 will reset bit 7, but it seems that the VINT flag goes down on it's own. Because of this, when the PPU generates a VINT, it doesn't require any acknowledgement whatsoever; it will continue firing off VINTs, regardless of inservice to $2002. The only way to stop VINTs is to clear $2000.7. - - - Because the PPU cannot make a read from PPU memory immediately upon request (via $2007), there is an internal buffer, which acts as a 1-stage data pipeline. As a read is requested, the contents of the read buffer are returned to the NES's CPU. After this, at the PPU's earliest convience (according to PPU read cycle timings), the PPU will fetch the requested data from the PPU memory, and throw it in the read buffer. Writes to PPU mem via $2007 are pipelined as well, but it is unknown to me if the PPU uses this same buffer (this could be easily tested by writing somthing to $2007, and seeing if the same value is returned immediately after reading). - - -+-----------------------+ -|Frame rendering details| -+-----------------------+ - The following describes the PPU's status during all 262 scanlines of a frame. Any scanlines where work is done (like image rendering), consists of the steps which will be described in the next section. - - 0..19: Starting at the instant the VINT flag is pulled down (when a NMI is generated), 20 scanlines make up the period of time on the PPU which I like to call the VINT period. During this time, the PPU makes no access to it's external memory (i.e. name / pattern tables, etc.). - - 20: After 20 scanlines worth of time go by (since the VINT flag was set), the PPU starts to render scanlines. This first scanline is a dummy one; although it will access it's external memory in the same sequence it would for drawing a valid scanline, no on-screen pixels are rendered during this time, making the fetched background data immaterial. Both horizontal *and* vertical scroll counters are updated (presumably) at cc offset 256 in this scanline. Other than that, the operation of this scanline is identical to any other. The primary reason this scanline exists is to start the object render pipeline, since it takes 256 cc's worth of time to determine which objects are in range or not for any particular scanline. - - 21..260: after rendering 1 dummy scanline, the PPU starts to render the actual data to be displayed on the screen. This is done for 240 scanlines, of course. - - 261: after the very last rendered scanline finishes, the PPU does nothing for 1 scanline (i.e. the programmer gets screwed out of perfectly good VINT time). When this scanline finishes, the VINT flag is set, and the process of drawing lines starts all over again. - - -+--------------------------+ -|Scanline rendering details| -+--------------------------+ - Naturally, the PPU will fetch data from name, attribute, and pattern tables during a scanline to produce an image on the screen. This section details the PPU's doings during this time. - - As explained before, external PPU memory can be accessed every 2 cc's. With 341 cc's per scanline, this gives the PPU enough time to make 170 memory accesses per scanline (and it uses all of them!). After the 170th fetch, the PPU does nothing for 1 clock cycle. Remember that a single pixel is rendered every clock cycle. - - - Memory fetch phase 1 thru 128 - ----------------------------- - 1. Name table byte - 2. Attribute table byte - 3. Pattern table bitmap #0 - 4. Pattern table bitmap #1 - - This process is repeated 32 times (32 tiles in a scanline). - - - This is when the PPU retrieves the appropriate data from PPU memory for rendering the playfield. The first playfield tile fetched here is actually the 3rd to be drawn on the screen (the playfield data for the first 2 tiles to be rendered on this scanline are fetched at the end of the scanline prior to this one). - - All valid on-screen pixel data arrives at the PPU's video out pin during this time (256 clocks). For determining the precise delay between when a tile's bitmap fetch phase starts (the whole 4 memory fetches), and when the first pixel of that tile's bitmap data hits the video out pin, the formula is (16-n) clock cycles, where n is the fine horizontal scroll offset (0..7 pixels). This information is relivant for understanding the exact timing operation of the "object 0 collision" flag. - - Note that the PPU fetches an attribute table byte for every 8 sequential horizontal pixels it draws. This essentially limits the PPU's color area (the area of pixels which are forced to use the same 3-color palette) to only 8 horizontally sequential pixels. - - It is also during this time that the PPU evaluates the "Y coordinate" entries of all 64 objects in object attribute RAM (OAM), to see if the objects are within range (to be drawn on the screen) for the *next* scanline (this is why Y-coordinate entries in the OAM must be programmed to a value 1 less than the scanline the object is to appear on). Each evaluation (presumably) takes 4 clock cycles, for a total of 256 (which is why it's done during on-screen pixel rendering). - - - In-range object evaluation - -------------------------- - An 8-bit comparator is used to calculate the 9-bit difference between the current scanline (minus 21), and each Y-coordinate (plus 1) of every object entry in the OAM. Objects are considered in range if the comparator produces a difference in the range of 0..7 (if $2000.5 currently = 0), or 0..15 (if $2000.5 currently = 1). - - (Note that a 9-bit comparison result is generated. This means that setting object scanline coordinates for ranges -1..-15 are actually interpreted as ranges 241..255. For this reason, objects with these ranges will never be considered to be part of any on-screen scanline range, and will not allow smooth object scrolling off the top of the screen.) - - Tile index (8 bits), X-coordinate (8 bits), & attribute information (4 bits; vertical inversion is excluded) from the in-range OAM element, plus the associated 4-bit result of the range comparison accumulate in a part of the PPU called the "sprite temporary memory". Logical inversion is applied to the loaded 4-bit range comparison result, if the object's vertical inversion attribute bit is set. - - Since object range evaluations occur sequentially through the OAM (starting from entry 0 to 63), the sprite temporary memory always fills in order from the highest priority in-range object, to lower ones. A 4-bit "in-range" counter is used to determine the number of found objects on the scanline (from 0 up to 8), and serves as an index pointer for placement of found object data into the 8-element sprite temporary memory. The counter is reset at the beginning of the object evaluation phase, and is post-incremented everytime an object is found in-range. This occurs until the counter equals 8, when found object data after this is discarded, and a flag (bit 5 of $2002) is raised, indicating that it is going to be dropping objects for the next scanline. - - An additional memory bit associated with the sprite temporary memory is used to indicate that the primary object (#0) was found to be in range. This will be used later on to detect primary object-to-playfield pixel collisions. - - - Playfield render pipeline details - --------------------------------- - As pattern table & palette select data is fetched, it is loaded into internal latches (the palette select data is selected from the fetched byte via a 2-bit 1-of-4 selector). - - At the start of a new tile fetch phase (every 8 cc's), both latched pattern table bitmaps are loaded into the upper 8-bits of 2- 16-bit shift registers (which both shift right every clock cycle). The palette select data is also transfered into another latch during this time (which feeds the serial inputs of 2 8-bit right shift registers shifted every clock). The pixel data is fed into these extra shift registers in order to implement fine horizontal scrolling, since the periods when the PPU fetch tile data is fixed. - - A single bit from each shift register is selected, to form the valid 4-bit playfield pixel for the current clock cycle. The bit selection offset is based on the fine horizontal scroll value (this selects bit positions 0..7 for all 4 shift registers). The selected 4-bit pixel data will then be fed into the multiplexer (described later) to be mixed with object data. - - - Memory fetch phase 129 thru 160 - ------------------------------- - 1. Garbage name table byte - 2. Garbage name table byte - 3. Pattern table bitmap #0 for applicable object (for next scanline) - 4. Pattern table bitmap #1 for applicable object (for next scanline) - - This process is repeated 8 times. - - - This is the period of time when the PPU retrieves the appropriate pattern table data for the objects to be drawn on the *next* scanline. When less than 8 objects exist on the next scanline (as the in-range object evaluation counter indicates), dummy pattern table fetches take place for the remaining fetches. Internally, the fetched dummy-data is discarded, and replaced with completely transparent bitmap patterns). - - Although the fetched name table data is thrown away, and the name table address is somewhat unpredictable, the address does seem to relate to the first name table tile to be fetched for the next scanline. This would seem to imply that PPU cc #256 is when the PPU's scroll/address counters have their horizontal scroll values automatically updated. - - It should also be noted that because this fetch is required for objects on the next scanline, it is neccessary for a garbage scanline to exist prior to the very first scanline to be actually rendered, so that object attribute RAM entries can be evaluated, and the appropriate bitmap data retrieved. - - As far as the wasted fetch phases here, well, what can I say. Either Nintendo's engineers were VERY lazy, and didn't want to add the small amount of extra circuitry to the PPU so that 16 object fetches could take place per scanline, or Nintendo couldn't spot the extra memory required to implement 16 object scanlines. Thing is though- between the object attribute mem, sprite temporary & buffer mem, and palette mem, that's already 2406 bits of RAM; I don't think it would've killed them to just add the 408 bits it would've took for an extra 8 objects, which would've made games with horrible OAM cycling (Double Dragon 2 w/ 2 players) look half-decent (hell, with 16 object scanlines, games would hardly even need OAM cycling). - - - Details of object pattern fetch & render - ---------------------------------------- - Where the PPU fetches pattern table data for an individual object is conditioned on the contents of the sprite temporary memory element, and $2000.5. If $2000.5 = 0, the tile index data is used as usual, and $2000.3 selects the pattern table to use. If $2000.5 = 1, the MSB of the range result value become the LSB of the indexed tile, and the LSB of the tile index value determines pattern table selection. The lower 3 bits of the range result value are always used as the fine vertical offset into the selected pattern. - - Horizontal inversion (bit order reversing) is applied to fetched bitmaps, if indicated in the sprite temporary memory element. - - The fetched pattern table data (which is 2 bytes), plus the associated 3 attribute bits (palette select & priority), and the x coordinate byte in sprite temporary memory are then loaded into a part of the PPU called the "sprite buffer memory" (the primary object present bit is also copied). This memory area again, is large enough to hold the contents for 8 sprites. - - The composition of one sprite buffer element here is: 2 8-bit shift registers (the fetched pattern table data is loaded in here, where it will be serialized at the appropriate time), a 3-bit latch (which holds the color & priority data for an object), and an 8-bit down counter (this is where the x coordinate is loaded). - - The counter is decremented every time the PPU renders a pixel (the first 256 cc's of a scanline; see "Memory fetch phase 1 thru 128" above). When the counter equals 0, the pattern table data in the shift registers will start to serialize (1 shift per clock). Before this time, or 8 clocks after, consider the outputs of the serializers for each stage to be 0 (transparency). - - The streams of all 8 object serializers are prioritized, and ultimately only one stream (with palette select & priority information) is selected for output to the multiplexer (where object & playfield pixels are prioritized). - - The data for the first sprite buffer entry (including the primary object present flag) has the first chance to enter the multiplexer, if it's output pixel is non-transparent (non-zero). Otherwise, priority is passed to the next serializer in the sprite buffer memory, and the test for non-transparency is made again (the primary object present status will always be passed to the multiplexer as false in this case). This is done until the last (8th) stage is reached, when the object data is passed through unconditionally. Keep in mind that this whole process occurs every clock cycle (hardware is used to determine priority instantly). - - The multiplexer does 2 things: determines primary object collisions, and decides which pixel data to pass through to index the palette RAM- either the playfield's or the object's. - - Primary object collisions occur when a non-transparent playfield pixel coincides with a non-transparent object pixel, while the primary object present status entering the multiplexer for the current clock cycle is true. This causes a flip-flop ($2002.6) to be set, and remains set (presumably) some time after the VINT occurence (prehaps up until scanline 20?). - - The decision for selecting the data to pass through to the palette index is made rather easilly. The condition to use object (opposed to playfield) data is: - - (OBJpri=foreground OR PFpixel=xparent) AND OBJpixel<>xparent - - Since the PPU has 2 palettes; one for objects, and one for playfield, the appropriate palette will be selected depending on which pixel data is passed through. - - After the palette look-up, the operation of events follows the aforementioned steps in the "video signal generation" section. - - - Memory fetch phase 161 thru 168 - ------------------------------- - 1. Name table byte - 2. Attribute table byte - 3. Pattern table bitmap #0 (for next scanline) - 4. Pattern table bitmap #1 (for next scanline) - - This process is repeated 2 times. - - - It is during this time that the PPU fetches the appliciable playfield data for the first and second tiles to be rendered on the screen for the *next* scanline. These fetches initialize the internal playfield pixel pipelines (2- 16-bit shift registers) with valid bitmap data. The rest of tiles (3..32) are fetched at the beginning of the following scanline. - - - Memory fetch phase 169 thru 170 - ------------------------------- - 1. Name table byte - 2. Name table byte - - - I'm unclear of the reason why this particular access to memory is made. The name table address that is accessed 2 times in a row here, is also the same nametable address that points to the 3rd tile to be rendered on the screen (or basically, the first name table address that will be accessed when the PPU is fetching playfield data on the next scanline). - - - After memory access 170 - ----------------------- - The PPU simply rests for 1 cycle here (or the equivelant of half a memory access cycle) before repeating the whole pixel/scanline rendering process. - - -+------------------+ -|Extra cycle frames| -+------------------+ - Scanline 20 is the only scanline that has variable length. On every odd frame, this scanline is only 340 cycles (the dead cycle at the end is removed). This is done to cause a shift in the NTSC colorburst phase. - - You see, a 3.58 MHz signal, the NTSC colorburst, is required to be modulated into a luminance carrying signal in order for color to be generated on an NTSC monitor. Since the PPU's video out consists of basically square waves (as opposed to sine waves, which would be preferred), it takes an entire colorburst cycle (1/3.58 MHz) for an NTSC monitor to identify the color of a PPU pixel accurately. - - But now you remember that the PPU renders pixels at 5.37 MHz- 1.5x the rate of the colorburst. This means that if a single pixel resides on a scanline with a color different to those surrounding it, the pixel will probably be misrepresented on the screen, sometimes appearing faintly. - - Well, to somewhat fix this problem, they added this extra pixel into every odd frame (shifting the colorburst phase over a bit), and changing the way the monitor interprets isolated colored pixels each frame. This is why when you play games with detailed background graphics, the background seems to flicker a bit. Once you start scrolling the screen however, it seems as if some pixels become invisible; this is how stationary PPU images would look without this cycle removed from odd frames. - - Certain scroll rates expose this NTSC PPU color caveat regardless of the toggling phase shift. Some of Zelda 2's dungeon backgrounds are a good place to see this effect. - - -+---------------------------+ -|The MMC3's scanline counter| -+---------------------------+ - As most people know, the MMC3 bases it's scanline counter on PPU address line A13 (which is why IRQ's can be fired off manually by toggling A13 a bunch of times via $2006). What's not common knowledge is the number of times A13 is expected to toggle in a scanline (although if you've been paying close attention to the doc here, you should already know ;) - - A13 was probably used for the IRQ counter (as opposed to using the PPU's /READ line) because this address line already needed to be connected to the MMC for bankswitching purposes (so in other words, to reduce the MMC3's pin count by 1). They also probably used this method of counting (as opposed to a CPU cycle counter) since A13 cycles (0 -> 1) exactly 42 times per scanline, whereas the CPU count of cycles per scanline is not an exact integer (113.67). Having said that, I guess Nintendo wanted to provide an "easy-to-use" method of generating special image effects, without making programmers have to figure out how many clock cycles to program an IRQ counter with (a pretty lame excuse for not providing an IRQ counter with CPU clock cycle precision (which would have been more useful and versatile)). - - Regardless of any values PPU registers are programmed with, A13 will operate in a predictable fashion during image rendering (and if you understand how PPU addressing works, you should understand that A13 is the *only* address line with fixed behaviour during image rendering). - - -+------------------------+ -|PPU pixel priority quirk| -+------------------------+ - Object data is prioritized between itself, then prioritized between the playfield. There are some odd side effects to this scheme of rendering, however. For instance, imagine a low priority object pixel with foreground priority, a high priority object pixel with background priority, and a playfield pixel all coinciding (all non-transparent). - - Ideally, the playfield is considered to be the middle layer between background and foreground priority objects. This means that the playfield pixel should hide the background priority object pixel (regardless of object priority), and the foreground priority object should appear atop the PF pixel. - - However, because of the way the PPU renders (as just described), OBJ priority is evaluated first, and therefore the background object pixel wins, which means that you'll only be seeing the PF pixel after this mess. - - A good game to demonstrate this behaviour is Megaman 2. Go into airman's stage. First, jump into the energy bar, just to confirm that megaman's sprite is of a higher priority than the energy bar's. Now, get to the second half of the stage, where the clouds cover the energy bar. The energy bar will be ontop of the clouds, but megaman will be behind them. Now, look what happens when you jump into the energy bar here... you see the clouds where megaman underlaps the energy bar. - - -+----------------------+ -|Graphical enhancements| -+----------------------+ - Since an NES cartridge has access to the PPU bus, any number of on-cart hardware schemes can be used to enhance the graphic capabilities of the NES. After all, the PPU's playfield pipeline is very simple: it fetches 272 playfield pixels per scanline (as 34*2 byte fetches, in real-time), and outputs 256 of them to the screen (with the 0..7 pixel offset determined by the fine X scroll register), along with object data combined with it. - - Essentially, you can bypass the PPU's simple scrolling system, implement a custom one on your cart (fetching bitmap data in your own fashion), and feed the PPU bitmap data in your own order. - - The possibilities of this are endless (like sporting multiple playfields, or even playfield rotation/scaling), but of course what it comes down to is the amount of cartridge hardware required. - - Generally, playfield rotation/scaling can be done quite easily- it only requires a few sets of 16-bit registers and adders (the 16 bits are broken up into 8.8 fixed point values). But this kind of implementation is more suited for an integrated circuit, since this would require dozens of discrete logic chips. - - Multiple playfields are another thing which could be easily done. The caveat here is that pixel pipelines (i.e., shift registers) and a multiplexer would have to be implemented on the cart (not to mention exclusive name table RAM) in order to process the playfield bitmaps from multiple sources. The access to the CHR-ROM/RAM would also have to increased- but as it stands, the CHR-ROM/RAM bandwidth is 1.34 MHz, a rather low frequency. With a memory device capable of a 10.74 MHz bandwith, you could have 8 playfields to work with. Generally, this would be very useful for displaying multiple huge objects on the screen- without ever having to worry about annoying flicker. - - The only restriction to doing any of this is that: - - - every 8 sequential horizontal pixels sent to the PPU must share the same palette select value. Because of this, hardware would have to be implemented to decide which palette select value to feed the PPU between 8 horizontally sequential pixels, if they do not all share the same palette select value. The on-screen results of this may not be too flattering sometimes, but this is a small price to pay to do some neat graphical tricks on the NES. - - -only the playfield palette can be used. As usual, this pretty much limits your randomly accessable colors to about 12+1. - - It's a damn shame that Nintendo never created a MMC which would enhance graphics on the NES in useful ways as mentioned above. The MMC5 was the only device that came close, and it's only selling features were the single-tile color area, and the vertical split screen mode (which I don't think any game ever used). Considering the amount of pins (100) the MMC5 had, and number of gates they put in it just for the EXRAM (which was 1K bytes), they could've put some really useful graphics hardware inside there instead. - - Prehaps the infamous Color Dreams "Hellraiser" cart was the closest the NES ever came to seeing such sophisticated graphics. The cart was never released, but from what I've read, it was going to use some sort of frame buffer, and a Z80 CPU to do the graphical rendering. It had been rumored that the game had 3D graphics (or at least 2.5D) in it. If so (and the game was actually good), prehaps it would have raised a few eyebrows in the industry, and inspired Nintendo to develop a new MMC chip with similar capabilities, in order to keep the NES in it's profit margin for another few years (and allow it to compete somewhat with the more advanced systems of the time). - -EOF \ No newline at end of file diff --git a/branches/sdl2/documentation/tech/ppu/loopy1.txt b/branches/sdl2/documentation/tech/ppu/loopy1.txt deleted file mode 100644 index bda6d852..00000000 --- a/branches/sdl2/documentation/tech/ppu/loopy1.txt +++ /dev/null @@ -1,63 +0,0 @@ -Subject: [nesdev] the skinny on nes scrolling -Date: Tue, 13 Apr 1999 16:42:00 -0600 -From: loopy -Reply-To: nesdev@onelist.com -To: nesdev@onelist.com - -From: loopy - ---------- -the current information on background scrolling is sufficient for most games; -however, there are a few that require a more complete understanding. - -here are the related registers: - (v) vram address, a.k.a. 2006 which we all know and love. (16 bits) - (t) another temp vram address (16 bits) - (you can really call them 15 bits, the last isn't used) - (x) tile X offset (3 bits) - -the ppu uses the vram address for both reading/writing to vram thru 2007, -and for fetching nametable data to draw the background. as it's drawing the -background, it updates the address to point to the nametable data currently -being drawn. bits 0-11 hold the nametable address (-$2000). bits 12-14 are -the tile Y offset. - ---------- -stuff that affects register contents: -(sorry for the shorthand logic but i think it's easier to see this way) - -2000 write: - t:0000110000000000=d:00000011 -2005 first write: - t:0000000000011111=d:11111000 - x=d:00000111 -2005 second write: - t:0000001111100000=d:11111000 - t:0111000000000000=d:00000111 -2006 first write: - t:0011111100000000=d:00111111 - t:1100000000000000=0 -2006 second write: - t:0000000011111111=d:11111111 - v=t -scanline start (if background and sprites are enabled): - v:0000010000011111=t:0000010000011111 -frame start (line 0) (if background and sprites are enabled): - v=t - -note! 2005 and 2006 share the toggle that selects between first/second -writes. reading 2002 will clear it. - -note! all of this info agrees with the tests i've run on a real nes. BUT -if there's something you don't agree with, please let me know so i can verify -it. - -________________________________________________________ -NetZero - We believe in a FREE Internet. Shouldn't you? -Get your FREE Internet Access and Email at -http://www.netzero.net/download.html - ------------------------------------------------------------------------- -New hobbies? New curiosities? New enthusiasms? -http://www.ONElist.com -Sign up for a new e-mail list today! diff --git a/branches/sdl2/documentation/tech/ppu/loopy2.txt b/branches/sdl2/documentation/tech/ppu/loopy2.txt deleted file mode 100644 index 7a4585e1..00000000 --- a/branches/sdl2/documentation/tech/ppu/loopy2.txt +++ /dev/null @@ -1,33 +0,0 @@ -Subject: [nesdev] Re: the skinny on nes scrolling -Date: Tue, 13 Apr 1999 17:48:54 -0600 -From: loopy -Reply-To: nesdev@onelist.com -To: nesdev@onelist.com - -From: loopy - -(more notes on ppu logic) - -you can think of bits 0,1,2,3,4 of the vram address as the "x scroll"(*8) -that the ppu increments as it draws. as it wraps from 31 to 0, bit 10 is -switched. you should see how this causes horizontal wrapping between name -tables (0,1) and (2,3). - -you can think of bits 5,6,7,8,9 as the "y scroll"(*8). this functions -slightly different from the X. it wraps to 0 and bit 11 is switched when -it's incremented from _29_ instead of 31. there are some odd side effects -from this.. if you manually set the value above 29 (from either 2005 or -2006), the wrapping from 29 obviously won't happen, and attrib data will be -used as name table data. the "y scroll" still wraps to 0 from 31, but -without switching bit 11. this explains why writing 240+ to 'Y' in 2005 -appeared as a negative scroll value. - -________________________________________________________ -NetZero - We believe in a FREE Internet. Shouldn't you? -Get your FREE Internet Access and Email at -http://www.netzero.net/download.html - ------------------------------------------------------------------------- -Looking for a new hobby? Want to make a new friend? -http://www.ONElist.com -Come join one of the 115,000 e-mail communities at ONElist! diff --git a/branches/sdl2/documentation/tech/readme.now b/branches/sdl2/documentation/tech/readme.now deleted file mode 100644 index 4575e0c6..00000000 --- a/branches/sdl2/documentation/tech/readme.now +++ /dev/null @@ -1,6 +0,0 @@ -Many(possibly all) of these documents contain flaws or are incomplete, so -don't pull out your hair if there are inconsistencies between the documents, -what's in FCE Ultra, and what you observe. That's not to say that FCE Ultra -doesn't have its share of (emulation) flaws, though... - -For many more NES-related documents, try http://nesdev.parodius.com diff --git a/branches/sdl2/documentation/tech/readme.sound b/branches/sdl2/documentation/tech/readme.sound deleted file mode 100644 index cce95040..00000000 --- a/branches/sdl2/documentation/tech/readme.sound +++ /dev/null @@ -1,2 +0,0 @@ -Sound information is in the "cpu" subdirectory, due to the intimate -relationship between the sound circuitry and the cpu. diff --git a/branches/sdl2/documentation/todo b/branches/sdl2/documentation/todo deleted file mode 100644 index 5a1131dd..00000000 --- a/branches/sdl2/documentation/todo +++ /dev/null @@ -1,70 +0,0 @@ -The following games are broken to some extent: - -Crystalis: Mostly working, but the screen jumps around during - dialogue. It apparently resets the MMC3 IRQ counter - mid-scanline. It'll require low-level PPU and MMC3 - IRQ counter emulation to function properly. -Kyoro Chan Land: Expects a sprite hit to happen, but it has sprite 0 over - transparent background. - -*** First, things that are not on the TODO list(Don't bug me about these - things if you're an idiot. I don't like listening to idiots. - If you are not an idiot, and you can make decent arguments for why - these should be on the TODO list, then you can bug me.). - -*** General Features: - - Remappable command keys(to multiple keys on the keyboard and a joystick). - - Fix possible UNIF crashes(if no PRGx or CHRx chunks exist, it may crash, - due to changes made in 0.92). - - Windows Port: - Support for command-line options(so that one crazy guy will quit bugging - me). - - SDL Port: - Hotkey remap GUI - - Figure out a good way to add "turbo" button support and then do it. - - Make default svgalib video mode a non-tweaked VGA mode. - - Finish the software video blitting "library", add support for 2xsai, eagle, - interpolation, etc. effects. - - -*** Emulation: - - - ***IMPORTANT*** - If anyone ever cares to implement movie recording/playback, we must figure - out what to do with some unsaved variables, like timestamp and timestampbase. - These variables are abused in the sound emulation code, and modifying them - in certain ways elsewhere can cause crashes. - ***IMPORTANT*** - - Implement cart-based expansion devices, and interfaces for them(dip switches - and that Datach barcode reader, and maybe others). - - Fix DPCM playback and IRQ at end of playback. - - Fix some 6502 emulation bugs(undocumented opcodes might not be implemented - correctly and I'm not sure if the IRQ flag latency is implemented correctly). - - Implement more dummy CPU reads when in debug mode. - - Fix MMC3 IRQ emulation. - - Figure out correct timing for when the PPU refresh address register is - updated by the PPU(for the next scanline). - - Sound frame count stuff on PAL games(is it correct?). - - Fix FDS sound emulation. - - Fix NMI timing and D7 of 2002 setting timing. Fixing this might require - a small hack. Also be aware that this might break Battletoads, particularly - during the second level. - - Fix Zapper emulation(Chiller still doesn't always work correctly). diff --git a/branches/sdl2/doxygen b/branches/sdl2/doxygen deleted file mode 100644 index 580671e2..00000000 --- a/branches/sdl2/doxygen +++ /dev/null @@ -1,1237 +0,0 @@ -# Doxyfile 1.4.6 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = docs - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = src src/boards src/drivers/common src/drivers/win src/drivers/sdl src/input src/utils - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.cpp *.h *.c *.inc - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/branches/sdl2/fceux-server/.gitignore b/branches/sdl2/fceux-server/.gitignore deleted file mode 100644 index 674deb69..00000000 --- a/branches/sdl2/fceux-server/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# A simulation of Subversion default ignores, generated by reposurgeon. -*.o -*.lo -*.la -*.al -*.libs -*.so -*.so.[0-9]* -*.a -*.pyc -*.pyo -*.rej -*~ -*.#* -.*.swp -.DS_store -# Simulated Subversion default ignores end here diff --git a/branches/sdl2/fceux-server/AUTHORS b/branches/sdl2/fceux-server/AUTHORS deleted file mode 100644 index 0888cb48..00000000 --- a/branches/sdl2/fceux-server/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Major developer: Xodnizel -Interface changes and all releases past 0.0.3: Lukas Sabota diff --git a/branches/sdl2/fceux-server/COPYING b/branches/sdl2/fceux-server/COPYING deleted file mode 100644 index d159169d..00000000 --- a/branches/sdl2/fceux-server/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/branches/sdl2/fceux-server/ChangeLog b/branches/sdl2/fceux-server/ChangeLog deleted file mode 100644 index 89dde3c4..00000000 --- a/branches/sdl2/fceux-server/ChangeLog +++ /dev/null @@ -1,30 +0,0 @@ -0.0.5: - Interface received massive overhaul. Now takes command line - options. This will allow the server to communicate with - other front-ends. Integration can now occur in gfceu. - -0.0.4: - Renamed from "server" to "fceu-server". - Renamed standard.conf -> fceu-standard.conf - If no configuration file is specified, look in /etc and ./ - Added a --help option. - Added GPL headers - -0.0.3: - Error messages during server startup are more verbose(slightly). - - Fixed initialization of the sockaddr_in structure, sin_family - member. It's now initialized to AF_INET before calling bind(). - While not initializing that member seemed to work ok on - Linux 2.4, it won't work on Linux 2.2 and under Cygwin, - and possibly other environments. - -0.0.2: - Switched to using fcntl() to set the socket to nonblocking, - so I don't need to use MSG_NOWAIT in send() anymore, which is - undefined under Cygwin. - - Added a "clean" Makefile target. - -0.0.1: - First Release diff --git a/branches/sdl2/fceux-server/Makefile b/branches/sdl2/fceux-server/Makefile deleted file mode 100644 index 02d07f07..00000000 --- a/branches/sdl2/fceux-server/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -PREFIX = /usr -OUTFILE = fceux-net-server - -CC = g++ -OBJS = server.o md5.o throttle.o - - -all: ${OBJS} - ${CC} -o ${OUTFILE} ${OBJS} - -clean: - rm -f ${OUTFILE} ${OBJS} - -install: - install -m 755 -D fceux-net-server ${PREFIX}/bin/fceux-server - install -m 644 -D fceux-server.conf /etc/fceux-server.conf - -server.o: server.cpp -md5.o: md5.cpp -throttle.o: throttle.cpp diff --git a/branches/sdl2/fceux-server/README b/branches/sdl2/fceux-server/README deleted file mode 100644 index d32988e5..00000000 --- a/branches/sdl2/fceux-server/README +++ /dev/null @@ -1,53 +0,0 @@ -FCE Ultra Network Play Server v0.0.5 ------------------------------------- - -To compile, type this in the shell: -$ make -To install, type this in this shell: -$ sudo make install -To run, type this in shell: -$ ./fceu-server - -To compile under MS Windows, you should use Cygwin. I'm not -going to change this server to use Win-old-dirty-smelly-sock natively. - -There are known issues with running fceux-server in mac OSX. As a (somewhat extensive) workaround, you can run the server inside a Linux VM in bridged network mode. - -If it doesn't compile, sell your to the -. - -Most beings can run it like "./fceu-server >logfile &". -Windows users can run it some other way. A batch file with absolute paths, perhaps? - snuggums.bat: - C:\somethingdirectory\server.exe c:\somethingdirectory\standard.conf - -With the default settings, each client should use about 65-70Kbps, excluding any -data transferred during chat, state loads, etc(which should be negligible, but limits -will be placed on these types of transfers in the future). - -Clients connecting with high-latency or slow links may use more bandwidth, or they -may use less bandwidth. I'm really not quite sure. If it concerns you, test it. - -Any client connecting over VERY high latency links, such as bidirectional satellite connections, -may find that attempting network play will lock up his/her connection for -several minutes. Right, Disch. ;) - -The server probably won't scale well to a huge number of clients connected at the same time. - -Bumping up the server's priority and running it on a low-latency kernel(preferably with -1 ms or smaller timeslices) should help make network play more usable if you're running the -network play server on an otherwise non-idle physical server. - - - -TODO: - -Implement a more flexible timing system, so that PAL games will be playable. - -Change the protocol to allow the client to specify the size of input update information, -so devices like the powerpad or zapper can work over network play. - -Send emulation info, such as NTSC/PAL, input devices, and Game Genie emulation at connect -time, to make it easier on end users. - - diff --git a/branches/sdl2/fceux-server/cygwin1.dll b/branches/sdl2/fceux-server/cygwin1.dll deleted file mode 100644 index 116037f1..00000000 Binary files a/branches/sdl2/fceux-server/cygwin1.dll and /dev/null differ diff --git a/branches/sdl2/fceux-server/dist/fceu-server-0.0.4.tar.gz b/branches/sdl2/fceux-server/dist/fceu-server-0.0.4.tar.gz deleted file mode 100644 index a7850742..00000000 Binary files a/branches/sdl2/fceux-server/dist/fceu-server-0.0.4.tar.gz and /dev/null differ diff --git a/branches/sdl2/fceux-server/dist/fceu-server-0.0.5.tar.gz b/branches/sdl2/fceux-server/dist/fceu-server-0.0.5.tar.gz deleted file mode 100644 index 95269b77..00000000 Binary files a/branches/sdl2/fceux-server/dist/fceu-server-0.0.5.tar.gz and /dev/null differ diff --git a/branches/sdl2/fceux-server/dist/fceunetserver-0.0.3.tar.bz2 b/branches/sdl2/fceux-server/dist/fceunetserver-0.0.3.tar.bz2 deleted file mode 100644 index 8d108224..00000000 Binary files a/branches/sdl2/fceux-server/dist/fceunetserver-0.0.3.tar.bz2 and /dev/null differ diff --git a/branches/sdl2/fceux-server/fceux-net-server.exe b/branches/sdl2/fceux-server/fceux-net-server.exe deleted file mode 100644 index 780f6a47..00000000 Binary files a/branches/sdl2/fceux-server/fceux-net-server.exe and /dev/null differ diff --git a/branches/sdl2/fceux-server/fceux-server.conf b/branches/sdl2/fceux-server/fceux-server.conf deleted file mode 100644 index 9c71a224..00000000 --- a/branches/sdl2/fceux-server/fceux-server.conf +++ /dev/null @@ -1,5 +0,0 @@ -maxclients 100 ; Maximum number of clients -connecttimeout 5 ; Connection(login) timeout -framedivisor 1 ; Frame divisor(eg: 60 / framedivisor updates per second) -port 4046 ; Port to listen on -;password sexybeef diff --git a/branches/sdl2/fceux-server/md5.cpp b/branches/sdl2/fceux-server/md5.cpp deleted file mode 100644 index e00f8269..00000000 --- a/branches/sdl2/fceux-server/md5.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* FCE Ultra Network Play Server - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * */ - -/* - * RFC 1321 compliant MD5 implementation, - * by Christophe Devine ; - * this program is licensed under the GPL. - */ - -/* Modified October 3, 2003, to remove testing code, and add - include of "types.h". - - Added simple MD5 to ASCII string conversion function. - -Xodnizel -*/ - - - - -#include -#include "types.h" -#include "md5.h" - -#define GET_UINT32(n,b,i) \ -{ \ - (n) = ( (uint32) (b)[(i) + 3] << 24 ) \ - | ( (uint32) (b)[(i) + 2] << 16 ) \ - | ( (uint32) (b)[(i) + 1] << 8 ) \ - | ( (uint32) (b)[(i) ] ); \ -} - -#define PUT_UINT32(n,b,i) \ -{ \ - (b)[(i) ] = (uint8) ( (n) ); \ - (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \ - (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \ - (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \ -} - -void md5_starts( struct md5_context *ctx ) -{ - ctx->total[0] = 0; - ctx->total[1] = 0; - ctx->state[0] = 0x67452301; - ctx->state[1] = 0xEFCDAB89; - ctx->state[2] = 0x98BADCFE; - ctx->state[3] = 0x10325476; -} - -void md5_process( struct md5_context *ctx, uint8 data[64] ) -{ - uint32 A, B, C, D, X[16]; - - GET_UINT32( X[0], data, 0 ); - GET_UINT32( X[1], data, 4 ); - GET_UINT32( X[2], data, 8 ); - GET_UINT32( X[3], data, 12 ); - GET_UINT32( X[4], data, 16 ); - GET_UINT32( X[5], data, 20 ); - GET_UINT32( X[6], data, 24 ); - GET_UINT32( X[7], data, 28 ); - GET_UINT32( X[8], data, 32 ); - GET_UINT32( X[9], data, 36 ); - GET_UINT32( X[10], data, 40 ); - GET_UINT32( X[11], data, 44 ); - GET_UINT32( X[12], data, 48 ); - GET_UINT32( X[13], data, 52 ); - GET_UINT32( X[14], data, 56 ); - GET_UINT32( X[15], data, 60 ); - -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) - -#define P(a,b,c,d,k,s,t) \ -{ \ - a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ -} - - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - -#define F(x,y,z) (z ^ (x & (y ^ z))) - - P( A, B, C, D, 0, 7, 0xD76AA478 ); - P( D, A, B, C, 1, 12, 0xE8C7B756 ); - P( C, D, A, B, 2, 17, 0x242070DB ); - P( B, C, D, A, 3, 22, 0xC1BDCEEE ); - P( A, B, C, D, 4, 7, 0xF57C0FAF ); - P( D, A, B, C, 5, 12, 0x4787C62A ); - P( C, D, A, B, 6, 17, 0xA8304613 ); - P( B, C, D, A, 7, 22, 0xFD469501 ); - P( A, B, C, D, 8, 7, 0x698098D8 ); - P( D, A, B, C, 9, 12, 0x8B44F7AF ); - P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); - P( B, C, D, A, 11, 22, 0x895CD7BE ); - P( A, B, C, D, 12, 7, 0x6B901122 ); - P( D, A, B, C, 13, 12, 0xFD987193 ); - P( C, D, A, B, 14, 17, 0xA679438E ); - P( B, C, D, A, 15, 22, 0x49B40821 ); - -#undef F - -#define F(x,y,z) (y ^ (z & (x ^ y))) - - P( A, B, C, D, 1, 5, 0xF61E2562 ); - P( D, A, B, C, 6, 9, 0xC040B340 ); - P( C, D, A, B, 11, 14, 0x265E5A51 ); - P( B, C, D, A, 0, 20, 0xE9B6C7AA ); - P( A, B, C, D, 5, 5, 0xD62F105D ); - P( D, A, B, C, 10, 9, 0x02441453 ); - P( C, D, A, B, 15, 14, 0xD8A1E681 ); - P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); - P( A, B, C, D, 9, 5, 0x21E1CDE6 ); - P( D, A, B, C, 14, 9, 0xC33707D6 ); - P( C, D, A, B, 3, 14, 0xF4D50D87 ); - P( B, C, D, A, 8, 20, 0x455A14ED ); - P( A, B, C, D, 13, 5, 0xA9E3E905 ); - P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); - P( C, D, A, B, 7, 14, 0x676F02D9 ); - P( B, C, D, A, 12, 20, 0x8D2A4C8A ); - -#undef F - -#define F(x,y,z) (x ^ y ^ z) - - P( A, B, C, D, 5, 4, 0xFFFA3942 ); - P( D, A, B, C, 8, 11, 0x8771F681 ); - P( C, D, A, B, 11, 16, 0x6D9D6122 ); - P( B, C, D, A, 14, 23, 0xFDE5380C ); - P( A, B, C, D, 1, 4, 0xA4BEEA44 ); - P( D, A, B, C, 4, 11, 0x4BDECFA9 ); - P( C, D, A, B, 7, 16, 0xF6BB4B60 ); - P( B, C, D, A, 10, 23, 0xBEBFBC70 ); - P( A, B, C, D, 13, 4, 0x289B7EC6 ); - P( D, A, B, C, 0, 11, 0xEAA127FA ); - P( C, D, A, B, 3, 16, 0xD4EF3085 ); - P( B, C, D, A, 6, 23, 0x04881D05 ); - P( A, B, C, D, 9, 4, 0xD9D4D039 ); - P( D, A, B, C, 12, 11, 0xE6DB99E5 ); - P( C, D, A, B, 15, 16, 0x1FA27CF8 ); - P( B, C, D, A, 2, 23, 0xC4AC5665 ); - -#undef F - -#define F(x,y,z) (y ^ (x | ~z)) - - P( A, B, C, D, 0, 6, 0xF4292244 ); - P( D, A, B, C, 7, 10, 0x432AFF97 ); - P( C, D, A, B, 14, 15, 0xAB9423A7 ); - P( B, C, D, A, 5, 21, 0xFC93A039 ); - P( A, B, C, D, 12, 6, 0x655B59C3 ); - P( D, A, B, C, 3, 10, 0x8F0CCC92 ); - P( C, D, A, B, 10, 15, 0xFFEFF47D ); - P( B, C, D, A, 1, 21, 0x85845DD1 ); - P( A, B, C, D, 8, 6, 0x6FA87E4F ); - P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); - P( C, D, A, B, 6, 15, 0xA3014314 ); - P( B, C, D, A, 13, 21, 0x4E0811A1 ); - P( A, B, C, D, 4, 6, 0xF7537E82 ); - P( D, A, B, C, 11, 10, 0xBD3AF235 ); - P( C, D, A, B, 2, 15, 0x2AD7D2BB ); - P( B, C, D, A, 9, 21, 0xEB86D391 ); - -#undef F - - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; -} - -void md5_update( struct md5_context *ctx, uint8 *input, uint32 length ) -{ - uint32 left, fill; - - if( ! length ) return; - - left = ( ctx->total[0] >> 3 ) & 0x3F; - fill = 64 - left; - - ctx->total[0] += length << 3; - ctx->total[1] += length >> 29; - - ctx->total[0] &= 0xFFFFFFFF; - ctx->total[1] += ctx->total[0] < ( length << 3 ); - - if( left && length >= fill ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); - md5_process( ctx, ctx->buffer ); - length -= fill; - input += fill; - left = 0; - } - - while( length >= 64 ) - { - md5_process( ctx, input ); - length -= 64; - input += 64; - } - - if( length ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, length ); - } -} - -static uint8 md5_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -void md5_finish( struct md5_context *ctx, uint8 digest[16] ) -{ - uint32 last, padn; - uint8 msglen[8]; - - PUT_UINT32( ctx->total[0], msglen, 0 ); - PUT_UINT32( ctx->total[1], msglen, 4 ); - - last = ( ctx->total[0] >> 3 ) & 0x3F; - padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - - md5_update( ctx, md5_padding, padn ); - md5_update( ctx, msglen, 8 ); - - PUT_UINT32( ctx->state[0], digest, 0 ); - PUT_UINT32( ctx->state[1], digest, 4 ); - PUT_UINT32( ctx->state[2], digest, 8 ); - PUT_UINT32( ctx->state[3], digest, 12 ); -} - - -/* Uses a static buffer, so beware of how it's used. */ -char *md5_asciistr(uint8 digest[16]) -{ - static char str[33]; - static char trans[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - int x; - - for(x=0;x<16;x++) - { - str[x*2]=trans[digest[x]&0x0F]; - str[x*2+1]=trans[digest[x]>>4]; - } - return(str); -} diff --git a/branches/sdl2/fceux-server/md5.h b/branches/sdl2/fceux-server/md5.h deleted file mode 100644 index 10501e95..00000000 --- a/branches/sdl2/fceux-server/md5.h +++ /dev/null @@ -1,37 +0,0 @@ -/* FCE Ultra Network Play Server - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#ifndef _MD5_H -#define _MD5_H - -struct md5_context -{ - uint32 total[2]; - uint32 state[4]; - uint8 buffer[64]; -}; - -void md5_starts( struct md5_context *ctx ); -void md5_update( struct md5_context *ctx, uint8 *input, uint32 length ); -void md5_finish( struct md5_context *ctx, uint8 digest[16] ); - -/* Uses a static buffer, so beware of how it's used. */ -char *md5_asciistr(uint8 digest[16]); - -#endif /* md5.h */ diff --git a/branches/sdl2/fceux-server/server.cpp b/branches/sdl2/fceux-server/server.cpp deleted file mode 100644 index 116e8f49..00000000 --- a/branches/sdl2/fceux-server/server.cpp +++ /dev/null @@ -1,915 +0,0 @@ -/* FCE Ultra Network Play Server - * - * Copyright notice for this file: - * Copyright (C) 2004 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "types.h" -#include "md5.h" -#include "throttle.h" - -#define VERSION "0.0.5" -#define DEFAULT_PORT 4046 -#define DEFAULT_MAX 100 -#define DEFAULT_TIMEOUT 5 -#define DEFAULT_FRAMEDIVISOR 1 -#define DEFAULT_CONFIG "/etc/fceux-server.conf" - -// MSG_NOSIGNAL and SOL_TCP have been depreciated on osx -#if defined (__APPLE__) || defined(BSD) -#define MSG_NOSIGNAL SO_NOSIGPIPE -#define SOL_TCP IPPROTO_TCP -#endif - -typedef struct { - uint32 id; /* mainly for faster referencing when pointed to from the Games - entries. - */ - char *nickname; - int TCPSocket; - void *game; /* Pointer to the game this player is in. */ - int localplayers; /* The number of local players, 1-4 */ - - time_t timeconnect; /* Time the client made the connection. */ - - /* Variables to handle non-blocking TCP reads. */ - uint8 *nbtcp; - uint32 nbtcphas, nbtcplen; - uint32 nbtcptype; -} ClientEntry; - -typedef struct -{ - uint8 id[16]; /* Unique 128-bit identifier for this game session. */ - uint8 joybuf[5]; /* 4 player data + 1 command byte */ - int MaxPlayers; /* Maximum players for this game */ - ClientEntry *Players[4]; /* Pointers to player data. */ - int IsUnique[4]; /* Set to 1 if player is unique client, 0 - if it's a duplicated entry to handle multiple players - per client. - */ - uint8 ExtraInfo[64]; /* Expansion information to be used in future versions - of FCE Ultra. - */ -} GameEntry; - -typedef struct -{ - unsigned int MaxClients; /* The maximum number of clients to allow. */ - /* You should expect each client to use - 65-70Kbps(not including save state loads) while - connected(and logged in), when using the default - FrameDivisor value of 1. - */ - unsigned int ConnectTimeout; /* How long to wait(in seconds) for the client to provide - login data before disconnecting the client. - */ - unsigned int FrameDivisor; /* The number of updates per second are divided - by this number. 1 = 60 updates/sec(approx), - 2 = 30 updates/sec, etc. */ - unsigned int Port; /* The port to listen on. */ - uint8 *Password; /* The server password. */ -} CONFIG; - -CONFIG ServerConfig; - -int LoadConfigFile(char *fn) -{ - FILE *fp; - ServerConfig.Port = ServerConfig.MaxClients = ServerConfig.ConnectTimeout = ServerConfig.FrameDivisor = ~0; - if(fp=fopen(fn,"rb")) - { - char buf[256]; - while(fgets(buf, 256, fp) > 0) - { - if(!strncasecmp(buf,"maxclients",strlen("maxclients"))) - sscanf(buf,"%*s %d",&ServerConfig.MaxClients); - else if(!strncasecmp(buf,"connecttimeout",strlen("connecttimeout"))) - sscanf(buf,"%*s %d",&ServerConfig.ConnectTimeout); - else if(!strncasecmp(buf,"framedivisor",strlen("framedivisor"))) - sscanf(buf,"%*s %d",&ServerConfig.FrameDivisor); - else if(!strncasecmp(buf,"port",strlen("port"))) - sscanf(buf,"%*s %d",&ServerConfig.Port); - else if(!strncasecmp(buf,"password",strlen("password"))) - { - char *pass = 0; - sscanf(buf,"%*s %as",&pass); - if(pass) - { - struct md5_context md5; - ServerConfig.Password = (uint8 *)malloc(16); - md5_starts(&md5); - md5_update(&md5,(uint8*)pass,strlen(pass)); - md5_finish(&md5,ServerConfig.Password); - puts("Password required to log in."); - } - } - } - } - - else - { - printf("Cannot load configuration file %s.\n", fn); - return(0); - } - - if(~0 == (ServerConfig.Port & ServerConfig.MaxClients & ServerConfig.ConnectTimeout & ServerConfig.FrameDivisor)) - { - puts("Incomplete configuration file"); - return(0); - } - //printf("%d,%d,%d\n",ServerConfig.MaxClients,ServerConfig.ConnectTimeout,ServerConfig.FrameDivisor); - printf("Using configuration file located at %s\n", fn); - return(1); -} - -static ClientEntry *Clients; -static GameEntry *Games; - -static void en32(uint8 *buf, uint32 morp) -{ - buf[0]=morp; - buf[1]=morp>>8; - buf[2]=morp>>16; - buf[3]=morp>>24; -} - -static uint32 de32(uint8 *morp) -{ - return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)); -} - -static char *CleanNick(char *nick); -static int NickUnique(ClientEntry *client); -static void AddClientToGame(ClientEntry *client, uint8 id[16], uint8 extra[64]) throw(int); -static void SendToAll(GameEntry *game, int cmd, uint8 *data, uint32 len) throw(int); -static void BroadcastText(GameEntry *game, const char *fmt, ...) throw(int); -static void TextToClient(ClientEntry *client, const char *fmt, ...) throw(int); -static void KillClient(ClientEntry *client); - -#define NBTCP_LOGINLEN 0x100 -#define NBTCP_LOGIN 0x200 -#define NBTCP_COMMANDLEN 0x300 -#define NBTCP_COMMAND 0x400 - -#define NBTCP_UPDATEDATA 0x800 - -static void StartNBTCPReceive(ClientEntry *client, uint32 type, uint32 len) -{ - client->nbtcp = (uint8 *)malloc(len); - client->nbtcplen = len; - client->nbtcphas = 0; - client->nbtcptype = type; -} - -static void RedoNBTCPReceive(ClientEntry *client) -{ - client->nbtcphas = 0; -} - -static void EndNBTCPReceive(ClientEntry *client) -{ - free(client->nbtcp); - client->nbtcplen = client->localplayers; - client->nbtcphas = 0; - client->nbtcptype = 0; - client->nbtcp = 0; -} - -static uint8 *MakeMPS(ClientEntry *client) -{ - static uint8 buf[64]; - uint8 *bp = buf; - int x; - GameEntry *game = (GameEntry *)client->game; - - for(x=0;x<4;x++) - { - if(game->Players[x] == client) - { - *bp = '0' + x + 1; - bp++; - *bp = ','; - bp++; - } - } - if(*(bp-1) == ',') bp--; - - *bp = 0; - return(buf); -} - -/* Returns 1 if we are back to normal game mode, 0 if more data is yet to arrive. */ -static int CheckNBTCPReceive(ClientEntry *client) throw(int) -{ - if(!client->nbtcplen) - throw(1); /* Should not happen. */ - int l; - - while(l = recv(client->TCPSocket, client->nbtcp + client->nbtcphas, client->nbtcplen - client->nbtcphas, MSG_NOSIGNAL)) - { - if(l == -1) - { - if(errno == EAGAIN || errno == EWOULDBLOCK) - break; - throw(1); /* Die now. NOW. */ - } - client->nbtcphas += l; - - //printf("Read: %d, %04x, %d, %d\n",l,client->nbtcptype,client->nbtcphas, client->nbtcplen); - - /* We're all full. Yippie. */ - if(client->nbtcphas == client->nbtcplen) - { - uint32 len; - - switch(client->nbtcptype & 0xF00) - { - case NBTCP_UPDATEDATA: - { - GameEntry *game = (GameEntry *)client->game; - int x, wx; - if(client->nbtcp[0] == 0xFF) - { - EndNBTCPReceive(client); - StartNBTCPReceive(client, NBTCP_COMMANDLEN, 5); - return(1); - } - for(x=0,wx=0; x < 4; x++) - { - if(game->Players[x] == client) - { - game->joybuf[x] = client->nbtcp[wx]; - wx++; - } - } - RedoNBTCPReceive(client); - } - return(1); - case NBTCP_COMMANDLEN: - { - uint8 cmd = client->nbtcp[4]; - len = de32(client->nbtcp); - if(len > 200000) /* Sanity check. */ - throw(1); - - //printf("%02x, %d\n",cmd,len); - if(!len && !(cmd&0x80)) - { - SendToAll((GameEntry*)client->game, client->nbtcp[4], 0, 0); - EndNBTCPReceive(client); - StartNBTCPReceive(client,NBTCP_UPDATEDATA,client->localplayers); - } - else if(client->nbtcp[4]&0x80) - { - EndNBTCPReceive(client); - if(len) - StartNBTCPReceive(client,NBTCP_COMMAND | cmd,len); - else /* Woops. Client probably tried to send a text message of 0 length. Or maybe a 0-length cheat file? Better be safe! */ - StartNBTCPReceive(client,NBTCP_UPDATEDATA,client->localplayers); - } - else throw(1); - return(1); - } - case NBTCP_COMMAND: - { - len = client->nbtcplen; - uint32 tocmd = client->nbtcptype & 0xFF; - - if(tocmd == 0x90) /* Text */ - { - char *ma, *ma2; - - ma = (char *) malloc(len + 1); - memcpy(ma, client->nbtcp, len); - ma[len] = 0; - asprintf(&ma2, "<%s> %s",client->nickname,ma); - free(ma); - ma = ma2; - len=strlen(ma); - SendToAll((GameEntry*)client->game, tocmd, (uint8 *)ma, len); - free(ma); - } - else - SendToAll((GameEntry*)client->game, tocmd, client->nbtcp, len); - EndNBTCPReceive(client); - StartNBTCPReceive(client,NBTCP_UPDATEDATA,client->localplayers); - return(1); - } - case NBTCP_LOGINLEN:len = de32(client->nbtcp); - if(len > 1024 || len < (16 + 16 + 64 + 1)) - throw(1); - EndNBTCPReceive(client); - StartNBTCPReceive(client,NBTCP_LOGIN,len); - return(1); - case NBTCP_LOGIN: - { - uint32 len; - uint8 gameid[16]; - uint8 *sexybuf; - uint8 extra[64]; - - len = client->nbtcplen; - sexybuf = client->nbtcp; - - /* Game ID(MD5'd game MD5 and password on client side). */ - memcpy(gameid, sexybuf, 16); - sexybuf += 16; - len -= 16; - - if(ServerConfig.Password) - if(memcmp(ServerConfig.Password,sexybuf,16)) - { - TextToClient(client,"Invalid server password."); - throw(1); - } - sexybuf += 16; - len -= 16; - - memcpy(extra, sexybuf, 64); - sexybuf += 64; - len -= 64; - - client->localplayers = *sexybuf; - if(client->localplayers < 1 || client->localplayers > 4) - { - TextToClient(client,"Invalid number(%d) of local players!",client->localplayers); - throw(1); - } - sexybuf++; - len -= 1; - - AddClientToGame(client, gameid, extra); - /* Get the nickname */ - if(len) - { - client->nickname = (char *)malloc(len + 1); - memcpy(client->nickname, sexybuf, len); - client->nickname[len] = 0; - if((client->nickname = CleanNick(client->nickname))) - if(!NickUnique(client)) /* Nickname already exists */ - { - free(client->nickname); - client->nickname = 0; - } - } - uint8 *mps = MakeMPS(client); - - if(!client->nickname) - asprintf(&client->nickname,"*Player %s",mps); - - printf("Client %d assigned to game %d as player %s <%s>\n",client->id,(GameEntry*)client->game - Games,mps, client->nickname); - - int x; - GameEntry *tg=(GameEntry *)client->game; - - for(x=0; xMaxPlayers; x++) - if(tg->Players[x] && tg->IsUnique[x]) - { - if(tg->Players[x] != client) - { - try - { - TextToClient(tg->Players[x], "* Player %s has just connected as: %s",MakeMPS(client),client->nickname); - } catch(int i) - { - KillClient(tg->Players[x]); - } - TextToClient(client, "* Player %s is already connected as: %s",MakeMPS(tg->Players[x]),tg->Players[x]->nickname); - } - else - TextToClient(client, "* You(Player %s) have just connected as: %s",MakeMPS(client),client->nickname); - } - } - EndNBTCPReceive(client); - StartNBTCPReceive(client,NBTCP_UPDATEDATA,client->localplayers); - return(1); - } - } - } - return(0); -} - -int ListenSocket; - -static char *CleanNick(char *nick) -{ - int x; - - for(x=0; x' || nick[x] == '*' || (nick[x] < 0x20)) - nick[x] = 0; - if(!strlen(nick)) - { - free(nick); - nick = 0; - } - - return(nick); -} - -static int NickUnique(ClientEntry *client) -{ - int x; - GameEntry *game = (GameEntry *)client-> game; - - for(x=0; xMaxPlayers; x++) - if(game->Players[x] && client != game->Players[x]) - if(!strcasecmp(client->nickname, game->Players[x]->nickname)) - return(0); - return(1); -} - -static int MakeSendTCP(ClientEntry *client, uint8 *data, uint32 len) throw(int) -{ - if(send(client->TCPSocket, data, len, MSG_NOSIGNAL) != len) - throw(1); - return(1); -} - -static void SendToAll(GameEntry *game, int cmd, uint8 *data, uint32 len) throw(int) -{ - uint8 poo[5]; - int x; - - poo[4] = cmd; - - for(x=0;xMaxPlayers;x++) - { - if(!game->Players[x] || !game->IsUnique[x]) continue; - - try - { - if(cmd & 0x80) - en32(poo, len); - MakeSendTCP(game->Players[x],poo,5); - - if(cmd & 0x80) - { - MakeSendTCP(game->Players[x], data, len); - } - } - catch(int i) - { - KillClient(game->Players[x]); - } - - } -} - -static void TextToClient(ClientEntry *client, const char *fmt, ...) throw(int) -{ - char *moo; - va_list ap; - - va_start(ap,fmt); - vasprintf(&moo, fmt, ap); - va_end(ap); - - - uint8 poo[5]; - uint32 len; - - poo[4] = 0x90; - len = strlen(moo); - en32(poo, len); - - MakeSendTCP(client, poo, 5); - MakeSendTCP(client, (uint8*)moo, len); - free(moo); -} - -static void BroadcastText(GameEntry *game, const char *fmt, ...) throw(int) -{ - char *moo; - va_list ap; - - va_start(ap,fmt); - vasprintf(&moo, fmt, ap); - va_end(ap); - - SendToAll(game, 0x90,(uint8 *)moo,strlen(moo)); - free(moo); -} - -static void KillClient(ClientEntry *client) -{ - GameEntry *game; - uint8 *mps; - char *bmsg; - - game = (GameEntry *)client->game; - if(game) - { - int w; - int tc = 0; - - for(w=0;wMaxPlayers;w++) - if(game->Players[w]) tc++; - - for(w=0;wMaxPlayers;w++) - if(game->Players[w]) - if(game->Players[w] == client) - game->Players[w] = NULL; - - time_t curtime = time(0); - printf("Player <%s> disconnected from game %d on %s",client->nickname,game-Games,ctime(&curtime)); - asprintf(&bmsg, "* Player %s <%s> left.",MakeMPS(client),client->nickname); - if(tc == client->localplayers) /* If total players for this game = total local - players for this client, destroy the game. - */ - { - printf("Game %d destroyed.\n",game-Games); - memset(game, 0, sizeof(GameEntry)); - game = 0; - } - } - else - { - time_t curtime = time(0); - printf("Unassigned client %d disconnected on %s",client->id, ctime(&curtime)); - } - if(client->nbtcp) - free(client->nbtcp); - - if(client->nickname) - free(client->nickname); - - if(client->TCPSocket != -1) - close(client->TCPSocket); - memset(client, 0, sizeof(ClientEntry)); - client->TCPSocket = -1; - - if(game) - BroadcastText(game,"%s",bmsg); -} - -static void AddClientToGame(ClientEntry *client, uint8 id[16], uint8 extra[64]) throw(int) -{ - int wg; - GameEntry *game,*fegame; - - retry: - - game = NULL; - fegame = NULL; - - /* First, find an available game. */ - for(wg=0; wgMaxPlayers = 4; - memcpy(game->id, id, 16); - memcpy(game->ExtraInfo, extra, 64); - } - - - int n; - for(n = 0; n < game->MaxPlayers; n++) - if(game->Players[n]) - { - try - { - uint8 b[5]; - b[4] = 0x81; - MakeSendTCP(game->Players[n], b, 5); - break; - } - catch(int i) - { - KillClient(game->Players[n]); - /* All right, now the client we sent the request to is killed. I HOPE YOU'RE HAPPY! */ - /* Since killing a client can destroy a game, we'll need to see if the game was trashed. - If it was, then "goto retry", and try again. Ugly, yes. I LIKE UGLY. - */ - if(!game->MaxPlayers) - goto retry; - } - } - - int instancecount = client->localplayers; - - for(n=0; nMaxPlayers; n++) - if(!game->Players[n]) - { - game->Players[n] = client; - if(instancecount == client->localplayers) - game->IsUnique[n] = 1; - else - game->IsUnique[n] = 0; - instancecount --; - if(!instancecount) - break; - } - - /* Game is full. */ - if(n == game->MaxPlayers) - { - for(n=0; nMaxPlayers; n++) - if(game->Players[n] == client) - game->Players[n] = 0; - TextToClient(client, "Sorry, game is full. %d instance(s) tried, %d available.",client->localplayers,client->localplayers - instancecount); - throw(1); - } - - client->game = (void *)game; -} - - - - -int main(int argc, char *argv[]) -{ - - struct sockaddr_in sockin; - socklen_t sockin_len; - int i; - char* pass = 0; - /* If we can't load the default config file, use some defined values */ - if(!LoadConfigFile(DEFAULT_CONFIG)) { - ServerConfig.Port = DEFAULT_PORT; - ServerConfig.MaxClients = DEFAULT_MAX; - ServerConfig.ConnectTimeout = DEFAULT_TIMEOUT; - ServerConfig.FrameDivisor = DEFAULT_FRAMEDIVISOR; - } - char* configfile = 0; - - - for(i=1; ilocalplayers; - - while(CheckNBTCPReceive(client)) {}; - } // catch - catch(int i) - { - KillClient(Games[whichgame].Players[n]); - } - } // A games clients - - /* Now we send the data to all the clients. */ - for(n = 0; n < Games[whichgame].MaxPlayers; n++) - { - if(!Games[whichgame].Players[n] || !Games[whichgame].IsUnique[n]) continue; - try - { - MakeSendTCP(Games[whichgame].Players[n], Games[whichgame].joybuf, 5); - } - catch(int i) - { - KillClient(Games[whichgame].Players[n]); - } - } // A game's clients - } // Games - - SpeedThrottle(); - } // while(1) -} diff --git a/branches/sdl2/fceux-server/throttle.cpp b/branches/sdl2/fceux-server/throttle.cpp deleted file mode 100644 index dedffe31..00000000 --- a/branches/sdl2/fceux-server/throttle.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* FCE Ultra Network Play Server - * - * Copyright notice for this file: - * Copyright (C) 2004 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - - -#include -#include -#include "types.h" -#include "throttle.h" - -#ifdef TODO -THROTTLE *MakeThrottle(uint32 fps) -{ - - -} - -/* Returns 1 if it's time to run, 0 if it's not time yet. */ -int TestThrottle(THROTTLE *throt) -{ - -} - -/* Pass it a pointer to an array of THROTTLE structs */ -/* It will check */ -void DoAllThrottles(THROTTLE *throt) -{ - - -} - -void KillThrottle(THROTTLE *throt) -{ - -} - -#endif - -static uint64 tfreq; -static uint64 desiredfps; - -int32 FCEUI_GetDesiredFPS(void) -{ - //if(PAL) - // return(838977920); // ~50.007 - //else - return(1008307711); // ~60.1 -} - -void RefreshThrottleFPS(int divooder) -{ - desiredfps=(FCEUI_GetDesiredFPS() / divooder)>>8; - tfreq=1000000; - tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ -} - -static uint64 GetCurTime(void) -{ - uint64 ret; - struct timeval tv; - - gettimeofday(&tv,0); - ret=(uint64)tv.tv_sec*1000000; - ret+=tv.tv_usec; - return(ret); -} - -void SpeedThrottle(void) -{ - static uint64 ttime,ltime; - - waiter: - ttime=GetCurTime(); - - if( (ttime-ltime) < (tfreq/desiredfps) ) - { - usleep(1000); - goto waiter; - } - if( (ttime-ltime) >= (tfreq*4/desiredfps)) - ltime=ttime; - else - ltime+=tfreq/desiredfps; -} - diff --git a/branches/sdl2/fceux-server/throttle.h b/branches/sdl2/fceux-server/throttle.h deleted file mode 100644 index 4434f86d..00000000 --- a/branches/sdl2/fceux-server/throttle.h +++ /dev/null @@ -1,23 +0,0 @@ -/* FCE Ultra Network Play Server - * - * Copyright notice for this file: - * Copyright (C) 2004 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * */ - - -void RefreshThrottleFPS(int divooder); -void SpeedThrottle(void); diff --git a/branches/sdl2/fceux-server/types.h b/branches/sdl2/fceux-server/types.h deleted file mode 100644 index 4d1e35f4..00000000 --- a/branches/sdl2/fceux-server/types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* FCE Ultra Network Play Server - * - * Copyright notice for this file: - * Copyright (C) 2004 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __FCEU_TYPES -#define __FCEU_TYPES - -#include -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; - -typedef unsigned long long uint64; -typedef long long int64; -#define INLINE inline -#define GINLINE inline - -#endif diff --git a/branches/sdl2/fceux.desktop b/branches/sdl2/fceux.desktop deleted file mode 100644 index 60aecf2c..00000000 --- a/branches/sdl2/fceux.desktop +++ /dev/null @@ -1,22 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Fceux -GenericName=NES/Famicom emulator -NoDisplay=false -Comment=Emulate NES ROMs -Exec=/usr/bin/fceux -Icon=/usr/share/pixmaps/fceux.png -Terminal=false -MimeType=application/x-nes-rom -Categories=Game;Emulator; -Encoding=UTF-8 -Actions=Fullscreen;DefaultConfig; -[Desktop Action Fullscreen] -Name=Open in Fullscreen -Exec=fceux -f 1 -OnlyShowIn=Unity -[Desktop Action DefaultConfig] -Name=Start With the Default Configuration -Exec=fceux --no-config 1 -OnlyShowIn=Unity diff --git a/branches/sdl2/fceux.png b/branches/sdl2/fceux.png deleted file mode 100644 index 1cf27b1f..00000000 Binary files a/branches/sdl2/fceux.png and /dev/null differ diff --git a/branches/sdl2/getSDLKey/COPYING b/branches/sdl2/getSDLKey/COPYING deleted file mode 100644 index d159169d..00000000 --- a/branches/sdl2/getSDLKey/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/branches/sdl2/getSDLKey/Makefile b/branches/sdl2/getSDLKey/Makefile deleted file mode 100644 index 2bb65883..00000000 --- a/branches/sdl2/getSDLKey/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -PREFIX = /usr -OUTFILE = getSDLKey - -CC = g++ -OBJS = getSDLKey.o -LIBS = $(shell sdl-config --cflags --libs) - -all: ${OBJS} - ${CC} -o ${OUTFILE} ${OBJS} ${LIBS} - -clean: - rm -f ${OUTFILE} ${OBJS} - -install: - install -m 755 -D getSDLKey ${PREFIX}/bin/getSDLKey - -getSDLKey.o = getSDLKey.cpp diff --git a/branches/sdl2/getSDLKey/README b/branches/sdl2/getSDLKey/README deleted file mode 100644 index d300fe7d..00000000 --- a/branches/sdl2/getSDLKey/README +++ /dev/null @@ -1,27 +0,0 @@ -############################################# -# getSDLKey - Lukas Sabota - October, 2011 # -############################################# - -1. Dependencies: - gcc - make - libsdl - -2. Installing -Run "make" to compile to "getSDLKey". Run "make install" as root if you would like to install "getSDLKey" into a user-specified PREFIX. - -3. Running -Type "./getSDLKey" while in this directory to run. - -4. About this tool. -This is a tool to determine what the SDL keysym for a particular key on your keyboard is. This is especially useful when mapping hotkeys to FCEUX. Take a look at an excerpt of ~/.fceux/fceux.cfg: - - SDL.Hotkeys.SaveState = 286 - -Apparently, F5 on my system is SDL keysym 286. If you wanted to remap this to a different key, run ./getSDLKey and press the desired key to see what keysym you should modify your configuration with. - -5. Bugs -You can report any issues with this tool in the FCEUX SourceForge bugtracker. Alternatively, you can contact me directly at LTsmooth42 _at_ gmail _dot_ com. - -6. Future -I plan to implement a GUI for remapping these keys so you dont have to do this in the future, but were all very busy people, arent we? diff --git a/branches/sdl2/getSDLKey/getSDLKey.cpp b/branches/sdl2/getSDLKey/getSDLKey.cpp deleted file mode 100644 index 4f25fd8c..00000000 --- a/branches/sdl2/getSDLKey/getSDLKey.cpp +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////// -// getSDLKey.cpp -// Lukas Sabota - October, 2011 -// -// Prints the corresponding SDL keysym for a key pressed -// into a SDL window. Useful for remapping hotkeys in they -// ~/.fceux/fceux.cfg config file, but may be useful for other -// applications as well. -// -///////////////////////////////////////////////////////////////// - -#include - -void DisplayState(SDL_KeyboardEvent *key) -{ - if (key->type == SDL_KEYUP) - printf("RELEASED: "); - else - printf("PRESSED: "); - -} - -void DisplayModifiers(SDL_KeyboardEvent *key) -{ - SDLMod modifier = key->keysym.mod; - if( modifier & KMOD_NUM ) printf( "NUMLOCK " ); - if( modifier & KMOD_CAPS ) printf( "CAPSLOCK " ); - if( modifier & KMOD_MODE ) printf( "MODE " ); - if( modifier & KMOD_LCTRL ) printf( "LCTRL " ); - if( modifier & KMOD_RCTRL ) printf( "RCTRL " ); - if( modifier & KMOD_LSHIFT ) printf( "LSHIFT " ); - if( modifier & KMOD_RSHIFT ) printf( "RSHIFT " ); - if( modifier & KMOD_LALT ) printf( "LALT " ); - if( modifier & KMOD_RALT ) printf( "RALT " ); - if( modifier & KMOD_LMETA ) printf( "LMETA " ); - if( modifier & KMOD_RMETA ) printf( "RMETA " ); -} - -void DisplayKey(SDL_KeyboardEvent *key) -{ - printf( "%s\n", SDL_GetKeyName(key->keysym.sym)); -} - -void DisplayKeysym(SDL_KeyboardEvent *key) -{ - printf ("%d\n", key->keysym.sym); -} - - -int main(int argc, char** argv) -{ - SDL_Surface *screen; - - if (SDL_Init(SDL_INIT_VIDEO) != 0) - { - printf("Unable to initialize SDL: %s\n", SDL_GetError()); - return 1; - } - - atexit(SDL_Quit); - - screen = SDL_SetVideoMode(320, 240, 0, SDL_ANYFORMAT); - SDL_WM_SetCaption("Get SDL Keysyms! Now 50\% off!", NULL); - if (screen == NULL) - { - printf("Unable to set video mode: %s\n", SDL_GetError()); - return 1; - } - SDL_Event event; - int running = 1; - - while(running) { - while(SDL_PollEvent(&event)) { - switch(event.type){ - case SDL_KEYDOWN: - case SDL_KEYUP: - DisplayState(&event.key); - DisplayModifiers(&event.key); - DisplayKey(&event.key); - DisplayKeysym(&event.key); - break; - case SDL_QUIT: - running = 0; - break; - } - } - } - - return 0; -} diff --git a/branches/sdl2/output/.gitignore b/branches/sdl2/output/.gitignore deleted file mode 100644 index 907b4c9c..00000000 --- a/branches/sdl2/output/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/7z.dll -/auxlib.lua -/cheats -/disksys.rom -/fceux.cfg -/fceux.chm -/fceux.chw -/fceux.exe -/fceux.exp -/fceux.lib -/fceux.pdb -/fcs -/movies -/sav -/snaps diff --git a/branches/sdl2/output/fceux.chm b/branches/sdl2/output/fceux.chm deleted file mode 100644 index cc94fb1a..00000000 Binary files a/branches/sdl2/output/fceux.chm and /dev/null differ diff --git a/branches/sdl2/output/lua5.1.dll b/branches/sdl2/output/lua5.1.dll deleted file mode 100644 index b87f3b66..00000000 Binary files a/branches/sdl2/output/lua5.1.dll and /dev/null differ diff --git a/branches/sdl2/output/lua51.dll b/branches/sdl2/output/lua51.dll deleted file mode 100644 index 27ab2654..00000000 Binary files a/branches/sdl2/output/lua51.dll and /dev/null differ diff --git a/branches/sdl2/output/luaScripts/AVI-HeadsUpDisplay.lua b/branches/sdl2/output/luaScripts/AVI-HeadsUpDisplay.lua deleted file mode 100644 index 0a888949..00000000 --- a/branches/sdl2/output/luaScripts/AVI-HeadsUpDisplay.lua +++ /dev/null @@ -1,121 +0,0 @@ --- Script by amaurea, andymac and feos for FCEUX 2.2.0 and earlier versions. --- Allows customizable recording of Frame, Lag, Timer and Input display to AVI dump. --- Drag and drop HUD items with mouse, use Numpad 1-6 to switch them on/off. - -print("Drag and drop HUD items with mouse, use Numpad 1-6 to switch them on/off.") - -screen = {w=256,h=231} -move = {object=nil,offx=0,offy=0} - -pads = { - {num=1,on=true, color="red", x=9, y=220,w=34,h=10,toggle="numpad1"}, - {num=2,on=true, color="yellow",x=54, y=220,w=34,h=10,toggle="numpad2"}, - {num=3,on=false,color="green", x=99, y=220,w=34,h=10,toggle="numpad3"}, - {num=4,on=false,color="orange",x=144,y=220,w=34,h=10,toggle="numpad4"} -} - -buttons = { - A = {x=30,y=5,w=3,h=3}, - B = {x=24,y=5,w=3,h=3}, - select = {x=18,y=7,w=3,h=1}, - start = {x=12,y=7,w=3,h=1}, - up = {x=4, y=1,w=2,h=2}, - down = {x=4, y=7,w=2,h=2}, - left = {x=1, y=4,w=2,h=2}, - right = {x=7, y=4,w=2,h=2} -} - -text = {on=true,x=1, y=9,w=30,h=16,toggle="numpad5"} -timer = {on=true,x=197,y=9,w=58,h= 7,toggle="numpad6"} - -function drawpad(pad) - gui.drawbox( pad.x, pad.y, pad.x+pad.w, pad.y+pad.h, "#3070ffb0" ) - gui.drawbox( pad.x+4, pad.y+4, pad.x+6, pad.y+6, "black" ) - controller = joypad.read(pad.num) - for name, b in pairs(buttons) do - gui.drawbox( pad.x + b.x, pad.y + b.y, pad.x + b.x + b.w, pad.y + b.y + b.h, - controller[name] and pad.color or "black" ) - end -end - -function mouseover(pad, margin) - return keys.xmouse >= pad.x-margin and keys.xmouse <= pad.x+pad.w+margin and - keys.ymouse >= pad.y-margin and keys.ymouse <= pad.y+pad.h+margin -end - -function inrange(upper, lower, testval) - if testval >= upper then return upper - elseif testval <= lower then return lower - else return testval - end -end - -function concat(tables) - local res = {} - for _, tab in ipairs(tables) do - for _, val in ipairs(tab) do - table.insert(res, val) - end - end - return res -end - -prev_keys = input.get() -objects = concat({pads, {text, timer}}) - -function everything() - keys = input.get() - - -- Are we moving anything around? - if move.object then - if keys["leftclick"] then - -- Do not go outside screen - local safex = inrange(screen.w - move.object.w, 0, keys.xmouse - move.offx) - local safey = inrange(screen.h - move.object.h, 8, keys.ymouse - move.offy) - move.object.x = safex - move.object.y = safey - else move.object = nil end - - -- Try to pick something up - elseif keys["leftclick"] then - for _,object in ipairs(objects) do - if mouseover(object,0) then - move.object = object - move.offx = keys.xmouse - object.x - move.offy = keys.ymouse - object.y - end - end - end - - -- Toggle displays - for _, object in ipairs(objects) do - if keys[object.toggle] and not prev_keys[object.toggle] then - object.on = not object.on - end - end - - -- Actually draw the stuff - if timer.on then - mins = math.floor(movie.framecount()/3600) - secs = movie.framecount()/60-mins*60 - gui.text( timer.x, timer.y, string.format("%s:%05.2f",os.date("!%H:%M",mins*60),secs), "white" ) - end - - if text.on then - local done = movie.mode() == "finished" or movie.mode() == nil - gui.text( text.x, text.y, movie.framecount(), done and "red" or "white" ) - gui.text( text.x, text.y + 9, FCEU.lagcount(), FCEU.lagged() and "red" or "green" ) - end - - for _, pad in ipairs(pads) do - if pad.on then drawpad(pad) end - end - - prev_keys = keys -end - -gui.register(everything) - -while (true) do - FCEU.frameadvance() -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/BoulderDash_AmoebaAI.lua b/branches/sdl2/output/luaScripts/BoulderDash_AmoebaAI.lua deleted file mode 100644 index adcbcb36..00000000 --- a/branches/sdl2/output/luaScripts/BoulderDash_AmoebaAI.lua +++ /dev/null @@ -1,589 +0,0 @@ ---------------------------------------------------------------------------- --- Boulder Dash - Displaying Amoeba Pointer Movements --- by AnS, 2012 --- requested by CtrlAltDestroy ---------------------------------------------------------------------------- --- Showcases following functions: --- * memory.registerexec() ---------------------------------------------------------------------------- --- Usage: --- Start playing any level of the BoulderDash that has the Amoeba enemy, --- for example Level 2-3, Level 4-1 or Level 6-3. --- Come close to the Amoeba enemy and see if you can find any regularities --- in its movement. When you are convinced that its behavior is completely --- erratic, run the script and unpause emulation. Now the script will draw --- various arrows that show you the actual rules of the enemy AI. --- --- You can control the "playback slider" in the bottom of the screen (click --- or drag it with mouse). Also you can pause and unpause this mini-playback --- while the emulator is still paused. This is necessary because the Amoeba --- makes a new set of moves every 8 frames, and this time span is not enough --- for you to replay all the logged events. ---------------------------------------------------------------------------- --- Explanations: --- The Amoeba AI is defined by UpdateAmoeba() function (see the disassembly --- code at the end of this script). --- The UpdateAmoeba() makes many steps with the Amoeba Pointer (so the arrow --- may move from tile to tile 100-200 times within the span of one frame! --- This complexity makes it look unpredictable for player, even though the --- rules of movement are very simple (move clockwise, rotate anticlockwise). --- --- This script allows you to see all steps of this Pointer, so you can grasp --- the logic of Amoeba movement/multiplication. The script registers hooks --- to all essential points of the UpdateAmoeba() code, and logs the whole --- process of the function execution. Then it pauses emulation and replays --- the log of events by drawing arrows over the game sprites. --- The log auto-resets at the beginning of every new call of UpdateAmoeba(). --- --- Similar approach can be used for displaying complex AI in other games. ---------------------------------------------------------------------------- - --- constants - -CELL_SIZE = 16; -CELL_HALFSIZE = CELL_SIZE / 2; -UPPER_BORDER_SIZE = 64; -LEFT_BORDER_SIZE = 32; -INTRO_DELAY = 1; -OUTRO_DELAY = 1; -MAX_ARROW_SIZE = 9; - -PAUSE_BUTTON_X = 2; -PAUSE_BUTTON_Y = 172; -PAUSE_BUTTON_WIDTH = 16; -PAUSE_BUTTON_HEIGHT = 16; - -TIMELINE_X = 20; -TIMELINE_LENGTH = 232; -TIMELINE_HEIGHT = 8; -TIMELINE_Y = 180; - -ColorStatuses = { "#00A000FF", "#00FF00FF", "#A0A0A0FF", "#00FFFFFF", "#FFFFFFFF", "#C0C000FF" }; -STATUS_NORMAL = 1; -- Green: Normal movements -STATUS_ROTATED = 2; -- Light-green: just rotated 90 degrees (anticlockwise) relative to current movement direction -STATUS_BUMPED = 3; -- Grey: bumped into obstacle -STATUS_SET = 4; -- Blue: Set amoeba -STATUS_REFUSED = 5; -- White: Refused to set amoeba -STATUS_END = 6; -- Yellow: RTS from UpdateAmoeba - --- variables - -animation_timer = 0; -current_step = 0; -animation_speed = 0.5; -animation_paused = false; -mouse_held = false; -dragging_timeline = false; - -log_size = 0; -creation_frame = -1; - --- arrays for storing the log data - -Amoeba_X = {}; -Amoeba_Y = {}; -AmoebaDirection = {}; -AmoebaPhase = {}; -AmoebaTimer = {}; -ColorStatus = {}; - ------------------------------------------------------------------------- -function reset_log() - log_size = 0; - animation_timer = 0; - creation_frame = movie.framecount(); - emu.pause(); -end - -function append_log_normal() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x0050); -- Temp_X - Amoeba_Y[log_size] = memory.readbyte(0x004F); -- Temp_Y - AmoebaDirection[log_size] = memory.readbyte(0x004E); -- Temp_AmoebaDirection - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_NORMAL; -- Green: Normal movements -end - -function append_log_rotated() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x0050); -- Temp_X - Amoeba_Y[log_size] = memory.readbyte(0x004F); -- Temp_Y - AmoebaDirection[log_size] = memory.readbyte(0x004E); -- Temp_AmoebaDirection - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_ROTATED; -- Light-green: just rotated 90 degrees (anticlockwise) relative to current movement direction -end - -function append_log_bumped() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x0050); -- Temp_X - Amoeba_Y[log_size] = memory.readbyte(0x004F); -- Temp_Y - AmoebaDirection[log_size] = memory.readbyte(0x004E); -- Temp_AmoebaDirection - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_BUMPED; -- Grey: bumped into obstacle -end - -function append_log_set() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x0050); -- Temp_X - Amoeba_Y[log_size] = memory.readbyte(0x004F); -- Temp_Y - AmoebaDirection[log_size] = memory.readbyte(0x004E); -- Temp_AmoebaDirection - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_SET; -- Blue: Set amoeba -end - -function append_log_refused() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x0050); -- Temp_X - Amoeba_Y[log_size] = memory.readbyte(0x004F); -- Temp_Y - AmoebaDirection[log_size] = memory.readbyte(0x004E); -- Temp_AmoebaDirection - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_REFUSED; -- White: Refused to set amoeba -end - -function append_log_rts() - log_size = log_size + 1; - Amoeba_X[log_size] = memory.readbyte(0x00BC); - AmoebaDirectionAnd_Y = memory.readbyte(0x00BB); - Amoeba_Y[log_size] = AND(AmoebaDirectionAnd_Y, 0x3F); - AmoebaDirection[log_size] = AND(AmoebaDirectionAnd_Y, 0xC0); - AmoebaPhase[log_size] = memory.readbyte(0x00B7); - AmoebaTimer[log_size] = memory.readbyte(0x00BD); - ColorStatus[log_size] = STATUS_END; -- Yellow: RTS from UpdateAmoeba -end - ------------------------------------------------------------------------- -function DrawArrow(x, y, direction, size, color) - x = x + CELL_HALFSIZE; - y = y + CELL_HALFSIZE; - if (direction == 00) then - -- Left - gui.line(x, y - size, x - size, y, color); - gui.line(x - size, y, x, y + size, color); - gui.line(x, y + size, x, y - size, color); - end - if (direction == 0x40) then - -- up - gui.line(x - size, y, x, y - size, color); - gui.line(x, y - size, x + size, y, color); - gui.line(x + size, y, x - size, y, color); - end - if (direction == 0x80) then - -- Right - gui.line(x, y - size, x + size, y, color); - gui.line(x + size, y, x, y + size, color); - gui.line(x, y + size, x, y - size, color); - end - if (direction == 0xC0) then - -- Down - gui.line(x - size, y, x, y + size, color); - gui.line(x, y + size, x + size, y, color); - gui.line(x + size, y, x - size, y, color); - end -end ------------------------------------------------------------------------- --- This function is called every frame when the emulator is unpaused, --- and 20 times per second when the emulator is paused. - -function update() - AmoebaOrigin_X = memory.readbyte(0x00B9); - AmoebaOriginDirectionAnd_Y = memory.readbyte(0x00B8); - AmoebaOrigin_Y = AND(AmoebaOriginDirectionAnd_Y, 0x3F); - AmoebaOriginDirection = AND(AmoebaOriginDirectionAnd_Y, 0xC0); - - Camera_X_Lo = memory.readbyte(0x00BE); - Camera_X_Hi = memory.readbyte(0x00BF); - Camera_Y_Lo = memory.readbyte(0x00C0); - Camera_Y_Hi = memory.readbyte(0x00C1); - Camera_X = (256 * Camera_X_Hi + Camera_X_Lo) - UPPER_BORDER_SIZE; - Camera_Y = (256 * Camera_Y_Hi + Camera_Y_Lo) - LEFT_BORDER_SIZE; - - if (log_size > 0) then - - inp = input.get() - if (inp.leftclick) then - xm = inp.xmouse - ym = inp.ymouse - -- check click on the Pause/Resume button - if (not mouse_held) then - if (xm >= PAUSE_BUTTON_X and ym >= PAUSE_BUTTON_Y and xm < PAUSE_BUTTON_X + PAUSE_BUTTON_WIDTH and ym < PAUSE_BUTTON_Y + PAUSE_BUTTON_HEIGHT) then - animation_paused = not animation_paused; - end - end - -- check click on the timeline - if (dragging_timeline or (xm >= TIMELINE_X and ym >= TIMELINE_Y - TIMELINE_HEIGHT and xm < TIMELINE_X + TIMELINE_LENGTH and ym < TIMELINE_Y + TIMELINE_HEIGHT)) then - shift = xm - TIMELINE_X; - if (shift < 0) then - shift = 0; - else - if (shift > TIMELINE_LENGTH) then shift = TIMELINE_LENGTH; end - end - animation_timer = (INTRO_DELAY + log_size + OUTRO_DELAY) * shift / TIMELINE_LENGTH; - dragging_timeline = true; - end - mouse_held = true; - else - mouse_held = false; - dragging_timeline = false; - end - - if (not animation_paused and not mouse_held) then - -- animate - animation_timer = animation_timer + animation_speed; - if (animation_timer > INTRO_DELAY + log_size + OUTRO_DELAY) then - animation_timer = 0; - end - end - - current_step = math.floor(animation_timer - INTRO_DELAY); - if (current_step > log_size) then - current_step = log_size; - else - if (current_step < 1) then current_step = 1; end - end - - -- show info - if (ColorStatus[current_step] == STATUS_END) then - -- emphasize the phase change by yellow - gui.text(3, 11, "AmoebaPhase = " .. AND(AmoebaPhase[current_step], 3), "yellow"); - else - gui.text(3, 11, "AmoebaPhase = " .. AND(AmoebaPhase[current_step], 3)); - end - if ((ColorStatus[current_step] == STATUS_SET) or (ColorStatus[current_step] == STATUS_REFUSED)) then - -- emphasize the decrement by red - gui.text(3, 20, "AmoebaTimer = " .. AmoebaTimer[current_step], "red"); - else - gui.text(3, 20, "AmoebaTimer = " .. AmoebaTimer[current_step]); - end - - -- draw origin - DrawArrow(AmoebaOrigin_X * CELL_SIZE - Camera_X, AmoebaOrigin_Y * CELL_SIZE - Camera_Y, AmoebaOriginDirection, 5, "#00FFFFFF"); - - -- draw tail of pointers - for i = (MAX_ARROW_SIZE - 1), 0, -1 do - step = current_step - i; - if (step > 0) then - for s = 1, (MAX_ARROW_SIZE - i) do - -- draw previous position of pointer - DrawArrow(Amoeba_X[step] * CELL_SIZE - Camera_X, Amoeba_Y[step] * CELL_SIZE - Camera_Y, AmoebaDirection[step], s, ColorStatuses[ColorStatus[step]]); - end - end - end - -- draw black border around the last (current) pointer - DrawArrow(Amoeba_X[current_step] * CELL_SIZE - Camera_X, Amoeba_Y[current_step] * CELL_SIZE - Camera_Y, AmoebaDirection[current_step], MAX_ARROW_SIZE + 1, "black"); - - -- draw GUI - -- Pause/Resume button - gui.box(PAUSE_BUTTON_X, PAUSE_BUTTON_Y, PAUSE_BUTTON_X + PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_Y + PAUSE_BUTTON_HEIGHT, "grey", "black"); - if (animation_paused) then - for s = 1, 6 do - DrawArrow(PAUSE_BUTTON_X - 2, PAUSE_BUTTON_Y, 0x80, s, "black"); - end - else - gui.box(PAUSE_BUTTON_X + (PAUSE_BUTTON_WIDTH / 2) - 3, PAUSE_BUTTON_Y + 3, PAUSE_BUTTON_X + (PAUSE_BUTTON_WIDTH / 2) - 1, PAUSE_BUTTON_Y + PAUSE_BUTTON_HEIGHT - 3, "black", "black"); - gui.box(PAUSE_BUTTON_X + (PAUSE_BUTTON_WIDTH / 2) + 3, PAUSE_BUTTON_Y + 3, PAUSE_BUTTON_X + (PAUSE_BUTTON_WIDTH / 2) + 1, PAUSE_BUTTON_Y + PAUSE_BUTTON_HEIGHT - 3, "black", "black"); - end - - -- line - gui.box(TIMELINE_X, TIMELINE_Y - TIMELINE_HEIGHT, TIMELINE_X + TIMELINE_LENGTH, TIMELINE_Y + TIMELINE_HEIGHT, "#00000040", "black"); - gui.box(TIMELINE_X, TIMELINE_Y - 1, TIMELINE_X + TIMELINE_LENGTH, TIMELINE_Y + 1, "white", "black"); - -- slider - shift = TIMELINE_LENGTH * animation_timer / (INTRO_DELAY + log_size + OUTRO_DELAY); - gui.box(TIMELINE_X + shift - 1, TIMELINE_Y - TIMELINE_HEIGHT, TIMELINE_X + shift + 1, TIMELINE_Y + TIMELINE_HEIGHT, "grey", "black"); - -- info - gui.text(TIMELINE_X + 80 + creation_frame % 3, TIMELINE_Y + TIMELINE_HEIGHT + 2, "Displaying " .. current_step .. " / " .. log_size); - gui.text(TIMELINE_X + 80 + creation_frame % 3, TIMELINE_Y + TIMELINE_HEIGHT + 11, "Created at frame " .. creation_frame); - end -end ------------------------------------------------------------------------- -gui.register(update); - -memory.registerexec(0xCE60, reset_log); -- ReallyUpdateAmoeba ---memory.registerexec(0xCE66, reset_log); -- RestartFromOrigin - -memory.registerexec(0xCE95, append_log_normal); -- TryMultiplying_Left -memory.registerexec(0xCEAE, append_log_normal); -- TryMultiplying_Up -memory.registerexec(0xCEC7, append_log_normal); -- TryMultiplying_Right -memory.registerexec(0xCEE0, append_log_normal); -- TryMultiplying_Down -memory.registerexec(0xCEF9, append_log_normal); -- TryMultiplying_Left2 -memory.registerexec(0xCF12, append_log_normal); -- TryMultiplying_Up2 -memory.registerexec(0xCF2B, append_log_normal); -- TryMultiplying_Right2 - -memory.registerexec(0xCEA3, append_log_rotated); -- Rotated from left to down -memory.registerexec(0xCEBC, append_log_rotated); -- Rotated from up to left -memory.registerexec(0xCED5, append_log_rotated); -- Rotated from right to up -memory.registerexec(0xCEEE, append_log_rotated); -- Rotated from down to right -memory.registerexec(0xCF07, append_log_rotated); -- Rotated from left to down -memory.registerexec(0xCF20, append_log_rotated); -- Rotated from up to left -memory.registerexec(0xCF39, append_log_rotated); -- Rotated from right to up - -memory.registerexec(0xCE9C, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCEB5, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCECE, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCEE7, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCF00, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCF19, append_log_bumped); -- Bumped into obstacle -memory.registerexec(0xCF32, append_log_bumped); -- Bumped into obstacle - -memory.registerexec(0xCF97, append_log_normal); -- Jumped to another amoeba -memory.registerexec(0xCFA5, append_log_set); -- Set amoeba -memory.registerexec(0xCFA3, append_log_refused); -- Refused to set amoeba -memory.registerexec(0xCF5D, append_log_rts); -- RTS from UpdateAmoeba - ------------------------------------------------------------------------- --- Disassembly of the BoulderDash code in question: --- --- UpdateAmoeba: --- ; Called every frame, but works only once per 8 frames --- >01:CE51:A5 B7 LDA AmoebaPhase = #$82 --- 01:CE53:F0 0A BEQ ExitWithoutUpdate --- 01:CE55:C9 FF CMP #$FF --- 01:CE57:F0 06 BEQ ExitWithoutUpdate --- 01:CE59:A5 FE LDA FrameCounter = #$6A --- 01:CE5B:29 07 AND #$07 --- 01:CE5D:F0 01 BEQ ReallyUpdateAmoeba --- ExitWithoutUpdate: --- 01:CE5F:60 RTS ----------------------------------------------------------- --- ReallyUpdateAmoeba: --- 01:CE60:A5 B7 LDA AmoebaPhase = #$82 --- 01:CE62:29 03 AND #$03 --- 01:CE64:D0 0C BNE PrepareForLoop25 --- RestartFromOrigin: --- ; Every time the amoeba multiplies or fails to multiply within 32 frames, it restarts to the original point --- 01:CE66:A9 00 LDA #$00 --- 01:CE68:85 B7 STA AmoebaPhase = #$82 --- 01:CE6A:A5 B8 LDA AmoebaOriginDirectionAnd_Y = #$41 --- 01:CE6C:85 BB STA AmoebaDirectionAnd_Y = #$41 --- 01:CE6E:A5 B9 LDA AmoebaOrigin_X = #$14 --- 01:CE70:85 BC STA Amoeba_X = #$18 --- PrepareForLoop25: --- 01:CE72:A9 19 LDA #$19 --- 01:CE74:85 4D STA 25Tries = #$0A --- ; Temp_X = Amoeba_X; Temp_Y = AmoebaDirectionAnd_Y & 00111111b; Temp_AmoebaDirection = AmoebaDirectionAnd_Y & 11000000b --- 01:CE76:A5 BB LDA AmoebaDirectionAnd_Y = #$41 --- 01:CE78:29 3F AND #$3F --- 01:CE7A:A8 TAY --- 01:CE7B:A5 BB LDA AmoebaDirectionAnd_Y = #$41 --- 01:CE7D:29 C0 AND #$C0 --- 01:CE7F:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CE81:A6 BC LDX Amoeba_X = #$18 --- 01:CE83:84 4F STY Temp_Y = #$38 --- 01:CE85:86 50 STX Temp_X = #$0A --- Loop25Tries: --- 01:CE87:A5 4E LDA Temp_AmoebaDirection = #$00 --- 01:CE89:C9 40 CMP #$40 --- 01:CE8B:F0 21 BEQ TryMultiplying_Up --- 01:CE8D:C9 80 CMP #$80 --- 01:CE8F:F0 36 BEQ TryMultiplying_Right --- 01:CE91:C9 C0 CMP #$C0 --- 01:CE93:F0 4B BEQ TryMultiplying_Down --- TryMultiplying_Left: --- 01:CE95:20 5E CF JSR CheckMultiplying_Left --- 01:CE98:B0 05 BCS NextTimeTryDown --- 01:CE9A:F0 0A BEQ OkSetAmoeba --- 01:CE9C:4C AC CE JMP Restore_X --- NextTimeTryDown: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CE9F:A9 C0 LDA #$C0 --- 01:CEA1:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CEA3:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CEA6:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CEA9:90 01 BCC Restore_X --- 01:CEAB:60 RTS ----------------------------------------------------------- --- Restore_X: --- 01:CEAC:E6 50 INC Temp_X = #$0A --- TryMultiplying_Up: --- 01:CEAE:20 6A CF JSR CheckMultiplying_Up --- 01:CEB1:B0 05 BCS NextTimeTryLeft --- 01:CEB3:F0 0A BEQ OkSetAmoeba --- 01:CEB5:4C C5 CE JMP Restore_Y --- NextTimeTryLeft: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CEB8:A9 00 LDA #$00 --- 01:CEBA:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CEBC:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CEBF:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CEC2:90 01 BCC Restore_Y --- 01:CEC4:60 RTS ----------------------------------------------------------- --- Restore_Y: --- 01:CEC5:E6 4F INC Temp_Y = #$38 --- TryMultiplying_Right: --- 01:CEC7:20 76 CF JSR CheckMultiplying_Right --- 01:CECA:B0 05 BCS NextTimeTryUp --- 01:CECC:F0 0A BEQ OkSetAmoeba --- 01:CECE:4C DE CE JMP Restore_X --- NextTimeTryUp: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CED1:A9 40 LDA #$40 --- 01:CED3:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CED5:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CED8:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CEDB:90 01 BCC Restore_X --- 01:CEDD:60 RTS ----------------------------------------------------------- --- Restore_X: --- 01:CEDE:C6 50 DEC Temp_X = #$0A --- TryMultiplying_Down: --- 01:CEE3:B0 05 BCS NextTimeTryRight --- 01:CEE5:F0 0A BEQ OkSetAmoeba --- 01:CEE7:4C F7 CE JMP Restore_X --- NextTimeTryRight: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CEEA:A9 80 LDA #$80 --- 01:CEEC:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CEEE:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CEF1:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CEF4:90 01 BCC Restore_X --- 01:CEF6:60 RTS ----------------------------------------------------------- --- Restore_X: --- 01:CEF7:C6 4F DEC Temp_Y = #$38 --- TryMultiplying_Left2: --- 01:CEF9:20 5E CF JSR CheckMultiplying_Left --- 01:CEFC:B0 05 BCS NextTimeTryDown2 --- 01:CEFE:F0 0A BEQ OkSetAmoeba --- 01:CF00:4C 10 CF JMP Restore_X --- NextTimeTryDown2: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CF03:A9 C0 LDA #$C0 --- 01:CF05:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CF07:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CF0A:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CF0D:90 01 BCC Restore_X --- 01:CF0F:60 RTS ----------------------------------------------------------- --- Restore_X: --- 01:CF10:E6 50 INC Temp_X = #$0A --- TryMultiplying_Up2: --- 01:CF12:20 6A CF JSR CheckMultiplying_Up --- 01:CF15:B0 05 BCS NextTimeTryLeft2 --- 01:CF17:F0 0A BEQ OkSetAmoeba --- 01:CF19:4C 29 CF JMP Restore_Y --- NextTimeTryLeft2: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CF1C:A9 00 LDA #$00 --- 01:CF1E:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CF20:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CF23:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CF26:90 01 BCC Restore_Y --- 01:CF28:60 RTS ----------------------------------------------------------- --- Restore_Y: --- 01:CF29:E6 4F INC Temp_Y = #$38 --- TryMultiplying_Right2: --- 01:CF2B:20 76 CF JSR CheckMultiplying_Right --- 01:CF2E:B0 05 BCS NextTimeTryUp2 --- 01:CF30:F0 0A BEQ OkSetAmoeba --- 01:CF32:4C 42 CF JMP Restore_X --- NextTimeTryUp2: --- ; Since we just moved the pointer to another amoeba, rotate direction anticlockwise --- 01:CF35:A9 40 LDA #$40 --- 01:CF37:85 4E STA Temp_AmoebaDirection = #$00 --- 01:CF39:4C 44 CF JMP DoUntilAll25TriesExpired --- OkSetAmoeba: --- 01:CF3C:20 99 CF JSR IntendToSetAmoebaToMap --- 01:CF3F:90 01 BCC Restore_X --- 01:CF41:60 RTS ----------------------------------------------------------- --- Restore_X: --- 01:CF42:C6 50 DEC Temp_X = #$0A --- DoUntilAll25TriesExpired: --- 01:CF44:C6 4D DEC 25Tries = #$0A --- 01:CF46:F0 03 BEQ All25TriesExpired --- 01:CF48:4C 87 CE JMP Loop25Tries --- All25TriesExpired: --- ; Exits from UpdateAmoeba --- 01:CF4B:A5 4F LDA Temp_Y = #$38 --- 01:CF4D:05 4E ORA Temp_AmoebaDirection = #$00 --- 01:CF4F:85 BB STA AmoebaDirectionAnd_Y = #$41 --- 01:CF51:A5 50 LDA Temp_X = #$0A --- 01:CF53:85 BC STA Amoeba_X = #$18 --- 01:CF55:E6 B7 INC AmoebaPhase = #$82 --- 01:CF57:A5 B7 LDA AmoebaPhase = #$82 --- 01:CF59:29 83 AND #$83 --- 01:CF5B:85 B7 STA AmoebaPhase = #$82 --- 01:CF5D:60 RTS ----------------------------------------------------------- --- --- CheckMultiplying_Left: --- ; Returns C=1 when the pointer is on another amoeba, Z=1 when can multiply --- 01:CF5E:A4 4F LDY Temp_Y = #$38 --- 01:CF60:C6 50 DEC Temp_X = #$0A --- 01:CF62:A6 50 LDX Temp_X = #$0A --- 01:CF64:20 7D CC JSR GetObjectFromMap --- 01:CF67:4C 8B CF JMP CheckMultiplying --- CheckMultiplying_Up: --- ; Returns C=1 when the pointer is on another amoeba, Z=1 when can multiply --- 01:CF6A:C6 4F DEC Temp_Y = #$38 --- 01:CF6C:A4 4F LDY Temp_Y = #$38 --- 01:CF6E:A6 50 LDX Temp_X = #$0A --- 01:CF70:20 7D CC JSR GetObjectFromMap --- 01:CF73:4C 8B CF JMP CheckMultiplying --- CheckMultiplying_Right: --- ; Returns C=1 when the pointer is on another amoeba, Z=1 when can multiply --- 01:CF76:E6 50 INC Temp_X = #$0A --- 01:CF78:A4 4F LDY Temp_Y = #$38 --- 01:CF7A:A6 50 LDX Temp_X = #$0A --- 01:CF7C:20 7D CC JSR GetObjectFromMap --- 01:CF7F:4C 8B CF JMP CheckMultiplying --- CheckMultiplying_Down: --- ; Returns C=1 when the pointer is on another amoeba, Z=1 when can multiply --- 01:CF82:E6 4F INC Temp_Y = #$38 --- 01:CF84:A4 4F LDY Temp_Y = #$38 --- 01:CF86:A6 50 LDX Temp_X = #$0A --- 01:CF88:20 7D CC JSR GetObjectFromMap --- CheckMultiplying: --- ; Returns C=1 when the pointer is on another amoeba, Z=1 when can multiply --- 01:CF8B:C9 D0 CMP #$D0 --- 01:CF8D:F0 08 BEQ OccupiedByAmoeba --- 01:CF8F:C9 00 CMP #$00 --- 01:CF91:F0 02 BEQ $CF95 --- 01:CF93:C9 20 CMP #$20 --- ; Return result in Z flag: Z=1 when can multiply --- 01:CF95:18 CLC --- 01:CF96:60 RTS ----------------------------------------------------------- --- OccupiedByAmoeba: --- ; The place is occupied by another amoeba, so we can't multiply there --- ; but instead we will move the pointer there! --- 01:CF97:38 SEC --- 01:CF98:60 RTS ----------------------------------------------------------- --- --- IntendToSetAmoebaToMap: --- ; Uses Temp_X/Temp_Y, returns C=1 on success, and C=0 when --Countdown_BD != 0 --- 01:CF99:A5 B7 LDA AmoebaPhase = #$82 --- 01:CF9B:09 80 ORA #$80 --- 01:CF9D:85 B7 STA AmoebaPhase = #$82 --- 01:CF9F:C6 BD DEC Amoeba_Timer = #$1D --- 01:CFA1:F0 02 BEQ ReallySetAmoebaToMap --- DontWantToMultiply: --- ; The IntendToSetAmoebaToMap() must be called many times, only then the multiplication will be made --- 01:CFA3:18 CLC --- 01:CFA4:60 RTS ----------------------------------------------------------- --- ReallySetAmoebaToMap: --- ; Uses Temp_X/Temp_Y, returns C=1 on success --- 01:CFA5:A4 4F LDY Temp_Y = #$38 --- 01:CFA7:A6 50 LDX Temp_X = #$0A --- 01:CFA9:A9 D0 LDA #$D0 --- 01:CFAB:20 77 D0 JSR SetObjectToMap --- 01:CFAE:A4 4F LDY Temp_Y = #$38 --- 01:CFB0:A6 50 LDX Temp_X = #$0A --- 01:CFB2:A9 D0 LDA #$D0 --- 01:CFB4:20 B7 D0 JSR AddObjectToBuffer --- SheduleNextTimer: --- ; Every time the waiting period decreases by 4 --- 01:CFB7:A5 BA LDA AmoebaTimerResetValue = #$3F --- 01:CFB9:38 SEC --- 01:CFBA:E9 04 SBC #$04 --- 01:CFBC:85 BA STA AmoebaTimerResetValue = #$3F --- 01:CFBE:85 BD STA Amoeba_Timer = #$1D --- ; Next update should reset the pointer to the origin --- 01:CFC0:A9 80 LDA #$80 --- 01:CFC2:85 B7 STA AmoebaPhase = #$82 --- 01:CFC4:38 SEC --- 01:CFC5:60 RTS ----------------------------------------------------------- ------------------------------------------------------------------------- - diff --git a/branches/sdl2/output/luaScripts/BugsBunnyBirthdayBlowout.lua b/branches/sdl2/output/luaScripts/BugsBunnyBirthdayBlowout.lua deleted file mode 100644 index 59cff15b..00000000 --- a/branches/sdl2/output/luaScripts/BugsBunnyBirthdayBlowout.lua +++ /dev/null @@ -1,210 +0,0 @@ ---Bugs Bunny Birthday Blowout ---Written by XKeeper ---Creates Lag and Sprite counters as well as Camera position - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function box(x1,y1,x2,y2,color) - if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function filledbox(x1,y1,x2,y2,color) - for i = 0, math.abs(y1 - y2) do - line(x1,y1 + i,x2,y1 + i,color); - end; -end; - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function lifebar(x, y, sx, sy, a1, a2, oncolor, offcolor, noborder) - -- this function will have the effect of drawing an HP bar - -- keep in mind xs and ys are 2px larger to account for borders - - x1 = x; - x2 = x + sx + 4; - y1 = y; - y2 = y + sy + 4; - w = math.floor(a1 / math.max(1, a1, a2) * sx); - if not a2 then w = 0 end; - - if (noborder) then - box(x1 + 1, y1 + 1, x2 - 1, y2 - 1, "#000000"); - else - box(x1 + 1, y1 + 1, x2 - 1, y2 - 1, "#ffffff"); - box(x1 , y1 , x2 , y2 , "#000000"); - end; - - if (w < sx) then - filledbox(x1 + w + 2, y1 + 2, x2 - 2, y2 - 2, offcolor); - end; - - if (w > 0) then - filledbox(x1 + 2, y1 + 2, x1 + 2 + w, y2 - 2, oncolor); - end; - -end; - - - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function line(x1,y1,x2,y2,color) - if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then - local success = pcall(function() gui.drawline(x1,y1,x2,y2,color) end); - if not success then - text(60, 224, "ERROR: ".. x1 ..",".. y1 .." ".. x2 ..",".. y2); - end; - end; -end; - -function text(x,y,str) - if (x >= 0 and x <= 255 and y >= 0 and y <= 240) then - gui.text(x,y,str); - end; -end; - -function pixel(x,y,color) - if (x >= 0 and x <= 255 and y >= 0 and y <= 240) then - gui.drawpixel(x,y,color); - end; -end; - - - -function drawpos(cx, cy, ex, ey, n) - sx = ex - cx; - sy = ey - cy; - - num = ""; - if n then - num = string.format("%02X", n); - end; - - if sx >= 0 and sx <= 255 and sy >= 0 and sy <= 244 then - line(sx, sy, sx + 16, sy + 0, "#ff0000"); - line(sx, sy, sx + 0, sy + 16, "#ff0000"); - text(sx, sy, num); - - elseif sx < 0 and sy >= 0 and sy <= 244 then - line(0, sy, 16, sy, "#ff0000"); - text(4, sy, num); - - elseif sx > 255 and sy >= 0 and sy <= 244 then - line(239, sy, 255, sy, "#ff0000"); - text(243, sy, num); - - elseif sy < 0 and sx >= 0 and sx <= 256 then - line(sx, 8, sx, 24, "#ff0000"); - text(sx, 8, num); - - elseif sy > 244 and sx >= 0 and sx <= 256 then - line(sx, 212, sx, 244, "#ff0000"); - text(sx, 216, num); - - end; - - -end; - - -lagdetectorold = 0; -timer = 0; -lagframes = 0; -lastlag = 0; - -while (true) do - - timer = timer + 1; - - lagdetector = memory.readbyte(0x00f5); --- if lagdetector == lagdetectorold then - if AND(lagdetector, 0x20) == 0x20 then --- if lagdetector == 0x0C then - lagframes = lagframes + 1; - else - if lagframes ~= 0 then - lastlag = lagframes; - end; - lagframes = 0; - lagdetectorold = lagdetector; - end; - memory.writebyte(0x00f5, OR(lagdetector, 0x20)); - - playerx = memory.readbyte(0x0432) + memory.readbyte(0x0433) * 0x100; - playery = memory.readbyte(0x0435) + memory.readbyte(0x0436) * 0x100; - - screenx = memory.readbyte(0x0456) + memory.readbyte(0x0457) * 0x100; - screeny = memory.readbyte(0x0458) + memory.readbyte(0x0459) * 0x100; - - text( 8, 8, string.format("%04X, %04X", playerx, playery)); - text( 8, 16, string.format("%04X, %04X", screenx, screeny)); - - drawpos(screenx, screeny, playerx, playery); - - - tmp = 0; - for i = 0, 0xb do - - offset = 0x7680 + i * 0x20; - - enemyt = memory.readbyte(offset); - enemyx = memory.readbyte(offset + 2) + memory.readbyte(offset + 3) * 0x100; - enemyy = memory.readbyte(offset + 4) + memory.readbyte(offset + 5) * 0x100; - - if enemyt ~= 0xff then --- text(160, 8 + 8 * tmp, string.format("%02X: %02X <%04X, %04X>", i, enemyt, enemyx, enemyy)); - drawpos(screenx, screeny, enemyx, enemyy, i); - tmp = tmp + 1; - end - end; - - - text(142, 192, string.format("%02d lag frames", lastlag)); - text(142, 216, string.format("%02d active sprites", tmp)); - --- box(2, 208, 2 + 8 * lastlag, 210, "#ff4444"); --- box(2, 209, 2 + 8 * lastlag, 211, "#ff4444"); --- box(2, 212, 2 + 8 * tmp, 213, "#4444ff"); --- box(2, 214, 2 + 8 * tmp, 215, "#4444ff"); - - lifebar(144, 200, 100, 4, lastlag, 8, "#ffcc22", "#000000"); - lifebar(144, 208, 100, 4, tmp, 12, "#4488ff", "#000000"); - - FCEU.frameadvance(); - -end; - - - - - - - - - - - - - - - diff --git a/branches/sdl2/output/luaScripts/ButtonCount.lua b/branches/sdl2/output/luaScripts/ButtonCount.lua deleted file mode 100644 index 651c3293..00000000 --- a/branches/sdl2/output/luaScripts/ButtonCount.lua +++ /dev/null @@ -1,156 +0,0 @@ ---Written by Brandon Evans - ---You can change the number of controllers tracked here. -local controllers = 2 ---You can change the position of the text here. -local x = 0 -local y = 8 - -local players = {} -local states = {} -local pressed = 0 -local inputted = 0 - -function table.copy(t) - local t2 = {} - for k, v in pairs(t) do - t2[k] = v - end - return t2 -end - -function counts() - --Display the counts of the buttons pressed and inputted. - gui.text(x, y, 'Pressed: ' .. pressed) - gui.text(x, y + 8, 'Inputted: ' .. inputted) -end - -function load(slot) - --As Lua starts counting from 1, and there may be a slot 0, increment. - slot = slot + 1 - if not states[slot] or states[slot].inputted == nil then - gui.text(x, y + 16, 'No data loaded from slot ' .. tostring(slot - 1)) - counts() - return - end - --Load the data if there is any available for this slot. - players = table.copy(states[slot].players) - pressed = states[slot].pressed - inputted = states[slot].inputted - gui.text(x, y + 16, 'Data loaded from slot ' .. tostring(slot - 1)) - counts() -end - -function parse() - --If there is an open, read-only FM2 file, parse it for the initial data. - if not movie.active() then - return false - end - local fh = io.open(movie.name()) - if not fh or movie.mode() == 'record' or movie.name():match( - '.%.(%w+)$' - ) ~= 'fm2' then - return false - end - local frame = -1 - local last = {} - local match = { - 'right', 'left', 'down', 'up', 'start', 'select', 'B', 'A' - } - --Parse up until two frames before the current one. - while frame ~= emu.framecount() - 2 do - line = fh:read() - if not line then - break - end - --This is only a frame if it starts with a vertical bar. - if string.sub(line, 0, 1) == '|' then - frame = frame + 1 - players = {} - local player = -1 - --Split up the sections by a vertical bar. - for section in string.gmatch(line, '[^|]+') do - player = player + 1 - --Only deal with actual players. - if player ~= 0 then - local button = 0 - --Run through all the buttons. - for text in string.gmatch(section, '.') do - button = button + 1 - --Check if this button is pressed. - if text ~= ' ' and text ~= '.' then - inputted = inputted + 1 - --If the button was not previously pressed, - --increment. - if table.maxn(last) < player or not last[player][ - match[button] - ] then - pressed = pressed + 1 - end - if table.maxn(players) < player then - table.insert(players, {}) - end - --Mark this button as pressed. - players[player][match[button]] = true - end - end - end - end - --Save the players to compare with the next frame in the file. - last = players - end - end - return true -end - -function save(slot) - --As Lua starts counting from 1, and there may be a slot 0, increment. - slot = slot + 1 - while table.maxn(states) < slot do - table.insert(states, {}) - end - --Mark the current data as the data for this slot. - states[slot].players = table.copy(players) - states[slot].pressed = pressed - states[slot].inputted = inputted - gui.text(x, y + 16, 'Data saved to slot ' .. tostring(slot - 1)) - counts() -end - -if parse() then - gui.text(x, y + 16, 'Movie parsed for data') -else - gui.text(x, y + 16, 'No movie parsed for data') -end -if savestate.registerload then - savestate.registerload(load) - savestate.registersave(save) -end - -while true do - --If this is the first frame, reset the data. - if emu.framecount() == 0 then - players = {} - pressed = 0 - inputted = 0 - end - --Check players one and two. - for player = 1, controllers do - local buttons = joypad.getdown(player) - --Run through all of the pressed buttons. - for i, v in pairs(buttons) do - inputted = inputted + 1 - --If in the previous frame the button was not pressed, increment. - if table.maxn(players) >= player and not players[player][i] then - pressed = pressed + 1 - end - end - if table.maxn(players) < player then - table.insert(players, true) - end - --Mark these buttons as pressed. - players[player] = buttons - end - counts() - emu.frameadvance() -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/CustomLagIndicator_RvT.lua b/branches/sdl2/output/luaScripts/CustomLagIndicator_RvT.lua deleted file mode 100644 index 50bdeded..00000000 --- a/branches/sdl2/output/luaScripts/CustomLagIndicator_RvT.lua +++ /dev/null @@ -1,45 +0,0 @@ ---------------------------------------------------------------------------- --- Custom Lag Indicator for "RoboCop Vs The Terminator (U) (Prototype).nes" --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * emu.setlagflag() ---------------------------------------------------------------------------- --- Usage: --- The "RoboCop Vs The Terminator" game, as well as "Battle City" and some --- other NES games, polls gamepads input every frame (in NMI), even when --- it's lagging. So standard way of detecting lag (used by FCEUX and other --- emulators) does not work for such games, and you have to determine lag --- manually. --- --- In this game example we can detect lag by watching the RAM address 0x322. --- This counter increases in non-lag frames only. --- Debugger says the address increases by the instruction "INC $0322" which --- is executed at ROM address 07:C6E9. So we should register a hook to this --- instruction, and every time it's executed we can be sure that current --- frame doesn't have lag ("no_lag = true"). --- Then we should register another hook to the point where the game --- polls Input (actually slightly after the point), so we can override --- standard lag detection. --- It's easy to find the code where the game polls input (reading from $4016). --- Se we register a hook to an instruction following the input polling code. --- In this case its ROM address 07:DE58. ---------------------------------------------------------------------------- - -no_lag = false; - -function set_nolag() - no_lag = true; -end -memory.registerexecute(0xC6E9, set_nolag); -- 07:C6E9 INC $0322 - -function determine_lagflag() - if (no_lag) then - emu.setlagflag(false); - no_lag = false; -- no_lag only affects once - else - emu.setlagflag(true); - end -end -memory.registerexecute(0xDE58, determine_lagflag); -- 07:DE58 The end of the cycle of reading from $4016-4017 (the point where FCEUX sets lagFlag to 0) - diff --git a/branches/sdl2/output/luaScripts/Excitingbike-speedometeronly.lua b/branches/sdl2/output/luaScripts/Excitingbike-speedometeronly.lua deleted file mode 100644 index 16d24b72..00000000 --- a/branches/sdl2/output/luaScripts/Excitingbike-speedometeronly.lua +++ /dev/null @@ -1,90 +0,0 @@ ---Exciting Bike - Speedometer ---Written by XKeeper ---Shows the speedometer (obviously) - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - - -function gameloop() - - - - -end; - - -gui.register(gameloop); - - -barcolors = {}; -barcolors[0] = "#000000"; -barcolors[1] = "#880000"; -barcolors[2] = "#ff0000"; -barcolors[3] = "#eeee00"; -barcolors[4] = "#00ff00"; -barcolors[5] = "#00ffff"; -barcolors[6] = "#0000ff"; -barcolors[7] = "#ff00ff"; -barcolors[8] = "#ffffff"; -barcolors[9] = "#123456"; - -lastvalue = {}; -justblinked = {}; -lastzero = {}; -timer = 0; -speed = 0; - -while (true) do - - timer = timer + 1; - lastvalue['speed'] = speed; - - - speed = memory.readbyte(0x0094) * 0x100 + memory.readbyte(0x0090); - positionx = memory.readbyte(0x0050) * 0x100 + memory.readbyte(0x0394); - timerspeed = 3 - memory.readbyte(0x004c); - timerslant = math.max(0, memory.readbyte(0x0026) - 1); - - if memory.readbyte(0x0303) ~= 0x8E then - text(255, 181, "Didn't advance this frame"); - end; - - speedadj1 = math.fmod(speed, 0x100); - speedadj2 = math.fmod(math.floor(speed / 0x100), #barcolors + 1); - speedadj3 = math.fmod(speedadj2 + 1, #barcolors + 1); - - lifebar( 61, 11, 100, 4, speedadj1, 0x100, barcolors[speedadj3], barcolors[speedadj2], "#000000", "#ffffff"); - - text( 0, 4 + 6, string.format("Speed: %4X", speed)); - text( 1, 4 + 14, string.format("S.Chg: %4d", speed - lastvalue['speed'])); - - text( 20, 222, " 2009 Xkeeper - http://jul.rustedlogic.net/ "); - line( 21, 231, 232, 231, "#000000"); - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Excitingbike.lua b/branches/sdl2/output/luaScripts/Excitingbike.lua deleted file mode 100644 index a6868ac9..00000000 --- a/branches/sdl2/output/luaScripts/Excitingbike.lua +++ /dev/null @@ -1,221 +0,0 @@ ---Exicitebike ---Written by XKeeper ---Shows various stats including a RAM map & speed - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - - -function gameloop() - - - - -end; - - -gui.register(gameloop); - - -barcolors = {}; -barcolors[0] = "#000000"; -barcolors[1] = "#880000"; -barcolors[2] = "#ff0000"; -barcolors[3] = "#eeee00"; -barcolors[4] = "#00ff00"; -barcolors[5] = "#00ffff"; -barcolors[6] = "#0000ff"; -barcolors[7] = "#ff00ff"; -barcolors[8] = "#ffffff"; -barcolors[9] = "#123456"; - -lastvalue = {}; -justblinked = {}; -lastzero = {}; -timer = 0; -speed = 0; - -while (true) do - - timer = timer + 1; - lastvalue['speed'] = speed; - - - speed = memory.readbyte(0x0094) * 0x100 + memory.readbyte(0x0090); - positionx = memory.readbyte(0x0050) * 0x100 + memory.readbyte(0x0394); - timerspeed = 3 - memory.readbyte(0x004c); - timerslant = math.max(0, memory.readbyte(0x0026) - 1); - - if memory.readbyte(0x0303) ~= 0x8E then - text(255, 181, "Didn't advance this frame"); - end; - - speedadj1 = math.fmod(speed, 0x100); - speedadj2 = math.fmod(math.floor(speed / 0x100), #barcolors + 1); - speedadj3 = math.fmod(speedadj2 + 1, #barcolors + 1); - - lifebar( 61, 11, 100, 4, speedadj1, 0x100, barcolors[speedadj3], barcolors[speedadj2], "#000000", "#ffffff"); - - text(198, 9, string.format("Speed %2d", timerspeed)); - text(196, 17, string.format(" Slant %2d", timerslant)); - box( 186, 10, 198, 18, "#000000"); - box( 186, 18, 198, 26, "#000000"); - - if timerspeed == 0 then - filledbox(187, 11, 197, 17, "#00ff00"); - if memory.readbyte(0x00B0) ~= 0 then - temp = "->"; - else - temp = "(B)"; - end; - text( 0, 50, string.format("Hold %s to maintain speed", temp)); - else - filledbox(187, 11, 197, 17, "#880000"); - end; - if timerslant <= 1 then - filledbox(187, 19, 197, 25, "#00ff00"); - text( 0, 58, string.format("Use < + > to modify angle")); - else - filledbox(187, 19, 197, 25, "#880000"); - end; - - - - text( 0, 4 + 6, string.format("Speed: %4X", speed)); - text( 1, 4 + 14, string.format("S.Chg: %4d", speed - lastvalue['speed'])); - - - - value = memory.readbyte(0x0064); - lifebar( 1, 1, 240, 6, value, 0xFF, "#ffffff", "#111144", false, "#000000"); - tp = math.floor(value / 255 * 240) + 4; - text(tp, 1, string.format("%02X", value)); - - - drawerpos = memory.readbyte(0x00e8); - screenpos = memory.readbyte(0x00eb); - - for x = 0, 0x3F do - for y = 0, 5 do - offset = y * 0x40 + x + 0x400; - value = memory.readbyte(offset); - color = string.format("#%02x%02x%02x", value, value, value); - x = math.fmod(x - screenpos, 0x40); - while (x < 0) do - x = x + 0x40; - end; - box(x * 3 + 8, y * 3 + 28, x * 3 + 9, y * 3 + 30, color); - box(x * 3 + 9, y * 3 + 28, x * 3 +10, y * 3 + 30, color); --- pixel(x * 3 + 9, y * 3 + 28, color); - end; - end; - - drawerpos = drawerpos - screenpos; - while (drawerpos < 0) do - drawerpos = drawerpos + 0x40; - end; - - box(math.fmod(drawerpos, 0x40) * 3 + 7, 27, math.fmod(drawerpos, 0x40) * 3 + 11, 5 * 3 + 31, "#dd0000"); --- box(math.fmod(screenpos, 0x40) * 3 + 7, 25, math.fmod(screenpos, 0x40) * 3 + 11, 5 * 3 + 31, "#00ff00"); - box(math.fmod(0, 0x40) * 3 + 7, 27, math.fmod(0, 0x40) * 3 + 11, 5 * 3 + 31, "#00ff00"); - - for i = 0, 5 do - offset = 0x00e8 + i; - if not lastzero[offset] then - lastzero[offset] = {}; - end; - - - value = memory.readbyte(offset); - - if lastvalue[offset] and lastvalue[offset] ~= value then - if not justblinked[offset] then - color = "#ffffff"; - else - color = "#dd0000"; - end; - justblinked[offset] = true; - else - color = "#dd0000"; - justblinked[offset] = false; - end; - - lifebar( 3, 190 + i * 8, 240, 6, value, 240, color, "#111144", false, "#000000"); - tp = math.floor(value / 240 * 240) + 4; - text(tp, 190 + i * 8, string.format("%02X", value)); - - if lastzero[offset]['time'] then - text(165, 190 + i * 8, string.format("%7sa %4df", string.format("%.2f", (lastzero[offset]['total'] / lastzero[offset]['samples'])), lastzero[offset]['time'])); - end; - if value == 0 and not lastzero[offset]['uhoh'] then - if lastzero[offset]['fr'] then - lastzero[offset]['time'] = timer - lastzero[offset]['fr']; - if lastzero[offset]['total'] then - lastzero[offset]['total'] = lastzero[offset]['total'] + lastzero[offset]['time']; - lastzero[offset]['samples'] = lastzero[offset]['samples'] + 1; - else - lastzero[offset]['total'] = lastzero[offset]['time']; - lastzero[offset]['samples'] = 1; - end; - end; - lastzero[offset]['fr'] = timer; - lastzero[offset]['uhoh'] = true; - elseif value ~= 0 then - lastzero[offset]['uhoh'] = false; - end; - - lastvalue[offset] = value; - - end; - - - ---[[ - startoffset = 0x5E0; - s = 0x120; - xs = 0x40; - ys = math.floor(s / xs); - for x = 0, xs - 1 do - for y = 0, ys - 1 do - offset = y * xs + x + startoffset; - value = memory.readbyte(offset); - if value == 0x40 then - color = "clear"; - else - value = math.fmod(value * 0x10, 0x100); - color = string.format("#%02x%02x%02x", value, value, value); - end; - - box(x * 3 + 8, y * 3 + 64, x * 3 + 10, y * 3 + 66, color); - pixel(x * 3 + 9, y * 3 + 65, color); - end; - end; - -]] - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/FRKfunctions.lua b/branches/sdl2/output/luaScripts/FRKfunctions.lua deleted file mode 100644 index 0dfaeb9b..00000000 --- a/branches/sdl2/output/luaScripts/FRKfunctions.lua +++ /dev/null @@ -1,625 +0,0 @@ -_FRK_Fn= {} -_FRK_Fn.version= 1 - ---FatRatKnight --- Various little functions for use. - --- Shortly, I will list out functions and keywords that the script provides --- access to. But first, I feel a need to explain a few things... - --- Option keywords are simply global variables that this auxillary script looks --- for. If they are anything other than false or nil by the time your script --- calls requrie("FRKfunctions"), this script will react accordingly. - --- Reserved variable names are those the script uses, but allows access for --- other scripts. Sorry about taking valuble names away from you, but I figure --- you might want direct access to them. - --- Functions are just that. Functions that do stuff, the whole point of this --- auxillary script. I copied down their line numbers for your convenience. --- If the quick description isn't enough, then perhaps the more detailed --- comments and actual code might be. - --- Options for individual functions can be changed by altering its number --- after the require("FRKfunctions") line. - - - ---List of option keywords: - --- _FRK_SkipRename Convenient names aren't used for these functions --- _FRK_NoAutoReg Will not automatically fill registers - - ---List of reserved variable names: - --- keys For checking current keys. --- lastkeys For checking previous keys. - - ---List of functions: - --- 82 UpdateKeys() Updates this script's key tables --- 97 Press(button) Checks for a key hit --- 109 PressRepeater(button) Like Press, but if held for long --- 133 Release(button) Checks for when a key is released --- 144 MouseMoved() Returns how far the mouse moved - --- 166 FBoxOldFast(x1, y1, x2, y2, color) Faster at drawing, but stupid --- 180 FBoxOld(x1, y1, x2, y2, color) Border-only box; corners fix --- 210 FakeBox(x1, y1, x2, y2, Fill, Border) Fill-and-Border box; corners fix --- 230 Draw[digit](Left,Top,color) Paints tiny digit on screen --- 354 _FRK_Fn._DN_AnyBase(right, top, Number, color, bkgnd, div) - -- Paints a right-aligned number using any base from 2 to 16. --- 405 DrawNum(right, top, Number, color, bkgnd) Paints a beautiful number --- 413 DrawNumx(right, top, Number, color, bkgnd) Hexidecimal version - --- 504 ProcessReg() Removes functions in registers and stores 'em --- 521 ApplyReg() Sets registers --- 534 AddReg(name, function) --- 543 RemoveReg(name, pos) - --- 564 limits(value,low,high) Returns value or specified limits --- 575 within(value,low,high) Returns T/F; Is it within range? - - ---List of options for individual functions: - -_FRK_Fn.RepeaterDelay= 5 --How long should PressRepeater wait? - - - - - - - - - - --- input.get family - ---***************************************************************************** -function _FRK_Fn.UpdateKeys() ---***************************************************************************** --- Moves keys into lastkeys, then puts fresh keyboard input into keys. --- Meant to simplify the process of registering keyhits. --- Stick this thing at the beginning of a gui.register function or main loop. - - lastkeys= keys - keys= input.get() -end - -keys= input.get() -- Sanity. Want xmouse and ymouse to exist. -lastkeys= keys -- Otherwise, MouseMoved pings an error at me. - - ---***************************************************************************** -function _FRK_Fn.Press(button) -- Expects a key ---***************************************************************************** --- Returns true or false. It's true at the moment the user hits the button. --- Generally, if keys is pressed, the next loop around will set lastkeys, --- and thus prevent returning true more than once if held. - - return (keys[button] and not lastkeys[button]) -end - - -local repeater= 0 ---***************************************************************************** -function _FRK_Fn.PressRepeater(button) -- Expects a key ---***************************************************************************** ---DarkKobold & FatRatKnight --- Returns true or false. --- Acts much like press if you don't hold the key down. Once held long enough, --- it will repeatedly return true. --- It works fine if there are multiple calls to different buttons. Not so fine --- if there's multiple calls to the same button. Only one repeater variable... - - if keys[button] then - if not lastkeys[button] or repeater >= _FRK_Fn.RepeaterDelay then - return true - else - repeater = repeater + 1 - end - - elseif lastkeys[button] then -- To allow more calls for other buttons - repeater= 0 - end - return false -end - - ---***************************************************************************** -function _FRK_Fn.Release(button) -- Expects a key ---***************************************************************************** --- Returns true or false. It's true at the moment the user releases the button. --- Might be a good idea to know when the user ain't holding it anymore. --- Eh, I don't see any obvious application, but may as well have it. - - return ((not keys[button]) and lastkeys[button]) -end - - ---***************************************************************************** -function _FRK_Fn.MouseMoved() ---***************************************************************************** --- Returns two values: x,y --- This function tells you how far the mouse moved since the last update. --- It's simply the difference of what position it is now and what it once was. - - return (keys.xmouse - lastkeys.xmouse) , (keys.ymouse - lastkeys.ymouse) -end - - - - - - - - - - --- Display family --- For helping you see - ---***************************************************************************** -function _FRK_Fn.FBoxOldFast(x1, y1, x2, y2, color) ---***************************************************************************** --- Gets around FCEUX's problem of double-painting the corners. --- This particular function doesn't make sure the x and y are good. --- Call this instead if you need processing speed and know its fine - - gui.line(x1 ,y1 ,x2-1,y1 ,color) -- top - gui.line(x2 ,y1 ,x2 ,y2-1,color) -- right - gui.line(x1+1,y2 ,x2 ,y2 ,color) -- bottom - gui.line(x1 ,y1+1,x1 ,y2 ,color) -- left -end - - ---***************************************************************************** -function _FRK_Fn.FBoxOld(x1, y1, x2, y2, color) ---***************************************************************************** --- Gets around FCEUX's problem of double-painting the corners. --- This has several sanity checks to ensure a properly drawn box. --- It acts like the old-style border-only box. - - if (x1 == x2) and (y1 == y2) then -- Sanity: Is it a single dot? - gui.pixel(x1,y1,color) - - elseif (x1 == x2) or (y1 == y2) then -- Sanity: A straight line? - gui.line(x1,y1,x2,y2,color) - - else --(x1 ~= x2) and (y1 ~= y2) - local temp - if x1 > x2 then - temp= x1; x1= x2; x2= temp -- Sanity: Without these checks, - end -- This function may end up putting - if y1 > y2 then -- two or four out-of-place pixels - temp= y1; y1= y2; y2= temp -- near the corners. - end - - gui.line(x1 ,y1 ,x2-1,y1 ,color) -- top - gui.line(x2 ,y1 ,x2 ,y2-1,color) -- right - gui.line(x1+1,y2 ,x2 ,y2 ,color) -- bottom - gui.line(x1 ,y1+1,x1 ,y2 ,color) -- left - end -end - - ---***************************************************************************** -function _FRK_Fn.FakeBox(x1, y1, x2, y2, Fill, Border) ---***************************************************************************** --- Gets around FCEUX's problem of double-painting the corners. --- It acts like the new-style fill-and-border box. Not quite perfectly... --- One "problem" is that, if you specify Fill only, it won't successfully --- mimic the actual gui.box fill. - -if not Border then Border= Fill end - - gui.box(x1,y1,x2,y2,Fill,0) - FBoxOld(x1,y1,x2,y2,Border) -end - - ---### # ### ### # # ### ### ### ### ### # ## # ## ### ### ---# # ## # # # # # # # # # # # # # # # # # # # # # ---# # # ### ### ### ### ### ## ### ### # # ## # # # ## ## ---# # # # # # # # # # # # # ### # # # # # # # # ---### ### ### ### # ### ### # ### ### # # ## # ## ### # ---***************************************************************************** -_FRK_Fn.Draw= {} --Draw[button]( Left , Top , color ) ---***************************************************************************** ---Coordinates is the top-left pixel of the 3x5 digit. ---Used for drawing compact, colored numbers. - -local d= _FRK_Fn.Draw - -function d.D0(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+4,color) -end - -function d.D1(left, top, color) - gui.line(left ,top+4,left+2,top+4,color) - gui.line(left+1,top ,left+1,top+3,color) - gui.pixel(left ,top+1,color) -end - -function d.D2(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+3,left+2,top+1,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left ,top+2,color) - gui.pixel(left+2,top+2,color) -end - -function d.D3(left, top, color) - gui.line(left ,top ,left+1,top ,color) - gui.line(left ,top+2,left+1,top+2,color) - gui.line(left ,top+4,left+1,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) -end - -function d.D4(left, top, color) - gui.line(left ,top ,left ,top+2,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top+2,color) -end - -function d.D5(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+1,left+2,top+3,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left ,top+2,color) - gui.pixel(left+2,top+2,color) -end - -function d.D6(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+1,left ,top+4,color) - gui.line(left+2,top+2,left+2,top+4,color) - gui.pixel(left+1,top+2,color) - gui.pixel(left+1,top+4,color) -end - -function d.D7(left, top, color) - gui.line(left ,top ,left+1,top ,color) - gui.line(left+2,top ,left+1,top+4,color) -end - -function d.D8(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+2,color) - gui.pixel(left+1,top+4,color) -end - -function d.D9(left, top, color) - gui.line(left ,top ,left ,top+2,color) - gui.line(left+2,top ,left+2,top+3,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+2,color) -end - -function d.DA(left, top, color) - gui.line(left ,top+1,left ,top+4,color) - gui.line(left+2,top+1,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+3,color) -end - -function d.DB(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+1,top ,left+2,top+1,color) - gui.line(left+1,top+4,left+2,top+3,color) - gui.pixel(left+1,top+2,color) -end - -function d.DC(left, top, color) - gui.line(left ,top+1,left ,top+3,color) - gui.line(left+1,top ,left+2,top+1,color) - gui.line(left+1,top+4,left+2,top+3,color) -end - -function d.DD(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+2,top+1,left+2,top+3,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+4,color) -end - -function d.DE(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+1,top ,left+2,top ,color) - gui.line(left+1,top+4,left+2,top+4,color) - gui.pixel(left+1,top+2,color) -end - -function d.DF(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+1,top ,left+2,top ,color) - gui.pixel(left+1,top+2,color) -end - - -d[0],d[1],d[2],d[3],d[4]= d.D0, d.D1, d.D2, d.D3, d.D4 -d[5],d[6],d[7],d[8],d[9]= d.D5, d.D6, d.D7, d.D8, d.D9 -d[10],d[11],d[12],d[13],d[14],d[15]= d.DA, d.DB, d.DC, d.DD, d.DE, d.DF - ---***************************************************************************** -function _FRK_Fn._DN_AnyBase(right, top, Number, color, bkgnd, div) ---***************************************************************************** --- Works with any base from 2 to 16. Paints the input number. --- Returns the x position where it would paint another digit. --- It only works with integers. Rounds fractions toward zero. - - if div < 2 then return end -- Prevents the function from never returning. - - local Digit= {} - local Negative= false - if Number < 0 then - Number= -Number - Negative= true - end - - Number= math.floor(Number) - if not color then color= "white" end - if not bkgnd then bkgnd= "clear" end - - local i= 0 - if Number < 1 then - Digit[1]= 0 - i= 1 - end - - while (Number >= 1) do - i= i+1 - Digit[i]= Number % div - Number= math.floor(Number/div) - end - - if Negative then i= i+1 end - local left= right - i*4 - FakeBox(left+1, top-1, right+1, top+5,bkgnd,bkgnd) - - i= 1 - while _FRK_Fn.Draw[Digit[i]] do - _FRK_Fn.Draw[Digit[i]](right-2,top,color) - right= right-4 - i=i+1 - end - - if Negative then - gui.line(right, top+2,right-2,top+2,color) - right= right-4 - end - return right -end - - ---***************************************************************************** -function _FRK_Fn.DrawNum(right, top, Number, color, bkgnd) ---***************************************************************************** --- Paints the input number as right-aligned. Decimal version. - - return _FRK_Fn._DN_AnyBase(right, top, Number, color, bkgnd, 10) -end - ---***************************************************************************** -function _FRK_Fn.DrawNumx(right, top, Number, color, bkgnd) ---***************************************************************************** --- Paints the input number as right-aligned. Hexadecimal version. - - return _FRK_Fn._DN_AnyBase(right, top, Number, color, bkgnd, 16) -end - - - - - - - - - - --- Registry family --- For overloading the usual registers with multiple separate functions. - -local RegNames= {"Before", "After", "Exit", "Gui", "Save", "Load"} - -_FRK_Fn.RegList= {} -_FRK_Fn.RegList.Before={} -_FRK_Fn.RegList.After= {} -_FRK_Fn.RegList.Exit= {} -_FRK_Fn.RegList.Gui= {} -_FRK_Fn.RegList.Save= {} -_FRK_Fn.RegList.Load= {} - ---***************************************************************************** -_FRK_Fn.RegFn= {} --RegFn[name]() For various registers ---***************************************************************************** - -function _FRK_Fn.RegFn.Before() - local i= 1 - while (_FRK_Fn.RegList.Before[i]) do - _FRK_Fn.RegList.Before[i]() - i= i+1 - end -end - -function _FRK_Fn.RegFn.After() - local i= 1 - while (_FRK_Fn.RegList.After[i]) do - _FRK_Fn.RegList.After[i]() - i= i+1 - end -end - -function _FRK_Fn.RegFn.Exit() - local i= 1 - while (_FRK_Fn.RegList.Exit[i]) do - _FRK_Fn.RegList.Exit[i]() - i= i+1 - end -end - -function _FRK_Fn.RegFn.Gui() - local i= 1 - while (_FRK_Fn.RegList.Gui[i]) do - _FRK_Fn.RegList.Gui[i]() - i= i+1 - end -end - -function _FRK_Fn.RegFn.Save() - local i= 1 - while (_FRK_Fn.RegList.Save[i]) do - _FRK_Fn.RegList.Save[i]() - i= i+1 - end -end - -function _FRK_Fn.RegFn.Load() - local i= 1 - while (_FRK_Fn.RegList.Load[i]) do - _FRK_Fn.RegList.Load[i]() - i= i+1 - end -end - - -local EmuRegisters={ - emu.registerbefore, - emu.registerafter, - emu.registerexit, - gui.register, - savestate.registersave, - savestate.registerload -} ---***************************************************************************** -function _FRK_Fn.ProcessRegisters() ---***************************************************************************** --- Any functions in registers, such as those that might be inserted by --- auxillary files, are removed from their registers and inserted into my --- table of functions to execute. --- All registers will be empty after excecution of this function. - - for i= 1, 6 do - local test= EmuRegisters[i]() --- Make sure the function exists. Also, make sure it isn't ourselves... - if test and (test ~= _FRK_Fn.RegFn[ RegNames[i] ]) then - table.insert(_FRK_Fn.RegList[ RegNames[i] ],1,test) - end - end -end - ---***************************************************************************** -function _FRK_Fn.ApplyRegisters() ---***************************************************************************** --- Fills the registers with functions that will excecute functions stored in --- my tables. - - for i= 1, 6 do - if _FRK_Fn.RegList[ RegNames[i] ][ 1 ] then - EmuRegisters[i](_FRK_Fn.RegFn[ RegNames[i] ]) - end - end -end - ---***************************************************************************** -function _FRK_Fn.AddRegister(name, fn) ---***************************************************************************** --- Name should be "Before", "After", "Exit", "Gui", "Save", or "Load". --- Recommended for use if you plan to add functions to the register. - - table.insert(_FRK_Fn.RegList[name],fn) -end - ---***************************************************************************** -function _FRK_Fn.RemoveRegister(name, pos) ---***************************************************************************** --- Name should be "Before", "After", "Exit", "Gui", "Save", or "Load". --- You may omit pos. Doing so will remove and return the first function that's --- been inserted into my table. - - return table.remove(_FRK_Fn.RegList[name],pos) -end - - - - - - - - - - --- Miscellaneous family - ---***************************************************************************** -function _FRK_Fn.limits( value , low , high ) -- Expects numbers ---***************************************************************************** --- Returns value, low, or high. high is returned if value exceeds high, --- and low is returned if value is beneath low. --- Sometimes, you'd rather crop the number to some specific limits. - - return math.max(math.min(value,high),low) -end - - ---***************************************************************************** -function _FRK_Fn.within( value , low , high ) -- Expects numbers ---***************************************************************************** --- Returns true if value is between low and high, inclusive. False otherwise. --- Sometimes, you just want to know if the number is within a certain range. - - return ( value >= low ) and ( value <= high ) -end - - - - - - - - - ---============================================================================= -if not _FRK_SkipRename then ---============================================================================= - UpdateKeys= _FRK_Fn.UpdateKeys - Press= _FRK_Fn.Press - PressRepeater= _FRK_Fn.PressRepeater - Release= _FRK_Fn.Release - MouseMoved= _FRK_Fn.MouseMoved - - FBoxOldFast= _FRK_Fn.FBoxOldFast - FBoxOld= _FRK_Fn.FBoxOld - FakeBox= _FRK_Fn.FakeBox - Draw= _FRK_Fn.Draw - DrawNum= _FRK_Fn.DrawNum - DrawNumx= _FRK_Fn.DrawNumx - - ProcessReg= _FRK_Fn.ProcessRegisters - ApplyReg= _FRK_Fn.ApplyRegisters - AddReg= _FRK_Fn.AddRegister - RemoveReg= _FRK_Fn.RemoveRegister - - limits= _FRK_Fn.limits - within= _FRK_Fn.within -end - ---============================================================================= -if not _FRK_NoAutoReg then ---============================================================================= - emu.registerbefore( _FRK_Fn.RegFn.Before) - emu.registerafter( _FRK_Fn.RegFn.After ) - emu.registerexit( _FRK_Fn.RegFn.Exit ) - gui.register( _FRK_Fn.RegFn.Gui ) - savestate.registersave(_FRK_Fn.RegFn.Save ) - savestate.registerload(_FRK_Fn.RegFn.Load ) -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/GUI-iup_button.lua b/branches/sdl2/output/luaScripts/GUI-iup_button.lua deleted file mode 100644 index f1028575..00000000 --- a/branches/sdl2/output/luaScripts/GUI-iup_button.lua +++ /dev/null @@ -1,30 +0,0 @@ --- This script shows a simple button and click event - --- Include our help script to load iup and take care of exit -require("auxlib"); - -function testiup() - -- Our callback function - function someAction(self, a) gui.text(10,10,"pressed me!"); end; - - -- Create a button - myButton = iup.button{title="Button Textwtf"}; - - -- Set the callback - myButton.action = someAction; - - -- Create the dialog - dialogs = dialogs + 1; - handles[dialogs] = iup.dialog{ myButton, title="IupDialog Title"; }; - - -- Show the dialog (the colon notation is equal - -- to calling handles[dialogs].show(handles[dialogs]); ) - handles[dialogs]:show(); - -end - -testiup(); - -while (true) do -- prevent script from exiting - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/GUI-iup_example.lua b/branches/sdl2/output/luaScripts/GUI-iup_example.lua deleted file mode 100644 index cb2c71cc..00000000 --- a/branches/sdl2/output/luaScripts/GUI-iup_example.lua +++ /dev/null @@ -1,192 +0,0 @@ --- iup example --- this shows a test window with all kinds of idle dialogs --- docs: http://www.tecgraf.puc-rio.br/iup/ - --- include our generic script (TAKES CARE OF CLOSING DIALOGS and includes the two iup systems) -require("auxlib"); - --- Note that in the following example, parentheses are optional if you --- are specifying tables with curly braces! Might look a little confusing. -function testiup() - - local img1 = - iup.image{ - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1}, - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1}, - {1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1}, - {1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1}, - {1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1}, - {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1}, - {1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1}, - {1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,3,2,3,2,3,2,2,3,2,2,2,3,3,3,2,2,2,3,3,2,3,2,2,3,3,3,2,2,2}, - {2,2,2,3,2,3,3,2,3,3,2,3,2,3,2,2,2,3,2,3,2,2,3,3,2,3,2,2,2,3,2,2}, - {2,2,2,3,2,3,2,2,3,2,2,3,2,2,2,2,2,3,2,3,2,2,2,3,2,3,2,2,2,3,2,2}, - {2,2,2,3,2,3,2,2,3,2,2,3,2,2,3,3,3,3,2,3,2,2,2,3,2,3,3,3,3,3,2,2}, - {2,2,2,3,2,3,2,2,3,2,2,3,2,3,2,2,2,3,2,3,2,2,2,3,2,3,2,2,2,2,2,2}, - {2,2,2,3,2,3,2,2,3,2,2,3,2,3,2,2,2,3,2,3,2,2,3,3,2,3,2,2,2,3,2,2}, - {2,2,2,3,2,3,2,2,3,2,2,3,2,2,3,3,3,3,2,2,3,3,2,3,2,2,3,3,3,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,3,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; -- note that this ; is NOT the end of the command but a mere seperator, equivalent to a comma (,) - colors = - { - "BGCOLOR", -- 1 - "255 0 0", -- 2 - "0 0 0" -- 3 (changed because of Lua index starts at 1) - } - } - - local img2 = - iup.image{ - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,2,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,2,2,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {3,3,3,4,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {3,3,3,4,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {3,3,3,4,3,4,3,4,3,3,4,3,3,3,1,1,4,3,3,3,4,4,3,4,3,3,4,4,4,3,3,3}, - {3,3,3,4,3,4,4,3,4,4,3,4,3,4,1,1,3,4,3,4,3,3,4,4,3,4,3,3,3,4,3,3}, - {3,3,3,4,3,4,3,3,4,3,3,4,3,3,1,1,3,4,3,4,3,3,3,4,3,4,3,3,3,4,3,3}, - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {3,3,3,4,3,4,3,3,4,3,3,4,3,4,1,1,3,4,3,4,3,3,4,4,3,4,3,3,3,4,3,3}, - {3,3,3,4,3,4,3,3,4,3,3,4,3,3,1,1,4,4,3,3,4,4,3,4,3,3,4,4,4,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,4,3,3,3,4,3,3,3,3,3,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,4,4,4,3,3,3,3,3,3,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, - {2,2,2,2,2,2,2,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, - {3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}; -- note that this ; is NOT the end of the command but a mere seperator, equivalent to a comma (,) - colors = - { - "0 255 0", -- 1 - "BGCOLOR", -- 2 - "255 0 0", -- 3 - "0 0 0" -- 4 - } - } - - mnu = iup.menu{ - iup.submenu{ - title="IupSubMenu 1", - iup.menu { - iup.item{title="IupItem 1 Checked",value="ON"}, - iup.separator{}, - iup.item{title="IupItem 2 Disabled",active="NO"} - } - }, - iup.item{title="IupItem 3"}, - iup.item{title="IupItem 4"} - } - - btn = iup.button{title="Press me!"}; - -- set the callback function, action - -- when the user clicks on the button, this function is executed - -- and in this case, it fires a silly popup message - btn.action = - function (self) - iup.Message("Why","Why oh why did you press me?"); - end - - dialogs = dialogs + 1; -- there is no ++ in Lua - handles[dialogs] = - iup.dialog{ - title="IupDialog Title", - menu=mnu, -- add the menu in the table - iup.vbox{ - iup.hbox{ - iup.frame{ - title="IupButton", - iup.vbox{ - btn, -- add the button - iup.button{title="",image=img1}, - iup.button{title="",image=img1,impress=img2} - } - }, - iup.frame{ - title="IupLabel", - iup.vbox{ - iup.label{title="Label Text"}, - iup.label{title="",separator="HORIZONTAL"}, - iup.label{title="",image=img1} - } - }, - iup.frame{ - title="IupToggle", - iup.vbox{ - iup.toggle{title="Toggle Text", value="ON"}, - iup.toggle{title="",image=img1,impress=img2}, - iup.frame{ - title="IupRadio", - iup.radio{ - iup.vbox{ - iup.toggle{title="Toggle Text"}, - iup.toggle{title="Toggle Text"} - } - } - } -- /frame - } -- /vbox - }, - iup.frame{ - title="IupText/IupMultiline", - iup.vbox{ - iup.text{size="80x",value="IupText Text"}, - iup.multiline{size="80x60", - expand="YES", - value="IupMultiline Text\nSecond Line\nThird Line"} - } - }, - iup.frame{ - title="IupList", - iup.vbox{ - iup.list{"Item 1 Text","Item 2 Text","Item 3 Text"; expand="YES",value="1"}, - iup.list{"Item 1 Text","Item 2 Text","Item 3 Text"; dropdown="YES",expand="YES",value="2"}, - iup.list{"Item 1 Text","Item 2 Text","Item 3 Text"; editbox="YES",expand="YES",value="3"} - } - } - }, -- /hbox - iup.canvas{bgcolor="128 255 0"}, - gap="5", - alignment="ARIGHT", - margin="5x5" - } -- /vbox - }; - - handles[dialogs]:show(); -- this actually shows you the dialog. Note that this is equivalent to calling handles[dialogs].show(handles[dialogs]); just shorter. - -end - -testiup(); -- note that this is not called from within the loop! - --- once the loop quits, the script exits and all dialogs are automatically destroyed -while (true) do - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Galaxian.lua b/branches/sdl2/output/luaScripts/Galaxian.lua deleted file mode 100644 index d832166e..00000000 --- a/branches/sdl2/output/luaScripts/Galaxian.lua +++ /dev/null @@ -1,186 +0,0 @@ ---Galaxian ---Written by XKeeper ---Accesses the Music Player Easter Egg and displays the songs & information - -require "x_functions"; -require "x_interface"; - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu:5/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(6); -end; - -function musicplayer() - resets = memory.readbyte(0x0115); - song = memory.readbyte(0x0002); - songlua = math.max(1, math.floor(resets / 45)); - speed = memory.readbyte(0x0004); - speedde = memory.readbyte(0x0104); -- it's really an AND. But the only two values used are 0F and 07, so this modulous works. - pos = memory.readbyte(0x0000); - note = memory.readbyte(0x0001); - offsetb = song * 0x0100 + 0x4010 - 1; - offset = song * 0x0100 + pos - 1 + 0x4010; - note1 = 0x10 - math.floor(note / 0x10); - note2 = math.fmod(note, 0x10); - if note1 == 0x10 then note1 = 0 end; - - - text( 35, 42, string.format("Song Position: %02X%02X", song, pos)); - text( 40, 50, string.format("ROM Offset: %04X", offset)); - text( 43, 58, string.format("Song Speed: %02X", speed)); - text(105, 66, string.format(" %02X", math.fmod(speedde, speed))); - - lifebar(186, 21, 64, 4, note1, 15, "#8888ff", "#000066", false, "#ffffff"); - lifebar(186, 29, 64, 4, note2, 15, "#8888ff", "#000066", false, "#ffffff"); - text(178, 20, string.format("%X\n%X", note1, note2)); - - lifebar( 44, 67, 64, 4, math.fmod(speedde, speed), speed, "#8888ff", "#000066", false, "#ffffff"); - - if control.button(75, 90, 84, 1, "Toggle hex viewer") then - hexmap = not hexmap; - end; - - if hexmap then - songdata = {}; - songdata2 = {}; - for i = 0x00, 0xFF do - if i >= songs[songlua]['st'] and i <= songs[songlua]['en'] or true then - o = string.format("%02X", rom.readbyte(offsetb + i)); - else - o = ""; - end; - x = math.fmod(i, 0x10); - y = math.floor(i / 0x70); - if not songdata2[x] then - songdata2[x] = {}; - end; - if not songdata2[x][y] then - songdata2[x][y] = o; - -- songdata2[x][y] = string.format("%02X", y); - else - songdata2[x][y] = songdata2[x][y] .."\n".. o; - end; - end; - - for x = 0, 0x0F do - text(29 + x * 14, 100 + 8 * 0, songdata2[x][0]); - text(29 + x * 14, 100 + 8 * 7, songdata2[x][1]); - text(29 + x * 14, 100 + 8 * 14, songdata2[x][2]); - end; - - oboxx = 29 + math.fmod(pos, 0x10) * 14; - oboxy = 100 + 8 * math.floor(pos / 0x10); - c = "#ff0000"; - if math.fmod(timer, 4) < 2 then - c = "#FFFFFF"; - end; - box(oboxx, oboxy + 0, oboxx + 14, oboxy + 10, c); - end; - - if pos >= songs[songlua]['en'] then --and pos == 0xFE then - if not songs[songlua]['xx'] then - memory.writebyte(0x0104, 0xFF); --- text(50, 50, "LOCK"); - else - memory.writebyte(0x0115, songs[songs[songlua]['xx']]['rv']); - memory.writebyte(0x0002, songs[songs[songlua]['xx']]['sv']); - memory.writebyte(0x0004, songs[songs[songlua]['xx']]['sp']); - memory.writebyte(0x0000, songs[songs[songlua]['xx']]['st']); - end; - end; - - for id, val in pairs(songs) do - if id == songlua then - c = "#8888ff"; - if math.fmod(timer, 4) < 2 then - c = "#FFFFFF"; - end; - else - c = nil; - end; - if control.button(195, 33 + 11 * id, 57, 1, string.format("Play song %d", id), c, true) then --- resetrequired = true; --- memory.register(0x0104, nil); - memory.writebyte(0x0115, val['rv']); - memory.writebyte(0x0002, val['sv']); - memory.writebyte(0x0004, val['sp']); - memory.writebyte(0x0000, val['st']); - end; - end; - - if resetrequired then - text(50, 85, "Please soft-reset game."); - if movie.framecount() == 0 then - resetrequired = false; - end; - end; -end; - - -songs = { - -- resets song `id` speed start end - { rv = 0x2E, sv = 0x1B, sp = 0x0F, st = 0x00, en = 0xC6 }, - { rv = 0x5A, sv = 0x18, sp = 0x07, st = 0x00, en = 0xC2 }, - { rv = 0x87, sv = 0x06, sp = 0x0F, st = 0x00, en = 0x7F }, - { rv = 0xB4, sv = 0x16, sp = 0x0F, st = 0x50, en = 0xAF }, - { rv = 0xE1, sv = 0x1A, sp = 0x0F, st = 0x80, en = 0xF8, xx = 0x01 }, - }; -timer = 0; -hexmap = true; - -while true do - - timer = timer + 1; - input.update(); - - if memory.readbyte(0x0101) == 1 then - musicplayer(); - - else - filledbox(23, 49, 233, 130, "#000000"); - text( 25, 50, "Normally you'd have to do something insane"); - text( 52, 58, "like push RESET 45 times and"); - text( 56, 66, "hold A+B on P2's controller."); - - text( 28, 82, "Lucky for you, though, we borrowed this."); - text( 73, 90, "Feel free to use it."); - - text( 73, 119, "(Yeah, we've got that)"); - - timer2 = math.fmod(timer, 60); - if timer2 >= 30 then timer2 = 60 - timer2; end; - timer2 = math.floor((timer2 / 30) * 255); - c = string.format("#%02X%02XFF", timer2, timer2); - - if control.button(110, 106, 37, 1, " EASY ", c, "#ffffff") then - memory.writebyte(0x0101, 0x01); - memory.writebyte(0x0115, songs[2]['rv']); - memory.writebyte(0x0002, songs[2]['sv']); - memory.writebyte(0x0004, songs[2]['sp']); - memory.writebyte(0x0000, songs[2]['st']); - FCEU.softreset(); --- text(1, 1, 'woohoo'); - end; - end; - FCEU.frameadvance(); - -end; diff --git a/branches/sdl2/output/luaScripts/Gradius-BulletHell.lua b/branches/sdl2/output/luaScripts/Gradius-BulletHell.lua deleted file mode 100644 index 29fe3a85..00000000 --- a/branches/sdl2/output/luaScripts/Gradius-BulletHell.lua +++ /dev/null @@ -1,439 +0,0 @@ -SCRIPT_TITLE = "Gradius - Bullet Hell" -SCRIPT_VERSION = "1.0" - -require "m_utils" -m_require("m_utils",0) - ---[[ -Gradius - Bullet Hell -version 1.0 by miau - -Visit http://morphcat.de/lua/ for the most recent version and other scripts. - - -Controls - Press select to fire a bomb that will destroy all enemy bullets and grant you - invincibility for a short period of time. - -Supported roms - Gradius (J), Gradius (U), Gradius (E) - -Known bugs - - dying from blue bullets doesn't trigger the death sound effect --]] - ---configurable vars -local BOMBS_PER_LIFE = 5 -local HITBOX = {-2, 4, 9, 9} --vic viper's hit box for collision detection with blue bullets --------------------------------------------------------------------------------------------- - - - -local MAX_EXSPR = 64 -local timer = 0 -local spr = {} -local exspr = {} -local exsprdata = {} -local deathtimer = 0 -local bombtimer = 0 -local paused = 0 -local bombs = BOMBS_PER_LIFE -local bulletimg = "" - - -function makebinstr(t) - local str = "" - for i,v in ipairs(t) do - str = str..string.char(v) - end - return str -end - -function initialize() - --Transparency doesn't seem to work for gd images, bummer! - bulletimg = makebinstr( { - 0xff, 0xfe, 0, 0x6, 0, 0x6, 0x1, 0xff, - 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x2, 0x33, 0x6e, 0, - 0x2, 0x33, 0x6e, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0x2, 0x33, 0x6e, 0, 0x4d, 0xb6, 0xff, 0, - 0xdb, 0xff, 0xfc, 0, 0x2, 0x33, 0x6e, 0, - 0, 0, 0, 0, 0x2, 0x33, 0x6e, 0, - 0x4d, 0xb6, 0xff, 0, 0x4d, 0xb6, 0xff, 0, - 0xdb, 0xff, 0xfc, 0, 0xdb, 0xff, 0xfc, 0, - 0x2, 0x33, 0x6e, 0, 0x2, 0x33, 0x6e, 0, - 0xdb, 0xff, 0xfc, 0, 0xdb, 0xff, 0xfc, 0, - 0x4d, 0xb6, 0xff, 0, 0x4d, 0xb6, 0xff, 0, - 0x2, 0x33, 0x6e, 0, 0, 0, 0, 0, - 0x2, 0x33, 0x6e, 0, 0xdb, 0xff, 0xfc, 0, - 0x4d, 0xb6, 0xff, 0, 0x2, 0x33, 0x6e, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x2, 0x33, 0x6e, 0, - 0x2, 0x33, 0x6e, 0, 0, 0, 0, 0, - 0, 0, 0 } ) - - for i=0,31 do - spr[i] = { - status=0, - id=0, - x=0, - y=0, - timer=-1, - } - end -end - - -function createexsprite(s) - for i=0,MAX_EXSPR-1 do - if(exspr[i]==nil) then - exspr[i]=s - if(exspr[i].id==nil) then - exspr[i].id=0 - end - if(exspr[i].x==nil) then - exspr[i].x=0 - end - if(exspr[i].y==nil) then - exspr[i].y=0 - end - if(exspr[i].vx==nil) then - exspr[i].vx=0 - end - if(exspr[i].vy==nil) then - exspr[i].vy=0 - end - if(exspr[i].timer==nil) then - exspr[i].timer=0 - end - if(exspr[i].ai==nil) then - exspr[i].ai="" - end - return exspr[i] - end - end - return nil -end - -function destroyallexsprites() - exspr = {} -end - -function destroyexsprite(i) - exspr[i] = nil -end - -function destroysprite(i) - memory.writebyte(0x100+i,0x00) - memory.writebyte(0x120+i,0x00) - memory.writebyte(0x300+i,0x00) -end - - -function drawexsprite(id,x,y) - gui.gdoverlay(x, y, bulletimg) -end - - -function getvicdistance(x,y) - return getdistance(vic.x+4,vic.y+8,x,y) -end - -function doexspriteai(s) - if(s.ai=="Stray") then - if(s.timer==0) then - s.vx = -3 - s.vy = AND(timer,0x0F) / 8 - 1 - end - elseif(s.ai=="AimOnce") then - if(s.timer==0) then - s.vx,s.vy = get_vdir(s,vic) - s.vx = s.vx * 2 - s.vy = s.vy * 2 - --s.vy = AND(timer,0x0F) / 8 - 1 - end - elseif(s.ai=="AimDelayed") then - if(s.timer>=30 and s.timer<=33) then - local x,y = get_vdir(s,vic) - s.vx = (x+s.vx) - s.vy = (y+s.vy) - end - elseif(s.ai=="AimRight") then - if(s.timer==0) then - s.vx,s.vy = get_vdir(s,vic) - s.vx = s.vx * 2.5 - s.vy = s.vy * 1.5 - end - elseif(s.ai=="AimLeft") then - if(s.timer==0) then - s.vx,s.vy = get_vdir(s,vic) - s.vx = s.vx * 1.5 - s.vy = s.vy * 2.5 - end - elseif(s.ai=="BossPattern1") then - if(s.timer==0) then - s.vx = math.random(-100,0)/50 - s.vy = math.random(-100,0)/70 - elseif(s.timer>=30 and s.timer <=35) then - s.vx=s.vx/1.1 - s.vy=s.vy/1.1 - elseif(s.timer==70) then - local x,y = get_vdir(s,vic) - s.vx = x*3 - s.vy = y*3 - end - elseif(s.ai=="LimitedLifeSpan") then - if(s.timer>120) then - s.x=999 --results in death - end - end - - if(s.timer>600) then --delete extended sprites after 10 seconds in case one gets stuck on screen - s.x=999 - end -end - -function doboss1ai(s) - if(s.timer>80 and s.timer<320 and AND(s.timer,63)==0) then - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - createexsprite({x=s.x,y=s.y,ai="BossPattern1"}) - end - if(s.timer>320 and s.timer<520) then --pattern2 a - if(math.mod(s.timer,27)<=9 and AND(s.timer,3)==3) then - createexsprite({x=s.x,y=s.y,vx=-0.2,ai="AimDelayed"}) - end - end - if(s.timer>320 and s.timer<520) then --pattern2 b - if(AND(s.timer,63)==0) then - createexsprite({x=s.x,y=s.y,vx=-0.7,vy=-1.6}) - createexsprite({x=s.x,y=s.y,vx=-1.1,vy=-0.8}) - createexsprite({x=s.x,y=s.y,vx=-1.2,vy=-0}) - createexsprite({x=s.x,y=s.y,vx=-1.1,vy=0.8}) - createexsprite({x=s.x,y=s.y,vx=-0.7,vy=1.6}) - end - elseif(s.timer>520) then - s.timer = 60 - end -end - - -function dospriteai(s) - if(s.id==0x85) then --Fan - if(s.timer==30) then - createexsprite({x=s.x,y=s.y,ai="Stray"}) - end - elseif(s.id==0x86) then --Jumper - if(AND(s.timer,127)==40) then - createexsprite({x=s.x,y=s.y,vx=-1.5,vy=-0.5}) - createexsprite({x=s.x,y=s.y,vx=-1,vy=-1.1}) - createexsprite({x=s.x,y=s.y,vx=0,vy=-1.4}) - createexsprite({x=s.x,y=s.y,vx=1,vy=-1.1}) - createexsprite({x=s.x,y=s.y,vx=1.5,vy=-0.5}) - end - elseif(s.id==0x88) then --Rugul - if(AND(s.timer,63)==30) then - createexsprite({x=s.x,y=s.y,ai="Stray"}) - end - elseif(s.id==0x84 or s.id==0x9C) then --Fose, Uska(?) - if(AND(s.timer,63)==30) then - createexsprite({x=s.x,y=s.y,vx=0,vy=-2}) - elseif(AND(s.timer,63)==60) then - createexsprite({x=s.x,y=s.y,vx=0,vy=2}) - end - elseif(s.id==0x89 or s.id==0x8C) then --Rush - if(AND(timer,63)==5) then - createexsprite({x=s.x,y=s.y,vx=-1,vy=-1}) - end - elseif(s.id==0x96) then --Moai - elseif(s.id==0x97) then --Mother and Child - if(AND(timer,7)==0) then - local t = s.timer/15 - createexsprite({x=s.x+16,y=s.y+16,vx=math.sin(t)-1,vy=math.cos(t),ai="LimitedLifeSpan"}) - end - elseif(s.id==0x8B) then --Zabu - if(s.timer==5) then - createexsprite({x=s.x,y=s.y,vx=0.5,ai="AimDelayed"}) - end - elseif(s.id==0x92 or s.id==0x93 or s.id==0x87 or s.id==0x91) then --Dee-01, Ducker - --if(s.timer==5) then - local t = AND(s.timer,127) - if(t>60 and t<79 and AND(s.timer,3)==3) then - --createexsprite({x=s.x,y=s.y,ai="AimOnce"}) - createexsprite({x=s.x,y=s.y,ai="AimOnce"}) - end - elseif(s.id==0x98) then --boss... - doboss1ai(s) - end -end - - -function updatevars() - paused = memory.readbyte(0x0015) - if(paused==1) then - return - end - --load original sprites from ram - for i=0,31 do - --if(i==0 or memory.readbyte(0x0300+i)~=0) then - if(memory.readbyte(0x0300+i)~=spr[i].id) then - spr[i].timer = 0 - end - spr[i].status=memory.readbyte(0x0100+i) --1=alive, 2=dead - spr[i].id=memory.readbyte(0x0300+i) - spr[i].x=memory.readbyte(0x0360+i) - spr[i].y=memory.readbyte(0x0320+i) - spr[i].timer=spr[i].timer+1 - if(spr[i].id==0) then - spr[i].timer = 0 - else - dospriteai(spr[i]) - end - - if(i>3 and bombtimer>0 and getvicdistance(spr[i].x+4,spr[i].y+4)<30) then - if(spr[i].id~=0x29 and spr[i].id~=0x01 and spr[i].id~=0x99 and spr[i].id~=0x98 and spr[i].id~=0x94 and spr[i].id~=0x97 and spr[i].id~=0x96 and spr[i].id~=0x1E) then - --excluded: hidden bonus (0x29), power ups and moai bullets (0x01), boss (0x99+0x98), tentacle (0x94), mother (0x97), moai (0x96), gate (0x1E) - destroysprite(i) - end - end - --end - end - vic = spr[0] - - - - - if(deathtimer>0) then - if(deathtimer==120) then - destroyallexsprites() - deathtimer = 0 - bombs = BOMBS_PER_LIFE - else - if(deathtimer==1) then - --this is part of what gradius does to kill vic viper... - --faster and without the annoying sound effect. who cares! - memory.writebyte(0x4C,0x78) - memory.writebyte(0x0100,0x02) --status = dead - memory.writebyte(0x0160,0x00) - memory.writebyte(0x0140,0x00) - memory.writebyte(0x1B,0xA0) - memory.writebyte(0x0120,0x2D) --chr?-- - end - deathtimer = deathtimer + 1 - end - end - - - local jp = joypad.get(1) - if(jp.select and jp.select~=last_select and bombs>0) then - bombtimer = 1 - bombs = bombs - 1 - destroyallexsprites() - --destroy bullets - for i=1,31 do - if(spr[i].id<4 and spr[i].id~=1) then - destroysprite(i) - end - end - end - last_select = jp.select - - - if(last_vic_status~=vic.status) then - if(vic.status==2) then --vic died in the original game, start death timer to destroy all extended sprites - deathtimer = 1 - end - end - last_vic_status = vic.status - - --calculations on extended sprites - for i=0,MAX_EXSPR-1 do - if(exspr[i]~=nil) then - if(bombtimer>0 and getvicdistance(exspr[i].x+4,exspr[i].y+4)<25) then - destroyexsprite(i) - else - doexspriteai(exspr[i]) - exspr[i].timer = exspr[i].timer + 1 - exspr[i].x=exspr[i].x+exspr[i].vx - exspr[i].y=exspr[i].y+exspr[i].vy - if(exspr[i].x>255 or exspr[i].x<0 or exspr[i].y>255 or exspr[i].y<0) then - --destroy exsprite - exspr[i]=nil - break - end - --collision check with vic viper - if(deathtimer==0 and vic.status==1 and exspr[i].x>=vic.x+HITBOX[1] and exspr[i].x<=vic.x+HITBOX[3] - and exspr[i].y>=vic.y+HITBOX[2] and exspr[i].y<=vic.y+HITBOX[4]) then - deathtimer = 1 - end - end - end - end - - -end - -function render() - --bcbox(vic.x-2, vic.y+4, vic.x+9, vic.y+9, "#ffffff") - - gui.text(0, 8, string.format("bombs %d",bombs)); - --gui.text(0, 8, string.format("Lives %d",memory.readbyte(0x0020))); - --gui.text(0, 28, string.format("bombtimer %d",bombtimer)); - - --[[for i=1,31 do - if(spr[i].id~=0) then - gui.text(spr[i].x, spr[i].y, string.format("%X",spr[i].id)); - end - end--]] - - for i=0,MAX_EXSPR-1 do - if(exspr[i]~=nil) then - drawexsprite(exspr[i].id,exspr[i].x,exspr[i].y) - end - end - - - if(bombtimer>0) then - if(bombtimer<12) then - memory.writebyte(0x11,0xFF) --monochrome screen - else - memory.writebyte(0x11,0x1E) - end - bombtimer = bombtimer + 1 - for i=0,64 do - local x = vic.x+4+math.sin(i)*bombtimer*4 + math.random(0,12) - local y = vic.y+8+math.cos(i)*bombtimer*4 + math.random(0,12) - local c = 255-bombtimer - local cs = string.format("#%02x%02x00",c,c) - bcpixel(x,y,cs) - bcpixel(x-1,y,cs) - bcpixel(x+1,y,cs) - bcpixel(x,y+1,cs) - bcpixel(x,y-1,cs) - - x = vic.x+4+math.sin(i)*(20+math.sin(bombtimer/5)) - y = vic.y+8+math.cos(i)*(20+math.sin(bombtimer/5)) - bcpixel(x,y,cs) - bcpixel(x-1,y,cs) - bcpixel(x,y-1,cs) - end - if(bombtimer==180) then - bombtimer=0 - end - end -end - - -initialize() -vic = spr[0] -while(true) do - updatevars() - render() - EMU.frameadvance() - timer = timer + 1 -end diff --git a/branches/sdl2/output/luaScripts/JumpingFCEUXWindow.lua b/branches/sdl2/output/luaScripts/JumpingFCEUXWindow.lua deleted file mode 100644 index 918e473a..00000000 --- a/branches/sdl2/output/luaScripts/JumpingFCEUXWindow.lua +++ /dev/null @@ -1,33 +0,0 @@ -require 'winapi' - -fceuxWindowDY = 0; -fceuxWindowDX = 0; -MIN_JUMP_POWER = -20; - -function jumpingWindow() - desktopWidth, desktopHeight = winapi.get_desktop_window():get_bounds(); - - fceuxWindow = winapi.find_window("FCEUXWindowClass", nil); - fceuxWindowX, fceuxWindowY = fceuxWindow:get_position(); - fceuxWindowWidth, fceuxWindowHeight = fceuxWindow:get_bounds(); - - fceuxWindowDY = fceuxWindowDY + 1; -- gravity - fceuxWindowY = fceuxWindowY + fceuxWindowDY; - if (fceuxWindowY + fceuxWindowHeight >= desktopHeight and fceuxWindowDY >= 0) then - fceuxWindowY = desktopHeight - fceuxWindowHeight - 1; - -- bounce from floor - fceuxWindowDY = (0 - fceuxWindowDY) * 0.9; - if (fceuxWindowDY > MIN_JUMP_POWER) then fceuxWindowDY = MIN_JUMP_POWER - math.random(10); end - fceuxWindowDX = math.random(-7, 7); - end - - fceuxWindowX = fceuxWindowX + fceuxWindowDX; - if ((fceuxWindowX < 0 and fceuxWindowDX < 0) or (fceuxWindowX + fceuxWindowWidth >= desktopWidth and fceuxWindowDX > 0)) then - -- bounce from sides - fceuxWindowDX = 0 - fceuxWindowDX; - end - - fceuxWindow:resize(fceuxWindowX, fceuxWindowY, fceuxWindowWidth, fceuxWindowHeight); -end - -emu.registerbefore(jumpingWindow); diff --git a/branches/sdl2/output/luaScripts/Luabot.lua b/branches/sdl2/output/luaScripts/Luabot.lua deleted file mode 100644 index e20cd9f7..00000000 --- a/branches/sdl2/output/luaScripts/Luabot.lua +++ /dev/null @@ -1,249 +0,0 @@ --- BeeBee, LuaBot Frontend v1.07 --- qFox, 2 August 2008 - --- we need iup, so include it here (also takes care of cleaning up dialog when script exits) -require 'auxlib'; - -local botVersion = 1; -- check this version when saving/loading. this will change whenever the botsave-file changes. - -function createTextareaTab(reftable, tmptable, token, tab, fun, val) -- specific one, at that :) - reftable[token] = iup.multiline{title="Contents",expand="YES", border="YES" }; -- ,value=val}; - tmptable[token] = iup.vbox{iup.label{title="function "..fun.."()\n local result = no;"},reftable[token],iup.label{title=" return result;\nend;"}}; - tmptable[token].tabtitle = tab; -end; -function createTextareaTab2(reftable, tmptable, token, fun, arg) -- specific one, at that :) this one generates no return values - reftable[token] = iup.multiline{title="Contents",expand="YES", border="YES" }; --,value=fun}; - if (arg) then - tmptable[token] = iup.vbox{iup.label{title="function "..fun.."(wasOk) -- wasOk (boolean) is true when the attempt was ok\n"},reftable[token],iup.label{title="end;"}}; - else - tmptable[token] = iup.vbox{iup.label{title="function "..fun.."()\n"},reftable[token],iup.label{title="end;"}}; - end; - tmptable[token].tabtitle = fun; -end; - -function createGUI(n) - -- this table will keep the references for easy and fast lookup. - local reftable = {}; - -- this table we wont keep, it holds references to (mostly) cosmetic elements of the dialog - local tmptable = {}; - - -- ok, dont be intimidated by the next eight blocks of code. they basically all say the same! - -- every line creates an element for the gui and sets it up. every block is a tabbed pane and - -- they are all put into another tabbed pane themselves. all references are put into a table - -- paired with the tokens in the basicbot framework. this allows us to easily walk through - -- all the pairs of and replace them in the file, uppon writing. - - reftable.ROMNAME = iup.text{title="rom name", size="300x", value="something_or_the_other.rom"}; - tmptable.ROMNAME = iup.hbox{iup.label{title="Rom name: ", size="50x"}, reftable.ROMNAME, iup.fill{}}; - reftable.COMMENT = iup.text{title="comment", size="300x",value="a botscript for some game"}; - tmptable.COMMENT = iup.hbox{iup.label{title="Comment: ", size="50x"}, reftable.COMMENT, iup.fill{}}; - reftable.VERSION = iup.text{title="version", size="70x",value="1.00"}; - tmptable.VERSION = iup.hbox{iup.label{title="Version: ", size="50x"}, reftable.VERSION, iup.fill{}}; - tmptable.SAVE = iup.button{title="Save contents"}; - -- the callback is set after the dialog is created. we need the references to all controls for saving to work :) - tmptable.LOAD = iup.button{title="Load contents"}; - tmptable.WRITE = iup.button{title="Write bot script"}; - general = iup.vbox{tmptable.ROMNAME,tmptable.COMMENT,tmptable.VERSION,iup.fill{size="5x",},tmptable.SAVE,iup.fill{size="5x",},tmptable.LOAD,iup.fill{size="5x",},tmptable.WRITE,iup.fill{}}; - general.tabtitle = "General"; - - createTextareaTab(reftable, tmptable, "bA1", "A", "isPressedA1", "a1"); - createTextareaTab(reftable, tmptable, "bB1", "B", "isPressedB1", "b1"); - createTextareaTab(reftable, tmptable, "START1", "Start", "isPressedStart1", "start1"); - createTextareaTab(reftable, tmptable, "SELECT1","Select", "isPressedSelect1", "select1"); - createTextareaTab(reftable, tmptable, "UP1", "Up", "isPressedUp1", "up1"); - createTextareaTab(reftable, tmptable, "DOWN1", "Down", "isPressedDown1", "down1"); - createTextareaTab(reftable, tmptable, "LEFT1", "Left", "isPressedLeft1", "left1"); - createTextareaTab(reftable, tmptable, "RIGHT1", "Right", "isPressedRight1", "right1"); - tabs1 = iup.vbox{iup.tabs{tmptable.bA1,tmptable.bB1,tmptable.START1,tmptable.SELECT1,tmptable.UP1,tmptable.DOWN1,tmptable.LEFT1,tmptable.RIGHT1}}; - tabs1.tabtitle = "Player 1"; - - createTextareaTab(reftable, tmptable, "bA2", "A", "isPressedA2", "a2"); - createTextareaTab(reftable, tmptable, "bB2", "B", "isPressedB2", "b2"); - createTextareaTab(reftable, tmptable, "START2", "Start", "isPressedStart2", "start2"); - createTextareaTab(reftable, tmptable, "SELECT2","Select", "isPressedSelect2", "select2"); - createTextareaTab(reftable, tmptable, "UP2", "Up", "isPressedUp2", "up2"); - createTextareaTab(reftable, tmptable, "DOWN2", "Down", "isPressedDown2", "down2"); - createTextareaTab(reftable, tmptable, "LEFT2", "Left", "isPressedLeft2", "left2"); - createTextareaTab(reftable, tmptable, "RIGHT2", "Right", "isPressedRight2", "right2"); - tabs2 = iup.vbox{iup.tabs{tmptable.bA2,tmptable.bB2,tmptable.START2,tmptable.SELECT2,tmptable.UP2,tmptable.DOWN2,tmptable.LEFT2,tmptable.RIGHT2}}; - tabs2.tabtitle = "Player 2"; - - createTextareaTab(reftable, tmptable, "bA3", "A", "isPressedA3", "a3"); - createTextareaTab(reftable, tmptable, "bB3", "B", "isPressedB3", "b3"); - createTextareaTab(reftable, tmptable, "START3", "Start", "isPressedStart3", "start3"); - createTextareaTab(reftable, tmptable, "SELECT3","Select", "isPressedSelect3", "select3"); - createTextareaTab(reftable, tmptable, "UP3", "Up", "isPressedUp3", "up3"); - createTextareaTab(reftable, tmptable, "DOWN3", "Down", "isPressedDown3", "down3"); - createTextareaTab(reftable, tmptable, "LEFT3", "Left", "isPressedLeft3", "left3"); - createTextareaTab(reftable, tmptable, "RIGHT3", "Right", "isPressedRight3", "right3"); - tabs3 = iup.vbox{iup.tabs{tmptable.bA3,tmptable.bB3,tmptable.START3,tmptable.SELECT3,tmptable.UP3,tmptable.DOWN3,tmptable.LEFT3,tmptable.RIGHT3}}; - tabs3.tabtitle = "Player 3"; - - createTextareaTab(reftable, tmptable, "bA4", "A", "isPressedA4", "a4"); - createTextareaTab(reftable, tmptable, "bB4", "B", "isPressedB4", "b4"); - createTextareaTab(reftable, tmptable, "START4", "Start", "isPressedStart4", "start4"); - createTextareaTab(reftable, tmptable, "SELECT4","Select", "isPressedSelect4", "select4"); - createTextareaTab(reftable, tmptable, "UP4", "Up", "isPressedUp4", "up4"); - createTextareaTab(reftable, tmptable, "DOWN4", "Down", "isPressedDown4", "down4"); - createTextareaTab(reftable, tmptable, "LEFT4", "Left", "isPressedLeft4", "left4"); - createTextareaTab(reftable, tmptable, "RIGHT4", "Right", "isPressedRight4", "right4"); - tabs4 = iup.vbox{iup.tabs{tmptable.bA4,tmptable.bB4,tmptable.START4,tmptable.SELECT4,tmptable.UP4,tmptable.DOWN4,tmptable.LEFT4,tmptable.RIGHT4}}; - tabs4.tabtitle = "Player 4"; - - createTextareaTab2(reftable, tmptable, "ONSTART", "onStart", false); - createTextareaTab2(reftable, tmptable, "ONFINISH", "onFinish", false); - createTextareaTab2(reftable, tmptable, "ONSEGMENTSTART","onSegmentStart", false); - createTextareaTab2(reftable, tmptable, "ONSEGMENTEND", "onSegmentEnd", false); - createTextareaTab2(reftable, tmptable, "ONATTEMPTSTART","onAttemptStart", false); - createTextareaTab2(reftable, tmptable, "ONATTEMPTEND", "onAttemptEnd", true); - createTextareaTab2(reftable, tmptable, "ONINPUTSTART", "onInputStart", false); - createTextareaTab2(reftable, tmptable, "ONINPUTEND", "onInputEnd", false); - tabs5 = iup.vbox{iup.tabs{tmptable.ONSTART, tmptable.ONFINISH, tmptable.ONSEGMENTSTART, tmptable.ONSEGMENTEND, tmptable.ONATTEMPTSTART, tmptable.ONATTEMPTEND, tmptable.ONINPUTSTART, tmptable.ONINPUTEND}}; - tabs5.tabtitle = "Events"; - - createTextareaTab(reftable, tmptable, "SCORE", "score", "getScore", "score"); - createTextareaTab(reftable, tmptable, "TIE1", "tie1", "getTie1", "tie1"); - createTextareaTab(reftable, tmptable, "TIE2", "tie2", "getTie2", "tie2"); - createTextareaTab(reftable, tmptable, "TIE3", "tie3", "getTie3", "tie3"); - createTextareaTab(reftable, tmptable, "TIE4", "tie4", "getTie4", "tie4"); - tabs6 = iup.vbox{iup.tabs{tmptable.SCORE,tmptable.TIE1,tmptable.TIE2,tmptable.TIE3,tmptable.TIE4}}; - tabs6.tabtitle = "Score"; - - createTextareaTab(reftable, tmptable, "ISRUNEND", "isRunEnd", "isRunEnd", "isRunEnd"); - createTextareaTab(reftable, tmptable, "MUSTROLLBACK", "mustRollBack", "mustRollBack", "mustRollBack"); - createTextareaTab(reftable, tmptable, "ISSEGMENTEND", "isSegmentEnd", "isSegmentEnd", "isSegmentEnd"); - createTextareaTab(reftable, tmptable, "ISATTEMPTEND", "isAttemptEnd", "isAttemptEnd", "isAttemptEnd"); - createTextareaTab(reftable, tmptable, "ISATTEMPTOK", "isAttemptOk", "isAttemptOk", "isAttemptOk"); - tabs7 = iup.vbox{iup.tabs{tmptable.ISRUNEND,tmptable.MUSTROLLBACK,tmptable.ISSEGMENTEND,tmptable.ISATTEMPTEND,tmptable.ISATTEMPTOK}}; - tabs7.tabtitle = "Selection"; - - playertabs = iup.tabs{general,tabs1,tabs2,tabs3,tabs4,tabs5,tabs6,tabs7,title}; - handles[n] = iup.dialog{playertabs, title="BeeBee; BasicBot Frontend", size="450x200"} - handles[n]:showxy(iup.CENTER, iup.CENTER) - - -- now set the callback function for the save button. this will use all the references above. - -- these remain ok in the anonymous function by something called "closures". this means that - -- these variables, although local to the scope of the function, will remain their value in - -- the anonymous function. hence we can refer to them and fetch their contents, even though - -- you cant refer to them outside the context of the createGUI function. - tmptable.WRITE.action = - function(self, n) - local file = iup.filedlg{allownew="YES",dialogtype="SAVE",directory="./lua",showhidden="YES",title="Save botfile"}; - file:popup(iup.ANYWHERE,iup.ANYWHERE); - - if (file.value == "NULL") then - iup.Message("An error occurred trying to save your settings"); - return; - elseif (file.status == "-1") then - iup.Message("IupFileDlg","Operation canceled"); - return; - end - - -- ok, file selected, if an error occurred or user canceled, the function already returned, so lets write the bot! - - -- get the framework first. we need it to find the relevant tokens - local fh = assert(io.open("luabot_framework.lua","r")); - local framework = fh:read("*a"); - fh:close(); - - -- now replace all tokens by gui values - -- this is where the reftable comes in very handy :p - for token,obj in pairs(reftable) do - local st00pid = (reftable[token].value or ""); - framework = string.gsub(framework, "-- "..token, st00pid, 1); -- if nothing was entered, obj.value returns nil (not ""), so we have to make that translation - end; - - -- open the file, if old file, clear it - if (file.status == "1") then - fh = assert(io.open(file.value,"wb")); - else -- (file.status == "0") - fh = assert(io.open(file.value,"w+b")); -- clear file contents - end; - - -- write it - fh:write(framework); - - -- close it (automatically flushed) - fh:close(); - fh = nil; - - iup.Message ("Success", "Bot written to "..file.value.."!"); - end; - tmptable.SAVE.action = - function(self, n) - local file = iup.filedlg{allownew="YES",dialogtype="SAVE",directory="./lua",showhidden="YES",title="Save botfile",extfilter="BasicBot (*.bot)|*.bot|All files (*.*)|*.*|"}; - file:popup(iup.ANYWHERE,iup.ANYWHERE); - - if (file.status == 1) then -- cancel - return; - end; - - -- open the file, if old file, clear it - if (file.status == "1") then - fh = assert(io.open(file.value,"wb")); - else -- (file.status == "0") - fh = assert(io.open(file.value,"w+b")); -- clear file contents - end; - - -- allow us to detect the botfile version (warn the user if it's different?) - fh:write(botVersion.."\n"); - - -- now replace all tokens by gui values - -- this is where the reftable comes in very handy :p - for token,obj in pairs(reftable) do - print("------"); - print(token.." control -> "..tostring(obj)); - print(".value: "..tostring(obj.value)); - local st00pid = obj.value; - if (not st00pid) then st00pid = ""; end; - print(string.len(st00pid)); - fh:write(string.len(st00pid).."\n"); - if (string.len(st00pid) > 0) then fh:write(st00pid); end; - fh:write("\n"); - end; - - fh:close(); - iup.Message ("Success", "Settings saved!"); - end; - tmptable.LOAD.action = - function (self, n) - -- this function currently crashes fceux without notification - -- possibly because offsets are badly calculated, but serves as an example now - local file = iup.filedlg{allownew="NO",dialogtype="OPEN",directory="./lua",showhidden="YES",title="Save botfile",extfilter="BasicBot (*.bot)|*.bot|All files (*.*)|*.*|"}; - file:popup(iup.ANYWHERE,iup.ANYWHERE); - if (file.status == 1) then -- cancel - iup.Message ("Success", "Canceled by you..."); - return; - end; - local nellen = string.len("\n"); -- platform independent - fh = assert(io.open(file.value,"r")); - - fh:read("*n"); -- version - fh:read("*l"); -- return - - local len; - local data; - for token,crap in pairs(reftable) do - len = fh:read("*n"); -- read line (length) - if (not len) then - iup.Message ("Warning", "End of file reached too soon!"); - break; - end; -- no more data... (should we erase the rest?) - fh:read("*l"); -- return - data = fh:read(len); - if (not data) then - iup.Message ("Warning", "End of file reached too soon!"); - break; - end; -- no more data... (should we erase the rest?) - reftable[token].value = data; - fh:read("*l"); -- return - end; - iup.Message ("Success", "Settings loaded!"); - end; -end; - -dialogs = dialogs + 1; -createGUI(dialogs); -while (true) do - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Machrider.lua b/branches/sdl2/output/luaScripts/Machrider.lua deleted file mode 100644 index 53d56812..00000000 --- a/branches/sdl2/output/luaScripts/Machrider.lua +++ /dev/null @@ -1,266 +0,0 @@ ---Machrider - Speedometer ---Written by XKeeper - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - -function savereplay(filename, replaydata) - - stringout = ""; - - f = io.open(filename, "w"); - for k, v in pairs(replaydata) do - stringout = string.format("%d:%d:%d\n", k, v['speed'], v['gear']); - f:write(stringout); - end; - - f:close(); - - return true; - -end; - - - -olddist = 0; -lastcount = 0; -counter = 0; -altunittype = true; -waittimer = 0; -autoshift = true; -- auto-handle shifting? for the lazy people -speedgraph = {}; -timer = 0; -graphlen = 240; -graphheight = 100; -maxspeed = 500; -dorecording = false; - -while true do - - joydata = joypad.read(1); - if joydata['select'] and not joydatas then - altunittype = not altunittype; - joydatas = true; - - elseif joydata['up'] and joydata['B'] and not joydatas and dorecording then - savereplay("machriderspeed.xrp", speedgraph); - joydatas = true; - saved = true; - - elseif not joydata['select'] then - joydatas = false; - end; - - if saved and dorecording then - text(100, 140, "Saved data!"); - end; - - speedlow = memory.readbyte(0x0040); - speedhigh = memory.readbyte(0x0041); - speed = speedhigh * 0x100 + speedlow; - rpmlow = memory.readbyte(0x0042); - rpmhigh = memory.readbyte(0x0043); - rpm = rpmhigh * 0x100 + rpmlow; - gear = memory.readbyte(0x0032); - - - if autoshift and waittimer <= 0 then - if gear < 2 then - memory.writebyte(0x0032, 2); --- waittimer = 6; - elseif speed <= 250 and gear > 2 then - memory.writebyte(0x0032, math.max(gear - 1, 2)); --- waittimer = 6; - elseif speed >= 255 and gear < 3 then - memory.writebyte(0x0032, math.min(gear + 1, 3)); --- waittimer = 6; - end; - end; - waittimer = waittimer - 1; - - if dorecording then - timer = timer + 1; - speedgraph[timer] = {speed = speed, gear = gear}; - if timer > graphlen then - temp = timer - graphlen - 1; - -- speedgraph[temp] = nil; - end; - - - for i = timer - graphlen, timer do - if speedgraph[i] then - xp = ((i + 3) - timer) + graphlen; - yp = graphheight - (speedgraph[i]['speed'] / maxspeed) * graphheight; - - if (speedgraph[i]['gear'] == 0) then - c = "blue"; - elseif (speedgraph[i]['gear'] == 1) then - c = "green"; - elseif (speedgraph[i]['gear'] == 2) then - c = "#cccc00"; - elseif (speedgraph[i]['gear'] == 3) then - c = "red"; - else - c = "gray"; - end; - - -- pixel(((i + 3) - timer) + 60, 50 - speedgraph[i], "#ffffff"); - line(xp, 10, xp, graphheight + 10, "#000000"); - line(xp, yp + 10, xp, graphheight + 10, c); - pixel(xp, yp + 10, "#ffffff"); - - -- pixel(((i + 3) - timer) + 60, 50 - speedgraph[i], "#ffffff"); - end; - end; - end; - ---[[ - dist = math.fmod(memory.readbyte(0x0062), 0x20); - text( 8, 15, string.format("%02X %4dfr/mv", dist, lastcount)); - if dist > olddist then - lastcount = counter; - counter = 0; - end; - olddist = dist; - counter = counter + 1; - - lifebar( 8, 8, 0x1F * 5, 3, dist, 0x1F, "#ffffff", "#0000FF", "#000000", "#ffffff"); ---]] - - barwidth = 100; - segmentwidth = 2; - pct = speed / maxspeed * 100; - - if altunittype then - speedadjust = (65535 / 60 / 60 / 60) * speed; -- rough approximation of km/h - text(barwidth * segmentwidth - 2, 221, string.format(" %3.1dkm/h", speedadjust)); - else - text(barwidth * segmentwidth - 2, 221, string.format(" %3d", speed)); - end; - - box(2, 221, barwidth * segmentwidth + 2, 230, "#000000"); - box(2, 222, barwidth * segmentwidth + 2, 229, "#000000"); - box(2, 223, barwidth * segmentwidth + 2, 228, "#000000"); - box(2, 224, barwidth * segmentwidth + 2, 227, "#000000"); - box(2, 225, barwidth * segmentwidth + 2, 226, "#000000"); - lastseg = false; - - if pct > 0 then - for bl = 1, math.min(maxspeed - 1, speed) do - - pct = bl / maxspeed; - segment = math.floor(pct * barwidth); - if segment ~= lastseg then - - if pct < 0.50 then - val = math.floor(pct * 2 * 0xFF); - segcolor = string.format("#%02XFF00", val); - - elseif pct < 0.90 then - val = math.floor(0xFF - (pct - 0.5) * 100/40 * 0xFF); - segcolor = string.format("#FF%02X00", val); - - elseif bl < maxspeed then - val = math.floor((pct - 0.90) * 10 * 0xFF); - segcolor = string.format("#FF%02X%02X", val, val); - - else - segcolor = "#ffffff"; - end; - - - yb = math.max(math.min(3, (pct * 100 - 50)), 0); - -- box(segment * segmentwidth + 3, 225 - yb, segment * segmentwidth + 3 + (segmentwidth - 2), 229, segcolor); - box(segment * segmentwidth + 3, 225 - yb, segment * segmentwidth + 3, 229, segcolor); - -- box(bl * 3 + 3, 218, bl * 3 + 4, 225, segcolor); - -- line(bl * 3 + 4, 218, bl * 3 + 4, 225, segcolor); - end; - lastseg = segment; - end; - end; - - - - maxrpm = 0x7F; - barwidth = 104; - segmentwidth = 1; - pct = rpmhigh / maxrpm * 100; - - line(2, 220, (barwidth + 2) * segmentwidth + 2, 220, "#000000"); - - if autoshift then - text( 2, 203, string.format("AUTO %1d", gear + 1)); - else - text( 2, 203, string.format("Manual %1d", gear + 1)); - end; - if altunittype then - text( 2, 211, string.format("%5dRPM", math.min(9999, rpm * .25))); - else - text( 2, 211, string.format("%5dRPM", rpm)); - end; - - rpmhigh = math.min(maxrpm + 10, rpmhigh); - lastseg = false; - - if pct > 0 then - for bl = 1, rpmhigh do - - pct = bl / maxrpm; - segment = math.floor(pct * barwidth); - if segment ~= lastseg then - if pct < 0.70 then - val = math.floor(pct * (100/70) * 0xFF); - segcolor = string.format("#%02XFF00", val); - - elseif pct < 0.90 then - val = math.floor(0xFF - (pct - 0.7) * 100/20 * 0xFF); - segcolor = string.format("#FF%02X00", val); - - elseif bl < maxrpm then - val = math.floor((pct - 0.90) * 10 * 0xFF); - segcolor = string.format("#FF%02X%02X", val, val); - - else - segcolor = "#ffffff"; - end; - - yb = math.floor(math.max(math.min(4, segment - 99), 0) / 2); - -- box(segment * segmentwidth + 3, 225 - yb, segment * segmentwidth + 3 + (segmentwidth - 2), 229, segcolor); - segment = math.min(segment, barwidth); - box(segment * segmentwidth + 3, 221, segment * segmentwidth + 3, 223 - yb, segcolor); - -- box(bl * 3 + 3, 218, bl * 3 + 4, 225, segcolor); - -- line(bl * 3 + 4, 218, bl * 3 + 4, 225, segcolor); - end; - lastseg = seg; - end; - end; - - - - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/MegamanII-LaserEyes.lua b/branches/sdl2/output/luaScripts/MegamanII-LaserEyes.lua deleted file mode 100644 index 33c202f9..00000000 --- a/branches/sdl2/output/luaScripts/MegamanII-LaserEyes.lua +++ /dev/null @@ -1,730 +0,0 @@ -SCRIPT_TITLE = "Mega Man 2 LASER EYES" -SCRIPT_VERSION = "1.0" - -require "m_utils" -m_require("m_utils",0) - ---[[ -Mega Man 2 LASER EYES -version 1.0 by miau - -Visit http://morphcat.de/lua/ for the most recent version and other scripts. - - -Controls - Press select to fire a laser from Mega Man's eyes aimed at the closest object. - Left-click to drag and drop objects. - Middle-clicking instantly moves Mega Man to the cursor position. - -Supported roms - Rockman 2 - Dr Wily no Nazo (J), Mega Man 2 (U), Mega Man 2 (E) - -Known bugs -- shooting lasers at bosses is glitchy, do it at your own risk -- eyes might turn black for a short period of time after screen transition -- some objects have duplicate IDs which will result in wrong names being shown for them - --]] - ---configurable vars -local show_info = false --show sprite info on startup -local show_cursor = false --set this to true when recording a video - ---sound effects to use for various script events, nil to disable -local SFX_LASER = 0x25 -local SFX_EXPLOSION = 0x2B -local SFX_TARGET = nil --0x39 --0x21 --------------------------------------------------------------------------------------------- ---List of sound effects ---0x21 press ---0x22 peeewwwwwww ---0x23 metal blade ---0x24 mega buster ---0x25 sniper armor shot? ---0x26 hit1 ---0x27 air shooter ---0x28 energy ---0x29 touch ground ---0x2A wily thing ---0x2B destroy1 ---0x2C ?? ---0x2D reflected shot ---0x2E ?? (metal blade-like noise channel usage, short) ---0x2F menu selector ---0x30 mega man appear ---0x31 leaf shield ---0x32 menu open ---0x33 ?? (short, low noise) ---0x34 gate open ---0x35 atomic fire charge 1 ---0x36 atomic fire charge 2 ---0x37 atomic fire charge 2 ---0x38 atomic fire shot ? ---0x39 prop-top leap ---0x3A mega man disappearing ---0x3B diving into water ---0x3C appearing platform ---0x3D wily stage lava drops ---0x3E wily stage lava drops ---0x3F ?? (similar to 0x27) ---0x40 ?? (short noise) ---0x41 death ---0x42 e-tank/1up ---0x43 ?? (short noise in fixed intervals) - - - - - - -local sprdb = {} --enemy names source: http://megaman.wikia.com -sprdb[0x00] = {name="Squirt"} -sprdb[0x01] = {name="Squirt"} --spawned by Lantern Fish -sprdb[0x04] = {name="M-445"} -sprdb[0x07] = {name="Snapper Controller",invincible=true} -sprdb[0x08] = {name="Snapper"} -sprdb[0x0A] = {name="Crabbot"} -sprdb[0x0C] = {name="Croaker"} -sprdb[0x0D] = {name="Croaker (tiny)"} -sprdb[0x0E] = {name="",invincible=true} --bubble...underwater mega man -sprdb[0x0F] = {name="Lantern Fish"} -sprdb[0x13] = {name="Platform"} -sprdb[0x15] = {name="Beam"} -sprdb[0x16] = {name="Bubble Bat"} -sprdb[0x17] = {name="Robo-Rabbit"} -sprdb[0x18] = {name="Carrot"} --or mega man being hit -sprdb[0x1D] = {name="Mecha Monkey"} -sprdb[0x1E] = {name="Atomic Chicken Controller",invincible=true} -sprdb[0x1F] = {name="Atomic Chicken"} ---sprdb[0x1B] = {name="Climbing Mega Man"} --or hot dog fire ---sprdb[0x1C] = {name=""} --or hot dog fire controller? -sprdb[0x21] = {name="Telly Spawn Point",invincible=true} -sprdb[0x22] = {name="Telly"} -sprdb[0x23] = {name="Hothead"} --or Mega Buster -sprdb[0x24] = {name="Tackle Fire"} ---sprdb[0x27] = {name="Light Control"} ---sprdb[0x28] = {name="Light Control"} -sprdb[0x29] = {name="Cogwheel"} -sprdb[0x2A] = {name="Pierobot"} -sprdb[0x2B] = {name="Prop-Top Controller",invincible=true} -sprdb[0x2C] = {name="Prop-Top"} -sprdb[0x2E] = {name="Hot Dog"} -sprdb[0x2F] = {name="Gate"} -sprdb[0x30] = {name="Press"} -sprdb[0x31] = {name="Blocky"} -sprdb[0x32] = {name="Big Fish Controller",invincible=true} ---sprdb[0x33] = {name=""} --Bubble Lead -sprdb[0x34] = {name="Neo Met"} -sprdb[0x35] = {name="Bullet"} --Sniper Armor/Sniper Joe -sprdb[0x36] = {name="Fan Fiend"} --or Metal Blade -sprdb[0x37] = {name="Pipi Controller",invincible=true} --or Flash weapon (Time Stopper) controller(?) -sprdb[0x38] = {name="Pipi"} -sprdb[0x3A] = {name="Pipi Egg"} --or Item-3(?) -sprdb[0x3B] = {name="Pipi Egg Shell"} -sprdb[0x3C] = {name="Child Pipi"} -sprdb[0x3D] = {name="Lightning Lord"} -sprdb[0x3E] = {name="Thunder Chariot"} ---sprdb[0x3F] = {name="Lightning Bolt"} --or "splash"... (mega man diving into water) -sprdb[0x3F] = {invincible=true} -sprdb[0x40] = {name="Air Tikki"} -sprdb[0x41] = sprdb[0x40] -sprdb[0x44] = {name="Air Tikki Horn"} -sprdb[0x45] = {name="Gremlin"} -sprdb[0x46] = {name="Spring Head"} -sprdb[0x47] = {name="Mole Controller",invincible=true} -sprdb[0x48] = {name="Mole (rising)"} -sprdb[0x49] = {name="Mole (falling)"} -sprdb[0x4B] = {name="Crazy Cannon"} -sprdb[0x4D] = {name="Bullet (Crazy Cannon)"} -sprdb[0x4E] = {name="Sniper Armor"} -sprdb[0x4F] = {name="Sniper Joe"} -sprdb[0x50] = {name="Squirm"} -sprdb[0x51] = {name="Squirm Pipe"} - -sprdb[0x5C] = {name="Metal Blade"} -sprdb[0x5D] = {name="Air Shooter"} -sprdb[0x5E] = {name="Crash Bomb"} - ---[[sprdb[0x60] = {name="Bubble Man"} -sprdb[0x61] = sprdb[0x60] -sprdb[0x62] = sprdb[0x60] -sprdb[0x63] = {name="Metal Man"} --or Falling Blocks (Dragon) (id2:80) -sprdb[0x64] = sprdb[0x63] --or Falling Blocks (Dragon).. Dragon Controller? (id2:80) -sprdb[0x65] = sprdb[0x63] --or Dragon Body (id2:8B) -sprdb[0x66] = {name="Air Man"} --or Dragon Bottom (id2:8B) -sprdb[0x67] = sprdb[0x66] -sprdb[0x68] = sprdb[0x66] -sprdb[0x69] = {name="Crash Man"} -sprdb[0x6A] = sprdb[0x69] --running or wily boss no.2 (id2:8B/CB/83/C3/80) -sprdb[0x6B] = sprdb[0x69] --jumping -sprdb[0x70] = {name="Dragon"} --(id2:8B) -sprdb[0x71] = {name="Big Fish"} --Wily Boss 3 (id2:83) ---]] - -sprdb[0x76] = {name="Large Life Energy",invincible=true} -sprdb[0x77] = {name="Small Life Energy",invincible=true} -sprdb[0x78] = {name="Large Weapon Energy",invincible=true} -sprdb[0x79] = {name="Small Weapon Energy",invincible=true} -sprdb[0x7A] = {name="E-Tank",invincible=true} -sprdb[0x7B] = {name="1UP",invincible=true} - - -local eyes = {} -eyes.open = { - {0,0,0,0,0,1,1,0,1,0,0,0,0}, - {0,0,0,0,0,1,1,0,1,0,0,0,0}, -} -eyes.running = { - {0,0,0,0,0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,1,1,0,1,0,0,0,0}, - {0,0,0,0,0,1,1,0,1,0,0,0,0}, -} -eyes.shooting = { - {0,0,0,0,0,0,0,0,0,1,1,0,1}, - {0,0,0,0,0,0,0,0,0,1,1,0,1}, -} -eyes.ladder = { - {0,0,0,0,0,0,0,1,1,0,0,0,0}, - {0,0,0,0,0,0,0,1,1,0,0,0,0}, -} -eyes.closed = { - {0,0,0,0,0,0,0,0,0,0,0,0,0}, - {0,0,0,1,1,1,1,0,1,1,0,0,0}, -} -eyes.none = {} - -local mmeyes = eyes.open -local timer = 0 -local spr = {} -local last_inp = {} -local inp = {} -local laser = {timer=0} -local last_laser = 0 - - - ---very limited and hacky particle engine following -local P_MAX = 150 -local particle = {p={}} - -function particle.laserai(pi) - local function checkcollision(px,py,rx,ry) - if(px>=rx-8 and px<=rx+8 and py>=ry-8 and py<=ry+8) then - return true - else - return false - end - end - - for i=1,31 do - if(spr[i].a and is_enemy(i)) then - local px = particle.p[pi].x - local py = particle.p[pi].y - local px2 = particle.p[pi].x+particle.p[pi].vx*6 - local py2 = particle.p[pi].y+particle.p[pi].vy*6 - local rx = spr[i].x+spr[i].hx*256 - local ry = spr[i].y - if(checkcollision(px,py,rx,ry) or checkcollision(px2,py2,rx,ry)) then - --if(spr[i].hp>5) then - -- memory.writebyte(0x06C0+i,spr[i].hp-5) - --else - memory.writebyte(0x06C0+i,1) - play_sfx(SFX_EXPLOSION) - particle.explosion(spr[i].x+spr[i].hx*256,spr[i].y) - destroy_sprite(i) - --end - end - end - end -end - - -function particle.create(new) - for i=0,P_MAX-1 do - if(particle.p[i]==nil) then - particle.p[i]=new - if(particle.p[i].x==nil) then - particle.p[i].x=0 - end - if(particle.p[i].y==nil) then - particle.p[i].y=0 - end - if(particle.p[i].vx==nil) then - particle.p[i].vx=0 - end - if(particle.p[i].vy==nil) then - particle.p[i].vy=0 - end - if(particle.p[i].timer==nil) then - particle.p[i].timer=0 - end - if(particle.p[i].lspan==nil) then - particle.p[i].lspan=60 - end - if(particle.p[i].color==nil) then - particle.p[i].color="#FFFFFF" - end - return i - end - end - return nil -end - -function particle.explosion(x,y) --faster than using particle.create - local j = 0 - for i=0,P_MAX-1 do - if(particle.p[i]==nil) then - local vx = math.random(-50,50)/30 - local vy = math.random(-50,50)/30 - local color = "#FF0000" - particle.p[i] = {} - particle.p[i].x = x - particle.p[i].y = y - particle.p[i].vx = vx - particle.p[i].vy = vy - particle.p[i].color = color - particle.p[i].lspan = math.random(20,40) - particle.p[i].timer=0 - if(j==40) then - return - end - j = j + 1 - end - end -end - -function particle.destroy(i) - particle.p[i] = nil -end - - -function particle.update() - for i=0,P_MAX-1 do - if(particle.p[i]) then - if(particle.p[i].timer >= particle.p[i].lspan) then - particle.destroy(i) - else - if(particle.p[i].aifunc) then - particle.p[i].aifunc(i) - end - if(particle.p[i]) then - particle.p[i].x = particle.p[i].x + particle.p[i].vx - particle.p[i].y = particle.p[i].y + particle.p[i].vy - particle.p[i].timer = particle.p[i].timer + 1 - end - end - end - end -end - -function particle.render(xdisp,ydisp) - local j=0 - for i=0,P_MAX-1 do - if(particle.p[i]) then - bcline2(particle.p[i].x-xdisp,particle.p[i].y-ydisp, particle.p[i].x-xdisp+particle.p[i].vx*6,particle.p[i].y+particle.p[i].vy*6-ydisp, particle.p[i].color) - if(particle.p[i].aifunc) then - bcline2(particle.p[i].x-xdisp,particle.p[i].y+1-ydisp, particle.p[i].x-xdisp+particle.p[i].vx*6,particle.p[i].y+particle.p[i].vy*6+1-ydisp, particle.p[i].color) - end - j = j + 1 - end - end -end - - - - -function initialize() - for i=0,31 do - spr[i] = { - a=0, - id=0, - id2=0, - x=0, - y=0, - hp=0, - --timer=-1, - } - end -end - - -function unselect_all() - for i=0,31 do - spr[i].selected=false - spr[i].moving = false - end -end - -function getx16(s) - return s.hx*256+s.x -end - -function get_target() - --closest target - local closest = nil - local dmin = 9999 - for i=1,31 do - if(spr[i].a and is_enemy(i) and spr[i].seltimer>=10 and - ( (spr[i].sx>=megaman.sx and megaman.dir==1) - or (spr[i].sx<=megaman.sx and megaman.dir==-1) - or megaman.dir==0)) then - local d = getdistance(megaman.sx,megaman.sy,spr[i].sx,spr[i].sy) - if(d=0x80) - if(spr[i].a==false) then - spr[i].seltimer=nil - end - - if(spr[i].a) then - if(inp.xmouse>=spr[i].sx-8 and inp.xmouse<=spr[i].sx+8 and inp.ymouse>=spr[i].sy-8 and inp.ymouse<=spr[i].sy+8) then - spr[i].hover = true - spr[i].clicked = inp.leftclick - if(inp.leftclick and last_inp.leftclick==nil) then - unselect_all() - spr[i].selected=true - end - else - spr[i].hover = false - if(inp.leftclick==nil) then - spr[i].clicked = false - end - end - - --auto-target - if(is_enemy(i)) then - if(spr[i].seltimer==nil) then - spr[i].seltimer=1 - else - spr[i].seltimer = spr[i].seltimer + 1 - end - end - - if(spr[i].selected) then - --[[if(inp.delete) then - destroy_sprite(i) - elseif(inp.pagedown) then - memory.writebyte(0x0400+i,spr[i].id-1) - elseif(inp.pageup) then - memory.writebyte(0x0400+i,spr[i].id+1) - end-]] - - if(spr[i].clicked) then - if(inp.xmouse~=last_inp.xmouse or inp.ymouse~=last_inp.ymouse) then - spr[i].moving = true - end - else - spr[i].moving = false - end - end - - if(spr[i].moving) then - local x = inp.xmouse+scroll_x - memory.writebyte(0x0460+i,inp.xmouse+scroll_x) - memory.writebyte(0x04A0+i,inp.ymouse) - memory.writebyte(0x0440+i,scroll_hx+math.floor(x/256)) - end - - end - --end - end - - megaman = spr[0] - if(megaman.id2==0x80) then - megaman.dir=-1 - else - megaman.dir=1 - end - if(megaman.id==0x1B) then - megaman.dir = 0 - end - - - if(inp.middleclick) then --change mega man's coordinates - local x = inp.xmouse+scroll_x - memory.writebyte(0x0460,x) - memory.writebyte(0x04A0,inp.ymouse) - memory.writebyte(0x0440,scroll_hx+math.floor(x/256)) - end - - --LASER!!! - jp = joypad.read(1) - if(jp.select and (last_jp.select==nil or timer-last_laser>22)) then - local t = get_target() - local vx,vy - play_sfx(SFX_LASER) - if(t) then - vx,vy = getvdir(megaman.sx,megaman.sy-3,spr[t].sx,spr[t].sy) - vx = vx * 10 - vy = vy * 10 - else - if(megaman.dir==0) then - vx = 0 - vy = -10 - else - vx = megaman.dir*10 - vy = 0 - end - end - last_laser = timer - - particle.create({x=getx16(megaman),y=megaman.y-3,vx=vx,vy=vy,color="#FF0000",aifunc=particle.laserai}) - end - - if(inp.xmouse<83 and inp.ymouse<18) then - if(inp.leftclick and last_inp.leftclick==nil) then - if(show_info) then - show_info = false - else - show_info = true - end - end - end - - last_jp = jp - last_inp = inp -end - -function render() - - if(show_info) then - gui.text(0,8,"Sprite Info: ON") - else - gui.text(0,8,"Sprite Info: OFF") - end - if(inp.xmouse<83 and inp.ymouse<18) then - if(show_info) then - gui.drawbox(0,9,77,17,"red") - else - gui.drawbox(0,9,83,17,"red") - end - end - - particle.render(scroll_x+scroll_hx*256,0) - - --LASER EYES!!! - --TODO: prevent play_sfx from playing sounds during title screen/stage select - if(memory.readbyte(0x580) == 0x0D) then --title screen tune is being played - megaman.sx=211 - megaman.sy=131 - megaman.dir = -1 - mmeyes = eyes.open - - --lasers during title screen - if(AND(timer,7)==0 and math.random(0,1)==0) then - --play_sfx(SFX_LASER) - local vx,vy=getvdir(megaman.sx,megaman.sy-3,0,math.random(30,220)) - vx=vx*10 - vy=vy*10 - particle.create({x=megaman.sx+6,y=megaman.sy-3,vx=vx,vy=vy,color="#FF0000",aifunc=LaserAI}) - mmeyes = eyes.none - end - elseif(megaman.a) then --sprite active - local f = memory.readbyte(0x06A0)*256 + memory.readbyte(0x0680) - local frame = memory.readbyte(0x06A0) - local ftimer = memory.readbyte(0x0680) - if(memory.readbyte(0x69)~=0x0E) then --menu opened or "stage intro" tune - mmeyes = eyes.none - elseif(megaman.id==0x00) then --BLINK! change occurs on next frame - if(f >= 0xA01) then - mmeyes = eyes.closed - elseif(f>=0x001) then - mmeyes = eyes.open - end - elseif(megaman.id==0x01 or megaman.id==0x03 or megaman.id==0x05 or megaman.id==0x07 or megaman.id==0x0B or megaman.id==0x11 or megaman.id==0x13) then - mmeyes = eyes.shooting - elseif(megaman.id==0x04 or megaman.id==0x0C or megaman.id==0x0D or megaman.id==0x10) then - mmeyes = eyes.open - elseif(megaman.id==0x08 or megaman.id==0x09 or megaman.id==0x14) then - if((f>=0x201 and f<=0x300) or (f>=0x001 and f<=0x100)) then - mmeyes = eyes.running - else - mmeyes = eyes.open - end - elseif(megaman.id==0x18) then --getting hurt - mmeyes = eyes.closed - elseif(megaman.id==0x1C or megaman.id==0x1E) then --mega buster, other weapons - mmeyes = eyes.ladder - else--if(megaman.id==0x1A or megaman.id==0x1B) then --respawning after death, climbing a ladder - mmeyes = eyes.none - end - - --if(megaman.hp==0) then - -- mmeyes = eyes.none - --end - else - mmeyes = eyes.none - end - - if(mmeyes ~= eyes.none) then - local eyecolor = "#FF0000" - if(timer-last_laser<5) then - eyecolor = "#FFFFFF" - end - if(megaman.dir==-1) then - for y=1,4 do - if(mmeyes[y]) then - for x=1,14 do - if(mmeyes[y][15-x]==1) then - bcpixel(megaman.sx-9+x,megaman.sy-5+y,eyecolor) - end - end - end - end - else - for y=1,4 do - if(mmeyes[y]) then - for x=1,14 do - if(mmeyes[y][x]==1) then - bcpixel(megaman.sx-5+x,megaman.sy-5+y,eyecolor) - end - end - end - end - end - end - - - for i=0,31 do - if(spr[i].a) then - local x,y - local boxcolor - if(spr[i].clicked) then - boxcolor="#AA5500" - elseif(spr[i].hover) then - boxcolor="#FFCCAA" - else - boxcolor=nil - end - x = spr[i].sx - y = spr[i].sy - if(boxcolor) then - bcbox(x-9,y-9,x+9,y+9,boxcolor) - end - - if(spr[i].seltimer) then - if(spr[i].seltimer<30) then - local b=30-spr[i].seltimer - local c = (30-spr[i].seltimer)*8 - bcbox(x-9-b,y-9-b,x+9+b,y+9+b,string.format("#CC%02X%02X",c,c)) - if(spr[i].seltimer==23) then - play_sfx(SFX_TARGET) - end - elseif(spr[i].seltimer>90 or AND(timer,7)>2) then - bcbox(x-9,y-9,x+9,y+9,"red") - end - end - - - if(show_info and (spr[i].hover or spr[i].clicked or spr[i].seltimer)) then - --bctext(AND(spr[i].x+255-scroll_x,255), spr[i].y, i); - if(i==0) then - bctext(x, y, "Blue Bomber") - bctext(x, y+8, "("..spr[i].sx..","..spr[i].sy..")") - bctext(x, y+16, "HP "..spr[i].hp) - elseif(i>4) then - if(sprdb[spr[i].id] and sprdb[spr[i].id].name --[[and i>4--]]) then - bctext(x, y, sprdb[spr[i].id].name) - else - bctext(x, y, "("..spr[i].id..")") - end - bctext(x, y+8, "("..spr[i].sx..","..spr[i].sy..")") - if(spr[i].hp~=0) then - bctext(x, y+16, "HP "..spr[i].hp) - end - end - end - end - end - - if(show_cursor) then - local col2 - if(inp.leftclick) then - col2 = "#FFAA00" - elseif(inp.rightclick) then - col2 = "#0099EE" - elseif(inp.middleclick) then - col2 = "#AACC00" - else - col2 = "white" - end - drawcursor(inp.xmouse,inp.ymouse,"black",col2) - end -end - - - -initialize() - -while(true) do - update_vars() - render() - EMU.frameadvance() - timer = timer + 1 -end - - diff --git a/branches/sdl2/output/luaScripts/MemoryWatch.lua b/branches/sdl2/output/luaScripts/MemoryWatch.lua deleted file mode 100644 index 41358502..00000000 --- a/branches/sdl2/output/luaScripts/MemoryWatch.lua +++ /dev/null @@ -1,58 +0,0 @@ ---Memory Watch ---Creates a Dialog box for monitoring a game's RAM values. - ---Version History --- v0.01a (not yet done!) --- include some iup stuff and take care of cleanup -require 'auxlib'; - -local function toHexStr(n) - return string.format("%X",n); -end; - - -local mat = iup.matrix {numcol=4, numlin=10,numcol_visible=4, numlin_visible=10, width1="40", width2="80", width3="30", width4="30", ALIGNMENT1="ARIGHT", ALIGNMENT2="ALEFT"}; -mat.resizematrix = "YES"; -mat:setcell(0,1,"Address"); -- index 0 (i or j) will set title -mat:setcell(0,2,"Title"); -mat:setcell(0,3,"Dec"); -mat:setcell(0,4,"Hex"); - -dialogs = dialogs + 1; -handles[dialogs] = - iup.dialog{ - iup.vbox{ - iup.label{ - title="Enter a number in the first column (can be hex)." - }, - iup.label{ - title="Third and fourth are values of that address." - }, - iup.fill{size="5"}, - mat, - iup.fill{}, - }, - title="St00pid memory watch", - size="215x160", - margin="10x10" - }; - -handles[dialogs]:showxy(iup.CENTER, iup.CENTER); - -while (true) do - local cols = tonumber(mat.numcol); - for i=1,cols do - local val = tonumber(mat:getcell(i,1)); - if ( - --mat["edit_mode1x"..i] ~= "YES" and -- who knows what you're editing in there - val and val >= 0 and val <= 0xFFFF -- check bounds - ) then - local mem = memory.readbyte(val); - mat:setcell(i,3,mem..""); - mat:setcell(i,4,toHexStr(mem)); - end; - end; - mat.redraw = "C3:4"; - - FCEU.frameadvance(); -end; diff --git a/branches/sdl2/output/luaScripts/Multitrack.lua b/branches/sdl2/output/luaScripts/Multitrack.lua deleted file mode 100644 index baf67042..00000000 --- a/branches/sdl2/output/luaScripts/Multitrack.lua +++ /dev/null @@ -1,804 +0,0 @@ --- Multi-track rerecording for FCEUX 2.1.2 or later (script V2) --- To make up for the lack of an internal multi-track rerecording in FCEUX. --- It may get obsolete when TASEdit comes around. ---FatRatKnight --- Rewind (by Antony Lavelle) added by DarkKobold - --- Instructions: --- The script has its own buttons, defined in the junk below. --- If you're not sure what they do, experiment by pressing the button! --- If you're still not sure, I'll give you some basic idea here. - --- With the script buttons, defined by key down there, you can --- toggle the input on or off for the next frame. Just push --- the key button, and you'll see a light change. I don't --- recommend HOLDing down the key button, especially if they --- overlap with the actual controls you've set up on your --- emulator. Especially there, since that's where problems begin. - --- I also have options to determine whether the input from --- the emulator should apply or whether the script should --- bother. Hold space (default keys), and you can switch --- individual buttons on or off. The script will decide --- whether to ignore the script keys here or the input stored --- away in its list, with the options that pop up. - --- There's a player switch as well. Just hit the S key --- (default keys) and it'll change to player 2. Or 3, or 4. --- Or all players at once. This will make the script keys --- start working on other players instead of just 1. - --- Then there's the joypad input. home or end (default keys) --- grants varying levels of control to the emulator joypad. --- If you want to get rid of all control from the joypad setup --- of the emulator, you can do that. The defaults are to allow --- the controllers to toggle whatever input the script has. --- I did not implement a way to give this decision to --- individual joypad keys. - --- That's the basics of controlling input with this script. --- The script buttons let you decide input without a frame --- advance, and the joypad keys are there if you're so used --- to holding things down while pressing frame advance. - - --- A few more advanced things are in here. I will briefly mention them: - -- Rewind: Back up a frame or two with a press of a button! - -- Seems to hog up CPU greatly. Disable if you want things run smoothly. - -- Insert/Delete: Found a time saver, yet want to keep later input? - -- This lets you slide a chunk of frames forward or back. - -- I display a number that says how many frames are buffered. - -- Immediate: Good if you want to change input while rewinding. - -- Okay, its use is quite rare, but it's there. - --- Hopefully, this is enough to let you get started. Good luck! - - - --- Stuff that you are encouraged to change to fit what you need. ---***************************************************************************** --- Control scheme. Just experiment a little with the buttons. - -local selectplayer = "S" -- For selecting which player -local recordingtype= "space" -- For selecting how to record -local SetImmediate = "numpad5"--Toggle immediate option -local TrueSwitch = "home" -- Toggle whether joypad can turn off input -local FalseSwitch = "end" -- Toggle whether joypad can turn on input - -local show, hide = "pageup", "pagedown" -- Opacity adjuster -local scrlup, scrldown = "numpad8", "numpad2" -- Move the input display -local scrlleft, scrlright= "numpad4", "numpad6" -- Not a fast method, though. -local MorePast, LessPast = "numpad7", "numpad1" -- See more or less input! -local MoreFuture, LessFuture= "numpad3", "numpad9" -- Good use of screen space - -local add, remove = "insert", "delete" -- Moves input around -local rewind = "R" -- The button used to rewind things - -local key = {"right", "left", "down", "up", "L", "O", "J", "K"} -local btn = {"right", "left", "down", "up", "start", "select", "B", "A"} - --- key links to the keyboard keys, so change those to fit your control needs. --- btn links to joypad buttons. Don't change what's in there. --- However, feel free to reorder the strings in btn! It will change the display! - - ---***************************************************************************** --- Values to change. players, saveMax, and MsgDuration aren't changed in the --- code. All others are simply default values which can dynamically change. - -local players= 2 -- You may tweak the number of players here. - -local saveMax= 1000 -- Max Rewind Power. Set to 0 to disable - -local opaque= 0 -- Default opacity. 0 is solid, 4 is invisible. - -local dispX, dispY= 10, 99 -- Default input display position. - -local Past, Future= -10, 10 -- Keep Past negative; Range of input display - -local immediate= false -- true: Changes apply to list upon happening - -- false: Changes only apply on frame advance -local JoyOn = "inv" -- true OR "inv" If true, disable turn-off -local JoyOff= nil -- false OR nil If false, disable turn-on - -local MsgDuration= 60 -- How long should messages stay? - - ---***************************************************************************** - --- Stuff that really shouldn't be messed with, unless you plan to change the code significantly. -local optType= {"Both", "Keys", "List", "Off"} -- Names for option types -local keys, lastkeys= {}, {} -- To hold keyboard input -local Pin, thisInput= {}, {} -- Input manipulation array -local BufInput, BufLen= {},{}-- In case you want to insert or remove frames. -local option= {} -- Options for individual button input by script -local fc, lastfc= 0, 0 -- Frame counters -local FrameAdvance= false -- Frame advance detection -local pl= 1 -- Player selected -local plmin, plmax= 1, 1 -- For the all option -local repeater= 0 -- for holding a button -local rewinding= false -- For unpaused rewinding -local MsgTmr= 0 -- To time how long messages stay -local Message= "Activated Multitrack recording script. Have fun!" - - ---The stuff below is adapted from the original Rewinding script by Antony Lavelle - -local saveArray = {};--the Array in which the save states are stored -local saveCount = 0;--used for finding which array position to cycle through -local saver; -- the variable used for storing the save state -local rewindCount = 0;--this stops you looping back around the array if theres nothing at the end -local savePreventBuffer = 1;--Used for more control over when save states will be saved, not really used in this version much. - - --- Initialize tables for each player. -for i= 1, players do - Pin[i] = {} - thisInput[i] = {} - option[i] = {} - BufInput[i] = {} - BufLen[i] = 0 - for j= 1, 8 do - option[i][btn[j]]= 1 - end -end - --- Intention of options: --- "Both" Script buttons and input list used --- "Keys" Script buttons used --- "List" Input list used --- "Off" Script will not interfere with button - - ---***************************************************************************** -function press(button) ---***************************************************************************** ---FatRatKnight --- Checks if a button is pressed. --- The tables it accesses should be obvious in the next line. - - if keys[button] and not lastkeys[button] then - return true - end - - return false -end - - ---***************************************************************************** -function pressrepeater(button) ---***************************************************************************** ---DarkKobold; Changes by FatRatKnight. Description by FatRatKnight --- Checks if a button is pressed. Will keep returning true if held long enough. --- Accesses: keys[], lastkeys[], repeater - - if keys[button] then - if not lastkeys[button] or repeater >= 3 then - return true - else - repeater = repeater + 1; - end - - elseif lastkeys[button] then -- To allow more calls for other buttons - repeater= 0 - end; - return false -end - - ---***************************************************************************** -function NewMsg(text) ---***************************************************************************** ---FatRatKnight --- Sets the message and resets the timer --- Accesses: MsgTmr, Message - - MsgTmr= 0 - Message= text -end - - ---***************************************************************************** -function DispMsg() ---***************************************************************************** ---FatRatKnight --- Merely displays whatever text happens to be in Message --- Accesses: MsgTmr, Message, MsgDuration - - if MsgTmr < MsgDuration then - MsgTmr= MsgTmr + 1 - gui.text(0,20,Message) - end -end - - ---***************************************************************************** -function RewindThis() ---***************************************************************************** ---Added by DarkKobold; Made into function that returns T/F by FatRatKnight --- Loads a state that was saved just the frame prior --- Lets you know whether it was successful by returning true or false. --- Accesses: rewindCount, saveArray, saveCount, saveMax - - if rewindCount<=0 then - return false -- Failed to rewind - else - savestate.load(saveArray[saveCount]); - saveCount = saveCount-1; - rewindCount = rewindCount-1; - if saveCount<=0 then - saveCount = saveMax; - end; - end; - return true -- Yay, rewind! -end - - ---***************************************************************************** -function GetNextInput(P) ---***************************************************************************** ---FatRatKnight --- Gets the input from the input table. --- Accesses: BufLen[], BufInput[], fc, Pin[] - - if BufLen[P] > 0 then - return BufInput[P][BufLen[P]] - end - return Pin[P][fc-BufLen[P]] -end - - ---***************************************************************************** -function LoadStoredInput(P) ---***************************************************************************** ---FatRatKnight --- Loads up input into thisInput. --- Found a good reason why it should be called in several spots. --- Accesses: option[], thisInput[] - - local next= GetNextInput(P) - if next then - for i= 1, 8 do - local op= option[P][btn[i]] - if op == 1 or op == 3 then -- "Both" or "List" - thisInput[P][btn[i]]= next[btn[i]] - else - thisInput[P][btn[i]]= nil - end - end - else -- No input to load, so erase stuff. - for i= 1, 8 do - thisInput[P][btn[i]]= nil - end - end -end - - ---***************************************************************************** -function GetList(P,Offset) ---***************************************************************************** ---FatRatKnight --- Fetches the input from the list relative to current framecount. --- It takes into account insertions and deletions. --- Accesses: thisInput[], Pin[], BufLen[], BufInput[] - - if Offset == 0 then - return thisInput[P] - elseif Offset < 0 then - return Pin[P][fc+Offset] - end - - if BufLen[P] > 0 and BufLen[P] > Offset then - return BufInput[P][BufLen[P]-Offset] - end - return Pin[P][fc+Offset-BufLen[P]] -end - - ---***************************************************************************** -function InputSnap(P) ---***************************************************************************** ---FatRatKnight --- Will shove the input list over. --- Might end up freezing for a moment if there's a few thousand frames to shift --- Accesses: framed, BufLen, BufInput[], Pin[], players - - - if BufLen[P] < 0 then -- Squish! - local pointer= lastfc - while Pin[P][pointer] do - Pin[P][pointer]= Pin[P][pointer-BufLen[P]] - pointer= pointer+1 - end - end - - - if BufLen[P] > 0 then -- Foom! - local pointer= lastfc - while Pin[P][pointer] do - pointer= pointer+1 - end - -- pointer is now looking at a null frame. - -- Assume later frames are also null. - - while pointer > lastfc do - pointer= pointer-1 - Pin[P][pointer+BufLen[P]]= Pin[P][pointer] - end - -- pointer should now match lastfc. - -- Everything at lastfc and beyond should be moved over by BufLen. - - for i=0, BufLen[P]-1 do - Pin[P][lastfc +i]= BufInput[P][BufLen[P]-i] - end - end - - BufLen[P]= 0 -- If it ain't zero before, we did stuff to make us want it zero. -end - - ---***************************************************************************** -function NewFrame() ---***************************************************************************** ---FatRatKnight --- Psuedo-detection of frame-advance or state load. --- The lack of a function to otherwise detect state loads calls for this function --- Accesses: fc, lastfc, FrameAdvance - - fc= movie.framecount() - - for P= 1, players do - InputSnap(P) - LoadStoredInput(P) - end -end - -savestate.registerload(NewFrame) - - ---***************************************************************************** -local Draw= {} --Draw[button]( Left , Top , color ) ---***************************************************************************** ---FatRatKnight --- A set of functions for which to draw unique objects for each button. --- The functions are in a table, so I can index them easy. --- For use with DisplayInput() - -function Draw.right(x,y,color) -- ## - gui.line(x ,y ,x+1,y ,color) -- # - gui.line(x ,y+2,x+1,y+2,color) -- ## - gui.pixel(x+2,y+1,color) -end - -function Draw.left(x,y,color) -- ## - gui.line(x+1,y ,x+2,y ,color) -- # - gui.line(x+1,y+2,x+2,y+2,color) -- ## - gui.pixel(x ,y+1,color) -end - -function Draw.up(x,y,color) -- # - gui.line(x ,y+1,x ,y+2,color) -- # # - gui.line(x+2,y+1,x+2,y+2,color) -- # # - gui.pixel(x+1,y ,color) -end - -function Draw.down(x,y,color) -- # # - gui.line(x ,y ,x ,y+1,color) -- # # - gui.line(x+2,y ,x+2,y+1,color) -- # - gui.pixel(x+1,y+2,color) -end - -function Draw.start(x,y,color) -- # - gui.line(x+1,y ,x+1,y+2,color) -- ### - gui.line(x ,y+1,x+2,y+1,color) -- # -end - -function Draw.select(x,y,color) -- ### - gui.box(x ,y ,x+2,y+2,color) -- # # -end -- ### - -function Draw.A(x,y,color) -- ### - gui.box(x ,y ,x+2,y+1,color) -- ### - gui.pixel(x ,y+2,color) -- # # - gui.pixel(x+2,y+2,color) -end - -function Draw.B(x,y,color) -- # # - gui.line(x ,y ,x ,y+2,color) -- ## - gui.line(x+1,y+1,x+2,y+2,color) -- # # - gui.pixel(x+2,y ,color) -end - - ---***************************************************************************** -function DisplayInput() ---***************************************************************************** ---FatRatKnight; Changes by DarkKobold. --- Shows the input stream that is stored in this script. --- Converted into function form. There might be other ways of handling it. --- Accesses: dispX, dispY, Pin[], thisInput[], players - -dispX= math.min(math.max(dispX,-2),219) -if pl > players then -- All players, man? - dispX= math.min(dispX,243-16*players) -end - -if (Future-Past) > 53 then - Past= math.max(Past, -53) - Future= Past + 53 -end -Past = math.min(Past ,0) -Future= math.max(Future,0) -dispY = math.min(math.max(dispY, 3-4*Past),217-4*Future) - - for i= Past, Future do - - local X,Y= dispX,dispY - if i < 0 then - Y= Y-3 - elseif i > 0 then - Y= Y+3 - end - - for P= plmin, plmax do - local temp= {} -- I may want to pick thisInput instead of the frame list. - temp= GetList(P,i) - - local color - for j= 1, 8 do - if not temp then - color= "white" - elseif temp[btn[j]] then - color= "green" - else - color= "red" - end - - if pl <= players then - Draw[btn[j]]( X +4*j , Y +4*i , color) - else -- all players - local bx= X+1 +j +2*players*(j-1) +2*P - gui.box(bx , Y+4*i , bx+1 , Y+4*i +2 ,color) - end - end - end - end - - local color= "white" -- immediate == true - if not immediate then - color= "blue" - for P= plmin, plmax do - local TI= GetNextInput(P) - for i=1, 8 do - if not TI or (TI[btn[i]] and not thisInput[P][btn[i]]) or (not TI[btn[i]] and thisInput[P][btn[i]])then - color= "green" - end - end - end - end - if pl <= players then - gui.box(dispX+2,dispY-2,dispX+36,dispY+4,color) - else - gui.box(dispX+2,dispY-2,dispX+12 +16*players,dispY+4,color) - end -end - - --- Primary function. ... Why did I pick itisyourturn, anyway? ---***************************************************************************** -function itisyourturn() ---***************************************************************************** - keys= input.get() -- We need the keyboard and mouse! - fc= movie.framecount() -- We also need the Frame Count. - --- State: Rewind - if saveMax > 0 then -- Disable Rewind if none exists - if pressrepeater(rewind) or rewinding then - rewinding= false - if RewindThis() then - NewFrame() - movie.rerecordcounting(true) - end - if rewindCount <= 0 then - emu.pause() - end - end - end - - if (fc == 0) and (lastfc ~= 0) then -- Hacky bit of script... - NewFrame() -- In case of resets that aren't - end -- considered stateloads. - --- Selection: Players - if press(selectplayer) then - pl= pl + 1 - if (pl > players+1) or (players == 1) then - pl= 1 - end - --- For standard player loops for allplayer option - if pl > players then - plmin= 1 - plmax= players - else - plmin= pl - plmax= pl - end - end - - --- Input: Insert or delete frames - if press(add) then -- Part of the reason for - for P= plmin, plmax do -- speedy insertions and - BufLen[P]= BufLen[P]+1 -- deletions is due to the - if BufLen[P] > 0 then -- fact that I don't shift - BufInput[P][BufLen[P]]= {} -- frames immediately. - end - LoadStoredInput(P) - end - end -- I only shift once you - if press(remove) then -- begin rewind or load a - for P= plmin, plmax do -- state. At that point, - BufLen[P]= BufLen[P]-1 -- it may take a while if - LoadStoredInput(P) -- there's enough frames - end -- to shift around. - end - --- Input: Should thisInput always instantly write to input table? - if press(SetImmediate) then - if not immediate then - immediate= true - else - immediate= false - end - end - --- Input: Allow joypad to toggle input? - if press(TrueSwitch) then - if JoyOn == true then - JoyOn= "inv" - NewMsg("Joypad may now cancel input from the list") - else - JoyOn= true - NewMsg("Disabled joypad input cancellation") - end - end - if press(FalseSwitch) then - if JoyOff == false then - JoyOff= nil - NewMsg("Joypad may now write input into the list") - else - JoyOff= false - NewMsg("Disabled joypad input activation") - end - end - - --- Option: Opacity - if press(hide) and opaque < 4 then - opaque= opaque+1 - end - if press(show) and opaque > 0 then - opaque= opaque-1 - end - gui.transparency(opaque) - --- Option: Move input display by keyboard - if pressrepeater(scrlup) then - dispY= dispY - 1 - end - if pressrepeater(scrldown) then - dispY= dispY + 1 - end - if pressrepeater(scrlleft) then - dispX= dispX - 1 - end - if pressrepeater(scrlright) then - dispX= dispX + 1 - end - --- Option: Move input display by mouse - if keys["leftclick"] and lastkeys["leftclick"] then - dispX= dispX + keys.xmouse - lastkeys.xmouse - dispY= dispY + keys.ymouse - lastkeys.ymouse - end - --- Option: Adjust input display range - if pressrepeater(MorePast) then - Past= Past-1 -- Remember, Past is negative. - end -- Making it more negative would - if pressrepeater(LessPast) then -- let you see more of the past. - Past= Past+1 - end - if pressrepeater(MoreFuture) then -- On the other hand, I want to - Future= Future+1 -- make the Future positive. - end -- Don't we all want to be - if pressrepeater(LessFuture) then -- positive about the future? - Future= Future-1 - end - - --- Begin start of frame change - if FrameAdvance then - for P= 1, players do - if not Pin[P][lastfc] then - InputSnap(P) -- If last frame was empty, kill the shift - end -- Don't track more than one buffer for loads - --- Scroll the BufInput if there's anything in there. --- This can potentially slow things if you insert enough frames. - if BufLen[P] > 0 then - for i= BufLen[P], 1, -1 do - BufInput[P][i]= BufInput[P][i-1] - end - BufInput[P][1]= Pin[P][lastfc] - end - --- Store input - Pin[P][lastfc]= joypad.get(P) - - LoadStoredInput(P) - end -- Loop for each player - --- Resets key input, so it counts as pressed again if held through frame advance. - for i= 1, 8 do - lastkeys[key[i]]= nil - end - - end --- Done checking for a new frame - - --- Begin checking key input --- Are you setting button options? - if keys[recordingtype] then - gui.transparency(0) -- Override current opacity - for i= 1, 8 do -- key loop - --- Set current options - for P= plmin, plmax do - if press(key[i]) then - option[P][btn[i]]= option[plmax][btn[i]]+1 - if option[P][btn[i]] > 4 then - option[P][btn[i]]= 1 - end - end - end - --- Display current options - gui.text(20,20+12*i,btn[i]) - - if pl >= players + 1 then - local q= optType[option[1][btn[i]]] - for z= 2, players do - if q ~= optType[option[z][btn[i]]] then - q= "???" - break - end - end - gui.text(50,20+12*i,q) - else - gui.text(50,20+12*i,optType[option[pl][btn[i]]]) - end - - end -- key loop - --- Are you setting actual input? - else - for i= 1, 8 do - --- Toggle keyed input depending on options - for P= plmin, plmax do - op= option[P][btn[i]] - if op == 1 or op == 2 then -- "Both" or "Keys" - if press(key[i]) then - if thisInput[P][btn[i]] then - thisInput[P][btn[i]]= nil - else - thisInput[P][btn[i]]= true - end - end - end - end - - end -- key loop - --- Done with input. --- The next stuff is just displaying input table. --- It's here to hide it when setting options. - if opaque < 4 then - DisplayInput() - end - end -- Done with "options" if - --- Force copy of thisInput into the input table if immediate is on - if immediate then - for P= 1, players do - if not GetNextInput(P) then - Pin[P][fc-BufLen[P]]= {} - end -- Inserted frames always defined! Don't check for that - - if BufLen[P] > 0 then - for i= 1, 8 do - BufInput[P][BufLen[P]][btn[i]]= thisInput[P][btn[i]] - end - else - for i= 1, 8 do - Pin[P][fc-BufLen[P]][btn[i]]= thisInput[P][btn[i]] - end - end - end - end - --- Display selected player. Or other odds and ends. - if pl <= players then - gui.text(30,10,pl) - gui.text(45,10,BufLen[pl]) - else - gui.text(30,10,"A") - end; - - DispMsg() -- Also display whatever message is in there. - --- Change thisInput to conform to options - for P= 1, players do - for i= 1, 8 do - if thisInput[P][btn[i]] then - thisInput[P][btn[i]]= JoyOn -- Use the right kind of true - else - thisInput[P][btn[i]]= JoyOff -- And the right kind of false - end - end - end - --- Feed the input to the emulation. - if movie.mode() ~= "playback" then - for P= 1, players do - joypad.set(P, thisInput[P]) - end - end - - lastfc= fc -- Standard "this happened last time" stuff - lastkeys= keys -- Don't want to keep registering key hits. - FrameAdvance= false - -end -- Yes, finally! The end of itisyourturn! ---***************************************************************************** - - -gui.register(itisyourturn) -- Need to call while in between frames - -emu.pause(); -- Immediate pause is nice - ---***************************************************************************** -while true do -- Main loop ---***************************************************************************** --- Most of the stuff here by DarkKobold. Minor stuff by FatRatKnight --- Rewinding feature originally by Antony Lavelle. --- Keep in mind stuff here only happens on a frame advance or when unpaused. - - FrameAdvance= true - emu.frameadvance() - - if saveMax > 0 then -- Don't process if Rewind is disabled - if keys[rewind] and rewindCount > 0 then - rewinding= true - else - saveCount=saveCount+1; - rewindCount = math.min(rewindCount + 1,saveMax); - if saveCount==saveMax+1 then - saveCount = 1; - end - - if saveArray[saveCount] == nil then - saver = savestate.create(); - else - saver = saveArray[saveCount]; - end; - savestate.save(saver); - saveArray[saveCount] = saver; -- I'm pretty sure this line is unnecessary. - movie.rerecordcounting(false) - end - end - -end -- Main loop ends \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Multitrack2.lua b/branches/sdl2/output/luaScripts/Multitrack2.lua deleted file mode 100644 index 0913cb57..00000000 --- a/branches/sdl2/output/luaScripts/Multitrack2.lua +++ /dev/null @@ -1,1371 +0,0 @@ --- Multitrack v2 for FCEUX by FatRatKnight --- Recent addition: Experimental save. Same format as in .fm2 --- Did not include support to not have it trigger on script exit. Sorry... --- Additionally, there's no *loading* mechanism in this script. Eh... - - ---*************** -local players= 2 -- You may tweak the number of players here. ---*************** - - --- Rewind options -local saveMax= 50 -- How many save states to keep? Set to 0 to disable -local SaveBuf= 12 -- How many frames between saves? Don't use 0, ever. -local rewind= "numpad0" -- What key do you wish to hit for rewind? - ---Keep in mind: Higher saveMax, more savestates, more memory needed. - - ---Control -local PlayerSwitch= "home" -- For selecting other players -local opt= "end" -- For changing control options - -local BackupReadSwitch= "numpad-" -- Revert to backup copy -local BackupWriteSwitch= "numpad+" -- Copy input into backup - -local key = {"right", "left", "down", "up", "L", "O", "J", "K"} -local btn = {"right", "left", "down", "up", "start", "select", "B", "A"} - ---Try to avoid changing btn. You may reorder btn's stuff if you don't ---like the default order, however. Line up with key for good reasons. ---key is the actual keyboard control over the buttons. Change that! - - ---Insertions and deletions -local Insert= "insert" -- Inserts a frame at the frame you're at -local Delete= "delete" -- Eliminates current frame - - ---Display -local BackupDisplaySwitch= "numpad." -- Care to see the backup? - -local solid= "pageup" -- Make the display less -local clear= "pagedown" -- or more transparant. - -local DispN= "numpad8" -local DispS= "numpad2" -- For moving the -local DispE= "numpad6" -- display around. -local DispW= "numpad4" - -local MoreFutr= "numpad3" -local LessFutr= "numpad1" -- These will determine -local MorePast= "numpad7" -- how many frames you -local LessPast= "numpad9" -- want to display. -local ResetFP= "numpad5" - - ---Control options by keyboard -local OptUp= "numpad8" -local OptDn= "numpad2" -- Controls for changing -local OptRt= "numpad6" -- options by keyboard. -local OptLf= "numpad4" -local OptHit="numpad5" - - - ---Various colors I'm using. If you wish to bother, go ahead. -local shade= 0x00000080 -local white= "#FFFFFFFF" -local red= "#FF2000FF" -local green= 0x00FF00FF -local blue= 0x0040FFFF -local orange="#FFC000FF" -local yellow="#FFFF00FF" -local cyan= 0x00FFFFFF -local purple="#8020FFFF" - ---Default display stuff. Try to keep Past negative. -local DispX, DispY= 190, 70 --Position on screen to appear -local Past, Future= -12, 20 --How much input to see -local Opaque= 1 --0=unseen 1=visible Decimal in between works - - -local ListOfBtnClr= { -- Colors for individual buttons ---NotExist Off Ignored On - - white, red, orange, green, -- No backup to display - white, red, orange, green, -- Backup button is off - blue, blue, purple, cyan, -- Backup button is on - - white, red, orange, green, -- Same stuff as above. - white, red, orange, green, -- However, we're reading - blue, blue, purple, cyan, -- from backup here. - - white, red, orange, green, -- Likewise, but instead - white, red, orange, green, -- of read, we're writing - blue, blue, purple, cyan -- to the backup. Joy... -} - -local ListOfChangesClr= { -- Colors for backup-main comparisons ---NoMain NoMatch Equal - - white, green, blue, -- Backup just sits there... - white, orange, green, -- Reading from backup... - white, yellow, purple -- Writing to backup... -} - - - -local BackupFileLimit= 9 - - ---***************************************************************************** ---Please do not change the following, unless you plan to change the code: - -local plmin , plmax= 1 , 1 -local fc= movie.framecount() -local LastLoad= movie.framecount() -local saveCount= 0 -local saveArray= {} -local rewinding= false - -local BackupList= {} -local BackupOverride= {} -local DisplayBackup= true - -local InputList= {} -local ThisInput= {} -local BufInput= {} -local BufLen= {} -local TrueSwitch, FalseSwitch= {}, {} -local ReadList= {} -local ScriptEdit= {} - -for pl= 1, players do - InputList[pl]= {} - BackupList[pl]= {} - BackupOverride[pl]= false - ThisInput[pl]= {} - BufInput[pl]= {} - BufLen[pl]= 0 - - TrueSwitch[pl]= {} - FalseSwitch[pl]= {} - ReadList[pl]= {} - ScriptEdit[pl]= {} - for i= 1, 8 do - TrueSwitch[pl][i]= "inv" - FalseSwitch[pl][i]= nil - ReadList[pl][i]= true - ScriptEdit[pl][i]= false - end -end - ---***************************************************************************** --- Just painting instructions here. - -print("Running Multitrack Script made by FatRatKnight.", - "\r\nIts primary use is to preserve input after a loadstate.", - "\r\nIt also gives precise control on changing this stored input.", - "\r\nEdit the script if you need to change stuff. All options are near the top.", - "\r\nThe script is currently set as follows:\r\n") - -print("Players:",players) -if players > 1 then - print("Player Switch key:",PlayerSwitch, - "\r\nThere is an All Players view as well, beyond the last player.\r\n") -else - print("With only one player, the PlayerSwitch button is disabled.\r\n") -end - -print("Maximum rewind states:",saveMax) -local CalcSeconds= math.floor(saveMax*SaveBuf*100/60)/100 -if saveMax > 0 then - print("Frames between saves:",SaveBuf, - "\r\nRewind key:",rewind, - "\r\nThis can go backwards up to about",CalcSeconds,"seconds.", - "\r\nRewind is a quick and easy way to back up just a few frames.", - "\r\nJust hit",rewind,"and back you go!\r\n") -else - print("Rewind function is disabled. Cheap on memory!\r\n") -end - -print("Hold >",opt,"< to view control options.", - "\r\nYou may use the mouse or keyboard to toggle options.", - "\r\nFor keyboard, use",OptUp,OptDn,OptRt,OptLf,"to choose an option and", - OptHit,"to toggle the option.", - "\r\nFor mouse, it's as simple at point and click.", - "\r\nIf viewing All Players, changing options will affect all players.\r\n") - -print("For the frame display, you can drag it around with the mouse.", - "\r\nTo move it by keyboard:",DispN,DispS,DispE,DispW, - "\r\nTo change frames to display:",MoreFutr,LessFutr,MorePast,LessPast, - "\r\nTo recenter display around current frame:",ResetFP, - "\r\nLastly, hide it with >",clear,"< and show it with >",solid,"<\r\n") - -print("Insert frame:",Insert, - "\r\nDelete frame:",Delete, - "\r\nThese keys allow you to shift frames around the current frame.", - "Perhaps you found an improvement to a segment and want to delete frames.", - "Or this small trick you wanted to add requires shifting a few frames forward.", - "These buttons let you shift frames around without forcing you to", - "modify each and every one of them individually.\r\n") - - -print("Script keys:", - "\r\nJoy - Keyboard", - "\r\n------------") -for i= 1, 8 do - print(btn[i],"-",key[i]) -end -print("By default, these are disabled. Enable them through the control options.", - "\r\nThey are a one-tap joypad switch for precision control.", - "\r\nIt will affect the currently displayed player, or all of them if", - "it's displaying All Players.\r\n") - -print("If you want to \"load\" an fm2 into this script, run the play file", - "while running this script. As the movie on read-only plays out, the", - "script will pick up its input. The script does not need to start from", - "frame 1 -- Load a state near the end of a movie if you so wish!", - "Once input is loaded, you may continue whatever you were doing.\r\n") - -print("Remember, edit the script if you don't like the current options. All", - "the options you should care about are near the top, clearly marked.", - "Change the control keys through there, as well as number of players or rewind limits.", - "\r\nThis script works with the joypad you actually set from FCEUX's config,", - "and they can even cancel input stored in this script.", - -"\r\n\r\nAnd have fun with this script. I hope your experiments with this script goes well.", -"\r\n\r\nLeeland Kirwan, the FatRatKnight.") - -print("Players:",players," - - ",CalcSeconds,"seconds of rewind.") - - - ---***************************************************************************** -function FBoxOld(x1, y1, x2, y2, color) ---***************************************************************************** --- Gets around FCEUX's problem of double-painting the corners. --- The double-paint is visible with non-opaque drawing. --- It acts like the old-style border-only box. --- Slightly messes up when x2 or y2 are less than their counterparts. - - if (x1 == x2) and (y1 == y2) then - gui.pixel(x1,y1,color) - - elseif (x1 == x2) or (y1 == y2) then - gui.line(x1,y1,x2,y2,color) - - else --(x1 ~= x2) and (y1 ~= y2) - gui.line(x1 ,y1 ,x2-1,y1 ,color) -- top - gui.line(x2 ,y1 ,x2 ,y2-1,color) -- right - gui.line(x1+1,y2 ,x2 ,y2 ,color) -- bottom - gui.line(x1 ,y1+1,x1 ,y2 ,color) -- left - end -end - - ---***************************************************************************** -function FakeBox(x1, y1, x2, y2, Fill, Border) ---***************************************************************************** --- Gets around FCEUX's problem of double-painting the corners. --- It acts like the new-style fill-and-border box. - -if not Border then Border= Fill end - - gui.box(x1,y1,x2,y2,Fill,0) - FBoxOld(x1,y1,x2,y2,Border) -end - - ---***************************************************************************** -local Draw= {} --Draw[button]( Left , Top , color ) ---***************************************************************************** - -function Draw.right(x,y,color) -- ## - gui.line(x ,y ,x+1,y ,color) -- # - gui.line(x ,y+2,x+1,y+2,color) -- ## - gui.pixel(x+2,y+1,color) -end - -function Draw.left(x,y,color) -- ## - gui.line(x+1,y ,x+2,y ,color) -- # - gui.line(x+1,y+2,x+2,y+2,color) -- ## - gui.pixel(x ,y+1,color) -end - -function Draw.up(x,y,color) -- # - gui.line(x ,y+1,x ,y+2,color) -- # # - gui.line(x+2,y+1,x+2,y+2,color) -- # # - gui.pixel(x+1,y ,color) -end - -function Draw.down(x,y,color) -- # # - gui.line(x ,y ,x ,y+1,color) -- # # - gui.line(x+2,y ,x+2,y+1,color) -- # - gui.pixel(x+1,y+2,color) -end - -function Draw.start(x,y,color) -- # - gui.line(x+1,y ,x+1,y+2,color) -- ### - gui.pixel(x ,y+1,color) -- # - gui.pixel(x+2,y+1,color) -end - -function Draw.select(x,y,color) -- ### - FBoxOld(x ,y ,x+2,y+2,color) -- # # -end -- ### - -function Draw.A(x,y,color) -- ### - FBoxOld(x ,y ,x+2,y+1,color) -- ### - gui.pixel(x ,y+2,color) -- # # - gui.pixel(x+2,y+2,color) -end - -function Draw.B(x,y,color) -- # # - gui.line(x ,y ,x ,y+2,color) -- ## - gui.line(x+1,y+1,x+2,y+2,color) -- # # - gui.pixel(x+2,y ,color) -end - - - -function Draw.D0(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+4,color) -end - -function Draw.D1(left, top, color) - gui.line(left ,top+4,left+2,top+4,color) - gui.line(left+1,top ,left+1,top+3,color) - gui.pixel(left ,top+1,color) -end - -function Draw.D2(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+3,left+2,top+1,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left ,top+2,color) - gui.pixel(left+2,top+2,color) -end - -function Draw.D3(left, top, color) - gui.line(left ,top ,left+1,top ,color) - gui.line(left ,top+2,left+1,top+2,color) - gui.line(left ,top+4,left+1,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) -end - -function Draw.D4(left, top, color) - gui.line(left ,top ,left ,top+2,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top+2,color) -end - -function Draw.D5(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+1,left+2,top+3,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left ,top+2,color) - gui.pixel(left+2,top+2,color) -end - -function Draw.D6(left, top, color) - gui.line(left ,top ,left+2,top ,color) - gui.line(left ,top+1,left ,top+4,color) - gui.line(left+2,top+2,left+2,top+4,color) - gui.pixel(left+1,top+2,color) - gui.pixel(left+1,top+4,color) -end - -function Draw.D7(left, top, color) - gui.line(left ,top ,left+1,top ,color) - gui.line(left+2,top ,left+1,top+4,color) -end - -function Draw.D8(left, top, color) - gui.line(left ,top ,left ,top+4,color) - gui.line(left+2,top ,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+2,color) - gui.pixel(left+1,top+4,color) -end - -function Draw.D9(left, top, color) - gui.line(left ,top ,left ,top+2,color) - gui.line(left+2,top ,left+2,top+3,color) - gui.line(left ,top+4,left+2,top+4,color) - gui.pixel(left+1,top ,color) - gui.pixel(left+1,top+2,color) -end - - -Draw[0],Draw[1],Draw[2],Draw[3],Draw[4]=Draw.D0,Draw.D1,Draw.D2,Draw.D3,Draw.D4 -Draw[5],Draw[6],Draw[7],Draw[8],Draw[9]=Draw.D5,Draw.D6,Draw.D7,Draw.D8,Draw.D9 ---***************************************************************************** -function DrawNum(right, top, Number, color, bkgnd) ---***************************************************************************** --- Paints the input number as right-aligned. --- Returns the x position where it would paint another digit. --- It only works with integers. Rounds fractions toward zero. - - local Digit= {} - local Negative= false - if Number < 0 then - Number= -Number - Negative= true - end - - Number= math.floor(Number) - if not color then color= "white" end - if not bkgnd then bkgnd= "clear" end - - local i= 0 - if Number < 1 then - Digit[1]= 0 - i= 1 - end - - while (Number >= 1) do - i= i+1 - Digit[i]= Number % 10 - Number= math.floor(Number/10) - end - - if Negative then i= i+1 end - local left= right - i*4 - FakeBox(left+1, top-1, right+1, top+5,bkgnd,bkgnd) - - i= 1 - while Draw[Digit[i]] do - Draw[Digit[i]](right-2,top,color) - right= right-4 - i=i+1 - end - - if Negative then - gui.line(right, top+2,right-2,top+2,color) - right= right-4 - end - return right -end - - ---***************************************************************************** -function limits( value , low , high ) -- Expects numbers ---***************************************************************************** --- Returns value, low, or high. high is returned if value exceeds high, --- and low is returned if value is beneath low. - - return math.max(math.min(value,high),low) -end - ---***************************************************************************** -function within( value , low , high ) -- Expects numbers ---***************************************************************************** --- Returns true if value is between low and high. False otherwise. - - return ( value >= low ) and ( value <= high ) -end - - -local keys, lastkeys= {}, {} ---***************************************************************************** -function press(button) -- Expects a key ---***************************************************************************** --- Returns true or false. --- Generally, if keys is pressed, the next loop around will set lastkeys, --- and thus prevent returning true more than once if held. - - return (keys[button] and not lastkeys[button]) -end - -local repeater= 0 ---***************************************************************************** -function pressrepeater(button) -- Expects a key ---***************************************************************************** ---DarkKobold & FatRatKnight --- Returns true or false. --- Acts much like press if you don't hold the key down. Once held long enough, --- it will repeatedly return true. --- Try not to call this function more than once per main loop, since I've only --- set one repeater variable. Inside a for loop is real bad. - - if keys[button] then - if not lastkeys[button] or repeater >= 3 then - return true - else - repeater = repeater + 1; - end - - elseif lastkeys[button] then -- To allow more calls for other buttons - repeater= 0 - end; - return false -end - - - ---***************************************************************************** -function JoyToNum(Joys) -- Expects a table containing joypad buttons ---***************************************************************************** --- Returns a number from 0 to 255, representing button presses. --- These numbers are the primary storage for this version of this script. - - local joynum= 0 - - for i= 1, 8 do - if Joys[btn[i]] then - joynum= bit.bor(joynum, bit.rshift(0x100,i)) - end - end - - return joynum -end - ---***************************************************************************** -function ReadJoynum(input, button) -- Expects... Certain numbers! ---***************************************************************************** --- Returns true or false. True if the indicated button is pressed --- according to the input. False otherwise. --- Helper function - return ( bit.band(input , bit.rshift( 0x100,button )) ~= 0 ) -end - - ---***************************************************************************** -function RewindThis() ---***************************************************************************** ---DarkKobold & FatRatKnight; Original concept by Antony Lavelle - - if saveCount <= 0 then - return false -- Failed to rewind - else - savestate.load(saveArray[saveCount]); - saveCount = saveCount-1; - end; - return true -- Yay, rewind! -end - - ---***************************************************************************** -function ShowOnePlayer(x,y,color,button,pl) ---***************************************************************************** --- Displays an individual button. --- Helper function for DisplayInput. - - x= x + 4*button - 3 - Draw[btn[button]](x,y,color) -end - ---***************************************************************************** -function ShowManyPlayers(x,y,color,button,pl) ---***************************************************************************** --- Displays an individual button. Uses 2x3 boxes instead of button graphics. --- Helper function for DisplayInput. - - x= x + (2*players + 1)*(button - 1) + 2*pl - 1 - FBoxOld(x,y,x+1,y+2,color) -end - - -Future= limits(Future,Past,Past+53) --Idiot-proofing ---***************************************************************************** -function DisplayOptions(width) -- Expects width calculated by DisplayInput ---***************************************************************************** --- Returns true if Opaque is 0, as a signal to don't bother painting. --- Separated from DisplayInput to make it clear which half is doing what. - - --- Change opacity? - if pressrepeater(solid) then Opaque= Opaque + 1/8 end - if pressrepeater(clear) then Opaque= Opaque - 1/8 end - Opaque= limits(Opaque,0,1) - - gui.opacity(Opaque) - if Opaque == 0 then return true end - -- Don't bother processing display if there's none to see. - --- How many frames to show? - if pressrepeater(LessFutr) then - Future= Future-1 - if Future < Past then Past= Future end - end - if pressrepeater(MoreFutr) then - Future= Future+1 - if Future > Past+53 then Past= Future-53 end - end - if pressrepeater(MorePast) then - Past= Past-1 - if Past < Future-53 then Future= Past+53 end - end - if pressrepeater(LessPast) then - Past= Past+1 - if Past > Future then Future= Past end - end - - if press(ResetFP) then Past= -12; Future= 12 end - - --- Move the display around? - if pressrepeater(DispS) then DispY= DispY+1 end - if pressrepeater(DispW) then DispX= DispX-1 end - if pressrepeater(DispE) then DispX= DispX+1 end - if pressrepeater(DispN) then DispY= DispY-1 end - - if keys["leftclick"] and lastkeys["leftclick"] then - DispX= DispX + keys.xmouse - lastkeys.xmouse - DispY= DispY + keys.ymouse - lastkeys.ymouse - end - ---Miscellaneous - if press(BackupDisplaySwitch) then DisplayBackup= not DisplayBackup end - DispX= limits(DispX,2,254-width) - DispY= limits(DispY,3-4*Past,218-4*Future) - - - return nil -- Signal to display the input -end - - ---***************************************************************************** -function DisplayInput() ---***************************************************************************** --- Paints on the screen the current input stored within the script's list. - ---Are we showing all players or just one? - local HighlightButton= ShowOnePlayer - local width= 32 - if plmin ~= plmax then - HighlightButton= ShowManyPlayers - width= 16*players + 8 - end - ---For both setting options and asking if we should bother displaying ourselves - if DisplayOptions(width) then return end - ---Display frame offsets we're looking at. - local RtDigit= DispX + width + 22 - if RtDigit > 254 then RtDigit= DispX - 4 end - local TpDigit= DispY + 4*Past - 2 - DrawNum(RtDigit,TpDigit,Past,white,shade) - - if Future > Past+1 then - TpDigit= DispY + 4*Future - DrawNum(RtDigit,TpDigit,Future,white,shade) - end - ---Show cute little box around current frame - if Past <= 0 and Future >= 0 then - local color= blue - for pl= plmin, plmax do - local ThisFrame= InputList[pl][fc-BufLen[pl]] - if BufLen[pl] > 0 then ThisFrame= BufInput[pl][1] end - if ThisFrame ~= JoyToNum(ThisInput[pl]) then color= green end - end - FBoxOld(DispX-1,DispY-2,DispX+width+1,DispY+4,color) - end - ---Shade the proper regions efficiently - if Past < 0 then - local Y1= DispY + 4*Past -3 - local Y2= DispY - 3 - if Future < -1 then Y2= DispY + 4*Future +1 end - FakeBox(DispX,Y1,DispX+width,Y2,shade,shade) - end - if Future > 0 then - local Y1= DispY + 5 - local Y2= DispY + 4*Future+5 - if Past > 1 then Y1= DispY + 4*Past +1 end - FakeBox(DispX,Y1,DispX+width,Y2,shade,shade) - end - if Past <= 0 and Future >= 0 then - FakeBox(DispX,DispY-1,DispX+width,DispY+3,shade,shade) - end - ---Finally, we get to show the actual buttons! - for i= Past, Future do - local Y= DispY + 4*i - if i < 0 then Y=Y-2 - elseif i > 0 then Y=Y+2 end - - local BackupColor= nil -- For displaying a line for backup - for pl= plmin, plmax do - local scanz - if i < 0 then scanz= InputList[pl][fc+i] - elseif i == 0 then scanz= JoyToNum(ThisInput[pl]) - elseif i < BufLen[pl] then - scanz= BufInput[pl][i+1] - else scanz= InputList[pl][fc+i-BufLen[pl]] - end - for button= 1, 8 do - --- Take a number, oh mighty color. There's too much of ya! - local color - if not scanz then - color= 1 --Does not exist - elseif ReadJoynum(scanz,button) then - if (i <= 0) or (ReadList[pl][button]) then - color= 4 --Button on - else - color= 3 --Button on, will be ignored - end - else - color= 2 --Button off - end - - if DisplayBackup then - if BackupList[pl][fc+i] then - if ReadJoynum(BackupList[pl][fc+i],button) then - color= color+8 - else - color= color+4 - end - end - if BackupOverride[pl] == "read" then - color= color+12 - elseif BackupOverride[pl] == "write" then - color= color+24 - end - end - - HighlightButton(DispX,Y,ListOfBtnClr[color],button,pl) - - end -- button loop - --- Draw cute lines if we wish to see the backup - if DisplayBackup and BackupList[pl][fc+i] then - if not BackUpColor then - if not scanz then - BackupColor= 1 - elseif scanz == BackupList[pl][fc+i] then - BackupColor= 3 - else - BackupColor= 2 - end - if BackupOverride[pl] == "read" then - BackupColor= BackupColor+3 - elseif BackupOverride[pl] == "write" then - BackupColor= BackupColor+6 - end - - else -- Eh, we already have a BackupColor? - local CheckColor= (BackupColor-1)%3 - if not scanz then - BackupColor= BackupColor - CheckColor - elseif (scanz ~= BackupList[pl][fc+i]) and (CheckColor == 2) then - BackupColor= BackupColor - 1 - end - end - end - - end -- player loop - - if BackupColor then - gui.line(DispX-2,Y,DispX-2,Y+2,ListOfChangesClr[BackupColor]) - end - end -- loop from Past to Future -end --function - - ---***************************************************************************** -function SetInput() ---***************************************************************************** --- Prepares ThisInput for joypad use. - - for pl= 1, players do - local temp - if BackupOverride[pl] == "read" then - temp= BackupList[pl][fc] - else - if BufLen[pl] > 0 then - temp= BufInput[pl][1] - else - temp= InputList[pl][fc-BufLen[pl]] - end - end - - for i= 1, 8 do - if temp and ReadJoynum(temp,i) and ReadList[pl][i] then - ThisInput[pl][btn[i]]= TrueSwitch[pl][i] - else - ThisInput[pl][btn[i]]= FalseSwitch[pl][i] - end - end - end -end - - ---***************************************************************************** -function ApplyInput() ---***************************************************************************** --- Shoves ThisInput into the actual emulator joypads. - - if movie.mode() ~= "playback" then - for pl= 1, players do - joypad.set(pl, ThisInput[pl]) - end - end -end - - ---***************************************************************************** -function InputSnap() ---***************************************************************************** --- Will shove the input list over. --- Might end up freezing for a moment if there's a few thousand frames to shift - - for pl= 1, players do - - if BufLen[pl] < 0 then -- Squish! - local pointer= fc - while InputList[pl][pointer] do - InputList[pl][pointer]= InputList[pl][pointer-BufLen[pl]] - pointer= pointer+1 - end - end - - - if BufLen[pl] > 0 then -- Foom! - local pointer= fc - while InputList[pl][pointer] do - pointer= pointer+1 - end - -- pointer is now looking at a null frame. - -- Assume later frames are also null. - - while pointer > fc do - pointer= pointer-1 - InputList[pl][pointer+BufLen[pl]]= InputList[pl][pointer] - end - -- pointer should now match fc. - -- Everything at fc and beyond should be moved over by BufLen. - - for i=0, BufLen[pl]-1 do - InputList[pl][fc +i]= table.remove(BufInput[pl],1) - end - end - - BufLen[pl]= 0 -- If it ain't zero before, we want it zero now! - - end -end - - - - -local XStart, XDiff= 30, 25 -local YStart, YDiff= 12, 15 -local Status= { {},{},{},{} } -local TargA= {FalseSwitch,TrueSwitch,ReadList,ScriptEdit} -local TrueA= { nil , "inv" , true , true } -local FalsA= { false , true , false , false } -local BtnX, BtnY= 0, 0 - -local BasicText= { -"Activate: Lets the joypad activate input.", -"Remove: Allows the joypad to remove input.", -"List: Should the script remember button presses?", -"Keys: Allow the script-specific keys to work?"} - -local AdvText= { -{"With both joypad options on, you have full control.", - "Held buttons will toggle the script's stored input."}, -- 1 - -{"With this on-off set-up, auto-hold will not", - "accidentally cancel input, such as from load state."}, -- 2 - -{"With this off-on set, you can use auto-hold to", - "elegantly strip off unwanted input."}, -- 3 - -{"With both joypad options off, you ensure you can't", - "accidentally change what's stored in the script."}, -- 4 - -{"List on: Script will apply input stored within.", - "This is the whole point of the script, ya know."}, -- 5 - -{"List off: Stored input is ignored. A good idea if", - "you don't want the script interfering."}, -- 6 - -{"Keys on: Script keys will toggle the button press", - "for the current frame. Meant for precise edits."}, -- 7 - -{"Keys off: Script-specific keys are no longer a", - "factor. Long-term control is meant for joypad!"}, -- 8 - -{"Apparently, you've selected 'All players'", - "and they have different options set."}, -- 9 - -{"This is the 'All' button. Selecting this will set", - "all 'Yes' or all 'No' for this particular option."} --10 -} - ---***************************************************************************** -function ControlOptions() ---***************************************************************************** --- Lets the user make adjustments on the various controls of this script. --- The interface, apparently, is most of the work! - - --- Button selection - if (keys.xmouse ~= lastkeys.xmouse) or (keys.ymouse ~= lastkeys.ymouse) then - BtnX= math.floor((keys.xmouse- XStart+4)/XDiff) - BtnY= math.floor((keys.ymouse- YStart-6)/YDiff) - else - if press(OptUp) then - BtnX= limits(BtnX ,1,4) - BtnY= limits(BtnY-1,1,9) - end - if press(OptDn) then - BtnX= limits(BtnX ,1,4) - BtnY= limits(BtnY+1,1,9) - end - if press(OptRt) then - BtnX= limits(BtnX+1,1,4) - BtnY= limits(BtnY ,1,9) - end - if press(OptLf) then - BtnX= limits(BtnX-1,1,4) - BtnY= limits(BtnY ,1,9) - end - end - - ---Did you punch something? - if press("leftclick") or press(OptHit) then - if within( BtnY , 1 , 9 ) then - if within( BtnX , 1 , 4 ) then - local LoopS, LoopF= 1, 8 - if BtnY ~= 9 then - LoopS, LoopF= BtnY, BtnY - end - - local Target, TstT, TstF= TargA[BtnX], TrueA[BtnX], FalsA[BtnX] - - for pl= plmin, plmax do - for Loop= LoopS, LoopF do - if Target[plmax][LoopF] == TstT then - Target[pl][Loop]= TstF - else - Target[pl][Loop]= TstT - end - end - end - - end - end - end - - ---Figure out the status - for i= 1, 4 do - for j= 1, 8 do - Status[i][j]= TargA[i][plmin][j] - local pl= plmin+1 - while (pl <= plmax) do - if Status[i][j] ~= TargA[i][pl][j] then - Status[i][j]= "???" - break - end - pl= pl+1 - end - if Status[i][j] == TrueA[i] then Status[i][j]= "Yes" - elseif Status[i][j] == FalsA[i] then Status[i][j]= "No" end - end - end - ---============================================================================= ---Begin drawing. Finally... - - ---Shade the whole freaking screen - FakeBox(0,0,255,223,shade,shade) - --- Silly little graphics --- Perhaps I shouldn't always assume that button right is a right arrow... - Draw.B( XStart + XDiff ,YStart,red) - Draw.right( XStart + XDiff + 5,YStart,white) - Draw.B( XStart + XDiff +10,YStart,green) - - Draw.B( XStart + XDiff*2 ,YStart,green) - Draw.right( XStart + XDiff*2+ 5,YStart,white) - Draw.B( XStart + XDiff*2+10,YStart,red) - - Draw[btn[1]](XStart + XDiff*3 ,YStart ,green) - Draw[btn[1]](XStart + XDiff*3 ,YStart+4,green) - Draw[btn[2]](XStart + XDiff*3+ 4,YStart ,green) - Draw[btn[2]](XStart + XDiff*3+ 4,YStart+4,red) - Draw[btn[3]](XStart + XDiff*3+ 8,YStart ,red) - Draw[btn[3]](XStart + XDiff*3+ 8,YStart+4,green) - Draw[btn[4]](XStart + XDiff*3+12,YStart ,red) - Draw[btn[4]](XStart + XDiff*3+12,YStart+4,red) - - gui.box(XStart+XDiff*4,YStart,XStart+XDiff*4+14,YStart+6,0,green) - Draw[btn[6]](XStart + XDiff*4+ 2,YStart+2,green) - Draw[btn[7]](XStart + XDiff*4+ 6,YStart+2,green) - Draw[btn[8]](XStart + XDiff*4+10,YStart+2,green) - - ---Highlight button - if within( BtnY , 1 , 9 ) then - if within( BtnX , 1 , 4 ) then - local LowX=BtnX*XDiff +XStart -4 - local LowY=BtnY*YDiff +YStart -3 - gui.box(LowX,LowY,LowX+XDiff-2,LowY+YDiff-2,blue,blue) - ---Handle text. Feels sort of hard-coded, however - gui.text(1,160,BasicText[BtnX]) - - local adv - if BtnY == 9 then - adv= 10 - elseif Status[BtnX][BtnY] == "???" then - adv= 9 - elseif within(BtnX,1,2) and ((Status[3-BtnX][BtnY] == "???")) then - adv= 9 - elseif within(BtnX,1,2) then - adv= 1 - if Status[2][BtnY] == "No" then - adv= adv + 1 - end - if Status[1][BtnY] == "No" then - adv= adv + 2 - end - else - adv= 5 - if BtnX == 4 then - adv= adv+2 - end - if Status[BtnX][BtnY] == "No" then - adv= adv+1 - end - end - gui.text(1,175,AdvText[adv][1]) - gui.text(1,183,AdvText[adv][2]) - end - end - - ---Lines! - for i= 1, 5 do - local Xpos= XStart + XDiff*i -5 - gui.line(Xpos,0,Xpos,YStart + YDiff*10-4,green) - end - - for j= 1, 9 do - local Ypos= YStart + YDiff*j -4 - gui.line( 0, Ypos, XStart + XDiff*5-5, Ypos, green) - end - gui.line(XStart+XDiff-4, YStart + YDiff*10-4, XStart + XDiff*5-5, YStart + YDiff*10-4, green) - - ---Button labels! - for j= 1, 8 do - local Ypos= YStart + YDiff*j - gui.text( 1, Ypos, btn[j]) - Draw[btn[j]](XStart + XDiff - 12, Ypos, green) - - for i= 1, 4 do - gui.text(XStart + XDiff*i, Ypos, Status[i][j]) - end - end - - for i= 1, 4 do - gui.text(XStart + XDiff*i, YStart + YDiff*9, "All") - end - -end - - ---***************************************************************************** -function CatchInput() ---***************************************************************************** --- For use with registerbefore. It will get the input and paste it into --- the input list. - - fc= movie.framecount() - for pl= 1, players do - if BufLen[pl] > 0 then - table.remove(BufInput[pl],1) - table.insert(BufInput[pl],InputList[pl][fc-1]) - end - local NewJoy= JoyToNum(joypad.get(pl)) - InputList[pl][fc-1]= NewJoy - if not BackupList[pl][fc-1] or (BackupOverride[pl] == "write") then - BackupList[pl][fc-1]= NewJoy - end - end - SetInput() -end -emu.registerbefore(CatchInput) - - ---***************************************************************************** -function OnLoad() ---***************************************************************************** --- For use with registerload. It updates ThisInput so we're not stuck with --- junk being carried over when we load something. --- Also clears whatever rewind stuff is stored. - - InputSnap() - for pl= 1, players do --Assume user is done messing with backup on load - BackupOverride[pl]= false - end - - fc= movie.framecount() - LastLoad= fc - saveCount= 0 - SetInput() - ApplyInput() -- Sanity versus unpaused stateload -end -savestate.registerload(OnLoad) - - ---***************************************************************************** -function ItIsYourTurn() ---***************************************************************************** --- For use with gui.register. I need to catch input while paused! --- Needed for a half-decent interface. - ---Ensure things are nice, shall we? - local fc_= movie.framecount() - lastkeys= keys - keys= input.get() - - if fc ~= fc_ then -- Sanity versus unusual jump (Reset cycle?) - OnLoad() - end - ---Process Rewind - if saveMax > 0 then -- Don't process if Rewind is disabled - if pressrepeater(rewind) or rewinding then - rewinding= false - if RewindThis() then - InputSnap() - movie.rerecordcounting(true) - fc= movie.framecount() - SetInput() - if saveCount < 1 then emu.pause() end - end - end - end - ---Should we bother the backups today? - for pl= plmin, plmax do - if press(BackupReadSwitch) then - if BackupOverride[pl] ~= "read" then - BackupOverride[pl]= "read" - else - BackupOverride[pl]= false - end - end - if press(BackupWriteSwitch) then - if BackupOverride[pl] ~= "write" then - BackupOverride[pl]= "write" - else - BackupOverride[pl]= false - end - end - end - - if keys[BackupReadSwitch] and keys[BackupWriteSwitch] then - gui.text(30,1,"Hey, quit holding both buttons!") - elseif keys[BackupReadSwitch] then - gui.text(30,1,"This lets the script revert to the backup.") - elseif keys[BackupWriteSwitch] then - gui.text(30,1,"This stores input into the backup.") - end - ---Switch players on keypress - if press(PlayerSwitch) then - if plmin ~= plmax then - plmax= 1 - elseif plmin == players then - plmin= 1 - else - plmin= plmin+1 - plmax= plmax+1 - end - end - ---Display which player we're selecting. Upperleft corner seems good. - if plmin == plmax then - gui.text(1,2,plmin) - gui.text(11,2,BufLen[plmin]) - else - gui.text(1,2,"A") - end - ---Check if we want to see control options - if keys[opt] then - gui.opacity(1) - ControlOptions() - SetInput() - ---Otherwise, handle what we can see - else - ---Inserts and deletes. ---table functions don't work well on tables that don't connect from 1. - if pressrepeater(Insert) then - for pl= plmin, plmax do - BufLen[pl]= BufLen[pl] + 1 - if BufLen[pl] > 0 then - table.insert(BufInput[pl],1,0) - end - end - SetInput() - end - if pressrepeater(Delete) then - for pl= plmin, plmax do - if BufLen[pl] > 0 then - table.remove(BufInput[pl],1) - end - BufLen[pl]= BufLen[pl] - 1 - end - SetInput() - end - ---Script key handler - for pl= plmin, plmax do - for i= 1, 8 do - if press(key[i]) and ScriptEdit[pl][i] then - if ThisInput[pl][btn[i]] then - ThisInput[pl][btn[i]]= FalseSwitch[pl][i] - else - ThisInput[pl][btn[i]]= TrueSwitch[pl][i] - end - end - end - end - - DisplayInput() - end - ---Last bits of odds and ends - ApplyInput() - - collectgarbage("collect") -end -gui.register(ItIsYourTurn) - - ---***************************************************************************** -function Rewinder() ---***************************************************************************** --- Contains the saving part of the Rewind engine. --- Original by Antony Lavelle, added by DarkKobold, messed by FatRatKnight - if saveMax > 0 then -- Don't process if Rewind is disabled - if keys[rewind] and saveCount > 0 then - rewinding= true - - elseif (fc - LastLoad)%SaveBuf == 0 then - if saveCount >= saveMax then - table.remove(saveArray,1) - else - saveCount= saveCount+1 - end - - if saveArray[saveCount] == nil then - saveArray[saveCount]= savestate.create(); - end - - savestate.save(saveArray[saveCount]); - - movie.rerecordcounting(false) - end - end - -end - ---emu.registerafter(Rewinder) - - - - - - - - -local TestNumOfDoom= 0 -local TestFile= io.open("Backup" .. TestNumOfDoom .. ".txt" , "r") -while TestFile do - TestFile:close() - TestNumOfDoom= TestNumOfDoom+1 - if TestNumOfDoom >= BackupFileLimit then break end - TestFile= io.open("Backup" .. TestNumOfDoom .. ".txt" , "r") -end - - - - -local FCEUXbtn= {"right", "left", "down", "up", "start", "select", "B", "A"} -local FCEUXfrm= {"R","L","D","U","T","S","B","A"} -local FCEUXorder= {} - -for i= 1, 8 do - for j= 1, 8 do - if btn[i] == FCEUXbtn[j] then - FCEUXorder[j]= i - break - end - end -end - ---***************************************************************************** -function SaveToFile() ---***************************************************************************** --- Creates a file that, effectively, stores whatever's in the script at the --- time. --- List of known glitches: --- It only reads player 1 when deciding when to start or stop. - - InputSnap() - local LatestIndex= 0 - local EarliestIndex= math.huge - for Frame, Pads in pairs(InputList[1]) do - LatestIndex= math.max(LatestIndex,Frame) - EarliestIndex= math.min(EarliestIndex,Frame) - end - - - local BFile = io.open("Backup" .. TestNumOfDoom .. ".txt" , "w") - BFile:write("StartFrame: " .. EarliestIndex .. "\n") - - for Frame= EarliestIndex, LatestIndex do - BFile:write("|0") - for pl= 1, 4 do - BFile:write("|") - if InputList[pl] then - if InputList[pl][Frame] then - local Pads= InputList[pl][Frame] - for i= 1, 8 do - if ReadJoynum(Pads,FCEUXorder[i]) then - BFile:write(FCEUXfrm[i]) - else - BFile:write(".") - end - end - else - BFile:write(" ") - end - end - end - BFile:write("\n") - end - BFile:close() - -end - -emu.registerexit(SaveToFile) - - - - - - - - - - - -emu.pause() - -while true do - Rewinder() - - emu.frameadvance() -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/NightmareElmStreet-4Player.lua b/branches/sdl2/output/luaScripts/NightmareElmStreet-4Player.lua deleted file mode 100644 index fca98c45..00000000 --- a/branches/sdl2/output/luaScripts/NightmareElmStreet-4Player.lua +++ /dev/null @@ -1,57 +0,0 @@ ---Nightmare on Elm Street 4-Player TAS, lua script ---Displays important values on screen, including player positions, lag counter, and timers ---April 16th 2009 ---Written by adelikat - -local lag = 0; --Stores lag flag (00D6) value -local lagCounter = 0; --Stores lag change value (increments every time -local screenpos = 0; --Stores the screen position value - 00E8 -local ZZZ1 = 0; --Day/Night timers -local ZZZ2 = 0; -local ZZZ3 = 0; -local HP1 = 0; --Boss health -local HP2 = 0; --Boss health - -while (true) do - ---Counters and Lag flag - ---Get lag info -lag = memory.readbyte(0x00D6); -if (lag > 0) then - lag = 1; - lagCounter = lagCounter+1; -end - ---Get screen position -screenpos = memory.readbyte(0x00E8); - ---Get enemy HP values -HP1 = memory.readbyte(0x0113); -HP2 = memory.readbyte(0x0114); - ---Get Day/night timers -ZZZ1 = memory.readbyte(0x06C8); -ZZZ2 = memory.readbyte(0x06CC); -ZZZ3 = memory.readbyte(0x06D0); - ---dispay values -gui.text(191,8,"LagFlag:"); -gui.text(235,8,lag); - -gui.text(191,16,"LagCount:"); -gui.text(235,16,lagCounter); - -gui.text(191,24,"ScrnPos:"); -gui.text(235,24,screenpos); - -gui.text(1,8,"D/N:"..ZZZ1..","..ZZZ2..","..ZZZ3); - ---display enemy HP only if there is something to display TODO: display only the value that is useful -if ( (HP1 > 0 and HP1 < 255) or (HP2 > 0 and HP2 < 255) ) then - gui.text(1,16,"EnemyHPs:"..HP1..","..HP2); -end - - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/PunchOutChallenge.lua b/branches/sdl2/output/luaScripts/PunchOutChallenge.lua deleted file mode 100644 index d978c05a..00000000 --- a/branches/sdl2/output/luaScripts/PunchOutChallenge.lua +++ /dev/null @@ -1,334 +0,0 @@ ---Mike Tyson's Punch Out!! ---Intended to Challenge the PROs! ---adelikat - -local NumStars = 0x0342 -local UntilStar = 0x0347 --Number of punches to land until Mac can get a star -local NumHearts = 0x0321 --Number of hearts, single digit -local NumHearts10 = 0x0322 --Number of hearts, 10's digit -local CurrentRoundA = 0x0006 --Address for which round we are in -local Round = 0 --Stores which round we are on -local OppMove = 0x0090 --What move the opponent is making - -local DizzyFlag = 0x00BA -- If Opponent will be insta-knocked down by any punch -local StarKOFlag = 0x03CB -- If OPponent will be insta-knocked down by a star -local KaiserKOFlag = 0x004B -- Setting this to 0 disables his ability to be stunned, thus you can't KO Star him - -local OppDodgeStar = 0x0348 -- Counter for how many unstunned stars before the opponent starts to dodge - -local OpponentIDA = 0x0031 -local OpponentID = 0 --Stores contents of OpponentIDA - ---Oppenent ID Table ---Round 1, R2, R3 - --36,47,64, 66 Glass Joe 47 = After round 1 Jump back begins - --114,116,118,120=R1 Von Kaiser - --220 Piston Honda I - --225 Don I - --52,62,66 King Hippo - --226,241 Great Tiger - --207 Bald Bull - --23 Piston Honda - --71,87,95 Soda Popinski - --111 Bald Bull II - --19 Don II - --231 Sandman - --105 Super Macho Man - --34 Mike Tyson (Mr. Dream) - - -local AltOppIDAddress = 0x0330 --Alternate flag for determining the opponent ---0 = Kaiser R2, PistonI R1 R2 R3 ---1 = Tiger R1 ---2 = Don I R2, Don I R3 ---3 = Don I R1 ---4 = Tyson R1 ---5 = Glass Joe R3, Von R1, Von R3, Soda R1 ---6 = Piston II R1 ---7 = Bull I R1, BullI R1, Sandman R1, Macho R1 ---9 = Glass R1, Glass R2, KHippo RI & Don II - - - - - - - - - -local OppIDAlt --stores the contents of 0x0330 - -local EHP = 0x0398 -- Enemy HP address -local EHPx= 178 -local EHPy= 14 -local EnemyHP = 0 -local lastEHP = 0 -local EMod = 0 --Amount that the opponents health will be modded by at the end of a frame - -local MHP = 0x0391 -- Mac HP address -local MHPx = 122 -local MHPy = 14 -local MacHP = 0 -local lastMHP = 0 - -local OppKnockedDown = 0x0005 -- Oppoenent is on the canvas flag -local OppDown -- Stores contents of 0x0005 -local OppDx = 130 -local OppDy = 70 -local OppWillGetUpWith = 0x039E -- Health that the oppoenent will get up with -local OppWillGet -- Stores contents of 0x039E - -local OppHitFlag = 0x03E0 -local OppHit -local OppHitTimer = 0 -local OppHitToDisplay = 0 -local OppJustHit = false - -local joy = {} -joy.select = 1 - -OHitValuex = 100 -OHitValuey = 100 - ---***************************************************************************** -function IsOppDown() ---***************************************************************************** - OppDown = memory.readbyte(OppKnockedDown) - if OppDown > 0 then - return true - end - return false -end - ---***************************************************************************** -function OppIsHit() ---***************************************************************************** - OppHit = memory.readbyte(OppHitFlag) - if OppHit > 0 then - return true - end - return false -end - - - ---***************************************************************************** -while true do ---***************************************************************************** - Timer1 = memory.readbyte(0x0302) --Keep track of the clock in the game - Timer2 = memory.readbyte(0x0304) - Timer3 = memory.readbyte(0x0305) - Timer4 = memory.readbyte(0x0306) - Timer5 = memory.readbyte(0x0307) - - EnemyHP = memory.readbyte(EHP) - gui.text(EHPx,EHPy,EnemyHP) - - MacHP = memory.readbyte(MHP) - gui.text(MHPx,MHPy,MacHP) - - OpponentID = memory.readbyte(OpponentIDA) - OppIDAlt = memory.readbyte(AltOppIDAddress) - OppWhichMove = memory.readbyte(OppMove) - - Round = memory.readbyte(CurrentRoundA) - - - - --*************************************** - --Display how much health the opponent will get up with - - if IsOppDown() then - OppWillGet = memory.readbyte(OppWillGetUpWith) - gui.text(OppDx, OppDy, OppWillGet) - gui.text(OppDx+16,OppDy, "Next health") - - --Unfair opponent health boosts! - --This will affect the oppenent both on his knock downs and Mac's :) - if OppWillGet >= 88 then - memory.writebyte(OppWillGetUpWith, 128) - end - if OppWillGet > 64 then - memory.writebyte(OppWillGetUpWith, 96) - end - if OppWillGet > 9 then - memory.writebyte(OppWillGetUpWith, 64) - end - - if OppWillGet and EnemyHP < 64 and EnemyHP > 0 then - memory.writebyte(OppWillGetUpWith, 64) - end - - if OppWillGet and EnemyHP < 9 and EnemyHP > 0 then - memory.writebyte(OppWillGetUpWith, 128) --Now that's just rude. - end - end - --*************************************** - - --*************************************** - --Get the amount Mac damaged the opponent - if OppIsHit() then - OppHitToDisplay = lastEHP - EnemyHP - OppHitTimer = 60 - OppJustHit = true - else OppJustHit = false - end - --*************************************** - - --*************************************** - --Display damage amount - if OppHitTimer > 0 then - gui.text(OHitValuex, OHitValuey, OppHitToDisplay) - end - - if OppHitTimer > 0 then - OppHitTimer = OppHitTimer - 1 - end - --*************************************** - - - --*************************************** - --Force the pressing of select between rounds! - x = memory.readbyte(0x0004) - if x == 1 then - joypad.set(1, joy) - end - --*************************************** - - ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- - - --*************************************** - --Glass Joe custom mods - --*************************************** - if OpponentID == 36 or OpponentID == 47 or OpponentID == 64 then - if OppJustHit and OppHitToDisplay < 5 and EnemyHP > 1 then - EMod = EnemyHP + 3 - end - - if OppWhichMove == 25 then - memory.writebyte(OppMove, 1) --Remove his jump back and replace with a regular punch - end - end - - --*************************************** - --Von Kaiser custom mods - --*************************************** - if OppIDAlt == 5 then - gui.text(10,10,"Von Kaiser") - memory.writebyte(KaiserKOFlag, 1) - if Timer1 == 0 and Timer2 == 0 and Round == 1 then - memory.writebyte(OppDodgeStar, 2) - end - end - - --*************************************** - --Piston Honda I custom mods - --*************************************** - if (OppIDAlt == 0 and (Timer3 > 0 or Timer2 > 0 or Timer1 > 0)) then - gui.text(10,10,"Piston Honda I") - if Timer1 == 0 and Timer2 == 0 and Round == 1 then - memory.writebyte(OppDodgeStar, 2) - end - - if OppWhichMove == 25 then - memory.writebyte(OppMove, 1) --Remove his jump back and replace with a regular punch - end - end - - --*************************************** - --Don Flamenco I custom mods - --*************************************** - if OppIDAlt == 3 then - gui.text(10,10,"Don Flamenco I") - if Timer1 == 0 and Timer2 == 0 and Round == 1 then - memory.writebyte(OppDodgeStar, 0) - end - end - - --*************************************** - --King Hippo custom mods - --*************************************** - if OpponentID == 52 then --Round 1 only - if Timer1 == 0 and Timer2 == 0 then - EMod = 128 - end - end - if OpponentID == 52 or OpponentID == 62 or OpponentID == 66 then --All rounds - gui.text(10,10,"King Hippo") - if OppJustHit and OppHitToDisplay < 4 and OppHitToDisplay > 0 and EnemyHP > 1 then - EMod = EnemyHP + 2 - end - end - - - --*************************************** - --Great Tiger custom mods - --*************************************** - if OppIDAlt == 3 then - gui.text(10,10,"Great Tiger") - end - if OpponentID == 230 then --Round 1 Tiger punch only - IsTigerDizzy = memory.readbyte(DizzyFlag) - if IsTigerDizzy > 0 then - memory.writebyte(DizzyFlag, 0) - end - end - - --*************************************** - --Bald Bull I Custom mods - --*************************************** - - --*************************************** - --Piston Honda II Custom mods - --*************************************** - - - --*************************************** - --Soda Popinski Custom mods - --*************************************** - if OpponentID == 71 or OpponentID == 87 or OpponentID == 95 then - gui.text(10,10,"Soda Popinski") - --Nullify the instant star knockdown, and punish mac for trying! - Soda = memory.readbyte(StarKOFlag) --TODO declare a variable instead of using 0x03CB (this is the soda instand knockdown flag) - if Soda > 0 then - - memory.writebyte(0x03CB, 0) --Return it back to 0 - memory.writebyte(NumStars, 0) --Mac loses his stars - memory.writebyte(UntilStar, 12) --Mac won't get a star, and can't get a star in the next 10 punches! - EMod = 128 --Ouch! - end - - end - - --*************************************** - --Bald Bull II Custom mods - --*************************************** - - --*************************************** - --Don Flamenco II Custom mods - --*************************************** - - --*************************************** - --Mr Sandman Custom mods - --*************************************** - - --*************************************** - --Super Macho Man Custom mods - --*************************************** - - --*************************************** - --Mike Tyson - --*************************************** - ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- - FCEU.frameadvance() - if EMod > 0 then - memory.writebyte(EHP, EMod) - EMod = 0 - end - lastEHP = EnemyHP - lastMHP = MacHP -end diff --git a/branches/sdl2/output/luaScripts/PunchOutStats.lua b/branches/sdl2/output/luaScripts/PunchOutStats.lua deleted file mode 100644 index 36971bd2..00000000 --- a/branches/sdl2/output/luaScripts/PunchOutStats.lua +++ /dev/null @@ -1,91 +0,0 @@ ---Mike Tyson's Punch Out!! ---Shows Oppoenent & Mac's Health and damage amounts. ---adelikat - - -local EHP = 0x0398 -- Enemy HP address -local EHPx= 178 -local EHPy= 14 -local EnemyHP = 0 -local lastEHP = 0 - -local MHP = 0x0391 -- Mac HP address -local MHPx = 122 -local MHPy = 14 -local MacHP = 0 -local lastMHP = 0 - -local OppKnockedDown = 0x0005 -- Oppoenent is on the canvas flag -local OppDown -- Stores contents of 0x0005 -local OppDx = 130 -local OppDy = 70 -local OppWillGetUpWith = 0x039E -- Health that the oppoenent will get up with -local OppWillGet -- Stores contents of 0x039E - -local OppHitFlag = 0x03E0 -local OppHit -local OppHitTimer = 0 -local OppHitToDisplay = 0 - -OHitValuex = 100 -OHitValuey = 100 - ---***************************************************************************** -function IsOppDown() ---***************************************************************************** - OppDown = memory.readbyte(OppKnockedDown) - if OppDown > 0 then - return true - end - return false -end - ---***************************************************************************** -function OppIsHit() ---***************************************************************************** - OppHit = memory.readbyte(OppHitFlag) - if OppHit > 0 then - return true - end - return false -end - - - ---***************************************************************************** -while true do ---***************************************************************************** - EnemyHP = memory.readbyte(EHP) - gui.text(EHPx,EHPy,EnemyHP) - - MacHP = memory.readbyte(MHP) - gui.text(MHPx,MHPy,MacHP) - - if IsOppDown() then - OppWillGet = memory.readbyte(OppWillGetUpWith) - gui.text(OppDx, OppDy, OppWillGet) - gui.text(OppDx+16,OppDy, "Next health") - end - - if OppIsHit() then - OppHitToDisplay = lastEHP - EnemyHP - OppHitTimer = 60 - - end - - if OppHitTimer > 0 then - gui.text(OHitValuex, OHitValuey, OppHitToDisplay) - end - - - if OppHitTimer > 0 then - OppHitTimer = OppHitTimer - 1 - end - --gui.text(10,180,"Timer: ") - --gui.text(10,200,OppHitTimer) --Debug - - - FCEU.frameadvance() - lastEHP = EnemyHP - lastMHP = MacHP -end diff --git a/branches/sdl2/output/luaScripts/PunchOutTraining.lua b/branches/sdl2/output/luaScripts/PunchOutTraining.lua deleted file mode 100644 index 07e626b0..00000000 --- a/branches/sdl2/output/luaScripts/PunchOutTraining.lua +++ /dev/null @@ -1,155 +0,0 @@ --- Just something quick for Mike Tyson's Punch Out!! --- Intended to help time hits in real time. ---FatRatKnight - - -local EHP= 0x0398 -- Enemy HP address -local TMR= 23 -- Frames in advance for your punches. -local BND= -8 -- KEEP NEGATIVE!! Frames after the golden zone. -local threshold= 15-- How many frames before the target timing does it allow? - -local DISPx= 180 -local DISPy= 180 -local DISPx2= DISPx+11 -- Right side of box. Adjust that plus to your need -local DisplayBar= true - -local timer= 0 -local held= 0 -local accuracy= 0 -local earlies= 0 -local lates= 0 - -local perfect= 0 - -local EnemyHP -local lastEHP -local LastHit=-50 -local HitTiming= BND-1 - ---***************************************************************************** -function Is_Hit() ---***************************************************************************** - if lastEHP then - if EnemyHP < lastEHP then - return true - end - end - return false -end - - -local LastButtons= {} -local Buttons= {} ---***************************************************************************** -function IsPress() ---***************************************************************************** - LastButtons["A"]= Buttons["A"] - LastButtons["B"]= Buttons["B"] - LastButtons["select"]= Buttons["select"] - - Buttons= joypad.get(1) - if (Buttons["A"] and not LastButtons["A"]) or (Buttons["B"] and not LastButtons["B"]) then - return true - end - return false -end - - ---***************************************************************************** -while true do ---***************************************************************************** - EnemyHP= memory.readbyte(EHP) - gui.text(144,22,EnemyHP) - - if IsPress() then - if LastHit <= threshold and LastHit >= BND then - HitTiming= LastHit - LastHit= BND-1 - timer= -18 - if HitTiming > 0 then - accuracy= accuracy + HitTiming - earlies= earlies + 1 - elseif HitTiming < 0 then - accuracy= accuracy - HitTiming - lates= lates + 1 - else - perfect= perfect + 1 - end - end - end - - if Buttons["A"] or Buttons["B"] then - held= held + 1 - else - if held == 1 then - timer= 0 - LastHit= HitTiming-1 - end - held= 0 - end - - if Is_Hit() then - LastHit= TMR - end - - - if DisplayBar then - for i= 1, TMR do - local color= "black" - if i == LastHit then - color= "green" - elseif i == HitTiming and timer < 0 then - color= "red" - gui.text(100,80,"early " .. i) - end - gui.drawbox(DISPx, DISPy-3 - 4*i,DISPx2, DISPy-1 - 4*i,color) - end - - if HitTiming == 0 and timer < 0 then - gui.text(128,80,"OK") - gui.drawbox(128,80,144,90,"green") - local color= "white" - if (timer % 3) == 0 then - color= "green" - elseif (timer % 3) == 1 then - color= "blue" - end - gui.drawbox(DISPx , DISPy , DISPx2, DISPy+2, color) - gui.drawbox(DISPx-2, DISPy-2, DISPx2+2, DISPy+4, color) - else - local color= "black" - if i == LastHit then - color= "green" - end - gui.drawbox(DISPx , DISPy ,DISPx2, DISPy+2,color) - gui.drawbox(DISPx-2, DISPy-2,DISPx2+2, DISPy+4,"white") - end - - for i= BND, -1 do - local color= "black" - if i == LastHit then - color= "green" - elseif i == HitTiming and timer < 0 then - color= "red" - gui.text(146,80,"late " .. -i) - end - gui.drawbox(DISPx, DISPy+3 - 4*i,DISPx2, DISPy+5 - 4*i,color) - end - end - - if Buttons["select"] and not LastButtons["select"] then - if DisplayBar then - DisplayBar= false - else - DisplayBar= true - end - end - gui.text(5,120,"Timing error: " .. accuracy) - gui.text(5,140,"Perfect hits: " .. perfect) - gui.text(5,160,"Early: " .. earlies) - gui.text(5,170,"Late: " .. lates) - LastHit= LastHit-1 - FCEU.frameadvance() - lastEHP= EnemyHP - timer= timer+1 -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/RBIBaseball.lua b/branches/sdl2/output/luaScripts/RBIBaseball.lua deleted file mode 100644 index 799959b6..00000000 --- a/branches/sdl2/output/luaScripts/RBIBaseball.lua +++ /dev/null @@ -1,178 +0,0 @@ ---RBI Baseball script ---Written by adelikat ---Shows stats and information on screen and can even change a batter or pitcher's hand - -local PitchingScreenAddr = 0x001A; -local PitchingScreen; - -local p1PitchHealthAddr = 0x060D; -local p1PitchHealth; - -local p2PitchHealthAddr = 0x061D; -local p2PitchHealth; - -local p1OutsAddr = 0x0665; -local p1Outs; - -local pitchtypeAddr = 0x0112; -local pitchtype; - -local P1currHitterPowerAddr = 0x062B --2 byte -local P1currSpeedAddr = 0x062D -local P1currContactAddr = 0x062A - -local P2currHitterPowerAddr = 0x063B --2 byte -local P2currSpeedAddr = 0x063D -local P2currContactAddr = 0x063A - -local topinningAddr = 0x0115 - ---Extra Ram map notes ---0627 = P1 Batter Lefy or Righty (even or odd) ---0628 = P1 Bat average 150 + this address ---0629 = P1 # of Home Runs ---0638 = P2 Bat average 2 150 + this address ---0639 = P2 # of Home Runs ---0637 = P2 Batter Lefy or Righty (even or odd) - ---060x = P1 pitcher, 061x = P2 pitcher - ---0607 = ---Right digit = P1 Pitcher Lefty or Right (even or odd) ---Left digit = P1 Pitcher drop rating - ---0609 = P1 Sinker ball speed ---060A = P1 Regular ball Speed ---060B = P1 Fastball Speed ---060C = P1 Pitcher Curve rating left digit is curve left, right is curve right - ---0114 = Current Inning ---0115 = 10 if bottom of inning, 0 if on top, controls which player can control the batter - ---0728 & 0279 - In charge of inning music - ---TODO ---A hotkeys for boosting/lowering current pitcher (p1 or 2) health ---fix pitcher L/R switching to not kill the left digit (drop rating) in the process ---Do integer division on curve rating ---Outs display is wrong ---Music on/off toggle - -while true do - -memory.writebyte(0x0726, 0) --Turn of inning music -memory.writebyte(0x0727, 0) -memory.writebyte(0x0728, 0) -memory.writebyte(0x0729, 0) - -inningtb = memory.readbyte(topinningAddr); -i = input.get(); - ---Switch P1 batter hands -if (i.K == true) then - if (inningtb == 0x10) then - memory.writebyte(0x0607, 0) - end - if (inningtb == 0) then - memory.writebyte(0x0627, 0) - end -end - -if (i.L == true) then - if (inningtb == 0x10) then - memory.writebyte(0x0607, 1) - end - if (inningtb == 0) then - memory.writebyte(0x0627, 1) - end -end - ---Switch P2 batter hands -if (i.H == true) then - if (inningtb == 0x0) then - memory.writebyte(0x0617, 0) - end - if (inningtb == 0x10) then - memory.writebyte(0x0637, 0) - end -end - -if (i.J == true) then - if (inningtb == 0x0) then - memory.writebyte(0x0617, 1) - end - if (inningtb == 0x10) then - memory.writebyte(0x0637, 1) - end -end - -PitchingScreen = memory.readbyte(PitchingScreenAddr); - -------------------------------------------------------- -if (PitchingScreen == 0x003E) then -gui.text(186,24, "Toggle Hand\nH/J"); -gui.text(1,24, "Toggle Hand\nK/L"); - -pitchtype = memory.readbyte(pitchtypeAddr); - ---What the pitcher will pitch -if (pitchtype == 0) then - gui.text(100,1,"Sinker!!"); -end -if (pitchtype == 2) then - gui.text(100,1,"Fast Ball") -end -if (pitchtype == 1) then - gui.text(100,1,"Regular Pitch") -end - ---Top of Inning -if (inningtb == 0) then - gui.text(186,1,"Health " .. memory.readbyte(0x061D)) - gui.text(186,128,"Drop " .. memory.readbyte(0x0617) % 16) - gui.text(186,136,"CurveL " .. memory.readbyte(0x061C) / 16) - gui.text(186,144,"CurveR " .. memory.readbyte(0x061C) % 16) - gui.text(186,152,"Fast SP " .. memory.readbyte(0x061B)) - gui.text(186,160,"Reg SP " .. memory.readbyte(0x061A)) - gui.text(186,168,"Sink SP " .. memory.readbyte(0x0619)) - - P1currPower = memory.readbyte(P1currHitterPowerAddr) + (memory.readbyte(P1currHitterPowerAddr+1) * 256); - gui.text(1,176, "Power: " .. P1currPower); - P1currSpeed = memory.readbyte(P1currSpeedAddr); - gui.text(1,168, "Speed: " .. P1currSpeed); - P1currCt = memory.readbyte(P1currContactAddr); - gui.text(1,160, "Contact: " .. P1currCt); -end - ---Bottom of Inning -if (inningtb == 0x10) then - gui.text(1,1,"Health " .. memory.readbyte(0x060D)) - gui.text(1,128,"Drop " .. memory.readbyte(0x0607) % 16) - gui.text(1,136,"CurveL " .. memory.readbyte(0x060C) / 16) - gui.text(1,144,"CurveR " .. memory.readbyte(0x060C) % 16) - gui.text(1,152,"Fast SP " .. memory.readbyte(0x060B)) - gui.text(1,160,"Reg SP " .. memory.readbyte(0x060A)) - gui.text(1,168,"Sink SP " .. memory.readbyte(0x0609)) - - P2currPower = memory.readbyte(P2currHitterPowerAddr) + (memory.readbyte(P2currHitterPowerAddr+1) * 256); - gui.text(188,176, "Power: " .. P2currPower); - P2currSpeed = memory.readbyte(P2currSpeedAddr); - gui.text(188,168, "Speed: " .. P2currSpeed); - P2currCt = memory.readbyte(P2currContactAddr); - gui.text(188,160, "Contact: " .. P2currCt); -end - -end -------------------------------------------------------- - -if (PitchingScreen == 0x0036) then - -p1Outs = memory.readbyte(p1OutsAddr); -gui.text(1,1, "Outs " .. p1Outs); - -end -------------------------------------------------------- - -emu.frameadvance() - -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Registerfind(CheatSearch).lua b/branches/sdl2/output/luaScripts/Registerfind(CheatSearch).lua deleted file mode 100644 index 394e40e2..00000000 --- a/branches/sdl2/output/luaScripts/Registerfind(CheatSearch).lua +++ /dev/null @@ -1,217 +0,0 @@ ---RegisterFind ---written by QFox ---Weeds out RAM addresses along the lines of Cheat Search and Ram Filter. Has some features not present in either of those 2 hardcoded dialogs. - --- v0.1a (far from done!) --- include some iup stuff and take care of cleanup -require 'auxlib'; - -local function toHexStr(n) - return string.format("%X",n); -end; - -local mems; -local memstart = 0; -local memend = 0x200; -local running = false; -local removetop = 0; - -local from = iup.text{value="0x0000"}; -local till = iup.text{value="0x0100"}; -local output = iup.multiline{ expand="YES" }; -local changecheck = iup.toggle{title="Remove changed addresses"}; -local equalcheck = iup.toggle{title="Remove unchanged addresses"}; -local init = iup.button{title="Init"}; -init.action = - function(self) - mems = {}; - memstart = math.min(0xFFFE, math.max(0, tonumber(from.value))); - memend = math.min(0xFFFF, math.max(1, tonumber(till.value))); - for i=(memstart+1),(memend+1) do - mems[i] = memory.readbyte(i-1); - end; - end; -local set = iup.button{title="Set"}; -set.action = - function(self) - if (mems) then - for i=(memstart+1),(memend+1) do - if (mems[i]) then - mems[i] = memory.readbyte(i); - end; - end; - step:action(); - end; - end; -local start = iup.button{title="Run"}; -start.action = - function(self) - if (not mems) then init:action(); end; -- same as pressing the init button - running = true; - end; -local stop = iup.button{title="Stop"}; -stop.action = - function(self) - running = false; - end; -local step = iup.button{title="Step"}; -step.action = - function(self) - if (not mems) then init:action(); end; - local s = ''; - local count = 0; - gui.text(50,50,"change: "..changecheck.value.." equal: "..equalcheck.value); - for i=(memstart+1),(memend+1) do - local nowval = memory.readbyte(i-1); - if ( - mems[i] and -- no memory, no need to print it - ( not running or -- always print (existing) values when the bot is not running - ( - (changecheck.value == "OFF" or mems[i] == nowval) and -- its ok, we're just removing unequal values - (equalcheck.value == "OFF" or mems[i] ~= nowval) -- its ok, we're just removing equal values - ) - ) - ) then - if (removetop > 0) then -- delete this (should be processed even while not running) - mems[i] = false; - removetop = removetop - 1; - else - count = count + 1; - s = s.."0x"..toHexStr(i-1)..": "..toHexStr(nowval).."\n"; - end; - elseif (mems[i] and (removetop > 0 or running)) then -- we're still deleting results - mems[i] = false; - if (removetop > 0) then removetop = removetop - 1; end; - end; - end; - output.value = "Have "..count.." addresses:\n"..s; - end; -local removetext = iup.text{}; -local remove = iup.button{title="del",size="30x"}; -remove.action = - function(self) - removetop = tonumber(removetext.value); - removetext.value = tonumber(removetext.value)..""; - end; -local fewertext = iup.text{}; -local fewer = iup.button{title="del",size="30x"}; -fewer.action = - function(self) - local than = tonumber(fewertext.value); - if (mems and than) then - for i=memstart,memend do - if (mems[i] and mems[i] < than) then - mems[i] = false; - end; - end; - end; - step:action(); - end; -local moretext = iup.text{}; -local more = iup.button{title="del",size="30x"}; -more.action = - function(self) - local than = tonumber(moretext.value); - if (mems and than) then - for i=memstart,memend do - if (mems[i] and mems[i] > than) then - mems[i] = false; - end; - end; - end; - step:action(); - end; -local sametext = iup.text{}; -local same = iup.button{title="del",size="30x"}; -same.action = - function(self) - local than = tonumber(sametext.value); - if (mems and than) then - for i=memstart,memend do - if (mems[i] and mems[i] == than) then - mems[i] = false; - end; - end; - end; - step:action(); - end; - -dialogs = dialogs + 1; -handles[dialogs] = - iup.dialog{ - iup.vbox{ - iup.fill{size="5"}, - iup.hbox{ - iup.label{title="Start offset",size="50x"}, - from - }, - iup.hbox{ - iup.label{title="End offset",size="50x"}, - till - }, - iup.fill{size="5"}, - iup.hbox{ - remove, - iup.fill{size="5"}, - iup.label{title="Remove top",size="50x"}, - iup.fill{size="5"}, - removetext, - iup.fill{size="5"}, - iup.label{title="(next step)"}, - removetop - }, - iup.fill{size="5"}, - iup.hbox{ - fewer, - iup.fill{size="5"}, - iup.label{title="When less than: ",size="70x"}, - fewertext - }, - iup.fill{size="5"}, - iup.hbox{ - more, - iup.fill{size="5"}, - iup.label{title="When more than: ",size="70x"}, - moretext - }, - iup.fill{size="5"}, - iup.hbox{ - same, - iup.fill{size="5"}, - iup.label{title="When equal to: ",size="70x"}, - sametext - }, - iup.fill{size="5"}, - iup.hbox{ - init, - iup.fill{size="5"}, - start, - iup.fill{size="5"}, - stop, - iup.fill{size="5"}, - step, - iup.fill{size="5"}, - set - }, - iup.fill{size="5"}, - iup.label{title="Filters below are automatically applied when you"}, - iup.label{title="press run or press the step button."}, - iup.fill{size="5"}, - changecheck, - equalcheck, - iup.fill{size="5"}, - iup.hbox{ - output - } - }, - title="Lua Register Finder", - size="200x300" - }; -handles[dialogs]:showxy(iup.CENTER, iup.CENTER); - - - -while (true) do - step:action(); -- same as pressing the step button - FCEU.frameadvance(); -end; diff --git a/branches/sdl2/output/luaScripts/Rewinder.lua b/branches/sdl2/output/luaScripts/Rewinder.lua deleted file mode 100644 index c9257f20..00000000 --- a/branches/sdl2/output/luaScripts/Rewinder.lua +++ /dev/null @@ -1,71 +0,0 @@ --- NES Braidulator VERSION 1 ---(C) Antony Lavelle 2009 got_wot@hotmail.com http://www.the-exp.net --- A Lua script that allows 'Braid' style time reversal for Nes games being run in FCEUX ---'Braid' is copyright Jonathan Blow, who is not affiliated with this script, but you should all buy his game because it's ace. ---This is my first ever time scripting in Lua, so if you can improve on this idea/code please by all means do and redistribute it, just please be nice and include original credits along with your own :) - - - ---Change these settings to adjust options - - ---Which key you would like to function as the "rewind key" - -local rewindKey = 'select' - - ---How much rewind power would you like? (The higher the number the further back in time you can go, but more computer memory is used up) ---Do not set to 0! - -local saveMax = 1000; - - - - ---The stuff below is for more advanced users, enter at your own peril! - - - -local saveArray = {};--the Array in which the save states are stored -local saveCount = 1;--used for finding which array position to cycle through -local save; -- the variable used for storing the save state -local rewindCount = 0;--this stops you looping back around the array if theres nothing at the end -local savePreventBuffer = 1;--Used for more control over when save states will be saved, not really used in this version much. -while (true) do - savePreventBuffer = savePreventBuffer-1; - if savePreventBuffer==0 then - savePreventBuffer = 1; - end; - joyput = joypad.read(1); - if joyput[rewindKey] then - savePreventBuffer = 5; - if rewindCount==0 then - --makes sure you can't go back too far could also include other things in here, left empty for now. - else - savestate.load(saveArray[saveCount]); - saveCount = saveCount-1; - rewindCount = rewindCount-1; - if saveCount==0 then - saveCount = saveMax-1; - end; - end; - end; - if savePreventBuffer==1 then - gui.text(80,15,""); - saveCount=saveCount+1; - if saveCount==saveMax then - saveCount = 1; - end - rewindCount = rewindCount+1; - if rewindCount==saveMax-1 then - rewindCount = saveMax-2; - end; - save = savestate.create(); - savestate.save(save); - saveArray[saveCount] = save; - end; - local HUDMATH = (math.ceil((100/saveMax)*rewindCount));--Making the rewind time a percentage. - local HUDTEXT = "REWIND POWER: ".. HUDMATH .."%"; - gui.text(80,5,HUDTEXT);--Displaying the time onscreen. - FCEU.frameadvance(); -end; diff --git a/branches/sdl2/output/luaScripts/SMB-AreaScrambler.lua b/branches/sdl2/output/luaScripts/SMB-AreaScrambler.lua deleted file mode 100644 index aaf82875..00000000 --- a/branches/sdl2/output/luaScripts/SMB-AreaScrambler.lua +++ /dev/null @@ -1,97 +0,0 @@ ---SMB area scrambler ---Randomly changes the level contents. Doesn't garuantee a winnable level (nor does it guarantee it won't crash the game) ---Written by XKeeper - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - - - - -function areascrambler() -end; - - -function gameloop() - - joyin = joypad.read(1); - if joyin['select'] then - memory.writebyte(0x00e7, math.random(0, 0xFF)); - memory.writebyte(0x00e8, math.random(0, 0xFF)); - memory.writebyte(0x00e9, math.random(0, 0xFF)); - memory.writebyte(0x00ea, math.random(0, 0xFF)); - memory.writebyte(0x0750, math.random(0, 0xFF)); - end; - - if joyin['up'] then - memory.writebyte(0x009F, -5); - memory.writebyte(0x07F8, 3); - memory.writebyte(0x0722, 0xFF) - end; - - screenpage = memory.readbyte(0x071a); - screenxpos = memory.readbyte(0x071c); - - arealow = memory.readbyte(0x00e7); - areahigh = memory.readbyte(0x00e8); - - enemylow = memory.readbyte(0x00e9); - enemyhigh = memory.readbyte(0x00ea); - - unknown = memory.readbyte(0x0750); - - - text( 6, 30, string.format("Position: %02X %02X", screenpage, screenxpos)); - text( 19, 38, string.format("Area: %02X %02X", areahigh, arealow)); - text( 13, 46, string.format("Enemy: %02X %02X", enemyhigh, enemylow)); - text( 13, 54, string.format("?: %02X", unknown)); -end; - - -function areascramble() - memory.writebyte(0x00e7, math.random(0, 0xFF)); - memory.writebyte(0x00e8, math.random(0, 0xFF)); -end; - -function enemyscramble() - memory.writebyte(0x00e9, math.random(0, 0xFF)); - memory.writebyte(0x00ea, math.random(0, 0xFF)); -end; - - -gui.register(gameloop); -memory.register(0x00e8, areascramble); -memory.register(0x00ea, enemyscramble); - - - -while (true) do - - memory.writebyte(0x079F, 2); - FCEU.frameadvance(); -end; - diff --git a/branches/sdl2/output/luaScripts/SMB-CompetitionRecorder.lua b/branches/sdl2/output/luaScripts/SMB-CompetitionRecorder.lua deleted file mode 100644 index bf70f19f..00000000 --- a/branches/sdl2/output/luaScripts/SMB-CompetitionRecorder.lua +++ /dev/null @@ -1,121 +0,0 @@ --- Super Mario Bros. script by ugetab. --- 2010, April 20th. --- Competition Recorder: --- Start the script, then make a recording from Start. --- Play until you get a score you'd like to keep, then end the movie. --- A record of your best scores, and the filename you got it in, will be saved. --- You can easily find your best score, because it will be sorted highest to lowest. --- The last entry is always erased, but is also always the lowest score. - --- The best score for your current movie file will be displayed above the coin counter. - --- The reason this is good for competition is that you can't get away with cheating, --- unless the game allows it. A movie file is a collection of button presses which --- can be played back. If it doesn't play back the same for someone else, then there's --- probably a problem with the game file, or with what the person recording did. - -function text(x,y,str) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.text(x,y,str); - end; -end; - -function bubbleSort(table) ---http://www.dreamincode.net/code/snippet3406.htm ---check to make sure the table has some items in it - if #table < 2 then - --print("Table does not have enough data in it") - return; - end; - - for i = 0, (#table / 2) -1 do --> array start to end. Arrays start at 1, not 0. - for j = 1, (#table / 2) -1 do - if tonumber(table[(j*2)+1]) > tonumber(table[(j*2)-1]) then -->switch - temp1 = table[(j*2) - 1]; - temp2 = table[(j*2)]; - table[(j*2) - 1] = table[(j*2) + 1]; - table[(j*2)] = table[(j*2) + 2]; - table[(j*2) + 1] = temp1; - table[(j*2) + 2] = temp2; - end; - end; - end; - return; -end; - -filesizefile = io.open("MaxScore_LUA.txt","r"); - -if filesizefile == nil then - filewritefile = io.open("MaxScore_LUA.txt","w"); - filewritefile:close(); - filesizefile = io.open("MaxScore_LUA.txt","r"); -end; - -filesize = filesizefile:seek("end"); -filesizefile:close(); -scores = {"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}; - -if filesize == nil then - filesize = 0; -end; - -if filesize < 20 then - fileinit = io.open("MaxScore_LUA.txt","w+") - for i = 1, #scores do - fileinit:write(scores[i]..'\n'); - end; - fileinit:close(); -end; - -activescoring = false; -moviename = ""; - -maxscoresave = -9999999; - -text(83,8,"-Inactive-"); - -while (true) do - if (movie.mode() == "record") then - if movie.ispoweron() then - maxscoretest = memory.readbyte(0x07d7)..memory.readbyte(0x07d8)..memory.readbyte(0x07d9)..memory.readbyte(0x07da)..memory.readbyte(0x07db)..memory.readbyte(0x07dc).."0"; - activescoring = true; - - --if (tonumber(maxscoretest) >= tonumber(maxscoresave)) then - if (tonumber(maxscoretest) <= 9999990) then - maxscoresave = maxscoretest; - moviename = movie.getname(); - end; - --end; - - text(83,8,maxscoresave); - end; - end; - if (movie.mode() == nil) then - if (activescoring == true) then - activescoring = false; - text(83,8,"-Inactive-"); - readfile = io.open("MaxScore_LUA.txt","r"); - linecount = 1 - for line in readfile:lines() do - if linecount <= 20 then - scores[linecount] = line; - end; - linecount = linecount + 1; - end; - readfile:close (); - - --if tonumber(maxscoresave) > tonumber(scores[19]) then - scores[19] = maxscoresave; - scores[20] = moviename; - bubbleSort(scores); - savefile = io.open("MaxScore_LUA.txt","w+") - for i = 1, #scores do - savefile:write(tostring(scores[i])); - savefile:write('\n'); - end; - savefile:close(); - --end; - end; - end; - FCEU.frameadvance(); -end; diff --git a/branches/sdl2/output/luaScripts/SMB-HitBoxes.lua b/branches/sdl2/output/luaScripts/SMB-HitBoxes.lua deleted file mode 100644 index 1a973e16..00000000 --- a/branches/sdl2/output/luaScripts/SMB-HitBoxes.lua +++ /dev/null @@ -1,165 +0,0 @@ --- Super Mario Bros. hitbox script --- Super Mario Bros (JU) (PRG0) [!].nes --- Written by qFox --- 28 july 2008 - --- This script shows hitboxes of anything that has them --- It also displays the found hitboxes in a output window with iup --- Includes a toggle to automatically kill all enemies within 50px range of mario :p - --- Include our help script to load iup and take care of exit -require("auxlib"); - -local running = true; -local restrainingorder = false; -local myoutput; -function createGUI(n) - local mybutton = iup.button{title="Close (exits the main loop)"}; - mybutton.action = function(self, x) - running = false; - --handles[n]:destroy(); - --handles[n] = false; - end; - myoutput = iup.multiline{size="200x200",expand="YES",value="Debug crap should be here"} - nottooclose = iup.toggle{title="Kill enemies that come too close", value="OFF"}; - nottooclose.action = function(self, v) restrainingorder = (v == 1); end; -- v is 0 or 1 - handles[n] = - iup.dialog{ - iup.frame - { - iup.vbox - { - mybutton, - nottooclose, - myoutput, - title="Lua tools are izi!" - } - } - }; - handles[n]:showxy(iup.CENTER, iup.CENTER) -end - -dialogs = dialogs + 1; -createGUI(dialogs); - -local outstr; -local function knifeEnemyIfTooClose(enemynumber) -- enemynumber starts at 1 - -- we add the suffix for x coords because the screen is 255 positions wide but smb has two pages - -- loaded at any given time. some enemy can be in page 2 while you are on page one. since a byte - -- can only hold 255 values, this would wrap around and make it seem like the enemy is on the same - -- page. hence we add the number of pages they are one, if they are equal, it all works out :) - local mx = memory.readbyte(0x0086)+(255*memory.readbyte(0x006D)); - local my = memory.readbyte(0x00CE); - local ex = memory.readbyte(0x0086+enemynumber)+(255*memory.readbyte(0x006D+enemynumber)); - local ey = memory.readbyte(0x00CE+enemynumber); - local d = math.sqrt(((mx-ex)^2)+((my-ey)^2)); -- pythagoras ;) - outstr = outstr .. d.." < 30.0 ?\n"; - if (d < 50.0 and restrainingorder and memory.readbyte(0x0015+enemynumber) ~= 40) then -- dont kill of horizontal moving platforms. we kinda need them. - -- KNIFE! - outstr = outstr .. "Knifing next enemy!\n"; - memory.writebyte(0x001D+enemynumber, 0xFF); -- this address denotes an enemy state. writing FF to it kills them as if hit by a star (so not flatten). - end; - return d; -end; - --- draw a box and take care of coordinate checking -local function box(x1,y1,x2,y2,color) - -- gui.text(50,50,x1..","..y1.." "..x2..","..y2); - if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 224 and y2 > 0 and y2 < 224) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; - --- hitbox coordinate offsets (x1,y1,x2,y2) -local mario_hb = 0x04AC; -- 1x4 -local enemy_hb = 0x04B0; -- 5x4 -local coin_hb = 0x04E0; -- 3x4 -local fiery_hb = 0x04C8; -- 2x4 -local hammer_hb= 0x04D0; -- 9x4 -local power_hb = 0x04C4; -- 1x4 - --- addresses to check, to see whether the hitboxes should be drawn at all -local mario_ch = 0x000E; -local enemy_ch = 0x000F; -local coin_ch = 0x0030; -local fiery_ch = 0x0024; -local hammer_ch= 0x002A; -local power_ch = 0x0014; - -local a,b,c,d; -while (running) do - outstr = ''; - -- from 0x04AC are about 0x48 addresse that indicate a hitbox - -- different items use different addresses, some share - -- there can for instance only be one powerup on screen at any time (the star in 1.1 gets replaced by the flower, if you get it) - -- we cycle through the animation addresses for each type of hitbox, draw the corresponding hitbox if they are drawn - -- we draw: mario (1), enemies (5), coins (3), hammers (9), powerups (1). (bowser and (his) fireball are considered enemies) - - -- mario - if (memory.readbyte(mario_hb) > 0) then - a,b,c,d = memory.readbyte(mario_hb),memory.readbyte(mario_hb+1),memory.readbyte(mario_hb+2),memory.readbyte(mario_hb+3); - box(a,b,c,d, "green"); - outstr = outstr .. "Mario: <"..a..","..b..","..c..","..d..">\n"; - end; - - -- enemies - if (memory.readbyte(enemy_ch ) > 0) then - a,b,c,d = memory.readbyte(enemy_hb), memory.readbyte(enemy_hb+1), memory.readbyte(enemy_hb+2), memory.readbyte(enemy_hb+3); - box(a,b,c,d, "green"); - outstr = outstr .. "Enemy 1: <"..memory.readbyte(0x0016).."> <"..a..","..b..","..c..","..d.."> "..knifeEnemyIfTooClose(1).."\n"; - end; - if (memory.readbyte(enemy_ch+1) > 0) then - a,b,c,d = memory.readbyte(enemy_hb+4), memory.readbyte(enemy_hb+5), memory.readbyte(enemy_hb+6), memory.readbyte(enemy_hb+7); - box(a,b,c,d, "green"); - outstr = outstr .. "Enemy 2: <"..memory.readbyte(0x0017).."> <"..a..","..b..","..c..","..d.."> "..knifeEnemyIfTooClose(2).."\n"; - end; - if (memory.readbyte(enemy_ch+2) > 0) then - a,b,c,d = memory.readbyte(enemy_hb+8), memory.readbyte(enemy_hb+9), memory.readbyte(enemy_hb+10),memory.readbyte(enemy_hb+11); - box(a,b,c,d, "green"); - outstr = outstr .. "Enemy 3: <"..memory.readbyte(0x0018).."> <"..a..","..b..","..c..","..d.."> "..knifeEnemyIfTooClose(3).."\n"; - end; - if (memory.readbyte(enemy_ch+3) > 0) then - a,b,c,d = memory.readbyte(enemy_hb+12),memory.readbyte(enemy_hb+13),memory.readbyte(enemy_hb+14),memory.readbyte(enemy_hb+15); - box(a,b,c,d, "green"); - outstr = outstr .. "Enemy 4: <"..memory.readbyte(0x0019).."> <"..a..","..b..","..c..","..d.."> "..knifeEnemyIfTooClose(4).."\n"; - end; - if (memory.readbyte(enemy_ch+4) > 0) then - a,b,c,d = memory.readbyte(enemy_hb+16),memory.readbyte(enemy_hb+17),memory.readbyte(enemy_hb+18),memory.readbyte(enemy_hb+19) - box(a,b,c,d, "green"); - outstr = outstr .. "Enemy 5: <"..memory.readbyte(0x001A).."> <"..a..","..b..","..c..","..d.."> "..knifeEnemyIfTooClose(5).."\n"; - end; - - -- coins - if (memory.readbyte(coin_ch ) > 0) then box(memory.readbyte(coin_hb), memory.readbyte(coin_hb+1), memory.readbyte(coin_hb+2), memory.readbyte(coin_hb+3), "green"); end; - if (memory.readbyte(coin_ch+1) > 0) then box(memory.readbyte(coin_hb+4), memory.readbyte(coin_hb+5), memory.readbyte(coin_hb+6), memory.readbyte(coin_hb+7), "green"); end; - if (memory.readbyte(coin_ch+2) > 0) then box(memory.readbyte(coin_hb+8), memory.readbyte(coin_hb+9), memory.readbyte(coin_hb+10), memory.readbyte(coin_hb+11), "green"); end; - - -- (mario's) fireballs - if (memory.readbyte(fiery_ch ) > 0) then box(memory.readbyte(fiery_hb), memory.readbyte(fiery_hb+1), memory.readbyte(fiery_hb+2), memory.readbyte(fiery_hb+3), "green"); end; - if (memory.readbyte(fiery_ch+1) > 0) then box(memory.readbyte(fiery_hb+4), memory.readbyte(fiery_hb+5), memory.readbyte(fiery_hb+6),memory.readbyte(fiery_hb+7), "green"); end; - - -- hammers - if (memory.readbyte(hammer_ch ) > 0) then box(memory.readbyte(hammer_hb), memory.readbyte(hammer_hb+1), memory.readbyte(hammer_hb+2), memory.readbyte(hammer_hb+3), "green"); end; - if (memory.readbyte(hammer_ch+1) > 0) then box(memory.readbyte(hammer_hb+4), memory.readbyte(hammer_hb+5), memory.readbyte(hammer_hb+6), memory.readbyte(hammer_hb+7), "green"); end; - if (memory.readbyte(hammer_ch+2) > 0) then box(memory.readbyte(hammer_hb+8), memory.readbyte(hammer_hb+9), memory.readbyte(hammer_hb+10),memory.readbyte(hammer_hb+11), "green"); end; - if (memory.readbyte(hammer_ch+3) > 0) then box(memory.readbyte(hammer_hb+12),memory.readbyte(hammer_hb+13),memory.readbyte(hammer_hb+14),memory.readbyte(hammer_hb+15), "green"); end; - if (memory.readbyte(hammer_ch+4) > 0) then box(memory.readbyte(hammer_hb+16),memory.readbyte(hammer_hb+17),memory.readbyte(hammer_hb+18),memory.readbyte(hammer_hb+19), "green"); end; - if (memory.readbyte(hammer_ch+5) > 0) then box(memory.readbyte(hammer_hb+20),memory.readbyte(hammer_hb+21),memory.readbyte(hammer_hb+22),memory.readbyte(hammer_hb+23), "green"); end; - if (memory.readbyte(hammer_ch+6) > 0) then box(memory.readbyte(hammer_hb+24),memory.readbyte(hammer_hb+25),memory.readbyte(hammer_hb+26),memory.readbyte(hammer_hb+27), "green"); end; - if (memory.readbyte(hammer_ch+7) > 0) then box(memory.readbyte(hammer_hb+28),memory.readbyte(hammer_hb+29),memory.readbyte(hammer_hb+30),memory.readbyte(hammer_hb+31), "green"); end; - if (memory.readbyte(hammer_ch+8) > 0) then box(memory.readbyte(hammer_hb+32),memory.readbyte(hammer_hb+33),memory.readbyte(hammer_hb+34),memory.readbyte(hammer_hb+35), "green"); end; - - -- powerup - if (memory.readbyte(power_ch) > 0) then box(memory.readbyte(power_hb),memory.readbyte(power_hb+1),memory.readbyte(power_hb+2),memory.readbyte(power_hb+3), "green"); end; - - gui.text(5,32,"Green rectangles are hitboxes!"); - - if (myoutput) then - myoutput.value = outstr; - end; - - FCEU.frameadvance() -end - -gui.popup("script exited main loop"); - diff --git a/branches/sdl2/output/luaScripts/SMB-Jetpack.lua b/branches/sdl2/output/luaScripts/SMB-Jetpack.lua deleted file mode 100644 index b29c54f0..00000000 --- a/branches/sdl2/output/luaScripts/SMB-Jetpack.lua +++ /dev/null @@ -1,353 +0,0 @@ ---Super Mario Bros. - Jetpack ---Written by XKeeper ---A fun script that gives mario a "Jetback" - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - - -function doballs() - - count = 0; - for k, v in pairs(balls) do - - v['x'] = v['x'] + v['xs']; - v['y'] = v['y'] + v['ys']; - v['ys'] = v['ys'] - 0.1; - v['life'] = v['life'] - 1; - - if v['x'] < 0 or v['x'] > 254 or v['y'] < 0 or v['y'] > 243 or v['life'] < 0 then - balls[k] = nil; - else - balls[k] = v; --- pixel(v['x'], v['y'], "#FFFFFF"); - colkey = math.ceil(255 * (5 - math.max(math.min(5, (v['life'] / 15)), 0)) / 5); - - if v['c'] >= 0 then - color = string.format("#%02X%02X%02X", v['c'], v['c'], v['c']); --- color = string.format("#%02X%02X%02X", v['c'] * .8, v['c'] * .5, v['c'] * 0); - else - color = string.format("#%02X0000", v['c'] * -1 , 0, 0); - end; - - if v['life'] > 45 then - box(v['x'], v['y'], v['x'] + 1, v['y'] + 1, color); - else - pixel(v['x'], v['y'], color); - end; - count = count + 1; - end; - end; - --- lifebar( 2, 140, 249, 10, spower, 400, "#ffffff", "#000044", "#bbbbff"); - return count; - -end; - - - -function nojumping() - memory.writebyte(0x000a, AND(memory.readbyte(0x000a), 0x7F)); - - return true; -end; - -function nomoving() - joyput = joypad.read(1); - if (joyput['left'] or joyput['right']) then - memory.writebyte(0x000c, 0); - end; - - return true; -end; - - -function areascrambler() - memory.writebyte(0x00e7, math.random(0, 0xFF)); - memory.writebyte(0x00e8, math.random(0, 0xFF)); -end; - -function enemyscrambler() - memory.writebyte(0x00e9, math.random(0, 0xFF)); - memory.writebyte(0x00ea, math.random(0, 0xFF)); -end; - - ---[[ -memory.register(0x00e8, areascrambler); -memory.register(0x00ea, enemyscrambler); ---]] - --- gui.register(gameloop); -memory.register(0x000a, nojumping); -memory.register(0x000c, nomoving); - -testcount = 0; -balls = {}; -z = 0; -timer = 0; -jmax = 500; -jlife = 500; -- jmax; -refillrate = 0.020; -msgdisp = 300; -rechargerate = 0; -while (true) do - timer = timer + 1; - - - if timer < msgdisp then - yo = (((math.max(0, (timer + 60) - msgdisp))) ^ 2) / 50; - text(20, 50 - yo, "2009 Xkeeper - http://jul.rustedlogic.net/"); - text(49, 64 - yo, "A: Jetpack Left/Right: Move"); - text(53, 72 - yo, " B button: Turbo boost! "); - end; - - invincible = false; - if memory.readbyte(0x079F) >= 1 then - cyclepos = math.abs(15 - math.fmod(timer, 30)) / 15; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0xFF)); - barcolor = "#" .. warningboxcolor .. warningboxcolor .."ff"; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x80) + 0x7F); - barcolor2 = "#0000" .. warningboxcolor; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x40)); - barcolor3 = "#0000" .. warningboxcolor; --- barcolor3 = "#000000"; - - jlife = math.min(jmax, jlife + (jmax - jlife) / 25 + 0.25); - rechargerate = -0.025; - invincible = true; - elseif jlife <= jmax * 0.25 then - cyclepos = math.abs(15 - math.fmod(timer, 30)) / 15; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0xFF)); - barcolor = "#ff" .. warningboxcolor .. warningboxcolor; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x80) + 0x7F); - barcolor2 = "#" .. warningboxcolor .. "0000"; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x40)); - barcolor3 = "#" .. warningboxcolor .. "0000"; --- barcolor3 = "#000000"; - else - barcolor = "#ffffff"; - barcolor2 = "#ff4444"; - barcolor3 = "#000000"; - end; - lifebar(5, 8, 240, 2, jlife, jmax, barcolor, barcolor3, "#000000", barcolor2); - textx = math.max(4, math.min(math.floor(jlife/ jmax * 240) - 4, 229)); - if jlife == jmax then - textx = 223; - end; - text(textx, 13, string.format("%2.1d%%", math.min(jlife/ jmax * 100))); - ---[[ - bxp = math.sin(timer / 120) * 64 + 127; - byp = math.cos(timer / 120) * 64 + 127; - for i = 0, 0 do - balls[z] = {x = bxp + math.random(-100, 200) / 100, y = byp + math.random(-4, 4), xs = math.random(-100, 100) / 50, ys = math.random(-100, 100) / 100, life = math.random(60, 120), c = math.random(128, 255)}; - z = z + 1; - end; -]] - - - doballs(); - - - marioxspeed = memory.readbytesigned(0x0057); - marioyspeed = memory.readbytesigned(0x009F); - marioxpos = memory.readbyte(0x4AC); - marioypos = memory.readbyte(0x4AD); - --- lifebar(5, 2, 240, 2, marioxspeed + 0x40, 0x80, "#8888ff", "#000000"); - - joyput = joypad.read(1); - if joyput['up'] then - memory.writebyte(0x07F8, 3); - end; - if joyput['A'] and jlife >= 3 then - - rechargerate = 0; - memory.writebyte(0x009F, math.max(-3, marioyspeed - 1)); --- memory.writebyte(0x009F, -3); - if not invincible then jlife = math.max(0, jlife - 3); end; - for i = 0, 10 do - balls[z] = {x = marioxpos + 5, y = marioypos + 7, xs = math.random(-70, 70) / 100, ys = math.random(100, 300) / 100, life = math.random(30, 60), c = math.random(128, 255)}; - z = z + 1; - end; - end; - if (joyput['left'] or joyput['right']) then - - speedchange = 1; - speedmax = 0x28; - if joyput['B'] and jlife > 0 then - rechargerate = 0; - if not invincible then jlife = math.max(0, jlife - 1); end; - speedchange = 5; - speedmax = 0x40; - end; - - if joyput['left'] then - memory.writebyte(0x0033, 2); - memory.writebyte(0x0045, 2); - if marioxspeed > (speedmax * -1) then - memory.writebyte(0x0057, math.max(-0x40, marioxspeed - speedchange)); - end; - for i = 0, 10 do - balls[z] = {x = marioxpos + 7, y = marioypos + 7, xs = math.random(300, 400) / 100, ys = math.random(-10, 20) / 100, life = math.random(5, 5 + speedchange * 10), c = math.random(128, 255)}; - z = z + 1; - end; - else - - memory.writebyte(0x0033, 1); - memory.writebyte(0x0045, 1); - if marioxspeed < speedmax then - memory.writebyte(0x0057, math.min(0x40, marioxspeed + speedchange)); - end; - for i = 0, 10 do - balls[z] = {x = marioxpos + 7, y = marioypos + 7, xs = math.random(-400, -300) / 100, ys = math.random(-10, 20) / 100, life = math.random(5, 5 + speedchange * 10), c = math.random(128, 255)}; - z = z + 1; - end; - end; - end; - if not ((joyput['B'] and (joyput['left'] or joyput['right'])) or joyput['A']) then - - rechargerate = rechargerate + refillrate; - jlife = math.min(jmax, jlife + rechargerate); - - end; - - - - - - screenpage = memory.readbyte(0x071a); - screenxpos = memory.readbyte(0x071c); - - arealow = memory.readbyte(0x00e7); - areahigh = memory.readbyte(0x00e8); - - enemylow = memory.readbyte(0x00e9); - enemyhigh = memory.readbyte(0x00ea); - - --- text( 10, 24, string.format("Screen position: %02X.%02X", screenpage, screenxpos)); --- text(169, 24, string.format("Area: %02X %02X", areahigh, arealow)); --- text(163, 32, string.format("Enemy: %02X %02X", enemyhigh, enemylow)); - - ---[[ - text( 4, 217, string.format("Memory writes: %04d", testcount)); - if testcount > 1500 or testcount < 200 then - cyclepos = math.abs(15 - math.fmod(timer, 30)) / 15; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0xFF)); - barcolor = "#ff" .. warningboxcolor .. warningboxcolor; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x80) + 0x7F); - barcolor2 = "#" .. warningboxcolor .. "0000"; - warningboxcolor = string.format("%02X", math.floor(cyclepos * 0x40)); - barcolor3 = "#" .. warningboxcolor .. "0000"; --- barcolor3 = "#000000"; - else - barcolor = "#ffffff"; - barcolor2 = "#ff4444"; - barcolor3 = "#000000"; - end; - lifebar(5, 226, 240, 2, testcount, 2500, barcolor, barcolor3, "#000000", barcolor2); - ---]] - --- memory.writebyte(0x00e7, math.random(0, 0xFF)); --- memory.writebyte(0x00e8, math.random(0, 0xFF)); --- memory.writebyte(0x00e9, math.random(0, 0xFF)); --- memory.writebyte(0x00ea, math.random(0, 0xFF)); - - testcount = 0; - ---[[ - marioxspeed2 = math.abs(marioxspeed); - - box(2, 217, 0x40 * 3 + 5, 226, "#000000"); - box(2, 218, 0x40 * 3 + 5, 225, "#000000"); - box(2, 219, 0x40 * 3 + 5, 224, "#000000"); - box(2, 220, 0x40 * 3 + 5, 223, "#000000"); - box(2, 221, 0x40 * 3 + 5, 222, "#000000"); - - if marioxspeed2 > 0 then - for bl = 0, marioxspeed2 do - - if bl < 0x20 then - segcolor = string.format("#%02XFF00", math.floor(bl / 0x20 * 0xFF)); - else - segcolor = string.format("#FF%02X00", math.max(0, math.floor((0x40 - bl) / 0x20 * 0xFF))); - end; - - box(bl * 3 + 3, 218, bl * 3 + 4, 225, segcolor); --- line(bl * 3 + 4, 218, bl * 3 + 4, 225, segcolor); - end; - end; - - --]] - - maxspeed = 0x40; - marioxspeed = memory.readbytesigned(0x0057); - marioxspeed2 = math.abs(marioxspeed); - - - text(maxspeed * 3 + 2, 221, string.format(" %2d", marioxspeed2)); - - box(5, 221, maxspeed * 3 + 5, 230, "#000000"); - box(5, 222, maxspeed * 3 + 5, 229, "#000000"); - box(5, 223, maxspeed * 3 + 5, 228, "#000000"); - box(5, 224, maxspeed * 3 + 5, 227, "#000000"); - box(5, 225, maxspeed * 3 + 5, 226, "#000000"); - - if marioxspeed2 > 0 then - for bl = 1, marioxspeed2 do - - pct = bl / maxspeed; - if pct < 0.50 then - val = math.floor(pct * 2 * 0xFF); - segcolor = string.format("#%02XFF00", val); - - elseif pct < 0.90 then - val = math.floor(0xFF - (pct - 0.5) * 100/40 * 0xFF); - segcolor = string.format("#FF%02X00", val); - - elseif bl < maxspeed then - val = math.floor((pct - 0.90) * 10 * 0xFF); - segcolor = string.format("#FF%02X%02X", val, val); - - else - segcolor = "#ffffff"; - end; - - yb = math.max(math.min(3, (bl - 0x28)), 0); - box(bl * 3 + 3, 225 - yb, bl * 3 + 4, 229, segcolor); --- box(bl * 3 + 3, 218, bl * 3 + 4, 225, segcolor); --- line(bl * 3 + 4, 218, bl * 3 + 4, 225, segcolor); - end; - end; - - FCEU.frameadvance(); -end; - diff --git a/branches/sdl2/output/luaScripts/SMB-Lives&HPDisplay.lua b/branches/sdl2/output/luaScripts/SMB-Lives&HPDisplay.lua deleted file mode 100644 index 4c99f77c..00000000 --- a/branches/sdl2/output/luaScripts/SMB-Lives&HPDisplay.lua +++ /dev/null @@ -1,60 +0,0 @@ --- Super Mario Bros. script by 4matsy. --- 2008, September 11th. ---Displays the # of lives for Mario and a HP meter for Bowswer - -require("shapedefs"); - -function box(x1,y1,x2,y2,color) - if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 241 and y2 > 0 and y2 < 241) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; - -function line(x1,y1,x2,y2,color) - if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 241 and y2 > 0 and y2 < 241) then - gui.drawline(x1,y1,x2,y2,color); - end; -end; - -function text(x,y,str) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.text(x,y,str); - end; -end; - -function pixel(x,y,color) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.drawpixel(x,y,color); - end; -end; - - - -while (true) do - - -- print player's lives...I always thought this was a major omission of the status bar :p - text(63,13,"x"..memory.readbyte(0x075a)+1); - - -- check the enemy identifier buffer for presence of t3h b0ws3r (id #2d). if found, show his hp. - for i=0,5 do - if memory.readbyte((0x0016)+i) == 0x2d then -- aha, found you. YOU CANNOT HIDE FROM MY MAD SCRIPTZ0RING SKILLZ BWAHAHA - local bowsermaxhp = memory.readbyte(0xc56c); -- bowser's starting hp - local bowsercurhp = memory.readbyte(0x0483); -- bowser's current hp - local meterx = 104; -- x-origin of the meter - local metery = 228; -- y-origin of the meter - local spacingx = 8; -- how much x-space between each shape? - local spacingy = 0; -- how much y-space between each shape? - text((meterx-2),(metery-11),"Bowser:"); - for a=0,bowsermaxhp-1 do - drawshape((meterx+(spacingx*a)+0),(metery+(spacingy*a)+1),"heart_7x7","#000000"); - drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+0),"heart_7x7","#000000"); - drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+1),"heart_7x7","#000000"); - drawshape((meterx+(spacingx*a)+0),(metery+(spacingy*a)+0),"heart_7x7","#ffffff"); - if a < bowsercurhp then - drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+1),"heart_5x5","#ff0000"); - end; - end; - end; - end; - FCEU.frameadvance(); -end; diff --git a/branches/sdl2/output/luaScripts/SMB-Mouse.lua b/branches/sdl2/output/luaScripts/SMB-Mouse.lua deleted file mode 100644 index 8cc31403..00000000 --- a/branches/sdl2/output/luaScripts/SMB-Mouse.lua +++ /dev/null @@ -1,573 +0,0 @@ ---Super Mario Bros. - Drag and Drop ---Written by XKeeper ---Allows you to use the mouse to pick up enemies and movie them around! - -debugmodes = { - enabled = false; -- CHANGE THIS AT YOUR PERIL - showenemydata = false; - drawmouse = false; - locktimer = false; - invincible = false; - ver = "03/29 15:00:00"; - }; - -control = {}; -- must come first. - -- basically, will contain all the "interface" things, - -- buttons, menus, etc. - -- Easier to organize, I guess. - -require "x_functions"; -require "x_interface"; -if debugmodes['enabled'] and false then - require "x_smb1enemylist"; -- used for summoning and other things... not finished -end; - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu:5/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(6); -end; - - --- **************************************************************************** --- * drawmouse(xpos, ypos, click) --- * Draws a crude mouse pointer at the location; mostly good for screenshots and debugging. --- **************************************************************************** -function drawmouse(x, y, click) - - if click then - fill = "#cccccc"; - else - fill = "#ffffff"; - end; - - y = y + 1; - - for i = 0, 6 do - if i ~= 6 then - line(x + i, y + i, x + i, y + 8 - math.floor(i / 2), fill); - pixel(x + i, y + 8 - math.floor(i / 2), "#000000"); - end; - pixel(x + i, y + i - 1, "#000000"); - end; - pixel(x + 1, y + 0, "#000000"); - - line(x , y , x , y + 9, "#000000"); --- line(x + 1, y + 1, x + 6 , y + 6, "#000000"); --- line(x , y + 11, x + 7 , y + 7, "#000000"); - -end; - - --- **************************************************************************** --- * smbpx2ram( screen-x, screen-y ) --- * Returns the offset that represents the tile under screenx/screeny. --- **************************************************************************** -function smbpx2ram(px, py) - - local py = math.floor(py) - 0x20; - local px = math.floor(px); - if px < 0 or px > 400 or py < 0x00 or py > (240 - 0x20) then - return false; - end; - - local oy = math.floor(py / 0x10); - local ox = math.fmod(math.floor((px + smbdata['screenpos']) / 0x10), 0x20); - - offset = 0x500 + math.fmod(oy * 0x10 + math.floor(ox / 0x10) * 0xC0 + math.fmod(ox, 0xD0), 0x1A0); - return offset; - -end; - - --- **************************************************************************** --- * smbram2px( memory offset ) --- * Gives the current top-left pixel of the tile the offset represents. --- **************************************************************************** -function smbram2px(offset) - - offset = offset - 0x500; - if offset < 0 or offset >= 0x1A0 then - return false; - end; - - local px = (math.fmod(offset, 0x10) + math.floor(offset / 0xD0) * 0x10) * 0x10; - px = px - math.fmod(smbdata['screenpos'], 0x200); - if px < 0 then - px = px + 0x200; - end; - - local py = math.floor(math.fmod(offset, 0xD0) / 0x10); - returnval = {x = px, y = py}; - return returnval; - -end; - - --- **************************************************************************** --- * smbmoveenemy( Enemy number, xpos, ypos, x accell, y accell ) --- * moves enemies to given point. auto-sets facing direction, as well --- **************************************************************************** -function smbmoveenemy(n, x, y, ax, ay) - - local x1 = math.fmod(x, 0x100); - local x2 = math.floor(x / 0x100); - local y1 = math.fmod(y, 0x100); - local y2 = math.floor(y / 0x100); - local ax = math.max(-128, math.min(ax, 0x7F)); - local ay = math.max(-128, math.min(ay, 0x7F)); - - memory.writebyte(0x006D + n, x2); - memory.writebyte(0x0086 + n, x1); - memory.writebyte(0x00B5 + n, y2); - memory.writebyte(0x00CE + n, y1); - memory.writebyte(0x0057 + n, ax); - memory.writebyte(0x009F + n, ay); - - if ax > 0 then - memory.writebyte(0x0045 + n, 1); - elseif ax < 0 then - memory.writebyte(0x0045 + n, 2); - end; - -end; - - --- **************************************************************************** --- * inputaverage() --- * Mouse movement averages (something unique to this...). --- **************************************************************************** -function inputaverage() - - local tempx = 0; - local tempy = 0; - for temp = 1, 2 do - tempx = tempx + avgmove[temp]['xmouse']; - tempy = tempy + avgmove[temp]['ymouse']; - avgmove[temp] = avgmove[temp + 1]; - end; - avgmove[3]['xmouse'] = inpt['xmouse'] - last['xmouse']; - avgmove[3]['ymouse'] = inpt['ymouse'] - last['ymouse']; - avgmove['calc']['xmouse'] = (tempx + avgmove[3]['xmouse']) / 3; - avgmove['calc']['ymouse'] = (tempy + avgmove[3]['ymouse']) / 3; - -end; - - --- **************************************************************************** --- * tileview() --- * This does all the "what tile is here" shit for you (me) --- **************************************************************************** -function tileview () - local ramval = smbpx2ram(inpt['xmouse'], inpt['ymouse']); - if ramval then - local ret = smbram2px(ramval); - local c = "#ffffff"; - if math.fmod(timer, 4) < 2 then - c = "#cccccc"; - end; - if ret then - local tx1 = math.max(0, ret['x'] - 1); - local tx2 = math.min(0xFF, ret['x'] + 0x10); - local ty1 = math.max(ret['y'] * 0x10 + 0x1F, 0); - local ty2 = math.min(244, ret['y'] * 0x10 + 0x30); - box(tx1, ty1, tx2, ty2, c); - end; - - local textx = inpt['xmouse'] + 10; - local texty = inpt['ymouse'] - 4; - - if textx > 229 then - textx = textx - 42; - end; - texty = math.min(214, texty); - - text(textx, texty, string.format("%04X", ramval)); - text(textx, texty + 8, string.format(" %02X ", memory.readbyte(ramval))); - end; -end; - - --- **************************************************************************** --- * Generic test function, really. Does nothing of use. --- * Incidentally, most of the times this shows up, it doesn't --- **************************************************************************** -function test(arg) - - text(50, 100, "IT WORKS"); - -end; - - --- **************************************************************************** --- * spawnsetup(arg) --- * Prepares spawning of an enemy. --- * Perhaps should create a dialog box in the middle of the screen?.. --- **************************************************************************** -function spawnsetup(args) - - if mode ~= 2 then - spawndata['lmode'] = mode; - mode = 2; - spawndata['enum'] = 0x00; - spawndata['ename'] = "Green Koopa"; - spawndata['etype'] = 0; - spawndata['exs'] = 16; - spawndata['eys'] = 24; - -- etype: - --- 0: normal enemy (one slot) - --- 1: big enemy (two slots, takes latter but fills both) - --- 2: powerup (takes slot 6) - end; -end; - - --- **************************************************************************** --- * spawnsetup(arg) --- * Prepares spawning of an enemy. --- * Perhaps should create a dialog box in the middle of the screen?.. --- **************************************************************************** -function spawnenemy(args) - - local c = "#ffffff"; - if math.fmod(timer, 4) < 2 then - c = "#888888"; - end; - - local freespace = 0; - - if debugmodes['showenemydata'] then - for i = 1, 6 do - text(8, 8 + 8 * i, string.format("%d %02X", i, memory.readbyte(0x000E+i))); - end; - end; - for i = 1, 6 do - if ((spawndata['etype'] <= 1 and i <= 5) or (spawndata['etype'] == 2 and i == 6)) and memory.readbyte(0x000E+i) == 0 then - if debugmodes['showenemydata'] then - text(8, 8 + 8 * i, string.format("%d %02X *", i, memory.readbyte(0x000E+i))); - end; - if (spawndata['etype'] == 1 and memory.readbyte(0x000E + i - 1) == 0) or spawndata['etype'] ~= 1 then - freespace = i; - break; - end; - end; - end; - - if freespace > 0 then - box(inpt['xmouse'] - (spawndata['exs'] / 2), inpt['ymouse'] - (spawndata['eys'] / 2), inpt['xmouse'] + (spawndata['exs'] / 2), inpt['ymouse'] + (spawndata['eys'] / 2), c); - text(70, 31, string.format("Summon [%s]", spawndata['ename'])); - if debugmodes['showenemydata'] then - text(70, 39, string.format("Enemy slot [%X]", freespace)); - end; - local mx = smbdata['screenpos'] + inpt['xmouse']; - local my = 0x100 + inpt['ymouse']; - if inpt['leftclick'] and not last['leftclick'] then - memory.writebyte(0x000E + freespace, 1); - memory.writebyte(0x0015 + freespace, spawndata['enum']); - memory.writebyte(0x0499 + freespace, 3); - smbmoveenemy(freespace, mx - (spawndata['exs'] / 2), my - (spawndata['eys'] / 2), -1, 0); - mode = spawndata['lmode']; - end; - - else - text(70, 31, string.format("Can't summon (too many enemies)!")); - - end; - -end; - - --- **************************************************************************** --- * modechange(arg) --- * changes current mode (used in menu). --- * also changes menu text to reflect new mode. --- **************************************************************************** -function modechange(args) - - mode = args[1]; - if args[1] == 0 then - mainmenu['menu']['m001_mode']['menu']['m001_tiles']['marked'] = 1; - mainmenu['menu']['m001_mode']['menu']['m002_enemy']['marked'] = 0; - else - mainmenu['menu']['m001_mode']['menu']['m001_tiles']['marked'] = 0; - mainmenu['menu']['m001_mode']['menu']['m002_enemy']['marked'] = 1; - end; -end; - - --- **************************************************************************** --- * debugmode(arg) --- * changes debugmode flags --- * useful for on-the-fly checking, I guess --- **************************************************************************** -function debugmode(args) - - if debugmodes[args[2]] == false then - debugmodes[args[2]] = true; - mainmenu['menu']['m999_debug']['menu'][args[1]]['marked'] = 1; - else - debugmodes[args[2]] = false; - mainmenu['menu']['m999_debug']['menu'][args[1]]['marked'] = 0; - end; -end; - - - - - -mainmenu = { - test = 1; - life = 0; - width = 54; - menu = { - m001_mode = { - label = "Mode", - life = 0; - width = 50; - menu = { - m001_tiles = { - label = " Objects", - action = modechange, - args = {0}, - marked = 0; - }, - m002_enemy = { - label = " Sprites", - action = modechange, - args = {1}, - marked = 1; - }, - }, - }, - m002_summon = { - label = "Summon", - action = spawnsetup, - args = {1}, - }, - }, -}; - -if debugmodes['enabled'] then - mainmenu['menu']['m999_debug'] = { - label = "Debug", - life = 0; - width = 90; - menu = { - m000_showmouse = { - label = " Draw mouse", - action = debugmode, - marked = debugmodes['drawmouse'] and 1 or 0; - args = {"m000_showmouse", "drawmouse"}, - }, - m001_enemydata = { - label = " Show enemy data", - action = debugmode, - marked = debugmodes['showenemydata'] and 1 or 0; - args = {"m001_enemydata", "showenemydata"}, - }, - m002_locktimer = { - label = " Lock timer", - action = debugmode, - marked = debugmodes['locktimer'] and 1 or 0; - args = {"m002_locktimer", "locktimer"}, - }, - m003_invincible = { - label = " Invincibility", - action = debugmode, - marked = debugmodes['invincible'] and 1 or 0; - args = {"m003_invincible", "invincible"}, - }, - }, - }; -end; - - - - -smbdata = {screenpos = 0}; -mode = 1; -enemyhold = {}; -avgmove = { - { xmouse = 0, ymouse = 0 }, - { xmouse = 0, ymouse = 0 }, - { xmouse = 0, ymouse = 0 }, - calc = {} - }; -spawndata = {}; - -while (true) do - - - input.update(); -- updates mouse position - inputaverage(); -- average movement (for throwing) - - smbdata['screenposold'] = smbdata['screenpos']; - smbdata['screenpos'] = memory.readbyte(0x071a) * 0x100 + memory.readbyte(0x071c); - smbdata['screenposchg'] = smbdata['screenpos'] - smbdata['screenposold']; - smbdata['rendercol'] = memory.readbyte(0x06A0); - if smbdata['screenposchg'] < 0 then - smbdata['screenposchg'] = 0; - end; - timer = timer + 1; - - - if debugmodes['enabled'] then - if control.button( 234, 15, 19, 2, "SET\n999") then - memory.writebyte(0x07F8, 0x09); - memory.writebyte(0x07F9, 0x09); - memory.writebyte(0x07FA, 0x09); - end; - - if debugmodes['locktimer'] then - memory.writebyte(0x0787, 0x1F); - end; - - if debugmodes['invincible'] then - memory.writebyte(0x079E, 0x02); - end; - end; - - - if mode == 0 then - tileview(); - elseif mode == 2 then - - spawnenemy(); - - - else - if debugmodes['showenemydata'] then - text(0, 25 + 0, string.format("E# XPOS YPOS XREL YREL XA YA TY HB")); - end; - - for i=1,6 do - if (memory.readbyte(0x000E+i) ~= 0) then --and memory.readbyte(0x04AC+(i*4)) ~= 0xFF) and (memory.readbyte(0x0015 + i) ~= 0x30 and memory.readbyte(0x0015 + i) ~= 0x31) then - if not enemyhold[i] or not inpt['leftclick'] then - enemyhold[i] = nil; --- text(8, 50 + i * 8, "-"); - elseif enemyhold[i] then --- text(8, 50 + i * 8, string.format("HOLD %04X %04X", smbdata['screenpos'] + inpt['xmouse'] - enemyhold[i]['xmouse'], inpt['ymouse'] + 0x100 - enemyhold[i]['ymouse'])); - smbmoveenemy(i, smbdata['screenpos'] + inpt['xmouse'] - enemyhold[i]['x'], inpt['ymouse'] + 0x100 - enemyhold[i]['y'], (avgmove['calc']['xmouse']) * 8, avgmove['calc']['ymouse'] / 2.5); - end; - - e2x1 = memory.readbyte(0x04AC+(i*4)); - e2y1 = memory.readbyte(0x04AC+(i*4)+1); - e2x2 = memory.readbyte(0x04AC+(i*4)+2); - e2y2 = memory.readbyte(0x04AC+(i*4)+3); --- text(e2x1 - 5, e2y1 - 13, string.format("%02X", memory.readbyte(0x001E + i))); - - - - enemyxpos = memory.readbytesigned(0x006D + i) * 0x0100 + memory.readbyte(0x0086 + i); - enemyypos = memory.readbytesigned(0x00B5 + i) * 0x100 + memory.readbyte(0x00CE + i); - enemyxacc = memory.readbytesigned(0x0057 + i); - enemyyacc = memory.readbytesigned(0x009f + i); - enemyxposa = enemyxpos - smbdata['screenpos']; - enemyyposa = enemyypos - 0x100; - enemyyposa2 = math.fmod(enemyyposa + 0x10000, 0x100); - enemytype = memory.readbyte(0x0015 + i); - enemyhitbox = memory.readbyte(0x0499 + i); - - dead = ""; - if enemyyposa <= -72 + 32 and enemyyacc < -3 then - dead = "UP"; - end; - if math.abs(enemyxacc) >= 0x60 then - dead = dead .. "SIDE"; - end; - if dead ~= "" then - dead = " ".. dead; - end; - - if debugmodes['showenemydata'] then - line(enemyxposa, enemyyposa2, enemyxposa + 16, enemyyposa2, "#ffffff"); - text(enemyxposa, enemyyposa2, memory.readbyte(0x0045 + i)); - text(1, 25 + 8 * i, string.format("E%X %04X %04X %04X %04X %02X %02X %02X %02X %s", i, - AND(enemyxpos, 0xFFFF), - AND(enemyypos, 0xFFFF), - AND(enemyxposa, 0xFFFF), - AND(enemyyposa, 0xFFFF), - AND(enemyxacc, 0xFF), - AND(enemyyacc, 0xFF), - AND(enemytype, 0xFF), - AND(enemyhitbox, 0xFF), - "")); -- dead)); - end; - - if hitbox(inpt['xmouse'], inpt['ymouse'], inpt['xmouse'], inpt['ymouse'], e2x1, e2y1, e2x2, e2y2, "#ffffff", "#0000ff") then --- if hitbox(inpt['xmouse'], inpt['ymouse'], inpt['xmouse'], inpt['ymouse'], enemyxposa, enemyyposa, enemyxposa + 0xF, enemyyposa + 0x17) then - --- text(e2x1 - 5, e2y1 - 13, string.format("#%d %02X", i, memory.readbyte(0x0015 + i))); - - - if inpt['leftclick'] then - - if not enemyhold[i] then - enemyhold[i] = { x = inpt['xmouse'] - enemyxposa, y = inpt['ymouse'] - enemyyposa }; - end; - - --- memory.writebyte(0x001F + i, 0xFF); --- memory.writebyte(0x04AC + i, 0xFF); --- memory.writebyte(0x000E + i, 0x00); - end; - end; - else - enemyhold[i] = nil; - - end; - end; - end; - - --[[ - zap = zapper.read(); - - box(zap['xmouse'] - 5, zap['ymouse'] - 5, zap['xmouse'] + 5, zap['ymouse'] + 5, "#ffffff"); - if zap['click'] == 1 then - box(zap['xmouse'] - 7, zap['ymouse'] - 7, zap['xmouse'] + 7, zap['ymouse'] + 7, "#ff0000"); - end; - line(zap['xmouse'] - 0, zap['ymouse'] - 9, zap['xmouse'] + 0, zap['ymouse'] + 9, "#ffffff"); - line(zap['xmouse'] - 9, zap['ymouse'] - 0, zap['xmouse'] + 9, zap['ymouse'] + 0, "#ffffff"); - ]] - - - - -- almost always - if control.button(78, 14, 54, 1, "
") then - mainmenu['life'] = 70; - end; - control.showmenu(78, 25, mainmenu); - - text( 20, 222, " 2009 Xkeeper - http://jul.rustedlogic.net/ "); - line( 21, 231, 232, 231, "#000000"); - - if debugmodes['enabled'] then - text( 41, 214, " Debug version - ".. debugmodes['ver'] .." "); - end; - - - -- always on top - if debugmodes['drawmouse'] then - drawmouse(inpt['xmouse'], inpt['ymouse'], inpt['leftclick']); - end; - FCEU.frameadvance(); - -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/SMB-Snow.lua b/branches/sdl2/output/luaScripts/SMB-Snow.lua deleted file mode 100644 index 56841324..00000000 --- a/branches/sdl2/output/luaScripts/SMB-Snow.lua +++ /dev/null @@ -1,245 +0,0 @@ ---Super Mario Bros. - It's Snowing! ---Written by XKeeper - - -require("x_functions"); - -if not x_requires then - -- Sanity check. If they require a newer version, let them know. - timer = 1; - while (true) do - timer = timer + 1; - for i = 0, 32 do - gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000"); - end; - gui.text( 10, 32, string.format("This Lua script requires the x_functions library.")); - gui.text( 53, 42, string.format("It appears you do not have it.")); - gui.text( 39, 58, "Please get the x_functions library at"); - gui.text( 14, 69, "http://xkeeper.shacknet.nu/"); - gui.text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - -else - x_requires(4); -end; - - -function smbpx2ram(px, py) - - py = math.floor(py) - 0x20; - px = math.floor(px); - --- text(90, 16, string.format("PX[%4d] PY[%4d]", px, py)); - if px < 0 or px > 400 or py < 0x00 or py > (240 - 0x20) then - return false; - end; - - oy = math.floor(py / 0x10); - ox = math.fmod(math.floor((px + smbdata['screenpos']) / 0x10), 0x20); - --- text(90, 16, string.format("CX[%4X] CY[%4X]", ox, oy)); - - offset = 0x500 + math.fmod(oy * 0x10 + math.floor(ox / 0x10) * 0xC0 + math.fmod(ox, 0xD0), 0x1A0); - return offset; - -end; - -function smbram2px(offset) - - offset = offset - 0x500; - if offset < 0 or offset >= 0x1A0 then - return false; - end; - - - px = (math.fmod(offset, 0x10) + math.floor(offset / 0xD0) * 0x10) * 0x10; - px = px - math.fmod(smbdata['screenpos'], 0x200); --- text(8, 8, string.format("PX[%4d] OF[%4X]", px, offset)); - if px < 0 then - px = px + 0x200; - end; - - py = math.floor(math.fmod(offset, 0xD0) / 0x10); - returnval = {x = px, y = py}; - return returnval; - -end; - - -function doballs() - - count = 0; - for k, v in pairs(balls) do - - v['x'] = v['x'] + v['xs'] - smbdata['screenposchg']; - v['y'] = v['y'] + v['ys']; --- v['ys'] = v['ys'] - 0.1; - v['life'] = v['life'] - 1; - - offset = smbpx2ram(v['x'], v['y']); - temp = 0; - if offset then - temp = memory.readbyte(offset); - end; - - - -- 354 so we can spawn them offscreen - if v['x'] < 0 or v['x'] > 512 or v['y'] < 0 or v['y'] > 243 or v['life'] < 0 or (temp > 0) then - balls[k] = nil; - else - balls[k] = v; - colkey = math.ceil(255 * (5 - math.max(math.min(5, (v['life'] / 15)), 0)) / 5); - - if v['c'] >= 0 then - color = string.format("#%02X%02X%02X", v['c'], v['c'], 255); --- color = string.format("#%02X%02X%02X", v['c'] * .8, v['c'] * .5, v['c'] * 0); - else - color = string.format("#%02X0000", v['c'] * -1 , 0, 0); - end; - - if v['life'] > 400 then - box(v['x'] - 1, v['y'] - 1, v['x'] + 1, v['y'] + 1, color); - pixel(v['x'], v['y'], color); - elseif v['life'] > 200 then - box(v['x'], v['y'], v['x'] + 1, v['y'] + 1, color); - else - pixel(v['x'], v['y'], color); - end; - count = count + 1; - end; - end; - - return count; - -end; - - -balls = {}; -z = 0; -timer = 0; -smbdata = {screenpos = 0}; -while (true) do - - if - memory.readbyte(0x0301) == 0x3F and - memory.readbyte(0x0302) == 0x10 and - memory.readbyte(0x0303) == 0x04 and - memory.readbyte(0x0304) == 0x22 - then - memory.writebyte(0x0304, 0x0F); - end; - - smbdata['screenposold'] = smbdata['screenpos']; - smbdata['screenpos'] = memory.readbyte(0x071a) * 0x100 + memory.readbyte(0x071c); - smbdata['screenposchg'] = smbdata['screenpos'] - smbdata['screenposold']; - smbdata['rendercol'] = memory.readbyte(0x06A0); - if smbdata['screenposchg'] < 0 then - smbdata['screenposchg'] = 0; - end; - timer = timer + 1; - - - ballcount = doballs(); - - - for i = 0, 2 do - balls[z] = {x = math.random(0, 512), y = 0, xs = math.random(-50, 00) / 100, ys = math.random(100, 150) / 100, life = math.random(400, 700), c = math.random(200, 255)}; - z = z + 1; - end; - --- lifebar(8, 8, 240, 2, ballcount, 1000, "#ffffff", "clear"); ---]] - ---[[ - for x = 0x00, 0x0F do - for y = 0x00, 0x0C do - box(x * 0x10 + 0, y * 0x10 + 0x20, x * 0x10 + 0x01, y * 0x10 + 0x21, "#FFFFFF"); - value = memory.readbyte(smbpx2ram(x * 0x10, y * 0x10 + 0x20)); - if value > 0 then - text(x * 0x10 + 0, y * 0x10 + 0x20, string.format("%02X", value)); - end; - end; - end; -]] - --- text(8, 8, string.format("0x06A0 [%4X]", smbdata['rendercol'])); ---[[ - for i = 0, 5 do - ret = smbram2px(0x500 + i * 0x10 + i); - if ret then --- text(8, 16, string.format("PX[%4d] PY[%4d]", ret['x'], ret['y'])); - box(ret['x'] + 0, ret['y'] * 0x10 + 0x20, ret['x'] + 0x0F, ret['y'] * 0x10 + 0x2F, "#FFFFFF"); - end; - end; ---]] ---[[ - box(19, 19, 0x20 * 2 + 20, 46, "#0000ff"); - box(18, 18, 0x20 * 2 + 21, 47, "#0000ff"); - for x = 0, 0x1F do - for y = 0, 0x0C do - offset = 0x500 + y * 0x10 + math.floor(x / 0x10) * 0xD0 + math.fmod(x, 0x10); - c = memory.readbyte(offset); - box(x * 2 + 20, y * 2 + 20, x * 2 + 21, y * 2 + 21, string.format("#%02X%02X%02X", c, c, c)); - end; - end; - - if math.fmod(timer, 2) < 1 then - temp = math.floor(math.fmod(smbdata['screenpos'], 0x200) / 8); - if temp < 0x20 then - box(temp + 20, 19, temp + 0x10 * 2 + 20, 46, "#ffffff"); - else - box(temp + 20, 19, 0x20 * 2 + 20, 46, "#ffffff"); - box(19, 19, (temp - 0x20) + 20, 46, "#ffffff"); - end; - - line(smbdata['rendercol'] * 2 + 20, 19, smbdata['rendercol'] * 2 + 20, 46, "#00ff00"); - end; - ---]] ---[[ - x = 0; - y = 0; - px = math.sin(timer / 60) * 100 + 127; - py = math.cos(timer / 60) * 90 + 100 + 0x20; - offset = smbpx2ram(px, py); - if offset then - offset = offset - 0x500; - x = math.floor(offset / 0xD0) * 0x10 + math.fmod(offset, 0x10); - y = math.floor(math.fmod(offset, 0xD0) / 0x10); - - x2 = math.fmod(smbdata['screenpos'] + x * 0x10, 0x100); - box( x2, y * 0x10 + 0x20, x2 + 0x0F, y * 0x10 + 0x2F, "#ffffff"); --- line( 0, y * 0x10, 255, y * 0x10, "#ffffff"); - - box (px - 3, py - 3, px + 3, py + 3, "#ffffff"); - line(px - 6, py , px + 6, py , "#ffffff"); - line(px , py - 6, px , py + 6, "#ffffff"); - text(90, 24, string.format("Offset[%04X]", offset + 0x500)); - text(90, 32, string.format("OX[%4X] OY[%4X]", x, y)); - text(90, 40, string.format("SX[%4X]", x2)); - else - text(90, 24, "Offset failed"); - end; - - if math.fmod(timer, 2) < 1 then - temp = math.floor(math.fmod(smbdata['screenpos'], 0x200) / 8) + 20; - line(temp, 18, temp, 47, "#ffffff"); - box(20 + x * 2, 20 + y * 2, 21 + x * 2, 21 + y * 2, "#ffffff"); - - end; - ---]] - - - text( 20, 222, " 2009 Xkeeper - http://jul.rustedlogic.net/ "); - line( 21, 231, 232, 231, "#000000"); - - FCEU.frameadvance(); - -end; - diff --git a/branches/sdl2/output/luaScripts/SMB2U.lua b/branches/sdl2/output/luaScripts/SMB2U.lua deleted file mode 100644 index 4ebb2c39..00000000 --- a/branches/sdl2/output/luaScripts/SMB2U.lua +++ /dev/null @@ -1,173 +0,0 @@ --- Super Mario Bros. 2 USA - Grids & Contents (Unfinished) --- Super Mario Bros. 2 (U) (PRG0) [!].nes --- Written by QFox --- 31 July 2008 - --- shows (proper!) grid and contents. disable grid by setting variable to false --- shows any non-air grid's tile-id --- Slow! Will be heavy on lighter systems - - - -local angrybirdo = false; -- makes birdo freak, but can skew other creatures with timing :) -local drawgrid = true; -- draws a green grid - -local function box(x1,y1,x2,y2,color) - -- gui.text(50,50,x1..","..y1.." "..x2..","..y2); - if (x1 > 0 and x1 < 0xFF and x2 > 0 and x2 < 0xFF and y1 > 0 and y1 < 239 and y2 > 0 and y2 < 239) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; -local function text(x,y,str) - if (x > 0 and x < 0xFF and y > 0 and y < 240) then - gui.text(x,y,str); - end; -end; -local function toHexStr(n) - local meh = "%X"; - return meh:format(n); -end; - -while (true) do - if (angrybirdo and memory.readbyte(0x0010) > 0x81) then memory.writebyte(0x0010, 0x6D); end; -- birdo fires eggs constantly :p - - -- px = horzizontal page of current level - -- x = page x (relative to current page) - -- rx = real x (relative to whole level) - -- sx = screen x (relative to viewport) - local playerpx = memory.readbyte(0x0014); - local playerpy = memory.readbyte(0x001E); - local playerx = memory.readbyte(0x0028); - local playery = memory.readbyte(0x0032); - local playerrx = (playerpx*0xFF)+playerx; - local playerry = (playerpy*0xFF)+playery; - local playerstate = memory.readbyte(0x0050); - local screenoffsetx = memory.readbyte(0x04C0); - local screenoffsety = memory.readbyte(0x00CB); - - local playersx = (playerx - screenoffsetx); - if (playersx < 0) then playersx = playersx + 0xFF; end; - - local playersy = (playery - screenoffsety); - if (playersy < 0) then playersy = playersy + 0xFF; end; - - if (playerstate ~= 0x07) then - box(playersx, playersy, playersx+16, playersy+16, "green"); - end; - - if (memory.readbyte(0x00D8) == 0) then -- not scrolling vertically - -- show environment - -- i have playerrx, which is my real position in this level - -- i have the level, which is located at 0x6000 (the SRAM) - -- each tile (denoted by one byte) is 16x16 pixels - -- each screen is 15 tiles high and about 16 tiles wide - -- to get the right column, we add our playerrx/16 to 0x6000 - -- to be exact: - -- 0x6000 + (math.floor(playerrx/16) * 0xF0) + math.mod(playerx,0x0F) - - local levelstart = 0x6000; -- start of level layout in RAM - - -- ok, here we have two choices. either this is a horizontal level or - -- it is a vertical level. We have no real way of checking this, but - -- luckily levels are either horizontal or vertical :) - -- so there are three possibilities - -- 1: you're in 0:0, no worries - -- 2: you're in x:0, you're in a horizontal level - -- 3: you're in 0:y, you're in a vertical level - - - local addleftcrap = math.mod(screenoffsetx,16)*-1; -- works as padding to keep the grid aligned - local leftsplitrx = (memory.readbyte(0x04BE)*0x100) + (screenoffsetx + addleftcrap); -- column start left. add addleftcrap to iterative stuff to build up - local addtopcrap = math.mod(screenoffsety,15); -- works as padding to keep the grid aligned - local columns = math.floor(leftsplitrx/16); -- column x of the level is on the left side of the screen - - if (drawgrid) then -- print grid? - for i=0,15 do - -- text(addleftcrap+(i*16)-1, 37, toHexStr(columns+i)); -- print colnumber in each column - for j=0,17 do - box(addleftcrap+(i*16), addtopcrap+(j*16), addleftcrap+(i*16)+16, addtopcrap+(j*16)+16, "green"); -- draw green box for each cell - end; - end; - end; - - -- 42=mushroom if you go sub - -- 45=small - -- 44=big - -- 49=subspace - -- 6c=pow - -- 4e=cherry - - local topsplitry = (screenoffsety); - - -- starting page (might flow into next page). if the number of columns - -- is > 16, its a horizontal level, else its a vertical level. in either - -- case, the other will not up this value. - local levelpage = - levelstart + - ((math.floor(columns/16))*0xF0) + - (memory.readbyte(0x00CA)*0x100) + - topsplitry; - local levelcol = math.mod(columns,16); -- this is our starting column - - --text(10,150,toHexStr(topsplitry).." "..toHexStr(levelcol).." "..toHexStr(levelpage+levelcol).." "..toHexStr(leftsplitrx)); - - for j=0,15 do -- 16 columns - if (levelcol + j > 15) then -- go to next page - levelpage = levelpage + 0xF0; - levelcol = -j; - end; - for i=0,14 do -- 15 rows - local tile = memory.readbyte(levelpage+(levelcol+j)+(i*0x10)); - if (tile ~= 0x40) then - text(-2+addleftcrap+(j*16),5+(i*16),toHexStr(tile)); - end; - end; - end; - end; -- not scrolling if - - -- print some generic stats - text(2,10,"x:"..toHexStr(screenoffsetx)); - text(2,25,"y: "..toHexStr(screenoffsety)); - text(230,10,memory.readbyte(0x04C1)); - text(100,10,"Page: "..playerpx..","..playerpy); - text(playersx,playersy,playerrx.."\n"..playery); - - -- draw enemy info - local startpx = 0x0015; - local startpy = 0x001F; - local startx = 0x0029; - local starty = 0x0033; - local drawn = 0x0051; - local type = 0x0090; - for i=0,9 do - local estate = memory.readbyte(drawn+i); - if (estate ~= 0) then - local ex = memory.readbyte(startx+i); - local epx = memory.readbyte(startpx+i); - local ey = memory.readbyte(starty+i); - local epy = memory.readbyte(startpy+i); - local erx = (epx*0xFF)+ex; - local ery = (epy*0xFF)+ey; - local esx = (ex - screenoffsetx); - if (esx < 0) then esx = esx + 0xFF; end; - local esy = (ey - screenoffsety); - if (esy < 0) then esy = esy + 0xFF; end; - - --text(10, 20+(16*i), i..": "..esx.." "..erx); -- show enemy position list - - -- show enemy information - if ((erx > playerrx-127) and erx < (playerrx+120)) then - --text(esx,esy,erx); -- show level x pos above enemy - local wtf = "%X"; - text(esx,esy,wtf:format(memory.readbyte(type+i))); -- show enemy code - if (estate == 1 and i < 5) then - box(esx, esy, esx+16, esy+16, "red"); - else - box(esx, esy, esx+16, esy+16, "blue"); - end; - end; - end; - end; -- enemy info - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/SMB3-RainbowRiding.lua b/branches/sdl2/output/luaScripts/SMB3-RainbowRiding.lua deleted file mode 100644 index 493dea21..00000000 --- a/branches/sdl2/output/luaScripts/SMB3-RainbowRiding.lua +++ /dev/null @@ -1,638 +0,0 @@ -SCRIPT_TITLE = "Super Mario Bros. 3 Rainbow Riding" -SCRIPT_VERSION = "0.1" - -require "m_utils" -m_require("m_utils",0) - ---[[ -Super Mario Bros. 3 Rainbow Riding -version 0.1 by miau - -Visit http://morphcat.de/lua/ for the most recent version and other scripts. - -This script turns smb3 into a new game very similar to Kirby's Canvas Curse. -It's still incomplete, messy and full of bugs, so don't expect too much. Next version -will fix most of that... hopefully. -Probably slow on old computers, you may want to turn down emulator speed anyway to -decrease difficulty. - -Controls - Left-click on mario - jump - Middle-click anywhere - run - Draw vertical lines to make mario change his walking direction - Draw horizontal lines to help mario move over obstacles - -Supported roms - Super Mario Bros 3 (J), Super Mario Bros 3 (U) (PRG 0), Super Mario Bros 3 (U) (PRG 1), - Super Mario Bros 3 (E) - -Known Bugs/TODO list - Too many to list em all, actually... - - game objects are occasionally catapulted out of screen - bad divisions!? - - mario falling through lines (clean up collision detection) - - long vertically scrolling levels won't work - - boss battles are glitchy - - disable auto move in mini games? - - option to disable auto move? - - make collision detection work with fire balls (fire mario or fire piranha plants) - - improve map screen check - - add easy mode: decrease mario's speed - - improve enemy hit boxes - - (add suicide button in case mario gets stuck) --]] - ---configurable vars -local show_cursor = false --------------------------------------------------------------------------------------------- - - - -local Z_LSPAN = 400 --240 -local Z_MAX = 128 --256 --maximum amount of lines on screen -local NUM_SPRITES = 20 - -local zbuf = {} -local zindex = 1 -local timer = 0 -local zprev = 0 -local last_inp={} -local spr = {} --game's original sprites -local mario = {} -local clickbox={x1=-4,y1=4,x2=18,y2=32} -local collx = 0 -local colly = 0 ---local coll = {} --debug -local paintmeter = 0 -local lastpaint = -100 -local jp = {} - - ---accepts two tables containing these elements [1]=x1, [2]=y1, [3]=x2, [4]=y2 -function get_line_intersection(a,b) - local Asx,Asy,Bsx,Bsy,s,t - local Ax1,Ay1,Ax2,Ay2 - local Bx1,By1,Bx2,By2 - Ax1 = a[1] - Ay1 = a[2] - Ax2 = a[3] - Ay2 = a[4] - Bx1 = b[1] - By1 = b[2] - Bx2 = b[3] - By2 = b[4] - Asx = Ax2 - Ax1 - Asy = Ay2 - Ay1 - Bsx = Bx2 - Bx1 - Bsy = By2 - By1 - - s = (-Asy * (Ax1 - Bx1) + Asx * (Ay1 - By1)) / (-Bsx*Asy + Asx*Bsy) - t = (Bsx * (Ay1 - By1) - Bsy * (Ax1 - Bx1)) / (-Bsx*Asy + Asx*Bsy) - if(s>=0 and s<=1 and t>=0 and t<=1) then - local Ix,Iy - Ix = Ax1 + t * Asx - Iy = Ay1 + t * Asy - return Ix,Iy - else - return nil - end -end - -function close_to_line(Px,Py,a,range) --a[4] line segment - local Ax=a[1] - local Ay=a[2] - local Bx=a[3] - local By=a[4] - local APx = Px - Ax - local APy = Py - Ay - local ABx = Bx - Ax - local ABy = By - Ay - local absq = ABx*ABx + ABy*ABy - local apab = APx*ABx + APy*ABy - local t = apab / absq - - if (t < 0.0) then - t = 0.0 - elseif (t > 1.0) then - t = 1.0 - end - local Cx,Cy - Cx = Ax + ABx * t - Cy = Ay + ABy * t - if(getdistance(Px,Py,Cx,Cy)<=range) then - return true - else - return false - end -end - -function ride_line(s,xoffs,yoffs) - - local function move(zx1,zy1,zx2,zy2) - local avx,avy,cvx,cvy - cvx,cvy = getvdir(zx1,zy1,zx2,zy2) - if(math.abs(spr[s].vx) Z_MAX) then - spr[s].riding = 1 - end - if(spr[s].riding==firstline) then - spr[s].riding=nil - return - end - domovemagic(x,y,firstline) - end - end - - if(spr[s].riding==nil) then - return - end - - local x = spr[s].x+xoffs - local y = spr[s].y+yoffs - domovemagic(x,y,spr[s].riding) -end - -function collisioncheck(s) - local c=false - local cvx,cvy - local avx,avy - - local function checkpixel(xoffs,yoffs,i,j) - local x = spr[s].x+xoffs - local y = spr[s].y+yoffs - local px2 = x+spr[s].vx - local py2 = y+spr[s].vy - local px1 = x - local py1 = y - local zx = zbuf[i].x - local zy = zbuf[i].y - local zx2 = zbuf[j].x - local zy2 = zbuf[j].y - if(spr[s].vx~=0 or spr[s].vy~=0) then - if(spr[s].vx>0) then --we need at least one pixel!!? - px2 = px2 + 2 - elseif(spr[s].vx<0) then - px2 = px2 - 2 - end - if(spr[s].vy>0) then - py2 = py2 + 2 - elseif(spr[s].vy<0) then - py2 = py2 - 2 - end - - local cx,cy = get_line_intersection({px1,py1,px2,py2},{zx,zy,zx2,zy2}) - if(cx~=nil) then - cx = math.floor(cx) - cy = math.floor(cy) - local avx,avy,cvx,cvy - - --coll = {--[[a={px1,py1,px2+spr[s].vx*64,py2+spr[s].vy*64},-]]b={zbuf[i].x,zbuf[i].y,zbuf[j].x,zbuf[j].y}} --debug - collx = cx - colly = cy - - avx,avy = getvdir(px1,py1,px2,py2) - cvx,cvy = getvdir(zbuf[j].x,zbuf[j].y,zbuf[i].x,zbuf[i].y) - - - local x,y - x = cx-xoffs - y = cy-yoffs - if(spr[s].x==x and spr[s].y==y) then - --FCEU.message("boo"..timer) - else - set_sprite_pos(s,x,y) - end - if(s==0) then --mario/luigi - if(math.abs(cvy)==1 and math.abs(cvx) < 0.5) then - change_sprite_dir(s) - set_sprite_velocity(s,-avx,nil) - else - spr[s].riding = i - set_sprite_velocity(s,0,0) - end - else --enemies, moving platforms - end - - - return true - end - else - if(close_to_line(x,y,{zx,zy,zx2,zy2},4)) then - if(s==0) then - spr[s].riding = i - set_sprite_velocity(s,0,0) - end - return true - else - spr[s].riding = nil - end - end - return false - end - - if(spr[s].riding) then - ride_line(s,8,30) - return - end - - for i=1,Z_MAX do - if(zbuf[i] and zbuf[i].connected) then - --if(zbuf[i].x >= spr[s].x+hitbox.x1 and zbuf[i].y >= spr[s].y+hitbox.y1 - -- and zbuf[i].x <= spr[s].x+hitbox.x2 and zbuf[i].y <= spr[s].y+hitbox.y2) then - --local px = spr[s].x-spr[s].vx - --local py = spr[s].y-spr[s].vy - local j - j = i - 1 - if(j < 1) then - j = Z_MAX - end - - if(zbuf[j]) then --check if line is still valid (if nil, node disappeared) - if(s==0) then --mario - if(checkpixel(8,30,i,j)) then - return - end - else - if(checkpixel(0,0,i,j) or checkpixel(8,8,i,j) - --[[or checkpixel(0,8,i,j) or checkpixel(8,0,i,j)-]]) then - destroy_sprite(s) - return - end - end - end - - --end - end - end - -end - - -function screen_to_game_pos(x,y) - return x+scroll_x,y+scroll_y -end - -function game_to_screen_pos(x,y) - return x-scroll_x,y-scroll_y -end - - -function destroy_sprite(s) - if(s<10) then - memory.writebyte(0x660+s,0x06) - --memory.writebyte(0x660+s,0x00) - --set_sprite_velocity(s,10,10) - else - memory.writebyte(0x6C7+s-10,0x01) - --set_sprite_pos(s,0,0) - end -end - -function set_sprite_velocity(s,vx,vy) - if(s<10) then - if(s==0) then - memory.writebyte(0xD8,1) --air flag? - end - if(vx) then - memory.writebyte(0xBD+s,vx*16) - spr[s].vx = vx - end - if(vy) then - memory.writebyte(0xCF+s,vy*16) - spr[s].vy = vy - end - end -end - -function set_sprite_pos(i,x,y) - memory.writebyte(0x90+i,AND(x,255)) - memory.writebyte(0x75+i,math.floor(x/256)) - memory.writebyte(0xA2+i,AND(y,255)) - memory.writebyte(0x87+i,math.floor(y/256)) - spr[i].x = x - spr[i].y = y - spr[i].sx,spr[i].sy = game_to_screen_pos(spr[i].x,spr[i].y) -end - -function change_sprite_dir(s) - if(spr[s].dir == 1) then - spr[s].dir = -1 - elseif(spr[s].dir == -1) then - spr[s].dir = 1 - end -end - - -function add_rainbow_coord(cx,cy,connected) - zbuf[zindex] = {t=timer,x=cx,y=cy,connected=connected} - zprev = zbuf[zindex] - zindex = zindex + 1 - if(zindex>Z_MAX) then - zindex = 1 - end -end - -function drawrainbow(x1,y1,x2,y2,coloffs) - local cx,cy - local vx,vy - local color = coloffs - vx,vy = getvdir(x1,y1,x2,y2) - cx = x1 - cy = y1 - - for i=1,200 do - if(cx>=0 and cy>=0 and cx<=253 and cy<=253) then - local rcolor = color/1.8+161 --165 - gui.drawpixel(cx,cy,rcolor) - gui.drawpixel(cx,cy+1,rcolor) - gui.drawpixel(cx+1,cy,rcolor) - gui.drawpixel(cx+1,cy+1,rcolor) - - gui.drawpixel(cx+2,cy,rcolor) - gui.drawpixel(cx,cy+2,rcolor) - gui.drawpixel(cx+2,cy+1,rcolor) - gui.drawpixel(cx+1,cy+2,rcolor) - gui.drawpixel(cx+2,cy+2,rcolor) - end - if((x2>x1 and cx>x2) or (x2y1 and cy>y2) or (y260) then - mario.lastposchange = timer - change_sprite_dir(0) - end - - --load game sprites from ram - for i=0,NUM_SPRITES-1 do - if(i<10) then - spr[i].x = memory.readbyte(0x90+i)+memory.readbyte(0x75+i)*256 - spr[i].y = memory.readbyte(0xA2+i)+memory.readbyte(0x87+i)*256 - spr[i].vx = memory.readbytesigned(0xBD+i)/16 - spr[i].vy = memory.readbytesigned(0xCF+i)/16 - spr[i].a = (memory.readbytesigned(0x660+i)~=0) - spr[i].id = memory.readbytesigned(0x670+i) - spr[i].sx,spr[i].sy = game_to_screen_pos(spr[i].x,spr[i].y) - else - --TODO: 0x5D3? - local xcomp = memory.readbyte(0xFD) - local ycomp = memory.readbyte(0xFC) - spr[i].x = memory.readbyte(0x5C9+i-10) - spr[i].y = memory.readbyte(0x5BF+i-10) - spr[i].a = true - spr[i].vx = 0 - spr[i].vy = 0 - spr[i].sx = AND(spr[i].x-xcomp+256,255) - spr[i].sy = AND(spr[i].y-ycomp+256,255) - spr[i].x = spr[i].sx + scroll_x - spr[i].y = spr[i].sy + scroll_y - end - if(spr[i].a) then - collisioncheck(i) - end - end - -end - -function update_vars() - --disabling input not possible anymore in FCEUX 2.1? - jp = {} - if(mario.riding==nil) then - if(mario.movetimer) then - jp.B = 1 - mario.movetimer = mario.movetimer - 1 - if(mario.movetimer == 0) then - mario.movetimer = nil - end - end - if(mario.dir==1) then - jp.right=1 - elseif(mario.dir==-1) then - jp.left=1 - end - --if(AND(timer,1)==0) then --automatically enter doors and pipes... not a very good idea actually :P - --jp.up=1 - --if(memory.readbyte(0xD8)==1) then --air flag set? try to stay in air as long as possible... makes it easier to rescue mario if collision detection screws up.. sucks in water levels - -- jp.A=1 - --end - --else - -- jp.down=1 --automatically enter pipes - --end - end - - inp = input.get() - - scroll_x = memory.readbyte(0xFD)+memory.readbyte(0x12)*256 - scroll_y = memory.readbyte(0xFC)--+memory.readbyte(0x13)*256 --not quite right, long vertical scrolling levels won't work - - --0xD8 = 0 -> touch ground, 1 -> air - - update_sprites() - - - if(inp.middleclick) then - mario.movetimer = 30 - end - - if(inp.leftclick==nil) then - mario.jumping=false - end - if(inp.leftclick and last_inp.leftclick==nil and - inp.xmouse>=mario.sx+clickbox.x1 and inp.xmouse<=mario.sx+clickbox.x2 and - inp.ymouse>=mario.sy+clickbox.y1 and inp.ymouse<=mario.sy+clickbox.y2) - then - jp.A = 1 - mario.jumping = true - elseif(inp.leftclick and mario.jumping) then - jp.A = 1 - elseif(inp.leftclick) then - if(paintmeter>0) then - local x,y=screen_to_game_pos(inp.xmouse,inp.ymouse) - if(last_inp.leftclick==nil) then - add_rainbow_coord(x,y,false) - outofpaint = nil - elseif(outofpaint==nil) then - if(zprev and getdistance(x,y,zprev.x,zprev.y)>8) then - add_rainbow_coord(x,y,true) - paintmeter = paintmeter - 2 - lastpaint = timer - end - end - else - outofpaint = true - end - end - - joypad.set(1,jp) - - last_mario = mario - last_inp = inp -end - -function render() - --bctext(0,20,string.format("Memory usage: %.2f KB",collectgarbage("count"))) - - - local j = 0 - for i=1,Z_MAX do - if(zbuf[i]) then - j = j + 1 - end - end - --bctext(0,20,"Lines: "..j) - --bctext(0,20,mario.x..","..mario.y) - --bctext(0,30,mario.sx..","..mario.sy) - --bctext(0,40,mario.vx..","..mario.vy) - --bctext(0,50,"D "..mario.dir) - - --bctext(0,70,"scroll_x: "..scroll_x) - --bctext(0,80,"scroll_y: "..scroll_y) - --bctext(0,90,AND(mario.x,255)) - --if(mario.riding) then - -- bctext(0,100,"R") - --end - bcbox(mario.sx+clickbox.x1,mario.sy+clickbox.y1,mario.sx+clickbox.x2,mario.sy+clickbox.y2,"white") - - local prev_x, prev_y, prev_connected - local i=zindex - local color = AND(timer/2,15) - for j=1,Z_MAX do - if(zbuf[i]) then - local ltime = timer-zbuf[i].t - if(ltime0) then - drawrainbow(pmx+paintmeter,pmy,pmx,pmy,timer/6) - end - bcbox(pmx-2,pmy-1,pmx+102,pmy+3,"white") - - if(timer-lastpaint>60) then - paintmeter = paintmeter + 1 - if(paintmeter>100) then - paintmeter=100 - end - end - - if(show_cursor) then - local col2 - if(inp.leftclick) then - col2 = "#FFAA00" - elseif(inp.rightclick) then - col2 = "#0099EE" - elseif(inp.middleclick) then - col2 = "#AACC00" - else - col2 = "white" - end - drawcursor(inp.xmouse,inp.ymouse,"black",col2) - end -end - - -function domagic() - if(memory.readbyte(0x73)==0x20) then --map screen(?) - update_vars() - render() - else - bcpixel(1,10,"clear") - end -end - -initialize() -gui.register(domagic) - -while(true) do - FCEU.frameadvance() - timer = timer + 1 -end diff --git a/branches/sdl2/output/luaScripts/ShowPalette.lua b/branches/sdl2/output/luaScripts/ShowPalette.lua deleted file mode 100644 index 1f2805c2..00000000 --- a/branches/sdl2/output/luaScripts/ShowPalette.lua +++ /dev/null @@ -1,62 +0,0 @@ --- Show Palette --- Click for other palette boxes --- P00 - P3F are NES palette values. --- P40 - P7F are LUA palette values. - --- True or False -ShowTextLabels=true; - -function DecToHex(numberin) - if (numberin < 16) then - return string.format("0%X",numberin); - else - return string.format("%X",numberin); - end; -end; - -function text(x,y,str,text,back) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.text(x,y,str,text,back); - end; -end; - -local ButtonWasPressed; -local CurrentPaletteDisplay=0; - - - -while(true) do - -FCEU.frameadvance(); - -for i = 0, 7 do - gui.box(0 + (30*i),0,29 + (30*i),29,"P" .. DecToHex(0+i+(CurrentPaletteDisplay * 8)),"P" .. DecToHex(0+i+(CurrentPaletteDisplay * 8))); - gui.box(0 + (30*i),30,29 + (30*i),59,"P" .. DecToHex(16+i+(CurrentPaletteDisplay * 8)),"P" .. DecToHex(16+i+(CurrentPaletteDisplay * 8))); - gui.box(0 + (30*i),60,29 + (30*i),89,"P" .. DecToHex(32+i+(CurrentPaletteDisplay * 8)),"P" .. DecToHex(32+i+(CurrentPaletteDisplay * 8))); - gui.box(0 + (30*i),90,29 + (30*i),119,"P" .. DecToHex(48+i+(CurrentPaletteDisplay * 8)),"P" .. DecToHex(48+i+(CurrentPaletteDisplay * 8))); - if(ShowTextLabels == true) then - text(6 + (30*i),11,"P" .. DecToHex(0+i+(CurrentPaletteDisplay * 8))) - text(6 + (30*i),41,"P" .. DecToHex(16+i+(CurrentPaletteDisplay * 8))) - text(6 + (30*i),71,"P" .. DecToHex(32+i+(CurrentPaletteDisplay * 8))) - text(6 + (30*i),101,"P" .. DecToHex(48+i+(CurrentPaletteDisplay * 8))) - end; -end; - -mousestuff = input.get() - -if (not ButtonWasPressed) then - if (mousestuff.leftclick) then - ButtonWasPressed = 1; - CurrentPaletteDisplay=CurrentPaletteDisplay+1; - if (CurrentPaletteDisplay == 2) then - CurrentPaletteDisplay=8; - end; - if (CurrentPaletteDisplay == 10) then - CurrentPaletteDisplay=0; - end; - end; -end - -ButtonWasPressed = (mousestuff.leftclick); - -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/SoundDisplay.lua b/branches/sdl2/output/luaScripts/SoundDisplay.lua deleted file mode 100644 index c0fbccd6..00000000 --- a/branches/sdl2/output/luaScripts/SoundDisplay.lua +++ /dev/null @@ -1,213 +0,0 @@ ---------------------------------------------------------------------------- --- Display Sound Channels data --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * sound.get() ---------------------------------------------------------------------------- --- Usage: --- The script allows you to observe data of 5 sound channels. --- Analysing such info you can notice some regularities in how --- the data oscillates/changes when ingame music plays. --- Then you can write scripts similar to \taseditor\TrackNoise.lua --- to facilitate synchronous dances in TAS movies. ---------------------------------------------------------------------------- - -square1 = {x=1, y=8, on=true}; -square2 = {x=129, y=8, on=true}; -triangle = {x=1, y=67, on=true}; -noise = {x=129, y=67, on=true}; -dpcm = {x=1, y=118, on=true}; - -semitones = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"}; -duty_ratio = {"12.5%", "25%", "50%", "75%"}; -duty_color = {"purple", "magenta", "orange", "yellow"}; -key_color = {"#000000FF", "#202020FF", "#205050FF", "#008080FF", "#00C0C0FF", "#00FFFFFF", "#FFFFFFFF", "#FFFF00FF", "#FFFFFFFF", "#FFFF00FF", "#FFFFFFFF", "#FFFF00FF", "#FFFFFFFF", "#FFFF00FF", "#FFFFFFFF"}; -noise_color = {long="orange", short = "yellow"}; - -sample_names = { - -- Here you can specify custom names for DMC samples (to display name instead of just address) - -- For example, here are two samples for Contra(U) ROM - Sample_FC00 = {name="Kick", color="#C0C0C0FF"}, - Sample_FCC0 = {name="Snare", color="#80C0FFFF"}, -} - -function everyframe() - snd = sound.get(); - - if (square1.on) then - gui.text(square1.x, square1.y, "SQUARE 1:"); - - Volume = snd.rp2a03.square1.volume; - gui.text(square1.x, square1.y + 8, "Volume:"); - gui.box(square1.x + 32, square1.y + 7, square1.x + 32+15, square1.y + 15, "#006000FF", "black"); - gui.box(square1.x + 32, square1.y + 7, square1.x + 32 + Volume * 15, square1.y + 15, "green", "clear"); - gui.text(square1.x + 48, square1.y + 8, string.format("%g", Volume)); - - Frequency = snd.rp2a03.square1.frequency; - gui.text(square1.x, square1.y + 16, "Frequency: " .. string.format("%g", Frequency) .. "Hz"); - - Midikey = snd.rp2a03.square1.midikey; - gui.box(square1.x-1, square1.y + 23, square1.x + 127, square1.y + 31, "#008080FF", "black") - gui.box(square1.x-1, square1.y + 23, square1.x-1 + Midikey, square1.y + 31, "#00C0C0FF", "black") - Keycolor = key_color[math.floor(Volume * 15) + 1]; - gui.box(square1.x-1 + Midikey-1, square1.y + 23, square1.x-1 + Midikey+1, square1.y + 31, "white", Keycolor) - Note = math.floor((Midikey - 21) % 12); - Octave = math.floor((Midikey - 12) / 12); - Semitone = tostring(semitones[Note + 1]) .. Octave; - gui.text(square1.x, square1.y + 32, "Note: " .. Semitone .. " "); - gui.text(square1.x + 50, square1.y + 32, "(" .. string.format("%g", Midikey) .. ")"); - - Period = snd.rp2a03.square1.regs.frequency; - IndicatorColor = "#" .. string.format("%x", Period % 256) .. "0000FF"; - gui.text(square1.x, square1.y + 40, "Period:"); - gui.box(square1.x + 31, square1.y + 39, square1.x + 39, square1.y + 47, IndicatorColor, "black"); - gui.text(square1.x + 40, square1.y + 40, string.format("%g", Period)); - - Duty = snd.rp2a03.square1.duty; - gui.text(square1.x, square1.y + 48, "Duty #" .. Duty .. " (" .. duty_ratio[Duty + 1] .. ")", duty_color[Duty + 1]); - end - - if (square2.on) then - gui.text(square2.x, square2.y, "SQUARE 2:"); - - Volume = snd.rp2a03.square2.volume; - gui.text(square2.x, square2.y + 8, "Volume:"); - gui.box(square2.x + 32, square2.y + 7, square2.x + 32+15, square2.y + 15, "#006000FF", "black"); - gui.box(square2.x + 32, square2.y + 7, square2.x + 32 + Volume * 15, square2.y + 15, "green", "clear"); - gui.text(square2.x + 48, square2.y + 8, string.format("%g", Volume)); - - Frequency = snd.rp2a03.square2.frequency; - gui.text(square2.x, square2.y + 16, "Frequency: " .. string.format("%g", Frequency) .. "Hz"); - - Midikey = snd.rp2a03.square2.midikey; - gui.box(square2.x-1, square2.y + 23, square2.x + 127, square2.y + 31, "#008080FF", "black") - gui.box(square2.x-1, square2.y + 23, square2.x-1 + Midikey, square2.y + 31, "#00C0C0FF", "black") - Keycolor = key_color[math.floor(Volume * 15) + 1]; - gui.box(square2.x-1 + Midikey-1, square2.y + 23, square2.x-1 + Midikey+1, square2.y + 31, "white", Keycolor) - Note = math.floor((Midikey - 21) % 12); - Octave = math.floor((Midikey - 12) / 12); - Semitone = tostring(semitones[Note + 1]) .. Octave; - gui.text(square2.x, square2.y + 32, "Note: " .. Semitone .. " "); - gui.text(square2.x + 50, square2.y + 32, "(" .. string.format("%g", Midikey) .. ")"); - - Period = snd.rp2a03.square2.regs.frequency; - IndicatorColor = "#" .. string.format("%x", Period % 256) .. "0000FF"; - gui.text(square2.x, square2.y + 40, "Period:"); - gui.box(square2.x + 31, square2.y + 39, square2.x + 39, square2.y + 47, IndicatorColor, "black"); - gui.text(square2.x + 40, square2.y + 40, string.format("%g", Period)); - - Duty = snd.rp2a03.square2.duty; - gui.text(square2.x, square2.y + 48, "Duty #" .. Duty .. " (" .. duty_ratio[Duty + 1] .. ")", duty_color[Duty + 1]); - end - - if (triangle.on) then - gui.text(triangle.x, triangle.y, "TRIANGLE:"); - - Volume = snd.rp2a03.triangle.volume; - gui.text(triangle.x, triangle.y + 8, "Volume:"); - gui.box(triangle.x + 32, triangle.y + 7, triangle.x + 32+15, triangle.y + 15, "#006000FF", "black"); - gui.box(triangle.x + 32, triangle.y + 7, triangle.x + 32 + Volume * 15, triangle.y + 15, "#00A000FF", "clear"); - gui.text(triangle.x + 48, triangle.y + 8, string.format("%g", Volume)); - - Frequency = snd.rp2a03.triangle.frequency; - gui.text(triangle.x, triangle.y + 16, "Frequency: " .. string.format("%g", Frequency) .. "Hz"); - - Midikey = snd.rp2a03.triangle.midikey; - gui.box(triangle.x-1, triangle.y + 23, triangle.x + 127, triangle.y + 31, "#008080FF", "black") - gui.box(triangle.x-1, triangle.y + 23, triangle.x-1 + Midikey, triangle.y + 31, "#00C0C0FF", "black") - if (Volume ~= 0) then gui.box(triangle.x-1 + Midikey-1, triangle.y + 23, triangle.x-1 + Midikey+1, triangle.y + 31, "white", "black") end; - Note = math.floor((Midikey - 21) % 12); - Octave = math.floor((Midikey - 12) / 12); - Semitone = tostring(semitones[Note + 1]) .. Octave; - gui.text(triangle.x, triangle.y + 32, "Note: " .. Semitone .. " "); - gui.text(triangle.x + 50, triangle.y + 32, "(" .. string.format("%g", Midikey) .. ")"); - - Period = snd.rp2a03.triangle.regs.frequency; - IndicatorColor = "#" .. string.format("%x", Period % 256) .. "0000FF"; - gui.text(triangle.x, triangle.y + 40, "Period:"); - gui.box(triangle.x + 31, triangle.y + 39, triangle.x + 39, triangle.y + 47, IndicatorColor, "black"); - gui.text(triangle.x + 40, triangle.y + 40, string.format("%g", Period)); - end - - if (noise.on) then - gui.text(noise.x, noise.y, "NOISE:"); - - Volume = snd.rp2a03.noise.volume; - gui.text(noise.x, noise.y + 8, "Volume:"); - gui.box(noise.x + 32, noise.y + 7, noise.x + 32+15, noise.y + 15, "#006000FF", "black"); - gui.box(noise.x + 32, noise.y + 7, noise.x + 32 + Volume * 15, noise.y + 15, "green", "clear"); - gui.text(noise.x + 48, noise.y + 8, string.format("%g", Volume)); - - Frequency = snd.rp2a03.noise.frequency; - gui.text(noise.x, noise.y + 16, "Frequency: " .. string.format("%g", Frequency) .. "Hz"); - - Midikey = snd.rp2a03.noise.midikey; - gui.box(noise.x-1, noise.y + 23, noise.x + 127, noise.y + 31, "#008080FF", "black") - gui.box(noise.x-1, noise.y + 23, noise.x-1 + (Midikey/2), noise.y + 31, "#00C0C0FF", "black") - Keycolor = key_color[math.floor(Volume * 15) + 1]; - gui.box(noise.x-1 + (Midikey/2)-1, noise.y + 23, noise.x-1 + (Midikey/2)+1, noise.y + 31, "white", Keycolor) - Note = math.floor((Midikey - 21) % 12); - Octave = math.floor((Midikey - 12) / 12); - Semitone = tostring(semitones[Note + 1]) .. Octave; - gui.text(noise.x, noise.y + 32, "Note: " .. Semitone .. " "); - gui.text(noise.x + 58, noise.y + 32, "(" .. string.format("%g", Midikey) .. ")"); - - Period = snd.rp2a03.noise.regs.frequency; - IndicatorColor = "#" .. string.format("%X", Period % 256) .. "0000FF"; - gui.text(noise.x, noise.y + 40, "Period:"); - gui.box(noise.x + 31, noise.y + 39, noise.x + 39, noise.y + 47, IndicatorColor, "black"); - gui.text(noise.x + 40, noise.y + 40, string.format("%g", Period)); - - if (snd.rp2a03.noise.short) then - gui.text(noise.x, noise.y + 48, "Mode: short", noise_color.short); - else - gui.text(noise.x, noise.y + 48, "Mode: long", noise_color.long); - end - end - - if (dpcm.on) then - gui.text(dpcm.x, dpcm.y, "DPCM:"); - - Volume = snd.rp2a03.dpcm.volume; - gui.text(dpcm.x, dpcm.y + 8, "Volume:"); - gui.box(dpcm.x + 32, dpcm.y + 7, dpcm.x + 32+15, dpcm.y + 15, "#006000FF", "black"); - gui.box(dpcm.x + 32, dpcm.y + 7, dpcm.x + 32 + Volume * 15, dpcm.y + 15, "#00A000FF", "clear"); - gui.text(dpcm.x + 48, dpcm.y + 8, string.format("%g", Volume)); - - Frequency = snd.rp2a03.dpcm.frequency; - gui.text(dpcm.x, dpcm.y + 16, "Frequency: " .. string.format("%g", Frequency) .. "Hz"); - - Midikey = snd.rp2a03.dpcm.midikey; - gui.box(dpcm.x-1, dpcm.y + 23, dpcm.x + 127, dpcm.y + 31, "#008080FF", "black") - gui.box(dpcm.x-1, dpcm.y + 23, dpcm.x-1 + (Midikey/2), dpcm.y + 31, "#00C0C0FF", "black") - if (Volume ~= 0) then gui.box(dpcm.x-1 + (Midikey/2)-1, dpcm.y + 23, dpcm.x-1 + (Midikey/2)+1, dpcm.y + 31, "white", "black") end; - Note = math.floor((Midikey - 21) % 12); - Octave = math.floor((Midikey - 12) / 12); - Semitone = tostring(semitones[Note + 1]) .. Octave; - gui.text(dpcm.x, dpcm.y + 32, "Note: " .. Semitone .. " "); - gui.text(dpcm.x + 50, dpcm.y + 32, "(" .. string.format("%g", Midikey) .. ")"); - - Period = snd.rp2a03.dpcm.regs.frequency; - IndicatorColor = "#" .. string.format("%x", Period % 256) .. "0000FF"; - gui.text(dpcm.x, dpcm.y + 40, "Period:"); - gui.box(dpcm.x + 31, dpcm.y + 39, dpcm.x + 39, dpcm.y + 47, IndicatorColor, "black"); - gui.text(dpcm.x + 40, dpcm.y + 40, string.format("%g", Period)); - - if (snd.rp2a03.dpcm.dmcloop) then - gui.text(dpcm.x, dpcm.y + 48, "Sample: $" .. string.format("%X", snd.rp2a03.dpcm.dmcaddress) .. " (" .. snd.rp2a03.dpcm.dmcsize .. " bytes looped)", "orange"); - else - gui.text(dpcm.x, dpcm.y + 48, "Sample: $" .. string.format("%X", snd.rp2a03.dpcm.dmcaddress) .. " (" .. snd.rp2a03.dpcm.dmcsize .. " bytes)"); - end - - Sample_id = "Sample_" .. string.format("%X", snd.rp2a03.dpcm.dmcaddress); - if (sample_names[Sample_id] ~= nil) then - gui.text(dpcm.x + 170, dpcm.y + 48, sample_names[Sample_id].name, sample_names[Sample_id].color); - end - - gui.text(dpcm.x, dpcm.y + 56, "DMC seed: " .. string.format("%X", snd.rp2a03.dpcm.dmcseed)); - end -end - -emu.registerafter(everyframe); - diff --git a/branches/sdl2/output/luaScripts/SoundDisplay2.lua b/branches/sdl2/output/luaScripts/SoundDisplay2.lua deleted file mode 100644 index 6402ed76..00000000 --- a/branches/sdl2/output/luaScripts/SoundDisplay2.lua +++ /dev/null @@ -1,312 +0,0 @@ --- feos, 2012 --- gui.box frame simulates transparency - -print("Hi-hat and keys may glitch if you produce sound effects.") -print("Leftclick over the displays: channel names to hide the volumes, notes to hide the keyboard.") -print(" ") -print("And praise Gocha!") - -iterator = 15 -kb = {x=9, y=154, on=true} -prev_keys = input.get() -semitones = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"} - -volumes = { - S1V = {0}, S1C = {}, - S2V = {0}, S2C = {}, - TV = {0}, - NV = {0}, - DPCMV = {0} -} - -function Draw() - snd = sound.get() - keys = input.get() - - -- do only at the first frame - if #volumes.S1V == 1 then - channels = { - Square1 = {x=1, y=9, vol=volumes.S1V, color=volumes.S1C, duty=0, midi=0, semitone=0, octave=0, prev_semitone=0, float = {}}, - Square2 = {x=1+45*1, y=9, vol=volumes.S2V, color=volumes.S2C, duty=0, midi=0, semitone=0, octave=0, prev_semitone=0, float = {}}, - Triangle = {x=1+45*2, y=9, vol=volumes.TV, midi=0, semitone=0, octave=0, prev_semitone=0, float = {}}, - Noise = {x=1+45*3, y=9, vol=volumes.NV, midi=0, semitone=0, octave=0}, - DPCM = {x=1+45*4, y=9, vol=volumes.DPCMV} - } - end - - -- update the first indices for volume tables - -- shift the previous ones farther - table.insert(channels.Square1.vol, 1, snd.rp2a03.square1.volume*15) - table.insert(channels.Square2.vol, 1, snd.rp2a03.square2.volume*15) - table.insert(channels.Triangle.vol, 1, snd.rp2a03.triangle.volume*15) - table.insert(channels.Noise.vol, 1, snd.rp2a03.noise.volume*15) - table.insert(channels.DPCM.vol, 1, snd.rp2a03.dpcm.volume*15) - - -- get duty and midikey for proper channels - channels.Square1.duty = snd.rp2a03.square1.duty - channels.Square2.duty = snd.rp2a03.square2.duty - - channels.Square1.midi = snd.rp2a03.square1.midikey - channels.Square2.midi = snd.rp2a03.square2.midikey - channels.Triangle.midi = snd.rp2a03.triangle.midikey - channels.Noise.midi = snd.rp2a03.noise.midikey - - -- guess notes - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" or name == "Triangle" or name == "Noise" then - if chan.vol[1] > 0 then - chan.octave = math.floor((chan.midi - 12) / 12) - chan.semitone = tostring(semitones[math.floor((chan.midi - 21) % 12) + 1]) - else chan.semitone = "--"; chan.octave = "-" - end - end - end - - -- notes display - gui.text(kb.x+203, kb.y, "S1: "..channels.Square1.semitone..channels.Square1.octave, "#ff0000ff", "#000000ff") - gui.text(kb.x+203, kb.y+9, "S2: "..channels.Square2.semitone..channels.Square2.octave, "#aa00ccff", "#000000ff") - gui.text(kb.x+204, kb.y+18, "Tr: "..channels.Triangle.semitone..channels.Triangle.octave, "#00aaffff", "#000000ff") - gui.text(kb.x+204, kb.y+27, "Ns: "..channels.Noise.semitone..channels.Noise.octave, "#ffffffff", "#000000ff") - ------------------ --- Draw hi-hat -- ------------------ - - xhh1 = 227 - yhh1 = 18 - xhh2 = 227 - yhh2 = 18 - - if channels.Noise.vol[1] > 0 then - if channels.Noise.octave >= 9 and channels.Noise.octave <= 12 then - colorhh = "#ffaa00" - if channels.Noise.vol[2] - channels.Noise.vol[1] < 4 - and channels.Noise.vol[2] > 0 - then yhh1 = 15 - end - end - else colorhh = "#00000000" - end - - gui.line(xhh1-1, yhh1, xhh1+28, yhh1, "#00000088") - gui.line(xhh1-1, yhh1-1, xhh1+28, yhh1-1, "#00000088") - gui.line(xhh1-1, yhh1-2, xhh1+28, yhh1-2, "#00000088") - gui.line(xhh1+3, yhh1-3, xhh1+24, yhh1-3, "#00000088") - gui.line(xhh1+8, yhh1-4, xhh1+19, yhh1-4, "#00000088") - gui.line(xhh1+11, yhh1-5, xhh1+16, yhh1-5, "#00000088") - gui.line(xhh1+12, yhh1-6, xhh1+15, yhh1-6, "#00000088") - gui.line(xhh2-1, yhh2, xhh2+28, yhh2, "#00000088") - gui.line(xhh2-1, yhh2+1, xhh2+28, yhh2+1, "#00000088") - gui.line(xhh2-1, yhh2+2, xhh2+28, yhh2+2, "#00000088") - gui.line(xhh2+3, yhh2+3, xhh2+24, yhh2+3, "#00000088") - gui.line(xhh2+8, yhh2+4, xhh2+19, yhh2+4, "#00000088") - gui.line(xhh2+11, yhh2+5, xhh2+16, yhh2+5, "#00000088") - gui.line(xhh2+12, yhh2+6, xhh2+15, yhh2+6, "#00000088") - - gui.line(xhh1, yhh1-1, xhh1+27, yhh1-1, colorhh) - gui.line(xhh1+4, yhh1-2, xhh1+23, yhh1-2, colorhh) - gui.line(xhh1+9, yhh1-3, xhh1+18, yhh1-3, colorhh) - gui.line(xhh1+12, yhh1-4, xhh1+15, yhh1-4, colorhh) - gui.line(xhh1+13, yhh1-5, xhh1+14, yhh1-5, colorhh) - gui.line(xhh2, yhh2+1, xhh2+27, yhh2+1, colorhh) - gui.line(xhh2+4, yhh2+2, xhh2+23, yhh2+2, colorhh) - gui.line(xhh2+9, yhh2+3, xhh2+18, yhh2+3, colorhh) - gui.line(xhh2+12, yhh2+4, xhh2+15, yhh2+4, colorhh) - gui.line(xhh2+13, yhh2+5, xhh2+14, yhh2+5, colorhh) - --------------------- --- Keyboard stuff -- --------------------- - - if (kb.on) then - -- capture leftclicks - if keys.xmouse <= 256 and keys.xmouse >= 205 and keys.ymouse >= 154 and keys.ymouse <= 181 then - if keys["leftclick"] and not prev_keys["leftclick"] then kb.on = false end - end - -- draw the kayboard - gui.box(kb.x-8, kb.y, kb.x+200, kb.y+16, "#ffffffff") -- white solid box - for a = -2, 49 do gui.box(kb.x+4*a, kb.y, kb.x+4*a, kb.y+16, "#00000000") end -- black lines - -- draw colored boxes as clean notes - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" or name == "Triangle" then - if name == "Triangle" then color = "#00aaffff" - elseif name == "Square1" then color = "#ff0000ff" - else color = "#aa00ccff" - end - - if chan.semitone == "C" then gui.box(kb.x+1 +28*(chan.octave-1), kb.y, kb.x+3 +28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "D" then gui.box(kb.x+5 +28*(chan.octave-1), kb.y, kb.x+7 +28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "E" then gui.box(kb.x+9 +28*(chan.octave-1), kb.y, kb.x+11+28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "F" then gui.box(kb.x+13+28*(chan.octave-1), kb.y, kb.x+15+28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "G" then gui.box(kb.x+17+28*(chan.octave-1), kb.y, kb.x+19+28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "A" then gui.box(kb.x+21+28*(chan.octave-1), kb.y, kb.x+23+28*(chan.octave-1), kb.y+16, color) - elseif chan.semitone == "B" then gui.box(kb.x+25+28*(chan.octave-1), kb.y, kb.x+27+28*(chan.octave-1), kb.y+16, color) - end - end - end - -- draw accidental keys - gui.box(kb.x-3, kb.y, kb.x-5, kb.y+10, "#00000000") - for oct = 0, 6 do - gui.box(kb.x+3+28*oct, kb.y, kb.x+5+28*oct, kb.y+10, "#00000000") - gui.box(kb.x+7+28*oct, kb.y, kb.x+9+28*oct, kb.y+10, "#00000000") - gui.box(kb.x+15+28*oct, kb.y, kb.x+17+28*oct, kb.y+10, "#00000000") - gui.box(kb.x+19+28*oct, kb.y, kb.x+21+28*oct, kb.y+10, "#00000000") - gui.box(kb.x+23+28*oct, kb.y, kb.x+25+28*oct, kb.y+10, "#00000000") - end - -- draw colored boxes over accidental keys - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" or name == "Triangle" then - if name == "Triangle" then color = "#00aaffff" - elseif name == "Square1" then color = "#ff0000ff" - else color = "#aa00ccff" - end - - if chan.semitone == "C#" then gui.box(kb.x+3 +28*(chan.octave-1), kb.y, kb.x+5 +28*(chan.octave-1), kb.y+10, color) - elseif chan.semitone == "D#" then gui.box(kb.x+7 +28*(chan.octave-1), kb.y, kb.x+9 +28*(chan.octave-1), kb.y+10, color) - elseif chan.semitone == "F#" then gui.box(kb.x+15+28*(chan.octave-1), kb.y, kb.x+17+28*(chan.octave-1), kb.y+10, color) - elseif chan.semitone == "G#" then gui.box(kb.x+19+28*(chan.octave-1), kb.y, kb.x+21+28*(chan.octave-1), kb.y+10, color) - elseif chan.semitone == "A#" then gui.box(kb.x+23+28*(chan.octave-1), kb.y, kb.x+25+28*(chan.octave-1), kb.y+10, color) - end - end - end - - grey = "#aaaaaaaa" - for oct = 0, 6 do - gui.line(kb.x+3+28*oct, kb.y+10, kb.x+5+28*oct, kb.y+10, grey) - gui.line(kb.x+7+28*oct, kb.y+10, kb.x+9+28*oct, kb.y+10, grey) - gui.line(kb.x+15+28*oct, kb.y+10, kb.x+17+28*oct, kb.y+10, grey) - gui.line(kb.x+19+28*oct, kb.y+10, kb.x+21+28*oct, kb.y+10, grey) - gui.line(kb.x+23+28*oct, kb.y+10, kb.x+25+28*oct, kb.y+10, grey) - end - gui.line(kb.x-3, kb.y+10, kb.x-5, kb.y+10, grey) - gui.line(kb.x-8, kb.y, kb.x+200, kb.y, "#00000088") - gui.line(kb.x-8, kb.y+16, kb.x+200, kb.y+16, "#00000088") - gui.line(kb.x-8, kb.y, kb.x-8, kb.y+16, "#00000088") - gui.line(kb.x+200, kb.y, kb.x+200, kb.y+16, "#00000088") - else - -- capture leftclicks - if keys.xmouse <= 256 and keys.xmouse >= 205 and keys.ymouse >= 154 and keys.ymouse <= 181 then - if keys["leftclick"] and not prev_keys["leftclick"] then kb.on = true end - end - end - --------------------- --- Floating notes -- --------------------- - - if (kb.on) then - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" or name == "Triangle" then - - if chan.prev_semitone ~= chan.semitone then - if chan.semitone == "C" then table.insert(chan.float, 1, kb.x+1 +28*(chan.octave-1)) - elseif chan.semitone == "D" then table.insert(chan.float, 1, kb.x+5 +28*(chan.octave-1)) - elseif chan.semitone == "E" then table.insert(chan.float, 1, kb.x+9 +28*(chan.octave-1)) - elseif chan.semitone == "F" then table.insert(chan.float, 1, kb.x+13+28*(chan.octave-1)) - elseif chan.semitone == "G" then table.insert(chan.float, 1, kb.x+17+28*(chan.octave-1)) - elseif chan.semitone == "A" then table.insert(chan.float, 1, kb.x+21+28*(chan.octave-1)) - elseif chan.semitone == "B" then table.insert(chan.float, 1, kb.x+25+28*(chan.octave-1)) - elseif chan.semitone == "C#" then table.insert(chan.float, 1, kb.x+3 +28*(chan.octave-1)) - elseif chan.semitone == "D#" then table.insert(chan.float, 1, kb.x+7 +28*(chan.octave-1)) - elseif chan.semitone == "F#" then table.insert(chan.float, 1, kb.x+15+28*(chan.octave-1)) - elseif chan.semitone == "G#" then table.insert(chan.float, 1, kb.x+19+28*(chan.octave-1)) - elseif chan.semitone == "A#" then table.insert(chan.float, 1, kb.x+23+28*(chan.octave-1)) - end - end - - if name == "Triangle" then color = "#00aaffff" - elseif name == "Square1" then color = "#ff0000ff" - else color = "#aa00ccff" - end - - if #chan.float < 13 then - for i = 2, #chan.float do - if movie.framecount()%2 == 0 then gui.box(chan.float[i]-1, 161+i*5, chan.float[i]+3, 165+i*5, "#eedd2200") end - gui.box(chan.float[i], 162+i*5, chan.float[i]+2, 164+i*5, color) - end - else - for i = 2, 13 do - if movie.framecount()%2 == 0 then gui.box(chan.float[i]-1, 161+i*5, chan.float[i]+3, 165+i*5, "#eedd2200") end - gui.box(chan.float[i], 162+i*5, chan.float[i]+2, 164+i*5, color) - end - table.remove(chan.float, 14) - end - end - end - end - ---------------------- --- Volumes display -- ---------------------- - - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" then - -- set color for each duty value - if chan.duty == 0 then table.insert(chan.color,1,"#aaff00ff") - elseif chan.duty == 1 then table.insert(chan.color,1,"#00ff00ff") - elseif chan.duty == 2 then table.insert(chan.color,1,"#00bb00ff") - else table.insert(chan.color,1,"#008800ff") - end - end - -- capture leftclicks - if iterator == 15 then - if keys.ymouse <= 24 and keys.ymouse >= 0 then - if keys["leftclick"] and not prev_keys["leftclick"] then iterator = 1 end - end - else - if keys.ymouse <= 24 and keys.ymouse >= 0 then - if keys["leftclick"] and not prev_keys["leftclick"] then iterator = 15 end - end - end - -- draw volumes - gui.text(chan.x, 9, name, "#ffffffff", "#000000ff") - if iterator <=14 then - -- draw just first volume values - gui.text(chan.x, chan.y+9+1, chan.vol[1]) - if tonumber(chan.vol[1]) > 0 then - for j = 0, chan.vol[1]-1 do - gui.box(chan.x+13+j*2, chan.y+9, chan.x+15+j*2, chan.y+8+9, "#000000ff") - gui.line(chan.x+14+j*2, chan.y+1+9, chan.x+14+j*2, chan.y+7+9, "#00ff00ff") - if name == "Square1" or name == "Square2" then - -- color comes from duty - gui.text(chan.x+38, chan.y, chan.duty, chan.color[1], "#000000ff") - gui.line(chan.x+14+j*2, chan.y+1+9, chan.x+14+j*2, chan.y+7+9, chan.color[1]) - end - end - end - else - -- draw all 15 volume values - for i = 1, #chan.vol do - gui.text(chan.x, chan.y+i*9+1, chan.vol[i]) - if tonumber(chan.vol[i]) > 0 then - for j = 0, chan.vol[i]-1 do - gui.box(chan.x+13+j*2, chan.y+i*9, chan.x+15+j*2, chan.y+8+i*9, "#000000ff") - gui.line(chan.x+14+j*2, chan.y+1+i*9, chan.x+14+j*2, chan.y+7+i*9, "#00ff00ff") - if name == "Square1" or name == "Square2" then - -- color comes from duty - gui.text(chan.x+38, chan.y, chan.duty, chan.color[1], "#000000ff") - gui.line(chan.x+14+j*2, chan.y+1+i*9, chan.x+14+j*2, chan.y+7+i*9, chan.color[i]) - end - end - end - end - end - -- keep the table limited - table.remove(chan.vol, 15) - - -- highlight the first values - -- 30 Hz blinking, works properly if your monitor is set to 60 Hz - if chan.vol[1] > 0 and movie.framecount()%2 == 0 then - gui.box(chan.x+12, chan.y+8, chan.x+14+chan.vol[1]*2, chan.y+18, "#ffcc0000") - end - end - - for name, chan in pairs(channels) do - if name == "Square1" or name == "Square2" or name == "Triangle" then - chan.prev_semitone = chan.semitone - end - end - - prev_keys = keys -end -emu.registerafter(Draw); \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/Subtitler.lua b/branches/sdl2/output/luaScripts/Subtitler.lua deleted file mode 100644 index d0ab0773..00000000 --- a/branches/sdl2/output/luaScripts/Subtitler.lua +++ /dev/null @@ -1,384 +0,0 @@ ---FCEUX Subtitler Express v2, by FatRatKnight --- I find the built-in subtitles for FCEUX's .fm2 is somewhat inconvenient. --- This script should make the process smoother. - --- Run the script. Type whatever you like. Letters and such will appear at the --- top of the game display. The script can output a line of text that FCEUX --- can understand and translates into the appropriate subtitle. It can ouput to --- a file or to the display box - --- Whatever the script outputs, you can copy that and paste it into the .fm2 --- file in question, right before where all the actual frames begin. I suggest --- WordPad to open the .fm2 file. - --- If you're really that lazy, run a movie, subtitle it, then hit pageup twice. --- The movie will be stopped, but this script will replace the old subtitles --- with the new ones. It will actually create a new file appended with _S in --- case the script royally screws up somehow. - --- Let a frame pass, and the text becomes translucent. This is to signify that --- the text will remain visible as an actual subtitle, but you can put in a new --- subtitle here without destroying the old one. It will just override the old --- subtitle when it's time for the new one to show up. - --- Still, when it comes to translucent text, it's pretty dumb around loading --- states. Don't try to worry too much about it. - --- Beware of hotkeys you set in FCEUX, or even the defaults like I, P, shift+R, --- shift+L, comma, and period. These can and will interfere with this script --- if you don't disable them. - --- Please don't try to type while emulation is unpaused. This script is not --- smart enough to know how to handle unpaused typing. - --- Don't let the warnings scare you. I hope the script makes subtitling easy. - - -local BypassFrameAdvanceKey= "backslash" --Set this to the frameadvance key. - -local SaveToThisFile= "ConvenientSubtitles.txt" --Location to save a file - -local SaveOnExit= true --Dost thou wish to save when the script exits? - - --- List of commands: -local DelChar= "backspace" -- Delete a single character -local DelSub= "delete" -- Erase the whole subtitle for this frame -local ShoLine= "enter" -- Prints displayed line in .fm2 readable format -local SubCnt= "home" -- Counts current number of stored subtitles -local PntAll= "end" -- Prints all subtitles formatted for .fm2 -local SaveTxt= "pagedown" -- Saves subtitles to file -local T_AutoS= "insert" -- Toggles whether the script saves on exit -local SvToMov= "pageup" -- Saves subtitles to the movie file itself - - - -local WordyWords= {} -local CurrentStr= "" - -local KeyTable= { -a="a",b="b",c="c",d="d",e="e",f="f",g="g",h="h",i="i",j="j",k="k",l="l",m="m", -n="n",o="o",p="p",q="q",r="r",s="s",t="t",u="u",v="v",w="w",x="x",y="y",z="z", -tilde="`",minus="-",plus="=", -leftbracket="[",rightbracket="]",backslash="\\", -semicolon=";",quote="'", -comma=",",period=".",slash="/", - -A="A",B="B",C="C",D="D",E="E",F="F",G="G",H="H",I="I",J="J",K="K",L="L",M="M", -N="N",O="O",P="P",Q="Q",R="R",S="S",T="T",U="U",V="V",W="W",X="X",Y="Y",Z="Z", -TILDE="~",MINUS="_",PLUS="+", -LEFTBRACKET="{",RIGHTBRACKET="}",BACKSLASH="|", -SEMICOLON=":",QUOTE="\"", -COMMA="<",PERIOD=">",SLASH="?", - -numpad1="1",numpad2="2",numpad3="3",numpad4="4",numpad5="5", -numpad6="6",numpad7="7",numpad8="8",numpad9="9",numpad0="0", - -space= " ", SPACE= " "} - -KeyTable["1"]="!" -KeyTable["2"]="@" -KeyTable["3"]="#" -KeyTable["4"]="$" -KeyTable["5"]="%" -KeyTable["6"]="^" -KeyTable["7"]="&" -KeyTable["8"]="*" -KeyTable["9"]="(" -KeyTable["0"]=")" - ---LengthsTable= {} - ---for k,v in pairs(KeyTable) do --- LengthsTable[v]= gui.text(0,0,v) ---end - - -local fc, lastfc= 0, 0 ---***************************************************************************** -local function UpdateFC() lastfc= fc; fc= movie.framecount() end ---***************************************************************************** --- Quick function. I just want it to make use of movie.framecount convenient. - - ---***************************************************************************** -local function GetSortedSubs() ---***************************************************************************** --- Returns a sorted array of frame numbers for every subtitle - - local ReturnTbl= {} - local count= 0 - for frame,text in pairs(WordyWords) do - count= count+1 - ReturnTbl[count]= frame - end - table.sort(ReturnTbl) - return ReturnTbl -end - - - ---***************************************************************************** -local function FixSubs() ---***************************************************************************** --- Plants current subtitle into an array and fetches a new one. --- Should be called every time the frame count changes. Every. Single. Time. --- Can be called when the frame hasn't changed yet, if you need to. - - UpdateFC() - - if CurrentStr == "" then - WordyWords[lastfc]= nil - else - WordyWords[lastfc]= CurrentStr - end - - CurrentStr= WordyWords[fc] - if not CurrentStr then CurrentStr= "" end -end - -local LastSubfc= 0 -local LastSub= "" ---***************************************************************************** -local function GhostifySubs() ---***************************************************************************** --- Displays subtitles. Needs a little support from emu.registerbefore to know --- how to see an old subtitle after you decide to erase a new one. - - if CurrentStr ~= "" then - gui.text( 3, 9,CurrentStr) - elseif (fc < LastSubfc+300) and (fc > LastSubfc) then - gui.opacity(.5) - gui.text( 3, 9,LastSub) - end - gui.pixel(0,0,0) - gui.opacity(1) -end - - ---***************************************************************************** -local function SaveToFm2() ---***************************************************************************** --- Saves to a copy of the currently playing .fm2. It will append _S to the new --- filename, so run MySweetMovie.fm2, this script makes MySweetMovie_S.fm2 --- By the way, this script tells FCEUX to stop "owning" the file as a way to --- guarantee that this script can access it without interference. - - FixSubs() - - if not movie.active() then - print("Error: No movie!") - return false - end - - local OurMovie= movie.name() - - if string.match(OurMovie,".zip|") then - print("Error: File inside a zip!") - return false - end - - movie.close() - local MyFile, err= io.open(OurMovie,"r") - if not MyFile then - print("Error: Unable to open file for some strange reason.") - print(err) - return false - end - - local MovieData= MyFile:read("*a") - MyFile:close() - - local PreSub= string.find(MovieData,"\nsubtitle",1,true) - local PreData= string.find(MovieData,"\n|%d|") --- local RemovedSubs= nil - if PreSub then --- RemovedSubs= string.sub(MovieData,PreSub,PreData-1) - MovieData= (string.sub(MovieData,1,PreSub-1) - .. string.sub(MovieData,PreData)) - PreData= PreSub - end - - local S= GetSortedSubs() - local Write= "" - for i= 1, #S do - Write= Write .. "subtitle " .. S[i] .. " ".. WordyWords[S[i]] .. "\n" - end - - OurMovie= string.sub(OurMovie,1,-5) .. "_S" .. string.sub(OurMovie,-4) - - MyFile= io.open(OurMovie,"w") - MyFile:write(string.sub(MovieData,1,PreData) - .. Write - .. string.sub(MovieData,PreData+1)) - MyFile:close() - --- print(RemovedSubs) - print("Success") - return true -end - - ---***************************************************************************** -local function SaveToTxt() ---***************************************************************************** - FixSubs() - local OutFile, Err= io.open(SaveToThisFile,"w") - if not OutFile then - print("File write fail") - print(Err) - return false - end - local Subs= GetSortedSubs() - for i= 1, #Subs do - OutFile:write("subtitle ".. Subs[i] .." ".. WordyWords[Subs[i]] .."\n") - end - OutFile:close() - print("Saved",#Subs,"lines to",SaveToThisFile) - - return true -end - - - ---***************************************************************************** -local KeyFunctions= {} ---***************************************************************************** --- Greatly simplifies KeyReader for me. Also, faster processing should the list --- get pretty large. --- Various odds and ends that I want done shall be done here. - -function KeyFunctions._DelChar() --Remove a single character - if CurrentStr ~= "" then - CurrentStr= string.sub(CurrentStr,1,-2) - end -end -KeyFunctions[DelChar]= KeyFunctions._DelChar - - -function KeyFunctions._DelSub() --Remove the whole subtitle - CurrentStr= "" -end -KeyFunctions[DelSub]= KeyFunctions._DelSub - - -function KeyFunctions._ShoLine() --Dump the currently displayed line - print("subtitle",fc,CurrentStr) -end -KeyFunctions[ShoLine]= KeyFunctions._ShoLine - - -function KeyFunctions._SubCnt() --Count subtitles - local fr= GetSortedSubs() - print("Subtitle count:",#fr) -end -KeyFunctions[SubCnt]= KeyFunctions._SubCnt - - -function KeyFunctions._PntAll() --Dump all subtitles - FixSubs() - print("===========================") - local S= GetSortedSubs() - for i= 1, #S do - print("subtitle",S[i],WordyWords[S[i]]) - end -end -KeyFunctions[PntAll]= KeyFunctions._PntAll - - -function KeyFunctions._SaveTxt() --Save to a file - SaveToTxt() -end -KeyFunctions[SaveTxt]= KeyFunctions._SaveTxt - - -function KeyFunctions._T_AutoS() --Toggle Save-On-Exit - SaveOnExit= not SaveOnExit - if SaveOnExit then print("SaveOnExit activated!") - else print("Removed SaveOnExit.") end -end -KeyFunctions[T_AutoS]= KeyFunctions._T_AutoS - -local AmIClicked= false -function KeyFunctions._SvToMov() --Saves directly to the movie itself - if not movie.active() then - print("No movie detected. Doing nothing...") - return - end - - if not AmIClicked then - AmIClicked= true - print("Movie detected. Hit",SvToMov,"again to stop movie and", - "save subtitles directly into movie! Advance a frame to cancel.") - else - SaveToFm2() - end -end -KeyFunctions[SvToMov]= KeyFunctions._SvToMov - - -local lastkeys= input.get() ---***************************************************************************** -local function KeyReader() ---***************************************************************************** - if fc ~= movie.framecount() then --Egad, panic! New frame! Handle it!! - FixSubs() -- Whew. Problem solved. - - else -- Oh? Don't panic then - - local keys= input.get() - for k,v in pairs(keys) do - if not lastkeys[k] then - if k == BypassFrameAdvanceKey then - --... It's a bypass. Don't process. - elseif KeyFunctions[k] then - KeyFunctions[k]() - else - local ThisKey= k - if keys.shift then ThisKey= string.upper(ThisKey) - else ThisKey= string.lower(ThisKey) end - if KeyTable[ThisKey] then - CurrentStr= CurrentStr .. KeyTable[ThisKey] - end - end - end - end - GhostifySubs() - - lastkeys= keys - - end -- New frame test - -end - ---***************************************************************************** -local function Ex() ---***************************************************************************** - if SaveOnExit then - if not SaveToTxt() then - print("Dumping subtitles in message box instead!") - print("===========================") - local S= GetSortedSubs() - for i= 1, #fr do - print("subtitle",S[i],WordyWords[S[i]]) - end - end - end -end - ---***************************************************************************** -local function Bfr() ---***************************************************************************** - AmIClicked= false - - if CurrentStr ~= "" then - LastSubfc= fc - LastSub= CurrentStr - end - - FixSubs() -end - -gui.register(KeyReader) -emu.registerbefore(Bfr) -emu.registerexit(Ex) \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/TeenageMutantNinjaTurtles.lua b/branches/sdl2/output/luaScripts/TeenageMutantNinjaTurtles.lua deleted file mode 100644 index 56463b78..00000000 --- a/branches/sdl2/output/luaScripts/TeenageMutantNinjaTurtles.lua +++ /dev/null @@ -1,52 +0,0 @@ --- Teenage Mutant Ninja Turtles (U)[!].rom --- Written by QFox --- 31 july 2008 --- Displays Hitboxes, Enemy HP, and various stats on screen - -local function box(x1,y1,x2,y2,color) - -- gui.text(50,50,x1..","..y1.." "..x2..","..y2); - if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 241 and y2 > 0 and y2 < 241) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; -local function text(x,y,str) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.text(x,y,str); - end; -end; -local function pixel(x,y,color) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.drawpixel(x,y,color); - end; -end; - -while (true) do - local stuff = 0x023C; -- start of tile data, 4 bytes each, y, ?, ?, x. every tile appears to be 10x10px - -- print boxes for all the tiles - -- invalid tiles are automatically hidden because their x/y coords are out of range, i guess - for i=0,0x30 do - x = memory.readbyte(stuff+3+(i*4)); - y = memory.readbyte(stuff+(i*4)); - box(x,y+1,x+7,y+16,"red"); - end; - - -- print player's health - local x = memory.readbyte(0x0480); - local y = memory.readbyte(0x0460); - local hp = memory.readbyte(0x0077+memory.readbyte(0x0067)); -- get health of current char, there are 4 chars and 4 healths - text(x-10,y-20,hp); - - -- print enemy hp - local startx = 0x0484; - local starty = 0x0464; - local starthp = 0x0564; - for i=0,11 do - x = memory.readbyte(startx+i); - y = memory.readbyte(starty+i); - hp = memory.readbyte(starthp+i); - --box(x-5,y-5,x+5,y+5,"green"); -- their 'center', or whatever it is. - text(x-5,y-20,hp); - end; - - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/UsingLuaBot-Documentation.txt b/branches/sdl2/output/luaScripts/UsingLuaBot-Documentation.txt deleted file mode 100644 index ed39731a..00000000 --- a/branches/sdl2/output/luaScripts/UsingLuaBot-Documentation.txt +++ /dev/null @@ -1,140 +0,0 @@ -LuaBot -Documentation -Written by Qfox - - -LuaBot is a trial and error script that exhausts the input-search-space by simply trying to push buttons. - -You can program it to limit this searchspace, as it can become exponentially large. Just do the math. You can press eight possible buttons at any frame. That makes up for 8! or 8*7*6*5*4*3*2*1 possible combinations for one single frame. There are 60 frames in one second, that's 60 to the power of (8!). - -Anyways, the bot has two parts. The frontend, which we'll call BeeBee, and the Lua part, which we call LuaBot. - -You start the bot by openening the luabot_front.lua script file. Make sure the luabot_backend.lua file is in the same directory. - -BeeBee - -BeeBee (who received it's name from BasicBot, its predecessor) just writes it's contents into the LuaBot framework and produces a big Lua script for you. -All you need to do is enter Lua code for the specific functions and the code will generate the script. - -You can also save and load the contents of the front-end. That way you can easily manage your bot scripts, without actually having to look into the LuaBot code. - -BeeBee is only a pasting mechanism. It does not compile Lua or warn for errors. - -LuaBot - -LuaBot is a generic trial-and-error script that serves as a bot framework. It will set inputs as you program them for a number of frames (called an attempt). When the isAttemptEnd() says the attempt ends, a new attempt is started. All the attempts fall under one segment. At the end of a segment (denoted by the isSegmentEnd() function), the best attempt is kept (judged by the score and tie functions) and the next segment is started. The bot is capable of rolling back if a segment runs into a dead end. This allows you to backtrack and restart a previous segment. - -The bot evaluates a true or false by checking to see whether the return value of a function is bigger then a certain value. It does this for EVERY function that returns something and every function that returns something must return a number (or Lua _will_ complain). For absolute true or false you can return "yes" and "no", "maxvalue" and "minvalue" or "pressed" and "released". Read variable info for more information. - -The script takes a number of variables and functions into account. Some variables become important to prevent desyncing over segments. - -- maxvalue -The maximum value (exclusive) of the random evaluation. If a value is higher than rand(minvalue, maxvalue), it evaluates as true, else false. By default this is set to 100. - -- minvalue -The lowest value (inclusive) of the random evaluation. If a value is lower than rand(minvalue, maxvalue), it evaluates to false, else true. By default this is set to 0. - -- yes / no -- pressed / released -These map to the minvalue/maxvalue. - -- loopcounter -The number of times a frameadvance has been called by the main botloop. - -- key1 key2 key3 key4 -The input table of players 1-4. The keys are: A B up down left right select start. Set any to 1 if you want them to be set and to nil if you don't want them set. -Note that these get cleared right before onInputStart is called. This variable is saved in a pseudo-movie table if the attempt is better then the previous one and used for playback when moving to the next segment. - -- lastkey1 lastkey2 lastkey3 lastkey4 -The inputs that were given to FCEU on the PREVIOUS frame. This holds for segments as well (at the beginning of a new segment, the lastkeys of the previous segment are set). This also goes for the start. If you use key1-4 in onStart, the first segment will have those keys as lastkey. - -- frame -The number of frames of the current attempt. Starts at 1. - -- attempt -The number of attempts in the current segment. Starts at 1. - -- segment -The segment the bot is currently running. Note that rolledback segments are deducted from this number. - -- okattempts -The number of attempts that have been deemed ok. This is a statistical variable. It might tell you how well your bot is doing (combined with the number of failed attempts). - -- failattempts -The number of attempts in the current segment that have been deemed bad. This is a statistical variable. It might tell you how well your bot is doing (combined with the number of approved attempts). - -- segments -This is the big table that holds everything together. Don't mess with it. - -- maxframes -You can set maxframes and check it in the isAttemptEnd function to simply limit a attempt by this many frames. You can also just ignore this and do something else instead. - -- maxattempts -Same as maxframes, except for attempts in a segment. - -- maxsegments -Same as maxframes, except for segments in a run. - -- playingbest -Will be set to true when the bot is playing back it's best attempt to advance to the next segment. Not really used by other functions. - -- keyrecording1-4 -A simple table with the pressed keys for playback. - -- X Y Z P Q -Some "static" variables. These allow you to easily set them onStart and use them in various functions to return the same number. Like a global variable. The P and Q numbers used to denote a random number between 0 and P or Q, but they don't right now. - -- vars -This is your variable table. It's contents is saved at the end of an attempt and will be loaded at the beginning of a segment. On rollback, this table is also kept. Put any variable you want to keep accross segments in this table. - - -Ok. That's it for the variables. Now for functions. There are basically three types of functions. The functions that determine whether a button is pressed (8 for each player), to determine whether an attempt/segment/run has ended or was ok and functions for certain events. This number is not evaluated by the random-eval function. - -- getScore -This returns how "well" the current attempt is. At the end of a segment, the best scoring good attempt will be used to continue to the next segment. In case of a tie, see the tie functions. This number is not evaluated by the random-eval function! - -- getTie1-4 -If the score ends in a tie, that is, two attempts score equally well (have an equal number of points for instance), you can use these functions to break that tie. Like, which attempt has the most health or is the fastest or whatever. This number is not evaluated by the random-eval function! - -- isRunEnd -Return whether the bot should stop running. If the returned number is bigger then the random number rand(minvalue-maxvalue), the bot will stop. - -- mustRollBack -Returns whether the bot should rollback the current attempt. In such case, the previous segment is loaded and the current segment is completely discarded. If the returned number is bigger then the random number rand(minvalue-maxvalue), the segment will rollback one segment. - -- isSegmentEnd -If the returned number is bigger then the random number rand(minvalue-maxvalue), the bot will stop the current segment, play back the best recorded attempt and start a new segment. Mostly done when a certain number of attempts is reached, but possibly you know when have the best possible attempt and can move on. - -- isAttemptEnd -If the returned number is bigger then the random number rand(minvalue-maxvalue), the attempt will stop and a new attempt will be started. Some examples when this function should return yes is when you reached a certain goal, a number of frames or when you died (in which case the bot should try again :). - -- isAttemptOk -If the returned number is bigger then the random number rand(minvalue-maxvalue), the current attempt (which has just ended) is deemed ok. Only attempts that are deemed ok are up for being saved. For instance, when the player died in the current attempt, you should return no. - -- pressKeyX (pressKeyA1, pressKeyStart4, etc...) -These functions determine whether a button should be pressed in the next frame. If the returned number is bigger then the random number rand(minvalue-maxvalue), the button is pressed, otherwise it is not. To absolutely press a button, simply return yes or no. To use some odds, return a number between minvalue and maxvalue. For instance, using the default settings, if you return 50, there is a 50% chance the button will be pressed. - -- onStart -Maybe a little misleading, but the onStart function is called BEFORE the main botloop starts. You can do some non-generic startup stuff here like press start at the title screen and get the game started. Returns nothing. - -- onFinish -The opposite to onStart, this function is called when the main botloop exits. You can cleanup, or write stuff or whatever. - -- onSegmentStart -When a new segment is started, this is called. After initializing variables and such, but before onAttemptStart is called. Returns nothing. - -- onSegmentEnd -When isSegmentEnd evaluates to true, this function is called. Returns nothing. - -- onAttemptStart -Called at the start of a new attempt, after onSegmentStart (in case of a new segment) but before onInputStart. Returns nothing. - -- onAttemptEnd(wasOk) -Called at the end of an attempt. The only function to have a parameter (note: case sensitive). The parameter wasOk will return (boolean) whether isAttemptOk evaluated to true or false. Returns nothing. - -- onInputStart -In a frame, this is the first place where the key1-4 variables are cleared. This is called before all the input (pressKeyX) functions are called. Returns nothing. - -- onInputEnd -This is called immediately after the input (pressKeyX) functions have been called. Returns nothing. - diff --git a/branches/sdl2/output/luaScripts/UsingLuaScripting-Documentation.txt b/branches/sdl2/output/luaScripts/UsingLuaScripting-Documentation.txt deleted file mode 100644 index 4ea1e75f..00000000 --- a/branches/sdl2/output/luaScripts/UsingLuaScripting-Documentation.txt +++ /dev/null @@ -1,203 +0,0 @@ -Learning to use Lua Sctripting for FCEUX -Written by QFox - -This is a document designed primarily to help someone use FCEUX specific commands with LUA, and tends to assume that you have some programming experience. It is best used for basic coding reference, and it is not comprehensive, in that there are a large number of things that LUA can do which aren't mentioned here. For a broad overview of the LUA language, check here: - -The Manual: (Good for learning LUA's basic capabilities, but you don't need to learn it all before using LUA) -http://www.lua.org/manual/ - -Programming in LUA: (Good for finding exact coding syntax, such as for LUA arrays, or to get coding examples) -http://www.lua.org/pil/ - -Other .lua files: -Don't be afraid to copy, look through, and break existing .lua scripts in order to make your own. Taking a piece of other people's code and learning how it works, modifying it, or outright duplicating it for your own project generally isn't frowned upon, as long as you know that what you release may eventually be used by others for their projects. - -Windows users - see also the Lua Scripting chapter for the FCEUX sHelp manual (fceux.chm) - -Ok. Lua. Let's see. - -Lua is a scripting language. It is used in games like Farcry and World of Warcraft (and many other games and applications!). Even though you can find all kinds of tutorials online, let me help you with the basics. - -I will asume you are at least somewhat familiar with the basics of programming. So basic stuff like arrays, variables, strings, loops and if-then-else and branching are not explained here. - -A hello world EmuLua program looks like this: - -while (true) do - gui.text(50,50,"Hello world!"); - FCEU.frameadvance(); -end; - -When you load the script, the emulator will sort of go into pause mode and hand controls over to Lua (you!). Hence you are responsible for frameadvancing the emulator. -IF YOU DO NOT CALL FCEU.frameadvance AT THE CYCLE OF THE MAIN LOOP YOU WILL FREEZE THE EMULATOR! There. You have been warned. Don't worry though, you'll make this mistake at least once. Just force-quit the application and try again :) - -Now then. Just like any other language, Lua has a few quirks you should be aware of. - -First of all, if's require a then and end. After a couple of days intensive Lua coding, I still make this mistake myself, but the Lua interpreter will prompt you of such errors on load, so don't worry too much about it. So: - -if (something) then - dostuff -end; - -Lua uses nil instead of null. - -There are only two values that evaluate to "false", these are "nil" and "false". ANYTHING else will evaluate to true, even 0 or the empty string. - -Comments are denoted by two consecutive dashes; --. Anything after it on the same line is a comment and ignored by Lua. There is no /* */ type of commenting in Lua. - -Variables have a local and global scope. You explicitly make a variable local by declaring it with the "local" keyword. - -somethingglobal; -- accessible by any function or flow -local something; -- only known to the same or deeper scope as where it was declared - -Note that variables declared in for loops (see below) are always considered local. - -Arrays are called tables in Lua. To be more precise, Lua uses associative arrays. - -Do not rely on the table.length() when your table can contain nil values, this function stops when it encounters a nil value, thus possibly cutting your table short. - -One experienced programmers will have to get used to is the table offset; tables start at index 1, not 0. That's just the way it is, deal with it. - -There are a few ways to create a table: - -local tbl1 = {}; -- empty table -local tbl2 = {"a","b","c","d"}; -- table with 5 strings -local tbl3 = {a=1,b=2,c=3}; -- associative table with 3 numbers -local tbl4 = {"a",b=2,c="x","d"=5}; -- associative table with mixed content - -Note that you can mix up the data in one table, as shown by tbl4. - -You can refer to table values in a few equivalent manners, using the examples above: - -tbl1[1] -- = nil because tbl1 is empty -tbl2[2] -- = "b" -tbl3["a"] -- = 1 -tbl4.b -- = 2 -tbl2.3 -- = "c" - -When the argument of a function is just a table, the parantheses "()" are optional. So for instance: - -processTable({a=2,b=3}); - -Is equivalent to - -processTable{a=2,b=3}; - -Another notation that's equivalent is - -filehandle.read(filehandle, 5); -filehandle:read(5); - -When using the colon notation ":" Lua will call the function adding the self-reference to the front of the parameterstack. - -Functions behave like objects and are declared in the follow manner: - -function doSomething(somevalue, anothervalue) - dostuffhere -end; - -So no curly braces "{}" ! - -Some flow control: - -for i=0,15 do - -- do stuff here, i runs from 0 to 15 (inclusive!) -end; - -for key,value in pairs(table) do - -- do stuff here. pairs will iterate through the table, splitting the keys and values -end; - -while (somethingistrue) do - -end; - -if (somethingistrue) then - -end; - -if (somethingistrue) then - -else - -end; - -if (somethingistrue) then - -elseif (somethingelseistrue) then - -end; - -For comparison, you only have to remember that the exclamationmark is not used. Not equal "!=" is written like tilde-equals "~=" and if (!something) then ... is written with "not " in front of it; if (not something) then... - -For easy reference to the standard libraries look on the bottom half of this page: http://www.lua.org/manual/5.1/ - - -Now then, let's get to the emulator specifics! - -To load a Lua script in FCEU first load a rom (Lua can only do things after each frame cycle so load a rom first). Go to file, at the bottom choose Run Lua Script and select and load the file. - -When Lua starts, the emulator pauses and hands control over to Lua. Lua (that's you!) decides when the next frame is processed. That's why it's very common to write an endless while loop, exiting the main loop of a script will exit the script and hand control back to the emulator. This also happens when a script unexpectingly crashes. - -A bare script looks like this: - -while (true) do - FCEU.frameadvance(); -end; - -And is about equal to not running Lua at all. The frameadvance function is the same called internally, so no loss of speed there! - -Bitwise operators: - -Lua does not have bitwise operators, so we supply some for you. These are common bitwise operators, nothing fancy. - -AND(a,b); -OR(a,b); -XOR(a,b); -BIT(n); -- returns a number with only bit n set (1) - -The emulator specific Lua is equal to the one of snes9x, with some platform specific changes (few buttons, for instance). -You can find the reference here: http://dehacked.2y.net/snes9x-lua.html -The following is a quick reference, you can go to the snes9x reference for more details. - -To paint stuff on screen, use the gui table. This contains a few predefined functions to manipulate the main window. For any coordinate, 0,0 is the top-left pixel of the window. You have to prevent out-of-bound errors yourself for now. If a color can be passed on, it is a string. HTML-syntax is supported ("#34053D"), as well as a FEW colors ("red", "green", "blue" ...). - -gui.text(x, y, str); -- Print a line to the window, you can use \n for a return but it will only work once -gui.drawpixel(x, y, color); -- plot a pixel at the given coordinate -gui.drawline(x1, y1, x2, y2, color); -- plot a line from x1,y1 to x2,y2 -gui.drawbox(x1, y1, x2, y2, color); -- draw a square from x1,y1 to x2,y2 -gui.popup(str); -- pops up a messagebox informing the user of something. Real handy when debugging! -gui.getpixel(x,y); -- return the values of the pixel at given position. Returns three numbers of the emulator image before paiting is applied. -gui.gdscreenshot(); -- Takes a screen shot of the image and returns it in the form of a string which can be imported by the gd library using the gd.createFromGdStr() function -(for more gd functions see DeHackED's reference: http://dehacked.2y.net/snes9x-lua.html) - -PAINTING IS ALWAYS ONE FRAME BEHIND! This is because the painting is done at the creation of the next frame, not while Lua is running. - -Emulator control: - -FCEU.frameadvance(); -- advances emulation ONE frame -FCEU.pause(); -- same as pressing the pause button -FCEU.speedmode(strMode); -- Supported are "normal","turbo","nothrottle","maximum". But know that except for "normal", all other modes will run as "turbo" for now. -FCEU.wait(); -- skips the emulation of the next frame, in case your script needs to wait for something - -Memory control: - -memory.readbyte(adr); -- read one byte from given address and return it. Besides decimal values Lua also allows the hex notation 0x00FA. In FCEUX reading is done BEFORE the cheats are applied! -memory.writebyte(adr, value); -- write one byte to the RAM of the NES. writing is done AFTER the hexeditor receives its values, so if you are freezing an address by Lua, it will not show in the hex editor (but it will in the game :) -memory.readbytesigned(adr); -- same as readbyte, except this returns a signed value, rather then an unsigned value. -memory.register(adr, function); -- binds a function to an address. The function will be called when an address changes. NOTE THAT THIS IS EXPENSIVE (eg.: slow)! Only one function allowed per address. - -Input control: - -You can read and write input by using the joypad table. A input table has the following (case sensitive) keys, where nil denotes they are not to be pressed: up down left right start select A B - -joypad.read(playern); -- get the input table for the player who's input you want to read (a number!) -joypad.write(playern, inputtable); -- set the input for player n. Note that this will overwrite any input from the user, and only when this is used. - -Savestates: - -You can load and save to the predefined savestates 1 ... 9 or create new "anonymous" savestates. You must first create a savestate object, which is your handle to a savestate. Then you can pass this handle on to savestate.load or save to do so. - -savestate.create(n); -- n is optional. When supplied, it will create a savestate for slot n, otherwise a new (anonymous) savestate object is created. Note that this does not yet save or load anything! -savestate.load(state); -- load the given savestate -savestate.save(state); -- save the given savestate - diff --git a/branches/sdl2/output/luaScripts/UsingLuaScripting-ListofFunctions.txt b/branches/sdl2/output/luaScripts/UsingLuaScripting-ListofFunctions.txt deleted file mode 100644 index 5583649b..00000000 --- a/branches/sdl2/output/luaScripts/UsingLuaScripting-ListofFunctions.txt +++ /dev/null @@ -1,316 +0,0 @@ -Library Listing of FCEUX Lua Functions -Written by adelikat/QFox - -FCEU library - -FCEU.poweron() - -Executes a power cycle. - -FCEU.softreset() - -Executes a (soft) reset. - -FCEU.speedmode(string mode) - -Set the emulator to given speed. The mode argument can be one of these: - - "normal" - - "nothrottle" (same as turbo on fceux) - - "turbo" - - "maximum" - -FCEU.frameadvance() - -Advance the emulator by one frame. It's like pressing the frame advance button once. - -Most scripts use this function in their main game loop to advance frames. Note that you can also register functions by various methods that run "dead", returning control to the emulator and letting the emulator advance the frame. For most people, using frame advance in an endless while loop is easier to comprehend so I suggest starting with that. This makes more sense when creating bots. Once you move to creating auxillary libraries, try the register() methods. - -FCEU.pause() - -Pauses the emulator. FCEUX will not unpause until you manually unpause it. - -FCEU.exec_count() - - - -FCEU.exec_time() - - - -FCEU.setrenderplanes(bool sprites, bool background) - -Toggles the drawing of the sprites and background planes. Set to false or nil to disable a pane, anything else will draw them. - -FCEU.message(string message) - -Displays given message on screen in the standard messages position. Use gui.text() when you need to position text. - -int FCEU.lagcount() - -Return the number of lag frames encountered. Lag frames are frames where the game did not poll for input because it missed the vblank. This happens when it has to compute too much within the frame boundary. This returns the number indicated on the lag counter. - -bool FCEU.lagged() - -Returns true if currently in a lagframe, false otherwise. - -bool FCEU.getreadonly() - -Returns whether the emulator is in read-only state. - -While this variable only applies to movies, it is stored as a global variable and can be modified even without a movie loaded. Hence, it is in the FCEU library rather than the movie library. - -FCEU.setreadonly(bool state) - -Sets the read-only status to read-only if argument is true and read+write if false. -Note: This might result in an error if the medium of the movie file is not writeable (such as in an archive file). - -While this variable only applies to movies, it is stored as a global variable and can be modified even without a movie loaded. Hence, it is in the FCEU library rather than the movie library. - - -ROM Library - -rom.readbyte(int address) - -Get an unsigned byte from the actual ROM file at the given address. - -This includes the header! It's the same as opening the file in a hex-editor. - -rom.readbytesigned(int address) - -Get a signed byte from the actual ROM faile at the given address. Returns a byte that is signed. - -This includes the header! It's the same as opening the file in a hex-editor. - - -Memory Library - -memory.readbyte(int address) - -Get an unsigned byte from the RAM at the given address. Returns a byte regardless of emulator. The byte will always be positive. - -memory.readbyterange(int address, int length) - -Get a length bytes starting at the given address and return it as a string. Convert to table to access the individual bytes. - -memory.readbytesigned(int address) - -Get a signed byte from the RAM at the given address. Returns a byte regardless of emulator. The most significant bit will serve as the sign. - -memory.writebyte(int address, int value) - -Write the value to the RAM at the given address. The value is modded with 256 before writing (so writing 257 will actually write 1). Negative values allowed. - -memory.register(int address, function func) - -Register an event listener to the given address. The function is called whenever write occurs to this address. One function per address. Can be triggered mid-frame. Set to nil to remove listener. Given function may not call frame advance or any of the savestate functions. Joypad reading/writing is undefined (so don't). - -Note: this is slow! - - -Joypad Library - -table joypad.read(int player) - -Returns a table containing the buttons pressed by the given player. This takes keyboard inputs, not Lua. The table keys look like this (case sensitive): - -up, down, left, right, A, B, start, select - -Where a Lua truthvalue true means that the button is set, false means the button is unset. Note that only "false" and "nil" are considered a false value by Lua. Anything else is true, even the number 0. - -joypad.set(int player, table input) - -Set the inputs for the given player. Table keys look like this (case sensitive): - -up, down, left, right, A, B, start, select - -There are 3 possible values, true, false, and nil. True will turn the button on, false will turn it off. Nil will leave it unchanged (allowing the user to control it). - -table joypad.get() - -A alias of joypad.read(). Left in for backwards compatibility with older versions of FCEU/FCEUX. - -joypad.write() - -A alias of joypad.set(). Left in for backwards compatibility with older versions of FCEU/FCEUX. - - -Zapper Library - -table zapper.read() - -Returns the mouse data (which is used to generate zapper input, as well as the arkanoid paddle). - -The return table consists of 3 values: xmouse, ymouse, and click. xmouse and ymouse are the x,y coordinates of the cursor in terms of pixels. click represents the mouse click. 0 = no click, 1 = left cick, 2 = right click. - -Currently, zapper data is ignored while a movie is playing. - -Note: The right-click isn't used in zapper data -Note: The zapper is always controller 2 on the NES so there is no player argument to this function. - - -Input Library - -table input.get() - -Reads input from keyboard and mouse. Returns pressed keys and the position of mouse in pixels on game screen. The function returns a table with at least two properties; table.xmouse and table.ymouse. Additionally any of these keys will be set to true if they were held at the time of executing this function: -leftclick, rightclick, middleclick, capslock, numlock, scrolllock, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, backspace, tab, enter, shift, control, alt, pause, escape, space, pageup, pagedown, end, home, left, up, right, down, numpad0, numpad1, numpad2, numpad3, numpad4, numpad5, numpad6, numpad7, numpad8, numpad9, numpad*, insert, delete, numpad+, numpad-, numpad., numpad/, semicolon, plus, minus, comma, period, slash, backslash, tilde, quote, leftbracket, rightbracket. - -Savestate Library - -object savestate.create(int slot = nil) - -Create a new savestate object. Optionally you can save the current state to one of the predefined slots (0...9), otherwise you'll create an "anonymous" savestate. -Note that this does not actually save the current state! You need to create this value and pass it on to the load and save functions in order to save it. - -Anonymous savestates are temporary, memory only states. You can make them persistent by calling memory.persistent(state). Persistent anonymous states are deleted from disk once the script exits. - -savestate.save(object savestate) - -Save the current state object to the given savestate. The argument is the result of savestate.create(). You can load this state back up by calling savestate.load(savestate) on the same object. - -savestate.load(object savestate) - -Load the the given state. The argument is the result of savestate.create() and has been passed to savestate.save() at least once. - -If this savestate is not persistent and not one of the predefined states, the state will be deleted after loading. - -savestate.persist(object savestate) - -Set the given savestate to be persistent. It will not be deleted when you load this state but at the exit of this script instead, unless it's one of the predefined states. If it is one of the predefined savestates it will be saved as a file on disk. - - -Movie Library - -bool movie.active() - -Returns true if a movie is currently loaded and false otherwise. (This should be used to guard against Lua errors when attempting to retrieve movie information). - -int movie.framecount() - -Returns the framecount value. The frame counter runs without a movie running so this always returns a value. - -string movie.mode() - -Returns the current state of movie playback. Returns one of the following: - -- "record" -- "playback" -- nil - -movie.rerecordcounting(bool counting) - -Turn the rerecord counter on or off. Allows you to do some brute forcing without inflating the rerecord count. - -movie.stop() - -Stops movie playback. If no movie is loaded, it throws a Lua error. - -int movie.length() - -Returns the total number of frames of the current movie. Throws a Lua error if no movie is loaded. - -string movie.getname() - -Returns the filename of the current movie. Throws a Lua error if no movie is loaded. - -movie.rerecordcount() - -Returns the rerecord count of the current movie. Throws a Lua error if no movie is loaded. - -movie.playbeginning() - -Performs the Play from Beginning function. Movie mode is switched to read-only and the movie loaded will begin playback from frame 1. - -If no movie is loaded, no error is thrown and no message appears on screen. - - -GUI Library - -gui.drawpixel(int x, int y, type color) - -Draw one pixel of a given color at the given position on the screen. See drawing notes and color notes at the bottom of the page. - -gui.drawline(int x1, int y1, int x2, int y2, type color) - -Draws a line between the two points. See also drawing notes and color notes at the bottom of the page. - -gui.drawbox(int x1, int y1, int x2, int y2, type color) - -Draw a box with the two given opposite corners. -Also see drawing notes and color notes. - -gui.text(int x, int y, string str) - -Draws a given string at the given position. - -string gui.gdscreenshot() - -Takes a screen shot of the image and returns it in the form of a string which can be imported by the gd library using the gd.createFromGdStr() function. - -This function is provided so as to allow FCEUX to not carry a copy of the gd library itself. If you want raw RGB32 access, skip the first 11 bytes (header) and then read pixels as Alpha (always 0), Red, Green, Blue, left to right then top to bottom, range is 0-255 for all colors. - -Warning: Storing screen shots in memory is not recommended. Memory usage will blow up pretty quick. One screen shot string eats around 230 KB of RAM. - -gui.gdoverlay(int x = 0, int y = 0, string dgimage) - -Overlay the given image on the emulator. Transparency is absolute (any pixel not 100% transparent is completely opaque). The image must be gd file format version 1, true color. Image will be clipped to fit. - -gui.transparency(int strength) - -Set the transparency level for subsequent painting (including gdoverlay). Does not stack. -Values range from 0 to 4. Where 0 means completely opaque and 4 means completely transparent. - -function gui.register(function func) - -Register a function to be called between a frame being prepared for displaying on your screen and it actually happening. Used when that 1 frame delay for rendering is not acceptable. - -string gui.popup(string message, string type = "ok") - -Shows a popup. Default type is "ok". Can be one of these: - -- "ok" - "yesno" - "yesnocancel" -Returns "yes", "no" or "cancel" indicating the button clicked. - -Linux users might want to install xmessage to perform the work. Otherwise the dialog will appear on the shell and that's less noticeable. - - -Bitwise Operations - -int AND(int n1, int n2, ..., int nn) - -Binary logical AND of all the given integers. This function compensates for Lua's lack of it. - -int OR(int n1, int n2, ..., int nn) - -Binary logical OR of all the given integers. This function compensates for Lua's lack of it. - -int XOR(int n1, int n2, ..., int nn) - -Binary logical XOR of all the given integers. This function compensates for Lua's lack of it. - -int BIT(int n1, int n2, ..., int nn) - -Returns an integer with the given bits turned on. Parameters should be smaller than 31. - - -Appendix - -On drawing - -A general warning about drawing is that it is always one frame behind unless you use gui.register. This is because you tell the emulator to paint something but it will actually paint it when generating the image for the next frame. So you see your painting, except it will be on the image of the next frame. You can prevent this with gui.register because it gives you a quick chance to paint before blitting. - -Dimensions & color depths you can paint in: -320x239, 8bit color (confirm?) - -On colors - -Colors can be of a few types. -Int: use the a formula to compose the color as a number (depends on color depth) -String: Can either be a HTML color or simple colors. -HTML string: "#rrggbb" ("#228844") or #rrggbbaa if alpha is supported. -Simple colors: "clear", "red", "green", "blue", "white", "black", "gray", "grey", "orange", "yellow", "green", "teal", "cyan", "purple", "magenta". - -For transparancy use "clear", this is actually int 1. - - - diff --git a/branches/sdl2/output/luaScripts/ZapperDisplay.lua b/branches/sdl2/output/luaScripts/ZapperDisplay.lua deleted file mode 100644 index 51bc4aab..00000000 --- a/branches/sdl2/output/luaScripts/ZapperDisplay.lua +++ /dev/null @@ -1,33 +0,0 @@ ---Zapper display ---written by adelikat ---Purpose: To show the target of the zapper on screen --- Primary use is for fullscreen where the mouse cursor is disabled - -local zap --get zapper.read() values -local color = "white" --color of outside bull's eye circles - -while true do - -zap = zapper.read() - ---Red if firing -if (zap.click == 1) then - color = "red" -else - color = "white" -end - ---gui.text(1,1,"X: " .. zap.x) ---gui.text(1,9,"Y: " .. zap.y) ---gui.text(1,17,"Click: " .. zap.fire) - ---Draw bull's eye -gui.box(zap.x-1,zap.y-1,zap.x+1,zap.y+1,"clear","red") -gui.box(zap.x-6,zap.y-6,zap.x+6,zap.y+6,"clear",color) -gui.box(zap.x-12,zap.y-12,zap.x+12,zap.y+12,"clear",color) -gui.line(zap.x-12,zap.y-12,zap.x+12,zap.y+12,color) -gui.line(zap.x+12,zap.y-12,zap.x-12,zap.y+12,color) -gui.pixel(zap.x,zap.y,"red") - -emu.frameadvance() -end \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/ZapperFun.lua b/branches/sdl2/output/luaScripts/ZapperFun.lua deleted file mode 100644 index ab3dc4ae..00000000 --- a/branches/sdl2/output/luaScripts/ZapperFun.lua +++ /dev/null @@ -1,72 +0,0 @@ --- Zapper Fun --- quick and dirty script that shows zapper position and fire button presses in FCEUX --- Written by miau --- http://morphcat.de/lua/ - -local Z_LSPAN = 20 --life span (in frames) of white box -local Z_LSPAN_CLICK = 30 --life span of red box -local Z_MAX = 60 --maximum amount of boxes on screen - -local zbuf = {} -local zindex = 1 -local timer = 0 -local lastclick = zapper.read().fire -local lastx = zapper.read().x -local lasty = zapper.read().y - -function zapper_addcoord(x,y,click) - zbuf[zindex] = {t=timer,x=x,y=y,click=click} - zindex = zindex + 1 - if(zindex>Z_MAX) then - zindex = 1 - end -end - -function box(x1,y1,x2,y2,color1,color2) - if(x1>=0 and y1>=0 and x2<=255 and y2<=255) then - gui.drawbox(x1, y1, x2, y2, color1, color2) - end -end - - - - while(true) do - local x = zapper.read().x - local y = zapper.read().y - local click = zapper.read().fire - --gui.text(0, 8, string.format("x=%d",x)); - --gui.text(0, 18, string.format("y=%d",y)); - --gui.text(0, 28, string.format("click=%d",click)); - if(click==1 and click~=lastclick) then - zapper_addcoord(x,y,1) - elseif(x~=lastx or y~=lasty) then - zapper_addcoord(x,y,0) - end - lastclick=click - lastx=x - lasty=y - box(x-3, y-3, x+3, y+3, "white", 0) - - for i=1,Z_MAX do - if(zbuf[i]) then - ltime = timer-zbuf[i].t - if(zbuf[i].click==0) then - if(ltime= maxvalue) then return true; end; - if (n > math.random(minvalue, maxvalue-1)) then return true; end; - return false; -end; - -local loopcounter = 0; -- counts the main loop -local key1 = {}; -- holds the to be pressed keys this frame for player 1 -local key2 = {}; -- holds the to be pressed keys this frame for player 2 -local key3 = {}; -- holds the to be pressed keys this frame for player 3 -local key4 = {}; -- holds the to be pressed keys this frame for player 4 -local lastkey1 = {}; -- keys pressed in previous frame for player 1 -local lastkey2 = {}; -- keys pressed in previous frame for player 2 -local lastkey3 = {}; -- keys pressed in previous frame for player 1 -local lastkey4 = {}; -- keys pressed in previous frame for player 2 -local frame = 0; -- number of frames (current value is current frame count, incremented at the start of a new frame) -local attempt = 1; -- number of attempts (current value is current attempt, incremented after the end of an attempt) -local segment = 1; -- number of segments (current value is current segment, incremented after the end of a segment) -local okattempts = 0; -- number of successfull attempts (including rollback) -local failattempts = 0; -- number of failed attempts (including rollback) - -local segments = {}; -- table that holds every segment, each segment is another table that consists of the score, ties, savestate (begin of segment), lastkeys, keys pressed, etc. -segments[1] = {}; -- initialize the first segment, we initialize the savestate right after the before code has ran - --- these dont have to be used, but it makes it easier to control here -local maxframes = 400; -local maxattempts = 200; -local maxsegments = 100; - -local playingbest = false; -- when going to the next segment, we need to play the best segment to record, this indicates when we're doing so -local keyrecording1 = {}; -- every key pressed for player 1 is put in here -local keyrecording2 = {}; -- every key pressed for player 2 is put in here -local keyrecording3 = {}; -- every key pressed for player 3 is put in here -local keyrecording4 = {}; -- every key pressed for player 4 is put in here - --- some constants/macro's/whatever to make source easier to read -local press = maxvalue; -local release = minvalue; -local yes = maxvalue; -local maybe = maxvalue/2; -- 50% -local no = minvalue; - --- static constants, will be used by the frontend later -local X = 95; -local Y = 30; -local Z = 0; -local P = 0; -local Q = 0; - -local vars = {}; -- variable table. each cell holds a variable. variables are remembered accross segments - --- user defined functions - -local function getScore() -- score of current attempt - local result = no; - -- SCORE - return result; -end; - -local function getTie1() -- tie breaker of current attempt in case score is equal - local result = no; - -- TIE1 - return result; -end; - -local function getTie2() -- second tie breaker - local result = no; - -- TIE2 - return result; -end; - -local function getTie3() -- third tie breaker - local result = no; - -- TIE3 - return result; -end; - -local function getTie4() -- fourth tie breaker - local result = no; - -- TIE4 - return result; -end; - -local function isRunEnd() -- gets called 3x! twice in the main loop (every frame). determines whether the bot should quit. - local result = no; - -- ISRUNEND - return result; -end; - -local function mustRollBack() -- drop back to previous segment? called at the end of a segment - local result = no; - -- MUSTROLLBACK - return result; -end; - -local function isSegmentEnd() -- end of current segment? (usually just x frames or being really stuck (to rollback)) - local result = no; - -- ISSEGMENTEND - return result; -end; - -local function isAttemptOk() -- is current run ok? like, did you die? (then the run is NOT ok... :). return no for no and yes for yes or be left by chance. - local result = yes; - -- ISATTEMPTOK - return result; -end; - -local function isAttemptEnd() -- end of current attempt? (like when you die or reach a goal) - local result = no; - -- ISATTEMPTEND - return result; -end; - --- the next 2x8 functions determine whether a button should be pressed for player 1 and 2 --- return yes or no for absolute values, return anything between minvalue and maxvalue --- to set a chance of pressing that button. - -local function pressKeyA1() - local result = no; - -- bA1 - return result; -end; - -local function pressKeyB1() - local result = no; - -- bB1 - return result; -end; - -local function pressKeyStart1() - local result = no; - -- START1 - return result; -end; - -local function pressKeySelect1() - local result = no; - -- SELECT1 - return result; -end; - -local function pressKeyUp1() - local result = no; - -- UP1 - return result; -end; - -local function pressKeyDown1() - local result = no; - -- DOWN1 - return result; -end; - -local function pressKeyLeft1() - local result = no; - -- LEFT1 - return result; -end; - -local function pressKeyRight1() - local result = no; - -- RIGHT1 - return result; -end; - -local function pressKeyA2() - local result = no; - -- bA2 - return result; -end; - -local function pressKeyB2() - local result = no; - -- bB2 - return result; -end; - -local function pressKeyStart2() - local result = no; - -- START2 - return result; -end; - -local function pressKeySelect2() - local result = no; - -- SELECT2 - return result; -end; - -local function pressKeyUp2() - local result = no; - -- UP2 - return result; -end; - -local function pressKeyDown2() - local result = no; - -- DOWN2 - return result; -end; - -local function pressKeyLeft2() - local result = no; - -- LEFT2 - return result; -end; - -local function pressKeyRight2() - local result = no; - -- RIGHT2 - return result; -end; - -local function pressKeyA3() - local result = no; - -- bA3 - return result; -end; - -local function pressKeyB3() - local result = no; - -- bB3 - return result; -end; - -local function pressKeyStart3() - local result = no; - -- START3 - return result; -end; - -local function pressKeySelect3() - local result = no; - -- SELECT3 - return result; -end; - -local function pressKeyUp3() - local result = no; - -- UP3 - return result; -end; - -local function pressKeyDown3() - local result = no; - -- DOWN3 - return result; -end; - -local function pressKeyLeft3() - local result = no; - -- LEFT3 - return result; -end; - -local function pressKeyRight3() - local result = no; - -- RIGHT3 - return result; -end; - -local function pressKeyA4() - local result = no; - -- bA4 - return result; -end; - -local function pressKeyB4() - local result = no; - -- bB4 - return result; -end; - -local function pressKeyStart4() - local result = no; - -- START4 - return result; -end; - -local function pressKeySelect4() - local result = no; - -- SELECT4 - return result; -end; - -local function pressKeyUp4() - local result = no; - -- UP4 - return result; -end; - -local function pressKeyDown4() - local result = no; - -- DOWN4 - return result; -end; - -local function pressKeyLeft4() - local result = no; - -- LEFT4 - return result; -end; - -local function pressKeyRight4() - local result = no; - -- RIGHT4 - return result; -end; - --- now follow the "events", one for the start and end of a frame, attempt, segment and whole bot. none of them need to return anything - -local function onStart() -- this code should run before the bot starts, for instance to start the game from power on and get setup the game - -- ONSTART -end; - -local function onFinish() -- code ran after the bot finishes - -- ONFINISH -end; - -local function onSegmentStart() -- code ran after initializing a new segment, before onAttemptStart(). framecount is always one fewer then actual frame! - -- ONSEGMENTSTART -end; - -local function onSegmentEnd() -- code ran after a segment finishes, before cleanup of segment vars - -- ONSEGMENTEND -end; - -local function onAttemptStart() -- code ran after initalizing a new attempt, before onInputStart(). not ran when playing back. framecount is always one fewer then actual frame! - -- ONATTEMPTSTART -end; - -local function onAttemptEnd(wasOk) -- code ran after an attempt ends before cleanup code, argument is boolean true when attempt was ok, boolean false otherwise. not ran when playing back - -- ONATTEMPTEND -end; - -local function onInputStart() -- code ran prior to getting input (keys are empty). not ran when playing back - -- ONINPUTSTART -end; - -local function onInputEnd() -- code ran after getting input (lastkey are still valid) (last function before frame ends, you can still manipulate the input here!). not ran when playing back - -- ONINPUTEND -end; - --- the bot starts here.. (nothing is added from the user from this point onwards) - -onStart(); -- run this code first - -segments[segment].savestate = savestate.create(); -- create anonymous savestate obj for start of first segment -savestate.save(segments[segment].savestate); -- save current state to it, it will be reloaded at the start of each frame -local startkey1 = key1; -- save the last key pressed in the onStart. serves as an anchor for the first segment -local startkey2 = key2; -local startkey3 = key3; -- save the last key pressed in the onStart. serves as an anchor for the first segment -local startkey4 = key4; -local startvars = vars; -- save the vars array (it might have been used by the onStart) -lastkey1 = key1; -- to enter the loop... -lastkey2 = key2; -lastkey3 = key3; -lastkey4 = key4; ---FCEU.speedmode("maximum"); -- uncomment this line to make the bot run faster ("normal","turbo","maximum") - -onSegmentStart(); -onAttemptStart(); - -collectgarbage(); -- just in case... - --- This will loops for each frame, at the end of the while --- the frameadvance is called, causing it to advance -while (rand_if(isRunEnd())) do - loopcounter = loopcounter + 1; -- count the number of botloops - --gui.text(200,10,loopcounter); -- print it on the right side if you want to see the number of total frames - - if (not playingbest and rand_if(isAttemptEnd())) then -- load save state, continue with next attempt (disabled when playing back best) - -- record this attempt as the last attempt - if (not segments[segment].prev) then segments[segment].prev = {}; end; - segments[segment].prev.frames = frame; - segments[segment].prev.attempt = attempt; - segments[segment].prev.score = getScore(); - segments[segment].prev.tie1 = getTie1(); - segments[segment].prev.tie2 = getTie2(); - segments[segment].prev.tie3 = getTie3(); - segments[segment].prev.tie4 = getTie4(); - segments[segment].prev.ok = rand_if(isAttemptOk()); -- this is the check whether this attempt was valid or not. if not, it cannot become the best attempt. - -- update ok/failed attempt counters - if (segments[segment].prev.ok) then - okattempts = okattempts + 1; - onAttemptEnd(true); - else - failattempts = failattempts + 1; - onAttemptEnd(false); - end; - - -- if this attempt was better then the previous one, replace it - -- its a long IF, but all it checks (lazy eval) is whether the current - -- score is better then the previous one, or if its equal and the tie1 - -- is better then the previous tie1 or if the tie1 is equal to the prev - -- etc... for all four ties. Only tie4 actually needs to be better, tie1 - -- through tie3 can be equal as well, as long as the next tie breaks the - -- same tie of the previous attempt :) - if (segments[segment].prev.ok and (not segments[segment].best or (getScore() > segments[segment].best.score or (getScore() == segments[segment].best.score and (getTie1() > segments[segment].best.tie1 or (getTie1() == segments[segment].best.tie1 and (getTie1() > segments[segment].best.tie1 or (getTie1() == segments[segment].best.tie1 and (getTie1() > segments[segment].best.tie1 or (getTie1() == segments[segment].best.tie1 and getTie1() > segments[segment].best.tie1)))))))))) then - -- previous attempt was better then current best (or no current best - -- exists), so we (re)place it. - if (not segments[segment].best) then segments[segment].best = {}; end; - segments[segment].best.frames = segments[segment].prev.frames; - segments[segment].best.attempt = segments[segment].prev.attempt; - segments[segment].best.score = segments[segment].prev.score; - segments[segment].best.tie1 = segments[segment].prev.tie1; - segments[segment].best.tie2 = segments[segment].prev.tie2; - segments[segment].best.tie3 = segments[segment].prev.tie3; - segments[segment].best.tie4 = segments[segment].prev.tie4; - segments[segment].best.keys1 = keyrecording1; -- backup the recorded keys - segments[segment].best.keys2 = keyrecording2; -- backup the recorded keys player 2 - segments[segment].best.keys3 = keyrecording3; -- backup the recorded keys - segments[segment].best.keys4 = keyrecording4; -- backup the recorded keys player 2 - segments[segment].best.lastkey1 = lastkey1; -- backup the lastkey - segments[segment].best.lastkey2 = lastkey2; -- backup the lastkey - segments[segment].best.lastkey3 = lastkey3; -- backup the lastkey - segments[segment].best.lastkey4 = lastkey4; -- backup the lastkey - segments[segment].best.vars = vars; -- backup the vars table - end - - if (rand_if(isSegmentEnd())) then -- the current segment ends, replay the best attempt and continue from there onwards... - onSegmentEnd(); - if (rand_if(mustRollBack())) then -- rollback to previous segment - gui.text(50,50,"Rolling back to segment "..(segment-1)); - segments[segment] = nil; -- remove current segment data - attempt = 0; -- will be incremented in a few lines to be 1 - segment = segment - 1; - segments[segment].best = nil; - segments[segment].prev = nil; - collectgarbage(); -- collect the removed segment please - else - playingbest = true; -- this will start playing back the best attempt in this frame - end; - end; - - -- reset vars - attempt = attempt + 1; - frame = 0; - keyrecording1 = {}; -- reset the recordings :) - keyrecording2 = {}; - keyrecording3 = {}; - keyrecording4 = {}; - -- set lastkey to lastkey of previous segment (or start, if first segment) - -- also set the vars table to the table of the previous segment - if (segment == 1) then - lastkey1 = startkey1; - lastkey2 = startkey2; - lastkey3 = startkey3; - lastkey4 = startkey4; - vars = startvars; - else - lastkey1 = segments[segment-1].best.lastkey1; - lastkey2 = segments[segment-1].best.lastkey2; - lastkey3 = segments[segment-1].best.lastkey3; - lastkey4 = segments[segment-1].best.lastkey4; - vars = segments[segment-1].best.vars; - end; - -- load the segment savestate to go back to the start of this segment - if (segments[segment].savestate) then -- load segment savestate and try again :) - savestate.load(segments[segment].savestate); - else - fceu.crash(); -- this crashes because fceu is a nil table :) as long as gui.popup() doesnt work... we're crashing because no save state exists..? it should never happen. - end; - - if (rand_if(isRunEnd())) then break; end; -- if end of run, break out of main loop and run in end loop. - - if (not playingbest) then onAttemptStart(); end; -- only call this when not playing back best attempt. has decreased frame counter! - end; -- continues with (new) attempt - - -- increase framecounter _after_ processing attempt-end - frame = frame + 1; -- inrease the frame count (++frame?) - - if (playingbest and segments[segment].best) then -- press keys from memory (if there are any) - gui.text(10,150,"frame "..frame.." of "..segments[segment].best.frames); - if (frame >= segments[segment].best.frames) then -- end of playback, start new segment - playingbest = false; - lastkey1 = segments[segment].best.lastkey1; - lastkey2 = segments[segment].best.lastkey2; - lastkey3 = segments[segment].best.lastkey3; - lastkey4 = segments[segment].best.lastkey4; - vars = segments[segment].best.vars; - segment = segment + 1; - segments[segment] = {}; - -- create a new savestate for the start of this segment - segments[segment].savestate = savestate.create(); - savestate.save(segments[segment].savestate); - -- reset vars - frame = 0; -- onSegmentStart and onAttemptStart expect this to be one fewer... - attempt = 1; - - keyrecording1 = {}; -- reset recordings :) - keyrecording2 = {}; - keyrecording3 = {}; - keyrecording4 = {}; - -- after this, the next segment starts because playingbest is no longer true - onSegmentStart(); - onAttemptStart(); - frame = 1; -- now set it to 1 - else - key1 = segments[segment].best.keys1[frame]; -- fill keys with that of the best attempt - key2 = segments[segment].best.keys2[frame]; - key3 = segments[segment].best.keys3[frame]; - key4 = segments[segment].best.keys4[frame]; - gui.text(10,10,"Playback best of segment "..segment.."\nFrame: "..frame); - end; - end; - - if (rand_if(isRunEnd())) then break; end; -- if end of run, break out of main loop - -- note this is the middle, this is where an attempt or segment has ended if it would and started if it would! - -- now comes the input part for this frame - - if (not playingbest) then -- when playing best, the keys have been filled above. - -- press keys from bot - gui.text(10,10,"Attempt: "..attempt.." / "..maxattempts.."\nFrame: "..frame.." / "..maxframes); - if (segments[segment] and segments[segment].best and segments[segment].prev) then - gui.text(10,30,"Last score: "..segments[segment].prev.score.." ok="..okattempts..", fail="..failattempts.."\nBest score: "..segments[segment].best.score); - elseif (segments[segment] and segments[segment].prev) then - gui.text(10,30,"Last score: "..segments[segment].prev.score.."\nBest score: none, fails="..failattempts); - end; - gui.text(10,50,"Segment: "..segment); - - key1 = {}; - key2 = {}; - key3 = {}; - key4 = {}; - - onInputStart(); - - -- player 1 - if (rand_if(pressKeyUp1()) ) then key1.up = 1; end; - if (rand_if(pressKeyDown1())) then key1.down = 1; end; - if (rand_if(pressKeyLeft1())) then key1.left = 1; end; - if (rand_if(pressKeyRight1())) then key1.right = 1; end; - if (rand_if(pressKeyA1())) then key1.A = 1; end; - if (rand_if(pressKeyB1())) then key1.B = 1; end; - if (rand_if(pressKeySelect1())) then key1.select = 1; end; - if (rand_if(pressKeyStart1())) then key1.start = 1; end; - - -- player 2 - if (rand_if(pressKeyUp2()) ) then key2.up = 1; end; - if (rand_if(pressKeyDown2())) then key2.down = 1; end; - if (rand_if(pressKeyLeft2())) then key2.left = 1; end; - if (rand_if(pressKeyRight2())) then key2.right = 1; end; - if (rand_if(pressKeyA2())) then key2.A = 1; end; - if (rand_if(pressKeyB2())) then key2.B = 1; end; - if (rand_if(pressKeySelect2())) then key2.select = 1; end; - if (rand_if(pressKeyStart2())) then key2.start = 1; end; - - -- player 3 - if (rand_if(pressKeyUp3()) ) then key3.up = 1; end; - if (rand_if(pressKeyDown3())) then key3.down = 1; end; - if (rand_if(pressKeyLeft3())) then key3.left = 1; end; - if (rand_if(pressKeyRight3())) then key3.right = 1; end; - if (rand_if(pressKeyA3())) then key3.A = 1; end; - if (rand_if(pressKeyB3())) then key3.B = 1; end; - if (rand_if(pressKeySelect3())) then key3.select = 1; end; - if (rand_if(pressKeyStart3())) then key3.start = 1; end; - - -- player 2 - if (rand_if(pressKeyUp4()) ) then key4.up = 1; end; - if (rand_if(pressKeyDown4())) then key4.down = 1; end; - if (rand_if(pressKeyLeft4())) then key4.left = 1; end; - if (rand_if(pressKeyRight4())) then key4.right = 1; end; - if (rand_if(pressKeyA4())) then key4.A = 1; end; - if (rand_if(pressKeyB4())) then key4.B = 1; end; - if (rand_if(pressKeySelect4())) then key4.select = 1; end; - if (rand_if(pressKeyStart4())) then key4.start = 1; end; - - onInputEnd(); - - lastkey1 = key1; - lastkey2 = key2; - lastkey3 = key3; - lastkey4 = key4; - - keyrecording1[frame] = key1; -- record these keys - keyrecording2[frame] = key2; -- record these keys - keyrecording3[frame] = key3; -- record these keys - keyrecording4[frame] = key4; -- record these keys - end; - - -- actually set the keys here. - joypad.set(1, key1); - joypad.set(2, key2); - joypad.set(3, key3); - joypad.set(4, key4); - - -- next frame - FCEU.frameadvance(); -end; - -onFinish(); -- allow user cleanup before starting the final botloop - --- now enter an endless loop displaying the results of this run. -while (true) do - if (segments[segment].best) then gui.text(30,100,"end: max attempt ["..segment.."] had score = "..segments[segment].best.score); - elseif (segment > 1 and segments[segment-1].best) then gui.text(30,100,"end: no best attempt ["..segment.."]\nPrevious best score: "..segments[segment-1].best.score); - else gui.text(30,100,"end: no best attempt ["..segment.."] ..."); end; - FCEU.frameadvance(); -end; - --- i dont think it ever reaches this place... perhaps it should, or some event or whatever... -segments = nil; -collectgarbage(); -- collect the segment data... anything else is probably not worth it... diff --git a/branches/sdl2/output/luaScripts/m_utils.lua b/branches/sdl2/output/luaScripts/m_utils.lua deleted file mode 100644 index eaf96dca..00000000 --- a/branches/sdl2/output/luaScripts/m_utils.lua +++ /dev/null @@ -1,233 +0,0 @@ ---Used for scripts written by Miau such as Gradius-BulletHell - ---[[ -A Compilation of general-purpose functions. - --]] -M_UTILS_VERSION = 0 - ---initialization -if(FCEU) then - EMU = FCEU -elseif(snes9x) then - EMU = snes9x -elseif(gens) then - EMU = gens -end -if(EMU == nil) then - error("Unsupported environment. This script runs on Lua-capable emulators only - FCEUX, Snes9x or Gens.") -end - - - - ---[[ m_require - "require" with version checking - - Similar to the approach in Xk's x_functions.lua, but supports loading and automatic version checking of - "compatible" modules, too. A central version checking function does have its advantages. - -A compatible module looks like this: - if(REQUIRED_MODULE_VERSION==0) then --global variable = the second parameter of m_require - error("This module isn't backwards compatible to version 0.") - end - module("modulename") - MODULE_VERSION = 3 - function test() - end - return _M - -using it in your code: - m_require("modulefile.lua",3) --second parameter being > MODULE_VERSION would raise an error - modulename.test() --]] -function m_require(module,requiredver) - if(module==nil or module=="m_utils") then - if(M_UTILS_VERSION>=requiredver) then - return true - else - error("\n\nThis script requires m_utils version "..requiredver..".\n".. - "Your m_utils.lua is version "..M_UTILS_VERSION.."\n".. - "Check http://morphcat.de/lua/ for a newer version.") - end - else - --give the module the possibility to be backwards compatible - --not very elegant, but there seems to be no other way using require - REQUIRED_MODULE_VERSION = requiredver - local ret = require(module) - if(requiredver==nil) then --got no version checking to do - return ret - elseif(ret==nil or ret==false) then - error("Could not load module "..module.." or module invalid.") - elseif(type(ret)~="table") then - error("Invalid module "..module..", doesn't return itself.") - elseif(ret.MODULE_VERSION==nil) then - error("Invalid module "..module..", missing version information.") - elseif(ret.MODULE_VERSION < requiredver) then - error("\n\nThis script requires "..module.." version "..requiredver..".\n".. - "Your "..module.." module is version "..ret.MODULE_VERSION..".\n".. - "If it's one of miau's Lua modules check\n".. - "http://morphcat.de/lua/ for a newer version.\n") - else - return ret - end - end -end - - ---drawing functions with bounds checking -function bcbox(x1,y1,x2,y2,color1) - if(x1>=0 and y1>=0 and x2<=255 and y2<=255) then - gui.drawbox(x1, y1, x2, y2, color1, 0) - end -end - -function bcpixel(x,y,color) - if(x>=0 and y>=0 and x<=255 and y<=255) then - gui.drawpixel(x,y,color) - end -end - -function bcline(x1,y1,x2,y2,color) - if(x1>=0 and y1>=0 and x2<=255 and y2<=255 - and x2>=0 and y2>=0 and x1<=255 and y1<=255) then - gui.drawline(x1, y1, x2, y2, color) - end -end - - ---bc + clipping, just make sure x2,y2 is the point that will most likely leave the screen first -function bcline2(x1,y1,x2,y2,color) - if(x1>=0 and y1>=0 and x1<=255 and y1<=255) then - if(x2>255 or y2>255 or x2<0 or y2<0) then - local vx,vy=getvdir(x1,y1,x2,y2) - --TODO: replace brute force-y method with line intersection formula - if(math.abs(vx)==1 or math.abs(vy)==1) then - local x=x1 - local y=y1 - while(x<254 and x>1 and y<254 and y>1) do - x = x + vx - y = y + vy - end - x = math.floor(x) - y = math.floor(y) - --logf(" ("..x1..","..y1..")-("..x..","..y..")\r\n") - gui.drawline(x1,y1,x,y,color) - end - else - gui.drawline(x1,y1,x2,y2,color) - end - end -end - -function bctext(x,y,text) - if(x>=0 and y>=0 and x<=255 and y<=255) then - --make sure the text is always visible or else... possible memory leaks(?) and crashes on FCEUX <= 2.0.3 - local len=string.len(text)*8+1 - if(x+len > 255) then - x = 255-len - end - if(x < 0) then - x = 0 - end - - if(y > 222) then --NTSC - y=222 - end - gui.text(x, y, text) - end -end - - -function getdistance(x1,y1,x2,y2) - return math.floor(math.sqrt((x1-x2)^2+(y1-y2)^2)) -end - ---returns direction vector of a line -function getvdir(srcx,srcy,destx,desty) - local x1 = srcx - local x2 = destx - local y1 = srcy - local y2 = desty - local xc = x2-x1 - local yc = y2-y1 - if(math.abs(xc)>math.abs(yc)) then - yc = yc/math.abs(xc) - xc = xc/math.abs(xc) - elseif(math.abs(yc)>math.abs(xc)) then - xc = xc/math.abs(yc) - yc = yc/math.abs(yc) - else - if(xc<0) then - xc=-1 - elseif(xc>0) then - xc=1 - else - xc=0 - end - if(yc<0) then - yc=-1 - elseif(yc>0) then - yc=1 - else - yc=0 - end - end - - return xc,yc -end - - -local m_cursor = { - {1,0,0,0,0,0,0,0}, - {1,1,0,0,0,0,0,0}, - {1,2,1,0,0,0,0,0}, - {1,2,2,1,0,0,0,0}, - {1,2,2,2,1,0,0,0}, - {1,2,2,2,2,1,0,0}, - {1,2,2,2,2,2,1,0}, - {1,2,1,1,1,1,1,1}, - {1,1,0,0,0,0,0,0}, - {1,0,0,0,0,0,0,0}, -} -function drawcursor(px,py,col1,col2) - if(px>0 and py>0 and px<256-8 and py<256-10) then - for y=1,10 do - if(m_cursor[y]) then - for x=1,8 do - if(m_cursor[y][x]==1) then - gui.drawpixel(px+x,py+y,col1) - elseif(m_cursor[y][x]==2) then - gui.drawpixel(px+x,py+y,col2) - end - end - end - end - end -end - ---debug functions -function logf(s) - local fo = io.open("E:/emu/nes/fceux-2.0.4.win32-unofficial/lua/log.txt", "ab") - if(fo~=nil) then - fo:write(s) - fo:close() - return true - end -end - -function logtable(a) - for i,v in pairs(a) do - if(type(v)=="table") then - printarrrec(v) - else - if(v==false) then - v="false" - elseif(v==true) then - v="true" - end - logf(i.." = "..v.."\r\n") - end - end -end - diff --git a/branches/sdl2/output/luaScripts/shapedefs.lua b/branches/sdl2/output/luaScripts/shapedefs.lua deleted file mode 100644 index 3aa1c666..00000000 --- a/branches/sdl2/output/luaScripts/shapedefs.lua +++ /dev/null @@ -1,43 +0,0 @@ ---shapedefs ---A Lua script with defined functions for shapes such as hearts. ---Needed for SM-Lives&HPDisplay-4Matsy.lua - -local function box(x1,y1,x2,y2,color) - if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 241 and y2 > 0 and y2 < 241) then - gui.drawbox(x1,y1,x2,y2,color); - end; -end; -local function text(x,y,str) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.text(x,y,str); - end; -end; -local function pixel(x,y,color) - if (x > 0 and x < 255 and y > 0 and y < 240) then - gui.drawpixel(x,y,color); - end; -end; - -function drawshape (x,y,str,color) - if str == "heart_5x5" then - box(x+1,y+0,x+1,y+3,color); - box(x+3,y+0,x+3,y+3,color); - box(x+2,y+3,x+2,y+4,color); - box(x+0,y+1,x+4,y+2,color); - end; - if str == "heart_7x7" then - box(x+1,y+0,x+2,y+4,color); - box(x+4,y+0,x+5,y+4,color); - box(x+0,y+1,x+6,y+3,color); - box(x+3,y+2,x+3,y+6,color); - box(x+2,y+5,x+4,y+5,color); - end; - if str == "z2magicjar" then - box(x+0,y+5,x+4,y+6,color); - box(x+1,y+4,x+3,y+7,color); - box(x+1,y+0,x+3,y+0,color); - box(x+2,y+1,x+2,y+3,color); - box(x+3,y+2,x+3,y+2,color); - box(x+4,y+3,x+4,y+3,color); - end; -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/taseditor/InputDisplay_for_Selection.lua b/branches/sdl2/output/luaScripts/taseditor/InputDisplay_for_Selection.lua deleted file mode 100644 index 50f44d5b..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/InputDisplay_for_Selection.lua +++ /dev/null @@ -1,64 +0,0 @@ ---------------------------------------------------------------------------- --- Display Input at Selection cursor --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * taseditor.getselection() --- * taseditor.getinput() ---------------------------------------------------------------------------- --- Usage: --- Run the script, unpause emulation (or simply Frame Advance once). --- Now you can see additional joypad icon at the bottom left corner of FCEUX screen. --- This icon displays which buttons are held at the selected frame. --- If you have several frames selected, the joypad icon will only display buttons --- of the first selected frame. --- By default the script only shows 1P joypad, but you can change "num=2, on=false" --- to "num=2, on=true" to also display 2P joypad and so on. ---------------------------------------------------------------------------- - -pads = { - {num=1, on=true, color="red", x=50, y=200, w=34, h=10}, - {num=2, on=true, color="yellow", x=90, y=200, w=34, h=10}, - {num=3, on=false, color="green", x=130, y=200, w=34, h=10}, - {num=4, on=false, color="orange", x=170, y=200, w=34, h=10} -} - -buttons = { - A = {x=30, y=5, w=3, h=3, bitmask=1}, - B = {x=24, y=5, w=3, h=3, bitmask=2}, - select = {x=18, y=7, w=3, h=1, bitmask=4}, - start = {x=12, y=7, w=3, h=1, bitmask=8}, - up = {x=4, y=1, w=2, h=2, bitmask=16}, - down = {x=4, y=7, w=2, h=2, bitmask=32}, - left = {x=1, y=4, w=2, h=2, bitmask=64}, - right = {x=7, y=4, w=2, h=2, bitmask=128} -} - -function draw_joypads() - if (taseditor.engaged()) then - selection_table = taseditor.getselection(); - if (selection_table ~= nil) then - selection_start = selection_table[1]; - for _, pad in ipairs(pads) do - if pad.on then - gui.drawbox(pad.x, pad.y, pad.x+pad.w, pad.y+pad.h, "#3070ffb0") - gui.drawbox(pad.x+4, pad.y+4, pad.x+6, pad.y+6, "black") - controller = taseditor.getinput(selection_start, pad.num) - for name, btn in pairs(buttons) do - if (AND(controller, btn.bitmask) ~= 0) then - gui.drawbox(pad.x + btn.x, pad.y + btn.y, pad.x + btn.x + btn.w, pad.y + btn.y + btn.h, pad.color) - else - gui.drawbox(pad.x + btn.x, pad.y + btn.y, pad.x + btn.x + btn.w, pad.y + btn.y + btn.h, "black") - end - end - end - end - end - else - gui.text(1, 9, "TAS Editor is not engaged."); - end -end - -taseditor.registerauto(draw_joypads); - - diff --git a/branches/sdl2/output/luaScripts/taseditor/InvertSelection.lua b/branches/sdl2/output/luaScripts/taseditor/InvertSelection.lua deleted file mode 100644 index 342e9acb..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/InvertSelection.lua +++ /dev/null @@ -1,55 +0,0 @@ ---------------------------------------------------------------------------- --- Invert Selection --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * taseditor.getselection() --- * taseditor.setselection() ---------------------------------------------------------------------------- --- Usage: --- Run the script, unpause emulation (or simply Frame Advance once). --- Now you can press "Invert Selection" button to invert current Selection. --- Previously selected frames become deselected, all other frames become selected. ---------------------------------------------------------------------------- - -function display_selection() - if (taseditor.engaged()) then - selection_table = taseditor.getselection(); - if (selection_table ~= nil) then - selection_size = #selection_table; - gui.text(0, 10, "Selection: " .. selection_size .. " rows"); - else - gui.text(0, 10, "Selection: no"); - end - else - gui.text(1, 9, "TAS Editor is not engaged."); - end -end - -function invert_selection() - old_sel = taseditor.getselection(); - new_sel = {}; - - -- Select all - movie_size = movie.length(); - for i = 0, movie_size do - new_sel[i + 1] = i; - end - - if (selection_table ~= nil) then - -- Substract old selection from new selection set - for i = #old_sel, 1, -1 do - selected_frame = old_sel[i]; - -- we're taking advantage of the fact that "old_sel" is sorted in ascending order - -- so we can safely use table.remove to remove indexes from the end to the beginning - table.remove(new_sel, selected_frame + 1); - end - end - - -- Apply new set to TAS Editor selection - taseditor.setselection(new_sel); -end - -taseditor.registerauto(display_selection); -taseditor.registermanual(invert_selection, "Invert Selection"); - diff --git a/branches/sdl2/output/luaScripts/taseditor/RecordBackwards.lua b/branches/sdl2/output/luaScripts/taseditor/RecordBackwards.lua deleted file mode 100644 index 8e30376e..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/RecordBackwards.lua +++ /dev/null @@ -1,99 +0,0 @@ ---------------------------------------------------------------------------- --- Recording Input while Rewinding Playback frame-by-frame --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * joypad.getimmediate() --- * taseditor.getrecordermode() --- * taseditor.getsuperimpose() --- * taseditor.getinput() --- * taseditor.setinput() --- * taseditor.clearinputchanges() --- * taseditor.applyinputchanges() ---------------------------------------------------------------------------- --- Usage: --- Run the script, unpause emulation (or simply Frame Advance once). --- Now you can hold some joypad buttons and press "Rewind Frame" hotkey --- to Record those buttons into PREVIOUS frame. --- Try using this crazy method alongside with Frame Advance Recording. --- This script supports multitracking and superimpose. Doesn't support Patterns. ---------------------------------------------------------------------------- - --- This function reads joypad input table and converts it to single byte -function GetCurrentInputByte(player) - input_byte = 0; - input_table = joypad.getimmediate(player); - if (input_table ~= nil) then - -- A B select start up down left right - if (input_table.A) then input_byte = OR(input_byte, 1) end; - if (input_table.B) then input_byte = OR(input_byte, 2) end; - if (input_table.select) then input_byte = OR(input_byte, 4) end; - if (input_table.start) then input_byte = OR(input_byte, 8) end; - if (input_table.up) then input_byte = OR(input_byte, 16) end; - if (input_table.down) then input_byte = OR(input_byte, 32) end; - if (input_table.left) then input_byte = OR(input_byte, 64) end; - if (input_table.right) then input_byte = OR(input_byte, 128) end; - end - return input_byte; -end - -function reversed_recorder() - if taseditor.engaged() then - playback_position = movie.framecount(); - if (playback_position == (playback_last_position - 1)) then - -- Playback cursor moved up 1 frame, probably Rewind was used this frame - if (not movie.readonly()) then - -- Recording on - recording_mode = taseditor.getrecordermode(); - superimpose = taseditor.getsuperimpose(); - taseditor.clearinputchanges(); - name = "Record"; - if (recording_mode == "All") then - -- Recording all 4 joypads - for target_player = 1, 4 do - new_joypad_input = GetCurrentInputByte(target_player); - old_joypad_input = taseditor.getinput(playback_position, target_player); - -- Superimpose with old input if needed - if (superimpose == 1 or (superimpose == 2 and new_joypad_input == 0)) then - new_joypad_input = OR(new_joypad_input, old_joypad_input); - end - -- Add joypad info to name - if (new_joypad_input ~= old_joypad_input) then - name = name .. "(" .. target_player .. "P)"; - end - taseditor.submitinputchange(playback_position, target_player, new_joypad_input); - end - -- Write to movie data - taseditor.applyinputchanges(name); - else - -- Recording target_player using 1P keys - new_joypad_input = GetCurrentInputByte(1); - target_player = 1; - if (recording_mode == "2P") then target_player = 2 end; - if (recording_mode == "3P") then target_player = 3 end; - if (recording_mode == "4P") then target_player = 4 end; - old_joypad_input = taseditor.getinput(playback_position, target_player); - -- Superimpose with old input if needed - if (superimpose == 1 or (superimpose == 2 and new_joypad_input == 0)) then - new_joypad_input = OR(new_joypad_input, old_joypad_input); - end - -- Add joypad info to name - if (new_joypad_input ~= old_joypad_input) then - name = name .. "(" .. recording_mode .. ")"; - end - -- Write to movie data - taseditor.submitinputchange(playback_position, target_player, new_joypad_input); - taseditor.applyinputchanges(name); - end - end - end - playback_last_position = playback_position; - else - gui.text(1, 9, "TAS Editor is not engaged."); - end -end - -playback_last_position = movie.framecount(); -taseditor.registerauto(reversed_recorder); - - diff --git a/branches/sdl2/output/luaScripts/taseditor/ShowNotes.lua b/branches/sdl2/output/luaScripts/taseditor/ShowNotes.lua deleted file mode 100644 index 1fb61403..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/ShowNotes.lua +++ /dev/null @@ -1,64 +0,0 @@ ---------------------------------------------------------------------------- --- Showing Markers' Notes on screen --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * taseditor.getmarker() --- * taseditor.getnote() --- * taseditor.getselection() ---------------------------------------------------------------------------- --- Usage: --- Run the script, unpause emulation (or simply Frame Advance once). --- Now you can observe Marker Notes not only in TAS Editor window, --- but also in FCEUX main screen. --- This script automatically divides long Notes into several lines of text ---------------------------------------------------------------------------- - --- Custom function for word-wrapping long lines of text -function DisplayText(x, y, text, max_num_chars) - while string.len(text) >= max_num_chars do - -- Find last spacebar within first max_num_chars of text - last_spacebar = string.find(string.reverse(string.sub(text, 1, max_num_chars)), " "); - if (last_spacebar ~= nil) then - -- Output substring up to the spacebar - substring_len = max_num_chars - last_spacebar; - else - -- No spacebar found within first max_num_chars of the string - -- output substring up to the first spacebar (this substring will have length > max_num_chars) - substring_len = string.find(text, " "); - if (substring_len == nil) then - -- No spacebars found at all, output whole string - substring_len = string.len(text); - else - -- Don't output the spacebar - substring_len = substring_len - 1; - end - end - gui.text(x, y, string.sub(text, 1, substring_len)); - text = string.sub(text, substring_len + 2); - -- Next line - y = y + 8; - end - gui.text(x, y, text); -end - -function ShowNotes() - if taseditor.engaged() then - -- Take Marker near Playback cursor and display its Note in upper half of the screen - playback_position = movie.framecount(); - note = taseditor.getnote(taseditor.getmarker(playback_position)); - DisplayText(1, 9, note, 50); - -- Take Marker near Selection cursor and display its Note in lower half of the screen - current_selection = taseditor.getselection(); - if (current_selection ~= nil) then - selection_position = current_selection[1]; - note = taseditor.getnote(taseditor.getmarker(selection_position)); - DisplayText(1, 190, note, 50); - end - else - gui.text(1, 9, "TAS Editor is not engaged."); - end -end - -taseditor.registerauto(ShowNotes) - diff --git a/branches/sdl2/output/luaScripts/taseditor/Swap1P2P.lua b/branches/sdl2/output/luaScripts/taseditor/Swap1P2P.lua deleted file mode 100644 index e69ac197..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/Swap1P2P.lua +++ /dev/null @@ -1,37 +0,0 @@ ---------------------------------------------------------------------------- --- Swap 1P and 2P buttons at Selected frames --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * taseditor.getselection() --- * taseditor.clearinputchanges() --- * taseditor.getinput() --- * taseditor.submitinputchange() --- * taseditor.applyinputchanges() ---------------------------------------------------------------------------- --- Usage: --- Use the script when you want to exchange recorded input between joypads. --- Run the script, unpause emulation (or simply Frame Advance once). --- Now you can select several frames of input data and then --- press "Swap 1P/2P" button to swap Input of 1P and 2P in selected frames. --- You can easily modify the script to swap any other joypads. ---------------------------------------------------------------------------- - -function swap() - selection_table = taseditor.getselection(); - if (selection_table ~= nil) then - taseditor.clearinputchanges(); - for i = 1, #selection_table do - selected_frame = selection_table[i]; - joypad1data = taseditor.getinput(selected_frame, 1); - joypad2data = taseditor.getinput(selected_frame, 2); - taseditor.submitinputchange(selected_frame, 1, joypad2data); - taseditor.submitinputchange(selected_frame, 2, joypad1data); - end - taseditor.applyinputchanges("Swap 1P/2P"); - end -end - -taseditor.registermanual(swap, "Swap 1P/2P"); - - diff --git a/branches/sdl2/output/luaScripts/taseditor/TrackNoise.lua b/branches/sdl2/output/luaScripts/taseditor/TrackNoise.lua deleted file mode 100644 index 1160f9c7..00000000 --- a/branches/sdl2/output/luaScripts/taseditor/TrackNoise.lua +++ /dev/null @@ -1,82 +0,0 @@ ---------------------------------------------------------------------------- --- Tracking Noise channel volume peaks --- by AnS, 2012 ---------------------------------------------------------------------------- --- Showcases following functions: --- * sound.get() --- * taseditor.markedframe() --- * taseditor.getmarker() --- * taseditor.setmarker() --- * taseditor.getnote() --- * taseditor.setnote() ---------------------------------------------------------------------------- --- Usage: --- Run the script, unpause emulation. --- When the "Auto function" checkbox is checked, the script will --- automatically create Markers on various frames according to ingame music. --- These Markers should help you see music patterns, --- so you can adjust input precisely creating nice Tool-Assisted dances. --- --- This script uses Noise channel volume as an indicator for setting Markers, --- but it's possible to use any other property of sound channels --- as a factor to decide whether to set Marker on current frame. --- --- The script was tested on Super Mario Bros, Megaman and Duck Tales. --- You may want to see it in slow-mo. Use -/= hotkeys to change emulation speed. --- --- To create customized script for your game, first use SoundDisplay.lua --- to collect and analyse statistics about ingame music. Then choose --- which channel you want to sync your input to. Finally, change this script --- so that Markers will be created using new set of rules. ---------------------------------------------------------------------------- - -NOISE_VOL_THRESHOLD = 0.35; - -function track_changes() - if (taseditor.engaged()) then - current_frame = movie.framecount(); - if (last_frame ~= current_frame) then - -- Playback has moved - -- Get current value of indicator for current_frame - snd = sound.get(); - indicator = snd.rp2a03.noise.volume; - -- If Playback moved 1 frame forward, this was probably Frame Advance - if (last_frame == current_frame - 1) then - -- Looks like we advanced one frame from the last time - -- Decide whether to set Marker - if (indicator > NOISE_VOL_THRESHOLD and last_frame_indicator_value == 0) then - -- this was a peak in volume! ____/\____ - -- Set Marker and show frequency of noise+triangle in its Note - SetSoundMarker(current_frame - 1, "Sound: " .. (snd.rp2a03.noise.regs.frequency + snd.rp2a03.triangle.regs.frequency)); - end - end - last_frame = current_frame; - last_frame_indicator_value = indicator; - end - else - gui.text(1, 9, "TAS Editor is not engaged."); - end -end - -function SetSoundMarker(frame, new_note) - if (taseditor.markedframe(frame)) then - -- this frame is already marked - old_note = taseditor.getnote(taseditor.getmarker(frame)); - -- check if the Note of the Marker already contains new_note text - if (string.find(old_note, new_note) == nil) then - -- append new_note text to the Marker's Note - taseditor.setnote(taseditor.getmarker(frame), old_note .. " " .. new_note); - end - else - -- this frame isn't marked - -- create new Marker here - new_marker = taseditor.setmarker(frame); - taseditor.setnote(new_marker, new_note); - end -end - -last_frame = 0; -last_frame_indicator_value = 0; - -taseditor.registerauto(track_changes); - diff --git a/branches/sdl2/output/luaScripts/tetris.lua b/branches/sdl2/output/luaScripts/tetris.lua deleted file mode 100644 index 1ca1c72f..00000000 --- a/branches/sdl2/output/luaScripts/tetris.lua +++ /dev/null @@ -1,141 +0,0 @@ --- Tetris - displays block stats and shows hitboxes --- Written by QFox --- http://www.datacrystal.org/wiki/Tetris:RAM_map --- Tetris (U) [!].rom - -local function getPiece(n) -- returns table with information about this piece - -- every piece consists of 4 blocks - -- so piece will contain the information about these blocks - -- for every block is the offset compared to the x,y position of the piece - -- the x,y is written in a 4x4 plane of blocks, 1x1 being the topleft block - -- x,y is the position as given by tetris - local piece = {}; - if (n == 0) then -- T right - piece.pos = {{2,1},{1,2},{2,2},{3,2}}; - piece.rel = {{0,-1},{-1,0},{0,0},{1,0}}; - piece.anchor = {2,2}; - elseif (n == 1) then -- T up - piece.pos = {{1,1},{1,2},{2,2},{1,3}}; - piece.rel = {{0,-1},{0,0},{1,0},{0,1}}; - piece.anchor = {1,2}; - elseif (n == 2) then -- T down - piece.pos = {{1,1},{2,1},{3,1},{2,2}}; - piece.rel = {{-1,0},{0,0},{1,0},{0,1}}; - piece.anchor = {2,1}; - elseif (n == 3) then -- T left - piece.pos = {{2,1},{1,2},{2,2},{2,3}}; - piece.rel = {{0,-1},{-1,0},{0,0},{0,1}}; - piece.anchor = {2,2}; - elseif (n == 4) then -- J left - piece.pos = {{2,1},{2,2},{1,3},{2,3}}; - piece.rel = {{0,-1},{0,0},{-1,1},{0,1}}; - piece.anchor = {2,2}; - elseif (n == 5) then -- J up - piece.pos = {{1,1},{1,2},{2,2},{3,2}}; - piece.rel = {{-1,-1},{-1,0},{0,0},{1,0}}; - piece.anchor = {2,2}; - elseif (n == 6) then -- J right - piece.pos = {{1,1},{2,1},{1,2},{1,3}}; - piece.rel = {{0,-1},{1,-1},{0,0},{0,1}}; - piece.anchor = {1,2}; - elseif (n == 7) then -- J down - piece.pos = {{1,1},{2,1},{3,1},{3,2}}; - piece.rel = {{-1,0},{0,0},{1,0},{1,1}}; - piece.anchor = {2,1}; - elseif (n == 8) then -- Z horz - piece.pos = {{1,1},{2,1},{2,2},{3,2}}; - piece.rel = {{-1,0},{0,0},{0,1},{1,1}}; - piece.anchor = {2,1}; - elseif (n == 9) then -- Z vert - piece.pos = {{2,1},{1,2},{2,2},{1,3}}; - piece.rel = {{1,-1},{0,0},{1,0},{0,1}}; - piece.anchor = {1,2}; - elseif (n == 10) then -- O - piece.pos = {{1,1},{2,1},{1,2},{2,2}}; - piece.rel = {{-1,0},{0,0},{-1,1},{0,1}}; - piece.anchor = {2,1}; - elseif (n == 11) then -- S horz - piece.pos = {{2,1},{3,1},{1,2},{2,2}}; - piece.rel = {{0,0},{1,0},{-1,1},{0,1}}; - piece.anchor = {2,1}; - elseif (n == 12) then -- S vert - piece.pos = {{1,1},{1,2},{2,2},{2,3}}; - piece.rel = {{0,-1},{0,0},{1,0},{1,1}}; - piece.anchor = {1,2}; - elseif (n == 13) then -- L right - piece.pos = {{1,1},{1,2},{1,3},{2,3}}; - piece.rel = {{0,-1},{0,0},{0,1},{1,1}}; - piece.anchor = {1,2}; - elseif (n == 14) then -- L down - piece.pos = {{1,1},{2,1},{3,1},{1,2}}; - piece.rel = {{-1,0},{0,0},{1,0},{-1,1}}; - piece.anchor = {2,1}; - elseif (n == 15) then -- L left - piece.pos = {{1,1},{2,1},{2,2},{2,3}}; - piece.rel = {{-1,-1},{0,-1},{0,0},{0,1}}; - piece.anchor = {2,2}; - elseif (n == 16) then -- L up - piece.pos = {{3,1},{1,2},{2,2},{3,2}}; - piece.rel = {{1,-1},{-1,0},{0,0},{1,0}}; - piece.anchor = {2,2}; - elseif (n == 17) then -- I vert - piece.pos = {{1,1},{1,2},{1,3},{1,4}}; - piece.rel = {{0,-2},{0,-1},{0,0},{0,1}}; - piece.anchor = {1,3}; - elseif (n == 18) then -- I horz - piece.pos = {{1,1},{2,1},{3,1},{4,1}}; - piece.rel = {{-2,0},{-1,0},{0,0},{1,0}}; - piece.anchor = {3,1}; - else - return nil; - end; - piece.id = n; - return piece; -end; - - -- 0,0 - 10,20 - -- translated it's: <95,40> to <175,200> - -- x starts at 1, y starts at 0... - -- each block is 8x8 -local areax = 95; -local areay = 40; -local blocksize = 8; - -while (true) do - -- get position of current piece (now) - local x = (memory.readbyte(0x0060)*blocksize)+areax; - local y = (memory.readbyte(0x0061)*blocksize)+areay; - local now = getPiece(memory.readbyte(0x0062)); -- get piece info - -- draw a nice box around it - gui.drawbox(95,40,175,200,"red"); - gui.text(5,5,"xy: <"..x..", "..y..">"); - if (now and x > 0 and y > 0 and x < 250 and y < 200) then - gui.drawbox(x+(now.rel[1][1]*blocksize),y+(now.rel[1][2]*blocksize),x+(now.rel[1][1]*blocksize)+blocksize,y+(now.rel[1][2]*blocksize)+blocksize,"green"); - gui.drawbox(x+(now.rel[2][1]*blocksize),y+(now.rel[2][2]*blocksize),x+(now.rel[2][1]*blocksize)+blocksize,y+(now.rel[2][2]*blocksize)+blocksize,"green"); - gui.drawbox(x+(now.rel[3][1]*blocksize),y+(now.rel[3][2]*blocksize),x+(now.rel[3][1]*blocksize)+blocksize,y+(now.rel[3][2]*blocksize)+blocksize,"green"); - gui.drawbox(x+(now.rel[4][1]*blocksize),y+(now.rel[4][2]*blocksize),x+(now.rel[4][1]*blocksize)+blocksize,y+(now.rel[4][2]*blocksize)+blocksize,"green"); - end; - gui.text(5,15,"Now: "..memory.readbyte(0x0062).."\nNext: "..memory.readbyte(0x00BF)); - - -- draw the filled field and do some counting - local start = 0x0400; -- toprow - local height = -1; - local filled = 0; - for j=0,19 do - for i=0,9 do - if (memory.readbyte(start+(j*10)+i) ~= 0xEF) then - filled = filled + 1; - if (height == -1) then height = j; end; - gui.drawbox(areax+(i*blocksize),areay+(j*blocksize),areax+(i*blocksize)+blocksize,areay+(j*blocksize)+blocksize,"red"); - end; - end; - end; - if (height == -1) then height = 0; - else height = 20 - height; end; - gui.text(5,30,"Height: "..height.."\nFilled: "..filled.." ("..math.floor(filled/(height)*10).."%)"); - - - --local inp1 = joypad.read(1); - --joypad.set(1,{right=1}); - FCEU.frameadvance(); -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/vnb.lua b/branches/sdl2/output/luaScripts/vnb.lua deleted file mode 100644 index f7791b0d..00000000 --- a/branches/sdl2/output/luaScripts/vnb.lua +++ /dev/null @@ -1,613 +0,0 @@ - --- Valkyrie no Bouken stuffs --- This game sucks, don't play it --- Lovingly based off of 4matsy's SMB code, and then mutilated and mamed as required --- Xkeeper 2008, September 12th - - -require("x_functions"); -x_requires(4); - - - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - - - -function mapdot(x,y,color) - if (x >= 1 and x <= 254 and y >= 1 and y <= 239) then - gui.drawline(x - 1, y , x + 1, y , color); - gui.drawline(x , y - 1, x , y + 2, color); - end; -end; - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function doexp() - - totalexp = vnbnumber(0x00d5, 5); - growth = memory.readbyte(0x0111); - level = memory.readbyte(0x00b9); - nextlv = memory.readbyte(0x00bb); - prevexp = -1; - - if level ~= 0 then - - if nextlv < 0x14 then - nextexp = exptable[nextlv + 1]; - else - prevexp = math.floor(totalexp / 10000) * 10000; - nextexp = math.floor(totalexp / 10000) * 10000 + 10000; - end; - - if growth < 3 and prevexp == -1 then --- prevexp = exptable[leveltable[growth][level] + 1]; - - end; - - expval = {}; - expval["level"] = level; - expval["next"] = nextexp - totalexp; - expval["prev"] = prevexp; - expval["pct"] = math.floor((totalexp - prevexp) / (nextexp - prevexp) * 100); - expval["exp"] = totalexp; - - if prevexp == -1 then - expval["pct"] = -1; - end; - - else - - expval = {}; - expval["level"] = 0; - expval["next"] = 0; - expval["prev"] = 0; - expval["pct"] = 0; - expval["exp"] = 0; - - end; - - return expval; -end; - - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function vnbnumber(offset, length) - val = 0; - - for i = 0, length do - inp = memory.readbyte(offset + (i)); - if (inp ~= 0x26) then val = val + inp * (10 ^ i); end; - end; - - return val; -end; - - - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function worldmap() - - herox = memory.readbyte(0x0080) + memory.readbyte(0x0081) * 256; -- hero's X position - heroy = memory.readbyte(0x0082) + memory.readbyte(0x0083) * 256; -- hero's current MP - - if mapstyle == 1 then - mapx = 8; - mapy = 9; - mapw = 60; - maph = 37; - elseif mapstyle == 2 or mapstyle == 3 then - - mapx = 8; - mapy = 34; - mapw = 240; - maph = 147; - - else - return nil; - end; - - if gamemode == 0x05 or gamemode == 0x01 or gamemode == 0x06 or gamemode == 0x08 then - - maphx = math.ceil(herox / 3840 * mapw); - maphy = math.ceil(heroy / 2352 * maph); - - --- filledbox(mapx - 1, mapy - 1, mapx + mapw + 1, mapy + maph, "#000000"); - box(mapx - 1, mapy - 1, mapx + mapw + 1, mapy + maph, "#ffffff"); - - if mapstyle == 3 then - for i = 0, 0xFF do - - mappx = math.ceil((3840 / 16) * math.fmod(i, 0x10) / 3840 * mapw); - mappy = math.ceil((2352 / 16) * math.floor(i / 0x10) / 2352 * maph); - mappx2 = math.ceil((3840 / 16) * (math.fmod(i, 0x10) + 1) / 3840 * mapw) - 1; - mappy2 = math.ceil((2352 / 16) * (math.floor(i / 0x10) + 1) / 2352 * maph) - 1; - tmp = memory.readbyte(0x81E5 + i) * 2; - filledbox(mapx + mappx, mapy + mappy, mapx + mappx2, mapy + mappy2, string.format("#%02x%02x%02x", tmp, tmp, tmp)); - - end; - end; - - if math.fmod(timer, 60) >= 30 then - color = "#888888"; - else - color = "#bbbbbb"; - end; - - --- line(mapx, mapy + maphy, mapx + mapw, mapy + maphy, "#cccccc"); --- line(mapx + maphx, mapy, mapx + maphx, mapy + maph, "#cccccc"); - - mapdist = 51; - for i = 1, mappoints do - mappx = math.ceil(mapdots[i]["x"] / 3840 * mapw); - mappy = math.ceil(mapdots[i]["y"] / 2352 * maph); - mapdot(mapx + mappx, mapy + mappy, mapdots[i]["color"]); - if mapdots[i]["name"] then - mapdotdist = math.abs(mapdots[i]["x"] - herox) + math.abs(mapdots[i]["y"] - heroy); - if mapdotdist < mapdist then - mapdist = mapdotdist; - mapdistn = mapdots[i]["name"]; - end; - end; - end; - - if mapdist <= 50 then - text(90, 17, mapdistn); - end; - filledbox(mapx + maphx - 0, mapy + maphy - 0, mapx + maphx + 0, mapy + maphy + 0, "#ffffff"); - box(mapx + maphx - 1, mapy + maphy - 1, mapx + maphx + 1, mapy + maphy + 1, color); - --- text(mapx + 0, mapy + maph + 2, string.format("%04d, %04d", herox, heroy)); - - - end; -end; - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function gameloop() - - if gamemode == 0x01 and math.fmod(timer, 60) >= 30 then - text(105, 180, "< DEMO >"); - end; - - - herohp = memory.readbyte(0x00c0) + memory.readbyte(0x00c1) * 256; -- hero's current HP - heromp = memory.readbyte(0x00c2) + memory.readbyte(0x00c3) * 256; -- hero's current MP - heromaxhp = memory.readbyte(0x00c4) + memory.readbyte(0x00c5) * 256; -- hero's maximum HP - heromaxmp = memory.readbyte(0x00c6) + memory.readbyte(0x00c7) * 256; -- hero's maximum MP - money = vnbnumber(0x00d0, 4); - gametime = memory.readbyte(0x0031) * 0x3c + memory.readbyte(0x0030); -- game-time - gamehour = math.floor(gametime / 320); - gameminute = math.floor((gametime - 320 * gamehour) / 320 * 60); - expval = doexp(); - - worldmap(); - - filledbox(96, 194, 255, 244, "#000000"); - - text(191, 8, string.format("Time: %02d:%02d", gamehour, gameminute)); --- text(188, 23, string.format("GameMode: %02x", gamemode)); - - text( 90, 194, string.format("HP %3d/%3d MP %3d/%3d", herohp, heromaxhp, heromp, heromaxmp)); - if expval["next"] > 0 then - text( 90, 218, string.format("Lv.%2d: %6d XP Next %6d", expval["level"], expval["exp"], expval["next"])); - else - text( 90, 218, string.format("Lv.%2d: %6d EXP", expval["level"], expval["exp"])); - end; - - - text(217, 202, string.format("ATK %2d", memory.readbyte(0x00e7))); - text(217, 210, string.format("$%5d", money)); - - - lifebar(191, 16, 60, 2, gamehour, 24, "#ffffff", "#777777", true); - lifebar(191, 20, 60, 0, gameminute, 60, "#cccccc", "#555555", true); - lifebar( 90, 202, 123, 4, herohp, heromaxhp, "#ffcc00", "#880000", true); - lifebar( 90, 208, 123, 3, heromp, heromaxmp, "#9999ff", "#0000dd", true); - - if expval["pct"] ~= -1 then - lifebar( 90, 226, 162, 2, expval["pct"], 100, "#ffffff", "#555555", true); - end; - - box(89, 194, 91, 244, "#000000"); - line(90, 194, 90, 244, "#000000"); - - - if not enemy then enemy = {} end; - - if gamemode == 0x05 or gamemode == 0x01 or gamemode == 0x06 then - for i = 0, 5 do - - offset = 0x500 + 0x10 * i; - - if not enemy[i] then - enemy[i] = {}; - end; - - if (memory.readbyte(offset) > 0) then - - if not enemy[i]["maxhp"] then enemy[i]["maxhp"] = 0 end; - - enemy[i]["t"] = memory.readbyte(offset); - enemy[i]["x"] = memory.readbyte(offset + 5); - enemy[i]["y"] = memory.readbyte(offset + 6); - enemy[i]["hp"] = memory.readbyte(offset + 15); - enemy[i]["maxhp"] = math.max(enemy[i]["maxhp"], enemy[i]["hp"]); - - enemy[i]["item"] = memory.readbyte(offset + 10); - - if enemy[i]["t"] > 1 then - text(enemy[i]["x"] - 9, enemy[i]["y"] - 16, enemy[i]["hp"] .."/".. enemy[i]["maxhp"]); - lifebar(enemy[i]["x"] - 5, enemy[i]["y"] - 8, 22, 0, enemy[i]["hp"], enemy[i]["maxhp"], "#ffcc00", "#dd0000", false); - else - if (enemy[i]["item"] == 0x1C) then - if enemy[i]["hp"] == 0 then enemy[i]["hp"] = 10 end; - if enemy[i]["hp"] == 9 then enemy[i]["hp"] = 99 end; - text(enemy[i]["x"] - 6 - math.min(math.floor(enemy[i]["hp"] / 10) * 2, 2), enemy[i]["y"] - 8, "$".. enemy[i]["hp"]); - else - box(enemy[i]["x"], enemy[i]["y"], enemy[i]["x"] + 15, enemy[i]["y"] + 15, "#ffffff"); - text(enemy[i]["x"] - string.len(itemlist[enemy[i]["item"]]) * 1.75 + 0, enemy[i]["y"] - 8, itemlist[enemy[i]["item"]]); - - end; - end; - - else - enemy[i] = {}; - - end; - end; - end; - - for i = 0, 7 do - offset = 0x0160 + 0x02 * i; - item = memory.readbyte(offset + 1); - uses = memory.readbyte(offset + 1); - xo = math.fmod(i, 4); - yo = math.floor(i / 4); - if (item > 0 and (uses > 0 and uses < 255)) then - text(xo * 12 + 8, 194 + yo * 16, uses); - end; - end; - - - - ---[[-- auto-regenerate HP - if (herohp < heromaxhp) and ((math.fmod(timer, 3) == 0) or true) then - herohp = herohp + 1; - memory.writebyte(0x00c0, math.fmod(herohp, 256)); - memory.writebyte(0x00c1, math.floor(herohp / 256)); - end; ---]]-- - - - ---[[ basically the Big Cheating Section. - - if not expbooster then expbooster = 0 end; - expbooster = expbooster + 1; - if expbooster >= 3 and gamemode == 0x06 then - expbooster = 0; - memory.writebyte(0x0d5, memory.readbyte(0x00d5) + 1); - - for i = 0,5 do - inp = memory.readbyte(0x00d5 + i); - if (inp == 0x0a) then - memory.writebyte(0x00d5 + (i + 1), memory.readbyte(0x00d5 + (i + 1)) + 1); - memory.writebyte(0x00d5 + i, 0); - - elseif (inp == 0x27) then - memory.writebyte(0x00d5 + i, 1); - - end; - end; - end; -]]-- -end; - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function charaselect() - asign = memory.readbyte(0x0110); - btype = memory.readbyte(0x0111); - --- line( 92, 30, 92, 130, "#ffffff"); - - - filledbox( 13, 48, 96, 64, "#000000"); -- cover JP text - filledbox( 13, 80, 96, 96, "#000000"); -- cover JP text - filledbox( 13, 112, 96, 128, "#000000"); -- cover JP text - filledbox(160, 48, 231, 64, "#000000"); -- cover JP text - - text( 74, 24, " Create your character "); - - text( 15, 51, "Astrological sign:"); - text(158, 51, string.format("%s", asigns[asign])); - - text( 41, 83, "Blood type:"); --- text(164, 83, string.format("%s (%X)", btypes[btype], btype)); - - text( 26, 115, "Clothing color:"); - - - asign2 = math.fmod(asign, 4); - if asign2 == 0 then - shp = 64; - smp = 32; - elseif asign2 == 1 then - shp = 48; - smp = 48; - elseif asign2 == 2 then - shp = 32; - smp = 64; - elseif asign2 == 3 then - shp = 33; - smp = 63; - end; - - strength = 10 + math.floor(shp / 32); - - text( 8, 135, "Starting HP: "); - text( 8, 143, "Starting MP: "); - text(167, 135, " ".. shp); - text(167, 143, " ".. smp); - lifebar( 68, 136, 100, 4, shp, 64, "#ffcc00", "#880000"); - lifebar( 68, 144, 100, 4, smp, 64, "#9999ff", "#0000dd"); - - text(194, 136, "Strength: ".. strength); - text(194, 146, "Magic:"); - if smp >= 60 then - text(204, 162, "Fireball"); - end; - if smp >= 40 then - text(204, 154, "Heal"); - end; - - - - graphx = 17; - graphy = 160; - - text(graphx - 10, graphy + 63, "Lv."); - - for i = 1, 12 do - thispointx = i * 15 + graphx; - line(thispointx, graphy, thispointx, graphy + 63, "#000088"); - text(thispointx - 4 - (string.len(string.format("%d", i)) - 1) * 3, graphy + 63, string.format("%d", i)); - end; - - - for i = 0, 7 do - lg = i * 3; - thispointy = graphy + 63 - (lg) * 3; - line(graphx + 15, thispointy, graphx + 180, thispointy, "#000088"); - - if exptable[lg] then - temp = string.format("%d", exptable[lg]); - text(graphx - 17, thispointy - 4, string.format("%5d", exptable[lg])); - end; - - end; - - line(graphx + 15, graphy , graphx + 15, graphy + 63, "#9999ff"); - line(graphx + 15, graphy + 63, graphx + 180, graphy + 63, "#9999ff"); - --- filledbox(graphx + 19, graphy + 1, graphx + 73, graphy + 8, "#666666"); - text(graphx + 16, graphy - 1, "EXP Growth"); - - if btype <= 2 then - - lastpointx = graphx; - lastpointy = graphy + 180; - for i = 1, 12 do - thispointx = i * 15 + graphx; - thispointy = graphy + 63 - (leveltable[btype][i] * 3); - line(lastpointx, lastpointy, thispointx, thispointy, "#ffffff"); - lastpointx = thispointx; - lastpointy = thispointy; - end; - - else - --- filledbox(graphx + 75, graphy + 27, graphx + 119, graphy + 35, "#666666"); - text(graphx + 74, graphy + 26, " Random "); - - - end; - - line(194, 145, 254, 145, "#000000"); - line( 8, 153, 192, 153, "#000000"); - -end; - - - - - --- ************************************************************************************ --- ************************************************************************************ --- ************************************************************************************ - -function keyintercept() - tmp = memory.readbyte(0x0026); - - if AND(tmp, 0x04) == 0x04 then - mapstyle = math.fmod(mapstyle + 1, 3) - end; - --- memory.writebyte(0x0026, AND(tmp, 0xFB)); -end; - -memory.register(0x0026, keyintercept); - - - - - - - - -timer = 0; -mapstyle = 1; -- 0 = hidden, 1 = mini, 2 = bigmap -gamemode = 0; - -itemlist = {}; -itemlist[0x01] = "Lantrn"; -itemlist[0x02] = "Lantrn2"; -itemlist[0x03] = "Potion"; -itemlist[0x04] = "Potion2"; -itemlist[0x05] = "Antidt"; -itemlist[0x06] = "Antidt2"; -itemlist[0x07] = "Key"; -itemlist[0x08] = "GoldKey"; -itemlist[0x09] = "Ax"; -itemlist[0x0a] = "Ax2"; -itemlist[0x0b] = "Sword"; -itemlist[0x0c] = "Sword2"; -itemlist[0x0d] = "PwSword"; -itemlist[0x0e] = "PwSword2"; -itemlist[0x0f] = "MsSword"; -itemlist[0x10] = "SandraSl"; -itemlist[0x11] = "Mantle"; -itemlist[0x12] = "Mantle2"; -itemlist[0x13] = "Helmet"; -itemlist[0x14] = "Helmet2"; -itemlist[0x15] = "Tent"; -itemlist[0x16] = "Tent2"; -itemlist[0x17] = "Tiara"; -itemlist[0x18] = "Whale"; -itemlist[0x19] = "CureAll"; -itemlist[0x1a] = "TimeKey"; -itemlist[0x1b] = "Ship"; -itemlist[0x1c] = "Cash"; - -exptable = { - 0, - 20, - 50, - 90, - 150, - 230, - 350, - 510, - 750, - 1100, - 1600, - 2200, - 3200, - 4400, - 6400, - 9000, - 12000, - 15000, - 20000, - 30000, - 40000, - 50000, - }; - -leveltable = {}; -leveltable[0] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x13, 0x14}; -leveltable[1] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x07, 0x0A, 0x0D, 0x10, 0x13, 0x14, 0x15}; -leveltable[2] = { 0x00, 0x03, 0x06, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}; - -asigns = {}; -asigns[0x00] = "Aries"; -asigns[0x01] = "Taurus"; -asigns[0x02] = "Gemini"; -asigns[0x03] = "Cancer"; -asigns[0x04] = "Leo"; -asigns[0x05] = "Virgo"; -asigns[0x06] = "Libra"; -asigns[0x07] = "Scorpio"; -asigns[0x08] = "Sagittarius"; -asigns[0x09] = "Capricorn"; -asigns[0x0A] = "Aquarius"; -asigns[0x0B] = "Pisces"; - -btypes = {}; -btypes[0x00] = "A"; -btypes[0x01] = "B"; -btypes[0x02] = "O"; -btypes[0x03] = "AB"; - - -mapdots = {}; -mapdots[1] = {x = 996, y = 1888, color = "#4444ff"}; -- house -mapdots[2] = {x = 773, y = 989, color = "#4444ff"}; -- house - -mapdots[3] = {x = 266, y = 2263, color = "#00ff00"}; -- warp point -mapdots[4] = {x = 1800, y = 216, color = "#00ff00"}; -- warp point -mapdots[5] = {x = 776, y = 344, color = "#00ff00"}; -- warp point -mapdots[6] = {x = 2055, y = 2008, color = "#00ff00"}; -- warp point - -mapdots[7] = {x = 1863, y = 2045, color = "#dd0000", name = "South Pyramid"}; -- s.pyramid -mapdots[8] = {x = 1607, y = 381, color = "#dd0000", name = "North Pyramid"}; -- n.pyramid - - - -mappoints = table.maxn(mapdots); - -while (true) do - - - timer = timer +1; -- timer for script events - - gamemode = memory.readbyte(0x0029); -- game mode - - - if gamemode == 0x05 or gamemode == 0x01 or gamemode == 0x06 or gamemode == 0x08 then - gameloop(); - - elseif gamemode == 0x02 then - charaselect(); - else - --- gametime = memory.readbyte(0x0031) * 0x3c + memory.readbyte(0x0030); -- game-time --- gamehour = math.floor(gametime / 320); --- gameminute = math.floor((gametime - 320 * gamehour) / 320 * 60); - - gametimer1 = memory.readbyte(0x0031); - gametimer2 = memory.readbyte(0x0030); - - text(190, 8, string.format("Timer: %02X %02X", gametimer1, gametimer2)); - text(189, 23, string.format("GameMode: %02x", gamemode)); - lifebar(191, 16, 60, 2, gametimer1, 0x80, "#ffffff", "#777777", true); - lifebar(191, 20, 60, 0, gametimer2, 0x3c, "#cccccc", "#555555", true); - end; - - FCEU.frameadvance(); - -end; diff --git a/branches/sdl2/output/luaScripts/x_functions.lua b/branches/sdl2/output/luaScripts/x_functions.lua deleted file mode 100644 index a6d01c24..00000000 --- a/branches/sdl2/output/luaScripts/x_functions.lua +++ /dev/null @@ -1,262 +0,0 @@ - -x_func_version = 6; - ---[[ - Minor version history: - - v5 ----------- - - Added Bisqwit's 'clone table' function. - - v6 ----------- - - added pairs by keys - - added hitbox functions - - - -]] - - - - --- Draws a line from x1,y1 to x2,y2 using color - -function line(x1,y1,x2,y2,color) - if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then - local success = pcall(function() gui.drawline(x1,y1,x2,y2,color) end); - if not success then - text(60, 224, "ERROR: ".. x1 ..",".. y1 .." ".. x2 ..",".. y2); - end; - end; -end; - - --- Puts text on-screen (duh) -function text(x,y,str) - if str == nil then - str = "nil"; - end; - if (x >= 0 and x <= 255 and y >= 0 and y <= 240) then - gui.text(x,y,str); - end; -end; - --- Sets the pixel at x, y to color -function pixel(x,y,color) - if (x >= 0 and x <= 255 and y >= 0 and y <= 240) then - gui.drawpixel(x,y,color); - end; -end; - - --- Draws a rectangle from x1,y1 to x2, y2 -function box(x1,y1,x2,y2,color) - if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then ---[[ local success = pcall(function() gui.drawbox(x1,y1,x2,y2,color); end); - if not success then - text(60, 150, string.format("%3d %3d %3d %3d", x1, y1, x2, y2)); - FCEU.pause(); - end; -]] gui.drawbox(x1,y1,x2,y2,color); - end; -end; - - --- Draws a filled box from x1, y1 to x2, y2 (warning: can be slow if drawing large boxes) -function filledbox(x1,y1,x2,y2,color) - for i = 0, math.abs(y1 - y2) do - line(x1,y1 + i,x2,y1 + i,color); - end; -end; - - - --- Draws a life-bar. --- x, y: position of top-right --- sx, sy: width and height of ACTUAL BAR (0 is the smallest height (1px)) --- a1, a2: Amounts (a1/a2*100 = % of bar filled) --- oncolor, offcolor: "bar", "background" --- noborder: set to "true" if you just want a black outline without the white - -function lifebar(x, y, sx, sy, a1, a2, oncolor, offcolor, outerborder, innerborder) - -- this function will have the effect of drawing an HP bar - -- keep in mind xs and ys are 2px larger to account for borders - - x1 = x; - x2 = x + sx + 4; - y1 = y; - y2 = y + sy + 4; - w = math.floor(a1 / math.max(1, a1, a2) * sx); - if not a2 then w = 0 end; - - outer = outerborder; - inner = innerborder; - - if (outer == true or outer == false) and (inner == nil) then - -- legacy - outer = nil; - inner = "#000000"; - - elseif outer == nil and inner == nil then - outer = "#000000"; - inner = "#ffffff"; - - elseif inner == nil then - inner = "#ffffff"; - end; - - if (inner) then - box(x1 + 1, y1 + 1, x2 - 1, y2 - 1, inner); - end; - if (outer) then - box(x1 , y1 , x2 , y2 , outer); - end; - - if (w < sx) then - filledbox(x1 + w + 2, y1 + 2, x2 - 2, y2 - 2, offcolor); - end; - - if (w > 0) then - filledbox(x1 + 2, y1 + 2, x1 + 2 + w, y2 - 2, oncolor); - end; - -end; - - - -function graph(x, y, sx, sy, minx, miny, maxx, maxy, xval, yval, color, border, filled) - - - if (filled ~= nil) then - filledbox(x + 1, y + 1, x+sx, y+sy, "#000000"); - end; - if (border ~= nil) then - box(x, y, x+sx+1, y+sy+1, color); - end; - - - xp = (xval - minx) / (maxx - minx) * sx; - yp = (yval - miny) / (maxy - miny) * sy; - - line(x + 1 , yp + y + 1, x + sx + 1, yp + y + 1, color); - line(xp + x + 1, y + 1 , xp + x + 1, y + sy + 1, color); - - return true; -end; - - --- Bisqwit's clone table feature. -table.clone = function(table) - local res = {} - for k,v in pairs(table)do - res[k]=v - end - return res -end - -spairs = function (t, f) - local a = {} - for n in pairs(t) do table.insert(a, n) end - table.sort(a, f) - local i = 0 -- iterator variable - local iter = function () -- iterator function - i = i + 1 - if a[i] == nil then return nil - else return a[i], t[a[i]] - end - end - return iter -end - - --- **************************************************************************** --- * hitbox( coords1, coords2, con, coff ) --- * Checks if any point of coords1 is within coords2. --- * con/coff determine what colors of box to draw. --- **************************************************************************** -function hitbox(b1x1, b1y1, b1x2, b1y2, b2x1, b2y1, b2x2, b2y2, con, coff) - - if not b1x1 then - text(0, 8, "ERROR!!!!"); - return; - end; - - local noboxes = false; - if con == nil and coff == nil then - noboxes = true; - else - if coff == nil then - coff = "#00ff00" - end; - - if con == nil then - con = "#dd0000"; - end; - if coff == nil then - coff = "#00ff00" - end; - end; - - boxes = {{ - x = {b1x1, b1x2}, - y = {b1y1, b1y2}, - }, { - x = {b2x1, b2x2}, - y = {b2y1, b2y2}, - }}; - - hit = false; - - for xc = 1, 2 do - for yc = 1, 2 do - - if (boxes[1]['x'][xc] >= boxes[2]['x'][1]) and - (boxes[1]['y'][yc] >= boxes[2]['y'][1]) and - (boxes[1]['x'][xc] <= boxes[2]['x'][2]) and - (boxes[1]['y'][yc] <= boxes[2]['y'][2]) then - - hit = true; - -- TODO: make this break out of the for loop? might not be worth it - end; - end; - end; - - if hit == true then - if not noboxes then box(b2x1, b2y1, b2x2, b2y2, con); end; - return true; - else - if not noboxes then box(b2x1, b2y1, b2x2, b2y2, coff); end; - return false; - end; - - return true; - -end; - - - -function x_requires(required) - -- Sanity check. If they require a newer version, let them know. - timer = 1; - if x_func_version < required then - - while (true) do - timer = timer + 1; - - for i = 0, 32 do - box( 6, 28 + i, 250, 92 - i, "#000000"); - end; - - text( 10, 32, string.format("This Lua script requires version %02d or greater.", required)); - text( 43, 42, string.format("Your x_functions.lua is version %02d.", x_func_version)); - text( 29, 58, "Please check for an updated version at"); - text( 14, 69, "http://xkeeper.shacknet.nu:5/"); - text(114, 78, "emu/nes/lua/x_functions.lua"); - - warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF)); - box(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor); - - FCEU.frameadvance(); - end; - - end; -end; \ No newline at end of file diff --git a/branches/sdl2/output/luaScripts/x_interface.lua b/branches/sdl2/output/luaScripts/x_interface.lua deleted file mode 100644 index b2b333c9..00000000 --- a/branches/sdl2/output/luaScripts/x_interface.lua +++ /dev/null @@ -1,116 +0,0 @@ --- **************************************************************************** --- * --- * FCEUX Lua GUI tools --- * --- **************************************************************************** - - -control = {}; - -last = {}; -inpt = { xmouse = 0, ymouse = 0 }; - --- **************************************************************************** --- * input.update() --- * Updates input changes and calculates mouse movement averages. --- **************************************************************************** -function input.update() - - last = table.clone(inpt); - inpt = input.get(); - -end; - - --- **************************************************************************** --- * control.button( xpos, ypos, width, height, t ) --- * Draws a button that can have some effect. Not quite implemented yet! --- * width/height are for the outline and more or less have to be set manually. --- * since height is fixed, though, it's always a multiple. --- * c disables hitbox checking and sets the outline to that color --- **************************************************************************** -function control.button(x, y, w, h, t, c, sc) - local h = h * 8; - filledbox( x , y , x + w , y + h , "#000000"); - text(x - 1, y - 1, t); -- Yeah, for some reason... - - if c and not sc then - box( x - 1, y - 1, x + w + 1, y + h + 1, c); - elseif c then - return (hitbox(inpt['xmouse'], inpt['ymouse'], inpt['xmouse'], inpt['ymouse'], x - 1, y - 1, x + w + 1, y + h + 1, c, c) and (inpt['leftclick'] and not last['leftclick'])); - - elseif hitbox(inpt['xmouse'], inpt['ymouse'], inpt['xmouse'], inpt['ymouse'], x - 1, y - 1, x + w + 1, y + h + 1, "#6666ff", "#0000ff") and (inpt['leftclick'] and not last['leftclick']) then - box(x - 1, y - 1, x + w + 1, y + h + 1, "#ffffff"); -- for white-flash highlighting - return true; - end; - return false; - -end; - - - --- **************************************************************************** --- * control.showmenu( xpos, ypos, menutable ) --- * Displays the given menu and takes action on it. Usually. --- **************************************************************************** -function control.showmenu(x, y, menuinfo) - - - if menuinfo['life'] > 0 then - local temp = 0; - local i = 0; - local yscale = 11 - math.max(0, menuinfo['life'] - 60); --- text(x, y - 11, string.format("Life: %3d", menuinfo['life'])); - - for k, v in spairs(menuinfo['menu']) do - - local buttoncolor = nil; - if v['menu'] and v['life'] > 0 then - buttoncolor = "#ffffff"; - end; - - buttonclicked = control.button(x, y + yscale * i, menuinfo['width'], 1, v['label'], buttoncolor, true); - if v['menu'] then - text(x + menuinfo['width'] - 6, y + yscale * i - 1, ">"); - end; - if v['marked'] == 1 then - text(x, y + yscale * i - 1, ">"); - end; - - -- is a selection, not a submenu - if buttonclicked and v['action'] then - v['action'](v['args']); - menuinfo['life'] = 0; - return -1; - - -- a submenu - elseif buttonclicked and v['menu'] then - v['life'] = 70; - end; - - if v['menu'] and v['life'] > 0 and temp >= 0 then - temp2 = control.showmenu(x + menuinfo['width'] + 3, y + yscale * i, v); - if temp2 >= 0 then - temp = math.max(temp, temp2); - else - temp = temp2; - end; - end; - - i = i + 1; - - end; - if temp >= 0 and hitbox(inpt['xmouse'], inpt['ymouse'], inpt['xmouse'], inpt['ymouse'], x, y, x + menuinfo['width'] + 2, y + i * yscale) then - menuinfo['life'] = math.max(menuinfo['life'] - 1, 60); - elseif temp == -1 or (menuinfo['life'] < 60 and inpt['leftclick'] and not last['leftclick']) then - menuinfo['life'] = 0; - return 0; - else - menuinfo['life'] = math.max(math.min(60, temp), menuinfo['life'] - 1); - end; - end; - - return menuinfo['life']; - -end; - diff --git a/branches/sdl2/output/luaScripts/x_smb1enemylist.lua b/branches/sdl2/output/luaScripts/x_smb1enemylist.lua deleted file mode 100644 index 661aa7e0..00000000 --- a/branches/sdl2/output/luaScripts/x_smb1enemylist.lua +++ /dev/null @@ -1,44 +0,0 @@ --- temporary file because this will be huge. - -handles = {}; - -handles[ 1] = { x1 = 0, y1 = 0, x2 = 16, y2 = 24 }; -- Green & Red Koopa -handles[ 2] = { x1 = 0, y1 = 8, x2 = 16, y2 = 24 }; -- Goomba -handles[ 3] = { x1 = 0, y1 = 0, x2 = 16, y2 = 16 }; -- generic 16x16 -handles[ 4] = { x1 = 0, y1 = 0, x2 = 8, y2 = 8 }; -- generic 8x 8 - - -enemylist = {}; - --- type: --- Default (0): selectable, standard --- + 0x01: requires special handling --- + 0x02: can't be selected (dupe, whatever) --- + 0x10: requires two spaces to summon --- + 0x20: powerup ---[[ -enemylist[] = { id = 0x00, name = "Green Koopa", handle = 1, hitbox = 0x03, type = 0x00 }; -enemylist[] = { id = 0x01, name = "Red Koopa", handle = 1, hitbox = 0x03, type = 0x01 }; -- Will jitter back and forth if moved into air - -enemylist[] = { id = 0x06, name = "Goomba", handle = 2, hitbox = 0x09, type = 0x00 }; -enemylist[] = { id = 0x07, name = "Blooper", handle = 1, hitbox = 0x09, type = 0x01 }; -- Uhh? It just vanishes out of nowhere... - -enemylist[] = { id = 0x0A, name = "Gray Cheep-Cheep", handle = 2, hitbox = 0x09, type = 0x00 }; -enemylist[] = { id = 0x0B, name = "Red Cheep-Cheep", handle = 2, hitbox = 0x09, type = 0x00 }; - -enemylist[] = { id = 0x0D, name = "Pirahna Plant", handle = 1, hitbox = 0x09, type = 0x01 }; -- x speed is really y speed, main position needs hacked -enemylist[] = { id = 0x0E, name = "Green Paratroopa", handle = 1, hitbox = 0x03, type = 0x00 }; - -enemylist[] = { id = 0x14, name = "Flying Cheepcheep", handle = 2, hitbox = 0x09, type = 0x00 }; - - -enemylist[] = { id = 0x2E, name = "Mushroom", handle = 3, hitbox = 0x03, type = 0x20, powerupval = 0x00 }; -enemylist[] = { id = 0x2E, name = "Flower", handle = 3, hitbox = 0x03, type = 0x20, powerupval = 0x01 }; -enemylist[] = { id = 0x2E, name = "Starman", handle = 3, hitbox = 0x03, type = 0x20, powerupval = 0x02 }; -enemylist[] = { id = 0x2E, name = "1-up Mushroom", handle = 3, hitbox = 0x03, type = 0x20, powerupval = 0x03 }; -enemylist[] = { id = 0x30, name = "Flagpole flag", handle = 3, hitbox = -1, type = 0x20 }; -enemylist[] = { id = 0x31, name = "Castle flag", handle = 3, hitbox = -1, type = 0x00 }; -enemylist[] = { id = 0x32, name = "Springboard", handle = 1, hitbox = -1, type = 0x00 }; - - -]] \ No newline at end of file diff --git a/branches/sdl2/output/palettes/ASQ_realityA.pal b/branches/sdl2/output/palettes/ASQ_realityA.pal deleted file mode 100644 index 8c935870..00000000 Binary files a/branches/sdl2/output/palettes/ASQ_realityA.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/ASQ_realityB.pal b/branches/sdl2/output/palettes/ASQ_realityB.pal deleted file mode 100644 index 1d36d597..00000000 Binary files a/branches/sdl2/output/palettes/ASQ_realityB.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/BMF_final2.pal b/branches/sdl2/output/palettes/BMF_final2.pal deleted file mode 100644 index 01fd7161..00000000 Binary files a/branches/sdl2/output/palettes/BMF_final2.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/BMF_final3.pal b/branches/sdl2/output/palettes/BMF_final3.pal deleted file mode 100644 index d1560114..00000000 Binary files a/branches/sdl2/output/palettes/BMF_final3.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/FCEU-13-default_nitsuja.pal b/branches/sdl2/output/palettes/FCEU-13-default_nitsuja.pal deleted file mode 100644 index 9367073b..00000000 Binary files a/branches/sdl2/output/palettes/FCEU-13-default_nitsuja.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/FCEU-15-nitsuja_new.pal b/branches/sdl2/output/palettes/FCEU-15-nitsuja_new.pal deleted file mode 100644 index 4765e546..00000000 Binary files a/branches/sdl2/output/palettes/FCEU-15-nitsuja_new.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/FCEUX.pal b/branches/sdl2/output/palettes/FCEUX.pal deleted file mode 100644 index 7bf9128f..00000000 Binary files a/branches/sdl2/output/palettes/FCEUX.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/nestopia_rgb.pal b/branches/sdl2/output/palettes/nestopia_rgb.pal deleted file mode 100644 index d2d3d923..00000000 Binary files a/branches/sdl2/output/palettes/nestopia_rgb.pal and /dev/null differ diff --git a/branches/sdl2/output/palettes/nestopia_yuv.pal b/branches/sdl2/output/palettes/nestopia_yuv.pal deleted file mode 100644 index 4bb868ec..00000000 Binary files a/branches/sdl2/output/palettes/nestopia_yuv.pal and /dev/null differ diff --git a/branches/sdl2/output/taseditor.chm b/branches/sdl2/output/taseditor.chm deleted file mode 100644 index c0318726..00000000 Binary files a/branches/sdl2/output/taseditor.chm and /dev/null differ diff --git a/branches/sdl2/output/tools/taseditor_patterns.txt b/branches/sdl2/output/tools/taseditor_patterns.txt deleted file mode 100644 index a584bd4b..00000000 --- a/branches/sdl2/output/tools/taseditor_patterns.txt +++ /dev/null @@ -1,15 +0,0 @@ -Alternating (1010...) -10 -Alternating at 30FPS (11001100...) -1100 -One Quarter (10001000...) -1000 -Tap'n'Hold (101111111...) -1011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -One-Two (1011010110...) -10110 - -FORMAT OF THIS FILE: 2 lines per every Pattern - first line is the name, second line is looped sequence of presses: 1 = press button, 0 = don't press button. - - - diff --git a/branches/sdl2/src/.gitignore b/branches/sdl2/src/.gitignore deleted file mode 100644 index 7061d616..00000000 --- a/branches/sdl2/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/fceu diff --git a/branches/sdl2/src/SConscript b/branches/sdl2/src/SConscript deleted file mode 100644 index 4713e155..00000000 --- a/branches/sdl2/src/SConscript +++ /dev/null @@ -1,42 +0,0 @@ -import glob -file_list = glob.glob('*.cpp') -file_list.remove('lua-engine.cpp') # use logic below for this - -subdirs = Split(""" -boards -drivers/common -fir -input -utils -""") -#palettes - -Import('env') -Export('env') - -if env['LUA']: - file_list.append('lua-engine.cpp') - if env['SYSTEM_LUA'] == 0: - subdirs.append('lua') - -if env['CREATE_AVI']: - subdirs.append('drivers/videolog') - - - -for dir in subdirs: - subdir_files = SConscript('%s/SConscript' % dir) - file_list.append(subdir_files) -if env['PLATFORM'] == 'win32': - platform_files = SConscript('drivers/win/SConscript') -else: - platform_files = SConscript('drivers/sdl/SConscript') -file_list.append(platform_files) - -print env['LINKFLAGS'] - -if env['PLATFORM'] == 'win32': - fceux = env.Program('fceux.exe', file_list) -else: - fceux = env.Program('fceux', file_list) -Return('fceux') diff --git a/branches/sdl2/src/asm.cpp b/branches/sdl2/src/asm.cpp deleted file mode 100644 index 5131a14d..00000000 --- a/branches/sdl2/src/asm.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/// \file -/// \brief 6502 assembler and disassembler - -#include "types.h" -#include "utils/xstring.h" -#include "debug.h" -#include "asm.h" -#include "x6502.h" - -#include -#include -#include -///assembles the string to an instruction located at addr, storing opcodes in output buffer -int Assemble(unsigned char *output, int addr, char *str) { - //unsigned char opcode[3] = { 0,0,0 }; - output[0] = output[1] = output[2] = 0; - char astr[128],ins[4]; - int len = strlen(str); - if ((!len) || (len > 0x127)) return 1; - - strcpy(astr,str); - str_ucase(astr); - sscanf(astr,"%3s",ins); //get instruction - if (strlen(ins) != 3) return 1; - strcpy(astr,strstr(astr,ins)+3); //heheh, this is probably a bad idea, but let's do it anyway! - if ((astr[0] != ' ') && (astr[0] != 0)) return 1; - - //remove all whitespace - str_strip(astr,STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF); - - //repair syntax - chr_replace(astr,'[','('); //brackets - chr_replace(astr,']',')'); - chr_replace(astr,'{','('); - chr_replace(astr,'}',')'); - chr_replace(astr,';',0); //comments - str_replace(astr,"0X","$"); //miscellaneous - - //This does the following: - // 1) Sets opcode[0] on success, else returns 1. - // 2) Parses text in *astr to build the rest of the assembled - // data in 'opcode', else returns 1 on error. - - if (!strlen(astr)) { - //Implied instructions - if (!strcmp(ins,"BRK")) output[0] = 0x00; - else if (!strcmp(ins,"PHP")) output[0] = 0x08; - else if (!strcmp(ins,"ASL")) output[0] = 0x0A; - else if (!strcmp(ins,"CLC")) output[0] = 0x18; - else if (!strcmp(ins,"PLP")) output[0] = 0x28; - else if (!strcmp(ins,"ROL")) output[0] = 0x2A; - else if (!strcmp(ins,"SEC")) output[0] = 0x38; - else if (!strcmp(ins,"RTI")) output[0] = 0x40; - else if (!strcmp(ins,"PHA")) output[0] = 0x48; - else if (!strcmp(ins,"LSR")) output[0] = 0x4A; - else if (!strcmp(ins,"CLI")) output[0] = 0x58; - else if (!strcmp(ins,"RTS")) output[0] = 0x60; - else if (!strcmp(ins,"PLA")) output[0] = 0x68; - else if (!strcmp(ins,"ROR")) output[0] = 0x6A; - else if (!strcmp(ins,"SEI")) output[0] = 0x78; - else if (!strcmp(ins,"DEY")) output[0] = 0x88; - else if (!strcmp(ins,"TXA")) output[0] = 0x8A; - else if (!strcmp(ins,"TYA")) output[0] = 0x98; - else if (!strcmp(ins,"TXS")) output[0] = 0x9A; - else if (!strcmp(ins,"TAY")) output[0] = 0xA8; - else if (!strcmp(ins,"TAX")) output[0] = 0xAA; - else if (!strcmp(ins,"CLV")) output[0] = 0xB8; - else if (!strcmp(ins,"TSX")) output[0] = 0xBA; - else if (!strcmp(ins,"INY")) output[0] = 0xC8; - else if (!strcmp(ins,"DEX")) output[0] = 0xCA; - else if (!strcmp(ins,"CLD")) output[0] = 0xD8; - else if (!strcmp(ins,"INX")) output[0] = 0xE8; - else if (!strcmp(ins,"NOP")) output[0] = 0xEA; - else if (!strcmp(ins,"SED")) output[0] = 0xF8; - else return 1; - } - else { - //Instructions with Operands - if (!strcmp(ins,"ORA")) output[0] = 0x01; - else if (!strcmp(ins,"ASL")) output[0] = 0x06; - else if (!strcmp(ins,"BPL")) output[0] = 0x10; - else if (!strcmp(ins,"JSR")) output[0] = 0x20; - else if (!strcmp(ins,"AND")) output[0] = 0x21; - else if (!strcmp(ins,"BIT")) output[0] = 0x24; - else if (!strcmp(ins,"ROL")) output[0] = 0x26; - else if (!strcmp(ins,"BMI")) output[0] = 0x30; - else if (!strcmp(ins,"EOR")) output[0] = 0x41; - else if (!strcmp(ins,"LSR")) output[0] = 0x46; - else if (!strcmp(ins,"JMP")) output[0] = 0x4C; - else if (!strcmp(ins,"BVC")) output[0] = 0x50; - else if (!strcmp(ins,"ADC")) output[0] = 0x61; - else if (!strcmp(ins,"ROR")) output[0] = 0x66; - else if (!strcmp(ins,"BVS")) output[0] = 0x70; - else if (!strcmp(ins,"STA")) output[0] = 0x81; - else if (!strcmp(ins,"STY")) output[0] = 0x84; - else if (!strcmp(ins,"STX")) output[0] = 0x86; - else if (!strcmp(ins,"BCC")) output[0] = 0x90; - else if (!strcmp(ins,"LDY")) output[0] = 0xA0; - else if (!strcmp(ins,"LDA")) output[0] = 0xA1; - else if (!strcmp(ins,"LDX")) output[0] = 0xA2; - else if (!strcmp(ins,"BCS")) output[0] = 0xB0; - else if (!strcmp(ins,"CPY")) output[0] = 0xC0; - else if (!strcmp(ins,"CMP")) output[0] = 0xC1; - else if (!strcmp(ins,"DEC")) output[0] = 0xC6; - else if (!strcmp(ins,"BNE")) output[0] = 0xD0; - else if (!strcmp(ins,"CPX")) output[0] = 0xE0; - else if (!strcmp(ins,"SBC")) output[0] = 0xE1; - else if (!strcmp(ins,"INC")) output[0] = 0xE6; - else if (!strcmp(ins,"BEQ")) output[0] = 0xF0; - else return 1; - - { - //Parse Operands - // It's not the sexiest thing ever, but it works well enough! - - //TODO: - // Add branches. - // Fix certain instructions. (Setting bits is not 100% perfect.) - // Fix instruction/operand matching. (Instructions like "jmp ($94),Y" are no good!) - // Optimizations? - int tmpint; - char tmpchr,tmpstr[20]; - - if (sscanf(astr,"#$%2X%c",&tmpint,&tmpchr) == 1) { //#Immediate - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of #Immediate - case 0x66: case 0x81: case 0x84: case 0x86: - case 0xC6: case 0xE6: - return 1; - default: - //cheap hack for certain instructions - switch (output[0]) { - case 0xA0: case 0xA2: case 0xC0: case 0xE0: - break; - default: - output[0] |= 0x08; - break; - } - output[1] = tmpint; - break; - } - } - else if (sscanf(astr,"$%4X%c",&tmpint,&tmpchr) == 1) { //Absolute, Zero Page, Branch, or Jump - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - break; - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - tmpint -= (addr+2); - if ((tmpint < -128) || (tmpint > 127)) return 1; - output[1] = (tmpint & 0xFF); - break; - //return 1; //FIX ME - default: - if (tmpint > 0xFF) { //Absolute - output[0] |= 0x0C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - output[0] |= 0x04; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else if (sscanf(astr,"$%4X%s",&tmpint,tmpstr) == 2) { //Absolute,X, Zero Page,X, Absolute,Y or Zero Page,Y - if (!strcmp(tmpstr,",X")) { //Absolute,X or Zero Page,X - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x24: case 0x86: case 0xA2: case 0xC0: //Other instructions incapable of Absolute,X or Zero Page,X - case 0xE0: - return 1; - default: - if (tmpint > 0xFF) { //Absolute - if (output[0] == 0x84) return 1; //No STY Absolute,X! - output[0] |= 0x1C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - output[0] |= 0x14; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else if (!strcmp(tmpstr,",Y")) { //Absolute,Y or Zero Page,Y - switch (output[0]) { - case 0x20: case 0x4C: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Absolute,Y or Zero Page,Y - case 0x66: case 0x84: case 0x86: case 0xA0: - case 0xC0: case 0xC6: case 0xE0: case 0xE6: - return 1; - case 0xA2: //cheap hack for LDX - output[0] |= 0x04; - default: - if (tmpint > 0xFF) { //Absolute - if (output[0] == 0x86) return 1; //No STX Absolute,Y! - output[0] |= 0x18; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else { //Zero Page - if ((output[0] != 0x86) && (output[0] != 0xA2)) return 1; //only STX and LDX Absolute,Y! - output[0] |= 0x10; - output[1] = (tmpint & 0xFF); - } - break; - } - } - else return 1; - } - else if (sscanf(astr,"($%4X%s",&tmpint,tmpstr) == 2) { //Jump (Indirect), (Indirect,X) or (Indirect),Y - switch (output[0]) { - case 0x20: //Jumps - case 0x10: case 0x30: case 0x50: case 0x70: //Branches - case 0x90: case 0xB0: case 0xD0: case 0xF0: - case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Jump (Indirect), (Indirect,X) or (Indirect),Y - case 0x66: case 0x84: case 0x86: case 0xA0: - case 0xA2: case 0xC0: case 0xC6: case 0xE0: - case 0xE6: - return 1; - default: - if ((!strcmp(tmpstr,")")) && (output[0] == 0x4C)) { //Jump (Indirect) - output[0] = 0x6C; - output[1] = (tmpint & 0xFF); - output[2] = (tmpint >> 8); - } - else if ((!strcmp(tmpstr,",X)")) && (tmpint <= 0xFF) && (output[0] != 0x4C)) { //(Indirect,X) - output[1] = (tmpint & 0xFF); - } - else if ((!strcmp(tmpstr,"),Y")) && (tmpint <= 0xFF) && (output[0] != 0x4C)) { //(Indirect),Y - output[0] |= 0x10; - output[1] = (tmpint & 0xFF); - } - else return 1; - break; - } - } - else return 1; - } - } - - return 0; -} - -///disassembles the opcodes in the buffer assuming the provided address. Uses GetMem() and 6502 current registers to query referenced values. returns a static string buffer. -char *Disassemble(int addr, uint8 *opcode) { - static char str[64]={0},chr[5]={0}; - uint16 tmp,tmp2; - - //these may be replaced later with passed-in values to make a lighter-weight disassembly mode that may not query the referenced values - #define RX (X.X) - #define RY (X.Y) - - switch (opcode[0]) { - #define relative(a) { \ - if (((a)=opcode[1])&0x80) (a) = addr-(((a)-1)^0xFF); \ - else (a)+=addr; \ - } - #define absolute(a) { \ - (a) = opcode[1] | opcode[2]<<8; \ - } - #define zpIndex(a,i) { \ - (a) = opcode[1]+(i); \ - } - #define indirectX(a) { \ - (a) = (opcode[1]+RX)&0xFF; \ - (a) = GetMem((a)) | (GetMem((a)+1))<<8; \ - } - #define indirectY(a) { \ - (a) = GetMem(opcode[1]) | (GetMem(opcode[1]+1))<<8; \ - (a) += RY; \ - } - - - //odd, 1-byte opcodes - case 0x00: strcpy(str,"BRK"); break; - case 0x08: strcpy(str,"PHP"); break; - case 0x0A: strcpy(str,"ASL"); break; - case 0x18: strcpy(str,"CLC"); break; - case 0x28: strcpy(str,"PLP"); break; - case 0x2A: strcpy(str,"ROL"); break; - case 0x38: strcpy(str,"SEC"); break; - case 0x40: strcpy(str,"RTI"); break; - case 0x48: strcpy(str,"PHA"); break; - case 0x4A: strcpy(str,"LSR"); break; - case 0x58: strcpy(str,"CLI"); break; - case 0x60: strcpy(str,"RTS"); break; - case 0x68: strcpy(str,"PLA"); break; - case 0x6A: strcpy(str,"ROR"); break; - case 0x78: strcpy(str,"SEI"); break; - case 0x88: strcpy(str,"DEY"); break; - case 0x8A: strcpy(str,"TXA"); break; - case 0x98: strcpy(str,"TYA"); break; - case 0x9A: strcpy(str,"TXS"); break; - case 0xA8: strcpy(str,"TAY"); break; - case 0xAA: strcpy(str,"TAX"); break; - case 0xB8: strcpy(str,"CLV"); break; - case 0xBA: strcpy(str,"TSX"); break; - case 0xC8: strcpy(str,"INY"); break; - case 0xCA: strcpy(str,"DEX"); break; - case 0xD8: strcpy(str,"CLD"); break; - case 0xE8: strcpy(str,"INX"); break; - case 0xEA: strcpy(str,"NOP"); break; - case 0xF8: strcpy(str,"SED"); break; - - //(Indirect,X) - case 0x01: strcpy(chr,"ORA"); goto _indirectx; - case 0x21: strcpy(chr,"AND"); goto _indirectx; - case 0x41: strcpy(chr,"EOR"); goto _indirectx; - case 0x61: strcpy(chr,"ADC"); goto _indirectx; - case 0x81: strcpy(chr,"STA"); goto _indirectx; - case 0xA1: strcpy(chr,"LDA"); goto _indirectx; - case 0xC1: strcpy(chr,"CMP"); goto _indirectx; - case 0xE1: strcpy(chr,"SBC"); goto _indirectx; - _indirectx: - indirectX(tmp); - sprintf(str,"%s ($%02X,X) @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - break; - - //Zero Page - case 0x05: strcpy(chr,"ORA"); goto _zeropage; - case 0x06: strcpy(chr,"ASL"); goto _zeropage; - case 0x24: strcpy(chr,"BIT"); goto _zeropage; - case 0x25: strcpy(chr,"AND"); goto _zeropage; - case 0x26: strcpy(chr,"ROL"); goto _zeropage; - case 0x45: strcpy(chr,"EOR"); goto _zeropage; - case 0x46: strcpy(chr,"LSR"); goto _zeropage; - case 0x65: strcpy(chr,"ADC"); goto _zeropage; - case 0x66: strcpy(chr,"ROR"); goto _zeropage; - case 0x84: strcpy(chr,"STY"); goto _zeropage; - case 0x85: strcpy(chr,"STA"); goto _zeropage; - case 0x86: strcpy(chr,"STX"); goto _zeropage; - case 0xA4: strcpy(chr,"LDY"); goto _zeropage; - case 0xA5: strcpy(chr,"LDA"); goto _zeropage; - case 0xA6: strcpy(chr,"LDX"); goto _zeropage; - case 0xC4: strcpy(chr,"CPY"); goto _zeropage; - case 0xC5: strcpy(chr,"CMP"); goto _zeropage; - case 0xC6: strcpy(chr,"DEC"); goto _zeropage; - case 0xE4: strcpy(chr,"CPX"); goto _zeropage; - case 0xE5: strcpy(chr,"SBC"); goto _zeropage; - case 0xE6: strcpy(chr,"INC"); goto _zeropage; - _zeropage: - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%04X = #$%02X", chr,opcode[1],GetMem(opcode[1])); - // ################################## End of SP CODE ########################### - break; - - //#Immediate - case 0x09: strcpy(chr,"ORA"); goto _immediate; - case 0x29: strcpy(chr,"AND"); goto _immediate; - case 0x49: strcpy(chr,"EOR"); goto _immediate; - case 0x69: strcpy(chr,"ADC"); goto _immediate; - //case 0x89: strcpy(chr,"STA"); goto _immediate; //baka, no STA #imm!! - case 0xA0: strcpy(chr,"LDY"); goto _immediate; - case 0xA2: strcpy(chr,"LDX"); goto _immediate; - case 0xA9: strcpy(chr,"LDA"); goto _immediate; - case 0xC0: strcpy(chr,"CPY"); goto _immediate; - case 0xC9: strcpy(chr,"CMP"); goto _immediate; - case 0xE0: strcpy(chr,"CPX"); goto _immediate; - case 0xE9: strcpy(chr,"SBC"); goto _immediate; - _immediate: - sprintf(str,"%s #$%02X", chr,opcode[1]); - break; - - //Absolute - case 0x0D: strcpy(chr,"ORA"); goto _absolute; - case 0x0E: strcpy(chr,"ASL"); goto _absolute; - case 0x2C: strcpy(chr,"BIT"); goto _absolute; - case 0x2D: strcpy(chr,"AND"); goto _absolute; - case 0x2E: strcpy(chr,"ROL"); goto _absolute; - case 0x4D: strcpy(chr,"EOR"); goto _absolute; - case 0x4E: strcpy(chr,"LSR"); goto _absolute; - case 0x6D: strcpy(chr,"ADC"); goto _absolute; - case 0x6E: strcpy(chr,"ROR"); goto _absolute; - case 0x8C: strcpy(chr,"STY"); goto _absolute; - case 0x8D: strcpy(chr,"STA"); goto _absolute; - case 0x8E: strcpy(chr,"STX"); goto _absolute; - case 0xAC: strcpy(chr,"LDY"); goto _absolute; - case 0xAD: strcpy(chr,"LDA"); goto _absolute; - case 0xAE: strcpy(chr,"LDX"); goto _absolute; - case 0xCC: strcpy(chr,"CPY"); goto _absolute; - case 0xCD: strcpy(chr,"CMP"); goto _absolute; - case 0xCE: strcpy(chr,"DEC"); goto _absolute; - case 0xEC: strcpy(chr,"CPX"); goto _absolute; - case 0xED: strcpy(chr,"SBC"); goto _absolute; - case 0xEE: strcpy(chr,"INC"); goto _absolute; - _absolute: - absolute(tmp); - sprintf(str,"%s $%04X = #$%02X", chr,tmp,GetMem(tmp)); - break; - - //branches - case 0x10: strcpy(chr,"BPL"); goto _branch; - case 0x30: strcpy(chr,"BMI"); goto _branch; - case 0x50: strcpy(chr,"BVC"); goto _branch; - case 0x70: strcpy(chr,"BVS"); goto _branch; - case 0x90: strcpy(chr,"BCC"); goto _branch; - case 0xB0: strcpy(chr,"BCS"); goto _branch; - case 0xD0: strcpy(chr,"BNE"); goto _branch; - case 0xF0: strcpy(chr,"BEQ"); goto _branch; - _branch: - relative(tmp); - sprintf(str,"%s $%04X", chr,tmp); - break; - - //(Indirect),Y - case 0x11: strcpy(chr,"ORA"); goto _indirecty; - case 0x31: strcpy(chr,"AND"); goto _indirecty; - case 0x51: strcpy(chr,"EOR"); goto _indirecty; - case 0x71: strcpy(chr,"ADC"); goto _indirecty; - case 0x91: strcpy(chr,"STA"); goto _indirecty; - case 0xB1: strcpy(chr,"LDA"); goto _indirecty; - case 0xD1: strcpy(chr,"CMP"); goto _indirecty; - case 0xF1: strcpy(chr,"SBC"); goto _indirecty; - _indirecty: - indirectY(tmp); - sprintf(str,"%s ($%02X),Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - break; - - //Zero Page,X - case 0x15: strcpy(chr,"ORA"); goto _zeropagex; - case 0x16: strcpy(chr,"ASL"); goto _zeropagex; - case 0x35: strcpy(chr,"AND"); goto _zeropagex; - case 0x36: strcpy(chr,"ROL"); goto _zeropagex; - case 0x55: strcpy(chr,"EOR"); goto _zeropagex; - case 0x56: strcpy(chr,"LSR"); goto _zeropagex; - case 0x75: strcpy(chr,"ADC"); goto _zeropagex; - case 0x76: strcpy(chr,"ROR"); goto _zeropagex; - case 0x94: strcpy(chr,"STY"); goto _zeropagex; - case 0x95: strcpy(chr,"STA"); goto _zeropagex; - case 0xB4: strcpy(chr,"LDY"); goto _zeropagex; - case 0xB5: strcpy(chr,"LDA"); goto _zeropagex; - case 0xD5: strcpy(chr,"CMP"); goto _zeropagex; - case 0xD6: strcpy(chr,"DEC"); goto _zeropagex; - case 0xF5: strcpy(chr,"SBC"); goto _zeropagex; - case 0xF6: strcpy(chr,"INC"); goto _zeropagex; - _zeropagex: - zpIndex(tmp,RX); - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%02X,X @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - // ################################## End of SP CODE ########################### - break; - - //Absolute,Y - case 0x19: strcpy(chr,"ORA"); goto _absolutey; - case 0x39: strcpy(chr,"AND"); goto _absolutey; - case 0x59: strcpy(chr,"EOR"); goto _absolutey; - case 0x79: strcpy(chr,"ADC"); goto _absolutey; - case 0x99: strcpy(chr,"STA"); goto _absolutey; - case 0xB9: strcpy(chr,"LDA"); goto _absolutey; - case 0xBE: strcpy(chr,"LDX"); goto _absolutey; - case 0xD9: strcpy(chr,"CMP"); goto _absolutey; - case 0xF9: strcpy(chr,"SBC"); goto _absolutey; - _absolutey: - absolute(tmp); - tmp2=(tmp+RY); - sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); - break; - - //Absolute,X - case 0x1D: strcpy(chr,"ORA"); goto _absolutex; - case 0x1E: strcpy(chr,"ASL"); goto _absolutex; - case 0x3D: strcpy(chr,"AND"); goto _absolutex; - case 0x3E: strcpy(chr,"ROL"); goto _absolutex; - case 0x5D: strcpy(chr,"EOR"); goto _absolutex; - case 0x5E: strcpy(chr,"LSR"); goto _absolutex; - case 0x7D: strcpy(chr,"ADC"); goto _absolutex; - case 0x7E: strcpy(chr,"ROR"); goto _absolutex; - case 0x9D: strcpy(chr,"STA"); goto _absolutex; - case 0xBC: strcpy(chr,"LDY"); goto _absolutex; - case 0xBD: strcpy(chr,"LDA"); goto _absolutex; - case 0xDD: strcpy(chr,"CMP"); goto _absolutex; - case 0xDE: strcpy(chr,"DEC"); goto _absolutex; - case 0xFD: strcpy(chr,"SBC"); goto _absolutex; - case 0xFE: strcpy(chr,"INC"); goto _absolutex; - _absolutex: - absolute(tmp); - tmp2=(tmp+RX); - sprintf(str,"%s $%04X,X @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2)); - break; - - //jumps - case 0x20: strcpy(chr,"JSR"); goto _jump; - case 0x4C: strcpy(chr,"JMP"); goto _jump; - case 0x6C: absolute(tmp); sprintf(str,"JMP ($%04X) = $%04X", tmp,GetMem(tmp)|GetMem(tmp+1)<<8); break; - _jump: - absolute(tmp); - sprintf(str,"%s $%04X", chr,tmp); - break; - - //Zero Page,Y - case 0x96: strcpy(chr,"STX"); goto _zeropagey; - case 0xB6: strcpy(chr,"LDX"); goto _zeropagey; - _zeropagey: - zpIndex(tmp,RY); - // ################################## Start of SP CODE ########################### - // Change width to %04X - sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp)); - // ################################## End of SP CODE ########################### - break; - - //UNDEFINED - default: strcpy(str,"ERROR"); break; - - } - - return str; -} diff --git a/branches/sdl2/src/asm.h b/branches/sdl2/src/asm.h deleted file mode 100644 index 5dff9f32..00000000 --- a/branches/sdl2/src/asm.h +++ /dev/null @@ -1,2 +0,0 @@ -int Assemble(unsigned char *output, int addr, char *str); -char *Disassemble(int addr, uint8 *opcode); diff --git a/branches/sdl2/src/attic/fceustr.cpp b/branches/sdl2/src/attic/fceustr.cpp deleted file mode 100644 index 3904bb4c..00000000 --- a/branches/sdl2/src/attic/fceustr.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -#include "types.h" -#include "fceustr.h" - - -/* Creates a fceustr from a C-style string. */ -fceustr *fceustr_create(const char *str) -{ - fceustr *ret; - - ret=malloc(sizeof(fceustr)); - - ret->data=malloc(strlen(str)+1); - strcpy(ret->data,str); - - ret->len=strlen(str); - - return(ret); -} - -void fceustr_destroy(fceustr *str) -{ - if(str->data) free(str->data); - free(str); -} diff --git a/branches/sdl2/src/attic/fceustr.h b/branches/sdl2/src/attic/fceustr.h deleted file mode 100644 index 7033c3b0..00000000 --- a/branches/sdl2/src/attic/fceustr.h +++ /dev/null @@ -1,4 +0,0 @@ -typedef struct { - uint8 *data; - uint32 len; /* Not including extra NULL character. */ -} fceustr; diff --git a/branches/sdl2/src/attic/old fceultra docs.zip b/branches/sdl2/src/attic/old fceultra docs.zip deleted file mode 100644 index 9d203c37..00000000 Binary files a/branches/sdl2/src/attic/old fceultra docs.zip and /dev/null differ diff --git a/branches/sdl2/src/attic/pc/dface.h b/branches/sdl2/src/attic/pc/dface.h deleted file mode 100644 index 9981bd08..00000000 --- a/branches/sdl2/src/attic/pc/dface.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif -#include "../common/args.h" -#include "../common/config.h" - -#include "input.h" - -extern FCEUGI *CurGame; - -extern CFGSTRUCT DriverConfig[]; -extern ARGPSTRUCT DriverArgs[]; -extern char *DriverUsage; - -void DoDriverArgs(void); -uint8 *GetBaseDirectory(void); - -int InitSound(FCEUGI *gi); -void WriteSound(int32 *Buffer, int Count); -int KillSound(void); -uint32 GetMaxSound(void); -uint32 GetWriteSound(void); - -void SilenceSound(int s); /* DOS and SDL */ - - -int InitMouse(void); -void KillMouse(void); -void GetMouseData(uint32 *MouseData); - -int InitJoysticks(void); -int KillJoysticks(void); -uint32 *GetJSOr(void); - -int InitKeyboard(void); -int UpdateKeyboard(void); -char *GetKeyboard(void); -void KillKeyboard(void); - -int InitVideo(FCEUGI *gi); -int KillVideo(void); -void BlitScreen(uint8 *XBuf); -void LockConsole(void); -void UnlockConsole(void); -void ToggleFS(); /* SDL */ - -int LoadGame(const char *path); -int CloseGame(void); -int GUI_Init(int argc, char **argv, int (*dofunc)(void)); -int GUI_Idle(void); -int GUI_Update(void); -void GUI_Hide(int); -void GUI_RequestExit(void); -int GUI_SetVideo(int fullscreen, int width, int height); -char *GUI_GetKeyboard(void); -void GUI_GetMouseState(uint32 *b, int *x, int *y); - -void UpdatePhysicalInput(void); -int DTestButton(ButtConfig *bc); -int DWaitButton(const uint8 *text, ButtConfig *bc, int wb); -int ButtonConfigBegin(void); -void ButtonConfigEnd(void); - -void Giggles(int); -void DoFun(void); - -int FCEUD_NetworkConnect(void); -#ifdef __cplusplus -} -#endif - - diff --git a/branches/sdl2/src/attic/pc/dos-joystick.c b/branches/sdl2/src/attic/pc/dos-joystick.c deleted file mode 100644 index 05e18177..00000000 --- a/branches/sdl2/src/attic/pc/dos-joystick.c +++ /dev/null @@ -1,200 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "dos.h" -#include "dos-joystick.h" - -#define JOY_A 1 -#define JOY_B 2 -#define JOY_SELECT 4 -#define JOY_START 8 -#define JOY_UP 0x10 -#define JOY_DOWN 0x20 -#define JOY_LEFT 0x40 -#define JOY_RIGHT 0x80 - -int joy=0; -int joyBMap[6]; - -static int32 joybuttons=0; -static uint32 joyx=0; -static uint32 joyy=0; -static uint32 joyxcenter; -static uint32 joyycenter; - -static void ConfigJoystick(void); -volatile int soundjoyer=0; -volatile int soundjoyeron=0; - -/* Crude method to detect joystick. */ -static int DetectJoystick(void) -{ - uint8 b; - - outportb(0x201,0); - b=inportb(0x201); - sleep(1); - if((inportb(0x201)&3)==(b&3)) - return 0; - else - return 1; -} - -void UpdateJoyData(void) -{ - uint32 xc,yc; - - - joybuttons=((inportb(0x201)&0xF0)^0xF0)>>4; - - xc=yc=0; - - { - outportb(0x201,0); - - for(;;) - { - uint8 b; - - b=inportb(0x201); - if(!(b&3)) - break; - if(b&1) xc++; - if(b&2) yc++; - } - } - - joyx=xc; - joyy=yc; -} - -uint32 GetJSOr(void) -{ - int y; - unsigned long ret; - static int rtoggle=0; - ret=0; - - rtoggle^=1; - if(!soundo) - UpdateJoyData(); - for(y=0;y<6;y++) - if((y>=4 && rtoggle) || y<4) - if(joybuttons&joyBMap[y]) ret|=(1<=joyxcenter*1.75) ret|=JOY_RIGHT<<((joy-1)<<3); - if(joyy<=joyycenter*.25) ret|=JOY_UP<<((joy-1)<<3); - else if(joyy>=joyycenter*1.75) ret|=JOY_DOWN<<((joy-1)<<3); - - return ret; -} - -int InitJoysticks(void) -{ - if(!joy) return(0); - if(!DetectJoystick()) - { - printf("Joystick not detected!\n"); - joy=0; - return 0; - } - if(soundo) - { - soundjoyeron=1; - while(!soundjoyer); - } - else - UpdateJoyData(); - - joyxcenter=joyx; - joyycenter=joyy; - - if(!(joyBMap[0]|joyBMap[1]|joyBMap[2]|joyBMap[3])) - ConfigJoystick(); - return(1); -} - -static void BConfig(int b) -{ - int c=0; - uint32 st=time(0); - - while(time(0)< (st+4) ) - { - if(!soundo) - UpdateJoyData(); - if(joybuttons) c=joybuttons; - else if(c && !joybuttons) - { - joyBMap[b]=c; - break; - } - - } -} - -void KillJoysticks(void) -{ - -} - -static void ConfigJoystick(void) -{ - static char *genb="** Press button for "; - - printf("\n\n Joystick button configuration:\n\n"); - printf(" Push and release the button to map to the virtual joystick.\n"); - printf(" If you do not wish to assign a button, wait a few seconds\n"); - printf(" and the configuration will continue.\n\n"); - printf(" Press enter to continue...\n"); - getchar(); - - printf("%s\"Select\".\n",genb); - BConfig(2); - - printf("%s\"Start\".\n",genb); - BConfig(3); - - printf("%s\"B\".\n",genb); - BConfig(1); - - printf("%s\"A\".\n",genb); - BConfig(0); - - printf("%s\"Rapid fire B\".\n",genb); - BConfig(5); - - printf("%s\"Rapid fire A\".\n",genb); - BConfig(4); - -} - diff --git a/branches/sdl2/src/attic/pc/dos-joystick.h b/branches/sdl2/src/attic/pc/dos-joystick.h deleted file mode 100644 index 8c50c6b2..00000000 --- a/branches/sdl2/src/attic/pc/dos-joystick.h +++ /dev/null @@ -1,27 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -void UpdateJoyData(void); -uint32 GetJSOr(void); -int InitJoysticks(void); - -/* Variables to save in config file. */ -extern int joy; -extern int joyBMap[6]; diff --git a/branches/sdl2/src/attic/pc/dos-keyboard.c b/branches/sdl2/src/attic/pc/dos-keyboard.c deleted file mode 100644 index b5926c3c..00000000 --- a/branches/sdl2/src/attic/pc/dos-keyboard.c +++ /dev/null @@ -1,131 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include "keyscan.h" - -static unsigned char lastsc; -static char keybuf[256]; -int newk; - -/* Read scan code from port $60 */ -/* Acknowledge interrupt( output $20 to port $20) */ - -static void ihandler(_go32_dpmi_registers *r) -{ - unsigned char scode=inp(0x60); /* Get scan code. */ - - - if(scode!=0xE0) - { - int offs=0; - - /* I'm only interested in preserving the independent status of the - right ALT and CONTROL keys. - */ - if(lastsc==0xE0) - if((scode&0x7F)==SCAN_LEFTALT || (scode&0x7F)==SCAN_LEFTCONTROL) - offs=0x80; - - - keybuf[(scode&0x7f)|offs]=((scode&0x80)^0x80); - newk++; - } - lastsc=scode; - - outp(0x20,0x20); /* Acknowledge interrupt. */ -} - -static _go32_dpmi_seginfo KBIBack,KBIBackRM; -static _go32_dpmi_seginfo KBI,KBIRM; -static _go32_dpmi_registers KBIRMRegs; -static int initdone=0; - -int InitKeyboard(void) -{ - /* I'll assume that the keyboard is in the correct scancode mode(translated - mode 2, I think). - */ - newk=0; - memset(keybuf,0,sizeof(keybuf)); - KBIRM.pm_offset=KBI.pm_offset=(int)ihandler; - KBIRM.pm_selector=KBI.pm_selector=_my_cs(); - - _go32_dpmi_get_real_mode_interrupt_vector(9,&KBIBackRM); - _go32_dpmi_allocate_real_mode_callback_iret(&KBIRM, &KBIRMRegs); - _go32_dpmi_set_real_mode_interrupt_vector(9,&KBIRM); - - _go32_dpmi_get_protected_mode_interrupt_vector(9,&KBIBack); - _go32_dpmi_allocate_iret_wrapper(&KBI); - _go32_dpmi_set_protected_mode_interrupt_vector(9,&KBI); - lastsc=0; - initdone=1; - return(1); -} - -void KillKeyboard(void) -{ - if(initdone) - { - _go32_dpmi_set_protected_mode_interrupt_vector(9,&KBIBack); - _go32_dpmi_free_iret_wrapper(&KBI); - - _go32_dpmi_set_real_mode_interrupt_vector(9,&KBIBackRM); - _go32_dpmi_free_real_mode_callback(&KBIRM); - initdone=0; - } -} - -/* In FCE Ultra, it doesn't matter if the key states change - in the middle of the keyboard handling code. If you want - to use this code elsewhere, you may want to memcpy() keybuf - to another buffer and return that when GetKeyboard() is - called. -*/ - -char *GetKeyboard(void) -{ - return keybuf; -} - -/* Returns 1 on new scan codes generated, 0 on no new scan codes. */ -int UpdateKeyboard(void) -{ - int t=newk; - - if(t) - { - asm volatile( - "subl %%eax,_newk\n\t" - : - : "a" (t) - ); - - if(keybuf[SCAN_LEFTCONTROL] && keybuf[SCAN_C]) - raise(SIGINT); - return(1); - } - return(0); -} diff --git a/branches/sdl2/src/attic/pc/dos-mouse.c b/branches/sdl2/src/attic/pc/dos-mouse.c deleted file mode 100644 index 3e0d1142..00000000 --- a/branches/sdl2/src/attic/pc/dos-mouse.c +++ /dev/null @@ -1,80 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include "dos.h" - -int InitMouse(void) -{ - __dpmi_regs regs; - - memset(®s,0,sizeof(regs)); - regs.x.ax=0; - __dpmi_int(0x33,®s); - if(regs.x.ax!=0xFFFF) - return(0); - - memset(®s,0,sizeof(regs)); - regs.x.ax=0x7; - regs.x.cx=0; // Min X - regs.x.dx=260; // Max X - __dpmi_int(0x33,®s); - - memset(®s,0,sizeof(regs)); - regs.x.ax=0x8; - regs.x.cx=0; // Min Y - regs.x.dx=260; // Max Y - __dpmi_int(0x33,®s); - - memset(®s,0,sizeof(regs)); - regs.x.ax=0xF; - regs.x.cx=8; // Mickey X - regs.x.dx=8; // Mickey Y - __dpmi_int(0x33,®s); - - memset(®s,0,sizeof(regs)); - regs.x.ax=0x2; - __dpmi_int(0x33,®s); - - return(1); -} - -uint32 GetMouseData(uint32 *x, uint32 *y) -{ - if(FCEUI_IsMovieActive()<0) - return; - - __dpmi_regs regs; - - memset(®s,0,sizeof(regs)); - regs.x.ax=0x3; - __dpmi_int(0x33,®s); - - *x=regs.x.cx; - *y=regs.x.dx; - return(regs.x.bx&3); -} - -void KillMouse(void) -{ - -} diff --git a/branches/sdl2/src/attic/pc/dos-sound.c b/branches/sdl2/src/attic/pc/dos-sound.c deleted file mode 100644 index e1a21fc1..00000000 --- a/branches/sdl2/src/attic/pc/dos-sound.c +++ /dev/null @@ -1,567 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dos.h" -#include "dos-sound.h" -#include "dos-joystick.h" - - -static void SBIRQHandler(_go32_dpmi_registers *r); -static uint32 LMBuffer; /* Address of low memory DMA playback buffer. */ -static int LMSelector; - -static uint8 *WaveBuffer; -static unsigned int IVector, SBIRQ, SBDMA, SBDMA16, SBPort; -static int DSPV,hsmode; -static int format; -static int frags, fragsize, fragtotal; -static volatile int WritePtr, ReadPtr; -static volatile int hbusy; -static volatile int whichbuf; - - -static uint8 PICMask; -/* Protected mode interrupt vector info. */ -static _go32_dpmi_seginfo SBIH,SBIHOld; - -/* Real mode interrupt vector info. */ -static _go32_dpmi_seginfo SBIHRM,SBIHRMOld; -static _go32_dpmi_registers SBIHRMRegs; - -static int WriteDSP(uint8 V) -{ - int x; - - for(x=65536;x;x--) - { - if(!(inportb(SBPort+0xC)&0x80)) - { - outportb(SBPort+0xC,V); - return(1); - } - } - return(0); -} - -static int ReadDSP(uint8 *V) -{ - int x; - - for(x=65536;x;x--) /* Should be more than enough time... */ - { - if(inportb(SBPort+0xE)&0x80) - { - *V=inportb(SBPort+0xA); - return(1); - } - } - return(0); -} - - -static int SetVectors(void) -{ - SBIH.pm_offset=SBIHRM.pm_offset=(int)SBIRQHandler; - SBIH.pm_selector=SBIHRM.pm_selector=_my_cs(); - - /* Get and set real mode interrupt vector. */ - _go32_dpmi_get_real_mode_interrupt_vector(IVector,&SBIHRMOld); - _go32_dpmi_allocate_real_mode_callback_iret(&SBIHRM, &SBIHRMRegs); - _go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRM); - - /* Get and set protected mode interrupt vector. */ - _go32_dpmi_get_protected_mode_interrupt_vector(IVector,&SBIHOld); - _go32_dpmi_allocate_iret_wrapper(&SBIH); - _go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIH); - - return(1); -} - -static void ResetVectors(void) -{ - _go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIHOld); - _go32_dpmi_free_iret_wrapper(&SBIH); - _go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRMOld); - _go32_dpmi_free_real_mode_callback(&SBIHRM); -} - -int GetBLASTER(void) -{ - int check=0; - char *s; - - if(!(s=getenv("BLASTER"))) - { - puts(" Error getting BLASTER environment variable."); - return(0); - } - - while(*s) - { - switch(toupper(*s)) - { - case 'A': check|=(sscanf(s+1,"%x",&SBPort)==1)?1:0;break; - case 'I': check|=(sscanf(s+1,"%d",&SBIRQ)==1)?2:0;break; - case 'D': check|=(sscanf(s+1,"%d",&SBDMA)==1)?4:0;break; - case 'H': check|=(sscanf(s+1,"%d",&SBDMA16)==1)?8:0;break; - } - s++; - } - - if((check^7)&7 || SBDMA>=4 || (SBDMA16<=4 && check&8) || SBIRQ>15) - { - puts(" Invalid or incomplete BLASTER environment variable."); - return(0); - } - if(!(check&8)) - format=0; - return(1); -} - -static int ResetDSP(void) -{ - uint8 b; - - outportb(SBPort+0x6,0x1); - delay(10); - outportb(SBPort+0x6,0x0); - delay(10); - - if(ReadDSP(&b)) - if(b==0xAA) - return(1); - return(0); -} - -static int GetDSPVersion(void) -{ - int ret; - uint8 t; - - if(!WriteDSP(0xE1)) - return(0); - if(!ReadDSP(&t)) - return(0); - ret=t<<8; - if(!ReadDSP(&t)) - return(0); - ret|=t; - - return(ret); -} - -static void KillDMABuffer(void) -{ - __dpmi_free_dos_memory(LMSelector); -} - -static int MakeDMABuffer(void) -{ - uint32 size; - int32 tmp; - - size=fragsize*2; /* Two buffers in the DMA buffer. */ - size<<=format; /* Twice the size for 16-bit than for 8-bit. */ - - size<<=1; /* Double the size in case the first 2 buffers - cross a 64KB or 128KB page boundary. - */ - size=(size+15)>>4; /* Convert to paragraphs */ - - if((tmp=__dpmi_allocate_dos_memory(size,&LMSelector))<0) - return(0); - - LMBuffer=tmp<<=4; - - if(format) /* Check for and fix 128KB page boundary crossing. */ - { - if((LMBuffer&0x20000) != ((LMBuffer+fragsize*2*2-1)&0x20000)) - LMBuffer+=fragsize*2*2; - } - else /* Check for and fix 64KB page boundary crossing. */ - { - if((LMBuffer&0x10000) != ((LMBuffer+fragsize*2-1)&0x10000)) - LMBuffer+=fragsize*2; - } - - DOSMemSet(LMBuffer, format?0:128, (fragsize*2)<>8); - - /* Page of buffer. */ - outportb(PPorts[format?SBDMA16:SBDMA],LMBuffer>>16); - - /* Offset of buffer within page. */ - if(format) - tmp=((SBDMA16&3)<<2)+0xc0; - else - tmp=SBDMA<<1; - - outportb(tmp,(LMBuffer>>format)); - outportb(tmp,(LMBuffer>>(8+format))); -} - -int InitSB(int Rate, int bittage) -{ - hsmode=hbusy=0; - whichbuf=1; - puts("Initializing Sound Blaster..."); - - format=bittage?1:0; - frags=8; - - if(Rate<=11025) - fragsize=1<<5; - else if(Rate<=22050) - fragsize=1<<6; - else - fragsize=1<<7; - - fragtotal=frags*fragsize; - WaveBuffer=malloc(fragtotal<65535)) - { - printf(" Unsupported playback rate: %d samples per second\n",Rate); - return(0); - } - - if(!GetBLASTER()) - return(0); - - /* Disable IRQ line in PIC0 or PIC1 */ - if(SBIRQ>7) - { - PICMask=inportb(0xA1); - outportb(0xA1,PICMask|(1<<(SBIRQ&7))); - } - else - { - PICMask=inportb(0x21); - outportb(0x21,PICMask|(1<>8,DSPV&0xFF); - if(DSPV<0x201) - { - printf(" DSP version number is too low.\n"); - return(0); - } - - if(DSPV<0x400) - format=0; - if(!MakeDMABuffer()) - { - puts(" Error creating low-memory DMA buffer."); - return(0); - } - - if(SBIRQ>7) IVector=SBIRQ+0x68; - else IVector=SBIRQ+0x8; - - if(!SetVectors()) - { - puts(" Error setting interrupt vectors."); - KillDMABuffer(); - return(0); - } - - /* Reenable IRQ line. */ - if(SBIRQ>7) - outportb(0xA1,PICMask&(~(1<<(SBIRQ&7)))); - else - outportb(0x21,PICMask&(~(1<=0x400) - { - WriteDSP(0x41); // Set sampling rate - WriteDSP(Rate>>8); // High byte - WriteDSP(Rate&0xFF); // Low byte - if(!format) - { - WriteDSP(0xC6); // 8-bit output - WriteDSP(0x00); // 8-bit mono unsigned PCM - } - else - { - WriteDSP(0xB6); // 16-bit output - WriteDSP(0x10); // 16-bit mono signed PCM - } - WriteDSP((fragsize-1)&0xFF);// Low byte of size - WriteDSP((fragsize-1)>>8); // High byte of size - } - else - { - int tc,command; - if(Rate>22050) - { - tc=(65536-(256000000/Rate))>>8; - Rate=256000000/(65536-(tc<<8)); - command=0x90; // High-speed auto-initialize DMA mode transfer - hsmode=1; - } - else - { - tc=256-(1000000/Rate); - Rate=1000000/(256-tc); - command=0x1c; // Auto-initialize DMA mode transfer - } - WriteDSP(0x40); // Set DSP time constant - WriteDSP(tc); // time constant - WriteDSP(0x48); // Set DSP block transfer size - WriteDSP((fragsize-1)&0xFF); - WriteDSP((fragsize-1)>>8); - - WriteDSP(command); - } - - /* Enable DMA */ - if(format) - outportb(0xd4,SBDMA16&3); - else - outportb(0xa,SBDMA); - - printf(" %d hz, %d-bit\n",Rate,8<=8) - outportb(0xA0,0x20); - whichbuf^=1; - return; - } - hbusy=1; - - { - /* This code seems to fail on many SB emulators. Bah. - SCREW SB EMULATORS. ^_^ */ - uint32 count; - uint32 block; - uint32 port; - - if(format) - port=((SBDMA16&3)*4)+0xc2; - else - port=(SBDMA*2)+1; - - count=inportb(port); - count|=inportb(port)<<8; - - if(count>=fragsize) - block=1; - else - block=0; - dest=LMBuffer+((block*fragsize)<>2;x;x--,dest+=4) - { - _farnspokel(dest,sby); - } - } - else - { - for(x=(fragsize<>2;x;x--,dest+=4,src++) - { - _farnspokel(dest,*src); - } - ReadPtr=(ReadPtr+fragsize)&(fragtotal-1); - } - - if(soundjoyeron) - { - static int coot=0; - if(!coot) - { - UpdateJoyData(); - soundjoyer=1; - } - coot=(coot+1)&3; - } - hbusy=0; - outportb(0x20,0x20); - if(SBIRQ>=8) - outportb(0xA0,0x20); -} - -void SilenceSound(int s) -{ - ssilence=s; -} - -void WriteSBSound(int32 *Buffer, int Count, int NoBlocking) -{ - int x; - - if(!format) - { - for(x=0;x>8)^128; - WritePtr=(WritePtr+1)&(fragtotal-1); - } - } - else // 16 bit - { - for(x=0;x7)?0xA1:0x21,PICMask|(1<<(SBIRQ&7))); - ResetVectors(); - outportb((SBIRQ>7)?0xA1:0x21,PICMask); - KillDMABuffer(); -} diff --git a/branches/sdl2/src/attic/pc/dos-sound.h b/branches/sdl2/src/attic/pc/dos-sound.h deleted file mode 100644 index c0e261b5..00000000 --- a/branches/sdl2/src/attic/pc/dos-sound.h +++ /dev/null @@ -1,26 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -int InitSB(int Rate, int bittage); -void KillSB(void); - -void WriteSBSound(int32 *Buffer, int Count, int NoBlocking); -void SilenceSound(int s); - diff --git a/branches/sdl2/src/attic/pc/dos-video.c b/branches/sdl2/src/attic/pc/dos-video.c deleted file mode 100644 index 6c9a3682..00000000 --- a/branches/sdl2/src/attic/pc/dos-video.c +++ /dev/null @@ -1,246 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 \Firebug\ - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "dos.h" -#include "dos-video.h" - -#define TEXT 3 -#define G320x200x256 0x13 - -static void vga_waitretrace(void) -{ - while(inp(0x3da)&0x8); - while(!(inp(0x3da)&0x8)); -} - -static void vga_setmode(int mode) -{ - __dpmi_regs regs; - - memset(®s,0,sizeof(regs)); - regs.x.ax=mode; - - __dpmi_int(0x10,®s); -} - -void vga_setpalette(int i, int r, int g, int b) -{ - outp(0x3c8,i); - outp(0x3c9,r); - outp(0x3c9,g); - outp(0x3c9,b); -} - -int FCEUDvmode=1; - -static int vidready=0; - -/* Part of the VGA low-level mass register setting code derived from - code by \Firebug\. -*/ - -#include "vgatweak.c" - -void SetBorder(void) -{ - inportb(0x3da); - outportb(0x3c0,(0x11|0x20)); - outportb(0x3c0,0x80); -} - -void TweakVGA(int VGAMode) -{ - int I; - - vga_waitretrace(); - - outportb(0x3C8,0x00); - for(I=0;I<768;I++) outportb(0x3C9,0x00); - - outportb(0x3D4,0x11); - I=inportb(0x3D5)&0x7F; - outportb(0x3D4,0x11); - outportb(0x3D5,I); - - switch(VGAMode) - { - case 1: for(I=0;I<25;I++) VGAPortSet(v256x240[I]);break; - case 2: for(I=0;I<25;I++) VGAPortSet(v256x256[I]);break; - case 3: for(I=0;I<25;I++) VGAPortSet(v256x256S[I]);break; - case 6: for(I=0;I<25;I++) VGAPortSet(v256x224S[I]);break; - case 8: for(I=0;I<25;I++) VGAPortSet(v256x224_103[I]);break; - default: break; - } - - outportb(0x3da,0); -} - - -static uint8 palettedbr[256],palettedbg[256],palettedbb[256]; - -static void FlushPalette(void) -{ - int x; - for(x=0;x<256;x++) - { - int z=x; - vga_setpalette(z,palettedbr[x]>>2,palettedbg[x]>>2,palettedbb[x]>>2); - } -} - -void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b) -{ - palettedbr[index]=r; - palettedbg[index]=g; - palettedbb[index]=b; - if(vidready) - { - vga_setpalette(index,r>>2,g>>2,b>>2); - } -} - - -void FCEUD_GetPalette(uint8 i, uint8 *r, uint8 *g, uint8 *b) -{ - *r=palettedbr[i]; - *g=palettedbg[i]; - *b=palettedbb[i]; -} - -static uint32 ScreenLoc; - -int InitVideo(void) -{ - vidready=0; - switch(FCEUDvmode) - { - default: - case 1: - case 2: - case 3: - case 6: - case 8: - vga_setmode(G320x200x256); - vidready|=1; - ScreenLoc=0xa0000; - TweakVGA(FCEUDvmode); - SetBorder(); - DOSMemSet(ScreenLoc, 128, 256*256); - break; - } - vidready|=2; - FlushPalette(); - return 1; -} - -void KillVideo(void) -{ - if(vidready) - { - vga_setmode(TEXT); - vidready=0; - } -} -void LockConsole(void){} -void UnlockConsole(void){} -void BlitScreen(uint8 *XBuf) -{ - uint32 dest; - int tlines; - - if(eoptions&4 && !NoWaiting) - vga_waitretrace(); - - tlines=erendline-srendline+1; - - dest=ScreenLoc; - - switch(FCEUDvmode) - { - case 1:dest+=(((240-tlines)>>1)<<8);break; - case 2: - case 3:dest+=(((256-tlines)>>1)<<8);break; - case 4: - case 5:dest+=(((240-tlines)>>1)*640+((640-512)>>1));break; - case 8: - case 6:if(tlines>224) tlines=224;dest+=(((224-tlines)>>1)<<8);break; - } - - XBuf+=(srendline<<8)+(srendline<<4); - - _farsetsel(_dos_ds); - if(eoptions&DO_CLIPSIDES) - { - asm volatile( - "agoop1:\n\t" - "movl $30,%%eax\n\t" - "agoop2:\n\t" - "movl (%%esi),%%edx\n\t" - "movl 4(%%esi),%%ecx\n\t" - ".byte 0x64 \n\t" - "movl %%edx,(%%edi)\n\t" - ".byte 0x64 \n\t" - "movl %%ecx,4(%%edi)\n\t" - "addl $8,%%esi\n\t" - "addl $8,%%edi\n\t" - "decl %%eax\n\t" - "jne agoop2\n\t" - "addl $32,%%esi\n\t" - "addl $16,%%edi\n\t" - "decb %%bl\n\t" - "jne agoop1\n\t" - : - : "S" (XBuf+8), "D" (dest+8), "b" (tlines) - : "%eax","%cc","%edx","%ecx" ); - } - else - { - asm volatile( - "goop1:\n\t" - "movl $32,%%eax\n\t" - "goop2:\n\t" - "movl (%%esi),%%edx\n\t" - "movl 4(%%esi),%%ecx\n\t" - ".byte 0x64 \n\t" - "movl %%edx,(%%edi)\n\t" - ".byte 0x64 \n\t" - "movl %%ecx,4(%%edi)\n\t" - "addl $8,%%esi\n\t" - "addl $8,%%edi\n\t" - "decl %%eax\n\t" - "jne goop2\n\t" - "addl $16,%%esi\n\t" - "decb %%bl\n\t" - "jne goop1\n\t" - : - : "S" (XBuf), "D" (dest), "b" (tlines) - : "%eax","%cc","%edx","%ecx" ); - } -} - - diff --git a/branches/sdl2/src/attic/pc/dos-video.h b/branches/sdl2/src/attic/pc/dos-video.h deleted file mode 100644 index 75b1a1b8..00000000 --- a/branches/sdl2/src/attic/pc/dos-video.h +++ /dev/null @@ -1,22 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -extern int FCEUDvmode; - diff --git a/branches/sdl2/src/attic/pc/dos.c b/branches/sdl2/src/attic/pc/dos.c deleted file mode 100644 index bd34b058..00000000 --- a/branches/sdl2/src/attic/pc/dos.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "dos.h" -#include "dos-joystick.h" -#include "dos-video.h" -#include "dos-sound.h" -#include "../common/args.h" -#include "../common/config.h" - -/* _CRT0_FLAG_LOCK_MEMORY might not always result in all memory being locked. - Bummer. I'll add code to explicitly lock the data touched by the sound - interrupt handler(and the handler itself), if necessary(though that might - be tricky...). I'll also to cover the data the keyboard - interrupt handler touches. -*/ - -int _crt0_startup_flags = _CRT0_FLAG_FILL_SBRK_MEMORY | _CRT0_FLAG_LOCK_MEMORY | _CRT0_FLAG_USE_DOS_SLASHES; - -static int f8bit=0; -int soundo=44100; -int doptions=0; - - -CFGSTRUCT DriverConfig[]={ - NAC("sound",soundo), - AC(doptions), - AC(f8bit), - AC(FCEUDvmode), - NACA("joybmap",joyBMap), - AC(joy), - ENDCFGSTRUCT -}; - -char *DriverUsage= -"-vmode x Select video mode(all are 8 bpp).\n\ - 1 = 256x240 6 = 256x224(with scanlines)\n\ - 2 = 256x256 8 = 256x224\n\ - 3 = 256x256(with scanlines)\n\ --vsync x Wait for the screen's vertical retrace before updating the\n\ - screen. Refer to the documentation for caveats.\n\ - 0 = Disabled.\n\ - 1 = Enabled.\n\ --sound x Sound.\n\ - 0 = Disabled.\n\ - Otherwise, x = playback rate.\n\ --f8bit x Force 8-bit sound.\n\ - 0 = Disabled.\n\ - 1 = Enabled."; - -ARGPSTRUCT DriverArgs[]={ - {"-vmode",0,&FCEUDvmode,0}, - {"-sound",0,&soundo,0}, - {"-f8bit",0,&f8bit,0}, - {"-vsync",0,&doptions,DO_VSYNC}, - {0,0,0,0} -}; - -void DoDriverArgs(void) -{ - if(!joy) memset(joyBMap,0,sizeof(joyBMap)); -} - -int InitSound(void) -{ - if(soundo) - { - if(soundo==1) - soundo=44100; - soundo=InitSB(soundo,f8bit?0:1); - FCEUI_Sound(soundo); - } - return(soundo); -} - -void WriteSound(int32 *Buffer, int Count, int NoWaiting) -{ - WriteSBSound(Buffer,Count,NoWaiting); -} - -void KillSound(void) -{ - if(soundo) - KillSB(); -} - -void DOSMemSet(uint32 A, uint8 V, uint32 count) -{ - uint32 x; - - _farsetsel(_dos_ds); - for(x=0;x=0;x--) - { - if(arg0[x]=='/' || arg0[x]=='\\') - { - ret = malloc(x + 1); - strncpy(ret,arg0,x); - break; - } - } - - if(!ret) { x=0; ret = malloc(1); } - - BaseDirectory[x]=0; -} - -int main(int argc, char *argv[]) -{ - puts("\nStarting FCE Ultra "VERSION_STRING"...\n"); - arg0=argv[0]; - return(CLImain(argc,argv)); -} - diff --git a/branches/sdl2/src/attic/pc/dos.h b/branches/sdl2/src/attic/pc/dos.h deleted file mode 100644 index b6814800..00000000 --- a/branches/sdl2/src/attic/pc/dos.h +++ /dev/null @@ -1,27 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "main.h" -#include "dface.h" -#include "input.h" - -void DOSMemSet(uint32 A, uint8 V, uint32 count); -#define DO_VSYNC 1 - diff --git a/branches/sdl2/src/attic/pc/input.c b/branches/sdl2/src/attic/pc/input.c deleted file mode 100644 index 35fe0350..00000000 --- a/branches/sdl2/src/attic/pc/input.c +++ /dev/null @@ -1,720 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "main.h" -#include "dface.h" -#include "input.h" - -#include "../common/cheat.h" - -/* UsrInputType[] is user-specified. InputType[] is current - (game loading can override user settings) -*/ -int UsrInputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE}; -int InputType[3]={0,0,0}; -static int cspec=0; - -int gametype=0; - -/* Necessary for proper GUI functioning(configuring when a game isn't loaded). */ -void InputUserActiveFix(void) -{ - int x; - for(x=0;x<3;x++) InputType[x]=UsrInputType[x]; -} - -void ParseGIInput(FCEUGI *gi) -{ - gametype=gi->type; - - InputType[0]=UsrInputType[0]; - InputType[1]=UsrInputType[1]; - InputType[2]=UsrInputType[2]; - - if(gi->input[0]>=0) - InputType[0]=gi->input[0]; - if(gi->input[1]>=0) - InputType[1]=gi->input[1]; - if(gi->inputfc>=0) - InputType[2]=gi->inputfc; - cspec = gi->cspecial; - - #ifdef EXTGUI - Giggles(gi->cspecial); - #endif -} - - -static uint8 QuizKingData=0; -static uint8 HyperShotData=0; -static uint32 MahjongData=0; -static uint32 FTrainerData=0; -static uint8 TopRiderData=0; - -static uint8 BWorldData[1+13+1]; - -static void UpdateFKB(void); -static void UpdateGamepad(void); -static void UpdateQuizKing(void); -static void UpdateHyperShot(void); -static void UpdateMahjong(void); -static void UpdateFTrainer(void); -static void UpdateTopRider(void); - -static uint32 JSreturn=0; -int NoWaiting=1; - -#ifndef EXTGUI -static void DoCheatSeq(void) -{ - #if defined(DOS) || defined(SDL) - SilenceSound(1); - #endif - KillKeyboard(); - KillVideo(); - - DoConsoleCheatConfig(); - InitVideo(CurGame); - InitKeyboard(); - #if defined(DOS) || defined(SDL) - SilenceSound(0); - #endif -} -#endif - -#include "keyscan.h" -static char *keys=0; -static int DIPS=0; - -static uint8 keyonce[MKK_COUNT]; -#define KEY(__a) keys[MKK(__a)] - -static int _keyonly(int a) -{ - if(keys[a]) - { - if(!keyonce[a]) - { - keyonce[a]=1; - return(1); - } - } - else - keyonce[a]=0; - return(0); -} - -#define keyonly(__a) _keyonly(MKK(__a)) - -static int cidisabled=0; - -static void KeyboardCommands(void) -{ - int is_shift, is_alt; - - keys=GetKeyboard(); - - if(InputType[2]==SIFC_FKB) - { - if(keyonly(SCROLLLOCK)) - { - cidisabled^=1; - FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis"); - } - #ifdef SDL - SDL_WM_GrabInput(cidisabled?SDL_GRAB_ON:SDL_GRAB_OFF); - #endif - if(cidisabled) return; - } - - is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT); - is_alt = KEY(LEFTALT) | KEY(RIGHTALT); - - if(keyonly(F4)) - { - if(is_shift) FCEUI_SetRenderDisable(-1, 2); - else FCEUI_SetRenderDisable(2, -1); - } - #ifdef SDL - if(keyonly(ENTER) && is_alt) ToggleFS(); - #endif - - NoWaiting&=~1; - if(KEY(GRAVE)) - NoWaiting|=1; - - if(gametype==GIT_FDS) - { - if(keyonly(F6)) FCEUI_FDSSelect(); - if(keyonly(F8)) FCEUI_FDSInsert(); - } - - if(keyonly(F9)) FCEUI_SaveSnapshot(); - if(gametype!=GIT_NSF) - { - #ifndef EXTGUI - if(keyonly(F2)) DoCheatSeq(); - #endif - if(keyonly(F5)) - { - if(is_shift) - FCEUI_SaveMovie(NULL,0,NULL); - else - FCEUI_SaveState(NULL); - } - if(keyonly(F7)) - { - if(is_shift) - FCEUI_LoadMovie(NULL,0); - else - FCEUI_LoadState(NULL); - } - } - - if(keyonly(F1)) FCEUI_ToggleTileView(); - - if(keyonly(MINUS)) DecreaseEmulationSpeed(); - if(keyonly(EQUAL)) IncreaseEmulationSpeed(); - if(keyonly(BACKSPACE)) FCEUI_MovieToggleFrameDisplay(); - if(keyonly(BACKSLASH)) FCEUI_ToggleEmulationPause(); - if(keyonly(RIGHTCONTROL)) FCEUI_FrameAdvance(); - - if(keyonly(F10)) FCEUI_ResetNES(); - if(keyonly(F11)) FCEUI_PowerNES(); - - #ifdef EXTGUI - if(keyonly(F3)) GUI_Hide(-1); - if(KEY(F12)) GUI_RequestExit(); - if(KEY(ESCAPE)) CloseGame(); - #else - if(KEY(F12) || KEY(ESCAPE)) CloseGame(); - #endif - - if(gametype==GIT_VSUNI) - { - if(keyonly(F8)) FCEUI_VSUniCoin(); - if(keyonly(F6)) - { - DIPS^=1; - FCEUI_VSUniToggleDIPView(); - } - if(!(DIPS&1)) goto DIPSless; - if(keyonly(1)) FCEUI_VSUniToggleDIP(0); - if(keyonly(2)) FCEUI_VSUniToggleDIP(1); - if(keyonly(3)) FCEUI_VSUniToggleDIP(2); - if(keyonly(4)) FCEUI_VSUniToggleDIP(3); - if(keyonly(5)) FCEUI_VSUniToggleDIP(4); - if(keyonly(6)) FCEUI_VSUniToggleDIP(5); - if(keyonly(7)) FCEUI_VSUniToggleDIP(6); - if(keyonly(8)) FCEUI_VSUniToggleDIP(7); - } - else - { - static uint8 bbuf[32]; - static int bbuft; - static int barcoder = 0; - - if(keyonly(H)) FCEUI_NTSCSELHUE(); - if(keyonly(T)) FCEUI_NTSCSELTINT(); - if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC(); - if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC(); - - if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) - { - if(keyonly(F8)) - { - barcoder ^= 1; - if(!barcoder) - { - if(InputType[2] == SIFC_BWORLD) - { - strcpy(&BWorldData[1],bbuf); - BWorldData[0]=1; - } - else - FCEUI_DatachSet(bbuf); - FCEUI_DispMessage("Barcode Entered"); - } - else { bbuft = 0; FCEUI_DispMessage("Enter Barcode");} - } - } else barcoder = 0; - - #define SSM(x) \ - { if(barcoder) { if(bbuft < 13) {bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0;} FCEUI_DispMessage("Barcode: %s",bbuf);} \ - else { \ - if(is_shift) FCEUI_SelectMovie(x,1); \ - else FCEUI_SelectState(x,1); \ - } } - - DIPSless: - if(keyonly(0)) SSM(0); - if(keyonly(1)) SSM(1); - if(keyonly(2)) SSM(2); - if(keyonly(3)) SSM(3); - if(keyonly(4)) SSM(4); - if(keyonly(5)) SSM(5); - if(keyonly(6)) SSM(6); - if(keyonly(7)) SSM(7); - if(keyonly(8)) SSM(8); - if(keyonly(9)) SSM(9); - #undef SSM - } -} - -#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1} -#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2} - -#define MKZ() {{0},{0},{0},0} - -#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()} - -ButtConfig GamePadConfig[4][10]={ - /* Gamepad 1 */ - { - MK(KP3), MK(KP2), MK(TAB), MK(ENTER), MK(W),MK(Z), - MK(A), MK(S), MKZ(), MKZ() - }, - - /* Gamepad 2 */ - GPZ(), - - /* Gamepad 3 */ - GPZ(), - - /* Gamepad 4 */ - GPZ() -}; - - -static void UpdateGamepad(void) -{ - if(FCEUI_IsMovieActive()<0) - return; - - static int rapid=0; - uint32 JS=0; - int x; - int wg; - - rapid^=1; - - for(wg=0;wg<4;wg++) - { - for(x=0;x<8;x++) - if(DTestButton(&GamePadConfig[wg][x])) - JS|=(1<ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && - bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) - break; - } - bc->NumC=wc; -} - -void ConfigDevice(int which, int arg) -{ - uint8 buf[256]; - int x; - - ButtonConfigBegin(); - switch(which) - { - case FCFGD_QUIZKING: - for(x=0;x<6;x++) - { - sprintf(buf,"Quiz King Buzzer #%d", x+1); - subcon(buf,&QuizKingButtons[x]); - } - break; - case FCFGD_HYPERSHOT: - for(x=0;x<4;x++) - { - sprintf(buf,"Hyper Shot %d: %s",((x&2)>>1)+1,(x&1)?"JUMP":"RUN"); - subcon(buf,&HyperShotButtons[x]); - } - break; - case FCFGD_POWERPAD: - for(x=0;x<12;x++) - { - sprintf(buf,"PowerPad %d: %d", (arg&1)+1,x+11); - subcon(buf,&powerpadsc[arg&1][x]); - } - break; - - case FCFGD_GAMEPAD: - { - char *str[10]={"A","B","SELECT","START","UP","DOWN","LEFT","RIGHT","Rapid A","Rapid B"}; - for(x=0;x<10;x++) - { - sprintf(buf,"GamePad #%d: %s",arg+1,str[x]); - subcon(buf,&GamePadConfig[arg][x]); - } - } - break; - } - - ButtonConfigEnd(); -} - - -CFGSTRUCT InputConfig[]={ - ACA(UsrInputType), - AC(powerpadsc), - AC(QuizKingButtons), - AC(FTrainerButtons), - AC(HyperShotButtons), - AC(MahjongButtons), - AC(GamePadConfig), - AC(fkbmap), - ENDCFGSTRUCT -}; - - -static void InputCfg(char *text) -{ - if(!strncasecmp(text,"gamepad",strlen("gamepad"))) - { - ConfigDevice(FCFGD_GAMEPAD,(text[strlen("gamepad")]-'1')&3); - } - else if(!strncasecmp(text,"powerpad",strlen("powerpad"))) - { - ConfigDevice(FCFGD_POWERPAD,(text[strlen("powerpad")]-'1')&1); - } - else if(!strcasecmp(text,"hypershot")) - ConfigDevice(FCFGD_HYPERSHOT,0); - else if(!strcasecmp(text,"quizking")) - ConfigDevice(FCFGD_QUIZKING,0); -} - -static void FCExp(char *text) -{ - static char *fccortab[11]={"none","arkanoid","shadow","4player","fkb","hypershot", - "mahjong","quizking","ftrainera","ftrainerb","oekakids"}; - - static int fccortabi[11]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW, - SIFC_4PLAYER,SIFC_FKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING, - SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS}; - int y; - for(y=0;y<11;y++) - if(!strcmp(fccortab[y],text)) - UsrInputType[2]=fccortabi[y]; -} - -static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"}; -static int cortabi[6]={SI_NONE,SI_GAMEPAD, - SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID}; - -static void Input1(char *text) -{ - int y; - - for(y=0;y<6;y++) - if(!strcmp(cortab[y],text)) - UsrInputType[0]=cortabi[y]; -} - -static void Input2(char *text) -{ - int y; - - for(y=0;y<6;y++) - if(!strcmp(cortab[y],text)) - UsrInputType[1]=cortabi[y]; -} - -ARGPSTRUCT InputArgs[]={ - {"-inputcfg",0,(void *)InputCfg,0x2000}, - {"-fcexp",0,(void *)FCExp,0x2000}, - {"-input1",0,(void *)Input1,0x2000}, - {"-input2",0,(void *)Input2,0x2000}, - {0,0,0,0} -}; diff --git a/branches/sdl2/src/attic/pc/input.h b/branches/sdl2/src/attic/pc/input.h deleted file mode 100644 index f9fbf36e..00000000 --- a/branches/sdl2/src/attic/pc/input.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _aosdfjk02fmasf -#define _aosdfjk02fmasf -#define MAXBUTTCONFIG 4 -typedef struct { - uint8 ButtType[MAXBUTTCONFIG]; - uint8 DeviceNum[MAXBUTTCONFIG]; - uint16 ButtonNum[MAXBUTTCONFIG]; - uint32 NumC; - //uint64 DeviceID[MAXBUTTCONFIG]; /* TODO */ -} ButtConfig; - -extern CFGSTRUCT InputConfig[]; -extern ARGPSTRUCT InputArgs[]; -void ParseGIInput(FCEUGI *GI); - -#define BUTTC_KEYBOARD 0x00 -#define BUTTC_JOYSTICK 0x01 -#define BUTTC_MOUSE 0x02 - -#define FCFGD_GAMEPAD 1 -#define FCFGD_POWERPAD 2 -#define FCFGD_HYPERSHOT 3 -#define FCFGD_QUIZKING 4 - -void InitOtherInput(void); -void InputUserActiveFix(void); -#ifdef EXTGUI -extern ButtConfig GamePadConfig[4][10]; -extern ButtConfig powerpadsc[2][12]; -extern ButtConfig QuizKingButtons[6]; -extern ButtConfig FTrainerButtons[12]; -#endif - -void IncreaseEmulationSpeed(void); -void DecreaseEmulationSpeed(void); - -void FCEUD_UpdateInput(void); -#endif diff --git a/branches/sdl2/src/attic/pc/keyscan.h b/branches/sdl2/src/attic/pc/keyscan.h deleted file mode 100644 index bec3af66..00000000 --- a/branches/sdl2/src/attic/pc/keyscan.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifdef SDL -#include -#define SDLK_A SDLK_a -#define SDLK_B SDLK_b -#define SDLK_C SDLK_c -#define SDLK_D SDLK_d -#define SDLK_E SDLK_e -#define SDLK_F SDLK_f -#define SDLK_G SDLK_g -#define SDLK_H SDLK_h -#define SDLK_I SDLK_i -#define SDLK_J SDLK_j -#define SDLK_K SDLK_k -#define SDLK_L SDLK_l -#define SDLK_M SDLK_m -#define SDLK_N SDLK_n -#define SDLK_O SDLK_o -#define SDLK_P SDLK_p -#define SDLK_Q SDLK_q -#define SDLK_R SDLK_r -#define SDLK_S SDLK_s -#define SDLK_T SDLK_t -#define SDLK_U SDLK_u -#define SDLK_V SDLK_v -#define SDLK_W SDLK_w -#define SDLK_X SDLK_x -#define SDLK_Y SDLK_y -#define SDLK_Z SDLK_z -#define SDLK_LEFTCONTROL SDLK_LCTRL -#define SDLK_RIGHTCONTROL SDLK_RCTRL -#define SDLK_LEFTALT SDLK_LALT -#define SDLK_RIGHTALT SDLK_RALT -#define SDLK_LEFTSHIFT SDLK_LSHIFT -#define SDLK_RIGHTSHIFT SDLK_RSHIFT -#define SDLK_CURSORDOWN SDLK_DOWN -#define SDLK_CURSORUP SDLK_UP -#define SDLK_CURSORLEFT SDLK_LEFT -#define SDLK_CURSORRIGHT SDLK_RIGHT -#define SDLK_ENTER SDLK_RETURN -#define SDLK_EQUAL SDLK_EQUALS -#define SDLK_APOSTROPHE SDLK_QUOTE -#define SDLK_BRACKET_LEFT SDLK_LEFTBRACKET -#define SDLK_BRACKET_RIGHT SDLK_RIGHTBRACKET -#define SDLK_SCROLLLOCK SDLK_SCROLLOCK /* I guess the SDL people don't like lots of Ls... */ -#define SDLK_GRAVE SDLK_BACKQUOTE -#define MKK(k) SDLK_##k -#define MKK_COUNT (SDLK_LAST+1) - -#elif DOS - -#define SCAN_TILDE 0x29 -#define SCAN_1 0x02 -#define SCAN_2 0x03 -#define SCAN_3 0x04 -#define SCAN_4 0x05 -#define SCAN_5 0x06 -#define SCAN_6 0x07 -#define SCAN_7 0x08 -#define SCAN_8 0x09 -#define SCAN_9 0x0A -#define SCAN_0 0x0B -#define SCAN_MINUS 0x0C -#define SCAN_EQUAL 0x0D -#define SCAN_BACKSLASH 0x2B -#define SCAN_BACKSPACE 0x0E -#define SCAN_TAB 0x0F -#define SCAN_Q 0x10 -#define SCAN_W 0x11 -#define SCAN_E 0x12 -#define SCAN_R 0x13 -#define SCAN_T 0x14 -#define SCAN_Y 0x15 -#define SCAN_U 0x16 -#define SCAN_I 0x17 -#define SCAN_O 0x18 -#define SCAN_P 0x19 -#define SCAN_BRACKET_LEFT 0x1A -#define SCAN_BRACKET_RIGHT 0x1B -#define SCAN_LOWBACKSLASH 0x2B -#define SCAN_CAPSLOCK 0x3A -#define SCAN_A 0x1E -#define SCAN_S 0x1F -#define SCAN_D 0x20 -#define SCAN_F 0x21 -#define SCAN_G 0x22 -#define SCAN_H 0x23 -#define SCAN_J 0x24 -#define SCAN_K 0x25 -#define SCAN_L 0x26 -#define SCAN_SEMICOLON 0x27 -#define SCAN_APOSTROPHE 0x28 -#define SCAN_ENTER 0x1C -#define SCAN_LEFTSHIFT 0x2A -#define SCAN_Z 0x2C -#define SCAN_X 0x2D -#define SCAN_C 0x2E -#define SCAN_V 0x2F -#define SCAN_B 0x30 -#define SCAN_N 0x31 -#define SCAN_M 0x32 -#define SCAN_COMMA 0x33 -#define SCAN_PERIOD 0x34 -#define SCAN_SLASH 0x35 -#define SCAN_RIGHTSHIFT 0x36 -#define SCAN_LEFTCONTROL 0x1D -#define SCAN_LEFTALT 0x38 -#define SCAN_SPACE 0x39 - -/* Extended keys. */ -#define SCAN_RIGHTALT (0x38|0x80) -#define SCAN_RIGHTCONTROL (0x1D|0x80) -#define SCAN_BL_INSERT (0x52|0x80) -#define SCAN_BL_DELETE (0x53|0x80) -#define SCAN_BL_CURSORLEFT (0x4B|0x80) -#define SCAN_BL_HOME (0x47|0x80) -#define SCAN_BL_END (0x4F|0x80) -#define SCAN_BL_CURSORUP (0x48|0x80) -#define SCAN_BL_CURSORDOWN (0x50|0x80) -#define SCAN_BL_PAGEUP (0x49|0x80) -#define SCAN_BL_PAGEDOWN (0x51|0x80) -#define SCAN_BL_CURSORRIGHT (0x4D|0x80) - -#define SCAN_SCROLLLOCK 0x46 -/* Keys often found in the key pad area. */ -#define SCAN_NUMLOCK 0x45 -#define SCAN_HOME 0x47 -#define SCAN_CURSORLEFT 0x4B -#define SCAN_END 0x4F -#define SCAN_SLASH 0x35 -#define SCAN_CURSORUP 0x48 -#define SCAN_CENTER 0x4C -#define SCAN_CURSORDOWN 0x50 -#define SCAN_INSERT 0x52 -#define SCAN_PAUSE 0xC5 -#define SCAN_ASTERISK 0x37 -#define SCAN_PAGEUP 0x49 -#define SCAN_CURSORRIGHT 0x4D -#define SCAN_PAGEDOWN 0x51 -#define SCAN_DELETE 0x53 -#define SCAN_KP_MINUS 0x4A -#define SCAN_KP_PLUS 0x4E -#define SCAN_KP_ENTER 0x1C - -#define SCAN_ESCAPE 0x01 -#define SCAN_F1 0x3B -#define SCAN_F2 0x3C -#define SCAN_F3 0x3D -#define SCAN_F4 0x3E -#define SCAN_F5 0x3F -#define SCAN_F6 0x40 -#define SCAN_F7 0x41 -#define SCAN_F8 0x42 -#define SCAN_F9 0x43 -#define SCAN_F10 0x44 -#define SCAN_F11 0x57 -#define SCAN_F12 0x58 - -#define MK_COUNT 256 -#define MK(k) SCAN_##k - -#endif diff --git a/branches/sdl2/src/attic/pc/main.c b/branches/sdl2/src/attic/pc/main.c deleted file mode 100644 index 6bdd7ce7..00000000 --- a/branches/sdl2/src/attic/pc/main.c +++ /dev/null @@ -1,553 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "main.h" -#include "throttle.h" - -#include "../common/cheat.h" - -#include "input.h" -#include "dface.h" - -extern int32 fps_scale; - -int CloseGame(void); - -static char *soundrecfn=0; /* File name of sound recording. */ - -static int ntsccol=0,ntschue=0,ntsctint=0; -int soundvol=100; -long soundq=0; -int _sound=1; -long soundrate=48000; -#ifdef WIN32 -long soundbufsize=52; -#else -long soundbufsize=24; -#endif - -#ifdef FRAMESKIP -static int frameskip=0; -#endif -static int inited=0; -static int isloaded=0; // Is game loaded? - -int srendlinev[2]={8,0}; -int erendlinev[2]={231,239}; - - -static uint8 *DrBaseDirectory; - -int eoptions=0; - -static void DriverKill(void); -static int DriverInitialize(FCEUGI *gi); -int gametype; - -FCEUGI *CurGame=NULL; - -static void ParseGI(FCEUGI *gi) -{ - ParseGIInput(gi); - gametype=gi->type; -} - -#ifndef EXTGUI -void FCEUD_PrintError(char *s) -{ - puts(s); -} - -void FCEUD_Message(char *s) -{ - fputs(s,stdout); -} -#endif - -static char *cpalette=0; -static void LoadCPalette(void) -{ - uint8 tmpp[192]; - FILE *fp; - - if(!(fp=FCEUD_UTF8fopen(cpalette,"rb"))) - { - printf(" Error loading custom palette from file: %s\n",cpalette); - return; - } - fread(tmpp,1,192,fp); - FCEUI_SetPaletteArray(tmpp); - fclose(fp); -} -#ifdef EXTGUI -extern CFGSTRUCT GUIConfig; -#endif -static CFGSTRUCT fceuconfig[]={ - AC(soundrate), - AC(soundq), - AC(_sound), - AC(soundvol), - AC(soundbufsize), - ACS(cpalette), - AC(ntsctint), - AC(ntschue), - AC(ntsccol), - AC(eoptions), - ACA(srendlinev), - ACA(erendlinev), - ADDCFGSTRUCT(InputConfig), - ADDCFGSTRUCT(DriverConfig), - #ifdef EXTGUI - ADDCFGSTRUCT(GUIConfig), - #endif - ENDCFGSTRUCT -}; - -static void SaveConfig(void) -{ - char tdir[2048]; - sprintf(tdir,"%s"PSS"fceu98.cfg",DrBaseDirectory); - FCEUI_GetNTSCTH(&ntsctint, &ntschue); - SaveFCEUConfig(tdir,fceuconfig); -} - -static void LoadConfig(void) -{ - char tdir[2048]; - sprintf(tdir,"%s"PSS"fceu98.cfg",DrBaseDirectory); - FCEUI_GetNTSCTH(&ntsctint, &ntschue); /* Get default settings for if - no config file exists. */ - LoadFCEUConfig(tdir,fceuconfig); - InputUserActiveFix(); -} - -static void CreateDirs(void) -{ - char *subs[7]={"fcs","fcm","snaps","gameinfo","sav","cheats","movie"}; - char tdir[2048]; - int x; - - #ifdef WIN32 - mkdir(DrBaseDirectory); - for(x=0;x<6;x++) - { - sprintf(tdir,"%s"PSS"%s",DrBaseDirectory,subs[x]); - mkdir(tdir); - } - #else - mkdir(DrBaseDirectory,S_IRWXU); - for(x=0;x<6;x++) - { - sprintf(tdir,"%s"PSS"%s",DrBaseDirectory,subs[x]); - mkdir(tdir,S_IRWXU); - } - #endif -} - -#ifndef WIN32 -static void SetSignals(void (*t)(int)) -{ - int sigs[11]={SIGINT,SIGTERM,SIGHUP,SIGPIPE,SIGSEGV,SIGFPE,SIGKILL,SIGALRM,SIGABRT,SIGUSR1,SIGUSR2}; - int x; - for(x=0;x<11;x++) - signal(sigs[x],t); -} - -static void CloseStuff(int signum) -{ - DriverKill(); - printf("\nSignal %d has been caught and dealt with...\n",signum); - switch(signum) - { - case SIGINT:printf("How DARE you interrupt me!\n");break; - case SIGTERM:printf("MUST TERMINATE ALL HUMANS\n");break; - case SIGHUP:printf("Reach out and hang-up on someone.\n");break; - case SIGPIPE:printf("The pipe has broken! Better watch out for floods...\n");break; - case SIGSEGV:printf("Iyeeeeeeeee!!! A segmentation fault has occurred. Have a fluffy day.\n");break; - /* So much SIGBUS evil. */ - #ifdef SIGBUS - #if(SIGBUS!=SIGSEGV) - case SIGBUS:printf("I told you to be nice to the driver.\n");break; - #endif - #endif - case SIGFPE:printf("Those darn floating points. Ne'er know when they'll bite!\n");break; - case SIGALRM:printf("Don't throw your clock at the meowing cats!\n");break; - case SIGABRT:printf("Abort, Retry, Ignore, Fail?\n");break; - case SIGUSR1: - case SIGUSR2:printf("Killing your processes is not nice.\n");break; - } - exit(1); -} -#endif - -static void DoArgs(int argc, char *argv[]) -{ - int x; - - static ARGPSTRUCT FCEUArgs[]={ - {"-soundbufsize",0,&soundbufsize,0}, - {"-soundrate",0,&soundrate,0}, - {"-soundq",0,&soundq,0}, -#ifdef FRAMESKIP - {"-frameskip",0,&frameskip,0}, -#endif - {"-sound",0,&_sound,0}, - {"-soundvol",0,&soundvol,0}, - {"-cpalette",0,&cpalette,0x4001}, - {"-soundrecord",0,&soundrecfn,0x4001}, - - {"-ntsccol",0,&ntsccol,0}, - {"-pal",0,&eoptions,0x8000|EO_PAL}, - - {"-lowpass",0,&eoptions,0x8000|EO_LOWPASS}, - {"-gg",0,&eoptions,0x8000|EO_GAMEGENIE}, - {"-no8lim",0,&eoptions,0x8001}, - {"-snapname",0,&eoptions,0x8000|EO_SNAPNAME}, - {"-nofs",0,&eoptions,0x8000|EO_NOFOURSCORE}, - {"-clipsides",0,&eoptions,0x8000|EO_CLIPSIDES}, - {"-nothrottle",0,&eoptions,0x8000|EO_NOTHROTTLE}, - {"-slstart",0,&srendlinev[0],0},{"-slend",0,&erendlinev[0],0}, - {"-slstartp",0,&srendlinev[1],0},{"-slendp",0,&erendlinev[1],0}, - {0,(int *)InputArgs,0,0}, - {0,(int *)DriverArgs,0,0}, - {0,0,0,0} - }; - - ParseArguments(argc, argv, FCEUArgs); - if(cpalette) - { - if(cpalette[0]=='0') - if(cpalette[1]==0) - { - free(cpalette); - cpalette=0; - } - } - FCEUI_SetVidSystem((eoptions&EO_PAL)?1:0); - FCEUI_SetGameGenie((eoptions&EO_GAMEGENIE)?1:0); - FCEUI_SetLowPass((eoptions&EO_LOWPASS)?1:0); - - FCEUI_DisableSpriteLimitation(eoptions&1); - FCEUI_SetSnapName(eoptions&EO_SNAPNAME); - - for(x=0;x<2;x++) - { - if(srendlinev[x]<0 || srendlinev[x]>239) srendlinev[x]=0; - if(erendlinev[x]239) erendlinev[x]=239; - } - - FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]); - DoDriverArgs(); -} - -#include "usage.h" - -/* Loads a game, given a full path/filename. The driver code must be - initialized after the game is loaded, because the emulator code - provides data necessary for the driver code(number of scanlines to - render, what virtual input devices to use, etc.). -*/ -int LoadGame(const char *path) -{ - FCEUGI *tmp; - - CloseGame(); - if(!(tmp=FCEUI_LoadGame(path,1))) - return 0; - CurGame=tmp; - ParseGI(tmp); - RefreshThrottleFPS(); - - if(!DriverInitialize(tmp)) - return(0); - if(soundrecfn) - { - if(!FCEUI_BeginWaveRecord(soundrecfn)) - { - free(soundrecfn); - soundrecfn=0; - } - } - isloaded=1; - #ifdef EXTGUI - if(eoptions&EO_AUTOHIDE) GUI_Hide(1); - #endif - - FCEUD_NetworkConnect(); - return 1; -} - -/* Closes a game. Frees memory, and deinitializes the drivers. */ -int CloseGame(void) -{ - if(!isloaded) return(0); - FCEUI_CloseGame(); - DriverKill(); - isloaded=0; - CurGame=0; - - if(soundrecfn) - FCEUI_EndWaveRecord(); - - #ifdef EXTGUI - GUI_Hide(0); - #endif - InputUserActiveFix(); - return(1); -} - -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); - -void DoFun(void) -{ - uint8 *gfx; - int32 *sound; - int32 ssize; - static int fskipc=0; - static int opause=0; - - #ifdef FRAMESKIP - fskipc=(fskipc+1)%(frameskip+1); - #endif - - if(NoWaiting) {gfx=0;} - FCEUI_Emulate(&gfx, &sound, &ssize, fskipc); - FCEUD_Update(gfx, sound, ssize); - - if(opause!=FCEUI_EmulationPaused()) - { - opause=FCEUI_EmulationPaused(); - SilenceSound(opause); - } -} - -int CLImain(int argc, char *argv[]) -{ - int ret; - - if(!(ret=FCEUI_Initialize())) - return(0); - - DrBaseDirectory=GetBaseDirectory(); - FCEUI_SetBaseDirectory(DrBaseDirectory); - - CreateDirs(); - - #ifdef EXTGUI - if(argc==2 && !strcmp(argv[1],"-help")) // I hope no one has a game named "-help" :b - #else - if(argc<=1) - #endif - { - ShowUsage(argv[0]); - return(0); - } - - LoadConfig(); - DoArgs(argc-2,&argv[1]); - FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); - if(cpalette) - LoadCPalette(); - - /* All the config files and arguments are parsed now. */ - #ifdef EXTGUI - return(1); - - #else - if(!LoadGame(argv[argc-1])) - { - DriverKill(); - return(0); - } - - while(CurGame) - DoFun(); - - #if(0) - { - int x; - for(x=1;x= GetMaxSound() && fps_scale<=256) uflow=1; /* Go into massive underflow mode. */ - - if(can > Count) can=Count; - else uflow=0; - - WriteSound(Buffer,can); - - //if(uflow) puts("Underflow"); - tmpcan = GetWriteSound(); - // don't underflow when scaling fps - if(fps_scale>256 || ((tmpcan < Count*0.90) && !uflow)) - { - if(XBuf && (inited&4) && !(NoWaiting & 2)) - BlitScreen(XBuf); - Buffer+=can; - Count-=can; - if(Count) - { - if(NoWaiting) - { - can=GetWriteSound(); - if(Count>can) Count=can; - WriteSound(Buffer,Count); - } - else - { - while(Count>0) - { - WriteSound(Buffer,(Count= (Count * 1.8))) - { - if(Count > tmpcan) Count=tmpcan; - while(tmpcan > 0) - { -// printf("Overwrite: %d\n", (Count <= tmpcan)?Count : tmpcan); - WriteSound(Buffer, (Count <= tmpcan)?Count : tmpcan); - tmpcan -= Count; - } - } - #endif - - } - else - { - if(!NoWaiting && (!(eoptions&EO_NOTHROTTLE) || FCEUI_EmulationPaused())) - SpeedThrottle(); - if(XBuf && (inited&4)) - { - BlitScreen(XBuf); - } - } - FCEUD_UpdateInput(); - //if(!Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE)) - // SpeedThrottle(); - //if(XBuf && (inited&4)) - //{ - // BlitScreen(XBuf); - //} - //if(Count) - // WriteSound(Buffer,Count,NoWaiting); - //FCEUD_UpdateInput(); -} - - -/* Maybe ifndef WXWINDOWS would be better? ^_^ */ -#ifndef EXTGUI -FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) -{ - return(fopen(fn,mode)); -} - - -#endif diff --git a/branches/sdl2/src/attic/pc/main.h b/branches/sdl2/src/attic/pc/main.h deleted file mode 100644 index 505eaf04..00000000 --- a/branches/sdl2/src/attic/pc/main.h +++ /dev/null @@ -1,55 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "../../driver.h" -#include "../common/config.h" -#include "../common/args.h" - -extern int eoptions; -#define EO_NO8LIM 1 -#define EO_SUBASE 2 -#define EO_CLIPSIDES 8 -#define EO_SNAPNAME 16 -#define EO_NOFOURSCORE 32 -#define EO_NOTHROTTLE 64 -#define EO_GAMEGENIE 128 -#define EO_PAL 256 -#define EO_LOWPASS 512 -#define EO_AUTOHIDE 1024 - -extern int srendlinev[2],erendlinev[2]; -extern int NoWaiting; - -extern int soundvol; -extern long soundq; -extern int _sound; -extern long soundrate; -extern long soundbufsize; - -int CLImain(int argc, char *argv[]); - -#ifdef __cplusplus -} -#endif - diff --git a/branches/sdl2/src/attic/pc/sdl-icon.h b/branches/sdl2/src/attic/pc/sdl-icon.h deleted file mode 100644 index 3a563d0b..00000000 --- a/branches/sdl2/src/attic/pc/sdl-icon.h +++ /dev/null @@ -1,134 +0,0 @@ -static const struct { - unsigned int width; - unsigned int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ - uint8 pixel_data[32 * 32 * 3 + 1]; -} fceu_playicon = { - 32, 32, 3, - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\0\0\0\0\0\0\0\0\0\\\223\373\\\223\373\267\317\373" - "\246\304\373\260\312\373\222\267\373\246\304\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\267\317\373\246\304\373\260\312\373\210\261\373\246\304\373\\\223\373\\" - "\223\373\210\261\373\222\267\373\267\317\373\241\301\373\\\223\373\\\223" - "\373\0\0\0\0\0\0\\\223\373\\\223\373\227\272\373\227\272\373\227\272\373" - "\227\272\373\227\272\373\227\272\373\\\223\373\\\223\373z`sr\242\373\227" - "\272\373\227\272\373\\\223\373\\\223\373\\\223\373\\\223\373\213\261\373" - "z\247\373\213\261\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\" - "\223\373\\\223\373\313i=\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40" - "\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40" - "\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\257T*\\\223\373\\\223\373\\\223" - "\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40" - "\355\235\203\355\235\203\341\232\205\341\232\205\365\255\233\355\235\203" - "\355\235\203\350\250\232\365\255\233\355\235\203\307L\14\307L\14\307L\14" - "\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256B\12\\\223\373" - "\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373" - "\\\223\373\315Z\40\273zc\233l_\325\225\205\325\225\205\325\225\205\273\212" - "\201\325\225\205\237qd\325\225\205\317\231\216\307L\14\307L\14\307L\14\307" - "L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256B\12\\\223\373\\" - "\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\" - "\223\373\315Z\40\344\232\203\301\215\201\344\232\203\273\212\201\325\225" - "\205\2114\10\344\232\203\350\250\232\325\225\205\333\230\205\307L\14\307" - "L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256" - "B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223" - "\373\\\223\373\\\223\373\315Z\40\2259\11}0\10\2259\11}0\10}0\10\307L\14\225" - "9\11d&\6}0\10}0\10\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14" - "\307L\14\307L\14\307L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373" - "\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40\355\235\203" - "\355\233\201\355\235\203\355\235\203\355\235\203\365\255\233\355\235\203" - "\341\232\205\355\235\203\355\235\203\307L\14\365\255\233\355\235\203\365" - "\255\233\355\235\203\355\235\203\355\235\203\355\235\203\355\235\203\307" - "L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373" - "\\\223\373\\\223\373\\\223\373\315Z\40\325\225\205\311\221\204\311\221\204" - "\325\225\205\311\221\204\325\225\205\311\221\204\325\225\205\325\225\205" - "\311\221\204\307L\14\325\225\205\311\221\204\325\225\205\311\221\204\325" - "\225\205\311\221\204\325\225\205\311\221\204\307L\14\256B\12\\\223\373\\" - "\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\" - "\223\373\315Z\40\325\225\205\325\225\205\325\225\205\325\225\205\325\225" - "\205\325\225\205\317\231\216\325\225\205\325\225\205\325\225\205\307L\14" - "\325\225\205\317\231\216\325\225\205\317\231\216\325\225\205\325\225\205" - "\273zc\241n_\307L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0" - "\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40\325\225\205\325" - "\225\205\325\225\205\365\255\233\333\243\231\325\225\205\333\230\205\325" - "\225\205\325\225\205\325\225\205\307L\14\325\225\205\317\223\204\325\225" - "\205\333\230\205\325\225\205\325\225\205\333\230\205\317\223\204\307L\14" - "\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\" - "\223\373\\\223\373\\\223\373\315Z\40\325\225\205\325\225\205\325\225\205" - "\325\225\205\311\221\204\325\225\205\325\225\205\325\225\205\344\232\203" - "\273\212\201\307L\14\325\225\205\273\212\201\325\225\205\325\225\205\344" - "\232\203\273\212\201\344\232\203\273\212\201\341\232\205\256B\12\\\223\373" - "\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373" - "\\\223\373\257T*d&\6d&\6d&\6d&\6d&\6d&\6d&\6d&\6}0\10d&\6\256B\12d&\6p+\7" - "d&\6d&\6}0\10d&\6}0\10d&\6d&\6\223@\26\\\223\373\\\223\373\\\223\373\\\223" - "\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\234\243" - "\335\213\237\344\237\244\333\251\247\326\237\244\333\\\223\373\267\252\317" - "\222\241\341\267\252\317\210\237\346\241\245\332\267\252\317\246\246\327" - "\246\246\327\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0" - "\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\257hT\\\223\373\213\261\373\\\223" - "\373\241\301\373\210\261\373\246\304\373\222\267\373\241\301\373\260\312" - "\373\\\223\373\237\277\373\246\304\373\267\317\373\241\301\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\246\304\373\\\223\373\241" - "\301\373\210\261\373\246\304\373\222\267\373\241\301\373\260\312\373\\\223" - "\373\237\277\373\246\304\373\267\317\373\241\301\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373" - "\\\223\373\\\223\373D\203\270D\203\270\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0" - "\0\0\0\0\\\223\373\\\223\373(\211n\0\247\0\0n\0(\211n\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\0\0\0\0\0\0\\\223\373(\211n\0\247\0\0\247\0\0\247\0\0\247\0(\211n\\\223" - "\373\\\223\373\\\223\373\\\223\373\210\261\373\246\304\373\241\301\373z\247" - "\373\\\223\373\227\272\373\227\272\373\227\272\373\227\272\373\227\272\373" - "\227\272\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\0\0\0\0\0\0(\211n\0\247\0\0n\0\0\247\0\\\215\12fs\16" - "\0\247\0(\211n\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\" - "\223\373\\\223\373Z\231Z[\230SZ\231Z[\230SZ\231Z[\230S\\\223\373\0\0\0\0" - "\0\0\0\247\0\0\247\0\0\247\0\0\247\0vy\7p|\7\0\247\0\0\247\0(\211n\\\223" - "\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373" - "\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373b\237L\200\317\20\200\317" - "\20\200\317\20\200\317\20\200\317\20\200\317\20[\223H\0\0\0\0\0\0\230P.\323" - "d0\230P.\323d0\221M&\313`%\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323" - "d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323" - "d0\230P.\323d0\230P.\323d0\0\0\0\0\0\0\0\0\0\237N(\225E\35\237N(\225E\35" - "\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237" - "N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(" - "\225E\35\237N(\225E\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", -}; - diff --git a/branches/sdl2/src/attic/pc/sdl-joystick.c b/branches/sdl2/src/attic/pc/sdl-joystick.c deleted file mode 100644 index 97f121f1..00000000 --- a/branches/sdl2/src/attic/pc/sdl-joystick.c +++ /dev/null @@ -1,99 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * Copyright (C) 2002 Paul Kuliniewicz - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* PK: SDL joystick input stuff */ - -#include -#include -#include -#include - -#include "sdl.h" - -#define MAX_JOYSTICKS 32 -static SDL_Joystick *Joysticks[MAX_JOYSTICKS] = {NULL}; - -int DTestButtonJoy(ButtConfig *bc) -{ - int x; - - for(x=0;xNumC;x++) - { - if(bc->ButtonNum[x]&0x8000) /* Axis "button" */ - { - int pos; - pos = SDL_JoystickGetAxis(Joysticks[bc->DeviceNum[x]], bc->ButtonNum[x]&16383); - if ((bc->ButtonNum[x]&0x4000) && pos <= -16383) - return(1); - else if (!(bc->ButtonNum[x]&0x4000) && pos >= 16363) - return(1); - } - else if(bc->ButtonNum[x]&0x2000) /* Hat "button" */ - { - if( SDL_JoystickGetHat(Joysticks[bc->DeviceNum[x]],(bc->ButtonNum[x]>>8)&0x1F) & (bc->ButtonNum[x]&0xFF)) - return(1); - } - else - if(SDL_JoystickGetButton(Joysticks[bc->DeviceNum[x]], bc->ButtonNum[x] )) - return(1); - } - return(0); -} - -static int jinited=0; - -/* Cleanup opened joysticks. */ -int KillJoysticks (void) -{ - int n; /* joystick index */ - - if(!jinited) return(0); - for (n = 0; n < MAX_JOYSTICKS; n++) - { - if (Joysticks[n] != 0) - SDL_JoystickClose(Joysticks[n]); - Joysticks[n]=0; - } - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - return(1); -} - -/* Initialize joysticks. */ -int InitJoysticks (void) -{ - int n; /* joystick index */ - int total; - - SDL_InitSubSystem(SDL_INIT_JOYSTICK); - total=SDL_NumJoysticks(); - if(total>MAX_JOYSTICKS) total=MAX_JOYSTICKS; - - for (n = 0; n < total; n++) - { - /* Open the joystick under SDL. */ - Joysticks[n] = SDL_JoystickOpen(n); - //printf("Could not open joystick %d: %s.\n", - //joy[n] - 1, SDL_GetError()); - continue; - } - jinited=1; - return(1); -} diff --git a/branches/sdl2/src/attic/pc/sdl-netplay.c b/branches/sdl2/src/attic/pc/sdl-netplay.c deleted file mode 100644 index 83de4ba5..00000000 --- a/branches/sdl2/src/attic/pc/sdl-netplay.c +++ /dev/null @@ -1,224 +0,0 @@ -#include "sdl.h" -#include -#include "sdl-netplay.h" - -char *ServerHost; - -static int LocalPortTCP=0xFCE; -static int LocalPortUDP=0xFCE; -static int RemotePortTCP=0xFCE; - -static int RemotePortUDP; /* Not configurable, figured out during handshake. */ - -static TCPsocket Socket; -static UDPsocket UDPSocket; -static SDLNet_SocketSet set; - - -static void en32(uint8 *buf, uint32 morp) -{ - buf[0]=morp; - buf[1]=morp>>8; - buf[2]=morp>>16; - buf[3]=morp>>24; -} - -static uint32 de32(uint8 *morp) -{ - return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)); -} - - - -int FCEUD_NetworkConnect(void) -{ - IPaddress rip; - - SDLNet_Init(); - - if(netplay==1) /* Be a server. */ - { - TCPsocket tmp; - Uint16 p=LocalPortUDP; - - SDLNet_ResolveHost(&rip,NULL,LocalPortTCP); - - UDPSocket=SDLNet_UDP_Open(&p); - - tmp=SDLNet_TCP_Open(&rip); - Socket=SDLNet_TCP_Accept(&tmp); - - memcpy(&rip,SDLNet_TCP_GetPeerAddress(Socket),sizeof(IPaddress)); - - { - uint8 buf[12]; - uint32 player=1; - - magic=SDL_GetTicks(); - - SDLNet_Write32(buf,uport); - SDLNet_Write32(buf+4,1); - SDLNet_Write32(buf+8,magic); - - SDLNet_TCP_Send(Socket, buf, 12); - - /* Get the UDP port the client is waiting for data on. */ - SDLNet_TCP_Recv(Socket, buf, 2); - RemotePortUDP=de32(buf); - } - } - else /* Be a client */ - { - SDLNet_ResolveHost(&rip,ServerHost,RemotePortTCP); - Socket=SDLNet_TCP_Open(&rip); - - { - Uint16 p=LocalPortUDP; - uint8 buf[12]; - - UDPSocket=SDLNet_UDP_Open(&p); - - /* Now, tell the server what local UDP port it should send to. */ - en32(buf,p); - SDLNet_TCP_Send(Socket, buf, 4); - - /* Get the UDP port from the server we should send data to. */ - SDLNet_TCP_Recv(Socket, buf, 12); - RemotePortUDP=de32(buf); - magic=de32(buf+8); - } - set=SDLNet_AllocSocketSet(1); - SDLNet_TCP_AddSocket(set,TCPSocket); - SDLNet_UDP_AddSocket(set,UDPSocket); - } // End client connect code. - - rip.port=RemotePortUDP; - SDLNet_UDP_Bind(UDPSocket, 0, &rip); -} - - - - -static int CheckUDP(uint8 *packet, int32 len, int32 alt) -{ - uint32 crc; - uint32 repcrc; - - crc=FCEUI_CRC32(0,packet+4,len+8); - repcrc=de32(packet); - - if(crc!=repcrc) return(0); /* CRC32 mismatch, bad packet. */ - packet+=4; - - if(de32(packet)!=magic) /* Magic number mismatch, bad or spoofed packet. */ - return(0); - - packet+=4; - if(alt) - { - if(de32(packet) -#include -#include -#else -#include -#include -#include -#endif -#include -#include - -#include "sdl.h" -#include "sdl-opengl.h" -#include "../common/vidblit.h" - -#ifndef APIENTRY -#define APIENTRY -#endif - -static GLuint textures[2]={0,0}; // Normal image, scanline overlay. - -static int left,right,top,bottom; // right and bottom are not inclusive. -static int scanlines; -static void *HiBuffer; - -void APIENTRY (*p_glBindTexture)(GLenum target,GLuint texture); -void APIENTRY (*p_glColorTableEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -void APIENTRY (*p_glTexImage2D)( GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ); -void APIENTRY (*p_glBegin)(GLenum mode); -void APIENTRY (*p_glVertex2f)(GLfloat x, GLfloat y); -void APIENTRY (*p_glTexCoord2f)(GLfloat s, GLfloat t); -void APIENTRY (*p_glEnd)(void); -void APIENTRY (*p_glEnable)(GLenum cap); -void APIENTRY (*p_glBlendFunc)(GLenum sfactor, GLenum dfactor); -const GLubyte* APIENTRY (*p_glGetString)(GLenum name); -void APIENTRY (*p_glViewport)(GLint x, GLint y,GLsizei width, GLsizei height); -void APIENTRY (*p_glGenTextures)(GLsizei n, GLuint *textures); -void APIENTRY (*p_glDeleteTextures)(GLsizei n,const GLuint *textures); -void APIENTRY (*p_glTexParameteri)(GLenum target, GLenum pname, GLint param); -void APIENTRY (*p_glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -void APIENTRY (*p_glLoadIdentity)(void); -void APIENTRY (*p_glClear)(GLbitfield mask); -void APIENTRY (*p_glMatrixMode)(GLenum mode); -void APIENTRY (*p_glDisable)(GLenum cap); - -void SetOpenGLPalette(uint8 *data) -{ - if(!HiBuffer) - { - p_glBindTexture(GL_TEXTURE_2D, textures[0]); - p_glColorTableEXT(GL_TEXTURE_2D,GL_RGB,256,GL_RGBA,GL_UNSIGNED_BYTE,data); - } - else - SetPaletteBlitToHigh((uint8*)data); -} - -void BlitOpenGL(uint8 *buf) -{ - p_glBindTexture(GL_TEXTURE_2D, textures[0]); - if(HiBuffer) - { - static int xo=0; - xo=(xo+1)&3; - Blit8ToHigh(buf,(uint8*)HiBuffer,256,240,256*4,1,1); - if(!xo) - p_glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,256,256, 0, GL_RGBA,GL_UNSIGNED_BYTE, - HiBuffer); - } - else - { - //glPixelStorei(GL_UNPACK_ROW_LENGTH, 256); - p_glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, - GL_COLOR_INDEX,GL_UNSIGNED_BYTE,buf); - } - - p_glBegin(GL_QUADS); - p_glTexCoord2f(1.0f*left/256, 1.0f*bottom/256); // Bottom left of our picture. - p_glVertex2f(-1.0f, -1.0f); // Bottom left of target. - - p_glTexCoord2f(1.0f*right/256, 1.0f*bottom/256); // Bottom right of our picture. - p_glVertex2f( 1.0f, -1.0f); // Bottom right of target. - - p_glTexCoord2f(1.0f*right/256, 1.0f*top/256); // Top right of our picture. - p_glVertex2f( 1.0f, 1.0f); // Top right of target. - - p_glTexCoord2f(1.0f*left/256, 1.0f*top/256); // Top left of our picture. - p_glVertex2f(-1.0f, 1.0f); // Top left of target. - p_glEnd(); - - //glDisable(GL_BLEND); - if(scanlines) - { - p_glEnable(GL_BLEND); - - p_glBindTexture(GL_TEXTURE_2D, textures[1]); - p_glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); - - p_glBegin(GL_QUADS); - - p_glTexCoord2f(1.0f*left/256, 1.0f*bottom/256); // Bottom left of our picture. - p_glVertex2f(-1.0f, -1.0f); // Bottom left of target. - - p_glTexCoord2f(1.0f*right/256, 1.0f*bottom/256); // Bottom right of our picture. - p_glVertex2f( 1.0f, -1.0f); // Bottom right of target. - - p_glTexCoord2f(1.0f*right/256, 1.0f*top/256); // Top right of our picture. - p_glVertex2f( 1.0f, 1.0f); // Top right of target. - - p_glTexCoord2f(1.0f*left/256, 1.0f*top/256); // Top left of our picture. - p_glVertex2f(-1.0f, 1.0f); // Top left of target. - - p_glEnd(); - p_glDisable(GL_BLEND); - } - SDL_GL_SwapBuffers(); -} - -void KillOpenGL(void) -{ - if(textures[0]) - p_glDeleteTextures(2, &textures[0]); - textures[0]=0; - if(HiBuffer) - { - free(HiBuffer); - HiBuffer=0; - } -} -/* Rectangle, left, right(not inclusive), top, bottom(not inclusive). */ - -int InitOpenGL(int l, int r, int t, int b, double xscale,double yscale, int efx, int ipolate, - int stretchx, int stretchy, SDL_Surface *screen) -{ - const char *extensions; - - #define LFG(x) if(!(p_##x = SDL_GL_GetProcAddress(#x))) return(0); - - #define LFGN(x) p_##x = SDL_GL_GetProcAddress(#x) - - LFG(glBindTexture); - LFGN(glColorTableEXT); - LFG(glTexImage2D); - LFG(glBegin); - LFG(glVertex2f); - LFG(glTexCoord2f); - LFG(glEnd); - LFG(glEnable); - LFG(glBlendFunc); - LFG(glGetString); - LFG(glViewport); - LFG(glGenTextures); - LFG(glDeleteTextures); - LFG(glTexParameteri); - LFG(glClearColor); - LFG(glLoadIdentity); - LFG(glClear); - LFG(glMatrixMode); - LFG(glDisable); - - left=l; - right=r; - top=t; - bottom=b; - - HiBuffer=0; - - extensions=(const char*)p_glGetString(GL_EXTENSIONS); - - if((efx&2) || !extensions || !p_glColorTableEXT || !strstr(extensions,"GL_EXT_paletted_texture")) - { - if(!(efx&2)) // Don't want to print out a warning message in this case... - FCEU_printf("Paletted texture extension not found. Using slower texture format..."); - HiBuffer=malloc(4*256*256); - memset(HiBuffer,0x00,4*256*256); - #ifndef LSB_FIRST - InitBlitToHigh(4,0xFF000000,0xFF0000,0xFF00,efx&2,0); - #else - InitBlitToHigh(4,0xFF,0xFF00,0xFF0000,efx&2,0); - #endif - } - - { - int rw=(r-l)*xscale; - int rh=(b-t)*yscale; - int sx=(screen->w-rw)/2; // Start x - int sy=(screen->h-rh)/2; // Start y - - if(stretchx) { sx=0; rw=screen->w; } - if(stretchy) { sy=0; rh=screen->h; } - p_glViewport(sx, sy, rw, rh); - } - p_glGenTextures(2, &textures[0]); - scanlines=0; - - if(efx&1) - { - uint8 *buf; - int x,y; - - scanlines=1; - - p_glBindTexture(GL_TEXTURE_2D, textures[1]); - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,ipolate?GL_LINEAR:GL_NEAREST); - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,ipolate?GL_LINEAR:GL_NEAREST); - - buf=(uint8*)malloc(256*(256*2)*4); - - for(y=0;y<(256*2);y++) - for(x=0;x<256;x++) - { - buf[y*256*4+x*4]=0; - buf[y*256*4+x*4+1]=0; - buf[y*256*4+x*4+2]=0; - buf[y*256*4+x*4+3]=(y&1)?0x00:0xFF; //?0xa0:0xFF; // <-- Pretty - //buf[y*256+x]=(y&1)?0x00:0xFF; - } - p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256, (scanlines==2)?256*4:512, 0, - GL_RGBA,GL_UNSIGNED_BYTE,buf); - free(buf); - } - p_glBindTexture(GL_TEXTURE_2D, textures[0]); - - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,ipolate?GL_LINEAR:GL_NEAREST); - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,ipolate?GL_LINEAR:GL_NEAREST); - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); - p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); - p_glEnable(GL_TEXTURE_2D); - p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Background color to black. - p_glMatrixMode(GL_MODELVIEW); - - p_glClear(GL_COLOR_BUFFER_BIT); - p_glLoadIdentity(); - - return(1); -} diff --git a/branches/sdl2/src/attic/pc/sdl-opengl.h b/branches/sdl2/src/attic/pc/sdl-opengl.h deleted file mode 100644 index ca786f53..00000000 --- a/branches/sdl2/src/attic/pc/sdl-opengl.h +++ /dev/null @@ -1,6 +0,0 @@ -void SetOpenGLPalette(uint8 *data); -void BlitOpenGL(uint8 *buf); -void KillOpenGL(void); -int InitOpenGL(int l, int r, int t, int b, double xscale,double yscale, int efx, int ipolate, - int stretchx, int stretchy, SDL_Surface *screen); - diff --git a/branches/sdl2/src/attic/pc/sdl-sound.c b/branches/sdl2/src/attic/pc/sdl-sound.c deleted file mode 100644 index f0b522c1..00000000 --- a/branches/sdl2/src/attic/pc/sdl-sound.c +++ /dev/null @@ -1,373 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include - -#include "sdl.h" - -#ifdef USE_SEXYAL - -#include "../sexyal/sexyal.h" - -static SexyAL *Interface; -static SexyAL_device *Output; -static SexyAL_format format; -static SexyAL_buffering buffering; - -uint32 GetMaxSound(void) -{ - return(buffering.totalsize); -} - -uint32 GetWriteSound(void) -{ - return(Output->CanWrite(Output)); -} - -void WriteSound(int32 *Buffer, int Count) -{ - //printf("%d\n",Output->CanWrite(Output)); - Output->Write(Output, Buffer, Count); -} - -int InitSound(FCEUGI *gi) -{ - if(!_sound) return(0); - - memset(&format,0,sizeof(format)); - memset(&buffering,0,sizeof(buffering)); - - FCEUI_SetSoundVolume(soundvol); - FCEUI_SetSoundQuality(soundq); - - Interface=SexyAL_Init(0); - - format.sampformat=SEXYAL_FMT_PCMS32S16; - format.channels=gi->soundchan?gi->soundchan:1; - format.rate=gi->soundrate?gi->soundrate:soundrate; - buffering.fragcount=buffering.fragsize=0; - buffering.ms=soundbufsize; - - FCEUI_printf("\nInitializing sound..."); - if(!(Output=Interface->Open(Interface,SEXYAL_ID_UNUSED,&format,&buffering))) - { - FCEUD_PrintError("Error opening a sound device."); - Interface->Destroy(Interface); - Interface=0; - return(0); - } - - if(soundq && format.rate!=48000 && format.rate!=44100 && format.rate!=96000) - { - FCEUD_PrintError("Set sound playback rate neither 44100, 48000, nor 96000, but needs to be when in high-quality sound mode."); - KillSound(); - return(0); - } - - if(format.rate<8192 || format.rate > 96000) - { - FCEUD_PrintError("Set rate is out of range [8192-96000]"); - KillSound(); - return(0); - } - FCEUI_printf("\n Bits: %u\n Rate: %u\n Channels: %u\n Byte order: CPU %s\n Buffer size: %u sample frames(%f ms)\n",(format.sampformat>>4)*8,format.rate,format.channels,format.byteorder?"Reversed":"Native",buffering.totalsize,(double)buffering.totalsize*1000/format.rate); - - format.sampformat=SEXYAL_FMT_PCMS32S16; - format.channels=gi->soundchan?gi->soundchan:1; - format.byteorder=0; - - //format.rate=gi->soundrate?gi->soundrate:soundrate; - - Output->SetConvert(Output,&format); - - FCEUI_Sound(format.rate); - return(1); -} - -void SilenceSound(int n) -{ - -} - -int KillSound(void) -{ - FCEUI_Sound(0); - if(Output) - Output->Close(Output); - if(Interface) - Interface->Destroy(Interface); - Interface=0; - if(!Output) return(0); - Output=0; - return(1); -} - -#elif USE_JACKACK /* Use JACK Audio Connection Kit */ - -#include -#include - -static jack_port_t *output_port = NULL; -static jack_client_t *client = NULL; -static jack_ringbuffer_t *tmpbuf = NULL; -static unsigned int BufferSize; - -static int process(jack_nframes_t nframes, void *arg) -{ - jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(output_port, nframes); - size_t canread; - - canread = jack_ringbuffer_read_space(tmpbuf) / sizeof(jack_default_audio_sample_t); - - if(canread > nframes) - canread = nframes; - - jack_ringbuffer_read(tmpbuf, out,canread * sizeof(jack_default_audio_sample_t)); - nframes -= canread; - - if(nframes) /* Buffer underflow. Hmm. */ - { - - } - -} - -uint32 GetMaxSound(void) -{ - return(BufferSize); -} - -uint32 GetWriteSound(void) -{ - return(jack_readbuffer_write_space / sizeof(jack_default_audio_sample_t)); -} - - -static void DeadSound(void *arg) -{ - puts("AGH! Sound server hates us! Let's go on a rampage."); -} - -int InitSound(FCEUGI *gi) -{ - const char **ports; - - client = jack_client_new("FCE Ultra"); - - jack_set_process_callback(client, process, 0); - jack_on_shutdown(client, DeadSound, 0); - - printf("%ld\n",jack_get_sample_rate(client)); - - output_port = jack_port_register(client, "output", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - - BufferSize = soundbufsize * soundrate / 1000; - - tmpbuf = jack_ringbuffer_create(BufferSize * sizeof(jack_default_audio_sample_t)); - - jack_activate(client); - - - ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical | JackPortIsInput); - jack_connect(client, jack_port_name(output_port), ports[0]); - free(ports); -} - -void WriteSound(int32 *buf, int Count) -{ - jack_default_audio_sample_t jbuf[Count]; - int x; - - for(x=0;x>= 1; - - while(len) - { - int16 sample = 0; - if(BufferIn) - { - sample = Buffer[BufferRead]; - BufferRead = (BufferRead + 1) % BufferSize; - BufferIn--; - } - else sample = 0; - - *tmps = sample; - tmps++; - len--; - } -} - -int InitSound(FCEUGI *gi) -{ - SDL_AudioSpec spec; - if(!_sound) return(0); - - memset(&spec,0,sizeof(spec)); - if(SDL_InitSubSystem(SDL_INIT_AUDIO)<0) - { - puts(SDL_GetError()); - KillSound(); - return(0); - } - - spec.freq = soundrate; - spec.format = AUDIO_S16SYS; - spec.channels = 1; - spec.samples = 256; - spec.callback = fillaudio; - spec.userdata = 0; - - BufferSize = soundbufsize * soundrate / 1000; - - BufferSize -= spec.samples * 2; /* SDL uses at least double-buffering, so - multiply by 2. */ - - if(BufferSize < spec.samples) BufferSize = spec.samples; - - Buffer = malloc(sizeof(int) * BufferSize); - BufferRead = BufferWrite = BufferIn = 0; - - //printf("SDL Size: %d, Internal size: %d\n",spec.samples,BufferSize); - - if(SDL_OpenAudio(&spec,0)<0) - { - puts(SDL_GetError()); - KillSound(); - return(0); - } - SDL_PauseAudio(0); - FCEUI_Sound(soundrate); - return(1); -} - - -uint32 GetMaxSound(void) -{ - return(BufferSize); -} - -uint32 GetWriteSound(void) -{ - return(BufferSize - BufferIn); -} - -void WriteSound(int32 *buf, int Count) -{ - while(Count) - { - while(BufferIn == BufferSize) SDL_Delay(1); - Buffer[BufferWrite] = *buf; - Count--; - BufferWrite = (BufferWrite + 1) % BufferSize; - BufferIn++; - buf++; - } -} - -void SilenceSound(int n) -{ - SDL_PauseAudio(n); -} - -int KillSound(void) -{ - FCEUI_Sound(0); - SDL_CloseAudio(); - SDL_QuitSubSystem(SDL_INIT_AUDIO); - if(Buffer) - { - free(Buffer); - Buffer = 0; - } - return(0); -} - - -#endif - - -static int mute=0; -static int soundvolume=100; -void FCEUD_SoundVolumeAdjust(int n) -{ - switch(n) - { - case -1: soundvolume-=10; if(soundvolume<0) soundvolume=0; break; - case 0: soundvolume=100; break; - case 1: soundvolume+=10; if(soundvolume>150) soundvolume=150; break; - } - mute=0; - FCEUI_SetSoundVolume(soundvolume); - FCEU_DispMessage("Sound volume %d.", soundvolume); -} -void FCEUD_SoundToggle(void) -{ - if(mute) - { - mute=0; - FCEUI_SetSoundVolume(soundvolume); - FCEU_DispMessage("Sound mute off."); - } - else - { - mute=1; - FCEUI_SetSoundVolume(0); - FCEU_DispMessage("Sound mute on."); - } -} diff --git a/branches/sdl2/src/attic/pc/sdl-throttle.c b/branches/sdl2/src/attic/pc/sdl-throttle.c deleted file mode 100644 index 253ad885..00000000 --- a/branches/sdl2/src/attic/pc/sdl-throttle.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "sdl.h" -#include "throttle.h" - -static uint64 tfreq; -static uint64 desiredfps; - -static int32 fps_scale_table[]= -{ 3, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 2048 }; -int32 fps_scale = 256; - -#define fps_table_size (sizeof(fps_scale_table)/sizeof(fps_scale_table[0])) - -void RefreshThrottleFPS(void) -{ - desiredfps=FCEUI_GetDesiredFPS()>>8; - desiredfps=(desiredfps*fps_scale)>>8; - tfreq=10000000; - tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ -} - -void SpeedThrottle(void) -{ - static uint64 ttime,ltime=0; - - waiter: - - ttime=SDL_GetTicks(); - ttime*=10000; - - if( (ttime-ltime) < (tfreq/desiredfps) ) - { - int64 delay; - delay=(tfreq/desiredfps)-(ttime-ltime); - if(delay>0) - SDL_Delay(delay/10000); - //printf("%d\n",(tfreq/desiredfps)-(ttime-ltime)); - //SDL_Delay((tfreq/desiredfps)-(ttime-ltime)); - goto waiter; - } - if( (ttime-ltime) >= (tfreq*4/desiredfps)) - ltime=ttime; - else - ltime+=tfreq/desiredfps; -} - -void IncreaseEmulationSpeed(void) -{ - int i; - for(i=1; fps_scale_table[i]>8); -} - -void DecreaseEmulationSpeed(void) -{ - int i; - for(i=1; fps_scale_table[i]>8); -} - -void FCEUD_SetEmulationSpeed(int cmd) -{ - switch(cmd) - { - case EMUSPEED_SLOWEST: fps_scale=fps_scale_table[0]; break; - case EMUSPEED_SLOWER: DecreaseEmulationSpeed(); break; - case EMUSPEED_NORMAL: fps_scale=256; break; - case EMUSPEED_FASTER: IncreaseEmulationSpeed(); break; - case EMUSPEED_FASTEST: fps_scale=fps_scale_table[fps_table_size-1]; break; - default: - return; - } - - RefreshThrottleFPS(); - - FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8); -} diff --git a/branches/sdl2/src/attic/pc/sdl-video.c b/branches/sdl2/src/attic/pc/sdl-video.c deleted file mode 100644 index 5886f0fb..00000000 --- a/branches/sdl2/src/attic/pc/sdl-video.c +++ /dev/null @@ -1,432 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include - -#include "sdl.h" -#include "sdl-opengl.h" -#include "../common/vidblit.h" - -#include "sdl-icon.h" -#include "dface.h" - -SDL_Surface *screen; -SDL_Surface *BlitBuf; // Used as a buffer when using hardware-accelerated blits. -SDL_Surface *IconSurface=NULL; - -static int curbpp; -static int srendline,erendline; -static int tlines; -static int inited=0; - -#ifdef OPENGL -extern int sdlhaveogl; -static int usingogl; -static double exs,eys; -#else -static int exs,eys; -#endif -static int eefx; - -#define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0)) -#define NOFFSET (eoptions&EO_CLIPSIDES?8:0) - - -static int paletterefresh; - -/* Return 1 if video was killed, 0 otherwise(video wasn't initialized). */ -int KillVideo(void) -{ - if(IconSurface) - { - SDL_FreeSurface(IconSurface); - IconSurface=0; - } - - if(inited&1) - { - #ifdef OPENGL - if(usingogl) - KillOpenGL(); - else - #endif - if(curbpp>8) - KillBlitToHigh(); - SDL_QuitSubSystem(SDL_INIT_VIDEO); - inited&=~1; - return(1); - } - inited=0; - return(0); -} - -static int sponge; - -int InitVideo(FCEUGI *gi) -{ - const SDL_VideoInfo *vinf; - int flags=0; - - FCEUI_printf("Initializing video..."); - - FCEUI_GetCurrentVidSystem(&srendline,&erendline); - - if(_fullscreen) sponge=Settings.specialfs; - else sponge=Settings.special; - - - #ifdef OPENGL - usingogl=0; - if(_opengl && sdlhaveogl && !sponge) - { - flags=SDL_OPENGL; - usingogl=1; - } - #endif - - #ifdef EXTGUI - GUI_SetVideo(_fullscreen, 0, 0); - #endif - - if(!(SDL_WasInit(SDL_INIT_VIDEO)&SDL_INIT_VIDEO)) - if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1) - { - FCEUD_PrintError(SDL_GetError()); - return(0); - } - inited|=1; - - SDL_ShowCursor(0); - tlines=erendline-srendline+1; - - vinf=SDL_GetVideoInfo(); - - if(vinf->hw_available) - flags|=SDL_HWSURFACE; - - if(_fullscreen) - flags|=SDL_FULLSCREEN; - - flags|=SDL_HWPALETTE; - - //flags|=SDL_DOUBLEBUF; - #ifdef OPENGL - if(usingogl) - { - FCEU_printf("\n Initializing with OpenGL(Use \"-opengl 0\" to disable).\n"); - if(_doublebuf) - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - } - else - #endif - if(_doublebuf && (flags&SDL_HWSURFACE)) - flags|=SDL_DOUBLEBUF; - - if(_fullscreen) - { - int desbpp=_bpp; - - exs=_xscalefs; - eys=_yscalefs; - eefx=_efxfs; - - #ifdef OPENGL - if(!usingogl) {exs=(int)exs;eys=(int)eys;} - else desbpp=0; - - if(sponge) - { - exs=eys=2; - if(sponge == 3 || sponge == 4) exs = eys = 3; - eefx=0; - if(sponge == 1 || sponge == 3) desbpp = 32; - } - - - if( (usingogl && !_stretchx) || !usingogl) - #endif - if(_xres= 3) exs=eys=3; - eefx=0; - // SDL's 32bpp->16bpp code is slighty faster than mine, at least :/ - if(sponge == 1 || sponge == 3) desbpp=32; - } - - #ifdef OPENGL - if(!usingogl) {exs=(int)exs;eys=(int)eys;} - if(exs <= 0.01) - { - FCEUD_PrintError("xscale out of bounds."); - KillVideo(); - return(0); - } - if(eys <= 0.01) - { - FCEUD_PrintError("yscale out of bounds."); - KillVideo(); - return(0); - } - #endif - - #ifdef EXTGUI - GUI_SetVideo(_fullscreen, (NWIDTH*exs), tlines*eys); - #endif - - screen = SDL_SetVideoMode((NWIDTH*exs), tlines*eys, desbpp, flags); - } - curbpp=screen->format->BitsPerPixel; - if(!screen) - { - FCEUD_PrintError(SDL_GetError()); - KillVideo(); - return(0); - } - //BlitBuf=SDL_CreateRGBSurface(SDL_HWSURFACE,256,240,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0); - - inited=1; - - FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",screen->w,screen->h,screen->format->BitsPerPixel,_fullscreen?"full screen":""); - if(curbpp!=16 && curbpp!=24 && curbpp!=8 && curbpp!=32) - { - FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n",curbpp); - KillVideo(); - return(0); - } - - if(gi->name) - SDL_WM_SetCaption(gi->name,gi->name); - else - SDL_WM_SetCaption("FCE Ultra","FCE Ultra"); - - #ifdef LSB_FIRST - IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF,0xFF00,0xFF0000,0x00); - #else - IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF0000,0xFF00,0xFF,0x00); - #endif - - SDL_WM_SetIcon(IconSurface,0); - - paletterefresh=1; - - if(curbpp>8) - #ifdef OPENGL - if(!usingogl) - #endif - InitBlitToHigh(curbpp>>3,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,eefx,sponge); - #ifdef OPENGL - if(usingogl) - if(!InitOpenGL((eoptions&EO_CLIPSIDES)?8:0,256-((eoptions&EO_CLIPSIDES)?8:0),srendline,erendline+1,exs,eys,eefx,_openglip,_stretchx,_stretchy,screen)) - { - FCEUD_PrintError("Error initializing OpenGL."); - KillVideo(); - return(0); - } - #endif - return 1; -} - -void ToggleFS(void) -{ - extern FCEUGI *CurGame; - KillVideo(); - _fullscreen=!_fullscreen; - - if(!InitVideo(CurGame)) - { - _fullscreen=!_fullscreen; - InitVideo(CurGame); - } -} - -static SDL_Color psdl[256]; -void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b) -{ - psdl[index].r=r; - psdl[index].g=g; - psdl[index].b=b; - - paletterefresh=1; -} - -void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b) -{ - *r=psdl[index].r; - *g=psdl[index].g; - *b=psdl[index].b; -} - -static void RedoPalette(void) -{ - #ifdef OPENGL - if(usingogl) - SetOpenGLPalette((uint8*)psdl); - else - #endif - { - if(curbpp>8) - SetPaletteBlitToHigh((uint8*)psdl); - else - { - SDL_SetPalette(screen,SDL_PHYSPAL,psdl,0,256); - } - } -} - -void LockConsole(){} -void UnlockConsole(){} -void BlitScreen(uint8 *XBuf) -{ - SDL_Surface *TmpScreen; - uint8 *dest; - int xo=0,yo=0; - - if(!screen) return; - - if(paletterefresh) - { - RedoPalette(); - paletterefresh=0; - } - - #ifdef OPENGL - if(usingogl) - { - BlitOpenGL(XBuf); - return; - } - #endif - - XBuf+=srendline*256; - - if(BlitBuf) TmpScreen=BlitBuf; - else TmpScreen=screen; - - if(SDL_MUSTLOCK(TmpScreen)) - if(SDL_LockSurface(TmpScreen)) - { - return; - } - - dest=(uint8*)TmpScreen->pixels; - - if(_fullscreen) - { - xo=(((TmpScreen->w-NWIDTH*exs))/2); - dest+=xo*(curbpp>>3); - if(TmpScreen->h>(tlines*eys)) - { - yo=((TmpScreen->h-tlines*eys)/2); - dest+=yo*TmpScreen->pitch; - } - } - - if(curbpp>8) - { - if(BlitBuf) - Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,1,1); - else - Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,exs,eys); - } - else - { - if(BlitBuf) - Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,1,1,0,sponge); - else - Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,exs,eys,eefx,sponge); - } - if(SDL_MUSTLOCK(TmpScreen)) - SDL_UnlockSurface(TmpScreen); - - if(BlitBuf) - { - SDL_Rect srect; - SDL_Rect drect; - - srect.x=0; - srect.y=0; - srect.w=NWIDTH; - srect.h=tlines; - - drect.x=0; - drect.y=0; - drect.w=exs*NWIDTH; - drect.h=eys*tlines; - - SDL_BlitSurface(BlitBuf, &srect,screen,&drect); - } - - SDL_UpdateRect(screen, xo, yo, NWIDTH*exs, tlines*eys); - - if(screen->flags&SDL_DOUBLEBUF) - SDL_Flip(screen); -} - -uint32 PtoV(uint16 x, uint16 y) -{ - y=(double)y/eys; - x=(double)x/exs; - if(eoptions&EO_CLIPSIDES) - x+=8; - y+=srendline; - return(x|(y<<16)); -} diff --git a/branches/sdl2/src/attic/pc/sdl-video.h b/branches/sdl2/src/attic/pc/sdl-video.h deleted file mode 100644 index 4a4f056d..00000000 --- a/branches/sdl2/src/attic/pc/sdl-video.h +++ /dev/null @@ -1 +0,0 @@ -uint32 PtoV(uint16 x, uint16 y); diff --git a/branches/sdl2/src/attic/pc/sdl.c b/branches/sdl2/src/attic/pc/sdl.c deleted file mode 100644 index c2e939fc..00000000 --- a/branches/sdl2/src/attic/pc/sdl.c +++ /dev/null @@ -1,429 +0,0 @@ -#include -#include -#include - -#include "sdl.h" -#include "sdl-video.h" -#ifdef NETWORK -#include "unix-netplay.h" -#endif - -DSETTINGS Settings; -CFGSTRUCT DriverConfig[]={ - #ifdef OPENGL - AC(_stretchx), - AC(_stretchy), - AC(_opengl), - AC(_openglip), - #endif - AC(Settings.special), - AC(Settings.specialfs), - AC(_doublebuf), - AC(_xscale), - AC(_yscale), - AC(_xscalefs), - AC(_yscalefs), - AC(_bpp), - AC(_efx), - AC(_efxfs), - AC(_fullscreen), - AC(_xres), - AC(_yres), - #ifdef NETWORK - ACS(netplaynick), - AC(netlocalplayers), - AC(tport), - ACS(netpassword), - ACS(netgamekey), - #endif - ENDCFGSTRUCT -}; - -//-fshack x Set the environment variable SDL_VIDEODRIVER to \"x\" when -// entering full screen mode and x is not \"0\". - -char *DriverUsage= -"-xres x Set horizontal resolution to x for full screen mode.\n\ --yres x Set vertical resolution to x for full screen mode.\n\ --xscale(fs) x Multiply width by x(Real numbers >0 with OpenGL, otherwise integers >0).\n\ --yscale(fs) x Multiply height by x(Real numbers >0 with OpenGL, otherwise integers >0).\n\ --bpp(fs) x Bits per pixel for SDL surface(and video mode in fs). 8, 16, 32.\n\ --opengl x Enable OpenGL support if x is 1.\n\ --openglip x Enable OpenGL linear interpolation if x is 1.\n\ --doublebuf x \n\ --special(fs) x Specify special scaling filter.\n\ --stretch(x/y) x Stretch to fill surface on x or y axis(fullscreen, only with OpenGL).\n\ --efx(fs) x Enable special effects. Logically OR the following together:\n\ - 1 = scanlines(for yscale>=2).\n\ - 2 = TV blur(for bpp of 16 or 32).\n\ --fs x Select full screen mode if x is non zero.\n\ --connect s Connect to server 's' for TCP/IP network play.\n\ --netnick s Set the nickname to use in network play.\n\ --netgamekey s Use key 's' to create a unique session for the game loaded.\n\ --netpassword s Password to use for connecting to the server.\n\ --netlocalplayers x Set the number of local players.\n\ --netport x Use TCP/IP port x for network play."; - -ARGPSTRUCT DriverArgs[]={ - #ifdef OPENGL - {"-opengl",0,&_opengl,0}, - {"-openglip",0,&_openglip,0}, - {"-stretchx",0,&_stretchx,0}, - {"-stretchy",0,&_stretchy,0}, - #endif - {"-special",0,&Settings.special,0}, - {"-specialfs",0,&Settings.specialfs,0}, - {"-doublebuf",0,&_doublebuf,0}, - {"-bpp",0,&_bpp,0}, - {"-xscale",0,&_xscale,2}, - {"-yscale",0,&_yscale,2}, - {"-efx",0,&_efx,0}, - {"-xscalefs",0,&_xscalefs,2}, - {"-yscalefs",0,&_yscalefs,2}, - {"-efxfs",0,&_efxfs,0}, - {"-xres",0,&_xres,0}, - {"-yres",0,&_yres,0}, - {"-fs",0,&_fullscreen,0}, - //{"-fshack",0,&_fshack,0x4001}, - #ifdef NETWORK - {"-connect",0,&netplayhost,0x4001}, - {"-netport",0,&tport,0}, - {"-netlocalplayers",0,&netlocalplayers,0}, - {"-netnick",0,&netplaynick,0x4001}, - {"-netpassword",0,&netpassword,0x4001}, - #endif - {0,0,0,0} -}; - -static void SetDefaults(void) -{ - Settings.special=Settings.specialfs=0; - _bpp=8; - _xres=640; - _yres=480; - _fullscreen=0; - _xscale=2.50; - _yscale=2; - _xscalefs=_yscalefs=2; - _efx=_efxfs=0; - //_fshack=_fshacksave=0; -#ifdef OPENGL - _opengl=1; - _stretchx=1; - _stretchy=0; - _openglip=1; -#endif -} - -void DoDriverArgs(void) -{ - #ifdef BROKEN - if(_fshack) - { - if(_fshack[0]=='0') - if(_fshack[1]==0) - { - free(_fshack); - _fshack=0; - } - } - #endif -} - -int InitMouse(void) -{ - return(0); -} - -void KillMouse(void){} - -void GetMouseData(uint32 *d) -{ - if(FCEUI_IsMovieActive()<0) - return; - - int x,y; - uint32 t; - - t=SDL_GetMouseState(&x,&y); - #ifdef EXTGUI - GUI_GetMouseState(&t,&x,&y); - #endif - - d[2]=0; - if(t&SDL_BUTTON(1)) - d[2]|=1; - if(t&SDL_BUTTON(3)) - d[2]|=2; - t=PtoV(x,y); - d[0]=t&0xFFFF; - d[1]=(t>>16)&0xFFFF; -} - -int InitKeyboard(void) -{ - return(1); -} - -int UpdateKeyboard(void) -{ - return(1); -} - -void KillKeyboard(void) -{ - -} - - -void UpdatePhysicalInput(void) -{ - SDL_Event event; - - while(SDL_PollEvent(&event)) - { - switch(event.type) - { - //case SDL_SYSWMEVENT: puts("Nifty keen");break; - //case SDL_VIDEORESIZE: puts("Okie dokie");break; - case SDL_QUIT: CloseGame();puts("Quit");break; - } - //printf("Event: %d\n",event.type); - //fflush(stdout); - } - //SDL_PumpEvents(); -} - -static uint8 *KeyState=NULL; -char *GetKeyboard(void) -{ - KeyState=SDL_GetKeyState(0); - #ifdef EXTGUI - { char *tmp=GUI_GetKeyboard(); if(tmp) KeyState=tmp; } - #endif - return((char *)KeyState); -} - -#ifdef WIN32 -#include - - /* Stupid SDL */ - #ifdef main - #undef main - #endif -#endif - -#ifndef EXTGUI -uint8 *GetBaseDirectory(void) -{ - uint8 *ol; - uint8 *ret; - - ol=getenv("HOME"); - - if(ol) - { - ret=malloc(strlen(ol)+1+strlen("./fceultra")); - strcpy(ret,ol); - strcat(ret,"/.fceultra"); - } - else - { - #ifdef WIN32 - char *sa; - - ret=malloc(MAX_PATH+1); - GetModuleFileName(NULL,ret,MAX_PATH+1); - - sa=strrchr(ret,'\\'); - if(sa) - *sa = 0; - #else - ret=malloc(1); - ret[0]=0; - #endif - printf("%s\n",ret); - } - return(ret); -} -#endif - -#ifdef OPENGL -int sdlhaveogl; -#endif - - -int DTestButton(ButtConfig *bc) -{ - int x; - - for(x=0;xNumC;x++) - { - if(bc->ButtType[x]==BUTTC_KEYBOARD) - { - if(KeyState[bc->ButtonNum[x]]) - return(1); - } - else if(bc->ButtType[x]==BUTTC_JOYSTICK) - { - if(DTestButtonJoy(bc)) - return(1); - } - } - return(0); -} - -static int bcpv,bcpj; - -int ButtonConfigBegin(void) -{ - SDL_Surface *screen; - SDL_QuitSubSystem(SDL_INIT_VIDEO); - bcpv=KillVideo(); - bcpj=KillJoysticks(); - - if(!(SDL_WasInit(SDL_INIT_VIDEO)&SDL_INIT_VIDEO)) - if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1) - { - FCEUD_Message(SDL_GetError()); - return(0); - } - - screen = SDL_SetVideoMode(300, 1, 8, 0); - SDL_WM_SetCaption("Button Config",0); - InitJoysticks(); - - return(1); -} - -void ButtonConfigEnd(void) -{ - extern FCEUGI *CurGame; - KillJoysticks(); - SDL_QuitSubSystem(SDL_INIT_VIDEO); - if(bcpv) InitVideo(CurGame); - if(bcpj) InitJoysticks(); -} - -int DWaitButton(const uint8 *text, ButtConfig *bc, int wb) -{ - SDL_Event event; - static int32 LastAx[64][64]; - int x,y; - - SDL_WM_SetCaption(text,0); - #ifndef EXTGUI - puts(text); - #endif - for(x=0;x<64;x++) - for(y=0;y<64;y++) - LastAx[x][y]=0x100000; - - while(SDL_WaitEvent(&event)) - { - switch(event.type) - { - case SDL_KEYDOWN:bc->ButtType[wb]=BUTTC_KEYBOARD; - bc->DeviceNum[wb]=0; - bc->ButtonNum[wb]=event.key.keysym.sym; - return(1); - case SDL_JOYBUTTONDOWN:bc->ButtType[wb]=BUTTC_JOYSTICK; - bc->DeviceNum[wb]=event.jbutton.which; - bc->ButtonNum[wb]=event.jbutton.button; - return(1); - case SDL_JOYHATMOTION:if(event.jhat.value != SDL_HAT_CENTERED) - { - bc->ButtType[wb]=BUTTC_JOYSTICK; - bc->DeviceNum[wb]=event.jhat.which; - bc->ButtonNum[wb]=0x2000|((event.jhat.hat&0x1F)<<8)|event.jhat.value; - return(1); - } - break; - case SDL_JOYAXISMOTION: - if(LastAx[event.jaxis.which][event.jaxis.axis]==0x100000) - { - if(abs(event.jaxis.value)<1000) - LastAx[event.jaxis.which][event.jaxis.axis]=event.jaxis.value; - } - else - { - if(abs(LastAx[event.jaxis.which][event.jaxis.axis]-event.jaxis.value)>=8192) - { - bc->ButtType[wb]=BUTTC_JOYSTICK; - bc->DeviceNum[wb]=event.jaxis.which; - bc->ButtonNum[wb]=0x8000|(event.jaxis.axis)|((event.jaxis.value<0)?0x4000:0); - return(1); - } - } - break; - } - } - - return(0); -} - -#ifdef EXTGUI -int FCEUSDLmain(int argc, char *argv[]) -#else -int main(int argc, char *argv[]) -#endif -{ - FCEUD_Message("\nStarting FCE Ultra "FCEU_VERSION"...\n"); - - #ifdef WIN32 - /* Taken from win32 sdl_main.c */ - SDL_SetModuleHandle(GetModuleHandle(NULL)); - #endif - - if(SDL_Init(SDL_INIT_VIDEO)) /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */ - { - printf("Could not initialize SDL: %s.\n", SDL_GetError()); - return(-1); - } - - #ifdef OPENGL - #ifdef APPLEOPENGL - sdlhaveogl = 1; /* Stupid something... Hack. */ - #else - if(!SDL_GL_LoadLibrary(0)) sdlhaveogl=1; - else sdlhaveogl=0; - #endif - #endif - - SetDefaults(); - - { - int ret=CLImain(argc,argv); - SDL_Quit(); - return(ret?0:-1); - } -} - - -uint64 FCEUD_GetTime(void) -{ - return(SDL_GetTicks()); -} - -uint64 FCEUD_GetTimeFreq(void) -{ - return(1000); -} - -// dummy functions - -#define DUMMY(f) void f(void) {FCEU_DispMessage("Not implemented.");} -DUMMY(FCEUD_HideMenuToggle) -DUMMY(FCEUD_TurboOn) -DUMMY(FCEUD_TurboOff) -DUMMY(FCEUD_SaveStateAs) -DUMMY(FCEUD_LoadStateFrom) -DUMMY(FCEUD_MovieRecordTo) -DUMMY(FCEUD_MovieReplayFrom) -DUMMY(FCEUD_ToggleStatusIcon) -DUMMY(FCEUD_AviRecordTo) -DUMMY(FCEUD_AviStop) -void FCEUI_AviVideoUpdate(const unsigned char* buffer) {FCEU_DispMessage("Not implemented.");} -int FCEUD_ShowStatusIcon(void) {FCEU_DispMessage("Not implemented."); return 0; } -int FCEUI_AviIsRecording(void) {return 0;} - diff --git a/branches/sdl2/src/attic/pc/sdl.h b/branches/sdl2/src/attic/pc/sdl.h deleted file mode 100644 index 791316a8..00000000 --- a/branches/sdl2/src/attic/pc/sdl.h +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "main.h" -#include "dface.h" -#include "input.h" - -int DTestButtonJoy(ButtConfig *bc); - -typedef struct { - int xres; - int yres; - double xscale,yscale; - double xscalefs,yscalefs; - int efx,efxfs; - int bpp; - int fullscreen; - int doublebuf; - char *fshack; - char *fshacksave; - #ifdef OPENGL - int opengl; - int openglip; - int stretchx,stretchy; - #endif - int special,specialfs; -} DSETTINGS; - -extern DSETTINGS Settings; - -#define _doublebuf Settings.doublebuf -#define _bpp Settings.bpp -#define _xres Settings.xres -#define _yres Settings.yres -#define _fullscreen Settings.fullscreen -#define _xscale Settings.xscale -#define _yscale Settings.yscale -#define _xscalefs Settings.xscalefs -#define _yscalefs Settings.yscalefs -#define _efx Settings.efx -#define _efxfs Settings.efxfs -#define _ebufsize Settings.ebufsize -#define _fshack Settings.fshack -#define _fshacksave Settings.fshacksave - -#ifdef OPENGL -#define _opengl Settings.opengl -#define _openglip Settings.openglip -#define _stretchx Settings.stretchx -#define _stretchy Settings.stretchy -#endif - diff --git a/branches/sdl2/src/attic/pc/throttle.c b/branches/sdl2/src/attic/pc/throttle.c deleted file mode 100644 index 422dad79..00000000 --- a/branches/sdl2/src/attic/pc/throttle.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include "main.h" -#include "throttle.h" - -static uint64 tfreq; -static uint64 desiredfps; - -void RefreshThrottleFPS(void) -{ - desiredfps=FCEUI_GetDesiredFPS()>>8; - tfreq=1000000; - tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ -} - -static uint64 GetCurTime(void) -{ - uint64 ret; - struct timeval tv; - - gettimeofday(&tv,0); - ret=(uint64)tv.tv_sec*1000000; - ret+=tv.tv_usec; - return(ret); -} - -void SpeedThrottle(void) -{ - static uint64 ttime,ltime=0; - - waiter: - - ttime=GetCurTime(); - - if( (ttime-ltime) < (tfreq/desiredfps) ) - goto waiter; - if( (ttime-ltime) >= (tfreq*4/desiredfps)) - ltime=ttime; - else - ltime+=tfreq/desiredfps; -} - diff --git a/branches/sdl2/src/attic/pc/throttle.h b/branches/sdl2/src/attic/pc/throttle.h deleted file mode 100644 index d6ca2aa8..00000000 --- a/branches/sdl2/src/attic/pc/throttle.h +++ /dev/null @@ -1,2 +0,0 @@ -void RefreshThrottleFPS(void); -void SpeedThrottle(void); diff --git a/branches/sdl2/src/attic/pc/unix-netplay.c b/branches/sdl2/src/attic/pc/unix-netplay.c deleted file mode 100644 index 5bef56e2..00000000 --- a/branches/sdl2/src/attic/pc/unix-netplay.c +++ /dev/null @@ -1,292 +0,0 @@ -#ifdef NETWORK -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "main.h" -#include "dface.h" -#include "unix-netplay.h" - -#include "../../md5.h" - -#ifndef socklen_t -#define socklen_t int -#endif - -#ifndef SOL_TCP -#define SOL_TCP IPPROTO_TCP -#endif - - -char *netplayhost=0; -char *netplaynick=0; -char *netgamekey = 0; -char *netpassword = 0; -int netlocalplayers = 1; - -int Port=0xFCE; -int FCEUDnetplay=0; - -int tport=0xFCE; - -static int Socket=-1; - -static void en32(uint8 *buf, uint32 morp) -{ - buf[0]=morp; - buf[1]=morp>>8; - buf[2]=morp>>16; - buf[3]=morp>>24; -} -/* -static uint32 de32(uint8 *morp) -{ - return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)); -} -*/ -int FCEUD_NetworkConnect(void) -{ - struct sockaddr_in sockin; /* I want to play with fighting robots. */ - struct hostent *phostentb; - unsigned long hadr; - int TSocket; - int netdivisor; - - if(!netplayhost) return(0); - - if( (TSocket=socket(AF_INET,SOCK_STREAM,0))==-1) - { - puts("Error creating stream socket."); - FCEUD_NetworkClose(); - return(0); - } - - { - int tcpopt = 1; - #ifdef BEOS - if(setsockopt(TSocket, SOL_SOCKET, TCP_NODELAY, &tcpopt, sizeof(int))) - #else - if(setsockopt(TSocket, SOL_TCP, TCP_NODELAY, &tcpopt, sizeof(int))) - #endif - puts("Nodelay fail"); - } - - memset(&sockin,0,sizeof(sockin)); - sockin.sin_family=AF_INET; - - hadr=inet_addr(netplayhost); - - if(hadr!=INADDR_NONE) - sockin.sin_addr.s_addr=hadr; - else - { - puts("*** Looking up host name..."); - if(!(phostentb=gethostbyname((const char *)netplayhost))) - { - puts("Error getting host network information."); - close(TSocket); - FCEUD_NetworkClose(); - return(0); - } - memcpy(&sockin.sin_addr,phostentb->h_addr,phostentb->h_length); - } - - sockin.sin_port=htons(tport); - puts("*** Connecting to remote host..."); - if(connect(TSocket,(struct sockaddr *)&sockin,sizeof(sockin))==-1) - { - puts("Error connecting to remote host."); - close(TSocket); - FCEUD_NetworkClose(); - return(0); - } - Socket=TSocket; - puts("*** Sending initialization data to server..."); - { - uint8 *sendbuf; - uint8 buf[5]; - uint32 sblen; - - sblen = 4 + 16 + 16 + 64 + 1 + (netplaynick?strlen(netplaynick):0); - sendbuf = malloc(sblen); - memset(sendbuf, 0, sblen); - - en32(sendbuf, sblen - 4); - - if(netgamekey) - { - struct md5_context md5; - uint8 md5out[16]; - - md5_starts(&md5); - md5_update(&md5, CurGame->MD5, 16); - md5_update(&md5, netgamekey, strlen(netgamekey)); - md5_finish(&md5, md5out); - memcpy(sendbuf + 4, md5out, 16); - } - else - memcpy(sendbuf + 4, CurGame->MD5, 16); - - if(netpassword) - { - struct md5_context md5; - uint8 md5out[16]; - - md5_starts(&md5); - md5_update(&md5, netpassword, strlen(netpassword)); - md5_finish(&md5, md5out); - memcpy(sendbuf + 4 + 16, md5out, 16); - } - - memset(sendbuf + 4 + 16 + 16, 0, 64); - - sendbuf[4 + 16 + 16 + 64] = netlocalplayers; - - if(netplaynick) - memcpy(sendbuf + 4 + 16 + 16 + 64 + 1,netplaynick,strlen(netplaynick)); - - send(Socket, sendbuf, sblen, 0); - free(sendbuf); - - recv(Socket, buf, 1, MSG_WAITALL); - netdivisor = buf[0]; - } - - puts("*** Connection established."); - - FCEUDnetplay = 1; - FCEUI_NetplayStart(netlocalplayers, netdivisor); - return(1); -} - - -int FCEUD_SendData(void *data, uint32 len) -{ - int check; - if(!ioctl(fileno(stdin),FIONREAD,&check)) - if(check) - { - char buf[1024]; - char *f; - fgets(buf,1024,stdin); - if((f=strrchr(buf,'\n'))) - *f=0; - FCEUI_NetplayText(buf); - } - send(Socket, data, len ,0); - return(1); -} - -int FCEUD_RecvData(void *data, uint32 len) -{ - NoWaiting&=~2; - - for(;;) - { - fd_set funfun; - struct timeval popeye; - - popeye.tv_sec=0; - popeye.tv_usec=100000; - - FD_ZERO(&funfun); - FD_SET(Socket,&funfun); - - switch(select(Socket + 1,&funfun,0,0,&popeye)) - { - case 0: continue; - case -1:return(0); - } - - if(FD_ISSET(Socket,&funfun)) - { - if(recv(Socket,data,len,MSG_WAITALL) == len) - { - //unsigned long beefie; - - FD_ZERO(&funfun); - FD_SET(Socket, &funfun); - - popeye.tv_sec = popeye.tv_usec = 0; - if(select(Socket + 1, &funfun, 0, 0, &popeye) == 1) - //if(!ioctl(Socket,FIONREAD,&beefie)) - // if(beefie) - { - NoWaiting|=2; - //puts("Yaya"); - } - return(1); - } - else - return(0); - } - - } - return 0; -} - -void FCEUD_NetworkClose(void) -{ - if(Socket>0) - { - #ifdef BEOS - closesocket(Socket); - #else - close(Socket); - #endif - } - Socket=-1; - - if(FCEUDnetplay) - FCEUI_NetplayStop(); - FCEUDnetplay = 0; -} - - -void FCEUD_NetplayText(uint8 *text) -{ - char *tot = malloc(strlen(text) + 1); - char *tmp; - strcpy(tot, text); - tmp = tot; - - while(*tmp) - { - if(*tmp < 0x20) *tmp = ' '; - tmp++; - } - puts(tot); - free(tot); -} -#endif - diff --git a/branches/sdl2/src/attic/pc/unix-netplay.h b/branches/sdl2/src/attic/pc/unix-netplay.h deleted file mode 100644 index dd6ed18a..00000000 --- a/branches/sdl2/src/attic/pc/unix-netplay.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef NETWORK -extern char *netplaynick; -extern char *netplayhost; -extern char *netpassword; -extern char *netgamekey; -extern int tport; -extern int netlocalplayers; - -#endif diff --git a/branches/sdl2/src/attic/pc/usage.h b/branches/sdl2/src/attic/pc/usage.h deleted file mode 100644 index b8833200..00000000 --- a/branches/sdl2/src/attic/pc/usage.h +++ /dev/null @@ -1,60 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -void ShowUsage(char *prog) -{ -printf("\nUsage is as follows:\n%s filename\n\n",prog); -puts("Options:"); -puts(DriverUsage); -puts("-cpalette x Load a custom global palette from file x.\n\ --ntsccol x Emulate an NTSC's TV's colors.\n\ - 0 = Disabled.\n\ - 1 = Enabled.\n\ --pal x Emulate a PAL NES if x is 1.\n\ --sound x Sound.\n\ - 0 = Disabled.\n\ - Otherwise, x = playback rate.\n\ --soundvol x Sound volume. x is an integral percentage value.\n\ --soundq x Sets sound quality.\n\ - 0 = Low quality.\n\ - 1 = High quality.\n\ --inputx str Select device mapped to virtual input port x(1-2).\n\ - str may be: none, gamepad, zapper, powerpada, powerpadb,\n\ - arkanoid\n\ --fcexp str Select Famicom expansion port device.\n\ - str may be: none, shadow, arkanoid, 4player, fkb\n\ --inputcfg s Configure virtual input device \"s\".\n\ --nofs x Disables Four-Score emulation if x is 1.\n\ --gg x Enable Game Genie emulation if x is 1.\n\ --no8lim x Disables the 8 sprites per scanline limitation.\n\ - 0 = Limitation enabled.\n\ - 1 = Limitation disabled.\n\ --snapname x Selects what type of file name snapshots will have.\n\ - 0 = Numeric(0.png)\n\ - 1 = File base and numeric(mario-0.png)\n\ --nothrottle x Disable artificial speed throttling if x is non-zero.\n\ --clipsides x Clip leftmost and rightmost 8 columns of pixels of video output.\n\ - 0 = No clipping.\n\ - 1 = Clipping.\n\ --slstart x Set the first drawn emulated scanline. Valid values for x are\n\ - 0 through 239.\n\ --slend x Set the last drawn emulated scanline. Valid values for x are\n\ - 0 through 239."); -} diff --git a/branches/sdl2/src/attic/pc/vgatweak.c b/branches/sdl2/src/attic/pc/vgatweak.c deleted file mode 100644 index a04cf94e..00000000 --- a/branches/sdl2/src/attic/pc/vgatweak.c +++ /dev/null @@ -1,168 +0,0 @@ -/* This file is "#include"d from dos-video.c and svga-video.c */ - -typedef struct { - uint8 p; - uint8 i; - uint8 v; -} vgareg; - -vgareg v256x224_103[25] = -{ - { 0xc2, 0x0, 0xe7}, - { 0xd4, 0x0, 0x45}, - { 0xd4, 0x1, 0x3f}, - { 0xd4, 0x2, 0x40}, - { 0xd4, 0x3, 0x86}, - { 0xd4, 0x4, 0x3f}, - { 0xd4, 0x5, 0x10}, - { 0xd4, 0x6, 0xcd}, - { 0xd4, 0x7, 0x1f}, - { 0xd4, 0x8, 0x0}, - { 0xd4, 0x9, 0x41}, - { 0xd4, 0x10, 0xc0}, - { 0xd4, 0x11, 0xac}, - { 0xd4, 0x12, 0xbf}, - { 0xd4, 0x13, 0x20}, - { 0xd4, 0x14, 0x40}, // - { 0xd4, 0x15, 0xe7}, - { 0xd4, 0x16, 0x06}, // - { 0xd4, 0x17, 0xa3}, - { 0xc4, 0x1, 0x1}, - { 0xc4, 0x4, 0xe}, // - { 0xce, 0x5, 0x40}, - { 0xce, 0x6, 0x5}, - { 0xc0, 0x10, 0x41}, - { 0xc0, 0x13, 0x0}, -}; - -vgareg v256x240[25] = -{ - { 0xc2, 0x0, 0xe3}, - { 0xd4, 0x0, 0x4f}, - { 0xd4, 0x1, 0x3f}, - { 0xd4, 0x2, 0x40}, - { 0xd4, 0x3, 0x92}, - { 0xd4, 0x4, 0x44}, - { 0xd4, 0x5, 0x10}, - { 0xd4, 0x6, 0x0a}, - { 0xd4, 0x7, 0x3e}, - { 0xd4, 0x8, 0x00}, - { 0xd4, 0x9, 0x41}, - { 0xd4, 0x10, 0xea}, - { 0xd4, 0x11, 0xac}, - { 0xd4, 0x12, 0xdf}, - { 0xd4, 0x13, 0x20}, - { 0xd4, 0x14, 0x40}, - { 0xd4, 0x15, 0xe7}, - { 0xd4, 0x16, 0x06}, - { 0xd4, 0x17, 0xa3}, - { 0xc4, 0x1, 0x1}, - { 0xc4, 0x4, 0xe}, - { 0xce, 0x5, 0x40}, - { 0xce, 0x6, 0x5}, - { 0xc0, 0x10, 0x41}, - { 0xc0, 0x13, 0x0} -}; - -vgareg v256x224S[25] = -{ - { 0xc2, 0x0, 0xe3}, - { 0xd4, 0x0, 0x5f}, - { 0xd4, 0x1, 0x3f}, - { 0xd4, 0x2, 0x40}, - { 0xd4, 0x3, 0x82}, - { 0xd4, 0x4, 0x4e}, - { 0xd4, 0x5, 0x96}, - { 0xd4, 0x6, 0x5}, - { 0xd4, 0x7, 0x1}, - { 0xd4, 0x8, 0x0}, - { 0xd4, 0x9, 0x40}, - { 0xd4, 0x10, 0xea}, - { 0xd4, 0x11, 0xac}, - { 0xd4, 0x12, 0xdf}, - { 0xd4, 0x13, 0x20}, - { 0xd4, 0x14, 0x40}, - { 0xd4, 0x15, 0xe7}, - { 0xd4, 0x16, 0x0}, - { 0xd4, 0x17, 0xe3}, - { 0xc4, 0x1, 0x1}, - { 0xc4, 0x4, 0xe}, - { 0xce, 0x5, 0x40}, - { 0xce, 0x6, 0x5}, - { 0xc0, 0x10, 0x41}, - { 0xc0, 0x13, 0x0} -}; - -vgareg v256x256[25] = -{ - { 0xc2, 0x0, 0xe7}, - { 0xd4, 0x0, 0x5f}, - { 0xd4, 0x1, 0x3f}, - { 0xd4, 0x2, 0x40}, - { 0xd4, 0x3, 0x82}, - { 0xd4, 0x4, 0x4a}, - { 0xd4, 0x5, 0x9a}, - { 0xd4, 0x6, 0x23}, - { 0xd4, 0x7, 0xb2}, - { 0xd4, 0x8, 0x0}, - { 0xd4, 0x9, 0x61}, - { 0xd4, 0x10, 0xa}, - { 0xd4, 0x11, 0xac}, - { 0xd4, 0x12, 0xff}, - { 0xd4, 0x13, 0x20}, - { 0xd4, 0x14, 0x40}, - { 0xd4, 0x15, 0x7}, - { 0xd4, 0x16, 0x1a}, - { 0xd4, 0x17, 0xa3}, - { 0xc4, 0x1, 0x1}, - { 0xc4, 0x4, 0xe}, - { 0xce, 0x5, 0x40}, - { 0xce, 0x6, 0x5}, - { 0xc0, 0x10, 0x41}, - { 0xc0, 0x13, 0x0} -}; - -vgareg v256x256S[25] = -{ - { 0xc2, 0x00, 0xe7},{ 0xd4, 0x00, 0x5F},{ 0xd4, 0x01, 0x3f}, - { 0xd4, 0x02, 0x40},{ 0xd4, 0x03, 0x82},{ 0xd4, 0x04, 0x4a}, - { 0xd4, 0x05, 0x9a},{ 0xd4, 0x06, 0x25},{ 0xd4, 0x07, 0x15}, - { 0xd4, 0x08, 0x00},{ 0xd4, 0x09, 0x60},{ 0xd4, 0x10, 0x0a}, - { 0xd4, 0x11, 0xac},{ 0xd4, 0x12, 0xff},{ 0xd4, 0x13, 0x20}, - { 0xd4, 0x14, 0x40},{ 0xd4, 0x15, 0x07},{ 0xd4, 0x16, 0x1a}, - { 0xd4, 0x17, 0xa3},{ 0xc4, 0x01, 0x01},{ 0xc4, 0x04, 0x0e}, - { 0xce, 0x05, 0x40},{ 0xce, 0x06, 0x05},{ 0xc0, 0x10, 0x41}, - { 0xc0, 0x13, 0x00} -}; - -static void VGAPortSet(vgareg R) -{ - int p,i,v; - - p=0x300|R.p; - i=R.i; - v=R.v; - - switch(p) - { - case 0x3C0: inportb(0x3DA); - outportb(0x3C0,i); - outportb(0x3C0,v); - break; - case 0x3C2: - case 0x3C3: - default: outportb(p, v); - break; - case 0x3C4: if(i==1) - { - outportw(0x3c4,0x100); - outportw(0x3c4,(v<<8)|1); - outportw(0x3c4,0x300); - break; - } - case 0x3CE: - case 0x3D4: outportw(p,i|(v<<8)); - break; - } -} - diff --git a/branches/sdl2/src/attic/sexyal/convert.c b/branches/sdl2/src/attic/sexyal/convert.c deleted file mode 100644 index 8fc4d626..00000000 --- a/branches/sdl2/src/attic/sexyal/convert.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "sexyal.h" -#include "convert.h" - -static inline uint16_t FLIP16(uint16_t b) -{ - return((b<<8)|((b>>8)&0xFF)); -} - -static inline uint32_t FLIP32(uint32_t b) -{ - return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) ); -} - -#include "convert.inc" diff --git a/branches/sdl2/src/attic/sexyal/convert.h b/branches/sdl2/src/attic/sexyal/convert.h deleted file mode 100644 index ac364bb3..00000000 --- a/branches/sdl2/src/attic/sexyal/convert.h +++ /dev/null @@ -1,2 +0,0 @@ -void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames); - diff --git a/branches/sdl2/src/attic/sexyal/convert.inc b/branches/sdl2/src/attic/sexyal/convert.inc deleted file mode 100644 index 2c895bf1..00000000 --- a/branches/sdl2/src/attic/sexyal/convert.inc +++ /dev/null @@ -1,20387 +0,0 @@ -void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames) -{ -if(srcformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp2+=128; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp2+=128; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp2+=128; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp2+=128; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp2+=128; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp2+=128; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp2+=128; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp2+=128; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 8; - tmp2+=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=128; - tmp <<= 16; - tmp2+=128; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp2-=128; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp2-=128; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp2-=128; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp2-=128; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp2-=128; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp2-=128; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp2-=128; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp2-=128; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 8; - tmp2-=128; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=128; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=128; - tmp <<= 16; - tmp2-=128; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 16; - tmp2 <<= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp2+=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp2+=32768; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp2+=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp2+=32768; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp+=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp >>= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp2-=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp2-=32768; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp2-=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp2-=32768; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 0; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp-=32768; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP16(tmp); - tmp <<= 8; -FLIP16(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP16(tmp); -tmp2=*src; - src++; -FLIP16(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP16(tmp); -FLIP16(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp >>= 8; - tmp2+=32768; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 0; - tmp2+=32768; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp2+=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp2+=32768; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp2+=32768; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp2+=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp2+=32768; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=32768; - tmp <<= 8; - tmp2+=32768; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp >>= 8; - tmp2-=32768; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 0; - tmp2-=32768; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 0; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 0; - tmp2 <<= 0; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp2-=32768; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp2-=32768; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp2-=32768; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp2-=32768; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp2-=32768; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=32768; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=32768; - tmp <<= 8; - tmp2-=32768; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp <<= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp <<= 8; - tmp2 <<= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 16; - tmp2+=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp >>= 8; - tmp2+=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp+=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp+=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp2+=(1<<23); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp2+=(1<<23); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp2+=(1<<23); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp2+=(1<<23); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp2+=(1<<23); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp+=(1<<23); - tmp2+=(1<<23); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp2+=(1<<23); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp+=(1<<23); - tmp2+=(1<<23); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -if(srcformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* src=vsrc; -if(destformat->sampformat == SEXYAL_FMT_PCMS8) -{ -int8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 16; - tmp2-=(1<<23); - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU8) -{ -uint8_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 16; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 16; - tmp2 >>= 16; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS16) -{ -int16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU16) -{ -uint16_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S16) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp >>= 8; - tmp2-=(1<<23); - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U16) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp >>= 8; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp >>= 8; - tmp2 >>= 8; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMS32S24) -{ -int32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - tmp-=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - tmp-=(1<<23); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp2-=(1<<23); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp2-=(1<<23); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp2-=(1<<23); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp2-=(1<<23); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp2-=(1<<23); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - tmp-=(1<<23); - tmp2-=(1<<23); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp2-=(1<<23); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - tmp-=(1<<23); - tmp2-=(1<<23); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -if(destformat->sampformat == SEXYAL_FMT_PCMU32U24) -{ -uint32_t* dest=vdest; -if(srcformat->channels == 1) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -tmp=*src; - src++; -FLIP32(tmp); -FLIP32(tmp); - *dest=tmp; - dest++; - *dest=tmp; - dest++; -} -} -} -} -} -if(srcformat->channels == 2) -{ -if(destformat->channels == 1) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -tmp = (tmp+tmp2)>>1; - *dest=tmp; - dest++; -} -} -} -} -if(destformat->channels == 2) -{ -if(srcformat->byteorder == 0) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -tmp2=*src; - src++; -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -if(srcformat->byteorder == 1) -{ -if(destformat->byteorder == 0) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -if(destformat->byteorder == 1) -{ -while(frames--) -{ -int32_t tmp; -int32_t tmp2; -tmp=*src; - src++; -FLIP32(tmp); -tmp2=*src; - src++; -FLIP32(tmp2); -FLIP32(tmp); -FLIP32(tmp2); - *dest=tmp; - dest++; - *dest=tmp2; - dest++; -} -} -} -} -} -} -} -} diff --git a/branches/sdl2/src/attic/sexyal/convertgen b/branches/sdl2/src/attic/sexyal/convertgen deleted file mode 100644 index d4420fda..00000000 Binary files a/branches/sdl2/src/attic/sexyal/convertgen and /dev/null differ diff --git a/branches/sdl2/src/attic/sexyal/convertgen.c b/branches/sdl2/src/attic/sexyal/convertgen.c deleted file mode 100644 index 83e59083..00000000 --- a/branches/sdl2/src/attic/sexyal/convertgen.c +++ /dev/null @@ -1,155 +0,0 @@ -#include - -char *check[]={"SEXYAL_FMT_PCMS8","SEXYAL_FMT_PCMU8","SEXYAL_FMT_PCMS16", -"SEXYAL_FMT_PCMU16","SEXYAL_FMT_PCMS32S16","SEXYAL_FMT_PCMU32U16","SEXYAL_FMT_PCMS32S24","SEXYAL_FMT_PCMU32U24"}; -char *str[]={"int8_t","uint8_t","int16_t","uint16_t","int32_t","uint32_t","int32_t","uint32_t"}; - -int bitss[]={8,8,16,16,16,16,24,24}; -int bitsreal[]={8,8,16,16,32,32,32,32}; - -void Fetch(int x,char *wt) -{ - //printf(" int32_t tmp%s=*src;\n",wt); - printf("tmp%s=*src;\n",wt); - printf(" src++;\n"); -} - -void BitConv(int src, int dest, char *wt) -{ - if((src^dest)&1) /* signed/unsigned change. */ - if(src&1) /* Source unsigned, dest signed. */ - { - if(src==1) printf(" tmp%s-=128;\n",wt); - else if(src==3) printf(" tmp%s-=32768;\n",wt); - else if(src==5) printf(" tmp%s-=32768;\n",wt); - else if(src==7) printf(" tmp%s-=(1<<23);\n",wt); - } - else /* Source signed, dest unsigned */ - { - if(src==0) printf(" tmp%s+=128;\n",wt); - else if(src==2) printf(" tmp%s+=32768;\n",wt); - else if(src==4) printf(" tmp%s+=32768;\n",wt); - else if(src==6) printf(" tmp%s+=(1<<23);\n",wt); - } - if((src>>1) != (dest>>1)) - { - int shifty=bitss[src]-bitss[dest]; - if(shifty>0) - printf(" tmp%s >>= %d;\n",wt,shifty); - else - printf(" tmp%s <<= %d;\n",wt,-shifty); - } -} - -void Save(int x, char *wt) -{ - printf(" *dest=tmp%s;\n",wt); - printf(" dest++;\n"); -} - -main() -{ - int srcbits,destbits,srcchannels,destchannels; - int srcbo,destbo; - - puts("void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames)"); - puts("{"); - - for(srcbits=0;srcbits<8;srcbits++) - { - printf("if(srcformat->sampformat == %s)\n{\n",check[srcbits]); - - printf("%s* src=vsrc;\n",str[srcbits]); - - for(destbits=0;destbits<8;destbits++) - { - printf("if(destformat->sampformat == %s)\n{\n",check[destbits]); - - printf("%s* dest=vdest;\n",str[destbits]); - - for(srcchannels=0;srcchannels<2;srcchannels++) - { - printf("if(srcformat->channels == %c)\n{\n",'1'+srcchannels); - for(destchannels=0;destchannels<2;destchannels++) - { - printf("if(destformat->channels == %c)\n{\n",'1'+destchannels); - for(srcbo=0;srcbo<2;srcbo++) - { - printf("if(srcformat->byteorder == %d)\n{\n",srcbo); - for(destbo=0;destbo<2;destbo++) - { - printf("if(destformat->byteorder == %d)\n{\n",destbo); - //printf("if(srcformat->sampformat==%s && destformat->sameck[srcbits],check[destbits]); - printf("while(frames--)\n{\n"); - - puts("int32_t tmp;"); - if(srcchannels) - puts("int32_t tmp2;"); - - Fetch(srcbits,""); - - if(srcbo) - { - if(bitsreal[srcbits]==16) - puts("FLIP16(tmp);"); - else - puts("FLIP32(tmp);"); - } - - if(srcchannels) - { - Fetch(srcbits,"2"); - if(srcbo) - { - if(bitsreal[srcbits]==16) - puts("FLIP16(tmp2);"); - else - puts("FLIP32(tmp2);"); - } - } - - BitConv(srcbits,destbits,""); - - if(srcchannels) BitConv(srcbits,destbits,"2"); - - if(destbo) - { - if(bitsreal[srcbits]==16) - puts("FLIP16(tmp);"); - else - puts("FLIP32(tmp);"); - if(srcchannels && destchannels && destbo) - { - if(bitsreal[srcbits]==16) - puts("FLIP16(tmp2);"); - else - puts("FLIP32(tmp2);"); - } - } - - if(srcchannels && !destchannels) - printf("tmp = (tmp+tmp2)>>1;\n"); - - Save(destbits,""); - if(!srcchannels && destchannels) - Save(destbits,""); - - if(srcchannels && destchannels) - Save(destbits,"2"); - - puts("}"); - puts("}"); - } // destbo - puts("}"); - } // srcbo - puts("}"); - } - puts("}"); - } - puts("}"); - } - puts("}"); - } - - puts("}"); -} diff --git a/branches/sdl2/src/attic/sexyal/drivers/dsound.c b/branches/sdl2/src/attic/sexyal/drivers/dsound.c deleted file mode 100644 index b6569ce6..00000000 --- a/branches/sdl2/src/attic/sexyal/drivers/dsound.c +++ /dev/null @@ -1,276 +0,0 @@ -#include -#include -#include - -#undef WINNT -#define NONAMELESSUNION - -#define DIRECTSOUND_VERSION 0x0300 - -#include -#include "../sexyal.h" - -typedef struct -{ - LPDIRECTSOUND ppDS; /* DirectSound interface object. */ - LPDIRECTSOUNDBUFFER ppbuf; /* Primary buffer. */ - LPDIRECTSOUNDBUFFER ppbufsec; /* Secondary buffer. */ - LPDIRECTSOUNDBUFFER ppbufw; /* Buffer to do writes to. */ - WAVEFORMATEX wf; /* Format of the primary and secondary buffers. */ - long DSBufferSize; /* The size of the buffer that we can write to, in bytes. */ - - long BufHowMuch; /* How many bytes we should try to buffer. */ - DWORD ToWritePos; /* Position which the next write to the buffer - should write to. - */ -} DSFobby; - -static void CheckStatus(DSFobby *tmp) -{ - DWORD status=0; - - IDirectSoundBuffer_GetStatus(tmp->ppbufw, &status); - if(status&DSBSTATUS_BUFFERLOST) - IDirectSoundBuffer_Restore(tmp->ppbufw); - - if(!(status&DSBSTATUS_PLAYING)) - { - tmp->ToWritePos=0; - IDirectSoundBuffer_SetCurrentPosition(tmp->ppbufsec,0); - IDirectSoundBuffer_SetFormat(tmp->ppbufw,&tmp->wf); - IDirectSoundBuffer_Play(tmp->ppbufw,0,0,DSBPLAY_LOOPING); - } -} - -SexyAL_device *SexyALI_DSound_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering) -{ - SexyAL_device *dev; - DSFobby *fobby; - - DSBUFFERDESC DSBufferDesc; - DSCAPS dscaps; - DSBCAPS dsbcaps; - - dev=malloc(sizeof(SexyAL_device)); - fobby=malloc(sizeof(DSFobby)); - memset(fobby,0,sizeof(DSFobby)); - - memset(&fobby->wf,0,sizeof(WAVEFORMATEX)); - fobby->wf.wFormatTag = WAVE_FORMAT_PCM; - fobby->wf.nChannels = format->channels; - fobby->wf.nSamplesPerSec = format->rate; - - if(DirectSoundCreate(0,&fobby->ppDS,0) != DS_OK) - { - free(dev); - free(fobby); - return(0); - } - - { - //HWND hWnd = GetForegroundWindow(); // Ugly. - //if(!hWnd) - //{ hWnd=GetDesktopWindow(); exit(1); } - HWND hWnd; - hWnd=GetDesktopWindow(); - IDirectSound_SetCooperativeLevel(fobby->ppDS,hWnd,DSSCL_PRIORITY); - } - memset(&dscaps,0x00,sizeof(dscaps)); - dscaps.dwSize=sizeof(dscaps); - IDirectSound_GetCaps(fobby->ppDS,&dscaps); - IDirectSound_Compact(fobby->ppDS); - - /* Create primary buffer */ - memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC)); - DSBufferDesc.dwSize=sizeof(DSBufferDesc); - DSBufferDesc.dwFlags=DSBCAPS_PRIMARYBUFFER; - - if(IDirectSound_CreateSoundBuffer(fobby->ppDS,&DSBufferDesc,&fobby->ppbuf,0) != DS_OK) - { - IDirectSound_Release(fobby->ppDS); - free(dev); - free(fobby); - return(0); - } - - /* Set primary buffer format. */ - if(format->sampformat == SEXYAL_FMT_PCMU8) - fobby->wf.wBitsPerSample=8; - else // if(format->sampformat == SEXYAL_FMT_PCMS16) - { - fobby->wf.wBitsPerSample=16; - format->sampformat=SEXYAL_FMT_PCMS16; - } - - fobby->wf.nBlockAlign=fobby->wf.wBitsPerSample>>3; - fobby->wf.nAvgBytesPerSec=fobby->wf.nSamplesPerSec*fobby->wf.nBlockAlign; - if(IDirectSoundBuffer_SetFormat(fobby->ppbuf,&fobby->wf) != DS_OK) - { - IDirectSound_Release(fobby->ppbuf); - IDirectSound_Release(fobby->ppDS); - free(dev); - free(fobby); - return(0); - } - - /* Create secondary sound buffer */ - IDirectSoundBuffer_GetFormat(fobby->ppbuf,&fobby->wf,sizeof(WAVEFORMATEX),0); - memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC)); - DSBufferDesc.dwSize=sizeof(DSBufferDesc); - DSBufferDesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; - DSBufferDesc.dwFlags|=DSBCAPS_GLOBALFOCUS; - DSBufferDesc.dwBufferBytes=65536; - DSBufferDesc.lpwfxFormat=&fobby->wf; - if(IDirectSound_CreateSoundBuffer(fobby->ppDS, &DSBufferDesc, &fobby->ppbufsec, 0) != DS_OK) - { - IDirectSound_Release(fobby->ppbuf); - IDirectSound_Release(fobby->ppDS); - free(dev); - free(fobby); - return(0); - } - - fobby->DSBufferSize=65536; - IDirectSoundBuffer_SetCurrentPosition(fobby->ppbufsec,0); - fobby->ppbufw=fobby->ppbufsec; - - memcpy(&dev->format,format,sizeof(SexyAL_format)); - - if(!buffering->ms) - buffering->ms=53; - - buffering->totalsize=(int64_t)format->rate*buffering->ms/1000; - fobby->BufHowMuch=buffering->totalsize* format->channels * (format->sampformat>>4); - //printf("%d\n",fobby->BufHowMuch); - //fflush(stdout); - - dev->private=fobby; - timeBeginPeriod(1); - - return(dev); -} - -uint32_t SexyALI_DSound_RawCanWrite(SexyAL_device *device) -{ - DSFobby *tmp=device->private; - DWORD CurWritePos,CurPlayPos=0; - CheckStatus(tmp); - - CurWritePos=0; - - if(IDirectSoundBuffer_GetCurrentPosition(tmp->ppbufw,&CurPlayPos,&CurWritePos)==DS_OK) - { - //FCEU_DispMessage("%d",CurWritePos-CurPlayPos); - } - CurWritePos=(CurPlayPos+tmp->BufHowMuch)%tmp->DSBufferSize; - - /* If the current write pos is >= half the buffer size less than the to write pos, - assume DirectSound has wrapped around. - */ - - if(((int32_t)tmp->ToWritePos-(int32_t)CurWritePos) >= (tmp->DSBufferSize/2)) - { - CurWritePos+=tmp->DSBufferSize; - //printf("Fixit: %d,%d,%d\n",tmp->ToWritePos,CurWritePos,CurWritePos-tmp->DSBufferSize); - } - if(tmp->ToWritePosToWritePos; - if(howmuch > tmp->BufHowMuch) /* Oopsie. Severe buffer overflow... */ - { - tmp->ToWritePos=CurWritePos%tmp->DSBufferSize; - //IDirectSoundBuffer_Stop(tmp->ppbufsec); - //IDirectSoundBuffer_SetCurrentPosition(tmp->ppbufsec,tmp->ToWritePos); - //puts("Oops"); - //fflush(stdout); - //return(0); - } - return(CurWritePos-tmp->ToWritePos); - } - else - return(0); -} - -int SexyALI_DSound_RawWrite(SexyAL_device *device, void *data, uint32_t len) -{ - DSFobby *tmp=device->private; -// uint32_t cw; - - //printf("Pre: %d\n",SexyALI_DSound_RawCanWrite(device)); - //fflush(stdout); - - CheckStatus(tmp); - /* In this block, we write as much data as we can, then we write - the rest of it in >=1ms chunks. - */ - while(len) - { - VOID *LockPtr[2]={0,0}; - DWORD LockLen[2]={0,0}; - int32_t curlen; - - while(!(curlen=SexyALI_DSound_RawCanWrite(device))) - { - Sleep(1); - } - - if(curlen>len) curlen=len; - - if(DS_OK == IDirectSoundBuffer_Lock(tmp->ppbufw,tmp->ToWritePos,curlen,&LockPtr[0],&LockLen[0],&LockPtr[1],&LockLen[1],0)) - { - } - - if(LockPtr[1] != 0 && LockPtr[1] != LockPtr[0]) - { - memcpy(LockPtr[0],data,LockLen[0]); - memcpy(LockPtr[1],data+LockLen[0],len-LockLen[0]); - } - else if(LockPtr[0]) - { - memcpy(LockPtr[0],data,curlen); - } - IDirectSoundBuffer_Unlock(tmp->ppbufw,LockPtr[0],LockLen[0],LockPtr[1],LockLen[1]); - tmp->ToWritePos=(tmp->ToWritePos+curlen)%tmp->DSBufferSize; - - len-=curlen; - (uint8_t *) data+=curlen; - if(len) - Sleep(1); - } // end while(len) loop - - - return(1); -} - - - -int SexyALI_DSound_Close(SexyAL_device *device) -{ - if(device) - { - if(device->private) - { - DSFobby *tmp=device->private; - if(tmp->ppbufsec) - { - IDirectSoundBuffer_Stop(tmp->ppbufsec); - IDirectSoundBuffer_Release(tmp->ppbufsec); - } - if(tmp->ppbuf) - { - IDirectSoundBuffer_Stop(tmp->ppbuf); - IDirectSoundBuffer_Release(tmp->ppbuf); - } - if(tmp->ppDS) - { - IDirectSound_Release(tmp->ppDS); - } - free(device->private); - } - free(device); - timeEndPeriod(1); - return(1); - } - return(0); -} - diff --git a/branches/sdl2/src/attic/sexyal/drivers/oss.c b/branches/sdl2/src/attic/sexyal/drivers/oss.c deleted file mode 100644 index 68d9a8c8..00000000 --- a/branches/sdl2/src/attic/sexyal/drivers/oss.c +++ /dev/null @@ -1,241 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../sexyal.h" -#include "../md5.h" -#include "../smallc.h" - -#include "oss.h" - -#define IDBASE 0x1000 - -void SexyALI_OSS_Enumerate(int (*func)(uint8_t *name, uint64_t id, void *udata), void *udata) -{ - struct stat buf; - char fn[64]; - unsigned int n; - - n=0; - - do - { - sal_strcpy(fn,"/dev/dsp"); - sal_strcat(fn,sal_uinttos(n)); - if(stat(fn,&buf)!=0) break; - } while(func(fn,n+IDBASE,udata)); -} - -static int FODevice(uint64_t id) -{ - char fn[64]; - - if(id==SEXYAL_ID_DEFAULT) - { - sal_strcpy(fn,"/dev/dsp"); - return(open(fn,O_WRONLY)); - } - else if(id==SEXYAL_ID_UNUSED) - { - int x=-1; - int dspfd; - do - { - sal_strcpy(fn,"/dev/dsp"); - if(x!=-1) - sal_strcat(fn,sal_uinttos(x)); - dspfd=open(fn,O_WRONLY|O_NONBLOCK); - if(dspfd!=-1) break; - x++; - } while(errno!=ENOENT); - if(dspfd==-1) return(0); - fcntl(dspfd,F_SETFL,fcntl(dspfd,F_GETFL)&~O_NONBLOCK); - return(dspfd); - } - else - { - sal_strcpy(fn,"/dev/dsp"); - sal_strcat(fn,sal_uinttos(id-IDBASE)); - return(open(fn,O_WRONLY)); - } -} - -unsigned int Log2(unsigned int value) -{ - int x=0; - - value>>=1; - while(value) - { - value>>=1; - x++; - } - return(x?x:1); -} - -SexyAL_device *SexyALI_OSS_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering) -{ - SexyAL_device *device; - int fd; - unsigned int temp; - - if(!(fd=FODevice(id))) return(0); - - /* Set sample format. */ - /* TODO: Handle devices with byte order different from native byte order. */ - /* TODO: Fix fragment size calculation to work well with lower/higher playback rates, - as reported by OSS. - */ - - if(format->sampformat == SEXYAL_FMT_PCMU8) - temp=AFMT_U8; - else if(format->sampformat == SEXYAL_FMT_PCMS8) - temp=AFMT_S8; - else if(format->sampformat == SEXYAL_FMT_PCMU16) - temp=AFMT_U16_LE; - else - temp=AFMT_S16_NE; - - format->byteorder=0; - - ioctl(fd,SNDCTL_DSP_SETFMT,&temp); - switch(temp) - { - case AFMT_U8: format->sampformat = SEXYAL_FMT_PCMU8;break; - case AFMT_S8: format->sampformat = SEXYAL_FMT_PCMS8;break; - case AFMT_U16_LE: - #ifndef LSB_FIRST - format->byteorder=1; - #endif - format->sampformat = SEXYAL_FMT_PCMU16;break; - case AFMT_U16_BE: - #ifdef LSB_FIRST - format->byteorder=1; - #endif - format->sampformat = SEXYAL_FMT_PCMU16;break; - case AFMT_S16_LE: - #ifndef LSB_FIRST - format->byteorder=1; - #endif - format->sampformat = SEXYAL_FMT_PCMS16;break; - case AFMT_S16_BE: - #ifdef LSB_FIRST - format->byteorder=1; - #endif - format->sampformat = SEXYAL_FMT_PCMS16;break; - default: close(fd); return(0); - } - - /* Set number of channels. */ - temp=format->channels; - if(ioctl(fd,SNDCTL_DSP_CHANNELS,&temp)==-1) - { - close(fd); - return(0); - } - - if(temp<1 || temp>2) - { - close(fd); - return(0); - } - - format->channels=temp; - - /* Set frame rate. */ - temp=format->rate; - if(ioctl(fd,SNDCTL_DSP_SPEED,&temp)==-1) - { - close(fd); - return(0); - } - format->rate=temp; - device=malloc(sizeof(SexyAL_device)); - sal_memcpy(&device->format,format,sizeof(SexyAL_format)); - sal_memcpy(&device->buffering,buffering,sizeof(SexyAL_buffering)); - - if(buffering->fragcount == 0 || buffering->fragsize == 0) - { - buffering->fragcount=16; - buffering->fragsize=64; - } - else - { - if(buffering->fragsize<32) buffering->fragsize=32; - if(buffering->fragcount<2) buffering->fragcount=2; - } - - if(buffering->ms) - { - int64_t tc; - - //printf("%d\n",buffering->ms); - - /* 2*, >>1, |1 for crude rounding(it will always round 0.5 up, so it is a bit biased). */ - - tc=2*buffering->ms * format->rate / 1000 / buffering->fragsize; - //printf("%f\n",(double)buffering->ms * format->rate / 1000 / buffering->fragsize); - buffering->fragcount=(tc>>1)+(tc&1); //1<fragcount); - } - - temp=Log2(buffering->fragsize*(format->sampformat>>4)*format->channels); - temp|=buffering->fragcount<<16; - ioctl(fd,SNDCTL_DSP_SETFRAGMENT,&temp); - - { - audio_buf_info info; - ioctl(fd,SNDCTL_DSP_GETOSPACE,&info); - buffering->fragsize=info.fragsize/(format->sampformat>>4)/format->channels; - buffering->fragcount=info.fragments; - buffering->totalsize=buffering->fragsize*buffering->fragcount; - //printf("Actual: %d, %d\n",buffering->fragsize,buffering->fragcount); - } - device->private=malloc(sizeof(int)); - *(int*)device->private=fd; - return(device); -} - -int SexyALI_OSS_Close(SexyAL_device *device) -{ - if(device) - { - if(device->private) - { - close(*(int*)device->private); - free(device->private); - } - free(device); - return(1); - } - return(0); -} - -uint32_t SexyALI_OSS_RawWrite(SexyAL_device *device, void *data, uint32_t len) -{ - ssize_t bytes; - - bytes = write(*(int *)device->private,data,len); - if(bytes <= 0) return(0); /* FIXME: What to do on -1? */ - return(bytes); -} - -uint32_t SexyALI_OSS_RawCanWrite(SexyAL_device *device) -{ - struct audio_buf_info ai; - if(!ioctl(*(int *)device->private,SNDCTL_DSP_GETOSPACE,&ai)) - return(ai.bytes); - else - return(0); -} - diff --git a/branches/sdl2/src/attic/sexyal/drivers/oss.h b/branches/sdl2/src/attic/sexyal/drivers/oss.h deleted file mode 100644 index b6927508..00000000 --- a/branches/sdl2/src/attic/sexyal/drivers/oss.h +++ /dev/null @@ -1,6 +0,0 @@ -void SexyALI_OSS_Enumerate(int (*func)(uint8_t *name, uint64_t id, void *udata), void *udata); -SexyAL_device *SexyALI_OSS_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering); -int SexyALI_OSS_Close(SexyAL_device *device); -uint32_t SexyALI_OSS_RawWrite(SexyAL_device *device, void *data, uint32_t len); -uint32_t SexyALI_OSS_RawCanWrite(SexyAL_device *device); - diff --git a/branches/sdl2/src/attic/sexyal/drivers/osxcoreaudio.c b/branches/sdl2/src/attic/sexyal/drivers/osxcoreaudio.c deleted file mode 100644 index b2c39a93..00000000 --- a/branches/sdl2/src/attic/sexyal/drivers/osxcoreaudio.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include -#include - - diff --git a/branches/sdl2/src/attic/sexyal/md5.c b/branches/sdl2/src/attic/sexyal/md5.c deleted file mode 100644 index 50299f7f..00000000 --- a/branches/sdl2/src/attic/sexyal/md5.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * RFC 1321 compliant MD5 implementation, - * by Christophe Devine ; - * this program is licensed under the GPL. - */ - -/* Modified October 3, 2003, to remove testing code, and add - include of "types.h". - - -Xodnizel -*/ - -#include -#include "inttypes.h" -#include "md5.h" - -#define GET_UINT32(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) + 3] << 24 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) ] ); \ -} - -#define PUT_UINT32(n,b,i) \ -{ \ - (b)[(i) ] = (uint8_t) ( (n) ); \ - (b)[(i) + 1] = (uint8_t) ( (n) >> 8 ); \ - (b)[(i) + 2] = (uint8_t) ( (n) >> 16 ); \ - (b)[(i) + 3] = (uint8_t) ( (n) >> 24 ); \ -} - -void sal_md5_starts( struct sal_md5_context *ctx ) -{ - ctx->total[0] = 0; - ctx->total[1] = 0; - ctx->state[0] = 0x67452301; - ctx->state[1] = 0xEFCDAB89; - ctx->state[2] = 0x98BADCFE; - ctx->state[3] = 0x10325476; -} - -void sal_md5_process( struct sal_md5_context *ctx, uint8_t data[64] ) -{ - uint32_t A, B, C, D, X[16]; - - GET_UINT32( X[0], data, 0 ); - GET_UINT32( X[1], data, 4 ); - GET_UINT32( X[2], data, 8 ); - GET_UINT32( X[3], data, 12 ); - GET_UINT32( X[4], data, 16 ); - GET_UINT32( X[5], data, 20 ); - GET_UINT32( X[6], data, 24 ); - GET_UINT32( X[7], data, 28 ); - GET_UINT32( X[8], data, 32 ); - GET_UINT32( X[9], data, 36 ); - GET_UINT32( X[10], data, 40 ); - GET_UINT32( X[11], data, 44 ); - GET_UINT32( X[12], data, 48 ); - GET_UINT32( X[13], data, 52 ); - GET_UINT32( X[14], data, 56 ); - GET_UINT32( X[15], data, 60 ); - -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) - -#define P(a,b,c,d,k,s,t) \ -{ \ - a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ -} - - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - -#define F(x,y,z) (z ^ (x & (y ^ z))) - - P( A, B, C, D, 0, 7, 0xD76AA478 ); - P( D, A, B, C, 1, 12, 0xE8C7B756 ); - P( C, D, A, B, 2, 17, 0x242070DB ); - P( B, C, D, A, 3, 22, 0xC1BDCEEE ); - P( A, B, C, D, 4, 7, 0xF57C0FAF ); - P( D, A, B, C, 5, 12, 0x4787C62A ); - P( C, D, A, B, 6, 17, 0xA8304613 ); - P( B, C, D, A, 7, 22, 0xFD469501 ); - P( A, B, C, D, 8, 7, 0x698098D8 ); - P( D, A, B, C, 9, 12, 0x8B44F7AF ); - P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); - P( B, C, D, A, 11, 22, 0x895CD7BE ); - P( A, B, C, D, 12, 7, 0x6B901122 ); - P( D, A, B, C, 13, 12, 0xFD987193 ); - P( C, D, A, B, 14, 17, 0xA679438E ); - P( B, C, D, A, 15, 22, 0x49B40821 ); - -#undef F - -#define F(x,y,z) (y ^ (z & (x ^ y))) - - P( A, B, C, D, 1, 5, 0xF61E2562 ); - P( D, A, B, C, 6, 9, 0xC040B340 ); - P( C, D, A, B, 11, 14, 0x265E5A51 ); - P( B, C, D, A, 0, 20, 0xE9B6C7AA ); - P( A, B, C, D, 5, 5, 0xD62F105D ); - P( D, A, B, C, 10, 9, 0x02441453 ); - P( C, D, A, B, 15, 14, 0xD8A1E681 ); - P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); - P( A, B, C, D, 9, 5, 0x21E1CDE6 ); - P( D, A, B, C, 14, 9, 0xC33707D6 ); - P( C, D, A, B, 3, 14, 0xF4D50D87 ); - P( B, C, D, A, 8, 20, 0x455A14ED ); - P( A, B, C, D, 13, 5, 0xA9E3E905 ); - P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); - P( C, D, A, B, 7, 14, 0x676F02D9 ); - P( B, C, D, A, 12, 20, 0x8D2A4C8A ); - -#undef F - -#define F(x,y,z) (x ^ y ^ z) - - P( A, B, C, D, 5, 4, 0xFFFA3942 ); - P( D, A, B, C, 8, 11, 0x8771F681 ); - P( C, D, A, B, 11, 16, 0x6D9D6122 ); - P( B, C, D, A, 14, 23, 0xFDE5380C ); - P( A, B, C, D, 1, 4, 0xA4BEEA44 ); - P( D, A, B, C, 4, 11, 0x4BDECFA9 ); - P( C, D, A, B, 7, 16, 0xF6BB4B60 ); - P( B, C, D, A, 10, 23, 0xBEBFBC70 ); - P( A, B, C, D, 13, 4, 0x289B7EC6 ); - P( D, A, B, C, 0, 11, 0xEAA127FA ); - P( C, D, A, B, 3, 16, 0xD4EF3085 ); - P( B, C, D, A, 6, 23, 0x04881D05 ); - P( A, B, C, D, 9, 4, 0xD9D4D039 ); - P( D, A, B, C, 12, 11, 0xE6DB99E5 ); - P( C, D, A, B, 15, 16, 0x1FA27CF8 ); - P( B, C, D, A, 2, 23, 0xC4AC5665 ); - -#undef F - -#define F(x,y,z) (y ^ (x | ~z)) - - P( A, B, C, D, 0, 6, 0xF4292244 ); - P( D, A, B, C, 7, 10, 0x432AFF97 ); - P( C, D, A, B, 14, 15, 0xAB9423A7 ); - P( B, C, D, A, 5, 21, 0xFC93A039 ); - P( A, B, C, D, 12, 6, 0x655B59C3 ); - P( D, A, B, C, 3, 10, 0x8F0CCC92 ); - P( C, D, A, B, 10, 15, 0xFFEFF47D ); - P( B, C, D, A, 1, 21, 0x85845DD1 ); - P( A, B, C, D, 8, 6, 0x6FA87E4F ); - P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); - P( C, D, A, B, 6, 15, 0xA3014314 ); - P( B, C, D, A, 13, 21, 0x4E0811A1 ); - P( A, B, C, D, 4, 6, 0xF7537E82 ); - P( D, A, B, C, 11, 10, 0xBD3AF235 ); - P( C, D, A, B, 2, 15, 0x2AD7D2BB ); - P( B, C, D, A, 9, 21, 0xEB86D391 ); - -#undef F - - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; -} - -void sal_md5_update( struct sal_md5_context *ctx, uint8_t *input, uint32_t length ) -{ - uint32_t left, fill; - - if( ! length ) return; - - left = ( ctx->total[0] >> 3 ) & 0x3F; - fill = 64 - left; - - ctx->total[0] += length << 3; - ctx->total[1] += length >> 29; - - ctx->total[0] &= 0xFFFFFFFF; - ctx->total[1] += ctx->total[0] < ( length << 3 ); - - if( left && length >= fill ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); - sal_md5_process( ctx, ctx->buffer ); - length -= fill; - input += fill; - left = 0; - } - - while( length >= 64 ) - { - sal_md5_process( ctx, input ); - length -= 64; - input += 64; - } - - if( length ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, length ); - } -} - -static uint8_t md5_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -void sal_md5_finish( struct sal_md5_context *ctx, uint8_t digest[16] ) -{ - uint32_t last, padn; - uint8_t msglen[8]; - - PUT_UINT32( ctx->total[0], msglen, 0 ); - PUT_UINT32( ctx->total[1], msglen, 4 ); - - last = ( ctx->total[0] >> 3 ) & 0x3F; - padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - - sal_md5_update( ctx, md5_padding, padn ); - sal_md5_update( ctx, msglen, 8 ); - - PUT_UINT32( ctx->state[0], digest, 0 ); - PUT_UINT32( ctx->state[1], digest, 4 ); - PUT_UINT32( ctx->state[2], digest, 8 ); - PUT_UINT32( ctx->state[3], digest, 12 ); -} diff --git a/branches/sdl2/src/attic/sexyal/md5.h b/branches/sdl2/src/attic/sexyal/md5.h deleted file mode 100644 index e06e356c..00000000 --- a/branches/sdl2/src/attic/sexyal/md5.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _MD5_H -#define _MD5_H - -struct sal_md5_context -{ - uint32_t total[2]; - uint32_t state[4]; - uint8_t buffer[64]; -}; - -void sal_md5_starts( struct sal_md5_context *ctx ); -void sal_md5_update( struct sal_md5_context *ctx, uint8_t *input, uint32_t length ); -void sal_md5_finish( struct sal_md5_context *ctx, uint8_t digest[16] ); - -#endif /* md5.h */ diff --git a/branches/sdl2/src/attic/sexyal/sexyal.c b/branches/sdl2/src/attic/sexyal/sexyal.c deleted file mode 100644 index fc1594c3..00000000 --- a/branches/sdl2/src/attic/sexyal/sexyal.c +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include -#include "sexyal.h" -#include "convert.h" - -#ifdef WIN32 - -#else -#include "drivers/oss.h" -#endif - -static uint32_t FtoB(const SexyAL_format *format, uint32_t frames) -{ - return(frames*format->channels*(format->sampformat>>4)); -} -/* -static uint32_t BtoF(const SexyAL_format *format, uint32_t bytes) -{ - return(bytes / (format->channels * (format->sampformat>>4))); -} -*/ -static uint32_t CanWrite(SexyAL_device *device) -{ - uint32_t bytes,frames; - - #ifdef WIN32 - bytes=SexyALI_DSound_RawCanWrite(device); - #else - bytes=SexyALI_OSS_RawCanWrite(device); - #endif - frames=bytes / device->format.channels / (device->format.sampformat>>4); - - return(frames); -} - -static uint32_t Write(SexyAL_device *device, void *data, uint32_t frames) -{ - uint8_t buffer[2048*4]; - - while(frames) - { - int32_t tmp; - - tmp=frames; - if(tmp>2048) - { - tmp=2048; - frames-=2048; - } - else frames-=tmp; - - SexiALI_Convert(&device->srcformat, &device->format, buffer, data, tmp); - //printf("%02x, %02x, %02x\n", device->srcformat.sampformat, device->srcformat.byteorder, device->srcformat.channels); - //printf("buffer: %d\n",buffer[0]); - /* FIXME: Return the actual number of frame written. It should always equal - the number of frames requested to be written, except in cases of sound device - failures. - */ - #ifdef WIN32 - SexyALI_DSound_RawWrite(device,buffer,FtoB(&device->format,tmp)); - #else - SexyALI_OSS_RawWrite(device,buffer,FtoB(&device->format,tmp)); - #endif - } - return(frames); -} - -static int Close(SexyAL_device *device) -{ - #ifdef WIN32 - return(SexyALI_DSound_Close(device)); - #else - return(SexyALI_OSS_Close(device)); - #endif -} - -int SetConvert(struct __SexyAL_device *device, SexyAL_format *format) -{ - memcpy(&device->srcformat,format,sizeof(SexyAL_format)); - return(1); -} - -static SexyAL_device *Open(SexyAL *iface, uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering) -{ - SexyAL_device *ret; - - #ifdef WIN32 - if(!(ret=SexyALI_DSound_Open(id,format,buffering))) return(0); - #else - if(!(ret=SexyALI_OSS_Open(id,format,buffering))) return(0); - #endif - - ret->Write=Write; - ret->Close=Close; - ret->CanWrite=CanWrite; - ret->SetConvert=SetConvert; - return(ret); -} - -void Destroy(SexyAL *iface) -{ - free(iface); -} - -void *SexyAL_Init(int version) -{ - SexyAL *iface; - if(!version != 1) return(0); - - iface=malloc(sizeof(SexyAL)); - - iface->Open=Open; - iface->Destroy=Destroy; - return((void *)iface); -} diff --git a/branches/sdl2/src/attic/sexyal/sexyal.h b/branches/sdl2/src/attic/sexyal/sexyal.h deleted file mode 100644 index c2e28884..00000000 --- a/branches/sdl2/src/attic/sexyal/sexyal.h +++ /dev/null @@ -1,52 +0,0 @@ -#include - -typedef struct -{ - uint32_t sampformat; - uint32_t channels; /* 1 = mono, 2 = stereo */ - uint32_t rate; /* Number of frames per second, 22050, 44100, etc. */ - uint32_t byteorder; /* 0 = Native(to CPU), 1 = Reversed. PDP can go to hell. */ -} SexyAL_format; - -typedef struct -{ - uint32_t fragcount; - uint32_t fragsize; - uint32_t totalsize; /* Shouldn't be filled in by application code. */ - uint32_t ms; /* Milliseconds of buffering, approximate. */ -} SexyAL_buffering; - -#define SEXYAL_ID_DEFAULT 0 -#define SEXYAL_ID_UNUSED 1 - -#define SEXYAL_FMT_PCMU8 0x10 -#define SEXYAL_FMT_PCMS8 0x11 - -#define SEXYAL_FMT_PCMU16 0x20 -#define SEXYAL_FMT_PCMS16 0x21 - -#define SEXYAL_FMT_PCMU32U24 0x40 -#define SEXYAL_FMT_PCMS32S24 0x41 - -#define SEXYAL_FMT_PCMU32U16 0x42 -#define SEXYAL_FMT_PCMS32S16 0x43 - -typedef struct __SexyAL_device { - int (*SetConvert)(struct __SexyAL_device *, SexyAL_format *); - uint32_t (*Write)(struct __SexyAL_device *, void *data, uint32_t frames); - uint32_t (*CanWrite)(struct __SexyAL_device *); - int (*Close)(struct __SexyAL_device *); - SexyAL_format format; - SexyAL_format srcformat; - SexyAL_buffering buffering; - void *private; -} SexyAL_device; - -typedef struct __SexyAL { - SexyAL_device * (*Open)(struct __SexyAL *, uint64_t id, SexyAL_format *, SexyAL_buffering *buffering); - void (*Enumerate)(struct __SexyAL *, int (*func)(uint8_t *name, uint64_t id, void *udata)); - void (*Destroy)(struct __SexyAL *); -} SexyAL; - -/* Initializes the library, requesting the interface of the version specified. */ -void *SexyAL_Init(int version); diff --git a/branches/sdl2/src/attic/sexyal/smallc.c b/branches/sdl2/src/attic/sexyal/smallc.c deleted file mode 100644 index 4aa95091..00000000 --- a/branches/sdl2/src/attic/sexyal/smallc.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "smallc.h" - -void sal_memcpy(void *dest, const void *src, uint32_t n) -{ - while(n--) - { - *(uint8_t*)dest=*(uint8_t *)src; - (uint8_t*)dest++; - (uint8_t*)src++; - } -} - -uint32_t sal_strlen(const char *buf) -{ - uint32_t size=0; - - while(*buf++) size++; - - return(size); -} - -void sal_strcpy(char *dest, const char *src) -{ - while(*src) - *dest++ = *src++; - *dest=0; -} - -void sal_strcat(char *dest, const char *src) -{ - while(*dest) - dest++; - while(*src) - *dest++ = *src++; - *dest=0; -} - -const char *sal_uinttos(int value) -{ - static char buf[64],buf2[64]; - char *tmp; - int len=0; - - tmp=buf; - - while(value) - { - *tmp='0'+(value%10); - len++; - tmp++; - value/=10; - } - - tmp=buf2; - while(len-- >= 0) - { - *tmp=buf[len]; - tmp++; - } - - *tmp=0; - return(buf2); -} diff --git a/branches/sdl2/src/attic/sexyal/smallc.h b/branches/sdl2/src/attic/sexyal/smallc.h deleted file mode 100644 index 86856b1e..00000000 --- a/branches/sdl2/src/attic/sexyal/smallc.h +++ /dev/null @@ -1,7 +0,0 @@ -#include - -void sal_memcpy(void *dest, const void *src, uint32_t n); -void sal_strcpy(char *dest, const char *src); -const char *sal_uinttos(int value); -void sal_strcat(char *dest, const char *src); - diff --git a/branches/sdl2/src/attic/soundexp.cpp b/branches/sdl2/src/attic/soundexp.cpp deleted file mode 100644 index d59350f7..00000000 --- a/branches/sdl2/src/attic/soundexp.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#include - -#include "types.h" -#include "fceu.h" - -static OggVorbis_File cursong; - -void InstallSoundExp(void) -{ - FILE *fp=fopen("test.ogg","rb"); - - ov_open(fp,&cursong,NULL,0); - FCEUGameInfo->soundrate=44100; - FCEUGameInfo->soundchan=2; -} - -int cur=0; - -void UpdateSoundExp(int32 *buf, int32 len) -{ - int16 boo[8192]; - int32 offset=0; - int x; - int32 tlen=len; - - while(len) - { - int32 t=ov_read(&cursong,(char *)boo+offset*4,len*4,0,2,1,&cur)/4; - len-=t; - offset+=t; - } - -// printf("%d\n",inboo); - for(x=0;x> 2) & 1); - if (is172) - setchr8((((cmd ^ reg[2]) >> 3) & 2) | (((cmd ^ reg[2]) >> 5) & 1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to - // rearrange CHR banks for normal UNIF board and mapper 172 is unneccessary - else - setchr8(reg[2] & 3); -} - -static DECLFW(UNL22211WriteLo) { -// FCEU_printf("bs %04x %02x\n",A,V); - reg[A & 3] = V; -} - -static DECLFW(UNL22211WriteHi) { -// FCEU_printf("bs %04x %02x\n",A,V); - cmd = V; - Sync(); -} - -static DECLFR(UNL22211ReadLo) { - return (reg[1] ^ reg[2]) | (is173 ? 0x01 : 0x40); -// if(reg[3]) -// return reg[2]; -// else -// return X.DB; -} - -static void UNL22211Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4100, 0x4100, UNL22211ReadLo); - SetWriteHandler(0x4100, 0x4103, UNL22211WriteLo); - SetWriteHandler(0x8000, 0xFFFF, UNL22211WriteHi); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNL22211_Init(CartInfo *info) { - is172 = 0; - is173 = 0; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper172_Init(CartInfo *info) { - is172 = 1; - is173 = 0; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper173_Init(CartInfo *info) { - is172 = 0; - is173 = 1; - info->Power = UNL22211Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/09-034a.cpp b/branches/sdl2/src/boards/09-034a.cpp deleted file mode 100644 index 7847cd9d..00000000 --- a/branches/sdl2/src/boards/09-034a.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversions - * - * Super Mario Bros 2j (Alt Full) is a BAD incomplete dump, should be mapper 43 - * - * Both Voleyball and Zanac by Whirlind Manu shares the same PCB, but with - * some differences: Voleyball has 8K CHR ROM and 8K ROM at 6000K, Zanac - * have 8K CHR RAM and banked 16K ROM mapper at 6000 as two 8K banks. -* - * Super Mario Bros 2j (Alt Small) uses additionally IRQ timer to drive framerate - * - * PCB for this mapper is "09-034A" - */ - -#include "mapinc.h" - -static uint8 prg; -static uint32 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 4, "IRQC" }, - { &IRQa, 4, "IRQA" }, - { &prg, 1, "PRG" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(1, 0x6000, prg); - setprg32(0x8000, 0); - setchr8(0); -} - -static DECLFW(UNLSMB2JWrite1) { - prg = V & 1; - Sync(); -} - -static DECLFW(UNLSMB2JWrite2) { - IRQa = V & 1; - IRQCount = 0; - X6502_IRQEnd(FCEU_IQEXT); -} - -static DECLFR(UNLSMB2JRead) { - return 0xFF; -} - -static void UNLSMB2JPower(void) { - prg = 0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetReadHandler(0x4042, 0x4055, UNLSMB2JRead); - SetWriteHandler(0x4068, 0x4068, UNLSMB2JWrite2); - SetWriteHandler(0x4027, 0x4027, UNLSMB2JWrite1); -} - -static void UNLSMB2JIRQHook(int a) { - if (IRQa) - { - if (IRQCount < 5750) // completely by guess - IRQCount += a; - else { - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLSMB2J_Init(CartInfo *info) { - info->Power = UNLSMB2JPower; - MapIRQHook = UNLSMB2JIRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/103.cpp b/branches/sdl2/src/boards/103.cpp deleted file mode 100644 index 16a622c4..00000000 --- a/branches/sdl2/src/boards/103.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg0, reg1, reg2; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®0, 1, "REG0" }, - { ®1, 1, "REG1" }, - { ®2, 1, "REG2" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8(0x8000, 0xc); - setprg8(0xe000, 0xf); - if (reg2 & 0x10) { - setprg8(0x6000, reg0); - setprg8(0xa000, 0xd); - setprg8(0xc000, 0xe); - } else { - setprg8r(0x10, 0x6000, 0); - setprg4(0xa000, (0xd << 1)); - setprg2(0xb000, (0xd << 2) + 2); - setprg2r(0x10, 0xb800, 4); - setprg2r(0x10, 0xc000, 5); - setprg2r(0x10, 0xc800, 6); - setprg2r(0x10, 0xd000, 7); - setprg2(0xd800, (0xe << 2) + 3); - } - setmirror(reg1 ^ 1); -} - -static DECLFW(M103RamWrite0) { - WRAM[A & 0x1FFF] = V; -} - -static DECLFW(M103RamWrite1) { - WRAM[0x2000 + ((A - 0xB800) & 0x1FFF)] = V; -} - -static DECLFW(M103Write0) { - reg0 = V & 0xf; - Sync(); -} - -static DECLFW(M103Write1) { - reg1 = (V >> 3) & 1; - Sync(); -} - -static DECLFW(M103Write2) { - reg2 = V; - Sync(); -} - -static void M103Power(void) { - reg0 = reg1 = 0; reg2 = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, M103RamWrite0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0xB800, 0xD7FF, M103RamWrite1); - SetWriteHandler(0x8000, 0x8FFF, M103Write0); - SetWriteHandler(0xE000, 0xEFFF, M103Write1); - SetWriteHandler(0xF000, 0xFFFF, M103Write2); -} - -static void M103Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper103_Init(CartInfo *info) { - info->Power = M103Power; - info->Close = M103Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 16384; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/106.cpp b/branches/sdl2/src/boards/106.cpp deleted file mode 100644 index e427d293..00000000 --- a/branches/sdl2/src/boards/106.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[16], IRQa; -static uint32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { reg, 16, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setchr1(0x0000, reg[0] & 0xfe); - setchr1(0x0400, reg[1] | 1); - setchr1(0x0800, reg[2] & 0xfe); - setchr1(0x0c00, reg[3] | 1); - setchr1(0x1000, reg[4]); - setchr1(0x1400, reg[5]); - setchr1(0x1800, reg[6]); - setchr1(0x1c00, reg[7]); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, (reg[0x8] & 0xf) | 0x10); - setprg8(0xA000, (reg[0x9] & 0x1f)); - setprg8(0xC000, (reg[0xa] & 0x1f)); - setprg8(0xE000, (reg[0xb] & 0xf) | 0x10); - setmirror((reg[0xc] & 1) ^ 1); -} - -static DECLFW(M106Write) { - A &= 0xF; - switch (A) { - case 0xD: IRQa = 0; IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xE: IRQCount = (IRQCount & 0xFF00) | V; break; - case 0xF: IRQCount = (IRQCount & 0x00FF) | (V << 8); IRQa = 1; break; - default: reg[A] = V; Sync(); break; - } -} - -static void M106Power(void) { - reg[8] = reg[9] = reg[0xa] = reg[0xb] = -1; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M106Write); -} - -static void M106Reset(void) { -} - -static void M106Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void M106CpuHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount > 0x10000) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper106_Init(CartInfo *info) { - info->Reset = M106Reset; - info->Power = M106Power; - info->Close = M106Close; - MapIRQHook = M106CpuHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/108.cpp b/branches/sdl2/src/boards/108.cpp deleted file mode 100644 index 4c463f96..00000000 --- a/branches/sdl2/src/boards/108.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg); - setprg32(0x8000, ~0); - setchr8(0); -} - -static DECLFW(M108Write) { - reg = V; - Sync(); -} - -static void M108Power(void) { - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x8FFF, M108Write); // regular 108 - SetWriteHandler(0xF000, 0xFFFF, M108Write); // simplified Kaiser BB Hack -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper108_Init(CartInfo *info) { - info->Power = M108Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/112.cpp b/branches/sdl2/src/boards/112.cpp deleted file mode 100644 index 6c184b12..00000000 --- a/branches/sdl2/src/boards/112.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * NTDEC, ASDER games - * - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd, bank; -static uint8 *WRAM = NULL; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { &mirror, 1, "MIRR" }, - { &bank, 1, "BANK" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirror ^ 1); - setprg8(0x8000, reg[0]); - setprg8(0xA000, reg[1]); - setchr2(0x0000, (reg[2] >> 1)); - setchr2(0x0800, (reg[3] >> 1)); - setchr1(0x1000, ((bank & 0x10) << 4) | reg[4]); - setchr1(0x1400, ((bank & 0x20) << 3) | reg[5]); - setchr1(0x1800, ((bank & 0x40) << 2) | reg[6]); - setchr1(0x1C00, ((bank & 0x80) << 1) | reg[7]); -} - -static DECLFW(M112Write) { - switch (A) { - case 0xe000: mirror = V & 1; Sync();; break; - case 0x8000: cmd = V & 7; break; - case 0xa000: reg[cmd] = V; Sync(); break; - case 0xc000: bank = V; Sync(); break; - } -} - -static void M112Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M112Power(void) { - bank = 0; - setprg16(0xC000, ~0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M112Write); - SetWriteHandler(0x4020, 0x5FFF, M112Write); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper112_Init(CartInfo *info) { - info->Power = M112Power; - info->Close = M112Close; - GameStateRestore = StateRestore; - WRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartPRGMapping(0x10, WRAM, 8192, 1); - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/116.cpp b/branches/sdl2/src/boards/116.cpp deleted file mode 100644 index 555f6c48..00000000 --- a/branches/sdl2/src/boards/116.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * SL12 Protected 3-in-1 mapper hardware (VRC2, MMC3, MMC1) - * the same as 603-5052 board (TODO: add reading registers, merge) - * SL1632 2-in-1 protected board, similar to SL12 (TODO: find difference) - * - * Known PCB: - * - * Garou Densetsu Special (G0904.PCB, Huang-1, GAL dip: W conf.) - * Kart Fighter (008, Huang-1, GAL dip: W conf.) - * Somari (008, C5052-13, GAL dip: P conf., GK2-P/GK2-V maskroms) - * Somari (008, Huang-1, GAL dip: W conf., GK1-P/GK1-V maskroms) - * AV Mei Shao Nv Zhan Shi (aka AV Pretty Girl Fighting) (SL-12 PCB, Hunag-1, GAL dip: unk conf. SL-11A/SL-11B maskroms) - * Samurai Spirits (Full version) (Huang-1, GAL dip: unk conf. GS-2A/GS-4A maskroms) - * Contra Fighter (603-5052 PCB, C5052-3, GAL dip: unk conf. SC603-A/SCB603-B maskroms) - * - */ - -#include "mapinc.h" - -static uint8 mode; -static uint8 vrc2_chr[8], vrc2_prg[2], vrc2_mirr; -static uint8 mmc3_regs[10], mmc3_ctrl, mmc3_mirr; -static uint8 IRQCount, IRQLatch, IRQa; -static uint8 IRQReload; -static uint8 mmc1_regs[4], mmc1_buffer, mmc1_shift; - -static SFORMAT StateRegs[] = -{ - { &mode, 1, "MODE" }, - { vrc2_chr, 8, "VRCC" }, - { vrc2_prg, 2, "VRCP" }, - { &vrc2_mirr, 1, "VRCM" }, - { mmc3_regs, 10, "M3RG" }, - { &mmc3_ctrl, 1, "M3CT" }, - { &mmc3_mirr, 1, "M3MR" }, - { &IRQReload, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { mmc1_regs, 4, "M1RG" }, - { &mmc1_buffer, 1, "M1BF" }, - { &mmc1_shift, 1, "M1MR" }, - { 0 } -}; - -static void SyncPRG(void) { - switch (mode & 3) { - case 0: - setprg8(0x8000, vrc2_prg[0]); - setprg8(0xA000, vrc2_prg[1]); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - break; - case 1: - { - uint32 swap = (mmc3_ctrl >> 5) & 2; - setprg8(0x8000, mmc3_regs[6 + swap]); - setprg8(0xA000, mmc3_regs[7]); - setprg8(0xC000, mmc3_regs[6 + (swap ^ 2)]); - setprg8(0xE000, mmc3_regs[9]); - break; - } - case 2: - case 3: - { - uint8 bank = mmc1_regs[3] & 0xF; - if (mmc1_regs[0] & 8) { - if (mmc1_regs[0] & 4) { - setprg16(0x8000, bank); - setprg16(0xC000, 0x0F); - } else { - setprg16(0x8000, 0); - setprg16(0xC000, bank); - } - } else - setprg32(0x8000, bank >> 1); - break; - } - } -} - -static void SyncCHR(void) { - uint32 base = (mode & 4) << 6; - switch (mode & 3) { - case 0: - setchr1(0x0000, base | vrc2_chr[0]); - setchr1(0x0400, base | vrc2_chr[1]); - setchr1(0x0800, base | vrc2_chr[2]); - setchr1(0x0c00, base | vrc2_chr[3]); - setchr1(0x1000, base | vrc2_chr[4]); - setchr1(0x1400, base | vrc2_chr[5]); - setchr1(0x1800, base | vrc2_chr[6]); - setchr1(0x1c00, base | vrc2_chr[7]); - break; - case 1: { - uint32 swap = (mmc3_ctrl & 0x80) << 5; - setchr1(0x0000 ^ swap, base | ((mmc3_regs[0]) & 0xFE)); - setchr1(0x0400 ^ swap, base | (mmc3_regs[0] | 1)); - setchr1(0x0800 ^ swap, base | ((mmc3_regs[1]) & 0xFE)); - setchr1(0x0c00 ^ swap, base | (mmc3_regs[1] | 1)); - setchr1(0x1000 ^ swap, base | mmc3_regs[2]); - setchr1(0x1400 ^ swap, base | mmc3_regs[3]); - setchr1(0x1800 ^ swap, base | mmc3_regs[4]); - setchr1(0x1c00 ^ swap, base | mmc3_regs[5]); - break; - } - case 2: - case 3: - if (mmc1_regs[0] & 0x10) { - setchr4(0x0000, mmc1_regs[1]); - setchr4(0x1000, mmc1_regs[2]); - } else - setchr8(mmc1_regs[1] >> 1); - break; - } -} - -static void SyncMIR(void) { - switch (mode & 3) { - case 0: { - setmirror((vrc2_mirr & 1) ^ 1); - break; - } - case 1: { - setmirror((mmc3_mirr & 1) ^ 1); - break; - } - case 2: - case 3: { - switch (mmc1_regs[0] & 3) { - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - } - break; - } - } -} - -static void Sync(void) { - SyncPRG(); - SyncCHR(); - SyncMIR(); -} - -static DECLFW(UNLSL12ModeWrite) { -// FCEU_printf("%04X:%02X\n",A,V); - if ((A & 0x4100) == 0x4100) { - mode = V; - if (A & 1) { // hacky hacky, there are two configuration modes on SOMARI HUANG-1 PCBs - // Solder pads with P1/P2 shorted called SOMARI P, - // Solder pads with W1/W2 shorted called SOMARI W - // Both identical 3-in-1 but W wanted MMC1 registers - // to be reset when switch to MMC1 mode P one - doesn't - // There is issue with W version of Somari at starting copyrights - mmc1_regs[0] = 0xc; - mmc1_regs[3] = 0; - mmc1_buffer = 0; - mmc1_shift = 0; - } - Sync(); - } -} - -static DECLFW(UNLSL12Write) { -// FCEU_printf("%04X:%02X\n",A,V); - switch (mode & 3) { - case 0: { - if ((A >= 0xB000) && (A <= 0xE003)) { - int32 ind = ((((A & 2) | (A >> 10)) >> 1) + 2) & 7; - int32 sar = ((A & 1) << 2); - vrc2_chr[ind] = (vrc2_chr[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - SyncCHR(); - } else - switch (A & 0xF000) { - case 0x8000: vrc2_prg[0] = V; SyncPRG(); break; - case 0xA000: vrc2_prg[1] = V; SyncPRG(); break; - case 0x9000: vrc2_mirr = V; SyncMIR(); break; - } - break; - } - case 1: { - switch (A & 0xE001) { - case 0x8000: { - uint8 old_ctrl = mmc3_ctrl; - mmc3_ctrl = V; - if ((old_ctrl & 0x40) != (mmc3_ctrl & 0x40)) - SyncPRG(); - if ((old_ctrl & 0x80) != (mmc3_ctrl & 0x80)) - SyncCHR(); - break; - } - case 0x8001: - mmc3_regs[mmc3_ctrl & 7] = V; - if ((mmc3_ctrl & 7) < 6) - SyncCHR(); - else - SyncPRG(); - break; - case 0xA000: - mmc3_mirr = V; - SyncMIR(); - break; - case 0xC000: - IRQLatch = V; - break; - case 0xC001: - IRQReload = 1; - break; - case 0xE000: - X6502_IRQEnd(FCEU_IQEXT); - IRQa = 0; - break; - case 0xE001: - IRQa = 1; - break; - } - break; - } - case 2: - case 3: { - if (V & 0x80) { - mmc1_regs[0] |= 0xc; - mmc1_buffer = mmc1_shift = 0; - SyncPRG(); - } else { - uint8 n = (A >> 13) - 4; - mmc1_buffer |= (V & 1) << (mmc1_shift++); - if (mmc1_shift == 5) { - mmc1_regs[n] = mmc1_buffer; - mmc1_buffer = mmc1_shift = 0; - switch (n) { - case 0: SyncMIR(); - case 2: SyncCHR(); - case 3: - case 1: SyncPRG(); - } - } - } - break; - } - } -} - -static void UNLSL12HBIRQ(void) { - if ((mode & 3) == 1) { - int32 count = IRQCount; - if (!count || IRQReload) { - IRQCount = IRQLatch; - IRQReload = 0; - } else - IRQCount--; - if (!IRQCount) { - if (IRQa) - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -static void UNLSL12Power(void) { - mode = 0; - vrc2_chr[0] = ~0; - vrc2_chr[1] = ~0; - vrc2_chr[2] = ~0; - vrc2_chr[3] = ~0; // W conf. of Somari wanted CHR3 has to be set to BB bank (or similar), but doesn't do that directly - vrc2_chr[4] = 4; - vrc2_chr[5] = 5; - vrc2_chr[6] = 6; - vrc2_chr[7] = 7; - vrc2_prg[0] = 0; - vrc2_prg[1] = 1; - vrc2_mirr = 0; - mmc3_regs[0] = 0; - mmc3_regs[1] = 2; - mmc3_regs[2] = 4; - mmc3_regs[3] = 5; - mmc3_regs[4] = 6; - mmc3_regs[5] = 7; - mmc3_regs[6] = ~3; - mmc3_regs[7] = ~2; - mmc3_regs[8] = ~1; - mmc3_regs[9] = ~0; - mmc3_ctrl = mmc3_mirr = IRQCount = IRQLatch = IRQa = 0; - mmc1_regs[0] = 0xc; - mmc1_regs[1] = 0; - mmc1_regs[2] = 0; - mmc1_regs[3] = 0; - mmc1_buffer = 0; - mmc1_shift = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x7FFF, UNLSL12ModeWrite); - SetWriteHandler(0x8000, 0xFFFF, UNLSL12Write); -} - -void UNLSL12_Init(CartInfo *info) { - info->Power = UNLSL12Power; - GameHBIRQHook = UNLSL12HBIRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/117.cpp b/branches/sdl2/src/boards/117.cpp deleted file mode 100644 index 3a50ce27..00000000 --- a/branches/sdl2/src/boards/117.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 prgreg[4], chrreg[8], mirror; -static uint8 IRQa, IRQCount, IRQLatch; - -static SFORMAT StateRegs[] = -{ - { &IRQa, 1, "IRQA" }, - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { prgreg, 4, "PREG" }, - { chrreg, 8, "CREG" }, - { &mirror, 1, "MREG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, prgreg[0]); - setprg8(0xa000, prgreg[1]); - setprg8(0xc000, prgreg[2]); - setprg8(0xe000, prgreg[3]); - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chrreg[i]); - setmirror(mirror ^ 1); -} - -static DECLFW(M117Write) { - if (A < 0x8004) { - prgreg[A & 3] = V; - Sync(); - } else if ((A >= 0xA000) && (A <= 0xA007)) { - chrreg[A & 7] = V; - Sync(); - } else switch (A) { - case 0xc001: IRQLatch = V; break; - case 0xc003: IRQCount = IRQLatch; IRQa |= 2; break; - case 0xe000: IRQa &= ~1; IRQa |= V & 1; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break; - case 0xd000: mirror = V & 1; - } -} - -static void M117Power(void) { - prgreg[0] = ~3; prgreg[1] = ~2; prgreg[2] = ~1; prgreg[3] = ~0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M117Write); -} - -static void M117IRQHook(void) { - if (IRQa == 3 && IRQCount) { - IRQCount--; - if (!IRQCount) { - IRQa &= 1; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper117_Init(CartInfo *info) { - info->Power = M117Power; - GameHBIRQHook = M117IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/120.cpp b/branches/sdl2/src/boards/120.cpp deleted file mode 100644 index aee1982a..00000000 --- a/branches/sdl2/src/boards/120.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg); - setprg32(0x8000, 2); - setchr8(0); -} - -static DECLFW(M120Write) { - if (A == 0x41FF) { - reg = V & 7; - Sync(); - } -} - -static void M120Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x5FFF, M120Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper120_Init(CartInfo *info) { - info->Power = M120Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/121.cpp b/branches/sdl2/src/boards/121.cpp deleted file mode 100644 index aa4e5c2c..00000000 --- a/branches/sdl2/src/boards/121.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007-2008 Mad Dumper, CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Panda prince pirate. - * MK4, MK6, A9711/A9713 board - * 6035052 seems to be the same too, but with prot array in reverse - * A9746 seems to be the same too, check - * 187 seems to be the same too, check (A98402 board) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void Sync() { - switch (EXPREGS[5] & 0x3F) { - case 0x20: EXPREGS[7] = 1; EXPREGS[0] = EXPREGS[6]; break; - case 0x29: EXPREGS[7] = 1; EXPREGS[0] = EXPREGS[6]; break; - case 0x26: EXPREGS[7] = 0; EXPREGS[0] = EXPREGS[6]; break; - case 0x2B: EXPREGS[7] = 1; EXPREGS[0] = EXPREGS[6]; break; - case 0x2C: EXPREGS[7] = 1; if (EXPREGS[6]) EXPREGS[0] = EXPREGS[6]; break; - case 0x3C: - case 0x3F: EXPREGS[7] = 1; EXPREGS[0] = EXPREGS[6]; break; - case 0x28: EXPREGS[7] = 0; EXPREGS[1] = EXPREGS[6]; break; - case 0x2A: EXPREGS[7] = 0; EXPREGS[2] = EXPREGS[6]; break; - case 0x2F: break; - default: EXPREGS[5] = 0; break; - } -} - -static void M121CW(uint32 A, uint8 V) { - if (PRGsize[0] == CHRsize[0]) { // A9713 multigame extension hack! - setchr1(A, V | ((EXPREGS[3] & 0x80) << 1)); - } else { - if ((A & 0x1000) == ((MMC3_cmd & 0x80) << 5)) - setchr1(A, V | 0x100); - else - setchr1(A, V); - } -} - -static void M121PW(uint32 A, uint8 V) { - if (EXPREGS[5] & 0x3F) { -// FCEU_printf("prot banks: %02x %02x %02x %02x\n",V,EXPREGS[2],EXPREGS[1],EXPREGS[0]); - setprg8(A, (V & 0x1F) | ((EXPREGS[3] & 0x80) >> 2)); - setprg8(0xE000, (EXPREGS[0]) | ((EXPREGS[3] & 0x80) >> 2)); - setprg8(0xC000, (EXPREGS[1]) | ((EXPREGS[3] & 0x80) >> 2)); - setprg8(0xA000, (EXPREGS[2]) | ((EXPREGS[3] & 0x80) >> 2)); - } else { -// FCEU_printf("gen banks: %04x %02x\n",A,V); - setprg8(A, (V & 0x1F) | ((EXPREGS[3] & 0x80) >> 2)); - } -} - -static DECLFW(M121Write) { -// FCEU_printf("write: %04x:%04x\n",A&0xE003,V); - switch (A & 0xE003) { - case 0x8000: -// EXPREGS[5] = 0; -// FCEU_printf("gen: %02x\n",V); - MMC3_CMDWrite(A, V); - FixMMC3PRG(MMC3_cmd); - break; - case 0x8001: - EXPREGS[6] = ((V & 1) << 5) | ((V & 2) << 3) | ((V & 4) << 1) | ((V & 8) >> 1) | ((V & 0x10) >> 3) | ((V & 0x20) >> 5); -// FCEU_printf("bank: %02x (%02x)\n",V,EXPREGS[6]); - if (!EXPREGS[7]) Sync(); - MMC3_CMDWrite(A, V); - FixMMC3PRG(MMC3_cmd); - break; - case 0x8003: - EXPREGS[5] = V; -// EXPREGS[7] = 0; -// FCEU_printf("prot: %02x\n",EXPREGS[5]); - Sync(); - MMC3_CMDWrite(0x8000, V); - FixMMC3PRG(MMC3_cmd); - break; - } -} - -static uint8 prot_array[16] = { 0x83, 0x83, 0x42, 0x00 }; -static DECLFW(M121LoWrite) { - EXPREGS[4] = prot_array[V & 3]; // 0x100 bit in address seems to be switch arrays 0, 2, 2, 3 (Contra Fighter) - if ((A & 0x5180) == 0x5180) { // A9713 multigame extension - EXPREGS[3] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } -// FCEU_printf("write: %04x:%04x\n",A,V); -} - -static DECLFR(M121Read) { -// FCEU_printf("read: %04x->\n",A,EXPREGS[0]); - return EXPREGS[4]; -} - -static void M121Power(void) { - EXPREGS[3] = 0x80; - EXPREGS[5] = 0; - GenMMC3Power(); - SetReadHandler(0x5000, 0x5FFF, M121Read); - SetWriteHandler(0x5000, 0x5FFF, M121LoWrite); - SetWriteHandler(0x8000, 0x9FFF, M121Write); -} - -void Mapper121_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 8, 0); - pwrap = M121PW; - cwrap = M121CW; - info->Power = M121Power; - AddExState(EXPREGS, 8, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/15.cpp b/branches/sdl2/src/boards/15.cpp deleted file mode 100644 index 4aee608a..00000000 --- a/branches/sdl2/src/boards/15.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint16 latchea; -static uint8 latched; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static SFORMAT StateRegs[] = -{ - { &latchea, 2, "AREG" }, - { &latched, 1, "DREG" }, - { 0 } -}; - -static void Sync(void) { - int i; - setmirror(((latched >> 6) & 1) ^ 1); - switch (latchea) { - case 0x8000: - for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), (((latched & 0x7F) << 1) + i) ^ (latched >> 7)); - break; - case 0x8002: - for (i = 0; i < 4; i++) - setprg8(0x8000 + (i << 13), ((latched & 0x7F) << 1) + (latched >> 7)); - break; - case 0x8001: - case 0x8003: - for (i = 0; i < 4; i++) { - unsigned int b; - b = latched & 0x7F; - if (i >= 2 && !(latchea & 0x2)) - b = 0x7F; - setprg8(0x8000 + (i << 13), (i & 1) + ((b << 1) ^ (latched >> 7))); - } - break; - } -} - -static DECLFW(M15Write) { - latchea = A; - latched = V; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -static void M15Power(void) { - latchea = 0x8000; - latched = 0; - setchr8(0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M15Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - Sync(); -} - -static void M15Reset(void) { - latchea = 0x8000; - latched = 0; - Sync(); -} - -static void M15Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper15_Init(CartInfo *info) { - info->Power = M15Power; - info->Reset = M15Reset; - info->Close = M15Close; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/151.cpp b/branches/sdl2/src/boards/151.cpp deleted file mode 100644 index 2d9335f1..00000000 --- a/branches/sdl2/src/boards/151.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 regs[8]; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, regs[0]); - setprg8(0xA000, regs[2]); - setprg8(0xC000, regs[4]); - setprg8(0xE000, ~0); - setchr4(0x0000, regs[6]); - setchr4(0x1000, regs[7]); -} - -static DECLFW(M151Write) { - regs[(A >> 12) & 7] = V; - Sync(); -} - -static void M151Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M151Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper151_Init(CartInfo *info) { - info->Power = M151Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/156.cpp b/branches/sdl2/src/boards/156.cpp deleted file mode 100644 index d682f305..00000000 --- a/branches/sdl2/src/boards/156.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chrlo[8], chrhi[8], prg, mirr, mirrisused = 0; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &prg, 1, "PREG" }, - { chrlo, 8, "CRGL" }, - { chrhi, 8, "CRGH" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - uint32 i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chrlo[i] | (chrhi[i] << 8)); - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, prg); - setprg16(0xC000, ~0); - if (mirrisused) - setmirror(mirr ^ 1); - else - setmirror(MI_0); -} - -static DECLFW(M156Write) { - switch (A) { - case 0xC000: - case 0xC001: - case 0xC002: - case 0xC003: chrlo[A & 3] = V; Sync(); break; - case 0xC004: - case 0xC005: - case 0xC006: - case 0xC007: chrhi[A & 3] = V; Sync(); break; - case 0xC008: - case 0xC009: - case 0xC00A: - case 0xC00B: chrlo[4 + (A & 3)] = V; Sync(); break; - case 0xC00C: - case 0xC00D: - case 0xC00E: - case 0xC00F: chrhi[4 + (A & 3)] = V; Sync(); break; - case 0xC010: prg = V; Sync(); break; - case 0xC014: mirr = V; mirrisused = 1; Sync(); break; - } -} - -static void M156Reset(void) { - uint32 i; - for (i = 0; i < 8; i++) { - chrlo[i] = 0; - chrhi[i] = 0; - } - prg = 0; - mirr = 0; - mirrisused = 0; -} - -static void M156Power(void) { - M156Reset(); - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0xC000, 0xCFFF, M156Write); -} - -static void M156Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper156_Init(CartInfo *info) { - info->Reset = M156Reset; - info->Power = M156Power; - info->Close = M156Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/164.cpp b/branches/sdl2/src/boards/164.cpp deleted file mode 100644 index 7cde0a3a..00000000 --- a/branches/sdl2/src/boards/164.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * It seems that 162/163/164 mappers are the same mapper with just different - * mapper modes enabled or disabled in software or hardware, need more nanjing - * carts - */ - -#include "mapinc.h" - -static uint8 laststrobe, trigger; -static uint8 reg[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static writefunc pcmwrite; - -static void (*WSync)(void); - -static SFORMAT StateRegs[] = -{ - { &laststrobe, 1, "STB" }, - { &trigger, 1, "TRG" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, (reg[0] << 4) | (reg[1] & 0xF)); - setchr8(0); -} - -static void StateRestore(int version) { - WSync(); -} - -static DECLFR(ReadLow) { - switch (A & 0x7700) { - case 0x5100: return reg[2] | reg[0] | reg[1] | reg[3] ^ 0xff; break; - case 0x5500: - if (trigger) - return reg[2] | reg[1]; // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games - else - return 0; - } - return 4; -} - -static void M163HB(void) { - if (reg[1] & 0x80) { - if (scanline == 239) { - setchr4(0x0000, 0); - setchr4(0x1000, 0); - } else if (scanline == 127) { - setchr4(0x0000, 1); - setchr4(0x1000, 1); - } -/* - if(scanline>=127) // Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it - { - setchr4(0x0000,1); - setchr4(0x1000,1); - } - else - { - setchr4(0x0000,0); - setchr4(0x1000,0); - } -*/ - } -} - -static DECLFW(Write) { - switch (A & 0x7300) { - case 0x5100: reg[0] = V; WSync(); break; - case 0x5000: reg[1] = V; WSync(); break; - case 0x5300: reg[2] = V; break; - case 0x5200: reg[3] = V; WSync(); break; - } -} - -static void Power(void) { - memset(reg, 0, 8); - reg[1] = 0xFF; - SetWriteHandler(0x5000, 0x5FFF, Write); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -static void Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper164_Init(CartInfo *info) { - info->Power = Power; - info->Close = Close; - WSync = Sync; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -static DECLFW(Write2) { - if (A == 0x5101) { - if (laststrobe && !V) { - trigger ^= 1; - } - laststrobe = V; - } else if (A == 0x5100 && V == 6) //damn thoose protected games - setprg32(0x8000, 3); - else - switch (A & 0x7300) { - case 0x5200: reg[0] = V; WSync(); break; - case 0x5000: reg[1] = V; WSync(); if (!(reg[1] & 0x80) && (scanline < 128)) setchr8(0); /* setchr8(0); */ break; - case 0x5300: reg[2] = V; break; - case 0x5100: reg[3] = V; WSync(); break; - } -} - -static void Power2(void) { - memset(reg, 0, 8); - laststrobe = 1; - pcmwrite = GetWriteHandler(0x4011); - SetReadHandler(0x5000, 0x5FFF, ReadLow); - SetWriteHandler(0x5000, 0x5FFF, Write2); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -void Mapper163_Init(CartInfo *info) { - info->Power = Power2; - info->Close = Close; - WSync = Sync; - GameHBIRQHook = M163HB; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -static void Sync3(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - switch (reg[3] & 7) { - case 0: - case 2: setprg32(0x8000, (reg[0] & 0xc) | (reg[1] & 2) | ((reg[2] & 0xf) << 4)); break; - case 1: - case 3: setprg32(0x8000, (reg[0] & 0xc) | (reg[2] & 0xf) << 4); break; - case 4: - case 6: setprg32(0x8000, (reg[0] & 0xe) | ((reg[1] >> 1) & 1) | ((reg[2] & 0xf) << 4)); break; - case 5: - case 7: setprg32(0x8000, (reg[0] & 0xf) | ((reg[2] & 0xf) << 4)); break; - } -} - -static DECLFW(Write3) { -// FCEU_printf("bs %04x %02x\n",A,V); - reg[(A >> 8) & 3] = V; - WSync(); -} - -static void Power3(void) { - reg[0] = 3; - reg[1] = 0; - reg[2] = 0; - reg[3] = 7; - SetWriteHandler(0x5000, 0x5FFF, Write3); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - WSync(); -} - -void UNLFS304_Init(CartInfo *info) { - info->Power = Power3; - info->Close = Close; - WSync = Sync3; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/168.cpp b/branches/sdl2/src/boards/168.cpp deleted file mode 100644 index 5ec8e897..00000000 --- a/branches/sdl2/src/boards/168.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setchr4r(0x10, 0x0000, 0); - setchr4r(0x10, 0x1000, reg & 0x0f); - setprg16(0x8000, reg >> 6); - setprg16(0xc000, ~0); -} - -static DECLFW(M168Write) { - reg = V; - Sync(); -} - -static DECLFW(M168Dummy) { -} - -static void M168Power(void) { - reg = 0; - Sync(); - SetWriteHandler(0x4020, 0x7fff, M168Dummy); - SetWriteHandler(0xB000, 0xB000, M168Write); - SetWriteHandler(0xF000, 0xF000, M168Dummy); - SetWriteHandler(0xF080, 0xF080, M168Dummy); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void MNNNClose(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper168_Init(CartInfo *info) { - info->Power = M168Power; - info->Close = MNNNClose; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); - - CHRRAMSIZE = 8192 * 8; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); -} diff --git a/branches/sdl2/src/boards/170.cpp b/branches/sdl2/src/boards/170.cpp deleted file mode 100644 index 9a8a8e50..00000000 --- a/branches/sdl2/src/boards/170.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, 0); - setprg16(0xc000, ~0); - setchr8(0); -} - -static DECLFW(M170ProtW) { - reg = V << 1 & 0x80; -} - -static DECLFR(M170ProtR) { - return reg | (X.DB & 0x7F); -} - -static void M170Power(void) { - Sync(); - SetWriteHandler(0x6502, 0x6502, M170ProtW); - SetWriteHandler(0x7000, 0x7000, M170ProtW); - SetReadHandler(0x7001, 0x7001, M170ProtR); - SetReadHandler(0x7777, 0x7777, M170ProtR); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper170_Init(CartInfo *info) { - info->Power = M170Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/175.cpp b/branches/sdl2/src/boards/175.cpp deleted file mode 100644 index 82786074..00000000 --- a/branches/sdl2/src/boards/175.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, delay, mirr; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setchr8(reg); - if (!delay) { - setprg16(0x8000, reg); - setprg8(0xC000, reg << 1); - } - setprg8(0xE000, (reg << 1) + 1); - setmirror(((mirr & 4) >> 2) ^ 1); -} - -static DECLFW(M175Write1) { - mirr = V; - delay = 1; - Sync(); -} - -static DECLFW(M175Write2) { - reg = V & 0x0F; - delay = 1; - Sync(); -} - -static DECLFR(M175Read) { - if (A == 0xFFFC) { - delay = 0; - Sync(); - } - return CartBR(A); -} - -static void M175Power(void) { - reg = mirr = delay = 0; - SetReadHandler(0x8000, 0xFFFF, M175Read); - SetWriteHandler(0x8000, 0x8000, M175Write1); - SetWriteHandler(0xA000, 0xA000, M175Write2); - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper175_Init(CartInfo *info) { - info->Power = M175Power; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/176.cpp b/branches/sdl2/src/boards/176.cpp deleted file mode 100644 index 37309eb3..00000000 --- a/branches/sdl2/src/boards/176.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * Copyright (C) 2012 FCEUX team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -extern uint32 ROM_size; - -static uint8 prg[4], chr, sbw, we_sram; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[]= -{ - {prg, 4, "PRG"}, - {&chr, 1, "CHR"}, - {&sbw, 1, "SBW"}, - {0} -}; - -static void Sync(void) -{ - setprg8r(0x10,0x6000,0); - setprg8(0x8000,prg[0]); - setprg8(0xA000,prg[1]); - setprg8(0xC000,prg[2]); - setprg8(0xE000,prg[3]); - - setchr8(chr); -} - -static DECLFW(M176Write_5001) -{ - printf("%04X = $%02X\n",A,V); - if(sbw) - { - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - } - Sync(); -} - -static DECLFW(M176Write_5010) -{ - printf("%04X = $%02X\n",A,V); - if(V == 0x24) sbw = 1; - Sync(); -} - -static DECLFW(M176Write_5011) -{ - printf("%04X = $%02X\n",A,V); - V >>= 1; - if(sbw) - { - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - } - Sync(); -} - -static DECLFW(M176Write_5FF1) -{ - printf("%04X = $%02X\n",A,V); - V >>= 1; - prg[0] = V*4; - prg[1] = V*4+1; - prg[2] = V*4+2; - prg[3] = V*4+3; - Sync(); -} - -static DECLFW(M176Write_5FF2) -{ - printf("%04X = $%02X\n",A,V); - chr = V; - Sync(); -} - -static DECLFW(M176Write_A001) -{ - we_sram = V & 0x03; -} - -static DECLFW(M176Write_WriteSRAM) -{ -// if(we_sram) - CartBW(A,V); -} - -static void M176Power(void) -{ - SetReadHandler(0x6000,0x7fff,CartBR); - SetWriteHandler(0x6000,0x7fff,M176Write_WriteSRAM); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0xA001,0xA001,M176Write_A001); - SetWriteHandler(0x5001,0x5001,M176Write_5001); - SetWriteHandler(0x5010,0x5010,M176Write_5010); - SetWriteHandler(0x5011,0x5011,M176Write_5011); - SetWriteHandler(0x5ff1,0x5ff1,M176Write_5FF1); - SetWriteHandler(0x5ff2,0x5ff2,M176Write_5FF2); - - we_sram = 0; - sbw = 0; - prg[0] = 0; - prg[1] = 1; - prg[2] = (ROM_size-2)&63; - prg[3] = (ROM_size-1)&63; - Sync(); -} - - -static void M176Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper176_Init(CartInfo *info) -{ - info->Power=M176Power; - info->Close=M176Close; - - GameStateRestore=StateRestore; - - WRAMSIZE=8192; - WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/177.cpp b/branches/sdl2/src/boards/177.cpp deleted file mode 100644 index 04fd9c84..00000000 --- a/branches/sdl2/src/boards/177.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, reg & 0x1f); - setmirror(((reg & 0x20) >> 5) ^ 1); -} - -static DECLFW(M177Write) { - reg = V; - Sync(); -} - -static void M177Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M177Write); -} - -static void M177Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper177_Init(CartInfo *info) { - info->Power = M177Power; - info->Close = M177Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/178.cpp b/branches/sdl2/src/boards/178.cpp deleted file mode 100644 index cfd0392d..00000000 --- a/branches/sdl2/src/boards/178.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2013 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * DSOUNDV1/FL-TR8MA boards (32K WRAM, 8/16M), 178 mapper boards (8K WRAM, 4/8M) - * Various Education Cartridges - * - */ - -#include "mapinc.h" - -static uint8 reg[4]; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -// SND Registers -static uint8 pcm_enable = 0; -static int16 pcm_latch = 0x3F6, pcm_clock = 0x3F6; -static writefunc pcmwrite; - -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { 0 } -}; - -static int16 step_size[49] = { - 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, - 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, - 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, - 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552 -}; //49 items -static int32 step_adj[16] = { -1, -1, -1, -1, 2, 5, 7, 9, -1, -1, -1, -1, 2, 5, 7, 9 }; - -//decode stuff -static int32 jedi_table[16 * 49]; -static int32 acc = 0; //ADPCM accumulator, initial condition must be 0 -static int32 decstep = 0; //ADPCM decoding step, initial condition must be 0 - -static void jedi_table_init() { - int step, nib; - - for (step = 0; step < 49; step++) { - for (nib = 0; nib < 16; nib++) { - int value = (2 * (nib & 0x07) + 1) * step_size[step] / 8; - jedi_table[step * 16 + nib] = ((nib & 0x08) != 0) ? -value : value; - } - } -} - -static uint8 decode(uint8 code) { - acc += jedi_table[decstep + code]; - if ((acc & ~0x7ff) != 0) // acc is > 2047 - acc |= ~0xfff; - else acc &= 0xfff; - decstep += step_adj[code & 7] * 16; - if (decstep < 0) decstep = 0; - if (decstep > 48 * 16) decstep = 48 * 16; - return (acc >> 8) & 0xff; -} - -static void Sync(void) { - uint32 sbank = reg[1] & 0x7; - uint32 bbank = reg[2]; - setchr8(0); - setprg8r(0x10, 0x6000, reg[3] & 3); - if (reg[0] & 2) { // UNROM mode - setprg16(0x8000, (bbank << 3) | sbank); - if (reg[0] & 4) - setprg16(0xC000, (bbank << 3) | 6 | (reg[1] & 1)); - else - setprg16(0xC000, (bbank << 3) | 7); - } else { // NROM mode - uint32 bank = (bbank << 3) | sbank; - if (reg[0] & 4) { - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } else - setprg32(0x8000, bank >> 1); - } - setmirror((reg[0] & 1) ^ 1); -} - -static DECLFW(M178Write) { - reg[A & 3] = V; -// FCEU_printf("cmd %04x:%02x\n", A, V); - Sync(); -} - -static DECLFW(M178WriteSnd) { - if (A == 0x5800) { - if (V & 0xF0) { - pcm_enable = 1; -// pcmwrite(0x4011, (V & 0xF) << 3); - pcmwrite(0x4011, decode(V & 0xf)); - } else - pcm_enable = 0; - } else - FCEU_printf("misc %04x:%02x\n", A, V); -} - -static DECLFR(M178ReadSnd) { - if (A == 0x5800) - return (X.DB & 0xBF) | ((pcm_enable ^ 1) << 6); - else - return X.DB; -} - -static void M178Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = 0; - Sync(); - pcmwrite = GetWriteHandler(0x4011); - SetWriteHandler(0x4800, 0x4fff, M178Write); - SetWriteHandler(0x5800, 0x5fff, M178WriteSnd); - SetReadHandler(0x5800, 0x5fff, M178ReadSnd); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xffff, CartBR); -} - -static void M178SndClk(int a) { - if (pcm_enable) { - pcm_latch -= a; - if (pcm_latch <= 0) { - pcm_latch += pcm_clock; - pcm_enable = 0; - } - } -} - -static void M178Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper178_Init(CartInfo *info) { - info->Power = M178Power; - info->Close = M178Close; - GameStateRestore = StateRestore; - MapIRQHook = M178SndClk; - - jedi_table_init(); - - WRAMSIZE = 32768; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/18.cpp b/branches/sdl2/src/boards/18.cpp deleted file mode 100644 index dcec0dc1..00000000 --- a/branches/sdl2/src/boards/18.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[4], creg[8]; -static uint8 IRQa, mirr; -static int32 IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - if (mirr & 2) - setmirror(MI_0); - else - setmirror(mirr & 1); -} - -static DECLFW(M18WriteIRQ) { - switch (A & 0xF003) { - case 0xE000: IRQLatch &= 0xFFF0; IRQLatch |= (V & 0x0f) << 0x0; break; - case 0xE001: IRQLatch &= 0xFF0F; IRQLatch |= (V & 0x0f) << 0x4; break; - case 0xE002: IRQLatch &= 0xF0FF; IRQLatch |= (V & 0x0f) << 0x8; break; - case 0xE003: IRQLatch &= 0x0FFF; IRQLatch |= (V & 0x0f) << 0xC; break; - case 0xF000: IRQCount = IRQLatch; break; - case 0xF001: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF002: mirr = V & 3; Sync(); break; - } -} - -static DECLFW(M18WritePrg) { - uint32 i = ((A >> 1) & 1) | ((A - 0x8000) >> 11); - preg[i] &= (0xF0) >> ((A & 1) << 2); - preg[i] |= (V & 0xF) << ((A & 1) << 2); - Sync(); -} - -static DECLFW(M18WriteChr) { - uint32 i = ((A >> 1) & 1) | ((A - 0xA000) >> 11); - creg[i] &= (0xF0) >> ((A & 1) << 2); - creg[i] |= (V & 0xF) << ((A & 1) << 2); - Sync(); -} - -static void M18Power(void) { - IRQa = 0; - preg[0] = 0; - preg[1] = 1; - preg[2] = ~1; - preg[3] = ~0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0x9FFF, M18WritePrg); - SetWriteHandler(0xA000, 0xDFFF, M18WriteChr); - SetWriteHandler(0xE000, 0xFFFF, M18WriteIRQ); -} - -static void M18IRQHook(int a) { - if (IRQa && IRQCount) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = 0; - IRQa = 0; - } - } -} - -static void M18Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper18_Init(CartInfo *info) { - info->Power = M18Power; - info->Close = M18Close; - MapIRQHook = M18IRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/183.cpp b/branches/sdl2/src/boards/183.cpp deleted file mode 100644 index 9ba8c2c4..00000000 --- a/branches/sdl2/src/boards/183.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Gimmick Bootleg (VRC4 mapper) - */ - -#include "mapinc.h" - -static uint8 prg[4], chr[8], mirr; -static uint8 IRQCount; -static uint8 IRQPre; -static uint8 IRQa; - -static SFORMAT StateRegs[] = -{ - { prg, 4, "PRG" }, - { chr, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQPre, 1, "IRQP" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static void SyncPrg(void) { - setprg8(0x6000, prg[3]); - setprg8(0x8000, prg[0]); - setprg8(0xA000, prg[1]); - setprg8(0xC000, prg[2]); - setprg8(0xE000, ~0); -} - -static void SyncMirr(void) { - switch (mirr) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static void SyncChr(void) { - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); -} - -static void StateRestore(int version) { - SyncPrg(); - SyncChr(); - SyncMirr(); -} - -static DECLFW(M183Write) { - if ((A & 0xF800) == 0x6800) { - prg[3] = A & 0x3F; - SyncPrg(); - } else if (((A & 0xF80C) >= 0xB000) && ((A & 0xF80C) <= 0xE00C)) { - int index = (((A >> 11) - 6) | (A >> 3)) & 7; - chr[index] = (chr[index] & (0xF0 >> (A & 4))) | ((V & 0x0F) << (A & 4)); - SyncChr(); - } else switch (A & 0xF80C) { - case 0x8800: prg[0] = V; SyncPrg(); break; - case 0xA800: prg[1] = V; SyncPrg(); break; - case 0xA000: prg[2] = V; SyncPrg(); break; - case 0x9800: mirr = V & 3; SyncMirr(); break; - case 0xF000: IRQCount = ((IRQCount & 0xF0) | (V & 0xF)); break; - case 0xF004: IRQCount = ((IRQCount & 0x0F) | ((V & 0xF) << 4)); break; - case 0xF008: IRQa = V; if (!V) IRQPre = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF00C: IRQPre = 16; break; - } -} - -static void M183IRQCounter(void) { - if (IRQa) { - IRQCount++; - if ((IRQCount - IRQPre) == 238) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void M183Power(void) { - IRQPre = IRQCount = IRQa = 0; - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, M183Write); - SyncPrg(); - SyncChr(); -} - -void Mapper183_Init(CartInfo *info) { - info->Power = M183Power; - GameHBIRQHook = M183IRQCounter; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/185.cpp b/branches/sdl2/src/boards/185.cpp deleted file mode 100644 index 756864ee..00000000 --- a/branches/sdl2/src/boards/185.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 *DummyCHR = NULL; -static uint8 datareg; -static void (*Sync)(void); - - -static SFORMAT StateRegs[] = -{ - { &datareg, 1, "DREG" }, - { 0 } -}; - -// on off -//1 0x0F, 0xF0 - Bird Week -//2 0x33, 0x00 - B-Wings -//3 0x11, 0x00 - Mighty Bomb Jack -//4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen -//5 0xFF, 0x00 - Sansuu 3 Nen -//6 0x21, 0x13 - Spy vs Spy -//7 0x20, 0x21 - Seicross - -static void Sync185(void) { - // little dirty eh? ;_) - if ((datareg & 3) && (datareg != 0x13)) // 1, 2, 3, 4, 5, 6 - setchr8(0); - else - setchr8r(0x10, 0); -} - -static void Sync181(void) { - if (!(datareg & 1)) // 7 - setchr8(0); - else - setchr8r(0x10, 0); -} - -static DECLFW(MWrite) { - datareg = V; - Sync(); -} - -static void MPower(void) { - datareg = 0; - Sync(); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - SetWriteHandler(0x8000, 0xFFFF, MWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void MClose(void) { - if (DummyCHR) - FCEU_gfree(DummyCHR); - DummyCHR = NULL; -} - -static void MRestore(int version) { - Sync(); -} - -void Mapper185_Init(CartInfo *info) { - Sync = Sync185; - info->Power = MPower; - info->Close = MClose; - GameStateRestore = MRestore; - DummyCHR = (uint8*)FCEU_gmalloc(8192); - int x; - for (x = 0; x < 8192; x++) - DummyCHR[x] = 0xff; - SetupCartCHRMapping(0x10, DummyCHR, 8192, 0); - AddExState(StateRegs, ~0, 0, 0); -} - -void Mapper181_Init(CartInfo *info) { - Sync = Sync181; - info->Power = MPower; - info->Close = MClose; - GameStateRestore = MRestore; - DummyCHR = (uint8*)FCEU_gmalloc(8192); - int x; - for (x = 0; x < 8192; x++) - DummyCHR[x] = 0xff; - SetupCartCHRMapping(0x10, DummyCHR, 8192, 0); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/186.cpp b/branches/sdl2/src/boards/186.cpp deleted file mode 100644 index 137beaa9..00000000 --- a/branches/sdl2/src/boards/186.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Family Study Box by Fukutake Shoten - */ - -#include "mapinc.h" - -static uint8 SWRAM[3072]; -static uint8 *WRAM = NULL; -static uint8 regs[4]; - -static SFORMAT StateRegs[] = -{ - { regs, 4, "DREG" }, - { SWRAM, 3072, "SWRM" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, regs[0] >> 6); - setprg16(0x8000, regs[1]); - setprg16(0xc000, 0); -} - -static DECLFW(M186Write) { - if (A & 0x4203) regs[A & 3] = V; - Sync(); -} - -static DECLFR(M186Read) { - switch (A) { - case 0x4200: return 0x00; break; - case 0x4201: return 0x00; break; - case 0x4202: return 0x40; break; - case 0x4203: return 0x00; break; - } - return 0xFF; -} - -static DECLFR(ASWRAM) { - return(SWRAM[A - 0x4400]); -} -static DECLFW(BSWRAM) { - SWRAM[A - 0x4400] = V; -} - -static void M186Power(void) { - setchr8(0); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, CartBW); - SetReadHandler(0x4200, 0x43FF, M186Read); - SetWriteHandler(0x4200, 0x43FF, M186Write); - SetReadHandler(0x4400, 0x4FFF, ASWRAM); - SetWriteHandler(0x4400, 0x4FFF, BSWRAM); - regs[0] = regs[1] = regs[2] = regs[3]; - Sync(); -} - -static void M186Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M186Restore(int version) { - Sync(); -} - -void Mapper186_Init(CartInfo *info) { - info->Power = M186Power; - info->Close = M186Close; - GameStateRestore = M186Restore; - WRAM = (uint8*)FCEU_gmalloc(32768); - SetupCartPRGMapping(0x10, WRAM, 32768, 1); - AddExState(WRAM, 32768, 0, "WRAM"); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/187.cpp b/branches/sdl2/src/boards/187.cpp deleted file mode 100644 index 6e5baa2e..00000000 --- a/branches/sdl2/src/boards/187.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M187CW(uint32 A, uint8 V) { - if ((A & 0x1000) == ((MMC3_cmd & 0x80) << 5)) - setchr1(A, V | 0x100); - else - setchr1(A, V); -} - -static void M187PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { - uint8 bank = EXPREGS[0] & 0x1F; - if (EXPREGS[0] & 0x20) { - if (EXPREGS[0] & 0x40) - setprg32(0x8000, bank >> 2); - else - setprg32(0x8000, bank >> 1); // hacky hacky! two mappers in one! need real hw carts to test - } else { - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else - setprg8(A, V & 0x3F); -} - -static DECLFW(M187Write8000) { - EXPREGS[1] = 1; - MMC3_CMDWrite(A, V); -} - -static DECLFW(M187Write8001) { - if (EXPREGS[1]) - MMC3_CMDWrite(A, V); -} - -static DECLFW(M187WriteLo) { - if ((A == 0x5000) || (A == 0x6000)) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - } -} - -static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 }; -static DECLFR(M187Read) { - return prot_data[EXPREGS[1] & 3]; -} - -static void M187Power(void) { - EXPREGS[0] = EXPREGS[1] = 0; - GenMMC3Power(); - SetReadHandler(0x5000, 0x5FFF, M187Read); - SetWriteHandler(0x5000, 0x6FFF, M187WriteLo); - SetWriteHandler(0x8000, 0x8000, M187Write8000); - SetWriteHandler(0x8001, 0x8001, M187Write8001); -} - -void Mapper187_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M187PW; - cwrap = M187CW; - info->Power = M187Power; - AddExState(EXPREGS, 3, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/189.cpp b/branches/sdl2/src/boards/189.cpp deleted file mode 100644 index fb60b1b8..00000000 --- a/branches/sdl2/src/boards/189.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M189PW(uint32 A, uint8 V) { - setprg32(0x8000, EXPREGS[0] & 7); -} - -static DECLFW(M189Write) { - EXPREGS[0] = V | (V >> 4); //actually, there is a two versions of 189 mapper with hi or lo bits bankswitching. - FixMMC3PRG(MMC3_cmd); -} - -static void M189Power(void) { - EXPREGS[0] = EXPREGS[1] = 0; - GenMMC3Power(); - SetWriteHandler(0x4120, 0x7FFF, M189Write); -} - -void Mapper189_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M189PW; - info->Power = M189Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/193.cpp b/branches/sdl2/src/boards/193.cpp deleted file mode 100644 index 12e96a16..00000000 --- a/branches/sdl2/src/boards/193.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd, bank; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { &mirror, 1, "MIRR" }, - { &bank, 1, "BANK" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirror ^ 1); - setprg8(0x8000, reg[3]); - setprg8(0xA000, 0xD); - setprg8(0xC000, 0xE); - setprg8(0xE000, 0xF); - setchr4(0x0000, reg[0] >> 2); - setchr2(0x1000, reg[1] >> 1); - setchr2(0x1800, reg[2] >> 1); -} - -static DECLFW(M193Write) { - reg[A & 3] = V; - Sync(); -} - -static void M193Power(void) { - bank = 0; - Sync(); - SetWriteHandler(0x6000, 0x6003, M193Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, CartBW); -} - -static void M193Reset(void) { -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper193_Init(CartInfo *info) { - info->Reset = M193Reset; - info->Power = M193Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/199.cpp b/branches/sdl2/src/boards/199.cpp deleted file mode 100644 index 2a8ad051..00000000 --- a/branches/sdl2/src/boards/199.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Dragon Ball Z 2 - Gekishin Freeza! (C) - * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) - * San Guo Zhi 2 (C) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static void M199PW(uint32 A, uint8 V) { - setprg8(A, V); - setprg8(0xC000, EXPREGS[0]); - setprg8(0xE000, EXPREGS[1]); -} - -static void M199CW(uint32 A, uint8 V) { - setchr1r((V < 8) ? 0x10 : 0x00, A, V); - setchr1r((DRegBuf[0] < 8) ? 0x10 : 0x00, 0x0000, DRegBuf[0]); - setchr1r((EXPREGS[2] < 8) ? 0x10 : 0x00, 0x0400, EXPREGS[2]); - setchr1r((DRegBuf[1] < 8) ? 0x10 : 0x00, 0x0800, DRegBuf[1]); - setchr1r((EXPREGS[3] < 8) ? 0x10 : 0x00, 0x0c00, EXPREGS[3]); -} - -static void M199MW(uint8 V) { -// FCEU_printf("%02x\n",V); - switch (V & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M199Write) { - if ((A == 0x8001) && (MMC3_cmd & 8)) { - EXPREGS[MMC3_cmd & 3] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - if (A < 0xC000) - MMC3_CMDWrite(A, V); - else - MMC3_IRQWrite(A, V); -} - -static void M199Power(void) { - EXPREGS[0] = ~1; - EXPREGS[1] = ~0; - EXPREGS[2] = 1; - EXPREGS[3] = 3; - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, M199Write); -} - -static void M199Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -void Mapper199_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M199CW; - pwrap = M199PW; - mwrap = M199MW; - info->Power = M199Power; - info->Close = M199Close; - - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); - - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/206.cpp b/branches/sdl2/src/boards/206.cpp deleted file mode 100644 index d013a8f1..00000000 --- a/branches/sdl2/src/boards/206.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmd; -static uint8 DRegs[8]; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { DRegs, 8, "DREG" }, - { 0 } -}; - -static void Sync(void) { - setchr2(0x0000, DRegs[0]); - setchr2(0x0800, DRegs[1]); - int x; - for (x = 0; x < 4; x++) - setchr1(0x1000 + (x << 10), DRegs[2 + x]); - setprg8(0x8000, DRegs[6]); - setprg8(0xa000, DRegs[7]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); -} - -static void StateRestore(int version) { - Sync(); -} - -static DECLFW(M206Write) { - switch (A & 0x8001) { - case 0x8000: cmd = V & 0x07; break; - case 0x8001: - if (cmd <= 0x05) - V &= 0x3F; - else - V &= 0x0F; - if (cmd <= 0x01) V >>= 1; - DRegs[cmd & 0x07] = V; - Sync(); - break; - } -} - -static void M206Power(void) { - cmd = 0; - DRegs[6] = 0; - DRegs[7] = 1; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M206Write); -} - - -void Mapper206_Init(CartInfo *info) { - info->Power = M206Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/208.cpp b/branches/sdl2/src/boards/208.cpp deleted file mode 100644 index d581b1e8..00000000 --- a/branches/sdl2/src/boards/208.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 lut[256] = { - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static void M208PW(uint32 A, uint8 V) { - setprg32(0x8000, EXPREGS[5]); -} - -static DECLFW(M208Write) { - EXPREGS[5] = (V & 0x1) | ((V >> 3) & 0x2); - FixMMC3PRG(MMC3_cmd); -} - -static DECLFW(M208ProtWrite) { - if (A <= 0x57FF) - EXPREGS[4] = V; - else - EXPREGS[(A & 0x03)] = V ^ lut[EXPREGS[4]]; -} - -static DECLFR(M208ProtRead) { - return(EXPREGS[(A & 0x3)]); -} - -static void M208Power(void) { - EXPREGS[5] = 3; - GenMMC3Power(); - SetWriteHandler(0x4800, 0x4fff, M208Write); - SetWriteHandler(0x6800, 0x6fff, M208Write); - SetWriteHandler(0x5000, 0x5fff, M208ProtWrite); - SetReadHandler(0x5800, 0x5fff, M208ProtRead); - SetReadHandler(0x8000, 0xffff, CartBR); -} - -void Mapper208_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 0, 0); - pwrap = M208PW; - info->Power = M208Power; - AddExState(EXPREGS, 6, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/222.cpp b/branches/sdl2/src/boards/222.cpp deleted file mode 100644 index 0db78c7b..00000000 --- a/branches/sdl2/src/boards/222.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * (VRC4 mapper) - * - */ - -#include "mapinc.h" - -static uint8 IRQCount; -static uint8 IRQa; -static uint8 prg_reg[2]; -static uint8 chr_reg[8]; -static uint8 mirr; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 1, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { prg_reg, 2, "PRG" }, - { chr_reg, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void M222IRQ(void) { - if (IRQa) { - IRQCount++; - if (IRQCount >= 238) { - X6502_IRQBegin(FCEU_IQEXT); -// IRQa=0; - } - } -} - -static void Sync(void) { - setprg8(0x8000, prg_reg[0]); - setprg8(0xA000, prg_reg[1]); - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chr_reg[i]); - setmirror(mirr ^ 1); -} - -static DECLFW(M222Write) { - switch (A & 0xF003) { - case 0x8000: prg_reg[0] = V; break; - case 0x9000: mirr = V & 1; break; - case 0xA000: prg_reg[1] = V; break; - case 0xB000: chr_reg[0] = V; break; - case 0xB002: chr_reg[1] = V; break; - case 0xC000: chr_reg[2] = V; break; - case 0xC002: chr_reg[3] = V; break; - case 0xD000: chr_reg[4] = V; break; - case 0xD002: chr_reg[5] = V; break; - case 0xE000: chr_reg[6] = V; break; - case 0xE002: chr_reg[7] = V; break; -// case 0xF000: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break; -// case 0xF001: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQCount=V; break; -// case 0xF002: FCEU_printf("%04x:%02x %d\n",A,V,scanline); break; -// case 0xD001: IRQa=V; X6502_IRQEnd(FCEU_IQEXT); FCEU_printf("%04x:%02x %d\n",A,V,scanline); break; -// case 0xC001: IRQPre=16; FCEU_printf("%04x:%02x %d\n",A,V,scanline); break; - case 0xF000: IRQa = IRQCount = V; if (scanline < 240) IRQCount -= 8; else IRQCount += 4; X6502_IRQEnd(FCEU_IQEXT); break; - } - Sync(); -} - -static void M222Power(void) { - setprg16(0xC000, ~0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M222Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper222_Init(CartInfo *info) { - info->Power = M222Power; - GameHBIRQHook = M222IRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/228.cpp b/branches/sdl2/src/boards/228.cpp deleted file mode 100644 index e64c6ace..00000000 --- a/branches/sdl2/src/boards/228.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 mram[4], vreg; -static uint16 areg; - -static SFORMAT StateRegs[] = -{ - { mram, 4, "MRAM" }, - { &areg, 2, "AREG" }, - { &vreg, 1, "VREG" }, - { 0 } -}; - -static void Sync(void) { - uint32 prgl, prgh, page = (areg >> 7) & 0x3F; - if ((page & 0x30) == 0x30) - page -= 0x10; - prgl = prgh = (page << 1) + (((areg >> 6) & 1) & ((areg >> 5) & 1)); - prgh += ((areg >> 5) & 1) ^ 1; - - setmirror(((areg >> 13) & 1) ^ 1); - setprg16(0x8000,prgl); - setprg16(0xc000,prgh); - setchr8(((vreg & 0x3) | ((areg & 0xF) << 2))); -} - -static DECLFW(M228RamWrite) { - mram[A & 3] = V & 0x0F; -} - -static DECLFR(M228RamRead) { - return mram[A & 3]; -} - -static DECLFW(M228Write) { - areg = A; - vreg = V; - Sync(); -} - -static void M228Reset(void) { - areg = 0x8000; - vreg = 0; - memset(mram, 0, sizeof(mram)); - Sync(); -} - -static void M228Power(void) { - M228Reset(); - SetReadHandler(0x5000,0x5FFF,M228RamRead); - SetWriteHandler(0x5000,0x5FFF,M228RamWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M228Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper228_Init(CartInfo *info) { - info->Reset = M228Reset; - info->Power = M228Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/230.cpp b/branches/sdl2/src/boards/230.cpp deleted file mode 100644 index 0da975dd..00000000 --- a/branches/sdl2/src/boards/230.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * Copyright (C) 2009 qeed - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * 22 + Contra Reset based custom mapper... - * - */ - -#include "mapinc.h" - -static uint8 latche, reset; -static SFORMAT StateRegs[] = -{ - { &reset, 1, "RST" }, - { &latche, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - if(reset) { - setprg16(0x8000, latche & 7); - setprg16(0xC000, 7); - setmirror(MI_V); - } else { - uint32 bank = (latche & 0x1F) + 8; - if (latche & 0x20) { - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } else - setprg32(0x8000, bank >> 1); - setmirror((latche >> 6) & 1); - } - setchr8(0); -} - -static DECLFW(M230Write) { - latche = V; - Sync(); -} - -static void M230Reset(void) { - reset ^= 1; - Sync(); -} - -static void M230Power(void) { - latche = reset = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M230Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper230_Init(CartInfo *info) { - info->Power = M230Power; - info->Reset = M230Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/232.cpp b/branches/sdl2/src/boards/232.cpp deleted file mode 100644 index 86bb0d04..00000000 --- a/branches/sdl2/src/boards/232.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 bank, preg; -static SFORMAT StateRegs[] = -{ - { &bank, 1, "BANK" }, - { &preg, 1, "PREG" }, - { 0 } -}; - -static void Sync(void) { -// uint32 bbank = (bank & 0x18) >> 1; - uint32 bbank = ((bank & 0x10) >> 2) | (bank & 8); // some dumps have bbanks swapped, if swap commands, - // then all roms can be played, but with some swapped - // games in menu. if not, some dumps are unplayable - // make hard dump for both cart types to check - setprg16(0x8000, bbank | (preg & 3)); - setprg16(0xC000, bbank | 3); - setchr8(0); -} - -static DECLFW(M232WriteBank) { - bank = V; - Sync(); -} - -static DECLFW(M232WritePreg) { - preg = V; - Sync(); -} - -static void M232Power(void) { - bank = preg = 0; - Sync(); - SetWriteHandler(0x8000, 0xBFFF, M232WriteBank); - SetWriteHandler(0xC000, 0xFFFF, M232WritePreg); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper232_Init(CartInfo *info) { - info->Power = M232Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/234.cpp b/branches/sdl2/src/boards/234.cpp deleted file mode 100644 index ef471238..00000000 --- a/branches/sdl2/src/boards/234.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 bank, preg; -static SFORMAT StateRegs[] = -{ - { &bank, 1, "BANK" }, - { &preg, 1, "PREG" }, - { 0 } -}; - -static void Sync(void) { - if (bank & 0x40) { - setprg32(0x8000, (bank & 0xE) | (preg & 1)); - setchr8(((bank & 0xE) << 2) | ((preg >> 4) & 7)); - } else { - setprg32(0x8000, bank & 0xF); - setchr8(((bank & 0xF) << 2) | ((preg >> 4) & 3)); - } - setmirror((bank >> 7) ^ 1); -} - -DECLFR(M234ReadBank) { - uint8 r = CartBR(A); - if (!bank) { - bank = r; - Sync(); - } - return r; -} - -DECLFR(M234ReadPreg) { - uint8 r = CartBR(A); - preg = r; - Sync(); - return r; -} - -static void M234Reset(void) { - bank = preg = 0; - Sync(); -} - -static void M234Power(void) { - M234Reset(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0xFF80, 0xFF9F, M234ReadBank); - SetReadHandler(0xFFE8, 0xFFF7, M234ReadPreg); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper234_Init(CartInfo *info) { - info->Power = M234Power; - info->Reset = M234Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/235.cpp b/branches/sdl2/src/boards/235.cpp deleted file mode 100644 index 98ce11bb..00000000 --- a/branches/sdl2/src/boards/235.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint16 cmdreg; -static SFORMAT StateRegs[] = -{ - { &cmdreg, 2, "CREG" }, - { 0 } -}; - -static void Sync(void) { - if (cmdreg & 0x400) - setmirror(MI_0); - else - setmirror(((cmdreg >> 13) & 1) ^ 1); - if (cmdreg & 0x800) { - setprg16(0x8000, ((cmdreg & 0x300) >> 3) | ((cmdreg & 0x1F) << 1) | ((cmdreg >> 12) & 1)); - setprg16(0xC000, ((cmdreg & 0x300) >> 3) | ((cmdreg & 0x1F) << 1) | ((cmdreg >> 12) & 1)); - } else - setprg32(0x8000, ((cmdreg & 0x300) >> 4) | (cmdreg & 0x1F)); -} - -static DECLFW(M235Write) { - cmdreg = A; - Sync(); -} - -static void M235Power(void) { - setchr8(0); - SetWriteHandler(0x8000, 0xFFFF, M235Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - cmdreg = 0; - Sync(); -} - -static void M235Restore(int version) { - Sync(); -} - -void Mapper235_Init(CartInfo *info) { - info->Power = M235Power; - GameStateRestore = M235Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/244.cpp b/branches/sdl2/src/boards/244.cpp deleted file mode 100644 index 67c33694..00000000 --- a/branches/sdl2/src/boards/244.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg, creg; -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &creg, 1, "CREG" }, - { 0 } -}; - -static uint8 prg_perm[4][4] = { - { 0, 1, 2, 3, }, - { 3, 2, 1, 0, }, - { 0, 2, 1, 3, }, - { 3, 1, 2, 0, }, -}; - -static uint8 chr_perm[8][8] = { - { 0, 1, 2, 3, 4, 5, 6, 7, }, - { 0, 2, 1, 3, 4, 6, 5, 7, }, - { 0, 1, 4, 5, 2, 3, 6, 7, }, - { 0, 4, 1, 5, 2, 6, 3, 7, }, - { 0, 4, 2, 6, 1, 5, 3, 7, }, - { 0, 2, 4, 6, 1, 3, 5, 7, }, - { 7, 6, 5, 4, 3, 2, 1, 0, }, - { 7, 6, 5, 4, 3, 2, 1, 0, }, -}; - -static void Sync(void) { - setprg32(0x8000, preg); - setchr8(creg); -} - -static DECLFW(M244Write) { - if (V & 8) - creg = chr_perm[(V >> 4) & 7][V & 7]; - else - preg = prg_perm[(V >> 4) & 3][V & 3]; - Sync(); -} - -static void M244Power(void) { - preg = creg = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M244Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper244_Init(CartInfo *info) { - info->Power = M244Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/246.cpp b/branches/sdl2/src/boards/246.cpp deleted file mode 100644 index 2c46acc7..00000000 --- a/branches/sdl2/src/boards/246.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 regs[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg2r(0x10, 0x6800, 0); - setprg8(0x8000, regs[0]); - setprg8(0xA000, regs[1]); - setprg8(0xC000, regs[2]); - setprg8(0xE000, regs[3]); - setchr2(0x0000, regs[4]); - setchr2(0x0800, regs[5]); - setchr2(0x1000, regs[6]); - setchr2(0x1800, regs[7]); -} - -static DECLFW(M246Write) { - regs[A & 7] = V; - Sync(); -} - -static void M246Power(void) { - regs[0] = regs[1] = regs[2] = regs[3] = ~0; - Sync(); - SetWriteHandler(0x6000, 0x67FF, M246Write); - SetReadHandler(0x6800, 0x6FFF, CartBR); - SetWriteHandler(0x6800, 0x6FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void M246Close(void) -{ - if(WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper246_Init(CartInfo *info) { - info->Power = M246Power; - info->Close = M246Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 2048; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/252.cpp b/branches/sdl2/src/boards/252.cpp deleted file mode 100644 index 2c4b24b1..00000000 --- a/branches/sdl2/src/boards/252.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 creg[8], preg[2]; -static int32 IRQa, IRQCount, IRQClock, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { creg, 8, "CREG" }, - { preg, 2, "PREG" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { &IRQClock, 4, "IRQK" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xa000, preg[1]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) - if ((creg[i] == 6) || (creg[i] == 7)) - setchr1r(0x10, i << 10, creg[i] & 1); - else - setchr1(i << 10, creg[i]); -} - -static DECLFW(M252Write) { - if ((A >= 0xB000) && (A <= 0xEFFF)) { - uint8 ind = ((((A & 8) | (A >> 8)) >> 3) + 2) & 7; - uint8 sar = A & 4; - creg[ind] = (creg[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - Sync(); - } else - switch (A & 0xF00C) { - case 0x8000: - case 0x8004: - case 0x8008: - case 0x800C: preg[0] = V; Sync(); break; - case 0xA000: - case 0xA004: - case 0xA008: - case 0xA00C: preg[1] = V; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF004: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF008: X6502_IRQEnd(FCEU_IQEXT); IRQClock = 0; IRQCount = IRQLatch; IRQa = V & 2; break; - } -} - -static void M252Power(void) { - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M252Write); -} - -static void M252IRQ(int a) { - #define LCYCS 341 - if (IRQa) { - IRQClock += a * 3; - if (IRQClock >= LCYCS) { - while (IRQClock >= LCYCS) { - IRQClock -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void M252Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - if (CHRRAM) - FCEU_gfree(CHRRAM); - WRAM = CHRRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper252_Init(CartInfo *info) { - info->Power = M252Power; - info->Close = M252Close; - MapIRQHook = M252IRQ; - - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/253.cpp b/branches/sdl2/src/boards/253.cpp deleted file mode 100644 index e79662a7..00000000 --- a/branches/sdl2/src/boards/253.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chrlo[8], chrhi[8], prg[2], mirr, vlock; -static int32 IRQa, IRQCount, IRQLatch, IRQClock; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { chrlo, 8, "CHRL" }, - { chrhi, 8, "CHRH" }, - { prg, 2, "PRGR" }, - { &mirr, 1, "MIRR" }, - { &vlock, 1, "VLCK" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { &IRQClock, 4, "IRQK" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, prg[0]); - setprg8(0xa000, prg[1]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) { - uint32 chr = chrlo[i] | (chrhi[i] << 8); - if (((chrlo[i] == 4) || (chrlo[i] == 5)) && !vlock) - setchr1r(0x10, i << 10, chr & 1); - else - setchr1(i << 10, chr); - } - switch (mirr) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M253Write) { - if ((A >= 0xB000) && (A <= 0xE00C)) { - uint8 ind = ((((A & 8) | (A >> 8)) >> 3) + 2) & 7; - uint8 sar = A & 4; - uint8 clo = (chrlo[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - chrlo[ind] = clo; - if (ind == 0) { - if (clo == 0xc8) - vlock = 0; - else if (clo == 0x88) - vlock = 1; - } - if (sar) - chrhi[ind] = V >> 4; - Sync(); - } else - switch (A) { - case 0x8010: prg[0] = V; Sync(); break; - case 0xA010: prg[1] = V; Sync(); break; - case 0x9400: mirr = V & 3; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF004: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF008: X6502_IRQEnd(FCEU_IQEXT); IRQClock = 0; IRQCount = IRQLatch; IRQa = V & 2; break; - } -} - -static void M253Power(void) { - vlock = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M253Write); -} - -static void M253Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - if (CHRRAM) - FCEU_gfree(CHRRAM); - WRAM = CHRRAM = NULL; -} - -static void M253IRQ(int a) { - #define LCYCS 341 - if (IRQa) { - IRQClock += a * 3; - if (IRQClock >= LCYCS) { - while (IRQClock >= LCYCS) { - IRQClock -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper253_Init(CartInfo *info) { - info->Power = M253Power; - info->Close = M253Close; - MapIRQHook = M253IRQ; - GameStateRestore = StateRestore; - - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/28.cpp b/branches/sdl2/src/boards/28.cpp deleted file mode 100644 index c787b8c3..00000000 --- a/branches/sdl2/src/boards/28.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - Copyright (C) 2012 FCEUX team - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file 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 the this software. If not, see . -*/ - -#include "mapinc.h" - -// http://wiki.nesdev.com/w/index.php/INES_Mapper_028 - -//config -static int prg_mask_16k; - -// state -uint8 reg; -uint8 chr; -uint8 prg; -uint8 mode; -uint8 outer; - -void SyncMirror() -{ - switch (mode & 3) - { - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - } -} - -void Mirror(uint8 value) -{ - if ((mode & 2) == 0) - { - mode &= 0xfe; - mode |= value >> 4 & 1; - } - SyncMirror(); -} - - -static void Sync() -{ - int prglo; - int prghi; - - int outb = outer << 1; - //this can probably be rolled up, but i have no motivation to do so - //until it's been tested - switch (mode & 0x3c) - { - //32K modes - case 0x00: - case 0x04: - prglo = outb; - prghi = outb | 1; - break; - case 0x10: - case 0x14: - prglo = outb & ~2 | prg << 1 & 2; - prghi = outb & ~2 | prg << 1 & 2 | 1; - break; - case 0x20: - case 0x24: - prglo = outb & ~6 | prg << 1 & 6; - prghi = outb & ~6 | prg << 1 & 6 | 1; - break; - case 0x30: - case 0x34: - prglo = outb & ~14 | prg << 1 & 14; - prghi = outb & ~14 | prg << 1 & 14 | 1; - break; - //bottom fixed modes - case 0x08: - prglo = outb; - prghi = outb | prg & 1; - break; - case 0x18: - prglo = outb; - prghi = outb & ~2 | prg & 3; - break; - case 0x28: - prglo = outb; - prghi = outb & ~6 | prg & 7; - break; - case 0x38: - prglo = outb; - prghi = outb & ~14 | prg & 15; - break; - //top fixed modes - case 0x0c: - prglo = outb | prg & 1; - prghi = outb | 1; - break; - case 0x1c: - prglo = outb & ~2 | prg & 3; - prghi = outb | 1; - break; - case 0x2c: - prglo = outb & ~6 | prg & 7; - prghi = outb | 1; - break; - case 0x3c: - prglo = outb & ~14 | prg & 15; - prghi = outb | 1; - break; - } - prglo &= prg_mask_16k; - prghi &= prg_mask_16k; - - setprg16(0x8000, prglo); - setprg16(0xC000, prghi); - setchr8(chr); -} - -static DECLFW(WriteEXP) -{ - uint32 addr = A; - uint8 value = V; - reg = value & 0x81; -} - -static DECLFW(WritePRG) -{ - uint32 addr = A; - uint8 value = V; - switch (reg) - { - case 0x00: - chr = value & 3; - Mirror(value); - break; - case 0x01: - prg = value & 15; - Mirror(value); - Sync(); - break; - case 0x80: - mode = value & 63; - SyncMirror(); - Sync(); - break; - case 0x81: - outer = value & 63; - Sync(); - break; - } -} - - - -static void M28Reset(void) -{ - outer = 63; - prg = 15; - Sync(); -} - - -static void M28Power(void) -{ - prg_mask_16k = PRGsize[0] - 1; - - //EXP - SetWriteHandler(0x5000,0x5FFF,WriteEXP); - - //PRG - SetWriteHandler(0x8000,0xFFFF,WritePRG); - SetReadHandler(0x8000,0xFFFF,CartBR); - - //WRAM - SetReadHandler(0x6000,0x7FFF,CartBR); - SetWriteHandler(0x6000,0x7FFF,CartBW); - - M28Reset(); -} - -static void M28Close(void) -{ -} - -static SFORMAT StateRegs[]= -{ - {®, 1, "REG"}, - {&chr, 1, "CHR"}, - {&prg, 1, "PRG"}, - {&mode, 1, "MODE"}, - {&outer, 1, "OUTR"}, - {0} -}; - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper28_Init(CartInfo* info) -{ - info->Power=M28Power; - info->Reset=M28Reset; - info->Close=M28Close; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/32.cpp b/branches/sdl2/src/boards/32.cpp deleted file mode 100644 index 0c34402e..00000000 --- a/branches/sdl2/src/boards/32.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[2], creg[8], mirr; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - uint16 swap = ((mirr & 2) << 13); - setmirror((mirr & 1) ^ 1); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000 ^ swap, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000 ^ swap, ~1); - setprg8(0xE000, ~0); - uint8 i; - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); -} - -static DECLFW(M32Write0) { - preg[0] = V; - Sync(); -} - -static DECLFW(M32Write1) { - mirr = V; - Sync(); -} - -static DECLFW(M32Write2) { - preg[1] = V; - Sync(); -} - -static DECLFW(M32Write3) { - creg[A & 7] = V; - Sync(); -} - -static void M32Power(void) { - Sync(); - SetReadHandler(0x6000,0x7fff,CartBR); - SetWriteHandler(0x6000,0x7fff,CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x8FFF, M32Write0); - SetWriteHandler(0x9000, 0x9FFF, M32Write1); - SetWriteHandler(0xA000, 0xAFFF, M32Write2); - SetWriteHandler(0xB000, 0xBFFF, M32Write3); -} - -static void M32Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper32_Init(CartInfo *info) { - info->Power = M32Power; - info->Close = M32Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/33.cpp b/branches/sdl2/src/boards/33.cpp deleted file mode 100644 index daa6a773..00000000 --- a/branches/sdl2/src/boards/33.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 is48; -static uint8 regs[8], mirr; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "PREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirr); - setprg8(0x8000, regs[0]); - setprg8(0xA000, regs[1]); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - setchr2(0x0000, regs[2]); - setchr2(0x0800, regs[3]); - setchr1(0x1000, regs[4]); - setchr1(0x1400, regs[5]); - setchr1(0x1800, regs[6]); - setchr1(0x1C00, regs[7]); -} - -static DECLFW(M33Write) { - A &= 0xF003; - switch(A) { - case 0x8000: regs[0] = V & 0x3F; if(!is48) mirr = ((V >> 6) & 1) ^ 1; Sync(); break; - case 0x8001: regs[1] = V & 0x3F; Sync(); break; - case 0x8002: regs[2] = V; Sync(); break; - case 0x8003: regs[3] = V; Sync(); break; - case 0xA000: regs[4] = V; Sync(); break; - case 0xA001: regs[5] = V; Sync(); break; - case 0xA002: regs[6] = V; Sync(); break; - case 0xA003: regs[7] = V; Sync(); break; - } -} - -static DECLFW(M48Write) { - switch (A & 0xF003) { - case 0xC000: IRQLatch = V; break; - case 0xC001: IRQCount = IRQLatch; break; - case 0xC003: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xC002: IRQa = 1; break; - case 0xE000: mirr = ((V >> 6) & 1) ^ 1; Sync(); break; - } -} - -static void M33Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M33Write); -} - -static void M48Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, M33Write); - SetWriteHandler(0xC000, 0xFFFF, M48Write); -} - -static void M48IRQ(void) { - if (IRQa) { - IRQCount++; - if (IRQCount == 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper33_Init(CartInfo *info) { - is48 = 0; - info->Power = M33Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper48_Init(CartInfo *info) { - is48 = 1; - info->Power = M48Power; - GameHBIRQHook = M48IRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/34.cpp b/branches/sdl2/src/boards/34.cpp deleted file mode 100644 index 71f1b300..00000000 --- a/branches/sdl2/src/boards/34.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Many-in-one hacked mapper crap. - * - * Original BNROM is actually AxROM variations without mirroring control, - * and haven't SRAM on-board, so it must be removed from here - * - * Difficult banking is what NINA board doing, most hacks for 34 mapper are - * NINA hacks, so this is actually 34 mapper - * - */ - -#include "mapinc.h" - -static uint8 regs[3]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 3, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, regs[0]); - setchr4(0x0000, regs[1]); - setchr4(0x1000, regs[2]); -} - -static DECLFW(M34Write) { - if (A >= 0x8000) - regs[0] = V; - else - switch (A) { - case 0x7ffd: regs[0] = V; break; - case 0x7ffe: regs[1] = V; break; - case 0x7fff: regs[2] = V; break; - } - Sync(); -} - -static void M34Power(void) { - regs[0] = regs[1] = 0; - regs[2] = 1; - Sync(); - SetReadHandler(0x6000, 0x7ffc, CartBR); - SetWriteHandler(0x6000, 0x7ffc, CartBW); - SetReadHandler(0x8000, 0xffff, CartBR); - SetWriteHandler(0x7ffd, 0xffff, M34Write); -} - -static void M34Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper34_Init(CartInfo *info) { - info->Power = M34Power; - info->Close = M34Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/36.cpp b/branches/sdl2/src/boards/36.cpp deleted file mode 100644 index 209d777e..00000000 --- a/branches/sdl2/src/boards/36.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * TXC/Micro Genius simplified mapper - */ - -#include "mapinc.h" - -static uint8 latche; - -static SFORMAT StateRegs[] = -{ - { &latche, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xf); -} - -static DECLFW(M36Write) { - latche = V; - Sync(); -} - -static DECLFR(M36Read) { - return latche; // Need by Strike Wolf, being simplified mapper, this cart still uses some TCX mapper features andrely on it -} - -static void M36Power(void) { - latche = 0; - Sync(); - SetReadHandler(0x4100, 0x4100, M36Read); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFE, M36Write); // Actually, BUS conflict there preventing from triggering the wrong banks -} - -static void M36Restore(int version) { - Sync(); -} - -void Mapper36_Init(CartInfo *info) { - info->Power = M36Power; - GameStateRestore = M36Restore; - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/3d-block.cpp b/branches/sdl2/src/boards/3d-block.cpp deleted file mode 100644 index 2a8b62cb..00000000 --- a/branches/sdl2/src/boards/3d-block.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[4], IRQa; -static int16 IRQCount, IRQPause; - -static int16 Count = 0x0000; - -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, 0); - setchr8(0); -} - -//#define Count 0x1800 -#define Pause 0x010 - -static DECLFW(UNL3DBlockWrite) { - switch (A) { -//4800 32 -//4900 37 -//4a00 01 -//4e00 18 - case 0x4800: reg[0] = V; break; - case 0x4900: reg[1] = V; break; - case 0x4a00: reg[2] = V; break; - case 0x4e00: reg[3] = V; IRQCount = Count; IRQPause = Pause; IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -static void UNL3DBlockPower(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4800, 0x4E00, UNL3DBlockWrite); -} - -static void UNL3DBlockReset(void) { - Count += 0x10; - FCEU_printf("Count=%04x\n", Count); -} - -static void UNL3DBlockIRQHook(int a) { - if (IRQa) { - if (IRQCount > 0) { - IRQCount -= a; - } else { - if (IRQPause > 0) { - IRQPause -= a; - X6502_IRQBegin(FCEU_IQEXT); - } else { - IRQCount = Count; - IRQPause = Pause; - X6502_IRQEnd(FCEU_IQEXT); - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void UNL3DBlock_Init(CartInfo *info) { - info->Power = UNL3DBlockPower; - info->Reset = UNL3DBlockReset; - MapIRQHook = UNL3DBlockIRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/40.cpp b/branches/sdl2/src/boards/40.cpp deleted file mode 100644 index 5cae497d..00000000 --- a/branches/sdl2/src/boards/40.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg; -static uint32 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 4, "IRQC" }, - { &IRQa, 4, "IRQA" }, - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, ~1); - setprg8(0x8000, ~3); - setprg8(0xa000, ~2); - setprg8(0xc000, reg); - setprg8(0xe000, ~0); - setchr8(0); -} - -static DECLFW(M40Write) { - switch (A & 0xe000) { - case 0x8000: IRQa = 0; IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xa000: IRQa = 1; break; - case 0xe000: reg = V & 7; Sync(); break; - } -} - -static void M40Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0xffff, CartBR); - SetWriteHandler(0x8000, 0xffff, M40Write); -} - -static void M40Reset(void) { -} - -static void M40IRQHook(int a) { - if (IRQa) { - if (IRQCount < 4096) - IRQCount += a; - else{ - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper40_Init(CartInfo *info) { - info->Reset = M40Reset; - info->Power = M40Power; - MapIRQHook = M40IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/41.cpp b/branches/sdl2/src/boards/41.cpp deleted file mode 100644 index d0d90839..00000000 --- a/branches/sdl2/src/boards/41.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 mainreg, chrreg, mirror; - -static SFORMAT StateRegs[] = -{ - { &mainreg, 1, "MREG" }, - { &chrreg, 1, "CREG" }, - { &mirror, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, mainreg & 7); - setchr8(chrreg); - setmirror(mirror); -} - -static DECLFW(M41Write0) { - mainreg = A & 0xFF; - mirror = ((A >> 5) & 1) ^ 1; - chrreg = (chrreg & 3) | ((A >> 1) & 0xC); - Sync(); -} - -static DECLFW(M41Write1) { - if (mainreg & 0x4) { - chrreg = (chrreg & 0xC) | (A & 3); - Sync(); - } -} - -static void M41Power(void) { - mainreg = chrreg = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x67FF, M41Write0); - SetWriteHandler(0x8000, 0xFFFF, M41Write1); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper41_Init(CartInfo *info) { - info->Power = M41Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/411120-c.cpp b/branches/sdl2/src/boards/411120-c.cpp deleted file mode 100644 index ccc490e8..00000000 --- a/branches/sdl2/src/boards/411120-c.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2008 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// actually cart ID is 811120-C, sorry ;) K-3094 - another ID - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 reset_flag = 0; - -static void BMC411120CCW(uint32 A, uint8 V) { - setchr1(A, V | ((EXPREGS[0] & 3) << 7)); -} - -static void BMC411120CPW(uint32 A, uint8 V) { - if (EXPREGS[0] & (8 | reset_flag)) - setprg32(0x8000, ((EXPREGS[0] >> 4) & 3) | (0x0C)); - else - setprg8(A, (V & 0x0F) | ((EXPREGS[0] & 3) << 4)); -} - -static DECLFW(BMC411120CLoWrite) { - EXPREGS[0] = A; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void BMC411120CReset(void) { - EXPREGS[0] = 0; - reset_flag ^= 4; - MMC3RegReset(); -} - -static void BMC411120CPower(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, BMC411120CLoWrite); -} - -void BMC411120C_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = BMC411120CPW; - cwrap = BMC411120CCW; - info->Power = BMC411120CPower; - info->Reset = BMC411120CReset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/42.cpp b/branches/sdl2/src/boards/42.cpp deleted file mode 100644 index 87608574..00000000 --- a/branches/sdl2/src/boards/42.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 preg, creg, mirr; -static uint32 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &creg, 1, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQCount, 4, "IRQC" }, - { &IRQa, 4, "IRQA" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, preg); - setprg32(0x8000, ~0); - setchr8(creg); - setmirror(mirr); -} - -static DECLFW(M42Write) { - switch (A & 0xE003) { - case 0x8000: creg = V; Sync(); break; - case 0xE000: preg = V & 0x0F; Sync(); break; - case 0xE001: mirr = ((V >> 3) & 1 ) ^ 1; Sync(); break; - case 0xE002: IRQa = V & 2; if (!IRQa) IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -static void M42Power(void) { - preg = 0; - mirr = 1; // Ai Senshi Nicol actually has fixed mirroring, but mapper forcing it's default value now - Sync(); - SetReadHandler(0x6000, 0xffff, CartBR); - SetWriteHandler(0x6000, 0xffff, M42Write); -} - -static void M42IRQHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount >= 32768) IRQCount -= 32768; - if (IRQCount >= 24576) - X6502_IRQBegin(FCEU_IQEXT); - else - X6502_IRQEnd(FCEU_IQEXT); - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper42_Init(CartInfo *info) { - info->Power = M42Power; - MapIRQHook = M42IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/43.cpp b/branches/sdl2/src/boards/43.cpp deleted file mode 100644 index 396f80e2..00000000 --- a/branches/sdl2/src/boards/43.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg, swap; -static uint32 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 4, "IRQC" }, - { &IRQa, 4, "IRQA" }, - { ®, 1, "REG" }, - { &swap, 1, "SWAP" }, - { 0 } -}; - -static void Sync(void) { - setprg4(0x5000, 8 << 1); // Only YS-612 advanced version - setprg8(0x6000, swap?0:2); - setprg8(0x8000, 1); - setprg8(0xa000, 0); - setprg8(0xc000, reg); - setprg8(0xe000, swap?8:9); // hard dump for mr.Mary is 128K, - // bank 9 is the last 2K ok bank 8 repeated 4 times, then till the end of 128K - // instead used bank A, containing some CHR data, ines rom have unused banks removed, - // and bank A moved to the bank 9 place for compatibility with other crappy dumps - setchr8(0); -} - -static DECLFW(M43Write) { -// int transo[8]={4,3,4,4,4,7,5,6}; - int transo[8] = { 4, 3, 5, 3, 6, 3, 7, 3 }; // According to hardware tests - switch (A & 0xf1ff) { - case 0x4022: reg = transo[V & 7]; Sync(); break; - case 0x4120: swap = V & 1; Sync(); break; - case 0x8122: // hacked version - case 0x4122: IRQa = V & 1; X6502_IRQEnd(FCEU_IQEXT); IRQCount = 0; break; // original version - } -} - -static void M43Power(void) { - reg = swap = 0; - Sync(); - SetReadHandler(0x5000, 0xffff, CartBR); - SetWriteHandler(0x4020, 0xffff, M43Write); -} - -static void M43Reset(void) { -} - -static void M43IRQHook(int a) { - IRQCount += a; - if (IRQa) - if (IRQCount >= 4096) { - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper43_Init(CartInfo *info) { - info->Reset = M43Reset; - info->Power = M43Power; - MapIRQHook = M43IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/46.cpp b/branches/sdl2/src/boards/46.cpp deleted file mode 100644 index 04e03122..00000000 --- a/branches/sdl2/src/boards/46.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg0, reg1; - -static SFORMAT StateRegs[] = -{ - { ®0, 1, "REG0" }, - { ®1, 1, "REG1" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, (reg1 & 1) + ((reg0 & 0xF) << 1)); - setchr8(((reg1 >> 4) & 7) + ((reg0 & 0xF0) >> 1)); -} - -static DECLFW(M46Write0) { - reg0 = V; - Sync(); -} - -static DECLFW(M46Write1) { - reg1 = V; - Sync(); -} - -static void M46Power(void) { - reg0 = reg1 = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, M46Write0); - SetWriteHandler(0x8000, 0xFFFF, M46Write1); -} - -static void M46Reset(void) { - reg0 = reg1 = 0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper46_Init(CartInfo *info) { - info->Power = M46Power; - info->Reset = M46Reset; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/50.cpp b/branches/sdl2/src/boards/50.cpp deleted file mode 100644 index 40a8e42a..00000000 --- a/branches/sdl2/src/boards/50.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg; -static uint32 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 4, "IRQC" }, - { &IRQa, 4, "IRQA" }, - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, 0xF); - setprg8(0x8000, 0x8); - setprg8(0xa000, 0x9); - setprg8(0xc000, reg); - setprg8(0xe000, 0xB); - setchr8(0); -} - -static DECLFW(M50Write) { - switch (A & 0xD160) { - case 0x4120: IRQa = V & 1; if (!IRQa) IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x4020: reg = ((V & 1) << 2) | ((V & 2) >> 1) | ((V & 4) >> 1) | (V & 8); Sync(); break; - } -} - -static void M50Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0xffff, CartBR); - SetWriteHandler(0x4020, 0x5fff, M50Write); -} - -static void M50Reset(void) { -} - -static void M50IRQHook(int a) { - if (IRQa) { - if (IRQCount < 4096) - IRQCount += a; - else{ - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper50_Init(CartInfo *info) { - info->Reset = M50Reset; - info->Power = M50Power; - MapIRQHook = M50IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/51.cpp b/branches/sdl2/src/boards/51.cpp deleted file mode 100644 index 02d693c3..00000000 --- a/branches/sdl2/src/boards/51.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 bank, mode; -static SFORMAT StateRegs[] = -{ - { &bank, 1, "BANK" }, - { &mode, 1, "MODE" }, - { 0 } -}; - -static void Sync(void) { - if (mode & 2) { - setprg8(0x6000, ((bank & 7) << 2) | 0x23); - setprg16(0x8000, (bank << 1) | 0); - setprg16(0xC000, (bank << 1) | 1); - } else { - setprg8(0x6000, ((bank & 4) << 2) | 0x2F); - setprg16(0x8000, (bank << 1) | (mode >> 4)); - setprg16(0xC000, ((bank & 0xC) << 1) | 7); - } - if (mode == 0x12) - setmirror(MI_H); - else - setmirror(MI_V); - setchr8(0); -} - -static DECLFW(M51WriteMode) { - mode = V & 0x12; - Sync(); -} - -static DECLFW(M51WriteBank) { - bank = V & 0x0F; - if (A & 0x4000) - mode = (mode & 2) | (V & 0x10); - Sync(); -} - -static void M51Power(void) { - bank = 0; - mode = 2; - Sync(); - SetWriteHandler(0x6000, 0x7FFF, M51WriteMode); - SetWriteHandler(0x8000, 0xFFFF, M51WriteBank); - SetReadHandler(0x6000, 0xFFFF, CartBR); -} - -static void M51Reset(void) { - bank = 0; - mode = 2; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper51_Init(CartInfo *info) { - info->Power = M51Power; - info->Reset = M51Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/57.cpp b/branches/sdl2/src/boards/57.cpp deleted file mode 100644 index 4d2b5105..00000000 --- a/branches/sdl2/src/boards/57.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 prg_reg; -static uint8 chr_reg; -static uint8 hrd_flag; - -static SFORMAT StateRegs[] = -{ - { &hrd_flag, 1, "DPSW" }, - { &prg_reg, 1, "PRG" }, - { &chr_reg, 1, "CHR" }, - { 0 } -}; - -static void Sync(void) { - if (prg_reg & 0x80) - setprg32(0x8000, prg_reg >> 6); - else{ - setprg16(0x8000, (prg_reg >> 5) & 3); - setprg16(0xC000, (prg_reg >> 5) & 3); - } - setmirror((prg_reg & 8) >> 3); - setchr8((chr_reg & 3) | (prg_reg & 7) | ((prg_reg & 0x10) >> 1)); -} - -static DECLFR(M57Read) { - return hrd_flag; -} - -static DECLFW(M57Write) { - if ((A & 0x8800) == 0x8800) - prg_reg = V; - else - chr_reg = V; - Sync(); -} - -static void M57Power(void) { - prg_reg = 0; - chr_reg = 0; - hrd_flag = 0; - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M57Write); - SetReadHandler(0x6000, 0x6000, M57Read); - Sync(); -} - -static void M57Reset() { - hrd_flag++; - hrd_flag &= 3; - FCEU_printf("Select Register = %02x\n", hrd_flag); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper57_Init(CartInfo *info) { - info->Power = M57Power; - info->Reset = M57Reset; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/603-5052.cpp b/branches/sdl2/src/boards/603-5052.cpp deleted file mode 100644 index cf13a449..00000000 --- a/branches/sdl2/src/boards/603-5052.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 }; - -static DECLFW(UNL6035052ProtWrite) { - EXPREGS[0] = lut[V & 3]; -} - -static DECLFR(UNL6035052ProtRead) { - return EXPREGS[0]; -} - -static void UNL6035052Power(void) { - GenMMC3Power(); - SetWriteHandler(0x4020, 0x7FFF, UNL6035052ProtWrite); - SetReadHandler(0x4020, 0x7FFF, UNL6035052ProtRead); -} - -void UNL6035052_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power = UNL6035052Power; - AddExState(EXPREGS, 6, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/62.cpp b/branches/sdl2/src/boards/62.cpp deleted file mode 100644 index 0dc2a63d..00000000 --- a/branches/sdl2/src/boards/62.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 bank; -static uint16 mode; -static SFORMAT StateRegs[] = -{ - { &bank, 1, "BANK" }, - { &mode, 2, "MODE" }, - { 0 } -}; - -static void Sync(void) { - setchr8(((mode & 0x1F) << 2) | (bank & 0x03)); - if (mode & 0x20) { - setprg16(0x8000, (mode & 0x40) | ((mode >> 8) & 0x3F)); - setprg16(0xc000, (mode & 0x40) | ((mode >> 8) & 0x3F)); - } else - setprg32(0x8000, ((mode & 0x40) | ((mode >> 8) & 0x3F)) >> 1); - setmirror(((mode >> 7) & 1) ^ 1); -} - -static DECLFW(M62Write) { - mode = A & 0x3FFF; - bank = V & 3; - Sync(); -} - -static void M62Power(void) { - bank = mode = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M62Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void M62Reset(void) { - bank = mode = 0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper62_Init(CartInfo *info) { - info->Power = M62Power; - info->Reset = M62Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/65.cpp b/branches/sdl2/src/boards/65.cpp deleted file mode 100644 index fbfd6677..00000000 --- a/branches/sdl2/src/boards/65.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[3], creg[8], mirr; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; - -static SFORMAT StateRegs[] = -{ - { preg, 3, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirr); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - setchr1(0x0000, creg[0]); - setchr1(0x0400, creg[1]); - setchr1(0x0800, creg[2]); - setchr1(0x0C00, creg[3]); - setchr1(0x1000, creg[4]); - setchr1(0x1400, creg[5]); - setchr1(0x1800, creg[6]); - setchr1(0x1C00, creg[7]); - setmirror(mirr); -} - -static DECLFW(M65Write) { - switch (A) { - case 0x8000: preg[0] = V; Sync(); break; - case 0xA000: preg[1] = V; Sync(); break; - case 0xC000: preg[2] = V; Sync(); break; - case 0x9001: mirr = ((V >> 7) & 1) ^ 1; Sync(); break; - case 0x9003: IRQa = V & 0x80; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x9004: IRQCount = IRQLatch; break; - case 0x9005: IRQLatch &= 0x00FF; IRQLatch |= V << 8; break; - case 0x9006: IRQLatch &= 0xFF00; IRQLatch |= V; break; - case 0xB000: creg[0] = V; Sync(); break; - case 0xB001: creg[1] = V; Sync(); break; - case 0xB002: creg[2] = V; Sync(); break; - case 0xB003: creg[3] = V; Sync(); break; - case 0xB004: creg[4] = V; Sync(); break; - case 0xB005: creg[5] = V; Sync(); break; - case 0xB006: creg[6] = V; Sync(); break; - case 0xB007: creg[7] = V; Sync(); break; - } -} - -static void M65Power(void) { - preg[2] = ~1; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M65Write); -} - -void M65IRQ(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount < -4) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = -1; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper65_Init(CartInfo *info) { - info->Power = M65Power; - MapIRQHook = M65IRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/67.cpp b/branches/sdl2/src/boards/67.cpp deleted file mode 100644 index 4e29edbf..00000000 --- a/branches/sdl2/src/boards/67.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg, creg[4], mirr, suntoggle = 0; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &suntoggle, 1, "STOG" }, - { creg, 4, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setmirror(mirr); - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - setchr2(0x0000, creg[0]); - setchr2(0x0800, creg[1]); - setchr2(0x1000, creg[2]); - setchr2(0x1800, creg[3]); - switch (mirr) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M67Write) { - switch (A & 0xF800) { - case 0x8800: creg[0] = V; Sync(); break; - case 0x9800: creg[1] = V; Sync(); break; - case 0xA800: creg[2] = V; Sync(); break; - case 0xB800: creg[3] = V; Sync(); break; - case 0xC000: - case 0xC800: - IRQCount &= 0xFF << (suntoggle << 3); - IRQCount |= V << ((suntoggle ^ 1) << 3); - suntoggle ^= 1; - break; - case 0xD800: - suntoggle = 0; - IRQa = V & 0x10; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xE800: mirr = V & 3; Sync(); break; - case 0xF800: preg = V; Sync(); break; - } -} - -static void M67Power(void) { - suntoggle = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M67Write); -} - -void M67IRQ(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = -1; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper67_Init(CartInfo *info) { - info->Power = M67Power; - MapIRQHook = M67IRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/68.cpp b/branches/sdl2/src/boards/68.cpp deleted file mode 100644 index a38e567e..00000000 --- a/branches/sdl2/src/boards/68.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 chr_reg[4]; -static uint8 kogame, prg_reg, nt1, nt2, mirr; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE, count; - -static SFORMAT StateRegs[] = -{ - { &nt1, 1, "NT1" }, - { &nt2, 1, "NT2" }, - { &mirr, 1, "MIRR" }, - { &prg_reg, 1, "PRG" }, - { &kogame, 1, "KGME" }, - { &count, 4, "CNT" }, - { chr_reg, 4, "CHR" }, - { 0 } -}; - -static void M68NTfix(void) { - if ((!UNIFchrrama) && (mirr & 0x10)) { - PPUNTARAM = 0; - switch (mirr & 3) { - case 0: - vnapage[0] = vnapage[2] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - vnapage[1] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - case 1: - vnapage[0] = vnapage[1] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - vnapage[2] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - case 2: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = CHRptr[0] + (((nt1 | 128) & CHRmask1[0]) << 10); - break; - case 3: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = CHRptr[0] + (((nt2 | 128) & CHRmask1[0]) << 10); - break; - } - } else - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static void Sync(void) { - setchr2(0x0000, chr_reg[0]); - setchr2(0x0800, chr_reg[1]); - setchr2(0x1000, chr_reg[2]); - setchr2(0x1800, chr_reg[3]); - setprg8r(0x10, 0x6000, 0); - setprg16r((PRGptr[1]) ? kogame : 0, 0x8000, prg_reg); - setprg16(0xC000, ~0); -} - -static DECLFR(M68Read) { - if (!(kogame & 8)) { - count++; - if (count == 1784) - setprg16r(0, 0x8000, prg_reg); - } - return CartBR(A); -} - -static DECLFW(M68WriteLo) { - if (!V) { - count = 0; - setprg16r((PRGptr[1]) ? kogame : 0, 0x8000, prg_reg); - } - CartBW(A, V); -} - -static DECLFW(M68WriteCHR) { - chr_reg[(A >> 12) & 3] = V; - Sync(); -} - -static DECLFW(M68WriteNT1) { - nt1 = V; - M68NTfix(); -} - -static DECLFW(M68WriteNT2) { - nt2 = V; - M68NTfix(); -} - -static DECLFW(M68WriteMIR) { - mirr = V; - M68NTfix(); -} - -static DECLFW(M68WriteROM) { - prg_reg = V & 7; - kogame = ((V >> 3) & 1) ^ 1; - Sync(); -} - -static void M68Power(void) { - prg_reg = 0; - kogame = 0; - Sync(); - M68NTfix(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xBFFF, M68Read); - SetReadHandler(0xC000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, M68WriteCHR); - SetWriteHandler(0xC000, 0xCFFF, M68WriteNT1); - SetWriteHandler(0xD000, 0xDFFF, M68WriteNT2); - SetWriteHandler(0xE000, 0xEFFF, M68WriteMIR); - SetWriteHandler(0xF000, 0xFFFF, M68WriteROM); - SetWriteHandler(0x6000, 0x6000, M68WriteLo); - SetWriteHandler(0x6001, 0x7FFF, CartBW); -} - -static void M68Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); - M68NTfix(); -} - -void Mapper68_Init(CartInfo *info) { - info->Power = M68Power; - info->Close = M68Close; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/69.cpp b/branches/sdl2/src/boards/69.cpp deleted file mode 100644 index c289c9df..00000000 --- a/branches/sdl2/src/boards/69.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmdreg, preg[4], creg[8], mirr; -static uint8 IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &cmdreg, 1, "CMDR" }, - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - if ((preg[3] & 0xC0) == 0xC0) - setprg8r(0x10, 0x6000, 0); - else - setprg8(0x6000, preg[3] & 0x3F); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M69WRAMWrite) { - if ((preg[3] & 0xC0) == 0xC0) - CartBW(A, V); -} - -static DECLFR(M69WRAMRead) { - if ((preg[3] & 0xC0) == 0x40) - return X.DB; - else - return CartBR(A); -} - -static DECLFW(M69Write0) { - cmdreg = V & 0xF; -} - -static DECLFW(M69Write1) { - switch (cmdreg) { - case 0x0: creg[0] = V; Sync(); break; - case 0x1: creg[1] = V; Sync(); break; - case 0x2: creg[2] = V; Sync(); break; - case 0x3: creg[3] = V; Sync(); break; - case 0x4: creg[4] = V; Sync(); break; - case 0x5: creg[5] = V; Sync(); break; - case 0x6: creg[6] = V; Sync(); break; - case 0x7: creg[7] = V; Sync(); break; - case 0x8: preg[3] = V; Sync(); break; - case 0x9: preg[0] = V; Sync(); break; - case 0xA: preg[1] = V; Sync(); break; - case 0xB: preg[2] = V; Sync(); break; - case 0xC: mirr = V & 3; Sync();break; - case 0xD: IRQa = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xE: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF: IRQCount &= 0x00FF; IRQCount |= V << 8; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -// SUNSOFT-5/FME-7 Sound - -static void AYSound(int Count); -static void AYSoundHQ(void); -static void DoAYSQ(int x); -static void DoAYSQHQ(int x); - -static uint8 sndcmd, sreg[14]; -static int32 vcount[3]; -static int32 dcount[3]; -static int CAYBC[3]; - -static SFORMAT SStateRegs[] = -{ - { &sndcmd, 1, "SCMD" }, - { sreg, 14, "SREG" }, - { 0 } -}; - -static DECLFW(M69SWrite0) { - sndcmd = V % 14; -} - -static DECLFW(M69SWrite1) { - int x; - GameExpSound.Fill = AYSound; - GameExpSound.HiFill = AYSoundHQ; - if (FSettings.SndRate) - switch (sndcmd) { - case 0: - case 1: - case 8: if (FSettings.soundq >= 1) DoAYSQHQ(0); else DoAYSQ(0); break; - case 2: - case 3: - case 9: if (FSettings.soundq >= 1) DoAYSQHQ(1); else DoAYSQ(1); break; - case 4: - case 5: - case 10: if (FSettings.soundq >= 1) DoAYSQHQ(2); else DoAYSQ(2); break; - case 7: - for (x = 0; x < 2; x++) - if (FSettings.soundq >= 1) DoAYSQHQ(x); else DoAYSQ(x); - break; - } - sreg[sndcmd] = V; -} - -static void DoAYSQ(int x) { - int32 freq = ((sreg[x << 1] | ((sreg[(x << 1) + 1] & 15) << 8)) + 1) << (4 + 17); - int32 amp = (sreg[0x8 + x] & 15) << 2; - int32 start, end; - int V; - - amp += amp >> 1; - - start = CAYBC[x]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - CAYBC[x] = end; - - if (amp && !(sreg[0x7] & (1 << x))) - for (V = start; V < end; V++) { - if (dcount[x]) - Wave[V >> 4] += amp; - vcount[x] -= nesincsize; - while (vcount[x] <= 0) { - dcount[x] ^= 1; - vcount[x] += freq; - } - } -} - -static void DoAYSQHQ(int x) { - uint32 V; - int32 freq = ((sreg[x << 1] | ((sreg[(x << 1) + 1] & 15) << 8)) + 1) << 4; - int32 amp = (sreg[0x8 + x] & 15) << 6; - - amp += amp >> 1; - - if (!(sreg[0x7] & (1 << x))) { - for (V = CAYBC[x]; V < SOUNDTS; V++) { - if (dcount[x]) - WaveHi[V] += amp; - vcount[x]--; - if (vcount[x] <= 0) { - dcount[x] ^= 1; - vcount[x] = freq; - } - } - } - CAYBC[x] = SOUNDTS; -} - -static void AYSound(int Count) { - int x; - DoAYSQ(0); - DoAYSQ(1); - DoAYSQ(2); - for (x = 0; x < 3; x++) - CAYBC[x] = Count; -} - -static void AYSoundHQ(void) { - DoAYSQHQ(0); - DoAYSQHQ(1); - DoAYSQHQ(2); -} - -static void AYHiSync(int32 ts) { - int x; - - for (x = 0; x < 3; x++) - CAYBC[x] = ts; -} - -void Mapper69_ESI(void) { - GameExpSound.RChange = Mapper69_ESI; - GameExpSound.HiSync = AYHiSync; - memset(dcount, 0, sizeof(dcount)); - memset(vcount, 0, sizeof(vcount)); - memset(CAYBC, 0, sizeof(CAYBC)); - AddExState(&SStateRegs, ~0, 0, 0); -} - -// SUNSOFT-5/FME-7 Sound - -static void M69Power(void) { - cmdreg = sndcmd = 0; - IRQCount = 0xFFFF; - IRQa = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, M69WRAMRead); - SetWriteHandler(0x6000, 0x7FFF, M69WRAMWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x9FFF, M69Write0); - SetWriteHandler(0xA000, 0xBFFF, M69Write1); - SetWriteHandler(0xC000, 0xDFFF, M69SWrite0); - SetWriteHandler(0xE000, 0xFFFF, M69SWrite1); -} - -static void M69Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void M69IRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); IRQa = 0; IRQCount = 0xFFFF; - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper69_Init(CartInfo *info) { - info->Power = M69Power; - info->Close = M69Close; - MapIRQHook = M69IRQHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - Mapper69_ESI(); - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFAY_Init(void) { - sndcmd = 0; - SetWriteHandler(0xC000, 0xDFFF, M69SWrite0); - SetWriteHandler(0xE000, 0xFFFF, M69SWrite1); - Mapper69_ESI(); -} diff --git a/branches/sdl2/src/boards/71.cpp b/branches/sdl2/src/boards/71.cpp deleted file mode 100644 index 37c05aab..00000000 --- a/branches/sdl2/src/boards/71.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg, mirr; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - setchr8(0); - if(mirr) - setmirror(mirr); -} - -static DECLFW(M71Write) { - if ((A & 0xF000) == 0x9000) - mirr = MI_0 + ((V >> 4) & 1); // 2-in-1, some carts are normal hardwire V/H mirror, some uses mapper selectable 0/1 mirror - else - preg = V; - Sync(); -} - -static void M71Power(void) { - mirr = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M71Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper71_Init(CartInfo *info) { - info->Power = M71Power; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/72.cpp b/branches/sdl2/src/boards/72.cpp deleted file mode 100644 index de5ec91d..00000000 --- a/branches/sdl2/src/boards/72.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Moero!! Pro Tennis have ADPCM codec on-board, PROM isn't dumped, emulation isn't - * possible just now. - */ - -#include "mapinc.h" - -static uint8 preg, creg; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &creg, 1, "CREG" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - setchr8(creg); -} - -static DECLFW(M72Write) { - if (V & 0x80) - preg = V & 0xF; - if (V & 0x40) - creg = V & 0xF; - Sync(); -} - -static void M72Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, M72Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper72_Init(CartInfo *info) { - info->Power = M72Power; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/77.cpp b/branches/sdl2/src/boards/77.cpp deleted file mode 100644 index bbba3e8f..00000000 --- a/branches/sdl2/src/boards/77.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 latche; - -static uint8 *CHRRAM=NULL; -static uint32 CHRRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &latche, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, latche & 7); - setchr2(0x0000, latche >> 4); - setchr2r(0x10, 0x0800, 2); - setchr4r(0x10, 0x1000, 0); -} - -static DECLFW(M77Write) { - latche = V; - Sync(); -} - -static void M77Power(void) { - latche = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M77Write); -} - -static void M77Close(void) -{ - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper77_Init(CartInfo *info) { - info->Power = M77Power; - info->Close = M77Close; - GameStateRestore = StateRestore; - - CHRRAMSIZE = 6 * 1024; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/79.cpp b/branches/sdl2/src/boards/79.cpp deleted file mode 100644 index 14d9ac79..00000000 --- a/branches/sdl2/src/boards/79.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 creg, preg; -static SFORMAT StateRegs[] = -{ - { &creg, 1, "CREG" }, - { &preg, 1, "PREG" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, preg); - setchr8(creg); -} - -static DECLFW(M79Write) { - if ((A < 0x8000) && ((A ^ 0x4100) == 0)) { - preg = (V >> 3) & 1; - } - creg = V & 7; - Sync(); -} - -static void M79Power(void) { - preg = ~0; - Sync(); - SetWriteHandler(0x4100, 0x5FFF, M79Write); - SetWriteHandler(0x8000, 0xFFFF, M79Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper79_Init(CartInfo *info) { - info->Power = M79Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/80.cpp b/branches/sdl2/src/boards/80.cpp deleted file mode 100644 index b99132c2..00000000 --- a/branches/sdl2/src/boards/80.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 preg[3], creg[6], isExMirr; -static uint8 mirr, cmd, wram_enable, wram[256]; -static uint8 mcache[8]; -static uint32 lastppu; - -static SFORMAT StateRegs80[] = -{ - { preg, 3, "PREG" }, - { creg, 6, "CREG" }, - { wram, 256, "WRAM" }, - { &mirr, 1, "MIRR" }, - { &wram_enable, 1, "WRME" }, - { 0 } -}; - -static SFORMAT StateRegs95[] = -{ - { &cmd, 1, "CMDR" }, - { preg, 3, "PREG" }, - { creg, 6, "CREG" }, - { mcache, 8, "MCCH" }, - { &lastppu, 4, "LPPU" }, - { 0 } -}; - -static SFORMAT StateRegs207[] = -{ - { preg, 3, "PREG" }, - { creg, 6, "CREG" }, - { mcache, 8, "MCCH" }, - { &lastppu, 4, "LPPU" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - setchr2(0x0000, (creg[0] >> 1) & 0x3F); - setchr2(0x0800, (creg[1] >> 1) & 0x3F); - setchr1(0x1000, creg[2]); - setchr1(0x1400, creg[3]); - setchr1(0x1800, creg[4]); - setchr1(0x1C00, creg[5]); - if (isExMirr) { - setmirror(MI_0 + mcache[lastppu]); - } else - setmirror(mirr); -} - -static DECLFW(M80RamWrite) { - if(wram_enable == 0xA3) - wram[A & 0xFF] = V; -} - -static DECLFR(M80RamRead) { - if(wram_enable == 0xA3) - return wram[A & 0xFF]; - else - return 0xFF; -} - -static DECLFW(M80Write) { - switch (A) { - case 0x7EF0: creg[0] = V; mcache[0] = mcache[1] = V >> 7; Sync(); break; - case 0x7EF1: creg[1] = V; mcache[2] = mcache[3] = V >> 7; Sync(); break; - case 0x7EF2: creg[2] = V; mcache[4] = V >> 7; Sync(); break; - case 0x7EF3: creg[3] = V; mcache[5] = V >> 7; Sync(); break; - case 0x7EF4: creg[4] = V; mcache[6] = V >> 7; Sync(); break; - case 0x7EF5: creg[5] = V; mcache[7] = V >> 7; Sync(); break; - case 0x7EF6: mirr = V & 1; Sync(); break; - case 0x7EF8: wram_enable = V; break; - case 0x7EFA: - case 0x7EFB: preg[0] = V; Sync(); break; - case 0x7EFC: - case 0x7EFD: preg[1] = V; Sync(); break; - case 0x7EFE: - case 0x7EFF: preg[2] = V; Sync(); break; - } -} - -static DECLFW(M95Write) { - switch (A & 0xF001) { - case 0x8000: cmd = V; break; - case 0x8001: - switch (cmd & 0x07) { - case 0: creg[0] = V & 0x1F; mcache[0] = mcache[1] = (V >> 5) & 1; Sync(); break; - case 1: creg[1] = V & 0x1F; mcache[2] = mcache[3] = (V >> 5) & 1; Sync(); break; - case 2: creg[2] = V & 0x1F; mcache[4] = (V >> 5) & 1; Sync(); break; - case 3: creg[3] = V & 0x1F; mcache[5] = (V >> 5) & 1; Sync(); break; - case 4: creg[4] = V & 0x1F; mcache[6] = (V >> 5) & 1; Sync(); break; - case 5: creg[5] = V & 0x1F; mcache[7] = (V >> 5) & 1; Sync(); break; - case 6: preg[0] = V; Sync(); break; - case 7: preg[1] = V; Sync(); break; - } - Sync(); - } -} - -static void MExMirrPPU(uint32 A) { - static int8 lastmirr = -1, curmirr; - if (A < 0x2000) { - lastppu = A >> 10; - curmirr = mcache[lastppu]; - if (curmirr != lastmirr) { - setmirror(MI_0 + curmirr); - lastmirr = curmirr; - } - } -} - -static void M80Power(void) { - wram_enable = 0xFF; - Sync(); - SetReadHandler(0x7F00, 0x7FFF, M80RamRead); - SetWriteHandler(0x7F00, 0x7FFF, M80RamWrite); - SetWriteHandler(0x7EF0, 0x7EFF, M80Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void M207Power(void) { - mcache[0] = mcache[1] = mcache[2] = mcache[3] = 0; - mcache[4] = mcache[5] = mcache[6] = mcache[7] = 0; - Sync(); - SetWriteHandler(0x7EF0, 0x7EFF, M80Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void M95Power(void) { - preg[2] = ~1; - mcache[0] = mcache[1] = mcache[2] = mcache[3] = 0; - mcache[4] = mcache[5] = mcache[6] = mcache[7] = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M95Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper80_Init(CartInfo *info) { - isExMirr = 0; - info->Power = M80Power; - GameStateRestore = StateRestore; - - if (info->battery) { - info->SaveGame[0] = wram; - info->SaveGameLen[0] = 256; - } - - AddExState(&StateRegs80, ~0, 0, 0); -} - -void Mapper95_Init(CartInfo *info) { - isExMirr = 1; - info->Power = M95Power; - PPU_hook = MExMirrPPU; - GameStateRestore = StateRestore; - AddExState(&StateRegs95, ~0, 0, 0); -} - -void Mapper207_Init(CartInfo *info) { - isExMirr = 1; - info->Power = M207Power; - PPU_hook = MExMirrPPU; - GameStateRestore = StateRestore; - AddExState(&StateRegs207, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/8157.cpp b/branches/sdl2/src/boards/8157.cpp deleted file mode 100644 index 287be082..00000000 --- a/branches/sdl2/src/boards/8157.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * GG1 boards, similar to T-262, with no Data latch - * - */ - -#include "mapinc.h" - -static uint16 cmdreg; -static uint8 reset; -static SFORMAT StateRegs[] = -{ - { &reset, 1, "REST" }, - { &cmdreg, 2, "CREG" }, - { 0 } -}; - -static void Sync(void) { - uint32 base = ((cmdreg & 0x060) | ((cmdreg & 0x100) >> 1)) >> 2; - uint32 bank = (cmdreg & 0x01C) >> 2; - uint32 lbank = (cmdreg & 0x200) ? 7 : ((cmdreg & 0x80) ? bank : 0); - if (PRGptr[1]) { - setprg16r(base >> 3, 0x8000, bank); // for versions with split ROMs - setprg16r(base >> 3, 0xC000, lbank); - } else { - setprg16(0x8000, base | bank); - setprg16(0xC000, base | lbank); - } - setmirror(((cmdreg & 2) >> 1) ^ 1); -} - -static DECLFR(UNL8157Read) { - if ((cmdreg & 0x100) && (PRGsize[0] < (1024 * 1024))) { - A = (A & 0xFFF0) + reset; - } - return CartBR(A); -} - -static DECLFW(UNL8157Write) { - cmdreg = A; - Sync(); -} - -static void UNL8157Power(void) { - setchr8(0); - SetWriteHandler(0x8000, 0xFFFF, UNL8157Write); - SetReadHandler(0x8000, 0xFFFF, UNL8157Read); - cmdreg = reset = 0; - Sync(); -} - -static void UNL8157Reset(void) { - cmdreg = reset = 0; - reset++; - reset &= 0x1F; - Sync(); -} - -static void UNL8157Restore(int version) { - Sync(); -} - -void UNL8157_Init(CartInfo *info) { - info->Power = UNL8157Power; - info->Reset = UNL8157Reset; - GameStateRestore = UNL8157Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/82.cpp b/branches/sdl2/src/boards/82.cpp deleted file mode 100644 index 033e6ff6..00000000 --- a/branches/sdl2/src/boards/82.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Taito X1-017 board, battery backed - * - */ - -#include "mapinc.h" - -static uint8 regs[9], ctrl; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 9, "REGS" }, - { &ctrl, 1, "CTRL" }, - { 0 } -}; - -static void Sync(void) { - uint32 swap = ((ctrl & 2) << 11); - setchr2(0x0000 ^ swap, regs[0] >> 1); - setchr2(0x0800 ^ swap, regs[1] >> 1); - setchr1(0x1000 ^ swap, regs[2]); - setchr1(0x1400 ^ swap, regs[3]); - setchr1(0x1800 ^ swap, regs[4]); - setchr1(0x1c00 ^ swap, regs[5]); - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, regs[6]); - setprg8(0xA000, regs[7]); - setprg8(0xC000, regs[8]); - setprg8(0xE000, ~0); - setmirror(ctrl & 1); -} - -static DECLFW(M82Write) { - if (A <= 0x7ef5) - regs[A & 7] = V; - else - switch (A) { - case 0x7ef6: ctrl = V & 3; break; - case 0x7efa: regs[6] = V >> 2; break; - case 0x7efb: regs[7] = V >> 2; break; - case 0x7efc: regs[8] = V >> 2; break; - } - Sync(); -} - -static void M82Power(void) { - Sync(); - SetReadHandler(0x6000, 0xffff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetWriteHandler(0x7ef0, 0x7efc, M82Write); // external WRAM might end at $73FF -} - -static void M82Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper82_Init(CartInfo *info) { - info->Power = M82Power; - info->Close = M82Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/8237.cpp b/branches/sdl2/src/boards/8237.cpp deleted file mode 100644 index 38077690..00000000 --- a/branches/sdl2/src/boards/8237.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Super Game (Sugar Softec) protected mapper - * Pocahontas 2 (Unl) [U][!], etc. - * TODO: 9in1 LION KING HANGS! - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 cmdin; - -static uint8 regperm[8][8] = -{ - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0, 2, 6, 1, 7, 3, 4, 5 }, - { 0, 5, 4, 1, 7, 2, 6, 3 }, // unused - { 0, 6, 3, 7, 5, 2, 4, 1 }, - { 0, 2, 5, 3, 6, 1, 7, 4 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty -}; - -static uint8 adrperm[8][8] = -{ - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 3, 2, 0, 4, 1, 5, 6, 7 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, // unused - { 5, 0, 1, 2, 3, 7, 6, 4 }, - { 3, 1, 0, 5, 2, 4, 6, 7 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty - { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty -}; - -static void UNL8237CW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) - setchr1(A, ((EXPREGS[1] & 0xc) << 6) | (V & 0x7F) | ((EXPREGS[1] & 0x20) << 2)); - else - setchr1(A, ((EXPREGS[1] & 0xc) << 6) | V); -} - -static void UNL8237PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) { - uint8 sbank = (EXPREGS[1] & 0x10); - if (EXPREGS[0] & 0x80) { - uint8 bank = ((EXPREGS[1] & 3) << 4) | (EXPREGS[0] & 0x7) | (sbank >> 1); - if (EXPREGS[0] & 0x20) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else - setprg8(A, ((EXPREGS[1] & 3) << 5) | (V & 0x0F) | sbank); - } else { - if (EXPREGS[0] & 0x80) { - uint8 bank = ((EXPREGS[1] & 3) << 4) | (EXPREGS[0] & 0xF); - if (EXPREGS[0] & 0x20) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else - setprg8(A, ((EXPREGS[1] & 3) << 5) | (V & 0x1F)); - } -} - -static void UNL8237ACW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) - setchr1(A, ((EXPREGS[1] & 0xE) << 7) | (V & 0x7F) | ((EXPREGS[1] & 0x20) << 2)); - else - setchr1(A, ((EXPREGS[1] & 0xE) << 7) | V); -} - -static void UNL8237APW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) { - uint8 sbank = (EXPREGS[1] & 0x10); - if (EXPREGS[0] & 0x80) { - uint8 bank = ((EXPREGS[1] & 3) << 4) | ((EXPREGS[1] & 8) << 3) | (EXPREGS[0] & 0x7) | (sbank >> 1); - if (EXPREGS[0] & 0x20) { -// FCEU_printf("8000:%02X\n",bank>>1); - setprg32(0x8000, bank >> 1); - } else { -// FCEU_printf("8000-C000:%02X\n",bank); - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else { -// FCEU_printf("%04x:%02X\n",A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x0F)|sbank); - setprg8(A, ((EXPREGS[1] & 3) << 5) | ((EXPREGS[1] & 8) << 4) | (V & 0x0F) | sbank); - } - } else { - if (EXPREGS[0] & 0x80) { - uint8 bank = ((EXPREGS[1] & 3) << 4) | ((EXPREGS[1] & 8) << 3) | (EXPREGS[0] & 0xF); - if (EXPREGS[0] & 0x20) { -// FCEU_printf("8000:%02X\n",(bank>>1)&0x07); - setprg32(0x8000, bank >> 1); - } else { -// FCEU_printf("8000-C000:%02X\n",bank&0x0F); - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else { -// FCEU_printf("%04X:%02X\n",A,(((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x1F))&0x1F); - setprg8(A, ((EXPREGS[1] & 3) << 5) | ((EXPREGS[1] & 8) << 4) | (V & 0x1F)); - } - } -} -static DECLFW(UNL8237Write) { - uint8 dat = V; - uint8 adr = adrperm[EXPREGS[2]][((A >> 12) & 6) | (A & 1)]; - uint16 addr = (adr & 1) | ((adr & 6) << 12) | 0x8000; - if (adr < 4) { - if (!adr) - dat = (dat & 0xC0) | (regperm[EXPREGS[2]][dat & 7]); - MMC3_CMDWrite(addr, dat); - } else - MMC3_IRQWrite(addr, dat); -} - -static DECLFW(UNL8237ExWrite) { - switch (A) { - case 0x5000: EXPREGS[0] = V; FixMMC3PRG(MMC3_cmd); break; - case 0x5001: EXPREGS[1] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break; - case 0x5007: EXPREGS[2] = V; break; - } -} - -static void UNL8237Power(void) { - EXPREGS[0] = EXPREGS[2] = 0; - EXPREGS[1] = 3; - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, UNL8237Write); - SetWriteHandler(0x5000, 0x7FFF, UNL8237ExWrite); -} - -void UNL8237_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap = UNL8237CW; - pwrap = UNL8237PW; - info->Power = UNL8237Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDI"); -} - -void UNL8237A_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap = UNL8237ACW; - pwrap = UNL8237APW; - info->Power = UNL8237Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDI"); -} diff --git a/branches/sdl2/src/boards/830118C.cpp b/branches/sdl2/src/boards/830118C.cpp deleted file mode 100644 index f04d9dbf..00000000 --- a/branches/sdl2/src/boards/830118C.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2008 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// M-022 MMC3 based 830118C T-106 4M + 4M - -#include "mapinc.h" -#include "mmc3.h" - -static void BMC830118CCW(uint32 A, uint8 V) { - setchr1(A, (V & 0x7F) | ((EXPREGS[0] & 0x0c) << 5)); -} - -static void BMC830118CPW(uint32 A, uint8 V) { - if ((EXPREGS[0] & 0x0C) == 0x0C) { - if (A == 0x8000) { - setprg8(A, (V & 0x0F) | ((EXPREGS[0] & 0x0c) << 2)); - setprg8(0xC000, (V & 0x0F) | 0x32); - } else if (A == 0xA000) { - setprg8(A, (V & 0x0F) | ((EXPREGS[0] & 0x0c) << 2)); - setprg8(0xE000, (V & 0x0F) | 0x32); - } - } else { - setprg8(A, (V & 0x0F) | ((EXPREGS[0] & 0x0c) << 2)); - } -} - -static DECLFW(BMC830118CLoWrite) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void BMC830118CReset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -static void BMC830118CPower(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6800, 0x68FF, BMC830118CLoWrite); -} - -void BMC830118C_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = BMC830118CPW; - cwrap = BMC830118CCW; - info->Power = BMC830118CPower; - info->Reset = BMC830118CReset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/88.cpp b/branches/sdl2/src/boards/88.cpp deleted file mode 100644 index 7341f251..00000000 --- a/branches/sdl2/src/boards/88.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 mirror, cmd, is154; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { &mirror, 1, "MIRR" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setchr2(0x0000, reg[0] >> 1); - setchr2(0x0800, reg[1] >> 1); - setchr1(0x1000, reg[2] | 0x40); - setchr1(0x1400, reg[3] | 0x40); - setchr1(0x1800, reg[4] | 0x40); - setchr1(0x1C00, reg[5] | 0x40); - setprg8(0x8000, reg[6]); - setprg8(0xA000, reg[7]); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); -} - -static void MSync(void) { - if (is154) setmirror(MI_0 + (mirror & 1)); -} - -static DECLFW(M88Write) { - switch (A & 0x8001) { - case 0x8000: cmd = V & 7; mirror = V >> 6; MSync(); break; - case 0x8001: reg[cmd] = V; Sync(); break; - } -} - -static void M88Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = reg[4] = reg[5] = reg[6] = reg[7] = 0; - Sync(); - MSync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M88Write); -} - -static void StateRestore(int version) { - Sync(); - MSync(); -} - -void Mapper88_Init(CartInfo *info) { - is154 = 0; - info->Power = M88Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper154_Init(CartInfo *info) { - is154 = 1; - info->Power = M88Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/90.cpp b/branches/sdl2/src/boards/90.cpp deleted file mode 100644 index 7c873d26..00000000 --- a/branches/sdl2/src/boards/90.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -//#define DEBUG90 - -// Mapper 090 is simpliest mapper hardware and have not extended nametable control and latched chr banks in 4k mode -// Mapper 209 much compicated hardware with decribed above features disabled by default and switchable by command -// Mapper 211 the same mapper 209 but with forced nametable control - -static int is209; -static int is211; - -static uint8 IRQMode; // from $c001 -static uint8 IRQPre; // from $c004 -static uint8 IRQPreSize; // from $c007 -static uint8 IRQCount; // from $c005 -static uint8 IRQXOR; // Loaded from $C006 -static uint8 IRQa; // $c002, $c003, and $c000 - -static uint8 mul[2]; -static uint8 regie; - -static uint8 tkcom[4]; -static uint8 prgb[4]; -static uint8 chrlow[8]; -static uint8 chrhigh[8]; - -static uint8 chr[2]; - -static uint16 names[4]; -static uint8 tekker; - -static SFORMAT Tek_StateRegs[] = { - { &IRQMode, 1, "IRQM" }, - { &IRQPre, 1, "IRQP" }, - { &IRQPreSize, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQXOR, 1, "IRQX" }, - { &IRQa, 1, "IRQA" }, - { mul, 2, "MUL" }, - { ®ie, 1, "REGI" }, - { tkcom, 4, "TKCO" }, - { prgb, 4, "PRGB" }, - { chr, 2, "CLTC" }, - { chrlow, 4, "CHRL" }, - { chrhigh, 8, "CHRH" }, - { &names[0], 2 | FCEUSTATE_RLSB, "NMS0" }, - { &names[1], 2 | FCEUSTATE_RLSB, "NMS1" }, - { &names[2], 2 | FCEUSTATE_RLSB, "NMS2" }, - { &names[3], 2 | FCEUSTATE_RLSB, "NMS3" }, - { &tekker, 1, "TEKR" }, - { 0 } -}; - -static void mira(void) -{ - if((tkcom[0]&0x20&&is209)||is211) - { - int x; - if(tkcom[0]&0x40) // Name tables are ROM-only - { - for(x=0;x<4;x++) - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x); - } - else // Name tables can be RAM or ROM. - { - for(x=0;x<4;x++) - { - if((tkcom[1]&0x80)==(names[x]&0x80)) // RAM selected. - setntamem(NTARAM+((names[x]&0x1)<<10),1,x); - else - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x); - } - } - } - else - { - switch(tkcom[1]&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } - } -} - -static void tekprom(void) -{ - uint32 bankmode=((tkcom[3]&6)<<5); - switch(tkcom[0]&7) - { - case 00: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode); - setprg32(0x8000,0x0F|((tkcom[3]&6)<<3)); - break; - case 01: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode); - setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4)); - setprg16(0xC000,0x1F|((tkcom[3]&6)<<4)); - break; - case 03: // bit reversion - case 02: if(tkcom[0]&0x80) - setprg8(0x6000,(prgb[3]&0x3F)|bankmode); - setprg8(0x8000,(prgb[0]&0x3F)|bankmode); - setprg8(0xa000,(prgb[1]&0x3F)|bankmode); - setprg8(0xc000,(prgb[2]&0x3F)|bankmode); - setprg8(0xe000,0x3F|bankmode); - break; - case 04: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode); - setprg32(0x8000,(prgb[3]&0x0F)|((tkcom[3]&6)<<3)); - break; - case 05: if(tkcom[0]&0x80) - setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode); - setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4)); - setprg16(0xC000,(prgb[3]&0x1F)|((tkcom[3]&6)<<4)); - break; - case 07: // bit reversion - case 06: if(tkcom[0]&0x80) - setprg8(0x6000,(prgb[3]&0x3F)|bankmode); - setprg8(0x8000,(prgb[0]&0x3F)|bankmode); - setprg8(0xa000,(prgb[1]&0x3F)|bankmode); - setprg8(0xc000,(prgb[2]&0x3F)|bankmode); - setprg8(0xe000,(prgb[3]&0x3F)|bankmode); - break; - } -} - -static void tekvrom(void) -{ - int x, bank=0, mask=0xFFFF; - if(!(tkcom[3]&0x20)) - { - bank=(tkcom[3]&1)|((tkcom[3]&0x18)>>2); - switch (tkcom[0]&0x18) - { - case 0x00: bank<<=5; mask=0x1F; break; - case 0x08: bank<<=6; mask=0x3F; break; - case 0x10: bank<<=7; mask=0x7F; break; - case 0x18: bank<<=8; mask=0xFF; break; - } - } - switch(tkcom[0]&0x18) - { - case 0x00: // 8KB - setchr8(((chrlow[0]|(chrhigh[0]<<8))&mask)|bank); - break; - case 0x08: // 4KB -// for(x=0;x<8;x+=4) -// setchr4(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - setchr4(0x0000,((chrlow[chr[0]]|(chrhigh[chr[0]]<<8))&mask)|bank); - setchr4(0x1000,((chrlow[chr[1]]|(chrhigh[chr[1]]<<8))&mask)|bank); - break; - case 0x10: // 2KB - for(x=0;x<8;x+=2) - setchr2(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - break; - case 0x18: // 1KB - for(x=0;x<8;x++) - setchr1(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank); - break; - } -} - -static DECLFW(M90TekWrite) -{ - switch(A&0x5C03) - { - case 0x5800: mul[0]=V; break; - case 0x5801: mul[1]=V; break; - case 0x5803: regie=V; break; - } -} - -static DECLFR(M90TekRead) -{ - switch(A&0x5C03) - { - case 0x5800: return (mul[0]*mul[1]); - case 0x5801: return((mul[0]*mul[1])>>8); - case 0x5803: return (regie); - default: return tekker; - } - return(0xff); -} - -static DECLFW(M90PRGWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - prgb[A&3]=V; - tekprom(); -} - -static DECLFW(M90CHRlowWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - chrlow[A&7]=V; - tekvrom(); -} - -static DECLFW(M90CHRhiWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - chrhigh[A&7]=V; - tekvrom(); -} - -static DECLFW(M90NTWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - if(A&4) - { - names[A&3]&=0x00FF; - names[A&3]|=V<<8; - } - else - { - names[A&3]&=0xFF00; - names[A&3]|=V; - } - mira(); -} - -static DECLFW(M90IRQWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - switch(A&7) - { - case 00: //FCEU_printf("%s IRQ (C000)\n",V&1?"Enable":"Disable"); - IRQa=V&1;if(!(V&1)) X6502_IRQEnd(FCEU_IQEXT);break; - case 02: //FCEU_printf("Disable IRQ (C002) scanline=%d\n", scanline); - IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 03: //FCEU_printf("Enable IRQ (C003) scanline=%d\n", scanline); - IRQa=1;break; - case 01: IRQMode=V; - // FCEU_printf("IRQ Count method: "); - // switch (IRQMode&3) - // { - // case 00: FCEU_printf("M2 cycles\n");break; - // case 01: FCEU_printf("PPU A12 toggles\n");break; - // case 02: FCEU_printf("PPU reads\n");break; - // case 03: FCEU_printf("Writes to CPU space\n");break; - // } - // FCEU_printf("Counter prescaler size: %s\n",(IRQMode&4)?"3 bits":"8 bits"); - // FCEU_printf("Counter prescaler size adjust: %s\n",(IRQMode&8)?"Used C007":"Normal Operation"); - // if((IRQMode>>6)==2) FCEU_printf("Counter Down\n"); - // else if((IRQMode>>6)==1) FCEU_printf("Counter Up\n"); - // else FCEU_printf("Counter Stopped\n"); - break; - case 04: //FCEU_printf("Pre Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR); - IRQPre=V^IRQXOR;break; - case 05: //FCEU_printf("Main Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR); - IRQCount=V^IRQXOR;break; - case 06: //FCEU_printf("Xor Value: %d\n",V); - IRQXOR=V;break; - case 07: //if(!(IRQMode&8)) FCEU_printf("C001 is clear, no effect applied\n"); - // else if(V==0xFF) FCEU_printf("Prescaler is changed for 12bits\n"); - // else FCEU_printf("Counter Stopped\n"); - IRQPreSize=V;break; - } -} - -static DECLFW(M90ModeWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - tkcom[A&3]=V; - tekprom(); - tekvrom(); - mira(); - -#ifdef DEBUG90 - switch (A&3) - { - case 00: FCEU_printf("Main Control Register:\n"); - FCEU_printf(" PGR Banking mode: %d\n",V&7); - FCEU_printf(" CHR Banking mode: %d\n",(V>>3)&3); - FCEU_printf(" 6000-7FFF addresses mapping: %s\n",(V&0x80)?"Yes":"No"); - FCEU_printf(" Nametable control: %s\n",(V&0x20)?"Enabled":"Disabled"); - if(V&0x20) - FCEU_printf(" Nametable can be: %s\n",(V&0x40)?"ROM Only":"RAM or ROM"); - break; - case 01: FCEU_printf("Mirroring mode: "); - switch (V&3) - { - case 0: FCEU_printf("Vertical\n");break; - case 1: FCEU_printf("Horizontal\n");break; - case 2: FCEU_printf("Nametable 0 only\n");break; - case 3: FCEU_printf("Nametable 1 only\n");break; - } - FCEU_printf("Mirroring flag: %s\n",(V&0x80)?"On":"Off"); - break; - case 02: if((((tkcom[0])>>5)&3)==1) - FCEU_printf("Nametable ROM/RAM select mode: %d\n",V>>7); - break; - case 03: - FCEU_printf("CHR Banking mode: %s\n",(V&0x20)?"Entire CHR ROM":"256Kb Switching mode"); - if(!(V&0x20)) FCEU_printf("256K CHR bank number: %02x\n",(V&1)|((V&0x18)>>2)); - FCEU_printf("512K PRG bank number: %d\n",(V&6)>>1); - FCEU_printf("CHR Bank mirroring: %s\n",(V&0x80)?"Swapped":"Normal operate"); - } -#endif -} - -static DECLFW(M90DummyWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); -} - -static void CCL(void) -{ - if((IRQMode>>6) == 1) // Count Up - { - IRQCount++; - if((IRQCount == 0) && IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } - else if((IRQMode>>6) == 2) // Count down - { - IRQCount--; - if((IRQCount == 0xFF) && IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void ClockCounter(void) -{ - uint8 premask; - - if(IRQMode & 0x4) - premask = 0x7; - else - premask = 0xFF; - if((IRQMode>>6) == 1) // Count up - { - IRQPre++; - if((IRQPre & premask) == 0) CCL(); - } - else if((IRQMode>>6) == 2) // Count down - { - IRQPre--; - if((IRQPre & premask) == premask) CCL(); - } -} - -void CPUWrap(int a) -{ - int x; - if((IRQMode&3)==0) for(x=0;x>8; - if(h<0x20&&((h&0x0F)==0xF)) - { - l=A&0xF0; - if(l==0xD0) - { - chr[(h&0x10)>>4]=((h&0x10)>>2); - tekvrom(); - } - else if(l==0xE0) - { - chr[(h&0x10)>>4]=((h&0x10)>>2)|2; - tekvrom(); - } - } - } - else - { - chr[0]=0; - chr[1]=4; - } -} - -static void togglie() -{ - tekker+=0x40; - tekker&=0xC0; - FCEU_printf("tekker=%02x\n",tekker); - memset(tkcom,0x00,sizeof(tkcom)); - memset(prgb,0xff,sizeof(prgb)); - tekprom(); - tekvrom(); -} - -static void M90Restore(int version) -{ - tekprom(); - tekvrom(); - mira(); -} - -static void M90Power(void) -{ - SetWriteHandler(0x5000,0x5fff,M90TekWrite); - SetWriteHandler(0x8000,0x8ff0,M90PRGWrite); - SetWriteHandler(0x9000,0x9fff,M90CHRlowWrite); - SetWriteHandler(0xA000,0xAfff,M90CHRhiWrite); - SetWriteHandler(0xB000,0xBfff,M90NTWrite); - SetWriteHandler(0xC000,0xCfff,M90IRQWrite); - SetWriteHandler(0xD000,0xD5ff,M90ModeWrite); - SetWriteHandler(0xE000,0xFfff,M90DummyWrite); - - - SetReadHandler(0x5000,0x5fff,M90TekRead); - SetReadHandler(0x6000,0xffff,CartBR); - - mul[0]=mul[1]=regie=0xFF; - - memset(tkcom,0x00,sizeof(tkcom)); - memset(prgb,0xff,sizeof(prgb)); - memset(chrlow,0xff,sizeof(chrlow)); - memset(chrhigh,0xff,sizeof(chrhigh)); - memset(names,0x00,sizeof(names)); - - if(is211) - tekker=0xC0; - else - tekker=0x00; - - tekprom(); - tekvrom(); -} - - -void Mapper90_Init(CartInfo *info) -{ - is211=0; - is209=0; - info->Reset=togglie; - info->Power=M90Power; - PPU_hook=M90PPU; - MapIRQHook=CPUWrap; - GameHBIRQHook2=SLWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - -void Mapper209_Init(CartInfo *info) -{ - is211=0; - is209=1; - info->Reset=togglie; - info->Power=M90Power; - PPU_hook=M90PPU; - MapIRQHook=CPUWrap; - GameHBIRQHook2=SLWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - -void Mapper211_Init(CartInfo *info) -{ - is211=1; - info->Reset=togglie; - info->Power=M90Power; - PPU_hook=M90PPU; - MapIRQHook=CPUWrap; - GameHBIRQHook2=SLWrap; - GameStateRestore=M90Restore; - AddExState(Tek_StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/91.cpp b/branches/sdl2/src/boards/91.cpp deleted file mode 100644 index d1ed61b3..00000000 --- a/branches/sdl2/src/boards/91.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cregs[4], pregs[2]; -static uint8 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { cregs, 4, "CREG" }, - { pregs, 2, "PREG" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 1, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, pregs[0]); - setprg8(0xa000, pregs[1]); - setprg8(0xc000, ~1); - setprg8(0xe000, ~0); - setchr2(0x0000, cregs[0]); - setchr2(0x0800, cregs[1]); - setchr2(0x1000, cregs[2]); - setchr2(0x1800, cregs[3]); -} - -static DECLFW(M91Write0) { - cregs[A & 3] = V; - Sync(); -} - -static DECLFW(M91Write1) { - switch (A & 3) { - case 0: - case 1: pregs[A & 1] = V; Sync(); break; - case 2: IRQa = IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 3: IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -static void M91Power(void) { - Sync(); - SetWriteHandler(0x6000, 0x6fff, M91Write0); - SetWriteHandler(0x7000, 0x7fff, M91Write1); - SetReadHandler(0x8000, 0xffff, CartBR); -} - -static void M91IRQHook(void) { - if (IRQCount < 8 && IRQa) { - IRQCount++; - if (IRQCount >= 8) { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper91_Init(CartInfo *info) { - info->Power = M91Power; - GameHBIRQHook = M91IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/96.cpp b/branches/sdl2/src/boards/96.cpp deleted file mode 100644 index 08c42d6b..00000000 --- a/branches/sdl2/src/boards/96.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, ppulatch; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &ppulatch, 1, "PPUL" }, - { 0 } -}; - -static void Sync(void) { - setmirror(MI_0); - setprg32(0x8000, reg & 3); - setchr4(0x0000, (reg & 4) | ppulatch); - setchr4(0x1000, (reg & 4) | 3); -} - -static DECLFW(M96Write) { - reg = V; - Sync(); -} - -static void M96Hook(uint32 A) { - if ((A & 0x3000) == 0x2000) { - ppulatch = (A >> 8) & 3; - Sync(); - } -} - -static void M96Power(void) { - reg = ppulatch = 0; - Sync(); - SetReadHandler(0x8000, 0xffff, CartBR); - SetWriteHandler(0x8000, 0xffff, M96Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper96_Init(CartInfo *info) { - info->Power = M96Power; - PPU_hook = M96Hook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - diff --git a/branches/sdl2/src/boards/99.cpp b/branches/sdl2/src/boards/99.cpp deleted file mode 100644 index caf5cff8..00000000 --- a/branches/sdl2/src/boards/99.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 latch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static writefunc old4016; - -static SFORMAT StateRegs[] = -{ - { &latch, 1, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setchr8((latch >> 2) & 1); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, 0); - setprg8(0x8000, latch & 4); /* Special for VS Gumshoe */ -} - -static DECLFW(M99Write) { - latch = V; - Sync(); - old4016(A, V); -} - -static void M99Power(void) { - latch = 0; - Sync(); - old4016 = GetWriteHandler(0x4016); - SetWriteHandler(0x4016, 0x4016, M99Write); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); -} - -static void M99Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper99_Init(CartInfo *info) { - info->Power = M99Power; - info->Close = M99Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/SConscript b/branches/sdl2/src/boards/SConscript deleted file mode 100644 index f9afb2d5..00000000 --- a/branches/sdl2/src/boards/SConscript +++ /dev/null @@ -1,6 +0,0 @@ -import glob -source_list = glob.glob('*.cpp')+glob.glob('*.c') - -for x in range(len(source_list)): - source_list[x] = 'boards/' + source_list[x] -Return('source_list') diff --git a/branches/sdl2/src/boards/__dummy_mapper.cpp b/branches/sdl2/src/boards/__dummy_mapper.cpp deleted file mode 100644 index 505f9169..00000000 --- a/branches/sdl2/src/boards/__dummy_mapper.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2013 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; -/* -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint8 *CHRRAM = NULL; -static uint32 CHRRAMSIZE; -*/ - -static SFORMAT StateRegs[] = -{ - { reg, 8, "REGS" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, - { 0 } -}; - -static void Sync(void) { -} - -static DECLFW(MNNNWrite) { -} - -static void MNNNPower(void) { -// SetReadHandler(0x6000, 0x7fff, CartBR); -// SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, MNNNWrite); -} - -static void MNNNReset(void) { -} - -/* -static void MNNNClose(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - if (CHRRAM) - FCEU_gfree(CHRRAM); - WRAM = CHRRAM = NULL; -} -*/ - -static void MNNNIRQHook() { - X6502_IRQBegin(FCEU_IQEXT); -} - -static void StateRestore(int version) { - Sync(); -} - -void MapperNNN_Init(CartInfo *info) { - info->Reset = MNNNReset; - info->Power = MNNNPower; -// info->Close = MNNNClose; - GameHBIRQHook = MNNNIRQHook; - GameStateRestore = StateRestore; -/* - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CRAM"); -*/ -/* - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } -*/ - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/a9746.cpp b/branches/sdl2/src/boards/a9746.cpp deleted file mode 100644 index 321ac8aa..00000000 --- a/branches/sdl2/src/boards/a9746.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static DECLFW(UNLA9746Write) { -// FCEU_printf("write raw %04x:%02x\n",A,V); - switch (A & 0xE003) { - case 0x8000: EXPREGS[1] = V; EXPREGS[0] = 0; break; - case 0x8002: EXPREGS[0] = V; EXPREGS[1] = 0; break; - case 0x8001: - { - uint8 bits_rev = ((V & 0x20) >> 5) | ((V & 0x10) >> 3) | ((V & 0x08) >> 1) | ((V & 0x04) << 1); - switch (EXPREGS[0]) { - case 0x26: setprg8(0x8000, bits_rev); break; - case 0x25: setprg8(0xA000, bits_rev); break; - case 0x24: setprg8(0xC000, bits_rev); break; - case 0x23: setprg8(0xE000, bits_rev); break; - } - switch (EXPREGS[1]) { - case 0x0a: - case 0x08: EXPREGS[2] = (V << 4); break; - case 0x09: setchr1(0x0000, EXPREGS[2] | (V >> 1)); break; - case 0x0b: setchr1(0x0400, EXPREGS[2] | (V >> 1) | 1); break; - case 0x0c: - case 0x0e: EXPREGS[2] = (V << 4); break; - case 0x0d: setchr1(0x0800, EXPREGS[2] | (V >> 1)); break; - case 0x0f: setchr1(0x0c00, EXPREGS[2] | (V >> 1) | 1); break; - case 0x10: - case 0x12: EXPREGS[2] = (V << 4); break; - case 0x11: setchr1(0x1000, EXPREGS[2] | (V >> 1)); break; - case 0x14: - case 0x16: EXPREGS[2] = (V << 4); break; - case 0x15: setchr1(0x1400, EXPREGS[2] | (V >> 1)); break; - case 0x18: - case 0x1a: EXPREGS[2] = (V << 4); break; - case 0x19: setchr1(0x1800, EXPREGS[2] | (V >> 1)); break; - case 0x1c: - case 0x1e: EXPREGS[2] = (V << 4); break; - case 0x1d: setchr1(0x1c00, EXPREGS[2] | (V >> 1)); break; - } - } - break; - } -} - -static void UNLA9746Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xbfff, UNLA9746Write); -} - -void UNLA9746_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power = UNLA9746Power; - AddExState(EXPREGS, 6, 0, "EXPR"); -} - diff --git a/branches/sdl2/src/boards/ac-08.cpp b/branches/sdl2/src/boards/ac-08.cpp deleted file mode 100644 index 2c32fda2..00000000 --- a/branches/sdl2/src/boards/ac-08.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, mirr; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg); - setprg32r(1, 0x8000, 0); - setchr8(0); - setmirror(mirr); -} - -static DECLFW(AC08Mirr) { - mirr = ((V & 8) >> 3) ^ 1; - Sync(); -} - -static DECLFW(AC08Write) { - if (A == 0x8001) // Green Berret bank switching is only 100x xxxx xxxx xxx1 mask - reg = (V >> 1) & 0xf; - else - reg = V & 0xf; // Sad But True, 2-in-1 mapper, Green Berret need value shifted left one byte, Castlevania doesn't - Sync(); -} - -static void AC08Power(void) { - reg = 0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x4025, 0x4025, AC08Mirr); - SetWriteHandler(0x8000, 0xFFFF, AC08Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void AC08_Init(CartInfo *info) { - info->Power = AC08Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/addrlatch.cpp b/branches/sdl2/src/boards/addrlatch.cpp deleted file mode 100644 index 299f6e46..00000000 --- a/branches/sdl2/src/boards/addrlatch.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint16 latche, latcheinit; -static uint16 addrreg0, addrreg1; -static uint8 dipswitch; -static void (*WSync)(void); -static readfunc defread; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static DECLFW(LatchWrite) { - latche = A; - WSync(); -} - -static void LatchReset(void) { - latche = latcheinit; - WSync(); -} - -static void LatchPower(void) { - latche = latcheinit; - WSync(); - if (WRAM) { - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } else - SetReadHandler(0x6000, 0xFFFF, defread); - SetWriteHandler(addrreg0, addrreg1, LatchWrite); -} - -static void LatchClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16 linit, uint16 adr0, uint16 adr1, uint8 wram) { - latcheinit = linit; - addrreg0 = adr0; - addrreg1 = adr1; - WSync = proc; - if (func != NULL) - defread = func; - else - defread = CartBROB; - info->Power = LatchPower; - info->Reset = LatchReset; - info->Close = LatchClose; - if (wram) { - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - GameStateRestore = StateRestore; - AddExState(&latche, 2, 0, "LATC"); -} - -//------------------ BMCD1038 --------------------------- - -static void BMCD1038Sync(void) { - if (latche & 0x80) { - setprg16(0x8000, (latche & 0x70) >> 4); - setprg16(0xC000, (latche & 0x70) >> 4); - } else - setprg32(0x8000, (latche & 0x60) >> 5); - setchr8(latche & 7); - setmirror(((latche & 8) >> 3) ^ 1); -} - -static DECLFR(BMCD1038Read) { - if (latche & 0x100) - return dipswitch; - else - return CartBR(A); -} - -static void BMCD1038Reset(void) { - dipswitch++; - dipswitch &= 3; -} - -void BMCD1038_Init(CartInfo *info) { - Latch_Init(info, BMCD1038Sync, BMCD1038Read, 0x0000, 0x8000, 0xFFFF, 0); - info->Reset = BMCD1038Reset; - AddExState(&dipswitch, 1, 0, "DIPSW"); -} - -//------------------ UNL43272 --------------------------- -// mapper much complex, including 16K bankswitching -static void UNL43272Sync(void) { - if ((latche & 0x81) == 0x81) { - setprg32(0x8000, (latche & 0x38) >> 3); - } else - FCEU_printf("unrecognized command %04!\n", latche); - setchr8(0); - setmirror(0); -} - -static DECLFR(UNL43272Read) { - if (latche & 0x400) - return CartBR(A & 0xFE); - else - return CartBR(A); -} - -static void UNL43272Reset(void) { - latche = 0; - UNL43272Sync(); -} - -void UNL43272_Init(CartInfo *info) { - Latch_Init(info, UNL43272Sync, UNL43272Read, 0x0081, 0x8000, 0xFFFF, 0); - info->Reset = UNL43272Reset; - AddExState(&dipswitch, 1, 0, "DIPSW"); -} - -//------------------ Map 058 --------------------------- - -static void BMCGK192Sync(void) { - if (latche & 0x40) { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - } else - setprg32(0x8000, (latche >> 1) & 3); - setchr8((latche >> 3) & 7); - setmirror(((latche & 0x80) >> 7) ^ 1); -} - -void BMCGK192_Init(CartInfo *info) { - Latch_Init(info, BMCGK192Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 059 --------------------------- -// One more forgotten mapper -static void M59Sync(void) { - setprg32(0x8000, (latche >> 4) & 7); - setchr8(latche & 0x7); - setmirror((latche >> 3) & 1); -} - -static DECLFR(M59Read) { - if (latche & 0x100) - return 0; - else - return CartBR(A); -} - -void Mapper59_Init(CartInfo *info) { - Latch_Init(info, M59Sync, M59Read, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 061 --------------------------- -static void M61Sync(void) { - if (((latche & 0x10) << 1) ^ (latche & 0x20)) { - setprg16(0x8000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); - setprg16(0xC000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4))); - } else - setprg32(0x8000, latche & 0xF); - setchr8(0); - setmirror(((latche >> 7) & 1) ^ 1); -} - -void Mapper61_Init(CartInfo *info) { - Latch_Init(info, M61Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 092 --------------------------- -// Another two-in-one mapper, two Jaleco carts uses similar -// hardware, but with different wiring. -// Original code provided by LULU -// Additionally, PCB contains DSP extra sound chip, used for voice samples (unemulated) - -static void M92Sync(void) { - uint8 reg = latche & 0xF0; - setprg16(0x8000, 0); - if (latche >= 0x9000) { - switch (reg) { - case 0xD0: setprg16(0xc000, latche & 15); break; - case 0xE0: setchr8(latche & 15); break; - } - } else { - switch (reg) { - case 0xB0: setprg16(0xc000, latche & 15); break; - case 0x70: setchr8(latche & 15); break; - } - } -} - -void Mapper92_Init(CartInfo *info) { - Latch_Init(info, M92Sync, NULL, 0x80B0, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 200 --------------------------- - -static void M200Sync(void) { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - setchr8(latche & 7); - setmirror((latche & 8) >> 3); -} - -void Mapper200_Init(CartInfo *info) { - Latch_Init(info, M200Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 201 --------------------------- - -static void M201Sync(void) { - if (latche & 8) { - setprg32(0x8000, latche & 3); - setchr8(latche & 3); - } else { - setprg32(0x8000, 0); - setchr8(0); - } -} - -void Mapper201_Init(CartInfo *info) { - Latch_Init(info, M201Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 202 --------------------------- - -static void M202Sync(void) { - // According to more carefull hardware tests and PCB study - int32 mirror = latche & 1; - int32 bank = (latche >> 1) & 0x7; - int32 select = (mirror & (bank >> 2)); - setprg16(0x8000, select ? (bank & 6) | 0 : bank); - setprg16(0xc000, select ? (bank & 6) | 1 : bank); - setmirror(mirror ^ 1); - setchr8(bank); -} - -void Mapper202_Init(CartInfo *info) { - Latch_Init(info, M202Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 204 --------------------------- - -static void M204Sync(void) { - int32 tmp2 = latche & 0x6; - int32 tmp1 = tmp2 + ((tmp2 == 0x6) ? 0 : (latche & 1)); - setprg16(0x8000, tmp1); - setprg16(0xc000, tmp2 + ((tmp2 == 0x6) ? 1 : (latche & 1))); - setchr8(tmp1); - setmirror(((latche >> 4) & 1) ^ 1); -} - -void Mapper204_Init(CartInfo *info) { - Latch_Init(info, M204Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 212 --------------------------- - -static DECLFR(M212Read) { - uint8 ret = CartBROB(A); - if ((A & 0xE010) == 0x6000) - ret |= 0x80; - return ret; -} - -static void M212Sync(void) { - if (latche & 0x4000) { - setprg32(0x8000, (latche >> 1) & 3); - } else { - setprg16(0x8000, latche & 7); - setprg16(0xC000, latche & 7); - } - setchr8(latche & 7); - setmirror(((latche >> 3) & 1) ^ 1); -} - -void Mapper212_Init(CartInfo *info) { - Latch_Init(info, M212Sync, M212Read, 0xFFFF, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 213 --------------------------- - -static void M213Sync(void) { - setprg32(0x8000, (latche >> 1) & 3); - setchr8((latche >> 3) & 7); -} - -void Mapper213_Init(CartInfo *info) { - Latch_Init(info, M213Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 214 --------------------------- - -static void M214Sync(void) { - setprg16(0x8000, (latche >> 2) & 3); - setprg16(0xC000, (latche >> 2) & 3); - setchr8(latche & 3); -} - -void Mapper214_Init(CartInfo *info) { - Latch_Init(info, M214Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 217 --------------------------- - -static void M217Sync(void) { - setprg32(0x8000, (latche >> 2) & 3); - setchr8(latche & 7); -} - -void Mapper217_Init(CartInfo *info) { - Latch_Init(info, M217Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 227 --------------------------- - -static void M227Sync(void) { - uint32 S = latche & 1; - uint32 p = ((latche >> 2) & 0x1F) + ((latche & 0x100) >> 3); - uint32 L = (latche >> 9) & 1; - - if ((latche >> 7) & 1) { - if (S) { - setprg32(0x8000, p >> 1); - } else { - setprg16(0x8000, p); - setprg16(0xC000, p); - } - } else { - if (S) { - if (L) { - setprg16(0x8000, p & 0x3E); - setprg16(0xC000, p | 7); - } else { - setprg16(0x8000, p & 0x3E); - setprg16(0xC000, p & 0x38); - } - } else { - if (L) { - setprg16(0x8000, p); - setprg16(0xC000, p | 7); - } else { - setprg16(0x8000, p); - setprg16(0xC000, p & 0x38); - } - } - } - - setmirror(((latche >> 1) & 1) ^ 1); - setchr8(0); - setprg8r(0x10, 0x6000, 0); -} - -void Mapper227_Init(CartInfo *info) { - Latch_Init(info, M227Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); -} - -//------------------ Map 229 --------------------------- - -static void M229Sync(void) { - setchr8(latche); - if (!(latche & 0x1e)) - setprg32(0x8000, 0); - else { - setprg16(0x8000, latche & 0x1F); - setprg16(0xC000, latche & 0x1F); - } - setmirror(((latche >> 5) & 1) ^ 1); -} - -void Mapper229_Init(CartInfo *info) { - Latch_Init(info, M229Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 231 --------------------------- - -static void M231Sync(void) { - setchr8(0); - if (latche & 0x20) - setprg32(0x8000, (latche >> 1) & 0x0F); - else { - setprg16(0x8000, latche & 0x1E); - setprg16(0xC000, latche & 0x1E); - } - setmirror(((latche >> 7) & 1) ^ 1); -} - -void Mapper231_Init(CartInfo *info) { - Latch_Init(info, M231Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//------------------ Map 242 --------------------------- - -static void M242Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, (latche >> 3) & 0xf); - setmirror(((latche >> 1) & 1) ^ 1); -} - -void Mapper242_Init(CartInfo *info) { - Latch_Init(info, M242Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1); -} - -//------------------ 190in1 --------------------------- - -static void BMC190in1Sync(void) { - setprg16(0x8000, (latche >> 2) & 7); - setprg16(0xC000, (latche >> 2) & 7); - setchr8((latche >> 2) & 7); - setmirror((latche & 1) ^ 1); -} - -void BMC190in1_Init(CartInfo *info) { - Latch_Init(info, BMC190in1Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMC810544-C-A1 ------------------------ - -static void BMC810544CA1Sync(void) { - uint32 bank = latche >> 7; - if (latche & 0x40) - setprg32(0x8000, bank); - else { - setprg16(0x8000, (bank << 1) | ((latche >> 5) & 1)); - setprg16(0xC000, (bank << 1) | ((latche >> 5) & 1)); - } - setchr8(latche & 0x0f); - setmirror(((latche >> 4) & 1) ^ 1); -} - -void BMC810544CA1_Init(CartInfo *info) { - Latch_Init(info, BMC810544CA1Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMCNTD-03 ------------------------ - -static void BMCNTD03Sync(void) { - // 1PPP Pmcc spxx xccc - // 1000 0000 0000 0000 v - // 1001 1100 0000 0100 h - // 1011 1010 1100 0100 - uint32 prg = ((latche >> 10) & 0x1e); - uint32 chr = ((latche & 0x0300) >> 5) | (latche & 7); - if (latche & 0x80) { - setprg16(0x8000, prg | ((latche >> 6) & 1)); - setprg16(0xC000, prg | ((latche >> 6) & 1)); - } else - setprg32(0x8000, prg >> 1); - setchr8(chr); - setmirror(((latche >> 10) & 1) ^ 1); -} - -void BMCNTD03_Init(CartInfo *info) { - Latch_Init(info, BMCNTD03Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} - -//-------------- BMCG-146 ------------------------ - -static void BMCG146Sync(void) { - setchr8(0); - if (latche & 0x800) { // UNROM mode - setprg16(0x8000, (latche & 0x1F) | (latche & ((latche & 0x40) >> 6))); - setprg16(0xC000, (latche & 0x18) | 7); - } else { - if (latche & 0x40) { // 16K mode - setprg16(0x8000, latche & 0x1F); - setprg16(0xC000, latche & 0x1F); - } else { - setprg32(0x8000, (latche >> 1) & 0x0F); - } - } - setmirror(((latche & 0x80) >> 7) ^ 1); -} - -void BMCG146_Init(CartInfo *info) { - Latch_Init(info, BMCG146Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0); -} diff --git a/branches/sdl2/src/boards/ax5705.cpp b/branches/sdl2/src/boards/ax5705.cpp deleted file mode 100644 index 82a4824b..00000000 --- a/branches/sdl2/src/boards/ax5705.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Super Bros. Pocker Mali (VRC4 mapper) - */ - -#include "mapinc.h" - -static uint8 IRQCount; //, IRQPre; -static uint8 IRQa; -static uint8 prg_reg[2]; -static uint8 chr_reg[8]; -static uint8 mirr; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 1, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { prg_reg, 2, "PRG" }, - { chr_reg, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -/* -static void UNLAX5705IRQ(void) -{ - if(IRQa) - { - IRQCount++; - if(IRQCount>=238) - { - X6502_IRQBegin(FCEU_IQEXT); -// IRQa=0; - } - } -}*/ - -static void Sync(void) { - setprg8(0x8000, prg_reg[0]); - setprg8(0xA000, prg_reg[1]); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chr_reg[i]); - setmirror(mirr ^ 1); -} - -static DECLFW(UNLAX5705Write) { -// if((A>=0xA008)&&(A<=0xE003)) -// { -// int ind=(((A>>11)-6)|(A&1))&7; -// int sar=((A&2)<<1); -// chr_reg[ind]=(chr_reg[ind]&(0xF0>>sar))|((V&0x0F)<> 2) | (V & 5); break; // EPROM dump have mixed PRG and CHR banks, data lines to mapper seems to be mixed - case 0x8008: mirr = V & 1; break; - case 0xA000: prg_reg[1] = ((V & 2) << 2) | ((V & 8) >> 2) | (V & 5); break; - case 0xA008: chr_reg[0] = (chr_reg[0] & 0xF0) | (V & 0x0F); break; - case 0xA009: chr_reg[0] = (chr_reg[0] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xA00A: chr_reg[1] = (chr_reg[1] & 0xF0) | (V & 0x0F); break; - case 0xA00B: chr_reg[1] = (chr_reg[1] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xC000: chr_reg[2] = (chr_reg[2] & 0xF0) | (V & 0x0F); break; - case 0xC001: chr_reg[2] = (chr_reg[2] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xC002: chr_reg[3] = (chr_reg[3] & 0xF0) | (V & 0x0F); break; - case 0xC003: chr_reg[3] = (chr_reg[3] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xC008: chr_reg[4] = (chr_reg[4] & 0xF0) | (V & 0x0F); break; - case 0xC009: chr_reg[4] = (chr_reg[4] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xC00A: chr_reg[5] = (chr_reg[5] & 0xF0) | (V & 0x0F); break; - case 0xC00B: chr_reg[5] = (chr_reg[5] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xE000: chr_reg[6] = (chr_reg[6] & 0xF0) | (V & 0x0F); break; - case 0xE001: chr_reg[6] = (chr_reg[6] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; - case 0xE002: chr_reg[7] = (chr_reg[7] & 0xF0) | (V & 0x0F); break; - case 0xE003: chr_reg[7] = (chr_reg[7] & 0x0F) | ((((V & 4) >> 1) | ((V & 2) << 1) | (V & 0x09)) << 4); break; -// case 0x800A: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break; -// case 0xE00B: X6502_IRQEnd(FCEU_IQEXT); IRQa=IRQCount=V; /*if(scanline<240) IRQCount-=8; else IRQCount+=4;*/ break; - } - Sync(); -} - -static void UNLAX5705Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLAX5705Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLAX5705_Init(CartInfo *info) { - info->Power = UNLAX5705Power; -// GameHBIRQHook=UNLAX5705IRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/bandai.cpp b/branches/sdl2/src/boards/bandai.cpp deleted file mode 100644 index 98f849c5..00000000 --- a/branches/sdl2/src/boards/bandai.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * Copyright (C) 2011 FCEUX team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Bandai mappers - * - */ - -#include "mapinc.h" - -static uint8 reg[16], is153, x24c02; -static uint8 IRQa; -static int16 IRQCount, IRQLatch; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { reg, 16, "REGS" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 2, "IRQL" }, // need for Famicom Jump II - Saikyou no 7 Nin (J) [!] - { 0 } -}; - -// x24C0x interface - -#define X24C0X_STANDBY 0 -#define X24C0X_ADDRESS 1 -#define X24C0X_WORD 2 -#define X24C0X_READ 3 -#define X24C0X_WRITE 4 - -static uint8 x24c0x_data[256], x24c0x_state; -static uint8 x24c0x_addr, x24c0x_word, x24c0x_latch, x24c0x_bitcount; -static uint8 x24c0x_sda, x24c0x_scl, x24c0x_out, x24c0x_oe; - -static SFORMAT x24c0xStateRegs[] = -{ - { &x24c0x_addr, 1, "ADDR" }, - { &x24c0x_word, 1, "WORD" }, - { &x24c0x_latch, 1, "LATC" }, - { &x24c0x_bitcount, 1, "BITC" }, - { &x24c0x_sda, 1, "SDA" }, - { &x24c0x_scl, 1, "SCL" }, - { &x24c0x_out, 1, "OUT" }, - { &x24c0x_oe, 1, "OE" }, - { &x24c0x_state, 1, "STAT" }, - { 0 } -}; - -static void x24c0x_init() { - x24c0x_addr = x24c0x_word = x24c0x_latch = x24c0x_bitcount = x24c0x_sda = x24c0x_scl = x24c0x_oe = 0; - x24c0x_state = X24C0X_STANDBY; -} - -static void x24c0x_write(uint8 data) { - uint8 sda = (data >> 6) & 1; - uint8 scl = (data >> 5) & 1; - x24c0x_oe = (data >> 7); - - if(x24c0x_scl && scl) { - if(x24c0x_sda && !sda) { // START - x24c0x_state = X24C0X_ADDRESS; - x24c0x_bitcount = 0; - x24c0x_addr = 0; - } else if(!x24c0x_sda && sda) { //STOP - x24c0x_state = X24C0X_STANDBY; - } - } else if(!x24c0x_scl && scl) { // RISING EDGE - switch(x24c0x_state) { - case X24C0X_ADDRESS: - if(x24c0x_bitcount < 7) { - x24c0x_addr <<= 1; - x24c0x_addr |= sda; - } else { - if(!x24c02) // X24C01 mode - x24c0x_word = x24c0x_addr; - if(sda) { // READ COMMAND - x24c0x_state = X24C0X_READ; - } else { // WRITE COMMAND - if(x24c02) // X24C02 mode - x24c0x_state = X24C0X_WORD; - else - x24c0x_state = X24C0X_WRITE; - } - } - x24c0x_bitcount++; - break; - case X24C0X_WORD: - if(x24c0x_bitcount == 8) { // ACK - x24c0x_word = 0; - x24c0x_out = 0; - } else { // WORD ADDRESS INPUT - x24c0x_word <<= 1; - x24c0x_word |= sda; - if(x24c0x_bitcount == 16) { // END OF ADDRESS INPUT - x24c0x_bitcount = 7; - x24c0x_state = X24C0X_WRITE; - } - } - x24c0x_bitcount++; - break; - case X24C0X_READ: - if (x24c0x_bitcount == 8) { // ACK - x24c0x_out = 0; - x24c0x_latch = x24c0x_data[x24c0x_word]; - x24c0x_bitcount = 0; - } else { // REAL OUTPUT - x24c0x_out = x24c0x_latch >> 7; - x24c0x_latch <<= 1; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_word++; - x24c0x_word &= 0xff; - } - } - break; - case X24C0X_WRITE: - if (x24c0x_bitcount == 8) { // ACK - x24c0x_out = 0; - x24c0x_latch = 0; - x24c0x_bitcount = 0; - } else { // REAL INPUT - x24c0x_latch <<= 1; - x24c0x_latch |= sda; - x24c0x_bitcount++; - if(x24c0x_bitcount == 8) { - x24c0x_data[x24c0x_word] = x24c0x_latch; - x24c0x_word++; - x24c0x_word &= 0xff; - } - } - break; - } - } - - x24c0x_sda = sda; - x24c0x_scl = scl; -} - -static uint8 x24c0x_read() { - return x24c0x_out << 4; -} - -// - -static void Sync(void) { - if (is153) { - int base = (reg[0] & 1) << 4; - setchr8(0); - setprg16(0x8000, (reg[8] & 0x0F) | base); - setprg16(0xC000, 0x0F | base); - } else { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, reg[i]); - setprg16(0x8000, reg[8]); - setprg16(0xC000, ~0); - } - switch (reg[9] & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(BandaiWrite) { - A &= 0x0F; - if (A < 0x0A) { - reg[A & 0x0F] = V; - Sync(); - } else - switch (A) { - case 0x0A: X6502_IRQEnd(FCEU_IQEXT); IRQa = V & 1; IRQCount = IRQLatch; break; - case 0x0B: IRQLatch &= 0xFF00; IRQLatch |= V; break; - case 0x0C: IRQLatch &= 0xFF; IRQLatch |= V << 8; break; - case 0x0D: x24c0x_write(V); break; - } -} - -static DECLFR(BandaiRead) { - return (X.DB & 0xEF) | x24c0x_read(); -} - -static void BandaiIRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount < 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = -1; - } - } -} - -static void BandaiPower(void) { - IRQa = 0; - x24c0x_init(); - Sync(); - SetReadHandler(0x6000, 0x7FFF, BandaiRead); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, BandaiWrite); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper16_Init(CartInfo *info) { - x24c02 = 1; - is153 = 0; - info->Power = BandaiPower; - MapIRQHook = BandaiIRQHook; - - info->battery = 1; - info->SaveGame[0] = x24c0x_data; - info->SaveGameLen[0] = 256; - AddExState(x24c0x_data, 256, 0, "DATA"); - - GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper159_Init(CartInfo *info) { - x24c02 = 0; - is153 = 0; - info->Power = BandaiPower; - MapIRQHook = BandaiIRQHook; - - info->battery = 1; - info->SaveGame[0] = x24c0x_data; - info->SaveGameLen[0] = 128; - AddExState(x24c0x_data, 128, 0, "DATA"); - - GameStateRestore = StateRestore; - AddExState(&x24c0xStateRegs, ~0, 0, 0); - AddExState(&StateRegs, ~0, 0, 0); -} - -// Famicom jump 2: -// 0-7: Lower bit of data selects which 256KB PRG block is in use. -// This seems to be a hack on the developers' part, so I'll make emulation -// of it a hack(I think the current PRG block would depend on whatever the -// lowest bit of the CHR bank switching register that corresponds to the -// last CHR address read). - -static void M153Power(void) { - Sync(); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, BandaiWrite); -} - - -static void M153Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper153_Init(CartInfo *info) { - is153 = 1; - info->Power = M153Power; - info->Close = M153Close; - MapIRQHook = BandaiIRQHook; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -// Datach Barcode Battler - -static uint8 BarcodeData[256]; -static int BarcodeReadPos; -static int BarcodeCycleCount; -static uint32 BarcodeOut; - -int FCEUI_DatachSet(const uint8 *rcode) { - int prefix_parity_type[10][6] = { - { 0, 0, 0, 0, 0, 0 }, { 0, 0, 1, 0, 1, 1 }, { 0, 0, 1, 1, 0, 1 }, { 0, 0, 1, 1, 1, 0 }, - { 0, 1, 0, 0, 1, 1 }, { 0, 1, 1, 0, 0, 1 }, { 0, 1, 1, 1, 0, 0 }, { 0, 1, 0, 1, 0, 1 }, - { 0, 1, 0, 1, 1, 0 }, { 0, 1, 1, 0, 1, 0 } - }; - int data_left_odd[10][7] = { - { 0, 0, 0, 1, 1, 0, 1 }, { 0, 0, 1, 1, 0, 0, 1 }, { 0, 0, 1, 0, 0, 1, 1 }, { 0, 1, 1, 1, 1, 0, 1 }, - { 0, 1, 0, 0, 0, 1, 1 }, { 0, 1, 1, 0, 0, 0, 1 }, { 0, 1, 0, 1, 1, 1, 1 }, { 0, 1, 1, 1, 0, 1, 1 }, - { 0, 1, 1, 0, 1, 1, 1 }, { 0, 0, 0, 1, 0, 1, 1 } - }; - int data_left_even[10][7] = { - { 0, 1, 0, 0, 1, 1, 1 }, { 0, 1, 1, 0, 0, 1, 1 }, { 0, 0, 1, 1, 0, 1, 1 }, { 0, 1, 0, 0, 0, 0, 1 }, - { 0, 0, 1, 1, 1, 0, 1 }, { 0, 1, 1, 1, 0, 0, 1 }, { 0, 0, 0, 0, 1, 0, 1 }, { 0, 0, 1, 0, 0, 0, 1 }, - { 0, 0, 0, 1, 0, 0, 1 }, { 0, 0, 1, 0, 1, 1, 1 } - }; - int data_right[10][7] = { - { 1, 1, 1, 0, 0, 1, 0 }, { 1, 1, 0, 0, 1, 1, 0 }, { 1, 1, 0, 1, 1, 0, 0 }, { 1, 0, 0, 0, 0, 1, 0 }, - { 1, 0, 1, 1, 1, 0, 0 }, { 1, 0, 0, 1, 1, 1, 0 }, { 1, 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 0, 1, 0, 0 }, - { 1, 0, 0, 1, 0, 0, 0 }, { 1, 1, 1, 0, 1, 0, 0 } - }; - uint8 code[13 + 1]; - uint32 tmp_p = 0; - int i, j; - int len; - - for (i = len = 0; i < 13; i++) { - if (!rcode[i]) break; - if ((code[i] = rcode[i] - '0') > 9) - return(0); - len++; - } - if (len != 13 && len != 12 && len != 8 && len != 7) return(0); - - #define BS(x) BarcodeData[tmp_p] = x; tmp_p++ - - for (j = 0; j < 32; j++) { - BS(0x00); - } - - /* Left guard bars */ - BS(1); BS(0); BS(1); - - if (len == 13 || len == 12) { - uint32 csum; - - for (i = 0; i < 6; i++) - if (prefix_parity_type[code[0]][i]) { - for (j = 0; j < 7; j++) { - BS(data_left_even[code[i + 1]][j]); - } - } else - for (j = 0; j < 7; j++) { - BS(data_left_odd[code[i + 1]][j]); - } - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for (i = 7; i < 12; i++) - for (j = 0; j < 7; j++) { - BS(data_right[code[i]][j]); - } - csum = 0; - for (i = 0; i < 12; i++) csum += code[i] * ((i & 1) ? 3 : 1); - csum = (10 - (csum % 10)) % 10; - for (j = 0; j < 7; j++) { - BS(data_right[csum][j]); - } - } else if (len == 8 || len == 7) { - uint32 csum = 0; - - for (i = 0; i < 7; i++) csum += (i & 1) ? code[i] : (code[i] * 3); - - csum = (10 - (csum % 10)) % 10; - - for (i = 0; i < 4; i++) - for (j = 0; j < 7; j++) { - BS(data_left_odd[code[i]][j]); - } - - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for (i = 4; i < 7; i++) - for (j = 0; j < 7; j++) { - BS(data_right[code[i]][j]); - } - - for (j = 0; j < 7; j++) { - BS(data_right[csum][j]); - } - } - - /* Right guard bars */ - BS(1); BS(0); BS(1); - - for (j = 0; j < 32; j++) { - BS(0x00); - } - - BS(0xFF); - - #undef BS - - BarcodeReadPos = 0; - BarcodeOut = 0x8; - BarcodeCycleCount = 0; - return(1); -} - -static void BarcodeIRQHook(int a) { - BandaiIRQHook(a); - - BarcodeCycleCount += a; - - if (BarcodeCycleCount >= 1000) { - BarcodeCycleCount -= 1000; - if (BarcodeData[BarcodeReadPos] == 0xFF) { - BarcodeOut = 0; - } else { - BarcodeOut = (BarcodeData[BarcodeReadPos] ^ 1) << 3; - BarcodeReadPos++; - } - } -} - -static DECLFR(BarcodeRead) { - return BarcodeOut; -} - -static void M157Power(void) { - IRQa = 0; - BarcodeData[0] = 0xFF; - BarcodeReadPos = 0; - BarcodeOut = 0; - BarcodeCycleCount = 0; - - Sync(); - - SetWriteHandler(0x6000, 0xFFFF, BandaiWrite); - SetReadHandler(0x6000, 0x7FFF, BarcodeRead); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -void Mapper157_Init(CartInfo *info) { - is153 = 1; - info->Power = M157Power; - MapIRQHook = BarcodeIRQHook; - - GameInfo->cspecial = SIS_DATACH; - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/bb.cpp b/branches/sdl2/src/boards/bb.cpp deleted file mode 100644 index cdea2c20..00000000 --- a/branches/sdl2/src/boards/bb.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, chr; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &chr, 1, "CHR" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg & 3); - setprg32(0x8000, ~0); - setchr8(chr & 3); -} - -static DECLFW(UNLBBWrite) { - if ((A & 0x9000) == 0x8000) - reg = chr = V; - else - chr = V & 1; // hacky hacky, ProWres simplified FDS conversion 2-in-1 mapper - Sync(); -} - -static void UNLBBPower(void) { - chr = 0; - reg = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLBBWrite); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLBB_Init(CartInfo *info) { - info->Power = UNLBBPower; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/bmc13in1jy110.cpp b/branches/sdl2/src/boards/bmc13in1jy110.cpp deleted file mode 100644 index f4190451..00000000 --- a/branches/sdl2/src/boards/bmc13in1jy110.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * BMC 42-in-1 "reset switch" type - */ - -#include "mapinc.h" - -static uint8 bank_mode; -static uint8 bank_value; -static uint8 prgb[4]; -static SFORMAT StateRegs[] = -{ - { &bank_mode, 1, "BNM" }, - { &bank_value, 1, "BMV" }, - { prgb, 4, "PRGB" }, - { 0 } -}; - -static void Sync(void) { -// FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]); - switch (bank_mode & 7) { - case 0: - setprg32(0x8000, bank_value & 7); break; - case 1: - setprg16(0x8000, ((8 + (bank_value & 7)) >> 1) + prgb[1]); - setprg16(0xC000, (bank_value & 7) >> 1); - case 4: - setprg32(0x8000, 8 + (bank_value & 7)); break; - case 5: - setprg16(0x8000, ((8 + (bank_value & 7)) >> 1) + prgb[1]); - setprg16(0xC000, ((8 + (bank_value & 7)) >> 1) + prgb[3]); - case 2: - setprg8(0x8000, prgb[0] >> 2); - setprg8(0xa000, prgb[1]); - setprg8(0xc000, prgb[2]); - setprg8(0xe000, ~0); - break; - case 3: - setprg8(0x8000, prgb[0]); - setprg8(0xa000, prgb[1]); - setprg8(0xc000, prgb[2]); - setprg8(0xe000, prgb[3]); - break; - } -} - -static DECLFW(BMC13in1JY110Write) { -// FCEU_printf("%04x:%04x\n",A,V); - switch (A) { - case 0x8000: - case 0x8001: - case 0x8002: - case 0x8003: prgb[A & 3] = V; break; - case 0xD000: bank_mode = V; break; - case 0xD001: setmirror(V & 3); - case 0xD002: break; - case 0xD003: bank_value = V; break; - } - Sync(); -} - -static void BMC13in1JY110Power(void) { - prgb[0] = prgb[1] = prgb[2] = prgb[3] = 0; - bank_mode = 0; - bank_value = 0; - setprg32(0x8000, 0); - setchr8(0); - SetWriteHandler(0x8000, 0xFFFF, BMC13in1JY110Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void BMC13in1JY110_Init(CartInfo *info) { - info->Power = BMC13in1JY110Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/bmc42in1r.cpp b/branches/sdl2/src/boards/bmc42in1r.cpp deleted file mode 100644 index 06d851ae..00000000 --- a/branches/sdl2/src/boards/bmc42in1r.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * Copyright (C) 2009 qeed - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * BMC 42-in-1 "reset switch" + "select switch" - * - */ - -#include "mapinc.h" - -static uint8 isresetbased = 0; -static uint8 latche[2], reset; -static SFORMAT StateRegs[] = -{ - { &reset, 1, "RST" }, - { latche, 2, "LATC" }, - { 0 } -}; - -static void Sync(void) { - uint8 bank; - if (isresetbased) - bank = (latche[0] & 0x1f) | (reset << 5) | ((latche[1] & 1) << 6); - else - bank = (latche[0] & 0x1f) | ((latche[0] & 0x80) >> 2) | ((latche[1] & 1) << 6); - if (!(latche[0] & 0x20)) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - setmirror((latche[0] >> 6) & 1); - setchr8(0); -} - -static DECLFW(M226Write) { - latche[A & 1] = V; - Sync(); -} - -static void M226Power(void) { - latche[0] = latche[1] = reset = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M226Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper226_Init(CartInfo *info) { - isresetbased = 0; - info->Power = M226Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} - -static void M233Reset(void) { - reset ^= 1; - Sync(); -} - -void Mapper233_Init(CartInfo *info) { - isresetbased = 1; - info->Power = M226Power; - info->Reset = M233Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/bmc64in1nr.cpp b/branches/sdl2/src/boards/bmc64in1nr.cpp deleted file mode 100644 index 11102a32..00000000 --- a/branches/sdl2/src/boards/bmc64in1nr.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * BMC 42-in-1 "reset switch" type - */ - -#include "mapinc.h" - -static uint8 regs[4]; - -static SFORMAT StateRegs[] = -{ - { regs, 4, "REGS" }, - { 0 } -}; - -static void Sync(void) { - if (regs[0] & 0x80) { - if (regs[1] & 0x80) - setprg32(0x8000, regs[1] & 0x1F); - else{ - int bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else { - int bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); - setprg16(0xC000, bank); - } - if (regs[0] & 0x20) - setmirror(MI_H); - else - setmirror(MI_V); - setchr8((regs[2] << 2) | ((regs[0] >> 1) & 3)); -} - -static DECLFW(BMC64in1nrWriteLo) { - regs[A & 3] = V; - Sync(); -} - -static DECLFW(BMC64in1nrWriteHi) { - regs[3] = V; - Sync(); -} - -static void BMC64in1nrPower(void) { - regs[0] = 0x80; - regs[1] = 0x43; - regs[2] = regs[3] = 0; - Sync(); - SetWriteHandler(0x5000, 0x5003, BMC64in1nrWriteLo); - SetWriteHandler(0x8000, 0xFFFF, BMC64in1nrWriteHi); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void BMC64in1nr_Init(CartInfo *info) { - info->Power = BMC64in1nrPower; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} - - diff --git a/branches/sdl2/src/boards/bmc70in1.cpp b/branches/sdl2/src/boards/bmc70in1.cpp deleted file mode 100644 index 95c34370..00000000 --- a/branches/sdl2/src/boards/bmc70in1.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 is_large_banks, hw_switch; -static uint8 large_bank; -static uint8 prg_bank; -static uint8 chr_bank; -static uint8 bank_mode; -static uint8 mirroring; -static SFORMAT StateRegs[] = -{ - { &large_bank, 1, "LB" }, - { &hw_switch, 1, "DPSW" }, - { &prg_bank, 1, "PRG" }, - { &chr_bank, 1, "CHR" }, - { &bank_mode, 1, "BM" }, - { &mirroring, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - switch (bank_mode) { - case 0x00: - case 0x10: - setprg16(0x8000, large_bank | prg_bank); - setprg16(0xC000, large_bank | 7); - break; - case 0x20: - setprg32(0x8000, (large_bank | prg_bank) >> 1); - break; - case 0x30: - setprg16(0x8000, large_bank | prg_bank); - setprg16(0xC000, large_bank | prg_bank); - break; - } - setmirror(mirroring); - if (!is_large_banks) - setchr8(chr_bank); -} - -static DECLFR(BMC70in1Read) { - if (bank_mode == 0x10) -// if(is_large_banks) - return CartBR((A & 0xFFF0) | hw_switch); -// else -// return CartBR((A&0xFFF0)|hw_switch); - else - return CartBR(A); -} - -static DECLFW(BMC70in1Write) { - if (A & 0x4000) { - bank_mode = A & 0x30; - prg_bank = A & 7; - } else { - mirroring = ((A & 0x20) >> 5) ^ 1; - if (is_large_banks) - large_bank = (A & 3) << 3; - else - chr_bank = A & 7; - } - Sync(); -} - -static void BMC70in1Reset(void) { - bank_mode = 0; - large_bank = 0; - Sync(); - hw_switch++; - hw_switch &= 0xf; -} - -static void BMC70in1Power(void) { - setchr8(0); - bank_mode = 0; - large_bank = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, BMC70in1Read); - SetWriteHandler(0x8000, 0xffff, BMC70in1Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void BMC70in1_Init(CartInfo *info) { - is_large_banks = 0; - hw_switch = 0xd; - info->Power = BMC70in1Power; - info->Reset = BMC70in1Reset; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void BMC70in1B_Init(CartInfo *info) { - is_large_banks = 1; - hw_switch = 0x6; - info->Power = BMC70in1Power; - info->Reset = BMC70in1Reset; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/bonza.cpp b/branches/sdl2/src/boards/bonza.cpp deleted file mode 100644 index 58f04f2e..00000000 --- a/branches/sdl2/src/boards/bonza.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -#define CARD_EXTERNAL_INSERED 0x80 - -static uint8 prg_reg; -static uint8 chr_reg; -static SFORMAT StateRegs[] = -{ - { &prg_reg, 1, "PREG" }, - { &chr_reg, 1, "CREG" }, - { 0 } -}; - -/* - -cmd[0] = response on/off - 0x00 - on - 0x80 - off -cmd[1] = cmd - - -_GET_CHALLENGE: .BYTE 0,$B4, 0, 0,$62 - -_SELECT_FILE_1_0200: .BYTE 0,$A4, 1, 0, 2, 2, 0 -_SELECT_FILE_2_0201: .BYTE 0,$A4, 2, 0, 2, 2, 1 -_SELECT_FILE_2_0203: .BYTE 0,$A4, 2, 0, 2, 2, 3 -_SELECT_FILE_2_0204: .BYTE 0,$A4, 2, 0, 2, 2, 4 -_SELECT_FILE_2_0205: .BYTE 0,$A4, 2, 0, 2, 2, 5 -_SELECT_FILE_2_3F04: .BYTE 0,$A4, 2, 0, 2,$3F, 4 -_SELECT_FILE_2_4F00: .BYTE 0,$A4, 2, 0, 2,$4F, 0 - -_READ_BINARY_5: .BYTE 0,$B0,$85, 0, 2 -_READ_BINARY_6: .BYTE 0,$B0,$86, 0, 4 -_READ_BINARY_6_0: .BYTE 0,$B0,$86, 0,$18 -_READ_BINARY_0: .BYTE 0,$B0, 0, 2, 3 -_READ_BINARY_0_0: .BYTE 0,$B0, 0, 0, 4 -_READ_BINARY_0_1: .BYTE 0,$B0, 0, 0, $C -_READ_BINARY_0_2: .BYTE 0,$B0, 0, 0,$10 - -_UPDATE_BINARY: .BYTE 0,$D6, 0, 0, 4 -_UPDATE_BINARY_0: .BYTE 0,$D6, 0, 0,$10 - -_GET_RESPONSE: .BYTE $80,$C0, 2,$A1, 8 -_GET_RESPONSE_0: .BYTE 0,$C0, 0, 0, 2 -_GET_RESPONSE_1: .BYTE 0,$C0, 0, 0, 6 -_GET_RESPONSE_2: .BYTE 0,$C0, 0, 0, 8 -_GET_RESPONSE_3: .BYTE 0,$C0, 0, 0, $C -_GET_RESPONSE_4: .BYTE 0,$C0, 0, 0,$10 - -byte_8C0B: .BYTE $80,$30, 0, 2, $A, 0, 1 -byte_8C48: .BYTE $80,$32, 0, 1, 4 -byte_8C89: .BYTE $80,$34, 0, 0, 8, 0, 0 -byte_8D01: .BYTE $80,$36, 0, 0, $C -byte_8CA7: .BYTE $80,$38, 0, 2, 4 -byte_8BEC: .BYTE $80,$3A, 0, 3, 0 - -byte_89A0: .BYTE 0,$48, 0, 0, 6 -byte_8808: .BYTE 0,$54, 0, 0,$1C -byte_89BF: .BYTE 0,$58, 0, 0,$1C - -_MANAGE_CHANNEL: .BYTE 0,$70, 0, 0, 8 -byte_8CE5: .BYTE 0,$74, 0, 0,$12 -byte_8C29: .BYTE 0,$76, 0, 0, 8 -byte_8CC6: .BYTE 0,$78, 0, 0,$12 -*/ - -static uint8 sim0reset[0x1F] = { - 0x3B, 0xE9, 0x00, 0xFF, 0xC1, 0x10, 0x31, 0xFE, - 0x55, 0xC8, 0x10, 0x20, 0x55, 0x47, 0x4F, 0x53, - 0x56, 0x53, 0x43, 0xAD, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 -}; - -static void Sync(void) { - setprg32(0x8000, prg_reg); - setchr8(chr_reg); -} - -static void StateRestore(int version) { - Sync(); -} - -static DECLFW(M216WriteHi) { - prg_reg = A & 1; - chr_reg = (A & 0x0E) >> 1; - Sync(); -} - -static DECLFW(M216Write5000) { -// FCEU_printf("WRITE: %04x:%04x (PC=%02x cnt=%02x)\n",A,V,X.PC,sim0bcnt); -} - -static DECLFR(M216Read5000) { -// FCEU_printf("READ: %04x PC=%04x out=%02x byte=%02x cnt=%02x bit=%02x\n",A,X.PC,sim0out,sim0byte,sim0bcnt,sim0bit); - return 0; -} - -static void Power(void) { - prg_reg = 0; - chr_reg = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M216WriteHi); - SetWriteHandler(0x5000, 0x5000, M216Write5000); - SetReadHandler(0x5000, 0x5000, M216Read5000); -} - - -void Mapper216_Init(CartInfo *info) { - info->Power = Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/bs-5.cpp b/branches/sdl2/src/boards/bs-5.cpp deleted file mode 100644 index 5e2ff1fe..00000000 --- a/branches/sdl2/src/boards/bs-5.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg_prg[4]; -static uint8 reg_chr[4]; -static uint8 dip_switch; - -static SFORMAT StateRegs[] = -{ - { reg_prg, 4, "PREG" }, - { reg_chr, 4, "CREG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, reg_prg[0]); - setprg8(0xa000, reg_prg[1]); - setprg8(0xc000, reg_prg[2]); - setprg8(0xe000, reg_prg[3]); - setchr2(0x0000, reg_chr[0]); - setchr2(0x0800, reg_chr[1]); - setchr2(0x1000, reg_chr[2]); - setchr2(0x1800, reg_chr[3]); - setmirror(MI_V); -} - -static DECLFW(MBS5Write) { - int bank_sel = (A & 0xC00) >> 10; - switch (A & 0xF000) { - case 0x8000: - reg_chr[bank_sel] = A & 0x1F; - break; - case 0xA000: - if (A & (1 << (dip_switch + 4))) - reg_prg[bank_sel] = A & 0x0F; - break; - } - Sync(); -} - -static void MBS5Reset(void) { - dip_switch++; - dip_switch &= 3; - reg_prg[0] = reg_prg[1] = reg_prg[2] = reg_prg[3] = ~0; - Sync(); -} - -static void MBS5Power(void) { - dip_switch = 0; - reg_prg[0] = reg_prg[1] = reg_prg[2] = reg_prg[3] = ~0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, MBS5Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void BMCBS5_Init(CartInfo *info) { - info->Power = MBS5Power; - info->Reset = MBS5Reset; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/cityfighter.cpp b/branches/sdl2/src/boards/cityfighter.cpp deleted file mode 100644 index 32149596..00000000 --- a/branches/sdl2/src/boards/cityfighter.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * City Fighter IV sith Sound VRC4 hacked - */ - -#include "mapinc.h" - -static int32 IRQCount; -static uint8 IRQa; -static uint8 prg_reg, prg_mode, mirr; -static uint8 chr_reg[8]; -static writefunc pcmwrite; - -static SFORMAT StateRegs[] = -{ - { &IRQCount, 4, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { &prg_reg, 1, "PREG" }, - { &prg_mode, 1, "PMOD" }, - { &mirr, 1, "MIRR" }, - { chr_reg, 8, "CREG" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, prg_reg >> 2); - if (!prg_mode) - setprg8(0xC000, prg_reg); - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chr_reg[i]); - switch (mirr) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(UNLCITYFIGHTWrite) { - //FCEU_printf("%04x %02x",A,V); - switch (A & 0xF00C) { - case 0x9000: prg_reg = V & 0xC; mirr = V & 3; break; - case 0x9004: - case 0x9008: - case 0x900C: - if (A & 0x800) - pcmwrite(0x4011, (V & 0xf) << 3); - else - prg_reg = V & 0xC; - break; - case 0xC000: - case 0xC004: - case 0xC008: - case 0xC00C: prg_mode = V & 1; break; - case 0xD000: chr_reg[0] = (chr_reg[0] & 0xF0) | (V & 0x0F); break; - case 0xD004: chr_reg[0] = (chr_reg[0] & 0x0F) | (V << 4); break; - case 0xD008: chr_reg[1] = (chr_reg[1] & 0xF0) | (V & 0x0F); break; - case 0xD00C: chr_reg[1] = (chr_reg[1] & 0x0F) | (V << 4); break; - case 0xA000: chr_reg[2] = (chr_reg[2] & 0xF0) | (V & 0x0F); break; - case 0xA004: chr_reg[2] = (chr_reg[2] & 0x0F) | (V << 4); break; - case 0xA008: chr_reg[3] = (chr_reg[3] & 0xF0) | (V & 0x0F); break; - case 0xA00C: chr_reg[3] = (chr_reg[3] & 0x0F) | (V << 4); break; - case 0xB000: chr_reg[4] = (chr_reg[4] & 0xF0) | (V & 0x0F); break; - case 0xB004: chr_reg[4] = (chr_reg[4] & 0x0F) | (V << 4); break; - case 0xB008: chr_reg[5] = (chr_reg[5] & 0xF0) | (V & 0x0F); break; - case 0xB00C: chr_reg[5] = (chr_reg[5] & 0x0F) | (V << 4); break; - case 0xE000: chr_reg[6] = (chr_reg[6] & 0xF0) | (V & 0x0F); break; - case 0xE004: chr_reg[6] = (chr_reg[6] & 0x0F) | (V << 4); break; - case 0xE008: chr_reg[7] = (chr_reg[7] & 0xF0) | (V & 0x0F); break; - case 0xE00C: chr_reg[7] = (chr_reg[7] & 0x0F) | (V << 4); break; - case 0xF000: IRQCount = ((IRQCount & 0x1E0) | ((V & 0xF) << 1)); break; - case 0xF004: IRQCount = ((IRQCount & 0x1E) | ((V & 0xF) << 5)); break; - case 0xF008: IRQa = V & 2; X6502_IRQEnd(FCEU_IQEXT); break; - default: - break; - } - Sync(); -} - -static void UNLCITYFIGHTIRQ(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void UNLCITYFIGHTPower(void) { - prg_reg = 0; - Sync(); - pcmwrite = GetWriteHandler(0x4011); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLCITYFIGHTWrite); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLCITYFIGHT_Init(CartInfo *info) { - info->Power = UNLCITYFIGHTPower; - MapIRQHook = UNLCITYFIGHTIRQ; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/dance2000.cpp b/branches/sdl2/src/boards/dance2000.cpp deleted file mode 100644 index eb1841d4..00000000 --- a/branches/sdl2/src/boards/dance2000.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 prg, mode; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint32 lastnt = 0; - -static SFORMAT StateRegs[] = -{ - { &prg, 1, "REGS" }, - { &mode, 1, "MODE" }, - { &lastnt, 4, "LSNT" }, - { 0 } -}; - -static void Sync(void) { - setmirror((mode ^ 1) & 1); - setprg8r(0x10, 0x6000, 0); - setchr4(0x0000, lastnt); - setchr4(0x1000, 1); - if (mode & 4) - setprg32(0x8000, prg & 7); - else { - setprg16(0x8000, prg & 0x0f); - setprg16(0xC000, 0); - } -} - -static DECLFW(UNLD2000Write) { - switch (A) { - case 0x5000: prg = V; Sync(); break; - case 0x5200: mode = V; if (mode & 4) Sync(); break; - } -} - -static DECLFR(UNLD2000Read) { - if (prg & 0x40) - return X.DB; - else - return CartBR(A); -} - -static void UNLD2000Power(void) { - prg = mode = 0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, UNLD2000Read); - SetWriteHandler(0x5000, 0x5FFF, UNLD2000Write); -} - -static void UNL2000Hook(uint32 A) { - if (mode & 2) { - if ((A & 0x3000) == 0x2000) { - uint32 curnt = A & 0x800; - if (curnt != lastnt) { - setchr4(0x0000, curnt >> 11); - lastnt = curnt; - } - } - } else { - lastnt = 0; - setchr4(0x0000, 0); - } -} - -static void UNLD2000Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLD2000_Init(CartInfo *info) { - info->Power = UNLD2000Power; - info->Close = UNLD2000Close; - PPU_hook = UNL2000Hook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/datalatch.cpp b/branches/sdl2/src/boards/datalatch.cpp deleted file mode 100644 index 0665eeb6..00000000 --- a/branches/sdl2/src/boards/datalatch.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "../ines.h" - -static uint8 latche, latcheinit, bus_conflict; -static uint16 addrreg0, addrreg1; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static void (*WSync)(void); - -static DECLFW(LatchWrite) { -// FCEU_printf("bs %04x %02x\n",A,V); - if (bus_conflict) - latche = (V == CartBR(A)) ? V : 0; - else - latche = V; - WSync(); -} - -static void LatchPower(void) { - latche = latcheinit; - WSync(); - if (WRAM) { - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } else { - SetReadHandler(0x8000, 0xFFFF, CartBR); - } - SetWriteHandler(addrreg0, addrreg1, LatchWrite); -} - -static void LatchClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram, uint8 busc) { - bus_conflict = busc; - latcheinit = init; - addrreg0 = adr0; - addrreg1 = adr1; - WSync = proc; - info->Power = LatchPower; - info->Close = LatchClose; - GameStateRestore = StateRestore; - if (wram) { - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - AddExState(&latche, 1, 0, "LATC"); - AddExState(&bus_conflict, 1, 0, "BUSC"); -} - -//------------------ Map 0 --------------------------- - -#ifdef DEBUG_MAPPER -static DECLFW(NROMWrite) { - FCEU_printf("bs %04x %02x\n", A, V); - CartBW(A, V); -} -#endif - -static void NROMPower(void) { - setprg8r(0x10, 0x6000, 0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); - - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - #ifdef DEBUG_MAPPER - SetWriteHandler(0x4020, 0xFFFF, NROMWrite); - #endif -} - -void NROM_Init(CartInfo *info) { - info->Power = NROMPower; - info->Close = LatchClose; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); -} - -//------------------ Map 2 --------------------------- - -static void UNROMSync(void) { -// static uint32 mirror_in_use = 0; -// if (PRGsize[0] <= 128 * 1024) { -// setprg16(0x8000, latche & 0x7); -// if (latche & 8) mirror_in_use = 1; -// if (mirror_in_use) -// setmirror(((latche >> 3) & 1) ^ 1); // Higway Star Hacked mapper, disabled till new mapper defined -// } else - setprg16(0x8000, latche); - setprg16(0xc000, ~0); - setchr8(0); -} - -void UNROM_Init(CartInfo *info) { - Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0, 1); -} - -//------------------ Map 3 --------------------------- - -static void CNROMSync(void) { - setchr8(latche); - setprg32(0x8000, 0); - setprg8r(0x10, 0x6000, 0); // Hayauchy IGO uses 2Kb or RAM -} - -void CNROM_Init(CartInfo *info) { - Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, 1); -} - -//------------------ Map 7 --------------------------- - -static void ANROMSync() { - setprg32(0x8000, latche & 0xF); - setmirror(MI_0 + ((latche >> 4) & 1)); - setchr8(0); -} - -void ANROM_Init(CartInfo *info) { - Latch_Init(info, ANROMSync, 0, 0x4020, 0xFFFF, 0, 0); -} - -//------------------ Map 8 --------------------------- - -static void M8Sync() { - setprg16(0x8000, latche >> 3); - setprg16(0xc000, 1); - setchr8(latche & 3); -} - -void Mapper8_Init(CartInfo *info) { - Latch_Init(info, M8Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 11 --------------------------- - -static void M11Sync(void) { - setprg32(0x8000, latche & 0xF); - setchr8(latche >> 4); -} - -void Mapper11_Init(CartInfo *info) { - Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -void Mapper144_Init(CartInfo *info) { - Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0, 0); -} - -//------------------ Map 13 --------------------------- - -static void CPROMSync(void) { - setchr4(0x0000, 0); - setchr4(0x1000, latche & 3); - setprg32(0x8000, 0); -} - -void CPROM_Init(CartInfo *info) { - Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 29 --------------------------- //Used by Glider, http://www.retrousb.com/product_info.php?cPath=30&products_id=58 - -static void M29Sync() { - setprg16(0x8000, (latche & 0x1C) >> 2); - setprg16(0xc000, ~0); - setchr8r(0, latche & 3); - setprg8r(0x10, 0x6000, 0); -} - -void Mapper29_Init(CartInfo *info) { - Latch_Init(info, M29Sync, 0, 0x8000, 0xFFFF, 1, 0); -} - - -//------------------ Map 38 --------------------------- - -static void M38Sync(void) { - setprg32(0x8000, latche & 3); - setchr8(latche >> 2); -} - -void Mapper38_Init(CartInfo *info) { - Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0, 0); -} - -//------------------ Map 66 --------------------------- - -static void MHROMSync(void) { - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xF); -} - -void MHROM_Init(CartInfo *info) { - Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 70 --------------------------- - -static void M70Sync() { - setprg16(0x8000, latche >> 4); - setprg16(0xc000, ~0); - setchr8(latche & 0xf); -} - -void Mapper70_Init(CartInfo *info) { - Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 78 --------------------------- -/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */ -static void M78Sync() { - setprg16(0x8000, (latche & 7)); - setprg16(0xc000, ~0); - setchr8(latche >> 4); - setmirror(MI_0 + ((latche >> 3) & 1)); -} - -void Mapper78_Init(CartInfo *info) { - Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 86 --------------------------- - -static void M86Sync(void) { - setprg32(0x8000, (latche >> 4) & 3); - setchr8((latche & 3) | ((latche >> 4) & 4)); -} - -void Mapper86_Init(CartInfo *info) { - Latch_Init(info, M86Sync, ~0, 0x6000, 0x6FFF, 0, 0); -} - -//------------------ Map 87 --------------------------- - -static void M87Sync(void) { - setprg32(0x8000, 0); - setchr8(((latche >> 1) & 1) | ((latche << 1) & 2)); -} - -void Mapper87_Init(CartInfo *info) { - Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0, 0); -} - -//------------------ Map 89 --------------------------- - -static void M89Sync(void) { - setprg16(0x8000, (latche >> 4) & 7); - setprg16(0xc000, ~0); - setchr8((latche & 7) | ((latche >> 4) & 8)); - setmirror(MI_0 + ((latche >> 3) & 1)); -} - -void Mapper89_Init(CartInfo *info) { - Latch_Init(info, M89Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 93 --------------------------- - -static void SSUNROMSync(void) { - setprg16(0x8000, latche >> 4); - setprg16(0xc000, ~0); - setchr8(0); -} - -void SUNSOFT_UNROM_Init(CartInfo *info) { - Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 94 --------------------------- - -static void M94Sync(void) { - setprg16(0x8000, latche >> 2); - setprg16(0xc000, ~0); - setchr8(0); -} - -void Mapper94_Init(CartInfo *info) { - Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 97 --------------------------- - -static void M97Sync(void) { - setchr8(0); - setprg16(0x8000, ~0); - setprg16(0xc000, latche & 15); - switch (latche >> 6) { - case 0: break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_V); break; - case 3: break; - } - setchr8(((latche >> 1) & 1) | ((latche << 1) & 2)); -} - -void Mapper97_Init(CartInfo *info) { - Latch_Init(info, M97Sync, ~0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 101 --------------------------- - -static void M101Sync(void) { - setprg32(0x8000, 0); - setchr8(latche); -} - -void Mapper101_Init(CartInfo *info) { - Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 107 --------------------------- - -static void M107Sync(void) { - setprg32(0x8000, (latche >> 1) & 3); - setchr8(latche & 7); -} - -void Mapper107_Init(CartInfo *info) { - Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 113 --------------------------- - -static void M113Sync(void) { - setprg32(0x8000, (latche >> 3) & 7); - setchr8(((latche >> 3) & 8) | (latche & 7)); -// setmirror(latche>>7); // only for HES 6in1 -} - -void Mapper113_Init(CartInfo *info) { - Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0, 0); -} - -//------------------ Map 140 --------------------------- - -void Mapper140_Init(CartInfo *info) { - Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 152 --------------------------- - -static void M152Sync() { - setprg16(0x8000, (latche >> 4) & 7); - setprg16(0xc000, ~0); - setchr8(latche & 0xf); - setmirror(MI_0 + ((latche >> 7) & 1)); /* Saint Seiya...hmm. */ -} - -void Mapper152_Init(CartInfo *info) { - Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 180 --------------------------- - -static void M180Sync(void) { - setprg16(0x8000, 0); - setprg16(0xc000, latche); - setchr8(0); -} - -void Mapper180_Init(CartInfo *info) { - Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 184 --------------------------- - -static void M184Sync(void) { - setchr4(0x0000, latche); - setchr4(0x1000, latche >> 4); - setprg32(0x8000, 0); -} - -void Mapper184_Init(CartInfo *info) { - Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0, 0); -} - -//------------------ Map 203 --------------------------- - -static void M203Sync(void) { - setprg16(0x8000, (latche >> 2) & 3); - setprg16(0xC000, (latche >> 2) & 3); - setchr8(latche & 3); -} - -void Mapper203_Init(CartInfo *info) { - Latch_Init(info, M203Sync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ Map 240 --------------------------- - -static void M240Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, latche >> 4); - setchr8(latche & 0xF); -} - -void Mapper240_Init(CartInfo *info) { - Latch_Init(info, M240Sync, 0, 0x4020, 0x5FFF, 1, 0); -} - -//------------------ Map 241 --------------------------- -// Mapper 7 mostly, but with SRAM or maybe prot circuit -// figure out, which games do need 5xxx area reading - -static void M241Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - if (latche & 0x80) - setprg32(0x8000, latche | 8); // no 241 actually, but why not afterall? - else - setprg32(0x8000, latche); -} - -void Mapper241_Init(CartInfo *info) { - Latch_Init(info, M241Sync, 0, 0x8000, 0xFFFF, 1, 0); -} - -//------------------ A65AS --------------------------- - -// actually, there is two cart in one... First have extra mirroring -// mode (one screen) and 32K bankswitching, second one have only -// 16 bankswitching mode and normal mirroring... But there is no any -// correlations between modes and they can be used in one mapper code. - -static void BMCA65ASSync(void) { - if (latche & 0x40) - setprg32(0x8000, (latche >> 1) & 0x0F); - else { - setprg16(0x8000, ((latche & 0x30) >> 1) | (latche & 7)); - setprg16(0xC000, ((latche & 0x30) >> 1) | 7); - } - setchr8(0); - if (latche & 0x80) - setmirror(MI_0 + (((latche >> 5) & 1))); - else - setmirror(((latche >> 3) & 1) ^ 1); -} - -void BMCA65AS_Init(CartInfo *info) { - Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0, 0); -} - -//------------------ BMC-11160 --------------------------- -// Simple BMC discrete mapper by TXC - -static void BMC11160Sync(void) { - uint32 bank = (latche >> 4) & 7; - setprg32(0x8000, bank); - setchr8((bank << 2) | (latche & 3)); - setmirror((latche >> 7) & 1); -} - -void BMC11160_Init(CartInfo *info) { - Latch_Init(info, BMC11160Sync, 0, 0x8000, 0xFFFF, 0, 0); -} diff --git a/branches/sdl2/src/boards/dream.cpp b/branches/sdl2/src/boards/dream.cpp deleted file mode 100644 index c42fa0f9..00000000 --- a/branches/sdl2/src/boards/dream.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 latche; - -static void Sync(void) { - setprg16(0x8000, latche); - setprg16(0xC000, 8); -} - -static DECLFW(DREAMWrite) { - latche = V & 7; - Sync(); -} - -static void DREAMPower(void) { - latche = 0; - Sync(); - setchr8(0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x5020, 0x5020, DREAMWrite); -} - -static void Restore(int version) { - Sync(); -} - -void DreamTech01_Init(CartInfo *info) { - GameStateRestore = Restore; - info->Power = DREAMPower; - AddExState(&latche, 1, 0, "LATC"); -} diff --git a/branches/sdl2/src/boards/edu2000.cpp b/branches/sdl2/src/boards/edu2000.cpp deleted file mode 100644 index a8726391..00000000 --- a/branches/sdl2/src/boards/edu2000.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 *WRAM = NULL; -static uint8 reg; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, (reg & 0xC0) >> 6); - setprg32(0x8000, reg & 0x1F); -// setmirror(((reg&0x20)>>5)); -} - -static DECLFW(UNLEDU2000HiWrite) { -// FCEU_printf("%04x:%02x\n",A,V); - reg = V; - Sync(); -} - -static void UNLEDU2000Power(void) { - setmirror(MI_0); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0xFFFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, UNLEDU2000HiWrite); - reg = 0; - Sync(); -} - -static void UNLEDU2000Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void UNLEDU2000Restore(int version) { - Sync(); -} - -void UNLEDU2000_Init(CartInfo *info) { - info->Power = UNLEDU2000Power; - info->Close = UNLEDU2000Close; - GameStateRestore = UNLEDU2000Restore; - WRAM = (uint8*)FCEU_gmalloc(32768); - SetupCartPRGMapping(0x10, WRAM, 32768, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = 32768; - } - AddExState(WRAM, 32768, 0, "WRAM"); - AddExState(StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/emu2413.c b/branches/sdl2/src/boards/emu2413.c deleted file mode 100644 index 240aeb00..00000000 --- a/branches/sdl2/src/boards/emu2413.c +++ /dev/null @@ -1,1078 +0,0 @@ -/*********************************************************************************** - - emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 - - 2001 01-08 : Version 0.10 -- 1st version. - 2001 01-15 : Version 0.20 -- semi-public version. - 2001 01-16 : Version 0.30 -- 1st public version. - 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. - : Version 0.32 -- LPF implemented. - 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. - -- Fixed the LFO bug. - 2001 01-24 : Version 0.35 -- Fixed the drum problem, - support undocumented EG behavior. - 2001 02-02 : Version 0.38 -- Improved the performance. - Fixed the hi-hat and cymbal model. - Fixed the default percussive datas. - Noise reduction. - Fixed the feedback problem. - 2001 03-03 : Version 0.39 -- Fixed some drum bugs. - Improved the performance. - 2001 03-04 : Version 0.40 -- Improved the feedback. - Change the default table size. - Clock and Rate can be changed during play. - 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. - Added VRC7 patch (OPLL_reset_patch is changed). - Fixed OPLL_reset() bug. - Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. - Added OPLL_writeIO. - 2001 09-28 : Version 0.51 -- Removed the noise table. - 2002 01-28 : Version 0.52 -- Added Stereo mode. - 2002 02-07 : Version 0.53 -- Fixed some drum bugs. - 2002 02-20 : Version 0.54 -- Added the best quality mode. - 2002 03-02 : Version 0.55 -- Removed OPLL_init & OPLL_close. - 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. - - 2004 01-24 : Modified by xodnizel to remove code not needed for the VRC7, among other things. - - References: - fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). - fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. - s_opl.c -- 2001 written by Mamiya (NEZplug development). - fmgen.cpp -- 1999,2000 written by cisc. - fmpac.ill -- 2000 created by NARUTO. - MSX-Datapack - YMU757 data sheet - YM2143 data sheet - -**************************************************************************************/ -#include -#include -#include -#include -#include "emu2413.h" - -static const unsigned char default_inst[15][8] = { - /* VRC7 instruments, January 17, 2004 update -Xodnizel */ - { 0x03, 0x21, 0x04, 0x06, 0x8D, 0xF2, 0x42, 0x17 }, - { 0x13, 0x41, 0x05, 0x0E, 0x99, 0x96, 0x63, 0x12 }, - { 0x31, 0x11, 0x10, 0x0A, 0xF0, 0x9C, 0x32, 0x02 }, - { 0x21, 0x61, 0x1D, 0x07, 0x9F, 0x64, 0x20, 0x27 }, - { 0x22, 0x21, 0x1E, 0x06, 0xF0, 0x76, 0x08, 0x28 }, - { 0x02, 0x01, 0x06, 0x00, 0xF0, 0xF2, 0x03, 0x95 }, - { 0x21, 0x61, 0x1C, 0x07, 0x82, 0x81, 0x16, 0x07 }, - { 0x23, 0x21, 0x1A, 0x17, 0xEF, 0x82, 0x25, 0x15 }, - { 0x25, 0x11, 0x1F, 0x00, 0x86, 0x41, 0x20, 0x11 }, - { 0x85, 0x01, 0x1F, 0x0F, 0xE4, 0xA2, 0x11, 0x12 }, - { 0x07, 0xC1, 0x2B, 0x45, 0xB4, 0xF1, 0x24, 0xF4 }, - { 0x61, 0x23, 0x11, 0x06, 0x96, 0x96, 0x13, 0x16 }, - { 0x01, 0x02, 0xD3, 0x05, 0x82, 0xA2, 0x31, 0x51 }, - { 0x61, 0x22, 0x0D, 0x02, 0xC3, 0x7F, 0x24, 0x05 }, - { 0x21, 0x62, 0x0E, 0x00, 0xA1, 0xA0, 0x44, 0x17 }, -}; - -/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.)*/ -#define PG_BITS 9 -#define PG_WIDTH (1 << PG_BITS) - -/* Phase increment counter */ -#define DP_BITS 18 -#define DP_WIDTH (1 << DP_BITS) -#define DP_BASE_BITS (DP_BITS - PG_BITS) - -/* Dynamic range (Accuracy of sin table) */ -#define DB_BITS 8 -#define DB_STEP (48.0 / (1 << DB_BITS)) -#define DB_MUTE (1 << DB_BITS) - -/* Dynamic range of envelope */ -#define EG_STEP 0.375 -#define EG_BITS 7 -#define EG_MUTE (1 << EG_BITS) - -/* Dynamic range of total level */ -#define TL_STEP 0.75 -#define TL_BITS 6 -#define TL_MUTE (1 << TL_BITS) - -/* Dynamic range of sustine level */ -#define SL_STEP 3.0 -#define SL_BITS 4 -#define SL_MUTE (1 << SL_BITS) - -#define EG2DB(d) ((d) * (int32)(EG_STEP / DB_STEP)) -#define TL2EG(d) ((d) * (int32)(TL_STEP / EG_STEP)) -#define SL2EG(d) ((d) * (int32)(SL_STEP / EG_STEP)) - -#define DB_POS(x) (uint32)((x) / DB_STEP) -#define DB_NEG(x) (uint32)(DB_MUTE + DB_MUTE + (x) / DB_STEP) - -/* Bits for liner value */ -#define DB2LIN_AMP_BITS 11 -#define SLOT_AMP_BITS (DB2LIN_AMP_BITS) - -/* Bits for envelope phase incremental counter */ -#define EG_DP_BITS 22 -#define EG_DP_WIDTH (1 << EG_DP_BITS) - -/* Bits for Pitch and Amp modulator */ -#define PM_PG_BITS 8 -#define PM_PG_WIDTH (1 << PM_PG_BITS) -#define PM_DP_BITS 16 -#define PM_DP_WIDTH (1 << PM_DP_BITS) -#define AM_PG_BITS 8 -#define AM_PG_WIDTH (1 << AM_PG_BITS) -#define AM_DP_BITS 16 -#define AM_DP_WIDTH (1 << AM_DP_BITS) - -/* PM table is calcurated by PM_AMP * pow(2,PM_DEPTH*sin(x)/1200) */ -#define PM_AMP_BITS 8 -#define PM_AMP (1 << PM_AMP_BITS) - -/* PM speed(Hz) and depth(cent) */ -#define PM_SPEED 6.4 -#define PM_DEPTH 13.75 - -/* AM speed(Hz) and depth(dB) */ -#define AM_SPEED 3.7 -//#define AM_DEPTH 4.8 -#define AM_DEPTH 2.4 - -/* Cut the lower b bit(s) off. */ -#define HIGHBITS(c, b) ((c) >> (b)) - -/* Leave the lower b bit(s). */ -#define LOWBITS(c, b) ((c) & ((1 << (b)) - 1)) - -/* Expand x which is s bits to d bits. */ -#define EXPAND_BITS(x, s, d) ((x) << ((d) - (s))) - -/* Expand x which is s bits to d bits and fill expanded bits '1' */ -#define EXPAND_BITS_X(x, s, d) (((x) << ((d) - (s))) | ((1 << ((d) - (s))) - 1)) - -/* Adjust envelope speed which depends on sampling rate. */ -#define rate_adjust(x) (rate == 49716 ? x : (uint32)((double)(x) * clk / 72 / rate + 0.5)) /* added 0.5 to round the value*/ - -#define MOD(o, x) (&(o)->slot[(x) << 1]) -#define CAR(o, x) (&(o)->slot[((x) << 1) | 1]) - -#define BIT(s, b) (((s) >> (b)) & 1) - -/* Input clock */ -static uint32 clk = 844451141; -/* Sampling rate */ -static uint32 rate = 3354932; - -/* WaveTable for each envelope amp */ -static uint16 fullsintable[PG_WIDTH]; -static uint16 halfsintable[PG_WIDTH]; - -static uint16 *waveform[2] = { fullsintable, halfsintable }; - -/* LFO Table */ -static int32 pmtable[PM_PG_WIDTH]; -static int32 amtable[AM_PG_WIDTH]; - -/* Phase delta for LFO */ -static uint32 pm_dphase; -static uint32 am_dphase; - -/* dB to Liner table */ -static int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; - -/* Liner to Log curve conversion table (for Attack rate). */ -static uint16 AR_ADJUST_TABLE[1 << EG_BITS]; - -/* Definition of envelope mode */ -enum -{ SETTLE, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, FINISH }; - -/* Phase incr table for Attack */ -static uint32 dphaseARTable[16][16]; -/* Phase incr table for Decay and Release */ -static uint32 dphaseDRTable[16][16]; - -/* KSL + TL Table */ -static uint32 tllTable[16][8][1 << TL_BITS][4]; -static int32 rksTable[2][8][2]; - -/* Phase incr table for PG */ -static uint32 dphaseTable[512][8][16]; - -/*************************************************** - - Create tables - -****************************************************/ -INLINE static int32 Min(int32 i, int32 j) { - if (i < j) - return i; - else - return j; -} - -/* Table for AR to LogCurve. */ -static void makeAdjustTable(void) { - int32 i; - - AR_ADJUST_TABLE[0] = (1 << EG_BITS); - for (i = 1; i < 128; i++) - AR_ADJUST_TABLE[i] = (uint16)((double)(1 << EG_BITS) - 1 - (1 << EG_BITS) * log(i) / log(128)); -} - - -/* Table for dB(0 -- (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; - DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (int16)(-DB2LIN_TABLE[i]); - } -} - -/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); -} - -static void makeTllTable(void) { -#define dB2(x) ((x) * 2) - - static double kltable[16] = { - dB2(0.000), dB2(9.000), dB2(12.000), dB2(13.875), dB2(15.000), dB2(16.125), dB2(16.875), dB2(17.625), - dB2(18.000), dB2(18.750), dB2(19.125), dB2(19.500), dB2(19.875), dB2(20.250), dB2(20.625), dB2(21.000) - }; - - int32 tmp; - int32 fnum, block, TL, KL; - - for (fnum = 0; fnum < 16; fnum++) - for (block = 0; block < 8; block++) - for (TL = 0; TL < 64; TL++) - for (KL = 0; KL < 4; KL++) { - if (KL == 0) { - tllTable[fnum][block][TL][KL] = TL2EG(TL); - } else { - tmp = (int32)(kltable[fnum] - dB2(3.000) * (7 - block)); - if (tmp <= 0) - tllTable[fnum][block][TL][KL] = TL2EG(TL); - else - tllTable[fnum][block][TL][KL] = (uint32)((tmp >> (3 - KL)) / EG_STEP) + TL2EG(TL); - } - } -} - -/* Rate Table for Attack */ -static void makeDphaseARTable(void) { - int32 AR, Rks, RM, RL; - for (AR = 0; AR < 16; AR++) - for (Rks = 0; Rks < 16; Rks++) { - RM = AR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (AR) { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = 0; /*EG_DP_WIDTH;*/ - break; - default: - dphaseARTable[AR][Rks] = rate_adjust(3 * (RL + 4) << (RM + 1)); - break; - } - } -} - -/* Rate Table for Decay and Release */ -static void makeDphaseDRTable(void) { - int32 DR, Rks, RM, RL; - - for (DR = 0; DR < 16; DR++) - for (Rks = 0; Rks < 16; Rks++) { - RM = DR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (DR) { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: - dphaseDRTable[DR][Rks] = rate_adjust((RL + 4) << (RM - 1)); - break; - } - } -} - -static void makeRksTable(void) { - int32 fnum8, block, KR; - - for (fnum8 = 0; fnum8 < 2; fnum8++) - for (block = 0; block < 8; block++) - for (KR = 0; KR < 2; KR++) { - if (KR != 0) - rksTable[fnum8][block][KR] = (block << 1) + fnum8; - else - rksTable[fnum8][block][KR] = block >> 1; - } -} - -/************************************************************ - - Calc Parameters - -************************************************************/ - -INLINE static uint32 calc_eg_dphase(OPLL_SLOT * slot) { - switch (slot->eg_mode) { - case ATTACK: - return dphaseARTable[slot->patch.AR][slot->rks]; - - case DECAY: - return dphaseDRTable[slot->patch.DR][slot->rks]; - - case SUSHOLD: - return 0; - - case SUSTINE: - return dphaseDRTable[slot->patch.RR][slot->rks]; - - case RELEASE: - if (slot->sustine) - return dphaseDRTable[5][slot->rks]; - else if (slot->patch.EG) - return dphaseDRTable[slot->patch.RR][slot->rks]; - else - return dphaseDRTable[7][slot->rks]; - - case FINISH: - return 0; - - default: - return 0; - } -} - -/************************************************************* - - OPLL internal interfaces - -*************************************************************/ - -#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch.ML] -#define UPDATE_TLL(S) \ - (((S)->type == 0) ? \ - ((S)->tll = tllTable[((S)->fnum) >> 5][(S)->block][(S)->patch.TL][(S)->patch.KL]) : \ - ((S)->tll = tllTable[((S)->fnum) >> 5][(S)->block][(S)->volume][(S)->patch.KL])) -#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum) >> 8][(S)->block][(S)->patch.KR] -#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch.WF] -#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) -#define UPDATE_ALL(S) \ - UPDATE_PG(S); \ - UPDATE_TLL(S); \ - UPDATE_RKS(S); \ - UPDATE_WF(S); \ - UPDATE_EG(S) /* EG should be updated last. */ - - -/* Slot key on */ -INLINE static void slotOn(OPLL_SLOT * slot) { - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - slot->phase = 0; -} - -/* Slot key on without reseting the phase */ -INLINE static void slotOn2(OPLL_SLOT * slot) { - slot->eg_mode = ATTACK; - slot->eg_phase = 0; -} - -/* Slot key off */ -INLINE static void slotOff(OPLL_SLOT * slot) { - if (slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS(AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS)], EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; -} - -/* Channel key on */ -INLINE static void keyOn(OPLL * opll, int32 i) { - if (!opll->slot_on_flag[i * 2]) - slotOn(MOD(opll, i)); - if (!opll->slot_on_flag[i * 2 + 1]) - slotOn(CAR(opll, i)); - opll->key_status[i] = 1; -} - -/* Channel key off */ -INLINE static void keyOff(OPLL * opll, int32 i) { - if (opll->slot_on_flag[i * 2 + 1]) - slotOff(CAR(opll, i)); - opll->key_status[i] = 0; -} - -/* Set sustine parameter */ -INLINE static void setSustine(OPLL * opll, int32 c, int32 sustine) { - CAR(opll, c)->sustine = sustine; - if (MOD(opll, c)->type) - MOD(opll, c)->sustine = sustine; -} - -/* Volume : 6bit ( Volume register << 2 ) */ -INLINE static void setVolume(OPLL * opll, int32 c, int32 volume) { - CAR(opll, c)->volume = volume; -} - -INLINE static void setSlotVolume(OPLL_SLOT * slot, int32 volume) { - slot->volume = volume; -} - -/* Set F-Number ( fnum : 9bit ) */ -INLINE static void setFnumber(OPLL * opll, int32 c, int32 fnum) { - CAR(opll, c)->fnum = fnum; - MOD(opll, c)->fnum = fnum; -} - -/* Set Block data (block : 3bit ) */ -INLINE static void setBlock(OPLL * opll, int32 c, int32 block) { - CAR(opll, c)->block = block; - MOD(opll, c)->block = block; -} - -INLINE static void update_key_status(OPLL * opll) { int ch; - - for (ch = 0; ch < 6; ch++) - opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->HiFreq[ch]) & 0x10; -} - -/*********************************************************** - - Initializing - -***********************************************************/ - -static void OPLL_SLOT_reset(OPLL_SLOT * slot, int type) { - slot->type = type; - slot->sintbl = waveform[0]; - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = SETTLE; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->sustine = 0; - slot->fnum = 0; - slot->block = 0; - slot->volume = 0; - slot->pgout = 0; - slot->egout = 0; -} - -static void internal_refresh(void) { - makeDphaseTable(); - makeDphaseARTable(); - makeDphaseDRTable(); - pm_dphase = (uint32)rate_adjust(PM_SPEED * PM_DP_WIDTH / (clk / 72)); - am_dphase = (uint32)rate_adjust(AM_SPEED * AM_DP_WIDTH / (clk / 72)); -} - -static void maketables(uint32 c, uint32 r) { - if (c != clk) { - clk = c; - makePmTable(); - makeAmTable(); - makeDB2LinTable(); - makeAdjustTable(); - makeTllTable(); - makeRksTable(); - makeSinTable(); - //makeDefaultPatch (); - } - - if (r != rate) { - rate = r; - internal_refresh(); - } -} - -OPLL *OPLL_new(uint32 clk, uint32 rate) { - OPLL *opll; - - maketables(clk, rate); - - opll = (OPLL*)calloc(sizeof(OPLL), 1); - if (opll == NULL) - return NULL; - - opll->mask = 0; - - OPLL_reset(opll); - - return opll; -} - - -void OPLL_delete(OPLL * opll) { - free(opll); -} - -/* Reset whole of OPLL except patch datas. */ -void OPLL_reset(OPLL * opll) { - int32 i; - - if (!opll) - return; - - opll->adr = 0; - opll->out = 0; - - opll->pm_phase = 0; - opll->am_phase = 0; - - opll->mask = 0; - - for (i = 0; i < 12; i++) - OPLL_SLOT_reset(&opll->slot[i], i % 2); - - for (i = 0; i < 6; i++) { - opll->key_status[i] = 0; - //setPatch (opll, i, 0); - } - - for (i = 0; i < 0x40; i++) - OPLL_writeReg(opll, i, 0); - - opll->realstep = (uint32)((1 << 31) / rate); - opll->opllstep = (uint32)((1 << 31) / (clk / 72)); - opll->oplltime = 0; -} - -/* Force Refresh (When external program changes some parameters). */ -void OPLL_forceRefresh(OPLL * opll) { - int32 i; - - if (opll == NULL) - return; - - for (i = 0; i < 12; i++) { - UPDATE_PG(&opll->slot[i]); - UPDATE_RKS(&opll->slot[i]); - UPDATE_TLL(&opll->slot[i]); - UPDATE_WF(&opll->slot[i]); - UPDATE_EG(&opll->slot[i]); - } -} - -void OPLL_set_rate(OPLL * opll, uint32 r) { - if (opll->quality) - rate = 49716; - else - rate = r; - internal_refresh(); - rate = r; -} - -void OPLL_set_quality(OPLL * opll, uint32 q) { - opll->quality = q; - OPLL_set_rate(opll, rate); -} - -/********************************************************* - - Generate wave data - -*********************************************************/ -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ -#if (SLOT_AMP_BITS - PG_BITS) > 0 -#define wave2_2pi(e) ((e) >> (SLOT_AMP_BITS - PG_BITS)) -#else -#define wave2_2pi(e) ((e) << (PG_BITS - SLOT_AMP_BITS)) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ -#if (SLOT_AMP_BITS - PG_BITS - 1) == 0 -#define wave2_4pi(e) (e) -#elif (SLOT_AMP_BITS - PG_BITS - 1) > 0 -#define wave2_4pi(e) ((e) >> (SLOT_AMP_BITS - PG_BITS - 1)) -#else -#define wave2_4pi(e) ((e) << (1 + PG_BITS - SLOT_AMP_BITS)) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ -#if (SLOT_AMP_BITS - PG_BITS - 2) == 0 -#define wave2_8pi(e) (e) -#elif (SLOT_AMP_BITS - PG_BITS - 2) > 0 -#define wave2_8pi(e) ((e) >> (SLOT_AMP_BITS - PG_BITS - 2)) -#else -#define wave2_8pi(e) ((e) << (2 + PG_BITS - SLOT_AMP_BITS)) -#endif - - - -/* Update AM, PM unit */ -static void update_ampm(OPLL * opll) { - opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); - opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); - opll->lfo_am = amtable[HIGHBITS(opll->am_phase, AM_DP_BITS - AM_PG_BITS)]; - opll->lfo_pm = pmtable[HIGHBITS(opll->pm_phase, PM_DP_BITS - PM_PG_BITS)]; -} - -/* PG */ -INLINE static void calc_phase(OPLL_SLOT * slot, int32 lfo) { - if (slot->patch.PM) - slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - - slot->phase &= (DP_WIDTH - 1); - - slot->pgout = HIGHBITS(slot->phase, DP_BASE_BITS); -} - -/* EG */ -static void calc_envelope(OPLL_SLOT * slot, int32 lfo) { -#define S2E(x) (SL2EG((int32)(x / SL_STEP)) << (EG_DP_BITS - EG_BITS)) - - static uint32 SL[16] = { - S2E(0.0), S2E(3.0), S2E(6.0), S2E(9.0), S2E(12.0), S2E(15.0), S2E(18.0), S2E(21.0), - S2E(24.0), S2E(27.0), S2E(30.0), S2E(33.0), S2E(36.0), S2E(39.0), S2E(42.0), S2E(48.0) - }; - - uint32 egout; - - switch (slot->eg_mode) { - case ATTACK: - egout = AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS)]; - slot->eg_phase += slot->eg_dphase; - if ((EG_DP_WIDTH & slot->eg_phase) || (slot->patch.AR == 15)) { - egout = 0; - slot->eg_phase = 0; - slot->eg_mode = DECAY; - UPDATE_EG(slot); - } - break; - - case DECAY: - egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (slot->eg_phase >= SL[slot->patch.SL]) { - if (slot->patch.EG) { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSHOLD; - UPDATE_EG(slot); - } else { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSTINE; - UPDATE_EG(slot); - } - } - break; - - case SUSHOLD: - egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->patch.EG == 0) { - slot->eg_mode = SUSTINE; - UPDATE_EG(slot); - } - break; - - case SUSTINE: - case RELEASE: - egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) { - slot->eg_mode = FINISH; - egout = (1 << EG_BITS) - 1; - } - break; - - case FINISH: - egout = (1 << EG_BITS) - 1; - break; - - default: - egout = (1 << EG_BITS) - 1; - break; - } - - if (slot->patch.AM) - egout = EG2DB(egout + slot->tll) + lfo; - else - egout = EG2DB(egout + slot->tll); - - if (egout >= DB_MUTE) - egout = DB_MUTE - 1; - - slot->egout = egout; -} - -/* CARRIOR */ -INLINE static int32 calc_slot_car(OPLL_SLOT * slot, int32 fm) { - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) { - slot->output[0] = 0; - } else { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout + wave2_8pi(fm)) & (PG_WIDTH - 1)] + slot->egout]; - } - - return (slot->output[1] + slot->output[0]) >> 1; -} - -/* MODULATOR */ -INLINE static int32 calc_slot_mod(OPLL_SLOT * slot) { - int32 fm; - - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) { - slot->output[0] = 0; - } else if (slot->patch.FB != 0) { - fm = wave2_4pi(slot->feedback) >> (7 - slot->patch.FB); - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout + fm) & (PG_WIDTH - 1)] + slot->egout]; - } else { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - } - - slot->feedback = (slot->output[1] + slot->output[0]) >> 1; - - return slot->feedback; -} - -static INLINE int16 calc(OPLL * opll) { - int32 inst = 0, out = 0; - int32 i; - - update_ampm(opll); - - for (i = 0; i < 12; i++) { - calc_phase(&opll->slot[i], opll->lfo_pm); - calc_envelope(&opll->slot[i], opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if (!(opll->mask & OPLL_MASK_CH(i)) && (CAR(opll, i)->eg_mode != FINISH)) - inst += calc_slot_car(CAR(opll, i), calc_slot_mod(MOD(opll, i))); - - out = inst; - return (int16)out; -} - -void OPLL_fillbuf(OPLL* opll, int32 *buf, int32 len, int shift) { - while (len > 0) { - *buf += (calc(opll) + 32768) << shift; - buf++; - len--; - } -} - -int16 OPLL_calc(OPLL * opll) { - if (!opll->quality) - return calc(opll); - - while (opll->realstep > opll->oplltime) { - opll->oplltime += opll->opllstep; - opll->prev = opll->next; - opll->next = calc(opll); - } - - opll->oplltime -= opll->realstep; - opll->out = (int16)(((double)opll->next * (opll->opllstep - opll->oplltime) - + (double)opll->prev * opll->oplltime) / opll->opllstep); - - return (int16)opll->out; -} - -uint32 OPLL_setMask(OPLL * opll, uint32 mask) { - uint32 ret; - - if (opll) { - ret = opll->mask; - opll->mask = mask; - return ret; - } else - return 0; -} - -uint32 OPLL_toggleMask(OPLL * opll, uint32 mask) { - uint32 ret; - - if (opll) { - ret = opll->mask; - opll->mask ^= mask; - return ret; - } else - return 0; -} - -/**************************************************** - - I/O Ctrl - -*****************************************************/ - -static void setInstrument(OPLL * opll, uint32 i, uint32 inst) { - const uint8 *src; - OPLL_PATCH *modp, *carp; - - opll->patch_number[i] = inst; - - if (inst) - src = default_inst[inst - 1]; - else - src = opll->CustInst; - - modp = &MOD(opll, i)->patch; - carp = &CAR(opll, i)->patch; - - modp->AM = (src[0] >> 7) & 1; - modp->PM = (src[0] >> 6) & 1; - modp->EG = (src[0] >> 5) & 1; - modp->KR = (src[0] >> 4) & 1; - modp->ML = (src[0] & 0xF); - - carp->AM = (src[1] >> 7) & 1; - carp->PM = (src[1] >> 6) & 1; - carp->EG = (src[1] >> 5) & 1; - carp->KR = (src[1] >> 4) & 1; - carp->ML = (src[1] & 0xF); - - modp->KL = (src[2] >> 6) & 3; - modp->TL = (src[2] & 0x3F); - - carp->KL = (src[3] >> 6) & 3; - carp->WF = (src[3] >> 4) & 1; - - modp->WF = (src[3] >> 3) & 1; - - modp->FB = (src[3]) & 7; - - modp->AR = (src[4] >> 4) & 0xF; - modp->DR = (src[4] & 0xF); - - carp->AR = (src[5] >> 4) & 0xF; - carp->DR = (src[5] & 0xF); - - modp->SL = (src[6] >> 4) & 0xF; - modp->RR = (src[6] & 0xF); - - carp->SL = (src[7] >> 4) & 0xF; - carp->RR = (src[7] & 0xF); -} - - -void OPLL_writeReg(OPLL * opll, uint32 reg, uint32 data) { - int32 i, v, ch; - - data = data & 0xff; - reg = reg & 0x3f; - - switch (reg) { - case 0x00: - opll->CustInst[0] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_PG(MOD(opll, i)); - UPDATE_RKS(MOD(opll, i)); - UPDATE_EG(MOD(opll, i)); - } - } - break; - - case 0x01: - opll->CustInst[1] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_PG(CAR(opll, i)); - UPDATE_RKS(CAR(opll, i)); - UPDATE_EG(CAR(opll, i)); - } - } - break; - - case 0x02: - opll->CustInst[2] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_TLL(MOD(opll, i)); - } - } - break; - - case 0x03: - opll->CustInst[3] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_WF(MOD(opll, i)); - UPDATE_WF(CAR(opll, i)); - } - } - break; - - case 0x04: - opll->CustInst[4] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_EG(MOD(opll, i)); - } - } - break; - - case 0x05: - opll->CustInst[5] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_EG(CAR(opll, i)); - } - } - break; - - case 0x06: - opll->CustInst[6] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_EG(MOD(opll, i)); - } - } - break; - - case 0x07: - opll->CustInst[7] = data; - for (i = 0; i < 6; i++) { - if (opll->patch_number[i] == 0) { - setInstrument(opll, i, 0); - UPDATE_EG(CAR(opll, i)); - } - } - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - ch = reg - 0x10; - opll->LowFreq[ch] = data; - setFnumber(opll, ch, data + ((opll->HiFreq[ch] & 1) << 8)); - UPDATE_ALL(MOD(opll, ch)); - UPDATE_ALL(CAR(opll, ch)); - break; - - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - ch = reg - 0x20; - opll->HiFreq[ch] = data; - - setFnumber(opll, ch, ((data & 1) << 8) + opll->LowFreq[ch]); - setBlock(opll, ch, (data >> 1) & 7); - setSustine(opll, ch, (data >> 5) & 1); - if (data & 0x10) - keyOn(opll, ch); - else - keyOff(opll, ch); - UPDATE_ALL(MOD(opll, ch)); - UPDATE_ALL(CAR(opll, ch)); - update_key_status(opll); - break; - - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - opll->InstVol[reg - 0x30] = data; - i = (data >> 4) & 15; - v = data & 15; - setInstrument(opll, reg - 0x30, i); - setVolume(opll, reg - 0x30, v << 2); - UPDATE_ALL(MOD(opll, reg - 0x30)); - UPDATE_ALL(CAR(opll, reg - 0x30)); - break; - - default: - break; - } -} - -void OPLL_writeIO(OPLL * opll, uint32 adr, uint32 val) { - if (adr & 1) - OPLL_writeReg(opll, opll->adr, val); - else - opll->adr = val; -} - diff --git a/branches/sdl2/src/boards/emu2413.h b/branches/sdl2/src/boards/emu2413.h deleted file mode 100644 index c895f30f..00000000 --- a/branches/sdl2/src/boards/emu2413.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef _EMU2413_H_ -#define _EMU2413_H_ - -#ifndef INLINE -#if defined(_MSC_VER) -#define INLINE __forceinline -#elif defined(__GNUC__) -#define INLINE __inline__ -#elif defined(_MWERKS_) -#define INLINE inline -#else -#define INLINE -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned char uint8 ; -typedef signed char int8 ; - -typedef unsigned short uint16 ; -typedef signed short int16 ; - -typedef unsigned int uint32 ; -typedef signed int int32 ; - -#define PI 3.14159265358979323846 - -enum { OPLL_VRC7_TONE=0 }; - -/* voice data */ -typedef struct { - uint32 TL, FB, EG, ML, AR, DR, SL, RR, KR, KL, AM, PM, WF; -} OPLL_PATCH; - -/* slot */ -typedef struct { - OPLL_PATCH patch; - - int32 type; /* 0 : modulator 1 : carrier */ - - /* OUTPUT */ - int32 feedback; - int32 output[2]; /* Output value of slot */ - - /* for Phase Generator (PG) */ - uint16 *sintbl; /* Wavetable */ - uint32 phase; /* Phase */ - uint32 dphase; /* Phase increment amount */ - uint32 pgout; /* output */ - - /* for Envelope Generator (EG) */ - int32 fnum; /* F-Number */ - int32 block; /* Block */ - int32 volume; /* Current volume */ - int32 sustine; /* Sustine 1 = ON, 0 = OFF */ - uint32 tll; /* Total Level + Key scale level*/ - uint32 rks; /* Key scale offset (Rks) */ - int32 eg_mode; /* Current state */ - uint32 eg_phase; /* Phase */ - uint32 eg_dphase; /* Phase increment amount */ - uint32 egout; /* output */ -} OPLL_SLOT; - -/* Mask */ -#define OPLL_MASK_CH(x) (1 << (x)) - -/* opll */ -typedef struct { - uint32 adr; - int32 out; - - uint32 realstep; - uint32 oplltime; - uint32 opllstep; - int32 prev, next; - - /* Register */ - uint8 LowFreq[6]; - uint8 HiFreq[6]; - uint8 InstVol[6]; - - uint8 CustInst[8]; - - int32 slot_on_flag[6 * 2]; - - /* Pitch Modulator */ - uint32 pm_phase; - int32 lfo_pm; - - /* Amp Modulator */ - int32 am_phase; - int32 lfo_am; - - uint32 quality; - - /* Channel Data */ - int32 patch_number[6]; - int32 key_status[6]; - - /* Slot */ - OPLL_SLOT slot[6 * 2]; - - uint32 mask; -} OPLL; - -/* Create Object */ -OPLL *OPLL_new(uint32 clk, uint32 rate); -void OPLL_delete(OPLL *); - -/* Setup */ -void OPLL_reset(OPLL *); -void OPLL_set_rate(OPLL *opll, uint32 r); -void OPLL_set_quality(OPLL *opll, uint32 q); - -/* Port/Register access */ -void OPLL_writeIO(OPLL *, uint32 reg, uint32 val); -void OPLL_writeReg(OPLL *, uint32 reg, uint32 val); - -/* Synthsize */ -int16 OPLL_calc(OPLL *); - -/* Misc */ -void OPLL_forceRefresh(OPLL *); - -/* Channel Mask */ -uint32 OPLL_setMask(OPLL *, uint32 mask); -uint32 OPLL_toggleMask(OPLL *, uint32 mask); - - -void OPLL_fillbuf(OPLL* opll, int32 *buf, int32 len, int shift); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/branches/sdl2/src/boards/famicombox.cpp b/branches/sdl2/src/boards/famicombox.cpp deleted file mode 100644 index 05c6a629..00000000 --- a/branches/sdl2/src/boards/famicombox.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 regs[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { regs, 8, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg2r(0x10, 0x0800, 0); - setprg2r(0x10, 0x1000, 1); - setprg2r(0x10, 0x1800, 2); - setprg8r(0x10, 0x6000, 1); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); -} - -//static DECLFW(SSSNROMWrite) -//{ -// CartBW(A,V); -//} - -static DECLFW(SSSNROMWrite) { -// FCEU_printf("write %04x %02x\n",A,V); -// regs[A&7] = V; -} - -static DECLFR(SSSNROMRead) { -// FCEU_printf("read %04x\n",A); - switch (A & 7) { - case 0: return regs[0] = 0xff; // clear all exceptions - case 2: return 0xc0; // DIP selftest + freeplay - case 3: return 0x00; // 0, 1 - attract - // 2 - // 4 - menu - // 8 - self check and game casette check - // 10 - lock? - // 20 - game title & count display - case 7: return 0x22; // TV type, key not turned, relay B - default: return 0; - } -} - -static void SSSNROMPower(void) { - regs[0] = regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = regs[6] = 0; - regs[7] = 0xff; - Sync(); - memset(WRAM, 0x00, WRAMSIZE); -// SetWriteHandler(0x0000,0x1FFF,SSSNROMRamWrite); - SetReadHandler(0x0800, 0x1FFF, CartBR); - SetWriteHandler(0x0800, 0x1FFF, CartBW); - SetReadHandler(0x5000, 0x5FFF, SSSNROMRead); - SetWriteHandler(0x5000, 0x5FFF, SSSNROMWrite); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void SSSNROMReset(void) { - regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = regs[6] = 0; -} - -static void SSSNROMClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void SSSNROMIRQHook(void) { -// X6502_IRQBegin(FCEU_IQEXT); -} - -static void StateRestore(int version) { - Sync(); -} - -void SSSNROM_Init(CartInfo *info) { - info->Reset = SSSNROMReset; - info->Power = SSSNROMPower; - info->Close = SSSNROMClose; - GameHBIRQHook = SSSNROMIRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 16384; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ffe.cpp b/branches/sdl2/src/boards/ffe.cpp deleted file mode 100644 index da354114..00000000 --- a/branches/sdl2/src/boards/ffe.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FFE Copier Mappers - * - */ - -#include "mapinc.h" - -static uint8 preg[4], creg[8], latch, ffemode; -static uint8 IRQa, mirr; -static int32 IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { preg, 4, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - if (ffemode) { - int i; - for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, preg[3]); - } else { - setchr8(latch & 3); - setprg16(0x8000, (latch >> 2) & 0x3F); - setprg16(0xc000, 0x7); - } - switch (mirr) { - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - } -} - -static DECLFW(FFEWriteMirr) { - mirr = ((A << 1) & 2) | ((V >> 4) & 1); - Sync(); -} - -static DECLFW(FFEWriteIRQ) { - switch (A) { - case 0x4501: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x4502: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x4503: IRQCount &= 0x00FF; IRQCount |= V << 8; IRQa = 1; X6502_IRQEnd(FCEU_IQEXT); break; - } -} - -static DECLFW(FFEWritePrg) { - preg[A & 3] = V; - Sync(); -} - -static DECLFW(FFEWriteChr) { - creg[A & 7] = V; - Sync(); -} - -static DECLFW(FFEWriteLatch) { - latch = V; - Sync(); -} - -static void FFEPower(void) { - preg[3] = ~0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x42FE, 0x42FF, FFEWriteMirr); - SetWriteHandler(0x4500, 0x4503, FFEWriteIRQ); - SetWriteHandler(0x4504, 0x4507, FFEWritePrg); - SetWriteHandler(0x4510, 0x4517, FFEWriteChr); - SetWriteHandler(0x4510, 0x4517, FFEWriteChr); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, FFEWriteLatch); -} - -static void FFEIRQHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount >= 0x10000) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = 0; - } - } -} - -static void FFEClose(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper6_Init(CartInfo *info) { - ffemode = 0; - mirr = ((info->mirror & 1) ^ 1) | 2; - - info->Power = FFEPower; - info->Close = FFEClose; - MapIRQHook = FFEIRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper17_Init(CartInfo *info) { - ffemode = 1; - Mapper6_Init(info); -} diff --git a/branches/sdl2/src/boards/fk23c.cpp b/branches/sdl2/src/boards/fk23c.cpp deleted file mode 100644 index 604d5160..00000000 --- a/branches/sdl2/src/boards/fk23c.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" -#include "../ines.h" - -static bool is_BMCFK23CA; -static uint8 unromchr; -static uint32 dipswitch; -static uint8 *CHRRAM=NULL; -static uint32 CHRRAMSize; - -static void BMCFK23CCW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x40) - setchr8(EXPREGS[2]|unromchr); - else if(EXPREGS[0]&0x20) { - setchr1r(0x10, A, V); - } - else - { - uint16 base=(EXPREGS[2]&0x7F)<<3; - if(EXPREGS[3]&2) - { - int cbase=(MMC3_cmd&0x80)<<5; - setchr1(A,V|base); - setchr1(0x0000^cbase,DRegBuf[0]|base); - setchr1(0x0400^cbase,EXPREGS[6]|base); - setchr1(0x0800^cbase,DRegBuf[1]|base); - setchr1(0x0c00^cbase,EXPREGS[7]|base); - } - else - setchr1(A,V|base); - } -} - -//some games are wired differently, and this will need to be changed. -//all the WXN games require prg_bonus = 1, and cah4e3's multicarts require prg_bonus = 0 -//we'll populate this from a game database -static int prg_bonus; -static int prg_mask; - -//prg_bonus = 0 -//4-in-1 (FK23C8021)[p1][!].nes -//4-in-1 (FK23C8033)[p1][!].nes -//4-in-1 (FK23C8043)[p1][!].nes -//4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes - -//prg_bonus = 1 -//[m176]大富ç¿2-上海大亨.wxn.nes -//[m176]宠物翡翠.fix.nes -//[m176]格兰å¸äºš.wxn.nes -//[m176]梦幻之星.wxn.nes -//[m176]水浒神兽.fix.nes -//[m176]西楚霸王.fix.nes -//[m176]超级大富ç¿.wxn.nes -//[m176]雄霸天下.wxn.nes - -//works as-is under virtuanes m176 -//[m176]三侠五义.wxn.nes -//[m176]å£è¢‹é‡‘.fix.nes -//[m176]爆笑三国.fix.nes - -//needs other tweaks -//[m176]三国忠烈传.wxn.nes -//[m176]破釜沉舟.fix.nes - -//PRG wrapper -static void BMCFK23CPW(uint32 A, uint8 V) -{ - uint32 bank = (EXPREGS[1] & 0x1F); - uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0); - uint32 block = (EXPREGS[1] & 0x60) | hiblock; - uint32 extra = (EXPREGS[3] & 2); - - if((EXPREGS[0]&7)==4) - setprg32(0x8000,EXPREGS[1]>>1); - else if ((EXPREGS[0]&7)==3) - { - setprg16(0x8000,EXPREGS[1]); - setprg16(0xC000,EXPREGS[1]); - } - else - { - if(EXPREGS[0]&3) - { - uint32 blocksize = (6)-(EXPREGS[0]&3); - uint32 mask = (1<Power=BMCFK23CPower; - info->Reset=BMCFK23CReset; - AddExState(EXPREGS, 8, 0, "EXPR"); - AddExState(&unromchr, 1, 0, "UCHR"); - AddExState(&dipswitch, 1, 0, "DPSW"); - - prg_bonus = 1; - if(MasterRomInfoParams.find("bonus") != MasterRomInfoParams.end()) - prg_bonus = atoi(MasterRomInfoParams["bonus"].c_str()); - - prg_mask = 0x7F>>(prg_bonus); -} - -void BMCFK23CA_Init(CartInfo *info) -{ - is_BMCFK23CA = true; - - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap=BMCFK23CCW; - pwrap=BMCFK23CPW; - info->Power=BMCFK23CAPower; - info->Reset=BMCFK23CReset; - info->Close=BMCFK23CAClose; - - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CRAM"); - - AddExState(EXPREGS, 8, 0, "EXPR"); - AddExState(&unromchr, 1, 0, "UCHR"); - AddExState(&dipswitch, 1, 0, "DPSW"); - - prg_bonus = 1; - if(MasterRomInfoParams.find("bonus") != MasterRomInfoParams.end()) - prg_bonus = atoi(MasterRomInfoParams["bonus"].c_str()); - prg_mask = 0x7F>>(prg_bonus); -} diff --git a/branches/sdl2/src/boards/ghostbusters63in1.cpp b/branches/sdl2/src/boards/ghostbusters63in1.cpp deleted file mode 100644 index 5e09d9be..00000000 --- a/branches/sdl2/src/boards/ghostbusters63in1.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * 63in1 ghostbusters - */ - -#include "mapinc.h" - -static uint8 reg[2], bank; -static uint8 banks[4] = { 0, 0, 1, 2 }; -static uint8 *CHRROM = NULL; -static uint32 CHRROMSIZE; - -static SFORMAT StateRegs[] = -{ - { reg, 2, "REGS" }, - { &bank, 1, "BANK" }, - { 0 } -}; - -static void Sync(void) { - if (reg[0] & 0x20) { - setprg16r(banks[bank], 0x8000, reg[0] & 0x1F); - setprg16r(banks[bank], 0xC000, reg[0] & 0x1F); - } else - setprg32r(banks[bank], 0x8000, (reg[0] >> 1) & 0x0F); - if (reg[1] & 2) - setchr8r(0x10, 0); - else - setchr8(0); - setmirror((reg[0] & 0x40) >> 6); -} - -static DECLFW(BMCGhostbusters63in1Write) { - reg[A & 1] = V; - bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1); -// FCEU_printf("reg[0]=%02x, reg[1]=%02x, bank=%02x\n",reg[0],reg[1],bank); - Sync(); -} - -static DECLFR(BMCGhostbusters63in1Read) { - if (bank == 1) - return X.DB; - else - return CartBR(A); -} - -static void BMCGhostbusters63in1Power(void) { - reg[0] = reg[1] = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, BMCGhostbusters63in1Read); - SetWriteHandler(0x8000, 0xFFFF, BMCGhostbusters63in1Write); -} - -static void BMCGhostbusters63in1Reset(void) { - reg[0] = reg[1] = 0; -} - -static void StateRestore(int version) { - Sync(); -} - -static void BMCGhostbusters63in1Close(void) { - if (CHRROM) - FCEU_gfree(CHRROM); - CHRROM = NULL; -} - -void BMCGhostbusters63in1_Init(CartInfo *info) { - info->Reset = BMCGhostbusters63in1Reset; - info->Power = BMCGhostbusters63in1Power; - info->Close = BMCGhostbusters63in1Close; - - CHRROMSIZE = 8192; // dummy CHRROM, VRAM disable - CHRROM = (uint8*)FCEU_gmalloc(CHRROMSIZE); - SetupCartPRGMapping(0x10, CHRROM, CHRROMSIZE, 0); - AddExState(CHRROM, CHRROMSIZE, 0, "CROM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/gs-2004.cpp b/branches/sdl2/src/boards/gs-2004.cpp deleted file mode 100644 index 43f70684..00000000 --- a/branches/sdl2/src/boards/gs-2004.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, mirr; -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(1, 0x6000, 0); - setprg32(0x8000, reg); - setchr8(0); -} - -static DECLFW(BMCGS2004Write) { - reg = V; - Sync(); -} - -static void BMCGS2004Power(void) { - reg = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, BMCGS2004Write); -} - -static void BMCGS2004Reset(void) { - reg = ~0; -} - -static void StateRestore(int version) { - Sync(); -} - -void BMCGS2004_Init(CartInfo *info) { - info->Reset = BMCGS2004Reset; - info->Power = BMCGS2004Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/gs-2013.cpp b/branches/sdl2/src/boards/gs-2013.cpp deleted file mode 100644 index 704a8cf1..00000000 --- a/branches/sdl2/src/boards/gs-2013.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg, mirr; -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0, 0x6000, ~0); - setprg32r((reg & 8) >> 3, 0x8000, reg); - setchr8(0); -} - -static DECLFW(BMCGS2013Write) { - reg = V; - Sync(); -} - -static void BMCGS2013Power(void) { - reg = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, BMCGS2013Write); -} - -static void BMCGS2013Reset(void) { - reg = ~0; -} - -static void StateRestore(int version) { - Sync(); -} - -void BMCGS2013_Init(CartInfo *info) { - info->Reset = BMCGS2013Reset; - info->Power = BMCGS2013Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/h2288.cpp b/branches/sdl2/src/boards/h2288.cpp deleted file mode 100644 index 07ff76c1..00000000 --- a/branches/sdl2/src/boards/h2288.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -extern uint8 m114_perm[8]; - -static void H2288PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) { - uint8 bank = (EXPREGS[0] & 5) | ((EXPREGS[0] & 8) >> 2) | ((EXPREGS[0] & 0x20) >> 2); - if (EXPREGS[0] & 2) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else - setprg8(A, V & 0x3F); -} - -static DECLFW(H2288WriteHi) { - switch (A & 0x8001) { - case 0x8000: MMC3_CMDWrite(0x8000, (V & 0xC0) | (m114_perm[V & 7])); break; - case 0x8001: MMC3_CMDWrite(0x8001, V); break; - } -} - -static DECLFW(H2288WriteLo) { - if (A & 0x800) { - if (A & 1) - EXPREGS[1] = V; - else - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void H2288Power(void) { - EXPREGS[0] = EXPREGS[1] = 0; - GenMMC3Power(); -// SetReadHandler(0x5000,0x5FFF,H2288Read); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x5000, 0x5FFF, H2288WriteLo); - SetWriteHandler(0x8000, 0x9FFF, H2288WriteHi); -} - -void UNLH2288_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = H2288PW; - info->Power = H2288Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/karaoke.cpp b/branches/sdl2/src/boards/karaoke.cpp deleted file mode 100644 index 81d9dbc8..00000000 --- a/branches/sdl2/src/boards/karaoke.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -extern uint32 ROM_size; -static uint8 latche; - -static void Sync(void) { - if (latche) { - if (latche & 0x10) - setprg16(0x8000, (latche & 7)); - else - setprg16(0x8000, (latche & 7) | 8); - } else - setprg16(0x8000, 7 + (ROM_size >> 4)); -} - -static DECLFW(M188Write) { - latche = V; - Sync(); -} - -static DECLFR(ExtDev) { - return(3); -} - -static void Power(void) { - latche = 0; - Sync(); - setchr8(0); - setprg16(0xc000, 0x7); - SetReadHandler(0x6000, 0x7FFF, ExtDev); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M188Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper188_Init(CartInfo *info) { - info->Power = Power; - GameStateRestore = StateRestore; - AddExState(&latche, 1, 0, "LATC"); -} diff --git a/branches/sdl2/src/boards/kof97.cpp b/branches/sdl2/src/boards/kof97.cpp deleted file mode 100644 index 4a7925ac..00000000 --- a/branches/sdl2/src/boards/kof97.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static DECLFW(UNLKOF97CMDWrite) { - V = (V & 0xD8) | ((V & 0x20) >> 4) | ((V & 4) << 3) | ((V & 2) >> 1) | ((V & 1) << 2); //76143502 - if (A == 0x9000) A = 0x8001; - MMC3_CMDWrite(A, V); -} - -static DECLFW(UNLKOF97IRQWrite) { - V = (V & 0xD8) | ((V & 0x20) >> 4) | ((V & 4) << 3) | ((V & 2) >> 1) | ((V & 1) << 2); - if (A == 0xD000) A = 0xC001; - else if (A == 0xF000) A = 0xE001; - MMC3_IRQWrite(A, V); -} - -static void UNLKOF97Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xA000, UNLKOF97CMDWrite); - SetWriteHandler(0xC000, 0xF000, UNLKOF97IRQWrite); -} - -void UNLKOF97_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power = UNLKOF97Power; -} diff --git a/branches/sdl2/src/boards/ks7012.cpp b/branches/sdl2/src/boards/ks7012.cpp deleted file mode 100644 index feaa7542..00000000 --- a/branches/sdl2/src/boards/ks7012.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg32(0x8000, reg & 1); - setchr8(0); -} - -static DECLFW(UNLKS7012Write) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A) { - case 0xE0A0: reg = 0; Sync(); break; - case 0xEE36: reg = 1; Sync(); break; - } -} - -static void UNLKS7012Power(void) { - reg = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLKS7012Write); -} - -static void UNLKS7012Reset(void) { - reg = ~0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -static void UNLKS7012Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void UNLKS7012_Init(CartInfo *info) { - info->Power = UNLKS7012Power; - info->Reset = UNLKS7012Reset; - info->Close = UNLKS7012Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7013.cpp b/branches/sdl2/src/boards/ks7013.cpp deleted file mode 100644 index fe8349e9..00000000 --- a/branches/sdl2/src/boards/ks7013.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Just another pirate cart with pirate mapper, instead of original MMC1 - * Kaiser Highway Star - * - */ - -#include "mapinc.h" - -static uint8 reg, mirr; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REGS" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, reg); - setprg16(0xc000, ~0); - setmirror(mirr); - setchr8(0); -} - -static DECLFW(UNLKS7013BLoWrite) { - reg = V; - Sync(); -} - -static DECLFW(UNLKS7013BHiWrite) { - mirr = (V & 1) ^ 1; - Sync(); -} - -static void UNLKS7013BPower(void) { - reg = 0; - mirr = 0; - Sync(); - SetWriteHandler(0x6000, 0x7FFF, UNLKS7013BLoWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLKS7013BHiWrite); -} - -static void UNLKS7013BReset(void) { - reg = 0; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7013B_Init(CartInfo *info) { - info->Power = UNLKS7013BPower; - info->Reset = UNLKS7013BReset; - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7017.cpp b/branches/sdl2/src/boards/ks7017.cpp deleted file mode 100644 index 29c02037..00000000 --- a/branches/sdl2/src/boards/ks7017.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg, mirr; -static int32 IRQa, IRQCount, IRQLatch; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &mirr, 1, "MIRR" }, - { ®, 1, "REGS" }, - { &IRQa, 4, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { &IRQLatch, 4, "IRQL" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, reg); - setprg16(0xC000, 2); - setmirror(mirr); -} - -static DECLFW(UNLKS7017Write) { -// FCEU_printf("bs %04x %02x\n",A,V); - if ((A & 0xFF00) == 0x4A00) { - reg = ((A >> 2) & 3) | ((A >> 4) & 4); - } else if ((A & 0xFF00) == 0x5100) { - Sync(); - } else if (A == 0x4020) { - X6502_IRQEnd(FCEU_IQEXT); - IRQCount &= 0xFF00; - IRQCount |= V; - } else if (A == 0x4021) { - X6502_IRQEnd(FCEU_IQEXT); - IRQCount &= 0xFF; - IRQCount |= V << 8; - IRQa = 1; - } else if (A == 0x4025) { - mirr = ((V & 8) >> 3) ^ 1; - } -} -static DECLFR(FDSRead4030) { - X6502_IRQEnd(FCEU_IQEXT); - return X.IRQlow & FCEU_IQEXT ? 1 : 0; -} - -static void UNL7017IRQ(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount <= 0) { - IRQa = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void UNLKS7017Power(void) { - Sync(); - setchr8(0); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4030, 0x4030, FDSRead4030); - SetWriteHandler(0x4020, 0x5FFF, UNLKS7017Write); -} - -static void UNLKS7017Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7017_Init(CartInfo *info) { - info->Power = UNLKS7017Power; - info->Close = UNLKS7017Close; - MapIRQHook = UNL7017IRQ; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7030.cpp b/branches/sdl2/src/boards/ks7030.cpp deleted file mode 100644 index 8e6a592e..00000000 --- a/branches/sdl2/src/boards/ks7030.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - * Logical bank layot 32 K BANK 0, 64K BANK 1, 32K ~0 hardwired, 8K is missing - * need redump from MASKROM! - * probably need refix mapper after hard dump - * - */ - -#include "mapinc.h" - -static uint8 reg0, reg1; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®0, 1, "REG0" }, - { ®1, 1, "REG1" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg32(0x8000, ~0); - setprg4(0xb800, reg0); - setprg4(0xc800, 8 + reg1); -} - -// 6000 - 6BFF - RAM -// 6C00 - 6FFF - BANK 1K REG1 -// 7000 - 7FFF - BANK 4K REG0 - -static DECLFW(UNLKS7030RamWrite0) { - if ((A >= 0x6000) && A <= 0x6BFF) { - WRAM[A - 0x6000] = V; - } else if ((A >= 0x6C00) && A <= 0x6FFF) { - CartBW(0xC800 + (A - 0x6C00), V); - } else if ((A >= 0x7000) && A <= 0x7FFF) { - CartBW(0xB800 + (A - 0x7000), V); - } -} - -static DECLFR(UNLKS7030RamRead0) { - if ((A >= 0x6000) && A <= 0x6BFF) { - return WRAM[A - 0x6000]; - } else if ((A >= 0x6C00) && A <= 0x6FFF) { - return CartBR(0xC800 + (A - 0x6C00)); - } else if ((A >= 0x7000) && A <= 0x7FFF) { - return CartBR(0xB800 + (A - 0x7000)); - } - return 0; -} - -// B800 - BFFF - RAM -// C000 - CBFF - BANK 3K -// CC00 - D7FF - RAM - -static DECLFW(UNLKS7030RamWrite1) { - if ((A >= 0xB800) && A <= 0xBFFF) { - WRAM[0x0C00 + (A - 0xB800)] = V; - } else if ((A >= 0xC000) && A <= 0xCBFF) { - CartBW(0xCC00 + (A - 0xC000), V); - } else if ((A >= 0xCC00) && A <= 0xD7FF) { - WRAM[0x1400 + (A - 0xCC00)] = V; - } -} - -static DECLFR(UNLKS7030RamRead1) { - if ((A >= 0xB800) && A <= 0xBFFF) { - return WRAM[0x0C00 + (A - 0xB800)]; - } else if ((A >= 0xC000) && A <= 0xCBFF) { - return CartBR(0xCC00 + (A - 0xC000)); - } else if ((A >= 0xCC00) && A <= 0xD7FF) { - return WRAM[0x1400 + (A - 0xCC00)]; - } - return 0; -} - -static DECLFW(UNLKS7030Write0) { - reg0 = A & 7; - Sync(); -} - -static DECLFW(UNLKS7030Write1) { - reg1 = A & 15; - Sync(); -} - -static void UNLKS7030Power(void) { - reg0 = reg1 = ~0; - Sync(); - SetReadHandler(0x6000, 0x7FFF, UNLKS7030RamRead0); - SetWriteHandler(0x6000, 0x7FFF, UNLKS7030RamWrite0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0x8FFF, UNLKS7030Write0); - SetWriteHandler(0x9000, 0x9FFF, UNLKS7030Write1); - SetReadHandler(0xB800, 0xD7FF, UNLKS7030RamRead1); - SetWriteHandler(0xB800, 0xD7FF, UNLKS7030RamWrite1); -} - -static void UNLKS7030Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7030_Init(CartInfo *info) { - info->Power = UNLKS7030Power; - info->Close = UNLKS7030Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7031.cpp b/branches/sdl2/src/boards/ks7031.cpp deleted file mode 100644 index f9944340..00000000 --- a/branches/sdl2/src/boards/ks7031.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg[4]; - -static SFORMAT StateRegs[] = -{ - { reg, 4, "REGS" }, - { 0 } -}; - -static void Sync(void) { - setprg2(0x6000, reg[0]); - setprg2(0x6800, reg[1]); - setprg2(0x7000, reg[2]); - setprg2(0x7800, reg[3]); - - setprg2(0x8000, 15); - setprg2(0x8800, 14); - setprg2(0x9000, 13); - setprg2(0x9800, 12); - setprg2(0xa000, 11); - setprg2(0xa800, 10); - setprg2(0xb000, 9); - setprg2(0xb800, 8); - - setprg2(0xc000, 7); - setprg2(0xc800, 6); - setprg2(0xd000, 5); - setprg2(0xd800, 4); - setprg2(0xe000, 3); - setprg2(0xe800, 2); - setprg2(0xf000, 1); - setprg2(0xf800, 0); - - setchr8(0); -} - -static DECLFW(UNLKS7031Write) { - reg[(A >> 11) & 3] = V; - Sync(); -} - -static void UNLKS7031Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xffff, UNLKS7031Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7031_Init(CartInfo *info) { - info->Power = UNLKS7031Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7032.cpp b/branches/sdl2/src/boards/ks7032.cpp deleted file mode 100644 index 71d4c5f8..00000000 --- a/branches/sdl2/src/boards/ks7032.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8], cmd, IRQa = 0, isirqused = 0; -static int32 IRQCount; - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { reg, 8, "REGS" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg[4]); - setprg8(0x8000, reg[1]); - setprg8(0xA000, reg[2]); - setprg8(0xC000, reg[3]); - setprg8(0xE000, ~0); - setchr8(0); -} - -static DECLFW(UNLKS7032Write) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A & 0xF000) { -// case 0x8FFF: reg[4]=V; Sync(); break; - case 0x8000: X6502_IRQEnd(FCEU_IQEXT); IRQCount = (IRQCount & 0x000F) | (V & 0x0F); isirqused = 1; break; - case 0x9000: X6502_IRQEnd(FCEU_IQEXT); IRQCount = (IRQCount & 0x00F0) | ((V & 0x0F) << 4); isirqused = 1; break; - case 0xA000: X6502_IRQEnd(FCEU_IQEXT); IRQCount = (IRQCount & 0x0F00) | ((V & 0x0F) << 8); isirqused = 1; break; - case 0xB000: X6502_IRQEnd(FCEU_IQEXT); IRQCount = (IRQCount & 0xF000) | (V << 12); isirqused = 1; break; - case 0xC000: if (isirqused) { - X6502_IRQEnd(FCEU_IQEXT); IRQa = 1; - } - break; - case 0xE000: cmd = V & 7; break; - case 0xF000: reg[cmd] = V; Sync(); break; - } -} - -static void UNLSMB2JIRQHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount >= 0xFFFF) { - IRQa = 0; - IRQCount = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void UNLKS7032Power(void) { - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4020, 0xFFFF, UNLKS7032Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLKS7032_Init(CartInfo *info) { - info->Power = UNLKS7032Power; - MapIRQHook = UNLSMB2JIRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7037.cpp b/branches/sdl2/src/boards/ks7037.cpp deleted file mode 100644 index efe43f21..00000000 --- a/branches/sdl2/src/boards/ks7037.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg[8], cmd; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static void (*WSync)(void); - -static SFORMAT StateRegs[] = -{ - { &cmd, 1, "CMD" }, - { reg, 8, "REGS" }, - { 0 } -}; - -static void SyncKS7037(void) { - setprg4r(0x10, 0x6000, 0); - setprg4(0x7000, 15); - setprg8(0x8000, reg[6]); - setprg4(0xA000, ~3); - setprg4r(0x10, 0xB000, 1); - setprg8(0xC000, reg[7]); - setprg8(0xE000, ~0); - setchr8(0); - setmirrorw(reg[2] & 1, reg[4] & 1, reg[3] & 1, reg[5] & 1); -} - -static void SyncLH10(void) { - setprg8(0x6000, ~1); - setprg8(0x8000, reg[6]); - setprg8(0xA000, reg[7]); - setprg8r(0x10, 0xC000, 0); - setprg8(0xE000, ~0); - setchr8(0); - setmirror(0); -} - -static DECLFW(UNLKS7037Write) { - switch (A & 0xE001) { - case 0x8000: cmd = V & 7; break; - case 0x8001: reg[cmd] = V; WSync(); break; - } -} - -static void UNLKS7037Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = reg[4] = reg[5] = reg[6] = reg[7] = 0; - WSync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0x9FFF, UNLKS7037Write); - SetWriteHandler(0xA000, 0xBFFF, CartBW); - SetWriteHandler(0xC000, 0xFFFF, UNLKS7037Write); -} - -static void LH10Power(void) { - reg[0] = reg[1] = reg[2] = reg[3] = reg[4] = reg[5] = reg[6] = reg[7] = 0; - WSync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, UNLKS7037Write); - SetWriteHandler(0xC000, 0xDFFF, CartBW); - SetWriteHandler(0xE000, 0xFFFF, UNLKS7037Write); -} - -static void Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - WSync(); -} - -void UNLKS7037_Init(CartInfo *info) { - info->Power = UNLKS7037Power; - info->Close = Close; - - WSync = SyncKS7037; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void LH10_Init(CartInfo *info) { - info->Power = LH10Power; - info->Close = Close; - - WSync = SyncLH10; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/ks7057.cpp b/branches/sdl2/src/boards/ks7057.cpp deleted file mode 100644 index a9c47968..00000000 --- a/branches/sdl2/src/boards/ks7057.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg[8], mirror; -static SFORMAT StateRegs[] = -{ - { reg, 8, "PRG" }, - { &mirror, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg2(0x6000, reg[4]); - setprg2(0x6800, reg[5]); - setprg2(0x7000, reg[6]); - setprg2(0x7800, reg[7]); - setprg2(0x8000, reg[0]); - setprg2(0x8800, reg[1]); - setprg2(0x9000, reg[2]); - setprg2(0x9800, reg[3]); - setprg8(0xA000, 0xd); - setprg16(0xC000, 7); - setchr8(0); - setmirror(mirror); -} - -static DECLFW(UNLKS7057Write) { - switch (A & 0xF003) { - case 0x8000: - case 0x8001: - case 0x8002: - case 0x8003: - case 0x9000: - case 0x9001: - case 0x9002: - case 0x9003: mirror = V & 1; Sync(); break; - case 0xB000: reg[0] = (reg[0] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xB001: reg[0] = (reg[0] & 0x0F) | (V << 4); Sync(); break; - case 0xB002: reg[1] = (reg[1] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xB003: reg[1] = (reg[1] & 0x0F) | (V << 4); Sync(); break; - case 0xC000: reg[2] = (reg[2] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xC001: reg[2] = (reg[2] & 0x0F) | (V << 4); Sync(); break; - case 0xC002: reg[3] = (reg[3] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xC003: reg[3] = (reg[3] & 0x0F) | (V << 4); Sync(); break; - case 0xD000: reg[4] = (reg[4] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xD001: reg[4] = (reg[4] & 0x0F) | (V << 4); Sync(); break; - case 0xD002: reg[5] = (reg[5] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xD003: reg[5] = (reg[5] & 0x0F) | (V << 4); Sync(); break; - case 0xE000: reg[6] = (reg[6] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xE001: reg[6] = (reg[6] & 0x0F) | (V << 4); Sync(); break; - case 0xE002: reg[7] = (reg[7] & 0xF0) | (V & 0x0F); Sync(); break; - case 0xE003: reg[7] = (reg[7] & 0x0F) | (V << 4); Sync(); break; - } -} - -static void UNLKS7057Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLKS7057Write); -} - -static void UNLKS7057Reset(void) { - Sync(); -} - -void UNLKS7057_Init(CartInfo *info) { - info->Power = UNLKS7057Power; - info->Reset = UNLKS7057Reset; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/le05.cpp b/branches/sdl2/src/boards/le05.cpp deleted file mode 100644 index efbe13f6..00000000 --- a/branches/sdl2/src/boards/le05.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2011 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 chr; -static SFORMAT StateRegs[] = -{ - { &chr, 1, "CHR" }, - { 0 } -}; - -static void Sync(void) { - setprg2r(0, 0xE000, 0); - setprg2r(0, 0xE800, 0); - setprg2r(0, 0xF000, 0); - setprg2r(0, 0xF800, 0); - - setprg8r(1, 0x6000, 3); - setprg8r(1, 0x8000, 0); - setprg8r(1, 0xA000, 1); - setprg8r(1, 0xC000, 2); - - setchr8(chr & 1); - setmirror(MI_V); -} - -static DECLFW(LE05Write) { - chr = V; - Sync(); -} - -static void LE05Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, LE05Write); -} - -void LE05_Init(CartInfo *info) { - info->Power = LE05Power; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/lh32.cpp b/branches/sdl2/src/boards/lh32.cpp deleted file mode 100644 index 2150aee2..00000000 --- a/branches/sdl2/src/boards/lh32.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x6000, reg); - setprg8(0x8000, ~3); - setprg8(0xa000, ~2); - setprg8r(0x10, 0xc000, 0); - setprg8(0xe000, ~0); - setchr8(0); -} - -static DECLFW(LH32Write) { - reg = V; - Sync(); -} - -static void LH32Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0xC000, 0xDFFF, CartBW); - SetWriteHandler(0x6000, 0x6000, LH32Write); -} - -static void LH32Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void LH32_Init(CartInfo *info) { - info->Power = LH32Power; - info->Close = LH32Close; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/lh53.cpp b/branches/sdl2/src/boards/lh53.cpp deleted file mode 100644 index 7626dca5..00000000 --- a/branches/sdl2/src/boards/lh53.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * FDS Conversion - * - */ - -#include "mapinc.h" - -static uint8 reg, IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { ®, 1, "REG" }, - { &IRQa, 1, "IRQA" }, - { &IRQCount, 4, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg8(0x6000, reg); - setprg8(0x8000, 0xc); - setprg4(0xa000, (0xd << 1)); - setprg2(0xb000, (0xd << 2) + 2); - setprg2r(0x10, 0xb800, 4); - setprg2r(0x10, 0xc000, 5); - setprg2r(0x10, 0xc800, 6); - setprg2r(0x10, 0xd000, 7); - setprg2(0xd800, (0xe << 2) + 3); - setprg8(0xe000, 0xf); -} - -static DECLFW(LH53RamWrite) { - WRAM[(A - 0xB800) & 0x1FFF] = V; -} - -static DECLFW(LH53Write) { - reg = V; - Sync(); -} - -static DECLFW(LH53IRQaWrite) { - IRQa = V & 2; - IRQCount = 0; - if (!IRQa) - X6502_IRQEnd(FCEU_IQEXT); -} - -static void LH53IRQ(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount > 7560) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void LH53Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0xB800, 0xD7FF, LH53RamWrite); - SetWriteHandler(0xE000, 0xEFFF, LH53IRQaWrite); - SetWriteHandler(0xF000, 0xFFFF, LH53Write); -} - -static void LH53Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void LH53_Init(CartInfo *info) { - info->Power = LH53Power; - info->Close = LH53Close; - MapIRQHook = LH53IRQ; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/malee.cpp b/branches/sdl2/src/boards/malee.cpp deleted file mode 100644 index ca369a75..00000000 --- a/branches/sdl2/src/boards/malee.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 WRAM[2048]; - -static void MALEEPower(void) { - setprg2r(0x10, 0x7000, 0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x6000, 0x67FF, CartBR); - SetReadHandler(0x7000, 0x77FF, CartBR); - SetWriteHandler(0x7000, 0x77FF, CartBW); - setprg2r(1, 0x6000, 0); - setprg32(0x8000, 0); - setchr8(0); -} - -void MALEE_Init(CartInfo *info) { - info->Power = MALEEPower; - SetupCartPRGMapping(0x10, WRAM, 2048, 1); - AddExState(WRAM, 2048, 0, "WRAM"); -} diff --git a/branches/sdl2/src/boards/mapinc.h b/branches/sdl2/src/boards/mapinc.h deleted file mode 100644 index 8fa46f42..00000000 --- a/branches/sdl2/src/boards/mapinc.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "../types.h" -#include "../utils/memory.h" -#include "../x6502.h" -#include "../fceu.h" -#include "../ppu.h" -#include "../sound.h" -#include "../state.h" -#include "../cart.h" -#include "../cheat.h" -#include "../unif.h" -#include -#include diff --git a/branches/sdl2/src/boards/mihunche.cpp b/branches/sdl2/src/boards/mihunche.cpp deleted file mode 100644 index 512aa0f2..00000000 --- a/branches/sdl2/src/boards/mihunche.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2013 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint16 latche; - -static SFORMAT StateRegs[] = -{ - { &latche, 2, "LATC" }, - { 0 } -}; - -static void Sync(void) { - setprg32(0x8000, 0); - if(CHRsize[0] == 8192) { - setchr4(0x0000, latche & 1); - setchr4(0x1000, latche & 1); - } else { - setchr8(latche & 1); // actually, my bad, overdumped roms, the real CHR size if 8K - } - setmirror(MI_0 + (latche & 1)); -} - -static DECLFW(UNLCC21Write1) { - latche = A; - Sync(); -} - -static DECLFW(UNLCC21Write2) { - latche = V; - Sync(); -} - -static void UNLCC21Power(void) { - latche = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8001, 0xFFFF, UNLCC21Write1); - SetWriteHandler(0x8000, 0x8000, UNLCC21Write2); // another one many-in-1 mapper, there is a lot of similar carts with little different wirings -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLCC21_Init(CartInfo *info) { - info->Power = UNLCC21Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/mmc1.cpp b/branches/sdl2/src/boards/mmc1.cpp deleted file mode 100644 index 17fab418..00000000 --- a/branches/sdl2/src/boards/mmc1.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static void GenMMC1Power(void); -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery); - -static uint8 DRegs[4]; -static uint8 Buffer, BufferShift; - -static int mmc1opts; - -static void (*MMC1CHRHook4)(uint32 A, uint8 V); -static void (*MMC1PRGHook16)(uint32 A, uint8 V); - -static uint8 *WRAM = NULL; -static uint8 *CHRRAM = NULL; -static int is155, is171; - -static DECLFW(MBWRAM) { - if (!(DRegs[3] & 0x10) || is155) - Page[A >> 11][A] = V; // WRAM is enabled. -} - -static DECLFR(MAWRAM) { - if ((DRegs[3] & 0x10) && !is155) - return X.DB; // WRAM is disabled - return(Page[A >> 11][A]); -} - -static void MMC1CHR(void) { - if (mmc1opts & 4) { - if (DRegs[0] & 0x10) - setprg8r(0x10, 0x6000, (DRegs[1] >> 4) & 1); - else - setprg8r(0x10, 0x6000, (DRegs[1] >> 3) & 1); - } - - if (MMC1CHRHook4) { - if (DRegs[0] & 0x10) { - MMC1CHRHook4(0x0000, DRegs[1]); - MMC1CHRHook4(0x1000, DRegs[2]); - } else { - MMC1CHRHook4(0x0000, (DRegs[1] & 0xFE)); - MMC1CHRHook4(0x1000, DRegs[1] | 1); - } - } else { - if (DRegs[0] & 0x10) { - setchr4(0x0000, DRegs[1]); - setchr4(0x1000, DRegs[2]); - } else - setchr8(DRegs[1] >> 1); - } -} - -static void MMC1PRG(void) { - uint8 offs = DRegs[1] & 0x10; - if (MMC1PRGHook16) { - switch (DRegs[0] & 0xC) { - case 0xC: - MMC1PRGHook16(0x8000, (DRegs[3] + offs)); - MMC1PRGHook16(0xC000, 0xF + offs); - break; - case 0x8: - MMC1PRGHook16(0xC000, (DRegs[3] + offs)); - MMC1PRGHook16(0x8000, offs); - break; - case 0x0: - case 0x4: - MMC1PRGHook16(0x8000, ((DRegs[3] & ~1) + offs)); - MMC1PRGHook16(0xc000, ((DRegs[3] & ~1) + offs + 1)); - break; - } - } else { - switch (DRegs[0] & 0xC) { - case 0xC: - setprg16(0x8000, (DRegs[3] + offs)); - setprg16(0xC000, 0xF + offs); - break; - case 0x8: - setprg16(0xC000, (DRegs[3] + offs)); - setprg16(0x8000, offs); - break; - case 0x0: - case 0x4: - setprg16(0x8000, ((DRegs[3] & ~1) + offs)); - setprg16(0xc000, ((DRegs[3] & ~1) + offs + 1)); - break; - } - } -} - -static void MMC1MIRROR(void) { - if (!is171) - switch (DRegs[0] & 3) { - case 2: setmirror(MI_V); break; - case 3: setmirror(MI_H); break; - case 0: setmirror(MI_0); break; - case 1: setmirror(MI_1); break; - } -} - -static uint64 lreset; -static DECLFW(MMC1_write) { - int n = (A >> 13) - 4; - - /* The MMC1 is busy so ignore the write. */ - /* As of version FCE Ultra 0.81, the timestamp is only - increased before each instruction is executed(in other words - precision isn't that great), but this should still work to - deal with 2 writes in a row from a single RMW instruction. - */ - if ((timestampbase + timestamp) < (lreset + 2)) - return; -// FCEU_printf("Write %04x:%02x\n",A,V); - if (V & 0x80) { - DRegs[0] |= 0xC; - BufferShift = Buffer = 0; - MMC1PRG(); - lreset = timestampbase + timestamp; - return; - } - - Buffer |= (V & 1) << (BufferShift++); - - if (BufferShift == 5) { - DRegs[n] = Buffer; - BufferShift = Buffer = 0; - switch (n) { - case 0: MMC1MIRROR(); MMC1CHR(); MMC1PRG(); break; - case 1: MMC1CHR(); MMC1PRG(); break; - case 2: MMC1CHR(); break; - case 3: MMC1PRG(); break; - } - } -} - -static void MMC1_Restore(int version) { - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); - lreset = 0; // timestamp(base) is not stored in save states. -} - -static void MMC1CMReset(void) { - int i; - - for (i = 0; i < 4; i++) - DRegs[i] = 0; - Buffer = BufferShift = 0; - DRegs[0] = 0x1F; - - DRegs[1] = 0; - DRegs[2] = 0; // Should this be something other than 0? - DRegs[3] = 0; - - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); -} - -static int DetectMMC1WRAMSize(uint32 crc32) { - switch (crc32) { - case 0xc6182024: // Romance of the 3 Kingdoms - case 0x2225c20f: // Genghis Khan - case 0x4642dda6: // Nobunaga's Ambition - case 0x29449ba9: // "" "" (J) - case 0x2b11e0b0: // "" "" (J) - case 0xb8747abf: // Best Play Pro Yakyuu Special (J) - case 0xc9556b36: // Final Fantasy I & II (J) [!] - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(16); - break; - default: return(8); - } -} - -static uint32 NWCIRQCount; -static uint8 NWCRec; -#define NWCDIP 0xE - -static void NWCIRQHook(int a) { - if (!(NWCRec & 0x10)) { - NWCIRQCount += a; - if ((NWCIRQCount | (NWCDIP << 25)) >= 0x3e000000) { - NWCIRQCount = 0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void NWCCHRHook(uint32 A, uint8 V) { - if ((V & 0x10)) { // && !(NWCRec&0x10)) - NWCIRQCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - } - - NWCRec = V; - if (V & 0x08) - MMC1PRG(); - else - setprg32(0x8000, (V >> 1) & 3); -} - -static void NWCPRGHook(uint32 A, uint8 V) { - if (NWCRec & 0x8) - setprg16(A, 8 | (V & 0x7)); - else - setprg32(0x8000, (NWCRec >> 1) & 3); -} - -static void NWCPower(void) { - GenMMC1Power(); - setchr8r(0, 0); -} - -void Mapper105_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 8, 0); - MMC1CHRHook4 = NWCCHRHook; - MMC1PRGHook16 = NWCPRGHook; - MapIRQHook = NWCIRQHook; - info->Power = NWCPower; -} - -static void GenMMC1Power(void) { - lreset = 0; - if (mmc1opts & 1) { - FCEU_CheatAddRAM(8, 0x6000, WRAM); - if (mmc1opts & 4) - FCEU_dwmemset(WRAM, 0, 8192) - else if (!(mmc1opts & 2)) - FCEU_dwmemset(WRAM, 0, 8192); - } - SetWriteHandler(0x8000, 0xFFFF, MMC1_write); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - if (mmc1opts & 1) { - SetReadHandler(0x6000, 0x7FFF, MAWRAM); - SetWriteHandler(0x6000, 0x7FFF, MBWRAM); - setprg8r(0x10, 0x6000, 0); - } - - MMC1CMReset(); -} - -static void GenMMC1Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - if (WRAM) - FCEU_gfree(WRAM); - CHRRAM = WRAM = NULL; -} - -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) { - is155 = 0; - - info->Close = GenMMC1Close; - MMC1PRGHook16 = MMC1CHRHook4 = 0; - mmc1opts = 0; - PRGmask16[0] &= (prg >> 14) - 1; - CHRmask4[0] &= (chr >> 12) - 1; - CHRmask8[0] &= (chr >> 13) - 1; - - if (wram) { - WRAM = (uint8*)FCEU_gmalloc(wram * 1024); - //mbg 17-jun-08 - this shouldve been cleared to re-initialize save ram - //ch4 10-dec-08 - nope, this souldn't - //mbg 29-mar-09 - no time to debate this, we need to keep from breaking some old stuff. - //we really need to make up a policy for how compatibility and accuracy can be resolved. - memset(WRAM, 0, wram * 1024); - mmc1opts |= 1; - if (wram > 8) mmc1opts |= 4; - SetupCartPRGMapping(0x10, WRAM, wram * 1024, 1); - AddExState(WRAM, wram * 1024, 0, "WRAM"); - if (battery) { - mmc1opts |= 2; - info->SaveGame[0] = WRAM + ((mmc1opts & 4) ? 8192 : 0); - info->SaveGameLen[0] = 8192; - } - } - if (!chr) { - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - } - AddExState(DRegs, 4, 0, "DREG"); - - info->Power = GenMMC1Power; - GameStateRestore = MMC1_Restore; - AddExState(&lreset, 8, 1, "LRST"); - AddExState(&Buffer, 1, 1, "BFFR"); - AddExState(&BufferShift, 1, 1, "BFRS"); -} - -void Mapper1_Init(CartInfo *info) { - int ws = DetectMMC1WRAMSize(info->CRC32); - GenMMC1Init(info, 512, 256, ws, info->battery); -} - -/* Same as mapper 1, without respect for WRAM enable bit. */ -void Mapper155_Init(CartInfo *info) { - GenMMC1Init(info, 512, 256, 8, info->battery); - is155 = 1; -} - -/* Same as mapper 1, with different (or without) mirroring control. */ -/* Kaiser KS7058 board, KS203 custom chip */ -void Mapper171_Init(CartInfo *info) { - GenMMC1Init(info, 32, 32, 0, 0); - is171 = 1; -} - -void SAROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 64, 8, info->battery); -} - -void SBROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 64, 0, 0); -} - -void SCROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 128, 0, 0); -} - -void SEROM_Init(CartInfo *info) { - GenMMC1Init(info, 32, 64, 0, 0); -} - -void SGROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 0, 0); -} - -void SKROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 64, 8, info->battery); -} - -void SLROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 128, 0, 0); -} - -void SL1ROM_Init(CartInfo *info) { - GenMMC1Init(info, 128, 128, 0, 0); -} - -/* Begin unknown - may be wrong - perhaps they use different MMC1s from the - similarly functioning boards? -*/ - -void SL2ROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SFROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SHROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 256, 0, 0); -} - -/* End unknown */ -/* */ -/* */ - -void SNROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 8, info->battery); -} - -void SOROM_Init(CartInfo *info) { - GenMMC1Init(info, 256, 0, 16, info->battery); -} - - diff --git a/branches/sdl2/src/boards/mmc2and4.cpp b/branches/sdl2/src/boards/mmc2and4.cpp deleted file mode 100644 index e2c3d7ea..00000000 --- a/branches/sdl2/src/boards/mmc2and4.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "mapinc.h" - -static uint8 is10; -static uint8 creg[4], latch0, latch1, preg, mirr; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { creg, 4, "CREG" }, - { &preg, 1, "PREG" }, - { &mirr, 1, "MIRR" }, - { &latch0, 1, "LAT0" }, - { &latch1, 1, "LAT1" }, - { 0 } -}; - -static void Sync(void) { - if (is10) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - } else { - setprg8(0x8000, preg); - setprg8(0xA000, ~2); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - } - setchr4(0x0000, creg[latch0]); - setchr4(0x1000, creg[latch1 + 2]); - setmirror(mirr); -} - -DECLFW(MMC2and4Write) { - switch (A & 0xF000) { - case 0xA000: preg = V; Sync(); break; - case 0xB000: creg[0] = V; Sync(); break; - case 0xC000: creg[1] = V; Sync(); break; - case 0xD000: creg[2] = V; Sync(); break; - case 0xE000: creg[3] = V; Sync(); break; - case 0xF000: mirr = (V & 1) ^ 1; Sync(); break; - } -} - -static void MMC2and4PPUHook(uint32 A) { - uint8 l, h = A >> 8; - if (h >= 0x20 || ((h & 0xF) != 0xF)) - return; - l = A & 0xF0; - if (h < 0x10) { - if (l == 0xD0) { - latch0 = 0; - setchr4(0x0000, creg[0]); - } else if (l == 0xE0) { - latch0 = 1; - setchr4(0x0000, creg[1]); - } - } else { - if (l == 0xD0) { - latch1 = 0; - setchr4(0x1000, creg[2]); - } else if (l == 0xE0) { - latch1 = 1; - setchr4(0x1000, creg[3]); - } - } -} - -static void MMC2and4Power(void) { - preg = 0; - latch0 = latch1 = 1; - Sync(); - if (is10) { - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - } - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0xA000, 0xFFFF, MMC2and4Write); -} - -static void StateRestore(int version) { - Sync(); -} - -static void MMC2and4Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper9_Init(CartInfo *info) { - is10 = 0; - info->Power = MMC2and4Power; - PPU_hook = MMC2and4PPUHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper10_Init(CartInfo *info) { - is10 = 1; - info->Power = MMC2and4Power; - info->Close = MMC2and4Close; - PPU_hook = MMC2and4PPUHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/mmc3.cpp b/branches/sdl2/src/boards/mmc3.cpp deleted file mode 100644 index 775a6766..00000000 --- a/branches/sdl2/src/boards/mmc3.cpp +++ /dev/null @@ -1,1328 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2003 Xodnizel - * Mapper 12 code Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,165,205,245,249,250,254 -*/ - -#include "mapinc.h" -#include "mmc3.h" - -uint8 MMC3_cmd; -uint8 *WRAM; -uint32 WRAMSIZE; -uint8 *CHRRAM; -uint32 CHRRAMSIZE; -uint8 DRegBuf[8]; -uint8 EXPREGS[8]; /* For bootleg games, mostly. */ -uint8 A000B, A001B; -uint8 mmc3opts = 0; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -uint8 IRQCount, IRQLatch, IRQa; -uint8 IRQReload; - -static SFORMAT MMC3_StateRegs[] = -{ - { DRegBuf, 8, "REGS" }, - { &MMC3_cmd, 1, "CMD" }, - { &A000B, 1, "A000" }, - { &A001B, 1, "A001" }, - { &IRQReload, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static int isRevB = 1; - -void (*pwrap)(uint32 A, uint8 V); -void (*cwrap)(uint32 A, uint8 V); -void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); - -// ---------------------------------------------------------------------- -// ------------------------- Generic MM3 Code --------------------------- -// ---------------------------------------------------------------------- - -void FixMMC3PRG(int V) { - if (V & 0x40) { - pwrap(0xC000, DRegBuf[6]); - pwrap(0x8000, ~1); - } else { - pwrap(0x8000, DRegBuf[6]); - pwrap(0xC000, ~1); - } - pwrap(0xA000, DRegBuf[7]); - pwrap(0xE000, ~0); -} - -void FixMMC3CHR(int V) { - int cbase = (V & 0x80) << 5; - - cwrap((cbase ^ 0x000), DRegBuf[0] & (~1)); - cwrap((cbase ^ 0x400), DRegBuf[0] | 1); - cwrap((cbase ^ 0x800), DRegBuf[1] & (~1)); - cwrap((cbase ^ 0xC00), DRegBuf[1] | 1); - - cwrap(cbase ^ 0x1000, DRegBuf[2]); - cwrap(cbase ^ 0x1400, DRegBuf[3]); - cwrap(cbase ^ 0x1800, DRegBuf[4]); - cwrap(cbase ^ 0x1c00, DRegBuf[5]); - - if (mwrap) mwrap(A000B); -} - -void MMC3RegReset(void) { - IRQCount = IRQLatch = IRQa = MMC3_cmd = 0; - - DRegBuf[0] = 0; - DRegBuf[1] = 2; - DRegBuf[2] = 4; - DRegBuf[3] = 5; - DRegBuf[4] = 6; - DRegBuf[5] = 7; - DRegBuf[6] = 0; - DRegBuf[7] = 1; - - FixMMC3PRG(0); - FixMMC3CHR(0); -} - -DECLFW(MMC3_CMDWrite) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A & 0xE001) { - case 0x8000: - if ((V & 0x40) != (MMC3_cmd & 0x40)) - FixMMC3PRG(V); - if ((V & 0x80) != (MMC3_cmd & 0x80)) - FixMMC3CHR(V); - MMC3_cmd = V; - break; - case 0x8001: - { - int cbase = (MMC3_cmd & 0x80) << 5; - DRegBuf[MMC3_cmd & 0x7] = V; - switch (MMC3_cmd & 0x07) { - case 0: - cwrap((cbase ^ 0x000), V & (~1)); - cwrap((cbase ^ 0x400), V | 1); - break; - case 1: - cwrap((cbase ^ 0x800), V & (~1)); - cwrap((cbase ^ 0xC00), V | 1); - break; - case 2: - cwrap(cbase ^ 0x1000, V); - break; - case 3: - cwrap(cbase ^ 0x1400, V); - break; - case 4: - cwrap(cbase ^ 0x1800, V); - break; - case 5: - cwrap(cbase ^ 0x1C00, V); - break; - case 6: - if (MMC3_cmd & 0x40) - pwrap(0xC000, V); - else - pwrap(0x8000, V); - break; - case 7: - pwrap(0xA000, V); - break; - } - break; - } - case 0xA000: - if (mwrap) mwrap(V); - break; - case 0xA001: - A001B = V; - break; - } -} - -DECLFW(MMC3_IRQWrite) { -// FCEU_printf("%04x:%04x\n",A,V); - switch (A & 0xE001) { - case 0xC000: IRQLatch = V; break; - case 0xC001: IRQReload = 1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xE001: IRQa = 1; break; - } -} - -static void ClockMMC3Counter(void) { - int count = IRQCount; - if (!count || IRQReload) { - IRQCount = IRQLatch; - IRQReload = 0; - } else - IRQCount--; - if ((count | isRevB) && !IRQCount) { - if (IRQa) { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void MMC3_hb(void) { - ClockMMC3Counter(); -} - -static void MMC3_hb_KickMasterHack(void) { - if (scanline == 238) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -static void MMC3_hb_PALStarWarsHack(void) { - if (scanline == 240) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -void GenMMC3Restore(int version) { - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void GENCWRAP(uint32 A, uint8 V) { - setchr1(A, V); // Business Wars NEEDS THIS for 8K CHR-RAM -} - -static void GENPWRAP(uint32 A, uint8 V) { - setprg8(A, V & 0x7F); // [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken -} - -static void GENMWRAP(uint8 V) { - A000B = V; - setmirror((V & 1) ^ 1); -} - -static void GENNOMWRAP(uint8 V) { - A000B = V; -} - -static DECLFW(MBWRAMMMC6) { - WRAM[A & 0x3ff] = V; -} - -static DECLFR(MAWRAMMMC6) { - return(WRAM[A & 0x3ff]); -} - -void GenMMC3Power(void) { - if (UNIFchrrama) setchr8(0); - - SetWriteHandler(0x8000, 0xBFFF, MMC3_CMDWrite); - SetWriteHandler(0xC000, 0xFFFF, MMC3_IRQWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - A001B = A000B = 0; - setmirror(1); - if (mmc3opts & 1) { - if (WRAMSIZE == 1024) { - FCEU_CheatAddRAM(1, 0x7000, WRAM); - SetReadHandler(0x7000, 0x7FFF, MAWRAMMMC6); - SetWriteHandler(0x7000, 0x7FFF, MBWRAMMMC6); - } else { - FCEU_CheatAddRAM((WRAMSIZE & 0x1fff) >> 10, 0x6000, WRAM); - SetWriteHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBW); - SetReadHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBR); - setprg8r(0x10, 0x6000, 0); - } - if (!(mmc3opts & 2)) - FCEU_dwmemset(WRAM, 0, WRAMSIZE); - } - MMC3RegReset(); - if (CHRRAM) - FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE); -} - -static void GenMMC3Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - if (WRAM) - FCEU_gfree(WRAM); - CHRRAM = WRAM = NULL; -} - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) { - pwrap = GENPWRAP; - cwrap = GENCWRAP; - mwrap = GENMWRAP; - - WRAMSIZE = wram << 10; - - PRGmask8[0] &= (prg >> 13) - 1; - CHRmask1[0] &= (chr >> 10) - 1; - CHRmask2[0] &= (chr >> 11) - 1; - - if (wram) { - mmc3opts |= 1; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - } - - if (battery) { - mmc3opts |= 2; - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(MMC3_StateRegs, ~0, 0, 0); - - info->Power = GenMMC3Power; - info->Reset = MMC3RegReset; - info->Close = GenMMC3Close; - - if (info->CRC32 == 0x5104833e) // Kick Master - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if (info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20)// Shougi Meikan '92/'93 - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if (info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. - GameHBIRQHook = MMC3_hb_PALStarWarsHack; - else - GameHBIRQHook = MMC3_hb; - GameStateRestore = GenMMC3Restore; -} - -// ---------------------------------------------------------------------- -// -------------------------- MMC3 Based Code --------------------------- -// ---------------------------------------------------------------------- - -// ---------------------------- Mapper 4 -------------------------------- - -static int hackm4 = 0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/ - -static void M4Power(void) { - GenMMC3Power(); - A000B = (hackm4 ^ 1) & 1; - setmirror(hackm4); -} - -void Mapper4_Init(CartInfo *info) { - int ws = 8; - - if ((info->CRC32 == 0x93991433 || info->CRC32 == 0xaf65aa84)) { - FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); - ws = 0; - } - GenMMC3_Init(info, 512, 256, ws, info->battery); - info->Power = M4Power; - hackm4 = info->mirror; -} - -// ---------------------------- Mapper 12 ------------------------------- - -static void M12CW(uint32 A, uint8 V) { - setchr1(A, (EXPREGS[(A & 0x1000) >> 12] << 8) + V); -} - -static DECLFW(M12Write) { - EXPREGS[0] = V & 0x01; - EXPREGS[1] = (V & 0x10) >> 4; -} - -static DECLFR(M12Read) { - return EXPREGS[2]; -} - -static void M12Power(void) { - EXPREGS[0] = EXPREGS[1] = 0; - EXPREGS[2] = 1; // chinese is default - GenMMC3Power(); - SetWriteHandler(0x4100, 0x5FFF, M12Write); - SetReadHandler(0x4100, 0x5FFF, M12Read); -} - -static void M12Reset(void) { - EXPREGS[0] = EXPREGS[1] = 0; - EXPREGS[2] ^= 1; - MMC3RegReset(); -} - -void Mapper12_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M12CW; - isRevB = 0; - - info->Power = M12Power; - info->Reset = M12Reset; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 37 ------------------------------- - -static void M37PW(uint32 A, uint8 V) { - if (EXPREGS[0] != 2) - V &= 0x7; - else - V &= 0xF; - V |= EXPREGS[0] << 3; - setprg8(A, V); -} - -static void M37CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= EXPREGS[0] << 6; - setchr1(A, NV); -} - -static DECLFW(M37Write) { - EXPREGS[0] = (V & 6) >> 1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M37Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -static void M37Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M37Write); -} - -void Mapper37_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap = M37PW; - cwrap = M37CW; - info->Power = M37Power; - info->Reset = M37Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 44 ------------------------------- - -static void M44PW(uint32 A, uint8 V) { - uint32 NV = V; - if (EXPREGS[0] >= 6) NV &= 0x1F; - else NV &= 0x0F; - NV |= EXPREGS[0] << 4; - setprg8(A, NV); -} - -static void M44CW(uint32 A, uint8 V) { - uint32 NV = V; - if (EXPREGS[0] < 6) NV &= 0x7F; - NV |= EXPREGS[0] << 7; - setchr1(A, NV); -} - -static DECLFW(M44Write) { - if (A & 1) { - EXPREGS[0] = V & 7; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - MMC3_CMDWrite(A, V); -} - -static void M44Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0xA000, 0xBFFF, M44Write); -} - -void Mapper44_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M44CW; - pwrap = M44PW; - info->Power = M44Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 45 ------------------------------- - -static void M45CW(uint32 A, uint8 V) { - if (!UNIFchrrama) { - uint32 NV = V; - if (EXPREGS[2] & 8) - NV &= (1 << ((EXPREGS[2] & 7) + 1)) - 1; - else - if (EXPREGS[2]) - NV &= 0; // hack ;( don't know exactly how it should be - NV |= EXPREGS[0] | ((EXPREGS[2] & 0xF0) << 4); - setchr1(A, NV); - } -} - -static void M45PW(uint32 A, uint8 V) { - V &= (EXPREGS[3] & 0x3F) ^ 0x3F; - V |= EXPREGS[1]; - setprg8(A, V); -} - -static DECLFW(M45Write) { - if (EXPREGS[3] & 0x40) { - WRAM[A - 0x6000] = V; - return; - } - EXPREGS[EXPREGS[4]] = V; - EXPREGS[4] = (EXPREGS[4] + 1) & 3; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static DECLFR(M45Read) { - uint32 addr = 1 << (EXPREGS[5] + 4); - if (A & (addr | (addr - 1))) - return X.DB | 1; - else - return X.DB; -} - -static void M45Reset(void) { - EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = 0; - EXPREGS[5]++; - EXPREGS[5] &= 7; - MMC3RegReset(); -} - -static void M45Power(void) { - setchr8(0); - GenMMC3Power(); - EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = EXPREGS[4] = EXPREGS[5] = 0; - SetWriteHandler(0x5000, 0x7FFF, M45Write); - SetReadHandler(0x5000, 0x5FFF, M45Read); -} - -void Mapper45_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M45CW; - pwrap = M45PW; - info->Reset = M45Reset; - info->Power = M45Power; - AddExState(EXPREGS, 5, 0, "EXPR"); -} - -// ---------------------------- Mapper 47 ------------------------------- - -static void M47PW(uint32 A, uint8 V) { - V &= 0xF; - V |= EXPREGS[0] << 4; - setprg8(A, V); -} - -static void M47CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= EXPREGS[0] << 7; - setchr1(A, NV); -} - -static DECLFW(M47Write) { - EXPREGS[0] = V & 1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M47Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M47Write); -// SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper47_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); - pwrap = M47PW; - cwrap = M47CW; - info->Power = M47Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 49 ------------------------------- - -static void M49PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 1) { - V &= 0xF; - V |= (EXPREGS[0] & 0xC0) >> 2; - setprg8(A, V); - } else - setprg32(0x8000, (EXPREGS[0] >> 4) & 3); -} - -static void M49CW(uint32 A, uint8 V) { - uint32 NV = V; - NV &= 0x7F; - NV |= (EXPREGS[0] & 0xC0) << 1; - setchr1(A, NV); -} - -static DECLFW(M49Write) { - if (A001B & 0x80) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } -} - -static void M49Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -static void M49Power(void) { - M49Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M49Write); - SetReadHandler(0x6000, 0x7FFF, 0); -} - -void Mapper49_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 0, 0); - cwrap = M49CW; - pwrap = M49PW; - info->Reset = M49Reset; - info->Power = M49Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 52 ------------------------------- -static void M52PW(uint32 A, uint8 V) { - uint32 mask = 0x1F ^ ((EXPREGS[0] & 8) << 1); - uint32 bank = ((EXPREGS[0] & 6) | ((EXPREGS[0] >> 3) & EXPREGS[0] & 1)) << 4; - setprg8(A, bank | (V & mask)); -} - -static void M52CW(uint32 A, uint8 V) { - uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1); -// uint32 bank = (((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - uint32 bank = (((EXPREGS[0] >> 4) & 2) | (EXPREGS[0] & 4) | ((EXPREGS[0] >> 6) & (EXPREGS[0] >> 4) & 1)) << 7; // actually 256K CHR banks index bits is inverted! - setchr1(A, bank | (V & mask)); -} - -static DECLFW(M52Write) { - if (EXPREGS[1]) { - WRAM[A - 0x6000] = V; - return; - } - EXPREGS[1] = V & 0x80; - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M52Reset(void) { - EXPREGS[0] = EXPREGS[1] = 0; - MMC3RegReset(); -} - -static void M52Power(void) { - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, M52Write); -} - -void Mapper52_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap = M52CW; - pwrap = M52PW; - info->Reset = M52Reset; - info->Power = M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 76 ------------------------------- - -static void M76CW(uint32 A, uint8 V) { - if (A >= 0x1000) - setchr2((A & 0xC00) << 1, V); -} - -void Mapper76_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - cwrap = M76CW; -} - -// ---------------------------- Mapper 74 ------------------------------- - -static void M74CW(uint32 A, uint8 V) { - if ((V == 8) || (V == 9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper74_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M74CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 114 ------------------------------ - -static uint8 cmdin; -uint8 m114_perm[8] = { 0, 3, 1, 5, 6, 7, 2, 4 }; - -static void M114PWRAP(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { -// FCEU_printf("8000-C000:%02X\n",EXPREGS[0]&0xF); - setprg16(0x8000, EXPREGS[0] & 0xF); - setprg16(0xC000, EXPREGS[0] & 0xF); - } else { -// FCEU_printf("%04X:%02X\n",A,V&0x3F); - setprg8(A, V & 0x3F); - } -} - -static DECLFW(M114Write) { - switch (A & 0xE001) { - case 0x8001: MMC3_CMDWrite(0xA000, V); break; - case 0xA000: MMC3_CMDWrite(0x8000, (V & 0xC0) | (m114_perm[V & 7])); cmdin = 1; break; - case 0xC000: if (!cmdin) break; MMC3_CMDWrite(0x8001, V); cmdin = 0; break; - case 0xA001: IRQLatch = V; break; - case 0xC001: IRQReload = 1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xE001: IRQa = 1; break; - } -} - -static DECLFW(M114ExWrite) { - if (A <= 0x7FFF) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void M114Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, M114Write); - SetWriteHandler(0x5000, 0x7FFF, M114ExWrite); -} - -static void M114Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -void Mapper114_Init(CartInfo *info) { - isRevB = 0; - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M114PWRAP; - info->Power = M114Power; - info->Reset = M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDI"); -} - -// ---------------------------- Mapper 115 KN-658 board ------------------------------ - -static void M115PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { - if (EXPREGS[0] & 0x20) - setprg32(0x8000, (EXPREGS[0] & 0x0F) >> 1); // real hardware tests, info 100% now lol - else { - setprg16(0x8000, (EXPREGS[0] & 0x0F)); - setprg16(0xC000, (EXPREGS[0] & 0x0F)); - } - } else - setprg8(A, V); -} - -static void M115CW(uint32 A, uint8 V) { - setchr1(A, (uint32)V | ((EXPREGS[1] & 1) << 8)); -} - -static DECLFW(M115Write) { - if (A == 0x5080) - EXPREGS[2] = V; // Extra prot hardware 2-in-1 mode - else if (A == 0x6000) - EXPREGS[0] = V; - else if (A == 0x6001) - EXPREGS[1] = V; - FixMMC3PRG(MMC3_cmd); -} - -static DECLFR(M115Read) { - return EXPREGS[2]; -} - -static void M115Power(void) { - GenMMC3Power(); - SetWriteHandler(0x4100, 0x7FFF, M115Write); - SetReadHandler(0x5000, 0x5FFF, M115Read); -} - -void Mapper115_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap = M115CW; - pwrap = M115PW; - info->Power = M115Power; - AddExState(EXPREGS, 3, 0, "EXPR"); -} - -// ---------------------------- Mapper 118 ------------------------------ - -static uint8 PPUCHRBus; -static uint8 TKSMIR[8]; - -static void TKSPPU(uint32 A) { - A &= 0x1FFF; - A >>= 10; - PPUCHRBus = A; - setmirror(MI_0 + TKSMIR[A]); -} - -static void TKSWRAP(uint32 A, uint8 V) { - TKSMIR[A >> 10] = V >> 7; - setchr1(A, V & 0x7F); - if (PPUCHRBus == (A >> 10)) - setmirror(MI_0 + (V >> 7)); -} - -// ---------------------------- Mapper 119 ------------------------------ - -static void TQWRAP(uint32 A, uint8 V) { - setchr1r((V & 0x40) >> 2, A, V & 0x3F); -} - -void Mapper119_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap = TQWRAP; - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); -} - -// ---------------------------- Mapper 134 ------------------------------ - -static void M134PW(uint32 A, uint8 V) { - setprg8(A, (V & 0x1F) | ((EXPREGS[0] & 2) << 4)); -} - -static void M134CW(uint32 A, uint8 V) { - setchr1(A, (V & 0xFF) | ((EXPREGS[0] & 0x20) << 3)); -} - -static DECLFW(M134Write) { - EXPREGS[0] = V; - FixMMC3CHR(MMC3_cmd); - FixMMC3PRG(MMC3_cmd); -} - -static void M134Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x6001, 0x6001, M134Write); -} - -static void M134Reset(void) { - EXPREGS[0] = 0; - MMC3RegReset(); -} - -void Mapper134_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap = M134PW; - cwrap = M134CW; - info->Power = M134Power; - info->Reset = M134Reset; - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 165 ------------------------------ - -static void M165CW(uint32 A, uint8 V) { - if (V == 0) - setchr4r(0x10, A, 0); - else - setchr4(A, V >> 2); -} - -static void M165PPUFD(void) { - if (EXPREGS[0] == 0xFD) { - M165CW(0x0000, DRegBuf[0]); - M165CW(0x1000, DRegBuf[2]); - } -} - -static void M165PPUFE(void) { - if (EXPREGS[0] == 0xFE) { - M165CW(0x0000, DRegBuf[1]); - M165CW(0x1000, DRegBuf[4]); - } -} - -static void M165CWM(uint32 A, uint8 V) { - if (((MMC3_cmd & 0x7) == 0) || ((MMC3_cmd & 0x7) == 2)) - M165PPUFD(); - if (((MMC3_cmd & 0x7) == 1) || ((MMC3_cmd & 0x7) == 4)) - M165PPUFE(); -} - -static void M165PPU(uint32 A) { - if ((A & 0x1FF0) == 0x1FD0) { - EXPREGS[0] = 0xFD; - M165PPUFD(); - } else if ((A & 0x1FF0) == 0x1FE0) { - EXPREGS[0] = 0xFE; - M165PPUFE(); - } -} - -static void M165Power(void) { - EXPREGS[0] = 0xFD; - GenMMC3Power(); -} - -void Mapper165_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 128, 8, info->battery); - cwrap = M165CWM; - PPU_hook = M165PPU; - info->Power = M165Power; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 191 ------------------------------ - -static void M191CW(uint32 A, uint8 V) { - setchr1r((V & 0x80) >> 3, A, V); -} - -void Mapper191_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap = M191CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 192 ------------------------------- - -static void M192CW(uint32 A, uint8 V) { - //Ying Lie Qun Xia Zhuan (Chinese), - //You Ling Xing Dong (China) (Unl) [this will be mistakenly headered as m074 sometimes] - if ((V == 8) || (V == 9) || (V == 0xA) || (V == 0xB)) - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper192_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M192CW; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 194 ------------------------------- - -static void M194CW(uint32 A, uint8 V) { - if (V <= 1) //Dai-2-Ji - Super Robot Taisen (As).nes - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -void Mapper194_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M194CW; - CHRRAMSIZE = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 195 ------------------------------- -static void M195CW(uint32 A, uint8 V) { - if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) - setchr1r(0x10, A, V); - else - setchr1r(0, A, V); -} - -static void M195Power(void) { - GenMMC3Power(); - setprg4r(0x10, 0x5000, 2); - SetWriteHandler(0x5000, 0x5fff, CartBW); - SetReadHandler(0x5000, 0x5fff, CartBR); -} - -void Mapper195_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 16, info->battery); - cwrap = M195CW; - info->Power = M195Power; - CHRRAMSIZE = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); - AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); -} - -// ---------------------------- Mapper 196 ------------------------------- -// MMC3 board with optional command address line connection, allows to -// make three-four different wirings to IRQ address lines and separately to -// CMD address line, Mali Boss additionally check if wiring are correct for -// game - -static void M196PW(uint32 A, uint8 V) { - if (EXPREGS[0]) - setprg32(0x8000, EXPREGS[1]); - else - setprg8(A, V); -} - -static DECLFW(Mapper196Write) { - if (A >= 0xC000) { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1); - MMC3_IRQWrite(A, V); - } else { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1) | ((A >> 1) & 1); - MMC3_CMDWrite(A, V); - } -} - -static DECLFW(Mapper196WriteLo) { - EXPREGS[0] = 1; - EXPREGS[1] = (V & 0xf) | (V >> 4); - FixMMC3PRG(MMC3_cmd); -} - -static void Mapper196Power(void) { - GenMMC3Power(); - EXPREGS[0] = EXPREGS[1] = 0; - SetWriteHandler(0x6000, 0x6FFF, Mapper196WriteLo); - SetWriteHandler(0x8000, 0xFFFF, Mapper196Write); -} - -void Mapper196_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = M196PW; - info->Power = Mapper196Power; -} - -// ---------------------------- Mali Splash Bomb---------------------------- -// The same board as for 196 mapper games, but with additional data bit swap -// Also, it is impossible to work on the combined 196 mapper source with -// all data bits merged, because it's using one of them as 8000 reg... - -static void UNLMaliSBPW(uint32 A, uint8 V) { - setprg8(A, (V & 3) | ((V & 8) >> 1) | ((V & 4) << 1)); -} - -static void UNLMaliSBCW(uint32 A, uint8 V) { - setchr1(A, (V & 0xDD) | ((V & 0x20) >> 4) | ((V & 2) << 4)); -} - -static DECLFW(UNLMaliSBWrite) { - if (A >= 0xC000) { - A = (A & 0xFFFE) | ((A >> 2) & 1) | ((A >> 3) & 1); - MMC3_IRQWrite(A, V); - } else { - A = (A & 0xFFFE) | ((A >> 3) & 1); - MMC3_CMDWrite(A, V); - } -} - -static void UNLMaliSBPower(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xFFFF, UNLMaliSBWrite); -} - -void UNLMaliSB_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = UNLMaliSBPW; - cwrap = UNLMaliSBCW; - info->Power = UNLMaliSBPower; -} - -// ---------------------------- Mapper 197 ------------------------------- - -static void M197CW(uint32 A, uint8 V) { - if (A == 0x0000) - setchr4(0x0000, V >> 1); - else if (A == 0x1000) - setchr2(0x1000, V); - else if (A == 0x1400) - setchr2(0x1800, V); -} - -void Mapper197_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 8, 0); - cwrap = M197CW; -} - -// ---------------------------- Mapper 198 ------------------------------- - -static void M198PW(uint32 A, uint8 V) { - if (V >= 0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg8(A, V & 0x4F); - else - setprg8(A, V); -} - -void Mapper198_Init(CartInfo *info) { - GenMMC3_Init(info, 1024, 0, 16, info->battery); - pwrap = M198PW; - info->Power = M195Power; -} - -// ---------------------------- Mapper 205 ------------------------------ -// GN-45 BOARD - -static void M205PW(uint32 A, uint8 V) { -// GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü 1F + àïïàðàòíûé ïåðåêëþ÷àòåëü íà øèíå àäðåñà - setprg8(A, (V & 0x0f) | EXPREGS[0]); -} - -static void M205CW(uint32 A, uint8 V) { -// GN-30A - íà÷àëüíàÿ ìàñêà äîëæíà áûòü FF - setchr1(A, (V & 0x7F) | (EXPREGS[0] << 3)); -} - -static DECLFW(M205Write0) { - if (EXPREGS[2] == 0) { - EXPREGS[0] = A & 0x30; - EXPREGS[2] = A & 0x80; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - CartBW(A, V); -} - -static DECLFW(M205Write1) { - if (EXPREGS[2] == 0) { - EXPREGS[0] = V & 0x30; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - CartBW(A, V); -} - -static void M205Reset(void) { - EXPREGS[0] = EXPREGS[2] = 0; - MMC3RegReset(); -} - -static void M205Power(void) { - GenMMC3Power(); - SetWriteHandler(0x6000, 0x6fff, M205Write0); - SetWriteHandler(0x7000, 0x7fff, M205Write1); // OK-411 boards, the same logic, but data latched, 2-in-1 frankenstein -} - -void Mapper205_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = M205PW; - cwrap = M205CW; - info->Power = M205Power; - info->Reset = M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 245 ------------------------------ - -static void M245CW(uint32 A, uint8 V) { - if (!UNIFchrrama) // Yong Zhe Dou E Long - Dragon Quest VI (As).nes NEEDS THIS for RAM cart - setchr1(A, V & 7); - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); -} - -static void M245PW(uint32 A, uint8 V) { - setprg8(A, (V & 0x3F) | ((EXPREGS[0] & 2) << 5)); -} - -static void M245Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); -} - -void Mapper245_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M245CW; - pwrap = M245PW; - info->Power = M245Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 249 ------------------------------ - -static void M249PW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x2) { - if (V < 0x20) - V = (V & 1) | ((V >> 3) & 2) | ((V >> 1) & 4) | ((V << 2) & 8) | ((V << 2) & 0x10); - else { - V -= 0x20; - V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0); - } - } - setprg8(A, V); -} - -static void M249CW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x2) - V = (V & 3) | ((V >> 1) & 4) | ((V >> 4) & 8) | ((V >> 2) & 0x10) | ((V << 3) & 0x20) | ((V << 2) & 0xC0); - setchr1(A, V); -} - -static DECLFW(M249Write) { - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M249Power(void) { - EXPREGS[0] = 0; - GenMMC3Power(); - SetWriteHandler(0x5000, 0x5000, M249Write); -} - -void Mapper249_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = M249CW; - pwrap = M249PW; - info->Power = M249Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 250 ------------------------------ - -static DECLFW(M250Write) { - MMC3_CMDWrite((A & 0xE000) | ((A & 0x400) >> 10), A & 0xFF); -} - -static DECLFW(M250IRQWrite) { - MMC3_IRQWrite((A & 0xE000) | ((A & 0x400) >> 10), A & 0xFF); -} - -static void M250_Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xBFFF, M250Write); - SetWriteHandler(0xC000, 0xFFFF, M250IRQWrite); -} - -void Mapper250_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - info->Power = M250_Power; -} - -// ---------------------------- Mapper 254 ------------------------------ - -static DECLFR(MR254WRAM) { - if (EXPREGS[0]) - return WRAM[A - 0x6000]; - else - return WRAM[A - 0x6000] ^ EXPREGS[1]; -} - -static DECLFW(M254Write) { - switch (A) { - case 0x8000: EXPREGS[0] = 0xff; break; - case 0xA001: EXPREGS[1] = V; break; - } - MMC3_CMDWrite(A, V); -} - -static void M254_Power(void) { - GenMMC3Power(); - SetWriteHandler(0x8000, 0xBFFF, M254Write); - SetReadHandler(0x6000, 0x7FFF, MR254WRAM); -} - -void Mapper254_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, info->battery); - info->Power = M254_Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- UNIF Boards ----------------------------- - -void TBROM_Init(CartInfo *info) { - GenMMC3_Init(info, 64, 64, 0, 0); -} - -void TEROM_Init(CartInfo *info) { - GenMMC3_Init(info, 32, 32, 0, 0); -} - -void TFROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); -} - -void TGROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 0, 0, 0); -} - -void TKROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); -} - -void TLROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 0, 0); -} - -void TSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); -} - -void TLSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap = TKSWRAP; - mwrap = GENNOMWRAP; - PPU_hook = TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TKSROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap = TKSWRAP; - mwrap = GENNOMWRAP; - PPU_hook = TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TQROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap = TQWRAP; - CHRRAMSIZE = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); -} - -void HKROM_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 512, 1, info->battery); -} diff --git a/branches/sdl2/src/boards/mmc3.h b/branches/sdl2/src/boards/mmc3.h deleted file mode 100644 index 9dfbc920..00000000 --- a/branches/sdl2/src/boards/mmc3.h +++ /dev/null @@ -1,26 +0,0 @@ -extern uint8 MMC3_cmd; -extern uint8 mmc3opts; -extern uint8 A000B; -extern uint8 A001B; -extern uint8 EXPREGS[8]; -extern uint8 DRegBuf[8]; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -extern uint8 IRQCount,IRQLatch,IRQa; -extern uint8 IRQReload; - -extern void (*pwrap)(uint32 A, uint8 V); -extern void (*cwrap)(uint32 A, uint8 V); -extern void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void GenMMC3Restore(int version); -void MMC3RegReset(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); -DECLFW(MMC3_CMDWrite); -DECLFW(MMC3_IRQWrite); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); diff --git a/branches/sdl2/src/boards/mmc5.cpp b/branches/sdl2/src/boards/mmc5.cpp deleted file mode 100644 index d7703f4e..00000000 --- a/branches/sdl2/src/boards/mmc5.cpp +++ /dev/null @@ -1,874 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* None of this code should use any of the iNES bank switching wrappers. */ - -#include "mapinc.h" - -static void (*sfun)(int P); -static void (*psfun)(void); - -void MMC5RunSound(int Count); -void MMC5RunSoundHQ(void); - -static INLINE void MMC5SPRVROM_BANK1(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask1[0]; - MMC5SPRVPage[(A) >> 10] = &CHRptr[0][(V) << 10] - (A); - } -} - -static INLINE void MMC5BGVROM_BANK1(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask1[0]; MMC5BGVPage[(A) >> 10] = &CHRptr[0][(V) << 10] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK2(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask2[0]; MMC5SPRVPage[(A) >> 10] = MMC5SPRVPage[((A) >> 10) + 1] = &CHRptr[0][(V) << 11] - (A); - } -} -static INLINE void MMC5BGVROM_BANK2(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask2[0]; MMC5BGVPage[(A) >> 10] = MMC5BGVPage[((A) >> 10) + 1] = &CHRptr[0][(V) << 11] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK4(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask4[0]; MMC5SPRVPage[(A) >> 10] = MMC5SPRVPage[((A) >> 10) + 1] = MMC5SPRVPage[((A) >> 10) + 2] = MMC5SPRVPage[((A) >> 10) + 3] = &CHRptr[0][(V) << 12] - (A); - } -} -static INLINE void MMC5BGVROM_BANK4(uint32 A, uint32 V) { - if (CHRptr[0]) { - V &= CHRmask4[0]; MMC5BGVPage[(A) >> 10] = MMC5BGVPage[((A) >> 10) + 1] = MMC5BGVPage[((A) >> 10) + 2] = MMC5BGVPage[((A) >> 10) + 3] = &CHRptr[0][(V) << 12] - (A); - } -} - -static INLINE void MMC5SPRVROM_BANK8(uint32 V) { - if (CHRptr[0]) { - V &= CHRmask8[0]; MMC5SPRVPage[0] = MMC5SPRVPage[1] = MMC5SPRVPage[2] = MMC5SPRVPage[3] = MMC5SPRVPage[4] = MMC5SPRVPage[5] = MMC5SPRVPage[6] = MMC5SPRVPage[7] = &CHRptr[0][(V) << 13]; - } -} -static INLINE void MMC5BGVROM_BANK8(uint32 V) { - if (CHRptr[0]) { - V &= CHRmask8[0]; MMC5BGVPage[0] = MMC5BGVPage[1] = MMC5BGVPage[2] = MMC5BGVPage[3] = MMC5BGVPage[4] = MMC5BGVPage[5] = MMC5BGVPage[6] = MMC5BGVPage[7] = &CHRptr[0][(V) << 13]; - } -} - -static uint8 PRGBanks[4]; -static uint8 WRAMPage; -static uint16 CHRBanksA[8], CHRBanksB[4]; -static uint8 WRAMMaskEnable[2]; -uint8 mmc5ABMode; /* A=0, B=1 */ - -static uint8 IRQScanline, IRQEnable; -static uint8 CHRMode, NTAMirroring, NTFill, ATFill; - -static uint8 MMC5IRQR; -static uint8 MMC5LineCounter; -static uint8 mmc5psize, mmc5vsize; -static uint8 mul[2]; - -static uint8 *WRAM = NULL; -static uint8 *MMC5fill = NULL; -static uint8 *ExRAM = NULL; - -static uint8 MMC5WRAMsize; //configuration, not state -static uint8 MMC5WRAMIndex[8]; //configuration, not state - -static uint8 MMC5ROMWrProtect[4]; -static uint8 MMC5MemIn[5]; - -static void MMC5CHRA(void); -static void MMC5CHRB(void); - -typedef struct __cartdata { - uint32 crc32; - uint8 size; -} cartdata; - -#define Sprite16 (PPU[0]& 0x20) //Sprites 8x16/8x8 -//#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V)>>10][(V)] -static inline uint8 * MMC5BGVRAMADR(uint32 A) { - if (!Sprite16) { - if (mmc5ABMode == 0) - return &MMC5SPRVPage[(A) >> 10][(A)]; - else - return &MMC5BGVPage[(A) >> 10][(A)]; - } else return &MMC5BGVPage[(A) >> 10][(A)]; -} - -static void mmc5_PPUWrite(uint32 A, uint8 V) { - uint32 tmp = A; - extern uint8 PALRAM[0x20]; - - if (tmp >= 0x3F00) { - // hmmm.... - if (!(tmp & 0xf)) - PALRAM[0x00] = PALRAM[0x04] = PALRAM[0x08] = PALRAM[0x0C] = V & 0x3F; - else if (tmp & 3) PALRAM[(tmp & 0x1f)] = V & 0x3f; - } else if (tmp < 0x2000) { - if (PPUCHRRAM & (1 << (tmp >> 10))) - VPage[tmp >> 10][tmp] = V; - } else { - if (PPUNTARAM & (1 << ((tmp & 0xF00) >> 10))) - vnapage[((tmp & 0xF00) >> 10)][tmp & 0x3FF] = V; - } -} - -uint8 FASTCALL mmc5_PPURead(uint32 A) { - if (A < 0x2000) { - if (ppuphase == PPUPHASE_BG) - return *MMC5BGVRAMADR(A); - else return MMC5SPRVPage[(A) >> 10][(A)]; - } else { - return vnapage[(A >> 10) & 0x3][A & 0x3FF]; - } -} - -cartdata MMC5CartList[] = -{ - { 0x6f4e4312, 4 }, /* Aoki Ookami to Shiroki Mejika - Genchou Hishi */ - { 0x15fe6d0f, 2 }, /* Bandit Kings of Ancient China */ - { 0x671f23a8, 0 }, /* Castlevania III - Dracula's Curse (E) */ - { 0xcd4e7430, 0 }, /* Castlevania III - Dracula's Curse (KC) */ - { 0xed2465be, 0 }, /* Castlevania III - Dracula's Curse (U) */ - { 0xfe3488d1, 2 }, /* Daikoukai Jidai */ - { 0x0ec6c023, 1 }, /* Gemfire */ - { 0x0afb395e, 0 }, /* Gun Sight */ - { 0x1ced086f, 2 }, /* Ishin no Arashi */ - { 0x9cbadc25, 1 }, /* Just Breed */ - { 0x6396b988, 2 }, /* L'Empereur (J) */ - { 0x9c18762b, 2 }, /* L'Empereur (U) */ - { 0xb0480ae9, 0 }, /* Laser Invasion */ - { 0xb4735fac, 0 }, /* Metal Slader Glory */ - { 0xf540677b, 4 }, /* Nobunaga no Yabou - Bushou Fuuun Roku */ - { 0xeee9a682, 2 }, /* Nobunaga no Yabou - Sengoku Gunyuu Den (J) (PRG0) */ - { 0xf9b4240f, 2 }, /* Nobunaga no Yabou - Sengoku Gunyuu Den (J) (PRG1) */ - { 0x8ce478db, 2 }, /* Nobunaga's Ambition 2 */ - { 0xf011e490, 4 }, /* Romance of The Three Kingdoms II */ - { 0xbc80fb52, 1 }, /* Royal Blood */ - { 0x184c2124, 4 }, /* Sangokushi II (J) (PRG0) */ - { 0xee8e6553, 4 }, /* Sangokushi II (J) (PRG1) */ - { 0xd532e98f, 1 }, /* Shin 4 Nin Uchi Mahjong - Yakuman Tengoku */ - { 0x39f2ce4b, 2 }, /* Suikoden - Tenmei no Chikai */ - { 0xbb7f829a, 0 }, /* Uchuu Keibitai SDF */ - { 0xaca15643, 2 }, /* Uncharted Waters */ -}; - -#define MMC5_NOCARTS (sizeof(MMC5CartList) / sizeof(MMC5CartList[0])) -int DetectMMC5WRAMSize(uint32 crc32) { - int x; - for (x = 0; x < MMC5_NOCARTS; x++) { - if (crc32 == MMC5CartList[x].crc32) { - if(MMC5CartList[x].size > 1) - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(MMC5CartList[x].size * 8); - } - } - return 64; -} - -static void BuildWRAMSizeTable(void) { - int x; - for (x = 0; x < 8; x++) { - switch (MMC5WRAMsize) { - case 0: MMC5WRAMIndex[x] = 255; break; //X,X,X,X,X,X,X,X - case 1: MMC5WRAMIndex[x] = (x > 3) ? 255 : 0; break; //0,0,0,0,X,X,X,X - case 2: MMC5WRAMIndex[x] = (x & 4) >> 2; break; //0,0,0,0,1,1,1,1 - case 4: MMC5WRAMIndex[x] = (x > 3) ? 255 : (x & 3); break; //0,1,2,3,X,X,X,X - case 8: MMC5WRAMIndex[x] = x; break; //0,1,2,3,4,5,6,7 - } - } -} - -static void MMC5CHRA(void) { - int x; - switch (mmc5vsize & 3) { - case 0: - setchr8(CHRBanksA[7]); - MMC5SPRVROM_BANK8(CHRBanksA[7]); - break; - case 1: - setchr4(0x0000, CHRBanksA[3]); - setchr4(0x1000, CHRBanksA[7]); - MMC5SPRVROM_BANK4(0x0000, CHRBanksA[3]); - MMC5SPRVROM_BANK4(0x1000, CHRBanksA[7]); - break; - case 2: - setchr2(0x0000, CHRBanksA[1]); - setchr2(0x0800, CHRBanksA[3]); - setchr2(0x1000, CHRBanksA[5]); - setchr2(0x1800, CHRBanksA[7]); - MMC5SPRVROM_BANK2(0x0000, CHRBanksA[1]); - MMC5SPRVROM_BANK2(0x0800, CHRBanksA[3]); - MMC5SPRVROM_BANK2(0x1000, CHRBanksA[5]); - MMC5SPRVROM_BANK2(0x1800, CHRBanksA[7]); - break; - case 3: - for (x = 0; x < 8; x++) { - setchr1(x << 10, CHRBanksA[x]); - MMC5SPRVROM_BANK1(x << 10, CHRBanksA[x]); - } - break; - } -} - -static void MMC5CHRB(void) { - int x; - switch (mmc5vsize & 3) { - case 0: - setchr8(CHRBanksB[3]); - MMC5BGVROM_BANK8(CHRBanksB[3]); - break; - case 1: - setchr4(0x0000, CHRBanksB[3]); - setchr4(0x1000, CHRBanksB[3]); - MMC5BGVROM_BANK4(0x0000, CHRBanksB[3]); - MMC5BGVROM_BANK4(0x1000, CHRBanksB[3]); - break; - case 2: - setchr2(0x0000, CHRBanksB[1]); - setchr2(0x0800, CHRBanksB[3]); - setchr2(0x1000, CHRBanksB[1]); - setchr2(0x1800, CHRBanksB[3]); - MMC5BGVROM_BANK2(0x0000, CHRBanksB[1]); - MMC5BGVROM_BANK2(0x0800, CHRBanksB[3]); - MMC5BGVROM_BANK2(0x1000, CHRBanksB[1]); - MMC5BGVROM_BANK2(0x1800, CHRBanksB[3]); - break; - case 3: - for (x = 0; x < 8; x++) { - setchr1(x << 10, CHRBanksB[x & 3]); - MMC5BGVROM_BANK1(x << 10, CHRBanksB[x & 3]); - } - break; - } -} - -static void MMC5WRAM(uint32 A, uint32 V) { - V = MMC5WRAMIndex[V & 7]; - if (V != 255) { - setprg8r(0x10, A, V); - MMC5MemIn[(A - 0x6000) >> 13] = 1; - } else - MMC5MemIn[(A - 0x6000) >> 13] = 0; -} - -static void MMC5PRG(void) { - int x; - switch (mmc5psize & 3) { - case 0: - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = MMC5ROMWrProtect[2] = MMC5ROMWrProtect[3] = 1; - setprg32(0x8000, ((PRGBanks[1] & 0x7F) >> 2)); - for (x = 0; x < 4; x++) - MMC5MemIn[1 + x] = 1; - break; - case 1: - if (PRGBanks[1] & 0x80) { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 1; - setprg16(0x8000, (PRGBanks[1] >> 1)); - MMC5MemIn[1] = MMC5MemIn[2] = 1; - } else { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 0; - MMC5WRAM(0x8000, PRGBanks[1] & 7 & 0xFE); - MMC5WRAM(0xA000, (PRGBanks[1] & 7 & 0xFE) + 1); - } - MMC5MemIn[3] = MMC5MemIn[4] = 1; - MMC5ROMWrProtect[2] = MMC5ROMWrProtect[3] = 1; - setprg16(0xC000, (PRGBanks[3] & 0x7F) >> 1); - break; - case 2: - if (PRGBanks[1] & 0x80) { - MMC5MemIn[1] = MMC5MemIn[2] = 1; - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 1; - setprg16(0x8000, (PRGBanks[1] & 0x7F) >> 1); - } else { - MMC5ROMWrProtect[0] = MMC5ROMWrProtect[1] = 0; - MMC5WRAM(0x8000, PRGBanks[1] & 7 & 0xFE); - MMC5WRAM(0xA000, (PRGBanks[1] & 7 & 0xFE) + 1); - } - if (PRGBanks[2] & 0x80) { - MMC5ROMWrProtect[2] = 1; - MMC5MemIn[3] = 1; - setprg8(0xC000, PRGBanks[2] & 0x7F); - } else { - MMC5ROMWrProtect[2] = 0; - MMC5WRAM(0xC000, PRGBanks[2] & 7); - } - MMC5MemIn[4] = 1; - MMC5ROMWrProtect[3] = 1; - setprg8(0xE000, PRGBanks[3] & 0x7F); - break; - case 3: - for (x = 0; x < 3; x++) - if (PRGBanks[x] & 0x80) { - MMC5ROMWrProtect[x] = 1; - setprg8(0x8000 + (x << 13), PRGBanks[x] & 0x7F); - MMC5MemIn[1 + x] = 1; - } else { - MMC5ROMWrProtect[x] = 0; - MMC5WRAM(0x8000 + (x << 13), PRGBanks[x] & 7); - } - MMC5MemIn[4] = 1; - MMC5ROMWrProtect[3] = 1; - setprg8(0xE000, PRGBanks[3] & 0x7F); - break; - } -} - -static DECLFW(Mapper5_write) { - switch (A) { - case 0x5100: - mmc5psize = V; - MMC5PRG(); - break; - case 0x5101: - mmc5vsize = V; - if (!mmc5ABMode) { - MMC5CHRB(); - MMC5CHRA(); - } else { - MMC5CHRA(); - MMC5CHRB(); - } - break; - case 0x5102: - WRAMMaskEnable[0] = V; - break; - case 0x5103: - WRAMMaskEnable[1] = V; - break; - case 0x5104: - CHRMode = V; - MMC5HackCHRMode = V & 3; - break; - case 0x5105: - { - int x; - for (x = 0; x < 4; x++) { - switch ((V >> (x << 1)) & 3) { - case 0: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM; break; - case 1: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM + 0x400; break; - case 2: PPUNTARAM |= 1 << x; vnapage[x] = ExRAM; break; - case 3: PPUNTARAM &= ~(1 << x); vnapage[x] = MMC5fill; break; - } - } - NTAMirroring = V; - break; - } - case 0x5106: - if (V != NTFill) - FCEU_dwmemset(MMC5fill, (V | (V << 8) | (V << 16) | (V << 24)), 0x3c0); - NTFill = V; - break; - case 0x5107: - if (V != ATFill) { - unsigned char moop = V | (V << 2) | (V << 4) | (V << 6); - FCEU_dwmemset(MMC5fill + 0x3c0, moop | (moop << 8) | (moop << 16) | (moop << 24), 0x40); - } - ATFill = V; - break; - case 0x5113: - WRAMPage = V; - MMC5WRAM(0x6000, V & 7); - break; - case 0x5114: - case 0x5115: - case 0x5116: - case 0x5117: - PRGBanks[A & 3] = V; - MMC5PRG(); - break; - case 0x5120: - case 0x5121: - case 0x5122: - case 0x5123: - case 0x5124: - case 0x5125: - case 0x5126: - case 0x5127: - mmc5ABMode = 0; - CHRBanksA[A & 7] = V | ((MMC50x5130 & 0x3) << 8); - MMC5CHRA(); - break; - case 0x5128: - case 0x5129: - case 0x512a: - case 0x512b: - mmc5ABMode = 1; - CHRBanksB[A & 3] = V | ((MMC50x5130 & 0x3) << 8); - MMC5CHRB(); - break; - case 0x5130: MMC50x5130 = V; break; - case 0x5200: MMC5HackSPMode = V; break; - case 0x5201: MMC5HackSPScroll = (V >> 3) & 0x1F; break; - case 0x5202: MMC5HackSPPage = V & 0x3F; break; - case 0x5203: X6502_IRQEnd(FCEU_IQEXT); IRQScanline = V; break; - case 0x5204: X6502_IRQEnd(FCEU_IQEXT); IRQEnable = V & 0x80; break; - case 0x5205: mul[0] = V; break; - case 0x5206: mul[1] = V; break; - } -} - -static DECLFR(MMC5_ReadROMRAM) { - if (MMC5MemIn[(A - 0x6000) >> 13]) - return Page[A >> 11][A]; - else - return X.DB; -} - -static DECLFW(MMC5_WriteROMRAM) { - if ((A >= 0x8000) && (MMC5ROMWrProtect[(A - 0x8000) >> 13])) - return; - if (MMC5MemIn[(A - 0x6000) >> 13]) - if (((WRAMMaskEnable[0] & 3) | ((WRAMMaskEnable[1] & 3) << 2)) == 6) - Page[A >> 11][A] = V; -} - -static DECLFW(MMC5_ExRAMWr) { - if (MMC5HackCHRMode != 3) - ExRAM[A & 0x3ff] = V; -} - -static DECLFR(MMC5_ExRAMRd) { - return ExRAM[A & 0x3ff]; -} - -static DECLFR(MMC5_read) { - switch (A) { - case 0x5204: { - uint8 x; - X6502_IRQEnd(FCEU_IQEXT); - x = MMC5IRQR; - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - MMC5IRQR &= 0x40; - return x; - } - case 0x5205: - return(mul[0] * mul[1]); - case 0x5206: - return((mul[0] * mul[1]) >> 8); - } - return(X.DB); -} - -void MMC5Synco(void) { - int x; - - MMC5PRG(); - for (x = 0; x < 4; x++) { - switch ((NTAMirroring >> (x << 1)) & 3) { - case 0: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM; break; - case 1: PPUNTARAM |= 1 << x; vnapage[x] = NTARAM + 0x400; break; - case 2: PPUNTARAM |= 1 << x; vnapage[x] = ExRAM; break; - case 3: PPUNTARAM &= ~(1 << x); vnapage[x] = MMC5fill; break; - } - } - MMC5WRAM(0x6000, WRAMPage & 7); - if (!mmc5ABMode) { - MMC5CHRB(); - MMC5CHRA(); - } else { - MMC5CHRA(); - MMC5CHRB(); - } - - //in case the fill register changed, we need to overwrite the fill buffer - FCEU_dwmemset(MMC5fill, NTFill | (NTFill << 8) | (NTFill << 16) | (NTFill << 24), 0x3c0); - { - unsigned char moop = ATFill | (ATFill << 2) | (ATFill << 4) | (ATFill << 6); - FCEU_dwmemset(MMC5fill + 0x3c0, moop | (moop << 8) | (moop << 16) | (moop << 24), 0x40); - } - - MMC5HackCHRMode = CHRMode & 3; - - //zero 17-apr-2013 - why the heck should this happen here? anything in a `synco` should be depending on the state. - //im going to leave it commented out to see what happens - //X6502_IRQEnd(FCEU_IQEXT); -} - -void MMC5_hb(int scanline) { - if (scanline == 240) { - MMC5LineCounter = 0; - MMC5IRQR = 0x40; - return; - } - if (MMC5LineCounter < 240) { - if (MMC5LineCounter == IRQScanline) { - MMC5IRQR |= 0x80; - if (IRQEnable & 0x80) - X6502_IRQBegin(FCEU_IQEXT); - } - MMC5LineCounter++; - } - if (MMC5LineCounter == 240) - MMC5IRQR = 0; -} - -void MMC5_StateRestore(int version) { - MMC5Synco(); -} - -typedef struct { - uint16 wl[2]; - uint8 env[2]; - uint8 enable; - uint8 running; - uint8 raw; - uint8 rawcontrol; - int32 dcount[2]; - int32 BC[3]; - int32 vcount[2]; -} MMC5APU; - -static MMC5APU MMC5Sound; - - -static void Do5PCM() { - int32 V; - int32 start, end; - - start = MMC5Sound.BC[2]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - MMC5Sound.BC[2] = end; - - if (!(MMC5Sound.rawcontrol & 0x40) && MMC5Sound.raw) - for (V = start; V < end; V++) - Wave[V >> 4] += MMC5Sound.raw << 1; -} - -static void Do5PCMHQ() { - uint32 V; - if (!(MMC5Sound.rawcontrol & 0x40) && MMC5Sound.raw) - for (V = MMC5Sound.BC[2]; V < SOUNDTS; V++) - WaveHi[V] += MMC5Sound.raw << 5; - MMC5Sound.BC[2] = SOUNDTS; -} - - -static DECLFW(Mapper5_SW) { - A &= 0x1F; - - GameExpSound.Fill = MMC5RunSound; - GameExpSound.HiFill = MMC5RunSoundHQ; - - switch (A) { - case 0x10: if (psfun) psfun(); MMC5Sound.rawcontrol = V; break; - case 0x11: if (psfun) psfun(); MMC5Sound.raw = V; break; - - case 0x0: - case 0x4: - if (sfun) sfun(A >> 2); - MMC5Sound.env[A >> 2] = V; - break; - case 0x2: - case 0x6: - if (sfun) sfun(A >> 2); - MMC5Sound.wl[A >> 2] &= ~0x00FF; - MMC5Sound.wl[A >> 2] |= V & 0xFF; - break; - case 0x3: - case 0x7: - MMC5Sound.wl[A >> 2] &= ~0x0700; - MMC5Sound.wl[A >> 2] |= (V & 0x07) << 8; - MMC5Sound.running |= 1 << (A >> 2); - break; - case 0x15: - if (sfun) { - sfun(0); - sfun(1); - } - MMC5Sound.running &= V; - MMC5Sound.enable = V; - break; - } -} - -static void Do5SQ(int P) { - static int tal[4] = { 1, 2, 4, 6 }; - int32 V, amp, rthresh, wl; - int32 start, end; - - start = MMC5Sound.BC[P]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - MMC5Sound.BC[P] = end; - - wl = MMC5Sound.wl[P] + 1; - amp = (MMC5Sound.env[P] & 0xF) << 4; - rthresh = tal[(MMC5Sound.env[P] & 0xC0) >> 6]; - - if (wl >= 8 && (MMC5Sound.running & (P + 1))) { - int dc, vc; - - wl <<= 18; - dc = MMC5Sound.dcount[P]; - vc = MMC5Sound.vcount[P]; - - for (V = start; V < end; V++) { - if (dc < rthresh) - Wave[V >> 4] += amp; - vc -= nesincsize; - while (vc <= 0) { - vc += wl; - dc = (dc + 1) & 7; - } - } - MMC5Sound.dcount[P] = dc; - MMC5Sound.vcount[P] = vc; - } -} - -static void Do5SQHQ(int P) { - static int tal[4] = { 1, 2, 4, 6 }; - uint32 V; - int32 amp, rthresh, wl; - - wl = MMC5Sound.wl[P] + 1; - amp = ((MMC5Sound.env[P] & 0xF) << 8); - rthresh = tal[(MMC5Sound.env[P] & 0xC0) >> 6]; - - if (wl >= 8 && (MMC5Sound.running & (P + 1))) { - int dc, vc; - - wl <<= 1; - - dc = MMC5Sound.dcount[P]; - vc = MMC5Sound.vcount[P]; - for (V = MMC5Sound.BC[P]; V < SOUNDTS; V++) { - if (dc < rthresh) - WaveHi[V] += amp; - vc--; - if (vc <= 0) { /* Less than zero when first started. */ - vc = wl; - dc = (dc + 1) & 7; - } - } - MMC5Sound.dcount[P] = dc; - MMC5Sound.vcount[P] = vc; - } - MMC5Sound.BC[P] = SOUNDTS; -} - -void MMC5RunSoundHQ(void) { - Do5SQHQ(0); - Do5SQHQ(1); - Do5PCMHQ(); -} - -void MMC5HiSync(int32 ts) { - int x; - for (x = 0; x < 3; x++) - MMC5Sound.BC[x] = ts; -} - -void MMC5RunSound(int Count) { - int x; - Do5SQ(0); - Do5SQ(1); - Do5PCM(); - for (x = 0; x < 3; x++) - MMC5Sound.BC[x] = Count; -} - -void Mapper5_ESI(void) { - GameExpSound.RChange = Mapper5_ESI; - if (FSettings.SndRate) { - if (FSettings.soundq >= 1) { - sfun = Do5SQHQ; - psfun = Do5PCMHQ; - } else { - sfun = Do5SQ; - psfun = Do5PCM; - } - } else { - sfun = 0; - psfun = 0; - } - memset(MMC5Sound.BC, 0, sizeof(MMC5Sound.BC)); - memset(MMC5Sound.vcount, 0, sizeof(MMC5Sound.vcount)); - GameExpSound.HiSync = MMC5HiSync; -} - -void NSFMMC5_Init(void) { - memset(&MMC5Sound, 0, sizeof(MMC5Sound)); - mul[0] = mul[1] = 0; - ExRAM = (uint8*)FCEU_gmalloc(1024); - Mapper5_ESI(); - SetWriteHandler(0x5c00, 0x5fef, MMC5_ExRAMWr); - SetReadHandler(0x5c00, 0x5fef, MMC5_ExRAMRd); - MMC5HackCHRMode = 2; - SetWriteHandler(0x5000, 0x5015, Mapper5_SW); - SetWriteHandler(0x5205, 0x5206, Mapper5_write); - SetReadHandler(0x5205, 0x5206, MMC5_read); -} - -void NSFMMC5_Close(void) { - FCEU_gfree(ExRAM); - ExRAM = 0; -} - -static void GenMMC5Reset(void) { - int x; - - for (x = 0; x < 4; x++) PRGBanks[x] = ~0; - for (x = 0; x < 8; x++) CHRBanksA[x] = ~0; - for (x = 0; x < 4; x++) CHRBanksB[x] = ~0; - WRAMMaskEnable[0] = WRAMMaskEnable[1] = ~0; - - mmc5psize = mmc5vsize = 3; - CHRMode = 0; - - NTAMirroring = NTFill = ATFill = 0xFF; - - MMC5Synco(); - - SetWriteHandler(0x4020, 0x5bff, Mapper5_write); - SetReadHandler(0x4020, 0x5bff, MMC5_read); - - SetWriteHandler(0x5c00, 0x5fff, MMC5_ExRAMWr); - SetReadHandler(0x5c00, 0x5fff, MMC5_ExRAMRd); - - SetWriteHandler(0x6000, 0xFFFF, MMC5_WriteROMRAM); - SetReadHandler(0x6000, 0xFFFF, MMC5_ReadROMRAM); - - SetWriteHandler(0x5000, 0x5015, Mapper5_SW); - SetWriteHandler(0x5205, 0x5206, Mapper5_write); - SetReadHandler(0x5205, 0x5206, MMC5_read); - -// GameHBIRQHook=MMC5_hb; - FCEU_CheatAddRAM(8, 0x6000, WRAM); - FCEU_CheatAddRAM(1, 0x5c00, ExRAM); -} - -static SFORMAT MMC5_StateRegs[] = { - { PRGBanks, 4, "PRGB" }, - { CHRBanksA, 16, "CHRA" }, - { CHRBanksB, 8, "CHRB" }, - { &WRAMPage, 1, "WRMP" }, - { WRAMMaskEnable, 2, "WRME" }, - { &mmc5ABMode, 1, "ABMD" }, - { &IRQScanline, 1, "IRQS" }, - { &IRQEnable, 1, "IRQE" }, - { &CHRMode, 1, "CHRM" }, - { &NTAMirroring, 1, "NTAM" }, - { &NTFill, 1, "NTFL" }, - { &ATFill, 1, "ATFL" }, - - //zero 17-apr-2013 - added - { &MMC5IRQR, 1, "IRQR" }, - { &MMC5LineCounter, 1, "LCTR" }, - { &mmc5psize, 1, "PSIZ" }, - { &mmc5vsize, 1, "VSIZ" }, - { mul, 2, "MUL2" }, - { MMC5ROMWrProtect, 4, "WRPR" }, - { MMC5MemIn, 5, "MEMI" }, - - { &MMC5Sound.wl[0], 2 | FCEUSTATE_RLSB, "SDW0" }, - { &MMC5Sound.wl[1], 2 | FCEUSTATE_RLSB, "SDW1" }, - { MMC5Sound.env, 2, "SDEV" }, - { &MMC5Sound.enable, 1, "SDEN" }, - { &MMC5Sound.running, 1, "SDRU" }, - { &MMC5Sound.raw, 1, "SDRW" }, - { &MMC5Sound.rawcontrol, 1, "SDRC" }, - - //zero 17-apr-2013 - added - { &MMC5Sound.dcount[0], 4 | FCEUSTATE_RLSB, "DCT0" }, - { &MMC5Sound.dcount[1], 4 | FCEUSTATE_RLSB, "DCT1" }, - { &MMC5Sound.BC[0], 4 | FCEUSTATE_RLSB, "BC00" }, - { &MMC5Sound.BC[1], 4 | FCEUSTATE_RLSB, "BC01" }, - { &MMC5Sound.BC[2], 4 | FCEUSTATE_RLSB, "BC02" }, - { &MMC5Sound.vcount[0], 4 | FCEUSTATE_RLSB, "VCT0" }, - { &MMC5Sound.vcount[1], 4 | FCEUSTATE_RLSB, "VCT1" }, - { 0 } -}; - -static void GenMMC5_Init(CartInfo *info, int wsize, int battery) { - if (wsize) { - WRAM = (uint8*)FCEU_gmalloc(wsize * 1024); - SetupCartPRGMapping(0x10, WRAM, wsize * 1024, 1); - AddExState(WRAM, wsize * 1024, 0, "WRAM"); - } - - MMC5fill = (uint8*)FCEU_gmalloc(1024); - ExRAM = (uint8*)FCEU_gmalloc(1024); - - AddExState(ExRAM, 1024, 0, "ERAM"); - AddExState(&MMC5HackSPMode, 1, 0, "SPLM"); - AddExState(&MMC5HackSPScroll, 1, 0, "SPLS"); - AddExState(&MMC5HackSPPage, 1, 0, "SPLP"); - AddExState(&MMC50x5130, 1, 0, "5130"); - AddExState(MMC5_StateRegs, ~0, 0, 0); - - MMC5WRAMsize = wsize / 8; - BuildWRAMSizeTable(); - GameStateRestore = MMC5_StateRestore; - info->Power = GenMMC5Reset; - - if (battery) { - info->SaveGame[0] = WRAM; - if (wsize <= 16) - info->SaveGameLen[0] = 8192; - else - info->SaveGameLen[0] = 32768; - } - - MMC5HackVROMMask = CHRmask4[0]; - MMC5HackExNTARAMPtr = ExRAM; - MMC5Hack = 1; - MMC5HackVROMPTR = CHRptr[0]; - MMC5HackCHRMode = 0; - MMC5HackSPMode = MMC5HackSPScroll = MMC5HackSPPage = 0; - Mapper5_ESI(); - - FFCEUX_PPURead = mmc5_PPURead; - FFCEUX_PPUWrite = mmc5_PPUWrite; -} - -void Mapper5_Init(CartInfo *info) { - GenMMC5_Init(info, DetectMMC5WRAMSize(info->CRC32), info->battery); -} - -// ELROM seems to have 0KB of WRAM -// EKROM seems to have 8KB of WRAM, battery-backed -// ETROM seems to have 16KB of WRAM, battery-backed -// EWROM seems to have 32KB of WRAM, battery-backed - -void ELROM_Init(CartInfo *info) { - GenMMC5_Init(info, 0, 0); -} - -void EKROM_Init(CartInfo *info) { - GenMMC5_Init(info, 8, info->battery); -} - -void ETROM_Init(CartInfo *info) { - GenMMC5_Init(info, 16, info->battery); -} - -void EWROM_Init(CartInfo *info) { - GenMMC5_Init(info, 32, info->battery); -} diff --git a/branches/sdl2/src/boards/n106.cpp b/branches/sdl2/src/boards/n106.cpp deleted file mode 100644 index 71e189bf..00000000 --- a/branches/sdl2/src/boards/n106.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint16 IRQCount; -static uint8 IRQa; - -static uint8 WRAM[8192]; -static uint8 IRAM[128]; - -static DECLFR(AWRAM) { - return(WRAM[A - 0x6000]); -} - -static DECLFW(BWRAM) { - WRAM[A - 0x6000] = V; -} - -void Mapper19_ESI(void); - -static uint8 NTAPage[4]; - -static uint8 dopol; -static uint8 gorfus; -static uint8 gorko; - -static void NamcoSound(int Count); -static void NamcoSoundHack(void); -static void DoNamcoSound(int32 *Wave, int Count); -static void DoNamcoSoundHQ(void); -static void SyncHQ(int32 ts); - -static int is210; /* Lesser mapper. */ - -static uint8 PRG[3]; -static uint8 CHR[8]; - -static SFORMAT N106_StateRegs[] = { - { PRG, 3, "PRG" }, - { CHR, 8, "CHR" }, - { NTAPage, 4, "NTA" }, - { 0 } -}; - -static void SyncPRG(void) { - setprg8(0x8000, PRG[0]); - setprg8(0xa000, PRG[1]); - setprg8(0xc000, PRG[2]); - setprg8(0xe000, 0x3F); -} - -static void NamcoIRQHook(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount >= 0x7FFF) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = 0x7FFF; //7FFF; - } - } -} - -static DECLFR(Namco_Read4800) { - uint8 ret = IRAM[dopol & 0x7f]; - /* Maybe I should call NamcoSoundHack() here? */ - #ifdef FCEUDEF_DEBUGGER - if (!fceuindbg) - #endif - if (dopol & 0x80) - dopol = (dopol & 0x80) | ((dopol + 1) & 0x7f); - return ret; -} - -static DECLFR(Namco_Read5000) { - return(IRQCount); -} - -static DECLFR(Namco_Read5800) { - return(IRQCount >> 8); -} - -static void DoNTARAMROM(int w, uint8 V) { - NTAPage[w] = V; - if (V >= 0xE0) - setntamem(NTARAM + ((V & 1) << 10), 1, w); - else{ - V &= CHRmask1[0]; - setntamem(CHRptr[0] + (V << 10), 0, w); - } -} - -static void FixNTAR(void) { - int x; - for (x = 0; x < 4; x++) - DoNTARAMROM(x, NTAPage[x]); -} - -static void DoCHRRAMROM(int x, uint8 V) { - CHR[x] = V; - if (!is210 && !((gorfus >> ((x >> 2) + 6)) & 1) && (V >= 0xE0)) { -// printf("BLAHAHA: %d, %02x\n",x,V); -// setchr1r(0x10,x<<10,V&7); - } else - setchr1(x << 10, V); -} - -static void FixCRR(void) { - int x; - for (x = 0; x < 8; x++) - DoCHRRAMROM(x, CHR[x]); -} - -static DECLFW(Mapper19C0D8_write) { - DoNTARAMROM((A - 0xC000) >> 11, V); -} - -static uint32 FreqCache[8]; -static uint32 EnvCache[8]; -static uint32 LengthCache[8]; - -static void FixCache(int a, int V) { - int w = (a >> 3) & 0x7; - switch (a & 0x07) { - case 0x00: FreqCache[w] &= ~0x000000FF; FreqCache[w] |= V; break; - case 0x02: FreqCache[w] &= ~0x0000FF00; FreqCache[w] |= V << 8; break; - case 0x04: - FreqCache[w] &= ~0x00030000; FreqCache[w] |= (V & 3) << 16; - LengthCache[w] = (8 - ((V >> 2) & 7)) << 2; - break; - case 0x07: EnvCache[w] = (double)(V & 0xF) * 576716; break; - } -} - -static DECLFW(Mapper19_write) { - A &= 0xF800; - if (A >= 0x8000 && A <= 0xb800) - DoCHRRAMROM((A - 0x8000) >> 11, V); - else - switch (A) { - case 0x4800: - if (dopol & 0x40) { - if (FSettings.SndRate) { - NamcoSoundHack(); - GameExpSound.Fill = NamcoSound; - GameExpSound.HiFill = DoNamcoSoundHQ; - GameExpSound.HiSync = SyncHQ; - } - FixCache(dopol, V); - } - IRAM[dopol & 0x7f] = V; - if (dopol & 0x80) - dopol = (dopol & 0x80) | ((dopol + 1) & 0x7f); - break; - case 0xf800: - dopol = V; break; - case 0x5000: - IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x5800: - IRQCount &= 0x00ff; IRQCount |= (V & 0x7F) << 8; - IRQa = V & 0x80; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xE000: - gorko = V & 0xC0; - PRG[0] = V & 0x3F; - SyncPRG(); - break; - case 0xE800: - gorfus = V & 0xC0; - FixCRR(); - PRG[1] = V & 0x3F; - SyncPRG(); - break; - case 0xF000: - PRG[2] = V & 0x3F; - SyncPRG(); - break; - } -} - -static int dwave = 0; - -static void NamcoSoundHack(void) { - int32 z, a; - if (FSettings.soundq >= 1) { - DoNamcoSoundHQ(); - return; - } - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - if (a) DoNamcoSound(&Wave[dwave], a); - dwave += a; -} - -static void NamcoSound(int Count) { - int32 z, a; - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - if (a) DoNamcoSound(&Wave[dwave], a); - dwave = 0; -} - -static uint32 PlayIndex[8]; -static int32 vcount[8]; -static int32 CVBC; - -#define TOINDEX (16 + 1) - -// 16:15 -static void SyncHQ(int32 ts) { - CVBC = ts; -} - - -/* Things to do: - 1 Read freq low - 2 Read freq mid - 3 Read freq high - 4 Read envelope - ...? -*/ - -static INLINE uint32 FetchDuff(uint32 P, uint32 envelope) { - uint32 duff; - duff = IRAM[((IRAM[0x46 + (P << 3)] + (PlayIndex[P] >> TOINDEX)) & 0xFF) >> 1]; - if ((IRAM[0x46 + (P << 3)] + (PlayIndex[P] >> TOINDEX)) & 1) - duff >>= 4; - duff &= 0xF; - duff = (duff * envelope) >> 16; - return(duff); -} - -static void DoNamcoSoundHQ(void) { - int32 P, V; - int32 cyclesuck = (((IRAM[0x7F] >> 4) & 7) + 1) * 15; - - for (P = 7; P >= (7 - ((IRAM[0x7F] >> 4) & 7)); P--) { - if ((IRAM[0x44 + (P << 3)] & 0xE0) && (IRAM[0x47 + (P << 3)] & 0xF)) { - uint32 freq; - int32 vco; - uint32 duff2, lengo, envelope; - - vco = vcount[P]; - freq = FreqCache[P]; - envelope = EnvCache[P]; - lengo = LengthCache[P]; - - duff2 = FetchDuff(P, envelope); - for (V = CVBC << 1; V < (int)SOUNDTS << 1; V++) { - WaveHi[V >> 1] += duff2; - if (!vco) { - PlayIndex[P] += freq; - while ((PlayIndex[P] >> TOINDEX) >= lengo) PlayIndex[P] -= lengo << TOINDEX; - duff2 = FetchDuff(P, envelope); - vco = cyclesuck; - } - vco--; - } - vcount[P] = vco; - } - } - CVBC = SOUNDTS; -} - - -static void DoNamcoSound(int32 *Wave, int Count) { - int P, V; - for (P = 7; P >= 7 - ((IRAM[0x7F] >> 4) & 7); P--) { - if ((IRAM[0x44 + (P << 3)] & 0xE0) && (IRAM[0x47 + (P << 3)] & 0xF)) { - int32 inc; - uint32 freq; - int32 vco; - uint32 duff, duff2, lengo, envelope; - - vco = vcount[P]; - freq = FreqCache[P]; - envelope = EnvCache[P]; - lengo = LengthCache[P]; - - if (!freq) { /*printf("Ack");*/ - continue; - } - - { - int c = ((IRAM[0x7F] >> 4) & 7) + 1; - inc = (long double)(FSettings.SndRate << 15) / ((long double)freq * 21477272 / ((long double)0x400000 * c * 45)); - } - - duff = IRAM[(((IRAM[0x46 + (P << 3)] + PlayIndex[P]) & 0xFF) >> 1)]; - if ((IRAM[0x46 + (P << 3)] + PlayIndex[P]) & 1) - duff >>= 4; - duff &= 0xF; - duff2 = (duff * envelope) >> 19; - for (V = 0; V < Count * 16; V++) { - if (vco >= inc) { - PlayIndex[P]++; - if (PlayIndex[P] >= lengo) - PlayIndex[P] = 0; - vco -= inc; - duff = IRAM[(((IRAM[0x46 + (P << 3)] + PlayIndex[P]) & 0xFF) >> 1)]; - if ((IRAM[0x46 + (P << 3)] + PlayIndex[P]) & 1) - duff >>= 4; - duff &= 0xF; - duff2 = (duff * envelope) >> 19; - } - Wave[V >> 4] += duff2; - vco += 0x8000; - } - vcount[P] = vco; - } - } -} - -static void Mapper19_StateRestore(int version) { - SyncPRG(); - FixNTAR(); - FixCRR(); - int x; - for (x = 0x40; x < 0x80; x++) - FixCache(x, IRAM[x]); -} - -static void M19SC(void) { - if (FSettings.SndRate) - Mapper19_ESI(); -} - -void Mapper19_ESI(void) { - GameExpSound.RChange = M19SC; - memset(vcount, 0, sizeof(vcount)); - memset(PlayIndex, 0, sizeof(PlayIndex)); - CVBC = 0; -} - -void NSFN106_Init(void) { - SetWriteHandler(0xf800, 0xffff, Mapper19_write); - SetWriteHandler(0x4800, 0x4fff, Mapper19_write); - SetReadHandler(0x4800, 0x4fff, Namco_Read4800); - Mapper19_ESI(); -} - -static int battery = 0; - -static void N106_Power(void) { - int x; - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xffff, Mapper19_write); - SetWriteHandler(0x4020, 0x5fff, Mapper19_write); - if (!is210) { - SetWriteHandler(0xc000, 0xdfff, Mapper19C0D8_write); - SetReadHandler(0x4800, 0x4fff, Namco_Read4800); - SetReadHandler(0x5000, 0x57ff, Namco_Read5000); - SetReadHandler(0x5800, 0x5fff, Namco_Read5800); - NTAPage[0] = NTAPage[1] = NTAPage[2] = NTAPage[3] = 0xFF; - FixNTAR(); - } - - SetReadHandler(0x6000, 0x7FFF, AWRAM); - SetWriteHandler(0x6000, 0x7FFF, BWRAM); - FCEU_CheatAddRAM(8, 0x6000, WRAM); - - gorfus = 0xFF; - SyncPRG(); - FixCRR(); - - if (!battery) { - FCEU_dwmemset(WRAM, 0, 8192); - FCEU_dwmemset(IRAM, 0, 128); - } - for (x = 0x40; x < 0x80; x++) - FixCache(x, IRAM[x]); -} - -void Mapper19_Init(CartInfo *info) { - is210 = 0; - battery = info->battery; - info->Power = N106_Power; - - MapIRQHook = NamcoIRQHook; - GameStateRestore = Mapper19_StateRestore; - GameExpSound.RChange = M19SC; - - if (FSettings.SndRate) - Mapper19_ESI(); - - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(IRAM, 128, 0, "IRAM"); - AddExState(N106_StateRegs, ~0, 0, 0); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = 8192; - info->SaveGame[1] = IRAM; - info->SaveGameLen[1] = 128; - } -} - -static void Mapper210_StateRestore(int version) { - SyncPRG(); - FixCRR(); -} - -void Mapper210_Init(CartInfo *info) { - is210 = 1; - GameStateRestore = Mapper210_StateRestore; - info->Power = N106_Power; - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(N106_StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/n625092.cpp b/branches/sdl2/src/boards/n625092.cpp deleted file mode 100644 index 058cd3d8..00000000 --- a/branches/sdl2/src/boards/n625092.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * 700in1 and 400in1 carts - * - */ - - -#include "mapinc.h" - -static uint16 cmd, bank; - -static SFORMAT StateRegs[] = -{ - { &cmd, 2, "CMD" }, - { &bank, 2, "BANK" }, - { 0 } -}; - -static void Sync(void) { - setmirror((cmd & 1) ^ 1); - setchr8(0); - if (cmd & 2) { - if (cmd & 0x100) { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | bank); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | 7); - } else { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | (bank & 6)); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | ((bank & 6) | 1)); - } - } else { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | bank); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | bank); - } -} - -static uint16 ass = 0; - -static DECLFW(UNLN625092WriteCommand) { - cmd = A; - if (A == 0x80F8) { - setprg16(0x8000, ass); - setprg16(0xC000, ass); - } else { - Sync(); - } -} - -static DECLFW(UNLN625092WriteBank) { - bank = A & 7; - Sync(); -} - -static void UNLN625092Power(void) { - cmd = 0; - bank = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, UNLN625092WriteCommand); - SetWriteHandler(0xC000, 0xFFFF, UNLN625092WriteBank); -} - -static void UNLN625092Reset(void) { - cmd = 0; - bank = 0; - ass++; - FCEU_printf("%04x\n", ass); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLN625092_Init(CartInfo *info) { - info->Reset = UNLN625092Reset; - info->Power = UNLN625092Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/novel.cpp b/branches/sdl2/src/boards/novel.cpp deleted file mode 100644 index c6dca068..00000000 --- a/branches/sdl2/src/boards/novel.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 latch; - -static void DoNovel(void) { - setprg32(0x8000, latch & 3); - setchr8(latch & 7); -} - -static DECLFW(NovelWrite) { - latch = A & 0xFF; - DoNovel(); -} - -static void NovelReset(void) { - SetWriteHandler(0x8000, 0xFFFF, NovelWrite); - SetReadHandler(0x8000, 0xFFFF, CartBR); - setprg32(0x8000, 0); - setchr8(0); -} - -static void NovelRestore(int version) { - DoNovel(); -} - -void Novel_Init(CartInfo *info) { - AddExState(&latch, 1, 0, "L1"); - info->Power = NovelReset; - GameStateRestore = NovelRestore; -} diff --git a/branches/sdl2/src/boards/onebus.cpp b/branches/sdl2/src/boards/onebus.cpp deleted file mode 100644 index 96ce0265..00000000 --- a/branches/sdl2/src/boards/onebus.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007-2010 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VR02/VT03 Console and OneBus System - * - * Street Dance (Dance pad) (Unl) - * 101-in-1 Arcade Action II - * DreamGEAR 75-in-1, etc. - * - */ - -#include "mapinc.h" - -// General Purpose Registers -static uint8 cpu410x[16], ppu201x[16], apu40xx[64]; - -// IRQ Registers -static uint8 IRQCount, IRQa, IRQReload; -#define IRQLatch cpu410x[0x1] - -// MMC3 Registers -static uint8 inv_hack = 0; // some OneBus Systems have swapped PRG reg commans in MMC3 inplementation, - // trying to autodetect unusual behavior, due not to add a new mapper. -#define mmc3cmd cpu410x[0x5] -#define mirror cpu410x[0x6] - -// APU Registers -static uint8 pcm_enable = 0, pcm_irq = 0; -static int16 pcm_addr, pcm_size, pcm_latch, pcm_clock = 0xF6; - -static writefunc defapuwrite[64]; -static readfunc defapuread[64]; - -static SFORMAT StateRegs[] = -{ - { cpu410x, 16, "REGC" }, - { ppu201x, 16, "REGS" }, - { apu40xx, 64, "REGA" }, - { &IRQReload, 1, "IRQR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { &pcm_enable, 1, "PCME" }, - { &pcm_irq, 1, "PCMI" }, - { &pcm_addr, 2, "PCMA" }, - { &pcm_size, 2, "PCMS" }, - { &pcm_latch, 2, "PCML" }, - { &pcm_clock, 2, "PCMC" }, - { 0 } -}; - -static void PSync(void) { - uint8 bankmode = cpu410x[0xb] & 7; - uint8 mask = (bankmode == 0x7) ? (0xff) : (0x3f >> bankmode); - uint32 block = ((cpu410x[0x0] & 0xf0) << 4) + (cpu410x[0xa] & (~mask)); - uint32 pswap = (mmc3cmd & 0x40) << 8; - -// uint8 bank0 = (cpu410x[0xb] & 0x40)?(~1):(cpu410x[0x7]); -// uint8 bank1 = cpu410x[0x8]; -// uint8 bank2 = (cpu410x[0xb] & 0x40)?(cpu410x[0x9]):(~1); -// uint8 bank3 = ~0; - uint8 bank0 = cpu410x[0x7 ^ inv_hack]; - uint8 bank1 = cpu410x[0x8 ^ inv_hack]; - uint8 bank2 = (cpu410x[0xb] & 0x40) ? (cpu410x[0x9]) : (~1); - uint8 bank3 = ~0; - -// FCEU_printf(" PRG: %04x [%02x]",0x8000^pswap,block | (bank0 & mask)); - setprg8(0x8000 ^ pswap, block | (bank0 & mask)); -// FCEU_printf(" %04x [%02x]",0xa000^pswap,block | (bank1 & mask)); - setprg8(0xa000, block | (bank1 & mask)); -// FCEU_printf(" %04x [%02x]",0xc000^pswap,block | (bank2 & mask)); - setprg8(0xc000 ^ pswap, block | (bank2 & mask)); -// FCEU_printf(" %04x [%02x]\n",0xe000^pswap,block | (bank3 & mask)); - setprg8(0xe000, block | (bank3 & mask)); -} - -static void CSync(void) { - static const uint8 midx[8] = { 0, 1, 2, 0, 3, 4, 5, 0 }; - uint8 mask = 0xff >> midx[ppu201x[0xa] & 7]; - uint32 block = ((cpu410x[0x0] & 0x0f) << 11) + ((ppu201x[0x8] & 0x70) << 4) + (ppu201x[0xa] & (~mask)); - uint32 cswap = (mmc3cmd & 0x80) << 5; - - uint8 bank0 = ppu201x[0x6] & (~1); - uint8 bank1 = ppu201x[0x6] | 1; - uint8 bank2 = ppu201x[0x7] & (~1); - uint8 bank3 = ppu201x[0x7] | 1; - uint8 bank4 = ppu201x[0x2]; - uint8 bank5 = ppu201x[0x3]; - uint8 bank6 = ppu201x[0x4]; - uint8 bank7 = ppu201x[0x5]; - - setchr1(0x0000 ^ cswap, block | (bank0 & mask)); - setchr1(0x0400 ^ cswap, block | (bank1 & mask)); - setchr1(0x0800 ^ cswap, block | (bank2 & mask)); - setchr1(0x0c00 ^ cswap, block | (bank3 & mask)); - setchr1(0x1000 ^ cswap, block | (bank4 & mask)); - setchr1(0x1400 ^ cswap, block | (bank5 & mask)); - setchr1(0x1800 ^ cswap, block | (bank6 & mask)); - setchr1(0x1c00 ^ cswap, block | (bank7 & mask)); - - setmirror((mirror & 1) ^ 1); -} - -static void Sync(void) { - PSync(); - CSync(); -} - -static DECLFW(UNLOneBusWriteCPU410X) { -// FCEU_printf("CPU %04x:%04x\n",A,V); - switch (A & 0xf) { - case 0x1: IRQLatch = V & 0xfe; break; - case 0x2: IRQReload = 1; break; - case 0x3: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0x4: IRQa = 1; break; - default: - cpu410x[A & 0xf] = V; - Sync(); - } -} - -static DECLFW(UNLOneBusWritePPU201X) { -// FCEU_printf("PPU %04x:%04x\n",A,V); - ppu201x[A & 0x0f] = V; - Sync(); -} - -static DECLFW(UNLOneBusWriteMMC3) { -// FCEU_printf("MMC %04x:%04x\n",A,V); - switch (A & 0xe001) { - case 0x8000: mmc3cmd = (mmc3cmd & 0x38) | (V & 0xc7); Sync(); break; - case 0x8001: - { - switch (mmc3cmd & 7) { - case 0: ppu201x[0x6] = V; CSync(); break; - case 1: ppu201x[0x7] = V; CSync(); break; - case 2: ppu201x[0x2] = V; CSync(); break; - case 3: ppu201x[0x3] = V; CSync(); break; - case 4: ppu201x[0x4] = V; CSync(); break; - case 5: ppu201x[0x5] = V; CSync(); break; - case 6: cpu410x[0x7] = V; PSync(); break; - case 7: cpu410x[0x8] = V; PSync(); break; - } - break; - } - case 0xa000: mirror = V; CSync(); break; - case 0xc000: IRQLatch = V & 0xfe; break; - case 0xc001: IRQReload = 1; break; - case 0xe000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; - case 0xe001: IRQa = 1; break; - } -} - -static void UNLOneBusIRQHook(void) { - uint32 count = IRQCount; - if (!count || IRQReload) { - IRQCount = IRQLatch; - IRQReload = 0; - } else - IRQCount--; - if (count && !IRQCount) { - if (IRQa) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static DECLFW(UNLOneBusWriteAPU40XX) { -// FCEU_printf("APU %04x:%04x\n",A,V); - apu40xx[A & 0x3f] = V; - switch (A & 0x3f) { - case 0x12: - if (apu40xx[0x30] & 0x10) { - pcm_addr = V << 6; - } - case 0x13: - if (apu40xx[0x30] & 0x10) { - pcm_size = (V << 4) + 1; - } - case 0x15: - if (apu40xx[0x30] & 0x10) { - pcm_enable = V & 0x10; - if (pcm_irq) { - X6502_IRQEnd(FCEU_IQEXT); - pcm_irq = 0; - } - if (pcm_enable) - pcm_latch = pcm_clock; - V &= 0xef; - } - } - defapuwrite[A & 0x3f](A, V); -} - -static DECLFR(UNLOneBusReadAPU40XX) { - uint8 result = defapuread[A & 0x3f](A); -// FCEU_printf("read %04x, %02x\n",A,result); - switch (A & 0x3f) { - case 0x15: - if (apu40xx[0x30] & 0x10) { - result = (result & 0x7f) | pcm_irq; - } - } - return result; -} - -static void UNLOneBusCpuHook(int a) { - if (pcm_enable) { - pcm_latch -= a; - if (pcm_latch <= 0) { - pcm_latch += pcm_clock; - pcm_size--; - if (pcm_size < 0) { - pcm_irq = 0x80; - pcm_enable = 0; - X6502_IRQBegin(FCEU_IQEXT); - } else { - uint8 raw_pcm = ARead[pcm_addr](pcm_addr) >> 1; - defapuwrite[0x11](0x4011, raw_pcm); - pcm_addr++; - pcm_addr &= 0x7FFF; - } - } - } -} - -static void UNLOneBusPower(void) { - uint32 i; - IRQReload = IRQCount = IRQa = 0; - - memset(cpu410x, 0x00, sizeof(cpu410x)); - memset(ppu201x, 0x00, sizeof(ppu201x)); - memset(apu40xx, 0x00, sizeof(apu40xx)); - - SetupCartCHRMapping(0, PRGptr[0], PRGsize[0], 0); - - for (i = 0; i < 64; i++) { - defapuread[i] = GetReadHandler(0x4000 | i); - defapuwrite[i] = GetWriteHandler(0x4000 | i); - } - SetReadHandler(0x4000, 0x403f, UNLOneBusReadAPU40XX); - SetWriteHandler(0x4000, 0x403f, UNLOneBusWriteAPU40XX); - - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x2010, 0x201f, UNLOneBusWritePPU201X); - SetWriteHandler(0x4100, 0x410f, UNLOneBusWriteCPU410X); - SetWriteHandler(0x8000, 0xffff, UNLOneBusWriteMMC3); - - Sync(); -} - -static void UNLOneBusReset(void) { - IRQReload = IRQCount = IRQa = 0; - - memset(cpu410x, 0x00, sizeof(cpu410x)); - memset(ppu201x, 0x00, sizeof(ppu201x)); - memset(apu40xx, 0x00, sizeof(apu40xx)); - - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLOneBus_Init(CartInfo *info) { - info->Power = UNLOneBusPower; - info->Reset = UNLOneBusReset; - - if (((*(uint32*)&(info->MD5)) == 0x305fcdc3) || // PowerJoy Supermax Carts - ((*(uint32*)&(info->MD5)) == 0x6abfce8e)) - inv_hack = 0xf; - - GameHBIRQHook = UNLOneBusIRQHook; - MapIRQHook = UNLOneBusCpuHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/pec-586.cpp b/branches/sdl2/src/boards/pec-586.cpp deleted file mode 100644 index 6de80af7..00000000 --- a/branches/sdl2/src/boards/pec-586.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 reg[8]; -static uint32 lastnt = 0; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { reg, 2, "REG" }, - { &lastnt, 4, "LNT" }, - { 0 } -}; - -static uint8 bs_tbl[128] = { - 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 00 - 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 10 - 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, // 20 - 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 30 - 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, // 40 - 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, // 50 - 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x00, 0x10, 0x20, 0x30, // 60 - 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, // 70 -}; - -static uint8 br_tbl[16] = { - 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, -}; - -static void Sync(void) { - setchr8(0); - setprg8r(0x10, 0x6000, 0); - if(PRGsize[0] == 512 * 1024) { - if(reg[0] & 0x010) { - setprg32(0x8000, reg[0] & 7); - } else { - if(reg[0] & 0x40) - setprg8(0x8000, (reg[0] & 0x0F) | 0x20 | ((reg[0] & 0x20) >> 1)); - } - if((reg[0] & 0x18) == 0x18) - setmirror(MI_H); - else - setmirror(MI_V); - } else { - setprg16(0x8000, bs_tbl[reg[0] & 0x7f] >> 4); - setprg16(0xc000, bs_tbl[reg[0] & 0x7f] & 0xf); - setmirror(MI_V); - } -} - -static DECLFW(UNLPEC586Write) { - reg[(A & 0x700) >> 8] = V; - PEC586Hack = (reg[0] & 0x80) >> 7; -// FCEU_printf("bs %04x %02x\n", A, V); - Sync(); -} - -static DECLFR(UNLPEC586Read) { -// FCEU_printf("read %04x\n", A); - return (X.DB & 0xD8) | br_tbl[reg[4] >> 4]; -} - -static DECLFR(UNLPEC586ReadHi) { - if((reg[0] & 0x10) || ((reg[0] & 0x40) && (A < 0xA000))) - return CartBR(A); - else - return PRGptr[0][((0x0107 | ((A >> 7) & 0x0F8)) << 10) | (A & 0x3FF)]; -} - -static void UNLPEC586Power(void) { - if(PRGsize[0] == 512 * 1024) - reg[0] = 0x00; - else - reg[0] = 0x0E; - Sync(); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - if(PRGsize[0] == 512 * 1024) - SetReadHandler(0x8000, 0xFFFF, UNLPEC586ReadHi); - else - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x5000, 0x5fff, UNLPEC586Write); - SetReadHandler(0x5000, 0x5fff, UNLPEC586Read); -} - -static void UNLPEC586Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLPEC586Init(CartInfo *info) { - info->Power = UNLPEC586Power; - info->Close = UNLPEC586Close; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/sa-9602b.cpp b/branches/sdl2/src/boards/sa-9602b.cpp deleted file mode 100644 index a6a19bbe..00000000 --- a/branches/sdl2/src/boards/sa-9602b.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void SA9602BPW(uint32 A, uint8 V) { - setprg8r(EXPREGS[1], A, V & 0x3F); - if (MMC3_cmd & 0x40) - setprg8r(0, 0x8000, ~(1)); - else - setprg8r(0, 0xc000, ~(1)); - setprg8r(0, 0xe000, ~(0)); -} - -static DECLFW(SA9602BWrite) { - switch (A & 0xe001) { - case 0x8000: EXPREGS[0] = V; break; - case 0x8001: - if ((EXPREGS[0] & 7) < 6) { - EXPREGS[1] = V >> 6; - FixMMC3PRG(MMC3_cmd); - } - break; - } - MMC3_CMDWrite(A, V); -} - -static void SA9602BPower(void) { - EXPREGS[0] = EXPREGS[1] = 0; - GenMMC3Power(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xBFFF, SA9602BWrite); -} - -void SA9602B_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 0, 0, 0); - pwrap = SA9602BPW; - mmc3opts |= 2; - info->SaveGame[0] = UNIFchrrama; - info->SaveGameLen[0] = 32 * 1024; - info->Power = SA9602BPower; - AddExState(EXPREGS, 2, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/sachen.cpp b/branches/sdl2/src/boards/sachen.cpp deleted file mode 100644 index 0f73e407..00000000 --- a/branches/sdl2/src/boards/sachen.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmd, dip; -static uint8 latch[8]; - -static void S74LS374MSync(uint8 mirr) { - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirrorw(0, 1, 1, 1); break; - case 3: setmirror(MI_0); break; - } -} - -static void S74LS374NSynco(void) { - setprg32(0x8000, latch[0]); - setchr8(latch[1] | latch[3] | latch[4]); - S74LS374MSync(latch[2]); -} - -static DECLFW(S74LS374NWrite) { - A &= 0x4101; - if (A == 0x4100) - cmd = V & 7; - else{ - switch (cmd) { - case 2: latch[0] = V & 1; latch[3] = (V & 1) << 3; break; - case 4: latch[4] = (V & 1) << 2; break; - case 5: latch[0] = V & 7; break; - case 6: latch[1] = V & 3; break; - case 7: latch[2] = V >> 1; break; - } - S74LS374NSynco(); - } -} - -static DECLFR(S74LS374NRead) { - uint8 ret; - if ((A & 0x4100) == 0x4100) -// ret=(X.DB&0xC0)|((~cmd)&0x3F); - ret = ((~cmd) & 0x3F) ^ dip; - else - ret = X.DB; - return ret; -} - -static void S74LS374NPower(void) { - dip = 0; - latch[0] = latch[1] = latch[2] = latch[3] = latch[4] = 0; - S74LS374NSynco(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x7FFF, S74LS374NWrite); - SetReadHandler(0x4100, 0x5fff, S74LS374NRead); -} - -static void S74LS374NReset(void) { - dip ^= 1; - latch[0] = latch[1] = latch[2] = latch[3] = latch[4] = 0; - S74LS374NSynco(); -} - -static void S74LS374NRestore(int version) { - S74LS374NSynco(); -} - -void S74LS374N_Init(CartInfo *info) { - info->Power = S74LS374NPower; - info->Reset = S74LS374NReset; - GameStateRestore = S74LS374NRestore; - AddExState(latch, 5, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - AddExState(&dip, 1, 0, "DIP"); -} - -static void S74LS374NASynco(void) { - setprg32(0x8000, latch[0]); - setchr8(latch[1]); - S74LS374MSync(latch[2]); -} - -static DECLFW(S74LS374NAWrite) { - A &= 0x4101; - if (A == 0x4100) - cmd = V & 7; - else{ - switch (cmd) { - case 0: latch[0] = 0; latch[1] = 3; break; - case 2: latch[3] = (V & 1) << 3; break; - case 4: latch[1] = (latch[1] & 6) | (V & 3); break; - case 5: latch[0] = V & 1; break; - case 6: latch[1] = (latch[1] & 1) | latch[3] | ((V & 3) << 1); break; - case 7: latch[2] = V & 1; break; - } - S74LS374NASynco(); - } -} - -static void S74LS374NAPower(void) { - latch[0] = latch[2] = latch[3] = latch[4] = 0; - latch[1] = 3; - S74LS374NASynco(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x7FFF, S74LS374NAWrite); -} - -void S74LS374NA_Init(CartInfo *info) { - info->Power = S74LS374NAPower; - GameStateRestore = S74LS374NRestore; - AddExState(latch, 5, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); -} - -static int type; -static void S8259Synco(void) { - int x; - setprg32(0x8000, latch[5] & 7); - - if (!UNIFchrrama) { // No CHR RAM? Then BS'ing is ok. - for (x = 0; x < 4; x++) { - int bank; - if (latch[7] & 1) - bank = (latch[0] & 0x7) | ((latch[4] & 7) << 3); - else - bank = (latch[x] & 0x7) | ((latch[4] & 7) << 3); - switch (type) { - case 00: bank = (bank << 1) | (x & 1); setchr2(0x800 * x, bank); break; - case 01: setchr2(0x800 * x, bank); break; - case 02: bank = (bank << 2) | (x & 3); setchr2(0x800 * x, bank); break; - case 03: - bank = latch[x] & 7; - switch (x & 3) { - case 01: bank |= (latch[4] & 1) << 4; break; - case 02: bank |= (latch[4] & 2) << 3; break; - case 03: bank |= ((latch[4] & 4) << 2) | ((latch[6] & 1) << 3); break; - } - setchr1(0x400 * x, bank); - setchr4(0x1000, ~0); - break; - } - } - } - if (!(latch[7] & 1)) - S74LS374MSync(latch[7] >> 1); - else - setmirror(MI_V); -} - -static DECLFW(S8259Write) { - A &= 0x4101; - if (A == 0x4100) - cmd = V; - else{ - latch[cmd & 7] = V; - S8259Synco(); - } -} - -static void S8259Reset(void) { - int x; - cmd = 0; - - for (x = 0; x < 8; x++) latch[x] = 0; - setchr8(0); - - S8259Synco(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x7FFF, S8259Write); -} - -static void S8259Restore(int version) { - S8259Synco(); -} - -void S8259A_Init(CartInfo *info) { // Kevin's Horton 141 mapper - info->Power = S8259Reset; - GameStateRestore = S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type = 0; -} - -void S8259B_Init(CartInfo *info) { // Kevin's Horton 138 mapper - info->Power = S8259Reset; - GameStateRestore = S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type = 1; -} - -void S8259C_Init(CartInfo *info) { // Kevin's Horton 139 mapper - info->Power = S8259Reset; - GameStateRestore = S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type = 2; -} - -void S8259D_Init(CartInfo *info) { // Kevin's Horton 137 mapper - info->Power = S8259Reset; - GameStateRestore = S8259Restore; - AddExState(latch, 8, 0, "LATC"); - AddExState(&cmd, 1, 0, "CMD"); - type = 3; -} - -static void (*WSync)(void); - -static DECLFW(SAWrite) { - if (A & 0x100) { - latch[0] = V; - WSync(); - } -} - -static void SAPower(void) { - latch[0] = 0; - WSync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0x5FFF, SAWrite); -} - -static void SARestore(int version) { - WSync(); -} - -static DECLFW(SADWrite) { - latch[0] = V; - WSync(); -} - -static void SADPower(void) { - latch[0] = 0; - WSync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, SADWrite); -} - -static void SA0161MSynco() { - setprg32(0x8000, (latch[0] >> 3) & 1); - setchr8(latch[0] & 7); -} - -static void SA72007Synco() { - setprg32(0x8000, 0); - setchr8(latch[0] >> 7); -} - -static void SA009Synco() { - setprg32(0x8000, 0); - setchr8(latch[0] & 1); -} - -static void SA72008Synco() { - setprg32(0x8000, (latch[0] >> 2) & 1); - setchr8(latch[0] & 3); -} - -void SA0161M_Init(CartInfo *info) { - WSync = SA0161MSynco; - GameStateRestore = SARestore; - info->Power = SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA72007_Init(CartInfo *info) { - WSync = SA72007Synco; - GameStateRestore = SARestore; - info->Power = SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA72008_Init(CartInfo *info) { - WSync = SA72008Synco; - GameStateRestore = SARestore; - info->Power = SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA009_Init(CartInfo *info) { - WSync = SA009Synco; - GameStateRestore = SARestore; - info->Power = SAPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA0036_Init(CartInfo *info) { - WSync = SA72007Synco; - GameStateRestore = SARestore; - info->Power = SADPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -void SA0037_Init(CartInfo *info) { - WSync = SA0161MSynco; - GameStateRestore = SARestore; - info->Power = SADPower; - AddExState(&latch[0], 1, 0, "LATC"); -} - -// ----------------------------------------------- - -static void TCU01Synco() { - setprg32(0x8000, ((latch[0] & 0x80) >> 6) | ((latch[0] >> 2) & 1)); - setchr8((latch[0] >> 3) & 0xF); -} - -static DECLFW(TCU01Write) { - if ((A & 0x103) == 0x102) { - latch[0] = V; - TCU01Synco(); - } -} - -static void TCU01Power(void) { - latch[0] = 0; - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x4100, 0xFFFF, TCU01Write); - TCU01Synco(); -} - -static void TCU01Restore(int version) { - TCU01Synco(); -} - -void TCU01_Init(CartInfo *info) { - GameStateRestore = TCU01Restore; - info->Power = TCU01Power; - AddExState(&latch[0], 1, 0, "LATC"); -} - -//----------------------------------------------- - -static void TCU02Synco() { - setprg32(0x8000, 0); - setchr8(latch[0] & 3); -} - -static DECLFW(TCU02Write) { - if ((A & 0x103) == 0x102) { - latch[0] = V + 3; - TCU02Synco(); - } -} - -static DECLFR(TCU02Read) { - return (latch[0] & 0x3F) | (X.DB & 0xC0); -} - -static void TCU02Power(void) { - latch[0] = 0; - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4100, 0x4100, TCU02Read); - SetWriteHandler(0x4100, 0xFFFF, TCU02Write); - TCU02Synco(); -} - -static void TCU02Restore(int version) { - TCU02Synco(); -} - -void TCU02_Init(CartInfo *info) { - GameStateRestore = TCU02Restore; - info->Power = TCU02Power; - AddExState(&latch[0], 1, 0, "LATC"); -} - -// --------------------------------------------- - -static DECLFR(TCA01Read) { - uint8 ret; - if ((A & 0x4100) == 0x4100) - ret = (X.DB & 0xC0) | ((~A) & 0x3F); - else - ret = X.DB; - return ret; -} - -static void TCA01Power(void) { - setprg16(0x8000, 0); - setprg16(0xC000, 1); - setchr8(0); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetReadHandler(0x4100, 0x5FFF, TCA01Read); -} - -void TCA01_Init(CartInfo *info) { - info->Power = TCA01Power; -} - diff --git a/branches/sdl2/src/boards/sc-127.cpp b/branches/sdl2/src/boards/sc-127.cpp deleted file mode 100644 index ed466ca1..00000000 --- a/branches/sdl2/src/boards/sc-127.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Wario Land II (Kirby hack) - */ - -#include "mapinc.h" - -static uint8 reg[8], chr[8]; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; -static uint16 IRQCount, IRQa; - -static SFORMAT StateRegs[] = -{ - { reg, 8, "REGS" }, - { chr, 8, "CHRS" }, - { &IRQCount, 16, "IRQc" }, - { &IRQa, 16, "IRQa" }, - { 0 } -}; - -static void Sync(void) { - int i; - setprg8(0x8000, reg[0]); - setprg8(0xA000, reg[1]); - setprg8(0xC000, reg[2]); - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - setmirror(reg[3] ^ 1); -} - -static DECLFW(UNLSC127Write) { - switch (A) { - case 0x8000: reg[0] = V; break; - case 0x8001: reg[1] = V; break; - case 0x8002: reg[2] = V; break; - case 0x9000: chr[0] = V; break; - case 0x9001: chr[1] = V; break; - case 0x9002: chr[2] = V; break; - case 0x9003: chr[3] = V; break; - case 0x9004: chr[4] = V; break; - case 0x9005: chr[5] = V; break; - case 0x9006: chr[6] = V; break; - case 0x9007: chr[7] = V; break; - case 0xC002: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xC005: IRQCount = V; break; - case 0xC003: IRQa = 1; break; - case 0xD001: reg[3] = V; break; - } - Sync(); -} - -static void UNLSC127Power(void) { - Sync(); - setprg8r(0x10, 0x6000, 0); - setprg8(0xE000, ~0); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLSC127Write); -} - -static void UNLSC127IRQ(void) { - if (IRQa) { - IRQCount--; - if (IRQCount == 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - } - } -} - -static void UNLSC127Reset(void) { -} - -static void UNLSC127Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLSC127_Init(CartInfo *info) { - info->Reset = UNLSC127Reset; - info->Power = UNLSC127Power; - info->Close = UNLSC127Close; - GameHBIRQHook = UNLSC127IRQ; - GameStateRestore = StateRestore; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/sheroes.cpp b/branches/sdl2/src/boards/sheroes.cpp deleted file mode 100644 index c536c1d5..00000000 --- a/branches/sdl2/src/boards/sheroes.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 *CHRRAM; -static uint8 tekker; - -static void MSHCW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x40) - setchr8r(0x10, 0); - else{ - if (A < 0x800) - setchr1(A, V | ((EXPREGS[0] & 8) << 5)); - else if (A < 0x1000) - setchr1(A, V | ((EXPREGS[0] & 4) << 6)); - else if (A < 0x1800) - setchr1(A, V | ((EXPREGS[0] & 1) << 8)); - else - setchr1(A, V | ((EXPREGS[0] & 2) << 7)); - } -} - -static DECLFW(MSHWrite) { - EXPREGS[0] = V; - FixMMC3CHR(MMC3_cmd); -} - -static DECLFR(MSHRead) { - return(tekker); -} - -static void MSHReset(void) { - MMC3RegReset(); - tekker ^= 0xFF; -} - -static void MSHPower(void) { - tekker = 0x00; - GenMMC3Power(); - SetWriteHandler(0x4100, 0x4100, MSHWrite); - SetReadHandler(0x4100, 0x4100, MSHRead); -} - -static void MSHClose(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -void UNLSHeroes_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 512, 0, 0); - cwrap = MSHCW; - info->Power = MSHPower; - info->Reset = MSHReset; - info->Close = MSHClose; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(EXPREGS, 4, 0, "EXPR"); - AddExState(&tekker, 1, 0, "DIPSW"); -} diff --git a/branches/sdl2/src/boards/sl1632.cpp b/branches/sdl2/src/boards/sl1632.cpp deleted file mode 100644 index 80643c5f..00000000 --- a/branches/sdl2/src/boards/sl1632.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 chrcmd[8], prg0, prg1, bbrk, mirr, swap; -static SFORMAT StateRegs[] = -{ - { chrcmd, 8, "CHRC" }, - { &prg0, 1, "PRG0" }, - { &prg1, 1, "PRG1" }, - { &bbrk, 1, "BRK" }, - { &mirr, 1, "MIRR" }, - { &swap, 1, "SWAP" }, - { 0 } -}; - -static void Sync(void) { - int i; - setprg8(0x8000, prg0); - setprg8(0xA000, prg1); - setprg8(0xC000, ~1); - setprg8(0xE000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, chrcmd[i]); - setmirror(mirr ^ 1); -} - -static void UNLSL1632CW(uint32 A, uint8 V) { - int cbase = (MMC3_cmd & 0x80) << 5; - int page0 = (bbrk & 0x08) << 5; - int page1 = (bbrk & 0x20) << 3; - int page2 = (bbrk & 0x80) << 1; - setchr1(cbase ^ 0x0000, page0 | (DRegBuf[0] & (~1))); - setchr1(cbase ^ 0x0400, page0 | DRegBuf[0] | 1); - setchr1(cbase ^ 0x0800, page0 | (DRegBuf[1] & (~1))); - setchr1(cbase ^ 0x0C00, page0 | DRegBuf[1] | 1); - setchr1(cbase ^ 0x1000, page1 | DRegBuf[2]); - setchr1(cbase ^ 0x1400, page1 | DRegBuf[3]); - setchr1(cbase ^ 0x1800, page2 | DRegBuf[4]); - setchr1(cbase ^ 0x1c00, page2 | DRegBuf[5]); -} - -static DECLFW(UNLSL1632CMDWrite) { - if (A == 0xA131) { - bbrk = V; - } - if (bbrk & 2) { - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - if (A < 0xC000) - MMC3_CMDWrite(A, V); - else - MMC3_IRQWrite(A, V); - } else { - if ((A >= 0xB000) && (A <= 0xE003)) { - int ind = ((((A & 2) | (A >> 10)) >> 1) + 2) & 7; - int sar = ((A & 1) << 2); - chrcmd[ind] = (chrcmd[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - } else - switch (A & 0xF003) { - case 0x8000: prg0 = V; break; - case 0xA000: prg1 = V; break; - case 0x9000: mirr = V & 1; break; - } - Sync(); - } -} - -static void StateRestore(int version) { - if (bbrk & 2) { - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } else - Sync(); -} - -static void UNLSL1632Power(void) { - GenMMC3Power(); - SetWriteHandler(0x4100, 0xFFFF, UNLSL1632CMDWrite); -} - -void UNLSL1632_Init(CartInfo *info) { - GenMMC3_Init(info, 256, 512, 0, 0); - cwrap = UNLSL1632CW; - info->Power = UNLSL1632Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/subor.cpp b/branches/sdl2/src/boards/subor.cpp deleted file mode 100644 index 00d9a997..00000000 --- a/branches/sdl2/src/boards/subor.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 is167, regs[4]; - -static SFORMAT StateRegs[] = -{ - { regs, 4, "DREG" }, - { 0 } -}; - -static void Sync(void) { - int base, bank; - base = ((regs[0] ^ regs[1]) & 0x10) << 1; - bank = (regs[2] ^ regs[3]) & 0x1f; - - if (regs[1] & 0x08) { - bank &= 0xFE; - if (is167) { - setprg16(0x8000, base + bank + 1); - setprg16(0xC000, base + bank + 0); - } else { - setprg16(0x8000, base + bank + 0); - setprg16(0xC000, base + bank + 1); - } - } else { - if (regs[1] & 0x04) { - setprg16(0x8000, 0x1F); - setprg16(0xC000, base + bank); - } else { - setprg16(0x8000, base + bank); - if (is167) - setprg16(0xC000, 0x20); - else - setprg16(0xC000, 0x07); - } - } - setchr8(0); -} - -static DECLFW(M166Write) { - regs[(A >> 13) & 0x03] = V; - Sync(); -} - -static void M166Power(void) { - regs[0] = regs[1] = regs[2] = regs[3] = 0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M166Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper166_Init(CartInfo *info) { - is167 = 0; - info->Power = M166Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper167_Init(CartInfo *info) { - is167 = 1; - info->Power = M166Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/super24.cpp b/branches/sdl2/src/boards/super24.cpp deleted file mode 100644 index f62fbe85..00000000 --- a/branches/sdl2/src/boards/super24.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 *CHRRAM = NULL; -static int masko8[8] = { 63, 31, 15, 1, 3, 0, 0, 0 }; - -static void Super24PW(uint32 A, uint8 V) { - uint32 NV = V & masko8[EXPREGS[0] & 7]; - NV |= (EXPREGS[1] << 1); - setprg8r((NV >> 6) & 0xF, A, NV); -} - -static void Super24CW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x20) - setchr1r(0x10, A, V); - else{ - uint32 NV = V | (EXPREGS[2] << 3); - setchr1r((NV >> 9) & 0xF, A, NV); - } -} - -static DECLFW(Super24Write) { - switch (A) { - case 0x5FF0: - EXPREGS[0] = V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - break; - case 0x5FF1: - EXPREGS[1] = V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5FF2: - EXPREGS[2] = V; - FixMMC3CHR(MMC3_cmd); - break; - } -} - -static void Super24Power(void) { - EXPREGS[0] = 0x24; - EXPREGS[1] = 159; - EXPREGS[2] = 0; - GenMMC3Power(); - SetWriteHandler(0x5000, 0x7FFF, Super24Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void Super24Reset(void) { - EXPREGS[0] = 0x24; - EXPREGS[1] = 159; - EXPREGS[2] = 0; - MMC3RegReset(); -} - -static void Super24Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; -} - -void Super24_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 256, 0, 0); - info->Power = Super24Power; - info->Reset = Super24Reset; - info->Close = Super24Close; - cwrap = Super24CW; - pwrap = Super24PW; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - AddExState(EXPREGS, 3, 0, "BIG2"); -} diff --git a/branches/sdl2/src/boards/supervision.cpp b/branches/sdl2/src/boards/supervision.cpp deleted file mode 100644 index 46be8ed2..00000000 --- a/branches/sdl2/src/boards/supervision.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmd0, cmd1; -static SFORMAT StateRegs[] = -{ - { &cmd0, 1, "L1" }, - { &cmd1, 1, "L2" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - if (PRGptr[1]) - setprg8r((cmd0 & 0xC) >> 2, 0x6000, ((cmd0 & 0x3) << 4) | 0xF); - else - setprg8(0x6000, (((cmd0 & 0xF) << 4) | 0xF) + 4); - if (cmd0 & 0x10) { - if (PRGptr[1]) { - setprg16r((cmd0 & 0xC) >> 2, 0x8000, ((cmd0 & 0x3) << 3) | (cmd1 & 7)); - setprg16r((cmd0 & 0xC) >> 2, 0xc000, ((cmd0 & 0x3) << 3) | 7); - } else { - setprg16(0x8000, (((cmd0 & 0xF) << 3) | (cmd1 & 7)) + 2); - setprg16(0xc000, (((cmd0 & 0xF) << 3) | 7) + 2); - } - } else - if (PRGptr[4]) - setprg32r(4, 0x8000, 0); - else - setprg32(0x8000, 0); - setmirror(((cmd0 & 0x20) >> 5) ^ 1); -} - -static DECLFW(SuperWriteLo) { - if (!(cmd0 & 0x10)) { - cmd0 = V; - Sync(); - } -} - -static DECLFW(SuperWriteHi) { - cmd1 = V; - Sync(); -} - -static void SuperPower(void) { - SetWriteHandler(0x6000, 0x7FFF, SuperWriteLo); - SetWriteHandler(0x8000, 0xFFFF, SuperWriteHi); - SetReadHandler(0x6000, 0xFFFF, CartBR); - cmd0 = cmd1 = 0; - Sync(); -} - -static void SuperReset(void) { - cmd0 = cmd1 = 0; - Sync(); -} - -static void SuperRestore(int version) { - Sync(); -} - -void Supervision16_Init(CartInfo *info) { - info->Power = SuperPower; - info->Reset = SuperReset; - GameStateRestore = SuperRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/t-227-1.cpp b/branches/sdl2/src/boards/t-227-1.cpp deleted file mode 100644 index ca99b6f9..00000000 --- a/branches/sdl2/src/boards/t-227-1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2008 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// T-227-1, 820632, MMC3 based, multimenu, 60000in1 (0010) dip switches - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 reset_flag = 0x07; - -static void BMCT2271CW(uint32 A, uint8 V) { - uint32 va = V; - if (EXPREGS[0] & 0x20) { - va |= 0x200; - va |= (EXPREGS[0] & 0x10) << 4; - } else { - va &= 0x7F; - va |= (EXPREGS[0] & 0x18) << 4; - } - setchr1(A, va); -} - -static void BMCT2271PW(uint32 A, uint8 V) { - uint32 va = V & 0x3F; - if (EXPREGS[0] & 0x20) { - va &= 0x1F; - va |= 0x40; - va |= (EXPREGS[0] & 0x10) << 1; - } else { - va &= 0x0F; - va |= (EXPREGS[0] & 0x18) << 1; - } - switch (EXPREGS[0] & 3) { - case 0x00: setprg8(A, va); break; - case 0x02: - { - va = (va & 0xFD) | ((EXPREGS[0] & 4) >> 1); - if (A < 0xC000) { - setprg16(0x8000, va >> 1); - setprg16(0xC000, va >> 1); - } - break; - } - case 0x01: - case 0x03: if (A < 0xC000) setprg32(0x8000, va >> 2); break; - } -} - -static DECLFW(BMCT2271LoWrite) { - if (!(EXPREGS[0] & 0x80)) - EXPREGS[0] = A & 0xFF; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static DECLFR(BMCT2271HiRead) { - uint32 av = A; - if (EXPREGS[0] & 0x40) av = (av & 0xFFF0) | reset_flag; - return CartBR(av); -} - -static void BMCT2271Reset(void) { - EXPREGS[0] = 0x00; - reset_flag++; - reset_flag &= 0x0F; - MMC3RegReset(); -} - -static void BMCT2271Power(void) { - EXPREGS[0] = 0x00; - GenMMC3Power(); - SetWriteHandler(0x6000, 0x7FFF, BMCT2271LoWrite); - SetReadHandler(0x8000, 0xFFFF, BMCT2271HiRead); -} - -void BMCT2271_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, 0); - pwrap = BMCT2271PW; - cwrap = BMCT2271CW; - info->Power = BMCT2271Power; - info->Reset = BMCT2271Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} diff --git a/branches/sdl2/src/boards/t-262.cpp b/branches/sdl2/src/boards/t-262.cpp deleted file mode 100644 index 01b873b3..00000000 --- a/branches/sdl2/src/boards/t-262.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 bank, base, lock, mirr, mode; -static SFORMAT StateRegs[] = -{ - { &bank, 1, "BANK" }, - { &base, 1, "BASE" }, - { &lock, 1, "LOCK" }, - { &mirr, 1, "MIRR" }, - { &mode, 1, "MODE" }, - { 0 } -}; - -static void Sync(void) { - setchr8(0); - setprg16(0x8000, base | bank); - setprg16(0xC000, base | (mode ? bank : 7)); - setmirror(mirr); -} - -static DECLFW(BMCT262Write) { - if (!lock) { - base = ((A & 0x60) >> 2) | ((A & 0x100) >> 3); - mode = A & 0x80; - mirr = ((A & 2) >> 1) ^ 1; - lock = (A & 0x2000) >> 13; - } - bank = V & 7; - Sync(); -} - -static void BMCT262Power(void) { - lock = bank = base = mode = 0; - Sync(); - SetWriteHandler(0x8000, 0xFFFF, BMCT262Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void BMCT262Reset(void) { - lock = bank = base = mode = 0; - Sync(); -} - -static void BMCT262Restore(int version) { - Sync(); -} - -void BMCT262_Init(CartInfo *info) { - info->Power = BMCT262Power; - info->Reset = BMCT262Reset; - GameStateRestore = BMCT262Restore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/tengen.cpp b/branches/sdl2/src/boards/tengen.cpp deleted file mode 100644 index b47afff2..00000000 --- a/branches/sdl2/src/boards/tengen.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 cmd, mirr, regs[11]; -static uint8 rmode, IRQmode, IRQCount, IRQa, IRQLatch; - -static SFORMAT StateRegs[] = { - { regs, 11, "REGS" }, - { &cmd, 1, "CMDR" }, - { &mirr, 1, "MIRR" }, - { &rmode, 1, "RMOD" }, - { &IRQmode, 1, "IRQM" }, - { &IRQCount, 1, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { &IRQLatch, 1, "IRQL" }, - { 0 } -}; - -static void M64IRQHook(int a) { - static int32 smallcount; - if (IRQmode) { - smallcount += a; - while (smallcount >= 4) { - smallcount -= 4; - IRQCount--; - if (IRQCount == 0xFF) - if (IRQa) X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void M64HBHook(void) { - if ((!IRQmode) && (scanline != 240)) { - rmode = 0; - IRQCount--; - if (IRQCount == 0xFF) { - if (IRQa) { - rmode = 1; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void Sync(void) { - if (cmd & 0x20) { - setchr1(0x0000, regs[0]); - setchr1(0x0400, regs[8]); - setchr1(0x0800, regs[1]); - setchr1(0x0C00, regs[9]); - } else { - setchr2(0x0000, regs[0] >> 1); - setchr2(0x0800, regs[1] >> 1); - } - setchr1(0x1000, regs[2]); - setchr1(0x1400, regs[3]); - setchr1(0x1800, regs[4]); - setchr1(0x1C00, regs[5]); - setprg8(0x8000, regs[6]); - setprg8(0xA000, regs[7]); - setprg8(0xC000, regs[10]); - setprg8(0xE000, ~0); - setmirror(mirr); -} - -static DECLFW(M64Write) { - switch (A & 0xF001) { - case 0xA000: mirr = (V & 1) ^ 1; Sync(); break;\ - case 0x8000: cmd = V; break; - case 0x8001: - if ((cmd & 0xF) < 10) - regs[cmd & 0xF] = V; - else if ((cmd & 0xF) == 0xF) - regs[10] = V; - Sync(); - break; - case 0xC000: - IRQLatch = V; - if (rmode == 1) - IRQCount = IRQLatch; - break; - case 0xC001: - rmode = 1; - IRQCount = IRQLatch; - IRQmode = V & 1; - break; - case 0xE000: - IRQa = 0; - X6502_IRQEnd(FCEU_IQEXT); - if (rmode == 1) - IRQCount = IRQLatch; - break; - case 0xE001: - IRQa = 1; - if (rmode == 1) - IRQCount = IRQLatch; - break; - } -} - -static void M64Power(void) { - cmd = mirr = 0; - regs[0] = regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = ~0; - regs[6] = regs[7] = regs[8] = regs[9] = regs[10] = ~0; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M64Write); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper64_Init(CartInfo *info) { - info->Power = M64Power; - GameHBIRQHook = M64HBHook; - MapIRQHook = M64IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/tf-1201.cpp b/branches/sdl2/src/boards/tf-1201.cpp deleted file mode 100644 index 24e8a771..00000000 --- a/branches/sdl2/src/boards/tf-1201.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Lethal Weapon (VRC4 mapper) - */ - -#include "mapinc.h" - -static uint8 prg0, prg1, mirr, swap; -static uint8 chr[8]; -static uint8 IRQCount; -static uint8 IRQPre; -static uint8 IRQa; - -static SFORMAT StateRegs[] = -{ - { &prg0, 1, "PRG0" }, - { &prg0, 1, "PRG1" }, - { &mirr, 1, "MIRR" }, - { &swap, 1, "SWAP" }, - { chr, 8, "CHR" }, - { &IRQCount, 1, "IRQC" }, - { &IRQPre, 1, "IRQP" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static void SyncPrg(void) { - if (swap & 3) { - setprg8(0x8000, ~1); - setprg8(0xC000, prg0); - } else { - setprg8(0x8000, prg0); - setprg8(0xC000, ~1); - } - setprg8(0xA000, prg1); - setprg8(0xE000, ~0); -} - -static void SyncChr(void) { - int i; - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - setmirror(mirr ^ 1); -} - -static void StateRestore(int version) { - SyncPrg(); - SyncChr(); -} - -static DECLFW(UNLTF1201Write) { - A = (A & 0xF003) | ((A & 0xC) >> 2); - if ((A >= 0xB000) && (A <= 0xE003)) { - int ind = (((A >> 11) - 6) | (A & 1)) & 7; - int sar = ((A & 2) << 1); - chr[ind] = (chr[ind] & (0xF0 >> sar)) | ((V & 0x0F) << sar); - SyncChr(); - } else switch (A & 0xF003) { - case 0x8000: prg0 = V; SyncPrg(); break; - case 0xA000: prg1 = V; SyncPrg(); break; - case 0x9000: mirr = V & 1; SyncChr(); break; - case 0x9001: swap = V & 3; SyncPrg(); break; - case 0xF000: IRQCount = ((IRQCount & 0xF0) | (V & 0xF)); break; - case 0xF002: IRQCount = ((IRQCount & 0x0F) | ((V & 0xF) << 4)); break; - case 0xF001: - case 0xF003: IRQa = V & 2; X6502_IRQEnd(FCEU_IQEXT); if (scanline < 240) IRQCount -= 8; break; - } -} - -static void UNLTF1201IRQCounter(void) { - if (IRQa) { - IRQCount++; - if (IRQCount == 237) { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void UNLTF1201Power(void) { - IRQPre = IRQCount = IRQa = 0; - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLTF1201Write); - SyncPrg(); - SyncChr(); -} - -void UNLTF1201_Init(CartInfo *info) { - info->Power = UNLTF1201Power; - GameHBIRQHook = UNLTF1201IRQCounter; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/transformer.cpp b/branches/sdl2/src/boards/transformer.cpp deleted file mode 100644 index 0f9c4a60..00000000 --- a/branches/sdl2/src/boards/transformer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -unsigned int *GetKeyboard(void); // FIXME: 10/28 - now implemented in SDL as well. should we rename this to a FCEUI_* function? - -static unsigned int *TransformerKeys, oldkeys[256]; -static int TransformerCycleCount, TransformerChar = 0; - -static void TransformerIRQHook(int a) { - TransformerCycleCount += a; - if (TransformerCycleCount >= 1000) { - uint32 i; - TransformerCycleCount -= 1000; - TransformerKeys = GetKeyboard(); - - for (i = 0; i < 256; i++) { - if (oldkeys[i] != TransformerKeys[i]) { - if (oldkeys[i] == 0) - TransformerChar = i; - else - TransformerChar = i | 0x80; - X6502_IRQBegin(FCEU_IQEXT); - memcpy((void*)&oldkeys[0], (void*)TransformerKeys, sizeof(oldkeys)); - break; - } - } - } -} - -static DECLFR(TransformerRead) { - uint8 ret = 0; - switch (A & 3) { - case 0: ret = TransformerChar & 15; break; - case 1: ret = (TransformerChar >> 4); break; - case 2: break; - case 4: break; - } - X6502_IRQEnd(FCEU_IQEXT); - return ret; -} - -static void TransformerPower(void) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, 0); - setprg16(0xC000, ~0); - setchr8(0); - - SetReadHandler(0x5000, 0x5004, TransformerRead); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - - MapIRQHook = TransformerIRQHook; -} - -static void TransformerClose(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Transformer_Init(CartInfo *info) { - info->Power = TransformerPower; - info->Close = TransformerClose; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); -} diff --git a/branches/sdl2/src/boards/vrc1.cpp b/branches/sdl2/src/boards/vrc1.cpp deleted file mode 100644 index 899bcfb5..00000000 --- a/branches/sdl2/src/boards/vrc1.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-1 - * - */ - -#include "mapinc.h" - -static uint8 preg[3], creg[2], mode; -static SFORMAT StateRegs[] = -{ - { &mode, 1, "MODE" }, - { creg, 2, "CREG" }, - { preg, 3, "PREG" }, - { 0 } -}; - -static void Sync(void) { - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - setchr4(0x0000, creg[0] | ((mode & 2) << 3)); - setchr4(0x1000, creg[1] | ((mode & 4) << 2)); - setmirror((mode & 1) ^ 1); -} - -static DECLFW(M75Write) { - switch (A & 0xF000) { - case 0x8000: preg[0] = V; Sync(); break; - case 0x9000: mode = V; Sync(); break; - case 0xA000: preg[1] = V; Sync(); break; - case 0xC000: preg[2] = V; Sync(); break; - case 0xE000: creg[0] = V & 0xF; Sync(); break; - case 0xF000: creg[1] = V & 0xF; Sync(); break; - } -} - -static void M75Power(void) { - Sync(); - SetWriteHandler(0x8000, 0xFFFF, M75Write); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper75_Init(CartInfo *info) { - info->Power = M75Power; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/vrc2and4.cpp b/branches/sdl2/src/boards/vrc2and4.cpp deleted file mode 100644 index 58e6d868..00000000 --- a/branches/sdl2/src/boards/vrc2and4.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2007 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 isPirate, is22; -static uint16 IRQCount; -static uint8 IRQLatch, IRQa; -static uint8 prgreg[2], chrreg[8]; -static uint16 chrhi[8]; -static uint8 regcmd, irqcmd, mirr, big_bank; -static uint16 acount = 0; -static uint16 weirdo = 0; - -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { prgreg, 2, "PREG" }, - { chrreg, 8, "CREG" }, - { chrhi, 16, "CRGH" }, - { ®cmd, 1, "CMDR" }, - { &irqcmd, 1, "CMDI" }, - { &mirr, 1, "MIRR" }, - { &big_bank, 1, "BIGB" }, - { &IRQCount, 2, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { 0 } -}; - -static void Sync(void) { - if (regcmd & 2) { - setprg8(0xC000, prgreg[0] | big_bank); - setprg8(0x8000, ((~1) & 0x1F) | big_bank); - } else { - setprg8(0x8000, prgreg[0] | big_bank); - setprg8(0xC000, ((~1) & 0x1F) | big_bank); - } - setprg8(0xA000, prgreg[1] | big_bank); - setprg8(0xE000, ((~0) & 0x1F) | big_bank); - if (UNIFchrrama) - setchr8(0); - else{ - uint8 i; - if(!weirdo) - for (i = 0; i < 8; i++) - setchr1(i << 10, (chrhi[i] | chrreg[i]) >> is22); - else { - setchr1(0x0000, 0xFC); - setchr1(0x0400, 0xFD); - setchr1(0x0800, 0xFF); - weirdo--; - } - } - switch (mirr & 0x3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC24Write) { - A &= 0xF003; - if ((A >= 0xB000) && (A <= 0xE003)) { - if (UNIFchrrama) - big_bank = (V & 8) << 2; // my personally many-in-one feature ;) just for support pirate cart 2-in-1 - else{ - uint16 i = ((A >> 1) & 1) | ((A - 0xB000) >> 11); - uint16 nibble = ((A & 1) << 2); - chrreg[i] = (chrreg[i] & (0xF0 >> nibble)) | ((V & 0xF) << nibble); - if(nibble) - chrhi[i] = (V & 0x10) << 4; // another one many in one feature from pirate carts - } - Sync(); - } else - switch (A & 0xF003) { - case 0x8000: - case 0x8001: - case 0x8002: - case 0x8003: - if (!isPirate) { - prgreg[0] = V & 0x1F; - Sync(); - } - break; - case 0xA000: - case 0xA001: - case 0xA002: - case 0xA003: - if (!isPirate) - prgreg[1] = V & 0x1F; - else{ - prgreg[0] = (V & 0x1F) << 1; - prgreg[1] = ((V & 0x1F) << 1) | 1; - } - Sync(); - break; - case 0x9000: - case 0x9001: if (V != 0xFF) mirr = V; Sync(); break; - case 0x9002: - case 0x9003: regcmd = V; Sync(); break; - case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break; - case 0xF001: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break; - case 0xF002: X6502_IRQEnd(FCEU_IQEXT); acount = 0; IRQCount = IRQLatch; IRQa = V & 2; irqcmd = V & 1; break; - case 0xF003: X6502_IRQEnd(FCEU_IQEXT); IRQa = irqcmd; break; - } -} - -static DECLFW(M21Write) { - A = (A & 0xF000) | ((A >> 1) & 0x3); // Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] isn't mapper 21 actually, - // it's mapper 23 by wirings - VRC24Write(A, V); -} - -static DECLFW(M22Write) { - if (A == 0xC007) { // Ganbare Goemon Gaiden does strange things!!! at the end credits - weirdo = 8; // quick dirty hack, seems there is no other games with such PCB, so - // we never know if it will not work for something else lol - } - A |= ((A >> 2) & 0x3); // It's just swapped lines from 21 mapper - // - VRC24Write((A & 0xF000) | ((A >> 1) & 1) | ((A << 1) & 2), V); -} - -static DECLFW(M23Write) { - A |= ((A >> 2) & 0x3) | ((A >> 4) & 0x3) | ((A >> 6) & 0x3);// actually there is many-in-one mapper source, some pirate or - // licensed games use various address bits for registers - VRC24Write(A, V); -} - -static void M21Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M21Write); -} - -static void M22Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M22Write); -} - -static void M23Power(void) { - big_bank = 0x20; - Sync(); - setprg8r(0x10, 0x6000, 0); // Only two Goemon games are have battery backed RAM, three more shooters - // (Parodius Da!, Gradius 2 and Crisis Force uses 2k or SRAM at 6000-67FF only - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M23Write); -} - -static void M25Power(void) { - big_bank = 0x20; - Sync(); - setprg8r(0x10, 0x6000, 0); - SetReadHandler(0x6000, 0x7FFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M22Write); -} - -void VRC24IRQHook(int a) { - #define LCYCS 341 - if (IRQa) { - acount += a * 3; - if (acount >= LCYCS) { - while (acount >= LCYCS) { - acount -= LCYCS; - IRQCount++; - if (IRQCount & 0x100) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -static void VRC24Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -void Mapper21_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M21Power; - MapIRQHook = VRC24IRQHook; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper22_Init(CartInfo *info) { - isPirate = 0; - is22 = 1; - info->Power = M22Power; - GameStateRestore = StateRestore; - - AddExState(&StateRegs, ~0, 0, 0); -} - -void VRC24_Init(CartInfo *info) { - info->Close = VRC24Close; - MapIRQHook = VRC24IRQHook; - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if(info->battery) { - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper23_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M23Power; - VRC24_Init(info); -} - -void Mapper25_Init(CartInfo *info) { - isPirate = 0; - is22 = 0; - info->Power = M25Power; - VRC24_Init(info); -} - -void UNLT230_Init(CartInfo *info) { - isPirate = 1; - is22 = 0; - info->Power = M23Power; - VRC24_Init(info); -} diff --git a/branches/sdl2/src/boards/vrc3.cpp b/branches/sdl2/src/boards/vrc3.cpp deleted file mode 100644 index 8369100e..00000000 --- a/branches/sdl2/src/boards/vrc3.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-3 - * - */ - -#include "mapinc.h" - -static uint8 preg; -static uint8 IRQx; //autoenable -static uint8 IRQm; //mode -static uint8 IRQa; -static uint16 IRQReload, IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PREG" }, - { &IRQa, 1, "IRQA" }, - { &IRQx, 1, "IRQX" }, - { &IRQm, 1, "IRQM" }, - { &IRQReload, 2, "IRQR" }, - { &IRQCount, 2, "IRQC" }, - { 0 } -}; - -static void Sync(void) { - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, preg); - setprg16(0xC000, ~0); - setchr8(0); -} - -static DECLFW(M73Write) { - switch (A & 0xF000) { - case 0x8000: IRQReload &= 0xFFF0; IRQReload |= (V & 0xF) << 0; break; - case 0x9000: IRQReload &= 0xFF0F; IRQReload |= (V & 0xF) << 4; break; - case 0xA000: IRQReload &= 0xF0FF; IRQReload |= (V & 0xF) << 8; break; - case 0xB000: IRQReload &= 0x0FFF; IRQReload |= (V & 0xF) << 12; break; - case 0xC000: - IRQm = V & 4; - IRQx = V & 1; - IRQa = V & 2; - if (IRQa) { - if (IRQm) { - IRQCount &= 0xFFFF; - IRQCount |= (IRQReload & 0xFF); - } else - IRQCount = IRQReload; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xD000: X6502_IRQEnd(FCEU_IQEXT); IRQa = IRQx; break; - case 0xF000: preg = V; Sync(); break; - } -} - -static void M73IRQHook(int a) { - int32 i; - if (!IRQa) return; - for (i = 0; i < a; i++) { - if (IRQm) { - uint16 temp = IRQCount; - temp &= 0xFF; - IRQCount &= 0xFF00; - if (temp == 0xFF) { - IRQCount = IRQReload; - IRQCount |= (uint16)(IRQReload & 0xFF); - X6502_IRQBegin(FCEU_IQEXT); - } else { - temp++; - IRQCount |= temp; - } - } else { - //16 bit mode - if (IRQCount == 0xFFFF) { - IRQCount = IRQReload; - X6502_IRQBegin(FCEU_IQEXT); - } else - IRQCount++; - } - } -} - -static void M73Power(void) { - IRQReload = IRQm = IRQx = 0; - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M73Write); -} - -static void M73Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper73_Init(CartInfo *info) { - info->Power = M73Power; - info->Close = M73Close; - MapIRQHook = M73IRQHook; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/branches/sdl2/src/boards/vrc5.cpp b/branches/sdl2/src/boards/vrc5.cpp deleted file mode 100644 index 0b439370..00000000 --- a/branches/sdl2/src/boards/vrc5.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-5 (CAI Shogakko no Sansu) - * - */ - -#include "mapinc.h" - -static uint8 QTAINTRAM[2048]; -static writefunc old2007wrap; - -static uint16 CHRSIZE = 8192; -static uint16 WRAMSIZE = 8192 + 4096; -static uint8 *CHRRAM = NULL; -static uint8 *WRAM = NULL; - -static uint8 IRQa, K4IRQ; -static uint32 IRQLatch, IRQCount; - -static uint8 regs[16]; -//static uint8 test[8]; -static SFORMAT StateRegs[] = -{ - { &IRQCount, 1, "IRQC" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQa, 1, "IRQA" }, - { &K4IRQ, 1, "KIRQ" }, - { regs, 16, "REGS" }, - { 0 } -}; - -static void chrSync(void) { - setchr4r(0x10, 0x0000, regs[5] & 1); - setchr4r(0x10, 0x1000, 0); -} - -static void Sync(void) { - chrSync(); -// if(regs[0xA]&0x10) -// { -/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3); - setchr1r(0x10,0x1000,0); - setchr1r(0x10,0x1400,1); - setchr1r(0x10,0x1800,2); - setchr1r(0x10,0x1c00,3);*/ -/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3); - setchr1r(0x10,0x1000,(((regs[5]&1)^1)<<2)+4); - setchr1r(0x10,0x1400,(((regs[5]&1)^1)<<2)+5); - setchr1r(0x10,0x1800,(((regs[5]&1)^1)<<2)+6); - setchr1r(0x10,0x1c00,(((regs[5]&1)^1)<<2)+7); -*/ -// } -// else -// { -/* - setchr1r(0x10,0x0000,(((regs[5]&1)^1)<<2)+0); - setchr1r(0x10,0x0400,(((regs[5]&1)^1)<<2)+1); - setchr1r(0x10,0x0800,(((regs[5]&1)^1)<<2)+2); - setchr1r(0x10,0x0c00,(((regs[5]&1)^1)<<2)+3); - setchr1r(0x10,0x1000,(((regs[5]&1))<<2)+4); - setchr1r(0x10,0x1400,(((regs[5]&1))<<2)+5); - setchr1r(0x10,0x1800,(((regs[5]&1))<<2)+6); - setchr1r(0x10,0x1c00,(((regs[5]&1))<<2)+7); -// } -//*/ -/* setchr1r(1,0x0000,test[0]); - setchr1r(1,0x0400,test[1]); - setchr1r(1,0x0800,test[2]); - setchr1r(1,0x0c00,test[3]); - setchr1r(1,0x1000,test[4]); - setchr1r(1,0x1400,test[5]); - setchr1r(1,0x1800,test[6]); - setchr1r(1,0x1c00,test[7]); -*/ - setprg4r(0x10, 0x6000, regs[0] & 1); - if (regs[2] >= 0x40) - setprg8r(1, 0x8000, (regs[2] - 0x40)); - else - setprg8r(0, 0x8000, (regs[2] & 0x3F)); - if (regs[3] >= 0x40) - setprg8r(1, 0xA000, (regs[3] - 0x40)); - else - setprg8r(0, 0xA000, (regs[3] & 0x3F)); - if (regs[4] >= 0x40) - setprg8r(1, 0xC000, (regs[4] - 0x40)); - else - setprg8r(0, 0xC000, (regs[4] & 0x3F)); - - setprg8r(1, 0xE000, ~0); - setmirror(MI_V); -} - -/*static DECLFW(TestWrite) -{ - test[A&7] = V; - Sync(); -}*/ - -static DECLFW(M190Write) { -// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp); - regs[(A & 0x0F00) >> 8] = V; - switch (A) { - case 0xd600: IRQLatch &= 0xFF00; IRQLatch |= V; break; - case 0xd700: IRQLatch &= 0x00FF; IRQLatch |= V << 8; break; - case 0xd900: IRQCount = IRQLatch; IRQa = V & 2; K4IRQ = V & 1; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xd800: IRQa = K4IRQ; X6502_IRQEnd(FCEU_IQEXT); break; - } - Sync(); -} - -static DECLFR(M190Read) { -// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp); - return regs[(A & 0x0F00) >> 8] + regs[0x0B]; -} -static void VRC5IRQ(int a) { - if (IRQa) { - IRQCount += a; - if (IRQCount & 0x10000) { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount = IRQLatch; - } - } -} - -//static void Mapper190_PPU(uint32 A) -//{ -// if(A<0x2000) -// setchr4r(0x10,0x1000,QTAINTRAM[A&0x1FFF]&1); -// else -// chrSync(); -//} - -static DECLFW(M1902007Wrap) { - if (A >= 0x2000) { - if (regs[0xA] & 1) - QTAINTRAM[A & 0x1FFF] = V; - else - old2007wrap(A, V); - } -} - - -static void M190Power(void) { -/* test[0]=0; - test[1]=1; - test[2]=2; - test[3]=3; - test[4]=4; - test[5]=5; - test[6]=6; - test[7]=7; -*/ - setprg4r(0x10, 0x7000, 2); - - old2007wrap = GetWriteHandler(0x2007); - SetWriteHandler(0x2007, 0x2007, M1902007Wrap); - - SetReadHandler(0x6000, 0xFFFF, CartBR); -// SetWriteHandler(0x5000,0x5007,TestWrite); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, M190Write); - SetReadHandler(0xDC00, 0xDC00, M190Read); - SetReadHandler(0xDD00, 0xDD00, M190Read); - Sync(); -} - -static void M190Close(void) { - if (CHRRAM) - FCEU_gfree(CHRRAM); - CHRRAM = NULL; - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper190_Init(CartInfo *info) { - info->Power = M190Power; - info->Close = M190Close; - GameStateRestore = StateRestore; - - MapIRQHook = VRC5IRQ; -// PPU_hook=Mapper190_PPU; - - CHRRAM = (uint8*)FCEU_gmalloc(CHRSIZE); - SetupCartCHRMapping(0x10, CHRRAM, CHRSIZE, 1); - AddExState(CHRRAM, CHRSIZE, 0, "CRAM"); - - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE - 4096; - } - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/vrc6.cpp b/branches/sdl2/src/boards/vrc6.cpp deleted file mode 100644 index 66b45651..00000000 --- a/branches/sdl2/src/boards/vrc6.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * VRC-6 - * - */ - -#include "mapinc.h" - -static uint8 is26; -static uint8 prg[2], chr[8], mirr; -static uint8 IRQLatch, IRQa, IRQd; -static int32 IRQCount, CycleCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { prg, 2, "PRG" }, - { chr, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQd, 1, "IRQD" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQCount, 4, "IRQC" }, - { &CycleCount, 4, "CYCC" }, - { 0 } -}; - -static void(*sfun[3]) (void); -static uint8 vpsg1[8]; -static uint8 vpsg2[4]; -static int32 cvbc[3]; -static int32 vcount[3]; -static int32 dcount[2]; - -static SFORMAT SStateRegs[] = -{ - { vpsg1, 8, "PSG1" }, - { vpsg2, 4, "PSG2" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - if (is26) - setprg8r(0x10, 0x6000, 0); - setprg16(0x8000, prg[0]); - setprg8(0xc000, prg[1]); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC6SW) { - A &= 0xF003; - if (A >= 0x9000 && A <= 0x9002) { - vpsg1[A & 3] = V; - if (sfun[0]) sfun[0](); - } else if (A >= 0xA000 && A <= 0xA002) { - vpsg1[4 | (A & 3)] = V; - if (sfun[1]) sfun[1](); - } else if (A >= 0xB000 && A <= 0xB002) { - vpsg2[A & 3] = V; - if (sfun[2]) sfun[2](); - } -} - -static DECLFW(VRC6Write) { - if (is26) - A = (A & 0xFFFC) | ((A >> 1) & 1) | ((A << 1) & 2); - if (A >= 0x9000 && A <= 0xB002) { - VRC6SW(A, V); - return; - } - switch (A & 0xF003) { - case 0x8000: prg[0] = V; Sync(); break; - case 0xB003: mirr = (V >> 2) & 3; Sync(); break; - case 0xC000: prg[1] = V; Sync(); break; - case 0xD000: chr[0] = V; Sync(); break; - case 0xD001: chr[1] = V; Sync(); break; - case 0xD002: chr[2] = V; Sync(); break; - case 0xD003: chr[3] = V; Sync(); break; - case 0xE000: chr[4] = V; Sync(); break; - case 0xE001: chr[5] = V; Sync(); break; - case 0xE002: chr[6] = V; Sync(); break; - case 0xE003: chr[7] = V; Sync(); break; - case 0xF000: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF001: - IRQa = V & 2; - IRQd = V & 1; - if (V & 2) - IRQCount = IRQLatch; - CycleCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF002: - IRQa = IRQd; - X6502_IRQEnd(FCEU_IQEXT); - } -} - -static void VRC6Power(void) { - Sync(); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetWriteHandler(0x8000, 0xFFFF, VRC6Write); -} - -static void VRC6IRQHook(int a) { - if (IRQa) { - CycleCount += a * 3; - while(CycleCount >= 341) { - CycleCount -= 341; - IRQCount++; - if (IRQCount == 0x100) { - IRQCount = IRQLatch; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void VRC6Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void StateRestore(int version) { - Sync(); -} - -// VRC6 Sound - -static void DoSQV1(void); -static void DoSQV2(void); -static void DoSawV(void); - -static INLINE void DoSQV(int x) { - int32 V; - int32 amp = (((vpsg1[x << 2] & 15) << 8) * 6 / 8) >> 4; - int32 start, end; - - start = cvbc[x]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - cvbc[x] = end; - - if (vpsg1[(x << 2) | 0x2] & 0x80) { - if (vpsg1[x << 2] & 0x80) { - for (V = start; V < end; V++) - Wave[V >> 4] += amp; - } else { - int32 thresh = (vpsg1[x << 2] >> 4) & 7; - int32 freq = ((vpsg1[(x << 2) | 0x1] | ((vpsg1[(x << 2) | 0x2] & 15) << 8)) + 1) << 17; - for (V = start; V < end; V++) { - if (dcount[x] > thresh) - Wave[V >> 4] += amp; - vcount[x] -= nesincsize; - while (vcount[x] <= 0) { - vcount[x] += freq; - dcount[x] = (dcount[x] + 1) & 15; - } - } - } - } -} - -static void DoSQV1(void) { - DoSQV(0); -} - -static void DoSQV2(void) { - DoSQV(1); -} - -static void DoSawV(void) { - int V; - int32 start, end; - - start = cvbc[2]; - end = (SOUNDTS << 16) / soundtsinc; - if (end <= start) return; - cvbc[2] = end; - - if (vpsg2[2] & 0x80) { - static int32 saw1phaseacc = 0; - uint32 freq3; - static uint8 b3 = 0; - static int32 phaseacc = 0; - static uint32 duff = 0; - - freq3 = (vpsg2[1] + ((vpsg2[2] & 15) << 8) + 1); - - for (V = start; V < end; V++) { - saw1phaseacc -= nesincsize; - if (saw1phaseacc <= 0) { - int32 t; - rea: - t = freq3; - t <<= 18; - saw1phaseacc += t; - phaseacc += vpsg2[0] & 0x3f; - b3++; - if (b3 == 7) { - b3 = 0; - phaseacc = 0; - } - if (saw1phaseacc <= 0) - goto rea; - duff = (((phaseacc >> 3) & 0x1f) << 4) * 6 / 8; - } - Wave[V >> 4] += duff; - } - } -} - -static INLINE void DoSQVHQ(int x) { - int32 V; - int32 amp = ((vpsg1[x << 2] & 15) << 8) * 6 / 8; - - if (vpsg1[(x << 2) | 0x2] & 0x80) { - if (vpsg1[x << 2] & 0x80) { - for (V = cvbc[x]; V < (int)SOUNDTS; V++) - WaveHi[V] += amp; - } else { - int32 thresh = (vpsg1[x << 2] >> 4) & 7; - for (V = cvbc[x]; V < (int)SOUNDTS; V++) { - if (dcount[x] > thresh) - WaveHi[V] += amp; - vcount[x]--; - if (vcount[x] <= 0) { - vcount[x] = (vpsg1[(x << 2) | 0x1] | ((vpsg1[(x << 2) | 0x2] & 15) << 8)) + 1; - dcount[x] = (dcount[x] + 1) & 15; - } - } - } - } - cvbc[x] = SOUNDTS; -} - -static void DoSQV1HQ(void) { - DoSQVHQ(0); -} - -static void DoSQV2HQ(void) { - DoSQVHQ(1); -} - -static void DoSawVHQ(void) { - static uint8 b3 = 0; - static int32 phaseacc = 0; - int32 V; - - if (vpsg2[2] & 0x80) { - for (V = cvbc[2]; V < (int)SOUNDTS; V++) { - WaveHi[V] += (((phaseacc >> 3) & 0x1f) << 8) * 6 / 8; - vcount[2]--; - if (vcount[2] <= 0) { - vcount[2] = (vpsg2[1] + ((vpsg2[2] & 15) << 8) + 1) << 1; - phaseacc += vpsg2[0] & 0x3f; - b3++; - if (b3 == 7) { - b3 = 0; - phaseacc = 0; - } - } - } - } - cvbc[2] = SOUNDTS; -} - - -void VRC6Sound(int Count) { - int x; - - DoSQV1(); - DoSQV2(); - DoSawV(); - for (x = 0; x < 3; x++) - cvbc[x] = Count; -} - -void VRC6SoundHQ(void) { - DoSQV1HQ(); - DoSQV2HQ(); - DoSawVHQ(); -} - -void VRC6SyncHQ(int32 ts) { - int x; - for (x = 0; x < 3; x++) cvbc[x] = ts; -} - -static void VRC6_ESI(void) { - GameExpSound.RChange = VRC6_ESI; - GameExpSound.Fill = VRC6Sound; - GameExpSound.HiFill = VRC6SoundHQ; - GameExpSound.HiSync = VRC6SyncHQ; - - memset(cvbc, 0, sizeof(cvbc)); - memset(vcount, 0, sizeof(vcount)); - memset(dcount, 0, sizeof(dcount)); - if (FSettings.SndRate) { - if (FSettings.soundq >= 1) { - sfun[0] = DoSQV1HQ; - sfun[1] = DoSQV2HQ; - sfun[2] = DoSawVHQ; - } else { - sfun[0] = DoSQV1; - sfun[1] = DoSQV2; - sfun[2] = DoSawV; - } - } else - memset(sfun, 0, sizeof(sfun)); - AddExState(&SStateRegs, ~0, 0, 0); -} - -// VRC6 Sound - -void Mapper24_Init(CartInfo *info) { - is26 = 0; - info->Power = VRC6Power; - MapIRQHook = VRC6IRQHook; - VRC6_ESI(); - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper26_Init(CartInfo *info) { - is26 = 1; - info->Power = VRC6Power; - info->Close = VRC6Close; - MapIRQHook = VRC6IRQHook; - VRC6_ESI(); - GameStateRestore = StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFVRC6_Init(void) { - VRC6_ESI(); - SetWriteHandler(0x8000, 0xbfff, VRC6SW); -} diff --git a/branches/sdl2/src/boards/vrc7.cpp b/branches/sdl2/src/boards/vrc7.cpp deleted file mode 100644 index 39154efa..00000000 --- a/branches/sdl2/src/boards/vrc7.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2012 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "mapinc.h" - -static uint8 vrc7idx, preg[3], creg[8], mirr; -static uint8 IRQLatch, IRQa, IRQd; -static int32 IRQCount, CycleCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static SFORMAT StateRegs[] = -{ - { &vrc7idx, 1, "VRCI" }, - { preg, 3, "PREG" }, - { creg, 8, "CREG" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQd, 1, "IRQD" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQCount, 4, "IRQC" }, - { &CycleCount, 4, "CYCC" }, - { 0 } -}; - -// VRC7 Sound - -#include "emu2413.h" - -static int32 dwave = 0; -static OPLL *VRC7Sound = NULL; - -void DoVRC7Sound(void) { - int32 z, a; - if (FSettings.soundq >= 1) - return; - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - OPLL_fillbuf(VRC7Sound, &Wave[dwave], a, 1); - dwave += a; -} - -void UpdateOPLNEO(int32 *Wave, int Count) { - OPLL_fillbuf(VRC7Sound, Wave, Count, 4); -} - -void UpdateOPL(int Count) { - int32 z, a; - z = ((SOUNDTS << 16) / soundtsinc) >> 4; - a = z - dwave; - if (VRC7Sound && a) - OPLL_fillbuf(VRC7Sound, &Wave[dwave], a, 1); - dwave = 0; -} - -static void VRC7SC(void) { - if (VRC7Sound) - OPLL_set_rate(VRC7Sound, FSettings.SndRate); -} - -static void VRC7SKill(void) { - if (VRC7Sound) - OPLL_delete(VRC7Sound); - VRC7Sound = NULL; -} - -static void VRC7_ESI(void) { - GameExpSound.RChange = VRC7SC; - GameExpSound.Kill = VRC7SKill; - VRC7Sound = OPLL_new(3579545, FSettings.SndRate ? FSettings.SndRate : 44100); - OPLL_reset(VRC7Sound); - OPLL_reset(VRC7Sound); -} - -// VRC7 Sound - -static void Sync(void) { - uint8 i; - setprg8r(0x10, 0x6000, 0); - setprg8(0x8000, preg[0]); - setprg8(0xA000, preg[1]); - setprg8(0xC000, preg[2]); - setprg8(0xE000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, creg[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(VRC7SW) { - if (FSettings.SndRate) { - OPLL_writeReg(VRC7Sound, vrc7idx, V); - GameExpSound.Fill = UpdateOPL; - GameExpSound.NeoFill = UpdateOPLNEO; - } -} - -static DECLFW(VRC7Write) { - A |= (A & 8) << 1; // another two-in-oooone - if (A >= 0xA000 && A <= 0xDFFF) { - A &= 0xF010; - creg[((A >> 4) & 1) | ((A - 0xA000) >> 11)] = V; - Sync(); - } else if (A == 0x9030) { - VRC7SW(A, V); - } else switch (A & 0xF010) { - case 0x8000: preg[0] = V; Sync(); break; - case 0x8010: preg[1] = V; Sync(); break; - case 0x9000: preg[2] = V; Sync(); break; - case 0x9010: vrc7idx = V; break; - case 0xE000: mirr = V & 3; Sync(); break; - case 0xE010: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xF000: - IRQa = V & 2; - IRQd = V & 1; - if (V & 2) - IRQCount = IRQLatch; - CycleCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF010: - IRQa = IRQd; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void VRC7Power(void) { - Sync(); - SetWriteHandler(0x6000, 0x7FFF, CartBW); - SetReadHandler(0x6000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, VRC7Write); -} - -static void VRC7Close(void) -{ - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void VRC7IRQHook(int a) { - if (IRQa) { - CycleCount += a * 3; - while(CycleCount >= 341) { - CycleCount -= 341; - IRQCount++; - if (IRQCount == 0x100) { - IRQCount = IRQLatch; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper85_Init(CartInfo *info) { - info->Power = VRC7Power; - info->Close = VRC7Close; - MapIRQHook = VRC7IRQHook; - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - if (info->battery) { - info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = WRAMSIZE; - } - GameStateRestore = StateRestore; - VRC7_ESI(); - AddExState(&StateRegs, ~0, 0, 0); -} - -void NSFVRC7_Init(void) { - SetWriteHandler(0x9010, 0x901F, VRC7Write); - SetWriteHandler(0x9030, 0x903F, VRC7Write); - VRC7_ESI(); -} diff --git a/branches/sdl2/src/boards/vrc7p.cpp b/branches/sdl2/src/boards/vrc7p.cpp deleted file mode 100644 index 5a886cb0..00000000 --- a/branches/sdl2/src/boards/vrc7p.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2009 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * YOKO Mortal Kombat V Pro, VRC7 pirate clone - */ - -#include "mapinc.h" - -static uint8 prg[3], chr[8], mirr; -static uint8 IRQLatch, IRQa, IRQd; -static int32 IRQCount, CycleCount; - -static SFORMAT StateRegs[] = -{ - { prg, 3, "PRG" }, - { chr, 8, "CHR" }, - { &mirr, 1, "MIRR" }, - { &IRQa, 1, "IRQA" }, - { &IRQd, 1, "IRQD" }, - { &IRQLatch, 1, "IRQL" }, - { &IRQCount, 4, "IRQC" }, - { &CycleCount, 4, "CYCC" }, - { 0 } -}; - -static void Sync(void) { - uint8 i; - setprg8(0x8000, prg[0]); - setprg8(0xa000, prg[1]); - setprg8(0xc000, prg[2]); - setprg8(0xe000, ~0); - for (i = 0; i < 8; i++) - setchr1(i << 10, chr[i]); - switch (mirr & 3) { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(UNLVRC7Write) { - switch (A & 0xF008) { - case 0x8000: prg[0] = V; Sync(); break; - case 0x8008: prg[1] = V; Sync(); break; - case 0x9000: prg[2] = V; Sync(); break; - case 0xa000: chr[0] = V; Sync(); break; - case 0xa008: chr[1] = V; Sync(); break; - case 0xb000: chr[2] = V; Sync(); break; - case 0xb008: chr[3] = V; Sync(); break; - case 0xc000: chr[4] = V; Sync(); break; - case 0xc008: chr[5] = V; Sync(); break; - case 0xd000: chr[6] = V; Sync(); break; - case 0xd008: chr[7] = V; Sync(); break; - case 0xe000: mirr = V; Sync(); break; - case 0xe008: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0xf000: - IRQa = V & 2; - IRQd = V & 1; - if (V & 2) - IRQCount = IRQLatch; - CycleCount = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf008: - if (IRQd) - IRQa = 1; - else - IRQa = 0; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void UNLVRC7Power(void) { - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLVRC7Write); -} - -static void UNLVRC7IRQHook(int a) { - if (IRQa) { - CycleCount += a * 3; - while (CycleCount >= 341) { - CycleCount -= 341; - IRQCount++; - if (IRQCount == 248) { - IRQCount = IRQLatch; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void StateRestore(int version) { - Sync(); -} - -void UNLVRC7_Init(CartInfo *info) { - info->Power = UNLVRC7Power; - MapIRQHook = UNLVRC7IRQHook; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/boards/yoko.cpp b/branches/sdl2/src/boards/yoko.cpp deleted file mode 100644 index d2b4e05b..00000000 --- a/branches/sdl2/src/boards/yoko.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * YOKO mapper, almost the same as 83, TODO: figure out difference - * Mapper 83 - 30-in-1 mapper, two modes for single game carts, one mode for - * multigame Dragon Ball Z Party - * - * Mortal Kombat 2 YOKO - * N-CXX(M), XX - PRG+CHR, 12 - 128+256, 22 - 256+256, 14 - 128+512 - * - */ - -#include "mapinc.h" - -static uint8 mode, bank, reg[11], low[4], dip, IRQa; -static int32 IRQCount; -static uint8 *WRAM = NULL; -static uint32 WRAMSIZE; - -static uint8 is2kbank, isnot2kbank; - -static SFORMAT StateRegs[] = -{ - { &mode, 1, "MODE" }, - { &bank, 1, "BANK" }, - { &IRQCount, 4, "IRQC" }, - { &IRQa, 1, "IRQA" }, - { reg, 11, "REGS" }, - { low, 4, "LOWR" }, - { &is2kbank, 1, "IS2K" }, - { &isnot2kbank, 1, "NT2K" }, - { 0 } -}; - -static void UNLYOKOSync(void) { - setmirror((mode & 1) ^ 1); - setchr2(0x0000, reg[3]); - setchr2(0x0800, reg[4]); - setchr2(0x1000, reg[5]); - setchr2(0x1800, reg[6]); - if (mode & 0x10) { - uint32 base = (bank & 8) << 1; - setprg8(0x8000, (reg[0] & 0x0f) | base); - setprg8(0xA000, (reg[1] & 0x0f) | base); - setprg8(0xC000, (reg[2] & 0x0f) | base); - setprg8(0xE000, 0x0f | base); - } else { - if (mode & 8) - setprg32(0x8000, bank >> 1); - else{ - setprg16(0x8000, bank); - setprg16(0xC000, ~0); - } - } -} - -static void M83Sync(void) { - switch (mode & 3) { // check if it is truth - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } - if (is2kbank && !isnot2kbank) { - setchr2(0x0000, reg[0]); - setchr2(0x0800, reg[1]); - setchr2(0x1000, reg[6]); - setchr2(0x1800, reg[7]); - } else { - int x; - for (x = 0; x < 8; x++) - setchr1(x << 10, reg[x] | ((bank & 0x30) << 4)); - } - setprg8r(0x10, 0x6000, 0); - if (mode & 0x40) { - setprg16(0x8000, (bank & 0x3F)); // DBZ Party [p1] - setprg16(0xC000, (bank & 0x30) | 0xF); - } else { - setprg8(0x8000, reg[8]); - setprg8(0xA000, reg[9]); - setprg8(0xC000, reg[10]); - setprg8(0xE000, ~0); - } -} - -static DECLFW(UNLYOKOWrite) { - switch (A & 0x8C17) { - case 0x8000: bank = V; UNLYOKOSync(); break; - case 0x8400: mode = V; UNLYOKOSync(); break; - case 0x8800: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x8801: IRQa = mode & 0x80; IRQCount &= 0xFF; IRQCount |= V << 8; break; - case 0x8c00: reg[0] = V; UNLYOKOSync(); break; - case 0x8c01: reg[1] = V; UNLYOKOSync(); break; - case 0x8c02: reg[2] = V; UNLYOKOSync(); break; - case 0x8c10: reg[3] = V; UNLYOKOSync(); break; - case 0x8c11: reg[4] = V; UNLYOKOSync(); break; - case 0x8c16: reg[5] = V; UNLYOKOSync(); break; - case 0x8c17: reg[6] = V; UNLYOKOSync(); break; - } -} - -static DECLFW(M83Write) { - switch (A) { - case 0x8000: is2kbank = 1; - case 0xB000: // Dragon Ball Z Party [p1] BMC - case 0xB0FF: // Dragon Ball Z Party [p1] BMC - case 0xB1FF: bank = V; mode |= 0x40; M83Sync(); break; // Dragon Ball Z Party [p1] BMC - case 0x8100: mode = V | (mode & 0x40); M83Sync(); break; - case 0x8200: IRQCount &= 0xFF00; IRQCount |= V; X6502_IRQEnd(FCEU_IQEXT); break; - case 0x8201: IRQa = mode & 0x80; IRQCount &= 0xFF; IRQCount |= V << 8; break; - case 0x8300: reg[8] = V; mode &= 0xBF; M83Sync(); break; - case 0x8301: reg[9] = V; mode &= 0xBF; M83Sync(); break; - case 0x8302: reg[10] = V; mode &= 0xBF; M83Sync(); break; - case 0x8310: reg[0] = V; M83Sync(); break; - case 0x8311: reg[1] = V; M83Sync(); break; - case 0x8312: reg[2] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8313: reg[3] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8314: reg[4] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8315: reg[5] = V; isnot2kbank = 1; M83Sync(); break; - case 0x8316: reg[6] = V; M83Sync(); break; - case 0x8317: reg[7] = V; M83Sync(); break; - } -} - -static DECLFR(UNLYOKOReadDip) { - return (X.DB & 0xFC) | dip; -} - -static DECLFR(UNLYOKOReadLow) { - return low[A & 3]; -} - -static DECLFW(UNLYOKOWriteLow) { - low[A & 3] = V; -} - -static void UNLYOKOPower(void) { - mode = bank = 0; - dip = 3; - UNLYOKOSync(); - SetReadHandler(0x5000, 0x53FF, UNLYOKOReadDip); - SetReadHandler(0x5400, 0x5FFF, UNLYOKOReadLow); - SetWriteHandler(0x5400, 0x5FFF, UNLYOKOWriteLow); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, UNLYOKOWrite); -} - -static void M83Power(void) { - is2kbank = 0; - isnot2kbank = 0; - mode = bank = 0; - dip = 0; - M83Sync(); - SetReadHandler(0x5000, 0x5000, UNLYOKOReadDip); - SetReadHandler(0x5100, 0x5103, UNLYOKOReadLow); - SetWriteHandler(0x5100, 0x5103, UNLYOKOWriteLow); - SetReadHandler(0x6000, 0x7fff, CartBR); - SetWriteHandler(0x6000, 0x7fff, CartBW); // Pirate Dragon Ball Z Party [p1] used if for saves instead of seraial EEPROM - SetReadHandler(0x8000, 0xffff, CartBR); - SetWriteHandler(0x8000, 0xffff, M83Write); -} - -static void UNLYOKOReset(void) { - dip = (dip + 1) & 3; - mode = bank = 0; - UNLYOKOSync(); -} - -static void M83Reset(void) { - dip ^= 1; - M83Sync(); -} - -static void M83Close(void) { - if (WRAM) - FCEU_gfree(WRAM); - WRAM = NULL; -} - -static void UNLYOKOIRQHook(int a) { - if (IRQa) { - IRQCount -= a; - if (IRQCount < 0) { - X6502_IRQBegin(FCEU_IQEXT); - IRQa = 0; - IRQCount = 0xFFFF; - } - } -} - -static void UNLYOKOStateRestore(int version) { - UNLYOKOSync(); -} - -static void M83StateRestore(int version) { - M83Sync(); -} - -void UNLYOKO_Init(CartInfo *info) { - info->Power = UNLYOKOPower; - info->Reset = UNLYOKOReset; - MapIRQHook = UNLYOKOIRQHook; - GameStateRestore = UNLYOKOStateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper83_Init(CartInfo *info) { - info->Power = M83Power; - info->Reset = M83Reset; - info->Close = M83Close; - MapIRQHook = UNLYOKOIRQHook; - GameStateRestore = M83StateRestore; - - WRAMSIZE = 8192; - WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); - SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); - AddExState(WRAM, WRAMSIZE, 0, "WRAM"); - - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/branches/sdl2/src/cart.cpp b/branches/sdl2/src/cart.cpp deleted file mode 100644 index baeaba65..00000000 --- a/branches/sdl2/src/cart.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/// \file -/// \brief This file contains all code for coordinating the mapping in of the address space external to the NES. - -#include "types.h" -#include "fceu.h" -#include "ppu.h" -#include "driver.h" - -#include "cart.h" -#include "x6502.h" - -#include "file.h" -#include "utils/memory.h" - - -#include -#include -#include -#include - -uint8 *Page[32], *VPage[8]; -uint8 **VPageR = VPage; -uint8 *VPageG[8]; -uint8 *MMC5SPRVPage[8]; -uint8 *MMC5BGVPage[8]; - -static uint8 PRGIsRAM[32]; /* This page is/is not PRG RAM. */ - -/* 16 are (sort of) reserved for UNIF/iNES and 16 to map other stuff. */ -uint8 CHRram[32]; -uint8 PRGram[32]; - -uint8 *PRGptr[32]; -uint8 *CHRptr[32]; - -uint32 PRGsize[32]; -uint32 CHRsize[32]; - -uint32 PRGmask2[32]; -uint32 PRGmask4[32]; -uint32 PRGmask8[32]; -uint32 PRGmask16[32]; -uint32 PRGmask32[32]; - -uint32 CHRmask1[32]; -uint32 CHRmask2[32]; -uint32 CHRmask4[32]; -uint32 CHRmask8[32]; - -int geniestage = 0; - -int modcon; - -uint8 genieval[3]; -uint8 geniech[3]; - -uint32 genieaddr[3]; - -static INLINE void setpageptr(int s, uint32 A, uint8 *p, int ram) { - uint32 AB = A >> 11; - int x; - - if (p) - for (x = (s >> 1) - 1; x >= 0; x--) { - PRGIsRAM[AB + x] = ram; - Page[AB + x] = p - A; - } - else - for (x = (s >> 1) - 1; x >= 0; x--) { - PRGIsRAM[AB + x] = 0; - Page[AB + x] = 0; - } -} - -static uint8 nothing[8192]; -void ResetCartMapping(void) { - int x; - - PPU_ResetHooks(); - - for (x = 0; x < 32; x++) { - Page[x] = nothing - x * 2048; - PRGptr[x] = CHRptr[x] = 0; - PRGsize[x] = CHRsize[x] = 0; - } - for (x = 0; x < 8; x++) { - MMC5SPRVPage[x] = MMC5BGVPage[x] = VPageR[x] = nothing - 0x400 * x; - } -} - -void SetupCartPRGMapping(int chip, uint8 *p, uint32 size, int ram) { - PRGptr[chip] = p; - PRGsize[chip] = size; - - PRGmask2[chip] = (size >> 11) - 1; - PRGmask4[chip] = (size >> 12) - 1; - PRGmask8[chip] = (size >> 13) - 1; - PRGmask16[chip] = (size >> 14) - 1; - PRGmask32[chip] = (size >> 15) - 1; - - PRGram[chip] = ram ? 1 : 0; -} - -void SetupCartCHRMapping(int chip, uint8 *p, uint32 size, int ram) { - CHRptr[chip] = p; - CHRsize[chip] = size; - - CHRmask1[chip] = (size >> 10) - 1; - CHRmask2[chip] = (size >> 11) - 1; - CHRmask4[chip] = (size >> 12) - 1; - CHRmask8[chip] = (size >> 13) - 1; - - CHRram[chip] = ram; -} - -DECLFR(CartBR) { - return Page[A >> 11][A]; -} - -DECLFW(CartBW) { - //printf("Ok: %04x:%02x, %d\n",A,V,PRGIsRAM[A>>11]); - if (PRGIsRAM[A >> 11] && Page[A >> 11]) - Page[A >> 11][A] = V; -} - -DECLFR(CartBROB) { - if (!Page[A >> 11]) - return(X.DB); - else - return Page[A >> 11][A]; -} - -void setprg2r(int r, uint32 A, uint32 V) { - V &= PRGmask2[r]; - setpageptr(2, A, PRGptr[r] ? (&PRGptr[r][V << 11]) : 0, PRGram[r]); -} - -void setprg2(uint32 A, uint32 V) { - setprg2r(0, A, V); -} - -void setprg4r(int r, uint32 A, uint32 V) { - V &= PRGmask4[r]; - setpageptr(4, A, PRGptr[r] ? (&PRGptr[r][V << 12]) : 0, PRGram[r]); -} - -void setprg4(uint32 A, uint32 V) { - setprg4r(0, A, V); -} - -void setprg8r(int r, uint32 A, uint32 V) { - if (PRGsize[r] >= 8192) { - V &= PRGmask8[r]; - setpageptr(8, A, PRGptr[r] ? (&PRGptr[r][V << 13]) : 0, PRGram[r]); - } else { - uint32 VA = V << 2; - int x; - for (x = 0; x < 4; x++) - setpageptr(2, A + (x << 11), PRGptr[r] ? (&PRGptr[r][((VA + x) & PRGmask2[r]) << 11]) : 0, PRGram[r]); - } -} - -void setprg8(uint32 A, uint32 V) { - setprg8r(0, A, V); -} - -void setprg16r(int r, uint32 A, uint32 V) { - if (PRGsize[r] >= 16384) { - V &= PRGmask16[r]; - setpageptr(16, A, PRGptr[r] ? (&PRGptr[r][V << 14]) : 0, PRGram[r]); - } else { - uint32 VA = V << 3; - int x; - - for (x = 0; x < 8; x++) - setpageptr(2, A + (x << 11), PRGptr[r] ? (&PRGptr[r][((VA + x) & PRGmask2[r]) << 11]) : 0, PRGram[r]); - } -} - -void setprg16(uint32 A, uint32 V) { - setprg16r(0, A, V); -} - -void setprg32r(int r, uint32 A, uint32 V) { - if (PRGsize[r] >= 32768) { - V &= PRGmask32[r]; - setpageptr(32, A, PRGptr[r] ? (&PRGptr[r][V << 15]) : 0, PRGram[r]); - } else { - uint32 VA = V << 4; - int x; - - for (x = 0; x < 16; x++) - setpageptr(2, A + (x << 11), PRGptr[r] ? (&PRGptr[r][((VA + x) & PRGmask2[r]) << 11]) : 0, PRGram[r]); - } -} - -void setprg32(uint32 A, uint32 V) { - setprg32r(0, A, V); -} - -void setchr1r(int r, uint32 A, uint32 V) { - if (!CHRptr[r]) return; - FCEUPPU_LineUpdate(); - V &= CHRmask1[r]; - if (CHRram[r]) - PPUCHRRAM |= (1 << (A >> 10)); - else - PPUCHRRAM &= ~(1 << (A >> 10)); - VPageR[(A) >> 10] = &CHRptr[r][(V) << 10] - (A); -} - -void setchr2r(int r, uint32 A, uint32 V) { - if (!CHRptr[r]) return; - FCEUPPU_LineUpdate(); - V &= CHRmask2[r]; - VPageR[(A) >> 10] = VPageR[((A) >> 10) + 1] = &CHRptr[r][(V) << 11] - (A); - if (CHRram[r]) - PPUCHRRAM |= (3 << (A >> 10)); - else - PPUCHRRAM &= ~(3 << (A >> 10)); -} - -void setchr4r(int r, unsigned int A, unsigned int V) { - if (!CHRptr[r]) return; - FCEUPPU_LineUpdate(); - V &= CHRmask4[r]; - VPageR[(A) >> 10] = VPageR[((A) >> 10) + 1] = - VPageR[((A) >> 10) + 2] = VPageR[((A) >> 10) + 3] = &CHRptr[r][(V) << 12] - (A); - if (CHRram[r]) - PPUCHRRAM |= (15 << (A >> 10)); - else - PPUCHRRAM &= ~(15 << (A >> 10)); -} - -void setchr8r(int r, uint32 V) { - int x; - - if (!CHRptr[r]) return; - FCEUPPU_LineUpdate(); - V &= CHRmask8[r]; - for (x = 7; x >= 0; x--) - VPageR[x] = &CHRptr[r][V << 13]; - if (CHRram[r]) - PPUCHRRAM |= (255); - else - PPUCHRRAM = 0; -} - -void setchr1(uint32 A, uint32 V) { - setchr1r(0, A, V); -} - -void setchr2(uint32 A, uint32 V) { - setchr2r(0, A, V); -} - -void setchr4(uint32 A, uint32 V) { - setchr4r(0, A, V); -} - -void setchr8(uint32 V) { - setchr8r(0, V); -} - -/* This function can be called without calling SetupCartMirroring(). */ - -void setntamem(uint8 *p, int ram, uint32 b) { - FCEUPPU_LineUpdate(); - vnapage[b] = p; - PPUNTARAM &= ~(1 << b); - if (ram) - PPUNTARAM |= 1 << b; -} - -static int mirrorhard = 0; -void setmirrorw(int a, int b, int c, int d) { - FCEUPPU_LineUpdate(); - vnapage[0] = NTARAM + a * 0x400; - vnapage[1] = NTARAM + b * 0x400; - vnapage[2] = NTARAM + c * 0x400; - vnapage[3] = NTARAM + d * 0x400; -} - -void setmirror(int t) { - FCEUPPU_LineUpdate(); - if (!mirrorhard) { - switch (t) { - case MI_H: - vnapage[0] = vnapage[1] = NTARAM; vnapage[2] = vnapage[3] = NTARAM + 0x400; - break; - case MI_V: - vnapage[0] = vnapage[2] = NTARAM; vnapage[1] = vnapage[3] = NTARAM + 0x400; - break; - case MI_0: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = NTARAM; - break; - case MI_1: - vnapage[0] = vnapage[1] = vnapage[2] = vnapage[3] = NTARAM + 0x400; - break; - } - PPUNTARAM = 0xF; - } -} - -void SetupCartMirroring(int m, int hard, uint8 *extra) { - if (m < 4) { - mirrorhard = 0; - setmirror(m); - } else { - vnapage[0] = NTARAM; - vnapage[1] = NTARAM + 0x400; - vnapage[2] = extra; - vnapage[3] = extra + 0x400; - PPUNTARAM = 0xF; - } - mirrorhard = hard; -} - -static uint8 *GENIEROM = 0; - -void FixGenieMap(void); - -// Called when a game(file) is opened successfully. Returns TRUE on error. -bool FCEU_OpenGenie(void) -{ - FILE *fp; - int x; - - if (!GENIEROM) - { - char *fn; - - if (!(GENIEROM = (uint8*)FCEU_malloc(4096 + 1024))) - return true; - - fn = strdup(FCEU_MakeFName(FCEUMKF_GGROM, 0, 0).c_str()); - fp = FCEUD_UTF8fopen(fn, "rb"); - if (!fp) - { - FCEU_PrintError("Error opening Game Genie ROM image!\nIt should be named \"gg.rom\"!"); - free(GENIEROM); - GENIEROM = 0; - return true; - } - if (fread(GENIEROM, 1, 16, fp) != 16) - { - grerr: - FCEU_PrintError("Error reading from Game Genie ROM image!"); - free(GENIEROM); - GENIEROM = 0; - fclose(fp); - return true; - } - if (GENIEROM[0] == 0x4E) - { - /* iNES ROM image */ - if (fread(GENIEROM, 1, 4096, fp) != 4096) - goto grerr; - if (fseek(fp, 16384 - 4096, SEEK_CUR)) - goto grerr; - if (fread(GENIEROM + 4096, 1, 256, fp) != 256) - goto grerr; - } else - { - if (fread(GENIEROM + 16, 1, 4352 - 16, fp) != (4352 - 16)) - goto grerr; - } - fclose(fp); - - /* Workaround for the FCE Ultra CHR page size only being 1KB */ - for (x = 0; x < 4; x++) - { - memcpy(GENIEROM + 4096 + (x << 8), GENIEROM + 4096, 256); - } - } - - geniestage = 1; - return false; -} - -/* Called when a game is closed. */ -void FCEU_CloseGenie(void) { - /* No good reason to free() the Game Genie ROM image data. */ - geniestage = 0; - FlushGenieRW(); - VPageR = VPage; -} - -void FCEU_KillGenie(void) { - if (GENIEROM) { - free(GENIEROM); - GENIEROM = 0; - } -} - -static DECLFR(GenieRead) { - return GENIEROM[A & 4095]; -} - -static DECLFW(GenieWrite) { - switch (A) { - case 0x800c: - case 0x8008: - case 0x8004: genieval[((A - 4) & 0xF) >> 2] = V; break; - - case 0x800b: - case 0x8007: - case 0x8003: geniech[((A - 3) & 0xF) >> 2] = V; break; - - case 0x800a: - case 0x8006: - case 0x8002: genieaddr[((A - 2) & 0xF) >> 2] &= 0xFF00; genieaddr[((A - 2) & 0xF) >> 2] |= V; break; - - case 0x8009: - case 0x8005: - case 0x8001: genieaddr[((A - 1) & 0xF) >> 2] &= 0xFF; genieaddr[((A - 1) & 0xF) >> 2] |= (V | 0x80) << 8; break; - - case 0x8000: - if (!V) - FixGenieMap(); - else { - modcon = V ^ 0xFF; - if (V == 0x71) - modcon = 0; - } - break; - } -} - -static readfunc GenieBackup[3]; - -static DECLFR(GenieFix1) { - uint8 r = GenieBackup[0](A); - - if ((modcon >> 1) & 1) // No check - return genieval[0]; - else if (r == geniech[0]) - return genieval[0]; - - return r; -} - -static DECLFR(GenieFix2) { - uint8 r = GenieBackup[1](A); - - if ((modcon >> 2) & 1) // No check - return genieval[1]; - else if (r == geniech[1]) - return genieval[1]; - - return r; -} - -static DECLFR(GenieFix3) { - uint8 r = GenieBackup[2](A); - - if ((modcon >> 3) & 1) // No check - return genieval[2]; - else if (r == geniech[2]) - return genieval[2]; - - return r; -} - - -void FixGenieMap(void) { - int x; - - geniestage = 2; - - for (x = 0; x < 8; x++) - VPage[x] = VPageG[x]; - - VPageR = VPage; - FlushGenieRW(); - //printf("Rightyo\n"); - for (x = 0; x < 3; x++) - if ((modcon >> (4 + x)) & 1) { - readfunc tmp[3] = { GenieFix1, GenieFix2, GenieFix3 }; - GenieBackup[x] = GetReadHandler(genieaddr[x]); - SetReadHandler(genieaddr[x], genieaddr[x], tmp[x]); - } -} - -void FCEU_GeniePower(void) { - uint32 x; - - if (!geniestage) - return; - - geniestage = 1; - for (x = 0; x < 3; x++) { - genieval[x] = 0xFF; - geniech[x] = 0xFF; - genieaddr[x] = 0xFFFF; - } - modcon = 0; - - SetWriteHandler(0x8000, 0xFFFF, GenieWrite); - SetReadHandler(0x8000, 0xFFFF, GenieRead); - - for (x = 0; x < 8; x++) - VPage[x] = GENIEROM + 4096 - 0x400 * x; - - if (AllocGenieRW()) - VPageR = VPageG; - else - geniestage = 2; -} - - -void FCEU_SaveGameSave(CartInfo *LocalHWInfo) { - if (LocalHWInfo->battery && LocalHWInfo->SaveGame[0]) { - FILE *sp; - - std::string soot = FCEU_MakeFName(FCEUMKF_SAV, 0, "sav"); - if ((sp = FCEUD_UTF8fopen(soot, "wb")) == NULL) { - FCEU_PrintError("WRAM file \"%s\" cannot be written to.\n", soot.c_str()); - } else { - for (int x = 0; x < 4; x++) - if (LocalHWInfo->SaveGame[x]) { - fwrite(LocalHWInfo->SaveGame[x], 1, - LocalHWInfo->SaveGameLen[x], sp); - } - } - } -} - -// hack, movie.cpp has to communicate with this function somehow -int disableBatteryLoading = 0; - -void FCEU_LoadGameSave(CartInfo *LocalHWInfo) { - if (LocalHWInfo->battery && LocalHWInfo->SaveGame[0] && !disableBatteryLoading) { - FILE *sp; - - std::string soot = FCEU_MakeFName(FCEUMKF_SAV, 0, "sav"); - sp = FCEUD_UTF8fopen(soot, "rb"); - if (sp != NULL) { - for (int x = 0; x < 4; x++) - if (LocalHWInfo->SaveGame[x]) - fread(LocalHWInfo->SaveGame[x], 1, LocalHWInfo->SaveGameLen[x], sp); - } - } -} - -//clears all save memory. call this if you want to pretend the saveram has been reset (it doesnt touch what is on disk though) -void FCEU_ClearGameSave(CartInfo *LocalHWInfo) { - if (LocalHWInfo->battery && LocalHWInfo->SaveGame[0]) { - for (int x = 0; x < 4; x++) - if (LocalHWInfo->SaveGame[x]) - memset(LocalHWInfo->SaveGame[x], 0, LocalHWInfo->SaveGameLen[x]); - } -} diff --git a/branches/sdl2/src/cart.h b/branches/sdl2/src/cart.h deleted file mode 100644 index e5670c54..00000000 --- a/branches/sdl2/src/cart.h +++ /dev/null @@ -1,94 +0,0 @@ -typedef struct { - // Set by mapper/board code: - void (*Power)(void); - void (*Reset)(void); - void (*Close)(void); - uint8 *SaveGame[4]; // Pointers to memory to save/load. - uint32 SaveGameLen[4]; // How much memory to save/load. - - // Set by iNES/UNIF loading code. - int mirror; // As set in the header or chunk. - // iNES/UNIF specific. Intended - // to help support games like "Karnov" - // that are not really MMC3 but are - // set to mapper 4. - int battery; // Presence of an actual battery. - uint8 MD5[16]; - uint32 CRC32; // Should be set by the iNES/UNIF loading - // code, used by mapper/board code, maybe - // other code in the future. -} CartInfo; - -void FCEU_SaveGameSave(CartInfo *LocalHWInfo); -void FCEU_LoadGameSave(CartInfo *LocalHWInfo); -void FCEU_ClearGameSave(CartInfo *LocalHWInfo); - -extern uint8 *Page[32], *VPage[8], *MMC5SPRVPage[8], *MMC5BGVPage[8]; - -void ResetCartMapping(void); -void SetupCartPRGMapping(int chip, uint8 *p, uint32 size, int ram); -void SetupCartCHRMapping(int chip, uint8 *p, uint32 size, int ram); -void SetupCartMirroring(int m, int hard, uint8 *extra); - -DECLFR(CartBROB); -DECLFR(CartBR); -DECLFW(CartBW); - -extern uint8 PRGram[32]; -extern uint8 CHRram[32]; - -extern uint8 *PRGptr[32]; -extern uint8 *CHRptr[32]; - -extern uint32 PRGsize[32]; -extern uint32 CHRsize[32]; - -extern uint32 PRGmask2[32]; -extern uint32 PRGmask4[32]; -extern uint32 PRGmask8[32]; -extern uint32 PRGmask16[32]; -extern uint32 PRGmask32[32]; - -extern uint32 CHRmask1[32]; -extern uint32 CHRmask2[32]; -extern uint32 CHRmask4[32]; -extern uint32 CHRmask8[32]; - -void setprg2(uint32 A, uint32 V); -void setprg4(uint32 A, uint32 V); -void setprg8(uint32 A, uint32 V); -void setprg16(uint32 A, uint32 V); -void setprg32(uint32 A, uint32 V); - -void setprg2r(int r, unsigned int A, unsigned int V); -void setprg4r(int r, unsigned int A, unsigned int V); -void setprg8r(int r, unsigned int A, unsigned int V); -void setprg16r(int r, unsigned int A, unsigned int V); -void setprg32r(int r, unsigned int A, unsigned int V); - -void setchr1r(int r, unsigned int A, unsigned int V); -void setchr2r(int r, unsigned int A, unsigned int V); -void setchr4r(int r, unsigned int A, unsigned int V); -void setchr8r(int r, unsigned int V); - -void setchr1(unsigned int A, unsigned int V); -void setchr2(unsigned int A, unsigned int V); -void setchr4(unsigned int A, unsigned int V); -void setchr8(unsigned int V); - -void setmirror(int t); -void setmirrorw(int a, int b, int c, int d); -void setntamem(uint8 *p, int ram, uint32 b); - -#define MI_H 0 -#define MI_V 1 -#define MI_0 2 -#define MI_1 3 - -extern int geniestage; - -void FCEU_GeniePower(void); - -bool FCEU_OpenGenie(void); -void FCEU_CloseGenie(void); -void FCEU_KillGenie(void); diff --git a/branches/sdl2/src/cheat.cpp b/branches/sdl2/src/cheat.cpp deleted file mode 100644 index 051ecb58..00000000 --- a/branches/sdl2/src/cheat.cpp +++ /dev/null @@ -1,964 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator -* -* Copyright notice for this file: -* Copyright (C) 2002 Xodnizel -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "types.h" -#include "x6502.h" -#include "cheat.h" -#include "fceu.h" -#include "file.h" -#include "cart.h" -#include "driver.h" -#include "utils/memory.h" - -#include -#include -#include -#include -#include - -using namespace std; - -static uint8 *CheatRPtrs[64]; - -vector FrozenAddresses; //List of addresses that are currently frozen -void UpdateFrozenList(void); //Function that populates the list of frozen addresses -unsigned int FrozenAddressCount=0; //Keeps up with the Frozen address count, necessary for using in other dialogs (such as hex editor) - -void FCEU_CheatResetRAM(void) -{ - int x; - - for(x=0;x<64;x++) - CheatRPtrs[x]=0; -} - -void FCEU_CheatAddRAM(int s, uint32 A, uint8 *p) -{ - uint32 AB=A>>10; - int x; - - for(x=s-1;x>=0;x--) - CheatRPtrs[AB+x]=p-A; -} - - -struct CHEATF { - struct CHEATF *next; - char *name; - uint16 addr; - uint8 val; - int compare; /* -1 for no compare. */ - int type; /* 0 for replace, 1 for substitute(GG). */ - int status; -}; - -typedef struct { - uint16 addr; - uint8 val; - int compare; - readfunc PrevRead; -} CHEATF_SUBFAST; - - -static CHEATF_SUBFAST SubCheats[256]; -static int numsubcheats=0; -struct CHEATF *cheats=0,*cheatsl=0; - - -#define CHEATC_NONE 0x8000 -#define CHEATC_EXCLUDED 0x4000 -#define CHEATC_NOSHOW 0xC000 - -static uint16 *CheatComp = 0; -int savecheats = 0; - -static DECLFR(SubCheatsRead) -{ - CHEATF_SUBFAST *s=SubCheats; - int x=numsubcheats; - - do - { - if(s->addr==A) - { - if(s->compare>=0) - { - uint8 pv=s->PrevRead(A); - - if(pv==s->compare) - return(s->val); - else return(pv); - } - else return(s->val); - } - s++; - } while(--x); - return(0); /* We should never get here. */ -} - -void RebuildSubCheats(void) -{ - int x; - struct CHEATF *c=cheats; - for(x=0;xtype==1 && c->status) - { - if(GetReadHandler(c->addr)==SubCheatsRead) - { - /* Prevent a catastrophe by this check. */ - //FCEU_DispMessage("oops",0); - } - else - { - SubCheats[numsubcheats].PrevRead=GetReadHandler(c->addr); - SubCheats[numsubcheats].addr=c->addr; - SubCheats[numsubcheats].val=c->val; - SubCheats[numsubcheats].compare=c->compare; - SetReadHandler(c->addr,c->addr,SubCheatsRead); - numsubcheats++; - } - } - c=c->next; - } - FrozenAddressCount = numsubcheats; //Update the frozen address list - UpdateFrozenList(); - //FCEUI_DispMessage("Active Cheats: %d",0, FrozenAddresses.size()/*FrozenAddressCount*/); //Debug -} - -void FCEU_PowerCheats() -{ - numsubcheats=0; /* Quick hack to prevent setting of ancient read addresses. */ - RebuildSubCheats(); -} - -static int AddCheatEntry(char *name, uint32 addr, uint8 val, int compare, int status, int type); -static void CheatMemErr(void) -{ - FCEUD_PrintError("Error allocating memory for cheat data."); -} - -/* This function doesn't allocate any memory for "name" */ -static int AddCheatEntry(char *name, uint32 addr, uint8 val, int compare, int status, int type) -{ - struct CHEATF *temp; - if(!(temp=(struct CHEATF *)FCEU_dmalloc(sizeof(struct CHEATF)))) - { - CheatMemErr(); - return(0); - } - temp->name=name; - temp->addr=addr; - temp->val=val; - temp->status=status; - temp->compare=compare; - temp->type=type; - temp->next=0; - - if(cheats) - { - cheatsl->next=temp; - cheatsl=temp; - } - else - cheats=cheatsl=temp; - - return(1); -} - -void FCEU_LoadGameCheats(FILE *override) -{ - FILE *fp; - unsigned int addr; - unsigned int val; - unsigned int status; - unsigned int type; - unsigned int compare; - int x; - - char linebuf[2048]; - char *namebuf; - int tc=0; - char *fn; - - numsubcheats=savecheats=0; - - if(override) - fp = override; - else - { - fn=strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str()); - fp=FCEUD_UTF8fopen(fn,"rb"); - free(fn); - if(!fp) return; - } - - FCEU_DispMessage("Cheats file loaded.",0); //Tells user a cheats file was loaded. - while(fgets(linebuf,2048,fp)>0) - { - char *tbuf=linebuf; - int doc=0; - - addr=val=compare=status=type=0; - - if(tbuf[0]=='S') - { - tbuf++; - type=1; - } - else type=0; - - if(tbuf[0]=='C') - { - tbuf++; - doc=1; - } - - if(tbuf[0]==':') - { - tbuf++; - status=0; - } - else status=1; - - if(doc) - { - char *neo=&tbuf[4+2+2+1+1+1]; - if(sscanf(tbuf,"%04x%*[:]%02x%*[:]%02x",&addr,&val,&compare)!=3) - continue; - if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1))) - return; - strcpy(namebuf,neo); - } - else - { - char *neo=&tbuf[4+2+1+1]; - if(sscanf(tbuf,"%04x%*[:]%02x",&addr,&val)!=2) - continue; - if (!(namebuf=(char *)FCEU_dmalloc(strlen(neo)+1))) - return; - strcpy(namebuf,neo); - } - - for(x=0;x<(int)strlen(namebuf);x++) - { - if(namebuf[x]==10 || namebuf[x]==13) - { - namebuf[x]=0; - break; - } - else if(namebuf[x] > 0x00 && namebuf[x] < 0x20) - namebuf[x]=0x20; - } - - AddCheatEntry(namebuf,addr,val,doc?compare:-1,status,type); - tc++; - } - RebuildSubCheats(); - if(!override) - fclose(fp); -} - -void FCEU_FlushGameCheats(FILE *override, int nosave) -{ - if(CheatComp) - { - free(CheatComp); - CheatComp=0; - } - if((!savecheats || nosave) && !override) /* Always save cheats if we're being overridden. */ - { - if(cheats) - { - struct CHEATF *next=cheats; - for(;;) - { - struct CHEATF *last=next; - next=next->next; - free(last->name); - free(last); - if(!next) break; - } - cheats=cheatsl=0; - } - } - else - { - char *fn = 0; - - if(!override) - fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str()); - - if(cheats) - { - struct CHEATF *next=cheats; - FILE *fp; - - if(override) - fp = override; - else - fp=FCEUD_UTF8fopen(fn,"wb"); - - if(fp) - { - for(;;) - { - struct CHEATF *t; - if(next->type) - fputc('S',fp); - if(next->compare>=0) - fputc('C',fp); - - if(!next->status) - fputc(':',fp); - - if(next->compare>=0) - fprintf(fp,"%04x:%02x:%02x:%s\n",next->addr,next->val,next->compare,next->name); - else - fprintf(fp,"%04x:%02x:%s\n",next->addr,next->val,next->name); - - free(next->name); - t=next; - next=next->next; - free(t); - if(!next) break; - } - if(!override) - fclose(fp); - } - else - FCEUD_PrintError("Error saving cheats."); - cheats=cheatsl=0; - } - else if(!override) - remove(fn); - if(!override) - free(fn); - } - - RebuildSubCheats(); /* Remove memory handlers. */ - -} - - -int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type) -{ - char *t; - - if(!(t=(char *)FCEU_dmalloc(strlen(name)+1))) - { - CheatMemErr(); - return(0); - } - strcpy(t,name); - if(!AddCheatEntry(t,addr,val,compare,1,type)) - { - free(t); - return(0); - } - savecheats=1; - RebuildSubCheats(); - - return(1); -} - -int FCEUI_DelCheat(uint32 which) -{ - struct CHEATF *prev; - struct CHEATF *cur; - uint32 x=0; - - for(prev=0,cur=cheats;;) - { - if(x==which) // Remove this cheat. - { - if(prev) // Update pointer to this cheat. - { - if(cur->next) // More cheats. - prev->next=cur->next; - else // No more. - { - prev->next=0; - cheatsl=prev; // Set the previous cheat as the last cheat. - } - } - else // This is the first cheat. - { - if(cur->next) // More cheats - cheats=cur->next; - else - cheats=cheatsl=0; // No (more) cheats. - } - free(cur->name); // Now that all references to this cheat are removed, - free(cur); // free the memory. - break; - } // *END REMOVE THIS CHEAT* - - - if(!cur->next) // No more cheats to go through(this shouldn't ever happen...) - return(0); - prev=cur; - cur=prev->next; - x++; - } - - savecheats=1; - RebuildSubCheats(); - return(1); -} - -void FCEU_ApplyPeriodicCheats(void) -{ - struct CHEATF *cur=cheats; - if(!cur) return; - - for(;;) - { - if(cur->status && !(cur->type)) - if(CheatRPtrs[cur->addr>>10]) - CheatRPtrs[cur->addr>>10][cur->addr]=cur->val; - if(cur->next) - cur=cur->next; - else - break; - } -} - - -void FCEUI_ListCheats(int (*callb)(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data), void *data) -{ - struct CHEATF *next=cheats; - - while(next) - { - if(!callb(next->name,next->addr,next->val,next->compare,next->status,next->type,data)) break; - next=next->next; - } -} - -int FCEUI_GetCheat(uint32 which, char **name, uint32 *a, uint8 *v, int *compare, int *s, int *type) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - if(name) - *name=next->name; - if(a) - *a=next->addr; - if(v) - *v=next->val; - if(s) - *s=next->status; - if(compare) - *compare=next->compare; - if(type) - *type=next->type; - return(1); - } - next=next->next; - x++; - } - return(0); -} - -static int GGtobin(char c) -{ - static char lets[16]={'A','P','Z','L','G','I','T','Y','E','O','X','U','K','S','V','N'}; - int x; - - for(x=0;x<16;x++) - if(lets[x] == toupper(c)) return(x); - return(0); -} - -/* Returns 1 on success, 0 on failure. Sets *a,*v,*c. */ -int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c) -{ - uint16 A; - uint8 V,C; - uint8 t; - int s; - - A=0x8000; - V=0; - C=0; - - s=strlen(str); - if(s!=6 && s!=8) return(0); - - t=GGtobin(*str++); - V|=(t&0x07); - V|=(t&0x08)<<4; - - t=GGtobin(*str++); - V|=(t&0x07)<<4; - A|=(t&0x08)<<4; - - t=GGtobin(*str++); - A|=(t&0x07)<<4; - //if(t&0x08) return(0); /* 8-character code?! */ - - t=GGtobin(*str++); - A|=(t&0x07)<<12; - A|=(t&0x08); - - t=GGtobin(*str++); - A|=(t&0x07); - A|=(t&0x08)<<8; - - if(s==6) - { - t=GGtobin(*str++); - A|=(t&0x07)<<8; - V|=(t&0x08); - - *a=A; - *v=V; - *c=-1; - return(1); - } - else - { - t=GGtobin(*str++); - A|=(t&0x07)<<8; - C|=(t&0x08); - - t=GGtobin(*str++); - C|=(t&0x07); - C|=(t&0x08)<<4; - - t=GGtobin(*str++); - C|=(t&0x07)<<4; - V|=(t&0x08); - *a=A; - *v=V; - *c=C; - return(1); - } - return(0); -} - -int FCEUI_DecodePAR(const char *str, int *a, int *v, int *c, int *type) -{ - int boo[4]; - if(strlen(str)!=8) return(0); - - sscanf(str,"%02x%02x%02x%02x",boo,boo+1,boo+2,boo+3); - - *c=-1; - - if(1) - { - *a=(boo[3]<<8)|(boo[2]+0x7F); - *v=0; - } - else - { - *v=boo[3]; - *a=boo[2]|(boo[1]<<8); - } - /* Zero-page addressing modes don't go through the normal read/write handlers in FCEU, so - we must do the old hacky method of RAM cheats. - */ - if(*a<0x0100) - *type=0; - else - *type=1; - return(1); -} - -/* name can be NULL if the name isn't going to be changed. */ -/* same goes for a, v, and s(except the values of each one must be <0) */ - -int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int c, int s, int type) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - if(name) - { - char *t; - if((t=(char *)realloc(next->name, strlen(name)+1))) - { - next->name=t; - strcpy(next->name,name); - } - else - return(0); - } - if(a>=0) - next->addr=a; - if(v>=0) - next->val=v; - if(s>=0) - next->status=s; - if(c>=-1) - next->compare=c; - next->type=type; - - savecheats=1; - RebuildSubCheats(); - - return(1); - } - next=next->next; - x++; - } - return(0); -} - -/* Convenience function. */ -int FCEUI_ToggleCheat(uint32 which) -{ - struct CHEATF *next=cheats; - uint32 x=0; - - while(next) - { - if(x==which) - { - next->status=!next->status; - savecheats=1; - RebuildSubCheats(); - return(next->status); - } - next=next->next; - x++; - } - - return(-1); -} - -static int InitCheatComp(void) -{ - uint32 x; - - CheatComp=(uint16*)FCEU_dmalloc(65536*sizeof(uint16)); - if(!CheatComp) - { - CheatMemErr(); - return(0); - } - for(x=0;x<65536;x++) - CheatComp[x]=CHEATC_NONE; - - return(1); -} - -void FCEUI_CheatSearchSetCurrentAsOriginal(void) -{ - uint32 x; - - if(!CheatComp) - { - if(InitCheatComp()) - { - CheatMemErr(); - return; - } - } - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatRPtrs[x>>10]) - CheatComp[x]=CheatRPtrs[x>>10][x]; - else - CheatComp[x]|=CHEATC_NONE; - } -} - -void FCEUI_CheatSearchShowExcluded(void) -{ - uint32 x; - - for(x=0x000;x<0x10000;x++) - CheatComp[x]&=~CHEATC_EXCLUDED; -} - - -int32 FCEUI_CheatSearchGetCount(void) -{ - uint32 x,c=0; - - if(CheatComp) - { - for(x=0x0000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - c++; - } - - return c; -} -/* This function will give the initial value of the search and the current value at a location. */ - -void FCEUI_CheatSearchGet(int (*callb)(uint32 a, uint8 last, uint8 current, void *data),void *data) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - CheatMemErr(); - return; - } - - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - if(!callb(x,CheatComp[x],CheatRPtrs[x>>10][x],data)) - break; -} - -void FCEUI_CheatSearchGetRange(uint32 first, uint32 last, int (*callb)(uint32 a, uint8 last, uint8 current)) -{ - uint32 x; - uint32 in=0; - - if(!CheatComp) - { - if(!InitCheatComp()) - CheatMemErr(); - return; - } - - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW) && CheatRPtrs[x>>10]) - { - if(in>=first) - if(!callb(x,CheatComp[x],CheatRPtrs[x>>10][x])) - break; - in++; - if(in>last) return; - } -} - -void FCEUI_CheatSearchBegin(void) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - { - CheatMemErr(); - return; - } - } - for(x=0;x<0x10000;x++) - { - if(CheatRPtrs[x>>10]) - CheatComp[x]=CheatRPtrs[x>>10][x]; - else - CheatComp[x]=CHEATC_NONE; - } -} - - -static int INLINE CAbs(int x) -{ - if(x<0) - return(0-x); - return x; -} - -void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2) -{ - uint32 x; - - if(!CheatComp) - { - if(!InitCheatComp()) - { - CheatMemErr(); - return; - } - } - - - if(!type) // Change to a specific value. - { - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]==v1 && CheatRPtrs[x>>10][x]==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==1) // Search for relative change(between values). - { - for(x=0;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]==v1 && CAbs(CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==2) // Purely relative change. - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CAbs(CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - } - else if(type==3) // Any change. - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]!=CheatRPtrs[x>>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==4) // new value = known - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatRPtrs[x>>10][x]==v1) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==5) // new value greater than - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==6) // new value less than - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if(CheatComp[x]>CheatRPtrs[x>>10][x]) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==7) // new value greater than by known value - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if((CheatRPtrs[x>>10][x]-CheatComp[x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } - else if(type==8) // new value less than by known value - { - for(x=0x000;x<0x10000;x++) - if(!(CheatComp[x]&CHEATC_NOSHOW)) - { - if((CheatComp[x]-CheatRPtrs[x>>10][x])==v2) - { - - } - else - CheatComp[x]|=CHEATC_EXCLUDED; - } - - } -} - -int FCEU_CheatGetByte(uint32 A) -{ - // if(CheatRPtrs[A>>10]) - // return CheatRPtrs[A>>10][A]; //adelikat-commenting this stuff out so that lua can see frozen addresses, I hope this doesn't bork stuff. - /*else*/ if(A < 0x10000) - return ARead[A](A); - else - return 0; -} - -void FCEU_CheatSetByte(uint32 A, uint8 V) -{ - if(CheatRPtrs[A>>10]) - CheatRPtrs[A>>10][A]=V; - else if(A < 0x10000) - BWrite[A](A, V); -} - -void UpdateFrozenList(void) -{ - //The purpose of this function is to keep an up to date list of addresses that are currently frozen - //and make these accessible to other dialogs that deal with memory addresses such as - //memwatch, hex editor, ramfilter, etc. - - int x; - FrozenAddresses.clear(); //Clear vector and repopulate - for(x=0;x Connect -* Connect -> Compare {('||' | '&&') Compare} -* Compare -> Sum {('==' | '!=' | '<=' | '>=' | '<' | '>') Sum} -* Sum -> Product {('+' | '-') Product} -* Product -> Primitive {('*' | '/') Primitive} -* Primitive -> Number | Address | Register | Flag | PC Bank | '(' Connect ')' -* Number -> '#' [1-9A-F]* -* Address -> '$' [1-9A-F]* | '$' '[' Connect ']' -* Register -> 'A' | 'X' | 'Y' | 'P' -* Flag -> 'N' | 'C' | 'Z' | 'I' | 'B' | 'V' -* PC Bank -> 'K' -* Data Bank -> 'T' -*/ - -#include "types.h" -#include "conddebug.h" -#include "utils/memory.h" - -#include -#include -#include -#include -#include - -// hack: this address is used by 'T' condition -uint16 addressOfTheLastAccessedData = 0; -// Next non-whitespace character in string -char next; - -int ishex(char c) -{ - return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); -} - -void scan(const char** str) -{ - do - { - next = **str; - (*str)++; - } while (isspace(next)); -} - -// Frees a condition and all of it's sub conditions -void freeTree(Condition* c) -{ - if (c->lhs) freeTree(c->lhs); - if (c->rhs) freeTree(c->rhs); - - free(c); -} - -// Generic function to handle all infix operators but the last one in the precedence hierarchy. : '(' E ')' -Condition* InfixOperator(const char** str, Condition(*nextPart(const char**)), int(*operators)(const char**)) -{ - Condition* t = nextPart(str); - Condition* t1; - Condition* mid; - int op; - - while ((op = operators(str))) - { - scan(str); - - t1 = nextPart(str); - - if (t1 == 0) - { - if(t) - freeTree(t); - return 0; - } - - mid = (Condition*)FCEU_dmalloc(sizeof(Condition)); - if (!mid) - return NULL; - memset(mid, 0, sizeof(Condition)); - - mid->lhs = t; - mid->rhs = t1; - mid->op = op; - - t = mid; - } - - return t; -} - -// Generic handler for two-character operators -int TwoCharOperator(const char** str, char c1, char c2, int op) -{ - if (next == c1 && **str == c2) - { - scan(str); - return op; - } - else - { - return 0; - } -} - -// Determines if a character is a flag -int isFlag(char c) -{ - return c == 'N' || c == 'I' || c == 'C' || c == 'V' || c == 'Z' || c == 'B' || c == 'U' || c == 'D'; -} - -// Determines if a character is a register -int isRegister(char c) -{ - return c == 'A' || c == 'X' || c == 'Y' || c == 'P'; -} - -// Determines if a character is for PC bank -int isPCBank(char c) -{ - return c == 'K'; -} - -// Determines if a character is for Data bank -int isDataBank(char c) -{ - return c == 'T'; -} - -// Reads a hexadecimal number from str -int getNumber(unsigned int* number, const char** str) -{ -// char buffer[5]; - - if (sscanf(*str, "%X", number) == EOF || *number > 0xFFFF) - { - return 0; - } - -// Older, inferior version which doesn't work with leading zeros -// sprintf(buffer, "%X", *number); -// *str += strlen(buffer); - while (ishex(**str)) (*str)++; - scan(str); - - return 1; -} - -Condition* Connect(const char** str); - -// Handles the following part of the grammar: '(' E ')' -Condition* Parentheses(const char** str, Condition* c, char openPar, char closePar) -{ - if (next == openPar) - { - scan(str); - - c->lhs = Connect(str); - - if (!c) return 0; - - if (next == closePar) - { - scan(str); - return c; - } - else - { - return 0; - } - } - - return 0; -} - -/* -* Check for primitives -* Flags, Registers, Numbers, Addresses and parentheses -*/ -Condition* Primitive(const char** str, Condition* c) -{ - if (isFlag(next)) /* Flags */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_FLAG; - c->value1 = next; - } - else - { - c->type2 = TYPE_FLAG; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isRegister(next)) /* Registers */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_REG; - c->value1 = next; - } - else - { - c->type2 = TYPE_REG; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isPCBank(next)) /* PC Bank */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_PC_BANK; - c->value1 = next; - } - else - { - c->type2 = TYPE_PC_BANK; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (isDataBank(next)) /* Data Bank */ - { - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_DATA_BANK; - c->value1 = next; - } - else - { - c->type2 = TYPE_DATA_BANK; - c->value2 = next; - } - - scan(str); - - return c; - } - else if (next == '#') /* Numbers */ - { - unsigned int number = 0; - if (!getNumber(&number, str)) - { - return 0; - } - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_NUM; - c->value1 = number; - } - else - { - c->type2 = TYPE_NUM; - c->value2 = number; - } - - return c; - } - else if (next == '$') /* Addresses */ - { - if ((**str >= '0' && **str <= '9') || (**str >= 'A' && **str <= 'F')) /* Constant addresses */ - { - unsigned int number = 0; - if (!getNumber(&number, str)) - { - return 0; - } - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_ADDR; - c->value1 = number; - } - else - { - c->type2 = TYPE_ADDR; - c->value2 = number; - } - - return c; - } - else if (**str == '[') /* Dynamic addresses */ - { - scan(str); - Parentheses(str, c, '[', ']'); - - if (c->type1 == TYPE_NO) - { - c->type1 = TYPE_ADDR; - } - else - { - c->type2 = TYPE_ADDR; - } - - return c; - } - else - { - return 0; - } - } - else if (next == '(') - { - return Parentheses(str, c, '(', ')'); - } - - return 0; -} - -/* Handle * and / operators */ -Condition* Term(const char** str) -{ - Condition* t; - Condition* t1; - Condition* mid; - - t = (Condition*)FCEU_dmalloc(sizeof(Condition)); - if (!t) - return NULL; - - memset(t, 0, sizeof(Condition)); - - if (!Primitive(str, t)) - { - freeTree(t); - return 0; - } - - while (next == '*' || next == '/') - { - int op = next == '*' ? OP_MULT : OP_DIV; - - scan(str); - - if (!(t1 = (Condition*)FCEU_dmalloc(sizeof(Condition)))) - return NULL; - - memset(t1, 0, sizeof(Condition)); - - if (!Primitive(str, t1)) - { - freeTree(t); - freeTree(t1); - return 0; - } - - if (!(mid = (Condition*)FCEU_dmalloc(sizeof(Condition)))) - return NULL; - - memset(mid, 0, sizeof(Condition)); - - mid->lhs = t; - mid->rhs = t1; - mid->op = op; - - t = mid; - } - - return t; -} - -/* Check for + and - operators */ -int SumOperators(const char** str) -{ - switch (next) - { - case '+': return OP_PLUS; - case '-': return OP_MINUS; - default: return OP_NO; - } -} - -/* Handle + and - operators */ -Condition* Sum(const char** str) -{ - return InfixOperator(str, Term, SumOperators); -} - -/* Check for <=, =>, ==, !=, > and < operators */ -int CompareOperators(const char** str) -{ - int val = TwoCharOperator(str, '=', '=', OP_EQ); - if (val) return val; - - val = TwoCharOperator(str, '!', '=', OP_NE); - if (val) return val; - - val = TwoCharOperator(str, '>', '=', OP_GE); - if (val) return val; - - val = TwoCharOperator(str, '<', '=', OP_LE); - if (val) return val; - - val = next == '>' ? OP_G : 0; - if (val) return val; - - val = next == '<' ? OP_L : 0; - if (val) return val; - - return OP_NO; -} - -/* Handle <=, =>, ==, !=, > and < operators */ -Condition* Compare(const char** str) -{ - return InfixOperator(str, Sum, CompareOperators); -} - -/* Check for || or && operators */ -int ConnectOperators(const char** str) -{ - int val = TwoCharOperator(str, '|', '|', OP_OR); - if(val) return val; - - val = TwoCharOperator(str, '&', '&', OP_AND); - if(val) return val; - - return OP_NO; -} - -/* Handle || and && operators */ -Condition* Connect(const char** str) -{ - return InfixOperator(str, Compare, ConnectOperators); -} - -/* Root of the parser generator */ -Condition* generateCondition(const char* str) -{ - Condition* c; - - scan(&str); - c = Connect(&str); - - if (!c || next != 0) return 0; - else return c; -} diff --git a/branches/sdl2/src/conddebug.h b/branches/sdl2/src/conddebug.h deleted file mode 100644 index 92ea6334..00000000 --- a/branches/sdl2/src/conddebug.h +++ /dev/null @@ -1,65 +0,0 @@ -/* FCEUXD SP - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2005 Sebastian Porst - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef CONDDEBUG_H -#define CONDDEBUG_H - -#define TYPE_NO 0 -#define TYPE_REG 1 -#define TYPE_FLAG 2 -#define TYPE_NUM 3 -#define TYPE_ADDR 4 -#define TYPE_PC_BANK 5 -#define TYPE_DATA_BANK 6 - -#define OP_NO 0 -#define OP_EQ 1 -#define OP_NE 2 -#define OP_GE 3 -#define OP_LE 4 -#define OP_G 5 -#define OP_L 6 -#define OP_PLUS 7 -#define OP_MINUS 8 -#define OP_MULT 9 -#define OP_DIV 10 -#define OP_OR 11 -#define OP_AND 12 - -extern uint16 addressOfTheLastAccessedData; -//mbg merge 7/18/06 turned into sane c++ -struct Condition -{ - Condition* lhs; - Condition* rhs; - - unsigned int type1; - unsigned int value1; - - unsigned int op; - - unsigned int type2; - unsigned int value2; -}; - -void freeTree(Condition* c); -Condition* generateCondition(const char* str); - -#endif diff --git a/branches/sdl2/src/config.cpp b/branches/sdl2/src/config.cpp deleted file mode 100644 index de66a1ec..00000000 --- a/branches/sdl2/src/config.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/// \file -/// \brief Contains methods related to the build configuration - -#include "types.h" -#include "version.h" -#include "fceu.h" -#include "driver.h" -#include "utils/memory.h" - -#include -#include -#include - -static char *aboutString = 0; - -// returns a string suitable for use in an aboutbox -char *FCEUI_GetAboutString() { - const char *aboutTemplate = - FCEU_NAME_AND_VERSION "\n\n" - "Administrators:\n" - "zeromus, adelikat, AnS\n\n" - "Current Contributors:\n" - "punkrockguy318 (Lukas Sabota)\n" - "CaH4e3, gocha, xhainingx, feos\n" - "\n" - "FCEUX 2.0:\n" - "mz, nitsujrehtona, SP, Ugly Joe,\n" - "Plombo, qeed, QFox, Shinydoofy\n" - "ugetab, Acmlm, DWEdit\n" - "\n" - "Previous versions:\n" - "FCE - Bero\n" - "FCEU - Xodnizel\n" - "FCEU XD - Bbitmaster & Parasyte\n" - "FCEU XD SP - Sebastian Porst\n" - "FCEU MM - CaH4e3\n" - "FCEU TAS - blip & nitsuja\n" - "FCEU TAS+ - Luke Gustafson\n" - "\n" - "FCEUX is dedicated to the fallen heroes\n" - "of NES emulation. In Memoriam --\n" - "ugetab\n" - "\n" - __TIME__ " " __DATE__ "\n"; - - if(aboutString) return aboutString; - - const char *compilerString = FCEUD_GetCompilerString(); - - //allocate the string and concatenate the template with the compiler string - if (!(aboutString = (char*)FCEU_dmalloc(strlen(aboutTemplate) + strlen(compilerString) + 1))) - return NULL; - - sprintf(aboutString,"%s%s",aboutTemplate,compilerString); - return aboutString; -} diff --git a/branches/sdl2/src/config.h b/branches/sdl2/src/config.h deleted file mode 100644 index e69de29b..00000000 diff --git a/branches/sdl2/src/debug.cpp b/branches/sdl2/src/debug.cpp deleted file mode 100644 index 2f85dbb7..00000000 --- a/branches/sdl2/src/debug.cpp +++ /dev/null @@ -1,800 +0,0 @@ -/// \file -/// \brief Implements core debugging facilities -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "cart.h" -#include "ines.h" -#include "debug.h" -#include "driver.h" -#include "ppu.h" - -#include "x6502abbrev.h" - -#include -#include - -unsigned int debuggerPageSize = 14; -int vblankScanLines = 0; //Used to calculate scanlines 240-261 (vblank) -int vblankPixel = 0; //Used to calculate the pixels in vblank - -int offsetStringToInt(unsigned int type, const char* offsetBuffer) -{ - int offset = -1; - - if (sscanf(offsetBuffer,"%4X",&offset) == EOF) - { - return -1; - } - - if (type & BT_P) - { - return offset & 0x3FFF; - } - else if (type & BT_S) - { - return offset & 0x00FF; - } - else // BT_C - { - if (GameInfo->type == GIT_NSF) { //NSF Breakpoint keywords - if (strcmp(offsetBuffer,"LOAD") == 0) return (NSFHeader.LoadAddressLow | (NSFHeader.LoadAddressHigh<<8)); - if (strcmp(offsetBuffer,"INIT") == 0) return (NSFHeader.InitAddressLow | (NSFHeader.InitAddressHigh<<8)); - if (strcmp(offsetBuffer,"PLAY") == 0) return (NSFHeader.PlayAddressLow | (NSFHeader.PlayAddressHigh<<8)); - } - else if (GameInfo->type == GIT_FDS) { //FDS Breakpoint keywords - if (strcmp(offsetBuffer,"NMI1") == 0) return (GetMem(0xDFF6) | (GetMem(0xDFF7)<<8)); - if (strcmp(offsetBuffer,"NMI2") == 0) return (GetMem(0xDFF8) | (GetMem(0xDFF9)<<8)); - if (strcmp(offsetBuffer,"NMI3") == 0) return (GetMem(0xDFFA) | (GetMem(0xDFFB)<<8)); - if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xDFFC) | (GetMem(0xDFFD)<<8)); - if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xDFFE) | (GetMem(0xDFFF)<<8)); - } - else { //NES Breakpoint keywords - if ((strcmp(offsetBuffer,"NMI") == 0) || (strcmp(offsetBuffer,"VBL") == 0)) return (GetMem(0xFFFA) | (GetMem(0xFFFB)<<8)); - if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xFFFC) | (GetMem(0xFFFD)<<8)); - if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xFFFE) | (GetMem(0xFFFF)<<8)); - } - } - - return offset; -} - -// Returns the value of a given type or register - -int getValue(int type) -{ - switch (type) - { - case 'A': return _A; - case 'X': return _X; - case 'Y': return _Y; - case 'N': return _P & N_FLAG ? 1 : 0; - case 'V': return _P & V_FLAG ? 1 : 0; - case 'U': return _P & U_FLAG ? 1 : 0; - case 'B': return _P & B_FLAG ? 1 : 0; - case 'D': return _P & D_FLAG ? 1 : 0; - case 'I': return _P & I_FLAG ? 1 : 0; - case 'Z': return _P & Z_FLAG ? 1 : 0; - case 'C': return _P & C_FLAG ? 1 : 0; - case 'P': return _PC; - } - - return 0; -} - - -/** -* Checks whether a breakpoint condition is syntactically valid -* and creates a breakpoint condition object if everything's OK. -* -* @param condition Condition to parse -* @param num Number of the breakpoint in the BP list the condition belongs to -* @return 0 in case of an error; 2 if everything went fine -**/ -int checkCondition(const char* condition, int num) -{ - const char* b = condition; - - // Check if the condition isn't just all spaces. - - int onlySpaces = 1; - - while (*b) - { - if (*b != ' ') - { - onlySpaces = 0; - break; - } - - ++b; - } - - - // If there's an actual condition create the BP condition object now - - if (*condition && !onlySpaces) - { - Condition* c = generateCondition(condition); - - // Remove the old breakpoint condition before adding a new condition. - if (watchpoint[num].cond) - { - freeTree(watchpoint[num].cond); - free(watchpoint[num].condText); - watchpoint[num].cond = 0; - watchpoint[num].condText = 0; - } - - // If the creation of the BP condition object was succesful - // the condition is apparently valid. It can be added to the - // breakpoint now. - - if (c) - { - watchpoint[num].cond = c; - watchpoint[num].condText = (char*)malloc(strlen(condition) + 1); - if (!watchpoint[num].condText) - return 0; - strcpy(watchpoint[num].condText, condition); - } - else - { - watchpoint[num].cond = 0; - } - - return watchpoint[num].cond == 0 ? 2 : 0; - } - else - { - // Remove the old breakpoint condition - if (watchpoint[num].cond) - { - freeTree(watchpoint[num].cond); - free(watchpoint[num].condText); - watchpoint[num].cond = 0; - watchpoint[num].condText = 0; - } - return 0; - } -} - -/** -* Adds a new breakpoint. -* -* @param hwndDlg Handle of the debugger window -* @param num Number of the breakpoint -* @param -**/ -unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable) -{ - // Finally add breakpoint to the list - watchpoint[num].address = start; - watchpoint[num].endaddress = 0; - - // Optional end address found - if (end != -1) - { - watchpoint[num].endaddress = end; - } - - // Get the breakpoint flags - watchpoint[num].flags = 0; - if (enable) watchpoint[num].flags|=WP_E; - if (type & WP_R) watchpoint[num].flags|=WP_R; - if (type & WP_F) watchpoint[num].flags|=WP_F; - if (type & WP_W) watchpoint[num].flags|=WP_W; - if (type & WP_X) watchpoint[num].flags|=WP_X; - if (type & BT_P) { - watchpoint[num].flags|=BT_P; - watchpoint[num].flags&=~WP_X; //disable execute flag! - } - if (type & BT_S) { - watchpoint[num].flags|=BT_S; - watchpoint[num].flags&=~WP_X; //disable execute flag! - } - - if (watchpoint[num].desc) - free(watchpoint[num].desc); - - watchpoint[num].desc = (char*)malloc(strlen(name) + 1); - strcpy(watchpoint[num].desc, name); - - return checkCondition(condition, num); -} - -int GetPRGAddress(int A){ - int result; - if(A > 0xFFFF) - return -1; - result = &Page[A>>11][A]-PRGptr[0]; - if((result > (int)PRGsize[0]) || (result < 0)) - return -1; - else - return result; -} - -/** -* Returns the bank for a given offset. -* Technically speaking this function does not calculate the actual bank -* where the offset resides but the 0x4000 bytes large chunk of the ROM of the offset. -* -* @param offs The offset -* @return The bank of that offset or -1 if the offset is not part of the ROM. -**/ -int getBank(int offs) -{ - //NSF data is easy to overflow the return on. - //Anything over FFFFF will kill it. - - //GetNesFileAddress doesn't work well with Unif files - int addr = GetNesFileAddress(offs)-16; - - if (GameInfo && GameInfo->type==GIT_NSF) - return addr != -1 ? addr / 0x1000 : -1; - return addr != -1 ? addr / (1< 0xFFFF))return -1; - result = &Page[A>>11][A]-PRGptr[0]; - if((result > (int)(PRGsize[0])) || (result < 0))return -1; - else return result+16; //16 bytes for the header remember -} - -int GetRomAddress(int A){ - int i; - uint8 *p = GetNesPRGPointer(A-=16); - for(i = 16;i < 32;i++){ - if((&Page[i][i<<11] <= p) && (&Page[i][(i+1)<<11] > p))break; - } - if(i == 32)return -1; //not found - - return (i<<11) + (p-&Page[i][i<<11]); -} - -uint8 *GetNesPRGPointer(int A){ - return PRGptr[0]+A; -} - -uint8 *GetNesCHRPointer(int A){ - return CHRptr[0]+A; -} - -uint8 GetMem(uint16 A) { - if ((A >= 0x2000) && (A < 0x4000)) { - switch (A&7) { - case 0: return PPU[0]; - case 1: return PPU[1]; - case 2: return PPU[2]|(PPUGenLatch&0x1F); - case 3: return PPU[3]; - case 4: return SPRAM[PPU[3]]; - case 5: return XOffset; - case 6: return RefreshAddr&0xFF; - case 7: return VRAMBuffer; - } - } else if ((A >= 0x4000) && (A < 0x5000)) return 0xFF; // AnS: changed the range, so MMC5 ExRAM can be watched in the Hexeditor - if (GameInfo) return ARead[A](A); //adelikat: 11/17/09: Prevent crash if this is called with no game loaded. - else return 0; -} - -uint8 GetPPUMem(uint8 A) { - uint16 tmp=RefreshAddr&0x3FFF; - - if (tmp<0x2000) return VPage[tmp>>10][tmp]; - if (tmp>=0x3F00) return PALRAM[tmp&0x1F]; - return vnapage[(tmp>>10)&0x3][tmp&0x3FF]; -} - -//--------------------- - -// Evaluates a condition -int evaluate(Condition* c) -{ - int f = 0; - - int value1, value2; - - if (c->lhs) - { - value1 = evaluate(c->lhs); - } - else - { - switch(c->type1) - { - case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code - case TYPE_NUM: value1 = c->value1; break; - default: value1 = getValue(c->value1); break; - } - } - - switch(c->type1) - { - case TYPE_ADDR: value1 = GetMem(value1); break; - case TYPE_PC_BANK: value1 = getBank(_PC); break; - case TYPE_DATA_BANK: value1 = getBank(addressOfTheLastAccessedData); break; - } - - f = value1; - - if (c->op) - { - if (c->rhs) - { - value2 = evaluate(c->rhs); - } - else - { - switch(c->type2) - { - case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code - case TYPE_NUM: value2 = c->value2; break; - default: value2 = getValue(c->type2); break; - } - } - - switch(c->type2) - { - case TYPE_ADDR: value2 = GetMem(value2); break; - case TYPE_PC_BANK: value2 = getBank(_PC); break; - case TYPE_DATA_BANK: value2 = getBank(addressOfTheLastAccessedData); break; - } - - switch (c->op) - { - case OP_EQ: f = value1 == value2; break; - case OP_NE: f = value1 != value2; break; - case OP_GE: f = value1 >= value2; break; - case OP_LE: f = value1 <= value2; break; - case OP_G: f = value1 > value2; break; - case OP_L: f = value1 < value2; break; - case OP_MULT: f = value1 * value2; break; - case OP_DIV: f = value1 / value2; break; - case OP_PLUS: f = value1 + value2; break; - case OP_MINUS: f = value1 - value2; break; - case OP_OR: f = value1 || value2; break; - case OP_AND: f = value1 && value2; break; - } - } - - return f; -} - -int condition(watchpointinfo* wp) -{ - return wp->cond == 0 || evaluate(wp->cond); -} - - -//--------------------- - -volatile int codecount, datacount, undefinedcount; -unsigned char *cdloggerdata; -unsigned int cdloggerdataSize = 0; -static int indirectnext; - -int debug_loggingCD; - -//called by the cpu to perform logging if CDLogging is enabled -void LogCDVectors(int which){ - int j; - j = GetPRGAddress(which); - if(j == -1) return; - - if(!(cdloggerdata[j] & 2)){ - cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } - j++; - - if(!(cdloggerdata[j] & 2)){ - cdloggerdata[j] |= 0x0E; - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } -} - -void LogCDData(uint8 *opcode, uint16 A, int size) { - int i, j; - uint8 memop = 0; - - if((j = GetPRGAddress(_PC)) != -1) - for (i = 0; i < size; i++) { - if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip - cdloggerdata[j+i] |= 1; - cdloggerdata[j+i] |=((_PC+i)>>11)&0x0c; - if(indirectnext)cdloggerdata[j+i] |= 0x10; - codecount++; - if(!(cdloggerdata[j+i] & 2))undefinedcount--; - } - - //log instruction jumped to in an indirect jump - if(opcode[0] == 0x6c) - indirectnext = 1; - else - indirectnext = 0; - - switch (optype[opcode[0]]) { - case 1: - case 4: memop = 0x20; break; - } - - if((j = GetPRGAddress(A)) != -1) { - if(!(cdloggerdata[j] & 2)) { - cdloggerdata[j] |= 2; - cdloggerdata[j] |=(A>>11)&0x0c; - cdloggerdata[j] |= memop; - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } - } -} - -//-----------debugger stuff - -watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over -int iaPC; -uint32 iapoffset; //mbg merge 7/18/06 changed from int -int u; //deleteme -int skipdebug; //deleteme -int numWPs; - -bool break_asap = false; -// for CPU cycles and Instructions counters -uint64 total_cycles_base = 0; -uint64 delta_cycles_base = 0; -bool break_on_cycles = false; -uint64 break_cycles_limit = 0; -uint64 total_instructions = 0; -uint64 delta_instructions = 0; -bool break_on_instructions = false; -uint64 break_instructions_limit = 0; - -static DebuggerState dbgstate; - -DebuggerState &FCEUI_Debugger() { return dbgstate; } - -void ResetDebugStatisticsCounters() -{ - ResetCyclesCounter(); - ResetInstructionsCounter(); -} -void ResetCyclesCounter() -{ - total_cycles_base = delta_cycles_base = timestampbase + (uint64)timestamp; -} -void ResetInstructionsCounter() -{ - total_instructions = delta_instructions = 0; -} -void ResetDebugStatisticsDeltaCounters() -{ - delta_cycles_base = timestampbase + (uint64)timestamp; - delta_instructions = 0; -} -void IncrementInstructionsCounters() -{ - total_instructions++; - delta_instructions++; -} - -void BreakHit(int bp_num, bool force) -{ - if(!force) - { - //check to see whether we fall in any forbid zone - for (int i = 0; i < numWPs; i++) - { - watchpointinfo& wp = watchpoint[i]; - if(!(wp.flags & WP_F) || !(wp.flags & WP_E)) - continue; - - if (condition(&wp)) - { - if (wp.endaddress) { - if( (wp.address <= _PC) && (wp.endaddress >= _PC) ) - return; //forbid - } else { - if(wp.address == _PC) - return; //forbid - } - } - } - } - - FCEUI_SetEmulationPaused(EMULATIONPAUSED_PAUSED); //mbg merge 7/19/06 changed to use EmulationPaused() - -#ifdef WIN32 - FCEUD_DebugBreakpoint(bp_num); -#endif -} - -uint8 StackAddrBackup = X.S; -uint16 StackNextIgnorePC = 0xFFFF; - -///fires a breakpoint -static void breakpoint(uint8 *opcode, uint16 A, int size) { - int i, j; - uint8 brk_type; - uint8 stackop=0; - uint8 stackopstartaddr,stackopendaddr; - - if (break_asap) - { - break_asap = false; - BreakHit(BREAK_TYPE_LUA, true); - } - - if (break_on_cycles && ((timestampbase + (uint64)timestamp - total_cycles_base) > break_cycles_limit)) - BreakHit(BREAK_TYPE_CYCLES_EXCEED, true); - if (break_on_instructions && (total_instructions > break_instructions_limit)) - BreakHit(BREAK_TYPE_INSTRUCTIONS_EXCEED, true); - - //if the current instruction is bad, and we are breaking on bad opcodes, then hit the breakpoint - if(dbgstate.badopbreak && (size == 0)) - BreakHit(BREAK_TYPE_BADOP, true); - - //if we're stepping out, track the nest level - if (dbgstate.stepout) { - if (opcode[0] == 0x20) dbgstate.jsrcount++; - else if (opcode[0] == 0x60) { - if (dbgstate.jsrcount) - dbgstate.jsrcount--; - else { - dbgstate.stepout = false; - dbgstate.step = true; - return; - } - } - } - - //if we're stepping, then we'll always want to break - if (dbgstate.step) { - dbgstate.step = false; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - - //if we're running for a scanline, we want to check if we've hit the cycle limit - if (dbgstate.runline) { - uint64 ts = timestampbase; - ts+=timestamp; - int diff = dbgstate.runline_end_time-ts; - if (diff<=0) - { - dbgstate.runline=false; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - } - - //check the step over address and break if we've hit it - if ((watchpoint[64].address == _PC) && (watchpoint[64].flags)) { - watchpoint[64].address = 0; - watchpoint[64].flags = 0; - BreakHit(BREAK_TYPE_STEP, true); - return; - } - - brk_type = opbrktype[opcode[0]] | WP_X; - - switch (opcode[0]) { - //Push Ops - case 0x08: //Fall to next - case 0x48: stackopstartaddr=stackopendaddr=X.S-1; stackop=WP_W; StackAddrBackup = X.S; StackNextIgnorePC=_PC+1; break; - //Pull Ops - case 0x28: //Fall to next - case 0x68: stackopstartaddr=stackopendaddr=X.S+1; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=_PC+1; break; - //JSR (Includes return address - 1) - case 0x20: stackopstartaddr=stackopendaddr=X.S-1; stackop=WP_W; StackAddrBackup = X.S; StackNextIgnorePC=(opcode[1]|opcode[2]<<8); break; - //RTI (Includes processor status, and exact return address) - case 0x40: stackopstartaddr=X.S+1; stackopendaddr=X.S+3; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=(GetMem(X.S+2|0x0100)|GetMem(X.S+3|0x0100)<<8); break; - //RTS (Includes return address - 1) - case 0x60: stackopstartaddr=X.S+1; stackopendaddr=X.S+2; stackop=WP_R; StackAddrBackup = X.S; StackNextIgnorePC=(GetMem(stackopstartaddr|0x0100)|GetMem(stackopendaddr|0x0100)<<8)+1; break; - } - - for (i = 0; i < numWPs; i++) - { -// ################################## Start of SP CODE ########################### - if ((watchpoint[i].flags & WP_E) && condition(&watchpoint[i])) - { -// ################################## End of SP CODE ########################### - if (watchpoint[i].flags & BT_P) - { - // PPU Mem breaks - if ((watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 7)) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= RefreshAddr) && (watchpoint[i].endaddress >= RefreshAddr)) - BreakHit(i); - } else - { - if (watchpoint[i].address == RefreshAddr) - BreakHit(i); - } - } - } else if (watchpoint[i].flags & BT_S) - { - // Sprite Mem breaks - if ((watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 4)) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= PPU[3]) && (watchpoint[i].endaddress >= PPU[3])) - BreakHit(i); - } else - { - if (watchpoint[i].address == PPU[3]) - BreakHit(i); - } - } else if ((watchpoint[i].flags & WP_W) && (A == 0x4014)) - { - // Sprite DMA! :P - BreakHit(i); - } - } else - { - // CPU mem breaks - if ((watchpoint[i].flags & brk_type)) - { - if (watchpoint[i].endaddress) - { - if (((watchpoint[i].flags & (WP_R | WP_W)) && (watchpoint[i].address <= A) && (watchpoint[i].endaddress >= A)) || - ((watchpoint[i].flags & WP_X) && (watchpoint[i].address <= _PC) && (watchpoint[i].endaddress >= _PC))) - BreakHit(i); - } else - { - if (((watchpoint[i].flags & (WP_R | WP_W)) && (watchpoint[i].address == A)) || - ((watchpoint[i].flags & WP_X) && (watchpoint[i].address == _PC))) - BreakHit(i); - } - } else - { - // brk_type independant coding - if (stackop > 0) - { - // Announced stack mem breaks - // PHA, PLA, PHP, and PLP affect the stack data. - // TXS and TSX only deal with the pointer. - if (watchpoint[i].flags & stackop) - { - for (j = (stackopstartaddr|0x0100); j <= (stackopendaddr|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } - if (StackNextIgnorePC == _PC) - { - // Used to make it ignore the unannounced stack code one time - StackNextIgnorePC = 0xFFFF; - } else - { - if ((X.S < StackAddrBackup) && (stackop==0)) - { - // Unannounced stack mem breaks - // Pushes to stack - if (watchpoint[i].flags & WP_W) - { - for (j = (X.S|0x0100); j < (StackAddrBackup|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } else if ((StackAddrBackup < X.S) && (stackop==0)) - { - // Pulls from stack - if (watchpoint[i].flags & WP_R) - { - for (j = (StackAddrBackup|0x0100); j < (X.S|0x0100); j++) - { - if (watchpoint[i].endaddress) - { - if ((watchpoint[i].address <= j) && (watchpoint[i].endaddress >= j)) - BreakHit(i); - } else - { - if (watchpoint[i].address == j) - BreakHit(i); - } - } - } - } - } - - } - } -// ################################## Start of SP CODE ########################### - } -// ################################## End of SP CODE ########################### - } - - //Update the stack address with the current one, now that changes have registered. - StackAddrBackup = X.S; -} -//bbit edited: this is the end of the inserted code - -void DebugCycle() -{ - uint8 opcode[3] = {0}; - uint16 A = 0; - int size; - - if (scanline == 240) - { - vblankScanLines = (PAL?int((double)timestamp / ((double)341 / (double)3.2)):timestamp / 114); //114 approximates the number of timestamps per scanline during vblank. Approx 2508. NTSC: (341 / 3.0) PAL: (341 / 3.2). Uses (3.? * cpu_cycles) / 341.0, and assumes 1 cpu cycle. - if (vblankScanLines) vblankPixel = 341 / vblankScanLines; //341 pixels per scanline - //FCEUI_printf("vbPixel = %d",vblankPixel); //Debug - //FCEUI_printf("ts: %d line: %d\n", timestamp, vblankScanLines); //Debug - } - else - vblankScanLines = 0; - - if (GameInfo->type==GIT_NSF) - { - if ((_PC >= 0x3801) && (_PC <= 0x3824)) return; - } - - opcode[0] = GetMem(_PC); - size = opsize[opcode[0]]; - switch (size) - { - case 2: - opcode[1] = GetMem(_PC + 1); - break; - case 3: - opcode[1] = GetMem(_PC + 1); - opcode[2] = GetMem(_PC + 2); - break; - } - - switch (optype[opcode[0]]) - { - case 0: break; - case 1: - A = (opcode[1] + _X) & 0xFF; - A = GetMem(A) | (GetMem(A + 1) << 8); - break; - case 2: A = opcode[1]; break; - case 3: A = opcode[1] | (opcode[2] << 8); break; - case 4: A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1) << 8)) + _Y; break; - case 5: A = opcode[1] + _X; break; - case 6: A = (opcode[1] | (opcode[2] << 8)) + _Y; break; - case 7: A = (opcode[1] | (opcode[2] << 8)) + _X; break; - case 8: A = opcode[1] + _Y; break; - } - addressOfTheLastAccessedData = A; - - if (numWPs || dbgstate.step || dbgstate.runline || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak || break_on_cycles || break_on_instructions || break_asap) - breakpoint(opcode, A, size); - - if(debug_loggingCD) - LogCDData(opcode, A, size); - -#ifdef WIN32 - //This needs to be windows only or else the linux build system will fail since logging is declared in a - //windows source file - FCEUD_TraceInstruction(opcode, size); -#endif - -} diff --git a/branches/sdl2/src/debug.h b/branches/sdl2/src/debug.h deleted file mode 100644 index 09c10177..00000000 --- a/branches/sdl2/src/debug.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - -#include "conddebug.h" -#include "git.h" -#include "nsf.h" - -//watchpoint stuffs -#define WP_E 0x01 //watchpoint, enable -#define WP_W 0x02 //watchpoint, write -#define WP_R 0x04 //watchpoint, read -#define WP_X 0x08 //watchpoint, execute -#define WP_F 0x10 //watchpoint, forbid - -#define BT_C 0x00 //break type, cpu mem -#define BT_P 0x20 //break type, ppu mem -#define BT_S 0x40 //break type, sprite mem - -#define BREAK_TYPE_STEP -1 -#define BREAK_TYPE_BADOP -2 -#define BREAK_TYPE_CYCLES_EXCEED -3 -#define BREAK_TYPE_INSTRUCTIONS_EXCEED -4 -#define BREAK_TYPE_LUA -5 - -//opbrktype is used to grab the breakpoint type that each instruction will cause. -//WP_X is not used because ALL opcodes will have the execute bit set. -static const uint8 opbrktype[256] = { - /*0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F*/ -/*0x00*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x10*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x20*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x30*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x40*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x50*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x60*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x70*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x80*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, 0, 0, 0, WP_W, WP_W, WP_W, 0, -/*0x90*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, WP_W, 0, 0, 0, WP_W, 0, 0, -/*0xA0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xB0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xC0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xD0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0xE0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xF0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0 -}; - - -typedef struct { - uint16 address; - uint16 endaddress; - uint8 flags; -// ################################## Start of SP CODE ########################### - - Condition* cond; - char* condText; - char* desc; - -// ################################## End of SP CODE ########################### -} watchpointinfo; - -//mbg merge 7/18/06 had to make this extern -extern watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over - -int getBank(int offs); -int GetNesFileAddress(int A); -int GetPRGAddress(int A); -int GetRomAddress(int A); -//int GetEditHex(HWND hwndDlg, int id); -uint8 *GetNesPRGPointer(int A); -uint8 *GetNesCHRPointer(int A); -void KillDebugger(); -uint8 GetMem(uint16 A); -uint8 GetPPUMem(uint8 A); - -//---------CDLogger -void LogCDVectors(int which); -void LogCDData(uint8 *opcode, uint16 A, int size); -extern volatile int codecount, datacount, undefinedcount; -extern unsigned char *cdloggerdata; -extern unsigned int cdloggerdataSize; - -extern int debug_loggingCD; -static INLINE void FCEUI_SetLoggingCD(int val) { debug_loggingCD = val; } -static INLINE int FCEUI_GetLoggingCD() { return debug_loggingCD; } -//------- - -//-------tracing -//we're letting the win32 driver handle this ittself for now -//extern int debug_tracing; -//static INLINE void FCEUI_SetTracing(int val) { debug_tracing = val; } -//static INLINE int FCEUI_GetTracing() { return debug_tracing; } -//--------- - -//--------debugger -extern int iaPC; -extern uint32 iapoffset; //mbg merge 7/18/06 changed from int -void DebugCycle(); -void BreakHit(int bp_num, bool force = false); - -extern bool break_asap; -extern uint64 total_cycles_base; -extern uint64 delta_cycles_base; -extern bool break_on_cycles; -extern uint64 break_cycles_limit; -extern uint64 total_instructions; -extern uint64 delta_instructions; -extern bool break_on_instructions; -extern uint64 break_instructions_limit; -extern void ResetDebugStatisticsCounters(); -extern void ResetCyclesCounter(); -extern void ResetInstructionsCounter(); -extern void ResetDebugStatisticsDeltaCounters(); -extern void IncrementInstructionsCounters(); -//------------- - -//internal variables that debuggers will want access to -extern uint8 *vnapage[4],*VPage[8]; -extern uint8 PPU[4],PALRAM[0x20],SPRAM[0x100],VRAMBuffer,PPUGenLatch,XOffset; -extern uint32 RefreshAddr; - -extern int debug_loggingCD; -extern int numWPs; - -///encapsulates the operational state of the debugger core -class DebuggerState { -public: - ///indicates whether the debugger is stepping through a single instruction - bool step; - ///indicates whether the debugger is stepping out of a function call - bool stepout; - ///indicates whether the debugger is running one line - bool runline; - ///target timestamp for runline to stop at - uint64 runline_end_time; - ///indicates whether the debugger should break on bad opcodes - bool badopbreak; - ///counts the nest level of the call stack while stepping out - int jsrcount; - - ///resets the debugger state to an empty, non-debugging state - void reset() { - numWPs = 0; - step = false; - stepout = false; - jsrcount = 0; - } -}; - -extern NSF_HEADER NSFHeader; - -///retrieves the core's DebuggerState -DebuggerState &FCEUI_Debugger(); - -//#define CPU_BREAKPOINT 1 -//#define PPU_BREAKPOINT 2 -//#define SPRITE_BREAKPOINT 4 -//#define READ_BREAKPOINT 8 -//#define WRITE_BREAKPOINT 16 -//#define EXECUTE_BREAKPOINT 32 - -int offsetStringToInt(unsigned int type, const char* offsetBuffer); -unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable); - -#endif diff --git a/branches/sdl2/src/drawing.cpp b/branches/sdl2/src/drawing.cpp deleted file mode 100644 index 2d64fd82..00000000 --- a/branches/sdl2/src/drawing.cpp +++ /dev/null @@ -1,525 +0,0 @@ -#include "types.h" -#include "fceu.h" -#include "drawing.h" -#include "video.h" -#include "movie.h" -#include "driver.h" - -static uint8 Font6x7[792] = -{ - 6, 0, 0, 0, 0, 0, 0, 0, // 0x20 - Spacebar - 3, 64, 64, 64, 64, 64, 0, 64, - 5, 80, 80, 80, 0, 0, 0, 0, - 6, 80, 80,248, 80,248, 80, 80, - 6, 32,120,160,112, 40,240, 32, - 6, 64,168, 80, 32, 80,168, 16, - 6, 96,144,160, 64,168,144,104, - 3, 64, 64, 0, 0, 0, 0, 0, - 4, 32, 64, 64, 64, 64, 64, 32, - 4, 64, 32, 32, 32, 32, 32, 64, - 6, 0, 80, 32,248, 32, 80, 0, - 6, 0, 32, 32,248, 32, 32, 0, - 3, 0, 0, 0, 0, 0, 64,128, - 5, 0, 0, 0,240, 0, 0, 0, - 3, 0, 0, 0, 0, 0, 0, 64, - 5, 16, 16, 32, 32, 32, 64, 64, - 6,112,136,136,136,136,136,112, // 0x30 - 0 - 6, 32, 96, 32, 32, 32, 32, 32, - 6,112,136, 8, 48, 64,128,248, - 6,112,136, 8, 48, 8,136,112, - 6, 16, 48, 80,144,248, 16, 16, - 6,248,128,128,240, 8, 8,240, - 6, 48, 64,128,240,136,136,112, - 6,248, 8, 16, 16, 32, 32, 32, - 6,112,136,136,112,136,136,112, - 6,112,136,136,120, 8, 16, 96, - 3, 0, 0, 64, 0, 0, 64, 0, - 3, 0, 0, 64, 0, 0, 64,128, - 4, 0, 32, 64,128, 64, 32, 0, - 5, 0, 0,240, 0,240, 0, 0, - 4, 0,128, 64, 32, 64,128, 0, - 6,112,136, 8, 16, 32, 0, 32, // 0x3F - ? - 6,112,136,136,184,176,128,112, // 0x40 - @ - 6,112,136,136,248,136,136,136, // 0x41 - A - 6,240,136,136,240,136,136,240, - 6,112,136,128,128,128,136,112, - 6,224,144,136,136,136,144,224, - 6,248,128,128,240,128,128,248, - 6,248,128,128,240,128,128,128, - 6,112,136,128,184,136,136,120, - 6,136,136,136,248,136,136,136, - 4,224, 64, 64, 64, 64, 64,224, - 6, 8, 8, 8, 8, 8,136,112, - 6,136,144,160,192,160,144,136, - 6,128,128,128,128,128,128,248, - 6,136,216,168,168,136,136,136, - 6,136,136,200,168,152,136,136, - 7, 48, 72,132,132,132, 72, 48, - 6,240,136,136,240,128,128,128, - 6,112,136,136,136,168,144,104, - 6,240,136,136,240,144,136,136, - 6,112,136,128,112, 8,136,112, - 6,248, 32, 32, 32, 32, 32, 32, - 6,136,136,136,136,136,136,112, - 6,136,136,136, 80, 80, 32, 32, - 6,136,136,136,136,168,168, 80, - 6,136,136, 80, 32, 80,136,136, - 6,136,136, 80, 32, 32, 32, 32, - 6,248, 8, 16, 32, 64,128,248, - 3,192,128,128,128,128,128,192, - 5, 64, 64, 32, 32, 32, 16, 16, - 3,192, 64, 64, 64, 64, 64,192, - 4, 64,160, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 0, 0, 0,248, - 3,128, 64, 0, 0, 0, 0, 0, - 5, 0, 0, 96, 16,112,144,112, // 0x61 - a - 5,128,128,224,144,144,144,224, - 5, 0, 0,112,128,128,128,112, - 5, 16, 16,112,144,144,144,112, - 5, 0, 0, 96,144,240,128,112, - 5, 48, 64,224, 64, 64, 64, 64, - 5, 0,112,144,144,112, 16,224, - 5,128,128,224,144,144,144,144, - 2,128, 0,128,128,128,128,128, - 4, 32, 0, 32, 32, 32, 32,192, - 5,128,128,144,160,192,160,144, - 2,128,128,128,128,128,128,128, - 6, 0, 0,208,168,168,168,168, - 5, 0, 0,224,144,144,144,144, - 5, 0, 0, 96,144,144,144, 96, - 5, 0, 0,224,144,144,224,128, - 5, 0, 0,112,144,144,112, 16, - 5, 0, 0,176,192,128,128,128, - 5, 0, 0,112,128, 96, 16,224, - 4, 64, 64,224, 64, 64, 64, 32, - 5, 0, 0,144,144,144,144,112, - 5, 0, 0,144,144,144,160,192, - 6, 0, 0,136,136,168,168, 80, - 5, 0, 0,144,144, 96,144,144, - 5, 0,144,144,144,112, 16, 96, - 5, 0, 0,240, 32, 64,128,240, - 4, 32, 64, 64,128, 64, 64, 32, - 3, 64, 64, 64, 64, 64, 64, 64, - 4,128, 64, 64, 32, 64, 64,128, - 6, 0,104,176, 0, 0, 0, 0 -}; - -void DrawTextLineBG(uint8 *dest) -{ - int x,y; - static int otable[7]={81,49,30,17,8,3,0}; - //100,40,15,10,7,5,2}; - for(y=0;y<14;y++) - { - int offs; - - if(y>=7) offs=otable[13-y]; - else offs=otable[y]; - - for(x=offs;x<(256-offs);x++) - { - // Choose the dimmest set of colours and then dim that - dest[y*256+x]=(dest[y*256+x]&0x0F)|0xC0; - } - } -} - - -void DrawMessage(bool beforeMovie) -{ - if(guiMessage.howlong) - { - //don't display movie messages if we're not before the movie - if(beforeMovie && !guiMessage.isMovieMessage) - return; - - uint8 *t; - guiMessage.howlong--; - - if (guiMessage.linesFromBottom > 0) - t=XBuf+FCEU_TextScanlineOffsetFromBottom(guiMessage.linesFromBottom)+1; - else - t=XBuf+FCEU_TextScanlineOffsetFromBottom(20)+1; - - /* - FCEU palette: - $00: [8] unvpalette found in palettes/palettes.h - black, white, black, greyish, redish, bright green, bluish - $80: - nes palette - $C0: - dim version of nes palette - - */ - - if(t>=XBuf) - { - int color = 0x20; - if(guiMessage.howlong <= 40) color = 0x3C; - if(guiMessage.howlong <= 32) color = 0x31; - if(guiMessage.howlong <= 24) color = 0x21; - if(guiMessage.howlong <= 16) color = 0x51; - if(guiMessage.howlong <= 8) color = 0x41; - DrawTextTrans(ClipSidesOffset+t, 256, (uint8 *)guiMessage.errmsg, color+0x80); - } - } - - if(subtitleMessage.howlong) - { - //don't display movie messages if we're not before the movie - if(beforeMovie && !subtitleMessage.isMovieMessage) - return; - - uint8 *tt; - subtitleMessage.howlong--; - tt=XBuf+FCEU_TextScanlineOffsetFromBottom(216); - - if(tt>=XBuf) - { - int color = 0x20; - if(subtitleMessage.howlong == 39) color = 0x38; - if(subtitleMessage.howlong <= 30) color = 0x2C; - if(subtitleMessage.howlong <= 20) color = 0x1C; - if(subtitleMessage.howlong <= 10) color = 0x11; - if(subtitleMessage.howlong <= 5) color = 0x1; - DrawTextTrans(ClipSidesOffset+tt, 256, (uint8 *)subtitleMessage.errmsg, color+0x80); - } - } -} - - - - -static uint8 sstat[2541] = -{ - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83, - 0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x83,0x83,0x83, - 0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x80,0x83, - 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81, - 0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x81,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, - 0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83, - 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83, - 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83, - 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83, - 0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x83,0x80,0x80,0x81,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x80,0x83,0x83,0x81,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x81,0x81,0x81,0x83,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 -}; - - - - - -static uint8 play_slines[]= -{ - 0, 0, 1, - 1, 0, 2, - 2, 0, 3, - 3, 0, 4, - 4, 0, 5, - 5, 0, 6, - 6, 0, 7, - 7, 0, 8, - 8, 0, 7, - 9, 0, 6, - 10, 0, 5, - 11, 0, 4, - 12, 0, 3, - 13, 0, 2, - 14, 0, 1, - 99, -}; - -static uint8 record_slines[]= -{ - 0, 5, 9, - 1, 3, 11, - 2, 2, 12, - 3, 1, 13, - 4, 1, 13, - 5, 0, 14, - 6, 0, 14, - 7, 0, 14, - 8, 0, 14, - 9, 0, 14, - 10, 1, 13, - 11, 1, 13, - 12, 2, 12, - 13, 3, 11, - 14, 5, 9, - 99, -}; - -static uint8 pause_slines[]= -{ - 0, 2, 6, - 1, 2, 6, - 2, 2, 6, - 3, 2, 6, - 4, 2, 6, - 5, 2, 6, - 6, 2, 6, - 7, 2, 6, - 8, 2, 6, - 9, 2, 6, - 10, 2, 6, - 11, 2, 6, - 12, 2, 6, - 13, 2, 6, - 14, 2, 6, - - 0, 9, 13, - 1, 9, 13, - 2, 9, 13, - 3, 9, 13, - 4, 9, 13, - 5, 9, 13, - 6, 9, 13, - 7, 9, 13, - 8, 9, 13, - 9, 9, 13, - 10, 9, 13, - 11, 9, 13, - 12, 9, 13, - 13, 9, 13, - 14, 9, 13, - 99, -}; - -static uint8 no_slines[]= -{ - 99 -}; - -static uint8* sline_icons[4]= -{ - no_slines, - play_slines, - record_slines, - pause_slines -}; - -static void drawstatus(uint8* XBuf, int n, int y, int xofs) -{ - uint8* slines=sline_icons[n]; - int i; - - - XBuf += FCEU_TextScanlineOffsetFromBottom(y) + 240 + 255 + xofs; - for(i=0; slines[i]!=99; i+=3) - { - int y=slines[i]; - uint8* dest=XBuf+(y*256); - int x; - for(x=slines[i+1]; x!=slines[i+2]; ++x) - dest[x]=0; - } - - XBuf -= 255; - for(i=0; slines[i]!=99; i+=3) - { - int y=slines[i]; - uint8* dest=XBuf+(y*256); - int x; - for(x=slines[i+1]; x!=slines[i+2]; ++x) - dest[x]=4; - } -} - -/// this draws the recording icon (play/pause/record) -void FCEU_DrawRecordingStatus(uint8* XBuf) -{ - if(FCEUD_ShowStatusIcon()) - { - bool hasPlayRecIcon = false; - if(FCEUMOV_Mode(MOVIEMODE_RECORD)) - { - drawstatus(XBuf-ClipSidesOffset,2,28,0); - hasPlayRecIcon = true; - } - else if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_FINISHED)) - { - drawstatus(XBuf-ClipSidesOffset,1,28,0); - hasPlayRecIcon = true; - } - - if(FCEUI_EmulationPaused()) - drawstatus(XBuf-ClipSidesOffset,3,28,hasPlayRecIcon?-16:0); - } -} - - -void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur) -{ - uint8 *XBaf; - int z,x,y; - - XBaf=XBuf - 4 + (FSettings.LastSLine-34)*256; - if(XBaf>=XBuf) - for(z=1;z<11;z++) - { - if(nstatus[z%10]) - { - for(y=0;y<13;y++) - for(x=0;x<21;x++) - XBaf[y*256+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; - } else { - for(y=0;y<13;y++) - for(x=0;x<21;x++) - if(sstat[y*21+x+(z-1)*21*12]!=0x83) - XBaf[y*256+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; - - else - XBaf[y*256+x+z*21+z]=(XBaf[y*256+x+z*21+z]&0xF)|0xC0; - } - if(cur==z%10) - { - for(x=0;x<21;x++) - XBaf[x+z*21+z*1]=4; - for(x=1;x<12;x++) - { - XBaf[256*x+z*21+z*1]= - XBaf[256*x+z*21+z*1+20]=4; - } - for(x=0;x<21;x++) - XBaf[12*256+x+z*21+z*1]=4; - } - } -} - -static int FixJoedChar(uint8 ch) -{ - int c = ch - 32; - return (c < 0 || c > 98) ? 0 : c; -} -static int JoedCharWidth(uint8 ch) -{ - return Font6x7[FixJoedChar(ch)*8]; -} - -char target[64][256]; - -void DrawTextTransWH(uint8 *dest, int width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border) -{ - int beginx=2, x=beginx; - int y=2; - - memset(target, 0, 64 * 256); - - assert(width==256); - if (max_w > 256) max_w = 256; - if (max_h > 64) max_h = 64; - - int ch = 0, wid = 0, nx = 0, ny = 0, max_x = x, offs = 0; - int pixel_color; - for(; *textmsg; ++textmsg) - { - if(*textmsg == '\n') - { - // new line - x = beginx; - y += 8; - continue; - } - ch = FixJoedChar(*textmsg); - wid = Font6x7[ch * 8]; - - if ((x + wid) >= (int)width) - { - // wrap to new line - x = beginx; - y += 8; - } - - for(ny = 0; ny < 7; ++ny) - { - uint8 d = Font6x7[ch * 8 + 1 + ny]; - for(nx = 0; nx < wid; ++nx) - { - pixel_color = (d >> (7 - nx)) & 1; - if (pixel_color) - { - if (y + ny >= 62) - { - // Max border is 2, so the max safe y is 62 (since 64 is the max for the target array - goto textoverflow; - } - target[y + ny][x + nx] = 2; - } else - { - target[y + ny][x + nx] = 1; - } - } - } - // proceed to next char - x += wid; - if (max_x < x) - max_x = x; - - } -textoverflow: - - max_x += 2; - if (max_x > width) - max_x = width; - int max_y = y + ny + 2; - if (max_y > 62) - max_y = 62; - - // draw target buffer to screen buffer - for (y = 0; y < max_y; ++y) - { - for (x = 0; x < max_x; ++x) - { - offs = y * width + x; - pixel_color = target[y][x] * 100; - - if(border>=1) - { - x>=( 1) && (pixel_color += target[y][x-1]); - x<(width-1) && (pixel_color += target[y][x+1]); - y>=( 1) && (pixel_color += target[y-1][x]); - y<(16 -1) && (pixel_color += target[y+1][x]); - } - if(border>=2) - { - x>=( 1) && (pixel_color += target[y][x-1]*10); - x<(width-1) && (pixel_color += target[y][x+1]*10); - y>=( 1) && (pixel_color += target[y-1][x]*10); - y<(16 -1) && (pixel_color += target[y+1][x]*10); - - x>=( 1) && y>=( 1) && (pixel_color += target[y-1][x-1]); - x<(width-1) && y>=( 1) && (pixel_color += target[y-1][x+1]); - x>=( 1) && y<(16-1) && (pixel_color += target[y+1][x-1]); - x<(width-1) && y<(16-1) && (pixel_color += target[y+1][x+1]); - - x>=( 2) && (pixel_color += target[y][x-2]); - x<(width-2) && (pixel_color += target[y][x+2]); - y>=( 2) && (pixel_color += target[y-2][x]); - y<(16 -2) && (pixel_color += target[y+2][x]); - } - - if(pixel_color >= 200) - dest[offs] = fgcolor; - else if(pixel_color >= 10) - { - if(dest[offs] < 0xA0) - dest[offs] = 0xC1; - else - dest[offs] = 0xD1; - } - else if(pixel_color > 0) - { - dest[offs] = 0xCF; - } - } - } -} - -void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor) -{ - DrawTextTransWH(dest, width, textmsg, fgcolor, 256, 16, 2); -} diff --git a/branches/sdl2/src/drawing.h b/branches/sdl2/src/drawing.h deleted file mode 100644 index 9ec8e50e..00000000 --- a/branches/sdl2/src/drawing.h +++ /dev/null @@ -1,6 +0,0 @@ -void DrawTextLineBG(uint8 *dest); -void DrawMessage(bool beforeMovie); -void FCEU_DrawRecordingStatus(uint8* XBuf); -void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur); -void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor); -void DrawTextTransWH(uint8 *dest, int width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border); diff --git a/branches/sdl2/src/driver.h b/branches/sdl2/src/driver.h deleted file mode 100644 index 84b4af68..00000000 --- a/branches/sdl2/src/driver.h +++ /dev/null @@ -1,355 +0,0 @@ -#ifndef __DRIVER_H_ -#define __DRIVER_H_ - -#include "types.h" -#include "git.h" -#include "file.h" - -#include -#include -#include - -FILE *FCEUD_UTF8fopen(const char *fn, const char *mode); -inline FILE *FCEUD_UTF8fopen(const std::string &n, const char *mode) { return FCEUD_UTF8fopen(n.c_str(),mode); } -EMUFILE_FILE* FCEUD_UTF8_fstream(const char *n, const char *m); -inline EMUFILE_FILE* FCEUD_UTF8_fstream(const std::string &n, const char *m) { return FCEUD_UTF8_fstream(n.c_str(),m); } -FCEUFILE* FCEUD_OpenArchiveIndex(ArchiveScanRecord& asr, std::string& fname, int innerIndex); -FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename); -ArchiveScanRecord FCEUD_ScanArchive(std::string fname); - -//mbg 7/23/06 -const char *FCEUD_GetCompilerString(); - -//This makes me feel dirty for some reason. -void FCEU_printf(char *format, ...); -#define FCEUI_printf FCEU_printf - -//Video interface -// FIXME: these functions are declared in windows video driver header, but not in linux video driver header; -// eventually both platform video drivers should be brought to same set of functions and single shared header, -// which then can be included where access to video driver functions is needed instead of driver.h -void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b); -void FCEUD_GetPalette(uint8 i,uint8 *r, uint8 *g, uint8 *b); - -//Displays an error. Can block or not. -void FCEUD_PrintError(const char *s); -void FCEUD_Message(const char *s); - -//Network interface - -//Call only when a game is loaded. -int FCEUI_NetplayStart(int nlocal, int divisor); - -// Call when network play needs to stop. -void FCEUI_NetplayStop(void); - -//Note: YOU MUST NOT CALL ANY FCEUI_* FUNCTIONS WHILE IN FCEUD_SendData() or FCEUD_RecvData(). - -//Return 0 on failure, 1 on success. -int FCEUD_SendData(void *data, uint32 len); -int FCEUD_RecvData(void *data, uint32 len); - -//Display text received over the network. -void FCEUD_NetplayText(uint8 *text); - -//Encode and send text over the network. -void FCEUI_NetplayText(uint8 *text); - -//Called when a fatal error occurred and network play can't continue. This function -//should call FCEUI_NetplayStop() after it has deinitialized the network on the driver -//side. -void FCEUD_NetworkClose(void); - -bool FCEUI_BeginWaveRecord(const char *fn); -int FCEUI_EndWaveRecord(void); - -void FCEUI_ResetNES(void); -void FCEUI_PowerNES(void); - -void FCEUI_NTSCSELHUE(void); -void FCEUI_NTSCSELTINT(void); -void FCEUI_NTSCDEC(void); -void FCEUI_NTSCINC(void); -void FCEUI_GetNTSCTH(int *tint, int *hue); -void FCEUI_SetNTSCTH(int n, int tint, int hue); - -void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib); -void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib); - -//tells the emulator whether a fourscore is attached -void FCEUI_SetInputFourscore(bool attachFourscore); -//tells whether a fourscore is attached -bool FCEUI_GetInputFourscore(); -//tells whether the microphone is used -bool FCEUI_GetInputMicrophone(); - -void FCEUI_UseInputPreset(int preset); - - -//New interface functions - -//0 to order screen snapshots numerically(0.png), 1 to order them file base-numerically(smb3-0.png). -//this variable isn't used at all, snap is always name-based -//void FCEUI_SetSnapName(bool a); - -//0 to keep 8-sprites limitation, 1 to remove it -void FCEUI_DisableSpriteLimitation(int a); - -void FCEUI_SetRenderPlanes(bool sprites, bool bg); -void FCEUI_GetRenderPlanes(bool& sprites, bool& bg); - -//name=path and file to load. returns null if it failed -FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode, bool silent = false); - -//same as FCEUI_LoadGame, except that it can load from a tempfile. -//name is the logical path to open; archiveFilename is the archive which contains name -FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silent = false); - -//general purpose emulator initialization. returns true if successful -bool FCEUI_Initialize(); - -//Emulates a frame. -void FCEUI_Emulate(uint8 **, int32 **, int32 *, int); - -//Closes currently loaded game -void FCEUI_CloseGame(void); - -//Deallocates all allocated memory. Call after FCEUI_Emulate() returns. -void FCEUI_Kill(void); - -//Enable/Disable game genie. a=true->enabled -void FCEUI_SetGameGenie(bool a); - -//Set video system a=0 NTSC, a=1 PAL -void FCEUI_SetVidSystem(int a); - -//Convenience function; returns currently emulated video system(0=NTSC, 1=PAL). -int FCEUI_GetCurrentVidSystem(int *slstart, int *slend); - -#ifdef FRAMESKIP -/* Should be called from FCEUD_BlitScreen(). Specifies how many frames - to skip until FCEUD_BlitScreen() is called. FCEUD_BlitScreenDummy() - will be called instead of FCEUD_BlitScreen() when when a frame is skipped. -*/ -void FCEUI_FrameSkip(int x); -#endif - -//First and last scanlines to render, for ntsc and pal emulation. -void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); - -//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory. -void FCEUI_SetBaseDirectory(std::string const & dir); - -//Tells FCE Ultra to copy the palette data pointed to by pal and use it. -//Data pointed to by pal needs to be 64*3 bytes in length. -void FCEUI_SetPaletteArray(uint8 *pal); - -//Sets up sound code to render sound at the specified rate, in samples -//per second. Only sample rates of 44100, 48000, and 96000 are currently supported. -//If "Rate" equals 0, sound is disabled. -void FCEUI_Sound(int Rate); -void FCEUI_SetSoundVolume(uint32 volume); -void FCEUI_SetTriangleVolume(uint32 volume); -void FCEUI_SetSquare1Volume(uint32 volume); -void FCEUI_SetSquare2Volume(uint32 volume); -void FCEUI_SetNoiseVolume(uint32 volume); -void FCEUI_SetPCMVolume(uint32 volume); - -void FCEUI_SetSoundQuality(int quality); - -void FCEUD_SoundToggle(void); -void FCEUD_SoundVolumeAdjust(int); - -int FCEUI_SelectState(int, int); -extern void FCEUI_SelectStateNext(int); - -//"fname" overrides the default save state filename code if non-NULL. -void FCEUI_SaveState(const char *fname, bool display_message=true); -void FCEUI_LoadState(const char *fname, bool display_message=true); - -void FCEUD_SaveStateAs(void); -void FCEUD_LoadStateFrom(void); - -//at the minimum, you should call FCEUI_SetInput, FCEUI_SetInputFC, and FCEUI_SetInputFourscore -//you may also need to maintain your own internal state -void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp); - - -void FCEUD_MovieRecordTo(void); -void FCEUD_MovieReplayFrom(void); -void FCEUD_LuaRunFrom(void); - -int32 FCEUI_GetDesiredFPS(void); -void FCEUI_SaveSnapshot(void); -void FCEUI_SaveSnapshotAs(void); -void FCEU_DispMessage(char *format, int disppos, ...); -#define FCEUI_DispMessage FCEU_DispMessage - -int FCEUI_DecodePAR(const char *code, int *a, int *v, int *c, int *type); -int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c); -int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type); -int FCEUI_DelCheat(uint32 which); -int FCEUI_ToggleCheat(uint32 which); - -int32 FCEUI_CheatSearchGetCount(void); -void FCEUI_CheatSearchGetRange(uint32 first, uint32 last, int (*callb)(uint32 a, uint8 last, uint8 current)); -void FCEUI_CheatSearchGet(int (*callb)(uint32 a, uint8 last, uint8 current, void *data), void *data); -void FCEUI_CheatSearchBegin(void); -void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2); -void FCEUI_ListCheats(int (*callb)(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data), void *data); - -int FCEUI_GetCheat(uint32 which, char **name, uint32 *a, uint8 *v, int *compare, int *s, int *type); -int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare,int s, int type); - -void FCEUI_CheatSearchShowExcluded(void); -void FCEUI_CheatSearchSetCurrentAsOriginal(void); - -//.rom -#define FCEUIOD_ROMS 0 //Roms -#define FCEUIOD_NV 1 //NV = nonvolatile. save data. -#define FCEUIOD_STATES 2 //savestates -#define FCEUIOD_FDSROM 3 //disksys.rom -#define FCEUIOD_SNAPS 4 //screenshots -#define FCEUIOD_CHEATS 5 //cheats -#define FCEUIOD_MOVIES 6 //.fm2 files -#define FCEUIOD_MEMW 7 //memory watch fiels -#define FCEUIOD_BBOT 8 //basicbot, obsolete -#define FCEUIOD_MACRO 9 //macro files - old TASEdit v0.1 paradigm, not implemented, probably obsolete -#define FCEUIOD_INPUT 10 //input presets -#define FCEUIOD_LUA 11 //lua scripts -#define FCEUIOD_AVI 12 //default file for avi output -#define FCEUIOD__COUNT 13 //base directory override? - -void FCEUI_SetDirOverride(int which, char *n); - -void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v)); -uint8 FCEUI_MemSafePeek(uint16 A); -void FCEUI_MemPoke(uint16 a, uint8 v, int hl); -void FCEUI_NMI(void); -void FCEUI_IRQ(void); -uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo); -void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi); - -uint32 FCEUI_CRC32(uint32 crc, uint8 *buf, uint32 len); - -void FCEUI_SetLowPass(int q); - -void FCEUI_NSFSetVis(int mode); -int FCEUI_NSFChange(int amount); -int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen); - -void FCEUI_VSUniToggleDIPView(void); -void FCEUI_VSUniToggleDIP(int w); -uint8 FCEUI_VSUniGetDIPs(void); -void FCEUI_VSUniSetDIP(int w, int state); -void FCEUI_VSUniCoin(void); - -void FCEUI_FDSInsert(void); //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN -//int FCEUI_FDSEject(void); -void FCEUI_FDSSelect(void); - -int FCEUI_DatachSet(const uint8 *rcode); - -///returns a flag indicating whether emulation is paused -int FCEUI_EmulationPaused(); -///returns a flag indicating whether a one frame step has been requested -int FCEUI_EmulationFrameStepped(); -///clears the framestepped flag. use it after youve stepped your one frame -void FCEUI_ClearEmulationFrameStepped(); -///sets the EmulationPaused flags -void FCEUI_SetEmulationPaused(int val); -///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses -void FCEUI_ToggleEmulationPause(); - -//indicates whether input aids should be drawn (such as crosshairs, etc; usually in fullscreen mode) -// FIXME: this function is already declared in both platform video driver headers; -// eventually both platform video drivers should be brought to same set of functions and single shared header, -// which then can be included where access to video driver functions is needed instead of driver.h -bool FCEUD_ShouldDrawInputAids(); - -///called when the emulator closes a game -void FCEUD_OnCloseGame(void); - -void FCEUI_FrameAdvance(void); -void FCEUI_FrameAdvanceEnd(void); - -//AVI Output -int FCEUI_AviBegin(const char* fname); -void FCEUI_AviEnd(void); -void FCEUI_AviVideoUpdate(const unsigned char* buffer); -void FCEUI_AviSoundUpdate(void* soundData, int soundLen); -bool FCEUI_AviIsRecording(); -bool FCEUI_AviEnableHUDrecording(); -void FCEUI_SetAviEnableHUDrecording(bool enable); -bool FCEUI_AviDisableMovieMessages(); -void FCEUI_SetAviDisableMovieMessages(bool disable); - -void FCEUD_AviRecordTo(void); -void FCEUD_AviStop(void); - -///A callback that the emu core uses to poll the state of a given emulator command key -typedef int TestCommandState(int cmd); -///Signals the emu core to poll for emulator commands and take actions -void FCEUI_HandleEmuCommands(TestCommandState* testfn); - - -//Emulation speed -enum EMUSPEED_SET -{ - EMUSPEED_SLOWEST=0, - EMUSPEED_SLOWER, - EMUSPEED_NORMAL, - EMUSPEED_FASTER, - EMUSPEED_FASTEST -}; -void FCEUD_SetEmulationSpeed(int cmd); -void FCEUD_TurboOn(void); -void FCEUD_TurboOff(void); -void FCEUD_TurboToggle(void); - -int FCEUD_ShowStatusIcon(void); -void FCEUD_ToggleStatusIcon(void); -void FCEUD_HideMenuToggle(void); - -///signals the driver to perform a file open GUI operation -void FCEUD_CmdOpen(void); - -//new merge-era driver routines here: - -///signals that the cpu core hit a breakpoint. this function should not return until the core is ready for the next cycle -void FCEUD_DebugBreakpoint(int bp_num); - -///the driver should log the current instruction, if it wants (we should move the code in the win driver that does this to the shared area) -void FCEUD_TraceInstruction(uint8 *opcode, int size); - -///the driver might should update its NTView (only used if debugging support is compiled in) -void FCEUD_UpdateNTView(int scanline, bool drawall); - -///the driver might should update its PPUView (only used if debugging support is compiled in) -void FCEUD_UpdatePPUView(int scanline, int drawall); - -///I am dissatisfied with this method of getting an option from the driver to the core. but that is what we're using for now -bool FCEUD_PauseAfterPlayback(); - -///called when fceu changes something in the video system you might be interested in -void FCEUD_VideoChanged(); - -enum EFCEUI -{ - FCEUI_STOPAVI, FCEUI_QUICKSAVE, FCEUI_QUICKLOAD, FCEUI_SAVESTATE, FCEUI_LOADSTATE, - FCEUI_NEXTSAVESTATE,FCEUI_PREVIOUSSAVESTATE,FCEUI_VIEWSLOTS, - FCEUI_STOPMOVIE, FCEUI_RECORDMOVIE, FCEUI_PLAYMOVIE, - FCEUI_OPENGAME, FCEUI_CLOSEGAME, - FCEUI_TASEDITOR, - FCEUI_RESET, FCEUI_POWER, FCEUI_PLAYFROMBEGINNING, FCEUI_EJECT_DISK, FCEUI_SWITCH_DISK, FCEUI_INSERT_COIN -}; - -//checks whether an EFCEUI is valid right now -bool FCEU_IsValidUI(EFCEUI ui); - -#ifdef __cplusplus -extern "C" -#endif -FILE *FCEUI_UTF8fopen_C(const char *n, const char *m); - -#endif //__DRIVER_H_ diff --git a/branches/sdl2/src/drivers/common/SConscript b/branches/sdl2/src/drivers/common/SConscript deleted file mode 100644 index 3d39b224..00000000 --- a/branches/sdl2/src/drivers/common/SConscript +++ /dev/null @@ -1,6 +0,0 @@ -import glob -source_list = glob.glob('*.cpp') + glob.glob('*.c') - -for x in range(len(source_list)): - source_list[x] = 'drivers/common/' + source_list[x] -Return('source_list') diff --git a/branches/sdl2/src/drivers/common/args.cpp b/branches/sdl2/src/drivers/common/args.cpp deleted file mode 100644 index 4167b8f5..00000000 --- a/branches/sdl2/src/drivers/common/args.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/****************************************************************/ -/* FCE Ultra */ -/* */ -/* This file contains code for parsing command-line */ -/* options. */ -/* */ -/****************************************************************/ - -#include -#include -#include - -#include "../../types.h" -#include "args.h" - -int ParseEA(int x, int argc, char *argv[], ARGPSTRUCT *argsps) -{ - int y=0; - int ret=1; - - do - { - if(!argsps[y].name) - { - ParseEA(x,argc,argv,(ARGPSTRUCT*)argsps[y].var); - y++; - continue; - } - if(!strcmp(argv[x],argsps[y].name)) // A match. - { - //ret++; - if(argsps[y].subs) - { - if((x+1)>=argc) - break; - ret++; - if(argsps[y].substype&0x2000) - { - ((void (*)(char *))argsps[y].subs)(argv[x+1]); - } - else if(argsps[y].substype&0x8000) - { - *(int *)argsps[y].subs&=~(argsps[y].substype&(~0x8000)); - *(int *)argsps[y].subs|=atoi(argv[x+1])?(argsps[y].substype&(~0x8000)):0; - } - else - switch(argsps[y].substype&(~0x4000)) - { - case 0: // Integer - *(int *)argsps[y].subs=atoi(argv[x+1]); - break; - case 2: // Double float - *(double *)argsps[y].subs=atof(argv[x+1]); - break; - case 1: // String - if(argsps[y].substype&0x4000) - { - if(*(char **)argsps[y].subs) - free(*(char **)argsps[y].subs); - if(!( *(char **)argsps[y].subs=(char*)malloc(strlen(argv[x+1])+1) )) - break; - } - strcpy(*(char **)argsps[y].subs,argv[x+1]); - break; - } - } - if(argsps[y].var) - *argsps[y].var=1; - } - y++; - } while(argsps[y].var || argsps[y].subs); - return ret; -} - -int ParseArguments(int argc, char *argv[], ARGPSTRUCT *argsps) -{ - int x; - - for(x=0;x -#include -#include "../../driver.h" -#include "../../fceu.h" - -static void GetString(char *s, int max) -{ - int x; - fgets(s,max,stdin); - - for(x=0;x "); - fgets(buf,ARRAY_SIZE(buf),stdin); - if(buf[0]=='s' || buf[0]=='S') return(-1); - if(buf[0]=='\n') return(0); - if(!sscanf(buf,"%d",&num)) - return(0); - if(num<1) goto tryagain; - return(num); - } - else - { - int num=0; - - tryagain2: - printf(" <'Enter' to make no selection or enter a number.> "); - fgets(buf,ARRAY_SIZE(buf),stdin); - if(buf[0]=='\n') return(0); - if(!sscanf(buf,"%d",&num)) - return(0); - if(num<1) goto tryagain2; - return(num); - } -} - -int EndListShow(void) -{ - if(mordoe) - { - int r=ListChoice(1); - if(r>0 && r<=listcount) - listsel=listids[r-1]; - } - return(listsel); -} - -/* Returns 0 to stop listing, 1 to continue. */ -int AddToList(char *text, uint32 id) -{ - if(listcount==16) - { - int t=ListChoice(0); - mordoe=0; - if(t==-1) return(0); // Stop listing. - else if(t>0 && t<17) - { - listsel=listids[t-1]; - return(0); - } - listcount=0; - } - mordoe=1; - listids[listcount]=id; - printf("%2d) %s\n",listcount+1,text); - listcount++; - return(1); -} - -/* -** -** End list code. -**/ - -typedef struct MENU { - char *text; - void *action; - int type; // 0 for menu, 1 for function. -} MENU; - -static void SetOC(void) -{ - FCEUI_CheatSearchSetCurrentAsOriginal(); -} - -static void UnhideEx(void) -{ - FCEUI_CheatSearchShowExcluded(); -} - -static void ToggleCheat(int num) -{ - printf("Cheat %d %sabled.\n",1+num, - FCEUI_ToggleCheat(num)?"en":"dis"); -} - -static void ModifyCheat(int num) -{ - char *name; - char buf[256]; - uint32 A; - uint8 V; - int compare; - int type; - - int s; - int t; - - FCEUI_GetCheat(num, &name, &A, &V, &compare, &s, &type); - - printf("Name [%s]: ",name); - GetString(buf,256); - - /* This obviously doesn't allow for cheats with no names. Bah. Who wants - nameless cheats anyway... - */ - - if(buf[0]) - name=buf; // Change name when FCEUI_SetCheat() is called. - else - name=0; // Don't change name when FCEUI_SetCheat() is called. - - printf("Address [$%04x]: ",(unsigned int)A); - A=GetH16(A); - - printf("Value [%03d]: ",(unsigned int)V); - V=Get8(V); - - printf("Compare [%3d]: ",compare); - compare=GetI(compare); - - printf("Type(0=Old Style, 1=Read Substitute) [%1d]: ",type); - type=GetI(type)?1:0; - - printf("Enable [%s]: ",s?"Y":"N"); - t=getchar(); - if(t=='Y' || t=='y') s=1; - else if(t=='N' || t=='n') s=0; - - FCEUI_SetCheat(num,name,A,V,compare,s,type); -} - - -static void AddCheatGGPAR(int which) -{ - int A, V, C; - int type; - char name[256],code[256]; - - printf("Name: "); - GetString(name,256); - - printf("Code: "); - GetString(code,256); - - printf("Add cheat \"%s\" for code \"%s\"?",name,code); - if(GetYN(0)) - { - if(which) - { - if(!FCEUI_DecodePAR(code,&A,&V,&C,&type)) - { - puts("Invalid Game Genie code."); - return; - } - } - else - { - if(!FCEUI_DecodeGG(code,&A,&V,&C)) - { - puts("Invalid Game Genie code."); - return; - } - type=1; - } - - if(FCEUI_AddCheat(name,A,V,C,type)) - puts("Cheat added."); - else - puts("Error adding cheat."); - } -} - -static void AddCheatGG(void) -{ - AddCheatGGPAR(0); -} - -static void AddCheatPAR(void) -{ - AddCheatGGPAR(1); -} - -static void AddCheatParam(uint32 A, uint8 V) -{ - char name[256]; - - printf("Name: "); - GetString(name,256); - printf("Address [$%04x]: ",(unsigned int)A); - A=GetH16(A); - printf("Value [%03d]: ",(unsigned int)V); - V=Get8(V); - printf("Add cheat \"%s\" for address $%04x with value %03d?",name,(unsigned int)A,(unsigned int)V); - if(GetYN(0)) - { - if(FCEUI_AddCheat(name,A,V,-1,0)) - puts("Cheat added."); - else - puts("Error adding cheat."); - } -} - -static void AddCheat(void) -{ - AddCheatParam(0,0); -} - -static int lid; -static int clistcallb(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data) -{ - char tmp[512]; - int ret; - - if(compare>=0) - sprintf(tmp,"%s $%04x:%03d:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,compare,name); - else - sprintf(tmp,"%s $%04x:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,name); - if(type==1) - tmp[2]='S'; - ret=AddToList(tmp,lid); - lid++; - return(ret); -} - -static void ListCheats(void) -{ - int which; - lid=0; - - BeginListShow(); - FCEUI_ListCheats(clistcallb,0); - which=EndListShow(); - if(which>=0) - { - char tmp[32]; - printf(" <(T)oggle status, (M)odify, or (D)elete this cheat.> "); - fgets(tmp,ARRAY_SIZE(tmp),stdin); - switch(tolower(tmp[0])) - { - case 't':ToggleCheat(which); - break; - case 'd':if(!FCEUI_DelCheat(which)) - puts("Error deleting cheat!"); - else - puts("Cheat has been deleted."); - break; - case 'm':ModifyCheat(which); - break; - } - } -} - -static void ResetSearch(void) -{ - FCEUI_CheatSearchBegin(); - puts("Done."); -} - -static int srescallb(uint32 a, uint8 last, uint8 current, void *data) -{ - char tmp[14]; - sprintf(tmp, "$%04x:%03d:%03d",(unsigned int)a,(unsigned int)last,(unsigned int)current); - return(AddToList(tmp,a)); -} - -static void ShowRes(void) -{ - int n=FCEUI_CheatSearchGetCount(); - printf(" %d results:\n",n); - if(n) - { - int which; - BeginListShow(); - FCEUI_CheatSearchGet(srescallb,0); - which=EndListShow(); - if(which>=0) - AddCheatParam(which,0); - } -} - -static int ShowShortList(char *moe[], int n, int def) -{ - int x,c; - int baa; //mbg merge 7/17/06 made to normal int - char tmp[256]; - - red: - for(x=0;x ",def+1); - fgets(tmp,ARRAY_SIZE(tmp),stdin); - if(tmp[0]=='\n') - return def; - c=tolower(tmp[0]); - baa=c-'1'; - - if(baaC)", - "Value increased by V2 (|C-O|==V2)", - "Value decreased by V2 (|O-C|==V2)"}; - int av[9]={ASK_V1|ASK_V2, - ASK_V1|ASK_V2, - ASK_V2, - ASK_NONE, - ASK_V1, - ASK_NONE, - ASK_NONE, - ASK_V2, - ASK_V2}; - - printf("\nSearch Filter:\n"); - - method=ShowShortList(m,9,method); - if(av[method]&ASK_V1) - { - printf("V1 [%03d]: ",v1); - v1=Get8(v1); - } - if(av[method]&ASK_V2) - { - printf("V2 [%03d]: ",v2); - v2=Get8(v2); - } - FCEUI_CheatSearchEnd(method,v1,v2); - puts("Search completed.\n"); -} - - -static MENU NewCheatsMenu[]={ - {"Add Cheat",(void *)AddCheat,1}, - {"Reset Search",(void *)ResetSearch,1}, - {"Do Search",(void *)DoSearch,1}, - {"Set Original to Current",(void *)SetOC,1}, - {"Unhide Excluded",(void *)UnhideEx,1}, - {"Show Results",(void *)ShowRes,1}, - {"Add Game Genie Cheat",(void *)AddCheatGG,1}, - {"Add PAR Cheat",(void *)AddCheatPAR,1}, - {0} -}; - -static MENU MainMenu[]={ - {"List Cheats",(void *)ListCheats,1}, - {"New Cheats...",(void *)NewCheatsMenu,0}, - {0} -}; - -static void DoMenu(MENU *men) -{ - int x=0; - - redisplay: - x=0; - puts(""); - while(men[x].text) - { - printf("%d) %s\n",x+1,men[x].text); - x++; - } - puts("D) Display Menu\nX) Return to Previous\n"); - { - char buf[32]; - int c; - - recommand: - printf("Command> "); - fgets(buf,ARRAY_SIZE(buf),stdin); - c=tolower(buf[0]); - if(c=='\n') - goto recommand; - else if(c=='d') - goto redisplay; - else if(c=='x') - { - return; - } - else if(sscanf(buf,"%d",&c)) - { - if(c>x) goto invalid; - if(men[c-1].type) - { - void (*func)(void)=(void(*)())men[c-1].action; - func(); - } - else - DoMenu((MENU*)men[c-1].action); /* Mmm...recursivey goodness. */ - goto redisplay; - } - else - { - invalid: - puts("Invalid command.\n"); - goto recommand; - } - - } -} - -void DoConsoleCheatConfig(void) -{ - MENU *curmenu=MainMenu; - - DoMenu(curmenu); -} diff --git a/branches/sdl2/src/drivers/common/cheat.h b/branches/sdl2/src/drivers/common/cheat.h deleted file mode 100644 index 77619fe3..00000000 --- a/branches/sdl2/src/drivers/common/cheat.h +++ /dev/null @@ -1,21 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -void DoConsoleCheatConfig(void); diff --git a/branches/sdl2/src/drivers/common/config.cpp b/branches/sdl2/src/drivers/common/config.cpp deleted file mode 100644 index ca610616..00000000 --- a/branches/sdl2/src/drivers/common/config.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - *fs - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/****************************************************************/ -/* FCE Ultra */ -/* */ -/* This file contains routines for reading/writing the */ -/* configuration file. */ -/* */ -/****************************************************************/ - -#include -#include -#include - -#include "../../types.h" -#include "../../driver.h" -#include "../../utils/xstring.h" -#include "config.h" - -static int FReadString(FILE *fp, char *str, int n) -{ - int x=0,z; - for(;;) - { - z=fgetc(fp); - str[x]=z; - x++; - if(z<=0) break; - if(x>=n) return 0; - } - if(z<0) return 0; - return 1; -} - -#include -#include -typedef std::map CFGMAP; -static CFGMAP cfgmap; - -static void cfg_Parse(FILE *fp) -{ - //yes... it is a homebrewed key-value-pair parser - std::string key,value; - enum { - NEWLINE, KEY, SEPARATOR, VALUE, COMMENT - } state = NEWLINE; - bool bail = false; - for(;;) - { - int c = fgetc(fp); - bool iswhitespace, iscommentchar, isnewline; - if(c == -1) - goto bail; - iswhitespace = (c==' '||c=='\t'); - iscommentchar = (c=='#'); - isnewline = (c==10||c==13); - switch(state) - { - case NEWLINE: - if(iswhitespace) goto done; - if(iscommentchar) goto docomment; - if(isnewline) goto done; - key = ""; - value = ""; - goto dokey; - break; - case COMMENT: - docomment: - state = COMMENT; - if(isnewline) state = NEWLINE; - break; - case KEY: - dokey: //dookie - state = KEY; - if(iswhitespace) goto doseparator; - if(isnewline) goto commit; - key += c; - break; - case SEPARATOR: - doseparator: - state = SEPARATOR; - if(isnewline) goto commit; - if(!iswhitespace) goto dovalue; - break; - case VALUE: - dovalue: - state = VALUE; - if(isnewline) goto commit; - value += c; - } - goto done; - - bail: - bail = true; - if(state == VALUE) goto commit; - commit: - cfgmap[key] = value; - state = NEWLINE; - if(bail) break; - done: ; - } -} - -static void cfg_Save(FILE *fp) -{ - for(CFGMAP::iterator it(cfgmap.begin()); it != cfgmap.end(); it++) - { - if(it->first.size()>30 || it->second.size()>30) - { - int zzz=9; - } - fprintf(fp,"%s %s\n",it->first.c_str(),it->second.c_str()); - } -} - - -static void GetValueR(FILE *fp, char *str, void *v, int c) -{ - char buf[256]; - int s; - - while(FReadString(fp,buf,256)) - { - fread(&s,1,4,fp); - - if(!strcmp(str, buf)) - { - if(!c) // String, allocate some memory. - { - if(!(*(char **)v=(char*)malloc(s))) - goto gogl; - - fread(*(char **)v,1,s,fp); - continue; - } - else if(s>c || s -#include -#include -#include -#include -#include - -#include "../../types.h" -#include "configSys.h" - -std::string cfgFile = "fceux.cfg"; -/** - * Add a given option. The option is specified as a short command - * line (-f), long command line (--foo), option name (Foo), its type - * (integer or string). - */ -int -Config::_addOption(char shortArg, - const std::string &longArg, - const std::string &name, - int type) -{ - // make sure we have a valid type - if(type != INTEGER && type != STRING && - type != DOUBLE && type != FUNCTION) { - return -1; - } - - // check if the option already exists - if(_shortArgMap.find(shortArg) != _shortArgMap.end() || - _longArgMap.find(longArg) != _longArgMap.end() || - (type == INTEGER && _intOptMap.find(name) != _intOptMap.end()) || - (type == STRING && _strOptMap.find(name) != _strOptMap.end()) || - (type == DOUBLE && _dblOptMap.find(name) != _dblOptMap.end())) { - return -1; - } - - // add the option - switch(type) { - case(STRING): - _strOptMap[name] = ""; - break; - case(INTEGER): - _intOptMap[name] = 0; - break; - case(DOUBLE): - _dblOptMap[name] = 0.0; - break; - case(FUNCTION): - _fnOptMap[name] = NULL; - break; - default: - break; - } - _shortArgMap[shortArg] = name; - _longArgMap[longArg] = name; - - return 0; -} - -int -Config::_addOption(const std::string &longArg, - const std::string &name, - int type) -{ - // make sure we have a valid type - if(type != STRING && type != INTEGER && type != DOUBLE) { - return -1; - } - - // check if the option already exists - if(_longArgMap.find(longArg) != _longArgMap.end() || - (type == STRING && _strOptMap.find(name) != _strOptMap.end()) || - (type == INTEGER && _intOptMap.find(name) != _intOptMap.end()) || - (type == DOUBLE && _dblOptMap.find(name) != _dblOptMap.end())) { - return -1; - } - - // add the option - switch(type) { - case(STRING): - _strOptMap[name] = ""; - break; - case(INTEGER): - _intOptMap[name] = 0; - break; - case(DOUBLE): - _dblOptMap[name] = 0.0; - break; - default: - break; - } - _longArgMap[longArg] = name; - - return 0; -} - - -/** - * Add a given option and sets its default value. The option is - * specified as a short command line (-f), long command line (--foo), - * option name (Foo), its type (integer or string), and its default - * value. - */ -int -Config::addOption(char shortArg, - const std::string &longArg, - const std::string &name, - int defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(shortArg, longArg, name, INTEGER); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - -/** - * Add a given option and sets its default value. The option is - * specified as a short command line (-f), long command line (--foo), - * option name (Foo), its type (integer or string), and its default - * value. - */ -int -Config::addOption(char shortArg, - const std::string &longArg, - const std::string &name, - double defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(shortArg, longArg, name, DOUBLE); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - - -/** - * Add a given option and sets its default value. The option is - * specified as a short command line (-f), long command line (--foo), - * option name (Foo), its type (integer or string), and its default - * value. - */ -int -Config::addOption(char shortArg, - const std::string &longArg, - const std::string &name, - const std::string &defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(shortArg, longArg, name, STRING); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - -int -Config::addOption(char shortArg, - const std::string &longArg, - const std::string &name, - void (*defaultFn)(const std::string &)) -{ - int error; - - // add the option to the config system - error = _addOption(shortArg, longArg, name, FUNCTION); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultFn); - if(error) { - return error; - } - - return 0; -} - -int -Config::addOption(const std::string &longArg, - const std::string &name, - const std::string &defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(longArg, name, STRING); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - -int -Config::addOption(const std::string &longArg, - const std::string &name, - int defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(longArg, name, INTEGER); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - -int -Config::addOption(const std::string &longArg, - const std::string &name, - double defaultValue) -{ - int error; - - // add the option to the config system - error = _addOption(longArg, name, DOUBLE); - if(error) { - return error; - } - - // set the option to the default value - error = setOption(name, defaultValue); - if(error) { - return error; - } - - return 0; -} - -int -Config::addOption(const std::string &name, - const std::string &defaultValue) -{ - if(_strOptMap.find(name) != _strOptMap.end()) { - return -1; - } - - // add the option - _strOptMap[name] = defaultValue; - return 0; -} - -int -Config::addOption(const std::string &name, - int defaultValue) -{ - if(_intOptMap.find(name) != _intOptMap.end()) { - return -1; - } - - // add the option - _intOptMap[name] = defaultValue; - return 0; -} - -int -Config::addOption(const std::string &name, - double defaultValue) -{ - if(_dblOptMap.find(name) != _dblOptMap.end()) { - return -1; - } - - // add the option - _dblOptMap[name] = defaultValue; - return 0; -} - -/** - * Sets the specified option to the given integer value. - */ -int -Config::setOption(const std::string &name, - int value) -{ - std::map::iterator opt_i; - - // confirm that the option exists - opt_i = _intOptMap.find(name); - if(opt_i == _intOptMap.end()) { - return -1; - } - - // set the option - opt_i->second = value; - return 0; -} - -/** - * Sets the specified option to the given integer value. - */ -int -Config::setOption(const std::string &name, - double value) -{ - std::map::iterator opt_i; - - // confirm that the option exists - opt_i = _dblOptMap.find(name); - if(opt_i == _dblOptMap.end()) { - return -1; - } - - // set the option - opt_i->second = value; - return 0; -} - -/** - * Sets the specified option to the given string value. - */ -int -Config::setOption(const std::string &name, - const std::string &value) -{ - std::map::iterator opt_i; - - // confirm that the option exists - opt_i = _strOptMap.find(name); - if(opt_i == _strOptMap.end()) { - return -1; - } - - // set the option - opt_i->second = value; - return 0; -} - -/** - * Sets the specified option to the given function. - */ -int -Config::setOption(const std::string &name, - void (*value)(const std::string &)) -{ - std::map::iterator opt_i; - - // confirm that the option exists - opt_i = _fnOptMap.find(name); - if(opt_i == _fnOptMap.end()) { - return -1; - } - - // set the option - opt_i->second = value; - return 0; -} - - -int -Config::getOption(const std::string &name, - std::string *value) const -{ - std::map::const_iterator opt_i; - - // confirm that the option exists - opt_i = _strOptMap.find(name); - if(opt_i == _strOptMap.end()) { - return -1; - } - - // get the option - (*value) = opt_i->second; - return 0; -} - -int -Config::getOption(const std::string &name, - const char **value) const -{ - std::map::const_iterator opt_i; - - // confirm that the option exists - opt_i = _strOptMap.find(name); - if(opt_i == _strOptMap.end()) { - return -1; - } - - // get the option - (*value) = opt_i->second.c_str(); - return 0; -} - -int -Config::getOption(const std::string &name, - int *value) const -{ - std::map::const_iterator opt_i; - - // confirm that the option exists - opt_i = _intOptMap.find(name); - if(opt_i == _intOptMap.end()) { - return -1; - } - - // get the option - (*value) = opt_i->second; - return 0; -} - -int -Config::getOption(const std::string &name, - double *value) const -{ - std::map::const_iterator opt_i; - - // confirm that the option exists - opt_i = _dblOptMap.find(name); - if(opt_i == _dblOptMap.end()) { - return -1; - } - - // get the option - (*value) = opt_i->second; - return 0; -} - -/** - * Parses the command line arguments. Short args are of the form -f - * , long args are of the form --foo . Returns < 0 on error, - * or the index of the rom file in argv. - */ -int -Config::_parseArgs(int argc, - char **argv) -{ - int retval = 0; - std::map::iterator long_i, str_i; - std::map::iterator short_i; - std::map::iterator int_i; - std::map::iterator dbl_i; - std::map::iterator fn_i; - std::string arg, opt, value; - - for(int i = 1; i < argc; i++) { - arg = argv[i]; - if(arg[0] != '-') { - // must be a rom name? - retval = i; - continue; - } - - if(arg.size() < 2) { - // XXX invalid argument - return -1; - } - - // parse the argument and get the option name - if(arg[1] == '-') { - // long arg - long_i = _longArgMap.find(arg.substr(2)); - if(long_i == _longArgMap.end()) { - // XXX invalid argument - return -1; - } - - opt = long_i->second; - } else { - // short arg - short_i = _shortArgMap.find(arg[1]); - if(short_i == _shortArgMap.end()) { - // XXX invalid argument - return -1; - } - - opt = short_i->second; - } - - // make sure we've got a value - if(i + 1 >= argc) { - // XXX missing value - return -1; - } - i++; - - // now, find the appropriate option entry, and update it - str_i = _strOptMap.find(opt); - int_i = _intOptMap.find(opt); - dbl_i = _dblOptMap.find(opt); - fn_i = _fnOptMap.find(opt); - if(str_i != _strOptMap.end()) { - str_i->second = argv[i]; - } else if(int_i != _intOptMap.end()) { - int_i->second = atol(argv[i]); - } else if(dbl_i != _dblOptMap.end()) { - dbl_i->second = atof(argv[i]); - } else if(fn_i != _fnOptMap.end()) { - (*(fn_i->second))(argv[i]); - } else { - // XXX invalid option? shouldn't happen - return -1; - } - } - - // if we didn't get a rom-name, return error - return (retval) ? retval : -1; -} - - -/** - * Parses first the configuration file, and then overrides with any - * command-line options that were specified. - */ -int -Config::parse(int argc, - char **argv) -{ - int error; - - // read the config file - error = _load(); - if(error) { - return error; - } - - // try to read cfg.d/* - std::string cfgd_dir_name = _dir + "/" + "cfg.d/"; - DIR *d; - struct dirent *dir; - d = opendir(cfgd_dir_name.c_str()); - if (d) - { - while ((dir = readdir(d)) != NULL) - { - // dont load "." or ".." - if(strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) - { - continue; - } - - // TODO 0 = good -1 = bad - std::string fname = cfgd_dir_name + dir->d_name; - printf("Loading auxilary configuration file at %s...\n", fname.c_str()); - if (_loadFile(fname.c_str()) != 0) - { - printf("Failed to parse configuration at %s\n", fname.c_str()); - } - } - - closedir(d); - } - - // parse the arguments - return _parseArgs(argc, argv); -} - - -/** - * Read each line of the config file and put the variables into the - * config maps. Valid configuration lines are of the form: - * - *