Browse Source

TempleOS V5.03 Nightly (ISO SHA-1 54758c6)

v6
Terry A. Davis 5 years ago committed by TempleOS-bot
parent
commit
66b9e3183f
  1. BIN
      0000Boot/0000Kernel.BIN.C
  2. 444
      Adam/ABlkDev/ChkDsk.HC
  3. 167
      Adam/ABlkDev/PrtDsk.HC
  4. 409
      Adam/ASnd.HC
  5. 58
      Adam/Gr/GrMV.HC
  6. 96
      Adam/Gr/ScrnCast.HC
  7. BIN
      Compiler/Compiler.BIN
  8. 2
      Compiler/CompilerB.HH
  9. 17
      Demo/AcctExample/AlienProject/AlienMain.HC
  10. BIN
      Demo/AcctExample/AlienProject/AlienWorkingDir.HC
  11. 90
      Demo/AcctExample/LightTable.HC
  12. 6
      Demo/AcctExample/PersonalNotes.DD
  13. 2
      Demo/AcctExample/Registry.HC
  14. BIN
      Demo/AcctExample/TOS/TOSTheme.HC
  15. 2029
      Demo/WebLogDemo/access_170605.log
  16. 1649
      Demo/WebLogDemo/access_170606.log
  17. 3169
      Demo/WebLogDemo/access_170622.log
  18. 2
      Doc/ChgLog.DD
  19. 26
      Doc/NewASCII.DD
  20. 24
      Doc/Reliability.DD
  21. BIN
      Downloads/Linux/TOSZ
  22. 1084
      Downloads/Linux/TOSZ.CPP
  23. 6
      Downloads/Linux/gw
  24. 7
      Downloads/Linux/make_tosz
  25. 23
      Downloads/ReadMe.TXT
  26. 151
      Kernel/BlkDev/DskCluster.HC
  27. 238
      Kernel/KMain.HC
  28. BIN
      Linux/TOSZ
  29. 6
      Linux/gw
  30. 9
      Linux/make_tosz

BIN
0000Boot/0000Kernel.BIN.C

Binary file not shown.

444
Adam/ABlkDev/ChkDsk.HC

