[QT][MENU_FLAGS] Fix TYPO.
extern QStringList virtualMediaList; // {TYPE, POSITION}
+void EmuThreadClass::resetEmu()
+{
+ clear_key_queue();
+ p_emu->reset();
+}
+
+void EmuThreadClass::specialResetEmu()
+{
+#ifdef USE_SPECIAL_RESET
+ p_emu->special_reset();
+#endif
+}
+
+void EmuThreadClass::loadState()
+{
+#ifdef USE_STATE
+ if(!lStateFile.isEmpty()) {
+ p_emu->load_state(lStateFile.toLocal8Bit().constData());
+ lStateFile.clear();
+ }
+#endif
+}
+
+void EmuThreadClass::saveState()
+{
+#ifdef USE_STATE
+ if(!sStateFile.isEmpty()) {
+ p_emu->save_state(sStateFile.toLocal8Bit().constData());
+ sStateFile.clear();
+ }
+#endif
+}
+
void EmuThreadClass::doWork(const QString ¶ms)
{
- int interval = 0, sleep_period = 0;
+ int interval = 0;
+ int64_t sleep_period = 0;
int run_frames;
qint64 current_time;
bool first = true;
bStopRecordSoundReq = false;
bStartRecordMovieReq = false;
sStateFile.clear();
+ lStateFile.clear();
record_fps = -1;
+ tick_timer.start();
+ update_fps_time = tick_timer.elapsed();
+ //update_fps_time = SDL_GetTicks();
next_time = 0;
mouse_flag = false;
for(int i = 0; i < using_flags->get_max_bubble(); i++) bubble_text[i].clear();
_queue_begin = parse_command_queue(virtualMediaList, 0);
+ //SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "2");
+
do {
//p_emu->SetHostCpus(this->idealThreadCount());
if(MainWindow == NULL) {
goto _exit;
}
msleep(10);
+ //SDL_Delay(10);
continue;
}
if(first) {
sleep_period = 0;
if(p_emu) {
// drive machine
-#ifdef USE_STATE
if(bLoadStateReq != false) {
- if(!sStateFile.isEmpty()) {
- p_emu->load_state(sStateFile.toLocal8Bit().constData());
- sStateFile.clear();
- }
+ loadState();
bLoadStateReq = false;
req_draw = true;
}
-#endif
+
if(bResetReq != false) {
- clear_key_queue();
- p_emu->reset();
+ resetEmu();
bResetReq = false;
req_draw = true;
}
-#ifdef USE_SPECIAL_RESET
if(bSpecialResetReq != false) {
- p_emu->special_reset();
+ specialResetEmu();
bSpecialResetReq = false;
}
-#endif
-
-#ifdef USE_STATE
if(bSaveStateReq != false) {
- if(!sStateFile.isEmpty()) {
- p_emu->save_state(sStateFile.toLocal8Bit().constData());
- sStateFile.clear();
- }
+ saveState();
bSaveStateReq = false;
}
-#endif
-#if defined(USE_MINIMUM_RENDERING)
- if((vert_line_bak != config.opengl_scanline_vert) ||
- (horiz_line_bak != config.opengl_scanline_horiz) ||
- (gl_crt_filter_bak != config.use_opengl_filters) ||
- (opengl_filter_num_bak != config.opengl_filter_num)) req_draw = true;
- vert_line_bak = config.opengl_scanline_vert;
- horiz_line_bak = config.opengl_scanline_horiz;
- gl_crt_filter_bak = config.use_opengl_filters;
- opengl_filter_num_bak = config.opengl_filter_num;
-#endif
+
+ if(using_flags->is_use_minimum_rendering()) {
+ if((vert_line_bak != config.opengl_scanline_vert) ||
+ (horiz_line_bak != config.opengl_scanline_horiz) ||
+ (gl_crt_filter_bak != config.use_opengl_filters) ||
+ (opengl_filter_num_bak != config.opengl_filter_num)) req_draw = true;
+ vert_line_bak = config.opengl_scanline_vert;
+ horiz_line_bak = config.opengl_scanline_horiz;
+ gl_crt_filter_bak = config.use_opengl_filters;
+ opengl_filter_num_bak = config.opengl_filter_num;
+ }
+
if(bStartRecordSoundReq != false) {
p_emu->start_record_sound();
bStartRecordSoundReq = false;
}
run_frames = p_emu->run();
total_frames += run_frames;
+ if(using_flags->is_use_minimum_rendering()) {
#if defined(USE_MINIMUM_RENDERING)
- req_draw |= p_emu->is_screen_changed();
+ req_draw |= p_emu->is_screen_changed();
#else
- req_draw = true;
+ req_draw = true;
#endif
+ } else {
+ req_draw = true;
+ }
+
#if defined(USE_KEY_LOCKED) && !defined(INDEPENDENT_CAPS_KANA_LED)
led_data = p_emu->get_caps_locked() ? 0x01 : 0x00;
led_data |= (p_emu->get_kana_locked() ? 0x02 : 0x00);
}
#endif
sample_access_drv();
-
- interval += get_interval();
now_skip = p_emu->is_frame_skippable() && !p_emu->is_video_recording();
- if(config.full_speed) interval = 1;
+ if(config.full_speed) {
+ interval = 1;
+ } else {
+ interval = get_interval();
+ }
if((prev_skip && !now_skip) || next_time == 0) {
next_time = tick_timer.elapsed();
+ //next_time = SDL_GetTicks();
}
if(!now_skip) {
next_time += interval;
}
prev_skip = now_skip;
- //printf("p_emu::RUN Frames = %d SKIP=%d Interval = %d NextTime = %d\n", run_frames, now_skip, interval, next_time);
+#if 0
+ {
+ struct tm *timedat;
+ time_t nowtime;
+ char strbuf2[256];
+ char strbuf3[24];
+ struct timeval tv;
+ nowtime = time(NULL);
+ gettimeofday(&tv, NULL);
+ memset(strbuf2, 0x00, sizeof(strbuf2));
+ memset(strbuf3, 0x00, sizeof(strbuf3));
+ timedat = localtime(&nowtime);
+ strftime(strbuf2, 255, "%Y-%m-%d %H:%M:%S", timedat);
+ snprintf(strbuf3, 23, ".%06ld", tv.tv_usec);
+ printf("%s%s[EMU]::RUN Frames = %d SKIP=%d Interval = %d NextTime = %d SRC = %d\n", strbuf2, strbuf3, run_frames, now_skip, interval, next_time, tick_timer.clockType());
+ }
+#endif
if(next_time > tick_timer.elapsed()) {
+ //if(next_time > SDL_GetTicks()) {
// update window if enough time
if(!req_draw) {
no_draw_count++;
// sleep 1 frame priod if need
current_time = tick_timer.elapsed();
- if((int)(next_time - current_time) >= 10) {
- sleep_period = next_time - current_time;
+ //current_time = SDL_GetTicks();
+ sleep_period = 0;
+ if(next_time > current_time) {
+ if((int)(next_time - current_time) >= 1) {
+ sleep_period = next_time - current_time;
+ }
}
} else if(++skip_frames > MAX_SKIP_FRAMES) {
// update window at least once per 10 frames
no_draw_count = 0;
skip_frames = 0;
qint64 tt = tick_timer.elapsed();
+ //quint32 tt = SDL_GetTicks();
+ if(next_time > tt) {
+ sleep_period = next_time - tt;
+ } else {
+ sleep_period = 0;
+ }
if(config.full_speed) {
next_time = tt + 1;
} else {
- next_time = tt + get_interval();
+ next_time = tt;// + get_interval();
+ next_time = next_time + get_interval();
}
- sleep_period = next_time - tt;
+ sleep_period = 0;
}
}
req_draw = false;
if(bRunThread == false){
goto _exit;
}
- if(sleep_period <= 0) sleep_period = 1;
- msleep(sleep_period);
+ if(sleep_period > 0) {
+ //sleep_period = 1;
+ msleep(sleep_period);
+ //SDL_Delay(sleep_period);
+ }
+ //SDL_Delay(sleep_period);
} while(1);
_exit:
//emit quit_draw_thread();
void dec_message_count(void);
const _TCHAR *get_device_name(void);
bool get_power_state(void);
+ void resetEmu();
+ void specialResetEmu();
+ void loadState();
+ void saveState();
public:
EmuThreadClass(Ui_MainWindowBase *rootWindow, USING_FLAGS *p, QObject *parent = 0);
}
}
#if defined(USE_SDL2)
- SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
+ //SDL_Init(SDL_INIT_AUDIO | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK);
+ SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS);
#else
SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
#endif
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Audio and JOYSTICK subsystem was initialised.");
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Audio subsystem was initialised.");
}
message("* qt/gui")
-set(THIS_LIB_VERSION 2.18.4)
+set(THIS_LIB_VERSION 2.18.5)
#include(cotire)
#include(PrecompiledHeader)
bRunThread = true;
prev_skip = false;
- tick_timer.start();
- update_fps_time = tick_timer.elapsed();
- next_time = update_fps_time;
+ //tick_timer.start();
+ //update_fps_time = tick_timer.elapsed();
+ //next_time = update_fps_time;
total_frames = 0;
draw_frames = 0;
skip_frames = 0;
void EmuThreadClassBase::do_load_state(QString s)
{
- sStateFile = s;
+ lStateFile = s;
bLoadStateReq = true;
}
if(frames >= 0) draw_frames += frames;
if(calc_message) {
qint64 current_time = tick_timer.elapsed();
+ //qint64 current_time = SDL_GetTicks();
+
if(update_fps_time <= current_time && update_fps_time != 0) {
_TCHAR buf[256];
QString message;
bool bStopRecordSoundReq;
bool bStartRecordMovieReq;
QString sStateFile;
+ QString lStateFile;
// bool draw_timing;
bool doing_debug_command;
virtual void dec_message_count(void);
virtual const _TCHAR *get_device_name(void);
virtual bool get_power_state(void);
-
+
+ virtual void resetEmu() { }
+ virtual void specialResetEmu() { }
+ virtual void loadState() { }
+ virtual void saveState() { }
+
void enqueue_key_up(key_queue_t s) {
keyMutex->lock();
key_fifo->write(KEY_QUEUE_UP);
if(using_flags->is_use_joystick()) {
# if defined(USE_SDL2)
+ int result = SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK);
+ //int result = 0;
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "Joystick/Game controller subsystem was %s.", (result == 0) ? "initialized" : "not initialized");
for(i = 0; i < 16; i++) {
controller_table[i] = NULL;
}
} else {
csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : Any joysticks were not connected.");
}
- bRunThread = true;
+ bRunThread = (result == 0) ? true : false;
} else {
for(i = 0; i < 16; i++) {
joyhandle[i] = NULL;
SDL_GameControllerClose(controller_table[i]);
controller_table[i] = NULL;
}
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : EXIT");
# else
for(i = 0; i < 16; i++) {
SDL_JoystickClose(joyhandle[i]);
joyhandle[i] = NULL;
}
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : EXIT");
# endif
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : EXIT");
}
}
joyhandle[num] = SDL_GameControllerGetJoystick(controller_table[num]);
if(controller_table[num] != NULL) {
names[num] = QString::fromUtf8(SDL_GameControllerNameForIndex(num));
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : Controller %d : %s : is plugged.", num, names[num].toUtf8().constData());
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "JoyThread : Controller %d : %s : is plugged.", num, names[num].toUtf8().constData());
strncpy(p_config->assigned_joystick_name[num], names[num].toUtf8().constData(),
(sizeof(p_config->assigned_joystick_name) / sizeof(char)) - 1);
joy_num[num] = num;
joyhandle[i] = SDL_JoystickOpen(num);
joy_num[i] = SDL_JoystickInstanceID(joyhandle[i]);
names[i] = QString::fromUtf8(SDL_JoystickNameForIndex(num));
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : Joystick %d : %s : is plugged.", num, names[i].toUtf8().data());
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "JoyThread : Joystick %d : %s : is plugged.", num, names[i].toUtf8().data());
strncpy(p_config->assigned_joystick_name[num], names[num].toUtf8().constData(),
(sizeof(p_config->assigned_joystick_name) / sizeof(char)) - 1);
break;
if(controller_table[num] != NULL) {
SDL_GameControllerClose(controller_table[num]);
controller_table[num] = NULL;
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : Controller %d : %s : is removed.", num, names[num].toUtf8().data());
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "JoyThread : Controller %d : %s : is removed.", num, names[num].toUtf8().data());
joy_num[num] = -1;
}
joyhandle[num] = NULL;
if(joyhandle[num] != NULL) {
SDL_JoystickClose(joyhandle[num]);
joyhandle[num] = NULL;
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "JoyThread : Joystick %d : %s : is removed.", num, names[num].toUtf8().data());
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "JoyThread : Joystick %d : %s : is removed.", num, names[num].toUtf8().data());
joy_num[num] = -1;
}
}
int get_max_memcard() { return max_memcard; }
- bool is_use_minimum_rendaring() { return use_minimum_rendering; }
+ bool is_use_minimum_rendering() { return use_minimum_rendering; }
bool is_use_dig_resolution() { return use_dig_resolution; }
int get_use_monitor_type() { return use_monitor_type; }
"Audio Device #%d: %s", i, tmps.toLocal8Bit().constData());
sound_device_list.append(tmps);
}
-#endif
-#if defined(USE_SDL2)
//QString sdev = QString::fromUtf8("\"") + sound_device_list.at(audio_dev_id) + QString::fromUtf8("\"");
//audio_dev_id = SDL_OpenAudioDevice(NULL, 0, &snd_spec_req, &snd_spec_presented, SDL_AUDIO_ALLOW_ANY_CHANGE);
audio_dev_id = SDL_OpenAudioDevice(sdev.toUtf8().constData(), 0,
&snd_spec_req, &snd_spec_presented,
0);
- debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_SOUND, "Try to openDEVICE #%d: %s -> %s: DEVID=%d\n",
+ debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_SOUND, "Try to open DEVICE #%d: %s -> %s: DEVID=%d\n",
p_config->sound_device_num, sdev.toUtf8().constData(), (audio_dev_id <= 0) ? "FAIL" : "SUCCESS", audio_dev_id);
#else
audio_dev_id = 1;