//===========================================================================
static BYTE __stdcall PrintTransmit(WORD, WORD, BYTE, BYTE value, ULONG)
{
    if (!CheckPrint())
    {
        return 0;
    }
    char c = value & 0x7F;
	fwrite(&c, 1, 1, file);
    return 0;
}
예제 #2
0
void CheckmateTest(int Counter) {
    static int i;
    static int Checkstate;


    CheckerID1=-1;
    CheckerID2=-1;
    CheckerID3=-1;
    CheckerID4=-1;
    CheckerID5=-1;
    CheckerID6=-1;

    Check=0;
    //CheckmateMatchSum=0;
    i=0;
    Checkstate=2;
    if(Checkstate==2) {
        if(Counter==0)
            BlackCheckSeries(-3,0);//(dummy)arguments can be any integer as long as the first is negative
        if(Counter==1)
            WhiteCheckSeries(-3,0);

        if(Check==1)--Checkstate;
    }
    //InvalidKingPosition=0;
    CheckmateSum=0;
    CheckmatePositionSearch();
    static int z;
    if(Checkstate==1) {
        for(; i<8; ++i) {
            //printf("%d\n",PossibleKingPositions[i]);
            //CheckmateMatchSum=0;
            //CheckmatePositionSearch=0;

            if(PossibleKingPositions[i]>-1&&PossibleKingPositions[i]<71) {
                if(Counter==0) {
                    //printf("Are we entering this statement?\n");
                    z = BlackCheckSeries(PossibleKingPositions[i],0);
                    if (z==1) PossibleKingPositionsHit[i]=1;
                }
                if(Counter==1) {
                    z = WhiteCheckSeries(PossibleKingPositions[i],0);
                    if (z==1) PossibleKingPositionsHit[i]=1;
                }

            }
            // printf("Got here. Must be a problem with the b variable name.\n");
            if(PossibleKingPositionsHit[i]==1) {
                ++CheckmateSum;
                if(Counter==0)
                    printf("Check on White King. Hit at position %d.\n",i+1);
                if(Counter==1)
                    printf("Check on White King. Hit at position %d.\n",i+1);
            }
            //need a Check to see which adjacent squares have friend pieces
        }
    }
    //printf("The number of potential Hits is %d\n",//CheckmateMatchSum);

    CheckPrint();
    if(CheckmateSum==8)TerminateProgramFlag=1;
}
//===========================================================================
static BYTE __stdcall PrintTransmit(WORD, WORD, BYTE, BYTE value, ULONG)
{
	         char Lat8A[]= "abwgdevzijklmnoprstufhc~{}yx`q|]";
             char Lat82[]= "abwgdevzijklmnoprstufhc^[]yx@q{}~`"; 
			 char Kir82[]= "юабцдефгхийклмнопярстужвьызэчъ[]^@";
	  char Kir8ACapital[]= "юабцдефгхийклмнопярстужвьызэчъщ";
	char Kir8ALowerCase[]= "ЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗЭЧЪЩ";
	bool Pres = false;
    if (!CheckPrint())
    {
        return 0;
    }
	
	char c = NULL;
	if ((g_Apple2Type == A2TYPE_PRAVETS8A) &&  g_bConvertEncoding)  //This is print conversion for Pravets 8A/C. Print conversion for Pravets82/M is still to be done.
		{
			if ((value > 90) && (value < 128)) //This range shall be set more precisely
			{
			c = value;
			int loop = 0;
			while (loop < 31)
				{
				if (c== Lat8A[loop]) 
				c= 0 + Kir8ALowerCase  [loop] ;
				loop++;
				} //End loop
			}//End if (value < 128)
				else if ((value >64) && (value <91))
				{
					c = value + 32;
			    }
				else
				{
					c = value & 0x7F;
					int loop = 0;
					while (loop < 31)
					{
					if (c== Lat8A[loop]) c= 0 + Kir8ACapital  [loop];
					loop++;
					}
				}
	} //End if (g_Apple2Type == A2TYPE_PRAVETS8A)
		else if (((g_Apple2Type == A2TYPE_PRAVETS82) || (g_Apple2Type == A2TYPE_PRAVETS8M)) && g_bConvertEncoding)
		{
			c =  value & 0x7F;
			int loop = 0;
			while (loop < 34)
			{
				if (c == Lat82[loop])
					c= Kir82 [loop];
				loop++;
			} //end while
		}
		else //Apple II
		{			
			c =  value & 0x7F;
		}
	if ((g_bFilterUnprintable == false) || (c>31) || (c==13) || (c==10) || (c<0)) //c<0 is needed for cyrillic characters
		fwrite(&c, 1, 1, file); //break;
				

	/*else
	{
	char c = value & 0x7F;
	fwrite(&c, 1, 1, file);
	}*/
	return 0;
}
//===========================================================================
static BYTE __stdcall PrintStatus(WORD, WORD, BYTE, BYTE, ULONG)
{
    CheckPrint();
    return 0xFF; // status - TODO?
}