shithub: duke3d

Download patch

ref: 62984ca13048b15166da4511f10c43d747980e85
parent: 6b9299bd6526aea844933b56ae6879e794a655b7
author: Fabien Sanglard <[email protected]>
date: Wed Dec 12 09:04:07 EST 2012

Fixed issue with more win32 calls, the sound engine is missing now.

--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -64,6 +64,10 @@
 #include "dukeunix.h"
 #endif
 
+#if PLATFORM_MACOSX
+#include "dukeunix.h"
+#endif
+
 #if PLATFORM_WIN32
 #include "dukewin.h"
 #endif
--- /dev/null
+++ b/Game/src/dukeunix.h
@@ -1,0 +1,101 @@
+//
+//  dukeunix.h
+//  Duke3D
+//
+//  Created by fabien sanglard on 12-12-12.
+//  Copyright (c) 2012 fabien sanglard. All rights reserved.
+//
+
+#ifndef Duke3D_dukeunix_h
+#define Duke3D_dukeunix_h
+
+
+#define cdecl
+#define __far
+#define __interrupt
+
+#ifdef __GNUC__
+typedef long long __int64;
+#endif
+
+//#define STUBBED(x)
+#ifdef __SUNPRO_C
+#define STUBBED(x) fprintf(stderr,"STUB: %s (??? %s:%d)\n",x,__FILE__,__LINE__)
+#else
+#define STUBBED(x) fprintf(stderr,"STUB: %s (%s, %s:%d)\n",x,__FUNCTION__,__FILE__,__LINE__)
+#endif
+
+#define PATH_SEP_CHAR '/'
+#define PATH_SEP_STR  "/"
+#define ROOTDIR       "/"
+#define CURDIR        "./"
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <assert.h>
+
+struct find_t
+{
+    DIR *dir;
+    char pattern[MAX_PATH];
+    char name[MAX_PATH];
+};
+int _dos_findfirst(char *filename, int x, struct find_t *f);
+int _dos_findnext(struct find_t *f);
+
+struct dosdate_t
+{
+    unsigned char day;
+    unsigned char month;
+    unsigned int year;
+    unsigned char dayofweek;
+};
+
+void _dos_getdate(struct dosdate_t *date);
+
+#ifndef min
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#endif
+
+#ifndef max
+#define max(x, y) ((x) > (y) ? (x) : (y))
+#endif
+
+#define FP_OFF(x) ((long) (x))
+
+#ifndef strcmpi
+#define strcmpi(x, y) strcasecmp(x, y)
+#endif
+
+#ifdef DC
+#undef stderr
+#undef stdout
+#undef getchar
+/* kos compat */
+#define stderr ((FILE*)2)
+#define stdout ((FILE*)2)
+#define Z_AvailHeap() ((10 * 1024) * 1024)
+#else
+// 64 megs should be enough for anybody.  :)  --ryan.
+#define Z_AvailHeap() ((64 * 1024) * 1024)
+#endif
+
+#define printchrasm(x,y,ch) printf("%c", (char) (ch & 0xFF))
+
+#ifdef __GNUC__
+#define GCC_PACK1_EXT __attribute__((packed,aligned(1)))
+#endif
+
+
+// FCS: Game.c features calls to mkdir without the proper flags.
+// Giving all access is ugly but it is just game OK !
+#define mkdir(X) mkdir(X,0777)
+
+#endif
--- a/Game/src/funct.h
+++ b/Game/src/funct.h
@@ -27,6 +27,8 @@
 #ifndef FUNCT_H
 #define FUNCT_H
 
+#include "duke3d.h"
+
 extern void sendscore(char *s);
 //#line "sounds.c" 25
 extern void SoundStartup(void );
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -24,7 +24,10 @@
 */
 //-------------------------------------------------------------------------
 
-#include <windows.h>
+#ifdef _WIN32
+  #include <windows.h>
+#endif
+
 #include "types.h"
 
 #include "develop.h"
@@ -37,7 +40,7 @@
 #include "control.h"
 #include "sounds.h"
 #include "config.h"
-#include "audiolib\sndcards.h"
+#include "audiolib/sndcards.h"
 
 #include "duke3d.h"
 
