Created
March 31, 2022 09:25
-
-
Save prozacchiwawa/b8d6ee46e3d2c1fdc54f36ce9b37d801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <graph.h> | |
#include <math.h> | |
#include <float.h> | |
#include <dos.h> | |
#include <malloc.h> | |
int *buf; | |
unsigned short off; | |
double direction; | |
#define CV 57.29577951 | |
const digital[10][7] = { { 1, | |
1, 1, | |
0, | |
1, 1, | |
1 }, | |
{ 0, | |
0, 1, | |
0, | |
0, 1, | |
0 }, | |
{ 1, | |
0, 1, | |
1, | |
1, 0, | |
1 }, | |
{ 1, | |
0, 1, | |
1, | |
0, 1, | |
1 }, | |
{ 0, | |
1, 1, | |
1, | |
0, 1, | |
0 }, | |
{ 1, | |
1, 0, | |
1, | |
0, 1, | |
1 }, | |
{ 1, | |
1, 0, | |
1, | |
1, 1, | |
1 }, | |
{ 1, | |
0, 1, | |
0, | |
0, 1, | |
0 }, | |
{ 1, | |
1, 1, | |
1, | |
1, 1, | |
1 }, | |
{ 1, | |
1, 1, | |
1, | |
0, 1, | |
1 } }; | |
const int cds[7][4] = { { 5, 20, 10, 20 }, | |
{ 5, 20, 5, 10 }, | |
{ 10, 20, 10, 10 }, | |
{ 5, 10, 10, 10 }, | |
{ 5, 10, 5, 0 }, | |
{ 10, 10, 10, 0 }, | |
{ 5, 0, 10, 0 } }; | |
#define OUT 0 | |
#define DRAW 1 | |
#define MOVE 2 | |
#define detect() (!(inp(0x3da) & 8)) | |
void doit( void ) | |
{ | |
char tmp[9]; | |
int n,j; | |
_strtime(tmp); | |
for (n = 0;n != 8;++n) | |
{ | |
switch(tmp[n]) | |
{ | |
case ':':buffer(MOVE,n*15-65,5); | |
buffer(DRAW,n*15-65,6); | |
buffer(MOVE,n*15-65,7); | |
buffer(DRAW,n*15-65,8); | |
break; | |
default:for (j=0;j!=7;++j) | |
{ | |
if (digital[tmp[n]-0x30][j]) | |
{ | |
buffer(MOVE,n*15+cds[j][0]-65, | |
cds[j][1]); | |
buffer(DRAW,n*15+cds[j][2]-65, | |
cds[j][3]); | |
} | |
} | |
} | |
} | |
} | |
int outbuf( void ) | |
{ | |
off -= 2; | |
return(*(buf+off)); | |
} | |
void inbuf( i ) | |
int i; | |
{ | |
*(buf+off) = i; | |
off += 2; | |
} | |
int buffer( control,x,y ) | |
int control,x,y; | |
{ | |
double dmx,dmy,dmz,ddz,ddy,ddx,ix,dxms,dyms,dxds,dyds; | |
if (control==OUT) | |
{ | |
ix = (double)(outbuf())* 100; | |
dmx = cos(direction/CV) * (ix-20); | |
dmy = sin(direction/CV) * ix + 13000; | |
dmz = (double)(outbuf()) * 200 - 1000; | |
dxms = dmx+dmz+1500; | |
dyms = dmy+dmz+1500; | |
ix = (double)(outbuf())* 100; | |
ddx = cos(direction/CV) * (ix-20); | |
ddy = sin(direction/CV) * ix + 13000; | |
ddz = (double)(outbuf()) * 200 - 1000; | |
dxds = ddx+ddz+1500; | |
dyds = ddy+ddz+1500; | |
_setcolor(0); | |
_moveto_w(dxms/(dyms/20),-1500/(dyms/20)); | |
_lineto_w(dxds/(dyds/20),-1500/(dyds/20)); | |
_setcolor(4); | |
_moveto_w(dmx/(dmy/20),dmz/(dmy/20)); | |
_lineto_w(ddx/(ddy/20),ddz/(ddy/20)); | |
} | |
if (control==MOVE) | |
{ | |
inbuf(y); | |
inbuf(x); | |
} | |
if (control==DRAW) | |
{ | |
inbuf(y); | |
inbuf(x); | |
} | |
return(off); | |
} | |
main() | |
{ | |
short apage = 1,vpage = 0; | |
direction = 3; | |
buf = malloc(1000); | |
_setvideomode(_MRES16COLOR); | |
_setwindow(1,-10,-8,10,8); | |
while(inp(0x60)&0x80) | |
{ | |
_setactivepage(apage); | |
_setvisualpage(vpage); | |
apage = (apage+1) % 2; | |
vpage = (vpage+1) % 2; | |
_setcolor(3); | |
_rectangle_w(_GFILLINTERIOR,-10,0,10,8); | |
_setcolor(8); | |
_rectangle_w(_GFILLINTERIOR,-10,-8,10,0); | |
doit(); | |
while (buffer(OUT,0,0)); | |
if (direction>360) | |
direction-=360; | |
direction += 10.1; | |
} | |
free(buf); | |
_setvideomode(_TEXTC80); | |
printf("Spinning Digits... A demo by UNKNOWN"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment