X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Finit.c;h=64f748019cac0e9050ef5048b0939bb616c9a7c1;hb=6d639c557d602855b9866959445f3f5b5513d289;hp=f77bd79ef23bb37dcf915ef4fe78e2b0cee4a249;hpb=8d46c5298f0fcce7bdb52f3835b2fbbdc403dfe0;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index f77bd79e..64f74801 100644 --- a/src/init.c +++ b/src/init.c @@ -14,6 +14,7 @@ #include #include "init.h" +#include "events.h" #include "misc.h" #include "sound.h" #include "screens.h" @@ -81,14 +82,13 @@ void OpenAll(int argc, char *argv[]) #ifndef USE_SDL_LIBRARY XMapWindow(display, window); - XFlush(display); + FlushDisplay(); #endif InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ InitLevelAndPlayerInfo(); - return; InitGadgets(); /* needs to know number of level series */ DrawMainMenu(); @@ -147,6 +147,31 @@ void InitSound() if (sound_status == SOUND_OFF) return; +#ifdef USE_SDL_LIBRARY + /* initialize SDL audio */ + + if (SDL_Init(SDL_INIT_AUDIO) < 0) + { + Error(ERR_WARN, "SDL_Init() failed: %s\n", SDL_GetError()); + sound_status = SOUND_OFF; + return; + } + + if (Mix_OpenAudio(22050, AUDIO_S16, 2, 256) < 0) + { + Error(ERR_WARN, "Mix_OpenAudio() failed: %s\n", SDL_GetError()); + sound_status = SOUND_OFF; + return; + } + + Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); + Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); + + sound_status = SOUND_AVAILABLE; + sound_loops_allowed = TRUE; + +#else /* !USE_SDL_LIBRARY */ + #ifndef MSDOS if (access(sound_device_name, W_OK) != 0) { @@ -181,20 +206,23 @@ void InitSound() */ #endif /* MSDOS */ +#endif /* !USE_SDL_LIBRARY */ for(i=0; i= SDL_NumJoysticks()) + joystick_nr = -1; + + /* misuse joystick file descriptor variable to store joystick number */ + stored_player[i].joystick_fd = joystick_nr; + + /* this allows subsequent calls to 'InitJoysticks' for re-initialization */ + if (Check_SDL_JoystickOpened(joystick_nr)) + Close_SDL_Joystick(joystick_nr); + + if (!setup.input[i].use_joystick) + continue; + + if (!Open_SDL_Joystick(joystick_nr)) + { + Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + continue; + } + + joystick_status = JOYSTICK_AVAILABLE; + } + +#else /* !USE_SDL_LIBRARY */ + #ifndef MSDOS for (i=0; i=0; i++) @@ -680,33 +760,31 @@ void InitGfx() for(j=0; jformat, 0x00, 0x00, 0x00)); + if ((tile_masked[tile] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) + Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError()); - sdl_drawto = sdl_backbuffer = sdl_pix[PIX_DB_BACK]; - sdl_fieldbuffer = sdl_pix[PIX_DB_FIELD]; - SetDrawtoField(DRAW_BACKBUFFER); + SDL_FreeSurface(sdl_image_tmp); - SDLCopyArea(sdl_pix[PIX_BACK], sdl_backbuffer, - 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - SDLFillRectangle(sdl_pix[PIX_DB_BACK], - REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, 0x000000); - SDLFillRectangle(sdl_pix[PIX_DB_DOOR], - 0,0, 3*DXSIZE,DYSIZE+VYSIZE, 0x000000); + BlitBitmap(src_bitmap, tile_masked[tile], src_x,src_y, TILEX,TILEY, 0,0); + } + } #else /* !USE_SDL_LIBRARY */ @@ -758,7 +836,7 @@ void InitGfx() if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR]) Error(ERR_EXIT, "cannot create additional pixmaps"); - for(i=0; iformat, 0x00, 0x00, 0x00)); - if ((sdl_pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) + if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL) Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s\n", SDL_GetError()); /* free temporary surface */ @@ -903,6 +979,11 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) if (!pix[pos]) Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename); + + /* 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 /* !USE_SDL_LIBRARY */ } @@ -2119,7 +2200,7 @@ void CloseAllAndExit(int exit_value) FreeSounds(NUM_SOUNDS); } - for(i=0; i