diff --git a/changelog.txt b/changelog.txt index 3c063032..718aef7e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,5 @@ ---version 2.0.4 yet to be released--- +15-mar-2009 - adelikat - Lua - added movie.rerecordcount() and movie.length() 14-mar-2009 - adelikat - Lua - added movie.active() - returns a bool value based on whether a movie is currently loaded 14-mar-2009 - adelikat - Fixed Joypad.set, it uses 3 values instead of 2 now. True will take control of a button and make it on, False will take control and make it off, and Nil will not take control (allowing the user to press the button) 14-mar-2009 - adelikat - Fix major crash issue where NROM game savestates were writing erroneous information if a non NROM game was loaded prior diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 21082b7f..8ad79bb4 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -939,7 +939,7 @@ static int movie_stop(lua_State *L) { // movie.active() // -//returns a bool value is there is a movie currently opn +//returns a bool value is there is a movie currently open int movie_active (lua_State *L) { bool movieactive = (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()); @@ -947,6 +947,31 @@ int movie_active (lua_State *L) { return 1; } +//movie.rerecordcount() +// +//returns the rerecord count of the current movie +static int movie_rerecordcount (lua_State *L) { + if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying()) + luaL_error(L, "No movie loaded."); + + lua_pushinteger(L, FCEUI_GetMovieRerecordCount()); + + return 1; +} + +//movie.length() +// +//returns an int value representing the total length of the current movie loaded + +static int movie_length (lua_State *L) { + if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying()) + luaL_error(L, "No movie loaded."); + + lua_pushinteger(L, FCEUI_GetMovieLength()); + + return 1; +} + // Common code by the gui library: make sure the screen array is ready static void gui_prepare() { if (!gui_data) @@ -1851,6 +1876,8 @@ static const struct luaL_reg movielib[] = { {"rerecordcounting", movie_rerecordcounting}, {"stop", movie_stop}, {"active", movie_active}, + {"length", movie_length}, + {"rerecordcount", movie_rerecordcount}, // {"record", movie_record}, // {"playback", movie_playback}, diff --git a/src/movie.cpp b/src/movie.cpp index 899dc60f..0d8340c9 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1149,6 +1149,16 @@ void FCEUI_ToggleInputDisplay(void) } } +int FCEUI_GetMovieLength() +{ + return currMovieData.records.size(); +} + +int FCEUI_GetMovieRerecordCount() +{ + return currMovieData.rerecordCount; +} + bool FCEUI_GetMovieToggleReadOnly() { return movie_readonly; diff --git a/src/movie.h b/src/movie.h index 0583f5d7..d3a9f332 100644 --- a/src/movie.h +++ b/src/movie.h @@ -250,6 +250,8 @@ bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount = fa char* FCEUI_MovieGetCurrentName(int addSlotNumber); void FCEUI_MovieToggleReadOnly(void); bool FCEUI_GetMovieToggleReadOnly(); +int FCEUI_GetMovieLength(); +int FCEUI_GetMovieRerecordCount(); void FCEUI_MovieToggleFrameDisplay(); void FCEUI_ToggleInputDisplay(void);