118
118
while (event_image_list_ptr->next != NULL) {
119
119
if (strcmp(filename, event_image_list_ptr->next->orig_filename) == 0) {
120
120
if (mapped_name != NULL) {
122
*mapped_name = lib_stralloc(event_image_list_ptr->next->mapped_filename);
122
if (event_image_list_ptr->next->mapped_filename != NULL) {
123
*mapped_name = lib_stralloc(event_image_list_ptr->next->mapped_filename);
124
128
event_image_list_ptr->next->mapped_filename = lib_stralloc(*mapped_name);
129
133
event_image_list_ptr = event_image_list_ptr->next;
149
153
char *event_data;
150
154
unsigned int size;
155
char *strdir, *strfile;
152
157
list->current->type = EVENT_ATTACHIMAGE;
153
158
list->current->clk = maincpu_clk;
154
159
list->current->next
155
160
= (event_list_t *)lib_calloc(1, sizeof(event_list_t));
157
size = strlen(filename) + 3;
162
util_fname_split(filename, &strdir, &strfile);
164
if (event_image_include)
165
size = strlen(filename) + 3;
167
size = strlen(strfile) + sizeof(long) + 4;
159
169
event_data = lib_malloc(size);
160
170
event_data[0] = unit;
161
171
event_data[1] = read_only;
162
strcpy(&event_data[2], filename);
164
if (event_image_append(filename, NULL, 0) == 1) {
173
if (event_image_include) {
174
strcpy(&event_data[2], filename);
175
if (event_image_append(filename, NULL, 0) == 1) {
168
fd = fopen(filename, MODE_READ);
171
file_len = util_file_length(fd);
172
event_data = lib_realloc(event_data, size + file_len);
174
if (fread(&event_data[size], file_len, 1, fd) != 1)
175
log_error(event_log, "Cannot load image file %s", filename);
179
log_error(event_log, "Cannot open image file %s", filename);
179
fd = fopen(filename, MODE_READ);
182
file_len = util_file_length(fd);
183
event_data = lib_realloc(event_data, size + file_len);
185
if (fread(&event_data[size], file_len, 1, fd) != 1)
186
log_error(event_log, "Cannot load image file %s", filename);
190
log_error(event_log, "Cannot open image file %s", filename);
195
strcpy(&event_data[2], "");
196
*(unsigned long *)(event_data + 3) = crc32_file(filename);
197
strcpy(&event_data[3 + sizeof(long)], strfile);
184
203
list->current->size = size;
185
204
list->current->data = event_data;
186
205
list->current = list->current->next;
201
220
unsigned int unit, read_only;
202
221
char *orig_filename, *filename = NULL;
223
unsigned long crc_to_attach;
205
225
unit = (unsigned int)((char*)data)[0];
206
226
read_only = (unsigned int)((char*)data)[1];
207
227
orig_filename = &((char*)data)[2];
208
file_len = size - strlen(orig_filename) - 3;
213
fd = archdep_mkstemp_fd(&filename, MODE_WRITE);
216
#ifdef HAS_TRANSLATION
217
ui_error(translate_text(IDGS_CANNOT_CREATE_IMAGE), filename);
219
ui_error(_("Cannot create image file!"));
224
if (fwrite((char*)data + strlen(orig_filename) + 3, file_len, 1, fd) != 1) {
225
#ifdef HAS_TRANSLATION
226
ui_error(translate_text(IDGS_CANNOT_WRITE_IMAGE_FILE_S), filename);
228
ui_error(_("Cannot write image file %s"), filename);
234
event_image_append(orig_filename, &filename, 1);
229
if (*orig_filename == 0) {
230
/* no image attached */
231
orig_filename = (char *) data + 3 + sizeof(long);
236
233
if (event_image_append(orig_filename, &filename, 0) != 0) {
237
#ifdef HAS_TRANSLATION
238
ui_error(translate_text(IDGS_CANNOT_FIND_MAPPED_NAME_S), orig_filename);
240
ui_error(_("Cannot find mapped name for %s"), orig_filename);
234
crc_to_attach = *(unsigned long *)(((char *)data)+3);
236
filename = ui_get_file("Please attach image %s (CRC32 checksum 0x%x)",
237
(char *) data + 3 + sizeof(long), crc_to_attach);
238
} while (filename != NULL && crc_to_attach != crc32_file(filename));
239
if (filename == NULL) {
240
ui_error("Image wasn't attached. Playback will probably get out of sync.");
243
event_image_append(orig_filename, &filename, 1);
246
file_len = size - strlen(orig_filename) - 3;
251
fd = archdep_mkstemp_fd(&filename, MODE_WRITE);
254
ui_error(translate_text(IDGS_CANNOT_CREATE_IMAGE), filename);
258
if (fwrite((char*)data + strlen(orig_filename) + 3, file_len, 1, fd) != 1) {
259
ui_error(translate_text(IDGS_CANNOT_WRITE_IMAGE_FILE_S), filename);
264
event_image_append(orig_filename, &filename, 1);
266
if (event_image_append(orig_filename, &filename, 0) != 0) {
267
ui_error(translate_text(IDGS_CANNOT_FIND_MAPPED_NAME_S), orig_filename);
246
272
/* now filename holds the name to attach */
247
273
/* FIXME: read_only isn't handled for tape */
633
655
case EVENT_START_MODE_FILE_LOAD:
634
656
if (machine_read_snapshot(
635
657
event_snapshot_path(event_end_snapshot), 1) < 0) {
636
#ifdef HAS_TRANSLATION
637
658
ui_error(translate_text(IDGS_ERROR_READING_END_SNAP_S),
639
ui_error(_("Error reading end snapshot file %s."),
641
659
event_snapshot_path(event_end_snapshot));
702
720
if (machine_write_snapshot(
703
721
event_snapshot_path(event_end_snapshot), 1, 1, 1) < 0) {
704
#ifdef HAS_TRANSLATION
705
722
ui_error(translate_text(IDGS_CANT_CREATE_END_SNAP_S),
707
ui_error(_("Could not create end snapshot file %s."),
709
723
event_snapshot_path(event_end_snapshot));
769
783
event_snapshot_path(event_end_snapshot), &major, &minor, machine_name);
772
#ifdef HAS_TRANSLATION
773
786
ui_error(translate_text(IDGS_CANT_OPEN_END_SNAP_S),
775
ui_error(_("Could not open end snapshot file %s."),
777
787
event_snapshot_path(event_end_snapshot));
778
788
ui_display_playback(0, NULL);
808
814
event_snapshot_path(event_start_snapshot), 0) < 0)
810
816
char *st = lib_stralloc(event_snapshot_path((char *)(&data[1])));
811
#ifdef HAS_TRANSLATION
812
817
ui_error(translate_text(IDGS_ERROR_READING_START_SNAP_TRIED),
814
ui_error(_("Error reading start snapshot file. Tried %s and %s"),
816
818
st, event_snapshot_path(event_start_snapshot));
818
820
ui_display_playback(0, NULL);
896
894
if (machine_write_snapshot(
897
895
event_snapshot_path(event_end_snapshot), 1, 1, 1) < 0) {
898
#ifdef HAS_TRANSLATION
899
896
ui_error(translate_text(IDGS_CANT_CREATE_END_SNAP_S),
901
ui_error(_("Could not create end snapshot file %s."),
903
897
event_snapshot_path(event_end_snapshot));
905
899
milestone_timestamp_alarm = next_timestamp_clk;
1187
1183
static const resource_int_t resources_int[] = {
1188
1184
{ "EventStartMode", EVENT_START_MODE_FILE_SAVE, RES_EVENT_NO, NULL,
1189
1185
&event_start_mode, set_event_start_mode, NULL },
1186
{ "EventImageInclude", 1, RES_EVENT_NO, NULL,
1187
&event_image_include, set_event_image_include, NULL },
1215
1213
return event_playback_start();
1218
#ifdef HAS_TRANSLATION
1219
static const cmdline_option_t cmdline_options[] = {
1220
{ "-playback", CALL_FUNCTION, 0, cmdline_help, NULL, NULL, NULL,
1221
0, IDCLS_PLAYBACK_RECORDED_EVENTS },
1225
static const cmdline_option_t cmdline_options[] = {
1226
{ "-playback", CALL_FUNCTION, 0, cmdline_help, NULL, NULL, NULL,
1227
NULL, N_("Playback recorded events") },
1216
static const cmdline_option_t cmdline_options[] = {
1217
{ "-playback", CALL_FUNCTION, 0,
1218
cmdline_help, NULL, NULL, NULL,
1219
USE_PARAM_STRING, USE_DESCRIPTION_ID,
1220
IDCLS_UNUSED, IDCLS_PLAYBACK_RECORDED_EVENTS,
1232
1225
int event_cmdline_options_init(void)