4
4
#include < frontend/audio.h>
5
5
#include < frontend/render.h>
6
6
#include " n64_emulator_thread.h"
7
+
8
+ #include < QWindow>
9
+
7
10
#include " qt_wsi_platform.h"
8
11
9
12
class QtParallelRdpWindowInfo : public ParallelRdpWindowInfo {
@@ -19,9 +22,9 @@ class QtParallelRdpWindowInfo : public ParallelRdpWindowInfo {
19
22
QWindow* pane;
20
23
};
21
24
22
- N64EmulatorThread::N64EmulatorThread (QtWSIPlatform* wsiPlatform) {
23
- this -> wsiPlatform = wsiPlatform;
24
- init_n64system (nullptr , true , false , QT_VULKAN_VIDEO_TYPE, false );
25
+ N64EmulatorThread::N64EmulatorThread (Vulkan::InstanceFactory* instanceFactory, QtWSIPlatform* wsiPlatform, const char * rom_path, bool debug, bool interpreter)
26
+ : wsiPlatform(wsiPlatform), instanceFactory(instanceFactory) {
27
+ init_n64system (rom_path , true , debug , QT_VULKAN_VIDEO_TYPE, interpreter );
25
28
26
29
if (file_exists (PIF_ROM_PATH)) {
27
30
logalways (" Found PIF ROM at %s, loading" , PIF_ROM_PATH);
@@ -32,32 +35,30 @@ N64EmulatorThread::N64EmulatorThread(QtWSIPlatform* wsiPlatform) {
32
35
}
33
36
}
34
37
35
- void N64EmulatorThread::start () {
38
+ void N64EmulatorThread::run () noexcept {
36
39
if (n64_should_quit () || running) {
37
40
logfatal (" Tried to start emulator thread, but it was already running!" );
38
41
}
39
42
40
- QtWSIPlatform* _wsiPlatform = this ->wsiPlatform ;
41
- QWindow* pane = wsiPlatform->getPane ();
42
43
running = true ;
43
- bool * _game_loaded = &game_loaded;
44
- emuThread = std::thread ([_wsiPlatform, pane, _game_loaded]() {
45
- init_vulkan_wsi (_wsiPlatform, std::make_unique<QtParallelRdpWindowInfo>(pane));
46
44
47
- init_parallel_rdp ( );
45
+ init_vulkan_wsi (instanceFactory, wsiPlatform, std::make_unique<QtParallelRdpWindowInfo>(wsiPlatform-> getWindowHandle ()) );
48
46
49
- while (!(*_game_loaded)) {
50
- std::this_thread::sleep_for (std::chrono::milliseconds (1000 / 60 ));
51
- prdp_update_screen_no_game ();
52
- }
47
+ init_parallel_rdp ();
53
48
54
- n64_system_loop ();
55
- });
49
+ while (!game_loaded) {
50
+ std::this_thread::sleep_for (std::chrono::milliseconds (1000 / 60 ));
51
+ prdp_update_screen_no_game ();
52
+ }
53
+
54
+ n64_system_loop ();
56
55
}
57
56
58
57
void N64EmulatorThread::reset () {
59
- if (running) {
60
- n64_queue_reset ();
58
+ if (game_loaded) {
59
+ reset_n64system ();
60
+ n64_load_rom (n64sys.rom_path );
61
+ pif_rom_execute ();
61
62
}
62
63
}
63
64
0 commit comments