From 6f48d7fefe7550d9326e31c6cf979f07bfdc94f6 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 6 Feb 2018 18:18:16 +0100 Subject: [PATCH] Add MSVC 2010 project file and a make the project compile --- project/msvc/.gitignore | 6 + project/msvc/README.txt | 3 + project/msvc/grafx2.sln | 20 ++ project/msvc/grafx2.vcxproj | 200 ++++++++++++++++ project/msvc/grafx2.vcxproj.filters | 341 ++++++++++++++++++++++++++++ src/buttons.c | 14 +- src/const.h | 6 + src/errors.h | 3 + src/filesel.c | 19 +- src/gfx2.rc | 1 + src/help.c | 10 +- src/hotkeys.c | 2 +- src/hotkeys.h | 2 +- src/init.c | 6 +- src/io.c | 18 +- src/loadsave.c | 2 + src/main.c | 2 + src/misc.c | 2 + src/mountlist.c | 4 +- src/mountlist.h | 4 +- src/oldies.c | 2 + src/op_c.c | 2 + src/readline.c | 6 + src/realpath.c | 4 +- src/setup.c | 7 +- src/text.c | 5 + src/windows.c | 6 + 27 files changed, 678 insertions(+), 19 deletions(-) create mode 100644 project/msvc/.gitignore create mode 100644 project/msvc/README.txt create mode 100644 project/msvc/grafx2.sln create mode 100644 project/msvc/grafx2.vcxproj create mode 100644 project/msvc/grafx2.vcxproj.filters create mode 100644 src/gfx2.rc diff --git a/project/msvc/.gitignore b/project/msvc/.gitignore new file mode 100644 index 00000000..e8376ee0 --- /dev/null +++ b/project/msvc/.gitignore @@ -0,0 +1,6 @@ +Debug +Release +ipch +*.suo +*.user +*.sdf \ No newline at end of file diff --git a/project/msvc/README.txt b/project/msvc/README.txt new file mode 100644 index 00000000..e014c13c --- /dev/null +++ b/project/msvc/README.txt @@ -0,0 +1,3 @@ +Project files for MS Visual Studio 2010 +Edit project properties to set proper include and libraries directory for SDL 1.2 +and SDL image 1.2 diff --git a/project/msvc/grafx2.sln b/project/msvc/grafx2.sln new file mode 100644 index 00000000..c8f8c739 --- /dev/null +++ b/project/msvc/grafx2.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grafx2", "grafx2.vcxproj", "{2C23F950-9403-4871-848E-7E98BE9BD565}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2C23F950-9403-4871-848E-7E98BE9BD565}.Debug|Win32.ActiveCfg = Debug|Win32 + {2C23F950-9403-4871-848E-7E98BE9BD565}.Debug|Win32.Build.0 = Debug|Win32 + {2C23F950-9403-4871-848E-7E98BE9BD565}.Release|Win32.ActiveCfg = Release|Win32 + {2C23F950-9403-4871-848E-7E98BE9BD565}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/project/msvc/grafx2.vcxproj b/project/msvc/grafx2.vcxproj new file mode 100644 index 00000000..f4a30a8a --- /dev/null +++ b/project/msvc/grafx2.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {2C23F950-9403-4871-848E-7E98BE9BD565} + Win32Proj + grafx2 + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + $(SolutionDir)..\..\bin\ + $(ProjectName)$(Configuration) + + + false + $(SolutionDir)..\..\bin\ + + + + + + Level3 + Disabled + NOTTF;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + C:\code\SDL_image-1.2.12\include;C:\code\SDL-1.2.15\include;%(AdditionalIncludeDirectories) + + + Windows + true + SDL.lib;SDLmain.lib;SDL_image.lib;%(AdditionalDependencies) + C:\code\SDL-1.2.15\lib\x86;C:\code\SDL_image-1.2.12\lib\x86;%(AdditionalLibraryDirectories) + + + + + Level3 + + + MaxSpeed + true + true + NOTTF;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + C:\code\SDL_image-1.2.12\include;C:\code\SDL-1.2.15\include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + SDL.lib;SDLmain.lib;SDL_image.lib;%(AdditionalDependencies) + C:\code\SDL-1.2.15\lib\x86;C:\code\SDL_image-1.2.12\lib\x86;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/msvc/grafx2.vcxproj.filters b/project/msvc/grafx2.vcxproj.filters new file mode 100644 index 00000000..f2f08cec --- /dev/null +++ b/project/msvc/grafx2.vcxproj.filters @@ -0,0 +1,341 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + + + Fichiers de ressources + + + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + \ No newline at end of file diff --git a/src/buttons.c b/src/buttons.c index 4ed77dfc..4a96280b 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -24,7 +24,7 @@ #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #include #include -#elif defined(__WIN32__) +#elif defined(__WIN32__) || defined(WIN32) #include #endif @@ -37,9 +37,19 @@ #include #include #include +#if !defined(_MSC_VER) #include +#else +#if (_MSC_VER >= 1400) +#define strncasecmp _memicmp +#else +#define strncasecmp memicmp +#endif +#endif #include +#if !defined(__VBCC__) && !defined(_MSC_VER) #include +#endif #include #include #include @@ -81,7 +91,9 @@ #include #include #elif defined(__WIN32__) +#ifndef _MSC_VER #include +#endif #include #else #include diff --git a/src/const.h b/src/const.h index 329387ca..bdbbe311 100644 --- a/src/const.h +++ b/src/const.h @@ -38,6 +38,12 @@ #else #include // for PATH_MAX #endif +#ifndef PATH_MAX +#ifdef _MSC_VER +#include +#endif +#define PATH_MAX MAX_PATH +#endif #ifndef M_2PI #define M_2PI 6.28318530717958647692528676656 ///< Hmm, pie... diff --git a/src/errors.h b/src/errors.h index b9dd23c9..7d9e20d4 100644 --- a/src/errors.h +++ b/src/errors.h @@ -26,6 +26,9 @@ #ifdef __VBCC__ #define __func__ "stupid compiler !" #endif +#ifdef _MSC_VER + #define __func__ __FUNCTION__ +#endif /// Prints the source filename, line number, function name, a string and an integer. #define DEBUG(y,z) printf("%s %d %s | %s : %d###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z) diff --git a/src/filesel.c b/src/filesel.c index 8077c52f..62f7a6d7 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -41,11 +41,15 @@ #include #include #include +#ifdef _MSC_VER +#include +#define snprintf _snprintf +#else #include +#include +#endif #include -#include #include -#include #include "const.h" #include "struct.h" @@ -97,12 +101,15 @@ byte Native_filesel(byte load) ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; + ofn.lpstrFilter = TEXT("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"); +#ifdef UNICODE +#else ofn.lpstrFile = szFileName; +#endif ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER; if(load) ofn.Flags |= OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.lpstrDefExt = "txt"; + ofn.lpstrDefExt = TEXT("txt"); if(load) { @@ -682,7 +689,7 @@ void Read_list_of_drives(T_Fileselector *list, byte name_length) char drive_path[]="A:\\"; // Cette API Windows est étrange, je dois m'y faire... drive_path[0]='A'+bit_index; - switch (GetDriveType(drive_path)) + switch (GetDriveTypeA(drive_path)) { case DRIVE_CDROM: icon=ICON_CDROM; @@ -1572,7 +1579,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context else if (context->Type == CONTEXT_PALETTE) Open_window(310,200,"Save palette"); else - assert(false); + assert(0); Window_set_normal_button(198,180,51,14,"Save",0,1,SDLK_RETURN); // 1 if (Selector->Format_filter<=FORMAT_ALL_FILES) // Correction du *.* { diff --git a/src/gfx2.rc b/src/gfx2.rc new file mode 100644 index 00000000..250ae880 --- /dev/null +++ b/src/gfx2.rc @@ -0,0 +1 @@ +1 ICON "gfx2.ico" diff --git a/src/help.c b/src/help.c index 203bfd0d..486093bf 100644 --- a/src/help.c +++ b/src/help.c @@ -25,8 +25,11 @@ #include #include -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(WIN32) #include +#ifdef _MSC_VER + #define snprintf _snprintf +#endif #elif defined(__macosx__) || defined(__FreeBSD__) #include #include @@ -61,6 +64,9 @@ extern char Program_version[]; // generated in pversion.c extern char SVN_revision[]; // generated in pversion.c +#ifdef _MSC_VER//TODO TEMP +#define SVN_revision "MSC_0000" +#endif // Recherche un raccourci clavier: word * Shortcut(word shortcut_number) @@ -785,7 +791,7 @@ void Button_Stats(void) #if defined(__WIN32__) { ULARGE_INTEGER tailleU; - GetDiskFreeSpaceEx(Main.selector.Directory,&tailleU,NULL,NULL); + GetDiskFreeSpaceExA(Main.selector.Directory,&tailleU,NULL,NULL); mem_size = tailleU.QuadPart; } #elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__) || defined(__SYLLABLE__) || defined(__AROS__) diff --git a/src/hotkeys.c b/src/hotkeys.c index ca8942ad..c86ebacb 100644 --- a/src/hotkeys.c +++ b/src/hotkeys.c @@ -23,7 +23,7 @@ #include "global.h" #include "hotkeys.h" -#ifdef __VBCC__ +#if defined(__VBCC__) || defined(_MSC_VER) #define false 0 #define true 1 #endif diff --git a/src/hotkeys.h b/src/hotkeys.h index c5eed94e..9365ff27 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -26,7 +26,7 @@ /// The actual data is in hotkeys.c ////////////////////////////////////////////////////////////////////////////// -#if !defined(__VBCC__) +#if !defined(__VBCC__) && !defined(_MSC_VER) #include #else #define bool char diff --git a/src/init.c b/src/init.c index cc27c985..0259e78b 100644 --- a/src/init.c +++ b/src/init.c @@ -38,7 +38,7 @@ //#include #include -#ifndef __VBCC__ +#if !defined(__VBCC__) && !defined(_MSC_VER) #include #endif @@ -58,6 +58,10 @@ #ifdef GRAFX2_CATCHES_SIGNALS #include #endif +#ifdef _MSC_VER +#include +#define snprintf _snprintf +#endif #include "buttons.h" #include "const.h" diff --git a/src/io.c b/src/io.c index e8e4e242..6d0cf2e6 100644 --- a/src/io.c +++ b/src/io.c @@ -30,14 +30,20 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #include #include #include #elif defined(__WIN32__) +#ifdef _MSC_VER + #include +#else #include +#endif #include //#include #elif defined(__MINT__) @@ -297,6 +303,9 @@ int Directory_exists(char * directory) // Détermine si un répertoire passé en paramètre existe ou non dans le // répertoire courant. { +#ifdef _MSC_VER // TODO + return 1; +#else DIR* entry; // Structure de lecture des éléments if (strcmp(directory,PARENT_DIR)==0) @@ -315,6 +324,7 @@ int Directory_exists(char * directory) return 1; } } +#endif } /// Check if a file or directory is hidden. @@ -360,6 +370,8 @@ int File_length_file(FILE * file) void For_each_file(const char * directory_name, void Callback(const char *, const char *)) { +#ifdef _MSC_VER +#else // Pour scan de répertoire DIR* current_directory; //Répertoire courant struct dirent* entry; // Structure de lecture des éléments @@ -389,11 +401,14 @@ void For_each_file(const char * directory_name, void Callback(const char *, cons } } closedir(current_directory); +#endif } /// Scans a directory, calls Callback for each file or directory in it, void For_each_directory_entry(const char * directory_name, void * pdata, T_File_dir_cb Callback) { +#ifdef _MSC_VER // TODO ! +#else DIR* current_directory; // current directory struct dirent* entry; // directory entry struct char full_filename[MAX_PATH_CHARACTERS]; @@ -446,6 +461,7 @@ void For_each_directory_entry(const char * directory_name, void * pdata, T_File_ File_is_hidden(entry->d_name, full_filename)); } closedir(current_directory); +#endif } @@ -491,7 +507,7 @@ byte Create_lock_file(const char *file_directory) #ifdef __WIN32__ // Windowzy method for creating a lock file - Lock_file_handle = CreateFile( + Lock_file_handle = CreateFileA( lock_filename, GENERIC_WRITE, 0, // No sharing diff --git a/src/loadsave.c b/src/loadsave.c index b46c6417..db0351b3 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -28,7 +28,9 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #include #include #include diff --git a/src/main.c b/src/main.c index 641df1a6..f1c28d1e 100644 --- a/src/main.c +++ b/src/main.c @@ -35,7 +35,9 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #include #include diff --git a/src/misc.c b/src/misc.c index ebdf4135..3a97c2c1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -23,7 +23,9 @@ */ #include #include +#ifndef _MSC_VER #include +#endif #include #include #include "struct.h" diff --git a/src/mountlist.c b/src/mountlist.c index f92d0330..e0bc1cb2 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -20,7 +20,7 @@ */ // This file is not used on some platforms, so don't do anything for them -#if(!defined(__WIN32__))&&(!defined(__amigaos4__))&&(!defined(__AROS__))&&(!defined(__MORPHOS__))&&(!defined(__amigaos__)) +#if(!(defined(__WIN32__)||defined(WIN32)))&&(!defined(__amigaos4__))&&(!defined(__AROS__))&&(!defined(__MORPHOS__))&&(!defined(__amigaos__)) // We don't use autoconf and all that in grafx2, so let's do the config here ... #if defined(__macosx__) || defined(__FreeBSD__) || defined(__OpenBSD__) // MacOS X is POSIX compliant @@ -63,7 +63,9 @@ #include +#ifndef _MSC_VER #include +#endif #if HAVE_SYS_PARAM_H # include diff --git a/src/mountlist.h b/src/mountlist.h index ae0c2944..5e01c8a1 100644 --- a/src/mountlist.h +++ b/src/mountlist.h @@ -28,8 +28,8 @@ #ifndef MOUNTLIST_H_ # define MOUNTLIST_H_ -#if !defined(__VBCC__) - # include +#if !defined(__VBCC__) && !defined(_MSC_VER) + #include #else #define bool char #endif diff --git a/src/oldies.c b/src/oldies.c index 7c19f400..b85f7c68 100644 --- a/src/oldies.c +++ b/src/oldies.c @@ -22,7 +22,9 @@ */ #include #include +#ifndef _MSC_VER #include +#endif #include #include #include "struct.h" diff --git a/src/op_c.c b/src/op_c.c index d3e1d721..9f01c941 100644 --- a/src/op_c.c +++ b/src/op_c.c @@ -21,7 +21,9 @@ along with Grafx2; if not, see */ #include +#ifndef _MSC_VER #include +#endif #include #include #include diff --git a/src/readline.c b/src/readline.c index 5595650c..7c9c4ad1 100644 --- a/src/readline.c +++ b/src/readline.c @@ -47,6 +47,7 @@ #ifdef __WIN32__ #include #include + #elif defined __HAIKU__ #include "haiku.h" #elif defined(__AROS__) @@ -57,6 +58,11 @@ #include #endif +#ifdef _MSC_VER +#include +#define snprintf _snprintf +#endif + // Virtual keyboard is ON by default on these platforms: #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(GCWZERO) #define VIRT_KEY_DEFAULT_ON 1 diff --git a/src/realpath.c b/src/realpath.c index b5138f93..4411b3f4 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -8,7 +8,9 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #if defined(__AROS__) || defined(__linux__) || defined(__GLIBC__)|| defined(__MINT__) || defined(__FreeBSD__) #include #endif @@ -114,7 +116,7 @@ return resolved_path; } -#elif defined (__WIN32__) +#elif defined(__WIN32__) || defined(WIN32) // Mingw has a working equivalent. It only has reversed arguments. char *Realpath(const char *_path, char *resolved_path) { diff --git a/src/setup.c b/src/setup.c index 221d36df..168aee5a 100644 --- a/src/setup.c +++ b/src/setup.c @@ -29,9 +29,12 @@ #include #include #include -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(WIN32) #include #include // Mingw's _mkdir() +#ifdef _MSC_VER + #include +#endif #elif defined(__macosx__) #import #import @@ -58,7 +61,7 @@ int Create_ConfigDirectory(char * config_dir) { - #ifdef __WIN32__ + #if defined(__WIN32__) || defined(WIN32) // Mingw's mkdir has a weird name and only one argument return _mkdir(config_dir); #else diff --git a/src/text.c b/src/text.c index 449645d9..e662a27d 100644 --- a/src/text.c +++ b/src/text.c @@ -50,6 +50,11 @@ #import #endif +#ifdef _MSC_VER +#include +#define snprintf _snprintf +#endif + #include #include "SFont.h" diff --git a/src/windows.c b/src/windows.c index 2c70a3c9..baf65180 100644 --- a/src/windows.c +++ b/src/windows.c @@ -29,6 +29,11 @@ #include // atoi() #include // strncpy() strlen() +#ifdef _MSC_VER +#include +#define snprintf _snprintf +#endif + #include "windows.h" #include "engine.h" @@ -1437,6 +1442,7 @@ void Warning_with_format(const char *template, ...) { va_start(arg_ptr, template); vsnprintf(message, sizeof(message), template, arg_ptr); + Verbose_message("Warning", message); va_end(arg_ptr); }