static void put_filename (char *s, int x, int y, attr_t a) { char buf[256]; int i; tui_gotoxy (x,y); if (strcmp (s, ".") == 0) strcpy (buf, "(none)"); else strcpy (buf, s); buf[maxlen] = 0; for (i = 0; i < strlen (buf); i++) waddch (currwin, buf[i] | a); for (; i < maxlen; i++) waddch (currwin, ' ' | a); }
static int makemenu (const char **menu, int x, int y) { const char **m = menu; int maxlen = 0, count = 0; int w; while (*m != NULL) { int l = strlen (*m); if (l > maxlen) maxlen = l; m++; count++; } w = tui_dlog (x, y, x + maxlen + 2, y + count + 1); tui_drawbox (w); tui_selwin (w); y = 2; while (*menu != NULL) { tui_gotoxy (2, y++); tui_puts (*menu++); } tui_selwin (0); return w; }
static void print_configuration (void) { char tmp[256]; int y = 5; int i; tui_clrwin (0); tui_drawbox (0); tui_hline (2, 3, tui_cols () - 1); sprintf (tmp, "UAE %d.%d.%d: The Un*x Amiga Emulator", UAEMAJOR, UAEMINOR, UAESUBREV); tui_gotoxy ((tui_cols () - strlen(tmp))/2, 2); tui_puts (tmp); strcpy(tmp, "Press RETURN/ENTER to run UAE, ESC to exit"); tui_gotoxy ((tui_cols () - strlen(tmp))/2, tui_lines ()); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF0: %s", trimfilename (currprefs.df[0], tui_cols () - 20)); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF1: %s", trimfilename (currprefs.df[1], tui_cols () - 20)); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF2: %s", trimfilename (currprefs.df[2], tui_cols () - 20)); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "Disk file DF3: %s", trimfilename (currprefs.df[3], tui_cols () - 20)); tui_puts (tmp); y++; tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "VIDEO: %d:%d%s %s", currprefs.gfx_width, currprefs.gfx_height, currprefs.gfx_lores_mode ? " (lores)" : "", "" /*colormodes[currprefs.color_mode]*/); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN+7, y++); if (currprefs.gfx_vresolution) tui_puts ("Doubling lines, "); /* if (currprefs.gfx_correct_aspect) tui_puts ("Aspect corrected"); else tui_puts ("Not aspect corrected");*/ tui_gotoxy (OPTION_COLUMN+7, y++); if (currprefs.gfx_xcenter) tui_puts ("X centered"); if (currprefs.gfx_xcenter == 2) tui_puts (" (clever)"); if (currprefs.gfx_ycenter && currprefs.gfx_xcenter) tui_puts (", "); if (currprefs.gfx_ycenter) tui_puts ("Y centered "); if (currprefs.gfx_ycenter == 2) tui_puts (" (clever)"); tui_gotoxy (OPTION_COLUMN+7, y++); tui_puts ("drawing every "); switch (currprefs.gfx_framerate) { case 1: break; case 2: tui_puts ("2nd "); break; case 3: tui_puts ("3rd "); break; default: sprintf (tmp, "%dth ",currprefs.gfx_framerate); tui_puts (tmp); break; } tui_puts ("frame. "); tui_gotoxy (OPTION_COLUMN+7, y++); if (currprefs.gfxmem_size) { sprintf (tmp, "Picasso 96 %d MB", currprefs.gfxmem_size / 0x100000); tui_puts(tmp); } else tui_puts ("Picasso 96 Off"); y++; tui_gotoxy (OPTION_COLUMN, y++); tui_puts ("CPU: "); switch (currprefs.cpu_level) { case 0: tui_puts ("68000"); break; case 1: tui_puts ("68010"); break; case 2: tui_puts ("68020"); break; case 3: tui_puts ("68020/68881"); break; } if (currprefs.address_space_24 && currprefs.cpu_level > 1) tui_puts (" (24 bit addressing)"); if (currprefs.cpu_compatible) tui_puts (" (slow but compatible)"); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "MEMORY: %4dK chip; %4dK fast; %4dK slow", currprefs.chipmem_size/1024, currprefs.fastmem_size/1024, currprefs.bogomem_size/1024); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); sprintf (tmp, "ROM IMAGE: %s", trimfilename (currprefs.romfile, tui_cols () - 50)); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN, y++); if (!sound_available) tui_puts ("SOUND: Not available"); else { switch (currprefs.produce_sound) { case 0: tui_puts ("SOUND: 0 (Off)"); break; case 1: tui_puts ("SOUND: 1 (Off, but emulated)"); break; case 2: tui_puts ("SOUND: 2 (On)"); break; case 3: tui_puts ("SOUND: 3 (On, emulated perfectly)"); break; } tui_gotoxy (OPTION_COLUMN + 7, y++); sprintf (tmp, "%d bits at %d Hz", currprefs.sound_bits, currprefs.sound_freq); tui_puts (tmp); tui_gotoxy (OPTION_COLUMN + 7, y++); sprintf (tmp, "Maximum buffer size %d bytes", currprefs.sound_maxbsiz); tui_puts (tmp); } tui_gotoxy (OPTION_COLUMN,y++); tui_puts ("GAME PORT 1: "); tui_puts (gameport_state (0)); tui_gotoxy (OPTION_COLUMN,y++); tui_puts ("GAME PORT 2: "); tui_puts (gameport_state (1)); for (i = 0;; i++) { char buf[256]; tui_gotoxy (OPTION_COLUMN+1,y++); if (sprintf_filesys_unit (currprefs.mountinfo, buf, i) == -1) break; tui_puts (buf); } }
static int _tui_input_string(int x, int y, char *buf, int max_length, int displayed_length, int foreground_color, int background_color) { int cursor_pos = 0; int scroll_offset = 0; int string_length = strlen(buf); int need_redisplay = 1; tui_set_attr(foreground_color, background_color, 0); _setcursortype(_SOLIDCURSOR); while (1) { int key; if (need_redisplay) { tui_display(x, y, displayed_length, "%s", buf + scroll_offset); need_redisplay = 0; } tui_gotoxy(x + cursor_pos - scroll_offset, y); key = getkey(); switch (key) { case K_Left: if (cursor_pos > 0) { cursor_pos--; if (cursor_pos < scroll_offset) { scroll_offset = cursor_pos; need_redisplay = 1; } } break; case K_Right: if (cursor_pos < string_length) { cursor_pos++; if (cursor_pos >= (scroll_offset + displayed_length)) { scroll_offset = cursor_pos - displayed_length + 1; need_redisplay = 1; } } break; case K_Home: cursor_pos = 0; scroll_offset = 0; need_redisplay = 1; break; case K_End: cursor_pos = string_length; scroll_offset = cursor_pos - displayed_length + 1; if (scroll_offset < 0) scroll_offset = 0; need_redisplay = 1; break; case K_BackSpace: if (cursor_pos > 0 && cursor_pos <= string_length) { memmove(buf + cursor_pos - 1, buf + cursor_pos, string_length - cursor_pos + 1); string_length--; cursor_pos--; if (cursor_pos < scroll_offset) scroll_offset = cursor_pos; need_redisplay = 1; } break; case K_Delete: if (cursor_pos < string_length) { memmove(buf + cursor_pos, buf + cursor_pos + 1, string_length - cursor_pos); string_length--; need_redisplay = 1; } break; case K_Return: _setcursortype(_NOCURSOR); return 0; case K_Escape: _setcursortype(_NOCURSOR); return -1; default: if (key <= 0xff && isprint((char) key) && string_length < max_length) { memmove(buf + cursor_pos + 1, buf + cursor_pos, string_length - cursor_pos + 1); buf[cursor_pos] = (char) key; cursor_pos++; string_length++; if (cursor_pos - scroll_offset >= displayed_length) scroll_offset = cursor_pos - displayed_length + 1; need_redisplay = 1; } break; } } }