Fix regression on POKEY device introduced in last commit.

Fixed high pass filters for POKEY.
Added POKEYN device based on modern device. Migrated bzone,
ccastles and missile to use this device. [Couriersud]
This commit is contained in:
Couriersud 2012-05-18 20:47:57 +00:00
parent 13efa048d6
commit 64b0ae9b73
6 changed files with 1076 additions and 35 deletions

File diff suppressed because it is too large Load Diff

View File

@ -92,4 +92,108 @@ void pokey_kbcode_w (device_t *device, int kbcode, int make);
DECLARE_LEGACY_SOUND_DEVICE(POKEY, pokey);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> pokey_device
class pokeyn_device : public device_t,
public device_sound_interface
{
public:
// construction/destruction
pokeyn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
virtual void device_post_load();
virtual void device_clock_changed();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// device_sound_interface overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
// configuration state
pokey_interface m_intf;
private:
void poly_init(UINT8 *poly, int size, int left, int right, int add);
void rand_init(UINT8 *rng, int size, int left, int right, int add);
inline void process_channel(int ch);
inline void reset_channel(int ch);
inline void inc_chan(int ch);
inline int check_borrow(int ch);
void pokey_potgo(void);
void write_cmd(int offset, UINT8 data);
// internal state
sound_stream* m_stream;
INT32 m_clock_cnt[3]; /* clock counters */
INT32 m_borrow_cnt[4]; /* borrow counters */
INT32 m_counter[4]; /* channel counter */
INT32 m_divisor[4]; /* channel divisor (modulo value) */
UINT32 m_volume[4]; /* channel volume - derived */
UINT8 m_output[4]; /* channel output signal (1 active, 0 inactive) */
UINT8 m_filter_sample[4]; /* hi-pass filter sample */
UINT32 m_p4; /* poly4 index */
UINT32 m_p5; /* poly5 index */
UINT32 m_p9; /* poly9 index */
UINT32 m_p17; /* poly17 index */
UINT32 m_r9; /* rand9 index */
UINT32 m_r17; /* rand17 index */
UINT32 m_clockmult; /* clock multiplier */
emu_timer *m_timer[3]; /* timers for channel 1,2 and 4 events */
attotime m_timer_period[3]; /* computed periods for these timers */
int m_timer_param[3]; /* computed parameters for these timers */
emu_timer *m_rtimer; /* timer for calculating the random offset */
emu_timer *m_ptimer[8]; /* pot timers */
devcb_resolved_read8 m_pot_r[8];
devcb_resolved_read8 m_allpot_r;
devcb_resolved_read8 m_serin_r;
devcb_resolved_write8 m_serout_w;
void (*m_interrupt_cb)(device_t *device, int mask);
UINT8 m_AUDF[4]; /* AUDFx (D200, D202, D204, D206) */
UINT8 m_AUDC[4]; /* AUDCx (D201, D203, D205, D207) */
UINT8 m_POTx[8]; /* POTx (R/D200-D207) */
UINT8 m_AUDCTL; /* AUDCTL (W/D208) */
UINT8 m_ALLPOT; /* ALLPOT (R/D208) */
UINT8 m_KBCODE; /* KBCODE (R/D209) */
UINT8 m_RANDOM; /* RANDOM (R/D20A) */
UINT8 m_SERIN; /* SERIN (R/D20D) */
UINT8 m_SEROUT; /* SEROUT (W/D20D) */
UINT8 m_IRQST; /* IRQST (R/D20E) */
UINT8 m_IRQEN; /* IRQEN (W/D20E) */
UINT8 m_SKSTAT; /* SKSTAT (R/D20F) */
UINT8 m_SKCTL; /* SKCTL (W/D20F) */
attotime m_clock_period;
attotime m_ad_time_fast;
attotime m_ad_time_slow;
UINT8 m_poly4[0x0f];
UINT8 m_poly5[0x1f];
UINT8 m_poly9[0x1ff];
UINT8 m_poly17[0x1ffff];
UINT8 m_rand9[0x1ff];
UINT8 m_rand17[0x1ffff];
};
// device type definition
extern const device_type POKEYN;
#endif /* __POKEY_H__ */

View File

@ -400,7 +400,7 @@ MACHINE_CONFIG_FRAGMENT( bzone_audio )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("pokey", POKEY, BZONE_MASTER_CLOCK / 8)
MCFG_SOUND_ADD("pokey", POKEYN, BZONE_MASTER_CLOCK / 8)
MCFG_SOUND_CONFIG(bzone_pokey_interface)
MCFG_SOUND_ROUTE_EX(0, "discrete", 1.0, 0)

View File

