Annotation of uae/src/tui.c, revision 1.1.1.6

1.1       root        1:  /*
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   *
                      4:   * Text-based user interface
                      5:   * Sie haben es sich verdient!
                      6:   *
                      7:   * Copyright 1996 Tim Gunn, Bernd Schmidt
                      8:   */
                      9: 
                     10: #include "sysconfig.h"
                     11: #include "sysdeps.h"
                     12: 
                     13: #include <stdio.h>
                     14: #include <ctype.h>
                     15: 
                     16: #include "config.h"
                     17: #include "options.h"
1.1.1.3   root       18: #include "threaddep/penguin.h"
1.1.1.2   root       19: #include "uae.h"
1.1.1.3   root       20: #include "gensound.h"
                     21: #include "joystick.h"
                     22: #include "keybuf.h"
1.1       root       23: #include "autoconf.h"
1.1.1.3   root       24: #include "xwin.h"
1.1       root       25: #include "tui.h"
                     26: #include "gui.h"
                     27: #include "memory.h"
                     28: 
1.1.1.3   root       29: #define MAX_MENU_HEIGHT 15
                     30: #define OPTION_COLUMN 3
                     31: #define MENU_COL_OFFSET -2
1.1       root       32: 
                     33: int mountok=0;
                     34: 
1.1.1.4   root       35: void gui_led (int led, int on)
1.1       root       36: {
                     37: }
1.1.1.4   root       38: void gui_filename (int num, const char *name)
1.1       root       39: {
                     40: }
1.1.1.4   root       41: static void getline (char *p)
1.1       root       42: {
                     43: }
1.1.1.4   root       44: void gui_handle_events (void)
1.1       root       45: {
                     46: }
1.1.1.6 ! root       47: void gui_fps (int x)
        !            48: {
        !            49: }
1.1.1.3   root       50: static void save_settings (void)
1.1       root       51: {
1.1.1.3   root       52:     FILE *f;
                     53:     tui_backup_optionsfile ();
                     54:     f = fopen (optionsfile, "w");
                     55:     if (f == NULL) {
1.1.1.4   root       56:        fprintf (stderr, "Error saving options file!\n");
1.1.1.3   root       57:        return;
                     58:     }
1.1.1.6 ! root       59:     save_options (f, &currprefs);
1.1.1.3   root       60:     fclose (f);
1.1       root       61: }
                     62: 
                     63: void gui_exit()
                     64: {
                     65: }
                     66: 
1.1.1.2   root       67: static struct bstring mainmenu[] = {
1.1.1.3   root       68:     { "UAE configuration", 0 },
1.1.1.2   root       69:     { "_Disk settings", 'D' },
                     70:     { "_Video settings", 'V' },
                     71:     { "_Memory settings", 'M' },
1.1.1.5   root       72:     { "_CPU settings", 'C' },
1.1.1.2   root       73:     { "_Hard disk settings", 'H' },
                     74:     { "_Sound settings", 'S' },
                     75:     { "_Other settings", 'O' },
1.1.1.3   root       76:     { "S_ave settings", 'A' },
1.1.1.2   root       77:     { "_Run UAE", 'R' },
                     78:     { NULL, -3 }
                     79: };
                     80: 
1.1.1.3   root       81: static struct bstring mainmenu2[] = {
                     82:     { "UAE configuration", 0 },
                     83:     { "_Disk settings", 'D' },
                     84: /*    { "_Video settings", 'V' },
                     85:     { "_Memory settings", 'M' },
                     86:     { "_Hard disk settings", 'H' },
                     87:     { "_Sound settings", 'S' }, */
                     88:     { "_Other settings", 'O' },
                     89:     { "S_ave settings", 'A' },
                     90:     { "R_eset UAE", 'E' },
                     91:     { "_Quit UAE", 'Q' },
                     92:     { "_Run UAE", 'R' },
                     93:     { NULL, -3 }
1.1       root       94: };
                     95: 
1.1.1.3   root       96: static struct bstring diskmenu[] = {
                     97:     { "Floppy disk settings", 0 },
1.1.1.2   root       98:     { "Change DF_0:", '0' },
                     99:     { "Change DF_1:", '1' },
                    100:     { "Change DF_2:", '2' },
                    101:     { "Change DF_3:", '3' },
                    102:     { NULL, -3 }
1.1       root      103: };
                    104: 
