mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-28 02:54:15 +01:00
Added support for browsing during rzx recording
This commit is contained in:
parent
7538a0da07
commit
88631eb3ee
@ -133,6 +133,9 @@ void computer_init () { //Called only on start-up
|
|||||||
ordenador.tape_current_mode = TAP_TRASH;
|
ordenador.tape_current_mode = TAP_TRASH;
|
||||||
ordenador.next_block= NOBLOCK;
|
ordenador.next_block= NOBLOCK;
|
||||||
ordenador.tap_file = NULL;
|
ordenador.tap_file = NULL;
|
||||||
|
|
||||||
|
ordenador.recording_rzx=0;
|
||||||
|
ordenador.playing_rzx=0;
|
||||||
|
|
||||||
ordenador.osd_text[0] = 0;
|
ordenador.osd_text[0] = 0;
|
||||||
ordenador.osd_time = 0;
|
ordenador.osd_time = 0;
|
||||||
@ -1889,8 +1892,6 @@ void ResetComputer () {
|
|||||||
ordenador.currpix=0;
|
ordenador.currpix=0;
|
||||||
ordenador.interr = 1;
|
ordenador.interr = 1;
|
||||||
|
|
||||||
ordenador.recording_rzx=0;
|
|
||||||
//ordenador.playing_rzx=0;
|
|
||||||
ordenador.icount=0;
|
ordenador.icount=0;
|
||||||
ordenador.extract_screen_rzx = 0;
|
ordenador.extract_screen_rzx = 0;
|
||||||
|
|
||||||
|
@ -315,6 +315,8 @@ static void tape_browser()
|
|||||||
if (row_selected[0]==']') strncpy(block_n, row_selected+1,4);
|
if (row_selected[0]==']') strncpy(block_n, row_selected+1,4);
|
||||||
else strncpy(block_n, row_selected,4);
|
else strncpy(block_n, row_selected,4);
|
||||||
|
|
||||||
|
free((void*)row_selected);
|
||||||
|
|
||||||
block_n[4]=0;
|
block_n[4]=0;
|
||||||
|
|
||||||
block_n_int=atoi(block_n);
|
block_n_int=atoi(block_n);
|
||||||
@ -329,7 +331,6 @@ static void tape_browser()
|
|||||||
|
|
||||||
fseek(ordenador.tap_file, tape_position, SEEK_SET);
|
fseek(ordenador.tap_file, tape_position, SEEK_SET);
|
||||||
ordenador.tape_position = tape_position;
|
ordenador.tape_position = tape_position;
|
||||||
free((void*)row_selected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insert_tape()
|
static void insert_tape()
|
||||||
@ -1932,6 +1933,9 @@ static void rzx_browser()
|
|||||||
unsigned int rzx_position, block_n_int;
|
unsigned int rzx_position, block_n_int;
|
||||||
const char *row_selected;
|
const char *row_selected;
|
||||||
char block_n[5];
|
char block_n[5];
|
||||||
|
char ext[4];
|
||||||
|
char filename[MAX_PATH_LENGTH];
|
||||||
|
int retorno=0;
|
||||||
|
|
||||||
if (rzx_browser_list[0].position==0) {msgInfo("No RZX snapshot",3000,NULL);return;}
|
if (rzx_browser_list[0].position==0) {msgInfo("No RZX snapshot",3000,NULL);return;}
|
||||||
|
|
||||||
@ -1943,6 +1947,8 @@ static void rzx_browser()
|
|||||||
if (row_selected[0]==']') strncpy(block_n, row_selected+1,4);
|
if (row_selected[0]==']') strncpy(block_n, row_selected+1,4);
|
||||||
else strncpy(block_n, row_selected,4);
|
else strncpy(block_n, row_selected,4);
|
||||||
|
|
||||||
|
free((void*)row_selected);
|
||||||
|
|
||||||
block_n[4]=0;
|
block_n[4]=0;
|
||||||
|
|
||||||
block_n_int=atoi(block_n);
|
block_n_int=atoi(block_n);
|
||||||
@ -1953,9 +1959,32 @@ static void rzx_browser()
|
|||||||
|
|
||||||
ordenador.frames_count_rzx=rzx_browser_list[block_n_int].frames_count;
|
ordenador.frames_count_rzx=rzx_browser_list[block_n_int].frames_count;
|
||||||
|
|
||||||
rzx_set_file_position(rzx_position);
|
if (ordenador.playing_rzx) rzx_set_file_position(rzx_position);
|
||||||
|
|
||||||
free((void*)row_selected);
|
if (ordenador.recording_rzx)
|
||||||
|
{
|
||||||
|
if (rzx_extract_snapshot(rzx_position, load_path_snaps, ext, 0)) return; //Position at the end of snapshot
|
||||||
|
|
||||||
|
sprintf(filename, "%s/rzxtemp.%s", load_path_snaps, ext);
|
||||||
|
|
||||||
|
printf("Loading %s\n",filename);
|
||||||
|
|
||||||
|
if (ext_matches(filename, ".z80")|ext_matches(filename, ".Z80"))
|
||||||
|
retorno = load_z80(filename);
|
||||||
|
else if (ext_matches(filename, ".sna")|ext_matches(filename, ".SNA"))
|
||||||
|
retorno = load_sna(filename);
|
||||||
|
else
|
||||||
|
{printf("Not supported snap format\n");retorno=-2;}
|
||||||
|
|
||||||
|
unlink(filename);
|
||||||
|
|
||||||
|
if (block_n_int <(MAX_RZX_BROWSER_ITEM))
|
||||||
|
{
|
||||||
|
rzx_browser_list[block_n_int+1].position =0;
|
||||||
|
ordenador.total_frames_rzx = rzx_browser_list[block_n_int].frames_count;
|
||||||
|
rzx_snapshot_counter = block_n_int+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_rzx(int which)
|
static int do_rzx(int which)
|
||||||
@ -1970,6 +1999,7 @@ static int do_rzx(int which)
|
|||||||
ordenador.recording_rzx=0;
|
ordenador.recording_rzx=0;
|
||||||
rzx_close();
|
rzx_close();
|
||||||
ordenador.icount = 0;
|
ordenador.icount = 0;
|
||||||
|
ordenador.total_frames_rzx=0;
|
||||||
retorno2=save_rzx();
|
retorno2=save_rzx();
|
||||||
if (retorno2) break; //Error
|
if (retorno2) break; //Error
|
||||||
save_z80("temp.z80",1);
|
save_z80("temp.z80",1);
|
||||||
@ -2012,7 +2042,7 @@ static int do_rzx(int which)
|
|||||||
retorno = -2;
|
retorno = -2;
|
||||||
break;
|
break;
|
||||||
case 4: //browser
|
case 4: //browser
|
||||||
if (!ordenador.playing_rzx) break;
|
if (!ordenador.playing_rzx&&!ordenador.recording_rzx) break;
|
||||||
rzx_browser();
|
rzx_browser();
|
||||||
retorno = -2;
|
retorno = -2;
|
||||||
break;
|
break;
|
||||||
|
@ -524,9 +524,9 @@ int extract_screen_rzx (char *screen_memory, char *filename)
|
|||||||
|
|
||||||
ordenador.extract_screen_rzx = 1;
|
ordenador.extract_screen_rzx = 1;
|
||||||
|
|
||||||
if (rzx_playback(filename)) return -1;
|
if (rzx_playback(filename)) return -1; //Force the snaphot extract
|
||||||
|
|
||||||
ordenador.total_frames_rzx = 0;
|
ordenador.total_frames_rzx = 0; //rzx_playback changes this variable
|
||||||
|
|
||||||
ordenador.extract_screen_rzx = 0;
|
ordenador.extract_screen_rzx = 0;
|
||||||
|
|
||||||
@ -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;
|
rzx_position=rzx_browser_list[block_n_int].position;
|
||||||
|
|
||||||
if (rzx_extract_snapshot(rzx_position, load_path_snaps, ext)) return; //error
|
if (rzx_extract_snapshot(rzx_position, load_path_snaps, ext, 1)) return; //error
|
||||||
|
|
||||||
strcpy(name, "rzxtemp.");
|
strcpy(name, "rzxtemp.");
|
||||||
strcat(name, ext);
|
strcat(name, ext);
|
||||||
|
@ -40,7 +40,7 @@ extern FILE *fdebug;
|
|||||||
|
|
||||||
RZX_EMULINFO emul_info;
|
RZX_EMULINFO emul_info;
|
||||||
rzx_u32 tstates;
|
rzx_u32 tstates;
|
||||||
int snapshot_counter;
|
int rzx_snapshot_counter;
|
||||||
RZX_browser rzx_browser_list[MAX_RZX_BROWSER_ITEM+1];
|
RZX_browser rzx_browser_list[MAX_RZX_BROWSER_ITEM+1];
|
||||||
char extracted_rzx_file[MAX_PATH_LENGTH];
|
char extracted_rzx_file[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ rzx_u32 rzx_callback(int msg, void *par)
|
|||||||
case RZXMSG_LOADSNAP:
|
case RZXMSG_LOADSNAP:
|
||||||
if(rzx.mode==RZX_SCAN)
|
if(rzx.mode==RZX_SCAN)
|
||||||
{
|
{
|
||||||
if (snapshot_counter>=MAX_RZX_BROWSER_ITEM) break;
|
if (rzx_snapshot_counter>=MAX_RZX_BROWSER_ITEM) break;
|
||||||
if (!(((RZX_SNAPINFO*)par)->options&RZX_EXTERNAL)) rzx_browser_list[snapshot_counter++].position=((RZX_SNAPINFO*)par)->position; //Embedded snapshot - Position at beginning
|
if (!(((RZX_SNAPINFO*)par)->options&RZX_EXTERNAL)) rzx_browser_list[rzx_snapshot_counter++].position=((RZX_SNAPINFO*)par)->position; //Embedded snapshot - Position at beginning
|
||||||
rzx_browser_list[snapshot_counter].position=0;
|
rzx_browser_list[rzx_snapshot_counter].position=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -104,6 +104,13 @@ rzx_u32 rzx_callback(int msg, void *par)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RZXMSG_SAVESNAP:
|
||||||
|
printf("> Save snaphsot\n");
|
||||||
|
if (rzx_snapshot_counter>=MAX_RZX_BROWSER_ITEM) break;
|
||||||
|
rzx_browser_list[rzx_snapshot_counter].position=((RZX_SNAPINFO*)par)->position;
|
||||||
|
rzx_browser_list[rzx_snapshot_counter].frames_count = ordenador.total_frames_rzx;
|
||||||
|
rzx_browser_list[++rzx_snapshot_counter].position=0;
|
||||||
|
break;
|
||||||
case RZXMSG_CREATOR:
|
case RZXMSG_CREATOR:
|
||||||
printf("> CREATOR: '%s %d.%d'\n",
|
printf("> CREATOR: '%s %d.%d'\n",
|
||||||
((RZX_EMULINFO*)par)->name,
|
((RZX_EMULINFO*)par)->name,
|
||||||
@ -111,7 +118,8 @@ rzx_u32 rzx_callback(int msg, void *par)
|
|||||||
(int)((RZX_EMULINFO*)par)->ver_minor);
|
(int)((RZX_EMULINFO*)par)->ver_minor);
|
||||||
if ((int)((RZX_EMULINFO*)par)->length>0)
|
if ((int)((RZX_EMULINFO*)par)->length>0)
|
||||||
printf("%s \n", (const char *)((RZX_EMULINFO*)par)->data);
|
printf("%s \n", (const char *)((RZX_EMULINFO*)par)->data);
|
||||||
snapshot_counter=0;
|
rzx_snapshot_counter=0;
|
||||||
|
rzx_browser_list[0].frames_count=0;
|
||||||
rzx_browser_list[0].position=0;
|
rzx_browser_list[0].position=0;
|
||||||
break;
|
break;
|
||||||
case RZXMSG_IRBNOTIFY:
|
case RZXMSG_IRBNOTIFY:
|
||||||
@ -137,11 +145,16 @@ rzx_u32 rzx_callback(int msg, void *par)
|
|||||||
}
|
}
|
||||||
else if(rzx.mode==RZX_SCAN)
|
else if(rzx.mode==RZX_SCAN)
|
||||||
{
|
{
|
||||||
if ((snapshot_counter>0)&&(snapshot_counter<MAX_RZX_BROWSER_ITEM+1)) rzx_browser_list[snapshot_counter-1].frames_count = ordenador.total_frames_rzx;
|
if ((rzx_snapshot_counter>0)&&(rzx_snapshot_counter<MAX_RZX_BROWSER_ITEM+1)) rzx_browser_list[rzx_snapshot_counter-1].frames_count = ordenador.total_frames_rzx;
|
||||||
ordenador.total_frames_rzx += ((RZX_IRBINFO*)par)->framecount;
|
ordenador.total_frames_rzx += ((RZX_IRBINFO*)par)->framecount;
|
||||||
printf("> IRB notify: Total frames to play %d\n", ordenador.total_frames_rzx);
|
printf("> IRB notify: Total frames to play %d\n", ordenador.total_frames_rzx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RZXMSG_IRBCLOSE:
|
||||||
|
printf("> IRB close\n");
|
||||||
|
if ((rzx_snapshot_counter>0)&&(rzx_snapshot_counter<MAX_RZX_BROWSER_ITEM+1))
|
||||||
|
ordenador.total_frames_rzx += ((RZX_IRBINFO*)par)->framecount;
|
||||||
|
break;
|
||||||
case RZXMSG_SECURITY:
|
case RZXMSG_SECURITY:
|
||||||
printf("> Security Information Block\n");
|
printf("> Security Information Block\n");
|
||||||
break;
|
break;
|
||||||
|
@ -28,4 +28,5 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
extern RZX_browser rzx_browser_list[MAX_RZX_BROWSER_ITEM+1];
|
extern RZX_browser rzx_browser_list[MAX_RZX_BROWSER_ITEM+1];
|
||||||
extern char extracted_rzx_file[MAX_PATH_LENGTH];
|
extern char extracted_rzx_file[MAX_PATH_LENGTH];
|
||||||
|
extern int rzx_snapshot_counter;
|
@ -302,9 +302,12 @@ void rzx_set_file_position(unsigned int rzx_position)
|
|||||||
#ifdef RZX_USE_COMPRESSION
|
#ifdef RZX_USE_COMPRESSION
|
||||||
rzx_pclose();
|
rzx_pclose();
|
||||||
#endif
|
#endif
|
||||||
|
fseek(rzxfile,rzx_position,SEEK_SET);
|
||||||
|
INcount=0;
|
||||||
|
INold=0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rzx_extract_snapshot(unsigned int position, char *path, char *ext)
|
int rzx_extract_snapshot(unsigned int position, char *path, char *ext, int restore_position)
|
||||||
{
|
{
|
||||||
int done=0, ret=0;
|
int done=0, ret=0;
|
||||||
int old_position, fpos;
|
int old_position, fpos;
|
||||||
@ -318,6 +321,11 @@ old_position=ftell(rzxfile);
|
|||||||
|
|
||||||
fseek(rzxfile,position,SEEK_SET);
|
fseek(rzxfile,position,SEEK_SET);
|
||||||
fread(block.buff,5,1,rzxfile);
|
fread(block.buff,5,1,rzxfile);
|
||||||
|
#ifndef RZX_BIG_ENDIAN
|
||||||
|
block.length=*((rzx_u32*)(&block.buff[1]));
|
||||||
|
#else
|
||||||
|
block.length=block.buff[1]+256*block.buff[2]+65536*block.buff[3]+16777216*block.buff[4];
|
||||||
|
#endif
|
||||||
fread(block.buff,12,1,rzxfile);
|
fread(block.buff,12,1,rzxfile);
|
||||||
strcpy(rzx_snap.filename,"");
|
strcpy(rzx_snap.filename,"");
|
||||||
rzx_snap.options=0x00;
|
rzx_snap.options=0x00;
|
||||||
@ -333,7 +341,7 @@ old_position=ftell(rzxfile);
|
|||||||
strcat(rzx_snap.filename,"/rzxtemp.");
|
strcat(rzx_snap.filename,"/rzxtemp.");
|
||||||
strcat(rzx_snap.filename,&block.buff[4]);
|
strcat(rzx_snap.filename,&block.buff[4]);
|
||||||
strcpy(ext, &block.buff[4]);
|
strcpy(ext, &block.buff[4]);
|
||||||
#ifndef RZX_BIG_ENDIAN
|
#ifndef RZX_BIG_ENDIAN
|
||||||
rzx_snap.length=*((rzx_u32*)&block.buff[8]);
|
rzx_snap.length=*((rzx_u32*)&block.buff[8]);
|
||||||
#else
|
#else
|
||||||
rzx_snap.length=block.buff[8]+256*block.buff[9]+65536*block.buff[10]+16777216*block.buff[11];
|
rzx_snap.length=block.buff[8]+256*block.buff[9]+65536*block.buff[10]+16777216*block.buff[11];
|
||||||
@ -365,7 +373,8 @@ old_position=ftell(rzxfile);
|
|||||||
}
|
}
|
||||||
else ret=-1;
|
else ret=-1;
|
||||||
|
|
||||||
fseek(rzxfile,old_position,SEEK_SET);
|
if (restore_position) fseek(rzxfile,old_position,SEEK_SET);
|
||||||
|
else rzx_set_file_position(position+block.length); //Used for edit recording
|
||||||
|
|
||||||
#ifdef RZX_USE_COMPRESSION
|
#ifdef RZX_USE_COMPRESSION
|
||||||
rzx_swap_variables_revert();
|
rzx_swap_variables_revert();
|
||||||
@ -406,6 +415,8 @@ void rzx_close_irb()
|
|||||||
rzx_status&=~RZX_IRB;
|
rzx_status&=~RZX_IRB;
|
||||||
INcount=0;
|
INcount=0;
|
||||||
INold=0xFFFF;
|
INold=0xFFFF;
|
||||||
|
rzx_irb.framecount = rzx_framecount;
|
||||||
|
emul_handler(RZXMSG_IRBCLOSE,&rzx_irb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -621,13 +632,14 @@ int rzx_record(const char *filename)
|
|||||||
}
|
}
|
||||||
memset(block.buff,0,RZXBLKBUF);
|
memset(block.buff,0,RZXBLKBUF);
|
||||||
rzx.mode=RZX_IDLE;
|
rzx.mode=RZX_IDLE;
|
||||||
rzxfile=fopen(filename,"wb");
|
rzxfile=fopen(filename,"w+b");
|
||||||
if(rzxfile==NULL)
|
if(rzxfile==NULL)
|
||||||
{
|
{
|
||||||
rzx_close();
|
rzx_close();
|
||||||
return RZX_NOTFOUND;
|
return RZX_NOTFOUND;
|
||||||
}
|
}
|
||||||
strcpy(rzx.filename,filename);
|
strcpy(rzx.filename,filename);
|
||||||
|
strcpy(file_emul.name,filename);
|
||||||
/* write the main RZX header */
|
/* write the main RZX header */
|
||||||
memcpy(block.buff,"RZX!",4);
|
memcpy(block.buff,"RZX!",4);
|
||||||
block.buff[4]=LHI(RZX_LIBRARY_VERSION);
|
block.buff[4]=LHI(RZX_LIBRARY_VERSION);
|
||||||
@ -653,6 +665,11 @@ int rzx_record(const char *filename)
|
|||||||
rzx_status&=~RZX_IRB;
|
rzx_status&=~RZX_IRB;
|
||||||
INcount=0;
|
INcount=0;
|
||||||
INold=0xFFFF;
|
INold=0xFFFF;
|
||||||
|
file_emul.ver_major=host_emul.ver_major;
|
||||||
|
file_emul.ver_minor=host_emul.ver_minor;
|
||||||
|
file_emul.length = host_emul.length;
|
||||||
|
file_emul.data = host_emul.data;
|
||||||
|
emul_handler(RZXMSG_CREATOR,&file_emul);
|
||||||
return RZX_OK;
|
return RZX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,6 +881,7 @@ int rzx_add_snapshot(const char *filename, const rzx_u32 flags)
|
|||||||
snapfile=fopen(filename,"rb");
|
snapfile=fopen(filename,"rb");
|
||||||
if(snapfile==NULL) return RZX_NOTFOUND;
|
if(snapfile==NULL) return RZX_NOTFOUND;
|
||||||
if(rzx_status&RZX_IRB) rzx_close_irb();
|
if(rzx_status&RZX_IRB) rzx_close_irb();
|
||||||
|
rzx_snap.position = ftell(rzxfile);
|
||||||
/* find the length of the snapshot file */
|
/* find the length of the snapshot file */
|
||||||
fseek(snapfile,0,SEEK_END);
|
fseek(snapfile,0,SEEK_END);
|
||||||
snaplen=ftell(snapfile);
|
snaplen=ftell(snapfile);
|
||||||
@ -942,6 +960,7 @@ int rzx_add_snapshot(const char *filename, const rzx_u32 flags)
|
|||||||
fclose(snapfile); snapfile=NULL;
|
fclose(snapfile); snapfile=NULL;
|
||||||
/* remove the snapshot if requested */
|
/* remove the snapshot if requested */
|
||||||
if(flags&RZX_REMOVE) remove(filename);
|
if(flags&RZX_REMOVE) remove(filename);
|
||||||
|
emul_handler(RZXMSG_SAVESNAP,&rzx_snap);
|
||||||
return RZX_OK;
|
return RZX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,8 @@ typedef unsigned long int rzx_u32; /* must be unsigned 32-bit */
|
|||||||
#define RZXMSG_SECURITY 4
|
#define RZXMSG_SECURITY 4
|
||||||
#define RZXMSG_SEC_SIG 5
|
#define RZXMSG_SEC_SIG 5
|
||||||
#define RZXMSG_UNKNOWN 6
|
#define RZXMSG_UNKNOWN 6
|
||||||
|
#define RZXMSG_SAVESNAP 7
|
||||||
|
#define RZXMSG_IRBCLOSE 8
|
||||||
|
|
||||||
|
|
||||||
/* RZX global flags */
|
/* RZX global flags */
|
||||||
@ -139,7 +141,7 @@ int rzx_add_snapshot(const char *filename, const rzx_u32 flags);
|
|||||||
int rzx_add_comment(const char *text, const rzx_u32 flags);
|
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 rzx_extract_snapshot(unsigned int position, char *path, char *ext, int restore_position);
|
||||||
|
|
||||||
#ifdef RZX_DEBUG
|
#ifdef RZX_DEBUG
|
||||||
extern rzx_u16 INcount;
|
extern rzx_u16 INcount;
|
||||||
|
Loading…
Reference in New Issue
Block a user