summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/sp0250.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/sp0250.h')
-rw-r--r--src/devices/sound/sp0250.h58
1 files changed, 41 insertions, 17 deletions
diff --git a/src/devices/sound/sp0250.h b/src/devices/sound/sp0250.h
index 9685fa4fea2..48f77a69d01 100644
--- a/src/devices/sound/sp0250.h
+++ b/src/devices/sound/sp0250.h
@@ -11,6 +11,7 @@ public:
sp0250_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
auto drq() { return m_drq.bind(); }
+ void set_pwm_mode() { m_pwm_mode = true; }
void write(uint8_t data);
uint8_t drq_r();
@@ -18,33 +19,56 @@ public:
protected:
// device-level overrides
virtual void device_start() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
private:
- // internal state
- int16_t m_amp;
- uint8_t m_pitch;
- uint8_t m_repeat;
- int m_pcount, m_rcount;
- int m_playing;
- uint32_t m_RNG;
- sound_stream * m_stream;
- int m_voiced;
- uint8_t m_fifo[15];
- int m_fifo_pos;
- devcb_write_line m_drq;
+ // internal helpers
+ int8_t next();
+ void load_values();
- struct
+ // state for each filter
+ class filter
{
+ public:
+ filter() : z1(0), z2(0) { }
+ void reset() { z1 = z2 = 0; }
+ int16_t apply(int16_t in)
+ {
+ int16_t z0 = in + ((z1 * F) >> 8) + ((z2 * B) >> 9);
+ z2 = z1;
+ z1 = z0;
+ return z0;
+ }
int16_t F, B;
int16_t z1, z2;
- } m_filter[6];
+ };
- void load_values();
- TIMER_CALLBACK_MEMBER( timer_tick );
- emu_timer * m_tick_timer;
+ // PWM state
+ bool m_pwm_mode;
+ uint8_t m_pwm_index;
+ uint8_t m_pwm_count;
+ uint32_t m_pwm_counts;
+
+ // LPC state
+ bool m_voiced;
+ int16_t m_amp;
+ uint16_t m_lfsr;
+ uint8_t m_pitch;
+ uint8_t m_pcount;
+ uint8_t m_repeat;
+ uint8_t m_rcount;
+ filter m_filter[6];
+
+ // FIFO state
+ uint8_t m_fifo[15];
+ uint8_t m_fifo_pos;
+
+ // external interfacing
+ sound_stream *m_stream;
+ devcb_write_line m_drq;
};
DECLARE_DEVICE_TYPE(SP0250, sp0250_device)