Added rzx edit

This commit is contained in:
fabio.olimpieri 2015-03-22 20:43:56 +00:00
parent 88631eb3ee
commit 0022e8f106
3 changed files with 63 additions and 4 deletions

View File

@ -194,7 +194,7 @@ static const char *microdrive_messages[] = {
static const char *tools_messages[] = {
/*00*/ "Recording (RZX)",
/*01*/ "^|Record|Play|Stop|Bookmark|Browser",
/*01*/ "^|Record|Play|Stop|Bookmark|Brows|Edit",
/*02*/ "Screen shot",
/*03*/ "^|Save1|Save2|Load|Delete",
/*04*/ "Files source",
@ -1878,7 +1878,7 @@ static int manage_file(int which)
return retorno;
}
static int load_rzx()
static int load_rzx(int edit)
{
int retorno;
@ -1890,7 +1890,8 @@ static int load_rzx()
if (!(ext_matches(filename, ".rzx")|ext_matches(filename, ".RZX"))) {free((void *)filename); return -1;}
retorno=rzx_playback(filename);
if (edit) retorno=rzx_edit(filename);
else retorno=rzx_playback(filename);
if (retorno!=RZX_OK) //RZX_OK = 0
{
@ -2016,7 +2017,7 @@ static int do_rzx(int which)
ordenador.icount = 0;
ordenador.total_frames_rzx=0;
ordenador.frames_count_rzx=1;
retorno2 = load_rzx();
retorno2 = load_rzx(0);
if (retorno2) break; //Error or no file
retorno2 = rzx_update(&ordenador.maxicount); //The first frame does not generate interrupt
if (retorno2 == RZX_FINISHED) {printf("RZX: Playing finished at fisrt frame\n"); break;}
@ -2046,6 +2047,20 @@ static int do_rzx(int which)
rzx_browser();
retorno = -2;
break;
case 5: //edit
ordenador.playing_rzx=0;
ordenador.recording_rzx=0;
rzx_close();
ordenador.icount = 0;
ordenador.total_frames_rzx=0;
ordenador.frames_count_rzx=1;
retorno2 = load_rzx(1); //Load and edit
if (retorno2) break; //Error or no file
ordenador.playing_rzx=0;
ordenador.recording_rzx=1;
rzx_browser();
retorno = -2;
break;
default:
break;
}

View File

@ -673,6 +673,49 @@ int rzx_record(const char *filename)
return RZX_OK;
}
int rzx_edit(const char *filename)
{
if(filename==0) return RZX_INVALID;
if(inputbuffer==NULL)
{
inputbuffer=(rzx_u8*)malloc(RZXINPUTMAX);
if(inputbuffer==NULL) return RZX_NOMEMORY;
memset(inputbuffer,0,RZXINPUTMAX);
}
if(oldbuffer==NULL)
{
oldbuffer=(rzx_u8*)malloc(RZXINPUTMAX);
if(oldbuffer==NULL) return RZX_NOMEMORY;
memset(oldbuffer,0,RZXINPUTMAX);
}
rzx_status&=~RZX_IRB;
rzxfile=fopen(filename,"r+b");
if(rzxfile==NULL) return RZX_NOTFOUND;
memset(&block,0,16);
fread(block.buff,6,1,rzxfile);
if(memcmp(block.buff,"RZX!",4))
{
/* not an RZX file */
rzx_close();
return RZX_INVALID;
}
/* save info about the RZX */
strcpy(rzx.filename, filename);
rzx.ver_major=block.buff[4];
rzx.ver_minor=block.buff[5];
/* pre-scan the file to collect useful information and stats */
rzx.mode=RZX_SCAN;
if(rzx_scan()!=RZX_OK)
{
rzx_close();
return RZX_INVALID;
}
rzx.mode=RZX_RECORD;
INcount=0;
INmax=0;
INold=0xFFFF;
return RZX_OK;
}
void rzx_close(void)
{

View File

@ -142,6 +142,7 @@ int rzx_add_comment(const char *text, const rzx_u32 flags);
void rzx_set_file_position(unsigned int rzx_position);
int rzx_extract_snapshot(unsigned int position, char *path, char *ext, int restore_position);
int rzx_edit(const char *filename);
#ifdef RZX_DEBUG
extern rzx_u16 INcount;