Record-Replay
version 1 by Al Golden
Version 1 of Record-Replay by Al Golden begins here.
Include (-
Verb meta 'recording' * -> CommandsOn
* 'on' -> CommandsOn
* 'off' -> CommandsOff;
Verb meta 'replay' * -> CommandsRead;
#ifdef TARGET_ZCODE;
[ CommandsOnSub;
@output_stream 4;
xcommsdir = 1;
"[Command recording on.]";
];
[ CommandsOffSub;
if (xcommsdir == 1) @output_stream -4;
xcommsdir = 0;
"[Command recording off.]";
];
[ CommandsReadSub;
@input_stream 1;
xcommsdir = 2;
"[Replaying commands.]^^";
];
#ifnot; ! TARGET_GLULX
[ CommandsOnSub fref;
if (gg_commandstr ~= 0) {
if (gg_command_reading) "[Commands are currently replaying.]";
else "[Command recording already on.]";
}
! fileref_create_by_prompt
fref = glk($0062, $103, $01, 0);
if (fref == 0) "[Command recording failed.]";
gg_command_reading = false;
! stream_open_file
gg_commandstr = glk($0042, fref, $01, GG_COMMANDWSTR_ROCK);
glk($0063, fref); ! fileref_destroy
if (gg_commandstr == 0) return L__M(##CommandsOn, 4);
"[Command recording on.]";
];
[ CommandsOffSub;
if (gg_commandstr == 0) "[Command recording already off.]";
if (gg_command_reading) "[Command replay complete.]";
glk($0044, gg_commandstr, 0); ! stream_close
gg_commandstr = 0;
gg_command_reading = false;
"[Command recording off.]";
];
[ CommandsReadSub fref;
if (gg_commandstr ~= 0) {
if (gg_command_reading) "[Commands are already replaying.]";
else "[Command replay failed. Command recording is on.]";
}
! fileref_create_by_prompt
fref = glk($0062, $103, $02, 0);
if (fref == 0) "[Command replay failed.]";
gg_command_reading = true;
! stream_open_file
gg_commandstr = glk($0042, fref, $02, GG_COMMANDRSTR_ROCK);
glk($0063, fref); ! fileref_destroy
if (gg_commandstr == 0) return L__M(##CommandsRead, 4);
"[Command replay complete.]";
];
#endif; ! TARGET_
-).
Record-Replay ends here.