|
|
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.2 ! root 18: #include "uae.h"
1.1 root 19: #include "os.h"
20: #include "autoconf.h"
21: #include "tui.h"
22: #include "gui.h"
23: #include "memory.h"
24:
25: char *colormodes[] = { "256 colors", "32768 colors", "65536 colors",
26: "256 colors dithered", "16 colors dithered", "16 million colors" };
27:
28: int quit_program;
29:
30: char mountvol[256] = "\0";
31: char mountdir[256] = "\0";
32: int mountok=0;
33:
34: void gui_led(int led, int on)
35: {
36: }
1.1.1.2 ! root 37: void gui_filename(int num, const char *name)
1.1 root 38: {
39: }
40: static void getline(char *p)
41: {
42: }
43: void gui_handle_events(void)
44: {
45: }
46:
47: static void save_options(FILE *f)
48: {
49: /* We only get here if allow_save is true, so... */
50: fprintf(f, "-o\n");
51: if (use_debugger)
52: fprintf(f, "-D\n");
53: fprintf(f, "-r %s\n", romfile);
54: fprintf(f, "-0 %s\n", df0);
55: fprintf(f, "-1 %s\n", df1);
56: fprintf(f, "-2 %s\n", df2);
57: fprintf(f, "-3 %s\n", df3);
58: fprintf(f, "-p %s\n", prtname);
59: fprintf(f, "-S %d\n", produce_sound);
60: if (fake_joystick)
61: fprintf(f, "-J\n");
62: fprintf(f, "-l %s\n", (keyboard_lang == KBD_LANG_DE ? "de"
63: : keyboard_lang == KBD_LANG_US ? "us"
64: : keyboard_lang == KBD_LANG_SE ? "se"
65: : keyboard_lang == KBD_LANG_FR ? "fr"
66: : keyboard_lang == KBD_LANG_IT ? "it"
67: : "FOO"));
68: fprintf(f, "-f %d\n", framerate);
1.1.1.2 ! root 69: fprintf(f, "-O %d:%d:", gfx_requested_width, gfx_requested_height);
! 70: if (gfx_requested_lores)
! 71: fprintf(f, "l");
! 72: switch (gfx_requested_xcenter) {
! 73: case 1: fprintf(f, "x"); break;
! 74: case 2: fprintf(f, "X"); break;
! 75: default: break;
! 76: }
! 77: switch (gfx_requested_ycenter) {
! 78: case 1: fprintf(f, "y"); break;
! 79: case 2: fprintf(f, "Y"); break;
! 80: default: break;
! 81: }
! 82: if (gfx_requested_linedbl)
! 83: fprintf(f, "d");
! 84: if (gfx_requested_correct_aspect)
! 85: fprintf(f, "c");
! 86: fprintf(f, "\n-H %d\n", color_mode);
1.1 root 87: if (fastmem_size > 0)
88: fprintf(f, "-F %d\n", fastmem_size / 0x100000);
89: if (bogomem_size > 0)
90: fprintf(f, "-s %d\n", bogomem_size / 0x40000);
91: fprintf(f, "-c %d\n", chipmem_size / 0x80000);
92: if (!automount_uaedev)
93: fprintf(f, "-a\n");
94: fprintf(f, "-B %d\n", sound_desired_bsiz);
95: fprintf(f, "-b %d\n", sound_desired_bits);
96: fprintf(f, "-R %d\n", sound_desired_freq);
1.1.1.2 ! root 97: fprintf(f, "-A %d\n", emul_accuracy);
! 98: /* We don't write "-t" - I can hardly imagine a user who wants that in his
! 99: * config file. */
1.1 root 100: write_filesys_config(f);
101: }
102:
103: void gui_exit()
104: {
105: if (allow_save) {
1.1.1.2 ! root 106: FILE *f;
! 107: tui_backup_optionsfile();
! 108: f = fopen(optionsfile, "w");
! 109: if (f == NULL) {
! 110: fprintf(stderr, "Error saving options file!\n");
! 111: return;
1.1 root 112: }
1.1.1.2 ! root 113: save_options(f);
! 114: fclose(f);
1.1 root 115: }
116: }
117:
1.1.1.2 ! root 118: static struct bstring mainmenu[] = {
! 119: { "UAE main menu", 0 },
! 120: { "_Disk settings", 'D' },
! 121: { "_Video settings", 'V' },
! 122: { "_Memory settings", 'M' },
! 123: { "_Hard disk settings", 'H' },
! 124: { "_Sound settings", 'S' },
! 125: { "_Other settings", 'O' },
! 126: { "_Run UAE", 'R' },
! 127: { NULL, -3 }
! 128: };
! 129:
! 130: static const char *mainmenu2[] = {
! 131: "D - Disk settings",
! 132: "S - Sound settings",
! 133: "F - Change frame rate",
! 134: NULL
1.1 root 135: };
136:
1.1.1.2 ! root 137: static struct bstring diskmenu[] = {
! 138: { "Change DF_0:", '0' },
! 139: { "Change DF_1:", '1' },
! 140: { "Change DF_2:", '2' },
! 141: { "Change DF_3:", '3' },
! 142: { NULL, -3 }
1.1 root 143: };
144:
1.1.1.2 ! root 145: static struct bstring videomenu[] = {
! 146: { "Change _width", 'W' },
! 147: { "Change _height", 'H' },
! 148: { "Toggle _low resolution", 'L' },
! 149: { "Change _X centering", 'X' },
! 150: { "Change _Y centering", 'Y' },
! 151: { "Toggle line _doubling", 'D' },
! 152: { "Toggle _aspect _correction", 'A' },
! 153: { "Change _color mode", 'C' },
! 154: { "Change _framerate", 'F' },
! 155: { NULL, -3 }
1.1 root 156: };
157:
1.1.1.2 ! root 158: static struct bstring memorymenu[] = {
! 159: { "Change _fastmem size", 'F' },
! 160: { "Change _chipmem size", 'C' },
! 161: { "Change _slowmem size", 'S' },
! 162: { NULL, -3 }
1.1 root 163: };
164:
1.1.1.2 ! root 165: static struct bstring soundmenu[] = {
! 166: { "Change _sound emulation", 'S' },
! 167: { NULL , -3 }
1.1 root 168: };
169:
1.1.1.2 ! root 170: static struct bstring miscmenu[] = {
! 171: { "1 - Toggle keypad _joystick emulation", 'J' },
! 172: { "2 - Select _ROM image", 'R' },
! 173: { NULL, -3 }
1.1 root 174: };
175:
1.1.1.2 ! root 176: static struct bstring hdmenu[] = {
! 177: { "1 - Enable/Disable _harddisks/fastmem", 'H' },
! 178: { "2 - _Add a mounted volume", 'A' },
! 179: { "3 - Add a mounted _volume r/o", 'V' },
! 180: { "4 - _Remove a mounted volume", 'R' },
! 181: { NULL, -3 }
1.1 root 182: };
183:
184: static int makemenu(const char **menu, int x, int y)
185: {
186: const char **m = menu;
187: int maxlen = 0, count = 0;
188: int w;
189:
190: while (*m != NULL) {
191: int l = strlen(*m);
192: if (l > maxlen)
193: maxlen = l;
194: m++; count++;
195: }
196: w = tui_dlog(x, y, x + maxlen + 2, y + count + 1);
197: tui_drawbox(w);
198: tui_selwin(w);
199: y = 2;
200: while (*menu != NULL) {
201: tui_gotoxy(2, y++);
202: tui_puts(*menu++);
203: }
204: tui_selwin(0);
205: return w;
206: }
207:
208: static char tmpbuf[256];
209:
210: static char *trimfilename(char *s, size_t n)
211: {
212: size_t i;
213: if (n > 250)
214: n = 250;
215: if (strlen(s) == 0)
216: strcpy(tmpbuf, "none");
217: else if (strlen(s) < n)
218: strcpy(tmpbuf, s);
219: else {
220: tmpbuf[0] = '^';
221: strcpy(tmpbuf + 1, s + strlen(s) - n + 2);
222: }
223: for (i = strlen(tmpbuf); i < n; i++)
224: tmpbuf[i] = ' ';
225: tmpbuf[i] = 0;
226: return tmpbuf;
227: }
228:
229: static void print_configuration(void)
230: {
231: char tmp[256];
232: int y = 5;
1.1.1.2 ! root 233: int i;
1.1 root 234:
1.1.1.2 ! root 235: tui_clrwin(0);
1.1 root 236:
1.1.1.2 ! root 237: tui_drawbox(0);
! 238: tui_hline(2, 3, tui_cols() - 1);
! 239: sprintf(tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAEURSAMINOR);
! 240: tui_gotoxy((tui_cols() - strlen(tmp))/2, 2); tui_puts(tmp);
! 241: strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit");
! 242: tui_gotoxy((tui_cols() - strlen(tmp))/2, tui_lines()); tui_puts(tmp);
! 243:
1.1 root 244: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF0: %s", trimfilename(df0, tui_cols() - 50)); tui_puts(tmp);
245: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF1: %s", trimfilename(df1, tui_cols() - 50)); tui_puts(tmp);
246: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF2: %s", trimfilename(df2, tui_cols() - 50)); tui_puts(tmp);
247: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF3: %s", trimfilename(df3, tui_cols() - 50)); tui_puts(tmp);
248: y++;
249: tui_gotoxy(35, y++);
1.1.1.2 ! root 250: sprintf(tmp, "VIDEO: %d:%d%s %s", gfx_requested_width, gfx_requested_height,
! 251: gfx_requested_lores ? " (lores)" : "", colormodes[color_mode]);
1.1 root 252: tui_puts(tmp);
253:
254: tui_gotoxy(42, y++);
1.1.1.2 ! root 255: if (gfx_requested_linedbl)
! 256: tui_puts("Doubling lines, ");
! 257: if (gfx_requested_correct_aspect)
! 258: tui_puts("Aspect corrected");
1.1 root 259: else
260: tui_puts("Not aspect corrected");
261: tui_gotoxy(42, y++);
1.1.1.2 ! root 262: if (gfx_requested_xcenter)
! 263: tui_puts ("X centered");
! 264: if (gfx_requested_xcenter == 2)
! 265: tui_puts (" (clever)");
! 266: if (gfx_requested_ycenter && gfx_requested_xcenter)
! 267: tui_puts (", ");
! 268: if (gfx_requested_ycenter)
! 269: tui_puts ("Y centered ");
! 270: if (gfx_requested_ycenter == 2)
! 271: tui_puts (" (clever)");
! 272: tui_gotoxy(42, y++);
1.1 root 273: tui_puts("drawing every ");
274: switch(framerate) {
275: case 1: break;
276: case 2: tui_puts("2nd "); break;
277: case 3: tui_puts("3rd "); break;
278: default: sprintf(tmp, "%dth ",framerate); tui_puts(tmp); break;
279: }
280: tui_puts("frame. ");
281: y++;
282: tui_gotoxy(35, y++);
283: sprintf(tmp, "MEMORY: %4dK chip; %4dK fast; %4dK slow",chipmem_size/1024,fastmem_size/1024,bogomem_size/1024);
284: tui_puts(tmp);
285:
286: tui_gotoxy(35, y++);
287: sprintf(tmp, "ROM IMAGE: %s", trimfilename(romfile, tui_cols() - 50));
288: tui_puts(tmp);
289: tui_gotoxy(35, y++);
290: if (!sound_available)
1.1.1.2 ! root 291: tui_puts("SOUND: Not available");
1.1 root 292: else {
293: switch (produce_sound) {
1.1.1.2 ! root 294: case 0: tui_puts("SOUND: 0 (Off)"); break;
! 295: case 1: tui_puts("SOUND: 1 (Off, but emulated)"); break;
! 296: case 2: tui_puts("SOUND: 2 (On)"); break;
1.1 root 297: case 3: tui_puts("SOUND: 3 (On, emulated perfectly)"); break;
298: }
299: }
300:
301: tui_gotoxy(35,y++);
302: if(fake_joystick==1) {
303: tui_puts("JOYSTICK: using keypad emulation");
304: } else {
305: if (joystickpresent)
1.1.1.2 ! root 306: tui_puts("JOYSTICK: using joystick #0");
1.1 root 307: else
1.1.1.2 ! root 308: tui_puts("JOYSTICK: no joystick emulation");
1.1 root 309: }
310:
311: tui_gotoxy(35,y++);
1.1.1.2 ! root 312: sprintf(tmp, "HARDDISK: (%s)", automount_uaedev ? "enabled" : "disabled");
! 313: tui_puts(tmp);
1.1 root 314:
1.1.1.2 ! root 315: for (i = 0;; i++) {
! 316: char buf[256];
! 317:
! 318: tui_gotoxy(36,y++);
! 319: if (sprintf_filesys_unit(buf, i) == -1)
! 320: break;
! 321: tui_puts(buf);
1.1 root 322: }
323: }
324:
325: static void HDOptions(void)
326: {
327: char *buff;
328: char tmp[256];
1.1.1.2 ! root 329: int c = 0;
1.1 root 330:
331: for (;;){
332:
333: tui_selwin(0);
334: print_configuration();
1.1.1.2 ! root 335:
! 336: c = tui_menubrowse(hdmenu, 3, 5, c);
! 337: if (c == -1)
! 338: break;
! 339: else switch(c) {
! 340: case 0:
! 341: automount_uaedev=!automount_uaedev;
! 342: break;
! 343: case 1:
! 344: tui_wgets(mountvol, "Enter mounted volume name", 10);
! 345: if (strlen(mountvol) == 0)
! 346: break;
! 347: if(mountvol[strlen(mountvol)-1]==':')
! 348: mountvol[strlen(mountvol)-1] = 0;
! 349: tui_wgets(mountdir, "Enter mounted volume path", 78);
! 350: add_filesys_unit(mountvol, mountdir, 0);
1.1 root 351: break;
1.1.1.2 ! root 352: case 2:
! 353: tui_wgets(mountvol, "Enter mounted volume name", 10);
! 354: if (strlen(mountvol) == 0)
! 355: break;
! 356: if(mountvol[strlen(mountvol)-1]==':')
! 357: mountvol[strlen(mountvol)-1] = 0;
1.1 root 358: tui_wgets(mountdir, "Enter mounted volume path", 78);
1.1.1.2 ! root 359: add_filesys_unit(mountvol, mountdir, 1);
! 360: break;
! 361: case 3:
! 362: tui_wgets(mountvol, "Enter name of volume to be removed", 10);
! 363: if (kill_filesys_unit(mountvol) == -1)
! 364: tui_errorbox("Volume does not exist");
1.1 root 365: break;
366: }
367: }
368: }
369:
370: static void DiskOptions(void)
371: {
1.1.1.2 ! root 372: char buf[256], tmp[256];
! 373: int c = 0;
! 374:
1.1 root 375: for (;;) {
376: char *sel;
1.1.1.2 ! root 377:
1.1 root 378: tui_selwin(0);
379: print_configuration();
380:
1.1.1.2 ! root 381: c = tui_menubrowse(diskmenu, 3, 5, c);
! 382: if (c == -1)
1.1 root 383: break;
1.1.1.2 ! root 384: else switch(c) {
! 385: case 0:
1.1 root 386: sel = tui_filereq("*.adf", df0);
387: if (sel == NULL)
388: break;
389: strcpy(df0, sel);
390: break;
1.1.1.2 ! root 391: case 1:
1.1 root 392: sel = tui_filereq("*.adf", df1);
393: if (sel == NULL)
394: break;
395: strcpy(df1, sel);
396: break;
1.1.1.2 ! root 397: case 2:
1.1 root 398: sel = tui_filereq("*.adf", df2);
399: if (sel == NULL)
400: break;
401: strcpy(df2, sel);
402: break;
1.1.1.2 ! root 403: case 3:
1.1 root 404: sel = tui_filereq("*.adf", df3);
405: if (sel == NULL)
406: break;
407: strcpy(df3, sel);
408: break;
409: }
410: }
411: }
412:
413: static void VideoOptions(void)
414: {
415: char tmp[256];
1.1.1.2 ! root 416: int c = 0;
1.1 root 417:
418: for (;;) {
419:
420: tui_selwin(0);
421: print_configuration();
1.1.1.2 ! root 422:
! 423: c = tui_menubrowse(videomenu, 3, 5, c);
! 424: if (c == -1)
! 425: break;
! 426: else switch(c) {
! 427: case 0:
! 428: tui_wgets(tmp, "Enter new video mode width", 4);
! 429: if (atoi (tmp) < 320 || atoi (tmp) > 1600 /* maybe we'll implement SHires */)
! 430: tui_errorbox("Insane value for video mode width");
! 431: else
! 432: gfx_requested_width = atoi (tmp);
! 433: break;
! 434: case 1:
! 435: tui_wgets(tmp, "Enter new video mode height", 4);
! 436: if (atoi (tmp) < 200 || atoi (tmp) > 800 /* whatever */)
! 437: tui_errorbox("Insane value for video mode height");
! 438: else
! 439: gfx_requested_height = atoi (tmp);
! 440: break;
! 441: case 2:
! 442: gfx_requested_lores = !gfx_requested_lores;
1.1 root 443: break;
1.1.1.2 ! root 444: case 3:
! 445: gfx_requested_xcenter = (gfx_requested_xcenter + 1) % 3;
! 446: break;
! 447: case 4:
! 448: gfx_requested_ycenter = (gfx_requested_ycenter + 1) % 3;
! 449: break;
! 450: case 5:
! 451: gfx_requested_linedbl = !gfx_requested_linedbl;
! 452: break;
! 453: case 6:
! 454: gfx_requested_correct_aspect = !gfx_requested_correct_aspect;
! 455: break;
! 456: case 7:
1.1 root 457: color_mode++;
458: if (color_mode > MAX_COLOR_MODES)
459: color_mode=0;
460: break;
1.1.1.2 ! root 461: case 8:
1.1 root 462: framerate++;
463: if (framerate > 9)
464: framerate=1;
465: break;
466: }
467: }
468: }
469:
470: static void MemoryOptions(void)
471: {
1.1.1.2 ! root 472: int c = 0;
1.1 root 473: for (;;) {
474:
475: tui_selwin(0);
476: print_configuration();
477:
1.1.1.2 ! root 478: c = tui_menubrowse(memorymenu, 3, 5, c);
! 479: if (c == -1)
1.1 root 480: break;
1.1.1.2 ! root 481: else switch(c) {
! 482: case 0:
1.1 root 483: if (fastmem_size == 0)
484: fastmem_size = 0x200000;
485: else if (fastmem_size == 0x800000)
486: fastmem_size = 0;
487: else
488: fastmem_size <<= 1;
489: break;
1.1.1.2 ! root 490: case 1:
! 491: if (chipmem_size == 0x800000)
1.1 root 492: chipmem_size = 0x80000;
493: else
494: chipmem_size <<= 1;
495: break;
1.1.1.2 ! root 496: case 2:
1.1 root 497: if (bogomem_size == 0)
498: bogomem_size = 0x40000;
499: else if (bogomem_size == 0x100000)
500: bogomem_size = 0;
501: else
502: bogomem_size <<= 1;
503: break;
504: }
505:
506: }
507: }
508:
509: static void SoundOptions(void)
510: {
1.1.1.2 ! root 511: int c = 0;
1.1 root 512: for (;;) {
513:
514: tui_selwin(0);
515: print_configuration();
1.1.1.2 ! root 516: c = tui_menubrowse(soundmenu, 3, 5, c);
! 517: if (c == -1)
1.1 root 518: break;
1.1.1.2 ! root 519: else switch(c) {
! 520: case 0:
1.1 root 521: produce_sound++;
522: if(produce_sound > 3)
523: produce_sound = 0;
524: break;
525: }
526: }
527: }
528:
529: static void OtherOptions(void)
530: {
531: char *tmp;
1.1.1.2 ! root 532: int c = 0;
1.1 root 533:
534: for (;;) {
535:
536: tui_selwin(0);
537: print_configuration();
1.1.1.2 ! root 538: c = tui_menubrowse(miscmenu, 3, 5, c);
! 539: if (c == -1) {
1.1 root 540: break;
1.1.1.2 ! root 541: } else switch(c) {
! 542: case 0:
1.1 root 543: fake_joystick = !fake_joystick;
544: break;
1.1.1.2 ! root 545: case 1:
1.1 root 546: tmp = tui_filereq("*.rom", romfile);
547: if (tmp != NULL)
548: strcpy(romfile, tmp);
549: break;
550: }
551: }
552: }
553:
1.1.1.2 ! root 554: static int do_gui(int mode)
1.1 root 555: {
556: char cwd[1024];
1.1.1.2 ! root 557:
1.1 root 558: if (getcwd(cwd, 1024) == NULL)
559: return 0;
560:
561: quit_program = 0;
562:
563: tui_setup();
1.1.1.2 ! root 564:
1.1 root 565: for (;;) {
566: int c;
1.1.1.2 ! root 567:
1.1 root 568: tui_selwin(0);
569: print_configuration();
1.1.1.2 ! root 570: c = tui_menubrowse(mainmenu, 2, 4, 0);
! 571: if (c == -1) {
1.1 root 572: tui_shutdown();
1.1.1.2 ! root 573: return -2;
! 574: } else if (c == 6) {
1.1 root 575: break;
1.1.1.2 ! root 576: } else switch (c) {
! 577: case 0: DiskOptions(); break;
! 578: case 1: VideoOptions(); break;
! 579: case 2: MemoryOptions(); break;
! 580: case 3: HDOptions(); break;
! 581: case 4: SoundOptions(); break;
! 582: case 5: OtherOptions(); break;
1.1 root 583: }
584: }
585: tui_shutdown();
1.1.1.2 ! root 586:
1.1 root 587: chdir (cwd);
588: return 0;
589: }
1.1.1.2 ! root 590:
! 591: int gui_init(void)
! 592: {
! 593: return do_gui(1);
! 594: }
! 595:
! 596: int gui_update(void)
! 597: {
! 598: return 0;
! 599: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.