Beispiel #1
0
void _xfputc (char c, char *font, Bool bold)
{


    if (c==12) {
	clg();
	_x_proportional = _y_proportional = 0;
	return;
    }

    if (c==13) {
	_x_proportional = 0;
	//_y_proportional += 8; // compact
	_y_proportional += 9; // normal line spacing
	return;
    }
    if ((_xchar_proportional = _xfindchar( (char) (c - 32), (char *) font)) == -1) return;

    if (_x_proportional + _xchar_proportional[0] >= DisplayWidth(0, 0)) _xfputc (13, font, bold);

    putsprite (SPR_OR, _x_proportional, _y_proportional, _xchar_proportional);
    if (bold) putsprite (SPR_OR, ++_x_proportional, _y_proportional, _xchar_proportional);

    _x_proportional += _xchar_proportional[0];

}
Beispiel #2
0
void ren_draw_map (int xStart, int yStart) {
    char x,y, mx, my;
    unsigned char val;

    //31 is 62 / 2
    for (y = 0; y < 31; ++y) {
        //Left shift is a multiply by two.
        undrawb (y, y, 61 - (y << 1), 93 - (y << 1));
    }

    for (x = 0; x < 94; x += 8) {
        for (y = 0; y < 62; y += 8) {
            //Right shifts are divides by two. Should give a (tiny) speed boost.
            mx = x >> 3;
            my = y >> 3;
            val = map_map [map_getindex (xStart + mx, yStart + my)];
            putsprite (SPR_XOR, x, y, spr_tile_blank);
            switch (val) {
                case MAP_GRASS_DEC : putsprite (SPR_OR, x, y, spr_tile_grass); break;
                case MAP_NONE: break;
                default: break;
            }
        }
    }
}
Beispiel #3
0
void MovePiece(char *ptr, char plusx, char plusy)
{
	char *locn;
	char temp,temp2;
	int x,y;

	temp  = PieceIsBall + 3;
	temp2 = (plusx + (plusy * 16));

	while(1) /* loop */
	{

		locn = *(ptr) + Board;
		if(TestNextPosIsStop(*(locn+temp2))) return; /* till edge */

		y = (*(ptr) / 16);
		x = (*(ptr) - (y * 16)) * 6;
		y *= 6;

		if(*(locn+temp2)==BUBB)
			putsprite(spr_xor,x+(plusx*6),y+(plusy*6),sprites + (8 * BUBB));

		*(locn+temp2) = *locn;
		*locn = 0;

 		/* remove old */
		putsprite(spr_xor,x,y,sprites + (8 * temp));
		/* put new */
		putsprite(spr_xor,x+(plusx*6),y+(plusy*6),sprites + (8 * temp));

		(*ptr) += temp2;
	}
}
Beispiel #4
0
void move_left() {
	if (a>0) {
#if (spritesize == 2)
		putsprite(spr_xor,(a*spritesize),(21*spritesizeh)-1,paddle);
		a--;
		putsprite(spr_or,(a*spritesize),(21*spritesizeh)-1,paddle);
#else
		putsprite(spr_xor,(a*spritesize),(21*spritesizeh),paddle);
		a--;
		putsprite(spr_or,(a*spritesize),(21*spritesizeh),paddle);
#endif
	}
}
Beispiel #5
0
void move_right() {
	if (a<29) {
#if (spritesize == 2)
		putsprite(spr_xor,(a*spritesize),(21*spritesizeh)-1,paddle);
		a++;
		putsprite(spr_or,(a*spritesize),(21*spritesizeh)-1,paddle);
#else
		putsprite(spr_xor,(a*spritesize),(21*spritesizeh),paddle);
		a++;
		putsprite(spr_or,(a*spritesize),(21*spritesizeh),paddle);
#endif
	}
}
Beispiel #6
0
 /*************************
         SHOW LIVES
  *************************/
