int sound_init(running_machine *machine) { /* handle -nosound */ nosound_mode = (Machine->sample_rate == 0); if (nosound_mode) Machine->sample_rate = 11025; /* count the speakers */ for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ; VPRINTF(("total speakers = %d\n", totalspeakers)); /* initialize the OSD layer */ VPRINTF(("osd_start_audio_stream\n")); samples_this_frame = osd_start_audio_stream(1); if (!samples_this_frame) return 1; /* allocate memory for mix buffers */ leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix)); rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix)); finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix)); /* allocate a global timer for sound timing */ sound_update_timer = mame_timer_alloc(NULL); /* initialize the streams engine */ VPRINTF(("streams_init\n")); streams_init(); /* now start up the sound chips and tag their streams */ VPRINTF(("start_sound_chips\n")); if (start_sound_chips()) return 1; /* then create all the speakers */ VPRINTF(("start_speakers\n")); if (start_speakers()) return 1; /* finally, do all the routing */ VPRINTF(("route_sound\n")); if (route_sound()) return 1; if (MAKE_WAVS) wavfile = wav_open("finalmix.wav", Machine->sample_rate, 2); /* enable sound by default */ global_sound_enabled = TRUE; /* register callbacks */ config_register("mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); return 0; }
void sound_init(running_machine *machine) { attotime update_frequency = SOUND_UPDATE_FREQUENCY; const char *filename; /* handle -nosound */ nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND); if (nosound_mode) Machine->sample_rate = 11025; /* count the speakers */ for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ; VPRINTF(("total speakers = %d\n", totalspeakers)); /* allocate memory for mix buffers */ leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix)); rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix)); finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix)); /* allocate a global timer for sound timing */ sound_update_timer = timer_alloc(sound_update, NULL); timer_adjust(sound_update_timer, update_frequency, 0, update_frequency); /* initialize the streams engine */ VPRINTF(("streams_init\n")); streams_init(machine, update_frequency.attoseconds); /* now start up the sound chips and tag their streams */ VPRINTF(("start_sound_chips\n")); start_sound_chips(); /* then create all the speakers */ VPRINTF(("start_speakers\n")); start_speakers(); /* finally, do all the routing */ VPRINTF(("route_sound\n")); route_sound(); /* open the output WAV file if specified */ filename = options_get_string(mame_options(), OPTION_WAVWRITE); if (filename[0] != 0) wavfile = wav_open(filename, machine->sample_rate, 2); /* enable sound by default */ global_sound_enabled = TRUE; sound_muted = FALSE; sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); /* register callbacks */ config_register("mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); }
int video_init(void) { osd_create_params params; artwork_callbacks *artcallbacks; int bmwidth = Machine->drv->screen_width; int bmheight = Machine->drv->screen_height; movie_file = NULL; movie_frame = 0; add_pause_callback(video_pause); add_exit_callback(video_exit); /* first allocate the necessary palette structures */ if (palette_start()) return 1; #ifndef NEW_RENDER /* if we're a vector game, override the screen width and height */ if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR) scale_vectorgames(options.vector_width, options.vector_height, &bmwidth, &bmheight); /* compute the visible area for raster games */ if (!(Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)) { params.width = Machine->drv->default_visible_area.max_x - Machine->drv->default_visible_area.min_x + 1; params.height = Machine->drv->default_visible_area.max_y - Machine->drv->default_visible_area.min_y + 1; } else { params.width = bmwidth; params.height = bmheight; } /* fill in the rest of the display parameters */ compute_aspect_ratio(Machine->drv, ¶ms.aspect_x, ¶ms.aspect_y); params.depth = Machine->color_depth; params.colors = palette_get_total_colors_with_ui(); params.fps = Machine->drv->frames_per_second; params.video_attributes = Machine->drv->video_attributes; #ifdef MESS artcallbacks = &mess_artwork_callbacks; #else artcallbacks = &mame_artwork_callbacks; #endif /* initialize the display through the artwork (and eventually the OSD) layer */ if (artwork_create_display(¶ms, direct_rgb_components, artcallbacks)) return 1; /* the create display process may update the vector width/height, so recompute */ if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR) scale_vectorgames(options.vector_width, options.vector_height, &bmwidth, &bmheight); /* now allocate the screen bitmap */ scrbitmap[0] = auto_bitmap_alloc_depth(bmwidth, bmheight, Machine->color_depth); if (!scrbitmap[0]) return 1; #endif /* set the default refresh rate */ set_refresh_rate(Machine->drv->frames_per_second); /* set the default visible area */ set_visible_area(0,1,0,1); // make sure everything is recalculated on multiple runs set_visible_area( Machine->drv->default_visible_area.min_x, Machine->drv->default_visible_area.max_x, Machine->drv->default_visible_area.min_y, Machine->drv->default_visible_area.max_y); /* create spriteram buffers if necessary */ if (Machine->drv->video_attributes & VIDEO_BUFFERS_SPRITERAM) if (init_buffered_spriteram()) return 1; #ifndef NEW_RENDER #if defined(MAME_DEBUG) && !defined(NEW_DEBUGGER) /* if the debugger is enabled, initialize its bitmap and font */ if (Machine->debug_mode) { int depth = options.debug_depth ? options.debug_depth : Machine->color_depth; /* first allocate the debugger bitmap */ Machine->debug_bitmap = auto_bitmap_alloc_depth(options.debug_width, options.debug_height, depth); if (!Machine->debug_bitmap) return 1; /* then create the debugger font */ Machine->debugger_font = build_debugger_font(); if (Machine->debugger_font == NULL) return 1; } #endif #endif /* convert the gfx ROMs into character sets. This is done BEFORE calling the driver's */ /* palette_init() routine because it might need to check the Machine->gfx[] data */ if (Machine->drv->gfxdecodeinfo) if (allocate_graphics(Machine->drv->gfxdecodeinfo)) return 1; /* initialize the palette - must be done after osd_create_display() */ if (palette_init()) return 1; /* force the first update to be full */ set_vh_global_attribute(NULL, 0); /* actually decode the graphics */ if (Machine->drv->gfxdecodeinfo) decode_graphics(Machine->drv->gfxdecodeinfo); /* reset performance data */ last_fps_time = osd_cycles(); rendered_frames_since_last_fps = frames_since_last_fps = 0; performance.game_speed_percent = 100; performance.frames_per_second = Machine->refresh_rate; performance.vector_updates_last_second = 0; /* reset video statics and get out of here */ pdrawgfx_shadow_lowpri = 0; leds_status = 0; /* initialize tilemaps */ if (tilemap_init() != 0) fatalerror("tilemap_init failed"); return 0; }