From da14f69fd95c7bd5a0d70cdf4935af06f1f20a04 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 1 Dec 2000 19:22:24 +0100 Subject: [PATCH] rnd-20001201-1-src --- Makefile | 2 +- src/Makefile | 49 +++++------ src/cartoons.c | 3 +- src/editor.c | 16 +++- src/events.c | 4 +- src/files.c | 3 +- src/game.c | 7 +- src/init.c | 6 +- src/joystick.c | 5 +- src/libgame/Makefile | 60 ++++++++++++++ src/{ => libgame}/buttons.c | 12 ++- src/{ => libgame}/buttons.h | 2 +- src/{ => libgame}/image.c | 0 src/{ => libgame}/image.h | 5 +- src/libgame/joystick_TMP.h | 90 ++++++++++++++++++++ src/libgame/libgame.c | 14 ++++ src/libgame/libgame.h | 29 +++++++ src/libgame/main_TMP.h | 1 + src/{ => libgame}/misc.c | 14 ++-- src/{ => libgame}/misc.h | 5 +- src/{ => libgame}/msdos.c | 11 +-- src/{ => libgame}/msdos.h | 0 src/{ => libgame}/pcx.c | 0 src/{ => libgame}/pcx.h | 5 +- src/{ => libgame}/platform.h | 0 src/libgame/private.c | 22 +++++ src/libgame/private.h | 27 ++++++ src/{ => libgame}/random.c | 0 src/{ => libgame}/random.h | 0 src/{ => libgame}/sdl.c | 17 ++-- src/{ => libgame}/sdl.h | 2 +- src/{ => libgame}/sound.c | 15 ++-- src/{ => libgame}/sound.h | 6 +- src/{ => libgame}/system.c | 50 ++++++++--- src/{ => libgame}/system.h | 49 ++++++++++- src/libgame/text.c | 156 +++++++++++++++++++++++++++++++++++ src/libgame/text.h | 27 ++++++ src/libgame/types.h | 25 ++++++ src/{ => libgame}/x11.c | 5 +- src/{ => libgame}/x11.h | 0 src/main.c | 36 ++++++-- src/main.h | 53 ++++++------ src/netserv.c | 7 +- src/network.c | 8 +- src/screens.c | 9 +- src/tape.c | 4 +- src/tools.c | 19 +++-- src/tools.h | 6 +- 48 files changed, 732 insertions(+), 154 deletions(-) create mode 100644 src/libgame/Makefile rename src/{ => libgame}/buttons.c (99%) rename src/{ => libgame}/buttons.h (99%) rename src/{ => libgame}/image.c (100%) rename src/{ => libgame}/image.h (97%) create mode 100644 src/libgame/joystick_TMP.h create mode 100644 src/libgame/libgame.c create mode 100644 src/libgame/libgame.h create mode 120000 src/libgame/main_TMP.h rename src/{ => libgame}/misc.c (99%) rename src/{ => libgame}/misc.h (98%) rename src/{ => libgame}/msdos.c (99%) rename src/{ => libgame}/msdos.h (100%) rename src/{ => libgame}/pcx.c (100%) rename src/{ => libgame}/pcx.h (94%) rename src/{ => libgame}/platform.h (100%) create mode 100644 src/libgame/private.c create mode 100644 src/libgame/private.h rename src/{ => libgame}/random.c (100%) rename src/{ => libgame}/random.h (100%) rename src/{ => libgame}/sdl.c (94%) rename src/{ => libgame}/sdl.h (99%) rename src/{ => libgame}/sound.c (98%) rename src/{ => libgame}/sound.h (98%) rename src/{ => libgame}/system.c (86%) rename src/{ => libgame}/system.h (70%) create mode 100644 src/libgame/text.c create mode 100644 src/libgame/text.h create mode 100644 src/libgame/types.h rename src/{ => libgame}/x11.c (99%) rename src/{ => libgame}/x11.h (100%) diff --git a/Makefile b/Makefile index cf775274..e058339a 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ SRC_DIR = src MAKE_CMD = $(MAKE) -C $(SRC_DIR) all: - @$(MAKE_CMD) TARGET=sdl + @$(MAKE_CMD) TARGET=x11 x11: @$(MAKE_CMD) TARGET=x11 diff --git a/src/Makefile b/src/Makefile index cc8e1df0..6bf31b87 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,6 +3,8 @@ # (c) 1995-2000 Holger Schemel, info@artsoft.org # #=============================================================================# +.EXPORT_ALL_VARIABLES: + ifndef PLATFORM # platform not specified -- try auto detection ifdef COMSPEC PLATFORM = msdos @@ -18,6 +20,8 @@ X11_INCL = -I$(XINC_PATH) X11_LIBS = -L$(XLIB_PATH) endif +AR = ar +RANLIB = ranlib ifeq ($(PLATFORM),msdos) # MS-DOS native compiling @@ -98,66 +102,56 @@ OPTIONS = $(DEBUG) -Wall # only for debugging purposes CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG) LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm + SRCS = main.c \ init.c \ events.c \ tools.c \ screens.c \ - misc.c \ game.c \ editor.c \ - buttons.c \ files.c \ tape.c \ - sound.c \ joystick.c \ cartoons.c \ - random.c \ - pcx.c \ - image.c \ network.c \ - netserv.c \ - msdos.c \ - system.c \ - x11.c \ - sdl.c + netserv.c OBJS = main.o \ init.o \ events.o \ tools.o \ screens.o \ - misc.o \ game.o \ editor.o \ - buttons.o \ files.o \ tape.o \ - sound.o \ joystick.o \ cartoons.o \ - random.o \ - pcx.o \ - image.o \ network.o \ - netserv.o \ - msdos.o \ - system.o \ - x11.o \ - sdl.o + netserv.o + +LIBDIR = libgame +LIBGAME = $(LIBDIR)/libgame.a + -all: $(PROGNAME) +all: $(PROGNAME) -$(PROGNAME): $(OBJS) - $(CC) $(PROFILING) $(OBJS) $(LDFLAGS) -o $(PROGNAME) +$(PROGNAME): $(LIBGAME) $(OBJS) + $(CC) $(PROFILING) $(OBJS) $(LIBGAME) $(LDFLAGS) -o $(PROGNAME) + +$(LIBGAME): + $(MAKE) -C $(LIBDIR) .c.o: $(CC) $(PROFILING) $(CFLAGS) -c $*.c clean: - $(RM) *.o - $(RM) ../*.exe + $(MAKE) -C $(LIBDIR) clean + $(RM) $(OBJS) + $(RM) $(LIBGAME) $(RM) $(PROGNAME) + $(RM) ../*.exe #-----------------------------------------------------------------------------# @@ -165,6 +159,7 @@ clean: #-----------------------------------------------------------------------------# depend: + $(MAKE) -C $(LIBDIR) depend for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend ifeq (.depend,$(wildcard .depend)) diff --git a/src/cartoons.c b/src/cartoons.c index 3290331e..b3a639a3 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -11,9 +11,10 @@ * cartoons.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "cartoons.h" #include "main.h" -#include "misc.h" #include "tools.h" static void HandleAnimation(int); diff --git a/src/editor.c b/src/editor.c index 0977a92a..2ed164c1 100644 --- a/src/editor.c +++ b/src/editor.c @@ -13,11 +13,11 @@ #include +#include "libgame/libgame.h" + #include "editor.h" #include "screens.h" #include "tools.h" -#include "misc.h" -#include "buttons.h" #include "files.h" #include "game.h" #include "tape.h" @@ -1394,6 +1394,7 @@ static void CreateControlButtons() GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2, GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); @@ -1451,6 +1452,7 @@ static void CreateControlButtons() GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); @@ -1501,6 +1503,7 @@ static void CreateControlButtons() GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY, GDI_DECORATION_SHIFTING, 1, 1, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); @@ -1579,6 +1582,7 @@ static void CreateCounterButtons() GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y, GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleCounterButtons, GDI_END); @@ -1629,6 +1633,7 @@ static void CreateCounterButtons() GDI_BORDER_SIZE, ED_BORDER_SIZE, GDI_TEXTINPUT_DESIGN_WIDTH, gd_width, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleCounterButtons, GDI_END); @@ -1772,6 +1777,7 @@ static void CreateTextInputGadgets() GDI_BORDER_SIZE, ED_BORDER_SIZE, GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleTextInputGadgets, GDI_END); @@ -1841,6 +1847,7 @@ static void CreateScrollbarGadgets() GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_BORDER_SIZE, ED_BORDER_SIZE, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); @@ -1890,6 +1897,7 @@ static void CreateCheckbuttonGadgets() GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y, GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleRadiobuttons, GDI_END); @@ -1922,6 +1930,7 @@ static void CreateCheckbuttonGadgets() GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x3, gd_y, GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x4, gd_y, GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleCheckbuttons, GDI_END); @@ -4048,6 +4057,9 @@ void HandleEditorGadgetInfoText(void *ptr) char infotext[MAX_INFOTEXT_LEN + 1]; char shortcut[MAX_INFOTEXT_LEN + 1]; + if (game_status != LEVELED) + return; + ClearEditorGadgetInfoText(); /* misuse this function to delete brush cursor, if needed */ diff --git a/src/events.c b/src/events.c index 95d37522..604345d9 100644 --- a/src/events.c +++ b/src/events.c @@ -11,16 +11,16 @@ * events.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "events.h" #include "init.h" #include "screens.h" #include "tools.h" #include "game.h" #include "editor.h" -#include "misc.h" #include "tape.h" #include "joystick.h" -#include "buttons.h" #include "network.h" /* values for key_status */ diff --git a/src/files.c b/src/files.c index 42f7a993..f8bbea80 100644 --- a/src/files.c +++ b/src/files.c @@ -15,9 +15,10 @@ #include #include +#include "libgame/libgame.h" + #include "files.h" #include "tools.h" -#include "misc.h" #include "tape.h" #include "joystick.h" diff --git a/src/game.c b/src/game.c index 670f8cb1..1f39cd8f 100644 --- a/src/game.c +++ b/src/game.c @@ -11,13 +11,12 @@ * game.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "game.h" -#include "misc.h" #include "tools.h" #include "screens.h" -#include "sound.h" #include "init.h" -#include "buttons.h" #include "files.h" #include "tape.h" #include "joystick.h" @@ -176,7 +175,7 @@ void GetPlayerConfig() setup.sound_music = FALSE; } - if (!fullscreen_available) + if (!video.fullscreen_available) setup.fullscreen = FALSE; setup.sound_simple = setup.sound; diff --git a/src/init.c b/src/init.c index 851eaa5e..d48e713c 100644 --- a/src/init.c +++ b/src/init.c @@ -13,10 +13,10 @@ #include +#include "libgame/libgame.h" + #include "init.h" #include "events.h" -#include "misc.h" -#include "sound.h" #include "screens.h" #include "editor.h" #include "game.h" @@ -24,8 +24,6 @@ #include "tools.h" #include "files.h" #include "joystick.h" -#include "image.h" -#include "pcx.h" #include "network.h" #include "netserv.h" diff --git a/src/joystick.c b/src/joystick.c index 8f6a0d6a..16d00d78 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -11,12 +11,13 @@ * joystick.c * ***********************************************************/ -#ifdef __FreeBSD__ +#if defined(PLATFORM_FREEBSD) #include #endif +#include "libgame/libgame.h" + #include "joystick.h" -#include "misc.h" #if !defined(PLATFORM_MSDOS) static int JoystickPosition(int middle, int margin, int actual) diff --git a/src/libgame/Makefile b/src/libgame/Makefile new file mode 100644 index 00000000..f096730d --- /dev/null +++ b/src/libgame/Makefile @@ -0,0 +1,60 @@ +#=============================================================================# +# Makefile for Rocks'n'Diamonds # +# (c) 1995-2000 Holger Schemel, info@artsoft.org # +#=============================================================================# + +SRCS = libgame.c \ + private.c \ + system.c \ + buttons.c \ + text.c \ + sound.c \ + pcx.c \ + image.c \ + random.c \ + misc.c \ + msdos.c \ + x11.c \ + sdl.c + +OBJS = libgame.o \ + private.o \ + system.o \ + buttons.o \ + text.o \ + sound.o \ + pcx.o \ + image.o \ + random.o \ + misc.o \ + msdos.o \ + x11.o \ + sdl.o + +LIBGAME = libgame.a + + +all: $(LIBGAME) + +$(LIBGAME): $(OBJS) + $(AR) cru $(LIBGAME) $(OBJS) + $(RANLIB) $(LIBGAME) + +.c.o: + $(CC) $(PROFILING) $(CFLAGS) -c $*.c + +clean: + $(RM) $(OBJS) + $(RM) $(LIBGAME) + + +#-----------------------------------------------------------------------------# +# development only stuff # +#-----------------------------------------------------------------------------# + +depend: + for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif diff --git a/src/buttons.c b/src/libgame/buttons.c similarity index 99% rename from src/buttons.c rename to src/libgame/buttons.c index 88ff994e..3fad7560 100644 --- a/src/buttons.c +++ b/src/libgame/buttons.c @@ -13,11 +13,11 @@ #include +#include "libgame.h" + +#include "main_TMP.h" + #include "buttons.h" -#include "tools.h" -#include "misc.h" -#include "editor.h" -#include "tape.h" /* some positions in the video tape control window */ #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS) @@ -324,8 +324,12 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my) static void default_callback_info(void *ptr) { +#if 0 if (game_status == LEVELED) HandleEditorGadgetInfoText(ptr); +#endif + + return; } static void default_callback_action(void *ptr) diff --git a/src/buttons.h b/src/libgame/buttons.h similarity index 99% rename from src/buttons.h rename to src/libgame/buttons.h index 368fa9ee..38fbe634 100644 --- a/src/buttons.h +++ b/src/libgame/buttons.h @@ -14,7 +14,7 @@ #ifndef BUTTONS_H #define BUTTONS_H -#include "main.h" +#include "libgame.h" /* the following definitions are also used by tools.c */ diff --git a/src/image.c b/src/libgame/image.c similarity index 100% rename from src/image.c rename to src/libgame/image.c diff --git a/src/image.h b/src/libgame/image.h similarity index 97% rename from src/image.h rename to src/libgame/image.h index 860521c0..4f55fe3a 100644 --- a/src/image.h +++ b/src/libgame/image.h @@ -14,9 +14,12 @@ #ifndef IMAGE_H #define IMAGE_H +#include "platform.h" + #ifndef TARGET_SDL -#include "main.h" +#include "types.h" +#include "x11.h" #define MAX_COLORS 256 /* maximal number of colors for each image */ diff --git a/src/libgame/joystick_TMP.h b/src/libgame/joystick_TMP.h new file mode 100644 index 00000000..ccf728aa --- /dev/null +++ b/src/libgame/joystick_TMP.h @@ -0,0 +1,90 @@ +/*********************************************************** +* 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 * +*----------------------------------------------------------* +* joystick.h * +***********************************************************/ + +#ifndef JOYSTICK_H +#define JOYSTICK_H + +/* values for the joystick */ +#define JOYSTICK_OFF 0 +#define JOYSTICK_AVAILABLE 1 + +#ifdef __FreeBSD__ +#include +#define DEV_JOYSTICK_0 "/dev/joy0" +#define DEV_JOYSTICK_1 "/dev/joy1" +#define DEV_JOYSTICK_2 "/dev/joy2" +#define DEV_JOYSTICK_3 "/dev/joy3" +#else +#define DEV_JOYSTICK_0 "/dev/js0" +#define DEV_JOYSTICK_1 "/dev/js1" +#define DEV_JOYSTICK_2 "/dev/js2" +#define DEV_JOYSTICK_3 "/dev/js3" +#endif + +/* get these values from the program 'js' from the joystick package, */ +/* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */ + +#ifdef TARGET_SDL +#define JOYSTICK_XLEFT -32767 +#define JOYSTICK_XMIDDLE 0 +#define JOYSTICK_XRIGHT 32767 +#define JOYSTICK_YUPPER -32767 +#define JOYSTICK_YMIDDLE 0 +#define JOYSTICK_YLOWER 32767 +#else +#define JOYSTICK_XLEFT 30 +#define JOYSTICK_XMIDDLE 530 +#define JOYSTICK_XRIGHT 1250 +#define JOYSTICK_YUPPER 40 +#define JOYSTICK_YMIDDLE 680 +#define JOYSTICK_YLOWER 1440 +#endif + +#define JOYSTICK_PERCENT 25 + +#define JOY_LEFT MV_LEFT +#define JOY_RIGHT MV_RIGHT +#define JOY_UP MV_UP +#define JOY_DOWN MV_DOWN +#define JOY_BUTTON_1 (1<<4) +#define JOY_BUTTON_2 (1<<5) +#define JOY_BUTTON (JOY_BUTTON_1 | JOY_BUTTON_2) + +#define JOY_BUTTON_NOT_PRESSED 0 +#define JOY_BUTTON_PRESSED 1 +#define JOY_BUTTON_NEW_PRESSED 2 +#define JOY_BUTTON_NEW_RELEASED 3 + +#ifdef NO_JOYSTICK +#define JOYSTICK_STATUS JOYSTICK_OFF +#else +#define JOYSTICK_STATUS JOYSTICK_AVAILABLE +#endif + + +#if defined(TARGET_SDL) +SDL_Joystick *Get_SDL_Joystick(int); +boolean Open_SDL_Joystick(int); +void Close_SDL_Joystick(int); +boolean Check_SDL_JoystickOpened(int); +void HandleJoystickEvent(Event *); +int Get_SDL_Joystick_Axis(int, int); +#endif + +void CheckJoystickData(void); +int Joystick(int); +int JoystickButton(int); +int AnyJoystick(void); +int AnyJoystickButton(void); + +#endif /* JOYSTICK_H */ diff --git a/src/libgame/libgame.c b/src/libgame/libgame.c new file mode 100644 index 00000000..8c000c20 --- /dev/null +++ b/src/libgame/libgame.c @@ -0,0 +1,14 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * +*----------------------------------------------------------* +* libgame.c * +***********************************************************/ + +#include "libgame.h" diff --git a/src/libgame/libgame.h b/src/libgame/libgame.h new file mode 100644 index 00000000..b2af1408 --- /dev/null +++ b/src/libgame/libgame.h @@ -0,0 +1,29 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * +*----------------------------------------------------------* +* libgame.h * +***********************************************************/ + +#ifndef LIBGAME_H +#define LIBGAME_H + +#include "platform.h" +#include "types.h" +#include "private.h" +#include "system.h" +#include "random.h" +#include "buttons.h" +#include "text.h" +#include "sound.h" +#include "image.h" +#include "pcx.h" +#include "misc.h" + +#endif /* LIBGAME_H */ diff --git a/src/libgame/main_TMP.h b/src/libgame/main_TMP.h new file mode 120000 index 00000000..31e337c4 --- /dev/null +++ b/src/libgame/main_TMP.h @@ -0,0 +1 @@ +../main.h \ No newline at end of file diff --git a/src/misc.c b/src/libgame/misc.c similarity index 99% rename from src/misc.c rename to src/libgame/misc.c index a87a9b32..bfc6d454 100644 --- a/src/misc.c +++ b/src/libgame/misc.c @@ -11,8 +11,6 @@ * misc.c * ***********************************************************/ -#include "platform.h" - #include #include #include @@ -24,13 +22,13 @@ #include #endif +#include "libgame.h" + +#include "main_TMP.h" + #include "misc.h" -#include "init.h" -#include "tools.h" -#include "sound.h" -#include "random.h" -#include "joystick.h" -#include "files.h" + +#include "joystick_TMP.h" #if defined(PLATFORM_MSDOS) volatile unsigned long counter = 0; diff --git a/src/misc.h b/src/libgame/misc.h similarity index 98% rename from src/misc.h rename to src/libgame/misc.h index e376cd26..3002844e 100644 --- a/src/misc.h +++ b/src/libgame/misc.h @@ -14,7 +14,10 @@ #ifndef MISC_H #define MISC_H -#include "main.h" +#include +#include + +#include "libgame.h" /* values for InitCounter() and Counter() */ #define INIT_COUNTER 0 diff --git a/src/msdos.c b/src/libgame/msdos.c similarity index 99% rename from src/msdos.c rename to src/libgame/msdos.c index 960609df..cc8aedd7 100644 --- a/src/msdos.c +++ b/src/libgame/msdos.c @@ -12,19 +12,10 @@ * msdos.c * ***********************************************************/ -#include "platform.h" +#include "libgame.h" #if defined(PLATFORM_MSDOS) -#include "main.h" -#include "misc.h" -#include "tools.h" -#include "sound.h" -#include "files.h" -#include "joystick.h" -#include "image.h" -#include "pcx.h" - /* allegro driver declarations */ DECLARE_GFX_DRIVER_LIST(GFX_DRIVER_VBEAF GFX_DRIVER_VESA2L GFX_DRIVER_VESA1) DECLARE_COLOR_DEPTH_LIST(COLOR_DEPTH_8) diff --git a/src/msdos.h b/src/libgame/msdos.h similarity index 100% rename from src/msdos.h rename to src/libgame/msdos.h diff --git a/src/pcx.c b/src/libgame/pcx.c similarity index 100% rename from src/pcx.c rename to src/libgame/pcx.c diff --git a/src/pcx.h b/src/libgame/pcx.h similarity index 94% rename from src/pcx.h rename to src/libgame/pcx.h index 47250992..f214971b 100644 --- a/src/pcx.h +++ b/src/libgame/pcx.h @@ -14,10 +14,9 @@ #ifndef PCX_H #define PCX_H -#ifndef TARGET_SDL +#include "libgame.h" -#include "main.h" -#include "image.h" +#if !defined(TARGET_SDL) #define PCX_Success 0 #define PCX_OpenFailed -1 diff --git a/src/platform.h b/src/libgame/platform.h similarity index 100% rename from src/platform.h rename to src/libgame/platform.h diff --git a/src/libgame/private.c b/src/libgame/private.c new file mode 100644 index 00000000..90de58af --- /dev/null +++ b/src/libgame/private.c @@ -0,0 +1,22 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * +*----------------------------------------------------------* +* private.c * +***********************************************************/ + +#include "libgame.h" + +#if 0 +Display *display; +Visual *visual; +int screen; + +DrawWindow window = None; +#endif diff --git a/src/libgame/private.h b/src/libgame/private.h new file mode 100644 index 00000000..e79f00d9 --- /dev/null +++ b/src/libgame/private.h @@ -0,0 +1,27 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * +*----------------------------------------------------------* +* private.h * +***********************************************************/ + +#ifndef PRIVATE_H +#define PRIVATE_H + +#include "libgame.h" + +#if 0 +extern Display *display; +extern Visual *visual; +extern int screen; + +extern DrawWindow window; +#endif + +#endif /* PRIVATE_H */ diff --git a/src/random.c b/src/libgame/random.c similarity index 100% rename from src/random.c rename to src/libgame/random.c diff --git a/src/random.h b/src/libgame/random.h similarity index 100% rename from src/random.h rename to src/libgame/random.h diff --git a/src/sdl.c b/src/libgame/sdl.c similarity index 94% rename from src/sdl.c rename to src/libgame/sdl.c index 6e4b781b..8e2ec948 100644 --- a/src/sdl.c +++ b/src/libgame/sdl.c @@ -12,10 +12,9 @@ * sdl.c * ***********************************************************/ -#ifdef TARGET_SDL +#include "libgame.h" -#include "main.h" -#include "misc.h" +#ifdef TARGET_SDL inline void SDLInitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) { @@ -53,11 +52,11 @@ inline void SDLInitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) pix[PIX_DB_BACK] = *backbuffer; /* 'backbuffer' is SDL screen buffer */ } -inline boolean SDLSetVideoMode(DrawBuffer *backbuffer) +inline boolean SDLSetVideoMode(DrawBuffer *backbuffer, boolean fullscreen) { boolean success = TRUE; - if (setup.fullscreen && !fullscreen_enabled && fullscreen_available) + if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available) { /* switch display to fullscreen mode, if available */ DrawWindow window_old = *backbuffer; @@ -71,7 +70,7 @@ inline boolean SDLSetVideoMode(DrawBuffer *backbuffer) Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError()); /* do not try it again */ - fullscreen_available = FALSE; + video.fullscreen_available = FALSE; success = FALSE; } else @@ -80,12 +79,12 @@ inline boolean SDLSetVideoMode(DrawBuffer *backbuffer) SDL_FreeSurface(window_old); *backbuffer = window_new; - fullscreen_enabled = TRUE; + video.fullscreen_enabled = TRUE; success = TRUE; } } - if ((!setup.fullscreen && fullscreen_enabled) || !*backbuffer) + if ((!fullscreen && video.fullscreen_enabled) || !*backbuffer) { /* switch display to window mode */ DrawWindow window_old = *backbuffer; @@ -106,7 +105,7 @@ inline boolean SDLSetVideoMode(DrawBuffer *backbuffer) SDL_FreeSurface(window_old); *backbuffer = window_new; - fullscreen_enabled = FALSE; + video.fullscreen_enabled = FALSE; success = TRUE; } } diff --git a/src/sdl.h b/src/libgame/sdl.h similarity index 99% rename from src/sdl.h rename to src/libgame/sdl.h index cd503c1d..f150e7df 100644 --- a/src/sdl.h +++ b/src/libgame/sdl.h @@ -297,7 +297,7 @@ typedef int Colormap; /* SDL function definitions */ inline void SDLInitBufferedDisplay(DrawBuffer *, DrawWindow *); -inline boolean SDLSetVideoMode(DrawBuffer *); +inline boolean SDLSetVideoMode(DrawBuffer *, boolean); inline void SDLCopyArea(SDL_Surface *, SDL_Surface *, int, int, int, int, int, int); inline void SDLFillRectangle(SDL_Surface *, int, int, int, int, unsigned int); diff --git a/src/sound.c b/src/libgame/sound.c similarity index 98% rename from src/sound.c rename to src/libgame/sound.c index 91da5d7d..745e3cd9 100644 --- a/src/sound.c +++ b/src/libgame/sound.c @@ -11,6 +11,10 @@ * sound.c * ***********************************************************/ +#include "libgame.h" + +#include "main_TMP.h" + #include "sound.h" #include "misc.h" @@ -58,7 +62,7 @@ int OpenAudioDevice(char *audio_device_name) int audio_fd; /* check if desired audio device is accessible */ - if (access(sound_device_name, W_OK) != 0) + if (access(audio_device_name, W_OK) != 0) return -1; /* try to open audio device in non-blocking mode */ @@ -79,12 +83,12 @@ void UnixOpenAudio(struct AudioSystemInfo *audio) DEVICENAME_DSP, DEVICENAME_AUDIO }; - int audio_fd; + int audio_fd = -1; int i; /* look for available audio devices, starting with preferred ones */ for (i=0; i= 0) + if ((audio_fd = OpenAudioDevice(audio_device_name[i])) >= 0) break; if (audio_fd < 0) @@ -95,6 +99,7 @@ void UnixOpenAudio(struct AudioSystemInfo *audio) close(audio_fd); + audio->device_name = audio_device_name[i]; audio->sound_available = TRUE; #if defined(AUDIO_STREAMING_DSP) @@ -202,7 +207,7 @@ void SoundServer() #endif if (playing_sounds || - (audio.device_fd = OpenAudioDevice(sound_device_name)) >= 0) + (audio.device_fd = OpenAudioDevice(audio.device_name)) >= 0) { if (!playing_sounds) /* we just opened the audio device */ { @@ -365,7 +370,7 @@ void SoundServer() int wait_percent = 90; /* wait 90% of the real playing time */ int i; - if ((audio.device_fd = OpenAudioDevice(sound_device_name)) >= 0) + if ((audio.device_fd = OpenAudioDevice(audio.device_name)) >= 0) { playing_sounds = 1; diff --git a/src/sound.h b/src/libgame/sound.h similarity index 98% rename from src/sound.h rename to src/libgame/sound.h index 16fe71de..199ef755 100644 --- a/src/sound.h +++ b/src/libgame/sound.h @@ -14,8 +14,6 @@ #ifndef SOUND_H #define SOUND_H -#include "platform.h" - #include #include @@ -31,7 +29,7 @@ #define SND_BLOCKSIZE 32768 #endif -#include "main.h" +#include "libgame.h" #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE) #define AUDIO_STREAMING_DSP @@ -86,11 +84,13 @@ #define DEVICENAME_AUDIO "/dev/audio" #define DEVICENAME_AUDIOCTL "/dev/audioCtl" +#if 0 #if defined(AUDIO_STREAMING_DSP) #define AUDIO_DEVICE DEVICENAME_DSP #else #define AUDIO_DEVICE DEVICENAME_AUDIO #endif +#endif struct SoundHeader_SUN { diff --git a/src/system.c b/src/libgame/system.c similarity index 86% rename from src/system.c rename to src/libgame/system.c index 37ca4841..5a55f1c2 100644 --- a/src/system.c +++ b/src/libgame/system.c @@ -12,9 +12,31 @@ * system.c * ***********************************************************/ -#include "main.h" -#include "misc.h" -#include "sound.h" +#include "libgame.h" + + +/* ========================================================================= */ +/* internal variables */ +/* ========================================================================= */ + +Display *display; +Visual *visual; +int screen; +Colormap cmap; + +DrawWindow window = None; +GC gc; + +int FrameCounter; + + +/* ========================================================================= */ +/* exported variables */ +/* ========================================================================= */ + +struct VideoSystemInfo video; +struct AudioSystemInfo audio; +struct OptionInfo options; /* ========================================================================= */ @@ -23,6 +45,9 @@ inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) { + video.fullscreen_available = FULLSCREEN_STATUS; + video.fullscreen_enabled = FALSE; + #ifdef TARGET_SDL SDLInitBufferedDisplay(backbuffer, window); #else @@ -199,19 +224,19 @@ inline boolean PointerInWindow(DrawWindow window) #endif } -inline boolean SetVideoMode(void) +inline boolean SetVideoMode(boolean fullscreen) { #ifdef TARGET_SDL - return SDLSetVideoMode(&backbuffer); + return SDLSetVideoMode(&backbuffer, fullscreen); #else boolean success = TRUE; - if (setup.fullscreen && fullscreen_available) + if (fullscreen && video.fullscreen_available) { Error(ERR_WARN, "fullscreen not available in X11 version"); /* display error message only once */ - fullscreen_available = FALSE; + video.fullscreen_available = FALSE; success = FALSE; } @@ -220,13 +245,15 @@ inline boolean SetVideoMode(void) #endif } -inline void ChangeVideoModeIfNeeded(void) +inline boolean ChangeVideoModeIfNeeded(boolean fullscreen) { #ifdef TARGET_SDL - if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || - (!setup.fullscreen && fullscreen_enabled)) - SetVideoMode(); + if ((fullscreen && !video.fullscreen_enabled && video.fullscreen_available)|| + (!fullscreen && video.fullscreen_enabled)) + fullscreen = SetVideoMode(fullscreen_wanted); #endif + + return fullscreen; } @@ -240,6 +267,7 @@ inline boolean OpenAudio(struct AudioSystemInfo *audio) audio->loops_available = FALSE; audio->soundserver_pipe[0] = audio->soundserver_pipe[1] = 0; audio->soundserver_pid = 0; + audio->device_name = NULL; audio->device_fd = 0; #if defined(TARGET_SDL) diff --git a/src/system.h b/src/libgame/system.h similarity index 70% rename from src/system.h rename to src/libgame/system.h index fdfb4a6a..fe805c8a 100644 --- a/src/system.h +++ b/src/libgame/system.h @@ -15,7 +15,7 @@ #ifndef SYSTEM_H #define SYSTEM_H -#include "platform.h" +#include "libgame.h" #if defined(PLATFORM_MSDOS) #include "msdos.h" @@ -43,15 +43,58 @@ typedef int (*EventFilter)(const Event *); /* structure definitions */ +struct VideoSystemInfo +{ + boolean fullscreen_available; + boolean fullscreen_enabled; +}; + struct AudioSystemInfo { boolean sound_available; boolean loops_available; int soundserver_pipe[2]; int soundserver_pid; + char *device_name; int device_fd; }; +struct OptionInfo +{ + char *display_name; + char *server_host; + int server_port; + char *ro_base_directory; + char *rw_base_directory; + char *level_directory; + boolean serveronly; + boolean network; + boolean verbose; + boolean debug; +}; + + +/* ========================================================================= */ +/* exported variables */ +/* ========================================================================= */ + +extern struct VideoSystemInfo video; +extern struct AudioSystemInfo audio; +extern struct OptionInfo options; + + +/* declarations of internal variables */ + +extern Display *display; +extern Visual *visual; +extern int screen; +extern Colormap cmap; + +extern DrawWindow window; +extern GC gc; + +extern int FrameCounter; + /* function definitions */ @@ -70,8 +113,8 @@ inline void SyncDisplay(void); inline void KeyboardAutoRepeatOn(void); inline void KeyboardAutoRepeatOff(void); inline boolean PointerInWindow(DrawWindow); -inline boolean SetVideoMode(void); -inline void ChangeVideoModeIfNeeded(void); +inline boolean SetVideoMode(boolean); +inline boolean ChangeVideoModeIfNeeded(boolean); inline boolean OpenAudio(struct AudioSystemInfo *); inline void CloseAudio(struct AudioSystemInfo *); diff --git a/src/libgame/text.c b/src/libgame/text.c new file mode 100644 index 00000000..28f88c56 --- /dev/null +++ b/src/libgame/text.c @@ -0,0 +1,156 @@ +/*********************************************************** +* 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 * +*----------------------------------------------------------* +* text.c * +***********************************************************/ + +#include + +#include "libgame.h" + +#include "main_TMP.h" + +int getFontWidth(int font_size, int font_type) +{ + return (font_size == FS_BIG ? FONT1_XSIZE : + font_size == FS_MEDIUM ? FONT6_XSIZE : + font_type == FC_SPECIAL1 ? FONT3_XSIZE : + font_type == FC_SPECIAL2 ? FONT4_XSIZE : + font_type == FC_SPECIAL3 ? FONT5_XSIZE : + FONT2_XSIZE); +} + +int getFontHeight(int font_size, int font_type) +{ + return (font_size == FS_BIG ? FONT1_YSIZE : + font_size == FS_MEDIUM ? FONT6_YSIZE : + font_type == FC_SPECIAL1 ? FONT3_YSIZE : + font_type == FC_SPECIAL2 ? FONT4_YSIZE : + font_type == FC_SPECIAL3 ? FONT5_YSIZE : + FONT2_YSIZE); +} + +void DrawInitText(char *text, int ypos, int color) +{ + if (window && pix[PIX_SMALLFONT]) + { + ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE); + DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2, + ypos, text, FS_SMALL, color); + FlushDisplay(); + } +} + +void DrawTextFCentered(int y, int font_type, char *format, ...) +{ + char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; + int font_width = getFontWidth(FS_SMALL, font_type); + va_list ap; + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, SY + y, + buffer, FS_SMALL, font_type); +} + +void DrawTextF(int x, int y, int font_type, char *format, ...) +{ + char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; + va_list ap; + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + DrawText(SX + x, SY + y, buffer, FS_SMALL, font_type); +} + +void DrawText(int x, int y, char *text, int font_size, int font_type) +{ + DrawTextExt(drawto, gc, x, y, text, font_size, font_type); + + if (x < DX) + redraw_mask |= REDRAW_FIELD; + else if (y < VY) + redraw_mask |= REDRAW_DOOR_1; +} + +void DrawTextExt(DrawBuffer d, GC gc, int x, int y, + char *text, int font_size, int font_type) +{ + int font_width, font_height, font_start; + int font_bitmap; + boolean print_inverse = FALSE; + + if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM) + font_size = FS_SMALL; + if (font_type < FC_RED || font_type > FC_SPECIAL3) + font_type = FC_RED; + + font_width = getFontWidth(font_size, font_type); + font_height = getFontHeight(font_size, font_type); + + font_bitmap = (font_size == FS_BIG ? PIX_BIGFONT : + font_size == FS_MEDIUM ? PIX_MEDIUMFONT : + PIX_SMALLFONT); + font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : + font_size == FS_MEDIUM ? FONT6_YSIZE : + FONT2_YSIZE) * + FONT_LINES_PER_FONT); + + if (font_type == FC_SPECIAL3) + font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT; + + while (*text) + { + char c = *text++; + + if (c == '~' && font_size == FS_SMALL) + { + print_inverse = TRUE; + continue; + } + + if (c >= 'a' && c <= 'z') + c = 'A' + (c - 'a'); + else if (c == 'ä' || c == 'Ä') + c = 91; + else if (c == 'ö' || c == 'Ö') + c = 92; + else if (c == 'ü' || c == 'Ü') + c = 93; + + if (c >= 32 && c <= 95) + { + int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width; + int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start; + int dest_x = x, dest_y = y; + + if (print_inverse) + { + BlitBitmap(pix[font_bitmap], d, + FONT_CHARS_PER_LINE * font_width, + 3 * font_height + font_start, + font_width, font_height, x, y); + + SetClipOrigin(clip_gc[font_bitmap], dest_x - src_x, dest_y - src_y); + BlitBitmapMasked(pix_masked[font_bitmap], d, + 0, 0, font_width, font_height, dest_x, dest_y); + } + else + BlitBitmap(pix[font_bitmap], d, + src_x, src_y, font_width, font_height, dest_x, dest_y); + } + + x += font_width; + } +} diff --git a/src/libgame/text.h b/src/libgame/text.h new file mode 100644 index 00000000..57fa7e13 --- /dev/null +++ b/src/libgame/text.h @@ -0,0 +1,27 @@ +/*********************************************************** +* 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 * +*----------------------------------------------------------* +* text.h * +***********************************************************/ + +#ifndef TEXT_H +#define TEXT_H + +#include "libgame.h" + +int getFontWidth(int, int); +int getFontHeight(int, int); +void DrawInitText(char *, int, int); +void DrawTextF(int, int, int, char *, ...); +void DrawTextFCentered(int, int, char *, ...); +void DrawText(int, int, char *, int, int); +void DrawTextExt(DrawBuffer, GC, int, int, char *, int, int); + +#endif /* TEXT_H */ diff --git a/src/libgame/types.h b/src/libgame/types.h new file mode 100644 index 00000000..e4aad2a3 --- /dev/null +++ b/src/libgame/types.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 * +*----------------------------------------------------------* +* types.h * +***********************************************************/ + +#ifndef TYPES_H +#define TYPES_H + +typedef unsigned char boolean; +typedef unsigned char byte; + +#ifndef FALSE +#define FALSE 0 +#define TRUE (!FALSE) +#endif + +#endif /* TYPES_H */ diff --git a/src/x11.c b/src/libgame/x11.c similarity index 99% rename from src/x11.c rename to src/libgame/x11.c index 3c60b153..9de89c95 100644 --- a/src/x11.c +++ b/src/libgame/x11.c @@ -12,10 +12,11 @@ * x11.c * ***********************************************************/ +#include "libgame.h" + #if defined(TARGET_X11) -#include "main.h" -#include "misc.h" +#include "main_TMP.h" struct IconFileInfo { diff --git a/src/x11.h b/src/libgame/x11.h similarity index 100% rename from src/x11.h rename to src/libgame/x11.h diff --git a/src/main.c b/src/main.c index 8d927cb1..8bf9e775 100644 --- a/src/main.c +++ b/src/main.c @@ -11,31 +11,36 @@ * main.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "main.h" #include "init.h" #include "game.h" #include "events.h" -#include "sound.h" #include "joystick.h" -#include "misc.h" #if defined(PLATFORM_MSDOS) #include #endif -Display *display; -Visual *visual; -int screen; +#if 0 DrawWindow window = None; -GC gc, clip_gc[NUM_BITMAPS], tile_clip_gc; +GC gc; +#endif + +GC clip_gc[NUM_BITMAPS], tile_clip_gc; Bitmap pix[NUM_BITMAPS]; Bitmap pix_masked[NUM_BITMAPS], tile_masked[NUM_TILES]; Pixmap clipmask[NUM_BITMAPS], tile_clipmask[NUM_TILES]; DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer; +#if 0 Colormap cmap; +#endif +#if 0 char *sound_device_name = AUDIO_DEVICE; +#endif int joystick_device = 0; char *joystick_device_name[MAX_PLAYERS] = @@ -56,8 +61,11 @@ boolean motion_status = FALSE; int key_joystick_mapping = 0; int global_joystick_status = JOYSTICK_STATUS; int joystick_status = JOYSTICK_STATUS; + +#if 0 boolean fullscreen_available = FULLSCREEN_STATUS; boolean fullscreen_enabled = FALSE; +#endif boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; int redraw_x1 = 0, redraw_y1 = 0; @@ -94,7 +102,12 @@ int SBX_Left, SBX_Right; int SBY_Upper, SBY_Lower; int ZX,ZY, ExitX,ExitY; int AllPlayersGone; -int FrameCounter, TimeFrames, TimePlayed, TimeLeft; + +#if 0 +int FrameCounter; +#endif + +int TimeFrames, TimePlayed, TimeLeft; boolean network_player_action_received = FALSE; @@ -104,10 +117,19 @@ struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL; struct HiScore highscore[MAX_SCORE_ENTRIES]; struct SampleInfo Sound[NUM_SOUNDS]; struct TapeInfo tape; + +#if 0 struct OptionInfo options; +#endif + struct SetupInfo setup; struct GameInfo game; + +#if 0 +struct VideoSystemInfo video; struct AudioSystemInfo audio; +#endif + struct GlobalInfo global; /* data needed for playing sounds */ diff --git a/src/main.h b/src/main.h index 3eb6993d..c53408b2 100644 --- a/src/main.h +++ b/src/main.h @@ -28,10 +28,9 @@ #define DEBUG_TIMING 0 #endif -typedef unsigned char boolean; -typedef unsigned char byte; - -#include "system.h" +#if 0 +#include "libgame/libgame.h" +#endif #ifndef FALSE #define FALSE 0 @@ -238,20 +237,6 @@ struct HiScore int Score; }; -struct OptionInfo -{ - char *display_name; - char *server_host; - int server_port; - char *ro_base_directory; - char *rw_base_directory; - char *level_directory; - boolean serveronly; - boolean network; - boolean verbose; - boolean debug; -}; - struct SetupJoystickInfo { char *device_name; @@ -451,19 +436,24 @@ struct GlobalInfo int fps_slowdown_factor; }; -extern Display *display; -extern Visual *visual; -extern int screen; +#if 0 extern DrawWindow window; -extern GC gc, clip_gc[], tile_clip_gc; +extern GC gc; +#endif + +extern GC clip_gc[], tile_clip_gc; extern Bitmap pix[]; extern Bitmap pix_masked[], tile_masked[]; extern Pixmap clipmask[], tile_clipmask[]; extern DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer; +#if 0 extern Colormap cmap; +#endif +#if 0 extern char *sound_device_name; +#endif extern int joystick_device; extern char *joystick_device_name[]; @@ -477,8 +467,11 @@ extern int button_status; extern boolean motion_status; extern int key_joystick_mapping; extern int global_joystick_status, joystick_status; + +#if 0 extern boolean fullscreen_available; extern boolean fullscreen_enabled; +#endif extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; extern int redraw_x1, redraw_y1; @@ -514,7 +507,12 @@ extern int SBX_Left, SBX_Right; extern int SBY_Upper, SBY_Lower; extern int ZX,ZY, ExitX,ExitY; extern int AllPlayersGone; -extern int FrameCounter, TimeFrames, TimePlayed, TimeLeft; + +#if 0 +extern int FrameCounter; +#endif + +extern int TimeFrames, TimePlayed, TimeLeft; extern boolean SiebAktiv; extern int SiebCount; @@ -527,10 +525,19 @@ extern struct HiScore highscore[]; extern struct TapeInfo tape; extern struct SampleInfo Sound[]; extern struct JoystickInfo joystick[]; + +#if 0 extern struct OptionInfo options; +#endif + extern struct SetupInfo setup; extern struct GameInfo game; + +#if 0 +extern struct VideoSystemInfo video; extern struct AudioSystemInfo audio; +#endif + extern struct GlobalInfo global; extern char *sound_name[]; diff --git a/src/netserv.c b/src/netserv.c index 2e356e92..6a2479e5 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -11,7 +11,7 @@ * network.c * ***********************************************************/ -#include "platform.h" +#include "libgame/libgame.h" #if defined(PLATFORM_UNIX) @@ -26,8 +26,11 @@ #include #include +#if 0 +#include "libgame/libgame.h" +#endif + #include "netserv.h" -#include "misc.h" static int clients = 0; static int onceonly = 0; diff --git a/src/network.c b/src/network.c index e3a07c64..410695be 100644 --- a/src/network.c +++ b/src/network.c @@ -11,7 +11,7 @@ * network.c * ***********************************************************/ -#include "platform.h" +#include "libgame/libgame.h" #if defined(PLATFORM_UNIX) @@ -24,15 +24,17 @@ #include #include +#if 0 +#include "libgame/libgame.h" +#endif + #include "network.h" #include "netserv.h" #include "game.h" #include "tape.h" #include "files.h" #include "tools.h" -#include "buttons.h" #include "screens.h" -#include "misc.h" struct NetworkClientPlayerInfo { diff --git a/src/screens.c b/src/screens.c index e4be1318..43027323 100644 --- a/src/screens.c +++ b/src/screens.c @@ -11,15 +11,14 @@ * screens.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "screens.h" #include "events.h" -#include "sound.h" #include "game.h" #include "tools.h" #include "editor.h" -#include "misc.h" #include "files.h" -#include "buttons.h" #include "tape.h" #include "joystick.h" #include "cartoons.h" @@ -85,7 +84,7 @@ void DrawMainMenu() UndrawSpecialEditorDoor(); /* needed if last screen was the setup screen and fullscreen state changed */ - ChangeVideoModeIfNeeded(); + setup.fullscreen = ChangeVideoModeIfNeeded(setup.fullscreen); #ifdef TARGET_SDL SetDrawtoField(DRAW_BACKBUFFER); #endif @@ -1500,7 +1499,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) setup.fading = !setup.fading; } #endif - else if (y == 8 && fullscreen_available) + else if (y == 8 && video.fullscreen_available) { if (setup.fullscreen) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); diff --git a/src/tape.c b/src/tape.c index 49fa39ae..7a5d5ff3 100644 --- a/src/tape.c +++ b/src/tape.c @@ -11,10 +11,10 @@ * tape.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "tape.h" -#include "misc.h" #include "game.h" -#include "buttons.h" #include "tools.h" #include "files.h" #include "network.h" diff --git a/src/tools.c b/src/tools.c index 423ce49d..61e1bac1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -13,16 +13,15 @@ #include -#ifdef __FreeBSD__ +#if defined(PLATFORM_FREEBSD) #include #endif +#include "libgame/libgame.h" + #include "tools.h" #include "game.h" #include "events.h" -#include "sound.h" -#include "misc.h" -#include "buttons.h" #include "joystick.h" #include "cartoons.h" #include "network.h" @@ -352,6 +351,8 @@ void ClearWindow() redraw_mask |= REDRAW_FIELD; } + +#if 0 int getFontWidth(int font_size, int font_type) { return (font_size == FS_BIG ? FONT1_XSIZE : @@ -489,6 +490,8 @@ void DrawTextExt(DrawBuffer d, GC gc, int x, int y, x += font_width; } } +#endif + void DrawAllPlayers() { @@ -2365,10 +2368,12 @@ static struct } }; +#if 0 static void DoNotDisplayInfoText(void *ptr) { return; } +#endif void CreateToolButtons() { @@ -2416,8 +2421,12 @@ void CreateToolButtons() GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY, GDI_DECORATION_SHIFTING, 1, 1, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK_ACTION, HandleToolButtons, + +#if 0 GDI_CALLBACK_INFO, DoNotDisplayInfoText, +#endif + + GDI_CALLBACK_ACTION, HandleToolButtons, GDI_END); if (gi == NULL) diff --git a/src/tools.h b/src/tools.h index 0fc1f2da..721aa002 100644 --- a/src/tools.h +++ b/src/tools.h @@ -62,6 +62,8 @@ void SetDrawtoField(int); void BackToFront(); void FadeToFront(); void ClearWindow(); + +#if 0 int getFontWidth(int, int); int getFontHeight(int, int); void DrawInitText(char *, int, int); @@ -69,6 +71,8 @@ void DrawTextF(int, int, int, char *, ...); void DrawTextFCentered(int, int, char *, ...); void DrawText(int, int, char *, int, int); void DrawTextExt(DrawBuffer, GC, int, int, char *, int, int); +#endif + void DrawAllPlayers(void); void DrawPlayerField(int, int); void DrawPlayer(struct PlayerInfo *); @@ -116,4 +120,4 @@ void CreateToolButtons(); int el2gfx(int); -#endif +#endif /* TOOLS_H */ -- 2.34.1