Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
OOPIFY: Cleanups, gdrom serialize, fix sh4_cpu leak
Browse files Browse the repository at this point in the history
  • Loading branch information
skmp committed Jan 15, 2020
1 parent b64c979 commit 807079a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 42 deletions.
30 changes: 7 additions & 23 deletions libswirl/hw/gdrom/gdromv3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ struct GDRomV3_impl final : MMIODevice {
}
}

void gdrom_serialize(void** data, unsigned int* total_size) {
void serialize(void** data, unsigned int* total_size) {

REICAST_S(sns_asc);
REICAST_S(sns_ascq);
Expand Down Expand Up @@ -1049,7 +1049,7 @@ struct GDRomV3_impl final : MMIODevice {
REICAST_S(ByteCount);
}

bool gdrom_unserialize(void** data, unsigned int* total_size) {
void unserialize(void** data, unsigned int* total_size) {

REICAST_US(sns_asc);
REICAST_US(sns_ascq);
Expand All @@ -1075,8 +1075,6 @@ struct GDRomV3_impl final : MMIODevice {
REICAST_US(SecNumber);
REICAST_US(GDStatus);
REICAST_US(ByteCount);

return true;
}

int Update(int i, int c, int j)
Expand Down Expand Up @@ -1227,27 +1225,13 @@ MMIODevice* Create_GDRomDevice(SystemBus* sb, ASIC* asic) {
//disk changes etc
void libCore_gdrom_disc_change()
{
if (g_GDRomDrive) dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->gd_setdisc();
if (sh4_cpu) {
auto gdd = sh4_cpu->GetA0H<GDRomV3_impl>(A0H_GDROM);
if (gdd) gdd->gd_setdisc();
}
}

void libCore_CDDA_Sector(s16* sector)
{
dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->ReadCDDA(sector);
}
/*
u32 ReadMem_gdrom(u32 Addr, u32 sz)
{
return dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->Read(Addr, sz);
}
void WriteMem_gdrom(u32 Addr, u32 data, u32 sz)
{
dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->Write(Addr, data, sz);
}
*/
void gdrom_serialize(void** data, unsigned int* total_size) {
dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->gdrom_serialize(data, total_size);
}

bool gdrom_unserialize(void** data, unsigned int* total_size) {
return dynamic_cast<GDRomV3_impl*>(g_GDRomDrive)->gdrom_unserialize(data, total_size);
sh4_cpu->GetA0H<GDRomV3_impl>(A0H_GDROM)->ReadCDDA(sector);
}
2 changes: 1 addition & 1 deletion libswirl/hw/holly/holly_intc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//TODO: MOVE THIS
u32 SB_ISTNRM;

struct ASICDevice_impl : ASIC {
struct ASICDevice_impl final : ASIC {
SystemBus* sb;
ASICDevice_impl(SystemBus* sb) : sb(sb) { }

Expand Down
2 changes: 1 addition & 1 deletion libswirl/hw/holly/sb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Array<RegisterStruct> sb_regs(0x540);
u32 SB_FFST_rc;
u32 SB_FFST;

struct SystemBus_impl : SystemBus {
struct SystemBus_impl final : SystemBus {

u32 sbio_read_noacc(u32 addr) {
verify(false);
Expand Down
2 changes: 1 addition & 1 deletion libswirl/hw/maple/maple_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool IsOnSh4Ram(u32 addr)

u32 dmacount=0;

struct MapleDevice : MMIODevice {
struct MapleDevice final : MMIODevice {

void SB_MSHTCL_Write(u32 addr, u32 data)
{
Expand Down
9 changes: 4 additions & 5 deletions libswirl/libswirl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
unique_ptr<VirtualDreamcast> virtualDreamcast;
unique_ptr<GDRomDisc> g_GDRDisc;

MMIODevice* g_GDRomDrive;


void FlushCache();
void LoadCustom();
Expand Down Expand Up @@ -805,7 +803,7 @@ struct Dreamcast_impl : VirtualDreamcast {
#if DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE
Create_NaomiDevice(systemBus)
#else
(g_GDRomDrive = Create_GDRomDevice(systemBus, asic))
Create_GDRomDevice(systemBus, asic)
#endif
;

Expand Down Expand Up @@ -851,8 +849,6 @@ struct Dreamcast_impl : VirtualDreamcast {
{
sh4_cpu->Term();

g_GDRomDrive = nullptr;

#if DC_PLATFORM != DC_PLATFORM_DREAMCAST
naomi_cart_Close();
#endif
Expand All @@ -864,6 +860,9 @@ struct Dreamcast_impl : VirtualDreamcast {
mcfg_DestroyDevices();

SaveSettings();

delete sh4_cpu;
sh4_cpu = nullptr;
}

void Stop()
Expand Down
2 changes: 0 additions & 2 deletions libswirl/libswirl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct VirtualDreamcast {
extern unique_ptr<VirtualDreamcast> virtualDreamcast;
extern unique_ptr<GDRomDisc> g_GDRDisc;

extern MMIODevice* g_GDRomDrive;


// TODO: rename these
int reicast_init(int argc, char* argv[]);
Expand Down
9 changes: 0 additions & 9 deletions libswirl/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ enum serialize_version_enum {
} ;

//gdrom
void gdrom_serialize(void** data, unsigned int* total_size);
bool gdrom_unserialize(void** data, unsigned int* total_size);

//./core/hw/arm7/arm_mem.cpp

Expand Down Expand Up @@ -793,8 +791,6 @@ bool dc_serialize(void **data, unsigned int *total_size)

REICAST_SA(reply_11,16) ;

gdrom_serialize(data, total_size);


REICAST_SA(EEPROM,0x100);
REICAST_S(EEPROM_loaded);
Expand Down Expand Up @@ -1081,7 +1077,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size)

REICAST_USA(reply_11,16);

gdrom_unserialize(data, total_size);
REICAST_US(i); //LIBRETRO_S(GDROM_TICK);

REICAST_USA(EEPROM,0x100);
Expand Down Expand Up @@ -1397,10 +1392,6 @@ bool dc_unserialize(void **data, unsigned int *total_size)

REICAST_USA(reply_11,16) ;

gdrom_unserialize(data, total_size);




REICAST_USA(EEPROM,0x100);
REICAST_US(EEPROM_loaded);
Expand Down

0 comments on commit 807079a

Please sign in to comment.