optional lua in sdl

This commit is contained in:
punkrockguy318 2008-09-24 06:06:31 +00:00
parent 2fe4fcd2d1
commit 407f0f8663
16 changed files with 92 additions and 21 deletions

View File

@ -5,7 +5,8 @@ opts = Options()
opts.AddOptions( opts.AddOptions(
BoolOption('FRAMESKIP', 'Enable frameskipping', 1), BoolOption('FRAMESKIP', 'Enable frameskipping', 1),
BoolOption('OPENGL', 'Enable OpenGL support', 1), BoolOption('OPENGL', 'Enable OpenGL support', 1),
BoolOption('DEBUG', 'Build with debugging symbols', 0) BoolOption('DEBUG', 'Build with debugging symbols', 0),
BoolOption('LUA', 'Enable Lua support', 1)
) )
env = Environment(options = opts) env = Environment(options = opts)
@ -47,11 +48,12 @@ else:
if not conf.CheckLib('z', autoadd=1): if not conf.CheckLib('z', autoadd=1):
print 'Did not find libz or z.lib, exiting!' print 'Did not find libz or z.lib, exiting!'
Exit(1) Exit(1)
if env['LUA']:
lua51 = conf.CheckLib('lua5.1', autoadd=1) lua51 = conf.CheckLib('lua5.1', autoadd=1)
lua = conf.CheckLib('lua', autoadd=1) lua = conf.CheckLib('lua', autoadd=1)
if lua == 0 and lua51 == 0: if lua == 0 and lua51 == 0:
print 'Did not find liblua5.1, liblua, lua.lib or lua5.1.lib, exiting!' print 'Did not find liblua5.1, liblua, lua.lib or lua5.1.lib, compiling anyway!'
Exit(1) env['LUA'] = 0
### Search for zenity if we're not in windows ### Search for zenity if we're not in windows
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin': if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin':
@ -85,11 +87,13 @@ else:
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1']) conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
# parse SDL cflags/libs # parse SDL cflags/libs
env.ParseConfig('sdl-config --cflags --libs') env.ParseConfig('sdl-config --cflags --libs')
if env['LUA']:
# parse liblua cflags # parse liblua cflags
if lua51: if lua51:
env.Append(CPPPATH = ['/usr/local/include/lua5.1', '/usr/include/lua5.1']) env.Append(CPPPATH = ['/usr/local/include/lua5.1', '/usr/include/lua5.1'])
if lua: if lua:
env.Append(CPPPATH = ['/usr/local/include/lua', '/usr/include/lua']) env.Append(CPPPATH = ['/usr/local/include/lua', '/usr/include/lua'])
env.Append(CPPDEFINES=["_S9XLUA_H"])
env = conf.Finish() env = conf.Finish()
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32': if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':

View File

@ -1,5 +1,7 @@
---version 2.0.3 yet to be released--- ---version 2.0.3 yet to be released---
22-sep-2008 - punkrockguy318 - [ 208437 ] fixed an issue where flawed movie 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 would crash fceux on every startup
21-aug-2008 - punkrockguy318 - sdl - fixed issue where windowed mode would 21-aug-2008 - punkrockguy318 - sdl - fixed issue where windowed mode would
always be set to 32 bpp always be set to 32 bpp

View File

