hedgewars/uSound.pas
changeset 371 731ad6d27bd1
parent 355 40c68869899e
child 393 db01cc79f278
equal deleted inserted replaced
370:c75410fe3133 371:731ad6d27bd1
    25 procedure ReleaseSound;
    25 procedure ReleaseSound;
    26 procedure SoundLoad;
    26 procedure SoundLoad;
    27 procedure PlaySound(snd: TSound; infinite: boolean);
    27 procedure PlaySound(snd: TSound; infinite: boolean);
    28 procedure PlayMusic;
    28 procedure PlayMusic;
    29 procedure StopSound(snd: TSound);
    29 procedure StopSound(snd: TSound);
    30 function  ChangeVolume(voldelta: integer): integer;
    30 function  ChangeVolume(voldelta: LongInt): LongInt;
    31 
    31 
    32 implementation
    32 implementation
    33 uses uMisc, uConsole;
    33 uses uMisc, uConsole;
    34 const chanTPU = 12;
    34 const chanTPU = 12;
    35 var Mus: PMixMusic;
    35 var Mus: PMixMusic;
    36     Volume: integer;
    36     Volume: LongInt;
    37 
    37 
    38 procedure InitSound;
    38 procedure InitSound;
    39 begin
    39 begin
    40 if not isSoundEnabled then exit;
    40 if not isSoundEnabled then exit;
    41 WriteToConsole('Init sound...');
    41 WriteToConsole('Init sound...');
    81 TryDo(Mus <> nil, msgFailed, false);
    81 TryDo(Mus <> nil, msgFailed, false);
    82 WriteLnToConsole(msgOK)
    82 WriteLnToConsole(msgOK)
    83 end;
    83 end;
    84 
    84 
    85 procedure PlaySound(snd: TSound; infinite: boolean);
    85 procedure PlaySound(snd: TSound; infinite: boolean);
    86 var loops: integer;
    86 var loops: LongInt;
    87 begin
    87 begin
    88 if not isSoundEnabled then exit;
    88 if not isSoundEnabled then exit;
    89 if infinite then loops:= -1 else loops:= 0;
    89 if infinite then loops:= -1 else loops:= 0;
    90 Soundz[snd].lastChan:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1)
    90 Soundz[snd].lastChan:= Mix_PlayChannelTimed(-1, Soundz[snd].id, loops, -1)
    91 end;
    91 end;
   102 if not isSoundEnabled then exit;
   102 if not isSoundEnabled then exit;
   103 if Mix_PlayingMusic = 0 then
   103 if Mix_PlayingMusic = 0 then
   104    Mix_PlayMusic(Mus, -1)
   104    Mix_PlayMusic(Mus, -1)
   105 end;
   105 end;
   106 
   106 
   107 function ChangeVolume(voldelta: integer): integer;
   107 function ChangeVolume(voldelta: LongInt): LongInt;
   108 begin
   108 begin
   109 if not isSoundEnabled then
   109 if not isSoundEnabled then
   110    exit(0);
   110    exit(0);
   111 
   111 
   112 inc(Volume, voldelta);
   112 inc(Volume, voldelta);