Common Source Code Project for Qt (a.k.a for FM-7).
Revision | 34ae92a457461b1bb3794c8cde4e9764dd9d536b (tree) |
---|---|
Zeit | 2020-05-28 20:05:51 |
Autor | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[VM][EVENT][Qt] execute event->drive() (or event->run()) by half frame.This is workaround for choppy mouse pointer/joystick.
@@ -75,8 +75,8 @@ int EmuThreadClass::get_interval(void) | ||
75 | 75 | { |
76 | 76 | static int accum = 0; |
77 | 77 | accum += p_emu->get_frame_interval(); |
78 | - int interval = accum >> 10; | |
79 | - accum -= interval << 10; | |
78 | + int interval = accum >> 11; | |
79 | + accum -= interval << 11; | |
80 | 80 | return interval; |
81 | 81 | } |
82 | 82 |
@@ -163,7 +163,7 @@ void EVENT::reset() | ||
163 | 163 | memset(sound_tmp, 0, sound_tmp_samples * sizeof(int32_t) * 2); |
164 | 164 | } |
165 | 165 | // buffer_ptr = 0; |
166 | - | |
166 | + event_half = false; | |
167 | 167 | #ifdef _DEBUG_LOG |
168 | 168 | initialize_done = true; |
169 | 169 | #endif |
@@ -171,6 +171,7 @@ void EVENT::reset() | ||
171 | 171 | |
172 | 172 | void EVENT::drive() |
173 | 173 | { |
174 | + if(event_half) goto skip1; | |
174 | 175 | // raise pre frame events to update timing settings |
175 | 176 | for(int i = 0; i < frame_event_count; i++) { |
176 | 177 | frame_event[i]->event_pre_frame(); |
@@ -204,7 +205,7 @@ void EVENT::drive() | ||
204 | 205 | } |
205 | 206 | } |
206 | 207 | } |
207 | - | |
208 | + | |
208 | 209 | // run virtual machine for 1 frame period |
209 | 210 | for(int i = 0; i < frame_event_count; i++) { |
210 | 211 | frame_event[i]->event_frame(); |
@@ -225,8 +226,18 @@ void EVENT::drive() | ||
225 | 226 | update_event(-event_remain); |
226 | 227 | } |
227 | 228 | } |
228 | - event_remain += frame_clocks; | |
229 | - cpu_remain += frame_clocks << power; | |
229 | +skip1: | |
230 | + int _fclocks; | |
231 | + if(event_half) { | |
232 | + _fclocks = frame_clocks - (frame_clocks / 2); | |
233 | + } else { | |
234 | + _fclocks = frame_clocks / 2; | |
235 | + } | |
236 | + event_half = !(event_half); | |
237 | +// event_remain += frame_clocks; | |
238 | +// cpu_remain += frame_clocks << power; | |
239 | + event_remain += _fclocks; | |
240 | + cpu_remain += _fclocks << power; | |
230 | 241 | |
231 | 242 | while(event_remain > 0) { |
232 | 243 | int event_done = event_remain; |
@@ -717,7 +728,7 @@ uint16_t* EVENT::create_sound(int* extra_frames) | ||
717 | 728 | // drive extra frames to fill the sound buffer |
718 | 729 | while(sound_samples > buffer_ptr) { |
719 | 730 | drive(); |
720 | - frames++; | |
731 | + if(!(event_half)) frames++; | |
721 | 732 | } |
722 | 733 | #ifdef LOW_PASS_FILTER |
723 | 734 | // low-pass filter |
@@ -1127,7 +1138,7 @@ void EVENT::update_config() | ||
1127 | 1138 | } |
1128 | 1139 | |
1129 | 1140 | // Revert clock ratio to 1024 (2^10).STATE_VERSION to 4; 20191013 K.O |
1130 | -#define STATE_VERSION 4 | |
1141 | +#define STATE_VERSION 5 | |
1131 | 1142 | |
1132 | 1143 | bool EVENT::process_state(FILEIO* state_fio, bool loading) |
1133 | 1144 | { |
@@ -1185,6 +1196,7 @@ bool EVENT::process_state(FILEIO* state_fio, bool loading) | ||
1185 | 1196 | state_fio->StateValue(next_lines_per_frame); |
1186 | 1197 | state_fio->StateArray(dev_need_mix, sizeof(dev_need_mix), 1); |
1187 | 1198 | state_fio->StateValue(need_mix); |
1199 | + state_fio->StateValue(event_half); | |
1188 | 1200 | |
1189 | 1201 | // post process |
1190 | 1202 | if(loading) { |
@@ -45,7 +45,8 @@ private: | ||
45 | 45 | |
46 | 46 | uint32_t cpu_update_clocks[MAX_CPU][6]; |
47 | 47 | int dcount_cpu; |
48 | - | |
48 | + | |
49 | + bool event_half; | |
49 | 50 | int frame_clocks; |
50 | 51 | int vline_clocks[MAX_LINES]; |
51 | 52 | int power; |