hedgewars/uSound.pas
changeset 174 0b2c5b22f644
parent 97 e7c1df9cce2c
child 175 d226d976d836
--- a/hedgewars/uSound.pas	Tue Sep 26 20:25:42 2006 +0000
+++ b/hedgewars/uSound.pas	Wed Sep 27 20:13:29 2006 +0000
@@ -42,11 +42,13 @@
 procedure PlaySound(snd: TSound);
 procedure PlayMusic;
 procedure StopTPUSound;
+function  ChangeVolume(voldelta: integer): integer;
 
 implementation
 uses uMisc, uConsole;
 const chanTPU = 12;
 var Mus: PMixMusic;
+    Volume: integer;
 
 procedure InitSound;
 begin
@@ -58,7 +60,11 @@
 if isSoundEnabled then WriteLnToConsole(msgOK)
                   else WriteLnToConsole(msgFailed);
 Mix_AllocateChannels(Succ(chanTPU));
-Mix_VolumeMusic(48)
+Mix_VolumeMusic(48);
+
+Volume:= cInitVolume;
+if Volume < 0 then Volume:= 0;
+Volume:= Mix_Volume(-1, Volume)
 end;
 
 procedure ReleaseSound;
@@ -112,4 +118,12 @@
    Mix_PlayMusic(Mus, -1)
 end;
 
+function ChangeVolume(voldelta: integer): integer;
+begin
+inc(Volume, voldelta);
+if Volume < 0 then Volume:= 0;
+Volume:= Mix_Volume(-1, Volume);
+Result:= Volume * 100 div MIX_MAX_VOLUME
+end;
+
 end.