FTP and SMP connect also after start up, SCRs on file select menus

This commit is contained in:
fabio.olimpieri 2013-01-03 07:34:16 +00:00
parent 1a74eec1d5
commit 27460a96b6
6 changed files with 300 additions and 102 deletions

View File

@ -611,7 +611,7 @@ inline void show_screen (int tstados) {
temporal3 = ordenador.memoria[(((*ordenador.p_translt) + (ordenador.video_offset))&0xFFFFFF80)+(procesador.R&0x7F)]; // data with snow temporal3 = ordenador.memoria[(((*ordenador.p_translt) + (ordenador.video_offset))&0xFFFFFF80)+(procesador.R&0x7F)]; // data with snow
ordenador.screen_snow=0; // no more snow for now ordenador.screen_snow=0; // no more snow for now
} else } else
temporal3 = ordenador.memoria[(*ordenador.p_translt) + ordenador.video_offset]; // bitmap // bitmap temporal3 = ordenador.memoria[(*ordenador.p_translt) + ordenador.video_offset]; // bitmap
ordenador.p_translt++; ordenador.p_translt++;
ordenador.p_translt2++; ordenador.p_translt2++;

View File

@ -71,7 +71,8 @@ unsigned char *sound[NUM_SNDBUF];
char path_snaps[2049]; char path_snaps[2049];
char path_taps[2049]; char path_taps[2049];
char path_mdrs[2049]; char path_mdrs[2049];
char path_scr[2049]; char path_scr1[2049];
char path_scr2[2049];
char path_confs[2049]; char path_confs[2049];
char path_poke[2049]; char path_poke[2049];
char path_tmp[2049]; char path_tmp[2049];
@ -1267,14 +1268,16 @@ int main(int argc,char *argv[]) {
strcat(path_snaps,"/"); strcat(path_snaps,"/");
strcpy(path_taps,path_snaps); strcpy(path_taps,path_snaps);
strcpy(path_mdrs,path_snaps); strcpy(path_mdrs,path_snaps);
strcpy(path_scr,path_snaps); strcpy(path_scr1,path_snaps);
strcpy(path_scr2,path_snaps);
strcpy(path_confs,path_snaps); strcpy(path_confs,path_snaps);
strcpy(path_poke,path_snaps); strcpy(path_poke,path_snaps);
strcpy(path_tmp,path_snaps); strcpy(path_tmp,path_snaps);
strcat(path_snaps,"snapshots"); strcat(path_snaps,"snapshots");
strcat(path_taps,"tapes"); strcat(path_taps,"tapes");
strcat(path_mdrs,"microdrives"); strcat(path_mdrs,"microdrives");
strcat(path_scr,"scr"); strcat(path_scr1,"scr"); //left scr for retrocompatibility
strcat(path_scr2,"scr2");
strcat(path_confs,"configurations"); strcat(path_confs,"configurations");
strcat(path_poke,"poke"); strcat(path_poke,"poke");
strcat(path_tmp,"tmp"); strcat(path_tmp,"tmp");

View File

@ -35,13 +35,14 @@ extern unsigned char *sound[NUM_SNDBUF];
extern char path_snaps[2049]; extern char path_snaps[2049];
extern char path_taps[2049]; extern char path_taps[2049];
extern char path_mdrs[2049]; extern char path_mdrs[2049];
extern char path_scr[2049]; extern char path_scr1[2049];
extern char path_scr2[2049];
extern char path_confs[2049]; extern char path_confs[2049];
extern char path_poke[2049]; extern char path_poke[2049];
extern char path_tmp[2049]; extern char path_tmp[2049];
extern unsigned int colors[80]; extern unsigned int colors[80];
extern unsigned int jump_frames,curr_frames; extern unsigned int jump_frames,curr_frames;
extern unsigned char usbismount, smbismount, tmpismade, ftpismount; extern unsigned char usbismount, smbismount, tmpismade, ftpismount,networkisinit;
void SDL_Fullscreen_Switch(void); void SDL_Fullscreen_Switch(void);
void load_rom(char); void load_rom(char);
@ -55,5 +56,8 @@ void init_sound();
void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface); void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface);
int set_video_mode(); int set_video_mode();
int remove_dir(char *dir); int remove_dir(char *dir);
unsigned char ConnectFTP ();
unsigned char ConnectShare ();
unsigned char InitNetwork();
#endif #endif

