2011-09-13 17:50:18 +03:00
|
|
|
#ifndef _moviefile__hpp__included__
|
|
|
|
#define _moviefile__hpp__included__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <map>
|
2012-01-09 21:55:55 +02:00
|
|
|
#include "controllerframe.hpp"
|
2011-09-13 17:50:18 +03:00
|
|
|
#include "rom.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This structure gives parsed representationg of movie file, as result of decoding or for encoding.
|
|
|
|
*/
|
|
|
|
struct moviefile
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* This constructor construct movie structure with default settings.
|
|
|
|
*
|
2011-09-16 21:09:22 +03:00
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
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.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
|
|
|
* throws std::runtime_error: Can't load the movie file
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
moviefile(const std::string& filename) 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.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
|
|
|
* throws std::runtime_error: Can't save the movie file.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void save(const std::string& filename, unsigned compression) throw(std::bad_alloc, std::runtime_error);
|
|
|
|
|
2011-09-18 17:27:03 +03:00
|
|
|
/**
|
|
|
|
* Force loading as corrupt.
|
|
|
|
*/
|
|
|
|
bool force_corrupt;
|
2011-09-13 17:50:18 +03:00
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* What is the ROM type and region?
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
gametype_t gametype;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* What's in port #1?
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
porttype_t port1;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* What's in port #2?
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
porttype_t port2;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Emulator Core version string.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string coreversion;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Name of the game
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string gamename;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Project ID (used to identify if two movies are from the same project).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string projectid;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Rerecord count (only saved).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string rerecords;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of main ROM (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string rom_sha256; //SHA-256 of main ROM.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of main ROM XML (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string romxml_sha256; //SHA-256 of main ROM XML.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of slot A ROM (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string slota_sha256; //SHA-256 of SLOT A ROM.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of slot A XML (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string slotaxml_sha256; //SHA-256 of SLOT A XML.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of slot B ROM (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string slotb_sha256; //SHA-256 of SLOT B ROM.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* SHA-256 of slot B XML (empty string if none).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::string slotbxml_sha256; //SHA-256 of SLOT B XML.
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Authors of the run, first in each pair is full name, second is nickname.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
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.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::map<std::string, std::vector<char>> movie_sram;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* True if savestate, false if movie.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
bool is_savestate;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Contents of SRAM on time of savestate (if is_savestate is true).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::map<std::string, std::vector<char>> sram;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Core savestate (if is_savestate is true).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::vector<char> savestate; //Savestate to load (if is_savestate is true).
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Host memory (if is_savestate is true).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::vector<char> host_memory;
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Screenshot (if is_savestate is true).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::vector<char> screenshot;
|
|
|
|
/**
|
2011-11-24 08:51:25 +02:00
|
|
|
* Current frame (if is_savestate is true).
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
2011-11-24 08:51:25 +02:00
|
|
|
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;
|
2011-09-19 21:45:35 +03:00
|
|
|
/**
|
|
|
|
* Compressed rrdata.
|
|
|
|
*/
|
|
|
|
std::vector<char> c_rrdata;
|
2011-09-13 17:50:18 +03:00
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Input for each (sub)frame.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
2012-01-09 21:55:55 +02:00
|
|
|
controller_frame_vector input; //Input for each frame.
|
2011-09-24 21:05:56 +03:00
|
|
|
/**
|
|
|
|
* 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;
|
2011-09-13 17:50:18 +03:00
|
|
|
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Get number of frames in movie.
|
2011-09-13 17:50:18 +03:00
|
|
|
*
|
2011-09-16 21:09:22 +03:00
|
|
|
* returns: Number of frames.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
uint64_t get_frame_count() throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-16 21:09:22 +03:00
|
|
|
* Get length of the movie
|
2011-09-13 17:50:18 +03:00
|
|
|
*
|
2011-09-19 22:39:58 +03:00
|
|
|
* parameter framebias: Number of frames to subtract.
|
2011-09-16 21:09:22 +03:00
|
|
|
* returns: Length of the movie in nanoseconds.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
2011-09-19 22:39:58 +03:00
|
|
|
uint64_t get_movie_length(uint64_t framebias = 0) throw();
|
2011-09-13 17:50:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|