コード例 #1
0
ファイル: _xfputc.c プロジェクト: meesokim/z88dk
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];

}
コード例 #2
0
ファイル: sinwave.c プロジェクト: bitfixer/bitfixer
main()
{

float x,y,incr,yenlarge;
int z,buf;

	clg();
	incr=2.0/(float)getmaxx();
	yenlarge=(float)getmaxy() / 6.0;

	for (x=-3.0; x<0; x=x+incr)
	{
		buf=255;
		for (y=-3.0; y<3.0; y=y+0.2)
		{
			z = (int) (float)getmaxy() - (yenlarge * (y + 3.0) + ( yenlarge * sin (x*x + y*y) ));

			if (buf>z)
			{
				buf = z;
				plot ( (int) ((float)getmaxx() / 6.0 * (x + 3.0)), z);
				plot ( (int) ((float)getmaxx() / 6.0 * (3.0 - x)), z);
			}
		}
	}
	
	while (getk() != 13) {};
}
コード例 #3
0
ファイル: sin.c プロジェクト: z88dk/z88dk
void main() {
  int x, y;
  clg();

  for (x = 0; x < 144; x++) {
    y = (int)(24 * (1.0 - sin(x / 144.0 * 3.14 * 8)));
    plot(x, y);
  }

  sleep(1);  // sleep 1 second

  clg();
  plot(0,24);

  for (x = 0; x < 144; x++) {
    y = (int)(24 * (1.0 - sin(x / 144.0 * 3.14 * 8)));
     drawto(x,y);
  }


  while (getk() != 10) {
  };  // enter key is assigned to 10 in the g800 port of z88dk
}
コード例 #4
0
ファイル: ex10b.c プロジェクト: bitfixer/bitfixer
main() {
	int c, l;
	unsigned char i;
	unsigned int dly;

	clg();
	invhrg();
//	zx_border(0);
//	zx_colour(PAPER_BLACK|INK_WHITE);

	c = 0;

	// paint polygon
	for (;;) {
		
		clg();
		for (i=4;i>0;i--) {
			// fake light source
			stencil_init(stencil);
			stencil_add_circle(80+c*3-i, 42+i, i*3+5, 1, stencil);
			stencil_render(stencil, 14-(i*2));
		}

		for (i=11;i>0;i--) {
			stencil_init(stencil);
			stencil_add_circle(128+(11-i), 150 - i, i*3 ,1, stencil);
			stencil_add_side(128-i*3+(11-i), 150 - i, 128, 30+i, stencil);
			stencil_add_side(128+i*3+(11-i), 150 - i, 128, 30+i, stencil);
			stencil_render(stencil, 6*(12-i)/(c+1));
		}

		for (dly=0;dly<30000;dly++) {};

		c = (c+1) & 15;
	}
}
コード例 #5
0
ファイル: dstar.c プロジェクト: meesokim/z88dk
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++)));
		}
	}
}
コード例 #6
0
ファイル: box.c プロジェクト: z88dk/z88dk
void main() {
  int x, y, w, h;
  clg();

  while (1) {
    x = rand() % (getmaxx() );
    y = rand() % (getmaxy() );
    w = rand() % 16 + 4;
    h = rand() % 16 + 4;

    drawb(x, y, w, h);
    small_delay();
    if (getk() == 10) {
      break;
    }  // enter key is assigned to 10
  }
}
コード例 #7
0
ファイル: mandel.c プロジェクト: meesokim/z88dk
void main()
{

 	clg();

	xmax=getmaxx();
	ymax=getmaxy()-1;
	
	a=-2.0; b=2.0;
	c=a; d=b;
	e=4.0;

	g=(b-a)/(float)xmax;
	h=(d-c)/(float)ymax;
	
	for(y=ymax/2; y>0; y--)
	{
	  j=(float)y*h+c;
	  for(x=xmax; x>0; x--)
	  {
	     i=(float)x*g+a;
	     k=0;
	     l=0.0; m=0.0; n=0.0; o=0.0;
l110:	     k++;
	     if (k<100)  //Iterates
	     {
		p=n-o+i;
		m=2.0*l*m+j;
		l=p;
		n=l*l; o=m*m;

		if ((n+o)<e) goto l110;
		if (k&1){
		  plot (x,y);
		  plot (x,ymax-y);
		}

	     }
	  }
	}
	while (getk() != 13) {};
}
コード例 #8
0
ファイル: stencil.c プロジェクト: bitfixer/bitfixer
main() {

	clg();

	// paint polygon or circle
for (;;) {

		// get a random position and size for the object
		x=rand()%getmaxx(); y=rand()%getmaxy(); r=rand()%(getmaxy()/2);
		// if it does not go out of screen, then paint it..
		if (((x-r)>0) && ((x+r)<getmaxx()) && ((y-r)>0) && ((y+r)<getmaxy())) {
			stencil_init(stencil);
			p=rand()%8;
			if (!p)
				stencil_add_circle(x, y, r, 1, stencil);
			else
				// rotate thepolygon by a random angle
				stencil_add_polygon(x, y, p+2, r, rand()%180, stencil);
			// fill object with a texture of a random brightness
			stencil_render(stencil, rand()%12);
		}
	}
}
コード例 #9
0
ファイル: gfx.c プロジェクト: z88dk/z88dk
void main()
{
    int j, i;

    mine->graph = 1;
    mine->width = 255;
    mine->number = '4';

    /* Open map with width 256 on window #4 */
    window(&mine);

    /* Clear the graphics window */
    clg();

    /* Draw a series of concentric circles in the centre of the screen 
 * these go off the screen but don't generate an error - very cool!
 */
    for (i = 50; i != 0; i--) {
        circle(128, 32, i, 1);
        if (i < 25)
            i--;
    }

    draw(0, 0, 255, 63);

    /* Draw a diamond - weak, but it demonstrates relative drawing! */
    plot(200, 32);

    drawr(10, 10);
    drawr(10, -10);
    drawr(-10, -10);
    drawr(-10, 10);

    /* Close the graphics window */
    closegfx(&mine);
}
コード例 #10
0
ファイル: gfx.c プロジェクト: bitfixer/bitfixer
main()
{
        float  x;
        int     i,j,k,l;

	clg();

/* Draw a series of concentric circles in the centre of the screen 
 * these go off the screen but don't generate an error - very cool!
 */
        for (i=90 ; i>=0; i--)
        {
                circle(128,128,i,1);
                if (i < 25 ) i--;
                if (i < 55 ) i--;
                if (i < 75 ) i--;
        }

// Sort of 3d ball
		for (i=4;i>0;i--) {
			stencil_init(stencil);
			stencil_add_circle(80*3-i, 22+i, i*3+5, 1, stencil);
			stencil_render(stencil, 14-(i*2));
		}


	draw(0,0,255,47);

/* Draw a diamond - weak, but it demonstrates relative drawing! */

        plot(140,22);

        drawr(20,20);
        drawr(20,-20);
        drawr(-20,-20);
        drawr(-20,20);
        
        fill(148,24);
        
        for (i=0;i<12;i++) {
        // now a filled diamond via stencil
			stencil_init(stencil);
			stencil_add_side(10+i*8,50,30+i*8,30,stencil);
			stencil_add_side(30+i*8,30,50+i*8,50,stencil);
			stencil_add_side(50+i*8,50,30+i*8,70,stencil);
			stencil_add_side(10+i*8,50,30+i*8,70,stencil);
			stencil_render(stencil, i);
		}

/* Draw a sort of 3D cone, based on an ellipse */
		k=0;
        for (x=7.2 ; x>2.0; x=x-0.1)
        {
			i=170+(int)(sin(x)*50.0);
			j=160+(int)(cos(x)*20.0);
			stencil_init(stencil);
			
			if (k!=0) {
				stencil_add_side(170,60,k,l,stencil);
				stencil_add_side(170,60,i,j,stencil);
				stencil_add_side(i,j,k,l,stencil);
			}
			stencil_render(stencil, x*1.6);
			k=i;l=j;
        }
}
コード例 #11
0
ファイル: XOpenDisplay.c プロジェクト: z88dk/z88dk
struct _XDisplay*XOpenDisplay(char *display_name) {
	clg();
	return 1;
}
コード例 #12
0
ファイル: wall.c プロジェクト: bitfixer/bitfixer
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;

}
コード例 #13
0
ファイル: showlib3d.c プロジェクト: meesokim/z88dk
int main(void)
{
	static Vector_t rot;
	static Vector_t t;
	static Point_t p[8];
	static unsigned c = 0;
	static int i;
	static int zf = 0;
#ifdef TIMING
    extern unsigned _oz64hz_word;
    static unsigned frames;
#endif
    //ozinitprofiler();
	//ozsetactivepage(1);
	//ozsetdisplaypage(0);
#ifdef TIMING
    frames=0;
    _oz64hz_word=0;
#endif
	while(c != 13) {
		//if(ozkeyhit()) c = ozngetch();
		//if(getk()) c = fgetc_cons();
		c=getk();
		switch(c) {
			case '1':
				zf -= 10;
				if(zf < -100) zf = -100;
				break;
			case '2':
				zf += 10;
				if(zf > 300) zf = 300;
				break;
			case '3':
				exit (0);
		}
		c = 0;
		for(i = 0; i < 8; i++) {
			ozcopyvector(&t,&cube[i]);
			ozrotatepointx(&t, rot.x);
			ozrotatepointy(&t, rot.y);
			t.z += zf; /* zoom factor */
			ozplotpoint(&t, &p[i]);
		}
		rot.y = (rot.y+1)%360;
		rot.x = (rot.x+2)%360;
		clg();
		/* top face */
		draw(p[0].x + MX, p[0].y + MY, p[1].x + MX, p[1].y + MY);
		draw(p[1].x + MX, p[1].y + MY, p[2].x + MX, p[2].y + MY);
		draw(p[2].x + MX, p[2].y + MY, p[3].x + MX, p[3].y + MY);
		draw(p[3].x + MX, p[3].y + MY, p[0].x + MX, p[0].y + MY);
		/* bottom face */
		draw(p[4].x + MX, p[4].y + MY, p[5].x + MX, p[5].y + MY);
		draw(p[5].x + MX, p[5].y + MY, p[6].x + MX, p[6].y + MY);
		draw(p[6].x + MX, p[6].y + MY, p[7].x + MX, p[7].y + MY);
		draw(p[7].x + MX, p[7].y + MY, p[4].x + MX, p[4].y + MY);
		/* side faces */
		draw(p[0].x + MX, p[0].y + MY, p[4].x + MX, p[4].y + MY);
		draw(p[1].x + MX, p[1].y + MY, p[5].x + MX, p[5].y + MY);
		draw(p[2].x + MX, p[2].y + MY, p[6].x + MX, p[6].y + MY);
		draw(p[3].x + MX, p[3].y + MY, p[7].x + MX, p[7].y + MY);
        //ozsetdisplaypage(!ozgetdisplaypage());
#ifdef TIMING
        frames++;
        if(_oz64hz_word>64*10)
        {
            static char buf[80];
            sprintf(buf,"%d frames in 10 seconds",frames);
            ozputs(0,0,buf);
            ozgetch();
            _oz64hz_word=0;
            frames=0;
        }
#endif
		//ozsetactivepage(!ozgetactivepage());
	}
}
コード例 #14
0
ファイル: clock.c プロジェクト: meesokim/z88dk
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();
	
	}

}