coswave - marinus-lab/z88dk GitHub Wiki
This program will display the cos(x²+y²) function using the z-buffer algorithm.
#include `<graphics.h>`
#include `<stdio.h>`
#include `<math.h>`
main()
{
float x,y;
char z,buf;
clg();
for (x=-3.0; x<3.0; x=x+0.06)
{
buf=100;
for (y=-3.0; y<3.0; y=y+0.2)
{
z = (char) 70.0 - (10.0 * (y + 3.0) + ( 10.0 * cos (x*x + y*y) ));
if (buf>z)
{
buf = z;
plot ( (char) (16.0 * (x+3.0)), (char) z);
}
}
}
}
Compile it with the following command:
zcc +cpc -lndos -lm -ocoswave -create-app coswave.c
It will make a file named "coswave.cpc", producing the following output:
{{examples:snippets:cpc_base.gif|}}
Compile it with the following command:
zcc +cpm -lndos -lcpccpm -lm coswave.c
It will create the "a.com" command:
{{examples:snippets:cpc_cpm.gif|}}
{{examples:snippets:cpc_cpmplus.gif|}}
Compile it with the following command:
zcc +lambda -create-app -lm coswave.c
It will create the "a.p" program:
{{:examples:snippets:coswave-lambda.png|}}