Add toolbar button and Action menu item to toggle forcing the recompiler to interpret blocks, should help with some slowdowns (tested to help with Daggerfall on both recompilers and Legend of Hero III on new recompiler).

This commit is contained in:
OBattler
2025-12-05 14:18:17 +01:00
parent 7369cbc134
commit 3feb0f135d
31 changed files with 331 additions and 1 deletions

View File

@@ -51,6 +51,7 @@
#define CPU_BLOCK_END() cpu_block_end = 1
int cpu_force_interpreter = 0;
int cpu_override_dynarec = 0;
int inrecomp = 0;
int cpu_block_end = 0;
@@ -778,7 +779,7 @@ exec386_dynarec(int32_t cycs)
cycles_old = cycles;
oldtsc = tsc;
tsc_old = tsc;
if ((!CACHE_ON()) || cpu_override_dynarec) /*Interpret block*/
if (cpu_force_interpreter || cpu_override_dynarec || (!CACHE_ON())) /*Interpret block*/
{
exec386_dynarec_int();
} else {

View File

@@ -823,6 +823,8 @@ extern MMX_REG *MMP[8];
extern uint16_t *MMEP[8];
extern int cpu_block_end;
extern int cpu_force_interpreter;
extern int cpu_override_dynarec;
extern void mmx_init(void);

View File

@@ -373,6 +373,8 @@ reset_common(int hard)
in_lock = 0;
cpu_cpurst_on_sr = 0;
cpu_force_interpreter = 0;
}
/* Hard reset. */

View File

@@ -71,6 +71,8 @@ extern void ui_sb_set_text(char *str);
extern void ui_sb_bugui(char *str);
extern void ui_sb_mt32lcd(char *str);
extern void ui_update_force_interpreter(void);
#ifdef __cplusplus
}
#endif

View File

@@ -3038,3 +3038,15 @@ msgstr ""
msgid "Search:"
msgstr ""
msgid "Force interpretation"
msgstr ""
msgid "Allow recompilation"
msgstr ""
msgid "&Force interpretation"
msgstr ""
msgid "&Allow recompilation"
msgstr ""

View File

@@ -3044,3 +3044,15 @@ msgstr "Tmavé"
msgid "Search:"
msgstr "Hledat:"
msgid "Force interpretation"
msgstr "Vynutit interpretaci"
msgid "Allow recompilation"
msgstr "Povolit rekompilaci"
msgid "&Force interpretation"
msgstr "&Vynutit interpretaci"
msgid "&Allow recompilation"
msgstr "&Povolit rekompilaci"

View File

@@ -3044,3 +3044,15 @@ msgstr "Dunkel"
msgid "Search:"
msgstr "Suche:"
msgid "Force interpretation"
msgstr "Erzwingen der Interpretation"
msgid "Allow recompilation"
msgstr "Recompilierung zulassen"
msgid "&Force interpretation"
msgstr "&Erzwingen der Interpretation"
msgid "&Allow recompilation"
msgstr "Recompilierung &zulassen"

View File

@@ -3044,3 +3044,15 @@ msgstr "Oscuro"
msgid "Search:"
msgstr "Buscar:"
msgid "Force interpretation"
msgstr "Forzar interpretación"
msgid "Allow recompilation"
msgstr "Permitir recompilación"
msgid "&Force interpretation"
msgstr "&Forzar interpretación"
msgid "&Allow recompilation"
msgstr "&Permitir recompilación"

View File

@@ -3038,3 +3038,15 @@ msgstr "Tumma"
msgid "Search:"
msgstr "Hae:"
msgid "Force interpretation"
msgstr "Pakota tulkinta"
msgid "Allow recompilation"
msgstr "Salli uudelleenkompilointi"
msgid "&Force interpretation"
msgstr "&Pakota tulkinta"
msgid "&Allow recompilation"
msgstr "&Salli uudelleenkompilointi"

View File

@@ -3044,3 +3044,15 @@ msgstr "Sombre"
msgid "Search:"
msgstr "Rechercher :"
msgid "Force interpretation"
msgstr "Forcer l'interprétation"
msgid "Allow recompilation"
msgstr "Permettre la recompilation"
msgid "&Force interpretation"
msgstr "&Forcer l'interprétation"
msgid "&Allow recompilation"
msgstr "&Permettre la recompilation"

