LTCD_060719.ISO
This commit is contained in:
commit
f86e69648b
156 files changed
+49537
No files matched your search
@@ -0,0 +1,145 @@
|
||||
//This program does a fractel-like thing with
|
||||
//integer arithmetic, since floating is not
|
||||
//supported.
|
||||
|
||||
class Simplex
|
||||
{
|
||||
U8 x,y;
|
||||
};
|
||||
|
||||
void Norm(U4 *lo,U4 *hi,Simplex *n1)
|
||||
{
|
||||
U8 result=n1->x+n1->y;
|
||||
*lo=result.u4[0];
|
||||
*hi=result.u4[1];
|
||||
}
|
||||
|
||||
Simplex *CopySimplex(Simplex *dst, Simplex *src)
|
||||
{
|
||||
MemCpy(dst,src,sizeof(Simplex));
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
Simplex *Mix(Simplex *result,Simplex *n1,Simplex *n2)
|
||||
{
|
||||
result->x=MulU8(n1->x,n2->x);
|
||||
result->y=MulU8(n1->y,n2->y);
|
||||
return result;
|
||||
}
|
||||
|
||||
Simplex *Mangle(Simplex *result,Simplex *n1,Simplex *n2)
|
||||
{
|
||||
result->x=MulU8(n1->x,n2->y);
|
||||
result->y=MulU8(n1->y,n2->x);
|
||||
return result;
|
||||
}
|
||||
|
||||
Simplex *Add(Simplex *result,Simplex *n1,Simplex *n2)
|
||||
{
|
||||
result->x=n1->x+n2->x;
|
||||
result->y=n1->y+n2->y;
|
||||
return result;
|
||||
}
|
||||
|
||||
Simplex *Sub(Simplex *result,Simplex *n1,Simplex *n2)
|
||||
{
|
||||
result->x=n1->x-n2->x;
|
||||
result->y=n1->y-n2->y;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void DrawIt()
|
||||
{
|
||||
U1 old_attr=Fs->text_attribute;
|
||||
Fs->text_attribute=(BLACK<<4)+WHITE;
|
||||
ClearWindowText;
|
||||
Fs->text_attribute=old_attr;
|
||||
}
|
||||
|
||||
|
||||
void BigDawg()
|
||||
{
|
||||
U4 old_update,d_lo,d_hi;
|
||||
U8 sc,ch;
|
||||
I4 i,j,k,cnt;
|
||||
Simplex n1,n2,n3,n4,n5,n6,n7,n8;
|
||||
U4 in_color,key_hit;
|
||||
U8 timeout_jiffies;
|
||||
GrBitMap *base=GrNew(grbase);
|
||||
|
||||
old_update=Fs->update_window;
|
||||
Fs->update_window=&DrawIt;
|
||||
|
||||
MaximizeWindow;
|
||||
GrClear;
|
||||
do {
|
||||
n2.x=RandU4;
|
||||
SwapInNext;
|
||||
n2.y=RandU4;
|
||||
cnt=RandU4;
|
||||
SwapInNext;
|
||||
|
||||
n8.x=RandU4;
|
||||
SwapInNext;
|
||||
n8.y=RandU4;
|
||||
SwapInNext;
|
||||
|
||||
in_color=RandU2 & 1;
|
||||
|
||||
key_hit=FALSE;
|
||||
timeout_jiffies=jiffies+JIFFY_FREQ/8;
|
||||
for (j=0;j<grheight;j++) {
|
||||
if (jiffies>timeout_jiffies && j<20) {
|
||||
key_hit=TRUE;
|
||||
ch=0;
|
||||
break;
|
||||
}
|
||||
if (ScanChar(&sc,&ch)) {
|
||||
key_hit=TRUE;
|
||||
break;
|
||||
}
|
||||
for (i=0;i<grwidth;i++) {
|
||||
if (jiffies>timeout_jiffies && j<20) {
|
||||
key_hit=TRUE;
|
||||
ch=0;
|
||||
break;
|
||||
}
|
||||
n1.x.u4[0]=i;
|
||||
n1.y.u4[0]=j;
|
||||
n1.x.u4[1]=0;
|
||||
n1.y.u4[1]=0;
|
||||
CopySimplex(&n3,&n1);
|
||||
|
||||
k=0;
|
||||
Norm(&d_lo,&d_hi,&n3);
|
||||
while (d_lo<cnt && k<0x100) {
|
||||
if (jiffies>timeout_jiffies && j<20) {
|
||||
key_hit=TRUE;
|
||||
ch=0;
|
||||
break;
|
||||
}
|
||||
Mangle(&n7,Mix(&n4,&n3,&n1),
|
||||
Add(&n5,&n3,&n2));
|
||||
k++;
|
||||
Norm(&d_lo,&d_hi,
|
||||
Add(&n3,&n7,Mangle(&n6,&n3,&n8)));
|
||||
}
|
||||
if (!in_color)
|
||||
k=(k!=1)?15:0;
|
||||
base->color=ROP_EQU+k;
|
||||
GrPlot(base,i,j);
|
||||
}
|
||||
SwapInNext;
|
||||
}
|
||||
|
||||
if (!key_hit)
|
||||
ch=GetChar;
|
||||
GrClear;
|
||||
} while (ch!=CH_ESC && ch!=CH_CTRLQ);
|
||||
Fs->update_window=old_update;
|
||||
GrDel(base);
|
||||
}
|
||||
|
||||
BigDawg; //Autostart when included
|
||||
Reference in new issue
Block a user