Skip to content

Commit e4efebb

Browse files
ChetSimpsonejaquay
authored andcommitted
add stop to cartridge and cpak interfaces
1 parent b42f24e commit e4efebb

File tree

19 files changed

+121
-62
lines changed

19 files changed

+121
-62
lines changed

FD502/fd502.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,12 @@ BOOL WINAPI DllMain(
9090
DWORD fdwReason, // reason for calling function
9191
LPVOID lpReserved ) // reserved
9292
{
93-
if (fdwReason == DLL_PROCESS_DETACH ) //Clean Up
94-
{
95-
CloseCartDialog(g_hConfDlg);
96-
for (unsigned char Drive=0;Drive<=3;Drive++)
97-
unmount_disk_image(Drive);
98-
}
99-
else
93+
if (fdwReason == DLL_PROCESS_ATTACH) //Clean Up
10094
{
10195
gModuleInstance = hinstDLL;
102-
RealDisks=InitController();
10396
}
104-
return 1;
97+
98+
return TRUE;
10599
}
106100

107101
extern "C"
@@ -144,10 +138,20 @@ extern "C"
144138
AssertInt = context->assert_interrupt;
145139
strcpy(IniFile, configuration_path);
146140

141+
RealDisks = InitController();
147142
LoadConfig();
148143
BuildCartridgeMenu();
149144
}
150145

146+
__declspec(dllexport) void PakTerminate()
147+
{
148+
CloseCartDialog(g_hConfDlg);
149+
for (unsigned char Drive = 0; Drive <= 3; Drive++)
150+
{
151+
unmount_disk_image(Drive);
152+
}
153+
}
154+
151155
}
152156

153157
extern "C"

HardDisk/harddisk.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module
6464
DWORD fdwReason, // reason for calling function
6565
LPVOID lpReserved ) // reserved
6666
{
67-
if (fdwReason == DLL_PROCESS_DETACH ) {
68-
CloseCartDialog(hConfDlg);
69-
UnmountHD(0);
70-
UnmountHD(1);
71-
} else {
67+
if (fdwReason == DLL_PROCESS_ATTACH)
68+
{
7269
gModuleInstance = hinstDLL;
7370
}
74-
return 1;
71+
72+
return TRUE;
7573
}
7674

7775
void MemWrite(unsigned char Data, unsigned short Address)
@@ -132,6 +130,13 @@ extern "C"
132130
BuildCartridgeMenu();
133131
}
134132

133+
__declspec(dllexport) void PakTerminate()
134+
{
135+
CloseCartDialog(hConfDlg);
136+
UnmountHD(0);
137+
UnmountHD(1);
138+
}
139+
135140
}
136141

137142

Ramdisk/Ramdisk.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ BOOL WINAPI DllMain(
2929
DWORD fdwReason, // reason for calling function
3030
LPVOID lpReserved ) // reserved
3131
{
32-
if (fdwReason == DLL_PROCESS_DETACH ) //Clean Up
32+
if (fdwReason == DLL_PROCESS_ATTACH) //Clean Up
3333
{
34-
return 1;
34+
gModuleInstance = hinstDLL;
3535
}
36-
gModuleInstance = hinstDLL;
37-
return 1;
36+
37+
return TRUE;
3838
}
3939

4040
extern "C"

SuperIDE/SuperIDE.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ BOOL WINAPI DllMain(
5555
DWORD fdwReason, // reason for calling function
5656
LPVOID lpReserved ) // reserved
5757
{
58-
if (fdwReason == DLL_PROCESS_DETACH ) //Clean Up
58+
if (fdwReason == DLL_PROCESS_ATTACH) //Clean Up
5959
{
60-
if (hConfDlg) DestroyWindow(hConfDlg);
60+
gModuleInstance = hinstDLL;
6161
}
62-
gModuleInstance = hinstDLL;
63-
return 1;
62+
63+
return TRUE;
6464
}
6565

6666

@@ -109,6 +109,14 @@ extern "C"
109109
BuildCartridgeMenu();
110110
}
111111

112+
__declspec(dllexport) void PakTerminate()
113+
{
114+
if (hConfDlg)
115+
{
116+
CloseCartDialog(hConfDlg);
117+
hConfDlg = nullptr;
118+
}
119+
}
112120
}
113121

114122
extern "C"

