Delay committing fullscreen until seeing window size change
[lsnes.git] / include / core / runmode.hpp
blobb548a8e4608971a2e0c765d8b8f52ee5e85f0d14
1 #ifndef _runmode__hpp__included__
2 #define _runmode__hpp__included__
4 #include <cstdint>
6 class emulator_runmode
8 public:
9 const static uint64_t QUIT;
10 const static uint64_t NORMAL;
11 const static uint64_t LOAD;
12 const static uint64_t ADVANCE_FRAME;
13 const static uint64_t ADVANCE_SUBFRAME;
14 const static uint64_t SKIPLAG;
15 const static uint64_t SKIPLAG_PENDING;
16 const static uint64_t PAUSE;
17 const static uint64_t PAUSE_BREAK;
18 const static uint64_t CORRUPT;
20 const static unsigned P_START;
21 const static unsigned P_VIDEO;
22 const static unsigned P_SAVE;
23 const static unsigned P_NONE;
24 /**
25 * Ctor.
27 emulator_runmode();
28 /**
29 * Save current mode and set mode to LOAD.
31 void start_load();
32 /**
33 * Restore saved mode.
35 void end_load();
36 /**
37 * Decay SKIPLAG_PENDING to SKIPLAG.
39 void decay_skiplag();
40 /**
41 * Decay PAUSE_BREAK into PAUSE.
43 void decay_break();
44 /**
45 * Is paused?
47 bool is_paused() { return is(PAUSE | PAUSE_BREAK); }
48 /**
49 * Is paused normally?
51 bool is_paused_normal() { return is(PAUSE); }
52 /**
53 * Is paused debug break?
55 bool is_paused_break() { return is(PAUSE_BREAK); }
56 /**
57 * Is advancing frames?
59 bool is_advance_frame() { return is(ADVANCE_FRAME); }
60 /**
61 * Is advancing subframes?
63 bool is_advance_subframe() { return is(ADVANCE_SUBFRAME); }
64 /**
65 * Is advancing (frames or subframes)?
67 bool is_advance() { return is(ADVANCE_FRAME|ADVANCE_SUBFRAME); }
68 /**
69 * Is skipping lag?
71 bool is_skiplag() { return is(SKIPLAG); }
72 /**
73 * Is running free?
75 bool is_freerunning() { return is(NORMAL); }
76 /**
77 * Is special?
79 bool is_special() { return is(QUIT|LOAD|CORRUPT); }
80 /**
81 * Is load?
83 bool is_load() { return is(LOAD); }
84 /**
85 * Is quit?
87 bool is_quit() { return is(QUIT); }
88 /**
89 * Set pause.
91 void set_pause() { set(PAUSE); }
92 /**
93 * Set break.
95 void set_break() { set(PAUSE_BREAK); }
96 /**
97 * Set quit.
99 void set_quit() { set(QUIT); }
101 * Set freerunning.
103 void set_freerunning() { set(NORMAL); }
105 * Set advance frame.
107 * The advanced and cancel flags are cleared.
109 void set_frameadvance() { set(ADVANCE_FRAME); }
111 * Set advance subframe.
113 * The advanced and cancel flags are cleared.
115 void set_subframeadvance() { set(ADVANCE_SUBFRAME); }
117 * Set pending skiplag.
119 void set_skiplag_pending() { set(SKIPLAG_PENDING); }
121 * Set pause or freerunning.
123 void set_pause_cond(bool paused) { set(paused ? PAUSE : NORMAL); }
125 * Set advanced flag and return previous value.
127 bool set_and_test_advanced();
129 * Set cancel flag.
131 void set_cancel();
133 * Test and clear cancel flag.
135 bool clear_and_test_cancel();
137 * Is cancel flag set?
139 bool test_cancel();
141 * Is advanced flag set?
143 bool test_advanced();
145 * Test corrupt flag.
147 bool is_corrupt() { return is(CORRUPT); }
149 * Set corrupt flag.
151 void set_corrupt() { set(CORRUPT); }
153 * Clear corrupt flag.
155 void clear_corrupt() { set(LOAD); }
157 * Set current point
159 void set_point(unsigned _point);
161 * Get current point
163 unsigned get_point();
165 * Get the current runmode.
167 uint64_t get();
168 private:
169 void revalidate();
170 void set(uint64_t m);
171 bool is(uint64_t m);
172 uint64_t mode;
173 uint64_t saved_mode;
174 uint64_t magic; //If mode is QUIT, this has to be QUIT_MAGIC.
175 //Flags relating to repeating advance.
176 bool advanced; //This is second or subsequent advance.
177 bool cancel; //Cancel advance at next oppurtunity.
178 bool saved_advanced;
179 bool saved_cancel;
180 //Current point.
181 unsigned point;
184 #endif