Skip to content

Commit 7a3ea32

Browse files
committed
shared/wswansound.cpp: Minor emulation fixes, Correct output rate
1 parent f57f3f3 commit 7a3ea32

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/mame/shared/wswansound.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ wswan_sound_device::wswan_sound_device(const machine_config &mconfig, const char
3535
device_rom_interface(mconfig, *this),
3636
m_channel(nullptr),
3737
m_sweep_step(0),
38-
m_sweep_time(0),
38+
m_sweep_time(8192),
3939
m_sweep_count(0),
4040
m_noise_type(0),
4141
m_noise_reset(0),
@@ -54,7 +54,7 @@ wswan_sound_device::wswan_sound_device(const machine_config &mconfig, const char
5454
{
5555
}
5656

57-
static constexpr int clk_div = 64;
57+
static constexpr int clk_div = 128;
5858

5959
//-------------------------------------------------
6060
// device_start - device-specific startup
@@ -138,9 +138,9 @@ void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<r
138138

139139
if (m_audio[0].on)
140140
{
141-
s32 sample = m_audio[0].signal;
141+
s32 const sample = m_audio[0].signal;
142142
m_audio[0].pos += clk_div;
143-
if (m_audio[0].pos >= m_audio[0].period)
143+
while (m_audio[0].pos >= m_audio[0].period)
144144
{
145145
m_audio[0].pos -= m_audio[0].period;
146146
m_audio[0].signal = fetch_sample(0, m_audio[0].offset++);
@@ -153,15 +153,15 @@ void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<r
153153
{
154154
if (m_audio2_voice)
155155
{
156-
u8 voice_data = (m_audio[1].vol_left << 4) | m_audio[1].vol_right;
156+
u8 const voice_data = (m_audio[1].vol_left << 4) | m_audio[1].vol_right;
157157
left += voice_data * (m_master_volume & 0x0f);
158158
right += voice_data * (m_master_volume & 0x0f);
159159
}
160160
else
161161
{
162-
s32 sample = m_audio[1].signal;
162+
s32 const sample = m_audio[1].signal;
163163
m_audio[1].pos += clk_div;
164-
if (m_audio[1].pos >= m_audio[1].period)
164+
while (m_audio[1].pos >= m_audio[1].period)
165165
{
166166
m_audio[1].pos -= m_audio[1].period;
167167
m_audio[1].signal = fetch_sample(1, m_audio[1].offset++);
@@ -173,17 +173,17 @@ void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<r
173173

174174
if (m_audio[2].on)
175175
{
176-
s32 sample = m_audio[2].signal;
176+
s32 const sample = m_audio[2].signal;
177177
m_audio[2].pos += clk_div;
178-
if (m_audio[2].pos >= m_audio[2].period)
178+
while (m_audio[2].pos >= m_audio[2].period)
179179
{
180180
m_audio[2].pos -= m_audio[2].period;
181181
m_audio[2].signal = fetch_sample(2, m_audio[2].offset++);
182182
}
183183
if (m_audio3_sweep && m_sweep_time)
184184
{
185185
m_sweep_count += clk_div;
186-
if (m_sweep_count >= m_sweep_time)
186+
while (m_sweep_count >= m_sweep_time)
187187
{
188188
m_sweep_count -= m_sweep_time;
189189
m_audio[2].freq += m_sweep_step;
@@ -197,9 +197,9 @@ void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<r
197197

198198
if (m_audio[3].on)
199199
{
200-
s32 sample = m_audio[3].signal;
200+
s32 const sample = m_audio[3].signal;
201201
m_audio[3].pos += clk_div;
202-
if (m_audio[3].pos >= m_audio[3].period)
202+
while (m_audio[3].pos >= m_audio[3].period)
203203
{
204204
if (m_audio4_noise)
205205
m_audio[3].signal = m_noise_output ? 0xf : 0;
@@ -323,7 +323,7 @@ void wswan_sound_device::port_w(offs_t offset, u16 data, u16 mem_mask)
323323
// Sweep step
324324
if (ACCESSING_BITS_0_7)
325325
{
326-
m_sweep_step = (int8_t)(data & 0xff);
326+
m_sweep_step = s8(data & 0xff);
327327
}
328328
// Sweep time
329329
if (ACCESSING_BITS_8_15)

src/mame/shared/wswansound.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class wswan_sound_device : public device_t,
2929
{
3030
CHAN() :
3131
freq(0),
32-
period(0),
32+
period(2048),
3333
pos(0),
3434
vol_left(0),
3535
vol_right(0),

0 commit comments

Comments
 (0)