Moves 'refresh' from public to internal video state and renames it to 'frame_period'

Changes all drivers that previously accessed 'refresh' to use video_screen_get_frame_period()
This commit is contained in:
Zsolt Vasvari 2008-03-07 14:34:04 +00:00
parent d0f5196025
commit d0870c6936
26 changed files with 76 additions and 74 deletions

View File

@ -1500,7 +1500,7 @@ void cheat_init(running_machine *machine)
InitStringTable(); InitStringTable();
periodic_timer = timer_alloc(cheat_periodic, NULL); periodic_timer = timer_alloc(cheat_periodic, NULL);
timer_adjust_periodic(periodic_timer, attotime_make(0, machine->screen[0].refresh), 0, attotime_make(0, machine->screen[0].refresh)); timer_adjust_periodic(periodic_timer, video_screen_get_frame_period(0), 0, video_screen_get_frame_period(0));
add_exit_callback(machine, cheat_exit); add_exit_callback(machine, cheat_exit);
} }
@ -11403,7 +11403,7 @@ static void cheat_periodicAction(running_machine *machine, CheatAction * action)
/* ----- keep if one shot + restore prevous value + delay !=0 ----- */ /* ----- keep if one shot + restore prevous value + delay !=0 ----- */
cheat_periodicOperation(action); cheat_periodicOperation(action);
if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(machine->screen[0].refresh))) if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds)))
{ {
action->frameTimer = 0; action->frameTimer = 0;
@ -11415,7 +11415,7 @@ static void cheat_periodicAction(running_machine *machine, CheatAction * action)
else else
{ {
/* ----- otherwise, delay ----- */ /* ----- otherwise, delay ----- */
if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(machine->screen[0].refresh))) if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds)))
{ {
action->frameTimer = 0; action->frameTimer = 0;
@ -11454,7 +11454,7 @@ static void cheat_periodicAction(running_machine *machine, CheatAction * action)
if(currentValue != action->lastValue) if(currentValue != action->lastValue)
{ {
action->frameTimer = parameter * ATTOSECONDS_TO_HZ(machine->screen[0].refresh); action->frameTimer = parameter * ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
action->flags |= kActionFlag_WasModified; action->flags |= kActionFlag_WasModified;
} }

View File

@ -951,7 +951,7 @@ static void cpu_inittimers(running_machine *machine)
ipf = machine->config->cpu_slices_per_frame; ipf = machine->config->cpu_slices_per_frame;
if (ipf <= 0) if (ipf <= 0)
ipf = 1; ipf = 1;
refresh_attosecs = (numscreens == 0) ? HZ_TO_ATTOSECONDS(60) : machine->screen[0].refresh; refresh_attosecs = (numscreens == 0) ? HZ_TO_ATTOSECONDS(60) : video_screen_get_frame_period(0).attoseconds;
timeslice_period = attotime_make(0, refresh_attosecs / ipf); timeslice_period = attotime_make(0, refresh_attosecs / ipf);
timeslice_timer = timer_alloc(cpu_timeslicecallback, NULL); timeslice_timer = timer_alloc(cpu_timeslicecallback, NULL);
timer_adjust_periodic(timeslice_timer, timeslice_period, 0, timeslice_period); timer_adjust_periodic(timeslice_timer, timeslice_period, 0, timeslice_period);

View File

@ -174,7 +174,7 @@ const char *profiler_get_text(void)
} }
if (computed || showdelay[i]) if (computed || showdelay[i])
{ {
if (computed) showdelay[i] = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh); if (computed) showdelay[i] = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
showdelay[i]--; showdelay[i]--;
if (i < PROFILER_PROFILER) if (i < PROFILER_PROFILER)

View File

@ -677,9 +677,9 @@ static void *nesapu_start(int sndindex, int clock, const void *config)
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
/* Initialize global variables */ /* Initialize global variables */
info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(Machine->screen[0].refresh); info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
info->buffer_size = info->samps_per_sync; info->buffer_size = info->samps_per_sync;
info->real_rate = info->samps_per_sync * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh); info->real_rate = info->samps_per_sync * ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
info->apu_incsize = (float) (clock / (float) info->real_rate); info->apu_incsize = (float) (clock / (float) info->real_rate);
/* Use initializer calls */ /* Use initializer calls */

