Improved RZX compatibility with the other emulator, fixed bug in rzx edit (file truncate)

This commit is contained in:
fabio.olimpieri 2015-03-27 09:24:14 +00:00
parent 0022e8f106
commit f496d9f1b7
4 changed files with 25 additions and 7 deletions

View File

@ -1835,8 +1835,7 @@ int main(int argc,char *argv[])
if ((ordenador.precision==0)||(jump_frames>0)) ordenador.interr=0; if ((ordenador.precision==0)||(jump_frames>0)) ordenador.interr=0;
if (ordenador.recording_rzx) if (ordenador.recording_rzx)
{ {
if (ordenador.icount == 0xFFFF) ordenador.icount=0; if (test_IFF1(&procesador)||(ordenador.icount>10)) {rzx_update(&ordenador.icount);ordenador.icount=0;}
else if (test_IFF1(&procesador)||(ordenador.icount>10)) {rzx_update(&ordenador.icount);ordenador.icount=0;}
} }
} }
} }

View File

@ -2019,9 +2019,7 @@ static int do_rzx(int which)
ordenador.frames_count_rzx=1; ordenador.frames_count_rzx=1;
retorno2 = load_rzx(0); retorno2 = load_rzx(0);
if (retorno2) break; //Error or no file if (retorno2) break; //Error or no file
retorno2 = rzx_update(&ordenador.maxicount); //The first frame does not generate interrupt ordenador.maxicount = 0; //Force rzx_update and interrupt
if (retorno2 == RZX_FINISHED) {printf("RZX: Playing finished at fisrt frame\n"); break;}
//ordenador.cicles_counter=32; //to avoid the interrupt at first frame
ordenador.playing_rzx = 1; ordenador.playing_rzx = 1;
retorno = -2; //Come back to the menu retorno = -2; //Come back to the menu
break; break;
@ -2035,7 +2033,7 @@ static int do_rzx(int which)
case 3: //Add Bookmark case 3: //Add Bookmark
if (!ordenador.recording_rzx) break; if (!ordenador.recording_rzx) break;
rzx_update(&ordenador.icount); rzx_update(&ordenador.icount);
ordenador.icount=0xFFFF; //to avoid a new rzx_update ordenador.icount=0;
save_z80("temp.z80",1); save_z80("temp.z80",1);
if (rzx_add_snapshot("temp.z80", RZX_COMPRESSED)==RZX_OK) {printf("RZX: Added snapshot\n");msgInfo("Added Bookmark", 3000, NULL);} if (rzx_add_snapshot("temp.z80", RZX_COMPRESSED)==RZX_OK) {printf("RZX: Added snapshot\n");msgInfo("Added Bookmark", 3000, NULL);}
else {printf("RZX: Impossible to add snapshot\n"); break;} else {printf("RZX: Impossible to add snapshot\n"); break;}
@ -2044,7 +2042,11 @@ static int do_rzx(int which)
break; break;
case 4: //browser case 4: //browser
if (!ordenador.playing_rzx&&!ordenador.recording_rzx) break; if (!ordenador.playing_rzx&&!ordenador.recording_rzx) break;
if (ordenador.recording_rzx) rzx_update(&ordenador.icount); //Discard the records
ordenador.icount = 0;
rzx_reset(); //Reset internal library variables
rzx_browser(); rzx_browser();
if (ordenador.playing_rzx) ordenador.maxicount = 0; //Force rzx_update and interrupt
retorno = -2; retorno = -2;
break; break;
case 5: //edit case 5: //edit

View File

@ -719,6 +719,9 @@ int rzx_edit(const char *filename)
void rzx_close(void) void rzx_close(void)
{ {
long fpos;
int fd;
switch(rzx.mode) switch(rzx.mode)
{ {
case RZX_PLAYBACK: case RZX_PLAYBACK:
@ -728,7 +731,14 @@ void rzx_close(void)
break; break;
case RZX_RECORD: case RZX_RECORD:
/* is there an IRB to close? */ /* is there an IRB to close? */
if(rzx_status&RZX_IRB) rzx_close_irb(); if(rzx_status&RZX_IRB) rzx_close_irb();
if (rzxfile!=NULL)
{
fflush(rzxfile);
fpos=ftell(rzxfile);
fd=fileno(rzxfile);
ftruncate(fd, fpos);
}
break; break;
default: default:
break; break;
@ -757,6 +767,12 @@ void rzx_close(void)
} }
} }
void rzx_reset()
{
INmax=0;
INcount=0;
INold=0xFFFF;
}
int rzx_update(rzx_u16 *icount) int rzx_update(rzx_u16 *icount)
{ {

View File

@ -143,6 +143,7 @@ int rzx_add_comment(const char *text, const rzx_u32 flags);
void rzx_set_file_position(unsigned int rzx_position); 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_extract_snapshot(unsigned int position, char *path, char *ext, int restore_position);
int rzx_edit(const char *filename); int rzx_edit(const char *filename);
void rzx_reset(void);
#ifdef RZX_DEBUG #ifdef RZX_DEBUG
extern rzx_u16 INcount; extern rzx_u16 INcount;