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; }
int video_init(running_machine *machine) { int scrnum; add_exit_callback(machine, video_exit); /* reset globals */ memset(scrinfo, 0, sizeof(scrinfo)); /* configure all of the screens */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) if (machine->drv->screen[scrnum].tag != NULL) { internal_screen_info *info = &scrinfo[scrnum]; screen_state *state = &machine->screen[scrnum]; /* configure the screen with the default parameters */ video_screen_configure(scrnum, state->width, state->height, &state->visarea, state->refresh); /* reset VBLANK timing */ info->vblank_time = sub_mame_times(time_zero, double_to_mame_time(Machine->screen[0].vblank)); /* register for save states */ state_save_register_item("video", scrnum, info->vblank_time.seconds); state_save_register_item("video", scrnum, info->vblank_time.subseconds); } /* create spriteram buffers if necessary */ if (machine->drv->video_attributes & VIDEO_BUFFERS_SPRITERAM) init_buffered_spriteram(); /* 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 != NULL) allocate_graphics(machine->drv->gfxdecodeinfo); /* configure the palette */ palette_config(machine); /* actually decode the graphics */ if (machine->drv->gfxdecodeinfo != NULL) decode_graphics(machine->drv->gfxdecodeinfo); /* reset performance data */ last_fps_time = osd_ticks(); rendered_frames_since_last_fps = frames_since_last_fps = 0; performance.game_speed_percent = 100; performance.frames_per_second = machine->screen[0].refresh; 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(machine) != 0) fatalerror("tilemap_init failed"); /* create a render target for snapshots */ if (Machine->drv->screen[0].tag != NULL) { snap_bitmap = NULL; snap_target = render_target_alloc(layout_snap, RENDER_CREATE_SINGLE_FILE | RENDER_CREATE_HIDDEN); assert(snap_target != NULL); if (snap_target == NULL) return 1; render_target_set_layer_config(snap_target, 0); } /* create crosshairs */ crosshair_init(); return 0; }