@ -0,0 +1,444 @@
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
Bool ChkDskConfirm(Bool *_fix,Bool *_confirm)
{
if (*_fix && *_confirm) {
"Fix ";
if (!YorN)
*_fix=FALSE;
*_confirm=FALSE;
}
return *_fix;
}
I64 RedSeaChkDskLst(CDrv *dv,CDirEntry *tmpde1,
U8 *bits,U8 *bits2,I64 size,I64 bpc)
{
CDirEntry *tmpde2;
I64 i,j,errs=0;
while (tmpde1) {
tmpde2=tmpde1->next;
if (tmpde1->attr & RS_ATTR_DIR && tmpde1->sub)
errs+=RedSeaChkDskLst(dv,tmpde1->sub,bits,bits2,size,bpc);
j=(tmpde1->size+bpc-1)/bpc;
for (i=0;i<j;i++) {
if (i+tmpde1->cluster-dv->data_area>size) {
PrintErr("Invalid Cluster:%s Cluster:%X\n",tmpde1->full_name,
i+tmpde1->cluster);
errs++;
break;
}
if (LBts(bits,i+tmpde1->cluster-dv->data_area)) {
PrintErr("Dbl Alloc:%s Cluster:%X\n",tmpde1->full_name,
i+tmpde1->cluster);
errs++;
}
if (!LBtr(bits2,i+tmpde1->cluster-dv->data_area)) {
PrintErr("UnAlloc:%s Cluster:%X\n",tmpde1->full_name,
i+tmpde1->cluster);
errs++;
}
}
DirEntryDel(tmpde1);
tmpde1=tmpde2;
}
return errs;
}
I64 RedSeaChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{
I64 i,j,bpc,size,errs=0;
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
*old_dir=StrNew(Fs->cur_dir),
*bits,*bits2;
CDirEntry *ptr,*ptr2;
Drv(drv_let);
"Scanning...\n";
size=(dv->size-(dv->data_area-dv->drv_offset))/dv->spc;
bpc=dv->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3);
bits2=CAlloc((size+7)>>3+BLK_SIZE);
RBlks(dv,bits2,dv->fat1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
//Get Root Dir size
ptr2=MAlloc(bpc);
RBlks(dv,ptr2,dv->root_cluster,1);
ptr=ptr2(U8 *)-offset(CDirEntry.start);
j=(ptr->size+bpc-1)/bpc;
Free(ptr2);
for (i=0;i<j;i++) {
if (i+dv->root_cluster-dv->data_area>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++;
break;
}
if (LBts(bits,i+dv->root_cluster-dv->data_area)) {
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++;
}
if (!LBtr(bits2,i+dv->root_cluster-dv->data_area)) {
PrintErr("UnAlloc: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++;
}
}
errs+=RedSeaChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),
bits,bits2,size,bpc);
for (i=1;i<size;i++)
if (Bt(bits2,i)) {
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i+dv->data_area);
errs++;
if (ChkDskConfirm(_fix,_confirm))
RedSeaFreeClusters(dv,i+dv->data_area,1);
}
Free(files_find_mask);
Free(bits);
Free(bits2);
Drv(Drv2Let(old_dv));
Cd(old_dir);
Free(old_dir);
return errs;
}
I64 FAT32ChkDskLst(CDrv *dv,CDirEntry *tmpde1,
U8 *bits,U32 *bits2,I64 size,I64 bpc)
{
CDirEntry *tmpde2;
I64 i,c,errs=0;
while (tmpde1) {
tmpde2=tmpde1->next;
if (tmpde1->attr & RS_ATTR_DIR && tmpde1->sub)
errs+=FAT32ChkDskLst(dv,tmpde1->sub,bits,bits2,size,bpc);
i=0;
c=tmpde1->cluster;
while (0<c<0x0FFFFFF8) {
if (c>size) {
PrintErr("Invalid Cluster:%s Cluster:%X\n",tmpde1->full_name,c);
errs++;
break;
}
if (LBts(bits,c)) {
PrintErr("Dbl Alloc:%s Cluster:%X\n",tmpde1->full_name,c);
errs++;
}
if (!bits2[c]) {
PrintErr("UnAlloc:%s Cluster:%X\n",tmpde1->full_name,c);
errs++;
} else
bits2[c]=0;
c=ClusterNumNext(dv,c);
i++;
}
if (!(tmpde1->attr & RS_ATTR_DIR)) {
i*=bpc;
if (tmpde1->size>i) {
PrintErr("Alloced File Too Short:%s\n",tmpde1->full_name);
errs++;
}
if (i>tmpde1->size+bpc-1) {
PrintWarn("Alloced File Too Long:%s\n",tmpde1->full_name);
errs++;
}
}
DirEntryDel(tmpde1);
tmpde1=tmpde2;
}
return errs;
}
I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{
I64 i,bpc,size,c,errs=0;
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
*old_dir=StrNew(Fs->cur_dir),
*bits;
U32 *bits2;
Drv(drv_let);
"Scanning...\n";
size=(dv->size-(dv->data_area-dv->drv_offset))/dv->spc;
bpc=dv->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3);
bits2=CAlloc(size*4+BLK_SIZE);
RBlks(dv,bits2,dv->fat1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
c=dv->root_cluster;
while (0<c<0x0FFFFFF8) {
if (c>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",c);
errs++;
break;
}
if (LBts(bits,c)) {
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",c);
errs++;
}
if (!bits2[c]) {
PrintErr("UnAlloc: RootDir Cluster:%X\n",c);
errs++;
} else
bits2[c]=0;
c=ClusterNumNext(dv,c);
}
errs+=FAT32ChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),
bits,bits2,size,bpc);
bits2[1]=0; //See $LK,"FAT32Fmt",A="MN:FAT32Fmt"$()
for (i=1;i<size;i++)
if (bits2[i]) {
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
errs++;
if (ChkDskConfirm(_fix,_confirm))
FAT32FreeClusters(dv,i);
}
Free(files_find_mask);
Free(bits);
Free(bits2);
Drv(Drv2Let(old_dv));
Cd(old_dir);
Free(old_dir);
return errs;
}
public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
{//Check disk for allocation errors and, optionally, fix.
//You probably want to reformat and reinstall.
I64 errs=0;
CDrv *dv=Let2Drv(drv_let);
switch (dv->fs_type) {
case FSt_REDSEA:
errs=RedSeaChkDsk(drv_let,&fix,&confirm);
break;
case FSt_FAT32:
errs=FAT32ChkDsk(drv_let,&fix,&confirm);
break;
default:
PrintErr("File System Not Supported\n");
}
if (errs) {
if (fix)
"It might be a little better. ";
"Copy files to another partition or CD/DVD, "
"reformat, and copy back. "
"Or, copy from a back-up.\n";
}
return errs;
}
U0 RedSeaDrvView(U8 drv_let=0)
{
CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=dv->size+dv->drv_offset-dv->data_area;
U8 *bitmap;
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
WinBorder(ON);
DocCursor;
DocClear;
DCFill;
try {
i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(dv,bitmap,dv->fat1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
break;
for (x=0;x<GR_WIDTH-FONT_WIDTH<<1;x++) {
lohi=i*s;
c1=lohi/l;
if (Bt(bitmap,c1))
dc->color=ROP_XOR+BLUE^TRANSPARENT;
else
dc->color=ROP_XOR+WHITE^TRANSPARENT;
GrPlot(dc,x,y);
i++;
}
}
Free(bitmap);
} catch
DrvUnlock(dv);
GetChar;
SettingsPop;
DCFill;
DCDel(dc);
}
U0 FAT32DrvView(U8 drv_let=0)
{
CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(dv->size+dv->spc-1)/dv->spc-(2+dv->data_area-dv->drv_offset);
U32 *bitmap;
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
WinBorder(ON);
DocCursor;
DocClear;
DCFill;
try {
i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(dv,bitmap,dv->fat1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
break;
for (x=0;x<GR_WIDTH-FONT_WIDTH<<1;x++) {
lohi=i*s;
c1=lohi/l;
if (bitmap[c1])
dc->color=ROP_XOR+BLUE^TRANSPARENT;
else
dc->color=ROP_XOR+WHITE^TRANSPARENT;
GrPlot(dc,x,y);
i++;
}
}
Free(bitmap);
} catch
DrvUnlock(dv);
GetChar;
SettingsPop;
DCFill;
DCDel(dc);
}
public U0 DrvView(U8 drv_let=0)
{//Drive view. Graph the allocation map's fragmentation.
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
Drv(drv_let);
switch (dv->fs_type) {
case FSt_REDSEA:
RedSeaDrvView(drv_let);
break;
case FSt_FAT32:
FAT32DrvView(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Drv2Let(old_dv));
}
public U0 DskView(U8 drv_let=0)
{//Disk view. Pie chart of partition sizes.
I64 i,j,attr,
h=Fs->pix_width,
v=Fs->pix_height,
radius;
CDrv *dv;
CBlkDev *bd=Let2BlkDev(drv_let);
CDC *dc=DCAlias;
F64 sect_start,sect_end;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
DocCursor;
DocClear;
DCFill;
if (h<v)
radius=0.4*h;
else
radius=0.4*v;
dc->color=BLACK;
GrCircle(dc,h>>1,v>>1,radius);
j=1;
for (i=0;i<DRVS_NUM;i++) {
dv=&blkdev.drvs[i];
if (bd==dv->bd && dv->fs_type) {
sect_start=-(dv->drv_offset*2*ã/(bd->max_blk+1));
sect_end =-((dv->drv_offset+dv->size)*2*ã/(bd->max_blk+1));
dc->color=BLACK;
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_start),
v>>1+radius*Sin(sect_start));
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_end),
v>>1+radius*Sin(sect_end));
attr=DrvTextAttrGet(Drv2Let(dv));
dc->color=attr&15;
GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Drv2Let(dv),
dv->fs_type,"ST_DRV_TYPES");
dc->color.c1=attr>>4;
dc->color|=ROPF_DITHER;
GrFloodFill(dc,
h>>1+(radius-4)*Cos((sect_start+sect_end)/2),
v>>1+(radius-4)*Sin((sect_start+sect_end)/2),FALSE);
j++;
}
}
GetChar(,FALSE);
SettingsPop;
DCFill;
DCDel(dc);
}
I64 RedSeaUnusedDrvSpace(U8 drv_let=0)
{
CDrv *dv=Let2Drv(drv_let);
I64 res=0,i,l;
U8 *bitmap;
try {
l=dv->size+dv->drv_offset-dv->data_area;
i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(dv,bitmap,dv->fat1,i);
for (i=0;i<l;i++)
if (!Bt(bitmap,i))
res++;
Free(bitmap);
} catch
DrvUnlock(dv);
return res*BLK_SIZE*dv->spc;
}
I64 FAT32UnusedDrvSpace(U8 drv_let=0)
{
CDrv *dv=Let2Drv(drv_let);
I64 res=0,i,l;
U32 *bitmap;
try {
l=(dv->size+dv->spc-1)/dv->spc-(2+dv->data_area-dv->drv_offset);
i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(dv,bitmap,dv->fat1,i);
for (i=0;i<l;i++)
if (!bitmap[i])
res++;
Free(bitmap);
} catch
DrvUnlock(dv);
return res*BLK_SIZE*dv->spc;
}
public I64 UnusedDrvSpace(U8 drv_let=0)
{//Returns unused size in bytes.
CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *old_dir=StrNew(Fs->cur_dir);
I64 res=0;
Drv(drv_let);
switch (dv->fs_type) {
case FSt_REDSEA:
res=RedSeaUnusedDrvSpace(drv_let);
break;
case FSt_FAT32:
res=FAT32UnusedDrvSpace(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Drv2Let(old_dv));
Cd(old_dir);
Free(old_dir);
return res;
}

167
Adam/ABlkDev/PrtDsk.HC

@ -0,0 +1,167 @@
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)"
#define ROUND_DRV_TO (63*255)
#define DRV_HEADER 63
class CPlannedDrv
{
CPlannedDrv *next,*last;
I64 size;
Bool pri;
};
public I64 PrtDsk(U8 drv_let=0,...)
{/*Partition the disk containing partition drv_let.
drv_let=0 means add new drive that is not already mounted.
>PrtDsk('C',0.5,0.25,0.25); //Make three. 50% C, 25% D, 25% E, round-up to blk.
*/
CBlkDev *bd;
CPlannedDrv head,*tmppp;
CMasterBoot mbr;
Bool pri=TRUE;
I64 ext_base,drv_let2,pri_cnt=0,i,start_offset,offset,
total,remaining,cur_arg=0;
"This command does not play well\n"
"with other operating systems.\n"
"You really should use another\n"
"operating system's partitioner.\n"
"If you use this, it may, in fact,\n"
"make your hard drive impossible\n"
"to repartition with other operating\n"
"until you set block zero to zero\n"
"with $$LK,\"BootMHDZero\",\"MN:BootMHDZero\"$$()\n\n\n"
"Continue";
if (argc<=cur_arg && !YorN)
return 0;
'\n';
if (drv_let && !Let2BlkDev(drv_let,FALSE))
drv_let=0;
if (!drv_let && !(drv_let=Mount(TRUE)) ||
!(bd=Let2BlkDev(drv_let,FALSE)) || bd->type!=BDT_ATA)
return 0;
total=bd->max_blk+1;
QueInit(&head);
drv_let2=bd->first_drv_let;
remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO);
while (FloorU64(remaining,ROUND_DRV_TO)>=ROUND_DRV_TO) {
tmppp=MAlloc(sizeof(CPlannedDrv));
do {
"$$RED$$Partition %C$$FG$$\n",drv_let2;
tmppp->pri=FALSE;
if (pri) {
"Primary Partition";
if (argc>cur_arg || YorN) {
pri_cnt++;
tmppp->pri=TRUE;
if (pri_cnt==3)
pri=FALSE;
} else
pri=FALSE;
}
"\nBlocks Remaining:%d (0x%X)\n",
remaining-DRV_HEADER,remaining-DRV_HEADER;
if (argc>cur_arg)
tmppp->size=MinI64(CeilU64(MaxI64(remaining,DRV_HEADER),ROUND_DRV_TO),
CeilU64(argv[cur_arg++](F64)*total,ROUND_DRV_TO));
else
tmppp->size=CeilU64(GetI64("Size in Blocks :",
remaining-DRV_HEADER)+DRV_HEADER,ROUND_DRV_TO);
} while (!(ROUND_DRV_TO<=tmppp->size<=FloorU64(remaining,ROUND_DRV_TO)));
QueIns(tmppp,head.last);
remaining-=tmppp->size;
drv_let2++;
}
"\n\n!!! Repartition Drive !!!\n\n";
tmppp=head.next;
drv_let2=bd->first_drv_let;
while (tmppp!=&head) {
"Drive %C:%08X ",drv_let2,tmppp->size;
if (tmppp->pri)
"Primary\n";
else
"Logical\n";
tmppp=tmppp->next;
drv_let2++;
}
if (!argc && !AreYouSure)
goto pd_done;
remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO)-ROUND_DRV_TO;
tmppp=head.next;
MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55;
offset=0;
for (i=0;i<pri_cnt;i++) {
mbr.p[i].active=0x80;
mbr.p[i].start_head=0;
mbr.p[i].start_cyl=0x101;
mbr.p[i].type=1; //Will get set different.
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=DRV_HEADER+offset;
mbr.p[i].size=tmppp->size-DRV_HEADER;
offset+=tmppp->size;
remaining-=tmppp->size;
tmppp=tmppp->next;
}
if (!i) i++;
if (tmppp!=&head) {
mbr.p[i].active=0x80;
mbr.p[i].start_head=0;
mbr.p[i].start_cyl=0x101;
mbr.p[i].type=0xF;
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=offset;
mbr.p[i].size=remaining;
ext_base=offset;
}
ATAWriteBlks(bd,&mbr,0,1);
while (tmppp!=&head) {
start_offset=offset;
MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55;
mbr.p[0].active=0x80;
mbr.p[0].start_head=1;
mbr.p[0].start_cyl=0x101;
mbr.p[0].type=1; //Will get set different.
mbr.p[0].end_head=0xFE;
mbr.p[0].end_cyl=0xFFFF;
mbr.p[0].offset=DRV_HEADER;
mbr.p[0].size=tmppp->size-DRV_HEADER;
offset+=tmppp->size;
tmppp=tmppp->next;
if (tmppp!=&head) {
mbr.p[1].active=0x80;
mbr.p[1].start_head=0;
mbr.p[1].start_cyl=0x101;
mbr.p[1].type=5;
mbr.p[1].end_head=0xFE;
mbr.p[1].end_cyl=0xFFFF;
mbr.p[1].offset=offset-ext_base;
mbr.p[1].size=tmppp->size;
}
ATAWriteBlks(bd,&mbr,start_offset,1);
}
bd->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS);
BlkDevAdd(bd,,FALSE,TRUE);
for (i=bd->first_drv_let;i<drv_let2;i++)
Fmt(i,,FALSE);
pd_done:
while (head.next!=&head) {
tmppp=head.next;
QueRem(tmppp);
Free(tmppp);
}
return total;
}

