From 4bca9bc5f299a9b287134b06e41b147f506792b4 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 27 Nov 2000 01:11:01 +0100 Subject: [PATCH] rnd-20001127-1-src --- Makefile | 12 +- src/Makefile | 35 +++-- src/buttons.c | 10 +- src/editor.c | 18 +-- src/events.c | 72 +++++----- src/files.c | 24 ++-- src/files.h | 2 +- src/game.c | 14 +- src/image.c | 71 +++++---- src/image.h | 3 +- src/init.c | 104 +++++++------- src/joystick.c | 16 +-- src/joystick.h | 4 +- src/main.c | 10 +- src/main.h | 24 ++-- src/misc.c | 286 ++++++++++++++++++------------------- src/msdos.c | 6 +- src/msdos.h | 2 + src/netserv.c | 6 +- src/network.c | 6 +- src/platform.h | 25 ++++ src/screens.c | 41 +++--- src/sdl.h | 379 ++++++++++++++++++++++++------------------------- src/sound.c | 86 +++++------ src/sound.h | 11 +- src/system.h | 11 +- src/tape.c | 2 +- src/tools.c | 10 +- src/x11.c | 14 +- src/x11.h | 378 ++++++++++++++++++++++++------------------------ 30 files changed, 860 insertions(+), 822 deletions(-) create mode 100644 src/platform.h diff --git a/Makefile b/Makefile index 2ea6579c..82094534 100644 --- a/Makefile +++ b/Makefile @@ -35,8 +35,9 @@ 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 Win32 build) -CROSS_PATH=/usr/local/cross-tools/i386-mingw32/bin +# specify paths for cross-compiling (only needed for MS-DOS and Win32 build) +CROSS_PATH_MSDOS=/usr/local/cross-msdos/i386-msdosdjgpp +CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc #-----------------------------------------------------------------------------# # you should not need to change anything below # @@ -64,8 +65,11 @@ solaris: msdos: @$(MAKE_CMD) PLATFORM=msdos -win32: - @PATH=$(CROSS_PATH):${PATH} $(MAKE_CMD) PLATFORM=win32 +cross-msdos: + @PATH=$(CROSS_PATH_MSDOS)/bin:${PATH} $(MAKE_CMD) PLATFORM=cross-msdos + +cross-win32: + @PATH=$(CROSS_PATH_WIN32)/bin:${PATH} $(MAKE_CMD) PLATFORM=cross-win32 clean: @$(MAKE_CMD) clean diff --git a/src/Makefile b/src/Makefile index f2b146b7..4dc15309 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,30 +25,45 @@ RM = del PROGNAME = ../rocks.exe SYS_CFLAGS = -DTARGET_X11 -SYS_LDFLAGS = -s -lalleg -lm +SYS_LDFLAGS = -s -lalleg -else # Unix; Win32 cross-compiling +else # Unix or cross-compiling for MS-DOS and Win32 RM = rm -f PROGNAME = ../rocksndiamonds ifeq ($(PLATFORM),solaris) EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH) +PLATFORM = unix +endif + +ifeq ($(PLATFORM),unix) +PROFILING = -pg endif -ifeq ($(PLATFORM),win32) +ifeq ($(PLATFORM),cross-msdos) +PROGNAME = ../rocks.exe +TARGET = allegro +endif + +ifeq ($(PLATFORM),cross-win32) PROGNAME = ../rocksndiamonds.exe TARGET = sdl -else -PROFILING = -pg +endif + +ifeq ($(TARGET),x11) +SYS_CFLAGS = -DTARGET_X11 $(X11_INCL) +SYS_LDFLAGS = $(X11_LIBS) -lX11 endif ifeq ($(TARGET),sdl) SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags) -SYS_LDFLAGS = -lSDL_image -lSDL_mixer $(shell sdl-config --libs) -lm -else -SYS_CFLAGS = -DTARGET_X11 $(X11_INCL) -SYS_LDFLAGS = $(X11_LIBS) -lX11 -lm +SYS_LDFLAGS = -lSDL_image -lSDL_mixer $(shell sdl-config --libs) +endif + +ifeq ($(TARGET),allegro) +SYS_CFLAGS = -DTARGET_X11 -I$(CROSS_PATH_MSDOS)/include +SYS_LDFLAGS = -lalleg endif endif # (PLATFORM != msdos) @@ -80,7 +95,7 @@ OPTIONS = $(DEBUG) -Wall # only for debugging purposes # OPTIONS = -O3 CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG) -LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) +LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm SRCS = main.c \ init.c \ diff --git a/src/buttons.c b/src/buttons.c index c6996e71..88ff994e 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1307,30 +1307,30 @@ void HandleGadgetsKeyInput(Key key) gi->text.cursor_position++; DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - else if (key == KEY_Left && cursor_pos > 0) + else if (key == KSYM_Left && cursor_pos > 0) { gi->text.cursor_position--; DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - else if (key == KEY_Right && cursor_pos < text_length) + else if (key == KSYM_Right && cursor_pos < text_length) { gi->text.cursor_position++; DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - else if (key == KEY_BackSpace && cursor_pos > 0) + else if (key == KSYM_BackSpace && cursor_pos > 0) { strcpy(text, gi->text.value); strcpy(&gi->text.value[cursor_pos - 1], &text[cursor_pos]); gi->text.cursor_position--; DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - else if (key == KEY_Delete && cursor_pos < text_length) + else if (key == KSYM_Delete && cursor_pos < text_length) { strcpy(text, gi->text.value); strcpy(&gi->text.value[cursor_pos], &text[cursor_pos + 1]); DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - else if (key == KEY_Return) + else if (key == KSYM_Return) { CheckRangeOfNumericInputGadget(gi); DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); diff --git a/src/editor.c b/src/editor.c index 3e6f7f26..0977a92a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3984,9 +3984,9 @@ void HandleLevelEditorKeyInput(Key key) { if (letter) DrawLevelText(0, 0, letter, TEXT_WRITECHAR); - else if (key == KEY_Delete || key == KEY_BackSpace) + else if (key == KSYM_Delete || key == KSYM_BackSpace) DrawLevelText(0, 0, 0, TEXT_BACKSPACE); - else if (key == KEY_Return) + else if (key == KSYM_Return) DrawLevelText(0, 0, 0, TEXT_NEWLINE); } else if (button_status == MB_RELEASED) @@ -3995,23 +3995,23 @@ void HandleLevelEditorKeyInput(Key key) switch (key) { - case KEY_Left: + case KSYM_Left: id = GADGET_ID_SCROLL_LEFT; break; - case KEY_Right: + case KSYM_Right: id = GADGET_ID_SCROLL_RIGHT; break; - case KEY_Up: + case KSYM_Up: id = GADGET_ID_SCROLL_UP; break; - case KEY_Down: + case KSYM_Down: id = GADGET_ID_SCROLL_DOWN; break; - case KEY_Page_Up: + case KSYM_Page_Up: id = GADGET_ID_SCROLL_LIST_UP; button = MB_RIGHTBUTTON; break; - case KEY_Page_Down: + case KSYM_Page_Down: id = GADGET_ID_SCROLL_LIST_DOWN; button = MB_RIGHTBUTTON; break; @@ -4025,7 +4025,7 @@ void HandleLevelEditorKeyInput(Key key) ClickOnGadget(level_editor_gadget[id], button); else if (letter == '.') ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button); - else if (key == KEY_space || key == KEY_Return) + else if (key == KSYM_space || key == KSYM_Return) ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button); else for (i=0; idynamite = 1000; break; @@ -704,7 +704,7 @@ void HandleKey(Key key, int key_status) #if 0 - case KEY_z: + case KSYM_z: { int i; @@ -741,7 +741,7 @@ void HandleNoEvent() return; } -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (options.network) HandleNetworking(); #endif diff --git a/src/files.c b/src/files.c index 37210cd7..42f7a993 100644 --- a/src/files.c +++ b/src/files.c @@ -45,7 +45,7 @@ #define TAPE_COOKIE_10 "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0" /* file names and filename extensions */ -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) #define USERDATA_DIRECTORY ".rocksndiamonds" #define LEVELSETUP_DIRECTORY "levelsetup" #define SETUP_FILENAME "setup.conf" @@ -65,11 +65,11 @@ #define SCOREFILE_EXTENSION "sco" #endif -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) #define ERROR_FILENAME "error.out" #endif -#ifdef WIN32 +#if defined(PLATFORM_WIN32) #ifndef S_IRGRP #define S_IRGRP S_IRUSR #endif @@ -88,7 +88,7 @@ #ifndef S_IXOTH #define S_IXOTH S_IXUSR #endif -#endif +#endif /* PLATFORM_WIN32 */ /* file permissions for newly written files */ #define MODE_R_ALL (S_IRUSR | S_IRGRP | S_IROTH) @@ -347,7 +347,7 @@ static char *getScoreFilename(int nr) static void createDirectory(char *dir, char *text) { if (access(dir, F_OK) != 0) -#ifdef WIN32 +#if defined(PLATFORM_WIN32) if (mkdir(dir) != 0) #else if (mkdir(dir, USERDATA_DIR_MODE) != 0) @@ -1543,12 +1543,12 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->input[i].joy.ylower = JOYSTICK_YLOWER; si->input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0); si->input[i].joy.bomb = (i == 0 ? JOY_BUTTON_2 : 0); - si->input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINED); - si->input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KEY_UNDEFINED); - si->input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KEY_UNDEFINED); - si->input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KEY_UNDEFINED); - si->input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KEY_UNDEFINED); - si->input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KEY_UNDEFINED); + si->input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KSYM_UNDEFINED); + si->input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KSYM_UNDEFINED); + si->input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KSYM_UNDEFINED); + si->input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KSYM_UNDEFINED); + si->input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KSYM_UNDEFINED); + si->input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KSYM_UNDEFINED); } } @@ -2216,7 +2216,7 @@ void SaveLevelSetup_SeriesInfo() chmod(filename, SETUP_PERMS); } -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) void initErrorFile() { char *filename; diff --git a/src/files.h b/src/files.h index c87b3309..e920328e 100644 --- a/src/files.h +++ b/src/files.h @@ -33,7 +33,7 @@ void SaveLevelSetup_LastSeries(void); void LoadLevelSetup_SeriesInfo(void); void SaveLevelSetup_SeriesInfo(void); -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) void initErrorFile(); FILE *openErrorFile(); void dumpErrorFile(); diff --git a/src/game.c b/src/game.c index 63bf4b00..70802137 100644 --- a/src/game.c +++ b/src/game.c @@ -505,7 +505,7 @@ void InitGame() network_player_action_received = FALSE; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) /* initial null action */ if (network_playing) SendToServer_MovePlayer(MV_NO_MOVING); @@ -4243,7 +4243,7 @@ void GameActions() #endif */ -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) /* last chance to get network player actions without main loop delay */ HandleNetworking(); #endif @@ -4280,7 +4280,7 @@ void GameActions() stored_player[i].effective_action = stored_player[i].action; } -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (network_playing) SendToServer_MovePlayer(summarized_player_action); #endif @@ -5950,7 +5950,7 @@ void PlaySoundLevel(int x, int y, int sound_nr) volume = PSND_MAX_VOLUME; -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) stereo = (sx - SCR_FIELDX/2) * 12; #else stereo = PSND_MIDDLE + (2 * sx - (SCR_FIELDX - 1)) * 5; @@ -6184,7 +6184,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) Request("Do you really want to quit the game ?", REQ_ASK | REQ_STAY_CLOSED)) { -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (options.network) SendToServer_StopPlaying(); else @@ -6201,7 +6201,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) case GAME_CTRL_ID_PAUSE: if (options.network) { -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (tape.pausing) SendToServer_ContinuePlaying(); else @@ -6215,7 +6215,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) case GAME_CTRL_ID_PLAY: if (tape.pausing) { -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (options.network) SendToServer_ContinuePlaying(); else diff --git a/src/image.c b/src/image.c index 5331a886..9dd4c249 100644 --- a/src/image.c +++ b/src/image.c @@ -11,14 +11,43 @@ * image.c * ***********************************************************/ -#ifndef TARGET_SDL +#if defined(TARGET_X11) #include "image.h" #include "pcx.h" #include "misc.h" -/* exclude all except newImage() and freeImage() */ -#ifndef MSDOS +/* for MS-DOS/Allegro, exclude all except newImage() and freeImage() */ + +Image *newImage(unsigned int width, unsigned int height, unsigned int depth) +{ + Image *image; + const unsigned int bytes_per_pixel = 1; + int i; + + if (depth > 8) + Error(ERR_EXIT, "images with more than 256 colors are not supported"); + + depth = 8; + image = checked_malloc(sizeof(Image)); + image->data = checked_malloc(width * height * bytes_per_pixel); + image->width = width; + image->height = height; + image->depth = depth; + image->rgb.used = 0; + for (i=0; irgb.color_used[i] = FALSE; + + return image; +} + +void freeImage(Image *image) +{ + free(image->data); + free(image); +} + +#if defined(PLATFORM_UNIX) /* extra colors to try allocating in private color maps to minimize flashing */ #define NOFLASH_COLORS 256 @@ -469,38 +498,6 @@ void freeXImage(Image *image, XImageInfo *ximageinfo) free(ximageinfo); } -#endif /* !MSDOS */ - -Image *newImage(unsigned int width, unsigned int height, unsigned int depth) -{ - Image *image; - const unsigned int bytes_per_pixel = 1; - int i; - - if (depth > 8) - Error(ERR_EXIT, "images with more than 256 colors are not supported"); - - depth = 8; - image = checked_malloc(sizeof(Image)); - image->data = checked_malloc(width * height * bytes_per_pixel); - image->width = width; - image->height = height; - image->depth = depth; - image->rgb.used = 0; - for (i=0; irgb.color_used[i] = FALSE; - - return image; -} - -void freeImage(Image *image) -{ - free(image->data); - free(image); -} - -#ifndef MSDOS - int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, Pixmap *pixmap, Pixmap *pixmap_mask) { @@ -553,5 +550,5 @@ int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, return PCX_Success; } -#endif /* !MSDOS */ -#endif /* !TARGET_SDL */ +#endif /* PLATFORM_UNIX */ +#endif /* TARGET_X11 */ diff --git a/src/image.h b/src/image.h index 18f3ec0d..860521c0 100644 --- a/src/image.h +++ b/src/image.h @@ -51,11 +51,10 @@ typedef struct byte *data; /* image data */ } Image; -int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); - Image *newImage(unsigned int, unsigned int, unsigned int); void freeImage(Image *); void freeXImage(Image *, XImageInfo *); +int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); #endif /* !TARGET_SDL */ #endif /* IMAGE_H */ diff --git a/src/init.c b/src/init.c index 411d5407..b95b99c2 100644 --- a/src/init.c +++ b/src/init.c @@ -52,16 +52,16 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) initErrorFile(); #endif if (options.serveronly) { -#ifdef WIN32 - Error(ERR_WARN, "networking not supported in Windows version"); -#else +#if defined(PLATFORM_UNIX) NetworkServer(options.server_port, options.serveronly); +#else + Error(ERR_WARN, "networking not supported in Windows version"); #endif /* never reached */ @@ -121,14 +121,14 @@ void InitLevelInfo() void InitNetworkServer() { -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) int nr_wanted; #endif if (!options.network) return; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); if (!ConnectToServer(options.server_host, options.server_port)) @@ -149,7 +149,7 @@ void InitSound() if (sound_status == SOUND_OFF) return; -#ifdef TARGET_SDL +#if defined(TARGET_SDL) if (InitAudio()) { sound_status = SOUND_AVAILABLE; @@ -161,7 +161,7 @@ void InitSound() } #else /* !TARGET_SDL */ -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if ((sound_status = CheckAudio(sound_device_name)) == SOUND_OFF) return; @@ -169,10 +169,10 @@ void InitSound() sound_loops_allowed = TRUE; #endif -#else /* MSDOS || WIN32 */ +#else /* !PLATFORM_UNIX */ sound_loops_allowed = TRUE; -#endif /* MSDOS || WIN32 */ +#endif /* !PLATFORM_UNIX */ #endif /* !TARGET_SDL */ for(i=0; ipicture_with_mask && !clipmask[pos]) Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename); -#endif /* !TARGET_SDL */ +#endif } void InitGadgets() @@ -1807,7 +1805,7 @@ void CloseAllAndExit(int exit_value) { int i; -#ifdef TARGET_SDL +#if defined(TARGET_SDL) StopSounds(); FreeSounds(NUM_SOUNDS); #else @@ -1824,7 +1822,7 @@ void CloseAllAndExit(int exit_value) if (pix[i]) FreeBitmap(pix[i]); -#ifdef TARGET_SDL +#if defined(TARGET_SDL) FreeBitmap(pix_masked[i]); #else if (clipmask[i]) @@ -1834,7 +1832,7 @@ void CloseAllAndExit(int exit_value) #endif } -#ifdef TARGET_SDL +#if defined(TARGET_SDL) KeyboardAutoRepeatOn(); #else if (gc) @@ -1847,7 +1845,7 @@ void CloseAllAndExit(int exit_value) } #endif -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) dumpErrorFile(); #endif diff --git a/src/joystick.c b/src/joystick.c index 00d497f3..8f6a0d6a 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -18,7 +18,7 @@ #include "joystick.h" #include "misc.h" -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) static int JoystickPosition(int middle, int margin, int actual) { long range, pos; @@ -40,7 +40,7 @@ static int JoystickPosition(int middle, int margin, int actual) } #endif -#ifdef USE_SDL_JOYSTICK +#if defined(TARGET_SDL) static SDL_Joystick *sdl_joystick[MAX_PLAYERS] = { NULL, NULL, NULL, NULL }; static int sdl_js_axis[MAX_PLAYERS][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} }; @@ -205,7 +205,7 @@ int Joystick(int player_nr) return result; } -#else /* !USE_SDL_JOYSTICK */ +#else /* !TARGET_SDL */ void CheckJoystickData() { @@ -231,7 +231,7 @@ void CheckJoystickData() } } -#ifndef MSDOS +#if defined(PLATFORM_UNIX) int Joystick(int player_nr) { #ifdef __FreeBSD__ @@ -304,7 +304,7 @@ int Joystick(int player_nr) return result; } -#else /* MSDOS */ +#else /* PLATFORM_MSDOS */ /* allegro global variables for joystick control */ extern int num_joysticks; @@ -325,7 +325,7 @@ int Joystick(int player_nr) return 0; /* the allegro global variable 'num_joysticks' contains the number - of joysticks found at initialization under MSDOS / Windows */ + of joysticks found at initialization under MS-DOS / Windows */ #if 0 if (joystick_nr >= num_joysticks || !setup.input[player_nr].use_joystick) @@ -361,9 +361,9 @@ int Joystick(int player_nr) return result; } -#endif /* MSDOS */ +#endif /* PLATFORM_MSDOS */ -#endif /* !USE_SDL_JOYSTICK */ +#endif /* !TARGET_SDL */ int JoystickButton(int player_nr) { diff --git a/src/joystick.h b/src/joystick.h index 3632b7a7..735f75c8 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -74,7 +74,7 @@ #endif -#ifdef USE_SDL_JOYSTICK +#if defined(TARGET_SDL) SDL_Joystick *Get_SDL_Joystick(int); boolean Open_SDL_Joystick(int); void Close_SDL_Joystick(int); @@ -89,4 +89,4 @@ int JoystickButton(int); int AnyJoystick(void); int AnyJoystickButton(void); -#endif +#endif /* JOYSTICK_H */ diff --git a/src/main.c b/src/main.c index 33b276bb..b980ea24 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ #include "joystick.h" #include "misc.h" -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) #include #endif @@ -569,7 +569,7 @@ int num_element_info = sizeof(element_info)/sizeof(char *); /* | SDL TEST STUFF | */ /* +-----------------------------------------------------------------------+ */ -#ifdef USE_SDL_JOYSTICK +#if defined(TARGET_SDL) SDL_Surface *sdl_screen, *sdl_image_tmp, *sdl_image, *sdl_image_masked; SDL_Surface *sdl_image2_tmp, *sdl_image2, *sdl_image2_masked; @@ -933,7 +933,7 @@ void TEST_SDL_JOYSTICK() SDL_QuitSubSystem(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK); } -#endif /* USE_SDL_JOYSTICK */ +#endif /* TARGET_SDL */ /* +-----------------------------------------------------------------------+ */ /* | SDL TEST STUFF | */ @@ -945,7 +945,7 @@ int main(int argc, char *argv[]) { program_name = (strrchr(argv[0],'/') ? strrchr(argv[0],'/') + 1 : argv[0]); -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) _fmode = O_BINARY; #endif @@ -955,7 +955,7 @@ int main(int argc, char *argv[]) #endif #if 0 -#ifdef USE_SDL_JOYSTICK +#ifdef TARGET_SDL /* TEST_SDL_BLIT_RECT((WIN_XSIZE - TILEX)/2, (WIN_YSIZE - TILEY)/2); TEST_SDL_EVENT_LOOP(); diff --git a/src/main.h b/src/main.h index d38f529c..016433e1 100644 --- a/src/main.h +++ b/src/main.h @@ -41,13 +41,15 @@ typedef unsigned char byte; #define WIN_XSIZE 672 #define WIN_YSIZE 560 #define WIN_SDL_DEPTH 16 /* !!! change this !!! */ -#ifndef MSDOS + +#if !defined(PLATFORM_MSDOS) #define WIN_XPOS 0 #define WIN_YPOS 0 -#else /* MSDOS */ +#else #define WIN_XPOS ((XRES - WIN_XSIZE) / 2) #define WIN_YPOS ((YRES - WIN_YSIZE) / 2) -#endif /* MSDOS */ +#endif + #define SCR_FIELDX 17 #define SCR_FIELDY 17 #define MAX_BUF_XSIZE (SCR_FIELDX + 2) @@ -1592,14 +1594,14 @@ extern int num_element_info; #define NUM_SOUNDS 62 /* default input keys */ -#define DEFAULT_KEY_LEFT KEY_Left -#define DEFAULT_KEY_RIGHT KEY_Right -#define DEFAULT_KEY_UP KEY_Up -#define DEFAULT_KEY_DOWN KEY_Down -#define DEFAULT_KEY_SNAP KEY_Shift_L -#define DEFAULT_KEY_BOMB KEY_Shift_R -#define DEFAULT_KEY_OKAY KEY_Return -#define DEFAULT_KEY_CANCEL KEY_Escape +#define DEFAULT_KEY_LEFT KSYM_Left +#define DEFAULT_KEY_RIGHT KSYM_Right +#define DEFAULT_KEY_UP KSYM_Up +#define DEFAULT_KEY_DOWN KSYM_Down +#define DEFAULT_KEY_SNAP KSYM_Shift_L +#define DEFAULT_KEY_BOMB KSYM_Shift_R +#define DEFAULT_KEY_OKAY KSYM_Return +#define DEFAULT_KEY_CANCEL KSYM_Escape /* directions for moving */ #define MV_NO_MOVING 0 diff --git a/src/misc.c b/src/misc.c index 3d448a69..a87a9b32 100644 --- a/src/misc.c +++ b/src/misc.c @@ -11,13 +11,15 @@ * misc.c * ***********************************************************/ +#include "platform.h" + #include #include #include #include #include -#ifndef WIN32 +#if !defined(PLATFORM_WIN32) #include #include #endif @@ -30,7 +32,7 @@ #include "joystick.h" #include "files.h" -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) volatile unsigned long counter = 0; void increment_counter() @@ -46,7 +48,6 @@ END_OF_FUNCTION(increment_counter); #define MAX_OPTION_LEN 256 #ifdef TARGET_SDL - static unsigned long mainCounter(int mode) { static unsigned long base_ms = 0; @@ -65,8 +66,8 @@ static unsigned long mainCounter(int mode) } #else /* !TARGET_SDL */ -#ifndef MSDOS +#if defined(PLATFORM_UNIX) static unsigned long mainCounter(int mode) { static struct timeval base_time = { 0, 0 }; @@ -84,13 +85,12 @@ static unsigned long mainCounter(int mode) return counter_ms; /* return milliseconds since last init */ } - -#endif /* !MSDOS */ +#endif /* PLATFORM_UNIX */ #endif /* !TARGET_SDL */ void InitCounter() /* set counter back to zero */ { -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) mainCounter(INIT_COUNTER); #else LOCK_VARIABLE(counter); @@ -101,7 +101,7 @@ void InitCounter() /* set counter back to zero */ unsigned long Counter() /* get milliseconds since last call of InitCounter() */ { -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) return mainCounter(READ_COUNTER); #else return (counter * 10); @@ -112,7 +112,7 @@ static void sleep_milliseconds(unsigned long milliseconds_delay) { boolean do_busy_waiting = (milliseconds_delay < 5 ? TRUE : FALSE); -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) /* don't use select() to perform waiting operations under DOS/Windows environment; always use a busy loop for waiting instead */ do_busy_waiting = TRUE; @@ -133,9 +133,9 @@ static void sleep_milliseconds(unsigned long milliseconds_delay) } else { -#ifdef TARGET_SDL +#if defined(TARGET_SDL) SDL_Delay(milliseconds_delay); -#else /* !TARGET_SDL */ +#else 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 /* !TARGET_SDL */ +#endif } } @@ -228,25 +228,21 @@ char *int2str(int number, int size) unsigned int SimpleRND(unsigned int max) { -#ifdef TARGET_SDL - +#if defined(TARGET_SDL) static unsigned long root = 654321; unsigned long current_ms; current_ms = SDL_GetTicks(); root = root * 4253261 + current_ms; return (root % max); - -#else /* !TARGET_SDL */ - +#else static unsigned long root = 654321; struct timeval current_time; gettimeofday(¤t_time, NULL); root = root * 4253261 + current_time.tv_sec + current_time.tv_usec; return (root % max); - -#endif /* !TARGET_SDL */ +#endif } #ifdef DEBUG @@ -269,7 +265,7 @@ unsigned int RND(unsigned int max) unsigned int InitRND(long seed) { -#ifdef TARGET_SDL +#if defined(TARGET_SDL) unsigned long current_ms; if (seed == NEW_RANDOMIZE) @@ -283,7 +279,7 @@ unsigned int InitRND(long seed) srandom_linux_libc((unsigned int) seed); return (unsigned int) seed; } -#else /* !TARGET_SDL */ +#else struct timeval current_time; if (seed == NEW_RANDOMIZE) @@ -297,12 +293,12 @@ unsigned int InitRND(long seed) srandom_linux_libc((unsigned int) seed); return (unsigned int) seed; } -#endif /* !TARGET_SDL */ +#endif } char *getLoginName() { -#ifdef WIN32 +#if defined(PLATFORM_WIN32) return ANONYMOUS_NAME; #else struct passwd *pwd; @@ -316,9 +312,7 @@ char *getLoginName() char *getRealName() { -#if defined(MSDOS) || defined(WIN32) - return ANONYMOUS_NAME; -#else +#if defined(PLATFORM_UNIX) struct passwd *pwd; if ((pwd = getpwuid(getuid())) == NULL || strlen(pwd->pw_gecos) == 0) @@ -348,14 +342,14 @@ char *getRealName() return real_name; } +#else /* !PLATFORM_UNIX */ + return ANONYMOUS_NAME; #endif } char *getHomeDir() { -#if defined(MSDOS) || defined(WIN32) - return "."; -#else +#if defined(PLATFORM_UNIX) static char *home_dir = NULL; if (!home_dir) @@ -372,6 +366,8 @@ char *getHomeDir() } return home_dir; +#else + return "."; #endif } @@ -597,7 +593,7 @@ void Error(int mode, char *format, ...) if (mode & ERR_WARN && !options.verbose) return; -#if defined(MSDOS) || defined(WIN32) +#if !defined(PLATFORM_UNIX) if ((error = openErrorFile()) == NULL) { printf("Cannot write to error output file!\n"); @@ -749,9 +745,9 @@ void putFileChunk(FILE *file, char *chunk_name, int chunk_length, putFile32BitInteger(file, chunk_length, byte_order); } -#define TRANSLATE_KEY_TO_KEYNAME 0 -#define TRANSLATE_KEY_TO_X11KEYNAME 1 -#define TRANSLATE_X11KEYNAME_TO_KEY 2 +#define TRANSLATE_KEYSYM_TO_KEYNAME 0 +#define TRANSLATE_KEYSYM_TO_X11KEYNAME 1 +#define TRANSLATE_X11KEYNAME_TO_KEYSYM 2 void translate_keyname(Key *keysym, char **x11name, char **name, int mode) { @@ -763,100 +759,100 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) } translate_key[] = { /* normal cursor keys */ - { KEY_Left, "XK_Left", "cursor left" }, - { KEY_Right, "XK_Right", "cursor right" }, - { KEY_Up, "XK_Up", "cursor up" }, - { KEY_Down, "XK_Down", "cursor down" }, + { KSYM_Left, "XK_Left", "cursor left" }, + { KSYM_Right, "XK_Right", "cursor right" }, + { KSYM_Up, "XK_Up", "cursor up" }, + { KSYM_Down, "XK_Down", "cursor down" }, /* keypad cursor keys */ -#ifdef KEY_KP_Left - { KEY_KP_Left, "XK_KP_Left", "keypad left" }, - { KEY_KP_Right, "XK_KP_Right", "keypad right" }, - { KEY_KP_Up, "XK_KP_Up", "keypad up" }, - { KEY_KP_Down, "XK_KP_Down", "keypad down" }, +#ifdef KSYM_KP_Left + { KSYM_KP_Left, "XK_KP_Left", "keypad left" }, + { KSYM_KP_Right, "XK_KP_Right", "keypad right" }, + { KSYM_KP_Up, "XK_KP_Up", "keypad up" }, + { KSYM_KP_Down, "XK_KP_Down", "keypad down" }, #endif /* other keypad keys */ -#ifdef KEY_KP_Enter - { KEY_KP_Enter, "XK_KP_Enter", "keypad enter" }, - { KEY_KP_Add, "XK_KP_Add", "keypad +" }, - { KEY_KP_Subtract, "XK_KP_Subtract", "keypad -" }, - { KEY_KP_Multiply, "XK_KP_Multiply", "keypad mltply" }, - { KEY_KP_Divide, "XK_KP_Divide", "keypad /" }, - { KEY_KP_Separator, "XK_KP_Separator", "keypad ," }, +#ifdef KSYM_KP_Enter + { KSYM_KP_Enter, "XK_KP_Enter", "keypad enter" }, + { KSYM_KP_Add, "XK_KP_Add", "keypad +" }, + { KSYM_KP_Subtract, "XK_KP_Subtract", "keypad -" }, + { KSYM_KP_Multiply, "XK_KP_Multiply", "keypad mltply" }, + { KSYM_KP_Divide, "XK_KP_Divide", "keypad /" }, + { KSYM_KP_Separator,"XK_KP_Separator", "keypad ," }, #endif /* modifier keys */ - { KEY_Shift_L, "XK_Shift_L", "left shift" }, - { KEY_Shift_R, "XK_Shift_R", "right shift" }, - { KEY_Control_L, "XK_Control_L", "left control" }, - { KEY_Control_R, "XK_Control_R", "right control" }, - { KEY_Meta_L, "XK_Meta_L", "left meta" }, - { KEY_Meta_R, "XK_Meta_R", "right meta" }, - { KEY_Alt_L, "XK_Alt_L", "left alt" }, - { KEY_Alt_R, "XK_Alt_R", "right alt" }, - { KEY_Super_L, "XK_Super_L", "left super" }, /* Win-L */ - { KEY_Super_R, "XK_Super_R", "right super" }, /* Win-R */ - { KEY_Mode_switch, "XK_Mode_switch", "mode switch" }, /* Alt-R */ - { KEY_Multi_key, "XK_Multi_key", "multi key" }, /* Ctrl-R */ + { KSYM_Shift_L, "XK_Shift_L", "left shift" }, + { KSYM_Shift_R, "XK_Shift_R", "right shift" }, + { KSYM_Control_L, "XK_Control_L", "left control" }, + { KSYM_Control_R, "XK_Control_R", "right control" }, + { KSYM_Meta_L, "XK_Meta_L", "left meta" }, + { KSYM_Meta_R, "XK_Meta_R", "right meta" }, + { KSYM_Alt_L, "XK_Alt_L", "left alt" }, + { KSYM_Alt_R, "XK_Alt_R", "right alt" }, + { KSYM_Super_L, "XK_Super_L", "left super" }, /* Win-L */ + { KSYM_Super_R, "XK_Super_R", "right super" }, /* Win-R */ + { KSYM_Mode_switch, "XK_Mode_switch", "mode switch" }, /* Alt-R */ + { KSYM_Multi_key, "XK_Multi_key", "multi key" }, /* Ctrl-R */ /* some special keys */ - { KEY_BackSpace, "XK_BackSpace", "backspace" }, - { KEY_Delete, "XK_Delete", "delete" }, - { KEY_Insert, "XK_Insert", "insert" }, - { KEY_Tab, "XK_Tab", "tab" }, - { KEY_Home, "XK_Home", "home" }, - { KEY_End, "XK_End", "end" }, - { KEY_Page_Up, "XK_Page_Up", "page up" }, - { KEY_Page_Down, "XK_Page_Down", "page down" }, - { KEY_Menu, "XK_Menu", "menu" }, /* Win-Menu */ + { KSYM_BackSpace, "XK_BackSpace", "backspace" }, + { KSYM_Delete, "XK_Delete", "delete" }, + { KSYM_Insert, "XK_Insert", "insert" }, + { KSYM_Tab, "XK_Tab", "tab" }, + { KSYM_Home, "XK_Home", "home" }, + { KSYM_End, "XK_End", "end" }, + { KSYM_Page_Up, "XK_Page_Up", "page up" }, + { KSYM_Page_Down, "XK_Page_Down", "page down" }, + { KSYM_Menu, "XK_Menu", "menu" }, /* Win-Menu */ /* ASCII 0x20 to 0x40 keys (except numbers) */ - { KEY_space, "XK_space", "space" }, - { KEY_exclam, "XK_exclam", "!" }, - { KEY_quotedbl, "XK_quotedbl", "\"" }, - { KEY_numbersign, "XK_numbersign", "#" }, - { KEY_dollar, "XK_dollar", "$" }, - { KEY_percent, "XK_percent", "%" }, - { KEY_ampersand, "XK_ampersand", "&" }, - { KEY_apostrophe, "XK_apostrophe", "'" }, - { KEY_parenleft, "XK_parenleft", "(" }, - { KEY_parenright, "XK_parenright", ")" }, - { KEY_asterisk, "XK_asterisk", "*" }, - { KEY_plus, "XK_plus", "+" }, - { KEY_comma, "XK_comma", "," }, - { KEY_minus, "XK_minus", "-" }, - { KEY_period, "XK_period", "." }, - { KEY_slash, "XK_slash", "/" }, - { KEY_colon, "XK_colon", ":" }, - { KEY_semicolon, "XK_semicolon", ";" }, - { KEY_less, "XK_less", "<" }, - { KEY_equal, "XK_equal", "=" }, - { KEY_greater, "XK_greater", ">" }, - { KEY_question, "XK_question", "?" }, - { KEY_at, "XK_at", "@" }, + { KSYM_space, "XK_space", "space" }, + { KSYM_exclam, "XK_exclam", "!" }, + { KSYM_quotedbl, "XK_quotedbl", "\"" }, + { KSYM_numbersign, "XK_numbersign", "#" }, + { KSYM_dollar, "XK_dollar", "$" }, + { KSYM_percent, "XK_percent", "%" }, + { KSYM_ampersand, "XK_ampersand", "&" }, + { KSYM_apostrophe, "XK_apostrophe", "'" }, + { KSYM_parenleft, "XK_parenleft", "(" }, + { KSYM_parenright, "XK_parenright", ")" }, + { KSYM_asterisk, "XK_asterisk", "*" }, + { KSYM_plus, "XK_plus", "+" }, + { KSYM_comma, "XK_comma", "," }, + { KSYM_minus, "XK_minus", "-" }, + { KSYM_period, "XK_period", "." }, + { KSYM_slash, "XK_slash", "/" }, + { KSYM_colon, "XK_colon", ":" }, + { KSYM_semicolon, "XK_semicolon", ";" }, + { KSYM_less, "XK_less", "<" }, + { KSYM_equal, "XK_equal", "=" }, + { KSYM_greater, "XK_greater", ">" }, + { KSYM_question, "XK_question", "?" }, + { KSYM_at, "XK_at", "@" }, /* more ASCII keys */ - { KEY_bracketleft, "XK_bracketleft", "[" }, - { KEY_backslash, "XK_backslash", "backslash" }, - { KEY_bracketright, "XK_bracketright", "]" }, - { KEY_asciicircum, "XK_asciicircum", "circumflex" }, - { KEY_underscore, "XK_underscore", "_" }, - { KEY_grave, "XK_grave", "grave" }, - { KEY_quoteleft, "XK_quoteleft", "quote left" }, - { KEY_braceleft, "XK_braceleft", "brace left" }, - { KEY_bar, "XK_bar", "bar" }, - { KEY_braceright, "XK_braceright", "brace right" }, - { KEY_asciitilde, "XK_asciitilde", "ascii tilde" }, + { KSYM_bracketleft, "XK_bracketleft", "[" }, + { KSYM_backslash, "XK_backslash", "backslash" }, + { KSYM_bracketright,"XK_bracketright", "]" }, + { KSYM_asciicircum, "XK_asciicircum", "circumflex" }, + { KSYM_underscore, "XK_underscore", "_" }, + { KSYM_grave, "XK_grave", "grave" }, + { KSYM_quoteleft, "XK_quoteleft", "quote left" }, + { KSYM_braceleft, "XK_braceleft", "brace left" }, + { KSYM_bar, "XK_bar", "bar" }, + { KSYM_braceright, "XK_braceright", "brace right" }, + { KSYM_asciitilde, "XK_asciitilde", "ascii tilde" }, /* special (non-ASCII) keys */ - { KEY_Adiaeresis, "XK_Adiaeresis", "Ä" }, - { KEY_Odiaeresis, "XK_Odiaeresis", "Ö" }, - { KEY_Udiaeresis, "XK_Udiaeresis", "Ü" }, - { KEY_adiaeresis, "XK_adiaeresis", "ä" }, - { KEY_odiaeresis, "XK_odiaeresis", "ö" }, - { KEY_udiaeresis, "XK_udiaeresis", "ü" }, - { KEY_ssharp, "XK_ssharp", "sharp s" }, + { KSYM_Adiaeresis, "XK_Adiaeresis", "Ä" }, + { KSYM_Odiaeresis, "XK_Odiaeresis", "Ö" }, + { KSYM_Udiaeresis, "XK_Udiaeresis", "Ü" }, + { KSYM_adiaeresis, "XK_adiaeresis", "ä" }, + { KSYM_odiaeresis, "XK_odiaeresis", "ö" }, + { KSYM_udiaeresis, "XK_udiaeresis", "ü" }, + { KSYM_ssharp, "XK_ssharp", "sharp s" }, /* end-of-array identifier */ { 0, NULL, NULL } @@ -864,22 +860,22 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) int i; - if (mode == TRANSLATE_KEY_TO_KEYNAME) + if (mode == TRANSLATE_KEYSYM_TO_KEYNAME) { static char name_buffer[30]; Key key = *keysym; - if (key >= KEY_A && key <= KEY_Z) - sprintf(name_buffer, "%c", 'A' + (char)(key - KEY_A)); - else if (key >= KEY_a && key <= KEY_z) - sprintf(name_buffer, "%c", 'a' + (char)(key - KEY_a)); - else if (key >= KEY_0 && key <= KEY_9) - sprintf(name_buffer, "%c", '0' + (char)(key - KEY_0)); - else if (key >= KEY_KP_0 && key <= KEY_KP_9) - sprintf(name_buffer, "keypad %c", '0' + (char)(key - KEY_KP_0)); - else if (key >= KEY_F1 && key <= KEY_F24) - sprintf(name_buffer, "function F%d", (int)(key - KEY_F1 + 1)); - else if (key == KEY_UNDEFINED) + if (key >= KSYM_A && key <= KSYM_Z) + sprintf(name_buffer, "%c", 'A' + (char)(key - KSYM_A)); + else if (key >= KSYM_a && key <= KSYM_z) + sprintf(name_buffer, "%c", 'a' + (char)(key - KSYM_a)); + else if (key >= KSYM_0 && key <= KSYM_9) + sprintf(name_buffer, "%c", '0' + (char)(key - KSYM_0)); + else if (key >= KSYM_KP_0 && key <= KSYM_KP_9) + sprintf(name_buffer, "keypad %c", '0' + (char)(key - KSYM_KP_0)); + else if (key >= KSYM_F1 && key <= KSYM_F24) + sprintf(name_buffer, "function F%d", (int)(key - KSYM_F1 + 1)); + else if (key == KSYM_UNDEFINED) strcpy(name_buffer, "(undefined)"); else { @@ -901,22 +897,22 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) *name = name_buffer; } - else if (mode == TRANSLATE_KEY_TO_X11KEYNAME) + else if (mode == TRANSLATE_KEYSYM_TO_X11KEYNAME) { static char name_buffer[30]; Key key = *keysym; - if (key >= KEY_A && key <= KEY_Z) - sprintf(name_buffer, "XK_%c", 'A' + (char)(key - KEY_A)); - else if (key >= KEY_a && key <= KEY_z) - sprintf(name_buffer, "XK_%c", 'a' + (char)(key - KEY_a)); - else if (key >= KEY_0 && key <= KEY_9) - sprintf(name_buffer, "XK_%c", '0' + (char)(key - KEY_0)); - else if (key >= KEY_KP_0 && key <= KEY_KP_9) - sprintf(name_buffer, "XK_KP_%c", '0' + (char)(key - KEY_KP_0)); - else if (key >= KEY_F1 && key <= KEY_F24) - sprintf(name_buffer, "XK_F%d", (int)(key - KEY_F1 + 1)); - else if (key == KEY_UNDEFINED) + if (key >= KSYM_A && key <= KSYM_Z) + sprintf(name_buffer, "XK_%c", 'A' + (char)(key - KSYM_A)); + else if (key >= KSYM_a && key <= KSYM_z) + sprintf(name_buffer, "XK_%c", 'a' + (char)(key - KSYM_a)); + else if (key >= KSYM_0 && key <= KSYM_9) + sprintf(name_buffer, "XK_%c", '0' + (char)(key - KSYM_0)); + else if (key >= KSYM_KP_0 && key <= KSYM_KP_9) + sprintf(name_buffer, "XK_KP_%c", '0' + (char)(key - KSYM_KP_0)); + else if (key >= KSYM_F1 && key <= KSYM_F24) + sprintf(name_buffer, "XK_F%d", (int)(key - KSYM_F1 + 1)); + else if (key == KSYM_UNDEFINED) strcpy(name_buffer, "[undefined]"); else { @@ -938,9 +934,9 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) *x11name = name_buffer; } - else if (mode == TRANSLATE_X11KEYNAME_TO_KEY) + else if (mode == TRANSLATE_X11KEYNAME_TO_KEYSYM) { - Key key = KEY_UNDEFINED; + Key key = KSYM_UNDEFINED; char *name_ptr = *x11name; if (strncmp(name_ptr, "XK_", 3) == 0 && strlen(name_ptr) == 4) @@ -948,18 +944,18 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) char c = name_ptr[3]; if (c >= 'A' && c <= 'Z') - key = KEY_A + (Key)(c - 'A'); + key = KSYM_A + (Key)(c - 'A'); else if (c >= 'a' && c <= 'z') - key = KEY_a + (Key)(c - 'a'); + key = KSYM_a + (Key)(c - 'a'); else if (c >= '0' && c <= '9') - key = KEY_0 + (Key)(c - '0'); + key = KSYM_0 + (Key)(c - '0'); } else if (strncmp(name_ptr, "XK_KP_", 6) == 0 && strlen(name_ptr) == 7) { char c = name_ptr[6]; if (c >= '0' && c <= '9') - key = KEY_0 + (Key)(c - '0'); + key = KSYM_0 + (Key)(c - '0'); } else if (strncmp(name_ptr, "XK_F", 4) == 0 && strlen(name_ptr) <= 6) { @@ -972,7 +968,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) d = atoi(&name_ptr[4]); if (d >=1 && d <= 24) - key = KEY_F1 + (Key)(d - 1); + key = KSYM_F1 + (Key)(d - 1); } else if (strncmp(name_ptr, "XK_", 3) == 0) { @@ -1027,7 +1023,7 @@ char *getKeyNameFromKey(Key key) { char *name; - translate_keyname(&key, NULL, &name, TRANSLATE_KEY_TO_KEYNAME); + translate_keyname(&key, NULL, &name, TRANSLATE_KEYSYM_TO_KEYNAME); return name; } @@ -1035,7 +1031,7 @@ char *getX11KeyNameFromKey(Key key) { char *x11name; - translate_keyname(&key, &x11name, NULL, TRANSLATE_KEY_TO_X11KEYNAME); + translate_keyname(&key, &x11name, NULL, TRANSLATE_KEYSYM_TO_X11KEYNAME); return x11name; } @@ -1043,7 +1039,7 @@ Key getKeyFromX11KeyName(char *x11name) { Key key; - translate_keyname(&key, &x11name, NULL, TRANSLATE_X11KEYNAME_TO_KEY); + translate_keyname(&key, &x11name, NULL, TRANSLATE_X11KEYNAME_TO_KEYSYM); return key; } diff --git a/src/msdos.c b/src/msdos.c index b0d9d2cb..089d1a9d 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -12,7 +12,9 @@ * msdos.c * ***********************************************************/ -#ifdef MSDOS +#include "platform.h" + +#if defined(PLATFORM_MSDOS) #include "main.h" #include "misc.h" @@ -917,4 +919,4 @@ void NetworkServer(int port, int serveronly) Error(ERR_WARN, "networking not supported in DOS version"); } -#endif /* MSDOS */ +#endif /* PLATFORM_MSDOS */ diff --git a/src/msdos.h b/src/msdos.h index 9e93109d..2a16bb6d 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -18,6 +18,8 @@ #include #include +/* symbol 'window' is defined in DJGPP cross-compiler in libc.a(conio.o) */ +#define window window_djgpp /* system dependent definitions */ diff --git a/src/netserv.c b/src/netserv.c index 10b0ab50..2e356e92 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -11,7 +11,9 @@ * network.c * ***********************************************************/ -#if !defined(MSDOS) && !defined(WIN32) +#include "platform.h" + +#if defined(PLATFORM_UNIX) #include #include @@ -661,4 +663,4 @@ void NetworkServer(int port, int serveronly) } } -#endif /* !MSDOS && !WIN32 */ +#endif /* PLATFORM_UNIX */ diff --git a/src/network.c b/src/network.c index 88c55521..e3a07c64 100644 --- a/src/network.c +++ b/src/network.c @@ -11,7 +11,9 @@ * network.c * ***********************************************************/ -#if !defined(MSDOS) && !defined(WIN32) +#include "platform.h" + +#if defined(PLATFORM_UNIX) #include #include @@ -615,4 +617,4 @@ void HandleNetworking() } } -#endif /* !MSDOS && !WIN32 */ +#endif /* PLATFORM_UNIX */ diff --git a/src/platform.h b/src/platform.h new file mode 100644 index 00000000..903f1165 --- /dev/null +++ b/src/platform.h @@ -0,0 +1,25 @@ +/*********************************************************** +* 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 * +*----------------------------------------------------------* +* platform.h * +***********************************************************/ + +#ifndef PLATFORM_H +#define PLATFORM_H + +#if defined(MSDOS) +#define PLATFORM_MSDOS +#elif defined(WIN32) +#define PLATFORM_WIN32 +#else +#define PLATFORM_UNIX +#endif + +#endif /* PLATFORM_H */ diff --git a/src/screens.c b/src/screens.c index cb715f42..1723c602 100644 --- a/src/screens.c +++ b/src/screens.c @@ -333,7 +333,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (setup.autorecord) TapeStartRecording(); -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (options.network) SendToServer_StartPlaying(); else @@ -828,15 +828,16 @@ void HandleTypeName(int newxpos, Key key) return; } - if (((key >= KEY_A && key <= KEY_Z) || (key >= KEY_a && key <= KEY_z)) && + if (((key >= KSYM_A && key <= KSYM_Z) || + (key >= KSYM_a && key <= KSYM_z)) && xpos < MAX_PLAYER_NAME_LEN) { char ascii; - if (key >= KEY_A && key <= KEY_Z) - ascii = 'A' + (char)(key - KEY_A); + if (key >= KSYM_A && key <= KSYM_Z) + ascii = 'A' + (char)(key - KSYM_A); else - ascii = 'a' + (char)(key - KEY_a); + ascii = 'a' + (char)(key - KSYM_a); setup.player_name[xpos] = ascii; setup.player_name[xpos + 1] = 0; @@ -847,14 +848,14 @@ void HandleTypeName(int newxpos, Key key) setup.player_name, FS_BIG, FC_YELLOW); DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); } - else if ((key == KEY_Delete || key == KEY_BackSpace) && xpos > 0) + else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0) { xpos--; setup.player_name[xpos] = 0; DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM); } - else if (key == KEY_Return && xpos > 0) + else if (key == KSYM_Return && xpos > 0) { DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED); DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM); @@ -1042,7 +1043,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) else x = y = 0; /* no action */ - if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ { dy = SIGN(dy); step = num_page_entries - 1; @@ -1230,7 +1231,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) return; } - if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ step = MAX_LEVEL_SERIES_ON_SCREEN - 1; if (dy < 0) @@ -1563,7 +1564,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) SaveJoystickData(); */ -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) save_joystick_data(JOYSTICK_FILENAME); #endif @@ -1917,7 +1918,7 @@ void CustomizeKeyboard(int player_nr) { Key key = GetEventKey((KeyEvent *)&event, TRUE); - if (key == KEY_Escape || (key == KEY_Return && step_nr == 6)) + if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6)) { finished = TRUE; break; @@ -1928,7 +1929,7 @@ void CustomizeKeyboard(int player_nr) break; /* press 'Enter' to keep the existing key binding */ - if (key == KEY_Return) + if (key == KSYM_Return) key = *customize_step[step_nr].key; /* check if key already used */ @@ -2008,7 +2009,7 @@ void CalibrateJoystick(int player_nr) } joy_ctrl; #endif -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) int new_joystick_xleft = 128, new_joystick_xright = 128; int new_joystick_yupper = 128, new_joystick_ylower = 128; int new_joystick_xmiddle, new_joystick_ymiddle; @@ -2030,7 +2031,7 @@ void CalibrateJoystick(int player_nr) ClearWindow(); -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW); DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW); DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW); @@ -2085,12 +2086,12 @@ void CalibrateJoystick(int player_nr) case EVENT_KEYPRESS: switch(GetEventKey((KeyEvent *)&event, TRUE)) { - case KEY_Return: + case KSYM_Return: if (check_remaining == 0) result = 1; break; - case KEY_Escape: + case KSYM_Escape: result = 0; break; @@ -2109,9 +2110,9 @@ void CalibrateJoystick(int player_nr) } } -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) -#ifdef USE_SDL_JOYSTICK +#if defined(TARGET_SDL) joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0); joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1); #else @@ -2148,7 +2149,7 @@ void CalibrateJoystick(int player_nr) { result = 1; -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) if (calibration_step == 1) { remove_joystick(); @@ -2189,7 +2190,7 @@ void CalibrateJoystick(int player_nr) if (x != last_x || y != last_y) { -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB); #else DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU); diff --git a/src/sdl.h b/src/sdl.h index 68007d76..bfe4b4ad 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -16,15 +16,8 @@ #define SDL_H #include "SDL.h" - -#if SDL_MAJOR_VERSION >= 1 && SDL_MINOR_VERSION >= 1 #include "SDL_image.h" #include "SDL_mixer.h" -#define USE_SDL_JOYSTICK -#else -#include "IMG.h" -#include "mixer.h" -#endif /* definitions needed for "system.c" */ @@ -77,98 +70,98 @@ typedef int Colormap; #define EVENT_MAPNOTIFY SDL_USEREVENT + 4 #define EVENT_UNMAPNOTIFY SDL_USEREVENT + 5 -#define KEY_UNDEFINED SDLK_UNKNOWN +#define KSYM_UNDEFINED SDLK_UNKNOWN -#define KEY_Return SDLK_RETURN -#define KEY_Escape SDLK_ESCAPE +#define KSYM_Return SDLK_RETURN +#define KSYM_Escape SDLK_ESCAPE -#define KEY_Left SDLK_LEFT -#define KEY_Right SDLK_RIGHT -#define KEY_Up SDLK_UP -#define KEY_Down SDLK_DOWN +#define KSYM_Left SDLK_LEFT +#define KSYM_Right SDLK_RIGHT +#define KSYM_Up SDLK_UP +#define KSYM_Down SDLK_DOWN #ifdef SDLK_KP_LEFT -#define KEY_KP_Left SDLK_KP_LEFT -#define KEY_KP_Right SDLK_KP_RIGHT -#define KEY_KP_Up SDLK_KP_UP -#define KEY_KP_Down SDLK_KP_DOWN +#define KSYM_KP_Left SDLK_KP_LEFT +#define KSYM_KP_Right SDLK_KP_RIGHT +#define KSYM_KP_Up SDLK_KP_UP +#define KSYM_KP_Down SDLK_KP_DOWN #endif -#define KEY_KP_Enter SDLK_KP_ENTER -#define KEY_KP_Add SDLK_KP_PLUS -#define KEY_KP_Subtract SDLK_KP_MINUS -#define KEY_KP_Multiply SDLK_KP_MULTIPLY -#define KEY_KP_Divide SDLK_KP_DIVIDE -#define KEY_KP_Separator SDLK_KP_PERIOD - -#define KEY_Shift_L SDLK_LSHIFT -#define KEY_Shift_R SDLK_RSHIFT -#define KEY_Control_L SDLK_LCTRL -#define KEY_Control_R SDLK_RCTRL -#define KEY_Meta_L SDLK_LMETA -#define KEY_Meta_R SDLK_RMETA -#define KEY_Alt_L SDLK_LALT -#define KEY_Alt_R SDLK_RALT -#define KEY_Super_L SDLK_LSUPER -#define KEY_Super_R SDLK_RSUPER -#define KEY_Mode_switch SDLK_MODE -#define KEY_Multi_key SDLK_RCTRL - -#define KEY_BackSpace SDLK_BACKSPACE -#define KEY_Delete SDLK_DELETE -#define KEY_Insert SDLK_INSERT -#define KEY_Tab SDLK_TAB -#define KEY_Home SDLK_HOME -#define KEY_End SDLK_END -#define KEY_Page_Up SDLK_PAGEUP -#define KEY_Page_Down SDLK_PAGEDOWN -#define KEY_Menu SDLK_MENU - -#define KEY_space SDLK_SPACE -#define KEY_exclam SDLK_EXCLAIM -#define KEY_quotedbl SDLK_QUOTEDBL -#define KEY_numbersign SDLK_HASH -#define KEY_dollar SDLK_DOLLAR -#define KEY_percent KEY_UNDEFINED /* undefined */ -#define KEY_ampersand SDLK_AMPERSAND -#define KEY_apostrophe SDLK_QUOTE -#define KEY_parenleft SDLK_LEFTPAREN -#define KEY_parenright SDLK_RIGHTPAREN -#define KEY_asterisk SDLK_ASTERISK -#define KEY_plus SDLK_PLUS -#define KEY_comma SDLK_COMMA -#define KEY_minus SDLK_MINUS -#define KEY_period SDLK_PERIOD -#define KEY_slash SDLK_SLASH - -#define KEY_colon SDLK_COLON -#define KEY_semicolon SDLK_SEMICOLON -#define KEY_less SDLK_LESS -#define KEY_equal SDLK_EQUALS -#define KEY_greater SDLK_GREATER -#define KEY_question SDLK_QUESTION -#define KEY_at SDLK_AT - -#define KEY_bracketleft SDLK_LEFTBRACKET -#define KEY_backslash SDLK_BACKSLASH -#define KEY_bracketright SDLK_RIGHTBRACKET -#define KEY_asciicircum SDLK_CARET -#define KEY_underscore SDLK_UNDERSCORE -#define KEY_grave SDLK_BACKQUOTE - -#define KEY_quoteleft KEY_UNDEFINED /* undefined */ -#define KEY_braceleft KEY_UNDEFINED /* undefined */ -#define KEY_bar KEY_UNDEFINED /* undefined */ -#define KEY_braceright KEY_UNDEFINED /* undefined */ -#define KEY_asciitilde KEY_UNDEFINED /* undefined */ - -#define KEY_Adiaeresis SDLK_WORLD_36 -#define KEY_Odiaeresis SDLK_WORLD_54 -#define KEY_Udiaeresis SDLK_WORLD_60 -#define KEY_adiaeresis SDLK_WORLD_68 -#define KEY_odiaeresis SDLK_WORLD_86 -#define KEY_udiaeresis SDLK_WORLD_92 -#define KEY_ssharp SDLK_WORLD_63 +#define KSYM_KP_Enter SDLK_KP_ENTER +#define KSYM_KP_Add SDLK_KP_PLUS +#define KSYM_KP_Subtract SDLK_KP_MINUS +#define KSYM_KP_Multiply SDLK_KP_MULTIPLY +#define KSYM_KP_Divide SDLK_KP_DIVIDE +#define KSYM_KP_Separator SDLK_KP_PERIOD + +#define KSYM_Shift_L SDLK_LSHIFT +#define KSYM_Shift_R SDLK_RSHIFT +#define KSYM_Control_L SDLK_LCTRL +#define KSYM_Control_R SDLK_RCTRL +#define KSYM_Meta_L SDLK_LMETA +#define KSYM_Meta_R SDLK_RMETA +#define KSYM_Alt_L SDLK_LALT +#define KSYM_Alt_R SDLK_RALT +#define KSYM_Super_L SDLK_LSUPER +#define KSYM_Super_R SDLK_RSUPER +#define KSYM_Mode_switch SDLK_MODE +#define KSYM_Multi_key SDLK_RCTRL + +#define KSYM_BackSpace SDLK_BACKSPACE +#define KSYM_Delete SDLK_DELETE +#define KSYM_Insert SDLK_INSERT +#define KSYM_Tab SDLK_TAB +#define KSYM_Home SDLK_HOME +#define KSYM_End SDLK_END +#define KSYM_Page_Up SDLK_PAGEUP +#define KSYM_Page_Down SDLK_PAGEDOWN +#define KSYM_Menu SDLK_MENU + +#define KSYM_space SDLK_SPACE +#define KSYM_exclam SDLK_EXCLAIM +#define KSYM_quotedbl SDLK_QUOTEDBL +#define KSYM_numbersign SDLK_HASH +#define KSYM_dollar SDLK_DOLLAR +#define KSYM_percent KSYM_UNDEFINED /* undefined */ +#define KSYM_ampersand SDLK_AMPERSAND +#define KSYM_apostrophe SDLK_QUOTE +#define KSYM_parenleft SDLK_LEFTPAREN +#define KSYM_parenright SDLK_RIGHTPAREN +#define KSYM_asterisk SDLK_ASTERISK +#define KSYM_plus SDLK_PLUS +#define KSYM_comma SDLK_COMMA +#define KSYM_minus SDLK_MINUS +#define KSYM_period SDLK_PERIOD +#define KSYM_slash SDLK_SLASH + +#define KSYM_colon SDLK_COLON +#define KSYM_semicolon SDLK_SEMICOLON +#define KSYM_less SDLK_LESS +#define KSYM_equal SDLK_EQUALS +#define KSYM_greater SDLK_GREATER +#define KSYM_question SDLK_QUESTION +#define KSYM_at SDLK_AT + +#define KSYM_bracketleft SDLK_LEFTBRACKET +#define KSYM_backslash SDLK_BACKSLASH +#define KSYM_bracketright SDLK_RIGHTBRACKET +#define KSYM_asciicircum SDLK_CARET +#define KSYM_underscore SDLK_UNDERSCORE +#define KSYM_grave SDLK_BACKQUOTE + +#define KSYM_quoteleft KSYM_UNDEFINED /* undefined */ +#define KSYM_braceleft KSYM_UNDEFINED /* undefined */ +#define KSYM_bar KSYM_UNDEFINED /* undefined */ +#define KSYM_braceright KSYM_UNDEFINED /* undefined */ +#define KSYM_asciitilde KSYM_UNDEFINED /* undefined */ + +#define KSYM_Adiaeresis SDLK_WORLD_36 +#define KSYM_Odiaeresis SDLK_WORLD_54 +#define KSYM_Udiaeresis SDLK_WORLD_60 +#define KSYM_adiaeresis SDLK_WORLD_68 +#define KSYM_odiaeresis SDLK_WORLD_86 +#define KSYM_udiaeresis SDLK_WORLD_92 +#define KSYM_ssharp SDLK_WORLD_63 #ifndef SDLK_A #define SDLK_A 65 @@ -199,106 +192,106 @@ typedef int Colormap; #define SDLK_Z 90 #endif -#define KEY_A SDLK_A -#define KEY_B SDLK_B -#define KEY_C SDLK_C -#define KEY_D SDLK_D -#define KEY_E SDLK_E -#define KEY_F SDLK_F -#define KEY_G SDLK_G -#define KEY_H SDLK_H -#define KEY_I SDLK_I -#define KEY_J SDLK_J -#define KEY_K SDLK_K -#define KEY_L SDLK_L -#define KEY_M SDLK_M -#define KEY_N SDLK_N -#define KEY_O SDLK_O -#define KEY_P SDLK_P -#define KEY_Q SDLK_Q -#define KEY_R SDLK_R -#define KEY_S SDLK_S -#define KEY_T SDLK_T -#define KEY_U SDLK_U -#define KEY_V SDLK_V -#define KEY_W SDLK_W -#define KEY_X SDLK_X -#define KEY_Y SDLK_Y -#define KEY_Z SDLK_Z - -#define KEY_a SDLK_a -#define KEY_b SDLK_b -#define KEY_c SDLK_c -#define KEY_d SDLK_d -#define KEY_e SDLK_e -#define KEY_f SDLK_f -#define KEY_g SDLK_g -#define KEY_h SDLK_h -#define KEY_i SDLK_i -#define KEY_j SDLK_j -#define KEY_k SDLK_k -#define KEY_l SDLK_l -#define KEY_m SDLK_m -#define KEY_n SDLK_n -#define KEY_o SDLK_o -#define KEY_p SDLK_p -#define KEY_q SDLK_q -#define KEY_r SDLK_r -#define KEY_s SDLK_s -#define KEY_t SDLK_t -#define KEY_u SDLK_u -#define KEY_v SDLK_v -#define KEY_w SDLK_w -#define KEY_x SDLK_x -#define KEY_y SDLK_y -#define KEY_z SDLK_z - -#define KEY_0 SDLK_0 -#define KEY_1 SDLK_1 -#define KEY_2 SDLK_2 -#define KEY_3 SDLK_3 -#define KEY_4 SDLK_4 -#define KEY_5 SDLK_5 -#define KEY_6 SDLK_6 -#define KEY_7 SDLK_7 -#define KEY_8 SDLK_8 -#define KEY_9 SDLK_9 - -#define KEY_KP_0 SDLK_KP0 -#define KEY_KP_1 SDLK_KP1 -#define KEY_KP_2 SDLK_KP2 -#define KEY_KP_3 SDLK_KP3 -#define KEY_KP_4 SDLK_KP4 -#define KEY_KP_5 SDLK_KP5 -#define KEY_KP_6 SDLK_KP6 -#define KEY_KP_7 SDLK_KP7 -#define KEY_KP_8 SDLK_KP8 -#define KEY_KP_9 SDLK_KP9 - -#define KEY_F1 SDLK_F1 -#define KEY_F2 SDLK_F2 -#define KEY_F3 SDLK_F3 -#define KEY_F4 SDLK_F4 -#define KEY_F5 SDLK_F5 -#define KEY_F6 SDLK_F6 -#define KEY_F7 SDLK_F7 -#define KEY_F8 SDLK_F8 -#define KEY_F9 SDLK_F9 -#define KEY_F10 SDLK_F10 -#define KEY_F11 SDLK_F11 -#define KEY_F12 SDLK_F12 -#define KEY_F13 SDLK_F13 -#define KEY_F14 SDLK_F14 -#define KEY_F15 SDLK_F15 -#define KEY_F16 KEY_UNDEFINED -#define KEY_F17 KEY_UNDEFINED -#define KEY_F18 KEY_UNDEFINED -#define KEY_F19 KEY_UNDEFINED -#define KEY_F20 KEY_UNDEFINED -#define KEY_F21 KEY_UNDEFINED -#define KEY_F22 KEY_UNDEFINED -#define KEY_F23 KEY_UNDEFINED -#define KEY_F24 KEY_UNDEFINED +#define KSYM_A SDLK_A +#define KSYM_B SDLK_B +#define KSYM_C SDLK_C +#define KSYM_D SDLK_D +#define KSYM_E SDLK_E +#define KSYM_F SDLK_F +#define KSYM_G SDLK_G +#define KSYM_H SDLK_H +#define KSYM_I SDLK_I +#define KSYM_J SDLK_J +#define KSYM_K SDLK_K +#define KSYM_L SDLK_L +#define KSYM_M SDLK_M +#define KSYM_N SDLK_N +#define KSYM_O SDLK_O +#define KSYM_P SDLK_P +#define KSYM_Q SDLK_Q +#define KSYM_R SDLK_R +#define KSYM_S SDLK_S +#define KSYM_T SDLK_T +#define KSYM_U SDLK_U +#define KSYM_V SDLK_V +#define KSYM_W SDLK_W +#define KSYM_X SDLK_X +#define KSYM_Y SDLK_Y +#define KSYM_Z SDLK_Z + +#define KSYM_a SDLK_a +#define KSYM_b SDLK_b +#define KSYM_c SDLK_c +#define KSYM_d SDLK_d +#define KSYM_e SDLK_e +#define KSYM_f SDLK_f +#define KSYM_g SDLK_g +#define KSYM_h SDLK_h +#define KSYM_i SDLK_i +#define KSYM_j SDLK_j +#define KSYM_k SDLK_k +#define KSYM_l SDLK_l +#define KSYM_m SDLK_m +#define KSYM_n SDLK_n +#define KSYM_o SDLK_o +#define KSYM_p SDLK_p +#define KSYM_q SDLK_q +#define KSYM_r SDLK_r +#define KSYM_s SDLK_s +#define KSYM_t SDLK_t +#define KSYM_u SDLK_u +#define KSYM_v SDLK_v +#define KSYM_w SDLK_w +#define KSYM_x SDLK_x +#define KSYM_y SDLK_y +#define KSYM_z SDLK_z + +#define KSYM_0 SDLK_0 +#define KSYM_1 SDLK_1 +#define KSYM_2 SDLK_2 +#define KSYM_3 SDLK_3 +#define KSYM_4 SDLK_4 +#define KSYM_5 SDLK_5 +#define KSYM_6 SDLK_6 +#define KSYM_7 SDLK_7 +#define KSYM_8 SDLK_8 +#define KSYM_9 SDLK_9 + +#define KSYM_KP_0 SDLK_KP0 +#define KSYM_KP_1 SDLK_KP1 +#define KSYM_KP_2 SDLK_KP2 +#define KSYM_KP_3 SDLK_KP3 +#define KSYM_KP_4 SDLK_KP4 +#define KSYM_KP_5 SDLK_KP5 +#define KSYM_KP_6 SDLK_KP6 +#define KSYM_KP_7 SDLK_KP7 +#define KSYM_KP_8 SDLK_KP8 +#define KSYM_KP_9 SDLK_KP9 + +#define KSYM_F1 SDLK_F1 +#define KSYM_F2 SDLK_F2 +#define KSYM_F3 SDLK_F3 +#define KSYM_F4 SDLK_F4 +#define KSYM_F5 SDLK_F5 +#define KSYM_F6 SDLK_F6 +#define KSYM_F7 SDLK_F7 +#define KSYM_F8 SDLK_F8 +#define KSYM_F9 SDLK_F9 +#define KSYM_F10 SDLK_F10 +#define KSYM_F11 SDLK_F11 +#define KSYM_F12 SDLK_F12 +#define KSYM_F13 SDLK_F13 +#define KSYM_F14 SDLK_F14 +#define KSYM_F15 SDLK_F15 +#define KSYM_F16 KSYM_UNDEFINED +#define KSYM_F17 KSYM_UNDEFINED +#define KSYM_F18 KSYM_UNDEFINED +#define KSYM_F19 KSYM_UNDEFINED +#define KSYM_F20 KSYM_UNDEFINED +#define KSYM_F21 KSYM_UNDEFINED +#define KSYM_F22 KSYM_UNDEFINED +#define KSYM_F23 KSYM_UNDEFINED +#define KSYM_F24 KSYM_UNDEFINED /* SDL function definitions */ diff --git a/src/sound.c b/src/sound.c index d302b0e7..51b0f126 100644 --- a/src/sound.c +++ b/src/sound.c @@ -23,37 +23,38 @@ static struct SoundControl emptySoundControl = -1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL }; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) static int stereo_volume[PSND_MAX_LEFT2RIGHT+1]; static char premix_first_buffer[SND_BLOCKSIZE]; #ifdef VOXWARE static char premix_left_buffer[SND_BLOCKSIZE]; static char premix_right_buffer[SND_BLOCKSIZE]; static int premix_last_buffer[SND_BLOCKSIZE]; -#endif /* VOXWARE */ +#endif static unsigned char playing_buffer[SND_BLOCKSIZE]; -#endif /* !MSDOS && !WIN32 */ +#endif /* forward declaration of internal functions */ #ifdef VOXWARE static void SoundServer_InsertNewSound(struct SoundControl); -#endif - -#if !defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32) +#else +#if defined(PLATFORM_UNIX) static unsigned char linear_to_ulaw(int); static int ulaw_to_linear(unsigned char); #endif +#endif #ifdef HPUX_AUDIO static void HPUX_Audio_Control(); #endif -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) static void SoundServer_InsertNewSound(struct SoundControl); static void SoundServer_StopSound(int); static void SoundServer_StopAllSounds(); #endif +#if defined(PLATFORM_UNIX) int OpenAudio(char *audio_device_name) { int audio_fd; @@ -94,11 +95,12 @@ boolean UnixInitAudio(void) { return TRUE; } +#endif /* PLATFORM_UNIX */ void SoundServer() { int i; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) struct SoundControl snd_ctrl; fd_set sound_fdset; @@ -109,7 +111,7 @@ void SoundServer() playlist[i] = emptySoundControl; playing_sounds = 0; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) stereo_volume[PSND_MAX_LEFT2RIGHT] = 0; for(i=0;iname, sound_ext); -#ifdef TARGET_SDL +#if defined(TARGET_SDL) snd_info->mix_chunk = Mix_LoadWAV(filename); if (snd_info->mix_chunk == NULL) @@ -792,7 +796,7 @@ boolean LoadSound(struct SoundInfo *snd_info) #else /* !TARGET_SDL */ -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) if ((file = fopen(filename, "r")) == NULL) { @@ -848,7 +852,7 @@ boolean LoadSound(struct SoundInfo *snd_info) for (i=0; idata_len; i++) snd_info->data_ptr[i] = snd_info->data_ptr[i] ^ 0x80; -#else /* MSDOS */ +#else /* PLATFORM_MSDOS */ snd_info->sample_ptr = load_sample(filename); if (!snd_info->sample_ptr) @@ -857,7 +861,7 @@ boolean LoadSound(struct SoundInfo *snd_info) return FALSE; } -#endif /* MSDOS */ +#endif /* PLATFORM_MSDOS */ #endif /* !TARGET_SDL */ return TRUE; @@ -903,7 +907,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 TARGET_SDL +#if defined(TARGET_SDL) Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); @@ -911,7 +915,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) Mix_PlayChannel(-1, Sound[nr].mix_chunk, (loop ? -1 : 0)); #else -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0) { Error(ERR_WARN, "cannot pipe to child process - no sounds"); @@ -962,7 +966,7 @@ void StopSoundExt(int nr, int method) snd_ctrl.stop_sound = TRUE; } -#ifdef TARGET_SDL +#if defined(TARGET_SDL) if (SSND_FADING(method)) { @@ -976,7 +980,7 @@ void StopSoundExt(int nr, int method) } #else -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0) { Error(ERR_WARN, "cannot pipe to child process - no sounds"); @@ -997,7 +1001,7 @@ void FreeSounds(int num_sounds) return; for(i=0; i #include #include -#endif /* !MSDOS */ +#endif /* system dependent definitions */ -/* DOS version also defines "TARGET_STRING" */ +/* MS-DOS header file also defines "TARGET_STRING" */ #ifndef TARGET_STRING #define TARGET_STRING "X11" #endif @@ -69,201 +69,201 @@ typedef XClientMessageEvent ClientMessageEvent; #define EVENT_MAPNOTIFY MapNotify #define EVENT_UNMAPNOTIFY UnmapNotify -#define KEY_UNDEFINED XK_VoidSymbol +#define KSYM_UNDEFINED XK_VoidSymbol -#define KEY_Return XK_Return -#define KEY_Escape XK_Escape +#define KSYM_Return XK_Return +#define KSYM_Escape XK_Escape -#define KEY_Left XK_Left -#define KEY_Right XK_Right -#define KEY_Up XK_Up -#define KEY_Down XK_Down +#define KSYM_Left XK_Left +#define KSYM_Right XK_Right +#define KSYM_Up XK_Up +#define KSYM_Down XK_Down #ifdef XK_KP_Left -#define KEY_KP_Left XK_KP_Left -#define KEY_KP_Right XK_KP_Right -#define KEY_KP_Up XK_KP_Up -#define KEY_KP_Down XK_KP_Down +#define KSYM_KP_Left XK_KP_Left +#define KSYM_KP_Right XK_KP_Right +#define KSYM_KP_Up XK_KP_Up +#define KSYM_KP_Down XK_KP_Down #endif #ifdef XK_KP_Enter -#define KEY_KP_Enter XK_KP_Enter -#define KEY_KP_Add XK_KP_Add -#define KEY_KP_Subtract XK_KP_Subtract -#define KEY_KP_Multiply XK_KP_Multiply -#define KEY_KP_Divide XK_KP_Divide -#define KEY_KP_Separator XK_KP_Separator +#define KSYM_KP_Enter XK_KP_Enter +#define KSYM_KP_Add XK_KP_Add +#define KSYM_KP_Subtract XK_KP_Subtract +#define KSYM_KP_Multiply XK_KP_Multiply +#define KSYM_KP_Divide XK_KP_Divide +#define KSYM_KP_Separator XK_KP_Separator #endif -#define KEY_Shift_L XK_Shift_L -#define KEY_Shift_R XK_Shift_R -#define KEY_Control_L XK_Control_L -#define KEY_Control_R XK_Control_R -#define KEY_Meta_L XK_Meta_L -#define KEY_Meta_R XK_Meta_R -#define KEY_Alt_L XK_Alt_L -#define KEY_Alt_R XK_Alt_R -#define KEY_Super_L XK_Super_L -#define KEY_Super_R XK_Super_R -#define KEY_Mode_switch XK_Mode_switch -#define KEY_Multi_key XK_Multi_key - -#define KEY_BackSpace XK_BackSpace -#define KEY_Delete XK_Delete -#define KEY_Insert XK_Insert -#define KEY_Tab XK_Tab -#define KEY_Home XK_Home -#define KEY_End XK_End -#define KEY_Page_Up XK_Page_Up -#define KEY_Page_Down XK_Page_Down -#define KEY_Menu XK_Menu - -#define KEY_space XK_space -#define KEY_exclam XK_exclam -#define KEY_quotedbl XK_quotedbl -#define KEY_numbersign XK_numbersign -#define KEY_dollar XK_dollar -#define KEY_percent XK_percent -#define KEY_ampersand XK_ampersand -#define KEY_apostrophe XK_apostrophe -#define KEY_parenleft XK_parenleft -#define KEY_parenright XK_parenright -#define KEY_asterisk XK_asterisk -#define KEY_plus XK_plus -#define KEY_comma XK_comma -#define KEY_minus XK_minus -#define KEY_period XK_period -#define KEY_slash XK_slash - -#define KEY_colon XK_colon -#define KEY_semicolon XK_semicolon -#define KEY_less XK_less -#define KEY_equal XK_equal -#define KEY_greater XK_greater -#define KEY_question XK_question -#define KEY_at XK_at - -#define KEY_bracketleft XK_bracketleft -#define KEY_backslash XK_backslash -#define KEY_bracketright XK_bracketright -#define KEY_asciicircum XK_asciicircum -#define KEY_underscore XK_underscore -#define KEY_grave XK_grave - -#define KEY_quoteleft XK_quoteleft -#define KEY_braceleft XK_braceleft -#define KEY_bar XK_bar -#define KEY_braceright XK_braceright -#define KEY_asciitilde XK_asciitilde - -#define KEY_Adiaeresis XK_Adiaeresis -#define KEY_Odiaeresis XK_Odiaeresis -#define KEY_Udiaeresis XK_Udiaeresis -#define KEY_adiaeresis XK_adiaeresis -#define KEY_odiaeresis XK_odiaeresis -#define KEY_udiaeresis XK_udiaeresis -#define KEY_ssharp XK_ssharp - -#define KEY_A XK_A -#define KEY_B XK_B -#define KEY_C XK_C -#define KEY_D XK_D -#define KEY_E XK_E -#define KEY_F XK_F -#define KEY_G XK_G -#define KEY_H XK_H -#define KEY_I XK_I -#define KEY_J XK_J -#define KEY_K XK_K -#define KEY_L XK_L -#define KEY_M XK_M -#define KEY_N XK_N -#define KEY_O XK_O -#define KEY_P XK_P -#define KEY_Q XK_Q -#define KEY_R XK_R -#define KEY_S XK_S -#define KEY_T XK_T -#define KEY_U XK_U -#define KEY_V XK_V -#define KEY_W XK_W -#define KEY_X XK_X -#define KEY_Y XK_Y -#define KEY_Z XK_Z - -#define KEY_a XK_a -#define KEY_b XK_b -#define KEY_c XK_c -#define KEY_d XK_d -#define KEY_e XK_e -#define KEY_f XK_f -#define KEY_g XK_g -#define KEY_h XK_h -#define KEY_i XK_i -#define KEY_j XK_j -#define KEY_k XK_k -#define KEY_l XK_l -#define KEY_m XK_m -#define KEY_n XK_n -#define KEY_o XK_o -#define KEY_p XK_p -#define KEY_q XK_q -#define KEY_r XK_r -#define KEY_s XK_s -#define KEY_t XK_t -#define KEY_u XK_u -#define KEY_v XK_v -#define KEY_w XK_w -#define KEY_x XK_x -#define KEY_y XK_y -#define KEY_z XK_z - -#define KEY_0 XK_0 -#define KEY_1 XK_1 -#define KEY_2 XK_2 -#define KEY_3 XK_3 -#define KEY_4 XK_4 -#define KEY_5 XK_5 -#define KEY_6 XK_6 -#define KEY_7 XK_7 -#define KEY_8 XK_8 -#define KEY_9 XK_9 - -#define KEY_KP_0 XK_KP_0 -#define KEY_KP_1 XK_KP_1 -#define KEY_KP_2 XK_KP_2 -#define KEY_KP_3 XK_KP_3 -#define KEY_KP_4 XK_KP_4 -#define KEY_KP_5 XK_KP_5 -#define KEY_KP_6 XK_KP_6 -#define KEY_KP_7 XK_KP_7 -#define KEY_KP_8 XK_KP_8 -#define KEY_KP_9 XK_KP_9 - -#define KEY_F1 XK_F1 -#define KEY_F2 XK_F2 -#define KEY_F3 XK_F3 -#define KEY_F4 XK_F4 -#define KEY_F5 XK_F5 -#define KEY_F6 XK_F6 -#define KEY_F7 XK_F7 -#define KEY_F8 XK_F8 -#define KEY_F9 XK_F9 -#define KEY_F10 XK_F10 -#define KEY_F11 XK_F11 -#define KEY_F12 XK_F12 -#define KEY_F13 XK_F13 -#define KEY_F14 XK_F14 -#define KEY_F15 XK_F15 -#define KEY_F16 XK_F16 -#define KEY_F17 XK_F17 -#define KEY_F18 XK_F18 -#define KEY_F19 XK_F19 -#define KEY_F20 XK_F20 -#define KEY_F21 XK_F21 -#define KEY_F22 XK_F22 -#define KEY_F23 XK_F23 -#define KEY_F24 XK_F24 +#define KSYM_Shift_L XK_Shift_L +#define KSYM_Shift_R XK_Shift_R +#define KSYM_Control_L XK_Control_L +#define KSYM_Control_R XK_Control_R +#define KSYM_Meta_L XK_Meta_L +#define KSYM_Meta_R XK_Meta_R +#define KSYM_Alt_L XK_Alt_L +#define KSYM_Alt_R XK_Alt_R +#define KSYM_Super_L XK_Super_L +#define KSYM_Super_R XK_Super_R +#define KSYM_Mode_switch XK_Mode_switch +#define KSYM_Multi_key XK_Multi_key + +#define KSYM_BackSpace XK_BackSpace +#define KSYM_Delete XK_Delete +#define KSYM_Insert XK_Insert +#define KSYM_Tab XK_Tab +#define KSYM_Home XK_Home +#define KSYM_End XK_End +#define KSYM_Page_Up XK_Page_Up +#define KSYM_Page_Down XK_Page_Down +#define KSYM_Menu XK_Menu + +#define KSYM_space XK_space +#define KSYM_exclam XK_exclam +#define KSYM_quotedbl XK_quotedbl +#define KSYM_numbersign XK_numbersign +#define KSYM_dollar XK_dollar +#define KSYM_percent XK_percent +#define KSYM_ampersand XK_ampersand +#define KSYM_apostrophe XK_apostrophe +#define KSYM_parenleft XK_parenleft +#define KSYM_parenright XK_parenright +#define KSYM_asterisk XK_asterisk +#define KSYM_plus XK_plus +#define KSYM_comma XK_comma +#define KSYM_minus XK_minus +#define KSYM_period XK_period +#define KSYM_slash XK_slash + +#define KSYM_colon XK_colon +#define KSYM_semicolon XK_semicolon +#define KSYM_less XK_less +#define KSYM_equal XK_equal +#define KSYM_greater XK_greater +#define KSYM_question XK_question +#define KSYM_at XK_at + +#define KSYM_bracketleft XK_bracketleft +#define KSYM_backslash XK_backslash +#define KSYM_bracketright XK_bracketright +#define KSYM_asciicircum XK_asciicircum +#define KSYM_underscore XK_underscore +#define KSYM_grave XK_grave + +#define KSYM_quoteleft XK_quoteleft +#define KSYM_braceleft XK_braceleft +#define KSYM_bar XK_bar +#define KSYM_braceright XK_braceright +#define KSYM_asciitilde XK_asciitilde + +#define KSYM_Adiaeresis XK_Adiaeresis +#define KSYM_Odiaeresis XK_Odiaeresis +#define KSYM_Udiaeresis XK_Udiaeresis +#define KSYM_adiaeresis XK_adiaeresis +#define KSYM_odiaeresis XK_odiaeresis +#define KSYM_udiaeresis XK_udiaeresis +#define KSYM_ssharp XK_ssharp + +#define KSYM_A XK_A +#define KSYM_B XK_B +#define KSYM_C XK_C +#define KSYM_D XK_D +#define KSYM_E XK_E +#define KSYM_F XK_F +#define KSYM_G XK_G +#define KSYM_H XK_H +#define KSYM_I XK_I +#define KSYM_J XK_J +#define KSYM_K XK_K +#define KSYM_L XK_L +#define KSYM_M XK_M +#define KSYM_N XK_N +#define KSYM_O XK_O +#define KSYM_P XK_P +#define KSYM_Q XK_Q +#define KSYM_R XK_R +#define KSYM_S XK_S +#define KSYM_T XK_T +#define KSYM_U XK_U +#define KSYM_V XK_V +#define KSYM_W XK_W +#define KSYM_X XK_X +#define KSYM_Y XK_Y +#define KSYM_Z XK_Z + +#define KSYM_a XK_a +#define KSYM_b XK_b +#define KSYM_c XK_c +#define KSYM_d XK_d +#define KSYM_e XK_e +#define KSYM_f XK_f +#define KSYM_g XK_g +#define KSYM_h XK_h +#define KSYM_i XK_i +#define KSYM_j XK_j +#define KSYM_k XK_k +#define KSYM_l XK_l +#define KSYM_m XK_m +#define KSYM_n XK_n +#define KSYM_o XK_o +#define KSYM_p XK_p +#define KSYM_q XK_q +#define KSYM_r XK_r +#define KSYM_s XK_s +#define KSYM_t XK_t +#define KSYM_u XK_u +#define KSYM_v XK_v +#define KSYM_w XK_w +#define KSYM_x XK_x +#define KSYM_y XK_y +#define KSYM_z XK_z + +#define KSYM_0 XK_0 +#define KSYM_1 XK_1 +#define KSYM_2 XK_2 +#define KSYM_3 XK_3 +#define KSYM_4 XK_4 +#define KSYM_5 XK_5 +#define KSYM_6 XK_6 +#define KSYM_7 XK_7 +#define KSYM_8 XK_8 +#define KSYM_9 XK_9 + +#define KSYM_KP_0 XK_KP_0 +#define KSYM_KP_1 XK_KP_1 +#define KSYM_KP_2 XK_KP_2 +#define KSYM_KP_3 XK_KP_3 +#define KSYM_KP_4 XK_KP_4 +#define KSYM_KP_5 XK_KP_5 +#define KSYM_KP_6 XK_KP_6 +#define KSYM_KP_7 XK_KP_7 +#define KSYM_KP_8 XK_KP_8 +#define KSYM_KP_9 XK_KP_9 + +#define KSYM_F1 XK_F1 +#define KSYM_F2 XK_F2 +#define KSYM_F3 XK_F3 +#define KSYM_F4 XK_F4 +#define KSYM_F5 XK_F5 +#define KSYM_F6 XK_F6 +#define KSYM_F7 XK_F7 +#define KSYM_F8 XK_F8 +#define KSYM_F9 XK_F9 +#define KSYM_F10 XK_F10 +#define KSYM_F11 XK_F11 +#define KSYM_F12 XK_F12 +#define KSYM_F13 XK_F13 +#define KSYM_F14 XK_F14 +#define KSYM_F15 XK_F15 +#define KSYM_F16 XK_F16 +#define KSYM_F17 XK_F17 +#define KSYM_F18 XK_F18 +#define KSYM_F19 XK_F19 +#define KSYM_F20 XK_F20 +#define KSYM_F21 XK_F21 +#define KSYM_F22 XK_F22 +#define KSYM_F23 XK_F23 +#define KSYM_F24 XK_F24 /* X11 function definitions */ -- 2.34.1