boolean picture_with_mask;
};
+#if 0
struct IconFileInfo
{
char *picture_filename;
char *picturemask_filename;
};
+#endif
#ifndef USE_SDL_LIBRARY
static int sound_process_id = 0;
#endif
-static void InitLevelAndPlayerInfo(void);
+static void InitPlayerInfo(void);
+static void InitLevelInfo(void);
static void InitNetworkServer(void);
+#if 0
static void InitDisplay(void);
+#endif
static void InitSound(void);
static void InitSoundServer(void);
+#if 0
static void InitWindow(int, char **);
+#endif
static void InitGfx(void);
+static void InitGfxBackground(void);
static void LoadGfx(int, struct PictureFileInfo *);
static void InitGadgets(void);
static void InitElementProperties(void);
exit(0);
}
+ InitPlayerInfo();
+
InitCounter();
InitSound();
InitSoundServer();
signal(SIGINT, CloseAllAndExit);
signal(SIGTERM, CloseAllAndExit);
+
+ InitBufferedDisplay(&backbuffer, &window);
+ InitEventFilter(FilterMouseMotionEvents);
+
+
+
+#if 0
+
InitDisplay();
InitWindow(argc, argv);
+#if 0
#ifndef USE_SDL_LIBRARY
XMapWindow(display, window);
FlushDisplay();
#endif
+#endif
+
+#endif
+
+
InitGfx();
InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */
- InitLevelAndPlayerInfo();
+ InitLevelInfo();
InitGadgets(); /* needs to know number of level series */
+ InitGfxBackground();
DrawMainMenu();
InitNetworkServer();
}
-void InitLevelAndPlayerInfo()
+void InitPlayerInfo()
{
int i;
local_player->connected = TRUE;
- LoadLevelInfo(); /* global level info */
LoadSetup(); /* global setup info */
+}
+
+void InitLevelInfo()
+{
+ LoadLevelInfo(); /* global level info */
LoadLevelSetup_LastSeries(); /* last played series info */
LoadLevelSetup_SeriesInfo(); /* last played level info */
}
if (SDL_Init(SDL_INIT_AUDIO) < 0)
{
- Error(ERR_WARN, "SDL_Init() failed: %s\n", SDL_GetError());
+ Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError());
sound_status = SOUND_OFF;
return;
}
- if (Mix_OpenAudio(22050, AUDIO_S16, 2, 256) < 0)
+ if (Mix_OpenAudio(22050, AUDIO_S16, 2, 512) < 0)
{
- Error(ERR_WARN, "Mix_OpenAudio() failed: %s\n", SDL_GetError());
+ Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError());
sound_status = SOUND_OFF;
return;
}
return;
}
- if ((sound_device = open(sound_device_name,O_WRONLY))<0)
+ if ((sound_device = OpenAudio(sound_device_name)) < 0)
{
Error(ERR_WARN, "cannot open sound device - no sounds");
sound_status = SOUND_OFF;
if (!LoadSound(&Sound[i]))
{
sound_status = SOUND_OFF;
+ sound_loops_allowed = FALSE;
return;
}
}
void InitJoysticks()
{
-#ifdef USE_SDL_LIBRARY
+#ifdef USE_SDL_JOYSTICK
static boolean sdl_joystick_subsystem_initialized = FALSE;
#endif
joystick_status = JOYSTICK_OFF;
-#ifdef USE_SDL_LIBRARY
+#ifdef USE_SDL_JOYSTICK
if (!sdl_joystick_subsystem_initialized)
{
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
{
- Error(ERR_EXIT, "SDL_Init() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
return;
}
}
joystick_status = JOYSTICK_AVAILABLE;
}
-#else /* !USE_SDL_LIBRARY */
+#else /* !USE_SDL_JOYSTICK */
#ifndef MSDOS
for (i=0; i<MAX_PLAYERS; i++)
#endif /* !USE_SDL_LIBRARY */
}
+
+
+#if 0
+
void InitDisplay()
{
#ifdef USE_SDL_LIBRARY
/* initialize SDL video */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
- Error(ERR_EXIT, "SDL_Init() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
/* automatically cleanup SDL stuff after exit() */
atexit(SDL_Quit);
{
#ifdef USE_SDL_LIBRARY
/* open SDL video output device (window or fullscreen mode) */
- if ((window = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
+#if 0
+ if ((backbuffer = SDL_SetVideoMode(WIN_XSIZE, WIN_YSIZE, WIN_SDL_DEPTH,
SDL_HWSURFACE))
== NULL)
- Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+#else
+ if (!SetVideoMode())
+ Error(ERR_EXIT, "setting video mode failed");
+#endif
/* set window and icon title */
SDL_WM_SetCaption(WINDOW_TITLE_STRING, WINDOW_TITLE_STRING);
#endif /* !USE_SDL_LIBRARY */
}
+#endif
+
+
+
void InitGfx()
{
- int i,j;
+ int i, j;
#ifdef USE_SDL_LIBRARY
SDL_Surface *sdl_image_tmp;
{ -1, 0 }
};
+ /* create additional image buffers for double-buffering */
+
+#if 0
+ pix[PIX_DB_BACK] = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
+#endif
+ pix[PIX_DB_DOOR] = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
+ pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+
+
+
+#if 0
+
+#ifdef USE_SDL_LIBRARY
+
+ /* SDL cannot directly draw to the visible video framebuffer like X11,
+ but always uses a backbuffer, which is then blitted to the visible
+ video framebuffer with 'SDL_UpdateRect' (or replaced with the current
+ visible video framebuffer with 'SDL_Flip', if the hardware supports
+ this). Therefore do not use an additional backbuffer for drawing, but
+ use a symbolic buffer (distinguishable from the SDL backbuffer) called
+ 'window', which indicates that the SDL backbuffer should be updated to
+ the visible video framebuffer when attempting to blit to it.
+
+ For convenience, it seems to be a good idea to create this symbolic
+ buffer 'window' at the same size as the SDL backbuffer. Although it
+ should never be drawn to directly, it would do no harm nevertheless. */
+
+ window = pix[PIX_DB_BACK]; /* 'window' is only symbolic buffer */
+ pix[PIX_DB_BACK] = backbuffer; /* 'backbuffer' is SDL screen buffer */
+
+#endif /* !USE_SDL_LIBRARY */
+
+#endif
+
+
+
#if DEBUG_TIMING
debug_print_timestamp(0, NULL); /* initialize timestamp function */
#endif
#endif
#endif
- LoadGfx(PIX_SMALLFONT,&pic[PIX_SMALLFONT]);
- DrawInitText(WINDOW_TITLE_STRING,20,FC_YELLOW);
- DrawInitText(COPYRIGHT_STRING,50,FC_RED);
+ LoadGfx(PIX_SMALLFONT, &pic[PIX_SMALLFONT]);
+ DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
+ DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
#ifdef MSDOS
- DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
+ DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
rest(200);
#endif /* MSDOS */
DrawInitText("Loading graphics:",120,FC_GREEN);
debug_print_timestamp(0, "SUMMARY LOADING ALL GRAPHICS:");
#endif
-#ifdef USE_SDL_LIBRARY
- /* create some native image surfaces for double-buffer purposes */
-
- /* create double-buffer surface for background image */
- if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
- WIN_XSIZE, WIN_YSIZE,
- WIN_SDL_DEPTH, 0, 0, 0, 0))
- == NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
-
- if ((pix[PIX_DB_BACK] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
-
- SDL_FreeSurface(sdl_image_tmp);
+ /* create additional image buffers for masking of graphics */
- /* create double-buffer surface for door image */
- if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
- 3 * DXSIZE, DYSIZE + VYSIZE,
- WIN_SDL_DEPTH, 0, 0, 0, 0))
- == NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
-
- if ((pix[PIX_DB_DOOR] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
-
- SDL_FreeSurface(sdl_image_tmp);
-
- /* create double-buffer surface for field image */
- if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
- FXSIZE, FYSIZE,
- WIN_SDL_DEPTH, 0, 0, 0, 0))
- == NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
-
- if ((pix[PIX_DB_FIELD] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
-
- SDL_FreeSurface(sdl_image_tmp);
+#ifdef USE_SDL_LIBRARY
/* initialize surface array to 'NULL' */
for(i=0; i<NUM_TILES; i++)
if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, TILEX, TILEY,
WIN_SDL_DEPTH, 0, 0, 0, 0))
== NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
/* create native transparent surface for current image */
SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
SDL_FreeSurface(sdl_image_tmp);
#else /* !USE_SDL_LIBRARY */
- pix[PIX_DB_BACK] = XCreatePixmap(display, window,
- WIN_XSIZE,WIN_YSIZE,
- XDefaultDepth(display,screen));
- pix[PIX_DB_DOOR] = XCreatePixmap(display, window,
- 3*DXSIZE,DYSIZE+VYSIZE,
- XDefaultDepth(display,screen));
- pix[PIX_DB_FIELD] = XCreatePixmap(display, window,
- FXSIZE,FYSIZE,
- XDefaultDepth(display,screen));
-
+ /* create graphic context structures needed for clipping */
clip_gc_values.graphics_exposures = False;
clip_gc_valuemask = GCGraphicsExposures;
copy_clipmask_gc =
- XCreateGC(display,clipmask[PIX_BACK],clip_gc_valuemask,&clip_gc_values);
+ XCreateGC(display, clipmask[PIX_BACK], clip_gc_valuemask, &clip_gc_values);
clip_gc_values.graphics_exposures = False;
clip_gc_valuemask = GCGraphicsExposures;
tile_clip_gc =
- XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
+ XCreateGC(display, window, clip_gc_valuemask, &clip_gc_values);
+
+ for(i=0; i<NUM_BITMAPS; i++)
+ {
+ if (clipmask[i])
+ {
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_values.clip_mask = clipmask[i];
+ clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
+ clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
+ }
+ }
/* initialize pixmap array to Pixmap 'None' */
for(i=0; i<NUM_TILES; i++)
}
}
- if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR])
- Error(ERR_EXIT, "cannot create additional pixmaps");
-
- for(i=0; i<NUM_BITMAPS; i++)
- {
- if (clipmask[i])
- {
- clip_gc_values.graphics_exposures = False;
- clip_gc_values.clip_mask = clipmask[i];
- clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
- clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
- }
- }
-
#endif /* !USE_SDL_LIBRARY */
+}
+
+void InitGfxBackground()
+{
+ int x, y;
drawto = backbuffer = pix[PIX_DB_BACK];
fieldbuffer = pix[PIX_DB_FIELD];
SetDrawtoField(DRAW_BACKBUFFER);
BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
- ClearRectangle(pix[PIX_DB_BACK], REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
+ ClearRectangle(backbuffer, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE);
- for(i=0; i<MAX_BUF_XSIZE; i++)
- for(j=0; j<MAX_BUF_YSIZE; j++)
- redraw[i][j] = 0;
+ for(x=0; x<MAX_BUF_XSIZE; x++)
+ for(y=0; y<MAX_BUF_YSIZE; y++)
+ redraw[x][y] = 0;
redraw_tiles = 0;
redraw_mask = REDRAW_ALL;
}
#ifdef USE_SDL_LIBRARY
/* load image to temporary surface */
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
- Error(ERR_EXIT, "IMG_Load() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
/* create native non-transparent surface for current image */
if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
/* create native transparent surface for current image */
SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError());
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
/* free temporary surface */
SDL_FreeSurface(sdl_image_tmp);
for(j=0; j<*(ep2_num[i]); j++)
Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
- for(i=EL_CHAR_START; i<EL_CHAR_END; i++)
+ for(i=EL_CHAR_START; i<=EL_CHAR_END; i++)
Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
}
}
#endif
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
dumpErrorFile();
#endif