View File

@@ -3046,3 +3046,15 @@ msgstr "Tamno"
msgid "Search:"
msgstr "Pretrag:"
msgid "Force interpretation"
msgstr "Prisilna interpretacija"
msgid "Allow recompilation"
msgstr "Omogući rekompilaciju"
msgid "&Force interpretation"
msgstr "&Prisilna interpretacija"
msgid "&Allow recompilation"
msgstr "&Omogući rekompilaciju"

View File

@@ -3044,3 +3044,15 @@ msgstr "Scura"
msgid "Search:"
msgstr "Cerca:"
msgid "Force interpretation"
msgstr "Forza interpretazione"
msgid "Allow recompilation"
msgstr "Permetti ricompilazione"
msgid "&Force interpretation"
msgstr "&Forza interpretazione"
msgid "&Allow recompilation"
msgstr "&Permetti ricompilazione"

View File

@@ -3045,3 +3045,15 @@ msgstr "暗闇"
msgid "Search:"
msgstr "検索:"
msgid "Force interpretation"
msgstr "解釈を強制する"
msgid "Allow recompilation"
msgstr "再コンパイルを許可する"
msgid "&Force interpretation"
msgstr "解釈を強制する(&F)"
msgid "&Allow recompilation"
msgstr "再コンパイルを許可する(&A)"

View File

@@ -3038,3 +3038,15 @@ msgstr "어둠"
msgid "Search:"
msgstr "검색:"
msgid "Force interpretation"
msgstr "강제 해석"
msgid "Allow recompilation"
msgstr "재컴파일 허용"
msgid "&Force interpretation"
msgstr "강제 해석(&F)"
msgid "&Allow recompilation"
msgstr "재컴파일 허용(&A)"

View File

@@ -3038,3 +3038,15 @@ msgstr "Mørk"
msgid "Search:"
msgstr "Søk:"
msgid "Force interpretation"
msgstr "Tving tolkning"
msgid "Allow recompilation"
msgstr "Tillat rekompilering"
msgid "&Force interpretation"
msgstr "&Tving tolkning"
msgid "&Allow recompilation"
msgstr "&Tillat rekompilering"

View File

@@ -3038,3 +3038,15 @@ msgstr "Donker"
msgid "Search:"
msgstr "Zoeken:"
msgid "Force interpretation"
msgstr "Interpretatie afdwingen"
msgid "Allow recompilation"
msgstr "Recompilatie toestaan"
msgid "&Force interpretation"
msgstr "Interpretatie &afdwingen"
msgid "&Allow recompilation"
msgstr "Recompilatie &toestaan"

View File

@@ -3045,3 +3045,15 @@ msgstr "Ciemny"
msgid "Search:"
msgstr "Szukanie:"
msgid "Force interpretation"
msgstr "Wymuś interpretację"
msgid "Allow recompilation"
msgstr "Zezwól na rekompilację"
msgid "&Force interpretation"
msgstr "&Wymuś interpretację"
msgid "&Allow recompilation"
msgstr "&Zezwól na rekompilację"

View File

@@ -3038,3 +3038,15 @@ msgstr "Escuro"
msgid "Search:"
msgstr "Pesquisar:"
msgid "Force interpretation"
msgstr "Forçar interpretação"
msgid "Allow recompilation"
msgstr "Permitir recompilação"
msgid "&Force interpretation"
msgstr "&Forçar interpretação"
msgid "&Allow recompilation"
msgstr "&Permitir recompilação"

View File

@@ -3045,3 +3045,15 @@ msgstr "Escuro"
msgid "Search:"
msgstr "Procurar:"
msgid "Force interpretation"
msgstr "Forçar interpretação"
msgid "Allow recompilation"
msgstr "Permitir recompilação"
msgid "&Force interpretation"
msgstr "&Forçar interpretação"
msgid "&Allow recompilation"
msgstr "&Permitir recompilação"

View File

@@ -3038,3 +3038,15 @@ msgstr "Тёмная"
msgid "Search:"
msgstr "Поиск:"
msgid "Force interpretation"
msgstr "Принудительная интерпретация"
msgid "Allow recompilation"
msgstr "Разрешить рекомпиляцию"
msgid "&Force interpretation"
msgstr "&Принудительная интерпретация"
msgid "&Allow recompilation"
msgstr "&Разрешить рекомпиляцию"

