Fixed bug in rzx snapshot extract, changed rzx function names

This commit is contained in:
fabio.olimpieri 2015-03-18 12:57:14 +00:00
parent 951654101f
commit 7538a0da07
4 changed files with 39 additions and 8 deletions

View File

@ -1953,7 +1953,7 @@ static void rzx_browser()
ordenador.frames_count_rzx=rzx_browser_list[block_n_int].frames_count;
set_rzxfile_position(rzx_position);
rzx_set_file_position(rzx_position);
free((void*)row_selected);
}

View File

@ -654,7 +654,7 @@ void draw_scr_file(int x,int y, const char *selected_file, int which)
rzx_position=rzx_browser_list[block_n_int].position;
if (extract_snapshot(rzx_position, load_path_snaps, ext)) return; //error
if (rzx_extract_snapshot(rzx_position, load_path_snaps, ext)) return; //error
strcpy(name, "rzxtemp.");
strcat(name, ext);

View File

@ -86,6 +86,29 @@ static rzx_u8 *zbuf=0;
static int zmode=0;
static rzx_u32 packed_bytes=0;
static z_stream zs_temp;
static rzx_u8 *zbuf_temp=0;
static int zmode_temp=0;
static rzx_u32 packed_bytes_temp=0;
void rzx_swap_variables()
{
zs_temp=zs;
zbuf_temp=zbuf;
zmode_temp=zmode;
packed_bytes_temp=packed_bytes;
}
void rzx_swap_variables_revert()
{
zs=zs_temp;
zbuf=zbuf_temp;
zmode=zmode_temp;
packed_bytes=packed_bytes_temp;
}
unsigned int last_snapshot_position;
int rzx_pwrite(rzx_u8 *buffer, int len)
@ -271,7 +294,7 @@ int rzx_scan()
return ret;
}
void set_rzxfile_position(unsigned int rzx_position)
void rzx_set_file_position(unsigned int rzx_position)
{
block.start = rzx_position;
@ -281,12 +304,16 @@ void set_rzxfile_position(unsigned int rzx_position)
#endif
}
int extract_snapshot(unsigned int position, char *path, char *ext)
int rzx_extract_snapshot(unsigned int position, char *path, char *ext)
{
int done=0, ret=0;
int old_position, fpos;
FILE *snapfile;
#ifdef RZX_USE_COMPRESSION
rzx_swap_variables();
#endif
old_position=ftell(rzxfile);
fseek(rzxfile,position,SEEK_SET);
@ -338,8 +365,12 @@ old_position=ftell(rzxfile);
}
else ret=-1;
fseek(rzxfile,old_position,SEEK_SET);
return ret;
fseek(rzxfile,old_position,SEEK_SET);
#ifdef RZX_USE_COMPRESSION
rzx_swap_variables_revert();
#endif
return ret;
}
void rzx_close_irb()

View File

@ -138,8 +138,8 @@ int rzx_get_input(rzx_u8 *input);
int rzx_add_snapshot(const char *filename, const rzx_u32 flags);
int rzx_add_comment(const char *text, const rzx_u32 flags);
void set_rzxfile_position(unsigned int rzx_position);
int extract_snapshot(unsigned int position, char *path, char *ext);
void rzx_set_file_position(unsigned int rzx_position);
int rzx_extract_snapshot(unsigned int position, char *path, char *ext);
#ifdef RZX_DEBUG
extern rzx_u16 INcount;