diff -Nru base0107/src/inptport.c w0107/src/inptport.c --- base0107/src/inptport.c 2006-07-03 16:03:59.000000000 +1200 +++ w0107/src/inptport.c 2006-07-24 17:23:13.000000000 +1200 @@ -256,6 +256,15 @@ /* original input_ports without modifications */ input_port_entry *input_ports_default; +/* recorded speed read from an INP file */ +double rec_speed; + +/* set to 1 if INP file being played is a standard MAME INP file */ +int isnotext; + +/* for average speed calculations */ +int framecount; +double totalspeed; /************************************* @@ -2099,9 +2108,16 @@ { mame_fclose(Machine->playback_file); Machine->playback_file = NULL; + if(isnotext) + ui_popup("End of playback"); + else + { + ui_popup("End of playback - %i frames - Average speed %f%%",framecount,(double)totalspeed/framecount); + printf("End of playback - %i frames - Average speed %f%%\n",framecount,(double)totalspeed/framecount); + } } } - + else // because re-recording is cheating... /* handle recording */ if (Machine->record_file != NULL) { @@ -2288,6 +2304,26 @@ else update_playback_record(portnum, readinputport(portnum)); } + + /* record speed */ + if(Machine->record_file != NULL) + { + const performance_info *pinfo = mame_get_performance_info(); + double speed = pinfo->game_speed_percent; + long marker = 0x00ABCDEF; // end of frame marker + mame_fwrite(Machine->record_file,&speed,sizeof(double)); + mame_fwrite(Machine->record_file,&marker,sizeof(long)); + } + + /* store speed read from INP file, if extended INP */ + if(Machine->playback_file != NULL && !isnotext) + { + long dummy; + mame_fread(Machine->playback_file,&rec_speed,sizeof(double)); + mame_fread(Machine->playback_file,&dummy,sizeof(long)); + framecount++; + totalspeed += rec_speed; + } profiler_mark(PROFILER_END); } diff -Nru base0107/src/usrintrf.c w0107/src/usrintrf.c --- base0107/src/usrintrf.c 2006-07-24 14:01:45.000000000 +1200 +++ w0107/src/usrintrf.c 2006-07-24 17:23:13.000000000 +1200 @@ -1467,14 +1467,14 @@ /* handle a request to display graphics/palette */ #ifndef NEW_RENDER - if (input_ui_pressed(IPT_UI_SHOW_GFX)) + if (input_ui_pressed(IPT_UI_SHOW_GFX) && !Machine->record_file) { osd_sound_enable(0); showcharset(bitmap); osd_sound_enable(1); } #else - if (input_ui_pressed(IPT_UI_SHOW_GFX)) + if (input_ui_pressed(IPT_UI_SHOW_GFX) && !Machine->record_file) { if (!is_paused) mame_pause(TRUE); @@ -1483,11 +1483,11 @@ #endif /* handle a save state request */ - if (input_ui_pressed(IPT_UI_SAVE_STATE)) + if (input_ui_pressed(IPT_UI_SAVE_STATE) && !Machine->record_file) initiate_load_save(LOADSAVE_SAVE); /* handle a load state request */ - if (input_ui_pressed(IPT_UI_LOAD_STATE)) + if (input_ui_pressed(IPT_UI_LOAD_STATE) && !Machine->record_file) initiate_load_save(LOADSAVE_LOAD); /* handle a save snapshot request */ @@ -1495,7 +1495,7 @@ snapshot_save_all_screens(); /* toggle pause */ - if (input_ui_pressed(IPT_UI_PAUSE)) + if (input_ui_pressed(IPT_UI_PAUSE) && !Machine->record_file) { /* with a shift key, it is single step */ if (is_paused && (code_pressed(KEYCODE_LSHIFT) || code_pressed(KEYCODE_RSHIFT))) diff -Nru base0107/src/windows/config.c w0107/src/windows/config.c --- base0107/src/windows/config.c 2006-07-21 17:22:04.000000000 +1200 +++ w0107/src/windows/config.c 2006-07-24 17:25:53.000000000 +1200 @@ -9,6 +9,7 @@ // standard windows headers #define WIN32_LEAN_AND_MEAN +#define _USE_32BIT_TIME_T // VC2005 uses a 64-bit time_t structure by default #include // standard C headers @@ -76,7 +77,15 @@ extern int audio_latency; extern const char *wavwrite; - +struct ext_header +{ + char header[7]; // must be "XINP" followed by NULLs + char shortname[9]; // game shortname + char version[32]; // MAME version string + long starttime; // approximate INP start time + char dummy[32]; // for possible future expansion +}; +extern int isnotext; //============================================================ // PROTOTYPES @@ -473,7 +482,12 @@ options.playback = NULL; if (options.record != NULL) + { + long val = (long)time(NULL); + mame_fseek(options.record,52,SEEK_SET); + mame_fwrite(options.record,&val,sizeof(long)); mame_fclose(options.record); + } options.record = NULL; if (options.language_file != NULL) @@ -763,25 +777,54 @@ static void setup_playback(const char *filename, const game_driver *driver) { inp_header inp_header; + struct ext_header xheader; + char check[7]; // open the playback file options.playback = mame_fopen(filename, 0, FILETYPE_INPUTLOG, 0); assert_always(options.playback != NULL, "Failed to open file for playback"); - // read playback header - mame_fread(options.playback, &inp_header, sizeof(inp_header)); - - // if the first byte is not alphanumeric, it's an old INP file with no header - if (!isalnum(inp_header.name[0])) - mame_fseek(options.playback, 0, SEEK_SET); - - // else verify the header against the current game - else if (strcmp(driver->name, inp_header.name) != 0) - fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", inp_header.name, driver->name); + // read first four bytes to check INP type + mame_fread(options.playback, check, 7); + mame_fseek(options.playback, 0, SEEK_SET); + if(strncmp(check,"XINP\0\0\0",7) != 0) + { + isnotext = 1; + printf("This INP file is not an extended INP file, extra info not available\n"); + + // read playback header + mame_fread(options.playback, &inp_header, sizeof(inp_header)); + + // if the first byte is not alphanumeric, it's an old INP file with no header + if (!isalnum(inp_header.name[0])) + mame_fseek(options.playback, 0, SEEK_SET); + + // else verify the header against the current game + else if (strcmp(driver->name, inp_header.name) != 0) + fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", inp_header.name, driver->name); - // otherwise, print a message indicating what's happening + // otherwise, print a message indicating what's happening + else + printf("Playing back previously recorded " GAMENOUN " %s\n", driver->name); + } else - printf("Playing back previously recorded " GAMENOUN " %s\n", driver->name); + { + isnotext = 0; + printf("Extended INP file info:\n"); + + // read header + mame_fread(options.playback, &xheader, sizeof(struct ext_header)); + + // output info to console + printf("Version string: %s\n",xheader.version); + printf("Start time: %s\n",ctime(&xheader.starttime)); + + // verify header against current game + if (strcmp(driver->name, xheader.shortname) != 0) + fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", inp_header.name, driver->name); + else + printf("Playing back previously recorded " GAMENOUN " %s\n", driver->name); + } } @@ -792,16 +835,23 @@ static void setup_record(const char *filename, const game_driver *driver) { - inp_header inp_header; +// inp_header inp_header; + struct ext_header xheader; + + // force game info screens to be skipped on recording, so that the recorded start time is accurate + options.skip_warnings = options.skip_gameinfo = options.skip_disclaimer = TRUE; // open the record file options.record = mame_fopen(filename, 0, FILETYPE_INPUTLOG, 1); assert_always(options.record != NULL, "Failed to open file for recording"); // create a header - memset(&inp_header, '\0', sizeof(inp_header)); - strcpy(inp_header.name, driver->name); - mame_fwrite(options.record, &inp_header, sizeof(inp_header)); + memset(&xheader, '\0', sizeof(struct ext_header)); + strcpy(xheader.header, "XINP\0\0\0"); + strcpy(xheader.shortname, driver->name); + strcpy(xheader.version, build_version); + xheader.starttime = (long)time(NULL); + mame_fwrite(options.record, &xheader, sizeof(struct ext_header)); } diff -Nru base0107/src/windows/video.c w0107/src/windows/video.c --- base0107/src/windows/video.c 2006-07-17 05:37:46.000000000 +1200 +++ w0107/src/windows/video.c 2006-07-24 17:23:13.000000000 +1200 @@ -59,7 +59,9 @@ // from wind3dfx.c extern struct rc_option win_d3d_opts[]; - +// speed recorded in INP file +extern double rec_speed; +extern int isnotext; //============================================================ // CONSTANTS @@ -143,8 +145,6 @@ {12,0,0,0,0,0,0,0,0,0,0,0 } }; - - //============================================================ // PROTOTYPES //============================================================ @@ -429,6 +429,8 @@ dest += sprintf(dest, "\n %d vector updates", performance->vector_updates_last_second); else if (performance->partial_updates_this_frame > 1) dest += sprintf(dest, "\n %d partial updates", performance->partial_updates_this_frame); + if(Machine->playback_file != NULL && !isnotext) + dest += sprintf(dest,"\n Recorded speed %f%%", rec_speed); } /* return a pointer to the static buffer */ @@ -790,7 +792,7 @@ } // toggle throttle? - if (input_ui_pressed(IPT_UI_THROTTLE)) + if (input_ui_pressed(IPT_UI_THROTTLE) && !Machine->record_file) { video_config.throttle = !video_config.throttle;