View File

@@ -3044,3 +3044,15 @@ msgstr "Tmavá"
msgid "Search:"
msgstr "Hľadať:"
msgid "Force interpretation"
msgstr "Vynútiť interpretáciu"
msgid "Allow recompilation"
msgstr "Povoliť rekompiláciu"
msgid "&Force interpretation"
msgstr "&Vynútiť interpretáciu"
msgid "&Allow recompilation"
msgstr "&Povoliť rekompiláciu"

View File

@@ -3046,3 +3046,15 @@ msgstr "Temno"
msgid "Search:"
msgstr "Išči:"
msgid "Force interpretation"
msgstr "Vsili interpretacijo"
msgid "Allow recompilation"
msgstr "Dovoli prevajanje"
msgid "&Force interpretation"
msgstr "&Vsili interpretacijo"
msgid "&Allow recompilation"
msgstr "&Dovoli prevajanje"

View File

@@ -3038,3 +3038,15 @@ msgstr "Mörk"
msgid "Search:"
msgstr "Sök:"
msgid "Force interpretation"
msgstr "Tvinga tolkning"
msgid "Allow recompilation"
msgstr "Tillåt omkompilering"
msgid "&Force interpretation"
msgstr "&Tvinga tolkning"
msgid "&Allow recompilation"
msgstr "&Tillåt omkompilering"

View File

@@ -3038,3 +3038,15 @@ msgstr "Karanlık"
msgid "Search:"
msgstr "Ara:"
msgid "Force interpretation"
msgstr "Yorumlanmasını zorla"
msgid "Allow recompilation"
msgstr "Derlenmesine izin ver"
msgid "&Force interpretation"
msgstr "&Yorumlanmasını zorla"
msgid "&Allow recompilation"
msgstr "&Derlenmesine izin ver"

View File

@@ -3046,3 +3046,15 @@ msgstr "Темний"
msgid "Search:"
msgstr "Пошук:"
msgid "Force interpretation"
msgstr "Примусове тлумачення"
msgid "Allow recompilation"
msgstr "Дозволити рекомпіляцію"
msgid "&Force interpretation"
msgstr "&Примусове тлумачення"
msgid "&Allow recompilation"
msgstr "&Дозволити рекомпіляцію"

View File

@@ -3038,3 +3038,15 @@ msgstr "Tối"
msgid "Search:"
msgstr "Tìm:"
msgid "Force interpretation"
msgstr "Buộc giải thích"
msgid "Allow recompilation"
msgstr "Cho phép biên dịch lại"
msgid "&Force interpretation"
msgstr "&Buộc giải thích"
msgid "&Allow recompilation"
msgstr "&Cho phép biên dịch lại"

View File

