Skip to content

Commit d125cc8

Browse files
committed
VAmiga imp theblacklotus#2
1 parent 81fc8af commit d125cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1187
-836
lines changed

CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,27 @@ set(CMAKE_CXX_EXTENSIONS False)
1818
set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
1919
set(CAPSTONE_M68K_SUPPORT ON CACHE BOOL "" FORCE)
2020

21-
include(scripts/cmake/format_sources.cmake)
21+
22+
# Include CMake helper utils
2223
include(scripts/cmake/compile_options.cmake)
24+
include(scripts/cmake/format_sources.cmake)
2325
include(external/sdl2/sdl2.cmake)
2426

25-
# Libraries
27+
28+
# Include CMakelists.txt libraries
29+
set(UAE_CUSTOM_IMPL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/uae_lib_imp" CACHE INTERNAL "Path to UAE custom implementation directory")
30+
add_subdirectory(libs/uae_lib)
2631
add_subdirectory(external/zlib)
2732
add_subdirectory(external/ADFlib)
2833
add_subdirectory(external/dear_imgui)
2934
add_subdirectory(external/EASTL)
3035
add_subdirectory(external/capstone)
3136
add_subdirectory(external/nativefiledialog-extended) #nfd
3237
add_subdirectory(libs/qd)
33-
add_subdirectory(libs/vAmiga)
3438
add_subdirectory(libs/amDebugger)
3539
add_subdirectory(libs/exprParser)
36-
37-
set(UAE_CUSTOM_IMPL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/uae_lib_imp" CACHE INTERNAL "Path to UAE custom implementation directory")
38-
add_subdirectory(libs/uae_lib)
40+
add_subdirectory(libs/vAmiga)
41+
add_subdirectory(libs/vamiga_imp_lib)
3942

4043
# Quasar *.h/cpp files
4144
file(GLOB_RECURSE QUAESAR_SOURCES "src/*.cpp")
@@ -150,7 +153,7 @@ target_link_libraries(quaesar PRIVATE
150153
qd
151154
uae_lib
152155
amDebugger
153-
VACore
156+
VamigaImpLib
154157
)
155158

156159

@@ -162,7 +165,6 @@ target_link_libraries(quaesar PRIVATE
162165
add_option_edit_and_continue(quaesar)
163166
add_option_edit_and_continue(qd)
164167
add_option_edit_and_continue(amDebugger)
165-
add_option_edit_and_continue(VACore)
166168

167169

168170
if (WIN32)

libs/amDebugger/src/amDebugger/codeAnalyzer/cdaServer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ struct CapstoneDisassemblerContext {
9696
{
9797
reset();
9898
const uint8_t* startDisasmDat = vm->mem->getRealAddr(begAddr);
99+
if (!startDisasmDat)
100+
return;
99101
uint32_t countBytes = endAddr - begAddr;
100102
m_nInstructions =
101103
cs_disasm(*m_pCapstone, startDisasmDat, countBytes, begAddr, countBytes / 2, &m_pInstructions);

libs/amDebugger/src/amDebugger/dbgConnection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace amD {
77
class UaeSharedConnectionImpl;
88

99

10-
class IVmServiceConnection : public qd::RefCounted
10+
class IVmServiceProvider : public qd::RefCounted
1111
{
1212
public:
1313
qd::string m_name;
@@ -16,12 +16,12 @@ class IVmServiceConnection : public qd::RefCounted
1616
virtual ref_ptr<IVm::VM> getClientVm() = 0;
1717
virtual ref_ptr<IVm::VM> getServerVm() = 0;
1818

19-
}; // IVmServiceConnection
19+
}; // IVmServiceProvider
2020
//////////////////////////////////////////////////////////////////////////
2121

2222

23-
ref_ptr<IVmServiceConnection> create_dummy_connection();
24-
ref_ptr<IVmServiceConnection> create_uae_shared_connection(const char* name);
23+
ref_ptr<IVmServiceProvider> create_dummy_connection();
24+
ref_ptr<IVmServiceProvider> create_uae_shared_connection(const char* name);
2525

2626

2727
}; // namespace amD

libs/amDebugger/src/amDebugger/debugger.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ namespace amD {
88
DbgProjOptinons g_opt = {};
99

1010

11-
Debugger::Debugger(DebuggerApp* _app, ref_ptr<IVmServiceConnection> pCon)
11+
Debugger::Debugger(DebuggerApp* _app)
1212
: m_pDbgApp(_app)
13-
, m_pConnection(pCon)
1413
{
15-
assert(m_pConnection);
1614
}
1715

1816

19-
void Debugger::init()
17+
18+
19+
IVm::VM* Debugger::getVm() const
2020
{
21-
m_pVm = m_pConnection->getClientVm();
22-
assert(m_pVm);
21+
return m_pVm.get();
2322
}
2423

2524

@@ -48,6 +47,31 @@ qd::EFlow Debugger::setupDefaultOperationArgsImp(qd::operation::BaseOpArgs* args
4847
}
4948

5049

50+
void Debugger::fetchVmState()
51+
{
52+
if (m_pVm)
53+
m_pVm->fetchStateFromEmu();
54+
}
55+
56+
57+
amD::IVmServiceProvider* Debugger::getConnection() const
58+
{
59+
return m_pConnection.get();
60+
}
61+
62+
63+
void Debugger::setConnection(ref_ptr<IVmServiceProvider> pCon)
64+
{
65+
if (m_pConnection == pCon)
66+
return;
67+
m_pConnection = pCon;
68+
if (m_pConnection)
69+
m_pVm = m_pConnection->getClientVm();
70+
else
71+
m_pVm = nullptr;
72+
}
73+
74+
5175
void Debugger::execConsoleCmd(qd::string&& cmd)
5276
{
5377
amD::operation::ExecConsoleCmd exec;

libs/amDebugger/src/amDebugger/debugger.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace amD {
1010

1111
class DebuggerApp;
12-
class IVmServiceConnection;
12+
class IVmServiceProvider;
1313

1414
constexpr static int BREAKPOINTS_MAX = 20;
1515

@@ -20,7 +20,7 @@ class Breakpoint
2020
AddrRef addr1 = {};
2121
AddrRef addr2 = {};
2222
bool enabled = false;
23-
EReg reg;
23+
IVm::EReg reg;
2424
}; // class Breakpoint
2525
//////////////////////////////////////////////////////////////////////////
2626

@@ -51,28 +51,26 @@ struct DbgProjOptinons
5151
extern DbgProjOptinons g_opt;
5252

5353

54-
// Debugger client
54+
//------------------------------------------------------------------------
55+
// Debugger client engine
5556
//
5657
class Debugger
5758
: public qd::RefCounted
5859
, public qd::IOperationEnvironment
5960
{
6061
DebuggerApp* m_pDbgApp = nullptr;
61-
ref_ptr<IVmServiceConnection> m_pConnection;
62+
ref_ptr<IVmServiceProvider> m_pConnection;
63+
ref_ptr<IVm::VM> m_pVm = nullptr; // owner
6264

6365
public:
64-
ref_ptr<IVm::VM> m_pVm = nullptr;
65-
66-
public:
67-
Debugger(DebuggerApp* _app, ref_ptr<IVmServiceConnection> pCon);
66+
Debugger(DebuggerApp* _app);
6867
virtual ~Debugger() override = default;
6968

70-
void init();
71-
IVm::VM* getVm() const { return m_pVm.get(); }
69+
IVm::VM* getVm() const;
7270
amD::DebuggerApp* getDbgApp() const { return m_pDbgApp; }
7371

74-
75-
amD::IVmServiceConnection* getConnection() const { return m_pConnection.get(); }
72+
amD::IVmServiceProvider* getConnection() const;
73+
void setConnection(ref_ptr<IVmServiceProvider> pCon);
7674

7775
void execConsoleCmd(qd::string&& cmd);
7876

@@ -88,15 +86,16 @@ class Debugger
8886

8987
bool isDebugActivated() const;
9088
void setDebugMode(EVmDebugMode debug_mode);
89+
void fetchVmState();
9190

9291
//------------------------------------------------------------------------
9392
// Implement Operation Environment
9493
virtual IOperationEnvironment* getOpEnvParent() const override { return nullptr; }
9594
virtual qd::EFlow applyOperationMsgProcImp(qd::operation::BaseOpArgs* args) override;
9695
virtual qd::EFlow setupDefaultOperationArgsImp(qd::operation::BaseOpArgs* args) const override;
9796

98-
9997
}; // class Debugger
98+
//////////////////////////////////////////////////////////////////////////
10099

101100

102101
}; // namespace amD

libs/amDebugger/src/amDebugger/debuggerOps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ FORWARD_DECLARATION_2(amD, DebuggerDesktop);
1010
FORWARD_DECLARATION_3(amD, operation, Operation);
1111
FORWARD_DECLARATION_3S(amD, shortcut, EId);
1212

13+
using namespace IVm;
1314

1415
namespace amD {
1516

@@ -109,7 +110,7 @@ struct DebugTraceContinue : public amD::operation::OperationArgs {
109110
d.m_name = "Continue";
110111
d.addShortcut(amD::shortcut::EId::DebugTraceContinue);
111112
}
112-
amD::EVmDebugMode debugMode = EVmDebugMode::Live;
113+
IVm::EVmDebugMode debugMode = EVmDebugMode::Live;
113114
};
114115

115116

libs/amDebugger/src/amDebugger/debuggerServer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ namespace amD {
99

1010
class IVmConnectionBuilder : public qd::RefCounted, public qd::IOperationEnvironment
1111
{
12-
public:
12+
protected:
1313
IVm::VM* vm = nullptr;
1414

15+
public:
16+
1517
void init();
1618
IVm::VM* getVm() const { return vm; }
17-
virtual ref_ptr<amD::IVmServiceConnection> createConnection() const = 0;
19+
virtual ref_ptr<amD::IVmServiceProvider> createConnection() const = 0;
1820

1921
}; // class IVmConnectionBuilder
2022

libs/amDebugger/src/amDebugger/debuggerWndApp.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ constexpr uint32_t g_nDebuggerWndSizeY = 800;
2727
DebuggerApp::DebuggerApp()
2828
{
2929
setPartActive(true);
30-
setPartVisible(true);
30+
setPartRenderable(true);
31+
32+
m_pDebugger = new amD::Debugger(this); // Debugger client
3133
}
3234

3335

@@ -43,14 +45,7 @@ void DebuggerApp::init()
4345
createRenderWindow();
4446
initImGui();
4547

46-
amD::IVmConnectionsManager* pConnMgr = m_pApp->getInterface_<amD::IVmConnectionsManager>();
47-
ASSERT_AND_DO(pConnMgr, return);
48-
ref_ptr<IVmServiceConnection> pCurConnect = pConnMgr->createVmConnectionByInd(0);
49-
assert(pCurConnect);
50-
51-
m_pDebugger = new amD::Debugger(this, pCurConnect); // Debugger client
52-
m_pDebugger->init();
53-
48+
// m_pDebugger->setConnection(pCurConnect);
5449

5550
assert(m_pDebugger);
5651
qd::UiNodeCreator mk;
@@ -88,7 +83,6 @@ void DebuggerApp::createRenderWindow()
8883

8984
void DebuggerApp::initImGui()
9085
{
91-
9286
auto pImGuiMgr = qd::ModuleManager::get()->getModuleInstOrCreate_<qd::ImGuiContextManager>();
9387
m_pQimGuiCtx = pImGuiMgr->createContextImGui(m_pWindow, m_pWndRenderer);
9488

@@ -115,13 +109,6 @@ qd::EFlow DebuggerApp::applyOperationMsgProcImp(qd::operation::BaseOpArgs* p_msg
115109
}
116110

117111

118-
// amD::DebuggerApp* DebuggerApp::get() {
119-
// return g_pInstance;
120-
// }
121-
122-
123-
124-
125112
void DebuggerApp::destroy()
126113
{
127114
if (m_pOperationMgr)
@@ -147,6 +134,7 @@ void DebuggerApp::update(float /*dt*/, float /*time*/)
147134
if (isWndVisible())
148135
{
149136
m_pQimGuiCtx->newFrame();
137+
getDbg()->fetchVmState();
150138
m_pGui->drawImGuiMainFrame();
151139
m_pQimGuiCtx->endFrame();
152140
}
@@ -176,12 +164,12 @@ void DebuggerApp::setWndVisible(bool v)
176164
if (v)
177165
{
178166
SDL_ShowWindow(m_pWindow);
179-
setPartVisible(true);
167+
setPartRenderable(true);
180168
}
181169
else
182170
{
183171
SDL_HideWindow(m_pWindow);
184-
setPartVisible(false);
172+
setPartRenderable(false);
185173
}
186174
}
187175

@@ -212,6 +200,12 @@ qd::EFlow DebuggerApp::onSdlEventProc(SDL_Event& event)
212200
}
213201

214202

203+
IVm::VM* DebuggerApp::getVm() const
204+
{
205+
return m_pDebugger->getVm();
206+
}
207+
208+
215209
const amD::Breakpoint* BreakpointsSortedList::getBpByAddr(AddrRef addr, EReg /*reg*/) const
216210
{
217211
OneAddrBp lh;

libs/amDebugger/src/amDebugger/debuggerWndApp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ FORWARD_DECLARATION_2(IVm, VM);
2323
namespace amD {
2424

2525
class DebuggerDesktop;
26-
class IVmServiceConnection;
26+
class IVmServiceProvider;
2727

2828

2929
class IVmConnectionsManager
@@ -32,7 +32,7 @@ class IVmConnectionsManager
3232

3333
public:
3434
virtual uint32_t getNumConnections() = 0;
35-
virtual ref_ptr<amD::IVmServiceConnection> createVmConnectionByInd(uint32_t idx) = 0;
35+
virtual ref_ptr<amD::IVmServiceProvider> createVmProvider(const char* conn_id) = 0;
3636
}; // class IVmConnectionsManager
3737

3838

@@ -69,7 +69,7 @@ class DebuggerApp
6969
void setWndVisible(bool v);
7070
virtual qd::EFlow onSdlEventProc(SDL_Event& event) override;
7171

72-
IVm::VM* getVm() const { return m_pDebugger->getVm(); }
72+
IVm::VM* getVm() const;
7373

7474
amD::Debugger* getDbg() const { return m_pDebugger; }
7575

libs/amDebugger/src/amDebugger/ui/debuggerDesktop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void DebuggerDesktop::_drawMainMenuBar()
6666

6767
if (auto pm = qIm::LockMenu("Debug"))
6868
{
69-
amD::EVmDebugMode debugMode = vm->getVmDebugMode();
69+
IVm::EVmDebugMode debugMode = vm->getVmDebugMode();
7070
qIm::menuItemFromOperationArgs_<amD::operation::DebugTraceContinue>(pDbg, "", false,
7171
debugMode.isBreak());
7272
qIm::menuItemFromOperationArgs_<amD::operation::DebugTraceStart>(pDbg, "", false, debugMode.isLive());

0 commit comments

Comments
 (0)