409
Adam/ASnd.HC

@ -0,0 +1,409 @@
#help_index "Snd"
public U0 SndTaskEndCB()
{//Will turn-off snd when a task gets killed.
Snd;
Exit;
}
#help_index "Snd/Math;Math"
public F64 Saw(F64 t,F64 period)
{//Sawtooth. 0.0 - 1.0 think "(Sin+1)/2"
if (period) {
if (t>=0.0)
return t%period/period;
else
return 1.0+t%period/period;
} else
return 0.0;
}
public F64 FullSaw(F64 t,F64 period)
{//Plus&Minus Sawtooth. 1.0 - -1.0 think "Sin"
if (period) {
if (t>=0.0)
return 2.0*(t%period/period)-1.0;
else
return 2.0*(t%period/period)+1.0;
} else
return 0.0;
}
public F64 Caw(F64 t,F64 period)
{//Cawtooth. 1.0 - 0.0 think "(Cos+1)/2"
if (period) {
if (t>=0.0)
return 1.0-t%period/period;
else
return -(t%period)/period;
} else
return 1.0;
}
public F64 FullCaw(F64 t,F64 period)
{//Plus&Minus Cawtooth. 1.0 - -1.0 think "Cos"
if (period) {
if (t>=0.0)
return -2.0*(t%period/period)+1.0;
else
return -2.0*(t%period/period)-1.0;
} else
return 1.0;
}
public F64 Tri(F64 t,F64 period)
{//Triangle waveform. 0.0 - 1.0 - 0.0
if (period) {
t=2.0*(Abs(t)%period)/period;
if (t<=1.0)
return t;
else
return 2.0-t;
} else
return 0.0;
}
public F64 FullTri(F64 t,F64 period)
{//Plus&Minus Triangle waveform. 0.0 - 1.0 - 0.0 - -1.0 -0.0
if (period) {
t=4.0*(t%period)/period;
if (t<=-1.0) {
if (t<=-3.0)
return t+4.0;
else
return -2.0-t;
} else {
if (t<=1.0)
return t;
else if (t<=3.0)
return 2.0-t;
else
return t-4.0;
}
} else
return 0.0;
}
#help_index "Snd/Music"
public class CMusicGlbls
{
U8 *cur_song;
CTask *cur_song_task;
I64 octave;
F64 note_len;
U8 note_map[7];
Bool mute;
I64 meter_top,meter_bottom;
F64 tempo,stacatto_factor;
//If you wish to sync with a
//note in a Play() string. 0 is the start
I64 play_note_num;
F64 tM_correction,last_Beat,last_tM;
} music={NULL,NULL,4,1.0,{0,2,3,5,7,8,10},FALSE,4,4,2.5,0.9,0,0,0,0};
#help_index "Snd/Music;Time/Seconds"
public F64 tM()
{//Time in seconds synced to music subsystem.
return (cnts.jiffies+music.tM_correction)/JIFFY_FREQ;
}
public F64 Beat()
{//Time in music beats.
F64 res,cur_tM;
PUSHFD
CLI
if (mp_cnt>1)
while (LBts(&sys_semas[SEMA_TMBEAT],0))
PAUSE
cur_tM=tM;
res=music.last_Beat;
if (music.tempo)
res+=(cur_tM-music.last_tM)*music.tempo;
music.last_tM=cur_tM;
music.last_Beat=res;
LBtr(&sys_semas[SEMA_TMBEAT],0);
POPFD
return res;
}
#help_index "Snd/Music"
U8 *MusicSetOctave(U8 *st)
{
I64 ch;
ch=*st++;
while ('0'<=ch<='9') {
music.octave=ch-'0';
ch=*st++;
}
return --st;
}
U8 *MusicSetMeter(U8 *st)
{
I64 ch;
ch=*st++;
while (ch=='M') {
ch=*st++;
if ('0'<=ch<='9') {
music.meter_top=ch-'0';
ch=*st++;
}
if (ch=='/')
ch=*st++;
if ('0'<=ch<='9') {
music.meter_bottom=ch-'0';
ch=*st++;
}
}
return --st;
}
U8 *MusicSetNoteLen(U8 *st)
{
Bool cont=TRUE;
do {
switch (*st++) {
case 'w': music.note_len=4.0; break;
case 'h': music.note_len=2.0; break;
case 'q': music.note_len=1.0; break;
case 'e': music.note_len=0.5; break;
case 's': music.note_len=0.25; break;
case 't': music.note_len=2.0*music.note_len/3.0; break;
case '.': music.note_len=1.5*music.note_len; break;
default:
st--;
cont=FALSE;
}
} while (cont);
return st;
}
public I8 Note2Ona(I64 note,I64 octave=4)
{//Note to ona. Mid C is ona=51, note=3 and octave=4.
if (note<3)
return (octave+1)*12+note;
else
return octave*12+note;
}
public I8 Ona2Note(I8 ona)
{//Ona to note in octave. Mid C is ona=51, note=3 and octave=4.
return ona%12;
}
public I8 Ona2Octave(I8 ona)
{//Ona to octave. Mid C is ona=51, note=3 and octave=4.
I64 note=ona%12,octave=ona/12;
if (note<3)
return octave-1;
else
return octave;
}
public U0 Play(U8 *st,U8 *words=NULL)
{/* Notes are entered with a capital letter.
Octaves are entered with a digit and
stay set until changed. Mid C is octave 4.
Durations are entered with
'w' whole note
'h' half note
'q' quarter note
'e' eighth note
't' sets to 2/3rds the current duration
'.' sets to 1.5 times the current duration
durations stay set until changed.
'(' tie, placed before the note to be extended
$LK,"music.meter_top",A="MN:CMusicGlbls"$,$LK,"music.meter_bottom",A="MN:CMusicGlbls"$ is set with
"M3/4"
"M4/4"
etc.
Sharp and flat are done with '#' or 'b'.
The var music.stacatto_factor can
be set to a range from 0.0 to 1.0.
The var music.tempo is quarter-notes
per second. It defaults to
2.5 and gets faster when bigger.
*/
U8 *word,*last_st;
I64 note,octave,i=0,ona,timeout_val,timeout_val2;
Bool tie;
F64 d,on_jiffies,off_jiffies;
music.play_note_num=0;
while (*st) {
timeout_val=cnts.jiffies;
tie=FALSE;
do {
last_st=st;
if (*st=='(') {
tie=TRUE;
st++;
} else {
st=MusicSetMeter(st);
st=MusicSetOctave(st);
st=MusicSetNoteLen(st);
}
} while (st!=last_st);
if (!*st) break;
note=*st++-'A';
if (note<7) {
note=music.note_map[note];
octave=music.octave;
if (*st=='b') {
note--;
if (note==2)
octave--;
st++;
} else if (*st=='#') {
note++;
if (note==3)
octave++;
st++;
}
ona=Note2Ona(note,octave);
} else
ona=0;
if (words && (word=LstSub(i++,words)) && StrCmp(word," "))
"%s",word;
d=JIFFY_FREQ*music.note_len/music.tempo;
on_jiffies =d*music.stacatto_factor;
off_jiffies =d*(1.0-music.stacatto_factor);
timeout_val+=on_jiffies;
timeout_val2=timeout_val+off_jiffies;
if (!music.mute)
Snd(ona);
SleepUntil(timeout_val);
music.tM_correction+=on_jiffies-ToI64(on_jiffies);
if (!music.mute && !tie)
Snd;
SleepUntil(timeout_val2);
music.tM_correction+=off_jiffies-ToI64(off_jiffies);
music.play_note_num++;
}
}
U0 MusicSettingsRst()
{
music.play_note_num=0;
music.stacatto_factor=0.9;
music.tempo=2.5;
music.octave=4;
music.note_len=1.0;
music.meter_top=4;
music.meter_bottom=4;
SndRst;
PUSHFD
CLI
if (mp_cnt>1)
while (LBts(&sys_semas[SEMA_TMBEAT],0))
PAUSE
music.last_tM=tM;
music.last_Beat=0.0;
LBtr(&sys_semas[SEMA_TMBEAT],0);
POPFD
}
MusicSettingsRst;
U0 CurSongTask()
{
Fs->task_end_cb=&SndTaskEndCB;
while (TRUE)
Play(music.cur_song);
}
#help_index "Snd"
#define SE_NOISE 0
#define SE_SWEEP 1
class CSoundEffectFrame
{
I32 type;
I8 ona1,ona2;
F64 duration;
};
U0 SoundEffectEndTaskCB()
{
Free(FramePtr("CSoundEffectFrame"));
music.mute--;
SndTaskEndCB;
}
U0 SoundEffectTask(CSoundEffectFrame *ns)
{
I64 i,ona;
F64 t0=tS,t,timeout=t0+ns->duration;
FramePtrAdd("CSoundEffectFrame",ns);
Fs->task_end_cb=&SoundEffectEndTaskCB;
switch (ns->type) {
case SE_NOISE:
i=MaxI64(ns->ona2-ns->ona1,1);
while (tS<timeout) {
ona=RandU16%i+ns->ona1;
Snd(ona);
t=Clamp(3000.0/Ona2Freq(ona),1.0,50.0);
if (t+tS>timeout)
t=timeout-tS;
Sleep(t);
}
break;
case SE_SWEEP:
while (tS<timeout) {
t=(tS-t0)/ns->duration;
ona=(1.0-t)*ns->ona1+t*ns->ona2;
Snd(ona);
t=Clamp(3000.0/Ona2Freq(ona),1.0,50.0);
if (t+tS>timeout)
t=timeout-tS;
Sleep(t);
}
break;
}
}
public CTask *Noise(I64 mS,F64 min_ona,F64 max_ona)
{//Make white noise for given number of mS.
CSoundEffectFrame *ns;
if (mS>0) {
ns=MAlloc(sizeof(CSoundEffectFrame));
ns->type=SE_NOISE;
ns->duration=mS/1000.0;
ns->ona1=min_ona;
ns->ona2=max_ona;
music.mute++;
return Spawn(&SoundEffectTask,ns,"Noise",,Fs);
} else
return NULL;
}
public CTask *Sweep(I64 mS,F64 ona1,F64 ona2)
{//Sweep through freq range in given number of mS.
CSoundEffectFrame *ns;
if (mS>0) {
ns=MAlloc(sizeof(CSoundEffectFrame));
ns->type=SE_SWEEP;
ns->duration=mS/1000.0;
ns->ona1=ona1;
ns->ona2=ona2;
music.mute++;
return Spawn(&SoundEffectTask,ns,"Noise",,Fs);
} else
return NULL;
}