View File

@ -1127,7 +1127,7 @@ int sprintf_game_info(char *buffer)
Machine->screen[index].visarea.max_x - Machine->screen[index].visarea.min_x + 1, Machine->screen[index].visarea.max_x - Machine->screen[index].visarea.min_x + 1,
Machine->screen[index].visarea.max_y - Machine->screen[index].visarea.min_y + 1, Machine->screen[index].visarea.max_y - Machine->screen[index].visarea.min_y + 1,
(Machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H", (Machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H",
ATTOSECONDS_TO_HZ(Machine->screen[index].refresh)); ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds));
} }
} }
@ -1743,9 +1743,9 @@ static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer
{ {
screen_state *state = &Machine->screen[arg]; screen_state *state = &Machine->screen[arg];
video_screen_configure(arg, state->width, state->height, &state->visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001)); video_screen_configure(arg, state->width, state->height, &state->visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001));
sprintf(buffer, "%s Refresh rate %.3f", slider_get_screen_desc(arg), ATTOSECONDS_TO_HZ(Machine->screen[arg].refresh)); sprintf(buffer, "%s Refresh rate %.3f", slider_get_screen_desc(arg), ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds));
} }
refresh = ATTOSECONDS_TO_HZ(Machine->screen[arg].refresh); refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
return floor((refresh - defrefresh) * 1000.0f + 0.5f); return floor((refresh - defrefresh) * 1000.0f + 0.5f);
} }

View File

