From a8b2caa1d373c84c1b3fc2f615370c2a319051ca Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 25 Nov 2000 20:23:02 +0100 Subject: [PATCH] rnd-20001125-3-src --- Makefile | 27 ++++++-------- src/Makefile | 56 ++++++++++------------------- src/events.c | 4 +-- src/image.c | 4 +-- src/image.h | 5 ++- src/init.c | 96 +++++++++++++++----------------------------------- src/joystick.h | 2 +- src/misc.c | 24 ++++++------- src/pcx.c | 4 +-- src/pcx.h | 5 ++- src/screens.c | 2 +- src/sdl.c | 24 +++++++++++-- src/sdl.h | 2 ++ src/sound.c | 38 ++++++++++++++++---- src/sound.h | 10 ++++-- src/system.c | 55 +++++++++++++++++------------ src/system.h | 14 ++++++-- src/tools.c | 6 ++-- src/x11.c | 4 +-- 19 files changed, 192 insertions(+), 190 deletions(-) diff --git a/Makefile b/Makefile index 93533d6d..2ea6579c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ #=============================================================================# -# Makefile for Rocks'n'Diamonds 1.4.0 # -# (c) 1995-1999 Holger Schemel, aeglos@valinor.owl.de # +# Makefile for Rocks'n'Diamonds # +# (c) 1995-2000 Holger Schemel, info@artsoft.org # #=============================================================================# #-----------------------------------------------------------------------------# @@ -10,13 +10,6 @@ # specify your favorite ANSI C compiler CC = gcc -# explicitely choose your platform, if defaults doesn't work right -# needed for SUN/Solaris; Linux and DOS work fine with auto detection -# PLATFORM = solaris -# PLATFORM = unix -# PLATFORM = dos -# PLATFORM = windows - # specify path to X11 on your system # if undefined, use system defaults (works with Linux/gcc/libc5) X11_PATH = /usr/X11 @@ -42,7 +35,7 @@ X11_PATH = /usr/X11 # when installing the game in a single user environment, choose this # SCORE_ENTRIES = MANY_PER_NAME -# specify path for cross-compiling (only needed for Windows build) +# specify path for cross-compiling (only needed for Win32 build) CROSS_PATH=/usr/local/cross-tools/i386-mingw32/bin #-----------------------------------------------------------------------------# @@ -65,14 +58,14 @@ x11: sdl: @$(MAKE_CMD) TARGET=sdl -sdl_old: - @$(MAKE_CMD) TARGET=sdl USE_SDL_OLD_LIBS=true - solaris: @$(MAKE_CMD) PLATFORM=solaris -windows: - @PATH=$(CROSS_PATH):${PATH} $(MAKE_CMD) PLATFORM=windows +msdos: + @$(MAKE_CMD) PLATFORM=msdos + +win32: + @PATH=$(CROSS_PATH):${PATH} $(MAKE_CMD) PLATFORM=win32 clean: @$(MAKE_CMD) clean @@ -94,10 +87,10 @@ backup_gfx: dist-unix: ./Scripts/make_dist.sh unix . -dist-dos: +dist-msdos: ./Scripts/make_dist.sh dos . -dist: dist-unix dist-dos +dist: dist-unix dist-msdos depend dep: $(MAKE_CMD) depend diff --git a/src/Makefile b/src/Makefile index 93f9d3d3..f2b146b7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,11 +1,11 @@ #=============================================================================# -# Makefile for Rocks'n'Diamonds 1.4.0 # -# (c) 1995-1999 Holger Schemel, aeglos@valinor.owl.de # +# Makefile for Rocks'n'Diamonds # +# (c) 1995-2000 Holger Schemel, info@artsoft.org # #=============================================================================# ifndef PLATFORM # platform not specified -- try auto detection ifdef COMSPEC -PLATFORM = dos +PLATFORM = msdos else PLATFORM = unix endif @@ -19,22 +19,24 @@ X11_LIBS = -L$(XLIB_PATH) endif -ifeq ($(PLATFORM),dos) # DOS / Windows +ifeq ($(PLATFORM),msdos) # MS-DOS native compiling RM = del PROGNAME = ../rocks.exe -LIBS = -s -lm -lalleg -else # Unix +SYS_CFLAGS = -DTARGET_X11 +SYS_LDFLAGS = -s -lalleg -lm + +else # Unix; Win32 cross-compiling RM = rm -f PROGNAME = ../rocksndiamonds ifeq ($(PLATFORM),solaris) -EXTRA_LIBS = -lnsl -lsocket -R$(XLIB_PATH) +EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH) endif -ifeq ($(PLATFORM),windows) +ifeq ($(PLATFORM),win32) PROGNAME = ../rocksndiamonds.exe TARGET = sdl else @@ -42,35 +44,14 @@ PROFILING = -pg endif ifeq ($(TARGET),sdl) -USE_SDL = true -else -USE_SDL = false -endif - -ifeq ($(USE_SDL_OLD_LIBS),true) -SDL_EXTRA_LIBS = -lIMG -lmixer +SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags) +SYS_LDFLAGS = -lSDL_image -lSDL_mixer $(shell sdl-config --libs) -lm else -SDL_EXTRA_LIBS = -lSDL_image -lSDL_mixer +SYS_CFLAGS = -DTARGET_X11 $(X11_INCL) +SYS_LDFLAGS = $(X11_LIBS) -lX11 -lm endif -SDL_CFLAGS := -DUSE_SDL_LIBRARY $(shell sdl-config --cflags) -SDL_LDFLAGS := $(SDL_EXTRA_LIBS) $(shell sdl-config --libs) - -X11_CFLAGS = -DUSE_X11_LIBRARY $(X11_INCL) -X11_LDFLAGS = $(X11_LIBS) -lX11 - -ifeq ($(USE_SDL),true) -SYS_CFLAGS = $(SDL_CFLAGS) -SYS_LDFLAGS = $(SDL_LDFLAGS) -else -SYS_CFLAGS = $(X11_CFLAGS) -SYS_LDFLAGS = $(X11_LDFLAGS) -endif - -INCL = $(SYS_CFLAGS) -LIBS = $(SYS_LDFLAGS) $(EXTRA_LIBS) -lm - -endif # (PLATFORM != dos) +endif # (PLATFORM != msdos) ifdef RO_GAME_DIR # path to read-only game data specified @@ -98,9 +79,8 @@ OPTIONS = $(DEBUG) -Wall # only for debugging purposes # OPTIONS = -O3 -Wall # OPTIONS = -O3 -# SYSTEM = -DSYSV -Ae # may be needed for HP-UX - -CFLAGS = $(OPTIONS) $(SYSTEM) $(SYS_CFLAGS) $(CONFIG) +CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG) +LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) SRCS = main.c \ init.c \ @@ -153,7 +133,7 @@ OBJS = main.o \ all: $(PROGNAME) $(PROGNAME): $(OBJS) - $(CC) $(PROFILING) $(OBJS) $(LIBS) -o $(PROGNAME) + $(CC) $(PROFILING) $(OBJS) $(LDFLAGS) -o $(PROGNAME) .c.o: $(CC) $(PROFILING) $(CFLAGS) -c $*.c diff --git a/src/events.c b/src/events.c index 9f84cc20..8d6cd621 100644 --- a/src/events.c +++ b/src/events.c @@ -206,7 +206,7 @@ void SleepWhileUnmapped() void HandleExposeEvent(ExposeEvent *event) { -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL int x = event->x, y = event->y; int width = event->width, height = event->height; @@ -326,7 +326,7 @@ void HandleFocusEvent(FocusChangeEvent *event) void HandleClientMessageEvent(ClientMessageEvent *event) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL CloseAllAndExit(0); /* the only possible message here is SDL_QUIT */ #else #ifndef MSDOS diff --git a/src/image.c b/src/image.c index 2b234d47..5331a886 100644 --- a/src/image.c +++ b/src/image.c @@ -11,7 +11,7 @@ * image.c * ***********************************************************/ -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL #include "image.h" #include "pcx.h" @@ -554,4 +554,4 @@ int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, } #endif /* !MSDOS */ -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ diff --git a/src/image.h b/src/image.h index d05b63c6..18f3ec0d 100644 --- a/src/image.h +++ b/src/image.h @@ -14,7 +14,7 @@ #ifndef IMAGE_H #define IMAGE_H -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL #include "main.h" @@ -57,6 +57,5 @@ Image *newImage(unsigned int, unsigned int, unsigned int); void freeImage(Image *); void freeXImage(Image *, XImageInfo *); -#endif /* !USE_SDL_LIBRARY */ - +#endif /* !TARGET_SDL */ #endif /* IMAGE_H */ diff --git a/src/init.c b/src/init.c index a8ce6a50..411d5407 100644 --- a/src/init.c +++ b/src/init.c @@ -35,7 +35,7 @@ struct PictureFileInfo boolean picture_with_mask; }; -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL static int sound_process_id = 0; #endif @@ -149,66 +149,31 @@ void InitSound() if (sound_status == SOUND_OFF) return; -#ifdef USE_SDL_LIBRARY - /* initialize SDL audio */ - - if (SDL_Init(SDL_INIT_AUDIO) < 0) +#ifdef TARGET_SDL + if (InitAudio()) { - Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError()); - sound_status = SOUND_OFF; - return; + sound_status = SOUND_AVAILABLE; + sound_loops_allowed = TRUE; } - - if (Mix_OpenAudio(22050, AUDIO_S16, 2, 512) < 0) + else { - Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError()); sound_status = SOUND_OFF; - return; } - - Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); - Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); - - sound_status = SOUND_AVAILABLE; - sound_loops_allowed = TRUE; - -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ #if !defined(MSDOS) && !defined(WIN32) - if (access(sound_device_name, W_OK) != 0) - { - Error(ERR_WARN, "cannot access sound device - no sounds"); - sound_status = SOUND_OFF; + if ((sound_status = CheckAudio(sound_device_name)) == SOUND_OFF) return; - } - - if ((sound_device = OpenAudio(sound_device_name)) < 0) - { - Error(ERR_WARN, "cannot open sound device - no sounds"); - sound_status = SOUND_OFF; - return; - } - - close(sound_device); - sound_status = SOUND_AVAILABLE; #ifdef VOXWARE sound_loops_allowed = TRUE; - - /* - setup.sound_loops_on = TRUE; - */ - #endif + #else /* MSDOS || WIN32 */ sound_loops_allowed = TRUE; - /* - setup.sound_loops_on = TRUE; - */ - #endif /* MSDOS || WIN32 */ -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ for(i=0; ipicture_with_mask && !clipmask[pos]) Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename); -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ } void InitGadgets() @@ -1847,7 +1807,7 @@ void CloseAllAndExit(int exit_value) { int i; -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL StopSounds(); FreeSounds(NUM_SOUNDS); #else @@ -1864,7 +1824,7 @@ void CloseAllAndExit(int exit_value) if (pix[i]) FreeBitmap(pix[i]); -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL FreeBitmap(pix_masked[i]); #else if (clipmask[i]) @@ -1874,7 +1834,7 @@ void CloseAllAndExit(int exit_value) #endif } -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL KeyboardAutoRepeatOn(); #else if (gc) diff --git a/src/joystick.h b/src/joystick.h index 0bbb22bf..3632b7a7 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -36,7 +36,7 @@ /* get these values from the program 'js' from the joystick package, */ /* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */ -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL #define JOYSTICK_XLEFT -32767 #define JOYSTICK_XMIDDLE 0 #define JOYSTICK_XRIGHT 32767 diff --git a/src/misc.c b/src/misc.c index aaad307a..3d448a69 100644 --- a/src/misc.c +++ b/src/misc.c @@ -45,7 +45,7 @@ END_OF_FUNCTION(increment_counter); /* maximal allowed length of a command line option */ #define MAX_OPTION_LEN 256 -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL static unsigned long mainCounter(int mode) { @@ -64,7 +64,7 @@ static unsigned long mainCounter(int mode) return counter_ms; /* return milliseconds since last init */ } -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ #ifndef MSDOS static unsigned long mainCounter(int mode) @@ -86,7 +86,7 @@ static unsigned long mainCounter(int mode) } #endif /* !MSDOS */ -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ void InitCounter() /* set counter back to zero */ { @@ -133,9 +133,9 @@ static void sleep_milliseconds(unsigned long milliseconds_delay) } else { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_Delay(milliseconds_delay); -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ struct timeval delay; delay.tv_sec = milliseconds_delay / 1000; @@ -143,7 +143,7 @@ static void sleep_milliseconds(unsigned long milliseconds_delay) if (select(0, NULL, NULL, NULL, &delay) != 0) Error(ERR_WARN, "sleep_milliseconds(): select() failed"); -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ } } @@ -228,7 +228,7 @@ char *int2str(int number, int size) unsigned int SimpleRND(unsigned int max) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL static unsigned long root = 654321; unsigned long current_ms; @@ -237,7 +237,7 @@ unsigned int SimpleRND(unsigned int max) root = root * 4253261 + current_ms; return (root % max); -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ static unsigned long root = 654321; struct timeval current_time; @@ -246,7 +246,7 @@ unsigned int SimpleRND(unsigned int max) root = root * 4253261 + current_time.tv_sec + current_time.tv_usec; return (root % max); -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ } #ifdef DEBUG @@ -269,7 +269,7 @@ unsigned int RND(unsigned int max) unsigned int InitRND(long seed) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL unsigned long current_ms; if (seed == NEW_RANDOMIZE) @@ -283,7 +283,7 @@ unsigned int InitRND(long seed) srandom_linux_libc((unsigned int) seed); return (unsigned int) seed; } -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ struct timeval current_time; if (seed == NEW_RANDOMIZE) @@ -297,7 +297,7 @@ unsigned int InitRND(long seed) srandom_linux_libc((unsigned int) seed); return (unsigned int) seed; } -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ } char *getLoginName() diff --git a/src/pcx.c b/src/pcx.c index a3bdf3bd..b075940c 100644 --- a/src/pcx.c +++ b/src/pcx.c @@ -11,7 +11,7 @@ * pcx.c * ***********************************************************/ -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL #include "pcx.h" #include "image.h" @@ -262,4 +262,4 @@ Image *Read_PCX_to_Image(char *filename) return image; } -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ diff --git a/src/pcx.h b/src/pcx.h index 45fc251b..47250992 100644 --- a/src/pcx.h +++ b/src/pcx.h @@ -14,7 +14,7 @@ #ifndef PCX_H #define PCX_H -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL #include "main.h" #include "image.h" @@ -31,6 +31,5 @@ extern int errno_pcx; Image *Read_PCX_to_Image(char *); -#endif /* !USE_SDL_LIBRARY */ - +#endif /* !TARGET_SDL */ #endif /* PCX_H */ diff --git a/src/screens.c b/src/screens.c index 68fa60c6..cb715f42 100644 --- a/src/screens.c +++ b/src/screens.c @@ -86,7 +86,7 @@ void DrawMainMenu() /* needed if last screen was the setup screen and fullscreen state changed */ ChangeVideoModeIfNeeded(); -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SetDrawtoField(DRAW_BACKBUFFER); #endif diff --git a/src/sdl.c b/src/sdl.c index 51f125a7..ddf1137d 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -12,7 +12,7 @@ * sdl.c * ***********************************************************/ -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL #include "main.h" #include "misc.h" @@ -183,4 +183,24 @@ inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y, SDL_MapRGB(surface->format, color_r, color_g, color_b)); } -#endif /* USE_SDL_LIBRARY */ +inline boolean SDLInitAudio(void) +{ + if (SDL_Init(SDL_INIT_AUDIO) < 0) + { + Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError()); + return FALSE; + } + + if (Mix_OpenAudio(22050, AUDIO_S16, 2, 512) < 0) + { + Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError()); + return FALSE; + } + + Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); + Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); + + return TRUE; +} + +#endif /* TARGET_SDL */ diff --git a/src/sdl.h b/src/sdl.h index 0fe26e03..4d48f3d2 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -310,4 +310,6 @@ inline void SDLCopyArea(SDL_Surface *, SDL_Surface *, inline void SDLFillRectangle(SDL_Surface *, int, int, int, int, unsigned int); inline void SDLDrawSimpleLine(SDL_Surface *, int, int, int, int, unsigned int); +inline boolean SDLInitAudio(void); + #endif /* SDL_H */ diff --git a/src/sound.c b/src/sound.c index 1ab2b8c5..d302b0e7 100644 --- a/src/sound.c +++ b/src/sound.c @@ -69,6 +69,32 @@ int OpenAudio(char *audio_device_name) return audio_fd; } +int CheckAudio(char *audio_device_name) +{ + int audio_fd; + + if (access(audio_device_name, W_OK) != 0) + { + Error(ERR_WARN, "cannot access audio device - no sound"); + return SOUND_OFF; + } + + if ((audio_fd = OpenAudio(sound_device_name)) < 0) + { + Error(ERR_WARN, "cannot open audio device - no sound"); + return SOUND_OFF; + } + + close(audio_fd); + + return SOUND_AVAILABLE; +} + +boolean UnixInitAudio(void) +{ + return TRUE; +} + void SoundServer() { int i; @@ -741,7 +767,7 @@ boolean LoadSound(struct SoundInfo *snd_info) { char filename[256]; char *sound_ext = "wav"; -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL #ifndef MSDOS byte sound_header_buffer[WAV_HEADER_SIZE]; char chunk[CHUNK_ID_LEN + 1]; @@ -755,7 +781,7 @@ boolean LoadSound(struct SoundInfo *snd_info) options.ro_base_directory, SOUNDS_DIRECTORY, snd_info->name, sound_ext); -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL snd_info->mix_chunk = Mix_LoadWAV(filename); if (snd_info->mix_chunk == NULL) @@ -764,7 +790,7 @@ boolean LoadSound(struct SoundInfo *snd_info) return FALSE; } -#else /* !USE_SDL_LIBRARY */ +#else /* !TARGET_SDL */ #ifndef MSDOS @@ -832,7 +858,7 @@ boolean LoadSound(struct SoundInfo *snd_info) } #endif /* MSDOS */ -#endif /* !USE_SDL_LIBRARY */ +#endif /* !TARGET_SDL */ return TRUE; } @@ -877,7 +903,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) snd_ctrl.data_ptr = Sound[nr].data_ptr; snd_ctrl.data_len = Sound[nr].data_len; -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); @@ -936,7 +962,7 @@ void StopSoundExt(int nr, int method) snd_ctrl.stop_sound = TRUE; } -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL if (SSND_FADING(method)) { diff --git a/src/sound.h b/src/sound.h index 6eb0dad2..7ebdc65b 100644 --- a/src/sound.h +++ b/src/sound.h @@ -135,7 +135,7 @@ struct SoundInfo SAMPLE *sample_ptr; #endif -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL Mix_Chunk *mix_chunk; #endif }; @@ -159,11 +159,15 @@ struct SoundControl #endif }; -/* start sound server */ +/* general sound functions */ int OpenAudio(char *); +int CheckAudio(char *); +boolean UnixInitAudio(void); + +/* sound server functions */ void SoundServer(void); -/* client functions */ +/* sound client functions */ boolean LoadSound(struct SoundInfo *); void PlaySound(int); void PlaySoundStereo(int, int); diff --git a/src/system.c b/src/system.c index c600152f..08c2eb5d 100644 --- a/src/system.c +++ b/src/system.c @@ -17,7 +17,7 @@ inline void InitEventFilter(EventFilter filter_function) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL /* set event filter to filter out certain events */ SDL_SetEventFilter(filter_function); #endif @@ -25,7 +25,7 @@ inline void InitEventFilter(EventFilter filter_function) inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDLInitBufferedDisplay(backbuffer, window); #else X11InitBufferedDisplay(backbuffer, window); @@ -34,7 +34,7 @@ inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) inline int GetDisplayDepth(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL return SDL_GetVideoSurface()->format->BitsPerPixel; #else return XDefaultDepth(display, screen); @@ -45,7 +45,7 @@ inline Bitmap CreateBitmap(int width, int height, int depth) { int real_depth = (depth == DEFAULT_DEPTH ? GetDisplayDepth() : depth); -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_Surface *surface_tmp, *surface_native; if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, @@ -71,7 +71,7 @@ inline Bitmap CreateBitmap(int width, int height, int depth) inline void FreeBitmap(Bitmap bitmap) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_FreeSurface(bitmap); #else XFreePixmap(display, bitmap); @@ -80,7 +80,7 @@ inline void FreeBitmap(Bitmap bitmap) inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDLFillRectangle(bitmap, x, y, width, height, 0x000000); #else XFillRectangle(display, bitmap, gc, x, y, width, height); @@ -92,7 +92,7 @@ inline void BlitBitmap(Bitmap src_bitmap, Bitmap dst_bitmap, int width, int height, int dst_x, int dst_y) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDLCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height, dst_x, dst_y); #else @@ -101,13 +101,13 @@ inline void BlitBitmap(Bitmap src_bitmap, Bitmap dst_bitmap, #endif } -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL static GC last_clip_gc = 0; /* needed for XCopyArea() through clip mask */ #endif inline void SetClipMask(GC clip_gc, Pixmap clip_pixmap) { -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL XSetClipMask(display, clip_gc, clip_pixmap); last_clip_gc = clip_gc; #endif @@ -115,7 +115,7 @@ inline void SetClipMask(GC clip_gc, Pixmap clip_pixmap) inline void SetClipOrigin(GC clip_gc, int clip_x, int clip_y) { -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL XSetClipOrigin(display, clip_gc, clip_x, clip_y); last_clip_gc = clip_gc; #endif @@ -126,7 +126,7 @@ inline void BlitBitmapMasked(Bitmap src_bitmap, Bitmap dst_bitmap, int width, int height, int dst_x, int dst_y) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDLCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height, dst_x, dst_y); #else @@ -138,7 +138,7 @@ inline void BlitBitmapMasked(Bitmap src_bitmap, Bitmap dst_bitmap, inline void DrawSimpleWhiteLine(Bitmap bitmap, int from_x, int from_y, int to_x, int to_y) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, 0xffffff); #else XSetForeground(display, gc, WhitePixel(display, screen)); @@ -150,7 +150,7 @@ inline void DrawSimpleWhiteLine(Bitmap bitmap, int from_x, int from_y, /* execute all pending screen drawing operations */ inline void FlushDisplay(void) { -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL XFlush(display); #endif } @@ -158,14 +158,14 @@ inline void FlushDisplay(void) /* execute and wait for all pending screen drawing operations */ inline void SyncDisplay(void) { -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL XSync(display, FALSE); #endif } inline void KeyboardAutoRepeatOn(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2, SDL_DEFAULT_REPEAT_INTERVAL / 2); SDL_EnableUNICODE(1); @@ -176,7 +176,7 @@ inline void KeyboardAutoRepeatOn(void) inline void KeyboardAutoRepeatOff(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableUNICODE(0); #else @@ -186,7 +186,7 @@ inline void KeyboardAutoRepeatOff(void) inline boolean PointerInWindow(DrawWindow window) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL return TRUE; #else DrawWindow root, child; @@ -203,7 +203,7 @@ inline boolean PointerInWindow(DrawWindow window) inline boolean PendingEvent(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL return (SDL_PollEvent(NULL) ? TRUE : FALSE); #else return (XPending(display) ? TRUE : FALSE); @@ -212,7 +212,7 @@ inline boolean PendingEvent(void) inline void NextEvent(Event *event) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL SDL_WaitEvent(event); #else XNextEvent(display, event); @@ -221,7 +221,7 @@ inline void NextEvent(Event *event) inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL #if 0 printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n", (int)event->keysym.unicode, @@ -249,7 +249,7 @@ inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) inline boolean SetVideoMode(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL return SDLSetVideoMode(&backbuffer); #else boolean success = TRUE; @@ -270,16 +270,25 @@ inline boolean SetVideoMode(void) inline void ChangeVideoModeIfNeeded(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || (!setup.fullscreen && fullscreen_enabled)) SetVideoMode(); #endif } +inline boolean InitAudio(void) +{ +#ifdef TARGET_SDL + return SDLInitAudio(); +#else + return TRUE; +#endif +} + inline void dummy(void) { -#ifdef USE_SDL_LIBRARY +#ifdef TARGET_SDL #else #endif } diff --git a/src/system.h b/src/system.h index 02bd92cb..1c3b8e20 100644 --- a/src/system.h +++ b/src/system.h @@ -15,13 +15,21 @@ #ifndef SYSTEM_H #define SYSTEM_H +#if defined(MSDOS) +#define PLATFORM_MSDOS +#elif defined(WIN32) +#define PLATFORM_WIN32 +#else +#define PLATFORM_UNIX +#endif + #if defined(MSDOS) #include "msdos.h" #endif -#if defined(USE_SDL_LIBRARY) +#if defined(TARGET_SDL) #include "sdl.h" -#elif defined(USE_X11_LIBRARY) +#elif defined(TARGET_X11) #include "x11.h" #endif @@ -70,4 +78,6 @@ inline Key GetEventKey(KeyEvent *, boolean); inline boolean SetVideoMode(void); inline void ChangeVideoModeIfNeeded(void); +inline boolean InitAudio(void); + #endif /* SYSTEM_H */ diff --git a/src/tools.c b/src/tools.c index 89ad7c74..77f574db 100644 --- a/src/tools.c +++ b/src/tools.c @@ -927,7 +927,7 @@ void DrawGraphicThruMaskExt(DrawBuffer d, int dest_x, int dest_y, int graphic) else { #if DEBUG -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL printf("DrawGraphicThruMask(): tile '%d' needs clipping!\n", tile); #endif #endif @@ -1110,7 +1110,7 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, else { #if DEBUG -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile); #endif #endif @@ -2249,7 +2249,7 @@ void UndrawSpecialEditorDoor() redraw_mask |= REDRAW_ALL; } -#ifndef USE_SDL_LIBRARY +#ifndef TARGET_SDL int ReadPixel(DrawBuffer d, int x, int y) { XImage *pixel_image; diff --git a/src/x11.c b/src/x11.c index 957443a8..34402106 100644 --- a/src/x11.c +++ b/src/x11.c @@ -12,7 +12,7 @@ * x11.c * ***********************************************************/ -#ifdef USE_X11_LIBRARY +#ifdef TARGET_X11 #include "main.h" #include "misc.h" @@ -203,4 +203,4 @@ inline void X11InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) pix[PIX_DB_BACK] = *backbuffer; /* 'backbuffer' is off-screen buffer */ } -#endif /* USE_X11_LIBRARY */ +#endif /* TARGET_X11 */ -- 2.34.1