コード例 #1
0
        // device-level overrides

        //-------------------------------------------------
        //  device_start - device-specific startup
        //-------------------------------------------------
        protected override void device_start()
        {
            m_disound = GetClassInterface <device_sound_interface_ay8910>();


            int master_clock = (int)clock();

            if (m_ioports < 1 && !(m_port_a_read_cb.isnull() && m_port_a_write_cb.isnull()))
            {
                fatalerror("Device '{0}' is a {1} and has no port A!", tag(), name());
            }

            if (m_ioports < 2 && !(m_port_b_read_cb.isnull() && m_port_b_write_cb.isnull()))
            {
                fatalerror("Device '{0}' is a {1} and has no port B!", tag(), name());
            }

            m_port_a_read_cb.resolve();
            m_port_b_read_cb.resolve();
            m_port_a_write_cb.resolve();
            m_port_b_write_cb.resolve();

            if ((m_flags & AY8910_SINGLE_OUTPUT) != 0)
            {
                logerror("{0} device using single output!\n", name());
                m_streams = 1;
            }

            m_vol3d_table = new int[8 * 32 * 32 * 32];  // make_unique_clear<int32_t[]>(8*32*32*32);

            build_mixer_table();

            /* The envelope is pacing twice as fast for the YM2149 as for the AY-3-8910,    */
            /* This handled by the step parameter. Consequently we use a divider of 8 here. */
            m_channel = machine().sound().stream_alloc(this, 0, m_streams, master_clock / 8);

            ay_set_clock(master_clock);
            ay8910_statesave();
        }
コード例 #2
0
        // internal helpers

        //-------------------------------------------------
        //  update_bit - update one of the eight output
        //  lines with a new data bit
        //-------------------------------------------------
        void update_bit()
        {
            // first verify that the selected bit is actually changing
            if (BIT(m_q, m_address) == (m_data ? 1 : 0))
            {
                return;
            }

            if (!m_clear)
            {
                // update selected bit with new data
                m_q = (byte)((m_q & ~(1 << m_address)) | ((m_data ? 1 : 0) << m_address));
            }
            else
            {
                // clear any other bit that was formerly set
                clear_outputs(0);
                m_q = (byte)((m_data ? 1 : 0) << m_address);
            }

            // update output line via callback
            if (!m_q_out_cb[m_address].isnull())
            {
                m_q_out_cb[m_address].op(m_data ? 1 : 0);
            }

            // update parallel output
            if (!m_parallel_out_cb.isnull())
            {
                m_parallel_out_cb.op(0, m_q, (byte)(1 << m_address));
            }

            // do some logging
            if (LOG_ALL_WRITES || (LOG_UNDEFINED_WRITES && m_q_out_cb[m_address].isnull() && m_parallel_out_cb.isnull()))
            {
                logerror("Q{0} {1} at {2}\n", m_address, m_data ? "set" : "cleared", machine().describe_context());  // Q%d %s at %s\n
            }
        }