Refactor movie class to library/
[lsnes.git] / src / core / movie.cpp
blobcf901a4e755c4010f509c84199349b230027bf62
1 #include "lsnes.hpp"
3 #include "core/emucore.hpp"
4 #include "core/misc.hpp"
5 #include "core/movie.hpp"
6 #include "core/rom.hpp"
8 #include <stdexcept>
9 #include <cassert>
10 #include <cstring>
11 #include <fstream>
14 movie_logic::movie_logic() throw()
18 movie& movie_logic::get_movie() throw()
20 return mov;
23 long movie_logic::new_frame_starting(bool dont_poll) throw(std::bad_alloc, std::runtime_error)
25 mov.next_frame();
26 controller_frame c = update_controls(false);
27 if(!mov.readonly_mode()) {
28 mov.set_controls(c);
29 if(!dont_poll)
30 mov.set_all_DRDY();
31 if(c.axis3(0, 0, 1)) {
32 long hi = c.axis3(0, 0, 2);
33 long lo = c.axis3(0, 0, 3);
34 mov.commit_reset(hi * 10000 + lo);
36 } else if(!dont_poll)
37 mov.set_all_DRDY();
38 return mov.get_reset_status();
41 short movie_logic::input_poll(unsigned port, unsigned dev, unsigned id) throw(std::bad_alloc, std::runtime_error)
43 if(!mov.get_DRDY(port, dev, id)) {
44 mov.set_controls(update_controls(true));
45 mov.set_all_DRDY();
47 int16_t in = mov.next_input(port, dev, id);
48 //std::cerr << "BSNES asking for (" << port << "," << dev << "," << id << ") (frame "
49 // << mov.get_current_frame() << ") giving " << in << std::endl;
50 return in;