Skip to content

Commit 935996e

Browse files
author
ejaquay
committed
Static libcommon builds clean up changes to string resources
libcommon string resources were renumbered to avoid collisions with vcc resources then the strings were copied into vcc.rc so they are availiable for cart load error messages.
1 parent d48b68b commit 935996e

File tree

5 files changed

+33
-41
lines changed

5 files changed

+33
-41
lines changed

Vcc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ bool IsShiftKeyDown();
133133

134134
CartridgeMenu CartMenu;
135135

136+
void InitStaticModuleInstance(HINSTANCE hInstance);
136137

137138
//static CRITICAL_SECTION FrameRender;
138139
/*--------------------------------------------------------------------------*/
@@ -149,8 +150,10 @@ int APIENTRY WinMain(_In_ HINSTANCE hInstance,
149150
OleInitialize(nullptr); //Work around fixs app crashing in "Open file" system dialogs (related to Adobe acrobat 7+
150151
LoadString(hInstance, IDS_APP_TITLE,g_szAppName, MAX_LOADSTRING);
151152

152-
// Init static libcommon
153-
void InitStaticModuleInstance();
153+
#ifdef USE_STATIC_LIB
154+
// Init static libcommon
155+
InitStaticModuleInstance(hInstance);
156+
#endif
154157

155158
// Parse command line
156159
memset(&CmdArg,0,sizeof(CmdArg));

Vcc.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,16 +827,17 @@ END
827827

828828
/////////////////////////////////////////////////////////////////////////////
829829
//
830-
// String Table
831-
//
830+
// String Table. ** Resources are being used by libcommon.rc!! **
831+
// These strings are duplicated for Vcc.exe so they are available for
832+
// static builds. libcommon should not use these because resources are
833+
// not a thing with static builds - they can not be contained in a static
834+
// object library.
832835

833836
STRINGTABLE
834837
BEGIN
835838
IDS_APP_TITLE "VCC 2.1.9.3-pre3 Tandy Color Computer 3 Emulator"
836839
IDS_CATNUMBER "26-3334"
837-
838-
// FIXME
839-
#ifdef USE_STATIC_LIB
840+
// Strings for error messages FIXME: duplicated in libcommon
840841
IDS_ERROR_UNKNOWN "Unknown error."
841842
IDS_ERROR_CARTRIDGE_ALREADY_LOADED "Cartridge is already loaded."
842843
IDS_ERROR_CARTRIDGE_CANNOT_OPEN "Cannot open cartridge."
@@ -845,7 +846,6 @@ BEGIN
845846
IDS_ERROR_CARTRIDGE_NOT_ROM "Cartridge is not a valid ROM image."
846847
IDS_ERROR_CARTRIDGE_NOT_EXPANSION "Cartridge is not a valid expansion plugin."
847848
IDS_ERROR_CARTRIDGE_API_NOT_SUPPORTED "Cartridge is using an API that is no longer supported."
848-
#endif
849849

850850
END
851851

libcommon/resource/resource.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//{{NO_DEPENDENCIES}}
22
// Microsoft Visual C++ generated include file.
3-
// Used by libcommon.rc
43
//
5-
// FIXME
6-
#ifdef USE_STATIC_LIB
4+
// These resources were renumbered to avoid collision with Vcc.exe
5+
// resources for static builds.
6+
//
77
#define IDS_ERROR_UNKNOWN 501
88
#define IDS_ERROR_CARTRIDGE_ALREADY_LOADED 502
99
#define IDS_ERROR_CARTRIDGE_CANNOT_OPEN 503
@@ -12,16 +12,6 @@
1212
#define IDS_ERROR_CARTRIDGE_NOT_ROM 506
1313
#define IDS_ERROR_CARTRIDGE_NOT_EXPANSION 507
1414
#define IDS_ERROR_CARTRIDGE_API_NOT_SUPPORTED 508
15-
#else
16-
#define IDS_ERROR_UNKNOWN 101
17-
#define IDS_ERROR_CARTRIDGE_ALREADY_LOADED 102
18-
#define IDS_ERROR_CARTRIDGE_CANNOT_OPEN 103
19-
#define IDS_ERROR_CARTRIDGE_NOT_FOUND 104
20-
#define IDS_ERROR_CARTRIDGE_NOT_LOADED 105
21-
#define IDS_ERROR_CARTRIDGE_NOT_ROM 106
22-
#define IDS_ERROR_CARTRIDGE_NOT_EXPANSION 107
23-
#define IDS_ERROR_CARTRIDGE_API_NOT_SUPPORTED 108
24-
#endif
2515

2616
// Next default values for new objects
2717
//

libcommon/src/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
HINSTANCE gModuleInstance = nullptr;
66

7-
#ifndef USE_STATIC_LIB
7+
#ifdef USE_STATIC_LIB
8+
// Static library has no DLLmain but may require caller's hInstance
9+
void InitStaticModuleInstance(HINSTANCE hInstance) {
10+
gModuleInstance = hInstance;
11+
}
12+
#else
813
BOOL APIENTRY DllMain(HMODULE module_handle, DWORD reason, LPVOID reserved)
914
{
1015
if(reason == DLL_PROCESS_ATTACH)
@@ -14,8 +19,4 @@ BOOL APIENTRY DllMain(HMODULE module_handle, DWORD reason, LPVOID reserved)
1419

1520
return TRUE;
1621
}
17-
#else
18-
void InitStaticModuleInstance(HINSTANCE hInstance) {
19-
gModuleInstance = hInstance;
20-
}
2122
#endif

resource.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define IDS_CATNUMBER 2
77
#define IDAPPLY 3
88
#define IDOK2 3
9-
9+
//
1010
#define IDS_UNKNOWN_ERROR 3
1111
#define IDS_MODULE_ALREADY_LOADED 4
1212
#define IDS_MODULE_CANNOT_OPEN 5
@@ -15,18 +15,6 @@
1515
#define IDS_MODULE_NOT_ROM 8
1616
#define IDS_MODULE_NOT_EXPANSION 9
1717

18-
// FIXME
19-
#ifdef USE_STATIC_LIB
20-
#define IDS_ERROR_UNKNOWN 501
21-
#define IDS_ERROR_CARTRIDGE_ALREADY_LOADED 502
22-
#define IDS_ERROR_CARTRIDGE_CANNOT_OPEN 503
23-
#define IDS_ERROR_CARTRIDGE_NOT_FOUND 504
24-
#define IDS_ERROR_CARTRIDGE_NOT_LOADED 505
25-
#define IDS_ERROR_CARTRIDGE_NOT_ROM 506
26-
#define IDS_ERROR_CARTRIDGE_NOT_EXPANSION 507
27-
#define IDS_ERROR_CARTRIDGE_API_NOT_SUPPORTED 508
28-
#endif
29-
3018
#define IDR_MENU 101
3119
#define IDI_COCO3 103
3220
#define IDD_ABOUTBOX 104
@@ -73,6 +61,16 @@
7361
#define IDB_FONT_CONSOLA 178
7462
#define IDD_FUNCTION_KEYS 179
7563

64+
// error string resources FIXME: duplicated in libcommon
65+
#define IDS_ERROR_UNKNOWN 501
66+
#define IDS_ERROR_CARTRIDGE_ALREADY_LOADED 502
67+
#define IDS_ERROR_CARTRIDGE_CANNOT_OPEN 503
68+
#define IDS_ERROR_CARTRIDGE_NOT_FOUND 504
69+
#define IDS_ERROR_CARTRIDGE_NOT_LOADED 505
70+
#define IDS_ERROR_CARTRIDGE_NOT_ROM 506
71+
#define IDS_ERROR_CARTRIDGE_NOT_EXPANSION 507
72+
#define IDS_ERROR_CARTRIDGE_API_NOT_SUPPORTED 508
73+
7674
#define IDC_MUTE 1003
7775
#define IDC_THROTTLE 1004
7876
#define IDC_ARTIFACTS 1005
@@ -477,9 +475,9 @@
477475
#define IDM_HELP_FUNKEY 40059
478476
#define ID_CONFIGURE_OPTIONS 65535
479477

480-
481478
// Next default values for new objects
482-
//
479+
// Caution: error strings resources start at 501
480+
483481
#ifdef APSTUDIO_INVOKED
484482
#ifndef APSTUDIO_READONLY_SYMBOLS
485483
#define _APS_NEXT_RESOURCE_VALUE 180

0 commit comments

Comments
 (0)