# uncomment this if your system has no joystick include file
# JOYSTICK = -DNO_JOYSTICK
-# uncomment this if your system has no sound
-# SOUNDS = -DNO_SOUNDS
-
# choose if you want to allow many global score file entries for one player
# default is 'MANY_PER_NAME'
# when installing the game in a multi user environment, choose this
CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
-CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(SOUNDS) $(JOYSTICK)
+CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(JOYSTICK)
DEBUG = -DDEBUG -g
OPTIONS = $(DEBUG) -Wall # only for debugging purposes
# OPTIONS = -O3 -Wall -ansi -pedantic
# OPTIONS = -O3 -Wall
# OPTIONS = -O3
+# OPTIONS = -DSYSV -Ae # may be needed for HP-UX
CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG)
LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
void GetPlayerConfig()
{
- if (sound_status == SOUND_OFF)
+ if (!sysinfo.audio_available)
setup.sound = FALSE;
- if (!sound_loops_allowed)
+ if (!sysinfo.audio_loops_available)
{
setup.sound_loops = FALSE;
setup.sound_music = FALSE;
setup.sound_music = FALSE;
FadeSound(background_loop[level_nr % num_bg_loops]);
}
- else if (sound_loops_allowed)
+ else if (sysinfo.audio_loops_available)
{
setup.sound = setup.sound_music = TRUE;
PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
case SOUND_CTRL_ID_LOOPS:
if (setup.sound_loops)
setup.sound_loops = FALSE;
- else if (sound_loops_allowed)
+ else if (sysinfo.audio_loops_available)
setup.sound = setup.sound_loops = TRUE;
break;
case SOUND_CTRL_ID_SIMPLE:
if (setup.sound_simple)
setup.sound_simple = FALSE;
- else if (sound_status==SOUND_AVAILABLE)
+ else if (sysinfo.audio_available)
setup.sound = setup.sound_simple = TRUE;
break;
boolean picture_with_mask;
};
-#ifndef TARGET_SDL
-static int sound_process_id = 0;
-#endif
-
static void InitPlayerInfo(void);
static void InitLevelInfo(void);
static void InitNetworkServer(void);
{
int i;
- if (sound_status == SOUND_OFF)
+ /* REMOVE THIS! (gone to system.c:InitAudio) */
+ if (!sysinfo.audio_available)
return;
#if defined(TARGET_SDL)
if (InitAudio())
{
- sound_status = SOUND_AVAILABLE;
- sound_loops_allowed = TRUE;
+ sysinfo.audio_available = TRUE;
+ sysinfo.audio_loops_available = TRUE;
}
else
{
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
}
#else /* !TARGET_SDL */
#if defined(PLATFORM_UNIX)
- if ((sound_status = CheckAudio(sound_device_name)) == SOUND_OFF)
+ if (!(sysinfo.audio_available = CheckAudio(sound_device_name)))
return;
#ifdef VOXWARE
- sound_loops_allowed = TRUE;
+ sysinfo.audio_loops_available = TRUE;
#endif
#else /* !PLATFORM_UNIX */
- sound_loops_allowed = TRUE;
+ sysinfo.audio_loops_available = TRUE;
#endif /* !PLATFORM_UNIX */
#endif /* !TARGET_SDL */
if (!LoadSound(&Sound[i]))
{
- sound_status = SOUND_OFF;
- sound_loops_allowed = FALSE;
+ sysinfo.audio_available = FALSE;
+ sysinfo.audio_loops_available = FALSE;
return;
}
}
void InitSoundServer()
{
- if (sound_status == SOUND_OFF)
+ if (!sysinfo.audio_available)
return;
#if !defined(TARGET_SDL)
#if defined(PLATFORM_UNIX)
- if (pipe(sound_pipe)<0)
+ if (pipe(sysinfo.audio_process_pipe) < 0)
{
Error(ERR_WARN, "cannot create pipe - no sounds");
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
return;
}
- if ((sound_process_id = fork()) < 0)
+ if ((sysinfo.audio_process_id = fork()) < 0)
{
Error(ERR_WARN, "cannot create sound server process - no sounds");
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
return;
}
- if (!sound_process_id) /* we are child */
+ if (!sysinfo.audio_process_id) /* we are child */
{
SoundServer();
/* never reached */
exit(0);
}
- else /* we are parent */
- close(sound_pipe[0]); /* no reading from pipe needed */
+ else /* we are parent */
+ close(sysinfo.audio_process_pipe[0]); /* no reading from pipe needed */
#else /* !PLATFORM_UNIX */
StopSounds();
FreeSounds(NUM_SOUNDS);
#else
- if (sound_process_id)
+ if (sysinfo.audio_process_id)
{
StopSounds();
- kill(sound_process_id, SIGTERM);
+ kill(sysinfo.audio_process_id, SIGTERM);
FreeSounds(NUM_SOUNDS);
}
#endif
DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer;
Colormap cmap;
-int sound_pipe[2];
-int sound_device;
char *sound_device_name = SOUND_DEVICE;
+
int joystick_device = 0;
char *joystick_device_name[MAX_PLAYERS] =
{
int key_joystick_mapping = 0;
int global_joystick_status = JOYSTICK_STATUS;
int joystick_status = JOYSTICK_STATUS;
-int sound_status = SOUND_STATUS;
-boolean sound_loops_allowed = FALSE;
boolean fullscreen_available = FULLSCREEN_STATUS;
boolean fullscreen_enabled = FALSE;
struct LevelInfo level;
struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL;
struct HiScore highscore[MAX_SCORE_ENTRIES];
-struct SoundInfo Sound[NUM_SOUNDS];
+struct SampleInfo Sound[NUM_SOUNDS];
struct TapeInfo tape;
struct OptionInfo options;
struct SetupInfo setup;
struct GameInfo game;
+struct SystemInfo sysinfo;
struct GlobalInfo global;
/* data needed for playing sounds */
extern DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer;
extern Colormap cmap;
-extern int sound_pipe[2];
-extern int sound_device;
extern char *sound_device_name;
+
extern int joystick_device;
extern char *joystick_device_name[];
extern boolean motion_status;
extern int key_joystick_mapping;
extern int global_joystick_status, joystick_status;
-extern int sound_status;
-extern boolean sound_loops_allowed;
extern boolean fullscreen_available;
extern boolean fullscreen_enabled;
extern struct PlayerInfo stored_player[], *local_player;
extern struct HiScore highscore[];
extern struct TapeInfo tape;
-extern struct SoundInfo Sound[];
+extern struct SampleInfo Sound[];
extern struct JoystickInfo joystick[];
extern struct OptionInfo options;
extern struct SetupInfo setup;
extern struct GameInfo game;
+extern struct SystemInfo sysinfo;
extern struct GlobalInfo global;
extern char *sound_name[];
last_joystick_state = 0;
joystick_event = FALSE;
+ sysinfo.audio_available = TRUE;
reserve_voices(MAX_SOUNDS_PLAYING, 0);
if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1)
if (install_sound(DIGI_SB, MIDI_NONE, NULL) == -1)
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
}
static boolean hide_mouse(Display *display, int x, int y,
#define PLATFORM_UNIX
#endif
+/* define additional keywords for several Unix platforms */
+
+#if defined(__FreeBSD__)
+#define PLATFORM_FREEBSD
+#endif
+
+/* detecting HP-UX by the following compiler keyword definitions:
+ - in K&R mode (the default), the HP C compiler defines "hpux"
+ - in ANSI mode (-Aa or -Ae), the HP C compiler defines "__hpux"
+ - the gcc (Gnu) C compiler defines "__hpux__"
+ Thanks to Jarkko Hietaniemi for this note. */
+
+#if defined(__hpux__) || defined(__hpux) || defined(hpux)
+#define PLATFORM_HPUX
+#endif
+
#endif /* PLATFORM_H */
{
int yy = y-1;
- if (y==3 && sound_status==SOUND_AVAILABLE)
+ if (y == 3 && sysinfo.audio_available)
{
if (setup.sound)
{
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.sound = !setup.sound;
}
- else if (y==4 && sound_loops_allowed)
+ else if (y == 4 && sysinfo.audio_loops_available)
{
if (setup.sound_loops)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
}
setup.sound_loops = !setup.sound_loops;
}
- else if (y==5 && sound_loops_allowed)
+ else if (y == 5 && sysinfo.audio_loops_available)
{
if (setup.sound_music)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
}
#if 0
- else if (y==6)
+ else if (y == 6)
{
if (setup.toons)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.toons = !setup.toons;
}
- else if (y==7)
+ else if (y == 7)
{
#if 0
if (setup.double_buffering)
}
#endif
- else if (y==6)
+ else if (y == 6)
{
if (setup.scroll_delay)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.scroll_delay = !setup.scroll_delay;
}
- else if (y==7)
+ else if (y == 7)
{
if (setup.soft_scrolling)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
setup.soft_scrolling = !setup.soft_scrolling;
}
#if 0
- else if (y==8)
+ else if (y == 8)
{
if (setup.fading)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
setup.fading = !setup.fading;
}
#endif
- else if (y==8 && fullscreen_available)
+ else if (y == 8 && fullscreen_available)
{
if (setup.fullscreen)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.fullscreen = !setup.fullscreen;
}
- else if (y==9)
+ else if (y == 9)
{
if (setup.quick_doors)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.quick_doors = !setup.quick_doors;
}
- else if (y==10)
+ else if (y == 10)
{
if (setup.autorecord)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.autorecord = !setup.autorecord;
}
- else if (y==11)
+ else if (y == 11)
{
if (setup.team_mode)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.team_mode = !setup.team_mode;
}
- else if (y==12)
+ else if (y == 12)
{
if (setup.handicap)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.handicap = !setup.handicap;
}
- else if (y==13)
+ else if (y == 13)
{
if (setup.time_limit)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
setup.time_limit = !setup.time_limit;
}
- else if (y==14)
+ else if (y == 14)
{
game_status = SETUPINPUT;
DrawSetupInputScreen();
struct SoundControl snd_ctrl;
fd_set sound_fdset;
- close(sound_pipe[1]); /* no writing into pipe needed */
+ close(sysinfo.audio_process_pipe[1]); /* no writing into pipe needed */
#endif
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
#endif
FD_ZERO(&sound_fdset);
- FD_SET(sound_pipe[0], &sound_fdset);
+ FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
while(1) /* wait for sound playing commands from client */
{
- FD_SET(sound_pipe[0], &sound_fdset);
- select(sound_pipe[0]+1, &sound_fdset, NULL, NULL, NULL);
- if (!FD_ISSET(sound_pipe[0], &sound_fdset))
+ FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
+ select(sysinfo.audio_process_pipe[0] + 1, &sound_fdset, NULL, NULL, NULL);
+ if (!FD_ISSET(sysinfo.audio_process_pipe[0], &sound_fdset))
continue;
- if (read(sound_pipe[0], &snd_ctrl, sizeof(snd_ctrl)) != sizeof(snd_ctrl))
+ if (read(sysinfo.audio_process_pipe[0], &snd_ctrl, sizeof(snd_ctrl))
+ != sizeof(snd_ctrl))
Error(ERR_EXIT_SOUND_SERVER, "broken pipe - no sounds");
#ifdef VOXWARE
playlist[i]=emptySoundControl;
playing_sounds=0;
- close(sound_device);
+ close(sysinfo.audio_fd);
}
else if (snd_ctrl.stop_sound)
{
}
if (!playing_sounds)
- close(sound_device);
+ close(sysinfo.audio_fd);
}
if (playing_sounds || snd_ctrl.active)
#endif
if (playing_sounds ||
- (sound_device = OpenAudio(sound_device_name)) >= 0)
+ (sysinfo.audio_fd = OpenAudio(sound_device_name)) >= 0)
{
if (!playing_sounds) /* we just opened the audio device */
{
/* (with stereo the effective buffer size will shrink to 256) */
fragment_size = 0x00020009;
- if (ioctl(sound_device, SNDCTL_DSP_SETFRAGMENT, &fragment_size) < 0)
+ if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_size)
+ < 0)
Error(ERR_EXIT_SOUND_SERVER,
"cannot set fragment size of /dev/dsp - no sounds");
/* try if we can use stereo sound */
- if (ioctl(sound_device, SNDCTL_DSP_STEREO, &stereo) < 0)
+ if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0)
{
#ifdef DEBUG
static boolean reported = FALSE;
stereo = FALSE;
}
- if (ioctl(sound_device, SNDCTL_DSP_SPEED, &sample_rate) < 0)
+ if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0)
Error(ERR_EXIT_SOUND_SERVER,
"cannot set sample rate of /dev/dsp - no sounds");
/* get the real fragmentation size; this should return 512 */
- if (ioctl(sound_device, SNDCTL_DSP_GETBLKSIZE, &fragment_size) < 0)
+ if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_GETBLKSIZE, &fragment_size)
+ < 0)
Error(ERR_EXIT_SOUND_SERVER,
"cannot get fragment size of /dev/dsp - no sounds");
SoundServer_InsertNewSound(snd_ctrl);
while(playing_sounds &&
- select(sound_pipe[0]+1,&sound_fdset,NULL,NULL,&delay)<1)
+ select(sysinfo.audio_process_pipe[0] + 1,
+ &sound_fdset, NULL, NULL, &delay) < 1)
{
- FD_SET(sound_pipe[0], &sound_fdset);
+ FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
/* first clear the last premixing buffer */
memset(premix_last_buffer,0,fragment_size*sizeof(int));
}
/* finally play the sound fragment */
- write(sound_device,playing_buffer,fragment_size);
+ write(sysinfo.audio_fd, playing_buffer,fragment_size);
}
/* if no sounds playing, free device for other sound programs */
if (!playing_sounds)
- close(sound_device);
+ close(sysinfo.audio_fd);
}
}
int wait_percent = 90; /* wait 90% of the real playing time */
int i;
- if ((sound_device = OpenAudio(sound_device_name)) >= 0)
+ if ((sysinfo.audio_fd = OpenAudio(sound_device_name)) >= 0)
{
playing_sounds = 1;
while(playing_sounds &&
- select(sound_pipe[0]+1,&sound_fdset,NULL,NULL,&delay)<1)
+ select(sysinfo.audio_process_pipe[0] + 1,
+ &sound_fdset, NULL, NULL, &delay) < 1)
{
- FD_SET(sound_pipe[0], &sound_fdset);
+ FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
/* get pointer and size of the actual sound sample */
sample_ptr = snd_ctrl.data_ptr + snd_ctrl.playingpos;
playing_sounds = 0;
/* finally play the sound fragment */
- write(sound_device,playing_buffer,sample_size);
+ write(sysinfo.audio_fd,playing_buffer,sample_size);
delay.tv_sec = 0;
delay.tv_usec = ((sample_size*10*wait_percent)/(sample_rate))*1000;
}
- close(sound_device);
+ close(sysinfo.audio_fd);
}
}
#if !defined(PLATFORM_MSDOS)
if (!playing_sounds)
- close(sound_device);
+ close(sysinfo.audio_fd);
#endif
}
playing_sounds = 0;
#if !defined(PLATFORM_MSDOS)
- close(sound_device);
+ close(sysinfo.audio_fd);
#endif
}
#endif /* PLATFORM_MSDOS */
#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
#define WAV_HEADER_SIZE 20 /* size of WAV file header */
-boolean LoadSound(struct SoundInfo *snd_info)
+boolean LoadSound(struct SampleInfo *snd_info)
{
char filename[256];
char *sound_ext = "wav";
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (sound_status==SOUND_OFF || !setup.sound)
+ if (!sysinfo.audio_available || !setup.sound)
return;
if (volume<PSND_MIN_VOLUME)
#else
#if !defined(PLATFORM_MSDOS)
- if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
+ if (write(sysinfo.audio_process_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
return;
}
#else
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (sound_status==SOUND_OFF)
+ if (!sysinfo.audio_available)
return;
if (SSND_FADING(method))
#else
#if !defined(PLATFORM_MSDOS)
- if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
+ if (write(sysinfo.audio_process_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- sound_status = SOUND_OFF;
+ sysinfo.audio_available = FALSE;
return;
}
#else
{
int i;
- if (sound_status == SOUND_OFF)
+ if (!sysinfo.audio_available)
return;
for(i=0; i<num_sounds; i++)
char magic_8SVX[4];
};
-struct SoundInfo
+struct SampleInfo
{
char *name;
byte *data_ptr;
void SoundServer(void);
/* sound client functions */
-boolean LoadSound(struct SoundInfo *);
+boolean LoadSound(struct SampleInfo *);
void PlaySound(int);
void PlaySoundStereo(int, int);
void PlaySoundLoop(int);
inline boolean InitAudio(void)
{
+ sysinfo.audio_available = TRUE;
+ sysinfo.audio_loops_available = FALSE;
+
+ if (!sysinfo.audio_available)
+ return FALSE;
+
#ifdef TARGET_SDL
return SDLInitAudio();
#else
#endif
-/* system-wide contant definitions */
+/* contant definitions */
#define DEFAULT_DEPTH 0
#define FULLSCREEN_AVAILABLE TRUE
-/* system-wide type definitions */
+/* type definitions */
typedef int (*EventFilter)(const Event *);
-/* system-wide function definitions */
+/* structure definitions */
+
+struct SystemInfo
+{
+ boolean audio_available;
+ boolean audio_loops_available;
+ int audio_process_id;
+ int audio_process_pipe[2];
+ int audio_fd;
+};
+
+
+/* function definitions */
inline void InitBufferedDisplay(DrawBuffer *, DrawWindow *);
inline int GetDisplayDepth(void);