|
|
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"
18: #include "os.h"
19: #include "autoconf.h"
20: #include "tui.h"
21: #include "gui.h"
22: #include "memory.h"
23:
24: char *screenmodes[] = { "320x200", "320x240", "320x400", "640x480", "800x600" };
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: }
37: void gui_filename(int num, char *name)
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);
69: fprintf(f, "-d %d\n", screen_res);
70: if (correct_aspect)
71: fprintf(f, "-C\n");
72: fprintf(f, "-H %d\n", color_mode);
73: if (fastmem_size > 0)
74: fprintf(f, "-F %d\n", fastmem_size / 0x100000);
75: if (bogomem_size > 0)
76: fprintf(f, "-s %d\n", bogomem_size / 0x40000);
77: fprintf(f, "-c %d\n", chipmem_size / 0x80000);
78: if (!automount_uaedev)
79: fprintf(f, "-a\n");
80: fprintf(f, "-B %d\n", sound_desired_bsiz);
81: fprintf(f, "-b %d\n", sound_desired_bits);
82: fprintf(f, "-R %d\n", sound_desired_freq);
83:
84: write_filesys_config(f);
85: }
86:
87: void gui_exit()
88: {
89: if (allow_save) {
90: if (tui_backup_optionsfile() == 0) {
91: FILE *f = fopen(optionsfile, "w");
92: if (f == NULL) {
93: fprintf(stderr, "Error saving options file!\n");
94: return;
95: }
96: save_options(f);
97: fclose(f);
98: }
99: }
100: }
101:
102: static const char *mainmenu[] = {
103: "D - Disk settings",
104: "V - Video settings",
105: "M - Memory settings",
106: "H - Hard disk settings",
107: "S - Sound settings",
108: "O - Other settings",
109: NULL
110: };
111:
112: static const char *diskmenu[] = {
113: "0 - change DF0:",
114: "1 - change DF1:",
115: "2 - change DF2:",
116: "3 - change DF3:",
117: NULL
118: };
119:
120: static const char *videomenu[] = {
121: "1 - Change resolution",
122: "2 - Change color mode",
123: "3 - Toggle aspect correction",
124: "4 - Change framerate",
125: NULL
126: };
127:
128: static const char *memmenu[] = {
129: "1 - Change fastmem size",
130: "2 - Change chipmem size",
131: "3 - Change slowmem size",
132: NULL
133: };
134:
135: static const char *soundmenu[] = {
136: "1 - Change sound emulation",
137: NULL
138: };
139:
140: static const char *miscmenu[] = {
141: "1 - Toggle keypad joystick emulation",
142: "2 - Select ROM image",
143: NULL
144: };
145:
146: static const char *hdmenu[] = {
147: "1 - Enable/Disable HardDrive file",
148: "2 - Change Mounted volume name",
149: "3 - Change Mounted volume path",
150: "4 - Enable/Disable Mounted volume",
151: NULL
152: };
153:
154: static int makemenu(const char **menu, int x, int y)
155: {
156: const char **m = menu;
157: int maxlen = 0, count = 0;
158: int w;
159:
160: while (*m != NULL) {
161: int l = strlen(*m);
162: if (l > maxlen)
163: maxlen = l;
164: m++; count++;
165: }
166: w = tui_dlog(x, y, x + maxlen + 2, y + count + 1);
167: tui_drawbox(w);
168: tui_selwin(w);
169: y = 2;
170: while (*menu != NULL) {
171: tui_gotoxy(2, y++);
172: tui_puts(*menu++);
173: }
174: tui_selwin(0);
175: return w;
176: }
177:
178: static char tmpbuf[256];
179:
180: static char *trimfilename(char *s, size_t n)
181: {
182: size_t i;
183: if (n > 250)
184: n = 250;
185: if (strlen(s) == 0)
186: strcpy(tmpbuf, "none");
187: else if (strlen(s) < n)
188: strcpy(tmpbuf, s);
189: else {
190: tmpbuf[0] = '^';
191: strcpy(tmpbuf + 1, s + strlen(s) - n + 2);
192: }
193: for (i = strlen(tmpbuf); i < n; i++)
194: tmpbuf[i] = ' ';
195: tmpbuf[i] = 0;
196: return tmpbuf;
197: }
198:
199: static void print_configuration(void)
200: {
201: char tmp[256];
202: int y = 5;
203:
204: /* tui_clrarea(35,4,79,20);*/
205:
206: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF0: %s", trimfilename(df0, tui_cols() - 50)); tui_puts(tmp);
207: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF1: %s", trimfilename(df1, tui_cols() - 50)); tui_puts(tmp);
208: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF2: %s", trimfilename(df2, tui_cols() - 50)); tui_puts(tmp);
209: tui_gotoxy(35, y++); sprintf(tmp, "Disk file DF3: %s", trimfilename(df3, tui_cols() - 50)); tui_puts(tmp);
210: y++;
211: tui_gotoxy(35, y++);
212: sprintf(tmp, "VIDEO: %-7s %-19s ",screenmodes[screen_res], colormodes[color_mode]);
213: tui_puts(tmp);
214:
215: tui_gotoxy(42, y++);
216: if (correct_aspect)
217: tui_puts("Aspect corrected ");
218: else
219: tui_puts("Not aspect corrected");
220: tui_gotoxy(42, y++);
221: tui_puts("drawing every ");
222: switch(framerate) {
223: case 1: break;
224: case 2: tui_puts("2nd "); break;
225: case 3: tui_puts("3rd "); break;
226: default: sprintf(tmp, "%dth ",framerate); tui_puts(tmp); break;
227: }
228: tui_puts("frame. ");
229: y++;
230: tui_gotoxy(35, y++);
231: sprintf(tmp, "MEMORY: %4dK chip; %4dK fast; %4dK slow",chipmem_size/1024,fastmem_size/1024,bogomem_size/1024);
232: tui_puts(tmp);
233:
234: tui_gotoxy(35, y++);
235: sprintf(tmp, "ROM IMAGE: %s", trimfilename(romfile, tui_cols() - 50));
236: tui_puts(tmp);
237: tui_gotoxy(35, y++);
238: if (!sound_available)
239: tui_puts("SOUNDS: Not available");
240: else {
241: switch (produce_sound) {
242: case 0: tui_puts("SOUND: 0 (Off) "); break;
243: case 1: tui_puts("SOUND: 1 (Off, but emulated) "); break;
244: case 2: tui_puts("SOUND: 2 (On) "); break;
245: case 3: tui_puts("SOUND: 3 (On, emulated perfectly)"); break;
246: }
247: }
248:
249: tui_gotoxy(35,y++);
250: if(fake_joystick==1) {
251: tui_puts("JOYSTICK: using keypad emulation");
252: } else {
253: if (joystickpresent)
254: tui_puts("JOYSTICK: using joystick #0 ");
255: else
256: tui_puts("JOYSTICK: no joystick emulation ");
257: }
258:
259: tui_gotoxy(35,y++);
260: tui_puts("HARDDISK: ");
261: if(hardfile_size>16) {
262: sprintf(tmp, "Current Harddisk file = %d K is", hardfile_size/1024);
263: tui_puts(tmp);
264: if (automount_uaedev==1) {
265: tui_puts(" active");
266: } else {
267: tui_puts(" not active");
268: }
269: } else {
270: tui_puts("No Harddisk file available ");
271: }
272:
273: tui_gotoxy(35,y++);
274: if(mountok==1) {
275: sprintf(tmp, "Mounting volume %s at %s",mountvol,mountdir); tui_puts(tmp);
276: }
277: tui_refresh();
278: }
279:
280: static void HDOptions(void)
281: {
282: char *buff;
283: char tmp[256];
284:
285: int w = makemenu(hdmenu, 3, 5);
286:
287: for (;;){
288: int c;
289:
290: tui_selwin(0);
291: print_configuration();
292: tui_refresh();
293: tui_selwin(w);
294: tui_refresh();
295: c = tui_getc();
296: if (c == 27 || c == 13)
297: break;
298: switch(c) {
299: case '1':
300: automount_uaedev=!automount_uaedev; break;
301: case '2':
302: tui_wgets(mountvol, "Enter mounted volume name", 78);
303: if(mountvol[strlen(mountvol)-1]==':') {
304: mountvol[strlen(mountvol)-1]=0; }
305: break;
306: case '3':
307: tui_wgets(mountdir, "Enter mounted volume path", 78);
308: break;
309: case '4': mountok=!mountok; break;
310: }
311: }
312: tui_dlogdie(w);
313: }
314:
315: static void DiskOptions(void)
316: {
317: char buf[256], tmp[256];
318: int w = makemenu(diskmenu, 3, 5);
319:
320: for (;;) {
321: char *sel;
322: int c;
323:
324: tui_selwin(0);
325: print_configuration();
326: tui_refresh();
327: tui_selwin(w);
328: tui_refresh();
329:
330: c = tui_getc();
331: if (c == 27 || c == 13)
332: break;
333: switch(c) {
334: case '0':
335: sel = tui_filereq("*.adf", df0);
336: if (sel == NULL)
337: break;
338: strcpy(df0, sel);
339: break;
340: case '1':
341: sel = tui_filereq("*.adf", df1);
342: if (sel == NULL)
343: break;
344: strcpy(df1, sel);
345: break;
346: case '2':
347: sel = tui_filereq("*.adf", df2);
348: if (sel == NULL)
349: break;
350: strcpy(df2, sel);
351: break;
352: case '3':
353: sel = tui_filereq("*.adf", df3);
354: if (sel == NULL)
355: break;
356: strcpy(df3, sel);
357: break;
358: }
359: }
360: tui_dlogdie(w);
361: }
362:
363: static void VideoOptions(void)
364: {
365: char tmp[256];
366: int w = makemenu(videomenu, 3, 5);
367:
368: for (;;) {
369: int c;
370:
371: tui_selwin(0);
372: print_configuration();
373: tui_refresh();
374: tui_selwin(w);
375: tui_refresh();
376:
377: c = tui_getc();
378: if (c == 27 || c == 13)
379: break;
380: switch(c) {
381: case 49:
382: screen_res++;
383: if (screen_res > MAX_SCREEN_MODES)
384: screen_res=0;
385: break;
386: case 50:
387: color_mode++;
388: if (color_mode > MAX_COLOR_MODES)
389: color_mode=0;
390: break;
391: case 51:
392: correct_aspect = !correct_aspect;
393: break;
394: case 52:
395: framerate++;
396: if (framerate > 9)
397: framerate=1;
398: break;
399: }
400: }
401: tui_dlogdie(w);
402: }
403:
404: static void MemoryOptions(void)
405: {
406: int w = makemenu(memmenu, 3, 5);
407: for (;;) {
408: int c;
409:
410: tui_selwin(0);
411: print_configuration();
412: tui_refresh();
413: tui_selwin(w);
414: tui_refresh();
415:
416: c = tui_getc();
417: if (c == 27 || c == 13)
418: break;
419: switch(c) {
420: case '1':
421: if (fastmem_size == 0)
422: fastmem_size = 0x200000;
423: else if (fastmem_size == 0x800000)
424: fastmem_size = 0;
425: else
426: fastmem_size <<= 1;
427: break;
428: case '2':
429: if (chipmem_size == 0x200000)
430: chipmem_size = 0x80000;
431: else
432: chipmem_size <<= 1;
433: break;
434: case '3':
435: if (bogomem_size == 0)
436: bogomem_size = 0x40000;
437: else if (bogomem_size == 0x100000)
438: bogomem_size = 0;
439: else
440: bogomem_size <<= 1;
441: break;
442: }
443:
444: }
445: tui_dlogdie(w);
446: }
447:
448: static void SoundOptions(void)
449: {
450: int w = makemenu(soundmenu, 3, 5);
451:
452: for (;;) {
453: int c;
454:
455: tui_selwin(0);
456: print_configuration();
457: tui_refresh();
458: tui_selwin(w);
459: tui_refresh();
460:
461: c = tui_getc();
462: if (c == 27 || c == 13)
463: break;
464: switch(c) {
465: case '1':
466: produce_sound++;
467: if(produce_sound > 3)
468: produce_sound = 0;
469: break;
470:
471: }
472: }
473: tui_dlogdie(w);
474: }
475:
476: static void OtherOptions(void)
477: {
478: char *tmp;
479: int w = makemenu(miscmenu, 3, 5);
480:
481: for (;;) {
482: int c;
483:
484: tui_selwin(0);
485: print_configuration();
486: tui_refresh();
487: tui_selwin(w);
488: tui_refresh();
489:
490: c = tui_getc();
491: if (c == 27 || c == 13)
492: break;
493: switch(c) {
494: case '1':
495: fake_joystick = !fake_joystick;
496: break;
497: case '2':
498: tmp = tui_filereq("*.rom", romfile);
499: if (tmp != NULL)
500: strcpy(romfile, tmp);
501: break;
502: }
503: }
504: tui_dlogdie(w);
505: }
506:
507: int gui_init()
508: {
509: char cwd[1024];
510: char tmp[256];
511: int mm_win;
512:
513: if (getcwd(cwd, 1024) == NULL)
514: return 0;
515:
516: quit_program = 0;
517:
518: tui_setup();
519:
520: tui_drawbox(0);
521: tui_hline(2, 3, tui_cols() - 1);
522: sprintf(tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAEURSAMINOR);
523: tui_gotoxy((tui_cols() - strlen(tmp))/2, 2); tui_puts(tmp);
524: strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit");
525: tui_gotoxy((tui_cols() - strlen(tmp))/2, tui_lines()); tui_puts(tmp);
526:
527: mm_win = makemenu(mainmenu, 2, 4);
528:
529: for (;;) {
530: int c;
531: tui_selwin(0);
532: print_configuration();
533: tui_refresh();
534: tui_selwin(mm_win);
535: tui_refresh();
536: c = tui_getc();
537:
538: if (c == 27) {
539: tui_dlogdie(mm_win);
540: tui_shutdown();
541: exit(0);
542: } else if (c == 13) {
543: break;
544: }
545:
546: switch(c) {
547: case 100: DiskOptions(); break;
548: case 118: VideoOptions(); break;
549: case 109: MemoryOptions(); break;
550: case 104: HDOptions(); break;
551: case 115: SoundOptions(); break;
552: case 111: OtherOptions(); break;
553: }
554: }
555:
556: tui_dlogdie(mm_win);
557: if(mountok)
558: add_filesys_unit(mountvol, mountdir, 0);
559:
560: tui_shutdown();
561: chdir (cwd);
562: return 0;
563: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.