Gui interface zx spectrum style, submenu for 48k mode 2 & 3

This commit is contained in:
fabio.olimpieri 2014-04-19 17:02:16 +00:00
parent 174bfed1c3
commit 64f2b1d511
7 changed files with 257 additions and 220 deletions

View File

@ -134,7 +134,8 @@ dist: $(BUILD)
cp images/symbol_shift_small.png $@/fbzx-wii/fbzx cp images/symbol_shift_small.png $@/fbzx-wii/fbzx
cp images/caps_shift_small.png $@/fbzx-wii/fbzx cp images/caps_shift_small.png $@/fbzx-wii/fbzx
cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx
cp images/FreeMono.ttf $@/fbzx-wii/fbzx cp images/ZX_Spectrum.ttf $@/fbzx-wii/fbzx
cp images/ZX_Spectrum_narrow.ttf $@/fbzx-wii/fbzx
cp fbzx.net $@/fbzx-wii cp fbzx.net $@/fbzx-wii
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc
touch $@/fbzx-wii/tapes/dummy touch $@/fbzx-wii/tapes/dummy

View File

@ -144,7 +144,8 @@ dist: $(BUILD)
cp images/symbol_shift_small.png $@/fbzx-wii/fbzx cp images/symbol_shift_small.png $@/fbzx-wii/fbzx
cp images/caps_shift_small.png $@/fbzx-wii/fbzx cp images/caps_shift_small.png $@/fbzx-wii/fbzx
cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx
cp images/FreeMono.ttf $@/fbzx-wii/fbzx cp images/ZX_Spectrum.ttf $@/fbzx-wii/fbzx
cp images/ZX_Spectrum_narrow.ttf $@/fbzx-wii/fbzx
cp fbzx.net $@/fbzx-wii cp fbzx.net $@/fbzx-wii
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/fbzx-wii/doc cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/fbzx-wii/doc
touch $@/fbzx-wii/tapes/dummy touch $@/fbzx-wii/tapes/dummy

