bool movie.record(string filename, [int save_type, [string author]]) Saves and records a movie.
| 3436 | // |
| 3437 | // Saves and records a movie. |
| 3438 | int movie_record(lua_State *L) { |
| 3439 | int arg_count = lua_gettop(L); |
| 3440 | |
| 3441 | if (arg_count == 0) { |
| 3442 | luaL_error(L, "no parameters specified"); |
| 3443 | return 0; |
| 3444 | } |
| 3445 | |
| 3446 | const char *filename = luaL_checkstring(L,1); |
| 3447 | if (filename == NULL) { |
| 3448 | luaL_error(L, "Filename required"); |
| 3449 | return 0; |
| 3450 | } |
| 3451 | |
| 3452 | // No need to use the full functionality of the enum |
| 3453 | int save_type = arg_count >= 2 ? lua_tointeger(L, 2) : 0; |
| 3454 | EMOVIE_FLAG flags; |
| 3455 | if (save_type == 1) flags = MOVIE_FLAG_NONE; // from savestate |
| 3456 | else if (save_type == 2) flags = MOVIE_FLAG_FROM_SAVERAM; |
| 3457 | else flags = MOVIE_FLAG_FROM_POWERON; |
| 3458 | |
| 3459 | // XXX: Assuming UTF-8 strings in Lua |
| 3460 | std::wstring author = |
| 3461 | arg_count >= 3 ? |
| 3462 | mbstowcs( (std::string)luaL_checkstring(L, 3) ) : L"" |
| 3463 | ; |
| 3464 | |
| 3465 | // Save it! |
| 3466 | FCEUI_SaveMovie(filename, flags, author); |
| 3467 | |
| 3468 | lua_pushboolean(L, 1); |
| 3469 | return 1; |
| 3470 | } |
| 3471 | |
| 3472 | //movie.ispoweron |
| 3473 | // |
nothing calls this directly
no test coverage detected