TempleOSCDV5.00.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:48:09 +02:00
1 parent 122df6338e
commit f6eacf7744
374 files changed
+11078 -11204

No files matched your search

-205
View File
@@ -1,205 +0,0 @@
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.HC"$.
$SP,"<1>",BI=1,BP="::/Demo/Graphics/Mountain.HC.Z,Mountain"$ //Pointer to sprite in $LK,"Mountain.HC",A="FI:::/Demo/Graphics/Mountain.HC"$ file
#define NUM_CLOUDS 16
#define SKY_LINES 30
#define CLOUD_PTS 512
#define CLOUD_PENS 8
#define CLOUD_PEN_PTS 16
#define CLOUD_PEN_SIZE 16
class Cloud
{
I64 i,x,y,w,h,dx,dy;
I64 color;
I64 px[CLOUD_PTS],py[CLOUD_PTS],pc[CLOUD_PTS];
} clouds[NUM_CLOUDS];
class CloudPen
{
CDC *img;
I64 px[CLOUD_PEN_PTS],py[CLOUD_PEN_PTS];
} cloud_pens[CLOUD_PENS];
CDC *cloud_pen;
I64 mp_not_done_flags;
U0 MPDrawClouds(CTask *task)
{
Cloud *c;
CDC *dc=DCAlias(gr.dc2,task);
I64 i,j,k,xx,yy,lo=Gs->num*CLOUD_PTS/mp_cnt,hi=(Gs->num+1)*CLOUD_PTS/mp_cnt;
for (j=0,c=clouds;j<NUM_CLOUDS;j++,c++)
for (i=lo;i<hi;i++) {
k=c->pc[i];
if (k<c->color)
dc->color=ROP_MONO+LTGRAY;
else
dc->color=ROP_MONO+WHITE;
xx=c->x.i32[1]+c->px[i];
yy=c->y.i32[1]+c->py[i];
k=RandU16&31-16;
if (k==-16)
k=-c->px[i];
c->px[i]+=SignI64(k);
k=RandU16&31-16;
if (k==-16)
k=-c->py[i];
c->py[i]+=SignI64(k);
GrBlot(dc,xx,yy,cloud_pens[i&(CLOUD_PENS-1)].img);
}
DCDel(dc);
LBtr(&mp_not_done_flags,Gs->num);
}
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i;
Sprite3(dc,0,SKY_LINES*FONT_HEIGHT,0,$IB,"<1>",BI=1$);
mp_not_done_flags=1<<mp_cnt-1;
for (i=0;i<mp_cnt;i++)
JobQue(&MPDrawClouds,task,i);
while (mp_not_done_flags)
Yield;
}
U0 AnimateTask(I64)
{
I64 i,j;
Cloud *c;
CloudPen *cp;
while (TRUE) {
Refresh;
for (i=0,cp=cloud_pens;i<CLOUD_PENS;i++,cp++) {
DCClear(cp->img);
cp->img->color=COLOR_MONO;
for (j=0;j<CLOUD_PEN_PTS;j++) {
GrPlot(cp->img,cp->px[j],cp->py[j]);
cp->px[j]=ClampI64(cp->px[j]+RandU16%3-1,0,CLOUD_PEN_SIZE-1);
cp->py[j]=ClampI64(cp->py[j]+RandU16%3-1,0,CLOUD_PEN_SIZE-1);
}
}
for (i=0,c=clouds;i<NUM_CLOUDS;i++,c++) {
c->x+=c->dx;
c->y=ClampI64(c->y+c->dy,0,0.7*(SKY_LINES*FONT_HEIGHT)<<32);
c->color=MAX_U16*c->y.i32[1]/(0.8*(SKY_LINES*FONT_HEIGHT));
}
Sleep(20);
}
}
#define SAMPLES 6
U0 Init()
{
Cloud *c=clouds;
CloudPen *cp=cloud_pens;
I64 i,j,k,l,
w=Fs->pix_width,
h=SKY_LINES*FONT_HEIGHT;
for (i=0;i<NUM_CLOUDS;i++,c++) {
c->x=ToI64(w/2+Rand*w/2-w/4)<<32;
c->y=ToI64(h/2+Rand*h/2-h/4)<<32;
c->dx=RandI32;
c->dy=RandI32;
c->w=100;
c->h=50;
c->color=RandU16;
for (l=0;l<CLOUD_PTS;l++) {
k=0;
for (j=0;j<SAMPLES;j++)
k+=RandI16;
c->px[l]=(k*c->w/MAX_I16)/SAMPLES;
k=0;
for (j=0;j<SAMPLES;j++)
k+=RandI16;
c->py[l]=(k*c->h/MAX_I16)/SAMPLES;
c->pc[l]=RandU16;
}
}
for (i=0;i<CLOUD_PENS;i++,cp++) {
cp->img=DCNew(CLOUD_PEN_SIZE,CLOUD_PEN_SIZE);
for (j=0;j<CLOUD_PEN_PTS;j++) {
cp->px[j]=RandU16%CLOUD_PEN_SIZE;
cp->py[j]=RandU16%CLOUD_PEN_SIZE;
}
}
}
U0 CleanUp()
{
I64 i;
CloudPen *cp=cloud_pens;
for (i=0;i<CLOUD_PENS;i++,cp++)
DCDel(cp->img);
}
U0 SongTask(I64)
{//Song by the Holy Spirit
//This specifies a callback routine
//to be called when the task dies.
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("3qBetDA2G3qD2sG3E2G3EetCEDqFEeDC");
Play("qBetDA2G3qD2sG3E2G3EetCEDqFEeDC");
Play("CGqDeADsDCDCqGEetDAD2sG3D2G3D");
Play("eCGqDeADsDCDCqGEetDAD2sG3D2G3D");
}
}
U0 CloudScene()
{
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
try {
Fs->text_attr=YELLOW<<4+BLUE;
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
"$$BG,LTCYAN$$%h*c",SKY_LINES,'\n';
"$$BG,YELLOW$$%h5c",'\n';
BibleVerse(,"Exodus,14:19",7);
Fs->draw_it=&DrawIt;
GetChar;
Refresh;
} catch
PutExcept;
SettingsPop;
CleanUp;
}
#if __CMD_LINE__
CloudScene;
#endif
+2 -2
View File
@@ -1,13 +1,13 @@
interrupt U0 IntBeepOn()
{
*(dev.uncached_alias+LAPIC_EOI)(U32 *)=0; //signal end of interrupt
Snd(100);
Snd(34);
}
interrupt U0 IntBeepOff()
{
*(dev.uncached_alias+LAPIC_EOI)(U32 *)=0;
Snd(0);
Snd;
}
U0 IntTest()
+2 -2
View File
@@ -20,7 +20,7 @@ U0 MPUnlockedInc(I64)
U0 UnlockedInc()
{
CSrvCmd *tmpm0,*tmpm1;
CJob *tmpm0,*tmpm1;
glbl=0;
tmpm0=JobQue(&MPUnlockedInc,NULL,0,0);
tmpm1=JobQue(&MPUnlockedInc,NULL,1,0);
@@ -39,7 +39,7 @@ U0 MPLockedInc(I64)
U0 LockedInc()
{
CSrvCmd *tmpm0,*tmpm1;
CJob *tmpm0,*tmpm1;
glbl=0;
tmpm0=JobQue(&MPLockedInc,NULL,0,0);
tmpm1=JobQue(&MPLockedInc,NULL,1,0);
+1 -1
View File
@@ -12,7 +12,7 @@ I64 MPSum(I64 my_mp_cnt)
I64 Sum(I64 n,I64 my_mp_cnt)
{
CSrvCmd *tmpm[MP_MAX_PROCESSORS];
CJob *tmpm[MP_MAX_PROCESSORS];
I64 res=0,i;
mp_n=n+1;
for (i=0;i<my_mp_cnt;i++)
+16 -16
View File
@@ -8,7 +8,7 @@ for sorting. Then, it merge sorts them.
I64 my_mp_cnt=1<<Bsr(mp_cnt);//Power of 2
I32 *a1,*a2;
I32 *arg1,*arg2;
I32 *b[my_mp_cnt],bn[my_mp_cnt];
I64 mp_not_done_flags;
@@ -73,25 +73,25 @@ U0 MPRadixSortDemo(I64 dummy=0)
no_warn dummy;
I64 i,j,k1,k2;
F64 t0;
a1=MAlloc(NUM*sizeof(I32));
arg1=MAlloc(NUM*sizeof(I32));
for (i=0;i<NUM;i++)
a1[i]=RandI32;
arg1[i]=RandI32;
a2=MAlloc(NUM*sizeof(I32));
arg2=MAlloc(NUM*sizeof(I32));
"$$GREEN$$QSort$$FG$$\n";
t0=tS;
MemCpy(a2,a1,sizeof(I32)*NUM);
QSort(a2,NUM,sizeof(I32),&Compare);
MemCpy(arg2,arg1,sizeof(I32)*NUM);
QSort(arg2,NUM,sizeof(I32),&Compare);
"Time:%9.6f\n",tS-t0;
D(a2+NUM/4);
D(arg2+NUM/4);
"$$GREEN$$QSortU32$$FG$$\n";
t0=tS;
MemCpy(a2,a1,sizeof(I32)*NUM);
QSortU32(a2,NUM);
MemCpy(arg2,arg1,sizeof(I32)*NUM);
QSortU32(arg2,NUM);
"Time:%9.6f\n",tS-t0;
D(a2+NUM/4);
D(arg2+NUM/4);
for (i=0;i<my_mp_cnt;i++) {
//$WW,0$We must do full size, just in case.
@@ -108,8 +108,8 @@ U0 MPRadixSortDemo(I64 dummy=0)
k1=32-Bsr(my_mp_cnt);
k2=my_mp_cnt/2;
for (i=0;i<NUM;i++) {
j=a1[i]>>k1+k2; //This is a preliminary radix sort.
b[j][bn[j]++]=a1[i];
j=arg1[i]>>k1+k2; //This is a preliminary radix sort.
b[j][bn[j]++]=arg1[i];
}
mp_not_done_flags=1<<my_mp_cnt-1;
for (i=0;i<my_mp_cnt;i++)
@@ -118,14 +118,14 @@ U0 MPRadixSortDemo(I64 dummy=0)
Yield;
j=0;
for (i=0;i<my_mp_cnt;i++) {
MemCpy(&a2[j],b[i],bn[i]*sizeof(I32));
MemCpy(&arg2[j],b[i],bn[i]*sizeof(I32));
j+=bn[i];
}
"Time:%9.6f\n",tS-t0;
D(a2+NUM/4);
D(arg2+NUM/4);
Free(a1);
Free(a2);
Free(arg1);
Free(arg2);
for (i=0;i<my_mp_cnt;i++)
Free(b[i]);
}
+1 -1
View File
@@ -27,7 +27,7 @@ U0 PDAnswer(U8 *a,I64 len)
{
DocLock(doc);
a-=(len-1)/2;
DocPrint(doc,"CPU:%d Len:%2d ",Gs->num,len);
DocPrint(doc,"CPU%02X Len:%2d ",Gs->num,len);
while (len--)
DocPrint(doc,"%C",*a++); //%C is toupper char
DocPrint(doc,"\n");