*
*/
-
#ifdef WIN32
#define NEED_VARARGS /* Uses ... */
#include "win32api.h"
static BOOL FDECL(CtrlHandler, (DWORD));
static void FDECL(xputc_core, (char));
#if 1 /*JP*/
-static void FDECL(xputc2_core, (unsigned int, unsigned int));
+static void FDECL(xputc2_core, (unsigned char *));
#endif
void FDECL(cmov, (int, int));
void FDECL(nocmov, (int, int));
static void NDECL(init_ttycolor);
static void NDECL(really_move_cursor);
static void NDECL(check_and_set_font);
+#if 0 /*JP*/
static boolean NDECL(check_font_widths);
+#endif
static void NDECL(set_known_good_console_font);
static void NDECL(restore_original_console_font);
extern void NDECL(safe_routines);
if (back->iskanji == 1) {
cell_t * back2 = back + 1;
cell_t * front2 = front + 1;
+ /* pos.x == 0 \82Ì\8fð\8c\8f\82Í\95s\97v\82Ì\82Í\82¸\82¾\82ª #42072 \91Î\8dô\82Å\92Ç\89Á\81B */
if (back->attribute != front->attribute ||
- back2->attribute != front2->attribute) {
+ back2->attribute != front2->attribute || pos.X == 0) {
WORD attrs[2];
attrs[0] = attrs[1] = back->attribute;
WriteConsoleOutputAttribute(console.hConOut, attrs,
front->attribute = back->attribute;
front2->attribute = back2->attribute;
}
+ /* pos.x == 0 \82Ì\8fð\8c\8f\82Í\95s\97v\82Ì\82Í\82¸\82¾\82ª #42072 \91Î\8dô\82Å\92Ç\89Á\81B */
if (back->character != front->character ||
- back2->character != front2->character) {
- unsigned char buf[2];
- buf[0] = (unsigned char)(back->character);
- buf[1] = (unsigned char)(back2->character);
- WriteConsoleOutputCharacter(console.hConOut, buf, 2, pos,
+ back2->character != front2->character || pos.X == 0) {
+ wchar_t wbuf[1];
+ wbuf[0] = back->character;
+ WriteConsoleOutputCharacterW(console.hConOut, wbuf, 1, pos,
&unused);
- front->character = back->character;
- front2->character = back2->character;
+ *front = *back;
+ *front2 = *back2;
}
pos.X++;
back += 2;
WriteConsoleOutputCharacterA(console.hConOut, &ch, 1, pos,
&unused);
}
+#if 1 /*JP*/
+ /* \8a¿\8e\9a\82Ì1\83o\83C\83g\96Ú\82¾\82Á\82½\8fê\8d\87\81A
+ 2\83o\83C\83g\96Ú\82ð\83N\83\8a\83A\82µ\82Ä\8am\8eÀ\82É\8dX\90V\82·\82é */
+ if (front->iskanji == 1) {
+ (front + 1)->character = '\0';
+ }
+#endif
*front = *back;
}
back++;
boolean numberpad;
int portdebug;
{
- int ch = keyboard_handler.pProcessKeystroke(
+ int ch;
+
+#ifdef QWERTZ_SUPPORT
+ if (Cmd.swap_yz)
+ numberpad |= 0x10;
+#endif
+ ch = keyboard_handler.pProcessKeystroke(
console.hConIn, ir, valid, numberpad, portdebug);
+#ifdef QWERTZ_SUPPORT
+ numberpad &= ~0x10;
+#endif
/* check for override */
if (ch && ch < MAX_OVERRIDES && key_overrides[ch])
ch = key_overrides[ch];
int mod;
coord cc;
DWORD count;
+ boolean numpad = iflags.num_pad;
+
really_move_cursor();
if (iflags.debug_fuzzer)
return randomkey();
+#ifdef QWERTZ_SUPPORT
+ if (Cmd.swap_yz)
+ numpad |= 0x10;
+#endif
+
return (program_state.done_hup)
? '\033'
: keyboard_handler.pCheckInput(
- console.hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
+ console.hConIn, &ir, &count, numpad, 0, &mod, &cc);
}
int
int ch;
coord cc;
DWORD count;
+ boolean numpad = iflags.num_pad;
+
really_move_cursor();
if (iflags.debug_fuzzer)
return randomkey();
+#ifdef QWERTZ_SUPPORT
+ if (Cmd.swap_yz)
+ numpad |= 0x10;
+#endif
ch = (program_state.done_hup)
? '\033'
: keyboard_handler.pCheckInput(
- console.hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc);
+ console.hConIn, &ir, &count, numpad, 1, mod, &cc);
+#ifdef QWERTZ_SUPPORT
+ numpad &= ~0x10;
+#endif
if (!ch) {
*x = cc.x;
*y = cc.y;
set_console_cursor(x, y);
}
-void
+/* same signature as 'putchar()' with potential failure result ignored */
+int
xputc(ch)
-char ch;
+int ch;
{
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
- xputc_core(ch);
+ xputc_core((char) ch);
+ return 0;
}
#if 1 /*JP*/
void
-xputc2_core(ch1, ch2)
-unsigned int ch1;
-unsigned int ch2;
+xputc2_core(str)
+unsigned char *str;
{
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
boolean inverse = FALSE;
cell_t cell;
+ wchar_t wbuf[1];
/* xputc_core()\82©\82ç\82Ì\83R\83s\81[ */
inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
}
}
- cell.character = ch1;
+ int ret = MultiByteToWideChar(
+ CP_ACP,
+ MB_PRECOMPOSED,
+ str,
+ strlen(str),
+ wbuf,
+ 1);
+
+ /* \8d¶\91¤\82É\83\8f\83C\83h\95¶\8e\9a\8fî\95ñ\82ð\8bl\82ß\82é */
+ cell.character = wbuf[0];
cell.iskanji = 1;
buffer_write(console.back_buffer, &cell, console.cursor);
console.cursor.X++;
- cell.character = ch2;
+ /* \89E\91¤\82Í\83_\83~\81[ */
+ cell.character = 255;
cell.iskanji = 2;
buffer_write(console.back_buffer, &cell, console.cursor);
}
void
-xputc2(ch1, ch2)
-int ch1;
-int ch2;
+xputc2(str)
+unsigned char *str;
{
/* wintty.c \82Å\82Í 1 \83o\83C\83g\96\88\82É curx \82ð\89Á\8eZ\82·\82é\82ª\81A\82±\82±\82Í
- 2 \83o\83C\83g\82½\82Ü\82Á\82Ä\82©\82ç\8cÄ\82Ñ\8fo\82³\82ê\82é\82Ì\82Å\81A1 \95¶\8e\9a\95ª\90æ\82É\90i\82ñ\82Å
- \82µ\82Ü\82Á\82Ä\82¢\82é\81B\8f]\82Á\82Ä 1 \82ð\88ø\82\81B */
- console.cursor.X = ttyDisplay->curx - 1;
+ n \83o\83C\83g\82½\82Ü\82Á\82Ä\82©\82ç\8cÄ\82Ñ\8fo\82³\82ê\82é\82Ì\82Å\81An-1 \95¶\8e\9a\95ª\90æ\82É\90i\82ñ\82Å
+ \82µ\82Ü\82Á\82Ä\82¢\82é\81B\8f]\82Á\82Ä n-1 \82ð\88ø\82\81B */
+ console.cursor.X = ttyDisplay->curx - (strlen(str) - 1);
console.cursor.Y = ttyDisplay->cury;
- xputc2_core(ch1, ch2);
+ xputc2_core(str);
}
#endif
const char *s;
{
int k;
- int slen = strlen(s);
+ int slen = (int) strlen(s);
if (ttyDisplay)
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
BACKGROUND_INTENSITY : FOREGROUND_INTENSITY;
cell.attribute = console.attr;
+#if 0 /*JP*/
cell.character = (console.has_unicode ? console.cpMap[ch] : ch);
+#else
+ cell.character = ch;
+#endif
#if 1 /*JP*//*\8fí\82É1\83o\83C\83g\95¶\8e\9a*/
cell.iskanji = 0;
#endif
cell_t cell;
cell.attribute = console.attr;
+#if 0 /*JP*/
cell.character = (console.has_unicode ? cp437[ch] : ch);
+#else
+ cell.character = ch;
+#endif
#if 1 /*JP*//*\8fí\82É1\83o\83C\83g\95¶\8e\9a*/
cell.iskanji = 0;
#endif
void
raw_clear_screen()
{
- buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0);
+ if (WINDOWPORT("tty")) {
+ cell_t * back = console.back_buffer;
+ cell_t * front = console.front_buffer;
+ COORD pos;
+ DWORD unused;
+
+ for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
+ for (pos.X = 0; pos.X < console.width; pos.X++) {
+ WriteConsoleOutputAttribute(console.hConOut, &back->attribute,
+ 1, pos, &unused);
+ front->attribute = back->attribute;
+ if (console.has_unicode) {
+ WriteConsoleOutputCharacterW(console.hConOut,
+ &back->character, 1, pos, &unused);
+ } else {
+ char ch = (char)back->character;
+ WriteConsoleOutputCharacterA(console.hConOut, &ch, 1, pos,
+ &unused);
+ }
+ *front = *back;
+ back++;
+ front++;
+ }
+ }
+ }
}
void
clear_screen()
{
- raw_clear_screen();
+ buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0);
home();
}
}
}
-#ifdef TEXTCOLOR
/*
* CLR_BLACK 0
* CLR_RED 1
#endif
init_ttycolor_completed = TRUE;
}
-#endif /* TEXTCOLOR */
+#if 0
int
-has_color(int color)
+has_color(int color) /* this function is commented out */
{
#ifdef TEXTCOLOR
if ((color >= 0) && (color < CLR_MAX))
else
return 0;
}
+#endif
int
term_attr_fixup(int attrmask)
if (iflags.window_inited)
end_screen();
buf[0] = '\n';
- (void) vsprintf(&buf[1], s, VA_ARGS);
+ (void) vsnprintf(&buf[1], sizeof buf - 1, s, VA_ARGS);
msmsg(buf);
really_move_cursor();
VA_END();
#endif
}
+#if 0 /*JP*/
/* check_font_widths returns TRUE if all glyphs in current console font
* fit within the width of a single console cell.
*/
boolean used[256];
memset(used, 0, sizeof(used));
for (int i = 0; i < SYM_MAX; i++) {
- used[l_syms[i]] = TRUE;
- used[r_syms[i]] = TRUE;
+ used[primary_syms[i]] = TRUE;
+ used[rogue_syms[i]] = TRUE;
}
int wcUsedCount = 0;
return all_glyphs_fit;
}
+#endif
/* set_known_good_console_font sets the code page and font used by the console
* to settings know to work well with NetHack. It also saves the original
}
}
+#if 0 /*JP*/
/* set_cp_map() creates a mapping of every possible character of a code
* page to its corresponding WCHAR. This is necessary due to the high
* cost of making calls to MultiByteToWideChar() for every character we
}
}
+#endif
#if 0
/* early_raw_print() is used during early game intialization prior to the
/* check the font before we capture the code page map */
check_and_set_font();
+#if 0 /*JP*/
set_cp_map();
+#endif
/* Set console mode */
DWORD cmode, mask;
HKL keyboard_layout = GetKeyboardLayout(0);
DWORD primary_language = (UINT_PTR) keyboard_layout & 0x3f;
- if (primary_language == LANG_ENGLISH) {
- if (!load_keyboard_handler("nhdefkey"))
- error("Unable to load nhdefkey.dll");
- } else {
- if (!load_keyboard_handler("nhraykey"))
- error("Unable to load nhraykey.dll");
+ /* This was overriding the handler that had already
+ been loaded during options parsing. Needs to
+ check first */
+#if 0 /*JP*//* \93ú\96{\8cê\82Å\82Ínhdefkey\82µ\82©\8eg\82í\82È\82¢ */
+ if (!iflags.altkeyhandler[0]) {
+ if (primary_language == LANG_ENGLISH) {
+ if (!load_keyboard_handler("nhdefkey"))
+ error("Unable to load nhdefkey.dll");
+ } else {
+ if (!load_keyboard_handler("nhraykey"))
+ error("Unable to load nhraykey.dll");
+ }
}
+#else
+ if (!load_keyboard_handler("nhdefkey"))
+ error("nhdefkey.dll\82ð\93Ç\82Ý\8d\9e\82ß\82Ü\82¹\82ñ");
+#endif
}
#endif /* TTY_GRAPHICS */
char buf[ROWNO * COLNO]; /* worst case scenario */
VA_START(fmt);
VA_INIT(fmt, const char *);
- Vsprintf(buf, fmt, VA_ARGS);
+ (void) vsnprintf(buf, sizeof buf, fmt, VA_ARGS);
if (redirect_stdout)
fprintf(stdout, "%s", buf);
else {