1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
diff -Nru base0120/src/emu/inptport.c w0120/src/emu/inptport.c
--- base0120/src/emu/inptport.c 2007-09-29 15:57:09.000000000 +1200
+++ w0120/src/emu/inptport.c 2007-10-16 00:36:35.000000000 +1300
@@ -90,6 +90,7 @@
except that the accumulated deltas are not bounded, but rather wrap.
***************************************************************************/
+#define _USE_32BIT_TIME_T // VC2005 uses a 64-bit time_t structure by default
#include "osdepend.h"
#include "driver.h"
@@ -270,7 +271,7 @@
static input_port_entry *input_ports_default;
/* recorded speed read from an INP file */
-static double rec_speed;
+double rec_speed;
/* set to 1 if INP file being played is a standard MAME INP file */
static int no_extended_inp;
@@ -322,8 +323,6 @@
input_port_28_dword_r, input_port_29_dword_r, input_port_30_dword_r, input_port_31_dword_r
};
-
-
/***************************************************************************
COMMON SHARED STRINGS
***************************************************************************/
@@ -444,6 +443,8 @@
{ INPUT_STRING_None, "None" }
};
+/* set to 1 if INP file being played is a standard MAME INP file */
+int isnotext;
/***************************************************************************
@@ -1225,8 +1226,9 @@
static void setup_record(running_machine *machine)
{
const char *filename = options_get_string(mame_options(), OPTION_RECORD);
- inp_header inpheader;
+ //inp_header inpheader;
file_error filerr;
+ struct ext_header xheader;
/* if no file, nothing to do */
if (filename[0] == 0)
@@ -1236,10 +1238,16 @@
filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &machine->record_file);
assert_always(filerr == FILERR_NONE, "Failed to open file for recording");
+ /* disable cheats */
+ options_set_bool(mame_options(),OPTION_CHEAT,0,OPTION_PRIORITY_MAXIMUM);
+
/* create a header */
- memset(&inpheader, 0, sizeof(inpheader));
- strcpy(inpheader.name, machine->gamedrv->name);
- mame_fwrite(machine->record_file, &inpheader, sizeof(inpheader));
+ memset(&xheader, '\0', sizeof(struct ext_header));
+ strcpy(xheader.header, "XINP\0\0\0");
+ strcpy(xheader.shortname, machine->gamedrv->name);
+ strcpy(xheader.version, build_version);
+ xheader.starttime = (long)time(NULL);
+ mame_fwrite(Machine->record_file, &xheader, sizeof(struct ext_header));
}
@@ -1255,8 +1263,13 @@
/* close any playback or recording files */
if (machine->playback_file != NULL)
mame_fclose(machine->playback_file);
- if (machine->record_file != NULL)
- mame_fclose(machine->record_file);
+ if (machine->record_file != NULL)
+ {
+ long val = (long)time(NULL);
+ mame_fseek(machine->record_file,52,SEEK_SET);
+ mame_fwrite(machine->record_file,&val,sizeof(long));
+ mame_fclose(machine->record_file);
+ }
}
@@ -2789,7 +2802,7 @@
}
}
}
-
+ else // because re-recording is cheating
/* handle recording */
if (Machine->record_file != NULL)
{
@@ -2962,7 +2975,7 @@
/* note that analog ports are handled instantaneously at port read time */
}
}
-
+
#ifdef MESS
/* less MESS to MESSy things */
inputx_update();
@@ -2997,6 +3010,15 @@
update_playback_record(portnum, readinputport(portnum));
}
+ /* record speed */
+ if(Machine->record_file != NULL)
+ {
+ double speed = video_get_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 && !no_extended_inp)
{
diff -Nru base0120/src/emu/ui.c w0120/src/emu/ui.c
--- base0120/src/emu/ui.c 2007-09-07 04:42:07.000000000 +1200
+++ w0120/src/emu/ui.c 2007-10-16 00:30:13.000000000 +1300
@@ -321,7 +321,7 @@
int state;
/* disable everything if we are using -str */
- if (!first_time || (str > 0 && str < 60*5) || Machine->gamedrv == &driver_empty)
+ if (!first_time || (str > 0 && str < 60*5) || Machine->gamedrv == &driver_empty || Machine->record_file)
show_gameinfo = show_warnings = show_disclaimer = FALSE;
/* initialize the on-screen display system */
@@ -1283,7 +1283,7 @@
mame_schedule_soft_reset(Machine);
/* handle a request to display graphics/palette */
- if (input_ui_pressed(IPT_UI_SHOW_GFX))
+ if (input_ui_pressed(IPT_UI_SHOW_GFX) && !Machine->record_file)
{
if (!is_paused)
mame_pause(Machine, TRUE);
@@ -1291,14 +1291,14 @@
}
/* handle a save state request */
- if (input_ui_pressed(IPT_UI_SAVE_STATE))
+ if (input_ui_pressed(IPT_UI_SAVE_STATE) && !Machine->record_file)
{
mame_pause(Machine, TRUE);
return ui_set_handler(handler_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)
{
mame_pause(Machine, TRUE);
return ui_set_handler(handler_load_save, LOADSAVE_LOAD);
@@ -1309,7 +1309,7 @@
video_save_active_screen_snapshots(Machine);
/* 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 && (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT)))
@@ -1375,11 +1375,11 @@
}
/* toggle throttle? */
- if (input_ui_pressed(IPT_UI_THROTTLE))
+ if (input_ui_pressed(IPT_UI_THROTTLE) && !Machine->record_file)
video_set_throttle(!video_get_throttle());
/* check for fast forward */
- if (input_port_type_pressed(IPT_UI_FAST_FORWARD, 0))
+ if (input_port_type_pressed(IPT_UI_FAST_FORWARD, 0) && !Machine->record_file)
{
video_set_fastforward(TRUE);
ui_show_fps_temp(0.5);
diff -Nru base0120/src/emu/uimenu.c w0120/src/emu/uimenu.c
--- base0120/src/emu/uimenu.c 2007-09-23 09:27:43.000000000 +1200
+++ w0120/src/emu/uimenu.c 2007-10-16 00:32:08.000000000 +1300
@@ -631,7 +631,7 @@
*selected = num_items - 1;
/* pause enables/disables pause */
- if (input_ui_pressed(IPT_UI_PAUSE))
+ if (input_ui_pressed(IPT_UI_PAUSE) && !Machine->record_file)
mame_pause(Machine, !mame_is_paused(Machine));
return 0;
diff -Nru base0120/src/emu/video.c w0120/src/emu/video.c
--- base0120/src/emu/video.c 2007-09-29 03:06:28.000000000 +1200
+++ w0120/src/emu/video.c 2007-10-16 00:30:13.000000000 +1300
@@ -157,7 +157,9 @@
{ 0,1,1,1,1,1,1,1,1,1,1,1 }
};
-
+// speed recorded in INP file
+extern double rec_speed;
+extern int isnotext;
/***************************************************************************
FUNCTION PROTOTYPES
@@ -1216,6 +1218,10 @@
if (global.partial_updates_this_frame > 1)
dest += sprintf(dest, "\n%d partial updates", global.partial_updates_this_frame);
+ /* display recorded speed on playback */
+ if(Machine->playback_file != NULL && !isnotext)
+ dest += sprintf(dest,"\n Recorded speed %f%%", rec_speed);
+
/* return a pointer to the static buffer */
return buffer;
}
@@ -2193,6 +2199,10 @@
}
}
+double video_get_speed_percent(void)
+{
+ return global.speed_percent;
+}
/***************************************************************************
diff -Nru base0120/src/emu/video.h w0120/src/emu/video.h
--- base0120/src/emu/video.h 2007-08-31 04:45:52.000000000 +1200
+++ w0120/src/emu/video.h 2007-10-16 00:30:13.000000000 +1300
@@ -166,4 +166,6 @@
void video_crosshair_toggle(void);
+double video_get_speed_percent(void);
+
#endif /* __VIDEO_H__ */
|