-/* File: main-gcu.c */
+/* File: main-gcu.c */
/*
* Copyright (c) 1997 Ben Harrison, and others
#endif
+#include <locale.h>
+
+
/*
* XXX XXX Hack -- POSIX uses "O_NONBLOCK" instead of "O_NDELAY"
*
game_termios.c_cc[VMIN] = 1;
game_termios.c_cc[VTIME] = 0;
- /* Turn off flow control */
- game_termios.c_iflag &= ~IXON;
-
#endif
#ifdef USE_TERMIO
game_termio.c_cc[VMIN] = 1;
game_termio.c_cc[VTIME] = 0;
- /* Turn off flow control */
- game_termio.c_iflag &= ~IXON;
-
#endif
#ifdef USE_TCHARS
game_tchars.t_quitc = (char)-1;
game_tchars.t_eofc = (char)-1;
game_tchars.t_brkc = (char)-1;
-
- /* XXX XXX XXX Should maybe turn off flow control too. How? */
-
+
#endif
}
mvcur(curscr->cury, curscr->curx, LINES - 1, 0);
#else
/* this moves curses to bottom right corner */
- mvcur(curscr->_cury, curscr->_curx, LINES - 1, 0);
+ mvcur(getcury(curscr), getcurx(curscr), LINES - 1, 0);
#endif
/* Exit curses */
/*
* Initialize sound
*/
-static bool init_sound()
+static bool init_sound(void)
{
/* Initialize once */
if (!can_use_sound)
/* Prepare the sounds */
for (i = 1; i < SOUND_MAX; i++)
{
- /* Extract name of sound file */
- sprintf(wav, "%s.wav", angband_sound_name[i]);
+ /* Extract name of sound file */
+ sprintf(wav, "%s.wav", angband_sound_name[i]);
- /* Access the sound */
- path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, wav);
+ /* Access the sound */
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_SOUND, wav);
- /* Save the sound filename, if it exists */
- if (check_file(buf)) sound_file[i] = string_make(buf);
+ /* Save the sound filename, if it exists */
+ if (check_file(buf)) sound_file[i] = string_make(buf);
}
/* Sound available */
mvcur(curscr->cury, curscr->curx, LINES - 1, 0);
#else
/* This moves curses to bottom right corner */
- mvcur(curscr->_cury, curscr->_curx, LINES - 1, 0);
+ mvcur(getcury(curscr), getcurx(curscr), LINES - 1, 0);
#endif
/* Flush the curses buffer */
if (!sound_file[v]) return (1);
sprintf(buf,"./gcusound.sh %s\n", sound_file[v]);
- system(buf);
- return (0);
+ return (system(buf) < 0);
#if 0
char *argv[4];
{
/* Set one color (note scaling) */
init_color(i, angband_color_table[i][1] * 1000 / 255,
- angband_color_table[i][2] * 1000 / 255,
- angband_color_table[i][3] * 1000 / 255);
+ angband_color_table[i][2] * 1000 / 255,
+ angband_color_table[i][3] * 1000 / 255);
}
#endif
/* Make a noise */
case TERM_XTRA_NOISE:
- (void)write(1, "\007", 1);
- return (0);
+ return write(1, "\007", 1) != 1;
#ifdef USE_SOUND
/* Make a special sound */
case TERM_XTRA_SOUND:
- return (Term_xtra_gcu_sound(v));
+ return (Term_xtra_gcu_sound(v));
#endif
/* Flush the Curses buffer */
return (0);
}
+
+static void hook_quit(cptr str)
+{
+ /* Unused */
+ (void)str;
+
+ /* Exit curses */
+ endwin();
+}
+
+
/*
* Prepare "curses" for use by the file "term.c"
*
int num_term = 4, next_win = 0;
char path[1024];
+ /* Unused */
+ (void)argc;
+ (void)argv;
+
+
+ setlocale(LC_ALL, "");
+
#ifdef USE_SOUND
/* Build the "sound" path */
- path_build(path, 1024, ANGBAND_DIR_XTRA, "sound");
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
/* Allocate the path */
ANGBAND_DIR_XTRA_SOUND = string_make(path);
if (initscr() == (WINDOW*)ERR) return (-1);
#endif
+ /* Activate hooks */
+ quit_aux = hook_quit;
+ core_aux = hook_quit;
+
/* Hack -- Require large screen, or Quit with message */
i = ((LINES < 24) || (COLS < 80));
if (i) quit("Angband needs an 80x24 'curses' screen");
/* Do we have color, and enough color, available? */
can_use_color = ((start_color() != ERR) && has_colors() &&
- (COLORS >= 8) && (COLOR_PAIRS >= 8));
+ (COLORS >= 8) && (COLOR_PAIRS >= 8));
#ifdef REDEFINE_COLORS
/* Can we change colors? */
can_fix_color = (can_use_color && can_change_color() &&
- (COLORS >= 16) && (COLOR_PAIRS > 8));
+ (COLORS >= 16) && (COLOR_PAIRS > 8));
#endif
/* Attempt to use customized colors */
/* Prepare the color pairs */
for (i = 1; i <= 63; i++)
{
- /* Reset the color */
- if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
- {
- quit("Color pair init failed");
- }
+ /* Reset the color */
+ if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
+ {
+ quit("Color pair init failed");
+ }
/* Set up the colormap */
colortable[i - 1] = (COLOR_PAIR(i) | A_NORMAL);
colortable[i + 7] = (COLOR_PAIR(i) | A_BRIGHT);
- /* XXX XXX XXX Take account of "gamma correction" */
+ /* XXX XXX XXX Take account of "gamma correction" */
/* Prepare the "Angband Colors" */
Term_xtra_gcu_react();
/* Attempt to use colors */
else if (can_use_color)
{
- /* Color-pair 0 is *always* WHITE on BLACK */
+ /* Color-pair 0 is *always* WHITE on BLACK */
/* Prepare the color pairs */
init_pair(1, COLOR_RED, COLOR_BLACK);
colortable[3] = (COLOR_PAIR(1) | A_BRIGHT); /* Orange XXX */
colortable[4] = (COLOR_PAIR(1) | A_NORMAL); /* Red */
colortable[5] = (COLOR_PAIR(2) | A_NORMAL); /* Green */
- colortable[6] = (COLOR_PAIR(4) | A_NORMAL); /* Blue */
+ colortable[6] = (COLOR_PAIR(4) | A_BRIGHT); /* Blue */
colortable[7] = (COLOR_PAIR(3) | A_NORMAL); /* Umber */
colortable[8] = (COLOR_PAIR(7) | A_BRIGHT); /* Dark-grey XXX */
colortable[9] = (COLOR_PAIR(0) | A_NORMAL); /* Light-grey XXX */
- colortable[10] = (COLOR_PAIR(5) | A_NORMAL); /* Purple */
+ colortable[10] = (COLOR_PAIR(5) | A_BRIGHT); /* Purple */
colortable[11] = (COLOR_PAIR(3) | A_BRIGHT); /* Yellow */
- colortable[12] = (COLOR_PAIR(5) | A_BRIGHT); /* Light Red XXX */
+ colortable[12] = (COLOR_PAIR(5) | A_NORMAL); /* Light Red XXX */
colortable[13] = (COLOR_PAIR(2) | A_BRIGHT); /* Light Green */
- colortable[14] = (COLOR_PAIR(4) | A_BRIGHT); /* Light Blue */
+ colortable[14] = (COLOR_PAIR(6) | A_BRIGHT); /* Light Blue */
colortable[15] = (COLOR_PAIR(3) | A_NORMAL); /* Light Umber XXX */
}
/* Initialize (if needed) */
if (arg_sound && !init_sound())
{
- /* Warning */
- plog("Cannot initialize sound!");
+ /* Warning */
+ plog("Cannot initialize sound!");
- /* Cannot enable */
- arg_sound = FALSE;
+ /* Cannot enable */
+ arg_sound = FALSE;
}
/* Change setting */
cbreak();
noecho();
nonl();
+ raw();
/* Extract the game keymap */
keymap_game_prepare();
switch (i)
{
- /* Upper left */
- case 0: rows = 24;
- cols = 80;
- y = x = 0;
- break;
- /* Lower left */
- case 1: rows = LINES - 25;
- cols = 80;
- y = 24;
- x = 0;
- break;
- /* Upper right */
- case 2: rows = 24;
- cols = COLS - 81;
- y = 0;
- x = 81;
- break;
- /* Lower right */
- case 3: rows = LINES - 25;
- cols = COLS - 81;
- y = 24;
- x = 81;
- break;
- /* XXX */
- default: rows = cols = 0;
- y = x = 0;
- break;
+ /* Upper left */
+ case 0: rows = 24;
+ cols = 80;
+ y = x = 0;
+ break;
+ /* Lower left */
+ case 1: rows = LINES - 25;
+ cols = 80;
+ y = 24;
+ x = 0;
+ break;
+ /* Upper right */
+ case 2: rows = 24;
+ cols = COLS - 81;
+ y = 0;
+ x = 81;
+ break;
+ /* Lower right */
+ case 3: rows = LINES - 25;
+ cols = COLS - 81;
+ y = 24;
+ x = 81;
+ break;
+ /* XXX */
+ default: rows = cols = 0;
+ y = x = 0;
+ break;
}
/* No non-windows */