TempleOSCDV5.01.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:48:15 +02:00
1 parent f6eacf7744
commit 320c7ee98a
219 files changed
+5211 -4853

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
Cd(__DIR__);;
#include "TOSExt"
#include "TOSCfg"
#include "TOSMisc"
#include "TOSToHtml"
#include "TOSDistro"
#include "TOSBlog"
#include "TOSNIST"
#include "TOSHolySpirit"
#include "TOSIns"
Cd("..");;
+126
View File
@@ -0,0 +1,126 @@
#help_index "Misc/Blog"
public U8 *BlogLocalDir(CDate cdt=0)
{//MAlloc dirname of blog for date.
static U8 dir[STR_LEN];
CDateStruct ds;
if (!cdt) cdt=Now+local_time_offset;
Date2Struct(&ds,cdt);
StrPrint(dir,BLOG_LOCAL_BASE "/%d%Z",ds.year,ds.mon-1,"ST_MONTHS");
if (!FileFind(dir,,FUF_JUST_DIRS))
MkDir(dir);
return dir;
}
public U8 *BlogLocalFile(CDate cdt=0)
{//MAlloc filename of blog for date.
static U8 file[STR_LEN];
CDateStruct ds;
if (!cdt) cdt=Now+local_time_offset;
Date2Struct(&ds,cdt);
StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
BlogLocalDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
return file;
}
public U8 *BlogWebDir(CDate cdt=0)
{//MAlloc D:/Wb/dirname of blog for date.
static U8 dir[STR_LEN];
CDateStruct ds;
if (!cdt) cdt=Now+local_time_offset;
Date2Struct(&ds,cdt);
StrPrint(dir,BLOG_WEB_BASE "/%d%Z",
ds.year,ds.mon-1,"ST_MONTHS");
return dir;
}
public U8 *BlogWebFile(CDate cdt=0)
{//MAlloc D:/Wb/filename of blog for date.
static U8 file[STR_LEN];
CDateStruct ds;
if (!cdt) cdt=Now+local_time_offset;
Date2Struct(&ds,cdt);
StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
BlogWebDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
return file;
}
public U8 *FileNameNumNext(U8 *files_find_mask,U8 *fmt)
{//Cnt files in a mask. Create next filename.
CDirEntry *tmpde=FilesFind(files_find_mask);
U8 *res=MStrPrint(fmt,FileCnt(tmpde));
DirTreeDel(tmpde);
return res;
}
public U0 BlogDCImgWrite(CDC *dc,CDate cdt=0)
{//Add dc to blog as BMP file.
U8 file_mask[STR_LEN],file_name[STR_LEN],*st1,*st2;
if (!cdt) cdt=Now+local_time_offset;
StrPrint(file_mask,"%s/Img*",BlogLocalDir(cdt));
StrPrint(file_name,"%s/Img%%03d.BMP",BlogLocalDir(cdt));
st1=FileNameNumNext(file_mask,file_name);
st2=MStrPrint("http://www.templeos.org/Wb%s",st1+2);
BMPWrite(st1,dc);
Free(st1);
"$$HC,\"<img src=\\\"%s\\\" width=\\\"%d\\\" "
"height=\\\"%d\\\" alt=\\\"\\\">\"$$\n",st2,dc->width,dc->height;
Free(st2);
}
public U0 BlogScrnShot()
{//Add scrn shot to blog as BMP file.
Bool old_cursor=DocCursor,old_silent;
CDC *dc1,*dc2;
U8 *old_fp_draw_ms=gr.fp_draw_ms;
gr.fp_draw_ms=NULL;
Refresh(2);
dc1=DCScrnCapture;
dc2=DCExt(dc1,0,FONT_HEIGHT,GR_WIDTH-1,GR_HEIGHT-1);
BlogDCImgWrite(dc2);
gr.fp_draw_ms=old_fp_draw_ms;
DCDel(dc1);
DCDel(dc2);
DocCursor(old_cursor);
old_silent=Silent;
FreshenBlog;
Silent(old_silent);
}
public U0 FreshenBlog()
{//Regen html files for D:/Home/Web.
MkDir("D:/Wb");
MkDir("D:/Wb/Home");
MkDir("D:/Wb/Home/Web");
MkDir("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS);
MkDir("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS "/BlogDir");
FreshenWebDir("/Home/Web");
FreshenWebDir("/Home/Web/" INS_REG_PERSONAL_INITIALS);
FreshenWebDir(BlogLocalDir+2);
Drv('C');
}
public U0 Blog(Bool god_misc2=FALSE)
{//Make entry in blog.
if (!FileFind(BlogLocalFile,,FUF_JUST_FILES))
Copy("~/Web/" INS_REG_PERSONAL_INITIALS "/DailyBlogHeader.DD.Z",
BlogLocalFile);
AutoComplete;
WinBorder;
WinMax;
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN|SCF_CTRL);
if (god_misc2)
Msg(MSG_KEY_DOWN_UP,0,SC_F7|SCF_SHIFT|SCF_ALT);
else {
Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
Msg(MSG_KEY_DOWN_UP,'\n',0);
}
if (Ed(BlogLocalFile,EDF_WAS_WRITE)) {
DocOpt(BlogLocalFile,"-r");
Copy(BlogLocalFile,"::" DAILY_BASE ".DD.Z");
Copy(BlogLocalFile,"D:" DAILY_BASE ".DD.Z");
Copy(BlogLocalFile,"D:/Wb" DAILY_BASE ".DD.Z");
TOSWebFile("D:/Wb" DAILY_BASE ".DD.Z");
}
}
+69
View File
@@ -0,0 +1,69 @@
#help_index "Misc/TOS/Cfg"
#define PERSONAL_WEB "http:/" "/www.templeos.org/Wb"
#define BLOG_BASE "/Home/Web/"\
INS_REG_PERSONAL_INITIALS "/BlogDir"
#define DAILY_BASE "/Home/Web/"\
INS_REG_PERSONAL_INITIALS "/DailyBlog"
#define BLOG_LOCAL_BASE "::" BLOG_BASE
#define BLOG_WEB_BASE PERSONAL_WEB BLOG_BASE
#define SLOP BLK_SIZE
U0 TOSDbgDistro1()
{
CBinFile *bfh=mem_boot_base-sizeof(CBinFile);
bfh(I64)+=bfh->file_size-1;
DefinePrint("TOS_DBG_DISTRO","0x%X",
CeilI64(SYS_KERNEL_END+SLOP,BLK_SIZE));
DefinePrint("TOS_DBG_DISTRO_END", "0x%X",FloorI64(
(BOOT_RAM_LIMIT-(BOOT_STK_SIZE+DVD_BOOT_LOADER_SIZE))>>4<<4-
(bfh(I64)-SYS_KERNEL_END)-SLOP,BLK_SIZE));
DefinePrint("CFG_DBG_DISTRO_FILE","\"/Tmp/DbgDistro.BIN.Z\"");
} TOSDbgDistro1;
U0 TOSDbgDistro2()
{
DefinePrint("CFG_DBG_DISTRO","\"a0x%X\n0x%X\n\"",TOS_DBG_DISTRO,
(TOS_DBG_DISTRO_END-TOS_DBG_DISTRO)/BLK_SIZE);
DefinePrint("CFG_DBG_DISTRO_START","\"0x%X\"",TOS_DBG_DISTRO);
} TOSDbgDistro2;
U0 TOSInit()
{
switch (INS_REG_MACHINE_NUM) {
case 1: //TAD Native Machine
DefinePrint("CFG_RAM_DRVS",
"\"B\nScale2Mem(2048,0x100000,4*1024*1024*1024)\n\"");
DefinePrint("CFG_HARD_DRVS","\"C\ns0xFE00\n0xFE10\n0\"");
DefinePrint("CFG_DVD_DRVS","\"Ts0x1F0\n1\"");
DefinePrint("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
DefinePrint("TOS_HDS","\"CD\"");
DefinePrint("TOS_MASTER_BOOT_DRVS","\"C\"");
break;
default:
DefinePrint("CFG_RAM_DRVS",
"\"B\nScale2Mem(2048,0x100000,4*1024*1024*1024)\n\"");
DefinePrint("CFG_HARD_DRVS","\"\"");
DefinePrint("CFG_DVD_DRVS","\"\"");
DefinePrint("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
DefinePrint("TOS_HDS","\"CD\"");
DefinePrint("TOS_MASTER_BOOT_DRVS","\"C\"");
}
} TOSInit;
#define TOS_ISO_NAME "B:/TempleOSCD.ISO"
#define TOS_ISO_C_NAME "B:/TempleOSCD.ISO.C"
#define TOS_DISTRO_DIR "B:/Distro"
#define CFG_OPTS "StaffMode\nAutoMountIDE\nCT\n"
#define CFG_DBG_OPTS "StaffMode\nAutoMountIDE\nCT"\
"HeapInit\n130\nMemInit\n131\nVarInit\n132\n\n"
#define CFG_DBGZ_OPTS "StaffMode\nAutoMountIDE\nCT"\
"HeapInit\n0\nMemInit\n0\nVarInit\n0\n\n"
#define TOS_CFG "\n" CFG_RAM_DRVS CFG_DVD_DRVS CFG_HARD_DRVS "\n"\
CFG_DSK_CACHE CFG_OPTS
#define TOS_DVD_CFG "TB\n0x20000\nT \n\n\nStaffMode\nAutoMountIDE\nCT\n"
#define TOS_DVD_DBG_CFG "A" CFG_DBG_DISTRO\
"B\nScale2Mem(2048,0x40000)\n\n\n"\
"NoMP\nTextMode\nDontProbe\nDbgDistro\n"\
"C:" CFG_DBG_DISTRO_FILE "\n"\
CFG_DBG_DISTRO_START "\n\n"
+589
View File
@@ -0,0 +1,589 @@
//The CFG defines are $LK,"~/TOS/TOSCfg.HC",A="FI:::/Demo/AcctExample/TOS/TOSCfg.HC"$.
#help_index "Misc/TOS/Distro"
#define MAKE_STD 1
#define MAKE_STD_RS 0
#define MAKE_ULTRA 1
#define MAKE_ULTRA_RS 0
#define MAKE_SUP1 1
#define MAKE_WEB 1
#define MAKE_BOOKS1 0
#define MAKE_BOOKS2 0
#define MAKE_DBG 0
#define MAKE_STAFF 1
public U8 TOSGetDrv()
{//Pmt for drv let.
I64 res;
"Drive (%s):",TOS_HDS;
res=Let2Let(GetChar);
'\n';
return res;
}
public U0 TOSBootHDIns(U8 drv_let=0)
{//Make Compiler and Kernel. Reinstall Kernel.
drv_let=Let2Let(drv_let);
In(TOS_CFG);
BootHDIns(drv_let);
if (StrOcc(TOS_MASTER_BOOT_DRVS,drv_let))
BootMHDIns(drv_let);
}
public U0 TOSCopyDrv(U8 src,U8 dst)
{//Fmt dst and copy entire drv.
U8 buf_s[STR_LEN],buf_d[STR_LEN];
src=Let2Let(src);
dst=Let2Let(dst);
Fmt(dst,,FALSE,FSt_FAT32);
StrPrint(buf_s,"%c:/",src);
StrPrint(buf_d,"%c:/",dst);
CopyTree(buf_s,buf_d);
DocClear;
Drv(dst);
TOSBootHDIns(dst);
}
public U0 TOSPmtAndCopyDrv()
{//Pmt for drv lets. Then, Fmt dst and copy entire drv.
I64 src,dst;
"$$RED$$\nCopy Src Drive:\n$$FG$$";
src=TOSGetDrv;
"$$RED$$\nCopy Dst Drive:\n$$FG$$";
dst=TOSGetDrv;
TOSCopyDrv(src,dst);
}
U0 DistroSongsPrep(U8 threshold='7')
{
CDoc *doc;
CDocEntry *doc_e;
CDirEntry *tmpde=FilesFind("/Home/Sup1/Sup1Hymns/*.HC*",
FUF_CLUSTER_ORDER),*tmpde1=tmpde;
DelTree("/Apps/Psalmody/Examples");
MkDir("/Apps/Psalmody/Examples");
while (tmpde) {
doc=DocRead(tmpde->full_name);
doc_e=doc->head.next;
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[2]>=threshold)
Copy(tmpde->full_name,"/Apps/Psalmody/Examples");
DocDel(doc);
tmpde=tmpde->next;
}
DirTreeDel(tmpde1);
}
U0 DistroPrep()
{
AOnceFlush; //Don't want in Registry
OnceFlush;
Del("/Home/Demo*");
DelTree("/Home/*Tmp.DD.Z");
if (FileFind("/Home/Sup1/Sup1Hymns"))
DistroSongsPrep;
DelTree("/Tmp");
MkDir("/Tmp");
MkDir("/Tmp/ScrnShots");
Touch("/PersonalMenu.DD.Z","+T");
Touch("/Home/PersonalMenu.DD.Z","+T");
DelTree("/Demo/AcctExample");
CopyTree("/Home","/Demo/AcctExample");
DelTree("/Demo/AcctExample/Budget");
DelTree("/Demo/AcctExample/Private");
DelTree("/Demo/AcctExample/Sup1");
DelTree("/Demo/AcctExample/Books1");
DelTree("/Demo/AcctExample/Books2");
DelTree("/Demo/AcctExample/Web");
Del("/Demo/AcctExample/Test*");
Copy("/Home/Web/index.DD.Z",
"/Demo/ToHtmlToTXTDemo/DemoInPage.DD.Z");
if (FileFind("~/Sup1/Sup1Utils/SortHeaders.HC.Z"))
ExeFile("~/Sup1/Sup1Utils/SortHeaders.HC.Z");
if (FileFind("~/Sup1/Sup1Blog/YouTube.DD.Z"))
Sort("~/Sup1/Sup1Blog/YouTube.DD.Z",,2);
//Once in a while, do ~/Sup1/Sup1Utils/DblSpaceScan.HC.
CursorRem("/*");
DelTree("/Demo/*.BI*");
S2T("/*","+r+S");
DocOpt("/*","+R");
Move(ACD_DEF_FILENAME,ACD_DEF_FILENAME_Z);
}
U0 DbgDistroFilePrep()
{
CBlkDev *bd;
if (!Let2Drv('A',FALSE)) {
In(CFG_DBG_DISTRO "\n");
Mount;
}
bd=Let2BlkDev('A');
Fmt('A',,FALSE,FSt_REDSEA);
MkDir("A:/Compiler");
Copy("C:/Compiler/Compiler.BIN.Z", "A:/Compiler");
Copy("C:/Compiler/OpCodes.DD.Z", "A:/Compiler");
Copy("C:/Compiler/CompilerA.HH.Z", "A:/Compiler");
Copy("C:/Compiler/CompilerB.HH.Z", "A:/Compiler");
MkDir("A:/Kernel");
Copy("C:/Kernel/*.HH*", "A:/Kernel");
CopyTree("C:/Kernel/BlkDev", "A:/Kernel/BlkDev");
Copy("C:/Home/Sup1/Sup1Distro/DbgStartOS.HC.Z","A:/StartOS.HC.Z");
MkDir("A:/Adam");
Copy("C:/Home/Sup1/Sup1Distro/DbgMakeAdam.HC.Z","A:/Adam/MakeAdam.HC.Z");
Copy("C:/Home/Sup1/Sup1Distro/DbgMount.HC.Z","A:/Adam");
Copy("C:/Adam/AExts.HC.Z", "A:/Adam");
Copy("C:/Adam/AMath.HC.Z", "A:/Adam");
Copy("C:/Adam/Training.HC.Z","A:/Adam");
Copy("C:/Adam/AMem.HC.Z", "A:/Adam");
Copy("C:/Adam/TaskRep.HC.Z", "A:/Adam");
FileWrite("C:" CFG_DBG_DISTRO_FILE,
bd->RAM_dsk,(bd->max_blk+1)<<BLK_SIZE_BITS);
}
U0 MakeSymFiles()
{
CDoc *doc;
U8 *st;
DocClear;
DocMax;
HashTablePurge(adam_task->hash_table);
Who;
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,"D:/Wb/Home/Web/SymsAlpha.DD.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
DocClear;
DocMax;
Who("+m");
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,"D:/Wb/Home/Web/SymsAddress.DD.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
DocClear;
}
I64 MakeLineRepFile()
{
U8 *st;
CDoc *doc;
I64 res,official;
CDocEntry *tree_branch,*start_indent,*end_indent;
DocClear;
Drv('C');
DistroPrep;
Cd("C:/");
DelTree("B:/TOS/TOS");
CopyTree("C:/Home","B:/TOS/TOS");
DelTree("C:/Home");
DocMax;
DocClear;
res=LineRep;
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,"B:/TOS/TOS/Web/LineRep.DD.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
DocClear;
official=LineRep("C:/*","-r")+
LineRep("C:/Adam/*")+
LineRep("C:/Compiler/*","-S+$$")+
LineRep("C:/Kernel/*");
DocClear;
CopyTree("B:/TOS/TOS","C:/Home");
DelTree("B:/TOS/TOS");
doc=DocRead("C:/Adam/ADefine.HC.Z");
DocTreeFind(doc,"LineRep",&tree_branch,&start_indent,&end_indent);
DocCut(doc,start_indent->next,end_indent->last);
doc->cur_entry=start_indent->next;
doc->cur_col=0;
DocPrint(doc,"DefinePrint(\"DD_TEMPLEOS_LOC\",\"%,d\");\n",res);
DocPrint(doc,"DefinePrint(\"DD_TEMPLEOS_LOC_OFFICIAL\",\"%,d\");\n",official);
DocWrite(doc);
DocDel(doc);
DefinePrint("DD_TEMPLEOS_LOC","%,d",res);
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","%,d",official);
"Total LOC:%12,d\n\n",res;
return res;
}
U0 StaffDistroPrep()
{
Drv('C');
DistroPrep;
In(TOS_DVD_CFG);
BootDVDIns('C');
Fmt('B',,FALSE,FSt_REDSEA);
DelTree(TOS_DISTRO_DIR);
CopyTree("C:/",TOS_DISTRO_DIR "/");
DelTree(TOS_DISTRO_DIR "/Home/Sup1");
DelTree(TOS_DISTRO_DIR "/Home/Books1");
DelTree(TOS_DISTRO_DIR "/Home/Books2");
Del(TOS_DISTRO_DIR "/" KERNEL_BIN_C);
}
U0 MakeStaffDistro()
{
StaffDistroPrep;
ISO9660ISO(TOS_ISO_NAME,TOS_DISTRO_DIR "/*",,
TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOS_STAFF_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - T.S. Company Internal Distro (%0.1fMB)",
0.1*(10*Size(TOS_ISO_NAME,"+s")/1024/1024));
Drv('C');
}
U0 DbgDistroPrep()
{
Drv('C');
DistroPrep;
DbgDistroFilePrep;
In(TOS_DVD_DBG_CFG);
BootDVDIns('C');
Fmt('B',,FALSE,FSt_REDSEA);
DelTree(TOS_DISTRO_DIR);
CopyTree("C:/",TOS_DISTRO_DIR "/");
DelTree(TOS_DISTRO_DIR "/Home");
MkDir(TOS_DISTRO_DIR "/Home");
Del(TOS_DISTRO_DIR "/" KERNEL_BIN_C);
Del(TOS_DISTRO_DIR BOOT_DIR "/OldMBR.BIN.C");
Del(TOS_DISTRO_DIR BOOT_DIR "/BootMHD2.BIN.C");
}
U0 MakeDbgDistro()
{
DbgDistroPrep;
ISO9660ISO(TOS_ISO_NAME,TOS_DISTRO_DIR "/*",,
TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOS_DBG_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - Debug Distro (%0.1fMB)",
0.1*(10*Size(TOS_ISO_NAME,"+s")/1024/1024));
Drv('C');
}
U0 StdDistroPrep()
{
Drv('C');
DistroPrep;
In(STD_DISTRO_DVD_CFG);
BootDVDIns('C');
Fmt('B',,FALSE,FSt_REDSEA);
DelTree(TOS_DISTRO_DIR);
CopyTree("C:/",TOS_DISTRO_DIR "/");
DelTree(TOS_DISTRO_DIR "/Home");
MkDir(TOS_DISTRO_DIR "/Home");
Del(TOS_DISTRO_DIR "/" KERNEL_BIN_C);
Del(TOS_DISTRO_DIR BOOT_DIR "/OldMBR.BIN.C");
Del(TOS_DISTRO_DIR BOOT_DIR "/BootMHD2.BIN.C");
}
U0 MakeStdDistro()
{
StdDistroPrep;
ISO9660ISO(TOS_ISO_NAME,TOS_DISTRO_DIR "/*",,
TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOSCD_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - Standard Distro (%0.1fMB)",
0.1*(10*Size(TOS_ISO_NAME,"+s")/1024/1024));
Drv('C');
}
U0 MakeStdRedSeaDistro()
{
StdDistroPrep;
RedSeaISO(TOS_ISO_C_NAME,TOS_DISTRO_DIR,TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOSCD_RS_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - Standard RedSea Distro (%0.1fMB)",
0.1*(10*Size(TOS_ISO_C_NAME,"+s")/1024/1024));
Drv('C');
}
U0 UltraDistroPrep()
{
StdDistroPrep;
DelTree(TOS_DISTRO_DIR "/Linux");
Del(TOS_DISTRO_DIR "/" KERNEL_BIN_C);
Del(TOS_DISTRO_DIR "/Adam/AutoComplete/ACDefs.DATA*");
Del(TOS_DISTRO_DIR "/Misc/PCIDevices.DD.Z");
Del(TOS_DISTRO_DIR "/Misc/Bible.TXT.Z");
DelTree(TOS_DISTRO_DIR "/Apps");
MkDir(TOS_DISTRO_DIR "/Apps");
DelTree(TOS_DISTRO_DIR "/Demo");
DelTree(TOS_DISTRO_DIR "/Misc/Tour");
Del(TOS_DISTRO_DIR "/" KERNEL_BIN_C);
Del(TOS_DISTRO_DIR "/Adam/AutoComplete/ACWords.DATA*");
Del(TOS_DISTRO_DIR "/Adam/God/Vocab.DD.Z");
Del(TOS_DISTRO_DIR "/Misc/OSTestSuite.HC.Z");
Copy("C:/Home/Sup1/Sup1Distro/UltraMenu.DD.Z",
TOS_DISTRO_DIR "/PersonalMenu.DD.Z");
Copy("C:/Demo/Games/Talons.HC.Z",
TOS_DISTRO_DIR "/Misc");
}
U0 MakeUltraDistro()
{
UltraDistroPrep;
ISO9660ISO(TOS_ISO_NAME,TOS_DISTRO_DIR "/*",,
TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOS_ULTRA_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - UltraSmall Distro (%0.2fMB)",
0.01*(100*Size(TOS_ISO_NAME,"+s")/1024/1024));
Drv('C');
}
U0 MakeUltraRedSeaDistro()
{
UltraDistroPrep;
RedSeaISO(TOS_ISO_C_NAME,TOS_DISTRO_DIR,TOS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
DefinePrint("DD_TEMPLEOS_ULTRA_RS_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - UltraSmall RedSea Distro (%0.2fMB)",
0.01*(100*Size(TOS_ISO_C_NAME,"+s")/1024/1024));
Drv('C');
}
U0 UpdateISODocDefines()
{
try {
#if MAKE_STD
DefinePrint("DD_TEMPLEOSCD_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - Standard Distro (%0.1fMB)",
0.1*(10*Size("D:/Wb/TempleOSCD.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSCD_K_SIZE",
"%dKB",Size("D:/Wb/TempleOSCD.ISO","+s")/1024);
#endif
#if MAKE_STD_RS
DefinePrint("DD_TEMPLEOSCD_RS_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - Standard RedSea Distro (%0.1fMB)",
0.1*(10*Size("D:/Wb/TempleOSCDRS.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSCD_RS_K_SIZE",
"%dKB",Size("D:/Wb/TempleOSCDRS.ISO","+s")/1024);
#endif
#if MAKE_ULTRA
DefinePrint("DD_TEMPLEOS_ULTRA_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - UltraSmall Distro (%0.2fMB)",
0.01*(100*Size("D:/Wb/TempleOSUltra.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOS_ULTRA_K_SIZE",
"%dKB",Size("D:/Wb/TempleOSUltra.ISO","+s")/1024);
#endif
#if MAKE_ULTRA_RS
DefinePrint("DD_TEMPLEOS_ULTRA_RS_SIZE",
"Download $TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$ - UltraSmall RedSea Distro (%0.2fMB)",
0.01*(100*Size("D:/Wb/TempleOSUltraRS.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOS_ULTRA_RS_K_SIZE",
"%dKB",Size("D:/Wb/TempleOSUltraRS.ISO","+s")/1024);
#endif
} catch
Fs->catch_except=TRUE;
}
UpdateISODocDefines;
I64 tos_progress;
F64 tos_progress_t0;
U0 TOSProgress(U8 *st)
{
U8 buf[STR_LEN];
progress4=tos_progress;
progress3_max=1;
*progress4_desc=0;
progress4_max=13+MAKE_STD+MAKE_STD_RS+MAKE_ULTRA+MAKE_ULTRA_RS+MAKE_SUP1+
MAKE_WEB+MAKE_BOOKS1+MAKE_BOOKS2+MAKE_DBG+MAKE_STAFF;
progress4_t0=tos_progress_t0;
StrPrint(buf,"%d. %s",++progress4,st);
"$$PURPLE$$$$TX+CX,\"%s\"$$$$FG$$\n",buf;
StrCpy(progress3_desc,buf);
tos_progress=progress4;
}
I64 TOSProfanity()
{
I64 res;
if (res=Profanity(,"D:/Wb/*;"
"!*/Misc/PCIDevices.DD*;!*/Misc/Bible.TXT*;"
"!*/Books?/*;!*/Sup1/Sup1Words/*;!*/Sup1/Sup1Blog/Profanity.DD*;"
"!*/Sup1/Sup1Blog/NumBible.TXT*;!*/God/Vocab.DD*")) {
while (PressAKey!=CH_SHIFT_ESC) {
ProgressBarsRst;
if (Profanity(,"C:/Home/*;"
"!*/Misc/PCIDevices.DD*;!*/Misc/Bible.TXT*;"
"!*/Books?/*;!*/Sup1/Sup1Words/*;!*/Sup1/Sup1Blog/Profanity.DD*;"
"!*/Sup1/Sup1Blog/NumBible.TXT*;!*/God/Vocab.DD*")) {
"\n\nEdit profanity and press $FG,2$ESC$FG$.\n";
if (!View)
break;
DocBottom;
} else
break;
}
}
return res;
}
U0 TOSRegen3()
{
I64 slash_home=0;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
tos_progress=-1;
tos_progress_t0=tS;
RegExe("TempleOS/TOSRegen");
TOSProgress("ChkDsk All");
AutoComplete;
WinBorder;
WinMax;
ChkAll;
TOSProgress("Make LineRep");
MakeLineRepFile;
TOSProgress("Copy C to D");
TOSCopyDrv('C','D');
TOSProgress("Del D:/Wb");
DelTree ("D:/Wb");
TOSProgress("Copy C to D:/Wb");
CopyTree("C:/","D:/Wb");
DocClear;
#if MAKE_STD
TOSProgress("Make Standard Distro ISO");
MakeStdDistro;
DocClear;
Move(TOS_ISO_NAME,"D:/Wb/TempleOSCD.ISO");
#endif
#if MAKE_STD_RS
TOSProgress("Make Standard RedSea Distro ISO");
MakeStdRedSeaDistro;
DocClear;
Move(TOS_ISO_C_NAME,"D:/Wb/TempleOSCDRS.ISO");
#endif
#if MAKE_ULTRA
TOSProgress("Make Ultra Distro ISO");
MakeUltraDistro;
DocClear;
Move(TOS_ISO_NAME,"D:/Wb/TempleOSUltra.ISO");
#endif
#if MAKE_ULTRA_RS
TOSProgress("Make Ultra RedSea Distro ISO");
MakeUltraRedSeaDistro;
DocClear;
Move(TOS_ISO_C_NAME,"D:/Wb/TempleOSUltraRS.ISO");
#endif
#if MAKE_DBG
TOSProgress("Make Dbg Distro ISO");
MakeDbgDistro;
DocClear;
Move(TOS_ISO_NAME,"D:/Wb/TempleOSDbg.ISO");
#endif
#if MAKE_STAFF
TOSProgress("Make Staff Distro ISO");
MakeStaffDistro;
DocClear;
Move(TOS_ISO_NAME,"D:/Wb/TempleOSStaff.ISO");
#endif
#if MAKE_SUP1
TOSProgress("Make Supplemental #1 ISO");
RedSeaISO("D:/Wb/TempleOSSup1","C:/Home/Sup1");
#endif
#if MAKE_WEB
TOSProgress("Make www.templeos.org ISO");
RedSeaISO("D:/Wb/TempleOSWeb","C:/Home/Web");
#endif
#if MAKE_BOOKS1
TOSProgress("Make Books #1 ISO");
RedSeaISO("D:/Wb/TempleOSBooks1","C:/Home/Books1");
#endif
#if MAKE_BOOKS2
TOSProgress("Make Books #2 ISO");
RedSeaISO("D:/Wb/TempleOSBooks2","C:/Home/Books2");
#endif
UpdateISODocDefines;
Cd("C:/");
DocClear;
TOSProgress("Check for Long Lines");
if (LongLines)
throw;
DocClear;
TOSProgress("Check for Broken DolDoc Links");
if (LinkChk)
throw;
DocClear;
TOSProgress("Make Symbol Files");
MakeSymFiles;
DocClear;
TOSProgress("Freshen WebSite");
FreshenSite;
DocClear;
TOSProgress("Check WebSite for Profanity");
if (TOSProfanity)
throw;
TOSProgress("Find /Home");
slash_home=F2("/Home","-i+la");
TOSProgress("ChkDsk All");
Drv('C');
ChkAll;
TOSProgress("Done");
SettingsPop;
"F2(\"/Home\") Cnt\t:%d\n",slash_home;
"Elapsed Time\t:%5.3fs\n",tS-progress4_t0;
ProgressBarsRst("TempleOS/TOSRegen");
}
public U0 TOSPreRegen()
{//Copy bookmarks and bins from D:/Home/Sup1 to C:/Home/Sup1
Copy("D:/Home/Sup1/Sup1Blog/Bookmarks.html","C:/Home/Sup1/Sup1Blog");
Del("C:/Home/Sup1/Sup1Bin/*");
Copy("D:/Home/Sup1/Sup1Bin/*","C:/Home/Sup1/Sup1Bin");
Copy("D:/Home/Sup1/Sup1Bin/God*","C:/Linux");
}
U0 TOSRegen2()
{
TOSChgLog; //$LK,"::/Doc/ChgLog.DD"$ datetime matches Kernel $LK,"sys_compile_time",A="MN:sys_compile_time"$.
TOSBootHDIns('C');
Once("TOSRegen3;");
BootRAM("C:/Kernel/" KERNEL_BIN_C); //Boot new Kernel and Compiler.
}
public U0 TOSRegen()
{//Generate distro ISO's and website image, D:/Wb.
TOSBootHDIns('C');
Once("TOSRegen2;");
BootRAM("C:/Kernel/" KERNEL_BIN_C); //Boot to load $LK,"TOS_CFG",A="PF:::/Demo/AcctExample/TOS/TOSCfg.HC,TOS_CFG"$.
}
+263
View File
@@ -0,0 +1,263 @@
#help_index "Misc/TOS/God;God/TOS"
#define NIST_TIME_OFFSET (tos_nist_offset-local_time_offset/CDATE_FREQ)
#define NIST_TIME_TO_SWITCH 3
#define GSRC_NIST_BEACON 0
#define GSRC_HOTBITS 1
#define GSRC_ANU_NIST 2
#define GSRC_RANDOM_ORG 3
#define GSRC_RANDOM_NUMBERS_INFO 4
#define GSRC_PASSWORD 5
#define GSRC_GENERATE_DATA 6
#define GSRC_VIRTUAL_NOTARY 7
#define GSRC_TIMER 8
#define GBP_SHORT 0
#define GBP_MEDIUM 1
#define GBP_LONG 2
class CRandExtDec5Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,A=\"5 Decimal Digits from Hex:%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CHexWordForm
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,A=\"Hex Word Indices#0:%s\"$$\n";
U8 rnd1[512] fmtstr "$$DA-P,A=\"Hex Word Indices#1:%s\"$$\n";
U8 rnd2[512] fmtstr "$$DA-P,A=\"Hex Word Indices#2:%s\"$$\n";
U8 rnd3[512] fmtstr "$$DA-P,A=\"Hex Word Indices#3:%s\"$$\n";
U8 rnd4[512] fmtstr "$$DA-P,A=\"Hex Word Indices#4:%s\"$$\n";
U8 rnd5[512] fmtstr "$$DA-P,A=\"Hex Word Indices#5:%s\"$$\n";
U8 rnd6[512] fmtstr "$$DA-P,A=\"Hex Word Indices#6:%s\"$$\n";
U8 rnd7[512] fmtstr "$$DA-P,A=\"Hex Word Indices#7:%s\"$$\n";
U8 rnd8[512] fmtstr "$$DA-P,A=\"Hex Word Indices#8:%s\"$$\n";
U8 rnd9[512] fmtstr "$$DA-P,A=\"Hex Word Indices#9:%s\"$$\n";
U8 rndA[512] fmtstr "$$DA-P,A=\"Hex Word Indices#A:%s\"$$\n";
U8 rndB[512] fmtstr "$$DA-P,A=\"Hex Word Indices#B:%s\"$$\n";
I64 cert;
};
class CNISTBeaconHexWordForm
{
I64 timestamp fmtstr "$$DA,A=\"TimeStamp:%d\"$$\n";
U8 rnd0[512] fmtstr "$$DA-P,A=\"Hex Word Indices#0:%s\"$$\n";
U8 rnd1[512] fmtstr "$$DA-P,A=\"Hex Word Indices#1:%s\"$$\n";
U8 rnd2[512] fmtstr "$$DA-P,A=\"Hex Word Indices#2:%s\"$$\n";
U8 rnd3[512] fmtstr "$$DA-P,A=\"Hex Word Indices#3:%s\"$$\n";
U8 rnd4[512] fmtstr "$$DA-P,A=\"Hex Word Indices#4:%s\"$$\n";
U8 rnd5[512] fmtstr "$$DA-P,A=\"Hex Word Indices#5:%s\"$$\n";
U8 rnd6[512] fmtstr "$$DA-P,A=\"Hex Word Indices#6:%s\"$$\n";
U8 rnd7[512] fmtstr "$$DA-P,A=\"Hex Word Indices#7:%s\"$$\n";
U8 rnd8[512] fmtstr "$$DA-P,A=\"Hex Word Indices#8:%s\"$$\n";
U8 rnd9[512] fmtstr "$$DA-P,A=\"Hex Word Indices#9:%s\"$$\n";
U8 rndA[512] fmtstr "$$DA-P,A=\"Hex Word Indices#A:%s\"$$\n";
U8 rndB[512] fmtstr "$$DA-P,A=\"Hex Word Indices#B:%s\"$$\n";
I64 cert;
};
class CRandHex5Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P-TRM,LEN=5,"
"A=\"Line (5-Digit Hex):%5s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CRandHex8Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P-TRM,LEN=8,"
"A=\"Line (8-Digit Hex):%8s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CMoviesForm
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,"
"A=\"Movie #1-100 (2 Decimal Digits from Hex):%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CPaintings100Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,"
"A=\"Painting #00-99 (2 Decimal Digits from Hex):%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CPaintings1000Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,"
"A=\"Painting #000-999 (3 Decimal Digits from Hex):%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CMetallicaForm
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,"
"A=\"Song #1-99 (2 Decimal Digits from Hex):%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert;
};
class CCertRandDec5Form
{
I64 timestamp;
U8 rnd0[512] fmtstr "$$DA-P,A=\"Line (Dec):%s\"$$\n";
U8 rnd1[512];
U8 rnd2[512];
U8 rnd3[512];
U8 rnd4[512];
U8 rnd5[512];
U8 rnd6[512];
U8 rnd7[512];
U8 rnd8[512];
U8 rnd9[512];
U8 rndA[512];
U8 rndB[512];
I64 cert fmtstr "$$DA,A=\"Certificate:%d\"$$\n";
};
class CGodVideoForm
{
U8 title[STR_LEN] fmtstr "$$DA-P,A=\"Title:%s\"$$\n";
U8 serial[STR_LEN] fmtstr "$$DA-P-TRM,LEN=11,A=\"SerialNum:%11s\"$$\n";
I64 min fmtstr "$$DA,A=\"Minutes:%d\"$$\n";
I64 sec fmtstr "$$DA,A=\"Seconds:%d\"$$\n";
};
class CWebBibleForm
{
U8 tag[STR_LEN] fmtstr "$$DA-P,A=\"Tag Text:%s\"$$\n";
U8 special[STR_LEN] fmtstr "$$DA-P,A=\"Bible Passage:%s\"$$\n";
I64 min;
I64 sec;
};
class CYouTubeForm
{
U8 tag[STR_LEN] fmtstr "$$DA-P,A=\"Title:%s\"$$\n";
U8 special[STR_LEN] fmtstr "$$DA-P-TRM,LEN=11,A=\"SerialNum:%11s\"$$\n";
I64 min fmtstr "$$DA,A=\"Minutes:%d\"$$\n";
I64 sec fmtstr "$$DA,A=\"Seconds:%d\"$$\n";
};
class CImgurForm
{
U8 tag[STR_LEN];
U8 special[STR_LEN] fmtstr "$$DA-P,A=\"SerialNum:%s\"$$\n";
I64 min fmtstr "$$DA,A=\"Width :%d\"$$\n";
I64 sec fmtstr "$$DA,A=\"Height :%d\"$$\n";
};
class CWikipediaForm
{
U8 tag[STR_LEN] fmtstr "$$DA-P,A=\"Tag Text:%s\"$$\n";
U8 special[STR_LEN] fmtstr "$$DA-P,A=\"Index :%s\"$$\n";
I64 min;
I64 sec;
};
class CWebBookMarkForm
{
U8 tag[STR_LEN] fmtstr "$$DA-P,A=\"Tag Text:%s\"$$\n";
U8 special[STR_LEN];
I64 min;
I64 sec;
};
extern U0 FreshenBlog();
extern U0 GodBooksPassageU32(U32 rand_u32,U8 *files_find_mask,
U8 *file_mask="*",I64 len=512,I64 verbosity=GBP_MEDIUM);
extern I64 GodHeaderIns(U8 *type=NULL);
extern U0 GodVideo(U8 *title,U8 *webpage,U8 *rnd,I64 digits,U8 *filename);
extern U0 GodWebIdx(U8 *title,U8 *webpage,U8 *rnd,I64 digits,U8 *filename)
extern U0 GodWordBatch(CHexWordForm *gm);
extern U0 TOSBookLines(U8 *book_filename,I64 book_lines,U8 *st,I64 num_lines,
I64 radix,Bool modulo,Bool plus_one);
extern U0 TOSGodDoodle(I64 god_src,CNISTBeaconHexWordForm *gm=NULL);
+640
View File
@@ -0,0 +1,640 @@
#help_index "Misc/TOS/God;God/TOS"
U8 *URLPercentSpaces(U8 *src)
{
U8 buf[2048],*dst=buf;
while (*src) {
if (*src==CH_SPACE) {
*dst++='%';
*dst++='2';
*dst++='0';
src++;
} else
*dst++=*src++;
}
*dst=0;
return StrNew(buf);
}
U8 *URLPlusSpaces(U8 *src)
{
U8 buf[2048],*dst=buf;
while (*src) {
if (*src==CH_SPACE) {
*dst++='+';
src++;
} else
*dst++=*src++;
}
*dst=0;
return StrNew(buf);
}
I64 ExtDecFromHex(U8 *st,I64 digits)
{
I64 res=0,ch;
while (digits) {
if (!(ch=*st++))
break;
if ('0'<=ch<='9') {
res=10*res+ch-'0';
digits--;
}
}
return res;
}
U0 TOSBookLines(U8 *book_filename,I64 book_lines,U8 *st,I64 num_lines,
I64 radix,Bool modulo,Bool plus_one)
{//Radix<0 means extract N dec digits from hex.
CDoc *doc_out,*doc_in;
CDocEntry *doc_e;
I64 i,start;
U8 *verse;
if (*st && (doc_out=DocPut)) {
if (radix<0)
i=ExtDecFromHex(st,-radix);
else
i=Str2I64(st,radix);
if (radix<0)
DocPrint(doc_out,"'%s'-->(Taking first %d decimal digits)",st,-radix);
else if (radix==16)
DocPrint(doc_out,"0x%s-->",st);
if (modulo) {
DocPrint(doc_out,"(%d remainder when divided by %d)",
i,book_lines-(num_lines-1));
start=i%(book_lines-(num_lines-1));
} else {
if (radix>=0 || plus_one)
DocPrint(doc_out,"%d",i);
start=i;
}
if (plus_one) {
start++;
DocPrint(doc_out,"+1");
}
DocPrint(doc_out,"-->Line:%d\n",start);
if (StrMatch("NumBible",book_filename)) {
verse=BibleLine2Verse(start);
DocPrint(doc_out,"$TX,"KingJamesBible",HTML="http://www.templeos.org/Wb/Home/Sup1/Sup1Blog/NumBible.TXT"$ (%s)\n\nGod says...\n$$RED$$",verse);
Free(verse);
}
doc_in=DocNew;
BookLines(doc_in,start,num_lines,book_filename);
while (TRUE) {//Del leading blanks
doc_e=doc_in->head.next;
if (doc_e==doc_in)
break;
else {
if (doc_e->type_u8==DOCT_NEW_LINE)
DocEntryDel(doc_in,doc_e);
else
break;
}
}
while (TRUE) {//Del trailing blanks
doc_e=doc_in->cur_entry->last;
if (doc_e==doc_in)
break;
else {
if (doc_e->type_u8==DOCT_NEW_LINE)
DocEntryDel(doc_in,doc_e);
else
break;
}
}
DocPrint(doc_in,"$$FG$$\n");
DocInsDoc(doc_out,doc_in);
DocDel(doc_in);
}
}
public U0 GodBooksPassageU32(U32 rand_u32,U8 *files_find_mask,
U8 *file_mask="*",I64 len=512,I64 verbosity=GBP_MEDIUM)
{//Make God pick a book passage. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
CDirEntry *tmpde=FilesFind(files_find_mask,
FUF_RECURSE|FUF_JUST_FILES|FUF_JUST_TXT),
*tmpde1,*tmpde2,**tmpde3;
I64 i=0;
U8 *st,*st2=NULL;
tmpde3=&tmpde2;
tmpde2=NULL;
while (tmpde) {
tmpde1=tmpde->next;
if (WildMatch(tmpde->full_name,file_mask)) {
*tmpde3=tmpde;
tmpde3=&tmpde->next;
} else
DirEntryDel(tmpde);
tmpde=tmpde1;
}
*tmpde3=NULL;
if (tmpde=tmpde2) {
while (tmpde) {
st=FileRead(tmpde->full_name);
tmpde->user_data=StrLen(st);
if (verbosity==GBP_LONG)
"%08X-",i;
if (tmpde->user_data>=len)
i+=tmpde->user_data+1-len;
if (verbosity==GBP_LONG)
"%08X:$$LK,\"%s\",A=\"FI:%s\"$$\n",
i-1,tmpde->full_name+2,tmpde->full_name;
Free(st);
tmpde=tmpde->next;
}
if (verbosity==GBP_LONG)
'\n';
if (verbosity>=GBP_MEDIUM)
"%08X*%08X",rand_u32,i;
i*=rand_u32;
if (verbosity>=GBP_MEDIUM)
"=%08X.%08X\n",i.u32[1],i.u32[0];
i=i.u32[1];
tmpde=tmpde2;
while (tmpde) {
if (!st2 && tmpde->user_data>=len) {
i-=tmpde->user_data+1-len;
if (i<0) {
st=FileRead(tmpde->full_name);
st2=st+(tmpde->user_data+1-len)+i;
st2[len]=0;
"%s\nGod says...\n$$RED$$%s$$FG$$\n",tmpde->full_name,st2;
Free(st);
}
}
tmpde=tmpde->next;
}
DirTreeDel(tmpde2);
}
}
U8 *FileDblRead(U8 *filename,I64 line)
{//FileDbl's are DolDoc files with 2-line entries.
U8 *res=NULL;
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);
if (DocLineNumGoTo(doc,line-1) && doc->cur_entry->type_u8==DOCT_TEXT)
res=StrNew(doc->cur_entry->tag);
DocDel(doc);
return res;
}
U8 *FileDblWrite(U8 *filename,I64 line,U8 *st)
{//FileDbl's are DolDoc files with 2-line entries.
U8 *res=NULL;
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);
if (DocLineNumGoTo(doc,line-1)) {
if (doc->cur_entry->type_u8==DOCT_TEXT) {
Free(doc->cur_entry->tag);
doc->cur_entry->tag=StrNew(st);
} else
DocPrint(doc,"%s",st);
DocTop(doc);
DocWrite(doc);
}
DocDel(doc);
return res;
}
U0 GodVideo(U8 *title,U8 *webpage,U8 *rnd,I64 digits,U8 *filename)
{
U8 *st,*st2;
CGodVideoForm *gvf=CAlloc(sizeof(CGodVideoForm));
I64 i=ExtDecFromHex(rnd,digits);
if (!i) i=Round(10`digits);
if (st=FileDblRead(filename,i*2)) {
StrCpy(gvf->title,st);
Free(st);
if (!(st=FileDblRead(filename,i*2+1))||!*st) {
Free(st);
if (DocForm(gvf) && *gvf->serial) {
if (gvf->min || gvf->sec)
st=MStrPrint("%s&hl=enUS&start=%d",
gvf->serial,gvf->min*60+gvf->sec);
else
st=StrNew(gvf->serial);
FileDblWrite(filename,i*2+1,st);
} else
st=NULL;
}
"'%s'-->(Taking first %d decimal digits) #%02d\n",rnd,digits,i;
if (StrIMatch("Metallica",filename)) {
st2=URLPlusSpaces(gvf->title+3);
"God's response:\n"
"$$TX,\"%s\",HTML=\"%s\"$$\n"
"$$TX,\"%s (Lyrics)\","
"HTML=\"http://lmgtfy.com/?q=Metallica+lyrics+%s\"$$\n",
title,webpage,gvf->title,st2;
Free(st2);
} else
"God's response:\n"
"$$TX,\"%s\",HTML=\"%s\"$$\n"
"#%s\n",title,webpage,gvf->title;
if (st) {
"$$HC,\"<object width=\\\"640\\\" height=\\\"520\\\">"
"<param name=\\\"movie\\\" "
"value=\\\"http://www.youtube.com/v/%s\\\"></param><param "
"name=\\\"allowscriptaccess\\\" "
"value=\\\"always\\\"></param><embed "
"src=\\\"http://www.youtube.com/v/%s\\\" "
"type=\\\"application/x-shockwave-flash\\\" "
"allowscriptaccess=\\\"always\\\" "
"width=\\\"640\\\" height=\\\"520\\\">"
"</embed></object>\"$$\n",st,st;
Free(st);
}
}
Free(gvf);
}
U0 GodWebIdx(U8 *title,U8 *webpage,U8 *rnd,I64 digits,U8 *filename)
{
U8 *st1,*st2;
I64 i=ExtDecFromHex(rnd,digits);
if (!i) i=Round(10`digits);
"'%s'-->(Taking first %d decimal digits) #%02d\n",rnd,digits,i;
st1=FileDblRead(filename,i*2);
st2=FileDblRead(filename,i*2+1);
"God's response:\n";
"$$TX,\"%s\",HTML=\"%s\"$$\n",title,webpage;
PutFileLink(filename);
if (!st1)
"\n$$RED$$God does not want to comment.$$FG$$\n";
else
"\n$$RED$$$$TX,\"%s\",HTML=\"%s\"$$$$FG$$\n",st1,st2;
Free(st1);
Free(st2);
}
U0 GodWordBatch(CHexWordForm *gm)
{//Insert batch of words from rand hex.
I64 i=0;
CDirEntry *tmpde,*tmpde1;
FifoU8Flush(god.fifo);
GodHexIns(gm->rnd0);
GodHexIns(gm->rnd1);
GodHexIns(gm->rnd2);
GodHexIns(gm->rnd3);
GodHexIns(gm->rnd4);
GodHexIns(gm->rnd5);
GodHexIns(gm->rnd6);
GodHexIns(gm->rnd7);
GodHexIns(gm->rnd8);
GodHexIns(gm->rnd9);
GodHexIns(gm->rndA);
GodHexIns(gm->rndB);
tmpde=tmpde1=FilesFind(god.word_file_mask,god.word_fuf_flags);
while (tmpde) {
PutFileLink(tmpde->full_name);
'\n';
tmpde=tmpde->next;
}
DirTreeDel(tmpde1);
"\n$$RED$$";
if (*gm->rnd0)
"%s\n",gm->rnd0;
if (*gm->rnd1)
"%s\n",gm->rnd1;
if (*gm->rnd2)
"%s\n",gm->rnd2;
if (*gm->rnd3)
"%s\n",gm->rnd3;
if (*gm->rnd4)
"%s\n",gm->rnd4;
if (*gm->rnd5)
"%s\n",gm->rnd5;
if (*gm->rnd6)
"%s\n",gm->rnd6;
if (*gm->rnd7)
"%s\n",gm->rnd7;
if (*gm->rnd8)
"%s\n",gm->rnd8;
if (*gm->rnd9)
"%s\n",gm->rnd9;
if (*gm->rndA)
"%s\n",gm->rndA;
if (*gm->rndB)
"%s\n",gm->rndB;
'\n';
while (FifoU8Cnt(god.fifo)>20) {
"%02d: ",i++;
GodWord(20,TRUE);
}
FifoU8Flush(god.fifo);
"$$FG$$\n";
}
U0 TOSGodDoodle(I64 god_src,CNISTBeaconHexWordForm *gm=NULL)
{
CDC *dc;
Bool old_silent;
U8 *elems,*hex=CAlloc(sizeof(CNISTBeaconHexWordForm.rnd0)*12);
if (gm) {
StrPrint(hex,"%s%s",gm->rnd0,gm->rnd1);
if (god_src==GSRC_NIST_BEACON) {
gm->timestamp=FloorI64(CDate2Unix(Now),60);
if (DocForm(gm(CNISTBeaconHexWordForm *)))
NISTBeaconURL(gm->timestamp);
else
goto gd_done;
}
CatPrint(hex,"%s%s",gm->rnd2,gm->rnd3);
if (god_src==GSRC_NIST_BEACON) {
gm->timestamp=FloorI64(CDate2Unix(Now),60);
if (DocForm(gm(CNISTBeaconHexWordForm *)))
NISTBeaconURL(gm->timestamp);
else
goto gd_done;
}
CatPrint(hex,"%s%s",gm->rnd4,gm->rnd5);
if (god_src==GSRC_NIST_BEACON) {
gm->timestamp=FloorI64(CDate2Unix(Now),60);
if (DocForm(gm(CNISTBeaconHexWordForm *)))
NISTBeaconURL(gm->timestamp);
else
goto gd_done;
}
CatPrint(hex,"%s%s",gm->rnd6,gm->rnd7);
if (god_src==GSRC_NIST_BEACON) {
gm->timestamp=FloorI64(CDate2Unix(Now),60);
if (DocForm(gm(CNISTBeaconHexWordForm *)))
NISTBeaconURL(gm->timestamp);
else
goto gd_done;
}
CatPrint(hex,"%s%s",gm->rnd8,gm->rnd9);
if (god_src==GSRC_NIST_BEACON) {
gm->timestamp=FloorI64(CDate2Unix(Now),60);
if (DocForm(gm(CNISTBeaconHexWordForm *)))
NISTBeaconURL(gm->timestamp);
else
goto gd_done;
}
CatPrint(hex,"%s%s",gm->rndA,gm->rndB);
}
if (elems=GodDoodleSprite(hex)) {
dc=Sprite2DC(elems);
BlogDCImgWrite(dc);
DCDel(dc);
Free(elems);
old_silent=Silent;
FreshenBlog;
Silent(old_silent);
}
gd_done:
Free(hex);
}
I64 GodHeaderIns(U8 *type=NULL)
{
CDateStruct ds;
I64 res;
if (type) {//If NISTBeacon
res=FloorI64(CDate2Unix(Now+2*60*CDATE_FREQ),60);
Date2Struct(&ds,Unix2CDate(res)+local_time_offset+30*CDATE_FREQ);
"Response of %s at %02d:%02d Timestamp:%d.\n\n",type,ds.hour,ds.min,res;
In("%c//Response of %s at %02d:%02d Timestamp:%d.\n\n",
CH_ESC,type,ds.hour,ds.min,res);
}
"$$TX,\"Guidelines for Talking with God.\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n";
return res;
}
U0 TimerGodIns()
{
U8 buf[STR_LEN];
GodHeaderIns;
FifoU8Flush(god.fifo);
GodBitsIns(GOD_GOOD_BITS,KbdMsEvtTime>>GOD_BAD_BITS);
switch (PopUpPickLst("Hex5Bible\0Hex8Books\0Doodle\0Movie\0Painting100\0"
"Painting1000\0Metallica\0")) {
case:
StrPrint(buf,"%05X",GodBits(5*4));
"$$TX,\"How this random Bible passage was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/Passage.html\"$$\n";
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
buf,20,16,TRUE,TRUE);
break;
case:
GodBooksPassageU32(GodBits(32),"~/*","C:/Home/Books?/*",,GBP_SHORT);
break;
case:
TOSGodDoodle(GSRC_TIMER);
break;
case:
StrPrint(buf,"%05X",GodBits(2*5*4)); //Little bit risky if no dec.
GodVideo("Top 100 Movies",
"http://www.afi.com/100years/movies10.aspx",
buf,2,"~/Sup1/Sup1Blog/Movies.DD.Z");
break;
case:
StrPrint(buf,"%05X",GodBits(2*5*4)); //Little bit risky if no dec.
GodWebIdx("Top 100 Paintings",
"http://www.brushwiz.com/most-famous-paintings",
buf,2,"~/Sup1/Sup1Blog/Paintings100.DD.Z");
break;
case:
StrPrint(buf,"%05X",GodBits(2*5*4)); //Little bit risky if no dec.
GodWebIdx("Top 1000 Paintings",
"http://en.most-famous-paintings.com/MostFamousPaintings."
"nsf/ListOfTop1000MostPopularPainting",
buf,3,"~/Sup1/Sup1Blog/Paintings1000.DD.Z");
break;
case:
StrPrint(buf,"%05X",GodBits(2*5*4)); //Little bit risky if no dec.
GodVideo("Metallica Song",
"http://home.hccnet.nl/a.r.adams/lyrics/"
"metallica/songindex.html",
buf,2,"~/Sup1/Sup1Blog/Metallica.DD.Z");
break;
}
}
public U0 GodIns()
{//<ALT-F7> Insert misc rand God item into blog.
U8 *st,*tag;
CRandExtDec5Form *gm=CAlloc(sizeof(CRandExtDec5Form));
I64 god_src=PopUpPickLst("NISTBeacon\0HotBits\0ANU_NIST\0Random.org\0"
"RandomNumbers.info\0Password\0GenerateData\0VirtualNotary\0Timer\0");
if (god_src>=GSRC_NIST_BEACON) {
switch (god_src) {
case GSRC_NIST_BEACON:
NISTGodIns1;
break;
start:
case GSRC_HOTBITS:
tag="https://www.fourmilab.ch/hotbits/secure_generate.html";
break;
case GSRC_ANU_NIST:
tag="http://qrng.anu.edu.au/NIST.php";
break;
end:
GodHeaderIns;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$\n",tag,tag;
switch (PopUpPickLst("ExtDec5Bible\0LinuxWords\0"
"HappyWords\0Hex5Bible\0Hex8Books\0Doodle\0Movie\0Painting100\0"
"Painting1000\0Metallica\0")) {
case:
if (DocForm(gm(CRandExtDec5Form *)))
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,-5,FALSE,FALSE);
break;
case:
if (DocForm(gm(CHexWordForm *))) {
Adam("GodInit(\"~/Sup1/Sup1Words/LinuxDict.TXT*\");");
GodWordBatch(gm);
}
break;
case:
if (DocForm(gm(CHexWordForm *))) {
Adam("GodInit(\"~/Sup1/Sup1Words/HappyWords.TXT*\");");
GodWordBatch(gm);
}
break;
case:
if (DocForm(gm(CRandHex5Form *))) {
"$$TX,\"How this random Bible passage was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/Passage.html\"$$\n";
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,16,TRUE,TRUE);
}
break;
case:
if (DocForm(gm(CRandHex8Form *))) {
"$$TX,\"How this random book pick was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/NISTPick002.html\"$$\n";
GodBooksPassageU32(Str2I64(gm->rnd0,16),
"~/*","C:/Home/Books?/*");
}
break;
case:
if (DocForm(gm(CHexWordForm *)))
TOSGodDoodle(god_src,gm);
break;
case:
if (DocForm(gm(CMoviesForm *)))
GodVideo("Top 100 Movies",
"http://www.afi.com/100years/movies10.aspx",
gm->rnd0,2,"~/Sup1/Sup1Blog/Movies.DD.Z");
break;
case:
if (DocForm(gm(CPaintings100Form *))) {
GodWebIdx("Top 100 Paintings",
"http://www.brushwiz.com/most-famous-paintings",
gm->rnd0,2,"~/Sup1/Sup1Blog/Paintings100.DD.Z");
}
break;
case:
if (DocForm(gm(CPaintings1000Form *))) {
GodWebIdx("Top 1000 Paintings",
"http://en.most-famous-paintings.com/MostFamousPaintings."
"nsf/ListOfTop1000MostPopularPainting",
gm->rnd0,3,"~/Sup1/Sup1Blog/Paintings1000.DD.Z");
}
break;
case:
if (DocForm(gm(CMetallicaForm *)))
GodVideo("Metallica Song",
"http://home.hccnet.nl/a.r.adams/lyrics/"
"metallica/songindex.html",
gm->rnd0,2,"~/Sup1/Sup1Blog/Metallica.DD.Z");
break;
}
break;
start:
case GSRC_RANDOM_ORG:
tag="http://www.random.org";
break;
case GSRC_RANDOM_NUMBERS_INFO:
tag="http://www.randomnumbers.info";
break;
case GSRC_PASSWORD:
tag="https://passed.pw";
break;
case GSRC_GENERATE_DATA:
tag="http://www.generatedata.com";
break;
end:
GodHeaderIns;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$\n",tag,tag;
switch (PopUpPickLst("ExtDec5Bible\0HexWordBatch\0"
"Hex5Bible\0Hex8Books\0Movie\0Metallica\0")) {
case:
if (DocForm(gm(CRandExtDec5Form *)))
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,-5,FALSE,FALSE);
break;
case:
if (DocForm(gm(CHexWordForm *)))
GodWordBatch(gm);
break;
case:
if (DocForm(gm(CRandHex5Form *))) {
"$$TX,\"How this random Bible passage was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/Passage.html\"$$\n";
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,16,TRUE,TRUE);
}
break;
case:
if (DocForm(gm(CRandHex8Form *))) {
"$$TX,\"How this random book pick was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/NISTPick002.html\"$$\n";
GodBooksPassageU32(Str2I64(gm->rnd0,16),
"~/*","C:/Home/Books?/*");
}
break;
case:
if (DocForm(gm(CMoviesForm *)))
GodVideo("Top 100 Movies",
"http://www.afi.com/100years/movies10.aspx",
gm->rnd0,2,"~/Sup1/Sup1Blog/Movies.DD.Z");
break;
case:
if (DocForm(gm(CMetallicaForm *)))
GodVideo("Metallica Song",
"http://home.hccnet.nl/a.r.adams/lyrics/"
"metallica/songindex.html",
gm->rnd0,2,"~/Sup1/Sup1Blog/Metallica.DD.Z");
break;
}
break;
case GSRC_VIRTUAL_NOTARY:
GodHeaderIns;
if (DocForm(gm(CCertRandDec5Form *))) {
tag="http://virtual-notary.org";
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$\n",tag,tag;
tag="Here is the certificate";
st=MStrPrint("http://www.templeos.org/Certs/virtual-notary-cert"
"-randomnum-%d.p12",gm->cert);
"\n$$TX,\"%$$Q: %d\",HTML=\"%$$Q\"$$.\n",tag,gm->cert,st;
Free(st);
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,-5,FALSE,FALSE);
}
break;
case GSRC_TIMER:
TimerGodIns;
break;
}
}
Free(gm);
}
if (FileFind("~/Sup1/Sup1Words/LinuxDict.TXT"))
GodInit("~/Sup1/Sup1Words/LinuxDict.TXT");
//if (FileFind("~/Sup1/Sup1Words/HappyWords.TXT"))
// GodInit("~/Sup1/Sup1Words/HappyWords.TXT");
+226
View File
@@ -0,0 +1,226 @@
#help_index "Misc/Blog"
U8 *YouTubeGet(U8 *filename="~/Sup1/Sup1Blog/YouTube.DD.Z",U8 *needle)
{
I64 i=0,line=I64_MIN;
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR),
*doc2=DocNew;
U8 *title,*code,*res;
while (DocFind(doc,line,needle)) {
if (!(doc->cur_entry->y&1)) {
title=doc->cur_entry->tag;
DocLineNumGoTo(doc,doc->cur_entry->y+2);
if (doc->cur_entry->type_u8==DOCT_TEXT) {
code=doc->cur_entry->tag;
DocPrint(doc2,"$$MU-UL,\"%s\",LE=0x%X$$\n",title,code);
i++;
}
}
line=doc->cur_entry->y+2;
}
switch (i) {
case 0:
res=NULL;
break;
case 1:
res=StrNew(code);
break;
default:
res=PopUpMenu(doc2);
if (res==DOCM_CANCEL)
res=NULL;
else
res=StrNew(res);
}
DocDel(doc);
DocDel(doc2);
return res;
}
U0 YouTubeAdd(U8 *filename="~/Sup1/Sup1Blog/YouTube.DD.Z",
U8 *title,U8 *code)
{
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);
if (!DocFind(doc,,title)) {
DocBottom(doc);
DocPrint(doc,"%s\n%s\n",title,code);
DocTop(doc);
DocWrite(doc);
Sort(filename,,2);
}
DocDel(doc);
}
U8 *WebBookMarks(U8 *filename="~/Sup1/Sup1Blog/Bookmarks.html")
{
U8 *st;
CDocEntry *doc_e;
CDoc *doc=DocNew;
CCmpCtrl *cc=CmpCtrlNew(MStrPrint("#include \"%s\"",filename));
while (Lex(cc))
if (cc->token==TK_STR && *cc->cur_str(U32 *)=='http') {
DocPrint(doc,"$$MU-UL,\"%$$Q\",LE=0x%X$$\n",cc->cur_str,cc->cur_str);
cc->cur_str=NULL;
}
CmpCtrlDel(cc);
if ((st=PopUpMenu(doc))!=DOCM_CANCEL)
st=StrNew(st);
else
st=NULL;
doc_e=doc->head.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_MENU_VAL)
Free(doc_e->left_exp);
doc_e=doc_e->next;
}
DocDel(doc);
return st;
}
U0 TOSIns()
{
CWebBibleForm *url=CAlloc(sizeof(CWebBibleForm));
U8 *tag,*st,*st2;
switch (PopUpPickLst("BiblePassage\0BibleVerse\0"
"YouTube\0Imgur\0Wikipedia\0WebBookMark\0")) {
case:
if (DocForm(url(CWebBibleForm *))) {
tag=url->special;
st2=URLPercentSpaces(url->special);
st=MStrPrint("http://www.biblegateway.com/passage/"
"?search=%s&version=NIV",st2);
Free(st2);
if (*url->tag)
tag=url->tag;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$",tag,st;
Free(st);
}
break;
case:
if (DocForm(url(CWebBibleForm *))) {
tag=url->special;
st2=URLPercentSpaces(url->special);
st=MStrPrint(
"http://www.biblegateway.com/verse/en/%s",st2);
Free(st2);
if (*url->tag)
tag=url->tag;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$",tag,st;
Free(st);
}
break;
case:
if (DocForm(url(CYouTubeForm *))) {
if (*url->special==CH_SPACE)
st2=YouTubeGet(,url->tag);
else
st2=StrNew(url->special);
if (st2 && *st2!=CH_SPACE) {
if (url->min || url->sec)
st=MStrPrint("%s&hl=enUS&start=%d",st2,url->min*60+url->sec);
else
st=StrNew(st2);
if (*url->special!=CH_SPACE && *url->tag)
YouTubeAdd(,url->tag,st);
"$$HC,\"<object width=\\\"640\\\" "
"height=\\\"520\\\"><param name=\\\"movie\\\" "
"value=\\\"http://www.youtube.com/v/%s\\\"></param><param "
"name=\\\"allowscriptaccess\\\" "
"value=\\\"always\\\"></param><embed "
"src=\\\"http://www.youtube.com/v/%s\\\" "
"type=\\\"application/x-shockwave-flash\\\" "
"allowscriptaccess=\\\"always\\\" "
"width=\\\"640\\\" height=\\\"520\\\">"
"</embed></object>\"$$\n",st,st;
Free(st);
Free(st2);
}
}
break;
case:
if (DocForm(url(CImgurForm *))) {
"$$HC,\"<center><img src=\\\"http://i.imgur.com/%s\\\" "
"width=\\\"%d\\\" height=\\\"%d\\\" "
"alt=\\\"\\\"></center>\"$$\n",
url->special,url->min,url->sec;
}
break;
case:
if (DocForm(url(CWikipediaForm *))) {
tag=url->special;
st=MStrPrint("http://en.wikipedia.org/wiki/%s",url->special);
if (*url->tag)
tag=url->tag;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$",tag,st;
Free(st);
}
break;
case:
if (DocForm(url(CWebBookMarkForm *))) {
tag=st=WebBookMarks;
if (*url->tag)
tag=url->tag;
"$$TX,\"%$$Q\",HTML=\"%$$Q\"$$",tag,st;
Free(st);
}
break;
}
Free(url);
}
#help_index "Misc/TOS/God;God/TOS"
public U0 GodCodeJmp()
{//Jump to rand code in OS. See $LK,"::/Adam/God/HSNotes.DD"$.
CDirEntry *tmpde1=FilesFind("/*",
FUF_JUST_FILES|FUF_RECURSE|FUF_JUST_SRC|FUF_CLUSTER_ORDER),
*tmpde=tmpde1;
I64 cnt=0,num;
CDoc *doc;
U8 *st;
while (tmpde) {
doc=DocRead(tmpde->full_name);
tmpde->user_data=doc->head.y;
cnt+=doc->head.y;
DocDel(doc);
tmpde=tmpde->next;
}
FifoU8Flush(god.fifo);
GodBitsIns(GOD_GOOD_BITS,KbdMsEvtTime>>GOD_BAD_BITS);
num=GodBits(GOD_GOOD_BITS)%cnt;
tmpde=tmpde1;
while (tmpde) {
num-=tmpde->user_data;
if (num<0) {
st=MStrPrint("FL:%s,%d",tmpde->full_name,-num);
break;
}
tmpde=tmpde->next;
}
DirTreeDel(tmpde1);
Ed(st);
Free(st);
}
U0 GodOffer()
{
switch (PopUpPickLst("MosesComic\0Fiction\0")) {
case:
"---- Moses Comic ---- "
"(Set in the $TX,"Numbers 11",HTML="http://www.biblegateway.com/passage/?search=Numbers%%%%2011&version=NIV"$ "
"part of the story.)\n"
"Moses says, \"\"\n"
"God says, \"\"\n";
break;
case:
"---- $TX,"Collaborative Fiction",HTML="http://en.wikipedia.org/wiki/Collaborative_fiction"$ ----\n"
"Once upon a time ";
break;
}
}
+251
View File
@@ -0,0 +1,251 @@
#help_index "Misc/TOS"
#define VIDEO_FRAME_RATE 29.97
#define FG_JUST_AUDIO 0
#define FG_BOOT_DRV 1
#define FG_RAM_DRV 2
I64 fg_mode=FG_RAM_DRV;
Bool fg_on =FALSE;
U0 FrameGrabberTask(I64)
{//#!/bin/bash
//for f in ./ScrnShots/*.Z; do ./Bin/TOSZ $$f; done
//ffmpeg -r 8 -i VID%05d.BMP -y Movie.avi
I64 frame_num=0;
U8 buf[STR_LEN],buf2[STR_LEN],*st_dir;
F64 end_time=tS;
Silent; //no output to scrn
if (fg_mode==FG_RAM_DRV)
st_dir="B:/Tmp/ScrnShots";
else
st_dir="::/Tmp/ScrnShots";
MkDir(st_dir);
while (fg_on) {
StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
StrCpy(buf2,buf);
BMPScrnCapture(buf);
while (TRUE) {
end_time+=1.0/VIDEO_FRAME_RATE;
if (end_time<tS) {
StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
Copy(buf2,buf);
} else
break;
}
SleepUntil(cnts.jiffies+(end_time-tS)*JIFFY_FREQ);
}
}
I64 CopyVideo()
{
I64 res=0;
Del("D:/Tmp/*.SND");
if (fg_mode==FG_JUST_AUDIO)
SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35,2.5);
else {
SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35);
DelTree("D:/Tmp/ScrnShots");
if (fg_mode==FG_RAM_DRV) {
res=CopyTree("B:/Tmp/ScrnShots","D:/Tmp/ScrnShots");
"Unused Space: %12.6fMeg\n",UnusedDrvSpace('B')/1024.0/1024.0;
} else
res=CopyTree("::/Tmp/ScrnShots","D:/Tmp/ScrnShots");
"$$BK,1$$Files Copied:%d$$BK,0$$ Time:%8.3fm\n",
res,res/60.0/VIDEO_FRAME_RATE;
}
return res;
}
public U0 FrameGrabberToggle()
{//The frame grabber saves BMP files to D:/Tmp/ScrnShots.
static F64 last_time=0;
if (tS-last_time>3.0) {
last_time=tS;
if (fg_on) {
fg_on=FALSE;
Snd;
wall->record=snd.record=FALSE;
Sleep(1000);
User("CopyVideo;Exit;\n");
} else {
fg_on=TRUE;
if (fg_mode!=FG_JUST_AUDIO)
Spawn(&FrameGrabberTask,NULL,"Frame Grabber");
wall->record=snd.record=TRUE;
Snd;
}
}
}
public U0 JukeSong(I64 num)
{//Make movie of one song.
AutoComplete;
if (!fg_on)
FrameGrabberToggle;
JukeSongsPuppet("~/Sup1/Sup1Hymns",,num,num+1);
if (fg_on)
FrameGrabberToggle;
}
public U0 JukeLines(I64 start_line,I64 end_line)
{//Make movie of many lines of songs.
AutoComplete;
if (!fg_on)
FrameGrabberToggle;
JukeSongsPuppet("~/Sup1/Sup1Hymns",,start_line*5,end_line*5);
if (fg_on)
FrameGrabberToggle;
}
public U0 ChkAll()
{//ChkDsk on C & D.
U8 *ptr=TOS_HDS;
while (*ptr)
ChkDsk(*ptr++);
}
public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
{//Use OCR to make a text DolDoc from CDC.
U8 byte_bit_cnts[256];
I64 i,j,*ptr,row,col,ch,best_ch,score,best_score,
cur_char_image,diff_image,total_score=0;
CDoc *doc=DocNew;
MemSet(byte_bit_cnts,0,sizeof(byte_bit_cnts));
for (i=0;i<256;i++)
for (j=0;j<7;j++)
if (Bt(&i,j))
byte_bit_cnts[i]++;
for (row=0;row<dc->height/FONT_HEIGHT;row++) {
for (col=0;col<dc->width/FONT_WIDTH;col++) {
cur_char_image=0;
for (i=0;i<FONT_HEIGHT;i++)
for (j=0;j<FONT_WIDTH;j++)
if (GrPeek(dc,col*FONT_WIDTH+j+dx,row*FONT_HEIGHT+i+dy)!=WHITE)
LBts(&cur_char_image,i*8+j);
best_score=I64_MAX;
best_ch=0;
ptr=&text.font[32];
for (ch=32;ch<127;ch++) {
diff_image=*ptr++ ^ cur_char_image;
score=0;
for (i=0;i<8;i++)
score+=byte_bit_cnts[diff_image.u8[i]];
if (score<best_score) {
best_score=score;
best_ch=ch;
}
}
if (best_ch=='$$')
DocPrint(doc,"$$$$");
else
DocPrint(doc,"%c",best_ch);
total_score+=best_score;
}
DocPrint(doc,"\n");
}
if (_total_score) *_total_score=total_score;
return doc;
}
public U0 BMP2Doc(U8 *_in_name,U8 *_out_name=NULL)
{//Use OCR to make a text DolDoc from BMP file.
U8 *in_name,*out_name;
I64 dx,dy,score,best_score=I64_MAX;
CDC *dc;
CDoc *doc;
in_name=DftExt(_in_name,"BMP");
if (_out_name)
out_name=DftExt(_out_name,"DD.Z");
else
out_name=ChgExt(_in_name,"DD.Z");
if (dc=BMPRead(in_name)) {
for (dy=-3;dy<=4;dy++)
for (dx=-3;dx<=4;dx++) {
doc=DC2Doc(dc,dx,dy,&score);
if (score<best_score) {
best_score=score;
StrCpy(&doc->filename.name,out_name);
DocWrite(doc);
}
DocDel(doc);
}
}
Free(in_name);
Free(out_name);
}
U0 TOSTheme()
{
if (!fg_on)
PopUp("Sleep(50);FrameGrabberToggle;");
ExeFile("~/Sup1/Sup1Graphics/TOS/TOSTheme.HC");
DocClear;
}
U0 TOSJukeVideo(I64 start=0,I64 end=10)
{
U8 *buf=FileRead("::/Misc/Bible.TXT.Z"); //Put in cache
Free(buf);
AutoComplete;
FrameGrabberToggle;
JukeSongsPuppet("~/Sup1/Sup1Hymns",,start,end);
FrameGrabberToggle;
}
#define MEM_TEST_SIZE 1024*1024
U0 MemTest()
{
U8 *b;
while (sys_data_bp->alloced_u8s-sys_data_bp->used_u8s>0x1000000) {
b=MAlloc(MEM_TEST_SIZE,Fs->data_heap);
MemSet(b,0x88,MSize(b));
"Data:%X\n",sys_data_bp->alloced_u8s-sys_data_bp->used_u8s;
Yield;
}
while (sys_code_bp->alloced_u8s-sys_code_bp->used_u8s>0x1000000) {
b=MAlloc(MEM_TEST_SIZE,Fs->code_heap);
MemSet(b,0x88,MSize(b));
"Code:%X\n",sys_code_bp->alloced_u8s-sys_code_bp->used_u8s;
Yield;
}
}
public I64 Profanity(
U8 *needle_filename="~/Sup1/Sup1Blog/Profanity.DD.Z",
U8 *files_find_mask="/*",U8 *fu_flags=NULL)
{//Scan for profanity.
CCmpCtrl *cc;
I64 res=0;
if (FileFind(needle_filename)) {
cc=CmpCtrlNew(MStrPrint("#include \"%s\"",needle_filename));
while (Lex(cc))
if (cc->token==TK_IDENT)
res+=Find(cc->cur_str,files_find_mask,fu_flags);
CmpCtrlDel(cc);
}
return res;
}
U0 TOSChgLog2()
{
InStr("\"Ed(\\\"::/Doc/ChgLog.DD.Z\\\");\n\";
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_UP|SCF_CTRL);
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
Msg(MSG_KEY_DOWN_UP,CH_CTRLY,0);
Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
Msg(MSG_KEY_DOWN_UP,CH_ESC,0);"
"\"Exit;\n\";");
}
public U0 TOSChgLog()
{//Opdate ChgLog file.
User("TOSChgLog2;\n");
}
+158
View File
@@ -0,0 +1,158 @@
#help_index "Misc/TOS/God;God/TOS"
I64 tos_timestamp=0,tos_type=0;
RegDft("TempleOS/TOSNIST","I64 tos_nist_offset=-8049;\n");
RegExe("TempleOS/TOSNIST");
public I64 CDate2Unix(CDate dt)
{//TempleOS datetime to Unix timestamp.
return ToI64((dt-Str2Date("1/1/1970"))/CDATE_FREQ+NIST_TIME_OFFSET);
}
public CDate Unix2CDate(I64 timestamp)
{//Unix timestamp to TempleOS datetime.
return (timestamp-NIST_TIME_OFFSET)*CDATE_FREQ+Str2Date("1/1/1970");
}
public U0 NISTBeaconSync()
{//Help get local clk in sync with NIST clk.
I64 i,j;
CDate dt;
CDateStruct ds;
while (!ScanChar) {
dt=Now;
Date2Struct(&ds,dt);
i=CDate2Unix(dt);
j=FloorI64(i,60);
"%d %d %02d %02d\n",i,j,ds.sec,(60+ds.sec-(i-j))%60;
Sleep(100);
}
tos_nist_offset=GetI64("tos_nist_offset (%d):",tos_nist_offset);
RegWrite("TempleOS/TOSNIST","I64 tos_nist_offset=%d;\n",tos_nist_offset);
}
U0 NISTBeaconURL(I64 timestamp)
{//Insert NIST Beacon header into blog.
U8 *tag;
CDateStruct ds;
CDate dt=Unix2CDate(timestamp);
Date2Struct(&ds,dt+local_time_offset+30*CDATE_FREQ);
"$$TX,\"NIST Beacon Date:%D Time:%02d:%02d Unix TimeStamp:%u\","
"HTML=\"https://beacon.nist.gov/home\"$$\n",dt,ds.hour,ds.min,timestamp;
tag=MStrPrint("https://beacon.nist.gov/rest/record/%d",timestamp);
"$$TX,\"NIST Beacon Record:%$$Q\",HTML=\"%$$Q\"$$\n",tag,tag;
Free(tag);
}
U0 NISTGodIns1()
{
tos_type=PopUpPickLst("ExtDec5Bible\0LinuxWords\0HappyWords\0"
"Hex5Bible\0Hex8Books\0Doodle\0Movie\0Painting100\0Painting1000\0"
"Metallica\0");
switch (tos_type) {
case: tos_timestamp=GodHeaderIns("Bible"); break;
case: tos_timestamp=GodHeaderIns("LinuxWords"); break;
case: tos_timestamp=GodHeaderIns("HappyWords"); break;
case: tos_timestamp=GodHeaderIns("Bible"); break;
case: tos_timestamp=GodHeaderIns("BookPick"); break;
case: tos_timestamp=GodHeaderIns("Doodle"); break;
case: tos_timestamp=GodHeaderIns("Movie"); break;
case: tos_timestamp=GodHeaderIns("Painting100"); break;
case: tos_timestamp=GodHeaderIns("Painting1000"); break;
case: tos_timestamp=GodHeaderIns("Metallica"); break;
}
Once("tos_timestamp=%d;\ntos_type=%d;\n"
"In(\"Blog(TRUE);\n\");",tos_timestamp,tos_type);
}
U0 NISTGodIns2()
{
CRandExtDec5Form *gm=CAlloc(sizeof(CRandExtDec5Form));
gm->timestamp=tos_timestamp;
switch (tos_type) {
case:
if (DocForm(gm(CRandExtDec5Form *))) {
NISTBeaconURL(gm->timestamp);
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,-5,FALSE,FALSE);
}
break;
case:
if (DocForm(gm(CHexWordForm *))) {
NISTBeaconURL(gm->timestamp);
Adam("GodInit(\"~/Sup1/Sup1Words/LinuxDict.TXT*\");");
GodWordBatch(gm);
}
break;
case:
if (DocForm(gm(CHexWordForm *))) {
NISTBeaconURL(gm->timestamp);
Adam("GodInit(\"~/Sup1/Sup1Words/HappyWords.TXT*\");");
GodWordBatch(gm);
}
break;
case:
if (DocForm(gm(CRandHex5Form *))) {
"$$TX,\"How this random Bible passage was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/NISTPassage.html\"$$\n";
NISTBeaconURL(gm->timestamp);
TOSBookLines("~/Sup1/Sup1Blog/NumBible.TXT",ST_BIBLE_LINES,
gm->rnd0,20,16,TRUE,TRUE);
}
break;
case:
if (DocForm(gm(CRandHex8Form *))) {
"$$TX,\"How this random book pick was chosen.\","
"HTML=\"http://www.templeos.org/Wb"
"/Home/Web/TAD/NISTPick002.html\"$$\n";
NISTBeaconURL(gm->timestamp);
GodBooksPassageU32(Str2I64(gm->rnd0,16),
"~/*","C:/Home/Books?/*");
}
break;
case:
if (DocForm(gm(CHexWordForm *))) {
NISTBeaconURL(gm->timestamp);
TOSGodDoodle(GSRC_NIST_BEACON,gm);
}
break;
case:
if (DocForm(gm(CMoviesForm *))) {
NISTBeaconURL(gm->timestamp);
GodVideo("Top 100 Movies",
"http://www.afi.com/100years/movies10.aspx",
gm->rnd0,2,"~/Sup1/Sup1Blog/Movies.DD.Z");
}
break;
case:
if (DocForm(gm(CPaintings100Form *))) {
NISTBeaconURL(gm->timestamp);
GodWebIdx("Top 100 Paintings",
"http://www.brushwiz.com/most-famous-paintings",
gm->rnd0,2,"~/Sup1/Sup1Blog/Paintings100.DD.Z");
}
break;
case:
if (DocForm(gm(CPaintings1000Form *))) {
NISTBeaconURL(gm->timestamp);
GodWebIdx("Top 1000 Paintings",
"http://en.most-famous-paintings.com/MostFamousPaintings."
"nsf/ListOfTop1000MostPopularPainting",
gm->rnd0,3,"~/Sup1/Sup1Blog/Paintings1000.DD.Z");
}
break;
case:
if (DocForm(gm(CMetallicaForm *))) {
NISTBeaconURL(gm->timestamp);
GodVideo("Metallica Song",
"http://home.hccnet.nl/a.r.adams/lyrics/"
"metallica/songindex.html",
gm->rnd0,2,"~/Sup1/Sup1Blog/Metallica.DD.Z");
}
break;
}
Free(gm);
}
+167
View File
@@ -0,0 +1,167 @@
$WW,1$$FG,5$$TX+CX,"TOS Staff Policies"$$FG$
* Motto: Run toward bugs, not away from bugs.
* Be Metallica. Use short, sharp, powerful words, as though a song.
* Be careful $FG,2$/Demo/AcctExample$FG$ doesn't get extra files. When you run TOSRegen(), it will copy home files to $FG,2$/Demo/AcctExample$FG$.
* Be careful $FG,2$remote/Wb$FG$ site doesn't get extra files. If you delete or rename a file, also delete the $FG,2$remote/Wb$FG$ file from the site.
$TR,"PreRegen()"$
$ID,2$
Linux: Export Bookmarks to ~/TAD/Home/Sup1/Sup1Blog/Bookmarks.html
Linux: >vm_in
Linux: VMware Machine: "TOS"
{
TempleOS: >TOSPreRegen;
TempleOS: Update Budget
}
$ID,-2$
$TR,"NewRelease(Bool full=FALSE)"$
$ID,2$
if ($FG,2$full$FG$)
]PreRegen()
Linux: VMware Machine:"TOS"
{
TempleOS: >TOSRegen($FG,2$full$FG$);
}
Linux: >vm_out
if ($FG,2$full$FG$) {
Linux: Burn ~/TAD to memory stick.
On other machine {
Linux: Copy ~/TAD from memory stick.
VMware: VMware NewMachine:"TOS", Install TempleOSStaff.ISO
{ //2048 Meg RAM or 57344 Meg RAM
TempleOS: $LK,"TOSStaffIns",A="MN:TOSStaffIns"$(); in VMware.
TempleOS: >TOSRegen;
TempleOS: >#include "::/Misc/OSTestSuite"
TempleOS: >Del("~/Demo*");
}
Linux: >emu_staff_new
Linux: >emu8core or >emu24core
{
TempleOS: $LK,"TOSStaffIns",A="MN:TOSStaffIns"$(); in QEMU.
TempleOS: >TOSRegen;
}
}
}
Linux: CrossFTP sync ~/TAD/Site1/Wb to remote/Wb
if ($FG,2$full$FG$) {
FileZilla
Upload ~/TAD/Site1/index.html to remote/index.html
Upload ~/TAD/Site1/TempleOS.html to remote/TempleOS.html
}
In WebHost FileMgr {
Del {
remote/TempleOSCD.ISO
remote/TempleOSSup1.ISO.C
remote/TempleOSWeb.ISO.C
remote/TempleOSUltra.ISO
}
Copy up one level to remote root {
remote/Wb/TempleOSCD.ISO
remote/Wb/TempleOSSup1.ISO.C
remote/Wb/TempleOSWeb.ISO.C
remote/Wb/TempleOSUltra.ISO
}
}
$ID,-2$
$TR,"NewVersion(Bool full=FALSE)"$
$ID,2$
Increment minor version number.
>$LK,"R",A="MN:R"$("3.12","3.13","-i-l"); //Approve by hand.
Add version release notice in $LK,"::/Doc/ChgLog.DD"$.
]NewRelease(TRUE);
Submit to www.betanews.com.
Send email to MajorGeeks.
if ($FG,2$full$FG$) {
Submit to www.upload.com.
Upload to SourceForge.
}
$ID,-2$
$TR,"NewYearlyVersion()"$
$ID,2$
Increment major version number.
>$LK,"R",A="MN:R"$("3.13","4.00","-i-l"); //Approve by hand.
Add version release notice in $LK,"::/Doc/ChgLog.DD"$.
$LK,"Update ::/Misc/PCIDevices.DD",A="FF:::/Adam/DevInfo.HC,PCIDevFileGen"$
Remove 6 months from bottom of $LK,"::/Doc/ChgLog.DD"$.
]NewVersion(TRUE);
$ID,-2$
* If you change the compiler language syntax, immediately make a ]NewRelease(TRUE).
$FG,5$$TX+CX,"TOS Staff Indoctrination"$$FG$
Make a list of all the ways you make a project scalable. With TempleOS, we scale down, not up, so do we do the opposite of all of them.
How would you improve this $LK,"LZW Compression",A="FI:::/Kernel/Compress.HC"$? We have a 100,000 line of code limit, so it's a trick, thought provoking, question introducing you to our way of thinking.
We hope to define objective metrics so we can simply ask the world to reduce the lines of code and be perfectly objective.
We hope for an objective metric for the compiler, such as how fast it compiles itself (having been compiled by itself). It's a little less elegant, but we actually compile kernel and compiler together all the time with $LK,"TOSBootHDIns",A="FF:::/Demo/AcctExample/TOS/TOSDistro.HC,TOSBootHDIns"$('C'). We have the freedom to change the $LK,"HolyC",A="FI:::/Doc/HolyC.DD"$ language, like how I made type-casting post-fix. We need some more limitations on the problem because we don't want a ridiculous language.
Consider these games as the basis of the vector space we wish to span:
$LK,"/Demo/Games/BattleLines.HC",A="FI:::/Demo/Games/BattleLines.HC"$
$LK,"/Demo/Games/BigGuns.HC",A="FI:::/Demo/Games/BigGuns.HC"$
$LK,"/Demo/Games/BlackDiamond.HC",A="FI:::/Demo/Games/BlackDiamond.HC"$
$LK,"/Demo/Games/BomberGolf.HC",A="FI:::/Demo/Games/BomberGolf.HC"$
$LK,"/Demo/Games/CastleFrankenstein.HC",A="FI:::/Demo/Games/CastleFrankenstein.HC"$
$LK,"/Demo/Games/CharDemo.HC",A="FI:::/Demo/Games/CharDemo.HC"$
$LK,"/Demo/Games/CircleTrace.HC",A="FI:::/Demo/Games/CircleTrace.HC"$
$LK,"/Demo/Games/Collision.HC",A="FI:::/Demo/Games/Collision.HC"$
$LK,"/Demo/Games/Digits.HC",A="FI:::/Demo/Games/Digits.HC"$
$LK,"/Demo/Games/DunGen.HC",A="FI:::/Demo/Games/DunGen.HC"$
$LK,"/Demo/Games/ElephantWalk.HC",A="FI:::/Demo/Games/ElephantWalk.HC"$
$LK,"/Demo/Games/FlapBat.HC",A="FI:::/Demo/Games/FlapBat.HC"$
$LK,"/Demo/Games/FlatTops.HC",A="FI:::/Demo/Games/FlatTops.HC"$
$LK,"/Demo/Games/Halogen.HC",A="FI:::/Demo/Games/Halogen.HC"$
$LK,"/Demo/Games/MassSpring.HC",A="FI:::/Demo/Games/MassSpring.HC"$
$LK,"/Demo/Games/Maze.HC",A="FI:::/Demo/Games/Maze.HC"$
$LK,"/Demo/Games/RainDrops.HC",A="FI:::/Demo/Games/RainDrops.HC"$
$LK,"/Demo/Games/RawHide.HC",A="FI:::/Demo/Games/RawHide.HC"$
$LK,"/Demo/Games/Rocket.HC",A="FI:::/Demo/Games/Rocket.HC"$
$LK,"/Demo/Games/RocketScience.HC",A="FI:::/Demo/Games/RocketScience.HC"$
$LK,"/Demo/Games/Squirt.HC",A="FI:::/Demo/Games/Squirt.HC"$
$LK,"/Demo/Games/Talons.HC",A="FI:::/Demo/Games/Talons.HC"$
$LK,"/Demo/Games/TheDead.HC",A="FI:::/Demo/Games/TheDead.HC"$
$LK,"/Demo/Games/TicTacToe.HC",A="FI:::/Demo/Games/TicTacToe.HC"$
$LK,"/Demo/Games/TreeCheckers.HC",A="FI:::/Demo/Games/TreeCheckers.HC"$
$LK,"/Demo/Games/Varoom.HC",A="FI:::/Demo/Games/Varoom.HC"$
$LK,"/Demo/Games/Wenceslas.HC",A="FI:::/Demo/Games/Wenceslas.HC"$
$LK,"/Demo/Games/Whap.HC",A="FI:::/Demo/Games/Whap.HC"$
$LK,"/Demo/Games/Zing.HC",A="FI:::/Demo/Games/Zing.HC"$
$LK,"/Demo/Games/ZoneOut.HC",A="FI:::/Demo/Games/ZoneOut.HC"$
Unlike Linux and Windows, we do not want to handle all usage models. On the contrary, we want to cherry-pick the hell out of our target usage so we maximize the elegance and simple beauty while delivering something good for $FG,4$$TX,"Hymns",HTML="http://www.templeos.org/Wb/Home/Web/TAD/HymnVideos.html"$$FG$.
If we can define the vector space we hope to span, precisely, then we can leave the operating system on autopilot for future generations. They simply make the best possible solution to the vector space.
Knuth other literate coding homos are wrong -- if you have a well define way of doing things, it usually doesn't matter as long as it is consistent and easy to remember, so you don't vasillate. Try to do things in the way the computer naturally wants to do them. Don't be an arrogant French buffoon. Top-down is ridiculous because you have to make headers for every function. Bottom-up is how a computer wants to do it. In the past, there was a big-endian/little-endian battle. Little endian is obviously the way the computer naturally wants to operate.
Do not bloat a compiler with theoretical optimizations that bad programmers might require. We would rather teach them. As a matter of fact, there is a very straight forward way to convert the C language to machine code.
When I solicit line-of-code reducing optimizations, I plan to make it 100% objective, if possible, and chuckle at the fun, hard-to-understand hacks.
If you have ideas on how to make TempleOS more like Linux, I'm not interested. However, if you have ideas to make it more like the 8-bit computer generation operating systems or like DOS, I am interested. We want the creative spirit of the 8-bit generation of computers.
$FG,8$
* "Linux" is a trademark owned by Linus Torvalds.
* "Windows" is a trademark owned by MicroSoft Corp.
+498
View File
@@ -0,0 +1,498 @@
//This is a customized version of $LK,"::/Demo/ToHtmlToTXTDemo/ToHtml.HC"$.
//$MA-X+PU,"Diff",LM="WinMax;WinBorder;S2T(\"/*\",\"+r+S\");Diff(\"/Demo/ToHtmlToTXTDemo/ToHtml.HC.Z\",\"~/TOS/TOSToHtml.HC.Z\");View;"$
#help_index "DolDoc/Conversion"
//See $LK,"::/Doc/Credits.DD"$.
#define DOCET_UNDEF_COLOR 0x100000000
#define DOCET_LINK_UNDERLINE 0x200000000
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,Bool underline_update,
U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{
U8 *ch,*ptr;
u32_attr&=0xFFFFFF00;
if (u32_attr&DOCET_INVERT)
u32_attr.u8[1]=(u32_attr.u8[1]&15)<<4|u32_attr.u8[1]>>4;
if (underline_update &&
!(u32_attr&DOCET_UNDERLINE) && *_old_u32_attr&DOCET_UNDERLINE) {
if (!(*_old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc,"</u>");
*_old_u32_attr&=~DOCET_LINK_UNDERLINE;
}
if (!(u32_attr&DOCET_BLINK) && *_old_u32_attr&DOCET_BLINK)
DocPrint(doc,"</blink>");
if (u32_attr&0xFF00!=*_old_u32_attr&0xFF00) {
if (!(*_old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc,"</span>");
DocPrint(doc,"<span class=c%02X>",u32_attr.u8[1]);
if (style_bitmap)
LBts(style_bitmap,u32_attr.u8[1]);
}
if (u32_attr&DOCET_BLINK && !(*_old_u32_attr&DOCET_BLINK))
DocPrint(doc,"<blink>");
if (underline_update) {
if (u32_attr&DOCET_UNDERLINE && !(*_old_u32_attr&DOCET_UNDERLINE))
DocPrint(doc,"<u>");
} else //Keep same underline status.
u32_attr=u32_attr&~DOCET_UNDERLINE | *_old_u32_attr&DOCET_UNDERLINE;
*_old_u32_attr=u32_attr | *_old_u32_attr&DOCET_LINK_UNDERLINE;
while (ch=*st++) {
switch (ch) {
case '\t':
do {
DocPutKey(doc,CH_SPACE,0);
*_col=*_col+1;
} while (*_col&7);
break;
start:
case 'ã': ptr="pi"; break;
case 'é': ptr="theta"; break;
case 'è': ptr="phi"; break;
case 'ê': ptr="omega"; break;
case 'ì': ptr="inf"; break;
case 'æ': ptr="u"; break;
end:
DocPrint(doc,ptr);
*_col=*_col+StrLen(ptr);
break;
start:
case CH_SHIFT_SPACE: ptr=" "; break;
case '&': ptr="&amp;"; break;
case '<': ptr="&lt;"; break;
case '>': ptr="&gt;"; break;
case '"': ptr="&quot;"; break;
end:
DocPrint(doc,ptr);
*_col=*_col+1;
break;
default:
if (CH_SPACE<=ch<0x7F || ch=='\n')
DocPutKey(doc,ch,0);
else
DocPrint(doc,".");
*_col=*_col+1;
}
}
}
U8 *TOSLinkCvt2(U8 *filename,I64 line_num)
{// ::/ --> http://www.templeos.org/Wb/
//Make your own LinkCvt routine
U8 *res=NULL,*st;
if (filename) {
st=ChgExt(filename,"html");
if (st && StrLen(st)>3 && !StrNCmp(st+1,":/",2))
res=MStrPrint(PERSONAL_WEB "/%s#l%d",st+3,line_num);
Free(st);
}
return res;
}
U8 *URLBibleGateway(U8 *src)
{
U8 buf[STR_LEN],*dst=buf;
if (!MemCmp(src,"BF:",3))
src+=3;
while (*src) {
if (*src==CH_SPACE || *src==',')
*dst++='+';
else
*dst++=*src;
src++;
}
*dst=0;
if (StrOcc(buf,'-'))
return MStrPrint(
"http://www.biblegateway.com/passage/?search=%s&version=NIV",buf);
else
return MStrPrint(
"http://www.biblegateway.com/verse/en/%s",buf);
}
U8 *TOSLinkCvt1(U8 *link_st)
{
static CDoc *bible=NULL;
static I64 locks=0;
U8 *res=NULL,*filename,*needle;
I64 i,num;
if (link_st) {
switch (i=EdLinkCvt(link_st,&filename,&needle,&num)) {
case LK_FILE_LINE:
case LK_PLAIN_LINE:
case LK_FILE:
res=TOSLinkCvt2(filename,num);
break;
case -1:
case LK_DEF:
case LK_HELP_INDEX:
case LK_DOC:
case LK_DOC_ANCHOR:
case LK_DOC_FIND:
case LK_DOC_LINE:
break;
case LK_BIBLE_FIND:
while (LBts(&locks,0))
Yield;
if (!bible)
bible=Adam("DocRead(\"%s\");",filename);
if (DocFind(bible,num,needle))
res=URLBibleGateway(link_st);
LBtr(&locks,0);
break;
default:
if (DocFileEd(i,filename,needle,&num,EDF_UNCOLLAPSE|EDF_BAIL))
res=TOSLinkCvt2(filename,num);
}
Free(filename);
Free(needle);
}
return res;
}
public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
U8 *body_footer=NULL,U8 *html_footer=NULL,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$doc to HTML file.
CDocEntry *doc_e,*style,*doc_e2;
I64 i,y,old_y=I64_MIN,col,old_u32_attr=DOCET_UNDEF_COLOR,old_attr,digits;
U32 *hl,*src;
U8 *st,st_2[2],*link_st,*style_bitmap=CAlloc(256/8);
CBGR48 p[COLORS_NUM];
GrPaletteGet(p);
CDoc *doc_out=DocNew;
Bool unlock_doc_in=DocLock(doc_in),no_bwd;
old_attr=doc_in->win_task->text_attr;
doc_in->win_task->text_attr=DOC_ATTR_DFT_TEXT;
for (i=0xF0;i<=0xFF;i++)
LBts(style_bitmap,i);
DocRecalc(doc_in,RECALCt_NORMAL|RECALCF_TO_HTML);
digits=Log10(doc_in->head.last->y+1)+1;
st_2[0]=0; st_2[1]=0;
doc_out->flags|=DOCF_PLAIN_TEXT|DOCF_NO_CURSOR;
if (!html_header) html_header=
"<!DOCTYPE HTML>\n"
"<html>\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\" "
"content=\"text/html;charset=US-ASCII\">\n"
"<meta name=\"generator\" content=\"$TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$\">\n";
if (!body_header) body_header=
"<body>\n"
"<pre style=\"font-family:courier;font-size:10pt\">\n";
if (!body_footer) body_footer=
"</pre></body>\n</html>\n";
if (!html_footer) html_footer=
"</html>\n";
DocPrint(doc_out,"%s",html_header);
DocPrint(doc_out,"<style type=\"text/css\">\n");
style=doc_out->cur_entry->last;
DocPrint(doc_out,
"</style>\n"
"</head>\n");
DocPrint(doc_out,"%s",body_header);
doc_e=doc_in->head.next;
col=doc_e->x;
y=doc_e->y;
while (doc_e!=doc_in) {
if (!(doc_e->de_flags&DOCEF_SKIP)) {
if (y!=old_y) {
if (line_anchors)
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
if (line_nums)
DocPrint(doc_out,"%0*d ",digits,y+1);
old_y=y;
}
while (y<doc_e->y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&old_u32_attr,FALSE,
"\n",&col,style_bitmap);
if (++y!=old_y) {
if (line_anchors)
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
if (line_nums)
DocPrint(doc_out,"%0*d ",digits,y+1);
old_y=y;
}
col=0;
}
no_bwd=TRUE;
doc_e2=doc_e->next;
while (doc_e2!=doc_in && doc_e2->y==doc_e->y) {
if (doc_e2->x<doc_e->x) {
no_bwd=FALSE;
break;
}
doc_e2=doc_e2->next;
}
if (no_bwd)
while (col<doc_e->x)
HtmlPutS(doc_out,doc_e->settings.final_u32_attr&~DOCET_UNDERLINE,
&old_u32_attr,TRUE," ",&col,style_bitmap);
link_st=NULL;
if (doc_e->de_flags&DOCEF_HTML_LINK)
link_st=StrNew(doc_e->html_link);
else if (st=DocEntryLink(doc_in,doc_e)) {
link_st=link_cvt(st);
Free(st);
}
if (link_st) {
if (old_u32_attr&DOCET_UNDERLINE &&!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=DOCET_UNDEF_COLOR|DOCET_UNDERLINE|DOCET_LINK_UNDERLINE;
DocPrint(doc_out,"<a href=\"%s\">",link_st);
}
switch (doc_e->type_u8) {
case DOCT_TEXT:
if (doc_e->de_flags&DOCEF_HIGHLIGHT) {
if (doc_e->last==doc_in)
MemCpy(&doc_e->settings,&doc_in->settings_head,
sizeof(CDocSettings));
else
MemCpy(&doc_e->settings,&doc_e->last->settings,
sizeof(CDocSettings));
src=hl=DocHighlight(doc_e,doc_e->tag,StrLen(doc_e->tag),
doc_e->type&0xFF00);
while (*src) {
st_2[0]=*src&0xFF;
HtmlPutS(doc_out,*src++,&old_u32_attr,TRUE,
st_2,&col,style_bitmap);
}
Free(hl);
} else {
if (doc_e->de_flags&DOCEF_CENTER_X && //$BK,1$Nonstandard$BK,0$
doc_e->settings.final_u32_attr&0xF00==PURPLE<<8)
DocPrint(doc_out,"<h1><center>");
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,TRUE,doc_e->tag,&col,style_bitmap);
if (doc_e->de_flags&DOCEF_CENTER_X && //$BK,1$Nonstandard$BK,0$
doc_e->settings.final_u32_attr&0xF00==PURPLE<<8)
DocPrint(doc_out,"</center></h1>");
}
break;
case DOCT_TAB:
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&old_u32_attr,TRUE,
"\t",&col,style_bitmap);
break;
case DOCT_HTML_CODE:
if (old_u32_attr&DOCET_UNDERLINE &&
!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=DOCET_UNDEF_COLOR;
DocPrint(doc_out,"%s",doc_e->tag);
break;
case DOCT_SPRITE:
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,TRUE,doc_e->tag,&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,TRUE,"/* Graphics Not Rendered in HTML */",
&col,style_bitmap);
break;
default:
if (doc_e->de_flags&DOCEF_TAG)
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,TRUE,doc_e->tag,&col,style_bitmap);
}
if (link_st) {
if (old_u32_attr&DOCET_UNDERLINE &&!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
DocPrint(doc_out,"</a>");
old_u32_attr=DOCET_UNDEF_COLOR|DOCET_UNDERLINE|DOCET_LINK_UNDERLINE;
Free(link_st);
}
}
doc_e=doc_e->next;
}
while (y++<doc_e->y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,TRUE,"\n",&col,style_bitmap);
col=0;
}
if (old_u32_attr&DOCET_UNDERLINE && !(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=DOCET_UNDEF_COLOR;
DocPrint(doc_out,"%s",body_footer);
DocPrint(doc_out,"%s",html_footer);
doc_out->cur_entry=style->next;
for (i=0;i<256;i++)
if (Bt(style_bitmap,i))
DocPrint(doc_out,
".c%02X{color:#%02x%02x%02x;background-color:#%02x%02x%02x;}\n",
i,p[i&15].r>>8,p[i&15].g>>8,p[i&15].b>>8,
p[i/16].r>>8,p[i/16].g>>8,p[i/16].b>>8);
doc_out->cur_entry=&doc_out->head;
DocRecalc(doc_out);
doc_in->win_task->text_attr=old_attr;
if (unlock_doc_in)
DocUnlock(doc_in);
return doc_out;
}
#help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)"
public U0 TOSToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,U8 *html_footer=NULL,
I64 width=80,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$file to HTML.
//Supply your own link_cvt routine.
U8 *in_name,*out_name;
CDoc *doc_in,*doc_out;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinHorz(0,width-1); //Sets doc width for word wrap.
in_name=DftExt(_in_name,"HC.Z");
if (_out_name)
out_name=DftExt(_out_name,"html");
else
out_name=ChgExt(_in_name,"html");
doc_in=DocRead(in_name);
DocTop(doc_in);
DocPrint(doc_in,"$$BD,LTCYAN$$"); //$BK,1$Nonstandard$BK,0$
doc_out=Doc2Html(doc_in,html_header,body_header,body_footer,html_footer,
line_anchors,link_cvt,line_nums);
StrCpy(&doc_out->filename.name,out_name);
SettingsPop;
DocWrite(doc_out);
DocDel(doc_in);
DocDel(doc_out);
Free(in_name);
Free(out_name);
}
#help_index "Misc/TOS"
U0 TOSWebFile(U8 *name,Bool line_nums=FALSE)
{
U8 *name2;
CDirEntry de;
Bool line_anchors;
if (FileFind(name,&de)) {
Free(de.full_name);
"File:%s\n",name;
Collapse(name,FALSE);
Touch(name,"",,de.datetime);
name2=ChgExt(name,"html");
if (StrMatch(BLOG_BASE,name) || StrMatch(DAILY_BASE,name))
line_anchors=FALSE;
else
line_anchors=TRUE;
TOSToHtml(name,name2,
"<!DOCTYPE HTML>\n"
"<html style=\"background-color:#FFFFFF;\">\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\" "
"content=\"text/html;charset=US-ASCII\">\n"
"<title>The Temple Operating System</title>\n"
"<meta name=\"keywords\" "
"content=\"Operating System,64-Bit,64 Bit,"
"Temple,OS,TempleOS,Free,Open Source,Public Domain,x86_64\">\n"
"<meta name=\"generator\" content=\"$TX,"TempleOS V5.01",D="DD_OS_NAME_VERSION"$\">\n",
"<body style=\"background-color:#55FFFF; border-style:solid;
border-width:8px; border-color:#0000AA;
margin-left:auto; margin-right:auto; width:800px; \">\n"
"<pre style=\"font-family:courier;font-size:10pt\">\n"
"<div style=\"margin-left:auto; margin-right:auto;"
" width: 640px;\">\n",
"</div></pre></body>\n",
"</html>\n",,line_anchors,,line_nums);
Touch(name2,"",,de.datetime);
Free(name2);
}
}
U0 FreshenWebDir(U8 *dirname,Bool line_nums=FALSE)
{//No recurse
CDirEntry *tmpde,*tmpde1;
U8 *src,*dst;
src=MStrPrint("D:/Wb%s",dirname);
MkDir(src);
Free(src);
src=MStrPrint("D:/Wb%s/*",dirname);
Del(src);
Free(src);
src=MStrPrint("C:%s/*",dirname);
dst=MStrPrint("D:/Wb%s",dirname);
Copy(src,dst);
Free(src);
Free(dst);
src=MStrPrint("D:/Wb%s/*",dirname);
tmpde=tmpde1=FilesFind(src,FUF_JUST_FILES|FUF_JUST_TXT|FUF_CLUSTER_ORDER);
while (tmpde) {
TOSWebFile(tmpde->full_name,line_nums);
tmpde=tmpde->next;
}
DirTreeDel(tmpde1);
}
public U0 FreshenSite()
{//Regen html files in D:/Wb
CDirEntry *tmpde,*tmpde1;
DocClear;
Cd("D:/Wb");
DelTree("D:/Wb/Home/Books1");
DelTree("D:/Wb/Home/Books2");
DelTree("D:/Wb/Home/Budget");
DelTree("D:/Wb/Home/Private");
Del("D:/Wb/Home/*");
Touch("D:/Wb/Home/Web/index.DD.Z","");
Touch("D:/Wb/Home/Web/DownloadOS.DD.Z","");
Touch("D:/Wb/Home/Web/TempleOS.DD.Z","");
tmpde=tmpde1=FilesFind("*",
FUF_RECURSE|FUF_JUST_FILES|FUF_JUST_TXT|FUF_CLUSTER_ORDER);
while (tmpde) {
TOSWebFile(tmpde->full_name);
tmpde=tmpde->next;
}
DirTreeDel(tmpde1);
FreshenWebDir("/Home/Sup1/Sup1Words",TRUE);
Drv('C');
}