summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/pokey.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/pokey.h')
-rw-r--r--src/devices/sound/pokey.h64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h
index 0717429aff3..3d60bcfcf8f 100644
--- a/src/devices/sound/pokey.h
+++ b/src/devices/sound/pokey.h
@@ -2,12 +2,13 @@
// copyright-holders:Brad Oliver, Eric Smith, Juergen Buchmueller
/*****************************************************************************
*
- * POKEY chip emulator 4.6
+ * POKEY chip emulator 4.9
*
* Based on original info found in Ron Fries' Pokey emulator,
* with additions by Brad Oliver, Eric Smith and Juergen Buchmueller.
* paddle (a/d conversion) details from the Atari 400/800 Hardware Manual.
* Polynomial algorithms according to info supplied by Perry McFarlane.
+ * Additional improvements from Mike Saarna's A7800 MAME fork.
*
*****************************************************************************/
@@ -49,7 +50,6 @@
//**************************************************************************
#define POKEY_KEYBOARD_CB_MEMBER(_name) uint8_t _name(uint8_t k543210)
-#define POKEY_INTERRUPT_CB_MEMBER(_name) void _name(int mask)
//**************************************************************************
// TYPE DEFINITIONS
@@ -114,14 +114,6 @@ public:
SKSTAT_C = 0x0F
};
- enum /* sync-operations */
- {
- SYNC_NOOP = 11,
- SYNC_SET_IRQST = 12,
- SYNC_POT = 13,
- SYNC_WRITE = 14
- };
-
enum output_type
{
LEGACY_LINEAR = 0,
@@ -138,19 +130,17 @@ public:
auto allpot_r() { return m_allpot_r_cb.bind(); }
auto serin_r() { return m_serin_r_cb.bind(); }
auto serout_w() { return m_serout_w_cb.bind(); }
+ auto irq_w() { return m_irq_w_cb.bind(); }
/* k543210 = k5 ... k0 returns bit0: kr1, bit1: kr2 */
/* all are, in contrast to actual hardware, ACTIVE_HIGH */
typedef device_delegate<uint8_t (uint8_t k543210)> kb_cb_delegate;
template <typename... T> void set_keyboard_callback(T &&... args) { m_keyboard_r.set(std::forward<T>(args)...); }
- typedef device_delegate<void (int mask)> int_cb_delegate;
- template <typename... T> void set_interrupt_callback(T &&... args) { m_irq_f.set(std::forward<T>(args)...); }
-
uint8_t read(offs_t offset);
void write(offs_t offset, uint8_t data);
- DECLARE_WRITE_LINE_MEMBER( sid_w ); // pin 24
+ void sid_w(int state); // pin 24
void serin_ready(int after);
// analog output configuration
@@ -190,7 +180,6 @@ protected:
virtual void device_reset() override;
virtual void device_post_load() override;
virtual void device_clock_changed() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
// device_sound_interface overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
@@ -201,39 +190,46 @@ protected:
// other internal states
int m_icount;
+ TIMER_CALLBACK_MEMBER(serout_ready_irq);
+ TIMER_CALLBACK_MEMBER(serout_complete_irq);
+ TIMER_CALLBACK_MEMBER(serin_ready_irq);
+ TIMER_CALLBACK_MEMBER(sync_write);
+ TIMER_CALLBACK_MEMBER(sync_pot);
+ TIMER_CALLBACK_MEMBER(sync_set_irqst);
+
private:
class pokey_channel
{
public:
pokey_channel();
- pokey_device *m_parent;
+
uint8_t m_INTMask;
- uint8_t m_AUDF; /* AUDFx (D200, D202, D204, D206) */
- uint8_t m_AUDC; /* AUDCx (D201, D203, D205, D207) */
- int32_t m_borrow_cnt; /* borrow counter */
- int32_t m_counter; /* channel counter */
- uint8_t m_output; /* channel output signal (1 active, 0 inactive) */
- uint8_t m_filter_sample; /* high-pass filter sample */
+ uint8_t m_AUDF; // AUDFx (D200, D202, D204, D206)
+ uint8_t m_AUDC; // AUDCx (D201, D203, D205, D207)
+ int32_t m_borrow_cnt; // borrow counter
+ int32_t m_counter; // channel counter
+ uint8_t m_output; // channel output signal (1 active, 0 inactive)
+ uint8_t m_filter_sample; // high-pass filter sample
- inline void sample(void) { m_filter_sample = m_output; }
- inline void reset_channel(void) { m_counter = m_AUDF ^ 0xff; }
+ void sample() { m_filter_sample = m_output; }
+ void reset_channel() { m_counter = m_AUDF ^ 0xff; m_borrow_cnt = 0; }
- inline void inc_chan()
+ void inc_chan(pokey_device &host, int cycles)
{
m_counter = (m_counter + 1) & 0xff;
if (m_counter == 0 && m_borrow_cnt == 0)
{
- m_borrow_cnt = 3;
- if (m_parent->m_IRQEN & m_INTMask)
+ m_borrow_cnt = cycles;
+ if (host.m_IRQEN & m_INTMask)
{
/* Exposed state has changed: This should only be updated after a resync ... */
- m_parent->synchronize(SYNC_SET_IRQST, m_INTMask);
+ host.machine().scheduler().synchronize(timer_expired_delegate(FUNC(pokey_device::sync_set_irqst), &host), m_INTMask);
}
}
}
- inline int check_borrow()
+ int check_borrow()
{
if (m_borrow_cnt > 0)
{
@@ -250,12 +246,12 @@ private:
void step_keyboard();
void step_pot();
- void poly_init_4_5(uint32_t *poly, int size, int xorbit, int invert);
+ void poly_init_4_5(uint32_t *poly, int size);
void poly_init_9_17(uint32_t *poly, int size);
void vol_init();
inline void process_channel(int ch);
- void pokey_potgo(void);
+ void pokey_potgo();
char *audc2str(int val);
char *audctl2str(int val);
@@ -280,9 +276,9 @@ private:
devcb_read8 m_allpot_r_cb;
devcb_read8 m_serin_r_cb;
devcb_write8 m_serout_w_cb;
+ devcb_write_line m_irq_w_cb;
kb_cb_delegate m_keyboard_r;
- int_cb_delegate m_irq_f;
uint8_t m_POTx[8]; /* POTx (R/D200-D207) */
uint8_t m_AUDCTL; /* AUDCTL (W/D208) */
@@ -312,6 +308,10 @@ private:
double m_r_pullup;
double m_cap;
double m_v_ref;
+
+ emu_timer *m_serout_ready_timer;
+ emu_timer *m_serout_complete_timer;
+ emu_timer *m_serin_ready_timer;
};