void showlives ()
{
  for (i=0; i<MAXLIVES; i++) {
    if (lives>i)
#if SIZE==6
      putsprite (spr_or, 1+SIZE2*19+i*SIZE, SIZE3*2, &man_right[SIZE3*2]);
    else
      putsprite (spr_and, 1+SIZE2*19+i*SIZE, SIZE3*2, &man_right[SIZE3*2]);
#elif SIZE==10
      putsprite (spr_or, SIZE2*20+i*15, 38, &man_right[SIZE3*2]);
    else
      putsprite (spr_and, SIZE2*20+i*15, 38, &man_right[SIZE3*2]);
#else
      putsprite (spr_or, SIZE2*20+i*SIZE3, SIZE3*2, &man_right[SIZE3*2]);
    else
Beispiel #7
0
void showscore ()
{
#if SIZE==6
    sprintf (scoretxt,"%05u",score);
    for (i=0; i<5; i++) {
      putsprite (spr_and, 1+SIZE2*19+i*4, SIZE3, blank);
      putsprite (spr_or, 1+SIZE2*19+i*4, SIZE3, &numbers[(scoretxt[i]-48)*7]);
    }
#else
    sprintf (scoretxt,"%06u",score);
    for (i=0; i<6; i++) {
      putsprite (spr_and, SIZE2*20+i*5, SIZE3, blank);
      putsprite (spr_or, SIZE2*20+i*5, SIZE3, &numbers[(scoretxt[i]-48)*7]);
    }
#endif
}
Beispiel #8
0
void spriteq_draw(s_screen *screen){
	int i;

	spriteq_sort();

	for(i=0;i<spritequeue_len;i++){
		if(order[i]->effect==SFX_REMAP) putsprite_remap(order[i]->x, order[i]->y, order[i]->frame, screen, order[i]->lut);
		else if(order[i]->effect==SFX_BLEND) putsprite_blend(order[i]->x, order[i]->y, order[i]->frame, screen, order[i]->lut);
		else putsprite(order[i]->x, order[i]->y, order[i]->frame, screen);
	}
}
Beispiel #9
0
main()
{
    
    cpc_SetBorder(3);
    cpc_DisableFirmware();
    cpc_SetMode(2);
    // https://codeforwin.org/2017/12/access-two-dimensional-array-using-pointers-c-programming.html
    inverse_color(&(sprite+2),sprite[0],sprite[1]);
    putsprite(SPR_OR, 0, 0, sprite);
    while (!cpc_AnyKeyPressed()){}   
}
Beispiel #10
0
void DrawBoard(void)
{
	int x,y;
	char *ptr;

	ptr = Board;

	clg(); /* clear the screen */

	for (y=0 ; y!=9 ; y++)
	{
		for (x=0 ; x!=16 ; x++)
		{
			putsprite(spr_or,(x*6),(y*6),sprites + (8 * (*ptr++)));
		}
	}
}
Beispiel #11
0
main()
{
	char x, y, temp;

	for(y=0 ; y<8 ; y++)
	{
		temp = smile[y+2];
		for(x=0 ; x<8 ; x++)
		{
			if(temp & 1)
			{
				putsprite(spr_or, 8 * x, 8 * y, smile);
			}
			temp >>= 1;
		}
	}
	getk(); /*pause*/
}
Beispiel #12
0
main()
{
	int x,y,z;
	int flag  = 1;
	int speed = 1;
	char *ptr;
	for (x=10; x<39; x+=3)
	{
		putsprite(spr_or,2*x   ,x,bullet);
		putsprite(spr_or,2*x-10,x,bullet);
		putsprite(spr_or,2*x+10,x,bullet);
	}

	x=40;
	y=20;

	bksave(x,y,arrow_bk);

	while(flag!=2)
	{
		switch(getk())
		{
			case 11: /* arrow up */
			  y-=speed;
			  flag=1;
			  break;
			case 10: /* arrow down */
			  y+=speed;
			  flag=1;
			  break;
			case 9:  /* arrow right */
			  x+=speed;
			  flag=1;
			  break;
			case 8:  /* arrow left */
			  x-=speed;
			  flag=1;
			  break;
			case 13: /* [Enter] */
			  flag=2;
			  break;
			default: /* reset speed */
			  speed=1;
			  break;
		}
		if(x<0) x=0;
		if(y<0) y=0;
		if(x>(SCREENX-8)) x=(SCREENX-8);
		if(y>(SCREENY-8)) y=(SCREENY-8);
		if(flag==1)
		{
			if(speed<3)
			speed++;

			bkrestore(arrow_bk);
			bksave(x,y,arrow_bk);
			putsprite(spr_or,x,y,arrow);
			putsprite(spr_mask,x,y,arrow_mask);
			flag = 0;
		}
	}
}
Beispiel #13
0
void ren_draw_wait (char x, char y) {
	putsprite (SPR_OR, x, y, spr_wait);
}
Beispiel #14
0
void main()
{
restart:

#ifdef JOYSTICK
	hit_border();
#ifndef LOMEM
#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(EINSTEIN)
	msx_text();
#endif

#ifdef SPECTRUM
#ifdef ZX81
	hrg_off();
	zx_colour(112);
#endif
#endif

	printf("%c",12);
	  printf("\n  CHOOSE YOUR JOYSTICK INTERFACE\n\n");
	for (k=0 ; k!=GAME_DEVICES; k++)
	  printf("    %u - %s\n\n",k+1,joystick_type[k]);

	stick=0;
	while ((stick<1) || (stick>GAME_DEVICES)) {
	  stick=getk()-48;
	  }
#else
	stick=1;
#endif
#endif

#ifdef SPECTRUM
#ifdef ZX81
	hrg_on();
	zx_colour(112);
#endif
#endif


#ifdef CLOCK
    srand(clock());
#endif
	tt=-1;

#ifdef ZX81
#if (spritesize == 2)
	speed=500;
#else
	speed=300;
#endif
#else
#ifdef C128
#else
	speed=300;
#endif
#endif

start_level:
#ifdef ZX81
	speed-=100;
#else
	speed-=200;
#endif

	tt++; t=0; p=1;
	clg();
	hit_border();

#ifdef LAMBDA
	zx_border (INK_CYAN);
	zx_colour(112);
#endif


  for (m=1; m<=4; m+=2)
	for (n=0; n<=30; n+=2) {
		putsprite(spr_or,(n*spritesize),((m+3)*spritesizeh),brick_l);
		putsprite(spr_or,((n+1)*spritesize),((m+3)*spritesizeh),brick_r);
		putsprite(spr_or,(n*spritesize),((m+4)*spritesizeh),brick_r);
		putsprite(spr_or,((n+1)*spritesize),((m+4)*spritesizeh),brick_l);
	#if (spritesize == 8)
	#ifdef SPECTRUM
	#ifdef ZX81
		*zx_cyx2aaddr(m+3,n) = m<<4;
		*zx_cyx2aaddr(m+3,n+1) = m<<4;
		*zx_cyx2aaddr(m+4,n) = (m+1)<<4;
		*zx_cyx2aaddr(m+4,n+1) = (m+1)<<4;
	#else
		*zx_cyx2aaddr(m+3,n) = m<<3;
		*zx_cyx2aaddr(m+3,n+1) = m<<3;
		*zx_cyx2aaddr(m+4,n) = (m+1)<<3;
		*zx_cyx2aaddr(m+4,n+1) = (m+1)<<3;
	#endif
	#endif
	#endif
	
	#ifdef LAMBDA
		*zx_cyx2aaddr(m+3,n) = m<<4;
		*zx_cyx2aaddr(m+3,n+1) = m<<4;
		*zx_cyx2aaddr(m+4,n) = (m+1)<<4;
		*zx_cyx2aaddr(m+4,n+1) = (m+1)<<4;
	#endif
	
	#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(MTX) || defined(EINSTEIN)
	#if (spritesize == 8)
		set_attr(m+3,n,((m+1)<<1)|0x10);
		set_attr(m+3,n+1,((m+1)<<1)|0x10);
		set_attr(m+4,n,(m<<1)|0x10);
		set_attr(m+4,n+1,(m<<1)|0x10);
	#endif
	#endif
	}
  for (n=0; n<=30; n+=2) {
		putsprite(spr_or,(n*spritesize),((m+3)*spritesizeh),brick_l);
		putsprite(spr_or,((n+1)*spritesize),((m+3)*spritesizeh),brick_r);
	#if (spritesize == 8)
	#ifdef SPECTRUM
	#ifdef ZX81
		*zx_cyx2aaddr(m+3,n) = 6<<4;
		*zx_cyx2aaddr(m+3,n+1) = 6<<4;
	#else
		*zx_cyx2aaddr(m+3,n) = 6<<3;
		*zx_cyx2aaddr(m+3,n+1) = 6<<3;
	#endif
	#endif
	#endif
	
	#ifdef LAMBDA
		*zx_cyx2aaddr(m+3,n) = 6<<4;
		*zx_cyx2aaddr(m+3,n+1) = 6<<4;
	#endif
	
	#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(MTX) || defined(EINSTEIN)
	#if (spritesize == 8)
		set_attr(m+3,n,LIGHT_YELLOW|0x10);
		set_attr(m+3,n+1,LIGHT_YELLOW|0x10);
	#endif
	#endif
	}
	
	u=0; v=0; a=14; t=0; w=0;

  for (r=0; r<=6; r++) {
			m=10;  n=8+rand()%15;
			p=0; a=13;

#if (spritesize == 2)
	putsprite(spr_or,(a*spritesize),(21*spritesizeh)-1,paddle);
#else
	putsprite(spr_or,(a*spritesize),(21*spritesizeh),paddle);
#endif

#ifndef LOMEM
	for (i=0; i<=6; i++) {
	  putsprite (spr_and, (24+i)*spritesize, 23*spritesizeh, ball);
	  if (i>r)
		putsprite (spr_or, (24+i)*spritesize, 23*spritesizeh, ball);
	}
#endif

		g=200;

		/* Let's show where the ball stars before the dance begins */
		putsprite(spr_or,(n*spritesize),(m*spritesizeh),ball);

		hit_border();
#ifdef SOUND
		for (i=1; i<14; i++) {
			bit_synth(4, 199+i, 200+i, 239+i, 240+i);
			putsprite(spr_xor,(n*spritesize),(m*spritesizeh),ball);
		}
		bit_synth(9, 255, 254, 253, 252);
#endif

		putsprite(spr_and,(n*spritesize),(m*spritesizeh),ball);

		while (m <= 20) {

			/* delay */
			do_delay();

			move_ball();

			/* total score count is 574 */
			if (t>=573) goto start_level;

			if (u==20)
				putsprite(spr_and,(v*spritesize),(u*spritesizeh),bounce);
			else
				putsprite(spr_and,(v*spritesize),(u*spritesizeh),ball);

			/* Intermediate step to move the ball smoothly */
			putsprite(spr_xor,(((n+v)*spritesize)>>1),(((m+u)*spritesizeh)>>1),ball);
			do_delay();
			putsprite(spr_xor,(((n+v)*spritesize)>>1),(((m+u)*spritesizeh)>>1),ball);

			u=m; v=n;
			if (m==20)
				putsprite(spr_or,(n*spritesize),(m*spritesizeh),bounce);
			else
				putsprite(spr_or,(n*spritesize),(m*spritesizeh),ball);

/*
	#ifdef SOUND
		bit_click();
	#endif
*/

#ifdef JOYSTICK
			if (joystick(stick) & MOVE_LEFT) {
				move_left();
				if (joystick(stick) & MOVE_FIRE)
					move_left();
			}
			if (joystick(stick) & MOVE_RIGHT) {
				move_right();
				if (joystick(stick) & MOVE_FIRE)
					move_right();
			}
#else
			k=getk();
			switch (k) {
				case '2':
					move_left();
					break
				case '1':
					move_left();
					move_left();
					break;
				case '9':
					move_right();
					break;
				case '0':
					move_right();
					move_right();
					break;
			}
#endif
		}
		/* ball is lost */

#if (spritesize == 2)
	  putsprite(spr_and,(a*spritesize),(21*spritesizeh)-1,paddle);
#else
	  putsprite(spr_and,(a*spritesize),(21*spritesizeh),paddle);
#endif
  }


#ifdef ZX81
#if (spritesize == 2)
  #asm
			ld	a,$1e
			ld	i,a
  #endasm
#endif
#endif

#ifndef LOMEM
#ifdef BANNERS
  putsprite(spr_or,40,(12*spritesizeh),scorebanner);
  sprintf (scoretxt,"%05u",tt*1000+t);

  k=0;
  for (i=0; i<5; i++) {
    putsprite (spr_or, 140+i+k, 12*spritesizeh+7, &bigdigit[(scoretxt[i]-48)*38]);
	if (scoretxt[i]=='1')
		k+=5;
	else
		k+=14;
  }

#else
  printf("%c\n\n Score: %u ",12,tt*1000+t);
#endif
#endif

/*  return (tt*1000+t); */
#ifdef SOUND
bit_fx2(5);
#endif
while (getk()) {}
while (!getk()) {}

goto restart;

}
Beispiel #15
0
void destroy_brick() {
	t = t+13-m;
	b = abs(m-n);

	putsprite(spr_and,(n*spritesize),(m*spritesizeh),blank);
	#ifdef SPECTRUM
	#if (spritesize == 8)
	#ifdef ZX81
		*zx_cyx2aaddr(m,n) = 112;
	#else
		*zx_cyx2aaddr(m,n) = 56;
	#endif
	#endif
	#endif
	
	#ifdef LAMBDA
		*zx_cyx2aaddr(m,n) = 112;
	#endif
	
	#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(MTX) || defined(EINSTEIN)
	#if (spritesize == 8)
		set_attr (m,n,0x1f);
	#endif
	#endif


	if ((b&1) && (n>0)) {
		putsprite(spr_and,((n-1)*spritesize),(m*spritesizeh),blank);
	#ifdef SPECTRUM
	#if (spritesize == 8)
	#ifdef ZX81
		*zx_cyx2aaddr(m,n-1) = 112;
	#else
		*zx_cyx2aaddr(m,n-1) = 56;
	#endif
	#endif
	#endif
	
	#ifdef LAMBDA
		*zx_cyx2aaddr(m,n-1) = 112;
	#endif
	
	#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(MTX) || defined(EINSTEIN)
	#if (spritesize == 8)
		set_attr (m,n-1,0x1F);
	#endif
	#endif
	}

	if ((!(b&1)) && (n<31))  {
		putsprite(spr_and,((n+1)*spritesize),(m*spritesizeh),blank);
	#ifdef SPECTRUM
	#if (spritesize == 8)
	#ifdef ZX81
		*zx_cyx2aaddr(m,n+1) = 112;
	#else
		*zx_cyx2aaddr(m,n+1) = 56;
	#endif
	#endif
	#endif
	
	#ifdef LAMBDA
		*zx_cyx2aaddr(m,n+1) = 112;
	#endif
	
	#if defined(MSX) || defined(SVI) || defined(SC3000) || defined(MTX) || defined(EINSTEIN)
	#if (spritesize == 8)
		set_attr (m,n+1,0x1F);
	#endif
	#endif
	}


	#ifdef SOUND
		bit_synth(10, 55, 54, 53, 52);
	#endif

	
#ifndef LOMEM
	sprintf (scoretxt,"%05u",tt*1000+t);

	for (i=0; i<5; i++) {
	  putsprite (spr_and, (2+i)*5, 23*spritesizeh-3, numblank);
	  putsprite (spr_or, (2+i)*5, 23*spritesizeh-3, &numbers[(scoretxt[i]-48)*7]);
	}
#endif
}
Beispiel #16
0
main()
{
#ifdef DETAILED
	sz=getmaxy()/2-5;
	long_sz=sz-18;
	short_sz=sz/2;
#else
	sz=getmaxy()/2-1;
	long_sz=sz-2;
	short_sz=sz/2;
#endif	
	cx=getmaxx()/2;
	cy=getmaxy()/2;
	
	printf("%cTime set..\n\n  Hours: ",12);
	gets(hr);
	k=atoi(hr);
	printf("\n  Minutes: ");
	scanf("%s",hr);
	j=atoi(hr);

	k=k*5+(j/12);
	if (k<15)
		k=k+45;
	else
		k-=15;

	if (j<15)
		j=j+45;
	else
		j-=15;
	
	clg();

	circle(cx,cy,cy,1);
#ifdef DETAILED
	circle(cx,cy,cy-3,1);
	circle(cx,cy,3,1);
#endif
	for (i=0;i<60;i++) {
		x=icos(i*6)*sz/256;
		y=isin(i*6)*sz/256;
		
		plot (cx+x,cy+y);
	
	}

#ifdef DETAILED
	for (i=0;i<12;i++) {
		x=isin(i*30)*(sz-8)/256;
		y=icos(i*30)*(sz-8)/256;
		putsprite(spr_or, cx+x-5, cy-y-3, roman_nums + i*16 + 7*(i>8));
	}
#endif

	x=-1;

	i=0;
	
	tm=clock();
	
	while (getk()!=' ') {
		tm=clock();
		if (i++ == 59) i=0;
		if (i == 45) {
			if (x != -1) {
				// min
				undraw(cx-1,cy+1,cx+x_min,cy+y_min);
				undraw(cx+1,cy-1,cx+x_min,cy+y_min);
				undraw(cx+1,cy+1,cx+x_min,cy+y_min);
				undraw(cx-1,cy-1,cx+x_min,cy+y_min);
			}
			if (j++ == 59) {
				j=0;
			}
			if (j == 45) {
				if (x != -1) {
					undraw(cx,cy,cx+x_hr,cy+y_hr);
					undraw(cx-1,cy+1,cx+x_hr-1,cy+y_hr+1);
					undraw(cx+1,cy-1,cx+x_hr+1,cy+y_hr-1);
					undraw(cx+1,cy+1,cx+x_hr+1,cy+y_hr+1);
					undraw(cx-1,cy-1,cx+x_hr-1,cy+y_hr-1);
				}
				if (k++ == 59) k=0;
			}
		}

		if (x != -1) {
			//sec
			undraw(cx,cy,cx+x,cy+y);
		}
		x=icos(i*6)*long_sz/256;
		y=isin(i*6)*long_sz/256;

		x_min=icos(j*6)*long_sz/256;
		y_min=isin(j*6)*long_sz/256;

		x_hr=icos(k*6)*short_sz/256;
		y_hr=isin(k*6)*short_sz/256;

		// sec
		draw(cx,cy,cx+x,cy+y);

		// min
		draw(cx-1,cy+1,cx+x_min,cy+y_min);
		draw(cx+1,cy-1,cx+x_min,cy+y_min);
		draw(cx+1,cy+1,cx+x_min,cy+y_min);
		draw(cx-1,cy-1,cx+x_min,cy+y_min);

		// hr
		draw(cx,cy,cx+x_hr,cy+y_hr);
		draw(cx-1,cy+1,cx+x_hr-1,cy+y_hr+1);
		draw(cx+1,cy-1,cx+x_hr+1,cy+y_hr-1);
		draw(cx+1,cy+1,cx+x_hr+1,cy+y_hr+1);
		draw(cx-1,cy-1,cx+x_hr-1,cy+y_hr-1);

		circle(cx,cy,3,1);
#ifdef DETAILED
		circle(cx,cy,5,1);
#endif

		while ((clock() < (tm+CLOCKS_PER_SEC))&&(clock() > CLOCKS_PER_SEC)) {}
		tm=clock();
	
	}

}