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

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

unix.superglobalmegacorp.com

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