@ -62,10 +62,11 @@ struct _internal_screen_state
INT32 last_partial_scan; /* scanline of last partial update */ INT32 last_partial_scan; /* scanline of last partial update */
/* screen timing */ /* screen timing */
attoseconds_t frame_period; /* attoseconds per frame */
attoseconds_t scantime; /* attoseconds per scanline */ attoseconds_t scantime; /* attoseconds per scanline */
attoseconds_t pixeltime; /* attoseconds per pixel */ attoseconds_t pixeltime; /* attoseconds per pixel */
attoseconds_t vblank_period; /* attoseconds per VBLANK period */ attoseconds_t vblank_period; /* attoseconds per VBLANK period */
attotime vblank_time; /* time of last VBLANK start */ attotime vblank_start_time; /* time of last VBLANK start */
UINT8 vblank_state; /* 1 = in VBLANK region, 0 = outside */ UINT8 vblank_state; /* 1 = in VBLANK region, 0 = outside */
emu_timer * vblank_begin_timer; /* timer to signal VBLANK start */ emu_timer * vblank_begin_timer; /* timer to signal VBLANK start */
emu_timer * vblank_end_timer; /* timer to signal VBLANK end */ emu_timer * vblank_end_timer; /* timer to signal VBLANK end */
@ -354,7 +355,7 @@ void video_init(running_machine *machine)
render_container_set_yscale(container, config->yscale); render_container_set_yscale(container, config->yscale);
/* reset VBLANK timing */ /* reset VBLANK timing */
internal_state->vblank_time = attotime_zero; internal_state->vblank_start_time = attotime_zero;
/* allocate a timer to generate per-scanline updates */ /* allocate a timer to generate per-scanline updates */
if (machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) if (machine->config->video_attributes & VIDEO_UPDATE_SCANLINE)
@ -367,8 +368,8 @@ void video_init(running_machine *machine)
assert(strlen(device->tag) < 30); assert(strlen(device->tag) < 30);
state_save_combine_module_and_tag(unique_tag, "video_screen", device->tag); state_save_combine_module_and_tag(unique_tag, "video_screen", device->tag);
state_save_register_item(unique_tag, 0, internal_state->vblank_time.seconds); state_save_register_item(unique_tag, 0, internal_state->vblank_start_time.seconds);
state_save_register_item(unique_tag, 0, internal_state->vblank_time.attoseconds); state_save_register_item(unique_tag, 0, internal_state->vblank_start_time.attoseconds);
state_save_register_item(unique_tag, 0, internal_state->frame_number); state_save_register_item(unique_tag, 0, internal_state->frame_number);
} }
@ -434,15 +435,15 @@ static void video_exit(running_machine *machine)
/* free all the textures and bitmaps */ /* free all the textures and bitmaps */
for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++)
{ {
internal_screen_state *info = get_internal_state(machine, scrnum); internal_screen_state *internal_state = get_internal_state(machine, scrnum);
if (info->texture[0] != NULL) if (internal_state->texture[0] != NULL)
render_texture_free(info->texture[0]); render_texture_free(internal_state->texture[0]);
if (info->texture[1] != NULL) if (internal_state->texture[1] != NULL)
render_texture_free(info->texture[1]); render_texture_free(internal_state->texture[1]);
if (info->bitmap[0] != NULL) if (internal_state->bitmap[0] != NULL)
bitmap_free(info->bitmap[0]); bitmap_free(internal_state->bitmap[0]);
if (info->bitmap[1] != NULL) if (internal_state->bitmap[1] != NULL)
bitmap_free(info->bitmap[1]); bitmap_free(internal_state->bitmap[1]);
} }
/* free the snapshot target */ /* free the snapshot target */
@ -681,7 +682,7 @@ static void decode_graphics(running_machine *machine, const gfx_decode_entry *gf
of a screen of a screen
-------------------------------------------------*/ -------------------------------------------------*/
void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, attoseconds_t refresh) void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, attoseconds_t frame_period)
{ {
const screen_config *scrconfig = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, scrnum)->inline_config; const screen_config *scrconfig = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, scrnum)->inline_config;
screen_state *state = &Machine->screen[scrnum]; screen_state *state = &Machine->screen[scrnum];
@ -749,16 +750,16 @@ void video_screen_configure(int scrnum, int width, int height, const rectangle *
state->width = width; state->width = width;
state->height = height; state->height = height;
state->visarea = *visarea; state->visarea = *visarea;
state->refresh = refresh;
/* compute timing parameters */ /* compute timing parameters */
internal_state->scantime = refresh / height; internal_state->frame_period = frame_period;
internal_state->pixeltime = refresh / (height * width); internal_state->scantime = frame_period / height;
internal_state->pixeltime = frame_period / (height * width);
/* if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now /* 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 */ from the visible area, otherwise just used the supplied value */
if ((scrconfig->vblank == 0) && !scrconfig->oldstyle_vblank_supplied) if ((scrconfig->vblank == 0) && !scrconfig->oldstyle_vblank_supplied)
internal_state->vblank_period = (state->refresh / state->height) * (state->height - (state->visarea.max_y + 1 - state->visarea.min_y)); internal_state->vblank_period = (frame_period / height) * (height - (visarea->max_y + 1 - visarea->min_y));
else else
internal_state->vblank_period = scrconfig->vblank; internal_state->vblank_period = scrconfig->vblank;
@ -768,7 +769,7 @@ void video_screen_configure(int scrnum, int width, int height, const rectangle *
float minrefresh = render_get_max_update_rate(); float minrefresh = render_get_max_update_rate();
if (minrefresh != 0) if (minrefresh != 0)
{ {
UINT32 target_speed = floor(minrefresh * 100.0 / ATTOSECONDS_TO_HZ(refresh)); UINT32 target_speed = floor(minrefresh * 100.0 / ATTOSECONDS_TO_HZ(frame_period));
target_speed = MIN(target_speed, global.original_speed); target_speed = MIN(target_speed, global.original_speed);
if (target_speed != global.speed) if (target_speed != global.speed)
{ {
@ -798,6 +799,7 @@ void video_screen_configure(int scrnum, int width, int height, const rectangle *
void video_screen_set_visarea(int scrnum, int min_x, int max_x, int min_y, int max_y) void video_screen_set_visarea(int scrnum, int min_x, int max_x, int min_y, int max_y)
{ {
screen_state *state = &Machine->screen[scrnum]; screen_state *state = &Machine->screen[scrnum];
internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
rectangle visarea; rectangle visarea;
visarea.min_x = min_x; visarea.min_x = min_x;
@ -805,7 +807,7 @@ void video_screen_set_visarea(int scrnum, int min_x, int max_x, int min_y, int m
visarea.min_y = min_y; visarea.min_y = min_y;
visarea.max_y = max_y; visarea.max_y = max_y;
video_screen_configure(scrnum, state->width, state->height, &visarea, state->refresh); video_screen_configure(scrnum, state->width, state->height, &visarea, internal_state->frame_period);
} }
@ -937,7 +939,7 @@ int video_screen_get_vpos(int scrnum)
{ {
screen_state *state = &Machine->screen[scrnum]; screen_state *state = &Machine->screen[scrnum];
internal_screen_state *internal_state = get_internal_state(Machine, scrnum); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_time)); attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time));
int vpos; int vpos;
/* round to the nearest pixel */ /* round to the nearest pixel */
@ -960,7 +962,7 @@ int video_screen_get_vpos(int scrnum)
int video_screen_get_hpos(int scrnum) int video_screen_get_hpos(int scrnum)
{ {
internal_screen_state *internal_state = get_internal_state(Machine, scrnum); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_time)); attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time));
int vpos; int vpos;
/* round to the nearest pixel */ /* round to the nearest pixel */
@ -1012,7 +1014,7 @@ attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos)
{ {
screen_state *state = &Machine->screen[scrnum]; screen_state *state = &Machine->screen[scrnum];
internal_screen_state *internal_state = get_internal_state(Machine, scrnum); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_time)); attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(), internal_state->vblank_start_time));
attoseconds_t targetdelta; attoseconds_t targetdelta;
/* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */ /* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */
@ -1024,9 +1026,9 @@ attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos)
/* if we're past that time (within 1/2 of a pixel), head to the next frame */ /* if we're past that time (within 1/2 of a pixel), head to the next frame */
if (targetdelta <= curdelta + internal_state->pixeltime / 2) if (targetdelta <= curdelta + internal_state->pixeltime / 2)
targetdelta += state->refresh; targetdelta += internal_state->frame_period;
while (targetdelta <= curdelta) while (targetdelta <= curdelta)
targetdelta += state->refresh; targetdelta += internal_state->frame_period;
/* return the difference */ /* return the difference */
return attotime_make(0, targetdelta - curdelta); return attotime_make(0, targetdelta - curdelta);
@ -1081,8 +1083,8 @@ attotime video_screen_get_time_until_update(int scrnum)
attotime video_screen_get_scan_period(int scrnum) attotime video_screen_get_scan_period(int scrnum)
{ {
internal_screen_state *info = get_internal_state(Machine, scrnum); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
return attotime_make(0, info->scantime); return attotime_make(0, internal_state->scantime);
} }
@ -1094,7 +1096,8 @@ attotime video_screen_get_scan_period(int scrnum)
attotime video_screen_get_frame_period(int scrnum) attotime video_screen_get_frame_period(int scrnum)
{ {
return attotime_make(0, Machine->screen[scrnum].refresh); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
return attotime_make(0, internal_state->frame_period);
} }
@ -1106,8 +1109,8 @@ attotime video_screen_get_frame_period(int scrnum)
UINT64 video_screen_get_frame_number(int scrnum) UINT64 video_screen_get_frame_number(int scrnum)
{ {
internal_screen_state *info = get_internal_state(Machine, scrnum); internal_screen_state *internal_state = get_internal_state(Machine, scrnum);
return info->frame_number; return internal_state->frame_number;
} }
@ -1254,7 +1257,7 @@ static TIMER_CALLBACK( vblank_begin_callback )
internal_screen_state *internal_state = (internal_screen_state *)state->private_data; internal_screen_state *internal_state = (internal_screen_state *)state->private_data;
/* reset the starting VBLANK time */ /* reset the starting VBLANK time */
internal_state->vblank_time = timer_get_time(); internal_state->vblank_start_time = timer_get_time();
/* mark as being in VBLANK */ /* mark as being in VBLANK */
internal_state->vblank_state = TRUE; internal_state->vblank_state = TRUE;
@ -1273,7 +1276,7 @@ static TIMER_CALLBACK( vblank_begin_callback )
video_frame_update(machine, FALSE); video_frame_update(machine, FALSE);
/* reset the timers */ /* reset the timers */
timer_adjust_oneshot(internal_state->vblank_begin_timer, attotime_make(0, state->refresh), 0); timer_adjust_oneshot(internal_state->vblank_begin_timer, attotime_make(0, internal_state->frame_period), 0);
timer_adjust_oneshot(internal_state->vblank_end_timer, attotime_make(0, internal_state->vblank_period), 0); timer_adjust_oneshot(internal_state->vblank_end_timer, attotime_make(0, internal_state->vblank_period), 0);
} }
@ -2186,7 +2189,6 @@ void video_movie_end_recording(running_machine *machine, int scrnum)
static void movie_record_frame(running_machine *machine, int scrnum) static void movie_record_frame(running_machine *machine, int scrnum)
{ {
screen_state *state = &machine->screen[scrnum];
internal_screen_state *internal_state = get_internal_state(machine, scrnum); internal_screen_state *internal_state = get_internal_state(machine, scrnum);
const rgb_t *palette; const rgb_t *palette;
@ -2213,7 +2215,7 @@ static void movie_record_frame(running_machine *machine, int scrnum)
png_add_text(&pnginfo, "System", text); png_add_text(&pnginfo, "System", text);
/* start the capture */ /* start the capture */
error = mng_capture_start(mame_core_file(internal_state->movie_file), global.snap_bitmap, ATTOSECONDS_TO_HZ(state->refresh)); error = mng_capture_start(mame_core_file(internal_state->movie_file), global.snap_bitmap, ATTOSECONDS_TO_HZ(internal_state->frame_period));
if (error != PNGERR_NONE) if (error != PNGERR_NONE)
{ {
png_free(&pnginfo); png_free(&pnginfo);

View File

@ -66,7 +66,6 @@ struct _screen_state
{ {
int width, height; /* current total width/height (HTOTAL, VTOTAL) */ int width, height; /* current total width/height (HTOTAL, VTOTAL) */
rectangle visarea; /* current visible area (HBLANK end/start, VBLANK end/start) */ rectangle visarea; /* current visible area (HBLANK end/start, VBLANK end/start) */
attoseconds_t refresh; /* current refresh period */
bitmap_format format; /* bitmap format (a copy of screen_config) */ bitmap_format format; /* bitmap format (a copy of screen_config) */
void * private_data; /* pointer to the private data structure */ void * private_data; /* pointer to the private data structure */
}; };

View File

@ -472,7 +472,7 @@ static void updateflip(void)
visarea.max_y = temp; visarea.max_y = temp;
} }
video_screen_configure(0, state->width, state->height, &visarea, state->refresh); video_screen_configure(0, state->width, state->height, &visarea, video_screen_get_frame_period(0).attoseconds);
} }

