static void update_fps(mame_time emutime) { osd_ticks_t curr = osd_ticks(); // update stats for the FPS average calculation if (fps_start_time == 0) { // start the timer going 1 second into the game if (emutime.seconds > 1) fps_start_time = osd_ticks(); } else { fps_frames_displayed++; if (fps_frames_displayed == video_config.framestorun) { mame_file_error filerr; mame_file *fp; char name[20]; // make a filename with an underscore prefix sprintf(name, "_%.8s.png", Machine->gamedrv->name); // write out the screenshot filerr = mame_fopen(SEARCHPATH_SCREENSHOT, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp); if (filerr == FILERR_NONE) { video_screen_save_snapshot(fp, 0); mame_fclose(fp); } mame_schedule_exit(Machine); } fps_end_time = curr; } }
void video_save_active_screen_snapshots(void) { UINT32 screenmask = render_get_live_screens_mask(); mame_file *fp; int scrnum; /* write one snapshot per visible screen */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) if (screenmask & (1 << scrnum)) { mame_file_error filerr = mame_fopen_next(SEARCHPATH_SCREENSHOT, "png", &fp); if (filerr == FILERR_NONE) { video_screen_save_snapshot(fp, scrnum); mame_fclose(fp); } } }
static void dump_screenshot(int write_file) { mame_file_error filerr; mame_file *fp; char buf[128]; int is_blank = 0; int scrnum; UINT32 screenmask; if (write_file) { /* dump a screenshot */ snprintf(buf, sizeof(buf) / sizeof(buf[0]), (screenshot_num >= 0) ? "_%s_%d.png" : "_%s.png", current_testcase.name, screenshot_num); filerr = mame_fopen(SEARCHPATH_SCREENSHOT, buf, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &fp); if (filerr == FILERR_NONE) { screenmask = render_get_live_screens_mask(); if (screenmask != 0) { /* choose a screen */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) { if (screenmask & (1 << scrnum)) break; } video_screen_save_snapshot(fp, scrnum); report_message(MSG_INFO, "Saved screenshot as %s", buf); } else { report_message(MSG_FAILURE, "Could not save screenshot; no live screen"); } mame_fclose(fp); } else { /* report the error */ report_message(MSG_FAILURE, "Could not save screenshot; error #%d", filerr); } if (screenshot_num >= 0) screenshot_num++; } #if 0 /* check to see if bitmap is blank */ bitmap = scrbitmap[0]; is_blank = 1; color = bitmap->read(bitmap, 0, 0); for (y = 0; is_blank && (y < bitmap->height); y++) { for (x = 0; is_blank && (x < bitmap->width); x++) { if (bitmap->read(bitmap, x, y) != color) is_blank = 0; } } #endif if (is_blank) { had_failure = TRUE; report_message(MSG_FAILURE, "Screenshot is blank"); } }