View File

@ -32,7 +32,6 @@
#include "VirtualKeyboard.h" #include "VirtualKeyboard.h"
#include "tape.h" #include "tape.h"
#include "menus.h" #include "menus.h"
#include "emulator.h"
#include "cargador.h" #include "cargador.h"
#include "characters.h" #include "characters.h"
@ -147,18 +146,17 @@ static const char *microdrive_messages[] = {
}; };
static const char *tools_messages[] = { static const char *tools_messages[] = {
/*00*/ "Save SCR", /*00*/ "Screen shot",
/*01*/ " ", /*01*/ "^|Save1|Save2|Load|Delete",
/*02*/ "Load SCR", /*02*/ " ",
/*03*/ " ", /*03*/ "Insert poke",
/*04*/ "Insert poke", /*04*/ " ",
/*05*/ " ", /*05*/ "Load poke file",
/*06*/ "Load poke file", /*06*/ " ",
/*07*/ " ", /*07*/ "Port",
/*08*/ "Port", /*08*/ "^|sd|usb|smb|ftp",
/*09*/ "^|sd|usb|smb|ftp", /*09*/ " ",
/*10*/ " ", /*10*/ "Help",
/*11*/ "Help",
NULL NULL
}; };
@ -228,7 +226,7 @@ static void insert_tape()
ordenador.tape_current_bit=0; ordenador.tape_current_bit=0;
ordenador.tape_current_mode=TAP_TRASH; ordenador.tape_current_mode=TAP_TRASH;
const char *filename = menu_select_file(path_taps, ordenador.current_tap, 0); const char *filename = menu_select_file(path_taps, ordenador.current_tap, 1);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -286,7 +284,7 @@ static void insert_tape()
static void delete_tape() static void delete_tape()
{ {
const char *filename = menu_select_file(path_taps, NULL, -1); const char *filename = menu_select_file(path_taps, NULL, 1);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -308,6 +306,15 @@ void create_tapfile_sdl() {
ancho=screen->w; ancho=screen->w;
clean_screen(); clean_screen();
if (ordenador.port==3) //If FTP is selected, saves file on SD card
{
int length;
strcpy(path_taps,getenv("HOME"));
length=strlen(path_taps);
if ((length>0)&&(path_taps[length-1]!='/')) strcat(path_taps,"/");
strcat(path_taps,"tapes");
}
print_string(videomem,"Choose a name for the TAP file",-1,32,14,0,ancho); print_string(videomem,"Choose a name for the TAP file",-1,32,14,0,ancho);
print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho); print_string(videomem,"(up to 30 characters)",-1,52,14,0,ancho);
@ -317,6 +324,8 @@ void create_tapfile_sdl() {
retorno=ask_filename_sdl(nombre2,82,"tap",path_taps,NULL); retorno=ask_filename_sdl(nombre2,82,"tap",path_taps,NULL);
if (ordenador.port==3) strcpy(path_taps,"ftp:");
if(retorno==2) // abort if(retorno==2) // abort
return; return;
@ -760,7 +769,7 @@ static void select_mdr()
static void delete_mdr() static void delete_mdr()
{ {
const char *filename = menu_select_file(path_mdrs, NULL, -1); const char *filename = menu_select_file(path_mdrs, NULL, 0);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -886,6 +895,19 @@ static void microdrive()
} }
} }
static void delete_scr()
{
const char *filename = menu_select_file(getenv("HOME"), NULL, 0); //Start from Home
if (filename==NULL) // Aborted
return;
if ((ext_matches(filename, ".scr")|ext_matches(filename, ".SCR"))
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename);
free((void *)filename);
}
static void load_scr() static void load_scr()
{ {
int retorno,loop; int retorno,loop;
@ -894,7 +916,7 @@ static void load_scr()
unsigned char paleta_tmp[64]; unsigned char paleta_tmp[64];
const char *filename = menu_select_file(path_scr, NULL, -1); const char *filename = menu_select_file(path_scr1, NULL, 0); // Load from SCR1
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -939,16 +961,28 @@ static void load_scr()
} }
static void save_scr() static void save_scr(int i)
{ {
const char *dir = path_scr; const char *dir;
const char *tape = ordenador.last_selected_file; const char *tape = ordenador.last_selected_file;
char *ptr; char *ptr;
FILE *fichero; FILE *fichero;
char db[256]; char db[256];
char fb[81]; char fb[81];
int retorno,retval; int retorno,retval, length;
char path_scr[2049];
strcpy(path_scr,getenv("HOME"));
length=strlen(path_scr);
if ((length>0)&&(path_scr[length-1]!='/'))
strcat(path_scr,"/");
//Save only on SD card
if (i==1) strcat(path_scr,"scr"); else
if (i==2) strcat(path_scr,"scr2"); else return;
dir = path_scr;
// Name (for saves) - TO CHECK // Name (for saves) - TO CHECK
if (tape && strrchr(tape, '/')) if (tape && strrchr(tape, '/'))
strncpy(fb, strrchr(tape, '/') + 1, 80); strncpy(fb, strrchr(tape, '/') + 1, 80);
@ -959,21 +993,10 @@ static void save_scr()
ptr = strrchr (fb, '.'); ptr = strrchr (fb, '.');
if (ptr) *ptr = 0; if (ptr) *ptr = 0;
//If file is taken from FTP, saves file on SD card
if (ordenador.port==3)
{
int length;
strcpy(path_scr,getenv("HOME"));
length=strlen(path_scr);
if ((length>0)&&(path_scr[length-1]!='/')) strcat(path_scr,"/");
strcat(path_scr,"scr");
dir=path_scr;
}
// Save SCR file // Save SCR file
snprintf(db, 255, "%s/%s.scr", dir, fb); snprintf(db, 255, "%s/%s.scr", dir, fb);
if (ordenador.port==3) strcpy(path_scr,"ftp:");
fichero=fopen(db,"r"); fichero=fopen(db,"r");
@ -989,7 +1012,7 @@ static void save_scr()
if(fichero==NULL) if(fichero==NULL)
retorno=-1; retorno=-1;
else { else {
retval=fwrite(ordenador.block1+0x04000,6912,1,fichero); // save screen retval=fwrite(ordenador.block1+0x04000+ordenador.video_offset,6912,1,fichero); // save screen
if (ordenador.ulaplus!=0) { if (ordenador.ulaplus!=0) {
retval=fwrite(ordenador.ulaplus_palete,64,1,fichero); // save ULAPlus palete retval=fwrite(ordenador.ulaplus_palete,64,1,fichero); // save ULAPlus palete
} }
@ -999,7 +1022,7 @@ static void save_scr()
switch(retorno) { switch(retorno) {
case 0: case 0:
msgInfo("SCR saved",3000,NULL); if (i==1) msgInfo("SCR1 saved",3000,NULL); else msgInfo("SCR2 saved",3000,NULL);
break; break;
case -1: case -1:
msgInfo("Can't create file",3000,NULL); msgInfo("Can't create file",3000,NULL);
@ -1021,11 +1044,13 @@ static void set_port(int which)
if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/"); if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/");
strcpy(path_taps,path_snaps); strcpy(path_taps,path_snaps);
strcpy(path_poke,path_snaps); strcpy(path_poke,path_snaps);
strcpy(path_scr,path_snaps); strcpy(path_scr1,path_snaps);
strcpy(path_scr2,path_snaps);
strcat(path_snaps,"snapshots"); strcat(path_snaps,"snapshots");
strcat(path_taps,"tapes"); strcat(path_taps,"tapes");
strcat(path_poke,"poke"); strcat(path_poke,"poke");
strcat(path_scr,"scr"); strcat(path_scr1,"scr");
strcat(path_scr2,"scr2");
ordenador.port = which; ordenador.port = which;
break; break;
case 1: //PORT_USB case 1: //PORT_USB
@ -1033,30 +1058,48 @@ static void set_port(int which)
strcpy(path_snaps,"usb:/"); strcpy(path_snaps,"usb:/");
strcpy(path_taps,"usb:/"); strcpy(path_taps,"usb:/");
strcpy(path_poke,"usb:/"); strcpy(path_poke,"usb:/");
strcpy(path_scr,"usb:/"); strcpy(path_scr1,"usb:/");
strcpy(path_scr2,"usb:/");
ordenador.port = which;} ordenador.port = which;}
else else
msgInfo("USB is not mounted",3000,NULL); msgInfo("USB is not mounted",3000,NULL);
break; break;
case 2: //PORT_SMB case 2: //PORT_SMB
if (!smbismount)
{
msgInfo("Try to mount SMB",0,NULL);
if (!networkisinit) networkisinit = InitNetwork();
if (networkisinit) ConnectShare();
if (smbismount) msgInfo("SMB is now mounted",3000,NULL);
}
if (smbismount) { if (smbismount) {
strcpy(path_snaps,"smb:/"); strcpy(path_snaps,"smb:/");
strcpy(path_taps,"smb:/"); strcpy(path_taps,"smb:/");
strcpy(path_poke,"smb:/"); strcpy(path_poke,"smb:/");
strcpy(path_scr,"smb:/"); strcpy(path_scr1,"smb:/");
strcpy(path_scr2,"smb:/");
ordenador.port = which;} ordenador.port = which;}
else else
msgInfo("SMB is not mounted",3000,NULL); msgInfo("SMB is not mounted",3000,NULL);
break; break;
case 3: //PORT_FTP case 3: //PORT_FTP
if (!ftpismount)
{
msgInfo("Try to mount FTP",0,NULL);
if (!networkisinit) networkisinit = InitNetwork();
if (networkisinit) ConnectFTP();
if (ftpismount) msgInfo("FTP is now mounted",3000,NULL);
}
if (ftpismount) { if (ftpismount) {
strcpy(path_snaps,"ftp:"); strcpy(path_snaps,"ftp:");
strcpy(path_taps,"ftp:"); strcpy(path_taps,"ftp:");
strcpy(path_poke,"ftp:"); strcpy(path_poke,"ftp:");
strcpy(path_scr,"ftp:"); strcpy(path_scr1,"ftp:");
strcpy(path_scr2,"ftp:");
ordenador.port = which;} ordenador.port = which;}
else else
msgInfo("FTP is not connected",3000,NULL); msgInfo("FTP is not mounted",3000,NULL);
break; break;
default: default:
break; break;
@ -1296,7 +1339,7 @@ void load_poke_file()
int ritorno; int ritorno;
ritorno=0; ritorno=0;
const char *filename = menu_select_file(dir, NULL,-1); const char *filename = menu_select_file(dir, NULL,0);
if (!filename) return; if (!filename) return;
@ -1323,37 +1366,57 @@ static void help(void)
help_messages, NULL); help_messages, NULL);
} }
void manage_scr(int which)
{
switch (which)
{
case 0: // Save SCR 1
save_scr(1);
break;
case 1: // Save SCR 2
save_scr(2);
break;
case 2: // Load SCR
load_scr();
break;
case 3: // Delete scr
delete_scr();
break;
default:
break;
}
}
static void tools() static void tools()
{ {
int opt ; int opt ;
int submenus[1]; int submenus[2];
memset(submenus, 0, sizeof(submenus)); memset(submenus, 0, sizeof(submenus));
submenus[0] = ordenador.port; submenus[1] = ordenador.port;
opt = menu_select_title("Tools menu", opt = menu_select_title("Tools menu",
tools_messages, submenus); tools_messages, submenus);
if (opt < 0) if (opt < 0)
return; return;
set_port(submenus[0]); set_port(submenus[1]);
switch(opt) switch(opt)
{ {
case 0: // Save SCR case 0:
save_scr(); manage_scr(submenus[0]);
break; break;
case 2: // Load SCR case 3: // Insert poke
load_scr();
break;
case 4: // Insert poke
do_poke_sdl(); do_poke_sdl();
break; break;
case 6: // Load poke file case 5: // Load poke file
load_poke_file(); load_poke_file();
break; break;
case 11: case 10:
help(); help();
break; break;
default: default:
@ -1407,7 +1470,7 @@ static void save_load_snapshot(int which)
case 2: case 2:
case 0: // Load or delete file case 0: // Load or delete file
{ {
const char *filename = menu_select_file(dir, NULL,-1); const char *filename = menu_select_file(dir, NULL,1);
if (!filename) if (!filename)
return; return;
@ -1487,7 +1550,7 @@ static void save_load_game_configurations(int which)
case 2: case 2:
case 0: // Load or delete file case 0: // Load or delete file
{ {
const char *filename = menu_select_file(dir, NULL,-1); const char *filename = menu_select_file(dir, NULL,0);
if (!filename) if (!filename)
return; return;

View File

@ -111,7 +111,7 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
rc.x = X; rc.x = X;
rc.y=Y; rc.y=Y;
rc.w=12*(len + 2)/RATIO; rc.w=12*(len + 2)/RATIO;
rc.h=duration > 0 ? 48/RATIO : 80/RATIO; rc.h=duration >= 0 ? 48/RATIO : 80/RATIO;
src.x=rc.x+4/RATIO; src.x=rc.x+4/RATIO;
src.y=rc.y+4/RATIO; src.y=rc.y+4/RATIO;
@ -505,16 +505,118 @@ void print_font(SDL_Surface *screen, int r, int g, int b,
} }
static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_size) #ifdef GEKKO
inline void paint_one_pixel_scr(unsigned char *colour,unsigned char *address)
{
*(address++)=*(colour+2);
*(address++)=*(colour+3);
}
#else
inline void paint_one_pixel_scr(unsigned char *colour,unsigned char *address) {
#if BYTE_ORDER == LITTLE_ENDIAN
switch(ordenador.bpp) {
case 1:
*address=*colour;
break;
case 3:
*(address++)=*(colour++);
case 2:
*(address++)=*(colour++);
*(address++)=*(colour++);
break;
case 4:
*((unsigned int *)address)=*((unsigned int *)colour);
break;
}
#else //BIG ENDIAN
switch(ordenador.bpp) {
case 1:
*address=*(colour+3);
break;
case 3:
*(address++)=*(colour+1);
case 2:
*(address++)=*(colour+2);
*(address++)=*(colour+3);
break;
case 4:
*((unsigned int *)address)=*((unsigned int *)colour);
break;
}
#endif
}
#endif
void draw_scr_file(int x,int y, char *filename)
{
FILE *fichero;
char screen [6912];
unsigned int *p_translt, *p_translt2;
unsigned char attribute, ink, paper, mask, octect;
int loop_x, loop_y,bucle,valor,*p ;
unsigned char *address;
if (filename==NULL) // Aborted
return;
if (!(ext_matches(filename, ".scr")||ext_matches(filename, ".SCR"))) return;
fichero=fopen(filename,"rb");
if (!fichero) return;
if (fread(screen,1,6912,fichero)!=6912) {fclose(fichero);return;}
fclose(fichero);
p_translt = ordenador.translate;
p_translt2 = ordenador.translate2;
for (loop_y=0; loop_y<192;loop_y++)
for(loop_x=0; loop_x<32; loop_x++)
{
attribute = screen[(*p_translt2)-147456]; // attribute
ink = attribute & 0x07; // ink colour
paper = (attribute >> 3) & 0x07; // paper colour
octect = screen[(*p_translt)-147456]; // bitmap
mask = 0x80;
for (bucle = 0; bucle < 8; bucle++)
{
valor = (octect & mask) ? (int) ink : (int) paper;
p=(colors+valor);
address = (unsigned char *)(ordenador.screen->pixels + (x + loop_x*8 + bucle + (y + loop_y)*640)*ordenador.bpp);
paint_one_pixel_scr((unsigned char *)p, address);
mask = ((mask >> 1) & 0x7F);
}
p_translt++;
p_translt2++;
}
}
static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_size, int draw_scr)
{ {
int font_height = TTF_FontHeight(p_menu->p_font); int font_height = TTF_FontHeight(p_menu->p_font);
int line_height = (font_height + font_height / 4); int line_height = (font_height + font_height / 4);
int x_start = p_menu->x1; int x_start = p_menu->x1;
int y_start = p_menu->y1 + line_height; int y_start = p_menu->y1 + line_height;
SDL_Rect r; SDL_Rect r;
int entries_visible = (p_menu->y2 - p_menu->y1) / line_height - 1; int entries_visible = (p_menu->y2 - p_menu->y1-5) / line_height - 1;
const char *selected_file = NULL;
int i, y; char filename[2049];
char name[512];
char *ptr;
int i, y, length;
if ( p_menu->n_entries * line_height > p_menu->y2 ) if ( p_menu->n_entries * line_height > p_menu->y2 )
y_start = p_menu->y1 + line_height; y_start = p_menu->y1 + line_height;
@ -563,8 +665,10 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
menu_print_font(screen, 0x40,0x40,0x40, menu_print_font(screen, 0x40,0x40,0x40,
x_start, y_start + y, msg, font_size); x_start, y_start + y, msg, font_size);
else if (p_menu->cur_sel == i) /* Selected - color */ else if (p_menu->cur_sel == i) /* Selected - color */
menu_print_font(screen, 0,200,0, {menu_print_font(screen, 0,200,0,
x_start, y_start + y, msg, font_size); x_start, y_start + y, msg, font_size);
selected_file = msg;
}
else if (IS_SUBMENU(msg)) else if (IS_SUBMENU(msg))
{ {
if (p_menu->cur_sel == i-1) if (p_menu->cur_sel == i-1)
@ -638,6 +742,47 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
} }
} }
} }
if ((draw_scr)&&(RATIO==1)) //Only in 640 mode
{
if ((!selected_file)||(selected_file[0] == '[')) return; //No dir
// Select after "/"
if (strrchr(selected_file, '/'))
strcpy(name, strrchr(selected_file, '/') + 1);
else strcpy(name,selected_file);
if ((ext_matches(name, ".zip")||ext_matches(name, ".ZIP")))
{
//remove the zip extension
ptr = strrchr (name, '.');
if (ptr) *ptr = 0;
}
//remove the other extensions
ptr = strrchr (name, '.');
if (ptr) *ptr = 0;
//Always load from SD card
strcpy(filename,getenv("HOME"));
length=strlen(filename);
if ((length>0)&&(filename[length-1]!='/'))
strcat(filename,"/");
strcat(filename, "scr/");
strcat(filename, name);
strcat(filename, ".scr");
draw_scr_file(370,52, filename);
strcpy(filename,getenv("HOME"));
length=strlen(filename);
if ((length>0)&&(filename[length-1]!='/'))
strcat(filename,"/");
strcat(filename, "scr2/");
strcat(filename, name);
strcat(filename, ".scr");
draw_scr_file(370,258, filename);
}
} }
static int get_next_seq_y(menu_t *p_menu, int v, int dy, int cicle) static int get_next_seq_y(menu_t *p_menu, int v, int dy, int cicle)
@ -899,17 +1044,12 @@ uint32_t menu_wait_key_press(void)
return keys; return keys;
} }
extern void PicDisplay(char *name, int off_x, int off_y, int wait);
extern const char **get_t64_list(char *t64);
extern const char **get_prg_list(char *t64);
extern char curdir[256]; extern char curdir[256];
static int menu_select_internal(SDL_Surface *screen, static int menu_select_internal(SDL_Surface *screen,
menu_t *p_menu, int *p_submenus, int sel, menu_t *p_menu, int *p_submenus, int sel,
void (*select_next_cb)(menu_t *p, void *data), void (*select_next_cb)(menu_t *p, void *data),
void *select_next_cb_data, int font_size) void *select_next_cb_data, int font_size, int draw_scr)
{ {
int ret = -1; int ret = -1;
int i; int i;
@ -926,7 +1066,7 @@ static int menu_select_internal(SDL_Surface *screen,
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff)); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
menu_draw(screen, p_menu, 0, font_size); menu_draw(screen, p_menu, 0, font_size, draw_scr);
SDL_Flip(screen); SDL_Flip(screen);
keys = menu_wait_key_press(); keys = menu_wait_key_press();
@ -967,7 +1107,7 @@ static int menu_select_internal(SDL_Surface *screen,
int menu_select_sized(const char *title, const char **msgs, int *submenus, int sel, int menu_select_sized(const char *title, const char **msgs, int *submenus, int sel,
int x, int y, int x2, int y2, int x, int y, int x2, int y2,
void (*select_next_cb)(menu_t *p, void *data), void (*select_next_cb)(menu_t *p, void *data),
void *select_next_cb_data, int font_size) void *select_next_cb_data, int font_size, int draw_scr)
{ {
menu_t menu; menu_t menu;
@ -987,7 +1127,7 @@ int menu_select_sized(const char *title, const char **msgs, int *submenus, int s
if (sel >= 0) if (sel >= 0)
select_one(&menu, sel); select_one(&menu, sel);
out = menu_select_internal(real_screen, &menu, submenus, sel, out = menu_select_internal(real_screen, &menu, submenus, sel,
select_next_cb, select_next_cb_data, font_size); select_next_cb, select_next_cb_data, font_size, draw_scr);
menu_fini(&menu); menu_fini(&menu);
@ -998,8 +1138,8 @@ int menu_select_title(const char *title, const char **msgs, int *submenus)
{ {
SDL_FillRect(real_screen, 0, SDL_MapRGB(real_screen->format, 0, 0, 0)); SDL_FillRect(real_screen, 0, SDL_MapRGB(real_screen->format, 0, 0, 0));
return menu_select_sized(title, msgs, submenus, 0, return menu_select_sized(title, msgs, submenus, 0,
32/RATIO, 32/RATIO, FULL_DISPLAY_X-32/RATIO, FULL_DISPLAY_Y-32/RATIO, 28/RATIO, 28/RATIO, FULL_DISPLAY_X-28/RATIO, FULL_DISPLAY_Y-28/RATIO,
NULL, NULL, 20); NULL, NULL, 20, 0);
} }
int menu_select(const char **msgs, int *submenus) int menu_select(const char **msgs, int *submenus)
@ -1008,7 +1148,7 @@ int menu_select(const char **msgs, int *submenus)
} }
static const char *menu_select_file_internal_zip(char *path, static const char *menu_select_file_internal_zip(char *path,
int x, int y, int x2, int y2, const char *selected_file, int which) int x, int y, int x2, int y2, const char *selected_file, int draw_scr)
{ {
const char **file_list = get_file_list_zip(path); const char **file_list = get_file_list_zip(path);
char *sel; char *sel;
@ -1026,9 +1166,9 @@ static const char *menu_select_file_internal_zip(char *path,
if (ptr_selected_file) ptr_selected_file++; if (ptr_selected_file) ptr_selected_file++;
else ptr_selected_file = selected_file; else ptr_selected_file = selected_file;
snprintf(buf,64,"file:%s",ptr_selected_file); snprintf(buf,64,"file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16); opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr);
} }
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16); else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
if (opt < 0) {free(path); return NULL;} if (opt < 0) {free(path); return NULL;}
@ -1124,7 +1264,7 @@ static const char *menu_select_file_internal_zip(char *path,
} }
static const char *menu_select_file_internal(const char *dir_path, static const char *menu_select_file_internal(const char *dir_path,
int x, int y, int x2, int y2, const char *selected_file, int which) int x, int y, int x2, int y2, const char *selected_file, int draw_scr)
{ {
const char **file_list = get_file_list(dir_path); const char **file_list = get_file_list(dir_path);
char *sel; char *sel;
@ -1144,9 +1284,9 @@ static const char *menu_select_file_internal(const char *dir_path,
if (ptr_selected_file) ptr_selected_file++; if (ptr_selected_file) ptr_selected_file++;
else ptr_selected_file = selected_file; else ptr_selected_file = selected_file;
snprintf(buf,64,"file:%s",ptr_selected_file); snprintf(buf,64,"file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16); opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr);
} }
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16); else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
if (opt < 0) if (opt < 0)
return NULL; return NULL;
@ -1175,7 +1315,7 @@ static const char *menu_select_file_internal(const char *dir_path,
/* Too deep recursion! */ /* Too deep recursion! */
if (s >= sizeof(buf)) if (s >= sizeof(buf))
return NULL; return NULL;
return menu_select_file(buf, selected_file, which); return menu_select_file(buf, selected_file, draw_scr);
} }
@ -1187,36 +1327,24 @@ static const char *menu_select_file_internal(const char *dir_path,
free(sel); free(sel);
if ((ext_matches(out, ".zip")||ext_matches(out, ".ZIP"))&&(tmpismade)) if ((ext_matches(out, ".zip")||ext_matches(out, ".ZIP"))&&(tmpismade))
{out_zip = (char *) menu_select_file_internal_zip (out, x, y, x2, y2, selected_file, which); {out_zip = (char *) menu_select_file_internal_zip (out, x, y, x2, y2, selected_file, draw_scr);
if (!out_zip) return NULL; if (!out_zip) return NULL;
if(!strcmp(out_zip,"[..]")) if(!strcmp(out_zip,"[..]"))
{ {
free(out_zip); free(out_zip);
return menu_select_file_internal (dir_path, x, y, x2, y2, selected_file, which); return menu_select_file_internal (dir_path, x, y, x2, y2, selected_file, draw_scr);
} }
else return out_zip; else return out_zip;
} }
else return out; else return out;
} }
/* const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr)
const char *menu_select_file_start(const char *dir_path, const char **d64_name)
{
const char *file = menu_select_file_internal(dir_path,
32, 32, FULL_DISPLAY_X, FULL_DISPLAY_Y - 32);
if (!file)
return NULL;
return file;
}
*/
const char *menu_select_file(const char *dir_path,const char *selected_file, int which)
{ {
if (dir_path == NULL) if (dir_path == NULL)
dir_path = ""; dir_path = "";
return menu_select_file_internal(dir_path, return menu_select_file_internal(dir_path,
0, 32/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 32/RATIO, selected_file, which); 0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, selected_file, draw_scr);
} }
static TTF_Font *read_font(const char *path, int font_size) static TTF_Font *read_font(const char *path, int font_size)

View File

@ -51,8 +51,8 @@ void print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const ch
/* Various option selects */ /* Various option selects */
int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus); int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus);
int menu_select(const char **pp_msgs, int *p_submenus); int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(const char *dir_path,const char *selected_file, int which); const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr);
const char *menu_select_file_start(const char *dir_path, const char **d64_name);
uint32_t menu_wait_key_press(void); uint32_t menu_wait_key_press(void);