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(
BoolOption('FRAMESKIP', 'Enable frameskipping', 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)
@ -47,11 +48,12 @@ else:
if not conf.CheckLib('z', autoadd=1):
print 'Did not find libz or z.lib, exiting!'
Exit(1)
lua51 = conf.CheckLib('lua5.1', autoadd=1)
lua = conf.CheckLib('lua', autoadd=1)
if lua == 0 and lua51 == 0:
print 'Did not find liblua5.1, liblua, lua.lib or lua5.1.lib, exiting!'
Exit(1)
if env['LUA']:
lua51 = conf.CheckLib('lua5.1', autoadd=1)
lua = conf.CheckLib('lua', autoadd=1)
if lua == 0 and lua51 == 0:
print 'Did not find liblua5.1, liblua, lua.lib or lua5.1.lib, compiling anyway!'
env['LUA'] = 0
### Search for zenity if we're not in windows
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin':
@ -85,11 +87,13 @@ else:
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
# parse SDL cflags/libs
env.ParseConfig('sdl-config --cflags --libs')
# parse liblua cflags
if lua51:
env.Append(CPPPATH = ['/usr/local/include/lua5.1', '/usr/include/lua5.1'])
if lua:
env.Append(CPPPATH = ['/usr/local/include/lua', '/usr/include/lua'])
if env['LUA']:
# parse liblua cflags
if lua51:
env.Append(CPPPATH = ['/usr/local/include/lua5.1', '/usr/include/lua5.1'])
if lua:
env.Append(CPPPATH = ['/usr/local/include/lua', '/usr/include/lua'])
env.Append(CPPDEFINES=["_S9XLUA_H"])
env = conf.Finish()
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':

View File

@ -1,5 +1,7 @@
---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
21-aug-2008 - punkrockguy318 - sdl - fixed issue where windowed mode would
always be set to 32 bpp

View File

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

View File

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

View File

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

View File

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

View File

@ -19,7 +19,9 @@
#include "../common/cheat.h"
#include "../../fceu.h"
#include "../../movie.h"
#ifdef _S9XLUA_H
#include "../../fceulua.h"
#endif
#include "input.h"
#include "dface.h"
@ -86,8 +88,7 @@ char *DriverUsage="\
Devices: quizking hypershot mahjong toprider ftrainer\n\
familykeyboard oekakids arkanoid shadow bworld 4player\n\
--inputcfg d Configures input device d on startup (gamepad1, gamepad2).\n\
--playmov f Plays back a recorded movie from filename f.\n\
--loadlua f Loads lua script from filename f.\n";
--playmov f Plays back a recorded movie from filename f.";
/* Moved network options out while netplay is broken.
--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);
puts("Options:");
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
g_config->getOption("SDL.LuaScript", &fname);
g_config->setOption("SDL.LuaScript", "");
@ -487,8 +494,8 @@ SDL_GL_LoadLibrary(0);
{
FCEU_LoadLuaCode(fname.c_str());
}
#endif
// loop playing the game
while(GameInfo) {
DoFun(frameskip);

View File

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

View File

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

View File

@ -32,7 +32,9 @@
#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"
@ -190,13 +192,17 @@ static void UpdateGP(int w, void *data, int arg)
{
if(w==0)
{
#ifdef _S9XLUA_H
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;
#endif
}
else
{
#ifdef _S9XLUA_H
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;
#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_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", },
#endif
{ 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 },

View File

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

View File

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

View File

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

View File

@ -29,7 +29,9 @@
#include "fceu.h"
#include "driver.h"
#include "boards/mapinc.h"
#ifdef _S9XLUA_H
#include "fceulua.h"
#endif
#include "palette.h"
#include "palettes/palettes.h"
@ -110,7 +112,9 @@ void SetNESDeemph(uint8 d, int force)
}
else /* Only set this when palette has changed. */
{
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette();
#endif
r=rtmul[6];
g=rtmul[6];
@ -155,7 +159,9 @@ void SetNESDeemph(uint8 d, int force)
}
lastd=d;
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette();
#endif
}
// 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);
if(GameInfo->type==GIT_NSF)
{
#ifdef _S9XLUA_H
FCEU_LuaUpdatePalette();
#endif
//for(x=0;x<128;x++)
// FCEUD_SetPalette(x,x,0,x);
}

View File

@ -46,7 +46,9 @@
#include "vsuni.h"
#include "drawing.h"
#include "driver.h"
#ifdef _S9XLUA_H
#include "fceulua.h"
#endif
uint8 *XBuf=NULL;
uint8 *XBackBuf=NULL;
@ -204,8 +206,10 @@ void FCEU_PutImage(void)
//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
//Update AVI before overlay stuff is written
if(!FCEUI_EmulationPaused())

View File

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