diff -Nru base0106u10/src/inptport.c w0106u10/src/inptport.c --- base0106u10/src/inptport.c 2006-07-08 13:02:59.000000000 +1200 +++ w0106u10/src/inptport.c 2006-07-10 10:43:32.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 base0106u10/src/windows/config.c w0106u10/src/windows/config.c --- base0106u10/src/windows/config.c 2006-07-08 13:02:55.000000000 +1200 +++ w0106u10/src/windows/config.c 2006-07-09 22:47:38.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 @@ -79,7 +80,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 @@ -365,7 +374,13 @@ options.playback = NULL; if (options.record != NULL) + { + long val = (long)time(NULL); + // Write refresh rate - should be available by now + 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) @@ -667,25 +682,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); + } } @@ -697,15 +741,22 @@ static void setup_record(const char *filename, const game_driver *driver) { 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 base0106u10/src/windows/video.c w0106u10/src/windows/video.c --- base0106u10/src/windows/video.c 2006-07-08 13:02:55.000000000 +1200 +++ w0106u10/src/windows/video.c 2006-07-10 10:38:39.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 @@ -141,8 +143,6 @@ {12,0,0,0,0,0,0,0,0,0,0,0 } }; - - //============================================================ // PROTOTYPES //============================================================ @@ -503,6 +503,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 */