equal
deleted
inserted
replaced
39 procedure InitSound; |
39 procedure InitSound; |
40 procedure ReleaseSound; |
40 procedure ReleaseSound; |
41 procedure SoundLoad; |
41 procedure SoundLoad; |
42 procedure PlaySound(snd: TSound); |
42 procedure PlaySound(snd: TSound); |
43 procedure PlayMusic; |
43 procedure PlayMusic; |
44 procedure StopSound(snd: TSound); |
44 procedure StopTPUSound; |
45 |
45 |
46 implementation |
46 implementation |
47 uses uMisc, uConsole; |
47 uses uMisc, uConsole; |
|
48 const chanTPU = 12; |
48 var Mus: PMixMusic; |
49 var Mus: PMixMusic; |
49 |
50 |
50 procedure InitSound; |
51 procedure InitSound; |
51 begin |
52 begin |
52 if not isSoundEnabled then exit; |
53 if not isSoundEnabled then exit; |
54 isSoundEnabled:= SDL_Init(SDL_INIT_AUDIO) >= 0; |
55 isSoundEnabled:= SDL_Init(SDL_INIT_AUDIO) >= 0; |
55 if isSoundEnabled then |
56 if isSoundEnabled then |
56 isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0; |
57 isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0; |
57 if isSoundEnabled then WriteLnToConsole(msgOK) |
58 if isSoundEnabled then WriteLnToConsole(msgOK) |
58 else WriteLnToConsole(msgFailed); |
59 else WriteLnToConsole(msgFailed); |
59 Mix_AllocateChannels(Succ(ord(High(TSound)))); |
60 Mix_AllocateChannels(Succ(chanTPU)); |
60 Mix_VolumeMusic(48) |
61 Mix_VolumeMusic(48) |
61 end; |
62 end; |
62 |
63 |
63 procedure ReleaseSound; |
64 procedure ReleaseSound; |
64 var i: TSound; |
65 var i: TSound; |
91 end; |
92 end; |
92 |
93 |
93 procedure PlaySound(snd: TSound); |
94 procedure PlaySound(snd: TSound); |
94 begin |
95 begin |
95 if not isSoundEnabled then exit; |
96 if not isSoundEnabled then exit; |
96 if Mix_Playing(ord(snd)) = 0 then |
97 if snd <> sndThrowPowerUp then Mix_PlayChannelTimed(-1, Soundz[snd].id, 0, -1) |
97 Mix_PlayChannelTimed(ord(snd), Soundz[snd].id, 0, -1) |
98 else Mix_PlayChannelTimed(chanTPU, Soundz[snd].id, 0, -1) |
98 end; |
99 end; |
99 |
100 |
100 procedure StopSound(snd: TSound); |
101 procedure StopTPUSound; |
101 begin |
102 begin |
102 if not isSoundEnabled then exit; |
103 if not isSoundEnabled then exit; |
103 if Mix_Playing(ord(snd)) <> 0 then |
104 if Mix_Playing(chanTPU) <> 0 then |
104 Mix_HaltChannel(ord(snd)) |
105 Mix_HaltChannel(chanTPU) |
105 end; |
106 end; |
106 |
107 |
107 procedure PlayMusic; |
108 procedure PlayMusic; |
108 begin |
109 begin |
109 if not isSoundEnabled then exit; |
110 if not isSoundEnabled then exit; |