void InitBackEnd3 P((void));
void FeatureDone P((ChessProgramState* cps, int val));
void InitChessProgram P((ChessProgramState *cps));
-\r
-#ifdef WIN32\r
- extern void ConsoleCreate();\r
-#endif\r
+double u64ToDouble P((u64 value));
+
+#ifdef WIN32
+ extern void ConsoleCreate();
+#endif
+
extern int tinyLayout, smallLayout;
static ChessProgramStats programStats;
#define TN_SGA 0003
#define TN_PORT 23
+/* Some compiler can't cast u64 to double
+ * This function do the job for us:
+
+ * We use the highest bit for cast, this only
+ * works if the highest bit is not
+ * in use (This should not happen)
+ *
+ * We used this for all compiler
+ */
+double
+u64ToDouble(u64 value)
+{
+ double r;
+ u64 tmp = value & 0x7fffffffffffffff;
+ r = (double)(s64)tmp;
+ if (value & 0x8000000000000000)
+ r += 9.2233720368547758080e18; /* 2^63 */
+ return r;
+}
+
/* Fake up flags for now, as we aren't keeping track of castling
availability yet */
int
/* end premove variables */
char *ics_prefix = "$";
-ics_type = ICS_GENERIC;\r
+int ics_type = ICS_GENERIC;
int currentMove = 0, forwardMostMove = 0, backwardMostMove = 0;
int pauseExamForwardMostMove = 0;
char buf[MSG_SIZ];
int err;
- InitChessProgram(&first);\r
-\r
- #ifdef WIN32\r
- /* Make a console window if needed */\r
- if (appData.icsActive) ConsoleCreate();\r
- #endif\r
+ InitChessProgram(&first);
+
+ #ifdef WIN32
+ /* Make a console window if needed */
+ if (appData.icsActive) ConsoleCreate();
+ #endif
if (appData.icsActive) {
err = establish();
int i, oldi;
int buf_len;
int next_out;
- int tkind;\r
-#ifdef WIN32\r
- /* For zippy color lines of winboard\r
- * cleanup for gcc compiler */\r
- int backup;\r
+ int tkind;
+#ifdef WIN32
+ /* For zippy color lines of winboard
+ * cleanup for gcc compiler */
+ int backup;
#endif
char *p;
oldi = i;
if (appData.zippyTalk || appData.zippyPlay) {
-#if ZIPPY\r
- #ifdef WIN32\r
- /* Backup address for color zippy lines */\r
- backup = i;\r
- if (loggedOn == TRUE)\r
- if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) ||\r
- (appData.zippyPlay && ZippyMatch(buf, &backup)));\r
+#if ZIPPY
+ #ifdef WIN32
+ /* Backup address for color zippy lines */
+ backup = i;
+ if (loggedOn == TRUE)
+ if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) ||
+ (appData.zippyPlay && ZippyMatch(buf, &backup)));
#else
if (ZippyControl(buf, &i) ||
ZippyConverse(buf, &i) ||
(appData.zippyPlay && ZippyMatch(buf, &i))) {
loggedOn = TRUE;
continue;
- }\r
+ }
#endif
#endif
}
break;
case AnalyzeMode:
case AnalyzeFile:
+ /* icsEngineAnalyze */
+ case IcsObserving:
+ if (!appData.icsEngineAnalyze) ignore = TRUE;
break;
case TwoMachinesPlay:
if ((cps->twoMachinesColor[0] == 'w') !=
prefixHint ? lastHint : "",
prefixHint ? " " : "", buf1);
- if (currentMove == forwardMostMove ||
- gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
+ if (currentMove == forwardMostMove || gameMode == AnalyzeMode
+ || gameMode == AnalyzeFile || appData.icsEngineAnalyze) {
DisplayMove(currentMove - 1);
DisplayAnalysis();
}
programStats.line_is_book = 1;
if (currentMove == forwardMostMove || gameMode==AnalyzeMode ||
- gameMode == AnalyzeFile) {
+ gameMode == AnalyzeFile || appData.icsEngineAnalyze) {
DisplayMove(currentMove - 1);
DisplayAnalysis();
}
strcat(programStats.movelist, " ");
strcat(programStats.movelist, p);
if (currentMove == forwardMostMove || gameMode==AnalyzeMode ||
- gameMode == AnalyzeFile) {
+ gameMode == AnalyzeFile || appData.icsEngineAnalyze) {
DisplayMove(currentMove - 1);
DisplayAnalysis();
}
|| (nCmailMovesRegistered + nCmailResults == nCmailGames)) {
sprintf(string, partCommandString,
appData.debugMode ? " -v" : "", appData.cmailGameName);
- commandOutput = popen(string, "rb");
+ commandOutput = popen(string, "r");
if (commandOutput == NULL) {
DisplayError(_("Failed to invoke cmail"), 0);
return;
if (gameMode != AnalyzeFile) {
- EditGameEvent();
- if (gameMode != EditGame) return;
+ if (!appData.icsEngineAnalyze) {
+ EditGameEvent();
+ if (gameMode != EditGame) return;
+ }
ResurrectChessProgram();
SendToProgram("analyze\n", &first);
first.analyzing = TRUE;
AnalysisPopUp(_("Analysis"),
_("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis."));
}
- gameMode = AnalyzeMode;
+ if (!appData.icsEngineAnalyze) gameMode = AnalyzeMode;
pausing = FALSE;
ModeHighlight();
SetGameInfo();
void
ExitAnalyzeMode()
{
+ /* icsEngineAnalyze - possible call of other functions */
+ if (appData.icsEngineAnalyze) appData.icsEngineAnalyze = FALSE;
+
if (first.analysisSupport && first.analyzing) {
SendToProgram("exit\n", &first);
first.analyzing = FALSE;
{
char buf[MSG_SIZ];
- if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
+ if (gameMode == AnalyzeMode || gameMode == AnalyzeFile
+ || appData.icsEngineAnalyze) {
sprintf(buf, "Analysis (%s)", first.tidy);
AnalysisPopUp(buf, text);
}
if (programStats.got_only_move) {
strcpy(buf, programStats.movelist);
} else {
- nps = (((u64)programStats.nodes) /
- (((double)programStats.time)/100.0));
+ nps = (u64ToDouble(programStats.nodes) /
+ ((double)programStats.time /100.0));
cs = programStats.time % 100;
s = programStats.time / 100;