Skip to content

Commit

Permalink
Fixed issue with more win32 calls, the sound engine is missing now.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiensanglard committed Dec 12, 2012
1 parent 6b9299b commit 62984ca
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 49 deletions.
4 changes: 4 additions & 0 deletions Game/src/duke3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "dukeunix.h"
#endif

#if PLATFORM_MACOSX
#include "dukeunix.h"
#endif

#if PLATFORM_WIN32
#include "dukewin.h"
#endif
Expand Down
101 changes: 101 additions & 0 deletions Game/src/dukeunix.h
Original file line number Diff line number Diff line change
@@ -0,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
2 changes: 2 additions & 0 deletions Game/src/funct.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#ifndef FUNCT_H
#define FUNCT_H

#include "duke3d.h"

extern void sendscore(char *s);
//#line "sounds.c" 25
extern void SoundStartup(void );
Expand Down
61 changes: 42 additions & 19 deletions Game/src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------

#include <windows.h>
#ifdef _WIN32
#include <windows.h>
#endif

#include "types.h"

#include "develop.h"
Expand All @@ -37,7 +40,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "control.h"
#include "sounds.h"
#include "config.h"
#include "audiolib\sndcards.h"
#include "audiolib/sndcards.h"

#include "duke3d.h"

Expand Down Expand Up @@ -8038,45 +8041,40 @@ void copyprotect(void)
}
}

#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);
}
else
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
Expand All @@ -8090,6 +8088,31 @@ static int load_duke3d_groupfile(void)
}

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);

Expand Down
2 changes: 1 addition & 1 deletion Game/src/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ int _dos_findnext(struct find_t *f)
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;
Expand Down
2 changes: 1 addition & 1 deletion Game/src/menues.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void getangplayers(short snum)
}
}

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;
Expand Down
2 changes: 1 addition & 1 deletion Game/src/sector.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ long getanimationgoal(long *animptr)
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;

Expand Down
29 changes: 2 additions & 27 deletions xcode/Duke3D.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -285,7 +277,6 @@
2D7B623916788F7900E35E54 /* Game */ = {
isa = PBXGroup;
children = (
2D7B62851678902400E35E54 /* audiolib */,
2D7B623A16788F9B00E35E54 /* _functio.h */,
2D7B623B16788F9B00E35E54 /* _rts.h */,
2D7B623C16788F9B00E35E54 /* actors.c */,
Expand Down Expand Up @@ -333,6 +324,7 @@
2D7B626B16788F9B00E35E54 /* sounds.h */,
2D7B626C16788F9B00E35E54 /* types.h */,
2D7B626D16788F9B00E35E54 /* util_lib.h */,
2D7B62FD167905C400E35E54 /* dukeunix.h */,
);
name = Game;
sourceTree = "<group>";
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit 62984ca

Please sign in to comment.