Pack movie data in memory
[lsnes.git] / include / core / moviefile.hpp
blobab9cfff0683577a6dc8b8813a2c86c0d762f9d20
1 #ifndef _moviefile__hpp__included__
2 #define _moviefile__hpp__included__
4 #include <string>
5 #include <vector>
6 #include <stdexcept>
7 #include <map>
8 #include "controllerframe.hpp"
9 #include "rom.hpp"
12 /**
13 * This structure gives parsed representationg of movie file, as result of decoding or for encoding.
15 struct moviefile
17 /**
18 * This constructor construct movie structure with default settings.
20 * throws std::bad_alloc: Not enough memory.
22 moviefile() throw(std::bad_alloc);
24 /**
25 * This constructor loads a movie/savestate file and fills structure accordingly.
27 * parameter filename: The file to load.
28 * throws std::bad_alloc: Not enough memory.
29 * throws std::runtime_error: Can't load the movie file
31 moviefile(const std::string& filename) throw(std::bad_alloc, std::runtime_error);
33 /**
34 * Reads this movie structure and saves it into file.
36 * parameter filename: The file to save to.
37 * parameter compression: The compression level 0-9. 0 is uncompressed.
38 * throws std::bad_alloc: Not enough memory.
39 * throws std::runtime_error: Can't save the movie file.
41 void save(const std::string& filename, unsigned compression) throw(std::bad_alloc, std::runtime_error);
43 /**
44 * Force loading as corrupt.
46 bool force_corrupt;
47 /**
48 * What is the ROM type and region?
50 gametype_t gametype;
51 /**
52 * What's in port #1?
54 porttype_t port1;
55 /**
56 * What's in port #2?
58 porttype_t port2;
59 /**
60 * Emulator Core version string.
62 std::string coreversion;
63 /**
64 * Name of the game
66 std::string gamename;
67 /**
68 * Project ID (used to identify if two movies are from the same project).
70 std::string projectid;
71 /**
72 * Rerecord count (only saved).
74 std::string rerecords;
75 /**
76 * SHA-256 of main ROM (empty string if none).
78 std::string rom_sha256; //SHA-256 of main ROM.
79 /**
80 * SHA-256 of main ROM XML (empty string if none).
82 std::string romxml_sha256; //SHA-256 of main ROM XML.
83 /**
84 * SHA-256 of slot A ROM (empty string if none).
86 std::string slota_sha256; //SHA-256 of SLOT A ROM.
87 /**
88 * SHA-256 of slot A XML (empty string if none).
90 std::string slotaxml_sha256; //SHA-256 of SLOT A XML.
91 /**
92 * SHA-256 of slot B ROM (empty string if none).
94 std::string slotb_sha256; //SHA-256 of SLOT B ROM.
95 /**
96 * SHA-256 of slot B XML (empty string if none).
98 std::string slotbxml_sha256; //SHA-256 of SLOT B XML.
99 /**
100 * Authors of the run, first in each pair is full name, second is nickname.
102 std::vector<std::pair<std::string, std::string>> authors;
104 * Contents of SRAM on time of initial powerup.
106 std::map<std::string, std::vector<char>> movie_sram;
108 * True if savestate, false if movie.
110 bool is_savestate;
112 * Contents of SRAM on time of savestate (if is_savestate is true).
114 std::map<std::string, std::vector<char>> sram;
116 * Core savestate (if is_savestate is true).
118 std::vector<char> savestate; //Savestate to load (if is_savestate is true).
120 * Host memory (if is_savestate is true).
122 std::vector<char> host_memory;
124 * Screenshot (if is_savestate is true).
126 std::vector<char> screenshot;
128 * Current frame (if is_savestate is true).
130 uint64_t save_frame;
132 * Number of lagged frames (if is_savestate is true).
134 uint64_t lagged_frames;
136 * Poll counters (if is_savestate is true).
138 std::vector<uint32_t> pollcounters;
140 * Compressed rrdata.
142 std::vector<char> c_rrdata;
144 * Input for each (sub)frame.
146 controller_frame_vector input; //Input for each frame.
148 * Current RTC second.
150 int64_t rtc_second;
152 * Current RTC subsecond.
154 int64_t rtc_subsecond;
156 * Movie starting RTC second.
158 int64_t movie_rtc_second;
160 * Movie starting RTC subsecond.
162 int64_t movie_rtc_subsecond;
165 * Get number of frames in movie.
167 * returns: Number of frames.
169 uint64_t get_frame_count() throw();
172 * Get length of the movie
174 * parameter framebias: Number of frames to subtract.
175 * returns: Length of the movie in nanoseconds.
177 uint64_t get_movie_length(uint64_t framebias = 0) throw();
180 #endif