@@ -131,6 +131,8 @@ procedure DisableSound; |
| 131 |
procedure SoundUpdate(cycles: integer); |
131 |
procedure SoundUpdate(cycles: integer); |
| 132 |
procedure SoundSetCycles(n: integer); |
132 |
procedure SoundSetCycles(n: integer); |
| 133 |
|
133 |
|
|
|
134 |
function SoundBufferTooFull: Boolean; |
|
|
135 |
|
| 134 |
var |
136 |
var |
| 135 |
soundEnable: boolean; |
137 |
soundEnable: boolean; |
| 136 |
sndRegChange: boolean; |
138 |
sndRegChange: boolean; |
@@ -154,13 +156,20 @@ uses vars, bass; |
| 154 |
|
156 |
|
| 155 |
const |
157 |
const |
| 156 |
sampleCycles: longint = (8192 * 1024) div 22050; |
158 |
sampleCycles: longint = (8192 * 1024) div 22050; |
|
|
159 |
TooFullThreshold: DWORD = 5120; // (0.2s) |
| 157 |
|
160 |
|
| 158 |
var |
161 |
var |
| 159 |
playStream: HStream; |
162 |
playStream: HStream; |
| 160 |
ready: integer; |
|
|
| 161 |
bufPos, bufCycles, bufLVal, bufRVal: integer; |
163 |
bufPos, bufCycles, bufLVal, bufRVal: integer; |
| 162 |
buf: array[0..2047] of byte; |
164 |
buf: array[0..2047] of byte; |
| 163 |
|
165 |
|
|
|
166 |
// HACK: This is kind of a hack. We should probably figure out a way to |
|
|
167 |
// tie playback rate to the emulation function instead of this, but it works. |
|
|
168 |
function SoundBufferTooFull: Boolean; |
|
|
169 |
begin |
|
|
170 |
Result := BASS_ChannelGetData(PlayStream, nil, BASS_DATA_AVAILABLE) > TooFullThreshold; |
|
|
171 |
end; |
|
|
172 |
|
| 164 |
procedure EnableSound; |
173 |
procedure EnableSound; |
| 165 |
begin |
174 |
begin |
| 166 |
if soundEnable then |
175 |
if soundEnable then |
@@ -176,8 +185,6 @@ begin |
| 176 |
BASS_ChannelPlay(PlayStream, True); |
185 |
BASS_ChannelPlay(PlayStream, True); |
| 177 |
|
186 |
|
| 178 |
soundEnable := True; |
187 |
soundEnable := True; |
| 179 |
ready := 3; |
|
|
| 180 |
bufPos := 0; |
|
|
| 181 |
bufCycles := 0; |
188 |
bufCycles := 0; |
| 182 |
bufLVal := 0; |
189 |
bufLVal := 0; |
| 183 |
bufRVal := 0; |
190 |
bufRVal := 0; |
@@ -209,7 +216,6 @@ begin |
| 209 |
if bufPos >= 2048 then |
216 |
if bufPos >= 2048 then |
| 210 |
begin |
217 |
begin |
| 211 |
BASS_StreamPutData(PlayStream, @buf, 2048); |
218 |
BASS_StreamPutData(PlayStream, @buf, 2048); |
| 212 |
Dec(ready); |
|
|
| 213 |
bufPos := 0; |
219 |
bufPos := 0; |
| 214 |
end; |
220 |
end; |
| 215 |
end; |
221 |
end; |
@@ -549,16 +555,6 @@ begin |
| 549 |
Dec(r, vol[snd[4].Vol]); |
555 |
Dec(r, vol[snd[4].Vol]); |
| 550 |
end; |
556 |
end; |
| 551 |
|
557 |
|
| 552 |
{l:=l shr 2; |
|
|
| 553 |
if (shortint(l)<-128) then l:=-128; |
|
|
| 554 |
if (shortint(l)>127) then l:=127; |
|
|
| 555 |
inc(l,$80); |
|
|
| 556 |
|
|
|
| 557 |
r:=r shr 2; |
|
|
| 558 |
if (shortint(r)<-128) then r:=-128; |
|
|
| 559 |
if (shortint(r)>127) then r:=127; |
|
|
| 560 |
inc(r,$80);} |
|
|
| 561 |
|
|
|
| 562 |
l := shortint(l shr 2) + 128; |
558 |
l := shortint(l shr 2) + 128; |
| 563 |
r := shortint(r shr 2) + 128; |
559 |
r := shortint(r shr 2) + 128; |
| 564 |
SoundOutBits(l, r, cycles) |
560 |
SoundOutBits(l, r, cycles) |