From 222cd4187e6632bd904a937f167a2f1c70b8f66d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 2 Dec 2000 03:05:20 +0100 Subject: [PATCH] rnd-20001202-2-src --- src/init.c | 18 ++++--- src/libgame/Makefile | 4 +- src/libgame/{buttons.c => gadgets.c} | 4 +- src/libgame/{buttons.h => gadgets.h} | 8 ++-- src/libgame/image.c | 2 + src/libgame/image.h | 5 ++ src/libgame/libgame.h | 2 +- src/libgame/misc.c | 2 + src/libgame/msdos.c | 72 +++++++++++++--------------- src/libgame/msdos.h | 3 +- src/libgame/sdl.c | 2 +- src/libgame/sdl.h | 2 +- src/libgame/sound.h | 5 +- src/libgame/system.c | 28 +++++++---- src/libgame/system.h | 9 +++- src/libgame/x11.c | 12 ----- src/main.c | 3 +- src/main.h | 7 ++- 18 files changed, 105 insertions(+), 83 deletions(-) rename src/libgame/{buttons.c => gadgets.c} (99%) rename src/libgame/{buttons.h => gadgets.h} (98%) diff --git a/src/init.c b/src/init.c index adfd3f2c..3a0c54ed 100644 --- a/src/init.c +++ b/src/init.c @@ -310,15 +310,19 @@ void InitJoysticks() void InitDisplay() { - char *x11_icon_filename = getPath3(options.ro_base_directory, - GRAPHICS_DIRECTORY, - "rocks_icon.xbm"); - char *x11_iconmask_filename = getPath3(options.ro_base_directory, - GRAPHICS_DIRECTORY, - "rocks_iconmask.xbm"); + char *gfx_dir = getPath2(options.ro_base_directory, GRAPHICS_DIRECTORY); + char *x11_icon_filename = getPath2(gfx_dir, X11_ICON_FILENAME); + char *x11_iconmask_filename = getPath2(gfx_dir, X11_ICONMASK_FILENAME); + char *msdos_pointer_filename = getPath2(gfx_dir, MSDOS_POINTER_FILENAME); + + free(gfx_dir); InitProgramInfo(program_name, PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, - ICON_TITLE_STRING, x11_icon_filename, x11_iconmask_filename); + ICON_TITLE_STRING, x11_icon_filename, x11_iconmask_filename, + msdos_pointer_filename); + + InitScrollbufferSize(FXSIZE, FYSIZE); /* (only needed for MS-DOS code) */ + InitVideoDisplay(); InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); diff --git a/src/libgame/Makefile b/src/libgame/Makefile index f096730d..c325fef5 100644 --- a/src/libgame/Makefile +++ b/src/libgame/Makefile @@ -6,7 +6,7 @@ SRCS = libgame.c \ private.c \ system.c \ - buttons.c \ + gadgets.c \ text.c \ sound.c \ pcx.c \ @@ -20,7 +20,7 @@ SRCS = libgame.c \ OBJS = libgame.o \ private.o \ system.o \ - buttons.o \ + gadgets.o \ text.o \ sound.o \ pcx.o \ diff --git a/src/libgame/buttons.c b/src/libgame/gadgets.c similarity index 99% rename from src/libgame/buttons.c rename to src/libgame/gadgets.c index 3fad7560..9827fc80 100644 --- a/src/libgame/buttons.c +++ b/src/libgame/gadgets.c @@ -8,7 +8,7 @@ * phone: ++49 +521 290471 * * email: aeglos@valinor.owl.de * *----------------------------------------------------------* -* buttons.c * +* gadgets.c * ***********************************************************/ #include @@ -17,7 +17,7 @@ #include "main_TMP.h" -#include "buttons.h" +#include "gadgets.h" /* some positions in the video tape control window */ #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS) diff --git a/src/libgame/buttons.h b/src/libgame/gadgets.h similarity index 98% rename from src/libgame/buttons.h rename to src/libgame/gadgets.h index 38fbe634..44a64f5f 100644 --- a/src/libgame/buttons.h +++ b/src/libgame/gadgets.h @@ -8,11 +8,11 @@ * phone: ++49 +521 290471 * * email: aeglos@valinor.owl.de * *----------------------------------------------------------* -* buttons.h * +* gadgets.h * ***********************************************************/ -#ifndef BUTTONS_H -#define BUTTONS_H +#ifndef GADGETS_H +#define GADGETS_H #include "libgame.h" @@ -262,4 +262,4 @@ void ClickOnGadget(struct GadgetInfo *, int); void HandleGadgets(int, int, int); void HandleGadgetsKeyInput(Key); -#endif +#endif /* GADGETS_H */ diff --git a/src/libgame/image.c b/src/libgame/image.c index 9dd4c249..b83de19f 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -11,6 +11,8 @@ * image.c * ***********************************************************/ +#include "platform.h" + #if defined(TARGET_X11) #include "image.h" diff --git a/src/libgame/image.h b/src/libgame/image.h index 4f55fe3a..1257dda1 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -18,8 +18,13 @@ #ifndef TARGET_SDL +#include "types.h" +#include "system.h" + +/* #include "types.h" #include "x11.h" +*/ #define MAX_COLORS 256 /* maximal number of colors for each image */ diff --git a/src/libgame/libgame.h b/src/libgame/libgame.h index b2af1408..95dba9b3 100644 --- a/src/libgame/libgame.h +++ b/src/libgame/libgame.h @@ -19,7 +19,7 @@ #include "private.h" #include "system.h" #include "random.h" -#include "buttons.h" +#include "gadgets.h" #include "text.h" #include "sound.h" #include "image.h" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 29e23929..572ff360 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -17,6 +17,8 @@ #include #include +#include "libgame.h" + #if !defined(PLATFORM_WIN32) #include #include diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index cc8aedd7..782369c1 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -16,6 +16,8 @@ #if defined(PLATFORM_MSDOS) +#define AllegroDefaultScreen() (display->screens[display->default_screen]) + /* allegro driver declarations */ DECLARE_GFX_DRIVER_LIST(GFX_DRIVER_VBEAF GFX_DRIVER_VESA2L GFX_DRIVER_VESA1) DECLARE_COLOR_DEPTH_LIST(COLOR_DEPTH_8) @@ -238,10 +240,10 @@ void XMapWindow(Display *display, Window window) unsigned int width, height; boolean mouse_off; - x = display->screens[display->default_screen].x; - y = display->screens[display->default_screen].y; - width = display->screens[display->default_screen].width; - height = display->screens[display->default_screen].height; + x = AllegroDefaultScreen().x; + y = AllegroDefaultScreen().y; + width = AllegroDefaultScreen().width; + height = AllegroDefaultScreen().height; mouse_off = hide_mouse(display, x, y, width, height); blit((BITMAP *)window, video_bitmap, 0, 0, x, y, width, height); @@ -291,14 +293,8 @@ Display *XOpenDisplay(char *display_name) Screen *screen; Display *display; BITMAP *mouse_bitmap = NULL; - char *filename; - - filename = getPath3(options.ro_base_directory, GRAPHICS_DIRECTORY, - MOUSE_FILENAME); - - mouse_bitmap = Read_PCX_to_AllegroBitmap(filename); - free(filename); + mouse_bitmap = Read_PCX_to_AllegroBitmap(program.msdos_pointer_filename); if (mouse_bitmap == NULL) return NULL; @@ -340,11 +336,11 @@ Window XCreateSimpleWindow(Display *display, Window parent, int x, int y, video_bitmap = create_video_bitmap(XRES, YRES); clear_to_color(video_bitmap, background); - display->screens[display->default_screen].video_bitmap = video_bitmap; - display->screens[display->default_screen].x = x; - display->screens[display->default_screen].y = y; - display->screens[display->default_screen].width = XRES; - display->screens[display->default_screen].height = YRES; + AllegroDefaultScreen().video_bitmap = video_bitmap; + AllegroDefaultScreen().x = x; + AllegroDefaultScreen().y = y; + AllegroDefaultScreen().width = XRES; + AllegroDefaultScreen().height = YRES; set_mouse_sprite(display->mouse_ptr); @@ -353,10 +349,10 @@ Window XCreateSimpleWindow(Display *display, Window parent, int x, int y, #endif set_mouse_speed(1, 1); - set_mouse_range(display->screens[display->default_screen].x + 1, - display->screens[display->default_screen].y + 1, - display->screens[display->default_screen].x + WIN_XSIZE + 1, - display->screens[display->default_screen].y + WIN_YSIZE + 1); + set_mouse_range(AllegroDefaultScreen().x + 1, + AllegroDefaultScreen().y + 1, + AllegroDefaultScreen().x + video.width + 1, + AllegroDefaultScreen().y + video.height + 1); show_video_bitmap(video_bitmap); @@ -425,8 +421,8 @@ void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y, if ((BITMAP *)d == video_bitmap) { - x += display->screens[display->default_screen].x; - y += display->screens[display->default_screen].y; + x += AllegroDefaultScreen().x; + y += AllegroDefaultScreen().y; freeze_mouse_flag = TRUE; mouse_off = hide_mouse(display, x, y, width, height); } @@ -446,7 +442,7 @@ Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width, BITMAP *bitmap = NULL; if (gfx_capabilities & GFX_HW_VRAM_BLIT && - width == FXSIZE && height == FYSIZE) + width == video.scrollbuffer_width && height == video.scrollbuffer_height) bitmap = create_video_bitmap(width, height); if (bitmap == NULL) @@ -469,14 +465,14 @@ inline void XCopyArea(Display *display, Drawable src, Drawable dest, GC gc, if ((BITMAP *)src == video_bitmap) { - src_x += display->screens[display->default_screen].x; - src_y += display->screens[display->default_screen].y; + src_x += AllegroDefaultScreen().x; + src_y += AllegroDefaultScreen().y; } if ((BITMAP *)dest == video_bitmap) { - dest_x += display->screens[display->default_screen].x; - dest_y += display->screens[display->default_screen].y; + dest_x += AllegroDefaultScreen().x; + dest_y += AllegroDefaultScreen().y; freeze_mouse_flag = TRUE; mouse_off = hide_mouse(display, dest_x, dest_y, width, height); } @@ -812,8 +808,8 @@ int XPending(Display *display) pending_events++; xmotion = (XMotionEvent *)&event_buffer[pending_events]; xmotion->type = MotionNotify; - xmotion->x = mouse_x - display->screens[display->default_screen].x; - xmotion->y = mouse_y - display->screens[display->default_screen].y; + xmotion->x = mouse_x - AllegroDefaultScreen().x; + xmotion->y = mouse_y - AllegroDefaultScreen().y; } /* mouse button event */ @@ -831,8 +827,8 @@ int XPending(Display *display) xbutton = (XButtonEvent *)&event_buffer[pending_events]; xbutton->type = (mouse_b & bitmask ? ButtonPress : ButtonRelease); xbutton->button = mapping[i]; - xbutton->x = mouse_x - display->screens[display->default_screen].x; - xbutton->y = mouse_y - display->screens[display->default_screen].y; + xbutton->x = mouse_x - AllegroDefaultScreen().x; + xbutton->y = mouse_y - AllegroDefaultScreen().y; } } last_mouse_b = mouse_b; @@ -868,10 +864,10 @@ void XDrawLine(Display *display, Drawable d, GC gc, if ((BITMAP *)d == video_bitmap) { - x1 += display->screens[display->default_screen].x; - y1 += display->screens[display->default_screen].y; - x2 += display->screens[display->default_screen].x; - y2 += display->screens[display->default_screen].y; + x1 += AllegroDefaultScreen().x; + y1 += AllegroDefaultScreen().y; + x2 += AllegroDefaultScreen().x; + y2 += AllegroDefaultScreen().y; freeze_mouse_flag = TRUE; mouse_off = hide_mouse(display, MIN(x1, x2), MIN(y1, y2), MAX(x1, x2) - MIN(x1, x2), @@ -894,8 +890,8 @@ Bool XQueryPointer(Display *display, Window window, Window *root, Window *child, int *root_x, int *root_y, int *win_x, int *win_y, unsigned int *mask) { - *win_x = mouse_x - display->screens[display->default_screen].x; - *win_y = mouse_y - display->screens[display->default_screen].y; + *win_x = mouse_x - AllegroDefaultScreen().x; + *win_y = mouse_y - AllegroDefaultScreen().y; return True; } @@ -916,7 +912,7 @@ boolean MSDOSOpenAudio(void) return allegro_init_audio(); } -boolean MSDOSCloseAudio(void) +void MSDOSCloseAudio(void) { /* nothing to be done here */ } diff --git a/src/libgame/msdos.h b/src/libgame/msdos.h index 26a3f791..12b0bb6d 100644 --- a/src/libgame/msdos.h +++ b/src/libgame/msdos.h @@ -447,7 +447,6 @@ /* end of X11 keyboard mapping */ -#define MOUSE_FILENAME "mouse.pcx" #define JOYSTICK_FILENAME "joystick.cnf" #define screen myscreen @@ -705,7 +704,7 @@ void XAutoRepeatOn(Display *); void XAutoRepeatOff(Display *); boolean MSDOSOpenAudio(void); -boolean MSDOSCloseAudio(void); +void MSDOSCloseAudio(void); void NetworkServer(int, int); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index edb861d9..e732b111 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -53,7 +53,7 @@ inline void SDLInitVideoBuffer(DrawBuffer *backbuffer, DrawWindow *window, should never be drawn to directly, it would do no harm nevertheless. */ /* create additional (symbolic) buffer for double-buffering */ - *window = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); + *window = CreateBitmap(video.width, video.height, video.depth); } inline boolean SDLSetVideoMode(DrawBuffer *backbuffer, boolean fullscreen) diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index a7147130..768dc6fa 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -297,7 +297,7 @@ typedef int Colormap; /* SDL function definitions */ inline void SDLInitVideoDisplay(void); -inline void SDLInitVideoBuffer(DrawBuffer *, DrawWindow *); +inline void SDLInitVideoBuffer(DrawBuffer *, DrawWindow *, boolean); inline boolean SDLSetVideoMode(DrawBuffer *, boolean); inline void SDLCopyArea(SDL_Surface *, SDL_Surface *, int, int, int, int, int, int); diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 199ef755..238a5b19 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -14,9 +14,12 @@ #ifndef SOUND_H #define SOUND_H -#include #include +#if defined(PLATFORM_LINUX) +#include +#endif + #define SND_BLOCKSIZE 4096 #if defined(PLATFORM_LINUX) diff --git a/src/libgame/system.c b/src/libgame/system.c index ee5e87ce..3d26c3ce 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -14,20 +14,20 @@ #include "libgame.h" - /* ========================================================================= */ /* internal variables */ /* ========================================================================= */ -Display *display; -Visual *visual; -int screen; -Colormap cmap; +Display *display = NULL; +Visual *visual = NULL; +int screen = 0; +Colormap cmap = None; DrawWindow window = None; -GC gc; +DrawBuffer backbuffer = None; +GC gc = None; -int FrameCounter; +int FrameCounter = 0; /* ========================================================================= */ @@ -52,7 +52,8 @@ inline static int GetRealDepth(int depth) inline void InitProgramInfo(char *command_name, char *program_title, char *window_title, char *icon_title, char *x11_icon_filename, - char *x11_iconmask_filename) + char *x11_iconmask_filename, + char *msdos_pointer_filename) { program.command_name = command_name; program.program_title = program_title; @@ -60,6 +61,15 @@ inline void InitProgramInfo(char *command_name, char *program_title, program.icon_title = icon_title; program.x11_icon_filename = x11_icon_filename; program.x11_iconmask_filename = x11_iconmask_filename; + program.msdos_pointer_filename = msdos_pointer_filename; +} + +inline void InitScrollbufferSize(int scrollbuffer_width, + int scrollbuffer_height) +{ + /* currently only used by MSDOS code to alloc VRAM buffer, if available */ + video.scrollbuffer_width = scrollbuffer_width; + video.scrollbuffer_height = scrollbuffer_height; } inline void InitVideoDisplay(void) @@ -274,7 +284,7 @@ inline boolean ChangeVideoModeIfNeeded(boolean fullscreen) #ifdef TARGET_SDL if ((fullscreen && !video.fullscreen_enabled && video.fullscreen_available)|| (!fullscreen && video.fullscreen_enabled)) - fullscreen = SetVideoMode(fullscreen_wanted); + fullscreen = SetVideoMode(fullscreen); #endif return fullscreen; diff --git a/src/libgame/system.h b/src/libgame/system.h index 5b9a1ef5..808f752d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -15,7 +15,9 @@ #ifndef SYSTEM_H #define SYSTEM_H +/* #include "libgame.h" +*/ #if defined(PLATFORM_MSDOS) #include "msdos.h" @@ -51,12 +53,14 @@ struct ProgramInfo char *icon_title; char *x11_icon_filename; char *x11_iconmask_filename; + char *msdos_pointer_filename; }; struct VideoSystemInfo { int default_depth; int width, height, depth; + int scrollbuffer_width, scrollbuffer_height; boolean fullscreen_available; boolean fullscreen_enabled; }; @@ -104,6 +108,7 @@ extern int screen; extern Colormap cmap; extern DrawWindow window; +extern DrawBuffer backbuffer; extern GC gc; extern int FrameCounter; @@ -111,7 +116,9 @@ extern int FrameCounter; /* function definitions */ -inline void InitProgramInfo(char *, char *, char *, char *, char *, char *); +inline void InitProgramInfo(char *, char *, char *, char *, char *, char *, + char *); +inline void InitScrollbufferSize(int, int); inline void InitVideoDisplay(void); inline void InitVideoBuffer(DrawBuffer *,DrawWindow *, int, int, int, boolean); inline Bitmap CreateBitmap(int, int, int); diff --git a/src/libgame/x11.c b/src/libgame/x11.c index 5d77d49d..4f0a25e4 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -16,18 +16,6 @@ #if defined(TARGET_X11) -#if 0 -#include "main_TMP.h" -#endif - -#if 0 -struct IconFileInfo -{ - char *picture_filename; - char *picturemask_filename; -}; -#endif - static void X11InitDisplay(); static DrawWindow X11InitWindow(); diff --git a/src/main.c b/src/main.c index 8bf9e775..92e8b38a 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ #if 0 DrawWindow window = None; +DrawBuffer backbuffer; GC gc; #endif @@ -33,7 +34,7 @@ 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; +DrawBuffer drawto, drawto_field, fieldbuffer; #if 0 Colormap cmap; #endif diff --git a/src/main.h b/src/main.h index 9eb316c2..f2ce895c 100644 --- a/src/main.h +++ b/src/main.h @@ -437,6 +437,7 @@ struct GlobalInfo #if 0 extern DrawWindow window; +extern DrawBuffer backbuffer; extern GC gc; #endif @@ -445,7 +446,7 @@ extern Bitmap pix[]; extern Bitmap pix_masked[], tile_masked[]; extern Pixmap clipmask[], tile_clipmask[]; -extern DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer; +extern DrawBuffer drawto, drawto_field, fieldbuffer; #if 0 extern Colormap cmap; #endif @@ -1667,6 +1668,10 @@ extern int num_element_info; #define WINDOW_SUBTITLE_STRING PROGRAM_RIGHTS_STRING " " PROGRAM_AUTHOR_STRING #define ICON_TITLE_STRING PROGRAM_TITLE_STRING +#define X11_ICON_FILENAME "rocks_icon.xbm" +#define X11_ICONMASK_FILENAME "rocks_iconmask.xbm" +#define MSDOS_POINTER_FILENAME "mouse.pcx" + /* default name for empty highscore entry */ #define EMPTY_PLAYER_NAME "no name" -- 2.34.1