acia/acia.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ unsigned char LoadExtRom(const char *);
8080
BOOL APIENTRY
8181
DllMain(HINSTANCE hinst, DWORD reason, LPVOID foo)
8282
{
83-
if (reason == DLL_PROCESS_ATTACH) {
83+
if (reason == DLL_PROCESS_ATTACH)
84+
{
8485
gModuleInstance = hinst;
85-
LoadExtRom("RS232.ROM");
86-
87-
} else if (reason == DLL_PROCESS_DETACH) {
88-
sc6551_close();
89-
AciaStat[0]='\0';
90-
CloseCartDialog(g_hDlg);
9186
}
87+
9288
return TRUE;
9389
}
9490

@@ -133,8 +129,16 @@ extern "C"
133129
strcpy(IniFile, configuration_path);
134130

135131
LoadConfig();
132+
LoadExtRom("RS232.ROM");
136133
sc6551_init();
137134
}
135+
__declspec(dllexport) void PakTerminate()
136+
{
137+
CloseCartDialog(g_hDlg);
138+
sc6551_close();
139+
AciaStat[0]='\0';
140+
}
141+
138142

139143
}
140144

becker/becker.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,10 @@ BOOL APIENTRY DllMain( HINSTANCE hinstDLL,
7878
case DLL_PROCESS_ATTACH:
7979
// init
8080
gModuleInstance = hinstDLL;
81-
LastStats = GetTickCount();
82-
SetDWTCPConnectionEnable(1);
83-
8481
break;
82+
8583
case DLL_PROCESS_DETACH:
8684
// shutdown
87-
88-
8985
break;
9086

9187
// not used by Vcc
@@ -426,10 +422,11 @@ extern "C"
426422
PakSetCart = context->assert_cartridge_line;
427423
strcpy(IniFile, configuration_path);
428424

425+
LastStats = GetTickCount();
429426
LoadConfig();
427+
SetDWTCPConnectionEnable(1);
430428
BuildCartridgeMenu();
431429
}
432-
433430
}
434431

435432

libcommon/include/vcc/core/cartridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace vcc { namespace core
4545
virtual description_type description() const = 0;
4646

4747
virtual void start() = 0;
48+
virtual void stop() = 0;
49+
4850
virtual void reset() = 0;
4951
virtual void heartbeat() = 0;
5052
virtual void write_port(unsigned char port_id, unsigned char value) = 0;

libcommon/include/vcc/core/cartridges/basic_cartridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ namespace vcc { namespace core { namespace cartridges
3939
description_type description() const override;
4040

4141
void start() override;
42+
void stop() override;
43+
4244
void reset() override;
4345
void heartbeat() override;
4446
void write_port(unsigned char port_id, unsigned char value) override;

libcommon/include/vcc/core/cartridges/legacy_cartridge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace vcc { namespace core { namespace cartridges
4545
LIBCOMMON_EXPORT description_type description() const override;
4646

4747
LIBCOMMON_EXPORT void start() override;
48+
LIBCOMMON_EXPORT void stop() override;
49+
4850
LIBCOMMON_EXPORT void reset() override;
4951
LIBCOMMON_EXPORT void heartbeat() override;
5052
LIBCOMMON_EXPORT void status(char* text_buffer, size_t buffer_size) override;
@@ -54,6 +56,7 @@ namespace vcc { namespace core { namespace cartridges
5456
LIBCOMMON_EXPORT unsigned short sample_audio() override;
5557
LIBCOMMON_EXPORT void menu_item_clicked(unsigned char menu_item_id) override;
5658

59+
5760
private:
5861

5962
const HMODULE handle_;
@@ -63,6 +66,7 @@ namespace vcc { namespace core { namespace cartridges
6366

6467
// imported module functions
6568
const PakInitializeModuleFunction initialize_;
69+
const PakTerminateModuleFunction terminate_;
6670
const PakGetNameModuleFunction get_name_;
6771
const PakGetCatalogIdModuleFunction get_catalog_id_;
6872
const PakGetDescriptionModuleFunction get_description_;

libcommon/include/vcc/core/legacy_cartridge_definitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern "C"
4545
void* host_key,
4646
const char* const configuration_path,
4747
const cpak_cartridge_context* const context);
48+
using PakTerminateModuleFunction = void (*)();
4849
using PakGetNameModuleFunction = const char* (*)();
4950
using PakGetCatalogIdModuleFunction = const char* (*)();
5051
using PakGetDescriptionModuleFunction = const char* (*)();

0 commit comments

Comments
 (0)