TempleOSTS_130707.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:45 +02:00
1 parent 17b71f1a2d
commit 1343005a29
617 files changed
+14399 -25130

No files matched your search

-1
View File
@@ -5,5 +5,4 @@
Cd("HOME");;
#include "/TempleOS/Accts/TS/TSAdam"
#include "/TempleOS/Accts/TS/TSDistro"
#include "/TempleOS/Demo/WebLogExample/WebLogRep"
Cd("HOME");;
+10 -10
View File
@@ -3,13 +3,13 @@
U0 FillInTime()
{
CDate spdt;
spdt=GetCurTimeCDate;
"$$IV,1$$----%D %T----$$IV,0$$\n",spdt,spdt;
CDate cdt;
cdt=GetCurTimeDate;
"$$IV,1$$----%D %T----$$IV,0$$\n",cdt,cdt;
}
U0 RandQuote(I64 num)
{ //$LK-A,"::/TempleOS/Apps/AfterEgypt/AENotes.TXT"$
{ //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
I64 i,size,l=512;
U8 *bible_filename=Define("ST_BIBLE_FILE"),
*buf=FileRead(bible_filename,&size);
@@ -22,7 +22,7 @@ U0 RandQuote(I64 num)
}
U0 BadCodeJump(I64 num)
{ //$LK-A,"::/TempleOS/Apps/AfterEgypt/AENotes.TXT"$
{ //$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;
@@ -129,7 +129,7 @@ Bool MyPutKey(I64 ch,I64 sc)
else
SetKeyDesc("God Word");
} else {
//$LK-A,"::/TempleOS/Apps/AfterEgypt/AENotes.TXT"$
//$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
if (sc & SCF_SHIFT)
RandQuote(KbdMouseEvtTime>>4);
else
@@ -157,7 +157,7 @@ Bool MyPutKey(I64 ch,I64 sc)
SetKeyDesc("Misc/Insert Datetime");
} else {
if (sc & SCF_SHIFT)
DocInsSafe(DocCur,
DocInsSafe(DocPut,
"$$HS+C$$$$FG$$$$HE$$");
else
FillInTime();
@@ -202,7 +202,7 @@ Bool MyPutKey(I64 ch,I64 sc)
else {
ClipBoardDel;
DocPrintF(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
DocCur->filename.name,DocCur->cur_entry->y+1);
DocPut->filename.name,DocPut->cur_entry->y+1);
}
return TRUE;
case 'L':
@@ -212,7 +212,7 @@ Bool MyPutKey(I64 ch,I64 sc)
i=RandU32;
ClipBoardDel;
DocPrintF(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
DocCur->filename.name,i);
DocPut->filename.name,i);
"$$AN,\"<TODO>\",\"ANC%d\"$$",i;
}
return TRUE;
@@ -234,7 +234,7 @@ Bool MyPutKey(I64 ch,I64 sc)
case 'b':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Cmd/Jump to Bad Code");
else //$LK-A,"::/TempleOS/Apps/AfterEgypt/AENotes.TXT"$
else //$LK-A,"::/TempleOS/Apps/HolySpirit/HSNotes.TXT"$
BadCodeJump(KbdMouseEvtTime>>4);
return TRUE;
+2 -3
View File
@@ -1,7 +1,6 @@
U0 UserStartUp()
{ //Run each time a user a spawned
UseTermDoc;
DocCurAttr(WHITE<<4+BLUE);
Type("::/TempleOS/Doc/Start.TXT");
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinZBufUpdate;
@@ -22,8 +21,8 @@ U0 UserStartUp()
CPURep;
}
U0 ServantStartUp()
{ //Run each time a servant task is spawned.
U0 SrvStartUp()
{ //Run each time a srv task is spawned.
UseTermDoc;
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinZBufUpdate;
+11
View File
@@ -0,0 +1,11 @@
//This is executed by Adam at boot.
//See $LK,"Adam1 Start-up","FF:::/TempleOS/Kernel/KEnd.CPP,Adam1:2"$
extern I8i OptEqu(I64i num,I8i val);
OptEqu(0,0); //(0,0)=EchoOff (0,1)=EchoOn
#include "/TempleOS/Kernel/BootDefs.HPP"
#include "/TempleOS/Kernel/Adam1a.HPP"
#include "/TempleOS/Compiler/CmpDefs.HPP"
#include "/TempleOS/Kernel/Adam1b.HPP"
#include "/TempleOS/Kernel/Adam1c.HPP"
#include "/TempleOS/Compiler/Compiler.HPP"
Dbg("Type 'G;'");
+1 -1
View File
@@ -1,6 +1,6 @@
//This file is executed by the
//first terminal window upon start-up.
//See $LK,"DoItOnce","FF:HOME/Adam3fSys.CPP,DoItOnce"$.
//See $LK,"DoItOnce","FF:HOME/Adam3fSys.CPP,DoItOnce"$ and $LK,"Acct Files","FF:::/TempleOS/Doc/GuideLines.TXT,ACCT FILES"$.
//It goes in your HOME directory and
//you can customize it.
Binary file not shown.
@@ -5,7 +5,6 @@
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
#include "HOME/Adam3aLocalize"
#include "HOME/Adam3bPkgs"
#include "HOME/Adam3cSnd"
#include "HOME/Adam3dKeyPlugIns"
#include "HOME/Adam3eWrappers"
#include "HOME/Adam3fSys"
@@ -7,8 +7,6 @@ SetTypeMatic(0);
//Set Time Zone
local_time_offset=-7*60*60*CDATE_FREQ; //Pacific
snd_vol=0.1;
//$AN,"","mouse_move_scale"$adjust these to set mouse move scale
mxx_scale=0.5;
myy_scale=0.5;
@@ -1,488 +0,0 @@
//ISO1 is ISO9660
//ISO2 is ISO13490
//ISO3 is ISO13346
//ISO13346 tag id types
#define ISO3T_PRI_VOL_DESC 1
#define ISO3T_ANCHOR_VOL_DESC_PTR 2
#define ISO3T_VOL_DESC_PTR 3
#define ISO3T_IMPLEMENTATION_VOL_DESC 4
#define ISO3T_PRT_DESC 5
#define ISO3T_LOG_VOL_DESC 6
#define ISO3T_UNALLOCATED_SPACE_DESC 7
#define ISO3T_TERMINATOR_DESC 8
#define ISO3T_LOG_VOL_INTEGRITY_DESC 9
#define ISO3T_FILE_SET_DESC 256
#define ISO3T_FILE_ID_DESC 257
#define ISO3T_ALLOC_EXTENT_DESC 258
#define ISO3T_INDIRECT_ENTRY 259
#define ISO3T_TERMINAL_ENTRY 260
#define ISO3T_FILE_ENTRY 261
#define ISO3T_EXT_ATTR_HEADER_DESC 262
#define ISO3T_UNALLOC_SPACE_ENTRY 263
#define ISO3T_SPACE_BITMAP_DESC 264
#define ISO3T_PRT_INTEGRITY_ENTRY 265
#define ISO3T_EXT_FILE_ENTRY 266
class CISO3Tag
{
U16 id;
U16 version;
U8 xsum;
U8 reserved;
U16 serial_num;
U16 desc_crc;
U16 desc_crc_len;
U32 loc;
};
class CISO3Date
{
U16 time_zone;
I16 year;
U8 mon;
U8 day;
U8 hour;
U8 min;
U8 sec;
U8 sec100;
U8 sec10000;
U8 sec1000000;
};
class CISO3DString32
{
U8 body[31];
U8 len;
};
class CISO3DString128
{
U8 body[127];
U8 len;
};
class CISO3CharSpec
{
U8 type;
U8 body[63];
};
class CISO3RegId
{
U8 flags;
U8 id[23];
U8 id_suffix[8];
};
class CISO3ExtentAD
{
U32 len;
U32 loc;
};
class CISO3LBAdd
{
U32 log_blk_num;
U16 prt_ref_num;
};
class CISO3LongAD
{
U32 len;
CISO3LBAdd loc;
U8 implementation_use[6];
};
class CISO3ICBTag
{
U32 prior_record_direct_entries;
U16 strategy_type;
U16 strategy_param;
U16 max_entries;
U8 reserved;
U8 file_type;
CISO3LBAdd parent_icb_loc;
U16 flags;
};
class CISO3PriDesc
{
CISO3Tag tag;
U32 vol_desc_seq_num;
U32 pri_vol_desc_num;
CISO3DString32 vol_id;
U16 vol_seq_num;
U16 max_vol_seq_num;
U16 interchg_level;
U16 max_interchg_level;
U32 char_set_lst;
U32 max_char_set_lst;
CISO3DString128 vol_set_id;
CISO3CharSpec desc_char_set;
CISO3CharSpec explanatory_char_set;
CISO3ExtentAD vol_abstract;
CISO3ExtentAD vol_copyright_notice;
CISO3RegId app_id;
CISO3Date recording_date_time;
CISO3RegId implementation_id[32];
U8 implementation_use[64];
U32 pred_vol_desc_seq_loc;
U16 flags;
U8 reserved[22];
};
class CISO3PrtMap
{
U8 type;
U8 len;
U0 mapping;
};
class CISO3PrtMap1
{
U8 type;
U8 len;
U16 vol_seq_num;
U16 prt_num;
};
class CISO3PrtMap2
{
U8 type;
U8 len;
U8 prt_id[62];
};
class CISO3LogVolDesc
{
CISO3Tag tag;
U32 vol_desc_seq_num;
CISO3CharSpec desc_char_set;
CISO3DString128 log_vol_id;
U32 blk_size;
CISO3RegId domain_id;
U8 log_vol_contents_use[16];
U32 map_table_len;
U32 num_prt_maps;
CISO3RegId implementation_id;
U8 implementation_use[128];
CISO3ExtentAD integrity_seq_extent;
U0 prt_maps;
};
class CISO3Prt
{
CISO3Tag tag;
U32 vol_desc_seq_num;
U16 flags;
U16 num;
CISO3RegId contents;
U8 contents_use[128];
U32 access_type;
U32 starting_loc;
U32 len;
CISO3RegId implementation_id;
U8 implementation_use[128];
U8 reserved[156];
};
class CISO3FileSetDesc
{
CISO3Tag tag;
CISO3Date recording_date_time;
U16 interchg_level;
U16 max_interchg_level;
U32 char_set_lst;
U32 max_char_set_lst;
U32 file_set_num;
U32 file_set_desc_num;
CISO3CharSpec log_vol_id_char_set;
CISO3DString128 log_vol_id;
CISO3CharSpec file_set_char_set;
CISO3DString32 file_set_id;
CISO3DString32 copyright_file_id;
CISO3DString32 abstract_file_id;
CISO3LongAD root_dir_icb;
CISO3RegId domain_id;
CISO3LongAD next_extent;
CISO3LongAD sys_stream_dir_icb;
U8 reserved[32];
};
class CISO3FileIdDesc
{
CISO3Tag tag;
U16 version;
U8 characteristics;
U8 len_of_file_id;
CISO3LongAD icb;
U16 len_of_implementation_use;
U0 implementation_use;
U0 file_id;
};
class CISO3File
{
CISO3Tag tag;
CISO3ICBTag icb_tag;
U32 uid;
U32 gid;
U32 permissions;
U16 file_link_cnt;
U8 record_fmt;
U8 record_display_attr;
U32 record_len;
I64 info_len;
I64 log_blks_recorded;
CISO3Date access_date_time;
CISO3Date modification_date_time;
CISO3Date attr_date_time;
U32 chk_pt;
CISO3LongAD ext_attr_icb;
CISO3RegId implementation_id;
I64 unique_id;
U32 ext_attr_len;
U32 alloc_desc_len;
U0 ext_attr;
U0 alloc_desc;
};
class CISO3FileExt
{
CISO3Tag tag;
CISO3ICBTag icb_tag;
U32 uid;
U32 gid;
U32 permissions;
U16 file_link_cnt;
U8 record_fmt;
U8 record_display_attr;
U32 record_len;
I64 info_len;
I64 object_size;
I64 log_blks_recorded;
CISO3Date access_date_time;
CISO3Date modification_date_time;
CISO3Date creation_date_time;
CISO3Date attr_date_time;
U32 chk_pt;
U32 reserved;
CISO3LongAD ext_attr_icb;
CISO3LongAD stream_dir_icb;
CISO3RegId implementation_id;
I64 unique_id;
U32 ext_attr_len;
U32 alloc_desc_len;
U0 ext_attr;
U0 alloc_desc;
};
import U0 ClassRep(U8 *class_name,U8 *d,I64 max_depth=2,Bool fun=FALSE,I64 offset=0);
Bool ISO3PrtInitPrt(CPrt *p,I64 blk)
{
CBlkDev *bdev=p->bdev;
I64 spc=bdev->blk_size>>BLK_SIZE_BITS,i=blk/spc;
CISO3FileSetDesc *iso=MAlloc(bdev->blk_size);
Bool unlock,result=FALSE;
try {
unlock=PrtLock(p);
while (TRUE) {
p->size=MaxI64(p->size,(i+1)*spc);
RBlks(p,iso,i*spc,spc);
"%X:%X\n",i,iso->tag.id;
switch (iso->tag.id) {
case ISO3T_FILE_SET_DESC:
ClassRep("CISO3FileSetDesc",iso,3);
// p->offset=blk;
// p->root_cluster=iso->root_dir_icb.loc.log_blk_num+p->offset/spc;
result=TRUE;
break;
case ISO3T_EXT_FILE_ENTRY:
ClassRep("CISO3FileExt",iso,3);
break;
case ISO3T_FILE_ENTRY:
ClassRep("CISO3File",iso,3);
break;
case ISO3T_FILE_ID_DESC:
ClassRep("CISO3FileIdDesc",iso,3);
break;
case ISO3T_ALLOC_EXTENT_DESC:
case ISO3T_INDIRECT_ENTRY:
case ISO3T_TERMINAL_ENTRY:
case ISO3T_EXT_ATTR_HEADER_DESC:
case ISO3T_UNALLOC_SPACE_ENTRY:
case ISO3T_SPACE_BITMAP_DESC:
case ISO3T_PRT_INTEGRITY_ENTRY:
break;
default
goto i3pip_done;
}
i++;
}
i3pip_done:
Free(iso);
if (unlock)
PrtUnlock(p);
} catch {
Free(iso);
if (unlock)
PrtUnlock(p);
}
return result;
}
Bool ISO3PrtInit(CPrt *p,I64 blk)
{
CBlkDev *bdev=p->bdev;
I64 spc=bdev->blk_size>>BLK_SIZE_BITS,i=blk/spc,offset=0;
CISO3Prt *iso=MAlloc(bdev->blk_size);
Bool unlock,result=FALSE;
try {
unlock=PrtLock(p);
while (TRUE) {
p->size=MaxI64(p->size,(i+1)*spc);
RBlks(p,iso,i*spc,spc);
"%X:%X\n",i,iso->tag.id;
switch (iso->tag.id) {
case ISO3T_PRT_DESC:
ClassRep("CISO3Prt",iso,3);
offset=iso->starting_loc*spc; //one partition for now
break;
case ISO3T_PRI_VOL_DESC:
ClassRep("CISO3PriDesc",iso,3);
break;
case ISO3T_LOG_VOL_DESC:
ClassRep("CISO3LogVolDesc",iso,3);
D(&iso(CISO3LogVolDesc *)->prt_maps);
break;
case ISO3T_ANCHOR_VOL_DESC_PTR:
case ISO3T_VOL_DESC_PTR:
case ISO3T_IMPLEMENTATION_VOL_DESC:
case ISO3T_UNALLOCATED_SPACE_DESC:
case ISO3T_LOG_VOL_INTEGRITY_DESC:
break;
case ISO3T_TERMINATOR_DESC:
goto i3pi_done;
default:
PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM");
throw(EXCEPT_PRT,10);
}
i++;
}
i3pi_done:
if (offset)
result=ISO3PrtInitPrt(p,offset);
Free(iso);
if (unlock)
PrtUnlock(p);
} catch {
Free(iso);
if (unlock)
PrtUnlock(p);
}
return result;
}
/****
U0 CDate2ISO3(CISO3Date *dst,CDate spdt)
{
CDateStruct ds;
CDate2CDateStruct(&ds,spdt);
MemSet(dst,0,sizeof(CISO3Date));
dst->year=ds.year;
dst->mon=ds.mon;
dst->day=ds.day_of_mon;
dst->hour=ds.hour;
dst->min=ds.min;
dst->sec=ds.sec;
dst->sec100=ds.sec100;
}
CDate ISO3Date2CDate(CISO3Date *dt)
{
CDateStruct ds;
MemSet(&ds,0,sizeof(CDateStruct));
ds.day_of_mon=dt->day;
ds.mon=dt->mon;
ds.year=dt->year;
ds.sec100=dt->sec100;
ds.sec=dt->sec;
ds.min=dt->min;
ds.hour=dt->hour;
return CDateStruct2CDate(&ds);
}
****/
Bool ISOPrtInit(CPrt *p,I64 blk)
{
CBlkDev *bdev=p->bdev;
I64 spc=bdev->blk_size>>BLK_SIZE_BITS,i=blk/spc;
CISO1PriDesc *iso=MAlloc(bdev->blk_size);
CISO1DirEntry *de;
Bool unlock,result=FALSE;
U8 buf[8];
try {
unlock=PrtLock(p);
p->type=PT_ISO9660; //default
p->spc=spc;
p->offset=p->data=p->root_cluster=p->size=0;
while (TRUE) {
p->size=MaxI64(p->size,(i+1)*spc);
RBlks(p,iso,i*spc,spc);
buf[0](U32)=iso->id[0](U32);
buf[4](U16)=iso->id[4](U8);
switch (LstEntryMatch(buf,"CD001\0CDW02\0BEA01\0BOOT2\0NSR02\0NSR03\0TEA01\0",LEF_EXACT)) {
case 0:
p->type=PT_ISO9660;
switch (iso->type) {
case ISO1T_SUPPLEMENTARY_DESC:
p->data=0;
de=&iso->root_dir_record;
p->root_cluster=de->loc.little;
p->size=iso->vol_space_size.little*bdev->blk_size>>BLK_SIZE_BITS;
result=TRUE;
goto ipi_done;
case ISO1T_TERMINATOR:
throw(EXCEPT_PRT,11);
}
break;
case 2...6:
p->type=PT_ISO13346;
break;
case 1: //PT_ISO13490 (Not supported)
default: //Its normal for ISO13346 to read NULL blk as terminator
switch (p->type) {
case PT_ISO13346:
i++; //Terminator is blk after last valid. Advance to next blk
if (ISO3PrtInit(p,i*spc)) {
result=TRUE;
goto ipi_done;
}
break;
}
PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM");
throw(EXCEPT_PRT,12);
}
i++;
}
ipi_done:
Free(iso);
if (unlock)
PrtUnlock(p);
} catch {
p->type=PT_ISO9660;
p->spc=spc;
p->offset=p->data=p->root_cluster=0;
Free(iso);
if (unlock)
PrtUnlock(p);
}
return result;
}
Binary file not shown.
@@ -1,21 +0,0 @@
$WW,1$I have a million metaphors. Linux is a semi; Windows is a car; and TempleOS is a motorcycle. Or, it's like a 1960's muscle car that wouldn't be street legal, now, with all the safety crap regulations complicating and gunking-up, but boy is it fun and beautiful under the hood. Maybe, it's a tree-house -- you don't need building codes to mod it and it has no networking. It's a kayak, not a Titanic -- just reset it. Why do you want a 1970's main frame operating system, anyway, that has ugly 32-bit crap all over its C language? 7-bit ASCII for source code? Please! Why not fix all the standard C library to pure 64-bit? How awful PrintF() with "%ld" instead of "%d" and crap for long constants! Yuck! You'll love $LK,"TempleOS C","FI:::/TempleOS/Doc/Differences.TXT"$.
Okay, here's a $LK,"Pop Quiz","FI:::/TempleOS/Demo/Lectures/64BitAsmQuiz.TXT"$ to get you psyched-up for TempleOS! Assembly language knowledge is not required, but anyone interested in TempleOS is probably at least curious about assembly language.
TempleOS has a good chance of running natively on $FG,4$x86_64$FG$ machines from about 2003-2010. After that, it will probably work just in VMware.
1) Download the free $FG,4$$TX+HTML,"TempleOSCD.ISO (24.0 MB)","http://www.templeos.org/TempleOSCD.ISO"$$FG$.
2) Download the free $FG,4$$TX+HTML,"VMware Player","https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0"$$FG$ (The $FG,4$$TX+HTML,"VMware","https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0"$$FG$ web page takes a whole minute to load completely. Be patient. When it finally shows, pick the first ".exe" to download.)
3) Create an "Other 64-Bit" virtual machine. Aim its CD-ROM to TempleOSCD.ISO
4) Play the virtual machine.
5) Log-in as "Accts/Install".
6) Optionally, purchase $FG,4$$TX+HTML,"VMware WorkStation","http://www.vmware.com"$$FG$ or download $FG,4$$TX+HTML,"WinImage","http://www.winimage.com/winimage.htm"$$FG$ if you wish to transfer files in and out.
If you want to install my personal version for $FG,4$$TX+HTML,"VMware","https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0"$$FG$...
1b) Download the free $FG,4$$TX+HTML,"TempleOSTS.ISO (24.5 MB)","http://www.templeos.org/TempleOSTS.ISO"$$FG$.
3b) Create an "Other 64-Bit" virtual machine. Aim its CD-ROM to TempleOSTS.ISO
5b) Type >$FG,4$TSInstall;$FG$ or >$FG,4$TSUpgrade;$FG$ at the command-line.
7b) See $FG,4$MakeBackUp$FG$ to reproduce the ISO's in $FG,4$E:/Wb$FG$. It makes this website, too.
* "WinImage" is a trademark of Gilles Vollant.
@@ -1,217 +0,0 @@
/*
You can play with this if you are
interested in USB. I'm not planning
on doing USB unless the legacy PS2
keyboard/mouse mode disappears.
There EHCI UHCI in various ICH chips and
others and God knows how many custom packet
formats for different keyboards and mice. Okay,
I suppose if BIOS can make a universal
packet, it is done just one way for
different mice. PS2 is more compatible.
*/
#help_index "USB"
extern I64 sys_num_usb;
extern CUSB sys_usb_devs[MAX_USB];
extern CUSBTD *USBAllocTD();
extern U0 USBFreeTD(CUSBTD *temptd);
extern U0 USBEndAll();
extern U0 USBInitAll();
extern U32 *USBAllocFrameLst(I64 usb_num,I64 size);
U8 *StatCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
{ //This routine shows the stat of the USB ports
U8 *st=MAlloc(128,mem_task);
U16 w1,w2,w3,w4;
U32 d1;
CUSB *u=doc_e->user_data;
I64 d=u->ports;
w3=InU16(d+USBP_STS);
w1=InU16(d+USBP_PORTSC0); w2=InU16(d+USBP_PORTSC1);
w4=InU16(d+USBP_FRNUM);
d1=InU32(d+USBP_FRBASEADD);
SPrintF(st,"%X:Stat:%04X P0:%04X P1:%04X FRAME:%04X",d1,w3,w1,w2,w4);
return st;
}
U0 PutStat()
{
I64 i;
Bool old_preempt=Preempt(OFF);
CDocEntry *doc_e;
CUSB *u;
WinMax;
"$$FG,GREEN$$Dev Stat Bits\n$$FG$$"
" 0:IRQ\n"
" 1:IRQ err\n"
" 2:Resume\n"
" 3:Host Sys Err\n"
" 4:Host Process Err\n"
" 5:Halted\n"
"$$FG,GREEN$$Port Stat Bits\n$$FG$$"
" 0:Connection Stat\n"
" 1:Connection Stat Change\n"
" 2:Port Enabled\n"
" 3:Port Enabled Change\n"
"4-5:Line Stat\n"
" 6:Resume Detect\n"
" 8:Low Speed\n"
" 9:Port Rst\n"
" 10:Overcurrent Active\n"
" 11:Overcurrent Indicator\n"
" 12:Suspend\n\n";
for (i=0;i<sys_num_usb;i++) {
u=&sys_usb_devs[i];
"$$FG,LTRED$$Dev%d:%X:",i,u->ports;
doc_e=DocPutS(DocCur,"$$TX+TC,\" \"$$");
doc_e->user_data=&sys_usb_devs[i];
doc_e->tag_cb=&StatCB;
"$$FG$$\n";
}
Preempt(old_preempt);
NewLine;
}
extern U0 PutQH(U32 h);
U32 *P(U32 d)
{
return d&~3;
}
U0 PutTD(U32 t)
{
"TD:$$FG,GREEN$$%08X$$FG$$\n",t;
"%08X\n",*P(t);
DocDm(t+4,8);
if (*P(t+12))
DocDm(*P(t+12),16);
// DocDm(*P(t+12),*P(t+4)>>21&0x7FF);
if (!(*P(t)&1)) {
if (*P(t)&2)
PutQH(*P(t));
else
PutTD(*P(t));
}
}
U0 PutQH(U32 h)
{
"QH:$$FG,RED$$%08X$$FG$$\n",h;
"%08X\n",*P(h);
"%08X\n",*P(h+4);
if (!(*P(h)&1)) {
if (*P(h)&2)
PutQH(*P(h));
else
PutTD(*P(h));
}
if (!(*P(h+4)&1)) {
if (*P(h+4)&2)
PutQH(*P(h+4));
else
PutTD(*P(h+4));
}
}
U0 PutFrame(U32 f)
{
PutQH(f);
}
U0 PutFrames()
{
I64 i,d,f,w1,w2;
CUSB *u;
for (i=0;i<sys_num_usb;i++) {
u=&sys_usb_devs[i];
d=u->ports;
w1=InU16(d+USBP_PORTSC0); w2=InU16(d+USBP_PORTSC1);
if (w1&1 || w2&1) {
f=InU32(d+USBP_FRBASEADD);
PutFrame(f);
}
}
}
U0 Main()
{
USBInitAll;
PutStat;
PutFrames;
"$$FG,RED$$The BIOS sets-up the USB in PS/2 legacy mode.$$FG$$\n";
}
Main;
/* Not Finished
#define PORT 5
#define DEV_ADD_INIT 1
#define DEV_ADD 1
#define END_PT0 0
#define END_PT1 1
#define END_PT2 2
#define MAX_LEN 8
#define TERMINATE 1
U0 SetUpTD()
{
CUSB *u=&sys_usb_devs[PORT];
I64 i,d=u->ports;
U32 *frm=CAllocAligned(0x1000,0x1000,Fs->code_heap),
*tds=CAllocAligned(256,16,Fs->code_heap),
*buf=CAlloc(128,Fs->code_heap);
DocD(buf,128);
"<0>\n"; Sleep(100);
OutU16(d+USBP_CMD,2); //Reset
"<1>\n"; Sleep(100);
OutU16(d+USBP_CMD,0);
"<2>\n"; Sleep(100);
OutU16(d+USBP_PORTSC0,4); //Enable
OutU16(d+USBP_PORTSC1,4);
"<3>\n"; Sleep(100);
tds[0]=&tds[4](U8 *);
tds[1]=0;
tds[2]=PID_SETUP+DEV_ADD_INIT<<8+END_PT0<<15+MAX_LEN<<21;
tds[3]=buf;
buf[0]=0+RQ_SET_ADDR<<8+DEV_ADD<<16;
buf[1]=0+0<<16;
tds[4]=TERMINATE;
tds[5]=0;
tds[6]=PID_SETUP+DEV_ADD_INIT<<8+END_PT0<<15+MAX_LEN<<21;
tds[7]=buf(U8 *)+8;
buf[2]=0+RQ_SET_ADDR<<8+DEV_ADD<<16;
buf[3]=0+0<<16;
frm[0]=&tds[0](U8 *);
for (i=1;i<0x1000/4;i++)
frm[i]=TERMINATE;
OutU16(d+USBP_FRNUM,frm);
OutU32(d+USBP_FRBASEADD,frm);
"<4>\n"; Sleep(200);
OutU16(d+USBP_CMD,1);
"<5>\n"; Sleep(1000);
OutU16(d+USBP_CMD,0);
"<6>\n"; Sleep(200);
}
SetUpTD;
*/
@@ -1,114 +0,0 @@
#define USBP_CMD 0x00
#define USBP_STS 0x02
#define USBP_INTR 0x04
#define USBP_FRNUM 0x06
#define USBP_FRBASEADD 0x08
#define USBP_SOFMOD 0x0C
#define USBP_PORTSC0 0x10
#define USBP_PORTSC1 0x12
#define MAX_USB 16
class CUSBTD //Not implemented
{
U32 td[4];
};
class CUSB //Not implemented
{
U8 num, //USB dev num
bus,dev,fun;
U16 ports,pad;
U32 *frame_lst;
};
//USB Pkt ID's
#define PID_OUT 0xE1
#define PID_IN 0x69
#define PID_SOF 0xA5
#define PID_SETUP 0x2D
#define PID_DATA0 0xC3
#define PID_DATA1 0x4B
#define PID_DATA2 0x87
#define PID_MDATA 0x0F
#define PID_ACK 0xD2
#define PID_NAK 0x5A
#define PID_STALL 0x1E
#define PID_NYET 0x96
#define PID_PRE 0x3C
#define PID_ERR 0x3C
#define PID_SPLIT 0x78
#define PID_PING 0xB4
//USB Std Rqsts
#define RQ_GET_STAT 0x0
#define RQ_CLR_FEAT 0x1
#define RQ_SET_FEAT 0x3
#define RQ_SET_ADDR 0x5
#define RQ_SET_DESC 0x7
#define RQ_GET_CFG 0x8
#define RQ_SET_CFG 0x9
#define RQ_GET_INTERFACE 0xA
#define RQ_SET_INTERFACE 0xB
#define RQ_SYNC_FRAME 0xC
I64 sys_num_usb=0;
CUSB sys_usb_devs[MAX_USB];
MemSet(sys_usb_devs,0,MAX_USB*sizeof(CUSB));
U0 USBInitOne(I64 b,I64 d,I64 f)
{
CUSB *u;
if (sys_num_usb<MAX_USB &&
PCIReadU16(b,d,f,0)==0x8086) {
u=&sys_usb_devs[sys_num_usb++];
u->num=sys_num_usb;
u->bus=b;
u->dev=d;
u->fun=f;
u->ports=PCIReadU32(b,d,f,0x20)&~0x1F;
}
}
U0 USBEndAll()
{
sys_num_usb=0;
}
U0 USBInitAll() //This is only valid for my ICH10 dev
{
if (sys_num_usb)
USBEndAll;
USBInitOne(0,29,0);
USBInitOne(0,29,1);
USBInitOne(0,29,2);
USBInitOne(0,29,3);
USBInitOne(0,26,0);
USBInitOne(0,26,1);
USBInitOne(0,26,2);
}
CUSBTD *USBAllocTD()
{
return MAllocAligned(sizeof(CUSBTD),0x10,sys_uncached_heap);
}
U0 USBFreeTD(CUSBTD *temptd)
{
Free(temptd);
}
U32 *USBAllocFrameLst(I64 usb_num,I64 size)
{ //aligned to 0x1000
CUSB *u;
if (0<=usb_num<sys_num_usb) {
u=&sys_usb_devs[usb_num];
Free(u->frame_lst);
u->frame_lst=MAllocAligned(size*sizeof(U32),0x1000,sys_uncached_heap);
OutU16(u->ports+USBP_CMD,0); //Stop
OutU16(u->ports+USBP_FRNUM,0);
OutU32(u->ports+USBP_FRBASEADD,u->frame_lst);
return u->frame_lst;
}
return NULL;
}
@@ -1,54 +0,0 @@
/*$HL,0$
$FG,5$$TX+CX,"Roll Your Own Distro"$$FG$
It's unlikely you will get it running on bare hardware, so you'll probably
run it in a virtual machine such as VMware. Download the free 64-bit
$FG,4$$TX+HTML,"VMware Player","https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0"$$FG$ for Linux or Windows and point the CDROM at the $FG,4$$TX+HTML,"TempleOSCD.ISO","http://www.templeos.org/TempleOSCD.ISO"$$FG$.
(The $FG,4$$TX+HTML,"VMware","https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0"$$FG$ web page takes a whole minute to load. They hide the free version.)
Purchase $FG,4$$TX+HTML,"VMware WorkStation","http://www.vmware.com"$$FG$ or download $FG,4$$TX+HTML,"WinImage","http://www.winimage.com/winimage.htm"$$FG$ if you wish to transfer files
in and out. The VMWare Workstation will stretch to full-screen and make drives
accessible from Windows.
$HL,1$*/
#define STD_DISTRO_CDROM_CFG "b10x20000\nt3 \n\n\n\n\n"
U0 MakeMyISO(U8 *out_iso_filename)
{//Does everything with current drive.
if (!IsDrvWritable) {
"Drive must be writable. Install on Hard drive, first.\n";
return;
}
DelTree("/Distro");
Auto(STD_DISTRO_CDROM_CFG);
MakeOSInstallPrtBootLoader(,'T');
CopyTree("/0000Boot","/Distro/0000Boot");
CopyTree("/TempleOS","/Distro/TempleOS");
//To save space, optionally delete dictionary.
Del("/Distro/TempleOS/Adam/WordStat/WSDefs.DAT");
Del("/Distro/TempleOS/Misc/Bible.TXT.Z");
Del("/Distro/TempleOS/Misc/PCIDevices.TXT.Z");
MkDir("/Distro/Temp");
MkDir("/Distro/Temp/ScreenShots");
CDFileCreate(out_iso_filename,"/Distro/*","",BOOTCD_BIN_Z);
//CDImageWrite('T',out_iso_filename,MT_CD); //Uncomment to burn a CD-ROM or (MT_DVD)
//DelTree("/Distro");
}
MakeMyISO("/MyDistro.ISO");
// Study my account examples $LK,"Cfg Strs","FL:::/TempleOS/Demo/AcctExample/TSAdam.CPP,1"$ $LK,"Update Funs","FL:::/TempleOS/Demo/AcctExample/TSDistro.CPP,1"$.
/*
* "Linux" is probably a trademark owned by Linus Torvalds.
* "VMware Player" and "VMware WorkStation" are trademarks of VMware, Inc.
* "Windows" is a trademark of MicroSoft Corp.
* "WinImage" is a trademark of Gilles Vollant.
*/
+28 -28
View File
@@ -1,23 +1,32 @@
* Cursor is not solid $LK,"Dbg","MN:Dbg"$ when entered in Adam2.
* fix result on Blot ect
* ata base- base1 temp blkdev
* 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","MN:Circle"$(), $LK,"Ellipse","MN:Ellipse"$(), $LK,"GrRot","MN:GrRot"$(), $LK,"GrMulMat","MN:GrMulMat"$() and others.
God says I might want to change to float.
$LK-A,"::/TempleOS/Demo/Lectures/FixedPoint.CPP"$.
$LK-A,"::/TempleOS/Demo/Lectures/FixedPointAdvanced.CPP"$.
* DOCF_DBL_DOLLARS in reindention
* # in reindention
* reindent $LK,"DocRecalc","MN:DocRecalc"$().skip_soft_cr
* HexEdit with odd size, ASCII cannot be edited.
* clean-up addDev pmt
* indent
* TestSuite Strut
* Might want to convert some Preempt() to Cli
* Bug: Back-up-script cause jumps back and forth in ToHtml.
* Bug? Hung after pressing CmpMain in personal menu. Haven't seen in a while.
* Crashes after back-up-script. Went away maybe after spurious IRQ fix.
* Music organ hangs when cursoring around. Haven't seen in while.
* $LK,"DocUpdateTaskDocs","MN:DocUpdateTaskDocs"$() used to skips locked docs. $LK,"WinMgrSync","MN:WinMgrSync"$() needs to check?
* Why was wordstat so slow on "OldMasterBootWrite" for example.
* $LK,"Plain","MN:Plain"$() might be better not saving $LK,"CH_CURSOR","MN:CH_CURSOR"$.
@@ -26,16 +35,12 @@
* It would be nice if $LK,"U","MN:U"$() NOP were better.
* Autoindent is very bad.
* Make native file system expanded size set in Copy.
* Make RedSea file system expanded size set in Copy.
* unhandled exception on MP message gets overwritten by WinMgr
* Cmd to enable/disable compiler warnings
* make aware of ctrl-r side bar
* fix documentation problem -- remembering 0 terminator in str or not for $$DA
* GetS, crazy putkey code
* editor page formatting is FUBAR
@@ -44,17 +49,14 @@
>Might want to do ZOOM in U8 graphics and convert screen capture to U8
>Might want to reverse bit order
* wenceslas crashes in testsuite, sometimes. went away?
* wenceslas crashes in testsuite, sometimes.
* CGrVectMap sucks -- Pilgrim
* return vals for grrect, grblot, grputchar?
* collisions for grrect, grblot, grputchar?
* 32-bit devices should be in free spot address space of E820.
* RAM drive too small for TempleOSCD.ISO
$WW,1$
* Race condition in Navy.CPP.Z torpedo
* Race condition in FlatTops.CPP.Z torpedo
* {Lock|Rep}{Seg|2E=NotBr|3E=Br}{OP}{ADD}{REX}
* Virtual Box MP reboot
@@ -70,7 +72,6 @@ GrEdit: Move sidebar selected elems.
GrEdit: Strip origin shift cmds.
GrEditBitMap, grabscroll?
GrEditBitMap, cut/paste boxes.
extern of fun with dft arg of str?
@@ -78,7 +79,7 @@ extern of fun with dft arg of str?
* FileMgr bad with lots of files.
* This $LK,"Fs->catch_except=TRUE","FF:::/TempleOS/Kernel/TaskCmd.CPP,Fs->catch_except=TRUE"$ causes problems because it catches divide and out-of-mem. Not sure what to do, yet.
* This $LK,"Fs->catch_except=TRUE","FF:::/TempleOS/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","MN:MPStart"$() free old task memory. (Prolly never gonna do anything about this.)
* $LK,"sys_var_init_flag","MN:sys_var_init_flag"$ local vars.
* sprite shift pts, ctrl pt for ellipse/polygon w,h is off when rotated.
@@ -94,7 +95,6 @@ $HC,"<object width=\"750\" height=\"520\"><param name=\"movie\" value=\"http://w
* $LK,"Bible sized nodes","FF:::/TempleOS/Adam/Doc/DocRecalc.CPP,->tag+i"$
* Mouseinstall throws exceptions, doesn't work, investigate Mouse $LK,"0x9FC30","FF:::/TempleOS/Kernel/KbdMouse/Mouse.CPP,9FC"$
* get kbd lights working.
* figure-out hyperthread vs nonhyperthread CPU's
* 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
@@ -106,8 +106,6 @@ $HC,"<object width=\"750\" height=\"520\"><param name=\"movie\" value=\"http://w
U0 (*fp_old_draw_input_ptr)(CDC *dc,I64 x,I64 y)=fp_draw_input_ptr;
}$FG$
* Syncronize VGA memory update with the hardware refresh cycle.
* Demo $LK,"ToHtml","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.
@@ -136,6 +134,8 @@ $HC,"<object width=\"750\" height=\"520\"><param name=\"movie\" value=\"http://w
* 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.
@@ -144,7 +144,7 @@ $HC,"<object width=\"750\" height=\"520\"><param name=\"movie\" value=\"http://w
* Make use of flag potential in SysFilesFind and possibly CFileAccess
* implement fixed pos files
* new C+ language features
* new Holy C language features
* better debugging
* Change hardcoded stuff to Define
+26 -2
View File
@@ -3,11 +3,35 @@ $ID,2$$TR,"TempleOS"$
$ID,2$$TR,"SysMsgFlags"$
$ID,2$sys_msg_flags[0]=0x205;
$ID,-2$$TR,"SysRegVer"$
$ID,2$registry_version=1.000;
$ID,2$registry_version=1.040;
$ID,-2$$ID,-2$$ID,-2$$TR,"DemoCompany"$
$ID,2$$TR,"Game1"$
$ID,2$F64 best_score=1.23;
$TR,"SimpleVal"$
$ID,2$1234;
$ID,-2$$ID,-2$$ID,-2$$TR,"TempleOS"$
$ID,2$$ID,-2$
$ID,2$$TR,"CircleTrace"$
$ID,2$F64 best_score=999.0000;
$ID,-2$$TR,"FPS"$
$ID,2$F64 best_score=55.2079;
$ID,-2$$TR,"EagleDive"$
$ID,2$I64 best_score=6;
$ID,-2$$TR,"CastleFrankenstein"$
$ID,2$F64 best_score=56.7504;
$ID,-2$$TR,"ZoneOut"$
$ID,2$F64 best_score=79.0963;
$ID,-2$$TR,"BugBird"$
$ID,2$F64 best_score=16.1659;
$ID,-2$$TR,"TimeOut"$
$ID,2$I64 best_score=14797;
$ID,-2$$TR,"RawHide"$
$ID,2$F64 best_score=60.9434;
$ID,-2$$TR,"KeepAway"$
$ID,2$I64 best_score0=0,best_score1=9999;
$ID,-2$$TR,"XCaliber"$
$ID,2$I64 best_score=118;
$ID,-2$$TR,"Wenceslas"$
$ID,2$F64 best_score=9999.0000;
$ID,-2$$TR,"BulgeBomber"$
$ID,2$I64 best_score=53;
$ID,-2$$ID,-2$
+24 -45
View File
@@ -75,7 +75,8 @@ boot it directly or from VMware with a physical drive.
else if (ChkDrvModelSerial('D',"Hitachi HDS721075KLA330","GTF202P8H509AF") &&
ChkDrvModelSerial('I',"ST3320620AS","6QF24J0A"))
ts_cid=CID_TAD8; //Regular boot of TAD8
else if (dft_drv=='T' && IsDrvATAPI('T') && m20[11].base==0x100000000 &&
//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
@@ -84,7 +85,6 @@ boot it directly or from VMware with a physical drive.
U0 TSInit()
{
//TS_IMG_DRV is for the holding area for burning CDROMs
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL;
CBlkDev *bdev;
switch (ts_cid) {
@@ -94,7 +94,7 @@ U0 TSInit()
case CID_TAD8_VM:
DefinePrintF("CFG_ACCT","\"\nTS/TAD\n\"");
DefinePrintF("CFG_HARD_DRVS","\"h2s0xbc00\n0xb880\n1d2s0xbc00\n0xb880\n0\"");
DefinePrintF("CFG_RAM_DRVS","\"b1Scale2Mem(2048,0x40000)\nz1Scale2Mem(2048,0x40000)\n\"");
DefinePrintF("CFG_RAM_DRVS","\"b1\nScale2Mem(2048,0x40000)\n\"");
DefinePrintF("CFG_CDROM_DRVS","\"t3s0xb800\n0\"");
DefinePrintF("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
if (ts_cid==CID_TAD8) {
@@ -108,13 +108,12 @@ U0 TSInit()
DefinePrintF("TS_BAK_DRV","\"E\"");
DefinePrintF("TS_RAM_DRV","\"B\"");
DefinePrintF("TS_WIN_DRV","\"H\"");
DefinePrintF("TS_IMG_DRV","\"Z\"");
DefinePrintF("TS_CDROM_DRV","\"T\"");
break;
*/
case CID_DFT:
DefinePrintF("CFG_ACCT","\"\nTS/TAD\n\"");
DefinePrintF("CFG_RAM_DRVS","\"b1Scale2Mem(2048,0x40000)\nz1Scale2Mem(2048,0x40000)\n\"");
DefinePrintF("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
DefinePrintF("CFG_HARD_DRVS","\"\"");
@@ -125,10 +124,10 @@ U0 TSInit()
DefinePrintF("CFG_HARD_DRVS","\"d2s0x1F0\n0x3F4\n0\"");
DefinePrintF("CFG_CDROM_DRVS","\"t3s0x170\n0\"");
bdev=Drv2BlkDev(dft_drv);
bdev=Drv2BlkDev(*sys_acct);
if (bdev->type==BDT_ATAPI) {
ATARep(FALSE,,&root);
ATAIDDrvs(root,dft_drv,&ata_drv,&atapi_drv);
ATAIDDrvs(root,*sys_acct,&ata_drv,&atapi_drv);
if (ata_drv)
DefinePrintF("CFG_HARD_DRVS","\"d2p%d\n\"",ata_drv->num);
if (atapi_drv)
@@ -154,28 +153,26 @@ U0 TSInit()
DefinePrintF("TS_BAK_DRV","\"E\"");
DefinePrintF("TS_RAM_DRV","\"B\"");
DefinePrintF("TS_WIN_DRV","\"\"");
DefinePrintF("TS_IMG_DRV","\"Z\"");
DefinePrintF("TS_CDROM_DRV","\"T\"");
}
} TSInit;
Bool ts_has_main_drv =ToBool(StrLen(TS_MAIN_DRV)),
ts_has_bak_drv =ToBool(StrLen(TS_BAK_DRV)),
ts_has_ram_drv =ToBool(StrLen(TS_BAK_DRV)),
ts_has_win_drv =ToBool(StrLen(TS_WIN_DRV)),
ts_has_img_drv =ToBool(StrLen(TS_IMG_DRV)),
ts_has_cdrom_drv=ToBool(StrLen(TS_CDROM_DRV));
U0 TSInit2()
{
DefinePrintF("TS_MAIN_DRV_LET","'%s'",TS_MAIN_DRV);
DefinePrintF("TS_BAK_DRV_LET","'%s'",TS_BAK_DRV);
DefinePrintF("TS_RAM_DRV_LET","'%s'",TS_RAM_DRV);
DefinePrintF("TS_WIN_DRV_LET","'%s'",TS_WIN_DRV);
DefinePrintF("TS_IMG_DRV_LET","'%s'",TS_IMG_DRV);
DefinePrintF("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_ram_drv =ToBool(StrLen(TS_BAK_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)
@@ -184,20 +181,21 @@ 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_img_drv)
SetDrvTextAttr(TS_IMG_DRV_LET, BLUE <<4|LTRED);
if (ts_has_cdrom_drv)
SetDrvTextAttr(TS_CDROM_DRV_LET,LTGRAY<<4|BLUE);
#define TS_ISO_NAME TS_RAM_DRV ":/TempleOSCD.ISO"
#define TS_ISO_NAME TS_RAM_DRV ":/TempleOSCD.ISO"
#define TS_DISTRO_DIR TS_RAM_DRV ":/Distro"
#define CFG_OPTS "ProtectLow\nAutoMountIDE\nDT\n"
#define CFG_DBG_OPTS "ProtectLow\nAutoMountIDE\nDTDet\nHeapInit\n130\nMemInit\n131\nVarInit\n132\n\n"
#define CFG_DBGZ_OPTS "ProtectLow\nAutoMountIDE\nDTDet\nHeapInit\n0\nMemInit\n0\nVarInit\n0\n\n"
#define CFG_DBG_OPTS "ProtectLow\nAutoMountIDE\nDT"\
"Det\nHeapInit\n130\nMemInit\n131\nVarInit\n132\n\n"
#define CFG_DBGZ_OPTS "ProtectLow\nAutoMountIDE\nDT"\
"Det\nHeapInit\n0\nMemInit\n0\nVarInit\n0\n\n"
#define TS_CFG CFG_RAM_DRVS CFG_CDROM_DRVS CFG_HARD_DRVS CFG_ACCT CFG_DSK_CACHE CFG_OPTS
#define TS_MENU_CFG CFG_RAM_DRVS CFG_CDROM_DRVS CFG_HARD_DRVS "\n\n" CFG_DSK_CACHE CFG_OPTS
#define TS_CDROM_CFG "b10x20000\nt3 \n\nTS\n\nAutoMountIDE\nDT\n"
#define TS_CDROM_CFG "b1\n0x20000\nt3 \n\nTS\n\nAutoMountIDE\nDT\n"
//$BK,1$Change these, too...$BK,0$
//$MA+A-X+PU,"STD_DISTRO_CDROM_CFG","F(\"STD_DISTRO_CDROM_CFG\");View;"$
@@ -221,12 +219,12 @@ public U0 MyScreenShot(I64 bits=4)
U8 *st;
CDirEntry *tempm;
I64 cnt=0;
tempm=FilesFind("::/Temp/ScreenShots/*.BMP");
tempm=FilesFind("::/Temp/ScreenShots/*.BMP.Z");
while (tempm) {
cnt++;
tempm=tempm->next;
}
st=MSPrintF("::/Temp/ScreenShots/SCRN%04d.BMP",cnt);
st=MSPrintF("::/Temp/ScreenShots/SCRN%04d.BMP.Z",cnt);
BMPFileCaptureScreen(st,bits);
Free(st);
Beep;
@@ -249,7 +247,7 @@ Boot Windows
Download "ffmpeg" from the Internet
>CD SCREENSHOTS
>TSZ -expand .
>TSZ .
>ffmpeg -r 8 -i VID%05d.BMP -y Movie.avi
*/
@@ -288,7 +286,7 @@ U0 CopyVideo()
{
if (ts_has_bak_drv) {
Del(TS_BAK_DRV ":/Temp/*.SND");
SndFileCreate(TS_BAK_DRV ":/Temp/Audio",0.23,0.0,WF_NULL,0.45,0.35);
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");
}
@@ -328,25 +326,6 @@ U0 CtrlAltS(I64)
}
SetCtrlAltLetCB('S',&CtrlAltS,"Cmd/Screen Shot");
public U0 Abbr(U8 *word,U8 *abbr)
{
U8 buf1[136],buf2[136];
StrCpy(buf1,word);
StrCpy(buf2,abbr);
StrUtil(buf1,SUF_TO_LOWER);
StrUtil(buf2,SUF_TO_LOWER);
Grep(buf1,"/TempleOS/"FILENAME_MASK_TXT,"-l-i",buf2);
*buf1=ToUpper(*buf1);
*buf2=ToUpper(*buf2);
Grep(buf1,"/TempleOS/"FILENAME_MASK_TXT,"-l-i",buf2);
StrUtil(buf1,SUF_TO_UPPER);
StrUtil(buf2,SUF_TO_UPPER);
Grep(buf1,"/TempleOS/"FILENAME_MASK_TXT,"-l-i",buf2);
}
public U0 ChkAll()
{
U8 *ptr=TS_HDS;
+72 -59
View File
@@ -79,12 +79,6 @@ U0 TSCopyDrv(U8 src,U8 dst)
SPrintF(buf_d,"%c:/Temp/ScreenShots",dst);
MkDir(buf_d);
if (ts_has_bak_drv && dst==TS_BAK_DRV_LET) {
SPrintF(buf_d,"%c:/Logs",dst);
MkDir(buf_d);
SPrintF(buf_d,"%c:/Logs/TEMPLEOSLogs",dst);
MkDir(buf_d);
}
DocClear;
Drv(dst);
TSMakeOSInstallPrtBootLoader(dst);
@@ -178,12 +172,14 @@ U0 Uncollapse(U8 *files_find_mask=FILENAME_MASK_TXT,U8 *fu_flags=NULL)
UncollapseLst(FilesFind(files_find_mask,f),&f);
}
U0 CopySongDir(U8 *files_find_mask,U8 threshold)
public U0 CopySongs(U8 threshold='7')
{
CDoc *s;
CDocEntry *doc_e;
CDirEntry *tempm,*tempm1;
tempm1=tempm=FilesFind(files_find_mask);
DelTree("/TempleOS/Apps/MusicOrgan/Examples");
MkDir("/TempleOS/Apps/MusicOrgan/Examples");
tempm1=tempm=FilesFind("/TempleOS/Accts/TS/TAD/MusicOrgan/*.CPP*");
while (tempm1) {
s=DocRead(tempm1->full_name);
doc_e=s->root.next;
@@ -194,17 +190,10 @@ U0 CopySongDir(U8 *files_find_mask,U8 threshold)
CDirLstDel(tempm);
}
public U0 CopySongs(U8 threshold='7')
{
DelTree("/TempleOS/Apps/MusicOrgan/Examples");
MkDir("/TempleOS/Apps/MusicOrgan/Examples");
CopySongDir("/TempleOS/Accts/TS/TAD/MusicOrgan/*.CPP*",threshold);
}
U0 DistroPrep()
{
Del("/TempleOS/Demo/WebLogExample/WebLog.TXT*");
Del("/TempleOS/Demo/GameStarters/EagleDive.BIN*");
Del("/TempleOS/Demo/Games/EagleDive.BIN*");
DelTree("/TempleOS/Accts/*Temp.TXT.Z");
CopySongs;
@@ -230,7 +219,7 @@ U0 DistroPrep()
Cd("/TempleOS");
FilesCursorTop;
DelTree("/TempleOS/Demo/*.BI?");
DelTree("/TempleOS/Demo/*.BI*");
Cd("/TempleOS");
S2T(FILENAME_MASK_SRC,"+r");
@@ -238,22 +227,6 @@ U0 DistroPrep()
Move(WSD_DEF_FILENAME,WSD_DEF_FILENAME_Z);
}
U0 TSDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(TS_CDROM_CFG);
MakeOSInstallPrtBootLoader(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
Fmt(TS_IMG_DRV_LET,TRUE,FALSE,PT_NATIVE);
Drv(TS_IMG_DRV_LET);
CopyTree(TS_MAIN_DRV ":/TempleOS","/TempleOS");
CopyTree(TS_MAIN_DRV ":/Windows","/Windows");
CopyTree(TS_MAIN_DRV ":/Linux","/Linux");
MkDir("/Temp");
MkDir("/Temp/ScreenShots");
CopyTree(TS_MAIN_DRV ":/0000Boot","/0000Boot");
}
U0 MakeSymFiles()
{
CDoc *doc;
@@ -262,7 +235,7 @@ U0 MakeSymFiles()
DocClear;
DocMax;
HashRep(Fs->hash_table,HTG_ALL,NULL,"-p",0,NULL);
if (doc=DocCur) {
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,TS_BAK_DRV ":/Wb/Accts/TS/Wb2/SymsAlpha.TXT.Z");
DocWrite(doc);
@@ -272,7 +245,7 @@ U0 MakeSymFiles()
DocClear;
DocMax;
HashRep(Fs->hash_table,HTG_ALL,NULL,"-p+m",0,NULL);
if (doc=DocCur) {
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,TS_BAK_DRV ":/Wb/Accts/TS/Wb2/SymsAddress.TXT.Z");
DocWrite(doc);
@@ -294,17 +267,22 @@ I64 MakeLineCntFile()
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Cd(TS_MAIN_DRV ":/TempleOS");
CopyTree(TS_MAIN_DRV ":/TempleOS/Accts/TS",TS_MAIN_DRV ":/Temp/TS");
DelTree(TS_MAIN_DRV ":/TempleOS/Accts/TS");
DocMax;
DocClear;
Cd(TS_MAIN_DRV ":/TempleOS");
result=LineCntRep;
if (doc=DocCur) {
if (doc=DocPut) {
st=StrNew(doc->filename.name);
StrCpy(doc->filename.name,TS_MAIN_DRV ":/TempleOS/Accts/TS/Wb2/LineCnt.TXT.Z");
StrCpy(doc->filename.name,TS_MAIN_DRV ":/Temp/TS/Wb2/LineCnt.TXT.Z");
DocWrite(doc);
StrCpy(doc->filename.name,st);
Free(st);
}
CopyTree(TS_MAIN_DRV ":/Temp/TS",TS_MAIN_DRV ":/TempleOS/Accts/TS");
DelTree(TS_MAIN_DRV ":/Temp/TS");
DocClear;
doc=DocRead(TS_MAIN_DRV ":/TempleOS/Adam/DocDefines.CPP.Z");
@@ -325,35 +303,49 @@ I64 MakeLineCntFile()
return result;
}
U0 StdDistroPrep(U8 *auto_cfg)
U0 TSDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(auto_cfg);
Auto(TS_CDROM_CFG);
MakeOSInstallPrtBootLoader(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
Fmt(TS_IMG_DRV_LET,TRUE,FALSE,PT_NATIVE);
Drv(TS_IMG_DRV_LET);
CopyTree(TS_MAIN_DRV ":/TempleOS","/TempleOS");
CopyTree(TS_MAIN_DRV ":/Windows","/Windows");
CopyTree(TS_MAIN_DRV ":/Linux","/Linux");
MkDir("/Temp");
DelTree("/TempleOS/Accts/TS");
CopyTree(TS_MAIN_DRV ":/0000Boot","/0000Boot");
Del("/0000Boot/OldMBR.BIN.C");
Del("/0000Boot/BootMHD2.BIN.C");
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/TempleOS",TS_DISTRO_DIR "/TempleOS");
CopyTree(TS_MAIN_DRV ":/Windows",TS_DISTRO_DIR "/Windows");
CopyTree(TS_MAIN_DRV ":/Linux",TS_DISTRO_DIR "/Linux");
MkDir(TS_DISTRO_DIR "/Temp");
MkDir(TS_DISTRO_DIR "/Temp/ScreenShots");
CopyTree(TS_MAIN_DRV ":/0000Boot",TS_DISTRO_DIR "/0000Boot");
}
U0 StdDistroPrep()
{
Drv(TS_MAIN_DRV_LET);
DistroPrep;
Auto(STD_DISTRO_CDROM_CFG);
MakeOSInstallPrtBootLoader(TS_MAIN_DRV_LET,TS_CDROM_DRV_LET);
DelTree(TS_DISTRO_DIR);
CopyTree(TS_MAIN_DRV ":/TempleOS",TS_DISTRO_DIR "/TempleOS");
CopyTree(TS_MAIN_DRV ":/Windows",TS_DISTRO_DIR "/Windows");
CopyTree(TS_MAIN_DRV ":/Linux",TS_DISTRO_DIR "/Linux");
MkDir(TS_DISTRO_DIR "/Temp");
DelTree(TS_DISTRO_DIR "/TempleOS/Accts/TS");
CopyTree(TS_MAIN_DRV ":/0000Boot",TS_DISTRO_DIR "/0000Boot");
Del(TS_DISTRO_DIR "/0000Boot/OldMBR.BIN.C");
Del(TS_DISTRO_DIR "/0000Boot/BootMHD2.BIN.C");
}
U0 MakeStdDistro()
{
StdDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeTSDistro()
{
TSDistroPrep;
CDFileCreate(TS_ISO_NAME,TS_IMG_DRV ":/*",NULL,BOOTCD_BIN_Z);
Drv(TS_MAIN_DRV_LET);
}
U0 MakeStdDistro()
{
StdDistroPrep(STD_DISTRO_CDROM_CFG);
CDFileCreate(TS_ISO_NAME,TS_IMG_DRV ":/*",NULL,BOOTCD_BIN_Z);
CDFileCreate(TS_ISO_NAME,TS_DISTRO_DIR "/*",,TS_DISTRO_DIR BOOT_DIR_KERNEL_BIN_C);
Drv(TS_MAIN_DRV_LET);
}
@@ -382,6 +374,9 @@ U0 MakeWebSite()
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","",,GetCurTimeDate);
tempm=tempm2=FilesFind(FILENAME_MASK_TXT,FUF_RECURSE|FUF_FLATTEN_TREE|FUF_JUST_FILES);
while (tempm) {
TSWebFile(tempm->full_name);
@@ -429,6 +424,19 @@ U0 TSUncompress()
}
}
U0 UpdateISODocDefines()
{
I64 size;
size=10*FileSize(TS_BAK_DRV ":/Wb/TempleOSCD.ISO")/1024/1024;
DefinePrintF("DD_TEMPLEOSCD_SIZE",
"Download $TX+D,"TempleOS V1.03","DD_OS_NAME_VERSION"$ - Std. Distro (%0.1f MB)",0.1*size);
size=10*FileSize(TS_BAK_DRV ":/Wb/TempleOSTS.ISO")/1024/1024;
DefinePrintF("DD_TEMPLEOSTS_SIZE",
"Download $TX+D,"TempleOS V1.03","DD_OS_NAME_VERSION"$ - T.S. Company Internal Distro (%0.1f MB)",0.1*size);
}
UpdateISODocDefines;
U0 MakeDistrosAndBackUp()
{
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
@@ -444,12 +452,17 @@ U0 MakeDistrosAndBackUp()
DelTree (TS_BAK_DRV ":/Wb"); progress4++;
CopyTree(TS_MAIN_DRV ":/TempleOS",TS_BAK_DRV ":/Wb"); progress4++;
DocClear;
MakeTSDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSTS.ISO"); progress4++;
MakeStdDistro; progress4++;
DocClear;
Copy(TS_ISO_NAME,TS_BAK_DRV ":/Wb/TempleOSCD.ISO"); progress4++;
UpdateISODocDefines;
Cd(TS_MAIN_DRV ":/TempleOS");
if (LinkChk)
throw;
@@ -491,7 +504,7 @@ U0 TSPrtDsk()
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,dft_drv,&ata_drv,&atapi_drv);
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);
+2 -5
View File
@@ -45,17 +45,14 @@ I64 AsmAndC()
Beeps(i);
asm {
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a C+ routine.
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a Holy C routine.
USE64 //Defaults to 64, but this is a good habit.
IMPORT Snd;
MOV RCX,&i[RBP] //You can clobber RAX,RBX,RCX,RDX.
//You better preserve the rest.
@@05: PUSH RCX
//U0 Snd(F64 freq,I64 waveform=WF_SQUARE,F64 amp=1.0);
MOV RAX,1.0 //amplitude
PUSH RAX
PUSH WF_SQUARE
//U0 Snd(F64 freq);
MOV RAX,RCX //freq=loop*100.0+100.0
IMUL2 RAX,100 //TempleOS uses nonstandard opcodes
+3 -6
View File
@@ -38,7 +38,7 @@ _BEEPS2::
POP RCX
LOOP @@05
PUSH RSI //we must preserve this register.
PUSH RSI //See $LK,"CREG_VARS_MASK","MN:CREG_VARS_MASK"$ & $LK,"CREG_NON_PTR_MASK","MN:CREG_NON_PTR_MASK"$
MOV RSI,JIFFIES_MSG
CALL PUT_STR
POP RSI
@@ -67,15 +67,12 @@ U0 AsmAndC2()
asm {
LIST
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a C+ routine.
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a Holy C routine.
USE64 //Defaults to 64, but this is a good habit.
MOV RCX,R15 //You can clobber RAX,RBX,RCX,RDX.
//You better preserve the rest.
@@05: PUSH RCX
//U0 Snd(F64 freq,I64 waveform=WF_SQUARE,F64 amp=1.0);
MOV RAX,1.0 //amplitude
PUSH RAX
PUSH WF_SQUARE
//U0 Snd(F64 freq);
MOV RAX,RCX //freq=loop*100.0+100.0
IMUL2 RAX,glbl_hz_step //evaluated at compile ttime
+8 -3
View File
@@ -28,24 +28,29 @@ USE64 //Defaults to 64, but this is a good habit.
IMPORT PUT_HEX_U8,PUT_CHAR;
MY_MSG:
MY_WORLD_MSG:
//Define U8 does not put terminating zeros
//on strings.
DU8 "Hello World\n",0;
DU8 "World\n",0;
//My convention is to put an underscore
//on C callable routines.
_HELLO_WORLD::
PUSH RSI //See $LK,"CREG_VARS_MASK","MN:CREG_VARS_MASK"$ & $LK,"CREG_NON_PTR_MASK","MN:CREG_NON_PTR_MASK"$
MOV RCX,10
@@05: MOV RAX,RCX
CALL PUT_HEX_U8
MOV RAX,CH_SPACE
CALL PUT_CHAR
MOV RSI,MY_MSG
MOV RAX,'Hello ' //Supports multi-byte char constants
CALL PUT_CHAR
//We broke it in two pieces to show different ways.
MOV RSI,MY_WORLD_MSG
//Alternatively, if you use an '&', you don't need
//to import a SYS_SYM. This only works for JIT asm.
CALL &PUT_STR
LOOP @@05
POP RSI
RET
};
+1 -1
View File
@@ -12,7 +12,7 @@ MSG_NEW_LINE: DU8 "\n\0";
_BUZZ_FIZZ::
ENTER 0 //Always use Enter/Leave
PUSH RSI //RSI must be preserved.
PUSH RSI //See $LK,"CREG_VARS_MASK","MN:CREG_VARS_MASK"$ & $LK,"CREG_NON_PTR_MASK","MN:CREG_NON_PTR_MASK"$
MOV RAX,RANGE_START
MOV DX,(FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1)<<8+
(BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1)
+6 -2
View File
@@ -3,8 +3,12 @@ PUT_DEC_U64::
//RAX is number to print in decimal.
//Preserves all regs.
ENTER 24 //24 char buffer on stack
PUSH_C_REGS //$LK,"Save regs","FF:::/TempleOS/Kernel/Adam1a.HPP,PUSH_C_REGS"$ which C code is free to clobber
PUSH RSI //This reg is not saved.
//$LK,"Save regs","FF:::/TempleOS/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,"CREG_VARS_MASK","MN:CREG_VARS_MASK"$ & $LK,"CREG_NON_PTR_MASK","MN:CREG_NON_PTR_MASK"$
LEA RSI,-1[RBP] //Load addr of end of buffer.
//We picked RSI because of PUT_STR
//We'll move backward
+1 -1
View File
@@ -11,5 +11,5 @@ for (i=0;i<3;i++)
"$$FG,RED$$//Press a letter to complete the mask$$FG$$\n";
"Dir(\"*.";
I64 ch=GetChar(NULL,FALSE); //Prompt for first digit of mask
I64 ch=GetChar(,FALSE); //Prompt for first digit of mask
"%c*\");\n",ch;
+14 -14
View File
@@ -1,20 +1,20 @@
//Intermediate compiler codes
#define IC_END 0x00
#define IC_START 0x01
#define IC_NOP 0x02
#define IC_NOP1 0x02
#define IC_END_EXP 0x03
#define IC_NOP1 0x04
#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 0x0B
#define IC_F64 0x0C
#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_ABS_ADDR 0x0E
#define IC_ADDR_IMPORT 0x0F
#define IC_HEAP_GLBL 0x10
#define IC_SIZEOF 0x11
#define IC_TYPE 0x12
@@ -31,9 +31,9 @@
#define IC_TO_F64 0x1B
#define IC_TO_BOOL 0x1C
#define IC_TOUPPER 0x1D
#define IC_NATIVE_TYPECAST 0x1E
#define IC_HOLYC_TYPECAST 0x1E
#define IC_ADDR 0x1F
#define IC_ADDR 0x1F
#define IC_COM 0x20
#define IC_NOT 0x21
#define IC_UNARY_MINUS 0x22
@@ -132,12 +132,12 @@
#define IC_WBINVD 0x6F
#define IC_INVD 0x70
#define IC_INU8 0x71
#define IC_INU16 0x72
#define IC_INU32 0x73
#define IC_OUTU8 0x74
#define IC_OUTU16 0x75
#define IC_OUTU32 0x76
#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_FLAGS 0x77
#define IC_SET_FLAGS 0x78
+5 -5
View File
@@ -21,15 +21,15 @@
*/
CDate spdt=GetCurTimeCDate;
CDate cdt=GetCurTimeDate;
I64 i;
for (i=0;i<DF_NUM;i++)
"%%h%dD: %h*D\n",i,i,spdt;
"%%h%dD: %h*D\n",i,i,cdt;
NewLine;
for (i=0;i<TF_NUM;i++)
"%%h%dT: %h*T\n",i,i,spdt;
"%%h%dT: %h*T\n",i,i,cdt;
"$$FG,PURPLE$$CDate freq:%12.6f$$FG$$\n",0x100000000/24.0/60.0/60.0;
@@ -41,5 +41,5 @@ for (i=0;i<TF_NUM;i++)
*/
//Example of how to use with $LK,"DF_NUM","MN:DF_NUM"$, $LK,"TF_NUM","MN:TF_NUM"$ #define's
"%h*D\n",DF_MM_DD_YYYY,spdt;
"%h*T\n",TF_HH24_MM,spdt;
"%h*D\n",DF_MM_DD_YYYY,cdt;
"%h*T\n",TF_HH24_MM,cdt;
+1 -1
View File
@@ -10,7 +10,7 @@ Press <CTRL-ALT-D> to enter Dbg.
Press <CTRL-ALT-D> to enter Dbg.
> $LK,"Uf","MN:Uf"$("DbgDemo");
> $LK,"U","MN:U"$(RIP);
> $LK,"U","MN:U"$(_RIP);
See $LK,"Debugging","HI:Debugging"$
+17 -32
View File
@@ -5,36 +5,24 @@ U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
//if the window mgr used it's own
//heap, so we use the owning task's heap.
U8 *st=MAlloc(64,mem_task);
CDate spdt=tS*CDATE_FREQ;
CDate cdt=tS*CDATE_FREQ;
//Doesn't have to be fixed width!!
SPrintF(st,"%d=%h11T",spdt,spdt);
SPrintF(st,"%d=%h11T",cdt,cdt);
return st;
}
U8 *CurTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
{
U8 *st=MAlloc(64,mem_task);
CDate spdt=GetCurTimeCDate;
SPrintF(st,"%h0D %h0T",spdt,spdt);
CDate cdt=GetCurTimeDate;
SPrintF(st,"%h0D %h0T",cdt,cdt);
return st;
}
U0 DoIt()
{
/* The main window is kept at Fs->last_doc.
A second framework is kept at Fs->next_doc.
Normally, the next_doc is used for updating
the border, primarily.
See $LK,"UseTermDoc","MN:UseTermDoc"$().
See $LK,"DocUpdateTaskDocs","MN:DocUpdateTaskDocs"$().
Note: the next_doc is not to be confused
with the aux_str, a member of the $LK,"CDocEntry","MN:CDocEntry"$.
*/
CDoc *aux=DocAux, //Fetches Fs->next_doc basically.
*cur=DocCur; //Fetches Fs->last_doc basically.
CDoc *bdoc=DocBorder,
*pdoc=DocPut;
CDocEntry *doc_e;
// We don't want an update between
@@ -43,32 +31,32 @@ with the aux_str, a member of the $LK,"CDocEntry","MN:CDocEntry"$.
Bool old_preempt=Preempt(OFF);
DocBottom(aux); //Ins at the bottom
DocPutS(aux,"$$FG,RED$$$$CM+BY+LX,5,-3$$");
DocBottom(bdoc); //Ins at the bottom
DocPutS(bdoc,"$$FG,RED$$$$CM+BY+LX,5,-3$$");
// The $LK,"DocPutS","MN:DocPutS"$() routine returns the addr of the last entry.
doc_e=DocPutS(aux,"$$TX+TC,\" \"$$");
doc_e=DocPutS(bdoc,"$$TX+TC,\" \"$$");
// The TC flag is "has tag callback".
// Flags are explained here:
// $LK-A,"::/TempleOS/Doc/CtrlL.TXT"$
// $LK-A,"::/TempleOS/Doc/Widget.TXT"$
// $LK-A,"::/TempleOS/Doc/Dollar.TXT"$
// $LK,"Dollar Flags","MN:DOCEf1_AUX_STR"$
// $LK,"ST_DOC_FLAGS","FF:::/TempleOS/Adam/Doc/Doc.CPP,ST_DOC_FLAGS"$
doc_e->tag_cb=&tSCB;
DocPutS(aux,"$$FG$$");
DocPutS(bdoc,"$$FG$$");
//$BK,1$WARNING:$BK,0$ If you use the last_doc you
//$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 next_doc.
//to use the border_doc.
DocPutS(cur,"$$FG,LTRED$$");
doc_e=DocPutS(cur,"$$TX+TC,\" \"$$");
DocPutS(pdoc,"$$FG,LTRED$$");
doc_e=DocPutS(pdoc,"$$TX+TC,\" \"$$");
doc_e->tag_cb=&CurTimeCB;
DocPutS(cur,"$$FG$$");
DocPutS(pdoc,"$$FG$$");
Preempt(old_preempt);
@@ -83,11 +71,8 @@ with the aux_str, a member of the $LK,"CDocEntry","MN:CDocEntry"$.
U0 UndoIt()
{
//Clear-out entries without a +H hold flag.
DocBottom(Fs->next_doc);
DocPutS(Fs->next_doc,"$$CL$$");
DocClear(Fs->border_doc);
}
DoIt;
// See $LK-A,"::/TempleOS/Demo/Doc/CallBackAux2.CPP"$ for another way.
-35
View File
@@ -1,35 +0,0 @@
//See $LK-A,"::/TempleOS/Demo/Doc/CallBack.CPP"$ first.
U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
{
U8 *st=MAlloc(64,mem_task);
CDate spdt=tS*CDATE_FREQ;
SPrintF(st,"%d=%h11T",spdt,spdt);
return st;
}
U0 DoIt()
{
CDocEntry *doc_e;
CDoc *aux2=DocNew;
aux2->flags|=DOCF_AUX_DOC;
DocPutS(aux2,"$$FG,RED$$$$CM+BY+LX,5,-3$$");
doc_e=DocPutS(aux2,"$$TX+TC,\" \"$$");
doc_e->tag_cb=&tSCB;
DocPutS(aux2,"$$FG$$");
DocQueInsRev(aux2,DocAux);
NewLine;
}
U0 UndoIt()
{
CDoc *aux2=DocAux;
DocQueRem(aux2);
DocDel(aux2);
}
DoIt;
+6 -4
View File
@@ -6,9 +6,9 @@
+RD refreshes the data.
+UD updates the val when you edit it.
+U32 means the val is 4 bytes.
-I64 I64 is the default so we might
-U64 U64 is the default so we might
want to turn-it-off. Strings
use I64.
use U64.
,32 sets the tag string width.
See $LK,"Data Tag Width","FA:::/TempleOS/Adam/Doc/DocPlain.CPP,DataTagWidth"$.
-P Means it is a string var, basically.
@@ -33,7 +33,7 @@ U0 DataDemo()
CDocEntry *doc_e;
//This is the command line document.
CDoc *doc=DocCur;
CDoc *doc=DocPut;
//We do this to prevent access to
//doc_e->data before it is set.
@@ -43,7 +43,7 @@ U0 DataDemo()
// doc->flags|=DOCF_FORM
//if you wish.
Spawn(&UpdateGlblTask,NULL,"Update Glbl",Fs);
Spawn(&UpdateGlblTask,NULL,"Update Glbl",,Fs);
"Enter editor overstrike mode\n"
"and you can modify the val.\n"
@@ -62,3 +62,5 @@ U0 DataDemo()
}
DataDemo;
//See $LK,"PopUpExtents","MN:PopUpExtents"$().
+4 -4
View File
@@ -2,8 +2,8 @@
The +D flag causes a define-string
look-up and substitution.
It is available in the <CTRL-L> menu
under text entries for use in
It is available in the <CTRL-L> text-widget
menu under text entries for use in
documentation.
*/
@@ -12,11 +12,11 @@ documentation.
DefineLoad("COMPANY","Trivial Solutions");
"Company: $$TX+D,\"\",\"COMPANY\"$$\n";
DefinePrintF("COMPANY_TIME","%T",GetCurTimeCDate);
DefinePrintF("COMPANY_TIME","%T",GetCurTimeDate);
#exe {
StreamPrintF(
"#define COMPANY_AGE %h56D\n",GetCurTimeCDate-A2CDate("8/1/2003"));
"#define COMPANY_AGE %h56D\n",GetCurTimeDate-A2Date("8/1/2003"));
};
+3 -3
View File
@@ -16,15 +16,15 @@ class DStruct
U0 FormDemo()
{
DStruct gtl;
CDate spdt;
CDate cdt;
gtl.num1=12.3e-4; //Set defaults
gtl.num2=4.5e3;
gtl.num3=0x1234;
gtl.num4=-567;
StrCpy(&gtl.name,"John");
spdt=GetCurTimeCDate;
gtl.datetime=spdt;
cdt=GetCurTimeDate;
gtl.datetime=cdt;
if (DocFormDo(&gtl,"DStruct")) {
"#1=%e\n",gtl.num1;
"#2=%e\n",gtl.num2;
+4 -4
View File
@@ -27,9 +27,9 @@ U0 MenuButton()
{
Bool done=FALSE;
I64 i,j=0,freq=100;
I64 old_flags=DocCur->flags;
I64 old_flags=DocPut->flags;
//This allows keyboard navigation to skip nonselectible entries.
DocCur->flags|=DOCF_FORM;
DocPut->flags|=DOCF_FORM;
do {
DocClear;
//Use <CTRL-L> to generate cursor movement expressions and check "Quote".
@@ -43,7 +43,7 @@ U0 MenuButton()
"\n$$BT,\"Set Freq\",MU_SET_FREQ$$\n\n\n"
"\n$$BT,\"Nothing\",MU_NOTHING$$\n\n\n"
"\n$$BT,\"Done\",DOCM_CANCEL$$\n\n\n";
i=DocMenuDo(DocCur);
i=DocMenuDo(DocPut);
DocBottom;
switch (i) {
case MU_NOTHING:
@@ -67,7 +67,7 @@ U0 MenuButton()
done=TRUE;
}
} while (!done);
DocCur->flags=DocCur->flags&~DOCF_FORM |
DocPut->flags=DocPut->flags&~DOCF_FORM |
old_flags & DOCF_FORM;
DocClear;
Snd(0);
Binary file not shown.
+26 -2
View File
@@ -13,7 +13,31 @@ For this example, however, I wanted to use DocPrintF
and disabled Preemption myself.
*/
#include "/TempleOS/Demo/Shared/TreeDemoJoin"
U0 TreeSub(CDoc *doc,CDirEntry *tempm)
{
CDirEntry *tempm1;
while (tempm) {
tempm1=tempm->next;
if (tempm->attr & _ATTR_DIR) {
DocPutS(doc,"$$TR,\"\"$$");
DocPrintF(doc,"$$MA+A,\"%s\",\"Cd(\\\"%s\\\");Dir;\n\"$$\n",
tempm->name,tempm->full_name);
if (tempm->sub) {
DocPutS(doc,"$$ID,+2$$");
TreeSub(doc,tempm->sub);
DocPutS(doc,"$$ID,-2$$");
}
} else {
DocPrintF(doc,"$$LK,\"%s\",\"FI:%s\"$$\n",
tempm->name,tempm->full_name);
}
//Note there is also a routine
//to delete an entire CDirEntry tree.
//See $LK,"CDirLstDel","MN:CDirLstDel"$().
CDirEntryDel(tempm);
tempm=tempm1;
}
}
U0 TreeDemo()
{
@@ -24,7 +48,7 @@ U0 TreeDemo()
DocPutS(doc,"$$ID,+2$$");
TreeSub(doc,FilesFind("/TempleOS/*",fuf_flags));
DocPutS(doc,"$$ID,-2$$");
DocInsDoc(DocCur,doc);
DocInsDoc(DocPut,doc);
DocDel(doc);
}
+8 -8
View File
@@ -15,7 +15,7 @@ output $LK,"Silent","MN:Silent"$().
U0 UnusedDefineScan()
{
CDoc *old_doc=DocCur,*doc;
CDoc *old_put_doc,*old_display_doc,*doc;
I64 cnt=0;
CHashTable *tempht;
CHash *temph;
@@ -50,18 +50,18 @@ U0 UnusedDefineScan()
progress1++;
if (FileOcc(temph->str,"/TempleOS/"FILENAME_MASK_TXT,"+l-i")==1) {
doc=DocNew;
DocQueRem(old_doc);
DocQueIns(doc,Fs->last_doc);
old_put_doc=DocPut;
old_display_doc=DocDisplay;
Fs->put_doc=Fs->display_doc=doc;
Grep(temph->str,"/TempleOS/"FILENAME_MASK_TXT,"+l-i");
DocQueRem(doc);
DocQueIns(old_doc,Fs->last_doc);
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) {
NewLine;
"" temph->str;
"%s ",temph->str;
doc_e2=DocEntryCopy(doc,doc_e);
DocIns(old_doc,doc_e2);
DocIns(old_put_doc,doc_e2);
NewLine;
}
doc_e=doc_e->next;
+25 -1
View File
@@ -4,7 +4,31 @@ hold the file until you are done. The $LK,"CDoc","MN:CDoc"$
framework is convenient for this.
*/
#include "/TempleOS/Demo/Shared/TreeDemoJoin"
U0 TreeSub(CDoc *doc,CDirEntry *tempm)
{
CDirEntry *tempm1;
while (tempm) {
tempm1=tempm->next;
if (tempm->attr & _ATTR_DIR) {
DocPutS(doc,"$$TR,\"\"$$");
DocPrintF(doc,"$$MA+A,\"%s\",\"Cd(\\\"%s\\\");Dir;\n\"$$\n",
tempm->name,tempm->full_name);
if (tempm->sub) {
DocPutS(doc,"$$ID,+2$$");
TreeSub(doc,tempm->sub);
DocPutS(doc,"$$ID,-2$$");
}
} else {
DocPrintF(doc,"$$LK,\"%s\",\"FI:%s\"$$\n",
tempm->name,tempm->full_name);
}
//Note there is also a routine
//to delete an entire CDirEntry tree.
//See $LK,"CDirLstDel","MN:CDirLstDel"$().
CDirEntryDel(tempm);
tempm=tempm1;
}
}
U0 FPrintFDemo(U8 *output_filename=NULL)
{
+1 -1
View File
@@ -5,7 +5,7 @@ U0 UnusedSpaceRep()
for (i=0;i<26;i++) {
try {
p=Drv2Prt(i+'A');
if (p->type==PT_FAT32 || p->type==PT_NATIVE)
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
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
-708
View File
@@ -1,708 +0,0 @@
$BG,0$
$SP,"<ship_null>",1$
$SP,"<ship_thrust>",2$
$SP,"<ship_null2>",3$
$SP,"<ship_thrust2>",4$
$SP,"<tiny_rock>",5$
$SP,"<tiny_rock2>",6$
$SP,"<small_rock>",7$
$SP,"<small_rock2>",8$
$SP,"<medium_rock>",9$
$SP,"<medium_rock2>",10$
$SP,"<large_rock>",11$
$SP,"<large_rock2>",12$
$SP,"<Bullet>",13$
$SP,"<Cargo>",14$
$BG$
#define CMD_NULL 0
#define CMD_SPIN_LEFT 1
#define CMD_SPIN_RIGHT 2
#define CMD_THRUST 3
#define CMD_FIRE 4
#define CMD_GAME_OVER 5
I64 cmd_code=CMD_NULL;
#define NUM_STARS 100
I64 stars_x[NUM_STARS],stars_y[NUM_STARS];
Bool bounce;
#define OT_SHIP 1
#define OT_CARGO 2
#define OT_BULLET 3
#define OT_TINY_ROCK 4
#define OT_SMALL_ROCK 5
#define OT_MEDIUM_ROCK 6
#define OT_LARGE_ROCK 7
#define A_TRANSITION -1
#define A_INACTIVE 0
#define A_ACTIVE 1
class Order2D2é
{
F64 x,y,é;
F64 DxDt,DyDt,DéDt;
};
class Obj
{
I32 active;
I32 type;
U8 *img;
F64 mass,radius;
F64 timeout;
};
#define NUM_OBJECTS 256
CMathODE *ode;
Order2D2é *o_state;
Obj *objs;
U0 ObjInit(I64 i, I64 type)
{
objs[i].active=A_ACTIVE;
objs[i].timeout=0;
objs[i].type=type;
switch (type) {
case OT_SHIP:
if (bounce)
objs[i].img=$IB,"<ship_null>",1$;
else
objs[i].img=$IB,"<ship_null>",3$;
objs[i].radius=15;
break;
case OT_CARGO:
objs[i].img=$IB,"<cargo>",14$;
objs[i].radius=30;
break;
case OT_BULLET:
objs[i].img=$IB,"<bullet>",15$;
objs[i].radius=7;
break;
case OT_TINY_ROCK:
if (i&1)
objs[i].img=$IB,"<tiny_rock>",5$;
else
objs[i].img=$IB,"<tiny_rock2>",6$;
objs[i].radius=5;
break;
case OT_SMALL_ROCK:
if (i&1)
objs[i].img=$IB,"<small_rock>",16$;
else
objs[i].img=$IB,"<small_rock2>",8$;
objs[i].radius=11;
break;
case OT_MEDIUM_ROCK:
if (i&1)
objs[i].img=$IB,"<medium_rock>",17$;
else
objs[i].img=$IB,"<medium_rock2>",10$;
objs[i].radius=20;
break;
case OT_LARGE_ROCK:
if (i&1)
objs[i].img=$IB,"<large_rock>",18$;
else
objs[i].img=$IB,"<large_rock2>",12$;
objs[i].radius=26;
break;
}
objs[i].mass=objs[i].radius*objs[i].radius*objs[i].radius;
}
I64 ObjAlloc(I64 type)
{
I64 i;
for (i=0;i<NUM_OBJECTS-1;i++)
if (objs[i].active==A_INACTIVE)
break;
ObjInit(i,type);
return i;
}
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,x,y;
task->text_attr=BLACK<<4+WHITE;
dc->color=WHITE;
for (i=0;i<NUM_STARS;i++)
GrPlot(dc,stars_x[i],stars_y[i]);
for (i=0;i<NUM_OBJECTS;i++) {
if (objs[i].active==A_ACTIVE) {
if (objs[i].timeout && objs[i].timeout<tT)
objs[i].active=A_INACTIVE;
else {
x=o_state[i].x;
y=o_state[i].y;
if (x<0) {
x=GR_WIDTH-AbsI64(x)%GR_WIDTH;
o_state[i].x=x;
} else if (x>GR_WIDTH) {
x%=GR_WIDTH;
o_state[i].x=x;
}
if (y<0) {
y=GR_HEIGHT-AbsI64(y)%GR_HEIGHT;
o_state[i].y=y;
} else if (y>GR_HEIGHT) {
y%=GR_HEIGHT;
o_state[i].y=y;
}
switch (objs[i].type) {
case OT_SHIP:
if (bounce) {
if (cmd_code==CMD_THRUST && RandU16&0x8000)
SpritePlotRotZ3b(dc,x,y,0,$IB,"<ship_thrust>",2$,o_state[i].é);
else
SpritePlotRotZ3b(dc,x,y,0,$IB,"<ship_null>",1$,o_state[i].é);
} else {
if (cmd_code==CMD_THRUST && RandU16&0x8000)
SpritePlotRotZ3b(dc,x,y,0,$IB,"<ship_thrust>",4$,o_state[i].é);
else
SpritePlotRotZ3b(dc,x,y,0,$IB,"<ship_null>",3$,o_state[i].é);
}
break;
case OT_BULLET:
case OT_TINY_ROCK:
case OT_SMALL_ROCK:
case OT_MEDIUM_ROCK:
case OT_LARGE_ROCK:
case OT_CARGO:
SpritePlotRotZ3b(dc,x,y,0,objs[i].img,o_state[i].é);
break;
}
}
}
}
dc->color=WHITE;
GrPutS(dc,0,0,"Escort the cargo ship.");
}
U0 Init()
{
I64 i,j;
cmd_code=CMD_NULL;
for (i=0;i<NUM_STARS;i++) {
stars_x[i]=RandU16%GR_WIDTH;
stars_y[i]=RandU16%GR_HEIGHT;
}
MemSet(objs,0,sizeof(Obj)*NUM_OBJECTS);
MemSet(o_state,0,sizeof(Order2D2é)*NUM_OBJECTS);
i=ObjAlloc(OT_SHIP); //always #0
objs[i].mass=2.0*objs[i].radius*objs[i].radius*objs[i].radius;
o_state[i].x=GR_WIDTH/2;
o_state[i].y=GR_HEIGHT/2;
i=ObjAlloc(OT_CARGO); //always #1
objs[i].mass=0.5*objs[i].radius*objs[i].radius*objs[i].radius;
o_state[i].x=0;
o_state[i].DxDt=16.0;
o_state[i].y=GR_HEIGHT/2;
o_state[i].é=ã/2;
for (j=0;j<4;j++) {
i=ObjAlloc(OT_LARGE_ROCK);
o_state[i].x=RandU32%GR_WIDTH;
o_state[i].y=RandU32%GR_HEIGHT;
o_state[i].DxDt=RandI16/2000.0;
o_state[i].DyDt=RandI16/2000.0;
o_state[i].DéDt=RandI16/25000.0;
o_state[i].é=2*ã*RandI16/16384.0;
}
}
U0 MyDerivative(CMathODE *,F64,Order2D2é *state,Order2D2é *DstateDt)
{
I64 i,j;
F64 f,d,d1,dd,dx,dy;
MemSet(DstateDt,0,sizeof(Order2D2é)*NUM_OBJECTS);
for (i=0;i<NUM_OBJECTS;i++) {
if (objs[i].active==A_ACTIVE) {
DstateDt[i].x=state[i].DxDt;
DstateDt[i].y=state[i].DyDt;
DstateDt[i].é=state[i].DéDt;
for (j=0;j<NUM_OBJECTS;j++) {
if (i!=j && objs[j].active==A_ACTIVE) {
dx=state[i].x-state[j].x;
dy=state[i].y-state[j].y;
dd=Sqr(dx)+Sqr(dy);
d=Sqrt(dd);
if (d) {
dx/=d;
dy/=d;
} else {
dx=0;
dy=0;
}
d1=objs[i].radius+objs[j].radius;
f=0;
if (dd<Sqr(d1)) {
if (bounce && objs[i].type!=OT_CARGO && objs[j].type!=OT_CARGO) {
f=Sqr(Sqr(Sqr(d1-Abs(d)+0.1))); //spring force
if (f>1000000.0) f=1000000.0;
}
} else
f=-2.5*objs[i].mass*objs[j].mass/(dd+1.0);
DstateDt[i].DxDt+=f*dx/objs[i].mass;
DstateDt[i].DyDt+=f*dy/objs[i].mass;
}
}
}
}
switch (cmd_code) {
case CMD_SPIN_LEFT:
DstateDt[0].DéDt-=10.0;
break;
case CMD_SPIN_RIGHT:
DstateDt[0].DéDt+=10.0;
break;
case CMD_THRUST:
DstateDt[0].DxDt+=100.0*Cos(state[0].é-ã/2.0);
DstateDt[0].DyDt+=100.0*Sin(state[0].é-ã/2.0);
break;
}
DstateDt[1].DxDt+=2.0*Cos(state[1].é-ã/2.0);
DstateDt[1].DyDt+=2.0*Sin(state[1].é-ã/2.0);
}
U0 Collision(I64 i,I64 j)
{
I64 i2;
switch (objs[i].type) {
case OT_SHIP:
if (!bounce) {
cmd_code=CMD_GAME_OVER;
objs[i].active=A_INACTIVE;
}
break;
case OT_CARGO:
cmd_code=CMD_GAME_OVER;
objs[i].active=A_INACTIVE;
break;
case OT_TINY_ROCK:
if (objs[j].type==OT_BULLET && !bounce)
objs[i].active=A_INACTIVE;
break;
case OT_BULLET:
if (!bounce)
objs[i].active=A_INACTIVE;
break;
case OT_SMALL_ROCK:
case OT_MEDIUM_ROCK:
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x+objs[i2].radius+2.0;
o_state[i2].y=o_state[i].y;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x-objs[i2].radius-2.0;
o_state[i2].y=o_state[i].y;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
objs[i].active=A_INACTIVE;
break;
case OT_LARGE_ROCK:
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x+objs[i2].radius+4.0;
o_state[i2].y=o_state[i].y+objs[i2].radius+4.0;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x-objs[i2].radius-4.0;
o_state[i2].y=o_state[i].y-objs[i2].radius-4.0;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x-objs[i2].radius-4.0;
o_state[i2].y=o_state[i].y+objs[i2].radius+4.0;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
i2=ObjAlloc(objs[i].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[i].x+objs[i2].radius+4.0;
o_state[i2].y=o_state[i].y-objs[i2].radius-4.0;
o_state[i2].é=o_state[i].é;
o_state[i2].DxDt=o_state[i].DxDt;
o_state[i2].DyDt=o_state[i].DyDt;
o_state[i2].DéDt=o_state[i].DéDt;
objs[i].active=A_INACTIVE;
break;
}
switch (objs[j].type) {
case OT_SHIP:
if (!bounce) {
cmd_code=CMD_GAME_OVER;
objs[j].active=A_INACTIVE;
}
break;
case OT_CARGO:
cmd_code=CMD_GAME_OVER;
objs[j].active=A_INACTIVE;
break;
case OT_TINY_ROCK:
if (objs[i].type==OT_BULLET && !bounce)
objs[j].active=A_INACTIVE;
break;
case OT_BULLET:
if (!bounce)
objs[j].active=A_INACTIVE;
break;
case OT_SMALL_ROCK:
case OT_MEDIUM_ROCK:
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x+objs[i2].radius+2.0;
o_state[i2].y=o_state[j].y;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x-objs[i2].radius-2.0;
o_state[i2].y=o_state[j].y;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
objs[j].active=A_INACTIVE;
break;
case OT_LARGE_ROCK:
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x+objs[i2].radius+4.0;
o_state[i2].y=o_state[j].y+objs[i2].radius+4.0;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x-objs[i2].radius-4.0;
o_state[i2].y=o_state[j].y-objs[i2].radius-4.0;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x-objs[i2].radius-4.0;
o_state[i2].y=o_state[j].y+objs[i2].radius+4.0;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
i2=ObjAlloc(objs[j].type-1);
objs[i2].active=A_TRANSITION;
o_state[i2].x=o_state[j].x+objs[i2].radius+4.0;
o_state[i2].y=o_state[j].y-objs[i2].radius-4.0;
o_state[i2].é=o_state[j].é;
o_state[i2].DxDt=o_state[j].DxDt;
o_state[i2].DyDt=o_state[j].DyDt;
o_state[i2].DéDt=o_state[j].DéDt;
objs[j].active=A_INACTIVE;
break;
}
}
U0 CheckCollisions()
{
I64 i,j;
F64 d,d1,dd,dx,dy;
CDC *dc;
for (i=0;i<NUM_OBJECTS;i++) {
if (objs[i].active==A_ACTIVE) {
for (j=i+1;j<NUM_OBJECTS;j++) {
if (objs[j].active==A_ACTIVE) {
dx=o_state[i].x-o_state[j].x;
dy=o_state[i].y-o_state[j].y;
dd=Sqr(dx)+Sqr(dy);
d=Sqrt(dd);
if (d) {
dx/=d;
dy/=d;
} else {
dx=0;
dy=0;
}
d1=objs[i].radius+objs[j].radius;
if (dd<Sqr(d1)) {
dc=DCNew(DCT_COLOR8,64,64,Fs);
SpritePlotRotZ3b(dc,32,32,0,objs[i].img,o_state[i].é);
dc->color=ROP_COLLISION;
dc->bkcolor=BLACK;
SpritePlotRotZ3b(dc,o_state[j].x-o_state[i].x+32,
o_state[j].y-o_state[i].y+32,0,
objs[j].img,o_state[j].é);
if (dc->collision_cnt>0)
Collision(i,j);
DCDel(dc);
}
}
}
}
}
for (i=0;i<NUM_OBJECTS;i++)
if (objs[i].active==A_TRANSITION)
objs[i].active=A_ACTIVE;
}
#define MUZZLE_VELOCITY 500.0
U0 Fire()
{
F64 é=o_state[0].é;
I64 i=ObjAlloc(OT_BULLET);
objs[i].timeout=tT+0.5;
objs[i].mass*=10.0;
o_state[i].x=o_state[0].x+(objs[0].radius+objs[i].radius+1.0)*Cos(é-ã/2.0);
o_state[i].y=o_state[0].y+(objs[0].radius+objs[i].radius+1.0)*Sin(é-ã/2.0);
o_state[i].DxDt=o_state[0].DxDt+MUZZLE_VELOCITY*Cos(é-ã/2.0);
o_state[i].DyDt=o_state[0].DyDt+MUZZLE_VELOCITY*Sin(é-ã/2.0);
o_state[i].DéDt=RandI16/3000.0;
//not real physics with the 0.005 factor
o_state[0].DxDt-=0.005*MUZZLE_VELOCITY*Cos(é-ã/2.0)*objs[i].mass/objs[0].mass;
o_state[0].DyDt-=0.005*MUZZLE_VELOCITY*Sin(é-ã/2.0)*objs[i].mass/objs[0].mass;
}
U0 CheckCrazy()
{
I64 i;
F64 d;
for (i=0;i<NUM_OBJECTS;i++)
if (objs[i].active==A_ACTIVE) {
d=Sqrt(Sqr(o_state[i].DxDt)+Sqr(o_state[i].DyDt));
if (d>MUZZLE_VELOCITY*5.0)
Auto(" ");
}
}
U0 SongTask(I64)
{ //Song by Terry A. Davis
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("W13eGGsGGeGGGe.GeCDsEDeCBAe.AeG");
Play("GsGGeGGGe.GeFEsDEeDCBe.AeFD");
Play("EDFDEDECDCECDCsGGeG");
Play("GG2hG3sGGeGGG2hG");
}
}
U0 Rocks()
{
I64 ch,sc,msg_code;
CMenuEntry *tempse;
PopUpOk(
"I refuse to rip-off the original\n"
"so this is intentionally unplayable\n"
"and included for demonstration\n"
"purposes.\n\n"
"Write games, don't play them.\n");
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Preempt(OFF),
WinBorder;
WordStat;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" Fire(,CH_SPACE);"
" Fwd(,,SC_CURSOR_UP);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" ToggleBounce(,'b');"
"}"
);
tempse=MenuEntryFind(Fs->cur_menu,"Play/ToggleBounce");
tempse->checked=bounce=TRUE;
ode=ODENew(NUM_OBJECTS*6,0.01);
ode->derivative=&MyDerivative;
ode->min_tolerance=0.001*ode->max_tolerance;
o_state=ode->state;
objs=MAlloc(NUM_OBJECTS*sizeof(Obj));
WinMax;
Init;
QueIns(ode,Fs->last_ode);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
while (msg_code=ScanMsg(&ch,&sc,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
if (msg_code==MSG_KEY_DOWN)
switch (ch) {
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
cmd_code=CMD_SPIN_RIGHT;
break;
case SC_CURSOR_LEFT:
cmd_code=CMD_SPIN_LEFT;
break;
case SC_CURSOR_UP:
cmd_code=CMD_THRUST;
break;
}
break;
case CH_SPACE:
Fire;
break;
case '\n':
Init;
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto rk_done;
case 'b':
tempse=MenuEntryFind(Fs->cur_menu,"Play/ToggleBounce");
tempse->checked=bounce=!bounce;
break;
}
else //MSG_KEY_UP
cmd_code=CMD_NULL;
}
CheckCollisions;
CheckCrazy;
if (cmd_code==CMD_GAME_OVER) {
Sleep(1000);
Init;
}
WinMgrSync; //msgs are only qued by winmngr
}
rk_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
CatchAll;
QueRem(ode);
ODEDel(ode);
Free(objs);
MenuPop;
SettingsPop;
}
Rocks;
®ùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿ   
 ôÿÿÿôÿÿÿôÿÿÿôÿÿÿùÿÿÿùÿÿÿùÿÿÿùÿÿÿþÿÿÿ þÿÿÿ   ùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿÿÿÿÿþÿÿÿ
þÿÿÿ

 ␍  ýÿÿÿ



óÿÿÿóÿÿÿøÿÿÿøÿÿÿûÿÿÿ ûÿÿÿ 3þÿÿÿýÿÿÿólß$† n[½þÿÿÿd¨ Šgþÿÿÿûÿÿÿn[Ïm’$C’$É$QeÛ¼„ar–ͳíÙžW’"Cš¶½mÛ²úÿÿÿ¶m’6MÛ+üÿÿÿ¤m
þÿÿÿþÿÿÿ¤iÛ
I² Grüÿÿÿôÿÿÿóæy^ÝÚ³m“$íÛmÛ³g’¡F CQŒ¢d["‰©( ³lÁ°lž×n$I’T¤$à ÷ÿÿÿž=Û$Íúÿÿÿ«]»¶m“¦IFI’$I’„IrY–ms×zõÖm¶kÛ&MÛ¶m“¤%‘’l¶e[’$‰HÒ·m›<I“$I’$I’ ³mÛ¶mÛ¶m[DŠŒüÿÿÿøÿÿÿ¶Mß§m{ þÿÿÿI�ɶm›·yÛùÿÿÿv]×£’,K€$ÉW $¥�Q‘ IŠK°Ù2Û´MoK’dɶm›=Ï3O“¦=␍øÿÿÿúÿÿÿ«ëu¦␍ó ÿÿÿÿþÿÿÿþÿÿÿþÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿþÿÿÿþÿÿÿþÿÿÿÿÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿÿÿÿÿÿÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÿÿÿ
þÿÿÿýÿÿÿþÿÿÿó ÿÿÿÿþÿÿÿþÿÿÿþÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿþÿÿÿþÿÿÿþÿÿÿÿÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿÿÿÿÿÿÿÿÿýÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÿÿÿ
þÿÿÿýÿÿÿþÿÿÿ3þÿÿÿýÿÿÿólß$† n[½þÿÿÿd¨Šgþÿÿÿûÿÿÿn[Ïm’$C’$É$QeÛ¼„ar–ͳíÙžW’"Cš¶½mÛ²úÿÿÿ¶m’6MÛ+üÿÿÿ¤m
þÿÿÿþÿÿÿ¤iÛ
I²Grüÿÿÿôÿÿÿóæy^ÝÚ³m“$íÛmÛ³g’¡F CQŒ¢d["‰©( ³lÁ°lž×n$I’T¤$à ÷ÿÿÿž=Û$Íúÿÿÿ«]»¶m“¦IFI’$I’„IrY–ms×zõÖm¶kÛ&MÛ¶m“¤%‘’l¶e[’$‰HÒ·m›<I“$I’$I’ ³mÛ¶mÛ¶m[DŠŒüÿÿÿøÿÿÿ¶Mß§m{ þÿÿÿI�ɶm›·yÛùÿÿÿv]×£’,K€$ÉW $¥�Q‘ IŠK°Ù2Û´MoK’dɶm›=Ï3O“¦=␍øÿÿÿúÿÿÿ«ëu¦6(ÿÿÿÿûÿÿÿÛlÛ¤m“dÂ�$·m ²dþÿÿÿþÿÿÿöiÚ
kMøÿÿÿصkۦϓ$Û$‰$ ’ A’$$m»Þ6ÏófGÿÿÿÿûÿÿÿuëÚöH† EQdlÛö-Q$Æë Á²lmýÿÿÿúÿÿÿ ÙöÿÿÿsÛÖmëÖ­ÏŸmû$¥$”"mY�%‰¢( #I’ÚömÛ®k»@’,˶mö¼$a…‰Â�$mÛ¾i’¾ùÛÁ¶mÛ¶m›çºvm[I¤„‰ÂDGøÿÿÿ®ëÚöì%›mÛ¶Iš´ízÛšˆÜþoI&IGA’$I’$II”m“¤ïmÛ¶Õž·$
’!É␍+øÿÿÿþÿÿÿk»éÿ´mÓ$™0L�e[ ýÿÿÿI– Éúÿÿÿ]Û" ýÿÿÿ›·Í¶m& ¥�¦í­¾ðÿÿÿþÿÿÿÿÿÿÿ ␍ûÿÿÿúÿÿÿûÿÿÿúÿÿÿùÿÿÿöÿÿÿöÿÿÿúÿÿÿþÿÿÿüÿÿÿüÿÿÿýÿÿÿýÿÿÿ␍␍␍ýÿÿÿ

þÿÿÿûÿÿÿþÿÿÿûÿÿÿ␍   ÿÿÿÿúÿÿÿüÿÿÿ ûÿÿÿþÿÿÿùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿŸùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿÿÿÿÿþÿÿÿ
þÿÿÿ

 ␍ 'þÿÿÿþÿÿÿ4In]Kjÿÿÿÿ (þÿÿÿ6™%Ifýÿÿÿ$I
Binary file not shown.
Binary file not shown.
-540
View File
@@ -1,540 +0,0 @@
AcctRegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
AcctRegExecuteBranch("TempleOS/Wenceslas");
#define BORDER 5
#define KING_STEP 4
$SP,"<1>",1$
$SP,"<2>",2$
$SP,"<3>",3$
$SP,"<4>",4$
$SP,"<5>",5$
$SP,"<6>",6$
$SP,"<7>",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->win_pixel_width,h=task->win_pixel_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>",4$;
else
img=$IB,"<5>",5$;
} else
img=$IB,"<3>",3$;
SpritePlot3(dc,trees[i].x,trees[i].y,0,img);
}
}
SpritePlot3(dc,w/2,h/2,0,$IB,"<6>",6$);
if (tT<door_open_t0+1.0)
SpritePlot3(dc,w/2,h/2,0,$IB,"<7>",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>",4$;
else
img=$IB,"<5>",5$;
} else
img=$IB,"<3>",3$;
SpritePlot3(dc,trees[i].x,trees[i].y,0,img);
}
}
temps=step_root.next;
while (temps!=&step_root) {
if (tT-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;
SpritePlotRotMat3b(dc,tempp->x,tempp->y,0,$IB,"<2>",2$,r);
tempp=tempp->next;
}
dc->pen_width=1;
GrIdentEqu(r);
GrRotYEqu(r,king_é+ã/2);
GrRotXEqu(r,ã/6);
SpritePlotRotMat3b(dc,king_x,king_y,0,$IB,"<1>",1$,r);
dc->pen_width=1;
dc->color=WHITE;
for (i=0;i<NUM_FLAKES;i++)
GrPlot(dc,(flakes[i].x+snow_x)%task->win_pixel_width,
(flakes[i].y+snow_y)%task->win_pixel_height);
if (tf) {
dc->color=LTRED;
if (Blink)
GrPutS(dc,w/2-(FONT_WIDTH*14)/2,h/2+FONT_HEIGHT,"Game Completed");
tt=tf;
} else {
tt=tT;
}
dc->color=LTBLUE;
GrPrintF(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=tT;
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=tT;
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=tT;
QueIns(temps,step_root.last);
}
U0 Init()
{
I64 i,min_x,max_x,min_y,max_y,
w=Fs->win_pixel_width,h=Fs->win_pixel_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>",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>",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=tT;
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(tT-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->win_pixel_width;
h=Fs->parent_task->win_pixel_height;
temps=step_root.next;
while (temps!=&step_root) {
temps1=temps->next;
if (tT-temps->t0>4.0) {
QueRem(temps);
Free(temps);
}
temps=temps1;
}
temps=king_step_root.next;
while (temps!=&king_step_root) {
temps1=temps->next;
if (tT-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 && tT>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=tT;
}
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=tT;
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("W13eCCCDCC2qG3eA2G3ABqCC");
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","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("
$$FG,PURPLE$$$$TX+CX,\"Winceslas Game\"$$$$FG$$
Start fires by pressing $$FG,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->win_pixel_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->win_pixel_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
CatchAll;
SettingsPop;
MenuPop;
CleanUp;
AcctRegWriteBranch("TempleOS/Wenceslas","F64 best_score=%5.4f;\n",best_score);
}
Wenceslas;
yþÿÿÿÚÿÿÿÊÿÿÿþÿÿÿÚÿÿÿ äÿÿÿÖÿÿÿ
ÐÿÿÿúÿÿÿÖÿÿÿôÿÿÿìÿÿÿüÿÿÿØÿÿÿúÿÿÿðÿÿÿüÿÿÿðÿÿÿÖÿÿÿüÿÿÿÔÿÿÿòÿÿÿæÿÿÿÒÿÿÿöÿÿÿÂÿÿÿþÿÿÿÔÿÿÿòÿÿÿ¼ÿÿÿþÿÿÿÎÿÿÿ ¼ÿÿÿþÿÿÿÔÿÿÿÊÿÿÿþÿÿÿØÿÿÿäÿÿÿÚÿÿÿÀÿÿÿþÿÿÿÎÿÿÿ´ÿÿÿÊÿÿÿªÿÿÿÿÿÿøÿÿÿÈÿÿÿ²ÿÿÿ¬ÿÿÿÆÿÿÿ
ÿÿÿÌÿÿÿ ÌÿÿÿüÿÿÿÔÿÿÿèÿÿÿÚÿÿÿÖÿÿÿ* ðÿÿÿüÿÿÿðÿÿÿðÿÿÿèÿÿÿþÿÿÿòÿÿÿüÿÿÿæÿÿÿþÿÿÿæÿÿÿàÿÿÿþÿÿÿèÿÿÿüÿÿÿòÿÿÿæÿÿÿðÿÿÿþÿÿÿâÿÿÿàÿÿÿàÿÿÿÞÿÿÿÞÿÿÿâÿÿÿÞÿÿÿÞÿÿÿýÿÿÿäÿÿÿâÿÿÿþÿÿÿäÿÿÿüÿÿÿèÿÿÿüÿÿÿèÿÿÿüÿÿÿòÿÿÿäÿÿÿêÿÿÿæÿÿÿþÿÿÿîÿÿÿìÿÿÿòÿÿÿxþÿÿÿèÿÿÿüÿÿÿòÿÿÿðÿÿÿèÿÿÿðÿÿÿüÿÿÿðÿÿÿþÿÿÿòÿÿÿüÿÿÿæÿÿÿþÿÿÿæÿÿÿàÿÿÿæÿÿÿðÿÿÿãöÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿðÿÿÿòÿÿÿîÿÿÿêÿÿÿ öÿÿÿæÿÿÿúÿÿÿæÿÿÿöÿÿÿèÿÿÿøÿÿÿæÿÿÿæÿÿÿøÿÿÿîÿÿÿþÿÿÿòÿÿÿ  þÿÿÿöÿÿÿôÿÿÿîÿÿÿðÿÿÿðÿÿÿþÿÿÿ üÿÿÿþÿÿÿäÿÿÿþÿÿÿäÿÿÿîÿÿÿäÿÿÿöÿÿÿöÿÿÿöÿÿÿðÿÿÿøÿÿÿüÿÿÿüÿÿÿðÿÿÿ
ðÿÿÿøÿÿÿúÿÿÿþÿÿÿúÿÿÿúÿÿÿðÿÿÿüÿÿÿúÿÿÿ
üÿÿÿüÿÿÿøÿÿÿúÿÿÿøÿÿÿúÿÿÿðÿÿÿòÿÿÿìÿÿÿôöÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿðÿÿÿòÿÿÿîÿÿÿêÿÿÿ öÿÿÿæÿÿÿúÿÿÿæÿÿÿöÿÿÿèÿÿÿøÿÿÿæÿÿÿæÿÿÿøÿÿÿîÿÿÿþÿÿÿòÿÿÿ  þÿÿÿöÿÿÿôÿÿÿîÿÿÿäÿÿÿúÿÿÿâÿÿÿúÿÿÿèÿÿÿúÿÿÿöÿÿÿòÿÿÿîÿÿÿöÿÿÿúÿÿÿöÿÿÿøÿÿÿðÿÿÿöÿÿÿäÿÿÿôÿÿÿôÿÿÿüÿÿÿêÿÿÿþÿÿÿþÿÿÿüÿÿÿôÿÿÿ ôÿÿÿöÿÿÿòÿÿÿâÿÿÿþÿÿÿúÿÿÿöÿÿÿòÿÿÿüÿÿÿøÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿ
üÿÿÿJ³±»ÿÿÿfÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLine truncated
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,8 @@
//This uses $LK,"fixed-point","FI:::/TempleOS/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/FPS","F64 best_score=9999;\n");
AcctRegExecuteBranch("TempleOS/FPS");
AcctRegSetDftEntry("TempleOS/CastleFrankenstein","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/CastleFrankenstein");
//Set snap to 4 and width to 4
//if you edit this map.
@@ -70,6 +70,25 @@ $SP,"<1>",1$
$SP,"<6>",6$
#define SCREEN_SCALE 512
#define PLOT_GRID_WIDTH 24
#define PLOT_GRID_HEIGHT 24
@@ -118,14 +137,14 @@ Bool LOSPlot(U8 *,I64 x,I64 y,I64)
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,
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);
}
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,*r1,*r2,*r3,*s2w,xx,yy,zz,x,y,x1,y1,z1,
x1w,y1w,x1h,y1h,xh,yh,zh,
c,x1w,y1w,x1h,y1h,xh,yh,zh,
cx=task->win_pixel_width/2,
cy=task->win_pixel_height/2,
_man_xx=man_xx,_man_yy=man_yy;
@@ -133,7 +152,6 @@ U0 DrawIt(CTask *task,CDC *dc)
F64 tt,_man_é=man_é;
CD3I32 poly[4];
task->text_attr=BLACK<<4;
DCAllocDepthBuf(dc);
MemSet(panels_processed_bitmap,0,(map_width*map_height+7)>>3);
@@ -182,9 +200,13 @@ U0 DrawIt(CTask *task,CDC *dc)
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 ((dc->color=map[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;
@@ -198,13 +220,20 @@ U0 DrawIt(CTask *task,CDC *dc)
poly[3].y=y+SCREEN_SCALE;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
if (dc->color==GREEN) {
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,"<5>",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)
SpritePlotRotMat3b(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<6>",6$,r3);
}
if (!map[(yy+1)*map_width+xx]) {
@@ -379,6 +408,9 @@ 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>",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;
@@ -455,7 +487,7 @@ U0 SongTask(I64)
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("W12q.A#1eG2AeA#qAq.A#1eG2eAeA#qA");
Play("2q.A#1eG2AeA#qAq.A#1eG2eAeA#qA");
Play("q.A#1eG2A#A1qG2q.A#1eG2A#A1qG");
Play("3eA#A2qG3eA#A2qG3eA#A2G3AA#A2qG");
}
@@ -489,17 +521,9 @@ U0 RotateMan(F64 d)
}
}
U0 FPS()
U0 CastleFrankenstein()
{
I64 sc;
PopUpOk(
"I refuse to rip-off the original\n"
"so this is intentionally crappy\n"
"and included for demonstration\n"
"purposes.\n\n"
"Write games, don't play them.\n");
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
@@ -516,14 +540,14 @@ U0 FPS()
);
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->text_attr=RED<<4+WHITE;
Preempt(OFF);
WinMax;
WordStat;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
@@ -559,14 +583,15 @@ U0 FPS()
fs_done:
} catch
CatchAll;
DocClear;
SettingsPop;
CleanUp;
MenuPop;
AcctRegWriteBranch("TempleOS/FPS","F64 best_score=%5.4f;\n",best_score);
AcctRegWriteBranch("TempleOS/CastleFrankenstein","F64 best_score=%5.4f;\n",best_score);
}
FPS;
Æ    <<<< ,,,$8888$$$$444 4 ( ( ((0,0T0T0TLTL,L,L,404P4P4PHPH0H0H0808L8L8LDLD4D4D4<4<H<H<H@H@8@T@l@l4lLlLˆLˆLˆ$ˆ$€$€$€0€0l0p4„4„(„H€HpHpDp8p8€8€8€D€DtHtDt<t<|<x@|@|DxD„ „„tppp\\\\llhlll````ddd h hXTPPPLLL(@@8HHHH8888DD D D <Z,u @ ZDD<DDD\D\DdT0T8THL0LLd d hh88x8|8|4x4Z<HñÿÿÿñÿÿÿØÿÿÿìÿÿÿØÿÿÿûÿÿÿ¿ÿÿÿ¿ÿÿÿØÿÿÿØÿÿÿìÿÿÿƒÿÿÿçÿÿÿƒÿÿÿûÿÿÿƒÿÿÿƒÿÿÿ
CastleFrankenstein;
+    <<<< ,,,$8888$$$$444 4 ( ( ((0,0T0T0TLTL,L,L,404P4P4PHPH0H0H0808L8L8LDLD4D4D4<4<H<H<H@H@8@T@l@l4lLlLˆLˆLˆ$ˆ$€$€$€0€0l0p4„4„(„H€HpHpDp8p8€8€8€D€DtHtDt<t<|<x@|@|DxD„ „„tppp\\\\llhlll````ddd h hXTPPPLLL(@@8HHHH8888DD D D <Z,u @ ZDD<DDD\D\DdT0T8THL0LLd d hh88x8|8|4x4tt$t@8HLL,L4L<LZ<HñÿÿÿñÿÿÿØÿÿÿìÿÿÿØÿÿÿûÿÿÿ¿ÿÿÿ¿ÿÿÿØÿÿÿØÿÿÿìÿÿÿƒÿÿÿçÿÿÿƒÿÿÿûÿÿÿƒÿÿÿƒÿÿÿ
tÿÿÿöÿÿÿtÿÿÿ
¿ÿÿÿöÿÿÿ¿ÿÿÿƒÿÿÿ
@@ -656,4 +681,10 @@ FPS;
   


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


  

     ␍␍ ␍  
@@ -1,7 +1,7 @@
//Practice tracing circles
AcctRegSetDftEntry("TempleOS/CircleTrace","F64 best_score=999;\n");
AcctRegExecuteBranch("TempleOS/CircleTrace");
AcctRegExeBranch("TempleOS/CircleTrace");
I64 cx,cy;
F64 avg_error=0,elapsed_time=0,total_error=0,score=999;
@@ -39,7 +39,7 @@ U0 CircleTrace()
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
WordStat;
cx=Fs->win_pixel_width/2;
@@ -115,6 +115,7 @@ U0 CircleTrace()
break;
}
} while (msg_code!=MSG_KEY_DOWN || p1!=CH_SHIFT_ESC && p1!=CH_ESC);
GetMsg(,,1<<MSG_KEY_UP);
SettingsPop;
DCFill;
DCDel(dc);
@@ -24,6 +24,8 @@ U0 Digits()
I64 num,ch,i;
U8 answer[1024];
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->text_attr=DKGRAY<<4+WHITE;
DocClear;
//Set default background and foreground
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$"
@@ -54,7 +56,7 @@ restart:
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$\n";
"Guess\nLength:%d\n\n",num;
for (i=0;i<num;i++) {
ch=GetChar(NULL,FALSE);
ch=GetChar(,FALSE);
if (ch==CH_SHIFT_ESC || ch==CH_ESC)
return;
ShowDigit(ch);
@@ -71,7 +73,8 @@ restart:
}
}
dg_done:
"$$CL$$\n";
DocClear;
SettingsPop;
}
Digits;
@@ -5,7 +5,7 @@
//starting pos.
$BG,0$
$SP,"map",1$
$SP,"<1>",1$
@@ -15,70 +15,38 @@ $SP,"map",1$
$SP,"<2>",2$
$SP,"hero",2$
$SP,"<3>",3$
$SP,"hero_attack",3$
$SP,"template",4$ //This is a template you can copy and use to make a tile.
$SP,"<4>",4$ //This is a template you can copy and use to make a tile.
//WHITE is the transparent color.
$SP,"tree",5$
$SP,"<5>",5$
$SP,"<6>",6$
$SP,"path",6$
$SP,"<7>",7$
$SP,"water1",7$
$SP,"water2",8$
$SP,"<8>",8$
$SP,"goblin",9$
$SP,"wall1",10$
$SP,"wall2",11$
$SP,"<9>",9$
$SP,"<10>",10$
$SP,"<11>",11$
@@ -133,18 +101,17 @@ Bool LOSPlot(U8 *,I64 x,I64 y,I64)
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,
return LOSLine(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_dc,task);
CDC *dc_t=DCAlias(gr_dc2,task);
I64 i,x,y,xx,yy,x1,y1,z1,color;
CD3I32 poly[4];
U8 **_tiles;
task->text_attr=BLACK<<4;
if (Blink(5))
_tiles=tiles1;
else
@@ -158,7 +125,7 @@ U0 DrawIt(CTask *task,CDC *dc)
dc_t->flags|=DCF_TRANSFORMATION;
//You could make it much more efficient
//if you did it like $LK-A,"::/TempleOS/Demo/GameStarters/BigGuns.CPP"$
//if you did it like $LK-A,"::/TempleOS/Demo/Games/BigGuns.CPP"$
//with a $LK,"CDC","MN:CDC"$.
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
@@ -361,11 +328,12 @@ U0 DunGen()
);
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
Preempt(OFF);
WinMax;
WordStat;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
@@ -505,5 +473,5 @@ DunGen;
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
òþÿÿÿüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ b ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²'$ìÿÿÿäÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²öÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
òþÿÿÿüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ b ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²'$ìÿÿÿäÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ²öÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
@@ -7,7 +7,7 @@
I64 best_score=0; //Doesn't work yet for AOT
#else
AcctRegSetDftEntry("TempleOS/EagleDive","I64 best_score=0;\n");
AcctRegExecuteBranch("TempleOS/EagleDive");
AcctRegExeBranch("TempleOS/EagleDive");
#endif
@@ -97,9 +97,8 @@ Bool game_over;
class MPCtrl {
I64 mp_cnt;
I64 doc_update;
F64 update_done_t[MP_MAX_PROCESSORS];
I64 done_flags;
I64 init_not_done_flags,update_not_done_flags,app_not_done_flags;
F64 update_done_time[MP_MAX_PROCESSORS];
Bool app_done;
} mp;
@@ -129,7 +128,7 @@ U0 FSTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
U0 CalcNormals()
{
/*The idea is that there are two triangles
/*The idea is that there are two tris
forming every grid square and we find the normal
vect with a curl.
@@ -205,7 +204,7 @@ Bool TestSameSlope(I64 x,I64 y,I64 w,I64 h)
I64 k1,k2,xx,yy,s;
if (!(0<=x && x+w<MAP_WIDTH && 0<=y && y+h<MAP_HEIGHT))
return FALSE;
//Works well averaging the two slopes of two triangles.
//Works well averaging the two slopes of two tris.
//If it is too picky, we get too many panels.
s=normals[y][x*2]+normals[y][x*2+1];
for (k2=0;k2<h;k2++)
@@ -329,7 +328,7 @@ U0 MPDoPanels(CTask *task)
panel_root=start_ptr;
CriticalSectionEnd;
}
LBts(&mp.done_flags,Gs->num);
LBtr(&mp.init_not_done_flags,Gs->num);
}
@@ -385,12 +384,11 @@ U0 InitMap()
panel_root=NULL;
num_panels=0;
mp.done_flags=0;
for (i=1;i<mp.mp_cnt;i++)
MPSpawn(&MPDoPanels,Fs,"Do Panels",i);
MPDoPanels(Fs);
while (mp.done_flags!=1<<mp.mp_cnt-1)
Yield;
mp.init_not_done_flags=1<<mp.mp_cnt-1;
for (i=0;i<mp.mp_cnt;i++)
Spawn(&MPDoPanels,Fs,"Do Panels",i);
while (mp.init_not_done_flags)
Sleep(1);
panels_processed_bitmap=MAlloc((num_panels+7)>>3);
}
@@ -443,7 +441,7 @@ U0 MPDrawIt(CTask *task,CDC *dc)
x3,y3,z3,
cx=task->win_pixel_width>>1,
cy=task->win_pixel_height>>1;
F64 h_grid_size,t0=tT;
F64 h_grid_size,t=tT;
Panel reg *tempp;
xx=x/(MAP_SCALE*COORDINATE_SCALE);
@@ -544,7 +542,8 @@ U0 MPDrawIt(CTask *task,CDC *dc)
y1h+=yh;
}
Free(s2w);
mp.update_done_t[Gs->num]=tT-t0;
mp.update_done_time[Gs->num]=Limit(tT-t,.001,0.5);
LBtr(&mp.update_not_done_flags,Gs->num);
}
U0 APEagleDiveTask(CTask *master_task)
@@ -553,10 +552,8 @@ U0 APEagleDiveTask(CTask *master_task)
if (!IsSysDeterministic)
Preempt(ON);
while (!mp.app_done) {
LBts(&Fs->task_flags,TASKf_IDLE);
while (!LBtr(&mp.doc_update,Gs->num) && !mp.app_done)
Yield;
LBtr(&Fs->task_flags,TASKf_IDLE);
while (!Bt(&mp.update_not_done_flags,Gs->num) && !mp.app_done)
Sleep(1);
if (!mp.app_done)
MPDrawIt(master_task,dc);
}
@@ -565,7 +562,7 @@ U0 APEagleDiveTask(CTask *master_task)
dc->depth_buf=NULL;
DCDel(dc);
LBts(&mp.done_flags,Gs->num);
LBtr(&mp.app_not_done_flags,Gs->num);
}
U0 DrawHorizon(CDC *dc)
@@ -663,14 +660,13 @@ U0 DrawHorizon(CDC *dc)
U0 BSPEagleDive()
{
CDC *dc=DCAlias(main_dc,Fs);
F64 last_t;
F64 max_t;
I64 i,xx,yy,height,bkcolor,
cx=Fs->win_pixel_width>>1,
cy=Fs->win_pixel_height>>1;
Fish *tempf;
MemSet(panels_processed_bitmap,0,(num_panels+7)>>3);
MemSet(mp.update_done_t,0,sizeof(F64)*MP_MAX_PROCESSORS);
xx=x/(MAP_SCALE*COORDINATE_SCALE);
yy=y/(MAP_SCALE*COORDINATE_SCALE);
@@ -694,13 +690,7 @@ U0 BSPEagleDive()
DrawHorizon(dc);
DCDepthBufRst(dc);
//Signal all cores to start update
mp.doc_update=1<<mp.mp_cnt-1-1;
//Wait for all cores to start
while (mp.doc_update)
Yield;
mp.update_not_done_flags=1<<mp.mp_cnt-1;
MPDrawIt(Fs,dc);
xx=x/COORDINATE_SCALE;
@@ -712,23 +702,19 @@ U0 BSPEagleDive()
tempf=tempf->next;
}
//Wait for all cores to complete.
LBts(&Fs->task_flags,TASKf_IDLE);
for (i=1;i<mp.mp_cnt;i++)
while (!mp.update_done_t[i])
Yield;
LBtr(&Fs->task_flags,TASKf_IDLE);
while (mp.update_not_done_flags)
Sleep(1);
last_t=mp.update_done_t[0];
max_t=mp.update_done_time[0];
for (i=1;i<mp.mp_cnt;i++)
last_t=Max(last_t,mp.update_done_t[i]);
max_t=Max(max_t,mp.update_done_time[i]);
//Adjust size of updated grid.
v_grid_size *=0.90+0.10*(0.65/Fs->win_max_refresh)/last_t;
v_grid_size *=0.90+0.10*(0.65/Fs->win_max_refresh)/max_t;
v_grid_size=Limit(v_grid_size,20,200);
//Regulate how much grid expands in the distance.
if (mp.mp_cnt>1)
span_factor*=0.90+0.10*mp.update_done_t[mp.mp_cnt-1]/mp.update_done_t[0];
span_factor*=0.90+0.10*mp.update_done_time[mp.mp_cnt-1]/mp.update_done_time[0];
span_factor=Limit(span_factor,.30,3.0);
} else {
@@ -821,11 +807,11 @@ U0 AnimateTask(I64)
U0 MPEnd()
{
mp.done_flags=0;
mp.app_not_done_flags=1<<mp.mp_cnt-1-1;
mp.app_done=TRUE;
//Wait for all cores to exit
while (mp.done_flags!=1<<mp.mp_cnt-1-1)
Yield;
while (mp.app_not_done_flags)
Sleep(1);
}
U0 TaskEndCB()
@@ -844,7 +830,7 @@ U0 SongTask(I64)
MusicSettingsRst;
music_stacatto_factor=0.2;
while (TRUE) {
Play("W13eBDEDBDEDFEEDFEED");
Play("3eBDEDBDEDFEEDFEED");
Play("BDEDBDEDFEEDFEED");
}
}
@@ -879,7 +865,7 @@ U0 Init(I64 _mp_cnt)
z=64 *COORDINATE_SCALE*MAP_SCALE;
for (i=1;i<mp.mp_cnt;i++)
MPSpawn(&APEagleDiveTask,Fs,"AP EagleDive",i);
Spawn(&APEagleDiveTask,Fs,"AP EagleDive",i);
Fs->task_end_cb=&TaskEndCB;
game_t0=tT;
}
@@ -933,9 +919,9 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
WinMax;
WinBorder;
"Initializing...\n";
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Init(_mp_cnt);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
@@ -947,11 +933,11 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_DOWN:
è +=-CTRLS_SCALE*Cos(tt1);
è +=-CTRLS_SCALE*Cos(tt1);
é2+=-CTRLS_SCALE*Sin(tt1)*Sin(è);
break;
case SC_CURSOR_UP:
è -=-CTRLS_SCALE*Cos(tt1);
è -=-CTRLS_SCALE*Cos(tt1);
é2-=-CTRLS_SCALE*Sin(tt1)*Sin(è);
break;
case SC_CURSOR_RIGHT:
@@ -971,7 +957,7 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
break;
}
é1=Wrap(é1);
è =Wrap(è);
è =Wrap(è);
é2=Wrap(é2);
} else
BSPEagleDive;
@@ -987,4 +973,4 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
}
EagleDive;
.¨¢¢¨¢¨¢¨˜˜¢ˆ¢ˆxx¢h¢hXX¢H¢H88¢(¢(¢¨¨""2¨2¨BBR¨R¨bbr¨r¨‚‚’¨’!r8P"!t2R!v,T!N*p@!L.lD!L4hH!Tx&!Xz !\|!ZDtLâÿÿÿ%ãÿÿÿ#
.¨¢¢¨¢¨¢¨˜˜¢ˆ¢ˆxx¢h¢hXX¢H¢H88¢(¢(¢¨¨""2¨2¨BBR¨R¨bbr¨r¨‚‚’¨’!r8P"!t2R!v,T!N*p@!L.lD!L4hH!Tx&!Xz !\|!ZDt�àÿÿÿýÿÿÿýÿÿÿ""ÿÿÿÿ+ÿÿÿÿ+ & & üÿÿÿ üÿÿÿáÿÿÿáÿÿÿ)
@@ -152,8 +152,6 @@ U0 DrawIt(CTask *task,CDC *dc)
Obj *tempo;
Torpedo *tempt;
Bool old_preempt=Preempt(OFF);
task->text_attr=BLUE<<4+WHITE;
tempt=torpedo_root.next;
while (tempt!=&torpedo_root) {
@@ -696,11 +694,12 @@ U0 AnimateTask(I64)
}
U0 Navy()
U0 FlatTops()
{
I64 p1,p2;
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->text_attr=BLUE<<4+WHITE;
PopUpOk("$$FG,GREEN$${Left-Mouse}$$FG$$\t\tChange Course\n"
"$$FG,GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
"$$FG,GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
@@ -726,7 +725,7 @@ U0 Navy()
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
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)) {
@@ -766,5 +765,5 @@ nv_done:
CleanUp;
}
Navy;
FlatTops;
r&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿr&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍␍ÿ␍␍ÿ␍␍ÿ␍␍ÿ␍␍ÿ␍ÿ␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ␍␍ÿÿÿ␍␍ÿÿÿÿ␍␍␍␍ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0þÿÿÿÿÿÿÿ 0þÿÿÿÿÿÿÿ␍
@@ -10,37 +10,36 @@ Bool crash;
U0 DrawIt(CTask *task,CDC *dc)
{
I64 h=task->win_pixel_width,v=task->win_pixel_height;
I64 w=task->win_pixel_width,h=task->win_pixel_height;
I64 i,x,y,xx;
Bool old_preempt=Preempt(OFF);
xx=h>>1-car_x+road_x[road_ptr&(NUM_ROAD-1)];
xx=w>>1-car_x+road_x[road_ptr&(NUM_ROAD-1)];
task->text_attr=BLACK+BLACK<<4;
dc->color=LTGRAY;
for (i=0;i<NUM_ROAD;i++) {
x=h>>1-car_x+road_x[(i+road_ptr)&(NUM_ROAD-1)];
y=v-0.5*i;
if (y<v/2) break;
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=h>>1-CAR_WIDTH_BY_2;
x=w>>1-CAR_WIDTH_BY_2;
if (x<xx-ROAD_WIDTH_BY_2)
crash=TRUE;
GrLine(dc,x-10,v,x-40,v-100);
GrLine(dc,x+10,v,x+40,v-100);
GrLine(dc,x-10,h,x-40,h-100);
GrLine(dc,x+10,h,x+40,h-100);
x=h>>1+CAR_WIDTH_BY_2;
x=w>>1+CAR_WIDTH_BY_2;
if (x>xx+ROAD_WIDTH_BY_2)
crash=TRUE;
GrLine(dc,x-10,v,x-40,v-100);
GrLine(dc,x+10,v,x+40,v-100);
GrLine(dc,x-10,h,x-40,h-100);
GrLine(dc,x+10,h,x+40,h-100);
dc->color=YELLOW;
if (crash)
GrPutS(dc,h>>1-FONT_WIDTH*4,(v-FONT_HEIGHT)>>1,"Game Over");
GrPutS(dc,w>>1-FONT_WIDTH*4,(h-FONT_HEIGHT)>>1,"Game Over");
Preempt(old_preempt);
}
@@ -61,6 +60,8 @@ U0 UpdateRoad()
U0 Init()
{
I64 i,x=0;
DocClear;
"$$BG,DKGRAY$$"; NewLine((TEXT_ROWS-1)/2);
speed=0;
distance=0;
road_trend=0;
@@ -80,6 +81,7 @@ U0 Halogen()
{
I64 p1,p2,ch=0,sc=0;
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
@@ -98,7 +100,6 @@ U0 Halogen()
WinMax;
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
@@ -157,6 +158,7 @@ ha_done:
} catch
CatchAll;
MenuPop;
DocClear;
SettingsPop;
}
File renamed without changes.
File renamed without changes.
@@ -168,7 +168,7 @@ U0 RainDrops()
sc_1=A2ScanCode('1');
sc_2=A2ScanCode('2');
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
@@ -1,7 +1,7 @@
//This uses $LK,"fixed-point","FI:::/TempleOS/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/RawHide","F64 best_score=9999;\n");
AcctRegExecuteBranch("TempleOS/RawHide");
AcctRegExeBranch("TempleOS/RawHide");
F64 t0,tf;
@@ -238,9 +238,9 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=RED;
t=tf-t0;
if (Blink)
GrPutS(dc,(task->win_pixel_width-FONT_WIDTH*9)>>1-task->win_scroll_x,
GrPutS(dc,(task->win_pixel_width-FONT_WIDTH*14)>>1-task->win_scroll_x,
(task->win_pixel_height-FONT_HEIGHT)>>1-task->win_scroll_y,
"Game Over");
"Game Completed");
} else {
dc->color=BLACK;
t=tT-t0;
@@ -392,10 +392,10 @@ U0 SongTask(I64)
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("W13qC2etG!3DCBDC!!ECFqFC!sADAD!qB");
Play("C2etG!3DCBDC!!ECFqFC!sADAD!qB");
Play("!2sG3A!2G3A!qG2etG3GDeBBqBFeBAqE");
Play("!2sG3A!2G3A!qG2etG3GDeBBqBFeBAqE");
Play("3qC2etG3DCBDCECFqFCsADADqB");
Play("C2etG3DCBDCECFqFCsADADqB");
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
}
}
@@ -479,13 +479,13 @@ U0 RawHide()
" Restart(,'\n');"
"}"
);
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Fs->win_inhibit=WIF_ALL-WIF_BORDER-WIF_GRAB_SCROLL-WIF_MENU;
WinMax;
WordStat;
Preempt(OFF);
Init;
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
@@ -510,6 +510,7 @@ U0 RawHide()
}
}
rh_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
CatchAll;
MenuPop;
@@ -519,4 +520,4 @@ rh_done:
}
RawHide;
òöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿböÿÿÿôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÂöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
òöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿböÿÿÿôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÂöÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
@@ -29,6 +29,22 @@ $SP,"<3>",3$
$BG$
$SP+BP,"<4>",4,"::/TempleOS/Demo/Graphics/Camp.CPP.Z,6"$ //Pointer to sprite <6> in Camp.CPP.Z file
#define HOSE_RADIUS 3
#define LINK_SIZE 6
#define NOZZLE_START_Y (GR_HEIGHT-15*FONT_HEIGHT)
@@ -53,6 +69,7 @@ U0 DrawIt(CTask *task,CDC *dc)
MySpring *temps;
CD3I32 poly[4];
SpritePlot3(dc,0,GROUND_Y,0,$IB,"<4>",4$);
if (start_up_timeout>tT) {
ode->drag_v2=0.01; //Let hose settle during start-up
ode->drag_v3=0.0001;
@@ -294,9 +311,7 @@ U0 MoveNozzleTaskY(I64 sign)
U0 DrawBackGroundTextLayer()
{
DocClear;
"$$BG,LTCYAN$$";
NewLine(GROUND_Y/FONT_HEIGHT);
"$$BG,YELLOW$$";
"$$BG,LTCYAN$$"; NewLine(GROUND_Y/FONT_HEIGHT);
}
U0 Init()
@@ -322,7 +337,6 @@ U0 CleanUp()
QueDel(&ode->next_spring,TRUE);
ODEDel(ode);
DocClear;
"$$BG$$";
}
U0 SongTask(I64)
@@ -330,7 +344,7 @@ U0 SongTask(I64)
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
Play("W13eAM4/4");
Play("3eAM4/4");
Play("2qGeGqG3eAq.BqBeBqA2eG3qA");
Play("eB2hG3q.BqBeCq.DD");
Play("qCeBqCeDhB");
@@ -341,7 +355,8 @@ U0 Squirt()
{
I64 sc;
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
Fs->text_attr=YELLOW<<4+BLUE;
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
WinMax;
WinBorder;
Preempt(OFF);
@@ -365,7 +380,7 @@ U0 Squirt()
);
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->draw_it=&DrawIt;
try {
@@ -374,16 +389,16 @@ U0 Squirt()
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_LEFT:
Spawn(&MoveNozzleTaskX,-1,"Move Nozzle",Fs);
Spawn(&MoveNozzleTaskX,-1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_RIGHT:
Spawn(&MoveNozzleTaskX,1,"Move Nozzle",Fs);
Spawn(&MoveNozzleTaskX,1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_UP:
Spawn(&MoveNozzleTaskY,-1,"Move Nozzle",Fs);
Spawn(&MoveNozzleTaskY,-1,"Move Nozzle",,Fs);
break;
case SC_CURSOR_DOWN:
Spawn(&MoveNozzleTaskY,1,"Move Nozzle",Fs);
Spawn(&MoveNozzleTaskY,1,"Move Nozzle",,Fs);
break;
}
break;
Binary file not shown.
@@ -4,21 +4,23 @@
U0 StadiumGen()
{
U0 (*fp_old_update)(CDC *dc);
CDC *dc;
CDC *dc,*dc2;
WinMax;
WinBorder;
DocClear;
Type("::/TempleOS/Demo/GameStarters/Stadium/Stadium.TXT");
Type("::/TempleOS/Demo/Games/Stadium/Stadium.TXT");
"$$CM,0,%d$$",TEXT_ROWS-2;
DocCursor(OFF);
fp_old_update=fp_final_screen_update; //hide mouse cursor
fp_final_screen_update=NULL;
WinMgrSync(2,TRUE);
dc=DCExtract(gr_screen_image,0,FONT_HEIGHT,GR_WIDTH,GR_HEIGHT);
dc2=DCCaptureScreen;
dc=DCExtract(dc2,0,FONT_HEIGHT,GR_WIDTH,GR_HEIGHT);
DCDel(dc2);
GRAWrite("::/TempleOS/Demo/GameStarters/Stadium/Stadium",dc);
GRAWrite("::/TempleOS/Demo/Games/Stadium/Stadium",dc);
DCDel(dc);
DocCursor(ON);
@@ -35,6 +35,12 @@ U0 DrawBoard(I64 player)
break;
}
/*
ipx,ipy are input pointer (mouse) x,y.
ip_lb is mouse left button
*/
if (player==1)
DrawX(dc,ipx-Fs->win_pixel_left,ipy-Fs->win_pixel_top);
else
+540
View File
@@ -0,0 +1,540 @@
AcctRegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/Wenceslas");
#define BORDER 5
#define KING_STEP 4
$SP,"<1>",1$
$SP,"<2>",2$
$SP,"<3>",3$
$SP,"<4>",4$
$SP,"<5>",5$
$SP,"<6>",6$
$SP,"<7>",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->win_pixel_width,h=task->win_pixel_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>",4$;
else
img=$IB,"<5>",5$;
} else
img=$IB,"<3>",3$;
SpritePlot3(dc,trees[i].x,trees[i].y,0,img);
}
}
SpritePlot3(dc,w/2,h/2,0,$IB,"<6>",6$);
if (tT<door_open_t0+1.0)
SpritePlot3(dc,w/2,h/2,0,$IB,"<7>",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>",4$;
else
img=$IB,"<5>",5$;
} else
img=$IB,"<3>",3$;
SpritePlot3(dc,trees[i].x,trees[i].y,0,img);
}
}
temps=step_root.next;
while (temps!=&step_root) {
if (tT-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;
SpritePlotRotMat3b(dc,tempp->x,tempp->y,0,$IB,"<2>",2$,r);
tempp=tempp->next;
}
dc->pen_width=1;
GrIdentEqu(r);
GrRotYEqu(r,king_é+ã/2);
GrRotXEqu(r,ã/6);
SpritePlotRotMat3b(dc,king_x,king_y,0,$IB,"<1>",1$,r);
dc->pen_width=1;
dc->color=WHITE;
for (i=0;i<NUM_FLAKES;i++)
GrPlot(dc,(flakes[i].x+snow_x)%task->win_pixel_width,
(flakes[i].y+snow_y)%task->win_pixel_height);
if (tf) {
dc->color=LTRED;
if (Blink)
GrPutS(dc,w/2-(FONT_WIDTH*14)/2,h/2+FONT_HEIGHT,"Game Completed");
tt=tf;
} else {
tt=tT;
}
dc->color=LTBLUE;
GrPrintF(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=tT;
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=tT;
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=tT;
QueIns(temps,step_root.last);
}
U0 Init()
{
I64 i,min_x,max_x,min_y,max_y,
w=Fs->win_pixel_width,h=Fs->win_pixel_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>",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>",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=tT;
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(tT-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->win_pixel_width;
h=Fs->parent_task->win_pixel_height;
temps=step_root.next;
while (temps!=&step_root) {
temps1=temps->next;
if (tT-temps->t0>4.0) {
QueRem(temps);
Free(temps);
}
temps=temps1;
}
temps=king_step_root.next;
while (temps!=&king_step_root) {
temps1=temps->next;
if (tT-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 && tT>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=tT;
}
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=tT;
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","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("
$$FG,PURPLE$$$$TX+CX,\"Winceslas Game\"$$$$FG$$
Start fires by pressing $$FG,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->win_pixel_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->win_pixel_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
CatchAll;
SettingsPop;
MenuPop;
CleanUp;
AcctRegWriteBranch("TempleOS/Wenceslas","F64 best_score=%5.4f;\n",best_score);
}
Wenceslas;
yþÿÿÿÚÿÿÿÊÿÿÿþÿÿÿÚÿÿÿ äÿÿÿÖÿÿÿ
ÐÿÿÿúÿÿÿÖÿÿÿôÿÿÿìÿÿÿüÿÿÿØÿÿÿúÿÿÿðÿÿÿüÿÿÿðÿÿÿÖÿÿÿüÿÿÿÔÿÿÿòÿÿÿæÿÿÿÒÿÿÿöÿÿÿÂÿÿÿþÿÿÿÔÿÿÿòÿÿÿ¼ÿÿÿþÿÿÿÎÿÿÿ ¼ÿÿÿþÿÿÿÔÿÿÿÊÿÿÿþÿÿÿØÿÿÿäÿÿÿÚÿÿÿÀÿÿÿþÿÿÿÎÿÿÿ´ÿÿÿÊÿÿÿªÿÿÿÿÿÿøÿÿÿÈÿÿÿ²ÿÿÿ¬ÿÿÿÆÿÿÿ
ÿÿÿÌÿÿÿ ÌÿÿÿüÿÿÿÔÿÿÿèÿÿÿÚÿÿÿÖÿÿÿ* ðÿÿÿüÿÿÿðÿÿÿðÿÿÿèÿÿÿþÿÿÿòÿÿÿüÿÿÿæÿÿÿþÿÿÿæÿÿÿàÿÿÿþÿÿÿèÿÿÿüÿÿÿòÿÿÿæÿÿÿðÿÿÿþÿÿÿâÿÿÿàÿÿÿàÿÿÿÞÿÿÿÞÿÿÿâÿÿÿÞÿÿÿÞÿÿÿýÿÿÿäÿÿÿâÿÿÿþÿÿÿäÿÿÿüÿÿÿèÿÿÿüÿÿÿèÿÿÿüÿÿÿòÿÿÿäÿÿÿêÿÿÿæÿÿÿþÿÿÿîÿÿÿìÿÿÿòÿÿÿxþÿÿÿèÿÿÿüÿÿÿòÿÿÿðÿÿÿèÿÿÿðÿÿÿüÿÿÿðÿÿÿþÿÿÿòÿÿÿüÿÿÿæÿÿÿþÿÿÿæÿÿÿàÿÿÿæÿÿÿðÿÿÿãöÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿðÿÿÿòÿÿÿîÿÿÿêÿÿÿ öÿÿÿæÿÿÿúÿÿÿæÿÿÿöÿÿÿèÿÿÿøÿÿÿæÿÿÿæÿÿÿøÿÿÿîÿÿÿþÿÿÿòÿÿÿ  þÿÿÿöÿÿÿôÿÿÿîÿÿÿðÿÿÿðÿÿÿþÿÿÿ üÿÿÿþÿÿÿäÿÿÿþÿÿÿäÿÿÿîÿÿÿäÿÿÿöÿÿÿöÿÿÿöÿÿÿðÿÿÿøÿÿÿüÿÿÿüÿÿÿðÿÿÿ
ðÿÿÿøÿÿÿúÿÿÿþÿÿÿúÿÿÿúÿÿÿðÿÿÿüÿÿÿúÿÿÿ
üÿÿÿüÿÿÿøÿÿÿúÿÿÿøÿÿÿúÿÿÿðÿÿÿòÿÿÿìÿÿÿôöÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿðÿÿÿòÿÿÿîÿÿÿêÿÿÿ öÿÿÿæÿÿÿúÿÿÿæÿÿÿöÿÿÿèÿÿÿøÿÿÿæÿÿÿæÿÿÿøÿÿÿîÿÿÿþÿÿÿòÿÿÿ  þÿÿÿöÿÿÿôÿÿÿîÿÿÿäÿÿÿúÿÿÿâÿÿÿúÿÿÿèÿÿÿúÿÿÿöÿÿÿòÿÿÿîÿÿÿöÿÿÿúÿÿÿöÿÿÿøÿÿÿðÿÿÿöÿÿÿäÿÿÿôÿÿÿôÿÿÿüÿÿÿêÿÿÿþÿÿÿþÿÿÿüÿÿÿôÿÿÿ ôÿÿÿöÿÿÿòÿÿÿâÿÿÿþÿÿÿúÿÿÿöÿÿÿòÿÿÿüÿÿÿøÿÿÿðÿÿÿøÿÿÿ
ôÿÿÿ
üÿÿÿÒbŸžÎÿÿÿhÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLine truncated
File renamed without changes.
Binary file not shown.
+2 -1
View File
@@ -7,7 +7,8 @@ U0 BSplineDemo()
SettingsPush;
Fs->win_inhibit=WIF_ALL-WIF_BORDER;
"$$CL$$Select ctrl points with left mouse. Right when finished.\n";
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);
-241
View File
@@ -1,241 +0,0 @@
Bool chged;
#define DAWG_SETTINGS_SPACING 16
#define DAWG_SETTINGS_RANGE 60
#define DAWG_SETTINGS_BORDER 2
class DawgSettingsState
{
I64 cnt,n2_amp,color_scale;
} glbl_state;
U0 DrawDawgSettingsCtrl(CDC *dc,CCtrl *c)
{
DawgSettingsState *s=c->state;
dc->color=LTRED;
GrRect(dc, c->left,c->top,DAWG_SETTINGS_SPACING*4+3,DAWG_SETTINGS_SPACING*2+DAWG_SETTINGS_RANGE);
dc->color=BLUE;
GrRect(dc, c->left+DAWG_SETTINGS_BORDER,c->top+DAWG_SETTINGS_BORDER,
DAWG_SETTINGS_SPACING*4+3-2*DAWG_SETTINGS_BORDER,DAWG_SETTINGS_SPACING*2+DAWG_SETTINGS_RANGE-2*DAWG_SETTINGS_BORDER);
dc->color=BLACK;
GrLine(dc,c->left+DAWG_SETTINGS_SPACING,c->top+DAWG_SETTINGS_SPACING,
c->left+DAWG_SETTINGS_SPACING,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1);
GrLine(dc,c->left+2*DAWG_SETTINGS_SPACING+1,c->top+DAWG_SETTINGS_SPACING,
c->left+2*DAWG_SETTINGS_SPACING+1,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1);
GrLine(dc,c->left+3*DAWG_SETTINGS_SPACING+1,c->top+DAWG_SETTINGS_SPACING,
c->left+3*DAWG_SETTINGS_SPACING+1,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1);
dc->color=LTRED;
GrPrintF(dc,c->left+DAWG_SETTINGS_SPACING-FONT_WIDTH/2,
c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE+3,
"%d",s->cnt*10/DAWG_SETTINGS_RANGE);
GrPrintF(dc,c->left+2*DAWG_SETTINGS_SPACING+1-FONT_WIDTH/2,
c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE+3,
"%d",s->n2_amp*10/DAWG_SETTINGS_RANGE);
GrPrintF(dc,c->left+3*DAWG_SETTINGS_SPACING+2-FONT_WIDTH/2,
c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE+3,
"%d",s->color_scale*10/DAWG_SETTINGS_RANGE);
GrRect(dc,c->left+DAWG_SETTINGS_SPACING-3, c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->cnt-2 ,7,5);
GrRect(dc,c->left+2*DAWG_SETTINGS_SPACING+1-3,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->n2_amp-2,7,5);
GrRect(dc,c->left+3*DAWG_SETTINGS_SPACING+2-3,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->color_scale-2,7,5);
dc->color=YELLOW;
GrRect(dc,c->left+DAWG_SETTINGS_SPACING-2, c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->cnt-1 ,5,3);
GrRect(dc,c->left+2*DAWG_SETTINGS_SPACING+1-2,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->n2_amp-1,5,3);
GrRect(dc,c->left+3*DAWG_SETTINGS_SPACING+2-2,c->top+DAWG_SETTINGS_SPACING+DAWG_SETTINGS_RANGE-1-s->color_scale-1,5,3);
}
U0 UpdateDerivedDawgSettingsCtrl(CCtrl *c)
{
DawgSettingsState *s=c->state;
c->left=c->win_task->win_pixel_width-(DAWG_SETTINGS_SPACING*4+3);
c->right=c->left+DAWG_SETTINGS_SPACING*4+3;
c->top=c->win_task->win_pixel_height-(DAWG_SETTINGS_SPACING*2+DAWG_SETTINGS_RANGE);
c->bottom=c->top+DAWG_SETTINGS_SPACING*2+DAWG_SETTINGS_RANGE;
s->cnt =LimitI64(s->cnt,0,DAWG_SETTINGS_RANGE-1);
s->n2_amp=LimitI64(s->n2_amp,0,DAWG_SETTINGS_RANGE-1);
s->color_scale=LimitI64(s->color_scale,0,DAWG_SETTINGS_RANGE-1);
}
U0 LeftClickDawgSettings(CCtrl *c,I64 x,I64 y,Bool down)
{
DawgSettingsState *s=c->state;
if (x<c->left+(c->right-c->left)/3)
s->cnt=DAWG_SETTINGS_RANGE-1-(y-(c->top+DAWG_SETTINGS_SPACING));
else if (x<c->left+2*(c->right-c->left)/3)
s->n2_amp=DAWG_SETTINGS_RANGE-1-(y-(c->top+DAWG_SETTINGS_SPACING));
else
s->color_scale=DAWG_SETTINGS_RANGE-1-(y-(c->top+DAWG_SETTINGS_SPACING));
if (c->update_derived_vals)
(*c->update_derived_vals)(c);
if (!down) chged=TRUE;
}
CCtrl *DawgSettingsNew()
{
Bool old_preempt;
CCtrl *c=CAlloc(sizeof(CCtrl));
c->win_task=Fs;
c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
c->type=CTRLT_GENERIC;
// c->state=CAlloc(sizeof(DawgSettingsState));
c->state=&glbl_state;
glbl_state.cnt=DAWG_SETTINGS_RANGE/2;
glbl_state.n2_amp=DAWG_SETTINGS_RANGE/2;
glbl_state.color_scale=DAWG_SETTINGS_RANGE/2;
c->draw_it=&DrawDawgSettingsCtrl;
c->left_click=&LeftClickDawgSettings;
c->update_derived_vals=&UpdateDerivedDawgSettingsCtrl;
old_preempt=Preempt(OFF);
QueIns(c,Fs->last_ctrl);
TaskDerivedValsUpdate;
Preempt(old_preempt);
return c;
}
U0 DawgSettingsDel(CCtrl *c)
{
Bool old_preempt=Preempt(OFF);
QueRem(c);
Preempt(old_preempt);
// Free(c->state);
Free(c);
}
//This program does a fractel-like thing with
//integer arithmetic.
class Simplex //This is something I made-up. It's not standard math.
{
I64 x,y;
};
I64 Norm(Simplex *n1)
{
return AbsI64(n1->x)+AbsI64(n1->y);
}
Simplex *CopySimplex(Simplex *dst, Simplex *src)
{
MemCpy(dst,src,sizeof(Simplex));
return dst;
}
Simplex *Mix(Simplex *result,Simplex *n1,Simplex *n2)
{ //This is something I made-up. It's not standard math.
result->x=n1->x*n2->x;
result->y=n1->y*n2->y;
return result;
}
Simplex *Mangle(Simplex *result,Simplex *n1,Simplex *n2)
{ //This is something I made-up. It's not standard math.
result->x=n1->x*n2->y;
result->y=n1->y*n2->x;
return result;
}
Simplex *Add(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=n1->x+n2->x;
result->y=n1->y+n2->y;
return result;
}
Simplex *Sub(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=n1->x-n2->x;
result->y=n1->y-n2->y;
return result;
}
U0 Bling()
{
I64 ch;
I64 x,y,cnt;
I64 d;
F64 color,color_scale;
Simplex n1,n2,n3,n4,n5,n6,n7,n8;
F64 timeout_time;
CCtrl *c=DawgSettingsNew;
CDC *dc=DCAlias;
F64 e=Exp(1);
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
DocCursor;
DocClear;
Fs->win_inhibit=WIF_ALL-WIF_BORDER-WIF_CTRLS;
chged=FALSE;
WordStat;
WinMax;
while (TRUE) {
next_dotel:
ch=0;
cnt =2e9*(RandU32+0x1000)/MAX_U32*((Exp(ToF64(glbl_state.cnt +10)/DAWG_SETTINGS_RANGE)-1)/e);
n2.x=2e9*Sign(RandI32)*(RandU32+0x1000)/MAX_U32*((Exp(ToF64(glbl_state.n2_amp)/DAWG_SETTINGS_RANGE)-1)/e);
n2.y=2e9*Sign(RandI32)*(RandU32+0x1000)/MAX_U32*((Exp(ToF64(glbl_state.n2_amp)/DAWG_SETTINGS_RANGE)-1)/e);
n8.x=RandI32;
n8.y=RandI32;
color_scale=4.0*(glbl_state.color_scale+1.0)/DAWG_SETTINGS_RANGE+0.5;
timeout_time=tT+0.1;
for (y=0;y<GR_HEIGHT;y++) {
if (y<20)
if (tT>timeout_time)
goto next_dotel;
if (ScanKey(&ch))
goto next_dotel;
for (x=0;x<GR_WIDTH;x++) {
if (y<20)
if (tT>timeout_time)
goto next_dotel;
n1.x=x; n1.y=y;
CopySimplex(&n3,&n1);
color=0;
d=Norm(&n3);
//This doesn't make mathematical sense, but it makes nice results.
while (d.u32[0]<cnt && color<65536) {
if (y<20)
if (tT>timeout_time)
goto next_dotel;
Mangle(&n7,Mix(&n4,&n3,&n1),
Add(&n5,&n3,&n2));
color++;
d=Norm(Add(&n3,&n7,Mangle(&n6,&n3,&n8)));
}
color-=(cnt-d.u32[0])/cnt;
dc->color=ROP_EQU+
color=gr_rainbow_10[LimitI64(color_scale*(Ln(color)),0,9)];
GrPlot(dc,x,y);
}
}
dc->color=COLOR_TRANSPARENT;
GrRect(dc,c->left,c->top,c->right-c->left,c->bottom-c->top);
while (TRUE) {
if (chged) {
chged=FALSE;
break;
}
if (ch=ScanChar)
if (ch==CH_SPACE||ch=='\n')
break;
else
goto bling_done;
WinMgrSync;
}
}
bling_done:
SettingsPop;
DCDel(dc);
DCFill;
DawgSettingsDel(c);
}
Bling; //Start when included
+1 -1
View File
@@ -9,7 +9,7 @@ GrFloodFill3(img1,30,30,0,TRUE);
GrLine3(img1,60,0,0,0,60,0);
DCFill(img2);
img2->color=ROP_EQU+RED;
img2->color=RED;
img2->brush=img1;
GrCircle(img2,256-30,256-30,128,67);
img2->color=BLUE;
+4 -4
View File
@@ -21,7 +21,7 @@ U0 DrawIt(CTask *,CDC *)
U0 Box()
{
F64 é=0,è=0,ê=0,s=1,s1=1.05;
dc=DCAlias(gr_dc,Fs);
dc=DCAlias(gr_dc2,Fs);
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
DocClear;
@@ -41,9 +41,9 @@ U0 Box()
Sleep(20);
é+=2*ã/70;
è +=2*ã/90;
ê +=2*ã/110;
s *=s1;
è+=2*ã/90;
ê+=2*ã/110;
s*=s1;
if ( !(0.2<s<1.4) ) s1=1/s1;
}
SettingsPop;
-64
View File
@@ -1,64 +0,0 @@
#define NUM_DATA_PTS 256
F64 CPU_idle[MP_MAX_PROCESSORS][NUM_DATA_PTS];
F64 mem[NUM_DATA_PTS];
F64 refresh[NUM_DATA_PTS];
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,x1,y1,x2,y2;
U8 buf[32];
for (i=1;i<NUM_DATA_PTS;i++) {
x1=(i-1)*task->win_pixel_width/(NUM_DATA_PTS-1);
x2=i*task->win_pixel_width/(NUM_DATA_PTS-1);
for (j=0;j<mp_cnt;j++) {
dc->color=gr_rainbow_10[j];
y1=task->win_pixel_height*CPU_idle[j][i-1];
y2=task->win_pixel_height*CPU_idle[j][i];
GrLine(dc,x1,y1,x2,y2);
}
dc->color=LTCYAN;
y1=task->win_pixel_height*mem[i-1];
y2=task->win_pixel_height*mem[i];
GrLine(dc,x1,y1,x2,y2);
dc->color=LTPURPLE;
y1=task->win_pixel_height*refresh[i-1];
y2=task->win_pixel_height*refresh[i];
GrLine(dc,x1,y1,x2,y2);
}
for (j=0;j<mp_cnt;j++) {
SPrintF(buf,"CPU%d",j);
PlotWinStr(task,buf,gr_rainbow_10[j]+WHITE<<4,0,task->win_height-4-j);
}
PlotWinStr(task,"Mem %",LTCYAN+WHITE<<4,0,task->win_height-3);
PlotWinStr(task,"Refresh Hz",LTPURPLE+WHITE<<4,0,task->win_height-2);
}
U0 CPUPlot()
{
I64 cur_pt=0,j;
MemSet(CPU_idle,0,sizeof(CPU_idle));
MemSet(mem,0,sizeof(F64)*NUM_DATA_PTS);
MemSet(refresh,0,sizeof(F64)*NUM_DATA_PTS);
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
while (!ScanChar) {
for (j=0;j<mp_cnt;j++)
CPU_idle[j][cur_pt]=cpu_structs[j].idle_factor;
mem[cur_pt]=ToF64(UnusedSysMem)/(sys_heap_limit-sys_heap_base+1);
refresh[cur_pt]=1.0-win_actual_refresh/100.0; //This plots on a scale of 0-100 Hz
Sleep(25);
cur_pt= ++cur_pt % NUM_DATA_PTS;
}
SettingsPop;
}
CPUPlot; //start when #included
//Study $LK-A,"::/TempleOS/Adam/MemRep.CPP"$ and $LK,"WallPaper","MN:WallPaper"$() to learn more about
//how the system resources are put together.
Binary file not shown.
+2 -2
View File
@@ -1,8 +1,8 @@
//See $LK-A,"::/TempleOS/Demo/GameStarters/Stadium/StadiumGen.CPP"$.
//See $LK-A,"::/TempleOS/Demo/Games/Stadium/StadiumGen.CPP"$.
U0 ViewScreenCapture(U8 *filename)
{
CDC *dc=DCAlias(gr_dc2,Fs),
CDC *dc=DCAlias(gr_dc,Fs),
*dc2=GRARead(filename);
GrBlot(dc,0,0,dc2);
DCDel(dc2);
+1 -1
View File
@@ -31,5 +31,5 @@ U0 AnimateTask(I64)
}
Spawn(&AnimateTask,NULL,"Animate",Fs);
Spawn(&AnimateTask,NULL,"Animate",,Fs);
TaskRep;
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -12,7 +12,7 @@ U0 Doodle()
WordStat;
DCFill;
"$$CL$$"; //$LK,"DocClear","MN:DocClear"$() is better
DocClear;
do {
msg_code=GetMsg(&p1,&p2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+
@@ -40,6 +40,7 @@ U0 Doodle()
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
GetMsg(,,1<<MSG_KEY_UP);
DCFill;
DCDel(dc);
SettingsPop;
+2
View File
@@ -1,3 +1,5 @@
//Press F5 to compile and run
U0 DotNet()
{
I64 i;
Binary file not shown.
Binary file not shown.
+1
View File
@@ -133,6 +133,7 @@ U0 FontEd()
}
}
fe_done:
GetMsg(,,1<<MSG_KEY_UP);
} catch
CatchAll;
MenuPop;
Binary file not shown.
+1 -1
View File
@@ -134,8 +134,8 @@ U0 Hanoi()
PressAKey;
} catch
CatchAll;
SettingsPop;
DocClear;
SettingsPop;
}
Hanoi;
+4 -3
View File
@@ -56,9 +56,9 @@ public U0 Life()
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
WinMax;
DCFill;
"$$CL$$";
DocClear;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
WordStat;
Fs->draw_it=&DrawIt;
Fs->win_inhibit=WIF_ALL-WIF_BORDER;
@@ -73,7 +73,7 @@ public U0 Life()
cnt=0;
while (msg_code!=MSG_IP_L_UP) {
restart=TRUE;
dc[cur_dc]->color=ROP_EQU+GREEN;
dc[cur_dc]->color=GREEN;
dc[cur_dc]->pen_width=0.04*ip_speed;
GrLine3(dc[cur_dc],x1,y1,0,x2,y2,0);
restart=TRUE;
@@ -88,6 +88,7 @@ public U0 Life()
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
GetMsg(,,1<<MSG_KEY_UP);
SettingsPop;
DCFill;
DCDel(dc[0]);
Binary file not shown.
Binary file not shown.
-21
View File
@@ -1,21 +0,0 @@
U0 DrawIt(CTask *task,CDC *)
{
if (win_updates&1)
PlotWinStr(task,"test",RED+WHITE*16,10,3);
else
PlotWinStr(task,"test",PURPLE+WHITE*16,10,3);
PlotWinStr(task,"test",RED+WHITE*16,10,2);
PlotWinStr(task,"test",PURPLE+WHITE*16,10,4);
}
U0 Main()
{
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
DocClear;
Fs->draw_it=&DrawIt;
GetChar;
SettingsPop;
}
Main;
-101
View File
@@ -1,101 +0,0 @@
U0 Convert()
{
I64 *ptr;
//Normally, allocate large objects on the heap
//because stk size can't grow. 256 bytes, however,
//is not that bad.
U8 byte_bit_cnts[256];
I64 i,j,row,col,ch,best_ch,score,best_score,cur_char_image,diff_image;
CDC *dc=DCAlias;
//Set-up a table telling how many 1 bits in a val.
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<Fs->win_height;row++) {
for (col=0;col<Fs->win_width;col++) {
//The size of one character is 8x8 pixels
//which fits in a 64-bit var. We'll
//fetch the pixels from the screen using $LK,"GrPeek","MN:GrPeek"$().
cur_char_image=0;
for (i=0;i<FONT_HEIGHT;i++)
for (j=0;j<FONT_WIDTH;j++)
//$LK,"GrPeek","MN:GrPeek"$() returns color or -1 if covered or off-screen.
if (GrPeek(dc,col*FONT_WIDTH+j,row*FONT_HEIGHT+i)!=COLOR_TRANSPARENT)
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=='$$')
"$$$$";
else
'' best_ch;
}
NewLine;
}
DCDel(dc);
}
public U0 Pic2ASCII()
{
I64 msg_code,cnt,x1,y1,x2,y2,p1,p2;
CDC *dc=DCAlias;
dc->color=ROP_EQU+BLACK;
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
Fs->win_inhibit=WIF_ALL-WIF_BORDER;
WinMax;
DCFill;
"$$CL$$Draw a picture and hit\na key to convert to ASCII.\n";
do {
msg_code=GetMsg(&p1,&p2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
switch (msg_code) {
case MSG_IP_L_DOWN:
x1=p1; y1=p2;
x2=p1; y2=p2;
cnt=0;
while (msg_code!=MSG_IP_L_UP) {
dc->pen_width=0.04*ip_speed;
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&p1,&p2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
x1=x2; y1=y2;
x2=p1; y2=p2;
}
GrLine3(dc,x1,y1,0,x2,y2,0);
break;
case MSG_KEY_DOWN:
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
//We clear the screen text and turn-off word-wrap
"$$CL$$$$WW,0$$";
Convert;
DCFill;
DCDel(dc);
SettingsPop;
}
Pic2ASCII; //Execute when #included
Loaded 100 of 617 files, more files were not shown because too many files have changed in this diff. Show more