/*
 *	MENU.C
 * Testprogramm für Bildschirmsteuerung FPGA Tang Nano

 */



#include <stdio.h>
#include <string.h>

/* Dazu noch die Sachen von NKC*/
#include <sys/ndrclock.h>
#include "../../nkc_common/nkc/nkc.h"


int main()
{
	char s[256];
    // Bildschirm löschen
    setbuf(stdout,NULL);
    setbuf(stdin,NULL);
    gp_clearscreen();
	puts("Menu - Beispiel fuer Bildschirmsteuerung");
	puts("abgeleitet von TSCP Schachprogramm");
	puts("");
	puts("Hinter command soll der Cursor blinken.");
	puts("");
	puts("\"help\" Kommandohilfe anzeigen");
	puts("\n");

	for (;;) {

		/* get user input */
		gp_setcurxy(0,10);
        iprintf("                 \rcommand>");
		gp_setflip(30u,0u);
		gp_cursor_on();
        gets(s);
		gp_setflip(0u,0u);
		gp_cursor_off();
        puts("\r");
		if (!strcmp(s, "on")) {
			puts("Computer spielt");
			continue;
		}
		if (!strcmp(s, "off")) {
			puts("Spieler spielt");
			continue;
		}
		if (!strcmp(s, "st")) {
			puts("Rechenzeit gewaehlt");
			continue;
		}
		if (!strcmp(s, "sd")) {
			puts("Rechentiefe gewaehlt");
			continue;
		}
		if (!strcmp(s, "undo")) {
			puts("Letzten Zug zuruecknehmen gewaehlt");
			continue;
		}
		if (!strcmp(s, "new")) {
			puts("Neues Spiel gewaehlt");
			continue;
		}
		if (!strcmp(s, "d")) {
			puts("Zeichne Board gewaehlt");
			continue;
		}
		if (!strcmp(s, "bench")) {
			puts("bench gewaehlt");
			continue;
		}
		if (!strcmp(s, "bye")) {
			puts("Share and enjoy!\n");
			break;
		}
		if (!strcmp(s, "help")) {
			puts("");
			puts("on - computer plays for the side to move");
			puts("off - computer stops playing");
			puts("st n - search for n seconds per move");
			puts("sd n - search n ply per move");
			puts("undo - takes back a move");
			puts("new - starts a new game");
			puts("d - display the board");
			puts("bench - run the built-in benchmark");
			puts("bye - exit the program\n");
			puts("Enter moves in coordinate notation, e.g., e2e4, e7e8Q");
			continue;
		}
	}

	return 0;
}

