* cartoons.c *
***********************************************************/
-#include "libgame/libgame.h"
-
#include "cartoons.h"
#include "main.h"
#include "tools.h"
+
static void HandleAnimation(int);
static boolean AnimateToon(int, boolean);
static void DrawAnim(Bitmap, GC, int, int, int, int, int, int, int, int);
setup.sound_simple = setup.sound;
+ SetAudioMode(setup.sound);
InitJoysticks();
}
OpenAudio(&audio);
+ AllocSoundArray(NUM_SOUNDS);
+
for(i=0; i<NUM_SOUNDS; i++)
{
- Sound[i].name = sound_name[i];
-
- if (!LoadSound(&Sound[i]))
+ if (!LoadSound(i, sound_name[i]))
{
audio.sound_available = FALSE;
audio.loops_available = FALSE;
+ audio.sound_enabled = FALSE;
+
return;
}
}
# (c) 1995-2000 Holger Schemel, info@artsoft.org #
#=============================================================================#
-SRCS = libgame.c \
- private.c \
- system.c \
+SRCS = system.c \
gadgets.c \
text.c \
sound.c \
x11.c \
sdl.c
-OBJS = libgame.o \
- private.o \
- system.o \
+OBJS = system.o \
gadgets.o \
text.o \
sound.o \
#include <stdarg.h>
#include <string.h>
-#include "libgame.h"
-
#include "gadgets.h"
+#include "text.h"
+#include "misc.h"
/* values for DrawGadget() */
#ifndef GADGETS_H
#define GADGETS_H
-#include "libgame.h"
+#include "system.h"
#define GADGET_FRAME_DELAY 150 /* delay between gadget actions */
* image.c *
***********************************************************/
-#include "platform.h"
-
-#if defined(TARGET_X11)
-
#include "image.h"
#include "pcx.h"
#include "misc.h"
+
+#if defined(TARGET_X11)
+
/* for MS-DOS/Allegro, exclude all except newImage() and freeImage() */
Image *newImage(unsigned int width, unsigned int height, unsigned int depth)
#ifndef IMAGE_H
#define IMAGE_H
-#include "platform.h"
-
-#ifndef TARGET_SDL
-
-#include "types.h"
#include "system.h"
-/*
-#include "types.h"
-#include "x11.h"
-*/
+
+#if defined(TARGET_X11)
#define MAX_COLORS 256 /* maximal number of colors for each image */
void freeXImage(Image *, XImageInfo *);
int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *);
-#endif /* !TARGET_SDL */
+#endif /* TARGET_X11 */
+
#endif /* IMAGE_H */
+++ /dev/null
-/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
-*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
-*----------------------------------------------------------*
-* libgame.c *
-***********************************************************/
-
-#include "libgame.h"
-
-
-/* ========================================================================= */
-/* exported variables */
-/* ========================================================================= */
-
-struct ProgramInfo program;
-struct OptionInfo options;
-struct VideoSystemInfo video;
-struct AudioSystemInfo audio;
-struct GfxInfo gfx;
-
-struct LevelDirInfo *leveldir_first = NULL;
-struct LevelDirInfo *leveldir_current = NULL;
-
-Display *display = NULL;
-Visual *visual = NULL;
-int screen = 0;
-Colormap cmap = None;
-
-DrawWindow window = NULL;
-DrawBuffer backbuffer = NULL;
-DrawBuffer drawto = NULL;
-
-int button_status = MB_NOT_PRESSED;
-boolean motion_status = FALSE;
-
-int redraw_mask = REDRAW_NONE;
-int redraw_tiles = 0;
-
-int FrameCounter = 0;
#include "platform.h"
#include "types.h"
-#include "private.h"
#include "system.h"
#include "random.h"
#include "gadgets.h"
#include "pcx.h"
#include "misc.h"
-
-/* default name for empty highscore entry */
-#define EMPTY_PLAYER_NAME "no name"
-
-/* default name for unknown player names */
-#define ANONYMOUS_NAME "anonymous"
-
-/* default name for new levels */
-#define NAMELESS_LEVEL_NAME "nameless level"
-
-/* definitions for game sub-directories */
-#ifndef RO_GAME_DIR
-#define RO_GAME_DIR "."
-#endif
-
-#ifndef RW_GAME_DIR
-#define RW_GAME_DIR "."
-#endif
-
-#define RO_BASE_PATH RO_GAME_DIR
-#define RW_BASE_PATH RW_GAME_DIR
-
-#define GRAPHICS_DIRECTORY "graphics"
-#define SOUNDS_DIRECTORY "sounds"
-#define LEVELS_DIRECTORY "levels"
-#define TAPES_DIRECTORY "tapes"
-#define SCORES_DIRECTORY "scores"
-
-/* areas in bitmap PIX_DOOR */
-/* meaning in PIX_DB_DOOR: (3 PAGEs)
- PAGEX1: 1. buffer for DOOR_1
- PAGEX2: 2. buffer for DOOR_1
- PAGEX3: buffer for animations
-*/
-
-#define DOOR_GFX_PAGESIZE (gfx.dxsize)
-#define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
-#define DOOR_GFX_PAGEY1 (0)
-#define DOOR_GFX_PAGEY2 (gfx.dysize)
-
-struct LevelDirInfo
-{
- char *filename; /* level series single directory name */
- char *fullpath; /* complete path relative to level directory */
- char *basepath; /* absolute base path of level directory */
- char *name; /* level series name, as displayed on main screen */
- char *name_short; /* optional short name for level selection screen */
- char *name_sorting; /* optional sorting name for correct level sorting */
- char *author; /* level series author name levels without author */
- char *imported_from; /* optional comment for imported level series */
- int levels; /* number of levels in level series */
- int first_level; /* first level number (to allow start with 0 or 1) */
- int last_level; /* last level number (automatically calculated) */
- int sort_priority; /* sort levels by 'sort_priority' and then by name */
- boolean level_group; /* directory contains more level series directories */
- boolean parent_link; /* entry links back to parent directory */
- boolean user_defined; /* user defined levels are stored in home directory */
- boolean readonly; /* readonly levels can not be changed with editor */
- int color; /* color to use on selection screen for this level */
- char *class_desc; /* description of level series class */
- int handicap_level; /* number of the lowest unsolved level */
- int cl_first; /* internal control field for "choose level" screen */
- int cl_cursor; /* internal control field for "choose level" screen */
-
- struct LevelDirInfo *node_parent; /* parent level directory info */
- struct LevelDirInfo *node_group; /* level group sub-directory info */
- struct LevelDirInfo *next; /* next level series structure node */
-};
-
-
-/* ========================================================================= */
-/* exported variables */
-/* ========================================================================= */
-
-extern struct ProgramInfo program;
-extern struct OptionInfo options;
-extern struct VideoSystemInfo video;
-extern struct AudioSystemInfo audio;
-extern struct GfxInfo gfx;
-
-extern struct LevelDirInfo *leveldir_first;
-extern struct LevelDirInfo *leveldir_current;
-
-extern Display *display;
-extern Visual *visual;
-extern int screen;
-extern Colormap cmap;
-
-extern DrawWindow window;
-extern DrawBuffer backbuffer;
-extern DrawBuffer drawto;
-
-extern int button_status;
-extern boolean motion_status;
-
-extern int redraw_mask;
-extern int redraw_tiles;
-
-extern int FrameCounter;
-
#endif /* LIBGAME_H */
+++ /dev/null
-../main.h
\ No newline at end of file
#include <sys/param.h>
#endif
-#include "libgame.h"
-
#include "misc.h"
+#include "random.h"
-#if 0
-#include "joystick_TMP.h"
-#endif
#if defined(PLATFORM_MSDOS)
volatile unsigned long counter = 0;
#include <stdlib.h>
#include <stdio.h>
-#include "libgame.h"
+#include "system.h"
+
/* values for InitCounter() and Counter() */
#define INIT_COUNTER 0
* msdos.c *
***********************************************************/
-#include "libgame.h"
+#include "system.h"
+
#if defined(PLATFORM_MSDOS)
+#include "sound.h"
+#include "misc.h"
+#include "pcx.h"
+
#define AllegroDefaultScreen() (display->screens[display->default_screen])
/* allegro driver declarations */
keyboard_auto_repeat = FALSE;
}
-boolean MSDOSOpenAudio(void)
+Bool MSDOSOpenAudio(void)
{
return allegro_init_audio();
}
#include <time.h>
#include "allegro.h"
+
/* symbol 'window' is defined in DJGPP cross-compiler in libc.a(conio.o) */
#define window window_djgpp
void XAutoRepeatOn(Display *);
void XAutoRepeatOff(Display *);
-boolean MSDOSOpenAudio(void);
+Bool MSDOSOpenAudio(void);
void MSDOSCloseAudio(void);
void NetworkServer(int, int);
#ifndef TARGET_SDL
+#include <stdio.h>
+
#include "pcx.h"
-#include "image.h"
#include "misc.h"
+
#define PCX_DEBUG FALSE
#define PCX_MAGIC 0x0a /* first byte in a PCX image file */
#ifndef PCX_H
#define PCX_H
-#include "libgame.h"
+#include "system.h"
+#include "image.h"
+
#if !defined(TARGET_SDL)
+++ /dev/null
-/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
-*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
-*----------------------------------------------------------*
-* private.c *
-***********************************************************/
-
-#include "libgame.h"
-
-#if 0
-Display *display;
-Visual *visual;
-int screen;
-
-DrawWindow window = None;
-#endif
+++ /dev/null
-/***********************************************************
-* Rocks'n'Diamonds -- McDuffin Strikes Back! *
-*----------------------------------------------------------*
-* (c) 1995-98 Artsoft Entertainment *
-* Holger Schemel *
-* Oststrasse 11a *
-* 33604 Bielefeld *
-* phone: ++49 +521 290471 *
-* email: aeglos@valinor.owl.de *
-*----------------------------------------------------------*
-* private.h *
-***********************************************************/
-
-#ifndef PRIVATE_H
-#define PRIVATE_H
-
-#include "libgame.h"
-
-#if 0
-extern Display *display;
-extern Visual *visual;
-extern int screen;
-
-extern DrawWindow window;
-#endif
-
-#endif /* PRIVATE_H */
* sdl.c *
***********************************************************/
-#include "libgame.h"
+#include "system.h"
+#include "misc.h"
-#ifdef TARGET_SDL
+
+#if defined(TARGET_SDL)
inline void SDLInitVideoDisplay(void)
{
* sound.c *
***********************************************************/
-#include "libgame.h"
-
-#include "main_TMP.h"
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
#include "sound.h"
#include "misc.h"
+
+static int num_sounds = 0;
+static struct SampleInfo *Sound = NULL;
+
+
/*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
static int playing_sounds = 0;
audio->device_name = audio_device_name[i];
audio->sound_available = TRUE;
+ audio->sound_enabled = TRUE;
#if defined(AUDIO_STREAMING_DSP)
audio->loops_available = TRUE;
/*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/
+void AllocSoundArray(int num)
+{
+ num_sounds = num;
+ Sound = checked_calloc(num_sounds * sizeof(struct SampleInfo));
+}
+
#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
#define WAV_HEADER_SIZE 20 /* size of WAV file header */
-boolean LoadSound(struct SampleInfo *snd_info)
+boolean LoadSound(int sound_nr, char *sound_name)
{
+ struct SampleInfo *snd_info = &Sound[sound_nr];
char filename[256];
char *sound_ext = "wav";
#if !defined(TARGET_SDL)
#endif
#endif
+ snd_info->name = sound_name;
+
sprintf(filename, "%s/%s/%s.%s",
options.ro_base_directory, SOUNDS_DIRECTORY,
snd_info->name, sound_ext);
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (!audio.sound_available || !setup.sound)
+ if (!audio.sound_available || !audio.sound_enabled)
return;
if (volume<PSND_MIN_VOLUME)
if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- audio.sound_available = FALSE;
+ audio.sound_available = audio.sound_enabled = FALSE;
return;
}
#else
if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- audio.sound_available = FALSE;
+ audio.sound_available = audio.sound_enabled = FALSE;
return;
}
#else
#include <math.h>
+#include "platform.h"
+
#if defined(PLATFORM_LINUX)
#include <sys/ioctl.h>
#endif
-#define SND_BLOCKSIZE 4096
-
#if defined(PLATFORM_LINUX)
#include <linux/soundcard.h>
#elif defined(PLATFORM_FREEBSD)
#include <machine/soundcard.h>
#elif defined(PLATFORM_HPUX)
#include <sys/audio.h>
-#undef SND_BLOCKSIZE
-#define SND_BLOCKSIZE 32768
#endif
-#include "libgame.h"
+#include "system.h"
+
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE)
#define AUDIO_STREAMING_DSP
#define MAX_SOUNDS_PLAYING 8
#endif
+#if !defined(PLATFORM_HPUX)
+#define SND_BLOCKSIZE 4096
+#else
+#define SND_BLOCKSIZE 32768
+#endif
+
/* some values for PlaySound(), StopSound() and friends */
#if !defined(PLATFORM_MSDOS)
#define PSND_SILENCE 0
void SoundServer(void);
/* sound client functions */
-boolean LoadSound(struct SampleInfo *);
+void AllocSoundArray(int);
+boolean LoadSound(int, char *);
void PlaySound(int);
void PlaySoundStereo(int, int);
void PlaySoundLoop(int);
#include <fcntl.h>
#endif
-#include "libgame.h"
+#include "system.h"
+#include "sound.h"
+#include "misc.h"
+
-#if 0
/* ========================================================================= */
/* exported variables */
/* ========================================================================= */
struct AudioSystemInfo audio;
struct GfxInfo gfx;
+struct LevelDirInfo *leveldir_first = NULL;
+struct LevelDirInfo *leveldir_current = NULL;
+
Display *display = NULL;
Visual *visual = NULL;
int screen = 0;
int FrameCounter = 0;
-#endif
/* ========================================================================= */
/* init functions */
{
audio->sound_available = FALSE;
audio->loops_available = FALSE;
+ audio->sound_enabled = FALSE;
audio->soundserver_pipe[0] = audio->soundserver_pipe[1] = 0;
audio->soundserver_pid = 0;
audio->device_name = NULL;
{
audio->sound_available = TRUE;
audio->loops_available = TRUE;
+ audio->sound_enabled = TRUE;
}
#elif defined(PLATFORM_MSDOS)
if (MSDOSOpenAudio())
{
audio->sound_available = TRUE;
audio->loops_available = TRUE;
+ audio->sound_enabled = TRUE;
}
#elif defined(PLATFORM_UNIX)
UnixOpenAudio(audio);
audio->sound_available = FALSE;
audio->loops_available = FALSE;
+ audio->sound_enabled = FALSE;
+}
+
+inline void SetAudioMode(boolean enabled)
+{
+ if (!audio.sound_available)
+ return;
+
+ audio.sound_enabled = enabled;
}
#ifndef SYSTEM_H
#define SYSTEM_H
-/*
-#include "libgame.h"
-*/
+#include "platform.h"
+#include "types.h"
#if defined(PLATFORM_MSDOS)
#include "msdos.h"
#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
+/* default name for empty highscore entry */
+#define EMPTY_PLAYER_NAME "no name"
+
+/* default name for unknown player names */
+#define ANONYMOUS_NAME "anonymous"
+
+/* default name for new levels */
+#define NAMELESS_LEVEL_NAME "nameless level"
+
+/* definitions for game sub-directories */
+#ifndef RO_GAME_DIR
+#define RO_GAME_DIR "."
+#endif
+
+#ifndef RW_GAME_DIR
+#define RW_GAME_DIR "."
+#endif
+
+#define RO_BASE_PATH RO_GAME_DIR
+#define RW_BASE_PATH RW_GAME_DIR
+
+#define GRAPHICS_DIRECTORY "graphics"
+#define SOUNDS_DIRECTORY "sounds"
+#define LEVELS_DIRECTORY "levels"
+#define TAPES_DIRECTORY "tapes"
+#define SCORES_DIRECTORY "scores"
+
+/* areas in bitmap PIX_DOOR */
+/* meaning in PIX_DB_DOOR: (3 PAGEs)
+ PAGEX1: 1. buffer for DOOR_1
+ PAGEX2: 2. buffer for DOOR_1
+ PAGEX3: buffer for animations
+*/
+
+#define DOOR_GFX_PAGESIZE (gfx.dxsize)
+#define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
+#define DOOR_GFX_PAGEY1 (0)
+#define DOOR_GFX_PAGEY2 (gfx.dysize)
+
+
/* type definitions */
typedef int (*EventFilter)(const Event *);
{
boolean sound_available;
boolean loops_available;
+ boolean sound_enabled;
int soundserver_pipe[2];
int soundserver_pid;
char *device_name;
int vxsize, vysize;
};
+struct LevelDirInfo
+{
+ char *filename; /* level series single directory name */
+ char *fullpath; /* complete path relative to level directory */
+ char *basepath; /* absolute base path of level directory */
+ char *name; /* level series name, as displayed on main screen */
+ char *name_short; /* optional short name for level selection screen */
+ char *name_sorting; /* optional sorting name for correct level sorting */
+ char *author; /* level series author name levels without author */
+ char *imported_from; /* optional comment for imported level series */
+ int levels; /* number of levels in level series */
+ int first_level; /* first level number (to allow start with 0 or 1) */
+ int last_level; /* last level number (automatically calculated) */
+ int sort_priority; /* sort levels by 'sort_priority' and then by name */
+ boolean level_group; /* directory contains more level series directories */
+ boolean parent_link; /* entry links back to parent directory */
+ boolean user_defined; /* user defined levels are stored in home directory */
+ boolean readonly; /* readonly levels can not be changed with editor */
+ int color; /* color to use on selection screen for this level */
+ char *class_desc; /* description of level series class */
+ int handicap_level; /* number of the lowest unsolved level */
+ int cl_first; /* internal control field for "choose level" screen */
+ int cl_cursor; /* internal control field for "choose level" screen */
+
+ struct LevelDirInfo *node_parent; /* parent level directory info */
+ struct LevelDirInfo *node_group; /* level group sub-directory info */
+ struct LevelDirInfo *next; /* next level series structure node */
+};
+
-#if 0
/* ========================================================================= */
/* exported variables */
/* ========================================================================= */
extern struct AudioSystemInfo audio;
extern struct GfxInfo gfx;
+extern struct LevelDirInfo *leveldir_first;
+extern struct LevelDirInfo *leveldir_current;
+
extern Display *display;
extern Visual *visual;
extern int screen;
extern int FrameCounter;
-#endif
/* function definitions */
inline boolean OpenAudio(struct AudioSystemInfo *);
inline void CloseAudio(struct AudioSystemInfo *);
+inline void SetAudioMode(boolean);
inline void InitEventFilter(EventFilter);
inline boolean PendingEvent(void);
* text.c *
***********************************************************/
+#include <stdio.h>
#include <stdarg.h>
-#include "libgame.h"
+#include "text.h"
/* ========================================================================= */
#ifndef TEXT_H
#define TEXT_H
-#include "libgame.h"
+#include "system.h"
+
/* font types */
#define FS_SMALL 0
* x11.c *
***********************************************************/
-#include "libgame.h"
+#include "system.h"
+#include "misc.h"
+
#if defined(TARGET_X11)
struct LevelInfo level;
struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL;
struct HiScore highscore[MAX_SCORE_ENTRIES];
+#if 0
struct SampleInfo Sound[NUM_SOUNDS];
+#endif
struct TapeInfo tape;
#if 0
#define DEBUG_TIMING 0
#endif
-#if 0
#include "libgame/libgame.h"
-#endif
#ifndef FALSE
#define FALSE 0
extern struct PlayerInfo stored_player[], *local_player;
extern struct HiScore highscore[];
extern struct TapeInfo tape;
+#if 0
extern struct SampleInfo Sound[];
+#endif
extern struct JoystickInfo joystick[];
#if 0