/* Lupengo			*
 * by Carlo Borreo		*
 * email: borreo@softhome.net	*
 * License: GPL			*
 * Started writing: 10-Aug-1987	*
 * First released:  01-May-2000 */

#define BUTTON (!(*( (unsigned char *)(0xbfe001) ) & 128))

mydelay(n)
{
while (n>0 && !BUTTON) {
	testkey(1);
	Delay(10);
	n -= 10;
	}
}

showit(s)
char *s;
{
display(s, DF_NOWAIT | DF_NOREFRESH);
}

xmove(x0,y0,x1,y1,shape)
{
xputscreen(x0,y0,shape);
while(x0!=x1 || y0!=y1) {
	xputscreen(x0,y0,BLANK);
	x0+=SIGN(x1-x0);
	y0+=SIGN(y1-y0);
	putscreen(x0,y0,shape);
	}
}

xputscreen(x,y,s)	/* putscreen with pause and testkey */
{
mydelay(10);
putscreen(x,y,s);
}

show_crush()
{
register int i, j;
char buf[80];
int pics[]={ W400, W1600, W6400, W25600 } ;
int pts[]={ 400, 1600, 6400, 25600 } ;

for (i=0; i<4; i++) {
	cls();
	showit(strcrushen);
	putscreen(4, 2, CARLONID);
	putscreen(5, 5, WALL);
	for (j=10-i; j<=10; j++)
		putscreen(j, 5, LUPONEL);
	putscreen(11, 5, WALL);
	xmove(4, 2, 4, 5, CARLONID);
	xputscreen(4, 5, CARLONIR);
	xmove(5, 5, 10, 5, WALL);
	xputscreen(10, 5, pics[i]);
	sprintf(buf, "%d %s", pts[i], strpoints);
	showit(buf);
	mydelay(50);
	}
}

show_stun()
{
register int i;
char buf[80];

cls();
showit(strstunen);
for (i=1; i<=15; i++)
	putscreen(i, 5, BORDER);
putscreen(10, 4, LUPONEL);
putscreen(5, 1, CARLONID);
xmove(5, 1, 5, 4, CARLONID);
for (i=1; i<=15; i++)
	putscreen(i, 5, ICEY);
putscreen(10, 4, DOWN);
mydelay(10);
for (i=1; i<=15; i++)
	putscreen(i, 5, BLACK);
mydelay(10);
xmove(5, 4, 11, 4, CARLONIR);
sprintf(buf, "100 %s", strpoints);
showit(buf);
for (i=1; i<=15; i++)
	putscreen(i, 5, BORDER);
mydelay(100);
}

show_tris()
{
char buf[80];

cls();
showit(str3inarow);
putscreen(4, 2, CARLONID);
putscreen(5, 5, TRIS);
putscreen(10, 5, TRIS);
putscreen(11, 5, TRIS);
xmove(4, 2, 4, 5, CARLONID);
xputscreen(4, 5, CARLONIR);
xmove(5, 5, 9, 5, TRIS);
sprintf(buf, "???? %s", strpoints);
showit(buf);
mydelay(100);
}

show_2p()
{
register int i;
char buf[80];

cls();
showit(str2better);
for (i=1; i<=15; i++)
	putscreen(i, 5, BORDER);
putscreen(10, 4, LUPONEL);
putscreen(12, 4, PIGL);
putscreen(5, 1, CARLONID);
xmove(5, 1, 5, 4, CARLONID);
for (i=1; i<=15; i++)
	putscreen(i, 5, ICEY);
putscreen(10, 4, DOWN);
mydelay(10);
for (i=1; i<=15; i++)
	putscreen(i, 5, BLACK);
xmove(12, 4, 9, 4, PIGL);
sprintf(buf, "100 %s", strpoints);
showit(buf);
for (i=1; i<=15; i++)
	putscreen(i, 5, BORDER);
mydelay(100);
}

showtable()
{
show_crush();
show_stun();
show_tris();
show_2p();
}
