X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=241849cef7285e13a119562ecbef5195d5767b8b;hb=49221e59bff18cdfbef8c877b588280266ae5037;hp=adfd3f2c34da9273e89e084ce310167b1c47c50f;hpb=e6bde4abb3952d4689917ce66d6bde79cd8df7fc;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index adfd3f2c..241849ce 100644 --- a/src/init.c +++ b/src/init.c @@ -310,15 +310,17 @@ 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); + InitVideoDisplay(); InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); @@ -326,11 +328,9 @@ void InitDisplay() void InitGfx() { - int i, j; + int i; -#if defined(TARGET_SDL) - SDL_Surface *sdl_image_tmp; -#else +#if defined(TARGET_X11) GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; @@ -366,6 +366,7 @@ void InitGfx() }; #endif +#ifdef TARGET_X11 static struct { int start; @@ -417,6 +418,15 @@ void InitGfx() { GFX2_SHIELD_ACTIVE, 3 }, { -1, 0 } }; +#endif + + /* initialize screen properties */ + + InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, + REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); + InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); + InitGfxScrollbufferInfo(FXSIZE, FYSIZE); /* create additional image buffers for double-buffering */ @@ -424,6 +434,8 @@ void InitGfx() pix[PIX_DB_FIELD] = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); LoadGfx(PIX_SMALLFONT, &pic[PIX_SMALLFONT]); + InitFontInfo(NULL, NULL, pix[PIX_SMALLFONT]); + DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW); DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED); #if defined(PLATFORM_MSDOS) @@ -436,10 +448,13 @@ void InitGfx() if (i != PIX_SMALLFONT) LoadGfx(i,&pic[i]); + InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]); + /* create additional image buffers for masking of graphics */ #if defined(TARGET_SDL) +#if 0 /* initialize surface array to 'NULL' */ for(i=0; iclip_mask, + 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->drawable, clip_gc_valuemask, &clip_gc_values); for(i=0; iclip_mask) { clip_gc_values.graphics_exposures = False; - clip_gc_values.clip_mask = clipmask[i]; + clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; - clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values); + pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, + clip_gc_valuemask,&clip_gc_values); } } @@ -507,6 +526,8 @@ void InitGfx() /* create only those clipping Pixmaps we really need */ for(i=0; tile_needs_clipping[i].start>=0; i++) { + int j; + for(j=0; jclip_mask; - tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1); + tile_clipmask[tile] = XCreatePixmap(display, window->drawable, + TILEX, TILEY, 1); - XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc, - src_x,src_y, TILEX,TILEY, 0,0); + XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc, + src_x, src_y, TILEX, TILEY, 0, 0); } } @@ -571,19 +593,21 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) rest(100); #endif + pix[pos] = CreateBitmapStruct(); + #if defined(TARGET_SDL) /* load image to temporary surface */ if ((sdl_image_tmp = IMG_Load(filename)) == NULL) 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) + if ((pix[pos]->surface = SDL_DisplayFormat(sdl_image_tmp)) == NULL) 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) + if ((pix[pos]->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL) Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError()); /* free temporary surface */ @@ -591,8 +615,9 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) #else /* !TARGET_SDL */ - pcx_err = Read_PCX_to_Pixmap(display, window, gc, filename, - &pix[pos], &clipmask[pos]); + pcx_err = Read_PCX_to_Pixmap(display, window->drawable, window->gc, + filename, + &pix[pos]->drawable, &pix[pos]->clip_mask); switch(pcx_err) { case PCX_Success: @@ -611,19 +636,21 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) break; } - if (!pix[pos]) + if (!pix[pos]->drawable) Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename); +#if 0 /* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always use pix_masked[], although they are the same when not using SDL */ pix_masked[pos] = pix[pos]; +#endif #endif /* !TARGET_SDL */ } #if defined(TARGET_X11) /* check if clip mask was correctly created */ - if (pic->picture_with_mask && !clipmask[pos]) + if (pic->picture_with_mask && !pix[pos]->clip_mask) Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename); #endif } @@ -1802,25 +1829,16 @@ void CloseAllAndExit(int exit_value) #endif for(i=0; i