58
Adam/Gr/GrMV.HC

@ -0,0 +1,58 @@
#help_index "Graphics/Device Contexts;Graphics/GR Files"
#define MV_FILE_MAX 0x007FF000
public I64 GR2MV(U8 *print_fmt="VID%03d.MV",
U8 *files_find_mask,U8 *fu_flags=NULL)
{/*Merge GR lst to MV file.
"+d" will delete GR list files.
*/
I64 fuf_flags=0,file_num=0,size;
CDirEntry *tmpde,*tmpde1;
U8 *base,*dst,*src,*st;
CDC *dc,*dc_base=DCNew(GR_WIDTH,GR_HEIGHT);
CDate cdt;
Bool old_silent;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+f+F");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
tmpde=tmpde1=FilesFind(files_find_mask,fuf_flags&FUG_FILES_FIND);
if (progress1_max=LinkedLstCnt(tmpde1)) {
dst=base=MAlloc(MV_FILE_MAX);
while (tmpde) {
dc=GRRead(tmpde->full_name);
GrBlot(dc_base,dc->x0,dc->y0,dc);
if (dst+GR_FILE_MAX>base+MV_FILE_MAX) {
st=MStrPrint(print_fmt,file_num++);
FileWrite(st,base,dst-base);
Free(st);
dst=base;
cdt=dc->cdt;
dc=DCCopy(dc_base);
dc->cdt=cdt;
}
src=DCSave(dc,&size);
DCDel(dc);
MemCpy(dst,src,size);
dst+=size;
Free(src);
if (fuf_flags&FUF_DEL) {
old_silent=Silent;
Del(tmpde->full_name);
Silent(old_silent);
}
progress1++;
tmpde=tmpde->next;
}
if (dst>base) {
st=MStrPrint(print_fmt,file_num++);
FileWrite(st,base,dst-base);
Free(st);
}
Free(base);
}
progress1=progress1_max=0;
DirTreeDel(tmpde1);
DCDel(dc_base);
return file_num;
}

