diff options
65 files changed, 708 insertions, 591 deletions
diff --git a/src/emu/mame.h b/src/emu/mame.h index 3a333e99bd2..00271c2c1a8 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -179,7 +179,6 @@ struct _running_machine /* video-related information */ gfx_element * gfx[MAX_GFX_ELEMENTS];/* array of pointers to graphic sets (chars, sprites) */ - screen_state screen[MAX_SCREENS];/* current screen state (to go away) */ const device_config * primary_screen; /* the primary screen device, or NULL if screenless */ palette_t * palette; /* global palette object */ diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 962747db6fd..6681d94608e 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -1855,7 +1855,7 @@ static view_item *load_view_item(xml_data_node *itemnode, layout_element *elemli /* sanity checks */ if (strcmp(itemnode->name, "screen") == 0) { - if (item->index >= MAX_SCREENS) + if (item->index < 0) fatalerror("Layout references invalid screen index %d", item->index); } else diff --git a/src/emu/video.c b/src/emu/video.c index c06969396bc..48faee5a201 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -45,10 +45,12 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _internal_screen_state internal_screen_state; -struct _internal_screen_state +typedef struct _screen_state screen_state; +struct _screen_state { - /* screen attributes */ + /* dimensions */ + int width; /* current width (HTOTAL) */ + int height; /* current height (VTOTAL) */ rectangle visarea; /* current visible area (HBLANK end/start, VBLANK end/start) */ /* textures and bitmaps */ @@ -277,8 +279,8 @@ INLINE int effective_throttle(running_machine *machine) void video_init(running_machine *machine) { - const device_config *screen; const char *filename; + const device_config *screen; /* validate */ assert(machine != NULL); @@ -305,63 +307,6 @@ void video_init(running_machine *machine) /* set the first screen device as the primary - this will set NULL if screenless */ machine->primary_screen = video_screen_first(machine->config); - for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) - { - char unique_tag[40]; - - int scrnum = device_list_index(machine->config->devicelist, VIDEO_SCREEN, screen->tag); - - render_container *container = render_container_get_screen(screen); - screen_config *config = screen->inline_config; - screen_state *state = &machine->screen[scrnum]; - - /* allocate the private state and hook it up to the public structure */ - internal_screen_state *internal_state = auto_malloc(sizeof(*internal_state)); - memset(internal_state, 0, sizeof(*internal_state)); - state->private_data = internal_state; - - /* allocate the VBLANK timers */ - internal_state->vblank_begin_timer = timer_alloc(vblank_begin_callback, (void *)screen); - internal_state->vblank_end_timer = timer_alloc(vblank_end_callback, (void *)screen); - - /* allocate a timer to reset partial updates */ - internal_state->scanline0_timer = timer_alloc(scanline0_callback, (void *)screen); - - /* configure the screen with the default parameters */ - video_screen_configure(screen, config->width, config->height, &config->visarea, config->refresh); - - /* configure the default cliparea */ - if (config->xoffset != 0) - render_container_set_xoffset(container, config->xoffset); - if (config->yoffset != 0) - render_container_set_yoffset(container, config->yoffset); - if (config->xscale != 0) - render_container_set_xscale(container, config->xscale); - if (config->yscale != 0) - render_container_set_yscale(container, config->yscale); - - /* reset VBLANK timing */ - internal_state->vblank_start_time = attotime_zero; - internal_state->vblank_end_time = attotime_make(0, internal_state->vblank_period); - - /* allocate a timer to generate per-scanline updates */ - if (machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) - { - internal_state->scanline_timer = timer_alloc(scanline_update_callback, (void *)screen); - timer_adjust_oneshot(internal_state->scanline_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); - } - - /* register for save states */ - assert(strlen(screen->tag) < 30); - state_save_combine_module_and_tag(unique_tag, "video_screen", screen->tag); - - state_save_register_item(unique_tag, 0, internal_state->vblank_start_time.seconds); - state_save_register_item(unique_tag, 0, internal_state->vblank_start_time.attoseconds); - state_save_register_item(unique_tag, 0, internal_state->vblank_end_time.seconds); - state_save_register_item(unique_tag, 0, internal_state->vblank_end_time.attoseconds); - state_save_register_item(unique_tag, 0, internal_state->frame_number); - } - /* create spriteram buffers if necessary */ if (machine->config->video_attributes & VIDEO_BUFFERS_SPRITERAM) init_buffered_spriteram(); @@ -393,6 +338,98 @@ void video_init(running_machine *machine) filename = options_get_string(mame_options(), OPTION_MNGWRITE); if ((filename[0] != 0) && (machine->primary_screen != NULL)) video_movie_begin_recording(machine->primary_screen, filename); + + /* for each screen */ + for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) + { + screen_state *state = get_safe_token(screen); + screen_config *config = screen->inline_config; + + /* configure the screen with the default parameters */ + video_screen_configure(screen, config->width, config->height, &config->visarea, config->refresh); + + /* reset VBLANK timing */ + state->vblank_start_time = attotime_zero; + state->vblank_end_time = attotime_make(0, state->vblank_period); + + /* start the timer to generate per-scanline updates */ + if (machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) + timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + } +} + + +/*------------------------------------------------- + screen_init - initializes the state of a + single screen device +-------------------------------------------------*/ + +static screen_state *screen_init(const device_config *screen) +{ + char unique_tag[40]; + screen_state *state; + render_container *container; + screen_config *config; + + /* validate some basic stuff */ + assert(screen != NULL); + assert(screen->static_config == NULL); + assert(screen->inline_config != NULL); + assert(screen->machine != NULL); + assert(screen->machine->config != NULL); + + /* get and validate that the container for this screen exists */ + container = render_container_get_screen(screen); + assert(container != NULL); + + /* get and validate the configuration */ + config = screen->inline_config; + assert(config->width > 0); + assert(config->height > 0); + assert(config->refresh > 0); + assert(config->visarea.min_x >= 0); + assert(config->visarea.max_x < config->width); + assert(config->visarea.max_x > config->visarea.min_x); + assert(config->visarea.min_y >= 0); + assert(config->visarea.max_y < config->height); + assert(config->visarea.max_y > config->visarea.min_y); + + /* everything checks out, allocate the state object */ + state = auto_malloc(sizeof(*state)); + memset(state, 0, sizeof(*state)); + + /* allocate the VBLANK timers */ + state->vblank_begin_timer = timer_alloc(vblank_begin_callback, (void *)screen); + state->vblank_end_timer = timer_alloc(vblank_end_callback, (void *)screen); + + /* allocate a timer to reset partial updates */ + state->scanline0_timer = timer_alloc(scanline0_callback, (void *)screen); + + /* configure the default cliparea */ + if (config->xoffset != 0) + render_container_set_xoffset(container, config->xoffset); + if (config->yoffset != 0) + render_container_set_yoffset(container, config->yoffset); + if (config->xscale != 0) + render_container_set_xscale(container, config->xscale); + if (config->yscale != 0) + render_container_set_yscale(container, config->yscale); + + /* allocate a timer to generate per-scanline updates */ + if (screen->machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) + state->scanline_timer = timer_alloc(scanline_update_callback, (void *)screen); + + /* register for save states */ + assert(strlen(screen->tag) < 30); + state_save_combine_module_and_tag(unique_tag, "video_screen", screen->tag); + + state_save_register_item(unique_tag, 0, state->vblank_start_time.seconds); + state_save_register_item(unique_tag, 0, state->vblank_start_time.attoseconds); + state_save_register_item(unique_tag, 0, state->vblank_end_time.seconds); + state_save_register_item(unique_tag, 0, state->vblank_end_time.attoseconds); + state_save_register_item(unique_tag, 0, state->frame_number); + + return state; } @@ -421,16 +458,15 @@ static void video_exit(running_machine *machine) for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - - if (internal_state->texture[0] != NULL) - render_texture_free(internal_state->texture[0]); - if (internal_state->texture[1] != NULL) - render_texture_free(internal_state->texture[1]); - if (internal_state->bitmap[0] != NULL) - bitmap_free(internal_state->bitmap[0]); - if (internal_state->bitmap[1] != NULL) - bitmap_free(internal_state->bitmap[1]); + + if (state->texture[0] != NULL) + render_texture_free(state->texture[0]); + if (state->texture[1] != NULL) + render_texture_free(state->texture[1]); + if (state->bitmap[0] != NULL) + bitmap_free(state->bitmap[0]); + if (state->bitmap[1] != NULL) + bitmap_free(state->bitmap[1]); } /* free the snapshot target */ @@ -672,7 +708,6 @@ static void decode_graphics(running_machine *machine, const gfx_decode_entry *gf void video_screen_configure(const device_config *screen, int width, int height, const rectangle *visarea, attoseconds_t frame_period) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; screen_config *config = screen->inline_config; /* validate arguments */ @@ -693,10 +728,10 @@ void video_screen_configure(const device_config *screen, int width, int height, assert(visarea->min_y < height); /* extract the current width/height from the bitmap */ - if (internal_state->bitmap[0] != NULL) + if (state->bitmap[0] != NULL) { - curwidth = internal_state->bitmap[0]->width; - curheight = internal_state->bitmap[0]->height; + curwidth = state->bitmap[0]->width; + curheight = state->bitmap[0]->height; } /* if we're too small to contain this width/height, reallocate our bitmaps and textures */ @@ -705,14 +740,14 @@ void video_screen_configure(const device_config *screen, int width, int height, bitmap_format screen_format = config->format; /* free what we have currently */ - if (internal_state->texture[0] != NULL) - render_texture_free(internal_state->texture[0]); - if (internal_state->texture[1] != NULL) - render_texture_free(internal_state->texture[1]); - if (internal_state->bitmap[0] != NULL) - bitmap_free(internal_state->bitmap[0]); - if (internal_state->bitmap[1] != NULL) - bitmap_free(internal_state->bitmap[1]); + if (state->texture[0] != NULL) + render_texture_free(state->texture[0]); + if (state->texture[1] != NULL) + render_texture_free(state->texture[1]); + if (state->bitmap[0] != NULL) + bitmap_free(state->bitmap[0]); + if (state->bitmap[1] != NULL) + bitmap_free(state->bitmap[1]); /* compute new width/height */ curwidth = MAX(width, curwidth); @@ -721,42 +756,42 @@ void video_screen_configure(const device_config *screen, int width, int height, /* choose the texture format - convert the screen format to a texture format */ switch (screen_format) { - case BITMAP_FORMAT_INDEXED16: internal_state->texture_format = TEXFORMAT_PALETTE16; break; - case BITMAP_FORMAT_RGB15: internal_state->texture_format = TEXFORMAT_RGB15; break; - case BITMAP_FORMAT_RGB32: internal_state->texture_format = TEXFORMAT_RGB32; break; + case BITMAP_FORMAT_INDEXED16: state->texture_format = TEXFORMAT_PALETTE16; break; + case BITMAP_FORMAT_RGB15: state->texture_format = TEXFORMAT_RGB15; break; + case BITMAP_FORMAT_RGB32: state->texture_format = TEXFORMAT_RGB32; break; default: fatalerror("Invalid bitmap format!"); break; } /* allocate bitmaps */ - internal_state->bitmap[0] = bitmap_alloc(curwidth, curheight, screen_format); - bitmap_set_palette(internal_state->bitmap[0], screen->machine->palette); - internal_state->bitmap[1] = bitmap_alloc(curwidth, curheight, screen_format); - bitmap_set_palette(internal_state->bitmap[1], screen->machine->palette); + state->bitmap[0] = bitmap_alloc(curwidth, curheight, screen_format); + bitmap_set_palette(state->bitmap[0], screen->machine->palette); + state->bitmap[1] = bitmap_alloc(curwidth, curheight, screen_format); + bitmap_set_palette(state->bitmap[1], screen->machine->palette); /* allocate textures */ - internal_state->texture[0] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(internal_state->texture[0], internal_state->bitmap[0], visarea, 0, internal_state->texture_format); - internal_state->texture[1] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(internal_state->texture[1], internal_state->bitmap[1], visarea, 0, internal_state->texture_format); + state->texture[0] = render_texture_alloc(NULL, NULL); + render_texture_set_bitmap(state->texture[0], state->bitmap[0], visarea, 0, state->texture_format); + state->texture[1] = render_texture_alloc(NULL, NULL); + render_texture_set_bitmap(state->texture[1], state->bitmap[1], visarea, 0, state->texture_format); } } /* now fill in the new parameters */ state->width = width; state->height = height; - internal_state->visarea = *visarea; + state->visarea = *visarea; /* compute timing parameters */ - internal_state->frame_period = frame_period; - internal_state->scantime = frame_period / height; - internal_state->pixeltime = frame_period / (height * width); + state->frame_period = frame_period; + state->scantime = frame_period / height; + state->pixeltime = frame_period / (height * width); /* if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now from the visible area, otherwise just used the supplied value */ if ((config->vblank == 0) && !config->oldstyle_vblank_supplied) - internal_state->vblank_period = (frame_period / height) * (height - (visarea->max_y + 1 - visarea->min_y)); + state->vblank_period = state->scantime * (height - (visarea->max_y + 1 - visarea->min_y)); else - internal_state->vblank_period = config->vblank; + state->vblank_period = config->vblank; /* adjust speed if necessary */ if (global.refresh_speed) @@ -777,12 +812,12 @@ void video_screen_configure(const device_config *screen, int width, int height, /* if we are on scanline 0 already, reset the update timer immediately */ /* otherwise, defer until the next scanline 0 */ if (video_screen_get_vpos(screen) == 0) - timer_adjust_oneshot(internal_state->scanline0_timer, attotime_zero, 0); + timer_adjust_oneshot(state->scanline0_timer, attotime_zero, 0); else - timer_adjust_oneshot(internal_state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + timer_adjust_oneshot(state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); /* start the VBLANK timer */ - timer_adjust_oneshot(internal_state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); + timer_adjust_oneshot(state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); } @@ -794,7 +829,6 @@ void video_screen_configure(const device_config *screen, int width, int height, void video_screen_set_visarea(const device_config *screen, int min_x, int max_x, int min_y, int max_y) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; rectangle visarea; /* validate arguments */ @@ -808,7 +842,7 @@ void video_screen_set_visarea(const device_config *screen, int min_x, int max_x, visarea.min_y = min_y; visarea.max_y = max_y; - video_screen_configure(screen, state->width, state->height, &visarea, internal_state->frame_period); + video_screen_configure(screen, state->width, state->height, &visarea, state->frame_period); } @@ -821,8 +855,7 @@ void video_screen_set_visarea(const device_config *screen, int min_x, int max_x, void video_screen_update_partial(const device_config *screen, int scanline) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - rectangle clip = internal_state->visarea; + rectangle clip = state->visarea; /* validate arguments */ assert(scanline >= 0); @@ -848,15 +881,15 @@ void video_screen_update_partial(const device_config *screen, int scanline) } /* skip if less than the lowest so far */ - if (scanline < internal_state->last_partial_scan) + if (scanline < state->last_partial_scan) { LOG_PARTIAL_UPDATES(("skipped because less than previous\n")); return; } /* set the start/end scanlines */ - if (internal_state->last_partial_scan > clip.min_y) - clip.min_y = internal_state->last_partial_scan; + if (state->last_partial_scan > clip.min_y) + clip.min_y = state->last_partial_scan; if (scanline < clip.max_y) clip.max_y = scanline; @@ -869,16 +902,16 @@ void video_screen_update_partial(const device_config *screen, int scanline) LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y)); if (screen->machine->config->video_update != NULL) - flags = (*screen->machine->config->video_update)(screen, internal_state->bitmap[internal_state->curbitmap], &clip); + flags = (*screen->machine->config->video_update)(screen, state->bitmap[state->curbitmap], &clip); global.partial_updates_this_frame++; profiler_mark(PROFILER_END); /* if we modified the bitmap, we have to commit */ - internal_state->changed |= ~flags & UPDATE_HAS_NOT_CHANGED; + state->changed |= ~flags & UPDATE_HAS_NOT_CHANGED; } /* remember where we left off */ - internal_state->last_partial_scan = scanline + 1; + state->last_partial_scan = scanline + 1; } @@ -918,18 +951,17 @@ void video_screen_update_now(const device_config *screen) int video_screen_get_vpos(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time)); + attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), state->vblank_start_time)); int vpos; /* round to the nearest pixel */ - delta += internal_state->pixeltime / 2; + delta += state->pixeltime / 2; /* compute the v position relative to the start of VBLANK */ - vpos = delta / internal_state->scantime; + vpos = delta / state->scantime; /* adjust for the fact that VBLANK starts at the bottom of the visible area */ - return (internal_state->visarea.max_y + 1 + vpos) % state->height; + return (state->visarea.max_y + 1 + vpos) % state->height; } @@ -942,21 +974,20 @@ int video_screen_get_vpos(const device_config *screen) int video_screen_get_hpos(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time)); + attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), state->vblank_start_time)); int vpos; /* round to the nearest pixel */ - delta += internal_state->pixeltime / 2; + delta += state->pixeltime / 2; /* compute the v position relative to the start of VBLANK */ - vpos = delta / internal_state->scantime; + vpos = delta / state->scantime; /* subtract that from the total time */ - delta -= vpos * internal_state->scantime; + delta -= vpos * state->scantime; /* return the pixel offset from the start of this scanline */ - return delta / internal_state->pixeltime; + return delta / state->pixeltime; } @@ -969,12 +1000,11 @@ int video_screen_get_hpos(const device_config *screen) int video_screen_get_vblank(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* we should never be called with no VBLANK period - indication of a buggy driver */ - assert(internal_state->vblank_period != 0); + assert(state->vblank_period != 0); - return (attotime_compare(timer_get_time(), internal_state->vblank_end_time) < 0); + return (attotime_compare(timer_get_time(), state->vblank_end_time) < 0); } @@ -986,9 +1016,8 @@ int video_screen_get_vblank(const device_config *screen) int video_screen_get_hblank(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; int hpos = video_screen_get_hpos(screen); - return (hpos < internal_state->visarea.min_x || hpos > internal_state->visarea.max_x); + return (hpos < state->visarea.min_x || hpos > state->visarea.max_x); } @@ -1021,8 +1050,7 @@ int video_screen_get_height(const device_config *screen) const rectangle *video_screen_get_visible_area(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - return &internal_state->visarea; + return &state->visarea; } @@ -1035,8 +1063,7 @@ const rectangle *video_screen_get_visible_area(const device_config *screen) attotime video_screen_get_time_until_pos(const device_config *screen, int vpos, int hpos) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time)); + attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(), state->vblank_start_time)); attoseconds_t targetdelta; /* validate arguments */ @@ -1044,17 +1071,17 @@ attotime video_screen_get_time_until_pos(const device_config *screen, int vpos, assert(hpos >= 0); /* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */ - vpos += state->height - (internal_state->visarea.max_y + 1); + vpos += state->height - (state->visarea.max_y + 1); vpos %= state->height; /* compute the delta for the given X,Y position */ - targetdelta = (attoseconds_t)vpos * internal_state->scantime + (attoseconds_t)hpos * internal_state->pixeltime; + targetdelta = (attoseconds_t)vpos * state->scantime + (attoseconds_t)hpos * state->pixeltime; /* if we're past that time (within 1/2 of a pixel), head to the next frame */ - if (targetdelta <= curdelta + internal_state->pixeltime / 2) - targetdelta += internal_state->frame_period; + if (targetdelta <= curdelta + state->pixeltime / 2) + targetdelta += state->frame_period; while (targetdelta <= curdelta) - targetdelta += internal_state->frame_period; + targetdelta += state->frame_period; /* return the difference */ return attotime_make(0, targetdelta - curdelta); @@ -1084,16 +1111,15 @@ attotime video_screen_get_time_until_vblank_end(const device_config *screen) { attotime ret; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; attotime current_time = timer_get_time(); /* we are in the VBLANK region, compute the time until the end of the current VBLANK period */ if (video_screen_get_vblank(screen)) - ret = attotime_sub(internal_state->vblank_end_time, current_time); + ret = attotime_sub(state->vblank_end_time, current_time); /* otherwise compute the time until the end of the next frame VBLANK period */ else - ret = attotime_sub(attotime_add_attoseconds(internal_state->vblank_end_time, internal_state->frame_period), current_time); + ret = attotime_sub(attotime_add_attoseconds(state->vblank_end_time, state->frame_period), current_time); return ret; } @@ -1123,8 +1149,7 @@ attotime video_screen_get_time_until_update(const device_config *screen) attotime video_screen_get_scan_period(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - return attotime_make(0, internal_state->scantime); + return attotime_make(0, state->scantime); } @@ -1148,8 +1173,7 @@ attotime video_screen_get_frame_period(const device_config *screen) else { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - ret = attotime_make(0, internal_state->frame_period); + ret = attotime_make(0, state->frame_period); } return ret; @@ -1165,8 +1189,7 @@ attotime video_screen_get_frame_period(const device_config *screen) UINT64 video_screen_get_frame_number(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - return internal_state->frame_number; + return state->frame_number; } @@ -1179,7 +1202,6 @@ void video_screen_register_vbl_cb(const device_config *screen, vblank_state_chan { int i, found; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* validate arguments */ assert(vbl_cb != NULL); @@ -1188,10 +1210,10 @@ void video_screen_register_vbl_cb(const device_config *screen, vblank_state_chan found = FALSE; for (i = 0; i < MAX_VBL_CB; i++) { - if (internal_state->vbl_cbs[i] == NULL) + if (state->vbl_cbs[i] == NULL) break; - if (internal_state->vbl_cbs[i] == vbl_cb) + if (state->vbl_cbs[i] == vbl_cb) found = TRUE; } @@ -1200,7 +1222,7 @@ void video_screen_register_vbl_cb(const device_config *screen, vblank_state_chan /* if not found, register and increment count */ if (!found) - internal_state->vbl_cbs[i] = vbl_cb; + state->vbl_cbs[i] = vbl_cb; } @@ -1215,8 +1237,7 @@ void video_screen_register_vbl_cb(const device_config *screen, vblank_state_chan static DEVICE_START( video_screen ) { - int scrnum = device_list_index(device->machine->config->devicelist, VIDEO_SCREEN, device->tag); - return &device->machine->screen[scrnum]; + return screen_init(device); } @@ -1278,28 +1299,27 @@ static TIMER_CALLBACK( vblank_begin_callback ) int i; device_config *screen = ptr; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* reset the starting VBLANK time */ - internal_state->vblank_start_time = timer_get_time(); - internal_state->vblank_end_time = attotime_add_attoseconds(internal_state->vblank_start_time, internal_state->vblank_period); + state->vblank_start_time = timer_get_time(); + state->vblank_end_time = attotime_add_attoseconds(state->vblank_start_time, state->vblank_period); /* call the screen specific callbacks */ - for (i = 0; internal_state->vbl_cbs[i] != NULL; i++) - internal_state->vbl_cbs[i](screen, TRUE); + for (i = 0; state->vbl_cbs[i] != NULL; i++) + state->vbl_cbs[i](screen, TRUE); /* if this is the primary screen and we need to update now */ if ((screen == machine->primary_screen) && !(machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) video_frame_update(machine, FALSE); /* reset the VBLANK start timer for the next frame */ - timer_adjust_oneshot(internal_state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); + timer_adjust_oneshot(state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); /* if no VBLANK period, call the VBLANK end callback immedietely, otherwise reset the timer */ - if (internal_state->vblank_period == 0) + if (state->vblank_period == 0) vblank_end_callback(machine, screen, 0); else - timer_adjust_oneshot(internal_state->vblank_end_timer, video_screen_get_time_until_vblank_end(screen), 0); + timer_adjust_oneshot(state->vblank_end_timer, video_screen_get_time_until_vblank_end(screen), 0); } @@ -1313,18 +1333,17 @@ static TIMER_CALLBACK( vblank_end_callback ) int i; const device_config *screen = ptr; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* call the screen specific callbacks */ - for (i = 0; internal_state->vbl_cbs[i] != NULL; i++) - internal_state->vbl_cbs[i](screen, FALSE); + for (i = 0; state->vbl_cbs[i] != NULL; i++) + state->vbl_cbs[i](screen, FALSE); /* if this is the primary screen and we need to update now */ if ((screen == machine->primary_screen) && (machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) video_frame_update(machine, FALSE); /* increment the frame number counter */ - internal_state->frame_number++; + state->frame_number++; } @@ -1337,13 +1356,12 @@ static TIMER_CALLBACK( scanline0_callback ) { const device_config *screen = ptr; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* reset partial updates */ - internal_state->last_partial_scan = 0; + state->last_partial_scan = 0; global.partial_updates_this_frame = 0; - timer_adjust_oneshot(internal_state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + timer_adjust_oneshot(state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); } @@ -1356,7 +1374,6 @@ static TIMER_CALLBACK( scanline_update_callback ) { const device_config *screen = ptr; screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; int scanline = param; /* force a partial update to the current scanline */ @@ -1364,9 +1381,9 @@ static TIMER_CALLBACK( scanline_update_callback ) /* compute the next visible scanline */ scanline++; - if (scanline > internal_state->visarea.max_y) - scanline = internal_state->visarea.min_y; - timer_adjust_oneshot(internal_state->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline); + if (scanline > state->visarea.max_y) + scanline = state->visarea.min_y; + timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline); } @@ -1463,7 +1480,6 @@ static int finish_screen_updates(running_machine *machine) for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* only update if live */ if (render_is_live_screen(screen)) @@ -1474,20 +1490,20 @@ static int finish_screen_updates(running_machine *machine) if (config->type != SCREEN_TYPE_VECTOR && (machine->config->video_attributes & VIDEO_SELF_RENDER) == 0) { /* if we're not skipping the frame and if the screen actually changed, then update the texture */ - if (!global.skipping_this_frame && internal_state->changed) + if (!global.skipping_this_frame && state->changed) { - bitmap_t *bitmap = internal_state->bitmap[internal_state->curbitmap]; + bitmap_t *bitmap = state->bitmap[state->curbitmap]; rectangle fixedvis = *video_screen_get_visible_area(screen); fixedvis.max_x++; fixedvis.max_y++; - render_texture_set_bitmap(internal_state->texture[internal_state->curbitmap], bitmap, &fixedvis, 0, internal_state->texture_format); - internal_state->curtexture = internal_state->curbitmap; - internal_state->curbitmap = 1 - internal_state->curbitmap; + render_texture_set_bitmap(state->texture[state->curbitmap], bitmap, &fixedvis, 0, state->texture_format); + state->curtexture = state->curbitmap; + state->curbitmap = 1 - state->curbitmap; } /* create an empty container with a single quad */ render_container_empty(render_container_get_screen(screen)); - render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), internal_state->texture[internal_state->curtexture], PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); + render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), state->texture[state->curtexture], PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); } /* update our movie recording state */ @@ -1496,9 +1512,9 @@ static int finish_screen_updates(running_machine *machine) } /* reset the screen changed flags */ - if (internal_state->changed) + if (state->changed) anything_changed = TRUE; - internal_state->changed = FALSE; + state->changed = FALSE; } /* draw any crosshairs */ @@ -2169,8 +2185,7 @@ static file_error mame_fopen_next(running_machine *machine, const char *pathopti int video_is_movie_active(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; - return (internal_state->movie_file != NULL); + return (state->movie_file != NULL); } @@ -2182,19 +2197,18 @@ int video_is_movie_active(const device_config *screen) void video_movie_begin_recording(const device_config *screen, const char *name) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; file_error filerr; /* close any existing movie file */ - if (internal_state->movie_file != NULL) + if (state->movie_file != NULL) video_movie_end_recording(screen); /* create a new movie file and start recording */ if (name != NULL) - filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &internal_state->movie_file); + filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &state->movie_file); else - filerr = mame_fopen_next(screen->machine, SEARCHPATH_MOVIE, "mng", &internal_state->movie_file); - internal_state->movie_frame = 0; + filerr = mame_fopen_next(screen->machine, SEARCHPATH_MOVIE, "mng", &state->movie_file); + state->movie_frame = 0; } @@ -2206,15 +2220,14 @@ void video_movie_begin_recording(const device_config *screen, const char *name) void video_movie_end_recording(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; /* close the file if it exists */ - if (internal_state->movie_file != NULL) + if (state->movie_file != NULL) { - mng_capture_stop(mame_core_file(internal_state->movie_file)); - mame_fclose(internal_state->movie_file); - internal_state->movie_file = NULL; - internal_state->movie_frame = 0; + mng_capture_stop(mame_core_file(state->movie_file)); + mame_fclose(state->movie_file); + state->movie_file = NULL; + state->movie_frame = 0; } } @@ -2227,11 +2240,10 @@ void video_movie_end_recording(const device_config *screen) static void movie_record_frame(const device_config *screen) { screen_state *state = get_safe_token(screen); - internal_screen_state *internal_state = (internal_screen_state *)state->private_data; const rgb_t *palette; /* only record if we have a file */ - if (internal_state->movie_file != NULL) + if (state->movie_file != NULL) { png_info pnginfo = { 0 }; png_error error; @@ -2242,7 +2254,7 @@ static void movie_record_frame(const device_config *screen) create_snapshot_bitmap(screen); /* track frames */ - if (internal_state->movie_frame++ == 0) + if (state->movie_frame++ == 0) { char text[256]; @@ -2253,7 +2265,7 @@ static void movie_record_frame(const device_config *screen) png_add_text(&pnginfo, "System", text); /* start the capture */ - error = mng_capture_start(mame_core_file(internal_state->movie_file), global.snap_bitmap, ATTOSECONDS_TO_HZ(internal_state->frame_period)); + error = mng_capture_start(mame_core_file(state->movie_file), global.snap_bitmap, ATTOSECONDS_TO_HZ(state->frame_period)); if (error != PNGERR_NONE) { png_free(&pnginfo); @@ -2264,7 +2276,7 @@ static void movie_record_frame(const device_config *screen) /* write the next frame */ palette = (screen->machine->palette != NULL) ? palette_entry_list_adjusted(screen->machine->palette) : NULL; - error = mng_capture_frame(mame_core_file(internal_state->movie_file), &pnginfo, global.snap_bitmap, screen->machine->config->total_colors, palette); + error = mng_capture_frame(mame_core_file(state->movie_file), &pnginfo, global.snap_bitmap, screen->machine->config->total_colors, palette); png_free(&pnginfo); if (error != PNGERR_NONE) { diff --git a/src/emu/video.h b/src/emu/video.h index e0473d50f82..58e314f2e31 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -23,9 +23,6 @@ CONSTANTS ***************************************************************************/ -/* maximum number of screens for one game */ -#define MAX_SCREENS 8 - /* number of levels of frameskipping supported */ #define FRAMESKIP_LEVELS 12 #define MAX_FRAMESKIP (FRAMESKIP_LEVELS - 2) @@ -64,18 +61,6 @@ enum ***************************************************************************/ /*------------------------------------------------- - screen_state - current live state of a screen --------------------------------------------------*/ - -typedef struct _screen_state screen_state; -struct _screen_state -{ - int width, height; /* current total width/height (HTOTAL, VTOTAL) */ - void * private_data; /* pointer to the private data structure */ -}; - - -/*------------------------------------------------- screen_config - configuration of a single screen -------------------------------------------------*/ diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index ec076ee351a..f1aaa39716a 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -395,7 +395,7 @@ static TIMER_CALLBACK( scanline_callback ) amiga_audio_update(); /* set timer for next line */ - scanline = (scanline + 1) % machine->screen[0].height; + scanline = (scanline + 1) % video_screen_get_height(machine->primary_screen); timer_set(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, scanline_callback); } diff --git a/src/mame/machine/konamigx.c b/src/mame/machine/konamigx.c index 48587c93daa..f8657ee3525 100644 --- a/src/mame/machine/konamigx.c +++ b/src/mame/machine/konamigx.c @@ -1550,7 +1550,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle } // traverse draw list - screenwidth = Machine->screen[0].width; + screenwidth = video_screen_get_width(machine->primary_screen); for (count=0; count<nobj; count++) { diff --git a/src/mame/video/amspdwy.c b/src/mame/video/amspdwy.c index addb1f858b7..e0fe1223460 100644 --- a/src/mame/video/amspdwy.c +++ b/src/mame/video/amspdwy.c @@ -105,8 +105,8 @@ Offset: Format: Value: static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) { int i; - int max_x = machine->screen[0].width - 1; - int max_y = machine->screen[0].height - 1; + int max_x = video_screen_get_width(machine->primary_screen) - 1; + int max_y = video_screen_get_height(machine->primary_screen) - 1; for (i = 0; i < spriteram_size ; i += 4) { diff --git a/src/mame/video/argus.c b/src/mame/video/argus.c index c3e8d87c240..ea957f0a873 100644 --- a/src/mame/video/argus.c +++ b/src/mame/video/argus.c @@ -1555,23 +1555,27 @@ VIDEO_UPDATE( valtric ) int step=valtric_mosaic; UINT32 *dest; int x,y,xx,yy; + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + if(valtric_mosaic<0)step*=-1; - for(y=0;y<screen->machine->screen[0].width+step;y+=step) - for(x=0;x<screen->machine->screen[0].height+step;x+=step) + + for(y=0;y<width+step;y+=step) + for(x=0;x<height+step;x+=step) { static int c=0; - if(y<screen->machine->screen[0].height && x< screen->machine->screen[0].width) + if(y<height && x< width) c=*BITMAP_ADDR32(mosaicbitmap, y, x); if(valtric_mosaic<0) - if(y+step-1<screen->machine->screen[0].height && x+step-1< screen->machine->screen[0].width) + if(y+step-1<height && x+step-1< width) c = *BITMAP_ADDR32(mosaicbitmap, y+step-1, x+step-1); for(yy=0;yy<step;yy++) for(xx=0;xx<step;xx++) { - if(xx+x < screen->machine->screen[0].width && yy+y<screen->machine->screen[0].height) + if(xx+x < width && yy+y<height) { dest=BITMAP_ADDR32(bitmap, y+yy, x+xx); *dest=c; diff --git a/src/mame/video/astrocde.c b/src/mame/video/astrocde.c index bf79a322555..bad3cd93ef5 100644 --- a/src/mame/video/astrocde.c +++ b/src/mame/video/astrocde.c @@ -308,8 +308,11 @@ VIDEO_UPDATE( astrocde ) int y; /* compute the starting point of sparkle for the current frame */ + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + if (astrocade_video_config & AC_STARS) - sparklebase = (video_screen_get_frame_number(screen) * (UINT64)(screen->machine->screen[0].width * screen->machine->screen[0].height)) % RNG_PERIOD; + sparklebase = (video_screen_get_frame_number(screen) * (UINT64)(width * height)) % RNG_PERIOD; /* iterate over scanlines */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) @@ -323,8 +326,8 @@ VIDEO_UPDATE( astrocde ) /* compute the star and sparkle offset at the start of this line */ if (astrocade_video_config & AC_STARS) { - staroffs = ((effy < 0) ? (effy + 262) : effy) * screen->machine->screen[0].width; - sparkleoffs = sparklebase + y * screen->machine->screen[0].width; + staroffs = ((effy < 0) ? (effy + 262) : effy) * width; + sparkleoffs = sparklebase + y * width; if (sparkleoffs >= RNG_PERIOD) sparkleoffs -= RNG_PERIOD; } @@ -488,7 +491,7 @@ static TIMER_CALLBACK( scanline_callback ) /* advance to the next scanline */ scanline++; - if (scanline >= machine->screen[0].height) + if (scanline >= video_screen_get_height(machine->primary_screen)) scanline = 0; timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); } diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c index 79a07ffe402..607cbdb00b6 100644 --- a/src/mame/video/atari.c +++ b/src/mame/video/atari.c @@ -761,7 +761,7 @@ VIDEO_START( atari ) LOG(("atari prio_init\n")); prio_init(); - for( i = 0; i < machine->screen[0].height; i++ ) + for( i = 0; i < video_screen_get_height(machine->primary_screen); i++ ) { antic.video[i] = auto_malloc(sizeof(VIDEO)); memset(antic.video[i], 0, sizeof(VIDEO)); @@ -955,7 +955,7 @@ static void antic_linerefresh(void) UINT32 scanline[4 + (HCHARS * 2) + 4]; /* increment the scanline */ - if( ++antic.scanline == Machine->screen[0].height ) + if( ++antic.scanline == video_screen_get_height(Machine->primary_screen) ) { /* and return to the top if the frame was complete */ antic.scanline = 0; @@ -1057,7 +1057,7 @@ static void antic_linerefresh(void) static int cycle(void) { - return video_screen_get_hpos(Machine->primary_screen) * CYCLES_PER_LINE / Machine->screen[0].width; + return video_screen_get_hpos(Machine->primary_screen) * CYCLES_PER_LINE / video_screen_get_width(Machine->primary_screen); } static void after(int cycles, timer_fired_func function, const char *funcname) @@ -1359,7 +1359,7 @@ static void antic_scanline_dma(int param) /* produce empty scanlines until vblank start */ antic.modelines = VBL_START + 1 - antic.scanline; if( antic.modelines < 0 ) - antic.modelines = Machine->screen[0].height - antic.scanline; + antic.modelines = video_screen_get_height(Machine->primary_screen) - antic.scanline; LOG((" JVB $%04x\n", antic.dpage|antic.doffs)); } else @@ -1523,7 +1523,7 @@ static void generic_atari_interrupt(void (*handle_keyboard)(void), int button_co handle_keyboard(); /* do nothing new for the rest of the frame */ - antic.modelines = Machine->screen[0].height - VBL_START; + antic.modelines = video_screen_get_height(Machine->primary_screen) - VBL_START; antic_renderer = antic_mode_0_xx; /* if the CPU want's to be interrupted at vertical blank... */ diff --git a/src/mame/video/atarigt.c b/src/mame/video/atarigt.c index 7edb73d192e..778cca1d508 100644 --- a/src/mame/video/atarigt.c +++ b/src/mame/video/atarigt.c @@ -134,7 +134,7 @@ VIDEO_START( atarigt ) {{ 0,0x8000,0,0,0,0,0,0 }} /* mask for the VRAM target */ }; atarirle_desc adjusted_modesc = modesc; - int i; + int i, width, height; /* blend the playfields and free the temporary one */ atarigen_blend_gfx(machine, 0, 2, 0x0f, 0x30); @@ -149,8 +149,11 @@ VIDEO_START( atarigt ) atarigen_alpha_tilemap = tilemap_create(get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); /* allocate temp bitmaps */ - pf_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - an_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + + pf_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + an_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); /* allocate memory */ expanded_mram = auto_malloc(sizeof(*expanded_mram) * MRAM_ENTRIES * 3); diff --git a/src/mame/video/atarimo.c b/src/mame/video/atarimo.c index 87790a6af5d..acf5d9e8584 100644 --- a/src/mame/video/atarimo.c +++ b/src/mame/video/atarimo.c @@ -429,8 +429,8 @@ void atarimo_init(running_machine *machine, int map, const struct atarimo_desc * mo->colorlookup[i] = i; /* allocate dirty grid */ - mo->dirtywidth = (machine->screen[0].width >> mo->tilexshift) + 2; - mo->dirtyheight = (machine->screen[0].height >> mo->tileyshift) + 2; + mo->dirtywidth = (video_screen_get_width(machine->primary_screen) >> mo->tilexshift) + 2; + mo->dirtyheight = (video_screen_get_height(machine->primary_screen) >> mo->tileyshift) + 2; mo->dirtygrid = auto_malloc(mo->dirtywidth * mo->dirtyheight); /* allocate the gfx lookup */ diff --git a/src/mame/video/atarirle.c b/src/mame/video/atarirle.c index 139d0cbe813..abfceea4dbf 100644 --- a/src/mame/video/atarirle.c +++ b/src/mame/video/atarirle.c @@ -273,7 +273,7 @@ void atarirle_init(int map, const atarirle_desc *desc) { const UINT16 *base = (const UINT16 *)memory_region(desc->region); atarirle_data *mo = &atarirle[map]; - int i; + int i, width, height; /* verify the map index */ assert_always(map >= 0 && map < ATARIRLE_MAX, "Invalid map index"); @@ -341,16 +341,19 @@ void atarirle_init(int map, const atarirle_desc *desc) memset(mo->spriteram, 0, sizeof(mo->spriteram[0]) * mo->spriteramsize); /* allocate bitmaps */ - mo->vram[0][0] = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - mo->vram[0][1] = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + width = video_screen_get_width(Machine->primary_screen); + height = video_screen_get_height(Machine->primary_screen); + + mo->vram[0][0] = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + mo->vram[0][1] = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); fillbitmap(mo->vram[0][0], 0, NULL); fillbitmap(mo->vram[0][1], 0, NULL); /* allocate alternate bitmaps if needed */ if (mo->vrammask.mask != 0) { - mo->vram[1][0] = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - mo->vram[1][1] = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + mo->vram[1][0] = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + mo->vram[1][1] = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); fillbitmap(mo->vram[1][0], 0, NULL); fillbitmap(mo->vram[1][1], 0, NULL); } diff --git a/src/mame/video/cave.c b/src/mame/video/cave.c index 469d7cef92d..8088f280681 100644 --- a/src/mame/video/cave.c +++ b/src/mame/video/cave.c @@ -566,8 +566,8 @@ static void get_sprite_info_cave(running_machine *machine) int glob_flipx = cave_videoregs[ 0 ] & 0x8000; int glob_flipy = cave_videoregs[ 1 ] & 0x8000; - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); for (; source < finish; source+=8 ) { @@ -687,8 +687,8 @@ static void get_sprite_info_donpachi(running_machine *machine) int glob_flipx = cave_videoregs[ 0 ] & 0x8000; int glob_flipy = cave_videoregs[ 1 ] & 0x8000; - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); for (; source < finish; source+=8 ) { @@ -753,8 +753,8 @@ static void get_sprite_info_donpachi(running_machine *machine) static void sprite_init_cave(running_machine *machine) { - screen_width = machine->screen[0].width; - screen_height = machine->screen[0].height; + screen_width = video_screen_get_width(machine->primary_screen); + screen_height = video_screen_get_height(machine->primary_screen); if (cave_spritetype == 0 || cave_spritetype == 2) // most of the games { @@ -767,7 +767,7 @@ static void sprite_init_cave(running_machine *machine) cave_spritetype2 = 0; } - sprite_zbuf = auto_bitmap_alloc( machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); + sprite_zbuf = auto_bitmap_alloc(screen_width, screen_height, BITMAP_FORMAT_INDEXED16 ); blit.baseaddr_zbuf = sprite_zbuf->base; blit.line_offset_zbuf = sprite_zbuf->rowpixels * sprite_zbuf->bpp / 8; diff --git a/src/mame/video/cvs.c b/src/mame/video/cvs.c index 3011789fae6..292611abbc2 100644 --- a/src/mame/video/cvs.c +++ b/src/mame/video/cvs.c @@ -145,8 +145,7 @@ WRITE8_HANDLER( cvs_scroll_w ) VIDEO_START( cvs ) { int generator = 0; - int y; - + int y, width, height; /* precalculate the star background */ @@ -184,9 +183,12 @@ VIDEO_START( cvs ) } /* configure the S2636 chips */ - s2636_0 = s2636_config(cvs_s2636_0_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); - s2636_1 = s2636_config(cvs_s2636_1_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); - s2636_2 = s2636_config(cvs_s2636_2_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + + s2636_0 = s2636_config(cvs_s2636_0_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + s2636_1 = s2636_config(cvs_s2636_1_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + s2636_2 = s2636_config(cvs_s2636_2_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); /* create helper bitmaps */ background_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); diff --git a/src/mame/video/deco16ic.c b/src/mame/video/deco16ic.c index 821921c4aa2..77b0a816c5e 100644 --- a/src/mame/video/deco16ic.c +++ b/src/mame/video/deco16ic.c @@ -518,7 +518,9 @@ WRITE16_HANDLER( deco16_pf4_data_w ) static void deco16_video_init(int pf12_only, int split, int full_width) { - sprite_priority_bitmap = auto_bitmap_alloc( Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED8 ); + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + sprite_priority_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED8 ); pf1_tilemap_16x16 = tilemap_create(get_pf1_tile_info, deco16_scan_rows, 16,16,64,32); pf1_tilemap_8x8 = tilemap_create(get_pf1_tile_info_b, tilemap_scan_rows,8,8,64,32); @@ -598,7 +600,9 @@ void deco16_2_video_init_half_width(void) /* 2 times playfield generator chips * void deco_allocate_sprite_bitmap(void) { /* Allow sprite bitmap to be used by Deco32 games as well */ - sprite_priority_bitmap = auto_bitmap_alloc( Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + sprite_priority_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16 ); } /*****************************************************************************************/ diff --git a/src/mame/video/deco32.c b/src/mame/video/deco32.c index 2f272298b45..3c8d30b791d 100644 --- a/src/mame/video/deco32.c +++ b/src/mame/video/deco32.c @@ -1035,6 +1035,8 @@ VIDEO_START( lockload ) VIDEO_START( nslasher ) { + int width, height; + pf1_tilemap = tilemap_create(get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); pf2_tilemap = tilemap_create(get_pf2_tile_info, deco16_scan_rows,16,16,64,32); pf3_tilemap = tilemap_create(get_pf3_tile_info, deco16_scan_rows,16,16,64,32); @@ -1042,9 +1044,11 @@ VIDEO_START( nslasher ) pf1a_tilemap =0; dirty_palette = auto_malloc(4096); - sprite0_mix_bitmap=auto_bitmap_alloc( machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); - sprite1_mix_bitmap=auto_bitmap_alloc( machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); - tilemap_alpha_bitmap=auto_bitmap_alloc( machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + sprite0_mix_bitmap=auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16 ); + sprite1_mix_bitmap=auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16 ); + tilemap_alpha_bitmap=auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16 ); tilemap_set_transparent_pen(pf1_tilemap,0); tilemap_set_transparent_pen(pf2_tilemap,0); diff --git a/src/mame/video/dkong.c b/src/mame/video/dkong.c index 7091e73b4a5..af694e5aeed 100644 --- a/src/mame/video/dkong.c +++ b/src/mame/video/dkong.c @@ -807,7 +807,7 @@ static TIMER_CALLBACK( scanline_callback ) counter = 0; offset = (state->flip ^ state->rflip_sig) ? 0x000 : 0x400; x = 0; - while (x < machine->screen[0].width) + while (x < video_screen_get_width(machine->primary_screen)) { pixel = BITMAP_ADDR16(state->bg_bits, y, x); if ((counter < table_len) && (x == 4 * (table[counter|offset] & 0x7f))) diff --git a/src/mame/video/esd16.c b/src/mame/video/esd16.c index 9c42a7b41e7..55ea3d0dd12 100644 --- a/src/mame/video/esd16.c +++ b/src/mame/video/esd16.c @@ -183,8 +183,8 @@ static void esd16_draw_sprites(running_machine *machine, bitmap_t *bitmap, const { int offs; - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); for ( offs = spriteram_size/2 - 8/2; offs >= 0 ; offs -= 8/2 ) { @@ -239,8 +239,8 @@ static void hedpanic_draw_sprites(running_machine *machine, bitmap_t *bitmap, co { int offs; - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); for ( offs = spriteram_size/2 - 8/2; offs >= 0 ; offs -= 8/2 ) { diff --git a/src/mame/video/gaelco3d.c b/src/mame/video/gaelco3d.c index 0642cb73bbf..226a3c8897d 100644 --- a/src/mame/video/gaelco3d.c +++ b/src/mame/video/gaelco3d.c @@ -75,12 +75,16 @@ static void gaelco3d_exit(running_machine *machine) VIDEO_START( gaelco3d ) { + int width, height; + poly = poly_alloc(2000, sizeof(poly_extra_data), 0); add_exit_callback(machine, gaelco3d_exit); screenbits = video_screen_auto_bitmap_alloc(machine->primary_screen); - zbuffer = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + zbuffer = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); palette = auto_malloc(32768 * sizeof(palette[0])); polydata_buffer = auto_malloc(MAX_POLYDATA * sizeof(polydata_buffer[0])); diff --git a/src/mame/video/gaiden.c b/src/mame/video/gaiden.c index f7389a1955e..744efc858bd 100644 --- a/src/mame/video/gaiden.c +++ b/src/mame/video/gaiden.c @@ -88,9 +88,12 @@ VIDEO_START( gaiden ) VIDEO_START( raiga ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + /* set up tile layers */ - tile_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - tile_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_bg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_fg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); background = tilemap_create(get_bg_tile_info, tilemap_scan_rows,16,16,64,32); foreground = tilemap_create(get_fg_tile_info_raiga,tilemap_scan_rows,16,16,64,32); @@ -101,7 +104,7 @@ VIDEO_START( raiga ) tilemap_set_transparent_pen(text_layer,0); /* set up sprites */ - sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + sprite_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); } VIDEO_START( drgnbowl ) diff --git a/src/mame/video/gaplus.c b/src/mame/video/gaplus.c index 0afda820a58..a582d9eb395 100644 --- a/src/mame/video/gaplus.c +++ b/src/mame/video/gaplus.c @@ -145,10 +145,9 @@ static void starfield_init(running_machine *machine) int generator = 0; int x,y; int set = 0; - int width, height; - width = machine->screen[0].width; - height = machine->screen[0].height; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); total_stars = 0; @@ -242,10 +241,9 @@ WRITE8_HANDLER( gaplus_starfield_control_w ) static void starfield_render(running_machine *machine, bitmap_t *bitmap) { int i; - int width, height; - width = machine->screen[0].width; - height = machine->screen[0].height; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); /* check if we're running */ if ( ( gaplus_starfield_control[0] & 1 ) == 0 ) @@ -341,10 +339,9 @@ VIDEO_UPDATE( gaplus ) VIDEO_EOF( gaplus ) /* update starfields */ { int i; - int width, height; - width = machine->screen[0].width; - height = machine->screen[0].height; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); /* check if we're running */ if ( ( gaplus_starfield_control[0] & 1 ) == 0 ) diff --git a/src/mame/video/gticlub.c b/src/mame/video/gticlub.c index 9a0fcc6baac..30ba12b6e70 100644 --- a/src/mame/video/gticlub.c +++ b/src/mame/video/gticlub.c @@ -181,11 +181,14 @@ void K001005_swap_buffers(void); void K001005_init(void) { int i; + + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + K001005_zbuffer = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED32); + K001005_bitmap[0] = video_screen_auto_bitmap_alloc(Machine->primary_screen); K001005_bitmap[1] = video_screen_auto_bitmap_alloc(Machine->primary_screen); - K001005_zbuffer = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED32); - K001005_texture = auto_malloc(0x800000); K001005_ram[0] = auto_malloc(0x140000 * sizeof(UINT16)); diff --git a/src/mame/video/hyprduel.c b/src/mame/video/hyprduel.c index 70dee3cad5c..0922bc49c6b 100644 --- a/src/mame/video/hyprduel.c +++ b/src/mame/video/hyprduel.c @@ -399,8 +399,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta UINT8 *base_gfx = memory_region(region); UINT8 *gfx_max = base_gfx + memory_region_length(region); - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); int max_sprites = spriteram_size / 8; int sprites = hyprduel_videoregs[0x00/2] % max_sprites; @@ -632,8 +632,8 @@ VIDEO_UPDATE( hyprduel ) } } - hyprduel_sprite_xoffs = hyprduel_videoregs[0x06/2] - screen->machine->screen[0].width / 2; - hyprduel_sprite_yoffs = hyprduel_videoregs[0x04/2] - screen->machine->screen[0].height / 2; + hyprduel_sprite_xoffs = hyprduel_videoregs[0x06/2] - video_screen_get_width(screen) / 2; + hyprduel_sprite_yoffs = hyprduel_videoregs[0x04/2] - video_screen_get_height(screen) / 2; /* The background color is selected by a register */ fillbitmap(priority_bitmap,0,cliprect); diff --git a/src/mame/video/irobot.c b/src/mame/video/irobot.c index b5093faa330..89e4b66a0fe 100644 --- a/src/mame/video/irobot.c +++ b/src/mame/video/irobot.c @@ -82,7 +82,7 @@ WRITE8_HANDLER( irobot_paletteram_w ) static void _irobot_poly_clear(running_machine *machine, UINT8 *bitmap_base) { - memset(bitmap_base, 0, BITMAP_WIDTH * machine->screen[0].height); + memset(bitmap_base, 0, BITMAP_WIDTH * video_screen_get_height(machine->primary_screen)); } void irobot_poly_clear(void) @@ -100,8 +100,9 @@ void irobot_poly_clear(void) VIDEO_START( irobot ) { /* Setup 2 bitmaps for the polygon generator */ - polybitmap1 = auto_malloc(BITMAP_WIDTH * machine->screen[0].height); - polybitmap2 = auto_malloc(BITMAP_WIDTH * machine->screen[0].height); + int height = video_screen_get_height(machine->primary_screen); + polybitmap1 = auto_malloc(BITMAP_WIDTH * height); + polybitmap2 = auto_malloc(BITMAP_WIDTH * height); /* clear the bitmaps so we start with valid palette look-up values for drawing */ _irobot_poly_clear(machine, polybitmap1); @@ -109,8 +110,8 @@ VIDEO_START( irobot ) /* Set clipping */ ir_xmin = ir_ymin = 0; - ir_xmax = machine->screen[0].width; - ir_ymax = machine->screen[0].height; + ir_xmax = video_screen_get_width(machine->primary_screen); + ir_ymax = video_screen_get_height(machine->primary_screen); } diff --git a/src/mame/video/jaguar.c b/src/mame/video/jaguar.c index 306cb9ef3de..430488ebc49 100644 --- a/src/mame/video/jaguar.c +++ b/src/mame/video/jaguar.c @@ -290,7 +290,7 @@ INLINE int adjust_object_timer(running_machine *machine, int vc) hdb = hdbpix[vc % 2]; /* if setting the second one in a line, make sure we will ever actually hit it */ - if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= machine->screen[0].width)) + if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= video_screen_get_width(machine->primary_screen))) return FALSE; /* adjust the timer */ @@ -633,7 +633,7 @@ READ16_HANDLER( jaguar_tom_regs_r ) return cpu_irq_state; case HC: - return video_screen_get_hpos(machine->primary_screen) % (machine->screen[0].width / 2); + return video_screen_get_hpos(machine->primary_screen) % (video_screen_get_width(machine->primary_screen) / 2); case VC: return video_screen_get_vpos(machine->primary_screen) * 2 + gpu_regs[VBE]; @@ -796,7 +796,7 @@ static TIMER_CALLBACK( cojag_scanline_update ) } /* point to the next counter value */ - if (++vc / 2 >= machine->screen[0].height) + if (++vc / 2 >= video_screen_get_height(machine->primary_screen)) vc = 0; } while (!adjust_object_timer(machine, vc)); diff --git a/src/mame/video/kaneko16.c b/src/mame/video/kaneko16.c index d903ee9d204..ad3d551e7dc 100644 --- a/src/mame/video/kaneko16.c +++ b/src/mame/video/kaneko16.c @@ -144,8 +144,10 @@ VIDEO_START( kaneko16_1xVIEW2 ) sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); { - int dx, xdim = machine->screen[0].width; - int dy, ydim = machine->screen[0].height; + int dx, dy; + + int xdim = video_screen_get_width(machine->primary_screen); + int ydim = video_screen_get_height(machine->primary_screen); switch (xdim) { @@ -184,8 +186,10 @@ VIDEO_START( kaneko16_2xVIEW2 ) 16,16, 0x20,0x20 ); { - int dx, xdim = machine->screen[0].width; - int dy, ydim = machine->screen[0].height; + int dx, dy; + + int xdim = video_screen_get_width(machine->primary_screen); + int ydim = video_screen_get_height(machine->primary_screen); switch (xdim) { @@ -502,7 +506,7 @@ void kaneko16_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rec in a temp buffer, then draw the buffer's contents from last to first. */ - int max = (machine->screen[0].width > 0x100) ? (0x200<<6) : (0x100<<6); + int max = (video_screen_get_width(machine->primary_screen) > 0x100) ? (0x200<<6) : (0x100<<6); int i = 0; struct tempsprite *s = spritelist.first_sprite; diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c index 5e7f2784115..b4462d3f3fd 100644 --- a/src/mame/video/konamiic.c +++ b/src/mame/video/konamiic.c @@ -4221,7 +4221,7 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta int offy = (short)((K053246_regs[2] << 8) | K053246_regs[3]); int solidpens = K053247_gfx->color_granularity - 1; - int screen_width = machine->screen[0].width; + int screen_width = video_screen_get_width(machine->primary_screen); /* safeguard older drivers missing any of the following video attributes: diff --git a/src/mame/video/liberatr.c b/src/mame/video/liberatr.c index 3e396d513e2..f9952bd0f27 100644 --- a/src/mame/video/liberatr.c +++ b/src/mame/video/liberatr.c @@ -124,8 +124,8 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan { UINT16 longitude; - const UINT8* latitude_scale = memory_region(REGION_USER1); - const UINT8* longitude_scale = memory_region(REGION_USER2); + const UINT8 *latitude_scale = memory_region(REGION_USER1); + const UINT8 *longitude_scale = memory_region(REGION_USER2); /* for each starting longitude */ for (longitude = 0; longitude < 0x100; longitude++) @@ -243,7 +243,7 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan /* calculate the bitmap's x coordinate for the western horizon center of bitmap - (the number of planet pixels) / 4 */ - *buffer++ = machine->screen[0].width/2 - (line->max_x + 2) / 4; + *buffer++ = (video_screen_get_width(machine->primary_screen) / 2) - ((line->max_x + 2) / 4); for (i = 0; i < segment_count; i++) { @@ -267,7 +267,7 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan VIDEO_START( liberatr ) { - liberatr_videoram = auto_malloc(machine->screen[0].width * machine->screen[0].height); + liberatr_videoram = auto_malloc(0x10000); /* allocate the planet descriptor structure */ liberatr_planets[0] = auto_malloc(sizeof(planet)); @@ -332,24 +332,20 @@ static void liberatr_draw_planet(bitmap_t *bitmap, pen_t *pens) UINT8 segment_length = *buffer++; if ((color & 0x0c) == 0x0c) - { color = base_color; - } for (i = 0; i < segment_length; i++, x++) - { *BITMAP_ADDR32(bitmap, y, x) = pens[color]; - } } } } -static void liberatr_draw_bitmap(running_machine *machine, bitmap_t *bitmap, pen_t *pens) +static void liberatr_draw_bitmap(bitmap_t *bitmap, pen_t *pens) { offs_t offs; - for (offs = 0; offs < machine->screen[0].width * machine->screen[0].height; offs++) + for (offs = 0; offs < 0x10000; offs++) { UINT8 data = liberatr_videoram[offs]; @@ -368,10 +364,8 @@ VIDEO_UPDATE( liberatr ) get_pens(pens); fillbitmap(bitmap, RGB_BLACK, cliprect); - liberatr_draw_planet(bitmap, pens); - - liberatr_draw_bitmap(screen->machine, bitmap, pens); + liberatr_draw_bitmap(bitmap, pens); return 0; } diff --git a/src/mame/video/madalien.c b/src/mame/video/madalien.c index 4b8c3998dc4..9dfe00a2305 100644 --- a/src/mame/video/madalien.c +++ b/src/mame/video/madalien.c @@ -155,7 +155,7 @@ static VIDEO_START( madalien ) tilemap_edge2[i] = tilemap_create(get_tile_info_BG_2, scan_functions[i], 16, 16, tilemap_cols[i], 8); tilemap_set_scrolldx(tilemap_edge2[i], 0, 0x50); - tilemap_set_scrolldy(tilemap_edge2[i], 0, machine->screen[0].height - 256); + tilemap_set_scrolldy(tilemap_edge2[i], 0, video_screen_get_height(machine->primary_screen) - 256); } headlight_bitmap = auto_bitmap_alloc(128, 128, BITMAP_FORMAT_INDEXED16); diff --git a/src/mame/video/malzak.c b/src/mame/video/malzak.c index 33c7623caaa..025de29b94f 100644 --- a/src/mame/video/malzak.c +++ b/src/mame/video/malzak.c @@ -56,13 +56,16 @@ static struct playfield VIDEO_START( malzak ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + saa5050_vidram = auto_malloc(0x800); /* configure the S2636 chips */ -// s2636_0 = s2636_config(malzak_s2636_0_ram, machine->screen[0].height, machine->screen[0].width, -8, -16); -// s2636_1 = s2636_config(malzak_s2636_1_ram, machine->screen[0].height, machine->screen[0].width, -9, -16); - s2636_0 = s2636_config(malzak_s2636_0_ram, machine->screen[0].height, machine->screen[0].width, 0, -16); - s2636_1 = s2636_config(malzak_s2636_1_ram, machine->screen[0].height, machine->screen[0].width, 0, -16); +// s2636_0 = s2636_config(malzak_s2636_0_ram, height, width, -8, -16); +// s2636_1 = s2636_config(malzak_s2636_1_ram, height, width, -9, -16); + s2636_0 = s2636_config(malzak_s2636_0_ram, height, width, 0, -16); + s2636_1 = s2636_config(malzak_s2636_1_ram, height, width, 0, -16); } VIDEO_UPDATE( malzak ) diff --git a/src/mame/video/metro.c b/src/mame/video/metro.c index a1de0ef2ef7..8658fcf679e 100644 --- a/src/mame/video/metro.c +++ b/src/mame/video/metro.c @@ -561,8 +561,8 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan UINT8 *base_gfx = memory_region(region); UINT8 *gfx_max = base_gfx + memory_region_length(region); - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); int max_sprites = spriteram_size / 8; int sprites = metro_videoregs[0x00/2] % max_sprites; @@ -869,8 +869,8 @@ VIDEO_UPDATE( metro ) } } - metro_sprite_xoffs = metro_videoregs[0x06/2] - screen->machine->screen[0].width / 2; - metro_sprite_yoffs = metro_videoregs[0x04/2] - screen->machine->screen[0].height / 2; + metro_sprite_xoffs = metro_videoregs[0x06/2] - video_screen_get_width(screen) / 2; + metro_sprite_yoffs = metro_videoregs[0x04/2] - video_screen_get_height(screen) / 2; /* The background color is selected by a register */ fillbitmap(priority_bitmap,0,cliprect); diff --git a/src/mame/video/model3.c b/src/mame/video/model3.c index 1236888d8af..6aba6a99555 100644 --- a/src/mame/video/model3.c +++ b/src/mame/video/model3.c @@ -142,11 +142,15 @@ static void model3_exit(running_machine *machine) VIDEO_START( model3 ) { + int width, height; + poly = poly_alloc(4000, sizeof(poly_extra_data), 0); add_exit_callback(machine, model3_exit); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); bitmap3d = video_screen_auto_bitmap_alloc(machine->primary_screen); - zbuffer = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED32); + zbuffer = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED32); m3_char_ram = auto_malloc(0x100000); m3_tile_ram = auto_malloc(0x8000); diff --git a/src/mame/video/namcos2.c b/src/mame/video/namcos2.c index 137ec9e5b8a..d62b9ab3223 100644 --- a/src/mame/video/namcos2.c +++ b/src/mame/video/namcos2.c @@ -258,14 +258,12 @@ namcos2_GetPosIrqScanline( void ) { /* PaleteRegister(4)? used by Finest Hour; pc=0x356e */ int scanline = GetPaletteRegister(5) - 34; + int height = video_screen_get_height(Machine->primary_screen); if( scanline<0 ) - { scanline = 0; - } - else if( scanline > Machine->screen[0].height ) - { - scanline = Machine->screen[0].height; - } + else if( scanline > height ) + scanline = height; + return scanline; } /* namcos2_GetPosIrqScanline */ diff --git a/src/mame/video/nbmj8891.c b/src/mame/video/nbmj8891.c index e4b805c19bb..f92d2022de9 100644 --- a/src/mame/video/nbmj8891.c +++ b/src/mame/video/nbmj8891.c @@ -295,18 +295,21 @@ void nbmj8891_vramflip(int vram) UINT8 color1, color2; UINT8 *vidram; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + if (nbmj8891_flipscreen == nbmj8891_flipscreen_old) return; vidram = vram ? nbmj8891_videoram1 : nbmj8891_videoram0; - for (y = 0; y < (Machine->screen[0].height / 2); y++) + for (y = 0; y < (height / 2); y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = vidram[(y * Machine->screen[0].width) + x]; - color2 = vidram[((y ^ 0xff) * Machine->screen[0].width) + (x ^ 0x1ff)]; - vidram[(y * Machine->screen[0].width) + x] = color2; - vidram[((y ^ 0xff) * Machine->screen[0].width) + (x ^ 0x1ff)] = color1; + color1 = vidram[(y * width) + x]; + color2 = vidram[((y ^ 0xff) * width) + (x ^ 0x1ff)]; + vidram[(y * width) + x] = color2; + vidram[((y ^ 0xff) * width) + (x ^ 0x1ff)] = color1; } } @@ -317,13 +320,13 @@ void nbmj8891_vramflip(int vram) static void update_pixel0(int x, int y) { - UINT8 color = nbmj8891_videoram0[(y * Machine->screen[0].width) + x]; + UINT8 color = nbmj8891_videoram0[(y * video_screen_get_width(Machine->primary_screen)) + x]; *BITMAP_ADDR16(nbmj8891_tmpbitmap0, y, x) = color; } static void update_pixel1(int x, int y) { - UINT8 color = nbmj8891_videoram1[(y * Machine->screen[0].width) + x]; + UINT8 color = nbmj8891_videoram1[(y * video_screen_get_width(Machine->primary_screen)) + x]; *BITMAP_ADDR16(nbmj8891_tmpbitmap1, y, x) = (color == 0x7f) ? 0xff : color; } @@ -335,6 +338,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj8891_gfxdraw(void) { UINT8 *GFX = memory_region(REGION_GFX1); + int width = video_screen_get_width(Machine->primary_screen); int x, y; int dx1, dx2, dy1, dy2; @@ -439,12 +443,12 @@ static void nbmj8891_gfxdraw(void) // layer 1 if (color1 != 0xff) { - nbmj8891_videoram0[(dy1 * Machine->screen[0].width) + dx1] = color1; + nbmj8891_videoram0[(dy1 * width) + dx1] = color1; update_pixel0(dx1, dy1); } if (color2 != 0xff) { - nbmj8891_videoram0[(dy1 * Machine->screen[0].width) + dx2] = color2; + nbmj8891_videoram0[(dy1 * width) + dx2] = color2; update_pixel0(dx2, dy1); } } @@ -456,21 +460,21 @@ static void nbmj8891_gfxdraw(void) // transparent enable if (color1 != 0xff) { - nbmj8891_videoram1[(dy2 * Machine->screen[0].width) + dx1] = color1; + nbmj8891_videoram1[(dy2 * width) + dx1] = color1; update_pixel1(dx1, dy2); } if (color2 != 0xff) { - nbmj8891_videoram1[(dy2 * Machine->screen[0].width) + dx2] = color2; + nbmj8891_videoram1[(dy2 * width) + dx2] = color2; update_pixel1(dx2, dy2); } } else { // transparent disable - nbmj8891_videoram1[(dy2 * Machine->screen[0].width) + dx1] = color1; + nbmj8891_videoram1[(dy2 * width) + dx1] = color1; update_pixel1(dx1, dy2); - nbmj8891_videoram1[(dy2 * Machine->screen[0].width) + dx2] = color2; + nbmj8891_videoram1[(dy2 * width) + dx2] = color2; update_pixel1(dx2, dy2); } } @@ -491,12 +495,14 @@ VIDEO_START( nbmj8891_1layer ) { UINT8 *CLUT = memory_region(REGION_USER1); int i; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); nbmj8891_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj8891_videoram0 = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(char)); + nbmj8891_videoram0 = auto_malloc(width * height * sizeof(char)); nbmj8891_palette = auto_malloc(0x200 * sizeof(char)); nbmj8891_clut = auto_malloc(0x800 * sizeof(char)); - memset(nbmj8891_videoram0, 0xff, (machine->screen[0].width * machine->screen[0].height * sizeof(char))); + memset(nbmj8891_videoram0, 0xff, (width * height * sizeof(char))); gfxdraw_mode = 0; if (nb1413m3_type == NB1413M3_TAIWANMB) @@ -505,14 +511,17 @@ VIDEO_START( nbmj8891_1layer ) VIDEO_START( nbmj8891_2layer ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + nbmj8891_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen); nbmj8891_tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj8891_videoram0 = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT8)); - nbmj8891_videoram1 = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT8)); + nbmj8891_videoram0 = auto_malloc(width * height * sizeof(UINT8)); + nbmj8891_videoram1 = auto_malloc(width * height * sizeof(UINT8)); nbmj8891_palette = auto_malloc(0x200 * sizeof(UINT8)); nbmj8891_clut = auto_malloc(0x800 * sizeof(UINT8)); - memset(nbmj8891_videoram0, 0xff, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); - memset(nbmj8891_videoram1, 0xff, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); + memset(nbmj8891_videoram0, 0xff, (width * height * sizeof(UINT8))); + memset(nbmj8891_videoram1, 0xff, (width * height * sizeof(UINT8))); gfxdraw_mode = 1; } @@ -526,24 +535,18 @@ VIDEO_UPDATE( nbmj8891 ) if (nbmj8891_screen_refresh) { + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + nbmj8891_screen_refresh = 0; - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) - { + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) update_pixel0(x, y); - } - } + if (gfxdraw_mode) - { - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) - { + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) update_pixel1(x, y); - } - } - } } if (nbmj8891_dispflag) diff --git a/src/mame/video/nbmj8991.c b/src/mame/video/nbmj8991.c index 7d5b303cc75..e7972525b49 100644 --- a/src/mame/video/nbmj8991.c +++ b/src/mame/video/nbmj8991.c @@ -153,23 +153,25 @@ static void nbmj8991_vramflip(void) static int nbmj8991_flipscreen_old = 0; int x, y; UINT8 color1, color2; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); if (nbmj8991_flipscreen == nbmj8991_flipscreen_old) return; - for (y = 0; y < Machine->screen[0].height / 2; y++) + for (y = 0; y < height / 2; y++) { - for (x = 0; x < Machine->screen[0].width / 2; x++) + for (x = 0; x < width / 2; x++) { // rotate 180 degrees ( 0, 0) - ( 511, 511) - color1 = nbmj8991_videoram[(y * Machine->screen[0].width) + x]; - color2 = nbmj8991_videoram[(((Machine->screen[0].height - 1) - y) * Machine->screen[0].width) + (((Machine->screen[0].width / 2) - 1) - x)]; - nbmj8991_videoram[(y * Machine->screen[0].width) + x] = color2; - nbmj8991_videoram[(((Machine->screen[0].height - 1) - y) * Machine->screen[0].width) + (((Machine->screen[0].width / 2) - 1) - x)] = color1; + color1 = nbmj8991_videoram[(y * width) + x]; + color2 = nbmj8991_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)]; + nbmj8991_videoram[(y * width) + x] = color2; + nbmj8991_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)] = color1; // rotate 180 degrees ( 512, 0) - (1023, 511) - color1 = nbmj8991_videoram[(y * Machine->screen[0].width) + (x + (Machine->screen[0].width / 2))]; - color2 = nbmj8991_videoram[(((Machine->screen[0].height - 1) - y) * Machine->screen[0].width) + ((((Machine->screen[0].width / 2) - 1) - x) + (Machine->screen[0].width / 2))]; - nbmj8991_videoram[(y * Machine->screen[0].width) + (x + (Machine->screen[0].width / 2))] = color2; - nbmj8991_videoram[(((Machine->screen[0].height - 1) - y) * Machine->screen[0].width) + ((((Machine->screen[0].width / 2) - 1) - x) + (Machine->screen[0].width / 2))] = color1; + color1 = nbmj8991_videoram[(y * width) + (x + (width / 2))]; + color2 = nbmj8991_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))]; + nbmj8991_videoram[(y * width) + (x + (width / 2))] = color2; + nbmj8991_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))] = color1; } } @@ -179,7 +181,7 @@ static void nbmj8991_vramflip(void) static void update_pixel(int x, int y) { - UINT8 color = nbmj8991_videoram[(y * Machine->screen[0].width) + x]; + UINT8 color = nbmj8991_videoram[(y * video_screen_get_width(Machine->primary_screen)) + x]; *BITMAP_ADDR16(nbmj8991_tmpbitmap, y, x) = color; } @@ -191,6 +193,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj8991_gfxdraw(void) { UINT8 *GFX = memory_region(REGION_GFX1); + int width = video_screen_get_width(Machine->primary_screen); int x, y; int dx1, dx2, dy; @@ -274,12 +277,12 @@ static void nbmj8991_gfxdraw(void) if (color1 != 0xff) { - nbmj8991_videoram[(dy * Machine->screen[0].width) + dx1] = color1; + nbmj8991_videoram[(dy * width) + dx1] = color1; update_pixel(dx1, dy); } if (color2 != 0xff) { - nbmj8991_videoram[(dy * Machine->screen[0].width) + dx2] = color2; + nbmj8991_videoram[(dy * width) + dx2] = color2; update_pixel(dx2, dy); } @@ -297,10 +300,13 @@ static void nbmj8991_gfxdraw(void) ******************************************************************************/ VIDEO_START( nbmj8991 ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + nbmj8991_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj8991_videoram = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT8)); + nbmj8991_videoram = auto_malloc(width * height * sizeof(UINT8)); nbmj8991_clut = auto_malloc(0x800 * sizeof(UINT8)); - memset(nbmj8991_videoram, 0x00, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); + memset(nbmj8991_videoram, 0x00, (width * height * sizeof(UINT8))); } VIDEO_UPDATE( nbmj8991_type1 ) @@ -309,15 +315,14 @@ VIDEO_UPDATE( nbmj8991_type1 ) if (nbmj8991_screen_refresh) { + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + nbmj8991_screen_refresh = 0; - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) - { + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) update_pixel(x, y); - } - } } if (nbmj8991_dispflag) @@ -349,15 +354,14 @@ VIDEO_UPDATE( nbmj8991_type2 ) if (nbmj8991_screen_refresh) { + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + nbmj8991_screen_refresh = 0; - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) - { + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) update_pixel(x, y); - } - } } if (nb1413m3_inputport & 0x20) diff --git a/src/mame/video/nbmj9195.c b/src/mame/video/nbmj9195.c index 1a2c67be47a..73129fb8646 100644 --- a/src/mame/video/nbmj9195.c +++ b/src/mame/video/nbmj9195.c @@ -185,30 +185,32 @@ static void nbmj9195_vramflip(int vram) static int nbmj9195_flipscreen_old[VRAM_MAX] = { 0, 0 }; int x, y; UINT16 color1, color2; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); if (nbmj9195_flipscreen[vram] == nbmj9195_flipscreen_old[vram]) return; - for (y = 0; y < (Machine->screen[0].height / 2); y++) + for (y = 0; y < (height / 2); y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = nbmj9195_videoram[vram][(y * Machine->screen[0].width) + x]; - color2 = nbmj9195_videoram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)]; - nbmj9195_videoram[vram][(y * Machine->screen[0].width) + x] = color2; - nbmj9195_videoram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)] = color1; + color1 = nbmj9195_videoram[vram][(y * width) + x]; + color2 = nbmj9195_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; + nbmj9195_videoram[vram][(y * width) + x] = color2; + nbmj9195_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; } } if (gfxdraw_mode == 2) { - for (y = 0; y < (Machine->screen[0].height / 2); y++) + for (y = 0; y < (height / 2); y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = nbmj9195_videoworkram[vram][(y * Machine->screen[0].width) + x]; - color2 = nbmj9195_videoworkram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)]; - nbmj9195_videoworkram[vram][(y * Machine->screen[0].width) + x] = color2; - nbmj9195_videoworkram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)] = color1; + color1 = nbmj9195_videoworkram[vram][(y * width) + x]; + color2 = nbmj9195_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; + nbmj9195_videoworkram[vram][(y * width) + x] = color2; + nbmj9195_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; } } } @@ -219,7 +221,7 @@ static void nbmj9195_vramflip(int vram) static void update_pixel(int vram, int x, int y) { - UINT16 color = nbmj9195_videoram[vram][(y * Machine->screen[0].width) + x]; + UINT16 color = nbmj9195_videoram[vram][(y * video_screen_get_width(Machine->primary_screen)) + x]; *BITMAP_ADDR16(nbmj9195_tmpbitmap[vram], y, x) = color; } @@ -231,6 +233,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj9195_gfxdraw(int vram) { UINT8 *GFX = memory_region(REGION_GFX1); + int width = video_screen_get_width(Machine->primary_screen); int x, y; int dx1, dx2, dy; @@ -324,27 +327,27 @@ static void nbmj9195_gfxdraw(int vram) if (nbmj9195_gfxflag2 & 0xc0) { // clut256 mode 1st(low) - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] &= 0x00f0; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] |= color1 & 0x0f; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] &= 0x00f0; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] |= color2 & 0x0f; + nbmj9195_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; + nbmj9195_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; + nbmj9195_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; + nbmj9195_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; continue; } else { // clut256 mode 2nd(high) - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] &= 0x000f; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] |= (color1 & 0x0f) << 4; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] &= 0x000f; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] |= (color2 & 0x0f) << 4; + nbmj9195_videoworkram[vram][(dy * width) + dx1] &= 0x000f; + nbmj9195_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; + nbmj9195_videoworkram[vram][(dy * width) + dx2] &= 0x000f; + nbmj9195_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] += nbmj9195_clut[vram][(nbmj9195_clutsel * 0x10)]; - nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] += nbmj9195_clut[vram][(nbmj9195_clutsel * 0x10)]; + nbmj9195_videoworkram[vram][(dy * width) + dx1] += nbmj9195_clut[vram][(nbmj9195_clutsel * 0x10)]; + nbmj9195_videoworkram[vram][(dy * width) + dx2] += nbmj9195_clut[vram][(nbmj9195_clutsel * 0x10)]; } - color1 = nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx1]; - color2 = nbmj9195_videoworkram[vram][(dy * Machine->screen[0].width) + dx2]; + color1 = nbmj9195_videoworkram[vram][(dy * width) + dx1]; + color2 = nbmj9195_videoworkram[vram][(dy * width) + dx2]; } else { @@ -361,12 +364,12 @@ static void nbmj9195_gfxdraw(int vram) if (((color1 & 0x00ff) != 0x00ff) || (!nbmj9195_transparency[vram])) { - nbmj9195_videoram[vram][(dy * Machine->screen[0].width) + dx1] = color1; + nbmj9195_videoram[vram][(dy * width) + dx1] = color1; update_pixel(vram, dx1, dy); } if (((color2 & 0x00ff) != 0x00ff) || (!nbmj9195_transparency[vram])) { - nbmj9195_videoram[vram][(dy * Machine->screen[0].width) + dx2] = color2; + nbmj9195_videoram[vram][(dy * width) + dx2] = color2; update_pixel(vram, dx2, dy); } @@ -405,11 +408,14 @@ WRITE8_HANDLER( nbmj9195_clut_1_w ) { nbmj9195_clut_w(1, offset, data); } ******************************************************************************/ VIDEO_START( nbmj9195_1layer ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj9195_videoram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); + nbmj9195_videoram[0] = auto_malloc(width * height * sizeof(UINT16)); nbmj9195_palette = auto_malloc(0x200 * sizeof(UINT8)); nbmj9195_clut[0] = auto_malloc(0x1000 * sizeof(UINT8)); - memset(nbmj9195_videoram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); + memset(nbmj9195_videoram[0], 0x0000, (width * height * sizeof(UINT16))); nbmj9195_scanline[0] = nbmj9195_scanline[1] = SCANLINE_MIN; nb19010_busyflag = 1; gfxdraw_mode = 0; @@ -417,15 +423,18 @@ VIDEO_START( nbmj9195_1layer ) VIDEO_START( nbmj9195_2layer ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); nbmj9195_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj9195_videoram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); - nbmj9195_videoram[1] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); + nbmj9195_videoram[0] = auto_malloc(width * height * sizeof(UINT16)); + nbmj9195_videoram[1] = auto_malloc(width * height * sizeof(UINT16)); nbmj9195_palette = auto_malloc(0x200 * sizeof(UINT8)); nbmj9195_clut[0] = auto_malloc(0x1000 * sizeof(UINT8)); nbmj9195_clut[1] = auto_malloc(0x1000 * sizeof(UINT8)); - memset(nbmj9195_videoram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); - memset(nbmj9195_videoram[1], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); + memset(nbmj9195_videoram[0], 0x0000, (width * height * sizeof(UINT16))); + memset(nbmj9195_videoram[1], 0x0000, (width * height * sizeof(UINT16))); nbmj9195_scanline[0] = nbmj9195_scanline[1] = SCANLINE_MIN; nb19010_busyflag = 1; gfxdraw_mode = 1; @@ -433,19 +442,22 @@ VIDEO_START( nbmj9195_2layer ) VIDEO_START( nbmj9195_nb22090 ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); nbmj9195_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj9195_videoram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); - nbmj9195_videoram[1] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); - nbmj9195_videoworkram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); - nbmj9195_videoworkram[1] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT16)); + nbmj9195_videoram[0] = auto_malloc(width * height * sizeof(UINT16)); + nbmj9195_videoram[1] = auto_malloc(width * height * sizeof(UINT16)); + nbmj9195_videoworkram[0] = auto_malloc(width * height * sizeof(UINT16)); + nbmj9195_videoworkram[1] = auto_malloc(width * height * sizeof(UINT16)); nbmj9195_nb22090_palette = auto_malloc(0xc00 * sizeof(UINT8)); nbmj9195_clut[0] = auto_malloc(0x1000 * sizeof(UINT8)); nbmj9195_clut[1] = auto_malloc(0x1000 * sizeof(UINT8)); - memset(nbmj9195_videoram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); - memset(nbmj9195_videoram[1], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); - memset(nbmj9195_videoworkram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); - memset(nbmj9195_videoworkram[1], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT16))); + memset(nbmj9195_videoram[0], 0x0000, (width * height * sizeof(UINT16))); + memset(nbmj9195_videoram[1], 0x0000, (width * height * sizeof(UINT16))); + memset(nbmj9195_videoworkram[0], 0x0000, (width * height * sizeof(UINT16))); + memset(nbmj9195_videoworkram[1], 0x0000, (width * height * sizeof(UINT16))); nbmj9195_scanline[0] = nbmj9195_scanline[1] = SCANLINE_MIN; nb19010_busyflag = 1; gfxdraw_mode = 2; @@ -463,20 +475,19 @@ VIDEO_UPDATE( nbmj9195 ) if (nbmj9195_screen_refresh) { + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + nbmj9195_screen_refresh = 0; - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) { update_pixel(0, x, y); if (gfxdraw_mode) - { update_pixel(1, x, y); - } } - } } for (i = 0; i < 2; i++) diff --git a/src/mame/video/niyanpai.c b/src/mame/video/niyanpai.c index 96369d6407e..b00facdc0da 100644 --- a/src/mame/video/niyanpai.c +++ b/src/mame/video/niyanpai.c @@ -153,28 +153,30 @@ static void niyanpai_vramflip(int vram) static int niyanpai_flipscreen_old[VRAM_MAX] = { 0, 0, 0 }; int x, y; UINT16 color1, color2; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); if (niyanpai_flipscreen[vram] == niyanpai_flipscreen_old[vram]) return; - for (y = 0; y < (Machine->screen[0].height / 2); y++) + for (y = 0; y < (height / 2); y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = niyanpai_videoram[vram][(y * Machine->screen[0].width) + x]; - color2 = niyanpai_videoram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)]; - niyanpai_videoram[vram][(y * Machine->screen[0].width) + x] = color2; - niyanpai_videoram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)] = color1; + color1 = niyanpai_videoram[vram][(y * width) + x]; + color2 = niyanpai_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; + niyanpai_videoram[vram][(y * width) + x] = color2; + niyanpai_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; } } - for (y = 0; y < (Machine->screen[0].height / 2); y++) + for (y = 0; y < (height / 2); y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = niyanpai_videoworkram[vram][(y * Machine->screen[0].width) + x]; - color2 = niyanpai_videoworkram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)]; - niyanpai_videoworkram[vram][(y * Machine->screen[0].width) + x] = color2; - niyanpai_videoworkram[vram][((y ^ 0x1ff) * Machine->screen[0].width) + (x ^ 0x3ff)] = color1; + color1 = niyanpai_videoworkram[vram][(y * width) + x]; + color2 = niyanpai_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; + niyanpai_videoworkram[vram][(y * width) + x] = color2; + niyanpai_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; } } @@ -184,7 +186,7 @@ static void niyanpai_vramflip(int vram) static void update_pixel(int vram, int x, int y) { - UINT16 color = niyanpai_videoram[vram][(y * Machine->screen[0].width) + x]; + UINT16 color = niyanpai_videoram[vram][(y * video_screen_get_width(Machine->primary_screen)) + x]; *BITMAP_ADDR16(niyanpai_tmpbitmap[vram], y, x) = color; } @@ -196,6 +198,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void niyanpai_gfxdraw(int vram) { UINT8 *GFX = memory_region(REGION_GFX1); + int width = video_screen_get_width(Machine->primary_screen); int x, y; int dx1, dx2, dy; @@ -289,27 +292,27 @@ static void niyanpai_gfxdraw(int vram) if (niyanpai_clutsel[vram] & 0x80) { // clut256 mode 1st(low) - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] &= 0x00f0; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] |= color1 & 0x0f; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] &= 0x00f0; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] |= color2 & 0x0f; + niyanpai_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; + niyanpai_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; + niyanpai_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; + niyanpai_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; continue; } else { // clut256 mode 2nd(high) - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] &= 0x000f; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] |= (color1 & 0x0f) << 4; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] &= 0x000f; - niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] |= (color2 & 0x0f) << 4; + niyanpai_videoworkram[vram][(dy * width) + dx1] &= 0x000f; + niyanpai_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; + niyanpai_videoworkram[vram][(dy * width) + dx2] &= 0x000f; + niyanpai_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; - // niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1] += niyanpai_clut[vram][(niyanpai_clutsel[vram] * 0x10)]; - // niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2] += niyanpai_clut[vram][(niyanpai_clutsel[vram] * 0x10)]; + // niyanpai_videoworkram[vram][(dy * width) + dx1] += niyanpai_clut[vram][(niyanpai_clutsel[vram] * 0x10)]; + // niyanpai_videoworkram[vram][(dy * width) + dx2] += niyanpai_clut[vram][(niyanpai_clutsel[vram] * 0x10)]; } - color1 = niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx1]; - color2 = niyanpai_videoworkram[vram][(dy * Machine->screen[0].width) + dx2]; + color1 = niyanpai_videoworkram[vram][(dy * width) + dx1]; + color2 = niyanpai_videoworkram[vram][(dy * width) + dx2]; } else { @@ -323,12 +326,12 @@ static void niyanpai_gfxdraw(int vram) if (((color1 & 0x00ff) != 0x00ff) || (!niyanpai_transparency[vram])) { - niyanpai_videoram[vram][(dy * Machine->screen[0].width) + dx1] = color1; + niyanpai_videoram[vram][(dy * width) + dx1] = color1; update_pixel(vram, dx1, dy); } if (((color2 & 0x00ff) != 0x00ff) || (!niyanpai_transparency[vram])) { - niyanpai_videoram[vram][(dy * Machine->screen[0].width) + dx2] = color2; + niyanpai_videoram[vram][(dy * width) + dx2] = color2; update_pixel(vram, dx2, dy); } @@ -372,25 +375,28 @@ WRITE16_HANDLER( niyanpai_clutsel_2_w ) { niyanpai_clutsel_w(2, data); } ******************************************************************************/ VIDEO_START( niyanpai ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + niyanpai_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); niyanpai_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); niyanpai_tmpbitmap[2] = video_screen_auto_bitmap_alloc(machine->primary_screen); - niyanpai_videoram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); - niyanpai_videoram[1] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); - niyanpai_videoram[2] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); - niyanpai_videoworkram[0] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); - niyanpai_videoworkram[1] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); - niyanpai_videoworkram[2] = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(short)); + niyanpai_videoram[0] = auto_malloc(width * height * sizeof(short)); + niyanpai_videoram[1] = auto_malloc(width * height * sizeof(short)); + niyanpai_videoram[2] = auto_malloc(width * height * sizeof(short)); + niyanpai_videoworkram[0] = auto_malloc(width * height * sizeof(short)); + niyanpai_videoworkram[1] = auto_malloc(width * height * sizeof(short)); + niyanpai_videoworkram[2] = auto_malloc(width * height * sizeof(short)); niyanpai_palette = auto_malloc(0x480 * sizeof(short)); niyanpai_clut[0] = auto_malloc(0x1000 * sizeof(char)); niyanpai_clut[1] = auto_malloc(0x1000 * sizeof(char)); niyanpai_clut[2] = auto_malloc(0x1000 * sizeof(char)); - memset(niyanpai_videoram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); - memset(niyanpai_videoram[1], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); - memset(niyanpai_videoram[2], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); - memset(niyanpai_videoworkram[0], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); - memset(niyanpai_videoworkram[1], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); - memset(niyanpai_videoworkram[2], 0x0000, (machine->screen[0].width * machine->screen[0].height * sizeof(short))); + memset(niyanpai_videoram[0], 0x0000, (width * height * sizeof(short))); + memset(niyanpai_videoram[1], 0x0000, (width * height * sizeof(short))); + memset(niyanpai_videoram[2], 0x0000, (width * height * sizeof(short))); + memset(niyanpai_videoworkram[0], 0x0000, (width * height * sizeof(short))); + memset(niyanpai_videoworkram[1], 0x0000, (width * height * sizeof(short))); + memset(niyanpai_videoworkram[2], 0x0000, (width * height * sizeof(short))); nb19010_busyflag = 1; } @@ -406,17 +412,18 @@ VIDEO_UPDATE( niyanpai ) if (niyanpai_screen_refresh) { + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + niyanpai_screen_refresh = 0; - for (y = 0; y < screen->machine->screen[0].height; y++) - { - for (x = 0; x < screen->machine->screen[0].width; x++) + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) { update_pixel(0, x, y); update_pixel(1, x, y); update_pixel(2, x, y); } - } } for (i = 0; i < 3; i++) diff --git a/src/mame/video/pastelg.c b/src/mame/video/pastelg.c index aad8928562f..8f30e573d0c 100644 --- a/src/mame/video/pastelg.c +++ b/src/mame/video/pastelg.c @@ -120,17 +120,19 @@ static void pastelg_vramflip(void) static int pastelg_flipscreen_old = 0; int x, y; UINT8 color1, color2; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); if (pastelg_flipscreen == pastelg_flipscreen_old) return; - for (y = 0; y < Machine->screen[0].height; y++) + for (y = 0; y < height; y++) { - for (x = 0; x < Machine->screen[0].width; x++) + for (x = 0; x < width; x++) { - color1 = pastelg_videoram[(y * Machine->screen[0].width) + x]; - color2 = pastelg_videoram[((y ^ 0xff) * Machine->screen[0].width) + (x ^ 0xff)]; - pastelg_videoram[(y * Machine->screen[0].width) + x] = color2; - pastelg_videoram[((y ^ 0xff) * Machine->screen[0].width) + (x ^ 0xff)] = color1; + color1 = pastelg_videoram[(y * width) + x]; + color2 = pastelg_videoram[((y ^ 0xff) * width) + (x ^ 0xff)]; + pastelg_videoram[(y * width) + x] = color2; + pastelg_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1; } } @@ -145,6 +147,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void pastelg_gfxdraw(void) { UINT8 *GFX = memory_region(REGION_GFX1); + int width = video_screen_get_width(Machine->primary_screen); int x, y; int dx, dy; @@ -229,13 +232,13 @@ static void pastelg_gfxdraw(void) if (color) { color = ((pastelg_palbank * 0x10) + color); - pastelg_videoram[(dy * Machine->screen[0].width) + dx] = color; + pastelg_videoram[(dy * width) + dx] = color; } } else { color = ((pastelg_palbank * 0x10) + pastelg_clut[color]); - pastelg_videoram[(dy * Machine->screen[0].width) + dx] = color; + pastelg_videoram[(dy * width) + dx] = color; } nb1413m3_busyctr++; @@ -252,9 +255,12 @@ static void pastelg_gfxdraw(void) ******************************************************************************/ VIDEO_START( pastelg ) { - pastelg_videoram = auto_malloc(machine->screen[0].width * machine->screen[0].height * sizeof(UINT8)); + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + + pastelg_videoram = auto_malloc(width * height * sizeof(UINT8)); pastelg_clut = auto_malloc(0x10 * sizeof(UINT8)); - memset(pastelg_videoram, 0x00, (machine->screen[0].width * machine->screen[0].height * sizeof(UINT8))); + memset(pastelg_videoram, 0x00, (width * height * sizeof(UINT8))); } /****************************************************************************** @@ -266,10 +272,12 @@ VIDEO_UPDATE( pastelg ) if (pastelg_dispflag) { int x, y; + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); - for (y = 0; y < screen->machine->screen[0].height; y++) - for (x = 0; x < screen->machine->screen[0].width; x++) - *BITMAP_ADDR16(bitmap, y, x) = pastelg_videoram[(y * screen->machine->screen[0].width) + x]; + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + *BITMAP_ADDR16(bitmap, y, x) = pastelg_videoram[(y * width) + x]; } else fillbitmap(bitmap, 0, cliprect); diff --git a/src/mame/video/policetr.c b/src/mame/video/policetr.c index 73bdb31ba21..7b781f81d33 100644 --- a/src/mame/video/policetr.c +++ b/src/mame/video/policetr.c @@ -275,31 +275,33 @@ WRITE32_HANDLER( policetr_video_w ) READ32_HANDLER( policetr_video_r ) { int inputval; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); /* the value read is based on the latch */ switch (video_latch) { /* latch 0x00 is player 1's gun X coordinate */ case 0x00: - inputval = ((readinputport(3) & 0xff) * Machine->screen[0].width) >> 8; + inputval = ((readinputport(3) & 0xff) * width) >> 8; inputval += 0x50; return (inputval << 20) | 0x20000000; /* latch 0x01 is player 1's gun Y coordinate */ case 0x01: - inputval = ((readinputport(4) & 0xff) * Machine->screen[0].height) >> 8; + inputval = ((readinputport(4) & 0xff) * height) >> 8; inputval += 0x17; return (inputval << 20); /* latch 0x02 is player 2's gun X coordinate */ case 0x02: - inputval = ((readinputport(5) & 0xff) * Machine->screen[0].width) >> 8; + inputval = ((readinputport(5) & 0xff) * width) >> 8; inputval += 0x50; return (inputval << 20) | 0x20000000; /* latch 0x03 is player 2's gun Y coordinate */ case 0x03: - inputval = ((readinputport(6) & 0xff) * Machine->screen[0].height) >> 8; + inputval = ((readinputport(6) & 0xff) * height) >> 8; inputval += 0x17; return (inputval << 20); diff --git a/src/mame/video/powerins.c b/src/mame/video/powerins.c index 54a15988461..a5baa7f196d 100644 --- a/src/mame/video/powerins.c +++ b/src/mame/video/powerins.c @@ -272,8 +272,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan UINT16 *source = spriteram16 + 0x8000/2; UINT16 *finish = spriteram16 + 0x9000/2; - int screen_w = machine->screen[0].width; - int screen_h = machine->screen[0].height; + int screen_w = video_screen_get_width(machine->primary_screen); + int screen_h = video_screen_get_height(machine->primary_screen); for ( ; source < finish; source += 16/2 ) { diff --git a/src/mame/video/psikyo.c b/src/mame/video/psikyo.c index af44e4785e1..a3fd0ba6c38 100644 --- a/src/mame/video/psikyo.c +++ b/src/mame/video/psikyo.c @@ -301,8 +301,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta UINT8 *TILES = memory_region(REGION_USER1); // Sprites LUT int TILES_LEN = memory_region_length(REGION_USER1); - int width = machine->screen[0].width; - int height = machine->screen[0].height; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); /* Exit if sprites are disabled */ if ( spritelist[ BYTE_XOR_BE((0x800-2)/2) ] & 1 ) return; diff --git a/src/mame/video/psikyosh.c b/src/mame/video/psikyosh.c index d530e5d8e31..fd363d60070 100644 --- a/src/mame/video/psikyosh.c +++ b/src/mame/video/psikyosh.c @@ -1054,10 +1054,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_START( psikyosh ) { - zoom_bitmap = auto_bitmap_alloc(16*16, 16*16, BITMAP_FORMAT_INDEXED8); + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + z_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); /* Need 16-bit z-buffer */ - z_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + zoom_bitmap = auto_bitmap_alloc(16*16, 16*16, BITMAP_FORMAT_INDEXED8); machine->gfx[1]->color_granularity=16; /* 256 colour sprites with palette selectable on 16 colour boundaries */ diff --git a/src/mame/video/psx.c b/src/mame/video/psx.c index f650f941aec..d2705de0209 100644 --- a/src/mame/video/psx.c +++ b/src/mame/video/psx.c @@ -286,19 +286,24 @@ static int m_n_debugcoordy[ DEBUG_COORDS ]; static void DebugMeshInit( void ) { + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + m_b_debugmesh = 0; m_b_debugtexture = 0; m_n_debuginterleave = -1; m_b_debugclear = 1; m_n_debugcoord = 0; m_n_debugskip = 0; - debugmesh = auto_bitmap_alloc( Machine->screen[0].width, Machine->screen[0].height, BITMAP_FORMAT_INDEXED16 ); + debugmesh = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16 ); } static void DebugMesh( int n_coordx, int n_coordy ) { int n_coord; int n_colour; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); if( m_b_debugclear ) { @@ -395,13 +400,11 @@ static void DebugMesh( int n_coordx, int n_coordy ) { if( (INT16)n_x.w.h >= 0 && (INT16)n_y.w.h >= 0 && - (INT16)n_x.w.h <= Machine->screen[0].width - 1 && - (INT16)n_y.w.h <= Machine->screen[0].height - 1 ) + (INT16)n_x.w.h <= width - 1 && + (INT16)n_y.w.h <= height - 1 ) { if( *BITMAP_ADDR16(debugmesh, n_y.w.h, n_x.w.h) != 0xffff ) - { *BITMAP_ADDR16(debugmesh, n_y.w.h, n_x.w.h) = n_colour; - } } n_x.d += n_dx; n_y.d += n_dy; @@ -424,7 +427,11 @@ static void DebugCheckKeys( void ) m_b_debugtexture = !m_b_debugtexture; if( m_b_debugmesh || m_b_debugtexture ) - video_screen_set_visarea(Machine->primary_screen, 0, Machine->screen[0].width - 1, 0, Machine->screen[0].height - 1 ); + { + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + video_screen_set_visarea(Machine->primary_screen, 0, width - 1, 0, height - 1 ); + } else video_screen_set_visarea(Machine->primary_screen, 0, m_n_screenwidth - 1, 0, m_n_screenheight - 1 ); @@ -503,14 +510,17 @@ static int DebugTextureDisplay( bitmap_t *bitmap ) if( m_b_debugtexture ) { - for( n_y = 0; n_y < Machine->screen[0].height; n_y++ ) + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); + + for( n_y = 0; n_y < height; n_y++ ) { int n_x; int n_xi; int n_yi; UINT16 p_n_interleave[ 1024 ]; - for( n_x = 0; n_x < Machine->screen[0].width; n_x++ ) + for( n_x = 0; n_x < width; n_x++ ) { if( m_n_debuginterleave == 0 ) { @@ -529,7 +539,7 @@ static int DebugTextureDisplay( bitmap_t *bitmap ) } p_n_interleave[ n_x ] = m_p_p_vram[ n_yi ][ n_xi ]; } - draw_scanline16( bitmap, 0, n_y, Machine->screen[0].width, p_n_interleave, Machine->pens, -1 ); + draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, Machine->pens, -1 ); } } return m_b_debugtexture; @@ -614,6 +624,8 @@ static void psx_gpu_init( void ) int n_level2; int n_shade; int n_shaded; + int width = video_screen_get_width(Machine->primary_screen); + int height = video_screen_get_height(Machine->primary_screen); #if defined( MAME_DEBUG ) DebugMeshInit(); @@ -625,13 +637,13 @@ static void psx_gpu_init( void ) m_n_lightgun_x = 0; m_n_lightgun_y = 0; - m_n_vram_size = Machine->screen[0].width * Machine->screen[0].height; + m_n_vram_size = width * height; m_p_vram = auto_malloc( m_n_vram_size * 2 ); memset( m_p_vram, 0x00, m_n_vram_size * 2 ); for( n_line = 0; n_line < 1024; n_line++ ) { - m_p_p_vram[ n_line ] = &m_p_vram[ ( n_line % Machine->screen[0].height ) * Machine->screen[0].width ]; + m_p_p_vram[ n_line ] = &m_p_vram[ ( n_line % height ) * width ]; } for( n_level = 0; n_level < MAX_LEVEL; n_level++ ) diff --git a/src/mame/video/quasar.c b/src/mame/video/quasar.c index d95221adfd6..ce9d0ef5b9f 100644 --- a/src/mame/video/quasar.c +++ b/src/mame/video/quasar.c @@ -98,12 +98,15 @@ PALETTE_INIT( quasar ) VIDEO_START( quasar ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + quasar_effectram = auto_malloc(0x400); /* configure the S2636 chips */ - s2636_0 = s2636_config(cvs_s2636_0_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); - s2636_1 = s2636_config(cvs_s2636_1_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); - s2636_2 = s2636_config(cvs_s2636_2_ram, machine->screen[0].height, machine->screen[0].width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + s2636_0 = s2636_config(cvs_s2636_0_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + s2636_1 = s2636_config(cvs_s2636_1_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); + s2636_2 = s2636_config(cvs_s2636_2_ram, height, width, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET); /* create helper bitmaps */ cvs_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen); diff --git a/src/mame/video/realbrk.c b/src/mame/video/realbrk.c index e9ff7a09201..2c9f1894452 100644 --- a/src/mame/video/realbrk.c +++ b/src/mame/video/realbrk.c @@ -217,8 +217,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan { int offs; - int max_x = machine->screen[0].width; - int max_y = machine->screen[0].height; + int max_x = video_screen_get_width(machine->primary_screen); + int max_y = video_screen_get_height(machine->primary_screen); rectangle spritetile_clip; spritetile_clip.min_x = 0; @@ -384,8 +384,8 @@ static void dai2kaku_draw_sprites( bitmap_t *bitmap,const rectangle *cliprect, i { int offs; - int max_x = Machine->screen[0].width; - int max_y = Machine->screen[0].height; + int max_x = video_screen_get_width(Machine->primary_screen); + int max_y = video_screen_get_height(Machine->primary_screen); for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 ) { diff --git a/src/mame/video/segaic16.c b/src/mame/video/segaic16.c index b9a75008965..47e08c37066 100644 --- a/src/mame/video/segaic16.c +++ b/src/mame/video/segaic16.c @@ -612,11 +612,14 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem rectangle pageclip; int page; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + /* which half/halves of the virtual tilemap do we intersect in the X direction? */ - if (xscroll < 64*8 - machine->screen[0].width) + if (xscroll < 64*8 - width) { leftmin = 0; - leftmax = machine->screen[0].width - 1; + leftmax = width - 1; rightmin = -1; } else if (xscroll < 64*8) @@ -624,12 +627,12 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem leftmin = 0; leftmax = 64*8 - xscroll - 1; rightmin = leftmax + 1; - rightmax = machine->screen[0].width - 1; + rightmax = width - 1; } - else if (xscroll < 128*8 - machine->screen[0].width) + else if (xscroll < 128*8 - width) { rightmin = 0; - rightmax = machine->screen[0].width - 1; + rightmax = width - 1; leftmin = -1; } else @@ -637,14 +640,14 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem rightmin = 0; rightmax = 128*8 - xscroll - 1; leftmin = rightmax + 1; - leftmax = machine->screen[0].width - 1; + leftmax = width - 1; } /* which half/halves of the virtual tilemap do we intersect in the Y direction? */ - if (yscroll < 32*8 - machine->screen[0].height) + if (yscroll < 32*8 - height) { topmin = 0; - topmax = machine->screen[0].height - 1; + topmax = height - 1; bottommin = -1; } else if (yscroll < 32*8) @@ -652,12 +655,12 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem topmin = 0; topmax = 32*8 - yscroll - 1; bottommin = topmax + 1; - bottommax = machine->screen[0].height - 1; + bottommax = height - 1; } - else if (yscroll < 64*8 - machine->screen[0].height) + else if (yscroll < 64*8 - height) { bottommin = 0; - bottommax = machine->screen[0].height - 1; + bottommax = height - 1; topmin = -1; } else @@ -665,7 +668,7 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem bottommin = 0; bottommax = 64*8 - yscroll - 1; topmin = bottommax + 1; - topmax = machine->screen[0].height - 1; + topmax = height - 1; } /* if the tilemap is flipped, we need to flip our sense within each quadrant */ @@ -674,26 +677,26 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem if (leftmin != -1) { int temp = leftmin; - leftmin = machine->screen[0].width - 1 - leftmax; - leftmax = machine->screen[0].width - 1 - temp; + leftmin = width - 1 - leftmax; + leftmax = width - 1 - temp; } if (rightmin != -1) { int temp = rightmin; - rightmin = machine->screen[0].width - 1 - rightmax; - rightmax = machine->screen[0].width - 1 - temp; + rightmin = width - 1 - rightmax; + rightmax = width - 1 - temp; } if (topmin != -1) { int temp = topmin; - topmin = machine->screen[0].height - 1 - topmax; - topmax = machine->screen[0].height - 1 - temp; + topmin = height - 1 - topmax; + topmax = height - 1 - temp; } if (bottommin != -1) { int temp = bottommin; - bottommin = machine->screen[0].height - 1 - bottommax; - bottommax = machine->screen[0].height - 1 - temp; + bottommin = height - 1 - bottommax; + bottommax = height - 1 - temp; } } diff --git a/src/mame/video/segas18.c b/src/mame/video/segas18.c index 7e33aac5163..b48025a59d7 100644 --- a/src/mame/video/segas18.c +++ b/src/mame/video/segas18.c @@ -54,6 +54,8 @@ void system18_vdp_update(bitmap_t *bitmap, const rectangle *cliprect); VIDEO_START( system18 ) { + int width, height; + /* compute palette info */ segaic16_palette_init(0x800); @@ -67,7 +69,9 @@ VIDEO_START( system18 ) system18_vdp_start(machine); /* create a temp bitmap to draw the VDP data into */ - tempbitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + tempbitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); } diff --git a/src/mame/video/seta.c b/src/mame/video/seta.c index 26f0be9d750..6db9eb48c22 100644 --- a/src/mame/video/seta.c +++ b/src/mame/video/seta.c @@ -853,7 +853,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan if (flip) { - y = (0x100 - machine->screen[0].height) + max_y - y; + y = (0x100 - video_screen_get_height(machine->primary_screen)) + max_y - y; flipx = !flipx; flipy = !flipy; } diff --git a/src/mame/video/skyfox.c b/src/mame/video/skyfox.c index b0facf8c109..13f3a26b8b9 100644 --- a/src/mame/video/skyfox.c +++ b/src/mame/video/skyfox.c @@ -168,8 +168,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { int offs; - int width = machine->screen[0].width; - int height = machine->screen[0].height; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); /* The 32x32 tiles in the 80-ff range are bankswitched */ int shift = (skyfox_bg_ctrl & 0x80) ? (4-1) : 4; diff --git a/src/mame/video/spacefb.c b/src/mame/video/spacefb.c index 7b931118c6c..18bb120e6cf 100644 --- a/src/mame/video/spacefb.c +++ b/src/mame/video/spacefb.c @@ -79,6 +79,8 @@ WRITE8_HANDLER( spacefb_port_2_w ) VIDEO_START( spacefb ) { + int width, height; + /* compute the color gun weights */ static const int resistances_rg[] = { 1000, 470, 220 }; static const int resistances_b [] = { 470, 220 }; @@ -88,7 +90,9 @@ VIDEO_START( spacefb ) 2, resistances_b, color_weights_b, 470, 0, 0, 0, 0, 0, 0); - object_present_map = auto_malloc(machine->screen[0].width * machine->screen[0].height); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + object_present_map = auto_malloc(width * height); /* this start value positions the stars to match the flyer screen shot, but most likely, the actual star position is random as the hardware diff --git a/src/mame/video/spbactn.c b/src/mame/video/spbactn.c index 52461934605..8c09026fb16 100644 --- a/src/mame/video/spbactn.c +++ b/src/mame/video/spbactn.c @@ -177,8 +177,11 @@ static int draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan VIDEO_START( spbactn ) { /* allocate bitmaps */ - tile_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - tile_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + + tile_bitmap_bg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_fg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); } VIDEO_UPDATE( spbactn ) diff --git a/src/mame/video/srmp2.c b/src/mame/video/srmp2.c index 2aa19c8af9f..d54518effeb 100644 --- a/src/mame/video/srmp2.c +++ b/src/mame/video/srmp2.c @@ -79,7 +79,7 @@ static void srmp2_draw_sprites(running_machine *machine, bitmap_t *bitmap, const /* Sprites Banking and/or Sprites Buffering */ UINT16 *src = spriteram16_2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 ); - int max_y = machine -> screen[0].height; + int max_y = video_screen_get_height(machine->primary_screen); xoffs = flip ? 0x10 : 0x10; yoffs = flip ? 0x05 : 0x07; @@ -229,7 +229,7 @@ static void srmp3_draw_sprites(running_machine *machine, bitmap_t *bitmap, const int offs; int xoffs, yoffs; - int max_y = machine -> screen[0].height; + int max_y = video_screen_get_height(machine->primary_screen); int ctrl = spriteram[ 0x600/2 ]; // int ctrl2 = spriteram[ 0x602/2 ]; @@ -390,7 +390,7 @@ static void mjyuugi_draw_sprites(running_machine *machine, bitmap_t *bitmap, con /* Sprites Banking and/or Sprites Buffering */ UINT16 *src = spriteram16_2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 ); - int max_y = machine -> screen[0].height; + int max_y = video_screen_get_height(machine->primary_screen); mjyuugi_draw_sprites_map(machine, bitmap, cliprect); diff --git a/src/mame/video/starshp1.c b/src/mame/video/starshp1.c index eba123c3915..c0e833c70e5 100644 --- a/src/mame/video/starshp1.c +++ b/src/mame/video/starshp1.c @@ -115,15 +115,17 @@ VIDEO_START( starshp1 ) READ8_HANDLER( starshp1_rng_r ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); int x = video_screen_get_hpos(machine->primary_screen); int y = video_screen_get_vpos(machine->primary_screen); /* the LFSR is only running in the non-blank region of the screen, so this is not quite right */ - if (x > Machine->screen[0].width - 1) - x = Machine->screen[0].width - 1; - if (y > Machine->screen[0].height - 1) - y = Machine->screen[0].height - 1; + if (x > width - 1) + x = width - 1; + if (y > height - 1) + y = height - 1; return LSFR[x + (UINT16) (512 * y)]; } diff --git a/src/mame/video/suna16.c b/src/mame/video/suna16.c index 0a457791764..358436682c5 100644 --- a/src/mame/video/suna16.c +++ b/src/mame/video/suna16.c @@ -121,8 +121,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { int offs; - int max_x = machine->screen[0].width - 8; - int max_y = machine->screen[0].height - 8; + int max_x = video_screen_get_width(machine->primary_screen) - 8; + int max_y = video_screen_get_height(machine->primary_screen) - 8; for ( offs = 0xfc00/2; offs < 0x10000/2 ; offs += 4/2 ) { diff --git a/src/mame/video/suna8.c b/src/mame/video/suna8.c index 21390c4f35f..c3a9fd8599b 100644 --- a/src/mame/video/suna8.c +++ b/src/mame/video/suna8.c @@ -208,8 +208,8 @@ static void draw_normal_sprites(running_machine *machine, bitmap_t *bitmap,const int i; int mx = 0; // multisprite x counter - int max_x = machine->screen[0].width - 8; - int max_y = machine->screen[0].height - 8; + int max_x = video_screen_get_width(machine->primary_screen) - 8; + int max_y = video_screen_get_height(machine->primary_screen) - 8; for (i = 0x1d00; i < 0x2000; i += 4) { @@ -338,8 +338,8 @@ static void draw_text_sprites(running_machine *machine, bitmap_t *bitmap,const r { int i; - int max_x = machine->screen[0].width - 8; - int max_y = machine->screen[0].height - 8; + int max_x = video_screen_get_width(machine->primary_screen) - 8; + int max_y = video_screen_get_height(machine->primary_screen) - 8; /* Earlier games only */ if (!(suna8_text_dim > 0)) return; diff --git a/src/mame/video/system1.c b/src/mame/video/system1.c index c75a8831ce7..d08d36088f9 100644 --- a/src/mame/video/system1.c +++ b/src/mame/video/system1.c @@ -194,8 +194,8 @@ INLINE void draw_pixel(running_machine *machine, bitmap_t *bitmap, int sprite_onscreen; const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - if (x < 0 || x >= Machine->screen[0].width || - y < 0 || y >= Machine->screen[0].height) + if (x < 0 || x >= video_screen_get_width(machine->primary_screen) || + y < 0 || y >= video_screen_get_height(machine->primary_screen)) return; if (sprite_onscreen_map[256*y+x] != 255) diff --git a/src/mame/video/taito_f3.c b/src/mame/video/taito_f3.c index a92d1e72692..181e71c3f3e 100644 --- a/src/mame/video/taito_f3.c +++ b/src/mame/video/taito_f3.c @@ -545,7 +545,7 @@ VIDEO_EOF( f3 ) VIDEO_START( f3 ) { const struct F3config *pCFG=&f3_config_table[0]; - int tile; + int tile, width, height; spritelist=0; spriteram32_buffered=0; @@ -605,7 +605,9 @@ VIDEO_START( f3 ) pivot_dirty = (UINT8 *)auto_malloc(2048); pf_line_inf = auto_malloc(5 * sizeof(struct f3_playfield_line_inf)); sa_line_inf = auto_malloc(1 * sizeof(struct f3_spritealpha_line_inf)); - pri_alp_bitmap = auto_bitmap_alloc( machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED8 ); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + pri_alp_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED8 ); tile_opaque_sp = (UINT8 *)auto_malloc(machine->gfx[2]->total_elements); tile_opaque_pf = (UINT8 *)auto_malloc(machine->gfx[1]->total_elements); diff --git a/src/mame/video/taitojc.c b/src/mame/video/taitojc.c index bed2aaf6195..27f39c0b055 100644 --- a/src/mame/video/taitojc.c +++ b/src/mame/video/taitojc.c @@ -195,6 +195,8 @@ static void taitojc_exit(running_machine *machine) VIDEO_START( taitojc ) { + int width, height; + poly = poly_alloc(4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS); add_exit_callback(machine, taitojc_exit); @@ -226,7 +228,9 @@ VIDEO_START( taitojc ) framebuffer = video_screen_auto_bitmap_alloc(machine->primary_screen); - zbuffer = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + width = video_screen_get_width(machine->primary_screen); + height = video_screen_get_height(machine->primary_screen); + zbuffer = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); } //static int tick = 0; @@ -634,8 +638,8 @@ void taitojc_clear_frame(void) cliprect.min_x = 0; cliprect.min_y = 0; - cliprect.max_x = Machine->screen[0].width-1; - cliprect.max_y = Machine->screen[0].height-1; + cliprect.max_x = video_screen_get_width(Machine->primary_screen) - 1; + cliprect.max_y = video_screen_get_height(Machine->primary_screen) - 1; fillbitmap(framebuffer, 0, &cliprect); fillbitmap(zbuffer, 0xffff, &cliprect); diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c index b83a44c14b2..b0d338fd94c 100644 --- a/src/mame/video/taitosj.c +++ b/src/mame/video/taitosj.c @@ -427,6 +427,8 @@ static void check_sprite_sprite_collision(running_machine *machine) static void calculate_sprite_areas(running_machine *machine, int *sprites_on, rectangle *sprite_areas) { int which; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); for (which = 0; which < 0x20; which++) { @@ -453,10 +455,10 @@ static void calculate_sprite_areas(running_machine *machine, int *sprites_on, re /* check for bitmap bounds to avoid illegal memory access */ if (minx < 0) minx = 0; if (miny < 0) miny = 0; - if (maxx >= machine->screen[0].width - 1) - maxx = machine->screen[0].width - 1; - if (maxy >= machine->screen[0].height - 1) - maxy = machine->screen[0].height - 1; + if (maxx >= width - 1) + maxx = width - 1; + if (maxy >= height - 1) + maxy = height - 1; sprite_areas[which].min_x = minx; sprite_areas[which].max_x = maxx; diff --git a/src/mame/video/tecmo16.c b/src/mame/video/tecmo16.c index e44757cfd20..076ac39fa1b 100644 --- a/src/mame/video/tecmo16.c +++ b/src/mame/video/tecmo16.c @@ -64,12 +64,15 @@ static TILE_GET_INFO( tx_get_tile_info ) VIDEO_START( fstarfrc ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + /* set up tile layers */ - tile_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - tile_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_bg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_fg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); /* set up sprites */ - sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + sprite_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); fg_tilemap = tilemap_create(fg_get_tile_info,tilemap_scan_rows,16,16,32,32); bg_tilemap = tilemap_create(bg_get_tile_info,tilemap_scan_rows,16,16,32,32); @@ -86,12 +89,15 @@ VIDEO_START( fstarfrc ) VIDEO_START( ginkun ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + /* set up tile layers */ - tile_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - tile_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_bg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_fg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); /* set up sprites */ - sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + sprite_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); fg_tilemap = tilemap_create(fg_get_tile_info,tilemap_scan_rows,16,16,64,32); bg_tilemap = tilemap_create(bg_get_tile_info,tilemap_scan_rows,16,16,64,32); @@ -106,12 +112,15 @@ VIDEO_START( ginkun ) VIDEO_START( riot ) { + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); + /* set up tile layers */ - tile_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); - tile_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_bg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); + tile_bitmap_fg = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); /* set up sprites */ - sprite_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, BITMAP_FORMAT_INDEXED16); + sprite_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); fg_tilemap = tilemap_create(fg_get_tile_info,tilemap_scan_rows,16,16,64,32); bg_tilemap = tilemap_create(bg_get_tile_info,tilemap_scan_rows,16,16,64,32); diff --git a/src/mame/video/tia.c b/src/mame/video/tia.c index 6d03a63fb2e..bfc4769a725 100644 --- a/src/mame/video/tia.c +++ b/src/mame/video/tia.c @@ -272,9 +272,9 @@ PALETTE_INIT( tia_PAL ) VIDEO_START( tia ) { - int cx = machine->screen[0].width; + int cx = video_screen_get_width(machine->primary_screen); - screen_height = machine->screen[0].height; + screen_height = video_screen_get_height(machine->primary_screen); helper[0] = auto_bitmap_alloc(cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); helper[1] = auto_bitmap_alloc(cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); helper[2] = auto_bitmap_alloc(cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); @@ -283,7 +283,7 @@ VIDEO_START( tia ) VIDEO_UPDATE( tia ) { - screen_height = screen->machine->screen[0].height; + screen_height = video_screen_get_height(screen); copybitmap(bitmap, helper[2], 0, 0, 0, 0, cliprect); return 0; } @@ -873,8 +873,8 @@ static WRITE8_HANDLER( VSYNC_w ) if ( curr_y > 5 ) update_bitmap( - Machine->screen[0].width, - Machine->screen[0].height); + video_screen_get_width(machine->primary_screen), + video_screen_get_height(machine->primary_screen)); if ( tia_vsync_callback ) { tia_vsync_callback( machine, 0, curr_y, 0xFFFF ); diff --git a/src/mame/video/volfied.c b/src/mame/video/volfied.c index ce6d8a1ce13..ee222d33f3f 100644 --- a/src/mame/video/volfied.c +++ b/src/mame/video/volfied.c @@ -95,13 +95,15 @@ static void refresh_pixel_layer(running_machine *machine, bitmap_t *bitmap) *********************************************************/ UINT16* p = video_ram; + int width = video_screen_get_width(machine->primary_screen); + int height = video_screen_get_height(machine->primary_screen); if (video_ctrl & 1) p += 0x20000; - for (y = 0; y < machine->screen[0].height; y++) + for (y = 0; y < height; y++) { - for (x = 1; x < machine->screen[0].width + 1; x++) // Hmm, 1 pixel offset is needed to align properly with sprites + for (x = 1; x < width + 1; x++) // Hmm, 1 pixel offset is needed to align properly with sprites { int color = (p[x] << 2) & 0x700; diff --git a/src/mame/video/ygv608.c b/src/mame/video/ygv608.c index 3d37210af06..d2d9bc3de11 100644 --- a/src/mame/video/ygv608.c +++ b/src/mame/video/ygv608.c @@ -747,9 +747,9 @@ VIDEO_UPDATE( ygv608 ) // clip to the current bitmap finalclip.min_x = 0; - finalclip.max_x = screen->machine->screen[0].width - 1; + finalclip.max_x = video_screen_get_width(screen) - 1; finalclip.min_y = 0; - finalclip.max_y = screen->machine->screen[0].height - 1; + finalclip.max_y = video_screen_get_height(screen) - 1; sect_rect(&finalclip, cliprect); cliprect = &finalclip; diff --git a/src/mame/video/zaxxon.c b/src/mame/video/zaxxon.c index 7dff8a48932..087ba34743d 100644 --- a/src/mame/video/zaxxon.c +++ b/src/mame/video/zaxxon.c @@ -141,8 +141,8 @@ static void video_start_common(running_machine *machine, tile_get_info_func fg_t /* configure the foreground tilemap */ tilemap_set_transparent_pen(fg_tilemap, 0); - tilemap_set_scrolldx(fg_tilemap, 0, machine->screen[0].width - 256); - tilemap_set_scrolldy(fg_tilemap, 0, machine->screen[0].height - 256); + tilemap_set_scrolldx(fg_tilemap, 0, video_screen_get_width(machine->primary_screen) - 256); + tilemap_set_scrolldy(fg_tilemap, 0, video_screen_get_height(machine->primary_screen) - 256); /* register for save states */ state_save_register_global(bg_enable); |