• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision34ae92a457461b1bb3794c8cde4e9764dd9d536b (tree)
Zeit2020-05-28 20:05:51
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][EVENT][Qt] execute event->drive() (or event->run()) by half frame.This is workaround for choppy mouse pointer/joystick.

Ändern Zusammenfassung

Diff

--- a/source/src/qt/common/emu_thread.cpp
+++ b/source/src/qt/common/emu_thread.cpp
@@ -75,8 +75,8 @@ int EmuThreadClass::get_interval(void)
7575 {
7676 static int accum = 0;
7777 accum += p_emu->get_frame_interval();
78- int interval = accum >> 10;
79- accum -= interval << 10;
78+ int interval = accum >> 11;
79+ accum -= interval << 11;
8080 return interval;
8181 }
8282
--- a/source/src/vm/event.cpp
+++ b/source/src/vm/event.cpp
@@ -163,7 +163,7 @@ void EVENT::reset()
163163 memset(sound_tmp, 0, sound_tmp_samples * sizeof(int32_t) * 2);
164164 }
165165 // buffer_ptr = 0;
166-
166+ event_half = false;
167167 #ifdef _DEBUG_LOG
168168 initialize_done = true;
169169 #endif
@@ -171,6 +171,7 @@ void EVENT::reset()
171171
172172 void EVENT::drive()
173173 {
174+ if(event_half) goto skip1;
174175 // raise pre frame events to update timing settings
175176 for(int i = 0; i < frame_event_count; i++) {
176177 frame_event[i]->event_pre_frame();
@@ -204,7 +205,7 @@ void EVENT::drive()
204205 }
205206 }
206207 }
207-
208+
208209 // run virtual machine for 1 frame period
209210 for(int i = 0; i < frame_event_count; i++) {
210211 frame_event[i]->event_frame();
@@ -225,8 +226,18 @@ void EVENT::drive()
225226 update_event(-event_remain);
226227 }
227228 }
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;
230241
231242 while(event_remain > 0) {
232243 int event_done = event_remain;
@@ -717,7 +728,7 @@ uint16_t* EVENT::create_sound(int* extra_frames)
717728 // drive extra frames to fill the sound buffer
718729 while(sound_samples > buffer_ptr) {
719730 drive();
720- frames++;
731+ if(!(event_half)) frames++;
721732 }
722733 #ifdef LOW_PASS_FILTER
723734 // low-pass filter
@@ -1127,7 +1138,7 @@ void EVENT::update_config()
11271138 }
11281139
11291140 // Revert clock ratio to 1024 (2^10).STATE_VERSION to 4; 20191013 K.O
1130-#define STATE_VERSION 4
1141+#define STATE_VERSION 5
11311142
11321143 bool EVENT::process_state(FILEIO* state_fio, bool loading)
11331144 {
@@ -1185,6 +1196,7 @@ bool EVENT::process_state(FILEIO* state_fio, bool loading)
11851196 state_fio->StateValue(next_lines_per_frame);
11861197 state_fio->StateArray(dev_need_mix, sizeof(dev_need_mix), 1);
11871198 state_fio->StateValue(need_mix);
1199+ state_fio->StateValue(event_half);
11881200
11891201 // post process
11901202 if(loading) {
--- a/source/src/vm/event.h
+++ b/source/src/vm/event.h
@@ -45,7 +45,8 @@ private:
4545
4646 uint32_t cpu_update_clocks[MAX_CPU][6];
4747 int dcount_cpu;
48-
48+
49+ bool event_half;
4950 int frame_clocks;
5051 int vline_clocks[MAX_LINES];
5152 int power;
Show on old repository browser