Skip to content

Commit 4c2187d

Browse files
committed
VAmiga integration
1 parent 7e41fce commit 4c2187d

File tree

18 files changed

+305
-198
lines changed

18 files changed

+305
-198
lines changed

libs/amDebugger/src/amDebugger/codeAnalyzer/cdaServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct CodeChunk : public eastl::intrusive_list_node {
5959

6060
class M68CodeDisassembler
6161
{
62-
SINGLETON_DECLARE(M68CodeDisassembler);
62+
SINGLETON_DECLARATION(M68CodeDisassembler);
6363

6464
public:
6565
csh* m_pCapstone = nullptr;

libs/amDebugger/src/amDebugger/debuggerConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
struct DbgConfig {
6-
SINGLETON_DECLARE(DbgConfig);
6+
SINGLETON_DECLARATION(DbgConfig);
77

88
bool showVHPopsLines = false;
99

libs/amDebugger/src/amDebugger/vm/vmInterface.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "vmInterface.h"
2+
#include "EASTL/span.h"
23

34
namespace IVm {
45

@@ -7,8 +8,6 @@ namespace IVm {
78

89

910
VM::VM()
10-
: m_pModules({(IModule**)(&mem), (IModule**)(&cpu), (IModule**)&custom, (IModule**)&copper, (IModule**)&blitter,
11-
(IModule**)&floppies[0]})
1211
{}
1312

1413

@@ -17,9 +16,9 @@ VM::~VM() {}
1716

1817
void VM::init()
1918
{
20-
for (IModule** curModule : m_pModules)
19+
for (IModule* curModule : eastl::span<IModule *>(&m_modSectBeg, &m_modSectEnd))
2120
{
22-
IModule* pCurMod = *curModule;
21+
IModule* pCurMod = curModule;
2322
if (pCurMod)
2423
pCurMod->init(this);
2524
}
@@ -29,9 +28,9 @@ void VM::init()
2928

3029
void VM::fetchStateFromEmu()
3130
{
32-
for (IModule** curModule : m_pModules)
31+
for (IModule* curModule : eastl::span<IModule *>(&m_modSectBeg, &m_modSectEnd))
3332
{
34-
IModule* pCurMod = *curModule;
33+
IModule* pCurMod = curModule;
3534
if (pCurMod)
3635
pCurMod->fetch();
3736
}

libs/amDebugger/src/amDebugger/vm/vmInterface.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class VM
6161

6262

6363
protected:
64-
int amiga_width = (754 + 7) & ~7;
65-
int amiga_height = 576;
64+
int m_scrSizeX = (754 + 7) & ~7;
65+
int m_scrSizeY = 576;
6666
bool mInit = false;
6767
IVm::EVmDebugMode m_debugMode = IVm::EVmDebugMode::Live;
6868
VM();
@@ -75,30 +75,33 @@ class VM
7575
virtual qd::EFlow applyOperationMsgProcImp(qd::operation::BaseOpArgs* /*args*/) override;
7676
virtual void applyVmConfig(CfgVmPrefs* prefs);
7777

78-
int getScreenSizeX() const { return amiga_width; }
79-
int getScreenSizeY() const { return amiga_height; }
78+
int getScreenSizeX() const { return m_scrSizeX; }
79+
int getScreenSizeY() const { return m_scrSizeY; }
8080
virtual int getCurCycle() { return -1; }
8181
virtual int getVPos() { return -1; }
8282
virtual int getHPos() { return -1; }
8383

8484
virtual IVm::EVmDebugMode getVmDebugMode() const { return m_debugMode; }
8585
virtual void setVmDebugMode(IVm::EVmDebugMode debug_mode) { m_debugMode = debug_mode; }; // base
8686

87+
IVm::IModule* m_modSectBeg = nullptr;
8788
IVm::Memory* mem = nullptr;
8889
IVm::Cpu* cpu = nullptr;
8990
IVm::CustomRegs* custom = nullptr;
9091
IVm::Copper* copper = nullptr;
9192
IVm::Blitter* blitter = nullptr;
92-
qd::array<IVm::Floppy*, IVm::MAX_FLOPPIES> floppies = {};
93+
IVm::Floppy* floppy0 = nullptr;
94+
IVm::Floppy* floppy1 = nullptr;
95+
IVm::Floppy* floppy2 = nullptr;
96+
IVm::Floppy* floppy3 = nullptr;
9397
IVm::Emu* emu = nullptr;
94-
95-
qd::array<IModule**, MS_MAX_COUNT> m_pModules;
98+
IVm::IModule* m_modSectEnd = nullptr;
9699

97100
}; // class IVm::VM
98101
//////////////////////////////////////////////////////////////////////////
99102

100103

101-
class Floppy : public IModule
104+
class Floppy : public IVm::IModule
102105
{
103106
public:
104107
int m_nFloppy = 0;
@@ -114,7 +117,7 @@ class Floppy : public IModule
114117
//////////////////////////////////////////////////////////////////////////
115118

116119

117-
class Emu : public IModule
120+
class Emu : public IVm::IModule
118121
{
119122
public:
120123
virtual int getDebugDmaMode() { return 0; }
@@ -131,7 +134,7 @@ class Emu : public IModule
131134
//////////////////////////////////////////////////////////////////////////
132135

133136

134-
class Memory : public IModule
137+
class Memory : public IVm::IModule
135138
{
136139
public:
137140
qd::array<IVm::MemBank, EMemSrc::MAX_COUNT> m_banks;
@@ -156,7 +159,7 @@ class Memory : public IModule
156159
//////////////////////////////////////////////////////////////////////////
157160

158161

159-
class Cpu : public IModule
162+
class Cpu : public IVm::IModule
160163
{
161164
public:
162165
virtual uint32_t getRegA(int i) const = 0;
@@ -168,7 +171,7 @@ class Cpu : public IModule
168171
//////////////////////////////////////////////////////////////////////////
169172

170173

171-
class CustomRegs : public IModule
174+
class CustomRegs : public IVm::IModule
172175
{
173176
public:
174177
virtual void fetch() override = 0;

libs/qd/base/baseTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static constexpr int64_t TTime64_MAX = INT64_MAX;
1515

1616

1717
//////////////////////////////////////////////////////////////////////////
18-
#define SINGLETON_DECLARE(TClassName) \
18+
#define SINGLETON_DECLARATION(TClassName) \
1919
public: \
2020
static TClassName& getSingleton() \
2121
{ \

libs/vAmiga_imp_lib/src/qvAmigaImp/va_server_app_part.cpp

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,16 @@
33
#include "qd/thread/thread.h"
44
#include "quasar_app/qsr_application.h"
55

6-
7-
8-
class VAmigaServerProviderFactory : public qsr::IAppPartServerProviderFactory
9-
{
10-
virtual bool createServerAppPart(qsr::ServerAppPartCreateCtx &ctx) override {
11-
ctx.outName = "VAmiga";
12-
ctx.outPartPtr = new qsr::VAmServerAppPart();
13-
ctx.outTypeInfo = &qd::typeof_<qsr::VAmServerAppPart>();
14-
return true;
15-
}
16-
};
17-
static qsr::plugin_api::RegOnLoadAppPartServerFactory reg_me(std::make_unique<VAmigaServerProviderFactory>());
18-
19-
20-
6+
//------------------------------------------------------------------------
217
namespace qsr {
228

239

24-
VAmServerAppPart::VAmServerAppPart() {
25-
}
26-
27-
28-
VAmServerAppPart::~VAmServerAppPart() {
29-
}
30-
3110
//------------------------------------------------------------------------
3211
class VAmSharedConnectionImpl : public amD::IVmDbgServiceBridge {
3312
public:
3413
ref_ptr<IVm::VM> m_pVAmVm;
3514

36-
VAmSharedConnectionImpl(ref_ptr<IVm::VM> pVAmVm) : m_pVAmVm(pVAmVm) {
37-
}
15+
VAmSharedConnectionImpl(ref_ptr<IVm::VM> pVAmVm) : m_pVAmVm(pVAmVm) {}
3816

3917
virtual ref_ptr<IVm::VM> getClientVm() override {
4018
return m_pVAmVm;
@@ -47,18 +25,51 @@ class VAmSharedConnectionImpl : public amD::IVmDbgServiceBridge {
4725
//////////////////////////////////////////////////////////////////////////
4826

4927

50-
struct VAmConnImpl : public amD::IVmConnectionBuilder {
51-
VAmServerAppPart *m_pVAmAppPart;
52-
VAmConnImpl(VAmServerAppPart *pApp) : m_pVAmAppPart(pApp) {
28+
29+
class VAmigaServerProviderFactory : public qsr::IAppPartServerProviderFactory
30+
{
31+
qsr::VAmServerAppPart *m_pVAmAppPart = nullptr;
32+
public:
33+
virtual void setup() override {
34+
id = "vamiga";
35+
guiName = "vAmiga emulator";
5336
}
54-
virtual ref_ptr<amD::IVmDbgServiceBridge> createConnection() const override {
37+
38+
virtual bool createServerAppPart(qsr::ServerAppPartCreateCtx &ctx) override {
39+
m_pVAmAppPart = new qsr::VAmServerAppPart();
40+
ctx.outPartPtr = m_pVAmAppPart;
41+
return true;
42+
}
43+
44+
virtual ref_ptr<amD::IVmDbgServiceBridge> createConnection() override {
5545
ref_ptr<IVm::VM> vm = m_pVAmAppPart->getVm();
5646
assert(vm);
57-
ref_ptr<VAmSharedConnectionImpl> pInst = new VAmSharedConnectionImpl(vm);
47+
ref_ptr<qsr::VAmSharedConnectionImpl> pInst = new qsr::VAmSharedConnectionImpl(vm);
5848
return pInst;
5949
}
50+
51+
};
52+
static qsr::plugin_api::RegOnLoadAppPartServerFactory reg_me(new VAmigaServerProviderFactory());
53+
//////////////////////////////////////////////////////////////////////////
54+
55+
56+
VAmServerAppPart::VAmServerAppPart() {
57+
}
58+
59+
60+
VAmServerAppPart::~VAmServerAppPart() {
61+
}
62+
63+
64+
65+
/*
66+
struct VAmConnImpl : public amD::IVmConnectionBuilder {
67+
VAmServerAppPart *m_pVAmAppPart;
68+
VAmConnImpl(VAmServerAppPart *pApp) : m_pVAmAppPart(pApp) {
69+
}
6070
};
6171
//////////////////////////////////////////////////////////////////////////
72+
*/
6273

6374

6475
void VAmServerAppPart::onPartCreate(qd::ApplicationPart::OnCreate_t &prm) {
@@ -67,9 +78,9 @@ void VAmServerAppPart::onPartCreate(qd::ApplicationPart::OnCreate_t &prm) {
6778
m_pVAmThread = new VAmServerThread(this);
6879
m_pVAmThread->initialize();
6980

70-
m_pConnBuilder = new VAmConnImpl(this);
71-
QuaesarVmServersMgr *pSvMgr = ((QuaesarApplication *)getApp())->m_pVmServersMgr;
72-
pSvMgr->registerVmServer(EQuaServerId::S_VAMIGA, m_pConnBuilder);
81+
// m_pConnBuilder = new VAmConnImpl(this);
82+
// QuaesarVmServersMgr *pSvMgr = ((QuaesarApplication *)getApp())->m_pVmServersMgr;
83+
// pSvMgr->registerVmServer(EQuaServerId::S_VAMIGA, m_pConnBuilder);
7384
}
7485

7586

libs/vAmiga_imp_lib/src/qvAmigaImp/va_vm_imp.cpp

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ namespace IVm::imp {
3434

3535
VAmVmImp::VAmVmImp(VAmServerThread* pVAmThread, vamiga::VAmiga* pVAmiga) {
3636
m_pVAmThread = pVAmThread;
37-
m_vaAmiga = pVAmiga;
38-
m_vaAccess = new QuaesarVAmigaInjectAccess(m_vaAmiga);
37+
m_vAmiga = pVAmiga;
38+
m_vaAccess = new QuaesarVAmigaInjectAccess(m_vAmiga);
3939
main = m_vaAccess->main;
4040

4141
instCpu.m_pVm = this;
42-
instCpu.m_pVAmiga = m_vaAmiga;
42+
instCpu.m_pVAmiga = m_vAmiga;
4343
instMemory.m_pVm = this;
44-
instMemory.m_pVAmiga = m_vaAmiga;
44+
instMemory.m_pVAmiga = m_vAmiga;
4545
TSuper::cpu = &instCpu;
4646
TSuper::mem = &instMemory;
4747
TSuper::custom = &instCustomRegs;
@@ -51,10 +51,10 @@ VAmVmImp::VAmVmImp(VAmServerThread* pVAmThread, vamiga::VAmiga* pVAmiga) {
5151
instEmu.vm = this;
5252
TSuper::emu = &instEmu;
5353
}
54-
for (size_t i = 0; i < TSuper::floppies.size(); ++i) {
54+
for (size_t i = 0; i < IVm::MAX_FLOPPIES; ++i) {
5555
VAmVmImp::Floppy& curFloppy = instFloppies[i];
5656
curFloppy.m_nFloppy = (int)i;
57-
TSuper::floppies[i] = &curFloppy;
57+
(&floppy0)[i] = &curFloppy;
5858
}
5959
}
6060

@@ -193,16 +193,16 @@ void VAmVmImp::Emu::setDebugDmaMode(int p_mode) {
193193

194194
void VAmVmImp::setVmDebugMode(EVmDebugMode debug_mode) {
195195
TSuper::setVmDebugMode(debug_mode);
196-
if (debug_mode == EVmDebugMode::Break) {
197-
while (!instEmu.isDebugActivatedFull()) {
198-
// ::debugger_active = 0;
199-
// ::debugging = 0;
200-
// ::activate_debugger_new();
201-
}
202-
} else if (debug_mode == EVmDebugMode::Live) {
203-
if (m_pVAmThread) m_pVAmThread->execConsoleCmd("g");
204-
// ::debugger_active = 0;
205-
}
196+
// if (debug_mode == EVmDebugMode::Break) {
197+
// while (!instEmu.isDebugActivatedFull()) {
198+
// // ::debugger_active = 0;
199+
// // ::debugging = 0;
200+
// // ::activate_debugger_new();
201+
// }
202+
// } else if (debug_mode == EVmDebugMode::Live) {
203+
// if (m_pVAmThread) m_pVAmThread->execConsoleCmd("g");
204+
// // ::debugger_active = 0;
205+
// }
206206
}
207207

208208
int VAmVmImp::getVPos() { return 0; }
@@ -235,6 +235,27 @@ void VAmVmImp::Floppy::setEnabled(bool v) {
235235
// cfgFloppy.dfxtype = v ? 0 : -1;
236236
}
237237

238+
239+
void VAmVmImp::Floppy::setAdfPath(const qd::string &v)
240+
{
241+
vamiga::FloppyDriveAPI *df = m_pVm->m_vAmiga->df[m_nFloppy];
242+
df->insert(v.c_str(), m_writeProtect);
243+
}
244+
245+
246+
qd::string VAmVmImp::Floppy::getAdfPath()
247+
{
248+
//vamiga::FloppyDriveAPI *df = m_pVm->m_vAmiga->df[m_nFloppy];
249+
return "";
250+
}
251+
252+
253+
void VAmVmImp::Floppy::init(IVm::VM *vm)
254+
{
255+
m_pVm = static_cast<VAmVmImp *>(vm);
256+
}
257+
258+
238259
bool VAmVmImp::Cpu::getFlg(ECpuFlg_ f) const {
239260
switch (f) {
240261
case IVm::CpuFlg_Z:
@@ -289,7 +310,7 @@ uint8_t* VAmVmImp::Memory::getRealAddr(AddrRef ptr) {
289310

290311
void VAmVmImp::Memory::init(IVm::VM* p_vm) {
291312
m_pVm = (VAmVmImp*)p_vm;
292-
vamiga::VAmiga* pVAmiga = m_pVm->m_vaAmiga;
313+
vamiga::VAmiga* pVAmiga = m_pVm->m_vAmiga;
293314
const vamiga::MemInfo& memInfo = pVAmiga->mem.getInfo();
294315
const vamiga::MemConfig& memCfg = pVAmiga->mem.getConfig();
295316

0 commit comments

Comments
 (0)