X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcursesdsp.c;h=8dd1cd4055feeeeaac3353bb376a60a6c242a91d;hb=0995f733591542a626dd01c9c8552fffaf4ea04d;hp=10eeae612a1e8d6bba17feb46eaaa27927f76b23;hpb=95369c6cb63d6513f7381dc3cc92c1f34044c607;p=gnushogi.git diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 10eeae6..8dd1cd4 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -6,6 +6,7 @@ * ---------------------------------------------------------------------- * Copyright (c) 1993, 1994, 1995 Matthias Mutz * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * @@ -30,10 +31,13 @@ * ---------------------------------------------------------------------- */ +/* request *snprintf prototypes*/ +#define _POSIX_C_SOURCE 200112L #include #include #include +#include #include #include @@ -41,7 +45,6 @@ #include #include "gnushogi.h" -#include "cursesdsp.h" #if HAVE_UNISTD_H #include @@ -66,16 +69,19 @@ int mycnt1, mycnt2; #define VIR_C(s) ((flag.reverse) ? (NO_COLS - 1 - column(s)) : column(s)) #define VIR_R(s) ((flag.reverse) ? (NO_ROWS - 1 - row(s)) : row(s)) -unsigned short MV[MAXDEPTH]; -int MSCORE; char *DRAW; -/* Forward declarations. */ -/* FIXME: change this name, puh-leeze! */ +/**************************************** + * forward declarations + ****************************************/ +/* FIXME: change this name, puh-leeze! */ static void UpdateCatched(void); static void DrawPiece(short sq); static void ShowScore(short score); +void Curses_UpdateDisplay(short f, short t, short redraw, short isspec); +void Curses_Die(int sig); +void Curses_ShowSidetoMove(void); /**************************************** * Trivial output functions. @@ -104,14 +110,6 @@ gotoXY(short x, short y) } -static void -ClearMessage(void) -{ - gotoXY(TAB, 6); - ClearEoln(); -} - - void Curses_ShowCurrentMove(short pnt, short f, short t) { @@ -145,7 +143,7 @@ void ShowHeader(void) { gotoXY(TAB, 2); - printw("GNU Shogi %s (pl %s)", version, patchlevel); + printw("GNU Shogi %s", PACKAGE_VERSION); } @@ -165,20 +163,26 @@ Curses_ShowMessage(char *s) void -Curses_AlwaysShowMessage(const char *format, va_list ap) +Curses_AlwaysShowMessage(const char *format, ...) { static char buffer[60]; + va_list ap; + va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); Curses_ShowMessage(buffer); + va_end(ap); } void -Curses_Printf(const char *format, va_list ap) +Curses_Printf(const char *format, ...) { static char buffer[60]; + va_list ap; + va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); printw("%s", buffer); + va_end(ap); } @@ -388,7 +392,7 @@ void Curses_help(void) { Curses_ClearScreen(); - printw("GNU Shogi %sp%s command summary\n", version, patchlevel); + printw("GNU Shogi %s command summary\n", PACKAGE_VERSION); printw("-------------------------------" "---------------------------------\n"); printw("7g7f move from 7g to 7f quit Exit Shogi\n"); @@ -672,7 +676,7 @@ Curses_OutputMove(void) t = (l + h) >> 1; } - ShowNodeCnt(NodeCnt); + Curses_ShowNodeCnt(NodeCnt); gotoXY(TAB, 23); printw("Max Tree = %5d", t); ClearEoln(); @@ -714,7 +718,7 @@ Curses_UpdateClocks(void) printw("%d:%02d ", m, s); if (flag.post) - ShowNodeCnt(NodeCnt); + Curses_ShowNodeCnt(NodeCnt); refresh(); } @@ -764,10 +768,8 @@ DrawPiece(short sq) void Curses_ShowPostnValue(short sq) { - short score; - gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); /* CHECKME */ - score = ScorePosition(color[sq]); + (void) ScorePosition(color[sq]); if (color[sq] != neutral) #if defined SAVE_SVALUE @@ -854,10 +856,17 @@ Curses_UpdateDisplay(short f, short t, short redraw, short isspec) gotoXY(3, 4 + 2*NO_ROWS); printw(" "); +#ifndef MINISHOGI if (flag.reverse) printw(" 1 2 3 4 5 6 7 8 9"); else printw(" 9 8 7 6 5 4 3 2 1"); +#else + if (flag.reverse) + printw(" 1 2 3 4 5"); + else + printw(" 1 2 3 4 5"); +#endif for (sq = 0; sq < NO_SQUARES; sq++) DrawPiece(sq); @@ -957,7 +966,7 @@ Curses_GiveHint(void) void -Curses_ChangeSearchDepth(void) +Curses_ChangeSearchDepth(char* sx) { Curses_ShowMessage("depth = "); FLUSH_SCANW("%hd", &MaxSearchDepth); @@ -998,7 +1007,7 @@ Curses_SelectLevel(char *sx) Curses_ClearScreen(); gotoXY(32, 2); - printw("GNU Shogi %sp%s", version, patchlevel); + printw("GNU Shogi %s", PACKAGE_VERSION); gotoXY(20, 4); printw(" 1. 40 moves in 5 minutes"); gotoXY(20, 5); @@ -1193,3 +1202,48 @@ Curses_SetupBoard(void) { Curses_ShowMessage("'setup' command is not supported in Cursesmode"); } + + +struct display curses_display = +{ + .ChangeAlphaWindow = Curses_ChangeAlphaWindow, + .ChangeBetaWindow = Curses_ChangeBetaWindow, + .ChangeHashDepth = Curses_ChangeHashDepth, + .ChangeSearchDepth = Curses_ChangeSearchDepth, + .ChangeXwindow = Curses_ChangeXwindow, + .ClearScreen = Curses_ClearScreen, + .DoDebug = Curses_DoDebug, + .DoTable = Curses_DoTable, + .EditBoard = Curses_EditBoard, + .ExitShogi = Curses_ExitShogi, + .GiveHint = Curses_GiveHint, + .Initialize = Curses_Initialize, + .ShowNodeCnt = Curses_ShowNodeCnt, + .OutputMove = Curses_OutputMove, + .PollForInput = Curses_PollForInput, + .SetContempt = Curses_SetContempt, + .SearchStartStuff = Curses_SearchStartStuff, + .SelectLevel = Curses_SelectLevel, + .ShowCurrentMove = Curses_ShowCurrentMove, + .ShowDepth = Curses_ShowDepth, + .ShowGameType = Curses_ShowGameType, + .ShowLine = Curses_ShowLine, + .ShowMessage = Curses_ShowMessage, + .AlwaysShowMessage = Curses_AlwaysShowMessage, + .Printf = Curses_Printf, + .doRequestInputString = Curses_doRequestInputString, + .GetString = Curses_GetString, + .SetupBoard = Curses_SetupBoard, + .ShowPatternCount = Curses_ShowPatternCount, + .ShowPostnValue = Curses_ShowPostnValue, + .ShowPostnValues = Curses_ShowPostnValues, + .ShowPrompt = Curses_ShowPrompt, + .ShowResponseTime = Curses_ShowResponseTime, + .ShowResults = Curses_ShowResults, + .ShowSidetoMove = Curses_ShowSidetoMove, + .ShowStage = Curses_ShowStage, + .TerminateSearch = Curses_TerminateSearch, + .UpdateClocks = Curses_UpdateClocks, + .UpdateDisplay = Curses_UpdateDisplay, + .help = Curses_help, +};