SparrowOSTS_121127.ISO
This commit is contained in:
1 parent
0e9364ff4c
commit
e57428affb
1218 files changed
+247142
-165507
No files matched your search
@@ -0,0 +1,9 @@
|
||||
#include "/SparrowOS/Accts/Adam3bPkgs"
|
||||
|
||||
#include "/SparrowOS/Apps/TimeClock/Load.CPP.Z"
|
||||
#include "/SparrowOS/Apps/MusicOrgan/Load.CPP.Z"
|
||||
Cd("HOME");;
|
||||
#include "/SparrowOS/Accts/TS/TSAdam"
|
||||
#include "/SparrowOS/Accts/TS/TSDistribute"
|
||||
#include "/SparrowOS/Demo/WebLogExample/WebLogRep.CPP.Z"
|
||||
Cd("HOME");;
|
||||
@@ -0,0 +1,266 @@
|
||||
//Change anything you want in this
|
||||
//acct file or others.
|
||||
|
||||
U0 FillInTime()
|
||||
{
|
||||
CDate ltdt;
|
||||
ltdt=GetCurTimeCDate;
|
||||
"$$IV,1$$----%D %T----$$IV,0$$\n",ltdt,ltdt;
|
||||
}
|
||||
|
||||
U0 RandQuote(I64 num)
|
||||
{ //$LK,"::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z","FI:::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z"$
|
||||
I64 i,size,l=512;
|
||||
U8 *bible_filename=Define("ST_BIBLE_FILE"),
|
||||
*buf=FileRead(bible_filename,&size);
|
||||
if (buf) {
|
||||
i=num%(size-l);
|
||||
buf[i+l]=0;
|
||||
"" buf+i;
|
||||
Free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
U0 BadCodeJump(I64 num)
|
||||
{ //$LK,"::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z","FI:::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z"$
|
||||
CDirEntry *root=FilesFind("/SparrowOS/*",FUF_JUST_FILES|FUF_RECURSE|FUF_FLATTEN_TREE|FUF_JUST_SRC_FILES),
|
||||
*tempm=root;
|
||||
I64 cnt=0;
|
||||
CDoc *doc;
|
||||
U8 *st;
|
||||
while (tempm) {
|
||||
doc=DocRead(tempm->full_name);
|
||||
tempm->user_data=doc->root.y;
|
||||
cnt+=doc->root.y;
|
||||
DocDel(doc);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
num=num%cnt;
|
||||
tempm=root;
|
||||
while (tempm) {
|
||||
num-=tempm->user_data;
|
||||
if (num<0) {
|
||||
st=MSPrintF("FL:%s,%d",tempm->full_name,-num);
|
||||
break;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
CDirListDel(root);
|
||||
Ed(st);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
Bool MyPutKey(I64 ch,I64 sc)
|
||||
{ //ch=ASCII; sc=scancode
|
||||
|
||||
//See $LK,"Char","HI:Char"$ for definition of scan codes.
|
||||
//See $LK,"Keyboard Handling","FI:::/SparrowOS/Doc/KeyBoard.TXT.Z"$
|
||||
|
||||
//You can customize keys. This routine
|
||||
//is called before the main editor
|
||||
//key handler $LK,"DocPutKey","MN:DocPutKey"$().
|
||||
//You can intercept any key.
|
||||
|
||||
//Return TRUE if you completely
|
||||
//handled the key.
|
||||
|
||||
I64 i,sc2=sc.u8[0];
|
||||
|
||||
if (SC_F1<=sc2<=SC_F10 &&
|
||||
sc&SCF_ALT &&
|
||||
!(sc & SCF_CTRL)) {
|
||||
switch (sc2) {
|
||||
case SC_F1:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/LTPURPLE");
|
||||
else
|
||||
SetKeyDesc("Dollar/PURPLE");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
"$$FG,LTPURPLE$$";
|
||||
else
|
||||
"$$FG,PURPLE$$";
|
||||
}
|
||||
break;
|
||||
case SC_F2:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/LTRED");
|
||||
else
|
||||
SetKeyDesc("Dollar/RED");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
"$$FG,LTRED$$";
|
||||
else
|
||||
"$$FG,RED$$";
|
||||
}
|
||||
break;
|
||||
case SC_F3:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/LTGREEN");
|
||||
else
|
||||
SetKeyDesc("Dollar/GREEN");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
"$$FG,LTGREEN$$";
|
||||
else
|
||||
"$$FG,GREEN$$";
|
||||
}
|
||||
break;
|
||||
case SC_F4:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/LTBLUE");
|
||||
else
|
||||
SetKeyDesc("Dollar/Default Color");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
"$$FG,LTBLUE$$";
|
||||
else
|
||||
"$$FG$$";
|
||||
}
|
||||
break;
|
||||
case SC_F5:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("God Passage");
|
||||
else
|
||||
SetKeyDesc("God Word");
|
||||
} else {
|
||||
//$LK,"::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z","FI:::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z"$
|
||||
if (sc & SCF_SHIFT)
|
||||
RandQuote(KbdMouseEvtTime>>4);
|
||||
else
|
||||
"%s ",ws_sorted_words[KbdMouseEvtTime>>4%ws_num_words]->str;
|
||||
}
|
||||
break;
|
||||
case SC_F6:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Cmd/Init WordStat Text");
|
||||
else
|
||||
SetKeyDesc("Cmd/Init WordStat LT");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
PopUp("WSInit(\"::/SparrowOS/Misc/Bible.TXT.Z\");");
|
||||
else
|
||||
PopUp("WSInit(\"::/SparrowOS/\" TEXT_FILE_MASK \";~*Bible.TXT.Z\");");
|
||||
}
|
||||
break;
|
||||
case SC_F7:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc & SCF_SHIFT)
|
||||
SetKeyDesc("Dollar/Insert Hidden Widget");
|
||||
else
|
||||
SetKeyDesc("Misc/Insert Datetime");
|
||||
} else {
|
||||
if (sc & SCF_SHIFT)
|
||||
DocInsSafe(DocCur,
|
||||
"$$HS+C$$$$FG$$$$HE$$");
|
||||
else
|
||||
FillInTime();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
if (!(sc & SCF_CTRL)) {
|
||||
if (sc & SCF_ALT) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Win/Tile Horizontally");
|
||||
else
|
||||
WinTileHorz;
|
||||
return TRUE;
|
||||
case 'm':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Win/Maximize");
|
||||
else {
|
||||
WinMax;
|
||||
WinBorder;
|
||||
}
|
||||
return TRUE;
|
||||
case 'v':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Win/Tile Vertically");
|
||||
else
|
||||
WinTileVert;
|
||||
return TRUE;
|
||||
case 'V':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Sys/Frame Grabber Toggle");
|
||||
else
|
||||
FrameGrabberToggle;
|
||||
return TRUE;
|
||||
|
||||
case 'l':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Edit/Put Link to Cur Pos on Clipboard");
|
||||
else {
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK-A,\"FL:%s,%d\"$$",
|
||||
DocCur->filename.name,DocCur->cur_entry->y+1);
|
||||
}
|
||||
return TRUE;
|
||||
case 'L':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Edit/Place Anchor, Put Link to Clipboard");
|
||||
else {
|
||||
i=RandU32;
|
||||
ClipBoardDel;
|
||||
DocPrintF(sys_clipboard_doc,"$$LK,\"<TODO>\",\"FA:%s,ANC%d\"$$",
|
||||
DocCur->filename.name,i);
|
||||
"$$AN,\"<TODO>\",\"ANC%d\"$$",i;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case 'w':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Win/WordStat(ON);");
|
||||
else
|
||||
WordStat(ON);
|
||||
return TRUE;
|
||||
case 'W':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Win/WordStat;");
|
||||
else
|
||||
WordStat;
|
||||
return TRUE;
|
||||
|
||||
//Ins your own ALT-key plug-ins
|
||||
case 'b':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("Cmd/Jump to Bad Code");
|
||||
else //$LK,"::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z","FI:::/SparrowOS/Apps/AfterEgypt/AENotes.TXT.Z"$
|
||||
BadCodeJump(KbdMouseEvtTime>>4);
|
||||
return TRUE;
|
||||
|
||||
case 'p':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("JukeBox(TAD)");
|
||||
else
|
||||
JukeBox("::/SparrowOS/Accts/TS/TAD/MusicOrgan");
|
||||
return TRUE;
|
||||
case 'P':
|
||||
if (sc&SCF_KEY_DESC)
|
||||
SetKeyDesc("JukeBox(Examples)");
|
||||
else
|
||||
JukeBox("::/SparrowOS/Apps/MusicOrgan/Examples");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool MyPutS(U8 *st)
|
||||
{
|
||||
nounusedwarn st;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeyDevAdd(&MyPutKey,&MyPutS,0x20000000,TRUE);
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "/SparrowOS/Accts/Adam3eWrappers"
|
||||
|
||||
#help_index "Utils;Cmd Line (Typically)"
|
||||
public U0 M(U8 *src1,U8 *src2,U8 *fu_flags=NULL)
|
||||
{
|
||||
MergeChk(src1,src2,fu_flags);
|
||||
}
|
||||
#help_index ""
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
U0 UserStartUp()
|
||||
{ //Run each time a user a spawned
|
||||
UseTermDoc;
|
||||
DocCurAttr(WHITE<<4+BLUE);
|
||||
Type("::/SparrowOS/Doc/Start.TXT.Z");
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinZBufUpdate;
|
||||
if (!IsSysDeterministic)
|
||||
Preempt(ON);
|
||||
Dir;
|
||||
CPURep;
|
||||
}
|
||||
|
||||
U0 ServantStartUp()
|
||||
{ //Run each time a servant task is spawned.
|
||||
UseTermDoc;
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinZBufUpdate;
|
||||
if (!IsSysDeterministic)
|
||||
Preempt(ON);
|
||||
}
|
||||
|
||||
CTask *user1,*user2;
|
||||
|
||||
U0 StartUpTasks()
|
||||
{
|
||||
user1=SpawnUser;
|
||||
user2=SpawnUser;
|
||||
WinToTop(user1);
|
||||
WinTileVert;
|
||||
if (!IsSysDeterministic)
|
||||
PopUp("#include \"::/SparrowOS/Adam/Start.CPP.Z\";");
|
||||
AdamLog("Boot Time:%7.3fs\n",tS);
|
||||
XTalk(user1,"#include \"DoItOnce.CPP.Z\";\n");
|
||||
Silent(ON);
|
||||
if (!IsSysDeterministic)
|
||||
WSInit("/SparrowOS/" TEXT_FILE_MASK ";~*Bible.TXT.Z");
|
||||
Silent(OFF);
|
||||
AdamLog("WordStat Time:%7.3fs\n",tS);
|
||||
if (ts_has_win_drv)
|
||||
DrvEnable(TS_WIN_DRV_LET,OFF);
|
||||
}
|
||||
|
||||
DelTree("::/Temp/ScreenShots");
|
||||
MkDir("::/Temp/ScreenShots");
|
||||
|
||||
StartUpTasks;
|
||||
|
||||
"\nOS Compile Time:%D %T\n",sys_compile_time,sys_compile_time;
|
||||
@@ -0,0 +1,12 @@
|
||||
//This file is executed by the
|
||||
//first terminal window upon start-up.
|
||||
//See $LK,"DoItOnce","FF:HOME/Adam3fSys.CPP.Z,DoItOnce"$.
|
||||
|
||||
//It goes in your HOME directory and
|
||||
//you can customize it.
|
||||
|
||||
//Delete this to get rid of
|
||||
//default start-up msg.
|
||||
|
||||
//Type("::/SparrowOS/Doc/Customize.TXT.Z");
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
//Change anything you want in this
|
||||
//acct file or others.
|
||||
|
||||
//This makes your keyboard fast
|
||||
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;
|
||||
mzz_scale=1.0; //wheel
|
||||
|
||||
//don't change these
|
||||
mxx_prescale=mxx/mxx_scale;
|
||||
myy_prescale=myy/myy_scale;
|
||||
mzz_prescale=mzz/mzz_scale;
|
||||
@@ -0,0 +1,488 @@
|
||||
//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_list;
|
||||
U32 max_char_set_list;
|
||||
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_list;
|
||||
U32 max_char_set_list;
|
||||
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,8);
|
||||
}
|
||||
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 ltdt)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate2CDateStruct(&ds,ltdt);
|
||||
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 (ListEntryMatch(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,9);
|
||||
}
|
||||
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,10);
|
||||
}
|
||||
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.
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
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 *USBAllocFrameList(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;
|
||||
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#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_list;
|
||||
};
|
||||
|
||||
//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 *USBAllocFrameList(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_list);
|
||||
u->frame_list=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_list);
|
||||
return u->frame_list;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
* Preempt-->cli
|
||||
|
||||
* Why is bitmap different from vector in $LK,"Logo","FI:::/SparrowOS/Accts/TS/TAD/Archive/Logo.TXT.Z"$?
|
||||
|
||||
* Hangs after pressing Compile MAIN in menu.
|
||||
* Crashes after back-up-script. Went away maybe after spurious IRQ fix.
|
||||
* Might be same as last one. Back-up-script cause jumps back and forth in ToHtml
|
||||
* Music organ hangs when cursoring around.
|
||||
|
||||
* $LK,"DocUpdateTaskDocs","MN:DocUpdateTaskDocs"$() skips locked docs. $LK,"WinMgrSync","MN:WinMgrSync"$() needs to check.
|
||||
|
||||
* Why is wordstat so slow on "OldMasterBootWrite" for example.
|
||||
|
||||
* $LK,"Plain","MN:Plain"$() might be better not saving $LK,"CH_CURSOR","MN:CH_CURSOR"$.
|
||||
|
||||
* TRANSPARENT might not work with line ROPF_DITHER
|
||||
|
||||
* 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.
|
||||
|
||||
* unhandled exception on MP message gets overwritten by WinMgr
|
||||
|
||||
* Cmd to enable/disable compiler warnings
|
||||
|
||||
* make aware of ctrl-r side bar
|
||||
|
||||
* fix problem -- remembering 0 terminator in str or not for $$DA
|
||||
* GetS, crazy putkey code
|
||||
* editor page formatting
|
||||
|
||||
* $LK,"gr_screen_image","MN:gr_screen_image"$
|
||||
>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
|
||||
|
||||
* CGrVectMap sucks
|
||||
* 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 SparrowOSCD.ISO
|
||||
$WW,1$
|
||||
* Race condition in Navy.CPP.Z torpedo
|
||||
|
||||
* Logrep throw for out-of-mem?
|
||||
* {Lock|Rep}{Seg|2E=NotBr|3E=Br}{OP}{ADD}{REX}
|
||||
* Virtual Box MP reboot
|
||||
* Std local var names
|
||||
* EIE_ABS_ADDR 64
|
||||
|
||||
//After Egypt possible future ideas
|
||||
//$LK,"Numbers,13:33","BF:Numbers,13:33"$ scouts
|
||||
//$LK,"Numbers,21:8","BF:Numbers,21:8"$ snakes
|
||||
|
||||
GrEdit: Move sidebar selected elems.
|
||||
- Be careful of multipt elems.
|
||||
GrEdit: Strip origin shift cmds.
|
||||
|
||||
GrEditBitMap, grabscroll?
|
||||
GrEditBitMap, cut/paste boxes.
|
||||
|
||||
extern of fun with dft arg of str?
|
||||
|
||||
* We kinda need a routine to return how much free memory, so that applications can plan a big alloc.
|
||||
|
||||
* FileMgr bad with lots of files.
|
||||
|
||||
* This $LK,"Fs->catch_except=TRUE","FF:::/SparrowOS/OSMain/TaskCmd.CPP.Z,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.
|
||||
|
||||
* Window mgr needs to do DOC operations on posted messages from mouse. Works for $LK,"SetIP","MN:SetIP"$(), though.
|
||||
|
||||
* Add local vars to sym table in $LK,"Dbg","MN:Dbg"$()? (maybe)
|
||||
|
||||
This shit:
|
||||
$HC,"<object width=\"750\" height=\"520\"><param name=\"movie\" value=\"http://www.youtube.com/v/WAr-xYtBFbY?hl=en&fs=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/WAr-xYtBFbY?hl=en&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"750\" height=\"520\"></embed></object>"$
|
||||
|
||||
|
||||
* $LK,"Bible sized nodes","FF:::/SparrowOS/Adam/Doc/DocRecalc.CPP.Z,->tag+i"$
|
||||
* Mouseinstall throws exceptions, doesn't work, investigate Mouse $LK,"0x9FC30","FF:::/SparrowOS/OSMain/KbdMouse/Mouse.CPP.Z,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
|
||||
* Fix Mom's secondary CD-ROM, dad's primary
|
||||
* pmtstr in install didn't like focus change
|
||||
|
||||
*$FG,2$U0 Main()
|
||||
{
|
||||
U0 (*fp_old_draw_input_ptr)(CDC *dc,I64 x,I64 y)=fp_draw_input_ptr;
|
||||
}$FG$
|
||||
|
||||
* 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.
|
||||
|
||||
* OVERSTRIKE at cmd line with menu macro.
|
||||
|
||||
* $FG,2$lock{}$FG$ warning on invalid modes.
|
||||
* Local array vars-->reg.
|
||||
* $LK,"DCF_SYMMETRY","MN:DCF_SYMMETRY"$, before transformation? (Currently it's after)
|
||||
* all graphics clipping -- screen y+top<0 for top<0
|
||||
* Maybe convert graphics to float
|
||||
* compiler F32
|
||||
* preempt(OFF) during graphic clipping?
|
||||
* compiler optimization heap_glbls with added offset
|
||||
* static_compile extern glblvar references.
|
||||
* extern glbl var in static module on data heap.
|
||||
* Might make FAT32 read in contiguous chunks.
|
||||
* make Limit(),Min(),Max() asm routines.
|
||||
* Might make CSprite flood fill operate on a separate bitmap and blotted at the end.
|
||||
* autofile popup of popup
|
||||
* <CTRL-R> delete subsprite in menu near others
|
||||
* consider changing domenu so a real <ESC> on menu item doesn't select (<SPACE BAR> sends <ESC> followed by <SPACE BAR> or something)
|
||||
* puts3 with depth buf? might not do this
|
||||
* make task queins and querem safe for multicore cycling through tasks (fwd).
|
||||
* make better heapwalk, do something with _CFG_HEAP_DBG.
|
||||
* log to file--would be inefficient--load-in whole file, modify and write out. Useful, but not very efficient (SparrowOS 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?
|
||||
* Might make DskView show drive colors.
|
||||
* Might do utility to set drive colors, making a tree entry in Adam 3 using registry-like routines... or registry I guess.
|
||||
|
||||
* New Editor widgets
|
||||
|
||||
* Make use of flag potential in SysFilesFind and possibly CFileAccess
|
||||
* implement fixed pos files
|
||||
|
||||
* new C+ language features
|
||||
* better debugging
|
||||
|
||||
* Change hardcoded stuff to Define
|
||||
* Too much preemption turned off?
|
||||
* Look for mem leaks.
|
||||
* Move stuff out of OSmain.
|
||||
|
||||
* $LK,"ROP_XOR","MN:ROP_XOR"$ with pen_width>1 is broken.
|
||||
|
||||
* use width and height in line clipping for pen_width>1 or blot.
|
||||
* SIMD transformation
|
||||
* test removable media id (critical for resident files)
|
||||
|
||||
* add field overflow U8 "t='*'"
|
||||
* Implement fmt codes into GetF
|
||||
* GetF date codes and maybe $FG,2$h$FG$ fmts for nums
|
||||
* Date Input
|
||||
* Default date fmt
|
||||
|
||||
* 16 bit Unassembly is bad--very low priority
|
||||
* more signed int disassembly
|
||||
* support r4u8 by adding 0x40 byte
|
||||
* static var off of data heap.
|
||||
* Might want to use U32*U32 multiplication.
|
||||
* could add "const" to not set LF_NOT_CONSTANT flag for trig, etc.
|
||||
* do r,rm ICCmp like ICBrCmp
|
||||
* could make glblvar imports use TY_RIP_DISP32.
|
||||
* PUSH_CMP allocs reg R9 or whatever
|
||||
* Might be problem with NOP in OPT pass1 for NO_PUSH in expressions besides assignments. Is ShiftNoPush fully implemented?
|
||||
* NOP1 might need to have diff ic_data's
|
||||
* in divequal, it assumes about ebx
|
||||
* error/warning line nums
|
||||
* ASM branch out warning of range off by 1 line--use lx->last_line_num
|
||||
|
||||
* Switch statement with sparse cases (low priority)
|
||||
* maybe inline functions?
|
||||
* Use of more floating-point stk?
|
||||
|
||||
* More aggressive in this routine $LK,"CmpF2PushPop","MN:CmpF2PushPop"$() with types besides MOV and F64.
|
||||
* !dbl ~dbl
|
||||
* &=, |= can overflow with Bts Btr on small data types
|
||||
|
||||
* num lock comes on with break key
|
||||
* sort options for findfiles
|
||||
* recalc_start could be more accurate before recalculating?
|
||||
* Maybe, get rid of $LK,"0x20000","FF:::/SparrowOS/Compiler/CmpMain.CPP.Z,0x20000"$ in compiler.
|
||||
* get rid of "$FG,2$$$PI$FG$" alias.
|
||||
@@ -0,0 +1,8 @@
|
||||
$TR,"Adam"$
|
||||
$ID,2$$TR,"SparrowOS"$
|
||||
$ID,2$$TR,"SysMsgFlags"$
|
||||
$ID,2$sys_msg_flags[0]=0x255;
|
||||
$ID,-2$$TR,"SysRegVer"$
|
||||
$ID,2$registry_version=1.020;
|
||||
$ID,-2$$ID,-2$$ID,-2$$TR,"SparrowOS"$
|
||||
$ID,2$$ID,-2$
|
||||
@@ -0,0 +1,413 @@
|
||||
#define CID_DFT 0
|
||||
#define CID_TAD8 1
|
||||
|
||||
I64 ts_cid=CID_DFT;
|
||||
|
||||
#include "::/SparrowOS/Accts/TS/TSIDComputer"
|
||||
|
||||
U0 VMDrvs(CATARep *root,CATARep **_ata_drv,CATARep **_atapi_drv)
|
||||
{
|
||||
CBlkDev *bd=Drv2BlkDev(dft_drv);
|
||||
CATARep *tempha=root,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
Bool found_atapi=FALSE;
|
||||
while (tempha) {
|
||||
if (tempha->type==BDT_ATA) {
|
||||
if (!ata_drv || tempha->unit<ata_drv->unit ||
|
||||
tempha->unit==ata_drv->unit && tempha->num<ata_drv->num)
|
||||
ata_drv=tempha;
|
||||
} else if (tempha->type==BDT_ATAPI) {
|
||||
if (!found_atapi) {
|
||||
if (bd && tempha->base0==bd->base0 && tempha->unit==bd->unit) {
|
||||
atapi_drv=tempha;
|
||||
found_atapi=TRUE;
|
||||
} else if (!atapi_drv || tempha->unit<atapi_drv->unit ||
|
||||
tempha->unit==atapi_drv->unit && tempha->num<atapi_drv->num)
|
||||
atapi_drv=tempha;
|
||||
}
|
||||
}
|
||||
tempha=tempha->next;
|
||||
}
|
||||
if (_ata_drv) *_ata_drv =ata_drv;
|
||||
if (_atapi_drv) *_atapi_drv=atapi_drv;
|
||||
}
|
||||
|
||||
U0 TSInit()
|
||||
{
|
||||
//TS_TRA_DRV is for transfering files to dual booted OS's
|
||||
//TS_IMG_DRV is for the holding area for burning CDROMs
|
||||
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
CBlkDev *bd;
|
||||
switch (ts_cid) {
|
||||
case CID_TAD8:
|
||||
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_CDROM_DRVS","\"t3s0xb800\n0\"");
|
||||
DefinePrintF("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
|
||||
DefinePrintF("TS_HDS","\"DEI\"");
|
||||
DefinePrintF("TS_MASTER_BOOT_DRVS","\"I\"");
|
||||
DefinePrintF("TS_MAIN_DRV","\"D\"");
|
||||
DefinePrintF("TS_BAK_DRV","\"E\"");
|
||||
DefinePrintF("TS_RAM_DRV","\"B\"");
|
||||
DefinePrintF("TS_TRA_DRV","\"I\"");
|
||||
DefinePrintF("TS_WIN_DRV","\"H\"");
|
||||
DefinePrintF("TS_IMG_DRV","\"Z\"");
|
||||
DefinePrintF("TS_CDROM_DRV","\"T\"");
|
||||
break;
|
||||
default:
|
||||
DefinePrintF("CFG_ACCT","\"\nTS/TAD\n\"");
|
||||
DefinePrintF("CFG_HARD_DRVS","\"d2s0x1F0\n0x3F4\n0\"");
|
||||
DefinePrintF("CFG_RAM_DRVS","\"b1Scale2Mem(2048,0x40000)\nz1Scale2Mem(2048,0x40000)\n\"");
|
||||
DefinePrintF("CFG_CDROM_DRVS","\"t3s0x170\n0\"");
|
||||
bd=Drv2BlkDev(dft_drv);
|
||||
if (bd->type==BDT_ATAPI) {
|
||||
ATARep(FALSE,&root);
|
||||
VMDrvs(root,&ata_drv,&atapi_drv);
|
||||
if (ata_drv)
|
||||
DefinePrintF("CFG_HARD_DRVS","\"d2p%d\n\"",ata_drv->num);
|
||||
if (atapi_drv)
|
||||
DefinePrintF("CFG_CDROM_DRVS","\"t3p%d\n\"",atapi_drv->num);
|
||||
} else {
|
||||
bd=Drv2BlkDev('D');
|
||||
DefinePrintF("CFG_HARD_DRVS","\"d2s0x%X\n0x%X\n%d\"",
|
||||
bd->base0,bd->base1,bd->unit);
|
||||
bd=Drv2BlkDev('T');
|
||||
DefinePrintF("CFG_CDROM_DRVS","\"t3s0x%X\n%d\"",bd->base0,bd->unit);
|
||||
}
|
||||
DefinePrintF("CFG_DSK_CACHE","\"Scale2Mem(0x80000,0x8000000)\n\"");
|
||||
DefinePrintF("TS_HDS","\"DEF\"");
|
||||
DefinePrintF("TS_MASTER_BOOT_DRVS","\"D\"");
|
||||
DefinePrintF("TS_MAIN_DRV","\"D\"");
|
||||
DefinePrintF("TS_BAK_DRV","\"E\"");
|
||||
DefinePrintF("TS_RAM_DRV","\"B\"");
|
||||
DefinePrintF("TS_TRA_DRV","\"F\"");
|
||||
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_tra_drv =ToBool(StrLen(TS_TRA_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_TRA_DRV_LET","'%s'",TS_TRA_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;
|
||||
|
||||
if (ts_has_main_drv)
|
||||
SetDrvTextAttr(TS_MAIN_DRV_LET, WHITE <<4|BLUE);
|
||||
if (ts_has_bak_drv)
|
||||
SetDrvTextAttr(TS_BAK_DRV_LET, WHITE <<4|RED);
|
||||
if (ts_has_ram_drv)
|
||||
SetDrvTextAttr(TS_RAM_DRV_LET, BLUE <<4|YELLOW);
|
||||
if (ts_has_tra_drv)
|
||||
SetDrvTextAttr(TS_TRA_DRV_LET, WHITE <<4|BROWN);
|
||||
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 ":/SparrowOSCD.ISO"
|
||||
|
||||
#define CFG_OPTS "ProtectLow\n\n"
|
||||
#define CFG_DBG_OPTS "ProtectLow\nDet\nHeapInit\n130\nMemInit\n131\nVarInit\n132\n\n"
|
||||
#define CFG_DBGZ_OPTS "ProtectLow\nDet\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\n\n"
|
||||
|
||||
//$BK,1$Change these, too...$BK,0$
|
||||
//$MA+A-X+PU,"PROD_CDROM_CFG","F(\"PROD_CDROM_CFG\");View;"$
|
||||
//$LK,"Install Acct","FF:::/SparrowOS/Accts/Install/DoItOnce.CPP.Z,InstallBoot"$
|
||||
|
||||
|
||||
U0 CtrlAltR(I64)
|
||||
{
|
||||
snd_record=!snd_record;
|
||||
}
|
||||
SetCtrlAltLetCB('R',&CtrlAltR,"Toggle snd_record");
|
||||
|
||||
Bool frame_grabber_paused=FALSE,
|
||||
frame_grabber_on=FALSE;
|
||||
|
||||
public U0 MyScreenShot(I64 bits=4)
|
||||
{
|
||||
U8 *st;
|
||||
CDirEntry *tempm;
|
||||
I64 cnt=0;
|
||||
tempm=FilesFind("::/Temp/ScreenShots/*.BMP");
|
||||
while (tempm) {
|
||||
cnt++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
st=MSPrintF("::/Temp/ScreenShots/SCRN%04d.BMP",cnt);
|
||||
BMPFileCaptureScreen(st,bits);
|
||||
Free(st);
|
||||
Beep;
|
||||
}
|
||||
|
||||
//This is the max rate for Windows Movie Maker.
|
||||
#define VIDEO_FRAME_RATE 8
|
||||
|
||||
#exe {
|
||||
if (ts_cid==CID_TAD8)
|
||||
StreamPutS("#define FRAME_DIR_CNT 600\n");
|
||||
else
|
||||
StreamPutS("#define FRAME_DIR_CNT 200\n");
|
||||
};
|
||||
|
||||
U0 FrameGrabberTask(I64)
|
||||
{
|
||||
I64 frame_num=0;
|
||||
I64 buf[136],buf2[136],buf3[136];
|
||||
F64 end_time=tNP,f;
|
||||
TaskInitExt;
|
||||
Silent(ON); //no output to screen
|
||||
while (frame_grabber_on) {
|
||||
SPrintF(buf2,"::/Temp/ScreenShots/V%03d",frame_num/FRAME_DIR_CNT);
|
||||
MkDir(buf2);
|
||||
SPrintF(buf,"%s/VID%05d.BMP.Z",buf2,frame_num%FRAME_DIR_CNT);
|
||||
frame_num++;
|
||||
Suspend(sys_winmgr_task,FALSE);
|
||||
BMPFileCaptureScreen(buf);
|
||||
Suspend(sys_winmgr_task);
|
||||
StrCpy(buf3,buf);
|
||||
|
||||
f=tNP;
|
||||
while (end_time<f) {
|
||||
end_time+=1.0/VIDEO_FRAME_RATE;
|
||||
if (end_time<f) {
|
||||
SPrintF(buf2,"::/Temp/ScreenShots/V%03d",frame_num/FRAME_DIR_CNT);
|
||||
MkDir(buf2);
|
||||
SPrintF(buf,"%s/VID%05d.BMP.Z",buf2,frame_num%FRAME_DIR_CNT);
|
||||
frame_num++;
|
||||
Copy(buf3,buf);
|
||||
}
|
||||
}
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
while (sys_cur_scan_code&SCF_NUM) {
|
||||
Suspend(sys_winmgr_task,FALSE);
|
||||
Yield;
|
||||
end_time=tNP;
|
||||
}
|
||||
while (end_time>tNP) {
|
||||
Suspend(sys_winmgr_task,FALSE);
|
||||
Yield;
|
||||
}
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
}
|
||||
Suspend(sys_winmgr_task,FALSE);
|
||||
}
|
||||
|
||||
public U0 FrameGrabberToggle()
|
||||
{
|
||||
if (frame_grabber_on) {
|
||||
IOSnd(ON);
|
||||
frame_grabber_on=FALSE;
|
||||
Snd(0);
|
||||
snd_record=FALSE;
|
||||
} else {
|
||||
IOSnd(OFF); //You don't want to hear screen capture file writes
|
||||
frame_grabber_on=TRUE;
|
||||
Spawn(&FrameGrabberTask,NULL,"Frame Grabber");
|
||||
snd_record=TRUE;
|
||||
Snd(0);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ScreenShotTask(I64)
|
||||
{
|
||||
TaskInitExt;
|
||||
MyScreenShot;
|
||||
}
|
||||
|
||||
U0 CtrlAltS(I64)
|
||||
{
|
||||
Spawn(&ScreenShotTask);
|
||||
}
|
||||
SetCtrlAltLetCB('S',&CtrlAltS,"Cmd/Screen Shot");
|
||||
|
||||
public U0 MBRRep(U8 drv_let='C')
|
||||
{
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
I64 type,i,j,ext_base;
|
||||
I64 offset;
|
||||
CMasterBoot mbr;
|
||||
|
||||
if (bdev->type!=BDT_ATA)
|
||||
return;
|
||||
drv_let=bdev->drv_let_base;
|
||||
offset=0;
|
||||
ext_base=INVALID_CLUSTER;
|
||||
while (TRUE) {
|
||||
ATAReadBlks(bdev,&mbr,offset,1);
|
||||
"$$FG,PURPLE$$Blk:%08X$$FG$$\n",offset;
|
||||
ClassRep("CMasterBoot",&mbr);
|
||||
if (mbr.signature!=0xAA55)
|
||||
break;
|
||||
j=-1;
|
||||
for (i=0;i<4;i++) {
|
||||
"$$FG,CYAN$$ Entry #%d$$FG$$\n",i;
|
||||
if (mbr.p[i].active||mbr.p[i].type)
|
||||
ClassRep("CMBRPrt",&mbr.p[i]);
|
||||
if (mbr.p[i].type) {
|
||||
type=mbr.p[i].type;
|
||||
"$$FG,RED$$%C Offset:%08X Size:%08X Type:%X$$FG$$\n",
|
||||
drv_let,mbr.p[i].offset+offset,
|
||||
mbr.p[i].size,type;
|
||||
if (type==5 || type==0xF)
|
||||
j=i;
|
||||
else
|
||||
drv_let++;
|
||||
}
|
||||
}
|
||||
if (j<0)
|
||||
break;
|
||||
if (!mbr.p[j].offset)
|
||||
break;
|
||||
if (ext_base==INVALID_CLUSTER) {
|
||||
offset=mbr.p[j].offset;
|
||||
ext_base=offset;
|
||||
} else
|
||||
offset=mbr.p[j].offset+ext_base;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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,"/SparrowOS/"TEXT_FILE_MASK,"-l-i",buf2);
|
||||
|
||||
*buf1=ToUpper(*buf1);
|
||||
*buf2=ToUpper(*buf2);
|
||||
Grep(buf1,"/SparrowOS/"TEXT_FILE_MASK,"-l-i",buf2);
|
||||
|
||||
StrUtil(buf1,SUF_TO_UPPER);
|
||||
StrUtil(buf2,SUF_TO_UPPER);
|
||||
Grep(buf1,"/SparrowOS/"TEXT_FILE_MASK,"-l-i",buf2);
|
||||
}
|
||||
|
||||
public U0 ChkAll()
|
||||
{
|
||||
U8 *ptr=TS_HDS;
|
||||
while (*ptr)
|
||||
ChkDsk(*ptr++);
|
||||
}
|
||||
|
||||
public U0 MyHAllRep(U8 *flags="-p",U8 *index=NULL)
|
||||
{
|
||||
HashRep(Fs->hash_table,HTG_SRC_SYM-HTT_DEFINE_STR-HTT_CLASS,NULL,flags,0,index);
|
||||
}
|
||||
|
||||
public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
|
||||
{
|
||||
I64 *ptr;
|
||||
U8 byte_bit_cnts[256],st[2];
|
||||
I64 i,j,row,col,ch,best_ch,score,best_score,cur_char_image,diff_image,total_score=0;
|
||||
CDoc *doc=DocNew;
|
||||
|
||||
MemSet(st,0,sizeof(st));
|
||||
MemSet(byte_bit_cnts,0,sizeof(byte_bit_cnts));
|
||||
for (i=0;i<256;i++)
|
||||
for (j=0;j<7;j++)
|
||||
if (Bt(&i,j))
|
||||
byte_bit_cnts[i]++;
|
||||
|
||||
for (row=0;row<dc->height/FONT_HEIGHT;row++) {
|
||||
for (col=0;col<dc->width/FONT_WIDTH;col++) {
|
||||
|
||||
cur_char_image=0;
|
||||
for (i=0;i<FONT_HEIGHT;i++)
|
||||
for (j=0;j<FONT_WIDTH;j++)
|
||||
if (GrPeek(dc,col*FONT_WIDTH+j+dx,row*FONT_HEIGHT+i+dy)!=WHITE)
|
||||
LBts(&cur_char_image,i*8+j);
|
||||
|
||||
best_score=MAX_I64;
|
||||
best_ch=0;
|
||||
ptr=&gr_font[32*FONT_HEIGHT];
|
||||
for (ch=32;ch<127;ch++) {
|
||||
diff_image=*ptr++ ^ cur_char_image;
|
||||
score=0;
|
||||
for (i=0;i<8;i++)
|
||||
score+=byte_bit_cnts[diff_image.u8[i]];
|
||||
if (score<best_score) {
|
||||
best_score=score;
|
||||
best_ch=ch;
|
||||
}
|
||||
}
|
||||
if (best_ch=='$$')
|
||||
DocPutS(doc,"$$$$");
|
||||
else {
|
||||
*st=best_ch;
|
||||
DocPutS(doc,st);
|
||||
}
|
||||
total_score+=best_score;
|
||||
}
|
||||
DocPutS(doc,"\n");
|
||||
}
|
||||
if (_total_score) *_total_score=total_score;
|
||||
return doc;
|
||||
}
|
||||
|
||||
public U0 BMP2TXT(U8 *_in_name,U8 *_out_name=NULL)
|
||||
{
|
||||
U8 *in_name,*out_name;
|
||||
I64 dx,dy,score,best_score=MAX_I64;
|
||||
CDC *dc;
|
||||
CDoc *doc;
|
||||
in_name=DftExt(_in_name,"BMP"),
|
||||
if (_out_name)
|
||||
out_name=DftExt(_out_name,"TXT.Z");
|
||||
else
|
||||
out_name=ChgExt(_in_name,"TXT.Z");
|
||||
if (dc=BMPFileRead(in_name)) {
|
||||
for (dy=-3;dy<=4;dy++)
|
||||
for (dx=-3;dx<=4;dx++) {
|
||||
doc=DC2Doc(dc,dx,dy,&score);
|
||||
if (score<best_score) {
|
||||
best_score=score;
|
||||
StrCpy(&doc->filename.name,out_name);
|
||||
DocWrite(doc);
|
||||
}
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
Free(in_name);
|
||||
Free(out_name);
|
||||
}
|
||||
|
||||
|
||||
U0 CopyVideo()
|
||||
{
|
||||
U8 *st;
|
||||
if (ts_has_tra_drv) {
|
||||
Del(TS_TRA_DRV ":/Temp/*.SND");
|
||||
st=MSPrintF("#include \"::/SparrowOS/Apps/MusicOrgan/Load\";"
|
||||
"SndFileCreate(\"" TS_TRA_DRV ":/Temp/Audio\",0.23,0.0,WF_NULL,0.45,0.35);");
|
||||
PopUp(st);
|
||||
Free(st);
|
||||
DelTree(TS_TRA_DRV ":/Temp/ScreenShots");
|
||||
CopyTree("::/Temp/ScreenShots",TS_TRA_DRV ":/Temp/ScreenShots");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
//The CFG defines are $LK,"Here","FI:::/SparrowOS/Demo/AcctExample/TSAdam.CPP.Z"$.
|
||||
|
||||
U0 ShowBootFileDate(U8 drv_let)
|
||||
{
|
||||
CDirEntry de;
|
||||
U8 *name=MSPrintF("%c:/OSMain.BIN.C",drv_let);
|
||||
if (FileFind(name,&de))
|
||||
"%s %D %T\n",name,de.datetime,de.datetime;
|
||||
else
|
||||
"%s\n",name;
|
||||
Free(name);
|
||||
}
|
||||
|
||||
U0 ShowBootFiles()
|
||||
{
|
||||
U8 *ptr=TS_HDS;
|
||||
while (*ptr)
|
||||
ShowBootFileDate(*ptr++);
|
||||
}
|
||||
|
||||
U8 DrvMySelect()
|
||||
{
|
||||
I64 result;
|
||||
ShowBootFiles;
|
||||
"Drive:";
|
||||
result=ToUpper(GetChar);
|
||||
NewLine;
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 CmpDrv(U8 drv_let)
|
||||
{
|
||||
drv_let=ToUpper(drv_let);
|
||||
Auto(TS_CFG);
|
||||
InstallBoot(drv_let);
|
||||
if (StrOcc(TS_MASTER_BOOT_DRVS,drv_let))
|
||||
InstallMasterBoot(drv_let);
|
||||
}
|
||||
|
||||
U0 QMenuBoot(U8 drv_let=0)
|
||||
{
|
||||
if (!drv_let)
|
||||
drv_let=Prt2Drv(Fs->cur_prt);
|
||||
Drv(drv_let);
|
||||
Cd("/SparrowOS/OSMain");
|
||||
Auto(TS_MENU_CFG);
|
||||
if (!Cmp("OSMain","OSMain",NULL,':'))
|
||||
Boot("OSMain.BIN.Z");
|
||||
}
|
||||
|
||||
U0 UpdateAndCompile(U8 src,U8 dst)
|
||||
{
|
||||
U8 buf_s[128],buf_d[128];
|
||||
if (src==dst) return;
|
||||
|
||||
SPrintF(buf_s,"%c:/SparrowOS",src);
|
||||
SPrintF(buf_d,"%c:/SparrowOS",dst);
|
||||
CopyTree(buf_s,buf_d);
|
||||
CmpDrv(dst);
|
||||
}
|
||||
|
||||
U0 PromptUpdateDrv()
|
||||
{
|
||||
U8 src,dst;
|
||||
"\nSrc Drive:\n";
|
||||
src=DrvMySelect;
|
||||
"\nDst Drive:\n";
|
||||
dst=DrvMySelect;
|
||||
UpdateAndCompile(src,dst);
|
||||
ShowBootFiles;
|
||||
Drv(src);
|
||||
}
|
||||
|
||||
U0 MyMerge()
|
||||
{
|
||||
U8 src,dst,buf_s[128],buf_d[128];
|
||||
"\nMerge Src Drive:\n";
|
||||
src=DrvMySelect;
|
||||
"\nMerge Dst Drive:\n";
|
||||
dst=DrvMySelect;
|
||||
SPrintF(buf_s,"%c:/SparrowOS/*",src);
|
||||
SPrintF(buf_d,"%c:/SparrowOS/*",dst);
|
||||
MergeChk(buf_d,buf_s,"+r+d");
|
||||
Drv(dst);
|
||||
}
|
||||
|
||||
U0 MyCopyDrv(U8 src,U8 dst)
|
||||
{
|
||||
U8 buf_s[128],buf_d[128];
|
||||
src=ToUpper(src);
|
||||
dst=ToUpper(dst);
|
||||
|
||||
Fmt(dst,TRUE,FALSE,PT_FAT32);
|
||||
|
||||
SPrintF(buf_s,"%c:/SparrowOS",src);
|
||||
SPrintF(buf_d,"%c:/SparrowOS",dst);
|
||||
CopyTree(buf_s,buf_d);
|
||||
|
||||
SPrintF(buf_s,"%c:/Windows",src);
|
||||
SPrintF(buf_d,"%c:/Windows",dst);
|
||||
CopyTree(buf_s,buf_d);
|
||||
|
||||
SPrintF(buf_s,"%c:/Linux",src);
|
||||
SPrintF(buf_d,"%c:/Linux",dst);
|
||||
CopyTree(buf_s,buf_d);
|
||||
|
||||
SPrintF(buf_s,"%c:/0000Boot",src);
|
||||
SPrintF(buf_d,"%c:/0000Boot",dst);
|
||||
CopyTree(buf_s,buf_d);
|
||||
|
||||
SPrintF(buf_d,"%c:/Temp",dst);
|
||||
MkDir(buf_d);
|
||||
|
||||
SPrintF(buf_d,"%c:/Temp/ScreenShots",dst);
|
||||
MkDir(buf_d);
|
||||
|
||||
if (ts_has_tra_drv && dst==TS_TRA_DRV_LET) {
|
||||
SPrintF(buf_d,"%c:/Logs",dst);
|
||||
MkDir(buf_d);
|
||||
SPrintF(buf_d,"%c:/Logs/SPARROWOSLogs",dst);
|
||||
MkDir(buf_d);
|
||||
}
|
||||
DocClear;
|
||||
Drv(dst);
|
||||
CmpDrv(dst);
|
||||
}
|
||||
|
||||
U0 PmtMyCopyDrv()
|
||||
{
|
||||
U8 src,dst;
|
||||
"$$FG,RED$$\nCopy Src Drive:\n$$FG$$";
|
||||
src=DrvMySelect;
|
||||
"$$FG,RED$$\nCopy Dst Drive:\n$$FG$$";
|
||||
dst=DrvMySelect;
|
||||
MyCopyDrv(src,dst);
|
||||
}
|
||||
|
||||
public U0 FileCursorRem(U8 *filename)
|
||||
{
|
||||
CDoc *doc;
|
||||
doc=DocRead(filename,DOCF_PLAIN_TEXT|DOCF_NO_CURSOR);
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
public U0 FileCursorTop(U8 *filename)
|
||||
{
|
||||
CDoc *doc;
|
||||
doc=DocRead(filename,DOCF_PLAIN_TEXT);
|
||||
doc->cur_entry=doc->root.next;
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
public U0 FilesCursorRem(U8 *mask="*")
|
||||
{
|
||||
I64 fuf_flags=0;
|
||||
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+t+f+F");
|
||||
CDirEntry *tempm=FilesFind(mask,fuf_flags),*tempm1;
|
||||
while (tempm) {
|
||||
tempm1=tempm->next;
|
||||
FileCursorRem(tempm->full_name);
|
||||
Touch(tempm->full_name,"","",tempm->datetime);
|
||||
CDirEntryDel(tempm);
|
||||
tempm=tempm1;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 FilesCursorTop(U8 *mask="*")
|
||||
{
|
||||
I64 fuf_flags=0;
|
||||
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+t+f+F");
|
||||
CDirEntry *tempm=FilesFind(mask,fuf_flags),*tempm1;
|
||||
while (tempm) {
|
||||
tempm1=tempm->next;
|
||||
FileCursorTop(tempm->full_name);
|
||||
Touch(tempm->full_name,"","",tempm->datetime);
|
||||
CDirEntryDel(tempm);
|
||||
tempm=tempm1;
|
||||
}
|
||||
}
|
||||
|
||||
U0 UncollapseFile(U8 *filename,I64 *)
|
||||
{
|
||||
CDoc *doc=DocRead(filename,DOCF_NO_CURSOR);
|
||||
DocCollapse(FALSE,doc);
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
U0 UncollapseList(CDirEntry *tempm1,I64 *flags)
|
||||
{
|
||||
CDirEntry *tempm2;
|
||||
while (tempm1 && !Bt(flags,FUf_CANCEL)) {
|
||||
tempm2=tempm1->next;
|
||||
if (tempm1->attr & _ATTR_DIR) {
|
||||
if (tempm1->sub) {
|
||||
"%S %s\n","ST_SCANNING_DIR",tempm1->full_name;
|
||||
UncollapseList(tempm1->sub,flags);
|
||||
}
|
||||
} else
|
||||
UncollapseFile(tempm1->full_name,flags);
|
||||
CDirEntryDel(tempm1);
|
||||
tempm1=tempm2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 Uncollapse(U8 *files_find_mask=TEXT_FILE_MASK,U8 *fu_flags=NULL)
|
||||
{
|
||||
I64 f=0;
|
||||
GetFFlags(&f,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
GetFFlags(&f,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
UncollapseList(FilesFind(files_find_mask,f),&f);
|
||||
}
|
||||
|
||||
U0 CopySongDir(U8 *files_find_mask,U8 threshold)
|
||||
{
|
||||
CDoc *s;
|
||||
CDocEntry *doc_e;
|
||||
CDirEntry *tempm,*tempm1;
|
||||
tempm1=tempm=FilesFind(files_find_mask);
|
||||
while (tempm1) {
|
||||
s=DocRead(tempm1->full_name);
|
||||
doc_e=s->root.next;
|
||||
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[2]>=threshold)
|
||||
Copy(tempm1->full_name,"/SparrowOS/Apps/MusicOrgan/Examples");
|
||||
tempm1=tempm1->next;
|
||||
}
|
||||
CDirListDel(tempm);
|
||||
}
|
||||
|
||||
public U0 CopySongs(U8 threshold='7')
|
||||
{
|
||||
DelTree("/SparrowOS/Apps/MusicOrgan/Examples");
|
||||
MkDir("/SparrowOS/Apps/MusicOrgan/Examples");
|
||||
CopySongDir("/SparrowOS/Accts/TS/TAD/MusicOrgan/*.CPP.Z",threshold);
|
||||
}
|
||||
|
||||
U0 PrepForDistribution()
|
||||
{
|
||||
Del("/SparrowOS/Demo/WebLogExample/WebLog.TXT.Z");
|
||||
Del("/SparrowOS/Demo/GameStarters/EagleDive.BIN.Z");
|
||||
DelTree("/SparrowOS/Accts/*Temp.TXT.Z");
|
||||
CopySongs;
|
||||
|
||||
//User
|
||||
Del("/SparrowOS/Accts/User/Registry.CPP.Z");
|
||||
|
||||
//Install
|
||||
Del("/SparrowOS/Accts/Install/Registry.CPP.Z");
|
||||
|
||||
//SafeMode
|
||||
Del("/SparrowOS/Accts/SafeMode/Registry.CPP.Z");
|
||||
|
||||
Touch("/SparrowOS/Accts/PersonalMenu.TXT.Z","+T");
|
||||
//TS
|
||||
Touch("/SparrowOS/Accts/TS/PersonalMenu.TXT.Z","+T");
|
||||
|
||||
DelTree("/SparrowOS/Demo/AcctExample");
|
||||
CopyTree("/SparrowOS/Accts/TS","/SparrowOS/Demo/AcctExample");
|
||||
DelTree("/SparrowOS/Demo/AcctExample/TAD/MusicOrgan");
|
||||
DelTree("/SparrowOS/Demo/AcctExample/Wb2");
|
||||
Del("/SparrowOS/Demo/AcctExample/TAD/Test*");
|
||||
|
||||
Cd("/SparrowOS");
|
||||
FilesCursorTop;
|
||||
|
||||
DelTree("/SparrowOS/Demo/*.BI?");
|
||||
|
||||
Cd("/SparrowOS");
|
||||
S2T(SRC_FILE_MASK,"+r");
|
||||
Move(WSD_DEF_FILENAME,WSD_DEF_FILENAME_Z);
|
||||
}
|
||||
|
||||
U0 PrepForInHouse()
|
||||
{
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
PrepForDistribution;
|
||||
Auto(TS_CDROM_CFG);
|
||||
InstallBoot(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 ":/SparrowOS","/SparrowOS");
|
||||
CopyTree(TS_MAIN_DRV ":/Windows","/Windows");
|
||||
CopyTree(TS_MAIN_DRV ":/Linux","/Linux");
|
||||
MkDir("/Temp");
|
||||
MkDir("/Temp/ScreenShots");
|
||||
CopyTree(TS_MAIN_DRV ":/0000Boot","/0000Boot");
|
||||
}
|
||||
|
||||
U0 MakeSymbolFiles()
|
||||
{
|
||||
CDoc *doc;
|
||||
U8 *st;
|
||||
if (ts_has_tra_drv) {
|
||||
DocClear;
|
||||
DocMax;
|
||||
HashRep(Fs->hash_table,HTG_ALL,NULL,"-p",0,NULL);
|
||||
if (doc=DocCur) {
|
||||
st=StrNew(doc->filename.name);
|
||||
StrCpy(doc->filename.name,TS_TRA_DRV ":/Wb/Accts/TS/Wb2/SymbolsAlpha.TXT.Z");
|
||||
DocWrite(doc);
|
||||
StrCpy(doc->filename.name,st);
|
||||
Free(st);
|
||||
}
|
||||
DocClear;
|
||||
DocMax;
|
||||
HashRep(Fs->hash_table,HTG_ALL,NULL,"-p+m",0,NULL);
|
||||
if (doc=DocCur) {
|
||||
st=StrNew(doc->filename.name);
|
||||
StrCpy(doc->filename.name,TS_TRA_DRV ":/Wb/Accts/TS/Wb2/SymbolsAddress.TXT.Z");
|
||||
DocWrite(doc);
|
||||
StrCpy(doc->filename.name,st);
|
||||
Free(st);
|
||||
}
|
||||
DocClear;
|
||||
}
|
||||
}
|
||||
|
||||
I64 MakeLineCntFile()
|
||||
{
|
||||
U8 *st;
|
||||
CDoc *doc;
|
||||
I64 result;
|
||||
CDocEntry *tree_branch,*start_indent,*end_indent;
|
||||
|
||||
DocClear;
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
PrepForDistribution;
|
||||
|
||||
DocMax;
|
||||
DocClear;
|
||||
Cd(TS_MAIN_DRV ":/SparrowOS");
|
||||
result=LineCntRep;
|
||||
if (doc=DocCur) {
|
||||
st=StrNew(doc->filename.name);
|
||||
StrCpy(doc->filename.name,TS_MAIN_DRV ":/SparrowOS/Accts/TS/Wb2/LineCnt.TXT.Z");
|
||||
DocWrite(doc);
|
||||
StrCpy(doc->filename.name,st);
|
||||
Free(st);
|
||||
}
|
||||
DocClear;
|
||||
|
||||
doc=DocRead(TS_MAIN_DRV ":/SparrowOS/Adam/DocDefines.CPP.Z");
|
||||
DocTreeFind(doc,"LineCnt",&tree_branch,&start_indent,&end_indent);
|
||||
DocCut(doc,start_indent->next,end_indent->last);
|
||||
doc->cur_entry=start_indent->next;
|
||||
doc->cur_data_col=0;
|
||||
DocPrintF(doc,"DefinePrintF(\"DD_SPARROWOS_LOC\",\"%,d\");\n",result);
|
||||
|
||||
st=MSPrintF("%,d",result);
|
||||
DefineLoad("DD_SPARROWOS_LOC",st);
|
||||
Free(st);
|
||||
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
|
||||
"Total LOC:%12,d\n\n",result;
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 PrepForProduction(U8 *auto_cfg)
|
||||
{
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
PrepForDistribution;
|
||||
Auto(auto_cfg);
|
||||
InstallBoot(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 ":/SparrowOS","/SparrowOS");
|
||||
CopyTree(TS_MAIN_DRV ":/Windows","/Windows");
|
||||
CopyTree(TS_MAIN_DRV ":/Linux","/Linux");
|
||||
MkDir("/Temp");
|
||||
DelTree("/SparrowOS/Accts/TS");
|
||||
CopyTree(TS_MAIN_DRV ":/0000Boot","/0000Boot");
|
||||
Del("/0000Boot/OldMBR.BIN.C");
|
||||
Del("/0000Boot/BootMHD2.BIN.C");
|
||||
}
|
||||
|
||||
U0 MakeInHouseCDImage()
|
||||
{
|
||||
PrepForInHouse;
|
||||
CDFileCreate(TS_ISO_NAME,TS_IMG_DRV ":/*",NULL,BOOTCD_BIN_Z);
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
}
|
||||
|
||||
U0 MakeProductionCDImage()
|
||||
{
|
||||
PrepForProduction(PROD_CDROM_CFG);
|
||||
CDFileCreate(TS_ISO_NAME,TS_IMG_DRV ":/*",NULL,BOOTCD_BIN_Z);
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
}
|
||||
|
||||
U0 TSWebFile(U8 *name)
|
||||
{
|
||||
U8 *name2;
|
||||
CDirEntry de;
|
||||
if (FileFind(name,&de)) {
|
||||
"File:%s\n",name;
|
||||
UncollapseFile(name,NULL);
|
||||
Touch(name,"",NULL,de.datetime);
|
||||
name2=ChgExt(name,"html");
|
||||
ToHtml(name,name2,
|
||||
"<title>The Sparrow Operating System</title>\n"
|
||||
"<meta name=\"keywords\" content=\"Operating System,64-Bit,64 Bit,Sparrow,OS,SparrowOS,Free,Open Source,Public Domain,x86_64\">\n"
|
||||
);
|
||||
Touch(name2,"",NULL,de.datetime);
|
||||
Free(name2);
|
||||
}
|
||||
}
|
||||
|
||||
U0 MakeWebSite()
|
||||
{
|
||||
CDirEntry *tempm,*tempm2;
|
||||
if (ts_has_tra_drv) {
|
||||
DocClear;
|
||||
Cd(TS_TRA_DRV ":/Wb");
|
||||
tempm=tempm2=FilesFind(TEXT_FILE_MASK,FUF_RECURSE|FUF_FLATTEN_TREE|FUF_JUST_FILES);
|
||||
while (tempm) {
|
||||
TSWebFile(tempm->full_name);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
CDirListDel(tempm2);
|
||||
Drv(TS_MAIN_DRV_LET);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ToWeb(U8 *name)
|
||||
{
|
||||
U8 *st,*st2;
|
||||
if (ts_has_tra_drv) {
|
||||
st=FileNameAbs(name);
|
||||
if (!StrNCmp(st+1,":/SparrowOS/",12)) {
|
||||
st2=MSPrintF(TS_TRA_DRV":/Wb/%s",st+13);
|
||||
"%s\n",st2;
|
||||
Copy(name,st2);
|
||||
TSWebFile(st2);
|
||||
Free(st2);
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
|
||||
U0 TSUncompress()
|
||||
{
|
||||
U8 *st;
|
||||
CDirEntry *tempm,*tempm1;
|
||||
if (ts_has_tra_drv) {
|
||||
DelTree(TS_TRA_DRV ":/Uncompressed");
|
||||
CopyTree(TS_MAIN_DRV ":/SparrowOS",TS_TRA_DRV ":/Uncompressed");
|
||||
tempm=FilesFind(TS_TRA_DRV ":/Uncompressed/*.Z",FUF_RECURSE|FUF_FLATTEN_TREE|FUF_JUST_FILES);
|
||||
while (tempm) {
|
||||
tempm1=tempm->next;
|
||||
st=StrNew(tempm->full_name);
|
||||
StrLastRem(st,".");
|
||||
Move(tempm->full_name,st);
|
||||
Free(st);
|
||||
CDirEntryDel(tempm);
|
||||
tempm=tempm1;
|
||||
}
|
||||
FilesCursorRem(TS_TRA_DRV ":/Uncompressed/" TEXT_FILE_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
U0 MakeBack()
|
||||
{
|
||||
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
|
||||
WordStat;
|
||||
WinMax;
|
||||
WinBorder;
|
||||
ChkAll;
|
||||
MyCopyDrv(TS_MAIN_DRV_LET,TS_BAK_DRV_LET);
|
||||
if (ts_has_tra_drv) {
|
||||
MakeLineCntFile;
|
||||
MyCopyDrv(TS_MAIN_DRV_LET,TS_TRA_DRV_LET);
|
||||
DelTree (TS_TRA_DRV ":/Wb");
|
||||
CopyTree(TS_MAIN_DRV ":/SparrowOS",TS_TRA_DRV ":/Wb");
|
||||
DocClear;
|
||||
MakeInHouseCDImage;
|
||||
DocClear;
|
||||
Copy(TS_ISO_NAME,TS_TRA_DRV ":/Wb/SparrowOSTS.ISO");
|
||||
MakeProductionCDImage;
|
||||
DocClear;
|
||||
Copy(TS_ISO_NAME,TS_TRA_DRV ":/Wb/SparrowOSCD.ISO");
|
||||
Cd(TS_MAIN_DRV ":/SparrowOS");
|
||||
if (LinkChk)
|
||||
throw;
|
||||
MakeSymbolFiles;
|
||||
MakeWebSite;
|
||||
TSUncompress;
|
||||
}
|
||||
ChkAll;
|
||||
SettingsPop;
|
||||
}
|
||||
|
||||
public U0 TSMount()
|
||||
{
|
||||
Auto(CFG_HARD_DRVS "\n");
|
||||
Mount;
|
||||
}
|
||||
|
||||
U0 TSCopy()
|
||||
{
|
||||
DelTree(TS_MAIN_DRV ":/SparrowOS");
|
||||
CopyTree(TS_CDROM_DRV ":/",TS_MAIN_DRV ":/");
|
||||
CmpDrv(TS_MAIN_DRV_LET);
|
||||
DelTree(TS_BAK_DRV ":/SparrowOS");
|
||||
CopyTree(TS_CDROM_DRV ":/",TS_BAK_DRV ":/");
|
||||
CmpDrv(TS_BAK_DRV_LET);
|
||||
if (ts_has_tra_drv) {
|
||||
DelTree(TS_TRA_DRV ":/SparrowOS");
|
||||
CopyTree(TS_CDROM_DRV ":/",TS_TRA_DRV ":/");
|
||||
CmpDrv(TS_TRA_DRV_LET);
|
||||
}
|
||||
Reboot;
|
||||
}
|
||||
|
||||
U0 TSPrtDsk()
|
||||
{
|
||||
CTask *task=SpawnUser;
|
||||
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
ATARep(FALSE,&root);
|
||||
VMDrvs(root,&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%d\nY\nY\n",(prt_dsk_dsk_size-PRT_HEADER)/3,(prt_dsk_dsk_size-PRT_HEADER)/3);
|
||||
}
|
||||
Kill(task);
|
||||
}
|
||||
|
||||
|
||||
public U0 TSUpdate()
|
||||
{
|
||||
TSMount;
|
||||
TSCopy;
|
||||
}
|
||||
|
||||
public U0 TSInstall()
|
||||
{
|
||||
TSPrtDsk;
|
||||
TSCopy;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
U0 TSIDComputer()
|
||||
{
|
||||
CMemE820 *m20=SYS_MEM_E820;
|
||||
if (m20[11].base==0x100000000 &&
|
||||
m20[11].base(I64)+m20[11].len-1==0x33FFFFFFF)
|
||||
ts_cid=CID_TAD8;
|
||||
} TSIDComputer;
|
||||
@@ -0,0 +1,7 @@
|
||||
U0 TSIDComputer()
|
||||
{
|
||||
CMemE820 *m20=SYS_MEM_E820;
|
||||
if (m20[11].base==0x100000000 &&
|
||||
m20[11].base(I64)+m20[11].len-1==0x33FFFFFFF)
|
||||
ts_cid=CID_TAD8;
|
||||
} TSIDComputer;
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
This is a JIT file, not static.
|
||||
|
||||
Asm labels can only be defined once
|
||||
in a task. Hit F5 to spawn a new task
|
||||
and run it.
|
||||
*/
|
||||
|
||||
asm {
|
||||
//Opcodes are slightly different to make writing my x86_64 assembler easier.
|
||||
//See $LK,"::/SparrowOS/Compiler/OpCodes.TXT.Z","FI:::/SparrowOS/Compiler/OpCodes.TXT.Z"$.
|
||||
USE64 //Defaults to 64, but this is a good habit.
|
||||
IMPORT Beep;
|
||||
|
||||
_BEEPS::
|
||||
//You can clobber RAX,RBX,RCX,RDX,R8,R9 in a pure asm subroutine.
|
||||
ENTER 0
|
||||
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1","FF:::/SparrowOS/OSMain/Adam1a.HPP.Z,SF_ARG1"$
|
||||
|
||||
@@05: PUSH RCX
|
||||
//U0 Beep(I64 freq=500,Bool busy=FALSE)
|
||||
PUSH FALSE //Do not busy (spin) wait
|
||||
PUSH 500 //Hz
|
||||
CALL Beep
|
||||
POP RCX
|
||||
LOOP @@05
|
||||
|
||||
LEAVE
|
||||
//Return vals are in RAX if you have one.
|
||||
RET1 8
|
||||
}
|
||||
|
||||
|
||||
//_extern binds a asm sym to a function.
|
||||
//My convention is to put an underscore
|
||||
//on C callable routines.
|
||||
_extern _BEEPS U0 Beeps(I64 cnt);
|
||||
|
||||
I64 AsmAndC()
|
||||
{
|
||||
I64 noreg i; //Normally this would be stored in a reg
|
||||
//Check with $LK,"Uf","MN:Uf"$("AsmAndC").
|
||||
|
||||
i=PmtI64("Num of beeps 1-5 (%d):",3,1,5);
|
||||
Beeps(i);
|
||||
|
||||
asm {
|
||||
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a 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
|
||||
|
||||
MOV RAX,RCX //freq=loop*100.0+100.0
|
||||
IMUL2 RAX,100 //SparrowOS uses nonstandard opcodes
|
||||
//to avoid multiple form of the same one.
|
||||
//See $LK,"::/SparrowOS/Compiler/OpCodes.TXT.Z","FI:::/SparrowOS/Compiler/OpCodes.TXT.Z"$.
|
||||
//$BK,1$Asm is kind-of a bonus -- there's no reason$BK,0$
|
||||
//$BK,1$to use it, but I need it for the kernel.$BK,0$
|
||||
ADD RAX,100
|
||||
PUSH RAX
|
||||
FILD U64 [RSP] //Convert from int to floating
|
||||
FSTP U64 [RSP]
|
||||
|
||||
CALL Snd
|
||||
|
||||
MOV RCX,0x20000000 //Simple delay loop
|
||||
@@10: LOOP @@10
|
||||
|
||||
POP RCX
|
||||
LOOP @@05
|
||||
}
|
||||
Snd(0);
|
||||
return i;
|
||||
}
|
||||
|
||||
"Beeps:%d\n",AsmAndC;
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
This is a JIT file, not static.
|
||||
|
||||
Asm labels can only be defined once
|
||||
in a task. Hit F5 to spawn a new task
|
||||
and run it.
|
||||
*/
|
||||
|
||||
//This is to demo glbl var access.
|
||||
//Glbs defined elsewhere can accessed too, like sys_jiffies.
|
||||
I64 glbl_hz=400,glbl_hz_step=100,glbl_hz_base=100;
|
||||
|
||||
asm {
|
||||
//Opcodes are slightly different to make writing my x86_64 assembler easier.
|
||||
//See $LK,"::/SparrowOS/Compiler/OpCodes.TXT.Z","FI:::/SparrowOS/Compiler/OpCodes.TXT.Z"$.
|
||||
USE64 //Defaults to 64, but this is a good habit.
|
||||
|
||||
|
||||
//See $LK,"::/SparrowOS/OSMain/Str1a.CPP.Z","FL:::/SparrowOS/OSMain/Str1a.CPP.Z,1"$ and $LK,"::/SparrowOS/OSMain/Utils1a.CPP.Z","FI:::/SparrowOS/OSMain/Utils1a.CPP.Z"$.
|
||||
//These are asm syms and must be imported to work properly.
|
||||
//When in doubt, import syms.
|
||||
IMPORT PUT_STR,PUT_CHAR,PUT_HEX_U64;
|
||||
|
||||
JIFFIES_MSG: DU8 "Jiffies:",0;
|
||||
|
||||
_BEEPS2::
|
||||
//You can clobber RAX,RBX,RCX,RDX,R8,R9 in a pure asm subroutine.
|
||||
ENTER 0
|
||||
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1","FF:::/SparrowOS/OSMain/Adam1a.HPP.Z,SF_ARG1"$
|
||||
|
||||
PUSH U64 [&sys_jiffies]
|
||||
|
||||
@@05: PUSH RCX
|
||||
//U0 Beep(I64 freq=500,Bool busy=FALSE)
|
||||
PUSH FALSE //Do not busy (spin) wait
|
||||
PUSH U64 [&glbl_hz] //evaluated at run time
|
||||
CALL &Beep
|
||||
POP RCX
|
||||
LOOP @@05
|
||||
|
||||
PUSH RSI //we must preserve this register.
|
||||
MOV RSI,JIFFIES_MSG
|
||||
CALL PUT_STR
|
||||
POP RSI
|
||||
|
||||
POP RAX
|
||||
SUB RAX,U64 [&sys_jiffies]
|
||||
NEG RAX
|
||||
CALL PUT_HEX_U64
|
||||
MOV RAX,CH_NEW_LINE
|
||||
CALL PUT_CHAR
|
||||
|
||||
LEAVE
|
||||
RET1 8
|
||||
}
|
||||
|
||||
//My convention is to put an underscore
|
||||
//on C callable routines.
|
||||
_extern _BEEPS2 U0 Beeps2(I64 cnt);
|
||||
|
||||
U0 AsmAndC2()
|
||||
{
|
||||
I64 reg R15 i;
|
||||
|
||||
i=PmtI64("$$FG,PURPLE$$\n\nNum of beeps 1-5 (%d):$$FG$$",3,1,5);
|
||||
Beeps2(i);
|
||||
|
||||
asm {
|
||||
LIST
|
||||
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest for code in a 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
|
||||
|
||||
MOV RAX,RCX //freq=loop*100.0+100.0
|
||||
IMUL2 RAX,glbl_hz_step //evaluated at compile ttime
|
||||
ADD RAX,U64 [&glbl_hz_base] //evaluated at run time
|
||||
PUSH RAX
|
||||
FILD U64 [RSP] //Convert from int to floating
|
||||
FSTP U64 [RSP]
|
||||
|
||||
CALL &Snd //We can skip IMPORT for this symbol if JIT.
|
||||
|
||||
MOV RCX,0x20000000 //Simple delay loop
|
||||
@@10: LOOP @@10
|
||||
|
||||
POP RCX
|
||||
LOOP @@05
|
||||
}
|
||||
Snd(0);
|
||||
}
|
||||
|
||||
AsmAndC2;
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This is a JIT file, not static.
|
||||
|
||||
Asm labels can only be defined once
|
||||
in a task. Hit F5 to spawn a new task
|
||||
and run it.
|
||||
|
||||
These are many useful kernel
|
||||
routines $LK,"::/SparrowOS/OSMain/Str1a.CPP.Z","FF:::/SparrowOS/OSMain/Str1a.CPP.Z,PUT_CHAR"$
|
||||
intended to be called from
|
||||
asm. Generally, they preserve
|
||||
regs.
|
||||
|
||||
You can call any routine you
|
||||
like, C or asm, if you import it.
|
||||
Be aware that C routines do not
|
||||
preserve RAX,RBX,RCX,RDX,R8,R9.
|
||||
When calling from the shell or
|
||||
from C, preserve all other regs.
|
||||
|
||||
*/
|
||||
|
||||
asm {
|
||||
//Opcodes are slightly different to make writing my x86_64 assembler easier.
|
||||
//See $LK,"::/SparrowOS/Compiler/OpCodes.TXT.Z","FI:::/SparrowOS/Compiler/OpCodes.TXT.Z"$.
|
||||
|
||||
USE64 //Defaults to 64, but this is a good habit.
|
||||
|
||||
IMPORT PUT_HEX_U8,PUT_CHAR;
|
||||
|
||||
MY_MSG:
|
||||
//Define U8 does not put terminating zeros
|
||||
//on strings.
|
||||
DU8 "Hello World\n",0;
|
||||
|
||||
//My convention is to put an underscore
|
||||
//on C callable routines.
|
||||
_HELLO_WORLD::
|
||||
MOV RCX,10
|
||||
@@05: MOV RAX,RCX
|
||||
CALL PUT_HEX_U8
|
||||
MOV RAX,CH_SPACE
|
||||
CALL PUT_CHAR
|
||||
MOV RSI,MY_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
|
||||
RET
|
||||
};
|
||||
|
||||
Call(_HELLO_WORLD);
|
||||
@@ -0,0 +1,48 @@
|
||||
#define RANGE_START 1
|
||||
#define RANGE_END 100
|
||||
|
||||
#define FIZZ_SPAN 6
|
||||
#define BUZZ_SPAN 7
|
||||
|
||||
asm {
|
||||
MSG_BUZZ: DU8 "BUZZ\n\0";
|
||||
MSG_FIZZ: DU8 "FIZZ\n\0";
|
||||
MSG_BUZZ_FIZZ: DU8 "BUZZ_FIZZ\n\0";
|
||||
MSG_NEW_LINE: DU8 "\n\0";
|
||||
|
||||
_BUZZ_FIZZ::
|
||||
ENTER 0 //Always use Enter/Leave
|
||||
PUSH ESI //RSI must be preserved. This instruction is 64-bit.
|
||||
MOV RAX,RANGE_START
|
||||
MOV DX,(FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1)<<8+
|
||||
(BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1)
|
||||
|
||||
@@05: DEC DH
|
||||
JNZ @@10
|
||||
MOV DH,FIZZ_SPAN
|
||||
MOV ESI,MSG_FIZZ
|
||||
DEC DL
|
||||
JNZ @@20
|
||||
MOV DL,BUZZ_SPAN
|
||||
MOV ESI,MSG_BUZZ_FIZZ
|
||||
JMP @@20
|
||||
|
||||
@@10: DEC DL
|
||||
JNZ @@15
|
||||
MOV DL,BUZZ_SPAN
|
||||
MOV ESI,MSG_BUZZ
|
||||
JMP @@20
|
||||
|
||||
@@15: CALL &PUT_HEX_U64
|
||||
MOV ESI,MSG_NEW_LINE
|
||||
@@20: CALL &PUT_STR
|
||||
|
||||
INC RAX
|
||||
CMP RAX,RANGE_END //Actually only a 32-bit instruction.
|
||||
JBE @@05
|
||||
POP ESI
|
||||
LEAVE
|
||||
RET
|
||||
}
|
||||
|
||||
Call(_BUZZ_FIZZ);
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
asm {
|
||||
DIV_U64_BY_U64::
|
||||
ENTER 0
|
||||
XOR RDX,RDX
|
||||
MOV RCX,64
|
||||
MOV RAX,SF_ARG1[RBP]
|
||||
MOV RBX,SF_ARG2[RBP]
|
||||
@@1: SHL1 RAX
|
||||
RCL1 RDX
|
||||
CMP RBX,RDX
|
||||
JA @@2
|
||||
INC RAX
|
||||
SUB RDX,RBX
|
||||
@@2: LOOP @@1
|
||||
LEAVE
|
||||
RET1 16
|
||||
}
|
||||
|
||||
_extern DIV_U64_BY_U64 I64 DivU64ByU64(I64 dividend,I64 divisor);
|
||||
|
||||
"123456/10=%d\n",DivU64ByU64(123456,10);
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
When I was a kid with a Commodore 64,
|
||||
the 6502 chip had no multiply instruction
|
||||
and this is how we had to do it, except,
|
||||
I used more regs in this example.
|
||||
*/
|
||||
asm {
|
||||
//Opcodes are slightly different to make writing my x86_64 assembler easier.
|
||||
//See $LK,"::/SparrowOS/Compiler/OpCodes.TXT.Z","FI:::/SparrowOS/Compiler/OpCodes.TXT.Z"$.
|
||||
|
||||
USE64 //Defaults to 64, but this is a good habit.
|
||||
|
||||
//You can clobber RAX,RBX,RCX,RDX,R8,R9
|
||||
|
||||
MUL_BY_HAND_U8_U8_TO_U16: //This is only for fun.
|
||||
//8bit * 8bit-->16bit
|
||||
//AL*BL-->AX
|
||||
MOV CL,8
|
||||
SHL AX,8
|
||||
@@05: SHL1 AX
|
||||
JNC @@10
|
||||
ADD AL,BL
|
||||
@@10: DEC CL
|
||||
JNZ @@05
|
||||
RET
|
||||
|
||||
_MUL_BY_HAND_U8_U8_TO_U16:: //C callable
|
||||
ENTER 0
|
||||
MOV AL,U8 SF_ARG1[RBP] //$LK,"SF_ARG1","FF:::/SparrowOS/OSMain/Adam1a.HPP.Z,SF_ARG1"$
|
||||
MOV BL,U8 SF_ARG2[RBP]
|
||||
CALL MUL_BY_HAND_U8_U8_TO_U16
|
||||
MOVZX RAX,AX
|
||||
LEAVE
|
||||
RET1 16
|
||||
|
||||
_MUL_U64_U64_TO_U128::
|
||||
//64bit * 64bit-->128bit
|
||||
ENTER 0
|
||||
MOV RBX,U64 SF_ARG3[RBP]
|
||||
MOV RAX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1","FF:::/SparrowOS/OSMain/Adam1a.HPP.Z,SF_ARG1"$
|
||||
MUL U64 SF_ARG2[RBP] //Result RDX:RAX 128bit
|
||||
MOV U64 [RBX],RAX
|
||||
MOV U64 8[RBX],RDX
|
||||
LEAVE
|
||||
RET1 24
|
||||
};
|
||||
|
||||
//My convention is to put an underscore
|
||||
//on C callable routines.
|
||||
_extern _MUL_BY_HAND_U8_U8_TO_U16 U16 MulU8(U8 n1,U8 n2);
|
||||
|
||||
class U128
|
||||
{
|
||||
U64 lo,hi;
|
||||
};
|
||||
|
||||
_extern _MUL_U64_U64_TO_U128 U0 MulU64(I64 n1,I64 n2,U128 *_prod);
|
||||
|
||||
U0 MulByHand()
|
||||
{
|
||||
U128 p;
|
||||
"2*7 =0x%X\n",MulU8(2,7);
|
||||
"100*10=0x%X\n",MulU8(100,10);
|
||||
|
||||
MulU64(0x0123456789ABCDEF,0x1000001,&p);
|
||||
"0x0123466789ABCDEF*0x1000001=0x%016X%016X\n",p.hi,p.lo;
|
||||
}
|
||||
|
||||
MulByHand;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
asm {
|
||||
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:::/SparrowOS/OSMain/Adam1a.HPP.Z,PUSH_C_REGS"$ which C code is free to clobber
|
||||
PUSH RSI //This reg is not saved.
|
||||
LEA RSI,-1[RBP] //Load addr of end of buffer.
|
||||
//We picked RSI because of PUT_STR
|
||||
//We'll move backward
|
||||
MOV U8 [RSI],0 //Terminator
|
||||
|
||||
OR RAX,RAX //Special case -- zero
|
||||
JNZ @@05
|
||||
DEC RSI
|
||||
MOV U8 [RSI],'0'
|
||||
JMP @@15
|
||||
|
||||
@@05: MOV RBX,10 //Divides by 10
|
||||
|
||||
@@10: XOR RDX,RDX
|
||||
DIV RBX //RAX=(RDX:RAX)/RBX with remainder in RDX
|
||||
ADD RDX,'0'
|
||||
DEC RSI
|
||||
MOV U8 [RSI],DL
|
||||
OR RAX,RAX
|
||||
JNZ @@10
|
||||
|
||||
@@15: CALL &PUT_STR
|
||||
POP RSI
|
||||
POP_C_REGS
|
||||
LEAVE
|
||||
RET
|
||||
|
||||
_DO_IT:: //The convention is C-callable routines have underscores.
|
||||
MOV RAX,122333221
|
||||
CALL PUT_DEC_U64
|
||||
PUSH 1
|
||||
CALL &NewLine //Print one carriage return
|
||||
RET
|
||||
}
|
||||
|
||||
Call(_DO_IT);
|
||||
@@ -0,0 +1,15 @@
|
||||
/* To run this, do a directory, right click on
|
||||
this file's name and select "AutoFile".
|
||||
Or, type $LK,"AutoFile","MN:AutoFile"$(filename);
|
||||
See $LK,"AutoFile","FF:::/SparrowOS/Doc/Glossary.TXT.Z,AutoFile"$ in the glossary for more info.
|
||||
*/
|
||||
|
||||
|
||||
I64 i;
|
||||
for (i=0;i<3;i++)
|
||||
"Dir;\n";
|
||||
|
||||
"$$FG,RED$$//Press a letter to complete the mask$$FG$$\n";
|
||||
"Dir(\"*.";
|
||||
I64 ch=GetChar(NULL,FALSE); //Prompt for first digit of mask
|
||||
"%c*\");\n",ch;
|
||||
@@ -0,0 +1,28 @@
|
||||
/* To run this, do a directory, right click on
|
||||
this file's name and select "AutoFile".
|
||||
Or, type $LK,"AutoFile","MN:AutoFile"$(filename);
|
||||
See $LK,"AutoFile","FF:::/SparrowOS/Doc/Glossary.TXT.Z,AutoFile"$ in the glossary for more info.
|
||||
|
||||
This autofile will renum the defines in
|
||||
AFEd.TXT.Z. Test it by numbering a few wrong
|
||||
and running this demo.
|
||||
|
||||
*/
|
||||
|
||||
U8 i;
|
||||
|
||||
"Ed(\"AFEd.TXT.Z\");\n";
|
||||
//Go to start of file
|
||||
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
|
||||
for (i=0;i<=0xC3;i++) {
|
||||
if (i)
|
||||
Msg(MSG_KEY_DOWN_UP,0,SC_F3);
|
||||
else
|
||||
"%c0x%c",CH_CTRLF,CH_ESC;
|
||||
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
|
||||
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
|
||||
"%02X",i;
|
||||
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
|
||||
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
|
||||
"%c%c",CH_BACKSPACE,CH_BACKSPACE;
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
//Intermediate compiler codes
|
||||
#define IC_END 0x00
|
||||
#define IC_START 0x01
|
||||
#define IC_NOP 0x02
|
||||
#define IC_END_EXP 0x03
|
||||
#define IC_NOP1 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_STR_CONST 0x0D
|
||||
#define IC_ABS_ADDR 0x0E
|
||||
#define IC_ADDR_IMPORT 0x0F
|
||||
#define IC_HEAP_GLBL 0x10
|
||||
#define IC_SIZEOF 0x11
|
||||
#define IC_TYPE 0x12
|
||||
#define IC_GET_LABEL 0x13
|
||||
#define IC_RBP 0x14
|
||||
#define IC_REG 0x15
|
||||
#define IC_FS 0x16
|
||||
#define IC_GS 0x17
|
||||
|
||||
#define IC_LEA 0x18
|
||||
#define IC_MOV 0x19
|
||||
|
||||
#define IC_TO_I64 0x1A
|
||||
#define IC_TO_F64 0x1B
|
||||
#define IC_TO_BOOL 0x1C
|
||||
#define IC_TOUPPER 0x1D
|
||||
#define IC_NATIVE_TYPECAST 0x1E
|
||||
|
||||
#define IC_ADDR 0x1F
|
||||
#define IC_COM 0x20
|
||||
#define IC_NOT 0x21
|
||||
#define IC_UNARY_MINUS 0x22
|
||||
|
||||
#define IC_DEREF 0x23
|
||||
#define IC_DEREF_PP 0x24
|
||||
#define IC_DEREF_MM 0x25
|
||||
#define IC__PP 0x26
|
||||
#define IC__MM 0x27
|
||||
#define IC_PP_ 0x28
|
||||
#define IC_MM_ 0x29
|
||||
|
||||
#define IC_SHL 0x2A
|
||||
#define IC_SHR 0x2B
|
||||
#define IC_SHL_CONST 0x2C
|
||||
#define IC_SHR_CONST 0x2D
|
||||
#define IC_POWER 0x2E
|
||||
|
||||
#define IC_MUL 0x2F
|
||||
#define IC_DIV 0x30
|
||||
#define IC_MOD 0x31
|
||||
|
||||
#define IC_AND 0x32
|
||||
|
||||
#define IC_OR 0x33
|
||||
#define IC_XOR 0x34
|
||||
|
||||
#define IC_ADD 0x35
|
||||
#define IC_SUB 0x36
|
||||
#define IC_ADD_CONST 0x37
|
||||
#define IC_SUB_CONST 0x38
|
||||
|
||||
#define IC_EQUAL_EQUAL 0x39
|
||||
#define IC_NOT_EQUAL 0x3A
|
||||
#define IC_LESS 0x3B
|
||||
#define IC_GREATER 0x3C
|
||||
#define IC_LESS_EQUAL 0x3D
|
||||
#define IC_GREATER_EQUAL 0x3E
|
||||
#define IC_PUSH_CMP 0x3F
|
||||
|
||||
#define IC_AND_AND 0x40
|
||||
|
||||
#define IC_OR_OR 0x41
|
||||
#define IC_XOR_XOR 0x42
|
||||
|
||||
#define IC_COLON 0x43
|
||||
#define IC_QUESTION 0x44
|
||||
|
||||
#define IC_ASSIGN 0x45
|
||||
#define IC_ASSIGN_PP 0x46
|
||||
#define IC_ASSIGN_MM 0x47
|
||||
|
||||
#define IC_SHL_EQUAL 0x48
|
||||
#define IC_SHR_EQUAL 0x49
|
||||
#define IC_MUL_EQUAL 0x4A
|
||||
#define IC_DIV_EQUAL 0x4B
|
||||
#define IC_MOD_EQUAL 0x4C
|
||||
#define IC_AND_EQUAL 0x4D
|
||||
#define IC_OR_EQUAL 0x4E
|
||||
#define IC_XOR_EQUAL 0x4F
|
||||
#define IC_ADD_EQUAL 0x50
|
||||
#define IC_SUB_EQUAL 0x51
|
||||
|
||||
#define IC_JMP 0x52
|
||||
#define IC_SWITCH 0x53
|
||||
#define IC_NOBOUND_SWITCH 0x54
|
||||
|
||||
#define IC_ADD_RSP 0x55
|
||||
#define IC_ADD_RSP1 0xC1
|
||||
#define IC_ENTER 0x56
|
||||
#define IC_PUSH_REGS 0x57
|
||||
#define IC_POP_REGS 0x58
|
||||
#define IC_LEAVE 0x59
|
||||
#define IC_RET 0x5A
|
||||
|
||||
#define IC_CALL 0x5B
|
||||
#define IC_CALL_INDIRECT 0x5C
|
||||
#define IC_CALL_INDIRECT2 0x5D
|
||||
#define IC_CALL_IMPORT 0x5E
|
||||
#define IC_CALL_EXTERN 0x5F
|
||||
#define IC_IRQ 0x60
|
||||
|
||||
#define IC_ASM 0x61
|
||||
#define IC_CLI 0x62
|
||||
#define IC_STI 0x63
|
||||
#define IC_PREEMPT 0x64
|
||||
#define IC_CLD 0x65
|
||||
#define IC_STD 0x66
|
||||
#define IC_HLT 0x67
|
||||
#define IC_PUSHFD 0x68
|
||||
#define IC_POPFD 0x69
|
||||
#define IC_PAUSE 0x6A
|
||||
|
||||
#define IC_CLFLUSH 0x6B
|
||||
#define IC_INVLPG 0x6C
|
||||
#define IC_WBINVD 0x6F
|
||||
#define IC_INVD 0x70
|
||||
|
||||
#define IC_INU8 0x71
|
||||
#define IC_INU16 0x72
|
||||
#define IC_INU32 0x73
|
||||
#define IC_OUTU8 0x74
|
||||
#define IC_OUTU16 0x75
|
||||
#define IC_OUTU32 0x76
|
||||
|
||||
#define IC_GET_FLAGS 0x77
|
||||
#define IC_SET_FLAGS 0x78
|
||||
#define IC_GET_RAX 0x79
|
||||
#define IC_SET_RAX 0x7A
|
||||
#define IC_GET_BASE_PTR 0x7B
|
||||
#define IC_SET_BASE_PTR 0x7C
|
||||
#define IC_GET_STK_PTR 0x7D
|
||||
#define IC_SET_STK_PTR 0x7E
|
||||
#define IC_RIP 0x7F
|
||||
|
||||
#define IC_RDTSC 0x80
|
||||
#define IC_HPET 0x81
|
||||
|
||||
#define IC_BT 0x82
|
||||
#define IC_BTS 0x83
|
||||
#define IC_BTR 0x84
|
||||
#define IC_BTC 0x85
|
||||
#define IC_BEQU 0x86
|
||||
#define IC_LBTS 0x87
|
||||
#define IC_LBTR 0x88
|
||||
#define IC_LBTC 0x89
|
||||
#define IC_LBEQU 0x8A
|
||||
#define IC_BSF 0x8B
|
||||
#define IC_BSR 0x8C
|
||||
|
||||
#define IC_QUE_INS 0x8D
|
||||
#define IC_QUE_INS_REV 0x8E
|
||||
#define IC_QUE_REM 0x8F
|
||||
|
||||
#define IC_STRLEN 0x90
|
||||
#define IC_MEMCPY 0x91
|
||||
|
||||
#define IC_MEMSET 0x92
|
||||
#define IC_MEMSET_U16 0xC2
|
||||
#define IC_MEMSET_U32 0xC3
|
||||
#define IC_MEMSET_U64 0xC4
|
||||
|
||||
#define IC_BR_ZERO 0x93
|
||||
#define IC_BR_NOT_ZERO 0x94
|
||||
|
||||
#define IC_BR_NOT_EQUAL 0x95
|
||||
#define IC_BR_EQUAL_EQUAL 0x96
|
||||
#define IC_BR_GREATER_EQUAL 0x97
|
||||
#define IC_BR_LESS_EQUAL 0x98
|
||||
#define IC_BR_GREATER 0x99
|
||||
#define IC_BR_LESS 0x9A
|
||||
#define IC_BR_NOT_EQUAL2 0x9B
|
||||
#define IC_BR_EQUAL_EQUAL2 0x9C
|
||||
#define IC_BR_GREATER_EQUAL2 0x9D
|
||||
#define IC_BR_LESS_EQUAL2 0x9E
|
||||
#define IC_BR_GREATER2 0x9F
|
||||
#define IC_BR_LESS2 0xA0
|
||||
#define IC_BR_AND_ZERO 0xA1
|
||||
#define IC_BR_AND_NOT_ZERO 0xA2
|
||||
#define IC_BR_AND_AND_ZERO 0xA3
|
||||
#define IC_BR_AND_AND_NOT_ZERO 0xA4
|
||||
#define IC_BR_OR_OR_ZERO 0xA5
|
||||
#define IC_BR_OR_OR_NOT_ZERO 0xA6
|
||||
|
||||
#define IC_BR_BT 0xA7
|
||||
#define IC_BR_BTS 0xA8
|
||||
#define IC_BR_BTR 0xA9
|
||||
#define IC_BR_BTC 0xAA
|
||||
#define IC_BR_LBTS 0xAB
|
||||
#define IC_BR_LBTR 0xAC
|
||||
#define IC_BR_LBTC 0xAD
|
||||
#define IC_BR_NOT_BT 0xAE
|
||||
#define IC_BR_NOT_BTS 0xAF
|
||||
#define IC_BR_NOT_BTR 0xB0
|
||||
#define IC_BR_NOT_BTC 0xB1
|
||||
#define IC_BR_NOT_LBTS 0xB2
|
||||
#define IC_BR_NOT_LBTR 0xB3
|
||||
#define IC_BR_NOT_LBTC 0xB4
|
||||
|
||||
#define IC_SWAP_U8 0xB5
|
||||
#define IC_SWAP_U16 0xB6
|
||||
#define IC_SWAP_U32 0xB7
|
||||
#define IC_SWAP_U64 0xB8
|
||||
|
||||
#define IC_ABS_I64 0xB9
|
||||
#define IC_SIGN_I64 0xBA
|
||||
#define IC_MIN_I64 0xBB
|
||||
#define IC_MIN_U64 0xBC
|
||||
#define IC_MAX_I64 0xBD
|
||||
#define IC_MAX_U64 0xBE
|
||||
#define IC_LIMIT_I64 0xBF
|
||||
#define IC_LIMIT_U64 0xC0
|
||||
|
||||
#define IC_NUM_ENTRIES 0xC5
|
||||
@@ -0,0 +1,12 @@
|
||||
/* This is not an AutoFile. It uses $LK,"AutoStr","MN:AutoStr"$
|
||||
to run text as though from an AutoFile.
|
||||
|
||||
This example shows how you can drive pop-up
|
||||
windows.
|
||||
*/
|
||||
|
||||
Auto(" ");
|
||||
"PopUp #1:%X\n",PopUpNoYes;
|
||||
|
||||
AutoStr("Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);'' CH_SPACE;");
|
||||
"PopUp #2:%X\n",PopUpNoYes;
|
||||
@@ -0,0 +1,26 @@
|
||||
U0 DoWait()
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<3;i++) {
|
||||
"PopUpNoYes;\n ";
|
||||
|
||||
//Necessary after a $LK,"DocEntryRun","MN:DocEntryRun"$()
|
||||
//which occurs when PopUp's close.
|
||||
TaskWait;
|
||||
|
||||
"\"%d\\n\\n\";\n",i;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DoNoWait()
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<3;i++)
|
||||
"PopUpNoYes;\n \"%d\\n\\n\";\n",i;
|
||||
}
|
||||
|
||||
"//With Wait ";PressAKey;
|
||||
DoWait;
|
||||
"//With No Wait ";PressAKey;
|
||||
DoNoWait;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/* To run this, do a directory, right click on
|
||||
this file's name and select "AutoFile".
|
||||
Or, type $LK,"AutoFile","MN:AutoFile"$(filename);
|
||||
See $LK,"AutoFile","FF:::/SparrowOS/Doc/Glossary.TXT.Z,AutoFile"$ in the glossary for more info.
|
||||
|
||||
Profiling does not $UL,1$require$UL,0$ autofiles.
|
||||
*/
|
||||
"$$FG,RED$$ProfAll;$$FG$$\n";
|
||||
"$$FG,RED$$//Collecting Data$$FG$$";
|
||||
PressAKey;
|
||||
"\n$$FG,RED$$ProfRep;$$FG$$\n";
|
||||
@@ -0,0 +1,13 @@
|
||||
U0 AFSetIPDemo()
|
||||
{
|
||||
I64 t,l;
|
||||
WinBorder(ON);
|
||||
l=Fs->win_pixel_left+Fs->win_scroll_x;
|
||||
t=Fs->win_pixel_top+Fs->win_scroll_y;
|
||||
SetIP(,,,FALSE,FALSE,FALSE); //Mouse unclicked
|
||||
AFSetIP(,l-4,t-4);
|
||||
AFSetIP(20,l+20,t+20,,TRUE);
|
||||
SetIP(,,,FALSE,FALSE,FALSE);
|
||||
}
|
||||
|
||||
AFSetIPDemo;
|
||||
@@ -0,0 +1,81 @@
|
||||
//This demonstrates class meta data.
|
||||
//Basically, we make use of the compiler's
|
||||
//data about a class. We can add to the
|
||||
//compilers data arbitrary items, either string or
|
||||
//or int or F64 (if you typecast).
|
||||
|
||||
//This stuff is not high performance.
|
||||
//Don't get carried away -- it might be slow.
|
||||
|
||||
|
||||
U0 RankOut(I64 i)
|
||||
{
|
||||
" %z",i,"Cadet\0Ensign\0Captain\0Admiral\0President\0";
|
||||
}
|
||||
|
||||
class Test1Struct
|
||||
{
|
||||
I64 age printf_str "%2d" dft_val 38;
|
||||
I64 color dft_val RED; //Accepts expressions
|
||||
I64 rank printf_str "%1d" dft_val 6/2 output_fun &RankOut;
|
||||
};
|
||||
|
||||
class Test2Struct
|
||||
{
|
||||
I64 age printf_str "%2d" dft_val 38 percentile 54.20;
|
||||
I64 rank printf_str "%1d" dft_val 5;
|
||||
I64 serial_num printf_str "%6d" dft_val 123456;
|
||||
};
|
||||
|
||||
|
||||
U0 DumpStruct(U8 *class_name,U8 *data)
|
||||
{
|
||||
CHashClass *tempc=HashFind(class_name,Fs->hash_table,HTT_CLASS);
|
||||
U8 *printf_str;
|
||||
I64 *q,dft_val;
|
||||
U0 (* fp_output_fun)(I64 i);
|
||||
F64 percentile;
|
||||
if (!tempc) return;
|
||||
CMemberList *ml;
|
||||
ml=tempc->member_list;
|
||||
while (ml) {
|
||||
"%s:",ml->str;
|
||||
|
||||
//All our items are I64's. If you want, you can check
|
||||
//the data type of the member var. See $LK,"ClassRep","MN:ClassRep"$().
|
||||
q=data+ml->offset;
|
||||
|
||||
if (printf_str=MemberMetaData("printf_str",ml))
|
||||
"" printf_str,*q;
|
||||
|
||||
//This is slightly ambiguous -- if no meta is present it will return zero.
|
||||
if (dft_val=MemberMetaData("dft_val",ml))
|
||||
" default:%d",dft_val;
|
||||
|
||||
//This corrects for the ambiguity, allowing zero percentile.
|
||||
if (MemberMetaFind("percentile",ml)) { //check if it exists
|
||||
//We could use the $LK,"CMemberListMeta","MN:CMemberListMeta"$ structure returned by
|
||||
//$LK,"MemberMetaFind","MN:MemberMetaFind"$() and save a search.
|
||||
percentile=MemberMetaData("percentile",ml)(F64);
|
||||
" percentile: %5.2f",percentile;
|
||||
}
|
||||
|
||||
if (fp_output_fun=MemberMetaData("output_fun",ml))
|
||||
(*fp_output_fun)(*q);
|
||||
NewLine;
|
||||
ml=ml->next;
|
||||
}
|
||||
}
|
||||
|
||||
Test1Struct t1;
|
||||
t1.age=44;
|
||||
t1.rank=3;
|
||||
|
||||
DumpStruct("Test1Struct",&t1);
|
||||
|
||||
Test2Struct t2;
|
||||
t2.age=22;
|
||||
t2.rank=2;
|
||||
t2.serial_num=55555;
|
||||
|
||||
DumpStruct("Test2Struct",&t2);
|
||||
@@ -0,0 +1,37 @@
|
||||
F64 glbl;
|
||||
|
||||
F64 CompileDemo(U8 *st)
|
||||
{
|
||||
I64 type;
|
||||
U8 *code;
|
||||
CLex *lx=LexNew(st,LF_DONT_FREE_BUF);
|
||||
F64 result=0;
|
||||
Lex(lx); //Gotta get it started
|
||||
"Compile \"%s\"\n",st;
|
||||
do {
|
||||
if (code=CmpExpression(lx,&type)) {
|
||||
if (type!=IT_F64)
|
||||
result=ToF64(Call(code));
|
||||
else
|
||||
result=Call(code)(F64);
|
||||
ExpressionDel(code);
|
||||
}
|
||||
"result=%9.4f\n",result;
|
||||
if (lx->token==';')
|
||||
Lex(lx);
|
||||
} while (lx->token!=TK_EOF); //end of file?
|
||||
LexDel(lx);
|
||||
return result;
|
||||
}
|
||||
|
||||
CompileDemo("2+Cos(ã)");
|
||||
CompileDemo("1;2+4");
|
||||
CompileDemo("glbl=1;glbl*2;glbl/3;Sin(glbl)");
|
||||
|
||||
//This is just like you typed-it on
|
||||
//the cmd line.
|
||||
ExePutS(
|
||||
"I64 i;"
|
||||
"for (i=0;i<10;i++) "
|
||||
" \"%d\n\",i;"
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
An $LK,"CDate","MN:CDate"$ is a signed 64-bit date/time num
|
||||
representing how many 49710ths of a second
|
||||
since Christ. The reason it is this crazy
|
||||
num is so that 32bits is exactly one day.
|
||||
|
||||
These nums can be subtracted to get time
|
||||
differences.
|
||||
|
||||
The time of day to the nearest 49710ths of a second
|
||||
is stored in the lower 32-bits. The upper
|
||||
32-bits hold the num of days since Christ.
|
||||
|
||||
$LK,"PrintF","MN:PrintF"$() and the file datetimes use
|
||||
this format, otherwise you might want to
|
||||
use $LK,"GetTimeStamp","MN:GetTimeStamp"$() for a higher frequency
|
||||
timing, divide by $LK,"time_stamp_freq","MN:time_stamp_freq"$,
|
||||
but this num is tied to your CPU's
|
||||
clock frequency which is inexact when
|
||||
converted to real-time.
|
||||
*/
|
||||
|
||||
|
||||
CDate ltdt=GetCurTimeCDate;
|
||||
|
||||
I64 i;
|
||||
for (i=0;i<NUM_DATE_FMTS;i++)
|
||||
"%%h%dD: %h*D\n",i,i,ltdt;
|
||||
NewLine;
|
||||
|
||||
for (i=0;i<NUM_TIME_FMTS;i++)
|
||||
"%%h%dT: %h*T\n",i,i,ltdt;
|
||||
|
||||
"$$FG,PURPLE$$CDate freq:%12.6f$$FG$$\n",0x100000000/24.0/60.0/60.0;
|
||||
|
||||
/*
|
||||
You can customize to your locality
|
||||
with $LK,"date_fmt_map","MN:date_fmt_map"$[] and $LK,"time_fmt_map","MN:time_fmt_map"$[].
|
||||
$LK,"DateTimeFmtMapsRst","MN:DateTimeFmtMapsRst"$() will rst
|
||||
them.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Press <CTRL-ALT-C> to break.
|
||||
|
||||
Rerun Program
|
||||
|
||||
Press <CTRL-ALT-D> to enter Dbg.
|
||||
> $LK,"Dr","MN:Dr"$; //Dump Registers
|
||||
> $LK,"BptsR","MN:BptsR"$; //Clear break-points.
|
||||
> $LK,"Go2","MN:Go2"$; //Cont program
|
||||
|
||||
|
||||
Press <CTRL-ALT-D> to enter Dbg.
|
||||
> $LK,"Uf","MN:Uf"$("DbgDemo");
|
||||
> $LK,"U","MN:U"$(RIP);
|
||||
|
||||
See $LK,"Debugging","HI:Debugging"$
|
||||
|
||||
*/
|
||||
|
||||
U0 DbgDemo()
|
||||
{
|
||||
I64 i=0;
|
||||
while (TRUE)
|
||||
if (!(i++%2000000))
|
||||
".";
|
||||
}
|
||||
|
||||
DbgDemo;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
See $LK,"Define","HI:Char/Define"$.
|
||||
*/
|
||||
|
||||
//These might be in the Adam task.
|
||||
DefineLoad("ST_YES_NO","(Yes or No)");
|
||||
DefineLoad("ST_EXIT","Exit");
|
||||
DefineListLoad("ST_NO_YES_LIST","No\0Yes\0");
|
||||
|
||||
|
||||
//New strings might be loaded for each user
|
||||
//to override.
|
||||
|
||||
"Spanish";
|
||||
if (YorN) {
|
||||
DefineLoad("ST_YES_NO","(Si or No)");
|
||||
DefineLoad("ST_EXIT","Salida");
|
||||
DefineListLoad("ST_NO_YES_LIST","No\0Si\0");
|
||||
}
|
||||
|
||||
|
||||
Bool Quit()
|
||||
{
|
||||
Bool result;
|
||||
U8 *st;
|
||||
I64 i;
|
||||
while (TRUE) {
|
||||
"%S %S?","ST_EXIT","ST_YES_NO";
|
||||
st=MGetS;
|
||||
i=DefineMatch(st,"ST_NO_YES_LIST",LEF_IGNORE_CASE);
|
||||
if (i>=0) {
|
||||
result=i;
|
||||
break;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Quit;
|
||||
@@ -0,0 +1,77 @@
|
||||
//This loads a list of zero terminated
|
||||
//strings into the sym table and
|
||||
//gives a name to it. Strings like
|
||||
//this are known as Define entries.
|
||||
|
||||
//See $LK,"ST_RAINBOW_10","FF:::/SparrowOS/Adam/Gr/GrScreen.CPP.Z,ST_RAINBOW_10"$
|
||||
|
||||
U0 ShowDigit(U8 ch)
|
||||
{
|
||||
//The %Z code displays a Define subentry
|
||||
"$$FG,%Z$$%d$$FG$$",ch-'0',"ST_RAINBOW_10",ch-'0';
|
||||
}
|
||||
|
||||
U0 ShowPattern(U8 *st)
|
||||
{
|
||||
U8 ch;
|
||||
while (ch=*st++)
|
||||
ShowDigit(ch);
|
||||
NewLine;
|
||||
}
|
||||
|
||||
U0 Digits()
|
||||
{
|
||||
I64 num,ch,i;
|
||||
U8 answer[1024];
|
||||
|
||||
DocClear;
|
||||
//Set default background and foreground
|
||||
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$"
|
||||
"\nThis is a mem game. "
|
||||
"Try to remember the digits and enter them. "
|
||||
"They are colored based on electrical "
|
||||
"engineering color codes.\n";
|
||||
for (i=0;i<10;i++) {
|
||||
"$$FG,%Z$$%d: %Z\n",i,"ST_RAINBOW_10",i,i,"ST_RAINBOW_10";
|
||||
}
|
||||
"$$FG$$\n"; //set to default background
|
||||
if (!PressAKey) goto dg_done;
|
||||
|
||||
while (TRUE) {
|
||||
restart:
|
||||
num=0;
|
||||
//Set to zeros so we have terminators
|
||||
MemSet(answer,0,sizeof(answer));
|
||||
while (TRUE) {
|
||||
DocClear;
|
||||
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$\n";
|
||||
"Pattern\nLength:%d\n\n",num+1;
|
||||
answer[num++]=RandU32%10+'0';
|
||||
ShowPattern(answer);
|
||||
if (!PressAKey) goto dg_done;
|
||||
|
||||
DocClear;
|
||||
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$\n";
|
||||
"Guess\nLength:%d\n\n",num;
|
||||
for (i=0;i<num;i++) {
|
||||
ch=GetChar(NULL,FALSE);
|
||||
if (ch==CH_SHIFT_ESC || ch==CH_ESC)
|
||||
return;
|
||||
ShowDigit(ch);
|
||||
if (ch!=answer[i]) {
|
||||
Snd(0);
|
||||
"\nScore:%d\n",num;
|
||||
ShowPattern(answer);
|
||||
Beep;
|
||||
Beep;
|
||||
if (!PressAKey) goto dg_done;
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dg_done:
|
||||
"$$CL$$\n";
|
||||
}
|
||||
|
||||
Digits;
|
||||
@@ -0,0 +1,93 @@
|
||||
U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
//This routine is called by the window
|
||||
//mgr things would get corrupted
|
||||
//if the window mgr used it's own
|
||||
//heap, so we use the owning task's heap.
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
CDate ltdt=tS*CDATE_FREQ;
|
||||
//Doesn't have to be fixed width!!
|
||||
SPrintF(st,"%d=%h11T",ltdt,ltdt);
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *CurTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
CDate ltdt=GetCurTimeCDate;
|
||||
SPrintF(st,"%h0D %h0T",ltdt,ltdt);
|
||||
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.
|
||||
CDocEntry *doc_e;
|
||||
|
||||
// We don't want an update between
|
||||
// creating the CDocEntry and defining the
|
||||
// callback, so we turn-off preemption.
|
||||
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
|
||||
DocBottom(aux); //Ins at the bottom
|
||||
DocPutS(aux,"$$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,\" \"$$");
|
||||
// The TC flag is "has tag callback".
|
||||
|
||||
// Flags are explained here:
|
||||
// $LK,"::/SparrowOS/Doc/CtrlL.TXT.Z","FI:::/SparrowOS/Doc/CtrlL.TXT.Z"$
|
||||
// $LK,"::/SparrowOS/Doc/Dollar.TXT.Z","FI:::/SparrowOS/Doc/Dollar.TXT.Z"$
|
||||
// $LK,"Dollar Flags","MN:DOCEf1_AUX_STR"$
|
||||
// $LK,"ST_DOC_FLAGS","FF:::/SparrowOS/Adam/Doc/Doc.CPP.Z,ST_DOC_FLAGS"$
|
||||
|
||||
doc_e->tag_cb=&tSCB;
|
||||
DocPutS(aux,"$$FG$$");
|
||||
|
||||
//$BK,1$WARNING:$BK,0$ If you use the last_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.
|
||||
|
||||
DocPutS(cur,"$$FG,LTRED$$");
|
||||
doc_e=DocPutS(cur,"$$TX+TC,\" \"$$");
|
||||
doc_e->tag_cb=&CurTimeCB;
|
||||
DocPutS(cur,"$$FG$$");
|
||||
|
||||
Preempt(old_preempt);
|
||||
|
||||
//Send carriage return, new line, so
|
||||
//that the timer string is not part
|
||||
//of the next cmd on the cmd line.
|
||||
NewLine;
|
||||
}
|
||||
|
||||
|
||||
|
||||
U0 UndoIt()
|
||||
{
|
||||
//Clear-out entries without a +H hold flag.
|
||||
DocBottom(Fs->next_doc);
|
||||
DocPutS(Fs->next_doc,"$$CL$$");
|
||||
}
|
||||
|
||||
|
||||
DoIt;
|
||||
|
||||
// See $LK,"::/SparrowOS/Demo/Doc/CallBackAux2.CPP.Z","FI:::/SparrowOS/Demo/Doc/CallBackAux2.CPP.Z"$ for another way.
|
||||
@@ -0,0 +1,35 @@
|
||||
//See $LK,"::/SparrowOS/Demo/Doc/CallBack.CPP.Z","FI:::/SparrowOS/Demo/Doc/CallBack.CPP.Z"$ first.
|
||||
|
||||
U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
CDate ltdt=tS*CDATE_FREQ;
|
||||
SPrintF(st,"%d=%h11T",ltdt,ltdt);
|
||||
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;
|
||||
@@ -0,0 +1,38 @@
|
||||
U0 CursorMovementDemo()
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<100;i++) {
|
||||
"%03d ",i;
|
||||
"$$CM,-4,1$$";
|
||||
if (i%10==9)
|
||||
"$$CM,4,-10$$";
|
||||
}
|
||||
|
||||
//+LX is relative to left side.
|
||||
//See <CTRL-L> with cursor-movement for all the flags.
|
||||
//Check "Quote" to set-up a cmd for in quotes.
|
||||
"$$CM+LX,0,+10$$\n";
|
||||
}
|
||||
|
||||
CursorMovementDemo;
|
||||
|
||||
//The word-wrap Off and On cmds are
|
||||
//$$WW,0$$ and $$WW,1$$.
|
||||
|
||||
//You might need $LK,"DocMax","MN:DocMax"$() to adjust
|
||||
//the cmd line window buf size.
|
||||
//It counts cmds, not lines.
|
||||
|
||||
//The +H flag will hold-onto an entry
|
||||
//so it doesn't get pushed-out of the document.
|
||||
//This is useful for a $$WW+H,1$$ cmd.
|
||||
|
||||
//See $LK,"::/SparrowOS/Doc/Dollar.TXT.Z","FI:::/SparrowOS/Doc/Dollar.TXT.Z"$ for documentation on
|
||||
//all flags and cmds.
|
||||
|
||||
|
||||
//Note: the default page length is 66 lines
|
||||
//and branching back more than the page length
|
||||
//will rst the column to 1. So, set page
|
||||
//length to a large number if you want to
|
||||
//branch back a long distance.
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
$$DA is the data widget.
|
||||
-T flag is for var
|
||||
width fields with a terminator
|
||||
character.
|
||||
+RD refreshes the data.
|
||||
+UD updates the val when you edit it.
|
||||
+U32 means the val is 4 bytes.
|
||||
-I64 I64 is the default so we might
|
||||
want to turn-it-off. Strings
|
||||
use I64.
|
||||
,32 sets the tag string width.
|
||||
See $LK,"Data Tag Width","FA:::/SparrowOS/Adam/Doc/DocPlain.CPP.Z,DataTagWidth"$.
|
||||
-P Means it is a string var, basically.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
I32 i;
|
||||
U8 buf[8];
|
||||
|
||||
U0 UpdateGlblTask(I64)
|
||||
{
|
||||
while (TRUE) {
|
||||
i++;
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 DataDemo()
|
||||
{
|
||||
CDocEntry *doc_e;
|
||||
|
||||
//This is the command line document.
|
||||
CDoc *doc=DocCur;
|
||||
|
||||
//We do this to prevent access to
|
||||
//doc_e->data before it is set.
|
||||
Bool unlock=DocLock(doc);
|
||||
|
||||
//You might set the $LK,"DOCF_FORM","MN:DOCF_FORM"$ flag.
|
||||
// doc->flags|=DOCF_FORM
|
||||
//if you wish.
|
||||
|
||||
Spawn(&UpdateGlblTask,NULL,"Update Glbl",Fs);
|
||||
|
||||
"Enter editor overstrike mode\n"
|
||||
"and you can modify the val.\n"
|
||||
"However, changes happen immediately,\n"
|
||||
"so it's tricky.\n\n";
|
||||
//Use <CTRL-L> for the $$DA,$$ format.
|
||||
doc_e=DocPutS(doc,"$$DA-T+RD+UD-I64+U32,32,\"%12d\"$$\n");
|
||||
doc_e->data=&i;
|
||||
|
||||
StrCpy(buf,"Terry");
|
||||
doc_e=DocPutS(doc,"$$DA-P+RD+UD,7,\"Str:%s\"$$\n");
|
||||
doc_e->data=buf;
|
||||
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
DataDemo;
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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
|
||||
documentation.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
DefineLoad("COMPANY","Trivial Solutions");
|
||||
"Company: $$TX+D,\"\",\"COMPANY\"$$\n";
|
||||
|
||||
DefinePrintF("COMPANY_TIME","%T",GetCurTimeCDate);
|
||||
|
||||
#exe {
|
||||
StreamPrintF(
|
||||
"#define COMPANY_AGE %h56D\n",GetCurTimeCDate-A2CDate("8/1/2003"));
|
||||
};
|
||||
|
||||
|
||||
"Age : $$TX+D,\"\",\"COMPANY_AGE\"$$ years\n";
|
||||
"Time: $$TX+D,\"\",\"COMPANY_TIME\"$$\n";
|
||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
public U0 DocProfile(U8 *filename,I64 flags)
|
||||
{
|
||||
I64 i,*cmd_stats=CAlloc(sizeof(I64)*DOCT_NUM_TYPES),
|
||||
*flags_stats=CAlloc(sizeof(I64)*64),
|
||||
*type_flags_stats=CAlloc(sizeof(I64)*64);
|
||||
//Note, word wrap is determined by
|
||||
//doc->win_task when a $LK,"CDoc","MN:CDoc"$ is recalculated
|
||||
//use $LK,"DocRecalc","MN:DocRecalc"$().
|
||||
CDoc *doc=DocRead(filename,flags);
|
||||
|
||||
//doc->root which is equal to doc is the
|
||||
//header of the CQue and represents the end-of-file marker.
|
||||
CDocEntry *doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
cmd_stats[doc_e->type_u8]++;
|
||||
for (i=0;i<64;i++)
|
||||
if (Bt(&doc_e->flags1,i))
|
||||
flags_stats[i]++;
|
||||
for (i=16;i<32;i++)
|
||||
if (Bt(&doc_e->type,i))
|
||||
type_flags_stats[i]++;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
|
||||
"$$FG,PURPLE$$-------%s-------\n",filename;
|
||||
"$$FG,GREEN$$The lowest byte of the 32-bit 'doc_e->type', '$$FG,PURPLE$$doc_e->type.u8[0]$$FG,GREEN$$', is cmd and accessed with the union '$$FG,PURPLE$$doc_e->type_u8$$FG,GREEN$$'. "
|
||||
"See $$LK,\"CDocEntry\",\"MN:CDocEntry\"$$, "
|
||||
"$$LK,\"Doc Type Defines\",\"MN:DOCT_TEXT\"$$ and $$LK,\"Doc Type Codes\",\"FF:::/SparrowOS/Adam/Doc/Doc.CPP.Z,ST_DOC_CMDS\"$$.\n$$FG$$";
|
||||
for (i=0;i<DOCT_NUM_TYPES;i++)
|
||||
if (cmd_stats[i])
|
||||
"%4Z:%d\n",i,"ST_DOC_CMDS",cmd_stats[i];
|
||||
|
||||
"\n$$FG,GREEN$$'$$FG,PURPLE$$doc_e->type.u8[1]$$FG,GREEN$$' is the screen color attr of the entry. "
|
||||
"'$$FG,PURPLE$$doc_e->type.u16[1]$$FG,GREEN$$' is some flags for blinking and stuff. "
|
||||
"See $$LK,\"Doc Type Flag Defines\",\"MN:DOCET_BLINK\"$$.\n$$FG$$";
|
||||
|
||||
for (i=16;i<32;i++)
|
||||
if (type_flags_stats[i])
|
||||
"%4d:%d\n",i,type_flags_stats[i];
|
||||
|
||||
"$$FG,GREEN$$\n'$$FG,PURPLE$$doc_e->flags1$$FG,GREEN$$' is 64-bit. "
|
||||
"See $$LK,\"Doc Flag Defines\",\"MN:DOCEf1_AUX_STR\"$$ and $$LK,\"Doc Flag Codes\",\"FF:::/SparrowOS/Adam/Doc/Doc.CPP.Z,ST_DOC_FLAGS\"$$.\n$$FG$$";
|
||||
for (i=0;i<64;i++)
|
||||
if (flags_stats[i])
|
||||
"%4Z:%d\n",i,"ST_DOC_FLAGS",flags_stats[i];
|
||||
|
||||
Free(cmd_stats);
|
||||
Free(flags_stats);
|
||||
PressAKey;
|
||||
NewLine;
|
||||
}
|
||||
|
||||
|
||||
//See $LK,"TipOfDay","MN:TipOfDay"$.
|
||||
|
||||
//Note: Not all $LK,"CDocEntry","MN:CDocEntry"$'s are full-sized nodes.
|
||||
//Some are $LK,"MAlloc","MN:MAlloc"$ed with a smaller size to save
|
||||
//mem. They all have at least the size $LK,"CDocEntryBase","MN:CDocEntryBase"$.
|
||||
|
||||
//Note: $LK,"CDocEntry","MN:CDocEntry"$'s should be allocated from the
|
||||
//heap of the owning task, doc->mem_task.
|
||||
|
||||
//The flag arrays $LK,"doc_tag_types","MN:doc_tag_types"$, $LK,"doc_form_types","MN:doc_form_types"$, etc
|
||||
//are useful.
|
||||
|
||||
DocProfile("::/SparrowOS/Doc/ChangeLog.TXT.Z",0);
|
||||
DocProfile("::/SparrowOS/Doc/ChangeLog.TXT.Z",DOCF_PLAIN_TEXT);
|
||||
@@ -0,0 +1,44 @@
|
||||
class DStruct
|
||||
{
|
||||
//Use <CTRL-L> and select "Data" to generate the fmtstrs
|
||||
|
||||
//The number is the field from after the ':' to the end.
|
||||
// See $LK,"Data Tag Width","FA:::/SparrowOS/Adam/Doc/DocPlain.CPP.Z,DataTagWidth"$.
|
||||
|
||||
F64 num1 fmtstr "$$DA-T,32,\"F64 1:%12.8f\"$$\n";
|
||||
F64 num2 fmtstr "$$DA-T,32,\"F64 2:%12e\"$$\n";
|
||||
I64 num3 fmtstr "$$DA-T,32,\"I64 1:0x%016X\"$$\n";
|
||||
I64 num4 fmtstr "$$DA-T,32,\"I64 2:%12d\"$$\n";
|
||||
U8 name[32] fmtstr "$$DA-P,31,\"Name :%s\"$$\n";
|
||||
CDate datetime fmtstr "$$DA-T,32,\"Date :%8D\"$$\n";
|
||||
};
|
||||
|
||||
U0 FormDemo()
|
||||
{
|
||||
DStruct gtl;
|
||||
CDate ltdt;
|
||||
|
||||
gtl.num1=12.3e-4; //Set defaults
|
||||
gtl.num2=4.5e3;
|
||||
gtl.num3=0x1234;
|
||||
gtl.num4=-567;
|
||||
StrCpy(>l.name,"John");
|
||||
ltdt=GetCurTimeCDate;
|
||||
gtl.datetime=ltdt;
|
||||
if (DocFormDo(>l,"DStruct")) {
|
||||
"#1=%e\n",gtl.num1;
|
||||
"#2=%e\n",gtl.num2;
|
||||
"#3=%d\n",gtl.num3;
|
||||
"#4=%d\n",gtl.num4;
|
||||
"Name=%s\n",gtl.name;
|
||||
"Date=%D\n",gtl.datetime;
|
||||
} else
|
||||
"Cancel\n";
|
||||
|
||||
"\n\nClassRep Example\n";
|
||||
ClassRep("DStruct",>l);
|
||||
|
||||
//See also $LK,"ClassRepD","MN:ClassRepD"$().
|
||||
}
|
||||
|
||||
FormDemo;
|
||||
@@ -0,0 +1,76 @@
|
||||
//This example shows buttons. Buttons return a menu val
|
||||
//unless you rig them to send macros. Menu entries are
|
||||
//about the same as buttons, but don't have a border.
|
||||
|
||||
|
||||
I64 PopUpFreq()
|
||||
{ //See also $LK,"PopUpRangeI64","MN:PopUpRangeI64"$()
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
DocPutS(doc,"$$TX+CX,\"Set Freq\"$$\n" //Centered text
|
||||
"$$CM+LX,2,4$$$$BT,\"100 Hz\",100$$"
|
||||
"$$CM+LX,18,0$$$$BT,\"200 Hz\",200$$"
|
||||
"$$CM+LX,2,4$$$$BT,\"400 Hz\",400$$"
|
||||
"$$CM+LX,18,0$$$$BT,\"800 Hz\",800$$\n");
|
||||
i=PopUpMenu(doc);
|
||||
if (i<0) i=0; // <SHIFT-ESC>
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
#define MU_NOTHING 0
|
||||
#define MU_SET_FREQ 1
|
||||
#define MU_SND_ON 2
|
||||
#define MU_SND_OFF 3
|
||||
|
||||
U0 MenuButton()
|
||||
{
|
||||
Bool done=FALSE;
|
||||
I64 i,j=0,freq=100;
|
||||
I64 old_flags=DocCur->flags;
|
||||
//This allows keyboard navigation to skip nonselectible entries.
|
||||
DocCur->flags|=DOCF_FORM;
|
||||
do {
|
||||
DocClear;
|
||||
//Use <CTRL-L> to generate cursor movement expressions and check "Quote".
|
||||
"$$CM+CX-RE,-4$$Menu Demo\n\n";
|
||||
"$$LM,8$$"; //Set left margin
|
||||
//These are buttons that return a val from a menu selection.
|
||||
if (!j)
|
||||
"\n$$BT,\"Snd On\",MU_SND_ON$$\n\n\n";
|
||||
else
|
||||
"\n$$BT,\"Snd Off\",MU_SND_OFF$$\n\n\n";
|
||||
"\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);
|
||||
DocBottom;
|
||||
switch (i) {
|
||||
case MU_NOTHING:
|
||||
break;
|
||||
case MU_SND_ON:
|
||||
j=freq;
|
||||
Snd(j);
|
||||
break;
|
||||
case MU_SND_OFF:
|
||||
j=0;
|
||||
Snd(j);
|
||||
break;
|
||||
case MU_SET_FREQ:
|
||||
freq=PopUpFreq;
|
||||
if (j) {
|
||||
j=freq;
|
||||
Snd(j);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
done=TRUE;
|
||||
}
|
||||
} while (!done);
|
||||
DocCur->flags=DocCur->flags&~DOCF_FORM |
|
||||
old_flags & DOCF_FORM;
|
||||
DocClear;
|
||||
Snd(0);
|
||||
}
|
||||
|
||||
MenuButton;
|
||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
"\nSuper : 3$$SY,-3$$2$$SY,0$$=9\n\n"
|
||||
"Sub : H$$SY,3$$2$$SY,0$$O\n\n"
|
||||
"Color : $$FG,RED$$Test$$FG$$\n\n"
|
||||
"Blink : $$BK,1$$Test$$BK,0$$\n\n"
|
||||
"Invert : $$IV,1$$Test$$IV,0$$\n\n"
|
||||
"UnderLine: $$UL,1$$Test$$UL,0$$\n\n"
|
||||
"Link : $$LK,\"Genesis,1:1\",\"BF:Genesis,1:1\"$$\n\n\n"
|
||||
|
||||
|
||||
"Button : $$BT-X,\"OKAY\",1$$\n\n\n\n";
|
||||
|
||||
//You can do it this way if you like.
|
||||
"\nSuper : 3$SY,-3$2$SY,0$=9\n\n"
|
||||
"Sub : H$SY,3$2$SY,0$O\n\n"
|
||||
//Can't see color because of syntax highlighting. Press <CTRL-T>
|
||||
"Color : $FG,4$Test$FG$\n\n"
|
||||
"Blink : $BK,1$Test$BK,0$\n\n"
|
||||
"Invert : $IV,1$Test$IV,0$\n\n"
|
||||
"UnderLine: $UL,1$Test$UL,0$\n\n"
|
||||
//<CTRL-SHIFT-T> on this link to toggle individual commands.
|
||||
"Link : $LK,"Genesis,1:1","BF:Genesis,1:1"$\n\n\n"
|
||||
|
||||
|
||||
"Button : $BT,"OKAY",1$\n\n\n\n";
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This uses DocPutS/DocPrintF because updates
|
||||
to within a tree while a tree is collapsed get
|
||||
messed-up if "live"(like using ordinary PrintF/PutS.)
|
||||
The insert point is confused by hiding of
|
||||
data in collapsed trees. Therefore, the window main
|
||||
Doc is taken off-line by disabling preemption so there
|
||||
are no screen updates until all data has been inserted.
|
||||
|
||||
There is a special Doc function which is also
|
||||
available to take an Doc off-line. See $LK,"DocInsSafe","MN:DocInsSafe"$.
|
||||
For this example, however, I wanted to use DocPrintF
|
||||
and disabled Preemption myself.
|
||||
*/
|
||||
|
||||
#include "/SparrowOS/Demo/Shared/TreeDemoJoin"
|
||||
|
||||
U0 TreeDemo()
|
||||
{
|
||||
I64 fuf_flags=0;
|
||||
CDoc *doc=DocNew;
|
||||
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
DocPutS(doc,"$$TR-C+AL,\"\"$$\n");
|
||||
DocPutS(doc,"$$ID,+2$$");
|
||||
TreeSub(doc,FilesFind("/SparrowOS/*",fuf_flags));
|
||||
DocPutS(doc,"$$ID,-2$$");
|
||||
DocInsDoc(DocCur,doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
TreeDemo;
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
This scans the sym table and checks
|
||||
each $LK,"HTT_DEFINE_STR","MN:HTT_DEFINE_STR"$ entry to see if
|
||||
it only occurs once in files.
|
||||
|
||||
It's a brute force solution, but
|
||||
gets the job done... slowly.
|
||||
|
||||
$LK,"Grep","MN:Grep"$() returns a count of matches.
|
||||
|
||||
$LK,"FileOcc","MN:FileOcc"$() is $LK,"Grep","MN:Grep"$() with
|
||||
output $LK,"Silent","MN:Silent"$().
|
||||
|
||||
*/
|
||||
|
||||
U0 UnusedDefineScan()
|
||||
{
|
||||
CDoc *old_doc=DocCur,*doc;
|
||||
I64 cnt=0;
|
||||
CHashTable *tempht;
|
||||
CHash *temph;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
Bool old_silent=IsSilent;
|
||||
|
||||
//Technically, we might want to
|
||||
//turn-off preemption in case the
|
||||
//table was modified.
|
||||
|
||||
try {
|
||||
tempht=Fs->hash_table;
|
||||
while (tempht) {
|
||||
temph=tempht->next_added;
|
||||
while (temph!=tempht) {
|
||||
if (temph->type&HTT_DEFINE_STR)
|
||||
cnt++;
|
||||
temph=temph->next_added;
|
||||
}
|
||||
tempht=tempht->next;
|
||||
}
|
||||
|
||||
progress1=0;
|
||||
progress1_max=cnt;
|
||||
StrCpy(progress1_desc,"Define Scan");
|
||||
|
||||
tempht=Fs->hash_table;
|
||||
while (tempht) {
|
||||
temph=tempht->next_added;
|
||||
while (temph!=tempht) {
|
||||
if (temph->type&HTT_DEFINE_STR) {
|
||||
progress1++;
|
||||
if (FileOcc(temph->str,"/SparrowOS/"TEXT_FILE_MASK,"+l-i")==1) {
|
||||
doc=DocNew;
|
||||
DocQueRem(old_doc);
|
||||
DocQueIns(doc,Fs->last_doc);
|
||||
Grep(temph->str,"/SparrowOS/"TEXT_FILE_MASK,"+l-i");
|
||||
DocQueRem(doc);
|
||||
DocQueIns(old_doc,Fs->last_doc);
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_LINK) {
|
||||
NewLine;
|
||||
"" temph->str;
|
||||
doc_e2=DocEntryCopy(doc,doc_e);
|
||||
DocIns(old_doc,doc_e2);
|
||||
NewLine;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
temph=temph->next_added;
|
||||
}
|
||||
tempht=tempht->next;
|
||||
}
|
||||
} catch
|
||||
CatchAll;
|
||||
|
||||
Silent(old_silent);
|
||||
NewLine;
|
||||
ProgressBarsRst;
|
||||
}
|
||||
|
||||
UnusedDefineScan;
|
||||
@@ -0,0 +1,68 @@
|
||||
#define DB_FILENAME "HOME/DataBaseDemo.BIN"
|
||||
#define DB_MAX_ACCT 100
|
||||
#define DB_ACCT_BLKS 1
|
||||
|
||||
class Acct
|
||||
{ //Use <CTRL-L> to help generate fmtstrs.
|
||||
U8 name[32] fmtstr "$$DA-P,32,\"Name:%s\"$$\n";
|
||||
U8 addr[64] fmtstr "$$DA-P,64,\"Addr:%s\"$$\n";
|
||||
U8 pad[DB_ACCT_BLKS*BLK_SIZE-64-32];
|
||||
};
|
||||
|
||||
|
||||
U0 InitDatabase()
|
||||
{
|
||||
CFile *f;
|
||||
//Write new contiguous file
|
||||
f=FOpen(DB_FILENAME,"w",DB_MAX_ACCT*DB_ACCT_BLKS);
|
||||
FClose(f);
|
||||
}
|
||||
|
||||
|
||||
U0 WriteAcct()
|
||||
{
|
||||
CFile *f;
|
||||
Acct a;
|
||||
I64 acctnum;
|
||||
|
||||
acctnum=PmtI64("Acct #",-1);
|
||||
if (0<=acctnum<DB_MAX_ACCT) {
|
||||
MemSet(&a,0,BLK_SIZE);
|
||||
if (DocFormDo(&a,"Acct")) {
|
||||
f=FOpen(DB_FILENAME,"w+");
|
||||
FWBlks(f,&a,acctnum*DB_ACCT_BLKS,DB_ACCT_BLKS);
|
||||
FClose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ReadAcct()
|
||||
{
|
||||
CFile *f;
|
||||
Acct a;
|
||||
I64 acctnum;
|
||||
|
||||
acctnum=PmtI64("Acct #",-1);
|
||||
if (0<=acctnum<DB_MAX_ACCT) {
|
||||
f=FOpen(DB_FILENAME,"r");
|
||||
FRBlks(f,&a,acctnum*DB_ACCT_BLKS,DB_ACCT_BLKS);
|
||||
FClose(f);
|
||||
ClassRep("Acct",&a);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DatabaseDemo()
|
||||
{
|
||||
I64 ch;
|
||||
if (!FileFind(DB_FILENAME))
|
||||
InitDatabase;
|
||||
do {
|
||||
"$$FG,GREEN$$R$$FG$$ead acct, $$FG,GREEN$$W$$FG$$rite acct or $$FG,GREEN$$<SHIFT-ESC>$$FG$$:";
|
||||
ch=ToUpper(GetChar);
|
||||
NewLine;
|
||||
if (ch=='R') ReadAcct;
|
||||
if (ch=='W') WriteAcct;
|
||||
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
|
||||
}
|
||||
|
||||
DatabaseDemo;
|
||||
@@ -0,0 +1,27 @@
|
||||
/* There is no FPrintF type function and no
|
||||
way to grow files. Therefore, use mem to
|
||||
hold the file until you are done. The $LK,"CDoc","MN:CDoc"$
|
||||
framework is convenient for this.
|
||||
*/
|
||||
|
||||
#include "/SparrowOS/Demo/Shared/TreeDemoJoin"
|
||||
|
||||
U0 FPrintFDemo(U8 *output_filename=NULL)
|
||||
{
|
||||
I64 fuf_flags=0;
|
||||
CDoc *doc=DocNew;
|
||||
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
DocPutS(doc,"$$TR-C+AL,\"\"$$\n");
|
||||
DocPutS(doc,"$$ID,+2$$");
|
||||
TreeSub(doc,FilesFind("/SparrowOS/*",fuf_flags));
|
||||
DocPutS(doc,"$$ID,-2$$");
|
||||
DocRecalc(doc);
|
||||
if (output_filename) {
|
||||
StrCpy(doc->filename.name,output_filename);
|
||||
DocWrite(doc,FALSE);
|
||||
} else
|
||||
DocWrite(doc,TRUE);
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
FPrintFDemo;
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
$WW,1$This gets a list of files, flattens the list from a tree into an array and sorts them by cluster num, to speed-up access time by avoiding moving the disk head around.
|
||||
$WW,0$*/
|
||||
|
||||
U0 Main()
|
||||
{
|
||||
I64 i,cnt=0;
|
||||
CDirEntry *tempm=FilesFind("::/SparrowOS/*",1<<FUf_RECURSE),
|
||||
**a=FilesOrder(tempm,&cnt);
|
||||
for (i=0;i<cnt;i++) {
|
||||
"%08X %s\n",a[i]->cluster,a[i]->full_name;
|
||||
CDirEntryDel(a[i]);
|
||||
}
|
||||
Free(a);
|
||||
}
|
||||
|
||||
Main;
|
||||
@@ -0,0 +1,41 @@
|
||||
U0 RawAccess(I64 drv_let=0)
|
||||
{
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
I64 blk,old_offset,old_size;
|
||||
U8 *buf=MAlloc(BLK_SIZE);
|
||||
|
||||
PrtRep;
|
||||
PressAKey;
|
||||
|
||||
ClassRep("CPrt",p);
|
||||
PressAKey;
|
||||
|
||||
ClassRep("CBlkDev",bdev);
|
||||
PressAKey;
|
||||
|
||||
//Temporarily change partition range to full device.
|
||||
//Normally, you are limited to just your partition.
|
||||
//This is obviously $BK,1$dangerous$BK,0$!
|
||||
old_offset=p->offset;
|
||||
old_size =p->size;
|
||||
p->offset=bdev->min_blk;
|
||||
p->size=bdev->max_blk-bdev->min_blk+1;
|
||||
|
||||
try {
|
||||
blk=PmtI64("Blk to Read: ",old_offset,bdev->min_blk,bdev->max_blk);
|
||||
RBlks(p,buf,blk,1);
|
||||
D(buf,BLK_SIZE);
|
||||
} catch
|
||||
CatchAll;
|
||||
|
||||
p->offset=old_offset;
|
||||
p->size =old_size;
|
||||
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
RawAccess;
|
||||
|
||||
//See $LK,"RBlks","MN:RBlks"$(), $LK,"WBlks","MN:WBlks"$(), $LK,"PrtLock","MN:PrtLock"$(), $LK,"PrtUnlock","MN:PrtUnlock"$()
|
||||
//$LK,"DBlk","MN:DBlk"$(), $LK,"DCluster","MN:DCluster"$(), $LK,"BlkDevLock","MN:BlkDevLock"$() and $LK,"BlkDevUnlock","MN:BlkDevUnlock"$().
|
||||
@@ -0,0 +1,16 @@
|
||||
U0 UnusedSpaceRep()
|
||||
{
|
||||
I64 i;
|
||||
CPrt *p;
|
||||
for (i=0;i<26;i++) {
|
||||
try {
|
||||
p=Drv2Prt(i+'A');
|
||||
if (p->type==PT_FAT32 || p->type==PT_NATIVE)
|
||||
"%C: %7.3f%% Free\n",
|
||||
Prt2Drv(p),UnusedDrvSpace(Prt2Drv(p))*100.0/(p->size*BLK_SIZE);
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
UnusedSpaceRep;
|
||||
@@ -0,0 +1,71 @@
|
||||
//$BK,1$WARNING:$BK,0$ Don't return out of a catch{}. This
|
||||
//might get fixed.
|
||||
|
||||
//You can use $LK,"CatchAll","MN:CatchAll"$() in a catch statement
|
||||
//and it will report args.
|
||||
|
||||
#define EXCEPT_1 1
|
||||
#define EXCEPT_2 2
|
||||
#define EXCEPT_3 3
|
||||
#define EXCEPT_4 4
|
||||
|
||||
U0 Show()
|
||||
{
|
||||
I64 i;
|
||||
"Fs->except_argc=%X\n",Fs->except_argc;
|
||||
for (i=0;i<Fs->except_argc;i++)
|
||||
"Fs->except_argv[%d]=%08X\n",i,Fs->except_argv[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Bool Pmt(I64 i)
|
||||
{
|
||||
"%d ",i;
|
||||
return YorN;
|
||||
}
|
||||
|
||||
U0 D1()
|
||||
{
|
||||
"D1\n";
|
||||
if (Pmt(1)) throw(EXCEPT_1);
|
||||
if (Pmt(2)) throw(EXCEPT_2,33,55,66);
|
||||
if (Pmt(5)) throw;
|
||||
}
|
||||
|
||||
U0 D2()
|
||||
{
|
||||
"D2\n";
|
||||
try {
|
||||
D1;
|
||||
if (Pmt(4)) throw(EXCEPT_4);
|
||||
} catch {
|
||||
"D2 handler\n";
|
||||
Show;
|
||||
if (Fs->except_argc>0) {
|
||||
if (Fs->except_argv[0]==EXCEPT_1) {
|
||||
"Caught in D2\n";
|
||||
Fs->catch_except=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 Demo()
|
||||
{
|
||||
try {
|
||||
D2;
|
||||
if (Pmt(3)) throw;
|
||||
} catch {
|
||||
"Demo handler\n";
|
||||
Show;
|
||||
"Ignore Except";
|
||||
if (YorN)
|
||||
Fs->ignore_except=TRUE;
|
||||
else
|
||||
Fs->catch_except=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Demo;
|
||||
@@ -0,0 +1,36 @@
|
||||
U0 Install()
|
||||
{
|
||||
gr_font[8*255+0]=0b00111100;
|
||||
gr_font[8*255+1]=0b01000010;
|
||||
gr_font[8*255+2]=0b10100101;
|
||||
gr_font[8*255+3]=0b10000001;
|
||||
gr_font[8*255+4]=0b11000011;
|
||||
gr_font[8*255+5]=0b10111101;
|
||||
gr_font[8*255+6]=0b01000010;
|
||||
gr_font[8*255+7]=0b00111100;
|
||||
}
|
||||
|
||||
Install;
|
||||
|
||||
"Face:ÿ\n";
|
||||
|
||||
//Chars 128-255 are treated as letters
|
||||
//by the compiler and everything else.
|
||||
//Enter them by holding ALT and
|
||||
//pressing a 3 digit decimal number or
|
||||
//press <CTRL-ALT-A>.
|
||||
|
||||
U0 SrcExample()
|
||||
{
|
||||
I64 fÿÿ=12345;
|
||||
"fÿÿ=%d\n",fÿÿ;
|
||||
}
|
||||
|
||||
SrcExample;
|
||||
//See $LK,"::/SparrowOS/Demo/ScreenCodes.CPP.Z","FI:::/SparrowOS/Demo/ScreenCodes.CPP.Z"$
|
||||
//$LK,"::/SparrowOS/Demo/Graphics/CharGraphics.CPP.Z","FI:::/SparrowOS/Demo/Graphics/CharGraphics.CPP.Z"$,
|
||||
//and $LK,"::/SparrowOS/Demo/Graphics/FontEd.CPP.Z","FI:::/SparrowOS/Demo/Graphics/FontEd.CPP.Z"$.
|
||||
|
||||
//See $LK,"alpha_bitmap","MN:alpha_bitmap"$, and
|
||||
//$LK,"alpha_numeric_bitmap","MN:alpha_numeric_bitmap"$.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -0,0 +1,124 @@
|
||||
//Practice tracing circles
|
||||
|
||||
AcctRegSetDftEntry("SparrowOS/CircleTrace","F64 best_score=999;\n");
|
||||
AcctRegExecuteBranch("SparrowOS/CircleTrace");
|
||||
|
||||
I64 cx,cy;
|
||||
F64 avg_error=0,elapsed_time=0,total_error=0,score=999;
|
||||
|
||||
U0 SongTask(I64)
|
||||
{
|
||||
Fs->task_end_cb=&SndTaskEndCB;
|
||||
MusicSettingsRst;
|
||||
while (TRUE)
|
||||
Play("hEDCARCDECR");
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *)
|
||||
{
|
||||
U8 buf[128];
|
||||
SPrintF(buf,"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f",avg_error,elapsed_time,score,best_score);
|
||||
PlotWinStr(task,buf,BLACK<<4+WHITE,0,0);
|
||||
}
|
||||
|
||||
#define CIRCLE_RADIUS 100
|
||||
#define CIRCUMFERENCE (2*ã*CIRCLE_RADIUS)
|
||||
|
||||
Bool CTPlot(CDC *dc,I64 x,I64 y,I64)
|
||||
{
|
||||
F64 rad=Sqrt(Sqr(x-cx)+Sqr(y-cy));
|
||||
GrPlot(dc,x,y);
|
||||
total_error+=Abs(rad-CIRCLE_RADIUS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
U0 CircleTrace()
|
||||
{
|
||||
I64 msg_code,p1,p2,x1,y1;
|
||||
F64 rad,t0,total_distance;
|
||||
CDC *dc=DCAlias;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
|
||||
Fs->song_task=Spawn(&SongTask,NULL,"Song",Fs);
|
||||
WordStat;
|
||||
|
||||
cx=Fs->win_pixel_width/2;
|
||||
cy=Fs->win_pixel_height/2;
|
||||
|
||||
Fs->win_inhibit=WIF_ALL-WIF_BORDER;
|
||||
DocCursor;
|
||||
DocClear;
|
||||
Fs->draw_it=&DrawIt;
|
||||
|
||||
DCFill;
|
||||
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
|
||||
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
|
||||
do {
|
||||
msg_code=GetMsg(&p1,&p2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_UP:
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
DCFill;
|
||||
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
|
||||
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
|
||||
dc->color=ROP_XOR+RED^COLOR_TRANSPARENT;
|
||||
t0=tP;
|
||||
total_distance=0.001;
|
||||
total_error=0;
|
||||
x1=p1; y1=p2;
|
||||
do {
|
||||
msg_code=ScanMsg(&p1,&p2,
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_L_UP:
|
||||
break;
|
||||
case MSG_IP_MOVE:
|
||||
if (x1!=p1 || y1!=p2) {
|
||||
total_distance+=Sqrt(Sqr(x1-p1)+Sqr(y1-p2));
|
||||
Line(dc,x1,y1,0,p1,p2,0,&CTPlot);
|
||||
x1=p1;y1=p2;
|
||||
//undo overlapping pixels on segments
|
||||
GrPlot(dc,x1,y1);
|
||||
rad=Sqrt(Sqr(x1-cx)+Sqr(y1-cy));
|
||||
total_error-=Abs(rad-CIRCLE_RADIUS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
elapsed_time=tP-t0;
|
||||
avg_error=total_error/total_distance;
|
||||
score=elapsed_time*avg_error;
|
||||
|
||||
//This $LK,"Sleep","MN:Sleep"$()s until the next time the
|
||||
//window mgr task runs. The
|
||||
//window mgr calls the UpdateWin() routine
|
||||
//and places msgs in the que, so there's
|
||||
//no need to do anything until the window mgr runs.
|
||||
WinMgrSync;
|
||||
|
||||
} while (msg_code!=MSG_IP_L_UP);
|
||||
music_mute=TRUE; Sleep(200);
|
||||
if (total_distance>0.95*CIRCUMFERENCE) {
|
||||
if (score<best_score) {
|
||||
Snd(2000);Sleep(50);Snd(0);Sleep(50);
|
||||
Snd(2000);Sleep(50);Snd(0);Sleep(50);
|
||||
Snd(2000);Sleep(50);
|
||||
best_score=score;
|
||||
} else {
|
||||
Snd(500);Sleep(50);
|
||||
}
|
||||
} else {
|
||||
Snd(100);Sleep(1000);
|
||||
}
|
||||
Snd(0); Sleep(200); music_mute=FALSE;
|
||||
break;
|
||||
}
|
||||
} while (msg_code!=MSG_KEY_DOWN || p1!=CH_SHIFT_ESC && p1!=CH_ESC);
|
||||
SettingsPop;
|
||||
DCFill;
|
||||
DCDel(dc);
|
||||
AcctRegWriteBranch("SparrowOS/CircleTrace","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
CircleTrace; //Execute when #included
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,509 @@
|
||||
//Set snap to 4 and width to 4
|
||||
//if you edit this map.
|
||||
|
||||
//Don't forget to change the
|
||||
//starting pos.
|
||||
$BG,0$
|
||||
|
||||
$SP,"map",1$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"hero",2$
|
||||
|
||||
|
||||
|
||||
$SP,"hero_attack",3$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"template",4$ //This is a template you can copy and use to make a tile.
|
||||
//WHITE is the transparent color.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"tree",5$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"path",6$
|
||||
|
||||
|
||||
|
||||
$SP,"water1",7$
|
||||
|
||||
|
||||
|
||||
$SP,"water2",8$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"goblin",9$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"wall1",10$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"wall2",11$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$BG$
|
||||
|
||||
//These are indexed by color #.
|
||||
//See $LK,"COLORS","MN:RED"$.
|
||||
|
||||
U8 *tiles1[16]=
|
||||
{NULL,$IB,"<7>",7$ ,$IB,"<5>",5$ ,NULL,
|
||||
$IB,"<6>",6$ ,NULL,NULL,NULL,
|
||||
NULL,NULL,NULL,NULL,
|
||||
NULL,NULL,NULL,NULL};
|
||||
|
||||
U8 *tiles2[16]=
|
||||
{NULL,$IB,"<8>",8$ ,$IB,"<5>",5$ ,NULL,
|
||||
$IB,"<6>",6$ ,NULL,NULL,NULL,
|
||||
NULL,NULL,NULL,NULL,
|
||||
NULL,NULL,NULL,NULL};
|
||||
|
||||
|
||||
|
||||
#define SCREEN_SCALE 24
|
||||
#define SCREEN_WIDTH 24
|
||||
#define SCREEN_HEIGHT 24
|
||||
I64 screen_x,screen_y;
|
||||
|
||||
#define MAP_SCALE 4
|
||||
I64 map_width,map_height;
|
||||
U8 *map=NULL;
|
||||
|
||||
I64 man_x,man_y,man_dx,man_dy;
|
||||
Bool man_attack;
|
||||
F64 man_attack_t0;
|
||||
|
||||
#define NUM_MONSTERS 16
|
||||
class Monster
|
||||
{
|
||||
I64 x,y,dx,dy;
|
||||
Bool dead,pad[7];
|
||||
} monsters[NUM_MONSTERS];
|
||||
|
||||
#define LOS_SCALE 4
|
||||
|
||||
Bool LOSPlot(U8 *,I64 x,I64 y,I64)
|
||||
{
|
||||
if (!map[(y/LOS_SCALE)*map_width+(x/LOS_SCALE)])
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
{ //Line of sight
|
||||
return Line(NULL,x1*LOS_SCALE+LOS_SCALE/2,y1*LOS_SCALE+LOS_SCALE/2,0,
|
||||
x2*LOS_SCALE+LOS_SCALE/2,y2*LOS_SCALE+LOS_SCALE/2,0,&LOSPlot);
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
CDC *dc_t=DCAlias(gr_dc,task);
|
||||
I64 i,x,y,xx,yy,x1,y1,z1,color;
|
||||
CD3I32 poly[4];
|
||||
U8 **_tiles;
|
||||
|
||||
task->text_attr=BLACK<<4;
|
||||
if (Blink(5,tP(task)))
|
||||
_tiles=tiles1;
|
||||
else
|
||||
_tiles=tiles2;
|
||||
|
||||
GrRotXEqu(dc_t->r,60*2*ã/360);
|
||||
GrRotZEqu(dc_t->r,15*2*ã/360);
|
||||
GrSetRotMat(dc_t,dc_t->r);
|
||||
dc_t->x=task->win_pixel_width/2;
|
||||
dc_t->y=task->win_pixel_height/2;
|
||||
dc_t->flags|=DCF_TRANSFORMATION;
|
||||
|
||||
//You could make it much more efficient
|
||||
//if you did it like $LK,"::/SparrowOS/Demo/GameStarters/BigGuns.CPP.Z","FI:::/SparrowOS/Demo/GameStarters/BigGuns.CPP.Z"$
|
||||
//with a $LK,"CDC","MN:CDC"$.
|
||||
|
||||
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
|
||||
yy=y+screen_y;
|
||||
if (0<=yy<map_height)
|
||||
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
|
||||
xx=x+screen_x;
|
||||
if (0<=xx<map_width) {
|
||||
if ((color=map[yy*map_width+xx]) &&
|
||||
LOS(xx,yy,man_x,man_y)) {
|
||||
if (_tiles[color]) {
|
||||
x1=x*SCREEN_SCALE;
|
||||
y1=y*SCREEN_SCALE;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
CSpritePlot3(dc,x1,y1,z1,_tiles[color]);
|
||||
} else { //If no tile defined, do solid color.
|
||||
poly[0].x=x*SCREEN_SCALE;
|
||||
poly[0].y=y*SCREEN_SCALE;
|
||||
poly[0].z=0;
|
||||
poly[1].x=(x+1)*SCREEN_SCALE-1;
|
||||
poly[1].y=y*SCREEN_SCALE;
|
||||
poly[1].z=0;
|
||||
poly[2].x=(x+1)*SCREEN_SCALE;
|
||||
poly[2].y=(y+1)*SCREEN_SCALE-1;
|
||||
poly[2].z=0;
|
||||
poly[3].x=x*SCREEN_SCALE-1;
|
||||
poly[3].y=(y+1)*SCREEN_SCALE-1;
|
||||
poly[3].z=0;
|
||||
dc_t->color=color;
|
||||
GrFillPoly3(dc_t,4,poly);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc_t->color=LTGRAY;
|
||||
for (x=-SCREEN_WIDTH/2;x<=SCREEN_WIDTH/2;x++)
|
||||
GrLine3(dc_t,x*SCREEN_SCALE,-SCREEN_HEIGHT/2*SCREEN_SCALE,0,x*SCREEN_SCALE,SCREEN_HEIGHT/2*SCREEN_SCALE-1,0);
|
||||
for (y=-SCREEN_HEIGHT/2;y<=SCREEN_HEIGHT/2;y++)
|
||||
GrLine3(dc_t,-SCREEN_WIDTH/2*SCREEN_SCALE,y*SCREEN_SCALE,0,SCREEN_WIDTH/2*SCREEN_SCALE,y*SCREEN_SCALE-1,0);
|
||||
|
||||
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
|
||||
yy=y+screen_y;
|
||||
if (0<=yy<map_height)
|
||||
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
|
||||
xx=x+screen_x;
|
||||
if (0<=xx<map_width) {
|
||||
if (!map[yy*map_width+xx]) {
|
||||
if (yy+1<map_height && LOS(xx,yy+1,man_x,man_y)) {
|
||||
x1=x*SCREEN_SCALE;
|
||||
y1=y*SCREEN_SCALE;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
CSpritePlot3(dc,x1,y1,z1,$IB,"<10>",10$);
|
||||
}
|
||||
if (xx+1<map_width && LOS(xx+1,yy,man_x,man_y)) {
|
||||
x1=x*SCREEN_SCALE;
|
||||
y1=y*SCREEN_SCALE;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
CSpritePlot3(dc,x1,y1,z1,$IB,"<11>",11$);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0;i<NUM_MONSTERS;i++)
|
||||
if (!monsters[i].dead && LOS(monsters[i].x,monsters[i].y,man_x,man_y)) {
|
||||
x1=(monsters[i].x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
y1=(monsters[i].y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
if (monsters[i].dx<0) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,x1,y1,x1,y1+1);
|
||||
} else
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
CSpritePlot3(dc,x1,y1,z1,$IB,"<9>",9$);
|
||||
}
|
||||
|
||||
x1=(man_x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
y1=(man_y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
if (tP(task)-man_attack_t0<0.2) {
|
||||
x1+=Tri(tP(task)-man_attack_t0,0.2)*SCREEN_SCALE*man_dx;
|
||||
y1+=Tri(tP(task)-man_attack_t0,0.2)*SCREEN_SCALE*man_dy;
|
||||
}
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
if (man_dx<0) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,x1,y1,x1,y1+1);
|
||||
} else
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
|
||||
if (tP(task)-man_attack_t0<0.2)
|
||||
CSpritePlot3(dc,x1,y1,z1,$IB,"<3>",3$);
|
||||
else
|
||||
CSpritePlot3(dc,x1,y1,z1,$IB,"<2>",2$);
|
||||
|
||||
DCDel(dc_t);
|
||||
}
|
||||
|
||||
|
||||
U0 Attack()
|
||||
{
|
||||
I64 i;
|
||||
man_attack_t0=tP;
|
||||
Noise(100,300,1000);
|
||||
for (i=0;i<NUM_MONSTERS;i++) {
|
||||
if (!monsters[i].dead &&
|
||||
man_x+man_dx==monsters[i].x && man_y+man_dy==monsters[i].y)
|
||||
monsters[i].dead=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,x,y,minx,maxx,miny,maxy;
|
||||
CDC *dc;
|
||||
CSpriteExtents($IB,"<1>",1$,&minx,&maxx,&miny,&maxy);
|
||||
map_width =(maxx-minx+1)/MAP_SCALE;
|
||||
map_height=(maxy-miny+1)/MAP_SCALE;
|
||||
Free(map);
|
||||
map=MAlloc(map_width*map_height*sizeof(U8));
|
||||
dc=DCNew(DCT_COLOR8,map_width*MAP_SCALE,map_height*MAP_SCALE);
|
||||
CSpritePlot3(dc,-minx,-miny,0,$IB,"<1>",1$);
|
||||
for (y=0;y<map_height;y++)
|
||||
for (x=0;x<map_width;x++)
|
||||
map[y*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
|
||||
DCDel(dc);
|
||||
|
||||
for (i=0;i<NUM_MONSTERS;i++) {
|
||||
monsters[i].dead=FALSE;
|
||||
monsters[i].dx=0;
|
||||
monsters[i].dy=0;
|
||||
do {
|
||||
monsters[i].x=RandU64%(map_width-2)+1;
|
||||
monsters[i].y=RandU64%(map_height-2)+1;
|
||||
} while (!map[(monsters[i].y)*map_width+monsters[i].x]);
|
||||
}
|
||||
man_attack_t0=tP;
|
||||
man_attack=FALSE;
|
||||
man_x=0;
|
||||
man_y=4;
|
||||
man_dx=0;
|
||||
man_dy=0;
|
||||
screen_x=0;
|
||||
screen_y=0;
|
||||
}
|
||||
|
||||
U0 CleanUp()
|
||||
{
|
||||
Free(map);
|
||||
map=NULL;
|
||||
}
|
||||
|
||||
U0 AnimateTask(I64)
|
||||
{
|
||||
I64 i,x,y,dx,dy;
|
||||
while (TRUE) {
|
||||
for (i=0;i<NUM_MONSTERS;i++)
|
||||
if (!monsters[i].dead) {
|
||||
dx=RandU16%3-1;
|
||||
dy=RandU16%3-1;
|
||||
x=monsters[i].x+dx;
|
||||
y=monsters[i].y+dy;
|
||||
if (0<=x<=map_width && 0<=y<=map_height &&
|
||||
map[y*map_width+x]) {
|
||||
monsters[i].x=x;
|
||||
monsters[i].y=y;
|
||||
monsters[i].dx=dx;
|
||||
monsters[i].dy=dy;
|
||||
}
|
||||
}
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DunGen()
|
||||
{
|
||||
I64 ch,sc;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,CH_NEW_LINE);"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Attack(,CH_SPACE);"
|
||||
"}"
|
||||
);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
|
||||
Preempt(OFF);
|
||||
WinMax;
|
||||
WordStat;
|
||||
Init;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",Fs);
|
||||
DocCursor;
|
||||
DocClear;
|
||||
Fs->draw_it=&DrawIt;
|
||||
|
||||
try {
|
||||
while (TRUE) {
|
||||
switch (GetMsg(&ch,&sc,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (ch) {
|
||||
case CH_NEW_LINE:
|
||||
Init;
|
||||
break;
|
||||
case CH_SPACE:
|
||||
man_attack=TRUE;
|
||||
break;
|
||||
case CH_ESC:
|
||||
case CH_SHIFT_ESC:
|
||||
goto dg_done;
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_RIGHT:
|
||||
if (man_attack) {
|
||||
man_dx=1;
|
||||
man_dy=0;
|
||||
Attack;
|
||||
} else
|
||||
if (man_x+1<map_width && map[man_y*map_width+(man_x+1)]==RED) {
|
||||
man_x++;
|
||||
if (man_x-screen_x>SCREEN_WIDTH/2-3) {
|
||||
screen_x+=SCREEN_WIDTH/2;
|
||||
if (screen_x+SCREEN_WIDTH/2>map_width)
|
||||
screen_x=map_width-SCREEN_WIDTH/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (man_attack) {
|
||||
man_dx=-1;
|
||||
man_dy=0;
|
||||
Attack;
|
||||
} else
|
||||
if (man_x-1>=0 && map[man_y*map_width+(man_x-1)]==RED) {
|
||||
man_x--;
|
||||
if (man_x-screen_x<-SCREEN_WIDTH/2+3) {
|
||||
screen_x-=SCREEN_WIDTH/2;
|
||||
if (screen_x-SCREEN_WIDTH/2<0)
|
||||
screen_x=SCREEN_WIDTH/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (man_attack) {
|
||||
man_dx=0;
|
||||
man_dy=-1;
|
||||
Attack;
|
||||
} else
|
||||
if (man_y-1>=0 && map[(man_y-1)*map_width+man_x]==RED) {
|
||||
man_y--;
|
||||
if (man_y-screen_y<-SCREEN_HEIGHT/2+3) {
|
||||
screen_y-=SCREEN_HEIGHT/2;
|
||||
if (screen_y-SCREEN_HEIGHT/2<0)
|
||||
screen_y=SCREEN_HEIGHT/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
if (man_attack) {
|
||||
man_dx=0;
|
||||
man_dy=1;
|
||||
Attack;
|
||||
} else
|
||||
if (man_y+1<map_height && map[(man_y+1)*map_width+man_x]==RED) {
|
||||
man_y++;
|
||||
if (man_y-screen_y>SCREEN_HEIGHT/2-3) {
|
||||
screen_y+=SCREEN_HEIGHT/2;
|
||||
if (screen_y+SCREEN_HEIGHT/2>map_height)
|
||||
screen_y=map_height-SCREEN_HEIGHT/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_UP:
|
||||
if (ch==CH_SPACE)
|
||||
man_attack=FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dg_done:
|
||||
GetMsg(,,1<<MSG_KEY_UP);
|
||||
} catch
|
||||
CatchAll;
|
||||
SettingsPop;
|
||||
MenuPop;
|
||||
CleanUp;
|
||||
}
|
||||
|
||||
DunGen;
|
||||
| ||||