--- uae/src/tui.c 2018/04/24 16:38:39 1.1 +++ uae/src/tui.c 2018/04/24 16:39:13 1.1.1.2 @@ -15,13 +15,13 @@ #include "config.h" #include "options.h" +#include "uae.h" #include "os.h" #include "autoconf.h" #include "tui.h" #include "gui.h" #include "memory.h" -char *screenmodes[] = { "320x200", "320x240", "320x400", "640x480", "800x600" }; char *colormodes[] = { "256 colors", "32768 colors", "65536 colors", "256 colors dithered", "16 colors dithered", "16 million colors" }; @@ -34,7 +34,7 @@ int mountok=0; void gui_led(int led, int on) { } -void gui_filename(int num, char *name) +void gui_filename(int num, const char *name) { } static void getline(char *p) @@ -66,10 +66,24 @@ static void save_options(FILE *f) : keyboard_lang == KBD_LANG_IT ? "it" : "FOO")); fprintf(f, "-f %d\n", framerate); - fprintf(f, "-d %d\n", screen_res); - if (correct_aspect) - fprintf(f, "-C\n"); - fprintf(f, "-H %d\n", color_mode); + fprintf(f, "-O %d:%d:", gfx_requested_width, gfx_requested_height); + if (gfx_requested_lores) + fprintf(f, "l"); + switch (gfx_requested_xcenter) { + case 1: fprintf(f, "x"); break; + case 2: fprintf(f, "X"); break; + default: break; + } + switch (gfx_requested_ycenter) { + case 1: fprintf(f, "y"); break; + case 2: fprintf(f, "Y"); break; + default: break; + } + if (gfx_requested_linedbl) + fprintf(f, "d"); + if (gfx_requested_correct_aspect) + fprintf(f, "c"); + fprintf(f, "\n-H %d\n", color_mode); if (fastmem_size > 0) fprintf(f, "-F %d\n", fastmem_size / 0x100000); if (bogomem_size > 0) @@ -80,75 +94,91 @@ static void save_options(FILE *f) fprintf(f, "-B %d\n", sound_desired_bsiz); fprintf(f, "-b %d\n", sound_desired_bits); fprintf(f, "-R %d\n", sound_desired_freq); - + fprintf(f, "-A %d\n", emul_accuracy); + /* We don't write "-t" - I can hardly imagine a user who wants that in his + * config file. */ write_filesys_config(f); } void gui_exit() { if (allow_save) { - if (tui_backup_optionsfile() == 0) { - FILE *f = fopen(optionsfile, "w"); - if (f == NULL) { - fprintf(stderr, "Error saving options file!\n"); - return; - } - save_options(f); - fclose(f); + FILE *f; + tui_backup_optionsfile(); + f = fopen(optionsfile, "w"); + if (f == NULL) { + fprintf(stderr, "Error saving options file!\n"); + return; } + save_options(f); + fclose(f); } } -static const char *mainmenu[] = { - "D - Disk settings", - "V - Video settings", - "M - Memory settings", - "H - Hard disk settings", - "S - Sound settings", - "O - Other settings", - NULL +static struct bstring mainmenu[] = { + { "UAE main menu", 0 }, + { "_Disk settings", 'D' }, + { "_Video settings", 'V' }, + { "_Memory settings", 'M' }, + { "_Hard disk settings", 'H' }, + { "_Sound settings", 'S' }, + { "_Other settings", 'O' }, + { "_Run UAE", 'R' }, + { NULL, -3 } +}; + +static const char *mainmenu2[] = { + "D - Disk settings", + "S - Sound settings", + "F - Change frame rate", + NULL }; -static const char *diskmenu[] = { - "0 - change DF0:", - "1 - change DF1:", - "2 - change DF2:", - "3 - change DF3:", - NULL +static struct bstring diskmenu[] = { + { "Change DF_0:", '0' }, + { "Change DF_1:", '1' }, + { "Change DF_2:", '2' }, + { "Change DF_3:", '3' }, + { NULL, -3 } }; -static const char *videomenu[] = { - "1 - Change resolution", - "2 - Change color mode", - "3 - Toggle aspect correction", - "4 - Change framerate", - NULL +static struct bstring videomenu[] = { + { "Change _width", 'W' }, + { "Change _height", 'H' }, + { "Toggle _low resolution", 'L' }, + { "Change _X centering", 'X' }, + { "Change _Y centering", 'Y' }, + { "Toggle line _doubling", 'D' }, + { "Toggle _aspect _correction", 'A' }, + { "Change _color mode", 'C' }, + { "Change _framerate", 'F' }, + { NULL, -3 } }; -static const char *memmenu[] = { - "1 - Change fastmem size", - "2 - Change chipmem size", - "3 - Change slowmem size", - NULL +static struct bstring memorymenu[] = { + { "Change _fastmem size", 'F' }, + { "Change _chipmem size", 'C' }, + { "Change _slowmem size", 'S' }, + { NULL, -3 } }; -static const char *soundmenu[] = { - "1 - Change sound emulation", - NULL +static struct bstring soundmenu[] = { + { "Change _sound emulation", 'S' }, + { NULL , -3 } }; -static const char *miscmenu[] = { - "1 - Toggle keypad joystick emulation", - "2 - Select ROM image", - NULL +static struct bstring miscmenu[] = { + { "1 - Toggle keypad _joystick emulation", 'J' }, + { "2 - Select _ROM image", 'R' }, + { NULL, -3 } }; -static const char *hdmenu[] = { - "1 - Enable/Disable HardDrive file", - "2 - Change Mounted volume name", - "3 - Change Mounted volume path", - "4 - Enable/Disable Mounted volume", - NULL +static struct bstring hdmenu[] = { + { "1 - Enable/Disable _harddisks/fastmem", 'H' }, + { "2 - _Add a mounted volume", 'A' }, + { "3 - Add a mounted _volume r/o", 'V' }, + { "4 - _Remove a mounted volume", 'R' }, + { NULL, -3 } }; static int makemenu(const char **menu, int x, int y) @@ -200,24 +230,46 @@ static void print_configuration(void) { char tmp[256]; int y = 5; + int i; -/* tui_clrarea(35,4,79,20);*/ + tui_clrwin(0); + tui_drawbox(0); + tui_hline(2, 3, tui_cols() - 1); + sprintf(tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAEURSAMINOR); + tui_gotoxy((tui_cols() - strlen(tmp))/2, 2); tui_puts(tmp); + strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit"); + tui_gotoxy((tui_cols() - strlen(tmp))/2, tui_lines()); tui_puts(tmp); + tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF0: %s", trimfilename(df0, tui_cols() - 50)); tui_puts(tmp); tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF1: %s", trimfilename(df1, tui_cols() - 50)); tui_puts(tmp); tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF2: %s", trimfilename(df2, tui_cols() - 50)); tui_puts(tmp); tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF3: %s", trimfilename(df3, tui_cols() - 50)); tui_puts(tmp); y++; tui_gotoxy(35, y++); - sprintf(tmp, "VIDEO: %-7s %-19s ",screenmodes[screen_res], colormodes[color_mode]); + sprintf(tmp, "VIDEO: %d:%d%s %s", gfx_requested_width, gfx_requested_height, + gfx_requested_lores ? " (lores)" : "", colormodes[color_mode]); tui_puts(tmp); tui_gotoxy(42, y++); - if (correct_aspect) - tui_puts("Aspect corrected "); + if (gfx_requested_linedbl) + tui_puts("Doubling lines, "); + if (gfx_requested_correct_aspect) + tui_puts("Aspect corrected"); else tui_puts("Not aspect corrected"); tui_gotoxy(42, y++); + if (gfx_requested_xcenter) + tui_puts ("X centered"); + if (gfx_requested_xcenter == 2) + tui_puts (" (clever)"); + if (gfx_requested_ycenter && gfx_requested_xcenter) + tui_puts (", "); + if (gfx_requested_ycenter) + tui_puts ("Y centered "); + if (gfx_requested_ycenter == 2) + tui_puts (" (clever)"); + tui_gotoxy(42, y++); tui_puts("drawing every "); switch(framerate) { case 1: break; @@ -236,12 +288,12 @@ static void print_configuration(void) tui_puts(tmp); tui_gotoxy(35, y++); if (!sound_available) - tui_puts("SOUNDS: Not available"); + tui_puts("SOUND: Not available"); else { switch (produce_sound) { - case 0: tui_puts("SOUND: 0 (Off) "); break; - case 1: tui_puts("SOUND: 1 (Off, but emulated) "); break; - case 2: tui_puts("SOUND: 2 (On) "); break; + case 0: tui_puts("SOUND: 0 (Off)"); break; + case 1: tui_puts("SOUND: 1 (Off, but emulated)"); break; + case 2: tui_puts("SOUND: 2 (On)"); break; case 3: tui_puts("SOUND: 3 (On, emulated perfectly)"); break; } } @@ -251,105 +303,104 @@ static void print_configuration(void) tui_puts("JOYSTICK: using keypad emulation"); } else { if (joystickpresent) - tui_puts("JOYSTICK: using joystick #0 "); + tui_puts("JOYSTICK: using joystick #0"); else - tui_puts("JOYSTICK: no joystick emulation "); + tui_puts("JOYSTICK: no joystick emulation"); } tui_gotoxy(35,y++); - tui_puts("HARDDISK: "); - if(hardfile_size>16) { - sprintf(tmp, "Current Harddisk file = %d K is", hardfile_size/1024); - tui_puts(tmp); - if (automount_uaedev==1) { - tui_puts(" active"); - } else { - tui_puts(" not active"); - } - } else { - tui_puts("No Harddisk file available "); - } + sprintf(tmp, "HARDDISK: (%s)", automount_uaedev ? "enabled" : "disabled"); + tui_puts(tmp); - tui_gotoxy(35,y++); - if(mountok==1) { - sprintf(tmp, "Mounting volume %s at %s",mountvol,mountdir); tui_puts(tmp); + for (i = 0;; i++) { + char buf[256]; + + tui_gotoxy(36,y++); + if (sprintf_filesys_unit(buf, i) == -1) + break; + tui_puts(buf); } - tui_refresh(); } static void HDOptions(void) { char *buff; char tmp[256]; - - int w = makemenu(hdmenu, 3, 5); + int c = 0; for (;;){ - int c; tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - c = tui_getc(); - if (c == 27 || c == 13) - break; - switch(c) { - case '1': - automount_uaedev=!automount_uaedev; break; - case '2': - tui_wgets(mountvol, "Enter mounted volume name", 78); - if(mountvol[strlen(mountvol)-1]==':') { - mountvol[strlen(mountvol)-1]=0; } + + c = tui_menubrowse(hdmenu, 3, 5, c); + if (c == -1) + break; + else switch(c) { + case 0: + automount_uaedev=!automount_uaedev; + break; + case 1: + tui_wgets(mountvol, "Enter mounted volume name", 10); + if (strlen(mountvol) == 0) + break; + if(mountvol[strlen(mountvol)-1]==':') + mountvol[strlen(mountvol)-1] = 0; + tui_wgets(mountdir, "Enter mounted volume path", 78); + add_filesys_unit(mountvol, mountdir, 0); break; - case '3': + case 2: + tui_wgets(mountvol, "Enter mounted volume name", 10); + if (strlen(mountvol) == 0) + break; + if(mountvol[strlen(mountvol)-1]==':') + mountvol[strlen(mountvol)-1] = 0; tui_wgets(mountdir, "Enter mounted volume path", 78); + add_filesys_unit(mountvol, mountdir, 1); + break; + case 3: + tui_wgets(mountvol, "Enter name of volume to be removed", 10); + if (kill_filesys_unit(mountvol) == -1) + tui_errorbox("Volume does not exist"); break; - case '4': mountok=!mountok; break; } } - tui_dlogdie(w); } static void DiskOptions(void) { - char buf[256], tmp[256]; - int w = makemenu(diskmenu, 3, 5); - + char buf[256], tmp[256]; + int c = 0; + for (;;) { char *sel; - int c; - + tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - c = tui_getc(); - if (c == 27 || c == 13) + c = tui_menubrowse(diskmenu, 3, 5, c); + if (c == -1) break; - switch(c) { - case '0': + else switch(c) { + case 0: sel = tui_filereq("*.adf", df0); if (sel == NULL) break; strcpy(df0, sel); break; - case '1': + case 1: sel = tui_filereq("*.adf", df1); if (sel == NULL) break; strcpy(df1, sel); break; - case '2': + case 2: sel = tui_filereq("*.adf", df2); if (sel == NULL) break; strcpy(df2, sel); break; - case '3': + case 3: sel = tui_filereq("*.adf", df3); if (sel == NULL) break; @@ -357,67 +408,78 @@ static void DiskOptions(void) break; } } - tui_dlogdie(w); } static void VideoOptions(void) { char tmp[256]; - int w = makemenu(videomenu, 3, 5); + int c = 0; for (;;) { - int c; tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - - c = tui_getc(); - if (c == 27 || c == 13) - break; - switch(c) { - case 49: - screen_res++; - if (screen_res > MAX_SCREEN_MODES) - screen_res=0; + + c = tui_menubrowse(videomenu, 3, 5, c); + if (c == -1) + break; + else switch(c) { + case 0: + tui_wgets(tmp, "Enter new video mode width", 4); + if (atoi (tmp) < 320 || atoi (tmp) > 1600 /* maybe we'll implement SHires */) + tui_errorbox("Insane value for video mode width"); + else + gfx_requested_width = atoi (tmp); + break; + case 1: + tui_wgets(tmp, "Enter new video mode height", 4); + if (atoi (tmp) < 200 || atoi (tmp) > 800 /* whatever */) + tui_errorbox("Insane value for video mode height"); + else + gfx_requested_height = atoi (tmp); + break; + case 2: + gfx_requested_lores = !gfx_requested_lores; break; - case 50: + case 3: + gfx_requested_xcenter = (gfx_requested_xcenter + 1) % 3; + break; + case 4: + gfx_requested_ycenter = (gfx_requested_ycenter + 1) % 3; + break; + case 5: + gfx_requested_linedbl = !gfx_requested_linedbl; + break; + case 6: + gfx_requested_correct_aspect = !gfx_requested_correct_aspect; + break; + case 7: color_mode++; if (color_mode > MAX_COLOR_MODES) color_mode=0; break; - case 51: - correct_aspect = !correct_aspect; - break; - case 52: + case 8: framerate++; if (framerate > 9) framerate=1; break; } } - tui_dlogdie(w); } static void MemoryOptions(void) { - int w = makemenu(memmenu, 3, 5); + int c = 0; for (;;) { - int c; tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - c = tui_getc(); - if (c == 27 || c == 13) + c = tui_menubrowse(memorymenu, 3, 5, c); + if (c == -1) break; - switch(c) { - case '1': + else switch(c) { + case 0: if (fastmem_size == 0) fastmem_size = 0x200000; else if (fastmem_size == 0x800000) @@ -425,13 +487,13 @@ static void MemoryOptions(void) else fastmem_size <<= 1; break; - case '2': - if (chipmem_size == 0x200000) + case 1: + if (chipmem_size == 0x800000) chipmem_size = 0x80000; else chipmem_size <<= 1; break; - case '3': + case 2: if (bogomem_size == 0) bogomem_size = 0x40000; else if (bogomem_size == 0x100000) @@ -442,122 +504,96 @@ static void MemoryOptions(void) } } - tui_dlogdie(w); } static void SoundOptions(void) { - int w = makemenu(soundmenu, 3, 5); - + int c = 0; for (;;) { - int c; tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - - c = tui_getc(); - if (c == 27 || c == 13) + c = tui_menubrowse(soundmenu, 3, 5, c); + if (c == -1) break; - switch(c) { - case '1': + else switch(c) { + case 0: produce_sound++; if(produce_sound > 3) produce_sound = 0; break; - } } - tui_dlogdie(w); } static void OtherOptions(void) { char *tmp; - int w = makemenu(miscmenu, 3, 5); + int c = 0; for (;;) { - int c; tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(w); - tui_refresh(); - - c = tui_getc(); - if (c == 27 || c == 13) + c = tui_menubrowse(miscmenu, 3, 5, c); + if (c == -1) { break; - switch(c) { - case '1': + } else switch(c) { + case 0: fake_joystick = !fake_joystick; break; - case '2': + case 1: tmp = tui_filereq("*.rom", romfile); if (tmp != NULL) strcpy(romfile, tmp); break; } } - tui_dlogdie(w); } -int gui_init() +static int do_gui(int mode) { char cwd[1024]; - char tmp[256]; - int mm_win; - + if (getcwd(cwd, 1024) == NULL) return 0; quit_program = 0; tui_setup(); - - tui_drawbox(0); - tui_hline(2, 3, tui_cols() - 1); - sprintf(tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAEURSAMINOR); - tui_gotoxy((tui_cols() - strlen(tmp))/2, 2); tui_puts(tmp); - strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit"); - tui_gotoxy((tui_cols() - strlen(tmp))/2, tui_lines()); tui_puts(tmp); - - mm_win = makemenu(mainmenu, 2, 4); - + for (;;) { int c; + tui_selwin(0); print_configuration(); - tui_refresh(); - tui_selwin(mm_win); - tui_refresh(); - c = tui_getc(); - - if (c == 27) { - tui_dlogdie(mm_win); + c = tui_menubrowse(mainmenu, 2, 4, 0); + if (c == -1) { tui_shutdown(); - exit(0); - } else if (c == 13) { + return -2; + } else if (c == 6) { break; - } - - switch(c) { - case 100: DiskOptions(); break; - case 118: VideoOptions(); break; - case 109: MemoryOptions(); break; - case 104: HDOptions(); break; - case 115: SoundOptions(); break; - case 111: OtherOptions(); break; + } else switch (c) { + case 0: DiskOptions(); break; + case 1: VideoOptions(); break; + case 2: MemoryOptions(); break; + case 3: HDOptions(); break; + case 4: SoundOptions(); break; + case 5: OtherOptions(); break; } } - - tui_dlogdie(mm_win); - if(mountok) - add_filesys_unit(mountvol, mountdir, 0); - tui_shutdown(); + chdir (cwd); return 0; } + +int gui_init(void) +{ + return do_gui(1); +} + +int gui_update(void) +{ + return 0; +}