1.1.1.3   root      105: static struct bstring videomenu[] = {
                    106:     { "Video settings", 0 },
1.1.1.2   root      107:     { "Change _width", 'W' },
                    108:     { "Change _height", 'H' },
1.1.1.3   root      109:     { "Change _color mode", 'C' },
                    110:     { "Select predefined _mode", 'M' },
1.1.1.2   root      111:     { "Toggle _low resolution", 'L' },
                    112:     { "Change _X centering", 'X' },
1.1.1.3   root      113:     { "Change _Y centering", 'Y' },
1.1.1.2   root      114:     { "Toggle line _doubling", 'D' },
                    115:     { "Toggle _aspect _correction", 'A' },
                    116:     { "Change _framerate", 'F' },
1.1.1.5   root      117:     { "_Graphics card memory", 'P'},
1.1.1.2   root      118:     { NULL, -3 }
1.1       root      119: };
                    120: 
1.1.1.3   root      121: static struct bstring memorymenu[] = {
                    122:     { "Memory settings", 0 },
1.1.1.2   root      123:     { "Change _fastmem size", 'F' },
                    124:     { "Change _chipmem size", 'C' },
                    125:     { "Change _slowmem size", 'S' },
1.1.1.3   root      126:     { "Select ROM _image", 'I' },
1.1.1.2   root      127:     { NULL, -3 }
1.1       root      128: };
                    129: 
1.1.1.5   root      130: static struct bstring cpumenu[] = {
                    131:     { "Change _CPU", 'C' },
                    132:     { NULL, -3 }
                    133: };
                    134: 
1.1.1.3   root      135: static struct bstring soundmenu[] = {
                    136:     { "Sound settings", 0 },
                    137:     { "Change _sound emulation accuracy", 'S' },
                    138:     { "Change m_inimum sound buffer size", 'I' },
                    139:     { "Change m_aximum sound buffer size", 'A' },
                    140:     { "Change number of _bits", 'B' },
                    141:     { "Change output _frequency", 'F' },
1.1.1.5   root      142:     { "Change s_tereo", 'T' },
1.1.1.2   root      143:     { NULL , -3 }
1.1       root      144: };
                    145: 
1.1.1.3   root      146: static struct bstring miscmenu[] = {
                    147:     { "Miscellaneous settings", 0 },
                    148:     { "Toggle joystick port _0 emulation", '0' },
                    149:     { "Toggle joystick port _1 emulation", '1' },
                    150:     { "Set _CPU emulation speed", 'C' },
1.1.1.2   root      151:     { NULL, -3 }
1.1       root      152: };
                    153: 
1.1.1.2   root      154: static struct bstring hdmenu[] = {
1.1.1.3   root      155: /*    { "Harddisk/CDROM emulation settings", 0 },*/
                    156:     { "Enable/Disable _harddisks/fastmem", 'H' },
                    157:     { "_Add a mounted volume", 'A' },
                    158:     { "Add a mounted _volume r/o", 'V' },
                    159:     { "Add a hard_file", 'F' },
                    160:     { "_Delete a mounted volume", 'D' },
1.1.1.2   root      161:     { NULL, -3 }
1.1       root      162: };
                    163: 
1.1.1.4   root      164: static int makemenu (const char **menu, int x, int y)
1.1       root      165: {
                    166:     const char **m = menu;
                    167:     int maxlen = 0, count = 0;
                    168:     int w;
1.1.1.3   root      169: 
1.1       root      170:     while (*m != NULL) {
1.1.1.4   root      171:        int l = strlen (*m);
1.1       root      172:        if (l > maxlen)
                    173:            maxlen = l;
                    174:        m++; count++;
                    175:     }
1.1.1.4   root      176:     w = tui_dlog (x, y, x + maxlen + 2, y + count + 1);
                    177:     tui_drawbox (w);
                    178:     tui_selwin (w);
1.1       root      179:     y = 2;
                    180:     while (*menu != NULL) {
1.1.1.4   root      181:        tui_gotoxy (2, y++);
                    182:        tui_puts (*menu++);
1.1       root      183:     }
1.1.1.4   root      184:     tui_selwin (0);
1.1       root      185:     return w;
                    186: }
                    187: 
                    188: static char tmpbuf[256];
                    189: 
                    190: static char *trimfilename(char *s, size_t n)
                    191: {
                    192:     size_t i;
                    193:     if (n > 250)
                    194:        n = 250;
1.1.1.4   root      195:     if (strlen (s) == 0)
                    196:        strcpy (tmpbuf, "none");
                    197:     else if (strlen (s) < n)
                    198:        strcpy (tmpbuf, s);
1.1       root      199:     else {
                    200:        tmpbuf[0] = '^';
1.1.1.4   root      201:        strcpy (tmpbuf + 1, s + strlen (s) - n + 2);
1.1       root      202:     }
                    203:     for (i = strlen(tmpbuf); i < n; i++)
                    204:        tmpbuf[i] = ' ';
                    205:     tmpbuf[i] = 0;
                    206:     return tmpbuf;
                    207: }
                    208: 
