X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcursesdsp.c;h=8dd1cd4055feeeeaac3353bb376a60a6c242a91d;hb=0995f733591542a626dd01c9c8552fffaf4ea04d;hp=906e44d3e83ad0983fcdf6bdb27748ba90b73de2;hpb=7c5f6ecf842604527da7c24a7ed873ef04bd616a;p=gnushogi.git diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 906e44d..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) { @@ -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); } @@ -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 @@ -964,7 +966,7 @@ Curses_GiveHint(void) void -Curses_ChangeSearchDepth(void) +Curses_ChangeSearchDepth(char* sx) { Curses_ShowMessage("depth = "); FLUSH_SCANW("%hd", &MaxSearchDepth); @@ -1200,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, +};