Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit d37bff5

Browse files
committed
OOPIFY: Convert SoundCPU to an A0H
1 parent 0d14750 commit d37bff5

File tree

8 files changed

+26
-29
lines changed

8 files changed

+26
-29
lines changed

libswirl/hw/aica/aica_mmio.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <math.h>
1111
#include "hw/holly/holly_intc.h"
1212
#include "hw/holly/sb.h"
13+
#include "hw/arm7/SoundCPU.h"
1314

1415
#define SH4_IRQ_BIT (1<<(holly_SPU_IRQ&255))
1516

@@ -381,7 +382,7 @@ void WriteMem_aica_rtc(u32 addr,u32 data,u32 sz)
381382
void ArmSetRST()
382383
{
383384
ARMRST&=1;
384-
g_SoundCPU->SetResetState(ARMRST);
385+
sh4_cpu->GetA0H<SoundCPU>(A0H_SCPU)->SetResetState(ARMRST);
385386
}
386387

387388
//Init/res/term

libswirl/hw/arm7/SoundCPU.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// nullAICA.cpp : Defines the entry point for the DLL application.
22
//
33

4-
#include "types.h"
4+
#include "SoundCPU.h"
55
#include "arm7.h"
66
#include "arm_mem.h"
77

88
struct SoundCPU_impl : SoundCPU {
99

1010
//called when plugin is used by emu (you should do first time init here)
11-
s32 Init()
11+
bool Init()
1212
{
1313
arm_Init();
1414

15-
return rv_ok;
15+
return true;
1616
}
1717

1818
//called when plugin is unloaded by emu, only if dcInit is called (eg, not called to enumerate plugins)

libswirl/hw/arm7/SoundCPU.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
#include "hw/sh4/sh4_mmio.h"
3+
struct SoundCPU : MMIODevice {
4+
5+
virtual void SetResetState(u32 State) = 0;
6+
virtual void Update(u32 cycles) = 0;
7+
8+
virtual ~SoundCPU() { }
9+
10+
static SoundCPU* Create();
11+
};

libswirl/hw/sh4/interpr/sh4_interpreter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "profiler/profiler.h"
2222
#include "../dyna/blockmanager.h"
2323
#include "../sh4_sched.h"
24+
#include "hw/arm7/SoundCPU.h"
2425

2526
#include "libswirl.h"
2627

@@ -106,7 +107,7 @@ int AicaUpdate(void* psh4, int tag, int c, int j)
106107

107108
//if (aica_sample_cycles>=AICA_SAMPLE_CYCLES)
108109
{
109-
g_SoundCPU->Update(512 * 32);
110+
sh4_cpu->GetA0H<SoundCPU>(A0H_SCPU)->Update(512 * 32);
110111
sh4_cpu->GetA0H<AICA>(A0H_AICA)->Update(1 * 32);
111112
//aica_sample_cycles-=AICA_SAMPLE_CYCLES;
112113
}

libswirl/hw/sh4/sh4_if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ enum Area0Hanlders {
250250
A0H_MAPLE,
251251
A0H_ASIC,
252252
A0H_SPG,
253+
A0H_SCPU,
253254

254255
A0H_MAX
255256
};

libswirl/libswirl.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "hw/modem/modem.h"
3333
#include "hw/holly/holly_intc.h"
3434
#include "hw/aica/aica_mmio.h"
35+
#include "hw/arm7/SoundCPU.h"
3536

3637
#define fault_printf(...)
3738

@@ -41,7 +42,7 @@
4142

4243
unique_ptr<VirtualDreamcast> virtualDreamcast;
4344
unique_ptr<GDRomDisc> g_GDRDisc;
44-
unique_ptr<SoundCPU> g_SoundCPU;
45+
4546
MMIODevice* g_GDRomDrive;
4647

4748

@@ -125,21 +126,11 @@ s32 plugins_Init()
125126
return rv;
126127
#endif
127128

128-
129-
g_SoundCPU.reset(SoundCPU::Create());
130-
131-
if (s32 rv = g_SoundCPU->Init())
132-
return rv;
133-
134129
return rv_ok;
135130
}
136131

137132
void plugins_Term()
138133
{
139-
//term all plugins
140-
g_SoundCPU->Term();
141-
g_SoundCPU.reset(nullptr);
142-
143134
g_GDRDisc->Term();
144135
g_GDRDisc.reset(nullptr);
145136
}
@@ -148,7 +139,6 @@ void plugins_Reset(bool Manual)
148139
{
149140
reios_reset();
150141
g_GDRDisc->Reset(Manual);
151-
g_SoundCPU->Reset(Manual);
152142
//libExtDevice_Reset(Manual);
153143
}
154144

@@ -823,6 +813,8 @@ struct Dreamcast_impl : VirtualDreamcast {
823813
SPG* spg = SPG::Create(asic);
824814
MMIODevice* pvrDevice = Create_PVRDevice(systemBus, asic, spg);
825815
MMIODevice* aicaDevice = Create_AicaDevice(systemBus, asic);
816+
SoundCPU* soundCPU = SoundCPU::Create();
817+
826818
MMIODevice* mapleDevice = Create_MapleDevice(systemBus, asic);
827819

828820
MMIODevice* extDevice = Create_ExtDevice(); // or Create_Modem();
@@ -848,7 +840,8 @@ struct Dreamcast_impl : VirtualDreamcast {
848840
sh4_cpu->SetA0Handler(A0H_MAPLE, mapleDevice);
849841
sh4_cpu->SetA0Handler(A0H_ASIC, asic);
850842
sh4_cpu->SetA0Handler(A0H_SPG, spg);
851-
843+
sh4_cpu->SetA0Handler(A0H_SCPU, soundCPU);
844+
852845
return sh4_cpu->Init();
853846
}
854847

libswirl/libswirl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct VirtualDreamcast {
2323

2424
extern unique_ptr<VirtualDreamcast> virtualDreamcast;
2525
extern unique_ptr<GDRomDisc> g_GDRDisc;
26-
extern unique_ptr<SoundCPU> g_SoundCPU;
26+
2727
extern MMIODevice* g_GDRomDrive;
2828

2929

libswirl/types.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -773,17 +773,7 @@ static u32 libExtDevice_ReadMem_A5(u32 addr,u32 size){ return 0; }
773773
static void libExtDevice_WriteMem_A5(u32 addr,u32 data,u32 size) { }
774774

775775
//ARM
776-
struct SoundCPU {
777-
virtual s32 Init() = 0;
778-
virtual void Reset(bool M) = 0;
779-
virtual void Term() = 0;
780776

781-
virtual void SetResetState(u32 State) = 0;
782-
virtual void Update(u32 cycles) = 0;
783-
virtual ~SoundCPU() { }
784-
785-
static SoundCPU* Create();
786-
};
787777

788778
#define ReadMemArrRet(arr,addr,sz) \
789779
{if (sz==1) \

0 commit comments

Comments
 (0)