commit
b163eb6e0a
|
@ -27,54 +27,36 @@ static bool updateLuaDisplay = false;
|
||||||
static bool openLuaKillMsgBox = false;
|
static bool openLuaKillMsgBox = false;
|
||||||
static int luaKillMsgBoxRetVal = 0;
|
static int luaKillMsgBoxRetVal = 0;
|
||||||
|
|
||||||
struct luaConsoleOutputLine
|
|
||||||
{
|
|
||||||
char text[256];
|
|
||||||
|
|
||||||
luaConsoleOutputLine(void)
|
|
||||||
{
|
|
||||||
memset( text, 0, sizeof(text) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear(void)
|
|
||||||
{
|
|
||||||
memset( text, 0, sizeof(text) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void setText( const char *txt )
|
|
||||||
{
|
|
||||||
strncpy( text, txt, sizeof(text)-1 );
|
|
||||||
text[sizeof(text)-1] = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct luaConsoleOutputBuffer
|
struct luaConsoleOutputBuffer
|
||||||
{
|
{
|
||||||
int head;
|
int head;
|
||||||
int tail;
|
int tail;
|
||||||
int size;
|
int size;
|
||||||
struct luaConsoleOutputLine *line;
|
char *buf;
|
||||||
|
|
||||||
luaConsoleOutputBuffer(void)
|
luaConsoleOutputBuffer(void)
|
||||||
{
|
{
|
||||||
tail = head = 0;
|
tail = head = 0;
|
||||||
size = 64;
|
size = 4096;
|
||||||
|
|
||||||
line = new luaConsoleOutputLine[size];
|
buf = (char*)malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
~luaConsoleOutputBuffer(void)
|
~luaConsoleOutputBuffer(void)
|
||||||
{
|
{
|
||||||
if ( line )
|
if ( buf )
|
||||||
{
|
{
|
||||||
delete [] line; line = NULL;
|
free(buf); buf = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLine( const char *l )
|
void addLine( const char *l )
|
||||||
{
|
{
|
||||||
|
int i=0;
|
||||||
//printf("Adding Line %i: '%s'\n", head, l );
|
//printf("Adding Line %i: '%s'\n", head, l );
|
||||||
line[head].setText( l );
|
while ( l[i] != 0 )
|
||||||
|
{
|
||||||
|
buf[head] = l[i]; i++;
|
||||||
|
|
||||||
head = (head + 1) % size;
|
head = (head + 1) % size;
|
||||||
|
|
||||||
|
@ -83,6 +65,7 @@ struct luaConsoleOutputBuffer
|
||||||
tail = (tail + 1) % size;
|
tail = (tail + 1) % size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clear(void)
|
void clear(void)
|
||||||
{
|
{
|
||||||
|
@ -349,7 +332,7 @@ void LuaControlDialog_t::refreshState(void)
|
||||||
|
|
||||||
while ( i != outBuf.head )
|
while ( i != outBuf.head )
|
||||||
{
|
{
|
||||||
luaOutputText.append( outBuf.line[i].text );
|
luaOutputText.append( 1, outBuf.buf[i] );
|
||||||
|
|
||||||
i = (i + 1) % outBuf.size;
|
i = (i + 1) % outBuf.size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -753,7 +753,8 @@ int fceuWrapperInit( int argc, char *argv[] )
|
||||||
g_config->setOption("SDL.LuaScript", "");
|
g_config->setOption("SDL.LuaScript", "");
|
||||||
if (s != "")
|
if (s != "")
|
||||||
{
|
{
|
||||||
#ifdef __linux
|
#if defined(__linux) || defined(__APPLE__)
|
||||||
|
|
||||||
// Resolve absolute path to file
|
// Resolve absolute path to file
|
||||||
char fullpath[2048];
|
char fullpath[2048];
|
||||||
if ( realpath( s.c_str(), fullpath ) != NULL )
|
if ( realpath( s.c_str(), fullpath ) != NULL )
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
|
#define SetCurrentDir chdir
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -616,7 +618,12 @@ static int emu_loadrom(lua_State *L)
|
||||||
#else
|
#else
|
||||||
const char *nameo2 = luaL_checkstring(L,1);
|
const char *nameo2 = luaL_checkstring(L,1);
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
|
|
||||||
|
if ( realpath( nameo2, nameo ) == NULL )
|
||||||
|
{
|
||||||
strncpy(nameo, nameo2, sizeof(nameo));
|
strncpy(nameo, nameo2, sizeof(nameo));
|
||||||
|
}
|
||||||
|
//printf("Load ROM: '%s'\n", nameo );
|
||||||
if (!LoadGame(nameo, true))
|
if (!LoadGame(nameo, true))
|
||||||
{
|
{
|
||||||
reloadLastGame();
|
reloadLastGame();
|
||||||
|
@ -6183,7 +6190,8 @@ void FCEU_LuaFrameBoundary()
|
||||||
*
|
*
|
||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
int FCEU_LoadLuaCode(const char *filename, const char *arg) {
|
int FCEU_LoadLuaCode(const char *filename, const char *arg)
|
||||||
|
{
|
||||||
if (!DemandLua())
|
if (!DemandLua())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -6195,13 +6203,11 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) {
|
||||||
luaScriptName = strdup(filename);
|
luaScriptName = strdup(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) || defined(__linux)
|
|
||||||
std::string getfilepath = filename;
|
std::string getfilepath = filename;
|
||||||
|
|
||||||
getfilepath = getfilepath.substr(0,getfilepath.find_last_of("/\\") + 1);
|
getfilepath = getfilepath.substr(0,getfilepath.find_last_of("/\\") + 1);
|
||||||
|
|
||||||
SetCurrentDir(getfilepath.c_str());
|
SetCurrentDir(getfilepath.c_str());
|
||||||
#endif
|
|
||||||
|
|
||||||
//stop any lua we might already have had running
|
//stop any lua we might already have had running
|
||||||
FCEU_LuaStop();
|
FCEU_LuaStop();
|
||||||
|
|
Loading…
Reference in New Issue