/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-2001 Artsoft Entertainment *
+* (c) 1994-2002 Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
/* load image to temporary surface */
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
- Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
+ {
+ SetError("IMG_Load(): %s", SDL_GetError());
+ return NULL;
+ }
/* create native non-transparent surface for current image */
if ((new_bitmap->surface = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+ {
+ SetError("SDL_DisplayFormat(): %s", SDL_GetError());
+ return NULL;
+ }
/* create native transparent surface for current image */
SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
if ((new_bitmap->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+ {
+ SetError("SDL_DisplayFormat(): %s", SDL_GetError());
+ return NULL;
+ }
/* free temporary surface */
SDL_FreeSurface(sdl_image_tmp);
+ new_bitmap->width = new_bitmap->surface->w;
+ new_bitmap->height = new_bitmap->surface->h;
+
return new_bitmap;
}
return;
}
- if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, AUDIO_S16,
- AUDIO_STEREO_CHANNELS,
+ if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, MIX_DEFAULT_FORMAT,
+ AUDIO_NUM_CHANNELS_STEREO,
DEFAULT_AUDIO_FRAGMENT_SIZE) < 0)
{
Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError());
audio.loops_available = TRUE;
audio.sound_enabled = TRUE;
- /* determine number of available channels */
- audio.channels = Mix_AllocateChannels(MIX_CHANNELS);
-
- if (!audio.mods_available) /* reserve first channel for music loops */
- {
- if (Mix_ReserveChannels(1) == 1)
- audio.music_channel = 0;
- else
- audio.music_available = FALSE;
- }
+ /* set number of available mixer channels */
+ audio.num_channels = Mix_AllocateChannels(NUM_MIXER_CHANNELS);
+ audio.music_channel = MUSIC_CHANNEL;
+ audio.first_sound_channel = FIRST_SOUND_CHANNEL;
- Mix_Volume(-1, SOUND_MAX_VOLUME);
- Mix_VolumeMusic(SOUND_MAX_VOLUME);
+ Mixer_InitChannels();
}
inline void SDLCloseAudio(void)