241 lines
4.7 KiB
Text
241 lines
4.7 KiB
Text
#include <stdio.h>
|
|
#include <math.h>
|
|
#include <conio.h>
|
|
#include <dos.h>
|
|
#include <stdlib.h>
|
|
|
|
char far *vram=(char far *)0xa0000000L;
|
|
|
|
extern char lightshift;
|
|
|
|
extern int _ndebug1;
|
|
|
|
extern char asmtestmode;
|
|
|
|
extern int csetmatrix(int *,long,long,long);
|
|
extern int crotlist(long *,long *);
|
|
extern int cclipedges(int *,int *,long *); // modifies given point list
|
|
extern int cprojlist(long *,long *);
|
|
extern int cdrawpolylist(int *);
|
|
extern int cmatrix_yxz(int,int,int,int *);
|
|
extern int cpolylist(int *polylist,int *polys,int *edges,long *points3);
|
|
extern int ceasypolylist(int *polylist,int *polys,long *points3);
|
|
|
|
long cubepoints[]={8,
|
|
-666,-666,-666,
|
|
666,-666,-666,
|
|
666,666,-666,
|
|
-666,666,-666,
|
|
-666,-666,666,
|
|
666,-666,666,
|
|
666,666,666,
|
|
-666,666,666
|
|
};
|
|
int cubeepolys[]={
|
|
4,0x4002,0,1,2,3,
|
|
4,0x4004,4,5,6,7,
|
|
4,0x4006,0,1,5,4,
|
|
4,0x4008,1,2,6,5,
|
|
4,0x4003,2,3,7,6,
|
|
4,0x4005,3,0,4,7,
|
|
0};
|
|
|
|
long points[64]={14,
|
|
-1000,-1000,-1000,
|
|
1000,-1000,-1000,
|
|
1000,1000,-1000,
|
|
-1000,1000,-1000,
|
|
-1000,-1000,1000,
|
|
1000,-1000,1000,
|
|
1000,1000,1000,
|
|
-1000,1000,1000,
|
|
0,0,-1700,
|
|
0,0,1700,
|
|
1700,0,0,
|
|
-1700,0,0,
|
|
0,1700,0,
|
|
0,-1700,0};
|
|
long points2[256];
|
|
int points3[256*2];
|
|
int edges[64]={12,0,
|
|
0,1,0,0,
|
|
1,2,0,0,
|
|
2,3,0,0,
|
|
3,0,0,0,
|
|
4,5,0,0, // 4
|
|
5,6,0,0,
|
|
6,7,0,0,
|
|
7,4,0,0,
|
|
0,4,0,0, // 8
|
|
1,5,0,0,
|
|
2,6,0,0,
|
|
3,7,0,0};
|
|
int edges2[64];
|
|
int polys[64]={
|
|
4,0x4010,0,1,2,3,
|
|
4,0x4008,0,8,4,9,
|
|
4,0x4010,1,9,5,10,
|
|
4,0x4020,2,10,6,11,
|
|
4,0x4040,3,11,7,12,
|
|
4,0x4080,4,5,6,7,
|
|
0};
|
|
int epolys[]={
|
|
3,0x4010,0,1,8,
|
|
3,0x4020,1,2,8,
|
|
3,0x4010,2,3,8,
|
|
3,0x4020,3,0,8,
|
|
|
|
3,0x4010,2,1,10,
|
|
3,0x4020,1,5,10,
|
|
3,0x4010,5,6,10,
|
|
3,0x4020,6,2,10,
|
|
|
|
3,0x4010,2,6,12,
|
|
3,0x4020,6,7,12,
|
|
3,0x4010,7,3,12,
|
|
3,0x4020,3,2,12,
|
|
|
|
3,0x4010,0,3,11,
|
|
3,0x4020,3,7,11,
|
|
3,0x4010,7,4,11,
|
|
3,0x4020,4,0,11,
|
|
|
|
3,0x4010,5,1,13,
|
|
3,0x4020,1,0,13,
|
|
3,0x4010,0,4,13,
|
|
3,0x4020,4,5,13,
|
|
|
|
3,0x4010,5,4,9,
|
|
3,0x4020,4,7,9,
|
|
3,0x4010,7,6,9,
|
|
3,0x4020,6,5,9,
|
|
|
|
0};
|
|
int polylist[256];
|
|
int matrix[9];
|
|
|
|
int testlist[]={
|
|
3,16, 190,100, 90,50, 110,150,
|
|
3,20, 10,100, 90,50, 99,150,
|
|
0};
|
|
|
|
main()
|
|
{
|
|
int a,b,c,x,y,rx,ry,rz,n=8,p1,p2,r,g,zpos=7000;
|
|
testasm();
|
|
//initnewgroup();
|
|
outp(0x3c8,0);
|
|
for(a=0;a<256;a++)
|
|
{
|
|
r=g=b=0;
|
|
c=16+(a&15)*3;
|
|
if(a&0x10) { b+=40*c/64; }
|
|
if(a&0x20) { r+=50*c/64; g+=50*c/64; b+=50*c/64; }
|
|
if(a&0x40) { b+=10; }
|
|
if(a&0x80) { r+=10; g+=10; b+=20; }
|
|
if(a==1) { r=60; g=0; b=0; }
|
|
if(a==2) { r=0; g=60; b=0; }
|
|
if(a==3) { r=0; g=0; b=60; }
|
|
if(a==4) { r=50; g=50; b=50; }
|
|
if(r>63) r=63;
|
|
if(g>63) g=63;
|
|
if(b>63) b=63;
|
|
outp(0x3c9,r);
|
|
outp(0x3c9,g);
|
|
outp(0x3c9,b);
|
|
}
|
|
outp(0x3c8,7);
|
|
outp(0x3c9,40);
|
|
outp(0x3c9,40);
|
|
outp(0x3c9,40);
|
|
for(a=0;a<256;a++) vram[a]=a;
|
|
lightshift=8;
|
|
for(;;)
|
|
{
|
|
if(kbhit())
|
|
{
|
|
a=getch();
|
|
if(a==27) break;
|
|
if(a=='l') lightshift=2;
|
|
if(a=='+') zpos+=200;
|
|
if(a=='-') zpos-=200;
|
|
if(a=='<') lightshift--;
|
|
if(a=='>') lightshift++;
|
|
if(a=='t') asmtestmode=1;
|
|
if(a=='c') { if(zpos==3200) { lightshift=8; zpos=7000; } else { zpos=3200; lightshift=11; } }
|
|
}
|
|
asm();
|
|
setborder(1);
|
|
rx+=16; ry+=15; rz+=7;
|
|
rx%=3600; ry%=3600; rz%=3600;
|
|
//if(rz==0) printf(".");
|
|
/*
|
|
a=0;
|
|
while(polylist[a])
|
|
{
|
|
a+=polylist[a]*2+2;
|
|
}
|
|
polylist[a++]=4;
|
|
polylist[a++]=19;
|
|
polylist[a++]=160-60; polylist[a++]=100-40;
|
|
polylist[a++]=160+60; polylist[a++]=100-40;
|
|
polylist[a++]=160+60; polylist[a++]=100+40;
|
|
polylist[a++]=160-60; polylist[a++]=100+40;
|
|
polylist[a++]=0;
|
|
*/
|
|
cglenzinit();
|
|
|
|
cmatrix_yxz(rx,ry,rz,matrix);
|
|
csetmatrix(matrix,0,0,zpos);
|
|
points2[0]=0; crotlist(points2,points);
|
|
//cclipedges(edges2,edges,points2);
|
|
points3[0]=0; cprojlist((long *)points3,points2);
|
|
//cpolylist(polylist,polys,edges,points3);
|
|
ceasypolylist(polylist,epolys,points3);
|
|
|
|
cglenzpolylist(polylist);
|
|
|
|
cmatrix_yxz(rx*2,-ry,rz*2,matrix);
|
|
csetmatrix(matrix,0,0,zpos);
|
|
points2[0]=0; crotlist(points2,cubepoints);
|
|
points3[0]=0; cprojlist((long *)points3,points2);
|
|
ceasypolylist(polylist,cubeepolys,points3);
|
|
|
|
cglenzpolylist(polylist);
|
|
|
|
cglenzdone();
|
|
//cdrawpolylist(polylist);
|
|
//cdrawpolylist(testlist);
|
|
//setborder(3);
|
|
//drawnewgroup();
|
|
#if 0
|
|
n=edges[0];
|
|
for(a=2,b=0;b<n;b++)
|
|
{
|
|
p1=edges[a++];
|
|
p2=edges[a++];
|
|
a+=2;
|
|
testline(points3[p1*6+2],points3[p1*6+3],points3[p2*6+2],points3[p2*6+3],63);
|
|
}
|
|
#endif
|
|
}
|
|
_asm mov ax,3
|
|
_asm int 10h
|
|
#if 0
|
|
for(a=0;a<100;)
|
|
{
|
|
b=polylist[a++];
|
|
c=polylist[a++];
|
|
if(!b) break;
|
|
printf("s:%i c:%i v:",b,c);
|
|
for(x=0;x<b;x++)
|
|
{
|
|
printf("%i,%i ",polylist[a+0],polylist[a+1]);
|
|
a+=2;
|
|
}
|
|
printf("\n");
|
|
}
|
|
printf("points2: %Fp\n",points2);
|
|
#endif
|
|
printf("Z:%i LS:%i \n",zpos,lightshift);
|
|
}
|