@@ -8038,23 +8041,18 @@
     }
 }
 
+#ifdef _WIN32
 
-static int load_duke3d_groupfile(void)
+void findGRPToUse(char* game_dir,char* baseDir,char* groupfilefullpath)
 {
-	// FIX_00032: Added multi base GRP manager. Use duke3d*.grp to handle multiple grp.
-    char groupfile[9][512];
-	char groupfilefullpath[512];
-	int kbdKey, i = 0;
-
-	char *baseDir="duke3d*.grp";
-	WIN32_FIND_DATA FindFileData;
+    WIN32_FIND_DATA FindFileData;
 	HANDLE hFind =  INVALID_HANDLE_VALUE;
-
+    
 	if(game_dir[0] != '\0')
 	{
 		sprintf(groupfilefullpath, "%s\\%s", game_dir, baseDir);
 		hFind = FindFirstFile(groupfilefullpath, &FindFileData);
-		if (hFind == INVALID_HANDLE_VALUE) 
+		if (hFind == INVALID_HANDLE_VALUE)
 		{
 			sprintf(groupfilefullpath, "%s", baseDir);
 		}
@@ -8062,21 +8060,21 @@
 			FindClose(hFind);
 	}
 	else
-		sprintf(groupfilefullpath, "%s", baseDir);		
-
+		sprintf(groupfilefullpath, "%s", baseDir);
+    
 	printf("Searching duke3d*.grp:\n\n");
 	hFind = FindFirstFile(groupfilefullpath,&FindFileData);
-
-	if ( hFind==INVALID_HANDLE_VALUE ) 
+    
+	if ( hFind==INVALID_HANDLE_VALUE )
 		Error(EXIT_SUCCESS, "Can't find %s\n", groupfilefullpath);
- 
-	do 
+    
+	do
 	{
 		i++;
 		sprintf(groupfile[i-1], "%s", FindFileData.cFileName);
 		printf("Found GRP #%d:\t%d Bytes\t %s \n", i, FindFileData.nFileSizeLow, groupfile[i-1]);
 	} while ( FindNextFile(hFind, &FindFileData) && i < 9 );
-
+    
 	if(i==1)
 		sprintf(groupfilefullpath, "%s", groupfile[0]);
 	else
@@ -8090,6 +8088,31 @@
 	}
 	
 	FindClose(hFind);
+}
+
+#else
+
+void findGRPToUse(char* game_dir,char* baseDir,char* groupfilefullpath){
+    
+    char *grpName="DUKE3D.GRP";
+    sprintf(groupfilefullpath, "%s\\%s", game_dir, grpName);
+    printf("The ONLY GRP location for this port is '%s'.\n",groupfilefullpath);
+}
+
+#endif
+
+static int load_duke3d_groupfile(void)
+{
+	// FIX_00032: Added multi base GRP manager. Use duke3d*.grp to handle multiple grp.
+    char groupfile[9][512];
+	char groupfilefullpath[512];
+	int kbdKey, i = 0;
+
+	char *baseDir="duke3d*.grp";
+    
+    
+    findGRPToUse(game_dir,baseDir,groupfilefullpath);
+	
 
 	FixFilePath(groupfilefullpath);
 
--- a/Game/src/global.c
+++ b/Game/src/global.c
@@ -333,7 +333,7 @@
     return(0);
 }
 
-#elif PLATFORM_UNIX 
+#elif defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX)
 int _dos_findfirst(char *filename, int x, struct find_t *f)
 {
     char *ptr;
--- a/Game/src/menues.c
+++ b/Game/src/menues.c
@@ -175,7 +175,7 @@
     }
 }
 
-static int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *nump)
+int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *nump)
 {
 
      long i;
--- a/Game/src/sector.c
+++ b/Game/src/sector.c
@@ -346,7 +346,7 @@
 	return(j);
 }
 
-static long setanimation(short animsect,long *animptr, long thegoal, long thevel)
+long setanimation(short animsect,long *animptr, long thegoal, long thevel)
 {
 	long i, j;
 
--- a/xcode/Duke3D.xcodeproj/project.pbxproj
+++ b/xcode/Duke3D.xcodeproj/project.pbxproj
@@ -47,9 +47,6 @@
 		2D7B627F16788F9B00E35E54 /* scriplib.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B626516788F9B00E35E54 /* scriplib.c */; };
 		2D7B628016788F9B00E35E54 /* sector.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B626716788F9B00E35E54 /* sector.c */; };
 		2D7B628116788F9B00E35E54 /* sounds.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B626A16788F9B00E35E54 /* sounds.c */; };
-		2D7B62DB1678902400E35E54 /* fx_man.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B629F1678902400E35E54 /* fx_man.c */; };
-		2D7B62F91678908300E35E54 /* task_man.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B62F71678908300E35E54 /* task_man.c */; };
-		2D7B62FC1678909C00E35E54 /* music.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B62FA1678909C00E35E54 /* music.c */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -164,12 +161,7 @@
 		2D7B626B16788F9B00E35E54 /* sounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sounds.h; path = ../../Game/src/sounds.h; sourceTree = "<group>"; };
 		2D7B626C16788F9B00E35E54 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../Game/src/types.h; sourceTree = "<group>"; };
 		2D7B626D16788F9B00E35E54 /* util_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = util_lib.h; path = ../../Game/src/util_lib.h; sourceTree = "<group>"; };
-		2D7B629F1678902400E35E54 /* fx_man.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fx_man.c; sourceTree = "<group>"; };
-		2D7B62A01678902400E35E54 /* fx_man.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fx_man.h; sourceTree = "<group>"; };
-		2D7B62F71678908300E35E54 /* task_man.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = task_man.c; sourceTree = "<group>"; };
-		2D7B62F81678908300E35E54 /* task_man.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = task_man.h; sourceTree = "<group>"; };
-		2D7B62FA1678909C00E35E54 /* music.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = music.c; sourceTree = "<group>"; };
-		2D7B62FB1678909C00E35E54 /* music.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = music.h; sourceTree = "<group>"; };
+		2D7B62FD167905C400E35E54 /* dukeunix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dukeunix.h; path = ../../Game/src/dukeunix.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -285,7 +277,6 @@
 		2D7B623916788F7900E35E54 /* Game */ = {
 			isa = PBXGroup;
 			children = (
-				2D7B62851678902400E35E54 /* audiolib */,
 				2D7B623A16788F9B00E35E54 /* _functio.h */,
 				2D7B623B16788F9B00E35E54 /* _rts.h */,
 				2D7B623C16788F9B00E35E54 /* actors.c */,
@@ -333,6 +324,7 @@
 				2D7B626B16788F9B00E35E54 /* sounds.h */,
 				2D7B626C16788F9B00E35E54 /* types.h */,
 				2D7B626D16788F9B00E35E54 /* util_lib.h */,
+				2D7B62FD167905C400E35E54 /* dukeunix.h */,
 			);
 			name = Game;
 			sourceTree = "<group>";
@@ -350,20 +342,6 @@
 			path = ../../Game/src/midi;
 			sourceTree = "<group>";
 		};
-		2D7B62851678902400E35E54 /* audiolib */ = {
-			isa = PBXGroup;
-			children = (
-				2D7B62FA1678909C00E35E54 /* music.c */,
-				2D7B62FB1678909C00E35E54 /* music.h */,
-				2D7B62F71678908300E35E54 /* task_man.c */,
-				2D7B62F81678908300E35E54 /* task_man.h */,
-				2D7B629F1678902400E35E54 /* fx_man.c */,
-				2D7B62A01678902400E35E54 /* fx_man.h */,
-			);
-			name = audiolib;
-			path = ../../Game/src/audiolib;
-			sourceTree = "<group>";
-		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -452,9 +430,6 @@
 				2D7B627F16788F9B00E35E54 /* scriplib.c in Sources */,
 				2D7B628016788F9B00E35E54 /* sector.c in Sources */,
 				2D7B628116788F9B00E35E54 /* sounds.c in Sources */,
-				2D7B62DB1678902400E35E54 /* fx_man.c in Sources */,
-				2D7B62F91678908300E35E54 /* task_man.c in Sources */,
-				2D7B62FC1678909C00E35E54 /* music.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};