View File

@ -195,7 +195,7 @@ static void TMS9928A_start (running_machine *machine, const TMS9928a_interface *
/* configure the screen if we weren't overridden */ /* configure the screen if we weren't overridden */
if (machine->screen[0].width == LEFT_BORDER+32*8+RIGHT_BORDER && machine->screen[0].height == TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ) if (machine->screen[0].width == LEFT_BORDER+32*8+RIGHT_BORDER && machine->screen[0].height == TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ)
video_screen_configure(0, LEFT_BORDER + 32*8 + RIGHT_BORDER, tms.top_border + 24*8 + tms.bottom_border, &tms.visarea, machine->screen[0].refresh); video_screen_configure(0, LEFT_BORDER + 32*8 + RIGHT_BORDER, tms.top_border + 24*8 + tms.bottom_border, &tms.visarea, video_screen_get_frame_period(0).attoseconds);
/* Video RAM */ /* Video RAM */
tms.vramsize = intf->vram; tms.vramsize = intf->vram;

View File

@ -2610,7 +2610,7 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
int vvis = (v->reg[videoDimensions].u >> 16) & 0x3ff; int vvis = (v->reg[videoDimensions].u >> 16) & 0x3ff;
int hbp = (v->reg[backPorch].u & 0xff) + 2; int hbp = (v->reg[backPorch].u & 0xff) + 2;
int vbp = (v->reg[backPorch].u >> 16) & 0xff; int vbp = (v->reg[backPorch].u >> 16) & 0xff;
screen_state *state = &Machine->screen[v->scrnum]; attoseconds_t refresh = video_screen_get_frame_period(v->scrnum).attoseconds;
attoseconds_t stdperiod, medperiod, vgaperiod; attoseconds_t stdperiod, medperiod, vgaperiod;
attoseconds_t stddiff, meddiff, vgadiff; attoseconds_t stddiff, meddiff, vgadiff;
rectangle visarea; rectangle visarea;
@ -2631,11 +2631,11 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
vgaperiod = HZ_TO_ATTOSECONDS(31500) * vtotal; vgaperiod = HZ_TO_ATTOSECONDS(31500) * vtotal;
/* compute a diff against the current refresh period */ /* compute a diff against the current refresh period */
stddiff = stdperiod - state->refresh; stddiff = stdperiod - refresh;
if (stddiff < 0) stddiff = -stddiff; if (stddiff < 0) stddiff = -stddiff;
meddiff = medperiod - state->refresh; meddiff = medperiod - refresh;
if (meddiff < 0) meddiff = -meddiff; if (meddiff < 0) meddiff = -meddiff;
vgadiff = vgaperiod - state->refresh; vgadiff = vgaperiod - refresh;
if (vgadiff < 0) vgadiff = -vgadiff; if (vgadiff < 0) vgadiff = -vgadiff;
mame_printf_debug("hSync=%08X vSync=%08X backPorch=%08X videoDimensions=%08X\n", mame_printf_debug("hSync=%08X vSync=%08X backPorch=%08X videoDimensions=%08X\n",

View File

@ -181,7 +181,7 @@ SOUND_START( cchasm )
ctc_intf.baseclock = cpunum_get_clock(1); ctc_intf.baseclock = cpunum_get_clock(1);
z80ctc_init (0, &ctc_intf); z80ctc_init (0, &ctc_intf);
timer_pulse(attotime_make(0, machine->screen[0].refresh), NULL, 0, cchasm_sh_update); timer_pulse(video_screen_get_frame_period(0), NULL, 0, cchasm_sh_update);
} }

View File

@ -365,7 +365,7 @@ static void galaxian_sh_start(void)
lfotimer = timer_alloc(lfo_timer_cb, NULL); lfotimer = timer_alloc(lfo_timer_cb, NULL);
timer_pulse(attotime_make(0, Machine->screen[0].refresh), NULL, 0, galaxian_sh_update); timer_pulse(video_screen_get_frame_period(0), NULL, 0, galaxian_sh_update);
state_save_register_global(freq); state_save_register_global(freq);
state_save_register_global(noise_enable); state_save_register_global(noise_enable);

View File

@ -84,5 +84,5 @@ void senjyo_sh_start(void)
sample_set_volume(0,0); sample_set_volume(0,0);
sample_start_raw(0,_single,SINGLE_LENGTH,single_rate,1); sample_start_raw(0,_single,SINGLE_LENGTH,single_rate,1);
timer_pulse(attotime_make(0, Machine->screen[0].refresh), NULL, 0, senjyo_sh_update); timer_pulse(video_screen_get_frame_period(0), NULL, 0, senjyo_sh_update);
} }