@ -12,7 +12,6 @@ file.cpp
filter.cpp filter.cpp
ines.cpp ines.cpp
input.cpp input.cpp
lua-engine.cpp
netplay.cpp netplay.cpp
nsf.cpp nsf.cpp
palette.cpp palette.cpp
@ -39,6 +38,9 @@ mappers""")
Import('env') Import('env')
Export('env') Export('env')
if env['LUA']:
file_list.append('lua-engine.cpp')
for dir in subdirs: for dir in subdirs:
subdir_files = SConscript('%s/SConscript' % dir) subdir_files = SConscript('%s/SConscript' % dir)
file_list.append(subdir_files) file_list.append(subdir_files)

View File

@ -1,6 +1,9 @@
/// \file /// \file
/// \brief Implements core debugging facilities /// \brief Implements core debugging facilities
#include <stdlib.h>
#include <string.h>
#include "types.h" #include "types.h"
#include "x6502.h" #include "x6502.h"
#include "fceu.h" #include "fceu.h"
@ -10,8 +13,7 @@
#include "driver.h" #include "driver.h"
#include "ppu.h" #include "ppu.h"
#include <stdlib.h>
#include <string.h>
#include "x6502abbrev.h" #include "x6502abbrev.h"

View File

@ -181,8 +181,10 @@ InitConfig()
// video playback // video playback
config->addOption("playmov", "SDL.Movie", ""); config->addOption("playmov", "SDL.Movie", "");
#ifdef _S9XLUA_H
// load lua script // load lua script
config->addOption("loadlua", "SDL.LuaScript", ""); config->addOption("loadlua", "SDL.LuaScript", "");
#endif
// GamePad 0 - 3 // GamePad 0 - 3
for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) {
@ -262,7 +264,9 @@ InitConfig()
// Hotkeys // Hotkeys
prefix = "SDL.Hotkeys."; prefix = "SDL.Hotkeys.";
config->addOption(prefix + "CheatMenu", SDLK_F1); config->addOption(prefix + "CheatMenu", SDLK_F1);
#ifdef _S9XLUA_H
config->addOption(prefix + "LoadLua", SDLK_F3); config->addOption(prefix + "LoadLua", SDLK_F3);
#endif
config->addOption(prefix + "RenderBG", SDLK_F4); config->addOption(prefix + "RenderBG", SDLK_F4);
config->addOption(prefix + "SaveState", SDLK_F5); config->addOption(prefix + "SaveState", SDLK_F5);
config->addOption(prefix + "LoadState", SDLK_F7); config->addOption(prefix + "LoadState", SDLK_F7);

View File

@ -32,7 +32,9 @@
#include "../../movie.h" #include "../../movie.h"
#include "../../fceu.h" #include "../../fceu.h"
#include "../../driver.h" #include "../../driver.h"
#ifdef _S9XLUA_H
#include "../../fceulua.h" #include "../../fceulua.h"
#endif
/** GLOBALS **/ /** GLOBALS **/
@ -364,6 +366,7 @@ KeyboardCommands()
if(_keyonly(key)) { if(_keyonly(key)) {
FCEUI_CloseGame(); FCEUI_CloseGame();
} }
#ifdef _S9XLUA_H
g_config->getOption("SDL.Hotkeys.LoadLua", &key); g_config->getOption("SDL.Hotkeys.LoadLua", &key);
if(_keyonly(key)) { if(_keyonly(key)) {
std::string fname; std::string fname;
@ -371,6 +374,7 @@ KeyboardCommands()
if(fname != "") if(fname != "")
FCEU_LoadLuaCode(fname.c_str()); FCEU_LoadLuaCode(fname.c_str());
} }
#endif
// VS Unisystem games // VS Unisystem games
if(gametype == GIT_VSUNI) { if(gametype == GIT_VSUNI) {

View File

@ -19,7 +19,9 @@
#include "../common/cheat.h" #include "../common/cheat.h"
#include "../../fceu.h" #include "../../fceu.h"
#include "../../movie.h" #include "../../movie.h"
#ifdef _S9XLUA_H
#include "../../fceulua.h" #include "../../fceulua.h"
#endif
#include "input.h" #include "input.h"
#include "dface.h" #include "dface.h"
@ -86,8 +88,7 @@ char *DriverUsage="\
Devices: quizking hypershot mahjong toprider ftrainer\n\ Devices: quizking hypershot mahjong toprider ftrainer\n\
familykeyboard oekakids arkanoid shadow bworld 4player\n\ familykeyboard oekakids arkanoid shadow bworld 4player\n\
--inputcfg d Configures input device d on startup (gamepad1, gamepad2).\n\ --inputcfg d Configures input device d on startup (gamepad1, gamepad2).\n\
--playmov f Plays back a recorded movie from filename f.\n\ --playmov f Plays back a recorded movie from filename f.";
--loadlua f Loads lua script from filename f.\n";
/* Moved network options out while netplay is broken. /* Moved network options out while netplay is broken.
--net s, -n s Connects to server 's' for TCP/IP network play.\n\ --net s, -n s Connects to server 's' for TCP/IP network play.\n\
@ -107,6 +108,11 @@ static void ShowUsage(char *prog)
printf("\nUsage is as follows:\n%s <options> filename\n\n",prog); printf("\nUsage is as follows:\n%s <options> filename\n\n",prog);
puts("Options:"); puts("Options:");
puts(DriverUsage); puts(DriverUsage);
#ifdef _S9XLUA_H
puts ("--loadlua f Loads lua script from filename f.\n");
#else
puts("");
#endif
} }
/** /**
@ -480,6 +486,7 @@ SDL_GL_LoadLibrary(0);
} }
#ifdef _S9XLUA_H
// load lua script if option passed // load lua script if option passed
g_config->getOption("SDL.LuaScript", &fname); g_config->getOption("SDL.LuaScript", &fname);
g_config->setOption("SDL.LuaScript", ""); g_config->setOption("SDL.LuaScript", "");
@ -487,7 +494,7 @@ SDL_GL_LoadLibrary(0);
{ {
FCEU_LoadLuaCode(fname.c_str()); FCEU_LoadLuaCode(fname.c_str());
} }
#endif
// loop playing the game // loop playing the game
while(GameInfo) { while(GameInfo) {

View File

@ -48,7 +48,9 @@
#include "input.h" #include "input.h"
#include "file.h" #include "file.h"
#include "vsuni.h" #include "vsuni.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
//TODO - we really need some kind of global platform-specific options api //TODO - we really need some kind of global platform-specific options api
#ifdef WIN32 #ifdef WIN32
@ -282,13 +284,17 @@ uint8 PAL=0;
static DECLFW(BRAML) static DECLFW(BRAML)
{ {
RAM[A]=V; RAM[A]=V;
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
} }
static DECLFW(BRAMH) static DECLFW(BRAMH)
{ {
RAM[A&0x7FF]=V; RAM[A&0x7FF]=V;
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
} }
static DECLFR(ARAML) static DECLFR(ARAML)
@ -463,7 +469,9 @@ bool FCEUI_Initialize()
void FCEUI_Kill(void) void FCEUI_Kill(void)
{ {
#ifdef _S9XLUA_H
FCEU_LuaStop(); FCEU_LuaStop();
#endif
FCEU_KillVirtualVideo(); FCEU_KillVirtualVideo();
FCEU_KillGenie(); FCEU_KillGenie();
FreeBuffers(); FreeBuffers();
@ -560,7 +568,9 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
AutoFire(); AutoFire();
UpdateAutosave(); UpdateAutosave();
#ifdef _S9XLUA_H
FCEU_LuaFrameBoundary(); FCEU_LuaFrameBoundary();
#endif
FCEU_UpdateInput(); FCEU_UpdateInput();
lagFlag = 1; lagFlag = 1;
if(geniestage!=1) FCEU_ApplyPeriodicCheats(); if(geniestage!=1) FCEU_ApplyPeriodicCheats();

View File

@ -1,5 +1,4 @@
#ifndef _S9XLUA_H #ifdef _S9XLUA_H
#define _S9XLUA_H
// Just forward function declarations // Just forward function declarations

View File

@ -32,7 +32,9 @@
#include "movie.h" #include "movie.h"
#include "state.h" #include "state.h"
#include "input/zapper.h" #include "input/zapper.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
#include "input.h" #include "input.h"
#include "vsuni.h" #include "vsuni.h"
#include "fds.h" #include "fds.h"
@ -190,13 +192,17 @@ static void UpdateGP(int w, void *data, int arg)
{ {
if(w==0) if(w==0)
{ {
#ifdef _S9XLUA_H
joy[0]= FCEU_LuaUsingJoypad(0) ? FCEU_LuaReadJoypad(0) : *(uint32 *)joyports[0].ptr; joy[0]= FCEU_LuaUsingJoypad(0) ? FCEU_LuaReadJoypad(0) : *(uint32 *)joyports[0].ptr;
joy[2]= FCEU_LuaUsingJoypad(2) ? FCEU_LuaReadJoypad(2) : *(uint32 *)joyports[0].ptr >> 16; joy[2]= FCEU_LuaUsingJoypad(2) ? FCEU_LuaReadJoypad(2) : *(uint32 *)joyports[0].ptr >> 16;
#endif
} }
else else
{ {
#ifdef _S9XLUA_H
joy[1]= FCEU_LuaUsingJoypad(1) ? FCEU_LuaReadJoypad(1) : *(uint32 *)joyports[1].ptr >> 8; joy[1]= FCEU_LuaUsingJoypad(1) ? FCEU_LuaReadJoypad(1) : *(uint32 *)joyports[1].ptr >> 8;
joy[3]= FCEU_LuaUsingJoypad(3) ? FCEU_LuaReadJoypad(3) : *(uint32 *)joyports[1].ptr >> 24; joy[3]= FCEU_LuaUsingJoypad(3) ? FCEU_LuaReadJoypad(3) : *(uint32 *)joyports[1].ptr >> 24;
#endif
} }
} }
@ -685,7 +691,9 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", 0 }, { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", 0 },
{ EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", 0 }, { EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", 0 },
#ifdef _S9XLUA_H
{ EMUCMD_SCRIPT_RELOAD, EMUCMDTYPE_MISC, FCEU_ReloadLuaCode, 0, 0, "Reload current Lua script", }, { EMUCMD_SCRIPT_RELOAD, EMUCMDTYPE_MISC, FCEU_ReloadLuaCode, 0, 0, "Reload current Lua script", },
#endif
{ EMUCMD_SOUND_TOGGLE, EMUCMDTYPE_SOUND, FCEUD_SoundToggle, 0, 0, "Sound Mute Toggle", EMUCMDFLAG_TASEDIT }, { EMUCMD_SOUND_TOGGLE, EMUCMDTYPE_SOUND, FCEUD_SoundToggle, 0, 0, "Sound Mute Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", EMUCMDFLAG_TASEDIT }, { EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", EMUCMDFLAG_TASEDIT },

View File

@ -1,3 +1,4 @@
#include <string.h>
#include "../types.h" #include "../types.h"
#include "../x6502.h" #include "../x6502.h"
#include "../fceu.h" #include "../fceu.h"
@ -8,4 +9,4 @@
#include "../utils/memory.h" #include "../utils/memory.h"
#include "../sound.h" #include "../sound.h"
#include "../state.h" #include "../state.h"
#include <string.h>

View File

@ -17,7 +17,9 @@
#include "file.h" #include "file.h"
#include "video.h" #include "video.h"
#include "movie.h" #include "movie.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
#include "utils/guid.h" #include "utils/guid.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "utils/memorystream.h" #include "utils/memorystream.h"
@ -1034,8 +1036,10 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size)
tempMovieData.truncateAt(currFrameCounter); tempMovieData.truncateAt(currFrameCounter);
currMovieData = tempMovieData; currMovieData = tempMovieData;
#ifdef _S9XLUA_H
if(!FCEU_LuaRerecordCountSkip()) if(!FCEU_LuaRerecordCountSkip())
currRerecordCount++; currRerecordCount++;
#endif
currMovieData.rerecordCount = currRerecordCount; currMovieData.rerecordCount = currRerecordCount;

View File

@ -39,7 +39,9 @@
#include "cart.h" #include "cart.h"
#include "input.h" #include "input.h"
#include "driver.h" #include "driver.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
@ -409,7 +411,9 @@ static DECLFR(NSF_read)
for(x=0;x<8;x++) for(x=0;x<8;x++)
BANKSET(0x8000+x*4096,NSFHeader.BankSwitch[x]); BANKSET(0x8000+x*4096,NSFHeader.BankSwitch[x]);
} }
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
return (CurrentSong-1); return (CurrentSong-1);
} }
case 0x3FF3:return PAL; case 0x3FF3:return PAL;

View File

@ -29,7 +29,9 @@
#include "fceu.h" #include "fceu.h"
#include "driver.h" #include "driver.h"
#include "boards/mapinc.h" #include "boards/mapinc.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
#include "palette.h" #include "palette.h"
#include "palettes/palettes.h" #include "palettes/palettes.h"
@ -110,7 +112,9 @@ void SetNESDeemph(uint8 d, int force)
} }
else /* Only set this when palette has changed. */ else /* Only set this when palette has changed. */
{ {
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette(); FCEU_LuaUpdatePalette();
#endif
r=rtmul[6]; r=rtmul[6];
g=rtmul[6]; g=rtmul[6];
@ -155,7 +159,9 @@ void SetNESDeemph(uint8 d, int force)
} }
lastd=d; lastd=d;
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette(); FCEU_LuaUpdatePalette();
#endif
} }
// Converted from Kevin Horton's qbasic palette generator. // Converted from Kevin Horton's qbasic palette generator.
@ -263,7 +269,9 @@ void WritePalette(void)
FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b);
if(GameInfo->type==GIT_NSF) if(GameInfo->type==GIT_NSF)
{ {
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette(); FCEU_LuaUpdatePalette();
#endif
//for(x=0;x<128;x++) //for(x=0;x<128;x++)
// FCEUD_SetPalette(x,x,0,x); // FCEUD_SetPalette(x,x,0,x);
} }

View File

@ -46,7 +46,9 @@
#include "vsuni.h" #include "vsuni.h"
#include "drawing.h" #include "drawing.h"
#include "driver.h" #include "driver.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
uint8 *XBuf=NULL; uint8 *XBuf=NULL;
uint8 *XBackBuf=NULL; uint8 *XBackBuf=NULL;
@ -204,8 +206,10 @@ void FCEU_PutImage(void)
//Some messages need to be displayed before the avi is dumped //Some messages need to be displayed before the avi is dumped
DrawMessage(true); DrawMessage(true);
#ifdef _S9XLUA_H
//Lua gui should draw before the avi is dumped. //Lua gui should draw before the avi is dumped.
FCEU_LuaGui(XBuf); FCEU_LuaGui(XBuf);
#endif
//Update AVI before overlay stuff is written //Update AVI before overlay stuff is written
if(!FCEUI_EmulationPaused()) if(!FCEUI_EmulationPaused())

View File

@ -24,7 +24,9 @@
#include "fceu.h" #include "fceu.h"
#include "debug.h" #include "debug.h"
#include "sound.h" #include "sound.h"
#ifdef _S9XLUA_H
#include "fceulua.h" #include "fceulua.h"
#endif
#include "x6502abbrev.h" #include "x6502abbrev.h"
@ -50,7 +52,9 @@ static INLINE uint8 RdMem(unsigned int A)
static INLINE void WrMem(unsigned int A, uint8 V) static INLINE void WrMem(unsigned int A, uint8 V)
{ {
BWrite[A](A,V); BWrite[A](A,V);
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
} }
static INLINE uint8 RdRAM(unsigned int A) static INLINE uint8 RdRAM(unsigned int A)
@ -63,7 +67,9 @@ static INLINE uint8 RdRAM(unsigned int A)
static INLINE void WrRAM(unsigned int A, uint8 V) static INLINE void WrRAM(unsigned int A, uint8 V)
{ {
RAM[A]=V; RAM[A]=V;
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
} }
uint8 X6502_DMR(uint32 A) uint8 X6502_DMR(uint32 A)
@ -76,7 +82,9 @@ void X6502_DMW(uint32 A, uint8 V)
{ {
ADDCYC(1); ADDCYC(1);
BWrite[A](A,V); BWrite[A](A,V);
#ifdef _S9XLUA_H
FCEU_LuaWriteInform(); FCEU_LuaWriteInform();
#endif
} }
#define PUSH(V) \ #define PUSH(V) \