Example #1
0
static void RunAnnotate(char *fname, int side)
{
    FILE *fin = fopen(fname, "r");
    struct Position *p;

    if(fin) {
        struct PGNHeader header;
        char move[16];


        while(!scanHeader(fin, &header)) {
            p = InitialPosition();
            while(!scanMove(fin, move)) {
                int themove = ParseSAN(p, move);
                if(themove != M_NONE) {
                    ShowPosition(p);
                    Print(0, "%s(%d): ", 
                            p->turn == White ? "White":"Black", (p->ply/2)+1);
                    Print(0, "%s\n", SAN(p, themove));
                    if(side == -1 || (side == p->turn)) {
                        Iterate(p);
                    }
                    DoMove(p, themove);
                }
            }
            FreePosition(p);
        }
    }
    else Print(0, "Couldn't open %s\n", fname);
}
Example #2
0
void repaintWindow(void) {
drawMaze();
ShowPosition(MY_X_LOC, MY_Y_LOC, MY_DIR);
ShowView(MY_X_LOC, MY_Y_LOC, MY_DIR);  //draws maze
ShowAllPositions();

NewScoreCard();
XFlush(dpy);
}
void COctopusStage545::OnTimer( UINT nIDEvent ) 
{
	if( nIDEvent == TIMER_STAGE ) 
	{
		if( first_tick ) 
		{
			OnStepSize3();

			first_tick = false;


			//Editing
			InitializeStage(); 
			GetPosition();

			//middlex	 = 100.0;
			//middley	 = 100.0;
			//middlez	 = 100.0;
			middlex	 = 12;//B.position_x;
			middley	 = 12;//B.position_y;
			middlez	 = 0;

			//m_gotox = 0;
			//m_gotoy = 0;


			range    = 24.975; //max is 25mm, but lets leave a little wiggle room

			savex    = 12;//middlex;
			savey    = 12;//middley;
			savez    = middlez;

			target_x = savex;
			target_y = savey;
			target_z = savez;
			//InitializeStage(); 


			StageCenter();

			OnSave(); 

			if ( glob_m_pLog != NULL ) 
				glob_m_pLog->Write(" PI 545 stage initialized ");
		}
		if( initialized ) 
		{
			GetPosition();
			ShowPosition();
		}
	}

	CDialog::OnTimer(nIDEvent);
}
Example #4
0
void DoViewUpdate()
{
	if (updateView) {	/* paint the screen */
		ShowPosition(MY_X_LOC, MY_Y_LOC, MY_DIR);
		if (M->peeking())
			ShowView(M->xPeek(), M->yPeek(), M->dirPeek());
		else
			ShowView(MY_X_LOC, MY_Y_LOC, MY_DIR);
		updateView = FALSE;
	}
}
Example #5
0
void moLogTextCtrl::LogError( moText p_message ) {

    wxString  w = moText2Wx( p_message );

    if (GetNumberOfLines()>10000) {
        Clear();
    }

    SetDefaultStyle( wxTextAttr( wxColour(255,0,0) ) );
    AppendText(w + wxT("\n"));

    ShowPosition( GetLastPosition() );

}
Example #6
0
void moLogTextCtrl::Log( moText p_message ) {

    wxString  w = moText2Wx( p_message );

    ///cada 10000 lineas publicadas, limpia el buffer completo
    if (GetNumberOfLines()>10000) {
        Clear();
    }

    SetDefaultStyle( wxTextAttr( wxColour( 50, 255, 50 )) );
    AppendText(w + wxT("\n"));

    ShowPosition( GetLastPosition() );

}
Example #7
0
int main()
{
    Point curPos = GetCurrentPosition();
    ShowPosition(curPos);
    return 0;
}
Example #8
0
void SourceView::showFile(std::string path, int proclinenum, const LINEINFOMAP *lineinfomap)
{
	currentfile = path;

	SetValue("");//clear text
	SetDefaultStyle(wxTextAttr(*wxBLACK));

	if (path == "[hint KiFastSystemCallRet]")
	{
		AppendText(
			" Hint: KiFastSystemCallRet often means the thread was waiting for something else to finish.\n"
			" \n"
			" Possible causes might be disk I/O, waiting for an event, or maybe just calling Sleep().\n"
			);
		return;
	}

	if (path == "" || path == "[unknown]")
	{
		SetValue("[ No source file available for this location. ]");

		return;
	}


	FILE *file = fopen(path.c_str(),"r");
	if(!file)
	{
		char *crtSub = "\\crt\\src\\";
		char *crt = strstr((char *)path.c_str(),crtSub);
		if(crt) {
			for(size_t i=0;i<msDevPaths.size();i++) {
				std::string newPath(msDevPaths[i]);
				newPath += crt+strlen(crtSub);
				path = newPath;
				file = fopen(path.c_str(),"r");
				if(file)
					break;
			}
		}
	}

	if(!file)
	{
		AppendText(std::string("[ Could not open file '" + path + "'. ]").c_str());
		return;
	}

	Show(false);
	std::string displaytext= "{\\rtf1\\ansi\\fdeff0{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;}\\cf1";
	int linenum = 1;//1-based counting
	//int showpos = 0;//index of character to make visible in order to scroll to line where proc is defined.
	const int MARGIN_WIDTH = 7;
	char line[1024*10];
	bool block=false;
	char blockType;
	while(fgets(line,sizeof(line),file))
	{
		char outLine[1024*20];
		LINEINFOMAP::const_iterator result = lineinfomap->find(linenum);
		
		if(result != lineinfomap->end()) {
			sprintf(outLine,"{\\b\\cf2 %0.2fs\t}",result->second.count);
		} else {
			strcpy(outLine,"\t");
		}
		char *out = outLine+strlen(outLine);
		char *in = line;
		while(*in) {
			if(!block)
			{
				if(in[0] == '/' && in[1] == '/') {
					block = true;
					blockType = '/';
					strcpy(out,"{\\cf3 ");
					out += strlen(out);
				} else 	if(in[0] == '/' && in[1] == '*') {
					block = true;
					blockType = '*';
					strcpy(out,"{\\cf3 ");
					out += strlen(out);
				} else if(in[0] == '"' && ( in[-1] != '\\' || in[-2] == '\\' )) {
					block = true;
					blockType = '"';
					strcpy(out,"{\\cf3 ");
					out += strlen(out);
				} if(!isCToken(in[-1]) && isCToken(in[0])) {
					char token[1024*10];
					char *tokOut = token;
					while(isCToken(*in)) {
						*(tokOut++) = *(in++);
					}
					*tokOut=0;
					if(keywords.Contains(token)) {
						strcpy(out,"{\\cf4 ");
						out += strlen(out);
						strcpy(out,token);
						out += strlen(out);
						strcpy(out,"}");
						out += strlen(out);
					} else {
						strcpy(out,token);
						out += strlen(token);
					}
					continue;
				}
			} else {
				if(blockType == '*' && in[-2] == '*' && in[-1] == '/') {
					block = false;
					strcpy(out,"}");
					out += strlen(out);
				} else if(blockType == '"' && in[0] == '"' && ( in[-1] != '\\' || in[-2] == '\\' )) {
					*(out++) = '"';
					block = false;
					strcpy(out,"}");
					out += strlen(out);
					in++;
					continue;
				}
			}

			switch(in[0]) {
			case '\n':
			case '\r':
				if(block && blockType == '/') {
					block = false;
					strcpy(out,"}");
					out += strlen(out);
				}
				break;
			case '{':
			case '}':
			case '\\':
				*(out++) = '\\';
				*(out++) = in[0];
				break;
			default:
				*(out++) = in[0];
				break;
			}
			in++;
		}
		*out = 0;
		
		strcat(outLine,"\\line\n");

		displaytext += outLine ;//form line to display
	
		linenum++;
	}
	displaytext += "}";
	fclose(file);

	SendMessage((HWND)GetHWND(),EM_EXLIMITTEXT,0,displaytext.size());

	SETTEXTEX settextex = {
		ST_DEFAULT,
		1200,
	};
	SendMessage((HWND)GetHWND(),EM_SETTEXTEX,(WPARAM)&settextex,(LPARAM)displaytext.c_str());

	wxFont font(8, wxMODERN , wxNORMAL, wxNORMAL);
	const bool res = SetStyle(0, (long)displaytext.size(), wxTextAttr(wxNullColour, wxNullColour, 
						font));
	const int showpos = std::max((int)XYToPosition(0, std::max(proclinenum -7 , 0)), 0);
	ShowPosition(showpos);
	Show(true);
}
Example #9
0
void Edit(char *args)
{
    int editing = TRUE;
    int i;
    int side = White;
    char buffer[16];
    struct Position *p = CurrentPosition;

    for(i=0; i<64; i++) p->piece[i] = Neutral;
    p->mask[White][0] = p->mask[Black][0] = 0;

    while(editing) {
        int sq;

        if(!ReadLine(buffer, 256)) break;

        sq = (buffer[1]-'a') + 8*(buffer[2]-'1');

        switch(buffer[0]) {
        case '.':
            editing = FALSE;
            break;
        case 'c':
            side = OPP(side);
            break;
        case 'P':
            p->piece[sq] = PIECEID(Pawn, side);
            SetBit(p->mask[side][0], sq);
            break;
        case 'N':
            p->piece[sq] = PIECEID(Knight, side);
            SetBit(p->mask[side][0], sq);
            break;
        case 'B':
            p->piece[sq] = PIECEID(Bishop, side);
            SetBit(p->mask[side][0], sq);
            break;
        case 'R':
            p->piece[sq] = PIECEID(Rook, side);
            SetBit(p->mask[side][0], sq);
            break;
        case 'Q':
            p->piece[sq] = PIECEID(Queen, side);
            SetBit(p->mask[side][0], sq);
            break;
        case 'K':
            p->piece[sq] = PIECEID(King, side);
            SetBit(p->mask[side][0], sq);
            break;
        }
    }

    p->castle = p->enPassant = 0;

    RecalcAttacks(p);
    if(p->piece[e1] == King) {
                if(p->piece[h1] == Rook) p->castle |= CastleMask[White][0];
                if(p->piece[a1] == Rook) p->castle |= CastleMask[White][1];
    }
    if(p->piece[e8] == -King) {
                if(p->piece[h8] == -Rook) p->castle |= CastleMask[Black][0];
                if(p->piece[a8] == -Rook) p->castle |= CastleMask[Black][1];
    }
    RecalcAttacks(p);
    ShowPosition(p);
}
Example #10
0
static void Test(char *fname)
{
    struct Position *p;
    int solved = 0, total = 0;
    FILE *fin, *fout;
    int i;
    int btav = 0;
    int btval;
    int bsval;
    int lctval = 1900;
    char line[256];

    if(!fname) {
        Print(0, "Usage: test <filename>\n");
        return;
    }

    fin = fopen(fname, "r");
    if(!fin) {
        Print(0, "Couldn't open %s for input.\n", fname);
        return;
    }

    fout = fopen("nsolved.epd", "w");

    for(i=1; ; i++) {
        int move, j;
        int correct = FALSE;

        if(fgets(line, 256, fin) == NULL) break;
        Print(0, "Problem %d:\n", i);
        p = CreatePositionFromEPD(line);
        ShowPosition(p);

        /* TestSwap(); */

        move = Iterate(p);
        for(j=0; goodmove[j] != M_NONE; j++) 
            if(move == goodmove[j]) correct = TRUE;

        if(!correct && badmove[0] != M_NONE) {
            correct = TRUE;

            for(j=0; badmove[j] != M_NONE; j++) 
                if(move == badmove[j]) correct = FALSE;
        }

        total++;
        if(correct) {
            Print(0, "solved!\n");
            solved++;

            btav += (FHTime < 900) ? FHTime : 900;

            if(FHTime <10)         lctval += 30;
            else if(FHTime < 30)   lctval += 25;
            else if(FHTime < 90)   lctval += 20;
            else if(FHTime < 180)  lctval += 15;
            else if(FHTime < 390)  lctval += 10;
            else if(FHTime <= 600) lctval += 5;
        }
        else {
            Print(0, "not solved!\n");
            btav += 900;
            if(fout) fprintf(fout, "%s", line);
        }

        btval = 2630 - (btav/total);
        bsval = (btav/(17*60));
        bsval = 2830 - bsval*bsval;

        Print(0, "solved %d out of %d  (BT2630 = %d, LCT2 = %d, BS2830 = %d)\n", 
            solved, total, btval, lctval, bsval);
        Print(0, "-----------------------------------------------\n\n");

        FreePosition(p);
    }

    if(fin) fclose(fin);
    if(fout) fclose(fout);
}
Example #11
0
static void Show(char *args)
{
    ShowPosition(CurrentPosition);
}