equal
deleted
inserted
replaced
34 *) |
34 *) |
35 interface |
35 interface |
36 uses SDLh, uConsts, uTypes, sysutils; |
36 uses SDLh, uConsts, uTypes, sysutils; |
37 |
37 |
38 var MusicFN: shortstring; // music file name |
38 var MusicFN: shortstring; // music file name |
|
39 previousVolume: LongInt; // cached volume value |
39 |
40 |
40 procedure initModule; |
41 procedure initModule; |
41 procedure freeModule; |
42 procedure freeModule; |
42 |
43 |
43 procedure InitSound; // Initiates sound-system if isSoundEnabled. |
44 procedure InitSound; // Initiates sound-system if isSoundEnabled. |
88 function ChangeVolume(voldelta: LongInt): LongInt; |
89 function ChangeVolume(voldelta: LongInt): LongInt; |
89 |
90 |
90 // Returns a pointer to the voicepack with the given name. |
91 // Returns a pointer to the voicepack with the given name. |
91 function AskForVoicepack(name: shortstring): Pointer; |
92 function AskForVoicepack(name: shortstring): Pointer; |
92 |
93 |
|
94 // Drastically lower the volume when we lose focus (and restore the previous value) |
|
95 procedure DampenAudio; |
|
96 procedure UndampenAudio; |
93 |
97 |
94 implementation |
98 implementation |
95 uses uVariables, uConsole, uUtils, uCommands, uDebug; |
99 uses uVariables, uConsole, uUtils, uCommands, uDebug; |
96 |
100 |
97 const chanTPU = 32; |
101 const chanTPU = 32; |
475 if isMusicEnabled then |
479 if isMusicEnabled then |
476 Mix_VolumeMusic(Volume * 4 div 8); |
480 Mix_VolumeMusic(Volume * 4 div 8); |
477 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
481 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
478 end; |
482 end; |
479 |
483 |
|
484 procedure DampenAudio; |
|
485 begin |
|
486 previousVolume:= Volume; |
|
487 ChangeVolume(-Volume * 7 div 9); |
|
488 end; |
|
489 |
|
490 procedure UndampenAudio; |
|
491 begin |
|
492 ChangeVolume(previousVolume - Volume); |
|
493 end; |
|
494 |
480 procedure PauseMusic; |
495 procedure PauseMusic; |
481 begin |
496 begin |
482 if (MusicFN = '') or (not isMusicEnabled) then |
497 if (MusicFN = '') or (not isMusicEnabled) then |
483 exit; |
498 exit; |
484 |
499 |