96
Adam/Gr/ScrnCast.HC

@ -0,0 +1,96 @@
#help_index "ScrnCast;Graphics/Device Contexts;Graphics/GR Files"
#define MV_FILE_MAX 0x007FF000
public I64 GR2MV(U8 *print_fmt="VID%03d.MV",
U8 *files_find_mask,U8 *fu_flags=NULL)
{/*Merge GR lst to MV file.
"+d" will delete GR list files.
*/
I64 fuf_flags=0,file_num=0,size;
CDirEntry *tmpde,*tmpde1;
U8 *base,*dst,*src,*st;
CDC *dc,*dc_base=DCNew(GR_WIDTH,GR_HEIGHT);
CDate cdt;
Bool old_silent;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+f+F");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
tmpde=tmpde1=FilesFind(files_find_mask,fuf_flags&FUG_FILES_FIND);
if (progress1_max=LinkedLstCnt(tmpde1)) {
dst=base=MAlloc(MV_FILE_MAX);
while (tmpde) {
dc=GRRead(tmpde->full_name);
GrBlot(dc_base,dc->x0,dc->y0,dc);
if (dst+GR_FILE_MAX>base+MV_FILE_MAX) {
st=MStrPrint(print_fmt,file_num++);
FileWrite(st,base,dst-base);
Free(st);
dst=base;
cdt=dc->cdt;
dc=DCCopy(dc_base);
dc->cdt=cdt;
}
src=DCSave(dc,&size);
DCDel(dc);
MemCpy(dst,src,size);
dst+=size;
Free(src);
if (fuf_flags&FUF_DEL) {
old_silent=Silent;
Del(tmpde->full_name);
Silent(old_silent);
}
progress1++;
tmpde=tmpde->next;
}
if (dst>base) {
st=MStrPrint(print_fmt,file_num++);
FileWrite(st,base,dst-base);
Free(st);
}
Free(base);
}
progress1=progress1_max=0;
DirTreeDel(tmpde1);
DCDel(dc_base);
return file_num;
}
#help_index "ScrnCast;Snd/AU Files"
public U0 SndShift(CSndData *head,F64 dt=0)
{//Shift CSndData in time.
CSndData *tmpsd,*tmpsd1;
if (dt) {
tmpsd=head->next;
while (tmpsd!=head) {
tmpsd1=tmpsd->next;
tmpsd->tS-=dt;
if (tmpsd->tS<tmpsd->last->tS) {
QueRem(tmpsd);
Free(tmpsd);
}
tmpsd=tmpsd1;
}
}
}
public I64 AUWrite(U8 *filename,CSndData *head,CDate *t0_now,F64 t0_tS)
{//Write AU file.
CSndData *tmpsd;
CAUData *base,*dst;
I64 size=(1+QueCnt(head))*sizeof(CAUData);
U8 *st=ExtDft(filename,"AU");
base=dst=MAlloc(size);
tmpsd=head;
do {
dst->cdt=t0_now(I64)+ToI64(CDATE_FREQ*(tmpsd->tS-t0_tS));
dst->ona=tmpsd->ona;
dst++;
tmpsd=tmpsd->next;
} while (tmpsd!=head);
FileWrite(st,base,dst(U8 *)-base(U8 *));
Free(base);
Free(st);
return size;
}