BIN
images/ZX_Spectrum.ttf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -59,32 +59,36 @@ void clean_screen();
static const char *main_menu_messages[] = { static const char *main_menu_messages[] = {
/*00*/ "Tape", /*00*/ "Tape",
/*01*/ "^|Insert|Load|Play|Stop|Rewind|Create|Del|Browse", /*01*/ "^|Ins|Load|Play|Stop|Rew|Make|Del|Brows",
/*02*/ "Snapshot", /*02*/ "Snapshot",
/*03*/ "^|Load|Save|Delete", /*03*/ "^|Load|Save|Delete",
/*04*/ "Wiimote configuration", /*04*/ "#1----------------------------------------",
/*05*/ "^|Wiimote1|Wiimote2", /*05*/ "Wiimote configuration",
/*06*/ "Tape settings", /*06*/ "^|Wiimote1|Wiimote2",
/*07*/ "Emulation settings", /*07*/ "Tape settings",
/*08*/ "Screen settings", /*08*/ "Emulation settings",
/*09*/ "Audio settings", /*09*/ "Screen settings",
/*10*/ "Config files", /*10*/ "Audio settings",
/*11*/ "Microdrive", /*11*/ "Config files",
/*12*/ "Tools", /*12*/ "Microdrive",
/*13*/ "Reset", /*13*/ "Tools",
/*14*/ "Quit", /*14*/ "Reset",
/*15*/ "Quit",
NULL NULL
}; };
static const char *emulation_messages[] = { static const char *emulation_messages[] = {
/*00*/ "Emulated machine", /*00*/ "Emulated machine",
/*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC", /*01*/ "^|48K|128K|+2|+2A/+3|128K_SP|48K_NTSC",
/*02*/ " ", /*02*/ " ",
/*03*/ "Frame rate", /*03*/ "48K model",
/*04*/ "^|100%|50%|33%|25%|20%", /*04*/ "^|issue2|issue3",
/*05*/ " ", /*05*/ " ",
/*06*/ "Precision", /*06*/ "Frame rate",
/*07*/ "^|on|off", /*07*/ "^|100%|50%|33%|25%|20%",
/*08*/ " ",
/*09*/ "Precision",
/*10*/ "^|on|off",
NULL NULL
}; };
@ -125,7 +129,7 @@ static const char *screen_messages[] = {
/*03*/ "TV mode", /*03*/ "TV mode",
/*04*/ "^|Color|B&W|Green", /*04*/ "^|Color|B&W|Green",
/*05*/ " ", /*05*/ " ",
/*06*/ "Buffer resolution", /*06*/ "Screen resolution",
/*07*/ "^|640X480|320X240", /*07*/ "^|640X480|320X240",
/*08* " ", /*08* " ",
*09* "576p video mode", *09* "576p video mode",
@ -135,7 +139,7 @@ static const char *screen_messages[] = {
static const char *input_messages[] = { static const char *input_messages[] = {
/*00*/ "Joystick type", /*00*/ "Joystick type",
/*01*/ "^|Cursor|Kempston|Sinclair1|Sinclair2|QAOP", /*01*/ "^|Cursor|Kempston|Sincl1|Sincl2|QAOP",
/*02*/ "Bind key to Wiimote", /*02*/ "Bind key to Wiimote",
/*03*/ "^|A|B|1|2|-|+", /*03*/ "^|A|B|1|2|-|+",
/*04*/ "Bind key to Nunchuk", /*04*/ "Bind key to Nunchuk",
@ -153,7 +157,7 @@ static const char *input_messages[] = {
static const char *microdrive_messages[] = { static const char *microdrive_messages[] = {
/*00*/ "Microdrive", /*00*/ "Microdrive",
/*01*/ "^|Insert|Create|Delete", /*01*/ "^|Insert|Make|Delete",
/*02*/ " ", /*02*/ " ",
/*03*/ "Interface I", /*03*/ "Interface I",
/*04*/ "^|on|off", /*04*/ "^|on|off",
@ -182,18 +186,18 @@ static const char *tools_messages[] = {
}; };
static const char *help_messages[] = { static const char *help_messages[] = {
/*00*/ "#2HOME enters the menu system, where arrow keys", /*00*/ "#2HOME enters the menu system where pad",
/*01*/ "#2and nunchuck are used to navigate up and down.", /*01*/ "#2and nunchuck are used to navigate.",
/*02*/ "#2You can bind keyboard keys to the wiimote", /*02*/ "#2You can bind keyboard keys to the ",
/*03*/ "#2buttons in the 'Wiimote' menu and", /*03*/ "#2wiimote buttons and change the",
/*04*/ "#2change emulation options in the Settings menu.", /*04*/ "#2emulation options.",
/*05*/ "#2 ", /*05*/ "#2 ",
/*06*/ "#2The easiest way to play a game is to load", /*06*/ "#2The easiest way to play a game is to ",
/*07*/ "#2a snapshot (.z80 and .sna files).", /*07*/ "#2load a snapshot (.z80 and .sna files).",
/*08*/ "#2You can also insert a tape file (.tap and .tzx)", /*08*/ "#2You can also insert a tape file",
/*09*/ "#2and then load the file in the tape menu.", /*09*/ "#2and load it in the tape menu.",
/*10*/ "#2 ", /*10*/ "#2 ",
/*11*/ "#2More information is available on the wiki:", /*11*/ "#2More information is available in",
/*12*/ "#2 http://wiibrew.org/wiki/FBZX_Wii", /*12*/ "#2 http://wiibrew.org/wiki/FBZX_Wii",
/*13*/ "#2 ", /*13*/ "#2 ",
/*14*/ "OK", /*14*/ "OK",
@ -351,7 +355,7 @@ static void delete_tape()
if ((ext_matches(filename, ".tap")|ext_matches(filename, ".TAP")|ext_matches(filename, ".tzx")| if ((ext_matches(filename, ".tap")|ext_matches(filename, ".TAP")|ext_matches(filename, ".tzx")|
ext_matches(filename, ".TZX")) ext_matches(filename, ".TZX"))
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename); && (msgYesNo("Delete the file?", 0, -1, -1))) unlink(filename);
free((void *)filename); free((void *)filename);
} }
@ -529,53 +533,45 @@ static int manage_tape(int which)
static unsigned int get_machine_model(void) static unsigned int get_machine_model(void)
{ {
if (ordenador.videosystem == 0) if (ordenador.videosystem == 0)
return (ordenador.mode128k + (ordenador.issue==3)); return (ordenador.mode128k);
else return (6); else return (5);
} }
static void set_machine_model(int which) static void set_machine_model(int which)
{ {
switch (which) switch (which)
{ {
case 0: //48k issue2 case 0: //48k
ordenador.issue=2;
ordenador.mode128k=0; ordenador.mode128k=0;
ordenador.ay_emul=0; ordenador.ay_emul=0;
ordenador.videosystem =0; ordenador.videosystem =0;
break; break;
case 1: //48k issue3 case 1: //128k
ordenador.issue=3;
ordenador.mode128k=0;
ordenador.ay_emul=0;
ordenador.videosystem =0;
break;
case 2: //128k
ordenador.issue=3; ordenador.issue=3;
ordenador.mode128k=1; ordenador.mode128k=1;
ordenador.ay_emul=1; ordenador.ay_emul=1;
ordenador.videosystem =0; ordenador.videosystem =0;
break; break;
case 3: //Amstrad +2 case 2: //Amstrad +2
ordenador.issue=3; ordenador.issue=3;
ordenador.mode128k=2; ordenador.mode128k=2;
ordenador.ay_emul=1; ordenador.ay_emul=1;
ordenador.videosystem =0; ordenador.videosystem =0;
break; break;
case 4: //Amstrad +2A/+3 case 3: //Amstrad +2A/+3
ordenador.issue=3; ordenador.issue=3;
ordenador.mode128k=3; ordenador.mode128k=3;
ordenador.ay_emul=1; ordenador.ay_emul=1;
ordenador.mdr_active=0; ordenador.mdr_active=0;
ordenador.videosystem =0; ordenador.videosystem =0;
break; break;
case 5: //128K Spanish case 4: //128K Spanish
ordenador.issue=3; ordenador.issue=3;
ordenador.mode128k=4; ordenador.mode128k=4;
ordenador.ay_emul=1; ordenador.ay_emul=1;
ordenador.videosystem =0; ordenador.videosystem =0;
break; break;
case 6: //48k ntsc case 5: //48k ntsc
ordenador.issue=3;
ordenador.mode128k=0; ordenador.mode128k=0;
ordenador.ay_emul=0; ordenador.ay_emul=0;
ordenador.videosystem =1; ordenador.videosystem =1;
@ -585,19 +581,20 @@ static void set_machine_model(int which)
static int emulation_settings(void) static int emulation_settings(void)
{ {
unsigned int submenus[3],submenus_old[3]; unsigned int submenus[4],submenus_old[4];
int opt, i, retorno; int opt, i, retorno;
unsigned char old_mode, old_videosystem; unsigned char old_mode, old_videosystem;
retorno=-1; //exit to the previous menue retorno=-1; //exit to the previous menu
memset(submenus, 0, sizeof(submenus)); memset(submenus, 0, sizeof(submenus));
submenus[0] = get_machine_model(); submenus[0] = get_machine_model();
submenus[1] = jump_frames; submenus[1] = ordenador.issue-2;
submenus[2] = !ordenador.precision; submenus[2] = jump_frames;
submenus[3] = !ordenador.precision;
for (i=0; i<3; i++) submenus_old[i] = submenus[i]; for (i=0; i<4; i++) submenus_old[i] = submenus[i];
old_mode=ordenador.mode128k; old_mode=ordenador.mode128k;
old_videosystem = ordenador.videosystem; old_videosystem = ordenador.videosystem;
@ -606,16 +603,18 @@ static int emulation_settings(void)
if (opt < 0) if (opt < 0)
return retorno; return retorno;
curr_frames=0;
if (submenus[0]!=submenus_old[0]) set_machine_model(submenus[0]); if (submenus[0]!=submenus_old[0]) set_machine_model(submenus[0]);
if ((old_mode!=ordenador.mode128k)||(old_videosystem!=ordenador.videosystem)) {ResetComputer(); retorno=-2;} if ((old_mode!=ordenador.mode128k)||(old_videosystem!=ordenador.videosystem)) {ResetComputer(); retorno=-2;}
curr_frames=0; if (ordenador.mode128k==0) ordenador.issue= submenus[1]+2; else ordenador.issue = 3;
jump_frames = submenus[1]; jump_frames = submenus[2];
if (submenus[2] != submenus_old[2]) if (submenus[3] != submenus_old[3])
{ {
ordenador.precision = !submenus[2]; ordenador.precision = !submenus[3];
ordenador.precision_old=ordenador.precision; ordenador.precision_old=ordenador.precision;
if (ordenador.turbo_state!=1) //Tape is not loading with auto mode if (ordenador.turbo_state!=1) //Tape is not loading with auto mode
if (ordenador.precision) if (ordenador.precision)
@ -942,7 +941,7 @@ static void delete_mdr()
return; return;
if ((ext_matches(filename, ".mdr")|ext_matches(filename, ".MDR")) if ((ext_matches(filename, ".mdr")|ext_matches(filename, ".MDR"))
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename); && (msgYesNo("Delete the file?", 0,-1, -1))) unlink(filename);
free((void *)filename); free((void *)filename);
} }
@ -1074,7 +1073,7 @@ static void delete_scr()
return; return;
if ((ext_matches(filename, ".scr")|ext_matches(filename, ".SCR")) 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); && (msgYesNo("Delete the file?", 0, -1, -1))) unlink(filename);
free((void *)filename); free((void *)filename);
} }
@ -1171,7 +1170,7 @@ static int save_scr(int i)
if(fichero!=NULL) if(fichero!=NULL)
{ {
fclose(fichero); fclose(fichero);
if (!msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) if (!msgYesNo("Overwrite the exiting file?", 0, -1, -1))
return 0; // file already exists return 0; // file already exists
} }
@ -1382,16 +1381,21 @@ int parse_poke (const char *filename)
FILE* fpoke; FILE* fpoke;
unsigned char title[128], flag, newfile, restore, old_mport1; unsigned char title[128], flag, newfile, restore, old_mport1;
int bank, address, value, original_value, ritorno,y,k, trainer, poke; int bank, address, value, original_value, ritorno,y,k, trainer, poke;
SDL_Rect src, banner; SDL_Rect src, banner, src_ext;
src.x=0; src.x=2/RATIO;
src.y=30/RATIO; src.y=28/RATIO;
src.w=FULL_DISPLAY_X; src.w=FULL_DISPLAY_X-4/RATIO;
src.h=FULL_DISPLAY_Y-60/RATIO; src.h=FULL_DISPLAY_Y-56/RATIO;
banner.x=0; src_ext.x=0;
src_ext.y=26/RATIO;
src_ext.w=FULL_DISPLAY_X;
src_ext.h=FULL_DISPLAY_Y-52/RATIO;
banner.x=2/RATIO;
banner.y=30/RATIO; banner.y=30/RATIO;
banner.w=FULL_DISPLAY_X; banner.w=FULL_DISPLAY_X-4/RATIO;
banner.h=20/RATIO; banner.h=20/RATIO;
y=60/RATIO; y=60/RATIO;
@ -1410,9 +1414,10 @@ int parse_poke (const char *filename)
clean_screen(); clean_screen();
SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff)); SDL_FillRect(screen, &src_ext, SDL_MapRGB(screen->format, 220, 220, 0));
SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0, 0, 0));
print_font(screen, 0x0, 0x0, 0x0,0, 30/RATIO, "Press 1 to deselect, 2 to select", 16); print_font(screen, 255, 255, 255,4/RATIO, 30/RATIO, "Press 1 to deselect, 2 to select", 16);
ritorno=0; ritorno=0;
do do
@ -1427,11 +1432,15 @@ int parse_poke (const char *filename)
if (strlen(title)>1) title[strlen(title)-2]='\0'; //cancel new line and line feed if (strlen(title)>1) title[strlen(title)-2]='\0'; //cancel new line and line feed
if (y>420/RATIO) {SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));y=40/RATIO;} if (y>420/RATIO) {SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0, 0, 0));y=40/RATIO;}
if (newfile) print_font(screen, 0x80, 0x80, 0x80,0, y, title+1, 16); banner.y=y-2/RATIO;
else {if (old_poke[trainer][0]==0) print_font(screen, 0xd0, 0, 0,0, y, title+1, 16); //In row 0 information on trainer selection
else print_font(screen, 0, 0xd0, 0,0, y, title+1, 16);} SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0, 200, 200));
if (newfile) print_font(screen, 0, 0, 0,4/RATIO, y, title+1, 16);
else {if (old_poke[trainer][0]==0) print_font(screen, 220, 0, 0,4/RATIO, y, title+1, 16); //In row 0 information on trainer selection
else print_font(screen, 0, 250, 0,4/RATIO, y, title+1, 16);}
SDL_Flip(screen); SDL_Flip(screen);
k=0; k=0;
@ -1439,19 +1448,17 @@ int parse_poke (const char *filename)
while (!((k & KEY_ESCAPE)||(k & KEY_SELECT))) while (!((k & KEY_ESCAPE)||(k & KEY_SELECT)))
{k = menu_wait_key_press();} {k = menu_wait_key_press();}
banner.y=y; SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
if (k & KEY_SELECT) if (k & KEY_SELECT)
{ {
print_font(screen, 0, 0x40, 0,0, y, title+1, 16); print_font(screen, 0, 220, 0,4/RATIO, y, title+1, 16);
old_poke[trainer][0]=1; old_poke[trainer][0]=1;
} }
else else
{ {
if ((!newfile)&&(old_poke[trainer][0]==1)) restore=1; if ((!newfile)&&(old_poke[trainer][0]==1)) restore=1;
print_font(screen, 0x80, 0, 0,0, y, title+1, 16); print_font(screen, 220, 0, 0,4/RATIO, y, title+1, 16);
old_poke[trainer][0]=0; old_poke[trainer][0]=0;
} }
@ -1707,7 +1714,7 @@ static int save_load_snapshot(int which)
} }
} }
else // Delete snashot file else // Delete snashot file
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(filename); if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(filename);
} }
free((void*)filename); free((void*)filename);
} break; } break;
@ -1722,7 +1729,7 @@ static int save_load_snapshot(int which)
retorno2=-1; retorno2=-1;
break; break;
case -1: case -1:
if (msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) if (msgYesNo("Overwrite the exiting file?", 0, -1, -1))
{ {
save_z80(db,1); //force overwrite save_z80(db,1); //force overwrite
msgInfo("Snapshot saved",3000,NULL); msgInfo("Snapshot saved",3000,NULL);
@ -1769,7 +1776,7 @@ static int save_load_game_configurations(int which)
if (!load_config(&ordenador,(char *)filename)) {msgInfo("Game confs loaded",3000,NULL);retorno2=-1;} if (!load_config(&ordenador,(char *)filename)) {msgInfo("Game confs loaded",3000,NULL);retorno2=-1;}
} }
else // Delete config file else // Delete config file
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(filename); if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(filename);
} }
free((void*)filename); free((void*)filename);
} break; } break;
@ -1800,7 +1807,7 @@ static int save_load_game_configurations(int which)
retorno2=-1; retorno2=-1;
break; break;
case -1: case -1:
if (msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) if (msgYesNo("Overwrite the exiting file?", 0, -1, -1))
{ {
save_config_game(&ordenador,db,1); //force overwrite save_config_game(&ordenador,db,1); //force overwrite
msgInfo("Game confs saved",3000,NULL); msgInfo("Game confs saved",3000,NULL);
@ -1840,7 +1847,7 @@ static void save_load_general_configurations(int which)
fconfig = fopen(config_path,"rb"); fconfig = fopen(config_path,"rb");
if (fconfig==NULL) if (fconfig==NULL)
{ {
msgInfo("Can not access the file",3000,NULL); msgInfo("Can't access the file",3000,NULL);
return; return;
} }
else fclose(fconfig); else fclose(fconfig);
@ -1855,7 +1862,7 @@ static void save_load_general_configurations(int which)
break; break;
} }
else // Delete config file else // Delete config file
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(config_path); if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(config_path);
} break; } break;
case 1: // Save configuration file case 1: // Save configuration file
@ -1935,36 +1942,36 @@ void main_menu()
case 2: case 2:
retorno = save_load_snapshot(submenus[1]); retorno = save_load_snapshot(submenus[1]);
break; break;
case 4: case 5:
input_options(submenus[2]); input_options(submenus[2]);
break; break;
case 6: case 7:
tape_settings(); tape_settings();
break; break;
case 7: case 8:
if (emulation_settings()==-2) retorno=-1; if (emulation_settings()==-2) retorno=-1;
break; break;
case 8: case 9:
screen_settings(); screen_settings();
break; break;
case 9: case 10:
audio_settings(); audio_settings();
break; break;
case 10: case 11:
manage_configurations(); manage_configurations();
break; break;
case 11: case 12:
microdrive(); microdrive();
break; break;
case 12: case 13:
if (tools()==-2) retorno=-1; if (tools()==-2) retorno=-1;
break; break;
case 13: case 14:
ResetComputer (); ResetComputer ();
retorno=-1; retorno=-1;
break; break;
case 14: case 15:
if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) if (msgYesNo("Are you sure to quit?", 0, -1, -1))
{salir = 0;retorno=-1;} {salir = 0;retorno=-1;}
break; break;
default: default:

