TempleOSTS_140317.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:02 +02:00
1 parent 2d2a65d572
commit 7ef616a20e
1416 files changed
+223873 -53917

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
#include "/Accts/Adam3bPkgs"
#include "/Apps/MusicOrgan/Load"
Cd("HOME");;
#include "/Accts/TS/TSAdam"
#include "/Accts/TS/TSDistro"
#include "/Accts/TS/TSHolySpirit"
Cd("HOME");;
+202
View File
@@ -0,0 +1,202 @@
//Change anything you want in this
//acct file or others.
U0 FillInTime()
{
CDate cdt;
cdt=Now;
"$$IV,1$$----%D %T----$$IV,0$$\n",cdt,cdt;
}
Bool MyPutKey(I64 ch,I64 sc)
{ //ch=ASCII; sc=scancode
//See $LK,"Char",A="HI:Char"$ for definition of scan codes.
//See $LK,"Keyboard Handling",A="FI:::/Doc/KeyBoard.TXT"$
//You can customize keys. This routine
//is called before the main editor
//key handler $LK,"DocPutKey",A="MN:DocPutKey"$().
//You can intercept any key.
//Return TRUE if you completely
//handled the key.
I64 i,sc2=sc.u8[0];
if (SC_F1<=sc2<=SC_F10 &&
sc&SCF_ALT &&
!(sc & SCF_CTRL)) {
switch (sc2) {
case SC_F1:
if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTPURPLE");
else
SetKeyDesc("Dollar/PURPLE");
} else {
if (sc & SCF_SHIFT)
"$$LTPURPLE$$";
else
"$$PURPLE$$";
}
break;
case SC_F2:
if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTRED");
else
SetKeyDesc("Dollar/RED");
} else {
if (sc & SCF_SHIFT)
"$$LTRED$$";
else
"$$RED$$";
}
break;
case SC_F3:
if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTGREEN");
else
SetKeyDesc("Dollar/GREEN");
} else {
if (sc & SCF_SHIFT)
"$$LTGREEN$$";
else
"$$GREEN$$";
}
break;
case SC_F4:
if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTBLUE");
else
SetKeyDesc("Dollar/Default Color");
} else {
if (sc & SCF_SHIFT)
"$$LTBLUE$$";
else
"$$FG$$";
}
break;
case SC_F7:
if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT)
SetKeyDesc("Misc/Insert My URL");
else
SetKeyDesc("Misc/Insert Datetime");
} else {
if (sc & SCF_SHIFT)
FillInMyURL;
else
FillInTime;
}
break;
}
return TRUE;
} else {
if (!(sc & SCF_CTRL)) {
if (sc & SCF_ALT) {
switch (ch) {
case 'h':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Tile Horizontally");
else
WinTileHorz;
return TRUE;
case 'm':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Maximize");
else {
WinMax;
WinBorder;
}
return TRUE;
case 'v':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Tile Vertically");
else
WinTileVert;
return TRUE;
case 'V':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Sys/Frame Grabber Toggle");
else
FrameGrabberToggle;
return TRUE;
case 'l':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Put Link to Cur Pos on Clipboard");
else {
ClipboardDel;
DocPrint(sys_clipboard_doc,"$$LK,\"FL:%s,%d\"$$",
DocPut->filename.name,DocPut->cur_entry->y+1);
}
return TRUE;
case 'L':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Place Anchor, Put Link to Clipboard");
else {
i=RandU32;
ClipboardDel;
DocPrint(sys_clipboard_doc,"$$LK,\"<TODO>\",A=\"FA:%s,ANC%d\"$$",
DocPut->filename.name,i);
"$$AN,\"<TODO>\",A=\"ANC%d\"$$",i;
}
return TRUE;
case 'w':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/WordStat(ON);");
else
WordStat(ON);
return TRUE;
case 'W':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/WordStat;");
else
WordStat;
return TRUE;
//Ins your own ALT-key plug-ins
case 'b':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Cmd/Jump to Bad Code");
else //$LK,"::/Adam/God/HSNotes.TXT"$
BadCodeJump;
return TRUE;
case 'g':
if (sc&SCF_KEY_DESC)
SetKeyDesc("BlogScreenShot");
else
BlogScreenShot;
return TRUE;
case 'p':
if (sc&SCF_KEY_DESC)
SetKeyDesc("JukeBox(TAD)");
else
JukeBox("::/Accts/TS/TAD/MusicOrgan");
return TRUE;
case 'P':
if (sc&SCF_KEY_DESC)
SetKeyDesc("JukeBox(Examples)");
else
JukeBox("::/Apps/MusicOrgan/Examples");
return TRUE;
}
}
}
}
return FALSE;
}
Bool MyPutS(U8 *)
{
return FALSE;
}
KeyDevAdd(&MyPutKey,&MyPutS,0x20000000,TRUE);
+58
View File
@@ -0,0 +1,58 @@
U0 UserStartUp()
{ //Run each time a user a spawned
DocTermNew;
Type("::/Doc/Start.TXT");
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
Dir;
switch (ts_cid) {
case CID_TAD8:
"$$GREEN$$TAD8$$FG$$:";
break;
case CID_TAD8_VM:
"$$RED$$TAD8_VM$$FG$$:";
break;
case CID_DFT:
"$$PURPLE$$DFT$$FG$$:";
break;
}
"$TX,"81,527",D="DD_TEMPLEOS_LOC_OFFICIAL"$LOC:";
CPURep;
}
U0 SrvStartUp()
{ //Run each time a srv task is spawned.
DocTermNew;
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
}
CTask *user1,*user2;
U0 StartUpTasks()
{
user1=SpawnUser;
user2=SpawnUser;
WinToTop(user1);
WinTileVert;
PopUp("#include \"::/Adam/Start\";");
"Boot Time:%7.3fs\n",tS;
XTalk(user1,"Cd(\"HOME\");#include \"DoOnce\";\n");
Silent(ON);
WSInit("/*;~*Bible.TXT*");
Silent(OFF);
"WordStat Time:%7.3fs\n",tS;
if (ts_has_win_drv)
DrvEnable(TS_WIN_DRV_LET,OFF);
}
DelTree("::/Temp/ScreenShots");
MkDir("::/Temp/ScreenShots");
StartUpTasks;
"\nOS Compile Time:%D %T\n",sys_compile_time,sys_compile_time;
+51
View File
@@ -0,0 +1,51 @@
#exe {OptOn(OPTf_WARN_PAREN);};
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
HashTablePurge(adam_task->hash_table);
#help_index "Misc"
public F64 os_version=2.03;
#include "AdamExt.HPP"
#include "Math2a"
#include "Training"
#include "Utils2a"
#include "MathODE"
Dbg("Type 'G;'");
Cd("::/Adam/Gr");;
#include "Gr"
Cd("::/Adam/Snd");;
#include "Snd"
Cd("::/Adam/Dsk");;
#include "Dsk2"
Cd("::/Adam");;
#include "Menu"
#include "Win2a"
#include "Win2b"
#include "Dbg2a"
Cd("::/Adam/Doc");;
#include "Doc"
LBts(&sys_run_level,RLf_DOC);
Cd("::/Adam/Ctrls");;
#include "Ctrls"
Cd("::/Adam");;
#include "AutoFile2a"
#include "LogIn"
Cd("::/Adam/WordStat");;
#include "WordStat"
Cd("::/Adam");;
#include "Hash2a"
#include "TaskSettings"
#include "DevInfo"
#include "DocDefines"
+12
View File
@@ -0,0 +1,12 @@
//This file is executed by the
//first terminal window upon start-up.
//See $LK,"DoOnce",A="FF:HOME/Adam3eSys.CPP,DoOnce"$ and $LK,"Acct Files",A="FF:::/Doc/GuideLines.TXT,ACCT FILES"$.
//It goes in your HOME directory and
//you can customize it.
//Delete this to get rid of
//default start-up msg.
//Type("::/Doc/Customize.TXT");
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
$TR,"Adam"$
$ID,2$$TR,"SysMsgFlags"$
$ID,2$sys_msg_flags[0]=0;
$ID,-2$$TR,"SysRegVer"$
$ID,2$registry_version=2.030;
$ID,-2$$ID,-2$
+15
View File
@@ -0,0 +1,15 @@
OptOn(OPTf_WARN_PAREN);
OptOn(OPTf_WARN_DUP_TYPES);
SetTypeMatic(0);
local_time_offset=-7*60*60*CDATE_FREQ; //Pacific
//$AN,"",A="mouse_move_scale"$adjust these to set mouse move scale
mxx_scale=0.5;
myy_scale=0.5;
mzz_scale=5.0; //wheel
//don't change these
mxx_prescale=mxx/mxx_scale;
myy_prescale=myy/myy_scale;
mzz_prescale=mzz/mzz_scale;
+199
View File
@@ -0,0 +1,199 @@
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1374957505">Accounts</H3>
<DL><p>
<DT><A HREF="https://www.annualcreditreport.com/cra/index.jsp" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >AnnualCreditReport</A>
<DT><A HREF="http://software.intel.com/partner/app/dashboard" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Dashboard Intel® Developer Zone</A>
<DT><A HREF="http://www.dell.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://i.dell.com/images/global/branding/dellecomicon.ico" >Dell Laptops, Desktop Computers, Monitors, Printers & PC Accessories</A>
<DT><A HREF="https://www.mymedicare.gov/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >mymedicare.gov Portal of Personalized Medicare Information</A>
<DT><A HREF="https://www.paypal.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Send Money, Money Transfer - PayPal</A>
<DT><A HREF="http://www.socialsecurity.gov/onlineservices/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.socialsecurity.gov/favicon.ico" >Social Security Online What You Can Do Online</A>
<DT><A HREF="http://www.wellsfargo.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Wells Fargo Home Page</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1389105117">Commonly Quoted</H3>
<DL><p>
<DT><A HREF="http://www.youtube.com/watch?v=eB5VXJXxnNU" ADD_DATE="1381134432" LAST_VISIT="1386666617" LAST_MODIFIED="1389105618" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >Ali G Homo Sapien</A>
<DT><A HREF="http://www.wired.com/magazine/2010/11/mf_ticketmaster/all/1" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Everyone Hates Ticketmaster — But No One Can Take It Down Magazine</A>
<DT><A HREF="http://stevehanov.ca/blog/index.php?id=56" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >How a programmer reads your resume (comic) - Steve Hanov's Programming Blog</A>
<DT><A HREF="http://wayback.archive.org/web/*/www.losethos.com" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://wayback.archive.org/favicon.ico" >Internet Archive (LoseThos)</A>
<DT><A HREF="http://waybackmachine.org/*/http://www.simstructure.hare.com" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Internet Archive (SimStructure)</A>
<DT><A HREF="http://www.youtube.com/watch?v=Dd7FixvoKBw" ADD_DATE="1379786905" LAST_VISIT="1386666617" LAST_MODIFIED="1389105613" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >Key Peele #1</A>
<DT><A HREF="http://www.youtube.com/watch?v=VHG_Gv_zLY4" ADD_DATE="1384979305" LAST_VISIT="1386666617" LAST_MODIFIED="1389105621" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >Key Peele #2</A>
<DT><A HREF="http://lmgtfy.com/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://lmgtfy.com/favicon.ico" >Let me google that for you</A>
<DT><A HREF="http://unusedino.de/ec64/technical/project64/mapping_c64.html" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://unusedino.de/favicon.ico" >Mapping The C64</A>
<DT><A HREF="http://www.youtube.com/watch?feature=player_embedded&v=nj6DK_WX7Yc#!" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://s.ytimg.com/yt/favicon-refresh-vfldLzJxy.ico" >The Magic of CES - YouTube#!</A>
<DT><A HREF="http://www.noob.us/humor/the-office-dwight-faces-nerd-torture-of-the-highest-form/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.noob.us/favicon.ico" >The Office - Dwight faces nerd torture of the highest form</A>
<DT><A HREF="http://www.youtube.com/watch?v=HRPDO63rI1E" ADD_DATE="1381122671" LAST_VISIT="1386666617" LAST_MODIFIED="1389105665" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >The Prisoner</A>
<DT><A HREF="http://www.youtube.com/watch?v=o_eSwq1ewsU" ADD_DATE="1381122683" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://s.ytimg.com/yts/img/favicon-vfldLzJxy.ico" >There... Are... Four... Lights! - YouTube</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957505">Downloads</H3>
<DL><p>
<DT><A HREF="http://www.ccs64.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Commodore 64 Emulator</A>
<DT><A HREF="http://ffmpeg.zeranoe.com/builds/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >FFmpeg</A>
<DT><A HREF="http://www.dandans.com/Full-Video-Audio-Mixer.htm" ADD_DATE="1375786853" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.dandans.com/webico.ico" >Full Video Audio Mixer, Mix & Merge Audio and Video, Extract & Remove Audio from Video</A>
<DT><A HREF="http://www.winimage.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Gilles Vollant software</A>
<DT><A HREF="https://www.virtualbox.org/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Oracle VM VirtualBox</A>
<DT><A HREF="http://www.qb64.net/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >QB64</A>
<DT><A HREF="http://www.phatcode.net/downloads.php?id=280" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >turbo assembler 5 (tasm)</A>
<DT><A HREF="http://www.vmware.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >VMware Virtualization Software for Desktops, Servers & Virtual Machines for Public and Private Cloud Solutions</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957505">Games</H3>
<DL><p>
<DT><A HREF="http://www.classicempire.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >EMPIRE, Wargame of the Century (tm) index</A>
<DT><A HREF="http://www.freeciv.net/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Freeciv.net - online multiplayer strategy game</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1389102772">Links</H3>
<DL><p>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957505">Media Streams</H3>
<DL><p>
<DT><A HREF="http://www.bbc.co.uk/?ok" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >BBC - bbc.co.uk homepage - Home of the BBC on the Internet</A>
<DT><A HREF="http://www.bbc.co.uk/iplayer/console/bbc_world_service" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >BBC iPlayer - Listen live - BBC World Service</A>
<DT><A HREF="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Free Online Course Materials Electrical Engineering and Computer Science MIT OpenCourseWare</A>
<DT><A HREF="http://ocw.mit.edu/OcwWeb/web/home/home/index.htm" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Free Online Course Materials MIT OpenCourseWare</A>
<DT><A HREF="http://www.gametrailers.com/news.php" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Gametrailers.com - Video Games News, Game Trailers News</A>
<DT><A HREF="http://www.komp.com/" ADD_DATE="1389413520" LAST_VISIT="1389413520" LAST_MODIFIED="1389413520" >komp Homepage - LV Portal - Homepage</A>
<DT><A HREF="http://openclassroom.stanford.edu/MainFolder/HomePage.php" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >OpenClassroom</A>
<DT><A HREF="http://webcast.berkeley.edu/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >webcast.berkeley UC Berkeley Video and Podcasts for Courses & Events</A>
<DT><A HREF="http://www.xtremeradio.com/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >X107.5 X-treme Radio Las Vegas, NV - Homepage</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957504">Misc</H3>
<DL><p>
<DT><A HREF="http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >140 Google Interview Questions Seattle Interview Coach</A>
<DT><A HREF="http://blog.smartbear.com/programming/7-silly-programming-challenges-to-do-for-fun/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1389105588" ICON_URI="http://blog.smartbear.com/wp-content/uploads/dynamik-gen/theme/images/favicon.png" >7 Silly Programming Challenges to Do for Fun</A>
<DT><A HREF="http://petr-mitrichev.blogspot.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://petr-mitrichev.blogspot.com/favicon.ico" >Algorithm problems for dummies Petr Mitrichev's blog</A>
<DT><A HREF="http://www.youtube.com/watch?v=p-_RHRAzUHM" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Flying with the fastest birds on the planet Peregrine Falcon & Gos Hawk - Animal Camera - BBC - YouTube</A>
<DT><A HREF="http://harkavagrant.com/index.php?id=296" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://harkavagrant.com/favicon.ico" >Hark, a vagrant 296</A>
<DT><A HREF="http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1389102608" ICON_URI="http://www.tldp.org/favicon.ico" >Linux Filesystem Hierarchy</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957504">People</H3>
<DL><p>
<DT><A HREF="http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/" ADD_DATE="1377013922" LAST_VISIT="1386666616" LAST_MODIFIED="1389102919" ICON_URI="http://www.altdevblogaday.com/favicon.ico" >Carmack #AltDevBlog</A>
<DT><A HREF="http://scpd.stanford.edu/knuth/index.jsp" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Computer Musings by Professor Donald E. Knuth Stanford University Online</A>
<DT><A HREF="http://www-cs-faculty.stanford.edu/~knuth/index.html" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Don Knuth's Home Page</A>
<DT><A HREF="http://www.insight.org/site/PageServer" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Insight For Living Chuck Swindoll's Bible-teaching via articles, books, audio, and devotionals</A>
<DT><A HREF="http://torvalds-family.blogspot.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Linus' blog</A>
<DT><A HREF="http://www.hawking.org.uk/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Stephen Hawking - Home</A>
<DT><A HREF="http://www.escapistmagazine.com/articles/view/editorials/zeropunctuation" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >The Escapist Zero Punctuation</A>
<DT><A HREF="http://www.thegatesnotes.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >The Gates Notes</A>
<DT><A HREF="http://www.linuxfoundation.org/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.linuxfoundation.org/sites/www.linuxfoundation.org/themes/opensourcery/favicon.ico" >The Linux Foundation</A>
<DT><A HREF="http://www.slingshotchannel.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >The Slingshot Channel's Official Website</A>
<DT><A HREF="http://pdos.csail.mit.edu/6.828/2012/xv6.html" ADD_DATE="1388187282" LAST_VISIT="1388187282" LAST_MODIFIED="1388187282" >Xv6, a simple Unix-like teaching operating system</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957504">Research</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1389105041">Operating Systems</H3>
<DL><p>
<DT><A HREF="http://stochastix.wordpress.com/2009/01/31/distance-between-two-words/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389106385" ICON_URI="http://1.gravatar.com/blavatar/97f8320d71ee1387cf94dbb722633e25?s=16" >Distance between two words « Reasonable Deviations</A>
<DT><A HREF="http://misc.aspell.net/wiki/English_Dictionaries" ADD_DATE="1384796381" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >English Dictionaries - AspellWiki</A>
<DT><A HREF="http://help.yahoo.com//l/us/yahoo/smallbusiness/webhosting/gftp/ftps-04.html#g" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://help.yahoo.com/favicon.ico" >How to setup FTPS tool - Yahoo! Small Business Help</A>
<DT><A HREF="http://msdn.microsoft.com/en-us/library/windows/hardware/ff559006(v=vs.85).aspx" ADD_DATE="1375962144" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://msdn.microsoft.com/Areas/Epx/Themes/Windows/Content/Winlogo_favicon.ico" >IDENTIFY_DEVICE_DATA structure (Windows Drivers)</A>
<DT><A HREF="http://arstechnica.com/information-technology/2012/10/linux-foundation-to-offer-signed-solution-for-uefi-secure-boot-conundrum/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Linux Foundation to offer signed solution for UEFI Secure Boot conundrum Ars Technica</A>
<DT><A HREF="http://www.linuxfoundation.org/news-media/blogs/browse/2012/10/linux-foundation-uefi-secure-boot-system-open-source" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Linux Foundation UEFI Secure Boot System for Open Source The Linux Foundation</A>
<DT><A HREF="http://www.pcworld.com/article/2011669/linux-foundation-unveils-a-new-solution-for-win-8-secure-boot.html" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Linux Foundation unveils a workaround for Win 8 Secure Boot PCWorld</A>
<DT><A HREF="http://academicearth.org/courses/operating-systems-and-system-programming" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Operating Systems and System Programming Berkeley Video Course</A>
<DT><A HREF="http://partedmagic.com/doku.php" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >start – Parted Magic</A>
</DL><p>
<DT><A HREF="http://www.hongkiat.com/blog/pixel-art-tutorials/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://mediatemplestatic.hongkiat.netdna-cdn.com/logo/hkdc/favicon.ico" >30 Excellent Pixel Art Tutorials For Pixel Lovers</A>
<DT><A HREF="http://bigocheatsheet.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Big-O Algorithm Complexity Cheat Sheet</A>
<DT><A HREF="https://www.circuitlab.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >CircuitLab sketch, simulate, and share your circuits</A>
<DT><A HREF="http://www.sparknotes.com/writing/style/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Grammar, Usage, and Style Guide SparkNotes Ultimate Style Ultimate Style</A>
<DT><A HREF="http://imgur.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://imgur.com/favicon.ico" >imgur the simple image sharer</A>
<DT><A HREF="http://software.intel.com/en-us/" ADD_DATE="1386626088" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://software.intel.com/sites/all/themes/isn3/favicon.ico" >Intel® Developer Zone</A>
<DT><A HREF="http://www.archive.org/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Internet Archive Digital Library of Free Books, Movies, Music & Wayback Machine</A>
<DT><A HREF="http://www.netlib.org/lapack/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >LAPACK — Linear Algebra PACKage</A>
<DT><A HREF="http://www.gutenberg.org/wiki/Main_Page" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.gutenberg.org/favicon.ico" >Main Page - Gutenberg</A>
<DT><A HREF="http://www.moreofit.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389102467" ICON_URI="http://www.moreofit.com/favicon.ico" >moreofit - Website Similarity Search Engine</A>
<DT><A HREF="http://www.peoplesmart.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389105190" ICON_URI="http://www.peoplesmart.com/favicon.ico" >People Search & Background Checks by Name, Phone, Email or Address - PeopleSmart</A>
<DT><A HREF="http://promo.net/pg/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >PROJECT GUTENBERG OFFICIAL HOME SITE - INDEX -- Free Books On-Line -</A>
<DT><A HREF="http://validator.w3.org/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >The W3C Markup Validation Service</A>
<DT><A HREF="http://www.whorush.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >WHORush.com, your source for information on domains</A>
<DT><A HREF="http://www.wolframalpha.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >WolframAlpha Computational Knowledge Engine</A>
<DT><A HREF="http://youtubetime.com/" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >YouTube Time</A>
<DT><A HREF="http://www.metacrawler.com/info.metac/dog/index.htm" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >[ MetaCrawler® ]</A>
<DT><A HREF="http://validator.w3.org/check?uri=http%3A%2F%2Flynx.isc.org%2Findex.html" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >[Valid] Markup Validation of http--lynx.isc.org-index.html - W3C Markup Validator</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957503">Spiritual</H3>
<DL><p>
<DT><A HREF="http://www.biblegateway.com/passage/?search=1+Corinthians+14&version=NIV" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389330204" ICON_URI="http://static5.bgcdn.com/favicon.ico?ca05b3df" >1 Corinthians 14 NIV - Intelligibility in Worship Follow the - Bible Gateway</A>
<DT><A HREF="http://qrng.anu.edu.au/NIST.php" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://qrng.anu.edu.au/favicon.ico" >ANU Quantum Random Number Server</A>
<DT><A HREF="http://www.generatedata.com/" ADD_DATE="1383350304" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >generatedata.com</A>
<DT><A HREF="https://qrng.physik.hu-berlin.de/download" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >QRNG Service - Download</A>
<DT><A HREF="http://random.irb.hr/index.php" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://random.irb.hr/favicon.ico" >Quantum Random Bit Generator Service</A>
<DT><A HREF="http://www.randomnumbers.info/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Random Numbers Info</A>
<DT><A HREF="http://www.random.org/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.random.org/favicon.ico" >RANDOM.ORG - True Random Number Service</A>
<DT><A HREF="https://www.fourmilab.ch/hotbits/secure_generate.html" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="https://www.fourmilab.ch/favicon.ico" >Request HotBits (Secure Server)</A>
<DT><A HREF="http://www.theyshootpictures.com/gf1000_all1000films.htm" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >TSPDT - The 1,000 Greatest Films (Full List)</A>
<DT><A HREF="http://www.usccb.org/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.usccb.org/favicon.ico" >United States Conference of Catholic Bishops</A>
<DT><A HREF="http://virtual-notary.org/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1387238161" ICON_URI="http://virtual-notary.org/static/favicon.png" >Virtual-Notary</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1374957503">TempleOS Business</H3>
<DL><p>
<DT><A HREF="http://betanews.com/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://betanews.com/wp-content/themes/betanews/favicon.ico" >BetaNews</A>
<DT><A HREF="http://www.devmaster.net/forums/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >DevMaster.net Forums - Powered by vBulletin</A>
<DT><A HREF="http://www.gamedev.net/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >GameDev.net - all your game development needs</A>
<DT><A HREF="http://www.majorgeeks.com/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.majorgeeks.com/favicon.ico" >MajorGeeks.com - Download Freeware and Shareware Computer Utilities</A>
<DT><A HREF="http://www.youtube.com/watch?v=6WgOWrT1yyI&feature=youtu.be&a" ADD_DATE="1381667845" LAST_VISIT="1386666617" LAST_MODIFIED="1387406101" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >Mum Tries Out TempleOS 1.06 (2013) - YouTube</A>
<DT><A HREF="http://www.businessconsultingabc.com/Feedback.html" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.businessconsultingabc.com/wp-content/themes/business-consulting-abc/favicon.ico" >Send Us Feedback Email ABC Business Consulting ABC Business Consulting</A>
<DT><A HREF="http://www.sparrowos.com/" ADD_DATE="1375793135" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.sparrowos.com/favicon.ico" >Sparrow Operating System</A>
<DT><A HREF="http://www.losethos.com/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" ICON_URI="http://www.losethos.com/favicon.ico" >The LoseThos Operating System</A>
<DT><A HREF="http://www.google.com/webmasters/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.google.com/favicon.ico" >Webmasters – Google</A>
</DL><p>
<DT><H3 FOLDED ADD_DATE="1389105242">Uncommon</H3>
<DL><p>
<DT><A HREF="http://irc.netsplit.de/channels/details.php?room=%23%23programming&net=freenode" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1389102778" ICON_URI="http://irc.netsplit.de/favicon.ico" >##programming freenode - Chat Room on IRC - irc.netsplit.de</A>
<DT><A HREF="http://politicalhumor.about.com/library/bl-political-cartoons.htm" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >2012 Political Cartoons - Best Political Cartoons of 2012</A>
<DT><A HREF="http://english.aljazeera.net/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >AJE - Al Jazeera English</A>
<DT><A HREF="http://www.amazon.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1389106076" ICON_URI="http://www.amazon.com/favicon.ico" >amazon.com Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more</A>
<DT><A HREF="http://www.huffingtonpost.com/" ADD_DATE="1386981098" LAST_VISIT="1386981098" LAST_MODIFIED="1386981098" ICON_URI="http://www.huffingtonpost.com/favicon.ico" >Breaking News and Opinion on The Huffington Post</A>
<DT><A HREF="http://www.dailyrotation.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >DAILY ROTATION</A>
<DT><A HREF="http://www.dzone.com/links/index.html" ADD_DATE="1378720139" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.dzone.com/favicon.ico" >dzone.com - fresh links for developers</A>
<DT><A HREF="http://www.hackforums.net/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Hack Forums</A>
<DT><A HREF="http://hckrnews.com/" ADD_DATE="1377987384" LAST_VISIT="1386666616" LAST_MODIFIED="1387840046" ICON_URI="http://hckrnews.com/img/touch/apple-touch-icon.png" >hckr news - Hacker News sorted by time</A>
<DT><A HREF="http://www.shellcity.net/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389105474" ICON_URI="http://www.shellcity.net/favicon.ico" >http--www.shellcity.net-</A>
<DT><A HREF="http://chat.icq.com/icqchat/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >ICQ Chat Rooms - ICQ.com</A>
<DT><A HREF="http://iopscience.iop.org/1367-2630" ADD_DATE="1374957505" LAST_VISIT="1386666617" LAST_MODIFIED="1389105799" ICON_URI="http://iopscience.iop.org/favicon.ico" >iopscience Journal of Physics</A>
<DT><A HREF="http://www.irc.org/links.html" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >IRC.org</A>
<DT><A HREF="http://www.haaretz.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Israel News - Haaretz Israeli News source</A>
<DT><A HREF="https://lobste.rs/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1389102792" ICON_URI="https://lobste.rs/favicon.ico" >Lobsters</A>
<DT><A HREF="http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=IStart" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >MSN.com</A>
<DT><A HREF="http://www.physorg.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >PhysOrg.com - Science News, Technology, Physics, Nanotechnology, Space Science, Earth Science, Medicine</A>
<DT><A HREF="http://www.chess.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Play Chess Online - Free Chess Games at Chess.com</A>
<DT><A HREF="http://gogloom.com/DIR?cat=84126&catdesc=Programming" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Programming CHAT ROOMS - Online CHAT!</A>
<DT><A HREF="http://royal.pingdom.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Royal Pingdom</A>
<DT><A HREF="http://www.infopackets.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >Tech News Daily - Infopackets.com</A>
<DT><A HREF="http://www.techbeta.org/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >TechBeta Free and open source software for Windows, Mac OS X, Linux, iPhone, and Mobile</A>
<DT><A HREF="http://www.techcrunch.com/" ADD_DATE="1374957503" LAST_VISIT="1386666617" LAST_MODIFIED="1386666617" >TechCrunch</A>
<DT><A HREF="http://www.tomshardware.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Tom's Hardware Hardware News, Tests and Reviews</A>
<DT><A HREF="http://news.yahoo.com/" ADD_DATE="1374957505" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://news.yahoo.com/favicon.ico" >Yahoo! News - Latest News & Headlines</A>
<DT><A HREF="http://www.yahoo.com/" ADD_DATE="1374957504" LAST_VISIT="1386666617" LAST_MODIFIED="1389106215" ICON_URI="http://l.yimg.com/rz/l/favicon.ico" >Yahoo!</A>
</DL><p>
<DT><A HREF="http://www.4chan.org/" ADD_DATE="1375781470" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://s.4cdn.org/image/favicon.ico" >4chan</A>
<DT><A HREF="http://arstechnica.com/index.ars" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Ars Technica</A>
<DT><A HREF="http://dictionary.reference.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://static.sfdict.com/dictcloud/favicon.ico" >Dictionary</A>
<DT><A HREF="http://www.drudgereport.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >DRUDGE</A>
<DT><A HREF="http://www.facebook.com/home.php" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Facebook</A>
<DT><A HREF="https://www.google.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="https://www.google.com/favicon.ico" >Google</A>
<DT><A HREF="http://news.ycombinator.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Hacker News</A>
<DT><A HREF="http://www.knpr.org/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.knpr.org/favicon.ico" >Nevada Public Radio</A>
<DT><A HREF="http://beacon.nist.gov/home" ADD_DATE="1383959013" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >NIST Randomness Beacon (Prototype Implementation) - NIST</A>
<DT><A HREF="http://forum.osdev.org/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://forum.osdev.org/favicon.ico" >OSDev.org • Index page</A>
<DT><A HREF="http://www.osnews.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.osnews.com/favicon.ico" >OSNews is Exploring the Future of Computing</A>
<DT><A HREF="http://www.pixeljoint.com/forum/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.pixeljoint.com/favicon.ico" >Pixel Joint Forum</A>
<DT><A HREF="http://popurls.com/" ADD_DATE="1378004893" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://popurls.com/favicon.ico" >popurls the genuine news aggregator for the latest web buzz</A>
<DT><A HREF="http://www.reddit.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666968" ICON_URI="http://www.redditstatic.com/icon.png" >reddit.com</A>
<DT><A HREF="http://slashdot.org/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://slashdot.org/favicon.ico" >slashdot News for nerds, stuff that matters</A>
<DT><A HREF="http://stackoverflow.com/" ADD_DATE="1381508264" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://cdn.sstatic.net/stackoverflow/img/favicon.ico" >Stack Overflow</A>
<DT><A HREF="http://www.templeos.org/logs/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.templeos.org/favicon.ico" >TempleOS Index of -logs</A>
<DT><A HREF="http://www.templeos.org/Wb/Accts/TS/Wb2/Rants/TAD/TADRants.html" ADD_DATE="1389595518" LAST_VISIT="1389595518" LAST_MODIFIED="1389595518" ICON_URI="http://www.templeos.org/favicon.ico" >Terry Davis' Rants</A>
<DT><A HREF="http://www.templeos.org/" ADD_DATE="1375628480" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://www.templeos.org/favicon.ico" >The Temple Operating System</A>
<DT><A HREF="https://twitter.com/" ADD_DATE="1378394318" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="https://abs.twimg.com/favicons/favicon.ico" >Twitter</A>
<DT><A HREF="http://www.wikipedia.org/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" ICON_URI="http://bits.wikimedia.org/favicon/wikipedia.ico" >Wikipedia</A>
<DT><A HREF="http://smallbusiness.yahoo.com/services/index.php?crumb=eynoh/GoPXd" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386666616" >Yahoo! Small Business</A>
<DT><A HREF="http://www.youtube.com/" ADD_DATE="1374957503" LAST_VISIT="1386666616" LAST_MODIFIED="1386677085" ICON_URI="http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png" >YouTube - Broadcast Yourself</A>
</DL><p>
+115
View File
@@ -0,0 +1,115 @@
//Be sure to Adam Include this.
#help_index "Comm"
#define COM1_BASE 0x3F8
#define COM2_BASE 0x2F8
#define COM3_BASE 0x3E8
#define COM4_BASE 0x2E8
#define UART_THR 0
#define UART_RDR 0
#define UART_BRDL 0
#define UART_IER 1
#define UART_BRDH 1
#define UART_IIR 2
#define UART_LCR 3
#define UART_MCR 4
#define UART_LSR 5
#define UART_MSR 6
I64 comm_base[5]={0,0x3F8,0x2F8,0x3E8,0x2E8};
CFifoU8 *comm_fifos[5]={NULL,NULL,NULL,NULL,NULL};
interrupt U0 CommInt3Handler()
{
I64 base=comm_base[2];
if (comm_fifos[2] && (InU8(base+UART_IIR) & 0xFE)==8) //RX IRQ
FifoU8Ins(comm_fifos[2],InU8(base+UART_RDR));
base=comm_base[4];
if (comm_fifos[4] && (InU8(base+UART_IIR) & 0xFE)==8) //RX IRQ
FifoU8Ins(comm_fifos[4],InU8(base+UART_RDR));
OutU8(0x20,0x20);
}
interrupt U0 CommInt4Handler()
{
I64 base=comm_base[1];
if (comm_fifos[1] && (InU8(base+UART_IIR) & 0xFE)==8) //RX IRQ
FifoU8Ins(comm_fifos[1],InU8(base+UART_RDR));
base=comm_base[3];
if (comm_fifos[3] && (InU8(base+UART_IIR) & 0xFE)==8) //RX IRQ
FifoU8Ins(comm_fifos[3],InU8(base+UART_RDR));
OutU8(0x20,0x20);
}
IntEntrySet(0x23,&CommInt3Handler);
IntEntrySet(0x24,&CommInt4Handler);
public U0 CommInit8n1(I64 port,I64 baud)
{
I64 base=comm_base[port];
PUSHFD
CLI
if (comm_fifos[port])
FifoU8Del(comm_fifos[port]);
comm_fifos[port]=FifoU8New(256);
OutU8(base+UART_LCR,0); //Set for IER
OutU8(base+UART_IER,0); //DIsable all IRQ
OutU8(base+UART_LCR,0x80); //Enable baud rate control
OutU8(base+UART_BRDL,(0x180/(baud/300)) & 0xFF); //LSB
OutU8(base+UART_BRDL,(0x180/(baud/300)) / 256); //MSB
OutU8(base+UART_LCR,3); // 8-none-1
InU8(base+UART_RDR); //read garbage
InU8(base+UART_LSR);
OutU8(base+UART_MCR,4);
OutU8(base+UART_IER,0); //DIsable all IRQ
OutU8(base+UART_MCR,0xA); //out2 and rts
OutU8(0x21,InU8(0x21) & (0xFF-0x18)); //Enable 8259 IRQ 3 & 4
OutU8(base+UART_IER,1); //Enable RX IRQ
POPFD
}
public U0 CommBusyPutChar(I64 port,U8 b)
{
I64 base=comm_base[port];
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
OutU8(base+UART_THR,b);
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
}
public U0 CommBusyPutS(I64 port,U8 *st)
{
I64 base=comm_base[port];
U8 b;
while (b=*(st++)) {
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
OutU8(base+UART_THR,b);
}
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
}
public U0 CommBusyWriteBlk(I64 port,U8 *buf,I64 count)
{
I64 base=comm_base[port];
while (count--) {
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
OutU8(base+UART_THR,*(buf++));
}
while (!(InU8(base+UART_LSR) & 0x20))
Yield;
}
#help_index ""
+245
View File
@@ -0,0 +1,245 @@
* Backward SHIFT-F3 is broken
* Exception msgs in Adam look bad
3sGCGCqCCe2G3EE2G3qDetDEFsDBDB
* $LK,"Mem32DevAlloc",A="MN:Mem32DevAlloc"$() is broken. Devices should be in free spot of E820 report.
* $$DA-U64+I16
* SPRITES in CMD Line code.
* get rid of clusters once RedSea
* Might want to move kernel code out of low 2Meg.
* F2 Macro on TestSuite
* PSect search all tables if not found very well.
* Bug: HI:Math/CD3
* asm LIST NOLIST bug
* Bible ranges.
* Current Bible position to link on clipboard.
* No way to clear +Hold entries
---------------------
$$=-CTASK_NEG_OFFSET
offset(CTask.addr)==0
Spawn(): CAlloc()
TaskFinishOff(): Free()
CSysFixedArea.adam
Looks like task_flags,locked_flags cause problems with neg offset.
---------------------
* $$CM+LE+RE is nasty
* Wenceslas in TestSuite crashes, long time ago
* 12/26/13 Mountain in TestSuite didn't run right. Turned yellow, did nothing.
* FAQ frontloaded
COMPILER
* Postpone LocalVar Init until last possible moment. (in case RETURN)
* PtrArith MUL SIZE -->QueIns(MUL)?
* QueRem(IC_NOP)?
* Fix return result for GrBlot, ect.
* Tour TestSuite on 256Meg NoMP runs out of mem. Leak,too?
* CTRL-R transform individual elements
* Size zero files don't copy out from VMware.
* FileMgr header
* ATA/ATAPI ID in VMware, when not booted to CD? I forgot.
* I use fixed-point in $LK,"Circle",A="MN:Circle"$(), $LK,"Ellipse",A="MN:Ellipse"$(), $LK,"GrRot",A="MN:GrRot"$(), $LK,"GrMulMat",A="MN:GrMulMat"$() and others.
God says I might want to change to float.
$LK,"::/Demo/Lectures/FixedPoint.CPP"$.
$LK,"::/Demo/Lectures/FixedPointAdvanced.CPP"$.
* DOCF_DBL_DOLLARS in reindention
* # in reindention
* reindent $LK,"DocRecalc",A="MN:DocRecalc"$().skip_soft_cr
* HexEdit with odd size, ASCII cannot be edited.
* clean-up addDev pmt
* Might want to convert some Preempt() to Cli
* Music organ hangs when cursoring around. Haven't seen in while.
* $LK,"Plain",A="MN:Plain"$() might be better not saving $LK,"CH_CURSOR",A="MN:CH_CURSOR"$.
* TRANSPARENT might not work with line ROPF_DITHER
* It would be nice if $LK,"U",A="MN:U"$() NOP were better.
* unhandled exception on MP message gets overwritten by WinMgr
* Cmd to enable/disable compiler warnings
* What if we had a type for either F64 or I64, like Print -- no conversion.
* What if we had a ... that did do conversion, if we have one that doesn't.
* fix documentation problem -- remembering 0 terminator in str or not for $$DA
* GetS, crazy putkey code
* editor page formatting is FUBAR
* $LK,"gr_screen_image",A="MN:gr_screen_image"$
>Might want to do ZOOM in U8 graphics and convert screen capture to U8
>Might want to reverse bit order
* return vals for grrect, grblot, grputchar?
* collisions for grrect, grblot, grputchar?
* Race condition in FlatTops.CPP.Z torpedo
* {Lock|Rep}{Seg|2E=NotBr|3E=Br}{OP}{ADD}{REX}
* Virtual Box MP reboot
* Std local var names
* EIT_ABS_ADDR 64
//After Egypt possible future ideas
//$LK,"Numbers,13:33",A="BF:Numbers,13:33"$ scouts
//$LK,"Numbers,21:8",A="BF:Numbers,21:8"$ snakes
* GrEdit: Move sidebar selected elems.
- Be careful of multipt elems.
* GrEdit: Strip origin shift cmds.
* GrEditBitMap, grabscroll?
* extern of fun with dft arg of str?
* We kinda need a routine to return how much free memory, so that applications can plan a big alloc.
* FileMgr bad with lots of files.
* This $LK,"Fs->catch_except=TRUE",A="FF:::/Kernel/SrvCmd.CPP,Fs->catch_except=TRUE"$ causes problems because it catches divide and out-of-mem. Not sure what to do, yet.
* $LK,"MPStart",A="MN:MPStart"$() free old task memory. (Prolly never gonna do anything about this.)
* $LK,"sys_var_init_flag",A="MN:sys_var_init_flag"$ local vars.
* sprite shift pts, ctrl pt for ellipse/polygon w,h is off when rotated.
* Window mgr needs to do DOC operations on posted messages from mouse. Works for $LK,"SetIP",A="MN:SetIP"$(), though.
* Add local vars to sym table in $LK,"Dbg",A="MN:Dbg"$()? (maybe)
* $LK,"Bible sized nodes",A="FF:::/Adam/Doc/DocRecalc2b.CPP,->tag+i"$
* Mouseinstall throws exceptions, doesn't work, investigate Mouse $LK,"0x9FC30",A="FF:::/Kernel/KbdMouse/Mouse.CPP,9FC"$
* get kbd lights working.
* Might have issue with compiler exceptions and restoring lex.hash tables.
* Generates two compiler error messages for expressions in statements.
* release semaphores or break lock sema,usb_td
* Fix Mom's secondary CD-ROM, dad's primary
* pmtstr in install didn't like focus change
*$FG,2$U0 Main()
{
U0 (*fp_old_draw_input_ptr)(CDC *dc,I64 x,I64 y)=fp_draw_input_ptr;
}$FG$
* What about local variable array/struct initialization.
* Demo $LK,"ToHtml",A="MN:ToHtml"$().
* Del short name in FAT32--currently I do not check to see if I have generated a unique short name and one can delete multiple files accidentally. Generating unique short names is a pain in the ass because you have to scan the whole directory. I think I just truncate the name instead of "Program~1" or whatever. S081130-0001.BMP crashed windows--two identical short names.
* OVERSTRIKE at cmd line with menu macro.
* $FG,2$lock{}$FG$ warning on invalid modes.
* Local array vars-->reg.
* $LK,"DCF_SYMMETRY",A="MN:DCF_SYMMETRY"$, before transformation? (Currently it's after)
* all graphics clipping -- screen y+top<0 for top<0
* Maybe convert graphics to float
* Warn unnecessary typecast
* compiler F32
* preempt(OFF) during graphic clipping?
* compiler optimization heap_glbls with added offset
* AOT-compile extern glblvar references.
* extern glbl var in AOT module on data heap.
* Might make FAT32 read in contiguous chunks.
* make Clamp(),Min(),Max() asm routines.
* Might make CSprite flood fill operate on a separate bitmap and blotted at the end.
* autofile popup of popup
* <CTRL-R> delete subsprite in menu near others
* consider changing domenu so a real <ESC> on menu item doesn't select (<SPACE BAR> sends <ESC> followed by <SPACE BAR> or something)
* puts3 with depth buf? might not do this
* make task queins and querem safe for multicore cycling through tasks (fwd).
* make better heapwalk, do something with _CFG_HEAP_DBG.
* log to file--would be inefficient--load-in whole file, modify and write out. Useful, but not very efficient (TempleOS file system has no grow-file ability. Created when FAT patent was an issue and wanted absly nothing people could sue me for.)
* APIC2
* import intel datasheets, somehow?
* Get better dictionary, good spell checker.
* WordStat/Man Jmp for user code.
* Might make DskView show drive colors.
* Might do utility to set drive colors, making a tree entry in Adam 3 using registry-like routines... or registry I guess.
* New Editor widgets
* Make use of flag potential in SysFilesFind and possibly CFileAccess
* implement fixed pos files
* new HolyC language features
* better debugging
* Too much preemption turned off?
* Look for mem leaks.
* Move stuff out of Kernel module.
* $LK,"ROP_XOR",A="MN:ROP_XOR"$ with pen_width>1 is broken.
* RGB wrong in BMP files.
* use width and height in line clipping for pen_width>1 or blot.
* SIMD transformation
* test removable media id (critical for resident files)
* add field overflow U8 "t='*'"
* Implement fmt codes into Get
* Date Input
* Default date fmt
* 16 bit Unassembly is bad--very low priority
* more signed int disassembly
* support r4u8 by adding 0x40 byte
* static var off of data heap.
* Might want to use U32*U32 multiplication.
* could add "const" to not set LF_NOT_CONST flag for trig, etc.
* do r,rm ICCmp like ICBrCmp
* could make glblvar imports use TY_RIP_DISP32.
* PUSH_CMP allocs reg R9 or whatever
* Might be problem with NOP in OPT pass1 for NO_PUSH in expressions besides assignments. Is ShiftNoPush fully implemented?
* NOP1 might need to have diff ic_data's
* in divequal, it assumes about ebx
* error/warning line nums
* ASM branch out warning of range off by 1 line--use lx->last_line_num
* Switch statement with sparse cases (low priority)
* maybe inline functions?
* Use of more floating-point stk?
* More aggressive in this routine $LK,"CmpF2PushPop",A="MN:CmpF2PushPop"$() with types besides MOV and F64.
* !dbl ~dbl
* &=, |= can overflow with Bts Btr on small data types
* num lock comes on with break key
* sort options for findfiles
* recalc_start could be more accurate before recalculating?
* Maybe, get rid of $LK,"0x20000",A="FF:::/Compiler/CmpMain.CPP,0x20000"$ in compiler.
* $TX,"WWW.OSDEV.ORG",HTML="http://www.osdev.org"$
* $FG,4$$TX,"KeyPeele#1",HTML="http://www.youtube.com/watch?v=Dd7FixvoKBw"$$FG$
* $FG,4$$TX,"KeyPeele#2",HTML="http://www.youtube.com/watch?v=VHG_Gv_zLY4"$$FG$
* $FG,4$$TX,"ThePrisoner",HTML="http://www.youtube.com/watch?v=HRPDO63rI1E"$$FG$
* $FG,4$$TX,"WestWorld",HTML="http://www.youtube.com/watch?v=LcL3eP0Hfy4"$$FG$
* $FG,4$$TX,"Picard:FourLights",HTML="http://www.youtube.com/watch?v=o_eSwq1ewsU"$$FG$
* $FG,4$$TX,"Dwight:NerdTorture",HTML="http://www.noob.us/humor/the-office-dwight-faces-nerd-torture-of-the-highest-form"$$FG$
* $FG,4$$TX,"AliG:Homosapiens",HTML="http://www.youtube.com/watch?v=eB5VXJXxnNU&t=2m20s"$$FG$
* $FG,4$$TX,"Dumb Guards",HTML="http://www.youtube.com/watch?v=OdKa9bXVinE"$$FG$
* $FG,4$$TX,"Mapping the Commodore 64",HTML="http://unusedino.de/ec64/technical/project64/mapping_c64.html"$$FG$
* Holy Grail: Lmq5PxHpLNw 1:28:27
+34
View File
@@ -0,0 +1,34 @@
$TR,"Adam"$
$ID,2$$TR,"SysMsgFlags"$
$ID,2$sys_msg_flags[0]=0x53;
$ID,-2$$TR,"SysRegVer"$
$ID,2$registry_version=2.030;
$ID,-2$$ID,-2$$TR,"TempleOS"$
$ID,2$$TR,"DiningStars"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"EagleDive"$
$ID,2$I64 best_score=2;
$ID,-2$$TR,"BlackDiamond"$
$ID,2$I64 best_score=35;
$ID,-2$$TR,"CastleFrankenstein"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"ZoneOut"$
$ID,2$F64 best_score=95.3249;
$ID,-2$$TR,"Varoom"$
$ID,2$F64 best_score=11.8623;
$ID,-2$$TR,"BugBird"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"TimeOut"$
$ID,2$I64 best_score=0;
$ID,-2$$TR,"RawHide"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"KeepAway"$
$ID,2$I64 best_score0=0,best_score1=9999;
$ID,-2$$TR,"XCaliber"$
$ID,2$I64 best_score=70;
I64 msg_flags=1;
$ID,-2$$TR,"Wenceslas"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"BulgeBomber"$
$ID,2$I64 best_score=45;
$ID,-2$$ID,-2$
+440
View File
@@ -0,0 +1,440 @@
Bool IsDrvVMware(U8 drv_let)
{
Bool result=FALSE;
U8 *m=NULL;
try
if ((m=DrvModelNum(drv_let)) &&
!MemCmp(m,"VMware",6))
result=TRUE;
catch
Fs->catch_except=TRUE;
Free(m);
return result;
}
I64 DrvMaxBlk(U8 drv_let)
{
I64 result=0;
CBlkDev *bdev;
try {
if (bdev=Drv2BlkDev(drv_let))
result=bdev->max_blk;
} catch
Fs->catch_except=TRUE;
return result;
}
I64 IsDrvATAPI(U8 drv_let)
{
Bool result=FALSE;
CBlkDev *bdev;
try if ((bdev=Drv2BlkDev(drv_let)) &&
bdev->type==BDT_ATAPI)
result=TRUE;
catch
Fs->catch_except=TRUE;
return result;
}
Bool ChkDrvModelSerial(U8 drv_let,U8 *model,U8 *serial)
{
Bool result;
U8 *m=NULL,*s=NULL;
try {
m=DrvModelNum(drv_let);
s=DrvSerialNum(drv_let);
} catch {
Free(m); Free(s);
m=NULL; s=NULL;
Fs->catch_except=TRUE;
}
if (m && s && !StrCmp(m,model) && !StrCmp(s,serial))
result=TRUE;
else
result=FALSE;
Free(m); Free(s);
return result;
}
#define SLOP BLK_SIZE
U0 TSBootDrv1()
{
CBinFile *bfh=sys_boot_base-sizeof(CBinFile);
bfh(I64)+=bfh->file_size-1;
DefinePrint("TS_BOOT_DRV_START","0x%X",CeilI64(SYS_KERNEL_END+SLOP,BLK_SIZE));
DefinePrint("TS_BOOT_DRV_END", "0x%X",FloorI64(
(BOOT_RAM_LIMIT-(BOOT_STK_SIZE+CD_BOOT_LOADER_SIZE))>>4<<4-
(bfh(I64)-SYS_KERNEL_END)-SLOP,BLK_SIZE));
DefinePrint("CFG_BOOT_DRV_FILE","\"/Temp/BootDrv.BIN.Z\"");
} TSBootDrv1;
U0 TSBootDrv2()
{
DefinePrint("CFG_BOOT_DRV","\"a10x%X\n0x%X\n\"",TS_BOOT_DRV_START,
(TS_BOOT_DRV_END-TS_BOOT_DRV_START)/BLK_SIZE);
DefinePrint("CFG_BOOT_DRV_START","\"0x%X\"",TS_BOOT_DRV_START);
} TSBootDrv2;
U0 TSEmployeeSet()
{
U8 *st=StrNew(sys_acct),*st2=MAllocIdentical(st);
StrLastRem(st,"/",st2);
Free(st);
DefinePrint("TS_EMPLOYEE","\"%s\"",st2);
Free(st2);
} TSEmployeeSet;
U0 TSBlogDirSet()
{
CDate cdt=Now;
DefinePrint("TS_BLOG_DIR","\"/Accts/TS/Wb2/Rants/%s/%04d/%02d\"",
TS_EMPLOYEE,Year(cdt),Month(cdt));
} TSBlogDirSet;
#define CID_DFT 0
#define CID_TAD8 1 //This was my old machine but it died. Booted natively
#define CID_TAD8_VM 2 //It could run booted with physical drive in VMware
//My current machine is TAD9 but it only runs in VMware, so it's CID_DFT
I64 ts_cid=CID_DFT;
U0 TSIDComputer()
{
/* My TAD8 computer died. It had two hard drives. You could
boot it directly or from VMware with a physical drive.
CMemE820 *m20=SYS_MEM_E820;
if (IsDrvVMware('D') && DrvMaxBlk('D')==0x575466EF)
ts_cid=CID_TAD8_VM; //VMware boot of TAD8
else if (ChkDrvModelSerial('D',"Hitachi HDS721075KLA330","GTF202P8H509AF") &&
ChkDrvModelSerial('I',"ST3320620AS","6QF24J0A"))
ts_cid=CID_TAD8; //Regular boot of TAD8
//beware 'S'
else if (*sys_acct=='T' && IsDrvATAPI('T') && m20[11].base==0x100000000 &&
m20[11].base(I64)+m20[11].len-1==0x33FFFFFFF)
ts_cid=CID_TAD8; //CDROM boot of TAD8
*/
} TSIDComputer;
U0 TSInit()
{
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL;
CBlkDev *bdev;
switch (ts_cid) {
/* This machine died, but you can use it as an example.
case CID_TAD8:
case CID_TAD8_VM:
DefinePrint("CFG_ACCT","\"\nTS/TAD\n\"");
DefinePrint("CFG_HARD_DRVS","\"h2s0xbc00\n0xb880\n1d2s0xbc00\n0xb880\n0\"");
DefinePrint("CFG_RAM_DRVS","\"b1\nScale2Mem(2048,0x40000)\n\"");
DefinePrint("CFG_CDROM_DRVS","\"t3s0xb800\n0\"");
DefinePrint("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
if (ts_cid==CID_TAD8) {
DefinePrint("TS_HDS","\"DEI\"");
DefinePrint("TS_MASTER_BOOT_DRVS","\"I\"");
} else { //CID_TAD8_VM
DefinePrint("TS_HDS","\"DE\"");
DefinePrint("TS_MASTER_BOOT_DRVS","\"\"");
}
DefinePrint("TS_MAIN_DRV","\"D\"");
DefinePrint("TS_BAK_DRV","\"E\"");
DefinePrint("TS_RAM_DRV","\"B\"");
DefinePrint("TS_WIN_DRV","\"H\"");
DefinePrint("TS_CDROM_DRV","\"T\"");
break;
*/
case CID_DFT:
DefinePrint("CFG_ACCT","\"\nTS/TAD\n\"");
DefinePrint("CFG_RAM_DRVS","\"b1\nScale2Mem(2048,0x40000)\n\"");
if (sys_auto_mount_ide_cnt) {
//If AutoMount was successful, No need to manually mount in next compile
DefinePrint("CFG_HARD_DRVS","\"\"");
DefinePrint("CFG_CDROM_DRVS","\"\"");
} else {
//These two are a crazy guess. ATA:IDE Primary ATAPI:IDE Secondary
DefinePrint("CFG_HARD_DRVS","\"d2s0x1F0\n0x3F4\n0\"");
DefinePrint("CFG_CDROM_DRVS","\"t3s0x170\n0\"");
bdev=Drv2BlkDev(*sys_acct);
if (bdev->type==BDT_ATAPI) {
ATARep(FALSE,,&root);
ATAIDDrvs(root,*sys_acct,&ata_drv,&atapi_drv);
if (ata_drv)
DefinePrint("CFG_HARD_DRVS","\"d2p%d\n\"",ata_drv->num);
if (atapi_drv)
DefinePrint("CFG_CDROM_DRVS","\"t3p%d\n\"",atapi_drv->num);
} else {
try {
bdev=Drv2BlkDev('D');
DefinePrint("CFG_HARD_DRVS","\"d2s0x%X\n0x%X\n%d\"",
bdev->base0,bdev->base1,bdev->unit);
} catch
Fs->catch_except=TRUE;
try {
bdev=Drv2BlkDev('T');
DefinePrint("CFG_CDROM_DRVS","\"t3s0x%X\n%d\"",bdev->base0,bdev->unit);
} catch
Fs->catch_except=TRUE;
}
}
DefinePrint("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
DefinePrint("TS_HDS","\"DE\"");
DefinePrint("TS_MASTER_BOOT_DRVS","\"D\"");
DefinePrint("TS_MAIN_DRV","\"D\"");
DefinePrint("TS_BAK_DRV","\"E\"");
DefinePrint("TS_BOOT_DRV","\"A\"");
DefinePrint("TS_RAM_DRV","\"B\"");
DefinePrint("TS_WIN_DRV","\"\"");
DefinePrint("TS_CDROM_DRV","\"T\"");
}
} TSInit;
U0 TSInit2()
{
DefinePrint("TS_MAIN_DRV_LET","'%s'",TS_MAIN_DRV);
DefinePrint("TS_BAK_DRV_LET","'%s'",TS_BAK_DRV);
DefinePrint("TS_BOOT_DRV_LET","'%s'",TS_BOOT_DRV);
DefinePrint("TS_RAM_DRV_LET","'%s'",TS_RAM_DRV);
DefinePrint("TS_WIN_DRV_LET","'%s'",TS_WIN_DRV);
DefinePrint("TS_CDROM_DRV_LET","'%s'",TS_CDROM_DRV);
} TSInit2;
Bool ts_has_main_drv =ToBool(StrLen(TS_MAIN_DRV)),
ts_has_bak_drv =ToBool(StrLen(TS_BAK_DRV)),
ts_has_boot_drv =ToBool(StrLen(TS_BOOT_DRV)),
ts_has_ram_drv =ToBool(StrLen(TS_RAM_DRV)),
ts_has_win_drv =ToBool(StrLen(TS_WIN_DRV)),
ts_has_cdrom_drv=ToBool(StrLen(TS_CDROM_DRV));
if (ts_has_main_drv)
SetDrvTextAttr(TS_MAIN_DRV_LET, WHITE <<4|BLUE);
if (ts_has_bak_drv)
SetDrvTextAttr(TS_BAK_DRV_LET, WHITE <<4|RED);
if (ts_has_boot_drv)
SetDrvTextAttr(TS_BOOT_DRV_LET, BLUE <<4|BROWN);
if (ts_has_ram_drv)
SetDrvTextAttr(TS_RAM_DRV_LET, BLUE <<4|YELLOW);
if (ts_has_win_drv)
SetDrvTextAttr(TS_WIN_DRV_LET, LTRED <<4|BLACK);
if (ts_has_cdrom_drv)
SetDrvTextAttr(TS_CDROM_DRV_LET,LTGRAY<<4|BLUE);
#define TS_ISO_NAME TS_RAM_DRV ":/TempleOSCD.ISO"
#define TS_DISTRO_DIR TS_RAM_DRV ":/Distro"
#define CFG_OPTS "AutoMountIDE\nDT\n"
#define CFG_DBG_OPTS "AutoMountIDE\nDT"\
"HeapInit\n130\nMemInit\n131\nVarInit\n132\n\n"
#define CFG_DBGZ_OPTS "AutoMountIDE\nDT"\
"HeapInit\n0\nMemInit\n0\nVarInit\n0\n\n"
#define TS_CFG "\n" CFG_RAM_DRVS CFG_CDROM_DRVS CFG_HARD_DRVS CFG_ACCT CFG_DSK_CACHE CFG_OPTS
#define TS_MENU_CFG "\n" CFG_RAM_DRVS CFG_CDROM_DRVS CFG_HARD_DRVS "\n\n" CFG_DSK_CACHE CFG_OPTS
#define TS_CDROM_CFG "Tb1\n0x20000\nt3 \n\nTS\n\nAutoMountIDE\nDT\n"
#define TS_CDROM_DBG_CFG "A" CFG_BOOT_DRV "b1\nScale2Mem(2048,0x40000)\n\n\n\n"\
"DontProbe\nBootDrv\n" TS_MAIN_DRV ":" CFG_BOOT_DRV_FILE "\n" CFG_BOOT_DRV_START "\n\n"
//$BK,1$Change these, too...$BK,0$
//$MA-X+PU,"STD_DISTRO_CDROM_CFG",LM="F(\"STD_DISTRO_CDROM_CFG\");View;"$
//$LK,"Install Acct",A="FF:::/Accts/Install/DoOnce.CPP,MakeOSPrtBootInstall"$
Bool frame_grabber_on=FALSE;
#define VIDEO_FRAME_RATE 8
U0 FrameGrabberTask(I64)
{
/**** TO MAKE MOVIE ****
TempleOS
<ALT-SHIFT-V>
[Do stuff you want recorded]
<ALT-SHIFT-V>
Boot Windows
Copy /Temp
Download "ffmpeg" from the Internet
>CD SCREENSHOTS
>TSZ .
>ffmpeg -r 8 -i VID%05d.BMP -y Movie.avi
*/
I64 frame_num=0;
U8 buf[136],buf2[136];
F64 end_time=tS;
Silent(ON); //no output to screen
MkDir("::/Temp/ScreenShots");
while (frame_grabber_on) {
SPrint(buf,"::/Temp/ScreenShots/VID%05d.BMP.Z",frame_num++);
StrCpy(buf2,buf);
BMPFileCaptureScreen(buf);
while (TRUE) {
end_time+=1.0/VIDEO_FRAME_RATE;
if (end_time<tS) {
SPrint(buf,"::/Temp/ScreenShots/VID%05d.BMP.Z",frame_num++);
Copy(buf2,buf);
} else
break;
}
SleepUntil(sys_jiffies+(end_time-tS)*JIFFY_FREQ);
}
}
U0 CopyVideo()
{
if (ts_has_bak_drv) {
Del(TS_BAK_DRV ":/Temp/*.SND");
SndFileCreate(TS_BAK_DRV ":/Temp/Audio",0.23,0.0,WF_SQUARE,0.45,0.35);
DelTree(TS_BAK_DRV ":/Temp/ScreenShots");
CopyTree("::/Temp/ScreenShots",TS_BAK_DRV ":/Temp/ScreenShots");
}
}
public U0 FrameGrabberToggle()
{
static F64 last_time=0;
if (tS-last_time>3.0) {
last_time=tS;
if (frame_grabber_on) {
frame_grabber_on=FALSE;
Snd(0);
wallpaper_record_on=snd_record=FALSE;
Sleep(1000);
CopyVideo;
} else {
frame_grabber_on=TRUE;
Spawn(&FrameGrabberTask,NULL,"Frame Grabber");
wallpaper_record_on=snd_record=TRUE;
Snd(0);
}
}
}
U0 JukeSongsPut(U8 *dir,I64 start_song,I64 end_song)
{
I64 i,j,len=4;
CDirEntry *tempde,*tempde1;
Cd(dir);
tempde1=FilesFind("*",FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES);
for (tempde=tempde1,i=0;tempde && i<start_song;i++)
tempde=tempde->next;
for (i=start_song;tempde && i<end_song;i++) {
if (FileExtDot(tempde->name))
FileExtRem(tempde->name);
if (j=StrLen(tempde->name)) {
*tempde->full_name=':';
*tempde->name=ToUpper(*tempde->name);
if (j>len) len=j;
}
tempde=tempde->next;
}
for (tempde=tempde1,i=0;tempde && i<start_song;i++)
tempde=tempde->next;
if (end_song-start_song<=9)
j=1;
else if (end_song-start_song<=99)
j=2;
else
j=3;
for (i=start_song;tempde && i<end_song;i++) {
"$$LK+CX,\"%*d) %-*s\",A=\"FI:%s\"$$\n",j,i-start_song+1,len,tempde->name,tempde->full_name;
tempde=tempde->next;
}
DirLstDel(tempde1);
}
public U0 JukeLines(I64 start_line,I64 end_line)
{
WordStat;
if (!frame_grabber_on)
FrameGrabberToggle;
JukeSongsPuppet("::/Apps/MusicOrgan/Examples",,start_line*5,end_line*5);
if (frame_grabber_on)
FrameGrabberToggle;
JukeSongsPut("::/Apps/MusicOrgan/Examples",start_line*5,end_line*5);
}
public U0 ChkAll()
{
U8 *ptr=TS_HDS;
while (*ptr)
ChkDsk(*ptr++);
}
public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
{
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=MAX_I64;
best_ch=0;
ptr=&gr_font[32*FONT_HEIGHT];
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 BMP2TXT(U8 *_in_name,U8 *_out_name=NULL)
{
U8 *in_name,*out_name;
I64 dx,dy,score,best_score=MAX_I64;
CDC *dc;
CDoc *doc;
in_name=DftExt(_in_name,"BMP"),
if (_out_name)
out_name=DftExt(_out_name,"TXT.Z");
else
out_name=ChgExt(_in_name,"TXT.Z");
if (dc=BMPFileRead(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);
}
+638
View File
@@ -0,0 +1,638 @@
//The CFG defines are $LK,"Here",A="FI:::/Demo/AcctExample/TSAdam.CPP"$.
U8 TSPmtDrv()
{
I64 result;
"Drive (%s):",TS_HDS;
result=ToUpper(GetChar);
NewLine;
return result;
}
U0 TSMakeOSPrtBootInstall(U8 drv_let)
{
drv_let=ToUpper(drv_let);
Auto(TS_CFG);
MakeOSPrtBootInstall(drv_let);
if (StrOcc(TS_MASTER_BOOT_DRVS,drv_let))
MasterBootIntall(drv_let);
}
U0 SoftBootMenu(U8 drv_let=0)
{
if (!drv_let)
drv_let=Prt2Drv(Fs->cur_prt);
Drv(drv_let);
Cd("/Kernel");
Auto(TS_MENU_CFG);
if (!Cmp("Kernel","Kernel",NULL,':'))
SoftBoot("Kernel.BIN.Z");
}
U0 TSCopyDrv(U8 src,U8 dst)
{
U8 buf_s[128],buf_d[128];
src=ToUpper(src);
dst=ToUpper(dst);
Fmt(dst,,FALSE,PT_FAT32);
SPrint(buf_s,"%c:/",src);
SPrint(buf_d,"%c:/",dst);
CopyTree(buf_s,buf_d);
DocClear;
Drv(dst);
TSMakeOSPrtBootInstall(dst);
}
U0 TSPmtCopyDrv()
{
I64 src,dst;
"$$RED$$\nCopy Src Drive:\n$$FG$$";
src=TSPmtDrv;
"$$RED$$\nCopy Dst Drive:\n$$FG$$";
dst=TSPmtDrv;
TSCopyDrv(src,dst);
}
public U0 CursorRemFile(U8 *filename)
{
CDoc *doc;
doc=DocRead(filename,DOCF_PLAIN_TEXT|DOCF_NO_CURSOR);
DocWrite(doc);
DocDel(doc);
}
public U0 CursorRem(U8 *files_find_mask="*")
{
I64 fuf_flags=0;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+T+f+F+O");
CDirEntry *tempde=FilesFind(files_find_mask,fuf_flags),*tempde1=tempde;
while (tempde) {
CursorRemFile(tempde->full_name);
Touch(tempde->full_name,"",,tempde->datetime);
tempde=tempde->next;
}
DirLstDel(tempde1);
}
public U0 CursorTopFile(U8 *filename)
{
CDoc *doc;
doc=DocRead(filename,DOCF_PLAIN_TEXT);
doc->cur_entry=doc->root.next;
DocWrite(doc);
DocDel(doc);
}
public U0 CursorTop(U8 *files_find_mask="*")
{
I64 fuf_flags=0;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+T+f+F+O");
CDirEntry *tempde=FilesFind(files_find_mask,fuf_flags),*tempde1=tempde;
while (tempde) {
CursorTopFile(tempde->full_name);
Touch(tempde->full_name,"",,tempde->datetime);
tempde=tempde->next;
}
DirLstDel(tempde1);
}
U0 UncollapseFile(U8 *filename,I64 *)
{
CDoc *doc=DocRead(filename,DOCF_NO_CURSOR);
DocCollapse(FALSE,doc);
DocWrite(doc);
DocDel(doc);
}
U0 Uncollapse(U8 *files_find_mask="*",U8 *fu_flags=NULL)
{
I64 fuf_flags=0;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+f+F+T+O");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
CDirEntry *tempde=FilesFind(files_find_mask,fuf_flags),*tempde1=tempde;
while (tempde && !Bt(&fuf_flags,FUf_CANCEL)) {
UncollapseFile(tempde->full_name,&fuf_flags);
Touch(tempde->full_name,"",,tempde->datetime);
tempde=tempde->next;
}
DirLstDel(tempde1);
}
public U0 CopySongs(U8 threshold='7')
{
CDoc *s;
CDocEntry *doc_e;
CDirEntry *tempde=FilesFind("/Accts/TS/TAD/MusicOrgan/*.CPP*",FUF_CLUSTER_ORDER),*tempde1=tempde;
DelTree("/Apps/MusicOrgan/Examples");
MkDir("/Apps/MusicOrgan/Examples");
while (tempde) {
s=DocRead(tempde->full_name);
doc_e=s->root.next;
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[2]>=threshold)
Copy(tempde->full_name,"/Apps/MusicOrgan/Examples");
tempde=tempde->next;
}
DirLstDel(tempde1);
}
U0 DistroPrep()
{
Del("/Demo/WebLogExample/WebLogRep.TXT*");
Del("/Demo/ReverseFileExample/PoemForeward.TXT*");
Del("/Demo/Games/EagleDive.BIN*");
DelTree("/Accts/*Temp.TXT.Z");
CopySongs;
DelTree("/Temp");
MkDir("/Temp");
MkDir("/Temp/ScreenShots");
//User
Del("/Accts/User/Registry.CPP.Z");
//Install
Del("/Accts/Install/Registry.CPP.Z");
Touch("/Accts/PersonalMenu.TXT.Z","+T");
//TS
Touch("/Accts/TS/PersonalMenu.TXT.Z","+T");
DelTree("/Demo/AcctExample");
CopyTree("/Accts/TS","/Demo/AcctExample");
DelTree("/Demo/AcctExample/TAD/MusicOrgan");
DelTree("/Demo/AcctExample/Wb2");
Del("/Demo/AcctExample/TAD/Test*");
CursorTop("/*");
DelTree("/Demo/*.BI*");
S2T("/*","+r+S");
DocOpt("/*");
Move(WSD_DEF_FILENAME,WSD_DEF_FILENAME_Z);
}
U0 MakeBootDrvFile()
{
try
PrtChk(Drv2Prt(TS_BOOT_DRV_LET));
catch {
Fs->catch_except=TRUE;
Auto(CFG_BOOT_DRV "\n");
Mount;
}
CBlkDev *bdev=Drv2BlkDev(TS_BOOT_DRV_LET);
Fmt(TS_BOOT_DRV_LET,,FALSE,PT_REDSEA);
MkDir(TS_BOOT_DRV ":/Compiler");
Copy(TS_MAIN_DRV ":/Compiler/Compiler.BIN.Z", TS_BOOT_DRV ":/Compiler");
Copy(TS_MAIN_DRV ":/Compiler/OpCodes.TXT.Z", TS_BOOT_DRV ":/Compiler");
Copy(TS_MAIN_DRV ":/Compiler/CmpDefs.HPP.Z", TS_BOOT_DRV ":/Compiler");
Copy(TS_MAIN_DRV ":/Compiler/Cmp.HPP.Z", TS_BOOT_DRV ":/Compiler");
MkDir(TS_BOOT_DRV ":/Kernel");
Copy(TS_MAIN_DRV ":/Kernel/*.HPP*", TS_BOOT_DRV ":/Kernel");
Copy(TS_MAIN_DRV ":/Kernel/Adam1*", TS_BOOT_DRV ":/Kernel");
CopyTree(TS_MAIN_DRV ":/Kernel/Dsk", TS_BOOT_DRV ":/Kernel/Dsk");
MkDir(TS_BOOT_DRV ":/Adam");
Copy(TS_MAIN_DRV ":/Accts/TS/DbgAdam2.CPP.Z", TS_BOOT_DRV ":/Adam/Adam2.CPP.Z");
Copy(TS_MAIN_DRV ":/Adam/AdamExt.HPP.Z", TS_BOOT_DRV ":/Adam");
Copy(TS_MAIN_DRV ":/Adam/Math2a.CPP.Z", TS_BOOT_DRV ":/Adam");
Copy(TS_MAIN_DRV ":/Adam/Training.CPP.Z", TS_BOOT_DRV ":/Adam");
Copy(TS_MAIN_DRV ":/Adam/Utils2a.CPP.Z", TS_BOOT_DRV ":/Adam");
Copy(TS_MAIN_DRV ":/Adam/MathODE.CPP.Z", TS_BOOT_DRV ":/Adam");
FileWrite(TS_MAIN_DRV ":" CFG_BOOT_DRV_FILE,bdev->RAM_dsk,(bdev->max_blk+1)<<BLK_SIZE_BITS);
}
U0 MakeSymFiles()
{
CDoc *doc;
U8 *st;
if (ts_has_bak_drv) {
DocClear;
DocMax;
HashTablePurge(adam_task->hash_table);
Who;
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,TS_BAK_DRV ":/Wb/Accts/TS/Wb2/SymsAlpha.TXT.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,TS_BAK_DRV ":/Wb/Accts/TS/Wb2/SymsAddress.TXT.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
DocClear;
}
}
I64 MakeLineRepFile()
{
U8 *st;
CDoc *doc;
I64 result,official;
CDocEntry *tree_branch,*start_indent,*end_indent;
DocClear;
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Cd(TS_MAIN_DRV ":/");
if (ts_has_ram_drv) {
DelTree(TS_RAM_DRV ":/TS");
CopyTree(TS_MAIN_DRV ":/Accts/TS",TS_RAM_DRV ":/TS");
DelTree(TS_MAIN_DRV ":/Accts/TS");
}
DocMax;
DocClear;
result=LineRep;
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,TS_RAM_DRV ":/TS/Wb2/LineRep.TXT.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
DocClear;
official=LineRep(TS_MAIN_DRV ":/Accts/*")+
LineRep(TS_MAIN_DRV ":/Adam/*")+
LineRep(TS_MAIN_DRV ":/Compiler/*","-S+T")+
LineRep(TS_MAIN_DRV ":/Kernel/*");
DocClear;
if (ts_has_ram_drv) {
CopyTree(TS_RAM_DRV ":/TS",TS_MAIN_DRV ":/Accts/TS");
DelTree(TS_RAM_DRV ":/TS");
}
doc=DocRead(TS_MAIN_DRV ":/Adam/DocDefines.CPP.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_data_col=0;
DocPrint(doc,"DefinePrint(\"DD_TEMPLEOS_LOC\",\"%,d\");\n",result);
DocPrint(doc,"DefinePrint(\"DD_TEMPLEOS_LOC_OFFICIAL\",\"%,d\");\n",official);
st=MPrint("%,d",result);
DefineLoad("DD_TEMPLEOS_LOC",st);
Free(st);
st=MPrint("%,d",official);
DefineLoad("DD_TEMPLEOS_LOC_OFFICIAL",st);
Free(st);
DocWrite(doc);
DocDel(doc);
"Total LOC:%12,d\n\n",result;
return result;
}
U0 TSDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(TS_CDROM_CFG);
MakeOSPrtBootInstall(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/",TS_DISTRO_DIR "/");
}
U0 DbgDistroPrep()
{
if (ts_has_boot_drv) {
Drv(TS_MAIN_DRV_LET);
DistroPrep;
MakeBootDrvFile;
Auto(TS_CDROM_DBG_CFG);
MakeOSPrtBootInstall(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/",TS_DISTRO_DIR "/");
Del(TS_MAIN_DRV ":" CFG_BOOT_DRV_FILE);
}
}
U0 StdDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(STD_DISTRO_CDROM_CFG);
MakeOSPrtBootInstall(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/",TS_DISTRO_DIR "/");
DelTree(TS_DISTRO_DIR "/Accts/TS");
Del(TS_DISTRO_DIR "/0000Boot/OldMBR.BIN.C");
Del(TS_DISTRO_DIR "/0000Boot/BootMHD2.BIN.C");
}
U0 LiteDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(STD_DISTRO_CDROM_CFG);
MakeOSPrtBootInstall(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/",TS_DISTRO_DIR "/");
DelTree(TS_DISTRO_DIR "/Accts/TS");
DelTree(TS_DISTRO_DIR "/Linux");
DelTree(TS_DISTRO_DIR "/Windows");
Del(TS_DISTRO_DIR "/0000Boot/OldMBR.BIN.C");
Del(TS_DISTRO_DIR "/0000Boot/BootMHD2.BIN.C");
Del(TS_DISTRO_DIR "/Adam/WordStat/WSDefs.DAT*");
Del(TS_DISTRO_DIR "/Misc/PCIDevices.TXT.Z");
Del(TS_DISTRO_DIR "/Misc/Bible.TXT.Z");
}
U0 UltraDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(STD_DISTRO_CDROM_CFG);
MakeOSPrtBootInstall(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/",TS_DISTRO_DIR "/");
DelTree(TS_DISTRO_DIR "/Accts/TS");
DelTree(TS_DISTRO_DIR "/Linux");
DelTree(TS_DISTRO_DIR "/Windows");
DelTree(TS_DISTRO_DIR "/Apps");
DelTree(TS_DISTRO_DIR "/Demo");
Del(TS_DISTRO_DIR "/0000Boot/OldMBR.BIN.C");
Del(TS_DISTRO_DIR "/0000Boot/BootMHD2.BIN.C");
Del(TS_DISTRO_DIR "/Adam/WordStat/*.DAT*");
DelTree(TS_DISTRO_DIR "/Misc/Tour");
Del(TS_DISTRO_DIR "/Misc/PCIDevices.TXT.Z");
Del(TS_DISTRO_DIR "/Misc/Bible.TXT.Z");
Del(TS_DISTRO_DIR "/Adam/God/Vocab.TXT.Z");
}
U0 MakeTSDistro()
{
TSDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeDbgDistro()
{
DbgDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeStdDistro()
{
StdDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeLiteDistro()
{
LiteDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeUltraDistro()
{
UltraDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 TSWebFile(U8 *name)
{
U8 *name2;
CDirEntry de;
if (FileFind(name,&de)) {
Free(de.full_name);
"File:%s\n",name;
UncollapseFile(name,NULL);
Touch(name,"",,de.datetime);
name2=ChgExt(name,"html");
ToHtml(name,name2,
"<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"
);
Touch(name2,"",,de.datetime);
Free(name2);
}
}
U0 MakeWebSite()
{
CDirEntry *tempde,*tempde1;
if (ts_has_bak_drv) {
DocClear;
Cd(TS_BAK_DRV ":/Wb");
DelTree(TS_BAK_DRV ":/Wb/Accts/TS/TAD");
Del(TS_BAK_DRV ":/Wb/Accts/TS/*");
Touch(TS_BAK_DRV ":/Wb/Accts/TS/Wb2/index.TXT.Z","",,Now);
Touch(TS_BAK_DRV ":/Wb/Accts/TS/Wb2/Downloads.TXT.Z","",,Now);
Touch(TS_BAK_DRV ":/Wb/Accts/TS/Wb2/TempleOS.TXT.Z","",,Now);
tempde=tempde1=FilesFind("*",FUF_RECURSE|FUF_JUST_FILES|FUF_JUST_TXT|FUF_CLUSTER_ORDER);
while (tempde) {
TSWebFile(tempde->full_name);
tempde=tempde->next;
}
DirLstDel(tempde1);
Drv(TS_MAIN_DRV_LET);
}
}
U0 FreshenWebDir(U8 *dirname)
{
CDirEntry *tempde,*tempde1;
U8 *src,*dst;
src=MPrint(TS_BAK_DRV ":/Wb%s/*",dirname);
Del(src);
Free(src);
src=MPrint(TS_MAIN_DRV ":%s/*",dirname);
dst=MPrint(TS_BAK_DRV ":/Wb%s",dirname);
Copy(src,dst);
Free(src);
Free(dst);
src=MPrint(TS_BAK_DRV ":/Uncompressed%s/*",dirname);
Del(src);
Free(src);
src=MPrint(TS_MAIN_DRV ":%s/*",dirname);
dst=MPrint(TS_BAK_DRV ":/Uncompressed%s",dirname);
Copy(src,dst);
Free(src);
Free(dst);
src=MPrint(TS_BAK_DRV ":/Wb%s/*",dirname);
tempde=tempde1=FilesFind(src,FUF_JUST_FILES|FUF_JUST_TXT|FUF_CLUSTER_ORDER);
while (tempde) {
TSWebFile(tempde->full_name);
tempde=tempde->next;
}
DirLstDel(tempde1);
}
U0 MakeWebSitePartial()
{
if (ts_has_bak_drv) {
FreshenWebDir("/Accts/TS/Wb2");
FreshenWebDir("/Accts/TS/Wb2/Rants/TAD");
FreshenWebDir(TS_BLOG_DIR);
Drv(TS_MAIN_DRV_LET);
}
}
U0 TSUncompress()
{
U8 *st;
CDirEntry *tempde,*tempde1;
if (ts_has_bak_drv) {
DelTree(TS_BAK_DRV ":/Uncompressed");
CopyTree(TS_MAIN_DRV ":/",TS_BAK_DRV ":/Uncompressed");
tempde=tempde1=FilesFind(TS_BAK_DRV ":/Uncompressed/*.Z",FUF_RECURSE|FUF_JUST_FILES|FUF_CLUSTER_ORDER);
while (tempde) {
st=StrNew(tempde->full_name);
StrLastRem(st,".");
Move(tempde->full_name,st);
Free(st);
tempde=tempde->next;
}
DirLstDel(tempde1);
CursorRem(TS_BAK_DRV ":/Uncompressed/*");
}
}
U0 UpdateISODocDefines()
{
DefinePrint("DD_TEMPLEOSTS_SIZE",
"Download $TX,"TempleOS V2.03",D="DD_OS_NAME_VERSION"$ - T.S. Company Internal Distro (%0.1f MB)",
0.1*(10*Size(TS_BAK_DRV ":/Wb/TempleOSTS.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSDBG_SIZE",
"Download $TX,"TempleOS V2.03",D="DD_OS_NAME_VERSION"$ - Debug Distro (%0.1f MB)",
0.1*(10*Size(TS_BAK_DRV ":/Wb/TempleOSDbg.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSCD_SIZE",
"Download $TX,"TempleOS V2.03",D="DD_OS_NAME_VERSION"$ - Standard Distro (%0.1f MB)",
0.1*(10*Size(TS_BAK_DRV ":/Wb/TempleOSCD.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSLITE_SIZE",
"Download $TX,"TempleOS V2.03",D="DD_OS_NAME_VERSION"$ - Lite Distro (%0.1f MB)",
0.1*(10*Size(TS_BAK_DRV ":/Wb/TempleOSLite.ISO","+s")/1024/1024));
DefinePrint("DD_TEMPLEOSULTRA_SIZE",
"Download $TX,"TempleOS V2.03",D="DD_OS_NAME_VERSION"$ - UltraLite Distro (%0.1f MB)",
0.1*(10*Size(TS_BAK_DRV ":/Wb/TempleOSUltra.ISO","+s")/1024/1024));
}
UpdateISODocDefines;
public U0 MakeDistrosAndBackUp()
{
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
progress4=*progress4_desc=0;
progress4_max=19;
WordStat;
WinMax;
WinBorder;
ChkAll; progress4++;
if (ts_has_bak_drv) {
MakeLineRepFile; progress4++;
TSCopyDrv(TS_MAIN_DRV_LET,TS_BAK_DRV_LET); progress4++;
DelTree (TS_BAK_DRV ":/Wb"); progress4++;
CopyTree(TS_MAIN_DRV ":/",TS_BAK_DRV ":/Wb"); progress4++;
DocClear;
MakeTSDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSTS.ISO"); progress4++;
MakeDbgDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSDbg.ISO"); progress4++;
MakeStdDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSCD.ISO"); progress4++;
MakeLiteDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSLite.ISO"); progress4++;
MakeUltraDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSUltra.ISO"); progress4++;
UpdateISODocDefines;
Cd(TS_MAIN_DRV ":/");
if (LinkChk)
throw;
progress4++;
MakeSymFiles; progress4++;
MakeWebSite; progress4++;
TSUncompress; progress4++;
}
Drv(TS_MAIN_DRV_LET);
ChkAll; progress4++;
progress4=progress4_max=0;
SettingsPop;
}
public U0 TSMount()
{
if (!sys_auto_mount_ide_cnt) {
Auto(CFG_HARD_DRVS "\n");
Mount;
}
}
U0 TSCopy()
{
if (ts_cid==CID_DFT) {//Dangerous! don't do on my main machine
Fmt(TS_MAIN_DRV_LET,,FALSE);
CopyTree(TS_CDROM_DRV ":/",TS_MAIN_DRV ":/");
TSMakeOSPrtBootInstall(TS_MAIN_DRV_LET);
Fmt(TS_BAK_DRV_LET,,FALSE);
CopyTree(TS_CDROM_DRV ":/",TS_BAK_DRV ":/");
TSMakeOSPrtBootInstall(TS_BAK_DRV_LET);
Reboot;
}
}
U0 TSPrtDsk()
{
CTask *task=SpawnUser;
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL;
if (ts_cid==CID_DFT) {//Dangerous! don't do on my main machine
ATARep(FALSE,TRUE,&root);
ATAIDDrvs(root,*sys_acct,&ata_drv,&atapi_drv);
if (ata_drv) {
XTalkWait(task,"PrtDsk;\nY%C2p%d\nYYY",TS_MAIN_DRV_LET,ata_drv->num);
XTalkWait(task,"%d\nY\nY\n",(prt_dsk_dsk_size-PRT_HEADER)/2);
}
Kill(task);
}
}
public U0 TSUpgrade()
{
if (ts_cid==CID_DFT) {//Dangerous! don't do on my main machine
TSMount;
TSCopy;
}
}
public U0 TSInstall()
{
if (ts_cid==CID_DFT) {//Dangerous! don't do on my main machine
TSPrtDsk;
TSCopy;
}
}
+404
View File
@@ -0,0 +1,404 @@
U0 BadCodeJump()
{ //$LK,"::/Adam/God/HSNotes.TXT"$
CDirEntry *tempde1=FilesFind("/*",FUF_JUST_FILES|FUF_RECURSE|FUF_JUST_SRC|FUF_CLUSTER_ORDER),
*tempde=tempde1;
I64 cnt=0,num;
CDoc *doc;
U8 *st;
while (tempde) {
doc=DocRead(tempde->full_name);
tempde->user_data=doc->root.y;
cnt+=doc->root.y;
DocDel(doc);
tempde=tempde->next;
}
num=KbdMouseEvtTime>>GOD_BAD_BITS%cnt;
tempde=tempde1;
while (tempde) {
num-=tempde->user_data;
if (num<0) {
st=MPrint("FL:%s,%d",tempde->full_name,-num);
break;
}
tempde=tempde->next;
}
DirLstDel(tempde1);
Ed(st);
Free(st);
}
public U8 *FileNameNumNext(U8 *files_find_mask,U8 *fmt)
{
CDirEntry *tempde=FilesFind(files_find_mask);
U8 *result=MPrint(fmt,FileCnt(tempde));
DirLstDel(tempde);
return result;
}
U0 DCImgWrite(CDC *dc)
{
U8 *st=FileNameNumNext("::" TS_BLOG_DIR "/Img*","::" TS_BLOG_DIR "/Img%03d.BMP"),*st2;
st2=MPrint("http://www.templeos.org/Wb%s",st+2);
BMPFileWrite(st,dc);
Free(st);
"$$HC,\"<img src=\\\"%s\\\" width=\\\"%d\\\" height=\\\"%d\\\" alt=\\\"\\\">\"$$\n",st2,dc->width,dc->height;
Free(st2);
}
U0 BlogScreenShot()
{
Bool old_cursor=DocCursor;
CDC *dc1,*dc2;
U8 *old_fp_draw_input_ptr=fp_draw_input_ptr;
fp_draw_input_ptr=NULL;
WinMgrSync(2);
dc1=DCCaptureScreen;
dc2=DCExtract(dc1,0,FONT_HEIGHT,GR_WIDTH-1,GR_HEIGHT-1);
DCImgWrite(dc2);
fp_draw_input_ptr=old_fp_draw_input_ptr;
DCDel(dc1);
DCDel(dc2);
DocCursor(old_cursor);
}
U8 *WebBookMarks(U8 *filename="HOME/Archive/Bookmarks.html")
{
U8 *st;
CDocEntry *doc_e;
CDoc *doc=DocNew;
CLex *lx=LexNew(MPrint("#include \"%s\"",filename));
while (Lex(lx))
if (lx->token==TK_STR && *lx->cur_str(U32 *)=='http') {
DocPrint(doc,"$$MU-UL,\"%Q\",LE=0x%X$$\n",lx->cur_str,lx->cur_str);
lx->cur_str=NULL;
}
LexDel(lx);
st=StrNew(PopUpMenu(doc));
doc_e=doc->root.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;
}
class CWebBookMarkForm
{
U8 tag[136] fmtstr "$$DA-P,135,A=\"Tag Text :%s\"$$\n";
U8 special[136];
I64 timestamp;
I64 cert;
I64 min;
I64 sec;
};
class CWebBibleForm
{
U8 tag[136] fmtstr "$$DA-P,135,A=\"Tag Text :%s\"$$\n";
U8 special[136] fmtstr "$$DA-P,135,A=\"Bible Passage:%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min;
I64 sec;
};
class CYouTubeForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"SerialNum:%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min fmtstr "$$DA,32,A=\"Minutes :%d\"$$\n";
I64 sec fmtstr "$$DA,32,A=\"Seconds :%d\"$$\n";
};
class CImgurForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"SerialNum:%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min fmtstr "$$DA,32,A=\"Width :%d\"$$\n";
I64 sec fmtstr "$$DA,32,A=\"Height :%d\"$$\n";
};
class CWikipediaForm
{
U8 tag[136] fmtstr "$$DA-P,135,A=\"Tag Text:%s\"$$\n";
U8 special[136] fmtstr "$$DA-P,135,A=\"Index :%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min;
I64 sec;
};
class CRandDecForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"Line (Dec):%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min;
I64 sec;
};
class CRandHexForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"Line (Hex):%s\"$$\n";
I64 timestamp;
I64 cert;
I64 min;
I64 sec;
};
class CRandCertForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"Line (Dec) :%s\"$$\n";
I64 timestamp;
I64 cert fmtstr "$$DA,32,A=\"Certificate:%d\"$$\n";
I64 min;
I64 sec;
};
class CRandHexBeaconForm
{
U8 tag[136];
U8 special[136] fmtstr "$$DA-P,135,A=\"Line (Hex):%s\"$$\n";
I64 timestamp fmtstr "$$DA,32,A=\"TimeStamp :%d\"$$\n";
I64 cert;
I64 min;
I64 sec;
};
U8 *URLPercentSpaces(U8 *src)
{
U8 buf[1024],*dst=buf;
while (*src) {
if (*src==CH_SPACE) {
*dst++='%';
*dst++='%';
*dst++='2';
*dst++='0';
src++;
} else
*dst++=*src++;
}
*dst=0;
return StrNew(buf);
}
U0 MyBibleLines(U8 *st,I64 num_lines,I64 radix,Bool modulo,Bool plus_one)
{
CDoc *doc_out,*doc_in;
CDocEntry *doc_e;
I64 i,start;
U8 *verse;
if (*st && (doc_out=DocPut)) {
i=A2I64(st,radix);
if (modulo) {
DocPrint(doc_out,"$TX,"(Modulo is just remainder.)",HTML="http://en.wikipedia.org/wiki/Modulo_operation"$\n");
if (radix==16)
DocPrint(doc_out,"0x%s-->",st);
DocPrint(doc_out,"(%d mod %d)",i,ST_BIBLE_LINES-(num_lines-1));
start=i%(ST_BIBLE_LINES-(num_lines-1));
} else {
if (radix==16)
DocPrint(doc_out,"0x%s-->",st);
DocPrint(doc_out,"%d",i);
start=i;
}
if (plus_one) {
start++;
DocPrint(doc_out,"+1");
}
DocPrint(doc_out,"-->Line:%d\n\n",start);
verse=BibleLine2Verse(start);
DocPrint(doc_out,"$TX,"KingJamesBible",HTML="http://www.templeos.org/files/BIBLE.TXT"$ (%s) God says...\n$$RED$$",verse);
Free(verse);
doc_in=DocNew;
BibleLines(doc_in,start,num_lines);
while (TRUE) { //Del leading blanks
doc_e=doc_in->root.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);
}
}
#define NIST_TIME_OFFSET (5*3600-353)
public U0 SyncNIST()
{
while (!ScanChar) {
"%d %d\n",
ToI64 ((Now-A2Date("1/1/1970"))/CDATE_FREQ+NIST_TIME_OFFSET),
FloorI64((Now-A2Date("1/1/1970"))/CDATE_FREQ+NIST_TIME_OFFSET,60);
Sleep(100);
}
}
U0 FillInMyURL()
{
U8 *tag,*st,*st2;
CWebBibleForm *url=CAlloc(sizeof(CWebBibleForm));
url->timestamp=
FloorI64((Now-A2Date("1/1/1970"))/CDATE_FREQ+NIST_TIME_OFFSET,60);
switch (PopUpPickLst("NISTBeacon\0WebBible\0YouTube\0Imgur\0Wikipedia\0RandomNumbers.info\0"
"Random.org\0VirtualNotary\0Nist\0HotBits\0GenerateData\0WebBookMark\0")) {
case 0:
if (DocFormDo(url(CRandHexBeaconForm *))) {
"$$TX,\"National Institute of Standards Public Randomness Beacon\","
"HTML=\"http://beacon.nist.gov/home\"$$\n\n"
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag=MPrint("http://beacon.nist.gov/rest/record/%d",url->timestamp);
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
Free(tag);
MyBibleLines(url->special,20,16,TRUE,TRUE);
}
break;
case 1:
if (DocFormDo(url(CWebBibleForm *))) {
tag=url->special;
st2=URLPercentSpaces(url->special);
st=MPrint("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 2:
if (DocFormDo(url(CYouTubeForm *))) {
if (url->min || url->sec)
st=MPrint("%s&hl=enUS&start=%d",url->special,url->min*60+url->sec);
else
st=StrNew(url->special);
"$$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);
}
break;
case 3:
if (DocFormDo(url(CImgurForm *))) {
"$$HC,\"<img src=\\\"http://i.imgur.com/%s\\\" "
"width=\\\"%d\\\" height=\\\"%d\\\" alt=\\\"\\\">\"$$\n",
url->special,url->min,url->sec;
}
break;
case 4:
if (DocFormDo(url(CWikipediaForm *))) {
tag=url->special;
st=MPrint("http://en.wikipedia.org/wiki/%s",url->special);
if (*url->tag)
tag=url->tag;
"$$TX,\"%Q\",HTML=\"%Q\"$$",tag,st;
Free(st);
}
break;
case 5:
if (DocFormDo(url(CRandDecForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="http://www.randomnumbers.info";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
MyBibleLines(url->special,20,10,FALSE,TRUE);
}
break;
case 6:
if (DocFormDo(url(CRandDecForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="http://www.random.org";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
MyBibleLines(url->special,20,10,FALSE,FALSE);
}
break;
case 7:
if (DocFormDo(url(CRandCertForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="http://virtual-notary.org";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n",tag,tag;
tag="Here is the certificate";
st=MPrint("http://www.templeos.org/Certs/virtual-notary-cert-randomnum-%d.p12",url->cert);
"\n$$TX,\"%Q: %d\",HTML=\"%Q\"$$.\n\n",tag,url->cert,st;
Free(st);
MyBibleLines(url->special,20,10,FALSE,FALSE);
}
break;
case 8:
if (DocFormDo(url(CRandHexForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="http://qrng.anu.edu.au/NIST.php";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
MyBibleLines(url->special,20,16,TRUE,TRUE);
}
break;
case 9:
if (DocFormDo(url(CRandHexForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="https://www.fourmilab.ch/hotbits/secure_generate.html";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
MyBibleLines(url->special,20,16,TRUE,TRUE);
}
break;
case 10:
if (DocFormDo(url(CRandDecForm *))) {
"$$TX,\"Guidelines for Talking with God\","
"HTML=\"http://www.templeos.org/Wb/Adam/God/HSNotes.html\"$$\n\n";
tag="http://www.generatedata.com";
"$$TX,\"%Q\",HTML=\"%Q\"$$\n\n",tag,tag;
MyBibleLines(url->special,20,10,FALSE,FALSE);
}
break;
case 11:
if (DocFormDo(url(CWebBookMarkForm *))) {
tag=st=WebBookMarks;
if (*url->tag)
tag=url->tag;
"$$TX,\"%Q\",HTML=\"%Q\"$$",tag,st;
Free(st);
}
break;
}
Free(url);
}
+79
View File
@@ -0,0 +1,79 @@
/*
This is a JIT file, not AOT.
Asm labels can only be defined once
in a task. Hit F5 to spawn a new task
each time and run it.
*/
asm {
//Opcodes are slightly different to make writing my x86_64 assembler easier.
//See $LK,"::/Compiler/OpCodes.TXT"$.
USE64 //Defaults to 64, but this is a good habit.
IMPORT Beep;
_BEEPS::
//You can always clobber RAX,RBX,RCX,RDX,R8,R9
PUSH RBP
MOV RBP,RSP
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/Adam1a.HPP,SF_ARG1"$
@@05: PUSH RCX
//U0 Beep(I64 freq=500,Bool busy=FALSE)
PUSH FALSE //Do not busy (spin) wait
PUSH 500 //Hz
CALL Beep
POP RCX
LOOP @@05
POP RBP
//Return vals are in RAX
RET1 8
}
//_extern binds a asm sym to a function.
//My convention is to put an underscore
//on C callable routines.
_extern _BEEPS U0 Beeps(I64 cnt);
I64 AsmAndC1()
{
I64 noreg i; //Normally this would be stored in a reg
//Check with $LK,"Uf",A="MN:Uf"$("AsmAndC1").
i=PmtI64("Num of beeps 1-5 (%d):",3,1,5);
Beeps(i);
asm {
//You can clobber RAX,RBX,RCX,RDX
USE64 //Defaults to 64, but this is a good habit.
IMPORT Snd; //Import an not use & or don't import and use &Snd.
MOV RCX,&i[RBP] //You can clobber RAX,RBX,RCX,RDX.
//You better preserve the rest.
@@05: PUSH RCX
//U0 Snd(F64 freq);
MOV RAX,RCX //freq=loop*100.0+100.0
IMUL2 RAX,100 //TempleOS uses nonstandard opcodes
//to avoid multiple form of the same one.
//See $LK,"::/Compiler/OpCodes.TXT"$.
ADD RAX,100
PUSH RAX
FILD U64 [RSP] //Convert from int to floating
FSTP U64 [RSP]
CALL Snd
MOV RCX,time_stamp_freq>>3 //JIT Const. Simple delay loop
@@10: LOOP @@10
POP RCX
LOOP @@05
}
Snd(0);
return i;
}
"Beeps:%d\n",AsmAndC1;
+92
View File
@@ -0,0 +1,92 @@
/*
This is a JIT file, not AOT.
Asm labels can only be defined once
in a task. Hit F5 to spawn a new task
each time and run it.
*/
//This is to demo glbl var access.
//Glbs defined elsewhere can accessed too, like sys_jiffies.
I64 glbl_hz=400,glbl_hz_step=100,glbl_hz_base=100;
asm {
//Opcodes are slightly different to make writing my x86_64 assembler easier.
//See $LK,"::/Compiler/OpCodes.TXT"$.
USE64 //Defaults to 64, but this is a good habit.
JIFFIES_MSG: DU8 "Jiffies:",0;
//See $LK,"::/Kernel/Str1a.CPP",A="FL:::/Kernel/Str1a.CPP,1"$ and $LK,"::/Kernel/Utils1a.CPP"$.
_BEEPS2::
//You can clobber RAX,RBX,RCX,RDX,R8,R9
PUSH RBP
MOV RBP,RSP
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/Adam1a.HPP,SF_ARG1"$
PUSH U64 [&sys_jiffies]
@@05: PUSH RCX
//U0 Beep(I64 freq=500,Bool busy=FALSE)
PUSH FALSE //Do not busy (spin) wait
PUSH U64 [&glbl_hz] //evaluated at run time
CALL &Beep
POP RCX
LOOP @@05
PUSH RSI //See $LK,"REG_VARS_MASK",A="MN:REG_VARS_MASK"$ & $LK,"REG_NON_PTR_MASK",A="MN:REG_NON_PTR_MASK"$
MOV RSI,JIFFIES_MSG
CALL PUT_STR
POP RSI
POP RAX
SUB RAX,U64 [&sys_jiffies]
NEG RAX
CALL PUT_HEX_U64
MOV RAX,'\n'
CALL PUT_CHARS
POP RBP
RET1 8
}
//My convention is to put an underscore
//on C callable routines.
_extern _BEEPS2 U0 Beeps2(I64 cnt);
U0 AsmAndC2()
{
I64 reg R15 i;
i=PmtI64("$$PURPLE$$\n\nNum of beeps 1-5 (%d):$$FG$$",3,1,5);
Beeps2(i);
asm {
LIST
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest.
USE64 //Defaults to 64, but this is a good habit.
MOV RCX,R15 //You can clobber RAX,RBX,RCX,RDX. Preserve the rest.
@@05: PUSH RCX
//U0 Snd(F64 freq);
MOV RAX,RCX //freq=loop*100.0+100.0
IMUL2 RAX,glbl_hz_step //evaluated at compile ttime
ADD RAX,U64 [&glbl_hz_base] //evaluated at run time
PUSH RAX
FILD U64 [RSP] //Convert from int to floating
FSTP U64 [RSP]
CALL &Snd //We can skip IMPORT with & if JIT compiling.
MOV RCX,time_stamp_freq>>3 //JIT Const. Simple delay loop.
@@10: LOOP @@10
POP RCX
LOOP @@05
}
Snd(0);
}
AsmAndC2;
+24
View File
@@ -0,0 +1,24 @@
/*
This is a JIT file, not AOT.
Asm labels can only be defined once
in a task. Hit F5 to spawn a new task
each time and run it.
*/
U0 AsmAndC3()
{
I64 i;
for (i=0;i<3;i++) {
MOV AL,0x41
STC
ADC AL,0 //Round-about way to make the not special constant, 0x42.
CALL PUT_HEX_U8
MOV RCX,time_stamp_freq>>5 //JIT Cosnt. Simple delay loop.
@@1: LOOP @@1
MOV RAX,' What?\n'
CALL PUT_CHARS
}
}
AsmAndC3;
+53
View File
@@ -0,0 +1,53 @@
/*
This is a JIT file, not AOT.
Asm labels can only be defined once
in a task. Hit F5 to spawn a new task
each time and run it.
These are many useful kernel
routines $LK,"::/Kernel/Str1a.CPP",A="FF:::/Kernel/Str1a.CPP,PUT_CHARS"$
intended to be called from
asm. Generally, they preserve
regs.
You can call any routine you
like, C or asm, if you import it.
Be aware that C routines do not
preserve RAX,RBX,RCX,RDX,R8,R9.
When calling from the shell or
from C, preserve all other regs.
*/
asm {
//Opcodes are slightly different to make writing my x86_64 assembler easier.
//See $LK,"::/Compiler/OpCodes.TXT"$.
USE64 //Defaults to 64, but this is a good habit.
MY_WORLD_MSG:
//Define U8 does not put terminating zeros
//on strings.
DU8 "World\n",0;
//My convention is to put an underscore
//on C callable routines.
_HELLO_WORLD::
PUSH RSI //See $LK,"REG_VARS_MASK",A="MN:REG_VARS_MASK"$ & $LK,"REG_NON_PTR_MASK",A="MN:REG_NON_PTR_MASK"$
MOV RCX,10
@@05: MOV RAX,RCX
CALL PUT_HEX_U8
MOV RAX,CH_SPACE
CALL PUT_CHARS
MOV RAX,'Hello ' //Supports multi-byte char consts
CALL PUT_CHARS
//We broke it in two pieces to show different ways.
MOV RSI,MY_WORLD_MSG
CALL PUT_STR
LOOP @@05
POP RSI
RET
};
Call(_HELLO_WORLD);
+186
View File
@@ -0,0 +1,186 @@
#define RANGE_START 1
#define RANGE_END 100
#define FIZZ_SPAN 6
#define BUZZ_SPAN 7
asm {
_BUZZ_FIZZ::
PUSH RBP
MOV RBP,RSP //Always set-up stk frame. (Stack Gets Traced)
PUSH RSI //See $LK,"REG_VARS_MASK",A="MN:REG_VARS_MASK"$ & $LK,"REG_NON_PTR_MASK",A="MN:REG_NON_PTR_MASK"$
PUSH RDI
MOV RSI,FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1
MOV RDI,BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1
MOV RAX,RANGE_START
@@05: CALL PUT_HEX_U64
PUSH RAX
MOV RAX,CH_SPACE
CALL PUT_CHARS
DEC RSI
JNZ @@10
MOV RAX,'FIZZ '
CALL PUT_CHARS
MOV RSI,FIZZ_SPAN
@@10: DEC RDI
JNZ @@15
MOV RAX,'BUZZ '
CALL PUT_CHARS
MOV RDI,BUZZ_SPAN
@@15: MOV RAX,'\n'
CALL PUT_CHARS
POP RAX
INC RAX
CMP RAX,RANGE_END //Actually only a 32-bit instruction.
JBE @@05
POP RDI
POP RSI
POP RBP
RET
}
Call(_BUZZ_FIZZ);
/*
_BUZZ_FIZZ+0x0000 55 PUSH U64 RBP
_BUZZ_FIZZ+0x0001 488BEC MOV U64 RBP,U64 RSP
_BUZZ_FIZZ+0x0004 56 PUSH U64 RSI
_BUZZ_FIZZ+0x0005 57 PUSH U64 RDI
_BUZZ_FIZZ+0x0006 BE06000000 MOV U64 RSI,U32 00000006
_BUZZ_FIZZ+0x000B BF07000000 MOV U64 RDI,U32 00000007
_BUZZ_FIZZ+0x0010 B801000000 MOV U64 RAX,U32 00000001
_BUZZ_FIZZ+0x0015 E88F7D2480 CALL I32 PUT_HEX_U64+0x0000
_BUZZ_FIZZ+0x001A 50 PUSH U64 RAX
_BUZZ_FIZZ+0x001B B820000000 MOV U64 RAX,U32 00000020
_BUZZ_FIZZ+0x0020 E8E87D2480 CALL I32 PUT_CHARS+0x0000
_BUZZ_FIZZ+0x0025 48FFCE DEC U64 RSI
_BUZZ_FIZZ+0x0028 7514 JNZ I8 _BUZZ_FIZZ+0x003E
_BUZZ_FIZZ+0x002A 48B846495A5A MOV U64 RAX,U32 5A5A4946
_BUZZ_FIZZ+0x0030 2000 AND U8 [RAX],U8 AL
_BUZZ_FIZZ+0x0032 0000 ADD U8 [RAX],U8 AL
_BUZZ_FIZZ+0x0034 E8D47D2480 CALL I32 PUT_CHARS+0x0000
_BUZZ_FIZZ+0x0039 BE06000000 MOV U64 RSI,U32 00000006
_BUZZ_FIZZ+0x003E 48FFCF DEC U64 RDI
_BUZZ_FIZZ+0x0041 7514 JNZ I8 _BUZZ_FIZZ+0x0057
_BUZZ_FIZZ+0x0043 48B842555A5A MOV U64 RAX,U32 5A5A5542
_BUZZ_FIZZ+0x0049 2000 AND U8 [RAX],U8 AL
_BUZZ_FIZZ+0x004B 0000 ADD U8 [RAX],U8 AL
_BUZZ_FIZZ+0x004D E8BB7D2480 CALL I32 PUT_CHARS+0x0000
_BUZZ_FIZZ+0x0052 BF07000000 MOV U64 RDI,U32 00000007
_BUZZ_FIZZ+0x0057 B80A000000 MOV U64 RAX,U32 0000000A
_BUZZ_FIZZ+0x005C E8AC7D2480 CALL I32 PUT_CHARS+0x0000
_BUZZ_FIZZ+0x0061 58 POP U64 RAX
_BUZZ_FIZZ+0x0062 48FFC0 INC U64 RAX
_BUZZ_FIZZ+0x0065 4883F864 CMP U64 RAX,I8 64
_BUZZ_FIZZ+0x0069 76AA JNA I8 _BUZZ_FIZZ+0x0015
_BUZZ_FIZZ+0x006B 5F POP U64 RDI
_BUZZ_FIZZ+0x006C 5E POP U64 RSI
_BUZZ_FIZZ+0x006D 5D POP U64 RBP
_BUZZ_FIZZ+0x006E C3 RET
0000000000000001
0000000000000002
0000000000000003
0000000000000004
0000000000000005
0000000000000006 FIZZ
0000000000000007 BUZZ
0000000000000008
0000000000000009
000000000000000A
000000000000000B
000000000000000C FIZZ
000000000000000D
000000000000000E BUZZ
000000000000000F
0000000000000010
0000000000000011
0000000000000012 FIZZ
0000000000000013
0000000000000014
0000000000000015 BUZZ
0000000000000016
0000000000000017
0000000000000018 FIZZ
0000000000000019
000000000000001A
000000000000001B
000000000000001C BUZZ
000000000000001D
000000000000001E FIZZ
000000000000001F
0000000000000020
0000000000000021
0000000000000022
0000000000000023 BUZZ
0000000000000024 FIZZ
0000000000000025
0000000000000026
0000000000000027
0000000000000028
0000000000000029
000000000000002A FIZZ BUZZ
000000000000002B
000000000000002C
000000000000002D
000000000000002E
000000000000002F
0000000000000030 FIZZ
0000000000000031 BUZZ
0000000000000032
0000000000000033
0000000000000034
0000000000000035
0000000000000036 FIZZ
0000000000000037
0000000000000038 BUZZ
0000000000000039
000000000000003A
000000000000003B
000000000000003C FIZZ
000000000000003D
000000000000003E
000000000000003F BUZZ
0000000000000040
0000000000000041
0000000000000042 FIZZ
0000000000000043
0000000000000044
0000000000000045
0000000000000046 BUZZ
0000000000000047
0000000000000048 FIZZ
0000000000000049
000000000000004A
000000000000004B
000000000000004C
000000000000004D BUZZ
000000000000004E FIZZ
000000000000004F
0000000000000050
0000000000000051
0000000000000052
0000000000000053
0000000000000054 FIZZ BUZZ
0000000000000055
0000000000000056
0000000000000057
0000000000000058
0000000000000059
000000000000005A FIZZ
000000000000005B BUZZ
000000000000005C
000000000000005D
000000000000005E
000000000000005F
0000000000000060 FIZZ
0000000000000061
0000000000000062 BUZZ
0000000000000063
0000000000000064
*/
+23
View File
@@ -0,0 +1,23 @@
asm {
DIV_U64_BY_U64::
PUSH RBP
MOV RBP,RSP
XOR RDX,RDX
MOV RCX,64
MOV RAX,SF_ARG1[RBP]
MOV RBX,SF_ARG2[RBP]
@@1: SHL1 RAX
RCL1 RDX
CMP RBX,RDX
JA @@2
INC RAX
SUB RDX,RBX
@@2: LOOP @@1
POP RBP
RET1 16
}
_extern DIV_U64_BY_U64 I64 DivU64ByU64(I64 dividend,I64 divisor);
"123456/10=%d\n",DivU64ByU64(123456,10);
+72
View File
@@ -0,0 +1,72 @@
/*
When I was a kid with a Commodore 64,
the 6502 chip had no multiply instruction
and this is how we had to do it, except,
I used more regs in this example.
*/
asm {
//Opcodes are slightly different to make writing my x86_64 assembler easier.
//See $LK,"::/Compiler/OpCodes.TXT"$.
USE64 //Defaults to 64, but this is a good habit.
//You can clobber RAX,RBX,RCX,RDX,R8,R9
MUL_BY_HAND_U8_U8_TO_U16: //This is only for fun.
//8bit * 8bit-->16bit
//AL*BL-->AX
MOV CL,8
SHL AX,8
@@05: SHL1 AX
JNC @@10
ADD AL,BL
@@10: DEC CL
JNZ @@05
RET
_MUL_BY_HAND_U8_U8_TO_U16:: //C callable
PUSH RBP
MOV RBP,RSP
MOV AL,U8 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/Adam1a.HPP,SF_ARG1"$
MOV BL,U8 SF_ARG2[RBP]
CALL MUL_BY_HAND_U8_U8_TO_U16
MOVZX RAX,AX
POP RBP
RET1 16
_MUL_U64_U64_TO_U128::
//64bit * 64bit-->128bit
PUSH RBP
MOV RBP,RSP
MOV RBX,U64 SF_ARG3[RBP]
MOV RAX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/Adam1a.HPP,SF_ARG1"$
MUL U64 SF_ARG2[RBP] //Result RDX:RAX 128bit
MOV U64 [RBX],RAX
MOV U64 8[RBX],RDX
POP RBP
RET1 24
};
//My convention is to put an underscore
//on C callable routines.
_extern _MUL_BY_HAND_U8_U8_TO_U16 U16 MulU8(U8 n1,U8 n2);
class U128
{
U64 lo,hi;
};
_extern _MUL_U64_U64_TO_U128 U0 MulU64(I64 n1,I64 n2,U128 *_prod);
U0 MulByHand()
{
U128 p;
"2*7 =0x%X\n",MulU8(2,7);
"100*10=0x%X\n",MulU8(100,10);
MulU64(0x0123456789ABCDEF,0x1000001,&p);
"0x0123466789ABCDEF*0x1000001=0x%016X%016X\n",p.hi,p.lo;
}
MulByHand;
+49
View File
@@ -0,0 +1,49 @@
asm {
PUT_DEC_U64::
//RAX is number to print in decimal.
//Preserves all regs.
PUSH RBP
MOV RBP,RSP
SUB RSP,24 //24 char buffer on stack
//$LK,"Save regs",A="FF:::/Kernel/Adam1a.HPP,PUSH_C_REGS"$ which C code is free to clobber. We don't have to for C callers,
//but this function will be nice for ASM callers if it saves all regs.
PUSH_C_REGS
PUSH RSI //See $LK,"REG_VARS_MASK",A="MN:REG_VARS_MASK"$ & $LK,"REG_NON_PTR_MASK",A="MN:REG_NON_PTR_MASK"$
LEA RSI,-1[RBP] //Load addr of end of buffer.
//We picked RSI because of PUT_STR
//We'll move backward
MOV U8 [RSI],0 //Terminator
TEST RAX,RAX //Special case -- zero
JNZ @@05
DEC RSI
MOV U8 [RSI],'0'
JMP @@15
@@05: MOV RBX,10 //Divides by 10
@@10: XOR RDX,RDX
DIV RBX //RAX=(RDX:RAX)/RBX with remainder in RDX
ADD RDX,'0'
DEC RSI
MOV U8 [RSI],DL
TEST RAX,RAX
JNZ @@10
@@15: CALL PUT_STR
POP RSI
POP_C_REGS
LEAVE
RET
_DO_IT:: //The convention is C-callable routines have underscores.
MOV RAX,122333221
CALL PUT_DEC_U64
PUSH 1
CALL &NewLine //Print one carriage return
RET
}
Call(_DO_IT);
+15
View File
@@ -0,0 +1,15 @@
/* To run this, do a directory, right click on
this file's name and select "AutoFile".
Or, type $LK,"AutoFile",A="MN:AutoFile"$(filename);
See $LK,"AutoFile",A="FF:::/Doc/Glossary.TXT,AutoFile"$ in the glossary for more info.
*/
I64 i;
for (i=0;i<3;i++)
"Dir;\n";
"$$RED$$//Press a letter to complete the mask$$FG$$\n";
"Dir(\"*.";
I64 ch=GetChar(,FALSE); //Prompt for first digit of mask
"%c*\");\n",ch;
+28
View File
@@ -0,0 +1,28 @@
/* To run this, do a directory, right click on
this file's name and select "AutoFile".
Or, type $LK,"AutoFile",A="MN:AutoFile"$(filename);
See $LK,"AutoFile",A="FF:::/Doc/Glossary.TXT,AutoFile"$ in the glossary for more info.
This autofile will renum the defines in
AFEd.TXT.Z. Test it by numbering a few wrong
and running this demo.
*/
U8 i;
"Ed(\"AFEd.TXT.Z\");\n";
//Go to start of file
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
for (i=0;i<=0xC3;i++) {
if (i)
Msg(MSG_KEY_DOWN_UP,0,SC_F3);
else
"%c0x%c",CH_CTRLF,CH_ESC;
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
"%02X",i;
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
"%c%c",CH_BACKSPACE,CH_BACKSPACE;
}
+230
View File
@@ -0,0 +1,230 @@
//Intermediate compiler codes
#define IC_END 0x00
#define IC_START 0x01
#define IC_NOP1 0x02
#define IC_END_EXP 0x03
#define IC_NOP2 0x04
#define IC_LABEL 0x05
#define IC_CALL_START 0x06
#define IC_CALL_END 0x07
#define IC_CALL_END2 0x08
#define IC_RETURN_VAL 0x09
#define IC_RETURN_VAL2 0x0A
#define IC_IMM_U64 0x0B
#define IC_IMM_F64 0x0C
#define IC_STR_CONST 0x0D
#define IC_ABS_ADDR 0x0E
#define IC_ADDR_IMPORT 0x0F
#define IC_HEAP_GLBL 0x10
#define IC_SIZEOF 0x11
#define IC_TYPE 0x12
#define IC_GET_LABEL 0x13
#define IC_RBP 0x14
#define IC_REG 0x15
#define IC_FS 0x16
#define IC_GS 0x17
#define IC_LEA 0x18
#define IC_MOV 0x19
#define IC_TO_I64 0x1A
#define IC_TO_F64 0x1B
#define IC_TO_BOOL 0x1C
#define IC_TOUPPER 0x1D
#define IC_HOLYC_TYPECAST 0x1E
#define IC_ADDR 0x1F
#define IC_COM 0x20
#define IC_NOT 0x21
#define IC_UNARY_MINUS 0x22
#define IC_DEREF 0x23
#define IC_DEREF_PP 0x24
#define IC_DEREF_MM 0x25
#define IC__PP 0x26
#define IC__MM 0x27
#define IC_PP_ 0x28
#define IC_MM_ 0x29
#define IC_SHL 0x2A
#define IC_SHR 0x2B
#define IC_SHL_CONST 0x2C
#define IC_SHR_CONST 0x2D
#define IC_POWER 0x2E
#define IC_MUL 0x2F
#define IC_DIV 0x30
#define IC_MOD 0x31
#define IC_AND 0x32
#define IC_OR 0x33
#define IC_XOR 0x34
#define IC_ADD 0x35
#define IC_SUB 0x36
#define IC_ADD_CONST 0x37
#define IC_SUB_CONST 0x38
#define IC_EQUAL_EQUAL 0x39
#define IC_NOT_EQUAL 0x3A
#define IC_LESS 0x3B
#define IC_GREATER 0x3C
#define IC_LESS_EQUAL 0x3D
#define IC_GREATER_EQUAL 0x3E
#define IC_PUSH_CMP 0x3F
#define IC_AND_AND 0x40
#define IC_OR_OR 0x41
#define IC_XOR_XOR 0x42
#define IC_COLON 0x43
#define IC_QUESTION 0x44
#define IC_ASSIGN 0x45
#define IC_ASSIGN_PP 0x46
#define IC_ASSIGN_MM 0x47
#define IC_SHL_EQUAL 0x48
#define IC_SHR_EQUAL 0x49
#define IC_MUL_EQUAL 0x4A
#define IC_DIV_EQUAL 0x4B
#define IC_MOD_EQUAL 0x4C
#define IC_AND_EQUAL 0x4D
#define IC_OR_EQUAL 0x4E
#define IC_XOR_EQUAL 0x4F
#define IC_ADD_EQUAL 0x50
#define IC_SUB_EQUAL 0x51
#define IC_JMP 0x52
#define IC_SWITCH 0x53
#define IC_NOBOUND_SWITCH 0x54
#define IC_ADD_RSP 0x55
#define IC_ADD_RSP1 0xC1
#define IC_ENTER 0x56
#define IC_PUSH_REGS 0x57
#define IC_POP_REGS 0x58
#define IC_LEAVE 0x59
#define IC_RET 0x5A
#define IC_CALL 0x5B
#define IC_CALL_INDIRECT 0x5C
#define IC_CALL_INDIRECT2 0x5D
#define IC_CALL_IMPORT 0x5E
#define IC_CALL_EXTERN 0x5F
#define IC_IRQ 0x60
#define IC_ASM 0x61
#define IC_CLI 0x62
#define IC_STI 0x63
#define IC_PREEMPT 0x64
#define IC_CLD 0x65
#define IC_STD 0x66
#define IC_HLT 0x67
#define IC_PUSHFD 0x68
#define IC_POPFD 0x69
#define IC_PAUSE 0x6A
#define IC_CLFLUSH 0x6B
#define IC_INVLPG 0x6C
#define IC_WBINVD 0x6F
#define IC_INVD 0x70
#define IC_IN_U8 0x71
#define IC_IN_U16 0x72
#define IC_IN_U32 0x73
#define IC_OUT_U8 0x74
#define IC_OUT_U16 0x75
#define IC_OUT_U32 0x76
#define IC_GET_RFLAGS 0x77
#define IC_SET_RFLAGS 0x78
#define IC_GET_RAX 0x79
#define IC_SET_RAX 0x7A
#define IC_GET_RBP 0x7B
#define IC_SET_RBP 0x7C
#define IC_GET_RSP 0x7D
#define IC_SET_RSP 0x7E
#define IC_RIP 0x7F
#define IC_RDTSC 0x80
#define IC_HPET 0x81
#define IC_BT 0x82
#define IC_BTS 0x83
#define IC_BTR 0x84
#define IC_BTC 0x85
#define IC_BEQU 0x86
#define IC_LBTS 0x87
#define IC_LBTR 0x88
#define IC_LBTC 0x89
#define IC_LBEQU 0x8A
#define IC_BSF 0x8B
#define IC_BSR 0x8C
#define IC_QUE_INS 0x8D
#define IC_QUE_INS_REV 0x8E
#define IC_QUE_REM 0x8F
#define IC_STRLEN 0x90
#define IC_MEMCPY 0x91
#define IC_MEMSET 0x92
#define IC_MEMSET_U16 0xC2
#define IC_MEMSET_U32 0xC3
#define IC_MEMSET_U64 0xC4
#define IC_BR_ZERO 0x93
#define IC_BR_NOT_ZERO 0x94
#define IC_BR_NOT_EQUAL 0x95
#define IC_BR_EQUAL_EQUAL 0x96
#define IC_BR_GREATER_EQUAL 0x97
#define IC_BR_LESS_EQUAL 0x98
#define IC_BR_GREATER 0x99
#define IC_BR_LESS 0x9A
#define IC_BR_NOT_EQUAL2 0x9B
#define IC_BR_EQUAL_EQUAL2 0x9C
#define IC_BR_GREATER_EQUAL2 0x9D
#define IC_BR_LESS_EQUAL2 0x9E
#define IC_BR_GREATER2 0x9F
#define IC_BR_LESS2 0xA0
#define IC_BR_AND_ZERO 0xA1
#define IC_BR_AND_NOT_ZERO 0xA2
#define IC_BR_AND_AND_ZERO 0xA3
#define IC_BR_AND_AND_NOT_ZERO 0xA4
#define IC_BR_OR_OR_ZERO 0xA5
#define IC_BR_OR_OR_NOT_ZERO 0xA6
#define IC_BR_BT 0xA7
#define IC_BR_BTS 0xA8
#define IC_BR_BTR 0xA9
#define IC_BR_BTC 0xAA
#define IC_BR_LBTS 0xAB
#define IC_BR_LBTR 0xAC
#define IC_BR_LBTC 0xAD
#define IC_BR_NOT_BT 0xAE
#define IC_BR_NOT_BTS 0xAF
#define IC_BR_NOT_BTR 0xB0
#define IC_BR_NOT_BTC 0xB1
#define IC_BR_NOT_LBTS 0xB2
#define IC_BR_NOT_LBTR 0xB3
#define IC_BR_NOT_LBTC 0xB4
#define IC_SWAP_U8 0xB5
#define IC_SWAP_U16 0xB6
#define IC_SWAP_U32 0xB7
#define IC_SWAP_U64 0xB8
#define IC_ABS_I64 0xB9
#define IC_SIGN_I64 0xBA
#define IC_MIN_I64 0xBB
#define IC_MIN_U64 0xBC
#define IC_MAX_I64 0xBD
#define IC_MAX_U64 0xBE
#define IC_LIMIT_I64 0xBF
#define IC_LIMIT_U64 0xC0
#define IC_NUM_ENTRIES 0xC5
+12
View File
@@ -0,0 +1,12 @@
/* This is not an AutoFile. It uses $LK,"AutoStr",A="MN:AutoStr"$
to run text as though from an AutoFile.
This example shows how you can drive pop-up
windows.
*/
Auto(" ");
"PopUp #1:%X\n",PopUpNoYes;
AutoStr("Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);'' CH_SPACE;");
"PopUp #2:%X\n",PopUpNoYes;
+26
View File
@@ -0,0 +1,26 @@
U0 DoWait()
{
I64 i;
for (i=0;i<3;i++) {
"PopUpNoYes;\n ";
//Necessary after a $LK,"DocEntryRun",A="MN:DocEntryRun"$()
//which occurs when PopUp's close.
TaskWait;
"\"%d\\n\\n\";\n",i;
}
}
U0 DoNoWait()
{
I64 i;
for (i=0;i<3;i++)
"PopUpNoYes;\n \"%d\\n\\n\";\n",i;
}
"//With Wait ";PressAKey;
DoWait;
"//With No Wait ";PressAKey;
DoNoWait;
+11
View File
@@ -0,0 +1,11 @@
/* To run this, do a directory, right click on
this file's name and select "AutoFile".
Or, type $LK,"AutoFile",A="MN:AutoFile"$(filename);
See $LK,"AutoFile",A="FF:::/Doc/Glossary.TXT,AutoFile"$ in the glossary for more info.
Profiling does not $UL,1$require$UL,0$ autofiles.
*/
"$$RED$$ProfAll;$$FG$$\n";
"$$RED$$//Collecting Data$$FG$$";
PressAKey;
"\n$$RED$$ProfRep;$$FG$$\n";
+13
View File
@@ -0,0 +1,13 @@
U0 AFSetIPDemo()
{
I64 t,l;
WinBorder(ON);
l=Fs->pix_left+Fs->scroll_x;
t=Fs->pix_top+Fs->scroll_y;
SetIP(,,,FALSE,FALSE,FALSE); //Mouse unclicked
AFSetIP(,l-4,t-4);
AFSetIP(20,l+20,t+20,,TRUE);
SetIP(,,,FALSE,FALSE,FALSE);
}
AFSetIPDemo;
+47
View File
@@ -0,0 +1,47 @@
//This shows the $LK,"Carry",A="MN:Carry"$ function.
//It holds the CPU carry flag.
//$LK,"U",A="MN:U"$() Unassemble to make sure it is
//right.
U0 BigCnt()
{
U64 lo=0,hi=0;
"BigCnt\n";
while (hi<0x10) {
lo+=1<<58;
hi+=Carry;
"%016X %016X\n",hi,lo;
}
}
BigCnt;
U0 BigShift()
{
U64 lo=1,hi=0;
"Big Shift\n";
while (lo||hi) {
hi<<=1;
lo<<=1;
hi+=Carry;
"%016X %016X\n",hi,lo;
}
}
BigShift;
U0 Branch()
{
U64 i=0xFFCC3311,j;
"Branch\n";
for (j=0;j<64;j++) {
i<<=1;
if (Carry)
"1";
else
"0";
}
"\n";
}
Branch;
+81
View File
@@ -0,0 +1,81 @@
//This demonstrates class meta data.
//Basically, we make use of the compiler's
//data about a class. We can add to the
//compilers data arbitrary items, either string or
//or int or F64 (if you typecast).
//This stuff is not high performance.
//Don't get carried away -- it might be slow.
U0 RankOut(I64 i)
{
" %z",i,"Cadet\0Ensign\0Captain\0Admiral\0President\0";
}
class Test1Struct
{
I64 age print_str "%2d" dft_val 38;
I64 color dft_val RED; //Accepts expressions
I64 rank print_str "%1d" dft_val 6/2 output_fun &RankOut;
};
class Test2Struct
{
I64 age print_str "%2d" dft_val 38 percentile 54.20;
I64 rank print_str "%1d" dft_val 5;
I64 serial_num print_str "%6d" dft_val 123456;
};
U0 DumpStruct(U8 *_d,U8 *class_name=lastclass)
{//lastclass is keyword
CHashClass *tempc=HashFind(class_name,Fs->hash_table,HTT_CLASS);
U8 *print_str;
I64 *q,dft_val;
U0 (* fp_output_fun)(I64 i);
F64 percentile;
if (!tempc) return;
CMemberLst *ml;
ml=tempc->member_lst;
while (ml) {
"%s:",ml->str;
//All our items are I64's. If you want, you can check
//the data type of the member var. See $LK,"ClassRep",A="MN:ClassRep"$().
q=_d+ml->offset;
if (print_str=MemberMetaData("print_str",ml))
"" print_str,*q;
//This is slightly ambiguous -- if no meta is present it will return zero.
if (dft_val=MemberMetaData("dft_val",ml))
" default:%d",dft_val;
//This corrects for the ambiguity, allowing zero percentile.
if (MemberMetaFind("percentile",ml)) { //check if it exists
//We could use the $LK,"CMemberLstMeta",A="MN:CMemberLstMeta"$ structure returned by
//$LK,"MemberMetaFind",A="MN:MemberMetaFind"$() and save a search.
percentile=MemberMetaData("percentile",ml)(F64);
" percentile: %5.2f",percentile;
}
if (fp_output_fun=MemberMetaData("output_fun",ml))
(*fp_output_fun)(*q);
NewLine;
ml=ml->next;
}
}
Test1Struct t1;
t1.age=44;
t1.rank=3;
DumpStruct(&t1);
Test2Struct t2;
t2.age=22;
t2.rank=2;
t2.serial_num=55555;
DumpStruct(&t2);
+37
View File
@@ -0,0 +1,37 @@
F64 glbl;
F64 CompileDemo(U8 *st)
{
I64 type;
U8 *ex;
CLex *lx=LexNew(st,LF_DONT_FREE_BUF);
F64 result=0;
Lex(lx); //Gotta get it started
"Compile \"%s\"\n",st;
do {
if (ex=LexExpression2Bin(lx,&type)) {
if (type!=RT_F64)
result=ToF64(Call(ex));
else
result=Call(ex)(F64);
Free(ex);
}
"result=%9.4f\n",result;
if (lx->token==';')
Lex(lx);
} while (lx->token!=TK_EOF); //end of file?
LexDel(lx);
return result;
}
CompileDemo("2+Cos(ã)");
CompileDemo("1;2+4");
CompileDemo("glbl=1;glbl*2;glbl/3;Sin(glbl)");
//This is just like you typed-it on
//the cmd line.
ExePrint(
"I64 i;"
"for (i=0;i<10;i++) "
" \"%%d\n\",i;"
);
+11
View File
@@ -0,0 +1,11 @@
"\n\n%D %T\n\n\n",Now,Now;
"Year:%d Month:%d Day:%d\n\n\n",Year,Month,Day;
CDate cdt=Now;
"Hour:%02d Minute:%02d Second:%02d\n\n\n",Hour24(cdt),Minute(cdt),Second(cdt);
"Day Name:%03tZ\n\n\n",WeekDay(cdt),"ST_DAYS_OF_WEEK";
"Month Name:%03tZ\n\n\n",Month(cdt)-1,"ST_MONTHS";
+28
View File
@@ -0,0 +1,28 @@
/*
Press <CTRL-ALT-C> to break.
Rerun Program
Press <CTRL-ALT-D> to enter Dbg.
> $LK,"Dr",A="MN:Dr"$; //Dump Regs
> $LK,"G2",A="MN:G2"$; //Cont program
Press <CTRL-ALT-D> to enter Dbg.
> $LK,"Uf",A="MN:Uf"$("DbgDemo");
> $LK,"U",A="MN:U"$(_RIP);
See $LK,"Debugging",A="HI:Debugging"$
*/
U0 DbgDemo()
{
I64 i=0;
while (TRUE)
if (!(i++%2000000))
".";
}
DbgDemo;
+40
View File
@@ -0,0 +1,40 @@
/*
See $LK,"Define",A="HI:Char/Define"$.
*/
//These might be in the Adam task.
DefineLoad("ST_YES_NO","(Yes or No)");
DefineLoad("ST_EXIT","Exit");
DefineLstLoad("ST_NO_YES_LST","No\0Yes\0");
//New strings might be loaded for each user
//to override.
"Spanish";
if (YorN) {
DefineLoad("ST_YES_NO","(Si or No)");
DefineLoad("ST_EXIT","Salida");
DefineLstLoad("ST_NO_YES_LST","No\0Si\0");
}
Bool Quit()
{
Bool result;
U8 *st;
I64 i;
while (TRUE) {
"%S %S?","ST_EXIT","ST_YES_NO";
st=MGetS;
i=DefineMatch(st,"ST_NO_YES_LST",LMF_IGNORE_CASE);
if (i>=0) {
result=i;
break;
}
Free(st);
}
return result;
}
Quit;
+78
View File
@@ -0,0 +1,78 @@
U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
{
//This routine is called by the window
//mgr things would get corrupted
//if the window mgr used it's own
//heap, so we use the owning task's heap.
U8 *st=MAlloc(64,mem_task);
CDate cdt=tS*CDATE_FREQ;
//Doesn't have to be fixed width!!
SPrint(st,"%d=%T",cdt,cdt);
return st;
}
U8 *CurTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
{
U8 *st=MAlloc(64,mem_task);
CDate cdt=Now;
SPrint(st,"%D %T",cdt,cdt);
return st;
}
U0 DoIt()
{
CDoc *bdoc=DocBorder,
*pdoc=DocPut;
CDocEntry *doc_e;
//We don't want an update between
//creating the CDocEntry and defining the
//callback, so we turn-off preemption.
Bool old_preempt=Preempt(OFF);
DocBottom(bdoc); //Ins at the bottom
DocPrint(bdoc,"$$RED$$$$CM+BY+LX,5,-3$$");
//The $LK,"DocPrint",A="MN:DocPrint"$() routine returns the addr of the last entry.
doc_e=DocPrint(bdoc,"$$TX+TC,\" \"$$");
//The TC flag is "has tag callback".
//Flags are explained here:
// $LK,"::/Doc/Widget.TXT"$
// $LK,"::/Doc/Dollar.TXT"$
// $LK,"Dollar Flags",A="MN:DOCEf1_TAG"$
// $LK,"ST_DOC_FLAGS",A="FF:::/Adam/Doc/DocInit.CPP,ST_DOC_FLAGS"$
doc_e->tag_cb=&tSCB;
DocPrint(bdoc,"$$FG$$");
//$BK,1$WARNING:$BK,0$ If you use the put_doc you
//run the risk of the user pressing
//<CTRL-T> or using the clipboard, both
//of which will crash. So, you might want
//to use the border_doc.
DocPrint(pdoc,"$$LTRED$$");
doc_e=DocPrint(pdoc,"$$TX+TC,\" \"$$");
doc_e->tag_cb=&CurTimeCB;
DocPrint(pdoc,"$$FG$$");
Preempt(old_preempt);
//Send carriage return, new line, so
//that the timer string is not part
//of the next cmd on the cmd line.
NewLine;
}
U0 UndoIt()
{
//Clear-out entries without a +H hold flag.
DocClear(Fs->border_doc);
}
DoIt;
+38
View File
@@ -0,0 +1,38 @@
U0 CursorMovementDemo()
{
I64 i;
for (i=0;i<100;i++) {
"%03d ",i;
"$$CM,-4,1$$";
if (i%10==9)
"$$CM,4,-10$$";
}
//+LX is relative to left side.
//See <CTRL-L> with cursor-movement for all the flags.
//Check "Quote" to set-up a cmd for in quotes.
"$$CM+LX,0,+10$$\n";
}
CursorMovementDemo;
//The word-wrap Off and On cmds are
//$$WW,0$$ and $$WW,1$$.
//You might need $LK,"DocMax",A="MN:DocMax"$() to adjust
//the cmd line window buf size.
//It counts cmds, not lines.
//The +H flag will hold-onto an entry
//so it doesn't get pushed-out of the document.
//This is useful for a $$WW+H,1$$ cmd.
//See $LK,"::/Doc/Dollar.TXT"$ for documentation on
//all flags and cmds.
//Note: the default page length is 66 lines
//and branching back more than the page length
//will rst the column to 1. So, set page
//length to a large number if you want to
//branch back a long distance.
+66
View File
@@ -0,0 +1,66 @@
/*
$$DA is the data widget.
-TRM flag is for var
width fields with a terminator
character.
+RD refreshes the data.
+UD updates the val when you edit it.
+U32 means the val is 4 bytes.
-U64 U64 is the default so we might
want to turn-it-off. Strings
use U64.
,32 sets the tag string width.
See $LK,"Data Tag Width",A="FA:::/Adam/Doc/DocPlain.CPP,DataTagWidth"$.
-P Means it is a string var, basically.
*/
I32 i;
U8 buf[8];
U0 UpdateGlblTask(I64)
{
while (TRUE) {
i++;
Sleep(1);
}
}
U0 DataDemo()
{
CDocEntry *doc_e;
//This is the command line document.
CDoc *doc=DocPut;
//We do this to prevent access to
//doc_e->data before it is set.
Bool unlock=DocLock(doc);
//You might set the $LK,"DOCF_FORM",A="MN:DOCF_FORM"$ flag.
// doc->flags|=DOCF_FORM
//if you wish.
Spawn(&UpdateGlblTask,NULL,"Update Glbl",,Fs);
"Enter editor overstrike mode\n"
"and you can modify the val.\n"
"However, changes happen immediately,\n"
"so it's tricky.\n\n";
//Use <CTRL-L> for the $$DA,$$ format.
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD-U64+U32,32,A=\"%%12d\"$$\n");
doc_e->data=&i;
StrCpy(buf,"Terry");
doc_e=DocPrint(doc,"$$DA-P+RD+UD,7,A=\"Str:%%s\"$$\n");
doc_e->data=buf;
if (unlock)
DocUnlock(doc);
}
DataDemo;
//See $LK,"PopUpExtents",A="MN:PopUpExtents"$().
+25
View File
@@ -0,0 +1,25 @@
/*
The +D flag causes a define-string
look-up and substitution.
It is available in the <CTRL-L> text-widget
menu under text entries for use in
documentation.
*/
DefineLoad("COMPANY","Trivial Solutions");
"Company: $$TX,\"\",D=\"COMPANY\"$$\n";
DefinePrint("COMPANY_TIME","%T",Now);
#exe {
StreamPrint(
"#define COMPANY_AGE %0.1f\n",
(Now-A2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
};
"Age : $$TX,\"\",D=\"COMPANY_AGE\"$$ years\n";
"Time: $$TX,\"\",D=\"COMPANY_TIME\"$$\n";
Binary file not shown.
+68
View File
@@ -0,0 +1,68 @@
public U0 DocProfile(U8 *filename,I64 flags)
{
I64 i,*cmd_stats=CAlloc(sizeof(I64)*DOCT_NUM_TYPES),
*flags_stats=CAlloc(sizeof(I64)*64),
*type_flags_stats=CAlloc(sizeof(I64)*64);
//Note, word wrap is determined by
//doc->win_task when a $LK,"CDoc",A="MN:CDoc"$ is recalculated
//use $LK,"DocRecalc",A="MN:DocRecalc"$().
CDoc *doc=DocRead(filename,flags);
//doc->root which is equal to doc is the
//header of the CQue and represents the end-of-file marker.
CDocEntry *doc_e=doc->root.next;
while (doc_e!=doc) {
cmd_stats[doc_e->type_u8]++;
for (i=0;i<64;i++)
if (Bt(&doc_e->flags1,i))
flags_stats[i]++;
for (i=16;i<32;i++)
if (Bt(&doc_e->type,i))
type_flags_stats[i]++;
doc_e=doc_e->next;
}
DocDel(doc);
"$$PURPLE$$-------%s-------\n",filename;
"$$GREEN$$The lowest byte of the 32-bit 'doc_e->type', '$$PURPLE$$doc_e->type.u8[0]$$GREEN$$', is cmd and accessed with the union '$$PURPLE$$doc_e->type_u8$$GREEN$$'. "
"See $$LK,\"CDocEntry\",A=\"MN:CDocEntry\"$$, "
"$$LK,\"Doc Type Defines\",A=\"MN:DOCT_TEXT\"$$ and $$LK,\"Doc Type Codes\",A=\"FF:::/Adam/Doc/DocInit.CPP,ST_DOC_CMDS\"$$.\n$$FG$$";
for (i=0;i<DOCT_NUM_TYPES;i++)
if (cmd_stats[i])
"%4Z:%d\n",i,"ST_DOC_CMDS",cmd_stats[i];
"\n$$GREEN$$'$$PURPLE$$doc_e->type.u8[1]$$GREEN$$' is the screen color attr of the entry. "
"'$$PURPLE$$doc_e->type.u16[1]$$GREEN$$' is some flags for blinking and stuff. "
"See $$LK,\"Doc Type Flag Defines\",A=\"MN:DOCET_BLINK\"$$.\n$$FG$$";
for (i=16;i<32;i++)
if (type_flags_stats[i])
"%4d:%d\n",i,type_flags_stats[i];
"$$GREEN$$\n'$$PURPLE$$doc_e->flags1$$GREEN$$' is 64-bit. "
"See $$LK,\"Doc Flag Defines\",A=\"MN:DOCEf1_TAG\"$$ and $$LK,\"Doc Flag Codes\",A=\"FF:::/Adam/Doc/DocInit.CPP,ST_DOC_FLAGS\"$$.\n$$FG$$";
for (i=0;i<64;i++)
if (flags_stats[i])
"%4Z:%d\n",i,"ST_DOC_FLAGS",flags_stats[i];
Free(cmd_stats);
Free(flags_stats);
PressAKey;
NewLine;
}
//See $LK,"TipOfDay",A="MN:TipOfDay"$.
//Note: Not all $LK,"CDocEntry",A="MN:CDocEntry"$'s are full-sized nodes.
//Some are $LK,"MAlloc",A="MN:MAlloc"$ed with a smaller size to save
//mem. They all have at least the size $LK,"CDocEntryBase",A="MN:CDocEntryBase"$.
//Note: $LK,"CDocEntry",A="MN:CDocEntry"$'s should be allocated from the
//heap of the owning task, doc->mem_task.
//The flag arrays $LK,"doc_type_flags_form",A="MN:doc_type_flags_form"$, etc
//are useful.
DocProfile("::/Doc/ChangeLog.TXT",0);
DocProfile("::/Doc/ChangeLog.TXT",DOCF_PLAIN_TEXT);
+44
View File
@@ -0,0 +1,44 @@
class FDStruct
{
//Use <CTRL-L> and select "Data" to generate the fmtstrs
//The number is the field from after the ':' to the end.
// See $LK,"Data Tag Width",A="FA:::/Adam/Doc/DocPlain.CPP,DataTagWidth"$.
F64 num1 fmtstr "$$DA-TRM,32,A=\"F64 1:%12.8f\"$$\n";
F64 num2 fmtstr "$$DA-TRM,32,A=\"F64 2:%12e\"$$\n";
I64 num3 fmtstr "$$DA-TRM,32,A=\"I64 1:0x%016X\"$$\n";
I64 num4 fmtstr "$$DA-TRM,32,A=\"I64 2:%12d\"$$\n";
U8 name[32] fmtstr "$$DA-P,31,A=\"Name :%s\"$$\n";
CDate datetime fmtstr "$$DA-TRM,32,A=\"Date :%8D\"$$\n";
};
U0 FormDemo()
{
FDStruct fds;
CDate cdt;
fds.num1=12.3e-4; //Set defaults
fds.num2=4.5e3;
fds.num3=0x1234;
fds.num4=-567;
StrCpy(&fds.name,"John");
cdt=Now;
fds.datetime=cdt;
if (DocFormDo(&fds)) {
"#1=%e\n",fds.num1;
"#2=%e\n",fds.num2;
"#3=%d\n",fds.num3;
"#4=%d\n",fds.num4;
"Name=%s\n",fds.name;
"Date=%D\n",fds.datetime;
} else
"Cancel\n";
"\n\nClassRep Example\n";
ClassRep(&fds);
//See also $LK,"ClassRepD",A="MN:ClassRepD"$().
}
FormDemo;
+76
View File
@@ -0,0 +1,76 @@
//This example shows buttons. Buttons return a menu val
//unless you rig them to send macros. Menu entries are
//about the same as buttons, but don't have a border.
I64 PopUpFreq()
{ //See also $LK,"PopUpRangeI64",A="MN:PopUpRangeI64"$()
I64 i;
CDoc *doc=DocNew;
DocPrint(doc,"$$TX+CX,\"Set Freq\"$$\n" //Centered text
"$$CM+LX,2,4$$$$BT,\"100 Hz\",LE=100$$"
"$$CM+LX,18,0$$$$BT,\"200 Hz\",LE=200$$"
"$$CM+LX,2,4$$$$BT,\"400 Hz\",LE=400$$"
"$$CM+LX,18,0$$$$BT,\"800 Hz\",LE=800$$\n");
i=PopUpMenu(doc);
if (i<0) i=0; // <SHIFT-ESC>
DocDel(doc);
return i;
}
#define MU_NOTHING 0
#define MU_SET_FREQ 1
#define MU_SND_ON 2
#define MU_SND_OFF 3
U0 MenuButton()
{
Bool done=FALSE;
I64 i,j=0,freq=100;
I64 old_flags=DocPut->flags;
//This allows keyboard navigation to skip nonselectible entries.
DocPut->flags|=DOCF_FORM;
do {
DocClear;
//Use <CTRL-L> to generate cursor movement expressions and check "Quote".
"$$CM+CX-RE,-4$$Menu Demo\n\n";
"$$LM,8$$"; //Set left margin
//These are buttons that return a val from a menu selection.
if (!j)
"\n$$BT,\"Snd On\",LE=MU_SND_ON$$\n\n\n";
else
"\n$$BT,\"Snd Off\",LE=MU_SND_OFF$$\n\n\n";
"\n$$BT,\"Set Freq\",LE=MU_SET_FREQ$$\n\n\n"
"\n$$BT,\"Nothing\",LE=MU_NOTHING$$\n\n\n"
"\n$$BT,\"Done\",LE=DOCM_CANCEL$$\n\n\n";
i=DocMenuDo(DocPut);
DocBottom;
switch (i) {
case MU_NOTHING:
break;
case MU_SND_ON:
j=freq;
Snd(j);
break;
case MU_SND_OFF:
j=0;
Snd(j);
break;
case MU_SET_FREQ:
freq=PopUpFreq;
if (j) {
j=freq;
Snd(j);
}
break;
default:
done=TRUE;
}
} while (!done);
DocPut->flags=DocPut->flags&~DOCF_FORM |
old_flags & DOCF_FORM;
DocClear;
Snd(0);
}
MenuButton;
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
"\nSuper : 3$$SY,-3$$2$$SY,0$$=9\n\n"
"Sub : H$$SY,3$$2$$SY,0$$O\n\n"
"Color : $$RED$$Test$$FG$$\n\n"
"Blink : $$BK,1$$Test$$BK,0$$\n\n"
"Invert : $$IV,1$$Test$$IV,0$$\n\n"
"UnderLine: $$UL,1$$Test$$UL,0$$\n\n"
"Link : $$LK,\"Genesis,1:1\",\"BF:Genesis,1:1\"$$\n\n\n"
"Button : $$BT-X,\"OKAY\",LE=1$$\n\n\n\n";
//You can do it this way if you like.
"\nSuper : 3$SY,-3$2$SY,0$=9\n\n"
"Sub : H$SY,3$2$SY,0$O\n\n"
//Can't see color because of syntax highlighting. Press <CTRL-T>
"Color : $FG,4$Test$FG$\n\n"
"Blink : $BK,1$Test$BK,0$\n\n"
"Invert : $IV,1$Test$IV,0$\n\n"
"UnderLine: $UL,1$Test$UL,0$\n\n"
//<CTRL-SHIFT-T> on this link to toggle individual commands.
"Link : $LK,"Genesis,1:1",A="BF:Genesis,1:1"$\n\n\n"
"Button : $BT,"OKAY",LE=1$\n\n\n\n";
+54
View File
@@ -0,0 +1,54 @@
/*
This uses $LK,"DocPrint",A="MN:DocPrint"$() because updates
to within a tree while a tree is collapsed get
messed-up if "live" (like using ordinary Print.)
The insert point is confused by hiding of
data in collapsed trees. Therefore, the window main
Doc is taken off-line by disabling preemption so there
are no screen updates until all data has been inserted.
There is a special Doc function which is also
available to take an Doc off-line. See $LK,"DocPrintWhole",A="MN:DocPrintWhole"$.
For this example, however, I wanted to use DocPrint
and disabled Preemption myself.
*/
U0 TreeSub(CDoc *doc,CDirEntry *tempde)
{
CDirEntry *tempde1;
while (tempde) {
tempde1=tempde->next;
if (tempde->attr & _ATTR_DIR) {
DocPrint(doc,"$$TR,\"\"$$");
DocPrint(doc,"$$MA,T=\"%s\",LM=\"Cd(\\\"%s\\\");Dir;\n\"$$\n",
tempde->name,tempde->full_name);
if (tempde->sub) {
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
}
} else
DocPrint(doc,"$$LK,\"%s\",A=\"FI:%s\"$$\n",
tempde->name,tempde->full_name);
//Note there is also a routine
//to delete an entire CDirEntry tree.
//See $LK,"DirLstDel",A="MN:DirLstDel"$().
DirEntryDel(tempde);
tempde=tempde1;
}
}
U0 TreeDemo()
{
I64 fuf_flags=0;
CDoc *doc=DocNew;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
DocPrint(doc,"$$TR-C,\"\"$$\n");
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,FilesFind("/*",fuf_flags));
DocPrint(doc,"$$ID,-2$$");
DocInsDoc(DocPut,doc);
DocDel(doc);
}
TreeDemo;
+84
View File
@@ -0,0 +1,84 @@
/*
This scans the sym table and checks
each $LK,"HTT_DEFINE_STR",A="MN:HTT_DEFINE_STR"$ entry to see if
it only occurs once in files.
It's a brute force solution, but
gets the job done... slowly.
$LK,"Grep",A="MN:Grep"$() returns a count of matches.
$LK,"FileOcc",A="MN:FileOcc"$() is $LK,"Grep",A="MN:Grep"$() with
output $LK,"Silent",A="MN:Silent"$().
*/
U0 UnusedDefineScan()
{
CDoc *old_put_doc,*old_display_doc,*doc;
I64 cnt=0;
CHashTable *tempht;
CHash *temph;
CDocEntry *doc_e,*doc_e2;
Bool old_silent=IsSilent;
//Technically, we might want to
//turn-off preemption in case the
//table was modified.
try {
tempht=Fs->hash_table;
while (tempht) {
temph=tempht->next_added;
while (temph!=tempht) {
if (temph->type&HTT_DEFINE_STR)
cnt++;
temph=temph->next_added;
}
tempht=tempht->next;
}
progress1=0;
progress1_max=cnt;
StrCpy(progress1_desc,"Define Scan");
tempht=Fs->hash_table;
while (tempht) {
temph=tempht->next_added;
while (temph!=tempht) {
if (temph->type&HTT_DEFINE_STR) {
progress1++;
if (FileOcc(temph->str,"/*","+l-i+T")==1) {
doc=DocNew;
old_put_doc=DocPut;
old_display_doc=DocDisplay;
Fs->put_doc=Fs->display_doc=doc;
Grep(temph->str,"/*","+l-i+T");
Fs->put_doc=old_put_doc;
Fs->display_doc=old_display_doc;
doc_e=doc->root.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_LINK) {
"%s ",temph->str;
doc_e2=DocEntryCopy(doc,doc_e);
DocInsEntry(old_put_doc,doc_e2);
NewLine;
}
doc_e=doc_e->next;
}
DocDel(doc);
}
}
temph=temph->next_added;
}
tempht=tempht->next;
}
} catch
PutExcept;
Silent(old_silent);
NewLine;
ProgressBarsRst;
}
UnusedDefineScan;
+68
View File
@@ -0,0 +1,68 @@
#define DB_FILENAME "HOME/DataBaseDemo.BIN"
#define DB_MAX_ACCT 100
#define DB_ACCT_BLKS 1
class Acct
{ //Use <CTRL-L> to help generate fmtstrs.
U8 name[32] fmtstr "$$DA-P,32,A=\"Name:%s\"$$\n";
U8 addr[64] fmtstr "$$DA-P,64,A=\"Addr:%s\"$$\n";
U8 pad[DB_ACCT_BLKS*BLK_SIZE-64-32];
};
U0 InitDatabase()
{
CFile *f;
//Write new contiguous file
f=FOpen(DB_FILENAME,"w",DB_MAX_ACCT*DB_ACCT_BLKS);
FClose(f);
}
U0 WriteAcct()
{
CFile *f;
Acct a;
I64 acctnum;
acctnum=PmtI64("Acct #",-1);
if (0<=acctnum<DB_MAX_ACCT) {
MemSet(&a,0,BLK_SIZE);
if (DocFormDo(&a)) {
f=FOpen(DB_FILENAME,"w+");
FWBlks(f,&a,acctnum*DB_ACCT_BLKS,DB_ACCT_BLKS);
FClose(f);
}
}
}
U0 ReadAcct()
{
CFile *f;
Acct a;
I64 acctnum;
acctnum=PmtI64("Acct #",-1);
if (0<=acctnum<DB_MAX_ACCT) {
f=FOpen(DB_FILENAME,"r");
FRBlks(f,&a,acctnum*DB_ACCT_BLKS,DB_ACCT_BLKS);
FClose(f);
ClassRep(&a);
}
}
U0 DatabaseDemo()
{
I64 ch;
if (!FileFind(DB_FILENAME))
InitDatabase;
do {
"$$GREEN$$R$$FG$$ead acct, $$GREEN$$W$$FG$$rite acct or $$GREEN$$<SHIFT-ESC>$$FG$$:";
ch=ToUpper(GetChar);
NewLine;
if (ch=='R') ReadAcct;
if (ch=='W') WriteAcct;
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
}
DatabaseDemo;
+41
View File
@@ -0,0 +1,41 @@
U0 RawAccess(I64 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
CBlkDev *bdev=Drv2BlkDev(drv_let);
I64 blk,old_offset,old_size;
U8 *buf=MAlloc(BLK_SIZE);
PrtRep;
PressAKey;
ClassRep(p);
PressAKey;
ClassRep(bdev);
PressAKey;
//Temporarily change partition range to full device.
//Normally, you are limited to just your partition.
//This is obviously $BK,1$dangerous$BK,0$!
old_offset=p->offset;
old_size =p->size;
p->offset=bdev->min_blk;
p->size=bdev->max_blk-bdev->min_blk+1;
try {
blk=PmtI64("Blk to Read: ",old_offset,bdev->min_blk,bdev->max_blk);
RBlks(p,buf,blk,1);
D(buf,BLK_SIZE);
} catch
PutExcept;
p->offset=old_offset;
p->size =old_size;
Free(buf);
}
RawAccess;
//See $LK,"RBlks",A="MN:RBlks"$(), $LK,"WBlks",A="MN:WBlks"$(), $LK,"PrtLock",A="MN:PrtLock"$(), $LK,"PrtUnlock",A="MN:PrtUnlock"$()
//$LK,"DBlk",A="MN:DBlk"$(), $LK,"DCluster",A="MN:DCluster"$(), $LK,"BlkDevLock",A="MN:BlkDevLock"$() and $LK,"BlkDevUnlock",A="MN:BlkDevUnlock"$().
+49
View File
@@ -0,0 +1,49 @@
/* There is no FPrintF type function and no
way to grow files. Therefore, use mem to
hold the file until you are done. The $LK,"CDoc",A="MN:CDoc"$
framework is convenient for this.
*/
U0 TreeSub(CDoc *doc,CDirEntry *tempde)
{
CDirEntry *tempde1;
while (tempde) {
tempde1=tempde->next;
if (tempde->attr & _ATTR_DIR) {
DocPrint(doc,"$$TR,\"\"$$");
DocPrint(doc,"$$MA,T=\"%s\",LM=\"Cd(\\\"%s\\\");Dir;\n\"$$\n",
tempde->name,tempde->full_name);
if (tempde->sub) {
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
}
} else
DocPrint(doc,"$$LK,\"%s\",A=\"FI:%s\"$$\n",
tempde->name,tempde->full_name);
//Note there is also a routine
//to delete an entire CDirEntry tree.
//See $LK,"DirLstDel",A="MN:DirLstDel"$().
DirEntryDel(tempde);
tempde=tempde1;
}
}
U0 FPrintFDemo(U8 *output_filename=NULL)
{
I64 fuf_flags=0;
CDoc *doc=DocNew(output_filename);
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
DocPrint(doc,"$$TR-C,\"\"$$\n");
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,FilesFind("/*",fuf_flags));
DocPrint(doc,"$$ID,-2$$");
DocRecalc(doc);
if (output_filename)
DocWrite(doc,FALSE);
else
DocWrite(doc,TRUE);
DocDel(doc);
}
FPrintFDemo;
+15
View File
@@ -0,0 +1,15 @@
U0 UnusedSpaceRep()
{
I64 i;
CPrt *p;
for (i=0;i<26;i++)
try {
p=Drv2Prt(i+'A');
if (p->type==PT_FAT32 || p->type==PT_REDSEA)
"%C: %7.3f%% Free\n",
Prt2Drv(p),UnusedDrvSpace(Prt2Drv(p))*100.0/(p->size*BLK_SIZE);
} catch
Fs->catch_except=TRUE;
}
UnusedSpaceRep;
+48
View File
@@ -0,0 +1,48 @@
//$BK,1$WARNING:$BK,0$ Don't return out of a catch{}. This
//might get fixed.
//You can use $LK,"PutExcept",A="MN:PutExcept"$() in a catch statement
//and it will report args.
Bool Pmt(I64 i)
{
"%d ",i;
return YorN;
}
U0 D1()
{
"D1\n";
if (Pmt(1)) throw('Point1');
if (Pmt(2)) throw('Point2');
}
U0 D2()
{
"D2\n";
try {
D1;
if (Pmt(4)) throw('Point4');
} catch {
"D2 handler\n"
"Ch:%c:%P\n",Fs->except_ch,Fs->except_caller1;
if (Fs->except_ch=='Point1') {
"Caught in D2\n";
Fs->catch_except=TRUE;
}
}
}
U0 Demo()
{
try {
D2;
if (Pmt(3)) throw('Point3');
} catch {
"Demo handler\n"
"Ch:%c:%P\n",Fs->except_ch,Fs->except_caller1;
Fs->catch_except=TRUE;
}
}
Demo;
+36
View File
@@ -0,0 +1,36 @@
U0 Install()
{
gr_font[8*255+0]=0b00111100;
gr_font[8*255+1]=0b01000010;
gr_font[8*255+2]=0b10100101;
gr_font[8*255+3]=0b10000001;
gr_font[8*255+4]=0b11000011;
gr_font[8*255+5]=0b10111101;
gr_font[8*255+6]=0b01000010;
gr_font[8*255+7]=0b00111100;
}
Install;
"Face:ÿ\n";
//Chars 128-255 are treated as letters
//by the compiler and everything else.
//Enter them by holding ALT and
//pressing a 3 digit decimal number or
//press <CTRL-ALT-A>.
U0 SrcExample()
{
I64 fÿÿ=12345;
"fÿÿ=%d\n",fÿÿ;
}
SrcExample;
//See $LK,"::/Demo/ScreenCodes.CPP"$
//$LK,"::/Demo/Graphics/CharGraphics.CPP"$,
//and $LK,"::/Demo/Graphics/FontEd.CPP"$.
//See $LK,"chars_bitmap_alpha",A="MN:chars_bitmap_alpha"$, and
//$LK,"chars_bitmap_alpha_numeric",A="MN:chars_bitmap_alpha_numeric"$.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+767
View File
@@ -0,0 +1,767 @@
//This uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/CastleFrankenstein","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/CastleFrankenstein");
//Set snap to 4 and width to 4
//if you edit this map.
//Don't forget to change the
//starting pos.
#define MAN_START_X 0
#define MAN_START_Y 4.5
$SP,"<1>",BI=1$
#define MONSTER_SCALE 2.0
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$
#define PLANT_SCALE 2.0
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
#define SCREEN_SCALE 512
#define PLOT_GRID_WIDTH 24
#define PLOT_GRID_HEIGHT 24
#define MAN_HEIGHT 125
#define MAP_SCALE 4
I64 map_width,map_height;
U8 *map=NULL,
*panels_processed_bitmap=NULL;
I64 man_xx,man_yy;
F64 man_é;
F64 t0,tf;
#define NUM_MONSTERS 16
I64 monsters_left;
class Monster
{
I64 x,y;
Bool dead,pad[7];
} monsters[NUM_MONSTERS];
U0 CFTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
{
I64 zz;
GrRot(dc->r,x,y,z);
zz=SCREEN_SCALE/3+*z;
if (zz<1) zz=1;
*x=SCREEN_SCALE/2* *x/zz;
*y=SCREEN_SCALE/2* (*y+MAN_HEIGHT)/zz;
*x+=dc->x;
*y+=dc->y;
*z+=dc->z;
}
#define LOS_SCALE 4
Bool LOSPlot(U8 *,I64 x,I64 y,I64)
{
if (!map[(y/LOS_SCALE)*map_width+(x/LOS_SCALE)])
return FALSE;
else
return TRUE;
}
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
{ //Line of sight
return Line(NULL,x1*LOS_SCALE/SCREEN_SCALE,y1*LOS_SCALE/SCREEN_SCALE,0,
x2*LOS_SCALE/SCREEN_SCALE,y2*LOS_SCALE/SCREEN_SCALE,0,&LOSPlot);
}
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,*r1,*r2,*r3,*s2w,xx,yy,zz,x,y,x1,y1,z1,
c,x1w,y1w,x1h,y1h,xh,yh,zh,
cx=task->pix_width/2,
cy=task->pix_height/2;
CSprite *temps;
F64 tt;
CD3I32 poly[4];
DCAllocDepthBuf(dc);
MemSet(panels_processed_bitmap,0,(map_width*map_height+7)>>3);
//World to screen
GrRotZEqu(dc->r,man_é+ã/2);
GrRotXEqu(dc->r,ã/2);
GrSetRotMat(dc,dc->r);
xh=-man_xx/SCREEN_SCALE; yh=-man_yy/SCREEN_SCALE; zh=0;
GrRot(dc->r,&xh,&yh,&zh);
GrSetTranslation(dc->r,xh,yh,zh);
//Screen to world
s2w=GrRotXNew(-ã/2,task);
GrRotZEqu(s2w,-man_é-ã/2);
xh=0; yh=0; zh=SCREEN_SCALE;
GrRot(s2w,&xh,&yh,&zh);
//Rotate light source
xx=dc->ls.x; yy=dc->ls.y; zz=-dc->ls.z;
(*dc->transform)(dc,&xx,&yy,&zz);
dc->ls.x=xx; dc->ls.y=yy; dc->ls.z=zz;
dc->flags|=DCF_TRANSFORMATION;
dc->transform=&CFTransform;
dc->x=cx;
dc->y=cy;
r1=GrRotXNew(-ã/2,task);
GrRotZEqu(r1,tS);
GrScaleEqu(r1,MONSTER_SCALE);
r2=GrIdentNew(task);
GrScaleEqu(r2,MONSTER_SCALE);
r3=GrRotXNew(-ã/2,task);
GrScaleEqu(r3,PLANT_SCALE);
x1h=man_xx+yh*PLOT_GRID_WIDTH/2+xh*(PLOT_GRID_HEIGHT-1);
y1h=man_yy-xh*PLOT_GRID_WIDTH/2+yh*(PLOT_GRID_HEIGHT-1);
xh>>=1; yh>>=1;
for (j=0;j<PLOT_GRID_HEIGHT*2;j++) {
x1w=x1h;
y1w=y1h;
for (i=0;i<PLOT_GRID_WIDTH*4;i++) {
xx=x1w/SCREEN_SCALE; yy=y1w/SCREEN_SCALE;
x=xx*SCREEN_SCALE-man_xx; y=yy*SCREEN_SCALE-man_yy;
if (1<=xx<map_width-1 && 1<=yy<map_height-1 &&
!LBts(panels_processed_bitmap,yy*map_width+xx)) {
if ((c=map[yy*map_width+xx]) &&
LOS(xx*SCREEN_SCALE+SCREEN_SCALE/2,yy*SCREEN_SCALE+SCREEN_SCALE/2,
man_xx,man_yy)) {
if (c==YELLOW)
dc->color=RED;
else
dc->color=c;
poly[0].x=x;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=0;
poly[3].x=x;
poly[3].y=y+SCREEN_SCALE;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
if (c==GREEN) {
x1=x+SCREEN_SCALE/2;
y1=y+SCREEN_SCALE/2;
z1=0;
GrTransform(dc,&x1,&y1,&z1);
if (z1>0)
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<5>",BI=5$,r3);
} else if (c==YELLOW) {
x1=x+SCREEN_SCALE/2;
y1=y+SCREEN_SCALE/2;
z1=0;
GrTransform(dc,&x1,&y1,&z1);
if (z1>0)
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<6>",BI=6$,r3);
}
if (!map[(yy+1)*map_width+xx]) {
dc->color=LTGRAY;
poly[0].x=x;
poly[0].y=y+SCREEN_SCALE;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y+SCREEN_SCALE;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[3].x=x;
poly[3].y=y+SCREEN_SCALE;
poly[3].z=SCREEN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[yy*map_width+xx+1]) {
dc->color=DKGRAY;
poly[0].x=x+SCREEN_SCALE;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y+SCREEN_SCALE;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[3].x=x+SCREEN_SCALE;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[(yy-1)*map_width+xx]) {
dc->color=LTGRAY;
poly[0].x=x;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y;
poly[2].z=SCREEN_SCALE;
poly[3].x=x;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[yy*map_width+xx-1]) {
dc->color=DKGRAY;
poly[0].x=x;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x;
poly[1].y=y+SCREEN_SCALE;
poly[1].z=0;
poly[2].x=x;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[3].x=x;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
GrFillPoly3(dc,4,poly);
}
}
}
x1w-=yh;
y1w+=xh;
}
x1h-=xh;
y1h-=yh;
}
//Draw Monsters
for (i=0;i<NUM_MONSTERS;i++) {
x=monsters[i].x;
y=monsters[i].y;
if (LOS(x,y,man_xx,man_yy)) {
x-=man_xx;
y-=man_yy;
xx=x;
yy=y;
zz=0;
GrTransform(dc,&xx,&yy,&zz);
if (zz>0) {
if (monsters[i].dead)
SpriteMat3B(dc,x,y,0,$IB,"<2>",BI=2$,r2);
else {
tt=Tri(tS,1.0);
temps=SpriteInterpolate($IB,"<3>",BI=3$,$IB,"<4>",BI=4$,tt);
SpriteMat3B(dc,x,y,0,temps,r1);
Free(temps);
}
}
}
}
Free(r1);
Free(r2);
Free(r3);
//Draw Map heads-up display, scaled 2 pixs
Free(dc->r);
GrSetRotMat(dc,GrIdentNew(task));
dc->x=task->pix_width -2*map_width;
dc->y=task->pix_height-2*map_height;
dc->z=0;
dc->transform=&GrTransform;
dc->pen_width=2;
for (i=0;i<map_height;i++)
for (j=0;j<map_width;j++) {
dc->color=map[(map_height-1-i)*map_width+j];
GrPlot3(dc,2*j,2*i,0);
}
//Draw Things on heads-up Map
dc->color=LTPURPLE;
for (i=0;i<NUM_MONSTERS;i++)
if (!monsters[i].dead)
GrPlot3(dc,2*(monsters[i].x/SCREEN_SCALE),2*(map_height-1-monsters[i].y/SCREEN_SCALE),0);
dc->color=LTCYAN;
GrPlot3(dc,2*(man_xx/SCREEN_SCALE),2*(map_height-1-man_yy/SCREEN_SCALE),0);
if (tf) {
dc->color=LTRED;
if (Blink)
GrPrint(dc,cx-(FONT_WIDTH*14)/2,cy-FONT_HEIGHT/2,"Game Completed");
tt=tf;
} else {
dc->color=LTGREEN;
GrLine(dc,cx-5,cy,cx+5,cy);
GrLine(dc,cx,cy-5,cx,cy+5);
tt=tS;
}
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",monsters_left,tt-t0,best_score);
Free(s2w);
}
U0 Fire()
{
I64 i,x,y;
F64 d,dx,dy,xx=Cos(man_é),yy=Sin(man_é);
Noise(100,300,1000);
for (i=0;i<NUM_MONSTERS;i++) {
x=monsters[i].x;
y=monsters[i].y;
if (!monsters[i].dead &&
LOS(x,y,man_xx,man_yy)) {
dx=x-man_xx;
dy=man_yy-y;
if (d=Sqrt(dx*dx+dy*dy)) {
dx/=d;
dy/=d;
if (dx*xx+dy*yy>0.995) {
monsters[i].dead=TRUE;
if (!--monsters_left) {
tf=tS;
if (tf-t0<best_score)
best_score=tf-t0;
}
}
}
}
}
}
U0 Init()
{
I64 i,x,y;
I64 min_map_x,max_map_x,min_map_y,max_map_y;
CDC *dc;
DocClear;
"$$BG,BLACK$$"; NewLine(TEXT_ROWS/2);
SpriteExtents($IB,"<1>",BI=1$,&min_map_x,&max_map_x,&min_map_y,&max_map_y);
map_width =(max_map_x-min_map_x+1)/MAP_SCALE+2;
map_height=(max_map_y-min_map_y+1)/MAP_SCALE+2;
Free(map);
Free(panels_processed_bitmap);
map=CAlloc(map_width*map_height*sizeof(U8));
panels_processed_bitmap=MAlloc((map_width*map_height+7)>>3);
dc=DCNew(map_width*MAP_SCALE,map_height*MAP_SCALE);
Sprite3(dc,-min_map_x+MAP_SCALE,-min_map_y+MAP_SCALE,0,$IB,"<1>",BI=1$);
for (y=1;y<map_height-1;y++)
for (x=1;x<map_width-1;x++)
map[(map_height-1-y)*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
DCDel(dc);
man_xx=(1+MAN_START_X)*SCREEN_SCALE;
man_yy=(map_height-1-MAN_START_Y)*SCREEN_SCALE;
man_é=0;
for (i=0;i<NUM_MONSTERS;i++) {
monsters[i].dead=FALSE;
do {
monsters[i].x=RandU64%((map_width-2)*SCREEN_SCALE)+SCREEN_SCALE;
monsters[i].y=RandU64%((map_height-2)*SCREEN_SCALE)+SCREEN_SCALE;
} while (!map[(monsters[i].y/SCREEN_SCALE)*map_width+monsters[i].x/SCREEN_SCALE]);
}
monsters_left=NUM_MONSTERS;
tf=0;
t0=tS;
}
U0 AnimateTask(I64)
{
I64 i,x,y,dd;
while (TRUE) {
dd=0.25*SCREEN_SCALE*Sin(tS/2);
for (i=0;i<NUM_MONSTERS;i++)
if (!monsters[i].dead) {
x=monsters[i].x;
y=monsters[i].y;
if (i&1)
x+=dd;
else
y+=dd;
if (0<=x<=map_width*SCREEN_SCALE &&
0<=y<=map_height*SCREEN_SCALE &&
map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE]) {
if (!map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE+1] &&
x-RoundI64(x,SCREEN_SCALE)>SCREEN_SCALE/2 ||
!map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE-1] &&
x-RoundI64(x,SCREEN_SCALE)<SCREEN_SCALE/2)
x=RoundI64(x,SCREEN_SCALE)+SCREEN_SCALE/2;
if (!map[(y/SCREEN_SCALE+1)*map_width+x/SCREEN_SCALE] &&
y-RoundI64(y,SCREEN_SCALE)>SCREEN_SCALE/2 ||
!map[(y/SCREEN_SCALE-1)*map_width+x/SCREEN_SCALE] &&
y-RoundI64(y,SCREEN_SCALE)<SCREEN_SCALE/2)
y=RoundI64(y,SCREEN_SCALE)+SCREEN_SCALE/2;
monsters[i].x=x;
monsters[i].y=y;
}
}
Sleep(20);
}
}
U0 CleanUp()
{
Free(map);
Free(panels_processed_bitmap);
map=NULL;
panels_processed_bitmap=NULL;
}
U0 SongTask(I64)
{ //Song by Terry A. Davis
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("2q.A#1eG2AeA#qAq.A#1eG2eAeA#qA");
Play("q.A#1eG2A#A1qG2q.A#1eG2A#A1qG");
Play("3eA#A2qG3eA#A2qG3eA#A2G3AA#A2qG");
}
}
U0 MoveMan(F64 é)
{
I64 x,y,color,step=SCREEN_SCALE/2;
do {
x=man_xx+step*Cos(é);
y=man_yy-step*Sin(é);
x=Clamp(x,0,map_width*SCREEN_SCALE);
y=Clamp(y,0,map_height*SCREEN_SCALE);
color=map[y/SCREEN_SCALE*map_width+x/SCREEN_SCALE];
if (color==RED || color==GREEN) {
man_xx=x;
man_yy=y;
break;
} else
step>>=1;
} while (step);
}
#define MICRO_STEPS 4
U0 RotateMan(F64 d)
{
I64 i;
for (i=0;i<MICRO_STEPS;i++) {
man_é+=d/MICRO_STEPS;
Sleep(15);
}
}
U0 CastleFrankenstein()
{
I64 sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Fwd(,,SC_CURSOR_UP);"
" Backward(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" Fire(,CH_SPACE);"
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=RED<<4+WHITE;
Preempt(OFF);
WinBorder;
WinMax;
WordStat;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
DocCursor;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (GetKey(&sc)) {
case CH_SPACE:
Fire;
break;
case '\n':
Init;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto fs_done;
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
Spawn(&RotateMan,(ã/32)(I64));
break;
case SC_CURSOR_LEFT:
Spawn(&RotateMan,(-ã/32)(I64));
break;
case SC_CURSOR_UP:
MoveMan(man_é);
break;
case SC_CURSOR_DOWN:
MoveMan(man_é+ã);
break;
}
break;
}
}
fs_done:
} catch
PutExcept;
DocClear;
SettingsPop;
CleanUp;
MenuPop;
AcctRegWriteBranch("TempleOS/CastleFrankenstein","F64 best_score=%5.4f;\n",best_score);
}
CastleFrankenstein;
+
 
 
<
<<
< 
,,,
$8
88
8$
$$
$4
44
4 (
( (
(0
,0T0
T0TL
TL,L
,L,4
04P4
P4PH
PH0H
0H08
08L8
L8LD
LD4D
4D4<
4<H<
H<H@
H@8@
T@l@
l4lL
lLˆL
ˆLˆ$
ˆ$€$
€$€0
€0l0
p4„4
„(„H
€HpH
pDp8
p8€8
€8€D
€DtH
tDt<
t<|<
x@|@
|DxD
„ „
„t
pp
p\
\\
\l
lh
ll
l`
``
`d
dd
h h
XT
PP
PL
LL
(@@
8H
HH
H8
88
8D
D D
D < Z,u
@ Z
DD<
DDD\
D\DdT0T8THL0LLd d hh88x8|8|4x4tt$t@8HLL,L4L<LZ<HñÿÿÿñÿÿÿØÿÿÿìÿÿÿØÿÿÿûÿÿÿ¿ÿÿÿ¿ÿÿÿØÿÿÿØÿÿÿìÿÿÿƒÿÿÿçÿÿÿƒÿÿÿûÿÿÿƒÿÿÿƒÿÿÿ
tÿÿÿöÿÿÿtÿÿÿ
¿ÿÿÿöÿÿÿ¿ÿÿÿƒÿÿÿ
tÿÿÿ
ƒÿÿÿ
ûÿÿÿƒÿÿÿ
çÿÿÿƒÿÿÿ
¿ÿÿÿ
¿ÿÿÿ
ûÿÿÿ¿ÿÿÿ
öÿÿÿ¿ÿÿÿ
ìÿÿÿØÿÿÿ
ñÿÿÿØÿÿÿ
Øÿÿÿ
Øÿÿÿ
ûÿÿÿ
ûÿÿÿ
ñÿÿÿûÿÿÿ
ìÿÿÿûÿÿÿ
ƒÿÿÿ
ìÿÿÿƒÿÿÿ
çÿÿÿ«ÿÿÿ-ìÿÿÿ«ÿÿÿ-«ÿÿÿ-«ÿÿÿ-°ÿÿÿ-°ÿÿÿ-ìÿÿÿ°ÿÿÿ-çÿÿÿ°ÿÿÿ-øÿÿÿxÿÿÿ ýÿÿÿ|ÿÿÿ xÿÿÿ xÿÿÿ |ÿÿÿ öÿÿÿtÿÿÿ
ÿÿÿÿxÿÿÿ ìÿÿÿûÿÿÿñÿÿÿûÿÿÿñÿÿÿûÿÿÿûÿÿÿìÿÿÿ
 ␍    !!&''"#%$$#    ␍ ␍!


 $%*$*+'&('()&(( $++
0/.112-,7 765343! 3 45833!839;:7;766;;1␍Z<HñÿÿÿöÿÿÿñÿÿÿØÿÿÿìÿÿÿØÿÿÿûÿÿÿ¿ÿÿÿ¿ÿÿÿØÿÿÿØÿÿÿìÿÿÿöÿÿÿƒÿÿÿçÿÿÿƒÿÿÿûÿÿÿƒÿÿÿƒÿÿÿ
tÿÿÿöÿÿÿtÿÿÿ
¿ÿÿÿöÿÿÿ¿ÿÿÿƒÿÿÿ
tÿÿÿ
ƒÿÿÿ
ûÿÿÿƒÿÿÿ
çÿÿÿƒÿÿÿ
¿ÿÿÿ
¿ÿÿÿ
ûÿÿÿ¿ÿÿÿ
öÿÿÿ¿ÿÿÿ
ìÿÿÿØÿÿÿ
ñÿÿÿØÿÿÿ
Øÿÿÿ
Øÿÿÿ
ûÿÿÿûÿÿÿñÿÿÿûÿÿÿìÿÿÿûÿÿÿƒÿÿÿ
ìÿÿÿƒÿÿÿ
çÿÿÿ«ÿÿÿ-ìÿÿÿ«ÿÿÿ-«ÿÿÿÓÿÿÿ«ÿÿÿÓÿÿÿ°ÿÿÿÓÿÿÿ°ÿÿÿÓÿÿÿìÿÿÿ°ÿÿÿ-çÿÿÿ°ÿÿÿ-øÿÿÿxÿÿÿ ýÿÿÿ|ÿÿÿ xÿÿÿ xÿÿÿ |ÿÿÿ öÿÿÿtÿÿÿ
ÿÿÿÿxÿÿÿ ìÿÿÿûÿÿÿñÿÿÿûÿÿÿñÿÿÿûÿÿÿ-ûÿÿÿ-ìÿÿÿ--
 ␍    !!&''"#%$$#    ␍ ␍!


 $%*$*+'&('()&(( $++
0/.112-,7 765343! 3 45833!839;:7;766;;1␍Z<HñÿÿÿñÿÿÿØÿÿÿìÿÿÿØÿÿÿûÿÿÿ¿ÿÿÿ¿ÿÿÿØÿÿÿØÿÿÿìÿÿÿöÿÿÿƒÿÿÿçÿÿÿƒÿÿÿûÿÿÿƒÿÿÿƒÿÿÿ
tÿÿÿöÿÿÿtÿÿÿ
¿ÿÿÿöÿÿÿ¿ÿÿÿƒÿÿÿ
tÿÿÿ
ƒÿÿÿ
ûÿÿÿƒÿÿÿ
çÿÿÿƒÿÿÿ
¿ÿÿÿ
¿ÿÿÿ
ûÿÿÿ¿ÿÿÿ
öÿÿÿ¿ÿÿÿ
ìÿÿÿØÿÿÿ
ñÿÿÿØÿÿÿ
Øÿÿÿ
Øÿÿÿ
ûÿÿÿûÿÿÿñÿÿÿûÿÿÿìÿÿÿûÿÿÿƒÿÿÿ
ìÿÿÿƒÿÿÿ
çÿÿÿ«ÿÿÿÓÿÿÿìÿÿÿ«ÿÿÿÓÿÿÿ«ÿÿÿ-«ÿÿÿ-°ÿÿÿ-°ÿÿÿ-ìÿÿÿ°ÿÿÿÓÿÿÿçÿÿÿ°ÿÿÿÓÿÿÿøÿÿÿxÿÿÿ ýÿÿÿ|ÿÿÿ xÿÿÿ xÿÿÿ |ÿÿÿ öÿÿÿtÿÿÿ
ÿÿÿÿxÿÿÿ ìÿÿÿûÿÿÿ#ñÿÿÿûÿÿÿ#ñÿÿÿ#ûÿÿÿûÿÿÿìÿÿÿ#öÿÿÿ
 ␍    !!&''"#%$$#    ␍ ␍!


 $%*$*+'&('()&(( $++
0/.112-,7 765343! 3 45833!839;:7;766;;1␍,ÎÿÿÿÎÿÿÿûÿÿÿçÿÿÿûÿÿÿçÿÿÿµÿÿÿ�ÿÿÿƒÿÿÿ�ÿÿÿâÿÿÿµÿÿÿâÿÿÿûÿÿÿÎÿÿÿûÿÿÿÎÿÿÿûÿÿÿûÿÿÿçÿÿÿûÿÿÿûÿÿÿçÿÿÿûÿÿÿµÿÿÿûÿÿÿ�ÿÿÿûÿÿÿ�ÿÿÿâÿÿÿûÿÿÿµÿÿÿâÿÿÿ�ÿÿÿµÿÿÿâÿÿÿµÿÿÿâÿÿÿ�ÿÿÿ�ÿÿÿûÿÿÿµÿÿÿûÿÿÿâÿÿÿµÿÿÿûÿÿÿâÿÿÿ�ÿÿÿûÿÿÿ 


  ␍␍ ␍ 
 

 ␍
␍÷ÿÿÿ÷ÿÿÿñÿÿÿ÷ÿÿÿ ôÿÿÿ ÷ÿÿÿ øÿÿÿçÿÿÿìÿÿÿçÿÿÿìÿÿÿçÿÿÿøÿÿÿøÿÿÿçÿÿÿðÿÿÿçÿÿÿðÿÿÿçÿÿÿøÿÿÿçÿÿÿçÿÿÿ   ␍ ␍ 
   


   ␍ ␍␍(Øÿÿÿ(ØÿÿÿØÿÿÿØÿÿÿìÿÿÿÎÿÿÿÎÿÿÿìÿÿÿ‚‚ìÿÿÿ‚ìÿÿÿìÿÿÿ‚öÿÿÿâÿÿÿ‚
âÿÿÿ‚ìÿÿÿ  


  

     ␍␍ ␍  
Binary file not shown.
+128
View File
@@ -0,0 +1,128 @@
//Practice tracing circles
//Giotto, a famous artist, drew a freehand circle as a portfolio for a job.
AcctRegSetDftEntry("TempleOS/CircleTrace","F64 best_score=999;\n");
AcctRegExeBranch("TempleOS/CircleTrace");
I64 cx,cy;
F64 avg_error=0,elapsed_time=0,total_error=0,score=999;
U0 SongTask(I64)
{
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE)
Play("hEDCARCDECR");
}
U0 DrawIt(CTask *task,CDC *)
{
U8 buf[128];
SPrint(buf,"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f",avg_error,elapsed_time,score,best_score);
PlotWinStr(task,buf,BLACK<<4+WHITE,0,0);
}
#define CIRCLE_RADIUS 100
#define CIRCUMFERENCE (2*ã*CIRCLE_RADIUS)
Bool CTPlot(CDC *dc,I64 x,I64 y,I64)
{
F64 rad=Sqrt(Sqr(x-cx)+Sqr(y-cy));
GrPlot(dc,x,y);
total_error+=Abs(rad-CIRCLE_RADIUS);
return TRUE;
}
U0 CircleTrace()
{
I64 msg_code,p1,p2,x1,y1;
F64 rad,t0,total_distance;
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
WordStat;
cx=Fs->pix_width/2;
cy=Fs->pix_height/2;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
DCFill;
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
do {
msg_code=GetMsg(&p1,&p2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
switch (msg_code) {
case MSG_KEY_UP:
break;
case MSG_IP_L_DOWN:
DCFill;
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
dc->color=ROP_XOR+RED^COLOR_TRANSPARENT;
t0=tS;
total_distance=0.001;
total_error=0;
x1=p1; y1=p2;
do {
msg_code=ScanMsg(&p1,&p2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
switch (msg_code) {
case MSG_IP_L_UP:
break;
case MSG_IP_MOVE:
if (x1!=p1 || y1!=p2) {
total_distance+=Sqrt(Sqr(x1-p1)+Sqr(y1-p2));
Line(dc,x1,y1,0,p1,p2,0,&CTPlot);
x1=p1;y1=p2;
//undo overlapping pixs on segments
GrPlot(dc,x1,y1);
rad=Sqrt(Sqr(x1-cx)+Sqr(y1-cy));
total_error-=Abs(rad-CIRCLE_RADIUS);
}
break;
}
elapsed_time=tS-t0;
avg_error=total_error/total_distance;
score=elapsed_time*avg_error;
//This $LK,"Sleep",A="MN:Sleep"$()s until the next time the
//window mgr task runs. The
//window mgr calls the UpdateWin() routine
//and places msgs in the que, so there's
//no need to do anything until the window mgr runs.
WinMgrSync;
} while (msg_code!=MSG_IP_L_UP);
music_mute=TRUE; Sleep(200);
if (total_distance>0.95*CIRCUMFERENCE) {
if (score<best_score) {
Snd(2000);Sleep(50);Snd(0);Sleep(50);
Snd(2000);Sleep(50);Snd(0);Sleep(50);
Snd(2000);Sleep(50);
best_score=score;
} else {
Snd(500);Sleep(50);
}
} else {
Snd(100);Sleep(1000);
}
Snd(0); Sleep(200); music_mute=FALSE;
break;
}
} while (msg_code!=MSG_KEY_DOWN || p1!=CH_SHIFT_ESC && p1!=CH_ESC);
GetMsg(,,1<<MSG_KEY_UP);
SettingsPop;
DCFill;
DCDel(dc);
AcctRegWriteBranch("TempleOS/CircleTrace","F64 best_score=%5.4f;\n",best_score);
}
CircleTrace; //Execute when #included
Binary file not shown.
Binary file not shown.
+80
View File
@@ -0,0 +1,80 @@
//This loads a lst of zero terminated
//strings into the sym table and
//gives a name to it. Strings like
//this are known as Define entries.
//See $LK,"ST_RAINBOW_10",A="FF:::/Adam/Gr/GrPalette.CPP,ST_RAINBOW_10"$
U0 PrintDigit(U8 ch)
{
//The %Z code displays a Define subentry
if ('0'<=ch<='9')
"$$FG,%Z$$%d$$FG$$",ch-'0',"ST_RAINBOW_10",ch-'0';
}
U0 PrintPattern(U8 *st)
{
I64 ch;
while (ch=*st++)
PrintDigit(ch);
NewLine;
}
U0 Digits()
{
I64 num,ch,i;
U8 answer[1024];
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=DKGRAY<<4+WHITE;
DocClear;
//Set default background and foreground
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$"
"\nThis is a mem game. "
"Try to remember the digits and enter them. "
"They are colored based on electrical "
"engineering color codes.\n";
for (i=0;i<10;i++)
"$$FG,%Z$$%d: %Z\n",i,"ST_RAINBOW_10",i,i,"ST_RAINBOW_10";
"$$FG$$\n"; //set to default background
ch=PressAKey;
if (ch==CH_ESC||ch==CH_SHIFT_ESC) goto dg_done;
while (TRUE) {
restart:
num=0;
//Set to zeros so we have terminators
MemSet(answer,0,sizeof(answer));
while (TRUE) {
DocClear;
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$\n";
"Pattern\nLength:%d\n\n",num+1;
answer[num++]=RandU32%10+'0';
PrintPattern(answer);
ch=PressAKey;
if (ch==CH_ESC||ch==CH_SHIFT_ESC) goto dg_done;
DocClear;
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$\n";
"Guess\nLength:%d\n\n",num;
for (i=0;i<num;i++) {
ch=GetChar(,FALSE);
if (ch==CH_ESC||ch==CH_SHIFT_ESC) goto dg_done;
PrintDigit(ch);
if (ch!=answer[i]) {
"\nScore:%d\n",num;
PrintPattern(answer);
Beep; Beep;
ch=PressAKey;
if (ch==CH_ESC||ch==CH_SHIFT_ESC)
goto dg_done;
else
goto restart;
}
}
}
}
dg_done:
DocClear;
SettingsPop;
}
Digits;
+558
View File
@@ -0,0 +1,558 @@
//Set snap to 4 and width to 4
//if you edit this map.
//Don't forget to change the
//starting pos.
$BG,0$
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$ //This is a template you can copy and use to make a tile.
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
$SP,"<7>",BI=7$
$SP,"<8>",BI=8$
$SP,"<9>",BI=9$
$SP,"<10>",BI=10$
$SP,"<11>",BI=11$
$BG$
//These are indexed by color #.
//See $LK,"COLORS",A="MN:RED"$.
U8 *tiles1[16]=
{NULL,$IB,"<7>",BI=7$ ,$IB,"<5>",BI=5$ ,NULL,
$IB,"<6>",BI=6$ ,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL};
U8 *tiles2[16]=
{NULL,$IB,"<8>",BI=8$ ,$IB,"<5>",BI=5$ ,NULL,
$IB,"<6>",BI=6$ ,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL};
#define SCREEN_SCALE 24
#define SCREEN_WIDTH 24
#define SCREEN_HEIGHT 24
I64 screen_x,screen_y;
#define MAP_SCALE 4
I64 map_width,map_height;
U8 *map=NULL;
I64 man_x,man_y,man_dx,man_dy;
Bool man_attack;
F64 man_attack_t0;
#define NUM_MONSTERS 16
class Monster
{
I64 x,y,dx,dy;
Bool dead,pad[7];
} monsters[NUM_MONSTERS];
#define LOS_SCALE 4
Bool LOSPlot(U8 *,I64 x,I64 y,I64)
{
if (!map[(y/LOS_SCALE)*map_width+(x/LOS_SCALE)])
return FALSE;
else
return TRUE;
}
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
{ //Line of sight
return Line(NULL,x1*LOS_SCALE+LOS_SCALE/2,y1*LOS_SCALE+LOS_SCALE/2,0,
x2*LOS_SCALE+LOS_SCALE/2,y2*LOS_SCALE+LOS_SCALE/2,0,&LOSPlot);
}
U0 DrawIt(CTask *task,CDC *dc)
{
CDC *dc_t=DCAlias(gr_dc2,task);
I64 i,x,y,xx,yy,x1,y1,z1,color;
CD3I32 poly[4];
U8 **_tiles;
if (Blink(5))
_tiles=tiles1;
else
_tiles=tiles2;
GrRotXEqu(dc_t->r,60*2*ã/360);
GrRotZEqu(dc_t->r,15*2*ã/360);
GrSetRotMat(dc_t,dc_t->r);
dc_t->x=task->pix_width/2;
dc_t->y=task->pix_height/2;
dc_t->flags|=DCF_TRANSFORMATION;
//You could make it much more efficient
//if you did it like $LK,"::/Demo/Games/BigGuns.CPP"$
//with a $LK,"CDC",A="MN:CDC"$.
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
yy=y+screen_y;
if (0<=yy<map_height)
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
xx=x+screen_x;
if (0<=xx<map_width) {
if ((color=map[yy*map_width+xx]) &&
LOS(xx,yy,man_x,man_y)) {
if (_tiles[color]) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
z1=0;
GrTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,_tiles[color]);
} else { //If no tile defined, do solid color.
poly[0].x=x*SCREEN_SCALE;
poly[0].y=y*SCREEN_SCALE;
poly[0].z=0;
poly[1].x=(x+1)*SCREEN_SCALE-1;
poly[1].y=y*SCREEN_SCALE;
poly[1].z=0;
poly[2].x=(x+1)*SCREEN_SCALE;
poly[2].y=(y+1)*SCREEN_SCALE-1;
poly[2].z=0;
poly[3].x=x*SCREEN_SCALE-1;
poly[3].y=(y+1)*SCREEN_SCALE-1;
poly[3].z=0;
dc_t->color=color;
GrFillPoly3(dc_t,4,poly);
}
}
}
}
}
dc_t->color=LTGRAY;
for (x=-SCREEN_WIDTH/2;x<=SCREEN_WIDTH/2;x++)
GrLine3(dc_t,x*SCREEN_SCALE,-SCREEN_HEIGHT/2*SCREEN_SCALE,0,x*SCREEN_SCALE,SCREEN_HEIGHT/2*SCREEN_SCALE-1,0);
for (y=-SCREEN_HEIGHT/2;y<=SCREEN_HEIGHT/2;y++)
GrLine3(dc_t,-SCREEN_WIDTH/2*SCREEN_SCALE,y*SCREEN_SCALE,0,SCREEN_WIDTH/2*SCREEN_SCALE,y*SCREEN_SCALE-1,0);
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
yy=y+screen_y;
if (0<=yy<map_height)
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
xx=x+screen_x;
if (0<=xx<map_width) {
if (!map[yy*map_width+xx]) {
if (yy+1<map_height && LOS(xx,yy+1,man_x,man_y)) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
z1=0;
GrTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,$IB,"<10>",BI=10$);
}
if (xx+1<map_width && LOS(xx+1,yy,man_x,man_y)) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
z1=0;
GrTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,$IB,"<11>",BI=11$);
}
}
}
}
}
for (i=0;i<NUM_MONSTERS;i++)
if (!monsters[i].dead && LOS(monsters[i].x,monsters[i].y,man_x,man_y)) {
x1=(monsters[i].x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
y1=(monsters[i].y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
z1=0;
GrTransform(dc_t,&x1,&y1,&z1);
if (monsters[i].dx<0) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
GrSetSymmetry(dc,x1,y1,x1,y1+1);
} else
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
Sprite3(dc,x1,y1,z1,$IB,"<9>",BI=9$);
}
x1=(man_x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
y1=(man_y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
z1=0;
if (tS-man_attack_t0<0.2) {
x1+=Tri(tS-man_attack_t0,0.2)*SCREEN_SCALE*man_dx;
y1+=Tri(tS-man_attack_t0,0.2)*SCREEN_SCALE*man_dy;
}
GrTransform(dc_t,&x1,&y1,&z1);
if (man_dx<0) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
GrSetSymmetry(dc,x1,y1,x1,y1+1);
} else
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
if (tS-man_attack_t0<0.2)
Sprite3(dc,x1,y1,z1,$IB,"<3>",BI=3$);
else
Sprite3(dc,x1,y1,z1,$IB,"<2>",BI=2$);
DCDel(dc_t);
}
U0 Attack()
{
I64 i;
man_attack_t0=tS;
Noise(100,300,1000);
for (i=0;i<NUM_MONSTERS;i++) {
if (!monsters[i].dead &&
man_x+man_dx==monsters[i].x && man_y+man_dy==monsters[i].y)
monsters[i].dead=TRUE;
}
}
U0 Init()
{
I64 i,x,y,minx,maxx,miny,maxy;
CDC *dc;
SpriteExtents($IB,"<1>",BI=1$,&minx,&maxx,&miny,&maxy);
map_width =(maxx-minx+1)/MAP_SCALE;
map_height=(maxy-miny+1)/MAP_SCALE;
Free(map);
map=MAlloc(map_width*map_height*sizeof(U8));
dc=DCNew(map_width*MAP_SCALE,map_height*MAP_SCALE);
Sprite3(dc,-minx,-miny,0,$IB,"<1>",BI=1$);
for (y=0;y<map_height;y++)
for (x=0;x<map_width;x++)
map[y*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
DCDel(dc);
for (i=0;i<NUM_MONSTERS;i++) {
monsters[i].dead=FALSE;
monsters[i].dx=0;
monsters[i].dy=0;
do {
monsters[i].x=RandU64%(map_width-2)+1;
monsters[i].y=RandU64%(map_height-2)+1;
} while (!map[(monsters[i].y)*map_width+monsters[i].x]);
}
man_attack_t0=tS;
man_attack=FALSE;
man_x=0;
man_y=4;
man_dx=0;
man_dy=0;
screen_x=0;
screen_y=0;
}
U0 CleanUp()
{
Free(map);
map=NULL;
}
U0 AnimateTask(I64)
{
I64 i,x,y,dx,dy;
while (TRUE) {
for (i=0;i<NUM_MONSTERS;i++)
if (!monsters[i].dead) {
dx=RandU16%3-1;
dy=RandU16%3-1;
x=monsters[i].x+dx;
y=monsters[i].y+dy;
if (0<=x<=map_width && 0<=y<=map_height &&
map[y*map_width+x]) {
monsters[i].x=x;
monsters[i].y=y;
monsters[i].dx=dx;
monsters[i].dy=dy;
}
}
Sleep(1000);
}
}
U0 DunGen()
{
I64 ch,sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Up(,,SC_CURSOR_UP);"
" Down(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" Attack(,CH_SPACE);"
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
Preempt(OFF);
WinMax;
WordStat;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (GetMsg(&ch,&sc,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
case MSG_KEY_DOWN:
switch (ch) {
case '\n':
Init;
break;
case CH_SPACE:
man_attack=TRUE;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto dg_done;
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
if (man_attack) {
man_dx=1;
man_dy=0;
Attack;
} else
if (man_x+1<map_width && map[man_y*map_width+(man_x+1)]==RED) {
man_x++;
if (man_x-screen_x>SCREEN_WIDTH/2-3) {
screen_x+=SCREEN_WIDTH/2;
if (screen_x+SCREEN_WIDTH/2>map_width)
screen_x=map_width-SCREEN_WIDTH/2;
}
}
break;
case SC_CURSOR_LEFT:
if (man_attack) {
man_dx=-1;
man_dy=0;
Attack;
} else
if (man_x-1>=0 && map[man_y*map_width+(man_x-1)]==RED) {
man_x--;
if (man_x-screen_x<-SCREEN_WIDTH/2+3) {
screen_x-=SCREEN_WIDTH/2;
if (screen_x-SCREEN_WIDTH/2<0)
screen_x=SCREEN_WIDTH/2;
}
}
break;
case SC_CURSOR_UP:
if (man_attack) {
man_dx=0;
man_dy=-1;
Attack;
} else
if (man_y-1>=0 && map[(man_y-1)*map_width+man_x]==RED) {
man_y--;
if (man_y-screen_y<-SCREEN_HEIGHT/2+3) {
screen_y-=SCREEN_HEIGHT/2;
if (screen_y-SCREEN_HEIGHT/2<0)
screen_y=SCREEN_HEIGHT/2;
}
}
break;
case SC_CURSOR_DOWN:
if (man_attack) {
man_dx=0;
man_dy=1;
Attack;
} else
if (man_y+1<map_height && map[(man_y+1)*map_width+man_x]==RED) {
man_y++;
if (man_y-screen_y>SCREEN_HEIGHT/2-3) {
screen_y+=SCREEN_HEIGHT/2;
if (screen_y+SCREEN_HEIGHT/2>map_height)
screen_y=map_height-SCREEN_HEIGHT/2;
}
}
break;
}
}
break;
case MSG_KEY_UP:
if (ch==CH_SPACE)
man_attack=FALSE;
break;
}
}
dg_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
SettingsPop;
MenuPop;
CleanUp;
}
DunGen;
£
|˜
˜øÿÿÿ˜
˜´
´´øÿÿÿ
´øÿÿÿ˜øÿÿÿ
¤¤
œ °
° °üÿÿÿ
°üÿÿÿœüÿÿÿ
œüÿÿÿœ
œ¬
¬¬
¬ 
  
 ¨
¤$Ì$
Ì$Ì@
Ì@¤@
¤@¤(
¨(È(
È(È<
È<¨<
¨<¨,
¨,Ä,
Ä,Ä8
Ä8¬8
¬8¬0
¬0À0
À0À4
À4°4
Ì4ä4
ä(ä@
ä@@
@
ø
øø$
ø$ä$
è(ü(
üü<
ø<è<
è8è,
è,ø,
ø,ø8
ø8ì<
ì8ì0
ì0ô0
ð4ô4
ô8ð8
üü
üì
èøÿÿÿè
èÔ
ÔÔøÿÿÿ
Ôøÿÿÿäøÿÿÿ
äøÿÿÿà
ä äüÿÿÿ
äüÿÿÿØüÿÿÿ
ØüÿÿÿØ
Ø Ü
Ü Ü
àà
ÐÌ
ÈüÿÿÿÈ
È Ä
Ä Äüÿÿÿ
 4�4
Œ,Œ<
Œ<€<
€<€,
€,ˆ,
ˆ,ˆ8
ˆ8„8
„8„0
˜4˜L
”LœL
œLœX
œX”X
”X”P
˜P˜T
¼ôÿÿÿ¼0
¼8¼P
¼P¼X°Ä,Ä8Rýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²%þÿÿÿëÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿJ$ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2ýÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿÿÿÿÿÿ    ÿÿÿÿÿÿÿ   ÿÿÿ    ÿÿ      ÿÿÿ    ÿÿ   ÿÿ  ÿÿÿÿÿÿ      ÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2ýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿ     ÿÿÿ    ÿÿ    ÿÿÿ    ÿÿ    ÿÿ  ÿÿÿÿÿÿ       ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ' ìÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
òþÿÿÿüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ b ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²'$ìÿÿÿäÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²öÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
File diff suppressed because it is too large. Load diff
+774
View File
@@ -0,0 +1,774 @@
#define GAME_SPEED_SCALE 0.1
F64 game_speed,
launch_unit_x1,launch_unit_y1,launch_unit_x2,launch_unit_y2,launch_t,
return_unit_x1,return_unit_y1,return_unit_x2,return_unit_y2,return_t,
set_é_unit_x1,set_é_unit_y1,set_é_unit_x2,set_é_unit_y2,set_é_t;
CTask *main_task;
#define OT_CARRIER 0
#define OT_CRUISER 1
#define OT_FIGHTER 2
#define OT_NUM_TYPES 3
#define OF_SHIP 1
#define OF_ACTIVE 2
#define OF_RETURNING 4
#define OF_SHOOTING 8
class Obj
{
Obj *next,*last;
Obj *next_in_squadron,*last_in_squadron;
Obj *host;
U8 player,type;
U16 flags;
I16 squadron,member_num;
F64 x,y,é,dé,
speed,turn_rate,
life_percent,
target_x,target_y,
ship_guns,ship_guns_range,
air_guns,air_guns_range,
fuel,max_fuel,fuel_burn_rate,
death_time,next_action_time;
I32 torpedos,max_torpedos;
F64 torpedos_range;
} obj_root;
class Torpedo
{
Torpedo *next,*last;
Obj *target;
F64 x,y,é,speed,timeout;
} torpedo_root;
#define SA_PARKED 0
#define SA_LAUNCHING 1
#define SA_FLYING 2
#define SA_SET_é 3
#define SA_RETURNING 4
#define SA_DEAD 5
class Squadron : Obj
{
I64 action,dead_mask,total_mask;
} *squadrons;
U0 SquadronIns(Obj *o,Obj *pred)
{
Obj *succ=pred->next_in_squadron;
o->next_in_squadron=succ;
o->last_in_squadron=pred;
pred->next_in_squadron=o;
succ->last_in_squadron=o;
}
U0 SquadronRem(Obj *o)
{
Obj *pred=o->last_in_squadron,*succ=o->next_in_squadron;
pred->next_in_squadron=succ;
succ->last_in_squadron=pred;
}
#define NUM_PLAYERS 2
I64 num_carriers[NUM_PLAYERS]={2,3},
num_cruisers[NUM_PLAYERS]={2,3},
num_planes_per_squadron[NUM_PLAYERS]={6,5},
num_squadrons_per_carrier[NUM_PLAYERS]={2,3},
num_alive[NUM_PLAYERS],
num_squadrons;
Obj *ObjFind(F64 x,F64 y,
I64 flag_mask=OF_ACTIVE|OF_RETURNING,I64 flag_val=OF_ACTIVE,
I64 type_mask=-1,I64 player_mask=-1,F64 *_d=NULL)
{
Obj *tempo=obj_root.next,*best=NULL;
F64 dd,best_dd=MAX_F64;
while (tempo!=&obj_root) {
if (tempo->flags&flag_mask==flag_val &&
Bt(&type_mask,tempo->type)&&Bt(&player_mask,tempo->player)) {
dd=Sqr(tempo->x-x)+Sqr(tempo->y-y);
if (dd<best_dd) {
best=tempo;
best_dd=dd;
}
}
tempo=tempo->next;
}
if (_d) *_d=Sqrt(best_dd);
return best;
}
U0 ObjDel(Obj *tempo)
{
if (tempo) {
if (tS<tempo->death_time)
tempo->flags&=~OF_ACTIVE;
else {
if (tempo->squadron>=0)
SquadronRem(tempo);
QueRem(tempo);
if (tempo->squadron>=0)
LBts(&squadrons[tempo->squadron].dead_mask,tempo->member_num);
num_alive[tempo->player]--;
Free(tempo);
}
}
}
$BG,1$
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
$BG$
CSprite *imgs[NUM_PLAYERS][OT_NUM_TYPES]={{$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"<3>",BI=3$},{$IB,"<4>",BI=4$,$IB,"<5>",BI=5$,$IB,"<6>",BI=6$}};
U0 DrawIt(CTask *task,CDC *dc)
{
F64 d,cur_time=tS;
Obj *tempo;
Torpedo *tempt;
Bool old_preempt=Preempt(OFF);
tempt=torpedo_root.next;
while (tempt!=&torpedo_root) {
dc->color=WHITE;
GrPlot(dc,tempt->x,tempt->y);
tempt=tempt->next;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->flags&OF_ACTIVE && tempo->flags&OF_SHIP) {
SpriteZ3B(dc,tempo->x,tempo->y,0,imgs[tempo->player][tempo->type],tempo->é+ã/2);
if (Blink) {
dc->color=BLACK;
GrLine(dc,tempo->x+5,tempo->y,tempo->x+5+10,tempo->y);
if (tempo->life_percent>0) {
if (tempo->life_percent<33)
dc->color=RED;
else if (tempo->life_percent<66)
dc->color=YELLOW;
else
dc->color=GREEN;
GrLine(dc,tempo->x+5,tempo->y,tempo->x+5+10*tempo->life_percent/100,tempo->y);
}
dc->color=BLACK;
GrLine(dc,tempo->x+5,tempo->y+2,tempo->x+5+10,tempo->y+2);
d=tempo->fuel*100/tempo->max_fuel;
if (d>0) {
if (d<33)
dc->color=RED;
else if (d<66)
dc->color=YELLOW;
else
dc->color=GREEN;
GrLine(dc,tempo->x+5,tempo->y+2,tempo->x+5+10*d/100,tempo->y+2);
}
}
}
tempo=tempo->next;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_SHIP))
SpriteZ3B(dc,tempo->x,tempo->y,0,imgs[tempo->player][tempo->type],tempo->é+ã/2);
if (tempo->flags&OF_SHOOTING) {
dc->color=LTRED;
GrLine(dc,tempo->x,tempo->y,tempo->target_x,tempo->target_y,3);
}
tempo=tempo->next;
}
dc->flags|=DCF_TRANSFORMATION;
if (cur_time<launch_t) {
dc->color=LTGREEN;
GrArrow3(dc,launch_unit_x1,launch_unit_y1,0,launch_unit_x2,launch_unit_y2,0);
}
if (cur_time<return_t) {
dc->color=LTRED;
GrArrow3(dc,return_unit_x1,return_unit_y1,0,return_unit_x2,return_unit_y2,0);
}
if (cur_time<set_é_t) {
dc->color=YELLOW;
GrArrow3(dc,set_é_unit_x1,set_é_unit_y1,0,set_é_unit_x2,set_é_unit_y2,0);
}
dc->color=YELLOW;
GrPrint(dc,-task->scroll_x,-task->scroll_y,"Game Speed: %5.2f",game_speed);
dc->color=LTCYAN;
GrPrint(dc,-task->scroll_x,-task->scroll_y+ FONT_HEIGHT,"Player 1: %d",num_alive[0]);
dc->color=LTPURPLE;
GrPrint(dc,-task->scroll_x,-task->scroll_y+2*FONT_HEIGHT,"Player 2: %d",num_alive[1]);
if ((!num_alive[0]||!num_alive[1]) && Blink) {
if (!num_alive[1]) {
dc->color=LTGREEN;
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*14)/2-task->scroll_x,
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Completed");
} else {
dc->color=LTRED;
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*9)/2-task->scroll_x,
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
}
}
Preempt(old_preempt);
}
U0 Init()
{
I64 i,fighter,ship,player,squadron,
w=Fs->pix_width,h=Fs->pix_height;
Squadron *temps;
Obj *tempo,*tempo1;
QueInit(&obj_root);
QueInit(&torpedo_root);
Fs->scroll_x=0;
Fs->scroll_y=0;
game_speed=1.0;
launch_t=return_t=set_é_t=0;
main_task=Fs;
num_squadrons=0;
for (player=0;player<NUM_PLAYERS;player++) {
num_alive[player]=0;
for (ship=0;ship<num_cruisers[player];ship++) {
tempo1=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo1->type=OT_CRUISER; tempo1->player=player;
tempo1->squadron=-1; tempo1->member_num=ship;
tempo1->flags=OF_ACTIVE|OF_SHIP;
tempo1->x=0.8*w*(Rand-0.5)+w>>1; tempo1->y=0.8*h*(Rand-0.5)+h>>1;
tempo1->host=NULL;
tempo1->speed=35.0; tempo1->turn_rate=2.5;
tempo1->é=2*ã*(Rand-0.5); tempo1->dé=0;
tempo1->life_percent=100.0;
tempo1->fuel=tempo1->max_fuel=100000;
tempo1->fuel_burn_rate=100.0;
tempo1->air_guns =5000; tempo1->air_guns_range =30.0;
tempo1->ship_guns=10000; tempo1->ship_guns_range=30.0;
tempo1->torpedos =tempo1->max_torpedos=0;
tempo1->torpedos_range =0.0;
tempo1->next_action_time=0;
QueIns(tempo1,obj_root.last);
}
for (ship=0;ship<num_carriers[player];ship++) {
tempo1=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo1->type=OT_CARRIER; tempo1->player=player;
tempo1->squadron=-1; tempo1->member_num=ship;
tempo1->flags=OF_ACTIVE|OF_SHIP;
tempo1->x=0.8*w*(Rand-0.5)+w>>1; tempo1->y=0.8*h*(Rand-0.5)+h>>1;
tempo1->host=NULL;
tempo1->speed=28.0; tempo1->turn_rate=1.0;
tempo1->é=2*ã*(Rand-0.5); tempo1->dé=0;
tempo1->life_percent=100.0;
tempo1->fuel=tempo1->max_fuel=750000;
tempo1->fuel_burn_rate=500.0;
tempo1->air_guns =5000; tempo1->air_guns_range =20.0;
tempo1->ship_guns=2000; tempo1->ship_guns_range=30.0;
tempo1->torpedos =tempo1->max_torpedos=0;
tempo1->torpedos_range =0.0;
tempo1->next_action_time=0;
QueIns(tempo1,obj_root.last);
for (squadron=0;squadron<num_squadrons_per_carrier[player];squadron++,num_squadrons++) {
for (fighter=0;fighter<num_planes_per_squadron[player];fighter++) {
tempo=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo->type=OT_FIGHTER; tempo->player=player;
tempo->squadron=num_squadrons; tempo->member_num=fighter;
tempo->flags=0;
tempo->host=tempo1;
tempo->speed=300.0; tempo->turn_rate=25.0;
tempo->life_percent=100.0;
tempo->fuel=tempo->max_fuel=1000;
tempo->fuel_burn_rate=1.0;
tempo->air_guns =35000; tempo->air_guns_range =8.0;
tempo->ship_guns=0; tempo->ship_guns_range=0.0;
tempo->torpedos =tempo->max_torpedos=1;
tempo->torpedos_range =20.0;
QueIns(tempo,obj_root.last);
}
}
}
}
squadrons=CAlloc(num_squadrons*sizeof(Squadron));
for (i=0,temps=squadrons;i<num_squadrons;i++,temps++) {
temps->next_in_squadron=temps->last_in_squadron=temps;
temps->squadron=i;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
temps->host =tempo->host;
temps->player=tempo->player;
temps->total_mask=1<<num_planes_per_squadron[tempo->player]-1;
SquadronIns(tempo,temps->last_in_squadron);
}
tempo=tempo->next;
}
}
U0 CleanUp()
{
QueDel(&obj_root,TRUE);
QueDel(&torpedo_root,TRUE);
Free(squadrons);
}
Obj *ObjLaunch(I64 player,I64 squadron=-1,Obj *host=NULL,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Obj *tempo;
F64 cur_time=tS;
if (!host)
host=ObjFind(x,y,,,1<<OT_CARRIER,1<<player);
if (host && cur_time>host->next_action_time) {
if (é==MAX_F64)
é=Arg(x-host->x,y-host->y);
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->host==host && (squadron<0||tempo->squadron==squadron) && !(tempo->flags&OF_ACTIVE) &&
(tempo->squadron<0||squadrons[tempo->squadron].action==SA_PARKED||squadrons[tempo->squadron].action==SA_LAUNCHING)) {
if (tempo->fuel<=0.0) //When low on fuel, not zero, gets launched and captured.
LBts(&squadrons[tempo->squadron].dead_mask,tempo->member_num);
else {
tempo->flags=tempo->flags&~OF_RETURNING|OF_ACTIVE;
tempo->é=host->é;
if (x==MAX_F64 || y==MAX_F64 || Sqr(x-host->x)+Sqr(y-host->y)>3*3)
tempo->dé=Wrap(é-tempo->é,-ã);
else
tempo->dé=0;
tempo->x=host->x;
tempo->y=host->y;
host->next_action_time=cur_time+0.25/game_speed;
return tempo;
}
}
tempo=tempo->next;
}
}
return NULL;
}
Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjLaunch(player,,,x,y)) {
if (player==0) {
launch_unit_x1=tempo->x;
launch_unit_y1=tempo->y;
launch_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
launch_unit_y2=ipy-main_task->pix_top -main_task->scroll_y;
launch_t=tS+0.5;
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_PARKED) {
temps->action=SA_LAUNCHING;
temps->é=tempo->é+tempo->dé;
}
return temps;
}
}
return NULL;
}
Obj *ObjReturn(I64 player,F64 x,F64 y)
{
Obj *tempo;
if (tempo=ObjFind(x,y,OF_ACTIVE,OF_ACTIVE,1<<OT_FIGHTER,1<<player))
tempo->flags|=OF_RETURNING;
return tempo;
}
Squadron *SquadronReturn(I64 player,F64 x,F64 y)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjReturn(player,x,y)) {
if (player==0) {
return_unit_x1=tempo->x;
return_unit_y1=tempo->y;
if (tempo->host) {
return_unit_x2=tempo->host->x;
return_unit_y2=tempo->host->y;
return_t=tS+0.5;
}
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_FLYING)
temps->action=SA_RETURNING;
return temps;
}
}
return NULL;
}
Obj *ObjSeté(I64 player,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Obj *tempo;
if ((tempo=ObjFind(x,y,,,,1<<player)) && tempo->flags&OF_ACTIVE && !(tempo->flags&OF_RETURNING)) {
if (é==MAX_F64)
é=Arg(x-tempo->x,y-tempo->y);
tempo->dé+=Wrap(é-(tempo->é+tempo->dé),-ã);
return tempo;
}
return NULL;
}
Squadron *SquadronSeté(I64 player,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjSeté(player,x,y,é)) {
if (player==0) {
set_é_unit_x1=tempo->x;
set_é_unit_y1=tempo->y;
set_é_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
set_é_unit_y2=ipy-main_task->pix_top -main_task->scroll_y;
set_é_t=tS+0.5;
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_FLYING) {
temps->action=SA_SET_é;
temps->é=tempo->é+tempo->dé;
}
return temps;
}
}
return NULL;
}
U0 SquadronActions()
{
I64 i,completed_mask;
Obj *tempo;
Squadron *temps;
for (i=0,temps=squadrons;i<num_squadrons;i++,temps++) {
completed_mask=0;
switch (temps->action) {
case SA_LAUNCHING:
ObjLaunch(temps->player,i,temps->host,,,temps->é);
tempo=temps->next_in_squadron;
while (tempo!=temps) {
LBEqu(&completed_mask,tempo->member_num,tempo->flags&OF_ACTIVE);
tempo=tempo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_FLYING;
break;
case SA_FLYING:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
LBEqu(&completed_mask,tempo->member_num,!(tempo->flags&OF_ACTIVE));
tempo=tempo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_PARKED;
break;
case SA_SET_é:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
tempo->dé+=Wrap(temps->é-(tempo->é+tempo->dé),-ã);
tempo=tempo->next_in_squadron;
}
temps->action=SA_FLYING;
break;
case SA_RETURNING:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
tempo->flags|=OF_RETURNING;
LBEqu(&completed_mask,tempo->member_num,!(tempo->flags&OF_ACTIVE));
tempo=tempo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_PARKED;
break;
}
if (temps->dead_mask==temps->total_mask)
temps->action=SA_DEAD;
}
}
U0 AI(I64 player,F64 period)
{
Obj *tempo;
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->player==player) {
if (tempo->type==OT_CARRIER && Rand<5*period)
SquadronLaunch(player,tempo->x,tempo->y);
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_RETURNING) && Rand<10.0*period)
SquadronSeté(player,tempo->x,tempo->y,tempo->é+pi/2*(Rand-0.5));
}
tempo=tempo->next;
}
}
U0 Combat(F64 period)
{
F64 d;
Obj *tempo,*tempo1;
Torpedo *tempt;
tempo=obj_root.next;
while (tempo!=&obj_root) {
tempo->flags&=~OF_SHOOTING;
if (tempo->flags&OF_ACTIVE &&
(tempo1=ObjFind(tempo->x,tempo->y,OF_ACTIVE,OF_ACTIVE,,1<<(tempo->player^1),&d))) {
tempo->target_x=tempo1->x;
tempo->target_y=tempo1->y;
if (tempo1->flags&OF_SHIP) {
if (tempo->torpedos && d<tempo->torpedos_range && Rand<125*period) {
tempo->torpedos--;
tempt=CAlloc(sizeof(Torpedo));
tempt->x=tempo->x;
tempt->y=tempo->y;
tempt->speed=100;
d/=tempt->speed*(GAME_SPEED_SCALE*game_speed);
tempo1->death_time=tempt->timeout=tS+d;
tempt->target=tempo1;
tempt->é=Arg(tempo1->x-tempo->x,tempo1->y-tempo->y);
QueIns(tempt,torpedo_root.last);
Sweep(2000,2000,300);
} else if (tempo->ship_guns>0 && d<tempo->ship_guns_range) {
tempo->flags|=OF_SHOOTING;
if (Rand<125.0*period) {
tempo1->life_percent-=tempo->ship_guns*Rand*period;
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
}
Noise(100,75,200);
}
} else {
if (tempo->air_guns>0 && d<tempo->air_guns_range) {
tempo->flags|=OF_SHOOTING;
if (Rand<125.0*period) {
tempo1->life_percent-=tempo->air_guns*Rand*period;
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
}
Noise(25,500,2000);
}
}
}
tempo=tempo->next;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
tempo1=tempo->next;
if (tempo->type==OT_FIGHTER &&
(tempo->life_percent<=0.0 || tempo->flags&OF_ACTIVE && tempo->fuel<=0.0 ||
tempo->host && !(tempo->flags&OF_ACTIVE) && tempo->host->life_percent<=0.0))
ObjDel(tempo);
tempo=tempo1;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
tempo1=tempo->next;
if (tempo->life_percent<=0.0)
ObjDel(tempo);
tempo=tempo1;
}
}
#define ANIMATE_FREQ 50
U0 AnimateTask(I64)
{ //Preemption is off after Spawn
Obj *tempo;
Torpedo *tempt,*tempt1;
F64 d,period;
I64 cnt=0;
while (TRUE) {
period=GAME_SPEED_SCALE*game_speed/ANIMATE_FREQ;
SquadronActions;
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->flags&OF_ACTIVE && tempo->fuel>0) {
if (tempo->dé) {
d=tempo->dé;
if (d> tempo->turn_rate*period) d= tempo->turn_rate*period;
if (d<-tempo->turn_rate*period) d=-tempo->turn_rate*period;
tempo->é +=d;
tempo->dé-=d;
}
tempo->x+=tempo->speed*Cos(tempo->é)*period*tempo->life_percent/100.0;
tempo->y+=tempo->speed*Sin(tempo->é)*period*tempo->life_percent/100.0;
tempo->fuel-=tempo->speed*tempo->fuel_burn_rate*period;
}
tempo=tempo->next;
}
tempt=torpedo_root.next;
while (tempt!=&torpedo_root) {
tempt1=tempt->next;
if (tS>tempt->timeout) {
tempo=tempt->target;
if (Rand<0.333333) {
tempo->life_percent-=150*Rand*Rand;
if (Rand<0.333333)
tempo->fuel*=0.75*Rand+0.25;
}
QueRem(tempt);
Free(tempt);
} else {
tempt->x+=tempt->speed*Cos(tempt->é)*period;
tempt->y+=tempt->speed*Sin(tempt->é)*period;
}
tempt=tempt1;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->host && !(tempo->flags&OF_ACTIVE)) {
tempo->x=tempo->host->x;
tempo->y=tempo->host->y;
}
tempo=tempo->next;
}
tempo=obj_root.next;
while (tempo!=&obj_root) {
if (tempo->flags&OF_ACTIVE) {
if (tempo->host) {
d=Sqrt(Sqr(tempo->x-tempo->host->x)+Sqr(tempo->y-tempo->host->y));
if (d<8 && tempo->max_fuel-tempo->fuel>30) {
tempo->life_percent=100.0;
if (tempo->host->fuel>0) {
d=tempo->max_fuel-tempo->fuel;
if (d>tempo->host->fuel) d=tempo->host->fuel;
tempo->host->fuel-=d;
tempo->fuel+=d;
}
tempo->torpedos=tempo->max_torpedos;
tempo->x=tempo->host->x;
tempo->y=tempo->host->y;
tempo->flags&=~OF_ACTIVE;
} else if (d>tempo->fuel-250)
tempo->flags|=OF_RETURNING;
if (tempo->flags&OF_RETURNING)
tempo->dé+=Wrap(Arg(tempo->host->x-tempo->x,tempo->host->y-tempo->y)-(tempo->é+tempo->dé),-ã);
} else if (tempo->type==OT_CARRIER)
tempo->life_percent=Min(100.0,tempo->life_percent+2.5*period);
}
tempo=tempo->next;
}
AI(1,period);
Combat(period);
Sleep(1000/ANIMATE_FREQ);
}
}
U0 FlatTops()
{
I64 p1,p2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLUE<<4+WHITE;
PopUpOk("$$GREEN$${Left-Mouse}$$FG$$\t\tChange Course\n"
"$$GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
"$$GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Screen\n");
Preempt(OFF),
WinBorder;
WordStat;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Faster(,'+');"
" Slower(,'-');"
"}"
);
WinMax;
Fs->win_inhibit|=WIF_IP_L|WIF_IP_R;
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
try {
while (TRUE)
switch(GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_IP_R_D_UP)) {
case MSG_KEY_DOWN:
switch (p1) {
case '\n':
CleanUp;
Init;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto nv_done;
case '+':
game_speed*=1.5;
break;
case '-':
game_speed/=1.5;
break;
}
break;
case MSG_IP_L_UP:
SquadronSeté(0,p1,p2);
break;
case MSG_IP_R_UP:
SquadronLaunch(0,p1,p2);
break;
case MSG_IP_R_D_UP:
SquadronReturn(0,p1,p2);
break;
}
nv_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
MenuPop;
SettingsPop;
CleanUp;
}
FlatTops;
r&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿr&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍ÿ␍␍ÿ␍␍ÿ␍␍ÿ␍␍ÿ␍ÿ␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍ÿÿÿ␍␍ÿÿÿÿ␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0
þÿÿÿ
ÿÿÿÿ 0
þÿÿÿ
ÿÿÿÿ␍
+165
View File
@@ -0,0 +1,165 @@
#define NUM_ROAD 512
#define ROAD_WIDTH_BY_2 200
#define CAR_WIDTH_BY_2 100
I64 road_x[NUM_ROAD],road_trend;
F64 speed,distance;
I64 road_ptr=0,car_x;
F64 t_last;
Bool crash;
U0 DrawIt(CTask *task,CDC *dc)
{
I64 w=task->pix_width,h=task->pix_height;
I64 i,x,y,xx;
Bool old_preempt=Preempt(OFF);
xx=w>>1-car_x+road_x[road_ptr&(NUM_ROAD-1)];
dc->color=LTGRAY;
for (i=0;i<NUM_ROAD;i++) {
x=w>>1-car_x+road_x[(i+road_ptr)&(NUM_ROAD-1)];
y=h-0.5*i;
if (y<(h+FONT_HEIGHT)>>1) break;
GrPlot(dc,x+ROAD_WIDTH_BY_2-0.4*i,y);
GrPlot(dc,x-ROAD_WIDTH_BY_2+0.4*i,y);
}
dc->color=WHITE;
x=w>>1-CAR_WIDTH_BY_2;
if (x<xx-ROAD_WIDTH_BY_2)
crash=TRUE;
GrLine(dc,x-10,h,x-40,h-100);
GrLine(dc,x+10,h,x+40,h-100);
x=w>>1+CAR_WIDTH_BY_2;
if (x>xx+ROAD_WIDTH_BY_2)
crash=TRUE;
GrLine(dc,x-10,h,x-40,h-100);
GrLine(dc,x+10,h,x+40,h-100);
dc->color=YELLOW;
if (crash)
GrPrint(dc,w>>1-FONT_WIDTH*4,(h-FONT_HEIGHT)>>1,"Game Over");
Preempt(old_preempt);
}
U0 UpdateRoad()
{
F64 t0=tS;
distance+=speed*(t0-t_last);
t_last=t0;
while (distance>1.0) {
road_trend=ClampI64(road_trend+SignI64(RandU16%3-1),-5,5);
road_x[road_ptr&(NUM_ROAD-1)]=
road_x[(road_ptr-1)&(NUM_ROAD-1)]+=road_trend/3;
road_ptr++;
distance-=1.0;
}
}
U0 Init()
{
I64 i,x=0;
DocClear;
"$$BG,DKGRAY$$"; NewLine((TEXT_ROWS-1)/2);
speed=0;
distance=0;
road_trend=0;
road_ptr=0;
car_x=0;
for (i=0;i<NUM_ROAD;i++) {
road_x[i]=x;
road_trend=ClampI64(road_trend+SignI64(RandU16%3-1),-5,5);
x+=road_trend/3;
}
t_last=tS;
crash=FALSE;
}
U0 Halogen()
{
I64 p1,p2,ch=0,sc=0;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Accelerate(,,SC_CURSOR_UP);"
" Deccellerate(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
Preempt(OFF);
WordStat;
WinMax;
Init;
DocCursor;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (ScanMsg(&p1,&p2,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
case MSG_KEY_DOWN:
ch=p1;sc=p2;
switch (ch) {
case '\n':
Init;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto ha_done;
}
break;
case MSG_KEY_UP:
ch=p1;sc=p2;
if (!ch)
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
case SC_CURSOR_LEFT:
case SC_CURSOR_UP:
case SC_CURSOR_DOWN:
sc=0;
break;
}
break;
}
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
car_x++;
break;
case SC_CURSOR_LEFT:
car_x--;
break;
case SC_CURSOR_UP:
if (++speed>200) speed=200;
break;
case SC_CURSOR_DOWN:
if (--speed<0) speed=0;
break;
}
if (crash)
Snd(0);
else {
if (speed)
Snd(speed+10);
else
Snd(0);
UpdateRoad;
}
Sleep(10);
}
ha_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
MenuPop;
DocClear;
SettingsPop;
}
Halogen;
+189
View File
@@ -0,0 +1,189 @@
class MyMass:CMass
{
F64 radius;
};
class MySpring:CSpring
{
};
CMathODE *ode=NULL;
U0 DrawIt(CTask *task,CDC *dc)
{
Bool old_suspend;
MyMass *tempm;
MySpring *temps;
old_suspend=Suspend(task);
dc->color=RED;
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
GrLine(dc,temps->end1->x,temps->end1->y,
temps->end2->x,temps->end2->y);
temps=temps->next;
}
dc->color=BLACK;
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
GrCircle(dc,tempm->x,tempm->y,tempm->radius);
tempm=tempm->next;
}
Suspend(task,old_suspend);
}
U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
{
//The forces due to springs and drag are
//automatically handled by the
//ode code. We can add new forces
//here.
F64 d,dd;
CD3 p;
MyMass *tempm1,*tempm2;
tempm1=ode->next_mass;
while (tempm1!=&ode->next_mass) {
tempm2=tempm1->next;
while (tempm2!=&ode->next_mass) {
D3Sub(&tempm2->state->x,&tempm1->state->x,&p);
dd=D3SqrNorm(&p);
if (dd<=Sqr(tempm1->radius+tempm2->radius)) {
d=Sqrt(dd)+0.0001;
dd=10.0*Sqr(Sqr(Sqr(tempm1->radius+tempm2->radius)-dd));
D3MulEqu(&p,dd/d);
D3AddEqu(&tempm2->DstateDt->DxDt,&p);
D3SubEqu(&tempm1->DstateDt->DxDt,&p);
}
tempm2=tempm2->next;
}
tempm1=tempm1->next;
}
}
U0 PlaceMass(I64 x, I64 y)
{
MyMass *tempm=CAlloc(sizeof(MyMass));
tempm->mass=1.0;
tempm->drag_profile_factor=100.0;
tempm->x=x;
tempm->y=y;
tempm->radius=10*(Rand+0.25);
QueIns(tempm,ode->last_mass);
}
U0 PlaceSpring(MyMass *tempm1,MyMass *tempm2)
{
MySpring *temps=CAlloc(sizeof(MySpring));
temps->end1=tempm1;
temps->end2=tempm2;
temps->const=10000;
temps->rest_len=100;
QueIns(temps,ode->last_spring);
}
U0 Init()
{
ode=ODENew(0,1e-4,ODEF_HAS_MASSES);
ode->derivative=&MyDerivative;
ode->drag_v2=0.002;
ode->drag_v3=0.00001;
ode->acceleration_limit=5e3;
QueIns(ode,Fs->last_ode);
}
U0 CleanUp()
{
QueRem(ode);
QueDel(&ode->next_mass,TRUE);
QueDel(&ode->next_spring,TRUE);
ODEDel(ode);
}
U0 MassSpringDemo()
{
I64 msg_code,p1,p2;
MyMass *tempm1=NULL,*tempm2=NULL;
PopUpOk("Left-Click to place mas\n"
"Right-Click and drag to\n"
"connect with spring.\n\n"
"Springs are 100 pixs long.\n");
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
//This Preempt() eliminates a lot of hassles.
//The concern is about changing
//que links while the winmgr task
//is updating the ode or screen.
//The Window mgr suspends this
//task while updating the ode. It
//will not be interrupted and with this
//preempt, we will not be interrupted.
//There is little downside to Preempt()
//since we will yield during GetMsg().
Preempt(OFF);
Fs->win_inhibit|=WIG_DBL_CLICK;
WordStat;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
"}"
);
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
msg_code=GetMsg(&p1,&p2,1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN);
switch (msg_code) {
case MSG_IP_L_DOWN:
PlaceMass(p1,p2);
break;
case MSG_IP_R_DOWN:
tempm1=MassFind(ode,p1,p2);
tempm2=NULL;
break;
case MSG_IP_R_UP:
if (tempm1 && (tempm2=MassFind(ode,p1,p2)) && tempm1!=tempm2)
PlaceSpring(tempm1,tempm2);
tempm1=tempm2=NULL;
break;
case MSG_KEY_DOWN:
switch (p1) {
case '\n':
CleanUp;
Init;
break;
case CH_SHIFT_ESC:
case CH_ESC:
goto ms_done;
}
break;
}
}
ms_done: //Don't goto out of try
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
SettingsPop;
CleanUp;
MenuPop;
}
MassSpringDemo;
+112
View File
@@ -0,0 +1,112 @@
//See $LK,"ExtScreenCodes",A="FA:::/Adam/Gr/GrScreen.CPP,ExtScreenCodes"$
#define ATTR (BLACK<<12+WHITE<<8)
U32 text[TEXT_ROWS][TEXT_COLS];
U0 DrawIt(CTask *task,CDC *)
{
MemCpy(gr_text_base+TEXT_COLS,text,(TEXT_ROWS-1)*TEXT_COLS*sizeof(U32));
// You can copy it this way, if you like:
// I64 i,j;
// for (j=0;j<TEXT_ROWS;j++)
// for (i=0;i<TEXT_COLS;i++)
// PlotWinU8(task,text[j][i],i,j);
PlotWinStr(task,"Draw a maze with left button.",ATTR>>8,0,0);
PlotWinStr(task,"Solve maze starting at right click.",ATTR>>8,0,1);
}
#define STK_SIZE 2048
//We would put these as local vars
//In SolveMaze() except the system stk size
//is limited. The heap is the normal TempleOS
//technique, but it's a pain in this case.
I64 stk_ptr,
stk_x [STK_SIZE],
stk_y [STK_SIZE],
stk_dir[STK_SIZE];
//Four directions:
// 0=Up,1=right,2=down,3=left
I64 dir_x[4]={ 0,+1, 0,-1}, // Could use $LK,"gr_x_offsets2",A="MN:gr_x_offsets2"$,$LK,"gr_y_offsets2",A="MN:gr_y_offsets2"$
dir_y[4]={+1, 0,-1, 0};
U0 SolveMaze(I64 x,I64 y)
{
I64 dir=0;
stk_ptr=0;
stk_x[stk_ptr]=x;
stk_y[stk_ptr]=y;
stk_dir[stk_ptr++]=dir;
while (TRUE) {
if (!(0<=x<MinI64(Fs->win_width,TEXT_COLS)) ||
!(0<=y<MinI64(Fs->win_height,TEXT_ROWS)) ) {
Beep;Beep;
break;
}
if (!text[y][x].u8[0])
text[y][x]='.'+ATTR;
x+=dir_x[dir];
y+=dir_y[dir];
//u8.[0] is the ASCII
if (text[y][x].u8[0]) {
x-=dir_x[dir];
y-=dir_y[dir];
if (++dir==4) {
if (--stk_ptr<0) return;
x=stk_x[stk_ptr];
y=stk_y[stk_ptr];
dir=stk_dir[stk_ptr];
}
} else {
dir=0;
stk_x[stk_ptr]=x;
stk_y[stk_ptr]=y;
stk_dir[stk_ptr++]=dir;
if (stk_ptr==STK_SIZE) return;
Sleep(100);
if (ScanChar)
ThrowBreak; //CTRL-ALT-C
}
}
}
U0 Maze()
{
I64 ch,x,y;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
WinBorder;
WordStat;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
try
do {
MemSet(text,0,sizeof(text));
while (!(ch=ScanChar)) {
//Input Ptr (mouse) text x,y coordinates.
x=iptx-Fs->win_left-Fs->scroll_x/FONT_WIDTH;
y=ipty-Fs->win_top-Fs->scroll_y/FONT_HEIGHT;
if (ip_lb&&!win_grab_scroll)
text[y][x]=CH_SPACE+ATTRF_INVERT+ATTR;
if (ip_rb&&!win_grab_scroll) {
text[y][x]='*'+ATTR;
SolveMaze(x,y);
ch=GetChar;
break;
}
WinMgrSync;
}
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
catch
PutExcept;
SettingsPop;
}
Maze;
+192
View File
@@ -0,0 +1,192 @@
I64 sc_1,sc_2;
#define NUM_DROPS 0x2000
class Drop
{
I32 x,y;
} drops[NUM_DROPS];
CDC *cur_dc;
U0 DrawFrame(CTask *task,CDC *dc)
{
I64 w=task->pix_width,h=task->pix_height,
cx=w>>1,cy=h>>1;
dc->color=LTRED;
GrLine(dc,cx-20,cy-50,cx,cy-150);
GrLine(dc,cx+20,cy-50,cx,cy-150);
dc->color=LTRED;
GrLine(dc,cx-100,cy-100,cx,cy);
GrLine(dc,cx+100,cy-100,cx,cy);
if (Bt(key_down_bitmap,sc_1)) {
dc->color=WHITE;
GrRect(dc,cx-2,cy-2,5,5);
}
dc->color=BLACK;
GrPrint(dc,cx+10,cy,"Press '1'");
dc->color=LTRED;
GrRect(dc,cx-20,cy+60,41,21);
dc->color=LTRED;
GrLine(dc,cx-200,cy,cx,cy+100);
GrLine(dc,cx+200,cy,cx,cy+100);
if (Bt(key_down_bitmap,sc_2)) {
dc->color=WHITE;
GrRect(dc,cx-2,cy+100-2,5,5);
}
dc->color=BLACK;
GrPrint(dc,cx+10,cy+100,"Press '2'");
dc->color=LTRED;
GrLine(dc,cx+400,cy+100,cx-250,cy+200);
}
U0 DrawDrops(CTask *,CDC *dc)
{
I64 i;
dc->color=BLUE;
for (i=0;i<NUM_DROPS;i++)
if (drops[i].y>=0 && GrPeek(dc,drops[i].x,drops[i].y)==WHITE)
GrPlot(dc,drops[i].x,drops[i].y);
}
U0 UpdateCurBase(CTask *task,CDC *dc)
{
Bool old_preempt=Preempt(OFF);
cur_dc->color=ROP_EQU;
dc->flags|=DCF_NO_TRANSPARENTS;
GrBlot(cur_dc,-task->pix_left-task->scroll_x,-task->pix_top-task->scroll_y,dc);
dc->flags&=~DCF_NO_TRANSPARENTS;
Preempt(old_preempt);
}
U0 DrawIt(CTask *task,CDC *dc)
{
DrawFrame(task,dc);
DrawDrops(task,dc);
UpdateCurBase(task,dc);
}
U0 AnimateTask(I64)
{
I64 i,j,cur_drop=0,c1,c2,x0,y0,x1,y1,w,h;
while (TRUE) {
w=Fs->parent_task->pix_width;
h=Fs->parent_task->pix_height;
for (i=0;i<2;i++) {
j=0;
do {
if (++cur_drop>=NUM_DROPS)
cur_drop=0;
if (drops[cur_drop].y<0)
break;
j++;
} while (j<=NUM_DROPS);
drops[cur_drop].x=RandU32%w;
drops[cur_drop].y=0;
}
for (i=0;i<NUM_DROPS;i++) {
if (drops[i].y>=0) {
if (drops[i].y>=h-1)
drops[i].y=-MAX_I32;
else {
x0=x1=drops[i].x;
y0=y1=drops[i].y;
if (GrPeek(cur_dc,x0,y0+1)==WHITE)
y1++;
else {
c1=GrPeek(cur_dc,x0+1,y0);
c2=GrPeek(cur_dc,x0-1,y0);
if (c1==WHITE && c2!=WHITE)
x1++;
else if (c2==WHITE && c1!=WHITE)
x1--;
else if (c1==WHITE && c2==WHITE) {
c1=GrPeek(cur_dc,x0+1,y0+1);
c2=GrPeek(cur_dc,x0-1,y0+1);
if (c1==WHITE && c2!=WHITE)
x1++;
else if (c2==WHITE && c1!=WHITE)
x1--;
else if (RandI16>=0)
x1++;
else
x1--;
}
if (GrPeek(cur_dc,x1,y1+1)==WHITE)
y1++;
}
if (GrPeek(cur_dc,x0,y0)==BLUE) {
cur_dc->color=WHITE;
GrPlot(cur_dc,x0,y0);
}
cur_dc->color=BLUE;
GrPlot(cur_dc,x1,y1);
drops[i].x=x1;
drops[i].y=y1;
}
}
}
Sleep(10);
}
}
U0 Init()
{
I64 i;
MemSet(drops,0,sizeof(drops));
for (i=0;i<NUM_DROPS;i++)
drops[i].y=-MAX_I32;
}
U0 RainDrops()
{
I64 ch,sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" OpenUpper(,'1');"
" OpenLower(,'2');"
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
cur_dc=DCNew(GR_WIDTH,GR_HEIGHT);
sc_1=A2ScanCode('1');
sc_2=A2ScanCode('2');
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
WordStat;
try {
do {
ch=GetKey(&sc);
switch (ch) {
case '\n':
Init;
break;
}
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
} catch
PutExcept;
SettingsPop;
MenuPop;
DCDel(cur_dc);
}
RainDrops;
+523
View File
@@ -0,0 +1,523 @@
//This uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/RawHide","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/RawHide");
F64 t0,tf;
#define MAP_WIDTH 1500
#define MAP_HEIGHT 1500
#define MAP_BORDER 3
CDC *dc2;
$BG,10$
#define GE_COW 0
$SP,"<1>",BI=1$
#define GE_BULL 1
$SP,"<2>",BI=2$
#define GE_HORSE 2
$SP,"<3>",BI=3$
#define GE_NUM 3
$BG$
class RHCSprite
{
U8 *img;
I64 min_x,max_x,min_y,max_y;
} rh_sprite[GE_NUM];
#define NUM_ANIMALS 128
class Animal
{
I64 num,x,y,dx,dy;
RHCSprite *ge;
U32 buddy;
U8 type;
Bool dead,pad[2];
} *a;
// ************************************
#define COURSE_LEN (MAP_HEIGHT*2)
I32 *rx,*ry,*rw;
I64 river_lo,river_hi;
U0 RiverNew()
{
rx=MAlloc(COURSE_LEN*sizeof(I32));
ry=MAlloc(COURSE_LEN*sizeof(I32));
rw=MAlloc(COURSE_LEN*sizeof(I32));
river_lo=river_hi=COURSE_LEN/2;
}
U0 RiverMake()
{
I64 i,x,y,dx,dy,w,old_x,old_y;
//Plan lower course of river
old_x=-1;old_y=-1;
x=MAP_WIDTH<<32/2; y=MAP_HEIGHT<<32/2;
dx=0; dy=1<<32;
w=20<<32;
i=COURSE_LEN/2;
while (y.i32[1]<MAP_HEIGHT-MAP_BORDER && i<COURSE_LEN) {
if (old_x.i32[1]!=x.i32[1]||old_y.i32[1]!=y.i32[1]) {
rx[i]=x.i32[1]; ry[i]=y.i32[1]; rw[i]=w.i32[1];
river_hi=i++;
old_x=x; old_y=y;
}
dx=ClampI64(dx+RandI32/64,-MAX_I32,MAX_I32);
dy=ClampI64(dy+RandI32/64,0,MAX_I32);
x+=dx; y+=dy;
w=ClampI64(w+RandI32*2,10*MAX_U32,150*MAX_U32);
}
//Plan upper course of river
old_x=-1;old_y=-1;
x=MAP_WIDTH<<32/2; y=MAP_HEIGHT<<32/2;
dx=0; dy=-1<<32;
w=20<<32;
i=COURSE_LEN/2-1;
while (y.i32[1]>=MAP_BORDER && i>=0) {
if (old_x.i32[1]!=x.i32[1]||old_y.i32[1]!=y.i32[1]) {
rx[i]=x.i32[1]; ry[i]=y.i32[1]; rw[i]=w.i32[1];
river_lo=i--;
old_x=x; old_y=y;
}
dx=ClampI64(dx+RandI32/64,-MAX_I32,MAX_I32);
dy=ClampI64(dy+RandI32/64,-MAX_I32,0);
x+=dx; y+=dy;
w=ClampI64(w+RandI32*2,10*MAX_U32,150*MAX_U32);
}
//Plot sand bar
x=0; y=0;
for (i=river_lo;i<=river_hi;i++) {
dc2->color=YELLOW;
dc2->pen_width=rw[i]+5;
GrPlot3(dc2,rx[i]+x.i32[1],ry[i]+y.i32[1],0);
x=ClampI64(x+RandI32,-6*MAX_U32,6*MAX_U32);
y=ClampI64(y+RandI32,-6*MAX_U32,6*MAX_U32);
}
//Plot water
for (i=river_lo;i<=river_hi;i++) {
dc2->color=BLUE;
dc2->pen_width=rw[i];
GrPlot3(dc2,rx[i],ry[i],0);
}
}
U0 RiverDel()
{
Free(rx);
Free(ry);
Free(rw);
}
// ************************************
class RiverDrop
{
RiverDrop *next,*last;
I64 index,dx,dy;
} rd_root;
Bool rd_lock;
U0 RiverDropsDel()
{
while (LBts(&rd_lock,0))
Yield;
QueDel(&rd_root,TRUE);
QueInit(&rd_root);
LBtr(&rd_lock,0);
}
U0 RiverDropsNext(CTask *mem_task)
{
RiverDrop *tempr,*tempr1;
while (LBts(&rd_lock,0))
Yield;
tempr=rd_root.next;
while (tempr!=&rd_root) {
tempr1=tempr->next;
if (++tempr->index>river_hi) {
QueRem(tempr);
Free(tempr);
} else {
do {
if (RandU16&1 &&
GrPeek(dc2,rx[tempr->index]+tempr->dx,ry[tempr->index]+tempr->dy)==BLUE)
break;
tempr->dx=ClampI64(tempr->dx+RandU16%3-1,-rw[tempr->index]/2,rw[tempr->index]/2);
tempr->dy=ClampI64(tempr->dy+RandU16%3-1,-rw[tempr->index]/2,rw[tempr->index]/2);
} while (GrPeek(dc2,rx[tempr->index]+tempr->dx,ry[tempr->index]+tempr->dy)!=BLUE &&
GrPeek(dc2,rx[tempr->index] ,ry[tempr->index]) ==BLUE); //Might be reinitializing
}
tempr=tempr1;
}
tempr=MAlloc(sizeof(RiverDrop),mem_task);
tempr->index=river_lo;
tempr->dx=0;
tempr->dy=0;
QueIns(tempr,rd_root.last);
LBtr(&rd_lock,0);
}
U0 RiverDropsDraw(CDC *dc,I64 cx,I64 cy)
{
RiverDrop *tempr;
dc->color=LTBLUE;
while (LBts(&rd_lock,0))
Yield;
tempr=rd_root.next;
while (tempr!=&rd_root) {
GrPlot(dc,rx[tempr->index]+tempr->dx-cx,ry[tempr->index]+tempr->dy-cy);
tempr=tempr->next;
}
LBtr(&rd_lock,0);
}
// ************************************
U0 DrawIt(CTask *task,CDC *dc)
{
static I64 last_ipx=0;
static Bool left=TRUE;
F64 t;
I64 i,
cx=(MAP_WIDTH -task->pix_width)/2,
cy=(MAP_HEIGHT-task->pix_height)/2;
if (task->scroll_x+cx<0)
task->scroll_x=-cx;
if (task->scroll_x+cx>MAP_WIDTH-task->pix_width)
task->scroll_x=MAP_WIDTH-task->pix_width-cx;
if (task->scroll_y+cy<0)
task->scroll_y=-cy;
if (task->scroll_y+cy>MAP_HEIGHT-task->pix_height)
task->scroll_y=MAP_HEIGHT-task->pix_height-cy;
dc2->flags|=DCF_NO_TRANSPARENTS;
GrBlot(dc,-cx,-cy,dc2);
RiverDropsDraw(dc,cx,cy);
for (i=0;i<NUM_ANIMALS;i++)
if (!a[i].dead) {
if (a[i].dx<0) {
dc->flags|=DCF_JUST_MIRROR|DCF_SYMMETRY;
GrSetSymmetry(dc,a[i].x.i32[1]-cx,0,a[i].x.i32[1]-cx,1);
}
Sprite3(dc,a[i].x.i32[1]-cx,a[i].y.i32[1]-cy,0,a[i].ge->img);
dc->flags&=~(DCF_JUST_MIRROR|DCF_SYMMETRY);
}
if (ipx-last_ipx>0)
left=FALSE;
else if (ipx-last_ipx<0)
left=TRUE;
if (left) {
dc->flags|=DCF_JUST_MIRROR|DCF_SYMMETRY;
GrSetSymmetry(dc,ipx-task->pix_left-task->scroll_x,0,ipx-task->pix_left-task->scroll_x,1);
}
Sprite3(dc,
ipx-task->pix_left-task->scroll_x,
ipy-task->pix_top -task->scroll_y,0,rh_sprite[GE_HORSE].img);
dc->flags&=~(DCF_JUST_MIRROR|DCF_SYMMETRY);
last_ipx=ipx;
if (tf) {
dc->color=RED;
t=tf-t0;
if (Blink)
GrPrint(dc,(task->pix_width-FONT_WIDTH*14)>>1-task->scroll_x,
(task->pix_height-FONT_HEIGHT)>>1-task->scroll_y,
"Game Completed");
} else {
dc->color=BLACK;
t=tS-t0;
}
GrPrint(dc,-task->scroll_x,-task->scroll_y,"Time:%7.2fs Best:%7.2fs",t,best_score);
}
U0 BuddySelect(I64 i)
{
I64 b,best_b=i,score,best_score=MAX_I64;
for (b=0;b<NUM_ANIMALS;b++) {
if (b!=i && !a[b].dead) {
score=RandU32%(512*512)+
SqrI64(a[b].x.i32[1]-a[i].x.i32[1])+
SqrI64(a[b].y.i32[1]-a[i].y.i32[1]);
if (score<best_score) {
best_score=score;
best_b=b;
}
}
}
a[i].buddy=best_b;
}
U0 AnimateTask(CTask *parent)
{
I64 i,cx,cy,cursor_x,cursor_y,dd,ddx,ddy,cnt,max_speed=MAX_I64,
min_x,max_x,min_y,max_y,updates=0;
F64 f,d,dx,dy,s,stress;
Animal *tempa,*tempa1;
while (TRUE) {
max_speed=ClampU64(max_speed,MAX_U32/3,200*MAX_U32);
cx=(MAP_WIDTH -parent->pix_width)/2,
cy=(MAP_HEIGHT-parent->pix_height)/2;
cursor_x=ipx+cx-parent->pix_left-parent->scroll_x;
cursor_y=ipy+cy-parent->pix_top -parent->scroll_y;
min_x=max_x=min_y=max_y=cnt=0;
stress=0;
for (i=0;i<NUM_ANIMALS;i++) {
tempa=&a[i];
if (!tempa->dead) {
//Move away from horse
ddx=tempa->x.i32[1]-cursor_x;
ddy=tempa->y.i32[1]-cursor_y;
if (dd=SqrI64(ddx)+SqrI64(ddy)) {
d=Sqrt(dd);
dx=ddx/d;
dy=ddy/d;
f=2.0e2*MAX_U32/dd;
tempa->dx+=f*dx;
tempa->dy+=f*dy;
}
//Reselect buddy about every NUM_ANIMALS*10ms=5.12 seconds
tempa1=&a[tempa->buddy];
if (tempa1->dead || i==updates%NUM_ANIMALS) {
BuddySelect(i);
tempa1=&a[tempa->buddy];
}
//Move toward buddy
ddx=tempa->x.i32[1]-tempa1->x.i32[1];
ddy=tempa->y.i32[1]-tempa1->y.i32[1];
if (dd=SqrI64(ddx)+SqrI64(ddy)) {
d=Sqrt(dd);
s=d`1.25-80;
stress+=Abs(s);
dx=ddx/d;
dy=ddy/d;
f=-0.001*s*MAX_U32;
tempa->dx+=f*dx;
tempa->dy+=f*dy;
}
//Make velocity similar to buddy
tempa->dx+=0.1*(tempa1->dx-tempa->dx);
tempa->dy+=0.1*(tempa1->dy-tempa->dy);
//Add random movement, limit speed and dampen speed
tempa->dx=0.995*ClampI64(tempa->dx+RandI32/32,-max_speed,max_speed);
tempa->dy=0.995*ClampI64(tempa->dy+RandI32/32,-max_speed,max_speed);
//Slow in river
if (GrPeek(dc2,tempa->x.i32[1],tempa->y.i32[1])!=LTGREEN) {
tempa->dx/=4;
tempa->dy/=4;
}
tempa->x+=tempa->dx;
tempa->y+=tempa->dy;
//Keep on map
if (!(MAP_BORDER-tempa->ge->min_x<=tempa->x.i32[1]<MAP_WIDTH-MAP_BORDER-tempa->ge->max_x)) {
tempa->x -=tempa->dx;
tempa->dx=-tempa->dx;
}
if (!(MAP_BORDER-tempa->ge->min_y<=tempa->y.i32[1]<MAP_HEIGHT-MAP_BORDER-tempa->ge->max_y)) {
tempa->y -=tempa->dy;
tempa->dy=-tempa->dy;
}
if (cnt) {
min_x=MinI64(min_x,tempa->x);
max_x=MaxI64(max_x,tempa->x);
min_y=MinI64(min_y,tempa->y);
max_y=MaxI64(max_y,tempa->y);
} else {
min_x=max_x=tempa->x;
min_y=max_y=tempa->y;
}
cnt++;
}
}
if (!(updates&15))
RiverDropsNext(parent);
if (!tf && (max_x-min_x)>>32<GR_WIDTH && (max_y-min_y)>>32<GR_HEIGHT) {
tf=tS;
music_mute=TRUE;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
if (tf-t0<best_score) {
best_score=tf-t0;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
}
music_mute=FALSE;
}
updates++;
if (cnt)
stress/=cnt;
else
stress=0;
if (stress>100.0) {
Yield;
max_speed=stress/5.0*MAX_U32; //Converge faster at start-up
} else {
Sleep(10);
max_speed=0; //Will be set to normal max speed
}
}
}
U0 SongTask(I64)
{ //Randomly generated (by God :-)
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("3qC2etG3DCBDCECFqFCsADADqB");
Play("C2etG3DCBDCECFqFCsADADqB");
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
}
}
U0 ReInit()
{
I64 i;
RiverDropsDel;
dc2->color=LTGREEN;
GrRect(dc2,2,2,MAP_WIDTH-4,MAP_HEIGHT-4);
RiverMake;
dc2->pen_width=MAP_BORDER;
dc2->color=RED;
GrLineRect4(dc2,MAP_BORDER/2,MAP_BORDER/2,MAP_WIDTH-(MAP_BORDER+1)/2,MAP_HEIGHT-(MAP_BORDER+1)/2);
for (i=river_lo;i<=river_hi;i++)
RiverDropsNext(Fs);
MemSet(a,0,NUM_ANIMALS*sizeof(Animal));
for (i=0;i<NUM_ANIMALS;i++) {
a[i].num=i;
a[i].x=(64+RandU32%(MAP_WIDTH-128))<<32;
a[i].y=(64+RandU32%(MAP_WIDTH-128))<<32;
if (i&1)
a[i].ge=&rh_sprite[GE_COW];
else
a[i].ge=&rh_sprite[GE_BULL];
BuddySelect(i);
}
t0=tS;
tf=0;
}
U0 Init()
{
I64 i;
RHCSprite *ge;
rh_sprite[0].img=$IB,"<1>",BI=1$;
rh_sprite[1].img=$IB,"<2>",BI=2$;
rh_sprite[2].img=$IB,"<3>",BI=3$;
for (i=0;i<GE_NUM;i++) {
ge=&rh_sprite[i];
SpriteExtents(ge->img,&ge->min_x,&ge->max_x,&ge->min_y,&ge->max_y);
}
RiverNew;
rd_lock=0;
QueInit(&rd_root);
dc2=DCNew(MAP_WIDTH,MAP_HEIGHT);
a=MAlloc(NUM_ANIMALS*sizeof(Animal));
ReInit;
}
U0 CleanUp()
{
DCDel(dc2);
Free(a);
RiverDropsDel;
RiverDel;
}
U0 RawHide()
{
I64 msg_code,p1,p2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
PopUpOk(
"Coral the cattle into an area\n"
"the size of a screen.\n\n"
"Scroll with {CTRL-Left Grab}.\n"
"Center with {CTRL-Right}.");
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
"}"
);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER-WIF_GRAB_SCROLL-WIF_MENU;
WinMax;
WordStat;
Preempt(OFF);
Init;
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_R_DOWN);
switch (msg_code) {
case MSG_IP_L_DOWN: //Doesn't do anything, yet.
break;
case MSG_IP_R_DOWN: //Doesn't do anything, yet.
break;
case MSG_KEY_DOWN:
switch (p1) {
case '\n':
ReInit;
break;
case CH_SHIFT_ESC:
case CH_ESC:
goto rh_done;
}
break;
}
}
rh_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
PutExcept;
MenuPop;
SettingsPop;
CleanUp;
AcctRegWriteBranch("TempleOS/RawHide","F64 best_score=%5.4f;\n",best_score);
}
RawHide;
òöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿböÿÿÿôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÂöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Binary file not shown.
Binary file not shown.
+415
View File
@@ -0,0 +1,415 @@
#define MT_HOSE 1
#define MT_DROPLET 2
class MyMass:CMass
{
I64 type;
F64 radius;
};
#define ST_HOSE 1
class MySpring:CSpring
{
I64 type;
};
$BG,11$
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$BG$
$SP,"<4>",BI=4,BP="::/Demo/Graphics/Camp.CPP.Z,Mountain"$ //Pointer to sprite in Camp.CPP.Z file
#define HOSE_RADIUS 3
#define LINK_SIZE 6
#define NOZZLE_START_Y (GR_HEIGHT-15*FONT_HEIGHT)
#define NOZZLE_LEN 18
#define FAUCET_X (5*HOSE_RADIUS)
#define FAUCET_Y (GR_HEIGHT-12*FONT_HEIGHT)
#define GROUND_Y (GR_HEIGHT-3*FONT_HEIGHT)
MyMass *faucet,*nozzle;
F64 nozzle_é;
CMathODE *ode=NULL;
F64 start_up_timeout;
U0 DrawIt(CTask *task,CDC *dc)
{
Bool old_suspend,first;
F64 dx,dy,d;
I64 x1b,y1b,x2b,y2b,
x1a,y1a,x2a,y2a;
MyMass *tempm,*tempm1;
MySpring *temps;
CD3I32 poly[4];
Sprite3(dc,0,GROUND_Y,0,$IB,"<4>",BI=4$);
if (start_up_timeout>tS) {
ode->drag_v2=0.01; //Let hose settle during start-up
ode->drag_v3=0.0001;
dc->color=RED;
GrPrint(dc,(GR_WIDTH-FONT_WIDTH*6)>>1,GR_HEIGHT>>1,"Squirt");
return;
} else {
ode->drag_v2=0.0005;
ode->drag_v3=0.0000025;
}
old_suspend=Suspend(task);
tempm=faucet;
dc->color=BLACK;
GrRect(dc,tempm->x+8,tempm->y,8,GROUND_Y-FAUCET_Y);
Sprite3(dc,tempm->x,tempm->y,0,$IB,"<1>",BI=1$);
dc->color=BLACK;
GrCircle(dc,tempm->x,tempm->y,tempm->radius);
dc->color=GREEN;
GrFloodFill(dc,tempm->x,tempm->y);
tempm=nozzle;
tempm1=nozzle->last;
dx=tempm->x-tempm1->x;
dy=tempm->y-tempm1->y;
nozzle_é=Wrap(Arg(dx,dy));
SpriteZ3B(dc,tempm->x,tempm->y,0,$IB,"<2>",BI=2$,nozzle_é);
dc->color=BLACK;
GrCircle(dc,tempm->x,tempm->y,tempm->radius);
dc->color=GREEN;
GrFloodFill(dc,tempm->x,tempm->y);
first=TRUE;
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
if (tempm->type==MT_HOSE) {
tempm1=tempm->last;
dx=tempm->x-tempm1->x;
dy=tempm->y-tempm1->y;
d=HOSE_RADIUS/Max(Sqrt(dx*dx+dy*dy),0.001);
dx*=d;
dy*=d;
x2a=tempm->x-dy;
y2a=tempm->y+dx;
x2b=tempm->x+dy;
y2b=tempm->y-dx;
if (first)
first=FALSE;
else {
dc->color=GREEN;
poly[0].x=x1a;
poly[0].y=y1a;
poly[0].z=0;
poly[1].x=x2a;
poly[1].y=y2a;
poly[1].z=0;
poly[2].x=x2b;
poly[2].y=y2b;
poly[2].z=0;
poly[3].x=x1b;
poly[3].y=y1b;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
}
//Fill gaps
GrLine(dc,x2a,y2a,x2b,y2b);
x1a=x2a;
y1a=y2a;
x1b=x2b;
y1b=y2b;
} else if (tempm->type==MT_DROPLET)
Sprite3(dc,tempm->x,tempm->y,0,$IB,"<3>",BI=3$);
tempm=tempm->next;
}
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
if (temps->type==ST_HOSE) {
dx=temps->end1->x-temps->end2->x;
dy=temps->end1->y-temps->end2->y;
d=HOSE_RADIUS/Max(Sqrt(dx*dx+dy*dy),0.001);
dx*=d;
dy*=d;
dc->color=BLACK;
GrLine(dc,temps->end1->x-dy,temps->end1->y+dx,
temps->end2->x-dy,temps->end2->y+dx);
GrLine(dc,temps->end1->x+dy,temps->end1->y-dx,
temps->end2->x+dy,temps->end2->y-dx);
}
temps=temps->next;
}
Suspend(task,old_suspend);
}
U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *state,COrder2D3 *DstateDt)
{
//The forces due to springs and drag are
//automatically handled by the
//ode code. We can add new forces
//here.
nounusedwarn t,state,DstateDt;
// F64 d,dd;
// CD3 p;
MyMass *tempm1,*tempm2;
nounusedwarn tempm2;
tempm1=ode->next_mass;
while (tempm1!=&ode->next_mass) {
if (tempm1->type==MT_HOSE) {
if (tempm1->state->y+tempm1->radius>GROUND_Y)
tempm1->DstateDt->DyDt-=Sqr(Sqr(tempm1->state->y+tempm1->radius-GROUND_Y))*tempm1->mass;
else
tempm1->DstateDt->DyDt+=500*tempm1->mass;
if (tempm1==nozzle || tempm1==faucet) {
tempm1->DstateDt->DxDt=0;
tempm1->DstateDt->DyDt=0;
}
} else if (tempm1->type==MT_DROPLET)
tempm1->DstateDt->DyDt=500*tempm1->mass;
tempm1=tempm1->next;
}
}
MyMass *PlaceMass(I64 type,I64 x, I64 y,F64 r,F64 dx,F64 dy,F64 mass,CTask *mem_task)
{
MyMass *tempm=CAlloc(sizeof(MyMass),mem_task);
tempm->type=type;
tempm->mass=mass;
tempm->drag_profile_factor=250.0;
tempm->x=x;
tempm->y=y;
tempm->DxDt=dx;
tempm->DyDt=dy;
tempm->radius=r;
QueIns(tempm,ode->last_mass);
return tempm;
}
MySpring PlaceSpring(MyMass *tempm1,MyMass *tempm2)
{
MySpring *temps=CAlloc(sizeof(MySpring));
temps->end1=tempm1;
temps->end2=tempm2;
temps->const=20000;
QueIns(temps,ode->last_spring);
return temps;
}
U0 HoseNew()
{
I64 i;
MyMass *tempm1=NULL,*tempm;
MySpring *temps;
for (i=FAUCET_X;i<GR_WIDTH;i+=LINK_SIZE) {
tempm=PlaceMass(MT_HOSE,i/2,GROUND_Y-HOSE_RADIUS,HOSE_RADIUS,0,0,1.0,Fs);
if (tempm1) {
temps=PlaceSpring(tempm,tempm1);
temps->rest_len=LINK_SIZE;
temps->type=ST_HOSE;
nozzle=tempm;
} else
faucet=tempm;
tempm1=tempm;
}
faucet->y=FAUCET_Y;
nozzle->y=NOZZLE_START_Y;
nozzle_é=0;
}
U0 AnimateTask(I64)
{
//Preempt is off by default for new task
MyMass *tempm,*tempm1;
F64 dx,dy;
while (TRUE) {
//The WinMgr task suspends our parent when it
//updates the ODE's. We use this to know when
//the ODE's are being updated.
if (!IsSuspended(Fs->parent_task)) {
dx=Cos(nozzle_é),
dy=Sin(nozzle_é),
PlaceMass(MT_DROPLET,
nozzle->x+NOZZLE_LEN*dx,nozzle->y+NOZZLE_LEN*dy,
HOSE_RADIUS,
500*dx,500*dy,
100.0,Fs->parent_task);
if (Rand<0.05) //faucet drip
PlaceMass(MT_DROPLET,
faucet->x,faucet->y,
HOSE_RADIUS,
0,0,
100.0,Fs->parent_task);
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
tempm1=tempm->next;
if (tempm->type==MT_DROPLET &&
tempm->y+tempm->radius>GROUND_Y) {
QueRem(tempm);
Free(tempm);
}
tempm=tempm1;
}
}
WinMgrSync;
}
}
#define NOZZLE_MOVE_STEPS 5
#define NOZZLE_MOVE 15.0
U0 MoveNozzleTaskX(I64 sign)
{
I64 i;
for (i=0;i<NOZZLE_MOVE_STEPS;i++) {
nozzle->x=Clamp(nozzle->x+
sign*NOZZLE_MOVE/NOZZLE_MOVE_STEPS,
HOSE_RADIUS*3,GR_WIDTH-HOSE_RADIUS*3);
WinMgrSync;
}
}
U0 MoveNozzleTaskY(I64 sign)
{
I64 i;
for (i=0;i<NOZZLE_MOVE_STEPS;i++) {
nozzle->y=Clamp(nozzle->y+
sign*NOZZLE_MOVE/NOZZLE_MOVE_STEPS,
HOSE_RADIUS*3,GROUND_Y);
WinMgrSync;
}
}
U0 Init()
{
DocClear;
"$$BG,LTCYAN$$"; NewLine(GROUND_Y/FONT_HEIGHT);
//Allow hose to settle.
start_up_timeout=tS+0.5;
ode=ODENew(0,5e-2,ODEF_HAS_MASSES);
ode->derivative=&MyDerivative;
ode->acceleration_limit=5e3;
HoseNew;
QueIns(ode,Fs->last_ode);
}
U0 CleanUp()
{
WinMgrSync(NOZZLE_MOVE_STEPS); //Let nozzle move tasks die
QueRem(ode);
QueDel(&ode->next_mass,TRUE);
QueDel(&ode->next_spring,TRUE);
ODEDel(ode);
DocClear;
}
U0 SongTask(I64)
{
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("3eAM4/4");
Play("2qGeGqG3eAq.BqBeBqA2eG3qA");
Play("eB2hG3q.BqBeCq.DD");
Play("qCeBqCeDhB");
}
}
U0 Squirt()
{
I64 sc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=YELLOW<<4+BLUE;
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
WinMax;
WinBorder;
Preempt(OFF);
DocCursor;
WordStat;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" Up(,,SC_CURSOR_UP);"
" Down(,,SC_CURSOR_DOWN);"
"}"
);
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (GetKey(&sc)) {
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_LEFT:
Spawn(&MoveNozzleTaskX,-1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_RIGHT:
Spawn(&MoveNozzleTaskX,1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_UP:
Spawn(&MoveNozzleTaskY,-1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_DOWN:
Spawn(&MoveNozzleTaskY,1,"Move Nozzle",,Fs);
break;
}
break;
case '\n':
CleanUp;
Init;
break;
case CH_SHIFT_ESC:
case CH_ESC:
goto sq_done;
}
}
sq_done: //Don't goto out of try
} catch
PutExcept;
SettingsPop;
CleanUp;
MenuPop;
}
Squirt;
R÷ÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2 ÿÿÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿJýÿÿÿýÿÿÿÿÿÿ ÿÿ ÿ ÿÿ  ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Binary file not shown.
Binary file not shown.
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
//Generate "Stadium.GRA.Z" from "Stadium.TXT.Z"
U0 StadiumGen()
{
U0 (*fp_old_update)(CDC *dc);
CDC *dc,*dc2;
WinMax;
WinBorder;
WordStat;
DocClear;
Type("::/Demo/Games/Stadium/Stadium.TXT");
"$$CM,0,%d$$",TEXT_ROWS-3;
DocCursor(OFF);
fp_old_update=fp_final_screen_update; //hide mouse cursor
fp_final_screen_update=NULL;
WinMgrSync(2,TRUE);
dc2=DCCaptureScreen;
dc=DCExtract(dc2,0,FONT_HEIGHT,GR_WIDTH,GR_HEIGHT);
DCDel(dc2);
GRAWrite("::/Demo/Games/Stadium/Stadium",dc);
DCDel(dc);
DocCursor(ON);
fp_final_screen_update=fp_old_update;
DocClear;
}
StadiumGen;
Binary file not shown.
+130
View File
@@ -0,0 +1,130 @@
I8 board [9];
I64 board_x[9]={150,250,350,150,250,350,150,250,350};
I64 board_y[9]={150,150,150,250,250,250,350,350,350};
U0 DrawX(CDC *dc,I64 x,I64 y)
{
dc->pen_width=5;
GrLine3(dc,x-20,y-20,0,x+20,y+20,0);
GrLine3(dc,x+20,y-20,0,x-20,y+20,0);
}
U0 DrawO(CDC *dc,I64 x,I64 y)
{
dc->pen_width=5;
GrCircle3(dc,x,y,0,25);
}
U0 DrawBoard(I64 player)
{
I64 i;
CDC *dc=DCAlias;
DCFill;
dc->pen_width=5;
GrLine3(dc,200,100,0,200,400,0);
GrLine3(dc,300,100,0,300,400,0);
GrLine3(dc,100,200,0,400,200,0);
GrLine3(dc,100,300,0,400,300,0);
for (i=0;i<9;i++)
switch (board[i]) {
case 1:
DrawX(dc,board_x[i],board_y[i]);
break;
case 2:
DrawO(dc,board_x[i],board_y[i]);
break;
}
/*
ipx,ipy are input pointer (mouse) x,y.
ip_lb is mouse left button
*/
if (player==1)
DrawX(dc,ipx-Fs->pix_left,ipy-Fs->pix_top);
else
DrawO(dc,ipx-Fs->pix_left,ipy-Fs->pix_top);
DCDel(dc);
}
U0 TakeTurn(I64 player)
{
I64 i,x=0,y=0;
while (!(100<=x<400) || !(100<=y<400) || board[i]) {
if (player==1)
Beep(500);
else
Beep(1000);
while (!ip_lb) {
DrawBoard(player);
WinMgrSync;
}
while (ip_lb) {
DrawBoard(player);
WinMgrSync;
}
x=ipx-Fs->pix_left;
y=ipy-Fs->pix_top;
i=(x-100)/100+(y-100)/100*3;
}
board[i]=player;
}
Bool CheckWinner(I64 player)
{
if ( player==board[0]==board[1]==board[2] ||
player==board[3]==board[4]==board[5] ||
player==board[6]==board[7]==board[8] ||
player==board[0]==board[3]==board[6] ||
player==board[1]==board[4]==board[7] ||
player==board[2]==board[5]==board[8] ||
player==board[0]==board[4]==board[8] ||
player==board[2]==board[4]==board[6] )
return TRUE;
else
return FALSE;
}
U0 DoGame()
{
I64 moves=0;
MemSet(board,0,sizeof(board));
while (TRUE) {
TakeTurn(1);
if (CheckWinner(1)) {
Beep(500);
Beep(500);
Beep(500);
break;
}
if (++moves==9) break;
TakeTurn(2);
if (CheckWinner(2)) {
Beep(1000);
Beep(1000);
Beep(1000);
break;
}
if (++moves==9) break;
}
}
U0 TicTacToe()
{
WinMax; //Maximize window
DocClear; //Clear window text.
"$$GREEN$$CTRL-ALT-C$$FG$$ to exit.\n";
try
while (TRUE)
DoGame;
catch
PutExcept;
DCFill;
}
TicTacToe;
+611
View File
@@ -0,0 +1,611 @@
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
AcctRegSetDftEntry("TempleOS/Varoom","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/Varoom");
F64 distance,t0,tf;
Bool game_over;
#define NUM_BUSHES 512
class Bush
{
CD3I32 p;
Bool sym,pad[3];
U8 *img;
} b[NUM_BUSHES];
#define NUM_CARS 8
class Car
{
CD3I32 p;
F64 é,speed;
CSprite *img;
} c[NUM_CARS];
#define TRACK_INNER 16000
#define TRACK_OUTER 18000
#define SHOULDER 200
#define SLICES 500
#define D_é (2*ã/SLICES)
#define TRACK_POLYS (3*SLICES)
#define DIPS 5
#define DIP_DEPTH 100
class TrackPoly
{
CColorROPU16 c,pad[3];
CD3I32 p[4];
} track[TRACK_POLYS];
I64 DipY(I64 x,I64 z)
{
F64 m,a;
R2P(&m,&a,x,z);
return DIP_DEPTH*m*Cos(DIPS*a)/((TRACK_INNER+TRACK_OUTER)/2);
}
#define CAR_LENGTH 400
F64 Dipé(I64 x,I64 z,F64 é)
{
F64 y_front,y_back;
y_front=DipY(x-CAR_LENGTH/2*Cos(é),z-CAR_LENGTH/2*Sin(é));
y_back =DipY(x+CAR_LENGTH/2*Cos(é),z+CAR_LENGTH/2*Sin(é));
return ASin((y_front-y_back)/CAR_LENGTH);
}
U0 InitTrackPoly(TrackPoly *tempt,CColorROPU16 c,
I64 inner,I64 outer,F64 é1,F64 é2)
{
tempt->c=c;
tempt->p[0].x=inner*Cos(é1);
tempt->p[0].z=inner*Sin(é1);
tempt->p[0].y=DipY(tempt->p[0].x,tempt->p[0].z);
tempt->p[1].x=outer*Cos(é1);
tempt->p[1].z=outer*Sin(é1);
tempt->p[1].y=DipY(tempt->p[1].x,tempt->p[1].z);
tempt->p[2].x=outer*Cos(é2);
tempt->p[2].z=outer*Sin(é2);
tempt->p[2].y=DipY(tempt->p[2].x,tempt->p[2].z);
tempt->p[3].x=inner*Cos(é2);
tempt->p[3].z=inner*Sin(é2);
tempt->p[3].y=DipY(tempt->p[3].x,tempt->p[3].z);
}
U0 InitTrack()
{
TrackPoly *tempt=track;
I64 i;
for (i=0;i<SLICES;i++) {
InitTrackPoly(tempt++,DKGRAY,TRACK_INNER,TRACK_OUTER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
if (i&1) {
InitTrackPoly(tempt++,RED,TRACK_INNER-SHOULDER,TRACK_INNER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
InitTrackPoly(tempt++,WHITE,TRACK_OUTER,TRACK_OUTER+SHOULDER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
} else {
InitTrackPoly(tempt++,WHITE,TRACK_INNER-SHOULDER,TRACK_INNER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
InitTrackPoly(tempt++,RED,TRACK_OUTER,TRACK_OUTER+SHOULDER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
}
}
}
#define HORIZON_DIP 200
I64 mp_not_done_flags;
U0 MPUpdateWin(CDC *dc2)
{
CTask *task=dc2->win_task;
I64 i,j,x,y,z,lo,hi,
w=task->pix_width,
h=task->pix_height,r[16],
cx=w>>1;
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc;
Bool draw;
CD3I32 poly[4];
TrackPoly *tempt;
CDC *dc=DCAlias(gr_dc2,task);
GrIdentEqu(r);
GrRotYEqu(r,ã-c[0].é);
GrRotXEqu(r,75*ã/180-dip_é);
dc->depth_buf=dc2->depth_buf;
//Track
lo=Gs->num*TRACK_POLYS/mp_cnt;
hi=(Gs->num+1)*TRACK_POLYS/mp_cnt;
for (i=lo,tempt=&track[lo];i<hi;i++,tempt++) {
dc->color=tempt->c;
draw=TRUE;
for (j=0;j<4;j++) {
x=tempt->p[j].x-c[0].p.x; y=tempt->p[j].y-c[0].p.y; z=tempt->p[j].z-c[0].p.z;
GrRot(r,&x,&y,&z);
s=100.0/(AbsI64(z)+50);
poly[j].y=s*y+h;
if (z<-200 || !(-h<poly[j].y<2*h)) {
draw=FALSE;
break;
}
poly[j].x=s*x+cx;
poly[j].z=z+GR_Z_ALL;
}
if (draw)
GrFillPoly3(dc,4,poly);
}
dc->flags|=DCF_TRANSFORMATION;
for (i=Gs->num;i<NUM_BUSHES;i+=mp_cnt) {
x=b[i].p.x-c[0].p.x; y=b[i].p.y-c[0].p.y; z=b[i].p.z-c[0].p.z;
GrRot(r,&x,&y,&z);
if (z>0) {
s=100.0/(AbsI64(z)+50);
GrIdentEqu(dc->r);
GrScaleEqu(dc->r,s*2);
GrSetRotMat(dc,dc->r);
if (b[i].sym) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
GrSetSymmetry(dc,s*x+cx,s*y+h,s*x+cx,s*y+h+10);
}
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,b[i].img);
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
}
}
for (i=Gs->num+1;i<NUM_CARS;i+=mp_cnt) {
tempc=&c[i];
x=tempc->p.x-c[0].p.x; y=tempc->p.y-c[0].p.y; z=tempc->p.z-c[0].p.z;
GrRot(r,&x,&y,&z);
if (z>0) {
s=100.0/(AbsI64(z)+50);
GrIdentEqu(dc->r);
GrScaleEqu(dc->r,s*2);
GrRotXEqu(dc->r,Dipé(tempc->p.x,tempc->p.z,-tempc->é));
GrRotYEqu(dc->r,tempc->é-c[0].é);
GrSetRotMat(dc,dc->r);
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,tempc->img);
}
}
dc->depth_buf=NULL;
DCDel(dc);
LBtr(&mp_not_done_flags,Gs->num);
}
U0 VRTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
{
I64 zz;
GrRot(dc->r,x,y,z);
zz=400+*z;
if (zz<1) zz=1;
*x=400* *x/zz;
*y=400* *y/zz;
*x+=dc->x;
*y+=dc->y;
*z+=dc->z;
}
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,x,y,z,
w=task->pix_width,
h=task->pix_height,r[16],
cx=w>>1;
F64 s,è,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
dc->color=LTCYAN;
GrRect(dc,0,0,w,HORIZON_DIP*Sin(dip_é)+FONT_HEIGHT*4.5);
GrIdentEqu(r);
GrRotYEqu(r,ã-c[0].é);
GrRotXEqu(r,75*ã/180-dip_é);
DCAllocDepthBuf(dc);
//Sun
x=c[0].p.x; y=0; z=1000000-c[0].p.z;
GrRot(r,&x,&y,&z);
s=100.0/(AbsI64(z)+50);
if (y<0) {
dc->color=BROWN;
GrCircle(dc,s*x+cx,15+HORIZON_DIP*Sin(dip_é),15);
dc->color=YELLOW;
GrFloodFill(dc,s*x+cx,15+HORIZON_DIP*Sin(dip_é));
}
mp_not_done_flags=1<<mp_cnt-1;
for (i=0;i<mp_cnt;i++)
JobQue(&MPUpdateWin,dc,i);
while (mp_not_done_flags)
Yield;
if (Bt(key_down_bitmap,SC_CURSOR_LEFT))
è=-0.5;
else if (Bt(key_down_bitmap,SC_CURSOR_RIGHT))
è=0.5;
else
è=0;
GrIdentEqu(r);
GrRotYEqu(r,è);
GrRotXEqu(r,0.4-8*dip_é); //Made this up
dc->transform=&VRTransform;
dc->x=task->pix_width>>1;
dc->y=task->pix_height-150;
dc->z=GR_Z_ALL;
SpriteMat3B(dc,0,0,-100,c[0].img,r);
//Map
dc->color=LTGRAY;
GrRect(dc,w-64,h-64,64,64);
dc->color=LTGREEN;
for (i=0;i<NUM_BUSHES;i++)
GrPlot(dc,w-64+64*(0x5000-b[i].p.x)/0xA000,h-64*(-b[i].p.z+0x5000)/0xA000);
dc->pen_width=2;
for (i=0;i<NUM_CARS;i++) {
if (i)
dc->color=LTPURPLE;
else
dc->color=LTCYAN;
GrPlot3(dc,w-64+64*(0x5000-c[i].p.x)/0xA000,h-64*(-c[i].p.z+0x5000)/0xA000,0);
}
if (game_over) {
dc->color=LTRED;
if (tf) {
s=tf-t0;
if (Blink)
GrPrint(dc,(w-FONT_WIDTH*14)/2,(h-FONT_HEIGHT)/2,"Game Completed");
} else {
s=99.9;
if (Blink)
GrPrint(dc,(w-FONT_WIDTH*9)/2,(h-FONT_HEIGHT)/2,"Game Over");
}
} else
s=tS-t0;
dc->color=BLACK;
GrPrint(dc,0,0,"é:%0.1f %0.1f%% Time:%0.2f Best:%0.2f",
180+180/ã*Arg(c[0].p.x,c[0].p.z),100.0*distance/(2*ã*TRACK_INNER),s,best_score);
}
U0 AnimateTask(I64)
{
Car *tempc;
I64 i;
F64 m,a;
while (TRUE) {
if (!game_over)
Snd(c[0].speed*3+10);
else
Snd(0);
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
tempc->p.x-=tempc->speed*Cos(tempc->é-ã/2);
tempc->p.z+=tempc->speed*Sin(tempc->é-ã/2);
if (i) {
tempc->é=Arg(-tempc->p.x,tempc->p.z);
tempc->p.x=-(TRACK_INNER+TRACK_OUTER)/2*Cos(tempc->é);
tempc->p.z= (TRACK_INNER+TRACK_OUTER)/2*Sin(tempc->é);
}
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
}
R2P(&m,&a,c[0].p.x,c[0].p.z);
if (!game_over && TRACK_INNER<=m<=TRACK_OUTER) {
for (i=1;i<NUM_CARS;i++)
if (D3I32SqrDist(&c[i].p,&c[0].p)<CAR_LENGTH*CAR_LENGTH>>1) {
game_over=TRUE;
Noise(500,50,100);
Sleep(500);
break;
}
if (!game_over) {
distance+=c[0].speed;
if (distance>2*ã*TRACK_INNER && Wrap(a+ã,-ã)>0.0) {
tf=tS;
game_over=TRUE;
Beep;
if (tf-t0<best_score) {
best_score=tf-t0;
Beep;
}
}
}
}
Sleep(10);
}
}
CSprite *imgs[8]={$IB,"<1>",BI=1$,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"<2>",BI=2$,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$,$IB,"<4>",BI=4$,$IB,"<4>",BI=4$};
U0 Init()
{
Bush *tempb;
Car *tempc;
I64 i;
for (i=0;i<NUM_BUSHES;i++) {
tempb=&b[i];
do {
tempb->p.x=RandU32&0x7FFF-0x4000;
tempb->p.z=RandU32&0x7FFF-0x4000;
} while (TRACK_INNER-SHOULDER<=
Sqrt(SqrI64(tempb->p.x)+SqrI64(tempb->p.z))<=TRACK_OUTER+SHOULDER);
tempb->p.y=DipY(tempb->p.x,tempb->p.z);
tempb->sym=RandU16&1;
tempb->img=imgs[i&7];
}
InitTrack;
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
if (i==0) {
tempc->img=$IB,"<5>",BI=5$;
tempc->speed=0;
} else {
tempc->img=$IB,"<6>",BI=6$;
tempc->speed=50.0;
}
tempc->é=i*2*ã/NUM_CARS;
tempc->p.x=-(TRACK_INNER+TRACK_OUTER)/2*Cos(tempc->é);
tempc->p.z= (TRACK_INNER+TRACK_OUTER)/2*Sin(tempc->é);
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
}
distance=0;
tf=0;
t0=tS;
game_over=FALSE;
}
U0 Varoom()
{
I64 ch,sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Accelerator(,,SC_CURSOR_UP);"
" Break(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
SettingsPush(Fs,TSF_SAME_SONG); //See $LK,"SettingsPush",A="MN:SettingsPush"$
try {
Fs->text_attr=YELLOW<<4+BLUE;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_GRAB_SCROLL-WIF_MENU;
WordStat;
WinMax;
WinBorder;
Preempt(OFF);
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
while (TRUE) {
while (ScanKey(&ch,&sc))
switch (ch) {
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_LEFT:
c[0].é-=ã/100;
break;
case SC_CURSOR_RIGHT:
c[0].é+=ã/100;
break;
case SC_CURSOR_UP:
c[0].speed+=3;
break;
case SC_CURSOR_DOWN:
c[0].speed-=3;
break;
}
break;
case '\n':
Init;
break;
case CH_SHIFT_ESC:
case CH_ESC:
goto vr_done;
}
WinMgrSync;
}
vr_done: //Don't goto out of try
} catch
Fs->catch_except=TRUE;
SettingsPop(Fs,TSF_SAME_SONG);
MenuPop;
AcctRegWriteBranch("TempleOS/Varoom","F64 best_score=%5.4f;\n",best_score);
}
Varoom;
ö
þÿÿÿèÿÿÿ
ôÿÿÿêÿÿÿ
þÿÿÿîÿÿÿúÿÿÿèÿÿÿ
øÿÿÿúÿÿÿôÿÿÿ
ôÿÿÿìÿÿÿ
âÿÿÿúÿÿÿèÿÿÿ
àÿÿÿ
ìÿÿÿ
îÿÿÿàÿÿÿ
üÿÿÿîÿÿÿ
øÿÿÿâÿÿÿ
øÿÿÿ
öÿÿÿúÿÿÿþÿÿÿ
úÿÿÿüÿÿÿÜÿÿÿ
úÿÿÿðÿÿÿúÿÿÿäÿÿÿã
æÿÿÿöÿÿÿäÿÿÿ
ìÿÿÿìÿÿÿæÿÿÿüÿÿÿ
äÿÿÿÖÿÿÿ
Öÿÿÿæÿÿÿ
æÿÿÿ"àÿÿÿ
êÿÿÿ$äÿÿÿ
ìÿÿÿ$æÿÿÿ
äÿÿÿúÿÿÿäÿÿÿúÿÿÿ
æÿÿÿüÿÿÿæÿÿÿüÿÿÿ
îÿÿÿúÿÿÿ êÿÿÿ
"Üÿÿÿ&æÿÿÿ
äÿÿÿ àÿÿÿ
þÿÿÿ
üÿÿÿ
üÿÿÿðÿÿÿ
êÿÿÿ øÿÿÿ
øÿÿÿèÿÿÿ
èÿÿÿþÿÿÿ
þÿÿÿîÿÿÿ
ìÿÿÿþÿÿÿ
þÿÿÿîÿÿÿ
öÿÿÿ ìÿÿÿ
êÿÿÿðÿÿÿ
ðÿÿÿäÿÿÿ
âÿÿÿðÿÿÿ
ðÿÿÿêÿÿÿ
êÿÿÿúÿÿÿ
 öÿÿÿ”
úÿÿÿÄÿÿÿ
úÿÿÿÄÿÿÿøÿÿÿúÿÿÿ
üÿÿÿÂÿÿÿüÿÿÿ
úÿÿÿÄÿÿÿæÿÿÿ¤ÿÿÿ
üÿÿÿÂÿÿÿäÿÿÿ¤ÿÿÿ
øÿÿÿ¼ÿÿÿúÿÿÿ†ÿÿÿ
Äÿÿÿüÿÿÿ„ÿÿÿ
þÿÿÿºÿÿÿ
Œÿÿÿ
Œÿÿÿüÿÿÿ¸ÿÿÿ
¦ÿÿÿšÿÿÿ
šÿÿÿzÿÿÿ
zÿÿÿ„ÿÿÿ
†ÿÿÿžÿÿÿ
žÿÿÿvÿÿÿ
vÿÿÿþÿÿÿ`ÿÿÿ
þÿÿÿ`ÿÿÿìÿÿÿ„ÿÿÿ
ìÿÿÿ„ÿÿÿöÿÿÿ¬ÿÿÿ
öÿÿÿ¬ÿÿÿâÿÿÿžÿÿÿ
âÿÿÿžÿÿÿØÿÿÿ¨ÿÿÿ
Øÿÿÿ¨ÿÿÿîÿÿÿºÿÿÿ
îÿÿÿºÿÿÿòÿÿÿºÿÿÿ
ôÿÿÿ¸ÿÿÿúÿÿÿ¸ÿÿÿ
–ÿÿÿˆÿÿÿ
„ÿÿÿŠÿÿÿ
þÿÿÿŽÿÿÿþÿÿÿjÿÿÿ
þÿÿÿjÿÿÿôÿÿÿ‚ÿÿÿ
ôÿÿÿ‚ÿÿÿøÿÿÿœÿÿÿ
ôÿÿÿ´ÿÿÿîÿÿÿ¦ÿÿÿ
èÿÿÿ²ÿÿÿÞÿÿÿ¦ÿÿÿ
œÿÿÿ–ÿÿÿ
øÿÿÿ€ÿÿÿhÿÿÿ
ˆÿÿÿ€ÿÿÿ
þÿÿÿ~ÿÿÿnÿÿÿ
~ÿÿÿ’ÿÿÿ
œÿÿÿ¨ÿÿÿ
öÿÿÿ²ÿÿÿðÿÿÿ‚ÿÿÿ
ðÿÿÿ‚ÿÿÿúÿÿÿjÿÿÿ
êÿÿÿ´ÿÿÿÞÿÿÿ ÿÿÿJ␍`ŒFçÿÿÿ}-çÿÿÿ}-çÿÿÿKFçÿÿÿK7ýÿÿÿ‡7ýÿÿÿ–ýÿÿÿ–(ýÿÿÿ‡(ýÿÿÿA7ýÿÿÿA7ýÿÿÿýÿÿÿF}-}-KFK7‡7––(‡(A7A7ºÿÿÿçÿÿÿ}Óÿÿÿçÿÿÿ}ÓÿÿÿçÿÿÿKºÿÿÿçÿÿÿKÉÿÿÿýÿÿÿ‡Éÿÿÿýÿÿÿ–ýÿÿÿ–Øÿÿÿýÿÿÿ‡ØÿÿÿýÿÿÿAÉÿÿÿýÿÿÿAÉÿÿÿýÿÿÿýÿÿÿºÿÿÿ}Óÿÿÿ}ÓÿÿÿKºÿÿÿKÉÿÿÿ‡Éÿÿÿ––Øÿÿÿ‡ØÿÿÿAÉÿÿÿAÉÿÿÿFçÿÿÿƒÿÿÿ-çÿÿÿƒÿÿÿ-çÿÿÿµÿÿÿFçÿÿÿµÿÿÿ7áÿÿÿyÿÿÿ7áÿÿÿjÿÿÿáÿÿÿjÿÿÿ(áÿÿÿyÿÿÿ(áÿÿÿ¿ÿÿÿ7áÿÿÿ¿ÿÿÿ7ýÿÿÿýÿÿÿFƒÿÿÿ-ƒÿÿÿ-µÿÿÿFµÿÿÿ7yÿÿÿ7jÿÿÿjÿÿÿ(yÿÿÿ(¿ÿÿÿ7¿ÿÿÿ7ºÿÿÿçÿÿÿƒÿÿÿÓÿÿÿçÿÿÿƒÿÿÿÓÿÿÿçÿÿÿµÿÿÿºÿÿÿçÿÿÿµÿÿÿÉÿÿÿáÿÿÿyÿÿÿÉÿÿÿáÿÿÿjÿÿÿáÿÿÿjÿÿÿØÿÿÿáÿÿÿyÿÿÿØÿÿÿáÿÿÿ¿ÿÿÿÉÿÿÿáÿÿÿ¿ÿÿÿÉÿÿÿýÿÿÿýÿÿÿºÿÿÿƒÿÿÿÓÿÿÿƒÿÿÿÓÿÿÿµÿÿÿºÿÿÿµÿÿÿÉÿÿÿyÿÿÿÉÿÿÿjÿÿÿjÿÿÿØÿÿÿyÿÿÿØÿÿÿ¿ÿÿÿÉÿÿÿ¿ÿÿÿÉÿÿÿ ␍ ␍   ␍␍
    
$%&&'$%$$$'$%%&&'&#!"!# #     /-.-/,/*,,*++)(+*)+(+ + +(!.-.!" + + ,*)*<=>>?<1033211=<<01<?330<1=2=>2>233?>;9:9;8867754765GEFEGDGBDDBCCA@CBA4C@C474C7C4@9FEF9:8C7C8D5BAB56TUVVWTIHKKJIIUTTHITWKKHTIUJUVJVJKKWVSRQQPSPONOLMOMN_^]]\__\Z\[Z[XY[YZLX[[OLLO[[XLQ]^^RQPO[[\PMYZZNM P88P654@@A5LMYYXLJ␍`ŒFçÿÿÿ}-çÿÿÿ}-çÿÿÿKFçÿÿÿK7ýÿÿÿ‡7ýÿÿÿ–ýÿÿÿ–(ýÿÿÿ‡(ýÿÿÿA7ýÿÿÿA7ýÿÿÿýÿÿÿF}-}-KFK7‡7––(‡(A7A7ºÿÿÿçÿÿÿ}Óÿÿÿçÿÿÿ}ÓÿÿÿçÿÿÿKºÿÿÿçÿÿÿKÉÿÿÿýÿÿÿ‡Éÿÿÿýÿÿÿ–ýÿÿÿ–Øÿÿÿýÿÿÿ‡ØÿÿÿýÿÿÿAÉÿÿÿýÿÿÿAÉÿÿÿýÿÿÿýÿÿÿºÿÿÿ}Óÿÿÿ}ÓÿÿÿKºÿÿÿKÉÿÿÿ‡Éÿÿÿ––Øÿÿÿ‡ØÿÿÿAÉÿÿÿAÉÿÿÿFçÿÿÿƒÿÿÿ-çÿÿÿƒÿÿÿ-çÿÿÿµÿÿÿFçÿÿÿµÿÿÿ7áÿÿÿyÿÿÿ7áÿÿÿjÿÿÿáÿÿÿjÿÿÿ(áÿÿÿyÿÿÿ(áÿÿÿ¿ÿÿÿ7áÿÿÿ¿ÿÿÿ7ýÿÿÿýÿÿÿFƒÿÿÿ-ƒÿÿÿ-µÿÿÿFµÿÿÿ7yÿÿÿ7jÿÿÿjÿÿÿ(yÿÿÿ(¿ÿÿÿ7¿ÿÿÿ7ºÿÿÿçÿÿÿƒÿÿÿÓÿÿÿçÿÿÿƒÿÿÿÓÿÿÿçÿÿÿµÿÿÿºÿÿÿçÿÿÿµÿÿÿÉÿÿÿáÿÿÿyÿÿÿÉÿÿÿáÿÿÿjÿÿÿáÿÿÿjÿÿÿØÿÿÿáÿÿÿyÿÿÿØÿÿÿáÿÿÿ¿ÿÿÿÉÿÿÿáÿÿÿ¿ÿÿÿÉÿÿÿýÿÿÿýÿÿÿºÿÿÿƒÿÿÿÓÿÿÿƒÿÿÿÓÿÿÿµÿÿÿºÿÿÿµÿÿÿÉÿÿÿyÿÿÿÉÿÿÿjÿÿÿjÿÿÿØÿÿÿyÿÿÿØÿÿÿ¿ÿÿÿÉÿÿÿ¿ÿÿÿÉÿÿÿ ␍ ␍   ␍␍
  
$%&&'$%$$$'$%%&&'&#!"!# #   /-.-/,/*,,*++)(+*)+(+ + +(!.-.!" + + ,*)*<=>>?<1033211=<<01<?330<1=2=>2>233?>;9:9;8867754765GEFEGDGBDDBCCA@CBA4C@C474C7C4@9FEF9:8C7C8D5BAB56TUVVWTIHKKJIIUTTHITWKKHTIUJUVJVJKKWVSRQQPSPONOLMOMN_^]]\__\Z\[Z[XY[YZLX[[OLLO[[XLQ]^^RQPO[[\PMYZZNM P88P654@@A5LMYYXL
+643
View File
@@ -0,0 +1,643 @@
AcctRegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/Wenceslas");
#define BORDER 5
#define KING_STEP 4
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
$SP,"<7>",BI=7$
#define NUM_FLAKES 0x8000
class Flake
{
U16 x,y;
} flakes[NUM_FLAKES];
#define NUM_TREES 8
class Tree
{
U16 x,y;
I64 fire_frame_index;
} trees[NUM_TREES];
I64 snow_x,snow_y;
I64 king_x,king_y,not_stopped_cnt;
F64 king_é,t0,tf,door_open_t0;
#define NUM_PEASANTS 16
class Peasant
{
Peasant *next,*last;
F64 x,y,é,door_opened_t0;
Bool stopped;
} peasant_root;
class Step
{
Step *next,*last;
U16 x,y;
F64 t0;
} step_root,king_step_root;
U0 DrawIt(CTask *task,CDC *dc)
{
I64 r[16],i,w=task->pix_width,h=task->pix_height;
U8 *img;
Step *temps;
Peasant *tempp;
F64 tt;
Bool old_preempt=Preempt(OFF);
dc->pen_width=1;
for (i=0;i<NUM_TREES;i++) {
if (trees[i].y<=h/2) { //Draw trees behind house
if (trees[i].fire_frame_index) {
if (trees[i].fire_frame_index++&1)
img=$IB,"<4>",BI=4$;
else
img=$IB,"<5>",BI=5$;
} else
img=$IB,"<3>",BI=3$;
Sprite3(dc,trees[i].x,trees[i].y,0,img);
}
}
Sprite3(dc,w/2,h/2,0,$IB,"<6>",BI=6$);
if (tS<door_open_t0+1.0)
Sprite3(dc,w/2,h/2,0,$IB,"<7>",BI=7$);
for (i=0;i<NUM_TREES;i++) {
if (trees[i].y>h/2) { //Draw trees in front of house
if (trees[i].fire_frame_index) {
if (trees[i].fire_frame_index++&1)
img=$IB,"<4>",BI=4$;
else
img=$IB,"<5>",BI=5$;
} else
img=$IB,"<3>",BI=3$;
Sprite3(dc,trees[i].x,trees[i].y,0,img);
}
}
temps=step_root.next;
while (temps!=&step_root) {
if (tS-temps->t0<2.0)
dc->color=DKGRAY;
else
dc->color=LTGRAY;
dc->pen_width=2;
GrPlot3(dc,temps->x,temps->y,0);
temps=temps->next;
}
dc->pen_width=1;
tempp=peasant_root.next;
while (tempp!=&peasant_root) {
GrIdentEqu(r);
GrRotYEqu(r,tempp->é+ã/2);
GrRotXEqu(r,ã/6);
if (tempp->stopped)
dc->color=LTCYAN;
else
dc->color=CYAN;
SpriteMat3B(dc,tempp->x,tempp->y,0,$IB,"<2>",BI=2$,r);
tempp=tempp->next;
}
dc->pen_width=1;
GrIdentEqu(r);
GrRotYEqu(r,king_é+ã/2);
GrRotXEqu(r,ã/6);
SpriteMat3B(dc,king_x,king_y,0,$IB,"<1>",BI=1$,r);
dc->pen_width=1;
dc->color=WHITE;
for (i=0;i<NUM_FLAKES;i++)
GrPlot(dc,(flakes[i].x+snow_x)%task->pix_width,
(flakes[i].y+snow_y)%task->pix_height);
if (tf) {
dc->color=LTRED;
if (Blink)
GrPrint(dc,w/2-(FONT_WIDTH*14)/2,h/2+FONT_HEIGHT,"Game Completed");
tt=tf;
} else {
tt=tS;
}
dc->color=LTBLUE;
GrPrint(dc,0,0,"Freezing Peasants:%d Time:%3.2f Best:%3.2f",
not_stopped_cnt,tt-t0,best_score);
Preempt(old_preempt);
}
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool king)
{
Step *temps;
if (king) {
temps=MAlloc(sizeof(Step),task);
temps->x=x;
temps->y=y;
temps->t0=tS;
QueIns(temps,king_step_root.last);
}
temps=MAlloc(sizeof(Step),task);
temps->x=x-3.5*Sin(é)+1.0*Cos(é);
temps->y=y+3.5*Cos(é)+1.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_root.last);
temps=MAlloc(sizeof(Step),task);
temps->x=x+3.5*Sin(é)-1.0*Cos(é);
temps->y=y-3.5*Cos(é)-1.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_root.last);
}
U0 Init()
{
I64 i,min_x,max_x,min_y,max_y,
w=Fs->pix_width,h=Fs->pix_height;
Peasant *tempp;
snow_x=0;
snow_y=0;
for (i=0;i<NUM_FLAKES;i++) {
flakes[i].x=RandU16;
flakes[i].y=RandU16;
}
SpriteExtents($IB,"<3>",BI=3$,&min_x,&max_x,&min_y,&max_y);
for (i=0;i<NUM_TREES;i++) {
trees[i].x=RandU16%(w-2*BORDER-(max_x-min_x+1))+BORDER-min_x;
trees[i].y=RandU16%(h-2*BORDER-(max_y-min_y+1))+BORDER-min_y;
trees[i].fire_frame_index=0;
}
QueInit(&step_root);
QueInit(&king_step_root);
SpriteExtents($IB,"<1>",BI=1$,&min_x,&max_x,&min_y,&max_y);
QueInit(&peasant_root);
for (i=0;i<NUM_PEASANTS;i++) {
tempp=MAlloc(sizeof(Peasant));
tempp->x=RandU16%(w-2*BORDER-(max_x-min_x+1))+BORDER-min_x;
tempp->y=RandU16%(h-2*BORDER-(max_y-min_y+1))+BORDER-min_y;
tempp->é=ã*2*Rand;
tempp->door_opened_t0=0;
tempp->stopped=FALSE;
QueIns(tempp,peasant_root.last);
}
king_x=w/2;
king_y=h/2;
king_é=-ã/2;
door_open_t0=0;
t0=tS;
tf=0;
}
U0 CleanUp()
{
QueDel(&peasant_root,TRUE);
QueDel(&step_root,TRUE);
QueDel(&king_step_root,TRUE);
}
U0 Follow(CTask *,Peasant *tempp)
{
Step *temps=king_step_root.next;
F64 d,best_d=MAX_F64;
while (temps!=&king_step_root) {
if ((d=Sqr(temps->x-tempp->x)+Sqr(temps->y-tempp->y)) &&
d<15*15) {
d+=1000*Sqr(tS-temps->t0);
if (d<best_d) {
best_d=d;
tempp->é=Arg(temps->x-tempp->x,temps->y-tempp->y);
}
}
temps=temps->next;
}
}
U0 AnimateTask(I64)
{//preempt off by default after Spawned
Step *temps,*temps1;
Peasant *tempp;
I64 i,animate_cnt=0,w,h;
while (TRUE) {
w=Fs->parent_task->pix_width;
h=Fs->parent_task->pix_height;
temps=step_root.next;
while (temps!=&step_root) {
temps1=temps->next;
if (tS-temps->t0>4.0) {
QueRem(temps);
Free(temps);
}
temps=temps1;
}
temps=king_step_root.next;
while (temps!=&king_step_root) {
temps1=temps->next;
if (tS-temps->t0>4.0) {
QueRem(temps);
Free(temps);
}
temps=temps1;
}
not_stopped_cnt=0;
tempp=peasant_root.next;
while (tempp!=&peasant_root) {
if (tempp->stopped) {
if (tempp->door_opened_t0 && tS>tempp->door_opened_t0+1.0) {
tempp->door_opened_t0=0;
tempp->y=tempp->x=-9999;
}
} else {
if (Sqr(tempp->x-w/2)+Sqr(tempp->y-h/2)<20*20) {
tempp->stopped=TRUE;
tempp->door_opened_t0=door_open_t0=tS;
}
for (i=0;i<NUM_TREES;i++) //Hang-out by fire
if (trees[i].fire_frame_index && Sqr(tempp->x-trees[i].x)+Sqr(tempp->y-trees[i].y)<20*20) {
tempp->stopped=TRUE;
break;
}
if (!tempp->stopped) {
Follow(Fs->parent_task,tempp);
tempp->x+=Cos(tempp->é)/100;
tempp->y+=Sin(tempp->é)/100;
if (!(BORDER/2<=tempp->x<w-BORDER/2) || !(BORDER/2<=tempp->y<h-BORDER/2)) {
tempp->é+=ã;
tempp->x+=3*Cos(tempp->é)/100;
tempp->y+=3*Sin(tempp->é)/100;
}
if (!(animate_cnt&511))
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,FALSE);
not_stopped_cnt++;
}
}
tempp=tempp->next;
}
if (!not_stopped_cnt && !tf) {
tf=tS;
music_mute=TRUE;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
if (tf-t0<best_score) {
best_score=tf-t0;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
}
music_mute=FALSE;
}
snow_x+=RandU16%3-1;
snow_y+=1-SignI64(RandU16&3);
Sleep(1);
animate_cnt++;
}
}
U0 BurnTrees()
{
I64 i;
for (i=0;i<NUM_TREES;i++)
if (Sqr(king_x-trees[i].x)+Sqr(king_y-trees[i].y)<10*10)
trees[i].fire_frame_index=1;
}
U0 SongTask(I64)
{
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
music_tempo= 2.480;
music_stacatto_factor= 0.902;
while (TRUE) {
Play("3eCCCDCC2qG3eA2G3ABqCC");
Play("eCCCDCC2qG3eA2G3ABqCC");
Play("eGFEDEDqCeA2G3ABqCC");
}
}
U0 Wenceslas()
{
I64 sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" BurnTree(,CH_SPACE);"
" Up(,,SC_CURSOR_UP);"
" Down(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
Preempt(OFF);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
PopUpOk("
Good King Wenceslas looked out
On the feast of Stephen
When the snow lay round about
Deep and crisp and even
Brightly shone the moon that night
Though the frost was cruel
When a poor man came in sight
Gath'ring winter fuel
\"Hither, page, and stand by me
If thou know'st it, telling
Yonder peasant, who is he?
Where and what his dwelling?\"
\"Sire, he lives a good league hence
Underneath the mountain
Right against the forest fence
By Saint Agnes' fountain.\"
\"Bring me flesh and bring me wine
Bring me pine logs hither
Thou and I will see him dine
When we bear him thither.\"
Page and monarch forth they went
Forth they went together
Through the rude wind's wild lament
And the bitter weather
");
PopUpOk("
\"Sire, the night is darker now
And the wind blows stronger
Fails my heart, I know not how,
I can go no longer.\"
\"Mark my footsteps, my good page
Tread thou in them boldly
Thou shalt find the winter's rage
Freeze thy blood less coldly.\"
In his master's steps he trod
Where the snow lay dinted
Heat was in the very sod
Which the Saint had printed
Therefore, Christian men, be sure
Wealth or rank possessing
Ye who now will bless the poor
Shall yourselves find blessing
");
PopUpOk("
$$PURPLE$$$$TX+CX,\"Winceslas Game\"$$$$FG$$
Start fires by pressing $$GREEN$$<SPACE BAR>$$FG$$
on trees. (Yule logs)
Lead peasants to fires.
");
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
WordStat;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (GetKey(&sc)) {
case '\n':
CleanUp;
Init;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto ws_done;
case CH_SPACE:
BurnTrees;
break;
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
if (king_x+KING_STEP<Fs->pix_width-BORDER)
king_x+=KING_STEP;
king_é=0;
StepNew(Fs,king_x,king_y,king_é,TRUE);
break;
case SC_CURSOR_LEFT:
if (king_x-KING_STEP>=BORDER)
king_x-=KING_STEP;
king_é=ã;
StepNew(Fs,king_x,king_y,king_é,TRUE);
break;
case SC_CURSOR_DOWN:
if (king_y+KING_STEP<Fs->pix_height-BORDER)
king_y+=KING_STEP;
king_é=-ã/2;
StepNew(Fs,king_x,king_y,king_é,TRUE);
break;
case SC_CURSOR_UP:
if (king_y-KING_STEP>=BORDER)
king_y-=KING_STEP;
king_é=ã/2;
StepNew(Fs,king_x,king_y,king_é,TRUE);
break;
}
}
}
ws_done:
} catch
PutExcept;
SettingsPop;
MenuPop;
CleanUp;
AcctRegWriteBranch("TempleOS/Wenceslas","F64 best_score=%5.4f;\n",best_score);
}
Wenceslas;
y
þÿÿÿÚÿÿÿ
Êÿÿÿ
þÿÿÿÚÿÿÿ äÿÿÿ
Öÿÿÿ
Ðÿÿÿ
úÿÿÿÖÿÿÿôÿÿÿìÿÿÿ
üÿÿÿØÿÿÿúÿÿÿðÿÿÿ
üÿÿÿðÿÿÿÖÿÿÿ
üÿÿÿÔÿÿÿòÿÿÿæÿÿÿ
ÒÿÿÿöÿÿÿÂÿÿÿ
þÿÿÿÔÿÿÿòÿÿÿ¼ÿÿÿ
þÿÿÿÎÿÿÿ ¼ÿÿÿ
þÿÿÿÔÿÿÿÊÿÿÿ
þÿÿÿØÿÿÿäÿÿÿ
ÚÿÿÿÀÿÿÿ
þÿÿÿÎÿÿÿ´ÿÿÿ
Êÿÿÿªÿÿÿ
ÿÿÿøÿÿÿÈÿÿÿ
²ÿÿÿ¬ÿÿÿ
Æÿÿÿ
ÿÿÿ
Ìÿÿÿ Ìÿÿÿ
üÿÿÿÔÿÿÿèÿÿÿÚÿÿÿ
Öÿÿÿ*
ðÿÿÿüÿÿÿ
ðÿÿÿ
ðÿÿÿèÿÿÿ
þÿÿÿòÿÿÿüÿÿÿæÿÿÿ
þÿÿÿæÿÿÿàÿÿÿ
þÿÿÿèÿÿÿüÿÿÿòÿÿÿ
æÿÿÿðÿÿÿ
þÿÿÿâÿÿÿàÿÿÿ
àÿÿÿÞÿÿÿ
Þÿÿÿâÿÿÿ
ÞÿÿÿÞÿÿÿ
ýÿÿÿäÿÿÿâÿÿÿ
þÿÿÿäÿÿÿüÿÿÿèÿÿÿ
üÿÿÿèÿÿÿüÿÿÿòÿÿÿ
äÿÿÿêÿÿÿ
æÿÿÿþÿÿÿîÿÿÿ
ìÿÿÿòÿÿÿx
þÿÿÿèÿÿÿüÿÿÿòÿÿÿ
ðÿÿÿèÿÿÿ
ðÿÿÿüÿÿÿ
ðÿÿÿ
þÿÿÿòÿÿÿüÿÿÿæÿÿÿ
þÿÿÿæÿÿÿàÿÿÿ
æÿÿÿðÿÿÿã
öÿÿÿðÿÿÿ
øÿÿÿ
ôÿÿÿ
ðÿÿÿòÿÿÿ
îÿÿÿ
êÿÿÿ
öÿÿÿæÿÿÿ
úÿÿÿæÿÿÿöÿÿÿèÿÿÿ
øÿÿÿæÿÿÿ
æÿÿÿ
øÿÿÿîÿÿÿ
þÿÿÿòÿÿÿ 
þÿÿÿöÿÿÿ
ôÿÿÿîÿÿÿ
ðÿÿÿ
ðÿÿÿþÿÿÿ
üÿÿÿþÿÿÿäÿÿÿ
þÿÿÿäÿÿÿîÿÿÿ
äÿÿÿöÿÿÿöÿÿÿ
öÿÿÿðÿÿÿøÿÿÿ
üÿÿÿüÿÿÿðÿÿÿ
ðÿÿÿøÿÿÿ
úÿÿÿ
þÿÿÿúÿÿÿúÿÿÿ
ðÿÿÿüÿÿÿ
úÿÿÿ
üÿÿÿ
üÿÿÿøÿÿÿ
úÿÿÿøÿÿÿúÿÿÿðÿÿÿ
òÿÿÿìÿÿÿô
öÿÿÿðÿÿÿ
øÿÿÿ
ôÿÿÿ
ðÿÿÿòÿÿÿ
îÿÿÿ
êÿÿÿ
öÿÿÿæÿÿÿ
úÿÿÿæÿÿÿöÿÿÿèÿÿÿ
øÿÿÿæÿÿÿ
æÿÿÿ
øÿÿÿîÿÿÿ
þÿÿÿòÿÿÿ 
þÿÿÿöÿÿÿ
ôÿÿÿîÿÿÿ
äÿÿÿ
úÿÿÿâÿÿÿúÿÿÿ
èÿÿÿúÿÿÿöÿÿÿ
òÿÿÿîÿÿÿöÿÿÿúÿÿÿ
öÿÿÿøÿÿÿðÿÿÿ
öÿÿÿäÿÿÿôÿÿÿôÿÿÿ
üÿÿÿêÿÿÿþÿÿÿþÿÿÿ
üÿÿÿôÿÿÿ
ôÿÿÿöÿÿÿ
òÿÿÿâÿÿÿ
þÿÿÿ
úÿÿÿ
öÿÿÿ
òÿÿÿüÿÿÿ
øÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿ
üÿÿÿÒbŸžÎÿÿÿhÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLine truncated
+173
View File
@@ -0,0 +1,173 @@
#define NUM_BALLS 7
#define NUM_SPRINGS 3
#define STRETCH 500.0
#define GRAVITY 50.0 //not really gravity
#define BALL_RADIUS 5
#define BASE_SIZE 10
CMass balls[NUM_BALLS];
CSpring springs[NUM_SPRINGS];
F64 collision_t;
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,
cx=task->pix_width>>1,
cy=task->pix_height>>1;
Bool snd_on=FALSE;
dc->color=BLACK;
GrPrint(dc,0,0,"Protect your base.");
GrRect(dc,cx-BASE_SIZE,cy-BASE_SIZE,BASE_SIZE*2,BASE_SIZE*2);
dc->color=CYAN;
GrRect(dc,cx-BASE_SIZE+2,cy-BASE_SIZE+2,BASE_SIZE*2-4,BASE_SIZE*2-4);
dc->color=YELLOW;
GrLine(dc,balls[0].x,balls[0].y,
ipx-task->pix_left-task->scroll_x,
ipy-task->pix_top-task->scroll_y);
for (i=0;i<NUM_SPRINGS;i++)
GrLine(dc,springs[i].end1->x,springs[i].end1->y,
springs[i].end2->x,springs[i].end2->y);
dc->color=LTCYAN;
GrCircle(dc,balls[0].x,balls[0].y,BALL_RADIUS);
GrFloodFill(dc,balls[0].x,balls[0].y,TRUE);
dc->color=BLACK;
GrCircle(dc,balls[0].x,balls[0].y,BALL_RADIUS);
for (i=1;i<NUM_BALLS;i++) {
dc->color=LTPURPLE;
GrCircle(dc,balls[i].x,balls[i].y,BALL_RADIUS);
GrFloodFill(dc,balls[i].x,balls[i].y,TRUE);
if (cx-BASE_SIZE-BALL_RADIUS<=balls[i].x<=cx+BASE_SIZE+BALL_RADIUS &&
cy-BASE_SIZE-BALL_RADIUS<=balls[i].y<=cy+BASE_SIZE+BALL_RADIUS)
snd_on=TRUE;
dc->color=BLACK;
GrCircle(dc,balls[i].x,balls[i].y,BALL_RADIUS);
}
if (snd_on)
Snd(1000);
else
Snd(0);
}
U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
{
I64 i,j;
F64 d,dd;
CD3 p,p2;
CTask *task=ode->win_task;
D3SubEqu(D3Equ(&p2,ipx-task->pix_left-task->scroll_x,ipy-task->pix_top-task->scroll_y,0),
&balls[0].state->x);
D3AddEqu(&balls[0].DstateDt->DxDt,D3MulEqu(&p2,STRETCH));
D3Equ(&p2,task->pix_width>>1,task->pix_height>>1,0);
for (i=1;i<NUM_BALLS;i++) {
D3Sub(&p2,&balls[i].state->x,&p);
if (d=D3Norm(&p)) {
//Gravity would be /(d*d*d), but that's too exponential.
D3MulEqu(&p,GRAVITY/d);
D3AddEqu(&balls[i].DstateDt->DxDt,&p);
}
}
for (i=0;i<NUM_BALLS;i++)
for (j=i+1;j<NUM_BALLS;j++) {
D3Sub(&balls[j].state->x,&balls[i].state->x,&p);
dd=D3SqrNorm(&p);
if (dd<=(2*BALL_RADIUS)*(2*BALL_RADIUS)) {
if (t-collision_t>0.05) {
Noise(50,5000,6000);
collision_t=t;
}
d=Sqrt(dd)+0.0001;
dd=10.0*Sqr(Sqr((2*BALL_RADIUS)*(2*BALL_RADIUS)-dd));
D3MulEqu(&p,dd/d);
D3AddEqu(&balls[j].DstateDt->DxDt,&p);
D3SubEqu(&balls[i].DstateDt->DxDt,&p);
}
}
d=balls[0].state->x;
if (d-BALL_RADIUS<0)
balls[0].DstateDt->DxDt+=Sqr(Sqr(Sqr(d-BALL_RADIUS)));
if (d+BALL_RADIUS>task->pix_width)
balls[0].DstateDt->DxDt-=Sqr(Sqr(Sqr((d+BALL_RADIUS)-task->pix_width)));
d=balls[0].state->y;
if (d-BALL_RADIUS<0)
balls[0].DstateDt->DyDt+=Sqr(Sqr(Sqr(d-BALL_RADIUS)));
if (d+BALL_RADIUS>task->pix_height)
balls[0].DstateDt->DyDt-=Sqr(Sqr(Sqr((d+BALL_RADIUS)-task->pix_height)));
}
U0 Whap()
{
I64 i;
CMathODE *ode=ODENew(0,1e-2,ODEF_HAS_MASSES);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
WordStat;
Preempt(OFF);
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
);
ode->derivative=&MyDerivative;
ode->drag_v2=0.002;
ode->drag_v3=0.00001;
ode->acceleration_limit=5e3;
MemSet(balls,0,NUM_BALLS*sizeof(CMass));
D3Equ(&balls[0].x,100,100,0);
for (i=1;i<NUM_BALLS;i++)
D3Equ(&balls[i].x,
RandI16%500+Fs->pix_width>>1,RandI16%500+Fs->pix_height>>1,0);
balls[0].x=ipx-Fs->pix_left-Fs->scroll_x;
balls[0].y=ipy-Fs->pix_top-Fs->scroll_y;
for (i=0;i<NUM_BALLS;i++) {
balls[i].mass=1.0;
balls[i].drag_profile_factor=1.0;
QueIns(&balls[i],ode->last_mass);
}
balls[2].x=balls[1].x+15;
balls[2].y=balls[1].y;
balls[3].x=balls[1].x;
balls[3].y=balls[1].y+15;
MemSet(springs,0,NUM_SPRINGS*sizeof(CSpring));
springs[0].end1=&balls[1];
springs[0].end2=&balls[2];
springs[0].rest_len=15;
springs[0].const=10000;
QueIns(&springs[0],ode->last_spring);
springs[1].end1=&balls[1];
springs[1].end2=&balls[3];
springs[1].rest_len=15;
springs[1].const=10000;
QueIns(&springs[1],ode->last_spring);
springs[2].end1=&balls[2];
springs[2].end2=&balls[3];
springs[2].rest_len=sqrt2*15;
springs[2].const=10000;
QueIns(&springs[2],ode->last_spring);
collision_t=0;
QueIns(ode,Fs->last_ode);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
GetChar;
SettingsPop;
QueRem(ode);
ODEDel(ode);
MenuPop;
}
Whap;
Binary file not shown.
Binary file not shown.
+94
View File
@@ -0,0 +1,94 @@
/*
This demonstrates dynamic initialization of
vars. It even works for AOT modules
because code is generated which runs at
$LK,"Load",A="MN:Load"$() time to initialize them.
This file is dual use -- you can JIT compile
it or AOT compile it. If you AOT compile
then override the filename extension warning.
Static vars are, essentually, global var.
*/
#ifaot
#include "::/Kernel/AOT.HPP"
#endif
class Test
{
I32 time;
U8 name[8];
};
Test g1[]={
{10,"Name1"},
{(tS%10.0)*100,"Name2"}, //Dynamic initialization
{30,"Name3"}
};
D(g1,sizeof(g1));
"Time 1:%d\n",g1[1].time;
U0 Main1()
{
static Test s1[]={
{10,"Static1"},
{(tS%10.0)*100,"Static2"}, //Dynamic initialization
{30,"Static3"}
};
D(s1,sizeof(s1));
"Time 2:%d\n",s1[1].time;
}
Main1;
/*
Now, we'll use the data heap glbl option
to force global vars onto the data heap.
You can't initialize heap glbls in a AOT
module.
You can turn the data heap flag
on and off within your programs, leaving
ones which need initialization on the code heap.
You can't dynamically initialize data heap
glbls--they are consts. This might be a silly
point, but might result in odd differences, perhaps
from the order things are evaluated.
Data heap glbls are good for AOT modules
because they don't take-up room in the .BIN.Z file.
*/
#ifjit
#exe {OptOn(OPTf_GLBLS_ON_DATA_HEAP);};
Test g2[]={
{10,"name1"},
{(tS%10.0)*100,"name2"}, //No dynamic initialization--converted to a const
{30,"name3"}
};
D(g2,sizeof(g2));
"Time 3:%d\n",g2[1].time;
U0 Main2()
{
static Test s2[]={
{10,"static1"},
{(tS%10.0)*100,"static2"}, //No dynamic initialization--converted to a const
{30,"static3"}
};
D(s2,sizeof(s2));
"Time 4:%d\n",s2[1].time;
}
Main2;
#exe {OptOn(OPTf_GLBLS_ON_DATA_HEAP);};
#endif
NewLine;
+117
View File
@@ -0,0 +1,117 @@
U0 Main()
{
F64 é=0,č=0,ę=0;
CD3I32 poly[4];
CDC *dc=DCAlias;
DCAllocDepthBuf(dc);
dc->flags|=DCF_TRANSFORMATION|DCF_SYMMETRY;
try {
while (!ScanChar) {
DCDepthBufRst(dc);
GrSetSymmetry(dc,Fs->pix_width/2,Fs->pix_height/2,
ipx-Fs->pix_left-Fs->scroll_x,
ipy-Fs->pix_top-Fs->scroll_y);
dc->color=LTBLUE;
GrLine(dc,Fs->pix_width/2,Fs->pix_height/2,
ipx-Fs->pix_left-Fs->scroll_x,
ipy-Fs->pix_top-Fs->scroll_y);
GrIdentEqu(dc->r);
GrRotXEqu(dc->r,ę);
GrRotYEqu(dc->r,č);
GrRotZEqu(dc->r,é);
GrSetRotMat(dc,dc->r);
dc->x=Fs->pix_width/2;
dc->y=Fs->pix_height/2;
dc->z=500;
dc->color=GREEN;
poly[0].x=50;
poly[0].y=150;
poly[0].z=0;
poly[1].x=275;
poly[1].y=100;
poly[1].z=0;
poly[2].x=155;
poly[2].y=200;
poly[2].z=0;
poly[3].x=100;
poly[3].y=200;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
dc->color=RED;
poly[0].x=50;
poly[0].y=150;
poly[0].z=50;
poly[1].x=275;
poly[1].y=100;
poly[1].z=50;
poly[2].x=155;
poly[2].y=200;
poly[2].z=50;
poly[3].x=100;
poly[3].y=200;
poly[3].z=50;
GrFillPoly3(dc,4,poly);
dc->color=BLUE;
poly[0].x=50;
poly[0].y=150;
poly[0].z=-50;
poly[1].x=275;
poly[1].y=100;
poly[1].z=-50;
poly[2].x=155;
poly[2].y=200;
poly[2].z=-50;
poly[3].x=100;
poly[3].y=200;
poly[3].z=-50;
GrFillPoly3(dc,4,poly);
dc->color=RED+GREEN<<16+ROPF_DITHER;
poly[0].x=50;
poly[0].y=150;
poly[0].z=50;
poly[1].x=275;
poly[1].y=100;
poly[1].z=50;
poly[2].x=275;
poly[2].y=100;
poly[2].z=0;
poly[3].x=50;
poly[3].y=150;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
dc->color=BLUE+GREEN<<16+ROPF_DITHER;
poly[0].x=100;
poly[0].y=200;
poly[0].z=-50;
poly[1].x=155;
poly[1].y=200;
poly[1].z=-50;
poly[2].x=155;
poly[2].y=200;
poly[2].z=0;
poly[3].x=100;
poly[3].y=200;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
WinMgrSync;
DCFill;
é+=2.1*ă/180.0;
č+=1.1*ă/180.0;
ę+=0.5*ă/180.0;
}
} catch
PutExcept;
DCFill;
DCDel(dc);
}
Main;
+33
View File
@@ -0,0 +1,33 @@
U0 BSplineDemo()
{
CDC *dc=DCAlias;
I64 p1,p2,i=0,msg_code;
CD3I32 c[64];
SettingsPush;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
DocClear;
"Select ctrl points with left mouse. Right when finished.\n";
DCFill;
do {
msg_code=GetMsg(&p1,&p2,1<<MSG_IP_L_UP+1<<MSG_IP_R_UP);
if (msg_code==MSG_IP_L_UP) {
c[i].x=p1; c[i].y=p2; c[i].z=0;
dc->color=GREEN;
GrCircle(dc,p1,p2,10);
i++;
}
} while (msg_code!=MSG_IP_R_UP);
dc->color=RED;
Gr2BSpline(dc,c,i,TRUE);
dc->color=BLUE;
Gr3BSpline(dc,c,i,TRUE);
DCDel(dc);
SettingsPop;
PressAKey;
DCFill;
}
BSplineDemo;
+38
View File
@@ -0,0 +1,38 @@
// Classic Commodore 64 Sprite
U8 a[60]={0,127,0,1,255,192,3,255,224,3,231,224,
7,217,240,7,223,240,7,217,240,3,231,224,
3,255,224,3,255,224,2,255,160,1,127,64,
1,62,64,0,156,128,0,156,128,0,73,0,0,73,0,
0,62,0,0,62,0,0,28,0};
U0 Balloon()
{
I64 i,j,k;
CLI
OutU8(VGA_SC_INDEX,VGA_MAP_MASK);
OutU8(VGA_SC_DATA,0xF);
MemSetU64(0xA0000,0,640*480/64);
OutU8(VGA_SC_INDEX,VGA_MAP_MASK);
OutU8(VGA_SC_DATA,RED+GREEN+8);
for (k=100;k<150;k++) {
for (i=0;i<20;i++)
for (j=0;j<3;j++)
*(0xA0000+0x1000+(i+k)*640/8+j)(U8 *)=a[i*3+j];
BusyWait(40000);
for (i=0;i<20;i++)
for (j=0;j<3;j++)
*(0xA0000+0x1000+(i+k)*640/8+j)(U8 *)=0;
}
STI
VGAFlush;
}
Balloon;
+41
View File
@@ -0,0 +1,41 @@
CDC *dc=DCAlias;
CDC *img1=DCNew(64,64);
CDC *img2=DCNew(512,512);
img1->color=COLOR_MONO;
img1->pen_width=3;
GrCircle(img1,30,30,20);
GrFloodFill3(img1,30,30,0,TRUE);
GrLine3(img1,60,0,0,0,60,0);
DCFill(img2);
img2->color=RED;
img2->brush=img1;
GrCircle(img2,256-30,256-30,128,67);
img2->color=BLUE;
img2->pen_width=6;
img2->brush=NULL;
GrLine3(img2,128,128,0,256+128,256+128,0);
GrLine3(img2,256+128,128,0,128,256+128,0);
img2->color=YELLOW;
GrRect(img2,256-20,256-20,40,40);
I64 i;
for (i=0;i<256;i+=4) {
WinMgrSync;
DCFill;
GrBlot(dc,i-256,i-256,img2);
Sleep(10);
}
U8 *tempg=DC2Sprite(img1);
Sprite(tempg);
Free(tempg);
NewLine(9);
DCDel(img1);
DCDel(img2);
DCDel(dc);
PressAKey;
DCFill;
+57
View File
@@ -0,0 +1,57 @@
//This uses $LK,"fixed-point-arithmetic",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
I64 x[16],y[16],dx[16],dy[16];
U0 Init()
{
I64 i;
F64 é;
MemSet(x,0,sizeof(x));
MemSet(y,0,sizeof(y));
for (i=0;i<16;i++) {
é=Rand*2*ã;
dx[i]=MAX_I32*Cos(é);
dy[i]=MAX_I32*Sin(é);
}
}
U0 Bounce()
{
CDC *dc=DCAlias;
I64 i,msg_code,p1,update;
Init;
try { //Catch <CTRL-ALT-C>
while (TRUE) {
update=win_updates;
do for (i=0;i<16;i++) {
dc->color=i;
GrPlot(dc,x[i].i32[1],y[i].i32[1]);
x[i]+=dx[i];
y[i]+=dy[i];
if (!(0<=x[i]<Fs->pix_width<<32)) {
x[i]-=dx[i];
dx[i]=-dx[i];
}
if (!(0<=y[i]<Fs->pix_height<<32)) {
y[i]-=dy[i];
dy[i]=-dy[i];
}
}
while (update==win_updates);
while (msg_code=ScanMsg(&p1,NULL,1<<MSG_KEY_DOWN|1<<MSG_RESIZE|1<<MSG_MOVE))
if (msg_code==MSG_KEY_DOWN) {
if (p1==CH_SHIFT_ESC || p1==CH_ESC)
goto bc_done;
else
Init;
} else
DCFill(dc);
}
bc_done:
} catch
PutExcept;
DCFill(dc);
DCDel(dc);
}
Bounce;
+54
View File
@@ -0,0 +1,54 @@
CDC *dc;
U0 DrawIt(CTask *,CDC *)
{//This technique is weird, but clever. In Box() we
//created an alias of the system $LK,"gr_dc2",A="MN:gr_dc2"$.
dc->pen_width=2;
dc->color=RED;
GrLine3(dc,-100,-100,-100, -100, 100,-100);
GrLine3(dc,-100, 100,-100, 100, 100,-100);
GrLine3(dc, 100, 100,-100, 100,-100,-100);
GrLine3(dc, 100,-100,-100, -100,-100,-100);
GrLine3(dc,-100,-100, 100, -100, 100, 100);
GrLine3(dc,-100, 100, 100, 100, 100, 100);
GrLine3(dc, 100, 100, 100, 100,-100, 100);
GrLine3(dc, 100,-100, 100, -100,-100, 100);
GrLine3(dc,-100,-100, 100, -100,-100,-100);
GrLine3(dc,-100, 100, 100, -100, 100,-100);
GrLine3(dc, 100, 100, 100, 100, 100,-100);
GrLine3(dc, 100,-100, 100, 100,-100,-100);
}
U0 Box()
{
F64 é=0,è=0,ê=0,s=1,s1=1.05;
dc=DCAlias(gr_dc2,Fs);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
DocClear;
Fs->draw_it=&DrawIt;
Preempt(OFF); //We don't want matrix used while we're changing it.
dc->x=200;
dc->y=200;
dc->flags|=DCF_TRANSFORMATION;
while (!ScanChar) {
GrIdentEqu(dc->r);
GrRotZEqu(dc->r,é);
GrRotXEqu(dc->r,è);
GrRotZEqu(dc->r,ê);
GrScaleEqu(dc->r,s);
GrSetRotMat(dc,dc->r);
Sleep(20);
é+=2*ã/70;
è+=2*ã/90;
ê+=2*ã/110;
s*=s1;
if ( !(0.2<s<1.4) ) s1=1/s1;
}
SettingsPop;
DCDel(dc);
}
Box;
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
//See $LK,"::/Demo/Games/Stadium/StadiumGen.CPP"$.
U0 ViewScreenCapture(U8 *filename)
{
CDC *dc=DCAlias(,Fs),
*dc2=GRARead(filename);
GrBlot(dc,0,0,dc2);
DCDel(dc2);
DCDel(dc);
}
U0 Main()
{
"Capture screen...\n";
PressAKey;
GRACaptureScreen("HOME/ScreenShot");
"View captured screen...\n";
PressAKey;
ViewScreenCapture("HOME/ScreenShot");
PressAKey;
DCFill;
}
Main;
+48
View File
@@ -0,0 +1,48 @@
//x must be global.
//Might as well make y global.
F64 x,y,y_last;
U0 Cartesian()
{
U8 *st;
I64 ch=0,h,v;
Bool first;
CDC *dc=DCAlias;
do {
DocClear;
"Enter algebraic equation to graph.\n"
"Example: y=2*x\n"
"y=";
if (st=MGetS) {
if (*st) {
h=Fs->pix_width/2;
v=Fs->pix_height/2;
dc->color=RED;
GrLine(dc,h,0,h,2*v+1);
GrLine(dc,0,v,2*h+1,v);
first=TRUE;
dc->color=BLACK;
for (x=-h;x<=h;x++) {
y=-ExePrint("ToF64(%s);",st)(F64);
if (!first)
GrLine(dc,x-1+h,y_last+v,x+h,y+v);
y_last=y;
first=FALSE;
}
ch=GetChar;
} else
ch=CH_SHIFT_ESC;
Free(st);
} else
ch=CH_SHIFT_ESC;
DCFill;
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
DCDel(dc);
}
Cartesian;
/*$WW,1$
For better performance, compile the expression entered by the user one time with $LK,"LexExpression2Bin",A="MN:LexExpression2Bin"$() and use $LK,"Call",A="MN:Call"$(). See $LK,"::/Demo/CompileDemo.CPP"$.
*/
+35
View File
@@ -0,0 +1,35 @@
U8 *old_font=gr_font;
// See $LK,"::/Kernel/Font8x8.CPP"$.
// See $LK,"::/Demo/ScreenCodes.CPP"$.
// See $LK,"::/Demo/ExtendedChars.CPP"$.
// See $LK,"::/Demo/Graphics/FontEd.CPP"$.
U8 waves[8*4]={
0x00,0x11,0xAA,0x44,0x00,0x11,0xAA,0x44,
0x00,0x22,0x55,0x88,0x00,0x22,0x55,0x88,
0x00,0x44,0xAA,0x11,0x00,0x44,0xAA,0x11,
0x00,0x88,0x55,0x22,0x00,0x88,0x55,0x22};
U0 AnimateEndCB()
{
gr_font=old_font;
Exit;
}
U0 AnimateTask(I64)
{
I64 i;
U8 *font=MAlloc(256*8);
Fs->task_end_cb=&AnimateEndCB;
MemCpy(font,gr_font,256*8);
gr_font=font;
while (TRUE) {
MemCpy(font+CH_SPACE*FONT_HEIGHT,waves+8*(i++&0x3),8);
Sleep(100);
}
}
Spawn(&AnimateTask,NULL,"Animate",,Fs);
TaskRep;
+119
View File
@@ -0,0 +1,119 @@
#define N 32
class Node
{
Node *left,*right;
I64 n;
};
I64 n1,n2,common_ancestor;
Node *root;
#define X_SPACING 16
#define Y_SPACING 45
#define ARROW_SPACING 3
U0 ShowTree(CDC *dc,Node *tempn,I64 *_node_x,I64 *_tree_x,I64 y)
{
I64 node_x;
if (tempn) {
if (tempn->left) {
ShowTree(dc,tempn->left,&node_x,_tree_x,y+Y_SPACING);
dc->color=BLUE;
GrArrow3(dc,*_tree_x,y,0,node_x+ARROW_SPACING,y+Y_SPACING-ARROW_SPACING,0);
}
if (tempn->n==n1 || tempn->n==n2) {
if (tempn->n==common_ancestor)
dc->color=YELLOW;
else
dc->color=RED;
} else if (tempn->n==common_ancestor)
dc->color=GREEN;
else
dc->color=BLUE;
*_node_x=*_tree_x;
GrPrint(dc,*_node_x,y,"%d",tempn->n);
*_tree_x+=X_SPACING;
if (tempn->right) {
ShowTree(dc,tempn->right,&node_x,_tree_x,y+Y_SPACING);
dc->color=BLUE;
GrArrow3(dc,*_node_x,y,0,node_x-ARROW_SPACING,y+Y_SPACING-ARROW_SPACING,0);
}
}
}
U0 DrawIt(CTask *,CDC *dc)
{
I64 node_x=0,tree_x=0;
ShowTree(dc,root,&node_x,&tree_x,20);
}
U0 TreeAdd(Node **_root,Node *tempn)
{
Node *root=*_root;
if (!root)
*_root=tempn;
else if (tempn->n==root->n)
Free(tempn);
else if (tempn->n<root->n)
TreeAdd(&root->left,tempn);
else
TreeAdd(&root->right,tempn);
}
U0 TreeNew()
{
I64 i;
Node *tempn;
for (i=0;i<N;i++) {
tempn=CAlloc(sizeof(Node));
tempn->n=RandU16%N;
if (i==N-1)
n1=tempn->n;
else if (i==N-2)
n2=tempn->n;
TreeAdd(&root,tempn);
Sleep(50);
}
}
U0 TreeCommonAncestorFind(Node *root)
{
if (root && root->n!=n1 && root->n!=n2) {
common_ancestor=root->n;
if (n1<root->n && n2<root->n)
TreeCommonAncestorFind(root->left);
else if (n1>root->n && n2>root->n)
TreeCommonAncestorFind(root->right);
}
}
U0 TreeCommonAncestor()
{ //Make tree and find common ancestor to n1 & n2.
root=NULL;
n1=n2=common_ancestor=0;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->draw_it=&DrawIt;
DocClear;
"Scroll with {CTRL-Left Grab}.\n";
try {
TreeNew;
TreeCommonAncestorFind(root);
PressAKey;
} catch
PutExcept;
SettingsPop;
}
TreeCommonAncestor;
/*
Be careful with recursive routines in TempleOS
because the stack does not grow and will overflow.
See $LK,"::/Demo/StkGrow.CPP"$.
*/
+16
View File
@@ -0,0 +1,16 @@
U0 Main()
{
CDC *dc=DCAlias;
dc->color=RED+BLACK<<16+ROPF_DITHER;
GrCircle(dc,100,100,50);
GrLine(dc,10,10,280,70);
dc->color=RED+BLUE<<16+ROPF_DITHER;
GrFloodFill(dc,100,100);
dc->color=PURPLE+BLUE<<16+ROPF_DITHER;
GrRect(dc,20,20,100,100);
PressAKey;
DCFill;
DCDel(dc);
}
Main;
Loaded 100 of 1416 files, more files were not shown because too many files have changed in this diff. Show more