// tape control functions
// ============================================================================
+void TapeSetDateFromIsoDateString(char *date)
+{
+ int i;
+
+ // check ISO date string for correct length
+ if (strlen(date) != 10)
+ return;
+
+ // check ISO date string for correct format
+ for (i = 0; i < strlen(date); i++)
+ if (((i != 4 && i != 7) && (date[i] < '0' || date[i] > '9')) ||
+ ((i == 4 || i == 7) && (date[i] != '-')))
+ return;
+
+ int yy = (date[2] - '0') * 10 + (date[3] - '0');
+ int mm = (date[5] - '0') * 10 + (date[6] - '0');
+ int dd = (date[8] - '0') * 10 + (date[9] - '0');
+
+ if (mm < 1 || mm > 12 || dd < 1 || dd > 31)
+ return;
+
+ tape.date = 10000 * yy + 100 * (mm - 1) + dd;
+}
+
void TapeSetDateFromEpochSeconds(time_t epoch_seconds)
{
struct tm *lt = localtime(&epoch_seconds);
void TapeHaltRecording(void)
{
- tape.counter++;
+ // only advance tape counter if any input events have been recorded
+ if (tape.pos[tape.counter].delay > 0)
+ tape.counter++;
// initialize delay for next tape entry (to be able to continue recording)
if (tape.counter < MAX_TAPE_LEN)
tape.pos[tape.counter].delay++;
}
+ tape.changed = TRUE;
+
return TRUE;
}
ModifyPauseButtons();
}
+
+ // stop tape when leaving auto-pause after completely replaying tape
+ if (tape.playing && !tape.pausing && tape.counter >= tape.length)
+ TapeStop();
}
void TapeStartPlaying(void)
void TapeQuickSave(void)
{
- if (game_status == GAME_MODE_MAIN)
+ if (game_status != GAME_MODE_PLAYING)
{
- Request("No game that can be saved!", REQ_CONFIRM);
+ Request("No game that could be saved!", REQ_CONFIRM);
return;
}
- if (game_status != GAME_MODE_PLAYING)
- return;
-
if (!tape.recording)
{
- Request("No recording that can be saved!", REQ_CONFIRM);
+ Request("No recording that could be saved!", REQ_CONFIRM);
return;
}
- if (tape.recording)
- TapeHaltRecording(); // prepare tape for saving on-the-fly
+ TapeHaltRecording(); // prepare tape for saving on-the-fly
if (TAPE_IS_EMPTY(tape))
{
- Request("No tape that can be saved!", REQ_CONFIRM);
+ Request("No tape that could be saved!", REQ_CONFIRM);
return;
}