lsnes/include/core/moviefile.hpp

214 lines
4.7 KiB
C++
Raw Normal View History

#ifndef _moviefile__hpp__included__
#define _moviefile__hpp__included__
#include <string>
#include <vector>
#include <stdexcept>
#include <map>
2012-09-08 19:44:45 +03:00
#include "core/controllerframe.hpp"
#include "core/rom.hpp"
#include "core/subtitles.hpp"
/**
* This structure gives parsed representationg of movie file, as result of decoding or for encoding.
*/
struct moviefile
{
/**
* Brief information
*/
struct brief_info
{
brief_info(const std::string& filename);
std::string sysregion;
std::string corename;
std::string projectid;
2013-09-14 16:29:58 +03:00
std::string hash[ROM_SLOT_COUNT];
std::string hashxml[ROM_SLOT_COUNT];
std::string hint[ROM_SLOT_COUNT];
uint64_t current_frame;
uint64_t rerecords;
private:
void binary_io(std::istream& s);
};
/**
* This constructor construct movie structure with default settings.
*
2011-09-16 21:09:22 +03:00
* throws std::bad_alloc: Not enough memory.
*/
moviefile() throw(std::bad_alloc);
/**
* This constructor loads a movie/savestate file and fills structure accordingly.
*
2011-09-16 21:09:22 +03:00
* parameter filename: The file to load.
2013-01-11 22:31:13 +02:00
* parameter romtype: Type of ROM.
2011-09-16 21:09:22 +03:00
* throws std::bad_alloc: Not enough memory.
* throws std::runtime_error: Can't load the movie file
*/
2013-01-11 22:31:13 +02:00
moviefile(const std::string& filename, core_type& romtype) throw(std::bad_alloc, std::runtime_error);
/**
* Reads this movie structure and saves it into file.
*
2011-09-16 21:09:22 +03:00
* parameter filename: The file to save to.
* parameter compression: The compression level 0-9. 0 is uncompressed.
2013-07-29 22:16:23 +03:00
* parameter binary: Save in binary form if true.
2011-09-16 21:09:22 +03:00
* throws std::bad_alloc: Not enough memory.
* throws std::runtime_error: Can't save the movie file.
*/
2013-07-29 22:16:23 +03:00
void save(const std::string& filename, unsigned compression, bool binary) throw(std::bad_alloc,
std::runtime_error);
/**
* Force loading as corrupt.
*/
bool force_corrupt;
/**
2011-09-16 21:09:22 +03:00
* What is the ROM type and region?
*/
core_sysregion* gametype;
/**
2013-01-05 09:19:09 +02:00
* Settings.
*/
2013-01-05 09:19:09 +02:00
std::map<std::string, std::string> settings;
/**
2011-09-16 21:09:22 +03:00
* Emulator Core version string.
*/
std::string coreversion;
/**
2011-09-16 21:09:22 +03:00
* Name of the game
*/
std::string gamename;
/**
2011-09-16 21:09:22 +03:00
* Project ID (used to identify if two movies are from the same project).
*/
std::string projectid;
/**
2011-09-16 21:09:22 +03:00
* Rerecord count (only saved).
*/
std::string rerecords;
/**
* SHA-256 of ROM (empty string if none).
*/
std::string romimg_sha256[ROM_SLOT_COUNT];
/**
* SHA-256 of ROM XML (empty string if none).
*/
std::string romxml_sha256[ROM_SLOT_COUNT];
2013-09-14 16:29:58 +03:00
/**
* ROM name hint (empty string if none).
*/
std::string namehint[ROM_SLOT_COUNT];
/**
2011-09-16 21:09:22 +03:00
* Authors of the run, first in each pair is full name, second is nickname.
*/
std::vector<std::pair<std::string, std::string>> authors;
/**
2011-09-16 21:09:22 +03:00
* Contents of SRAM on time of initial powerup.
*/
std::map<std::string, std::vector<char>> movie_sram;
/**
* Contents of RAM on time of initial powerup.
*/
std::map<std::string, std::vector<char>> ramcontent;
/**
2011-09-16 21:09:22 +03:00
* True if savestate, false if movie.
*/
bool is_savestate;
/**
2011-09-16 21:09:22 +03:00
* Contents of SRAM on time of savestate (if is_savestate is true).
*/
std::map<std::string, std::vector<char>> sram;
/**
2011-09-16 21:09:22 +03:00
* Core savestate (if is_savestate is true).
*/
std::vector<char> savestate; //Savestate to load (if is_savestate is true).
2012-07-20 00:23:40 +03:00
/**
* Anchoring core savestate (if not empty).
*/
std::vector<char> anchor_savestate;
/**
2011-09-16 21:09:22 +03:00
* Host memory (if is_savestate is true).
*/
std::vector<char> host_memory;
/**
2011-09-16 21:09:22 +03:00
* Screenshot (if is_savestate is true).
*/
std::vector<char> screenshot;
/**
* Current frame (if is_savestate is true).
*/
uint64_t save_frame;
/**
* Number of lagged frames (if is_savestate is true).
*/
uint64_t lagged_frames;
/**
* Poll counters (if is_savestate is true).
*/
std::vector<uint32_t> pollcounters;
/**
* Poll flag.
*/
unsigned poll_flag;
/**
* Compressed rrdata.
*/
std::vector<char> c_rrdata;
/**
2011-09-16 21:09:22 +03:00
* Input for each (sub)frame.
*/
controller_frame_vector input; //Input for each frame.
/**
* Current RTC second.
*/
int64_t rtc_second;
/**
* Current RTC subsecond.
*/
int64_t rtc_subsecond;
/**
* Movie starting RTC second.
*/
int64_t movie_rtc_second;
/**
* Movie starting RTC subsecond.
*/
int64_t movie_rtc_subsecond;
/**
* Start paused flag.
*/
bool start_paused;
2012-08-24 20:24:18 +03:00
/**
* Lazy project create flag.
*/
bool lazy_project_create;
2012-09-08 19:44:45 +03:00
/**
* Subtitles.
*/
std::map<moviefile_subtiming, std::string> subtitles;
2013-06-12 22:15:25 +03:00
/**
* Active macros at savestate.
*/
std::map<std::string, uint64_t> active_macros;
/**
2011-09-16 21:09:22 +03:00
* Get number of frames in movie.
*
2011-09-16 21:09:22 +03:00
* returns: Number of frames.
*/
uint64_t get_frame_count() throw();
/**
2011-09-16 21:09:22 +03:00
* Get length of the movie
*
2011-09-16 21:09:22 +03:00
* returns: Length of the movie in nanoseconds.
*/
2012-07-20 00:23:40 +03:00
uint64_t get_movie_length() throw();
2013-07-29 22:16:23 +03:00
private:
void binary_io(std::ostream& stream) throw(std::bad_alloc, std::runtime_error);
void binary_io(std::istream& stream, struct core_type& romtype) throw(std::bad_alloc, std::runtime_error);
};
#endif