Reorganize the window code a bit
[lsnes.git] / generic / moviefile.hpp
blob84b2a78ad2d060b9ca8b0f6513a3c72853f9d98c
1 #ifndef _moviefile__hpp__included__
2 #define _moviefile__hpp__included__
4 #include <string>
5 #include <vector>
6 #include <stdexcept>
7 #include <map>
8 #include "controllerdata.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 * State of movie code (if is_savestate is true).
130 std::vector<char> movie_state;
132 * Compressed rrdata.
134 std::vector<char> c_rrdata;
136 * Input for each (sub)frame.
138 std::vector<controls_t> input; //Input for each frame.
140 * Current RTC second.
142 int64_t rtc_second;
144 * Current RTC subsecond.
146 int64_t rtc_subsecond;
148 * Movie starting RTC second.
150 int64_t movie_rtc_second;
152 * Movie starting RTC subsecond.
154 int64_t movie_rtc_subsecond;
157 * Get number of frames in movie.
159 * returns: Number of frames.
161 uint64_t get_frame_count() throw();
164 * Get length of the movie
166 * parameter framebias: Number of frames to subtract.
167 * returns: Length of the movie in nanoseconds.
169 uint64_t get_movie_length(uint64_t framebias = 0) throw();
172 #endif