1.1.1.4   root      209: static void print_configuration (void)
1.1       root      210: {
                    211:     char tmp[256];
                    212:     int y = 5;
1.1.1.2   root      213:     int i;
1.1       root      214: 
1.1.1.4   root      215:     tui_clrwin (0);
1.1.1.3   root      216: 
1.1.1.4   root      217:     tui_drawbox (0);
                    218:     tui_hline (2, 3, tui_cols () - 1);
                    219:     sprintf (tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAESUBREV);
                    220:     tui_gotoxy ((tui_cols () - strlen(tmp))/2, 2); tui_puts (tmp);
1.1.1.2   root      221:     strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit");
1.1.1.4   root      222:     tui_gotoxy ((tui_cols () - strlen(tmp))/2, tui_lines ()); tui_puts (tmp);
1.1.1.2   root      223: 
1.1.1.4   root      224:     tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF0: %s", trimfilename (currprefs.df[0], tui_cols () - 20)); tui_puts (tmp);
                    225:     tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF1: %s", trimfilename (currprefs.df[1], tui_cols () - 20)); tui_puts (tmp);
                    226:     tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF2: %s", trimfilename (currprefs.df[2], tui_cols () - 20)); tui_puts (tmp);
                    227:     tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF3: %s", trimfilename (currprefs.df[3], tui_cols () - 20)); tui_puts (tmp);
1.1       root      228:     y++;
1.1.1.4   root      229:     tui_gotoxy (OPTION_COLUMN, y++);
                    230:     sprintf (tmp, "VIDEO: %d:%d%s %s", currprefs.gfx_width, currprefs.gfx_height,
1.1.1.3   root      231:            currprefs.gfx_lores ? " (lores)" : "", colormodes[currprefs.color_mode]);
1.1.1.4   root      232:     tui_puts (tmp);
1.1       root      233: 
1.1.1.4   root      234:     tui_gotoxy (OPTION_COLUMN+7, y++);
1.1.1.3   root      235:     if (currprefs.gfx_linedbl)
1.1.1.4   root      236:        tui_puts ("Doubling lines, ");
1.1.1.3   root      237:     if (currprefs.gfx_correct_aspect)
1.1.1.4   root      238:        tui_puts ("Aspect corrected");
1.1.1.3   root      239:     else
1.1.1.4   root      240:        tui_puts ("Not aspect corrected");
                    241:     tui_gotoxy (OPTION_COLUMN+7, y++);
1.1.1.3   root      242:     if (currprefs.gfx_xcenter)
1.1.1.2   root      243:        tui_puts ("X centered");
1.1.1.3   root      244:     if (currprefs.gfx_xcenter == 2)
1.1.1.2   root      245:        tui_puts (" (clever)");
1.1.1.3   root      246:     if (currprefs.gfx_ycenter && currprefs.gfx_xcenter)
1.1.1.2   root      247:        tui_puts (", ");
1.1.1.3   root      248:     if (currprefs.gfx_ycenter)
1.1.1.2   root      249:        tui_puts ("Y centered ");
1.1.1.3   root      250:     if (currprefs.gfx_ycenter == 2)
1.1.1.2   root      251:        tui_puts (" (clever)");
1.1.1.4   root      252:     tui_gotoxy (OPTION_COLUMN+7, y++);
                    253:     tui_puts ("drawing every ");
                    254:     switch (currprefs.framerate) {
1.1       root      255:      case 1: break;
1.1.1.4   root      256:      case 2: tui_puts ("2nd "); break;
                    257:      case 3: tui_puts ("3rd "); break;
                    258:      default: sprintf (tmp, "%dth ",currprefs.framerate); tui_puts (tmp); break;
1.1       root      259:     }
1.1.1.4   root      260:     tui_puts ("frame.    ");
1.1.1.5   root      261: 
                    262:     tui_gotoxy (OPTION_COLUMN+7, y++);
                    263:     if (currprefs.gfxmem_size) {
                    264:        sprintf (tmp, "Picasso 96 %d MB", currprefs.gfxmem_size / 0x100000);
                    265:        tui_puts(tmp);
                    266:     } else
                    267:        tui_puts ("Picasso 96 Off");
1.1       root      268:     y++;
1.1.1.5   root      269: 
                    270:     tui_gotoxy (OPTION_COLUMN, y++);
                    271:     tui_puts ("CPU: ");
                    272:     switch (currprefs.cpu_level) {
                    273:      case 0: tui_puts ("68000"); break;
                    274:      case 1: tui_puts ("68010"); break;
                    275:      case 2: tui_puts ("68020"); break;
                    276:      case 3: tui_puts ("68020/68881"); break;
                    277:     }
                    278:     if (currprefs.address_space_24 && currprefs.cpu_level > 1)
                    279:        tui_puts (" (24 bit addressing)");
                    280:     if (currprefs.cpu_compatible)
                    281:        tui_puts (" (slow but compatible)");
1.1.1.4   root      282:     tui_gotoxy (OPTION_COLUMN, y++);
1.1.1.5   root      283:     sprintf (tmp, "MEMORY: %4dK chip; %4dK fast; %4dK slow",
                    284:             currprefs.chipmem_size/1024,
                    285:             currprefs.fastmem_size/1024,
                    286:             currprefs.bogomem_size/1024);
1.1.1.4   root      287:     tui_puts (tmp);
                    288: 
                    289:     tui_gotoxy (OPTION_COLUMN, y++);
1.1.1.6 ! root      290:     sprintf (tmp, "ROM IMAGE: %s", trimfilename (currprefs.romfile, tui_cols () - 50));
1.1.1.4   root      291:     tui_puts (tmp);
                    292:     tui_gotoxy (OPTION_COLUMN, y++);
1.1       root      293:     if (!sound_available)
1.1.1.4   root      294:        tui_puts ("SOUND: Not available");
1.1       root      295:     else {
1.1.1.3   root      296:        switch (currprefs.produce_sound) {
1.1.1.4   root      297:         case 0: tui_puts ("SOUND: 0 (Off)"); break;
                    298:         case 1: tui_puts ("SOUND: 1 (Off, but emulated)"); break;
                    299:         case 2: tui_puts ("SOUND: 2 (On)"); break;
                    300:         case 3: tui_puts ("SOUND: 3 (On, emulated perfectly)"); break;
1.1       root      301:        }
1.1.1.4   root      302:        tui_gotoxy (OPTION_COLUMN + 7, y++);
                    303:        sprintf (tmp, "%d bits at %d Hz", currprefs.sound_bits, currprefs.sound_freq);
                    304:        tui_puts (tmp);
                    305:        tui_gotoxy (OPTION_COLUMN + 7, y++);
                    306:        sprintf (tmp, "Minimum buffer size %d bytes, maximum %d bytes", currprefs.sound_minbsiz, currprefs.sound_maxbsiz);
                    307:        tui_puts (tmp);
1.1       root      308:     }
                    309: 
1.1.1.4   root      310:     tui_gotoxy (OPTION_COLUMN,y++);
1.1.1.3   root      311:     tui_puts ("GAME PORT 1: "); tui_puts (gameport_state (0));
1.1.1.4   root      312:     tui_gotoxy (OPTION_COLUMN,y++);
1.1.1.3   root      313:     tui_puts ("GAME PORT 2: "); tui_puts (gameport_state (1));
1.1       root      314: 
1.1.1.4   root      315:     tui_gotoxy (OPTION_COLUMN,y++);
                    316:     sprintf (tmp, "HARDDISK: (%s)", currprefs.automount_uaedev ? "enabled" : "disabled");
                    317:     tui_puts (tmp);
1.1       root      318: 
1.1.1.2   root      319:     for (i = 0;; i++) {
                    320:        char buf[256];
1.1.1.3   root      321: 
1.1.1.4   root      322:        tui_gotoxy (OPTION_COLUMN+1,y++);
1.1.1.5   root      323:        if (sprintf_filesys_unit (currprefs.mountinfo, buf, i) == -1)
1.1.1.2   root      324:            break;
1.1.1.4   root      325:        tui_puts (buf);
1.1       root      326:     }
                    327: }
                    328: 