View File

@ -1054,7 +1054,7 @@ static VIDEO_UPDATE(cps3)
cps3_screenwidth = 496; cps3_screenwidth = 496;
visarea.min_x = 0; visarea.max_x = 496-1; visarea.min_x = 0; visarea.max_x = 496-1;
visarea.min_y = 0; visarea.max_y = 224-1; visarea.min_y = 0; visarea.max_y = 224-1;
video_screen_configure(0, 496, 224, &visarea, state->refresh ); video_screen_configure(0, 496, 224, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
} }
else else
@ -1066,7 +1066,7 @@ static VIDEO_UPDATE(cps3)
cps3_screenwidth = 384; cps3_screenwidth = 384;
visarea.min_x = 0; visarea.max_x = 384-1; visarea.min_x = 0; visarea.max_x = 384-1;
visarea.min_y = 0; visarea.max_y = 224-1; visarea.min_y = 0; visarea.max_y = 224-1;
video_screen_configure(0, 384, 224, &visarea, state->refresh ); video_screen_configure(0, 384, 224, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
} }

View File

@ -75,7 +75,7 @@ AH
visarea.max_x = _x_-1; \ visarea.max_x = _x_-1; \
visarea.min_y = 0; \ visarea.min_y = 0; \
visarea.max_y = _y_-1; \ visarea.max_y = _y_-1; \
video_screen_configure(0, _x_, _y_, &visarea, state->refresh ); \ video_screen_configure(0, _x_, _y_, &visarea, video_screen_get_frame_period(0).attoseconds ); \
} \ } \

