LTCD_060719.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:17 +02:00
commit f86e69648b
156 files changed
+49537

No files matched your search

+121
View File
@@ -0,0 +1,121 @@
/* This file gets included once into the
"Adam" task's memory by $LK,"LoadAdam3","MN:LoadAdam3"$() placed in
$LK,"HOME/USER.CPZ","FI:HOME/USER.CPZ"$. The declarations from this file
are available to all tasks, since all tasks
chain back to Adam.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
*/
class RenameSymbolStruct
{
I1 find[256] fmtstr "$$DA -P ,255 \"Find :%s\"$$\r\n";
I1 replace[256] fmtstr "$$DA -P ,255 \"Replace:%s\"$$\r\n";
};
void RenameCurSymbol()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
}
void RenameFile()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
Move(r.find,r.replace);
}
void FillinTime()
{
LTDate ltdt;
ltdt=GetCurTimeLTDate;
PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt.date,ltdt.time);
}
BoolU4 My_EditPlugIns(Ltf *l,I8 ch,U8 sc)
{ //You can customize these
U8 sc2,ms=0;
l;ch; //Ref, So not unused Warn
sc2=sc.u1[0];
if (sc2>=SC_F1 && sc2<=SC_F10 &&
(sc & SCF_ALT) &&
!(sc & SCF_CTRL)) {
if (sc2==SC_F1) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTPURPLE$$");
else
PutS("$$FG PURPLE$$");
} else if (sc2==SC_F2) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTRED$$");
else
PutS("$$FG RED$$");
} else if (sc2==SC_F3) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTGREEN$$");
else
PutS("$$FG GREEN$$");
} else if (sc2==SC_F4) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTBLUE$$");
else
PutS("$$FG$$");
} else if (sc2==SC_F6) {
if (!(sc & SCF_SHIFT))
PopUp("WsInit(\"/LT\");");
} else if (sc2==SC_F7) {
if ((sc & SCF_SHIFT))
LtfSafeInsert(Fs->cur_ltf,
"$$HS+C$$$$FG$$$$HE$$");
else
FillinTime();
} else if (sc2==SC_F8) {
if ((sc & SCF_SHIFT))
RenameFile();
else
RenameCurSymbol();
} else if (sc2==SC_F9)
PopUp("PunchIn;");
else if (sc2==SC_F10)
PopUp("PunchOut;");
return TRUE;
}
return FALSE;
}
Cd("/LT/UTILS");;
#include "BOOTINS"
#include "DBG"
#include "DIFF"
#include "GREP"
#include "S2T"
#include "HASHUTIL"
#include "IDE"
#include "BMP"
LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man()
LoadMapFile("::/LT/COMPILE/CMP.MPZ"); //Enable Man()
LoadMapFile("::/LT/ADAM/ADAMASM.MPZ"); //Enable Man()
Binary file not shown.
Binary file not shown.
+84
View File
@@ -0,0 +1,84 @@
//This is the startup file for new local users
UseConsoleLtf("USER.MUZ");
Fs->answers_displayed=2; //from 0-8
LoadAdam3;
U8 F(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags);
}
U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text);
}
U8 FD(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,TEXT_FILE_MASK,flags);
}
U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,TEXT_FILE_MASK,flags,replace_text);
}
PutSysText("ST_USER_STARTUP");
Type("/LT/DOC/Help.TXZ");
Fs->scroll_speed=10;
Bts(&Fs->crt_flags,CRTf_SHOW);
Type("/LT/DOC/StartUp.TXZ");
I1 src,dst,*st1,*st2;
I4 i;
if (Fs->user_num==1) {
for (i=0;i<10;i++) CrLf;
coutln "This will reformat or delete old installations, "
"copy files onto a partition, recompile "
"and modify the boot sector. For this "
"to work, your hard disk partition must "
"already be bootable with a boot loader like LILO. "
"Obviously, the partition "
"you select will lose data and be destroyed. ";
cout "Continue ";
if (YorN) {
cout "\r\nWould you like to view notes on installation, first";
if (YorN)
Edit("/LT/DOC/Install.TXZ");
coutln "\r\n$$BK,1$$$$FG,PURPLE$$Add Drives so you can install.$$FG$$$$BK,0$$";
AddDrives;
src=default_drive;
cout "\r\n\r\n\r\n$$BK,1$$$$FG,PURPLE$$Destination Drive:$$FG$$$$BK,0$$";
dst=GetChar;
coutln;
st1=MSPrintF("%c:/LT",src);
st2=MSPrintF("%c:/LT",dst);
PrintF("Format %c drive ",dst);
if (YorN) {
coutln;
Format(dst,TRUE,FALSE,PT_LT);
} else {
cout "\r\n$$BK 1$$WARNING$$BK 0$$ if you answer yes to the following "
"you will lose all files in your /LT directory.\r\n";
cout "Delete ",st2," Directory ";
if (YorN)
DelTree(st2);
coutln;
}
CopyTree(st1,st2);
st2=MSPrintF("%c:/0000BOOT",dst);
MkDir(st2);
Free(st2);
st2=MSPrintF("%c:/TEMP",dst);
MkDir(st2);
Free(st2);
InstallBoot(dst);
}
}
Binary file not shown.
Binary file not shown.
+114
View File
@@ -0,0 +1,114 @@
while (!initial_user_tasks_startup_complete)
SwapInNext;
void ASCIIKeys(I1 *st)
{
U8 ch;
I1 buf[80];
do {
ch=GetKey;
if (ch==*st) {
PutChar(ch);
st++;
} else {
if (*st==CH_CR)
SPrintF(buf,"Press the '$$FG GREEN$$ENTER$$FG$$' key");
else
SPrintF(buf,"Press the '$$FG GREEN$$%c$$FG$$' key",*st);
PopUpOk(buf);
}
} while (*st);
}
void SlowASCIIAutoType(I1 *st)
{
U8 ch;
do {
if (ch=*st++) {
PutChar(ch);
Sleep(100);
}
} while (ch);
}
void SpecialKey(U8 scancode,I1 *name)
{
U8 sc,ch;
I1 buf[80];
do {
ch=GetChar2(&sc);
if (sc&0xFF!=SC_PRTSCRN1) {
if (sc&0xFF!=scancode&0xFF) {
SPrintF(buf,"Press the '$$FG GREEN$$%s$$FG$$' key",name);
PopUpOk(buf);
}
}
} while (sc&0xFF!=scancode&0xFF);
Msg(MSG_KEY_DOWN,ch,sc);
}
void SpecialASCIIKey(U8 ch1,I1 *name,U8 flag_mask=0,U8 flags=0)
{
U8 sc,ch;
I1 buf[80];
do {
ch=GetChar2(&sc);
if (ch && ch!=ch1) {
SPrintF(buf,"Press the '$$FG GREEN$$%s$$FG$$' key",name);
PopUpOk(buf);
}
} while (ch!=ch1 || (sc&flag_mask!=flags));
Msg(MSG_KEY_DOWN,ch,sc);
}
void UntilSpecialKey(U8 scancode)
{
U8 sc,ch;
do {
ch=GetChar2(&sc);
Msg(MSG_KEY_DOWN,ch,sc);
} while (sc&0xFF!=scancode&0xFF);
}
void UntilASCIIKey(U8 ch1)
{
U8 sc,ch;
do {
ch=GetChar2(&sc);
Msg(MSG_KEY_DOWN,ch,sc);
} while (ch!=ch1);
}
public I8 PopUpTourPart()
{
I8 i;
Ltf *l=LtfNew;
LtfPutS(l,"$$FG PURPLE$$LoseThos Tours$$FG$$\r\n\r\n");
LtfPutS(l,"$$CM +LX, 4,4$$$$BT, \"Part 1: The basics\",1$$");
LtfPutS(l,"$$CM +LX, 4,4$$$$BT, \"Part 2: Editing and running programs\",2$$");
LtfPutS(l,"$$CM +LX, 4,4$$$$BT, \"Part 3: Adding macros to your start menu\",3$$");
LtfPutS(l,"$$CM +LX, 4,4$$$$BT, \"Part 4: WordStat\",4$$");
LtfPutS(l,"$$CM +LX, 4,4$$$$BT, \"Done\",-1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
I8 i;
do {
switch (i=PopUpTourPart)
{
case 1:
ExecuteFile("::/LT/ACCOUNTS/TOUR/TOUR1.AUZ");
break;
case 2:
ExecuteFile("::/LT/ACCOUNTS/TOUR/TOUR2.AUZ");
break;
case 3:
ExecuteFile("::/LT/ACCOUNTS/TOUR/TOUR3.AUZ");
break;
case 4:
ExecuteFile("::/LT/ACCOUNTS/TOUR/TOUR4.AUZ");
break;
}
} while (i>=1);
+101
View File
@@ -0,0 +1,101 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\r");
PopUpOk(
"After clicking 'OKAY', you will be at the\r\n"
"command line.\r\n\r\n"
"Type \"$$FG GREEN$$Dir;$$FG$$\" and press $$FG GREEN$$ENTER$$FG$$.\r\n\r\n"
"You must remember the semicolon.\r\n"
);
ASCIIKeys("Dir;\r");
Sleep(1000); //allow user time to see dir
PutChar(CH_CR);
PopUpOk(
"After clicking 'OKAY', you will be at the\r\n"
"command line.\r\n\r\n"
"Press the $$FG GREEN$$WINDOW$$FG$$s key.\r\n\r\n"
"This will access your macro/menu/help area.\r\n"
"You can customize it. It's like your\r\n"
"START menu.\r\n");
SpecialKey(SC_GUI,"WINDOWS KEY");
Sleep(1000);
PopUpOk(
"For future reference, you can get to the\r\n"
"menu/macro/help area by clicking the left\r\n"
"mouse button when the mouse cursor is on\r\n"
"the word \"MENU\" in the upper-left border\r\n"
"of the window.\r\n");
PopUpOk(
"After clicking 'OKAY', you will be back at\r\n"
"the menu/macro/help area.\r\n\r\n"
"Press $$FG GREEN$$CURSOR-DOWN$$FG$$ five times.\r\n");
//This puts the cursor at the top
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
I8 i;
for (i=0;i<5;i++)
SpecialKey(SC_CURSOR_DOWN,"CURSOR-DOWN");
PopUpOk(
"After clicking 'OKAY', the cursor will be\r\n"
"on top of a macro we wish to run. Usually,\r\n"
"underlined text will do something.\r\n\r\n"
"Macros are normally $$FG LTBLUE$$BLUE$$FG$$ and you run\r\n"
"them by left-clicking the mouse. You can\r\n"
"simulate a left-mouse with a $$FG GREEN$$SPACE$$FG$$\r\n"
"key.\r\n\r\n"
"After clicking OKAY, press $$FG GREEN$$SPACE$$FG$$.\r\n");
ASCIIKeys(" ");
Sleep(1000);
PopUpOk(
"The macro changed directories and did\r\n"
"a $$FG GREEN$$Dir;$$FG$$ command.\r\n\r\n"
"The $$FG RED$$RED$$FG$$ filenames listed are file\r\n"
"links. Left-clicking will edit/view them.\r\n"
"Right-clicking or pressing $$FG GREEN$$ENTER$$FG$$\r\n"
"when the cursor is on top will bring-up a\r\n"
"menu of options.\r\n\r\n"
"The $$FG LTBLUE$$BLUE$$FG$$ underline entries \"$$FG LTBLUE$$.$$FG$$\" and \"$$FG LTBLUE$$..$$FG$$\"\r\n"
"are macros and will change directories.\r\n");
PopUpOk(
"As you can see, the command line is not\r\n"
"different from the help/menu/macro area.\r\n"
"Both use the same commands and have the same\r\n"
"'Widgets' available.\r\n\r\n"
"Both utilize the same underlying document format\r\n"
"known as LoseThos rich text. It is similar to\r\n"
"html because it has ASCII behind it.\r\n\r\n"
"Press \"$$FG GREEN$$CTRL-T$$FG$$\" after clicking 'OKAY' to toggle\r\n"
"to plain text mode.\r\n");
SpecialASCIIKey(20,"CTRL-T");
Sleep(1000);
PopUpOk(
"The widgets are bracketed with dollar sign\r\n"
"characters. \"LK\" stands \"link\" and \"MA\"\r\n"
"stands for \"macro\".\r\n\r\n"
"Now, press \"$$FG GREEN$$CTRL-T$$FG$$\" to toggle back to\r\n"
"regular mode.\r");
SpecialASCIIKey(20,"CTRL-T");
Sleep(1000);
PopUpOk(
"In summary, you left-click on underlined\r\n"
"text or press $$FG GREEN$$SPACE$$FG$$ when the cursor\r\n"
"is on top, to perform the primary action.\r\n"
"You right-click or press $$FG GREEN$$ENTER$$FG$$\r\n"
"to perform a secondary action.\r\n\r\n"
"The $$FG GREEN$$WINDOW$$FG$$'s key will bring-up the help/macro/menus\r\n"
"as will clicking on the word \"MENU\" in the\r\n"
"upper-left corner of a window's border.\r\n\r\n"
"The $$FG GREEN$$CTRL-T$$FG$$ key will toggle plain-text mode.\r\n");
+76
View File
@@ -0,0 +1,76 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\r");
PopUpOk(
"Now, we're going to demonstrate how to work\r\n"
"with programs. We'll change to the \LT\DEMO\r\n"
"directory. The change directory command\r\n"
"will be typed for you and you just need\r\n"
"to press $$FG GREEN$$ENTER$$FG$$.\r\n\r\n"
"Note, that directories are specified with\r\n"
"a forward slash, not a backslash.\r\n"
"Drives can be specified in a $$FG GREEN$$Cd()$$FG$$ command\r\n"
"and the boot drive is specified with \"$$FG GREEN$$::$$FG$$\".");
PutS("Cd(\"::/LT/DEMO\");Dir;");
ASCIIKeys("\r");
PopUpOk(
"Now, we're going to edit a file. Normally,\r\n"
"you'll probably left-click on a directory\r\n"
"listing to edit a file, but we're going to\r\n"
"type it on the command line.\r\n\r\n"
"Press $$FG GREEN$$ENTER$$FG$$ to complete the command.\r\n");
PutS("Edit(\"Sound.CPZ\");");
ASCIIKeys("\r");
Sleep(1000);
PopUpOk(
"This program gets keys and plays frequencies.\r\n"
"It quits when you press $$FG GREEN$$ESC$$FG$$.\r\n\r\n"
"There is no \"$$FG GREEN$$main()$$FG$$\" function in LoseThos\r\n"
"programs. Any program statements outside\r\n"
"functions get executed when you $$FG GREEN$$#include$$FG$$\r\n"
"them at the command line.\r\n\r\n"
"The \"$$FG GREEN$$Organ;$$FG$$\" statement at the bottom\r\n"
"will run the program when we $$FG GREEN$$#include$$FG$$ it.\r\n");
PopUpOk(
"The editor and most things exit when you press\r\n"
"$$FG GREEN$$ESC$$FG$$. $$FG GREEN$$CTRL-Q$$FG$$ will abort (cancel) most things.\r\n\r\n"
"The $$FG GREEN$$ESC$$FG$$ key can be simulated with a left\r\n"
"double-click, while the $$FG GREEN$$CTRL-Q$$FG$$ key can be\r\n"
"simulated with a right double-click. When\r\n"
"you browse documentation, you'll left-click\r\n"
"on links and right double-click to go back,\r\n"
"unless you want to save changes to documents\r\n"
"using left double-click.\r\n\r\n"
"Press $$FG GREEN$$CTRL-Q$$FG$$ to quit out of the editor.\r\n"
);
SpecialASCIIKey(CH_CTRLQ,"CTRL-Q");
PopUpOk(
"Now, we'll run the Sound.CPZ program.\r\n"
"Press $$FG GREEN$$ENTER$$FG$$ at the command line to\r\n"
"$$FG GREEN$$#include$$FG$$ it. Then press keys to\r\n"
"cause sounds and press $$FG GREEN$$ESC$$FG$$ when\r\n"
"you are done.\r\n");
PutS("#include \"Sound.CPZ\";");
ASCIIKeys("\r");
UntilASCIIKey(CH_ESC);
PopUpOk(
"The program is still in memory and we\r\n"
"can start it again by typing \"$$FG GREEN$$Organ;$$FG$$\".\r\n\r\n"
"Press $$FG GREEN$$ENTER$$FG$$ at the command line to\r\n"
"run it again.\r\n");
PutS("Organ;");
ASCIIKeys("\r");
UntilASCIIKey(27);
+95
View File
@@ -0,0 +1,95 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\rCd(\"::/LT/DEMO\");Dir;\r");
PopUpOk(
"Now, we're going to add the Sound.CPZ\r\n"
"program to your start menu.\r\n\r\n"
"Press the $$FG GREEN$$WINDOW$$FG$$s key\r\n"
"to get to your menu/macro/help area.\r\n");
SpecialKey(SC_GUI,"WINDOWS KEY");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
Sleep(1000);
PopUpOk(
"Press $$FG GREEN$$CTRL-L$$FG$$ to invoke the\r\n"
"rich-text resource editor.\r\n");
SpecialASCIIKey(12,"CTRL-L");
PopUpOk(
"Press $$FG GREEN$$CURSOR-DOWN$$FG$$ until you reach\r\n"
"\"Macro\".\r\n");
I8 i;
for (i=0;i<8;i++)
SpecialKey(SC_CURSOR_DOWN,"CURSOR-DOWN");
PopUpOk(
"Press $$FG GREEN$$SPACE$$FG$$.\r\n");
ASCIIKeys(" ");
Sleep(1000);
PopUpOk(
"Now, we'll fill-in the visible text\r\n"
"of the macro.\r\n");
SlowASCIIAutoType("Click Here");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
PopUpOk("Now, we'll fill-in the macro text.\r\n");
SlowASCIIAutoType("Cd(\\\"::/LT/DEMO\\\");;#include \\\"Sound.CPZ\\\";\\r");
PopUpOk("Press $$FG GREEN$$ESC$$FG$$ to exit the form.\r\n");
SpecialASCIIKey(CH_ESC,"ESC");
Sleep(1000);
PopUpOk("Press $$FG GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n");
SpecialASCIIKey(CH_CR,"CTRL-SHIFT-ENTER",SCF_CTRL|SCF_SHIFT,SCF_CTRL|SCF_SHIFT);
Sleep(1000);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
PopUpOk(
"Press $$FG GREEN$$SPACE$$FG$$ to test it.\r\n");
ASCIIKeys(" ");
UntilASCIIKey(CH_ESC);
PopUpOk(
"Now, we'll do a fancier macro that pops-up\r\n"
"a new window which dies when finished,\r\n"
"returning memory to the system.\r\n");
Msg(MSG_KEY_DOWN,0,SC_GUI);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
Msg(MSG_KEY_DOWN,12,0); //CTRL-L
for (i=0;i<8;i++)
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
SlowASCIIAutoType(" Click here for Pop-up version");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
SlowASCIIAutoType("Cd(\\\"::/LT/DEMO\\\");;#include \\\"Sound.CPZ\\\"\\r");
PopUpOk(
"Press $$FG GREEN$$CURSOR-DOWN$$FG$$ until you reach\r\n"
"the \"Pop-Up\" check-box.\r\n");
for (i=0;i<2;i++)
SpecialKey(SC_CURSOR_DOWN,"CURSOR-DOWN");
PopUpOk(
"Press $$FG GREEN$$SPACE$$FG$$ to\r\n"
"check the box.\r\n");
ASCIIKeys(" ");
Sleep(500);
PopUpOk("Press $$FG GREEN$$ESC$$FG$$ to exit the form.\r\n");
SpecialASCIIKey(CH_ESC,"ESC");
Sleep(500);
PopUpOk("Press $$FG GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n");
SpecialASCIIKey(CH_CR,"CTRL-SHIFT-ENTER",SCF_CTRL|SCF_SHIFT,SCF_CTRL|SCF_SHIFT);
Sleep(500);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
PopUpOk(
"Press $$FG GREEN$$SPACE$$FG$$ to test it.\r\n");
ASCIIKeys(" ");
Sleep(5000);
PopUpOk(
"Press $$FG GREEN$$CTRL-S$$FG$$ to save your\r\n"
"macro/menu/help area file, if you wish.\r\n");
+58
View File
@@ -0,0 +1,58 @@
PopUp("WsInit(\"::/LT\");");
if (!ws_task)
ws_task=Spawn(&WsTsk,"WORDSTAT");
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\rCd(\"::/LT/DEMO\");\r");
PopUpOk(
"WordStat is an autocomplete feature\r\n"
"which will also jump to source code.\r\n\r\n"
"We will now place some text on the command\r\n"
"line and jump to source code.\r\n");
PutS("InstallB");
Sleep(1000);
PopUpOk(
"After clicking $$FG GREEN$$OKAY$$FG$$, look at\r\n"
"the $$FG GREEN$$InstallBoot$$FG$$ entry in the WordStat\r\n"
"window. Notice it has a '$$FG GREEN$$*$$FG$$' by it.\r\n"
"This means a source code link is available.\r\n");
sys_cur_focus_task=Fs->parent_tss;
Sleep(2000);
PopUpOk(
"Press $$FG GREEN$$CTRL-SHIFT-F1$$FG$$ to jump to source code.\r\n");
sys_cur_focus_task=Fs->parent_tss;
UntilSpecialKey(SC_F1|SCF_CTRL|SCF_SHIFT);
Sleep(2000);
PopUpOk(
"Press $$FG GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n");
UntilASCIIKey(CH_CTRLQ);
PopUpOk(
"Press $$FG GREEN$$CTRL-F1$$FG$$ to autocomplete.\r\n");
sys_cur_focus_task=Fs->parent_tss;
UntilSpecialKey(SC_F1|SCF_CTRL);
Sleep(500);
Msg(MSG_KEY_DOWN,CH_CR,SCF_CTRL|SCF_SHIFT);
PutS("\r");
PopUpOk(
"Tip: You can restart the WordStat window if you\r\n"
"have closed it by pressing $$FG GREEN$$CTRL-F1$$FG$$.\r\n");
PopUpOk(
"You can also use the $$FG GREEN$$Man()$$FG$$ function\r\n"
"to jump to source code.\r\n");
SlowASCIIAutoType("Man(\"InstallBoot\");");
Sleep(1000);
PutS("\r");
Sleep(2000);
PopUpOk(
"Press $$FG GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n");
UntilASCIIKey(CH_CTRLQ);
+10
View File
@@ -0,0 +1,10 @@
//This is the startup file for new local users
UseConsoleLtf("USER.MUZ");
Fs->answers_displayed=2; //from 0-8
LoadAdam3;
PutSysText("ST_USER_STARTUP");
Type("/LT/DOC/Help.TXZ");
Bts(&Fs->crt_flags,CRTf_SHOW);
if (Fs->user_num==1)
AutoFile("TOUR");
+71
View File
@@ -0,0 +1,71 @@
//This is the startup file for new local users
UseConsoleLtf("USER.MUZ");
Fs->answers_displayed=2; //from 0-8
LoadAdam3;
U8 F(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags);
}
U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text);
}
U8 FD(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,TEXT_FILE_MASK,flags);
}
U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,TEXT_FILE_MASK,flags,replace_text);
}
PutSysText("ST_USER_STARTUP");
Type("/LT/DOC/Help.TXZ");
Fs->scroll_speed=10;
Bts(&Fs->crt_flags,CRTf_SHOW);
Type("/LT/DOC/StartUp.TXZ");
I1 src,dst,*st1,*st2;
I4 i;
if (Fs->user_num==1) {
for (i=0;i<10;i++) CrLf;
coutln "This will copy the /LT directory from "
"the CD-ROM onto a harddisk overwriting old files. "
"It will then recompile "
"and modify the boot sector. If your old "
"installation is the right disk format and "
"you have created your own ACCOUNTS directory "
"that directory will be left intact.";
cout "Continue ";
if (YorN) {
cout "\r\nWould you like to view notes on installation, first";
if (YorN)
Edit("/LT/DOC/Install.TXZ");
coutln "\r\n$$BK,1$$$$FG,PURPLE$$Add Drives so you can upgrade.$$FG$$$$BK,0$$";
AddDrives;
src=default_drive;
cout "\r\n\r\n$$BK,1$$$$FG,PURPLE$$Destination Drive:$$FG$$$$BK,0$$";
dst=GetChar;
coutln;
st1=MSPrintF("%c:/LT",src);
st2=MSPrintF("%c:/LT",dst);
CopyTree(st1,st2);
st2=MSPrintF("%c:/0000BOOT",dst);
MkDir(st2);
Free(st2);
st2=MSPrintF("%c:/TEMP",dst);
MkDir(st2);
Free(st2);
InstallBoot(dst);
}
}
+47
View File
@@ -0,0 +1,47 @@
/*
This is the startup file for new local users.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
*/
UseConsoleLtf("USER.MUZ");
Fs->answers_displayed=2; //from 0-8
LoadAdam3;
Fs->EditPlugIns=&My_EditPlugIns;
Ltf *l=Fs->cur_ltf;
l->EditPlugIns=&My_EditPlugIns;
if (l=l->menu_ltf)
l->EditPlugIns=&My_EditPlugIns;
U8 F(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags);
}
U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text);
}
U8 FD(I1 *pattern,I1 *flags="+r+i")
{
return Grep(pattern,TEXT_FILE_MASK,flags);
}
U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l")
{
return Grep(pattern,TEXT_FILE_MASK,flags,replace_text);
}
PutSysText("ST_USER_STARTUP");
Type("/LT/DOC/Help.TXZ");
Fs->scroll_speed=10;
Bts(&Fs->crt_flags,CRTf_SHOW);
Type("/LT/DOC/StartUp.TXZ");
+27
View File
@@ -0,0 +1,27 @@
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
$MA,"Cd(\"HOME\");Dir;\r"$
$MA,"Cd(\"::/LT/OSMain\");Dir;\r"$
$MA,"Cd(\"::/LT/ADAM\");Dir;\r"$
$MA,"Cd(\"::/LT/APPS\");Dir;\r"$
$MA,"Cd(\"::/LT/DEMO\");Dir;\r"$
$MA,"Cd(\"::/LT/UTILS\");Dir;\r"$
$MA,"Drive('A');\r"$
$MA+A,"Recompile Floppy OS Drive A:","InstallBoot('A');\r"$
$WW,1$$MA+A-X+PU,"Play WarGame","Cd(\"::/LT/APPS\");;#include \"WARGAME\"\r"$
$MA+A-X+PU,"DO-TELL (A fractel-like thing)","Cd(\"::/LT/DEMO\");;#include \"Dawg\"\r"$
$MA+A-X+PU,"StarTrek Game","#include \"::/LT/DEMO/Graphics/StarTrek2\"\r"$
$MA+A,"Tour","Cd(\"::/LT/ACCOUNTS/TOUR\");;AutoFile(\"TOUR\");\r"$
The following can be used if you recompile, adding hard disk support.
$MA,"Drive('D');\r"$
$MA,"Drive('E');\r"$
$MA+A,"Recompile Hard Drive D:","InstallBoot(':','D');\r"$
$MA+A-X+PU,"List functions in alphabetic order","HFunsRep;View;"$
$MA+A-X+PU,"List functions in numeric address order","HMapRep;View;"$
+67
View File
@@ -0,0 +1,67 @@
#include "AdamExt"
#include "IncCompress"
#include "MATH"
#include "ODE"
Load("ADAMASM");
#include "ADAMASM.HPZ"
#include "GRMODE3"
#include "MUSIC"
#include "DISK10"
#include "FIFO"
#include "COMM"
#include "INPTR"
#include "GRELEM"
#include "LTF"
#include "UTILS"
#include "MOUSE"
#include "JOY"
#include "WINDOW"
#include "EDIT"
#include "LOGIN"
#include "WORDSTAT"
BoolU4 initial_user_tasks_startup_complete=FALSE;
public void DuelUsers()
{
I1 buf[80];
TssStruct *tss,*tss1;
tss=Spawn(&UserCmdLine);
while (!Bt(&tss->task_flags,TSSf_IDLE))
SwapInNext;
tss->window_top=2;
tss->window_right=(SCREEN_COLS-2)<<1;
tss1=tss;
tss=Spawn(&UserCmdLine);
while (!Bt(&tss->task_flags,TSSf_IDLE))
SwapInNext;
tss->window_top=2;
tss->window_left=SCREEN_COLS<<2>>1;
WindowToTop(tss1);
ws_task=Spawn(&WsTsk,"WORDSTAT");
SPrintF(buf,"Boot Time:%h17Ts\r\n",BootTime);
AdamLog(buf);
initial_user_tasks_startup_complete=TRUE;
}
Preempt(ON);
UseConsoleLtf(NULL);
adam_tss->window_top=2;
adam_tss->window_bottom=10;
update_screen_tss=Spawn(&WindowManagerTsk,"WINDOW MANAGER");
CollectAccntList;
Bts(&Fs->crt_flags,CRTf_SHOW);
if (!(Fs->account=FindSysAccnt(sys_startup_account)))
Fs->account=PopUpGetSysAccnt;
WsInit(wordstat_mask);
//This must be spawned because start-up files
// may invoke the Adam() cmd.
Spawn(&DuelUsers,"SPAWNUSERS");
coutln "\r\nOS Compile Time:",sys_compile_time;
Binary file not shown.
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
public LTextern CP_PLOT_SCREEN_I1 BoolU4 PlotScreenChar(U8 w,I8 x,I8 y);
public LTextern CP_PLOT_WINDOW_I1 BoolU4 PlotWindowChar(U8 w,I8 x,I8 y);
public LTextern CP_PLOT_BORDER_I1 BoolU4 PlotBorderChar(U8 w,I8 x,I8 y);
LTextern REVERSE_BITS_TABLE U1 reverse_bits_table[256];
LTextern GR_XOR_LINE void GrXorLine(U4 **dst3,U4 **src,U4 **src2,U8 d5,U4 **vga);
LTextern GR_PLOT_CHAR void GrPlotChar(U1 *font_ptr,U1 attr,U1 **dst2,U8 d1,U8 d2);
LTextern GR_PLOT_BACKGROUND void GrPlotBackground(U1 attr,U1 **dst,U8 d1,U8 d2);
LTextern GR_UPDATE_WINDOWS void GrUpdateWindows();
//The callback is void Plot(aux_data,x,y,z)
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
extern I8 PopUp(I1 *msg,TssStruct *parent=NULL);
extern U8 LtfPutChar(Ltf *l,I8 ch, U8 sc,BoolU4 old_preempt);
extern void LeftClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2);
extern void RightClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2);
extern U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL);
extern U8 GetMsgNoWait(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL);
extern void LtfInsert(Ltf *l,LtfEntry *ll);
extern LtfEntry *LtfPutS(Ltf *l,I1 *st);
extern I8 PopUpMenu(Ltf *l,I1 *help=NULL);
extern Ltf *LtfNew();
extern void LtfDel(Ltf *l,BoolU4 root_mem=FALSE);
extern LtfEntry *LtfPrintF(Ltf *l,I1 *src,...);
extern void DrawBorder(BoolU4 solid,I8 l,I8 r,I8 t,I8 b,U1 attr,BoolU4 clip);
extern void EditInsertLtf(Ltf *l,Ltf *b);
extern Ltf *LtfRead(I1 *name,U8 flags=0);
extern BoolU4 View();
extern BoolU4 IsPixelCovered(TssStruct *tss,I8 x,I8 y);
extern void PlotInputPointer();
extern void GrCircle(GrBitMap *base,I8 cx,I8 cy,I8 radius,
I8 step=1,double start_rad=0,double len_rad=pi2);
extern void GrPlot0(GrBitMap *base,I8 x,I8 y);
extern void ClearAllBpts(Ltf *l);
extern void ToggleBpt(Ltf *l,I8 line_offset=0,U8 flags=SBPTF_BPT);
extern void LtfGo();
extern void LtfStep(Ltf *l);
extern void Lpt1PutChar(U1 ch);
extern void WsFillin(I8 n);
extern void WsMan(I8 n,TssStruct *parent=NULL);
extern void WsTsk();
extern TssStruct *ws_task;
extern void Edit(I1 *filename);
+800
View File
@@ -0,0 +1,800 @@
#define CH_XOFF 0x13
#define CH_XON 0x11
#define UART_THR 0
#define UART_RDR 0
#define UART_BRDL 0
#define UART_IER 1
#define UART_BRDH 1
#define UART_IIR 2
#define UART_LCR 3
#define UART_MCR 4
#define UART_LSR 5
#define UART_MSR 6
#define COMMf_INCOMING_XOFFED 0
#define COMMf_OUTGOING_XOFFED 1
#define COMMf_TX_XOFF 2
#define COMMf_TX_XON 3
#define RMT_MAX_PKT_LEN 64 //Must be less then PKT_SYNC
#define RMT_PKT_ACK 0xA5
#define RMT_PKT_NACK 0x5A
#define RMT_PKT_SYNC 0xA3
#define RMT_PKT_SYNC2 0xA7
#define RMT_PKT_CHAR 0xA4
#define RMT_PKT_REQUEST 0xA6
#define RMT_PKT_CLOSE 0xA8
#define RMT_RQST_NONE 0x00
#define RMT_RQST_GETMSG 0x01
#define RMT_RQST_TX_FILE 0x02
#define RMT_RQST_RX_FILE 0x03
#define RMT_RQST_TX_BUF 0x04
#define RMT_RQST_RX_BUF 0x05
#define RMT_RQST_EXE_LOCAL 0x06
#define RMT_RQST_PUTS_CNT 0x07
#define RMT_RQST_MAX 0x07
U8 comm_base[5]={0,0x3F8,0x2F8,0x3E8,0x2E8};
U1Fifo *comm_Rx_fifos[5]={NULL,NULL,NULL,NULL,NULL};
U1Fifo *comm_Tx_fifos[5]={NULL,NULL,NULL,NULL,NULL};
U8 comm_flags[5]={0,0,0,0,0};
LTChnl *comm_chnls[5]={NULL,NULL,NULL,NULL,NULL};
public void RxClose(LTChnl *chnl)
{
U8 base;
U8 old_flags=GetFlags;
if (!chnl || !chnl->type) return;
if (chnl->type==LCT_COMM) {
base=comm_base[chnl->port];
OutP(base+UART_IER,0);
Cli;
if (comm_Rx_fifos[chnl->port]) {
DelU1Fifo(comm_Rx_fifos[chnl->port]);
comm_Rx_fifos[chnl->port]=NULL;
}
if (comm_Tx_fifos[chnl->port]) {
DelU1Fifo(comm_Tx_fifos[chnl->port]);
comm_Tx_fifos[chnl->port]=NULL;
}
comm_chnls[chnl->port]=NULL;
SetFlags(old_flags);
}
AFree(chnl);
}
public void CommPutChar(U8 port,U1 b)
{
U8 old_flags=GetFlags;
U8 base=comm_base[port];
Cli;
if (b==CH_XOFF)
Bts(&comm_flags[port],COMMf_TX_XOFF);
else if (b==CH_XON)
Bts(&comm_flags[port],COMMf_TX_XON);
else {
if (U1FifoCnt(comm_Tx_fifos[port])>comm_Tx_fifos[port]->mask-4) {
SetFlags(old_flags);
while (U1FifoCnt(comm_Tx_fifos[port])>comm_Tx_fifos[port]->mask-4)
SwapInNext;
Cli;
}
if (Bt(&comm_flags[port],COMMf_OUTGOING_XOFFED)) {
SetFlags(old_flags);
while (Bt(&comm_flags[port],COMMf_OUTGOING_XOFFED))
SwapInNext;
Cli;
}
if (comm_Tx_fifos[port])
U1FifoInsert(comm_Tx_fifos[port],b);
}
OutP(base+UART_IER,3); //Enable TX & RX IRQ
SetFlags(old_flags);
BusyWait(300);
}
public void RmtFlushRxFifo(LTChnl *chnl)
{
if (!chnl || !chnl->type) return;
U1FifoFlush(comm_Rx_fifos[chnl->port]);
if (Bt(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED))
chnl->PutChar(chnl,CH_XON);
}
public void RmtFlushTxFifo(LTChnl *chnl)
{
U8 base=comm_base[chnl->port];
if (!chnl || !chnl->type) return;
U1FifoFlush(comm_Tx_fifos[chnl->port]);
while (!(InP(base+UART_LSR) & 0x20))
SwapInNext;
}
public void RmtPrintF(LTChnl *chnl,I1 *src,...)
{
I1 *buf,*ptr;
if (!chnl || !chnl->type) return;
buf=SPrintFJoin(NULL,src,argc,argv);
ptr=buf;
while (*ptr)
chnl->PutChar(chnl,*ptr++);
Free(buf);
}
public void CommPrintF(U8 port,I1 *src,...)
{
RmtPrintF(comm_chnls[port],src,argc,argv);
}
void CommRxTxChar(U8 port)
{
U8 ch=0,irq,base=comm_base[port];
BoolU4 have_one;
if (comm_Rx_fifos[port] &&
comm_Tx_fifos[port]) {
while (TRUE) {
irq=InP(base+UART_IIR);
if ((irq & 0x07)==4) { //RX IRQ
ch=InP(base+UART_RDR);
if (ch==CH_XOFF)
Bts(&comm_flags[port],COMMf_OUTGOING_XOFFED);
else if (ch==CH_XON)
Btr(&comm_flags[port],COMMf_OUTGOING_XOFFED);
else {
U1FifoInsert(comm_Rx_fifos[port],ch);
if (U1FifoCnt(comm_Rx_fifos[port])>comm_Rx_fifos[port]->mask>>1)
CommPutChar(port,CH_XOFF);
}
} else if ((irq & 0x07)==2) { //TX IRQ
have_one=TRUE;
if (Btr(&comm_flags[port],COMMf_TX_XOFF))
ch=CH_XOFF;
else if (Btr(&comm_flags[port],COMMf_TX_XON))
ch=CH_XON;
else if (!U1FifoRemove(comm_Tx_fifos[port],&ch))
have_one=FALSE;
if (have_one) {
if (ch==CH_XOFF)
Bts(&comm_flags[port],COMMf_INCOMING_XOFFED);
else if (ch==CH_XON)
Btr(&comm_flags[port],COMMf_INCOMING_XOFFED);
OutP(base+UART_THR,ch);
}
if (!U1FifoCnt(comm_Tx_fifos[port]))
OutP(base+UART_IER,1); //Enable RX IRQ
} else
break;
}
}
}
public I8 RmtRxFifoCnt(LTChnl *chnl)
{
if (!chnl || !chnl->type) return 0;
return U1FifoCnt(comm_Rx_fifos[chnl->port]);
}
public I8 RmtTxFifoCnt(LTChnl *chnl)
{
if (!chnl || !chnl->type) return 0;
return U1FifoCnt(comm_Tx_fifos[chnl->port]);
}
public void RmtWaitTxDone(LTChnl *chnl)
{
U8 base=comm_base[chnl->port];
if (!chnl || !chnl->type) return;
while (RmtTxFifoCnt(chnl))
SwapInNext;
while (!(InP(base+UART_LSR) & 0x20))
SwapInNext;
}
void Irq03Handler()
{
CommRxTxChar(2);
CommRxTxChar(4);
}
void Irq04Handler()
{
CommRxTxChar(1);
CommRxTxChar(3);
}
public U1 CommGetChar(U8 port)
{
U8 ch=0;
while (!U1FifoRemove(comm_Rx_fifos[port],&ch))
SwapInNext;
if (Bt(&comm_flags[port],COMMf_INCOMING_XOFFED) &&
U1FifoCnt(comm_Rx_fifos[port])<comm_Rx_fifos[port]->mask>>2)
CommPutChar(port,CH_XON);
return ch;
}
public U1 RmtGetChar(LTChnl *chnl)
{
if (!chnl || !chnl->type)
return 0;
return CommGetChar(chnl->port);
}
public BoolU4 CommScanChar(U8 port,U1 *ch)
{
U8 ch1=0;
if (U1FifoPeek(comm_Rx_fifos[port],&ch1)) {
U1FifoRemove(comm_Rx_fifos[port],&ch1);
*ch=ch1;
if (Bt(&comm_flags[port],COMMf_INCOMING_XOFFED) &&
U1FifoCnt(comm_Rx_fifos[port])<comm_Rx_fifos[port]->mask>>2)
CommPutChar(port,CH_XON);
return TRUE;
} else
return FALSE;
}
public BoolU4 RmtScanChar(LTChnl *chnl,U1 *ch)
{
if (!chnl || !chnl->type)
return 0;
return CommScanChar(chnl->port,ch);
}
void CommRmtPutChar(LTChnl *chnl,U1 b)
{
CommPutChar(chnl->port,b);
}
U1 CommRmtGetChar(LTChnl *chnl)
{
return CommGetChar(chnl->port);
}
BoolU4 CommRmtScanChar(LTChnl *chnl,U1 *ch)
{
return CommScanChar(chnl->port,ch);
}
public LTChnl *CommOpen8N1(U8 port=1,U8 baud=38400)
{
LTChnl *chnl=NULL;
U8 old_flags=GetFlags,base=comm_base[port];
Cli;
if (!port || port>4 || comm_chnls[port])
goto co_exit;
chnl=AMAllocZ(sizeof(LTChnl));
comm_chnls[port]=chnl;
chnl->type=LCT_COMM;
base=comm_base[port];
chnl->port=port;
chnl->baud=baud;
chnl->PutChar=&CommRmtPutChar;
chnl->GetChar=&CommRmtGetChar;
chnl->ScanChar=&CommRmtScanChar;
if (comm_Rx_fifos[chnl->port])
DelU1Fifo(comm_Rx_fifos[chnl->port]);
if (comm_Tx_fifos[chnl->port])
DelU1Fifo(comm_Tx_fifos[chnl->port]);
comm_flags[chnl->port]=0;
comm_Rx_fifos[chnl->port]=NewU1Fifo(0x2000); //must be power of 2
comm_Tx_fifos[chnl->port]=NewU1Fifo(0x2000); //must be power of 2
OutP(base+UART_LCR,0); //Set for IER
OutP(base+UART_IER,0);
OutP(base+UART_LCR,0x80); //Enable baud rate control
OutP(base+UART_BRDL,(0x180/(baud/300)) & 0xFF); //LSB
OutP(base+UART_BRDH,(0x180/(baud/300)) / 256); //MSB
OutP(base+UART_LCR,3); // 8-none-1
InP(base+UART_RDR); //read garbage
InP(base+UART_LSR);
OutP(base+UART_MCR,4);
OutP(base+UART_IER,0); //DIsable all IRQ
OutP(base+UART_MCR,0xA); //out2 and rts
OutP(base+UART_IER,1); //Enable RX IRQ
co_exit:
SetFlags(old_flags);
return chnl;
}
public void CommClose(U8 port)
{
LTChnl *chnl=comm_chnls[port];
RxClose(chnl);
}
ext[EXT_IRQ03]=&Irq03Handler;
ext[EXT_IRQ04]=&Irq04Handler;
U8 RmtTxPktU1(LTChnl *chnl,U1 b)
{
if (!chnl || !chnl->type) return 0;
if (b==CH_XOFF || b==CH_XON ||
b==CH_ESC || b==RMT_PKT_CHAR ||
b==RMT_PKT_REQUEST ||
b==RMT_PKT_CLOSE) {
chnl->PutChar(chnl,CH_ESC);
chnl->PutChar(chnl,b^0x80);
return 2;
} else {
chnl->PutChar(chnl,b);
return 1;
}
}
BoolU4 RmtRxPktU1(LTChnl *chnl,U1 *b,
U8 timeout_jiffies,BoolU4 *esc=NULL)
{
U1 b1;
U8 timeout;
*b=RMT_PKT_NACK;
if (esc)
*esc=FALSE;
if (!chnl || !chnl->type)
return FALSE;
timeout=jiffies+timeout_jiffies;
while (jiffies<timeout) {
if (chnl->ScanChar(chnl,&b1)) {
if (b1==CH_ESC) {
timeout=jiffies+timeout_jiffies;
while (jiffies<timeout) {
if (chnl->ScanChar(chnl,&b1)) {
*b=b1^0x80;
if (esc) *esc=TRUE;
return TRUE;
}
SwapInNext;
}
return FALSE;
} else {
if (b1==RMT_PKT_CLOSE) {
Fs->rmt_chnl=NULL;
throw;
}
*b=b1;
return TRUE;
}
}
SwapInNext;
}
return FALSE;
}
void RmtTxPkt(LTChnl *chnl,U1 *p,U8 size,U8 rqst=RMT_RQST_NONE)
{
U1 b,xsum;
U8 i;
if (!chnl || !chnl->type) return;
if (rqst) {
rt_err1:
RmtFlushTxFifo(chnl);
chnl->PutChar(chnl,RMT_PKT_REQUEST);
RmtWaitTxDone(chnl);
RmtFlushRxFifo(chnl);
RmtTxPktU1(chnl,rqst);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=RMT_PKT_ACK)
goto rt_err1;
} else if (size==1) {
rt_err2:
RmtFlushTxFifo(chnl);
chnl->PutChar(chnl,RMT_PKT_CHAR);
RmtWaitTxDone(chnl);
RmtFlushRxFifo(chnl);
RmtTxPktU1(chnl,p[0]);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=RMT_PKT_ACK)
goto rt_err2;
} else {
rt_err3:
RmtFlushTxFifo(chnl);
RmtTxPktU1(chnl,RMT_PKT_SYNC);
RmtWaitTxDone(chnl);
RmtFlushRxFifo(chnl);
RmtTxPktU1(chnl,RMT_PKT_SYNC2);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=RMT_PKT_ACK)
goto rt_err3;
RmtTxPktU1(chnl,size);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=RMT_PKT_ACK)
goto rt_err3;
xsum=0x3A;
for (i=0;i<size;i++) {
b=p[i];
RmtTxPktU1(chnl,b);
xsum^=b;
}
while (RmtTxFifoCnt(chnl)) {
if (RmtRxFifoCnt(chnl)) {
if (RmtScanChar(chnl,&b)) {
if (b==RMT_PKT_NACK) {
RmtFlushRxFifo(chnl);
goto rt_err3;
}
}
}
SwapInNext;
}
RmtTxPktU1(chnl,xsum);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=RMT_PKT_ACK)
goto rt_err3;
}
}
void RmtRxPkt(LTChnl *chnl,U1 *p,U8 *size=NULL,U8 *rqst=NULL)
{
U1 b,b1,xsum;
U8 i,s,r;
BoolU4 esc;
if (!chnl || !chnl->type) {
if (size) *size=0;
if (rqst) *rqst=0;
return;
}
rr_start:
RmtFlushTxFifo(chnl);
if (RmtRxFifoCnt(chnl)>2)
RmtFlushRxFifo(chnl);
s=0;
r=0;
RmtRxPktU1(chnl,&b,JIFFY_FREQ);
RmtRxPktU1(chnl,&b1,JIFFY_FREQ/50,&esc);
rr_cont:
if (b==RMT_PKT_REQUEST) {
if (b1>RMT_RQST_MAX) {
if (b1==RMT_PKT_REQUEST && !esc)
goto rr_cont;
else
goto rr_err;
}
r=b1;
s=0;
goto rr_exit;
} else if (b==RMT_PKT_CHAR) {
if (b1==RMT_PKT_CHAR && !esc)
goto rr_cont;
*p=b1;
s=1;
goto rr_exit;
} else if (b==RMT_PKT_SYNC) {
if (b1!=RMT_PKT_SYNC2) {
if (b1==RMT_PKT_SYNC)
goto rr_cont;
else
goto rr_err;
}
RmtTxPktU1(chnl,RMT_PKT_ACK);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&s,JIFFY_FREQ/50);
if (s>RMT_MAX_PKT_LEN)
goto rr_err;
RmtTxPktU1(chnl,RMT_PKT_ACK);
RmtWaitTxDone(chnl);
xsum=0x3A;
for (i=0;i<s;i++) {
if (!RmtRxPktU1(chnl,&p[i],JIFFY_FREQ/50))
goto rr_err;
xsum^=p[i];
}
RmtRxPktU1(chnl,&b,JIFFY_FREQ/50);
if (b!=xsum)
goto rr_err;
goto rr_exit;
}
rr_err:
RmtTxPktU1(chnl,RMT_PKT_NACK);
RmtWaitTxDone(chnl);
goto rr_start;
rr_exit:
RmtTxPktU1(chnl,RMT_PKT_ACK);
RmtWaitTxDone(chnl);
if (size) *size=s;
if (rqst) *rqst=r;
}
public void RmtTxBlk(LTChnl *chnl,U1 *buf,I8 cnt)
{
U1 b[RMT_MAX_PKT_LEN];
U8 size;
if (!chnl || !chnl->type) return;
while (cnt>0) {
if (cnt<RMT_MAX_PKT_LEN)
size=cnt;
else
size=RMT_MAX_PKT_LEN;
MemCpy(b,buf,size);
RmtTxPkt(chnl,b,size);
cnt-=size;
buf+=size;
progress1=cnt;
}
}
public U1 *RmtRxBlk(LTChnl *chnl,I8 cnt)
{
U1 *result,*buf;
U1 b[RMT_MAX_PKT_LEN];
U8 size=0;
if (!chnl || !chnl->type) return NULL;
result=MAlloc(cnt);
buf=result;
while (cnt>0) {
RmtRxPkt(chnl,b,&size);
MemCpy(buf,b,size);
cnt-=size;
buf+=size;
progress1=cnt;
}
return result;
}
public U8 RmtGetMsg(LTChnl *chnl,I8 *p1,I8 *p2)
{
U8 cmd,d,size;
U1 b[RMT_MAX_PKT_LEN];
*p1=0;
*p2=0;
if (!chnl || !chnl->type)
return 0;
if (jiffies<chnl->null_msg_jiffy)
return 0;
else {
RmtTxPkt(chnl,NULL,0,RMT_RQST_GETMSG);
RmtRxPkt(chnl,b,&size);
if (size!=sizeof(U8)*3)
return 0;
cmd=b[0]><(U8);
*p1=b[8]><(U8);
*p2=b[16]><(U8);
if (!cmd)
chnl->null_msg_jiffy=jiffies+JIFFY_FREQ/50;
}
return cmd;
}
public void RmtSendMsg(LTChnl *chnl,U8 cmd,I8 p1,I8 p2)
{
U1 b[RMT_MAX_PKT_LEN];
if (!chnl || !chnl->type) return;
if (cmd) {
b[0]><(U8)=cmd;
b[8]><(U8)=p1;
b[16]><(U8)=p2;
RmtTxPkt(chnl,b,sizeof(U8)*3);
} else
RmtTxPkt(chnl,b,1);
}
public void RmtPutCharSC(LTChnl *chnl,I8 ch,U8 sc)
{
if (!chnl || !chnl->type) return;
if (ch)
RmtTxPkt(chnl,&ch,1);
}
public void RmtTxBuf(LTChnl *chnl,U1 *buf,U8 size)
{
if (!chnl || !chnl->type) return;
if (buf) {
RmtTxBlk(chnl,&size,sizeof(U8));
RmtTxBlk(chnl,buf,size);
}
}
public U1 *RmtRxBuf(LTChnl *chnl,U8 *size=NULL)
{
U1 *buf;
U8 *size2;
if (size) *size=0;
if (!chnl || !chnl->type) return NULL;
size2=RmtRxBlk(chnl,sizeof(U8));
buf=RmtRxBlk(chnl,*size2);
if (size) *size=*size2;
Free(size2);
return buf;
}
public void RmtTxFile(LTChnl *chnl,I1 *filename,
BoolU4 raw=TRUE)
{
U8 size;
U1 *buf;
if (!chnl || !chnl->type) return;
buf=ReadFile(filename,&size,NULL,raw);
if (buf) {
RmtTxBuf(chnl,buf,size);
Free(buf);
}
}
public U8 RmtRxFile(LTChnl *chnl,I1 *filename,
BoolU4 raw=TRUE)
{
U8 size;
U1 *buf;
if (!chnl || !chnl->type) return 0;
if (buf=RmtRxBuf(chnl,&size)) {
WriteFile(filename,buf,size,0,0,raw);
Free(buf);
}
return size;
}
public void RmtTxPutS(LTChnl *chnl,I1 *st)
{
U8 len;
if (!chnl || !chnl->type) return;
if (st) {
len=StrLen(st);
if (len) {
if (len>RMT_MAX_PKT_LEN) {
RmtTxPkt(chnl,NULL,0,RMT_RQST_PUTS_CNT);
RmtTxBuf(chnl,st,len+1);
} else
RmtTxBlk(chnl,st,len);
}
}
}
public void RmtTxPutChar(LTChnl *chnl,I8 ch)
{
if (!chnl || !chnl->type) return;
if (ch)
RmtTxPkt(chnl,&ch,1);
}
public I1 *RmtRxPutS(LTChnl *chnl,U8 *rqst=NULL)
{
U1 b[RMT_MAX_PKT_LEN];
U8 size;
U1 *buf=NULL;
if (!chnl || !chnl->type) return NULL;
if (RmtRxFifoCnt(chnl)>=2) {
RmtRxPkt(chnl,b,&size,rqst);
if (size) {
buf=MAlloc(size+1);
MemCpy(buf,b,size);
buf[size]=0;
} else
buf=MAllocZ(1);
}
return buf;
}
/***************
public U1 *RmtRqstTxBuf(U8 *size=NULL)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return NULL;
RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_BUF);
return RmtRxBuf(chnl,size);
}
public void RmtRqstRxBuf(U1 *buf,U8 size)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_BUF);
RmtTxBuf(chnl,buf,size);
}
*************/
public void RmtRqstTxFile(I1 *dst_local_filename,I1 *src_remote_filename)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_FILE);
RmtTxBuf(chnl,src_remote_filename,StrLen(src_remote_filename)+1);
RmtRxFile(chnl,dst_local_filename);
}
public void RmtRqstRxFile(I1 *src_local_filename,I1 *dst_remote_filename)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_FILE);
RmtTxBuf(chnl,dst_remote_filename,StrLen(dst_remote_filename)+1);
RmtTxFile(chnl,src_local_filename);
}
public void RmtRqstExeLocal(I1 *st)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_EXE_LOCAL);
RmtTxBuf(chnl,st,StrLen(st)+1);
}
void TelnetHostOpen(LTChnl *chnl)
{
if (!chnl || !chnl->type) return;
Fs->rmt_chnl=chnl;
}
void TelnetHostClose(LTChnl *chnl)
{
Fs->rmt_chnl=NULL;
}
void TelnetGuestOpen(LTChnl *chnl)
{
U8 i,cmd,p1,p2,rqst;
U1 *st,*st2;
if (!chnl || !chnl->type) return;
coutln "CTRL-ALT-C to exit";
try
while (TRUE) {
if (st2=RmtRxPutS(chnl,&rqst)) {
switch (rqst) {
case RMT_RQST_NONE:
PutS(st2);
break;
case RMT_RQST_GETMSG:
cmd=GetMsgNoWait(&p1,&p2,
1<<MSG_KEY_DOWN|
1<<MSG_CMD|
1<<MSG_KEY_UP);
RmtSendMsg(chnl,cmd,p1,p2);
break;
case RMT_RQST_TX_FILE:
st=RmtRxBuf(chnl);
RmtTxFile(chnl,st);
Free(st);
break;
case RMT_RQST_RX_FILE:
st=RmtRxBuf(chnl);
RmtRxFile(chnl,st);
Free(st);
break;
/***********
case RMT_RQST_TX_BUF:
break;
case RMT_RQST_RX_BUF:
RmtRxBuf(chnl);
break;
************/
case RMT_RQST_EXE_LOCAL:
st=RmtRxBuf(chnl);
ExecuteString(st);
Free(st);
break;
case RMT_RQST_PUTS_CNT:
Free(st2);
st2=RmtRxBuf(chnl);
PutS(st2);
break;
}
Free(st2);
st2=NULL;
}
SwapInNext;
}
catch
Fs->catch_except=TRUE;
for (i=0;i<5;i++) {
chnl->PutChar(chnl,RMT_PKT_CLOSE);
chnl->PutChar(chnl,RMT_PKT_CLOSE);
Sleep(50);
}
}
ext[EXT_RMT_PUTCHAR]=&RmtTxPutChar;
ext[EXT_RMT_PUTS]=&RmtTxPutS;
ext[EXT_RMT_LTFPUTCHAR]=&RmtPutCharSC;
ext[EXT_RMT_GETMSG]=&RmtGetMsg;
+821
View File
@@ -0,0 +1,821 @@
public BoolU4 Copy(I1 *f1,I1 *f2=".")
{
BoolU4 result=TRUE;
LTFileAccess *fa;
LTDirEntry *tempm,*tempm1;
U8 my_flags=0;
if (!(tempm=FindFiles(f1,&my_flags)))
return FALSE;
if (IsDir(f2)) {
fa=NewLTFileAccess(f2,TRUE);
if (fa) {
while (tempm) {
tempm1=tempm->next;
if (!(tempm->attr & LT_ATTR_DIR)) {
if (!CopySingle(tempm->full_name,tempm->name))
result=FALSE;
}
DelLTDirEntry(tempm);
tempm=tempm1;
}
DelLTFileAccess(fa);
}
return result;
} else
return CopySingle(f1,f2);
}
public BoolU4 Move(I1 *f1,I1 *f2)
{
if (Copy(f1,f2)) {
Del(f1);
return TRUE;
}
return FALSE;
}
U8 PutCopyTree(LTDirEntry *tempm,U8 src_dir_len,U8 dst_dir_len,I1 *dst_dir)
{
U8 result=0;
I1 *st;
while (tempm) {
st=MAlloc(StrLen(tempm->full_name)+dst_dir_len+2);
MemCpy(st,dst_dir,dst_dir_len);
StrCpy(st+dst_dir_len,tempm->full_name+src_dir_len);
if (tempm->attr & LT_ATTR_DIR) {
MkDir(st);
if (IsDir(st) && tempm->sub)
result+=PutCopyTree(tempm->sub,src_dir_len,dst_dir_len,dst_dir);
} else
if (CopySingle(tempm->full_name,st))
result++;
Free(st);
tempm=tempm->next;
}
return result;
}
public U8 CopyTree(I1 *src_mask,I1 *dst_mask)
{ //returns count of copied files (not dirs)
LTFileAccess *fa;
LTDirEntry *tempm=NULL;
U8 result=0,i1,i2,my_flags=(1<<FUf_RECURSE);
I1 *st1,*st2;
fa=NewLTFileAccess(src_mask,TRUE);
if (fa) {
tempm=SysFindFiles(fa->mask,&my_flags);
st1=CurDir;
DelLTFileAccess(fa);
i1=StrLen(st1);
if (i1==3) i1--;
fa=NewLTFileAccess(dst_mask,TRUE,TRUE);
if (fa) {
st2=CurDir;
i2=StrLen(st2);
if (i2==3) i2--;
result=PutCopyTree(tempm,i1,i2,st2);
DelLTFileAccess(fa);
Free(st2);
}
DelLTDirList(tempm);
Free(st1);
}
return result;
}
void DoDelTree(LTDirEntry *tempm1)
{
U8 result=0;
LTDirEntry *tempm2;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & LT_ATTR_DIR) {
if (tempm1->sub)
result+=DoDelTree(tempm1->sub);
SysDel(tempm1->full_name,TRUE);
}
DelLTDirEntry(tempm1);
tempm1=tempm2;
}
}
public BoolU4 DelTree(I1 *mask)
{
U8 my_flags=(1<<FUf_RECURSE);
if (!IsDir(mask)) {
coutln "Not a Directory";
return FALSE;
}
DoDelTree(FindFiles(mask,&my_flags));
SysDel(mask,TRUE);
SysDel(mask,FALSE);
return TRUE;
}
void DoDelMask(LTDirEntry *tempm1)
{
LTDirEntry *tempm2;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & LT_ATTR_DIR) {
if (tempm1->sub)
DoDelMask(tempm1->sub);
} else
Del(tempm1->full_name);
DelLTDirEntry(tempm1);
tempm1=tempm2;
}
}
public BoolU4 DelMask(I1 *mask)
{ //Purges select filetypes from tree
U8 my_flags=(1<<FUf_RECURSE);
if (IsDir(mask)) {
coutln "Not a Mask";
return FALSE;
}
DoDelMask(FindFiles(mask,&my_flags));
return TRUE;
}
void TouchFile(I1 *filename,I1 *attr) //LTust one file
{
U1 *temp_st=NewString(filename),
*cur_dir=NewString(filename);
LTPartition *p=DriveToPartition(*filename);
FlagsStruct f;
LTDirEntry de;
I1 buf[64];
if (FindFile(filename,&de,FALSE,TRUE)) {
if (!StrCmp(attr,"+?"))
PrintF("%-32ts %s\r\n",filename,SPrintFFlags(buf,"ST_FILE_ATTRS",de.attr));
else {
GetFFlags(&f,"ST_FILE_ATTRS",attr);
RemoveFirstSeg(cur_dir,":",temp_st);
RemoveLastSeg(cur_dir,"/",temp_st);
if (!*cur_dir)
StrCpy(cur_dir,"/");
de.attr=de.attr&f.off|f.on;
de.datetime=GetCurTimeLTDate;
NewLTDirEntry(p,cur_dir,&de,FALSE);
}
} else PutSysText("ST_FILE_NOT_FOUND");
}
void TouchList(LTDirEntry *tempm1,I1 *attr)
{
LTDirEntry *tempm2;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & LT_ATTR_DIR) {
if (tempm1->sub) {
coutln SysText("ST_SCANNING_DIRECTORY"),tempm1->full_name;
TouchList(tempm1->sub,attr);
}
} else
TouchFile(tempm1->full_name,attr);
DelLTDirEntry(tempm1);
tempm1=tempm2;
}
}
//Attr "+?" =show
// "+T" = resident
//flags "+r"=recurse
public void Touch(I1 *wild,I1 *attr="+?",I1 *flags="")
{
FlagsStruct f;
GetFFlags(&f,"ST_FILE_UTIL_FLAGS",flags);
TouchList(FindFiles(wild,&f.on),attr);
}
void FillBigEndianU2(U2 *dst,U2 w)
{
U2 *src=&w;
dst->u1[0]=src->u1[1];
dst->u1[1]=src->u1[0];
}
void FillBigEndianU4(U4 *dst,U8 d)
{
U8 *src=&d;
dst->u1[0]=src->u1[3];
dst->u1[1]=src->u1[2];
dst->u1[2]=src->u1[1];
dst->u1[3]=src->u1[0];
}
void FillU2Palindrome(U2Palindrome *dst,U2 w)
{
FillBigEndianU2(&dst->big,w);
dst->little=w;
}
void FillU4Palindrome(U4Palindrome *dst,U8 d)
{
FillBigEndianU4(&dst->big,d);
dst->little=d;
}
class CCdUserData
{
U8 location,path_entry_num,
short_dir_blks,long_dir_blks;
};
U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm,
ISODirEntry *tempi,ISODirEntry *tempi2,
U8 *cur_blk,
LTDirEntry *parent,BoolU4 write)
{
CCdUserData *tempc;
LTDirEntry *tempm1,*tempm2;
LTFile *in_file;
U1 *buf=MAlloc(CD_BLK_SIZE),*ptr1,*ptr2;
ISODirEntry *dir_blk_buf=MAllocZ(CD_BLK_SIZE*128),
*de=dir_blk_buf,*de1;
ISODirEntry *dir_blk_buf2=MAllocZ(CD_BLK_SIZE*128),
*de2=dir_blk_buf2,*de12;
U8 i,l;
tempc=parent->user_data;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,tempm->datetime);
de->flags=ISO_ATTR_DIR;
de->name_len=1;
de->name=0;
de->length+=de->name_len;
de+=de->length;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU4Palindrome(&de->location,tempc->location);
FillU4Palindrome(&de->size,tempc->short_dir_blks*CD_BLK_SIZE);
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,parent->datetime);
de->flags=ISO_ATTR_DIR;
de->name_len=1;
de->name=1;
de->length+=de->name_len;
de+=de->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,tempm->datetime);
de2->flags=ISO_ATTR_DIR;
de2->name_len=1;
de2->name=0;
de2->length=de2->length+de2->name_len;
de2+=de2->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU4Palindrome(&de2->location,tempc->location+tempc->short_dir_blks);
FillU4Palindrome(&de2->size,tempc->long_dir_blks*CD_BLK_SIZE);
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,parent->datetime);
de2->flags=ISO_ATTR_DIR;
de2->name_len=1;
de2->name=1;
de2->length+=de2->name_len;
de2+=de2->length;
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (!write) tempm1->user_data=MAllocZ(sizeof(CCdUserData));
de1=de;
de12=de2;
if (tempm1->attr & LT_ATTR_DIR) {
l=DoCreateCDFile(out_file,tempm1,de,de2,cur_blk,tempm,write);
de+=sizeof(ISODirEntry)-1+l;
de2+=sizeof(ISODirEntry)-1+l<<1;
} else {
tempc=tempm1->user_data;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU4Palindrome(&de->location,*cur_blk);
tempc->location=*cur_blk;
if (write)
coutln *cur_blk,":",tempm1->full_name;
FillU4Palindrome(&de->size,tempm1->size);
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,tempm1->datetime);
de->flags=0;
de->name_len=StrLen(tempm1->name);
StrCpy(&de->name,tempm1->name);
de->length=de->length+de->name_len;
de+=de->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU4Palindrome(&de2->location,*cur_blk);
FillU4Palindrome(&de2->size,tempm1->size);
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,tempm1->datetime);
de2->flags=0;
de2->name_len=StrLen(tempm1->name)<<1;
ptr1=&de2->name;
ptr2=&tempm1->name;
for (i=0;i<de2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
de2->length+=de2->name_len;
de2+=de2->length;
in_file=FOpen(tempm1->full_name,"r");
for (i=0;i<(FSize(in_file)+CD_BLK_SIZE-1)/CD_BLK_SIZE;i++) {
l=4;
if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)/BLK_SIZE) {
l=((FSize(in_file)+BLK_SIZE-1)/BLK_SIZE)%4;
MemSet(buf,0,CD_BLK_SIZE);
}
if (write) {
FRBlks(in_file,buf,i<<2,l);
FWBlks(out_file,buf,(*cur_blk)<<2,l);
}
*cur_blk+=1;
}
FClose(in_file);
}
if ((de1-dir_blk_buf)/CD_BLK_SIZE!=
(de -dir_blk_buf)/CD_BLK_SIZE) {
i=de1->length;
MemCpy(buf,de1,i);
MemSet(de1,0,i);
de=dir_blk_buf+((de-dir_blk_buf)/CD_BLK_SIZE)*CD_BLK_SIZE;
MemCpy(de,buf,i);
de+=i;
}
if ((de12-dir_blk_buf2)/CD_BLK_SIZE!=
(de2 -dir_blk_buf2)/CD_BLK_SIZE) {
i=de12->length;
MemCpy(buf,de12,i);
MemSet(de12,0,i);
de2=dir_blk_buf2+((de2-dir_blk_buf2)/CD_BLK_SIZE)*CD_BLK_SIZE;
MemCpy(de2,buf,i);
de2+=i;
}
tempm1=tempm2;
}
tempc=tempm->user_data;
tempi->length=sizeof(ISODirEntry)-1;
tempi->ext_attr_length=0;
tempi->flags=ISO_ATTR_DIR;
if (!tempm->name[0]) {
tempi->name_len=1;
tempi->name=1;
} else {
tempi->name_len=StrLen(tempm->name);
StrCpy(&tempi->name,tempm->name);
}
tempi->length+=tempi->name_len;
l=de+1-dir_blk_buf;
l=(l+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU4Palindrome(&tempi->size,l*CD_BLK_SIZE);
FillU4Palindrome(&tempi->location,*cur_blk);
tempc->short_dir_blks=l;
tempc->location=*cur_blk;
FillU4Palindrome(&dir_blk_buf->size,l*CD_BLK_SIZE);
FillU4Palindrome(&dir_blk_buf->location,*cur_blk);
FillU2Palindrome(&tempi->volume_sequence_num,1);
LTDateToISO(&tempi->date,tempm->datetime);
if (write)
coutln *cur_blk,":",tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf,(*cur_blk)<<2,l<<2);
*cur_blk+=l;
tempi2->length=sizeof(ISODirEntry)-1;
tempi2->ext_attr_length=0;
tempi2->flags=ISO_ATTR_DIR;
if (!tempm->name[0]) {
tempi2->name_len=1;
tempi->name=1;
} else {
tempi2->name_len=StrLen(tempm->name)<<1;
ptr1=&tempi2->name;
ptr2=&tempm->name;
for (i=0;i<tempi2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
}
tempi2->length+=tempi2->name_len;
l=de2+1-dir_blk_buf2;
l=(l+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU4Palindrome(&tempi2->size,l*CD_BLK_SIZE);
FillU4Palindrome(&tempi2->location,*cur_blk);
tempc->long_dir_blks=l;
FillU4Palindrome(&dir_blk_buf2->size,l*CD_BLK_SIZE);
FillU4Palindrome(&dir_blk_buf2->location,*cur_blk);
FillU2Palindrome(&tempi2->volume_sequence_num,1);
LTDateToISO(&tempi2->date,tempm->datetime);
if (write)
coutln *cur_blk,":",tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf2,(*cur_blk)<<2,l<<2);
*cur_blk+=l;
Free(dir_blk_buf);
Free(dir_blk_buf2);
Free(buf);
return tempi->name_len;
}
U8 CDTableLength(LTDirEntry *tempm,U8 *size1,U8 *size2,U8 cur_depth)
//returns depth
{
LTDirEntry *tempm1=tempm->sub;
U8 max_depth=cur_depth,i;
while (tempm1) {
if (tempm1->attr & LT_ATTR_DIR) {
*size1+=sizeof(ISOPathTableEntry)-2+((StrLen(tempm1->name)+1) & -0x2);
*size2+=sizeof(ISOPathTableEntry)-2+StrLen(tempm1->name)<<1;
i=CDTableLength(tempm1,size1,size2,cur_depth+1);
if (i>max_depth) max_depth=i;
}
tempm1=tempm1->next;
}
return max_depth;
}
void CDFillPathTable(LTDirEntry *tempm,
ISOPathTableEntry *itabbuf,ISOPathTableEntry *itabbuf2,
U8 parent_entry_num,BoolU4 big_endian,U8 *first_free,I8 cur_level,I8 output_level)
{
I1 *ptr1,*ptr2;
U8 i;
ISOPathTableEntry *tabbuf=*itabbuf;
ISOPathTableEntry *tabbuf2=*itabbuf2;
LTDirEntry *tempm1=tempm->sub,*tempm2;
CCdUserData *tempc;
if (cur_level==output_level) {
while (tempm1) {
if (tempm1->attr & LT_ATTR_DIR) {
tempc=tempm1->user_data;
tempc->path_entry_num=*first_free;
tabbuf->name_len=StrLen(tempm1->name);
if (big_endian) {
FillBigEndianU4(&tabbuf->blk,tempc->location);
FillBigEndianU2(&tabbuf->parent_entry_num,parent_entry_num);
} else {
tabbuf->blk=tempc->location;
tabbuf->parent_entry_num=parent_entry_num;
}
StrCpy(&tabbuf->name,tempm1->name);
tabbuf+=sizeof(ISOPathTableEntry)-2+
((StrLen(tempm1->name)+1) & -0x2);
tabbuf2->name_len=StrLen(tempm1->name)<<1;
if (big_endian) {
FillBigEndianU4(&tabbuf2->blk,tempc->location+tempc->short_dir_blks);
FillBigEndianU2(&tabbuf2->parent_entry_num,parent_entry_num);
} else {
tabbuf2->blk=tempc->location+tempc->short_dir_blks;
tabbuf2->parent_entry_num=parent_entry_num;
}
ptr1=&tabbuf2->name;
ptr2=&tempm1->name;
for (i=0;i<tabbuf2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
tabbuf2+=sizeof(ISOPathTableEntry)-2+
StrLen(tempm1->name)<<1;
*first_free+=1;
}
tempm1=tempm1->next;
}
*itabbuf=tabbuf;
*itabbuf2=tabbuf2;
}
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & LT_ATTR_DIR) {
tempc=tempm1->user_data;
CDFillPathTable(tempm1,itabbuf,itabbuf2,tempc->path_entry_num,
big_endian,first_free,cur_level+1,output_level);
}
tempm1=tempm2;
}
}
class ElTorito
{
U2 w[16];
U1 bootable; //88=bootable 00=not bootable
U1 media_type; //0=no emulation 4=hard disk
U2 load_seg; //0000->07C0
U1 sys_type;
U1 zero;
U2 sector_cnt;
U4 load_rba; //start address of virtual disk
U1 zero2[20];
};
public U8 CreateCDFile(I1 *filename,I1 src_drive,
I1 *bootfile=NULL)
{
ISOPrimaryDescriptor *iso =MAllocZ(CD_BLK_SIZE),
*iso1=MAllocZ(CD_BLK_SIZE),
*iso2=MAllocZ(CD_BLK_SIZE),
*iso3=MAllocZ(CD_BLK_SIZE);
LTDirEntry *rootdir=MAllocZ(sizeof(LTDirEntry));
U8 my_flags=(1<<FUf_RECURSE);
U8 cur_blk=0,bsize,tabsize,tabsize2,first_free,max_depth;
U4 *d;
I1 mask[8];
I1 *filename2=DefaultExtension(filename,"ISO");
ElTorito *et=MAllocZ(CD_BLK_SIZE);
U1 *buf=MAllocZ(CD_BLK_SIZE),
*bootfile_buf=NULL;
ISOPathTableEntry *tabbuf=NULL,*tabbuf2=NULL,
*itabbuf,*itabbuf2;
BoolU4 okay=TRUE;
U8 i,j;
LTFile *out_file=NULL;
ISODirEntry *tempi;
CCdUserData *tempc;
SPrintF(mask,"%c:/*",src_drive);
if (bootfile)
bootfile_buf=ReadFile(bootfile,&bsize);
rootdir->attr=LT_ATTR_DIR;
rootdir->sub=FindFiles(mask,&my_flags);
rootdir->datetime=GetCurTimeLTDate;
rootdir->user_data=MAllocZ(sizeof(CCdUserData));
tempc=rootdir->user_data;
tempc->path_entry_num=1;
if (okay) {
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf)
cur_blk+=2;
DoCreateCDFile(out_file,rootdir,
&iso->root_directory_record,
&iso2->root_directory_record,
&cur_blk,rootdir,FALSE);
tabsize=sizeof(ISOPathTableEntry);
tabsize2=sizeof(ISOPathTableEntry);
max_depth=CDTableLength(rootdir,&tabsize,&tabsize2,1);
FillU4Palindrome(&iso->path_table_size,tabsize);
FillU4Palindrome(&iso2->path_table_size,tabsize2);
tabsize=(tabsize+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize<<1;
tabsize2=(tabsize2+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize2<<1;
}
if (okay) {
if (FileAttr(filename2) & LT_ATTR_CONTIGUOUS)
out_file=FOpen(filename2,"wc",cur_blk<<2);
else
out_file=FOpen(filename2,"w",cur_blk<<2);
if (!out_file)
okay=FALSE;
}
if (okay) {
cur_blk=0;
while (cur_blk<CD_FILE_OFFSET>>2) {
FWBlks(out_file,buf,cur_blk<<2,4);
cur_blk++;
}
iso->type=ISOT_PRIMARY_VOLUME_DESC;
StrCpy(iso->id,"CD001");
iso->version=1;
FillU2Palindrome(&iso->volume_set_size,1);
FillU2Palindrome(&iso->volume_sequence_number,1);
FillU2Palindrome(&iso->logical_block_size,CD_BLK_SIZE);
iso->file_structure_version=1;
iso2->type=ISOT_SUPPLEMENTARY_DESC;
StrCpy(iso2->id,"CD001");
iso2->version=1;
FillU2Palindrome(&iso2->volume_set_size,1);
FillU2Palindrome(&iso2->volume_sequence_number,1);
FillU2Palindrome(&iso2->logical_block_size,CD_BLK_SIZE);
iso2->file_structure_version=1;
iso1->type=ISOT_BOOT_RECORD;
StrCpy(iso1->id,"CD001");
iso1->version=1;
StrCpy(iso1+7,"EL TORITO SPECIFICATION");
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf) {
d=iso1+0x47;
*d=cur_blk;
et->w[0]=1;
StrCpy(&et->w[2],"LoseThos");
et->w[15]=0xAA55;
j=0;
for (i=0;i<16;i++) //Checksum
j+=et->w[i];
et->w[14]=-j;
if (bootfile_buf)
et->bootable=0x88;
et->media_type=0; //0=no emu 2=1.44meg 4=hard drive
et->sector_cnt=4;
et->load_rba=cur_blk+1;
coutln cur_blk,": Pre Boot Blk";
FWBlks(out_file,et,cur_blk<<2,4);
cur_blk++;
coutln cur_blk,": Boot Blk";
FWBlks(out_file,bootfile_buf,cur_blk<<2,4);
cur_blk++;
}
DoCreateCDFile(out_file,rootdir,
&iso->root_directory_record,
&iso2->root_directory_record,
&cur_blk,rootdir,TRUE);
tabbuf=MAllocZ(tabsize*CD_BLK_SIZE);
iso->type_l_path_table=cur_blk;
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_directory_record;
tabbuf->blk=tempi->location.little;
tabbuf->parent_entry_num=1;
tabbuf2=MAllocZ(tabsize2*CD_BLK_SIZE);
iso2->type_l_path_table=cur_blk+tabsize;
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_directory_record;
tabbuf2->blk=tempi->location.little;
tabbuf2->parent_entry_num=1;
itabbuf=tabbuf+sizeof(ISOPathTableEntry);
itabbuf2=tabbuf2+sizeof(ISOPathTableEntry);
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,FALSE,&first_free,1,i);
coutln cur_blk,": Path Table 0";
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
coutln cur_blk,": Path Table 1";
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
MemSet(tabbuf,0,tabsize*CD_BLK_SIZE);
FillBigEndianU4(&iso->type_m_path_table,cur_blk);
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_directory_record;
tabbuf->blk=tempi->location.big;
FillBigEndianU2(&tabbuf->parent_entry_num,1);
MemSet(tabbuf2,0,tabsize2*CD_BLK_SIZE);
FillBigEndianU4(&iso2->type_m_path_table,cur_blk+tabsize);
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_directory_record;
tabbuf2->blk=tempi->location.big;
FillBigEndianU2(&tabbuf2->parent_entry_num,1);
itabbuf=tabbuf+sizeof(ISOPathTableEntry);
itabbuf2=tabbuf2+sizeof(ISOPathTableEntry);
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,TRUE,&first_free,1,i);
coutln cur_blk,": Path Table 2";
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
coutln cur_blk,": Path Table 3";
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
DelLTDirList(rootdir); //TODO: Free user_data
FillU4Palindrome(&iso->volume_space_size,cur_blk);
FillU4Palindrome(&iso2->volume_space_size,cur_blk);
FWBlks(out_file,iso,16<<2,4);
iso3->type=ISOT_TERMINATOR;
StrCpy(iso3->id,"CD001");
iso3->version=1;
if (bootfile_buf) {
FWBlks(out_file,iso1,17<<2,4);
FWBlks(out_file,iso2,18<<2,4);
FWBlks(out_file,iso3,19<<2,4);
} else {
FWBlks(out_file,iso2,17<<2,4);
FWBlks(out_file,iso3,18<<2,4);
}
} else
cur_blk=0;
FClose(out_file);
Free(tabbuf);
Free(tabbuf2);
Free(et);
Free(bootfile_buf);
Free(iso);
Free(iso1);
Free(iso2);
Free(iso3);
Free(filename2);
return cur_blk;
}
public void SetDriveTextAttr(I1 drive=0,U1 attr)
{
LTPartition *p;
try {
p=DriveToPartition(drive);
p->text_attr=attr;
} catch {
Fs->catch_except=TRUE;
}
}
public void PrintFDriveTextAttr(I1 drive=0)
{
LTPartition *p=DriveToPartition(drive);
U1 fg=p->text_attr&0xF,bg=p->text_attr>>4;
if (fg!=bg)
PrintF("$$FG,%d$$$$BG,%d$$",fg,bg);
}
U8 SizeFlattenLTDirTree(LTDirEntry *tempm)
{
U8 result=0;
while (tempm) {
result+=sizeof(LTDirEntry)-offset(LTDirEntry.start)+1;
if (tempm->attr & LT_ATTR_DIR)
result+=SizeFlattenLTDirTree(tempm->sub);
tempm=tempm->next;
}
return result+1;
}
U8 FillFlattenLTDirTree(LTDirEntry *tempm,U1 *dst)
{
U8 result=0,i;
while (tempm) {
*dst++=1;
result++;
i=sizeof(LTDirEntry)-offset(LTDirEntry.start);
MemCpy(dst,&tempm->start,i);
dst+=i;
result+=i;
if (tempm->attr & LT_ATTR_DIR) {
i=FillFlattenLTDirTree(tempm->sub,dst);
dst+=i;
result+=i;
}
tempm=tempm->next;
}
*dst=0;
return result+1;
}
public U1 *FlattenLTDirTree(LTDirEntry *tempm,U8 *size=NULL)
{
U8 i=SizeFlattenLTDirTree(tempm);
U1 *buf=MAlloc(i);
FillFlattenLTDirTree(tempm,buf);
if (*size) *size=i;
return buf;
}
U1 *DoUnflattenLTDirTree(U1 *src,LTDirEntry **tempm)
{
U8 i;
LTDirEntry *tempm1;
if (*src++) {
tempm1=MAllocZ(sizeof(LTDirEntry));
*tempm=tempm1;
i=sizeof(LTDirEntry)-offset(LTDirEntry.start);
MemCpy(&tempm1->start,src,i);
src+=i;
if (tempm1->attr & LT_ATTR_DIR)
src=DoUnflattenLTDirTree(src,&tempm1->sub);
src=DoUnflattenLTDirTree(src,&tempm1->next);
} else
*tempm=NULL;
return src;
}
public LTDirEntry *UnflattenLTDirTree(U1 *src)
{
LTDirEntry *tempm=NULL;
DoUnflattenLTDirTree(src,&tempm);
return tempm;
}
+3346
View File
File diff suppressed because it is too large. Load diff
+69
View File
@@ -0,0 +1,69 @@
$FG,2$$WW,1$'^'$FG$ Means the Control Key
$MA+A+LA+S,"Toggle Plain Text ^T","Msg(2,0x14,0x41400000414);"$
Select Text SHIFT CURSOR
$MA+A+LA,"Cut to Clipboard SHIFT DEL","Msg(2,0,0x3D300000253);"$
$MA+A+LA,"Copy to Clipboard ^INS","Msg(2,0,0x4D200000452);"$
$MA+A+LA,"Paste from Clipboard SHIFT INS","Msg(2,0,0x2D200000252);"$
$MA+A+LA,"Del Line ^Y","Msg(2,0x19,0x41500000415);"$
Begin/End of Line ^Left/^Right
Begin/End of File ^Up/^Down
$MA+A+LA,"Indent In ^N","Msg(2,0xE,0x43100000431);"$
$MA+A+LA,"Indent Out ^SHIFT N","Msg(2,0xE,0x63100000631);"$
$MA+A+LA,"Word Wrap On ^W","Msg(2,0x17,0x41100000411);"$
$MA+A+LA,"Word Wrap Off ^SHIFT W","Msg(2,0x17,0x61100000611);"$
$MA+A+LA,"Underline On ^U","Msg(2,0x15,0x41600000416);"$
$MA+A+LA,"Underline Off ^SHIFT U","Msg(2,0x15,0x61600000616);"$
$MA+A+LA,"Blink On ^B","Msg(2,2,0x43000000430);"$
$MA+A+LA,"Blink Off ^SHIFT B","Msg(2,2,0x63000006300);"$
$MA+A+LA,"Invert Color On ^Z","Msg(2,0x1A,0x42C0000042C);"$
$MA+A+LA,"Invert Color Off ^SHIFT Z","Msg(2,0x1A,0x62C0000062C);"$
$MA+A+LA,"Superscript ^P","Msg(2,0x10,0x41900000419);"$
$MA+A+LA,"Normal ^SHIFT P","Msg(2,0x10,0x61900000619);"$
$MA+A+LA,"Subscript ^ALT P","Msg(2,0x10,0xC1900000C19);"$
$MA+A+LA,"Insert Dollar Cmd ^L","Msg(2,0xC,0x42600000426);"$
$MA+A+LA,"Insert Graphic Cmd ^R","Msg(2,0x12,0x41300000413);"$
$MA+A+LA,"Macro Capture and Play F2","Msg(2,0,0x3C0000003C);"$
$MA+A+LA,"Page Break ^ENTER","Msg(2,0xD,0x41C0000041C);"$
$MA+A+LA,"Print PrintScreen","Msg(2,0,0xB7000000B7);"$
$MA+A+LA,"Goto Favorites ^SHIFT F","Msg(2,6,0x62100000621);"$
$MA+A+LA,"Find/Replace ^F","Msg(2,6,0x42100000421);"$
$MA+A+LA,"Find Next F3","Msg(2,0,0x3D0000003D);"$
$MA+A+LA,"Go to Line ^G","Msg(2,7,0x42200000422);"$
$MA+A+LA,"Save ^S","Msg(2,0x13,0x41F0000041F);"$
$MA+A+LA,"Save As ^A","Msg(2,1,0x41E0000041E);"$
$MA+A+LA,"Quit No Save ^Q","Msg(2,0x11,0x41000000410);"$
$MA+A+LA,"Quit and Save ESC","Msg(2,0x1B,0x0100000001);"$
$TR,"Cmd Line Issues"$
$ID,2$$FG$* CTRL-SHIFT-ENTER can be used to insert a carriage return without issuing a cmd. This is useful when you have scrolled-up and wish to enter a cmd on a blank line.
* The last semicolon on the line is converted to a double semicolon because the compiler looks ahead before doing a cmd. This normally has no negative effect, but when entering "if" statements with "else" clauses it presents problems.
$ID,-2$$TR,"Hot Keys"$
$ID,2$$FG,9$CTRL ALT DEL$FG$ Reboots
$FG,9$CTRL ALT ESC$FG$ Spawns new task
$FG,9$CTRL ALT TAB$FG$ Switches tasks
$FG,9$CTRL ALT X$FG$ Kills current task
$FG,9$$FG,9$CTRL ALT C$FG$ Breaks current program
$FG,9$WINDOWS KEY$FG$ Activates Menu/Help/Macro area
$FG,9$CTRL FUNCTION KEY$FG$ Enters autocomplete word
$FG,9$CTRL SHIFT-FUNCTION KEY$FG$ Does man page on symbol
$ID,-2$$TR,"Debugging"$
$ID,2$F9 Toggle Breakpoint
SHIFT-F9 Clear ALL Breakpoints
F5 Go
SHIFT-F5 Single-Step
$ID,-2$
* If "MENU" appears on the title bar, you can click it with a mouse.
+172
View File
@@ -0,0 +1,172 @@
public class U1Fifo
{
U1 *buf;
U8 mask,in_ptr,out_ptr;
};
public U1Fifo *NewU1Fifo(U8 size)
{
U1Fifo *f;
f=MAlloc(sizeof(U1Fifo));
f->buf=MAlloc(size);
f->mask=size-1;
f->in_ptr=0;
f->out_ptr=0;
return f;
}
public void DelU1Fifo(U1Fifo *f)
{
Free(f->buf);
Free(f);
}
public BoolU4 U1FifoInsert(U1Fifo *f,U1 ch)
{
U8 old_flags=GetFlags,
new_in_ptr;
Cli;
new_in_ptr=(f->in_ptr+1)&f->mask;
if (new_in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
f->buf[f->in_ptr]=ch;
f->in_ptr=new_in_ptr;
SetFlags(old_flags);
return TRUE;
}
}
public BoolU4 U1FifoRemove(U1Fifo *f,U1 *ch)
{
U8 old_flags=GetFlags;
Cli;
if (f->in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
*ch=f->buf[f->out_ptr];
f->out_ptr=(f->out_ptr+1)&f->mask;
SetFlags(old_flags);
return TRUE;
}
}
public BoolU4 U1FifoPeek(U1Fifo *f,U1 *ch)
{
U8 old_flags=GetFlags;
Cli;
if (f->in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
*ch=f->buf[f->out_ptr];
SetFlags(old_flags);
return TRUE;
}
}
public void U1FifoFlush(U1Fifo *f)
{
f->out_ptr=f->in_ptr;
}
public U8 U1FifoCnt(U1Fifo *f)
{
U8 result,old_flags=GetFlags;
Cli;
if (f->out_ptr>f->in_ptr)
result=f->mask+1-(f->out_ptr-f->in_ptr);
else
result=f->in_ptr-f->out_ptr;
SetFlags(old_flags);
return result;
}
public class U4Fifo
{
U4 *buf;
U8 mask,in_ptr,out_ptr;
};
public U4Fifo *NewU4Fifo(U8 size)
{
U4Fifo *f;
f=MAlloc(sizeof(U4Fifo));
f->buf=MAlloc(size*sizeof(U4));
f->mask=size-1;
f->in_ptr=0;
f->out_ptr=0;
return f;
}
public void DelU4Fifo(U4Fifo *f)
{
Free(f->buf);
Free(f);
}
public BoolU4 U4FifoInsert(U4Fifo *f,U4 d)
{
U8 old_flags=GetFlags,
new_in_ptr;
Cli;
new_in_ptr=(f->in_ptr+1)&f->mask;
if (new_in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
f->buf[f->in_ptr]=d;
f->in_ptr=new_in_ptr;
SetFlags(old_flags);
return TRUE;
}
}
public BoolU4 U4FifoRemove(U4Fifo *f,U4 *d)
{
U8 old_flags=GetFlags;
Cli;
if (f->in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
*d=f->buf[f->out_ptr];
f->out_ptr=(f->out_ptr+1)&f->mask;
SetFlags(old_flags);
return TRUE;
}
}
public BoolU4 U4FifoPeek(U1Fifo *f,U4 *d)
{
U8 old_flags=GetFlags;
Cli;
if (f->in_ptr==f->out_ptr) {
SetFlags(old_flags);
return FALSE;
} else {
*d=f->buf[f->out_ptr];
SetFlags(old_flags);
return TRUE;
}
}
public void U4FifoFlush(U4Fifo *f)
{
f->out_ptr=f->in_ptr;
}
public U8 U4FifoCnt(U4Fifo *f)
{
U8 result,old_flags=GetFlags;
Cli;
if (f->out_ptr>f->in_ptr)
result=f->mask+1-(f->out_ptr-f->in_ptr);
else
result=f->in_ptr-f->out_ptr;
SetFlags(old_flags);
return result;
}
+834
View File
@@ -0,0 +1,834 @@
I8 PopUpGrElemType(BoolU4 new_picture)
{
I8 i;
Ltf *l=LtfNew;
LtfPutS(l,"$$MU,\"Color (4-bit)\" GRET_COLOR4$$\r\n");
LtfPutS(l,"$$MU,\"Width\" GRET_WIDTH$$\r\n");
LtfPutS(l,"$$MU,\"Point\" GRET_POINT$$\r\n");
LtfPutS(l,"$$MU,\"Line\" GRET_LINE$$\r\n");
LtfPutS(l,"$$MU,\"PolyLine\" GRET_POLYLINE$$\r\n");
LtfPutS(l,"$$MU,\"PolyPoint\" GRET_POLYPOINT$$\r\n");
LtfPutS(l,"$$MU,\"BSpline2\" GRET_BSPLINE2$$\r\n");
LtfPutS(l,"$$MU,\"BSpline3\" GRET_BSPLINE3$$\r\n");
LtfPutS(l,"$$MU,\"BSpline2 Closed\" GRET_BSPLINE2_CLOSED$$\r\n");
LtfPutS(l,"$$MU,\"BSpline3 Closed\" GRET_BSPLINE3_CLOSED$$\r\n");
LtfPutS(l,"$$MU,\"End\" GRET_END$$\r\n");
if (new_picture)
LtfPutS(l,"$$MU,\"Cancel\" -1$$\r\n");
LtfPutS(l,"\r\nNote: Right-Click to get back to this menu.\r\n"
"Press ESC to Exit, CTRL-Q to abort.\r\n");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I8 PopUpColor()
{
I8 i;
Ltf *l=LtfNew;
for (i=0;i<16;i++)
LtfPrintF(l,"$$BM %d$$$$MU,\"________________\" %d$$\r\n",i,i);
LtfPutS(l,"$$BM WHITE$$$$MU,\"DEFAULT\" -1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I8 PopUpWidth()
{
I8 i;
Ltf *l=LtfNew;
for (i=0;i<16;i++)
LtfPrintF(l,"$$MU,\"%d\" %d$$\r\n",i,i);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
I8 GrXOffsets[8]={-1,0,1,-1,1,-1,0,1},
GrYOffsets[8]={-1,-1,-1,0,0,1,1,1};
U8 GrElemBaseSize(I8 type,BoolU4 queue=TRUE)
{
U8 i=(queue) ? offset(GrElem.start):0;
switch (type) {
case GRET_COLOR4:
i+=1+offset(GrElem.color4)-offset(GrElem.start);
break;
case GRET_COLOR24:
i+=3+offset(GrElem.color24)-offset(GrElem.start);
break;
case GRET_WIDTH:
i+=offset(GrElem.y1)-offset(GrElem.start);
break;
case GRET_POINT:
i+=offset(GrElem.x2)-offset(GrElem.start);
break;
case GRET_LINE:
i+=sizeof(GrElem)-offset(GrElem.start);
break;
case GRET_POLYLINE:
case GRET_POLYPOINT:
case GRET_BSPLINE2:
case GRET_BSPLINE3:
case GRET_BSPLINE2_CLOSED:
case GRET_BSPLINE3_CLOSED:
i+=offset(GrElem.y1)-offset(GrElem.start);
break;
case GRET_SHIFT:
i+=offset(GrElem.x2)-offset(GrElem.start);
break;
case GRET_END:
i+=offset(GrElem.x1)-offset(GrElem.start);
break;
}
return i;
}
U8 GrElemSize(GrElem *tempg,BoolU4 queue=TRUE)
{
U8 i=GrElemBaseSize(tempg->type,queue);
switch (tempg->type) {
case GRET_POLYLINE:
i+=tempg->num<<1*sizeof(I4);
break;
case GRET_POLYPOINT:
i+=sizeof(I4)<<1+(tempg->num*3+7)>>3;
break;
case GRET_BSPLINE2:
case GRET_BSPLINE3:
case GRET_BSPLINE2_CLOSED:
case GRET_BSPLINE3_CLOSED:
i+=tempg->num*sizeof(P3I4);
break;
}
return i;
}
//If you do not enter a color or width into
//a GrElem, you can pass a color and width
//when you plot it. "colorbase" is the color of
//the background you are drawing on.
public void GrElemsPlot(GrBitMap *base,I8 x,I8 y,I8 z,U1 *elems,U8 colorbase)
{
GrElem *tempg=elems-offset(GrElem.start);
U8 i,j;
I8 x1,y1,x2,y2;
I4 *ptr;
I8 cur_sub_GrElem_num=0;
P3I4 *p;
while (tempg->type) {
base->cur_sub_GrElem=cur_sub_GrElem_num++;
switch (tempg->type) {
case GRET_COLOR4:
base->color=colorbase^tempg->color4;
break;
case GRET_COLOR24:
base->color=colorbase^tempg->color24;
break;
case GRET_WIDTH:
base->pen_width=tempg->width;
break;
case GRET_POINT:
GrPlot3(base,tempg->x1+x,tempg->y1+y,0);
break;
case GRET_SHIFT:
x+=tempg->x1;
y+=tempg->y1;
break;
case GRET_LINE:
GrLine3(base,tempg->x1+x,tempg->y1+y,0,tempg->x2+x,tempg->y2+y,0);
break;
case GRET_POLYLINE:
ptr=&tempg->y1;
x1=ptr[0];
y1=ptr[1];
for (i=1;i<tempg->num;i++) {
x2=ptr[i<<1];
y2=ptr[i<<1+1];
GrLine3(base,x1+x,y1+y,0,x2+x,y2+y,0);
x1=x2;y1=y2;
}
break;
case GRET_POLYPOINT:
ptr=&tempg->y1;
x1=ptr[0];
y1=ptr[1];
ptr=ptr+sizeof(I4)<<1;
for (i=0;i<tempg->num;i++) {
GrPlot3(base,x1+x,y1+y,0);
j=Bt(ptr,i*3)+Bt(ptr,i*3+1)<<1+Bt(ptr,i*3+2)<<2;
x1+=GrXOffsets[j];
y1+=GrYOffsets[j];
}
break;
case GRET_BSPLINE2:
p=&tempg->y1;
for (i=0;i<tempg->num;i++) {
p[i].x+=x;
p[i].y+=y;
}
Gr2BSpline3(base,p,tempg->num,FALSE);
for (i=0;i<tempg->num;i++) {
p[i].x-=x;
p[i].y-=y;
}
break;
case GRET_BSPLINE3:
p=&tempg->y1;
for (i=0;i<tempg->num;i++) {
p[i].x+=x;
p[i].y+=y;
}
Gr3BSpline3(base,p,tempg->num,FALSE);
for (i=0;i<tempg->num;i++) {
p[i].x-=x;
p[i].y-=y;
}
break;
case GRET_BSPLINE2_CLOSED:
p=&tempg->y1;
for (i=0;i<tempg->num;i++) {
p[i].x+=x;
p[i].y+=y;
}
Gr2BSpline3(base,p,tempg->num,TRUE);
for (i=0;i<tempg->num;i++) {
p[i].x-=x;
p[i].y-=y;
}
break;
case GRET_BSPLINE3_CLOSED:
p=&tempg->y1;
for (i=0;i<tempg->num;i++) {
p[i].x+=x;
p[i].y+=y;
}
Gr3BSpline3(base,p,tempg->num,TRUE);
for (i=0;i<tempg->num;i++) {
p[i].x-=x;
p[i].y-=y;
}
break;
}
tempg+=GrElemSize(tempg,FALSE);
}
}
public void GrSetOrigin(GrElem *root,I8 dx,I8 dy,I8 dz)
{
U8 i;
I4 *ptr;
P3I4 *p;
GrElem *tempg=root->next;
while (tempg!=root) {
switch (tempg->type) {
case GRET_POINT:
tempg->x1+=dx;
tempg->y1+=dy;
break;
case GRET_LINE:
tempg->x1+=dx;
tempg->y1+=dy;
tempg->x2+=dx;
tempg->y2+=dy;
break;
case GRET_POLYLINE:
ptr=&tempg->y1;
ptr[0]+=dx;
ptr[1]+=dy;
for (i=1;i<tempg->num;i++) {
ptr[i<<1]+=dx;
ptr[i<<1+1]+=dy;
}
break;
case GRET_POLYPOINT:
ptr=&tempg->y1;
ptr[0]+=dx;
ptr[1]+=dy;
break;
case GRET_BSPLINE2:
case GRET_BSPLINE3:
case GRET_BSPLINE2_CLOSED:
case GRET_BSPLINE3_CLOSED:
p=&tempg->y1;
for (i=0;i<tempg->num;i++) {
p[i].x+=dx;
p[i].y+=dy;
}
break;
}
tempg=tempg->next;
}
}
void GrPolyPointPlot(GrElem *root,I8 x,I8 y,I8 z)
{
GrElem *tempg;
tempg=MAllocZ(GrElemBaseSize(GRET_POINT));
tempg->type=GRET_POINT;
tempg->x1=x;
tempg->y1=y;
InsQue(tempg,root->last);
}
void GrElemsDel(GrElem *root)
{
GrElem *tempg,*tempg1;
tempg=root->next;
while (tempg!=root) {
tempg1=tempg->next;
Free(tempg);
tempg=tempg1;
}
}
GrElem *GrElemsFromQueue(GrElem *root,U4 *size=NULL)
{
U8 s,my_size=GrElemBaseSize(GRET_END,FALSE);
GrElem *tempg,*result,*dst;
tempg=root->next;
while (tempg!=root) {
my_size+=GrElemSize(tempg,FALSE);
tempg=tempg->next;
}
result=MAlloc(my_size);
dst=result;
tempg=root->next;
while (tempg!=root) {
s=GrElemSize(tempg,FALSE);
MemCpy(dst,&tempg->type,s);
dst+=s;
tempg=tempg->next;
}
*dst=GRET_END;
if (size) *size=my_size;
return result;
}
GrElem *GrElemsToQueue(GrElem *elems)
{
U8 s;
GrElem *result=MAllocZ(sizeof(GrElem)),
*tempg=elems-offset(GrElem.start),
*tempg1;
result->next=result;
result->last=result;
while (tempg->type) {
tempg1=MAlloc(GrElemSize(tempg,TRUE));
s=GrElemSize(tempg,FALSE);
MemCpy(&tempg1->type,&tempg->type,s);
InsQue(tempg1,result->last);
tempg+=s;
}
return result;
}
public I4 PopUpPickGrElem(GrElem *root)
{
Ltf *l=LtfNew;
GrElem *tempg;
I4 cur_num=0;
tempg=root->next;
while (tempg!=root) {
LtfPrintF(l,"$$MU,\"%Z\",%d$$\r\n",
tempg->type,"ST_GRELEM_TYPES",cur_num++);
tempg=tempg->next;
}
LtfPrintF(l,"$$MU,\"END\",%d$$\r\n",cur_num);
cur_num=PopUpMenu(l);
LtfDel(l);
return cur_num;
}
#define GED_PICK_TEXT 1
#define GED_PICK_GRAPHICALLY 2
#define GED_SET_ORIGIN 3
#define GED_SHIFT_ORIGIN 4
#define GED_INSERT 5
#define GED_DELETE 6
#define GED_EDIT 7
#define GED_END 8
#define GED_CANCEL -1
I8 PopUpGrElemsEditChoice()
{
I8 i;
Ltf *l=LtfNew;
LtfPutS(l,"$$MU,\"Pick from text\",GED_PICK_TEXT$$\r\n");
LtfPutS(l,"$$MU,\"Pick graphically\",GED_PICK_GRAPHICALLY$$\r\n");
LtfPutS(l,"$$MU,\"Set Origin\",GED_SET_ORIGIN$$\r\n");
LtfPutS(l,"$$MU,\"Insert Shift Origin\",GED_SHIFT_ORIGIN$$\r\n");
LtfPutS(l,"$$MU,\"Insert\",GED_INSERT$$\r\n");
LtfPutS(l,"$$MU,\"Delete\",GED_DELETE$$\r\n");
// LtfPutS(l,"$$MU,\"Edit\",GED_EDIT$$\r\n");
LtfPutS(l,"$$MU,\"End\",GED_END$$\r\n");
LtfPutS(l,"$$MU,\"Cancel\",GED_CANCEL$$\r\n");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
GrElem *GrNumToQueue(GrElem *root,I8 num,I8 *x=NULL,I8 *y=NULL)
{
I8 xx=0,yy=0;
GrElem *result=root->next;
while (result!=root && num--) {
if (result->type==GRET_SHIFT) {
xx+=result->x1;
yy+=result->y1;
}
result=result->next;
}
if (x) *x=xx;
if (y) *y=yy;
return result;
}
void GrEditUpdate(LtfBinEntry *tempb,GrElem *root)
{
BoolU4 old_preempt=Preempt(OFF);
Free(tempb->data);
tempb->data=GrElemsFromQueue(root,&tempb->size);
Preempt(old_preempt);
}
I4 GrElOffset[9]={0,1,2,3,0,4,5,6,7};
BoolU4 GrElemsInsert(LtfBinEntry *tempb,I8 *cur_num,GrElem *root,I8 x,I8 y,BoolU4 new_picture)
{
I8 i,j,cmd,x1,y1,x2,y2,x3,y3,p1,p2;
I4 *ptr;
U8 color=ROP_EQU^GR_BLACK^((Fs->text_attribute>>4)&15);
BoolU4 old_ip_double=Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK);
I8 eletype=-2;
GrElem root2,*tempg,*tempg1,*tempg2,*insert_point;
U8 num;
BoolU4 old_inhibit=ip_inhibit_win_operations;
GrBitMap *base=GrNew(grbase);
I8 width=1;
P3I4 *p;
insert_point=GrNumToQueue(root,*cur_num,&x1,&y1);
x+=x1; y+=y1;
ip_inhibit_win_operations=TRUE;
while (TRUE) {
GrClear;
if (eletype==-2) {
ip_inhibit_win_operations=FALSE;
i=PopUpGrElemType(new_picture);
if (i>=-1)
eletype=i;
ip_inhibit_win_operations=TRUE;
}
switch (eletype) {
case GRET_COLOR4:
ip_inhibit_win_operations=FALSE;
i=PopUpColor;
if (i>=0) {
color=ROP_EQU|i;
tempg=MAlloc(GrElemBaseSize(GRET_COLOR4));
tempg->type=GRET_COLOR4;
tempg->color4=color;
InsQue(tempg,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
}
ip_inhibit_win_operations=TRUE;
eletype=-2;
color^=((Fs->text_attribute>>4)&15);
base->color=color;
break;
case GRET_COLOR24:
eletype=-2;
break;
case GRET_WIDTH:
ip_inhibit_win_operations=FALSE;
i=PopUpWidth;
if (i>=1) {
width=i;
tempg=MAlloc(GrElemBaseSize(GRET_WIDTH));
tempg->type=GRET_WIDTH;
tempg->width=width;
InsQue(tempg,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
base->pen_width=width;
}
ip_inhibit_win_operations=TRUE;
eletype=-2;
break;
}
if (eletype!=-2) {
cmd=0;p1=0;p2=0;
if (eletype!=GRET_END && eletype!=-1) {
cmd=GetMsg(&p1,&p2,
(1<<MSG_KEY_DOWN)+(1<<MSG_IP_L_DOWN)+
(1<<MSG_IP_R_UP));
if (cmd==MSG_IP_R_UP)
eletype=-2;
}
if (eletype==GRET_END || eletype==-1
|| cmd==MSG_KEY_DOWN) {
if (eletype==GRET_END || eletype==-1
|| p1==CH_CTRLQ || p1==CH_ESC) {
AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double);
ip_inhibit_win_operations=old_inhibit;
GrDel(base);
return eletype==GRET_END || p1==CH_ESC;
}
} else {
switch (eletype) {
case GRET_LINE:
x1=p1; y1=p2;
x2=p1; y2=p2;
do {
base->color=color&0xFFFFFF|ROP_OR;
GrLine3(base,x1,y1,0,x2,y2,0);
cmd=GetMsg(&p1,&p2,
(1<<MSG_IP_L_UP)+(1<<MSG_IP_MOVE));
base->color=color&0xFFFFFF|ROP_NAND;
GrLine3(base,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
} while (cmd!=MSG_IP_L_UP);
base->color=color&0xFFFFFF|ROP_EQU;
GrLine3(base,x1,y1,0,x2,y2,0);
tempg=MAlloc(GrElemBaseSize(GRET_LINE));
tempg->type=GRET_LINE;
tempg->x1=x1-x;
tempg->y1=y1-y;
tempg->x2=x2-x;
tempg->y2=y2-y;
InsQue(tempg,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
break;
case GRET_POINT:
x1=p1; y1=p2;
base->color=color;
GrPlot3(base,x1,y1,0);
tempg=MAlloc(GrElemBaseSize(GRET_POINT));
tempg->type=GRET_POINT;
tempg->x1=x1-x;
tempg->y1=y1-y;
InsQue(tempg,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
break;
case GRET_POLYLINE:
root2.next=&root2;
root2.last=&root2;
num=0;
x3=p1-x; y3=p2-y;
x1=p1; y1=p2;
x2=p1; y2=p2;
do {
do {
base->color=color&0xFFFFFF|ROP_OR;
GrLine3(base,x1,y1,0,x2,y2,0);
cmd=GetMsg(&p1,&p2,
(1<<MSG_IP_L_UP)+(1<<MSG_IP_MOVE)+
(1<<MSG_IP_R_UP));
base->color=color&0xFFFFFF|ROP_NAND;
GrLine3(base,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
} while (cmd!=MSG_IP_L_UP && cmd!=MSG_IP_R_UP);
base->color=color&0xFFFFFF|ROP_EQU;
if (cmd==MSG_IP_L_UP) {
GrLine3(base,x1,y1,0,x2,y2,0);
tempg=MAlloc(GrElemBaseSize(GRET_POINT));
tempg->type=GRET_POINT;
tempg->x1=x2-x;
tempg->y1=y2-y;
InsQue(tempg,root2.last);
x1=x2;y1=y2;
num++;
}
} while (cmd!=MSG_IP_R_UP);
if (num) {
tempg2=MAllocZ(GrElemBaseSize(GRET_POLYLINE)+
(num+1)<<1*sizeof(I4));
ptr=&tempg2->y1;
tempg=root2.next;
ptr[0]=x3;
ptr[1]=y3;
ptr+=sizeof(I4)<<1;
for (i=0;i<num;i++) {
tempg1=tempg->next;
ptr[i<<1]=tempg->x1;
ptr[i<<1+1]=tempg->y1;
Free(tempg);
tempg=tempg1;
}
tempg2->type=GRET_POLYLINE;
tempg2->num=num+1;
InsQue(tempg2,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
}
break;
case GRET_POLYPOINT:
root2.next=&root2;
root2.last=&root2;
x3=p1-x; y3=p2-y;
x1=p1; y1=p2;
x2=p1; y2=p2;
base->color=color&0xFFFFFF|ROP_EQU;
do {
cmd=GetMsg(&p1,&p2,
(1<<MSG_IP_L_UP)+(1<<MSG_IP_MOVE));
x2=p1; y2=p2;
GrLine3(base,x1,y1,0,x2,y2,0);
Line(&root2,x1-x,y1-y,0,x2-x,y2-y,0,&GrPolyPointPlot);
x1=x2;y1=y2;
num++;
} while (cmd!=MSG_IP_L_UP);
num=0;
tempg=root2.next;
x1=x3;y1=y3;
while (tempg!=&root2) {
tempg1=tempg->next;
if (tempg->x1==x1 && tempg->y1==y1) {
RemQue(tempg);
Free(tempg);
} else {
num++;
x1=tempg->x1;
y1=tempg->y1;
}
tempg=tempg1;
}
tempg2=MAllocZ(GrElemBaseSize(GRET_POLYPOINT)+
sizeof(I4)*2+(num*3+7)>>3);
ptr=&tempg2->y1;
tempg=root2.next;
ptr[0]=x3;
ptr[1]=y3;
ptr+=sizeof(I4)<<1;
x1=x3;y1=y3;
for (i=0;i<num;i++) {
tempg1=tempg->next;
j=GrElOffset[SignI8(tempg->x1-x1)+1+3*(SignI8(tempg->y1-y1)+1)];
x1=tempg->x1;y1=tempg->y1;
if (j&1) Bts(ptr,i*3);
if (j&2) Bts(ptr,i*3+1);
if (j&4) Bts(ptr,i*3+2);
Free(tempg);
tempg=tempg1;
}
tempg2->type=GRET_POLYPOINT;
tempg2->num=num+1;
InsQue(tempg2,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
break;
case GRET_BSPLINE2:
case GRET_BSPLINE3:
case GRET_BSPLINE2_CLOSED:
case GRET_BSPLINE3_CLOSED:
root2.next=&root2;
root2.last=&root2;
num=0;
x3=p1-x; y3=p2-y;
x1=p1; y1=p2;
x2=p1; y2=p2;
do {
do {
base->color=color&0xFFFFFF|ROP_OR;
GrLine3(base,x1,y1,0,x2,y2,0);
cmd=GetMsg(&p1,&p2,
(1<<MSG_IP_L_UP)+(1<<MSG_IP_MOVE)+
(1<<MSG_IP_R_UP));
base->color=color&0xFFFFFF|ROP_NAND;
GrLine3(base,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
} while (cmd!=MSG_IP_L_UP && cmd!=MSG_IP_R_UP);
base->color=color&0xFFFFFF|ROP_EQU;
if (cmd==MSG_IP_L_UP) {
GrLine3(base,x1,y1,0,x2,y2,0);
tempg=MAlloc(GrElemBaseSize(GRET_POINT));
tempg->type=GRET_POINT;
tempg->x1=x2-x;
tempg->y1=y2-y;
InsQue(tempg,root2.last);
x1=x2;y1=y2;
num++;
}
} while (cmd!=MSG_IP_R_UP);
if (num) {
tempg2=MAllocZ(GrElemBaseSize(GRET_POLYLINE)+
(num+1)*sizeof(P3I4));
p=&tempg2->y1;
tempg=root2.next;
p[0].x=x3;
p[0].y=y3;
p+=sizeof(P3I4);
for (i=0;i<num;i++) {
tempg1=tempg->next;
p[i].x=tempg->x1;
p[i].y=tempg->y1;
Free(tempg);
tempg=tempg1;
}
tempg2->type=eletype;
tempg2->num=num+1;
InsQue(tempg2,insert_point->last);
GrEditUpdate(tempb,root);
*cur_num=*cur_num+1;
}
break;
}
}
}
}
}
void EditInsertGraphic(Ltf *l,I8 x,I8 y)
{
BoolU4 old_preempt=Preempt(OFF);
LtfEntry *ll;
LtfBinEntry *tempb;
I8 cur_num=0;
GrElem *root;
tempb=MAllocZ(sizeof(LtfBinEntry));
tempb->type=LTFBT_ELEMENT_GRAPH;
tempb->size=GrElemBaseSize(GRET_END,FALSE);
tempb->data=MAllocZ(tempb->size);
ll=MAllocZ(sizeof(LtfEntry));
ll->display=NewString("");
ll->plain_text=MSPrintF("PI %d",l->cur_bin_num);
ll->bin_num=l->cur_bin_num;
tempb->num=l->cur_bin_num++;
ll->type=LTFT_PICTURE;
ll->flags=LTFLF_HAS_BIN;
ll->bin_data=tempb;
InsQue(tempb,l->bin_root.last);
LtfInsert(l,ll);
Preempt(old_preempt);
root=GrElemsToQueue(tempb->data);
if (!GrElemsInsert(tempb,&cur_num,root,x,y,TRUE)) {
Preempt(OFF);
RemQue(ll);
Free(ll);
Free(ll->display);
Free(ll->plain_text);
RemQue(tempb);
Free(tempb->data);
Preempt(old_preempt);
}
GrElemsDel(root);
}
public void LtfPutGrElem(Ltf *l,U1 *elems,U8 size)
{
BoolU4 old_preempt=Preempt(OFF);
LtfEntry *ll;
LtfBinEntry *tempb;
tempb=MAllocZ(sizeof(LtfBinEntry),l->mem_tss);
tempb->type=LTFBT_ELEMENT_GRAPH;
tempb->size=size;
tempb->data=MAlloc(size,l->mem_tss);
MemCpy(tempb->data,elems,size);
ll=MAllocZ(sizeof(LtfEntry),l->mem_tss);
ll->display=NewString("",l->mem_tss);
ll->plain_text=MSPrintF("PI %d",l->cur_bin_num); //TODO:mem_tss
ll->bin_num=l->cur_bin_num;
tempb->num=l->cur_bin_num++;
ll->type=LTFT_PICTURE;
ll->flags=LTFLF_HAS_BIN;
ll->bin_data=tempb;
InsQue(tempb,l->bin_root.last);
LtfInsert(l,ll);
Preempt(old_preempt);
}
public void PutGrElem(U1 *elems,U8 size)
{
Ltf *l=Fs->cur_ltf;
if (l)
LtfPutGrElem(l,elems,size);
}
void EditExistingGraphic(Ltf *l,I8 x,I8 y)
{
BoolU4 *old_preempt=Preempt(OFF);
LtfEntry *ll=l->cur_entry;
LtfBinEntry *tempb=ll->bin_data;
I8 i,cur_num=0,cmd,p1,p2,old_size=tempb->size,xx,yy;
GrElem *cur_elem,*old_GrElem=tempb->data,
*root=GrElemsToQueue(old_GrElem),*tempg,*insert_point;
BoolU4 old_inhibit=ip_inhibit_win_operations;
BoolU4 old_ip_double=Bt(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK);
tempb->data=MAllocIdentical(old_GrElem);
Preempt(old_preempt);
do {
i=PopUpGrElemsEditChoice;
switch (i) {
case GED_PICK_TEXT:
cur_num=PopUpPickGrElem(root);
break;
case GED_PICK_GRAPHICALLY:
l->cur_GrElem=tempb->data;
GetMsg(&p1,&p2,1<<MSG_IP_L_UP);
cur_num=l->cur_sub_GrElem;
l->cur_GrElem=NULL;
break;
case GED_SET_ORIGIN:
GetMsg(&p1,&p2,1<<MSG_IP_L_UP);
GrSetOrigin(root,x-p1,y-p2,0);
GrEditUpdate(tempb,root);
break;
case GED_SHIFT_ORIGIN:
ip_inhibit_win_operations=TRUE;
Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK);
insert_point=GrNumToQueue(root,cur_num);
tempg=MAlloc(GrElemBaseSize(GRET_SHIFT));
tempg->type=GRET_SHIFT;
tempg->x1=0;
tempg->y1=0;
InsQue(tempg,insert_point->last);
GetMsg(&p1,&p2,1<<MSG_IP_L_DOWN);
xx=p1; yy=p2;
do {
cmd=GetMsg(&p1,&p2,
(1<<MSG_IP_L_UP)+(1<<MSG_IP_MOVE));
tempg->x1=p1-xx;
tempg->y1=p2-yy;
GrEditUpdate(tempb,root);
} while (cmd!=MSG_IP_L_UP);
AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double);
ip_inhibit_win_operations=old_inhibit;
break;
case GED_INSERT:
GrElemsInsert(tempb,&cur_num,root,x,y,FALSE);
break;
case GED_DELETE:
cur_elem=GrNumToQueue(root,cur_num);
if (cur_elem!=root) {
RemQue(cur_elem);
Free(cur_elem);
GrEditUpdate(tempb,root);
}
break;
case GED_EDIT:
break;
}
} while (i!=GED_CANCEL && i!=GED_END);
Preempt(OFF);
if (i==GED_END)
Free(old_GrElem);
else {
Free(tempb->data);
tempb->data=old_GrElem;
tempb->size=old_size;
}
Preempt(old_preempt);
GrElemsDel(root);
}
+425
View File
@@ -0,0 +1,425 @@
ALIGN 8,0x90
REVERSE_BITS_TABLE::
$FG$$BG$ DU1 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0;
DU1 0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0;
DU1 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8;
DU1 0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8;
DU1 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4;
DU1 0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4;
DU1 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC;
DU1 0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC;
DU1 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2;
DU1 0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2;
DU1 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA;
DU1 0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA;
DU1 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6;
DU1 0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6;
DU1 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE;
DU1 0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE;
DU1 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1;
DU1 0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1;
DU1 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9;
DU1 0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9;
DU1 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5;
DU1 0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5;
DU1 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED;
DU1 0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD;
DU1 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3;
DU1 0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3;
DU1 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB;
DU1 0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB;
DU1 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7;
DU1 0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7;
DU1 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF;
DU1 0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF;
$FU$$FG$$BG$$FU$$FG$$BG$
MSG_DRAW_TASK_BORDER: DU1 "DrawTaskBorder",0;
MSG_UPDATE_ODES: DU1 "UpdateOdes",0;
////**************************PROCEDURE*************************
ALIGN 8,0x90
CP_PLOT_SCREEN_I1::
PUSH EBP
MOV EBP,ESP
MOV EBX,SF_PARAM2[EBP]
MOV EAX,SF_PARAM3[EBP]
OR EBX,EBX
JS @@100
OR EAX,EAX
JS @@100
CMP EBX,U4 FS:[TSS_CRT_WIDTH]
JGE @@100
CMP EAX,U4 FS:[TSS_CRT_HEIGHT]
JGE @@100
IMUL U4 FS:[TSS_CRT_WIDTH]
ADD EAX,U4 [SYS_TEXTBASE]
ADD EBX,EAX
MOV EAX,U4 SF_PARAM1[EBP]
MOV U4 [EBX],EAX
POP EBP
XOR EDX,EDX
MOV EAX,1
RET
@@100: POP EBP
XOR EDX,EDX
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
CP_PLOT_WINDOW_I1::
PUSH EBP
MOV EBP,ESP
MOV EBX,U4 SF_PARAM2[EBP]
MOV EAX,U4 SF_PARAM3[EBP]
OR EBX,EBX
JS @@100
ADD EBX,U4 FS:[TSS_WINDOW_LEFT]
CMP EBX,U4 FS:[TSS_WINDOW_RIGHT]
JG @@100
OR EBX,EBX
JS @@100
CMP EBX,U4 FS:[TSS_CRT_WIDTH]
JGE @@100
OR EAX,EAX
JS @@100
ADD EAX,U4 FS:[TSS_WINDOW_TOP]
CMP EAX,U4 FS:[TSS_WINDOW_BOTTOM]
JG @@100
OR EAX,EAX
JS @@100
CMP EAX,U4 FS:[TSS_CRT_HEIGHT]
JGE @@100
IMUL U4 FS:[TSS_CRT_WIDTH]
ADD EAX,U4 [SYS_TEXTBASE]
ADD EBX,EAX
MOV EAX,U4 SF_PARAM1[EBP]
MOV U4 [EBX],EAX
POP EBP
XOR EDX,EDX
MOV EAX,1
RET
@@100: POP EBP
XOR EDX,EDX
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
CP_PLOT_BORDER_I1::
PUSH EBP
MOV EBP,ESP
MOV EBX,U4 SF_PARAM2[EBP]
MOV EAX,U4 SF_PARAM3[EBP]
MOV EDX,-4
CMP EBX,EDX
JL @@100
ADD EBX,U4 FS:[TSS_WINDOW_LEFT]
MOV EDX,U4 FS:[TSS_WINDOW_RIGHT]
ADD EDX,4
CMP EBX,EDX
JG @@100
OR EBX,EBX
JS @@100
CMP EBX,U4 FS:[TSS_CRT_WIDTH]
JGE @@100
MOV EDX,-1
CMP EAX,EDX
JL @@100
ADD EAX,U4 FS:[TSS_WINDOW_TOP]
MOV EDX,U4 FS:[TSS_WINDOW_BOTTOM]
INC EDX
CMP EAX,EDX
JG @@100
OR EAX,EAX
JS @@100
CMP EAX,U4 FS:[TSS_CRT_HEIGHT]
JGE @@100
IMUL U4 FS:[TSS_CRT_WIDTH]
ADD EAX,U4 [SYS_TEXTBASE]
ADD EBX,EAX
MOV EAX,U4 SF_PARAM1[EBP]
MOV U4 [EBX],EAX
POP EBP
XOR EDX,EDX
MOV EAX,1
RET
@@100: POP EBP
XOR EDX,EDX
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
GR_UPDATE_WINDOWS::
PUSHAD //-****
MOV ESI,U4 FS:[TSS_ABSOLUTE_ADDRESS]
MOV EDI,ESI
JMP @@1
@@10: MOV EAX,U4 TSS_FS[EDI]
MOV FS,AX
PUSH ESI
MOV ESI,MSG_UPDATE_ODES
CALL FIND_EXTERN
JZ @@11
CALL ESI
@@11: POP ESI
BT U4 FS:[TSS_CRT_FLAGS],CRTf_SHOW
JNC @@2
PUSH ESI
MOV ESI,MSG_DRAW_TASK_BORDER
CALL FIND_EXTERN
JZ @@12
CALL ESI
@@12: POP ESI
BT U4 [SYS_FLAGS],SYSf_TASK_LINKS_ALTERED
JC @@100
@@1: MOV EAX,U4 FS:[TSS_UPDATE_WINDOW]
OR EAX,EAX
JZ @@2
CALL EAX
@@2: BT U4 [SYS_FLAGS],SYSf_TASK_LINKS_ALTERED
JC @@100
MOV EDI,U4 FS:[TSS_NEXT_TSS]
CMP ESI,EDI
JNE @@10
@@100: MOV EAX,U4 TSS_FS[ESI]
MOV FS,AX
POPAD //+****
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
/*
GrXorLine(&dst3,&src,&src2,d5,vga_image);
for (col=0;col<d5;col++) {
*dst3=*src^*src2;
dst3+=4;
src+=4;
src2+=4;
}
*/
GR_XOR_LINE::
PUSH EBP
MOV EBP,ESP
PUSH ESI
PUSH EDI
MOV EAX,SF_PARAM2[EBP]
MOV EDX,U4 [EAX]
MOV EAX,SF_PARAM3[EBP]
MOV ESI,U4 [EAX]
MOV ECX,SF_PARAM4[EBP]
MOV EAX,SF_PARAM5[EBP]
MOV EDI,U4 [EAX]
@@5: MOV EAX,U4 [ESI]
XOR EAX,U4 [EDX]
MOV U4 [ESI],EAX
CMP U4 [EDI],EAX
JNE @@7
STOSD
ADD ESI,4
ADD EDX,4
LOOP @@5
MOV EAX,SF_PARAM5[EBP]
MOV U4[EAX],EDI
MOV EAX,SF_PARAM1[EBP]
MOV EDI,U4 [EAX]
MOV ECX,SF_PARAM4[EBP]
ADD EDI,ECX
ADD EDI,ECX
ADD EDI,ECX
ADD EDI,ECX
JMP @@100
@@6: MOV EAX,U4 [ESI]
XOR EAX,U4 [EDX]
MOV U4 [ESI],EAX
@@7: STOSD
ADD ESI,4
ADD EDX,4
LOOP @@6
MOV EAX,SF_PARAM5[EBP]
MOV U4[EAX],EDI
MOV EBX,REVERSE_BITS_TABLE
MOV EAX,SF_PARAM3[EBP]
MOV ESI,U4 [EAX]
MOV ECX,SF_PARAM4[EBP]
MOV EAX,SF_PARAM1[EBP]
MOV EDI,U4 [EAX]
@@10: LODSD
XLATB
ROR EAX,8
XLATB
ROR EAX,8
XLATB
ROR EAX,8
XLATB
ROR EAX,8
STOSD
LOOP @@10
@@100: MOV EAX,SF_PARAM3[EBP]
MOV U4[EAX],ESI
MOV EAX,SF_PARAM1[EBP]
MOV U4[EAX],EDI
MOV EAX,SF_PARAM2[EBP]
MOV U4[EAX],EDX
POP EDI
POP ESI
POP EBP
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
/*
GrPlotChar(font_ptr,cur_ch.u1[1],&dst2,d1,d2);
for (plane=0x01;plane!=0x10;plane<<=1) {
font_ptr2=font_ptr;
if (cur_ch.u1[1] & plane) {
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst2|=*font_ptr2++;
dst2+=d1;
}
} else {
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst2&=~*font_ptr2++;
dst2+=d1;
}
}
dst2+=d2;
}
*/
GR_PLOT_CHAR::
PUSH EBP
MOV EBP,ESP
PUSH ESI
PUSH EDI
MOV EDX,1 //EDX=plane
MOV EBX,U4 SF_PARAM4[EBP] //EBX=d1
MOV EAX,U4 SF_PARAM3[EBP] //EDI=dst2
MOV EDI,U4 [EAX] //EDI=dst2
@@10: MOV ESI,U4 SF_PARAM1[EBP] //ESI=font_ptr2
TEST U4 SF_PARAM2[EBP],EDX
JZ @@30
@@20: LODSD
OR U1 [EDI],AL
ADD EDI,EBX
OR U1 [EDI],AH
ADD EDI,EBX
ROR EAX,16
OR U1 [EDI],AL
ADD EDI,EBX
OR U1 [EDI],AH
ADD EDI,EBX
LODSD
OR U1 [EDI],AL
ADD EDI,EBX
OR U1 [EDI],AH
ADD EDI,EBX
ROR EAX,16
OR U1 [EDI],AL
ADD EDI,EBX
OR U1 [EDI],AH
ADD EDI,EBX
JMP @@40
@@30: LODSD
NOT EAX
AND U1 [EDI],AL
ADD EDI,EBX
AND U1 [EDI],AH
ADD EDI,EBX
ROR EAX,16
AND U1 [EDI],AL
ADD EDI,EBX
AND U1 [EDI],AH
ADD EDI,EBX
LODSD
NOT EAX
AND U1 [EDI],AL
ADD EDI,EBX
AND U1 [EDI],AH
ADD EDI,EBX
ROR EAX,16
AND U1 [EDI],AL
ADD EDI,EBX
AND U1 [EDI],AH
ADD EDI,EBX
@@40: ADD EDI,U4 SF_PARAM5[EBP]
SHL1 EDX
CMP EDX,0x10
JNE @@10
MOV EAX,SF_PARAM3[EBP]
MOV U4[EAX],EDI
POP EDI
POP ESI
POP EBP
RET
////**************************PROCEDURE*************************
ALIGN 8,0x90
/*
GrPlotBackground(cur_ch.u1[1],&dst,d1,d2);
for (plane=0x10;plane!=0x100;plane=plane<<1) {
d=(cur_ch.u1[1] & plane) ? 0xFF:0x00;
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst=d;
dst+=d1;
}
dst+=d2;
}
*/
GR_PLOT_BACKGROUND::
PUSH EBP
MOV EBP,ESP
PUSH EDI
MOV EDX,0x10 //EDX=plane
MOV EBX,U4 SF_PARAM3[EBP] //EBX=d1
MOV EAX,U4 SF_PARAM2[EBP] //EDI=dst
MOV EDI,U4 [EAX] //EDI=dst
@@10: XOR EAX,EAX
TEST U4 SF_PARAM1[EBP],EDX
JZ @@20
DEC EAX
@@20: MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
MOV U1 [EDI],AL
ADD EDI,EBX
ADD EDI,U4 SF_PARAM4[EBP]
SHL1 EDX
CMP EDX,0x100
JNE @@10
MOV EAX,SF_PARAM2[EBP]
MOV U4[EAX],EDI
POP EDI
POP EBP
RET
+1228
View File
File diff suppressed because it is too large. Load diff
+14
View File
@@ -0,0 +1,14 @@
#define IP_NULL 0
#define IP_JOYSTICK0 1
#define IP_JOYSTICK1 2
#define IP_MOUSE 3
public I8 ipx=-100,ipy=-100,ipz=0;
public I8 ip_speed=0;
public I8 ip_pointer_type=IP_NULL;
public I8 iptx=ipx/FONT_WIDTH,ipty=ipy/FONT_HEIGHT;
public BoolU4 ip_on=TRUE, //Show or hide cursor
ip_lb_last=FALSE,ip_rb_last=FALSE,
ip_lb=FALSE,ip_cb=FALSE,ip_rb=FALSE; //Left/center/right buttons
public BoolU4 ip_has_wheel=FALSE;
public LTDate last_ip_move_time=BootTime;
+304
View File
@@ -0,0 +1,304 @@
#define ICT_U2 1
#define ICT_U4 2
#define ICT_U8 3
class IncCompressStructU2
{
U2 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IncCompressStructU4
{
U4 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IncCompressStructU8
{
U8 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IntermediateIncCompressStruct
{
IntermediateIncCompressStruct *next,*last;
U8 match_start_ref,match_start,match_size;
};
void IncCompressRange(U1 *ref,U8 ref_size,U1 *b,U8 range_start,U8 range_end,
IntermediateIncCompressStruct *root,U8 type_size)
{
I8 i,j,k,l,best_k=0,best_j,best_i;
IntermediateIncCompressStruct *tempc;
//$BK,1$TODO: improve this algorithm$BK,0$
for (i=range_start;i<range_end;i++) {
for (j=0;j<ref_size;j++) {
k=0;
l=(ref_size-j<range_end-i) ? ref_size-j:range_end-i;
while (ref[j+k]==b[i+k] && k<l)
k++;
if (k>best_k) {
best_k=k;
best_j=j;
best_i=i;
}
}
}
if (best_k>type_size) {
if (range_start+type_size<best_i)
IncCompressRange(ref,ref_size,b,range_start,best_i,root,type_size);
tempc=MAlloc(sizeof(IntermediateIncCompressStruct));
tempc->match_start_ref=best_j;
tempc->match_start=best_i;
tempc->match_size=best_k;
InsQue(tempc,root->last);
if (best_i+best_k+type_size<range_end)
IncCompressRange(ref,ref_size,b,best_i+best_k,range_end,root,type_size);
}
}
public IncCompressStructU2 *IncCompress(U1 *ref,U8 ref_size,U1 *b,U8 size)
{
U8 i,j=0,l=0,m=0,ic_type;
U1 *u1,*result;
U2 *u2;
U4 *u4;
U8 *u8;
IntermediateIncCompressStruct root,*tempc,*tempc1;
IncCompressStructU2 *tempi2;
IncCompressStructU4 *tempi4;
IncCompressStructU8 *tempi8;
root.next=&root;
root.last=&root;
if (ref_size<=0xFFFF && size<=0xFFFF) {
ic_type=ICT_U2;
i=sizeof(U1)+size+2*sizeof(U2);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU2));
if (root.next==&root)
i+=sizeof(IncCompressStructU2);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU2);
tempc=tempc->next;
}
}
} else if (ref_size<=0xFFFFFFFF && size<=0xFFFFFFFF) {
ic_type=ICT_U4;
i=sizeof(U1)+size+2*sizeof(U4);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU4));
if (root.next==&root)
i+=sizeof(IncCompressStructU4);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU4);
tempc=tempc->next;
}
}
} else {
ic_type=ICT_U8;
i=sizeof(U1)+size+2*sizeof(U8);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU8));
if (root.next==&root)
i+=sizeof(IncCompressStructU8);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU8);
tempc=tempc->next;
}
}
}
result=MAlloc(i);
u1=result;
*u1=ic_type;
switch (ic_type) {
case ICT_U2:
u2=result+sizeof(U1);
*u2=i;
u2+=sizeof(U2);
*u2=size;
tempi2=u2+sizeof(U2);
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi2->match_start=m;
tempi2->match_size=l;
tempi2->diff_size=tempc->match_start-(j+l);
if (tempi2->diff_size)
MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size);
tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi2->match_start=m;
tempi2->match_size=l;
tempi2->diff_size=size-(j+l);
if (tempi2->diff_size)
MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size);
break;
case ICT_U4:
u4=result+sizeof(U1);
*u4=i;
u4+=sizeof(U4);
*u4=size;
tempi4=u4+sizeof(U4);
//$BK,1$TODO: deal with >65536 matches and differences$BK,0$
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi4->match_start=m;
tempi4->match_size=l;
tempi4->diff_size=tempc->match_start-(j+l);
if (tempi4->diff_size)
MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size);
tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi4->match_start=m;
tempi4->match_size=l;
tempi4->diff_size=size-(j+l);
if (tempi4->diff_size)
MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size);
break;
case ICT_U8:
u8=result+sizeof(U1);
*u8=i;
u8+=sizeof(U8);
*u8=size;
tempi8=u8+sizeof(U8);
//$BK,1$TODO: deal with >65536 matches and differences$BK,0$
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi8->match_start=m;
tempi8->match_size=l;
tempi8->diff_size=tempc->match_start-(j+l);
if (tempi8->diff_size)
MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size);
tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi8->match_start=m;
tempi8->match_size=l;
tempi8->diff_size=size-(j+l);
if (tempi8->diff_size)
MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size);
break;
}
return result;
}
public U1 *IncExpand(U1 *ref,IncCompressStructU2 *b,U8 *size=NULL)
{
U1 *result,*dst,*u1=b,*b_end;
U2 *u2;
U4 *u4;
U8 *u8=b,s,ic_type;
IncCompressStructU2 *tempi2;
IncCompressStructU4 *tempi4;
IncCompressStructU8 *tempi8;
ic_type=*u1;
switch (ic_type) {
case ICT_U2:
u2=b+sizeof(U1);
b_end=b+*u2;
u2+=sizeof(U2);
s=*u2;
break;
case ICT_U4:
u4=b+sizeof(U1);
b_end=b+*u4;
u4+=sizeof(U4);
s=*u4;
break;
case ICT_U8:
u8=b+sizeof(U1);
b_end=b+*u8;
u8+=sizeof(U8);
s=*u8;
break;
}
result=MAlloc(s);
if (size) *size=s;
dst=result;
switch (ic_type) {
case ICT_U2:
tempi2=b+sizeof(U1)+2*sizeof(U2);
while (tempi2<b_end) {
if (tempi2->match_size) {
MemCpy(dst,ref+tempi2->match_start,tempi2->match_size);
dst+=tempi2->match_size;
}
if (tempi2->diff_size) {
MemCpy(dst,&tempi2->diff_data,tempi2->diff_size);
dst+=tempi2->diff_size;
}
tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size;
}
break;
case ICT_U4:
tempi4=b+sizeof(U1)+2*sizeof(U4);
while (tempi4<b_end) {
if (tempi4->match_size) {
MemCpy(dst,ref+tempi4->match_start,tempi4->match_size);
dst+=tempi4->match_size;
}
if (tempi4->diff_size) {
MemCpy(dst,&tempi4->diff_data,tempi4->diff_size);
dst+=tempi4->diff_size;
}
tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size;
}
break;
case ICT_U8:
tempi8=b+sizeof(U1)+2*sizeof(U8);
while (tempi8<b_end) {
if (tempi8->match_size) {
MemCpy(dst,ref+tempi8->match_start,tempi8->match_size);
dst+=tempi8->match_size;
}
if (tempi8->diff_size) {
MemCpy(dst,&tempi8->diff_data,tempi8->diff_size);
dst+=tempi8->diff_size;
}
tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size;
}
break;
}
return result;
}
+136
View File
@@ -0,0 +1,136 @@
#define JOY_CAL_FILE "::/LT/ADAM/JOY.DTZ"
#define LTPORT 0x201
#define CMAX 0x800
public I8 joyv[4],joymax[4],joymin[4],joyrest[4];
public BoolU4 joyb[4],joy_calibrated=FALSE,joy_being_calibrated=FALSE;
public I8 joysat=100,joynx=0,joyny=0; //Normalized
public I8 joycx=grwidth>>1,joycy=grheight>>1,joycvx=0,joycvy=0;
public I8 joytx=0,joyty=0; //Text row & col
void PollJoystick()
{
I8 i, j;
I8 mask = 15;
I8 scale2=24;
BoolU4 old_preempt=Preempt(OFF);
for (i=0;i<4;i++)
joyv[i]=0;
OutP(LTPORT, 0);
for (i=1; mask && i < CMAX; i++) {
j = InP(LTPORT) ^ mask;
if (j & 1) { joyv[0] = i; mask = mask ^ 1; }
if (j & 2) { joyv[1] = i; mask = mask ^ 2; }
if (j & 4) { joyv[2] = i; mask = mask ^ 4; }
if (j & 8) { joyv[3] = i; mask = mask ^ 8; }
}
Preempt(old_preempt);
j = InP(LTPORT);
joyb[0] = !(j & 0x10);
joyb[1] = !(j & 0x20);
joyb[2] = !(j & 0x40);
joyb[3] = !(j & 0x80);
if (joy_calibrated) {
joynx=joysat*(joyv[0]-joyrest[0])/(joymax[0]-joymin[0]+1);
if (AbsI8(joynx)<15)
joycvx=0;
else
joycvx+=joynx-SignI8(joynx)*15;
joyny=joysat*(joyv[1]-joyrest[1])/(joymax[1]-joymin[1]+1);
if (AbsI8(joyny)<15)
joycvy=0;
else
joycvy+=joyny-SignI8(joyny)*15;
joycx+=joycvx/scale2;
joycvx=70*joycvx/100;
joycy+=joycvy/scale2;
joycvy=70*joycvy/100;
if (joycx < 0) joycx=0;
if (joycx>=grwidth) joycx=grwidth-1;
if (joycy < 0) joycy=0;
if (joycy>=grheight) joycy=grheight-1;
joytx=joycx/FONT_WIDTH;
joyty=joycy/FONT_HEIGHT;
}
}
public void JoyCalibration()
{
I8 i,x,y;
I8 buf[3<<2];
I8 old_ip=ip_pointer_type;
joy_calibrated=FALSE;
ip_pointer_type=IP_JOYSTICK0;
GrBitMap *base=GrNew(grbase);
base->color=ROP_XOR|GR_WHITE;
for (i=0;i<4;i++)
joyb[i]=0;
coutln "$$CL$$Leave joystick and throttle centered\r\n and press button.";
while (!(joyb[0] || joyb[1])) {
SwapInNext;
}
for (i=0;i<4;i++) {
joyrest[i]=joyv[i];
joymax[i]=joyv[i];
joymin[i]=joyv[i];
}
while (joyb[0] || joyb[1]) {
SwapInNext;
}
coutln "$$CL$$Move all about including throttle and press button.";
while (!(joyb[0] || joyb[1])) {
x=joyv[0]>>1; y=joyv[1]>>1;
if (x<3) x=3;
if (y<3) y=3;
GrLine3(base,x-3,y-3,0,x+3,y+3,0);
GrLine3(base,x+3,y-3,0,x-3,y+3,0);
x=joyv[2]>>1; y=joyv[3]>>1;
if (x<3) x=3;
if (y<3) y=3;
GrLine3(base,x-3,y-3,0,x+3,y+3,0);
GrLine3(base,x+3,y-3,0,x-3,y+3,0);
for (i=0;i<4;i++) {
if (joyv[i]>joymax[i]) joymax[i]=joyv[i];
if (joyv[i]<joymin[i]) joymin[i]=joyv[i];
}
SwapInNext;
}
GrClear;
joy_calibrated=TRUE;
//Save
for (i=0;i<4;i++) {
buf[i*3+0]=joymin[i];
buf[i*3+1]=joymax[i];
buf[i*3+2]=joyrest[i];
}
if (DriveIsWritable(':'))
WriteFile(JOY_CAL_FILE,buf,sizeof(I8)*3<<2);
ip_pointer_type=old_ip;
GrDel(base);
}
BoolU4 LoadJoystickCalibration()
{
U8 size,i;
I8 *ptr,*buf=ReadFile(JOY_CAL_FILE,&size);
joy_being_calibrated=TRUE;
if (!size)
JoyCalibration;
else {
ptr=buf;
for (i=0;i<4;i++) {
joymin[i]=ptr[0];
joymax[i]=ptr[1];
joyrest[i]=ptr[2];
ptr=ptr+3*sizeof(I8);
joy_calibrated=TRUE;
}
Free(buf);
}
joy_being_calibrated=FALSE;
PollJoystick;
}
+58
View File
@@ -0,0 +1,58 @@
void CollectAccntList()
{
LTDirEntry *tempm1;
SysAccntStruct *tempa;
U8 my_flags=0;
sys_accounts.next=&sys_accounts;
sys_accounts.last=&sys_accounts;
tempm1=FindFiles("/LT/ACCOUNTS/*",&my_flags);
while (tempm1) {
if ((tempm1->attr & LT_ATTR_DIR) && tempm1->name[0]!='.') {
tempa=MAlloc(sizeof(SysAccntStruct));
StrCpy(tempa->name,tempm1->name);
tempa->flags=0;
InsQue(tempa,sys_accounts.last);
}
tempm1=tempm1->next;
}
DelLTDirList(tempm1);
}
public SysAccntStruct *FindSysAccnt(I1 *name)
{
SysAccntStruct *tempa;
tempa=sys_accounts.next;
while (tempa!=&sys_accounts) {
if (!StrCmp(tempa->name,name))
return tempa;
tempa=tempa->next;
}
return NULL;
}
public SysAccntStruct *PopUpGetSysAccnt()
{
Ltf *l=LtfNew;
SysAccntStruct *tempa;
LtfPutS(l,"Select Account.\r\nCursor down and press SPACE.\r\n");
tempa=sys_accounts.next;
while (tempa!=&sys_accounts) {
LtfPrintF(l,"$$CM +LX 2,3$$$$BT, \"%s\" %d$$",tempa->name,tempa);
tempa=tempa->next;
}
tempa=PopUpMenu(l);
LtfDel(l);
return tempa;
}
void LoadAdam3()
{
SysAccntStruct *tempa=Fs->account;
if (!Bts(&tempa->flags,SACTf_ADAM3_LOADED)) {
Adam("ExecuteFile(\"::/LT/ACCOUNTS/%s/ADAM3.CPZ\");;",
tempa->name);
}
}
+2240
View File
File diff suppressed because it is too large. Load diff
+72
View File
@@ -0,0 +1,72 @@
public double Abs(double i)
{
if (i<0)
return -i;
else
return i;
}
public double Sign(double i)
{
if (i<0)
return -1.0;
else if (!i)
return 0.0;
else
return 1.0;
}
public double Sqr(double d)
{
return d*d;
}
public void R2P(double *mag,double *arg,double x,double y)
{ //Rect to polar
*arg=Arg(x,y);
*mag=Sqrt(x*x+y*y);
}
public void P2R(double *x,double *y,double mag,double arg)
{ //Polar to Rect
*x=mag*Cos(arg);
*y=mag*Sin(arg);
}
public double Unwrap(double theta,double base=-pi)
{
double result=theta%pi2;
if (result<base) result+=pi2;
if (result>base+pi2) result-=pi2;
return result;
}
public I8 AbsI8(I8 i)
{
if (i<0)
return -i;
else
return i;
}
public I8 SignI8(I8 i)
{
if (i<0)
return -1;
else if (!i)
return 0;
else
return 1;
}
public I8 SqrI8(I8 i)
{
return MulI8(i,i);
}
public I8 DistI8(I8 x1,I8 y1,I8 x2,I8 y2)
{
I8 dx=x1-x2,dy=y1-y2;
return MulI8(dx,dx)+MulI8(dy,dy);
}
+189
View File
@@ -0,0 +1,189 @@
I8 mxx=grwidth>>1,
myy=grheight>>1,
mzz=0;
BoolU4 mouse_buttons[5];
U8 last_mouse_jiffy=0;
BoolU4 mouse_installed=FALSE;
BoolU4 mouse_has_wheel=FALSE;
BoolU4 mouse_has_ext_buttons=FALSE;
BoolU4 mouse_evt=FALSE;
BoolU4 mouse_irqs_working=FALSE;
U8 mouse_evt_time;
void MouseGetDeviceType()
{
U1 b;
KbdMouseCmdAck(0xF2);
b=KbdCmdRead;
if (b==3)
mouse_has_wheel=TRUE;
else if (b==4)
mouse_has_ext_buttons=TRUE;
}
void MouseReset()
{
KbdCmdFlush;
KbdCmdSend(KEYB_CTRL,0xA8); //Enable Mouse
KbdCmdFlush;
KbdCmdSend(KEYB_CTRL,0xA9); //check for mouse
KbdCmdFlush;
KbdMouseCmdAck(0xFF); //Reset
KbdCmdRead;
KbdCmdRead;
KbdMouseCmdAck(0xFF); //Reset
KbdCmdRead;
KbdCmdRead;
KbdMouseCmdAck(0xF3);
KbdMouseCmdAck(200);
KbdMouseCmdAck(0xF3); // enable Mouse
KbdMouseCmdAck(100); // Set Rate
KbdMouseCmdAck(0xF3);
KbdMouseCmdAck(80); //Resolution
MouseGetDeviceType; // enable Mouse
KbdMouseCmdAck(0xF3);
KbdMouseCmdAck(10);
MouseGetDeviceType; // enable Mouse
KbdMouseCmdAck(0xE8); //Resolution
KbdMouseCmdAck(0x03);
KbdMouseCmdAck(0xE6);
KbdMouseCmdAck(0xF3); // Set Rate
//if your mouse doesn't work, try this
// KbdMouseCmdAck(40);
KbdMouseCmdAck(100);
KbdMouseCmdAck(0xF4); // enable Mouse
}
void MouseHandler()
{
I8 i,j,dx,dy,dz,
old_mxx=mxx,old_myy=myy,old_mzz=mzz;
BoolU4 evt=FALSE,old_buttons[5];
U1 mouse_buf[4];
U8 evt_time=BootTime;
try {
for (i=0;i<5;i++)
old_buttons[i]=mouse_buttons[i];
for (i=0;i<3;i++) {
j=KbdCmdRead;
if (j<0)
throw;
else
mouse_buf[i]=j;
}
if (mouse_has_wheel || mouse_has_ext_buttons) {
j=KbdCmdRead;
if (j<0)
throw;
else
mouse_buf[3]=j;
} else
mouse_buf[3]=0;
Sti;
mouse_buttons[0] = mouse_buf[0] & 1;
mouse_buttons[1] = (mouse_buf[0] & 2) >> 1;
mouse_buttons[2] = (mouse_buf[0] & 4) >> 2;
mouse_buttons[3] = (mouse_buf[3] & 0x10) >> 4;
mouse_buttons[4] = (mouse_buf[3] & 0x20) >> 5;
if (mouse_buf[0] & 0x10)
dx=mouse_buf[1]-256;
else
dx=mouse_buf[1];
if (mouse_buf[0] & 0x20)
dy=256-mouse_buf[2];
else
dy=-mouse_buf[2];
if (mouse_buf[3] & 0x08)
dz=(mouse_buf[3]&7)-8;
else
dz=mouse_buf[3]&7;
mxx+=dx;
myy+=dy;
mzz+=dz;
if (mxx < 0) mxx=0;
if (mxx>=grwidth) mxx=grwidth-1;
if (myy < 0) myy=0;
if (myy>=grheight) myy=grheight-1;
} catch {
Fs->catch_except=TRUE;
KbdCmdFlush;
}
for (i=0;i<5;i++)
if (old_buttons[i]!=mouse_buttons[i])
evt=TRUE;
if (old_mxx!=mxx || old_myy!=myy || old_mzz!=mzz)
evt=TRUE;
if (evt) {
mouse_evt_time=evt_time;
last_mouse_jiffy=jiffies;
mouse_evt=TRUE;
}
}
void MouseIrqHandler()
{
mouse_irqs_working=TRUE;
MouseHandler;
}
void PollMouse()
{ //I can't get IRQ's working on some computers
U8 old_flags=GetFlags;
if (mouse_irqs_working) return;
// Cli;
if (!Bt(&sys_irq_flags,1)) {//not in keybd IRQ
if (InP(KEYB_CTRL) & 1) {
KbdCmdSend(KEYB_CTRL,0x60);
KbdCmdSend(KEYB_PORT,0x51); //disable kbd
MouseHandler;
KbdCmdSend(KEYB_CTRL,0x60);
KbdCmdSend(KEYB_PORT,0x41); //enable kbd
}
}
SetFlags(old_flags);
}
BoolU4 InstallMouseDriver()
{
BoolU4 result;
I8 i;
// U8 old_flags=GetFlags;
// Cli;
ext[EXT_IRQ0C]=NULL;
mouse_evt=FALSE;
for(i=0;i<5;i++)
mouse_buttons[i]=0;
mouse_has_wheel=FALSE;
mouse_has_ext_buttons=FALSE;
try {
MouseReset;
result=TRUE;
mouse_evt=TRUE;
ext[EXT_IRQ0C]=&MouseIrqHandler;
} catch {
Fs->catch_except=TRUE;
result=FALSE;
}
mouse_installed=result;
// SetFlags(old_flags);
return result;
}
Spawn(&InstallMouseDriver);
+82
View File
@@ -0,0 +1,82 @@
I1 *cur_song=NULL;
TssStruct *cur_song_tss=NULL;
U8 music_octive;
double music_note_len;
U1 music_note_map[7]={0,2,3,5,7,8,10};
public double music_tempo,music_stacatto_factor=1.0;
I1 *MusicSetOctive(I1 *st)
{
I1 ch=*st++;
while (ch>='0' && ch<='9') {
music_octive=ch-'0';
ch=*st++;
}
return --st;
}
I1 *MusicSetNoteLen(I1 *st)
{
BoolU4 cont=TRUE;
do {
switch (*st++) {
case 'w': music_note_len=4.0; break;
case 'h': music_note_len=2.0; break;
case 'q': music_note_len=1.0; break;
case 'e': music_note_len=0.5; break;
case 's': music_note_len=0.25; break;
case 't': music_note_len=2.0*music_note_len/3.0; break;
case '.': music_note_len=1.5*music_note_len; break;
default:
st--;
cont=FALSE;
}
} while (cont);
return st;
}
public void Play(I1 *st,I1 *words=NULL)
{
I1 *word;
U8 note,i=0;
double f;
while (*st) {
st=MusicSetOctive(st);
st=MusicSetNoteLen(st);
st=MusicSetOctive(st);
if (!*st) break;
note=*st++-'A';
if (note<7) {
note=music_note_map[note];
if (*st=='b') {
note--;
st++;
} else if (*st=='#') {
note++;
st++;
}
f=2.0`(6+music_octive+(note-3)/12.0);
} else
f=0;
if (words) {
if (word=PointAtListEntry(i++,words))
if (StrCmp(word," "))
PutS(word);
}
Sound(f);
Sleep(1000*music_stacatto_factor*music_note_len/music_tempo);
Sound(0);
Sleep(1000*(1.0-music_stacatto_factor)*music_note_len/music_tempo);
}
}
void ResetMusicSettings()
{
music_stacatto_factor=1.0;
music_tempo=2.5;
music_octive=3;
music_note_len=1.0;
}
ResetMusicSettings;
+171
View File
@@ -0,0 +1,171 @@
//This is taken from the book, $UL,1$Numeric Recipies in C$UL,0$
Ode *OdeNew(U8 n)
{
Ode *o=MAllocZ(sizeof(Ode));
o->n=n;
o->state=MAllocZ(n*sizeof(double));
o->base_t=ReadSysTimer*1.0/SYS_TIMER_FREQ;
o->h=1.0e-6;
o->DstateDt=MAllocZ(n*sizeof(double));
o->state_scale=MAllocZ(n*sizeof(double));
o->initial_state=MAllocZ(n*sizeof(double));
o->tolerance_start=1.0e-6;
o->temp0=MAllocZ(n*sizeof(double));
o->temp1=MAllocZ(n*sizeof(double));
o->temp2=MAllocZ(n*sizeof(double));
o->temp3=MAllocZ(n*sizeof(double));
o->temp4=MAllocZ(n*sizeof(double));
o->temp5=MAllocZ(n*sizeof(double));
o->temp6=MAllocZ(n*sizeof(double));
o->temp7=MAllocZ(n*sizeof(double));
return o;
}
void OdeDel(Ode *o)
{
Free(o->state);
Free(o->DstateDt);
Free(o->state_scale);
Free(o->initial_state);
Free(o->temp0);
Free(o->temp1);
Free(o->temp2);
Free(o->temp3);
Free(o->temp4);
Free(o->temp5);
Free(o->temp6);
Free(o->temp7);
Free(o);
}
void OdeOneStep(Ode *o)
{
I8 i;
o->derivative(o,o->t+o->base_t,o->state,o->DstateDt);
for (i=0;i<o->n;i++)
o->state[i]+=o->h*o->DstateDt[i];
o->t+=o->h;
}
void OdeRK4OneStep(Ode *o)
{
I8 i,n=o->n;
double xh,hh,h6;
double *dym,*dyt,*yt,*DstateDt;
dym =o->temp0;
dyt =o->temp1;
yt =o->temp2;
DstateDt=o->temp3;
hh =0.5*o->h;
h6 =o->h / 6.0;
xh =o->t +o->base_t+ hh;
o->derivative(o,o->t+o->base_t,o->state,o->DstateDt);
for (i=0;i<n;i++)
yt[i]=o->state[i]+hh*DstateDt[i];
o->derivative(o,xh,yt,dyt);
for (i=0;i<n;i++)
yt[i]=o->state[i]+hh*dyt[i];
o->derivative(o,xh,yt,dym);
for (i=0;i<n;i++) {
yt[i]=o->state[i]+o->h*dym[i];
dym[i]+=dyt[i];
}
o->t+=o->h;
o->derivative(o,o->t+o->base_t,yt,dyt);
for (i=0;i<n;i++)
o->state[i]+=h6*(DstateDt[i]+dyt[i]+2.0*dym[i]);
}
double ODEa2=0.2, ODEa3=0.3, ODEa4=0.6, ODEa5=1.0, ODEa6=0.875, ODEb21=0.2,
ODEb31=3.0/40.0, ODEb32=9.0/40.0, ODEb41=0.3, ODEb42=-0.9, ODEb43=1.2,
ODEb51=-11.0/54.0, ODEb52=2.5, ODEb53=-70.0/27.0, ODEb54=35.0/27.0,
ODEb61=1631.0/55296.0, ODEb62=175.0/512.0, ODEb63=575.0/13824.0,
ODEb64=44275.0/110592.0, ODEb65=253.0/4096.0, ODEc1=37.0/378.0,
ODEc3=250.0/621.0, ODEc4=125.0/594.0, ODEc6=512.0/1771.0,
ODEdc1=37.0/378.0 -2825.0/27648.0,
ODEdc3=250.0/621.0-18575.0/48384.0,
ODEdc4=125.0/594.0-13525.0/55296.0,
ODEdc5=-277.0/14336.0,
ODEdc6=512.0/1771.0-0.25;
void OdeCashKarp(Ode *o)
{
I8 i,n=o->n;
double h=o->h,*state=o->state,*DstateDt=o->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,*tempstate,*stateerr,*outstate;
ak2=o->temp0;
ak3=o->temp1;
ak4=o->temp2;
ak5=o->temp3;
ak6=o->temp4;
tempstate=o->temp5;
outstate=o->temp6;
stateerr=o->temp7;
for (i=0;i<n;i++)
tempstate[i]=state[i]+ODEb21*h*DstateDt[i];
o->derivative(o,o->t+o->base_t+ODEa2*h,tempstate,ak2);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb31*DstateDt[i]+ODEb32*ak2[i]);
o->derivative(o,o->t+o->base_t+ODEa3*h,tempstate,ak3);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb41*DstateDt[i]+ODEb42*ak2[i]+ODEb43*ak3[i]);
o->derivative(o,o->t+o->base_t+ODEa4*h,tempstate,ak4);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb51*DstateDt[i]+ODEb52*ak2[i]+ODEb53*ak3[i]+ODEb54*ak4[i]);
o->derivative(o,o->t+o->base_t+ODEa5*h,tempstate,ak5);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb61*DstateDt[i]+ODEb62*ak2[i]+ODEb63*ak3[i]+ODEb64*ak4[i]+ODEb65*ak5[i]);
o->derivative(o,o->t+o->base_t+ODEa6*h,tempstate,ak6);
for (i=0;i<n;i++)
outstate[i]=state[i]+h*(ODEc1*DstateDt[i]+ODEc3*ak3[i]+ODEc4*ak4[i]+ODEc6*ak6[i]);
for (i=0;i<n;i++)
stateerr[i]=h*(ODEdc1*DstateDt[i]+ODEdc3*ak3[i]+ODEdc4*ak4[i]+ODEdc5*ak5[i]+ODEdc6*ak6[i]);
}
#define SAFETY (0.9)
#define PGROW (-0.2)
#define PSHRNK (-0.25)
#define ERRCON (1.89e-4)
void OdeRK5OneStep(Ode *o)
{
I8 i;
double errmax,temp;
double *tempstate=o->temp6,*stateerr=o->temp7;
while (TRUE) {
OdeCashKarp(o);
errmax=0.0;
for (i=0;i<o->n;i++) {
temp=Abs(stateerr[i]/o->state_scale[i]);
if (temp>errmax)
errmax=temp;
}
errmax/=o->tolerance;
if (errmax>1.0 && o->h>1.0e-64) {
temp=o->h*SAFETY*errmax`PSHRNK;
if (temp<0.1*o->h)
o->h*=0.1;
else
o->h=temp;
} else {
o->t+=o->h;
if (errmax>ERRCON)
o->h*=SAFETY*errmax`PGROW;
else
o->h*=5.0;
if (o->h>1.0e32)
o->h=1.0e32;
MemCpy(o->state,tempstate,sizeof(double)*o->n);
break;
}
}
}
BIN
View File
Binary file not shown.
+442
View File
@@ -0,0 +1,442 @@
public void LtfDm(U1 *buf,U8 cnt=0x80)
{
LtfEntry *ll;
BoolU4 old_preempt=Preempt(OFF);
Ltf *l=Fs->cur_ltf;
ll=LtfPrintF(l,"$$HX -Z %d 16$$",cnt);
ll->data=buf;
l->cur_entry=ll->next;
LtfRecalc(l);
Preempt(old_preempt);
}
public void LtfD(U1 *buf,U8 cnt=0x80)
{
LtfEntry *ll;
BoolU4 old_preempt=Preempt(OFF);
Ltf *l=Fs->cur_ltf;
ll=LtfPrintF(l,"$$HX %d 16$$",cnt);
ll->data=buf;
l->cur_entry=ll->next;
LtfRecalc(l);
Preempt(old_preempt);
}
public U1 *PatchBlk(U8 blk,BoolU4 write=FALSE)
{
U1 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_partition,buf,blk,1,TRUE);
LtfD(buf,BLK_SIZE);
if (write) {
coutln "Edit and press ESC to write or ^Q";
if (View) {
coutln "Write";
WBlks(Fs->cur_partition,buf,blk,1,TRUE);
}
}
return buf;
}
public U1 *Patch(U8 c,U8 cnt=0,BoolU4 write=FALSE)
{
U1 *buf=MAlloc(BLK_SIZE*Fs->cur_partition->spc);
if (cnt)
c=NextClusterNum(Fs->cur_partition,c,cnt,TRUE);
RClusters(Fs->cur_partition,buf,c,1,TRUE);
coutln "Cluster:",c;
LtfD(buf,BLK_SIZE*Fs->cur_partition->spc);
if (write) {
coutln "Edit and press ESC to write or ^Q";
if (View) {
coutln "Write";
WClusters(Fs->cur_partition,buf,c,1,TRUE);
}
}
return buf;
}
public U8 UnusedSysMem()
{
MemBlk *tempm;
U8 i,result=0,old_flags=GetFlags;
Cli;
tempm=mem_free_list;
while (tempm) {
result=result+tempm->pages;
tempm=tempm->next;
}
for (i=0;i<FREE_PAGE_HASH_SIZE;i++) {
tempm=free_page_hash[i];
while (tempm) {
result+=tempm->pages;
tempm=tempm->next;
}
}
for (i=0;i<32;i++) {
tempm=free_page_hash2[i];
while (tempm) {
result+=tempm->pages;
tempm=tempm->next;
}
}
SetFlags(old_flags);
return result*PAGE_SIZE;
}
public U8 TaskAllocatedMem(TssStruct *tss=NULL)
{
MemBlk *m;
U8 result=0,old_flags=GetFlags;
if (!tss) tss=Fs;
m=tss->next_mem_blk;
Cli;
while (m!=&tss->next_mem_blk) {
result+=m->pages*PAGE_SIZE-sizeof(MemBlk);
m=m->next;
}
SetFlags(old_flags);
return result;
}
public U8 TaskUnusedAllocatedMem(TssStruct *tss=NULL)
{
U8 result=0,i,old_flags=GetFlags;
UnusedAllocatedMem *u;
if (!tss) tss=Fs;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
result+=u->size;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
result+=u->size;
u=u->next;
}
SetFlags(old_flags);
return result;
}
I8 CompareUamPtrs(UnusedAllocatedMem **e1,
UnusedAllocatedMem **e2)
{
return *e1-*e2;
}
I8 CompareUamSize(UnusedAllocatedMem **e1,
UnusedAllocatedMem **e2)
{
return (*e2)->size-(*e1)->size;
}
public void HeapRep(TssStruct *tss=NULL)
{
I8 i,cnt;
UnusedAllocatedMem *u;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
cnt=0;
u=tss->heap_hash[i];
while (u) {
cnt+=u->size;
u=u->next;
}
if (cnt)
PrintF("%03X:%08X\r\n",i<<2,cnt);
}
u=tss->malloc_free_list;
while (u) {
PrintF("%08X\r\n",u->size);
u=u->next;
}
SetFlags(old_flags);
}
public BoolU4 IsInHeap(U1 *a,TssStruct *tss=NULL)
{
MemBlk *m;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
m=tss->next_mem_blk;
Cli;
while (m!=&tss->next_mem_blk) {
if (a>=m && a<m+m->pages*PAGE_SIZE) {
SetFlags(old_flags);
return TRUE;
}
m=m->next;
}
SetFlags(old_flags);
return FALSE;
}
public BoolU4 HeapChk(TssStruct *tss=NULL)
//This just detects one type of error--
// when a freed value is not valid.
{
I8 i;
UnusedAllocatedMem *u;
BoolU4 result=TRUE;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
if (!IsInHeap(u,tss))
result=FALSE;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
if (!IsInHeap(u,tss))
result=FALSE;
u=u->next;
}
SetFlags(old_flags);
return result;
}
//TODO:Crashes
///More of a heap check at the moment
void CollectFreedAllocatedMem(TssStruct *tss=NULL)
{
I8 i,cnt;
//I8 j;
UnusedAllocatedMem *u,**sort_buf;
U8 old_flags=GetFlags;
// U4 *dd;
if (!tss) tss=Fs;
Cli;
cnt=0;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
cnt++;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
cnt++;
u=u->next;
}
SetFlags(old_flags);
//We might disturb the Free list and irq's might Free some
sort_buf=MAlloc(((cnt+512)&-0x100)*PTR_SIZE);
Cli;
cnt=0;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
sort_buf[cnt++]=u;
u=u->next;
}
tss->heap_hash[i]=NULL;
}
u=tss->malloc_free_list;
while (u) {
sort_buf[cnt++]=u;
u=u->next;
}
tss->malloc_free_list=NULL;
for (i=0;i<FREE_PAGE_HASH_SIZE;i++)
free_page_hash[i]=NULL;
for (i=0;i<32;i++)
free_page_hash2[i]=NULL;
SetFlags(old_flags);
QSort(sort_buf,cnt,PTR_SIZE,&CompareUamPtrs);
for (i=0;i<cnt;i++) {
if (sort_buf[i]+sort_buf[i]->size>sort_buf[i+1])
cout "****";
coutln sort_buf[i]," ",sort_buf[i]->size;
}
/*
j=0;
for (i=0;i<cnt;i++) {
if (sort_buf[i]==sort_buf[j]+sort_buf[j]->size &&
sort_buf[j]->size+sort_buf[i]->size<HEAP_HASH_SIZE)
sort_buf[j]->size=sort_buf[j]->size+
sort_buf[i]->size;
else
sort_buf[++j]=sort_buf[i];
}
if (cnt) {
j++;
QSort(sort_buf,j,PTR_SIZE,&CompareUamSize);
for (i=0;i<j;i++) {
sort_buf[i]->next=sort_buf[i]->size;
Free(sort_buf[i]+4,tss);
}
}
*/
Free(sort_buf);
}
void TaskRepTask(TssStruct *tss,I8 indent)
{
TssStruct *tss1;
I1 *st,*desc=MSPrintF("%Q",tss->task_descriptor);
st=MSPrintF("$$MA+A,\"%08X\",\"Kill(0x%X);\r\",$$",tss,tss,tss);
PrintF("%*s%s $$TX+SCX,\"%Q...\",16$$ %08X %04X %04X %02X\r\n",
indent,"",st,desc,
TaskAllocatedMem(tss),
tss->task_flags,tss->crt_flags,
ExceptDepth(tss));
Free(st);
Free(desc);
tss1=tss->next_child_tss;
while (tss1!=tss+&tss->next_child_tss-&tss->next_sibling_tss) {
TaskRepTask(tss1,indent+2);
tss1=tss1->next_sibling_tss;
}
}
public void TaskRep()
{
U8 old_flags=GetFlags;
Cli;
TaskRepTask(adam_tss,0);
SetFlags(old_flags);
}
SysBpt *FindBpt(TssStruct *tss,U1 *a,U8 flags=-1,BoolU4 remove=FALSE)
{//Removes
SysBpt *result=NULL;
U8 old_flags=GetFlags;
SysBpt *tempb,*tempb1,*tempb2;
Cli;
tempb1=&tss->bpt_list;
tempb=tss->bpt_list;
while (tempb) {
tempb2=tempb->next;
if (tempb->address==a && tempb->flags & flags) {
result=tempb;
if (remove)
tempb1->next=tempb2;
else
tempb1=&tempb->next;
} else
tempb1=&tempb->next;
tempb=tempb2;
}
SetFlags(old_flags);
return result;
}
public BoolU4 SBpt(TssStruct *tss,U1 *a,U8 flags=SBPTF_BPT) //set Bpt
{
U8 old_flags=GetFlags;
BoolU4 result=TRUE;
SysBpt *tempb;
Cli;
if (!(tempb=FindBpt(tss,a,flags,FALSE))) {
tempb=MAlloc(sizeof(SysBpt),tss);
tempb->address=a;
tempb->b=*a;
tempb->flags=flags;
result=FALSE;
tempb->next=tss->bpt_list;
tss->bpt_list=tempb;
if (tss==Fs)
*a=0xCC;
}
SetFlags(old_flags);
return result;
}
public BoolU4 RBpt(TssStruct *tss,U1 *a,U8 flags=-1)
{ //remove one Bpt
U8 old_flags=GetFlags;
BoolU4 result=FALSE;
SysBpt *tempb;
Cli;
if (tempb=FindBpt(tss,a,flags,TRUE)) {
result=TRUE;
Free(tempb,tss);
}
SetFlags(old_flags);
return result;
}
BoolU4 DBpt(TssStruct *tss,U1 *a,U8 flags=-1) //disable one Bpt
{ //used for continuing after a bpt
U8 old_flags=GetFlags;
BoolU4 result=FALSE;
SysBpt *tempb;
Cli;
if (tempb=FindBpt(tss,a,flags,FALSE)) {
Bts(&tempb->flags,SBPTf_DISABLE);
result=TRUE;
}
SetFlags(old_flags);
return result;
}
public void CBpt(TssStruct *tss,U8 flags=-1) //clear Bpts
{
U1 *a;
U8 old_flags=GetFlags;
SysBpt *tempb,*tempb1,*tempb2;
Cli;
tempb=tss->bpt_list;
tempb1=&tss->bpt_list;
while (tempb) {
tempb2=tempb->next;
if (tempb->flags & flags) {
a=tempb->address;
if (tss==Fs)
*a=tempb->b;
Free(tempb,tss);
tempb1->next=tempb2;
} else
tempb1=&tempb->next;
tempb=tempb2;
}
SetFlags(old_flags);
}
public BoolU4 IsTextFile(I1 *filename)
{
return WildFileNameList(TEXT_FILE_MASK,filename);
}
public BoolU4 IsSourceFile(I1 *filename)
{
return WildFileNameList(SOURCE_FILE_MASK,filename);
}
public BoolU4 IsCFile(I1 *filename)
{
return WildFileNameList(C_FILE_MASK,filename);
}
public BoolU4 IsAsmFile(I1 *filename)
{
return WildFileNameList(ASM_FILE_MASK,filename);
}
+1043
View File
File diff suppressed because it is too large. Load diff
+769
View File
@@ -0,0 +1,769 @@
public class WsHashEntry
{
WsHashEntry *next;
I1 *word;
U4 type,use_cnt;
I1 *source_link;
DbgInfo *debug;
I4 num;
U4 hits;
U2 last_vowel,last_consonant;
I1 *glossary;
};
class WsSubstruct
{
I4 hits,
repeats;
};
#define WS_SUBSTRUCTS_PER_STRUCT 8
class WsStruct
{
WsStruct *next,*last;
I4 substructs, //-1 means WsMatrixSide
entries;
WsSubstruct subs[WS_SUBSTRUCTS_PER_STRUCT];
};
class WsMatrixSide
{
WsStruct *next,*last;
I4 const_minus_one, //-1 used to header in queue
row_hits,col_hits;
};
#define WS_MAX_MATRIX_WORDS 0x8000
public class WsMatrix
{
I4 n;
WsMatrixSide side[WS_MAX_MATRIX_WORDS];
};
public I4 ws_num_words,ws_num_matrix_words;
SysHashTable *ws_hash_table=NewHashTable(4096);
public I1 *ws_cur_word;
public BoolU4 ws_disable=TRUE;
#define NUM_WS_MATRICES 1
public WsMatrix ws_matrices[NUM_WS_MATRICES];
public WsHashEntry **ws_sorted_words;
TssStruct *ws_task=NULL;
class WsFilemaskEntry
{
WsFilemaskEntry *next;
I1 *mask;
LTDirEntry *flist;
};
WsFilemaskEntry *ws_filemask_list=NULL,
*ws_gloss_filemask_list=NULL;
void WsPutMatrix(WsMatrix *m)
{
I8 i,j;
WsMatrixSide *ms;
WsStruct *tempw;
coutln "n:",m->n;
for (i=0;i<ws_num_matrix_words;i++) {
ms=&m->side[i];
coutln "col:",i," rhits:",ms->row_hits," chits:",ms->col_hits;
tempw=ms->next;
while (tempw!=ms) {
coutln " substructs:",tempw->substructs,
" entries:",tempw->entries;
for (j=0;j<tempw->substructs;j++) {
PrintF("(%04X %04X) ",
tempw->subs[j].hits,
tempw->subs[j].repeats);
}
CrLf;
tempw=tempw->next;
}
}
View;
}
WsHashEntry *WsAddHash(I1 *w)
{
WsHashEntry **tempw1,*tempw=FindHashEntry(w,ws_hash_table,HTT_WORD);
if (tempw) {
tempw->hits++;
return tempw;
}
tempw1=FindHashBucket(w,ws_hash_table);
tempw=AMAllocZ(sizeof(WsHashEntry));
tempw->word=ANewString(w);
tempw->type=HTT_WORD;
tempw->use_cnt=1;
tempw->hits=1;
tempw->num=-1;
tempw->next=*tempw1;
*tempw1=tempw;
ws_num_words++;
return tempw;
}
void WsInitSides(WsMatrix *m)
{
I8 i;
WsStruct *tempa;
m->n=0;
for (i=0;i<WS_MAX_MATRIX_WORDS;i++) {
m->side[i].next=&m->side[i].next;
m->side[i].last=&m->side[i].next;
m->side[i].const_minus_one=-1;
m->side[i].row_hits=0;
m->side[i].col_hits=0;
tempa=AMAlloc(sizeof(WsStruct));
tempa->subs[0].hits=0;
tempa->subs[0].repeats=ws_num_matrix_words;
tempa->entries=ws_num_matrix_words;
tempa->substructs=1;
InsQue(tempa,m->side[i].last);
}
}
WsStruct *WsFindStruct(WsMatrix *m,I8 col,I8 row,
I4 *row_base,I4 *substruct)
{
WsStruct *tempa;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return NULL;
if (row<ws_num_matrix_words>>1) {
tempa=m->side[col].next;
*row_base=0;
while (row>=tempa->entries) {
row-=tempa->entries;
*row_base+=tempa->entries;
tempa=tempa->next;
}
for (*substruct=0;row>=tempa->subs[*substruct].repeats;*substruct=*substruct+1) {
row-=tempa->subs[*substruct].repeats;
*row_base+=tempa->subs[*substruct].repeats;
}
} else {
row=ws_num_matrix_words-row;
tempa=m->side[col].last;
*row_base=ws_num_matrix_words;
while (row>tempa->entries) {
row-=tempa->entries;
*row_base-=tempa->entries;
tempa=tempa->last;
}
for (*substruct=tempa->substructs-1;row>tempa->subs[*substruct].repeats;
*substruct=*substruct-1) {
row-=tempa->subs[*substruct].repeats;
*row_base-=tempa->subs[*substruct].repeats;
}
*row_base-=tempa->subs[*substruct].repeats;
}
return tempa;
}
public I8 WsGetHits(WsMatrix *m,I8 col,I8 row)
{
I8 row_base,substruct;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return 0;
WsStruct *tempa=WsFindStruct(m,col,row,
&row_base,&substruct);
return tempa->subs[substruct].hits;
}
WsSubstruct *WsNext(WsSubstruct *s,WsStruct **parent)
{
I8 i=(s-&(*parent)->subs)/sizeof(WsSubstruct)+1;
if (i>=(*parent)->substructs) {
i=0;
*parent=(*parent)->next;
if ((*parent)->substructs==-1)
return NULL;
}
return (*parent)->subs+i*sizeof(WsSubstruct);
}
WsSubstruct *WsLast(WsSubstruct *s,WsStruct **parent)
{
I8 i=(s-&(*parent)->subs)/sizeof(WsSubstruct)-1;
if (i<0) {
*parent=(*parent)->last;
if ((*parent)->substructs==-1)
return NULL;
i=(*parent)->substructs-1;
}
return (*parent)->subs+i*sizeof(WsSubstruct);
}
void WsRemove(WsSubstruct *s,WsStruct *parent)
{
I8 i=(s-&parent->subs)/sizeof(WsSubstruct);
if (i<0 || i>=WS_SUBSTRUCTS_PER_STRUCT || parent->substructs<1)
return;
if (parent->substructs==1) {
RemQue(parent);
AFree(parent);
} else {
parent->entries-=s->repeats;
parent->substructs--;
MemCpy(&parent->subs[i],&parent->subs[i+1],
(parent->substructs-i)*sizeof(WsSubstruct));
}
}
WsSubstruct *WsInsert(WsSubstruct *s,WsStruct **parent,WsSubstruct *last)
{
WsStruct *tempa,*p=*parent;
I8 j,k,i=(last-&p->subs)/sizeof(WsSubstruct)+1;
if (i>=WS_SUBSTRUCTS_PER_STRUCT) {
i=0;
p=p->next;
*parent=p;
if (p->substructs==-1) {
tempa=AMAlloc(sizeof(WsStruct));
InsQue(tempa,p->last);
p=tempa;
*parent=p;
tempa->entries=0;
tempa->substructs=0;
}
}
if (p->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=p->next;
if (tempa->substructs==-1 || tempa->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=AMAlloc(sizeof(WsStruct));
tempa->entries=0;
tempa->substructs=0;
InsQue(tempa,p);
k=0;
for (j=i;j<p->substructs;j++) {
MemCpy(&tempa->subs[k],&p->subs[j],sizeof(WsSubstruct));
tempa->entries+=tempa->subs[k++].repeats;
tempa->substructs++;
}
p->entries-=tempa->entries;
p->substructs-=tempa->substructs;
} else {
for (j=tempa->substructs-1;j>=0;j--)
MemCpy(&tempa->subs[j+1],&tempa->subs[j],sizeof(WsSubstruct));
MemCpy(&tempa->subs[0],
&p->subs[WS_SUBSTRUCTS_PER_STRUCT-1],
sizeof(WsSubstruct));
p->entries-=tempa->subs[0].repeats;
p->substructs--;
tempa->entries+=tempa->subs[0].repeats;
tempa->substructs++;
for (j=WS_SUBSTRUCTS_PER_STRUCT-2;j>=i;j--)
MemCpy(&p->subs[j+1],
&p->subs[j],sizeof(WsSubstruct));
}
} else {
for (j=p->substructs-1;j>=i;j--)
MemCpy(&p->subs[j+1],
&p->subs[j],sizeof(WsSubstruct));
}
p->entries+=s->repeats;
p->substructs++;
MemCpy(&p->subs[i],s,sizeof(WsSubstruct));
return &p->subs[i];
}
WsSubstruct *WsCondense(WsSubstruct *s,WsStruct **parent)
{
WsSubstruct *temps,*temps_l,*temps_n;
WsStruct *tempa_l,*tempa_n;
if ((*parent)->substructs==-1)
return NULL;
temps=s;
tempa_l=*parent;
temps_l=WsLast(temps,&tempa_l);
if (temps_l && temps_l->hits==temps->hits) {
temps_l->repeats+=temps->repeats;
tempa_l->entries+=temps->repeats;
WsRemove(temps,*parent);
*parent=tempa_l;
temps=temps_l;
}
tempa_n=*parent;
temps_n=WsNext(temps,&tempa_n);
if (temps_n && temps_n->hits==temps->hits) {
temps->repeats=temps->repeats+temps_n->repeats;
(*parent)->entries=(*parent)->entries+temps_n->repeats;
WsRemove(temps_n,tempa_n);
}
return temps;
}
I8 WsIncHits(WsMatrix *m,I8 col,I8 row)
{
I8 row_base,substruct,repeats;
WsSubstruct sn,*temps,*temps1,*temps_l;
WsStruct *tempa,*tempa1,*tempa_l;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return 0;
tempa=WsFindStruct(m,col,row,&row_base,&substruct);
temps=&tempa->subs[substruct];
repeats=temps->repeats;
if (repeats==1) {
temps->hits++;
temps=WsCondense(temps,&tempa);
} else {
if (row==row_base) {
temps->repeats--;
tempa->entries--;
sn.hits=1;
sn.repeats=1;
tempa_l=tempa;
if (!(temps_l=WsLast(&tempa->subs[substruct],&tempa_l))) {
tempa_l=tempa->last; //header
temps_l=&tempa_l->subs[WS_SUBSTRUCTS_PER_STRUCT-1];
}
temps=WsInsert(&sn,&tempa_l,temps_l);
temps=WsCondense(temps,&tempa_l);
} else if (row==repeats-1+row_base) {
temps->repeats--;
tempa->entries--;
sn.hits=1;
sn.repeats=1;
temps=WsInsert(&sn,&tempa,temps);
temps=WsCondense(temps,&tempa);
} else {
tempa->entries-=repeats;
sn.hits=temps->hits+1;
sn.repeats=1;
tempa1=tempa;
temps1=temps;
temps=WsInsert(&sn,&tempa1,temps1);
temps1->repeats=row-row_base;
tempa->entries+=temps1->repeats;
sn.repeats=row_base+repeats-(row+1);
sn.hits=temps1->hits;
WsInsert(&sn,&tempa1,temps);
}
}
m->n++;
m->side[col].col_hits++;
m->side[row].row_hits++;
return temps->hits;
}
#define WS_FIFO_SIZE 2048
void WsAddSingleFile(LTDirEntry *tempd,BoolU4 compile)
{
I1 ch,ch1,*buf,*ptr,*ptr2;
WsHashEntry **f_ptr,**f_ptr2,
**fifo=MAllocZ(WS_FIFO_SIZE*sizeof(U4));
I8 i,j,fp=0,k=0;
buf=ReadTextFile(tempd->full_name);
ptr=buf;
while (ch=*ptr++) {
while (ch && !Bt(alpha_numeric_bitmap,ch))
ch=*ptr++;
if (!ch) break;
ptr--;
ptr2=ptr;
do ch=*ptr2++;
while (Bt(alpha_numeric_bitmap,ch));
ptr2--;
ch1=*ptr2;
*ptr2=0;
if (*ptr) {
if (!compile)
WsAddHash(ptr);
else {
f_ptr=fifo+fp<<2;
*f_ptr=FindHashEntry(ptr,ws_hash_table,HTT_WORD);
if ((*f_ptr)->num<0)
*f_ptr=NULL;
else {
for (i=0;i<NUM_WS_MATRICES;i++) {
for (j=0;j<1<<(i<<1);j++) {
f_ptr2=fifo+((fp-j-1)&(WS_FIFO_SIZE-1))<<2;
if (*f_ptr2)
WsIncHits(&ws_matrices[i],(*f_ptr2)->num,(*f_ptr)->num);
}
}
}
fp=(fp+1)&(WS_FIFO_SIZE-1);
}
ptr=ptr2+1;
}
if (!ch1) break;
*ptr2=ch1;
}
Free(fifo);
Free(buf);
}
void WsAddGlossFile(LTDirEntry *tempd)
{
LtfEntry *ll;
WsHashEntry *temph;
Ltf *l=LtfRead(tempd->full_name);
I1 *temp;
ll=l->dummy.next;
while (ll!=l) {
if (ll->btype==LTFT_ANCHOR) {
if (temph=FindHashEntry(ll->aux_string,
ws_hash_table,HTT_WORD)) {
temp=MSPrintF("FA:%s,%s",
tempd->full_name,ll->aux_string);
AFree(temph->glossary);
temph->glossary=ANewString(temp);
Free(temp);
}
}
ll=ll->next;
}
LtfDel(l);
}
I8 WsSort(WsHashEntry **e1,WsHashEntry **e2)
{
I8 r;
if (!(r=(*e2)->hits - (*e1)->hits))
r=StrCmp((*e1)->word,(*e2)->word);
return r;
}
void WsAddFileList(LTDirEntry *tempm1,BoolU4 compile,BoolU4 gloss)
{
while (tempm1) {
coutln tempm1->full_name;
if (tempm1->attr & LT_ATTR_DIR) {
if (tempm1->sub)
WsAddFileList(tempm1->sub,compile,gloss);
} else {
if (gloss)
WsAddGlossFile(tempm1);
else
WsAddSingleFile(tempm1,compile);
}
tempm1=tempm1->next;
}
}
I8 WsSkipCrap(I1 *src,I8 len)
{
I8 j;
j=len-1;
while (j>=0) {
if (Bt(alpha_numeric_bitmap,src[j]))
break;
else
j--;
}
return j+1;
}
I8 WsPriorWordInString(I1 *src,I1 *dst,I8 len,I8 buf_size)
{
I8 i,j=0,k;
BoolU4 cont=TRUE;
i=len-1;
while (i>=0 && cont) {
if (!Bt(alpha_numeric_bitmap,src[i]))
cont=FALSE;
else
i--;
}
if (i>=-1 && len>0)
for (k=i+1;k<len && j<buf_size-1;k++)
dst[j++]=src[k];
dst[j]=0;
return i+1;
}
BoolU4 WsPartialMatch(I1 *partial,I1 *complete)
{
I8 i,l=StrLen(partial);
for (i=0;i<l;i++)
if (partial[i]!=complete[i])
return FALSE;
return TRUE;
}
#define MAX_FILLINS 10
I8 ws_partial_len=0,fillin_matches[MAX_FILLINS+1];
I8 ws_num_fillins=0,fillin_scores[MAX_FILLINS+1],fillin_hits[MAX_FILLINS+1];
void WsFillin(I8 n)
{
I1 *s;
I8 len;
n--;
if (n>=0 && n<ws_num_fillins) {
s=ws_sorted_words[fillin_matches[n]]->word;
len=StrLen(s);
if (len>ws_partial_len)
Auto(s+ws_partial_len);
}
}
void WsMan(I8 n,TssStruct *parent=NULL)
{
I1 *buf;
WsHashEntry *tempw;
SysHashEntry *temph;
BoolU4 old_preempt=Preempt(OFF);
n--;
if (n>=0 && n<ws_num_fillins) {
if (tempw=ws_sorted_words[fillin_matches[n]]) {
buf=tempw->glossary;
if (temph=FindHashEntry(tempw->word,Fs->hash_table,HTT_ALL)) {
if (temph->source_link)
buf=temph->source_link;
}
if (buf) {
buf=MSPrintF("Edit(\"%s\");",buf);
Preempt(old_preempt);
PopUp(buf,parent);
Free(buf);
}
}
}
Preempt(old_preempt);
}
void WsAddFillin(I8 i,I8 j,I8 old_num_fillins)
{
BoolU4 cont;
I8 k;
if (ws_num_fillins<MAX_FILLINS || i>fillin_scores[ws_num_fillins-1] ||
i==fillin_scores[ws_num_fillins-1] && ws_sorted_words[j]->hits>fillin_hits[ws_num_fillins-1]) {
cont=TRUE;
for (k=ws_num_fillins-1;k>=old_num_fillins && cont;k--)
if (i<=fillin_scores[k] || i==fillin_scores[k] && ws_sorted_words[j]->hits<=fillin_hits[k]) {
cont=FALSE;
k++; //offset k--
} else {
fillin_scores[k+1]=fillin_scores[k];
fillin_matches[k+1]=fillin_matches[k];
fillin_hits[k+1]=fillin_hits[k];
}
if (ws_num_fillins<MAX_FILLINS)
ws_num_fillins++;
fillin_scores[k+1]=i;
fillin_hits[k+1]=ws_sorted_words[j]->hits;
fillin_matches[k+1]=j;
}
}
void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll)
{
I8 i,j,k,data_col;
I1 ch=0,*buf,*buf1,*src=NULL,*st;
WsHashEntry *w2;
U8 timeout_jiffies=jiffies+JIFFY_FREQ*20/1000;
SysHashEntry *temph;
TssStruct *tss;
src=LtfGetLine(focus_l,ll,&data_col);
i=StrLen(src);
buf=MAlloc(i+1);
buf1=MAlloc(i+1);
if (data_col==-1)
data_col=StrLen(i);
data_col=WsPriorWordInString(src,buf,data_col,256);
ws_partial_len=StrLen(buf);
data_col=WsSkipCrap(src,data_col);
data_col=WsPriorWordInString(src,buf1,data_col,256);
AFree(ws_cur_word);
ws_cur_word=ANewString(buf);
if (StrLen(buf1))
w2=FindHashEntry(buf1,ws_hash_table,HTT_WORD);
else
w2=NULL;
Free(src);
ws_num_fillins=0;
if (w2 && w2->num<ws_num_matrix_words)
for (j=0;j<ws_num_matrix_words && jiffies<timeout_jiffies;j++)
if (WsPartialMatch(buf,ws_sorted_words[j]->word)) {
i=WsGetHits(&ws_matrices[0],w2->num,ws_sorted_words[j]->num);
WsAddFillin(i,j,0);
}
k=ws_num_fillins;
for (j=0;j<ws_num_words && jiffies<timeout_jiffies;j++)
if (WsPartialMatch(buf,ws_sorted_words[j]->word))
WsAddFillin(0,j,k);
if (ws_num_fillins) {
LtfReset(l,TRUE);
l->flags|=LTFF_MIN_SIZE;
l->text_attribute=(LTBLUE<<4)+BLACK;
aux->text_attribute=(LTBLUE<<4)+BLACK;
Fs->text_attribute=l->text_attribute;
Fs->border_attribute=l->text_attribute;
LtfPrintF(l,"Word:%-20ts\r\n",ws_cur_word);
for (i=0;i<ws_num_fillins;i++) {
st=ws_sorted_words[fillin_matches[i]]->word;
if (ws_sorted_words[fillin_matches[i]]->glossary)
ch='#';
else
ch=CH_SPACE;
if (tss=sys_cur_focus_task) {
temph=FindHashEntry(st,tss->hash_table,HTT_ALL);
if (temph) {
if (temph->source_link)
ch='*';
}
}
LtfPrintF(l,"%cF%02d %-20ts\r\n",ch,i+1,st);
}
LtfRecalc(l);
Bts(&Fs->crt_flags,CRTf_SHOW);
WindowToTop(Fs);
}
Free(buf);
Free(buf1);
}
void WsTsk()
{
TssStruct *focus_tss;
U8 sc,ch;
Ltf *l;
LtfEntry *ll;
Preempt(OFF);
InitLocalTask;
UseConsoleLtf(NULL);
Fs->window_left=200;
Fs->window_bottom=30;
do {
Sleep(500);
if (!ws_disable) {
focus_tss=sys_cur_focus_task;
if (focus_tss) {
l=focus_tss->cur_ltf;
if (l && focus_tss!=Fs) {
LtfRecalc(l); //TODO: is this needed?
ll=l->cur_entry;
if (ll) {
if (ll==l) ll=ll->last;
while (ll->last!=l && (ll->btype==LTFT_CR ||
ll->btype==LTFT_SOFT_CR))
ll=ll->last;
while ((ll->last->btype)!=LTFT_CR && ll->last!=l)
ll=ll->last;
if (!ws_disable)
WsPutChoices(Fs->cur_ltf,Fs->aux_ltf,l,ll);
}
}
}
}
} while (!ScanChar(&sc,&ch));
ws_task=NULL;
}
void WsAdd(I1 *wild=TEXT_FILE_MASK,BoolU4 gloss)
{
WsFilemaskEntry *tempfm=AMAlloc(sizeof(WsFilemaskEntry));
if (gloss) {
tempfm->next=ws_gloss_filemask_list;
ws_gloss_filemask_list=tempfm;
} else {
tempfm->next=ws_filemask_list;
ws_filemask_list=tempfm;
}
tempfm->mask=ANewString(wild);
tempfm->flist=NULL;
}
void WsTraverseFilelist(BoolU4 compile,BoolU4 gloss)
{
WsFilemaskEntry *tempfm;
U8 my_flags=(1<<FUf_RECURSE);
if (gloss)
tempfm=ws_gloss_filemask_list;
else
tempfm=ws_filemask_list;
while (tempfm) {
if (!compile)
tempfm->flist=FindFiles(tempfm->mask,&my_flags);
WsAddFileList(tempfm->flist,compile,gloss);
tempfm=tempfm->next;
}
}
public void WsInit(I1 *mask)
{
I1 *buf,buf2[512];
I8 i,j=0;
WsHashEntry *tempw;
ws_disable=TRUE;
//TODO:free old wordstat data
ws_num_words=0;
ws_num_matrix_words=0;
MemSet(&ws_hash_table->body,0,sizeof(U4)*(ws_hash_table->mask+1));
ws_cur_word=NULL;
ws_filemask_list=NULL;
ws_gloss_filemask_list=NULL;
buf=NewString(mask);
do {
RemoveFirstSeg(buf,";",buf2);
if (*buf2) {
StrCat(buf2,"/" TEXT_FILE_MASK);
WsAdd(buf2,FALSE);
}
} while (*buf2);
Free(buf);
coutln "\r\n\r\nPass #1";
WsTraverseFilelist(FALSE,FALSE);
ws_sorted_words=AMAlloc(PTR_SIZE*ws_num_words);
for (i=0;i<=ws_hash_table->mask;i++) {
tempw=ws_hash_table->body[i];
while (tempw) {
ws_sorted_words[j++]=tempw;
tempw=tempw->next;
}
}
QSort(ws_sorted_words,ws_num_words,PTR_SIZE,&WsSort);
for (i=0;i<ws_num_words;i++)
ws_sorted_words[i]->num=i;
if (ws_num_words<=WS_MAX_MATRIX_WORDS)
ws_num_matrix_words=ws_num_words;
else
ws_num_matrix_words=WS_MAX_MATRIX_WORDS;
for (i=0;i<NUM_WS_MATRICES;i++)
WsInitSides(&ws_matrices[i]);
coutln "\r\n\r\nPass #2";
WsTraverseFilelist(TRUE,FALSE);
buf=NewString(mask);
do {
RemoveFirstSeg(buf,";",buf2);
if (*buf2) {
StrCat(buf2,"/*.GL?");
WsAdd(buf2,TRUE);
}
} while (*buf2);
Free(buf);
coutln "\r\n\r\nGlossary Pass";
WsTraverseFilelist(FALSE,TRUE);
ws_disable=FALSE;
}
+164
View File
@@ -0,0 +1,164 @@
#define TIME_FILENAME "HOME/TIMEFILE.DTZ"
#define TET_EOF 0
#define TET_PUNCH_IN 1
#define TET_PUNCH_OUT 2
class TimeEntry
{
TimeEntry *next,*last;
LTDate d;
U1 type;
I1 *desc;
};
void ReadTimeFile(TimeEntry *header)
{
U1 *buf,*ptr,type;
TimeEntry *tempt;
LTDate *d;
buf=ReadFile(TIME_FILENAME);
if (!buf)
buf=MAllocZ(1);
header->next=header;
header->last=header;
ptr=buf;
while (type=*ptr++) {
tempt=MAllocZ(sizeof(TimeEntry));
tempt->type=type;
d=ptr;
ptr+=sizeof(LTDate);
tempt->d=*d;
tempt->desc=NewString(ptr);
ptr+=StrLen(ptr)+1;
InsQue(tempt,header->last);
}
Free(buf);
}
void WriteTimeFile(TimeEntry *header)
{
U1 *buf,*ptr;
TimeEntry *tempt;
LTDate *d;
U8 size=1; //for eof
tempt=header->next;
while (tempt!=header) {
size+=sizeof(U1)+sizeof(LTDate)+StrLen(tempt->desc)+1;
tempt=tempt->next;
}
buf=MAlloc(size);
ptr=buf;
tempt=header->next;
while (tempt!=header) {
*ptr++=tempt->type;
d=ptr;
*d=tempt->d;
ptr+=sizeof(LTDate);
StrCpy(ptr,tempt->desc);
ptr+=StrLen(tempt->desc)+1;
tempt=tempt->next;
}
*ptr=TET_EOF;
WriteFile(TIME_FILENAME,buf,size);
Free(buf);
}
void DelTimeEntries(TimeEntry *header)
{
TimeEntry *tempt=header->next,*tempt1;
while (tempt!=header) {
tempt1=tempt->next;
Free(tempt->desc);
Free(tempt);
tempt=tempt1;
}
Free(header);
}
public BoolU4 TimeRep(TimeEntry **header=NULL)
{
BoolU4 is_in=FALSE;
TimeEntry *tempt;
U8 week,cur_week,week_total=0;
TimeEntry *my_header=MAlloc(sizeof(TimeEntry));
if (header)
*header=my_header;
ReadTimeFile(my_header);
tempt=my_header->next;
while (tempt!=my_header) {
week=DivU8(tempt->d.date,7); //TODO
if (week!=cur_week) {
if (is_in)
week_total=week_total+GetCurTimeLTDate;
PrintF("Week Total:%h2T\r\n",week_total);
cur_week=week;
week_total=0;
}
if (tempt->type==TET_PUNCH_IN) {
PutS("$$FG RED$$IN ");
if (!is_in)
week_total=week_total-tempt->d;
is_in=TRUE;
} else {
PutS("$$FG RED$$OUT");
if (is_in)
week_total=week_total+tempt->d;
is_in=FALSE;
}
PrintF(" %h2D %T:$$FG$$\r\n%s\r\n",
tempt->d.date,tempt->d.time,tempt->desc);
tempt=tempt->next;
}
if (is_in)
week_total=week_total+GetCurTimeLTDate;
PrintF("$$FG RED$$Week Total:%h2T$$FG$$\r\n",week_total);
if (!header)
DelTimeEntries(my_header);
return is_in;
}
public void PunchOut()
{
BoolU4 is_in;
TimeEntry *tempt,*header;
is_in=TimeRep(&header);
if (!is_in) {
PutS("$$BK 1$$Already Punched-Out$$BK 0$$\r\n");
View;
} else {
tempt=MAlloc(sizeof(TimeEntry));
tempt->type=TET_PUNCH_OUT;
tempt->d=GetCurTimeLTDate;
PrintF("\r\nEnter Description:\r\n");
if (!(tempt->desc=SysGetS))
tempt->desc=MAllocZ(1);
InsQue(tempt,header->last);
WriteTimeFile(header);
}
DelTimeEntries(header);
}
public void PunchIn()
{
U4 is_in;
TimeEntry *tempt,*header;
is_in=TimeRep(&header);
if (is_in) {
PutS("$$BK 1$$Already Punched-In$$BK 0$$\r\n");
View;
} else {
tempt=MAlloc(sizeof(TimeEntry));
tempt->type=TET_PUNCH_IN;
tempt->d=GetCurTimeLTDate;
PrintF("\r\nEnter Description:\r\n");
if (!(tempt->desc=SysGetS))
tempt->desc=MAllocZ(1);
InsQue(tempt,header->last);
WriteTimeFile(header);
}
DelTimeEntries(header);
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
$TX +CX "STARS & BARS"$
$TX +CX "------------"$
$TX +CX "Joystick Button #1 issues movement command"$
$TX +CX "Joystick Throttle adjusts amount of movement"$
$TX +CX "and controls repulsive VS attractive cmds"$
$MA +A +CX "SPACE Restart"," "$
$MA +A +CX "ESC Quit ","\33"$
$TX +CX "---------------------------"$
$MA +A +CX "'1' No Map ","1"$
$MA +A +CX "'2' Friendly Fire Power Map","2"$
$MA +A +CX "'3' Lapse Time ","3"$
+1411
View File
File diff suppressed because it is too large. Load diff
+881
View File
@@ -0,0 +1,881 @@
/*
'%'= 32 bit
'*'= 16 bit
'!'= don't switch modes
'&'= default
*/
R8 AL 0;
R8 CL 1;
R8 DL 2;
R8 BL 3;
R8 AH 4;
R8 CH 5;
R8 DH 6;
R8 BH 7;
R16 AX 0;
R16 CX 1;
R16 DX 2;
R16 BX 3;
R16 SP 4;
R16 BP 5;
R16 SI 6;
R16 DI 7;
R32 EAX 0;
R32 ECX 1;
R32 EDX 2;
R32 EBX 3;
R32 ESP 4;
R32 EBP 5;
R32 ESI 6;
R32 EDI 7;
SEG ES 0;
SEG CS 1;
SEG SS 2;
SEG DS 3;
SEG FS 4;
SEG GS 5;
KEYWORD include 0;
KEYWORD define 1;
KEYWORD union 2;
KEYWORD catch 3;
KEYWORD class 4;
KEYWORD try 5;
KEYWORD if 6;
KEYWORD else 7;
KEYWORD for 8;
KEYWORD while 9;
KEYWORD extern 10;
KEYWORD LTextern 11;
KEYWORD return 12;
KEYWORD sizeof 13;
KEYWORD LTintern 14;
KEYWORD fmtstr 15;
KEYWORD fmtdata 16;
KEYWORD output_fun 17;
KEYWORD input_fun 18;
KEYWORD cout 19;
KEYWORD dbgo 19; /*used for debugging*/
KEYWORD do 20;
KEYWORD asm 21;
KEYWORD goto 22;
KEYWORD exe 23;
KEYWORD break 24;
KEYWORD continue 25;
KEYWORD switch 26;
KEYWORD case 27;
KEYWORD default 28;
KEYWORD public 29;
KEYWORD offset 30;
KEYWORD typeof 31;
KEYWORD import 32;
KEYWORD LTimport 33;
KEYWORD coutln 34;
KEYWORD dbgoln 34;
KEYWORD ALIGN 64;
KEYWORD END 65;
KEYWORD U1 66;
KEYWORD U2 67;
KEYWORD U4 68;
KEYWORD U8 68; /*ALIAS*/
KEYWORD DU1 69;
KEYWORD DU2 70;
KEYWORD DU4 71;
KEYWORD DUP 72;
KEYWORD ORG 73;
KEYWORD STRUC 74;
KEYWORD ENDS 75;
KEYWORD USE16 76;
KEYWORD USE32 77;
KEYWORD IMPORT 78;
KEYWORD EXPORT 79;
KEYWORD INSERT 80;
KEYWORD LIST 81;
KEYWORD NOLIST 82;
KEYWORD INSERT_COMPRESSED 83;
KEYWORD DU8 84;
OPCODE PUSH
0x0E NO CS
0x16 NO SS
0x1E NO DS
0x06 NO ES
0x0F 0xA0 NO FS
0x0F 0xA8 NO GS
0x6A &IB IMM8
0x68 *!IW IMM16
0x68 %!ID IMM32
0x50 +/R *NO R16
0x50 +/R %NO R32
0xFF /6 *NO RM16
0xFF /6 %NO RM32;
OPCODE PUSHA 0x60 NO;
OPCODE PUSHAW 0x60 *NO;
OPCODE PUSHAD 0x60 %NO;
OPCODE PUSHF 0x9C NO;
OPCODE PUSHFW 0x9C *NO;
OPCODE PUSHFD 0x9C %NO;
OPCODE POP
0x1F NO DS
0x07 NO ES
0x17 NO SS
0x0F 0xA1 NO FS
0x0F 0xA9 NO GS
0x58 +*RW R16
0x58 +%RD R32
0x8F /0 *NO RM16
0x8F /0 %NO RM32;
OPCODE POPA 0x61 NO;
OPCODE POPAW 0x61 *NO;
OPCODE POPAD 0x61 %NO;
OPCODE POPF 0x9D NO;
OPCODE POPFW 0x9D *NO;
OPCODE POPFD 0x9D %NO;
OPCODE MOV
// 0xA0 NO AL MOFFS8
0xA1 *NO AX MOFFS16
0xA1 %NO EAX MOFFS32
// 0xA2 NO MOFFS8 AL
0xA3 *NO MOFFS16 AX
0xA3 %NO MOFFS32 EAX
0x8A /R NO R8 RM8
0x8B /R *NO R16 RM16
0x8B /R %NO R32 RM32
0x88 /R NO RM8 R8
0x89 /R *NO RM16 R16
0x89 /R %NO RM32 R32
0x8C /R %NO RM16 SREG
0x8E /R %NO SREG RM16
0xB0 +RB R8 UIMM8
0xB8 +*RW R16 UIMM16
0xB8 +%RD R32 UIMM32
0xC6 NO RM8 UIMM8
0xC7 *NO RM16 UIMM16
0xC7 %NO RM32 UIMM32;
OPCODE ADC
0x14 IB AL UIMM8
0x15 *IW AX UIMM16
0x15 %ID EAX UIMM32
0x80 /2 IB RM8 UIMM8
0x83 /2 *IB RM16 IMM8
0x83 /2 %IB RM32 IMM8
0x81 /2 *IW RM16 UIMM16
0x81 /2 %ID RM32 UIMM32
0x12 /R NO R8 RM8
0x13 /R *NO R16 RM16
0x13 /R %NO R32 RM32
0x10 /R NO RM8 R8
0x11 /R *NO RM16 R16
0x11 /R %NO RM32 R32;
OPCODE ADD
0x04 IB AL UIMM8
0x05 *IW AX UIMM16
0x05 %ID EAX UIMM32
0x80 /0 IB RM8 UIMM8
0x83 /0 *IB RM16 IMM8
0x83 /0 %IB RM32 IMM8
0x81 /0 *IW RM16 UIMM16
0x81 /0 %ID RM32 UIMM32
0x02 /R NO R8 RM8
0x03 /R *NO R16 RM16
0x03 /R %NO R32 RM32
0x00 /R NO RM8 R8
0x01 /R *NO RM16 R16
0x01 /R %NO RM32 R32;
OPCODE AND
0x24 IB AL UIMM8
0x25 *IW AX UIMM16
0x25 %ID EAX UIMM32
0x80 /4 IB RM8 UIMM8
0x83 /4 *IB RM16 IMM8
0x83 /4 %IB RM32 IMM8
0x81 /4 *IW RM16 UIMM16
0x81 /4 %ID RM32 UIMM32
0x22 /R NO R8 RM8
0x23 /R *NO R16 RM16
0x23 /R %NO R32 RM32
0x20 /R NO RM8 R8
0x21 /R *NO RM16 R16
0x21 /R %NO RM32 R32;
OPCODE CMP
0x3C IB AL UIMM8
0x3D *IW AX UIMM16
0x3D %ID EAX UIMM32
0x80 /7 IB RM8 UIMM8
0x83 /7 *IB RM16 IMM8
0X83 /7 %IB RM32 IMM8
0x81 /7 *IW RM16 UIMM16
0x81 /7 %ID RM32 UIMM32
0x3A /R NO R8 RM8
0x3B /R *NO R16 RM16 //ERROR?
0x3B /R %NO R32 RM32
0x38 /R NO RM8 R8
0x39 /R *NO RM16 R16
0x39 /R %NO RM32 R32;
OPCODE OR
0x0C IB AL UIMM8
0x0D *IW AX UIMM16
0x0D %ID EAX UIMM32
0x80 /1 IB RM8 UIMM8
0x83 /1 *IB RM16 IMM8
0x83 /1 %IB RM32 IMM8
0x81 /1 *IW RM16 UIMM16
0x81 /1 %ID RM32 UIMM32
0x0A /R NO R8 RM8
0x0B /R *NO R16 RM16
0x0B /R %NO R32 RM32
0x08 /R NO RM8 R8
0x09 /R *NO RM16 R16
0x09 /R %NO RM32 R32;
OPCODE SBB
0x1C IB AL UIMM8
0x1D *IW AX UIMM16
0x1D %ID EAX UIMM32
0x80 /3 IB RM8 UIMM8
0x83 /3 *IB RM16 IMM8
0x83 /3 %IB RM32 IMM8
0x81 /3 *IW RM16 UIMM16
0x81 /3 %ID RM32 UIMM32
0x1A /R NO R8 RM8
0x1B /R *NO R16 RM16
0x1B /R %NO R32 RM32
0x18 /R NO RM8 R8
0x19 /R *NO RM16 R16
0x19 /R %NO RM32 R32;
OPCODE SUB
0x2C IB AL UIMM8
0x2D *IW AX UIMM16
0x2D %ID EAX UIMM32
0x80 /5 IB RM8 UIMM8
0x83 /5 *IB RM16 IMM8
0x83 /5 %IB RM32 IMM8
0x81 /5 *IW RM16 UIMM16
0x81 /5 %ID RM32 UIMM32
0x2A /R NO R8 RM8
0x2B /R *NO R16 RM16
0x2B /R %NO R32 RM32
0x28 /R NO RM8 R8
0x29 /R *NO RM16 R16
0x29 /R %NO RM32 R32;
OPCODE TEST
0xA8 IB AL UIMM8
0xA9 *IW AX UIMM16
0xA9 %ID EAX UIMM32
0xF6 /0 IB RM8 UIMM8
0xF7 /0 *IW RM16 UIMM16
0xF7 /0 %ID RM32 UIMM32
0x84 /R NO RM8 R8
0x85 /R *NO RM16 R16
0x85 /R %NO RM32 R32;
OPCODE NOP 0x90 NO;
OPCODE XCHG
0x90 +/R *NO R16 AX
0x90 +/R *NO AX R16
0x90 +/R %NO R32 EAX
0x90 +/R %NO EAX R32
0x86 /R NO R8 RM8
0x87 /R *NO R16 RM16
0x87 /R %NO R32 RM32
0x86 /R NO RM8 R8
0x87 /R *NO RM16 R16
0x87 /R %NO RM32 R32;
OPCODE XOR
0x34 IB AL UIMM8
0x35 *IW AX UIMM16
0x35 %ID EAX UIMM32
0x80 /6 IB RM8 UIMM8
0x83 /6 *IB RM16 IMM8
0x83 /6 %IB RM32 IMM8
0x81 /6 *IW RM16 UIMM16
0x81 /6 %ID RM32 UIMM32
0x32 /R NO R8 RM8
0x33 /R *NO R16 RM16
0x33 /R %NO R32 RM32
0x30 /R NO RM8 R8
0x31 /R *NO RM16 R16
0x31 /R %NO RM32 R32;
OPCODE CALL
0xE8 *!&CW REL16
0xFF /2 *!NO RM16
0xE8 %!&CD REL32
0xFF /2 %!NO RM32
// 0x9A CD PTR1616
// 0xFF /3 *NO M1616
// 0x9A *CP PTR1632
// 0x9A %CP PTR3232
// 0xFF /3 %NO M1632
;
OPCODE JMP
0xEB &CB REL8
0xE9 *!CW REL16
0xE9 %!CD REL32
0xFF /4 *!NO RM16
0xFF /4 %!NO RM32;
OPCODE JA
0x77 &CB REL8
0x0F 0x87 *!CW REL16
0x0F 0x87 %!CD REL32;
OPCODE JAE
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JB
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JBE
0x76 &CB REL8
0x0F 0x86 *!CW REL16
0x0F 0x86 %!CD REL32;
OPCODE JC
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JCXZ
0xE3 CB REL8;
OPCODE JECXZ
0xE3 CB REL8;
OPCODE JE
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE JZ
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE JG
0x7F &CB REL8
0x0F 0x8F *!CW REL16
0x0F 0x8F %!CD REL32;
OPCODE JGE
0x7D &CB REL8
0x0F 0x8D *!CW REL16
0x0F 0x8D %!CD REL32;
OPCODE JL
0x7C &CB REL8
0x0F 0x8C *!CW REL16
0x0F 0x8C %!CD REL32;
OPCODE JLE
0x7E &CB REL8
0x0F 0x8E *!CW REL16
0x0F 0x8E %!CD REL32;
OPCODE JNA
0x76 &CB REL8
0x0F 0x86 *!CW REL16
0x0F 0x86 %!CD REL32;
OPCODE JNAE
0x72 &CB REL8
0x0F 0x82 *!CW REL16
0x0F 0x82 %!CD REL32;
OPCODE JNB
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JNBE
0x77 &CB REL8
0x0F 0x87 *!CW REL16
0x0F 0x87 %!CD REL32;
OPCODE JNC
0x73 &CB REL8
0x0F 0x83 *!CW REL16
0x0F 0x83 %!CD REL32;
OPCODE JNE
0x75 &CB REL8
0x0F 0x85 *!CW REL16
0x0F 0x85 %!CD REL32;
OPCODE JNG
0x7E &CB REL8
0x0F 0x8E *!CW REL16
0x0F 0x8E %!CD REL32;
OPCODE JNGE
0x7C &CB REL8
0x0F 0x8C *!CW REL16
0x0F 0x8C %!CD REL32;
OPCODE JNL
0x7D &CB REL8
0x0F 0x8D *!CW REL16
0x0F 0x8D %!CD REL32;
OPCODE JNLE
0x7F &CB REL8
0x0F 0x8F *!CW REL16
0x0F 0x8F %!CD REL32;
OPCODE JNO
0x71 &CB REL8
0x0F 0x81 *!CW REL16
0x0F 0x81 %!CD REL32;
OPCODE JNP
0x7B &CB REL8
0x0F 0x8B *!CW REL16
0x0F 0x8B %!CD REL32;
OPCODE JNS
0x79 &CB REL8
0x0F 0x89 *!CW REL16
0x0F 0x89 %!CD REL32;
OPCODE JNZ
0x75 &CB REL8
0x0F 0x85 *!CW REL16
0x0F 0x85 %!CD REL32;
OPCODE JO
0x70 &CB REL8
0x0F 0x80 *!CW REL16
0x0F 0x80 %!CD REL32;
OPCODE JP
0x7A &CB REL8
0x0F 0x8A *!CW REL16
0x0F 0x8A %!CD REL32;
OPCODE JPE
0x7A &CB REL8
0x0F 0x8A *!CW REL16
0x0F 0x8A %!CD REL32;
OPCODE JPO
0x7B &CB REL8
0x0F 0x8B *!CW REL16
0x0F 0x8B %!CD REL32;
OPCODE JS
0x78 &CB REL8
0x0F 0x88 *!CW REL16
0x0F 0x88 %!CD REL32;
OPCODE JZ
0x74 &CB REL8
0x0F 0x84 *!CW REL16
0x0F 0x84 %!CD REL32;
OPCODE INC
0x40 +*RW R16
0x40 +%RD R32
0xFE /0 NO RM8
0xFF /0 *NO RM16
0xFF /0 %NO RM32;
OPCODE DEC
0x48 +*RW R16
0x48 +%RD R32
0xFE /1 NO RM8
0xFF /1 *NO RM16
0xFF /1 %NO RM32;
OPCODE NOT
0xF6 /2 NO RM8
0xF7 /2 *NO RM16
0xF7 /2 %NO RM32;
OPCODE NEG
0xF6 /3 NO RM8
0xF7 /3 *NO RM16
0xF7 /3 %NO RM32;
OPCODE MUL
0xF6 /4 NO RM8
0xF7 /4 *NO RM16
0xF7 /4 %NO RM32;
OPCODE IMUL
0xF6 /5 NO RM8
0xF7 /5 *NO RM16
0xF7 /5 %NO RM32;
OPCODE IMUL2
0x0F 0xAF /R *NO R16 RM16
0x0F 0xAF /R *NO R32 RM32
0x6B /R *IB RM16 IMM8
0x6B /R %IB RM32 IMM8
0x69 /R *IW RM16 UIMM16
0x69 /R %ID RM32 UIMM32;
OPCODE DIV
0xF6 /6 NO RM8
0xF7 /6 *NO RM16
0xF7 /6 %NO RM32;
OPCODE IDIV
0xF6 /7 NO RM8
0xF7 /7 *NO RM16
0xF7 /7 %NO RM32;
OPCODE AAA 0x37 NO;
OPCODE AAD 0xD5 0x0A NO;
OPCODE AAM 0xD4 0x0A NO;
OPCODE AAS 0x3F NO;
OPCODE ARPL 0x63 /R NO RM16 R16;
OPCODE BOUND
0x62 /R *NO RM16 R16
0x62 /R %NO RM32 R32;
OPCODE BSF
0x0F 0xBC /R *NO R16 RM16
0x0F 0xBC /R %NO R32 RM32;
OPCODE BSR
0x0F 0xBD /R *NO R16 RM16
0x0F 0xBD /R %NO R32 RM32;
OPCODE BSWAP
0x0F 0xC8 /R %NO R32;
OPCODE BT
0x0F 0xA3 /R *NO RM16 R16
0x0F 0xA3 /R %NO RM32 R32
0x0F 0xBA /4 *IB RM16 UIMM8
0x0F 0xBA /4 %IB RM32 UIMM8;
OPCODE BTC
0x0F 0xBB /R *NO RM16 R16
0x0F 0xBB /R %NO RM32 R32
0x0F 0xBA /7 *IB RM16 UIMM8
0x0F 0xBA /7 %IB RM32 UIMM8;
OPCODE BTR
0x0F 0xB3 /R *NO RM16 R16
0x0F 0xB3 /R %NO RM32 R32
0x0F 0xBA /6 *IB RM16 UIMM8
0x0F 0xBA /6 %IB RM32 UIMM8;
OPCODE BTS
0x0F 0xAB /R *NO RM16 R16
0x0F 0xAB /R %NO RM32 R32
0x0F 0xBA /5 *IB RM16 UIMM8
0x0F 0xBA /5 %IB RM32 UIMM8;
OPCODE CBW 0x98 NO;
OPCODE CDQ 0x99 NO;
OPCODE CLC 0xF8 NO;
OPCODE CLD 0xFC NO;
OPCODE CLI 0xFA NO;
OPCODE CLTS 0x0F 0x06 NO;
OPCODE CMC 0xF5 NO;
OPCODE CMPSB 0xA6 NO;
OPCODE CMPSW 0xA7 *NO;
OPCODE CMPSD 0xA7 %NO;
OPCODE CMPXCHG
0x0F 0xB0 /R NO RM8 R8
0x0F 0xB1 /R *NO RM16 R16
0x0F 0xB1 /R %NO RM32 R32;
//OPCODE CHPXCHG8B 0x0F 0xC7 NO RM64
OPCODE CPUID 0x0F 0xA2 NP;
OPCODE CWD 0x99 NO;
OPCODE CWDE 0x98 NO;
OPCODE DAA 0x27 NO;
OPCODE DAS 0x2F NO;
//OPCODE ENTER 0xC8 IW IB IMM16 IMM8;
OPCODE HLT 0xF4 NO;
OPCODE IN
0xE4 IB AL UIMM8
0xE5 *IB AX UIMM8
0xE5 %IB EAX UIMM8
0xEC NO AL DX
0xED *NO AX DX
0xED %NO EAX DX;
OPCODE INS
0x6C NO RM8 DX
0x6D *NO RM16 DX
0x6D %NO RM32 DX;
OPCODE INSB 0x6C NO;
OPCODE INSW 0x6D *NO;
OPCODE INSD 0x6D %NO;
OPCODE INTO 0xCE NO;
OPCODE INT3 0xCC NO;
OPCODE INT 0xCD IB IMM8;
OPCODE INVD 0x0F 0x08 NO;
//OPCODE INVLPG 0x0F 0x07 /7 M;
OPCODE IRET 0xCF NO;
OPCODE LAHF 0x9F NO;
OPCODE LAR
0x0F 0x02 /R *NO R16 RM16
0x0F 0x02 /R %NO R32 RM32;
OPCODE LEA
0x8D /R *NO R16 RM16
0x8D /R %NO R32 RM32;
OPCODE LEAVE 0xC9 NO;
OPCODE LGDT
0x0F 0x01 /2 *NO M16
0x0F 0x01 /2 %NO M32;
OPCODE LIDT
0x0F 0x01 /3 *NO M16
0x0F 0x01 /3 %NO M32;
//OPCODE LGS LSS LFS LDS LES
OPCODE LLDT
0x0F 0x00 /2 *NO RM16
0x0F 0x00 /2 %NO RM32;
OPCODE LMSW
0x0F 0x01 /6 *NO RM16
0x0F 0x01 /6 %NO RM32;
OPCODE LOCK 0xF0 NO;
OPCODE LODSB 0xAC NO;
OPCODE LODSW 0xAD *NO;
OPCODE LODSD 0xAD %NO;
OPCODE LOOP 0xE2 CB REL8;
OPCODE LOOPE 0xE1 CB REL8;
OPCODE LOOPZ 0xE1 CB REL8;
OPCODE LOOPNE 0xE0 CB REL8;
OPCODE LOOPNZ 0xE0 CB REL8;
OPCODE LSL
0x0F 0x03 /R *NO R16 RM16
0x0F 0x03 /R %NO R32 RM32;
OPCODE LTR
0x0F 0x00 /3 *NO RM16
0x0F 0x00 /3 %NO RM32;
OPCODE MOVSB 0xA4 NO;
OPCODE MOVSW 0xA5 *NO;
OPCODE MOVSD 0xA5 %NO;
OPCODE MOVSX
0x0F 0xBE /R *NO R16 RM8
0x0F 0xBE /R %NO R32 RM8
0x0F 0xBF /R %NO R32 RM16;
OPCODE MOVZX
0x0F 0xB6 /R *NO R16 RM8
0x0F 0xB6 /R %NO R32 RM8
0x0F 0xB7 /R %NO R32 RM16;
OPCODE OUT
0xE6 IB UIMM8 AL
0xE7 *IB UIMM8 AX
0xE7 %IB UIMM8 EAX
0xEE NO DX AL
0xEF *NO DX AX
0xEF %NO DX EAX;
OPCODE OUTSB 0x6E NO;
OPCODE OUTSW 0x6F *NO;
OPCODE OUTSD 0x6F %NO;
OPCODE RDMSR 0x0F 0x32 NO;
OPCODE REP_INSB 0xF3 0x6C NO;
OPCODE REP_INSW 0xF3 0x6D *NO;
OPCODE REP_INSD 0xF3 0x6D %NO;
OPCODE REP_MOVSB 0xF3 0xA4 NO;
OPCODE REP_MOVSW 0xF3 0xA5 *NO;
OPCODE REP_MOVSD 0xF3 0xA5 %NO;
OPCODE REP_OUTSB 0xF3 0x6E NO;
OPCODE REP_OUTSW 0xF3 0x6F *NO;
OPCODE REP_OUTSD 0xF3 0x6F %NO;
OPCODE REP_LODSB 0xF2 0xAC NO;
OPCODE REP_LODSW 0xF2 0xAD *NO;
OPCODE REP_LODSD 0xF2 0xAD %NO;
OPCODE REP_STOSB 0xF3 0xAA NO;
OPCODE REP_STOSW 0xF3 0xAB *NO;
OPCODE REP_STOSD 0xF3 0xAB %NO;
OPCODE REPE_CMPSB 0xF3 0xA6 NO;
OPCODE REPE_CMPSW 0xF3 0xA7 *NO;
OPCODE REPE_CMPSD 0xF3 0xA7 %NO;
OPCODE REPE_SCASB 0xF3 0xAE NO;
OPCODE REPE_SCASW 0xF3 0xAF *NO;
OPCODE REPE_SCASD 0xF3 0xAF %NO;
OPCODE REPNE_CMPSB 0xF2 0xA6 NO;
OPCODE REPNE_CMPSW 0xF2 0xA7 *NO;
OPCODE REPNE_CMPSD 0xF2 0xA7 %NO;
OPCODE REPNE_SCASB 0xF2 0xAE NO;
OPCODE REPNE_SCASW 0xF2 0xAF *NO;
OPCODE REPNE_SCASD 0xF2 0xAF %NO;
OPCODE RET 0xC3 NO;
OPCODE RET2 0xC2 IW UIMM16;
OPCODE RETF 0xCB NO;
OPCODE RETF2 0xCA IW UIMM16;
OPCODE RSM 0x0F 0xAA NO;
OPCODE SAHF 0x9E NO;
OPCODE SCASB 0xAE NO;
OPCODE SCASW 0xAF *NO;
OPCODE SCASD 0xAF %NO;
OPCODE SEGCS 0x2E NO;
OPCODE SEGSS 0x36 NO;
OPCODE SEGDS 0x3E NO;
OPCODE SEGES 0x26 NO;
OPCODE SEGFS 0x64 NO;
OPCODE SEGGS 0x65 NO;
OPCODE SETA 0x0F 0x97 NO RM8;
OPCODE SETAE 0x0F 0x93 NO RM8;
OPCODE SETB 0x0F 0x92 NO RM8;
OPCODE SETBE 0x0F 0x96 NO RM8;
OPCODE SETC 0x0F 0x92 NO RM8;
OPCODE SETE 0x0F 0x94 NO RM8;
OPCODE SETG 0x0F 0x9F NO RM8;
OPCODE SETGE 0x0F 0x9D NO RM8;
OPCODE SETL 0x0F 0x9C NO RM8;
OPCODE SETLE 0x0F 0x9E NO RM8;
OPCODE SETNA 0x0F 0x96 NO RM8;
OPCODE SETNAE 0x0F 0x92 NO RM8;
OPCODE SETNB 0x0F 0x93 NO RM8;
OPCODE SETNBE 0x0F 0x97 NO RM8;
OPCODE SETNC 0x0F 0x93 NO RM8;
OPCODE SETNE 0x0F 0x95 NO RM8;
OPCODE SETNG 0x0F 0x9E NO RM8;
OPCODE SETNGE 0x0F 0x9C NO RM8;
OPCODE SETNL 0x0F 0x9D NO RM8;
OPCODE SETNLE 0x0F 0x9F NO RM8;
OPCODE SETNO 0x0F 0x91 NO RM8;
OPCODE SETNP 0x0F 0x9B NO RM8;
OPCODE SETNS 0x0F 0x99 NO RM8;
OPCODE SETNZ 0x0F 0x95 NO RM8;
OPCODE SETO 0x0F 0x90 NO RM8;
OPCODE SETP 0x0F 0x9A NO RM8;
OPCODE SETPE 0x0F 0x9A NO RM8;
OPCODE SETPO 0x0F 0x9B NO RM8;
OPCODE SETS 0x0F 0x98 NO RM8;
OPCODE SETZ 0x0F 0x94 NO RM8;
//OPCODE SGDT 0x0F 0x01 /0 m
//OPCODE SIDT 0x0F 0x01 /0 m
OPCODE SHLD
0x0F 0xA5 /R *NO RM16 R16
0x0F 0xA5 /R %NO RM32 R32;
OPCODE SHRD
0x0F 0xAD /R *NO RM16 R16
0x0F 0xAD /R %NO RM32 R32;
OPCODE SLDT
0x0F 0x00 /0 *NO RM16
0x0F 0x00 /0 %NO RM32;
OPCODE SMSW
0x0F 0x01 /4 *NO RM16
0x0F 0x01 /4 %NO RM32;
OPCODE STC 0xF9 NO;
OPCODE STD 0xFD NO;
OPCODE STI 0xFB NO;
OPCODE STOSB 0xAA NO;
OPCODE STOSW 0xAB *NO;
OPCODE STOSD 0xAB %NO;
OPCODE STR
0x0F 0x00 /1 *NO RM16
0x0F 0x00 /1 %NO RM32;
OPCODE VERR
0x0F 0x00 /4 *NO RM16
0x0F 0x00 /4 %NO RM32;
OPCODE VERW
0x0F 0x00 /5 *NO RM16
0x0F 0x00 /5 %NO RM32;
OPCODE WAIT 0x9B NO;
OPCODE WBINVD 0x0F 0x09 NO;
OPCODE WRMSR 0x0F 0x30 NO;
OPCODE XADD
0x0F 0xC0 /R NO RM8 R8
0x0F 0xC1 /R *NO RM16 R16
0x0F 0xC1 /R %NO RM32 R32;
OPCODE XLATB 0xD7 NO;
OPCODE RCL
0xD2 /2 NO RM8 CL
0xD3 /2 *NO RM16 CL
0xD3 /2 %NO RM32 CL
0xC0 /2 IB RM8 UIMM8
0xC1 /2 *IB RM16 UIMM8
0xC1 /2 %IB RM32 UIMM8;
OPCODE RCL1
0xD0 /2 NO RM8
0xD1 /2 *NO RM16
0xD1 /2 %NO RM32;
OPCODE RCR
0xD2 /3 NO RM8 CL
0xD3 /3 *NO RM16 CL
0xD3 /3 %NO RM32 CL
0xC0 /3 IB RM8 UIMM8
0xC1 /3 *IB RM16 UIMM8
0xC1 /3 %IB RM32 UIMM8;
OPCODE RCR1
0xD0 /3 NO RM8
0xD1 /3 *NO RM16
0xD1 /3 %NO RM32;
OPCODE ROL
0xD2 /0 NO RM8 CL
0xD3 /0 *NO RM16 CL
0xD3 /0 %NO RM32 CL
0xC0 /0 IB RM8 UIMM8
0xC1 /0 *IB RM16 UIMM8
0xC1 /0 %IB RM32 UIMM8;
OPCODE ROL1
0xD0 /0 NO RM8
0xD1 /0 *NO RM16
0xD1 /0 %NO RM32;
OPCODE ROR
0xD2 /1 NO RM8 CL
0xD3 /1 *NO RM16 CL
0xD3 /1 %NO RM32 CL
0xC0 /1 IB RM8 UIMM8
0xC1 /1 *IB RM16 UIMM8
0xC1 /1 %IB RM32 UIMM8;
OPCODE ROR1
0xD0 /1 NO RM8
0xD1 /1 *NO RM16
0xD1 /1 %NO RM32;
OPCODE SAL
0xD2 /4 NO RM8 CL
0xD3 /4 *NO RM16 CL
0xD3 /4 %NO RM32 CL
0xC0 /4 IB RM8 UIMM8
0xC1 /4 *IB RM16 UIMM8
0xC1 /4 %IB RM32 UIMM8;
OPCODE SAL1
0xD0 /4 NO RM8
0xD1 /4 *NO RM16
0xD1 /4 %NO RM32;
OPCODE SAR
0xD2 /7 NO RM8 CL
0xD3 /7 *NO RM16 CL
0xD3 /7 %NO RM32 CL
0xC0 /7 IB RM8 UIMM8
0xC1 /7 *IB RM16 UIMM8
0xC1 /7 %IB RM32 UIMM8;
OPCODE SAR1
0xD0 /7 NO RM8
0xD1 /7 *NO RM16
0xD1 /7 %NO RM32;
OPCODE SHL
0xD2 /4 NO RM8 CL
0xD3 /4 *NO RM16 CL
0xD3 /4 %NO RM32 CL
0xC0 /4 IB RM8 UIMM8
0xC1 /4 *IB RM16 UIMM8
0xC1 /4 %IB RM32 UIMM8;
OPCODE SHL1
0xD0 /4 NO RM8
0xD1 /4 *NO RM16
0xD1 /4 %NO RM32;
OPCODE SHR
0xD2 /5 NO RM8 CL
0xD3 /5 *NO RM16 CL
0xD3 /5 %NO RM32 CL
0xC0 /5 IB RM8 UIMM8
0xC1 /5 *IB RM16 UIMM8
0xC1 /5 %IB RM32 UIMM8;
OPCODE SHR1
0xD0 /5 NO RM8
0xD1 /5 *NO RM16
0xD1 /5 %NO RM32;
OPCODE FILD
0xDF /5 NO RM32; //Load 64 bit I4
OPCODE FISTP
0xDF /7 NO RM32; //Store 64 bit I4
OPCODE FLD
0xDD /0 NO RM32; //Load 64 bit double
OPCODE FSTP
0xDD /3 NO RM32; //Store 64 bit double
OPCODE FST
0xDD /2 NO RM32; //Store 64 bit double
OPCODE FRSTOR
0xDD /4 NO RM32;
OPCODE FSAVE
0x9B 0xDD /6 NO RM32;
OPCODE FYL2X 0xD9 0xF1 NO;
OPCODE FYL2XP1 0xD9 0xF9 NO;
OPCODE F2XM1 0xD9 0xF0 NO;
OPCODE FABS 0xD9 0xE1 NO;
OPCODE FCHS 0xD9 0xE0 NO;
OPCODE FSIN 0xD9 0xFE NO;
OPCODE FCOS 0xD9 0xFF NO;
OPCODE FPTAN 0xD9 0xF2 NO;
OPCODE FPATAN 0xD9 0xF3 NO;
OPCODE FSQRT 0xD9 0xFA NO;
OPCODE FMULP 0xDE 0xC9 NO;
OPCODE FDIVP 0xDE 0xF9 NO;
OPCODE FDIVRP 0xDE 0xF1 NO;
OPCODE FPREM 0xD9 0xF8 NO;
OPCODE FADDP 0xDE 0xC1 NO;
OPCODE FSUBP 0xDE 0xE9 NO;
OPCODE FSUBRP 0xDE 0xE1 NO;
OPCODE FCOMIP 0xDF 0xF1 NO;
OPCODE FCLEX 0x9B 0xDB 0xE2 NO;
OPCODE FSTSW 0x98 0xDF 0xE0 NO;
OPCODE FDECSTP 0xD9 0xF6 NO;
OPCODE FINCSTP 0xD9 0xF7 NO;
OPCODE FFREE 0xDD 0xC0 NO;
OPCODE FRNDINT 0xD9 0xFC NO;
OPCODE FSCALE 0xD9 0xFD NO;
OPCODE FXTRACT 0xD9 0xF4 NO;
OPCODE FLD1 0xD9 0xE8 NO;
OPCODE FLDL2T 0xD9 0xE9 NO;
OPCODE FLDL2E 0xD9 0xEA NO;
OPCODE FLDPI 0xD9 0xEB NO;
OPCODE FLDLG2 0xD9 0xEC NO;
OPCODE FLDLN2 0xD9 0xED NO;
OPCODE FLDZ 0xD9 0xEE NO;
OPCODE FXCH 0xD9 0xC9 NO;
OPCODE FSTCW 0x9B 0xD9 /7 NO RM32;
OPCODE FLDCW 0xD9 /5 NO RM32;
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1126
View File
File diff suppressed because it is too large. Load diff
+4083
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Binary file not shown.
+1687
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+3045
View File
File diff suppressed because it is too large. Load diff
+773
View File
@@ -0,0 +1,773 @@
/*
void PrsPush(ParseStack *ps,U4 val)
{
ps->stk[ps->ptr++]=val;
}
U8 PrsPop(ParseStack *ps)
{
return ps->stk[--ps->ptr];
}
*/
LTextern CP_PRSPUSH void PrsPush(ParseStack *ps,U4 val);
LTextern CP_PRSPOP U4 PrsPop(ParseStack *ps);
#define PRST_UNARY_TERM 0
#define PRST_UNARY_MODIFIERS 1
#define PRST_DEREFERRENCE 2
#define PRST_CHECK_BINARY_OPS 3
BoolU4 PrsParseExpression(LexStruct *l,BoolU4 add_esp=FALSE)
{
BoolU4 result=TRUE,question_clause=FALSE,
cont_unary,cont_check_binary_ops,is_lower;
I8 i,j,k;
IntermediateCode *tempi,*tempi_first=l->cb.cb_out_ptr;
ClassStruct *tempc;
ParseStack *ps=MAlloc(sizeof(ParseStack));
ps->ptr=0;
PrsPush(ps,0); //terminate
PrsPush(ps,0); //terminate
try {
do {
l->flags&=~(LF_PREINC+LF_PREDEC+LF_POSTINC+LF_POSTDEC+LF_FUNCTION);
do i=PrsUnaryTerm(l,ps);
while (i==PRST_UNARY_TERM);
while (i==PRST_UNARY_MODIFIERS)
i=PrsUnaryModifier(l,ps);
if (i==PRST_DEREFERRENCE)
PrsDereferrence(l,ps);
//Check for binary Ops
do {
i=PrsPop(ps);
tempc=PrsPop(ps);
if (i && i.u2[1]<=1) {
tempi=l->cb.cb_last_out_ptr;
i&=0xFFFF;
tempc=tempi->ic_class;
if (Bt(deref_bitmap,i) && tempc->pointer_cnt) {
tempc=tempc-sizeof(ClassStruct);
while (tempc->return_class)
tempc=tempc->return_class;
if (tempc->type & HTT_INTERNAL_TYPE)
i=EC_DEREF_U8+0x10000+it_to_ec_offset[tempc->sub_type];
else
i=EC_DEREF_U4+0x10000;
} else {
if (i==EC_ADDRESS) {
if (!(l->flags & (LF_EAX|LF_ARRAY))) {
j=tempi->ic_code.u2[0];
if (!Bt(deref_bitmap,j))
PrsExcept(l,"ST_INVALID_LVALUE");
tempi->ic_code=EC_NOP;
tempc=tempc+sizeof(ClassStruct);
}
}
}
CbAddIc(l,i,0,tempc);
cont_check_binary_ops=TRUE;
} else {
PrsPush(ps,tempc);
PrsPush(ps,i);
i=l->token;
k=binary_ops_table[i];
if (k.u2[0]==EC_QUESTION)
question_clause=TRUE;
else if (k.u2[0]==EC_COLON) {
if (!question_clause)
k=0;
else
question_clause=FALSE;
}
if (!k.u2[1]) {
cont_check_binary_ops=FALSE;
cont_unary=FALSE; //DONE
} else {
Lex(l); //skip op
if (Bt(assign_bitmap,k.u2[0])) {
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
j=tempi->ic_code.u2[0];
if (!Bt(deref_bitmap,j))
PrsExcept(l,"ST_INVALID_LVALUE");
tempi->ic_code=EC_NOP;
while (tempc->return_class)
tempc=tempc->return_class;
if (!(tempc->type & HTT_INTERNAL_TYPE))
k=k.u2[0]+0x100000+it_to_ec_offset[IT_U4];
else
k=k.u2[0]+0x100000+it_to_ec_offset[tempc->sub_type];
}
do {
i=PrsPop(ps); //pop ops of higher prec
tempc=PrsPop(ps);
is_lower=FALSE;
if (i) {
if (k.u2[1]==i.u2[1]) {
if (!Bt(assign_bitmap,k.u2[0]) ||
!Bt(assign_bitmap,i.u2[0]))
is_lower=TRUE;
} else if (k.u2[1]>i.u2[1])
is_lower=TRUE;
}
if (is_lower)
CbAddIc(l,i,0,tempc);
else {
PrsPush(ps,tempc);
PrsPush(ps,i);
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
PrsPush(ps,tempc);
PrsPush(ps,k);
cont_check_binary_ops=FALSE;
cont_unary=TRUE;
break;
}
} while (TRUE);
}
}
} while (cont_check_binary_ops);
} while (cont_unary);
while (TRUE) {
i=PrsPop(ps);
tempc=PrsPop(ps);
if (i)
CbAddIc(l,i,0,tempc);
else
break;
}
} catch {
if (Fs->except_argc>0) {
if (Fs->except_argv[0]==EXCEPT_COMPILER) {
l->statement_cnt=0;
l->braces_cnt=0;
result=FALSE;
Fs->catch_except=TRUE;
}
}
}
Free(ps);
if (add_esp && result) {
if (Bt(push_bitmap,tempi_first->ic_code.u2[0])) {
tempi_first->ic_flags|=ICF_NO_PUSHES;
CbAddIc(l,EC_END_EXP,0,0);
} else
CbAddIc(l,EC_ADD_ESP32,8,0);
}
return result;
}
U8 PrsUnaryTerm(LexStruct *l,ParseStack *ps)
{
I8 i,*i_ptr;
I8 argc_cnt,size;
U8 d;
SysHashEntry *temph,**temph1;
ClassStruct *tempc,*tempc1,*tempc2;
GlblVarStruct *tempg;
MemberListStruct *tempm;
LexUndefEntry *templu;
CbMiscStruct *tempmc;
IntermediateCode *tempi;
BoolU4 needs_right_paren;
LexCbStack *templ,*templ1;
if (l->token==TK_INTEGER) {
if (l->cur_i<0)
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_U8]);
else
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_I8]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_DOUBLE) {
i_ptr=&l->cur_d;
CbAddIc(l,EC_DOUBLE,*i_ptr,sys_internal_types[IT_DOUBLE]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_STRING) {
d=LexExtendString(l,&size);
if (l->flags & LF_ASM_EXPRESSIONS)
CbAddIc(l,EC_U8,d,sys_internal_types[IT_I1]+sizeof(ClassStruct));
else {
tempmc=CbMiscNew(l,CBMT_STRING_CONSTANT);
CbAddIc(l,EC_STRING_CONSTANT,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct));
tempmc->st_len=size;
tempmc->string=d;
l->flags|=LF_HAS_MISC_DATA;
}
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_INSERT_BINARY) {
d=l->ident;
size=l->ident_len;
l->ident=NULL;
Lex(l);
if (l->flags & LF_ASM_EXPRESSIONS)
CbAddIc(l,EC_U8,d,sys_internal_types[IT_I1]+sizeof(ClassStruct));
else {
tempmc=CbMiscNew(l,CBMT_STRING_CONSTANT);
CbAddIc(l,EC_STRING_CONSTANT,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct));
tempmc->st_len=size;
tempmc->string=d;
l->flags|=LF_HAS_MISC_DATA;
}
return PRST_CHECK_BINARY_OPS;
}
if (l->token==TK_INSERT_BINARY_TYPE ||
l->token==TK_INSERT_BINARY_SIZE) {
CbAddIc(l,EC_U8,l->cur_i,sys_internal_types[IT_U8]);
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (l->token=='(') {
Lex(l); //Skip (
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,2);
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l); //skip )
l->flags=(l->flags & ~(LF_ARRAY+LF_FUNCTION)) | LF_EAX;
return PRST_UNARY_MODIFIERS;
}
i=unary_ops_table[l->token];
if (i.u2[1]) {
Lex(l); //Skip op
if (i.u2[0]==EC_ADDRESS && l->token==TK_IDENT) {
if (tempc=l->hash_entry) {
if (tempc->type & HTT_FUNCTION) {
if (!Bt(&tempc->flags,Cf_INTERNAL)) {
Lex(l); //skip fun name
if (Bt(&tempc->flags,Cf_EXTERN)) {
if (l->a)
CbAddIc(l,EC_ABSOLUTE_ADDRESS,
tempc->executable_address,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,
&tempc->executable_address,sys_internal_types[IT_U4]);
CbAddIc(l,EC_DEREF_U4,0,
sys_internal_types[IT_U4]);
} else {
if (l->a)
CbAddIc(l,EC_ABSOLUTE_ADDRESS,
tempc->executable_address,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,
tempc->executable_address,sys_internal_types[IT_U4]);
}
return PRST_CHECK_BINARY_OPS;
} //TODO: is this an error?
}//TODO: is this an error?
}//TODO: is this an error?
}
PrsPush(ps,tempc);
PrsPush(ps,i);
return PRST_UNARY_TERM;
}
if (l->token=='+') {
Lex(l);
return PRST_UNARY_TERM;
}
if (l->token!=TK_IDENT) {
if (l->token==TK_PLUS_PLUS) {
Lex(l);
l->flags|=LF_PREINC;
return PRST_UNARY_TERM;
}
if (l->token==TK_MINUS_MINUS) {
Lex(l);
l->flags|=LF_PREDEC;
return PRST_UNARY_TERM;
}
if (l->token=='$$' && l->flags & LF_ASM_EXPRESSIONS) {
Lex(l);
CbAddIc(l,EC_U8,l->instruction_pointer,sys_internal_types[IT_U4]);
return PRST_CHECK_BINARY_OPS;
}
PrsExcept(l,"ST_MISSING_EXPRESSION");
}
if (tempm=l->local_var_entry) {
l->flags&=~(LF_EAX+LF_ARRAY+LF_FUNCTION);
tempc=tempm->member_class+sizeof(ClassStruct);
if (tempm->flags & MLF_FUNCTION) {
l->flags|=LF_FUNCTION;
PrsPush(ps,0);
PrsPush(ps,tempm->parameter_cnt);
}
if (tempm->cnt) {
l->flags|=LF_ARRAY;
tempc+=sizeof(ClassStruct);
}
CbAddIc(l,EC_EBP,0,tempc);
CbAddIc(l,EC_U8,tempm->offset,tempc);
CbAddIc(l,EC_ADDITION,0,tempc);
Lex(l); //skip var name
return PRST_UNARY_MODIFIERS;
}
if (!(temph=l->hash_entry)) {
if (!(l->flags & LF_ASM_EXPRESSIONS))
PrsExcept(l,"ST_INVALID_LVALUE");
temph=MAllocZ(sizeof(SysHashEntry));
temph->string=l->ident;
l->ident=NULL;
if (temph->string[0]=='@' &&
temph->string[1]=='@') {
temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_LOCAL;
temph1=FindHashBucket(temph->string,l->local_hash_table);
} else {
temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_GLBL;
temph1=FindHashBucket(temph->string,l->glbl_hash_table);
}
temph->use_cnt=0;
SetSourceFileInfo(l,temph);
temph->next=*temph1;
*temph1=temph;
temph->user0=0;
}
if (temph->type & HTT_SYS_SYMBOL) {
if (!(temph->type & HTT_LITERAL) &&
!(temph->type & HTT_IMPORT))
l->absolute_address_cnt++;
if (temph->type & (HTT_UNRESOLVED_LOCAL|HTT_UNRESOLVED_GLBL)) {
templu=MAlloc(sizeof(LexUndefEntry));
templu->hash=temph;
templu->next=l->undef_hash_entry;
l->undef_hash_entry=templu;
if (temph->type & HTT_UNRESOLVED_LOCAL)
l->flags|=LF_UNRESOLVED_LOCAL;
else
l->flags|=LF_UNRESOLVED_GLBL;
CbAddIc(l,EC_U8,&temph->user0,sys_internal_types[IT_U4]);
CbAddIc(l,EC_DEREF_U4,0,sys_internal_types[IT_U4]);
} else {
if (l->a && !(temph->type & HTT_LITERAL))
CbAddIc(l,EC_ABSOLUTE_ADDRESS,temph->user0,sys_internal_types[IT_U4]);
else
CbAddIc(l,EC_U8,temph->user0,sys_internal_types[IT_U4]);
}
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
if (temph->type & HTT_FUNCTION) {
Lex(l); //skip fun name
CbPush(l);
templ=l->cb.cb_next;
l->cb.cb_next=NULL;
tempc=temph;
i=tempc->parameter_cnt;
tempm=tempc->member_list;
argc_cnt=0;
if (l->token!='(')
needs_right_paren=FALSE;
else {
Lex(l);
needs_right_paren=TRUE;
}
while (i--) {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (tempm->flags & MLF_DEFAULT_AVAILABLE &&
(l->token==')' || !needs_right_paren))
CbAddIc(l,EC_U8,tempm->default_value,tempm->member_class);
else
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,3);
else {
CbPush(l);
CbAddIc(l,0,0,0);
tempi=CmpOptPass1(l,NULL,FALSE);
CbPop(l);
tempc1=tempi->ic_class;
while (tempc1->return_class)
tempc1=tempc1->return_class;
tempc2=tempm->member_class;
while (tempc2->return_class)
tempc2=tempc2->return_class;
if (tempc2->sub_type==IT_DOUBLE &&
tempc1->sub_type!=IT_DOUBLE)
tempi->ic_flags|=ICF_TO_DOUBLE;
else
if (tempc2->sub_type!=IT_DOUBLE &&
tempc1->sub_type==IT_DOUBLE)
tempi->ic_flags|=ICF_TO_INT;
}
CbAddIc(l,0,0,0);
CbPush(l);
tempm=tempm->next;
}
if (tempm && tempm->flags & MLF_DOT_DOT_DOT) {
CbInitOutPtrs(&l->cb);
CbAddIc(l,EC_U8,0,tempm->member_class);
tempi=l->cb.cb_last_out_ptr;
CbAddIc(l,0,0,0);
CbPush(l);
if (needs_right_paren) {
if (l->token!=')') {
do {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,4);
CbAddIc(l,0,0,0);
CbPush(l);
argc_cnt++;
} while (l->token==',');
}
}
tempi->ic_data=argc_cnt++; //++ so add_esp latter works
}
if (needs_right_paren) {
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
}
templ1=templ->cb_next;
templ->cb_next=l->cb.cb_next;
l->cb.cb_next=templ;
CbPop(l);
templ=l->cb.cb_next;
l->cb.cb_next=templ1;
while (templ) {
templ1=templ->cb_next;
CbAppend(l,templ);
templ=templ1;
}
if (Bt(&tempc->flags,Cf_INTERNAL))
CbAddIc(l,tempc->executable_address,0,tempc->return_class);
else if (Bt(&tempc->flags,Cf_EXTERN)) {
if (l->a)
CbAddIc(l,EC_CALL_INDIRECT2,tempc->executable_address,tempc->return_class);
else
CbAddIc(l,EC_CALL_INDIRECT2,&tempc->executable_address,tempc->return_class);
CbAddIc(l,EC_ADD_ESP32,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class);
} else {
CbAddIc(l,EC_CALL,tempc->executable_address,tempc->return_class);
CbAddIc(l,EC_ADD_ESP32,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class);
}
l->flags=(l->flags|LF_EAX) & ~(LF_ARRAY|LF_FUNCTION);
return PRST_UNARY_MODIFIERS;
}
if (temph->type & HTT_GLBL_VAR) {
tempg=temph;
tempc=tempg->var_class+sizeof(ClassStruct);
l->flags&=~(LF_EAX|LF_ARRAY|LF_FUNCTION);
if (tempg->cnt) {
tempc+=sizeof(ClassStruct);
l->flags|=LF_ARRAY;
}
if (tempg->flags & GVAF_FUNCTION) {
//TODO:Not implemented
l->flags|=LF_FUNCTION;
}
if (l->a) {
if (tempg->flags & GVAF_EXTERN) { //TODO: Untested
CbAddIc(l,EC_U8,&tempg->data_address,tempc);
CbAddIc(l,EC_DEREF_U4,0,tempc);
} else {
CbAddIc(l,EC_ABSOLUTE_ADDRESS,tempg->data_address,tempc);
if (tempg->flags & GVAF_IMPORT)
CbAddIc(l,EC_DEREF_U4,0,tempc);
}
} else {
if (tempg->flags & GVAF_EXTERN) {
CbAddIc(l,EC_U8,&tempg->data_address,tempc);
CbAddIc(l,EC_DEREF_U4,0,tempc);
} else
CbAddIc(l,EC_U8,tempg->data_address,tempc);
}
Lex(l);
return PRST_UNARY_MODIFIERS;
}
if (!(temph->type & HTT_KEYWORD))
PrsExcept(l,"ST_MISSING_EXPRESSION");
if (temph->user0==KW_SIZEOF) {
if (Lex(l)!='(') PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
if (tempm=l->local_var_entry) {
tempc=tempm->member_class;
i=(tempm->cnt) ? tempm->cnt:1;
CbAddIc(l,EC_U8,tempc->size*i,sys_internal_types[IT_U4]);
} else {
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE|HTT_GLBL_VAR)))
PrsExcept(l,"ST_INVALID_CLASS");
CbAddIc(l,EC_U8,tempc->size,sys_internal_types[IT_U4]);
} //TODO: should allow '*' and '.member', etc;
if (Lex(l)!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_CHECK_BINARY_OPS;
} else if (temph->user0==KW_OFFSET) {
if (Lex(l)!='(') PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
if (tempm=l->local_var_entry)
tempc=tempm->member_class;
else {
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_GLBL_VAR)))
PrsExcept(l,"ST_INVALID_CLASS");
else if (tempc->type & HTT_GLBL_VAR) {
tempg=tempc;
tempc=tempg->var_class;
}
}
if (Lex(l)!='.')
PrsExcept(l,"ST_EXPECTING_DOT");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_MEMBER");
if (!(tempm=FindMember(l->ident,tempc)))
PrsExcept(l,"ST_INVALID_MEMBER");
CbAddIc(l,EC_U8,tempm->offset,sys_internal_types[IT_U4]);
if (Lex(l)!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_CHECK_BINARY_OPS;
}
PrsExcept(l,"ST_MISSING_EXPRESSION");
}
U8 PrsUnaryModifier(LexStruct *l,ParseStack *ps)
{
I8 i,j;
LexCbStack *templ,*templ2,*templl;
ClassStruct *tempc,*tempc1;
MemberListStruct *tempm;
IntermediateCode *tempi;
if (l->flags & LF_ASM_EXPRESSIONS)
return PRST_CHECK_BINARY_OPS;
if (l->token==TK_DEREFERRENCE) {
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_EAX | LF_ARRAY))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
CbAddIc(l,EC_DEREF_U4+0x10000,0,tempc);
} else
tempi->ic_class-=sizeof(ClassStruct);
}
if (l->token=='.' || l->token==TK_DEREFERRENCE) {
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class;
if (!(l->flags & LF_EAX))
tempc-=sizeof(ClassStruct);
if (!(tempc->type & HTT_CLASS))
PrsExcept(l,"ST_INVALID_CLASS");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_MEMBER");
if (!(tempm=FindMember(l->ident,tempc)))
PrsExcept(l,"ST_INVALID_MEMBER");
Lex(l); //skip member name
tempc1=tempm->member_class+sizeof(ClassStruct);
CbAddIc(l,EC_U8,tempm->offset,tempc1);
l->flags&=~(LF_EAX|LF_ARRAY|LF_FUNCTION);
if (tempm->cnt) {
tempc1+=sizeof(ClassStruct);
l->flags|=LF_ARRAY;
}
if(tempm->flags & MLF_FUNCTION) {
PrsPush(ps,0);
PrsPush(ps,tempm->parameter_cnt);
l->flags|=LF_FUNCTION;
}
CbAddIc(l,EC_ADDITION,0,tempc1);
return PRST_UNARY_MODIFIERS;
}
if (l->token==TK_CAST) {
if (Lex(l)!='(')
PrsExcept(l,"ST_EXPECTING_LEFT_PAREN");
if (Lex(l)!=TK_IDENT)
PrsExcept(l,"ST_INVALID_CLASS");
tempc=l->hash_entry;
if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE)))
PrsExcept(l,"ST_INVALID_CLASS");
while (Lex(l)=='*')
tempc+=sizeof(ClassStruct);
tempc+=sizeof(ClassStruct);
tempi=l->cb.cb_last_out_ptr;
tempi->ic_class=tempc;
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l);
return PRST_UNARY_MODIFIERS;
}
if (l->token=='[') {
Lex(l);
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_ARRAY | LF_EAX))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
while (!(tempc->type & HTT_INTERNAL_TYPE) && tempc->return_class)
tempc=tempc->return_class;
if (tempc->type==HTT_INTERNAL_TYPE)
i=EC_DEREF_U8+0x10000+it_to_ec_offset[tempc->sub_type];
else
i=EC_DEREF_U4+0x10000;
CbAddIc(l,i,0,tempc);
} else {
tempc=tempi->ic_class;
if (!(l->flags & LF_EAX))
tempc-=sizeof(ClassStruct);
}
tempc1=tempc-sizeof(ClassStruct);
CbAddIc(l,EC_U8,tempc1->size,tempc);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,5);
if (l->token!=']')
PrsExcept(l,"ST_MISSING_RIGHT_BRACKET");
Lex(l); //skip ]
CbAddIc(l,EC_MULTIPLICATION,0,tempc);
CbAddIc(l,EC_ADDITION,0,tempc);
l->flags&=~(LF_EAX|LF_ARRAY);
return PRST_UNARY_MODIFIERS;
}
if (l->token=='(' && l->flags & LF_FUNCTION) {
tempi=l->cb.cb_last_out_ptr;
if (!(l->flags & (LF_EAX | LF_ARRAY))) {
tempc=tempi->ic_class-sizeof(ClassStruct);
CbAddIc(l,EC_DEREF_U4+0x10000,0,tempc);
} else {
tempi->ic_class=tempi->ic_class-sizeof(ClassStruct);
tempc=tempi;
}
i=PrsPop(ps);
PrsPop(ps);
j=i;
Lex(l); //skip '('
CbPush(l);
templ=l->cb.cb_next;
l->cb.cb_next=NULL;
while (i--) {
if (l->token==',')
Lex(l);
CbInitOutPtrs(&l->cb);
if (!PrsParseExpression(l))
throw(EXCEPT_COMPILER,6);
CbAddIc(l,0,0,0);
CbPush(l);
}
if (l->token!=')')
PrsExcept(l,"ST_MISSING_RIGHT_PAREN");
Lex(l); //skip ')'
templl=templ->cb_next;
templ->cb_next=l->cb.cb_next;
l->cb.cb_next=templ;
CbPop(l);
templ=l->cb.cb_next;
l->cb.cb_next=templl;
while (templ) {
templ2=templ->cb_next;
CbAppend(l,templ);
templ=templ2;
}
CbAddIc(l,EC_CALL_INDIRECT,j<<3,tempc);
CbAddIc(l,EC_ADD_ESP32,j<<3+8,tempc);
l->flags=(l->flags | LF_EAX)&~(LF_ARRAY | LF_FUNCTION);
return PRST_UNARY_MODIFIERS;
}
if (l->token==TK_PLUS_PLUS) {
Lex(l);
l->flags|=LF_POSTINC;
return PRST_DEREFERRENCE;
}
if (l->token==TK_MINUS_MINUS) {
Lex(l);
l->flags|=LF_POSTDEC;
return PRST_DEREFERRENCE;
}
return PRST_DEREFERRENCE;
}
U8 PrsDereferrence(LexStruct *l,ParseStack *ps)
{
I8 i;
ClassStruct *tempc;
IntermediateCode *tempi;
if (l->flags & LF_FUNCTION) {
i=PrsPop(ps);
tempc=PrsPop(ps);
}
if (l->flags & LF_EAX)
return PRST_CHECK_BINARY_OPS;
tempi=l->cb.cb_last_out_ptr;
tempc=tempi->ic_class-sizeof(ClassStruct);
if (l->flags & LF_ARRAY) {
tempi->ic_class=tempc;
return PRST_CHECK_BINARY_OPS;
}
if (l->flags & LF_PREINC) {
l->flags&=~LF_PREINC;
i=EC_PP_U8;
} else if (l->flags & LF_PREDEC) {
l->flags&=~LF_PREDEC;
i=EC_MM_U8;
} else if (l->flags & LF_POSTINC) {
l->flags&=~LF_POSTINC;
i=EC_U8_PP;
} else if (l->flags & LF_POSTDEC) {
l->flags&=~LF_POSTDEC;
i=EC_U8_MM;
} else
i=EC_DEREF_U8;
while (tempc->return_class)
tempc=tempc->return_class;
if (tempc->type & HTT_INTERNAL_TYPE)
i+=it_to_ec_offset[tempc->sub_type];
else
i+=it_to_ec_offset[IT_U4];
CbAddIc(l,i+0x10000,0,tempc);
return PRST_CHECK_BINARY_OPS;
}
U1 *CompileExpression(LexStruct *l)
{
U1 *result;
U8 size;
DbgInfo *dbg=NULL;
CbPush(l);
CbInitOutPtrs(&l->cb);
if (PrsParseExpression(l,TRUE)) {
CbAddIc(l,EC_RET,0,0);
CbAddIc(l,0,0,0);
result=CbCompile(l,NULL,&size,&dbg);
} else
result=NULL;
CbPop(l);
Free(dbg);
return result;
}
BoolU4 GetExpression(LexStruct *l,U1 **e) //FALSE=no err
{
*e=CompileExpression(l);
if (*e)
return TRUE;
else
return FALSE;
}
I8 Expression(LexStruct *l) //FALSE=no err
{
I8 result;
U1 *e=CompileExpression(l);
if (e) {
result=Run(e);
DelExpression(e);
} else
result=0;
return result;
}
+759
View File
@@ -0,0 +1,759 @@
void OutChar(I1 **addr_dst,I1 ch,I1 **addr_buf)
{
I8 i;
I1 *dst=*addr_dst,*buf;
if (addr_buf) {
buf=*addr_buf;
i=dst-buf;
if (i>=MSize(buf)) {
buf=MAlloc(i<<1+1);
MemCpy(buf,*addr_buf,i);
dst=buf+i;
*addr_buf=buf;
}
}
*dst++=ch;
*addr_dst=dst;
}
void OutString(I1 *ptr,I1 **addr_buf,I1 *addr_dst,
I8 len,BoolU4 left_justify,BoolU4 truncate)
{
I8 i,j;
i=StrLen(ptr);
if (truncate && i>len)
i=len;
if (left_justify) {
for (j=0;j<i;j++)
OutChar(addr_dst,*(ptr++),addr_buf);
for (j=0;j<len-i;j++)
OutChar(addr_dst,CH_SPACE,addr_buf);
} else {
for (j=0;j<len-i;j++)
OutChar(addr_dst,CH_SPACE,addr_buf);
for (j=len-i;j<len;j++)
OutChar(addr_dst,*(ptr++),addr_buf);
}
}
I1 *MSPrintFPSect(U8 add,U8 field_length)
{
U8 offset;
SysHashEntry *temph;
if (temph=FindPSect(add,&offset)) {
if (offset<=0xFFFF) {
if (field_length>5)
return MSPrintF("%*ts,%04X",field_length-5,temph->string,offset);
else
return MSPrintF("%s,%04X",temph->string,offset);
}
}
if (field_length)
return MSPrintF("%*tX",field_length,add);
else
return MSPrintF("%X",add);
}
I1 *MSPrintFTime(LTDate ltdt,U8 sub_format)
{
LTDateStruct d;
ToLTDateStruct(&d,ltdt);
switch (sub_format) {
case 1:
return MSPrintF("%02d:%02d",d.hours,d.minutes);
case 2:
if (d.hours>=12)
return MSPrintF("%02d:%02d:%02d pm",d.hours-12,d.minutes,d.seconds);
else
return MSPrintF("%02d:%02d:%02d am",d.hours,d.minutes,d.seconds);
case 3:
if (d.hours>=12)
return MSPrintF("%02d:%02d pm",d.hours-12,d.minutes);
else
return MSPrintF("%02d:%02d am",d.hours,d.minutes);
case 4:
if (d.hours>=12)
return MSPrintF("%02d:%02d:%02dp",d.hours-12,d.minutes,d.seconds);
else
return MSPrintF("%02d:%02d:%02da",d.hours,d.minutes,d.seconds);
case 5:
if (d.hours>=12)
return MSPrintF("%02d:%02dp",d.hours-12,d.minutes);
else
return MSPrintF("%02d:%02da",d.hours,d.minutes);
case 6:
return MSPrintF("%dh %02dm",d.hours+ltdt.date*24,d.minutes);
case 7:
return MSPrintF("%dh %02dm %02ds",d.hours+ltdt.date*24,d.minutes,d.seconds);
case 8:
return MSPrintF("%dd %02dh %02dm",ltdt.date,d.hours,d.minutes);
case 9:
return MSPrintF("%dd %02dh %02dm %02ds",ltdt.date,d.hours,d.minutes,d.seconds);
case 10:
return MSPrintF("%dd %02dh %02dm %02d.%02ds",ltdt.date,d.hours,d.minutes,d.seconds,d.hundredths);
case 11:
return MSPrintF("%dh %02dm %02d.%02ds",d.hours+ltdt.date*24,d.minutes,d.seconds,d.hundredths);
case 12:
return MSPrintF("%d.%02d",MulU8(60,(ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.hundredths);
case 13:
return MSPrintF("%02d:%02d.%02d",MulU8(60,ltdt.date*24+d.hours)+d.minutes,d.seconds,d.hundredths);
case 14:
return MSPrintF("%02d:%02d:%02d.%02d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.hundredths);
case 15:
return MSPrintF("%dd %02dh %02dm %02d.%04ds",ltdt.date,d.hours,d.minutes,d.seconds,d.ten_thousandths);
case 16:
return MSPrintF("%dh %02dm %02d.%04ds",d.hours+ltdt.date*24,d.minutes,d.seconds,d.ten_thousandths);
case 17:
return MSPrintF("%d.%04d",MulU8(60,(ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.ten_thousandths);
case 18:
return MSPrintF("%02d:%02d.%04d",MulU8(60,ltdt.date*24+d.hours)+d.minutes,d.seconds,d.ten_thousandths);
case 19:
return MSPrintF("%02d:%02d:%02d.%04d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.ten_thousandths);
default:
return MSPrintF("%02d:%02d:%02d",d.hours,d.minutes,d.seconds);
}
}
I1 *MSPrintFDate(U8 dt,U8 sub_format)
{
LTDateStruct d;
LTDate ltdt=0;
ltdt.date=dt;
ToLTDateStruct(&d,ltdt);
switch (sub_format) {
case 1:
return MSPrintF("%02d/%02d",d.month,d.day_of_month);
case 2:
return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month);
case 3:
return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month,(d.year)%100);
case 4:
return MSPrintF("%02d/%02d/%d",d.month,d.day_of_month,d.year);
case 5:
return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month,d.day_of_month,d.year);
case 6:
return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",d.day_of_month);
case 7:
return MSPrintF("%3tZ, %3tZ %02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month);
case 8:
return MSPrintF("%3tZ %02d,%04d",d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 9:
return MSPrintF("%3tZ, %3tZ %02d,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 10:
return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.day_of_month);
case 11:
return MSPrintF("%Z, %Z %d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month);
case 12:
return MSPrintF("%Z %d,%d",d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 13:
return MSPrintF("%Z, %Z %d,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.month-1,"ST_MONTHS",d.day_of_month,d.year);
case 14:
return MSPrintF("%02d/%02d/%02d",d.day_of_month,d.month,(d.year)%100);
case 15:
return MSPrintF("%02d/%02d",d.day_of_month,d.month);
case 16:
return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month);
case 17:
return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month,(d.year)%100);
case 18:
return MSPrintF("%02d/%02d/%d",d.day_of_month,d.month,d.year);
case 19:
return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month,d.year);
case 20:
return MSPrintF("%02d %3tZ",d.day_of_month,d.month-1,"ST_MONTHS");
case 21:
return MSPrintF("%3tZ, %02d %3tZ",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS");
case 22:
return MSPrintF("%02d %3tZ,%04d",d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 23:
return MSPrintF("%3tZ, %02d %3tZ,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 24:
return MSPrintF("%d %Z",d.day_of_month,d.month-1,"ST_MONTHS");
case 25:
return MSPrintF("%Z, %d %Z",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS");
case 26:
return MSPrintF("%d %Z,%d",d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 27:
return MSPrintF("%Z, %d %Z,%d",d.day_of_week,"ST_DAYS_OF_WEEK",
d.day_of_month,d.month-1,"ST_MONTHS",d.year);
case 28:
return MSPrintF("%02d/%02d/%02d",(d.year)%100,d.month,d.day_of_month);
case 29:
return MSPrintF("%d/%02d/%02d",d.year,d.month,d.day_of_month);
case 30:
return MSPrintF("%02d%02d%02d",(d.year)%100,d.month,d.day_of_month);
case 31:
return MSPrintF("%d%02d%02d",d.year,d.month,d.day_of_month);
case 32:
return MSPrintF("%02d%02d%02d",d.month,d.day_of_month,(d.year)%100);
case 33:
return MSPrintF("%02d%02d%d",d.month,d.day_of_month,d.year);
case 34:
return MSPrintF("%3tZ",d.day_of_week,"ST_DAYS_OF_WEEK");
case 35:
return MSPrintF("%Z",d.day_of_week,"ST_DAYS_OF_WEEK");
case 36:
return MSPrintF("%3tZ",d.month-1,"ST_MONTHS");
case 37:
return MSPrintF("%Z",d.month-1,"ST_MONTHS");
case 38:
return MSPrintF("%d %3tZ",d.year,d.month-1,"ST_MONTHS");
case 39:
return MSPrintF("%d %Z",d.year,d.month-1,"ST_MONTHS");
case 40:
return MSPrintF("%02d %3tZ",(d.year)%100,d.month-1,"ST_MONTHS");
case 41:
return MSPrintF("%02d %Z",(d.year)%100,d.month-1,"ST_MONTHS");
case 42:
return MSPrintF("%3tZ %d",d.month-1,"ST_MONTHS",d.year);
case 43:
return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.year);
case 44:
return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",(d.year)%100);
case 45:
return MSPrintF("%Z %02d",d.month-1,"ST_MONTHS",(d.year)%100);
case 46:
return MSPrintF("%02d",(d.year)%100);
case 47:
return MSPrintF("%d",d.year);
default:
return MSPrintF("%02d/%02d/%02d",d.month,d.day_of_month,(d.year)%100);
}
}
I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv)
{
I1 ch,*ptr,**addr_buf,*buf=NULL,*addr_dst,
*temp1;
BoolU4 pad_zero,left_justify,truncate,neg,neg_e;
I8 i;
I8 k,len,dec_len,sub_format;
U8 d,cur_param=0;
double dd,dd1,*dd_ptr;
I1 temp_buf[80];
argc; //ref so no warning
if (dst) {
addr_buf=NULL;
} else {
buf=MAlloc(256);
addr_buf=&buf;
dst=buf;
}
addr_dst=&dst;
while (ch = *(src++)) {
if (ch=='%') {
if (*src=='-') {
left_justify=TRUE;
src++;
} else
left_justify=FALSE;
if (*src=='0') {
pad_zero=TRUE;
src++;
} else
pad_zero=FALSE;
len=0;
while (*src>='0' && *src<='9')
len=len*10+ *(src++)-'0';
if (*src=='*') {
src++;
len=argv[cur_param++];
}
dec_len=0;
if (*src=='.') {
src++;
while (*src>='0' && *src<='9')
dec_len=dec_len*10+ *(src++)-'0';
if (*src=='*') {
src++;
dec_len=argv[cur_param++];
}
}
if (*src=='t') {
src++;
truncate=TRUE;
} else
truncate=FALSE;
sub_format=0;
if (*src=='h') {
src++;
while (*src>='0' && *src<='9')
sub_format=sub_format*10+ *(src++)-'0';
if (*src=='*') {
src++;
sub_format=argv[cur_param++];
}
}
neg=FALSE;
k=0;
switch (*src++) {
case 's':
ptr=argv[cur_param++];
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'S':
ptr=SysText(argv[cur_param++]);
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'F':
ptr=ReadTextFile(argv[cur_param++]);
if (ptr) {
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
Free(ptr);
}
break;
case 'Q':
ptr=argv[cur_param++];
while (ch=*ptr++) {
if (ch=='$$') {
OutChar(addr_dst,ch,addr_buf);
OutChar(addr_dst,ch,addr_buf);
} else if (ch==CH_LINE_FEED){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'n',addr_buf);
} else if (ch==CH_CR){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'r',addr_buf);
} else if (ch==CH_TAB){
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,'t',addr_buf);
} else {
if (ch=='"' || ch=='\\')
OutChar(addr_dst,'\\',addr_buf);
OutChar(addr_dst,ch,addr_buf);
}
}
break;
case 'z':
ptr=PointAtListEntry(argv[cur_param],argv[cur_param+1]);
cur_param=cur_param+2;
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'Z':
ptr=SysTextSub(argv[cur_param],argv[cur_param+1]);
cur_param=cur_param+2;
OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate);
break;
case 'c':
OutChar(addr_dst,argv[cur_param++],addr_buf);
break;
case 'D':
temp1=MSPrintFDate(argv[cur_param++],sub_format);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'T':
temp1=MSPrintFTime(argv[cur_param++],sub_format);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'P':
if (truncate)
temp1=MSPrintFPSect(argv[cur_param++],len);
else
temp1=MSPrintFPSect(argv[cur_param++],0);
OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate);
Free(temp1);
break;
case 'd':
i=argv[cur_param++];
if (i<0) {
neg=TRUE;
i=-i;
}
while (!k || i) {
temp_buf[k++]=ModU8(i,10)+'0';
i=DivU8(i,10);
}
out_num:
i=(neg)? 1:0;
if (truncate && k+i>len)
k=len-i;
if (pad_zero)
for (;i<len-k;i++)
OutChar(addr_dst,'0',addr_buf);
else
for (;i<len-k;i++)
OutChar(addr_dst,32,addr_buf);
if (neg)
OutChar(addr_dst,'-',addr_buf);
for (i=k-1;i>=0;i--)
OutChar(addr_dst,temp_buf[i],addr_buf);
break;
case 'u':
d=argv[cur_param++];
while (!k|| d) {
temp_buf[k++]=ModU8(d,10)+'0';
d=DivU8(d,10);
}
goto out_num;
case 'f':
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
out_f:
if (i=dec_len)
dd*=Pow10(i);
dd=Round(dd);
while (i--) {
temp_buf[k++]=dd%10+'0';
dd=Floor(dd/10);
}
if (dec_len)
temp_buf[k++]='.';
do {
temp_buf[k++]=dd%10+'0';
dd=Floor(dd/10);
} while (dd);
goto out_num;
case 'e':
if (!len) len=12;
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
dd1=(dd) ? Log10(dd):0;
dd1=Round(dd1);
out_e:
dd/=Pow10(dd1);
if (dd1<0) {
dd1=-dd1;
neg_e=TRUE;
} else
neg_e=FALSE;
if (dd) {
if (dd<1.0) {
dd*=10;
if (neg_e)
dd1+=1;
else
dd1-=1;
} else if (dd>=10.0) {
dd/=10;
if (neg_e)
dd1-=1;
else
dd1+=1;
}
}
i=3;
do {
temp_buf[k++]=dd1%10+'0';
dd1=Floor(dd1/10);
} while (dd1 && i--);
if (neg_e)
temp_buf[k++]='-';
temp_buf[k++]='e';
dec_len=len-k-neg-2;
goto out_f;
case 'g':
if (!len) len=12;
dd_ptr=&argv[cur_param++];
dd=*dd_ptr;
if (dd<0) {
neg=TRUE;
dd=-dd;
}
dd1=(dd) ? Log10(dd):0;
dd1=Round(dd1);
if (dd1>=(len-1-dec_len) || dd1<-(dec_len-1))
goto out_e;
else
goto out_f;
case 'X':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k]=(d & 15)+'0';
if (temp_buf[k]>'9') temp_buf[k]+='A'-0x3A;
k++;
d>>=4;
}
goto out_num;
case 'x':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k]=(d & 15)+'0';
if (temp_buf[k]>'9') temp_buf[k]+='a'-0x3A;
k++;
d>>=4;
}
goto out_num;
case 'b':
d=argv[cur_param++];
while (!k || d) {
temp_buf[k++]=(d&1)+'0';
d>>=1;
}
goto out_num;
case '%':
OutChar(addr_dst,'%',addr_buf);
break;
}
} else
OutChar(addr_dst,ch,addr_buf);
}
OutChar(addr_dst,0,addr_buf);
return buf;
}
double A2Double(I1 *src,I1 **end_ptr=NULL)
{
I1 ch=*src++;
I8 i=0,j=0,k=0;
double d;
BoolU4 neg=FALSE;
while (ch==CH_SPACE||ch==CH_TAB||ch==CH_SHIFT_SPACE)
ch=*src++;
if (ch=='-') {
neg=TRUE;
ch=*src++;
}
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch))
i=MulU8(i,10)+ch-'0';
else {
if (ch=='.' || ch=='e' || ch=='E') break;
d=i;
goto a2d_end;
}
ch=*src++;
}
if (ch=='.')
ch=*src++;
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch)) {
j=MulU8(j,10)+ch-'0';
k++;
} else {
d=i+j*Pow10(-k);
if (ch=='e' || ch=='E') break;
goto a2d_end;
}
ch=*src++;
}
ch=*src++;
k=1;
if (ch=='-') {
k=-1;
ch=*src++;
}
j=0;
while (TRUE) {
if (Bt(dec_numeric_bitmap,ch))
j=MulU8(j,10)+ch-'0';
else {
d*=Pow10(j*k);
goto a2d_end;
}
ch=*src++;
}
a2d_end:
if (end_ptr) *end_ptr=src-1;
return (neg) ? -d:d;
}
/*
A2LTDate()
This routine recognizes the following formats:
1) "*+nnnn" "*-nnnnn"
2) mm/dd
3) mm/dd/yy
*/
LTDate A2LTDate(I1 *src2)
{
LTDate result=0;
LTDateStruct d,d1;
I1 *src=MStringUtil(src2,SU_REMOVE_SPACES|SU_TO_UPPER),
*v=NewString(src),
*p1=src;
BoolU4 start_month=FALSE,end_month=FALSE;
BoolU4 start_year=FALSE,end_year=FALSE;
MemSet(&d,0,sizeof(LTDateStruct));
MemSet(&d1,0,sizeof(LTDateStruct));
if (!StrNCmp(p1,"SM(",3)) {
p1+=3;
start_month=TRUE;
} else if (!StrNCmp(p1,"EM(",3)) {
p1+=3;
end_month=TRUE;
} else if (!StrNCmp(p1,"SY(",3)) {
p1+=3;
start_year=TRUE;
} else if (!StrNCmp(p1,"EY(",3)) {
p1+=3;
end_year=TRUE;
}
if (*p1=='*') {
p1++;
if (*p1=='+' || *p1=='-')
result.date=AtoI(p1,10,&p1);
result+=GetCurTimeLTDate;
} else {
RemoveFirstSeg(p1,"/",v); //Put month into v
d.month=AtoI(v);
if (Occurrences(p1,'/')) {
RemoveFirstSeg(p1,"/",v); //Put day into v leaving year in p1
d.day_of_month=AtoI(v);
d.year=AtoI(p1,10,&p1);
if (d.year<100) //if not 4 digit year
d.year+=2000;
} else {
d.day_of_month=AtoI(p1,10,&p1);
ToLTDateStruct(&d1,GetCurTimeLTDate);
d.year=d1.year;
}
result=ToLTDate(&d);
}
if (*p1==')') p1++;
if (start_month)
result.date=FirstDayOfMonth(result.date);
else if (end_month)
result.date=LastDayOfMonth(result.date);
else if (start_year)
result.date=FirstDayOfYear(result.date);
else if (end_year)
result.date=LastDayOfYear(result.date);
if (*p1=='+' || *p1=='-')
result.date+=AtoI(p1);
Free(src);
Free(v);
return result;
}
void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv)
//Pass pointer to data,
//For %s pass pointer to pointer (be careful because address
// of array is the same as array--create ptr to array and take address
{
I1 ch,*buf,*ptr,**pptr;
BoolU4 left_justify=FALSE;
I8 cur_param=0,i,j,k,len,*i_ptr,sub_format=0,dec_len;
double *d_ptr;
argc; //ref so no warning
while (ch = *(fmt++)) {
if (ch=='%') {
if (*fmt=='%') {
src++;
fmt++;
} else {
if (*fmt=='-') {
left_justify=TRUE;
fmt++;
} else
left_justify=FALSE;
len=0;
while (*fmt>='0' && *fmt<='9')
len=len*10+ (*(fmt++)-'0');
if (*fmt=='*') {
fmt++;
len=argv[cur_param++];
}
ch=*(fmt++);
if (ch && !len) {
ptr=src;
while (*ptr && *ptr!=*fmt)
ptr++;
len=ptr-src;
} else {
if (ch=='.') {
dec_len=0;
while (*fmt>='0' && *fmt<='9')
dec_len=dec_len*10+ (*(fmt++)-'0');
if (*fmt=='*') {
fmt++;
dec_len=argv[cur_param++];
}
ch=*(fmt++);
}
}
buf=MAlloc(len+1);
for (i=0;i<len;i++)
buf[i]=*(src++);
buf[i]=0;
switch (ch) {
case 's':
pptr=argv[cur_param++];
StrCpy(*pptr,buf);
break;
case 'c':
ptr=argv[cur_param++];
*ptr=*buf;
break;
case 'z':
i_ptr=argv[cur_param++];
*i_ptr=MatchListEntry(buf,argv[cur_param++]);
break;
case 'Z':
i_ptr=argv[cur_param++];
*i_ptr=MatchSysTextEntry(buf,argv[cur_param++]);
break;
case 'd':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32)
*i_ptr=MulI8(*i_ptr,10)+(buf[k]-'0');
break;
case 'X':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32) {
j=ToUpper(buf[k])-'0';
if (j>9) j=j-'A'+('9'+1);
*i_ptr=(*i_ptr<<4)+j;
}
break;
case 'b':
i_ptr=argv[cur_param++];
*i_ptr=0;
for (k=0;k<len;k++)
if (buf[k]!=32)
*i_ptr=*i_ptr<<1+(buf[k]-'0');
break;
case 'e':
case 'f':
case 'g':
d_ptr=argv[cur_param++];
*d_ptr=A2Double(buf);
break;
case 'D':
i_ptr=argv[cur_param++];
*i_ptr=A2LTDate(buf)>>32;
break;
}
Free(buf);
}
} else
src++;
}
}
+34
View File
@@ -0,0 +1,34 @@
exe {KeepPrivate(ON);}
exe {Externs2Imports(ON);}
#include "/LT/OSMain/ADAMK.HPZ"
#include "/LT/OSMain/ADAMK2.HPZ"
#include "/LT/OSMain/ADAMK3.HPZ"
exe {KeepPrivate(OFF);}
exe {Externs2Imports(OFF);}
exe {PTrace(ON);}
exe {OTrace(ON);}
exe {CTrace(ON);}
void Test()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
void Test1()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
void Test2()
{
I8 i;
for (i=0;i<8;i++) {
coutln 1,2,3,4,i;
}
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
/* To run this, do a directory, right click on
this file's name and select "AutoFile".
Or, type $LK,"AutoFile","MN:AutoFile"$(filename);
See $LK,"AutoFile","FF:::/LT/DOC/OSGlossary.GLZ,AutoFile"$ in the glossary for more info.
*/
//This is to demo autofiles.
I4 i;
for (i=0;i<3;i++)
PutS("Dir;\r");
PutS("$$FG RED$$//Press a letter to complete the mask$$FG$$\r");
PutS("Dir(\"*.");
I1 ch=GetKey; //Prompt for first digit of mask
PrintF("%c*\");\r",ch);
+9
View File
@@ -0,0 +1,9 @@
/* 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:::/LT/DOC/OSGlossary.GLZ,AutoFile"$ in the glossary for more info.
*/
PutS("$$FG RED$$Prof(&GrUpdateScreen,0x2000);$$FG$$\r");
PutS("$$FG RED$$//Collecting Data, Press A Key$$FG$$");
GetKey;
PutS("\r$$FG RED$$ProfRep;$$FG$$\r");
+26
View File
@@ -0,0 +1,26 @@
/* 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:::/LT/DOC/OSGlossary.GLZ,AutoFile"$ in the glossary for more info.
This autofile will renumber the defines in
Demo3.TXZ. Test it by numbering a few wrong
and running this demo.
*/
U1 i;
PutS("Edit(\"Demo3.TXZ\");\r");
//Go to start of file
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
for (i=0;i<=0xD6;i++) {
PrintF("%c0x%c",6,CH_ESC); //ctrl F
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
PrintF("%02X",i);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);
PrintF("%c%c",CH_BACKSPACE,CH_BACKSPACE);
Sleep(5);
}
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
/* This is not an AutoFile. It uses $LK,"AutoString","MN:AutoString"$
to run text as though from an AutoFile.
This example shows how you can drive pop-up
windows.
*/
Auto(" ");
coutln "PopUp #1:",PopUpNoYes;
AutoString("Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);PutChar(CH_SPACE);");
coutln "PopUp #2:",PopUpNoYes;
+23
View File
@@ -0,0 +1,23 @@
void Lowest(U8 i)
{
PrintF("%d,%P %P\r\n",i,Caller,CallerCaller);
}
void Mid1()
{
Lowest(1);
}
void Mid2()
{
Lowest(2);
}
void Top()
{
Mid1;
Mid2;
Lowest(3);
}
Top;
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
// COM port Terminal
void CommTerm(U4 port=1,U4 baud=9600)
{
U8 sc;
U8 ch=0;
coutln "ESC to exit";
CommOpen8N1(port,baud);
while (ch!=CH_ESC) {
if (CommScanChar(port,&ch))
PutChar(ch);
ch=0;
if (ScanChar(&sc,&ch))
CommPutChar(port,ch);
SwapInNext;
}
CommClose(port);
}
CommTerm;
+9
View File
@@ -0,0 +1,9 @@
LTDate d=GetCurTimeLTDate;
I4 i;
for (i=0;i<48;i++)
PrintF("%%h%dD:%h*D\r\n",i,i,d.date);
CrLf;
for (i=0;i<20;i++)
PrintF("%%h%dT:%h*T\r\n",i,i,d);
+145
View File
@@ -0,0 +1,145 @@
//This program does a fractel-like thing with
//integer arithmetic, since floating is not
//supported.
class Simplex
{
U8 x,y;
};
void Norm(U4 *lo,U4 *hi,Simplex *n1)
{
U8 result=n1->x+n1->y;
*lo=result.u4[0];
*hi=result.u4[1];
}
Simplex *CopySimplex(Simplex *dst, Simplex *src)
{
MemCpy(dst,src,sizeof(Simplex));
return dst;
}
Simplex *Mix(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=MulU8(n1->x,n2->x);
result->y=MulU8(n1->y,n2->y);
return result;
}
Simplex *Mangle(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=MulU8(n1->x,n2->y);
result->y=MulU8(n1->y,n2->x);
return result;
}
Simplex *Add(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=n1->x+n2->x;
result->y=n1->y+n2->y;
return result;
}
Simplex *Sub(Simplex *result,Simplex *n1,Simplex *n2)
{
result->x=n1->x-n2->x;
result->y=n1->y-n2->y;
return result;
}
void DrawIt()
{
U1 old_attr=Fs->text_attribute;
Fs->text_attribute=(BLACK<<4)+WHITE;
ClearWindowText;
Fs->text_attribute=old_attr;
}
void BigDawg()
{
U4 old_update,d_lo,d_hi;
U8 sc,ch;
I4 i,j,k,cnt;
Simplex n1,n2,n3,n4,n5,n6,n7,n8;
U4 in_color,key_hit;
U8 timeout_jiffies;
GrBitMap *base=GrNew(grbase);
old_update=Fs->update_window;
Fs->update_window=&DrawIt;
MaximizeWindow;
GrClear;
do {
n2.x=RandU4;
SwapInNext;
n2.y=RandU4;
cnt=RandU4;
SwapInNext;
n8.x=RandU4;
SwapInNext;
n8.y=RandU4;
SwapInNext;
in_color=RandU2 & 1;
key_hit=FALSE;
timeout_jiffies=jiffies+JIFFY_FREQ/8;
for (j=0;j<grheight;j++) {
if (jiffies>timeout_jiffies && j<20) {
key_hit=TRUE;
ch=0;
break;
}
if (ScanChar(&sc,&ch)) {
key_hit=TRUE;
break;
}
for (i=0;i<grwidth;i++) {
if (jiffies>timeout_jiffies && j<20) {
key_hit=TRUE;
ch=0;
break;
}
n1.x.u4[0]=i;
n1.y.u4[0]=j;
n1.x.u4[1]=0;
n1.y.u4[1]=0;
CopySimplex(&n3,&n1);
k=0;
Norm(&d_lo,&d_hi,&n3);
while (d_lo<cnt && k<0x100) {
if (jiffies>timeout_jiffies && j<20) {
key_hit=TRUE;
ch=0;
break;
}
Mangle(&n7,Mix(&n4,&n3,&n1),
Add(&n5,&n3,&n2));
k++;
Norm(&d_lo,&d_hi,
Add(&n3,&n7,Mangle(&n6,&n3,&n8)));
}
if (!in_color)
k=(k!=1)?15:0;
base->color=ROP_EQU+k;
GrPlot(base,i,j);
}
SwapInNext;
}
if (!key_hit)
ch=GetChar;
GrClear;
} while (ch!=CH_ESC && ch!=CH_CTRLQ);
Fs->update_window=old_update;
GrDel(base);
}
BigDawg; //Autostart when included
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
$HD,5$$FO,5$$LM,0$$RM,28$$WW,1$This is page 1. This is page 2.
This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc.
This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc.$RM,58$$LM,32$$CM+LX+TY+PRY+MRX,0,5,,$ This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc.
This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. $LM,0$ This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc. This is a demo doc.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
GrBitMap *b=GrNew(grbase);
GrBitMap *img1=GrBitMapNew(BMT_MONO,128,128);
GrBitMap *img2=GrBitMapNew(BMT_COLOR4,512,512);
img1->color=GR_WHITE;
img1->pen_width=3;
GrLine3(img1,60,0,0,0,60,0);
GrCircle(img1,30,30,20);
img2->color=GR_RED^GR_WHITE|ROP_OR;
img2->brush=img1;
GrCircle(img2,256-30,256-30,128,67);
img2->color=GR_BLUE^GR_WHITE;
img2->pen_width=6;
img2->brush=NULL;
GrLine3(img2,128,128,0,256+128,256+128,0);
GrLine3(img2,256+128,128,0,128,256+128,0);
I8 i;
for (i=0;i<256;i+=4) {
GrClear;
GrBlot(b,i-256,i-256,img2);
Sleep(20);
}
GrDel(img1);
GrDel(img2);
GrDel(b);
+60
View File
@@ -0,0 +1,60 @@
GrBitMap *base=GrNew(grbase2);
void DrawIt()
{
ClearWindowText;
base->pen_width=2;
base->color=GR_RED;
GrLine3(base,-100,-100,-100, -100, 100,-100);
GrLine3(base,-100, 100,-100, 100, 100,-100);
GrLine3(base, 100, 100,-100, 100,-100,-100);
GrLine3(base, 100,-100,-100, -100,-100,-100);
GrLine3(base,-100,-100, 100, -100, 100, 100);
GrLine3(base,-100, 100, 100, 100, 100, 100);
GrLine3(base, 100, 100, 100, 100,-100, 100);
GrLine3(base, 100,-100, 100, -100,-100, 100);
GrLine3(base,-100,-100, 100, -100,-100,-100);
GrLine3(base,-100, 100, 100, -100, 100,-100);
GrLine3(base, 100, 100, 100, 100, 100,-100);
GrLine3(base, 100,-100, 100, 100,-100,-100);
}
void Box()
{
double theta=0,phi=0,zeta=0,s=1,s1=1.05;
I8 *r1,*r2,*r3,*r4,*r5;
U8 sc,ch;
U4 *old_update_window=Fs->update_window;
Fs->update_window=&DrawIt;
base->x=200;
base->y=200;
base->flags|=BMF_TRANSFORMATION;
while (TRUE) {
if (ScanChar(&sc,&ch)) break;
r1=GrTheta(theta);
r2=GrPhi(phi);
r3=GrTheta(zeta);
r4=GrMulMat(r1,r2);
r5=GrMulMat(r4,r3);
Free(base->r);
base->r=GrScaleMat(r5,s);
Free(r1);
Free(r2);
Free(r3);
Free(r4);
Free(r5);
Sleep(60);
theta+=pi2/70;
phi +=pi2/90;
zeta +=pi2/110;
s *=s1;
if (s<0.2|| s>1.4) s1=1/s1;
}
Fs->update_window=old_update_window;
}
Box;
+12
View File
@@ -0,0 +1,12 @@
void DotNet()
{
I8 i;
GrBitMap *base=GrNew(grbase);
PrintF("$$CL$$"); //Clear text
base->color=GR_RED^GR_WHITE; //Printed on white background
for (i=0;i<600;i+=20)
GrLine(base,i,0,0,600-i,3);
}
DotNet; //Run when #included
//Type "GrClear;" to get rid of it
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
void MsgLoop()
{
U8 p1=0,p2=0,cmd=0;
coutln "Use $$LK \"these\",\"MN:MSG_CMD\"$$ defines "
"in your programs instead of hardcoded numbers.";
coutln "Press ESC to Exit";
while (cmd!=MSG_KEY_DOWN || (p1!=CH_ESC && p1!=CH_CTRLQ)) {
cmd=GetMsg(&p1,&p2,-2);
// The following fixes the cursor position
LtfBottom(Fs->cur_ltf);
PrintF("CMD:%02X P1:%08X P2:%08X\r\n",cmd,p1,p2);
}
}
MsgLoop;
+20
View File
@@ -0,0 +1,20 @@
void SoundOff()
{
Sound(0);
Exit;
}
void MusicDemoTsk()
{
Fs->end_task_cb=&SoundOff;
while (TRUE) {
Play("1wCqDsEFG2AB");
Play("wCqDsEFG3AB");
Play("wCqDsEFG4AB");
Play("wCqDsEFG5AB");
Play("wCqDsEFG6AB");
}
}
Spawn(&MusicDemoTsk,"MUSIC");
+15
View File
@@ -0,0 +1,15 @@
//Practice your ASCII knowledge ;-)
void Organ()
{
U1 ch;
coutln "Press keys to make sounds";
coutln "and press ESC to exit.";
do {
ch=GetKey;
Sound((ch-28)*25);
} while (ch!=CH_ESC);
Sound(0);
}
Organ;
+15
View File
@@ -0,0 +1,15 @@
void Spy(TssStruct *tss)
{
BoolU4 old_preempt=Preempt(OFF);
SysHashTable *old_hash=Fs->hash_table;
Fs->hash_table=tss->hash_table;
while (!ScanChar) {
LtfBottom(Fs->cur_ltf);
PrintF("$$CL$$");
TssRep(tss);
StackRep(tss->esp);
WinSync;
}
Fs->hash_table=old_hash;
Preempt(old_preempt);
}
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
void TreeSub(Ltf *l,LTDirEntry *tempm)
{
LTDirEntry *tempm1;
while (tempm) {
tempm1=tempm->next;
if (tempm->attr & LT_ATTR_DIR) {
LtfPutS(l,"$$TR \"\"$$");
LtfPrintF(l,"$$MA +A \"%s\",\"Cd(\\\"%s\\\");Dir;\r\"$$\r\n",
tempm->name,tempm->full_name);
if (tempm->sub) {
LtfPutS(l,"$$ID,+2$$");
TreeSub(l,tempm->sub);
LtfPutS(l,"$$ID,-2$$");
}
} else {
LtfPrintF(l,"$$LK \"%12s\",\"FI:%s\"$$\r\n",
tempm->name,tempm->full_name);
}
DelLTDirEntry(tempm);
tempm=tempm1;
}
}
+183
View File
@@ -0,0 +1,183 @@
//This is an alternative window manager.
//It augments the existing one found
//in $LK,"::/LT/ADAM/WINDOW.CPZ","FI:::/LT/ADAM/WINDOW.CPZ"$. It uses
//the real-time differential equation
//solver to reposition windows as though
//they were repulsively charged particles.
//I find this window manager to be a
//novelty, not desirable for actual
//use. You're welcome to add it, or
//some variation to your start-up
//scripts if you like it. It's not
//fully debugged.
//I had to cheat to make this work.
//I added $LK,"CRTf_HAS_BEEN_RESIZED2","MN:CRTf_HAS_BEEN_RESIZED2"$ and
//modified $LK,"::/LT/ADAM/WINDOW.CPZ","FI:::/LT/ADAM/WINDOW.CPZ"$.
Ode *o=NULL;
I8 tss_cnt=0;
TssStruct *tss_map=NULL;
void EndTsk()
{
RemQue(o);
OdeDel(o);
Free(tss_map);
Exit;
}
void MyDerivative(Ode *o,double t,Order2D3 *state,Order2D3 *DstateDt)
{
U8 i,j;
double f,d,dd,dx,dy;
MemSet(DstateDt,0,sizeof(Order2D3)*tss_cnt);
for (i=0;i<tss_cnt;i++) {
DstateDt[i].x=state[i].DxDt;
DstateDt[i].y=state[i].DyDt;
for (j=0;j<tss_cnt;j++) {
if (i!=j) {
dx=state[i].x-state[j].x;
dy=state[i].y-state[j].y;
dd=Sqr(dx)+Sqr(dy)+1.0;
d=Sqrt(dd);
dx/=d;
dy/=d;
f=1000000.0/dd;
DstateDt[i].DxDt+=f*dx;
DstateDt[i].DyDt+=f*dy;
}
}
DstateDt[i].DxDt-=1.0*state[i].DxDt; //damping
DstateDt[i].DyDt-=1.0*state[i].DyDt;
}
}
void WinMngTsk()
{
BoolU4 same;
I8 i,x,y,j,cnt;
Order2D3 *tempo;
TssStruct *tss;
//This makes so this task doesn't get
//swapped-out unless voluntarily.
Preempt(OFF);
Fs->end_task_cb=&EndTsk;
while (TRUE) {
cnt=0;
tss=Fs->next_tss;
while (tss!=Fs) {
if (Bt(&tss->crt_flags,CRTf_SHOW))
cnt++;
tss=tss->next_tss;
}
if (cnt==tss_cnt) {
same=TRUE;
i=0;
tss=Fs->next_tss;
while (tss!=Fs) {
if (Bt(&tss->crt_flags,CRTf_SHOW))
if (tss_map[i++]!=tss)
same=FALSE;
tss=tss->next_tss;
}
} else
same=FALSE;
if (!same) {
tss_cnt=cnt;
if (o) {
RemQue(o);
OdeDel(o);
Free(tss_map);
}
o=OdeNew(cnt*sizeof(Order2D3));
tss_map=MAlloc(sizeof(U4)*cnt);
i=0;
tss=Fs->next_tss;
while (tss!=Fs) {
if (Bt(&tss->crt_flags,CRTf_SHOW)) {
tss_map[i]=tss;
tempo=o->state+sizeof(Order2D3)*i;
tempo->x=(tss->window_left+tss->window_right)>>1;
tempo->y=(tss->window_top+tss->window_bottom)>>1;
tempo->z=0;
tempo->DxDt=0;
tempo->DyDt=0;
tempo->DzDt=0;
i++;
}
tss=tss->next_tss;
}
o->derivative=&MyDerivative;
o->tolerance_start=.1;
InsQue(o,Fs->last_ode);
}
Sleep(60);
cnt=0;
tss=Fs->next_tss;
while (tss!=Fs) {
if (Bt(&tss->crt_flags,CRTf_SHOW))
cnt++;
tss=tss->next_tss;
}
if (cnt==tss_cnt) {
same=TRUE;
i=0;
tss=Fs->next_tss;
while (tss!=Fs) {
if (Bt(&tss->crt_flags,CRTf_SHOW))
if (tss_map[i++]!=tss)
same=FALSE;
tss=tss->next_tss;
}
} else
same=FALSE;
if (same) {
Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT);
for (i=0;i<tss_cnt;i++) {
tss=tss_map[i];
tempo=o->state+sizeof(Order2D3)*i;
x=tss->window_right-tss->window_left;
y=tss->window_bottom-tss->window_top;
if (Bt(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2)) {
tempo->x=(tss->window_left+tss->window_right)>>1;
tempo->y=(tss->window_top+tss->window_bottom)>>1;
tempo->DxDt=0;
tempo->DyDt=0;
} else {
j=tempo->x-x>>1;
j&=-4;
if (j<4) j=4;
if (j+x>tss->crt_width-12) j=tss->crt_width-x-12;
SetWindowHor(tss,j,j+x);
j=tempo->y-y>>1;
if (j<2) j=2;
if (j+y>tss->crt_height-3) j=tss->crt_height-y-3;
SetWindowVert(tss,j,j+y);
x=(tss->window_left+tss->window_right)>>1;
y=(tss->window_top+tss->window_bottom)>>1;
if (tempo->x>x+8) tempo->x=x+8;
if (tempo->y>y+2) tempo->y=y+2;
if (tempo->x<x-8) tempo->x=x-8;
if (tempo->y<y-2) tempo->y=y-2;
if (tempo->DxDt>32.0) tempo->DxDt=32.0;
if (tempo->DyDt>8.0) tempo->DyDt=8.0;
if (tempo->DxDt<-32.0) tempo->DxDt=-32.0;
if (tempo->DyDt<-8.0) tempo->DyDt=-8.0;
}
Btr(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2);
}
}
}
}
Spawn(&WinMngTsk,"WINMGR2");
+39
View File
@@ -0,0 +1,39 @@
$WW,1$See $LK,"::/LT/DOC/Dollar.TXZ","FI:::/LT/DOC/Dollar.TXZ"$ for details of dollar sign cmds.
$FG,2$"Expression"$FG$ a number or C+ algebraic term with operators and C+ symbols can be entered.
$FG,2$"Macro"$FG$ Most entries can behave like macro entries if you assign them macro strings.
$FG,2$"AutoString"$FG$ Like a macro except it is an $LK,"AutoFile","FF:::/LT/DOC/OSGlossary.GLZ,AutoFile"$. You cannot have both an autostring and macro text defined.
$FG,5$Displayed Text$FG$ is the text that will be displayed for the item. For links, you can leave it blank and the details of the link will be shown.
$FG,5$Hide$FG$ means display nothing, making an entry invisible.
$FG,5$Left X$FG$ relative to the left margin.
$FG,5$Center X$FG$ relative to the horizontal center of the window.
$FG,5$Right X$FG$ relative to the right margin.
$FG,5$Top Y$FG$ relative to the top of the window.
$FG,5$Center Y$FG$ relative to the vertical center of the window.
$FG$$FG,5$Bottom Y$FG$ relative to the bottom of the window.
$FG,5$Blink$FG$ make the text blink.
$FG,5$Invert$FG$ make the text inverted.
$FG,5$Underline$FG$ make the text underlined.
$FG,5$Scroll X Length Expression$FG$ if a value is entered, the text will scroll in an area of this width.
$FG,5$Y Offset Expression$FG$ if a value is entered, the text will be shifted vertically by this many pixels, so you can make superscripts or subscripts.
$FG,5$X Offset Expression$FG$ if a value is entered, the text will be shifted horizontally by this many pixels.
$FG,5$Tree$FG$ The item will behave like a tree widget, with this as the adam.
$FG,5$Collapsed$FG$ The tree or hidden widget will begin collapsed.
$FG,5$Alias$FG$ For tree entries, the text of the subentry the cursor is on will appear here. This is for drop-down lists.
$FG,5$Quote$FG$ Make the result suitable for including in a program, in quotes, especially $FG,4$format_str$FG$ entries in class definitions.
$FG,5$X Expression$FG$ For cursor movements, this is the horizontal value.
$FG,5$Y Expression$FG$ For cursor movements, this is the vertical value.
$FG,5$$BK,1$PopUp$BK,0$$FG$ For macro's, run the macro in a PopUp window. Do this when making a macro to run a program, so it doesn't tie-up memory.
$FG,5$Escape$FG$ For macro's, send an ESC char to exit before running the macro. Without this, the macro runs in the wrong window, usually.
$FG,5$Refresh Data$FG$ For entries in programs where values are prompted, this flag updates the entry continuously.
$FG,5$Password$FG$ When items are prompted, the value will be shown as "*".
+151
View File
@@ -0,0 +1,151 @@
$WW,1$$FG,5$DOLLAR SIGN CMDS$FG$
LoseThos supports rich-text type commands which are bracketed with "$$". Use CTRL-L to experiment with them. Use CTRL-T to toggle between plain text and rich text.
The format of "$$" commands includes a two character code, +/-flags, a comma and parameters separated by commas. The flags often determine how many and what parameters the command takes.
See $LK,"default_flags","FA:::/LT/ADAM/LTF.CPZ,default_flags"$.
$TR,"TX Text"$
$ID,2$Normally, text is not bracketed with "$$", but if you wish to specify flag attributes to center text, you can bracket them with "$$" and enter flags such as "$FG,4$+CX$FG$". You cannot edit them if they are bracketed by "$$" unless you toggle to plain text mode with CTRL-T.
$ID,-2$$TR,"CR Hard Carriage Return"$
$ID,2$Carriage returns are normally specified without being bracketed with "$$".
$ID,-2$$TR,"SR Soft Carriage Return"$
$ID,2$Word wrap uses soft carriage returns which are not saved. You never place soft carriage returns by yourself.
$ID,-2$$TR,"TB Tab"$
$ID,2$Tabs are normally not bracketed with "$$", but are stored as ASCII#9.
$ID,-2$$TR,"CU Cursor position"$
$ID,2$The cursor position is usually stored as a ASCII#5 I1acter and is not bracketed with "$$". You do not normally enter cursor position commands yourself.
$ID,-2$$TR,"ID Indent +/- number"$
$ID,2$This changes the indention deeper if positive or shallower if negative. It effects the behavior of trees.
$ID,-2$$TR,"DA Data"$
$ID,2$This is primarily used for forms that prompt for data. Use CTRL-L as a resource editor-type thing to generate the text you'll need in your "fmtdata" command in a struct. If you add it directly with LtfPutS, you'll need to fill-in the data address. See $LK,"DoForm","MN:DoForm"$().
$ID,-2$$TR,"Text Colors"$
$ID,2$You place an expression(usually a color define--see $LK,"color defines","MN:BLACK"$) to indicate which of the 16 colors to use. If you enter no number, color returns to the default.
$FG,5$FG Foreground Color$FG$
$FG,5$BG Background Color$FG$
$FG,5$FD Default Foreground Color$FG$
$FG,5$BD Default Background Color$FG$
$FG,5$FL Foreground of Link Color$FG$
$FG,5$BL Background of Link Color$FG$
$FG,5$FM Foreground of Macro/Menu-Value Color$FG$
$FG,5$BM Background of Macro/Menu-Value Color$FG$
$FG,5$FA Foreground of Anchor Color$FG$
$FG,5$BA Background of Anchor Color$FG$
$FG,5$FH Foreground of Hidden widget Color$FG$
$FG,5$BH Background of Hidden widget Color$FG$
$FG,5$FE Foreground of Tree Color$FG$
$FG,5$BE Background of Tree Color$FG$
$ID,-2$$TR,"FU,BU User Prompts"$
$ID,2$These are special color changing commands. They are used when the user is prompted for text at the command line. They reset the cursor position if the cursor is positioned before them on the line. They are also used to indicate the start of a prompted string.
$ID,-2$$TR,"CL clear"$
$ID,2$Clear all entries except ones with hold($FG,4$+H$FG$) flags. This is good for programs which update data to the command line. It keeps the quantity of ltf entries down.
$ID,-2$$TR,"WW Word Wrap"$
$ID,2$Include a 1 or 0.
$ID,-2$$TR,"UL Underline"$
$ID,2$Include a 1 or 0.
$ID,-2$$TR,"IV Invert"$
$ID,2$Include a 1 or 0.
$ID,-2$$TR,"BK Blink"$
$ID,2$Include a 1 or 0.
$ID,-2$$TR,"SX Shift X position"$
$ID,2$* Include a number from -16 to 15.
* Only foreground is shifted.
* Positive right.
* For negative be sure to preceed with a comma.
$ID,-2$$TR,"SY Shift Y position"$
$ID,2$* Include a number from -16 to 15.
* Only foreground is shifted.
* Positive down.
* For negative be sure to preceed with a comma.
$ID,-2$$TR,"CM Cursor Movement"$
$ID,2$
$ID,-2$$TR,"AN Anchor"$
$ID,2$
$ID,-2$$TR,"LK Link"$
$ID,2$By default, links have a separate display text from link text, but with the $FG,4$-A$FG$ flag you can make the link displayed as in example 3.
Examples (Press CTRL-T to see):
1)$LK,"File link to Help.TXZ","::/LT/DOC/Help.TXZ"$
2)$LK,"File link to Help.TXZ with link type file","FI:::/LT/DOC/Help.TXZ"$
3)File link without different display string.$LK-A,"::/LT/DOC/Help.TXZ"$
4)$LK,"File find link searching for 'Admin'","FF:::/LT/DOC/Help.TXZ,Admin"$
5)$LK,"File find link searching for 3rd 'CTRL'","FF:::/LT/OSMain/ADAMK.HPZ,CTRL:3"$
6)$LK,"Manual page link","MN:PrintF"$
7)$LK,"File line number link","FL:::/LT/OSMain/ADAMK.HPZ,200"$
8)$LK,"File anchor link--Press CTRL-T to see anchor after you click","FA:::/LT/OSMain/SYSTEXT.CPZ,OS_SYSTEXT"$
$ID,-2$$TR,"BT Button"$
$ID,2$
$ID,-2$$TR,"CB Check Box"$
$ID,2$
$ID,-2$$TR,"MA Macro"$
$ID,2$Macro's are usually placed into menu/help areas and they have the '$FG,4$+X$FG$' flag set by default. Adding '$FG,4$-X$FG$' prevents the usual ESC from being sent (which exits the macro screen). Note that when you output a macro to the cmd line, when the user clicks on it, it will go to the bottom and execute it unless you cancel the ESC with a '$FG,4$-X$FG$'.
$ID,-2$$TR,"MU Menu Value"$
$ID,2$
$ID,-2$$TR,"HX Hex Edit"$
$ID,2$
$ID,-2$$TR,"Hidden Text Widget"$
$ID,2$$FG,5$HS Start of hidden text$FG$
$FG,5$HE End of hidden text$FG$
$FG,5$$FG$Hidden text widgets allow text to be placed in collapsable brackets like this $HS$$FG$This is hidden.$HE$ which can be expanded by clicking them. If you place a '$FG,4$-C$FG$' flag to uncollapse it, it will start expanded like this $HS-C$$FG$Click to hide$HE$. They can be nestled like this $HS$Click here:$HS$This is nestled.$HE$ okay?$HE$.
$ID,-2$$TR,"TR Tree Widget"$
$ID,2$A tree widget is a branch in a collapsable tree. The domain of the branch extends from the first +indent until enough -indents bring it back to where it started. Tree's begin collapsed unless a $FG,4$-C$FG$ flag is present.
$ID,-2$$TR,"PI Picture"$
$ID,2$You can insert a picture into text with CTRL-R. It is critical where the cursor is at the time you enter CTRL-R because the picture will be offset from that location. This is especially important when adding images to programs. Numbers for pictures are automatically chosen because copying to and from the clipboard requires this. You can insert another picture with the same image by hitting CTRL-T and manually adding a $$PI$$ entry with the same number. You can cause the $$PI$$ command to appear with some text associated with it by manually adding text into the $$PI$$ command, as in $$PI,"pic 2",2$$.
$ID,-2$$TR,"IB Insert Binary"$
$ID,2$This cmd is used to tell the compiler to fetch the binary data stored after the end of text. There is basically one type of binary data in LTF's at this point--pictures-- created with CTRL-R. They have a number associated with them. This number is automatically chosen, because copying to the clip-board and back requires renumbering. To use a $$IB$$ command, toggle to plain text (CTRL-T) after inserting a picture and check the number in the $$PI$$ command. Create a $$IB$$ command with the same number and the picture will be inserted into the compiled stream like a string constant. You can optionally include text to be displayed for the $$IB$$ command.
The main reason for the $$IB$$ command at this point is to pass a parameter to the $LK,"GrElemsPlot","MN:GrElemsPlot"$() function. See $LK,"::/LT/DEMO/Graphics/Sprite1.CPZ","FI:::/LT/DEMO/Graphics/Sprite1.CPZ"$.
$ID,-2$$TR,"IT Insert Binary Type"$
$ID,2$See $$IB$$. This command inserts a number into the compiled stream describing the type of binary data associated with a number. See $LK,"LTFBT_ELEMENT_GRAPH","MN:LTFBT_ELEMENT_GRAPH"$ for the types of binary data in LTF's.
$ID,-2$$TR,"IS Insert Binary Size"$
$ID,2$See $$IB$$. This command inserts a number into the compiled stream describing the size of binary data associated with a number.
$ID,-2$$TR,"BP Break Point"$
$ID,2$This is used by the debugger to mark a break point.
$ID,-2$$TR,"ER Error"$
$ID,2$When errors are detected in dollar commands, an $FG,5$ER$FG$ entry is generated to hold the garbage so it is not lost.
$ID,-2$
$FE,4$$TR,"FLAGS"$
$ID,2$$TR,"+H Hold"$
$ID,2$Hold entry and do not delete it when cleared with $FG,5$CL$FG$ or when the l->max_entries is exceeded. Word wrap is a good one to hold.
$ID,-2$$TR,"+A Auxilliary String"$
$ID,2$Most commands display a string. Some need other strings. A $FG,4$+A$FG$ means an auxilliary string is present. Links have $FG,4$+A$FG$ by default, so use a $FG,4$-A$FG$ if you wish the display string and the link string to be the same.
$ID,-2$$TR,"+TR Tree"$(obsolete)
$ID,2$* There is now a separate $FG,5$TR$FG$ command so this flag is obsolete.
* Make a tree branch. Usually this is placed on a text($FG,5$TX$FG$) entry. The tree extends from the start until another tree entry or when indentation has been expanded and reduced back to the starting value.
* A $FG,4$+C$FG$ flag on a tree will start it collapsed.
$ID,-2$$TR,"+PU PopUp"$
$ID,2$A PopUp flag on a macro ($FG,5$MA$FG$) will cause the commands to run in a pop-up window.
$ID,-2$$TR,"+C Collapsed"$
$ID,2$A collapsed flag on a tree $FG,5$TR$FG$ entry or a hide start $FG,5$HS$FG$ will cause it to start collapsed. A $FG,4$-C$FG$ flag will make it start open.
$ID,-2$$TR,"+X Exit"$
$ID,2$* A exit flag will cause a macro to send an ESC before running(to exit the macro screen and return to the cmd prompt). Actually, the default has an exit flag set so you might add a $FG,4$-X$FG$ to turn-off ESC.
* If an entry is in the cmd prompt window, the $FG,4$+X$FG$ will cause a movement to the bottom of the window.
$ID,-2$$TR,"+Q Quit"$
$ID,2$A quit flag is similar to a $FG,4$+X$FG$ except a CTRL-Q instead of an ESC to exit.
$ID,-2$$TR,"+PW Password"$
$ID,2$A password flag on a data entry ($FG,5$DA$FG$) will cause text to be shown as '*'s.
$ID,-2$$TR,"+Z Zero"$
$ID,2$A zero flag on a hex edit($FG,5$HX$FG$) entry will cause the offset from zero. A $FG,4$-X$FG$ will show the actual mem address. By default, $FG,5$HX$FG$ has the zero flag set.
$ID,-2$$TR,"+AL Alias"$
$ID,2$An alias flag on a tree entry ($FG,4$+TR$FG$) will cause the text of the current entry the cursor is on to be copied to this entry. This creates something similar to a drop-down window, but it doesn't work well yet.
$ID,-2$$TR,"+RD Refresh Data"$
$ID,2$The Refresh Data flag on a $FG,5$DA$FG$ or a $FG,5$CB$FG$ makes the value updated continuously.
$ID,-2$$ID,-2$$FE,5$
$FG,5$EXAMPLES:
$FG$Press CTRL-T to see how the following were done.
$UL,1$Underlined$UL,0$ $IV,1$Inverted$IV,0$ $BK,1$Blinking$BK,0$ $SY,-3$super$SY,0$ $SY,0$$SY,3$sub$SY,0$
$TX+SCX,"This is a big long scrolling message.",10$
$FG,5$Cursor Movements:$FG$
$CM+LX,3,3$Cursor moved 3 rows down and to 3rd column from left.
$CM+RX,-40,3$Note mandatory comma after flags
The following may be changed to modes instead of attributes with flags.
$TX+CX,"This is centered"$
$TX+RX,"This is right justified"$
+19
View File
@@ -0,0 +1,19 @@
$WW,1$* $LK,"grbase","MN:grbase"$ is a bitmap for persistent data on the screen, not needing to be redrawn. You create an alias for this by using $LK,"GrNew","MN:GrNew"$() and work with that. This image is XORed on top of everything, so the colors you work with, you usually XOR with GR_WHITE to compensate. (White is usually the text background color. XORing twice gets you to what you started with.) It's slightly simpler using this bitmap then $LK,"grbase2","MN:grbase2"$, but it's not as good because changes aren't syncronized to the screen update and window borders are not enforced. See $LK,"::/LT/DEMO/Graphics/DotNet.CPZ","FI:::/LT/DEMO/Graphics/DotNet.CPZ"$
* $LK,"grbase2","MN:grbase2"$ is a bitmap for the screen, redrawn each refresh. You create an alias with $LK,"GrNew","MN:GrNew"$() and work with that. You must change the "$FG,2$Fs->update_window$FG$" variable to point to your update function and must draw everything in the window over and over again. "$FG,2$DrawIt()$FG$" is the preferred name for your update function, so everyone is consistent. See $LK,"::/LT/DEMO/Graphics/Box.CPZ","FI:::/LT/DEMO/Graphics/Box.CPZ"$
* Use $LK,"GrNew","MN:GrNew"$() to create your own structure for accessing the screen and pass it either $LK,"grbase","MN:grbase"$ or $LK,"grbase2","MN:grbase2"$. (Free it with $LK,"GrDel","MN:GrDel"$() when finished). A $LK,"GrBitMap","MN:GrBitMap"$ returned by $LK,"GrNew","MN:GrNew"$() stores the pen width and current color. It also can hold info necessary to rotate the whole image in 3D and shift it around.
* Use $LK,"GrBitMapNew","MN:GrBitMapNew"$() to create a memory bitmap which can be used to work off-line and which can be $LK,"GrBlot","MN:GrBlot"$ed onto the screen. If you set $FG,2$brush$FG$ member of $FG,2$GrBitMap$FG$ to another $FG,2$GrBitMap$FG$, all the graphic routines will $LK,"GrBlot","MN:GrBlot"$() the brush instead of $LK,"GrPlot","MN:GrPlot"$(). See $LK,"::/LT/DEMO/Graphics/Blot.CPZ","FI:::/LT/DEMO/Graphics/Blot.CPZ"$.
* There are various flavors of line and point plotting routines. $LK,"GrLine","MN:GrLine"$() and $LK,"GrPlot","MN:GrPlot"$() are the simplest. The others allow 3 dimensional graphics.
* $LK,"GrTheta","MN:GrTheta"$() and $LK,"GrPhi","MN:GrPhi"$() create matrices for 3 dimensional rotations. You pass them an angle in radians. To make the matrices take effect, assign them to your graphic $LK,"GrBitMap","MN:GrBitMap"$'s "$FG,2$r$FG$" variable and set the $LK,"BMF_TRANSFORMATION","MN:BMF_TRANSFORMATION"$ flag. Transformations (rotations) can be combined using $LK,"GrMulMat","MN:GrMulMat"$(). See $LK,"::/LT/DEMO/Graphics/Box.CPZ","FI:::/LT/DEMO/Graphics/Box.CPZ"$.
* You can rotate single points using $LK,"GrRotate","MN:GrRotate"$().
* You can shift the image around by changing a $LK,"GrBitMap","MN:GrBitMap"$'s "$FG,2$x$FG$","$FG,2$y$FG$" and "$FG,2$z$FG$" variables.
* Use the resource editor, $FG,2$CTRL-R$FG$, to create a picture-like thing called a Graphic Element that can be plotted with $LK,"GrElemsPlot","MN:GrElemsPlot"$(). Use $FG,2$$$IB,"",1$$$FG$ in a source program to insert the address of picture #1. (After creating a picture with $FG,2$CTRL-R$FG$ in your source code, toggle to plain text with $FG,2$CTRL-T$FG$ and check it's number. Then, make an assignment to a pointer variable with $FG,2$$$IB,"",n$$$FG$ as the value. See $LK,"::/LT/DEMO/Graphics/Sprite1.CPZ","FI:::/LT/DEMO/Graphics/Sprite1.CPZ"$ and $LK,"::/LT/DEMO/Graphics/Sprite2.CPZ","FI:::/LT/DEMO/Graphics/Sprite2.CPZ"$.) The origin (zero point) for a graphic element is defined by the cursor location when you press $FG,2$CTRL-R$FG$. The "$FG,2$x$FG$", "$FG,2$y$FG$" and "$FG,2$z$FG$" values you pass to $LK,"GrElemsPlot","MN:GrElemsPlot"$() shift it around. You can edit a Graphic Element by clicking the cursor on it and pressing $FG,2$CTRL-R$FG$ again.
* There is a mechanism built-in for generating motion based on differential equations, which allows real-world physics. You create an $LK,"Ode","MN:Ode"$ struct with $LK,"OdeNew","MN:OdeNew"$(), passing it the number of variables in the state vector. For real-world physics, you usually have 2 state variables for each dimension (for each mass) because motion is governed by f=ma which is a 2nd order equation. The two states are position and velocity and to solve these you need to supply the derivative of position and velocity. The derivative of position is usually simply the current velocity and the derivative of velocity is the acceleration (the sum of forces on a mass divided by mass). To help provide meaningful names for values in the state vector, you can create an $LK,"Order2D3","MN:Order2D3"$ pointer and point it to a mass in the state vector. Six elements in the state vector are required for each mass. See $LK,"::/LT/DEMO/Graphics/StarTrek2.CPZ","FI:::/LT/DEMO/Graphics/StarTrek2.CPZ"$. Or, see $LK,"::/LT/DEMO/Graphics/StarTrek3.CPZ","FI:::/LT/DEMO/Graphics/StarTrek3.CPZ"$ where an angle instead of a Z dimension is used. The values in the state don't have to be positions and velocities.
+88
View File
@@ -0,0 +1,88 @@
$WW,1$$FG,5$$TX+CX,"OS PROGRAMMING GUIDELINES:"$$FG$
* Virtual mem is not used. The stack does not grow, so allocate enough when the task (process) is $LK,"Spawn","MN:Spawn"$ed and use the heap for most things. (The "heap" refers to $LK,"MAlloc","MN:MAlloc"$() and $LK,"Free","MN:Free"$().)
* I've tried to standardize names see $LK,"Naming convention","FF:::/LT/DOC/OSGlossary.GLZ,Naming convention"$
* There are two modes of compiling $LK,"Static Compiled Mode","FF:::/LT/DOC/OSGlossary.GLZ,Static Compiled Mode"$ and $LK,"Dynamic Compiled Mode","FF:::/LT/DOC/OSGlossary.GLZ,Dynamic Compiled"$. Actual compilation is done in both--nothing is "interpreted".
$FG,5$$TX+CX,"Departures from C/C++:"$$FG$
* Built-in types include $FG,2$I0,I1,I2,I4,I8$FG$ for signed ints and $FG,2$U0,U1,U2,U4,U8$FG$ for unsigned ints and $FG,2$double$FG$.
* The "$FG,2$`$FG$" operator raises a base to a power.
* Operator Precidence
1) $FG,2$`$FG$,$FG,2$>>$FG$,$FG,2$<<$FG$
2) $FG,2$*$FG$,$FG,2$/$FG$,$FG,2$%$FG$
3) $FG,2$&$FG$
4) $FG,2$|$FG$,$FG,2$^$FG$
5) $FG,2$+$FG$,$FG,2$-$FG$
6) $FG,2$==$FG$,$FG,2$!=$FG$,$FG,2$<$FG$,$FG,2$>$FG$,$FG,2$<=$FG$,$FG,2$>=$FG$
7) $FG,2$&&$FG$
8) $FG,2$||$FG$,$FG,2$^^$FG$
9) $FG,2$:$FG$,$FG,2$?$FG$
10) $FG,2$=$FG$,$FG,2$<<=$FG$,$FG,2$>>=$FG$,$FG,2$*=$FG$,$FG,2$/=$FG$,$FG,2$&=$FG$,$FG,2$|=$FG$,$FG,2$^=$FG$,$FG,2$+=$FG$,$FG,2$-=$FG$
* No conditional compilation, except with the $FG,2$exe{}$FG$ feature. With this statement blk in your source code, you can place programs that insert text into the stream of code being compiled. See $LK,"exe {}","FF:::/LT/OSMain/END.CPZ,exe {"$ for an example where the date/time and compile-time prompting for configuration data is placed into a program. The $LK,"ExePrintF","MN:ExePrintF"$() and $LK,"ExePutS","MN:ExePutS"$() place text into a source program stream following the conclusion of the $FG,2$exe{}$FG$ blk. I do hope to add conditional compilation, but it's not a priority.
* No "$FG,2$#define$FG$" functions exist (I'm not a fan)
* Pointer arithmetic is not based on size of objects (I'd have no objections to this changing)
* No type-checking
* Variable parameter cnts ($FG,2$...$FG$) are accessed with "$FG,2$argc$FG$" and "$FG,2$argv[]$FG$" which are predefined invisible local variable.
* "$FG,2$cout$FG$" works with commas but not "$FG,2$<<$FG$" and and has no "$FG,2$endl$FG$" or other codes. Use "$FG,2$coutln$FG$" to print a carriage return after other stuff. An alias for "$FG,2$cout$FG$" is "$FG,2$dbgo$FG$" or "$FG,2$dbgoln$FG$" and is useful for debugging--I often place debug output all over the place and do a $LK,"Grep","MN:Grep"$() to locate them all.
* Type casting is done with "$FG,2$><(classname)$FG$" and is postfix.
* When dealing with function addresses, preceed the name with "$FG,2$&$FG$". This allows functions to be called like Pascal procedure with no "()" if there are no parameters or there are just default parameters.
* "$FG,2$$$$FG$" is an escape character. Two dollar signs signify an ordinary $$. See $LK,"::/LT/DOC/Dollar.TXZ","FI:::/LT/DOC/Dollar.TXZ"$.
* There is not a "$FG,2$struct$FG$" keyword, just "$FG,2$class$FG$".
* "$FG,2$union$FG$" is more like a class, so you don't referrence it with a "$FG,2$union$FG$" label after you define it. Some common unions are declared in $LK,"ADAMK.HPZ","MN:U2"$ for 1,2,4 and 8 byte objects. If you place a type in front of a union declaration, that is the type when used by itself.
* You cannot declare instances of "$FG,2$class$FG$es" or "$FG,2$unions$FG$" in the same statement where they are defined.
* $FG,2$class$FG$ member vars have two keywords for associating data with member vars -- "$FG,2$fmtstr$FG$" and "$FG,2$fmtdata$FG$". All compiler structures are saved and you can access the compiler's info about classes and variables. In the future, I hope to have arbitrary named data on class definitions.
* "$FG,2$static$FG$" variables in functions are not allowed and I have no plans for doing them--just use a global variable.
* See $LK,"::/LT/DEMO/Exceptions.CPZ","FI:::/LT/DEMO/Exceptions.CPZ"$. "$FG,2$try{} catch{}$FG$ and $FG,2$throw$FG$" are different from C++. "$FG,2$throw$FG$" is a function with variable ("$FG,2$...$FG$") parameters. The values passed in "$FG,2$throw()$FG$" can be accessed from within a "$FG,2$catch{}$FG$" using the "$FG,2$Fs->except_argc$FG$" and "$FG,2$Fs->except_argv[]$FG$" variables. Within a "$FG,2$catch {}$FG$" blk, set the var "$FG,2$Fs->catch_except$FG$" to "$FG,2$TRUE$FG$" if you want to terminate the search for a handler. By convention, the first parameter of $FG,2$except_argv[]$FG$ specifies the exception type number. A list of assigned exception types can be found at $LK,"EXCEPT_LOCAL","MN:EXCEPT_LOCAL"$. For a handler that will catch all excepts, you can use $LK,"CatchAll","MN:CatchAll"$().
* A function is available similar to "$FG,2$sizeof$FG$" which provides the offset of a member of a class. It's called "$FG,2$offset()$FG$". You place the class name and member inside as in "$FG,2$offset(classname.membername)$FG$". It has nothing to do with 16-bit code. $FG,2$sizeof()$FG$ cannot be applied to variables, just classes. Also, both $FG,2$sizeof()$FG$ and $FG,2$offset()$FG$ only accept one level of member variables. That is you cannot do $FG,2$sizeof(classname.membername.submembername)$FG$.$FG$
* There is a function called $LK,"MSize","MN:MSize"$() which gives the size of an object allocated off the heap. For larger size allocations, the system rounds-up to a power of two, so $FG,2$MSize()$FG$ lets you know the real size.
* You can $LK,"Free","MN:Free"$() a $FG,2$NULL$FG$ pointer. Useful variants of $LK,"MAlloc","MN:MAlloc"$() can be found $LK,"Here","MN:MAllocZ"$. Each task has a heap and you can $FG,2$MAlloc$FG$ and $FG,2$Free$FG$ off of other task's heaps.
$FG,5$$TX+CX,"PrintF Family"$$FG$
$LK,"MSPrintF","MN:MSPrintF"$() is like $LK,"SPrintF","MN:SPrintF"$() but it returns a $LK,"MAlloc","MN:MAlloc"$ated string. It is vary handy because you don't have to worry about overflow.
$LK,"Auto","MN:Auto"$(I1 *src,...) and text to the current task's input buffer.
$LK,"AutoString","MN:AutoString"$(I1 *src,...) sends text of an $LK,"AutoFile","FF:::/LT/DOC/OSGlossary.GLZ,AutoFile"$ to the keyboard stream of the current TASK but can also do mouse commands.
$LK,"XTalk","MN:XTalk"$(TssStruct *tss,I1 *src,...) and text to another task's input buffer.
$LK,"XTalkString","MN:XTalkString"$(TssStruct *tss,I1 *src,...) sends text of an $LK,"AutoFile","FF:::/LT/DOC/OSGlossary.GLZ,AutoFile"$ to the keyboard stream of another TASK but can also do mouse commands.
$LK,"LtfPutS","MN:LtfPutS"$(Ltf *l,I1 *src) and $LK,"LtfPrintF","MN:LtfPrintF"$(Ltf *l,I1 *src,...) send text to a linked text file. You can buffer to a Ltf and save it, providing the functionality of $FG,2$fprintf$FG$. See $LK,"::/LT/DEMO/FPrintF.CPZ","FI:::/LT/DEMO/FPrintF.CPZ"$.
$LK,"Adam","MN:Adam"$(I1 *src,...) send text to the adam task to be compiled and run.
$LK,"AdamLog","MN:AdamLog"$(I1 *src,...) and $LK,"AdamErr","MN:AdamErr"$(I1 *src,...) send text to the adam task to be displayed.
$LK,"Lpt1PrintF","MN:Lpt1PrintF"$(I1 *src,...) send text to the printer port.
$LK,"ExePrintF","MN:ExePrintF"$(I1 *src,...) and $LK,"ExePutS","MN:ExePutS"$(I1 *src) send text to the stream of code being compiled and must reside in a $FG,2$exe{}$FG$ blk.
$LK,"CommPrintF","MN:CommPrintF"$(U4 port,I1 *src,...) sends text to the comm ports.
$BK,1$Note:$BK,0$ If no $FG,2$PutS$FG$ variant is available, you can use $FG,2$PrintF("%s",src)$FG$.
The $LK,"PrintF","MN:PrintF"$() family supports extended format codes.
* $FG,2$"%S"$FG$ will print a systext entry.
* $FG,2$"%F"$FG$ will print a text file.
* $FG,2$"t"$FG$ is a flag which will truncate to field width.
* $FG,2$"%P"$FG$ will display a PSECT expression which is good for pointers or addresses.
* $FG,2$"%T"$FG$ and $FG,2$"%D"$FG$ will display a date or time and the format is selected with a subcode, entered after a "$FG,2$h$FG$". Example: "$FG,2$%20h1D$FG$" uses date format code "1". See $LK,"MSPrintFDate","FF:::/LT/OSMain/SPRINTF.CPZ,MSPrintFDate"$() and $LK,"MSPrintFTime","FF:::/LT/OSMain/SPRINTF.CPZ,MSPrintFTime"$() for subcodes.
* $FG,2$"%z"$FG$ will display a sub entry of an enumerated list of text entries. It calls $LK+S,"PointAtListEntry","MN:PointAtListEntry"$().
* $FG,2$"%Z"$FG$ will display a SysText sub entry.
* $FG,2$"%Q"$FG$ will convert "\" to "\\" and quote to backslash quote. (For use in creating strings in strings.)
$FG,5$$TX+CX,"Hash symbol tables:"$$FG$
* See $LK,"::/LT/UTILS/HASHUTIL.CPZ","FI:::/LT/UTILS/HASHUTIL.CPZ"$ for examples of how the hash tables are set-up. Basically, symbols are placed into hash tables and child process hash tables are chained to parents. This provides scopes for variables and functions.
* "$FG,2$adam_tss->hash_table$FG$" holds the C/C++ symbols loaded in on start-up.
* "$FG,2$Fs->hash_table$FG$" holds user C+ symbols and if a symbol is not found, it checks parents. When a duplicate symbol is added to the table, it overshadows the previous symbol. When developing software, typically you include the file at the command prompt, make changes and reinclude it. Old symbols are overshadowed but they are still there. Periodically, kill the TASK and start fresh when mem is low. If you wish your applications to free themselves instead of staying in mem, spawn or $LK,"PopUp","MN:PopUp"$() a task to run the application and kill it when it's done.
* To display the contents of a hash table, use the $LK,"HashRep","MN:HashRep"$() routine or the varients.
$FG,5$$TX+CX,"Assembly Language Concerns:"$$FG$
* Segment registers except $FG,2$FS$FG$ are set to $FG,2$0x00000000$FG$ as a base.
* $FG,2$FS$FG$ must always point to the per-TASK's structure. See $LK,"C+","FF:::/LT/OSMain/ADAMK.HPZ,TssStruct:2"$$LK "C++ task struct" "FF:::/LT/OSMain/ADAMK.HPZ,TssStruct"$ and $LK,"Asm","FF:::/LT/OSMain/OSINC.ASZ,TSS_EIP"$$LK "ASM task struct" "FF:::/LT/OSMain/OSINC.ASZ,TSS_BACK_LINK"$.
* Don't change the segment registers unless interrupts are off.
* When interacting with compiled code, preserve $FG,2$EBP, ESI, EDI$FG$ because the compiler uses these for register vars. You are free to trash $FG,2$EAX, EBX, ECX, EDX$FG$.
+78
View File
@@ -0,0 +1,78 @@
$WW+H,1$Left-click on the word "$FG,2$MENU$FG$" in the window title bar to pull-up the menu. Underlined text is usually a link. Left click with the mouse or press SPACE when the cursor is on top of them to edit/view them. Right click or press $FG,2$ENTER$FG$ to $FG,2$#include$FG$ them, often causing them to execute.
$FG,9$ESC$FG$ Exits and saves
$FG,9$CTRL Q$FG$ Aborts
$FG,9$Window's Key$FG$ Views the Menu/Help/Macro area
Double mouse clicks send $FG,2$ESC$FG$ or $FG,2$CTRLQ$FG$.
Remember to terminate commands with a semicolon.
$TR,"USER HELP"$
$ID,2$
See $LK,"::/LT/DOC/OSGlossary.GLZ","FL:::/LT/DOC/OSGlossary.GLZ,1"$ for a glossary.
$TR,"DOLLAR SIGN COMMANDS"$
$ID,2$$LK,"Dollar Sign Commands","FI:::/LT/DOC/Dollar.TXZ"$ are rich-text commands. The editor, compiler, assembler and operating system are seamlessly equiped to handle LoseThos rich text. Commands like $LK,"Dir","MN:Dir"$() and $LK,"Grep","MN:Grep"$() can output links to the command line.
$ID,-2$$TR,"COMMAND PROMPT"$
$ID,2$The LoseThos command line interface is based on C/C++. Explore the ".CPZ" files or $MA+A-X+PU,"Click Here","HFunsRep;View;"$ to learn which commands are available. A command which takes no parameters may be executed by typing the name and a semicolon. Commands with parameters require placing the parameter in parentheses like a function call.
$MA,"Dir(\"*\");"$ will list files in the current directory.
$MA,"Dir;"$ uses default of "*".
$MA,"Cd(\"::/LT/APPS\");"$ will change directories
Directories are referenced with "/" not "\". The Boot drive is referred to with "$FG,2$::$FG$". Other drives are referred to by a letter and a colon. Your user account directory is referred to with "$FG,2$HOME$FG$".
If a file is not found in one directory, all it's parents are searched.
$FG,9$Edit("FILENAME.TXZ");$FG$ Invokes the editor. See $LK,"Editor cmds","::/LT/ADAM/EDIT.MUZ"$. Note that editor commands work practically everywhere--like at the command prompt or within help.
$ID,-2$$TR,"BURNING CD-ROMs/DVDs"$
$ID,2$0) Prepare a partition (drive) with the files you wish to burn.
1) Use $LK+S,"CreateCDFile","MN:CreateCDFile"$() to make an ISO image file of a partition.
2) Use $LK+S,"WriteCDImage","MN:WriteCDImage"$() to burn an ISO file onto a CD or DVD.
Note: You can create a $LK,"File Partition","FF:::/LT/DOC/OSGlossary.GLZ,File Partition"$ on an ordinary partition, copy files into it, create an image and burn it.
$ID,-2$
See $LK+S,"::/LT/DOC/Quirks.TXZ","FI:::/LT/DOC/Quirks.TXZ"$ for things to watch for.
$ID,-2$$TR,"ADMIN HELP"$
$ID,2$
$TR,"ADDING DRIVES"$
$ID,2$Use $LK,"AddDrives","MN:AddDrives"$() to enable disk drives.
See $LK+S,"File Partition","FF:::/LT/DOC/OSGlossary.GLZ,File Partition"$ for a definition.
$ID,-2$
See $LK,"::/LT/DOC/Install.TXZ","FI:::/LT/DOC/Install.TXZ"$ for details on installing to a hard drive.
See $LK-A+S,"::/LT/OSMain/ADAMK.CPZ"$ for the LoseThos equivalent of the AUTOEXEC.BAT.
$TR,"ACCOUNTS"$
$ID,2$
You can add and remove accounts by making or removing directories in the $FG,2$::/LT/ACCOUNTS$FG$ directory. You'll have to copy start-up files into them.
See $LK-A,"HOME/USER.CPZ"$ for the user start-up file.
See $LK-A,"HOME/USER.MUZ"$ for a personalizable menu/macro area which can be viewed at the command line with the windows key or by clicking "$FG,2$MENU$FG$" in the upper left border area of a window.
See $LK-A,"HOME/FAVOR.MUZ"$ for a handy "favorites" file which can be reached by pressing $FG,2$CTRL-SHIFT-F$FG$, pretty-much anywhere. Users can place links and todo lists or any text within this.
See $LK-A,"HOME/ADAM3.CPZ"$ for the user files that get loaded into the adam task. These are only loaded once.
See $LK-A,"HOME/SYSTEM.CPZ"$ for the start-up file used when a $LK,"System","MN:System"$() command is used.
See $LK-A,"HOME/SERVANT.CPZ"$ for the start-up file other commands which $LK,"Spawn","MN:Spawn"$() tasks.
See $LK-A,"HOME/FAULT.CPZ"$ for a start-up file called when a fault occurs. When debugging you might place data display commands here.
$ID,-2$
$ID,-2$$TR,"DEVELOPER HELP"$
$ID,2$
See $LK-A+S,"::/LT/DOC/GuideLines.TXZ"$ for some programming guidelines.
See $LK+S,"::/LT/DOC/Graphics.TXZ","FI:::/LT/DOC/Graphics.TXZ"$ for details on graphics programming.
$ID,-2$
See $BK,1$$LK+S,"::/LT/DOC/Mysteries.TXZ","FI:::/LT/DOC/Mysteries.TXZ"$$BK,0$ for mysteries explained.
See $BK,1$$LK+S,"::/LT/DOC/News.TXZ","FL:::/LT/DOC/News.TXZ,1"$$BK,0$ for the latest news.
Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff. Show more