BIN
Compiler/Compiler.BIN

Binary file not shown.

2
Compiler/CompilerB.HH

@ -21,6 +21,7 @@ extern U0 StreamDir();
public extern I64 StreamExePrint(U8 *fmt,...);
public extern U0 StreamPrint(U8 *fmt,...);
public extern Bool Trace(Bool val=ON);
#help_index "Compiler/Lex"
#help_file "::/Doc/Lex"
extern U0 ClassMemberLstDel(CHashClass *c);
@ -71,7 +72,6 @@ public extern U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,
I64 *_jmp_dst=NULL,Bool just_ins=FALSE);
public extern I64 Un(U8 *rip,I64 cnt=0x80,I64 seg_size=64);
extern CUAsmGlbls uasm;
#help_index "Hash/System"
public extern I64 HashEntrySize(CHashSrcSym *tmph);
public extern I64 HashEntrySize2(CHashSrcSym *tmph);

17
Demo/AcctExample/AlienProject/AlienMain.HC

@ -0,0 +1,17 @@
Cd(__DIR__);;
#include "AlienWorkingDir"
U0 AlienGame()
{
"This is our alien game.\n";
PressAKey;
ShowWorkingDir;
}
AlienGame;

BIN
Demo/AcctExample/AlienProject/AlienWorkingDir.HC

Binary file not shown.

90
Demo/AcctExample/LightTable.HC

@ -0,0 +1,90 @@
#define PTS_NUM 1024
U0 LightTable()
{
I64 msg_code,i,x1,y1,x2,y2,arg1,arg2;
CDC *dc=DCAlias;
CD3I32 *c=MAlloc(PTS_NUM*sizeof(CD3I32));
MenuPush(
"File {"
" Restart(,'\n');"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Edit {"
" Fill(,CH_SPACE);"
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-
WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU;
Fs->text_attr=BLACK<<4+WHITE; //Current $LK,"CTask",A="MN:CTask"$ is Fs segment register.
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
try {
while (TRUE) {
msg_code=GetMsg(&arg1,&arg2,
1<<MSG_KEY_DOWN+1<<MSG_MS_L_DOWN+1<<MSG_MS_R_UP);
lt_restart:
switch (msg_code) {
case MSG_MS_R_UP:
x1=arg1; y1=arg2;
x2=arg1; y2=arg2;
dc->color=ROP_XOR+LTRED^TRANSPARENT;
do {
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP+1<<MSG_MS_MOVE);
GrLine3(dc,x1,y1,0,x2,y2,0);
x2=arg1; y2=arg2;
} while (msg_code!=MSG_MS_L_UP);
GrLine3(dc,x1,y1,0,x2,y2,0);
break;
case MSG_MS_L_DOWN:
i=0;
dc->color=ROP_XOR+WHITE^TRANSPARENT;
do {
c[i].x=arg1; c[i].y=arg2; c[i].z=0;
Gr2BSpline(dc,c,i+1);
msg_code=GetMsg(&arg1,&arg2,
1<<MSG_KEY_DOWN+1<<MSG_MS_L_UP+1<<MSG_MS_MOVE+1<<MSG_MS_R_UP);
Gr2BSpline(dc,c,i+1);
if (msg_code==MSG_KEY_DOWN)
goto lt_restart;
else if (msg_code==MSG_MS_L_UP) {
Noise(100,30,50);
i++;
}
} while (i<PTS_NUM-1 && msg_code!=MSG_MS_R_UP);
Gr2BSpline(dc,c,i);
break;
case MSG_KEY_DOWN:
switch (arg1) {
case CH_SPACE:
GrFloodFill(dc,ms.pos.x-Fs->pix_left,ms.pos.y-Fs->pix_top);
break;
case '\n':
DCFill;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto lt_done;
}
break;
}
}
lt_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
DCFill;
Free(c);
DCDel(dc);
SettingsPop;
MenuPop;
}
LightTable;

6
Demo/AcctExample/PersonalNotes.DD

@ -466,6 +466,10 @@ Zinger $HC,"<center><img src=\"http://media.shopwell.com/gladson/00041300000031
Dianna Throne $HC,"<center><img src=\"http://i.imgur.com/RtcK6iX.jpg%EF%BB%BF\" width=\"640\" height=\"746\" alt=\"\"></center>"$
170310 Terry $HC,"<center><img src=\"http://www.templeos.org/images/170310TerryADavis.jpg\" width=\"640\" height=\"640\" alt=\"\"></center>"$
$TX,"Linus Torvalds (Dec 28, 1969)",HTML="https://en.wikipedia.org/wiki/Linus_Torvalds"$
$TX,"John Carmack (Aug 20, 1970)",HTML="https://en.wikipedia.org/wiki/John_Carmack"$
$TX,"Terry A. Davis (Dec 15, 1969)",HTML="https://motherboard.vice.com/en_us/article/gods-lonely-programmer"$
$TX,"SimStructure",HTML="http://www.templeos.org/files/SimStrSetUp.zip"$
$TX,"ASU_Transcripts",HTML="http://www.templeos.org/files/ASU_Transcripts.pdf"$ $TX,"ASU Course Catalog (See page 261)",HTML="https://catalog.asu.edu/files/shared/archives/1994-1996/general/UG1994-1996.pdf/1994-1996-UG-241-267.pdf"$
$TX,"Dr. David Pheanis",HTML="https://webapp4.asu.edu/directory/person/77201"$ $TX,"Dr. Konstantinos S. Tsakalis",HTML="http://ecee.engineering.asu.edu/directory/tenured-and-tenure-track-faculty/kostantinos-s-tsakalis"$ $TX,"Dr. Walter Higgins",HTML="https://webapp4.asu.edu/directory/directorysearch?cn=Walter+Higgins"$
@ -473,6 +477,8 @@ $TX,"Peter Gadwa",HTML="http://www.wired.com/magazine/2010/11/mf_ticketmaster/al
$TX,"Tom Foley",HTML="http://web.gccaz.edu/~tfoley/perspage.html"$
$TX,"Graphic Technologies",HTML="https://web.archive.org/web/20020811060541/http://www.graphic-technologies.com/"$ $TX,"Lexmark vs Static Control",HTML="https://en.wikipedia.org/wiki/Lexmark_International,_Inc._v._Static_Control_Components,_Inc."$
$TX,"Stephen Davis",HTML="https://photos.google.com/share/AF1QipM4HI3mb_9qe8wDQ--nRfjIzOKyGG8heqWH-tbGBIIoxChWe4GeBegNzgHRy4Z1Qw?key=eGR0R0tyZG5tenRWd0tDN2RHRFRNTmI4NXdhc25B"$
3qEeEGCAsBABAqFDBeE2G33qEeEGCAsBABAqFDBeE2G33qCsBDBDq2G3s2G3F2G3FqAet2G32G3AEDAqF3qCsBDBDq2G3s2G3F2G3FqAet2G32G3AEDAqF

2
Demo/AcctExample/Registry.HC

@ -62,7 +62,7 @@ $ID,-2$$TR,"Titanium"$
$ID,2$I64 best_score=16469;
$ID,-2$$TR,"TOSRegen"$
$ID,2$progress1_tf=0.000;progress2_tf=0.000;
progress3_tf=0.000;progress4_tf=196.886;
progress3_tf=0.000;progress4_tf=196.786;
$ID,-2$$TR,"TempleTetris"$
$ID,2$I64 hiscore=1000;
$ID,-2$$ID,-2$$TR,"Once"$

BIN
Demo/AcctExample/TOS/TOSTheme.HC

Binary file not shown.

2029
Demo/WebLogDemo/access_170605.log

File diff suppressed because it is too large Load Diff

1649
Demo/WebLogDemo/access_170606.log

File diff suppressed because it is too large Load Diff

3169
Demo/WebLogDemo/access_170622.log

File diff suppressed because it is too large Load Diff

2
Doc/ChgLog.DD

@ -2,7 +2,7 @@ $WW,1$$FG,5$$TX+CX,"Change Log"$$FG$
Use $LK,"R",A="MN:R"$() to rename if I change a label.
$IV,1$----03/14/17 01:47:41----$IV,0$
$IV,1$----03/14/17 19:57:06----$IV,0$
$IV,1$----03/14/17 00:14:39----$IV,0$
* $BK,1$TempleOS version 5.03 Released$BK,0$

26
Doc/NewASCII.DD

@ -0,0 +1,26 @@
$WW,1$$FG,5$$TX+CX,"New ASCII"$$FG$
We want to use one set for ASCII, ScanCodes and ScreenCodes.
0 -63 :
64 -127 : SHIFT
128-191 : CTRL
192-256 : CTRL+SHIFT
No more ALT key in TempleOS.
CTRL-LEFT/RIGHT is already begin/end line.
CTRL-UP/DOWN is already top/bottom of document.
What about function keys?
We will use reduced keyboard, probably.
God says...
$FG,2$clearest bade domine chance none quoth privily subjection possessor abolished$FG,1$

24
Doc/Reliability.DD

@ -0,0 +1,24 @@
$WW,1$$FG,5$$TX+CX,"RedSea Reliability"$$FG$
TempleOS is like the 1040EZ tax form compared to the full 1040 form. Obviously, it is simpler. If you allow mission creep, pretty soon the 1040EZ looks just like the 1040 and the messed-up 1040EZ has no purpose.
The Commodore 64 had a file system that was simple enough for peers in my generation to enjoy the thrill of knowing exactly what is going on at the hardware level and writing fun projects to access it.
My primary design criteria is simplicity. If it is simple enough for only 100,000 people to learn, lets try to make it simpler so that 1 million can learn it.
Obviously, we don't do bad block tables, or redundant FATs.
We use the simplest possible technique, a contiguous-file-only allocation bitmap, not $LK,"Block Chains",A="FI:::/Doc/BlkChain.DD"$ or FAT tables.
You can be a good toy or you can be a good professional tool, but not both. TempleOS's file manager will start too slowly once a few thousand files exist because the file manager makes a list of all files on start-up.
Do not have more than a few thousand files or the file manager will not function.
You are encouraged to keep your entire drive limited to, maybe, 100 Meg of files because you are suppoosed to operate as a kayak instead of a Titanic. If you do this, backing-up will be only a minute or so and you should do it at least once a day.
Third party software should be run from ISO files or CD/DVDs directly, without installing to hard drive.
Multimedia graphics and sound is, basically, forbidden. If you ignore this, all hell will break loose because memory will fragment with large files and the original vision of kayak hard-drive back-ups won't work.
$FG,8$
* "Commodore 64" is a trademark owned by Polabe Holding NV.

BIN
Downloads/Linux/TOSZ

Binary file not shown.

1084
Downloads/Linux/TOSZ.CPP

File diff suppressed because it is too large Load Diff

6
Downloads/Linux/gw

@ -0,0 +1,6 @@
#!/bin/bash
#This prints random words from the Linux dictionary.
echo "$(shuf -n 32 /usr/share/dict/words --random-source=/dev/urandom | tr '\n' ' ')"

7
Downloads/Linux/make_tosz

@ -0,0 +1,7 @@
#!/bin/bash
#Make TOSZ
echo Make TOSZ
cc TOSZ.CPP -o TOSZ
chmod 777 TOSZ

23
Downloads/ReadMe.TXT

@ -0,0 +1,23 @@
TempleOS
You can't do anything until you burn a TempleOS CD/DVD from the ISO file
and boot it, or you aim your virtual machine's CD/DVD at the ISO file
and boot.
TempleOS is 64-bit and will not run on 32-bit hardware.
TempleOS requires 512 Meg of RAM minimum and can have 256 Gig of RAM or more!
TempleOS files are compressed with a nonstandard LZW format and the source
code can only be compiled by the TempleOS compiler because it is HolyC, a
nonstandard C/C++ dialect. You must boot TempleOS. Then, you can compile it
because it is 100% open source and all source present on the distro.
If attempting to run on native hardware, TempleOS may require you to enter I/O
port addresses for the CD/DVD drive and the hard drive. In Windows, you can
find I/O port info in the Accessories/System Tools/System Info/Hardware
Resources/I/O ports. Look for and write down "IDE", "ATA" or "SATA" port numbers.
In Linux, use "lspci -v". Then, boot the TempleOS CD and try all combinations.
(Sorry, it's too difficult for TempleOS to figure-out port numbers, automatically.)

151
Kernel/BlkDev/DskCluster.HC

@ -0,0 +1,151 @@
I64 ClusterNumNext(CDrv *dv,I64 c,I64 cnt=1)
{//Return next cnt'th cluster in chain.
Bool unlock;
DrvChk(dv);
if (cnt<=0) return c;
try {
unlock=DrvLock(dv);
switch (dv->fs_type) {
case FSt_ISO9660:
case FSt_REDSEA:
c+=cnt;
break;
case FSt_FAT32:
while (cnt-->0 && 0<c<0x0FFFFFF8) {
DrvFATBlkSet(dv,c);
c=dv->cur_fat_blk[c & (BLK_SIZE/4-1)];
}
if (!(0<c<0x0FFFFFF8))
c=INVALID_CLUSTER;
break;
default:
throw('Drv');
}
if (unlock)
DrvUnlock(dv);
} catch
if (unlock)
DrvUnlock(dv);
return c;
}
I64 Cluster2Blk(CDrv *dv,I64 c)
{//Drv cluster num to blk num.
DrvChk(dv);
switch (dv->fs_type) {
case FSt_REDSEA:
return c;
case FSt_ISO9660:
case FSt_FAT32:
return dv->data_area+c*dv->spc;
default:
throw('Drv');
}
}
I64 RClustersBlks(CDrv *dv,U8 *buf,I64 c,I64 blks)
{//Accepts blk count, so padding on last cluster is not read.
I64 i;
Bool unlock;
DrvChk(dv);
if (blks<=0) return c;
try {
unlock=DrvLock(dv);
switch (dv->fs_type) {
case FSt_ISO9660:
RBlks(dv,buf,dv->data_area+c*dv->spc,blks);
c+=(blks+dv->spc-1)/dv->spc;
break;
case FSt_REDSEA:
RBlks(dv,buf,c,blks);
c+=blks;
break;
case FSt_FAT32:
while (blks && 0<c<0x0FFFFFF8) {
i=blks;
if (i>dv->spc)
i=dv->spc;
RBlks(dv,buf,dv->data_area+c*dv->spc,i);
buf+=i<<BLK_SIZE_BITS;
c=ClusterNumNext(dv,c,1);
blks-=i;
}
if (blks)
throw('Drv');
break;
default:
throw('Drv');
}
if (unlock)
DrvUnlock(dv);
} catch
if (unlock)
DrvUnlock(dv);
return c;
}
I64 RClusters(CDrv *dv,U8 *buf,I64 c,I64 cnt)
{//Read cluster cnt from drv to buf.
return RClustersBlks(dv,buf,c,cnt*dv->spc);
}
I64 WClustersBlks(CDrv *dv,U8 *buf,I64 c,I64 blks)
{//Accepts blk count, so padding on last cluster is not written.
I64 i;
Bool unlock;
DrvChk(dv);
if (blks<=0) return c;
try {
unlock=DrvLock(dv);
switch (dv->fs_type) {
case FSt_REDSEA:
WBlks(dv,buf,c,blks);
c=0;
break;
case FSt_FAT32:
while (blks) {
if (!(0<c<0x0FFFFFF8))
throw('Drv');
i=blks;
if (i>dv->spc)
i=dv->spc;
WBlks(dv,buf,dv->data_area+c*dv->spc,i);
buf+=i<<BLK_SIZE_BITS;
c=ClusterNumNext(dv,c);
blks-=i;
}
break;
default:
throw('Drv');
}
if (unlock)
DrvUnlock(dv);
} catch
if (unlock)
DrvUnlock(dv);
return c;
}
I64 WClusters(CDrv *dv,U8 *buf,I64 c,I64 cnt)
{//Write cluster cnt from buf to drv.
return WClustersBlks(dv,buf,c,cnt*dv->spc);
}
I64 ClustersAlloc(CDrv *dv,I64 c=0,I64 cnt=1,Bool contiguous=FALSE)
{//Alloc cluster cnt into chain.
//c=0 means first cluster in chain
DrvChk(dv);
if (cnt<=0) return c;
switch (dv->fs_type) {
case FSt_REDSEA:
return RedSeaAllocClusters(dv,cnt);
case FSt_FAT32:
if (contiguous) {
if (c) throw('File');
return FAT32AllocContiguousClusters(dv,cnt);
} else
return FAT32AllocClusters(dv,c,cnt);
default:
throw('Drv');
}
}

238
Kernel/KMain.HC

@ -0,0 +1,238 @@
U0 SysGlblsInit()
{
I64 i,j;
CRAXRBCRCXRDX ee;
CPUId(0x1,&ee);
sys_cache_line_width=ee.rbx.u8[1]*8;
sys_focus_task=Fs;
QueInit(&sys_macro_head);
blkdev.dft_iso_filename =AStrNew(DFT_ISO_FILENAME);
blkdev.dft_iso_c_filename =AStrNew(DFT_ISO_C_FILENAME);
blkdev.tmp_filename =AStrNew("~/Tmp.DD.Z");
blkdev.dvd_boot_is_good=TRUE;
#exe {
if (!kernel_cfg->mount_ide_auto_hd_let)
kernel_cfg->mount_ide_auto_hd_let='C';
if (!kernel_cfg->mount_ide_auto_cd_let)
kernel_cfg->mount_ide_auto_cd_let='T';
StreamPrint("blkdev.first_hd_drv_let=%d;",
kernel_cfg->mount_ide_auto_hd_let);
StreamPrint("blkdev.first_dvd_drv_let=%d;",
kernel_cfg->mount_ide_auto_cd_let);
}
DbgMode(ON);
rev_bits_table=CAlloc(256);
set_bits_table=CAlloc(256);
for (i=0;i<256;i++)
for (j=0;j<8;j++) {
if (Bt(&i,7-j)) LBts(rev_bits_table+i,j);
if (Bt(&i,j)) set_bits_table[i]++;
}
ext=CAlloc(EXT_EXTS_NUM*sizeof(U8 *));
fp_getstr2=&SysGetStr2;
KeyDevInit;