A TempleOS distro for heretics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

136 lines
15 KiB

$WW,1$$FG,5$$TX+CX,"Welcome to TempleOS"$$FG$
TempleOS is a x86_64, multi-cored, non-preemptive multi-tasking, ring-0-only, single-address_mapped (identity-mapped), operating system for recreational programming. Paging is almost not used.
The people whom can most benefit are:
$ID,2$* Professionals doing hobby projects
* Teenagers doing projects
* Non-professional, older-persons projects
$ID,-2$
Simplicity is a goal to $LK,"keep the line count down",A="FI:::/Doc/Strategy.DD"$, so it's easy to tinker with. As it turns-out, simplicity makes it faster in some ways, too. It never switches privilege levels, never changes address maps, tends to load whole contiguous files and other, similar things which boost speed. It's only $TX,"82,150",D="DD_TEMPLEOS_LOC"$ lines of code including the kernel, the 64-bit compiler, the graphics library and all the tools. More importantly, it's designed to keep the user's line count down -- you can do a $LK,"Hello World",A="FI:::/Doc/HelloWorld.DD"$ application in one line of code and can put graphics on the scrn with a three line program!
It's a kayak, not a Titanic -- it will crash if you do something wrong. You quickly reboot, however. DOS and the 8-bit home computers of the 80's worked fine without memory protection and most computers in the world -- the embedded ones -- operate without protection. The resulting simplicity of no protections is why TempleOS has value. In facts, that's the point of TempleOS. See the $LK,"TempleOS Charter",A="FI:::/Doc/Charter.DD"$.
Conventional thinking is "failure is not an option" for general purpose operating systems. Since this OS is used in addition to Windows or Linux, however, failure is an option -- just use Windows or Linux if you can't do something. I cherry-pick what it will and won't do, to make it maximally beautiful. The following applications more or less form a basis that spans the range of use that TempleOS is intended for:
$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/Talons.HC",A="FI:::/Demo/Games/Talons.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/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"$
$LK,"/Apps/Psalmody/Examples/childish.HC",A="FI:::/Apps/Psalmody/Examples/childish.HC"$
$LK,"/Apps/Psalmody/Examples/night.HC",A="FI:::/Apps/Psalmody/Examples/night.HC"$
$LK,"/Apps/Psalmody/Examples/prosper.HC",A="FI:::/Apps/Psalmody/Examples/prosper.HC"$
Two things to know about TempleOS are that $UL,1$tasks$UL,0$ have $LK,"MAlloc",A="MN:MAlloc"$/$LK,"Free",A="MN:Free"$ heap memory, not applications, and tasks have compiler symbol tables that persist at a scope like environment variables in other operating systems, and the symbols can include functions.
For other operating systems, I hated learning one language for command line scripts and another for programming. With $FG,2$TempleOS$FG$, the command line feeds right into the $LK,"HolyC",A="FI:::/Doc/HolyC.DD"$ compiler, line by line, and it places code into memory it $LK,"MAlloc",A="MN:MAlloc"$()s. The compiler is paused at the command line, waiting for input. Naturally, you $FG,2$#include$FG$ a program to load it into memory and, usually, start it.
During the boot process, many files get $LK,"compiled",A="FI:::/StartOS.HC"$ before you have access to the command line. (Don't worry, booting takes only two seconds.) All the header declarations for the operating system are compiled and are available for use in your programs without needing to $FG,2$#include $FG$them. Everything is truly compiled to native $FG,2$$TX,"x86_64",HTML="http://en.wikipedia.org/wiki/Amd64#AMD64"$$FG$ machine code, nothing is $FG,2$interpreted$FG$ and there is no $FG,2$byte code$FG$.
Statements at the global scope -- outside the scope of functions -- execute immediately. There is no $FG,2$main()$FG$ function. Instead, you give meaningful names to what would be $FG,2$main()$FG$ functions and you invoke them by calling them with a statement in the global scope, usually at the bottom of your file.
I started with $FG,2$C$FG$ syntax, but didn't like the command line for a directory listing looking like this:
>$FG,2$Dir("*.*",FALSE);
$FG$So, I added default args from $FG,2$C++$FG$ and it looked like this:
>$FG,2$Dir();
$FG$I didn't like that, so I made parentheses optional on calls with no args and it, now, looks like this:
>$FG,2$Dir;$FG$
The syntax change created an ambiguity when specifying function addresses, like for calling $LK,"QSort",A="MN:QSort"$(). To resolve it, I made a '$FG,2$&$FG$' required in front of function names when specifying an address of a function, which is better anyway.
Once I was no longer using standard C/C++ syntax, I decided to change everything I didn't like and call it $LK,"HolyC",A="FI:::/Doc/HolyC.DD"$. Here are the new $LK,"operator precedence",A="FF:::/Doc/HolyC.DD,operator precedence"$ rules. It's Biblical! See $LK,"Luke,5:37",A="BF:Luke,5:37"$.
There are no object files in TempleOS and, normally, you don't make executable files either, but you can. That's known as $LK,"Ahead-of-Time",A="FF:::/Doc/Glossary.DD,AOT Compile Mode"$ compilation. Instead, you $LK,"Just in Time",A="FF:::/Doc/Glossary.DD,JIT Compile Mode"$ compile.
Tasks have no priority and are never removed from the queue. Instead, they often poll whatever they are waiting on and swap-out. (Swapping tasks takes half a microsecond and does not involve disk activity or memory maps.) See $LK,"Scheduler",A="FL:::/Kernel/Sched.HC,1"$. Polling keeps it simple. It might be a problem if you had lots of tasks busy, which rarely happens on a home computer. The order of the tasks in the queue determines front-to-back window order.
The $FG,2$FAT32$FG$ filesystem is supported to makes exchanging files with a dual booted other operating system easy and there is the simple, 64-bit TempleOS $LK,"RedSea",A="FI:::/Doc/RedSea.DD"$ filesystem. The $LK,"RedSea",A="FI:::/Doc/RedSea.DD"$ has allocation bitmap for clus and all files are stored contiguously. You can't grow files.
TempleOS is geared toward reading and writing whole files. Since whole files are processed, compression is possible. Filenames ending in "$FG,2$.Z$FG$" are automatically compressed or uncompressed when stored and fetched. TempleOS does support direct block random access into files, however -- $LK,"FBlkRead",A="MN:FBlkRead"$() and $LK,"FBlkWrite",A="MN:FBlkWrite"$().
If a file is not found, "$FG,2$.Z$FG$" is added or removed and a search is done, again. There is no $FG,2$PATH$FG$, but parent directories are searched when a file is not found. This feature is especially useful for default account files.
The graphic resolution is poor, $FG,2$640x480 16 color$FG$, but God said it was a covenant like circumcision. Also, that's all I feel comfortable with without GPU acceleration supported. A $FG,2$1600x1200x24$FG$ bit scrn takes 37 times more memory, implying 37 times the CPU power. Also, a fixed size keeps it simple with everybody machine having the same appearance. Look on the bright-side -- you won't spend as much time twiddling pixels for your game art and you'll have tons of CPU power available, especially with multicore systems.
TempleOS is for hobbyist programmers on single user (at a time) home computers, not mainframes or servers. The focus task is all-important so symmetrical multiprocessing is almost pointless. Why does it matter running two apps at the same time twice as fast when you really want to run one faster? You could say TempleOS does master/slave multiprocessing. The anticipated use for multicore is primarily putting graphics on the scrn. Hardware graphics acceleration is not used, so this is possible. See $LK,"TempleOS MultiCore",A="FI:::/Doc/MultiCore.DD"$.
There is no distinction between the terms $FG,2$task$FG$, $FG,2$process$FG$ or $FG,2$thread$FG$. All have a task record, $LK,"CTask",A="MN:CTask"$, pointed to by the $FG,2$FS$FG$ segment reg and are accessed with $FG,4$Fs->$FG$ while $FG,4$Gs->$FG$ points to a $LK,"CCPU",A="MN:CCPU"$ for the current CPU core. Each task can have just one window, but a task can have children with windows. (The segment regs are just used as extra regs -- there is nothing segmented about TempleOS' memory.) It is approximately the case that $FG,2$TempleOS$FG$ is multi-threading, single-processing.
In $FG,2$TempleOS$FG$, $LK,"Adam Task",A="FF:::/Doc/Glossary.DD,Adam Task"$$FG$ refers to the father of all tasks. He's never supposed to die. Since tasks inherit the symbols of parents, system-wide stuff is associated with $FG,2$Adam$FG$. His heap is like kernel memory in other operating systems. Since $FG,2$Adam$FG$ is immortal, it's safe to alloc objects, not tied to any mortal task, from $FG,2$Adam$FG$'s heap. He stays in a server mode, taking requests, so you can ask him to $FG,2$#include$FG$ something, placing that code system-wide. A funny story is that originally I called it the $FG,2$root$FG$ task and even had a $FG,2$/Root$FG$ directory :-) $FG,2$Adam$FG$ executes $LK,"::/StartOS.HC"$ at boot time.
For easy back-ups, place everything you author in your $FG,2$/Home$FG$ directory and subdirectories. Then, use $LK,"CopyTree",A="MN:CopyTree"$(). That should make upgrading easy, too. Customizable start-up scripts go in your $FG,2$/Home$FG$ directory. The default start-up scripts are in the root directory. Copy the start-up files you wish to customize into $FG,2$/Home$FG$ and modify them. See $LK,"Home Files",A="FF:::/Doc/GuideLines.DD,/Home Files"$. You can make your own distro that includes everything and is a bootable live CD with $LK,"::/Misc/DoDistro.HC"$.
Typically, your usage pattern through the day will be repeatedly left or right clicking on filenames in a cmd line $LK,"Dir",A="MN:Dir"$() listing. You left-click files to edit them and right-click to $FG,2$#include$FG$ them. To begin a project, type $LK,"Ed",A="MN:Ed"$("filename");, supplying a filename. You can also run programs with $FG,2$<F5>$FG$ when in the editor. $FG,2$<ESC>$FG$ to save and exit the file. You'll need to do a new $LK,"Dir",A="MN:Dir"$() cmd, periodically, so make a macro on your PersonalMenu. Access your PersonalMenu by pressing $FG,2$<CTRL-m>$FG$, cursoring until you are on top of it and pressing $FG,2$<SPACE>$FG$.
$FG,2$<CTRL-t>$FG$ toggles plain text mode, showing format commands, a little like viewing html code.
$FG,2$<CTRL-l>$FG$ inserts a text widgets.
$FG,2$<CTRL-r>$FG$ inserts or edit a graphic sprite resource at cursor location.
$FG,2$<CTRL-d>$FG$ brings-up the file manager. It's pretty crappy. I find I don't need it very often, believe it or not.
$FG,2$<CTRL-b>$FG$ toggles window border.
$FG,2$<ALT-m>$FG$ maximizes a window.
$FG,2$<ALT-SHIFT-a>$FG$ closes AutoComplete.
$FG,2$<ALT-a>$FG$ brings back AutoComplete.
$FG,2$<ALT-v>$FG$ vertically tiles windows.
$FG,2$<ALT-h>$FG$ horizontally tiles windows.
The $FG,2$ALT$FG$ keys are defined in $LK,"~/HomeKeyPlugIns.HC"$. You can customize them.
$FG,2$<CTRL-ALT-t>$FG$ new terminal window.
$FG,2$<CTRL-ALT-n>$FG$ switches to the next window.
$FG,2$<CTRL-ALT-x>$FG$ kills a window.
$LK,"Find",A="MN:Find"$() is your best friend. There's a wrapper function called $LK,"F",A="MN:F"$() in your $FG,2$~/HomeWrappers.HC.Z$FG$ file. Feel free to make wrapper functions for functions you use often and customize the args. By the way, $LK,"Find",A="MN:Find"$() or $LK,"R",A="MN:R"$() can be used to replace strings across multiple files. You can access $LK,"Find",A="MN:Find"$() using $FG,2$<CTRL-SHIFT-f>$FG$.
As you browse code, use the $FG,2$AutoComplete$FG$ window to look-up functions, etc. $FG,2$<CTRL-SHIFT-F1>$FG$ (or whatever number) to follow a sym to it's source. You can browse deeper and deeper. You go back with $FG,2$<SHIFT-ESC>$FG$.
Use the $LK,"Help & Index",A="FI:::/Doc/HelpIndex.DD"$ or $LK,"Demo Index",A="FI:::/Doc/DemoIndex.DD"$ to find-out what exists. Press $FG,2$<F1>$FG$ for help or use the links on your menu ($FG,2$<CTRL-m>$FG$). Also, look in the $FG,2$/Demo$FG$ or $FG,2$/Apps$FG$ directories for inspiration.
Software is distributed as $LK,"RedSea",A="FI:::/Doc/RedSea.DD"$ ISO files. Burn a CD/DVD, or set your CD/DVD in $FG,2$QEMU$FG$, $FG,2$VMware$FG$ or $FG,2$VirtualBox$FG$ to the ISO file. Then, access the $FG,2$'T'$FG$ drive. Or, $LK,"Mount",A="MN:Mount"$() the ISO.C file and access the $FG,2$'M'$FG$ drive in TempleOS. It must be a contiguous ISO.C file, so rename it under TempleOS to ISO.C.
Ideally, do not install applications such as games onto your hard drive because we wish to keep hard drive usage low, so the whole $FG,2$'C'$FG$ drive can be copied quickly to $FG,2$'D'$FG$. Also, the $LK,"FileMgr",A="MN:FileMgr"$() $FG,2$<CTRL-d>$FG$ starts too slowly when there are lots of hard drive files, but that is how we want it.
3rd party libraries are banned, since they circumvent the 100,000 line of code limit in the $LK,"TempleOS Charter",A="FI:::/Doc/Charter.DD"$. All applications must only depend on the core TempleOS files and whatever they bring along in the ISO. This is similar to how Commodore 64 applications only depended on the ROM.
Create a $LK,"RedSea",A="FI:::/Doc/RedSea.DD"$ ISO file with $LK,"RedSeaISO",A="MN:RedSeaISO"$(). Send an email to $TX,"tdavis@templeos.org",HTML="mailto:tdavis@templeos.org"$ if you want me to post a link to your TempleOS code in the App Store.
$MA-X+PU,"Take Tour",LM="User(\"Cd(\\\"::/Misc/Tour\\\");;InFile(\\\"Tour\\\");\n\");"$
$FG,8$
* "Linux" is a trademark owned by Linus Torvalds.
* "Windows" is a trademark owned by MicroSoft Corp.
* "Commodore 64" is a trademark owned by Polabe Holding NV.
* "QEMU" is a trademark owned by Fabrice Bellard.
* "VMware" is a trademark owned by VMware, Inc.
* "VirtualBox" is a trademark owned by Oracle.
$FG$