protected ay8910_device(machine_config mconfig, device_type type, string tag, device_t owner, u32 clock, psg_type_t psg_type, int streams, int ioports) : base(mconfig, type, tag, owner, clock) { m_class_interfaces.Add(new device_sound_interface_ay8910(mconfig, this)); // device_sound_interface(mconfig, *this); m_type = psg_type; m_streams = streams; m_ioports = ioports; m_ready = 0; m_channel = null; m_active = false; m_register_latch = 0; m_last_enable = 0; m_prescale_noise = 0; m_count_noise = 0; m_count_env = 0; m_env_step = 0; m_env_volume = 0; m_hold = 0; m_alternate = 0; m_attack = 0; m_holding = 0; m_rng = 0; m_env_step_mask = psg_type == psg_type_t.PSG_TYPE_AY ? (byte)0x0f : (byte)0x1f; m_step = psg_type == psg_type_t.PSG_TYPE_AY ? 2 : 1; m_zero_is_off = psg_type == psg_type_t.PSG_TYPE_AY ? 1 : 0; m_par = psg_type == psg_type_t.PSG_TYPE_AY ? ay8910_param : ym2149_param; m_par_env = psg_type == psg_type_t.PSG_TYPE_AY ? ay8910_param : ym2149_param_env; m_flags = AY8910_LEGACY_OUTPUT; m_port_a_read_cb = new devcb_read8(this); m_port_b_read_cb = new devcb_read8(this); m_port_a_write_cb = new devcb_write8(this); m_port_b_write_cb = new devcb_write8(this); memset(m_regs, (byte)0); memset(m_count, 0); memset(m_output, (byte)0); memset(m_vol_enabled, (byte)0); memset(m_vol_table, 0); memset(m_env_table, 0); m_res_load[0] = m_res_load[1] = m_res_load[2] = 1000; //Default values for resistor loads set_type(psg_type); }
// device_sound_interface - sound stream update overrides //virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); // trampolines for callbacks from fm.cpp //static void psg_set_clock(device_t *device, int clock) { downcast<ay8910_device *>(device)->ay_set_clock(clock); } //static void psg_write(device_t *device, int address, int data) { downcast<ay8910_device *>(device)->ay8910_write_ym(address, data); } //static int psg_read(device_t *device) { return downcast<ay8910_device *>(device)->ay8910_read_ym(); } //static void psg_reset(device_t *device) { downcast<ay8910_device *>(device)->ay8910_reset_ym(); } // internal helpers void set_type(psg_type_t psg_type) { m_type = psg_type; if (psg_type == psg_type_t.PSG_TYPE_AY) { m_env_step_mask = 0x0f; m_step = 2; m_zero_is_off = 1; m_par = ay8910_param; m_par_env = ay8910_param; } else { m_env_step_mask = 0x1f; m_step = 1; m_zero_is_off = 0; m_par = ym2149_param; m_par_env = ym2149_param_env; } }