X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=d83b754235cc37dce7569864cbae08d712a1bc94;hp=851eaa5e9370a63c610ca102f3924166bb86af22;hb=998be01ad92a672b69b11e24d472f6c0c076817f;hpb=10c48f0b3b2cf27451ddf355a3f72ee5c169eae4 diff --git a/src/init.c b/src/init.c index 851eaa5e..d83b7542 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" @@ -40,13 +38,14 @@ static void InitLevelInfo(void); static void InitNetworkServer(void); static void InitSound(void); static void InitSoundServer(void); +static void InitDisplay(void); static void InitGfx(void); static void InitGfxBackground(void); static void LoadGfx(int, struct PictureFileInfo *); static void InitGadgets(void); static void InitElementProperties(void); -void OpenAll(int argc, char *argv[]) +void OpenAll(void) { #if !defined(PLATFORM_UNIX) initErrorFile(); @@ -64,6 +63,11 @@ void OpenAll(int argc, char *argv[]) exit(0); } + InitProgramInfo(UNIX_USERDATA_DIRECTORY, + PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, + MSDOS_POINTER_FILENAME); + InitPlayerInfo(); InitCounter(); @@ -75,7 +79,7 @@ void OpenAll(int argc, char *argv[]) signal(SIGINT, CloseAllAndExit); signal(SIGTERM, CloseAllAndExit); - InitBufferedDisplay(&backbuffer, &window); + InitDisplay(); InitEventFilter(FilterMouseMotionEvents); InitGfx(); @@ -144,14 +148,16 @@ void InitSound() OpenAudio(&audio); + AllocSoundArray(NUM_SOUNDS); + 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); } } @@ -492,6 +525,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); } } @@ -517,7 +553,7 @@ void InitGfxBackground() { int x, y; - drawto = backbuffer = pix[PIX_DB_BACK]; + drawto = backbuffer; fieldbuffer = pix[PIX_DB_FIELD]; SetDrawtoField(DRAW_BACKBUFFER); @@ -556,19 +592,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 */ @@ -576,8 +614,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: @@ -596,19 +635,23 @@ 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); + pix[pos]->gc = window->gc; + +#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 } @@ -1787,25 +1830,16 @@ void CloseAllAndExit(int exit_value) #endif for(i=0; i