Ejemplo n.º 1
0
        attotime m_last_update;                                                    // last update time


        // construction/destruction

        //-------------------------------------------------
        //  sound_manager - constructor
        //-------------------------------------------------
        public sound_manager(running_machine machine)
        {
            m_machine            = machine;
            m_update_timer       = null;
            m_finalmix_leftover  = 0;
            m_finalmix           = new std.vector <s16>(machine.sample_rate());
            m_leftmix            = new std.vector <s32>(machine.sample_rate());
            m_rightmix           = new std.vector <s32>(machine.sample_rate());
            m_nosound_mode       = machine.osd().no_sound() ? 1 : 0;
            m_wavfile            = null;
            m_update_attoseconds = STREAMS_UPDATE_ATTOTIME.attoseconds();
            m_last_update        = attotime.zero;


            // get filename for WAV file or AVI file if specified
            string wavfile = machine.options().wav_write();
            string avifile = machine.options().avi_write();

            // handle -nosound and lower sample rate if not recording WAV or AVI
            if (m_nosound_mode != 0 && string.IsNullOrEmpty(wavfile) && string.IsNullOrEmpty(avifile))
            {
                machine.sample_rate_set(11025);
            }

            // count the mixers
            if (sound_global.VERBOSE)
            {
                mixer_interface_iterator iter = new mixer_interface_iterator(machine.root_device());
                sound_global.VPRINTF("total mixers = {0}\n", iter.count());
            }

            // register callbacks
            machine.configuration().config_register("mixer", config_load, config_save);
            machine.add_notifier(machine_notification.MACHINE_NOTIFY_PAUSE, pause);
            machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESUME, resume);
            machine.add_notifier(machine_notification.MACHINE_NOTIFY_RESET, reset);
            machine.add_notifier(machine_notification.MACHINE_NOTIFY_EXIT, stop_recording);

            // register global states
            machine.save().save_item(m_last_update, "m_last_update");

            // set the starting attenuation
            set_attenuation(machine.options().volume());

            // start the periodic update flushing timer
            m_update_timer = machine.scheduler().timer_alloc(update, this);
            m_update_timer.adjust(STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME);
        }
Ejemplo n.º 2
0
        keycode_map m_keycode_map = new keycode_map();     // keycode map


        // construction/destruction
        //-------------------------------------------------
        //  natural_keyboard - constructor
        //-------------------------------------------------
        public natural_keyboard(running_machine machine)
        {
            m_machine         = machine;
            m_in_use          = false;
            m_bufbegin        = 0;
            m_bufend          = 0;
            m_fieldnum        = 0;
            m_status_keydown  = false;
            m_last_cr         = false;
            m_timer           = null;
            m_current_rate    = attotime.zero;
            m_queue_chars     = null;
            m_accept_char     = null;
            m_charqueue_empty = null;


            // try building a list of keycodes; if none are available, don't bother
            build_codes(machine.ioport());
            if (!m_keycode_map.empty())
            {
                m_buffer.resize(KEY_BUFFER_SIZE);
                m_timer = machine.scheduler().timer_alloc(timer);
            }

            // retrieve option setting
            set_in_use(machine.options().natural_keyboard());
        }
Ejemplo n.º 3
0
        public static void display_ui_chooser(running_machine machine)
        {
            mame_ui_manager  mui       = mame_machine_manager.instance().ui();
            render_container container = machine.render().ui_container();

            if (machine.options().ui() == emu_options.ui_option.UI_SIMPLE)
            {
                ui.simple_menu_select_game.force_game_select(mui, container);
            }
            else
            {
                ui.menu_select_game.force_game_select(mui, container);
            }
        }