@@ -164,6 +164,8 @@ keyb_filter(BMessage *message, BHandler **target, BMessageFilter *filter)
static BMessageFilter *filter;
#endif
extern int cpu_force_interpreter;
extern void qt_mouse_capture(int);
extern "C" void qt_blit(int x, int y, int w, int h, int monitor_index);
@@ -278,8 +280,24 @@ MainWindow::MainWindow(QWidget *parent)
vmname.truncate(vmname.size() - 1);
this->setWindowTitle(QString("%1 - %2 %3").arg(vmname, EMU_NAME, EMU_VERSION_FULL));
connect(this, &MainWindow::forceInterpretationCompleted, this, [this]() {
const auto fi_icon = cpu_force_interpreter ? QIcon(":/menuicons/qt/icons/recompiler.ico") :
QIcon(":/menuicons/qt/icons/interpreter.ico");
const auto tooltip_text = cpu_force_interpreter ? QString(tr("Allow recompilation")) :
QString(tr("Force interpretation"));
const auto menu_text = cpu_force_interpreter ? QString(tr("&Allow recompilation")) :
QString(tr("&Force interpretation"));
ui->actionForce_interpretation->setIcon(fi_icon);
ui->actionForce_interpretation->setToolTip(tooltip_text);
ui->actionForce_interpretation->setText(menu_text);
ui->actionForce_interpretation->setChecked(cpu_force_interpreter);
ui->actionForce_interpretation->setEnabled(cpu_use_dynarec);
});
connect(this, &MainWindow::hardResetCompleted, this, [this]() {
ui->actionMCA_devices->setVisible(machine_has_bus(machine, MACHINE_BUS_MCA));
ui_update_force_interpreter();
num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
scroll_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
@@ -968,6 +986,12 @@ MainWindow::closeEvent(QCloseEvent *event)
event->accept();
}
void
ui_update_force_interpreter()
{
emit main_window->forceInterpretationCompleted();
}
void
MainWindow::updateShortcuts()
{
@@ -986,6 +1010,7 @@ MainWindow::updateShortcuts()
ui->actionHard_Reset->setShortcut(QKeySequence());
ui->actionPause->setShortcut(QKeySequence());
ui->actionMute_Unmute->setShortcut(QKeySequence());
ui->actionForce_interpretation->setShortcut(QKeySequence());
int accID;
QKeySequence seq;
@@ -1017,6 +1042,10 @@ MainWindow::updateShortcuts()
accID = FindAccelerator("mute");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionMute_Unmute->setShortcut(seq);
accID = FindAccelerator("force_interpretation");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionForce_interpretation->setShortcut(seq);
}
void
@@ -1600,6 +1629,7 @@ MainWindow::refreshMediaMenu()
status->refresh(ui->statusbar);
ui->actionMCA_devices->setVisible(machine_has_bus(machine, MACHINE_BUS_MCA));
ui->actionACPI_Shutdown->setEnabled(!!acpi_enabled);
ui_update_force_interpreter();
num_label->setToolTip(QShortcut::tr("Num Lock"));
num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
@@ -1788,6 +1818,13 @@ MainWindow::on_actionInverted_VGA_monitor_triggered()
video_toggle_option(ui->actionInverted_VGA_monitor, &invert_display);
}
void
MainWindow::on_actionForce_interpretation_triggered()
{
cpu_force_interpreter ^= 1;
ui_update_force_interpreter();
}
static void
update_scaled_checkboxes(Ui::MainWindow *ui, QAction *selected)
{

View File

@@ -58,6 +58,7 @@ signals:
void destroyRendererMonitor(int monitor_index);
void initRendererMonitorForNonQtThread(int monitor_index);
void destroyRendererMonitorForNonQtThread(int monitor_index);
void forceInterpretationCompleted();
void hardResetCompleted();
void setTitle(const QString &title);
@@ -79,6 +80,7 @@ public slots:
void updateStatusEmptyIcons();
void updateUiPauseState();
private slots:
void on_actionForce_interpretation_triggered();
void on_actionFullscreen_triggered();
void on_actionSettings_triggered();
void on_actionExit_triggered();

View File

@@ -70,6 +70,8 @@
</widget>
<addaction name="menuTablet_tool"/>
<addaction name="separator"/>
<addaction name="actionForce_interpretation"/>
<addaction name="separator"/>
<addaction name="actionKeyboard_requires_capture"/>
<addaction name="actionRight_CTRL_is_left_ALT"/>
<addaction name="separator"/>
@@ -292,6 +294,8 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionForce_interpretation"/>
<addaction name="separator"/>
<addaction name="actionPause"/>
<addaction name="actionHard_Reset"/>
<addaction name="separator"/>
@@ -302,6 +306,14 @@
<addaction name="separator"/>
<addaction name="actionSettings"/>
</widget>
<action name="actionForce_interpretation">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Force interpretation</string>
</property>
</action>
<action name="actionUpdate_mouse_every_CPU_frame">
<property name="checkable">
<bool>true</bool>

View File

@@ -68,6 +68,8 @@
<file>qt/icons/send_cad.ico</file>
<file>qt/icons/send_cae.ico</file>
<file>qt/icons/settings.ico</file>
<file>qt/icons/interpreter.ico</file>
<file>qt/icons/recompiler.ico</file>
</qresource>
<qresource prefix="/misc">
<file>qt/icons/warning.ico</file>

View File

@@ -1731,3 +1731,9 @@ ui_hard_reset_completed(void)
{
/* No-op. */
}
void
ui_update_force_interpreter(void)
{
/* No-op. */
}