示例#1
0
        static void build_single_table(double rl, ay_ym_param par, int normalize, ref int32_t [,] tab, int rank, int zero_is_off)//, int32_t *tab, int zero_is_off)
        {
            int    j;
            double rt;
            double rw;

            double [] temp = new double[32];
            double    min  = 10.0;
            double    max  = 0.0;

            for (j = 0; j < par.res_count; j++)
            {
                rt = 1.0 / par.r_down + 1.0 / rl;

                rw  = 1.0 / par.res[j];
                rt += 1.0 / par.res[j];

                if (!(zero_is_off != 0 && j == 0))
                {
                    rw += 1.0 / par.r_up;
                    rt += 1.0 / par.r_up;
                }

                temp[j] = rw / rt;
                if (temp[j] < min)
                {
                    min = temp[j];
                }
                if (temp[j] > max)
                {
                    max = temp[j];
                }
            }

            if (normalize != 0)
            {
                for (j = 0; j < par.res_count; j++)
                {
                    tab[rank, j] = (int)(MAX_OUTPUT * (((temp[j] - min) / (max - min)) - 0.25) * 0.5);
                }
            }
            else
            {
                for (j = 0; j < par.res_count; j++)
                {
                    tab[rank, j] = (int)(MAX_OUTPUT * temp[j]);
                }
            }
        }
示例#2
0
        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);
        }
示例#3
0
        // 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;
            }
        }
示例#4
0
        static void build_3D_table(double rl, ay_ym_param par, ay_ym_param par_env, int normalize, double factor, int zero_is_off, ref int [] tab)//, int32_t *tab)
        {
            double min = 10.0;
            double max = 0.0;

            std.vector <double> temp = new std.vector <double>(8 * 32 * 32 * 32, 0);

            for (int e = 0; e < 8; e++)
            {
                ay_ym_param par_ch1 = (e & 0x01) != 0 ? par_env : par;
                ay_ym_param par_ch2 = (e & 0x02) != 0 ? par_env : par;
                ay_ym_param par_ch3 = (e & 0x04) != 0 ? par_env : par;

                for (int j1 = 0; j1 < par_ch1.res_count; j1++)
                {
                    for (int j2 = 0; j2 < par_ch2.res_count; j2++)
                    {
                        for (int j3 = 0; j3 < par_ch3.res_count; j3++)
                        {
                            double n;
                            if (zero_is_off != 0)
                            {
                                n  = (j1 != 0 || (e & 0x01) != 0) ? 1 : 0;
                                n += (j2 != 0 || (e & 0x02) != 0) ? 1 : 0;
                                n += (j3 != 0 || (e & 0x04) != 0) ? 1 : 0;
                            }
                            else
                            {
                                n = 3.0;
                            }

                            double rt = n / par.r_up + 3.0 / par.r_down + 1.0 / rl;
                            double rw = n / par.r_up;

                            rw += 1.0 / par_ch1.res[j1];
                            rt += 1.0 / par_ch1.res[j1];
                            rw += 1.0 / par_ch2.res[j2];
                            rt += 1.0 / par_ch2.res[j2];
                            rw += 1.0 / par_ch3.res[j3];
                            rt += 1.0 / par_ch3.res[j3];

                            int indx = (e << 15) | (j3 << 10) | (j2 << 5) | j1;
                            temp[indx] = rw / rt;
                            if (temp[indx] < min)
                            {
                                min = temp[indx];
                            }
                            if (temp[indx] > max)
                            {
                                max = temp[indx];
                            }
                        }
                    }
                }
            }

            if (normalize != 0)
            {
                for (int j = 0; j < 32 * 32 * 32 * 8; j++)
                {
                    tab[j] = (int)(MAX_OUTPUT * (((temp[j] - min) / (max - min))) * factor);
                }
            }
            else
            {
                for (int j = 0; j < 32 * 32 * 32 * 8; j++)
                {
                    tab[j] = (int)(MAX_OUTPUT * temp[j]);
                }
            }

            /* for (e=0;e<16;e++) printf("%d %d\n",e<<10, tab[e<<10]); */
        }