void osd_update_video_and_audio(mame_display *display) { int i; double time_limit; double current_time; int cpunum; /* if the visible area has changed, update it */ if (display->changed_flags & GAME_VISIBLE_AREA_CHANGED) { ui_set_visible_area(display->game_visible_area.min_x, display->game_visible_area.min_y, display->game_visible_area.max_x, display->game_visible_area.max_y); } /* is this the first update? if so, eat it */ if (!seen_first_update) { seen_first_update = TRUE; return; } /* if we have already aborted or completed, our work is done */ if ((state == STATE_ABORTED) || (state == STATE_DONE)) return; /* have we hit the time limit? */ current_time = timer_get_time(); time_limit = (current_testcase.time_limit != 0.0) ? current_testcase.time_limit : TIME_IN_SEC(600); if (current_time > time_limit) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Time limit of %.2f seconds exceeded", time_limit); return; } /* update the runtime hash */ if (0) { for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) { runtime_hash *= 57; runtime_hash ^= cpunum_get_reg(cpunum, REG_PC); /* TODO - Add more registers? */ } } for (i = 0; i < sizeof(commands) / sizeof(commands[i]); i++) { if (current_command->command_type == commands[i].command_type) { commands[i].proc(); break; } } /* if we are ready for the next command, advance to it */ if (state == STATE_READY) { /* if we are at the end, and we are dumping screenshots, and we didn't * just dump a screenshot, dump one now */ if ((test_flags & MESSTEST_ALWAYS_DUMP_SCREENSHOT) && (current_command[0].command_type != MESSTEST_COMMAND_SCREENSHOT) && (current_command[1].command_type == MESSTEST_COMMAND_END)) { dump_screenshot(TRUE); } current_command++; } }
static void command_screenshot(void) { dump_screenshot(TRUE); }
static void command_checkblank(void) { dump_screenshot(FALSE); }
// Function to read from player; will be called when GTK is idle gboolean player_read_func(gpointer* arg) { int i; static int count=0; pose_t robot_pose; gui_data_t* gui_data = (gui_data_t*)arg; static struct timeval lastdump = {0, 0}; static struct timeval lastmapupdate = {0, 0}; static player_pose2d_t lastwaypt[MAX_NUM_ROBOTS]; static player_pose2d_t lastgoal[MAX_NUM_ROBOTS]; struct timeval curr; double diff; gboolean onmap; int peek; if(!count) { memset(lastwaypt,0,sizeof(lastwaypt)); memset(lastgoal,0,sizeof(lastgoal)); } // update map if(mapupdatefreq) { gettimeofday(&curr,NULL); diff = (curr.tv_sec + curr.tv_usec/1e6) - (lastmapupdate.tv_sec + lastmapupdate.tv_usec/1e6); if(diff >= 1.0/mapupdatefreq) { update_map(gui_data); lastmapupdate = curr; } } peek = playerc_mclient_peek(gui_data->mclient,10); if(peek < 0) { //fprintf(stderr, "Error on peek\n"); //gtk_main_quit(); return(TRUE); } else if(peek == 0) return(TRUE); // read new data if(playerc_mclient_read(gui_data->mclient,-1) <= 0) { //fprintf(stderr, "Error on read\n"); //gtk_main_quit(); return(TRUE); } for(i=0;i<gui_data->num_robots;i++) { int have_robot = 0; // Try to get the pose from the planner if(gui_data->planners[i] && gui_data->planners[i]->info.fresh) { robot_pose.px = gui_data->planners[i]->px; robot_pose.py = gui_data->planners[i]->py; robot_pose.pa = gui_data->planners[i]->pa; have_robot = 1; } // Fall back on getting the pose from the localizer else if(gui_data->localizes[i] && gui_data->localizes[i]->info.fresh && gui_data->localizes[i]->hypoth_count) { robot_pose.px = gui_data->localizes[i]->hypoths[0].mean.px; robot_pose.py = gui_data->localizes[i]->hypoths[0].mean.py; robot_pose.pa = gui_data->localizes[i]->hypoths[0].mean.pa; have_robot = 1; } // If we got the robot's pose from somewhere if(have_robot) { // is the robot localized within the map? onmap = (robot_pose.px >= gui_data->mapdev->origin[0]) && (robot_pose.px < (gui_data->mapdev->origin[0] + (gui_data->mapdev->width * gui_data->mapdev->resolution))) && (robot_pose.py >= gui_data->mapdev->origin[1]) && (robot_pose.py < (gui_data->mapdev->origin[1] + (gui_data->mapdev->height * gui_data->mapdev->resolution))); // if it's off the map, put it in the middle if(!onmap) robot_pose.px = robot_pose.py = 0.0; // don't draw the new pose if the user is in the middle of moving the // robot if(!robot_moving_p || (robot_moving_idx != i)) { // also don't draw it if the pose hasn't changed since last time if((gui_data->robot_poses[i].px != robot_pose.px) || (gui_data->robot_poses[i].py != robot_pose.py) || (gui_data->robot_poses[i].pa != robot_pose.pa)) { move_item(gui_data->robot_items[i],robot_pose,1); // If we have a localizer, retrieve and draw particle cloud if(showparticlesp && gui_data->localizes[i]) { playerc_localize_get_particles(gui_data->localizes[i]); draw_particles(gui_data,i); } // If we have a localizer retrive and draw uncertainty ellipsis if(showuncertaintyp && gui_data->localizes[i]) { draw_uncertainty(gui_data,i); } } } // regardless, store this pose for comparison on next iteration gui_data->robot_poses[i] = robot_pose; // If we have a planner if(gui_data->planners[i]) { // If the current goal or waypoint changed, get the whole list // of waypoints again if((lastwaypt[i].px != gui_data->planners[i]->wx) || (lastwaypt[i].py != gui_data->planners[i]->wy) || (lastwaypt[i].pa != gui_data->planners[i]->wa) || (lastgoal[i].px != gui_data->planners[i]->gx) || (lastgoal[i].py != gui_data->planners[i]->gy) || (lastgoal[i].pa != gui_data->planners[i]->ga)) { if(get_waypoints) { if(playerc_planner_get_waypoints(gui_data->planners[i]) < 0) { fprintf(stderr, "error while getting waypoints for robot %d\n", i); } else { draw_waypoints(gui_data,i); } } else draw_goal(gui_data,i); // Cache goal and waypoint info lastwaypt[i].px = gui_data->planners[i]->wx; lastwaypt[i].py = gui_data->planners[i]->wy; lastwaypt[i].pa = gui_data->planners[i]->wa; lastgoal[i].px = gui_data->planners[i]->gx; lastgoal[i].py = gui_data->planners[i]->gy; lastgoal[i].pa = gui_data->planners[i]->ga; } } // Reset freshness flag(s) if(gui_data->planners[i]) gui_data->planners[i]->info.fresh = 0; if(gui_data->localizes[i]) gui_data->localizes[i]->info.fresh = 0; } // raise the robot's canvas item, so that the user can select it if(gui_data->localizes[i] || gui_data->planners[i]) { gnome_canvas_item_raise_to_top(gui_data->robot_items[i]); } } // dump screenshot if(dumpp) { gettimeofday(&curr,NULL); diff = (curr.tv_sec + curr.tv_usec/1e6) - (lastdump.tv_sec + lastdump.tv_usec/1e6); if(diff >= 1.0/dumpfreq) { dump_screenshot(gui_data); lastdump = curr; } } count++; return(TRUE); }
static void command_checkblank(running_machine &machine) { dump_screenshot(machine, FALSE); }
static void command_screenshot(running_machine &machine) { dump_screenshot(machine, TRUE); }
void osd_update(running_machine &machine, int skip_redraw) { int i; attotime time_limit; attotime current_time; target->get_primitives(); /* don't do anything if we are initializing! */ switch(machine.phase()) { case MACHINE_PHASE_PREINIT: case MACHINE_PHASE_INIT: case MACHINE_PHASE_RESET: return; default: break; } /* if we have already aborted or completed, our work is done */ if ((state == STATE_ABORTED) || (state == STATE_DONE)) { machine.schedule_exit(); return; } /* have we hit the time limit? */ current_time = machine.time(); time_limit = (current_testcase.time_limit != attotime::zero) ? current_testcase.time_limit : attotime::from_seconds(600); if (current_time > time_limit) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Time limit of %s attoseconds exceeded", time_limit.as_string(9)); return; } for (i = 0; i < ARRAY_LENGTH(commands); i++) { if (current_command->command_type == commands[i].command_type) { commands[i].proc(machine); break; } } /* if we are ready for the next command, advance to it */ if (state == STATE_READY) { /* if we are at the end, and we are dumping screenshots, and we didn't * just dump a screenshot, dump one now */ if ((test_flags & MESSTEST_ALWAYS_DUMP_SCREENSHOT) && (current_command[0].command_type != MESSTEST_COMMAND_SCREENSHOT) && (current_command[1].command_type == MESSTEST_COMMAND_END)) { dump_screenshot(machine, TRUE); } current_command++; } }
int osd_update(mame_time emutime) { int i; double time_limit; double current_time; int cpunum; render_target_get_primitives(target); /* is this the first update? if so, eat it */ if (!seen_first_update) { seen_first_update = TRUE; goto done; } /* if we have already aborted or completed, our work is done */ if ((state == STATE_ABORTED) || (state == STATE_DONE)) { mame_schedule_exit(Machine); goto done; } /* have we hit the time limit? */ current_time = timer_get_time(); time_limit = (current_testcase.time_limit != 0.0) ? current_testcase.time_limit : TIME_IN_SEC(600); if (current_time > time_limit) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Time limit of %.2f seconds exceeded", time_limit); goto done; } /* update the runtime hash */ if (0) { for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) { runtime_hash *= 57; runtime_hash ^= cpunum_get_reg(cpunum, REG_PC); /* TODO - Add more registers? */ } } for (i = 0; i < sizeof(commands) / sizeof(commands[i]); i++) { if (current_command->command_type == commands[i].command_type) { commands[i].proc(); break; } } /* if we are ready for the next command, advance to it */ if (state == STATE_READY) { /* if we are at the end, and we are dumping screenshots, and we didn't * just dump a screenshot, dump one now */ if ((test_flags & MESSTEST_ALWAYS_DUMP_SCREENSHOT) && (current_command[0].command_type != MESSTEST_COMMAND_SCREENSHOT) && (current_command[1].command_type == MESSTEST_COMMAND_END)) { dump_screenshot(TRUE); } current_command++; } done: return FALSE; }