1.1.1.4   root      329: static void HDOptions (void)
1.1       root      330: {
                    331:     char *buff;
                    332:     char tmp[256];
1.1.1.3   root      333:     char mountvol[256];
                    334:     char mountdir[256];
1.1.1.2   root      335:     int c = 0;
1.1       root      336: 
                    337:     for (;;){
1.1.1.3   root      338: 
1.1       root      339:        tui_selwin(0);
                    340:        print_configuration();
1.1.1.2   root      341: 
1.1.1.3   root      342:        c = tui_menubrowse (hdmenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      343:        if (c == -1)
                    344:            break;
1.1.1.4   root      345:        else switch (c) {
1.1.1.2   root      346:         case 0:
1.1.1.3   root      347:            currprefs.automount_uaedev = !currprefs.automount_uaedev;
1.1.1.2   root      348:            break;
                    349:         case 1:
1.1.1.3   root      350:            tui_wgets (mountvol, "Enter mounted volume name", 10);
                    351:            if (strlen (mountvol) == 0)
1.1.1.2   root      352:                break;
1.1.1.3   root      353:            if (mountvol[strlen(mountvol)-1]==':')
1.1.1.2   root      354:                mountvol[strlen(mountvol)-1] = 0;
1.1.1.3   root      355:            tui_wgets (mountdir, "Enter mounted volume path", 78);
1.1.1.6 ! root      356:            add_filesys_unit (currprefs.mountinfo, mountvol, mountdir, 0, 0, 0, 0, 0);
1.1       root      357:            break;
1.1.1.3   root      358:         case 2:
                    359:            tui_wgets (mountvol, "Enter mounted volume name", 10);
                    360:            if (strlen (mountvol) == 0)
1.1.1.2   root      361:                break;
1.1.1.4   root      362:            if (mountvol[strlen (mountvol)-1]==':')
1.1.1.3   root      363:                mountvol[strlen (mountvol)-1] = 0;
                    364:            tui_wgets (mountdir, "Enter mounted volume path", 78);
1.1.1.6 ! root      365:            add_filesys_unit (currprefs.mountinfo, mountvol, mountdir, 1, 0, 0, 0, 0);
1.1.1.2   root      366:            break;
                    367:         case 3:
1.1.1.3   root      368:            buff = tui_filereq("*", "", "Select the hardfile to be mounted");
                    369:            if (buff == NULL)
                    370:                break;
                    371:            strcpy (mountvol, buff);
                    372:            tui_wgets (mountdir, "Enter number of sectors per track", 4);
                    373:            tui_wgets (mountdir + 10, "Enter number of heads", 4);
                    374:            tui_wgets (mountdir + 20, "Enter number of reserved blocks", 3);
1.1.1.6 ! root      375:            tui_wgets (mountdir + 30, "Enter block size", 4);
1.1.1.5   root      376:            buff = add_filesys_unit (currprefs.mountinfo, 0, mountvol, 1,
1.1.1.3   root      377:                                     atoi (mountdir), atoi (mountdir + 10),
1.1.1.6 ! root      378:                                     atoi (mountdir + 20), atoi (mountdir + 30));
1.1.1.3   root      379:            if (buff)
                    380:                tui_errorbox (buff);
                    381:            break;
                    382:         case 4:
                    383:            tui_wgets (mountvol, "Enter number of volume to be removed (0 for UAE0:, etc.)", 2);
1.1.1.5   root      384:            if (kill_filesys_unit (currprefs.mountinfo, atoi (mountvol)) == -1)
1.1.1.4   root      385:                tui_errorbox ("Volume does not exist");
1.1       root      386:            break;
                    387:        }
                    388:     }
                    389: }
                    390: 
1.1.1.4   root      391: static void DiskOptions (void)
1.1       root      392: {
1.1.1.3   root      393:     char tmp[256];
1.1.1.2   root      394:     int c = 0;
                    395: 
1.1       root      396:     for (;;) {
                    397:        char *sel;
1.1.1.2   root      398: 
1.1       root      399:        tui_selwin(0);
                    400:        print_configuration();
1.1.1.3   root      401: 
1.1.1.4   root      402:        c = tui_menubrowse (diskmenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      403:        if (c == -1)
1.1       root      404:            break;
1.1.1.4   root      405:        else switch (c) {
1.1.1.3   root      406:         case 0:
                    407:         case 1:
                    408:         case 2:
                    409:         case 3:
1.1.1.4   root      410:            sprintf (tmp, "Select a diskfile for DF%d:", c);
1.1.1.3   root      411:            sel = tui_filereq("*.adf", currprefs.df[c], tmp);
1.1       root      412:            if (sel == NULL)
                    413:                break;
1.1.1.5   root      414:            strcpy (currprefs.df[c], sel);
1.1       root      415:            break;
                    416:        }
                    417:     }
                    418: }
                    419: 
1.1.1.4   root      420: static void VideoOptions (void)
1.1       root      421: {
                    422:     char tmp[256];
1.1.1.2   root      423:     int c = 0;
1.1       root      424: 
1.1.1.3   root      425:     for (c = 0; c < 10; c++)
                    426:        if (videomenu[c].val == 'M') {
                    427:            if (video_mode_menu == NULL)
                    428:                videomenu[c].val = -4;
                    429:            break;
                    430:        }
                    431: 
                    432:     c = 0;
1.1       root      433:     for (;;) {
                    434: 
                    435:        tui_selwin(0);
                    436:        print_configuration();
1.1.1.3   root      437: 
1.1.1.4   root      438:        c = tui_menubrowse (videomenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      439:        if (c == -1)
                    440:            break;
1.1.1.4   root      441:        else switch (c) {
1.1.1.2   root      442:         case 0:
1.1.1.4   root      443:            tui_wgets (tmp, "Enter new video mode width", 4);
1.1.1.2   root      444:            if (atoi (tmp) < 320 || atoi (tmp) > 1600 /* maybe we'll implement SHires */)
1.1.1.4   root      445:                tui_errorbox ("Insane value for video mode width");
1.1.1.2   root      446:            else
1.1.1.3   root      447:                currprefs.gfx_width = atoi (tmp);
1.1.1.2   root      448:            break;
                    449:         case 1:
1.1.1.4   root      450:            tui_wgets (tmp, "Enter new video mode height", 4);
1.1.1.2   root      451:            if (atoi (tmp) < 200 || atoi (tmp) > 800 /* whatever */)
1.1.1.4   root      452:                tui_errorbox ("Insane value for video mode height");
1.1.1.2   root      453:            else
1.1.1.3   root      454:                currprefs.gfx_height = atoi (tmp);
1.1.1.2   root      455:            break;
                    456:         case 2:
1.1.1.3   root      457:            currprefs.color_mode++;
                    458:            if (currprefs.color_mode > MAX_COLOR_MODES)
                    459:                currprefs.color_mode=0;
1.1       root      460:            break;
1.1.1.2   root      461:         case 3:
1.1.1.4   root      462:            c = tui_menubrowse (video_mode_menu, 4, 6, 0, 15);
1.1.1.3   root      463:            if (c != -1)
                    464:                vidmode_menu_selected(c);
                    465:            c = 3;
1.1.1.2   root      466:            break;
                    467:         case 4:
1.1.1.3   root      468:            currprefs.gfx_lores = !currprefs.gfx_lores;
1.1.1.2   root      469:            break;
                    470:         case 5:
1.1.1.3   root      471:            currprefs.gfx_xcenter = (currprefs.gfx_xcenter + 1) % 3;
1.1.1.2   root      472:            break;
                    473:         case 6:
1.1.1.3   root      474:            currprefs.gfx_ycenter = (currprefs.gfx_ycenter + 1) % 3;
1.1.1.2   root      475:            break;
                    476:         case 7:
1.1.1.3   root      477:            currprefs.gfx_linedbl = !currprefs.gfx_linedbl;
1.1       root      478:            break;
1.1.1.2   root      479:         case 8:
1.1.1.3   root      480:            currprefs.gfx_correct_aspect = !currprefs.gfx_correct_aspect;
                    481:            break;
                    482:         case 9:
                    483:            currprefs.framerate++;
                    484:            if (currprefs.framerate > 9)
                    485:                currprefs.framerate=1;
1.1       root      486:            break;
1.1.1.5   root      487:         case 10:
                    488:            currprefs.gfxmem_size += 0x100000;
                    489:            if (currprefs.gfxmem_size > 0x800000)
                    490:                currprefs.gfxmem_size = 0;
                    491:            break;
1.1       root      492:        }
                    493:     }
                    494: }
                    495: 
1.1.1.4   root      496: static void MemoryOptions (void)
1.1       root      497: {
1.1.1.3   root      498:     char *tmp;
1.1.1.2   root      499:     int c = 0;
1.1       root      500:     for (;;) {
                    501: 
                    502:        tui_selwin(0);
1.1.1.4   root      503:        print_configuration ();
1.1       root      504: 
1.1.1.4   root      505:        c = tui_menubrowse (memorymenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      506:        if (c == -1)
1.1       root      507:            break;
1.1.1.4   root      508:        else switch (c) {
1.1.1.2   root      509:         case 0:
1.1.1.5   root      510:            if (currprefs.fastmem_size == 0)
                    511:                currprefs.fastmem_size = 0x200000;
                    512:            else if (currprefs.fastmem_size == 0x800000)
                    513:                currprefs.fastmem_size = 0;
1.1       root      514:            else
1.1.1.5   root      515:                currprefs.fastmem_size <<= 1;
1.1       root      516:            break;
1.1.1.2   root      517:         case 1:
1.1.1.5   root      518:            if (currprefs.chipmem_size == 0x800000)
                    519:                currprefs.chipmem_size = 0x80000;
1.1       root      520:            else
1.1.1.5   root      521:                currprefs.chipmem_size <<= 1;
                    522:            if (currprefs.chipmem_size > 0x200000)
                    523:                currprefs.fastmem_size = 0;
1.1.1.3   root      524:            break;
1.1.1.2   root      525:         case 2:
1.1.1.5   root      526:            if (currprefs.bogomem_size == 0)
                    527:                currprefs.bogomem_size = 0x40000;
                    528:            else if (currprefs.bogomem_size == 0x100000)
                    529:                currprefs.bogomem_size = 0;
1.1       root      530:            else
1.1.1.5   root      531:                currprefs.bogomem_size <<= 1;
1.1       root      532:            break;
1.1.1.3   root      533:         case 3:
1.1.1.6 ! root      534:            tmp = tui_filereq ("*.rom", currprefs.romfile, "Select a ROM image");
1.1.1.3   root      535:            if (tmp != NULL)
1.1.1.6 ! root      536:                strcpy (currprefs.romfile, tmp);
1.1.1.5   root      537:            break;
                    538:        }
                    539:     }
                    540: }
                    541: 
                    542: static void CPUOptions (void)
                    543: {
                    544:     char *tmp;
                    545:     int c = 0;
                    546:     for (;;) {
                    547:        tui_selwin(0);
                    548:        print_configuration ();
                    549: 
                    550:        c = tui_menubrowse (cpumenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
                    551:        if (c == -1)
                    552:            break;
                    553:        else switch (c) {
                    554:         case 0:
                    555:            currprefs.cpu_level++;
                    556:            if (currprefs.cpu_level > 3)
                    557:                currprefs.cpu_level = 0;
                    558:            /* Default to 32 bit addressing when switching from a 68000/68010 to a 32 bit CPU */
                    559:            if (currprefs.cpu_level == 2)
                    560:                currprefs.address_space_24 = 0;
                    561:            if (currprefs.cpu_level != 0)
                    562:                currprefs.cpu_compatible = 0;
1.1.1.3   root      563:            break;
                    564:        }
1.1       root      565:     }
                    566: }
                    567: 
1.1.1.4   root      568: static void SoundOptions (void)
1.1       root      569: {
1.1.1.3   root      570:     char tmp[256];
1.1.1.2   root      571:     int c = 0;
1.1       root      572:     for (;;) {
                    573:        tui_selwin(0);
1.1.1.4   root      574:        print_configuration ();
                    575:        c = tui_menubrowse (soundmenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      576:        if (c == -1)
1.1       root      577:            break;
1.1.1.4   root      578:        else switch (c) {
1.1.1.2   root      579:         case 0:
1.1.1.3   root      580:            currprefs.produce_sound++;
1.1.1.4   root      581:            if (currprefs.produce_sound > 3)
1.1.1.3   root      582:                currprefs.produce_sound = 0;
                    583:            break;
                    584: 
                    585:         case 1:
1.1.1.4   root      586:            tui_wgets (tmp, "Enter new minimum sound buffer size in bytes", 6);
1.1.1.3   root      587:            if (atoi (tmp) < 128 || atoi (tmp) > 65536 || atoi (tmp) > currprefs.sound_maxbsiz)
1.1.1.4   root      588:                tui_errorbox ("Insane value for minimum sound buffer size");
1.1.1.3   root      589:            else
                    590:                currprefs.sound_minbsiz = atoi (tmp);
                    591:            break;
                    592: 
                    593:         case 2:
1.1.1.4   root      594:            tui_wgets (tmp, "Enter new maximum sound buffer size in bytes", 6);
1.1.1.3   root      595:            if (atoi (tmp) < 128 || atoi (tmp) > 65536 || atoi (tmp) < currprefs.sound_minbsiz)
1.1.1.4   root      596:                tui_errorbox ("Insane value for maximum sound buffer size");
1.1.1.3   root      597:            else
                    598:                currprefs.sound_maxbsiz = atoi (tmp);
                    599:            break;
                    600: 
                    601:         case 3:
1.1.1.4   root      602:            tui_wgets (tmp, "Enter new number of bits", 3);
1.1.1.3   root      603:            if (atoi (tmp)!= 8 && atoi (tmp) != 16)
1.1.1.4   root      604:                tui_errorbox ("Unsupported number of bits");
1.1.1.3   root      605:            else
                    606:                currprefs.sound_bits = atoi (tmp);
                    607:            break;
                    608: 
                    609:         case 4:
1.1.1.4   root      610:            tui_wgets (tmp, "Enter new sound output frequency", 6);
1.1.1.3   root      611:            if (atoi (tmp) < 11025 || atoi (tmp) > 44100)
1.1.1.4   root      612:                tui_errorbox ("Unsupported frequency");
1.1.1.3   root      613:            else
                    614:                currprefs.sound_freq = atoi (tmp);
1.1       root      615:            break;
1.1.1.5   root      616:         case 5:
                    617:            currprefs.stereo = !currprefs.stereo;
                    618:            break;
1.1.1.3   root      619:        }
1.1       root      620:     }
                    621: }
                    622: 
1.1.1.4   root      623: static void OtherOptions (void)
1.1       root      624: {
1.1.1.3   root      625:     char tmp[256];
1.1.1.2   root      626:     int c = 0;
1.1       root      627: 
                    628:     for (;;) {
1.1.1.3   root      629:        tui_selwin (0);
                    630:        print_configuration ();
                    631:        c = tui_menubrowse (miscmenu, MENU_COL_OFFSET, 5, c, MAX_MENU_HEIGHT);
1.1.1.2   root      632:        if (c == -1) {
1.1       root      633:            break;
1.1.1.4   root      634:        } else switch (c) {
1.1.1.2   root      635:         case 0:
1.1.1.6 ! root      636:            currprefs.jport0 = (currprefs.jport0 + 1) % 6;
        !           637:            if (currprefs.jport0 == currprefs.jport1)
        !           638:              currprefs.jport1 = (currprefs.jport1 + 5) % 6;          
1.1.1.3   root      639:            break;
1.1.1.2   root      640:         case 1:
1.1.1.6 ! root      641:            currprefs.jport1 = (currprefs.jport1 + 1) % 6;
        !           642:            if (currprefs.jport0 == currprefs.jport1)
        !           643:              currprefs.jport0 = (currprefs.jport0 + 5) % 6;
1.1.1.3   root      644:            break;
                    645:         case 2:
1.1.1.4   root      646:            tui_wgets (tmp, "Enter new CPU emulation speed", 6);
1.1.1.3   root      647:            if (atoi (tmp) < 1 || atoi (tmp) > 20)
1.1.1.4   root      648:                tui_errorbox ("Unsupported CPU emulation speed");
1.1.1.3   root      649:            else
                    650:                currprefs.m68k_speed = atoi (tmp);
1.1       root      651:            break;
                    652:        }
                    653:     }
                    654: }
                    655: 
1.1.1.4   root      656: static int do_gui (int mode)
1.1       root      657: {
                    658:     char cwd[1024];
1.1.1.2   root      659: 
1.1.1.4   root      660:     if (getcwd (cwd, 1024) == NULL)
1.1       root      661:        return 0;
                    662: 
1.1.1.4   root      663:     tui_setup ();
1.1.1.3   root      664: 
1.1       root      665:     for (;;) {
                    666:        int c;
1.1.1.3   root      667: 
1.1.1.4   root      668:        tui_selwin (0);
                    669:        print_configuration ();
                    670:        c = tui_menubrowse (mode == 0 ? mainmenu2 : mainmenu, MENU_COL_OFFSET, 4, 0, MAX_MENU_HEIGHT);
1.1.1.2   root      671:        if (c == -1) {
1.1.1.4   root      672:            tui_shutdown ();
1.1.1.2   root      673:            return -2;
1.1.1.3   root      674:        }
                    675:        if (mode == 1) {
1.1.1.5   root      676:            if (c == 8)
1.1.1.3   root      677:                break;
                    678:            switch (c) {
                    679:             case 0: DiskOptions (); break;
                    680:             case 1: VideoOptions (); break;
                    681:             case 2: MemoryOptions (); break;
1.1.1.5   root      682:             case 3: CPUOptions (); break;
                    683:             case 4: HDOptions (); break;
                    684:             case 5: SoundOptions (); break;
                    685:             case 6: OtherOptions (); break;
                    686:             case 7: save_settings (); break;
1.1.1.3   root      687:            }
                    688:        } else {
                    689:            if (c == 5)
                    690:                break;
                    691:            switch (c) {
                    692:             case 0: DiskOptions (); break;
                    693:             case 1: OtherOptions (); break;
                    694:             case 2: save_settings (); break;
                    695:             case 3: uae_reset (); break;
                    696:             case 4: uae_quit (); break;
                    697:            }
1.1       root      698:        }
                    699:     }
1.1.1.4   root      700:     tui_shutdown ();
1.1.1.3   root      701: 
1.1       root      702:     chdir (cwd);
                    703:     return 0;
                    704: }
1.1.1.2   root      705: 
1.1.1.4   root      706: int gui_init (void)
1.1.1.2   root      707: {
1.1.1.4   root      708:     return do_gui (1);
1.1.1.2   root      709: }
                    710: 
1.1.1.4   root      711: void gui_changesettings (void)
1.1.1.3   root      712: {
                    713:     struct uae_prefs oldprefs;
                    714:     oldprefs = currprefs;
                    715: 
                    716:     if (do_gui(0) == -2)
                    717:        uae_quit ();
                    718:     else {
                    719:        changed_prefs = currprefs;
                    720:        currprefs = oldprefs;
1.1.1.6 ! root      721:        currprefs.jport0 = changed_prefs.jport0;
        !           722:        currprefs.jport1 = changed_prefs.jport1;
1.1.1.3   root      723:        joystick_setting_changed ();
                    724:     }
                    725: }
                    726: 
1.1.1.4   root      727: int gui_update (void)
1.1.1.2   root      728: {
1.1.1.3   root      729:     return 0;
1.1.1.2   root      730: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.