1 #include "core/instance.hpp"
2 #include "core/messages.hpp"
3 #include "core/movie.hpp"
4 #include "core/runmode.hpp"
9 const uint64_t QUIT_MAGIC
= 0x87dd4df349e5eff7ULL
;
12 const uint64_t emulator_runmode::QUIT
= 1;
13 const uint64_t emulator_runmode::NORMAL
= 2;
14 const uint64_t emulator_runmode::LOAD
= 4;
15 const uint64_t emulator_runmode::ADVANCE_FRAME
= 8;
16 const uint64_t emulator_runmode::ADVANCE_SUBFRAME
= 16;
17 const uint64_t emulator_runmode::SKIPLAG
= 32;
18 const uint64_t emulator_runmode::SKIPLAG_PENDING
= 64;
19 const uint64_t emulator_runmode::PAUSE
= 128;
20 const uint64_t emulator_runmode::PAUSE_BREAK
= 256;
21 const uint64_t emulator_runmode::CORRUPT
= 512;
23 const unsigned emulator_runmode::P_START
= 0;
24 const unsigned emulator_runmode::P_VIDEO
= 1;
25 const unsigned emulator_runmode::P_SAVE
= 2;
26 const unsigned emulator_runmode::P_NONE
= 3;
28 emulator_runmode::emulator_runmode()
37 uint64_t emulator_runmode::get()
43 void emulator_runmode::set(uint64_t m
)
45 if(!m
|| m
& (m
- 1) || m
> CORRUPT
)
46 throw std::logic_error("Trying to set invalid runmode");
52 //If setting state, clear the variables to be at initial state.
57 bool emulator_runmode::is(uint64_t m
)
60 return ((mode
& m
) != 0);
63 void emulator_runmode::start_load()
68 saved_advanced
= advanced
;
69 saved_cancel
= cancel
;
75 void emulator_runmode::end_load()
79 advanced
= saved_advanced
;
80 cancel
= saved_cancel
;
85 void emulator_runmode::decay_skiplag()
88 if(mode
== SKIPLAG_PENDING
) {
93 void emulator_runmode::decay_break()
96 if(mode
== PAUSE_BREAK
) {
101 void emulator_runmode::revalidate()
103 if(!mode
|| mode
& (mode
- 1) || (mode
== QUIT
&& magic
!= QUIT_MAGIC
) || mode
> CORRUPT
) {
107 emerg_save_movie(core
.mlogic
->get_mfile(), core
.mlogic
->get_rrdata());
108 messages
<< "WARNING: Emulator runmode undefined, invoked movie dump." << std::endl
;
113 bool emulator_runmode::set_and_test_advanced()
120 void emulator_runmode::set_cancel()
127 bool emulator_runmode::clear_and_test_cancel()
134 bool emulator_runmode::test_cancel()
139 bool emulator_runmode::test_advanced()
144 void emulator_runmode::set_point(unsigned _point
)
149 unsigned emulator_runmode::get_point()