View File

@ -88,35 +88,37 @@ static SDL_Surface *real_screen;
#define IS_MARKER(p_msg) ( (p_msg)[0] == '@' ) #define IS_MARKER(p_msg) ( (p_msg)[0] == '@' )
static int is_inited = 0; static int is_inited = 0;
static TTF_Font *menu_font16, *menu_font20, *menu_font8, *menu_font10; static TTF_Font *menu_font_alt_large, *menu_font_large, *menu_font_alt_small, *menu_font_small;
int fh, fw; int fh, fw;
int msgInfo(char *text, int duration, SDL_Rect *irc) int msgInfo(char *text, int duration, SDL_Rect *irc)
{ {
int len = strlen(text); int len = strlen(text);
int X, Y; int X, Y, w, h;
SDL_Rect src; SDL_Rect src;
SDL_Rect rc; SDL_Rect rc;
SDL_Rect brc; SDL_Rect brc;
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*12/RATIO; if (RATIO==1) TTF_SizeText(menu_font_large, "Z", &w, &h); else TTF_SizeText(menu_font_small, "Z", &w, &h);
Y = (FULL_DISPLAY_Y /2) - 24/RATIO;
brc.x = FULL_DISPLAY_X/2-2*12/RATIO; X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*w;
brc.y=Y+42/RATIO; Y = (FULL_DISPLAY_Y /2) - h;
brc.w=48/RATIO;
brc.h=20/RATIO; brc.x = FULL_DISPLAY_X/2-2*w-2/RATIO;
brc.y=Y+h*2-4/RATIO;
brc.w=w*4;
brc.h=h*3/2;
rc.x = X; rc.x = X;
rc.y=Y; rc.y=Y;
rc.w=12*(len + 2)/RATIO; rc.w=w*(len + 2);
rc.h=duration >= 0 ? 48/RATIO : 80/RATIO; rc.h=duration >= 0 ? h*2 : h*4;
src.x=rc.x+4/RATIO; src.x=rc.x+2/RATIO;
src.y=rc.y+4/RATIO; src.y=rc.y+2/RATIO;
src.w=rc.w; src.w=rc.w-4/RATIO;
src.h=rc.h; src.h=rc.h-4/RATIO;
if (irc) if (irc)
@ -126,9 +128,9 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
irc->w=src.w; irc->w=src.w;
irc->h=src.h; irc->h=src.h;
} }
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 0, 96, 0)); SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 220, 220, 0));
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 128, 128, 128)); SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 255, 255, 255));
menu_print_font(real_screen, 255,255,255, X+12/RATIO, Y+12/RATIO, text,20,64); menu_print_font(real_screen, 0,0,0, X+w, Y+h/2, text,20,64);
SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h); SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h);
SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h); SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h);
if (duration > 0) if (duration > 0)
@ -136,7 +138,7 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
else if (duration < 0) else if (duration < 0)
{ {
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00)); SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00));
menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-12/RATIO, Y+42/RATIO, "OK",20,64); menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-w, Y+h*2, "OK",20,64);
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h); SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h);
while (!(KEY_SELECT & menu_wait_key_press())) {} while (!(KEY_SELECT & menu_wait_key_press())) {}
@ -155,57 +157,59 @@ void msgKill(SDL_Rect *rc)
int msgYesNo(char *text, int default_opt, int x, int y) int msgYesNo(char *text, int default_opt, int x, int y)
{ {
int len = strlen(text); int len = strlen(text);
int X, Y; int X, Y, w, h;
SDL_Rect src; SDL_Rect src;
SDL_Rect rc; SDL_Rect rc;
SDL_Rect brc; SDL_Rect brc;
uint32_t key; uint32_t key;
if (RATIO==1) TTF_SizeText(menu_font_large, "Z", &w, &h); else TTF_SizeText(menu_font_small, "Z", &w, &h);
if (x < 0) if (x < 0)
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*12/RATIO; X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*w;
else else
X = x; X = x;
if (y < 0) if (y < 0)
Y = (FULL_DISPLAY_Y /2) - 48/RATIO; Y = (FULL_DISPLAY_Y /2) - h*2;
else else
Y = y; Y = y;
rc.x=X; rc.x=X;
rc.y=Y; rc.y=Y;
rc.w=12*(len + 2)/RATIO; rc.w=w*(len + 2);
rc.h=80/RATIO; rc.h=h*4;
src.x=rc.x+4/RATIO; src.x=rc.x+2/RATIO;
src.y=rc.y+4/RATIO; src.y=rc.y+2/RATIO;
src.w=rc.w; src.w=rc.w-4/RATIO;
src.h=rc.h; src.h=rc.h-4/RATIO;
while (1) while (1)
{ {
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 0, 96, 0)); SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 220, 220, 0));
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 128, 128, 128)); SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 255, 255, 255));
menu_print_font(real_screen, 255,255,255, X+12/RATIO, Y+12/RATIO, text,20,64); menu_print_font(real_screen, 0,0,0, X+w, Y+h/2, text,20,64);
if (default_opt) if (default_opt) //"YES"
{ {
brc.x=rc.x + rc.w/2-5*12/RATIO; brc.x=rc.x + rc.w/2-5*w-2/RATIO;
brc.y=rc.y+42/RATIO; brc.y=rc.y+h*2-4/RATIO;
brc.w=12*3/RATIO; brc.w=w*3;
brc.h=20/RATIO; brc.h=h*3/2;
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00)); SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 220, 0x00));
} }
else else //"NO"
{ {
brc.x=rc.x + rc.w/2+5*12/RATIO-2*12/RATIO-6/RATIO; brc.x=rc.x + rc.w/2+5*w-2*w-2/RATIO;
brc.y=rc.y+42/RATIO; brc.y=rc.y+h*2-4/RATIO;
brc.w=12*3/RATIO; brc.w=w*2;
brc.h=20/RATIO; brc.h=h*3/2;
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x80, 0x00, 0x00)); SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 255, 0x00, 0x00));
} }
menu_print_font(real_screen, 255,255,255, rc.x + rc.w/2-5*12/RATIO, Y+42/RATIO, "YES",20,64); menu_print_font(real_screen, 0,0,0, rc.x + rc.w/2-5*w, Y+h*2, "YES",20,64);
menu_print_font(real_screen, 255,255,255, rc.x + rc.w/2-5*12/RATIO+8*12/RATIO, Y+42/RATIO, "NO",20,64); menu_print_font(real_screen, 0,0,0, rc.x + rc.w/2+5*w-2*w, Y+h*2, "NO",20,64);
SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h); SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h);
SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h); SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h);
@ -415,17 +419,18 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
SDL_Rect dst = {x, y, 0, 0}; SDL_Rect dst = {x, y, 0, 0};
SDL_Color color = {r, g, b, 0}; SDL_Color color = {r, g, b, 0};
char buf[255]; char buf[255];
unsigned int i, lenght; unsigned int i, length;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
strncpy(buf, msg, 254); strncpy(buf, msg, 254);
if (buf[0] != '|' && buf[0] != '^' && buf[0] != '.' if (buf[0] != '|' && buf[0] != '^' && buf[0] != '.'
&& buf[0] != '-' && buf[0] != ' ' && !strstr(buf, " \"")) && buf[0] != '-' && buf[0] != ' ' && !strstr(buf, " \""))
{ {
lenght = strlen(buf); length = strlen(buf);
if (lenght>max_string) if (length>max_string)
{ {
strcpy (buf + max_string-8, buf + lenght-8); if (buf[length-8]== '.') strcpy (buf + max_string-8, buf + length-8);
else strcpy (buf + max_string-4, buf + length-4);
} }
} }
/* Fixup multi-menu option look */ /* Fixup multi-menu option look */
@ -437,13 +442,13 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
if (FULL_DISPLAY_X == 640) if (FULL_DISPLAY_X == 640)
{ {
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font16, buf, color); if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_large, buf, color);
else font_surf = TTF_RenderUTF8_Blended(menu_font20, buf, color); else font_surf = TTF_RenderUTF8_Blended(menu_font_large, buf, color);
} }
else else
{ {
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font8, buf, color); if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_small, buf, color);
else font_surf = TTF_RenderUTF8_Blended(menu_font10, buf, color); else font_surf = TTF_RenderUTF8_Blended(menu_font_small, buf, color);
} }
if (!font_surf) if (!font_surf)
@ -459,7 +464,7 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
void print_font(SDL_Surface *screen, int r, int g, int b, void print_font(SDL_Surface *screen, int r, int g, int b,
int x, int y, const char *msg, int font_size) int x, int y, const char *msg, int font_size)
{ {
#define _MAX_STRING 64 #define _MAX_STRING 52
SDL_Surface *font_surf; SDL_Surface *font_surf;
SDL_Rect dst = {x, y, 0, 0}; SDL_Rect dst = {x, y, 0, 0};
SDL_Color color = {r, g, b, 0}; SDL_Color color = {r, g, b, 0};
@ -477,13 +482,13 @@ void print_font(SDL_Surface *screen, int r, int g, int b,
if (FULL_DISPLAY_X == 640) if (FULL_DISPLAY_X == 640)
{ {
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font16, buf, color); if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_large, buf, color);
else font_surf = TTF_RenderUTF8_Blended(menu_font20, buf, color); else font_surf = TTF_RenderUTF8_Blended(menu_font_large, buf, color);
} }
else else
{ {
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font8, buf, color); if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_small, buf, color);
else font_surf = TTF_RenderUTF8_Blended(menu_font10, buf, color); else font_surf = TTF_RenderUTF8_Blended(menu_font_small, buf, color);
} }
if (!font_surf) if (!font_surf)
@ -552,22 +557,23 @@ void draw_scr_file(int x,int y, char *filename)
static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_size, int draw_scr) 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 / 2);
int x_start = p_menu->x1; int line_height = 22/ RATIO;
int y_start = p_menu->y1 + line_height; int x_start = p_menu->x1+4/RATIO;
int y_start = p_menu->y1 + line_height+4/RATIO;
SDL_Rect r; SDL_Rect r;
int entries_visible = (p_menu->y2 - p_menu->y1-5) / line_height - 1; int entries_visible = (p_menu->y2 - p_menu->y1-10/RATIO) / line_height - 1;
const char *selected_file = NULL; const char *selected_file = NULL;
char filename[MAX_PATH_LENGTH]; char filename[MAX_PATH_LENGTH];
char name[MAX_PATH_LENGTH]; char name[MAX_PATH_LENGTH];
char *ptr; char *ptr;
int i, y, length, max_string; int i, y, length, max_string;
if (draw_scr) max_string = 35; else max_string = 64; if ((draw_scr)&&(RATIO==1)) max_string = 30; else max_string = 46;
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;
if (p_menu->cur_sel - p_menu->start_entry_visible > entries_visible) if (p_menu->cur_sel - p_menu->start_entry_visible > entries_visible)
{ {
@ -589,12 +595,12 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
r.x = p_menu->x1; r.x = p_menu->x1;
r.y = p_menu->y1; r.y = p_menu->y1;
r.w = p_menu->x2 - p_menu->x1; r.w = p_menu->x2 - p_menu->x1;
r.h = line_height-1; r.h = line_height;
if (sel < 0) if (sel < 0)
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x40, 0x00, 0x00)); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x40, 0x00, 0x00));
else else
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Title SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Title
menu_print_font(screen, 0,0,0, p_menu->x1, p_menu->y1, p_menu->title, font_size, 52); menu_print_font(screen, 0,0,0, p_menu->x1+4/RATIO, p_menu->y1+4/RATIO, p_menu->title, font_size, 50);
} }
for (i = p_menu->start_entry_visible; i <= p_menu->start_entry_visible + entries_visible; i++) for (i = p_menu->start_entry_visible; i <= p_menu->start_entry_visible + entries_visible; i++)
@ -608,27 +614,37 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
else else
{ {
y = (i - p_menu->start_entry_visible) * line_height; y = (i - p_menu->start_entry_visible) * line_height;
r.x = p_menu->x1+2/RATIO;
r.y = p_menu->y1 + line_height +y;
if ((draw_scr)&&(RATIO==1)) r.w = 365; //Only in 640 mode
else r.w = p_menu->x2 - p_menu->x1-4/RATIO;
r.h = line_height;
if (sel < 0) if (sel < 0)
menu_print_font(screen, 0x40,0x40,0x40, //Not used menu_print_font(screen, 0x40,0x40,0x40, //Not used
x_start, y_start + y, msg, font_size, max_string); x_start, y_start + y, msg, font_size, max_string);
else if (p_menu->cur_sel == i) /* Selected - color */ else if (p_menu->cur_sel == i) /* Selected - color */
{ {
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 220, 220));
if (msg[0] == ']') if (msg[0] == ']')
menu_print_font(screen, 0,200,0, //Selected menu entry begining with ']' (tape browser) menu_print_font(screen, 0,0,0, //Selected menu entry begining with ']' (tape browser)
x_start, y_start + y, msg+1, font_size,max_string ); //do not show ']' x_start, y_start + y, msg+1, font_size,max_string ); //do not show ']'
else else
menu_print_font(screen, 0,200,0, //Selected menu entry menu_print_font(screen, 0,0,0, //Selected menu entry
x_start, y_start + y, msg, font_size,max_string ); x_start, y_start + y, msg, font_size,max_string );
selected_file = msg; 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)
menu_print_font(screen, 0,200,0, //Selected sub menu entry {
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 220, 220));
menu_print_font(screen, 0,0,0, //Selected sub menu entry
x_start, y_start + y, msg, font_size, max_string); x_start, y_start + y, msg, font_size, max_string);
}
else else
menu_print_font(screen, 0x40,0x40,0x40, //Non selected sub menu entry menu_print_font(screen, 255,255,255, //Non selected sub menu entry
x_start, y_start + y, msg, font_size, max_string); x_start, y_start + y, msg, font_size, max_string);
} }
else if (msg[0] == '#') else if (msg[0] == '#')
@ -636,11 +652,11 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
switch (msg[1]) switch (msg[1])
{ {
case '1': case '1':
menu_print_font(screen, 0,0,255, //Text 1 menu_print_font(screen, 220,220,0, //Text 1
x_start, y_start + y, msg+2, font_size, max_string); x_start, y_start + y, msg+2, font_size, max_string);
break; break;
case '2': case '2':
menu_print_font(screen, 0x40,0x40,0x40, //Text 2 menu_print_font(screen, 255,255,255, //Text 2
x_start, y_start + y, msg+2, font_size, max_string); x_start, y_start + y, msg+2, font_size, max_string);
break; break;
default: default:
@ -650,11 +666,11 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
} }
} }
else if (msg[0] == ']') else if (msg[0] == ']')
menu_print_font(screen, 0,0,255, //Non selected menu entry starting with ']' (tape browser) menu_print_font(screen, 220,0,0, //Non selected menu entry starting with ']' (tape browser)
x_start, y_start + y, msg+1, font_size, max_string); x_start, y_start + y, msg+1, font_size, max_string);
else /* Otherwise white */ else /* Otherwise white */
menu_print_font(screen, 0x40,0x40,0x40, //Non selected menu entry menu_print_font(screen, 255,255,255, //Non selected menu entry
x_start, y_start + y, msg, font_size, max_string); x_start, y_start + y, msg, font_size, max_string);
if (IS_SUBMENU(msg)) if (IS_SUBMENU(msg))
{ {
@ -677,21 +693,19 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
int w; int w;
int h; int h;
if (TTF_SizeText(p_menu->p_font, "X", &w, &h) < 0) if (TTF_SizeText(p_menu->p_font, "Z", &w, &h) < 0)
{ {
fw = w;
fh = h;
fprintf(stderr, "%s\n", TTF_GetError()); fprintf(stderr, "%s\n", TTF_GetError());
exit(1); exit(1);
} }
r = (SDL_Rect){ x_start + (n+1) * w-1, y_start + (i+ 1 - p_menu->start_entry_visible) * ((h + h/4)) -3, (n_chars - 1) * w, 2}; r = (SDL_Rect){ x_start + (n+1) * w-2/RATIO, y_start + (i+ 1 - p_menu->start_entry_visible) *line_height -8/RATIO, (n_chars - 1) * w, 2/RATIO};
if (p_menu->cur_sel == i-1) if (p_menu->cur_sel == i-1)
SDL_FillRect(screen, &r, SDL_FillRect(screen, &r,
SDL_MapRGB(screen->format, 255,0,0)); //Underline selected text SDL_MapRGB(screen->format, 220,0,0)); //Underline selected text
else else
SDL_FillRect(screen, &r, SDL_FillRect(screen, &r,
SDL_MapRGB(screen->format, 0x40,0x40,0x40));//Underline non selected text SDL_MapRGB(screen->format, 255,255,255));//Underline non selected text
break; break;
} }
} }
@ -702,16 +716,18 @@ 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 ((draw_scr)&&(RATIO==1)) //Only in 640 mode
{ {
r.x = p_menu->x1+ (p_menu->x2 - p_menu->x1)/2 + line_height*3/2+4; r.x = 367;
r.y = p_menu->y1+line_height-1; r.y = 39;
r.w = line_height/2; r.w = 2;
r.h = p_menu->y2 - p_menu->y1 - line_height+1; r.h = 423;
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Frame for scr preview
r.x = r.x + r.w; SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Frame for scr preview
r.y = p_menu->y1+ (p_menu->y2 - p_menu->y1)/2 + line_height/4+1; r.x = 369;
r.w = (p_menu->x2 - p_menu->x1)/2 - line_height*2-3; r.y = 249;
r.h = line_height/2; r.w = 270;
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Frame for scr preview r.h = 2;
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Frame for scr preview
if ((!selected_file)||(selected_file[0] == '[')) return; //No dir if ((!selected_file)||(selected_file[0] == '[')) return; //No dir
@ -749,7 +765,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
strcat(filename, "scr2/"); strcat(filename, "scr2/");
strcat(filename, name); strcat(filename, name);
strcat(filename, ".scr"); strcat(filename, ".scr");
draw_scr_file(375,262, filename); draw_scr_file(375,260, filename);
} }
} }
@ -876,7 +892,7 @@ static void menu_init_internal(menu_t *p_menu, const char *title,
submenu++; submenu++;
} }
} }
p_menu->text_h = p_menu->n_entries * (TTF_FontHeight(p_font) + TTF_FontHeight(p_font) / 4); p_menu->text_h = p_menu->n_entries * (TTF_FontHeight(p_font) + TTF_FontHeight(p_font) / 2);
} }
static void menu_fini(menu_t *p_menu) static void menu_fini(menu_t *p_menu)
@ -1041,10 +1057,14 @@ static int menu_select_internal(SDL_Surface *screen,
{ {
SDL_Rect r = {p_menu->x1, p_menu->y1, SDL_Rect r = {p_menu->x1, p_menu->y1,
p_menu->x2 - p_menu->x1, p_menu->y2 - p_menu->y1}; p_menu->x2 - p_menu->x1, p_menu->y2 - p_menu->y1};
SDL_Rect r_int = {p_menu->x1+2/RATIO, p_menu->y1+2/RATIO,
p_menu->x2 - p_menu->x1-4/RATIO, p_menu->y2 - p_menu->y1-4/RATIO};
uint32_t keys; uint32_t keys;
int sel_last = p_menu->cur_sel; int sel_last = p_menu->cur_sel;
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff)); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0));
SDL_FillRect(screen, &r_int, SDL_MapRGB(screen->format, 0, 0, 0));
menu_draw(screen, p_menu, 0, font_size, draw_scr); menu_draw(screen, p_menu, 0, font_size, draw_scr);
SDL_Flip(screen); SDL_Flip(screen);
@ -1052,9 +1072,9 @@ static int menu_select_internal(SDL_Surface *screen,
keys = menu_wait_key_press(); keys = menu_wait_key_press();
if (keys & KEY_UP) if (keys & KEY_UP)
select_next(p_menu, 0, -1, 1); {select_next(p_menu, 0, -1, 1);play_click();}
else if (keys & KEY_DOWN) else if (keys & KEY_DOWN)
select_next(p_menu, 0, 1, 1); {select_next(p_menu, 0, 1, 1);play_click();}
else if (keys & KEY_PAGEUP) else if (keys & KEY_PAGEUP)
select_next(p_menu, 0, -19, 0); select_next(p_menu, 0, -19, 0);
else if (keys & KEY_PAGEDOWN) else if (keys & KEY_PAGEDOWN)
@ -1080,7 +1100,7 @@ static int menu_select_internal(SDL_Surface *screen,
select_next_cb(p_menu, select_next_cb_data); select_next_cb(p_menu, select_next_cb_data);
} }
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); //SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
return ret; return ret;
} }
@ -1095,13 +1115,13 @@ int menu_select_sized(const char *title, const char **msgs, int *submenus, int s
if (FULL_DISPLAY_X == 640) if (FULL_DISPLAY_X == 640)
{ {
if (font_size == 16) menu_init_internal(&menu, title, menu_font16, msgs, x, y, x2, y2); if (font_size == 16) menu_init_internal(&menu, title, menu_font_alt_large, msgs, x, y, x2, y2);
else menu_init_internal(&menu, title, menu_font20, msgs, x, y, x2, y2); else menu_init_internal(&menu, title, menu_font_large, msgs, x, y, x2, y2);
} }
else else
{ {
if (font_size == 16) menu_init_internal(&menu, title, menu_font8, msgs, x, y, x2, y2); if (font_size == 16) menu_init_internal(&menu, title, menu_font_alt_small, msgs, x, y, x2, y2);
else menu_init_internal(&menu, title, menu_font10, msgs, x, y, x2, y2); else menu_init_internal(&menu, title, menu_font_small, msgs, x, y, x2, y2);
} }
if (sel >= 0) if (sel >= 0)
@ -1118,7 +1138,7 @@ 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,
28/RATIO, 28/RATIO, FULL_DISPLAY_X-28/RATIO, FULL_DISPLAY_Y-28/RATIO, 0, 48/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y-48/RATIO,
NULL, NULL, 20, 0); NULL, NULL, 20, 0);
} }
@ -1298,7 +1318,7 @@ static const char *menu_select_file_internal(char *dir_path,
char *updir; char *updir;
int opt; int opt;
int i; int i;
char buf[64]; char buf[80];
unsigned int block_pos; unsigned int block_pos;
if (!strcmp(dir_path,"browser")) file_list = get_file_list_browser(tape_pos, &block_pos); if (!strcmp(dir_path,"browser")) file_list = get_file_list_browser(tape_pos, &block_pos);
@ -1315,7 +1335,7 @@ static const char *menu_select_file_internal(char *dir_path,
ptr_selected_file= strrchr(selected_file,'/'); ptr_selected_file= strrchr(selected_file,'/');
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,"Selected file:%s",ptr_selected_file); snprintf(buf,80,"Selected file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr); 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, draw_scr); else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
@ -1399,20 +1419,20 @@ const char *menu_select_file(char *dir_path,const char *selected_file, int draw_
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, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, selected_file, draw_scr, 0); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, selected_file, draw_scr, 0);
} }
const char *menu_select_browser(unsigned int tape_pos) const char *menu_select_browser(unsigned int tape_pos)
{ {
return menu_select_file_internal("browser", return menu_select_file_internal("browser",
0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, NULL, 0, tape_pos); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, tape_pos);
} }
const char *menu_select_tape_block() const char *menu_select_tape_block()
{ {
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
return menu_select_file_internal("select_block", return menu_select_file_internal("select_block",
0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, NULL, 0, 0); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, 0);
} }
@ -1451,26 +1471,27 @@ static TTF_Font *read_font(const char *path, int font_size)
void font_init() void font_init()
{ {
char *font_path; char *font_path,*font_path2;
TTF_Init(); TTF_Init();
font_path=myfile("fbzx/FreeMono.ttf"); font_path=myfile("fbzx/ZX_Spectrum.ttf");
font_path2=myfile("fbzx/ZX_Spectrum_narrow.ttf");
menu_font16 = read_font(font_path, 16); menu_font_large = read_font(font_path, 16);//Used for menu
menu_font20 = read_font(font_path, 20); menu_font_alt_large = read_font(font_path2, 16); //Used for file selection
menu_font8 = read_font(font_path, 8); menu_font_small = read_font(font_path, 8);
menu_font10 = read_font(font_path, 10); menu_font_alt_small = read_font(font_path2, 8);
free(font_path); free(font_path);
} }
void font_fini() void font_fini()
{ {
TTF_CloseFont(menu_font16); TTF_CloseFont(menu_font_alt_large);
TTF_CloseFont(menu_font20); TTF_CloseFont(menu_font_large);
TTF_CloseFont(menu_font8); TTF_CloseFont(menu_font_alt_small);
TTF_CloseFont(menu_font10); TTF_CloseFont(menu_font_small);
TTF_Quit(); TTF_Quit();
} }
@ -1492,6 +1513,11 @@ int menu_is_inited(void)
return is_inited; return is_inited;
} }
void play_click(void)
{
}
int ask_value_sdl(int *final_value,int y_coord,int max_value) { int ask_value_sdl(int *final_value,int y_coord,int max_value) {
unsigned char nombre2[50]; unsigned char nombre2[50];

View File

@ -80,4 +80,6 @@ int ask_filename_sdl(char *nombre_final,int y_coord,char *extension, char *path,
const char *menu_select_tape_block(); const char *menu_select_tape_block();
void play_click(void);
#endif /* !__MENU_H__ */ #endif /* !__MENU_H__ */