Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 43595 Details for
Bug 70464
SDL_Mixer patch for tomatoes
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
tomatoes-1.5-sdl-mixer.patch
tomatoes-1.5-sdl-mixer.patch (text/plain), 12.30 KB, created by
Alexandru Toma
on 2004-11-09 02:11:46 UTC
(
hide
)
Description:
tomatoes-1.5-sdl-mixer.patch
Filename:
MIME Type:
Creator:
Alexandru Toma
Created:
2004-11-09 02:11:46 UTC
Size:
12.30 KB
patch
obsolete
>--- include/soundmusic.h 2004-09-27 19:28:10.000000000 +1000 >+++ include/soundmusic.h 2004-11-07 16:07:53.906446152 +1100 >@@ -30,11 +30,11 @@ > #ifndef SOUNDMUSIC_H > #define SOUNDMUSIC_H > >-#include <fmod.h> >-#include <fmod_errors.h> >+#include "SDL.h" >+#include "SDL_mixer.h" > > // Current music module >-extern FMUSIC_MODULE *music_mod; >+extern Mix_Music *music_mod; > > // Maximum number of music files > #define MAX_MUSIC 128 >@@ -79,11 +78,11 @@ > #define NUM_SOUNDS 28 > > // Sound array >-extern FSOUND_SAMPLE *sounds[NUM_SOUNDS]; >+extern Mix_Chunk *sounds[NUM_SOUNDS]; > > >-// Initialize the FMOD >-void init_fmod(); >+// Initialize the Mixer >+void init_mixer(); > > // Play music > void play_music(char *file); >@@ -92,7 +91,7 @@ > void play_sound(int sound, bool random_freq); > > // If the current music has finished, start playing another >-void check_music_finished(); >+void music_finished(); > > > #endif >--- src/game.cpp 2004-09-27 19:28:22.000000000 +1000 >+++ src/game.cpp 2004-11-07 16:07:06.219695640 +1100 >@@ -416,9 +416,6 @@ > } > > >- // Check if the music has finished playing >- check_music_finished(); >- > // Screenshot? > if(key[SDLK_F12]) { > if(f12_down == false) { >--- src/hiscore.cpp 2004-09-27 19:37:28.000000000 +1000 >+++ src/hiscore.cpp 2004-11-07 16:07:19.388693648 +1100 >@@ -142,9 +142,6 @@ > done = handle_event(event); // from 'game.cpp' > } > >- // If the current music has finished, start playing another >- check_music_finished(); >- > // Fade > if(fading) { > if(fading == 1) { >--- src/init.cpp 2004-09-27 19:28:22.000000000 +1000 >+++ src/init.cpp 2004-11-07 10:22:36.000000000 +1100 >@@ -94,7 +93,7 @@ > error_msg("Sorry, 8-bit color depth is not supported!\nYou must use 15, 16, 24 or 32-bit mode.\n"); > > // Initialize SDL with video and timer support >- if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0) >+ if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO) < 0) > error_msg("Unable to init SDL: %s", SDL_GetError()); > > // Hide the mouse cursor >--- src/main.cpp 2004-09-27 19:28:22.000000000 +1000 >+++ src/main.cpp 2004-11-06 23:36:21.000000000 +1100 >@@ -109,7 +109,7 @@ > init_sdl_and_gl(); > > // Initialize FMOD >- init_fmod(); >+ init_mixer(); > > // Load fonts > build_font_list(); >@@ -170,9 +170,11 @@ > pakfile.close_mpk(); > > // Close the FMOD >- FMUSIC_StopSong(music_mod); >- FMUSIC_FreeSong(music_mod); >- FSOUND_Close(); >+ if(music_mod){ >+ Mix_HaltMusic(); >+ Mix_FreeMusic(music_mod); >+ } >+ Mix_CloseAudio(); > > // Save the config > save_config(get_config_location(true), &config); >--- src/menu.cpp 2004-09-27 19:28:22.000000000 +1000 >+++ src/menu.cpp 2004-11-07 16:06:43.147203192 +1100 >@@ -602,9 +602,6 @@ > } > > while(timer_count > 0) { >- // If the current music has finished, start playing another >- check_music_finished(); >- > // Fade > if(fading) { > if(fading == 1) { >@@ -688,8 +685,8 @@ > > // Restore the settings > load_config(get_config_location(), &config); >- FSOUND_SetSFXMasterVolume(config.sound_vol); >- FMUSIC_SetMasterVolume(music_mod, config.music_vol); >+ Mix_Volume(-1,config.sound_vol); >+ Mix_VolumeMusic(config.music_vol); > } > } > >@@ -803,8 +800,8 @@ > > // Restore the settings > load_config(get_config_location(), &config); >- FSOUND_SetSFXMasterVolume(config.sound_vol); >- FMUSIC_SetMasterVolume(music_mod, config.music_vol); >+ Mix_Volume(-1,config.sound_vol); >+ Mix_VolumeMusic(config.music_vol); > } > } > >@@ -815,14 +812,14 @@ > if(config.music_vol < 0) > config.music_vol = 0; > // Update the volume levels >- FMUSIC_SetMasterVolume(music_mod, config.music_vol); >+ Mix_VolumeMusic(config.music_vol); > } > if(key[SDLK_RIGHT]) { > config.music_vol += 10; > if(config.music_vol > 255) > config.music_vol = 255; > // Update the volume levels >- FMUSIC_SetMasterVolume(music_mod, config.music_vol); >+ Mix_VolumeMusic(config.music_vol); > } > } > if(menu_item == MENU_SOUNDVOL) { >@@ -831,7 +828,7 @@ > if(config.sound_vol < 0) > config.sound_vol = 0; > // Update the volume levels >- FSOUND_SetSFXMasterVolume(config.sound_vol); >+ Mix_Volume(-1,config.sound_vol); > play_sound(SND_MENU1, false); > } > if(key[SDLK_RIGHT]) { >@@ -839,7 +836,7 @@ > if(config.sound_vol > 255) > config.sound_vol = 255; > // Update the volume levels >- FSOUND_SetSFXMasterVolume(config.sound_vol); >+ Mix_Volume(-1,config.sound_vol); > play_sound(SND_MENU1, false); > } > } >--- src/soundmusic.cpp 2004-09-27 19:28:22.000000000 +1000 >+++ src/soundmusic.cpp 2004-11-07 16:54:26.117965480 +1100 >@@ -30,21 +30,20 @@ > #include <stdlib.h> > #include <stdio.h> > #include "SDL.h" >+#include "SDL_mixer.h" > #include "game.h" > #include <string.h> > #include <dirent.h> > #include <ctype.h> >-#include <fmod.h> >-#include <fmod_errors.h> >-#include "soundmusic.h" > #include "mymath.h" > #include "init.h" > #include "mpak.h" > #include "comments.h" > #include "timer.h" >+#include "soundmusic.h" > > // Current music module >-FMUSIC_MODULE *music_mod; >+Mix_Music *music_mod = NULL; > > // Music files array > char music_files[MAX_MUSIC][256]; >@@ -52,7 +51,7 @@ > int cur_music; > > // Sound array >-FSOUND_SAMPLE *sounds[NUM_SOUNDS]; >+Mix_Chunk *sounds[NUM_SOUNDS]; > > > // Shuffle the playlist >@@ -140,27 +139,24 @@ > > > // If the current music has finished, start playing another >-void check_music_finished() { >+void music_finished() { > static bool f1_key_down = false; > > if(!config.sound || !num_music_files || !config.music_vol) > return; >+ >+ if(f1_key_down == false) { >+ // Play the current song from the playlist >+ play_music(music_files[cur_music]); > >- if(FMUSIC_IsFinished(music_mod) || key[SDLK_F1]) { >- if(f1_key_down == false) { >- // Play the current song from the playlist >- play_music(music_files[cur_music]); >- >- cur_music++; >- if(cur_music > num_music_files-1) >- shuffle_playlist(); >- >- f1_key_down = true; >- } >+ cur_music++; >+ if(cur_music > num_music_files-1) >+ shuffle_playlist(); >+ f1_key_down = true; > } >- > if(!key[SDLK_F1]) > f1_key_down = false; >+ > } > > >@@ -177,83 +173,69 @@ > if(check) { > // The file exists, load it > fclose(check); >- sounds[cur_sound] = FSOUND_Sample_Load(FSOUND_FREE, soundfile, FSOUND_2D, 0, 0); >+ sounds[cur_sound] = Mix_LoadWAV(soundfile); > } > else { >- // The file doesn't exist in the override directory, try to load it >- // from the pakfile. >- >- // Find the correct offset and the sample length >- UINT32 offset = 0, len = 0; >- int idx = pakfile.find_file(file); >- if(idx == -1) >- error_msg("load_sound():\nUnable to load sound %s from the pakfile!\nThe sound doesn't exist!", file); >- offset = pakfile.offsets[idx]; >- len = pakfile.sizes[idx]; >- >- // Load the sample >- sounds[cur_sound] = FSOUND_Sample_Load(FSOUND_FREE, pakfile.mpk_file, FSOUND_2D, offset, len); >+ // The file doesn't exist in the override directory >+ // try to load it from the pakfile. >+ FILE *fp = pakfile.open_file(file); >+ SDL_RWops *rw = SDL_RWFromFP(fp,0); >+ sounds[cur_sound] = Mix_LoadWAV_RW(rw,0); >+ SDL_FreeRW(rw); >+ fclose(fp); > } > > // Check for errors > if(!sounds[cur_sound]) >- error_msg("load_sound():\nUnable to load a sound from %s!\n", file); >- >+ error_msg("load_sound():\nUnable to load a sound from %s!\nError: %s\n",file,Mix_GetError()); > cur_sound++; > } > > >-// Initialize the FMOD >-void init_fmod() { >- // Check the FMOD version >- if(FSOUND_GetVersion() < FMOD_VERSION) >- error_msg("You are using a wrong version of FMOD.DLL (v%.02f)\nYou should have FMOD.DLL version v%.02f\n", FSOUND_GetVersion(), FMOD_VERSION); >- >- // Check if the audio is disabled >+// Initialize the SDL_Mixer >+void init_mixer() { > if(!config.sound) >- FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND); // Disable the audio >- >- // Initialize the FMOD >- if(!FSOUND_Init(config.sound_freq, 128, FSOUND_INIT_GLOBALFOCUS)) >- error_msg("Unable to initialize FMOD: FSOUND_Init() failed!\nReason of failure: %s\n", FMOD_ErrorString(FSOUND_GetError())); >- >+ return; >+ >+ // Initialize the Mixer >+ if(Mix_OpenAudio(config.sound_freq, AUDIO_S16, 2, 4096)) // Frequency, 16 bit sound, channels (stereo), buffer size >+ error_msg("Unable to open the audio device!\nError: %s\n", Mix_GetError()); >+ > // Load the sounds >- if(config.sound) { >- load_sound("snd_appear.wav"); >- load_sound("snd_bomb.wav"); >- load_sound("snd_explo.wav"); >- load_sound("snd_bonus1.wav"); >- load_sound("snd_bonus2.wav"); >- load_sound("snd_bonus3.wav"); >- load_sound("snd_die1.wav"); >- load_sound("snd_die2.wav"); >- load_sound("snd_die3.wav"); >- load_sound("snd_die4.wav"); >- load_sound("snd_die5.wav"); >- load_sound("snd_die6.wav"); >- load_sound("snd_levelteleport.wav"); >- load_sound("snd_wildfire.wav"); >- load_sound("snd_teleport.wav"); >- load_sound("snd_trap.wav"); >- load_sound("snd_lightning.wav"); >- load_sound("snd_wisp.wav"); >- load_sound("snd_jump.wav"); >- load_sound("snd_potatoman.wav"); >- load_sound("snd_potatoman2.wav"); >- load_sound("snd_turn.wav"); >- load_sound("snd_flowerpower.wav"); >- load_sound("snd_kick.wav"); >- load_sound("snd_killed5.wav"); >- load_sound("snd_menu1.wav"); >- load_sound("snd_menu2.wav"); >- load_sound("snd_finish.wav"); >- } >+ load_sound("snd_appear.wav"); >+ load_sound("snd_bomb.wav"); >+ load_sound("snd_explo.wav"); >+ load_sound("snd_bonus1.wav"); >+ load_sound("snd_bonus2.wav"); >+ load_sound("snd_bonus3.wav"); >+ load_sound("snd_die1.wav"); >+ load_sound("snd_die2.wav"); >+ load_sound("snd_die3.wav"); >+ load_sound("snd_die4.wav"); >+ load_sound("snd_die5.wav"); >+ load_sound("snd_die6.wav"); >+ load_sound("snd_levelteleport.wav"); >+ load_sound("snd_wildfire.wav"); >+ load_sound("snd_teleport.wav"); >+ load_sound("snd_trap.wav"); >+ load_sound("snd_lightning.wav"); >+ load_sound("snd_wisp.wav"); >+ load_sound("snd_jump.wav"); >+ load_sound("snd_potatoman.wav"); >+ load_sound("snd_potatoman2.wav"); >+ load_sound("snd_turn.wav"); >+ load_sound("snd_flowerpower.wav"); >+ load_sound("snd_kick.wav"); >+ load_sound("snd_killed5.wav"); >+ load_sound("snd_menu1.wav"); >+ load_sound("snd_menu2.wav"); >+ load_sound("snd_finish.wav"); > > // Search for music files > search_music(); >- >+ > // Set the volume >- FSOUND_SetSFXMasterVolume(config.sound_vol); >+ Mix_Volume(-1,config.sound_vol); > > // Start playing the music > if(num_music_files) { >@@ -262,6 +244,9 @@ > if(cur_music > num_music_files-1) > cur_music = 0; > } >+ >+ // Tell Mixer what to do when the music stops >+ Mix_HookMusicFinished(&music_finished); > } > > >@@ -274,20 +259,22 @@ > > char str[256] = ""; > sprintf(str, "%s%s", MUSIC_DIR, file); >- FMUSIC_StopSong(music_mod); >- FMUSIC_FreeSong(music_mod); >- music_mod = FMUSIC_LoadSong(str); >+ if(music_mod){ >+ Mix_HaltMusic(); >+ Mix_FreeMusic(music_mod); >+ } >+ music_mod = Mix_LoadMUS(str); > if(!music_mod) >- error_msg("play_music():\nUnable to play music from '%s'!\nFMOD error: %s\n", file, FMOD_ErrorString(FSOUND_GetError())); >+ error_msg("play_music():\nUnable to play music from '%s'!\nError: %s\n", file, Mix_GetError()); > > // Play >- FMUSIC_PlaySong(music_mod); >+ Mix_PlayMusic(music_mod, 0); > > // Add the comment >- add_comment(COL_DEFAULT, "Playing \"%s\"...", FMUSIC_GetName(music_mod)); >+ add_comment(COL_DEFAULT, "Playing \"%s\"...", file); > > // Set the volume >- FMUSIC_SetMasterVolume(music_mod, config.music_vol); >+ Mix_VolumeMusic(config.music_vol); > > game_paused = false; > } >@@ -299,18 +286,20 @@ > return; > > // Play the sound >- int channel = FSOUND_PlaySound(FSOUND_FREE, sounds[sound]); >+ Mix_PlayChannel(-1, sounds[sound], 0); >+ //int channel = Mix_PlayChannel(-1, sounds[sound], 0); > > // Random the frequency >+ // This doesn't work in SDL! > if(random_freq) { > int freq; > int freq_change[2]; >- freq = FSOUND_GetFrequency(channel); >+// freq = FSOUND_GetFrequency(channel); > > freq_change[0] = (int)((float)freq * 0.3f); > freq_change[1] = (int)((float)freq * 0.1f); > > // Upload the frequency to the sample >- FSOUND_SetFrequency(channel, freq+RAND(-freq_change[0], freq_change[1])); >+// FSOUND_SetFrequency(channel, freq+RAND(-freq_change[0], freq_change[1])); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 70464
: 43595