enabling some more Lua functionality (like input.get().x/y, movie.replay(), emu.emulating())
This commit is contained in:
parent
54193cc623
commit
17d4b20115
|
@ -138,7 +138,7 @@ static const char* luaCallIDStrings [] =
|
||||||
};
|
};
|
||||||
static const int _makeSureWeHaveTheRightNumberOfStrings [sizeof(luaCallIDStrings)/sizeof(*luaCallIDStrings) == LUACALL_COUNT ? 1 : 0];
|
static const int _makeSureWeHaveTheRightNumberOfStrings [sizeof(luaCallIDStrings)/sizeof(*luaCallIDStrings) == LUACALL_COUNT ? 1 : 0];
|
||||||
|
|
||||||
static const char* luaMemHookTypeStrings [] =
|
/*static const char* luaMemHookTypeStrings [] =
|
||||||
{
|
{
|
||||||
"MEMHOOK_WRITE",
|
"MEMHOOK_WRITE",
|
||||||
"MEMHOOK_READ",
|
"MEMHOOK_READ",
|
||||||
|
@ -149,6 +149,7 @@ static const char* luaMemHookTypeStrings [] =
|
||||||
"MEMHOOK_EXEC_SUB",
|
"MEMHOOK_EXEC_SUB",
|
||||||
};
|
};
|
||||||
static const int _makeSureWeHaveTheRightNumberOfStrings2 [sizeof(luaMemHookTypeStrings)/sizeof(*luaMemHookTypeStrings) == LUAMEMHOOK_COUNT ? 1 : 0];
|
static const int _makeSureWeHaveTheRightNumberOfStrings2 [sizeof(luaMemHookTypeStrings)/sizeof(*luaMemHookTypeStrings) == LUAMEMHOOK_COUNT ? 1 : 0];
|
||||||
|
*/
|
||||||
|
|
||||||
void StopScriptIfFinished(int uid, bool justReturned = false);
|
void StopScriptIfFinished(int uid, bool justReturned = false);
|
||||||
void SetSaveKey(LuaContextInfo& info, const char* key);
|
void SetSaveKey(LuaContextInfo& info, const char* key);
|
||||||
|
@ -159,6 +160,9 @@ void RefreshScriptSpeedStatus();
|
||||||
static char* rawToCString(lua_State* L, int idx=0);
|
static char* rawToCString(lua_State* L, int idx=0);
|
||||||
static const char* toCString(lua_State* L, int idx=0);
|
static const char* toCString(lua_State* L, int idx=0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// disabled, see comment above implementation of CalculateMemHookRegions
|
||||||
|
|
||||||
static void CalculateMemHookRegions(LuaMemHookType hookType);
|
static void CalculateMemHookRegions(LuaMemHookType hookType);
|
||||||
|
|
||||||
static int memory_registerHook(lua_State* L, LuaMemHookType hookType, int defaultSize)
|
static int memory_registerHook(lua_State* L, LuaMemHookType hookType, int defaultSize)
|
||||||
|
@ -266,7 +270,7 @@ DEFINE_LUA_FUNCTION(memory_registerexec, "address,[size=2,][cpuname=\"main\",]fu
|
||||||
{
|
{
|
||||||
return memory_registerHook(L, MatchHookTypeToCPU(L,LUAMEMHOOK_EXEC), 2);
|
return memory_registerHook(L, MatchHookTypeToCPU(L,LUAMEMHOOK_EXEC), 2);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
DEFINE_LUA_FUNCTION(emu_registerbefore, "func")
|
DEFINE_LUA_FUNCTION(emu_registerbefore, "func")
|
||||||
{
|
{
|
||||||
|
@ -2721,6 +2725,8 @@ DEFINE_LUA_FUNCTION(emu_openscript, "filename")
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
/*
|
/*
|
||||||
DEFINE_LUA_FUNCTION(gens_loadrom, "filename")
|
DEFINE_LUA_FUNCTION(gens_loadrom, "filename")
|
||||||
{
|
{
|
||||||
|
@ -2749,17 +2755,18 @@ DEFINE_LUA_FUNCTION(emu_lagged, "")
|
||||||
{
|
{
|
||||||
lua_pushboolean(L, LagFrameFlag);
|
lua_pushboolean(L, LagFrameFlag);
|
||||||
return 1;
|
return 1;
|
||||||
}/*
|
}
|
||||||
DEFINE_LUA_FUNCTION(gens_emulating, "")
|
DEFINE_LUA_FUNCTION(emu_emulating, "")
|
||||||
{
|
{
|
||||||
lua_pushboolean(L, Genesis_Started||SegaCD_Started||_32X_Started);
|
lua_pushboolean(L, romloaded);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DEFINE_LUA_FUNCTION(gens_atframeboundary, "")
|
DEFINE_LUA_FUNCTION(emu_atframeboundary, "")
|
||||||
{
|
{
|
||||||
lua_pushboolean(L, !Inside_Frame);
|
// TODO (actually this is a full implementation currently since registermemory callbacks are disabled)
|
||||||
|
lua_pushboolean(L, true);
|
||||||
return 1;
|
return 1;
|
||||||
}*/
|
}
|
||||||
DEFINE_LUA_FUNCTION(movie_getlength, "")
|
DEFINE_LUA_FUNCTION(movie_getlength, "")
|
||||||
{
|
{
|
||||||
lua_pushinteger(L, currMovieData.records.size());
|
lua_pushinteger(L, currMovieData.records.size());
|
||||||
|
@ -2774,12 +2781,12 @@ DEFINE_LUA_FUNCTION(movie_rerecordcount, "")
|
||||||
{
|
{
|
||||||
lua_pushinteger(L, currMovieData.rerecordCount);
|
lua_pushinteger(L, currMovieData.rerecordCount);
|
||||||
return 1;
|
return 1;
|
||||||
}/*
|
}
|
||||||
DEFINE_LUA_FUNCTION(movie_setrerecordcount, "")
|
DEFINE_LUA_FUNCTION(movie_setrerecordcount, "")
|
||||||
{
|
{
|
||||||
MainMovie.NbRerecords = luaL_checkinteger(L, 1);
|
currMovieData.rerecordCount = luaL_checkinteger(L, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}*/
|
}
|
||||||
DEFINE_LUA_FUNCTION(emu_rerecordcounting, "[enabled]")
|
DEFINE_LUA_FUNCTION(emu_rerecordcounting, "[enabled]")
|
||||||
{
|
{
|
||||||
LuaContextInfo& info = GetCurrentInfo();
|
LuaContextInfo& info = GetCurrentInfo();
|
||||||
|
@ -2854,30 +2861,29 @@ DEFINE_LUA_FUNCTION(movie_getname, "")
|
||||||
DEFINE_LUA_FUNCTION(movie_play, "[filename]")
|
DEFINE_LUA_FUNCTION(movie_play, "[filename]")
|
||||||
{
|
{
|
||||||
const char* filename = lua_isstring(L,1) ? lua_tostring(L,1) : NULL;
|
const char* filename = lua_isstring(L,1) ? lua_tostring(L,1) : NULL;
|
||||||
FCEUI_LoadMovie(filename, true, false, 0);
|
const char* errorMsg = FCEUI_LoadMovie(filename, true, false, 0);
|
||||||
// const char* errorMsg =
|
if(errorMsg)
|
||||||
// if(errorMsg)
|
luaL_error(L, errorMsg);
|
||||||
// luaL_error(L, errorMsg);
|
|
||||||
return 0;
|
return 0;
|
||||||
} /*
|
}
|
||||||
DEFINE_LUA_FUNCTION(movie_replay, "")
|
DEFINE_LUA_FUNCTION(movie_replay, "")
|
||||||
{
|
{
|
||||||
if(MainMovie.File)
|
if(movieMode == MOVIEMODE_INACTIVE)
|
||||||
GensReplayMovie();
|
return 0;
|
||||||
else
|
lua_settop(L, 0);
|
||||||
luaL_error(L, "it is invalid to call movie.replay when no movie open.");
|
extern char curMovieFilename[512];
|
||||||
return 0;
|
lua_pushstring(L, curMovieFilename);
|
||||||
} */
|
return movie_play(L);
|
||||||
|
}
|
||||||
DEFINE_LUA_FUNCTION(movie_close, "")
|
DEFINE_LUA_FUNCTION(movie_close, "")
|
||||||
{
|
{
|
||||||
|
|
||||||
FCEUI_StopMovie();
|
FCEUI_StopMovie();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_LUA_FUNCTION(sound_clear, "")
|
DEFINE_LUA_FUNCTION(sound_clear, "")
|
||||||
{
|
{
|
||||||
// Clear_Sound_Buffer();
|
if(SPU_user) SPU_user->ShutUp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3043,20 +3049,18 @@ DEFINE_LUA_FUNCTION(input_getcurrentinputstatus, "")
|
||||||
}
|
}
|
||||||
// mouse position in game screen pixel coordinates
|
// mouse position in game screen pixel coordinates
|
||||||
{
|
{
|
||||||
/* POINT point;
|
void UnscaleScreenCoords(s32& x, s32& y);
|
||||||
RECT rect, srcRectUnused;
|
void ToDSScreenRelativeCoords(s32& x, s32& y, bool bottomScreen);
|
||||||
float xRatioUnused, yRatioUnused;
|
|
||||||
int depUnused;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
ScreenToClient(MainWindow->getHWnd(), &point);
|
ScreenToClient(MainWindow->getHWnd(), &point);
|
||||||
GetClientRect(MainWindow->getHWnd(), &rect);
|
s32 x (point.x);
|
||||||
void CalculateDrawArea(int Render_Mode, RECT& RectDest, RECT& RectSrc, float& Ratio_X, float& Ratio_Y, int& Dep);
|
s32 y (point.y);
|
||||||
CalculateDrawArea(Full_Screen ? Render_FS : Render_W, rect, srcRectUnused, xRatioUnused, yRatioUnused, depUnused);
|
|
||||||
int xres = ((VDP_Reg.Set4 & 0x1) || Debug || !Game || !FrameCount) ? 320 : 256;
|
UnscaleScreenCoords(x,y);
|
||||||
int yres = ((VDP_Reg.Set2 & 0x8) && !(Debug || !Game || !FrameCount)) ? 240 : 224;
|
ToDSScreenRelativeCoords(x,y,false);
|
||||||
int x = ((point.x - rect.left) * xres) / max(1, rect.right - rect.left);
|
|
||||||
int y = ((point.y - rect.top) * yres) / max(1, rect.bottom - rect.top);*/
|
|
||||||
int x = 0, y = 0;
|
|
||||||
lua_pushinteger(L, x);
|
lua_pushinteger(L, x);
|
||||||
lua_setfield(L, -2, "xmouse");
|
lua_setfield(L, -2, "xmouse");
|
||||||
lua_pushinteger(L, y);
|
lua_pushinteger(L, y);
|
||||||
|
@ -3323,6 +3327,8 @@ static const struct luaL_reg aggcustom [] =
|
||||||
//
|
//
|
||||||
// Displays the given text on the screen, using the same font and techniques as the
|
// Displays the given text on the screen, using the same font and techniques as the
|
||||||
// main HUD.
|
// main HUD.
|
||||||
|
//
|
||||||
|
// TODO: this incomplete... it should support color and outline color and a much smaller font size
|
||||||
static int gui_text(lua_State *L) {
|
static int gui_text(lua_State *L) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -3372,6 +3378,7 @@ static const struct luaL_reg styluslib [] =
|
||||||
|
|
||||||
static const struct luaL_reg emulib [] =
|
static const struct luaL_reg emulib [] =
|
||||||
{
|
{
|
||||||
|
// TODO!
|
||||||
// {"frameadvance", emu_frameadvance},
|
// {"frameadvance", emu_frameadvance},
|
||||||
// {"speedmode", emu_speedmode},
|
// {"speedmode", emu_speedmode},
|
||||||
// {"wait", emu_wait},
|
// {"wait", emu_wait},
|
||||||
|
@ -3385,8 +3392,8 @@ static const struct luaL_reg emulib [] =
|
||||||
{"framecount", emu_getframecount},
|
{"framecount", emu_getframecount},
|
||||||
{"lagcount", emu_getlagcount},
|
{"lagcount", emu_getlagcount},
|
||||||
{"lagged", emu_lagged},
|
{"lagged", emu_lagged},
|
||||||
// {"emulating", emu_emulating},
|
{"emulating", emu_emulating},
|
||||||
// {"atframeboundary", emu_atframeboundary},
|
{"atframeboundary", emu_atframeboundary},
|
||||||
{"registerbefore", emu_registerbefore},
|
{"registerbefore", emu_registerbefore},
|
||||||
{"registerafter", emu_registerafter},
|
{"registerafter", emu_registerafter},
|
||||||
// {"registerstart", emu_registerstart},
|
// {"registerstart", emu_registerstart},
|
||||||
|
@ -3514,7 +3521,7 @@ static const struct luaL_reg movielib [] =
|
||||||
{"length", movie_getlength},
|
{"length", movie_getlength},
|
||||||
{"name", movie_getname},
|
{"name", movie_getname},
|
||||||
{"rerecordcount", movie_rerecordcount},
|
{"rerecordcount", movie_rerecordcount},
|
||||||
// {"setrerecordcount", movie_setrerecordcount},
|
{"setrerecordcount", movie_setrerecordcount},
|
||||||
|
|
||||||
{"rerecordcounting", emu_rerecordcounting},
|
{"rerecordcounting", emu_rerecordcounting},
|
||||||
{"readonly", movie_getreadonly},
|
{"readonly", movie_getreadonly},
|
||||||
|
@ -3522,7 +3529,7 @@ static const struct luaL_reg movielib [] =
|
||||||
{"framecount", emu_getframecount}, // for those familiar with other emulators that have movie.framecount() instead of emulatorname.framecount()
|
{"framecount", emu_getframecount}, // for those familiar with other emulators that have movie.framecount() instead of emulatorname.framecount()
|
||||||
|
|
||||||
{"play", movie_play},
|
{"play", movie_play},
|
||||||
// {"replay", movie_replay},
|
{"replay", movie_replay},
|
||||||
{"stop", movie_close},
|
{"stop", movie_close},
|
||||||
|
|
||||||
// alternative names
|
// alternative names
|
||||||
|
@ -3535,7 +3542,7 @@ static const struct luaL_reg movielib [] =
|
||||||
};
|
};
|
||||||
static const struct luaL_reg soundlib [] =
|
static const struct luaL_reg soundlib [] =
|
||||||
{
|
{
|
||||||
// {"clear", sound_clear},
|
{"clear", sound_clear},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3765,13 +3772,14 @@ void registerLibs(lua_State* L)
|
||||||
}
|
}
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// push arrays for storing hook functions in
|
// push arrays for storing hook functions in
|
||||||
for(int i = 0; i < LUAMEMHOOK_COUNT; i++)
|
for(int i = 0; i < LUAMEMHOOK_COUNT; i++)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_setfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[i]);
|
lua_setfield(L, LUA_REGISTRYINDEX, luaMemHookTypeStrings[i]);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetInfo(LuaContextInfo& info)
|
void ResetInfo(LuaContextInfo& info)
|
||||||
|
@ -4152,8 +4160,10 @@ void StopLuaScript(int uid)
|
||||||
info.started = false;
|
info.started = false;
|
||||||
|
|
||||||
info.numMemHooks = 0;
|
info.numMemHooks = 0;
|
||||||
|
/*
|
||||||
for(int i = 0; i < LUAMEMHOOK_COUNT; i++)
|
for(int i = 0; i < LUAMEMHOOK_COUNT; i++)
|
||||||
CalculateMemHookRegions((LuaMemHookType)i);
|
CalculateMemHookRegions((LuaMemHookType)i);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
RefreshScriptStartedStatus();
|
RefreshScriptStartedStatus();
|
||||||
}
|
}
|
||||||
|
@ -4166,7 +4176,7 @@ void CloseLuaContext(int uid)
|
||||||
luaContextInfo.erase(uid);
|
luaContextInfo.erase(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// the purpose of this structure is to provide a way of
|
// the purpose of this structure is to provide a way of
|
||||||
// QUICKLY determining whether a memory address range has a hook associated with it,
|
// 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.
|
// with a bias toward fast rejection because the majority of addresses will not be hooked.
|
||||||
|
@ -4253,6 +4263,10 @@ struct TieredRegion
|
||||||
TieredRegion hookedRegions [LUAMEMHOOK_COUNT];
|
TieredRegion hookedRegions [LUAMEMHOOK_COUNT];
|
||||||
|
|
||||||
|
|
||||||
|
// currently disabled for desmume,
|
||||||
|
// and the performance hit might not be accepable
|
||||||
|
// unless we can switch the emulation into a whole separate path
|
||||||
|
// that has this callback enabled.
|
||||||
static void CalculateMemHookRegions(LuaMemHookType hookType)
|
static void CalculateMemHookRegions(LuaMemHookType hookType)
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> hookedBytes;
|
std::vector<unsigned int> hookedBytes;
|
||||||
|
@ -4339,6 +4353,7 @@ static void CallRegisteredLuaMemHook_LuaMatch(unsigned int address, int size, un
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType)
|
void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType)
|
||||||
{
|
{
|
||||||
// performance critical! (called VERY frequently)
|
// performance critical! (called VERY frequently)
|
||||||
|
@ -4354,7 +4369,7 @@ void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value
|
||||||
CallRegisteredLuaMemHook_LuaMatch(address, size, value, hookType); // something has hooked this specific address
|
CallRegisteredLuaMemHook_LuaMatch(address, size, value, hookType); // something has hooked this specific address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void CallRegisteredLuaFunctions(LuaCallID calltype)
|
void CallRegisteredLuaFunctions(LuaCallID calltype)
|
||||||
|
|
|
@ -407,12 +407,16 @@ void FCEUI_StopMovie()
|
||||||
|
|
||||||
|
|
||||||
//begin playing an existing movie
|
//begin playing an existing movie
|
||||||
void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe)
|
const char* _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe)
|
||||||
{
|
{
|
||||||
//if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE))
|
//if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE))
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
// FIXME: name==null indicates to BROWSE to retrieve fname from user (or stdin if that's impossible),
|
||||||
|
// when called from movie_play
|
||||||
assert(fname);
|
assert(fname);
|
||||||
|
if(!fname)
|
||||||
|
return "LoadMovie doesn't support browsing yet";
|
||||||
|
|
||||||
//mbg 6/10/08 - we used to call StopMovie here, but that cleared curMovieFilename and gave us crashes...
|
//mbg 6/10/08 - we used to call StopMovie here, but that cleared curMovieFilename and gave us crashes...
|
||||||
if(movieMode == MOVIEMODE_PLAY)
|
if(movieMode == MOVIEMODE_PLAY)
|
||||||
|
@ -433,12 +437,13 @@ void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, i
|
||||||
|
|
||||||
//LoadFM2(currMovieData, fp->stream, INT_MAX, false);
|
//LoadFM2(currMovieData, fp->stream, INT_MAX, false);
|
||||||
|
|
||||||
|
bool loadedfm2 = false;
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
{
|
{
|
||||||
fstream fs (fname);
|
fstream fs (fname);
|
||||||
if(fs.is_open())
|
if(fs.is_open())
|
||||||
{
|
{
|
||||||
LoadFM2(currMovieData, &fs, INT_MAX, false);
|
loadedfm2 = LoadFM2(currMovieData, &fs, INT_MAX, false);
|
||||||
opened = true;
|
opened = true;
|
||||||
}
|
}
|
||||||
fs.close();
|
fs.close();
|
||||||
|
@ -447,10 +452,13 @@ void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, i
|
||||||
{
|
{
|
||||||
// for some reason fs.open doesn't work, it has to be a whole new fstream object
|
// for some reason fs.open doesn't work, it has to be a whole new fstream object
|
||||||
fstream fs (fname, std::ios_base::in);
|
fstream fs (fname, std::ios_base::in);
|
||||||
LoadFM2(currMovieData, &fs, INT_MAX, false);
|
loadedfm2 = LoadFM2(currMovieData, &fs, INT_MAX, false);
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!loadedfm2)
|
||||||
|
return "failed to load movie";
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//fully reload the game to reinitialize everything before playing any movie
|
//fully reload the game to reinitialize everything before playing any movie
|
||||||
//poweron(true);
|
//poweron(true);
|
||||||
|
@ -478,7 +486,7 @@ void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, i
|
||||||
if(currMovieData.sram.size() != 0)
|
if(currMovieData.sram.size() != 0)
|
||||||
{
|
{
|
||||||
bool success = MovieData::loadSramFrom(&currMovieData.sram);
|
bool success = MovieData::loadSramFrom(&currMovieData.sram);
|
||||||
if(!success) return;
|
if(!success) return "failed to load sram";
|
||||||
}
|
}
|
||||||
freshMovie = true;
|
freshMovie = true;
|
||||||
ClearAutoHold();
|
ClearAutoHold();
|
||||||
|
@ -487,6 +495,8 @@ void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, i
|
||||||
driver->USR_InfoMessage("Replay started Read-Only.");
|
driver->USR_InfoMessage("Replay started Read-Only.");
|
||||||
else
|
else
|
||||||
driver->USR_InfoMessage("Replay started Read+Write.");
|
driver->USR_InfoMessage("Replay started Read+Write.");
|
||||||
|
|
||||||
|
return NULL; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openRecordingMovie(const char* fname)
|
static void openRecordingMovie(const char* fname)
|
||||||
|
|
|
@ -194,7 +194,7 @@ extern bool movie_reset_command;
|
||||||
|
|
||||||
bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount);
|
bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount);
|
||||||
void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname);
|
void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname);
|
||||||
void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe);
|
const char* _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); // returns NULL on success, errmsg on failure
|
||||||
void FCEUI_StopMovie();
|
void FCEUI_StopMovie();
|
||||||
void FCEUMOV_AddInputState();
|
void FCEUMOV_AddInputState();
|
||||||
void FCEUMOV_HandlePlayback();
|
void FCEUMOV_HandlePlayback();
|
||||||
|
|
|
@ -439,6 +439,34 @@ void SetMinWindowSize()
|
||||||
MainWindow->setMinSize(video.rotatedwidthgap(), video.rotatedheightgap());
|
MainWindow->setMinSize(video.rotatedwidthgap(), video.rotatedheightgap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnscaleScreenCoords(s32& x, s32& y)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
HWND hwnd = MainWindow->getHWnd();
|
||||||
|
GetClientRect(hwnd,&r);
|
||||||
|
SetCapture(hwnd);
|
||||||
|
int defwidth = video.width, defheight = (video.height+video.screengap);
|
||||||
|
int winwidth = (r.right-r.left), winheight = (r.bottom-r.top);
|
||||||
|
|
||||||
|
// translate from scaling (screen resolution to 256x384 or 512x192)
|
||||||
|
switch (video.rotation)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 180:
|
||||||
|
x = (x*defwidth) / winwidth;
|
||||||
|
y = (y*defheight) / winheight;
|
||||||
|
break ;
|
||||||
|
case 90:
|
||||||
|
case 270:
|
||||||
|
x = (x*defheight) / winwidth;
|
||||||
|
y = (y*defwidth) / winheight;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = x/video.ratio();
|
||||||
|
y = y/video.ratio();
|
||||||
|
}
|
||||||
|
|
||||||
// input x,y should be windows client-space coords already at 1x scaling.
|
// input x,y should be windows client-space coords already at 1x scaling.
|
||||||
// output is in pixels relative to the top-left of the chosen screen.
|
// output is in pixels relative to the top-left of the chosen screen.
|
||||||
// the gap between screens (if any) is subtracted away from the output y.
|
// the gap between screens (if any) is subtracted away from the output y.
|
||||||
|
@ -3065,31 +3093,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
if (wParam & MK_LBUTTON)
|
if (wParam & MK_LBUTTON)
|
||||||
{
|
{
|
||||||
RECT r ;
|
|
||||||
s32 x = (s32)((s16)LOWORD(lParam));
|
s32 x = (s32)((s16)LOWORD(lParam));
|
||||||
s32 y = (s32)((s16)HIWORD(lParam));
|
s32 y = (s32)((s16)HIWORD(lParam));
|
||||||
GetClientRect(hwnd,&r);
|
|
||||||
SetCapture(hwnd);
|
|
||||||
int defwidth = video.width, defheight = (video.height+video.screengap);
|
|
||||||
int winwidth = (r.right-r.left), winheight = (r.bottom-r.top);
|
|
||||||
|
|
||||||
// translate from scaling (screen resolution to 256x384 or 512x192)
|
UnscaleScreenCoords(x,y);
|
||||||
switch (video.rotation)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 180:
|
|
||||||
x = (x*defwidth) / winwidth;
|
|
||||||
y = (y*defheight) / winheight;
|
|
||||||
break ;
|
|
||||||
case 90:
|
|
||||||
case 270:
|
|
||||||
x = (x*defheight) / winwidth;
|
|
||||||
y = (y*defwidth) / winheight;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = x/video.ratio();
|
|
||||||
y = y/video.ratio();
|
|
||||||
|
|
||||||
if(HudEditorMode)
|
if(HudEditorMode)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue