TempleOSTS_131005.ISO
This commit is contained in:
1 parent
1343005a29
commit
2d2a65d572
547 files changed
+33608
-12549
No files matched your search
@@ -5,7 +5,7 @@
|
||||
SetTypeMatic(0);
|
||||
|
||||
//Set Time Zone
|
||||
local_time_offset=0*60*60*CDATE_FREQ;
|
||||
local_time_offset=0*60*60*CDATE_FREQ; //Do daylight savings by hand
|
||||
|
||||
//$AN,"","mouse_move_scale"$adjust these to set mouse move scale
|
||||
mxx_scale=0.5;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
U0 FillInTime()
|
||||
{
|
||||
CDate cdt;
|
||||
cdt=GetCurTimeDate;
|
||||
cdt=GetDateTime;
|
||||
"$$IV,1$$----%D %T----$$IV,0$$\n",cdt,cdt;
|
||||
}
|
||||
|
||||
@@ -86,21 +86,13 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
if (!(sc & SCF_SHIFT))
|
||||
SetKeyDesc("Cmd/Init WordStat LT");
|
||||
} else if (!(sc & SCF_SHIFT))
|
||||
PopUp("WSInit(\"/TempleOS/\" FILENAME_MASK_TXT \";~*Bible.TXT*\");");
|
||||
PopUp("WSInit(\"/TempleOS/*;~*Bible.TXT*\");");
|
||||
break;
|
||||
case SC_F7:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/Insert Hidden Widget");
|
||||
else
|
||||
SetKeyDesc("Misc/Insert Datetime");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
DocInsSafe(DocPut,
|
||||
"$$HS+C$$$$FG$$$$HE$$");
|
||||
else
|
||||
FillInTime();
|
||||
}
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Misc/Insert Datetime");
|
||||
else
|
||||
FillInTime;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -134,7 +126,7 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
SetKeyDesc("Edit/Put Link to Cur Pos on Clipboard");
|
||||
else {
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
|
||||
DocPrint(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
|
||||
DocPut->filename.name,DocPut->cur_entry->y+1);
|
||||
}
|
||||
return TRUE;
|
||||
@@ -144,7 +136,7 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
else {
|
||||
i=RandU32;
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
|
||||
DocPrint(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
|
||||
DocPut->filename.name,i);
|
||||
"$$AN,\"<TODO>\",\"ANC%d\"$$",i;
|
||||
}
|
||||
@@ -170,9 +162,8 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool MyPutS(U8 *st)
|
||||
Bool MyPutS(U8 *)
|
||||
{
|
||||
nounusedwarn st;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
//Feel free to add more or change.
|
||||
public I64 F(U8 *pattern,U8 *fu_flags=NULL)
|
||||
{
|
||||
return Grep(pattern,"/TempleOS/"FILENAME_MASK_TXT,fu_flags);
|
||||
return Grep(pattern,"/TempleOS/*",fu_flags);
|
||||
}
|
||||
|
||||
public I64 R(U8 *pattern,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
|
||||
{
|
||||
return Grep(pattern,"/TempleOS/"FILENAME_MASK_TXT,fu_flags,replace_text);
|
||||
return Grep(pattern,"/TempleOS/*",fu_flags,replace_text);
|
||||
}
|
||||
|
||||
public I64 FD(U8 *pattern,U8 *fu_flags=NULL)
|
||||
{
|
||||
return Grep(pattern,FILENAME_MASK_TXT,fu_flags);
|
||||
return Grep(pattern,"*",fu_flags);
|
||||
}
|
||||
|
||||
public I64 RD(U8 *pattern,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
|
||||
{
|
||||
return Grep(pattern,FILENAME_MASK_TXT,fu_flags,replace_text);
|
||||
return Grep(pattern,"*",fu_flags,replace_text);
|
||||
}
|
||||
#help_index ""
|
||||
@@ -23,17 +23,17 @@ U0 SrvStartUp()
|
||||
|
||||
U0 StartUpTasks()
|
||||
{
|
||||
CTask *task1,*task2;
|
||||
task1=SpawnUser;
|
||||
task2=SpawnUser;
|
||||
WinToTop(task1);
|
||||
CTask *user1,*user2;
|
||||
user1=SpawnUser;
|
||||
user2=SpawnUser;
|
||||
WinToTop(user1);
|
||||
WinTileVert;
|
||||
if (!IsSysDeterministic)
|
||||
PopUp("#include \"::/TempleOS/Adam/Start\";");
|
||||
AdamLog("Boot Time:%7.3fs\n",tS);
|
||||
XTalk(task1,"#include \"DoItOnce\";\n");
|
||||
"Boot Time:%7.3fs\n",tS;
|
||||
XTalk(user1,"Cd(\"HOME\");#include \"DoItOnce\";\n");
|
||||
Silent(ON); //no output to screen
|
||||
WSInit("/TempleOS/" FILENAME_MASK_TXT ";~*Bible.TXT*");
|
||||
WSInit("/TempleOS/*;~*Bible.TXT*");
|
||||
Silent(OFF); //no output to screen
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ U0 SrvStartUp()
|
||||
|
||||
U0 StartUpTasks()
|
||||
{
|
||||
CTask *task1,*task2;
|
||||
task1=SpawnUser;
|
||||
task2=SpawnUser;
|
||||
WinToTop(task1);
|
||||
CTask *user1,*user2;
|
||||
user1=SpawnUser;
|
||||
user2=SpawnUser;
|
||||
WinToTop(user1);
|
||||
WinTileVert;
|
||||
AdamLog("Boot Time:%7.3fs\n",tS);
|
||||
XTalk(task1,"#include \"DoItOnce\";\n");
|
||||
"Boot Time:%7.3fs\n",tS;
|
||||
XTalk(user1,"Cd(\"HOME\");#include \"DoItOnce\";\n");
|
||||
Silent(ON); //no output to screen
|
||||
WSInit;
|
||||
Silent(OFF); //no output to screen
|
||||
|
||||
@@ -13,13 +13,13 @@ U0 VMInstallBoot(CTask *task,U8 cd_drv,U8 drv,U8 *acct_name,
|
||||
{
|
||||
U8 *st1,*st2;
|
||||
|
||||
st1=MSPrintF("%C:/",cd_drv);
|
||||
st2=MSPrintF("%C:/",drv);
|
||||
st1=MPrint("%C:/",cd_drv);
|
||||
st2=MPrint("%C:/",drv);
|
||||
CopyTree(st1,st2);
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
|
||||
st1=MSPrintF("%C:/TempleOS/Accts/%s",drv,acct_name);
|
||||
st1=MPrint("%C:/TempleOS/Accts/%s",drv,acct_name);
|
||||
MkDir(st1);
|
||||
Copy("::/TempleOS/Demo/MakeDistro.CPP.Z",st1);
|
||||
Free(st1);
|
||||
@@ -119,9 +119,9 @@ U0 RegularInstallWizard()
|
||||
if (1<=A2I(base0)<=num_hints) {
|
||||
tempha=ATARepFind(&root,A2I(base0));
|
||||
Free(base0);
|
||||
base0=MSPrintF("0x%X",tempha->base0);
|
||||
base1=MSPrintF("0x%X",tempha->base1);
|
||||
ms =MSPrintF("0x%X",tempha->unit);
|
||||
base0=MPrint("0x%X",tempha->base0);
|
||||
base1=MPrint("0x%X",tempha->base1);
|
||||
ms =MPrint("0x%X",tempha->unit);
|
||||
unit=A2I(ms);
|
||||
} else {
|
||||
while (TRUE) {
|
||||
@@ -151,8 +151,8 @@ U0 RegularInstallWizard()
|
||||
}
|
||||
|
||||
NewLine;
|
||||
st1=MSPrintF("%C:/TempleOS",*sys_acct);
|
||||
st2=MSPrintF("%C:/TempleOS",*dst);
|
||||
st1=MPrint("%C:/TempleOS",*sys_acct);
|
||||
st2=MPrint("%C:/TempleOS",*dst);
|
||||
|
||||
"$$FG,RED$$Format %C Partition?$$FG$$\n",*dst;
|
||||
if (YorN) {
|
||||
@@ -179,14 +179,14 @@ U0 RegularInstallWizard()
|
||||
NewLine;
|
||||
}
|
||||
CopyTree(st1,st2);
|
||||
st2=MSPrintF("%C:/0000Boot",*dst);
|
||||
st2=MPrint("%C:/0000Boot",*dst);
|
||||
MkDir(st2);
|
||||
Free(st2);
|
||||
st2=MSPrintF("%C:/Temp",*dst);
|
||||
st2=MPrint("%C:/Temp",*dst);
|
||||
MkDir(st2);
|
||||
Free(st2);
|
||||
|
||||
new_home_str=MSPrintF("%C:/TempleOS/Accts/%s",*dst,acct_name);
|
||||
new_home_str=MPrint("%C:/TempleOS/Accts/%s",*dst,acct_name);
|
||||
MkDir(new_home_str);
|
||||
Copy("::/TempleOS/Demo/MakeDistro.CPP.Z",new_home_str);
|
||||
XTalkWait(task,
|
||||
|
||||
Binary file not shown.
@@ -5,4 +5,5 @@
|
||||
Cd("HOME");;
|
||||
#include "/TempleOS/Accts/TS/TSAdam"
|
||||
#include "/TempleOS/Accts/TS/TSDistro"
|
||||
#include "/TempleOS/Accts/TS/TSHolySpirit"
|
||||
Cd("HOME");;
|
||||
@@ -4,51 +4,13 @@
|
||||
U0 FillInTime()
|
||||
{
|
||||
CDate cdt;
|
||||
cdt=GetCurTimeDate;
|
||||
cdt=GetDateTime;
|
||||
"$$IV,1$$----%D %T----$$IV,0$$\n",cdt,cdt;
|
||||
}
|
||||
|
||||
U0 RandQuote(I64 num)
|
||||
{ //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
|
||||
I64 i,size,l=512;
|
||||
U8 *bible_filename=Define("ST_BIBLE_FILE"),
|
||||
*buf=FileRead(bible_filename,&size);
|
||||
if (buf) {
|
||||
i=num%(size-l);
|
||||
buf[i+l]=0;
|
||||
"" buf+i;
|
||||
Free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
U0 BadCodeJump(I64 num)
|
||||
{ //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
|
||||
CDirEntry *root=FilesFind("/TempleOS/*",FUF_JUST_FILES|FUF_RECURSE|FUF_FLATTEN_TREE|FUF_JUST_SRC_FILES),
|
||||
*tempm=root;
|
||||
I64 cnt=0;
|
||||
CDoc *doc;
|
||||
U8 *st;
|
||||
while (tempm) {
|
||||
doc=DocRead(tempm->full_name);
|
||||
tempm->user_data=doc->root.y;
|
||||
cnt+=doc->root.y;
|
||||
DocDel(doc);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
num=num%cnt;
|
||||
tempm=root;
|
||||
while (tempm) {
|
||||
num-=tempm->user_data;
|
||||
if (num<0) {
|
||||
st=MSPrintF("FL:%s,%d",tempm->full_name,-num);
|
||||
break;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
CDirLstDel(root);
|
||||
Ed(st);
|
||||
Free(st);
|
||||
}
|
||||
#define WS_F6 0
|
||||
#define WS_SHIFT_F6 1
|
||||
I64 my_wordstat=WS_F6;
|
||||
|
||||
Bool MyPutKey(I64 ch,I64 sc)
|
||||
{ //ch=ASCII; sc=scancode
|
||||
@@ -64,7 +26,7 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
//Return TRUE if you completely
|
||||
//handled the key.
|
||||
|
||||
I64 i,sc2=sc.u8[0];
|
||||
I64 i,sc2=sc.u8[0],old_wordstat;
|
||||
|
||||
if (SC_F1<=sc2<=SC_F10 &&
|
||||
sc&SCF_ALT &&
|
||||
@@ -130,10 +92,24 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
SetKeyDesc("God Word");
|
||||
} else {
|
||||
//$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
|
||||
DocRecalc(DocPut);
|
||||
if (DocPut->cur_entry->settings->cur_text_attr&0xF!=RED)
|
||||
"$$FG,RED$$";
|
||||
if (sc & SCF_SHIFT)
|
||||
RandQuote(KbdMouseEvtTime>>4);
|
||||
else
|
||||
"%s ",ws_sorted_words[KbdMouseEvtTime>>4%ws_num_words]->str;
|
||||
RandQuote;
|
||||
else {
|
||||
if (my_wordstat!=WS_SHIFT_F6) {
|
||||
old_wordstat=TaskValidate(ws_task);
|
||||
my_wordstat=WS_SHIFT_F6;
|
||||
PopUp("WSInit(\"::/TempleOS/Apps/HolySpirit/Vocab.TXT*\");");
|
||||
while (!Bt(&ws_flags,WSf_INIT_IN_PROGRESS)) //Kinda risky
|
||||
Yield;
|
||||
while (Bt(&ws_flags,WSf_INIT_IN_PROGRESS))
|
||||
Yield;
|
||||
WordStat(old_wordstat);
|
||||
}
|
||||
RandWord;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F6:
|
||||
@@ -143,24 +119,32 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
else
|
||||
SetKeyDesc("Cmd/Init WordStat TempleOS");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
old_wordstat=TaskValidate(ws_task);
|
||||
if (sc & SCF_SHIFT) {
|
||||
my_wordstat=WS_SHIFT_F6;
|
||||
PopUp("WSInit(\"::/TempleOS/Apps/HolySpirit/Vocab.TXT*\");");
|
||||
else
|
||||
PopUp("WSInit(\"::/TempleOS/\" FILENAME_MASK_TXT \";~*Bible.TXT*\");");
|
||||
} else {
|
||||
my_wordstat=WS_F6;
|
||||
PopUp("WSInit(\"::/TempleOS/*;~*Bible.TXT*\");");
|
||||
}
|
||||
while (!Bt(&ws_flags,WSf_INIT_IN_PROGRESS)) //Kinda risky
|
||||
Yield;
|
||||
while (Bt(&ws_flags,WSf_INIT_IN_PROGRESS))
|
||||
Yield;
|
||||
WordStat(old_wordstat);
|
||||
}
|
||||
break;
|
||||
case SC_F7:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/Insert Hidden Widget");
|
||||
SetKeyDesc("Misc/Insert My URL");
|
||||
else
|
||||
SetKeyDesc("Misc/Insert Datetime");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
DocInsSafe(DocPut,
|
||||
"$$HS+C$$$$FG$$$$HE$$");
|
||||
FillInMyURL;
|
||||
else
|
||||
FillInTime();
|
||||
FillInTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -201,7 +185,7 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
SetKeyDesc("Edit/Put Link to Cur Pos on Clipboard");
|
||||
else {
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
|
||||
DocPrint(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
|
||||
DocPut->filename.name,DocPut->cur_entry->y+1);
|
||||
}
|
||||
return TRUE;
|
||||
@@ -211,7 +195,7 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
else {
|
||||
i=RandU32;
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
|
||||
DocPrint(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
|
||||
DocPut->filename.name,i);
|
||||
"$$AN,\"<TODO>\",\"ANC%d\"$$",i;
|
||||
}
|
||||
@@ -235,7 +219,14 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Cmd/Jump to Bad Code");
|
||||
else //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
|
||||
BadCodeJump(KbdMouseEvtTime>>4);
|
||||
BadCodeJump;
|
||||
return TRUE;
|
||||
|
||||
case 'g':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Godle");
|
||||
else //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
|
||||
Godle; //God drawing
|
||||
return TRUE;
|
||||
|
||||
case 'p':
|
||||
@@ -257,9 +248,8 @@ Bool MyPutKey(I64 ch,I64 sc)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool MyPutS(U8 *st)
|
||||
Bool MyPutS(U8 *)
|
||||
{
|
||||
nounusedwarn st;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ U0 StartUpTasks()
|
||||
WinTileVert;
|
||||
if (!IsSysDeterministic)
|
||||
PopUp("#include \"::/TempleOS/Adam/Start\";");
|
||||
AdamLog("Boot Time:%7.3fs\n",tS);
|
||||
XTalk(user1,"#include \"DoItOnce\";\n");
|
||||
"Boot Time:%7.3fs\n",tS;
|
||||
XTalk(user1,"Cd(\"HOME\");#include \"DoItOnce\";\n");
|
||||
Silent(ON);
|
||||
if (!IsSysDeterministic)
|
||||
WSInit("/TempleOS/" FILENAME_MASK_TXT ";~*Bible.TXT*");
|
||||
WSInit("/TempleOS/*;~*Bible.TXT*");
|
||||
Silent(OFF);
|
||||
AdamLog("WordStat Time:%7.3fs\n",tS);
|
||||
"WordStat Time:%7.3fs\n",tS;
|
||||
if (ts_has_win_drv)
|
||||
DrvEnable(TS_WIN_DRV_LET,OFF);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,12 +1,10 @@
|
||||
//Change anything you want in this
|
||||
//acct file or others.
|
||||
|
||||
#exe {OptOn(OPTf_WARN_PAREN);};
|
||||
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
|
||||
OptOn(OPTf_WARN_PAREN);
|
||||
OptOn(OPTf_WARN_DUP_TYPES);
|
||||
#include "HOME/Adam3aLocalize"
|
||||
#include "HOME/Adam3bPkgs"
|
||||
#include "HOME/Adam3dKeyPlugIns"
|
||||
#include "HOME/Adam3eWrappers"
|
||||
#include "HOME/Adam3fSys"
|
||||
#exe {OptOff(OPTf_WARN_PAREN);};
|
||||
#exe {OptOff(OPTf_WARN_DUP_TYPES);};
|
||||
@@ -0,0 +1,771 @@
|
||||
//This uses $LK,"fixed-point","FI:::/TempleOS/Demo/Lectures/FixedPoint.CPP"$.
|
||||
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/DiningStars","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/DiningStars");
|
||||
|
||||
#define PERSON_SCALE 6.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<1>",1$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<2>",2$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<3>",3$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLANT_SCALE 6.0
|
||||
|
||||
|
||||
|
||||
$SP,"<4>",4$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<5>",5$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Wall
|
||||
{
|
||||
Wall *next,*last;
|
||||
CD3I32 p1,p2;
|
||||
I64 cpu_num;
|
||||
} walls_root;
|
||||
|
||||
|
||||
|
||||
|
||||
#define SCREEN_SCALE 1024
|
||||
#define PLOT_GRID_WIDTH 24
|
||||
#define PLOT_GRID_HEIGHT 24
|
||||
#define MAN_HEIGHT 300
|
||||
#define WALL_HEIGHT 1.0
|
||||
#define BLUEPRINT_SCALE 4
|
||||
|
||||
CDC *blueprint_dc;
|
||||
I64 blueprint_width,blueprint_height;
|
||||
U8 *blueprint=NULL,
|
||||
*panels_processed=NULL;
|
||||
|
||||
I64 man_xx,man_yy;
|
||||
F64 man_é;
|
||||
|
||||
F64 t0,tf;
|
||||
|
||||
#define NUM_PERSONS 16
|
||||
class Person
|
||||
{
|
||||
I64 x,y;
|
||||
} persons[NUM_PERSONS];
|
||||
|
||||
U0 DSTransform(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;
|
||||
}
|
||||
|
||||
public U0 DSLighting(CDC *dc,CD3I32 *p1,CD3I32 *p2,CD3I32 *p3,CColorROPU32 color)
|
||||
{
|
||||
CD3I32 v1,v2;
|
||||
I64 i,vn_x,vn_y,vn_z;
|
||||
F64 d;
|
||||
|
||||
v1.x=p1->x-p2->x;
|
||||
v1.y=p1->y-p2->y;
|
||||
v1.z=p1->z-p2->z;
|
||||
|
||||
v2.x=p3->x-p2->x;
|
||||
v2.y=p3->y-p2->y;
|
||||
v2.z=p3->z-p2->z;
|
||||
|
||||
//V1 and V2 are vects along two sides
|
||||
//of the tri joined at p2.
|
||||
|
||||
vn_x=v1.y*v2.z-v1.z*v2.y;
|
||||
vn_y=v1.z*v2.x-v1.x*v2.z;
|
||||
vn_z=v1.x*v2.y-v1.y*v2.x;
|
||||
if (d=Sqrt(SqrI64(vn_x)+SqrI64(vn_y)+SqrI64(vn_z)))
|
||||
d=1<<16/d;
|
||||
vn_x*=d;
|
||||
vn_y*=d;
|
||||
vn_z*=d;
|
||||
//Vn is the cross product of V1 and V3
|
||||
//which means it is perpendicular. It
|
||||
//is the normal vect to the surface.
|
||||
//It has been scaled to length 65536.
|
||||
|
||||
//Light source has been scaled to length 65536.
|
||||
i=(vn_x*dc->ls.x+vn_y*dc->ls.y+vn_z*dc->ls.z)>>16;
|
||||
|
||||
i=(0x8000+i)>>1;//Tables are too dark ****TODO****
|
||||
|
||||
//The dot product of the light source
|
||||
//vect and the surface normal
|
||||
//gives an illumination number.
|
||||
//65536*65536>>16=65536
|
||||
|
||||
//TempleOS will generate a random U16
|
||||
//and compare to dither_probability and
|
||||
//will pick from two colors.
|
||||
//Probability dithering does not work with pen_width>1 at this time.
|
||||
if (color.c0.rop&ROPBF_TWO_SIDED) {
|
||||
color.c0.rop&=~ROPBF_TWO_SIDED;
|
||||
i=AbsI64(i)<<1;
|
||||
} else
|
||||
i+=65536;
|
||||
if (color.c0.rop&ROPBF_HALF_RANGE_COLOR) {
|
||||
color.c0.rop&=~ROPBF_HALF_RANGE_COLOR;
|
||||
i>>=1;
|
||||
if (color>=8) {
|
||||
color-=8;
|
||||
i+=65536;
|
||||
}
|
||||
}
|
||||
if (i<65536) {
|
||||
dc->color=ROPF_PROBABILITY_DITHER+color<<16+BLACK;
|
||||
dc->dither_probability=i;
|
||||
} else {
|
||||
dc->color=ROPF_PROBABILITY_DITHER+(color^8)<<16+color;
|
||||
dc->dither_probability=i-65536;
|
||||
}
|
||||
}
|
||||
|
||||
#define LOS_SCALE 4
|
||||
|
||||
Bool LOSPlot(U8 *,I64 x,I64 y,I64)
|
||||
{
|
||||
if (blueprint[(y/LOS_SCALE)*blueprint_width+(x/LOS_SCALE)]==WHITE)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
{ //Line of sight
|
||||
return LOSLine(NULL,x1*LOS_SCALE/SCREEN_SCALE,y1*LOS_SCALE/SCREEN_SCALE,0,
|
||||
x2*LOS_SCALE/SCREEN_SCALE,y2*LOS_SCALE/SCREEN_SCALE,0,&LOSPlot);
|
||||
}
|
||||
|
||||
I64 mp_not_done_flags;
|
||||
I64 *r1,*r2,*r3,*s2w,cx,cy,xh,yh,zh,x1h,y1h;
|
||||
|
||||
U0 MPDrawWalls(CDC *_dc)
|
||||
{
|
||||
CD3I32 poly[4];
|
||||
I64 i,j,n,cpu_num=Gs->num,xx,yy,x,y,x1,y1,z1,x2,y2,_x1h,_y1h,dx,dy,xx1,yy1,xx2,yy2,
|
||||
c,x1w,y1w,*_r3=MAllocIdentical(r3);
|
||||
Wall *tempw;
|
||||
CDC *dc=MAllocIdentical(_dc);
|
||||
dc->r=MAllocIdentical(_dc->r);
|
||||
_x1h=x1h-xh*cpu_num;
|
||||
_y1h=y1h-yh*cpu_num;
|
||||
for (j=cpu_num;j<PLOT_GRID_HEIGHT*2;j+=mp_cnt) {
|
||||
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<blueprint_width-1 && 1<=yy<blueprint_height-1 &&
|
||||
!LBts(panels_processed,yy*blueprint_width+xx)) {
|
||||
if ((c=blueprint[yy*blueprint_width+xx]) &&
|
||||
LOS(xx*SCREEN_SCALE+SCREEN_SCALE/2,yy*SCREEN_SCALE+SCREEN_SCALE/2,
|
||||
man_xx,man_yy)) {
|
||||
if (c==WHITE||c==LTBLUE)
|
||||
dc->color=BROWN;
|
||||
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 (!((yy*blueprint_width+xx)%3)) {
|
||||
if (c==GREEN) {
|
||||
x1=x+SCREEN_SCALE/2;
|
||||
y1=y+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc,&x1,&y1,&z1);
|
||||
if (z1>0)
|
||||
SpritePlotRotMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<4>",4$,_r3);
|
||||
} else if (c==BROWN) {
|
||||
x1=x+SCREEN_SCALE/2;
|
||||
y1=y+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc,&x1,&y1,&z1);
|
||||
if (z1>0)
|
||||
SpritePlotRotMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<5>",5$,_r3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
x1w-=yh;
|
||||
y1w+=xh;
|
||||
}
|
||||
_x1h-=xh*mp_cnt;
|
||||
_y1h-=yh*mp_cnt;
|
||||
}
|
||||
|
||||
tempw=walls_root.next;
|
||||
while (tempw!=&walls_root) {
|
||||
if (tempw->cpu_num==cpu_num) {
|
||||
dc->color=YELLOW;
|
||||
x1=tempw->p1.x*SCREEN_SCALE/BLUEPRINT_SCALE-man_xx;
|
||||
y1=tempw->p1.y*SCREEN_SCALE/BLUEPRINT_SCALE-man_yy;
|
||||
x2=tempw->p2.x*SCREEN_SCALE/BLUEPRINT_SCALE-man_xx;
|
||||
y2=tempw->p2.y*SCREEN_SCALE/BLUEPRINT_SCALE-man_yy;
|
||||
|
||||
//The foreshortening distorts Z coordinates in a funny way,
|
||||
//so we do the wall in tiny pieces.
|
||||
n=2*(AbsI64(x2-x1)+AbsI64(y2-y1))/SCREEN_SCALE;
|
||||
if (n<1) n=1;
|
||||
dx=(x2-x1)<<16/n;
|
||||
dy=(y2-y1)<<16/n;
|
||||
xx1=x1<<16;
|
||||
yy1=y1<<16;
|
||||
for (i=0;i<n;i++) {
|
||||
xx2=xx1+dx;
|
||||
yy2=yy1+dy;
|
||||
poly[0].x=xx1>>16;
|
||||
poly[0].y=yy1>>16;
|
||||
poly[0].z=0;
|
||||
poly[1].x=xx2>>16;
|
||||
poly[1].y=yy2>>16;
|
||||
poly[1].z=0;
|
||||
poly[2].x=xx2>>16;
|
||||
poly[2].y=yy2>>16;
|
||||
poly[2].z=WALL_HEIGHT*SCREEN_SCALE;
|
||||
poly[3].x=xx1>>16;
|
||||
poly[3].y=yy1>>16;
|
||||
poly[3].z=WALL_HEIGHT*SCREEN_SCALE;
|
||||
GrFillPoly3(dc,4,poly);
|
||||
xx1=xx2; yy1=yy2;
|
||||
}
|
||||
dc->color=BLACK;
|
||||
dc->pen_width=1;
|
||||
GrLine3(dc,x1,y1,0,x1,y1,WALL_HEIGHT*SCREEN_SCALE);
|
||||
GrLine3(dc,x2,y2,0,x2,y2,WALL_HEIGHT*SCREEN_SCALE);
|
||||
}
|
||||
tempw=tempw->next;
|
||||
}
|
||||
Free(_r3);
|
||||
Free(dc->r);
|
||||
Free(dc);
|
||||
LBtr(&mp_not_done_flags,cpu_num);
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,xx,yy,zz,x,y;
|
||||
U8 *temps;
|
||||
F64 tt;
|
||||
|
||||
cx=task->win_pixel_width/2;
|
||||
cy=task->win_pixel_height/2;
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
MemSet(panels_processed,0,(blueprint_width*blueprint_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=GrRotX(-ã/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=&DSTransform;
|
||||
dc->lighting=&DSLighting;
|
||||
dc->x=cx;
|
||||
dc->y=cy;
|
||||
r1=GrRotX(-ã/2,task);
|
||||
GrRotZEqu(r1,tT);
|
||||
GrScaleMatEqu(r1,PERSON_SCALE);
|
||||
|
||||
r2=GrIdent(task);
|
||||
GrScaleMatEqu(r2,PERSON_SCALE);
|
||||
|
||||
r3=GrRotX(-ã/2,task);
|
||||
GrScaleMatEqu(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;
|
||||
|
||||
mp_not_done_flags=1<<mp_cnt-1;
|
||||
for (i=0;i<mp_cnt;i++)
|
||||
JobQue(&MPDrawWalls,dc,i);
|
||||
while (mp_not_done_flags)
|
||||
Yield;
|
||||
|
||||
//Draw Persons
|
||||
for (i=0;i<NUM_PERSONS;i++) {
|
||||
x=persons[i].x;
|
||||
y=persons[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) {
|
||||
tt=2*Tri(tT,1.0);
|
||||
if (tt<1.0)
|
||||
temps=SpriteInterpolate($IB,"<2>",2$,$IB,"<1>",1$,tt);
|
||||
else
|
||||
temps=SpriteInterpolate($IB,"<1>",1$,$IB,"<3>",3$,tt-1.0);
|
||||
SpritePlotRotMat3B(dc,x,y,0,temps,r1);
|
||||
Free(temps);
|
||||
}
|
||||
}
|
||||
}
|
||||
Free(r1);
|
||||
Free(r2);
|
||||
Free(r3);
|
||||
|
||||
//Draw BluePrint heads-up display, scaled 2 pixels
|
||||
Free(dc->r);
|
||||
GrSetRotMat(dc,GrIdent(task));
|
||||
dc->x=task->win_pixel_width -2*blueprint_width;
|
||||
dc->y=task->win_pixel_height-2*blueprint_height;
|
||||
dc->z=0;
|
||||
dc->transform=&GrTransform;
|
||||
dc->pen_width=2;
|
||||
for (i=0;i<blueprint_height;i++)
|
||||
for (j=0;j<blueprint_width;j++) {
|
||||
dc->color=blueprint[(blueprint_height-1-i)*blueprint_width+j];
|
||||
GrPlot3(dc,2*j,2*i,0);
|
||||
}
|
||||
|
||||
//Draw Things on heads-up BluePrint
|
||||
dc->color=LTPURPLE;
|
||||
for (i=0;i<NUM_PERSONS;i++)
|
||||
GrPlot3(dc,2*(persons[i].x/SCREEN_SCALE),2*(blueprint_height-1-persons[i].y/SCREEN_SCALE),0);
|
||||
dc->color=LTCYAN;
|
||||
GrPlot3(dc,2*(man_xx/SCREEN_SCALE),2*(blueprint_height-1-man_yy/SCREEN_SCALE),0);
|
||||
|
||||
dc->color=LTGREEN;
|
||||
GrLine(dc,cx-5,cy,cx+5,cy);
|
||||
GrLine(dc,cx,cy-5,cx,cy+5);
|
||||
Free(s2w);
|
||||
}
|
||||
|
||||
U0 BluePrintDrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
task->text_attr=BLUE<<4+WHITE;
|
||||
GrBlot(dc,(task->win_pixel_width-blueprint_dc->width)>>1,
|
||||
(task->win_pixel_height-blueprint_dc->height)>>1,blueprint_dc);
|
||||
}
|
||||
|
||||
#define MAN_START_X 0
|
||||
#define MAN_START_Y 1
|
||||
|
||||
U0 MakeBluePrint()
|
||||
{
|
||||
I64 msg_code,i,x1,y1,x2,y2,p1,p2,color=WHITE,cpu_num=0;
|
||||
Wall *tempw;
|
||||
|
||||
DCFill(blueprint_dc,LTBLUE);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
|
||||
Fs->win_inhibit=WIF_ALL-WIF_BORDER;
|
||||
DocClear;
|
||||
|
||||
"Draw Floor Plan:
|
||||
|
||||
Walls in WHITE
|
||||
Tables in BROWN
|
||||
Plants in GREEN
|
||||
";
|
||||
|
||||
WinMax;
|
||||
WordStat;
|
||||
Fs->draw_it=&BluePrintDrawIt;
|
||||
|
||||
do {
|
||||
msg_code=GetMsg(&p1,&p2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+
|
||||
1<<MSG_IP_R_UP);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_R_UP:
|
||||
i=PopUpColor;
|
||||
if (i>=0) color=i;
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
if (color==WHITE) {
|
||||
p1-=(Fs->win_pixel_width-blueprint_dc->width)>>1;
|
||||
p2-=(Fs->win_pixel_height-blueprint_dc->height)>>1;
|
||||
x1=p1; y1=p2;
|
||||
x2=p1; y2=p2;
|
||||
blueprint_dc->color=ROP_XOR+color^LTBLUE;
|
||||
while (msg_code!=MSG_IP_L_UP) {
|
||||
GrLine(blueprint_dc,x1,y1,x2,y2);
|
||||
msg_code=GetMsg(&p1,&p2,
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
p1-=(Fs->win_pixel_width-blueprint_dc->width)>>1;
|
||||
p2-=(Fs->win_pixel_height-blueprint_dc->height)>>1;
|
||||
GrLine(blueprint_dc,x1,y1,x2,y2);
|
||||
x2=p1; y2=p2;
|
||||
}
|
||||
blueprint_dc->color=color;
|
||||
GrLine(blueprint_dc,x1,y1,x2,y2);
|
||||
|
||||
tempw=CAlloc(sizeof(Wall));
|
||||
tempw->p1.x=x1;
|
||||
tempw->p1.y=blueprint_dc->height-y1;
|
||||
tempw->p2.x=x2;
|
||||
tempw->p2.y=blueprint_dc->height-y2;
|
||||
tempw->cpu_num=cpu_num++%mp_cnt;
|
||||
QueIns(tempw,walls_root.last);
|
||||
} else {
|
||||
p1-=(Fs->win_pixel_width-blueprint_dc->width)>>1;
|
||||
p2-=(Fs->win_pixel_height-blueprint_dc->height)>>1;
|
||||
x1=p1; y1=p2;
|
||||
x2=p1; y2=p2;
|
||||
blueprint_dc->color=ROP_XOR+color^LTBLUE;
|
||||
while (msg_code!=MSG_IP_L_UP) {
|
||||
GrRectB(blueprint_dc,x1,y1,x2,y2);
|
||||
msg_code=GetMsg(&p1,&p2,
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
p1-=(Fs->win_pixel_width-blueprint_dc->width)>>1;
|
||||
p2-=(Fs->win_pixel_height-blueprint_dc->height)>>1;
|
||||
GrRectB(blueprint_dc,x1,y1,x2,y2);
|
||||
x2=p1; y2=p2;
|
||||
}
|
||||
blueprint_dc->color=color;
|
||||
GrRectB(blueprint_dc,x1,y1,x2,y2);
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_DOWN:
|
||||
break;
|
||||
}
|
||||
} while (msg_code!=MSG_KEY_DOWN || !p1);
|
||||
GetMsg(,,1<<MSG_KEY_UP);
|
||||
|
||||
SettingsPop;
|
||||
}
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,j,x,y,c,c1;
|
||||
QueInit(&walls_root);
|
||||
|
||||
blueprint_dc=DCNew(DCT_COLOR8,BLUEPRINT_SCALE*64,BLUEPRINT_SCALE*64);
|
||||
MakeBluePrint;
|
||||
|
||||
DocClear;
|
||||
"$$BG,LTGRAY$$"; NewLine(TEXT_ROWS/2-1);
|
||||
|
||||
blueprint_width =blueprint_dc->width/BLUEPRINT_SCALE;
|
||||
blueprint_height=blueprint_dc->height/BLUEPRINT_SCALE;
|
||||
Free(blueprint);
|
||||
Free(panels_processed);
|
||||
blueprint=MAlloc(blueprint_width*blueprint_height*sizeof(U8));
|
||||
MemSet(blueprint,WHITE,blueprint_width*blueprint_height);
|
||||
panels_processed=MAlloc((blueprint_width*blueprint_height+7)>>3);
|
||||
|
||||
for (y=1;y<blueprint_height-1;y++)
|
||||
for (x=1;x<blueprint_width-1;x++) {
|
||||
c=LTBLUE;
|
||||
for (i=0;i<BLUEPRINT_SCALE;i++)
|
||||
for (j=0;j<BLUEPRINT_SCALE;j++)
|
||||
if ((c1=GrPeek(blueprint_dc,x*BLUEPRINT_SCALE+i,y*BLUEPRINT_SCALE+j))!=LTBLUE)
|
||||
c=c1;
|
||||
blueprint[(blueprint_height-1-y)*blueprint_width+x]=c;
|
||||
}
|
||||
DCDel(blueprint_dc);
|
||||
|
||||
man_xx=(1+MAN_START_X)*SCREEN_SCALE;
|
||||
man_yy=(blueprint_height-1-MAN_START_Y)*SCREEN_SCALE;
|
||||
man_é=0;
|
||||
|
||||
for (i=0;i<NUM_PERSONS;i++) {
|
||||
do {
|
||||
persons[i].x=RandU64%((blueprint_width-2)*SCREEN_SCALE)+SCREEN_SCALE;
|
||||
persons[i].y=RandU64%((blueprint_height-2)*SCREEN_SCALE)+SCREEN_SCALE;
|
||||
} while (blueprint[(persons[i].y/SCREEN_SCALE)*blueprint_width+persons[i].x/SCREEN_SCALE]==WHITE);
|
||||
}
|
||||
tf=0;
|
||||
t0=tT;
|
||||
}
|
||||
|
||||
U0 AnimateTask(I64)
|
||||
{
|
||||
I64 i,x,y,dd;
|
||||
while (TRUE) {
|
||||
dd=0.25*SCREEN_SCALE*Sin(tT/2);
|
||||
for (i=0;i<NUM_PERSONS;i++) {
|
||||
x=persons[i].x;
|
||||
y=persons[i].y;
|
||||
if (i&1)
|
||||
x+=dd;
|
||||
else
|
||||
y+=dd;
|
||||
if (0<=x<=blueprint_width*SCREEN_SCALE &&
|
||||
0<=y<=blueprint_height*SCREEN_SCALE &&
|
||||
blueprint[(y/SCREEN_SCALE)*blueprint_width+x/SCREEN_SCALE]!=WHITE) {
|
||||
if (blueprint[(y/SCREEN_SCALE)*blueprint_width+x/SCREEN_SCALE+1]==WHITE &&
|
||||
x-RoundI64(x,SCREEN_SCALE)>SCREEN_SCALE/2 ||
|
||||
blueprint[(y/SCREEN_SCALE)*blueprint_width+x/SCREEN_SCALE-1]==WHITE &&
|
||||
x-RoundI64(x,SCREEN_SCALE)<SCREEN_SCALE/2)
|
||||
x=RoundI64(x,SCREEN_SCALE)+SCREEN_SCALE/2;
|
||||
if (blueprint[(y/SCREEN_SCALE+1)*blueprint_width+x/SCREEN_SCALE]==WHITE &&
|
||||
y-RoundI64(y,SCREEN_SCALE)>SCREEN_SCALE/2 ||
|
||||
blueprint[(y/SCREEN_SCALE-1)*blueprint_width+x/SCREEN_SCALE]==WHITE &&
|
||||
y-RoundI64(y,SCREEN_SCALE)<SCREEN_SCALE/2)
|
||||
y=RoundI64(y,SCREEN_SCALE)+SCREEN_SCALE/2;
|
||||
persons[i].x=x;
|
||||
persons[i].y=y;
|
||||
}
|
||||
}
|
||||
Sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
U0 CleanUp()
|
||||
{
|
||||
Free(blueprint);
|
||||
blueprint=NULL;
|
||||
Free(panels_processed);
|
||||
panels_processed=NULL;
|
||||
QueDel(&walls_root);
|
||||
}
|
||||
|
||||
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=Limit(x,0,blueprint_width*SCREEN_SCALE);
|
||||
y=Limit(y,0,blueprint_height*SCREEN_SCALE);
|
||||
color=blueprint[y/SCREEN_SCALE*blueprint_width+x/SCREEN_SCALE];
|
||||
if (color==LTBLUE || 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 DiningStars()
|
||||
{
|
||||
I64 sc;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Fwd(,,SC_CURSOR_UP);"
|
||||
" Backward(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
|
||||
Fs->text_attr=BROWN<<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_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
|
||||
CatchAll;
|
||||
DocClear;
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
MenuPop;
|
||||
AcctRegWriteBranch("TempleOS/DiningStars","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
DiningStars;
|
||||
| ||||