Esempio n. 1
0
bool CMineMap::Onlbtup(int m, int n)
{
    if(winf==0||winf==2)
        return false;
    if (m >= mx || n >= my || m < 0 || n < 0 || Map[m][n] <= 90)
        return false;
    if (Map[m][n] >= 101 && Map[m][n] <= 108)
    {
        Map[m][n] -= 100;
        first = 0;
        iswin();
        return true;
    }
    if (Map[m][n] == 100)
    {   //点击的地放周围都没雷,则递归点击周围8个
        Map[m][n] -= 100;
        Onlbtup(m - 1, n);
        Onlbtup(m + 1, n);
        Onlbtup(m, n - 1);
        Onlbtup(m, n + 1);
        Onlbtup(m - 1, n - 1);
        Onlbtup(m + 1, n - 1);
        Onlbtup(m - 1, n + 1);
        Onlbtup(m + 1, n + 1);
    }
    if (Map[m][n] == 99)
    {   //中雷了
        if (first)
        {
            rMine--;
            int a, b, t = 0;
            for (a = -1; a < 2; a++)
                for (b = -1; b < 2; b++)
                {
                    if ((a + m < mx) && (b + n < my) && (a + m >= 0) && (b + n >= 0) && (a || b))
                    {
                        if (Map[a + m][b + n] > 99)
                            Map[a + m][b + n]--;
                        if (Map[a + m][b + n] == 99)
                            t++;
                    }
                }
            first = 0;
            Map[m][n] = 100 + t;
            Onlbtup(m, n);
            return true;
        }
        int i, j;
        for (i = 0; i < mx; i++)
            for (j = 0; j < my; j++)
            {
                if (Map[i][j] == 99)
                    Map[i][j] = -1;
                if (Map[i][j]>49 && Map[i][j] < 60)
                    Map[i][j] = -2;
            }
        winf = 0;
    }
    return true;
}
Esempio n. 2
0
void Run()
{
	while (iswin())
		playchoice();
	if (wint==1)
		printf("\n\t\t\t白棋赢了!\n");
	else
		printf("\n\t\t\t黑棋赢了!\n");
	printf("\t\t\t游戏结束!\n\t\t按任意键重新开始\n"); 
	x=getch();
}
Esempio n. 3
0
Mouse::Mouse(Display *d) {
   if (!firsttime)
   	return;
   hidden = 0;
   inited = FALSE;
   status = 0;
   exb = FALSE;
   firsttime = FALSE;
	display = d;
	BOOL mouse=FALSE;
	int bbx=0;	// for bx value returned by mouse initialization call
	asm {	// Checking if mouse driver is present
		  cmp     word ptr ds:[33h*4],0 // Testing if mouse int handler exists
		  jnz    ismou
		  cmp    word ptr ds:[33h*4+2],0
		  jz     nomou
ismou:
		  xor 	ax,ax
		  int    33h             	// With AX=0h - Initialization
		  cmp    ax,-1           	// Was mouse initialization correct?
		  jnz    nomou            	// No => no correct mouse driver
		  mov		mouse,TRUE			// Mouse is present
		  mov		bbx,bx
nomou:
	}
	ismouse = mouse;
	b3 = (bbx==3 && mouse);
	grcur = cangr = (display->Adapter()!=adaOTHER) && !iswin() &&
         (display->yMax()<30);
	ydiv = display->Adapter()==adaVGA? 16 : (cangr? 14 : 0);
	lastx = lasty = -1;
	grx = gry = 0;
}

Mouse::~Mouse() {
// DON'T DO ANYTHING, SINCE IT'S JUST AN INSTANCE!
//	Restore();
}

void Mouse::Restore() {
	if (!inited)
		return;
	if (grcur) {
		grUndraw();
		// here we restore the original pattern of pat[] symbols
		getMset();	// Switching screen to special mode
		short int p32[6];
		for (int i=0; i<6; i++)
			p32[i]=pat[i]<<5;
		for (int j=0; j<ydiv; j++)
			for (int i=0; i<6; i++) {
				short aa=p32[i]++;
				char c=emc[j][i];
				asm {
					push 	es
					mov   ax,0a000h
					push	ax
					pop	es
					mov	di,aa
					mov	al,c
					mov	ah,byte ptr es:[di]
					mov	byte ptr es:[di],al
					pop	es
				}
			 }
		getMcl();	// Switching screen back to normal mode
		// original pattern restored
	}
	inited = FALSE;
}

void Mouse::Emulation(BOOL b) {	// toggle cursor emulation on/off
	if (b==grcur || (b && !cangr)) return;
	BOOL bb=inited;
	Restore();
	grcur=b;
	if (bb)    // If it was inited already - re-init it.
		Init();
}

void Mouse::Init() {
	if (!ismouse) return;
	if (inited)
		Restore();
	asm {	// Initialize mouse
		xor	ax,ax
		int	33h
	}
	hidden = 0;
	if (grcur && display->yMax()>25)
		grcur = FALSE; // can't make it on HiRes
	if (!grcur)
		asm { // show built-in cursor
			mov	ax,01h
			int	33h
		}
	else {
		// Here we preserve the original pattern of pat[] symbols
		getMset();	// Switching screen into special mode
			// loading the pattern into emc
		short int p32[6];
		for (int i=0; i<6; i++)
			p32[i]=pat[i]<<5;
		for (int j=0; j<ydiv; j++)
			for (int i=0; i<6; i++) {
				short aa=p32[i]++;
				char c;
				asm {
					push 	es
					mov   ax,0a000h
					push	ax
					pop	es
					mov	di,aa
					mov	ah,byte ptr es:[di]
					mov	c,ah
					pop	es
				}
				emc[j][i]=c;
			 }
			// Pattern loaded.
		getMcl();	// Switching screen back to normal mode
		grDraw();
	}
	inited = TRUE;
}