Ejemplo n.º 4
0
        // construction/destruction

        //-------------------------------------------------
        //  video_manager - constructor
        //-------------------------------------------------
        public video_manager(running_machine machine)
        {
            m_machine = machine;
            m_screenless_frame_timer = null;
            m_output_changed         = false;
            m_throttle_realtime      = attotime.zero;
            m_throttle_emutime       = attotime.zero;
            m_throttle_history       = 0;
            m_speed_last_realtime    = 0;
            m_speed_last_emutime     = attotime.zero;
            m_speed_percent          = 1.0;
            m_overall_real_seconds   = 0;
            m_overall_real_ticks     = 0;
            m_overall_emutime        = attotime.zero;
            m_overall_valid_counter  = 0;
            m_frame_update_counter   = 0;
            m_throttled           = true;
            m_throttle_rate       = 1.0f;
            m_fastforward         = false;
            m_seconds_to_run      = (u32)machine.options().seconds_to_run();
            m_auto_frameskip      = machine.options().auto_frameskip();
            m_speed               = (u32)original_speed_setting();
            m_low_latency         = machine.options().low_latency();
            m_empty_skip_count    = 0;
            m_frameskip_max       = m_auto_frameskip ? (u8)machine.options().frameskip() : (u8)0;
            m_frameskip_level     = m_auto_frameskip ? (u8)0 : (u8)machine.options().frameskip();
            m_frameskip_counter   = 0;
            m_frameskip_adjust    = 0;
            m_skipping_this_frame = false;
            m_average_oversleep   = 0;
            m_snap_target         = null;
            m_snap_native         = true;
            m_snap_width          = 0;
            m_snap_height         = 0;


            // request a callback upon exiting
            machine.add_notifier(machine_notification.MACHINE_NOTIFY_EXIT, exit);
            machine.save().register_postload(postload);

            // extract initial execution state from global configuration settings
            update_refresh_speed();

            unsigned screen_count = (unsigned)(new screen_device_enumerator(machine.root_device()).count());
            bool     no_screens   = screen_count == 0;

            // create a render target for snapshots
            string viewname = machine.options().snap_view();

            m_snap_native = !no_screens && std.strcmp(viewname, "native") == 0;

            // the native target is hard-coded to our internal layout and has all options disabled
            if (m_snap_native)
            {
                throw new emu_unimplemented();
            }
            else
            {
                // other targets select the specified view and turn off effects
                m_snap_target = machine.render().target_alloc(null, RENDER_CREATE_HIDDEN);
                m_snap_target.set_view(m_snap_target.configured_view(viewname, 0, 1));
                m_snap_target.set_screen_overlay_enabled(false);
            }

            // extract snap resolution if present
            //if (sscanf(machine.options().snap_size(), "%dx%d", &m_snap_width, &m_snap_height) != 2)
            var parts = machine.options().snap_size().Split('x');

            if (parts.Length == 2)
            {
                m_snap_width  = Convert.ToInt32(parts[0]);
                m_snap_height = Convert.ToInt32(parts[1]);
            }
            else
            {
                m_snap_width = m_snap_height = 0;
            }

            // if no screens, create a periodic timer to drive updates
            if (no_screens)
            {
                m_screenless_frame_timer = machine.scheduler().timer_alloc(screenless_update_callback, this);
                m_screenless_frame_timer.adjust(screen_device.DEFAULT_FRAME_PERIOD, 0, screen_device.DEFAULT_FRAME_PERIOD);
                machine.output().set_global_notifier(video_notifier_callback, this);
            }
        }
Ejemplo n.º 5
0
        // updates
        //void animate(u16 auto_time);
        //void draw(render_container &container, u8 fade);


        // private helpers
        //-------------------------------------------------
        //  create_bitmap - create the rendering
        //  structures for the given player
        //-------------------------------------------------
        void create_bitmap()
        {
            rgb_t color = m_player < (int)std.size(crosshair_colors) ? crosshair_colors[m_player] : rgb_t.white();

            // if we have a bitmap and texture for this player, kill it
            if (m_bitmap == null)
            {
                m_bitmap  = new bitmap_argb32();
                m_texture = m_machine.render().texture_alloc(render_texture.hq_scale);
            }
            else
            {
                m_bitmap.reset();
            }

            emu_file crossfile = new emu_file(m_machine.options().crosshair_path(), OPEN_FLAG_READ);

            if (!m_name.empty())
            {
                // look for user specified file
                if (!crossfile.open(m_name + ".png"))
                {
                    render_load_png(out m_bitmap, crossfile.core_file_get());
                    crossfile.close();
                }
            }
            else
            {
                // look for default cross?.png in crsshair/game dir
                string filename = util.string_format("cross{0}.png", m_player + 1);
                if (!crossfile.open(m_machine.system().name + (PATH_SEPARATOR + filename)))
                {
                    render_load_png(out m_bitmap, crossfile.core_file_get());
                    crossfile.close();
                }

                // look for default cross?.png in crsshair dir
                if (!m_bitmap.valid() && !crossfile.open(filename))
                {
                    render_load_png(out m_bitmap, crossfile.core_file_get());
                    crossfile.close();
                }
            }

            /* if that didn't work, use the built-in one */
            if (!m_bitmap.valid())
            {
                /* allocate a blank bitmap to start with */
                m_bitmap.allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
                m_bitmap.fill(new rgb_t(0x00, 0xff, 0xff, 0xff));

                /* extract the raw source data to it */
                for (int y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
                {
                    /* assume it is mirrored vertically */
                    PointerU32 dest0 = m_bitmap.pix(y);                          //u32 *dest0 = &m_bitmap->pix(y);
                    PointerU32 dest1 = m_bitmap.pix(CROSSHAIR_RAW_SIZE - 1 - y); //u32 *dest1 = &m_bitmap->pix(CROSSHAIR_RAW_SIZE - 1 - y);

                    /* extract to two rows simultaneously */
                    for (int x = 0; x < CROSSHAIR_RAW_SIZE; x++)
                    {
                        if (((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80) != 0)
                        {
                            dest0[x] = dest1[x] = new rgb_t(0xff, 0x00, 0x00, 0x00) | color;
                        }
                    }
                }
            }

            /* reference the new bitmap */
            m_texture.set_bitmap(m_bitmap, m_bitmap.cliprect(), texture_format.TEXFORMAT_ARGB32);
        }
Ejemplo n.º 6
0
        // updates
        //void animate(u16 auto_time);
        //void draw(render_container &container, u8 fade);


        // private helpers
        //-------------------------------------------------
        //  create_bitmap - create the rendering
        //  structures for the given player
        //-------------------------------------------------
        void create_bitmap()
        {
            int   x;
            int   y;
            rgb_t color = m_player < crosshair_colors.Length ? crosshair_colors[m_player] : rgb_t.white();

            // if we have a bitmap and texture for this player, kill it
            if (m_bitmap == null)
            {
                m_bitmap  = new bitmap_argb32();
                m_texture = m_machine.render().texture_alloc(render_texture.hq_scale);
            }

            emu_file crossfile = new emu_file(m_machine.options().crosshair_path(), OPEN_FLAG_READ);

            if (!m_name.empty())
            {
                // look for user specified file
                string filename = m_name + ".png";
                render_load_png(out m_bitmap, crossfile, null, filename.c_str());
            }
            else
            {
                // look for default cross?.png in crsshair/game dir
                string filename = string.Format("cross{0}.png", m_player + 1);
                render_load_png(out m_bitmap, crossfile, m_machine.system().name, filename.c_str());

                // look for default cross?.png in crsshair dir
                if (!m_bitmap.valid())
                {
                    render_load_png(out m_bitmap, crossfile, null, filename.c_str());
                }
            }

            crossfile.close();

            /* if that didn't work, use the built-in one */
            if (!m_bitmap.valid())
            {
                /* allocate a blank bitmap to start with */
                m_bitmap.allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
                m_bitmap.fill(new rgb_t(0x00, 0xff, 0xff, 0xff));

                /* extract the raw source data to it */
                for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
                {
                    /* assume it is mirrored vertically */
                    //u32 *dest0 = &m_bitmap->pix32(y);
                    RawBuffer dest0Buf;
                    UInt32    dest0Offset = m_bitmap.pix32(out dest0Buf, y);
                    //u32 *dest1 = &m_bitmap->pix32(CROSSHAIR_RAW_SIZE - 1 - y);
                    RawBuffer dest1Buf;
                    UInt32    dest1Offset = m_bitmap.pix32(out dest1Buf, CROSSHAIR_RAW_SIZE - 1 - y);

                    /* extract to two rows simultaneously */
                    for (x = 0; x < CROSSHAIR_RAW_SIZE; x++)
                    {
                        if (((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80) != 0)
                        {
                            //dest0[x] = dest1[x] = new rgb_t(0xff,0x00,0x00,0x00) | color;
                            dest0Buf.set_uint32((int)dest0Offset + x, new rgb_t(0xff, 0x00, 0x00, 0x00) | color);
                            dest1Buf.set_uint32((int)dest1Offset + x, new rgb_t(0xff, 0x00, 0x00, 0x00) | color);
                        }
                    }
                }
            }

            /* reference the new bitmap */
            m_texture.set_bitmap(m_bitmap, m_bitmap.cliprect(), texture_format.TEXFORMAT_ARGB32);
        }