View File

@ -606,7 +606,7 @@ static void GCU_w(int chip, UINT32 offset, UINT32 data, UINT32 mem_mask)
// only try and update the screen if the driver says we have one // only try and update the screen if the driver says we have one
if (screen < numscreens) if (screen < numscreens)
video_screen_configure(screen, visarea.max_x + 1, visarea.max_y + 1, &visarea, Machine->screen[screen].refresh); video_screen_configure(screen, visarea.max_x + 1, visarea.max_y + 1, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
break; break;
} }

View File

@ -264,7 +264,7 @@ static UINT32 hit_check_x,hit_check_y;
visarea.max_x = _x_-1; \ visarea.max_x = _x_-1; \
visarea.min_y = 0; \ visarea.min_y = 0; \
visarea.max_y = _y_-1; \ visarea.max_y = _y_-1; \
video_screen_configure(0, _x_, _y_, &visarea, state->refresh ); \ video_screen_configure(0, _x_, _y_, &visarea, video_screen_get_frame_period(0).attoseconds ); \
flip_screen_set(_flip_); \ flip_screen_set(_flip_); \
} \ } \

View File

@ -219,7 +219,7 @@ static void draw_framebuffer(running_machine *machine, bitmap_t *bitmap, const r
visarea.min_x = visarea.min_y = 0; visarea.min_x = visarea.min_y = 0;
visarea.max_x = width - 1; visarea.max_x = width - 1;
visarea.max_y = height - 1; visarea.max_y = height - 1;
video_screen_configure(0, width, height * 262 / 240, &visarea, machine->screen[0].refresh); video_screen_configure(0, width, height * 262 / 240, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
if (disp_ctrl_reg[DC_OUTPUT_CFG] & 0x1) // 8-bit mode if (disp_ctrl_reg[DC_OUTPUT_CFG] & 0x1) // 8-bit mode

View File

@ -632,7 +632,7 @@ WRITE32_HANDLER( n64_vi_reg_w )
screen_state *state = &Machine->screen[0]; screen_state *state = &Machine->screen[0];
rectangle visarea = state->visarea; rectangle visarea = state->visarea;
visarea.max_y = (data & 0x40) ? 479 : 239; visarea.max_y = (data & 0x40) ? 479 : 239;
video_screen_configure(0, state->width, visarea.max_y + 1, &visarea, Machine->screen[0].refresh); video_screen_configure(0, state->width, visarea.max_y + 1, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
n64_vi_control = data; n64_vi_control = data;
break; break;
@ -647,7 +647,7 @@ WRITE32_HANDLER( n64_vi_reg_w )
screen_state *state = &Machine->screen[0]; screen_state *state = &Machine->screen[0];
rectangle visarea = state->visarea; rectangle visarea = state->visarea;
visarea.max_x = data-1; visarea.max_x = data-1;
video_screen_configure(0, visarea.max_x + 1, state->height, &visarea, Machine->screen[0].refresh); video_screen_configure(0, visarea.max_x + 1, state->height, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
n64_vi_width = data; n64_vi_width = data;
fb_width = data; fb_width = data;

View File

@ -336,7 +336,7 @@ static void snes_init_ram(running_machine *machine)
has_dsp1 = ((snes_r_bank1(machine,0xffd6) >= 3) && (snes_r_bank1(machine,0xffd6) <= 5)) ? 1 : 0; has_dsp1 = ((snes_r_bank1(machine,0xffd6) >= 3) && (snes_r_bank1(machine,0xffd6) <= 5)) ? 1 : 0;
// init frame counter so first line is 0 // init frame counter so first line is 0
if( ATTOSECONDS_TO_HZ(Machine->screen[0].refresh) >= 59 ) if( ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds) >= 59 )
{ {
snes_ppu.beam.current_vert = SNES_VTOTAL_NTSC; snes_ppu.beam.current_vert = SNES_VTOTAL_NTSC;
} }
@ -379,9 +379,9 @@ MACHINE_RESET( snes )
snes_init_ram(machine); snes_init_ram(machine);
/* Set STAT78 to NTSC or PAL */ /* Set STAT78 to NTSC or PAL */
if( ATTOSECONDS_TO_HZ(machine->screen[0].refresh) >= 59.0f ) if( ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds) >= 59.0f )
snes_ram[STAT78] = SNES_NTSC; snes_ram[STAT78] = SNES_NTSC;
else /* if( machine->screen[0].refresh == 50 ) */ else /* if( ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds) == 50.0f ) */
snes_ram[STAT78] = SNES_PAL; snes_ram[STAT78] = SNES_PAL;
// reset does this to these registers // reset does this to these registers
@ -1110,11 +1110,11 @@ WRITE8_HANDLER( snes_w_io )
if ((snes_ram[STAT78] & 0x10) == SNES_NTSC) if ((snes_ram[STAT78] & 0x10) == SNES_NTSC)
{ {
video_screen_configure(0, SNES_HTOTAL*snes_htmult, SNES_VTOTAL_NTSC, &visarea, Machine->screen[0].refresh); video_screen_configure(0, SNES_HTOTAL*snes_htmult, SNES_VTOTAL_NTSC, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
else else
{ {
video_screen_configure(0, SNES_HTOTAL*snes_htmult, SNES_VTOTAL_PAL, &visarea, Machine->screen[0].refresh); video_screen_configure(0, SNES_HTOTAL*snes_htmult, SNES_VTOTAL_PAL, &visarea, video_screen_get_frame_period(0).attoseconds);
} }
} }

View File

@ -295,7 +295,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen )
{ {
cpunum_set_input_line(machine, 1, 0, HOLD_LINE); cpunum_set_input_line(machine, 1, 0, HOLD_LINE);
if (param != 0) if (param != 0)
timer_adjust_periodic(crtc_timer, attotime_make(0, machine->screen[0].refresh / param), 0, attotime_make(0, machine->screen[0].refresh / param)); timer_adjust_periodic(crtc_timer, attotime_div(video_screen_get_frame_period(0), param), 0, attotime_div(video_screen_get_frame_period(0), param));
} }

View File

@ -672,10 +672,11 @@ static void vdp_register_w(int data, int vblank)
{ {
screen_state *state = &Machine->screen[genesis_screen_number]; screen_state *state = &Machine->screen[genesis_screen_number];
rectangle visarea = state->visarea; rectangle visarea = state->visarea;
attoseconds_t refresh = video_screen_get_frame_period(genesis_screen_number).attoseconds;
/* this gets called from the init! */ /* this gets called from the init! */
visarea.max_x = scrwidth*8-1; visarea.max_x = scrwidth*8-1;
video_screen_configure(genesis_screen_number, scrwidth*8, state->height, &visarea, state->refresh); video_screen_configure(genesis_screen_number, scrwidth*8, state->height, &visarea, refresh);
} }
break; break;

View File

@ -147,7 +147,7 @@ static void gtia_state(void)
static int is_ntsc(void) static int is_ntsc(void)
{ {
return ATTOSECONDS_TO_HZ(Machine->screen[0].refresh) > 55; return ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds) > 55;
} }

View File

@ -79,7 +79,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen )
{ {
cpunum_set_input_line(machine, 0, 1, HOLD_LINE); cpunum_set_input_line(machine, 0, 1, HOLD_LINE);
if (param != 0) if (param != 0)
timer_adjust_periodic(crtc_timer, attotime_make(0, machine->screen[0].refresh / param), 0, attotime_make(0, machine->screen[0].refresh / param)); timer_adjust_periodic(crtc_timer, attotime_div(video_screen_get_frame_period(0), param), 0, attotime_div(video_screen_get_frame_period(0), param));
} }

View File

@ -1238,7 +1238,7 @@ static int get_adapter_for_monitor(d3d_info *d3d, win_monitor_info *monitor)
static void pick_best_mode(win_window_info *window) static void pick_best_mode(win_window_info *window)
{ {
double target_refresh = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh); double target_refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
INT32 target_width, target_height; INT32 target_width, target_height;
d3d_info *d3d = window->drawdata; d3d_info *d3d = window->drawdata;
INT32 minwidth, minheight; INT32 minwidth, minheight;

View File

@ -1304,7 +1304,7 @@ static void pick_best_mode(win_window_info *window)
// use those as the target for now // use those as the target for now
einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale); einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale); einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);
einfo.target_refresh = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh); einfo.target_refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(0).attoseconds);
// if we're not stretching, allow some slop on the minimum since we can handle it // if we're not stretching, allow some slop on the minimum since we can handle it
if (!video_config.hwstretch) if (!video_config.hwstretch)