@ -309,7 +309,8 @@ static ADDRESS_MAP_START( bzone_map, AS_PROGRAM, 8, bzone_state )
AM_RANGE(0x1800, 0x1800) AM_DEVREAD_LEGACY("mathbox", mathbox_status_r)
AM_RANGE(0x1810, 0x1810) AM_DEVREAD_LEGACY("mathbox", mathbox_lo_r)
AM_RANGE(0x1818, 0x1818) AM_DEVREAD_LEGACY("mathbox", mathbox_hi_r)
AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
// AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokeyn_device, read, write)
AM_RANGE(0x1840, 0x1840) AM_DEVWRITE_LEGACY("discrete", bzone_sounds_w)
AM_RANGE(0x1860, 0x187f) AM_DEVWRITE_LEGACY("mathbox", mathbox_go_w)
AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_LEGACY(&avgdvg_vectorram) AM_SIZE_LEGACY(&avgdvg_vectorram_size) AM_REGION("maincpu", 0x2000)
@ -333,7 +334,8 @@ static ADDRESS_MAP_START( redbaron_map, AS_PROGRAM, 8, bzone_state )
AM_RANGE(0x1808, 0x1808) AM_DEVWRITE_LEGACY("custom", redbaron_joysound_w) /* and select joystick pot also */
AM_RANGE(0x180a, 0x180a) AM_WRITENOP /* sound reset, yet todo */
AM_RANGE(0x180c, 0x180c) AM_DEVWRITE("earom", atari_vg_earom_device, ctrl_w)
AM_RANGE(0x1810, 0x181f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
//AM_RANGE(0x1810, 0x181f) AM_DEVREADWRITE_LEGACY("pokey", pokey_r, pokey_w)
AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokeyn_device, read, write)
AM_RANGE(0x1820, 0x185f) AM_DEVREADWRITE("earom", atari_vg_earom_device, read, write)
AM_RANGE(0x1860, 0x187f) AM_DEVWRITE_LEGACY("mathbox", mathbox_go_w)
AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_LEGACY(&avgdvg_vectorram) AM_SIZE_LEGACY(&avgdvg_vectorram_size) AM_REGION("maincpu", 0x2000)
@ -600,7 +602,7 @@ static MACHINE_CONFIG_DERIVED( redbaron, bzone_base )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("pokey", POKEY, 1500000)
MCFG_SOUND_ADD("pokey", POKEYN, 1500000)
MCFG_SOUND_CONFIG(redbaron_pokey_interface)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)

View File

@ -333,8 +333,8 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, ccastles_state )
AM_RANGE(0x9000, 0x90ff) AM_MIRROR(0x0300) AM_READWRITE(nvram_r, nvram_w)
AM_RANGE(0x9400, 0x9403) AM_MIRROR(0x01fc) AM_READ(leta_r)
AM_RANGE(0x9600, 0x97ff) AM_READ_PORT("IN0")
AM_RANGE(0x9800, 0x980f) AM_MIRROR(0x01f0) AM_DEVREADWRITE_LEGACY("pokey1", pokey_r, pokey_w)
AM_RANGE(0x9a00, 0x9a0f) AM_MIRROR(0x01f0) AM_DEVREADWRITE_LEGACY("pokey2", pokey_r, pokey_w)
AM_RANGE(0x9800, 0x980f) AM_MIRROR(0x01f0) AM_DEVREADWRITE("pokey1", pokeyn_device, read, write)
AM_RANGE(0x9a00, 0x9a0f) AM_MIRROR(0x01f0) AM_DEVREADWRITE("pokey2", pokeyn_device, read, write)
AM_RANGE(0x9c00, 0x9c7f) AM_WRITE(nvram_recall_w)
AM_RANGE(0x9c80, 0x9cff) AM_WRITE(ccastles_hscroll_w)
AM_RANGE(0x9d00, 0x9d7f) AM_WRITE(ccastles_vscroll_w)
@ -495,10 +495,10 @@ static MACHINE_CONFIG_START( ccastles, ccastles_state )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("pokey1", POKEY, MASTER_CLOCK/8)
MCFG_SOUND_ADD("pokey1", POKEYN, MASTER_CLOCK/8)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("pokey2", POKEY, MASTER_CLOCK/8)
MCFG_SOUND_ADD("pokey2", POKEYN, MASTER_CLOCK/8)
MCFG_SOUND_CONFIG(pokey_config)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_CONFIG_END

View File

@ -714,6 +714,7 @@ static SCREEN_UPDATE_IND16( missile )
WRITE8_MEMBER(missile_state::missile_w)
{
UINT8 *videoram = m_videoram;
/* if we're in MADSEL mode, write to video RAM */
if (get_madsel(&space))
{
@ -730,7 +731,10 @@ WRITE8_MEMBER(missile_state::missile_w)
/* POKEY */
else if (offset < 0x4800)
pokey_w(machine().device("pokey"), offset & 0x0f, data);
{
pokeyn_device *pokey_dev = downcast<pokeyn_device *>(machine().device("pokey"));
pokey_dev->write(*machine().firstcpu->space(), offset, data, 0xff);
}
/* OUT0 */
else if (offset < 0x4900)
@ -790,7 +794,10 @@ READ8_MEMBER(missile_state::missile_r)
/* POKEY */
else if (offset < 0x4800)
result = pokey_r(machine().device("pokey"), offset & 0x0f);
{
pokeyn_device *pokey_dev = downcast<pokeyn_device *>(machine().device("pokey"));
result = pokey_dev->read(*machine().firstcpu->space(), offset & 0x0f, 0xff);
}
/* IN0 */
else if (offset < 0x4900)
@ -1046,7 +1053,7 @@ static MACHINE_CONFIG_START( missile, missile_state )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("pokey", POKEY, MASTER_CLOCK/8)
MCFG_SOUND_ADD("pokey", POKEYN, MASTER_CLOCK/8)
MCFG_SOUND_CONFIG(pokey_config)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END