commit
b163eb6e0a
|
@ -27,60 +27,43 @@ static bool updateLuaDisplay = false;
|
|||
static bool openLuaKillMsgBox = false;
|
||||
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
|
||||
{
|
||||
int head;
|
||||
int tail;
|
||||
int size;
|
||||
struct luaConsoleOutputLine *line;
|
||||
char *buf;
|
||||
|
||||
luaConsoleOutputBuffer(void)
|
||||
{
|
||||
tail = head = 0;
|
||||
size = 64;
|
||||
size = 4096;
|
||||
|
||||
line = new luaConsoleOutputLine[size];
|
||||
buf = (char*)malloc(size);
|
||||
}
|
||||
|
||||
~luaConsoleOutputBuffer(void)
|
||||
{
|
||||
if ( line )
|
||||
if ( buf )
|
||||
{
|
||||
delete [] line; line = NULL;
|
||||
free(buf); buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void addLine( const char *l )
|
||||
{
|
||||
int i=0;
|
||||
//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;
|
||||
|
||||
if ( head == tail )
|
||||
{
|
||||
tail = (tail + 1) % size;
|
||||
if ( head == tail )
|
||||
{
|
||||
tail = (tail + 1) % size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +332,7 @@ void LuaControlDialog_t::refreshState(void)
|
|||
|
||||
while ( i != outBuf.head )
|
||||
{
|
||||
luaOutputText.append( outBuf.line[i].text );
|
||||
luaOutputText.append( 1, outBuf.buf[i] );
|
||||
|
||||
i = (i + 1) % outBuf.size;
|
||||
}
|
||||
|
|
|
@ -753,7 +753,8 @@ int fceuWrapperInit( int argc, char *argv[] )
|
|||
g_config->setOption("SDL.LuaScript", "");
|
||||
if (s != "")
|
||||
{
|
||||
#ifdef __linux
|
||||
#if defined(__linux) || defined(__APPLE__)
|
||||
|
||||
// Resolve absolute path to file
|
||||
char fullpath[2048];
|
||||
if ( realpath( s.c_str(), fullpath ) != NULL )
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
#include <libgen.h>
|
||||
#elif __APPLE__
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#define SetCurrentDir chdir
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -616,7 +618,12 @@ static int emu_loadrom(lua_State *L)
|
|||
#else
|
||||
const char *nameo2 = luaL_checkstring(L,1);
|
||||
char nameo[2048];
|
||||
strncpy(nameo, nameo2, sizeof(nameo));
|
||||
|
||||
if ( realpath( nameo2, nameo ) == NULL )
|
||||
{
|
||||
strncpy(nameo, nameo2, sizeof(nameo));
|
||||
}
|
||||
//printf("Load ROM: '%s'\n", nameo );
|
||||
if (!LoadGame(nameo, true))
|
||||
{
|
||||
reloadLastGame();
|
||||
|
@ -6183,7 +6190,8 @@ void FCEU_LuaFrameBoundary()
|
|||
*
|
||||
* 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())
|
||||
{
|
||||
return 0;
|
||||
|
@ -6195,13 +6203,11 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) {
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue