diff --git a/0000BOOT/BOOT.BIC b/0000BOOT/BOOT.BIC deleted file mode 100644 index 067e17a..0000000 Binary files a/0000BOOT/BOOT.BIC and /dev/null differ diff --git a/0000BOOT/CDBOOT.BIZ b/0000BOOT/CDBOOT.BIZ deleted file mode 100644 index 524b453..0000000 Binary files a/0000BOOT/CDBOOT.BIZ and /dev/null differ diff --git a/0000Boot/Boot.BIC b/0000Boot/Boot.BIC new file mode 100644 index 0000000..e86e292 Binary files /dev/null and b/0000Boot/Boot.BIC differ diff --git a/0000Boot/BootLoader.BIC b/0000Boot/BootLoader.BIC new file mode 100644 index 0000000..82eeb50 Binary files /dev/null and b/0000Boot/BootLoader.BIC differ diff --git a/LT/UTILS/BOOTRAM.BIZ b/0000Boot/CDBoot.BIZ similarity index 64% rename from LT/UTILS/BOOTRAM.BIZ rename to 0000Boot/CDBoot.BIZ index eef0791..176e3c3 100644 Binary files a/LT/UTILS/BOOTRAM.BIZ and b/0000Boot/CDBoot.BIZ differ diff --git a/LT/ACCOUNTS/FAULT.CPZ b/LT/ACCOUNTS/FAULT.CPZ deleted file mode 100644 index 770a194..0000000 Binary files a/LT/ACCOUNTS/FAULT.CPZ and /dev/null differ diff --git a/LT/ACCOUNTS/FAVOR.MUZ b/LT/ACCOUNTS/FAVOR.MUZ deleted file mode 100644 index 7da417a..0000000 Binary files a/LT/ACCOUNTS/FAVOR.MUZ and /dev/null differ diff --git a/LT/ACCOUNTS/INSTALL/USER.CPZ b/LT/ACCOUNTS/INSTALL/USER.CPZ deleted file mode 100644 index 67a1fa7..0000000 --- a/LT/ACCOUNTS/INSTALL/USER.CPZ +++ /dev/null @@ -1,84 +0,0 @@ -//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); - } - -} \ No newline at end of file diff --git a/LT/ACCOUNTS/SERVANT.CPZ b/LT/ACCOUNTS/SERVANT.CPZ deleted file mode 100644 index 8f733e8..0000000 Binary files a/LT/ACCOUNTS/SERVANT.CPZ and /dev/null differ diff --git a/LT/ACCOUNTS/TOUR/TOUR.AUZ b/LT/ACCOUNTS/TOUR/TOUR.AUZ deleted file mode 100644 index 4347517..0000000 --- a/LT/ACCOUNTS/TOUR/TOUR.AUZ +++ /dev/null @@ -1,114 +0,0 @@ -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); diff --git a/LT/ACCOUNTS/TOUR/TOUR1.AUZ b/LT/ACCOUNTS/TOUR/TOUR1.AUZ deleted file mode 100644 index 181960f..0000000 --- a/LT/ACCOUNTS/TOUR/TOUR1.AUZ +++ /dev/null @@ -1,101 +0,0 @@ -//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"); diff --git a/LT/ACCOUNTS/TOUR/TOUR2.AUZ b/LT/ACCOUNTS/TOUR/TOUR2.AUZ deleted file mode 100644 index 1410a39..0000000 --- a/LT/ACCOUNTS/TOUR/TOUR2.AUZ +++ /dev/null @@ -1,76 +0,0 @@ -//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); - diff --git a/LT/ACCOUNTS/TOUR/TOUR3.AUZ b/LT/ACCOUNTS/TOUR/TOUR3.AUZ deleted file mode 100644 index 7e383a9..0000000 --- a/LT/ACCOUNTS/TOUR/TOUR3.AUZ +++ /dev/null @@ -1,95 +0,0 @@ -//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"); diff --git a/LT/ACCOUNTS/TOUR/TOUR4.AUZ b/LT/ACCOUNTS/TOUR/TOUR4.AUZ deleted file mode 100644 index 3f09b1c..0000000 --- a/LT/ACCOUNTS/TOUR/TOUR4.AUZ +++ /dev/null @@ -1,58 +0,0 @@ -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); diff --git a/LT/ACCOUNTS/TOUR/USER.CPZ b/LT/ACCOUNTS/TOUR/USER.CPZ deleted file mode 100644 index abdda26..0000000 --- a/LT/ACCOUNTS/TOUR/USER.CPZ +++ /dev/null @@ -1,10 +0,0 @@ -//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"); diff --git a/LT/ACCOUNTS/UPGRADE/USER.CPZ b/LT/ACCOUNTS/UPGRADE/USER.CPZ deleted file mode 100644 index 9addeff..0000000 --- a/LT/ACCOUNTS/UPGRADE/USER.CPZ +++ /dev/null @@ -1,71 +0,0 @@ -//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); - } -} \ No newline at end of file diff --git a/LT/ACCOUNTS/USER.MUZ b/LT/ACCOUNTS/USER.MUZ deleted file mode 100644 index a999967..0000000 --- a/LT/ACCOUNTS/USER.MUZ +++ /dev/null @@ -1,27 +0,0 @@ -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;"$ \ No newline at end of file diff --git a/LT/ADAM/ADAM2.CPZ b/LT/ADAM/ADAM2.CPZ deleted file mode 100644 index 9f4abdb..0000000 --- a/LT/ADAM/ADAM2.CPZ +++ /dev/null @@ -1,67 +0,0 @@ -#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; diff --git a/LT/ADAM/ADAMASM.ASZ b/LT/ADAM/ADAMASM.ASZ deleted file mode 100644 index 295913b..0000000 Binary files a/LT/ADAM/ADAMASM.ASZ and /dev/null differ diff --git a/LT/ADAM/ADAMASM.BIZ b/LT/ADAM/ADAMASM.BIZ deleted file mode 100644 index dd7d74a..0000000 Binary files a/LT/ADAM/ADAMASM.BIZ and /dev/null differ diff --git a/LT/ADAM/ADAMASM.HPZ b/LT/ADAM/ADAMASM.HPZ deleted file mode 100644 index ddb3df1..0000000 --- a/LT/ADAM/ADAMASM.HPZ +++ /dev/null @@ -1,10 +0,0 @@ -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) diff --git a/LT/ADAM/ADAMASM.MPZ b/LT/ADAM/ADAMASM.MPZ deleted file mode 100644 index b385402..0000000 Binary files a/LT/ADAM/ADAMASM.MPZ and /dev/null differ diff --git a/LT/ADAM/AdamExt.CPZ b/LT/ADAM/AdamExt.CPZ deleted file mode 100644 index a6788f6..0000000 --- a/LT/ADAM/AdamExt.CPZ +++ /dev/null @@ -1,32 +0,0 @@ -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); - diff --git a/LT/ADAM/EDIT.CPZ b/LT/ADAM/EDIT.CPZ deleted file mode 100644 index c45d0e5..0000000 --- a/LT/ADAM/EDIT.CPZ +++ /dev/null @@ -1,3346 +0,0 @@ -#define EDIT_MENU_NAME "::/LT/ADAM/EDIT.MUZ" -public void LtfUpdateCurLtfWindow() -{ - LTPartition *p; - U1 attr=0; - Ltf *main=Fs->cur_ltf,*aux=Fs->aux_ltf; - ClearWindowText; - LtfUpdateWindowJoin(main,TRUE,TRUE,FALSE,FALSE); - if (main->flags & LTFF_ATTR_BY_PARTITION) { - p=Fs->cur_partition; - attr=p->text_attr; - } - if (main->flags & LTFF_ATTR_BY_FILENAME) { - try { - p=DriveToPartition(main->filename.name[0]); - } catch { - p=NULL; - Fs->catch_except=TRUE; - } - if (p) - attr=p->text_attr; - } - if ((attr & 0xF)!=(attr>>4)) - Fs->border_attribute=attr; - if (aux) { - if ((attr & 0xF)!=(attr>>4)) - aux->text_attribute=attr; - LtfUpdateWindowJoin(aux,TRUE,FALSE,FALSE,FALSE); - } -} - -public LtfEntry *LtfFindAnchor(Ltf *l,I1 *pattern) -{ - LtfEntry *ll=l->dummy.next; - while (ll!=l) { - if (ll->btype==LTFT_ANCHOR) { - if (!StrCmp(pattern,ll->aux_string)) { - l->cur_entry=ll; - l->cur_data_col=ll->min_col; - return ll; - } - } - ll=ll->next; - } - return NULL; -} - -void EditCursorLeft(Ltf *l,U8 sc) -{ - I1 *dst; - BoolU4 old_preempt=Preempt(OFF); - LtfEntry *cl=l->cur_entry,*original_cl=cl,*nl; - I8 cc=l->cur_data_col,y=cl->y; - if (sc & SCF_CTRL) { - while (cl->last!=l && (cl->last->y==y || - cl->last->flags & LTFLF_SKIP)) - cl=cl->last; //TODO: select? recurse? - cc=cl->min_col; - } else { - if (cc>cl->min_col) { - if (cl->btype==LTFT_TEXT && ccmax_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - dst=cl->display+cc; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - *dst=0; - cl->max_col=cc; - InsQue(nl,cl); - } - cc--; - if (cl->btype==LTFT_TEXT && cc>cl->min_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - dst=cl->display+cc; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - *dst=0; - cl->max_col=cc; - InsQue(nl,cl); - cl=nl; - cc=cl->min_col; - } - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } else { - cc=cl->min_col; - while (cl->last!=l && - (cl->last->btype==LTFT_SOFT_CR || - cl->last->flags & LTFLF_SKIP)) { - cl=cl->last; - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } - if (cl->last!=l) { - cl=cl->last; - if (cl->max_col>cl->min_col) { - cc=cl->max_col-1; - if (cl->btype==LTFT_TEXT && cc>cl->min_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - dst=cl->display+cc; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - *dst=0; - cl->max_col=cc; - InsQue(nl,cl); - cl=nl; - cc=cl->min_col; - } - } else - cc=cl->max_col; - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } - } - } - l->cur_data_col=cc; - l->cur_entry=cl; - if (cl!=original_cl) - LtfFormBackward(l); - l->recalc_start=l->cur_entry->last; - Preempt(old_preempt); -} - -void EditCursorRight(Ltf *l,U8 sc) -{ - BoolU4 old_preempt=Preempt(OFF); - I1 *dst; - LtfEntry *cl=l->cur_entry,*original_cl=cl,*nl; - I8 cc=l->cur_data_col,y=cl->y,old_flags,old_color; - l->recalc_start=cl->last; - if (sc & SCF_CTRL) { - while (cl!=l && ((cl->next->y==y && - cl->next->btype!=LTFT_SOFT_CR) || - cl->flags & LTFLF_SKIP)) - cl=cl->next; - if (cl->max_col>cl->min_col) - cc=cl->max_col-1; - else - cc=cl->min_col; - } else { - if (ccmax_col) { - if (cl->btype==LTFT_TEXT && cc>cl->min_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - dst=cl->display+cc; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - *dst=0; - cl->max_col=cc; - InsQue(nl,cl); - cl=nl; - cc=cl->min_col; - } - cc++; - old_flags=cl->flags; - old_color=cl->type; - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - if (cl->btype==LTFT_TEXT && ccmax_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | old_color & -0x100; - nl->flags=old_flags; - dst=cl->display+cc; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - cl->max_col=cc; - *dst=0; - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - InsQue(nl,cl); - cl=nl; - cc=cl->min_col; - } else if (cc>=cl->max_col) { - cl=cl->next; - cc=cl->min_col; - } - } else { - if (cl!=l) { - if (cc<=cl->min_col) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } - cl=cl->next; - while (cl!=l && cl->flags & LTFLF_SKIP) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - cl=cl->next; - } - cc=cl->min_col; - if (cl->btype==LTFT_SOFT_CR) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - cl=cl->next; - cc=cl->min_col; - } - } - } - } - l->cur_data_col=cc; - l->cur_entry=cl; - if (cl!=original_cl) - LtfFormForward(l); - Preempt(old_preempt); -} - -void EditLineUp(Ltf *l,U8 sc) -{ - BoolU4 old_preempt=Preempt(OFF); - I1 *dst; - I8 y,x; - LtfEntry *cl=l->cur_entry,*nl; - if (cl->btype==LTFT_HEX_EDIT) { - l->cur_data_col=l->cur_data_col-cl->display*3; - if (l->cur_data_col>=0) - return; - else { - y=cl->y; - l->cur_data_col=0; - } - } - x=l->x; y=l->y; - if (cl->btype==LTFT_TEXT) { - if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - dst=cl->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->y=cl->y; - nl->x=cl->x+l->cur_data_col<<2; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - *dst=0; - cl->max_col=l->cur_data_col; - InsQue(nl,cl); - } else - if (l->cur_data_col==cl->min_col && cl->last!=l) - cl=cl->last; - } else - if (cl->last!=l) - cl=cl->last; - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - l->cur_entry=cl; - LtfFormBackward(l); - cl=l->cur_entry; - while (cl->last!=l && (cl->y>=y || cl->flags & LTFLF_SKIP)) { - cl=cl->last; - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } - y=cl->y; - l->y=y; - while (cl!=l && (cl->y>=y && cl->x>=x || cl->flags & LTFLF_SKIP)) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - cl=cl->last; - } - - if (cl==l || cl->ynext; - else { - if (cl->btype!=LTFT_TEXT) { - if (sc & SCF_SHIFT) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } else { - if (cl->next->x==x) - cl=cl->next; - } - } - if (Bt(ltf_display_types,cl->btype)) { - l->cur_data_col=(x-cl->x)>>2; - if (cl->btype==LTFT_TEXT) { - if (l->cur_data_col>cl->max_col) - l->cur_data_col=cl->max_col; - } else { - if (l->cur_data_col>=cl->max_col) - l->cur_data_col=cl->max_col-1; - } - if (l->cur_data_colmin_col) - l->cur_data_col=cl->min_col; - } else - l->cur_data_col=cl->min_col; - if (cl->btype==LTFT_TEXT && cl->xcur_data_colmax_col-1) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - if ((sc & SCF_SHIFT)) - nl->type=cl->type | LTFLT_SELECTED; - else - nl->type=cl->type & ~LTFLT_SELECTED; - dst=cl->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - nl->y=cl->y; - nl->x=cl->x+l->cur_data_col<<2; - *dst=0; - cl->max_col=l->cur_data_col; - InsQue(nl,cl); - cl=nl; - l->cur_data_col=cl->min_col; - } - } - l->cur_entry=cl; - LtfFormBackward(l); - l->recalc_start=l->cur_entry->last; - Preempt(old_preempt); -} - -void EditLineDown(Ltf *l,U8 sc) -{ - BoolU4 old_preempt=Preempt(OFF); - I1 *dst; - I8 y,x,old_flags=0,old_color; - LtfEntry *cl=l->cur_entry,*nl; - if (cl->btype==LTFT_HEX_EDIT) { - l->cur_data_col=l->cur_data_col+cl->display*3; - if (l->cur_data_col/3>=cl->len) { - if (cl->next!=l) - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - } - return; - } - if (cl==l) - l->recalc_start=cl; - else - l->recalc_start=cl->last; - x=l->x; y=l->y; - if (cl->btype==LTFT_TEXT) { - if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=cl->type; - nl->flags=cl->flags; - if ((sc & SCF_SHIFT)) - nl->type=cl->type | LTFLT_SELECTED; - else - nl->type=cl->type & ~LTFLT_SELECTED; - dst=cl->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - nl->y=cl->y; - nl->x=cl->x+l->cur_data_col<<2; - *dst=0; - cl->max_col=l->cur_data_col; - InsQue(nl,cl); - cl=nl; - l->cur_data_col=cl->min_col; - } - } - while (cl!=l && (cl->y<=y || cl->flags & LTFLF_SKIP)) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - cl=cl->next; - } - y=cl->y; - l->y=y; - while (cl!=l && (cl->y<=y && cl->x<=x || cl->flags & LTFLF_SKIP)) { - old_flags=cl->flags; - old_color=cl->type; - if (cl->xflags & LTFLF_SKIP || - cl->x==x && !cl->max_col && - Bt(ltf_nondisplay_invisible_types,cl->btype)) { - if ((sc & SCF_SHIFT)) - cl->type|=LTFLT_SELECTED; - else - cl->type&=~LTFLT_SELECTED; - } - cl=cl->next; - } - - if (cl->last!=l && (cl->x>x || cl->y>y)) { - cl=cl->last; - l->cur_entry=cl; - LtfFormBackward(l); - cl=l->cur_entry; - } - if (Bt(ltf_display_types,cl->btype)) { - l->cur_data_col=(x-cl->x)>>2; - if (cl->btype==LTFT_TEXT) { - if (l->cur_data_col>cl->max_col) - l->cur_data_col=cl->max_col; - } else { - if (l->cur_data_col>=cl->max_col) - l->cur_data_col=cl->max_col-1; - } - if (l->cur_data_colmin_col) - l->cur_data_col=cl->min_col; - } else - l->cur_data_col=cl->min_col; - if (cl->btype==LTFT_TEXT) { - if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | old_color & -0x100; - nl->flags=old_flags; - dst=cl->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - *dst=0; - cl->max_col=l->cur_data_col; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - nl->x=cl->x+l->cur_data_col<<2; - InsQue(nl,cl); - cl=nl; - l->cur_data_col=cl->min_col; - } - } - l->cur_entry=cl; - LtfFormForward(l); - Preempt(old_preempt); -} - -void EditDelChar(Ltf *l) -{ - BoolU4 old_preempt=Preempt(OFF); - LtfEntry *cl=l->cur_entry; - - if (cl==l) { - Preempt(old_preempt); - return; - } else - l->recalc_start=cl->last; - if (cl->max_col!=0 && (cl->btype==LTFT_TEXT || cl->btype==LTFT_DATA)) { - if (cl->btype==LTFT_DATA) { - if (cl->flags & LTFLF_HAS_TERMINATOR && l->cur_data_col==cl->max_col-1) { - Preempt(old_preempt); - return; - } - } - if (l->cur_data_colmax_col) - StrCpy(cl->display+l->cur_data_col,cl->display+l->cur_data_col+1); - if (l->cur_data_col>=cl->max_col-1) { - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - } - LtfRemoveSoftCRs(l,l->cur_entry); - Preempt(old_preempt); - return; - } - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - RemQue(cl); - LtfDelEntry(cl,l->mem_tss); - LtfRemoveSoftCRs(l,l->cur_entry); - Preempt(old_preempt); -} - -void CheckDollarBufSize(Ltf *l) -{ - U1 *b; - if (l->dollar_buf_ptr>=l->dollar_buf_size-2) { - l->dollar_buf_size*=2; - b=MAlloc(l->dollar_buf_size,l->mem_tss); - MemCpy(b,l->dollar_buf,l->dollar_buf_ptr); - Free(l->dollar_buf,l->mem_tss); - l->dollar_buf=b; - } -} - - -public I8 LtfRunLine(Ltf *l,LtfEntry *cl,BoolU4 exited,BoolU4 old_preempt) -{ //Call with preempt off - I8 result=-1; - I1 ch=l->cmd_I1,*st; - I8 cb(Ltf *l,U1 *user,LtfEntry *ll); - - if (!exited) { - if (cl->flags & LTFLF_ESC) { - Msg(MSG_KEY_DOWN,CH_ESC,0,1<flags & LTFLF_QUIT) { - Msg(MSG_KEY_DOWN,CH_CTRLQ,0,1<btype==LTFT_LINK) { - if (ch==CH_SPACE) - LeftClickLink(l,cl,old_preempt); - else if (ch==CH_CR) - RightClickLink(l,cl,old_preempt); - return 0; - } - if (ch==CH_SPACE && cl->flags & LTFLF_TREE || cl->btype==LTFT_HIDE_START) - cl->flags^=LTFLF_COLLAPSED; - - if ((cl->btype>=LTFT_BUTTON && cl->btype<=LTFT_MENU_VALUE) || cl->btype==LTFT_PICTURE) { - if (cl->btype==LTFT_CHECK_BOX) - cl->flags^=LTFLF_CHECKED; - if (ch==CH_SPACE) { - if (cl->flags & LTFLF_LEFT_EXP) { - result=cl->left_exp; - Msg(MSG_CMD,result,0,1<flags & LTFLF_LEFT_CB) { - cb=cl->left_cb; - Preempt(old_preempt); - result=cb(l,l->user_data,cl); - Preempt(OFF); - Msg(MSG_CMD,result,0,1<flags & LTFLF_LEFT_MACRO) { - if (cl->flags & LTFLF_POPUP) { - st=NewString(cl->left_macro); - Preempt(old_preempt); - PopUp(st); - Preempt(OFF); - Free(st); - } else { - if (cl->flags & LTFLF_LEFT_AUTO) - AutoString("%s",cl->left_macro); - else - Auto(cl->left_macro); - } - } - } else if (ch==CH_CR) { - if (cl->flags & LTFLF_RIGHT_EXP) { - result=cl->right_exp; - Msg(MSG_CMD,result,0,1<flags & LTFLF_RIGHT_CB) { - cb=cl->right_cb; - Preempt(old_preempt); - result=cb(l,l->user_data,cl); - Preempt(OFF); - Msg(MSG_CMD,result,0,1<flags & LTFLF_RIGHT_MACRO) { - if (cl->flags & LTFLF_POPUP) { - st=NewString(cl->right_macro); - Preempt(old_preempt); - PopUp(st); - Preempt(OFF); - Free(st); - } else { - if (cl->flags & LTFLF_RIGHT_AUTO) - AutoString("%s",cl->right_macro); - else - Auto(cl->right_macro); - } - } - } - } - l->cmd_I1=CH_SPACE; - return result; -} - -void EditInsertChar(I8 ch,U8 sc,Ltf *l,BoolU4 old_preempt) -{ - BoolU4 old_preempt2=Preempt(OFF); - I1 *b,*src,*dst; - LtfEntry *cl=l->cur_entry,*nl; - I8 i,j,m,x=cl->x,y=cl->y; - - l->recalc_start=cl->last; - - if (l->flags & LTFF_IN_DOLLAR) { - if (!Bt(printable_chars_bitmap,ch)) - goto done; - CheckDollarBufSize(l); - l->dollar_buf[l->dollar_buf_ptr++]=ch; - if (ch!='$$') { - goto done; - } else { - l->dollar_buf[l->dollar_buf_ptr]=0; - LtfPutS(l,l->dollar_buf); - l->flags&=~LTFF_IN_DOLLAR; - l->dollar_buf_ptr=0; - goto done; - } - } else { - if (ch=='$$') { - if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) { - l->flags|=LTFF_IN_DOLLAR; - l->dollar_buf_ptr=0; - l->dollar_buf[l->dollar_buf_ptr++]=ch; - goto done; - } - } - } - - if (ch==CH_SPACE || ch==CH_CR) { - if (!(sc & SCF_CTRL) && !(sc & SCF_SHIFT)) { - if (cl->btype>=LTFT_BUTTON && cl->btype<=LTFT_MENU_VALUE || - cl->btype==LTFT_LINK || cl->flags & LTFLF_TREE || - cl->btype==LTFT_HIDE_START) { - l->cmd_I1=ch; - LtfRunLine(l,cl,FALSE,old_preempt); - goto done; - } - } - } - if (cl->btype==LTFT_HEX_EDIT) { - if (cl->flags & LTFLF_DATA_IS_PTR) - b=cl->data; - else - b=&cl->data; - i=l->cur_data_col; - j=i%(cl->display*3); - m=i/(cl->display*3)*cl->display; - if (j>=cl->display<<1) - b[j-cl->display<<1+m]=ch; - else { - ch=ToUpper(ch)-'0'; - if (ch>9) ch=ch+'0'-'A'+10; - if (ch>15) goto done; - m=j>>1+m; - if (j & 1) - b[m]=b[m] & 0xF0| ch; - else - b[m]=b[m] & 0xF | ch<<4; - } - l->cur_data_col++; - goto done; - } - if (cl->btype==LTFT_DATA && cl->flags & LTFLF_REFRESH_DATA) - goto done; - if (l->flags & LTFF_OVERSTRIKE) { - if (ch==13) { - while (l->cur_entry->next!=l && l->cur_entry->y==y) - l->cur_entry=l->cur_entry->next; - l->cur_data_col=l->cur_entry->min_col; - } else { - if (Bt(displayable_chars_bitmap,ch)) { - if (cl->btype==LTFT_TEXT) { - if (cl->display[l->cur_data_col]) { - cl->display[l->cur_data_col++]=ch; - goto done; - } - } else if (cl->btype==LTFT_DATA) { - if (cl->flags & LTFLF_HAS_TERMINATOR) { - if (cl->display[l->cur_data_col] && - l->cur_data_colmin_col+cl->len) { - cl->display[l->cur_data_col++]=ch; - if ( !(cl->display[l->cur_data_col])) { - cl->display[l->cur_data_col]='_'; - cl->display[l->cur_data_col+1]=0; - } - } - } else { - if (cl->display[l->cur_data_col]) - cl->display[l->cur_data_col++]=ch; - } - goto done; - } - b=MAlloc(2,l->mem_tss); - b[0]=ch; - b[1]=0; - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | l->text_attribute << 8; - nl->display=b; - nl->max_col=1; - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - InsQue(nl,cl->last); - } - } - goto done; - } - if (ch==CH_CR || ch==CH_TAB) { - nl=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - if (ch==CH_CR) { - if (sc & SCF_CTRL && !(sc & SCF_SHIFT)) - nl->type=LTFT_PAGE_BREAK | l->text_attribute << 8; - else - nl->type=LTFT_CR | l->text_attribute << 8; - } else - nl->type=LTFT_TAB | l->text_attribute << 8; - LtfInsert(l,nl); - } else { - if (ch>=CH_SHIFT_SPACE && ch<=0x7E) { - if (cl->btype==LTFT_DATA) { - i=cl->len+cl->min_col; - if (cl->flags & LTFLF_HAS_TERMINATOR) - i++; - if (i>cl->max_col) { - b=cl->display; - cl->max_col++; - for (i=cl->max_col;i>l->cur_data_col;i--) - b[i]=b[i-1]; - b[l->cur_data_col++]=ch; - } - } else if (cl->btype==LTFT_TEXT) { - b=MAlloc(cl->max_col+2,l->mem_tss); - dst=b; - src=cl->display; - i=l->cur_data_col; - while (i-->0) - *dst++=*src++; - *dst++=ch; - while (*dst++=*src++); - Free(cl->display,l->mem_tss); - cl->display=b; - cl->max_col++; - l->cur_data_col++; - } else { - b=MAlloc(2,l->mem_tss); - b[0]=ch; - b[1]=0; - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | l->text_attribute << 8; - nl->display=b; - nl->max_col=1; - nl->x=cl->x+4; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - InsQue(nl,cl->last); - } - } - } -done: - LtfRemoveSoftCRs(l,l->cur_entry); - Preempt(old_preempt2); -} - -void EditDelLine(Ltf *l) -{ - LtfEntry *cl=l->cur_entry,*cl2; - I8 y; - y=l->y; - while (cl!=l && cl->y==y) - cl=cl->next; - l->cur_entry=cl; - l->cur_data_col=cl->min_col; - cl=cl->last; - while (cl!=l && cl->y==y) { - cl2=cl->last; - RemQue(cl); - LtfDelEntry(cl,l->mem_tss); - cl=cl2; - } - if (cl==l) - l->recalc_start=cl; - else - l->recalc_start=cl->last; -} - -public void LtfLoad(Ltf *l,I1 *src2,U8 size) -{ - I8 i; - I1 *src; - LtfBinEntry *tempb; - if (src2) { - LtfPutS(l,src2); - src=src2+StrLen(src2)+1; - i=size-(offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); - while (src<=src2+i) { - tempb=MAllocZ(sizeof(LtfBinEntry)); - MemCpy(&tempb->start,src,offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); - src+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start); - tempb->data=MAlloc(tempb->size); - if (tempb->size) { - MemCpy(tempb->data,src,tempb->size); - src+=tempb->size; - } - InsQue(tempb,l->bin_root.last); - if (tempb->num>=l->cur_bin_num) - l->cur_bin_num=tempb->num+1; - } - } - if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) - LtfValidateBins(l); - l->recalc_start=l; - LtfRecalc(l); -} - -public Ltf *LtfRead(I1 *name,U8 flags=0) -{ - Ltf *l=LtfNew; - I1 *src,*name2; - U8 size=0; - l->flags|=flags; - name2=AbsoluteFileName(name); - StrCpy(l->filename.name,name2); - src=ReadFile(name2,&size,&l->file_attr); - Free(name2); - - if (src) { - LtfLoad(l,src,size); - Free(src); - } - return l; -} - -public I1 *LtfSave(Ltf *l,U8 *size=NULL) -{ - LtfEntry *cl; - LtfBinEntry *b; - I1 *st; - U8 cnt=2; //cursor + terminator - I1 *result,*dst,*src,ch; - I8 i; - if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) - LtfValidateBins(l); - l->recalc_start=l; - LtfRecalc(l); - for (cl=l->dummy.next;cl!=l;cl=cl->next) { - if (!Bt(ltf_data_types,cl->btype)) { - if (cl->btype==LTFT_TEXT && - !(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | - LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) { - cnt+=StrLen(cl->display); - if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) - cnt+=Occurrences(cl->display,'$$'); - } else if (cl->btype==LTFT_TAB || cl->btype==LTFT_PAGE_BREAK) - cnt++; - else if (cl->btype==LTFT_CR) - cnt+=2; - else if (cl->btype!=LTFT_SOFT_CR && - cl->btype!=LTFT_CURSOR && - cl->btype!=LTFT_BPT) { - st=cl->plain_text; - cl->plain_text=LtfToPlainText(cl); - Free(st); - cnt+=StrLen(cl->plain_text)+2; - } - } - } - for (b=l->bin_root.next;b!=&l->bin_root;b=b->next) - cnt+=offset(LtfBinEntry.data)- - offset(LtfBinEntry.start)+b->size; - result=MAlloc(cnt); - dst=result; - for (cl=l->dummy.next;cl!=l;cl=cl->next) { - if (!Bt(ltf_data_types,cl->btype)) { - if (cl->btype==LTFT_TEXT && - !(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | - LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) { - src=cl->display; - i=0; - while (ch=*src++) { - if (cl==l->cur_entry && i++==l->cur_data_col) - *dst++=CH_CURSOR; - *dst++=ch; - if (ch=='$$') { - if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) - *dst++=ch; - } - } - if (cl==l->cur_entry && i++==l->cur_data_col) - *dst++=CH_CURSOR; - } else { - if (cl==l->cur_entry) - *dst++=CH_CURSOR; - if (cl->btype==LTFT_TAB) - *dst++=CH_TAB; - else if (cl->btype==LTFT_PAGE_BREAK) - *dst++=CH_FORM_FEED; - else if (cl->btype==LTFT_CR) { - *dst++=CH_CR; - *dst++=CH_LINE_FEED; - } else if (cl->btype!=LTFT_SOFT_CR && - cl->btype!=LTFT_CURSOR && - cl->btype!=LTFT_BPT) { - *dst++='$$'; - StrCpy(dst,cl->plain_text); - dst+=StrLen(cl->plain_text); - *dst++='$$'; - } - } - } - } - *dst++=0; - b=l->bin_root.next; - if (b!=&l->bin_root) { - while (b!=&l->bin_root) { - MemCpy(dst,&b->type,offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); - dst+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start); - MemCpy(dst,b->data,b->size); - dst+=b->size; - b=b->next; - } - } else - cnt--; - if (size) *size=cnt; - return result; -} - -I1 *EditOverStrikeCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - I1 *st=MAlloc(2,mem_tss); - st[0]=(user_data->flags & LTFF_OVERSTRIKE) ? 'O':130; - st[1]=0; - return st; -} - -I1 *EditDollarCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - I1 *st=MAlloc(2,mem_tss); - st[0]=(user_data->flags & LTFF_IN_DOLLAR) ? '$$':130; - st[1]=0; - return st; -} - -I1 *EditQuotesCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - LexStruct *lx=mem_tss->last_lex; - I1 *st=MAlloc(2,mem_tss); - st[0]=(lx->flags & LF_IN_QUOTES) ? '"':130; - st[1]=0; - return st; -} - -I1 *EditBracesCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - LexStruct *lx=mem_tss->last_lex; - I1 *st=MAlloc(2,mem_tss); - st[0]=(lx->braces_cnt) ? '}':130; - st[1]=0; - return st; -} - -I1 *EditSemicolonCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - LexStruct *lx=mem_tss->last_lex; - I1 *st=MAlloc(2,mem_tss); - st[0]=(lx->statement_cnt) ? ';':130; - st[1]=0; - return st; -} - -I1 *EditDollarTypeCB(Ltf *l,Ltf *user_data,LtfEntry *ll,TssStruct *mem_tss) -{ - I1 *src=SysTextSub(user_data->cur_entry->btype,"ST_LTF_CMDS"); - I1 *st=MAllocZ(4,mem_tss); - if (user_data->cur_entry==user_data) { - StrCpy(st,"EOF"); - } else if (src) StrCpy(st,src); - return st; -} - -public BoolU4 DoLtf(Ltf *l,BoolU4 home=TRUE,I1 *help=NULL,BoolU4 help_is_file=FALSE) -{ - Ltf *menu=NULL,*old_ltf=Fs->cur_ltf,*old_aux=Fs->aux_ltf,*aux; - U8 sc=0; - I8 old_attribute=Fs->text_attribute; - I8 ch=0; - LtfEntry *ll; - U8 my_LtfPutChar(LTChnl *chnl,I8 ch,U8 sc); - BoolU4 old_update=Fs->update_window; - - if (help && !l->menu_ltf) { - if (help_is_file) - menu=LtfRead(help); - else { - menu=LtfNew; - menu->text_attribute=l->text_attribute; - LtfPutS(menu,help); - } - l->menu_ltf=menu; - } - - l->tss=Fs; - aux=LtfNew; - aux->text_attribute=Fs->border_attribute; - LtfPutS(aux,"$$CM +TY,0,-1$$"); - if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WINDOW)) - LtfPutS(aux,"$$TX+RX+BD,\"[X]\"$$"); - if (l->menu_ltf) - LtfPutS(aux,"$$TX+LX+BD,\"MENU\"$$"); - - ll=LtfPutS(aux,"$$DA-T-P+BD+RD+CX+SCX+IV,256,\"%s...\",16$$"); - ll->data=&l->filename.name; - LtfFormatData(ll); - - LtfPutS(aux,"$$CM+BY+RX,-24,1$$"); - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditDollarTypeCB; - LtfPutS(aux,"$$CM+BY+RX,-21,1$$"); - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditOverStrikeCB; - LtfPutS(aux,"$$CM+BY+RX,-20,1$$"); //gets merged without this - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditDollarCB; - - ll=LtfPutS(aux,"$$DA+BD+RD-T,32,\"Line:%04d \"$$"); - ll->data=&l->line; - LtfFormatData(ll); - ll=LtfPutS(aux,"$$DA+BD+RD-T,32,\"Col:%04d\"$$\r\n"); - ll->data=&l->col; - LtfFormatData(ll); - aux->user_data=l; - Fs->aux_ltf=aux; - - l->recalc_start=l; - LtfRecalc(l); - - if (home) - LtfHome(l); - Fs->cur_ltf=l; - Fs->text_attribute=l->text_attribute; - AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,l->menu_ltf); - Fs->update_window=&LtfUpdateCurLtfWindow; - Bts(&Fs->crt_flags,CRTf_SHOW); - do { - ch=GetChar2(&sc); - LtfPutChar(l,ch,sc,Bt(&sys_flags,SYSf_PREEMPTIVE)); - if (Fs->rmt_chnl) { - my_LtfPutChar=ext[EXT_RMT_LTFPUTCHAR]; - my_LtfPutChar(Fs->rmt_chnl,ch,sc); - } - LtfRecalc(l); - } while (ch!=CH_ESC && ch!=CH_CTRLQ); - Fs->cur_ltf=old_ltf; - Fs->aux_ltf=old_aux; - AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,old_ltf->menu_ltf); - Fs->text_attribute=old_attribute; - Fs->update_window=old_update; - LtfDel(aux); - if (menu) { - l->menu_ltf=NULL; - LtfDel(menu); - } - return ch==CH_ESC; -} - - -public BoolU4 DoForm(U1 *D,I1 *class_name, - I1 *help=NULL,BoolU4 help_is_file=FALSE, - I1 *header=NULL,I1 *footer=NULL) -{ - BoolU4 result=FALSE; - MemberListStruct *ml; - LtfEntry *ll; - I8 ch=0; - ClassStruct *cl=FindLocalHash(class_name,HTT_CLASS); - Ltf *l; - if (!cl) return FALSE; - l=LtfNew; - if (header) LtfPutS(l,header); - l->flags|=LTFF_OVERSTRIKE | LTFF_FORM; - ml=cl->member_list; - while (ml) { - if (ml->fmtstr) { - ll=LtfPutS(l,ml->fmtstr); - ll->data=D+ml->offset; - ll->my_format_data=ml->fmtdata; - LtfFormatData(ll); - } - ml=ml->next; - } - if (footer) LtfPutS(l,footer); - if (l->dummy.next!=l) { - l->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME); - LtfRecalc(l); - if (DoLtf(l,TRUE,help,help_is_file)) { - ll=l->dummy.next; - while (ll!=l) { - if (ll->btype==LTFT_DATA || ll->btype==LTFT_CHECK_BOX) - LtfGetData(ll); - ll=ll->next; - } - result=TRUE; - } - } - LtfDel(l); - return result; -} - - -public I8 DoMenu(Ltf *m,I1 *help=NULL) -{ - LtfEntry *ll; - I8 result=-1; - BoolU4 old_preempt=Preempt(OFF); - if (m) { - m->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME); -//TODO: preempt is off and popup in ltf could be run with preempt off - if (DoLtf(m,TRUE,help)) { - ll=m->cur_entry; - if (ll!=m) - result=LtfRunLine(m,ll,TRUE,old_preempt); - } - } - Preempt(old_preempt); - return result; -} - -public void LtfWrite(Ltf *l,BoolU4 prompt=FALSE) -{ - U8 size; - I1 *buf=LtfSave(l,&size); - if (prompt) { - if (DoForm(&l->filename,"EditFileNameStruct")) - WriteFile(l->filename.name,buf,size,0,l->file_attr); - } else - WriteFile(l->filename.name,buf,size,0,l->file_attr); - Free(buf); -} - -public void DelClipboard() -{ - LtfReset(sys_clipboard_ltf,TRUE,TRUE); -} - - -public void EditCopyToClipboard(Ltf *l) -{ - Ltf *b=sys_clipboard_ltf; - LtfEntry *cl=l->dummy.next,*nl; - LtfBinEntry *tempb; - DelClipboard(); - while (cl!=l) { - if (cl->type & LTFLT_SELECTED) { - cl->type&=~LTFLT_SELECTED; - if (!Bt(ltf_data_types,cl->btype)) { - nl=LtfCopyEntry(b,cl); - InsQue(nl,b->dummy.last); - } - } - cl=cl->next; - } -} - -public void EditCutToClipboard(Ltf *l) -{ - Ltf *b=sys_clipboard_ltf; - LtfEntry *cl=l->dummy.next,*cl1,*nl,*cl2=NULL; - LtfBinEntry *tempb; - DelClipboard(); - while (cl!=l) { - cl1=cl->next; - if (cl->type & LTFLT_SELECTED) { - cl->type&=~LTFLT_SELECTED; - if (!Bt(ltf_data_types,cl->btype)) { - nl=LtfCopyEntry(b,cl); - InsQue(nl,b->dummy.last); - } - if (cl==l->cur_entry || cl==cl2) - cl2=cl->next; - RemQue(cl); - LtfDelEntry(cl,l->mem_tss); - } - cl=cl1; - } - if (cl2) { - l->cur_entry=cl2; - l->cur_data_col=cl2->min_col; - } - l->recalc_start=l; - LtfRemoveSoftCRs(l,NULL); -} - -public void EditInsertLtf(Ltf *l,Ltf *b) -{ //TODO: $LK,"LtfReset","MN:LtfReset"$ - I1 *dst; - LtfEntry *nl,*cl=b->dummy.next; - LtfBinEntry *tempb; - LtfRemoveSoftCRs(l,NULL); - if ((l->cur_entry->btype)==LTFT_TEXT && - l->cur_data_col>l->cur_entry->min_col) { - if (l->cur_data_colcur_entry->max_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | l->cur_entry->type & 0xFFFFFF00; - nl->flags=l->cur_entry->flags; - nl->x=l->cur_entry->x; - nl->y=l->cur_entry->y; - nl->indent=l->cur_entry->indent; - nl->page_line_num=l->cur_entry->page_line_num; - nl->left_margin=l->cur_entry->left_margin; - nl->right_margin=l->cur_entry->right_margin; - dst=l->cur_entry->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - nl->max_col=StrLen(dst); - *dst=0; - l->cur_entry->max_col=l->cur_data_col; - InsQue(nl,l->cur_entry); - l->cur_entry=nl; - l->cur_data_col=nl->min_col; - } else - if (l->cur_entry!=l) - l->cur_entry=l->cur_entry->next; - } - while (cl!=b) { - if (cl->btype!=LTFT_SOFT_CR) { - nl=LtfCopyEntry(l,cl); - InsQue(nl,l->cur_entry->last); - } - cl=cl->next; - } - l->recalc_start=l; -} - -void Irq07Handler() -{ - Bts(&sys_irq_flags,7); -} -ext[EXT_IRQ07]=&Irq07Handler; - -#define LPT_INIT 0x09 -#define LPT_ON 0x1D -#define LPT_STROBE (LPT_ON ^ 1) -#define LPT_OFF 0x05 - -I8 lpt1_col=0; - -public void Lpt1On() -{ - lpt1_col=0; - OutP(0x77A,0); //Standard Mode - OutP(0x37A,LPT_INIT); - OutP(0x37A,LPT_ON); -} - -public void Lpt1Off() -{ - Sleep(1000); - OutP(0x37A,LPT_OFF); -} - -void Lpt1LineFeed() -{ - Lpt1PutChar(CH_CR); - Lpt1PutChar(CH_LINE_FEED); -} - -public void Lpt1PutChar(U1 *ch) -{ - U8 timeout_jiffies; - if (ch==CH_CURSOR) return; - do { - do { - if (InP(0x379)!=0x5F) - SwapInNext; - else - break; - } while (TRUE); - - OutP(0x378,ch); - Btr(&sys_irq_flags,7); - OutP(0x37A,LPT_STROBE); - OutP(0x37A,LPT_ON); - timeout_jiffies=jiffies+JIFFY_FREQ/100; - while (!Btr(&sys_irq_flags,7) && - jiffies=timeout_jiffies); - if (ch>=CH_SHIFT_SPACE && ch<=0x7F) { - lpt1_col++; - if (lpt1_col>=80) - Lpt1LineFeed; - } else if (ch==CH_CR) - lpt1_col=0; - else if (ch==CH_TAB) { - lpt1_col=(lpt1_col+8) & 0xFFFFFFF8; - if (lpt1_col>=80) - Lpt1LineFeed; - } -} - -public void Lpt1PrintF(I1 *src,...) -{ - I1 *buf=SPrintFJoin(NULL,src,argc,argv),*ptr=buf; - while (*ptr) - Lpt1PutChar(*ptr++); - Free(buf); -} - -public void Lpt1PrintLtf(Ltf *l) -{ - U1 t; - BoolU4 just_did_crlf=TRUE; - I8 i; - LtfEntry *ll; - LtfRecalc(l); - ll=l->dummy.next; - Lpt1On; - while (ll!=l) { - if (just_did_crlf) { - for (i=0;iindent>>2;i++) - Lpt1PutChar(CH_SPACE); - just_did_crlf=FALSE; - } - t=ll->btype; - if (Bt(ltf_display_types,t)) - Lpt1PrintF("%s",ll->display); - else if (t==LTFT_TAB) - Lpt1PutChar(CH_TAB); - else if (t==LTFT_CR || t==LTFT_SOFT_CR) { - Lpt1LineFeed; - just_did_crlf=TRUE; - } - ll=ll->next; - } - Lpt1PutChar(CH_FORM_FEED); - Lpt1Off; -} - -public void Lpt1PrintFile(I1 *name) -{ - Lpt1On; - Lpt1PrintF("%F",name); - Lpt1PutChar(CH_FORM_FEED); - Lpt1Off; -} - -public void EditFindNext(Ltf *l) -{ - I1 *ptr; - LtfEntry *ll,*cl=l->cur_entry; - U8 ss_flags; - if (l->find_replace->match_case) - ss_flags=0; - else - ss_flags=SS_IGNORE_CASE; - if (l->find_replace->whole_labels) - ss_flags|=SS_WHOLE_LABELS; - - ll=(l->find_replace->scan_forward)?cl->next:cl->last; - while (ll!=cl) { - if (ll!=l) { - if (Bt(ltf_display_types,ll->btype)) { - if ((ll->type & LTFLT_SELECTED) || !l->find_replace->scan_selected_text) { - if (ptr=SearchString(ll->display,l->find_replace->find_text,ss_flags)) { - l->cur_entry=ll; - l->cur_data_col=ptr-ll->display; - if (l->cur_data_colmin_col) - l->cur_data_col=ll->min_col; - if (l->cur_data_col>ll->max_col) - l->cur_data_col=ll->max_col; - LtfCenter(l); - return; - } - } - } - } - ll=(l->find_replace->scan_forward) ?ll->next:ll->last; - } -} - -public I8 PopUp(I1 *msg,TssStruct *parent=NULL) -{ - U8 result=0; - TssCmdStruct *tempc; - TssStruct *tss; - tss=Spawn(&ServantUserCmdLine,"SYSTEM TASK",parent); - while (!Bt(&tss->task_flags,TSSf_IDLE)) - SwapInNext; - Bts(&tss->crt_flags,CRTf_SHOW); - if (!parent) { - QueueTaskRequest(tss,parent,msg,(1<popup_tss=tss; - tempc=QueueTaskRequest(tss,parent,msg, - 1<popup_tss=NULL; - Kill(tss); - return result; - } -} - -public I8 PopUpMenu(Ltf *l,I1 *help=NULL) -{ - l->flags|=LTFF_MIN_SIZE | LTFF_FORM; - return ServantUser("DoMenu(0x%X,0x%X);",l,help); -} - -void PickFileSub(Ltf *l,LTDirEntry *tempm) -{ - while (tempm) { - if (tempm->attr & LT_ATTR_DIR) { - LtfPrintF(l,"$$TR \"%s\"$$\r\n",tempm->name); - LtfPutS(l,"$$ID,+2$$"); - if (tempm->sub) - PickFileSub(l,tempm->sub); - LtfPutS(l,"$$ID,-2$$"); - } else - LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n", - tempm->name,tempm->full_name); - tempm=tempm->next; - } -} - -public I1 *PopUpPickFile(I1 *mask="/*",I1 *flags="+r") -{ - I1 *st,*result=NULL; - LTDirEntry *tempm; - FlagsStruct f; - Ltf *l=LtfNew; - GetFFlags(&f,"ST_FILE_UTIL_FLAGS",flags); - tempm=FindFiles(mask,&f.on); - LtfPutS(l,"$$TR -C+AL,\"\"$$\r\n"); - LtfPutS(l,"$$ID,+2$$"); - PickFileSub(l,tempm); - LtfPutS(l,"$$ID,-2$$"); - st=PopUpMenu(l); - if (st>0) - result=NewString(st); - LtfDel(l); - DelLTDirList(tempm); - return result; -} - -void PickDirSub(Ltf *l,LTDirEntry *tempm) -{ - while (tempm) { - LtfPrintF(l,"$$TR \"\"$$"); - LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n", - tempm->name,tempm->full_name); - LtfPutS(l,"$$ID,+2$$"); - if (tempm->sub) - PickDirSub(l,tempm->sub); - LtfPutS(l,"$$ID,-2$$"); - tempm=tempm->next; - } -} - -public I1 *PopUpPickDir(I1 *mask="/*",I1 *flags="+r+D") -{ //+r=recurse +D=just dirs - I1 *st,*result=NULL; - LTDirEntry *tempm; - FlagsStruct f; - Ltf *l=LtfNew; - GetFFlags(&f,"ST_FILE_UTIL_FLAGS",flags); - tempm=FindFiles(mask,&f.on); - LtfPutS(l,"$$TR -C+AL,\"\"$$\r\n"); - LtfPutS(l,"$$ID,+2$$"); - PickDirSub(l,tempm); - LtfPutS(l,"$$ID,-2$$"); - st=PopUpMenu(l); - if (st>0) - result=NewString(st); - LtfDel(l); - DelLTDirList(tempm); - return result; -} - - - -public BoolU4 PopUpDoForm(U1 *d,I1 *class_name, - I1 *help=NULL,BoolU4 help_is_file=FALSE) -{ //TODO: add header/footer - BoolU4 result; - result=ServantUser("DoForm(0x%X,\"%s\",0x%X,%d);",d,class_name,help,help_is_file); - return result; -} - -PasswordStruct *PopUpPassword() -{ - PasswordStruct *pwr=MAlloc(sizeof(PasswordStruct)); - pwr->pw[0]=0; -//TODO: password within file operations locks on servant startup -// if (!PopUpDoForm(pwr,"PasswordStruct")) { - if (!DoForm(pwr,"PasswordStruct")) { - Free(pwr); - pwr=NULL; - } - return pwr; -} - -public I8 PopUpOk(I1 *header=NULL,I1 *footer=NULL) -{ - I8 i; - Ltf *l=LtfNew; - if (header) LtfPutS(l,header); - LtfPutS(l,"$$CM +CX,0,4$$$$BT, \"OKAY\" 1$$"); - if (footer) LtfPutS(l,footer); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -public I8 PopUpNoYes(I1 *header=NULL,I1 *footer=NULL) -{ - I8 i; - Ltf *l=LtfNew; - if (header) LtfPutS(l,header); - LtfPutS(l,"$$CM +LX, 2,4$$$$BT, \"YES\",1$$"); - LtfPutS(l,"$$CM +LX, 18,0$$$$BT, \"NO\",0$$"); - if (footer) LtfPutS(l,footer); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -public I8 PopUpCancelOk(I1 *header=NULL,I1 *footer=NULL) -{ - I8 i; - Ltf *l=LtfNew; - if (header) LtfPutS(l,header); - LtfPutS(l,"$$CM +LX, 2,4$$$$BT, \"OK\",1$$"); - LtfPutS(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",0$$"); - if (footer) LtfPutS(l,footer); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -public I8 PopUpReplaceSkipAllCancel(I1 *header=NULL,I1 *footer=NULL) -{ - I8 i; - Ltf *l=LtfNew; - if (header) LtfPutS(l,header); - LtfPutS(l,"$$CM +LX,2,4$$$$BT, \"REPLACE\",0$$"); - LtfPutS(l,"$$CM +LX, 18,0$$$$BT, \"SKIP\",1$$"); - LtfPutS(l,"$$CM +LX, 2,3$$$$BT, \"ALL\",2$$"); - LtfPutS(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",3$$"); - if (footer) LtfPutS(l,footer); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -public void EditReplace(Ltf *l) -{ - BoolU4 first=TRUE,old_preempt; - I8 cmd=0,i,j,plen,rlen,dlen; - I1 *src,*dst,*dst2; - LtfEntry *cl=l->cur_entry,*ll; - U8 ss_flags; - if (DoForm(l->find_replace,"EditFindTextStruct")) { - if (l->find_replace->match_case) - ss_flags=0; - else - ss_flags=SS_IGNORE_CASE; - if (l->find_replace->whole_labels) - ss_flags|=SS_WHOLE_LABELS; - if (!(l->find_replace->replace)) { - EditFindNext(l); - return; - } - plen=StrLen(l->find_replace->find_text); - if (!plen) return; - rlen=StrLen(l->find_replace->replace_text); - ll=cl; - while ((ll!=cl || first) && cmd!=3) { - first=FALSE; - if (ll->btype==LTFT_TEXT && - ((ll->type & LTFLT_SELECTED) || !l->find_replace->scan_selected_text)) { - src=ll->display; - while (src && cmd!=3) { - src=SearchString(src,l->find_replace->find_text,ss_flags); - if (src) { - l->cur_data_col=src-ll->display; - l->cur_entry=ll; - l->recalc_start=l; - if (cmd!=2) - LtfCenter(l); - ll=l->cur_entry; - src=l->cur_data_col+ll->display; - if (cmd!=2) { - cmd=PopUpReplaceSkipAllCancel(""); - if (cmd==2) - old_preempt=Preempt(OFF); - } - if (cmd==0 || cmd==2) { - dlen=StrLen(ll->display); - dst=MAlloc(dlen+1+rlen-plen,l->mem_tss); - dst2=dst; - j=src-ll->display; - for (i=0;idisplay[i]; - for (i=0;ifind_replace->replace_text[i]; - src=dst; - for (i=j+plen;i<=dlen;i++) - *dst++=ll->display[i]; - Free(ll->display,l->mem_tss); - ll->display=dst2; - l->cur_data_col=src-ll->display; - l->cur_entry=ll; - if (cmd!=2) { - l->recalc_start=l; - LtfRemoveSoftCRs(l,l->cur_entry); - LtfRecalc(l); - } - ll=l->cur_entry; - src=l->cur_data_col+ll->display; - } else - src++; - } - } - } - if (l->find_replace->scan_forward) { - ll=ll->next; - if (ll==l) { - if (cl==l) break; - ll=ll->next; - } - } else { - ll=ll->last; - if (ll==l) { - if (cl==l) break; - ll=ll->last; - } - } - } - } - if (cmd==2) { - l->recalc_start=l; - LtfRemoveSoftCRs(l,NULL); - LtfRecalc(l); - Preempt(old_preempt); - } -} - -class EditGoToLineStruct -{ - I8 line fmtstr "$$DA -T, 256, \"Go to Line:%04d\"$$"; -}; - -public void EditGoToLine(Ltf *l) -{ - EditGoToLineStruct gtl; - gtl.line=1; - if (DoForm(>l,"EditGoToLineStruct")) { - l->x=0; - l->y=gtl.line-1; - LtfUpdateWindowJoin(l,FALSE,FALSE,FALSE,TRUE); - LtfCenter(l); - } -} - -void TogglePlainTextMode(Ltf *l) -{ - U8 size; - I1 *st=LtfSave(l,&size); - BoolU4 old_preempt=Preempt(OFF); - U8 flags=l->flags ^ LTFF_PLAIN_TEXT; - Ltf *menu=l->menu_ltf; - LtfReset(l,TRUE); - l->menu_ltf=menu; - l->flags=flags & ~(LTFF_WORD_WRAP|LTFF_INVERTED|LTFF_UNDERLINED|LTFF_BLINK); - LtfLoad(l,st,size); - LtfCenter(l); - Preempt(old_preempt); - Free(st); -} - -#define LK_FILE 0 -#define LK_FILE_ANCHOR 1 -#define LK_FILE_FIND 2 -#define LK_FILE_LINE 3 -#define LK_MAN_PAGE 4 -#define LK_PLAIN 5 -#define LK_PLAIN_FIND 6 -#define LK_PLAIN_LINE 7 -#define LK_PLACE_ANCHOR 8 - -I8 PopUpLinkType() -{ - I8 i; - Ltf *l=LtfNew; - LtfPutS(l,"$$MU,\"To file\" LK_FILE$$\r\n"); - LtfPutS(l,"$$MU,\"To anchor in file\" LK_FILE_ANCHOR$$\r\n"); - LtfPutS(l,"$$MU,\"To string in file\" LK_FILE_FIND$$\r\n"); - LtfPutS(l,"$$MU,\"To line in file\" LK_FILE_LINE$$\r\n"); - LtfPutS(l,"$$MU,\"To man page\" LK_MAN_PAGE$$\r\n"); - LtfPutS(l,"$$MU,\"To plain-text file\" LK_PLAIN$$\r\n"); - LtfPutS(l,"$$MU,\"To string in plain-text file\" LK_PLAIN_FIND$$\r\n"); - LtfPutS(l,"$$MU,\"To line in plain-text file\" LK_PLAIN_LINE$$\r\n"); - LtfPutS(l,"$$MU,\"Place Anchor\" LK_PLACE_ANCHOR$$\r\n"); - LtfPutS(l,"$$MU,\"CANCEL\" -1$$"); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -class EditFileLinkStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132] fmtstr "$$DA -P 131 \"File :%s\"$$\r\n"; - I1 aux[132]; - I8 num; - BoolU4 hide; -}; - -class EditFileAnchorLinkStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132] fmtstr "$$DA -P 131 \"File :%s\"$$\r\n"; - I1 aux[132] fmtstr "$$DA -P 131 \"Anchor Label :%s\"$$\r\n"; - I8 num; - BoolU4 hide; -}; - -class EditFileFindLinkStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132] fmtstr "$$DA -P 131 \"File :%s\"$$\r\n"; - I1 aux[132] fmtstr "$$DA -P 131 \"String :%s\"$$\r\n"; - I8 num fmtstr "$$DA -T 131 \"Occurrence Num:%04d\"$$\r\n"; - BoolU4 hide; -}; - -class EditFileLineLinkStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132] fmtstr "$$DA -P 131 \"File :%s\"$$\r\n"; - I1 aux[132]; - I8 num fmtstr "$$DA -T 131 \"Line Num :%04d\"$$\r\n"; - BoolU4 hide; -}; - -class EditManPageLinkStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132]; - I1 aux[132] fmtstr "$$DA -P 131 \"Label :%s\"$$\r\n"; - I8 num; - BoolU4 hide; -}; - -class EditPlaceAnchorStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - I1 file[132]; - I1 aux[132] fmtstr "$$DA -P 131 \"Anchor Label :%s\"$$\r\n"; - I8 num; - BoolU4 hide fmtstr "$$CB \"Hide\"$$\r\n"; -}; - - -#define CTRL_L_HELP "::/LT/DOC/CtrlL.MUZ" -I1 *ctrl_L_header="Press WINDOW's key for help\r\n\r\n"; -void EditInsertLink() -{ - EditFileLinkStruct *el=MAllocZ(sizeof(EditFileLinkStruct)); - I8 type=PopUpLinkType; - if (type>=0) { - el->num=1; - switch (type) { - case LK_FILE: - if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"FI:%s\"$$",el->file,el->file); - else - PrintF("$$LK \"%s\",\"FI:%s\"$$",el->display,el->file); - } - break; - case LK_PLAIN: - if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"PI:%s\"$$",el->file,el->file); - else - PrintF("$$LK \"%s\",\"PI:%s\"$$",el->display,el->file); - } - break; - case LK_FILE_ANCHOR: - if (DoForm(el,"EditFileAnchorLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"FA:%s,%s\"$$",el->aux,el->file,el->aux); - else - PrintF("$$LK \"%s\",\"FA:%s,%s\"$$",el->display,el->file,el->aux); - } - break; - case LK_FILE_FIND: - if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (el->num==1) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"FF:%s,%s\"$$",el->aux,el->file,el->aux); - else - PrintF("$$LK \"%s\",\"FF:%s,%s\"$$",el->display,el->file,el->aux); - } else { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"FF:%s,%s:%d\"$$",el->aux,el->file,el->aux,el->num); - else - PrintF("$$LK \"%s\",\"FF:%s,%s:%d\"$$",el->display,el->file,el->aux,el->num); - } - } - break; - case LK_PLAIN_FIND: - if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (el->num==1) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"PF:%s,%s\"$$",el->aux,el->file,el->aux); - else - PrintF("$$LK \"%s\",\"PF:%s,%s\"$$",el->display,el->file,el->aux); - } else { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"PF:%s,%s:%d\"$$",el->aux,el->file,el->aux,el->num); - else - PrintF("$$LK \"%s\",\"PF:%s,%s:%d\"$$",el->display,el->file,el->aux,el->num); - } - } - break; - case LK_FILE_LINE: - if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"FL:%s,%d\"$$",el->file,el->file,el->num); - else - PrintF("$$LK \"%s\",\"FL:%s,%d\"$$",el->display,el->file,el->num); - } - break; - case LK_PLAIN_LINE: - if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"PL:%s,%d\"$$",el->file,el->file,el->num); - else - PrintF("$$LK \"%s\",\"PL:%s,%d\"$$",el->display,el->file,el->num); - } - break; - case LK_MAN_PAGE: - if (DoForm(el,"EditManPageLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) - PrintF("$$LK \"%s\",\"MN:%s\"$$",el->aux,el->aux); - else - PrintF("$$LK \"%s\",\"MN:%s\"$$",el->display,el->aux); - } - break; - case LK_PLACE_ANCHOR: - if (DoForm(el,"EditPlaceAnchorStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - if (!el->display[0]) { - if (el->hide) - PrintF("$$AN \"\",\"%s\"$$",el->aux); - else - PrintF("$$AN \"%s\",\"%s\"$$",el->aux,el->aux); - } else - PrintF("$$AN \"%s\",\"%s\"$$",el->display,el->aux); - } - break; - } - } - Free(el); -} - -I8 PopUpColorType() -{ - I8 i; - Ltf *l=LtfNew; - LtfPutS(l,"$$MU,\"Foreground\" LTFT_FOREGROUND_COLOR$$\r\n"); - LtfPutS(l,"$$MU,\"Background\" LTFT_BACKGROUND_COLOR$$\r\n"); - LtfPutS(l,"$$MU,\"Default Foreground\" LTFT_DEFAULT_FOREGROUND_COLOR$$\r\n"); - LtfPutS(l,"$$MU,\"Default Background\" LTFT_DEFAULT_BACKGROUND_COLOR$$\r\n"); - LtfPutS(l,"$$MU,\"Link Foreground\" LTFT_LINK_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Link Background\" LTFT_LINK_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Macro Foreground\" LTFT_MACRO_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Macro Background\" LTFT_MACRO_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Anchor Foreground\" LTFT_ANCHOR_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Anchor Background\" LTFT_ANCHOR_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Hidden Foreground\" LTFT_HIDDEN_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Hidden Background\" LTFT_HIDDEN_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Tree Foreground\" LTFT_TREE_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"Tree Background\" LTFT_TREE_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"User Foreground\" LTFT_USER_FOREGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"User Background\" LTFT_USER_BACKGROUND$$\r\n"); - LtfPutS(l,"$$MU,\"CANCEL\" -1$$"); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - - -public I8 PopUpPageSettingType() -{ - I8 i; - Ltf *l=LtfNew; - LtfPutS(l,"$$MU,\"Page Length\",LTFT_PAGE_LENGTH$$\r\n"); - LtfPutS(l,"$$MU,\"Page Header\",LTFT_HEADER$$\r\n"); - LtfPutS(l,"$$MU,\"Page Footer\",LTFT_FOOTER$$\r\n"); - LtfPutS(l,"$$MU,\"Left Margin\",LTFT_LEFT_MARGIN$$\r\n"); - LtfPutS(l,"$$MU,\"Right Margin\",LTFT_RIGHT_MARGIN$$\r\n"); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -void EditInsertColor() -{ - I8 type=PopUpColorType,col=LTF_DEFAULT; - if (type>=0) { - col=PopUpColor; - if (col!=LTF_DEFAULT) - PrintF("$$%Z %d$$",type,"ST_LTF_CMDS",col); - else - PrintF("$$%Z$$",type,"ST_LTF_CMDS"); - } -} - -class EditPageSettingStruct -{ - I1 value[132] fmtstr "$$DA -P 131 \"Setting Value:%s\"$$\r\n"; -}; - - -void EditInsertPageSetting() -{ - I8 type=PopUpPageSettingType; - EditPageSettingStruct *el=MAllocZ(sizeof(EditPageSettingStruct)); - if (type>=0) { - if (DoForm(el,"EditPageSettingStruct")) { - if (*el->value) - PrintF("$$%Z,%s$$",type,"ST_LTF_CMDS",el->value); - else - PrintF("$$%Z$$",type,"ST_LTF_CMDS"); - } - } - Free(el); -} - -I8 PopUpDollarType() -{ - I8 i; - Ltf *l=LtfNew; - LtfPutS(l,"$$MU,\"Link\" LTFT_LINK$$\r\n"); - LtfPutS(l,"$$MU,\"Text\" LTFT_TEXT$$\r\n"); - LtfPutS(l,"$$MU,\"Tree Branch\" LTFT_TREE$$\r\n"); - LtfPutS(l,"$$MU,\"Color\" LTFT_FOREGROUND_COLOR$$\r\n"); - LtfPutS(l,"$$MU,\"Page Settings\" LTFT_PAGE_LENGTH$$\r\n"); - LtfPutS(l,"$$MU,\"Cursor Movement\" LTFT_CURSOR_MOVEMENT$$\r\n"); - LtfPutS(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n"); - LtfPutS(l,"$$MU,\"Check Box\" LTFT_CHECK_BOX$$\r\n"); - LtfPutS(l,"$$MU,\"Macro\" LTFT_MACRO$$\r\n"); - LtfPutS(l,"$$MU,\"Menu Value\" LTFT_MENU_VALUE$$\r\n"); - LtfPutS(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n"); - LtfPutS(l,"$$MU,\"Data\" LTFT_DATA$$\r\n"); - LtfPutS(l,"$$MU,\"Hex Edit\" LTFT_HEX_EDIT$$\r\n"); - LtfPutS(l,"$$MU,\"Hidden Widget\" LTFT_HIDE_START$$\r\n"); - LtfPutS(l,"$$MU,\"Song\" LTFT_SONG$$\r\n"); - LtfPutS(l,"$$MU,\"CANCEL\" -1$$"); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -class EditDollarTextStruct -{ - I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; - BoolU4 left_x fmtstr "$$CB \"Left X\"$$\r\n"; - BoolU4 center_x fmtstr "$$CB \"Center X\"$$\r\n"; - BoolU4 right_x fmtstr "$$CB \"Right X\"$$\r\n"; - BoolU4 margin_rel fmtstr "$$CB \"Margin Rel X\"$$\r\n"; - BoolU4 blink fmtstr "$$CB \"Blink\"$$\r\n"; - BoolU4 invert fmtstr "$$CB \"Invert\"$$\r\n"; - BoolU4 underline fmtstr "$$CB \"Underline\"$$\r\n"; - BoolU4 tree fmtstr "$$CB \"Tree\"$$\r\n"; - BoolU4 collapsed fmtstr "$$CB \"Collapsed\"$$\r\n"; - BoolU4 alias fmtstr "$$CB \"Alias\"$$\r\n"; - I1 scroll_x [132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n"; - I1 shift_x [132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n"; - I1 shift_y [132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n"; -}; - -void EditInsertDollarText() -{ - I1 buf[132]; - EditDollarTextStruct *dt=MAllocZ(sizeof(EditDollarTextStruct)); - if (DoForm(dt,"EditDollarTextStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (dt->left_x ) StrCat(buf,"+LX"); - if (dt->center_x) StrCat(buf,"+CX"); - if (dt->right_x ) StrCat(buf,"+RX"); - if (dt->margin_rel) StrCat(buf,"+MRX"); - if (dt->blink) StrCat(buf,"+BK"); - if (dt->invert) StrCat(buf,"+IV"); - if (dt->underline) StrCat(buf,"+UL"); - if (dt->tree) StrCat(buf,"+TR"); - if (dt->collapsed) StrCat(buf,"+C"); - if (dt->alias) StrCat(buf,"+AL"); - if (*dt->scroll_x) StrCat(buf,"+SCX"); - if (*dt->shift_x) StrCat(buf,"+SX"); - if (*dt->shift_y) StrCat(buf,"+SY"); - PrintF("$$TX %s,\"%s\"",buf,dt->display); - if (*dt->shift_x) - PrintF(",%s",dt->shift_x); - if (*dt->shift_y) - PrintF(",%s",dt->shift_y); - if (*dt->scroll_x) - PrintF(",%s",dt->scroll_x); - PrintF("$$"); - } - Free(dt); -} - -class EditSongStruct -{ - I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; - I1 song[512] fmtstr "$$DA-P,511,\"Song :%s\"$$\r\n"; -}; - -void EditInsertSong() -{ - EditSongStruct *dt=MAllocZ(sizeof(EditSongStruct)); - if (DoForm(dt,"EditSongStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) - PrintF("$$SO,\"%s\",\"%s\"$$",dt->display,dt->song); - Free(dt); -} - -class EditMacroMenuStruct -{ - I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n"; - I1 left_macro[512] fmtstr "$$DA-P,511,\"Left Click Macro :%s\"$$\r\n"; - I1 left_exp[132] fmtstr "$$DA-P,131,\"Left Click Expression :%s\"$$\r\n"; - BoolU4 popup fmtstr "$$CB \"PopUp\"$$\r\n"; - BoolU4 left_is_auto fmtstr "$$CB \"Left is AutoString\"$$\r\n"; - BoolU4 left_x fmtstr "$$CB \"Left X \"$$\r\n"; - BoolU4 center_x fmtstr "$$CB \"Center X \"$$\r\n"; - BoolU4 right_x fmtstr "$$CB \"Right X \"$$\r\n"; - BoolU4 margin_rel fmtstr "$$CB \"Margin Rel X\"$$\r\n"; - BoolU4 blink fmtstr "$$CB \"Blink\"$$\r\n"; - BoolU4 invert fmtstr "$$CB \"Invert\"$$\r\n"; - BoolU4 underline fmtstr "$$CB \"Underline\"$$\r\n"; - BoolU4 escape fmtstr "$$CB \"Escape\"$$\r\n"; - I1 scroll_x[132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n"; - I1 shift_x[132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n"; - I1 shift_y[132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n"; -}; - -void EditInsertMacroMenu(BoolU4 is_macro) -{ - I1 buf[132]; - EditMacroMenuStruct *dt=MAllocZ(sizeof(EditMacroMenuStruct)); - dt->underline=TRUE; - dt->escape=TRUE; - if (DoForm(dt,"EditMacroMenuStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (is_macro && *dt->display) StrCat(buf,"+A "); - if (dt->popup) StrCat(buf,"+PU-X"); - if (dt->left_x ) StrCat(buf,"+LX"); - if (dt->center_x) StrCat(buf,"+CX"); - if (dt->right_x ) StrCat(buf,"+RX"); - if (dt->margin_rel) StrCat(buf,"+MRX"); - if (dt->blink) StrCat(buf,"+BK"); - if (dt->invert) StrCat(buf,"+IV"); - if (!dt->underline) StrCat(buf,"-UL"); - if (!dt->escape) StrCat(buf,"-X"); - if (*dt->scroll_x) StrCat(buf,"+SCX"); - if (*dt->shift_x) StrCat(buf,"+SX"); - if (*dt->shift_y) StrCat(buf,"+SY"); - if (is_macro) { - if (*dt->left_exp) StrCat(buf,"+LE"); - if (!*dt->left_macro) StrCat(buf,"-LM"); - } else { - if (!*dt->left_exp) StrCat(buf,"-LE"); - if (*dt->left_macro) StrCat(buf,"+LM"); - } - if (dt->left_is_auto) StrCat(buf,"+LA"); - if (dt->display[0] || is_macro) { - if (is_macro) { - if (*dt->display) - PrintF("$$MA %s,\"%s\"",buf,dt->display); - else - PrintF("$$MA %s,",buf); - } else - PrintF("$$MU %s,\"%s\"",buf,dt->display); - if (*dt->left_exp) - PrintF(",%s",dt->left_exp); - if (*dt->left_macro) - PrintF(",\"%s\"",dt->left_macro); - if (*dt->shift_x) - PrintF(",%s",dt->shift_x); - if (*dt->shift_y) - PrintF(",%s",dt->shift_y); - if (*dt->scroll_x) - PrintF(",%s",dt->scroll_x); - PrintF("$$"); - } - } - Free(dt); -} - -class EditButtonStruct -{ - I1 display[132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - BoolU4 popup fmtstr "$$CB \"PopUp\"$$\r\n"; - BoolU4 left_x fmtstr "$$CB \"Left X \"$$\r\n"; - BoolU4 center_x fmtstr "$$CB \"Center X \"$$\r\n"; - BoolU4 right_x fmtstr "$$CB \"Right X \"$$\r\n"; - BoolU4 margin_rel fmtstr "$$CB \"Margin Rel X\"$$\r\n"; - BoolU4 escape fmtstr "$$CB \"Escape\"$$\r\n"; - I1 left_macro [132] fmtstr "$$DA -P 131 \"Left Click Macro:%s\"$$\r\n"; - BoolU4 left_is_auto fmtstr "$$CB \"Left is AutoString\"$$\r\n"; - I1 left_exp [132] fmtstr "$$DA -P 131 \"Left Click Expression:%s\"$$\r\n"; - BoolU4 quote fmtstr "$$CB \"Quote\"$$\r\n"; -}; - -void EditInsertButton() -{ - I1 buf[132]; - EditButtonStruct *dt=MAllocZ(sizeof(EditButtonStruct)); - dt->escape=TRUE; - if (DoForm(dt,"EditButtonStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (dt->popup) StrCat(buf,"+PU-X"); - if (dt->left_x ) StrCat(buf,"+LX"); - if (dt->center_x) StrCat(buf,"+CX"); - if (dt->right_x ) StrCat(buf,"+RX"); - if (dt->margin_rel) StrCat(buf,"+MRX"); - if (!dt->escape) StrCat(buf,"-X"); - if (!*dt->left_exp) StrCat(buf,"-LE"); - if (*dt->left_macro) StrCat(buf,"+LM"); - if (dt->left_is_auto) StrCat(buf,"+LA"); - if (dt->display[0]) { - if (dt->quote) { - PrintF("$$$$BT %s,\\\"%s\\\"",buf,dt->display); - if (*dt->left_exp) - PrintF(",%s",dt->left_exp); - if (*dt->left_macro) - PrintF(",\\\"%s\\\"",dt->left_macro); - PrintF("$$$$"); - } else { - PrintF("$$BT %s,\"%s\"",buf,dt->display); - if (*dt->left_exp) - PrintF(",%s",dt->left_exp); - if (*dt->left_macro) - PrintF(",\"%s\"",dt->left_macro); - PrintF("$$"); - } - } - } - Free(dt); -} - - -class EditCursorMovementStruct -{ - I1 left_exp[132] fmtstr "$$DA -P 131 \"X Expression:%s\"$$\r\n"; - I1 right_exp[132] fmtstr "$$DA -P 131 \"Y Expression:%s\"$$\r\n"; - BoolU4 left_x fmtstr "$$CB \"Left X \"$$\r\n"; - BoolU4 center_x fmtstr "$$CB \"Center X \"$$\r\n"; - BoolU4 right_x fmtstr "$$CB \"Right X \"$$\r\n"; - BoolU4 margin_rel fmtstr "$$CB \"Margin Rel X\"$$\r\n"; - BoolU4 top_y fmtstr "$$CB \"Top Y \"$$\r\n"; - BoolU4 center_y fmtstr "$$CB \"Center Y \"$$\r\n"; - BoolU4 bottom_y fmtstr "$$CB \"Bottom Y \"$$\r\n"; - BoolU4 page_rel fmtstr "$$CB \"Page Rel Y\"$$\r\n"; - BoolU4 quote fmtstr "$$CB \"Quote\"$$\r\n"; -}; - -void EditInsertCursorMovement() -{ - I1 buf[132]; - EditCursorMovementStruct *dt=MAllocZ(sizeof(EditCursorMovementStruct)); - if (DoForm(dt,"EditCursorMovementStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (dt->left_x ) StrCat(buf,"+LX"); - if (dt->center_x) StrCat(buf,"+CX"); - if (dt->right_x ) StrCat(buf,"+RX"); - if (dt->margin_rel) StrCat(buf,"+MRX"); - if (dt->top_y ) StrCat(buf,"+TY"); - if (dt->center_y) StrCat(buf,"+CY"); - if (dt->bottom_y) StrCat(buf,"+BY"); - if (dt->page_rel) StrCat(buf,"+PRY"); - if (!*dt->left_exp) StrCat(buf,"-LE"); - if (!*dt->right_exp) StrCat(buf,"-RE"); - if (dt->quote) - PrintF("$$"); - PrintF("$$CM %s",buf); - if (*dt->left_exp) - PrintF(",%s",dt->left_exp); - if (*dt->right_exp) - PrintF(",%s",dt->right_exp); - PrintF("$$"); - if (dt->quote) - PrintF("$$"); - } - Free(dt); -} - -class EditDataStruct -{ - I1 format_str [132] fmtstr "$$DA -P 131 \"Format String:%s\"$$\r\n"; - U8 len fmtstr "$$DA 256 \"Length:%d\"$$\r\n"; - BoolU4 term fmtstr "$$CB \"Terminator\"$$\r\n"; - BoolU4 string fmtstr "$$CB \"String\"$$\r\n"; - BoolU4 refresh fmtstr "$$CB \"Refresh Data\"$$\r\n"; - BoolU4 password fmtstr "$$CB \"Password\"$$\r\n"; -}; - -void EditInsertData() -{ - I1 buf[132]; - EditDataStruct *dt=MAllocZ(sizeof(EditDataStruct)); - dt->term=TRUE; - dt->len=256; - if (DoForm(dt,"EditDataStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (dt->string) StrCat(buf,"-P"); - if (!dt->term) StrCat(buf,"-T"); - if (dt->refresh) StrCat(buf,"+RD"); - if (dt->password) StrCat(buf,"+PW"); - PrintF("$$$$DA%s,%d,\\\"%s\\\"$$$$", - buf,dt->len,dt->format_str); - } - Free(dt); -} - -class EditCheckBoxStruct -{ - I1 label [132] fmtstr "$$DA -P 131 \"Displayed Text:%s\"$$\r\n"; - BoolU4 refresh fmtstr "$$CB \"Refresh Data\"$$\r\n"; -}; - -void EditInsertCheckBox() -{ - I1 buf[132]; - EditCheckBoxStruct *dt=MAllocZ(sizeof(EditCheckBoxStruct)); - if (DoForm(dt,"EditCheckBoxStruct",CTRL_L_HELP,TRUE)) { - *buf=0; - if (dt->refresh) StrCat(buf,"+RD"); - PrintF("$$$$CB %s,\\\"%s\\\"$$$$", - buf,dt->label); - } - Free(dt); -} - -class EditHexEditStruct -{ - U8 cnt fmtstr "$$DA ,256 \"Count:%d\"$$\r\n"; - U8 cols fmtstr "$$DA ,256 \"Columns:%d\"$$\r\n"; - BoolU4 zero fmtstr "$$CB \"Zero Based\"$$\r\n"; - BoolU4 refresh fmtstr "$$CB \"Refresh Data\"$$\r\n"; -}; - -void EditInsertHexEdit() -{ - I1 buf[132]; - EditHexEditStruct *dt=MAllocZ(sizeof(EditHexEditStruct)); - dt->cnt=128; - dt->cols=16; - dt->zero=TRUE; - if (DoForm(dt,"EditHexEditStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (!dt->zero) StrCat(buf,"-Z"); - if (dt->refresh) StrCat(buf,"+RD"); - PrintF("$$$$HX %s,%d,%d$$$$", - buf,dt->cnt,dt->cols); - } - Free(dt); -} - -class EditTreeStruct -{ - I1 label[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; - I8 indent fmtstr "$$DA,131,\"Indention:%d\"$$\r\n"; - BoolU4 collapsed fmtstr "$$CB,\"Collapsed\"$$\r\n"; -}; - -void EditInsertTree() -{ - I1 buf[132],*st; - EditTreeStruct *dt=MAllocZ(sizeof(EditTreeStruct)); - dt->collapsed=TRUE; - dt->indent=2; - if (DoForm(dt,"EditTreeStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { - *buf=0; - if (!dt->collapsed) StrCat(buf,"-C"); - st=MSPrintF("$$TR %s,\"%s\"$$\r\n$$ID,%d$$*\r\n$$ID,%d$$", - buf,dt->label,dt->indent,-dt->indent); - LtfSafeInsert(Fs->cur_ltf,st); - Free(st); - } - Free(dt); -} - -void EditInsertHidden() -{ - LtfSafeInsert(Fs->cur_ltf,"$$HS$$*$$HE$$"); -} - - -void EditInsertDollarCmd() -{ - I8 type=PopUpDollarType; - switch (type) { - case LTFT_FOREGROUND_COLOR: - EditInsertColor; - break; - case LTFT_PAGE_LENGTH: - EditInsertPageSetting; - break; - case LTFT_LINK: - EditInsertLink; - break; - case LTFT_TEXT: - EditInsertDollarText; - break; - case LTFT_TREE: - EditInsertTree; - break; - case LTFT_MACRO: - EditInsertMacroMenu(TRUE); - break; - case LTFT_MENU_VALUE: - EditInsertMacroMenu(FALSE); - break; - case LTFT_CURSOR_MOVEMENT: - EditInsertCursorMovement; - break; - case LTFT_BUTTON: - EditInsertButton; - break; - case LTFT_DATA: - EditInsertData; - break; - case LTFT_CHECK_BOX: - EditInsertCheckBox; - break; - case LTFT_HEX_EDIT: - EditInsertHexEdit; - break; - case LTFT_HIDE_START: - EditInsertHidden; - break; - case LTFT_SONG: - EditInsertSong; - break; - } -} - -I1 *FavoritesFileName() -{ - return MSPrintF("::/LT/ACCOUNTS/%s/FAVOR.MUZ", - Fs->account->name); -} - -public void DoFavorites() -{ - I1 *name=FavoritesFileName; - Edit(name); - Free(name); -} - -I1 captured_macro_name[128]; -*captured_macro_name=0; - -I8 PopUpExitRecordPlayStopInsert() -{ - I8 result=0; - I1 buf[80]; - TssCmdStruct *tempc; - Ltf *l=LtfNew; - LtfEntry *ll; - ll=LtfPutS(l,"$$DA -P ,127 \"Name:%s\"$$"); - ll->data=captured_macro_name; - LtfFormatData(ll); - LtfPutS(l,"$$CM +LX +TY, 2,4$$$$BT, \"RECORD\" 1$$"); - LtfPutS(l,"$$CM +LX +TY, 18,4$$$$BT, \"PLAY\" 2$$"); - LtfPutS(l,"$$CM +LX +TY, 2,7$$$$BT, \"STOP\" 3$$"); - LtfPutS(l,"$$CM +LX +TY, 18,7$$$$BT, \"EXIT\" 0$$"); - LtfPutS(l,"$$CM +LX +TY, 2,10$$$$BT, \"INSERT\" 4$$"); - l->flags|=LTFF_MIN_SIZE | LTFF_FORM; - SPrintF(buf,"DoMenu(0x%X);",l); - macro_util_tss=Spawn(&ServantUserCmdLine,"MACRO POPUP",Fs); - Fs->popup_tss=macro_util_tss; - tempc=QueueTaskRequest(macro_util_tss,Fs,buf, - 1<popup_tss=NULL; - Kill(macro_util_tss); - macro_util_tss=NULL; - SwapInNext; //Kill task - LtfGetData(ll); - LtfDel(l); - return result; -} - - -void DelSysMacro() -{ - TssCmdStruct *tempc,*tempc1; - tempc=sys_macro_queue.next; - while (tempc!=&sys_macro_queue) { - tempc1=tempc->next; - RemQue(tempc); - AFree(tempc); - tempc=tempc1; - } -} - -I1 *SysMacro2Str() -{ - TssCmdStruct *tempc; - I8 cnt=0; - I1 *ptr,*m; - Btr(&sys_flags,SYSf_RECORD_MACRO); - tempc=sys_macro_queue.next; - while (tempc!=&sys_macro_queue) { - cnt++; - tempc=tempc->next; - } - m=MAlloc(cnt*54+1); - ptr=m; - - tempc=sys_macro_queue.next; - while (tempc!=&sys_macro_queue) { - SPrintF(ptr,"Msg(0x%08X,0x%016X,0x%016X);", - tempc->code,tempc->p1,tempc->p2); - ptr+=54; - tempc=tempc->next; - } - return m; -} - -void PlaySysMacro() -{ - I1 *m=SysMacro2Str; - while (sys_cur_focus_task==Fs) - SwapInNext; - XTalkString(sys_cur_focus_task,m); - Free(m); -} - -void MacroTask() -{ - I8 i; - StrCpy(captured_macro_name,"Click Here"); - do { - i=PopUpExitRecordPlayStopInsert; - RefocusWindow; - switch (i) { - case 1: - Btr(&sys_flags,SYSf_RECORD_MACRO); - DelSysMacro; - Bts(&sys_flags,SYSf_RECORD_MACRO); - break; - case 2: - PlaySysMacro; - break; - case 3: - Btr(&sys_flags,SYSf_RECORD_MACRO); - break; - case 4: - if (sys_cur_focus_task) - QueueMsg(sys_cur_focus_task,0, - MSG_KEY_DOWN,0,SC_F2|SCF_SHIFT,0); - break; - } - } while (i>0); -} - -void EditMacroUtil() -{ - if (!macro_util_tss) - Spawn(&MacroTask,"MACRO TASK"); -} - -void EditInsertCapturedMacro() -{ - BoolU4 old_preempt=Preempt(OFF); - I1 *st=SysMacro2Str; - PrintF("$$MA+A+LM+LA,\"%s\",\"%s\"$$", - captured_macro_name,st); - Free(st); - Preempt(old_preempt); -} - -public U8 LtfPutChar(Ltf *l,I8 ch,U8 sc,BoolU4 old_preempt) -{ - U8 sc2; - BoolU4 old_preempt2=Preempt(OFF); - LtfEntry *cl; - I8 i,x,y,ms=0; - I1 *st; - if (ch!=CH_ESC && ch!=CH_CTRLQ) { - cl=l->cur_entry; - x=l->x; y=l->y; - - sc2=sc.u1[0]; - if (sc2==SC_GUI) { - if (l->menu_ltf) { - ms=DoMenu(l->menu_ltf); - sc=0; sc2=0; ch=0; - } - } - - if (l->EditPlugIns) { - if (l->EditPlugIns(l,ch,sc)) { - sc=0; sc2=0; ch=0; - } - } - - if (Bt(printable_chars_bitmap,ch)) - EditInsertChar(ch,sc,l,old_preempt); - else if (sc2>=SC_F1 && sc2<=SC_F10 && sc & SCF_CTRL && !(sc & SCF_ALT)) { - if (!ws_task) - ws_task=Spawn(&WsTsk,"WORDSTAT"); - else { - if ((sc & SCF_SHIFT)) - WsMan(sc2-SC_F1+1,Fs); - else - WsFillin(sc2-SC_F1+1); - } - } else if (sc2==SC_CURSOR_DOWN||sc2==SC_END) { - if (sc2==SC_END || sc & SCF_CTRL) { - while (l->cur_entry!=l) { - if ((sc & SCF_SHIFT)) - l->cur_entry->type|=LTFLT_SELECTED; - else - l->cur_entry->type&=~LTFLT_SELECTED; - l->cur_entry=l->cur_entry->next; - } - l->cur_data_col=l->cur_entry->min_col; - l->recalc_start=l; - } else - EditLineDown(l,sc); - } else if (sc2==SC_CURSOR_UP||sc2==SC_HOME) { - if (sc2==SC_HOME || sc & SCF_CTRL) { - while (l->cur_entry!=l) { - if ((sc & SCF_SHIFT)) - l->cur_entry->type|=LTFLT_SELECTED; - else - l->cur_entry->type&=~LTFLT_SELECTED; - l->cur_entry=l->cur_entry->last; - } - l->cur_entry=l->dummy.next; - l->cur_data_col=l->cur_entry->min_col; - l->recalc_start=l; - } else - EditLineUp(l,sc); - } else if (sc2==SC_PAGE_DOWN) { - if (cl!=l) - cl=cl->last; - for (i=Fs->window_top;iwindow_bottom;i++) { - EditLineDown(l,sc); - l->y=l->cur_entry->y; - } - l->recalc_start=cl; - } else if (sc2==SC_PAGE_UP) { - for (i=Fs->window_top;iwindow_bottom;i++) { - EditLineUp(l,sc); - l->y=l->cur_entry->y; - } - cl=l->cur_entry; - if (cl==l) - l->recalc_start=cl; - else - l->recalc_start=cl->last; - } else if (sc2==SC_CURSOR_LEFT) - EditCursorLeft(l,sc); - else if (sc2==SC_CURSOR_RIGHT) - EditCursorRight(l,sc); - else if (sc2==SC_DELETE) { - if ((sc & SCF_SHIFT)) - EditCutToClipboard(l); - else - EditDelChar(l); - } else if (ch==CH_BACKSPACE) { - if (l->cur_data_col<=l->cur_entry->min_col) { - l->cur_entry=l->cur_entry->last; - if (l->cur_entry!=l && l->cur_entry->btype==LTFT_SOFT_CR) - l->cur_entry=l->cur_entry->last; - if (l->cur_entry==l || - (l->cur_entry->btype==LTFT_USER_FOREGROUND || - l->cur_entry->btype==LTFT_USER_BACKGROUND)) { - l->cur_entry=l->cur_entry->next; - l->cur_data_col=l->cur_entry->min_col; - } else { - l->cur_data_col=l->cur_entry->max_col; - if (l->cur_data_col>l->cur_entry->min_col) - l->cur_data_col--; - EditDelChar(l); - } - } else { - l->cur_data_col--; - EditDelChar(l); - } - } else if (ch==25) //ctrl Y - EditDelLine(l); - else if (ch==12) //ctrl L - EditInsertDollarCmd; - else if (ch==20) - TogglePlainTextMode(l); - else if (sc2==SC_INSERT) { - if ((sc & SCF_SHIFT)) - EditInsertLtf(l,sys_clipboard_ltf); - else if (sc & SCF_CTRL) - EditCopyToClipboard(l); - else - l->flags^=LTFF_OVERSTRIKE; - } else if (ch==6) { //CTRL F - if ((sc & SCF_SHIFT)) - DoFavorites; - else - EditReplace(l); - } else if (ch==18) { //CTRL R - if (cl->btype==LTFT_PICTURE) - EditExistingGraphic(l, - ((x-l->line_start_col)>>2+cl->max_col)*FONT_WIDTH, - (y-l->cur_top_line_num)*FONT_HEIGHT); - else - EditInsertGraphic(l, - (x-l->line_start_col)>>2*FONT_WIDTH, - (y-l->cur_top_line_num)*FONT_HEIGHT); - } else if (sc2==SC_F2 && !(sc & SCF_CTRL) && !(sc & SCF_ALT)) { - if ((sc & SCF_SHIFT)) - EditInsertCapturedMacro; - else - EditMacroUtil; - } else if (sc2==SC_F9 && !(sc & SCF_CTRL) && !(sc & SCF_ALT)) { - if ((sc & SCF_SHIFT)) - ClearAllBpts(l); - else - ToggleBpt(l); - } else if (sc2==SC_F5 && !(sc & SCF_CTRL) && !(sc & SCF_ALT)) { - if ((sc & SCF_SHIFT)) - LtfStep(l); - else - LtfGo; - } else if (sc2==SC_F3 && !(sc & SCF_CTRL) && !(sc & SCF_ALT)) { - l->find_replace->scan_forward=!(sc & SCF_SHIFT); - EditFindNext(l); - } else if (sc2==SC_F4 && !(sc & SCF_CTRL) && !(sc & SCF_ALT)) { - if ((sc & SCF_SHIFT)) - st=PopUpPickDir; - else - st=PopUpPickFile; - if (st) { - PrintF("\"%s\"",st); - Free(st); - } - } else if (ch==7) //CTRL G - EditGoToLine(l); - else if (ch==19) // CTRL S - LtfWrite(l); - else if (ch==1) //CTRL A - LtfWrite(l,TRUE); - else if (ch==14) { //CTRL N - if ((sc & SCF_SHIFT)) - PrintF("$$ID,-2$$"); - else - PrintF("$$ID,2$$"); - } else if (ch==23) { //CTRL W - if ((sc & SCF_SHIFT)) - PrintF("$$WW 0$$"); - else - PrintF("$$WW 1$$"); - } else if (ch==2) { //CTRL B - if ((sc & SCF_SHIFT)) - PrintF("$$BK 0$$"); - else - PrintF("$$BK 1$$"); - } else if (ch==21) { //CTRL U - if ((sc & SCF_SHIFT)) - PrintF("$$UL 0$$"); - else - PrintF("$$UL 1$$"); - } else if (ch==26) { //CTRL Z - if ((sc & SCF_SHIFT)) - PrintF("$$IV 0$$"); - else - PrintF("$$IV 1$$"); - } else if (ch==16) { //CTRL P - if ((sc & SCF_SHIFT)) - PrintF("$$SY 0$$"); - else if ((sc & SCF_ALT)) - PrintF("$$SY 3$$"); - else - PrintF("$$SY,-3$$"); - } else if (sc2==SC_PRTSCRN2) - Lpt1PrintLtf(l); - - if (!l->recalc_start) - l->recalc_start=l->cur_entry->last; - } - Preempt(old_preempt2); - - SwapInNext; - return ms; -} - -public void LtfPutSPartial(Ltf *l,I1 *st) -{ - U1 ch; - I1 *b,*src,*dst,*ptr=st,*ptr2; - BoolU4 old_preempt=Preempt(OFF); - LtfEntry *cl,*nl; - I8 i,j; - if (!st) { - Preempt(old_preempt); - return; - } - while (ch=*ptr) { - if (!Bt(displayable_chars_bitmap,ch) || ch=='$$' || - l->flags & (LTFF_OVERSTRIKE | LTFF_IN_DOLLAR)) { - LtfPutChar(l,ch,0,old_preempt); - ptr++; - } else { - ptr2=ptr++; - while (TRUE) { - ch=*ptr++; - if (!Bt(displayable_chars_bitmap,ch) || ch=='$$') - break; - } - ptr--; - *ptr=0; - cl=l->cur_entry; - l->recalc_start=cl->last; - j=StrLen(ptr2); - if (cl->btype==LTFT_TEXT) { - b=MAlloc(cl->max_col+j+1,l->mem_tss); - dst=b; - src=cl->display; - i=l->cur_data_col; - l->cur_data_col=i+j; - cl->max_col+=j; - while (i-->0) - *dst++=*src++; - while (j-->0) - *dst++=*ptr2++; - while (*dst++=*src++); - Free(cl->display,l->mem_tss); - cl->display=b; - } else { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT | l->text_attribute << 8; - nl->display=NewString(ptr2,l->mem_tss); - nl->x=cl->x; - nl->y=cl->y; - nl->max_col=StrLen(ptr2); - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - InsQue(nl,cl->last); - l->cur_entry=nl; - l->cur_data_col=StrLen(ptr2); - } - *ptr=ch; - LtfRemoveSoftCRs(l,l->cur_entry); - } - SwapInNext; - } - Preempt(old_preempt); - -} - -public void LtfEditFile(I8 type,I1 *filename, - I1 *pattern=NULL,I8 num=1) -{ - I1 *ptr; - I8 i,j,flags=0; - LtfEntry *ll; - Ltf *l,*m; - - if (type==LK_PLAIN) { - type=LK_FILE; - flags=LTFF_PLAIN_TEXT; - } else if (type==LK_PLAIN_FIND) { - type=LK_FILE_FIND; - flags=LTFF_PLAIN_TEXT; - } else if (type==LK_PLAIN_LINE) { - type=LK_FILE_LINE; - flags=LTFF_PLAIN_TEXT; - } - if (!*filename) - l=Fs->cur_ltf; - else { - l=LtfRead(filename,flags); - l->flags|=LTFF_ATTR_BY_FILENAME; - m=LtfRead(EDIT_MENU_NAME); - m->text_attribute=(WHITE<<4)+LTBLUE; - l->menu_ltf=m; - } - if (type==LK_FILE) { - if (l->y) - LtfCenter(l); - } else if (type==LK_FILE_LINE) { - l->y=num-1; - l->x=0; - LtfUpdateWindowJoin(l,FALSE,FALSE,FALSE,TRUE); - LtfCenter(l); - } else if (type==LK_FILE_ANCHOR) { - if (ll=LtfFindAnchor(l,pattern)) - LtfCenter(l); - } else if (type==LK_FILE_FIND) { - i=num; - ll=l->dummy.next; - while (ll!=l) { - if (Bt(ltf_display_types,ll->btype)) { - if (ptr=StrIStr(ll->display,pattern)) { - j=ptr-ll->display; - i--; - if (i==0) { - l->cur_entry=ll; - if (jmin_col) j=ll->min_col; - if (j>ll->max_col) j=ll->max_col; - l->cur_data_col=j; - LtfCenter(l); - break; - } - } - } - ll=ll->next; - } - } - if (DoLtf(l,FALSE)) - LtfWrite(l); - if (Fs->cur_ltf!=l) - LtfDel(l); -} - -public void Edit(I1 *filename) -{ - I1 *buf=NewString(filename), - *buf2=NewString(filename); - U8 num=1; - I1 *temp_filename=NewString(filename), - *tfn_ptr=temp_filename; - SysHashEntry *temph; - Ltf *cur; - I8 i; - - i=LK_FILE; - StrCpy(temp_filename,filename); - if (StrLen(filename)>3 && filename[2]==':') { - buf[2]=0; - i=MatchSysTextEntry(buf,"ST_LINK_TYPES",MLE_IGNORE_CASE); - tfn_ptr=temp_filename+3; - if (i==LK_MAN_PAGE) { - temph=FindLocalHash(tfn_ptr, - HTT_GLBL_VAR|HTT_CLASS|HTT_FUNCTION| - HTT_STRING_CONSTANT|HTT_SYS_SYMBOL); - if (temph) - Edit(temph->source_link); - Free(temp_filename); - Free(buf); - Free(buf2); - return; - } - if (i==LK_FILE_LINE||i==LK_PLAIN_LINE) { - if (Occurrences(tfn_ptr,',')) { - RemoveLastSeg(tfn_ptr,",",buf); - num=AtoI(buf); - } - } else if (i==LK_FILE_ANCHOR) { - *buf=0; - if (Occurrences(tfn_ptr,',')) - RemoveLastSeg(tfn_ptr,",",buf); - } else if (i==LK_FILE_FIND||i==LK_PLAIN_FIND) { - *buf=0; - *buf2=0; - if (Occurrences(tfn_ptr,',')) - RemoveLastSeg(tfn_ptr,",",buf); - if (Occurrences(buf,':')) { - RemoveLastSeg(buf,":",buf2); - num=AtoI(buf2); - } - } - } - tfn_ptr=NewString(tfn_ptr); - LtfEditFile(i,tfn_ptr,buf,num); - ClearWindowText; - CursorHome; - Free(tfn_ptr); - Free(temp_filename); - Free(buf); - Free(buf2); -} - -public void Plain(I1 *filename) -{ - I1 *buf=MSPrintF("PI:%s",filename); - Edit(buf); - Free(buf); -} - -public void UseConsoleLtf(I1 *menu_file) -{ - BoolU4 old_preempt; - LtfEntry *ll; - Ltf *l=LtfNew,*m,*aux=LtfNew; - l->max_entries=4096; - l->flags|=LTFF_ATTR_BY_PARTITION; - - LtfPutS(aux,"$$CM+BY+RX,-6,1$$"); - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditOverStrikeCB; - LtfPutS(aux,"$$CM+BY+RX,-5,1$$"); //gets merged without this - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditDollarCB; - LtfPutS(aux,"$$CM+BY+RX,-4,1$$"); //gets merged without this - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditQuotesCB; - LtfPutS(aux,"$$CM+BY+RX,-3,1$$"); //gets merged without this - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditBracesCB; - LtfPutS(aux,"$$CM+BY+RX,-2,1$$"); //gets merged without this - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditSemicolonCB; - LtfPutS(aux,"$$CM+BY+RX,-10,1$$"); - ll=LtfPutS(aux,"$$TX+BD+DC+RD,\" \"$$"); - ll->display_cb=&EditDollarTypeCB; - aux->user_data=l; - - LtfPutS(aux,"$$CM+TY,0,-1$$"); - ll=LtfPutS(aux,"$$DA-T-P+BD+RD+CX+SCX+IV,140,\"%s...\",16$$"); - ll->data=&Fs->task_descriptor; - LtfFormatData(ll); - LtfPrintF(aux,"$$CM,1,0$$$$TX+BD+IV,\"%X\"$$",Fs); - aux->text_attribute=Fs->border_attribute; - if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WINDOW)) - LtfPutS(aux,"$$TX+RX+BD,\"[X]\"$$"); - if (menu_file) { - LtfPutS(aux,"$$TX+LX+BD,\"MENU\"$$"); - m=LtfRead(menu_file); - m->flags|=LTFF_ATTR_BY_PARTITION; - l->menu_ltf=m; - Bts(&Fs->crt_flags,CRTf_HAS_MENU); - } - - old_preempt=Preempt(OFF); - Fs->update_window=&LtfUpdateCurLtfWindow; - Fs->cur_ltf=l; - Fs->aux_ltf=aux; - Fs->scroll_speed=7; - Preempt(old_preempt); -} - -public I1 *LtfGetLine(Ltf *l,LtfEntry *cl,I8 *cur_col=NULL) -{ - LtfEntry *cl2=cl; - BoolU4 old_preempt=Preempt(OFF); - I1 *result,*dst,*src,*start; - U8 i=0; - if (*cur_col) - *cur_col=-1; - while (cl2!=l && cl2->btype!=LTFT_CR) { - if (Bt(ltf_display_types,cl2->btype)) - i+=StrLen(cl2->display); - else if (cl2->btype==LTFT_TAB) - i++; - cl2=cl2->next; - } - result=MAlloc(i+1); - dst=result; - while (cl!=l && cl->btype!=LTFT_CR) { - start=dst; - if (Bt(ltf_display_types,cl->btype)) { - src=cl->display; - while (*src) - *dst++=*src++; - } else if (cl->btype==LTFT_TAB) - *dst++=9; - if (cl==l->cur_entry && cur_col) - *cur_col=start-result+l->cur_data_col; - cl=cl->next; - } - *dst++=0; - if (cl==l->cur_entry && cur_col && !l->cur_data_col) - *cur_col=dst-1-result; - Preempt(old_preempt); - return result; -} - -public BoolU4 View() -{ - I8 ch=0; - U8 sc=0; - Ltf *l=Fs->cur_ltf; - U8 my_LtfPutChar(LTChnl *chnl,I8 ch,U8 sc); - while (ch!=CH_ESC && ch!=CH_CTRLQ) { - ch=GetChar2(&sc); - LtfPutChar(l,ch,sc,Bt(&sys_flags,SYSf_PREEMPTIVE)); - if (Fs->rmt_chnl) { - my_LtfPutChar=ext[EXT_RMT_LTFPUTCHAR]; - my_LtfPutChar(Fs->rmt_chnl,ch,sc); - } - LtfRecalc(l); - } - return ch==CH_ESC; -} - - -public LtfEntry *LtfPutLine(LtfEntry *cl) -{ - while (cl->btype!=LTFT_ERROR && cl->btype!=LTFT_CR) { - if (Bt(ltf_display_types,cl->btype)) - PutS(cl->display); - else if (cl->btype==LTFT_TAB) - PutChar(CH_TAB); - cl=cl->next; - } - CrLf; - return (cl->btype==LTFT_ERROR) ? cl:cl->next; -} - -I1 *SysGetS() -{ - Ltf *l=Fs->cur_ltf; - LtfEntry *cl; - BoolU4 old_preempt; - I1 *result; - U8 ch,sc; - U8 my_LtfPutChar(LTChnl *chnl,I8 ch,U8 sc); - old_preempt=Preempt(OFF); - PutS("$$FU$$$$BU$$"); - do { - Preempt(old_preempt); - ch=GetChar2(&sc); - Preempt(OFF); - cl=l->cur_entry; - if (ch==CH_ESC) { - LtfBottom(l); - LtfRunLine(l,cl,TRUE,old_preempt); - } if (ch==CH_CTRLQ) - Exit; - else { - LtfPutChar(l,ch,sc,old_preempt); - if (Fs->rmt_chnl) { - my_LtfPutChar=ext[EXT_RMT_LTFPUTCHAR]; - my_LtfPutChar(Fs->rmt_chnl,ch,sc); - } - LtfRecalc(l); - } -//Ctrl shift is a blank line without entry - } while (ch!=CH_CR || sc & SCF_CTRL && (sc & SCF_SHIFT)); - - cl=l->cur_entry; - do cl=cl->last; - while (cl!=l && cl->btype!=LTFT_CR && - cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND); - - - do cl=cl->last; - while (cl!=l && cl->btype!=LTFT_CR && - cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND); - - cl=cl->next; - result=LtfGetLine(l,cl,NULL); - PutS("$$FU$$$$FG$$$$BG$$"); - Preempt(old_preempt); - return result; -} - -I1 *SysPrompt(BoolU4 double_semicolon=FALSE) -{ - I8 i; - I1 *s,*result; - - for (i=Fs->answers_displayed;i>0;i--) { - if (Fs->answers_types[i-1]==IT_DOUBLE) - PrintF("ansd%d=%15.7g=%15e\r\n",i-1, - Fs->double_answers[i-1],Fs->double_answers[i-1]); - else - PrintF("ans%d=0x%016X=%d\r\n",i-1, - Fs->answers[i-1],Fs->answers[i-1]); - } - PrintFDriveTextAttr(PartitionToDrive); - s=CurDir; - PutS(s); - Free(s); - PutChar('>'); - s=SysGetS; - if (double_semicolon) { - i=StrLen(s); - result=MAlloc(i+4); - MemCpy(result,s,i+1); - i--; - while (i>=0 && (result[i]==CH_SPACE || result[i]==CH_SHIFT_SPACE || result[i]==CH_TAB)) - i--; - i++; - if (i>0 && result[i-1]==';') - result[i++]=';'; //The Lex goes one beyond - result[i++]=13;//#define goes to - result[i++]=10; - result[i]=0; - } else - result=NewString(s); - Free(s); - return result; -} - -public I8 PmtI8(I1 *msg,I8 default,I8 lo=MIN_I8,I8 hi=MAX_I8) -{ - I8 result; - I1 *st; - while (TRUE) { - PrintF(msg,default); - st=SysGetS; - if (!*st) { - Free(st); - return default; - } - result=AtoI(st); - Free(st); - if (result>=lo && result<=hi) - return result; - } -} - -public double PmtDouble(I1 *msg,double default,double lo=MIN_double,double hi=MAX_double) -{ - double result; - I1 *st; - while (TRUE) { - PrintF(msg,default); - st=SysGetS; - if (!*st) { - Free(st); - return default; - } - result=A2Double(st); - Free(st); - if (result>=lo && result<=hi) - return result; - } -} - -public I1 *PmtStr(I1 *msg,I1 *default) -{ - I1 *st; - PrintF(msg,default); - st=SysGetS; - if (!*st) { - Free(st); - return NewString(default); - } - return st; -} - -public LTDate PmtLTDate(I1 *msg,LTDate default,LTDate lo=MIN_I8,LTDate hi=MAX_I8) -{ - LTDate result; - I1 *st; - while (TRUE) { - PrintF(msg,default.date,default.time); - st=SysGetS; - if (!*st) { - Free(st); - return default; - } - result=A2LTDate(st); - Free(st); - if (result>=lo && result<=hi) - return result; - } -} - -I8 PopUpCancelIncludeDelAuto(I1 *header=NULL,I1 *footer=NULL) -{ - I8 i; - Ltf *l=LtfNew; - if (header) LtfPutS(l,header); - LtfPutS(l,"$$CM +LX,2,4 $$$$BT, \"INCLUDE\" 1$$"); - LtfPutS(l,"$$CM +LX,18,0$$$$BT, \"DELETE\" 2$$"); - LtfPutS(l,"$$CM +LX,2,3 $$$$BT, \"AUTOFILE\" 3$$"); - LtfPutS(l,"$$CM +LX,18,0$$$$BT, \"COMPILE\" 5$$"); - LtfPutS(l,"$$CM +LX,2,3 $$$$BT, \"ADAM_INCLUDE\" 4$$"); - LtfPutS(l,"$$CM +LX,18,0$$$$BT, \"CANCEL\" 0$$"); - LtfPutS(l,"$$CM +LX,2,3 $$$$BT, \"LOAD\" 6$$"); - if (footer) LtfPutS(l,footer); - i=PopUpMenu(l); - LtfDel(l); - return i; -} - -void LeftClickLink(Ltf *l,LtfEntry *cl,U2 old_preempt2) -{ - BoolU4 old_preempt=Bt(&sys_flags,SYSf_PREEMPTIVE); - I1 *st; - l;//ref to prevent warning - if (cl->flags & LTFLF_AUX_STRING) - st=NewString(cl->aux_string); - else - st=NewString(cl->display); - Preempt(old_preempt2); - Edit(st); - Preempt(old_preempt); - Free(st); -} - -void LeftDoubleClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2) -{ //TODO come-up with new uses. - l;cl;old_preempt2;//ref to prevent warning -} - -void RightClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2) -{ - BoolU4 send_cr=FALSE,old_preempt=Bt(&sys_flags,SYSf_PREEMPTIVE); - I1 *st2,*st; - I8 i; - if (cl->flags & LTFLF_AUX_STRING) - st2=NewString(cl->aux_string); - else - st2=NewString(cl->display); - st=(st2[2]==':') ? st2+3:st2; - i=PopUpCancelIncludeDelAuto(st); - Preempt(old_preempt2); - if (i>0) { - LtfBottom(l); - switch (i) { - case 1: - if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) { - if (!PopUpNoYes("WARNING: Not .CP? File\r\n" - "Proceed anyway?\r\n\r\n")) { - send_cr=TRUE; - break; - } - } - cout "#include \"",st,"\";\r\n$$FU$$$$FG$$$$BG$$"; - ExecuteFile(st); - break; - case 2: - Del(st); - break; - case 3: - if (Occurrences(st,'.') && !WildCardMatch("*.AU?",st)) { - if (!PopUpNoYes("WARNING: Not .AU? File\r\n" - "Proceed anyway?\r\n\r\n")) { - send_cr=TRUE; - break; - } - } - cout "AutoFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; - AutoString("%F\r",st); - break; - case 4: - if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) { - if (!PopUpNoYes("WARNING: Not .CP? File\r\n" - "Proceed anyway?\r\n\r\n")) { - send_cr=TRUE; - break; - } - } - cout "Adam(\"#include \\\"",st,"\\\"\" );\r\n$$FU$$$$FG$$$$BG$$"; - Adam(";#include \"%s\"",st); - break; - case 5: - if (Occurrences(st,'.') && !WildFileNameList("*.CP?;*.AS?",st)) { - if (!PopUpNoYes("WARNING: Not .CP? or .AS? File\r\n" - "Proceed anyway?\r\n\r\n")) { - send_cr=TRUE; - break; - } - } - cout "CompileFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; - CompileFile(st); - break; - case 6: - if (Occurrences(st,'.') && !WildCardMatch("*.BI?",st)) { - if (!PopUpNoYes("WARNING: Not .BI? File\r\n" - "Proceed anyway?\r\n\r\n")) { - send_cr=TRUE; - break; - } - } - cout "Load(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; - Load(st); - break; - } - } else - send_cr=TRUE; - LtfBottom(l); - cout "$$FU$$$$FG$$$$BG$$"; - if (send_cr) - PutChar(CH_CR); - Preempt(old_preempt); - Free(st2); -} - -void RightDoubleClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2) -{ //TODO come-up with new uses. - l;cl;old_preempt2;//ref to prevent warning -} - -public void Man(I1 *st) -{ - I1 *name=MAlloc(3+StrLen(st)+1); - StrCpy(name,"MN:"); - StrCat(name,st); - Edit(name); - Free(name); -} - -ext[EXT_LTF_PUT_I1]=&LtfPutChar; -ext[EXT_LTF_PUTS]=&LtfPutSPartial; -ext[EXT_LTF_READ]=&LtfRead; -ext[EXT_LTF_WRITE]=&LtfWrite; -ext[EXT_LTF_NEW]=&LtfNew; -ext[EXT_LTF_RESET]=&LtfReset; -ext[EXT_LTF_DEL]=&LtfDel; - - \ No newline at end of file diff --git a/LT/ADAM/GRELEM.CPZ b/LT/ADAM/GRELEM.CPZ deleted file mode 100644 index e31a734..0000000 --- a/LT/ADAM/GRELEM.CPZ +++ /dev/null @@ -1,834 +0,0 @@ -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;inum;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;inum;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;inum;i++) { - p[i].x+=x; - p[i].y+=y; - } - Gr2BSpline3(base,p,tempg->num,FALSE); - for (i=0;inum;i++) { - p[i].x-=x; - p[i].y-=y; - } - break; - case GRET_BSPLINE3: - p=&tempg->y1; - for (i=0;inum;i++) { - p[i].x+=x; - p[i].y+=y; - } - Gr3BSpline3(base,p,tempg->num,FALSE); - for (i=0;inum;i++) { - p[i].x-=x; - p[i].y-=y; - } - break; - case GRET_BSPLINE2_CLOSED: - p=&tempg->y1; - for (i=0;inum;i++) { - p[i].x+=x; - p[i].y+=y; - } - Gr2BSpline3(base,p,tempg->num,TRUE); - for (i=0;inum;i++) { - p[i].x-=x; - p[i].y-=y; - } - break; - case GRET_BSPLINE3_CLOSED: - p=&tempg->y1; - for (i=0;inum;i++) { - p[i].x+=x; - p[i].y+=y; - } - Gr3BSpline3(base,p,tempg->num,TRUE); - for (i=0;inum;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;inum;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;inum;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<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<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<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;inext; - 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<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;inext; - 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<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;inext; - 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<cur_sub_GrElem; - l->cur_GrElem=NULL; - break; - case GED_SET_ORIGIN: - GetMsg(&p1,&p2,1<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<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); -} diff --git a/LT/ADAM/GRMODE2.ASZ b/LT/ADAM/GRMODE2.ASZ deleted file mode 100644 index f409f15..0000000 --- a/LT/ADAM/GRMODE2.ASZ +++ /dev/null @@ -1,425 +0,0 @@ - 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=ady) - d=(adx>=adz) ? adx:adz; - else - d=(ady>=adz) ? ady:adz; - if (d) { - dx=DivI8(dx<<32,d); - dy=DivI8(dy<<32,d); - dz=DivI8(dz<<32,d); - } - x1<<=32; y1<<=32; z1<<=32; - for (j=0;j>32; - y1=(MulI8(r[3],*x)+MulI8(r[4],*y)+MulI8(r[5],*z))>>32; - z1=(MulI8(r[6],*x)+MulI8(r[7],*y)+MulI8(r[8],*z))>>32; - *x=x1;*y=y1;*z=z1; -} - -public void GrTransform(GrBitMap *base,I8 *x,I8 *y,I8 *z) -{ - GrRotate(base->r,x,y,z); - *x+=base->x; - *y+=base->y; - *z+=base->z; -} - - -public I8 *GrTheta(double theta) -{ - double my_cos,my_sin; - I8 *r=MAllocZ(sizeof(I8)*9); - - my_cos=Cos(theta)*GrScale; - my_sin=Sin(theta)*GrScale; - r[0]=my_cos; - r[4]=my_cos; - r[3]=my_sin; - r[1]=-my_sin; - r[8]=GrScale; - return r; -} - -public I8 *GrPhi(double phi) -{ - double my_cos,my_sin; - I8 *r=MAllocZ(sizeof(I8)*9); - - my_cos=Cos(phi)*GrScale; - my_sin=Sin(phi)*GrScale; - r[4]=my_cos; - r[8]=my_cos; - r[7]=my_sin; - r[5]=-my_sin; - r[0]=GrScale; - return r; -} - -public I4 *GrScaleMat(I8 *m1,double s) -{ - I8 i,*r=MAllocZ(sizeof(I8)*9); - for (i=0;i<9;i++) - r[i]=m1[i]*s; - return r; -} - -public I4 *GrMulMat(I8 *m1,I8 *m2) -{ //TODO convert to I4 arith - I8 *r=MAllocZ(sizeof(I8)*9); - I8 i,j,k; - double d; - for (i=0;i<3;i++) { - for (j=0;j<3;j++) { - for (k=0;k<3;k++) { - d=m1[k+3*j]; - d*=m2[i+3*k]; - d/=GrScale; - r[i+3*j]+=d; - } - } - } - return r; -} - -void GrSetIdent(I8 *r) -{ - MemSet(r,0,9<<3); - r[0].u4[1]=1; - r[4].u4[1]=1; - r[8].u4[1]=1; -} - - -public void Circle(U1 *aux_data, - I8 cx,I8 cy,I8 cz, - I8 radius, - U1 *plot_cb(U1 *aux,I8 x,I8 y,I8 z), - I8 step=1, - double start_rad=0, - double len_rad=pi2) -{ - I8 i,j,len=len_rad*radius; - I8 x,y,x1,y1,s1,s2,c; - double t; - if (radius<0) return; - if (!radius) { - plot_cb(aux_data,cx,cy,cz); - return; - } - t=1.0/radius; - s1=(1<<24)*Sin(t); - s2=-s1; - c=(1<<24)*Cos(t); - if (start_rad) { - x=radius*Cos(start_rad); - y=-radius*Sin(start_rad); - } else { - x=radius; - y=0; - } - x<<=8; - y<<=8; - for (i=0;i<=len;i+=step) { - plot_cb(aux_data,cx+x>>8,cy+y>>8,cz); - for (j=0;j>24; - y1=(MulI8(s2,x)+MulI8(c,y))>>24; - x=x1; y=y1; - } - } -} - -I8 DistP3I4(P3I4 *p1,P3I4 *p2) -{ - return Sqrt(SqrI8(p1->x-p2->x)+SqrI8(p1->y-p2->y)+SqrI8(p1->z-p2->z)); -} - -void Bezier2(U1 *aux_data,P3I4 *ctrl,U1 *plot_cb(U1 *aux,I8 x,I8 y,I8 z)) -{//2nd order - I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max; - double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z; - double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0; - double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0; - double t,d=DistP3I4(&ctrl[0],&ctrl[1])+ - DistP3I4(&ctrl[1],&ctrl[2])+ - DistP3I4(&ctrl[2],&ctrl[0]), - s=1.0/d,t1,t2; - xx=x0; yy=y0; zz=z0; - for (t=0.0;t<=1.0;t+=s) { - t1=t*(1.0-t); - t2=t*t; - x=x0+x1*t1+x2*t2; - y=y0+y1*t1+y2*t2; - z=z0+z1*t1+z2*t2; - dx=AbsI8(x-xx); - dy=AbsI8(y-yy); - dz=AbsI8(z-zz); - if (dx>dy) - d_max=dx; - else - d_max=dy; - if (dz>d_max) - d_max=dz; - if (!d_max) - s*=1.1; - else { - s*=0.9; - plot_cb(aux_data,x,y,z); - xx=x;yy=y;zz=z; - } - } -} - -void Bezier3(U1 *aux_data,P3I4 *ctrl,U1 *plot_cb(U1 *aux,I8 x,I8 y,I8 z)) -{ //3rd order - I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max; - double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z; - double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0; - double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0; - double x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0; - double t,d=DistP3I4(&ctrl[0],&ctrl[1])+ - DistP3I4(&ctrl[1],&ctrl[2])+ - DistP3I4(&ctrl[2],&ctrl[3])+ - DistP3I4(&ctrl[3],&ctrl[0]), - s=1.0/d,nt,t1,t2,t3; - xx=x0; yy=y0; zz=z0; - for (t=0.0;t<=1.0;t+=s) { - nt=1.0-t; - t1=t*nt*nt; - t2=t*t*nt; - t3=t*t*t; - x=x0+x1*t1+x2*t2+x3*t3; - y=y0+y1*t1+y2*t2+y3*t3; - z=z0+z1*t1+z2*t2+z3*t3; - dx=AbsI8(x-xx); - dy=AbsI8(y-yy); - dz=AbsI8(z-zz); - if (dx>dy) - d_max=dx; - else - d_max=dy; - if (dz>d_max) - d_max=dz; - if (!d_max) - s*=1.1; - else { - s*=0.9; - plot_cb(aux_data,x,y,z); - xx=x;yy=y;zz=z; - } - } -} - -void BSpline2(U1 *aux_data,P3I4 *ctrl,I8 cnt,U1 *plot_cb(U1 *aux,I8 x,I8 y,I8 z),BoolU4 closed=FALSE) -{ //2nd order - I8 i,j; - P3I4 *c; - if (cnt<3) return; - if (closed) { - cnt++; - c=MAlloc(sizeof(P3I4)*(cnt*2-1)); - j=1; - for (i=0;icolor=GR_BLACK; - base->pen_width=1; -} - -GrBitMap *GrNew(GrBitMap *base) -{ - GrBitMap *result=MAlloc(sizeof(GrBitMap)); - MemCpy(result,base,sizeof(GrBitMap)); - result->r=MAlloc(9<<1<<2); - GrSetIdent(result->r); - GrReset(result); - result->flags|=BMF_ALIAS; - return result; -} - - -void GrDel(GrBitMap *base) -{ - Free(base->r); - if (!(base->flags & BMF_ALIAS)) - Free(base->body); - Free(base); -} - - -I4 gr_table[1024]; -BoolU4 gr_table_initialized=FALSE; - -#define GR_NUM_PEN_BRUSHES 64 -GrBitMap *gr_pen_brushes[GR_NUM_PEN_BRUSHES]; - -void GrSetupTable(GrBitMap *hidden) -{ - GrBitMap *b; - I8 i,j,k; - for (i=-16;i<16;i++) { - for (j=-16;j<16;j++) { - k=((i>=0) ? i:32+i)<<5+((j>=0) ? j:32+j); - gr_table[k]=(MulI8(i,hidden->internal_width)+j)>>3; - } - } - for (i=0;i<(256*FONT_HEIGHT*FONT_WIDTH)>>3;i++) - grfont[i]=reverse_bits_table[grfont[i]]; - - for (i=0;i>3)<<3; - if (!j) - b=GrBitMapNew(BMT_MONO,8,1); - else - b=GrBitMapNew(BMT_MONO,j,i); - gr_pen_brushes[i]=b; - b->color=GR_WHITE; - if (i<2) - GrPlot0(b,0,0); - else { - GrPlot0(b,i>>1,i>>1); - for (j=1;j<=i;j+=2) - GrCircle(b,i>>1+1,i>>1,j>>1); - for (j=1;j<=i;j+=2) - GrCircle(b,i>>1,i>>1+1,j>>1); - for (j=2;j<=i;j+=2) - GrCircle(b,i>>1,i>>1,j>>1); - } - } - - OutP(VGA_SC_INDEX,VGA_MAP_MASK); - OutP(VGA_SC_DATA,0x0F); - MemSet(0xA0000,0,grheight*grwidth>>3); - MemSet(vga_image,0,grwidth*grheight>>1); - - gr_table_initialized=TRUE; -} - -////**************************PROCEDURE************************* -// Format of U4 text entry -// Bits 0-7 ASCII -// Bits 8-11 Foreground color -// Bits 12-15 Background color -// Bits 16-20 Signed X position shift value -// Bits 21-25 Signed Y position shift value -// Bit 28 Blink -// Bit 29 Inverted (Swap foreground and background) -// Bit 30 Selected (XOR colors with FF) -// Bit 31 Underline - -void GrUpdateScreen(GrBitMap *b1,GrBitMap *b2, - U4 *my_textbase) -{ - U4 *src,*src2,cur_ch,u; -//U8 d; - U8 row,col,plane,ch_line,i, - d0=(b2->internal_width+1)<<2, - d1=(b2->internal_width)>>3, - d2=(b2->internal_width*b2->height-FONT_HEIGHT*b2->width)>>3, - d3=(b2->internal_width*b2->height<<2)>>3, - d4=(b2->internal_width*FONT_HEIGHT-b1->width)>>3, - d5=(b1->internal_width)>>5, - d6=(b2->internal_width)<<2, - num_cols=b1->width/FONT_WIDTH, - num_rows=b1->height/FONT_HEIGHT; - BoolU4 old_preempt; - U2 *dst2; - U4 *dst3,*dst4=vga_image; - BoolU4 GrBlinkFlag=(jiffies/(JIFFY_FREQ/5))&1; - U1 *dst,*font_ptr,*font_ptr2,saved_font_line; - - if (!gr_table_initialized) GrSetupTable(b2); - -//Update Text Background - src=my_textbase; - dst=b2->body+d0; - for (row=0;row>4); - if (cur_ch & LTFLT_BLINK) - if (GrBlinkFlag) - cur_ch.u1[1]=(cur_ch.u1[1]<<4)+(cur_ch.u1[1]>>4); - 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_linebody+d0; - for (row=0;row>4); - if (cur_ch & LTFLT_BLINK) - if (GrBlinkFlag) - cur_ch.u1[1]=(cur_ch.u1[1]<<4)+(cur_ch.u1[1]>>4); - font_ptr=&grfont[FONT_WIDTH*FONT_HEIGHT>>3*cur_ch.u1[0]]; - if (cur_ch & LTFLT_UNDERLINED) { - saved_font_line=font_ptr[7]; - font_ptr[7]=0xFF; - } - i=cur_ch.u2[1]&0x3FF; - dst2=dst+gr_table[i]; - if (i) { - i&=7; - for (plane=0x01;plane!=0x10;plane<<=1) { - font_ptr2=font_ptr; - if (cur_ch.u1[1] & plane) { - for (ch_line=0;ch_linebody; - src2=b2->body; - for (plane=1;plane<0x10;plane<<=1) { - OutP(VGA_SC_INDEX,VGA_MAP_MASK); - OutP(VGA_SC_DATA,plane); - dst3=0xA0000; - src2+=d6; - for (row=0;rowheight;row++) { - src2+=32>>3; - GrXorLine(&dst3,&src,&src2,d5,&dst4); -/* - for (col=0;col>3; - } - src2+=d6; - } - Preempt(old_preempt); - - if (gr_screen_capture) { - MemCpy(gr_screen_capture,vga_image,grheight*grwidth>>1); - gr_screen_capture=NULL; - } -} - -public void GrPlot0(GrBitMap *base,I8 x,I8 y) -{ //No clipping or transformation or pen width - U8 d,c; - U1 *dst,bit,not_bit; - U8 color=base->color; - double dist; - - if (base->flags & BMF_LOCATE_NEAREST) { - dist=DistI8(x,y,base->cur_x,base->cur_y); - if (distnearest_dist) { - base->nearest_sub_GrElem=base->cur_sub_GrElem; - base->nearest_dist=dist; - } - } - if (base->flags & BMF_DONT_DRAW) - return; - switch (base->type) { - case BMT_COLOR4: - d=base->plane_size; - dst=base->body+(base->left_margin+ - (y+base->top_margin)*base->internal_width)>>3+(x>>3); - bit=1<<(x&7); - not_bit=~bit; - c=color.u1[0]; - switch (color.u1[3]) { - case ROPB_EQU: - case ROPB_TRANSPARENT: - if (c & 1) - *dst|=bit; - else - *dst&=not_bit; - dst+=d; - if (c & 2) - *dst|=bit; - else - *dst&=not_bit; - dst+=d; - if (c & 4) - *dst|=bit; - else - *dst&=not_bit; - dst+=d; - if (c & 8) - *dst|=bit; - else - *dst&=not_bit; - break; - case ROPB_XOR: - if (c & 1) *dst^=bit; - dst+=d; - if (c & 2) *dst^=bit; - dst+=d; - if (c & 4) *dst^=bit; - dst+=d; - if (c & 8) *dst^=bit; - break; - case ROPB_OR: - if (c & 1) *dst|=bit; - dst+=d; - if (c & 2) *dst|=bit; - dst+=d; - if (c & 4) *dst|=bit; - dst+=d; - if (c & 8) *dst|=bit; - break; - case ROPB_NAND: - if (c & 1) *dst&=not_bit; - dst+=d; - if (c & 2) *dst&=not_bit; - dst+=d; - if (c & 4) *dst&=not_bit; - dst+=d; - if (c & 8) *dst&=not_bit; - break; - } - break; - case BMT_MONO: - d=base->internal_width*y+x; - c=color.u1[0]; - switch (color.u1[3]) { - case ROPB_EQU: - case ROPB_TRANSPARENT: - AssignBit(base->body,d,c); - break; - case ROPB_XOR: - if (c) - Btc(base->body,d); - break; - case ROPB_OR: - if (c) - Bts(base->body,d); - break; - case ROPB_NAND: - if (c) - Btr(base->body,d); - break; - } - break; - } -} - - -public BoolU4 GrBlot(GrBitMap *base,I8 x,I8 y,GrBitMap *img) -{ //Clipping but not transformation - I8 i,i1,i2,i3,j,k,k1,w1,h1,w2,h2,plane,plane1,bit_mask,bit_shift,p; - U1 *ptr; - U2 *ptr1; - I8 color,color_byte,plane_size,plane_size1,plane_limit; - BoolU4 draw=TRUE,color_bit; - - w1= (x<0)?-x:0; - h1= (y<0)?-y:0; - w2=img->width; - h2=img->height; - - if (base->flags & BMF_SCREEN_BITMAP) { - x+=Fs->window_pixel_left; - if (x+w1<0) w1=-x; - if (x+w2>Fs->window_pixel_right) - w2=Fs->window_pixel_right-x; - - y+=Fs->window_pixel_top; - if (y+h1<0) h1=-y; - if (y+h2>Fs->window_pixel_bottom) - h2=Fs->window_pixel_bottom-y; - - if (IsPixelCovered(Fs,x+w1,y+h1)) - draw=FALSE; - else if (IsPixelCovered(Fs,x+w2,y+h2)) - draw=FALSE; - x+=base->left_margin; - y+=base->top_margin; - } - if (x+w2>base->width) - w2=base->width-x; - if (y+h2>base->height) - h2=base->height-y; - if (draw && w1width && h2<=img->height) { - if (base->flags & BMF_DONT_DRAW) - return TRUE; - color=base->color; - p=0; - plane_size=img->plane_size<<3; - plane_size1=base->plane_size<<3; - switch (base->type) { - case BMT_COLOR4: plane_limit=plane_size*4; break; - case BMT_MONO: plane_limit=plane_size; break; - } - i1=(-w1)&7; - if (i1>w2) i1=w2; - i2=(w2-w1-i1)>>3; - i3=w2-w1-i2<<3-i1; - bit_shift=(x+w1)&7; - bit_mask=-1-255<type) { - case BMT_COLOR4: - k=j*img->internal_width+w1+plane; - k1=(j+y)*base->internal_width+x+w1+plane1; - switch (color.u1[3]) { - case ROPB_EQU: - case ROPB_TRANSPARENT: - for (i=0;ibody,k1++,Bt(img->body,k++)); - break; - case ROPB_XOR: - for (i=0;ibody,k++)) - Btc(base->body,k1++); - break; - case ROPB_OR: - for (i=0;ibody,k++)) - Bts(base->body,k1++); - break; - case ROPB_NAND: - for (i=0;ibody,k++)) - Btr(base->body,k1++); - break; - } - ptr=k>>3+img->body; - ptr1=k1>>3+base->body; - switch (color.u1[3]) { - case ROPB_EQU: - case ROPB_TRANSPARENT: - for (i=0;ibody,k1++,Bt(img->body,k++)); - break; - case ROPB_XOR: - for (i=0;ibody,k++)) - Btc(base->body,k1++); - break; - case ROPB_OR: - for (i=0;ibody,k++)) - Bts(base->body,k1++); - break; - case ROPB_NAND: - for (i=0;ibody,k++)) - Btr(base->body,k1++); - break; - } - break; - case BMT_MONO: - k=j*img->internal_width+w1; - k1=(j+y)*base->internal_width+x+w1+plane1; - switch (color.u1[3]) { - case ROPB_EQU: - for (i=0;ibody,k1++,color_bit && Bt(img->body,k++)); - break; - case ROPB_TRANSPARENT: - for (i=0;ibody,k++)) - AssignBit(base->body,k1++,color_bit); - break; - case ROPB_XOR: - if (color_bit) - for (i=0;ibody,k++)) - Btc(base->body,k1++); - break; - case ROPB_OR: - if (color_bit) - for (i=0;ibody,k++)) - Bts(base->body,k1++); - break; - case ROPB_NAND: - if (color_bit) - for (i=0;ibody,k++)) - Btr(base->body,k1++); - break; - } - ptr=k>>3+img->body; - ptr1=k1>>3+base->body; - switch (color.u1[3]) { - case ROPB_EQU: - for (i=0;ibody,k1++,color_bit && Bt(img->body,k++)); - break; - case ROPB_TRANSPARENT: - for (i=0;ibody,k++)) - AssignBit(base->body,k1++,color_bit); - break; - case ROPB_XOR: - if (color_bit) - for (i=0;ibody,k++)) - Btc(base->body,k1++); - break; - case ROPB_OR: - if (color_bit) - for (i=0;ibody,k++)) - Bts(base->body,k1++); - break; - case ROPB_NAND: - if (color_bit) - for (i=0;ibody,k++)) - Btr(base->body,k1++); - break; - } - break; - } - } - } - return TRUE; - } - return FALSE; -} - -public void GrPlot(GrBitMap *base,I8 x,I8 y) -{ //Clipping but No transformation or pen width - BoolU4 draw=TRUE; - if (base->brush) { - GrBlot(base,x,y,base->brush); - return; - } - if (base->flags & BMF_SCREEN_BITMAP) { - if (x<0) draw=FALSE; - x+=Fs->window_pixel_left; - if (x>Fs->window_pixel_right) draw=FALSE; - - if (y<0) draw=FALSE; - y+=Fs->window_pixel_top; - if (y>Fs->window_pixel_bottom) draw=FALSE; - if (x>=base->width) draw=FALSE; - if (y>=base->height) draw=FALSE; - if (IsPixelCovered(Fs,x,y)) draw=FALSE; - } else { - if (x<0) draw=FALSE; - if (x>=base->width) draw=FALSE; - if (y<0) draw=FALSE; - if (y>=base->height) draw=FALSE; - } - if (draw) - GrPlot0(base,x,y); -} - - -public void GrPlot2(GrBitMap *base,I8 x,I8 y,I8 z) -{ //Clipping and transformation but no pen_width - if (base->flags & BMF_TRANSFORMATION) { - GrRotate(base->r,&x,&y,&z); - x+=base->x; - y+=base->y; - z+=base->z; - } - GrPlot(base,x,y); -} - -public void GrPlot3(GrBitMap *base,I8 x,I8 y,I8 z) -{ //clipping and transformation and pen width - - I8 i,j,w,old_color; - double dist; - if (base->flags & BMF_TRANSFORMATION) { - GrRotate(base->r,&x,&y,&z); - x+=base->x; - y+=base->y; - z+=base->z; - } - w=base->pen_width>>1; - if (w<=0) - GrPlot(base,x,y); - else if (base->pen_widthcolor; - if (base->color.u1[3]==ROPB_EQU) - base->color.u1[3]=ROPB_TRANSPARENT; - if (GrBlot(base,x-w,y-w,gr_pen_brushes[base->pen_width])) { - if (base->flags & BMF_SCREEN_BITMAP) { - x+=Fs->window_pixel_left; - y+=Fs->window_pixel_top; - } - if (base->flags & BMF_LOCATE_NEAREST) { - dist=DistI8(x,y,base->cur_x,base->cur_y); - if (distnearest_dist) { - base->nearest_sub_GrElem=base->cur_sub_GrElem; - base->nearest_dist=dist; - } - } - } - base->color=old_color; - } else if (base->pen_width & 1) { - for (i=-w;i<=w;i++) - for (j=-w;j<=w;j++) - GrPlot(base,x+i,y+j); - } else { - for (i=-w;iwindow_pixel_left; - if (x>Fs->window_pixel_right) draw=FALSE; - - if (y<0) draw=FALSE; - y+=Fs->window_pixel_top; - if (y>Fs->window_pixel_bottom) draw=FALSE; - - if (x>=base->width) draw=FALSE; - if (y>=base->height) draw=FALSE; - - if (draw) { - if (base->brush) - GrBlot(base,x,y,base->brush); - else - GrPlot0(base,x,y); - } -} - -void GrLinePlot(GrBitMap *base,I8 x,I8 y,I8 z) -{ - GrPlot(base,x,y); -} - -public void GrLine(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0) -{ - Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start); -} - -public void GrCircle(GrBitMap *base,I8 cx,I8 cy,I8 radius, - I8 step=1,double start_rad=0,double len_rad=pi2) -{ - Circle(base,cx,cy,0,radius,&GrLinePlot,step,start_rad,len_rad); -} - -public void Gr2Bezier(GrBitMap *base,P3I4 *ctrl) -{ - Bezier2(base,ctrl,&GrLinePlot); -} - -public void Gr3Bezier(GrBitMap *base,P3I4 *ctrl) -{ - Bezier3(base,ctrl,&GrLinePlot); -} - -public void Gr2BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) -{ - BSpline2(base,ctrl,cnt,&GrLinePlot,closed); -} - -public void Gr3BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) -{ - BSpline3(base,ctrl,cnt,&GrLinePlot,closed); -} - -public void GrLine2(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0) -{ //tarnsformation but not pen width - if (base->flags & BMF_TRANSFORMATION) { - GrRotate(base->r,&x1,&y1,&z1); - x1+=base->x; - y1+=base->y; - z1+=base->z; - } - if (base->flags & BMF_TRANSFORMATION) { - GrRotate(base->r,&x2,&y2,&z2); - x2+=base->x; - y2+=base->y; - z2+=base->z; - } - Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start); -} - -void GrLine3Plot(GrBitMap *base,I8 x,I8 y,I8 z) -{ - GrPlot3(base,x,y,z); -} - -public void GrLine3(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0) -{ //transformation with pen width - U8 old_flags=base->flags; - - if (base->flags & BMF_TRANSFORMATION) { - GrRotate(base->r,&x1,&y1,&z1); - x1+=base->x; - y1+=base->y; - z1+=base->z; - GrRotate(base->r,&x2,&y2,&z2); - x2+=base->x; - y2+=base->y; - z2+=base->z; - } - base->flags&=~BMF_TRANSFORMATION; - Line(base,x1,y1,z1,x2,y2,z2,&GrLine3Plot,step,start); - base->flags=old_flags; -} - -public void Gr2Bezier3(GrBitMap *base,P3I4 *ctrl) -{ - Bezier2(base,ctrl,&GrLine3Plot); -} - -public void Gr3Bezier3(GrBitMap *base,P3I4 *ctrl) -{ - Bezier3(base,ctrl,&GrLine3Plot); -} - -public void Gr2BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) -{ - BSpline2(base,ctrl,cnt,&GrLine3Plot,closed); -} - -public void Gr3BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) -{ - BSpline3(base,ctrl,cnt,&GrLine3Plot,closed); -} - - -void GrLinePlot4(GrBitMap *base,I8 x,I8 y,I8 z) -{ - GrPlot4(base,x,y); -} - -public void GrLine4(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0) -{ - Line(base,x1,y1,0,x2,y2,0,&GrLinePlot4,step,start); -} - - -void PlotScreenString(I1 *s,U8 attr,I8 x,I8 y) -{ - U1 ch; - attr<<=8; - while (ch=*s++) { - PlotScreenChar(ch+attr,x,y); - x+=4; - } -} - -void PlotWindowString(I1 *s,U8 attr,I8 x,I8 y) -{ - U1 ch; - attr<<=8; - while (ch=*s++) { - PlotWindowChar(ch+attr,x,y); - x+=4; - } -} - -void PlotBorderString(I1 *s,U8 attr,I8 x,I8 y) -{ - U1 ch; - attr<<=8; - while (ch=*s++) { - PlotBorderChar(ch+attr,x,y); - x+=4; - } -} - diff --git a/LT/ADAM/JOY.CPZ b/LT/ADAM/JOY.CPZ deleted file mode 100644 index 7c7f00e..0000000 --- a/LT/ADAM/JOY.CPZ +++ /dev/null @@ -1,136 +0,0 @@ -#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]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); - } -} diff --git a/LT/ADAM/LTF.CPZ b/LT/ADAM/LTF.CPZ deleted file mode 100644 index cab6e97..0000000 --- a/LT/ADAM/LTF.CPZ +++ /dev/null @@ -1,2240 +0,0 @@ -U8 ltf_display_types[1],ltf_nondisplay_invisible_types[1], - ltf_form_types[1],ltf_data_types[1]; - -ltf_display_types[0]=1<bin_root.next; - while (b!=&l->bin_root) { - if (b->num==num) - return b; - b=b->next; - } - return NULL; -} - -void LtfValidateBins(Ltf *l) -{ - LtfBinEntry *b=l->bin_root.next,*b1; - LtfEntry *cl=l->dummy.next; - while (b!=&l->bin_root) { - b->use_cnt=0; - b=b->next; - } - while (cl!=l) { - if (cl->flags & LTFLF_HAS_BIN) { - if (cl->bin_data) - cl->bin_data->use_cnt++; - else { - cl->bin_data=LtfFindBin(l,cl->bin_num); - if (cl->bin_data) - cl->bin_data->use_cnt++; - } - } - cl=cl->next; - } - b=l->bin_root.next; - l->cur_bin_num=1; - while (b!=&l->bin_root) { - b1=b->next; - if (!b->use_cnt) { - RemQue(b); - Free(b->data,l->mem_tss); - Free(b,l->mem_tss); - } else { - if (b->num>=l->cur_bin_num) - l->cur_bin_num=b->num+1; - } - b=b1; - } -} - - -void LtfDelBin(LtfBinEntry *b,TssStruct *tss) -{ - b->use_cnt--; - if (!b->use_cnt) { - RemQue(b); - Free(b->data,tss); - Free(b,tss); - } -} - -void LtfDelEntry(LtfEntry *cl,TssStruct *tss) -{ - if (Bt(ltf_display_types,cl->btype)) - Free(cl->display,tss); - if (cl->btype>=LTFT_DATA) - Free(cl->plain_text,tss); - if (cl->flags & LTFLF_LEFT_MACRO) - Free(cl->left_macro,tss); - if (cl->flags & LTFLF_RIGHT_MACRO) - Free(cl->right_macro,tss); - if (cl->flags & LTFLF_AUX_STRING) - Free(cl->aux_string,tss); - if (cl->flags & LTFLF_HAS_BIN) - LtfDelBin(cl->bin_data,tss); - Free(cl,tss); -} - - -LtfEntry *LtfCopyEntry(Ltf *l,LtfEntry *cl) -{ - LtfEntry *nl; - LtfBinEntry *tempb; - TssStruct *tss=l->mem_tss; - nl=MAllocIdentical(cl,tss); - if (Bt(ltf_display_types,cl->btype)) - nl->display=MAllocIdentical(cl->display,tss); - if (cl->btype>=LTFT_DATA) - nl->plain_text=NewString(cl->plain_text,tss); - if (cl->flags & LTFLF_AUX_STRING) - nl->aux_string=NewString(cl->aux_string,tss); - if (cl->flags & LTFLF_LEFT_MACRO) - nl->left_macro=MAllocIdentical(cl->left_macro,tss); - if (cl->flags & LTFLF_RIGHT_MACRO) - nl->right_macro=MAllocIdentical(cl->right_macro,tss); - if (cl->flags & LTFLF_HAS_BIN) { - tempb=MAllocIdentical(cl->bin_data,tss); - tempb->data=MAllocIdentical(cl->bin_data->data,tss); - nl->bin_num=l->cur_bin_num; - tempb->num=l->cur_bin_num++; - nl->bin_data=tempb; - InsQue(tempb,l->bin_root.last); - } - return nl; -} - -void LtfFormForward(Ltf *l) -{ - LtfEntry *cl=l->cur_entry,*cl1=cl->last; - if (l->flags & LTFF_FORM) { - while (cl!=cl1 && !Bt(ltf_form_types,cl->btype)) { - cl=cl->next; - } - l->cur_data_col=cl->min_col; - l->cur_entry=cl; - } -} - -void LtfFormBackward(Ltf *l) -{ - LtfEntry *cl=l->cur_entry,*cl1=cl->next; - if (l->flags & LTFF_FORM) { - while (cl!=cl1 && !Bt(ltf_form_types,cl->btype)) { - cl=cl->last; - } - l->cur_data_col=cl->min_col; - l->cur_entry=cl; - } -} - -public void LtfHome(Ltf *l) -{ - if (!l) return; - l->cur_entry=l->dummy.next; - l->cur_data_col=l->cur_entry->min_col; - l->x=0; - l->y=0; - l->line_start_col=0; - l->cur_top_line_num=0; - LtfFormForward(l); -} - - -public void LtfReset(Ltf *l,BoolU4 is_old,BoolU4 adam_mem=FALSE) -{ - LtfEntry *cl,*cl1; - if (!l) return; - if (is_old) { - cl=l->dummy.next; - while (cl!=l) { - cl1=cl->next; - if (adam_mem) - LtfDelEntry(cl,adam_tss); - else - LtfDelEntry(cl,l->mem_tss); - cl=cl1; - } - } -//Check $LK,"EditInsertLtf","MN:EditInsertLtf"$ - l->text_attribute=(WHITE<<4)+BLUE; - l->link_attribute=(WHITE<<4)+RED; - l->macro_attribute=(WHITE<<4)+LTBLUE; - l->anchor_attribute=(WHITE<<4)+BLACK; - l->hidden_attribute=(WHITE<<4)+BLACK; - l->tree_attribute=(WHITE<<4)+PURPLE; - l->user_attribute=(WHITE<<4)+GREEN; - l->flags=0; - l->dummy.next=l; - l->dummy.last=l; - l->bin_root.next=&l->bin_root; - l->bin_root.last=&l->bin_root; - l->cur_bin_num=1; - l->recalc_start=l; - l->menu_ltf=NULL; - l->dollar_buf_ptr=0; - l->cmd_I1=CH_SPACE; - l->indent=0; - l->page_line_num=0; - l->page_length=66; - l->left_margin=LTF_DEFAULT; - l->right_margin=LTF_DEFAULT; - l->header=LTF_DEFAULT; - l->footer=LTF_DEFAULT; - - cl=&l->dummy; - cl->type=LTFT_ERROR; - cl->flags=0; - cl->x=0; - cl->y=0; - cl->min_col=0; - cl->max_col=0; - cl->indent=l->indent; - cl->page_line_num=l->page_line_num; - cl->left_margin=l->left_margin; - cl->right_margin=l->right_margin; - - LtfHome(l); -} - - -public void LtfDel(Ltf *l,BoolU4 adam_mem=FALSE) -{ - Ltf *m; - - if (!l) return; - m=l->menu_ltf; - LtfReset(l,TRUE,adam_mem); - Free(l->find_replace,l->mem_tss); - Free(l->dollar_buf,l->mem_tss); - LtfDel(m,adam_mem); - Free(l,l->mem_tss); -} - - -void LtfFormatData(LtfEntry *cl) -{ - BoolU4 *b; - U8 *d; - I8 i; - if (cl->btype==LTFT_DATA) { - d=cl->data; - if (cl->flags & LTFLF_DATA_IS_PTR) - SPrintF(cl->display,cl->aux_string,*d,cl->my_format_data); - else - SPrintF(cl->display,cl->aux_string,d,cl->my_format_data); - if (cl->flags & LTFLF_HAS_TERMINATOR) { - i=StrLen(cl->display); - cl->display[i++]='_'; - cl->display[i]=0; - } - } else if (cl->btype==LTFT_CHECK_BOX) { - if (cl->flags & LTFLF_DATA_IS_PTR) - b=cl->data; - else - b=&cl->data; - if (*b) - cl->flags|=LTFLF_CHECKED; - else - cl->flags&=~LTFLF_CHECKED; - } -} - -void LtfGetData(LtfEntry *cl) -{ - BoolU4 *b; - I8 i; - if (cl->btype==LTFT_DATA) { - i=StrLen(cl->display); - if (cl->flags & LTFLF_HAS_TERMINATOR) - cl->display[--i]=0; - if (i>cl->len+cl->min_col) - cl->display[cl->len+cl->min_col]=0; - if (cl->flags & LTFLF_DATA_IS_PTR) - GetF(cl->display,cl->aux_string,cl->data,cl->my_format_data); - else - GetF(cl->display,cl->aux_string,&cl->data,cl->my_format_data); - if (cl->flags & LTFLF_HAS_TERMINATOR) - cl->display[i]='_'; - } else if (cl->btype==LTFT_CHECK_BOX) { - if (cl->flags & LTFLF_DATA_IS_PTR) - b=cl->data; - else - b=&cl->data; - if (cl->flags & LTFLF_CHECKED) - *b=TRUE; - else - *b=FALSE; - } -} - - -I8 LtfCharDist(Ltf *l,I8 x,I8 y) -{ - I8 dx=(l->x-x)*FONT_WIDTH>>2,dy=(l->y-y)*FONT_HEIGHT; - return MulI8(dx,dx)+MulI8(dy,dy); -} - - -public void LtfUpdateWindowJoin(Ltf *l,BoolU4 to_screen,BoolU4 has_cursor, - BoolU4 recalc,BoolU4 find_cur_entry, - LtfEntry *pg_found=NULL,I8 num_del_entries=0) -{ - I8 i,ii,j,k,x,x0,y,y0,D,d2,col,col2,best_col=0,best_d=MAX_I8; - I8 num_entries=0,cursor_y=MIN_I8; - LtfEntry *cl,*cl2,*best_cl=l->cur_entry,*alias,*next_pg_found=NULL; - I8 ijif; - U8 w,w1; - U1 *bptr; - U1 ch,*ptr,buf[16]; - BoolU4 del_cl,skipped_update,tree_collapsed; - U8 hide_collapsed[2]; - TssStruct *tss=l->tss,*mem_tss=l->mem_tss; - BoolU4 resize=FALSE; - BoolU4 extra_processing,same_window; - BoolU4 revert_default_color_eol=FALSE; - GrBitMap *base=GrNew(grbase2); - I8 left_margin=tss->window_left,right_margin=tss->window_right; - - if (!l) return; - if (to_screen || find_cur_entry) { - recalc=TRUE; - l->recalc_start=l; - } - - if (has_cursor) { - if (Btr(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED)) - resize=TRUE; - - if (Btr(&tss->crt_flags,CRTf_SCROLL_X)) - l->line_start_col=(DivI8(MulI8(tss->scroll_x,l->max_x-l->min_x+1), - right_margin-left_margin+4)+l->min_x) & -4; - if (Btr(&tss->crt_flags,CRTf_SCROLL_Y)) - l->cur_top_line_num=DivI8(MulI8(tss->scroll_y,l->max_y-l->min_y+1), - tss->window_bottom-tss->window_top+1)+l->min_y; - } - x=0; y=0; - l->indent=0; - l->page_line_num=0; - l->left_margin=LTF_DEFAULT; - l->right_margin=LTF_DEFAULT; - l->header=LTF_DEFAULT; - l->footer=LTF_DEFAULT; - same_window=tss->window_top==l->old_window_top && - tss->window_bottom==l->old_window_bottom && - tss->window_left==l->old_window_left && - tss->window_right==l->old_window_right; - w=l->text_attribute<<8; - if (!find_cur_entry) { - l->x=0; - l->y=0; - } - l->flags&=~(LTFF_WORD_WRAP|LTFF_UNDERLINED|LTFF_INVERTED|LTFF_BLINK); - l->shifted_x=0; - l->shifted_y=0; - if (recalc) { - if (l->cur_data_col<=l->cur_entry->min_col) - l->cur_data_col=l->cur_entry->min_col; - if (!l->recalc_start) - cl=l; //skip update - else { - cl=l->recalc_start; - if (cl!=l) { - i=l->ww_lines_back; - ii=i/2; //Threshold for stopping on SOFT_CR - while (i-- && cl->btype!=LTFT_CR && - (i>ii || cl->btype!=LTFT_SOFT_CR) && - cl->flags & LTFLF_WORD_WRAP && - cl->last!=l) - cl=cl->last; - if (cl->flags & LTFLF_WORD_WRAP) - l->flags|=LTFF_WORD_WRAP; - else - l->flags&=~LTFF_WORD_WRAP; - if (cl->flags & LTFLF_UNDERLINED) { - l->flags|=LTFF_UNDERLINED; - w|=LTFLT_UNDERLINED; - } else - l->flags&=~LTFF_UNDERLINED; - if (cl->flags & LTFLF_INVERTED) { - l->flags|=LTFF_INVERTED; - w|=LTFLT_INVERTED; - } else - l->flags&=~LTFF_INVERTED; - if (cl->flags & LTFLF_BLINK) { - l->flags|=LTFF_BLINK; - w|=LTFLT_BLINK; - } else - l->flags&=~LTFF_BLINK; - w|=(cl->type & 0x0C00FF00); - x=cl->x; y=cl->y; - l->indent=cl->indent; - l->page_line_num=cl->page_line_num; - l->left_margin=cl->left_margin; - l->right_margin=cl->right_margin; - } else - cl=l->dummy.next; - } - } else - cl=l->dummy.next; - x0=l->line_start_col; - y0=l->cur_top_line_num; - if (l->dummy.next==l) { - best_cl=l; - best_col=0; - l->cur_entry=l; - l->cur_data_col=0; - cl=l; - - } - skipped_update=(cl==l && l->dummy.next!=l); - - extra_processing=recalc||find_cur_entry||resize; - - l->min_x=0x7FFFFFFC; l->min_y=MAX_I4; - l->max_x=-0x7FFFFFFF; l->max_y=MIN_I4; - - while (cl!=l) { - del_cl=FALSE; - if (cl->flags & LTFLF_SKIP) { - cl=cl->last; //for consistency handle skips the same - goto skip; - } - if (cl->flags & LTFLF_DISPLAY_CB) { - if (recalc || cl->flags & LTFLF_REFRESH_DATA) { - Free(cl->display,mem_tss); - cl->display=cl->display_cb(l,l->user_data,cl,mem_tss); - cl->max_col=StrLen(cl->display); - if (l->cur_entry==cl) { - if (l->cur_data_col>=cl->max_col && cl->max_col) - l->cur_data_col=cl->max_col-1; - } - } - } - if (extra_processing) { -word_wrap_start: - cl2=cl->next; - if (cl2->btype==LTFT_SOFT_CR) { - if (!same_window) { - if (l->cur_entry==cl2) { - l->cur_entry=cl2->next; - l->cur_data_col=l->cur_entry->min_col; - } - if (best_cl==cl2) { - best_cl=cl2->next; - best_col=0; - } - RemQue(cl2); - LtfDelEntry(cl2,mem_tss); - goto word_wrap_start; - } - } - if (cl->btype==LTFT_TEXT) { - if (cl->flags==cl2->flags && - cl->type==cl2->type) { - i=StrLen(cl->display); - j=StrLen(cl2->display); - ptr=MAlloc(i+j+1,mem_tss); - MemCpy(ptr,cl->display,i); - MemCpy(ptr+i,cl2->display,j+1); - Free(cl->display,mem_tss); - cl->display=ptr; - if (l->cur_entry==cl2) { - l->cur_entry=cl; - l->cur_data_col+=i; - } - if (best_cl==cl2) { - best_cl=cl; - best_col=0; - } - RemQue(cl2); - LtfDelEntry(cl2,mem_tss); - goto word_wrap_start; - } - } - } - if (cl->flags & LTFLF_SCROLLING_X) - k=cl->scroll_len; - else if (Bt(ltf_display_types,cl->btype)) - k=StrLen(cl->display); - else - k=0; - if (cl->flags & - (LTFLF_LEFT_X|LTFLF_RIGHT_X|LTFLF_CENTER_X| - LTFLF_TOP_Y|LTFLF_BOTTOM_Y|LTFLF_CENTER_Y)) { - if (cl->flags & LTFLF_MARGIN_REL_X) { - if (cl->flags & LTFLF_LEFT_X) - x=left_margin-tss->window_left; - else if (cl->flags & LTFLF_RIGHT_X) - x=right_margin-(k-1)<<2-tss->window_left; - else if (cl->flags & LTFLF_CENTER_X) - x=((right_margin+left_margin)>>1-k>>1-tss->window_left) & -4; - } else { - if (cl->flags & LTFLF_LEFT_X) - x=x0; - else if (cl->flags & LTFLF_RIGHT_X) - x=tss->window_right-tss->window_left+x0-(k-1)<<2; - else if (cl->flags & LTFLF_CENTER_X) - x=((tss->window_right-tss->window_left+x0)>>1-k<<1) & -4; - } - if (cl->flags & LTFLF_PAGE_REL_Y) { - if (cl->flags & LTFLF_TOP_Y) - y-=cl->page_line_num; - else if (cl->flags & LTFLF_BOTTOM_Y) - y+=l->page_length-cl->page_line_num; - else if (cl->flags & LTFLF_CENTER_Y) - y+=l->page_length>>1-cl->page_line_num; - } else { - if (cl->flags & LTFLF_TOP_Y) - y=y0; - else if (cl->flags & LTFLF_BOTTOM_Y) - y=tss->window_bottom-tss->window_top+y0; - else if (cl->flags & LTFLF_CENTER_Y) - y=(tss->window_bottom-tss->window_top)>>1+y0; - } - } - - if (extra_processing && k>0) { - if (l->flags & LTFF_WORD_WRAP) { - i=(right_margin+4-(x+tss->window_left))>>2; //Space left ON line - ii=(x+4-l->left_margin)>>2; - if (cl->btype==LTFT_TEXT) { -/* - if (l->cur_entry==cl->next && l->cur_data_col==0 - && k==i) - i--; - if (l->cur_entry==cl) { - if (l->cur_data_col==i || - (l->cur_data_col==i+1 && (cl->display[i]==CH_SPACE ||cl->display[i]==CH_SHIFT_SPACE))) - i--; - } -*/ - if (k>i) { - for (j=i;j>8-ii && j>=0;j--) - if (cl->display[j]==CH_SPACE || cl->display==CH_SHIFT_SPACE) { - i=j+1; - break; - } - if (k>i && i>0) { - cl2=MAllocIdentical(cl,mem_tss); - cl2->display=NewString(cl->display+i,mem_tss); - InsQue(cl2,cl); - if (l->cur_entry==cl && l->cur_data_col>=i) { - l->cur_entry=cl2; - l->cur_data_col=l->cur_data_col-i; - } - cl->display[i]=0; - ptr=NewString(cl->display,mem_tss); - Free(cl->display,mem_tss); - cl->display=ptr; - cl2=MAllocZ(sizeof(LtfEntryBase),mem_tss); - cl2->type=LTFT_SOFT_CR | cl->type & 0xFFFFFF00; - cl2->flags=cl->flags; - cl2->x=x; - cl2->y=y; - cl2->indent=l->indent; - cl2->page_line_num=l->page_line_num; - cl2->left_margin=l->left_margin; - cl2->right_margin=l->right_margin; - InsQue(cl2,cl); - goto skip_soft_cr; - } - } - if (k==i) - goto skip_soft_cr; - } - if (k>=i && cl->btype!=LTFT_SOFT_CR && cl->btype!=LTFT_CR - && cl->btype!=LTFT_CURSOR_MOVEMENT) { - if (cl->last->btype!=LTFT_SOFT_CR && - cl->last->btype!=LTFT_CR && - cl->last->btype!=LTFT_CURSOR_MOVEMENT) { - cl2=MAllocZ(sizeof(LtfEntryBase),mem_tss); - cl2->type=LTFT_SOFT_CR | cl->type & 0xFFFFFF00; - cl2->flags=LTFLF_WORD_WRAP | - cl->flags & (LTFLF_INVERTED|LTFLF_UNDERLINED| - LTFLF_BLINK|LTFLF_SKIP); - cl2->x=x; - cl2->y=y; - cl2->indent=l->indent; - cl2->page_line_num=l->page_line_num; - cl2->left_margin=l->left_margin; - cl2->right_margin=l->right_margin; - InsQue(cl2,cl->last); - if (l->left_margin==LTF_DEFAULT) - x=l->indent; - else - x=l->left_margin+l->indent; - y++; - } - } -skip_soft_cr: - } - } - if (cl==l->cur_entry) - cursor_y=y; - cl->x=x; - cl->y=y; - cl->indent=l->indent; - cl->page_line_num=l->page_line_num; - cl->left_margin=l->left_margin; - cl->right_margin=l->right_margin; - cl->type=w & 0xFF00 | cl->type & 0xFFFF00FF; - if (l->flags & LTFF_WORD_WRAP) - cl->flags|=LTFLF_WORD_WRAP; - else - cl->flags&=~LTFLF_WORD_WRAP; - - if (l->flags & LTFF_UNDERLINED) { - cl->flags|=LTFLF_UNDERLINED; - w|=LTFLT_UNDERLINED; - } else { - cl->flags&=~LTFLF_UNDERLINED; - w&=~LTFLT_UNDERLINED; - } - - if (l->flags & LTFF_INVERTED) { - cl->flags|=LTFLF_INVERTED; - w|=LTFLT_INVERTED; - } else { - cl->flags&=~LTFLF_INVERTED; - w&=~LTFLT_INVERTED; - } - if (l->flags & LTFF_BLINK) { - cl->flags|=LTFLF_BLINK; - w|=LTFLT_BLINK; - } else { - cl->flags&=~LTFLF_BLINK; - w&=~LTFLT_BLINK; - } - - if (xmin_x) l->min_x=x; - if (ymin_y) l->min_y=y; - - if (find_cur_entry) { - D=LtfCharDist(l,x,y); - col=0; - } - col2=0; - w=w&0xFC00FF00|(l->shifted_x & 0x1F)<<16|(l->shifted_y & 0x1F)<<21; - switch (cl->btype) { - case LTFT_LINK: - w1=w & 0xFFFF0000 | l->link_attribute<<8; - break; - case LTFT_MACRO: - case LTFT_MENU_VALUE: - w1=w & 0xFFFF0000 | l->macro_attribute<<8; - break; - case LTFT_ANCHOR: - w1=w & 0xFFFF0000 | l->anchor_attribute<<8; - break; - case LTFT_TREE: - w1=w & 0xFFFF0000 | l->tree_attribute<<8; - break; - case LTFT_HIDE_START: - case LTFT_HIDE_END: - w1=w & 0xFFFF0000 | l->hidden_attribute<<8; - break; - default: - w1=w; - } - w1=w1 & 0xFFFFFF00 | cl->type & 0xF3FF0000; - if (cl==l->cur_entry && cl->btype!=LTFT_TEXT) - w1^=0xFF00; - - if (cl->flags & LTFLF_REFRESH_DATA) { - if (cl->btype==LTFT_DATA || cl->btype==LTFT_CHECK_BOX) { - LtfFormatData(cl); - if (cl->btype==LTFT_DATA) - cl->max_col=StrLen(cl->display); - } - } - - ptr=cl->display; - if (cl->flags & LTFLF_TREE) { - if (StrLen(ptr)>=2) { - if (cl->flags & LTFLF_COLLAPSED) - *ptr++='+'; - else - *ptr++='-'; - *ptr++=']'; - } - } - if (cl->btype==LTFT_CHECK_BOX) { - if (StrLen(ptr)>=3) { - *ptr++='['; - if (cl->flags & LTFLF_CHECKED) - *ptr++='X'; - else - *ptr++=' '; - *ptr++=']'; - } - } else if (cl->btype==LTFT_HIDE_START) { - if (StrLen(ptr)>=2) { - *ptr++='<'; - if (cl->flags & LTFLF_COLLAPSED) - *ptr++='+'; - else - *ptr++='-'; - } - } else if (cl->btype==LTFT_HIDE_END) { - if (StrLen(ptr)>=1) - *ptr++='>'; - } - - if (Bt(ltf_display_types,cl->btype)) { - if (cl->flags & LTFLF_SCROLLING_X) { - j=StrLen(cl->display); - if (j && cl->scroll_len) { - ijif=DivU8(MulU8(jiffies,MulU8(FONT_WIDTH,tss->scroll_speed)),JIFFY_FREQ); - ijif=ModU8(ijif,j*FONT_WIDTH); - w1=w1 & 0xFFE0FF00| - ((FONT_WIDTH-1-ModU8(ijif,FONT_WIDTH))<<16); - ijif=DivU8(ijif,FONT_WIDTH); - ptr=cl->display; - for (k=0;kscroll_len;k++) { - ch=ptr[ModU8(ijif+k,j)]; - if (!Bt(displayable_chars_bitmap,ch)) ch='.'; - if (to_screen) { - if (cl->flags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+ch,x-x0,y-y0); - else - PlotWindowChar(w1+ch,x-x0,y-y0); - } - x+=4; - } - } - if (find_cur_entry) { - D=LtfCharDist(l,cl->x,cl->y); - col=cl->min_col; - } - col2=cl->scroll_len; //TODO This is flawed - } else { - ptr=cl->display; - if (cl->flags & LTFLF_PASSWORD) { - while (ch=*ptr++) { - if (ch!=CH_TAB) { - if (ptr-1-cl->display>=cl->min_col) { - if (!(cl->flags & LTFLF_HAS_TERMINATOR) || - ptr-cl->display!=StrLen(cl->display)) - ch='*'; - } - if (to_screen) { - if (cl->flags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+ch,x-x0,y-y0); - else - PlotWindowChar(w1+ch,x-x0,y-y0); - } - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2flags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+CH_SPACE,x-x0,y-y0); - else - PlotWindowChar(w1+CH_SPACE,x-x0,y-y0); - } - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2flags & LTFLF_BORDER_PLOT) { - while (ch=*ptr++) { - if (ch!=CH_TAB) { - if (to_screen) - PlotBorderChar(w1+ch,x-x0,y-y0); - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2btype) { - case LTFT_TEXT: - if (!col2) { - if (!(cl->flags & LTFLF_TREE) && recalc) - del_cl=TRUE; - } - break; - case LTFT_HEX_EDIT: - if (cl->flags & LTFLF_DATA_IS_PTR) - bptr=cl->data; - else - bptr=&cl->data; - k=cl->display; //columns - for (i=0;ilen;i=i+k) { - if (cl->flags & LTFLF_ZERO_BASED) - SPrintF(buf,"%08X ",i); - else - SPrintF(buf,"%08X ",bptr); - ptr=buf; - while (ch=*ptr++) { - if (to_screen) { - if (cl->flags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+ch,x-x0,y-y0); - else - PlotWindowChar(w1+ch,x-x0,y-y0); - } - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2cl->len) k=cl->len-i; - for (j=0;jflags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+ch,x-x0,y-y0); - else - PlotWindowChar(w1+ch,x-x0,y-y0); - } - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2display-k)*12; - for (j=0;jflags & LTFLF_BORDER_PLOT) - PlotBorderChar(w1+ch,x-x0,y-y0); - else - PlotWindowChar(w1+ch,x-x0,y-y0); - } - if (find_cur_entry) { - d2=LtfCharDist(l,x,y); - if (d2display*12+k<<2+36; - } - break; - case LTFT_TAB: - i=(x+32) & -0x20; - if (cl->flags & LTFLF_BORDER_PLOT) { - while (xtext_attribute<<8 & 0xF00; - } - if (l->left_margin==LTF_DEFAULT) - x=l->indent; - else - x=l->indent+l->left_margin; - y++; - l->page_line_num++; - if (l->footer==LTF_DEFAULT) { - if (l->page_line_num>=l->page_length) { - if (l->header==LTF_DEFAULT) - l->page_line_num=0; - else { - l->page_line_num=l->header; - y+=l->header; - } - } - } else { - if (l->page_line_num>=l->page_length-l->footer) { - y+=l->footer; - if (l->header==LTF_DEFAULT) - l->page_line_num=0; - else { - l->page_line_num=l->header; - y+=l->header; - } - } - } - break; - case LTFT_CURSOR_MOVEMENT: - x+=cl->cursor_x_offset<<2; - y+=cl->cursor_y_offset; - if (cl->flags & LTFLF_PAGE_REL_Y) { - if (cl->flags & LTFLF_TOP_Y) - l->page_line_num=0; - else if (cl->flags & LTFLF_BOTTOM_Y) - l->page_line_num=l->page_length; - else if (cl->flags & LTFLF_CENTER_Y) - l->page_line_num=l->page_length>>1; - } //TODO: else - l->page_line_num=(l->page_line_num+ - cl->cursor_y_offset)%l->page_length; - break; - case LTFT_PAGE_BREAK: - x=0; - y+=l->page_length-cl->page_line_num; - l->page_line_num=0; - if (l->header!=LTF_DEFAULT) { - y+=l->header; - l->page_line_num=l->header; - } - break; - case LTFT_INDENT: - if (cl->flags & LTFLF_LEFT_X) - l->indent=cl->attr<<2; - else - l->indent=l->indent+cl->attr<<2; - x=l->indent; - cl->indent=l->indent; - cl->x=0; - if (l->left_margin!=LTF_DEFAULT) { - x+=l->left_margin; - cl->x+=l->left_margin; - } - break; - case LTFT_PAGE_LENGTH: - l->page_length=cl->attr; - break; - case LTFT_LEFT_MARGIN: - l->left_margin=cl->attr<<2; - cl->left_margin=l->left_margin; - left_margin=tss->window_left+l->left_margin; - break; - case LTFT_RIGHT_MARGIN: - l->right_margin=cl->attr<<2; - cl->right_margin=l->right_margin; - right_margin=tss->window_left+l->right_margin; - break; - case LTFT_HEADER: - l->header=cl->attr; - break; - case LTFT_FOOTER: - l->footer=cl->attr; - break; - case LTFT_FOREGROUND_COLOR: - if (cl->attr==LTF_DEFAULT) - w=w & 0xF000 | l->text_attribute<<8 & 0xF00; - else - w=w & 0xF000 | cl->attr<<8; - break; - case LTFT_BACKGROUND_COLOR: - if (cl->attr==LTF_DEFAULT) - w=w & 0xF00 | l->text_attribute<<8 & 0xF000; - else - w=w & 0xF00 | cl->attr<<12; - break; - case LTFT_DEFAULT_FOREGROUND_COLOR: - if (cl->attr==LTF_DEFAULT) - w=w & 0xF000 | l->text_attribute<<8 & 0xF00; - else - w=w & 0xF000 | cl->attr <<8; - l->text_attribute=l->text_attribute & 0xF0 | cl->attr; - break; - case LTFT_DEFAULT_BACKGROUND_COLOR: - if (cl->attr==LTF_DEFAULT) - w=w & 0xF00 | l->text_attribute<<8 & 0xF000; - else - w=w & 0xF00 | cl->attr <<12; - l->text_attribute=l->text_attribute & 0xF | cl->attr<<4; - break; - case LTFT_LINK_FOREGROUND: - l->link_attribute=l->link_attribute & 0xF0 | cl->attr; - break; - case LTFT_LINK_BACKGROUND: - l->link_attribute=l->link_attribute & 0xF | cl->attr<<4; - break; - case LTFT_MACRO_FOREGROUND: - l->macro_attribute=l->macro_attribute & 0xF0 | cl->attr; - break; - case LTFT_MACRO_BACKGROUND: - l->macro_attribute=l->macro_attribute & 0xF | cl->attr<<4; - break; - case LTFT_ANCHOR_FOREGROUND: - l->anchor_attribute=l->anchor_attribute & 0xF0 | cl->attr; - break; - case LTFT_ANCHOR_BACKGROUND: - l->anchor_attribute=l->anchor_attribute & 0xF | cl->attr<<4; - break; - case LTFT_HIDDEN_FOREGROUND: - l->hidden_attribute=l->hidden_attribute & 0xF0 | cl->attr; - break; - case LTFT_HIDDEN_BACKGROUND: - l->hidden_attribute=l->hidden_attribute & 0xF | cl->attr<<4; - break; - case LTFT_TREE_FOREGROUND: - l->tree_attribute=l->tree_attribute & 0xF0 | cl->attr; - break; - case LTFT_TREE_BACKGROUND: - l->tree_attribute=l->tree_attribute & 0xF | cl->attr<<4; - break; - case LTFT_USER_FOREGROUND: - if (cl->attr==LTF_DEFAULT) { - w=w & 0xF000 | l->user_attribute<<8 & 0xF00; - if (y==cursor_y) { - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - } - } else - l->user_attribute=l->user_attribute & 0xF0 | cl->attr; - break; - case LTFT_USER_BACKGROUND: - if (cl->attr==LTF_DEFAULT) { - w=w & 0xF00 | l->user_attribute<<8 & 0xF000; - if (y==cursor_y) { - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - } - } else - l->user_attribute=l->user_attribute & 0xF | cl->attr<<4; - break; - case LTFT_WORD_WRAP: - if (cl->attr) - l->flags|=LTFF_WORD_WRAP; - else - l->flags&=~LTFF_WORD_WRAP; - break; - case LTFT_UNDERLINED: - if (cl->attr) - l->flags|=LTFF_UNDERLINED; - else - l->flags&=~LTFF_UNDERLINED; - break; - case LTFT_INVERTED: - if (cl->attr) - l->flags|=LTFF_INVERTED; - else - l->flags&=~LTFF_INVERTED; - break; - case LTFT_BLINK: - if (cl->attr) - l->flags|=LTFF_BLINK; - else - l->flags&=~LTFF_BLINK; - break; - case LTFT_SHIFTED_X: - l->shifted_x=cl->attr; - break; - case LTFT_SHIFTED_Y: - l->shifted_y=cl->attr; - break; - case LTFT_CURSOR: - if (!find_cur_entry && !(l->flags & LTFF_NO_CURSOR)) { - l->cur_entry=cl->next; - l->cur_data_col=l->cur_entry->min_col; - } - del_cl=TRUE; - break; - case LTFT_PICTURE: - if (!cl->bin_data) - cl->bin_data=LtfFindBin(l,cl->bin_num); - if (cl->bin_data) { - GrReset(base); - base->flags&=~(BMF_DONT_DRAW|BMF_LOCATE_NEAREST|BMF_TRANSFORMATION); - if (!to_screen) - base->flags|=BMF_DONT_DRAW; - i=((w1>>12)&0xF)^0xF; - if (w1 & LTFLT_SELECTED) - i^=0xF; - if (w1 & LTFLT_INVERTED) - i^=0xF; - base->color^=i; - if (find_cur_entry) - base->flags|=BMF_LOCATE_NEAREST; - base->nearest_sub_GrElem=0; - base->nearest_dist=MAX_I8; - if (to_screen && (l->cur_GrElem==cl->bin_data->data)) { - base->flags|=BMF_LOCATE_NEAREST; - base->cur_x=ipx; - base->cur_y=ipy; - } else { - base->cur_x=(l->x-x0)>>2*FONT_WIDTH; - base->cur_y=(l->y-y0)*FONT_HEIGHT; - } - base->cur_z=0; - GrElemsPlot(base,(x-x0)>>2*FONT_WIDTH, - (y-y0)*FONT_HEIGHT,0,cl->bin_data->data,i); - if (to_screen && (l->cur_GrElem==cl->bin_data->data)) - l->cur_sub_GrElem=base->nearest_sub_GrElem; - base->flags&=~(BMF_LOCATE_NEAREST|BMF_DONT_DRAW); - D=base->nearest_dist; - col=cl->min_col; - } - break; - case LTFT_BPT: - w=w & 0xF000 | RED<<8; - revert_default_color_eol=TRUE; - break; - case LTFT_SONG: - if (sys_cur_focus_task==tss && to_screen) { - if (StrCmp(cur_song,cl->song)) { - AFree(cur_song); - ResetMusicSettings; - cur_song=ANewString(cl->song); - } - } - Bts(&tss->task_flags,TSSf_HAS_SONG); - break; - case LTFT_CLEAR: - if (recalc && pg_found==cl) { - del_cl=TRUE; - pg_found=FALSE; - } else - next_pg_found=cl; - break; - } - - if (cl->flags & LTFLF_HAS_BORDER) { - if (cl->flags & LTFLF_SOLID_BORDER) - DrawBorder(1,cl->x-x0,x-x0-4,cl->y-y0,y-y0,w1.u1[1],TRUE); - else - DrawBorder(0,cl->x-x0,x-x0-4,cl->y-y0,y-y0,w1.u1[1],TRUE); - } - switch (cl->btype) { - case LTFT_CHECK_BOX: - case LTFT_HIDE_START: - cl->max_col=2; - break; - case LTFT_TREE: - case LTFT_BUTTON: - case LTFT_LINK: - case LTFT_MENU_VALUE: - case LTFT_MACRO: - case LTFT_HIDE_END: - cl->max_col=1; - break; - default: - cl->max_col=(cl->flags & LTFLF_TREE) ? 1:col2; - } - - if (x>l->max_x) l->max_x=x; - if (y>l->max_y) l->max_y=y; - if (Dflags & LTFLF_TREE) { - if (cl->flags & LTFLF_ALIAS) - alias=cl; - else - alias=NULL; - if (cl->flags & LTFLF_COLLAPSED) - tree_collapsed=TRUE; - else - tree_collapsed=FALSE; - cl2=cl->next; - while (cl2!=l && cl2->btype!=LTFT_INDENT && !(cl2->flags & LTFLF_TREE)) - cl2=cl2->next; - if (cl2->btype==LTFT_INDENT) { - i=l->indent; - j=i; - do { - if (tree_collapsed) - cl2->flags|=LTFLF_SKIP; - else - cl2->flags&=~LTFLF_SKIP; - if (alias && cl2==l->cur_entry && Bt(ltf_display_types,cl2->btype)) { - Free(alias->display,mem_tss); - alias->display=MAlloc(StrLen(cl2->display)+4,mem_tss); - alias->display[0]='+'; - alias->display[1]=']'; - alias->display[2]=CH_SPACE; - StrCpy(alias->display+3,cl2->display); - alias->max_col=cl2->max_col+3; - } - if (cl2->btype==LTFT_INDENT) { - if (cl2->flags & LTFLF_LEFT_X) - j=cl2->attr; - else - j+=cl2->attr; - } - cl2=cl2->next; - } while (cl2!=l && j>i); - } - } - if (cl->btype == LTFT_HIDE_START) { - if (cl->flags & LTFLF_ALIAS) - alias=cl; - else - alias=NULL; - cl2=cl->next; - Btr(hide_collapsed,0); - j=1; - AssignBit(hide_collapsed,j,cl->flags & LTFLF_COLLAPSED); - while (cl2!=l && j>0) { - if (Bt(hide_collapsed,j)) - cl2->flags|=LTFLF_SKIP; - else - cl2->flags&=~LTFLF_SKIP; - if (cl2->btype==LTFT_HIDE_START) { - j++; - AssignBit(hide_collapsed,j,cl2->flags & LTFLF_COLLAPSED); - if (Bt(hide_collapsed,j-1)) - Bts(hide_collapsed,j); - } else if (cl2->btype==LTFT_HIDE_END) { - j--; - if (Bt(hide_collapsed,j)) - cl2->flags|=LTFLF_SKIP; - else - cl2->flags&=~LTFLF_SKIP; - } - cl2=cl2->next; - } - } - -skip: - cl2=cl->next; - while (cl2!=l && cl2->flags & LTFLF_SKIP) { -/* - if (cl2==l->cur_entry) { - l->cur_entry=cl2->next; - l->cur_data_col=l->cur_entry->min_col; - } -*/ - cl2->x=x; - cl2->y=y; - cl2->indent=l->indent; - cl2->page_line_num=l->page_line_num; - cl2->left_margin=l->left_margin; - cl2->right_margin=l->right_margin; - cl2->type=w & 0xFF00 | cl2->type & 0xFFFF00FF; - if (l->flags & LTFF_WORD_WRAP) - cl2->flags|=LTFLF_WORD_WRAP; - else - cl2->flags&=~LTFLF_WORD_WRAP; - - if (l->flags & LTFF_UNDERLINED) { - cl2->flags|=LTFLF_UNDERLINED; - w|=LTFLT_UNDERLINED; - } else { - cl2->flags&=~LTFLF_UNDERLINED; - w&=~LTFLT_UNDERLINED; - } - - if (l->flags & LTFF_INVERTED) { - cl2->flags|=LTFLF_INVERTED; - w|=LTFLT_INVERTED; - } else { - cl2->flags&=~LTFLF_INVERTED; - w&=~LTFLT_INVERTED; - } - if (l->flags & LTFF_BLINK) { - cl2->flags|=LTFLF_BLINK; - w|=LTFLT_BLINK; - } else { - cl2->flags&=~LTFLF_BLINK; - w&=~LTFLT_BLINK; - } - cl2=cl2->next; - } - - if (del_cl || pg_found || num_entriesflags & LTFLF_HOLD)) { - if (cl==l->cur_entry) { - l->cur_entry=cl2; - l->cur_data_col=cl2->min_col; - } - if (best_cl==cl) { - best_cl=cl2; - best_col=0; - } - RemQue(cl); - LtfDelEntry(cl,mem_tss); - } - } - num_entries++; - cl=cl2; - } - - //Update header - if (!skipped_update) { - cl->x=x; - cl->y=y; - cl->indent=l->indent; - cl->page_line_num=l->page_line_num; - cl->left_margin=l->left_margin; - cl->right_margin=l->right_margin; - cl->type=w & 0xFF00 | cl->type & 0xFFFF00FF; - if (find_cur_entry) { - D=LtfCharDist(l,x,y); - if (Dflags & LTFF_MIN_SIZE) { - if (tss->window_right!=tss->window_left+l->max_x+4) { - tss->window_right=tss->window_left+l->max_x-l->min_x+4; - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - } - if (tss->window_bottom!=tss->window_top+l->max_y+1) { - tss->window_bottom=tss->window_top+l->max_y-l->min_y+1; - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - } - } - if (find_cur_entry) { - l->cur_entry=best_cl; - l->cur_data_col=best_col; - } - if ((l->cur_entry->btype)!=LTFT_HEX_EDIT) { - l->y=l->cur_entry->y; - l->x=l->cur_entry->x+l->cur_data_col<<2; - } else { - l->y=l->cur_entry->y+l->cur_data_col/3/l->cur_entry->display; - x=l->cur_data_col%(l->cur_entry->display*3); - i=x/l->cur_entry->display; - l->x=l->cur_entry->x+36; - if (i<2) - l->x+=x>>1*12+(x&1)<<2; - else - l->x+=l->cur_entry->display*12+(x-l->cur_entry->display<<1)<<2; - } - l->line=l->y+1; - l->col=l->x>>2+1; - if (has_cursor) { - if (l->cur_top_line_num+tss->window_bottom-tss->window_top>l->max_y) - l->cur_top_line_num=l->max_y-(tss->window_bottom-tss->window_top); - if (l->cur_top_line_nummin_y) - l->cur_top_line_num=l->min_y; - - if (l->y-l->cur_top_line_num>tss->window_bottom-tss->window_top) - l->cur_top_line_num=l->y-(tss->window_bottom-tss->window_top); - if (l->y-l->cur_top_line_num<0) - l->cur_top_line_num=l->y; - - if (l->line_start_col+tss->window_right-tss->window_left>l->max_x) - l->line_start_col=l->max_x-(tss->window_right-tss->window_left); - if (l->line_start_colmin_x) - l->line_start_col=l->min_x; - - if (l->x-l->line_start_col>tss->window_right-tss->window_left) - l->line_start_col=l->x-(tss->window_right-tss->window_left); - if (l->x-l->line_start_col<0) - l->line_start_col=l->x; - } - if (recalc) - l->recalc_start=NULL; - if (to_screen && has_cursor) { - tss->cursor_vert=l->y-l->cur_top_line_num+tss->window_top; - tss->cursor_hor=l->x-l->line_start_col+tss->window_left; - if (jiffies % (JIFFY_FREQ>>2) > (JIFFY_FREQ>>2)>>1) { - Btr(&Fs->crt_flags,CRTf_CURSOR_ON); - CursorOn; - } - - i=l->max_x-l->min_x+1; - tss->scroll_x=DivI8(MulI8(l->line_start_col-l->min_x, - tss->window_right-tss->window_left+4)+i-1,i)&-4; - - i=l->max_y-l->min_y+1; - tss->scroll_y=DivI8(MulI8(l->cur_top_line_num-l->min_y, - tss->window_bottom-tss->window_top+1)+i-1,i); - - PlotBorderChar(140+(tss->border_attribute<<8), - (tss->window_right-tss->window_left+4),tss->scroll_y); - PlotBorderChar(140+(tss->border_attribute<<8), - tss->scroll_x,(tss->window_bottom-tss->window_top+1)); - } - if (!same_window && extra_processing) { - l->old_window_top=tss->window_top; - l->old_window_bottom=tss->window_bottom; - l->old_window_left=tss->window_left; - l->old_window_right=tss->window_right; - } - GrDel(base); - if (recalc) { - i=num_entries-l->max_entries; - if (i>1024 && !num_del_entries || next_pg_found) - LtfUpdateWindowJoin(l,to_screen,has_cursor,recalc,find_cur_entry,next_pg_found,i); - } -} - -void LtfRemoveSoftCRs(Ltf *l,LtfEntry *cl=NULL) -{ - LtfEntry *cl2,*saved_cl=cl; - BoolU4 old_preempt=Preempt(OFF); - if (!cl) cl=l->dummy.next; - while (cl!=l) { - cl2=cl->next; - if (cl->btype==LTFT_SOFT_CR) { - if (l->cur_entry==cl) { - l->cur_entry=cl2; - l->cur_data_col=l->cur_entry->min_col; - } - RemQue(cl); - LtfDelEntry(cl,l->mem_tss); - } else if (saved_cl && cl->btype==LTFT_CR) - break; - cl=cl2; - } - Preempt(old_preempt); -} - -public void LtfRecalc(Ltf *l) -{ - if (l->recalc_start!=l && l->recalc_start) - LtfRemoveSoftCRs(l,l->recalc_start); - LtfUpdateWindowJoin(l,FALSE,FALSE,TRUE,FALSE); -} -ext[EXT_LTF_RECALC]=&LtfRecalc; - - -public void LtfCenter(Ltf *l) -{ - TssStruct *tss=l->tss; - LtfRecalc(l); - l->cur_top_line_num=l->y-(tss->window_bottom-tss->window_top)>>1; -} - -public void LtfBottom(Ltf *l) -{ - l->cur_entry=l; - l->cur_data_col=0; - l->recalc_start=l; - LtfRecalc(l); -} - -public Ltf *LtfNew() -{ - Ltf *l; - l=MAllocZ(sizeof(Ltf)); - StrCpy(l->filename.name,sys_temp_filename); - l->file_attr=0; - l->find_replace=MAllocZ(sizeof(EditFindTextStruct)); - l->find_replace->scan_forward=1; - l->find_replace->match_case=1; - l->EditPlugIns=Fs->EditPlugIns; - l->dollar_buf_size=84; - l->dollar_buf=MAlloc(l->dollar_buf_size); - l->max_entries=MAX_I4; - l->ww_lines_back=32; - l->tss=Fs; - l->mem_tss=Fs; - LtfReset(l,FALSE,FALSE); - return l; -} - -void ParseLtfFlags(LexStruct *l,U8 *flags,U4 *type) -{ - I8 i; - BoolU4 turn_on; - while (l->token=='+' || l->token=='-') { - turn_on=(l->token=='+'); - if (Lex(l)==TK_IDENT) { - i=MatchSysTextEntry(l->ident,"ST_LTF_FLAGS",MLE_EXACT); - if (i<0) - *type=LTFT_ERROR; - else { - AssignBit(flags,i,turn_on); - if (i==LTFLf_SELECTED) - AssignBit(type,30,turn_on); - else if (i==LTFLf_UNDERLINED) - AssignBit(type,31,turn_on); - else if (i==LTFLf_INVERTED) - AssignBit(type,29,turn_on); - else if (i==LTFLf_BLINK) - AssignBit(type,28,turn_on); - } - Lex(l); //skip flag - } - } -} - -void LtfDefaultFlags(U4 *type,U8 *f1) -{ - switch (*type & 255) {$AN,"default_flags","default_flags"$ - case LTFT_TREE: - *f1=LTFLF_COLLAPSED|LTFLF_TREE; - *type=*type | LTFLT_UNDERLINED; - break; - case LTFT_DATA: - *f1=LTFLF_DATA_IS_PTR | LTFLF_HAS_TERMINATOR | LTFLF_AUX_STRING; - break; - case LTFT_CURSOR_MOVEMENT: - *f1=LTFLF_LEFT_EXP | LTFLF_RIGHT_EXP; - break; - case LTFT_LINK: - *f1=LTFLF_AUX_STRING; - *type=*type | LTFLT_UNDERLINED; - break; - case LTFT_ANCHOR: - *f1=LTFLF_AUX_STRING; - break; - case LTFT_BUTTON: - *f1=LTFLF_ESC | LTFLF_LEFT_EXP | LTFLF_HAS_BORDER; - break; - case LTFT_CHECK_BOX: - *f1=LTFLF_DATA_IS_PTR; - break; - case LTFT_MACRO: - *f1=LTFLF_ESC | LTFLF_LEFT_MACRO; - *type=*type | LTFLT_UNDERLINED; - break; - case LTFT_MENU_VALUE: - *f1=LTFLF_ESC | LTFLF_LEFT_EXP; - *type=*type | LTFLT_UNDERLINED; - break; - case LTFT_HEX_EDIT: - *f1=LTFLF_DATA_IS_PTR | LTFLF_ZERO_BASED; - break; - case LTFT_PICTURE: - *f1=LTFLF_HAS_BIN; - break; - case LTFT_INSERT_BINARY: - case LTFT_INSERT_BINARY_TYPE: - case LTFT_INSERT_BINARY_SIZE: - *f1=LTFLF_HAS_BIN; - break; - case LTFT_HIDE_START: - *f1=LTFLF_COLLAPSED; - *type=*type | LTFLT_UNDERLINED; - break; - case LTFT_SONG: - *f1=LTFLF_LEFT_MACRO; - break; - } -} - -I1 *LtfToPlainText(LtfEntry *ll) -{ - I8 i,j; - U8 type=ll->btype,f1=0,flags; - I1 *buf,*buf2; - - if (ll->btype==LTFT_ERROR) - return NewString(ll->plain_text); - - LtfDefaultFlags(&type,&f1); - - buf=NewString(SysTextSub(ll->btype,"ST_LTF_CMDS")); - flags=ll->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | - LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP); - for (i=0;i<64;i++) - if (Bt(&f1,i)!=Bt(&flags,i)) { - if (Bt(&flags,i)) - buf=Add2String(buf,"+"); - else - buf=Add2String(buf,"-"); - buf=Add2String(buf,SysTextSub(i,"ST_LTF_FLAGS")); - } - - for (i=28;i<32;i++) - if (Bt(&type,i)!=Bt(&ll->type,i)) { - if (Bt(&ll->type,i)) - buf=Add2String(buf,"+"); - else - buf=Add2String(buf,"-"); - switch (i) { - case 28: j=LTFLf_BLINK; break; - case 29: j=LTFLf_INVERTED; break; - case 30: j=LTFLf_SELECTED; break; - case 31: j=LTFLf_UNDERLINED; break; - } - buf=Add2String(buf,SysTextSub(j,"ST_LTF_FLAGS")); - } - buf=Add2String(buf,","); - switch (ll->btype) { - case LTFT_TEXT: - case LTFT_LINK: - case LTFT_ANCHOR: - case LTFT_MENU_VALUE: - case LTFT_BUTTON: - case LTFT_CHECK_BOX: - case LTFT_TREE: - case LTFT_PICTURE: - case LTFT_INSERT_BINARY: - case LTFT_INSERT_BINARY_TYPE: - case LTFT_INSERT_BINARY_SIZE: - case LTFT_SONG: - buf=Add2String(buf,"\""); - if (i==LTFT_CHECK_BOX) { - buf=Add2String(buf,ll->display+4); - } else { - if (ll->flags & LTFLF_TREE) - buf=Add2String(buf,ll->display+3); - else - buf=Add2String(buf,ll->display); - } - buf=Add2String(buf,"\","); - break; - case LTFT_DATA: - buf2=MSPrintF("%s%d,",buf,ll->len); - Free(buf); buf=buf2; - break; - case LTFT_HEX_EDIT: - buf2=MSPrintF("%s%d,",buf,ll->len); - Free(buf); buf=buf2; - buf2=MSPrintF("%s%d,",buf,ll->display); - Free(buf); buf=buf2; - break; - case LTFT_PAGE_LENGTH: - case LTFT_LEFT_MARGIN: - case LTFT_RIGHT_MARGIN: - case LTFT_HEADER: - case LTFT_FOOTER: - case LTFT_INDENT: - case LTFT_FOREGROUND_COLOR: - case LTFT_BACKGROUND_COLOR: - case LTFT_DEFAULT_FOREGROUND_COLOR: - case LTFT_DEFAULT_BACKGROUND_COLOR: - case LTFT_LINK_FOREGROUND: - case LTFT_LINK_BACKGROUND: - case LTFT_MACRO_FOREGROUND: - case LTFT_MACRO_BACKGROUND: - case LTFT_ANCHOR_FOREGROUND: - case LTFT_ANCHOR_BACKGROUND: - case LTFT_HIDDEN_FOREGROUND: - case LTFT_HIDDEN_BACKGROUND: - case LTFT_TREE_FOREGROUND: - case LTFT_TREE_BACKGROUND: - case LTFT_USER_FOREGROUND: - case LTFT_USER_BACKGROUND: - case LTFT_WORD_WRAP: - case LTFT_UNDERLINED: - case LTFT_INVERTED: - case LTFT_BLINK: - case LTFT_SHIFTED_X: - case LTFT_SHIFTED_Y: - if (ll->attr!=LTF_DEFAULT) { - buf2=MSPrintF("%s%d,",buf,ll->attr); - Free(buf); buf=buf2; - } - break; - } - flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y| - LTFLF_AUX_STRING|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO| - LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO); - while (flags) { - j=Bsf(flags); - Btr(&flags,j); - switch (j) { - case LTFLf_SCROLLING_X: - buf2=MSPrintF("%s%d",buf,ll->scroll_len); - Free(buf); buf=buf2; - break; - case LTFLf_SHIFTED_X: - j=(ll->type.u2[1])&0x1F; - if (j&0x10) j|=0xFFFFFFF0; - buf2=MSPrintF("%s%d",buf,j); - Free(buf); buf=buf2; - break; - case LTFLf_SHIFTED_Y: - j=(ll->type>>21)&0x1F; - if (j&0x10) j|=0xFFFFFFF0; - buf2=MSPrintF("%s%d",buf,j); - Free(buf); buf=buf2; - break; - case LTFLf_AUX_STRING: - buf2=MSPrintF("%s\"%Q\"",buf,ll->aux_string); - Free(buf); buf=buf2; - break; - case LTFLf_LEFT_EXP: - buf2=MSPrintF("%s%d",buf,ll->left_exp); - Free(buf); buf=buf2; - break; - case LTFLf_LEFT_MACRO: - buf2=MSPrintF("%s\"%Q\"",buf,ll->left_macro); - Free(buf); buf=buf2; - break; - case LTFLf_RIGHT_EXP: - buf2=MSPrintF("%s%d",buf,ll->right_exp); - Free(buf); buf=buf2; - break; - case LTFLf_RIGHT_MACRO: - buf2=MSPrintF("%s\"%Q\"",buf,ll->right_macro); - Free(buf); buf=buf2; - break; - case LTFLf_HAS_BIN: - buf2=MSPrintF("%s%d",buf,ll->bin_num); - Free(buf); buf=buf2; - break; - } - buf=Add2String(buf,","); - } - buf[StrLen(buf)-1]=0; //Kill last comma - buf2=NewString(buf); //exact allocation - Free(buf); - return buf2; -} - - -LtfEntry *ParseDollarCmd(I1 *st,TssStruct *tss) -{ - I8 i,j,size,flags; - I1 *ptr; - LtfEntry *ll=NULL; - LexStruct *l=LexNew(st,LF_DONT_FREE_BUFFER,NULL); - Lex(l); - if (l->token==TK_IDENT) { - i=MatchSysTextEntry(l->ident,"ST_LTF_CMDS",MLE_IGNORE_CASE); - if (i<0) - i=LTFT_ERROR; - Lex(l); //skip cmd code - ll=MAllocZ(sizeof(LtfEntry),tss); - ll->type=i; - ll->plain_text=NewString(st,tss); - LtfDefaultFlags(&ll->type,&ll->flags); - ParseLtfFlags(l,&ll->flags,&ll->type); - - if (l->token==',') - Lex(l); - switch (i) { - case LTFT_TEXT: - case LTFT_LINK: - case LTFT_ANCHOR: - case LTFT_MENU_VALUE: - case LTFT_BUTTON: - case LTFT_CHECK_BOX: - case LTFT_TREE: - case LTFT_PICTURE: - case LTFT_INSERT_BINARY: - case LTFT_INSERT_BINARY_TYPE: - case LTFT_INSERT_BINARY_SIZE: - case LTFT_SONG: - if (l->token==TK_STRING) { - st=LexExtendString(l,&size); - if (i==LTFT_CHECK_BOX) { - ll->display=MSPrintF("[X] %s",st); - ll->min_col=1; - } else { - if (ll->flags & LTFLF_TREE) { - ll->display=MSPrintF("+] %s",st); - ll->min_col=1; - } else - ll->display=st; - } - } else { - if (i>=LTFT_PICTURE && i<=LTFT_INSERT_BINARY_SIZE || - i==LTFT_SONG) - ll->display=NewString(""); - else { - ll->display=0; - ll->type=LTFT_ERROR; - } - } - break; - case LTFT_HIDE_START: - ll->display=NewString("<-"); - ll->min_col=1; - break; - case LTFT_HIDE_END: - ll->display=NewString(">"); - break; - case LTFT_DATA: - ll->flags|=LTFLF_AUX_STRING; //don't allow switched off - ll->len=Expression(l); - break; - case LTFT_HEX_EDIT: - ll->len=Expression(l); - if (l->token==',') - Lex(l); - ll->display=Expression(l); //TODO union - break; - case LTFT_PAGE_LENGTH: - case LTFT_LEFT_MARGIN: - case LTFT_RIGHT_MARGIN: - case LTFT_HEADER: - case LTFT_FOOTER: - case LTFT_INDENT: - case LTFT_FOREGROUND_COLOR: - case LTFT_BACKGROUND_COLOR: - case LTFT_DEFAULT_FOREGROUND_COLOR: - case LTFT_DEFAULT_BACKGROUND_COLOR: - case LTFT_LINK_FOREGROUND: - case LTFT_LINK_BACKGROUND: - case LTFT_MACRO_FOREGROUND: - case LTFT_MACRO_BACKGROUND: - case LTFT_ANCHOR_FOREGROUND: - case LTFT_ANCHOR_BACKGROUND: - case LTFT_HIDDEN_FOREGROUND: - case LTFT_HIDDEN_BACKGROUND: - case LTFT_TREE_FOREGROUND: - case LTFT_TREE_BACKGROUND: - case LTFT_USER_FOREGROUND: - case LTFT_USER_BACKGROUND: - case LTFT_WORD_WRAP: - case LTFT_UNDERLINED: - case LTFT_INVERTED: - case LTFT_BLINK: - case LTFT_SHIFTED_X: - case LTFT_SHIFTED_Y: - if (!l->token) - ll->attr=LTF_DEFAULT; - else - ll->attr=Expression(l); - break; - case LTFT_ERROR: - ll->flags=0; - ll->type=LTFT_ERROR; - break; - } - - flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y| - LTFLF_AUX_STRING|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO| - LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO); - while (flags) { - j=Bsf(flags); - Btr(&flags,j); - while (l->token==',') - Lex(l); - switch (j) { //TODO: Might check for expression errors - case LTFLf_SCROLLING_X: - ll->scroll_len=Expression(l); - break; - case LTFLf_SHIFTED_X: - ll->type|=((Expression(l) & 0x1F)<<16); - break; - case LTFLf_SHIFTED_Y: - ll->type|=((Expression(l) & 0x1F)<<21); - break; - case LTFLf_AUX_STRING: - if (l->token==TK_STRING) { - ll->aux_string=LexExtendString(l,&size); - if (i==LTFT_MACRO && !ll->display) - ll->display=NewString(ll->aux_string,tss); - if (i==LTFT_DATA) { - if (ptr=StrStr(ll->aux_string,":")) - ll->min_col=ptr-ll->aux_string+1; - ll->display=MAlloc(ll->len+ll->min_col+2,tss); - } - } else - ll->type=LTFT_ERROR; - break; - case LTFLf_LEFT_EXP: - ll->left_exp=Expression(l); - break; - case LTFLf_LEFT_MACRO: - if (l->token==TK_STRING) { - ll->left_macro=LexExtendString(l,&size); - if (i==LTFT_MACRO && !ll->display) - ll->display=NewString(ll->left_macro,tss); - } else - ll->type=LTFT_ERROR; - break; - case LTFLf_RIGHT_EXP: - ll->right_exp=Expression(l); - break; - case LTFLf_RIGHT_MACRO: - if (l->token==TK_STRING) { - ll->right_macro=LexExtendString(l,&size); - if (i==LTFT_MACRO && !ll->display) - ll->display=NewString(ll->right_macro,tss); - } else - ll->type=LTFT_ERROR; - break; - case LTFLf_HAS_BIN: - if (!l->token) - ll->bin_num=0; - else - ll->bin_num=Expression(l); - break; - } - } - } else if (!ll) { - ll=MAllocZ(sizeof(LtfEntry),tss); - ll->type=LTFT_ERROR; - ll->plain_text=NewString(st,tss); - } - LexDel(l); - return ll; -} - -void LtfInsert(Ltf *l,LtfEntry *ll) -{ - I1 *dst; - LtfEntry *cl=l->cur_entry,*nl; - - ll->x=cl->x; - ll->y=cl->y; - ll->indent=cl->indent; - ll->page_line_num=cl->page_line_num; - ll->left_margin=cl->left_margin; - ll->right_margin=cl->right_margin; - if (l->cur_data_col>0 && - cl->btype==LTFT_TEXT && - l->cur_data_colmax_col) { - nl=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - nl->type=LTFT_TEXT|cl->type&-0x100; - nl->x=cl->x; - nl->y=cl->y; - nl->indent=cl->indent; - nl->page_line_num=cl->page_line_num; - nl->left_margin=cl->left_margin; - nl->right_margin=cl->right_margin; - nl->flags=cl->flags; - dst=cl->display+l->cur_data_col; - nl->display=NewString(dst,l->mem_tss); - *dst=0; - cl->max_col=l->cur_data_col; - InsQue(nl,cl); - l->cur_data_col=0; - cl=nl; - cl->max_col=StrLen(cl->display); - } - if (cl->btype==LTFT_TEXT && l->cur_data_col>=cl->max_col) { - InsQue(ll,cl); - l->cur_entry=ll->next; - } else { - InsQue(ll,cl->last); - l->cur_entry=cl; - } - l->cur_data_col=l->cur_entry->min_col; - LtfRemoveSoftCRs(l,l->cur_entry); -} - - -public LtfEntry *LtfPutS(Ltf *l,I1 *st) -{ - I1 ch,*ptr=st,*ptr2,*st2,*ptr3,*ptr4,*src; - BoolU4 old_preempt=Preempt(OFF); - LtfEntry *ll=NULL,*result=NULL,*cl=l->cur_entry; - l->recalc_start=l; //TODO:This might be optimized - if (!st) { - Preempt(old_preempt); - return NULL; - } - while (*ptr) { - ptr2=ptr; - ch=*ptr++; - while (TRUE) { - if (l->flags & LTFF_PLAIN_TEXT_WITH_TABS) - while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_CURSOR) - ch=*ptr++; - else if (l->flags & LTFF_PLAIN_TEXT) - while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED) - ch=*ptr++; - else - while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED && ch!='$$') - ch=*ptr++; - if (ch==CH_CURSOR) { - if (l->flags & LTFF_NO_CURSOR) - ch=*ptr++; - else - break; - } else - break; - } - ptr--; - if (!ch) { - if (ptr!=ptr2) { - ll=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - ll->type=LTFT_TEXT | l->text_attribute << 8; - if (l->flags & LTFF_NO_CURSOR) { - src=NewString(ptr2); - StringUtil(src,SU_REMOVE_CTRL_CHARS); - } else - src=ptr2; - ll->display=NewString(src,l->mem_tss); - ll->max_col=StrLen(src); - LtfInsert(l,ll); - if (l->flags & LTFF_NO_CURSOR) - Free(src); - } - } else { - if (ptr!=ptr2) { - *ptr=0; - ll=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - ll->type=LTFT_TEXT | l->text_attribute << 8; - if (l->flags & LTFF_NO_CURSOR) { - src=NewString(ptr2); - StringUtil(src,SU_REMOVE_CTRL_CHARS); - } else - src=ptr2; - ll->display=NewString(src,l->mem_tss); - ll->max_col=StrLen(src); - LtfInsert(l,ll); - if (l->flags & LTFF_NO_CURSOR) - Free(src); - *ptr=ch; - } - if (ch==CH_CURSOR) { //cursor - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_CURSOR | l->text_attribute << 8; - LtfInsert(l,ll); - ptr++; - } else if (ch==CH_FORM_FEED) { - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8; - LtfInsert(l,ll); - ptr++; - } else if (ch==CH_TAB) { - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_TAB | l->text_attribute << 8; - LtfInsert(l,ll); - ptr++; - } else if (ch=='$$') { - ptr++; //skip first dollar - ptr2=ptr; - while (*ptr && *ptr!='$$') - ptr++; - if (*ptr) { - *ptr=0; //zero second dollar - if (ptr==ptr2) { - ll=MAllocZ(sizeof(LtfEntryBase)+4,l->mem_tss); - ll->type=LTFT_TEXT | l->text_attribute << 8; - ll->max_col=1; - if (l->flags & LTFF_DOUBLE_DOLLARS) - ll->display=NewString("$$$$",l->mem_tss); - else - ll->display=NewString("$$",l->mem_tss); - LtfInsert(l,ll); - } else { - st2=MAlloc(ptr-ptr2+1); - ptr3=ptr2; - ptr4=st2; - while (*ptr3) { - ch=*ptr3++; - if (ch==CH_CURSOR) { - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_CURSOR | l->text_attribute << 8; - LtfInsert(l,ll); - } else if (ch==CH_FORM_FEED) { - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8; - LtfInsert(l,ll); - } else - *ptr4++=ch; - } - *ptr4=0; - if (ll=ParseDollarCmd(st2,l->mem_tss)) { - result=ll; - LtfInsert(l,ll); - } - Free(st2); - } - *ptr++='$$'; - } - } else { - ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); - ll->type=LTFT_CR | l->text_attribute << 8; - LtfInsert(l,ll); - if (ch==CH_CR) - while (*ptr==CH_CR) - ptr++; - if (*ptr==CH_LINE_FEED) - ptr++; - while (*ptr==CH_CR) - ptr++; - } - } - } - Preempt(old_preempt); - return result; -} - - -public LtfEntry *LtfPrintF(Ltf *l,I1 *src,...) -{ - LtfEntry *result; - I1 *buf=SPrintFJoin(NULL,src,argc,argv); - result=LtfPutS(l,buf); - Free(buf); - return result; -} - -public void LtfSetMax(U8 i) -{ - Ltf *l=Fs->cur_ltf; - l->max_entries=i; -} - -public void LtfSafeInsert(Ltf *l,I1 *st) -{ //This is necessary when hidden text might screw-up - //inserts. It does them all-at-once. - BoolU4 old_preempt=Preempt(OFF); - U8 old_flags=l->flags; - l->flags|=LTFF_NO_CURSOR; - LtfPutS(l,st); - LtfRecalc(l); - l->flags=old_flags; - Preempt(old_preempt); -} - -public void Type(I1 *name) -{ - Ltf *l=LtfRead(name); - EditInsertLtf(Fs->cur_ltf,l); - LtfDel(l); -} - -sys_clipboard_ltf=LtfNew; diff --git a/LT/ADAM/MOUSE.CPZ b/LT/ADAM/MOUSE.CPZ deleted file mode 100644 index 0a61ce8..0000000 --- a/LT/ADAM/MOUSE.CPZ +++ /dev/null @@ -1,189 +0,0 @@ -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); diff --git a/LT/ADAM/TEST.TXZ b/LT/ADAM/TEST.TXZ deleted file mode 100644 index a9263e0..0000000 Binary files a/LT/ADAM/TEST.TXZ and /dev/null differ diff --git a/LT/ADAM/WINDOW.CPZ b/LT/ADAM/WINDOW.CPZ deleted file mode 100644 index 04682a8..0000000 --- a/LT/ADAM/WINDOW.CPZ +++ /dev/null @@ -1,1042 +0,0 @@ -GrBitMap *WIN_base=GrNew(grbase2); -TssStruct *update_screen_tss; - -public void DrawBorder(BoolU4 solid,I8 l,I8 r,I8 t,I8 b,U8 attr,BoolU4 clip_to_window) -{ - I8 i; - solid=solid+(attr<<8); - if (clip_to_window) { - PlotWindowChar(132+solid,l-4,t-1); - PlotWindowChar(134+solid,r+4,t-1); - PlotWindowChar(136+solid,l-4,b+1); - PlotWindowChar(138+solid,r+4,b+1); - for (i=l;i<=r;i=i+4) { - PlotWindowChar(130+solid,i,t-1); - PlotWindowChar(130+solid,i,b+1); - } - for (i=t;i<=b;i=i+1) { - PlotWindowChar(128+solid,l-4,i); - PlotWindowChar(128+solid,r+4,i); - } - } else { - PlotScreenChar(132+solid,l-4,t-1); - PlotScreenChar(134+solid,r+4,t-1); - PlotScreenChar(136+solid,l-4,b+1); - PlotScreenChar(138+solid,r+4,b+1); - for (i=l;i<=r;i=i+4) { - PlotScreenChar(130+solid,i,t-1); - PlotScreenChar(130+solid,i,b+1); - } - for (i=t;i<=b;i=i+1) { - PlotScreenChar(128+solid,l-4,i); - PlotScreenChar(128+solid,r+4,i); - } - } -} - -void DrawTaskBorder() -{ - DrawBorder(Fs==sys_cur_focus_task, - Fs->window_left,Fs->window_right, - Fs->window_top,Fs->window_bottom, - Fs->border_attribute,FALSE); -} - - -#define SC_FIFO_SIZE 64 -I8 sc_fifo_in=0,sc_fifo_out=0; -U8 scan_code_fifo[SC_FIFO_SIZE]; -U8 keyboard_evt_time; - -void Irq01Handler() -{ - keyboard_evt_time=BootTime; - if (Btr(&sys_cur_scan_code,SCf_NEW_KEY)) { - Btr(&sys_cur_raw_scan_code,SCf_NEW_KEY); - scan_code_fifo[sc_fifo_in++ & (SC_FIFO_SIZE-1)]=sys_cur_scan_code|sys_cur_raw_scan_code<<32; - } -} -ext[EXT_IRQ01]=&Irq01Handler; - - -public void RefocusWindow() -{ - TssStruct *tss_focus=sys_cur_focus_task; - if (!tss_focus) { - tss_focus=update_screen_tss->last_tss; - while (tss_focus!=update_screen_tss) { - if (Bt(&tss_focus->task_flags,TSSf_LOCAL_USER)) { - sys_cur_focus_task=tss_focus; - break; - } - tss_focus=tss_focus->last_tss; - } - } -} - - -I8 old_ipx=-1000,old_ipy=-1000,old_ipz=0; -BoolU4 old_ip_lb=FALSE,old_ip_rb=FALSE; -U8 left_ip_double_time=0; -BoolU4 left_double=FALSE,left_down_sent=FALSE; -U8 right_ip_double_time=0; -BoolU4 right_double=FALSE,right_down_sent=FALSE; -public U8 double_click_mS=350; - -I8 win_min_refresh=5, - win_max_refresh=75, - win_updates=0; -double win_refresh, - win_refresh_duty_cycle=0.50, - win_average_swap_time; -U8 win_refresh_start,win_refresh_end; - - -void PlotInputPointer() -{ - if (ip_on && ip_pointer_type!=IP_NULL) { - WIN_base->color=ROP_XOR+GR_WHITE; - GrLine4(WIN_base,ipx,ipy,ipx+10,ipy+10); - GrLine4(WIN_base,ipx+2,ipy+1,ipx+11,ipy+10); - GrLine4(WIN_base,ipx+1,ipy+2,ipx+10,ipy+11); - GrLine4(WIN_base,ipx,ipy,ipx+5,ipy); - GrLine4(WIN_base,ipx,ipy,ipx,ipy+5); - } -} - - -void UpdateOdes() -{ - I8 i,timeout_jiffies=jiffies+JIFFY_FREQ/win_min_refresh; - double t_desired=ReadSysTimer*1.0/SYS_TIMER_FREQ, - t_initial,interpolation; - Ode *o=Fs->next_ode; - while (o!=&Fs->next_ode) { - o->tolerance=o->tolerance_start; - o->derivative(o,o->t+o->base_t,o->state,o->DstateDt); - for (i=0;in;i++) - o->state_scale[i]=Abs(o->state[i])+Abs(o->DstateDt[i]*o->h)+1e-4; - t_initial=o->t+o->base_t; - MemCpy(o->initial_state,o->state,o->n*sizeof(double)); - do { - while (o->t+o->base_ttimeout_jiffies) - o->base_t=t_desired-o->t; - } - if (interpolation=(o->t+o->base_t-t_initial)) - interpolation=(t_desired-t_initial)/interpolation; - else - interpolation=1.0; - if (interpolation>.1 || o->tolerance<1e-64) - break; - else { - MemCpy(o->state,o->initial_state,sizeof(double)*o->n); - o->t=t_initial-o->base_t; - o->tolerance/=10; - } - } while (TRUE); - for (i=0;in;i++) - o->state[i]=(o->state[i]-o->initial_state[i])*interpolation+o->initial_state[i]; - o->t=t_desired-o->base_t; - o=o->next; - } -} - -void EndCurSong() -{ - Sound(0); - Exit; -} - -void CurSongTsk() -{ - Fs->end_task_cb=&EndCurSong; - while (TRUE) - Play(cur_song); -} - -U8 WinPointAndSleep() -{ - U8 timeout_jiffies; - I8 p1,p2; - TssStruct *tss_focus=sys_cur_focus_task; - BoolU4 old_preempt=Preempt(OFF); - U8 cmd=0,dd; - LTDate temp,ip_move_time,u; - U8 refresh_time,total_time,new_time; - double average_swap_time; - - new_time=ReadSysTimer; - if (win_updates) { - total_time=new_time-win_refresh_start; - win_refresh=SYS_TIMER_FREQ*1.0/total_time; - refresh_time=win_refresh_end-win_refresh_start; - if (sys_swap_cnter) { - average_swap_time=Exp((new_time-win_refresh_end)*1.0/sys_swap_cnter); - win_refresh_duty_cycle*=win_average_swap_time/average_swap_time; - if (win_refresh_duty_cycle>0.9) - win_refresh_duty_cycle=0.9; - if (win_refresh_duty_cycle<0.1) - win_refresh_duty_cycle=0.1; - win_average_swap_time=average_swap_time; - - win_refresh*=win_refresh_duty_cycle*total_time/refresh_time; - } - if (win_refreshwin_max_refresh) win_refresh=win_max_refresh; - } else //first time - win_refresh=win_min_refresh; - win_refresh_start=new_time; - timeout_jiffies=jiffies+JIFFY_FREQ/win_refresh; - - if (tss_focus) { - while (sc_fifo_in!=sc_fifo_out) { - p2=scan_code_fifo[sc_fifo_out++ & (SC_FIFO_SIZE-1)]; - p1=TranslateScanCode(p2); - if (p2 & SCF_KEY_UP) { - QueueMsg(tss_focus,0, - MSG_KEY_UP,p1,p2,0); - cmd=MSG_KEY_UP; - } else { - QueueMsg(tss_focus,0, - MSG_KEY_DOWN,p1,p2,0); - cmd=MSG_KEY_DOWN; - } - } - - p1=ipx-tss_focus->window_left>>2*FONT_WIDTH; - p2=ipy-tss_focus->window_top*FONT_HEIGHT; - if (old_ipx!=ipx || old_ipy!=ipy) { - QueueMsg(tss_focus,0, - MSG_IP_MOVE,p1,p2,0); - cmd=MSG_IP_MOVE; - } - //TODO queue msg for ipz? - if (left_ip_double_time) { - if (jiffies>left_ip_double_time) { - if (left_double) { - if (!left_down_sent) { - QueueMsg(tss_focus,0, - MSG_IP_L_D_DOWN,p1,p2,0); - left_down_sent=TRUE; - cmd=MSG_IP_L_D_DOWN; - } - if (!ip_lb) { - QueueMsg(tss_focus,0, - MSG_IP_L_D_UP,p1,p2,0); - left_ip_double_time=0; - cmd=MSG_IP_L_D_UP; - } - } else { - if (!left_down_sent) { - QueueMsg(tss_focus,0, - MSG_IP_L_DOWN,p1,p2,0); - left_down_sent=TRUE; - cmd=MSG_IP_L_DOWN; - } - if (!ip_lb) { - QueueMsg(tss_focus,0, - MSG_IP_L_UP,p1,p2,0); - left_ip_double_time=0; - cmd=MSG_IP_L_UP; - } - } - } else { - if (ip_lb && !ip_lb_last) { - left_ip_double_time=jiffies; - left_double=TRUE; - } - } - } else { - if (Bt(&tss_focus->crt_flags,CRTf_NO_DOUBLE_CLICK)) { - if (ip_lb && !ip_lb_last) { - QueueMsg(tss_focus,0, - MSG_IP_L_DOWN,p1,p2,0); - cmd=MSG_IP_L_DOWN; - } else if (!ip_lb && ip_lb_last) { - QueueMsg(tss_focus,0, - MSG_IP_L_UP,p1,p2,0); - cmd=MSG_IP_L_UP; - } - } else { - if (ip_lb && !ip_lb_last) { - left_double=FALSE; - left_down_sent=FALSE; - left_ip_double_time=jiffies+ - double_click_mS*JIFFY_FREQ/1000; - } - } - } - - if (right_ip_double_time) { - if (jiffies>right_ip_double_time) { - if (right_double) { - if (!right_down_sent) { - QueueMsg(tss_focus,0, - MSG_IP_R_D_DOWN,p1,p2,0); - right_down_sent=TRUE; - cmd=MSG_IP_R_D_DOWN; - } - if (!ip_rb) { - QueueMsg(tss_focus,0, - MSG_IP_R_D_UP,p1,p2,0); - right_ip_double_time=0; - cmd=MSG_IP_R_D_UP; - } - } else { - if (!right_down_sent) { - QueueMsg(tss_focus,0, - MSG_IP_R_DOWN,p1,p2,0); - right_down_sent=TRUE; - cmd=MSG_IP_R_DOWN; - } - if (!ip_rb) { - QueueMsg(tss_focus,0, - MSG_IP_R_UP,p1,p2,0); - right_ip_double_time=0; - cmd=MSG_IP_R_UP; - } - } - } else { - if (ip_rb && !ip_rb_last) { - right_ip_double_time=jiffies; - right_double=TRUE; - } - } - } else { - if (Bt(&tss_focus->crt_flags,CRTf_NO_DOUBLE_CLICK)) { - if (ip_rb && !ip_rb_last) { - QueueMsg(tss_focus,0, - MSG_IP_R_DOWN,p1,p2,0); - cmd=MSG_IP_R_DOWN; - } else if (!ip_rb && ip_rb_last) { - QueueMsg(tss_focus,0, - MSG_IP_R_UP,p1,p2,0); - cmd=MSG_IP_R_UP; - } - } else { - if (ip_rb && !ip_rb_last) { - right_double=FALSE; - right_down_sent=FALSE; - right_ip_double_time=jiffies+ - double_click_mS*JIFFY_FREQ/1000; - } - } - } - } else { - RefocusWindow; - if (!sys_cur_focus_task) - sc_fifo_out=sc_fifo_in; - } - ip_lb_last=ip_lb; - ip_rb_last=ip_rb; - old_ip_lb=ip_lb; - old_ip_rb=ip_rb; - old_ipx=ipx; - old_ipy=ipy; - old_ipz=ipz; - if (ip_pointer_type==IP_MOUSE) { - ip_has_wheel=mouse_has_wheel; - PollMouse; //Not all computers IRQ's work - if (mouse_evt) { - ipx=mxx; - ipy=myy; - ipz=mzz; - ip_lb=mouse_buttons[0]; - ip_rb=mouse_buttons[1]; - mouse_evt=FALSE; - } - } else if (ip_pointer_type==IP_JOYSTICK0) { - ip_has_wheel=FALSE; - PollJoystick; - ipx=joycx; - ipy=joycy; - ipz=0; //TODO - ip_lb=joyb[0]; - ip_rb=joyb[1]; - } else if (ip_pointer_type==IP_NULL && mouse_installed) - ip_pointer_type=IP_MOUSE; - - dd=(old_ipx-ipx)*(old_ipx-ipx)+ - (old_ipy-ipy)*(old_ipy-ipy); - if (dd) { - ip_move_time=BootTime; - temp=ip_move_time-last_ip_move_time; - last_ip_move_time=ip_move_time; - ip_speed=Sqrt(dd)/temp*(0x10000*JIFFY_FREQ*SYS_TIMER0_PERIOD); - } - - iptx=(ipx/FONT_WIDTH)<<2; - ipty=ipy/FONT_HEIGHT; - - if (sys_cur_focus_task) - Btr(&sys_cur_focus_task->task_flags,TSSf_HAS_SONG); - - GrUpdateScreen(grbase,grbase2,textbase); - - if (sys_cur_focus_task) { - if (!Bt(&sys_cur_focus_task->task_flags,TSSf_HAS_SONG)) { - AFree(cur_song); - cur_song=NULL; - } - } - if (cur_song) { - if (!cur_song_tss) - cur_song_tss=Spawn(&CurSongTsk); - } else { - if (cur_song_tss) { - Kill(cur_song_tss); - cur_song_tss=NULL; - } - } - - Preempt(old_preempt); - - win_updates++; - win_refresh_end=ReadSysTimer; - sys_swap_cnter=0; - while (jiffiestask_flags,TSSf_INPUT_FILTER_TASK); - old_filter=Bts(&Fs->parent_tss->task_flags,TSSf_FILTER_INPUT); - while (TRUE) { - tempc=Fs->next_servant_cmd; - while (tempc!=&Fs->next_servant_cmd && - !Bt(&tempc->flags,TSSCf_TEXT)) - tempc=tempc->next; - if (tempc!=&Fs->next_servant_cmd) { - RemQue(tempc); - st=tempc->data; - AFree(tempc); - Preempt(ON); - try - ExecuteString(st); - catch - Fs->catch_except=TRUE; - Preempt(OFF); - AFree(st); - } else - break; - } - Fs->parent_tss->input_filter_tss=Fs->input_filter_tss; - if (!old_filter) - Btr(&Fs->parent_tss->task_flags,TSSf_FILTER_INPUT); -} - -U8 MsgJoin(TssCmdStruct **tempc,I8 *param1,I8 *param2,TssStruct *tss=NULL) -{ - U8 result; - TssCmdStruct *tempc1=*tempc; - if (!tss) tss=Fs; - while (tempc1!=&tss->next_servant_cmd && Bt(&tempc1->flags,TSSCf_TEXT)) - tempc1=tempc1->next; - if (tempc1!=&tss->next_servant_cmd) { - *param1=tempc1->p1; - *param2=tempc1->p2; - result=tempc1->code; - tempc1=tempc1->next; - } else { - *param1=0; - *param2=0; - result=0; - } - *tempc=tempc1; - return result; -} - -public U8 PeekMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL) -{ - U8 result; - TssCmdStruct *tempc; - BoolU4 old_preempt=Preempt(OFF); - I8 p1,p2; - if (!tss) tss=Fs; - *param1=0; - *param2=0; - tempc=tss->next_servant_cmd; - while (TRUE) { - result=MsgJoin(&tempc,&p1,&p2,tss); - if (Bt(&mask,result)) { - *param1=p1; - *param2=p2; - break; - } - if (!result) - break; - } - if (!result && tss->parent_tss) { - if (tss->parent_tss->popup_tss==tss) - result=PeekMsg(param1,param2,mask,tss->parent_tss); - } - Preempt(old_preempt); - if (old_preempt) - SwapInNext; - return result; -} - -public U8 GetMsgNoWait(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL) -{ - U8 result,old_flags=GetFlags; - TssCmdStruct *tempc,*tempc1,*tempc2; - I8 p1,p2; - U8 my_GetMsg(LTChnl *chnl,I8 *p1,I8 *p2); - BoolU4 old_preempt,cont; - if (!tss) tss=Fs; - *param1=0; - *param2=0; - - do { - cont=FALSE; - if (tss->rmt_chnl) { - if (jiffies>=tss->rmt_chnl->null_msg_jiffy) { - if (my_GetMsg=ext[EXT_RMT_GETMSG]) { - if (result=my_GetMsg(tss->rmt_chnl,&p1,&p2)) { - if (Bt(&mask,result)) { - *param1=p1; - *param2=p2; - return result; - } else - cont=TRUE; - } - } - } - } - } while (cont); - - old_preempt=Preempt(OFF); - while (TRUE) { - tempc=tss->next_servant_cmd; - tempc1=tempc; - result=MsgJoin(&tempc,&p1,&p2,tss); - while (tempc1!=tempc) { - Cli;//TODO: this would seem to get stuck if a non_input was encntered - if (!Bt(&tempc1->flags,TSSCf_TEXT)) { - tempc2=tempc1->next; - RemQue(tempc1); - AFree(tempc1); - tempc1=tempc2; - } else - tempc1=tempc1->next; - SetFlags(old_flags); - } - if (!result) - break; - if (Bt(&mask,result)) { - *param1=p1; - *param2=p2; - break; - } - } - if (!result && tss->parent_tss) { - if (tss->parent_tss->popup_tss==tss) - result=GetMsgNoWait(param1,param2,mask,tss->parent_tss); - } - Preempt(old_preempt); - if (old_preempt) - SwapInNext; - return result; -} - -public U8 FlushMsgs(TssStruct *tss=NULL) -{ - U8 result=0,p1,p2; - while (GetMsgNoWait(&p1,&p2,tss)) - result++; - return result; -} - -public U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL) -{ - U8 result; - if (!tss) tss=Fs; - Bts(&tss->task_flags,TSSf_IDLE); - while (!(result=GetMsgNoWait(param1,param2,mask,tss))) - SwapInNext; - Btr(&tss->task_flags,TSSf_IDLE); - return result; -} - -public BoolU4 WindowToTop(TssStruct *tss) -{ - BoolU4 result=FALSE,old_flags=GetFlags; - TssStruct *next,*last; - //REMOVE - Cli; - if (update_screen_tss->last_tss!=tss) { - next=tss->next_tss; - last=tss->last_tss; - next->last_tss=last; - last->next_tss=next; - AddTaskToQueue(tss,update_screen_tss); - result=TRUE; - } - if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) - sys_cur_focus_task=tss; - SetFlags(old_flags); - return result; -} -ext[EXT_WINDOW_TO_TOP]=&WindowToTop; - -void SetWindowHor(TssStruct *tss,I8 i,I8 j) -{ - I8 d=j-i; - if (d<0) d=0; - if (i>=tss->crt_width) { - i=tss->crt_width-4; - j=i+d; - } - if (j<0) { - j=0; - i=j-d; - } - if (i>j) { - if (i>0) - j=i; - else - i=j; - } - if (tss->window_left!=i || tss->window_right!=j) { - Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED); - Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2); - } - tss->window_left=i; - tss->window_right=j; -} - -void SetWindowVert(TssStruct *tss,I8 i,I8 j) -{ - I8 d=j-i; - if (d<0) d=0; - if (i>=tss->crt_height) { - i=tss->crt_height-1; - j=i+d; - } - if (j<=0) { - j=1; - i=j-d; - } - if (i>j) { - if (i>=0) - j=i; - else - i=j; - } - if (tss->window_top!=i || tss->window_bottom!=j) { - Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED); - Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2); - } - tss->window_top=i; - tss->window_bottom=j; -} - -BoolU4 SetCursorPosition(TssStruct *tss,I8 iptx,I8 ipty,BoolU4 set_cursor=TRUE) -{ - Ltf *l; - if (tss->window_top<=ipty && tss->window_bottom>=ipty && - tss->window_left<=iptx && tss->window_right>=iptx) { - if (tss->cur_ltf) { - l=tss->cur_ltf; - if (set_cursor) { - l->x=iptx-tss->window_left+l->line_start_col; - l->y=ipty-tss->window_top+l->cur_top_line_num; - LtfUpdateWindowJoin(l,FALSE,FALSE,FALSE,TRUE); - } - WindowToTop(tss); - return TRUE; - } - WindowToTop(tss); - return TRUE; - } - return FALSE; -} - -void UpdateDerivedTssValues(TssStruct *tss) -{ - tss->window_pixel_left=FONT_WIDTH*tss->window_left>>2; - tss->window_pixel_right=FONT_WIDTH*(tss->window_right+4)>>2-1; - tss->window_pixel_top=FONT_HEIGHT*tss->window_top; - tss->window_pixel_bottom=FONT_HEIGHT*(tss->window_bottom+1)-1; - tss->window_border_pixel_left=tss->window_pixel_left-FONT_WIDTH; - tss->window_border_pixel_right=tss->window_pixel_right+FONT_WIDTH; - tss->window_border_pixel_top=tss->window_pixel_top-FONT_HEIGHT; - tss->window_border_pixel_bottom=tss->window_pixel_bottom+FONT_HEIGHT; -} - -BoolU4 IsPixelCovered(TssStruct *tss,I8 x,I8 y) -{ - if (tss==update_screen_tss) return FALSE; - tss=tss->next_tss; - while (tss!=update_screen_tss) { - if (Bt(&tss->crt_flags,CRTf_SHOW)) { //no I2 circuit logic - if (x>=tss->window_border_pixel_left) { - if (x<=tss->window_border_pixel_right) { - if (y>=tss->window_border_pixel_top) { - if (y<=tss->window_border_pixel_bottom) { - return TRUE; - }}}}} - tss=tss->next_tss; - } - return FALSE; -} - -public void MaximizeWindow() -{ - Fs->window_right=SCREEN_COLS<<2-8; - Fs->window_left=4; - Fs->window_top=2; - Fs->window_bottom=SCREEN_LINES-2; - UpdateDerivedTssValues(Fs); -} - -void WallPaper() -{ - I8 p1,min_stack_size=MAX_I8,l=grheight/FONT_HEIGHT-1,um; - TssStruct *tss; - LTDate ltdt; - I1 buf[256]; - BoolU4 stk_aligned=TRUE; - - um=UnusedSysMem; - ltdt=GetCurTimeLTDate; - SPrintF(buf,"%h2D %h4T Refresh:%4.1f Mem:%08tX" - ltdt.date,ltdt.time,win_refresh,um); - buf[SCREEN_COLS]=0; - if (um>sys_heap_limit) - PlotScreenString(buf,RED,0,0); //Corruption - else - PlotScreenString(buf,WHITE,0,0); - - tss=Fs; - do { - p1=tss->esp-tss->stack_base; - if (tss->esp&3) stk_aligned=FALSE; - if (p1next_tss; - } while (tss!=Fs); - - SPrintF(buf,"Disk:%08tX Stk:%08tX %c compiled_lines=%d", - disk_status_display,min_stack_size,(stk_aligned)?CH_SPACE:'!', - compiled_lines); - buf[SCREEN_COLS]=0; - PlotScreenString(buf,WHITE,0,l--); - - SPrintF(buf,"progress1=%016tX progress2=%016tX", - progress1,progress2); - buf[SCREEN_COLS]=0; - PlotScreenString(buf,WHITE,0,l--); - - SPrintF(buf,"progress3=%016tX progress4=%016tX", - progress3,progress4); - buf[SCREEN_COLS]=0; - PlotScreenString(buf,WHITE,0,l--); -} - - -void WindowManagerTsk() -{ - TssStruct *tss=Fs; - I8 x,y,cmd; - Ltf *l; - LtfEntry *ll; - I8 my_ipz=0; - - Preempt(OFF); - InitCrt; - Fs->window_left=0; - Fs->window_right=Fs->crt_width-4; - Fs->window_top=0; - Fs->window_bottom=Fs->crt_height-1; - UpdateDerivedTssValues(Fs); - Fs->update_window=&WallPaper; - - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - Raw(OFF); - while (TRUE) { - UpdateDerivedTssValues(tss); - do { - if (Btr(&sys_flags,SYSf_TASK_LINKS_ALTERED)) - tss=Fs->last_tss; - else - tss=tss->last_tss; - if (tss==Fs) - WinPointAndSleep; - } while (tss==Fs || !Bt(&tss->crt_flags,CRTf_SHOW)); - UpdateDerivedTssValues(tss); - - if (!old_ip_lb && ip_lb && !ip_inhibit_win_operations) { - if (SetCursorPosition(tss,iptx,ipty)) { - if (tss->cur_ltf) { - l=tss->cur_ltf; - ll=l->cur_entry; - if (ll!=l) { - if (ll->btype==LTFT_LINK || - ll->btype==LTFT_CHECK_BOX || - (ll->flags & - (LTFLF_LEFT_CB | LTFLF_LEFT_EXP | LTFLF_LEFT_MACRO))) - ll->flags|=LTFLF_SOLID_BORDER; - } - } - old_ip_lb=TRUE; - } - } - if (old_ip_lb && !ip_lb&& !ip_inhibit_win_operations) { - if (ipty==tss->window_top-1) { - if (iptx>=tss->window_left && iptxwindow_left+16) { - if (Bt(&tss->crt_flags,CRTf_HAS_MENU)) { - QueueMsg(tss,0,MSG_KEY_DOWN,0,SC_GUI,0); - old_ip_lb=FALSE; - } - } else if (iptx>=tss->window_right-8 && iptx<=tss->window_right) { - if (Bt(&tss->crt_flags,CRTf_HAS_CLOSE_WINDOW)) { - if (tss->cur_ltf) - QueueMsg(tss,0,MSG_KEY_DOWN,CH_CTRLQ,0,0); - else - Bts(&tss->task_flags,TSSf_KILL_TASK); - old_ip_lb=FALSE; - } - } - } else if (SetCursorPosition(tss,iptx,ipty,FALSE)) { - if (tss->cur_ltf) { - do cmd=WinPointAndSleep; - while (cmd!=MSG_IP_L_UP && cmd!=MSG_IP_L_D_UP); - if (cmd==MSG_IP_L_UP) { - l=tss->cur_ltf; - ll=l->cur_entry; - if (ll!=l) { - if (ll->btype==LTFT_LINK || ll->btype==LTFT_TREE || - ll->btype==LTFT_CHECK_BOX || ll->flags & LTFLF_TREE || - ll->btype==LTFT_HIDE_START || - (ll->flags & - (LTFLF_LEFT_CB | LTFLF_LEFT_MACRO | LTFLF_LEFT_EXP))) - QueueMsg(tss,0,MSG_KEY_DOWN,CH_SPACE,0,0); - } - } else - QueueMsg(tss,0,MSG_KEY_DOWN,CH_ESC,0,0); - } - old_ip_lb=FALSE; - } - } - - if (ip_has_wheel) { - if (my_ipz!=ipz && tss==sys_cur_focus_task&& !ip_inhibit_win_operations) { - tss->scroll_y+=ipz-my_ipz; - my_ipz=ipz; - if (tss->scroll_y<0) - tss->scroll_y=0; - if (tss->scroll_y>tss->window_bottom+1-tss->window_top) - tss->scroll_y=tss->window_bottom+1-tss->window_top; - Bts(&tss->crt_flags,CRTf_SCROLL_Y); - if (tss->cur_ltf) { - while (Bt(&tss->crt_flags,CRTf_SCROLL_Y)) - WinPointAndSleep; - } - SetCursorPosition(tss, - ((tss->window_left+tss->window_right)>>1) & -4, - (tss->window_top+tss->window_bottom)>>1); - } - } - if (old_ip_rb && !ip_rb&& !ip_inhibit_win_operations) { - if (SetCursorPosition(tss,iptx,ipty,FALSE)) { - if (tss->cur_ltf) { - do cmd=WinPointAndSleep; - while (cmd!=MSG_IP_R_UP && cmd!=MSG_IP_R_D_UP); - if (cmd==MSG_IP_R_UP) { - if (SetCursorPosition(tss,iptx,ipty)) { - if (tss->cur_ltf) { - l=tss->cur_ltf; - ll=l->cur_entry; - if (ll!=l) { - if (ll->btype==LTFT_LINK || - (ll->flags & - (LTFLF_RIGHT_CB | LTFLF_RIGHT_MACRO | LTFLF_RIGHT_EXP))) - QueueMsg(tss,0,MSG_KEY_DOWN,CH_CR,0,0); - } - } - } - } else - QueueMsg(tss,0,MSG_KEY_DOWN,CH_CTRLQ,0,0); - } - old_ip_rb=FALSE; - } - } - if (ip_lb && !old_ip_lb&& !ip_inhibit_win_operations) { - if (tss->window_top==ipty+1 && - iptx>=tss->window_left-4 && iptx<=tss->window_right+4) { - if (iptx>=tss->window_left && iptxwindow_left+16 && - Bt(&tss->crt_flags,CRTf_HAS_MENU)) - old_ip_lb=TRUE; - else if (iptx>=tss->window_right-8 && iptx<=tss->window_right && - Bt(&tss->crt_flags,CRTf_HAS_CLOSE_WINDOW)) - old_ip_lb=TRUE; - else { - x=iptx-tss->window_left; - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - SetWindowHor(tss,iptx-x,tss->window_right+(iptx-x)-tss->window_left); - SetWindowVert(tss,ipty+1,tss->window_bottom+ipty+1-tss->window_top); - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - WindowToTop(tss); - UpdateDerivedTssValues(tss); - WinPointAndSleep; - } - old_ip_lb=FALSE; - } - } - if (!Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED) && tss->window_left==iptx+4 && - (ipty>=tss->window_top-1 && ipty<=tss->window_bottom+1)) { - y=ipty-tss->window_top; - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - SetWindowHor(tss,iptx+4,tss->window_right+iptx+4-tss->window_left); - SetWindowVert(tss,ipty-y,tss->window_bottom+(ipty-y)-tss->window_top); - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - WindowToTop(tss); - UpdateDerivedTssValues(tss); - WinPointAndSleep; - } - old_ip_lb=FALSE; - } - if (!Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED) && - tss->window_right+4==iptx && tss->window_bottom+1==ipty) { - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - SetWindowHor(tss,tss->window_left,iptx-4); - SetWindowVert(tss,tss->window_top,ipty-1); - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - WindowToTop(tss); - UpdateDerivedTssValues(tss); - WinPointAndSleep; - } - old_ip_lb=FALSE; - } - if (!Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED) && - tss->window_bottom==ipty-1 && - (iptx>=tss->window_left && iptx<=tss->window_right)) { - if (iptx==(tss->scroll_x+tss->window_left)) { - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - tss->scroll_x=iptx-tss->window_left; - Bts(&tss->crt_flags,CRTf_SCROLL_X); - WinPointAndSleep; - SetCursorPosition(tss, - ((tss->window_left+tss->window_right)>>1) & -4, - (tss->window_top+tss->window_bottom)>>1); - } - } else { - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - SetWindowVert(tss,tss->window_top,ipty-1); - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - WindowToTop(tss); - UpdateDerivedTssValues(tss); - WinPointAndSleep; - } - } - old_ip_lb=FALSE; - } - if (!Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED) && - tss->window_right==iptx-4 && - (ipty>=tss->window_top && ipty<=tss->window_bottom)) { - if (ipty==(tss->scroll_y+tss->window_top)) { - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - tss->scroll_y=ipty-tss->window_top; - Bts(&tss->crt_flags,CRTf_SCROLL_Y); - WinPointAndSleep; - SetCursorPosition(tss, - ((tss->window_left+tss->window_right)>>1) & -4, - (tss->window_top+tss->window_bottom)>>1); - } - } else { - while (ip_lb && !Bt(&sys_flags,SYSf_TASK_LINKS_ALTERED)) { - SetWindowHor(tss,tss->window_left,iptx-4); - Bts(&sys_flags,SYSf_CLEAR_SCREEN_TEXT); - WindowToTop(tss); - UpdateDerivedTssValues(tss); - WinPointAndSleep; - } - } - old_ip_lb=FALSE; - } - } - } -} - -public I8 GetChar(U8 *scancode=NULL) -{ //waits for key with nonzero ASCII - U8 ch,sc; - - void my_PutChar(LTChnl *chnl,I8 ch); - void my_PutS(LTChnl *chnl,I1 *st); - - if (Fs->rmt_chnl) { - my_PutS=ext[EXT_RMT_PUTS]; - my_PutS(Fs->rmt_chnl,"$$FU$$$$BU$$"); - } else - PutS("$$FU$$$$BU$$"); - do GetMsg(&ch,&sc,(1<rmt_chnl) { - my_PutChar=ext[EXT_RMT_PUTCHAR]; - my_PutChar(Fs->rmt_chnl,ch); - } else - PutChar(ch); - if (Fs->rmt_chnl) { - my_PutS=ext[EXT_RMT_PUTS]; - my_PutS(Fs->rmt_chnl,"$$FG$$$$BG$$"); - } else - PutS("$$FG$$$$BG$$"); - return ch; -} - -public I8 GetCharNoEcho(U8 *scancode=NULL) -//use GetKey() unless you need the scancode -{ //waits for key with nonzero ASCII - U8 ch,sc; - do GetMsg(&ch,&sc,(1<=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; +} + +BoolU8 MyPutS(I1 *st) +{ + nounusedwarn st; + return FALSE; +} + +AddKeyDev(&MyPutKey,&MyPutS,0x20000000); + +MPStart; +Cd("/LT/Adam");; +#include "PicWords2" +#include "HOME/PicWords3" +Cd("/LT/Utils/Boot");; +#include "InsBoot" +Cd("/LT/Utils");; +#include "Disk20" +#include "Diff" +#include "Grep" +#include "Merge" +#include "S2T" +#include "IDE" +#include "LinkChk" +#include "HeapLog" +#include "ListFile" +LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man() +LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man() +LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man() + + +void StartUpTsks() +{ + I1 buf[80]; + TssStruct *tss,*tss1; + + InitLocalTask; //needed for disk access + Preempt(ON); //off by default + Silent(ON); //no output to screen + + try { + tss1=SpawnUser; + tss=SpawnUser; + WinToTop(tss1); + WinTileVert; + + PopUp("#include \"::/LT/Doc/StartSong.CPZ\";"); + + SPrintF(buf,"Boot Time:%h17Ts\r\n",BootTime); + AdamLog(buf); + XTalk(tss1,"#include \"DoIt\";\r"); + + WsInit("/LT"); + WordStat; + } catch + CatchAll; +} + +//This must be spawned because start-up files +// may invoke the Adam() cmd. +Spawn(&StartUpTsks,"Spawn Users"); +PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time); diff --git a/LT/Accts/Fault.CPZ b/LT/Accts/Fault.CPZ new file mode 100644 index 0000000..d021567 --- /dev/null +++ b/LT/Accts/Fault.CPZ @@ -0,0 +1,51 @@ +/* When a fault occurs, a child process is +spawned running this file and the parent +gets suspended. You can modify what gets +displayed during faults to assist debugging. + +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. +*/ + +TssStruct *tss=Fs->parent_tss; +void **rsp_ptr=&tss->rsp,*rsp=tss->rsp, + *rbp_ptr=&tss->rbp,*rbp=tss->rbp, + *rip_ptr=&tss->rip,*rip=tss->rip; + +switch (tss->fault_num) +{ + case 0: //if divide except + //push rip as param to ThrowDivide + rsp-=8; + *rsp_ptr=rsp; + rsp[1]=rip; + *rip_ptr=&ThrowDivide; + Btr(&tss->task_flags,TSSf_SUSPENDED); + Exit; + case 0x10: + rsp-=8; + *rsp_ptr=rsp; + rsp[1]=rip; + *rip_ptr=&ThrowFloating; + Btr(&tss->task_flags,TSSf_SUSPENDED); + Exit; +} + +/* +Raw(ON); +coutln "Faulting TSS:",tss," IRQ#",tss->fault_num; +PrintF("Fault Location:%P\r\n",*rip); +Raw(OFF); +*/ + +UseConsoleLtf(NULL); +Bts(&Fs->crt_flags,CRTf_SHOW); + +coutln "Faulting TSS:",tss," IRQ#",tss->fault_num; +CallerRep(rbp,tss); +StackRep(rsp); +coutln "$$LK,\"See HOME/Fault.CPZ\",\"FI:HOME/Fault.CPZ\"$$"; +Dasm(rip-0x20,0x20); + + diff --git a/LT/Accts/Favor.MUZ b/LT/Accts/Favor.MUZ new file mode 100644 index 0000000..4ed6e52 --- /dev/null +++ b/LT/Accts/Favor.MUZ @@ -0,0 +1,16 @@ +$WW,1$This is a handy file which can be accessed with CTRL-SHIFT-F, known as a favorites file. I use it for links and "TODO" type stuff in my account. + +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. + +$LK+S,"Goto OS Systext","FA:::/LT/OSMain/SysText.CPZ,OS_SYSTEXT"$ +$LK,"Goto Compiler Systext","FA:::/LT/Compiler/CmpInit.CPZ,COMPILE_SYSTEXT"$ + +$LK,"::/LT/Doc/Help.TXZ","FI:::/LT/Doc/Help.TXZ"$ +$LK,"::/LT/Doc/GuideLines.TXZ","FI:::/LT/Doc/GuideLines.TXZ"$ +$LK,"::/LT/Doc/OSGlossary.GLZ","FI:::/LT/Doc/OSGlossary.GLZ"$ +$LK,"::/LT/Doc/Tips.TXZ","FI:::/LT/Doc/Tips.TXZ"$ +$LK,"::/LT/Doc/Dollar.TXZ","FI:::/LT/Doc/Dollar.TXZ"$ + +$FG,5$ \ No newline at end of file diff --git a/LT/Accts/Install/Adam3.APZ b/LT/Accts/Install/Adam3.APZ new file mode 100644 index 0000000..f90645e --- /dev/null +++ b/LT/Accts/Install/Adam3.APZ @@ -0,0 +1,181 @@ +//Change anything you want in this +//account file or others. + +//Set Time Zone +local_time_offset=0*60*60*LTDATE_FREQ; + +//$AN,"","mouse_move_scale"$adjust these to set mouse move scale +mxx_scale=0.5; +myy_scale=0.5; +mzz_scale=1.0; //wheel + +//don't change these +mxx_prescale=mxx/mxx_scale; +myy_prescale=myy/myy_scale; +mzz_prescale=mzz/mzz_scale; + +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,ltdt); +} + + + +BoolU8 MyPutKey(I8 ch,U8 sc) +{ //ch=ASCII; sc=scancode + +//You can customize keys. This routine +//is called before the main editor +//key handler $LK,"LtfPutKeyExt","MN:LtfPutKeyExt"$(). +//You can intercept any key. + +//Return TRUE if you completely +//handled the key. + + nounusedwarn ch; + U8 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; +} + +BoolU8 MyPutS(I1 *st) +{ + nounusedwarn st; + return FALSE; +} + +AddKeyDev(&MyPutKey,&MyPutS,0x20000000); + +Cd("/LT/Adam");; +#include "PicWords2" +#include "HOME/PicWords3" +Cd("/LT/Utils/Boot");; +#include "InsBoot" +Cd("/LT/Utils");; +#include "Disk20" +#include "Diff" +#include "Grep" +#include "Merge" +#include "S2T" +#include "IDE" +#include "LinkChk" +#include "HeapLog" +#include "ListFile" +LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man() +LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man() +LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man() + + +void StartUpTsks() +{ + I1 buf[80]; + TssStruct *tss,*tss1; + + InitLocalTask; //needed for disk access + Preempt(ON); //off by default + Silent(ON); //no output to screen + + try { + tss1=SpawnUser; + tss=SpawnUser; + WinToTop(tss1); + WinTileVert; + + PopUp("#include \"::/LT/Doc/StartSong.CPZ\";"); + + SPrintF(buf,"Boot Time:%h17Ts\r\n",BootTime); + AdamLog(buf); + XTalk(tss1,"#include \"DoIt\";\r"); + + WsInit(""); +// WordStat; + } catch + CatchAll; +} + +//This must be spawned because start-up files +// may invoke the Adam() cmd. +Spawn(&StartUpTsks,"Spawn Users"); +PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time); diff --git a/LT/Accts/Install/DoIt.CPZ b/LT/Accts/Install/DoIt.CPZ new file mode 100644 index 0000000..85d31f3 Binary files /dev/null and b/LT/Accts/Install/DoIt.CPZ differ diff --git a/LT/Accts/Install/User.CPZ b/LT/Accts/Install/User.CPZ new file mode 100644 index 0000000..f14a113 Binary files /dev/null and b/LT/Accts/Install/User.CPZ differ diff --git a/LT/Accts/PicWords3.APZ b/LT/Accts/PicWords3.APZ new file mode 100644 index 0000000..649cfc5 --- /dev/null +++ b/LT/Accts/PicWords3.APZ @@ -0,0 +1,9 @@ +// Create Pictures Here + +void LoadUserPicWords() +{ +//Call $LK,"AddPicWord","MN:AddPicWord"$() +} + + +LoadUserPicWords; diff --git a/LT/Accts/Servant.CPZ b/LT/Accts/Servant.CPZ new file mode 100644 index 0000000..25e03c8 --- /dev/null +++ b/LT/Accts/Servant.CPZ @@ -0,0 +1,11 @@ +/* +This is the startup file for servant tasks. + +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(NULL); +Bts(&Fs->crt_flags,CRTf_SHOW); +//Turn on preemption \ No newline at end of file diff --git a/LT/ACCOUNTS/ADAM3.CPZ b/LT/Accts/Songs/Adam3.APZ similarity index 50% rename from LT/ACCOUNTS/ADAM3.CPZ rename to LT/Accts/Songs/Adam3.APZ index b899615..3ed008b 100644 --- a/LT/ACCOUNTS/ADAM3.CPZ +++ b/LT/Accts/Songs/Adam3.APZ @@ -1,13 +1,19 @@ -/* 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. +//Change anything you want in this +//account file or others. + +//Set Time Zone +local_time_offset=0*60*60*LTDATE_FREQ; + +//$AN,"","mouse_move_scale"$adjust these to set mouse move scale +mxx_scale=0.5; +myy_scale=0.5; +mzz_scale=1.0; //wheel + +//don't change these +mxx_prescale=mxx/mxx_scale; +myy_prescale=myy/myy_scale; +mzz_prescale=mzz/mzz_scale; -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 { @@ -50,15 +56,25 @@ void FillinTime() { LTDate ltdt; ltdt=GetCurTimeLTDate; - PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt.date,ltdt.time); + PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt,ltdt); } -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]; + +BoolU8 MyPutKey(I8 ch,U8 sc) +{ //ch=ASCII; sc=scancode + +//You can customize keys. This routine +//is called before the main editor +//key handler $LK,"LtfPutKeyExt","MN:LtfPutKeyExt"$(). +//You can intercept any key. + +//Return TRUE if you completely +//handled the key. + + nounusedwarn ch; + U8 sc2=sc.u1[0]; + if (sc2>=SC_F1 && sc2<=SC_F10 && (sc & SCF_ALT) && !(sc & SCF_CTRL)) { @@ -71,12 +87,12 @@ BoolU4 My_EditPlugIns(Ltf *l,I8 ch,U8 sc) if ((sc & SCF_SHIFT)) PutS("$$FG LTRED$$"); else - PutS("$$FG RED$$"); + PutS("$$FG,RED$$"); } else if (sc2==SC_F3) { if ((sc & SCF_SHIFT)) PutS("$$FG LTGREEN$$"); else - PutS("$$FG GREEN$$"); + PutS("$$FG,GREEN$$"); } else if (sc2==SC_F4) { if ((sc & SCF_SHIFT)) PutS("$$FG LTBLUE$$"); @@ -105,17 +121,56 @@ BoolU4 My_EditPlugIns(Ltf *l,I8 ch,U8 sc) return FALSE; } +BoolU8 MyPutS(I1 *st) +{ + nounusedwarn st; + return FALSE; +} -Cd("/LT/UTILS");; -#include "BOOTINS" -#include "DBG" -#include "DIFF" -#include "GREP" +AddKeyDev(&MyPutKey,&MyPutS,0x20000000); + +Cd("/LT/Adam");; +#include "PicWords2" +#include "HOME/PicWords3" +Cd("/LT/Utils/Boot");; +#include "InsBoot" +Cd("/LT/Utils");; +#include "Disk20" +#include "Diff" +#include "Grep" +#include "Merge" #include "S2T" -#include "HASHUTIL" #include "IDE" -#include "BMP" +#include "LinkChk" +#include "HeapLog" +#include "ListFile" LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man() -LoadMapFile("::/LT/COMPILE/CMP.MPZ"); //Enable Man() -LoadMapFile("::/LT/ADAM/ADAMASM.MPZ"); //Enable Man() +LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man() +LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man() + +void StartUpTsks() +{ + I1 buf[80]; + TssStruct *tss; + + InitLocalTask; //needed for disk access + Preempt(ON); //off by default + Silent(ON); //no output to screen + + try { + tss=SpawnUser; + WinToTop(tss); + WinTileVert; + + XTalk(tss,"#include \"DoIt\";\r"); + + WsInit(""); + } catch + CatchAll; +} + +//This must be spawned because start-up files +// may invoke the Adam() cmd. +Spawn(&StartUpTsks,"Spawn Users"); +PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time); diff --git a/LT/Accts/Songs/DoIt.CPZ b/LT/Accts/Songs/DoIt.CPZ new file mode 100644 index 0000000..5e83c80 --- /dev/null +++ b/LT/Accts/Songs/DoIt.CPZ @@ -0,0 +1,4 @@ +Cd("::/LT/Apps/MusicOrgan");; +#include "Load";; +JukeBox("Examples"); + diff --git a/LT/Accts/Songs/User.CPZ b/LT/Accts/Songs/User.CPZ new file mode 100644 index 0000000..12601d4 --- /dev/null +++ b/LT/Accts/Songs/User.CPZ @@ -0,0 +1,5 @@ +UseConsoleLtf("User.MUZ"); +PutSysText("ST_USER_STARTUP"); +Type("::/LT/Doc/Help.TXZ"); +Bts(&Fs->crt_flags,CRTf_SHOW); +Preempt(ON); diff --git a/LT/ACCOUNTS/SYSTEM.CPZ b/LT/Accts/System.CPZ similarity index 100% rename from LT/ACCOUNTS/SYSTEM.CPZ rename to LT/Accts/System.CPZ diff --git a/LT/Accts/Tour/DoIt.CPZ b/LT/Accts/Tour/DoIt.CPZ new file mode 100644 index 0000000..02bbd14 --- /dev/null +++ b/LT/Accts/Tour/DoIt.CPZ @@ -0,0 +1 @@ +AutoFile("Tour"); diff --git a/LT/Accts/Tour/Tour.AUZ b/LT/Accts/Tour/Tour.AUZ new file mode 100644 index 0000000..78c2eec --- /dev/null +++ b/LT/Accts/Tour/Tour.AUZ @@ -0,0 +1,37 @@ +public I8 PopUpTourPart() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$FG PURPLE$$LoseThos Tours$$FG$$\r\n\r\n"); + LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 1: The basics\",1$$"); + LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 2: Editing and running programs\",2$$"); + LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 3: Adding macros to your start menu\",3$$"); + LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 4: WordStat\",4$$"); + LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 5: Wow!!\",5$$"); + LtfPutSExt(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/Accts/Tour/Tour1.AUZ"); + break; + case 2: + ExecuteFile("::/LT/Accts/Tour/Tour2.AUZ"); + break; + case 3: + ExecuteFile("::/LT/Accts/Tour/Tour3.AUZ"); + break; + case 4: + ExecuteFile("::/LT/Accts/Tour/Tour4.AUZ"); + break; + case 5: + ExecuteFile("::/LT/Accts/Tour/Tour5.AUZ"); + break; + } +} while (i>=1); diff --git a/LT/Accts/Tour/Tour1.AUZ b/LT/Accts/Tour/Tour1.AUZ new file mode 100644 index 0000000..14dfba2 --- /dev/null +++ b/LT/Accts/Tour/Tour1.AUZ @@ -0,0 +1,105 @@ +//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" +"The syntax is like $$FG,GREEN$$C/C++$$FG$$ except you\r\n" +"don't need $$FG,GREEN$$()$$FG$$ if there are no parameters.\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" +); + +AFPmtStr("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"); + +AFGetKey(SC_GUI); +Sleep(1000); +PopUpOk( +"You can get to the menu/macro/help area\r\n" +"by clicking on the word \"MENU\" in the\r\n" +"title bar.\r\n"); + +PopUpOk( +"$$UL,1$$$$FG,LTBLUE$$Blue Underlined Text are Macros$$FG$$$$UL,0$$\r\n" +"\t$$FG,GREEN$$SPACE BAR$$FG$$\t=Left Mouse\t-->Execute Macro\r\n" +"\r\n\r\n" +"$$UL,1$$$$FG,LTRED$$Red Underlined Text are Links$$FG$$$$UL,0$$\r\n" +"\t$$FG,GREEN$$SPACE BAR$$FG$$\t=Left Mouse\t-->Edit/View Link Doc\r\n" +"\t$$FG,GREEN$$ENTER$$FG$$\t\t=Right Mouse\t-->Link Menu\r\n" +"\r\n\r\n" +"Exiting Documents/Forms\r\n" +"\t$$FG,GREEN$$ESC$$FG$$\t=Left Double Mouse\t-->Save and Exit\r\n" +"\t$$FG,GREEN$$CTRL-Q$$FG$$\t=Right Double Mouse\t-->Abort/Cancel/Quit or Back\r\n" +); + +PopUpOk( +"$$FG,GREEN$$CTRL-ALT-ESC$$FG$$\tSpawn new user shell window\r\n" +"$$FG,GREEN$$CTRL-ALT-X$$FG$$\tKill window\r\n" +"$$FG,GREEN$$CTRL-ALT-C$$FG$$\tBreak(interrupt) program\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$$ nine 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<9;i++) + AFGetKey(SC_CURSOR_DOWN); + +PopUpOk( +"After clicking 'OKAY', the cursor will be\r\n" +"on top of a macro we wish to run.\r\n" +"\r\n" +"After clicking OKAY, press $$FG,GREEN$$SPACE$$FG$$.\r\n"); +AFPmtStr(" "); +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" +"It is similar to $$FG,GREEN$$html$$FG$$ because it has ASCII\r\n" +"behind it. LoseThos documents can include graphics.\r\n\r\n" +"Press \"$$FG,GREEN$$CTRL-T$$FG$$\" after clicking 'OKAY' to toggle\r\n" +"to plain text mode.\r\n"); +AFGetChar(20); +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"); +AFGetChar(20); +Sleep(1000); diff --git a/LT/Accts/Tour/Tour2.AUZ b/LT/Accts/Tour/Tour2.AUZ new file mode 100644 index 0000000..6ba6918 --- /dev/null +++ b/LT/Accts/Tour/Tour2.AUZ @@ -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;"); +AFPmtStr("\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(\"ASCIIOrgan.CPZ\");"); +AFPmtStr("\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$$ASCIIOrgan;$$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" +); + +AFGetChar(CH_CTRLQ); + +PopUpOk( +"Now, we'll run the ASCIIOrgan.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 \"ASCIIOrgan.CPZ\";"); +AFPmtStr("\r"); +AFUntilChar(CH_ESC); + +PopUpOk( +"The program is still in memory and we\r\n" +"can start it again by typing \"$$FG,GREEN$$ASCIIOrgan;$$FG$$\".\r\n\r\n" +"Press $$FG,GREEN$$ENTER$$FG$$ at the command line to\r\n" +"run it again.\r\n"); + +PutS("ASCIIOrgan;"); +AFPmtStr("\r"); +AFUntilChar(27); + diff --git a/LT/Accts/Tour/Tour3.AUZ b/LT/Accts/Tour/Tour3.AUZ new file mode 100644 index 0000000..571acc1 --- /dev/null +++ b/LT/Accts/Tour/Tour3.AUZ @@ -0,0 +1,110 @@ +//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 ASCIIOrgan.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"); +AFGetKey(SC_GUI); +Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL); +Sleep(1000); + +PopUpOk( +"Press $$FG,GREEN$$CTRL-L$$FG$$ to invoke the\r\n" +"text-widget resource editor.\r\n" +"\r\n" +"($$FG,GREEN$$CTRL-R$$FG$$ invokes the\r\n" +"graphic resource editor.)\r\n" +); +AFGetChar(12); + +Sleep(100); +PopUpOk( +"Press $$FG,GREEN$$CURSOR-DOWN$$FG$$ until you reach\r\n" +"\"Macro\".\r\n"); +I8 i; +for (i=0;i<8;i++) + AFGetKey(SC_CURSOR_DOWN); + +PopUpOk( +"Press $$FG,GREEN$$SPACE$$FG$$.\r\n"); +AFPmtStr(" "); +Sleep(1000); + + +PopUpOk( +"Now, we'll fill-in the visible text\r\n" +"of the macro.\r\n"); +AFDelayedPutS("Click Here"); + +Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN); +PopUpOk("Now, we'll fill-in the macro text.\r\n"); +AFDelayedPutS("Cd(\\\"::/LT/Demo\\\");;#include \\\"ASCIIOrgan.CPZ\\\";\\r"); + +PopUpOk("Press $$FG,GREEN$$ESC$$FG$$ to exit the form.\r\n"); +AFGetChar(CH_ESC); +Sleep(1000); + +PopUpOk( +"Press $$FG,GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n" +"($$FG,GREEN$$CTRL-ENTER$$FG$$ does a page break and $$FG,GREEN$$ENTER$$FG$$\r\n" +"would execute the macro.)\r\n"); +AFGetKey(SC_CR|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"); +AFPmtStr(" "); +AFUntilChar(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); +AFDelayedPutS(" Click here for Pop-up version"); +Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN); +AFDelayedPutS("Cd(\\\"::/LT/Demo\\\");;#include \\\"ASCIIOrgan.CPZ\\\";\\r"); +Msg(MSG_KEY_DOWN,0,SC_CURSOR_LEFT|SCF_CTRL); + +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++) + AFGetKey(SC_CURSOR_DOWN); +PopUpOk( +"Press $$FG,GREEN$$SPACE$$FG$$ to\r\n" +"check the box.\r\n"); +AFPmtStr(" "); +Sleep(500); + +PopUpOk("Press $$FG,GREEN$$ESC$$FG$$ to exit the form.\r\n"); +AFGetChar(CH_ESC); +Sleep(500); + +PopUpOk("Press $$FG,GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n"); +AFGetKey(SC_CR|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"); +AFPmtStr(" "); +Sleep(5000); + +PopUpOk( +"Press $$FG,GREEN$$CTRL-S$$FG$$ to save your\r\n" +"macro/menu/help area file, if you wish.\r\n"); +if (Fs->parent_tss->popup_tss) { + PutChar(CH_CTRLQ); + Sleep(100); +} +PutChar(CH_CTRLQ); //exit menu + diff --git a/LT/Accts/Tour/Tour4.AUZ b/LT/Accts/Tour/Tour4.AUZ new file mode 100644 index 0000000..f5cc513 --- /dev/null +++ b/LT/Accts/Tour/Tour4.AUZ @@ -0,0 +1,58 @@ +PopUp("WsInit(\"::/LT\");"); +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" +"The function keys work with code, while\r\n" +"the number keys work with the dictionary.\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"); +Sleep(2000); + +PopUpOk( +"Press $$FG,GREEN$$CTRL-SHIFT-F1$$FG$$ to jump to source code.\r\n"); +AFGetKey(SC_F1|SCF_CTRL|SCF_SHIFT); +Sleep(500); + +PopUpOk( +"Press $$FG,GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n"); +AFUntilChar(CH_CTRLQ); +Sleep(100); +sys_cur_focus_task=Fs; + +PopUpOk( +"Press $$FG,GREEN$$CTRL-F1$$FG$$ to autocomplete.\r\n"); +AFGetKey(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"); +AFDelayedPutS("Man(\"InstallBoot\");"); +Sleep(1000); +PutS("\r"); + +Sleep(2000); +PopUpOk( +"Press $$FG,GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n"); +AFUntilChar(CH_CTRLQ); diff --git a/LT/Accts/Tour/Tour5.AUZ b/LT/Accts/Tour/Tour5.AUZ new file mode 100644 index 0000000..9b699f3 --- /dev/null +++ b/LT/Accts/Tour/Tour5.AUZ @@ -0,0 +1,19 @@ +PopUpOk( +"All text widgets work everywhere.\r\n" +"The $$FG,GREEN$$Type()$$FG$$ command is like\r\n" +"the DOS command of the same name\r\n" +"or the UNIX, $$FG,GREEN$$cat$$FG$$ command.\r\n" +"We will now send your menu document\r\n" +"to the command line. They use the same\r\n" +"document format and it is active!!.\r\n"); + +PopUpOk("Press $$FG,GREEN$$ENTER$$FG$$."); + +//This puts the cursor at the bottom +Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL); +PutS("\r"); + +PutS("Type(\"HOME/User.MUZ\");"); +AFPmtStr("\r"); + + diff --git a/LT/Accts/Tour/User.CPZ b/LT/Accts/Tour/User.CPZ new file mode 100644 index 0000000..f14a113 Binary files /dev/null and b/LT/Accts/Tour/User.CPZ differ diff --git a/LT/ACCOUNTS/USER.CPZ b/LT/Accts/User.CPZ similarity index 50% rename from LT/ACCOUNTS/USER.CPZ rename to LT/Accts/User.CPZ index 3bb7379..c9d04ff 100644 --- a/LT/ACCOUNTS/USER.CPZ +++ b/LT/Accts/User.CPZ @@ -1,3 +1,4 @@ +#help_index "Utils" /* This is the startup file for new local users. @@ -6,42 +7,31 @@ 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 +UseConsoleLtf("User.MUZ"); -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") +U8 F(I1 *pattern,I1 *flags=NULL) { return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags); } -U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l") +U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+l-i") { return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text); } -U8 FD(I1 *pattern,I1 *flags="+r+i") +U8 FD(I1 *pattern,I1 *flags=NULL) { return Grep(pattern,TEXT_FILE_MASK,flags); } -U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+r+l") +U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+l-i") { return Grep(pattern,TEXT_FILE_MASK,flags,replace_text); } PutSysText("ST_USER_STARTUP"); -Type("/LT/DOC/Help.TXZ"); +Type("::/LT/Doc/Help.TXZ"); Fs->scroll_speed=10; Bts(&Fs->crt_flags,CRTf_SHOW); - - -Type("/LT/DOC/StartUp.TXZ"); - +Preempt(ON); +#help_index "" diff --git a/LT/Accts/User.MUZ b/LT/Accts/User.MUZ new file mode 100644 index 0000000..91a590b Binary files /dev/null and b/LT/Accts/User.MUZ differ diff --git a/LT/Accts/User/DoIt.CPZ b/LT/Accts/User/DoIt.CPZ new file mode 100644 index 0000000..91e8f06 --- /dev/null +++ b/LT/Accts/User/DoIt.CPZ @@ -0,0 +1,2 @@ +Type("::/LT/Doc/Customize.TXZ"); + diff --git a/LT/Adam/Adam2.APZ b/LT/Adam/Adam2.APZ new file mode 100644 index 0000000..1b77639 --- /dev/null +++ b/LT/Adam/Adam2.APZ @@ -0,0 +1,55 @@ +public double os_version=3.05; + +#include "AdamExt.HPZ" + +Load("GrAsm/GrAsm"); +#include "GrAsm/GrAsm.HPZ" + +#include "KbdMouse" +#include "InputPointer" +#include "IncCompress" +#include "Math" +#include "ODE" +Cd("::/LT/Adam/Gr");; +#include "Gr" +Cd("::/LT/Adam");; +#include "Music" +#include "Disk10" +#include "DiskCDDVD" +#include "Comm" +#include "Remote" +#include "JoyStick" +#include "Utils" +#include "Message" +#include "Window" +#include "LPT" +Cd("::/LT/Adam/Ltf");; +#include "Ltf" +Cd("::/LT/Adam");; +#include "AutoFile" +#include "LogIn" +Cd("::/LT/Adam/WordStat");; +#include "WordStat" +Cd("::/LT/Adam");; +#include "Dbg" +#include "HashUtils" +#include "FileManager" + +UseConsoleLtf(NULL); + +adam_tss->win_top=2; +adam_tss->win_bottom=10; +sys_update_screen_tss=Spawn(&WinManagerTsk,"Window Manager"); +CollectAccntList; +Bts(&Fs->crt_flags,CRTf_SHOW); + +if (!(Fs->account=FindSysAccnt(sys_startup_account))) + Fs->account=PopUpGetSysAccnt; +sys_update_screen_tss->account=Fs->account; +LoadAccntRegistry; + +Cd("::/LT/Adam");; +#include "WallPaper" + +Cd("HOME");; +#include "Adam3" diff --git a/LT/Adam/AdamExt.HPZ b/LT/Adam/AdamExt.HPZ new file mode 100644 index 0000000..ca6ecab --- /dev/null +++ b/LT/Adam/AdamExt.HPZ @@ -0,0 +1,46 @@ +extern void UseConsoleLtf(I1 *menu_file); +extern BoolU8 WinToTop(TssStruct *tss=NULL); +extern U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL); +extern U8 ScanMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL); +extern void PlotInputPointer(GrBitMap *base); +extern void GrPlot0(GrBitMap *base,I8 x,I8 y); +extern void DrawTaskBorder(TssStruct *tss); +extern void UpdateOdes(TssStruct *tss); + +extern void IDEClearAllBpts(Ltf *l); +extern void IDEToggleBpt(Ltf *l); + +extern U8 ltf_display_types[1],ltf_nondisplay_invisible_types[1], + ltf_form_types[1],ltf_data_types[1]; +extern I8 PopUp(I1 *msg,TssStruct *parent=NULL,TssStruct **pu_tss=NULL); +extern LtfEntry *LtfPutSExt(Ltf *l,I1 *st); +extern I8 PopUpMenu(Ltf *l,I1 *help=NULL); +extern Ltf *LtfNew(); +extern void LtfDel(Ltf *l); +extern LtfEntry *LtfPrintF(Ltf *l,I1 *src,...); +extern I1 *EditPicture(); +extern BoolU8 View(); +extern void IDEGo(); +extern void IDEStep(Ltf *l); +extern void IDESetLineNum(Ltf *l); +extern void IDE(I1 *filename); +extern void LtfD(U1 *buf,U8 cnt=0x80); +extern void LtfUpdateWinJoin(Ltf *l,BoolU4 to_screen,BoolU4 has_cursor, + BoolU4 recalc,BoolU4 find_cur_entry,BoolU4 preempt, + LtfEntry *pg_found=NULL,I8 num_del_entries=0); +extern void LtfRecalc(Ltf *l); +extern BoolU8 DoForm(U1 *D,I1 *class_name, + I1 *help=NULL,BoolU4 help_is_file=FALSE, + I1 *header=NULL,I1 *footer=NULL); + +extern void WsFillin(I8 n); +extern void WsMan(I8 n,TssStruct *parent=NULL); +extern void WsdFillin(I8 n); +extern void WsdDef(I8 n,TssStruct *parent=NULL); +extern BoolU8 WordStat(BoolU8 val=ON); +extern void WsdPopUpDef(I1 *st,I8 num=-1,TssStruct *parent=NULL); +extern void FileManager(I1 *mask="/*",I1 *flags=NULL); +extern void LtfHelpIndex(Ltf *l,I1 *index); +extern void AccntOneTimePopUp(I8 flag_num,I1 *msg); + +#define CTRL_L_HELP "::/LT/Doc/CtrlL.MUZ" diff --git a/LT/Adam/AutoFile.APZ b/LT/Adam/AutoFile.APZ new file mode 100644 index 0000000..cacd4ef Binary files /dev/null and b/LT/Adam/AutoFile.APZ differ diff --git a/LT/Adam/Comm.APZ b/LT/Adam/Comm.APZ new file mode 100644 index 0000000..07f669f Binary files /dev/null and b/LT/Adam/Comm.APZ differ diff --git a/LT/Adam/Dbg.APZ b/LT/Adam/Dbg.APZ new file mode 100644 index 0000000..645fba4 --- /dev/null +++ b/LT/Adam/Dbg.APZ @@ -0,0 +1,1410 @@ +#help_index "Debugging" + +InstructionEntry **disasm_table=NULL; +I8 disasm_table_entries=0; +U8 ins64_mask=0x0880088880; + +I8 CompareInstructionEntries(InstructionEntry **tempi1,InstructionEntry **tempi2) +{ + I8 i1,i2,j=0,result=0; + while (TRUE) { + if (j<(*tempi1)->opcode_cnt && j<(*tempi2)->opcode_cnt) { + i1=(*tempi1)->opcode[j]; + i2=(*tempi2)->opcode[j]; + result=i1-i2; + if (result) return result; + j++; + } else { + i1=(*tempi1)->opcode_cnt; + i2=(*tempi2)->opcode_cnt; + result=i1-i2; + if (result) return result; + + i1=(*tempi1)->slash_value; + i2=(*tempi2)->slash_value; + result=i1-i2; + if (result) return result; + + i1=(*tempi1)->flags & IEF_OP_SIZE32; + i2=(*tempi2)->flags & IEF_OP_SIZE32; + result=i1-i2; + if (result) return result; + + i1=Bt(&ins64_mask,(*tempi1)->arg1) || + Bt(&ins64_mask,(*tempi1)->arg2); + i2=Bt(&ins64_mask,(*tempi2)->arg1) || + Bt(&ins64_mask,(*tempi2)->arg2); + result=i1-i2; + if (result) return result; + + return result; + } + } +} + +void LoadDisasmTable() +{ + SysHashTable *h=asm_hash; + OpcodeHashEntry *temph; + InstructionEntry *tempi; + U8 cnt=0; + I8 i,j,k; + + for (i=0;i<=h->mask;i++) { + temph=h->body[i]; + while (temph) { + if (temph->type==HTT_OPCODE) + cnt+=temph->instruction_entry_cnt; + temph=temph->next; + } + } + disasm_table_entries=cnt; + + j=0; + disasm_table=MAlloc(cnt*sizeof(void *)); + for (i=0;i<=h->mask;i++) { + temph=h->body[i]; + while (temph) { + if (temph->type==HTT_OPCODE) { + tempi=&temph->ins; + for (k=0;kinstruction_entry_cnt;k++) { + disasm_table[j++]=tempi; + tempi+=sizeof(InstructionEntry); + } + } + temph=temph->next; + } + } + + QSort(disasm_table,cnt,sizeof(void *),&CompareInstructionEntries); +} + +if (!disasm_table) { + LoadDisasmTable; + LoadList("ST_INT_NAMES", +" \0 \0NMI\0 \0 \0 \0 \0 \0" +" \0 \0 \0 \0 \0 \0 \0 \0" + +" \0 \0 \0 \0 \0 \0 \0 \0" +" \0 \0 \0 \0 \0 \0 \0 \0" + +" \0 \0 \0 \0 \0 \0 \0 \0" +" \0 \0 \0 \0 \0 \0 \0 \0" + +" \0 \0 \0 \0cout\0coutln\0 \0 \0" +" \0 \0 \0 \0 \0 \0 \0 \0" + +"f_unary_minus\0f_inc\0f_dec\0f_power\0f_mul\0f_div\0f_mod\0f_add\0" +"f_sub\0f_less\0f_greater\0f_less_equal\0f_greater_equal\0f_to_int_RAX\0f_to_double_RAX\0f_to_int_RDX\0" +"f_to_double_RDX\0\0"); +} + + + + + + +BoolU8 PutSourceLine(void *add,U8 cnt,I1 *buf=NULL) +{ + ClassStruct *tempc; + I8 i,minl,maxl,offset; + DbgInfo *dbg; + void **body; + I1 *src; + if (tempc=FindPSect(add,&offset)) { + if (dbg=tempc->debug) { + body=dbg->body; + minl=dbg->min_line; + maxl=dbg->max_line; + for (i=minl;i<=maxl;i++) { + if (*body>=add) { + if (*bodysource_link); + RemoveFirstSeg(src,":"); + RemoveLastSeg(src,","); + if (buf) + SPrintF(buf,"$$LK-A,\"FL:%s,%d\"$$",src,i); + else + PrintF("$$LK-A,\"FL:%s,%d\"$$",src,i); + Free(src); + return TRUE; + } else + return FALSE; + } + body+=sizeof(void *); + } + } + } + return FALSE; +} + +public void DasmIns(I1 *buf,I8 *add,I8 seg_size=64,I8 *branch=NULL) +//Disassembles one instruction +{ + U1 *ip=*add,*bb; + U2 *ww; + U4 *dd; + U8 *dddd; + I8 disp,imm; + I8 opsize,opadd; + BoolU4 cont; + I8 i,j,k,n,m,o1,o2,a1,a2,aa1,aa2,arg1_size=0,arg2_size=0,a1_size,a2_size, + ModrM=-1,SIB=-1,scale,r1,r2, + Mod=-1,RM1=-1,RM2=-1,REX=-1,REX_r=0,REX_x=0,REX_b=0; + InstructionEntry *tempi; + OpcodeHashEntry *tempo,dummy; + I1 *a1_st,*a2_st,*bin_data_area,*bin_data_area2, + buf2[256],buf3[256],seg_overrides[40],arg1_st[256],arg2_st[256]; + + if (branch) *branch=-1; + if (seg_size==16) { + opsize=16; + opadd=16; + } else if (seg_size==32) { + opsize=32; + opadd=32; + } else { + opsize=32; + opadd=64; + } + *arg1_st=0; + *arg2_st=0; + a1_st=arg1_st; + a2_st=arg2_st; + + *buf=0; + if (PutSourceLine(ip,1,buf)) + StrCat(buf,"\r\n"); + SPrintF(buf+StrLen(buf),"%16tP ",ip); + bin_data_area=buf+StrLen(buf); + for (i=0;i<6;i++) { + SPrintF(buf2,"%02X",ip[i]); + StrCat(buf,buf2); + } + StrCat(buf," "); + + SPrintF(buf3,"%16tP ",ip+6); + bin_data_area2=buf3+StrLen(buf3); + for (i=6;i<12;i++) { + SPrintF(buf2,"%02X",ip[i]); + StrCat(buf3,buf2); + } + + *seg_overrides=0; + cont=TRUE; + do { + switch (*ip++) { + case 0x2E: StrCat(seg_overrides,"CS:"); break; + case 0x36: StrCat(seg_overrides,"SS:"); break; + case 0x3E: StrCat(seg_overrides,"DS:"); break; + case 0x26: StrCat(seg_overrides,"ES:"); break; + case 0x64: StrCat(seg_overrides,"FS:"); break; + case 0x65: StrCat(seg_overrides,"GS:"); break; + case 0x66: + if (opsize==16) + opsize=32; + else + opsize=16; + break; + case 0x67: + if (opadd==16) + opadd=32; + else + opadd=16; + break; + + case 0x40: + REX=0x40; + break; + case 0x41: + REX=0x41; + REX_b=8; + break; + case 0x42: + REX=0x42; + REX_x=8; + break; + case 0x43: + REX=0x43; + REX_b=8; + REX_x=8; + break; + + case 0x44: + REX=0x44; + REX_r=8; + break; + case 0x45: + REX=0x45; + REX_b=8; + REX_r=8; + break; + case 0x46: + REX=0x46; + REX_x=8; + REX_r=8; + break; + case 0x47: + REX=0x47; + REX_b=8; + REX_x=8; + REX_r=8; + break; + + case 0x48: + REX=0x48; + opsize=64; + break; + case 0x49: + REX=0x49; + REX_b=8; + opsize=64; + break; + case 0x4A: + REX=0x4A; + REX_x=8; + opsize=64; + break; + case 0x4B: + REX=0x4B; + REX_b=8; + REX_x=8; + opsize=64; + break; + + case 0x4C: + REX=0x4C; + REX_r=8; + opsize=64; + break; + case 0x4D: + REX=0x4D; + REX_b=8; + REX_r=8; + opsize=64; + break; + case 0x4E: + REX=0x4E; + REX_x=8; + REX_r=8; + opsize=64; + break; + case 0x4F: + REX=0x4F; + REX_b=8; + REX_x=8; + REX_r=8; + opsize=64; + break; + + default: + cont=FALSE; + } + } while (cont); + ip--; + + i=0; + j=disasm_table_entries-1; + do { + k=(i+j)>>1; //binary search + tempi=disasm_table[k]; + m=0; + n=0; + while (TRUE) { + if (nopcode_cnt) { + o1=ip[n]; + if (n==tempi->opcode_cnt-1 && + tempi->flags & IEF_PLUS_OPCODE) + o1&=-8; + o2=tempi->opcode[n]; + m=o1-o2; + n++; + if (m) + break; + } else { + if (tempi->slash_value<8) { + o1=(ip[n] >> 3) & 7; + o2=tempi->slash_value; + m=o1-o2; + if (!m) { + if (opsize==16) { + if (tempi->flags & IEF_OP_SIZE32) + m=-1; + } else { + if (tempi->flags & IEF_OP_SIZE16) + m=1; + } + if (!m) { + if (opsize==64||tempi->flags&IEF_NO_REX) { + if (!Bt(&ins64_mask,tempi->arg1) && + !Bt(&ins64_mask,tempi->arg2)) + m=1; + } else { + if (Bt(&ins64_mask,tempi->arg1) || + Bt(&ins64_mask,tempi->arg2)) + m=-1; + } + } + } + break; + } else { + m=0; + if (opsize==16) { + if (tempi->flags & IEF_OP_SIZE32) + m=-1; + } else { + if (tempi->flags & IEF_OP_SIZE16) + m=1; + } + if (!m) { + a1=tempi->arg1; + a2=tempi->arg2; + if (opsize==64) { + if (!Bt(&ins64_mask,a1) && + !Bt(&ins64_mask,a2) && + !(a2==ARGT_NO && + (a1>=ARGT_UIMM8 && a1<=ARGT_UIMM64 || + a1>=ARGT_IMM8 && a1<=ARGT_IMM64 ) )) + m=1; + } else { + if (Bt(&ins64_mask,a1) || + Bt(&ins64_mask,a2)) + m=-1; + } + } + break; + } + } + } + + if (m>0) { + if (k==i) { + k=j; + break; + } else + i=k; + } else if (m<0) { + if (k-i<=1) { + k=i; + break; + } else + j=k; + } else + break; + } while (TRUE); + + tempi=disasm_table[k]; + ip+=tempi->opcode_cnt; + tempo=tempi-(tempi->ins_entry_num*sizeof(InstructionEntry))+&dummy-&dummy.ins; + StrCat(buf,tempo->str); + + a1=tempi->arg1; + a2=tempi->arg2; + aa1=a1; + aa2=a2; + + StrCpy(buf2,SysTextSub(a1,"ST_ARGUMENT_TYPES")); + if (StrStr(buf2,"8")) { + arg1_size=1; + StrCat(arg1_st,"U1 "); + } else if (StrStr(buf2,"16")) { + arg1_size=2; + StrCat(arg1_st,"U2 "); + } else if (StrStr(buf2,"32")) { + arg1_size=4; + StrCat(arg1_st,"U4 "); + } else if (StrStr(buf2,"64")) { + arg1_size=8; + StrCat(arg1_st,"U8 "); + } + + StrCpy(buf2,SysTextSub(a2,"ST_ARGUMENT_TYPES")); + if (StrStr(buf2,"8")) { + arg2_size=1; + StrCat(arg2_st,"U1 "); + } else if (StrStr(buf2,"16")) { + arg2_size=2; + StrCat(arg2_st,"U2 "); + } else if (StrStr(buf2,"32")) { + arg2_size=4; + StrCat(arg2_st,"U4 "); + } else if (StrStr(buf2,"64")) { + arg2_size=8; + StrCat(arg2_st,"U8 "); + } + + a1_size=arg1_size; + a2_size=arg2_size; + if (tempi->flags & IEF_PLUS_OPCODE && (tempi->slash_value==SV_REGISTER || + tempi->opcode_modifier>=OM_RB && tempi->opcode_modifier<=OM_RD)) { + ip--; + RM1=*(ip++) - tempi->opcode[tempi->opcode_cnt-1]+REX_b; + *buf2=0; + if (a1>=ARGT_R8 && a1<=ARGT_R64) { + if (a1_size==1) + SPrintF(buf2,"%Z",RM1,"ST_U1_REGS"); + else if (a1_size==2) + SPrintF(buf2,"%Z",RM1,"ST_U2_REGS"); + else if (a1_size==4) + SPrintF(buf2,"%Z",RM1,"ST_U4_REGS"); + else if (a1_size==8) + SPrintF(buf2,"%Z",RM1,"ST_U8_REGS"); + StrCat(a1_st,buf2); + } else { + if (a2_size==1) + SPrintF(buf2,"%Z",RM1,"ST_U1_REGS"); + else if (a2_size==2) + SPrintF(buf2,"%Z",RM1,"ST_U2_REGS"); + else if (a2_size==4) + SPrintF(buf2,"%Z",RM1,"ST_U4_REGS"); + else if (a2_size==8) + SPrintF(buf2,"%Z",RM1,"ST_U8_REGS"); + StrCat(a2_st,buf2); + } + } + if ((a1>=ARGT_RM8 && a1<=ARGT_RM64) || + (a2>=ARGT_RM8 && a2<=ARGT_RM64)) { + if (a2>=ARGT_RM8 && a2<=ARGT_RM64) { + a1_st=arg2_st; + a2_st=arg1_st; + a1_size=arg2_size; + a2_size=arg1_size; + aa1=a2; + aa2=a1; + } + StrCat(a1_st,seg_overrides); + ModrM=*(ip++); + Mod=(ModrM>>6) & 3; + RM1=ModrM & 7+REX_b; + RM2=(ModrM>>3) & 7+REX_r; + if (Mod<3 && RM1&7==4) { + SIB=*(ip++); + } + if (Mod==1) { + bb=ip; + disp=*bb; + SPrintF(buf2,"%02X",disp); + StrCat(a1_st,buf2); + ip++; + } + if (Mod==2) { + dd=ip; + disp=*dd; + SPrintF(buf2,"%08X",disp); + StrCat(a1_st,buf2); + ip+=4; + } + if (tempi->slash_value<8) + RM2=-1; + else { + *buf2=0; + if (aa2==ARGT_SREG) + SPrintF(buf2,"%Z",RM2,"ST_SEG_REGS"); + else if (!(aa2>=ARGT_IMM8 && aa2<=ARGT_IMM64) && + !(aa2>=ARGT_UIMM8 && aa2<=ARGT_UIMM64)) { + if (a2_size==1) + SPrintF(buf2,"%Z",RM2,"ST_U1_REGS"); + else if (a2_size==2) + SPrintF(buf2,"%Z",RM2,"ST_U2_REGS"); + else if (a2_size==4) + SPrintF(buf2,"%Z",RM2,"ST_U4_REGS"); + else if (a2_size==8) + SPrintF(buf2,"%Z",RM2,"ST_U8_REGS"); + } + StrCat(a2_st,buf2); + } + if (RM1&7==5 && Mod==0) { + dd=ip; + disp=*dd; + ip+=4; + if (disp>MAX_I4) + disp|=0xFFFFFFFF00000000; + if (seg_size==64) { + disp+=ip; + if (aa2==ARGT_IMM8 || aa2==ARGT_UIMM8) + disp++; + else if (aa2==ARGT_IMM16 || aa2==ARGT_UIMM16) + disp+=2; + else if (aa2==ARGT_IMM32 || aa2==ARGT_UIMM32) + disp+=4; + else if (aa2==ARGT_IMM64 || aa2==ARGT_UIMM64) + disp+=8; + } + SPrintF(buf2,"[%X] ",disp); + StrCat(a1_st,buf2); + RM1=-1; + } else { + if (Mod<3) { + if (RM1&7==4) { + RM1=-1; + r1=SIB & 7+REX_b; + r2=(SIB >> 3) & 7+REX_x; + scale=(SIB >> 6) &3; + if (scale==3) + scale=8; + else if (scale==2) + scale=4; + else if (scale==1) + scale=2; + else + scale=1; + if (r1&7==5 && Mod==0) { + dd=ip; + disp=*dd; + SPrintF(buf2,"%08X",disp); + StrCat(a1_st,buf2); + ip+=4; + if (seg_size!=64) + SPrintF(buf2,"[%Z*%d]",r2,"ST_U4_REGS",scale); + else + SPrintF(buf2,"[%Z*%d]",r2,"ST_U8_REGS",scale); + StrCat(a1_st,buf2); + } else { + if (seg_size!=64) + SPrintF(buf2,"[%Z+%Z*%d]",r1,"ST_U4_REGS", + r2,"ST_U4_REGS",scale); + else + SPrintF(buf2,"[%Z+%Z*%d]",r1,"ST_U8_REGS", + r2,"ST_U8_REGS",scale); + StrCat(a1_st,buf2); + } + } else { + *buf2=0; + if (opadd==16) + SPrintF(buf2,"[%Z]",RM1,"ST_U2_REGS"); + else if (opadd==32) + SPrintF(buf2,"[%Z]",RM1,"ST_U4_REGS"); + else + SPrintF(buf2,"[%Z]",RM1,"ST_U8_REGS"); + StrCat(a1_st,buf2); + } + } else { + *buf2=0; + if (a1_size==1) + SPrintF(buf2,"%Z",RM1,"ST_U1_REGS"); + else if (a1_size==2) + SPrintF(buf2,"%Z",RM1,"ST_U2_REGS"); + else if (a1_size==4) + SPrintF(buf2,"%Z",RM1,"ST_U4_REGS"); + else if (a1_size==8) + SPrintF(buf2,"%Z",RM1,"ST_U8_REGS"); + StrCat(a1_st,buf2); + } + } + } + if (a1>=ARGT_MOFFS8 && a1<=ARGT_MOFFS64) { + StrCat(arg1_st,seg_overrides); + if (arg1_size==1) { + bb=ip; + disp=*bb; + ip++; + SPrintF(buf2,"[%X]",disp); + StrCat(arg1_st,buf2); + } else if (opadd==16) { + ww=ip; + disp=*ww; + ip+=2; + SPrintF(buf2,"[%X]",disp); + StrCat(arg1_st,buf2); + } else { + dd=ip; + disp=*dd; + ip+=4; + SPrintF(buf2,"[%X]",disp); + StrCat(arg1_st,buf2); + } + } + + if (a2>=ARGT_MOFFS8 && a2<=ARGT_MOFFS64) { + StrCat(arg2_st,seg_overrides); + if (arg2_size==1) { + bb=ip; + disp=*bb; + ip++; + SPrintF(buf2,"[%X]",disp); + StrCat(arg2_st,buf2); + } else if (opadd==16) { + ww=ip; + disp=*ww; + ip+=2; + SPrintF(buf2,"[%X]",disp); + StrCat(arg2_st,buf2); + } else { + dd=ip; + disp=*dd; + ip+=4; + SPrintF(buf2,"[%X]",disp); + StrCat(arg2_st,buf2); + } + } + + switch (a1) { + case ARGT_IMM8: + case ARGT_UIMM8: + bb=ip; + imm=*bb; + SPrintF(buf2,"%02X",imm); + StrCat(arg1_st,buf2); + if (tempi->opcode[0]==0xCD) { + StrCat(arg1_st," "); + StrCat(arg1_st,SysTextSub(imm,"ST_INT_NAMES")); + } + ip++; + break; + case ARGT_IMM16: + case ARGT_UIMM16: + ww=ip; + imm=*ww; + SPrintF(buf2,"%04X",imm); + StrCat(arg1_st,buf2); + ip+=2; + break; + case ARGT_IMM32: + case ARGT_UIMM32: + dd=ip; + imm=*dd; + SPrintF(buf2,"%08X",imm); + StrCat(arg1_st,buf2); + ip+=4; + break; + case ARGT_IMM64: + case ARGT_UIMM64: + dddd=ip; + imm=*dddd; + SPrintF(buf2,"%016X",imm); + StrCat(arg1_st,buf2); + ip+=8; + break; + case ARGT_REL8: + bb=ip; + disp=*bb; + if (disp>MAX_I1) + disp|=0xFFFFFFFFFFFFFF00; + ip++; + disp+=ip; + SPrintF(buf2,"%P ",disp); + if (branch) *branch=disp; + StrCat(arg1_st,buf2); + break; + case ARGT_REL16: + ww=ip; + disp=*ww; + if (disp>MAX_I2) + disp|=0xFFFFFFFFFFFF0000; + ip+=2; + disp+=ip; + SPrintF(buf2,"%P ",disp); + if (branch) *branch=disp; + StrCat(arg1_st,buf2); + break; + case ARGT_REL32: + dd=ip; + disp=*dd; + if (disp>MAX_I4) + disp|=0xFFFFFFFF00000000; + ip+=4; + disp+=ip; + SPrintF(buf2,"%P ",disp); + if (branch) *branch=disp; + StrCat(arg1_st,buf2); + break; + case ARGT_CL: + StrCat(arg1_st,"CL"); + break; + case ARGT_AL: + StrCat(arg1_st,"AL"); + break; + case ARGT_AX: + StrCat(arg1_st,"AX"); + break; + case ARGT_EAX: + StrCat(arg1_st,"EAX"); + break; + case ARGT_DX: + StrCat(arg1_st,"DX"); + break; + case ARGT_SS: + StrCat(arg1_st,"SS"); + break; + case ARGT_DS: + StrCat(arg1_st,"DS"); + break; + case ARGT_ES: + StrCat(arg1_st,"ES"); + break; + case ARGT_FS: + StrCat(arg1_st,"FS"); + break; + case ARGT_GS: + StrCat(arg1_st,"GS"); + break; + case ARGT_CS: + StrCat(arg1_st,"CS"); + break; + } + + switch (a2) { + case ARGT_IMM8: + case ARGT_UIMM8: + bb=ip; + imm=*bb; + SPrintF(buf2,"%02X",imm); + StrCat(arg2_st,buf2); + ip++; + break; + case ARGT_IMM16: + case ARGT_UIMM16: + ww=ip; + imm=*ww; + SPrintF(buf2,"%04X",imm); + StrCat(arg2_st,buf2); + ip+=2; + break; + case ARGT_IMM32: + case ARGT_UIMM32: + dd=ip; + imm=*dd; + SPrintF(buf2,"%08X",imm); + StrCat(arg2_st,buf2); + ip+=4; + break; + case ARGT_IMM64: + case ARGT_UIMM64: + dddd=ip; + imm=*dddd; + SPrintF(buf2,"%016X",imm); + StrCat(arg2_st,buf2); + ip+=8; + break; + case ARGT_CL: + StrCat(arg2_st,"CL"); + break; + case ARGT_AL: + StrCat(arg2_st,"AL"); + break; + case ARGT_AX: + StrCat(arg2_st,"AX"); + break; + case ARGT_EAX: + StrCat(arg2_st,"EAX"); + break; + case ARGT_DX: + StrCat(arg2_st,"DX"); + break; + case ARGT_SS: + StrCat(arg2_st,"SS"); + break; + case ARGT_DS: + StrCat(arg2_st,"DS"); + break; + case ARGT_ES: + StrCat(arg2_st,"ES"); + break; + case ARGT_FS: + StrCat(arg2_st,"FS"); + break; + case ARGT_GS: + StrCat(arg2_st,"GS"); + break; + case ARGT_CS: + StrCat(arg2_st,"CS"); + break; + } + + if (*arg1_st) { + StrCat(buf,"\t"); + StrCat(buf,arg1_st); + } + if (*arg2_st) { + StrCat(buf,","); + StrCat(buf,arg2_st); + } + for (i=ip-*add;i<6;i++) { + bin_data_area[i<<1]=CH_SPACE; + bin_data_area[i<<1+1]=CH_SPACE; + } + for (i=ip-*add;i<12;i++) { + bin_data_area2[(i-6)<<1]=CH_SPACE; + bin_data_area2[(i-6)<<1+1]=CH_SPACE; + } + StrCat(buf,"\r\n"); + if (ip-*add>6) { + StrCat(buf,buf3); + StrCat(buf,"\r\n"); + } + *add=ip; +} + + +public U1 *Dasm(U1 *ip,U8 cnt=20,I8 seg_size=64) +//Disassembles a number of instructions. +{ + I8 i; + I1 buf[1024]; + for (i=0;i=0 && i=filter_cnt) { + PrintF("$$FG,GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time, + routine_total*10000/total_time%100,routine_total); + PrintF("%s\r\n$$FG$$",last_buf); + } + StrCpy(last_buf,buf2); + routine_total=0; + } + hits=pf_array[i]; + routine_total+=hits; + if (hits>=filter_cnt) { + PrintF("%3d.%02d%% %08X:",hits*100/total_time, + hits*10000/total_time%100,hits); + if (!PutSourceLine(ip,ip-last_ip+1)) + PrintF("%s\r\n",buf); + else + CrLf; + last_ip=ip; + } + } + if (*last_buf && routine_total>=filter_cnt) { + PrintF("$$FG,GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time, + routine_total*10000/total_time%100,routine_total); + PrintF("%s\r\n$$FG$$",last_buf); + } + break; + case PFM_ALL: + QSort(pf_array,pf_ptr,sizeof(U8),&PFACompare); + *last_buf=0; + for (i=0;i=pf_ptr) break; + } + SPrintF(buf,"%P",ip); + StrCpy(buf3,buf); + RemoveFirstSeg(buf3,",",buf2); + if (StrCmp(buf2,last_buf)) { + if (*last_buf && routine_total>=filter_cnt) { + PrintF("$$FG,GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time, + routine_total*10000/total_time%100,routine_total); + PrintF("%s\r\n$$FG$$",last_buf); + } + StrCpy(last_buf,buf2); + routine_total=0; + } + routine_total+=hits; + if (hits>=filter_cnt) { + PrintF("%3d.%02d%% %08X:",hits*100/total_time, + hits*10000/total_time%100,hits); + if (!PutSourceLine(ip,ip-last_ip+1)) + PrintF("%s\r\n",buf); + else + CrLf; + last_ip=ip; + } + } + if (*last_buf && routine_total>=filter_cnt) { + PrintF("$$FG,GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time, + routine_total*10000/total_time%100,routine_total); + PrintF("%s\r\n$$FG$$",last_buf); + } + break; + } + prof_mode=mode; +} + +#help_index "Debugging" + +void ClassRep2(Ltf *l,I1 *class_name,U1 *d,I8 depth,U8 max_depth,U8 types=HTT_CLASS,I8 offset=0) +{ + U8 i,j; + MemberListStruct *ml; + I1 ch,*s,*s2; + U4 *ptr; + U8 *ptr2; + ClassStruct *cl2,*cl=FindLocalHash(class_name,types); + if (depth>=max_depth) return; + if (!cl) { + LtfPutSExt(l,"Class Not Found.\r\n"); + return; + } + if (!CheckPtr(d) || !CheckPtr(d+cl->size)) { + LtfPrintF(l,"Bad Ptr:%016X\r\n",d); + return; + } + LtfPrintF(l,"Class:\"%s\"\r\n",class_name); + ml=cl->member_list; + while (ml) { + cl2=ml->member_class; + ptr=d+ml->offset; + LtfPrintF(l,"%08X ",ptr+offset); //TODO + j=cl2->ptr_cnt; + while (cl2->return_class) + cl2=cl2->return_class; + cl2-=cl2->ptr_cnt*sizeof(ClassStruct); + if (cl2->type & HTT_INTERNAL_TYPE) { + LtfPrintF(l,"$$FG,GREEN$$%-20ts:$$FG$$",ml->str); + if (!j && ml->cnt==0) { + switch (cl2->sub_type) { + case IT_I1: + LtfPrintF(l,"%02X '%c'",ptr->u1[0],ptr->u1[0]); + break; + case IT_U1: + LtfPrintF(l,"%02X",ptr->u1[0]); + break; + case IT_I2: + LtfPrintF(l,"%04X",ptr->u2[0]); + break; + case IT_U2: + LtfPrintF(l,"%04X",ptr->u2[0]); + break; + case IT_I4: + LtfPrintF(l,"%08X",*ptr); + break; + case IT_U4: + LtfPrintF(l,"%08X",*ptr); + break; + case IT_DOUBLE: + ptr2=ptr; + LtfPrintF(l,"%16g",*ptr2); + break; + default: + ptr2=ptr; + LtfPrintF(l,"%016X",*ptr2); + break; + } + } else if ((j==1 || ml->cnt) && + cl2->sub_type==IT_I1) { + if (j==1) { + if (CheckPtr(*ptr)) { + s2=MStrUtil(*ptr,SU_SAFE_DOLLAR); + LtfPrintF(l,"\"%40ts\"",s2); + Free(s2); + } + } else { + if (ml->cnt<40) + s=ptr+ml->cnt; + else + s=ptr+40; + ch=*s; + *s=0; + s2=MStrUtil(ptr,SU_SAFE_DOLLAR); + LtfPrintF(l,"\"%s\"",s2); + Free(s2); + *s=ch; + } + } else if (ml->cnt>0 && ml->cnt<=32 && !j) { + for (i=0;icnt;i++) { + switch (cl2->sub_type) { + case IT_I1: + LtfPrintF(l,"%02X '%c' ",ptr->u1[0],ptr->u1[0]); + ptr+=1; + break; + case IT_U1: + LtfPrintF(l,"%02X ",ptr->u1[0]); + ptr+=1; + break; + case IT_I2: + LtfPrintF(l,"%04X ",ptr->u2[0]); + ptr+=2; + break; + case IT_U2: + LtfPrintF(l,"%04X ",ptr->u2[0]); + ptr+=2; + break; + case IT_I4: + LtfPrintF(l,"%08X ",*ptr); + ptr+=4; + break; + case IT_U4: + LtfPrintF(l,"%08X ",*ptr); + ptr+=4; + break; + case IT_DOUBLE: + ptr2=ptr; + LtfPrintF(l,"%16g ",*ptr2); + ptr+=8; + break; + default: + ptr2=ptr; + LtfPrintF(l,"%016X ",*ptr2); + ptr+=8; + break; + } + } + } else + LtfPrintF(l,"%016X",*ptr); + LtfPutSExt(l,"\r\n"); + } else { + if (depth<2) { + if (j==1 && !CheckPtr(*ptr)) + LtfPrintF(l,"%-20ts:%016X\r\n",ml->str,*ptr); + else { + LtfPrintF(l,"$$TR,\"%s\"$$\r\n",ml->str); + LtfPutSExt(l,"$$ID,2$$"); + if (!j) + ClassRep2(l,cl2->str,ptr,depth+1,max_depth); + else if (j==1) + ClassRep2(l,cl2->str,*ptr,depth+1,max_depth); + LtfPutSExt(l,"$$ID,-2$$"); + } + } else + LtfPrintF(l,"%-20ts\r\n",ml->str); + } + ml=ml->next; + } +} + +public void ClassRep(I1 *class_name,U1 *d,I8 max_depth=2,BoolU4 fun=FALSE,I8 offset=0) +//Displays members of a record +//by using the compiler's info. +{ + Ltf *l; + BoolU4 old_preempt; + if (IsRaw) { + l=LtfNew; + } else { + LtfMax; + old_preempt=Preempt(OFF); + l=Fs->cur_ltf; + } + if (fun) + ClassRep2(l,class_name,d,0,max_depth,HTT_FUNCTION,offset); + else + ClassRep2(l,class_name,d,0,max_depth,HTT_CLASS,offset); + LtfPutSExt(l,"\r\n"); + LtfRecalc(l); + if (IsRaw) { + LtfDump(l,150000); + LtfDel(l); + } else + Preempt(old_preempt); +} + +void RawClassRep(I1 *st,U1 *rbp=NULL,I8 max_depth,BoolU8 is_function,I8 offset=0) +{ + BoolU4 old_raw=Raw(ON); + dc_col=0; + ClassRep(st,rbp,max_depth,is_function,offset); + old_raw=Raw(old_raw); +} + +void UpdateRegVarImg(ClassStruct *cl,U1 *d,TssStruct *tss) +{ + MemberListStruct *ml; + ClassStruct *cl2; + ml=cl->member_list; + while (ml) { + if (ml->register>=CREG_RAX) { + cl2=ml->member_class; + while (cl2->return_class) + cl2=cl2->return_class; + MemCpy(d+ml->offset,&tss->rax+ml->register*8,cl2->size); + } + ml=ml->next; + } +} + +public void FunRep(I1 *st,U1 *rbp=NULL,I8 max_depth=2,TssStruct *tss=NULL) +//Shows names and values of a function's +//local variables using info the compiler +//has. +{ + I8 size; + void *img; + ClassStruct *tempc=FindLocalHash(st,HTT_FUNCTION); + MemberListStruct *tempm; + if (tempc) { + if (rbp) { + if (tss) { + size=tempc->parameter_cnt*8-tempc->size+16; + img=MAlloc(size); + MemCpy(img,rbp+tempc->size,size); + UpdateRegVarImg(tempc,img-tempc->size,tss); + ClassRep(st,img-tempc->size,max_depth,TRUE,rbp-img+tempc->size); + Free(img); + } else + ClassRep(st,rbp,max_depth,TRUE); + } else { + tempm=tempc->member_list; + while (tempm) { + if (tempm->register==-1) + PrintF("%08tX %s\r\n",tempm->offset,tempm->str); + else + PrintF("%08Z %s\r\n",tempm->register,"ST_U8_REGS",tempm->str); + tempm=tempm->next; + } + PrintF("%08tX Stack Size\r\n",tempc->size); + } + } +} + +public void DasmFun(I1 *st) +{ + ClassStruct *tempc=FindLocalHash(st,HTT_FUNCTION); + DbgInfo *tempd; + if (tempc) { + FunRep(st); + if (tempd=tempc->debug) { + Dasm2(tempc->executable_address, + tempd->body[tempd->max_line-tempd->min_line+1]- + tempc->executable_address); + } else + Dasm(tempc->executable_address); + } +} + +#help_index "Debugging/Breakpoints" +SysBpt *FindBpt(TssStruct *tss,U1 *a,U8 flags=ALL_MASK,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 +//Sets a breakpoint +//Honestly, I never use this. I put +//output statements to debug, partly +//because breakpoints don't work well. +//You can configure your $FG,2$Fault.CPZ$FG$ file +//in your $FG,2$HOME$FG$ directory to assist debuggting. +{ + 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=ALL_MASK) +//Resets (removes) one breakpoint +{ + 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; +} + +BoolU8 DBpt(TssStruct *tss,U1 *a,U8 flags=ALL_MASK) //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=ALL_MASK) //clear Bpts +//Clear break-point +{ + 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 void Go() +//Continue after breakpoint +{ + TssStruct *tss=Fs->parent_tss; + void *rip=&tss->rip; + if (!Btr(&tss->task_flags,TSSf_DISABLE_BPTS)) { + *rip-=1; + if (!DBpt(tss,*rip)) + *rip+=1; + } + Btr(&tss->rflags,8); + Btr(&tss->task_flags,TSSf_SUSPENDED); + Exit; +} + +public void Step() +//Execute single assembly instruction +//and stop. +{ + TssStruct *tss=Fs->parent_tss; + void *rip=&tss->rip; + if (!Bts(&tss->task_flags,TSSf_DISABLE_BPTS)) { + *rip-=1; + if (!DBpt(tss,*rip)) + *rip+=1; + } + Bts(&tss->rflags,8); + Btr(&tss->task_flags,TSSf_SUSPENDED); + Exit; +} + +#help_index "" + \ No newline at end of file diff --git a/LT/Adam/Disk10.APZ b/LT/Adam/Disk10.APZ new file mode 100644 index 0000000..a458cb2 Binary files /dev/null and b/LT/Adam/Disk10.APZ differ diff --git a/LT/ADAM/DISK10.CPZ b/LT/Adam/DiskCDDVD.APZ similarity index 64% rename from LT/ADAM/DISK10.CPZ rename to LT/Adam/DiskCDDVD.APZ index e842638..6a634e5 100644 --- a/LT/ADAM/DISK10.CPZ +++ b/LT/Adam/DiskCDDVD.APZ @@ -1,198 +1,4 @@ - -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<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<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<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); -} +#help_index "File/CD DVD" void FillBigEndianU2(U2 *dst,U2 w) { @@ -242,7 +48,7 @@ U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, *de=dir_blk_buf,*de1; ISODirEntry *dir_blk_buf2=MAllocZ(CD_BLK_SIZE*128), *de2=dir_blk_buf2,*de12; - U8 i,l; + U8 i,n; tempc=parent->user_data; @@ -297,9 +103,9 @@ U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, 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; + n=DoCreateCDFile(out_file,tempm1,de,de2,cur_blk,tempm,write); + de+=sizeof(ISODirEntry)-1+n; + de2+=sizeof(ISODirEntry)-1+n<<1; } else { tempc=tempm1->user_data; de->length=sizeof(ISODirEntry)-1; @@ -336,14 +142,14 @@ U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, 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; + n=4; + if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) { + n=((FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS)%4; MemSet(buf,0,CD_BLK_SIZE); } if (write) { - FRBlks(in_file,buf,i<<2,l); - FWBlks(out_file,buf,(*cur_blk)<<2,l); + FRBlks(in_file,buf,i<<2,n); + FWBlks(out_file,buf,(*cur_blk)<<2,n); } *cur_blk+=1; } @@ -384,21 +190,21 @@ U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, } 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); + n=de+1-dir_blk_buf; + n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE; + FillU4Palindrome(&tempi->size,n*CD_BLK_SIZE); FillU4Palindrome(&tempi->location,*cur_blk); - tempc->short_dir_blks=l; + tempc->short_dir_blks=n; tempc->location=*cur_blk; - FillU4Palindrome(&dir_blk_buf->size,l*CD_BLK_SIZE); + FillU4Palindrome(&dir_blk_buf->size,n*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; + FWBlks(out_file,dir_blk_buf,(*cur_blk)<<2,n<<2); + *cur_blk+=n; tempi2->length=sizeof(ISODirEntry)-1; tempi2->ext_attr_length=0; @@ -416,20 +222,20 @@ U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, } } 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); + n=de2+1-dir_blk_buf2; + n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE; + FillU4Palindrome(&tempi2->size,n*CD_BLK_SIZE); FillU4Palindrome(&tempi2->location,*cur_blk); - tempc->long_dir_blks=l; - FillU4Palindrome(&dir_blk_buf2->size,l*CD_BLK_SIZE); + tempc->long_dir_blks=n; + FillU4Palindrome(&dir_blk_buf2->size,n*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; + FWBlks(out_file,dir_blk_buf2,(*cur_blk)<<2,n<<2); + *cur_blk+=n; Free(dir_blk_buf); Free(dir_blk_buf2); @@ -539,11 +345,10 @@ public U8 CreateCDFile(I1 *filename,I1 src_drive, *iso2=MAllocZ(CD_BLK_SIZE), *iso3=MAllocZ(CD_BLK_SIZE); LTDirEntry *rootdir=MAllocZ(sizeof(LTDirEntry)); - U8 my_flags=(1<attr=LT_ATTR_DIR; - rootdir->sub=FindFiles(mask,&my_flags); + rootdir->sub=FindFiles(mask,1<datetime=GetCurTimeLTDate; rootdir->user_data=MAllocZ(sizeof(CCdUserData)); tempc=rootdir->user_data; @@ -731,90 +540,4 @@ public U8 CreateCDFile(I1 *filename,I1 src_drive, 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+=LT_DIR_ENTRY_SIZE+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=LT_DIR_ENTRY_SIZE; - 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=LT_DIR_ENTRY_SIZE; - 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; -} +#help_index "" diff --git a/LT/Adam/DisplayKeys.APZ b/LT/Adam/DisplayKeys.APZ new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/LT/Adam/DisplayKeys.APZ differ diff --git a/LT/Adam/FileManager.APZ b/LT/Adam/FileManager.APZ new file mode 100644 index 0000000..c3161a3 --- /dev/null +++ b/LT/Adam/FileManager.APZ @@ -0,0 +1,684 @@ +#help_index "File/Cmd Line (Typically)" + +#define FILEMANAGER_MENU_NAME "::/LT/Doc/FileManager.MUZ" + +class FMUncollapsedList +{ + FMUncollapsedList *next; + I1 *name; +}; + +void AddTempDriveWizard() +{ + TssStruct *tss; + I1 *a_drive=NULL,*a_size=NULL,*a_type=NULL,*a_name=NULL,*a_default=NULL; + I8 size,drive,type,drive2; + LTPartition *p; + PartitionRep; + BoolU4 okay=FALSE,sure=FALSE,in_use,valid_drive2; + cout "$$WW,1$$"; + + a_type =PmtStr("\r\n(R)am or (F)ile : "); + type =ToUpper(*a_type); + if (type=='R' || type=='F') { + a_drive =PmtStr("\r\nNew Drive Letter: "); + drive=ToUpper(*a_drive); + if (drive>'A' && drive<='Z') { + p=&local_partitions[drive-'A']; + try { + CheckLTPartition(p); + in_use=TRUE; + } catch { + Fs->catch_except=TRUE; + in_use=FALSE; + } + if (in_use) + coutln "$$FG,RED$$Drive letter in use.$$FG$$"; + else { + a_size =PmtStr("\r\nSize in Meg : "); + size=AtoI(a_size)*0x100000>>BLK_SIZE_BITS; + if (size<0x800) + coutln "$$FG,RED$$Invalid size.$$FG$$"; + else { + if (type=='F') { + coutln "$$FG,RED$$Specify entire path, including drive, but leave-off " + "the filename extension.$$FG$$"; + a_default=MSPrintF("%c:/Temp/Drive%c",default_drive,drive); + a_name=PmtStr("\r\nFile Name (%s): ",a_default); + if (*a_name==':') + *a_name=default_drive; + if (StrLen(a_name)<4 || a_name[1]!=':' || + Occurrences(a_name,'.')) + coutln "$$FG,RED$$Invalid file name.$$FG$$"; + else { + drive2=ToUpper(*a_name); + p=&local_partitions[drive2-'A']; + valid_drive2=FALSE; + if (p->type==PT_LT) { + try { + CheckLTPartition(p); + valid_drive2=TRUE; + } catch + Fs->catch_except=TRUE; + } + if (!valid_drive2) + coutln "$$FG,RED$$Invalid drive in file name.$$FG$$"; + else + okay=TRUE; + } + } else { + if (size<7*UnusedSysMem/8) + coutln "$$FG,RED$$Size is too big.$$FG$$"; + else + okay=TRUE; + } + } + } + } else + coutln "$$FG,RED$$Invalid drive letter.$$FG$$"; + } + + CrLf; + if (okay) + sure=AreYouSure; + if (okay && sure) { + tss=SpawnUser; + tss->win_top=Fs->win_top; + tss->win_bottom=(Fs->win_top+Fs->win_bottom)>>2-1; + Fs-> win_top=tss->win_bottom+3; + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + WinToTop(Fs); + XTalk(tss,"AddDrives;\r"); + XTalk(tss,"%c",drive); + if (type=='R') { + XTalk(tss,"1"); + XTalk(tss,"%d\r",size); + } else { + XTalk(tss,"5"); + XTalk(tss,"%s\r",a_name); + XTalk(tss,"Y"); + XTalk(tss,"%d\r",size); + } + XTalkWithWait(tss,"\r"); + Fs->win_top=tss->win_top; + Kill(tss); + PartitionRep; + } else + coutln "$$FG,RED$$Canceled$$FG$$"; + CrLf; + PressAKey; + Free(a_drive); + Free(a_type); + Free(a_size); + Free(a_name); + Free(a_default); +} + +void FMAddTempDrive() +{ + PopUp("AddTempDriveWizard;\r",Fs); +} + +FMUncollapsedList *FMCollectUncollapsedList(Ltf *l) +{ + LtfEntry *ll=l->dummy.next; + FMUncollapsedList *result=NULL,*tempc; + LTDirEntry *tempm; + while (ll!=l) { + if (ll->btype==LTFT_TREE) { + if (!(ll->flags<FLF_COLLAPSED)) { + if (tempm=ll->user_data) { + tempc=MAlloc(sizeof(FMUncollapsedList)); + tempc->next=result; + result=tempc; + tempc->name=NewStr(tempm->full_name); + } + } + } + ll=ll->next; + } + return result; +} + +void FMMarkUncollapsed(Ltf *l,FMUncollapsedList *tempc,I1 *cur_entry,I1 *next_entry) +{ + LtfEntry *ll=l->dummy.next; + FMUncollapsedList *tempc1; + LTDirEntry *tempm; + while (ll!=l) { + if (ll->btype==LTFT_TREE) { + tempm=ll->user_data; + tempc1=tempc; + while (tempc1) { + if (!StrCmp(tempc1->name,tempm->full_name)) { + ll->flags&=~LTFLF_COLLAPSED; + break; + } + tempc1=tempc1->next; + } + if (cur_entry) { + if (!StrNCmp(cur_entry,tempm->full_name,StrLen(tempm->full_name))) { + l->cur_entry=ll; + if (StrLen(tempm->full_name)==StrLen(cur_entry)) + cur_entry=NULL; + } else if (next_entry) { + if (!StrNCmp(next_entry,tempm->full_name,StrLen(tempm->full_name))) { + l->cur_entry=ll; + if (StrLen(tempm->full_name)==StrLen(next_entry)) + cur_entry=NULL; + } + } + } + } else if (ll->btype==LTFT_MENU_VALUE) { + tempm=ll->left_exp; + if (cur_entry) { + if (!StrNCmp(cur_entry,tempm->full_name,StrLen(tempm->full_name))) { + l->cur_entry=ll; + if (StrLen(tempm->full_name)==StrLen(cur_entry)) + cur_entry=NULL; + } else if (next_entry) { + if (!StrNCmp(next_entry,tempm->full_name,StrLen(tempm->full_name))) { + l->cur_entry=ll; + if (StrLen(tempm->full_name)==StrLen(next_entry)) + cur_entry=NULL; + } + } + } + } + ll=ll->next; + } +} + +void FMDelUncollapsedList(FMUncollapsedList *tempc) +{ + FMUncollapsedList *tempc1; + while (tempc) { + tempc1=tempc->next; + Free(tempc->name); + Free(tempc); + tempc=tempc1; + } +} + +LTDirEntry *FMRebuildLtfDrive(I1 drive,Ltf *l,LTDirEntry **root,BoolU4 init) +{ + U8 f=0; + LtfEntry *ll; + LTDirEntry *tempm,*tempm1; + I1 *st; + + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r"); + tempm=MAllocZ(sizeof(LTDirEntry)); + tempm->full_name=MSPrintF("%c:/",drive); + StrCpy(tempm->name,""); + st=MSPrintF("%c:/*",drive); + if (init) { + tempm1=FindFiles(st,f); + tempm->sub=tempm1; + } else + tempm1=NULL; + Free(st); + ll=LtfPrintF(l,"$$TR,\"%s\"$$",tempm->full_name); + ll->user_data=tempm; + tempm->next=*root; + *root=tempm; + LtfPutSExt(l,"\r\n$$ID,+2$$"); + LtfBottom(l); + if (init) { + LTDirEntryToFileLtf(l,tempm1); + while (tempm1) { + tempm1->parent=tempm; + tempm1=tempm1->next; + } + } + LtfPutSExt(l,"$$ID,-2$$"); + return tempm; +} + + +void FMRebuildLtf(Ltf **l_,LTDirEntry **root) +{ + LTPartition *p; + I8 i; + Ltf *l=*l_,*m,*b=sys_clipboard_ltf; + FMUncollapsedList *tempc=NULL; + I1 *cur_entry=NULL,*next_entry=NULL; + LtfEntry *cl; + LTDirEntry *tempm,*tempm1,*cur_tree_entry; + if (l) { + + cur_tree_entry=NULL; + cl=l->cur_entry; + if (cl->btype==LTFT_TREE) + cur_tree_entry=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + cur_tree_entry=cl->left_exp; + if (cur_tree_entry) + cur_entry=NewStr(cur_tree_entry->full_name); + + tempm=NULL; + if (cl!=l) + cl=cl->next; + while (cl!=l) { + if (cl->btype==LTFT_TREE) + tempm=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + tempm=cl->left_exp; + else + tempm=NULL; + if (tempm) { + tempm1=tempm->parent; + while (tempm1) { + if (tempm1==cur_tree_entry) { + tempm=NULL; + break; + } else + tempm1=tempm1->parent; + } + if (tempm) + break; + } + cl=cl->next; + } + if (tempm) + next_entry=NewStr(tempm->full_name); + + tempc=FMCollectUncollapsedList(l); + Fs->cur_ltf=NULL; + LtfDel(l); + } + if (*root) { + DelLTDirList(*root); + *root=NULL; + } + l=LtfNew; + l->flags|=LTFF_FORM; + m=LtfRead(FILEMANAGER_MENU_NAME); + m->text_attribute=(WHITE<<4)+LTBLUE; + l->menu_ltf=m; + for (i=0;i<32;i++) { + p=&local_partitions[i]; + if (p->type==PT_LT) + FMRebuildLtfDrive(p->drive,l,root,TRUE); + else if (p->type==PT_ISO9660) { + if (p->bdev->flags<BDF_INITIALIZED) + tempm=FMRebuildLtfDrive(p->drive,l,root,TRUE); + else { + tempm=FMRebuildLtfDrive(p->drive,l,root,FALSE); + tempm->flags|=LTDEF_NOT_INITIALIZED; + } + tempm->flags|=LTDEF_REMOVABLE; + } + } + LtfHome(l); + FMMarkUncollapsed(l,tempc,cur_entry,next_entry); + l->recalc_start=l; + LtfCenter(l); + LtfReset(b,TRUE); + FMDelUncollapsedList(tempc); + Free(cur_entry); + Free(next_entry); + *l_=l; + Fs->cur_ltf=l; +} + +void FMRename(Ltf *l) +{ + EditFileNameStruct fn; + LtfEntry *ll=l->cur_entry; + LTDirEntry *tempm=NULL,*parent; + if (ll->btype==LTFT_MENU_VALUE) { + tempm=ll->left_exp; + if (parent=tempm->parent) { + Cd(parent->full_name); + StrCpy(fn.name,tempm->name); + if (DoForm(fn.name,"EditFileNameStruct")) { + Silent(ON); + Move(tempm->name,fn.name); + Silent(OFF); + } + } + } else if (ll->btype==LTFT_TREE) { + tempm=ll->user_data; + if (parent=tempm->parent) { + Cd(parent->full_name); + StrCpy(fn.name,tempm->name); + if (DoForm(fn.name,"EditFileNameStruct")) { + if (StrCmp(tempm->name,fn.name)) { + Silent(ON); + CopyTree(tempm->name,fn.name); + DelTree(tempm->name); + Silent(OFF); + } + } + } + } +} + +void FMDelete(Ltf *l) +{ + LtfEntry *cl=l->cur_entry; + LTDirEntry *tempm; + if (cl->btype==LTFT_MENU_VALUE) { + tempm=cl->left_exp; + Silent(ON); + Del(tempm->full_name); + Silent(OFF); + } else if (cl->btype==LTFT_TREE) { + tempm=cl->user_data; + Silent(ON); + DelTree(tempm->full_name); + Silent(OFF); + } +} + +void FMMount(Ltf *l) +{ + LtfEntry *cl=l->cur_entry; + LTDirEntry *tempm; + if (cl->btype==LTFT_TREE) + tempm=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + tempm=cl->left_exp; + else + tempm=NULL; + if (tempm) { + while (tempm->parent) + tempm=tempm->parent; + Silent(ON); + ChangeDisk(*tempm->full_name); + Silent(OFF); + } +} + +void FMFormatDrive(Ltf *l) +{ + LtfEntry *cl=l->cur_entry; + LTDirEntry *tempm; + I1 *st=NULL; + if (cl->btype==LTFT_TREE) + tempm=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + tempm=cl->left_exp; + else + tempm=NULL; + if (tempm) { + while (tempm->parent) + tempm=tempm->parent; + st=MSPrintF("Format Drive '%c'?\r\nAre You Sure?\r\n",*tempm->full_name); + if (PopUpNoYes(st)) { + Silent(ON); + Format(*tempm->full_name,TRUE,FALSE); + Silent(OFF); + } + } + Free(st); +} + +void FMMakeISO(Ltf *l) +{ + LtfEntry *cl=l->cur_entry; + LTDirEntry *tempm; + if (cl->btype==LTFT_TREE) + tempm=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + tempm=cl->left_exp; + else + tempm=NULL; + if (tempm) { + while (tempm->parent) + tempm=tempm->parent; + Silent(ON); + CreateCDFile(NULL,*tempm->full_name); + Silent(OFF); + } +} + +void FMBurnISO(Ltf *l) +{ + LtfEntry *cl=l->cur_entry; + LTDirEntry *tempm; + if (cl->btype==LTFT_TREE) + tempm=cl->user_data; + else if (cl->btype==LTFT_MENU_VALUE) + tempm=cl->left_exp; + else + tempm=NULL; + if (tempm) { + while (tempm->parent) + tempm=tempm->parent; + Silent(ON); + WriteCDImage(*tempm->full_name,NULL); + Silent(OFF); + } +} + +void FMCopy(Ltf *l) +{ + Ltf *b=sys_clipboard_ltf; + I1 *st; + LtfEntry *cl=l->cur_entry,*ll=b->dummy.next; + LTDirEntry *tempm,*tempm1,*tempm2; + if (cl->btype==LTFT_TREE) { + tempm1=cl->user_data; + while (ll!=b) { + if (ll->btype==LTFT_MENU_VALUE) { + tempm=ll->left_exp; + tempm->flags|=LTDEF_PROCESSED; + tempm2=tempm->parent; + if (!tempm2 || !(tempm2->flags<DEF_PROCESSED)) { + Silent(ON); + Copy(tempm->full_name,tempm1->full_name); + Silent(OFF); + } + } else if (ll->btype==LTFT_TREE) { + tempm=ll->user_data; + tempm->flags|=LTDEF_PROCESSED; + tempm2=tempm->parent; + if (!tempm2 || !(tempm2->flags<DEF_PROCESSED)) { + Silent(ON); + if (*tempm1->name) + st=MSPrintF("%s/%s",tempm1->full_name,tempm->name); + else + st=MSPrintF("%s%s",tempm1->full_name,tempm->name); + CopyTree(tempm->full_name,st); + Free(st); + Silent(OFF); + } + } + ll=ll->next; + } + } +} + + +I8 PopUpCancelPasteDel(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"RENAME \",7$$"); + LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"DELETE \",2$$"); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"PASTE CLIPBOARD FILES\",1$$"); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"CHANGE DISK(MOUNT IT)\",3$$"); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"ADD TEMP DRIVE \",4$$"); + LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"FORMAT \",6$$"); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"MAKE ISO FILE \",8$$"); + LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"BURN ISO FILE \",9$$"); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"HELP \",5$$"); + LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"CANCEL \",0$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +void FMRightClick() +{ + I8 i=PopUpCancelPasteDel; + if (i>0) { + switch (i) { + case 1: + Msg(MSG_KEY_DOWN,0,SC_INSERT+SCF_SHIFT); + break; + case 2: + Msg(MSG_KEY_DOWN,0x19,0); + break; + case 3: + Msg(MSG_KEY_DOWN,'m',0); + break; + case 4: + Msg(MSG_KEY_DOWN,'t',0); + break; + case 5: + Msg(MSG_KEY_DOWN,0,SC_GUI); + break; + case 6: + Msg(MSG_KEY_DOWN,'f',0); + break; + case 7: + Msg(MSG_KEY_DOWN,CH_CR,0); + break; + case 8: + Msg(MSG_KEY_DOWN,'M',0); + break; + case 9: + Msg(MSG_KEY_DOWN,'B',0); + break; + } + } +} + +public void FileManager() +{ + LTDirEntry *root=NULL,*tempm,*tempm1,*tempm2; + U8 sc,ch,p1,p2,cmd; + Ltf *l=NULL,*old_ltf=Fs->cur_ltf; + void *old_update=Fs->update_win; + BoolU4 old_preempt=Preempt(OFF); + I1 *st,*old_cur_dir=NewStr(Fs->cur_dir); + LTPartition *old_p=Fs->cur_partition; + LtfEntry *cl=NULL,*ll; + BoolU4 okay; + + FMRebuildLtf(&l,&root); + Fs->update_win=&LtfUpdateBothLtf; + do { + Preempt(OFF); + if (cmd=ScanMsg(&p1,&p2, + 1<cur_entry; + break; + case MSG_IP_L_UP: + if (cl) { + if (cl->btype==LTFT_MENU_VALUE) { + tempm=cl->left_exp; + if (SetCursorPosition(Fs,p1/FONT_WIDTH+Fs->win_left,p2/FONT_HEIGHT+Fs->win_top,TRUE)) { + ll=l->cur_entry; + if (ll->btype==LTFT_TREE) { + tempm1=ll->user_data; + Silent(ON); + Move(tempm->full_name,tempm1->full_name); + Silent(OFF); + PutKey(CH_SPACE,0); //toggle collapse again + FMRebuildLtf(&l,&root); + } + } + } else if (cl->btype==LTFT_TREE) { + tempm=cl->user_data; + if (SetCursorPosition(Fs,p1/FONT_WIDTH+Fs->win_left,p2/FONT_HEIGHT+Fs->win_top,TRUE)) { + ll=l->cur_entry; + if (ll->btype==LTFT_TREE) { + tempm1=ll->user_data; + okay=TRUE; + tempm2=tempm1; + while (tempm2) { + if (tempm2!=tempm) + tempm2=tempm2->parent; + else { + okay=FALSE; + break; + } + } + if (okay) { + if (*tempm1->name) + st=MSPrintF("%s/%s",tempm1->full_name,tempm->name); + else + st=MSPrintF("%s%s",tempm1->full_name,tempm->name); + if (StrCmp(tempm->full_name,st)) { + Silent(ON); + CopyTree(tempm->full_name,st); + DelTree(tempm->full_name); + Silent(OFF); + PutKey(CH_SPACE,0); //toggle collapse again + FMRebuildLtf(&l,&root); + } + Free(st); + } + } + } + } + cl=NULL; + } + break; + case MSG_KEY_DOWN: + ch=p1; sc=p2; + if (ch==CH_CR) { + FMRename(l); + FMRebuildLtf(&l,&root); + } else if (ch==0x19 || //ctrl-y + (sc.u1[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))) { + FMDelete(l); + FMRebuildLtf(&l,&root); + } else if (ch=='m') { + FMMount(l); + FMRebuildLtf(&l,&root); + } else if (ch=='M') { + FMMakeISO(l); + FMRebuildLtf(&l,&root); + } else if (ch=='B') { + FMBurnISO(l); + FMRebuildLtf(&l,&root); + } else if (ch=='t') { + FMAddTempDrive; + FMRebuildLtf(&l,&root); + } else if (ch=='f') { + FMFormatDrive(l); + FMRebuildLtf(&l,&root); + } else if (sc.u1[0]==SC_INSERT && sc&SCF_SHIFT && !(sc&SCF_CTRL)) { + FMCopy(l); + FMRebuildLtf(&l,&root); + } else if (ch!=0x14 && ch!=CH_ESC && ch!=CH_CTRLQ) {//ctrl T not allowed + if (ch!=CH_SPACE || l->cur_entry->btype!=LTFT_MENU_VALUE) { + Preempt(old_preempt); + PutKey(ch,sc); + Preempt(OFF); + LtfRecalc(Fs->cur_ltf); + } + } + break; + } + } else { + Fs->task_flags|=1<task_flags&=~(1<cur_ltf=old_ltf; + Fs->update_win=old_update; + Preempt(old_preempt); + LtfDel(l); + DelLTDirList(root); + Drive(old_p->drive); + Cd(old_cur_dir); + Free(old_cur_dir); +} +#help_index "" diff --git a/LT/Adam/Gr/Gr.APZ b/LT/Adam/Gr/Gr.APZ new file mode 100644 index 0000000..ac9a166 --- /dev/null +++ b/LT/Adam/Gr/Gr.APZ @@ -0,0 +1,13 @@ +#help_index "Graphics" + +extern GrBitMap *GrAlias(GrBitMap *base,TssStruct *tss); +extern void GrDel(GrBitMap *base); + +#include "GrMath" +#include "GrScreen" +#include "GrBitMap" +#include "GrPlot" +#include "GrChar" +#include "GrElem" + +#help_index "" diff --git a/LT/Adam/Gr/GrBitMap.APZ b/LT/Adam/Gr/GrBitMap.APZ new file mode 100644 index 0000000..92c241c --- /dev/null +++ b/LT/Adam/Gr/GrBitMap.APZ @@ -0,0 +1,1465 @@ +#help_index "Graphics/Bitmaps" +public void GrReset(GrBitMap *base) +{ + base->color=BLACK; + base->color2=BLACK; + base->bkcolor=BLACK; + base->pen_width=1; +} + +public GrBitMap *GrAlias(GrBitMap *base,TssStruct *tss) +{ + GrBitMap *result=MAlloc(sizeof(GrBitMap),tss); + if (base->bitmap_signature!=BMS_SIGNATURE) + Debugger; + MemCpy(result,base,sizeof(GrBitMap)); + result->win_tss=tss; + result->mem_tss=tss; + result->r=MAlloc(16<<3,tss); + GrSetIdent(result->r); + GrReset(result); + result->flags|=BMF_ALIAS; + return result; +} + + +public void GrDel(GrBitMap *base) +{ + if (base->bitmap_signature!=BMS_SIGNATURE) + Debugger; + base->bitmap_signature=0; + Free(base->r,base->mem_tss); + if (!(base->flags & BMF_ALIAS)) + Free(base->body,base->mem_tss); + Free(base,base->mem_tss); +} + +#help_index "Graphics" + +public void GrPlot0(GrBitMap *base,I8 x,I8 y) +{ //No clipping or transformation or pen width + U8 d,c,c2; + U1 *dst,bit,not_bit; + U8 color=base->color,bkcolor=base->bkcolor; + double dist; + + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x,y,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + if (base->flags & BMF_DONT_DRAW) + return; + switch (base->type) { + case BMT_COLOR4: + d=base->plane_size; + dst=base->body+(base->left_margin+x+ + (y+base->top_margin)*base->internal_width)>>3; + bit=1<<(x&7); + not_bit=~bit; + c=color.u1[0]; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + if (c & 1) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 2) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 4) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 8) + *dst|=bit; + else + *dst&=not_bit; + break; + case ROPB_COLLISION: + c2=0; + if (*dst&bit) + c2+=1; + dst+=d; + if (*dst&bit) + c2+=2; + dst+=d; + if (*dst&bit) + c2+=4; + dst+=d; + if (*dst&bit) + c2+=8; + if (c2!=bkcolor.u1[0]) + base->collision_cnt++; + break; + case ROPB_XOR: + if (c & 1) *dst^=bit; + dst+=d; + if (c & 2) *dst^=bit; + dst+=d; + if (c & 4) *dst^=bit; + dst+=d; + if (c & 8) *dst^=bit; + break; + case ROPB_OR: + if (c & 1) *dst|=bit; + dst+=d; + if (c & 2) *dst|=bit; + dst+=d; + if (c & 4) *dst|=bit; + dst+=d; + if (c & 8) *dst|=bit; + break; + case ROPB_NAND: + if (c & 1) *dst&=not_bit; + dst+=d; + if (c & 2) *dst&=not_bit; + dst+=d; + if (c & 4) *dst&=not_bit; + dst+=d; + if (c & 8) *dst&=not_bit; + break; + } + break; + case BMT_MONO: + d=base->internal_width*(y+base->top_margin)+ + x+base->left_margin; + c=color&0xFFFFFF; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + AssignBit(base->body,d,c); + break; + case ROPB_COLLISION: + if (c) { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=Bt(base->body,d); + else + base->collision_cnt+=!Bt(base->body,d); + } else { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=!Bt(base->body,d); + else + base->collision_cnt+=Bt(base->body,d); + } + break; + case ROPB_XOR: + if (c) + Btc(base->body,d); + break; + case ROPB_OR: + if (c) + Bts(base->body,d); + break; + case ROPB_NAND: + if (c) + Btr(base->body,d); + break; + } + break; + } +} + +public I8 GrPeek0(GrBitMap *base,I8 x,I8 y) +{ //No clipping or transformation + U8 d,c; + U1 *dst,bit; + + switch (base->type) { + case BMT_COLOR4: + d=base->plane_size; + dst=base->body+(base->left_margin+x+ + (y+base->top_margin)*base->internal_width)>>3; + bit=1<<(x&7); + + c=0; + if (*dst & bit) + c|=1; + dst+=d; + if (*dst & bit) + c|=2; + dst+=d; + if (*dst & bit) + c|=4; + dst+=d; + if (*dst & bit) + c|=8; + + return c; + case BMT_MONO: + d=base->internal_width*(y+base->top_margin)+ + x+base->left_margin; + return Bt(base->body,d); + } +} + +#help_index "Graphics;Graphics/Bitmaps" + +public BoolU4 GrBlot(GrBitMap *base,I8 x,I8 y,GrBitMap *img) +{ //Clipping but not transformation + I8 reg i,i1,i2,i3,j,k,k1,kk,kk1,w1,h1,w2,h2,plane,plane1,reg bit_mask,reg bit_shift,p,dist; + U1 reg *ptr; + U2 reg *ptr1; + I8 color,color2,reg color_byte,c,plane_size,plane_size1,plane_limit,plane_limit1; + BoolU4 draw=TRUE,color_bit; + + w1= (x<0)?-x:0; + h1= (y<0)?-y:0; + w2=img->width; + h2=img->height; + + if (base->flags & BMF_SCREEN_BITMAP) { + x+=base->win_tss->win_pixel_left; + y+=base->win_tss->win_pixel_top; + } + if (base->flags & BMF_LOCATE_NEAREST) { //TODO:Untested + dist=DistI8(x+img->width>>1,y+img->height>>1,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + if (base->flags & BMF_SCREEN_BITMAP) { + if (x+w1<0) w1=-x; + if (x+w2>base->win_tss->win_pixel_right) + w2=base->win_tss->win_pixel_right-x; + + if (y+h1<0) h1=-y; + if (y+h2>base->win_tss->win_pixel_bottom) + h2=base->win_tss->win_pixel_bottom-y; + + if (IsPixelCovered(base->win_tss,x+w1,y+h1)) + draw=FALSE; + else if (IsPixelCovered(base->win_tss,x+w2,y+h2)) + draw=FALSE; + x+=base->left_margin; + y+=base->top_margin; + } + if (x+w2>base->width) + w2=base->width-x; + if (y+h2>base->height) + h2=base->height-y; + if (draw && w1width && h2<=img->height) { + if (base->flags & BMF_DONT_DRAW) + return TRUE; + color=base->color; + p=0; + plane_size=img->plane_size<<3; + plane_size1=base->plane_size<<3; + switch (base->type) { + case BMT_COLOR4: + plane_limit=plane_size*4; + plane_limit1=plane_size1*4; + break; + case BMT_MONO: + plane_limit=plane_size; + plane_limit1=plane_size1; + break; + } + i1=(-w1)&7; + if (i1>w2) i1=w2; + i2=(w2-w1-i1)>>3; + i3=w2-w1-i2<<3-i1; + bit_shift=x&7; + bit_mask=-1-255<bkcolor&0xFFFFFF; + color2=img->bkcolor &0xFFFFFF; + switch (img->type) { + case BMT_COLOR4: + k=h1*img->internal_width; + k1=(h1+y)*base->internal_width+x; + for (j=h1;jbody,k1+i+plane1)) + c+=p; + if (c!=color) { + c=0; + for (plane=0,p=1;planebody,k+i+plane)) + c+=p; + if (c!=color2) + base->collision_cnt++; + } + } + k+=img->internal_width; + k1+=base->internal_width; + } + break; + case BMT_MONO: + k=h1*img->internal_width; + k1=(h1+y)*base->internal_width+x; + for (j=h1;jbody,k1+i+plane1)) + c+=p; + if (c!=color) { + if (Bt(img->body,k+i)!=color2) + base->collision_cnt++; + } + } + k+=img->internal_width; + k1+=base->internal_width; + } + break; + } + } else if (color.u1[3]==ROPB_TRANSPARENT && img->type==BMT_COLOR4) { + color2=img->bkcolor &0xFFFFFF; + k=h1*img->internal_width; + for (j=h1;jbody,k+i+plane)) + c+=p; + if (c!=color2) { + base->color=c; + GrPlot0(base,x+i-base->left_margin,y+j-base->top_margin); + } + } + k+=img->internal_width; + } + base->color=color; + } else + for (plane=0,plane1=0;planeinternal_width+w1; + kk1=(h1+y)*base->internal_width+x+w1; + for (j=h1;jtype) { + case BMT_COLOR4: + k=kk+plane; + k1=kk1+plane1; + ptr=img->body; + ptr1=base->body; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;i>3; + ptr1+=k1>>3; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;ibody; + ptr1=base->body; + k+=i2<<3; + k1+=i2<<3; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;ibody; + ptr1=base->body; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;i>3; + ptr1+=k1>>3; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;ibody; + ptr1=base->body; + k+=i2<<3; + k1+=i2<<3; + switch (color.u1[3]) { + case ROPB_EQU: + for (i=0;iinternal_width; + kk1+=base->internal_width; + } + } + return TRUE; + } + return FALSE; +} + +#help_index "Graphics" + +public BoolU4 GrText(GrBitMap *base,I8 x,I8 y,U1 *s) +{ //Clipping but not transformation + I8 len=StrLen(s),ch,reg i,i1,i2,i3,j,k1,kk1,w1,h1,w2,h2,plane1,reg bit_mask,reg bit_shift,p,dist,l,l1; + U1 reg *ptr,*font_ptr,*s1; + U2 reg *ptr1,*ptr2; + I8 color,reg color_byte,c,plane_size1,plane_limit1; + BoolU4 draw=TRUE,color_bit; + + w1= (x<0)?-x:0; + h1= (y<0)?-y:0; + w2=len*FONT_WIDTH; + h2=FONT_HEIGHT; + + if (base->flags & BMF_SCREEN_BITMAP) { + x+=base->win_tss->win_pixel_left; + y+=base->win_tss->win_pixel_top; + } + if (base->flags & BMF_LOCATE_NEAREST) { //TODO:Untested + dist=DistI8(x+w2>>1,y+h2>>1,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + if (base->flags & BMF_SCREEN_BITMAP) { + if (x+w1<0) w1=-x; + if (x+w2>base->win_tss->win_pixel_right) + w2=base->win_tss->win_pixel_right-x; + + if (y+h1<0) h1=-y; + if (y+h2>base->win_tss->win_pixel_bottom) + h2=base->win_tss->win_pixel_bottom-y; + + if (IsPixelCovered(base->win_tss,x+w1,y+h1)) + draw=FALSE; + else if (IsPixelCovered(base->win_tss,x+w2,y+h2)) + draw=FALSE; + x+=base->left_margin; + y+=base->top_margin; + } + if (x+w2>base->width) + w2=base->width-x; + if (y+h2>base->height) + h2=base->height-y; + if (draw && w1flags & BMF_DONT_DRAW) + return TRUE; + color=base->color; + p=0; + plane_size1=base->plane_size<<3; + switch (base->type) { + case BMT_COLOR4: + plane_limit1=plane_size1*4; + break; + case BMT_MONO: + plane_limit1=plane_size1; + break; + } + i1=(-w1)&7; + if (i1>w2) i1=w2; + i2=(w2-w1-i1)>>3; + i3=w2-w1-i2<<3-i1; + bit_shift=x&7; + bit_mask=-1-255<bkcolor&0xFFFFFF; + ch=*s++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + for (i=w1;iinternal_width+x; + ptr=font_ptr; + for (j=h1;jbody,k1+i+plane1)) + c+=p; + if (c!=color) { + if (Bt(ptr,l)) + base->collision_cnt++; + } + k1+=base->internal_width; + ptr++; + } + if (++l==FONT_WIDTH) { + ch=*s++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + l=0; + } + } + } else { + for (plane1=0;plane1body+plane1>>3; + kk1=(h1+y)*base->internal_width+x+w1; + ch=*s1++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + for (i=0;iinternal_width; + } + break; + case ROPB_XOR: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + case ROPB_OR: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + case ROPB_NAND: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + } + if (++l1==FONT_WIDTH) { + ch=*s1++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + l1=0; + } + } + kk1+=i1; + ptr2+=kk1>>3; + for (i=0;iinternal_width>>3; + } + break; + case ROPB_XOR: + if (color_bit) + for (j=h1;jinternal_width>>3; + } + break; + case ROPB_OR: + if (color_bit) + for (j=h1;jinternal_width>>3; + } + break; + case ROPB_NAND: + if (color_bit) + for (j=h1;jinternal_width>>3; + } + break; + } + ptr2++; + ch=*s1++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + } + kk1+=i2<<3; + ptr1=base->body+plane1>>3; + for (i=0;iinternal_width; + } + break; + case ROPB_XOR: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + case ROPB_OR: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + case ROPB_NAND: + if (color_bit) + for (j=h1;jinternal_width; + } + break; + } + if (++l1==FONT_WIDTH) { + ch=*s1++; + font_ptr=&grfont[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; + l1=0; + } + } + } + } + return TRUE; + } + return FALSE; +} + + +public BoolU4 GrBox(GrBitMap *base,I8 x,I8 y,I8 w,I8 h) +{ //Clipping but not transformation + I8 i,i1,i2,i3,j,k1,kk1,w1,h1,w2,h2,plane1,bit_mask,bit_shift,p,dist; + U2 *ptr1; + I8 color,color_byte,c,plane_size1,plane_limit1; + BoolU4 draw=TRUE,color_bit; + + w1= (x<0)?-x:0; + h1= (y<0)?-y:0; + w2=w; + h2=h; + + if (base->flags & BMF_SCREEN_BITMAP) { + x+=base->win_tss->win_pixel_left; + y+=base->win_tss->win_pixel_top; + } + if (base->flags & BMF_LOCATE_NEAREST) { //TODO:Untested + if (base->cur_x>=x && base->cur_y>=y && + base->cur_x<=x+w && base->cur_y<=y+h) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=0; + } else { + dist=DistI8(x+w>>1,y+h>>1,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + } + + if (base->flags & BMF_SCREEN_BITMAP) { + if (x+w1<0) w1=-x; + if (x+w2>base->win_tss->win_pixel_right) + w2=base->win_tss->win_pixel_right-x; + + if (y+h1<0) h1=-y; + if (y+h2>base->win_tss->win_pixel_bottom) + h2=base->win_tss->win_pixel_bottom-y; + + if (IsPixelCovered(base->win_tss,x+w1,y+h1)) + draw=FALSE; + else if (IsPixelCovered(base->win_tss,x+w2,y+h2)) + draw=FALSE; + x+=base->left_margin; + y+=base->top_margin; + } + if (x+w2>base->width) + w2=base->width-x; + if (y+h2>base->height) + h2=base->height-y; + if (draw && w1flags & BMF_DONT_DRAW) + return TRUE; + color=base->color; + p=0; + plane_size1=base->plane_size<<3; + switch (base->type) { + case BMT_COLOR4: + plane_limit1=plane_size1*4; + break; + case BMT_MONO: + plane_limit1=plane_size1; + break; + } + i1=(-w1)&7; + if (i1>w2) i1=w2; + i2=(w2-w1-i1)>>3; + i3=w2-w1-i2<<3-i1; + bit_shift=x&7; + bit_mask=-1-255<bkcolor&0xFFFFFF; + k1=(h1+y)*base->internal_width+x; + for (j=h1;jbody,k1+i+plane1)) + c+=p; + if (c!=color) + base->collision_cnt++; + } + k1+=base->internal_width; + } + } else + for (plane1=0;plane1internal_width+x+w1+plane1; + for (j=h1;jbody,k1++,color_byte); + break; + case ROPB_XOR: + for (i=0;ibody,k1++); + break; + case ROPB_OR: + for (i=0;ibody,k1++); + break; + case ROPB_NAND: + for (i=0;ibody,k1++); + break; + } + ptr1=k1>>3+base->body; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + for (i=0;ibody,k1++,color_byte); + break; + case ROPB_XOR: + for (i=0;ibody,k1++); + break; + case ROPB_OR: + for (i=0;ibody,k1++); + break; + case ROPB_NAND: + for (i=0;ibody,k1++); + break; + } + kk1+=base->internal_width; + } + } + return TRUE; + } + return FALSE; +} + + +I8 GrRayLenMinus(GrBitMap *base,I8 x,I8 y) +{ + I8 cnt=0,c,x3=x,y3=y,d; + U1 *dst,bit,*dst2; + BoolU4 peek=TRUE, + not_color=(base->flags&BMF_FILL_NOT_COLOR)?TRUE:FALSE; + + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) peek=FALSE; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) peek=FALSE; + + if (y3<0) peek=FALSE; + y3+=base->win_tss->win_pixel_top; + if (y3>base->win_tss->win_pixel_bottom) peek=FALSE; + if (x3>=base->width) peek=FALSE; + if (y3>=base->height) peek=FALSE; + if (IsPixelCovered(base->win_tss,x3,y3)) peek=FALSE; + } else { + if (x3<0) peek=FALSE; + if (x3>=base->width) peek=FALSE; + if (y3<0) peek=FALSE; + if (y3>=base->height) peek=FALSE; + } + if (!peek) + return 0; + + switch (base->type) { + case BMT_COLOR4: + dst2=base->body+(base->left_margin+ + (y3+base->top_margin)*base->internal_width)>>3; + d=base->plane_size; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + + dst=dst2+x3>>3; + bit=1<<(x3&7); + c=0; + if (*dst & bit) + c|=1; + dst+=d; + if (*dst & bit) + c|=2; + dst+=d; + if (*dst & bit) + c|=4; + dst+=d; + if (*dst & bit) + c|=8; + + if (not_color) { + if (c!=base->color2) { + cnt++; + x--; + } else + break; + } else { + if (c==base->color2) { + cnt++; + x--; + } else + break; + } + } + return cnt; + case BMT_MONO: + d=base->internal_width*(y3+base->top_margin)+ + base->left_margin; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + if (not_color) { + if (Bt(base->body,d+x3)!=base->color2) { + cnt++; + x--; + } else + break; + } else { + if (Bt(base->body,d+x3)==base->color2) { + cnt++; + x--; + } else + break; + } + } + return cnt; + } +} + +I8 GrRayLen(GrBitMap *base,I8 *x1,I8 y) +{ + I8 cnt=0,d,c,c2,x=*x1,x2=x,x3=x,y3=y; + BoolU4 peek=TRUE, + not_color=(base->flags&BMF_FILL_NOT_COLOR)?TRUE:FALSE; + U1 *dst,bit,not_bit,*dst2; + U8 color=base->color,bkcolor=base->bkcolor; + double dist; + + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) peek=FALSE; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) peek=FALSE; + + if (y3<0) peek=FALSE; + y3+=base->win_tss->win_pixel_top; + if (y3>base->win_tss->win_pixel_bottom) peek=FALSE; + if (x3>=base->width) peek=FALSE; + if (y3>=base->height) peek=FALSE; + if (IsPixelCovered(base->win_tss,x3,y3)) peek=FALSE; + } else { + if (x3<0) peek=FALSE; + if (x3>=base->width) peek=FALSE; + if (y3<0) peek=FALSE; + if (y3>=base->height) peek=FALSE; + } + if (!peek) + return 0; + + switch (base->type) { + case BMT_COLOR4: + dst2=base->body+(base->left_margin+ + (y3+base->top_margin)*base->internal_width)>>3; + d=base->plane_size; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + + dst=dst2+x3>>3; + bit=1<<(x3&7); + not_bit=~bit; + + c=0; + if (*dst & bit) + c|=1; + dst+=d; + if (*dst & bit) + c|=2; + dst+=d; + if (*dst & bit) + c|=4; + dst+=d; + if (*dst & bit) + c|=8; + + if (not_color && c!=base->color2 || + !not_color && c==base->color2) { + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x3,y3,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + dst=dst2+x3>>3; + + c=color.u1[0]; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + if (c & 1) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 2) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 4) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 8) + *dst|=bit; + else + *dst&=not_bit; + break; + case ROPB_COLLISION: + c2=0; + if (*dst&bit) + c2+=1; + dst+=d; + if (*dst&bit) + c2+=2; + dst+=d; + if (*dst&bit) + c2+=4; + dst+=d; + if (*dst&bit) + c2+=8; + if (c2!=bkcolor.u1[0]) + base->collision_cnt++; + break; + case ROPB_XOR: + if (c & 1) *dst^=bit; + dst+=d; + if (c & 2) *dst^=bit; + dst+=d; + if (c & 4) *dst^=bit; + dst+=d; + if (c & 8) *dst^=bit; + break; + case ROPB_OR: + if (c & 1) *dst|=bit; + dst+=d; + if (c & 2) *dst|=bit; + dst+=d; + if (c & 4) *dst|=bit; + dst+=d; + if (c & 8) *dst|=bit; + break; + case ROPB_NAND: + if (c & 1) *dst&=not_bit; + dst+=d; + if (c & 2) *dst&=not_bit; + dst+=d; + if (c & 4) *dst&=not_bit; + dst+=d; + if (c & 8) *dst&=not_bit; + break; + } + cnt++; + x++; + } else + break; + } + *x1=x-1; + x=x2-1; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + + dst=dst2+x3>>3; + bit=1<<(x3&7); + not_bit=~bit; + + c=0; + if (*dst & bit) + c|=1; + dst+=d; + if (*dst & bit) + c|=2; + dst+=d; + if (*dst & bit) + c|=4; + dst+=d; + if (*dst & bit) + c|=8; + + if (not_color && c!=base->color2 || + !not_color && c==base->color2) { + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x3,y3,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + dst=dst2+x3>>3; + + c=color.u1[0]; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + if (c & 1) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 2) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 4) + *dst|=bit; + else + *dst&=not_bit; + dst+=d; + if (c & 8) + *dst|=bit; + else + *dst&=not_bit; + break; + case ROPB_COLLISION: + c2=0; + if (*dst&bit) + c2+=1; + dst+=d; + if (*dst&bit) + c2+=2; + dst+=d; + if (*dst&bit) + c2+=4; + dst+=d; + if (*dst&bit) + c2+=8; + if (c2!=bkcolor.u1[0]) + base->collision_cnt++; + break; + case ROPB_XOR: + if (c & 1) *dst^=bit; + dst+=d; + if (c & 2) *dst^=bit; + dst+=d; + if (c & 4) *dst^=bit; + dst+=d; + if (c & 8) *dst^=bit; + break; + case ROPB_OR: + if (c & 1) *dst|=bit; + dst+=d; + if (c & 2) *dst|=bit; + dst+=d; + if (c & 4) *dst|=bit; + dst+=d; + if (c & 8) *dst|=bit; + break; + case ROPB_NAND: + if (c & 1) *dst&=not_bit; + dst+=d; + if (c & 2) *dst&=not_bit; + dst+=d; + if (c & 4) *dst&=not_bit; + dst+=d; + if (c & 8) *dst&=not_bit; + break; + } + cnt++; + x--; + } else + break; + } + return cnt; + case BMT_MONO: + d=base->internal_width*(y3+base->top_margin)+ + base->left_margin; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + + c=Bt(base->body,d+x3); + if (not_color && c!=base->color2 || + !not_color && c==base->color2) { + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x3,y3,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + c=color&0xFFFFFF; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + AssignBit(base->body,d+x3,c); + break; + case ROPB_COLLISION: + if (c) { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=Bt(base->body,d+x3); + else + base->collision_cnt+=!Bt(base->body,d+x3); + } else { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=!Bt(base->body,d+x3); + else + base->collision_cnt+=Bt(base->body,d+x3); + } + break; + case ROPB_XOR: + if (c) + Btc(base->body,d+x3); + break; + case ROPB_OR: + if (c) + Bts(base->body,d+x3); + break; + case ROPB_NAND: + if (c) + Btr(base->body,d+x3); + break; + } + cnt++; + x++; + } else + break; + } + *x1=x-1; + x=x2-1; + while (TRUE) { + x3=x; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x3<0) break; + x3+=base->win_tss->win_pixel_left; + if (x3>base->win_tss->win_pixel_right) break; + if (x3>=base->width) break; + if (IsPixelCovered(base->win_tss,x3,y3)) break; + } else { + if (x3<0) break; + if (x3>=base->width) break; + } + + c=Bt(base->body,d+x3); + if (not_color && c!=base->color2 || + !not_color && c==base->color2) { + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x3,y3,base->cur_x,base->cur_y); + if (dist<=base->nearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + c=color&0xFFFFFF; + switch (color.u1[3]) { + case ROPB_EQU: + case ROPB_TRANSPARENT: + AssignBit(base->body,d+x3,c); + break; + case ROPB_COLLISION: + if (c) { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=Bt(base->body,d+x3); + else + base->collision_cnt+=!Bt(base->body,d+x3); + } else { + if (bkcolor&0xFFFFFF) + base->collision_cnt+=!Bt(base->body,d+x3); + else + base->collision_cnt+=Bt(base->body,d+x3); + } + break; + case ROPB_XOR: + if (c) + Btc(base->body,d+x3); + break; + case ROPB_OR: + if (c) + Bts(base->body,d+x3); + break; + case ROPB_NAND: + if (c) + Btr(base->body,d+x3); + break; + } + cnt++; + x--; + } else + break; + } + return cnt; + } +} + \ No newline at end of file diff --git a/LT/Adam/Gr/GrChar.APZ b/LT/Adam/Gr/GrChar.APZ new file mode 100644 index 0000000..c71faa4 Binary files /dev/null and b/LT/Adam/Gr/GrChar.APZ differ diff --git a/LT/Adam/Gr/GrElem.APZ b/LT/Adam/Gr/GrElem.APZ new file mode 100644 index 0000000..6c9da8c --- /dev/null +++ b/LT/Adam/Gr/GrElem.APZ @@ -0,0 +1,1664 @@ +#define GRET_MENU -999 +#define GRET_CANCEL -1 +#define GRET_SNAP -2 + +#help_index "Graphics/Input" +I8 PopUpGrElemType(BoolU4 new_picture) +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Color (4-bit)\",GRET_COLOR4$$\r\n"); + LtfPutSExt(l,"$$MU,\"Width\",GRET_WIDTH$$\r\n"); + LtfPutSExt(l,"$$MU,\"Snap\",GRET_SNAP$$\r\n"); + LtfPutSExt(l,"$$MU,\"Point\",GRET_POINT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Line\",GRET_LINE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Box\",GRET_BOX$$\r\n"); + LtfPutSExt(l,"$$MU,\"Circle\",GRET_CIRCLE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Ellipse\",GRET_ELLIPSE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Text\",GRET_TEXT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Flood Fill\",GRET_FLOOD_FILL$$\r\n"); + LtfPutSExt(l,"$$MU,\"Flood Fill Not Color\",GRET_FLOOD_FILL_NOT$$\r\n"); + LtfPutSExt(l,"$$MU,\"SpeedLine\",GRET_SPEEDLINE$$\r\n"); + LtfPutSExt(l,"$$MU,\"PolyLine\",GRET_POLYLINE$$\r\n"); + LtfPutSExt(l,"$$MU,\"PolyPoint\",GRET_POLYPOINT$$\r\n"); + LtfPutSExt(l,"$$MU,\"BSpline2\",GRET_BSPLINE2$$\r\n"); + LtfPutSExt(l,"$$MU,\"BSpline3\",GRET_BSPLINE3$$\r\n"); + LtfPutSExt(l,"$$MU,\"BSpline2 Closed\",GRET_BSPLINE2_CLOSED$$\r\n"); + LtfPutSExt(l,"$$MU,\"BSpline3 Closed\",GRET_BSPLINE3_CLOSED$$\r\n"); + LtfPutSExt(l,"$$MU,\"to Bitmap (4-bit)\",GRET_BITMAP4$$\r\n"); + LtfPutSExt(l,"$$MU,\"to Bitmap (4-bit) Transparent\",GRET_BITMAP4_TRANSPARENT$$\r\n"); + LtfPutSExt(l,"$$MU,\"End\",GRET_END$$\r\n"); + if (new_picture) + LtfPutSExt(l,"$$MU,\"Cancel\",GRET_CANCEL$$\r\n"); + LtfPutSExt(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$$$$FM,BLACK$$$$MU,\"__%-8Z__\",%d$$\r\n",i,i,"ST_COLORS",i); + LtfPutSExt(l,"$$BM,WHITE$$$$MU,\"DEFAULT\",LTF_DEFAULT$$"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +public I8 PopUpI8_16() +{ + 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; +} + +#help_index "Graphics/GrElem" +#help_file "::/LT/Doc/GrElem.TXZ" + +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_WIDTH: + i+=offset(GrElem.y1)-offset(GrElem.start); + break; + case GRET_TEXT: + i+=offset(GrElem.st)-offset(GrElem.start); + break; + case GRET_POINT: + case GRET_FLOOD_FILL: + case GRET_FLOOD_FILL_NOT: + i+=offset(GrElem.x2)-offset(GrElem.start); + break; + case GRET_ELLIPSE: + case GRET_SPEEDLINE_POINT: + i+=sizeof(GrElem)-offset(GrElem.start); + break; + case GRET_LINE: + i+=offset(GrElem.linespeed)-offset(GrElem.start); + break; + case GRET_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + i+=sizeof(GrElem)-offset(GrElem.start); + break; + case GRET_BOX: + i+=offset(GrElem.linespeed)-offset(GrElem.start); + break; + case GRET_CIRCLE: + i+=offset(GrElem.y2)-offset(GrElem.start); + break; + case GRET_SPEEDLINE: + 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_TEXT: + i+=StrLen(tempg->st)+1; + break; + case GRET_SPEEDLINE: + i+=tempg->num*(2*sizeof(I4)+sizeof(double)); + break; + case GRET_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + i+=((tempg->width+7)&~7)*tempg->height*4/8; + break; + case GRET_POLYPOINT: +//Backward compatibility kludge: num should num-1 + 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,void *elems) +{ + GrElem *tempg=elems-offset(GrElem.start); + I8 i,j,k; + I8 x1,y1,x2,y2; + I4 *ptr; + I8 cur_sub_GrElem_num=0; + U8 colorbase=base->bkcolor; + GrBitMap *img; + P3I4 *p; + nounusedwarn z; + if (colorbase.u1[3]==ROPB_COLLISION) + base->color=colorbase; + 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_WIDTH: + base->pen_width=tempg->width; + GrScalePenWidth(base); + break; + case GRET_POINT: + GrPlot3(base,tempg->x1+x,tempg->y1+y,0); + break; + case GRET_TEXT: + GrText3(base,tempg->x1+x,tempg->y1+y,0,tempg->st); + break; + case GRET_FLOOD_FILL: + GrFloodFill3(base,tempg->x1+x,tempg->y1+y,0,FALSE); + break; + case GRET_FLOOD_FILL_NOT: + GrFloodFill3(base,tempg->x1+x,tempg->y1+y,0,TRUE); + 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_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + img=MAllocZ(sizeof(GrBitMap)); + img->type=BMT_COLOR4; + img->width=tempg->width; + img->internal_width=(tempg->width+7)&~7; + img->height=tempg->height; + img->left_margin=0; + img->right_margin=tempg->width; + img->top_margin=0; + img->bottom_margin=tempg->height; + img->plane_size=(img->internal_width*img->height)>>3; + img->body=tempg+sizeof(GrElem); + img->bitmap_signature=BMS_SIGNATURE; + img->bkcolor=tempg->bkcolor; + i=base->color; + if (tempg->type==GRET_BITMAP4) + base->color=ROP_EQU+i&0xFFFFFF; + else + base->color=ROP_TRANSPARENT+i&0xFFFFFF; + GrBlot3(base,tempg->x2+x,tempg->y2+y,0,img); + base->color=i; + Free(img); + break; + case GRET_BOX: + GrBox3(base,tempg->x1+x,tempg->y1+y,0,tempg->x2-tempg->x1,tempg->y2-tempg->y1); + break; + case GRET_CIRCLE: + GrCircle3(base,tempg->x1+x,tempg->y1+y,0,tempg->x2); + break; + case GRET_ELLIPSE: + GrEllipse3(base,tempg->x2+x,tempg->y2+y,0,tempg->width,tempg->height,tempg->rot_angle); + break; + case GRET_POLYLINE: + ptr=&tempg->y1; + x1=ptr[0]; + y1=ptr[1]; + for (i=1;inum;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_SPEEDLINE: + ptr=&tempg->y1; + x1=ptr[0]; + y1=ptr[1]; + for (i=1;inum;i++) { + x2=ptr[i<<2]; + y2=ptr[i<<2+1]; +//TODO GrSpeedLine2(base,x1+x,y1+y,0,x2+x,y2+y,0,ptr[i<<2+2]><(double)); + GrSpeedLine(base,x1+x,y1+y,x2+x,y2+y,ptr[i<<2+2]><(double)); + x1=x2;y1=y2; + } + break; + case GRET_POLYPOINT: + ptr=&tempg->y1; + x1=ptr[0]; + y1=ptr[1]; + ptr+=sizeof(I4)<<1; + k=(tempg->num-1)*3; + GrPlot3(base,x1+x,y1+y,0); + for (i=0;iy1; + for (i=0;inum;i++) { + p[i].x+=x; + p[i].y+=y; + } + Gr2BSpline3(base,p,tempg->num,FALSE); + for (i=0;inum;i++) { + p[i].x-=x; + p[i].y-=y; + } + break; + case GRET_BSPLINE3: + p=&tempg->y1; + for (i=0;inum;i++) { + p[i].x+=x; + p[i].y+=y; + } + Gr3BSpline3(base,p,tempg->num,FALSE); + for (i=0;inum;i++) { + p[i].x-=x; + p[i].y-=y; + } + break; + case GRET_BSPLINE2_CLOSED: + p=&tempg->y1; + for (i=0;inum;i++) { + p[i].x+=x; + p[i].y+=y; + } + Gr2BSpline3(base,p,tempg->num,TRUE); + for (i=0;inum;i++) { + p[i].x-=x; + p[i].y-=y; + } + break; + case GRET_BSPLINE3_CLOSED: + p=&tempg->y1; + for (i=0;inum;i++) { + p[i].x+=x; + p[i].y+=y; + } + Gr3BSpline3(base,p,tempg->num,TRUE); + for (i=0;inum;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; + nounusedwarn dz; + while (tempg!=root) { + switch (tempg->type) { + case GRET_POINT: + case GRET_FLOOD_FILL: + case GRET_FLOOD_FILL_NOT: + 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_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + case GRET_ELLIPSE: + tempg->x2+=dx; + tempg->y2+=dy; + break; + case GRET_BOX: + tempg->x1+=dx; + tempg->y1+=dy; + tempg->x2+=dx; + tempg->y2+=dy; + break; + case GRET_TEXT: + case GRET_CIRCLE: + tempg->x1+=dx; + tempg->y1+=dy; + break; + case GRET_POLYLINE: + ptr=&tempg->y1; + ptr[0]+=dx; + ptr[1]+=dy; + for (i=1;inum;i++) { + ptr[i<<1]+=dx; + ptr[i<<1+1]+=dy; + } + break; + case GRET_SPEEDLINE: + ptr=&tempg->y1; + ptr[0]+=dx; + ptr[1]+=dy; + for (i=1;inum;i++) { + ptr[i<<2]+=dx; + ptr[i<<2+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;inum;i++) { + p[i].x+=dx; + p[i].y+=dy; + } + break; + } + tempg=tempg->next; + } +} + + +I1 GrElOffset[9]={0,1,2,3,0,4,5,6,7}; + +void GrPolyPointPlot(GrElem *root,I8 x,I8 y,I8 z) +{ + nounusedwarn z; + GrElem *tempg=MAllocZ(GrElemBaseSize(GRET_POINT)); + tempg->type=GRET_POINT; + tempg->x1=x; + tempg->y1=y; + InsQue(tempg,root->last); +} + + +GrElem *GrTransformCircle(I8 *r,GrElem *tempg) +{ + I8 x,y,z,radius=tempg->x2<<24; + double m1,a1,m2; + GrElem *tempg1=MAllocZ(GrElemBaseSize(GRET_ELLIPSE)); + tempg1->type=GRET_ELLIPSE; + + x=tempg->x1; y=tempg->y1; z=0; + GrRotate(r,&x,&y,&z); + tempg1->x2=x; + tempg1->y2=y; + + x=radius; y=0; z=0; + GrRotate(r,&x,&y,&z); + R2P(&m1,&a1,x,y); + + x=0; y=radius; z=0; + GrRotate(r,&x,&y,&z); + m2=Sqrt(x*x+y*y); + + tempg1->width=m1/0x1000000; + tempg1->height=m2/0x1000000; + tempg1->rot_angle=-a1; + + return tempg1; +} + + +GrElem *GrTransformEllipse(I8 *r,GrElem *tempg) +{ + I8 x,y,z,x_radius=tempg->width<<24,y_radius=tempg->height<<24; + double m1,a1,m2,a2,s,c; + GrElem *tempg1=MAllocZ(GrElemBaseSize(GRET_ELLIPSE)); + tempg1->type=GRET_ELLIPSE; + + x=tempg->x2; y=tempg->y2; z=0; + GrRotate(r,&x,&y,&z); + tempg1->x2=x; + tempg1->y2=y; + + c=Cos(tempg->rot_angle); + s=Sin(tempg->rot_angle); + + x=x_radius*c; + y=x_radius*s; + z=0; + GrRotate(r,&x,&y,&z); + R2P(&m1,&a1,x,y); + + x=-y_radius*s; + y=y_radius*c; + z=0; + GrRotate(r,&x,&y,&z); + R2P(&m2,&a2,x,y); + m2=m2*Abs(Sin(a2-a1)); + + tempg1->width=m1/0x1000000; + tempg1->height=m2/0x1000000; + tempg1->rot_angle=-a1; + + return tempg1; +} + + +public void GrElemTransform(I8 *r,GrElem *root) +{ + I8 x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3; + I8 i,j,k,num; + I4 *ptr; + P3I4 *p; + GrElem *tempg=root->next,root2,*tempg1,*tempg2,*tempg3; + while (tempg!=root) { + switch (tempg->type) { + case GRET_POINT: + case GRET_FLOOD_FILL: + case GRET_FLOOD_FILL_NOT: + x=tempg->x1; y=tempg->y1; z=0; + GrRotate(r,&x,&y,&z); + tempg->x1=x; + tempg->y1=y; + break; + case GRET_LINE: + x=tempg->x1; y=tempg->y1; z=0; + GrRotate(r,&x,&y,&z); + tempg->x1=x; + tempg->y1=y; + x=tempg->x2; y=tempg->y2; z=0; + GrRotate(r,&x,&y,&z); + tempg->x2=x; + tempg->y2=y; + break; + case GRET_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + x=tempg->x2; y=tempg->y2; z=0; + GrRotate(r,&x,&y,&z); + tempg->x2=x; + tempg->y2=y; + break; + case GRET_BOX: + x=tempg->x1; y=tempg->y1; z=0; + GrRotate(r,&x,&y,&z); + tempg->x1=x; + tempg->y1=y; + x=tempg->x2; y=tempg->y2; z=0; + GrRotate(r,&x,&y,&z); + tempg->x2=x; + tempg->y2=y; + break; + case GRET_TEXT: + x=tempg->x1; y=tempg->y1; z=0; + GrRotate(r,&x,&y,&z); + tempg->x1=x; + tempg->y1=y; + break; + case GRET_CIRCLE: + tempg1=GrTransformCircle(r,tempg); + InsQue(tempg1,tempg); + RemQue(tempg); + Free(tempg); + tempg=tempg1; + break; + case GRET_ELLIPSE: + tempg1=GrTransformEllipse(r,tempg); + InsQue(tempg1,tempg); + RemQue(tempg); + Free(tempg); + tempg=tempg1; + break; + case GRET_POLYLINE: + ptr=&tempg->y1; + x=ptr[0]; y=ptr[1]; z=0; + GrRotate(r,&x,&y,&z); + ptr[0]=x; + ptr[1]=y; + for (i=1;inum;i++) { + x=ptr[i<<1]; y=ptr[i<<1+1]; z=0; + GrRotate(r,&x,&y,&z); + ptr[i<<1]=x; + ptr[i<<1+1]=y; + } + break; + case GRET_SPEEDLINE: + ptr=&tempg->y1; + x=ptr[0]; y=ptr[1]; z=0; + GrRotate(r,&x,&y,&z); + ptr[0]=x; + ptr[1]=y; + for (i=1;inum;i++) { + x=ptr[i<<2]; y=ptr[i<<2+1]; z=0; + GrRotate(r,&x,&y,&z); + ptr[i<<2]=x; + ptr[i<<2+1]=y; + } + break; + case GRET_POLYPOINT: + root2.next=&root2; + root2.last=&root2; + ptr=&tempg->y1; + x=ptr[0]; y=ptr[1]; z=0; + x1=x; y1=y; z1=z; //unrotated cur coordinates + GrRotate(r,&x,&y,&z); + ptr+=sizeof(I4)<<1; + k=(tempg->num-1)*3; + x2=x; y2=y; z2=z; //rotated start coordinates + x3=x; y3=y; z3=z; //lag 1 rotated coordinates + for (i=0;inext; + if (tempg1->x1==x3 && tempg1->y1==y3) { + RemQue(tempg1); + Free(tempg1); + } else { + num++; + x3=tempg1->x1; + y3=tempg1->y1; + } + tempg1=tempg2; + } + + tempg3=MAllocZ(GrElemBaseSize(GRET_POLYPOINT)+ + sizeof(I4)*2+(num*3+7)>>3); + ptr=&tempg3->y1; + ptr[0]=x2; + ptr[1]=y2; + ptr+=sizeof(I4)<<1; + x3=0;y3=0; z3=0; + i=0; + tempg1=root2.next; + while (tempg1!=&root2) { + tempg2=tempg1->next; + OrU4BitField(ptr,i, + GrElOffset[SignI8(tempg1->x1-x3)+1+ + 3*(SignI8(tempg1->y1-y3)+1)]); + i+=3; + x3=tempg1->x1;y3=tempg1->y1; + RemQue(tempg1); + Free(tempg1); + tempg1=tempg2; + } + tempg3->type=GRET_POLYPOINT; + tempg3->num=num+1; + InsQue(tempg3,tempg); + RemQue(tempg); + Free(tempg); + tempg=tempg3; + break; + case GRET_BSPLINE2: + case GRET_BSPLINE3: + case GRET_BSPLINE2_CLOSED: + case GRET_BSPLINE3_CLOSED: + p=&tempg->y1; + for (i=0;inum;i++) { + x=ptr[i]; y=ptr[i]; z=0; + GrRotate(r,&x,&y,&z); + p[i].x=x; + p[i].y=y; + } + break; + } + tempg=tempg->next; + } +} + +class EGETStruct +{ + double x_scale fmtstr "$$DA-T,32,\"X Scale :%12.6f\"$$\r\n"; + double y_scale fmtstr "$$DA-T,32,\"Y Scale :%12.6f\"$$\r\n"; + double z_scale fmtstr "$$DA-T,32,\"Z Scale :%12.6f\"$$\r\n"; + double theta1 fmtstr "\r\nAngles are in degrees\r\n$$DA-T,32,\"Theta1 :%12.6f\"$$\r\n"; + double phi fmtstr "$$DA-T,32,\"Phi :%12.6f\"$$\r\n"; + double theta2 fmtstr "$$DA-T,32,\"Theta2 :%12.6f\"$$\r\n"; + double x_offset fmtstr "\r\n$$DA-T,32,\"X Offset:%12.6f\"$$\r\n"; + double y_offset fmtstr "$$DA-T,32,\"Y Offset:%12.6f\"$$\r\n"; + double z_offset fmtstr "$$DA-T,32,\"Z Offset:%12.6f\"$$\r\n"; +}; + +void EditGrElemTransform(GrElem *root) +{ + EGETStruct *eg=MAlloc(sizeof(EGETStruct)); + I8 *r=MAllocZ(sizeof(I8)*16),*r1,*r2; + eg->x_scale=1.0; + eg->y_scale=1.0; + eg->z_scale=1.0; + eg->theta1=0.0; + eg->phi=0.0; + eg->theta2=0.0; + eg->x_offset=0.0; + eg->y_offset=0.0; + eg->z_offset=0.0; + if (DoForm(eg,"EGETStruct")) { + r[0]=eg->x_scale*gr_scale; + r[5]=eg->y_scale*gr_scale; + r[10]=eg->z_scale*gr_scale; + r[15]=gr_scale; + + r1=GrTheta(-eg->theta1*pi/180.0); + r2=GrMulMat(r,r1); + Free(r); + Free(r1); + r=r2; + + r1=GrPhi(eg->phi*pi/180.0); + r2=GrMulMat(r,r1); + Free(r); + Free(r1); + r=r2; + + r1=GrTheta(-eg->theta2*pi/180.0); + r2=GrMulMat(r,r1); + Free(r); + Free(r1); + r=r2; + + r[3]=eg->x_offset*gr_scale; + r[7]=eg->y_offset*gr_scale; + r[11]=eg->z_offset*gr_scale; + + GrElemTransform(r,root); + } + Free(r); +} + + +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; + U4 *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 I8 PopUpPickGrElem(GrElem *root,I8 old_num=0) +{ + Ltf *l=LtfNew; + GrElem *tempg; + I8 cur_num=0; + + tempg=root->next; + while (tempg!=root) { + if (cur_num==old_num) + LtfPrintF(l,"$$FM,LTRED$$"); + else + LtfPrintF(l,"$$FM,LTBLUE$$"); + LtfPrintF(l,"$$MU,\"%Z\",%d$$\r\n", + tempg->type,"ST_GRELEM_TYPES",cur_num++); + tempg=tempg->next; + } + if (cur_num==old_num) + LtfPrintF(l,"$$FM,LTRED$$"); + else + LtfPrintF(l,"$$FM,LTBLUE$$"); + LtfPrintF(l,"$$MU,\"END\",%d$$\r\n",cur_num); + cur_num=PopUpMenu(l); + LtfDel(l); + return cur_num; +} + +public BoolU8 GrElemTextEdit(GrElem *root) +{ + Ltf *l=LtfNew; + GrElem *tempg; + LtfEntry *ll; + BoolU8 result; + tempg=root->next; + while (tempg!=root) { + LtfPrintF(l,"%Z\r\n", + tempg->type,"ST_GRELEM_TYPES"); + ll=LtfPrintF(l," $$HX,%d,16$$\r\n",GrElemSize(tempg,FALSE)); + ll->data=&tempg->start; + tempg=tempg->next; + } + result=ServantUser("DoMenu(0x%X,0x%X,0x%X);",l,NULL,0); + LtfDel(l); + return result; +} + + +#define GED_PICK_TEXT 1 +#define GED_PICK_GRAPHICALLY 2 +#define GED_SET_ORIGIN 3 +#define GED_TRANSFORM 4 +#define GED_SHIFT_ORIGIN 5 +#define GED_INSERT 6 +#define GED_DELETE 7 +#define GED_EDIT 8 +#define GED_END 9 +#define GED_CANCEL -1 + +I8 PopUpGrElemsEditChoice() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Pick from text\",GED_PICK_TEXT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Pick graphically\",GED_PICK_GRAPHICALLY$$\r\n"); + LtfPutSExt(l,"$$MU,\"Set Origin\",GED_SET_ORIGIN$$\r\n"); + LtfPutSExt(l,"$$MU,\"Transform\",GED_TRANSFORM$$\r\n"); + LtfPutSExt(l,"$$MU,\"Insert Shift Origin\",GED_SHIFT_ORIGIN$$\r\n"); + LtfPutSExt(l,"$$MU,\"Insert\",GED_INSERT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Delete\",GED_DELETE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Edit\",GED_EDIT$$\r\n"); + LtfPutSExt(l,"$$MU,\"End\",GED_END$$\r\n"); + LtfPutSExt(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); +} + +void GrSetSettings(GrBitMap *base,GrElem *root,I8 cur_num,U8 *color,U8 *bkcolor,I8 *width) +{ + GrElem *tempg; + *bkcolor=(Fs->text_attribute>>4)&15; + *color=ROP_EQU|BLACK^*bkcolor; + *width=1; + GrReset(base); + + tempg=root->next; + while (cur_num>0 && tempg!=root) { + switch (tempg->type) { + case GRET_COLOR4: + *color=tempg->color4^*bkcolor; + base->color=*color; + break; + case GRET_WIDTH: + *width=tempg->width; + base->pen_width=*width; + break; + } + cur_num--; + tempg=tempg->next; + } +} + +class GrSnapStruct +{ + I8 x,y,z,xo,yo,zo; +}; + +void GrSetSnap(GrSnapStruct *g) +{ + ipx_snap=g->x; + ipy_snap=g->y; + ipz_snap=g->z; + ipx_snap_offset=g->xo; + ipy_snap_offset=g->yo; + ipz_snap_offset=g->zo; +} + +BoolU8 GrElemsInsert(LtfBinEntry *tempb,I8 *cur_num,GrElem *root,I8 x,I8 y,BoolU4 new_picture) +{ + I8 i,cmd,x1,y1,x2,y2,x3,y3,p1,p2, + bkcolor,color,num,old_width; + I4 *ptr; + BoolU4 old_ip_double=Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + I8 eletype=GRET_MENU; + GrElem root2,*tempg,*tempg1,*tempg2,*insert_point; + BoolU4 old_inhibit=ip_inhibit_win_operations; + GrBitMap *base=GrAlias(Gs->grbase,Fs); + I8 width; + GrSnapStruct old_snap,new_snap; + GrBitMap *img; + P3I4 *p; + I1 *st; + double m1,a1; + insert_point=GrNumToQueue(root,*cur_num,&x1,&y1); + x+=x1; y+=y1; + + old_snap.x=ipx_snap; + old_snap.y=ipy_snap; + old_snap.z=ipz_snap; + old_snap.xo=ipx_snap_offset; + old_snap.yo=ipy_snap_offset; + old_snap.zo=ipz_snap_offset; + MemCpy(&new_snap,&old_snap,sizeof(GrSnapStruct)); + + ip_inhibit_win_operations=TRUE; + while (TRUE) { + GrSetSettings(base,root,*cur_num,&color,&bkcolor,&width); + GrClear; + if (eletype==GRET_MENU) { + ip_inhibit_win_operations=FALSE; + GrSetSnap(&old_snap); + i=PopUpGrElemType(new_picture); + if (i>GRET_MENU) + eletype=i; + switch (eletype) { + case GRET_FLOOD_FILL: + case GRET_FLOOD_FILL_NOT: +AccntOneTimePopUp(ARf_FLOODFILL_MSG, +ST_WARNING "This is affected by what's underneath\r\n" +"when it is drawn. You will probably want to\r\n" +"convert it to a bitmap.\r\n\r\n" +"A tip on artistry you might consider\r\n" +"is using lines to fill regions because\r\n" +"brush strokes look cool.\r\n"); + break; + } + + GrSetSnap(&new_snap); + ip_inhibit_win_operations=TRUE; + } + switch (eletype) { + case GRET_COLOR4: + ip_inhibit_win_operations=FALSE; + GrSetSnap(&old_snap); + 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+=1; + } + GrSetSnap(&new_snap); + ip_inhibit_win_operations=TRUE; + eletype=GRET_MENU; + break; + case GRET_WIDTH: + ip_inhibit_win_operations=FALSE; + GrSetSnap(&old_snap); + i=PopUpI8_16; + 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+=1; + } + GrSetSnap(&new_snap); + ip_inhibit_win_operations=TRUE; + eletype=GRET_MENU; + break; + case GRET_SNAP: + ip_inhibit_win_operations=FALSE; + GrSetSnap(&old_snap); + i=PopUpI8_16; + if (i>=1) { + new_snap.x=i; + new_snap.y=i; + new_snap.z=i; + new_snap.xo=Fs->win_pixel_left%i; + new_snap.yo=Fs->win_pixel_top%i; + new_snap.zo=0; + } + GrSetSnap(&new_snap); + ip_inhibit_win_operations=TRUE; + eletype=GRET_MENU; + break; + case GRET_TEXT: + ip_inhibit_win_operations=FALSE; + GrSetSnap(&old_snap); + st=PopUp("ANewStr(PmtStr(\"Text:\"));",Fs); + GrSetSnap(&new_snap); + ip_inhibit_win_operations=TRUE; + if (st) { + x1=0; y1=0; + do { + base->color=color&0xFFFFFF|ROP_OR; + GrText3(base,x1,y1,0,st); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrText3(base,x1,y1,0,st); + x1=p1; y1=p2; + } while (cmd!=MSG_IP_L_UP); + tempg=MAllocZ(GrElemBaseSize(GRET_TEXT)+StrLen(st)+1); + tempg->type=GRET_TEXT; + tempg->x1=x1-x; + tempg->y1=y1-y; + StrCpy(tempg->st,st); + InsQue(tempg,insert_point->last); + GrEditUpdate(tempb,root); + *cur_num+=1; + AFree(st); + } + eletype=GRET_MENU; + break; + } + if (eletype!=GRET_MENU) { + cmd=0;p1=0;p2=0; + if (eletype!=GRET_END && eletype!=-1) { + cmd=GetMsg(&p1,&p2, + (1<crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double); + ip_inhibit_win_operations=old_inhibit; + GrDel(base); + GrSetSnap(&old_snap); + 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<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+=1; + break; + case GRET_BOX: + x1=p1; y1=p2; + x2=p1; y2=p2; + do { + base->color=color&0xFFFFFF|ROP_OR; + GrBox3(base,x1,y1,0,x2-x1,y2-y1); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrBox3(base,x1,y1,0,x2-x1,y2-y1); + x2=p1; y2=p2; + if (x2color=color&0xFFFFFF|ROP_EQU; + GrBox3(base,x1,y1,0,x2-x1,y2-y1); + tempg=MAlloc(GrElemBaseSize(GRET_BOX)); + tempg->type=GRET_BOX; + 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+=1; + break; + case GRET_BITMAP4: + case GRET_BITMAP4_TRANSPARENT: + x1=p1; y1=p2; + x2=p1; y2=p2; + old_width=base->pen_width; + base->pen_width=1; + do { + base->color=color&0xFFFFFF|ROP_OR; + GrLine3(base,x1,y1,0,x2,y1,0); + GrLine3(base,x1,y1,0,x1,y2,0); + GrLine3(base,x2,y2,0,x2,y1,0); + GrLine3(base,x2,y2,0,x1,y2,0); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrLine3(base,x1,y1,0,x2,y1,0); + GrLine3(base,x1,y1,0,x1,y2,0); + GrLine3(base,x2,y2,0,x2,y1,0); + GrLine3(base,x2,y2,0,x1,y2,0); + x2=p1; y2=p2; + if (x2color=color&0xFFFFFF|ROP_EQU; + GrLine3(base,x1,y1,0,x2,y1,0); + GrLine3(base,x1,y1,0,x1,y2,0); + GrLine3(base,x2,y2,0,x2,y1,0); + GrLine3(base,x2,y2,0,x1,y2,0); + x2++; y2++; + tempg=MAllocZ(GrElemBaseSize(GRET_BITMAP4)+ + ((x2-x1+7)&~7)*(y2-y1)/2); + tempg->type=eletype; + tempg->width=x2-x1; + tempg->height=y2-y1; + tempg->x2=x1-x; + tempg->y2=y1-y; + tempg->bkcolor=bkcolor; + img=GrBitMapNew(BMT_COLOR4,tempg->width,tempg->height,Fs); + img->color=bkcolor; + GrBox(img,0,0,tempg->width,tempg->height); + GrSetSettings(img,root,0,&color,&bkcolor,&width); + GrElemsPlot(img,-(x1-x),-(y1-y),0,tempb->data); + MemCpy(tempg+sizeof(GrElem),img->body,((x2-x1+7)&~7)*(y2-y1)/2); + GrDel(img); + GrElemsDel(root); + root->next=root; + root->last=root; + InsQue(tempg,insert_point->last); + GrEditUpdate(tempb,root); + *cur_num=1; + base->pen_width=old_width; + eletype=GRET_MENU; + break; + case GRET_CIRCLE: + x1=p1; y1=p2; + x2=p1; y2=p2; + do { + base->color=color&0xFFFFFF|ROP_OR; + GrCircle3(base,x1,y1,0,Sqrt(SqrI8(x1-x2)+SqrI8(y1-y2))); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrCircle3(base,x1,y1,0,Sqrt(SqrI8(x1-x2)+SqrI8(y1-y2))); + x2=p1; y2=p2; + } while (cmd!=MSG_IP_L_UP); + base->color=color&0xFFFFFF|ROP_EQU; + GrCircle3(base,x1,y1,0,Sqrt(SqrI8(x1-x2)+SqrI8(y1-y2))); + tempg=MAlloc(GrElemBaseSize(GRET_CIRCLE)); + tempg->type=GRET_CIRCLE; + tempg->x1=x1-x; + tempg->y1=y1-y; + tempg->x2=Sqrt(SqrI8(x1-x2)+SqrI8(y1-y2)); + InsQue(tempg,insert_point->last); + GrEditUpdate(tempb,root); + *cur_num+=1; + break; + case GRET_ELLIPSE: + x1=p1; y1=p2; + x2=p1; y2=p2; + do { + base->color=color&0xFFFFFF|ROP_OR; + GrEllipse3(base,(x1+x2)>>1,(y1+y2)>>1,0, + AbsI8(x1-x2)>>1,AbsI8(y1-y2)>>1); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrEllipse3(base,(x1+x2)>>1,(y1+y2)>>1,0, + AbsI8(x1-x2)>>1,AbsI8(y1-y2)>>1); + x2=p1; y2=p2; + } while (cmd!=MSG_IP_L_UP); + tempg=MAlloc(GrElemBaseSize(GRET_ELLIPSE)); + tempg->type=GRET_ELLIPSE; + tempg->x2=(x1+x2)>>1-x; + tempg->y2=(y1+y2)>>1-y; + tempg->width =AbsI8(x1-x2)>>1; + tempg->height=AbsI8(y1-y2)>>1; + + do { + R2P(&m1,&a1,x2-(tempg->x2+x),y2-(tempg->y2+y)); + tempg->rot_angle=-a1; + base->color=color&0xFFFFFF|ROP_OR; + GrEllipse3(base,tempg->x2+x,tempg->y2+y,0, + tempg->width,tempg->height,tempg->rot_angle); + cmd=GetMsg(&p1,&p2, + (1<color=color&0xFFFFFF|ROP_NAND; + GrEllipse3(base,tempg->x2+x,tempg->y2+y,0, + tempg->width,tempg->height,tempg->rot_angle); + x2=p1; y2=p2; + } while (cmd!=MSG_IP_L_UP); + + R2P(&m1,&a1,x2-(tempg->x2+x),y2-(tempg->y2+y)); + tempg->rot_angle=-a1; + + base->color=color&0xFFFFFF|ROP_EQU; + GrEllipse3(base,tempg->x2+x,tempg->y2+y,0, + tempg->width,tempg->height,tempg->rot_angle); + InsQue(tempg,insert_point->last); + GrEditUpdate(tempb,root); + *cur_num+=1; + break; + case GRET_POINT: + x1=p1; y1=p2; + 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+=1; + break; + case GRET_FLOOD_FILL: + case GRET_FLOOD_FILL_NOT: + x1=p1; y1=p2; + tempg=MAlloc(GrElemBaseSize(GRET_FLOOD_FILL)); + tempg->type=eletype; + tempg->x1=x1-x; + tempg->y1=y1-y; + InsQue(tempg,insert_point->last); + GrEditUpdate(tempb,root); + *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<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;inext; + 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+=1; + } + break; + case GRET_SPEEDLINE: + 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<linespeed=ip_speed; +//TODO: GrSpeedLine2(base,x1,y1,0,x2,y2,0,tempg->linespeed); + GrSpeedLine(base,x1,y1,x2,y2,tempg->linespeed); + tempg->type=GRET_SPEEDLINE_POINT; + tempg->x1=x2-x; + tempg->y1=y2-y; + InsQue(tempg,root2.last); + x1=x2;y1=y2; + } 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_SPEEDLINE)+ + (num+1)*(sizeof(I4)*2+sizeof(double))); + ptr=&tempg2->y1; + tempg=root2.next; + ptr[0]=x3; + ptr[1]=y3; + ptr+=sizeof(I4)*2+sizeof(double); + x1=x3;y1=y3; + for (i=0;inext; + ptr[i<<2]=tempg->x1; + ptr[i<<2+1]=tempg->y1; + ptr[i<<2+2]><(double)=tempg->linespeed; + Free(tempg); + tempg=tempg1; + } + tempg2->type=GRET_SPEEDLINE; + tempg2->num=num+1; + InsQue(tempg2,insert_point->last); + GrEditUpdate(tempb,root); + *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<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; + ptr[0]=x3; + ptr[1]=y3; + ptr+=sizeof(I4)<<1; + x1=x3;y1=y3; + i=0; + tempg=root2.next; + while (tempg!=&root2) { + tempg1=tempg->next; + OrU4BitField(ptr,i, + GrElOffset[SignI8(tempg->x1-x1)+1+ + 3*(SignI8(tempg->y1-y1)+1)]); + i+=3; + x1=tempg->x1;y1=tempg->y1; + RemQue(tempg); + Free(tempg); + tempg=tempg1; + } + tempg2->type=GRET_POLYPOINT; + tempg2->num=num+1; + InsQue(tempg2,insert_point->last); + GrEditUpdate(tempb,root); + *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<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; + for (i=1;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+=1; + } + break; + } + } + } + } +} + + +void EditInsertGraphic(Ltf *l,I8 x,I8 y) +{ + BoolU4 old_preempt=Preempt(OFF); + I1 *st; + LtfEntry *ll; + LtfBinEntry *tempb; + I8 cur_num=0; + GrElem *root; + if (Fs!=l->mem_tss) + Debugger; + tempb=MAllocZ(sizeof(LtfBinEntry),l->mem_tss); + tempb->type=LTFBT_GRELEM; + tempb->size=GrElemBaseSize(GRET_END,FALSE); + tempb->data=MAllocZ(tempb->size,l->mem_tss); + if (st=EditPicture) { + ll=LtfPutSExt(l,st); + Free(st); + ll->bin_num=l->cur_bin_num; + tempb->num=l->cur_bin_num++; + ll->bin_data=tempb; + InsQue(tempb,l->bin_root.last); + Preempt(old_preempt); + root=GrElemsToQueue(tempb->data); + x+=StrLen(ll->display)*FONT_WIDTH; + if (!GrElemsInsert(tempb,&cur_num,root,x,y,TRUE)) { + Preempt(OFF); + RemQue(ll); + Free(ll,l->mem_tss); + Free(ll->display,l->mem_tss); + RemQue(tempb); + Free(tempb->data,l->mem_tss); + Free(tempb,l->mem_tss); + Preempt(old_preempt); + } + GrElemsDel(root); + } else { + Free(tempb->data,l->mem_tss); + Free(tempb,l->mem_tss); + } +} + + +public LtfEntry *LtfPutGrElem(Ltf *l,U1 *elems,U8 size,U1 *txt=NULL) +{ + I1 *st; + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *ll; + LtfBinEntry *tempb; + tempb=MAllocZ(sizeof(LtfBinEntry),l->mem_tss); + tempb->type=LTFBT_GRELEM; + tempb->size=size; + tempb->data=MAlloc(size,l->mem_tss); + MemCpy(tempb->data,elems,size); + tempb->num=l->cur_bin_num; + InsQue(tempb,l->bin_root.last); + if (txt) + st=MSPrintF(txt,l->cur_bin_num++); + else + st=MSPrintF("$$PI,\"\",%d$$",l->cur_bin_num++); + ll=LtfPutSExt(l,st); + Free(st); + ll->bin_data=tempb; + Preempt(old_preempt); + return ll; +} + +#help_index "Graphics/GrElem;Ltf/Output" +public LtfEntry *PutGrElem(U1 *elems,U8 size,U1 *txt=NULL) +{ //If you set $FG,4$txt$FG$, +//then include dollarsigns ("$FG,4$$$PI ...$$$FG$") + Ltf *l; + if (l=Fs->cur_ltf) + return LtfPutGrElem(l,elems,size,txt); + return NULL; +} + +#help_index "Graphics/GrElem" +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; + *root,*tempg,*insert_point; + BoolU4 old_inhibit=ip_inhibit_win_operations; + BoolU4 old_ip_double=Bt(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + root=GrElemsToQueue(old_GrElem); + + cur_elem=root->next; + while (cur_elem->type!=GRET_END) { + cur_num++; + cur_elem=cur_elem->next; + } + + tempb->data=MAllocIdentical(old_GrElem); + Preempt(old_preempt); + do { + i=PopUpGrElemsEditChoice; + switch (i) { + case GED_PICK_TEXT: + cur_num=PopUpPickGrElem(root,cur_num); + break; + case GED_PICK_GRAPHICALLY: + ip_inhibit_win_operations=TRUE; + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + l->cur_GrElem=tempb->data; + l->cur_sub_grelem=0; + GetMsg(&p1,&p2,1<cur_sub_grelem; + l->cur_GrElem=NULL; + AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double); + ip_inhibit_win_operations=old_inhibit; + break; + case GED_SET_ORIGIN: + ip_inhibit_win_operations=TRUE; + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + GetMsg(&p1,&p2,1<crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double); + ip_inhibit_win_operations=old_inhibit; + break; + case GED_TRANSFORM: + EditGrElemTransform(root); + 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<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: + if (GrElemTextEdit(root)) + GrEditUpdate(tempb,root); + 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); +} + +#help_index "Graphics" + \ No newline at end of file diff --git a/LT/Adam/Gr/GrMath.APZ b/LT/Adam/Gr/GrMath.APZ new file mode 100644 index 0000000..24f5e3e --- /dev/null +++ b/LT/Adam/Gr/GrMath.APZ @@ -0,0 +1,569 @@ +#help_index "Graphics/Math" + +I8 GrXOffsets[8]={-1,0,1,-1,1,-1,0,1}, + GrYOffsets[8]={-1,-1,-1,0,0,1,1,1}; + +public void Line(void *aux_data, + I8 x1,I8 y1,I8 z1, + I8 x2,I8 y2,I8 z2, + void plot_cb(void *aux,I8 x,I8 y,I8 z), + I8 step=1,I8 start=0) +{ + I8 i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1; + I8 adx=AbsI8(dx),ady=AbsI8(dy),adz=AbsI8(dz); + + if (adx>=ady) { + if (adx>=adz) { + if (d=adx) { + if (dx>=0) + dx=0x100000000; + else + dx=-0x100000000; + dy=dy<<32/d; + dz=dz<<32/d; + } + } else { + if (d=adz) { + dx=dx<<32/d; + dy=dy<<32/d; + if (dz>=0) + dz=0x100000000; + else + dz=-0x100000000; + } + } + } else { + if (ady>=adz) { + if (d=ady) { + dx=dx<<32/d; + if (dy>=0) + dy=0x100000000; + else + dy=-0x100000000; + dz=dz<<32/d; + } + } else { + if (d=adz) { + dx=dx<<32/d; + dy=dy<<32/d; + if (dz>=0) + dz=0x100000000; + else + dz=-0x100000000; + } + } + } + x1<<=32; y1<<=32; z1<<=32; + for (j=0;j=ady1) + d1=(adx1>=adz1) ? adx1:adz1; + else + d1=(ady1>=adz1) ? ady1:adz1; + d1<<=1; + if (d1) { + dx1=dx1<<32/d1; + dy1=dy1<<32/d1; + dz1=dz1<<32/d1; + } + + if (adx2>=ady2) + d2=(adx2>=adz2) ? adx2:adz2; + else + d2=(ady2>=adz2) ? ady2:adz2; + d2<<=1; + if (d2) { + dx2=dx2<<32/d2; + dy2=dy2<<32/d2; + dz2=dz2<<32/d2; + } + + x1<<=32; y1<<=32; z1<<=32; + for (j=0;j<=d1;j++) { + x2=x1; y2=y1; z2=z1; + for (i=0;i<=d2;i++) { + plot_cb(aux_data,x2.i4[1],y2.i4[1],z2.i4[1]); + x2+=dx2; y2+=dy2; z2+=dz2; + } + x1+=dx1; y1+=dy1; z1+=dz1; + } +} + +#help_index "Graphics/Math/3D Transformation" +I8 gr_scale; +gr_scale.u4[0]=0; +gr_scale.u4[1]=1; + +void *gr_screen_capture=NULL; +public void GrRotate(I8 *r,I8 *x,I8 *y,I8 *z) +{ + I8 x1,y1,z1,xx=*x,yy=*y,zz=*z; + x1=(r[0]*xx+r[1]*yy+r[2]*zz+r[3])>>32; + y1=(r[4]*xx+r[5]*yy+r[6]*zz+r[7])>>32; + z1=(r[8]*xx+r[9]*yy+r[10]*zz+r[11])>>32; + *x=x1;*y=y1;*z=z1; +} + +public void GrTransform(GrBitMap *base,I8 *x,I8 *y,I8 *z) +{ + GrRotate(base->r,x,y,z); + *x+=base->x; + *y+=base->y; + *z+=base->z; +} + + +public I8 *GrTheta(double theta,TssStruct *tss=NULL) +{ + double my_cos,my_sin; + I8 *r=MAllocZ(sizeof(I8)*16,tss); + + my_cos=Cos(theta)*gr_scale; + my_sin=Sin(theta)*gr_scale; + r[0]=my_cos; + r[5]=my_cos; + r[4]=my_sin; + r[1]=-my_sin; + r[10]=gr_scale; + return r; +} + +public I8 *GrPhi(double phi,TssStruct *tss=NULL) +{ + double my_cos,my_sin; + I8 *r=MAllocZ(sizeof(I8)*16,tss); + + my_cos=Cos(phi)*gr_scale; + my_sin=Sin(phi)*gr_scale; + r[5]=my_cos; + r[10]=my_cos; + r[9]=my_sin; + r[6]=-my_sin; + r[0]=gr_scale; + return r; +} + +public I8 *GrScaleMat(I8 *m1,double s,TssStruct *tss=NULL) +{ + I8 i,*r=MAllocZ(sizeof(I8)*16,tss); + for (i=0;i<16;i++) + r[i]=m1[i]*s; + return r; +} + +public I8 *GrMulMat(I8 *m1,I8 *m2,TssStruct *tss=NULL) +{ + I8 *r=MAllocZ(sizeof(I8)*16,tss); + I8 i,j,k; + double d; + for (i=0;i<4;i++) { + for (j=0;j<4;j++) { + for (k=0;k<4;k++) { + d=m1[k+4*j]; + d*=m2[i+4*k]; + d/=gr_scale; + r[i+4*j]+=d; + } + } + } + return r; +} + +public I8 GrDetMat(I8 *m1) +{ + I8 i; + double m[16],d; + for (i=0;i<16;i++) + m[i]=m1[i]/(1.0*0x100000000); + d=m[0]*(m[5]*m[10]-m[6]*m[9])- + m[1]*(m[4]*m[10]-m[6]*m[8])+ + m[2]*(m[4]*m[9]-m[5]*m[8]); + return d*0x100000000; +} + +public void GrScalePenWidth(GrBitMap *base) +{ + I8 d; + if (base->flags&BMF_TRANSFORMATION) { + if (base->pen_width) { + d=base->pen_width*GrDetMat(base->r)+0x80000000; + base->pen_width=d.u4[1]; + if (base->pen_width<1) + base->pen_width=1; + } + } +} + +public void GrSetIdent(I8 *r) +{ + MemSet(r,0,16<<3); + r[0].u4[1]=1; + r[5].u4[1]=1; + r[10].u4[1]=1; + r[15].u4[1]=1; +} + +public void GrSetTranslation(I8 *r,I8 x,I8 y,I8 z) +{ + r[3]=x<<32; + r[7]=y<<32; + r[11]=z<<32; +} + +#help_index "Graphics/Math" +public void Circle(void *aux_data, + I8 cx,I8 cy,I8 cz, + I8 radius, + void plot_cb(void *aux,I8 x,I8 y,I8 z), + I8 step=1, + double start_rad=0, + double len_rad=pi2) +{ + I8 i,j,len=len_rad*radius; + I8 x,y,x1,y1,s1,s2,c; + double t; + if (radius<0) return; + if (!radius) { + plot_cb(aux_data,cx,cy,cz); + return; + } + t=1.0/radius; + s1=(1<<24)*Sin(t); + s2=-s1; + c=(1<<24)*Cos(t); + if (start_rad) { + x=radius*Cos(start_rad); + y=-radius*Sin(start_rad); + } else { + x=radius; + y=0; + } + x<<=8; + y<<=8; + for (i=0;i<=len;i+=step) { + plot_cb(aux_data,cx+x>>8,cy+y>>8,cz); + for (j=0;j>24; + y1=(s2*x+c*y)>>24; + x=x1; y=y1; + } + } +} + +public void Ellipse(void *aux_data, + I8 cx,I8 cy,I8 cz, + I8 x_radius,I8 y_radius, + void plot_cb(void *aux,I8 x,I8 y,I8 z), + double rot_angle=0, + I8 step=1, + double start_rad=0, + double len_rad=pi2) +{ + I8 i,j,len; + I8 x,y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2; + double t; + if (x_radius<0 || y_radius<0 || step<1) + return; + if (!x_radius && !y_radius) { + plot_cb(aux_data,cx,cy,cz); + return; + } + if (x_radius>=y_radius) { + t=1.0/x_radius; + len=len_rad*x_radius; + } else { + t=1.0/y_radius; + len=len_rad*y_radius; + } + + s1=(1<<24)*Sin(t); + s2=-s1; + c=(1<<24)*Cos(t); + + s12=(1<<24)*Sin(rot_angle); + s22=-s12; + c2=(1<<24)*Cos(rot_angle); + + if (start_rad) { + x=x_radius*Cos(start_rad); + y=-x_radius*Sin(start_rad); + } else { + x=x_radius; + y=0; + } + x<<=8; + y<<=8; + x2=x; + y2=y; + + y1=y2*y_radius/x_radius; + x=(c2*x2+s12*y1)>>24; + y=(s22*x2+c2*y1)>>24; + + for (i=0;i<=len;i+=step) { + plot_cb(aux_data,cx+x>>8,cy+y>>8,cz); + for (j=0;j>24; + y1=(s2*x2+c*y2)>>24; + x2=x1; + y2=y1; + y1=y1*y_radius/x_radius; + x=(c2*x1+s12*y1)>>24; + y=(s22*x1+c2*y1)>>24; + } + } +} + +public I8 DistP3I4(P3I4 *p1,P3I4 *p2) +{ + return Sqrt(SqrI8(p1->x-p2->x)+SqrI8(p1->y-p2->y)+SqrI8(p1->z-p2->z)); +} + +public void Bezier2(void *aux_data,P3I4 *ctrl,void plot_cb(void *aux,I8 x,I8 y,I8 z)) +{//2nd order + I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max; + double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z; + double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0; + double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0; + double t,d=DistP3I4(&ctrl[0],&ctrl[1])+ + DistP3I4(&ctrl[1],&ctrl[2])+ + DistP3I4(&ctrl[2],&ctrl[0]), + s=0.5/d,t1,t2; + xx=x0; yy=y0; zz=z0; + for (t=0.0;t<=1.0;t+=s) { + t1=t*(1.0-t); + t2=t*t; + x=x0+x1*t1+x2*t2; + y=y0+y1*t1+y2*t2; + z=z0+z1*t1+z2*t2; + dx=AbsI8(x-xx); + dy=AbsI8(y-yy); + dz=AbsI8(z-zz); + if (dx>dy) + d_max=dx; + else + d_max=dy; + if (dz>d_max) + d_max=dz; + if (!d_max) + s*=1.1; + else { + s*=0.9; + plot_cb(aux_data,x,y,z); + xx=x;yy=y;zz=z; + } + } +} + +public void Bezier3(void *aux_data,P3I4 *ctrl,void plot_cb(void *aux,I8 x,I8 y,I8 z)) +{ //3rd order + I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max; + double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z; + double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0; + double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0; + double x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0; + double t,d=DistP3I4(&ctrl[0],&ctrl[1])+ + DistP3I4(&ctrl[1],&ctrl[2])+ + DistP3I4(&ctrl[2],&ctrl[3])+ + DistP3I4(&ctrl[3],&ctrl[0]), + s=0.5/d,nt,t1,t2,t3; + xx=x0; yy=y0; zz=z0; + for (t=0.0;t<=1.0;t+=s) { + nt=1.0-t; + t1=t*nt*nt; + t2=t*t*nt; + t3=t*t*t; + x=x0+x1*t1+x2*t2+x3*t3; + y=y0+y1*t1+y2*t2+y3*t3; + z=z0+z1*t1+z2*t2+z3*t3; + dx=AbsI8(x-xx); + dy=AbsI8(y-yy); + dz=AbsI8(z-zz); + if (dx>dy) + d_max=dx; + else + d_max=dy; + if (dz>d_max) + d_max=dz; + if (!d_max) + s*=1.1; + else { + s*=0.9; + plot_cb(aux_data,x,y,z); + xx=x;yy=y;zz=z; + } + } +} + +public void BSpline2(void *aux_data,P3I4 *ctrl,I8 cnt,void plot_cb(void *aux,I8 x,I8 y,I8 z),BoolU4 closed=FALSE) +{ //2nd order + I8 i,j; + P3I4 *c; + if (cnt<3) return; + if (closed) { + cnt++; + c=MAlloc(sizeof(P3I4)*(cnt*2-1)); + j=1; + for (i=0;ibrush) { + GrBlot(base,x,y,base->brush); + return; + } + if (base->flags & BMF_SCREEN_BITMAP) { + if (x<0) draw=FALSE; + x+=base->win_tss->win_pixel_left; + if (x>base->win_tss->win_pixel_right) draw=FALSE; + + if (y<0) draw=FALSE; + y+=base->win_tss->win_pixel_top; + if (y>base->win_tss->win_pixel_bottom) draw=FALSE; + if (x>=base->width) draw=FALSE; + if (y>=base->height) draw=FALSE; + if (IsPixelCovered(base->win_tss,x,y)) draw=FALSE; + } else { + if (x<0) draw=FALSE; + if (x>=base->width) draw=FALSE; + if (y<0) draw=FALSE; + if (y>=base->height) draw=FALSE; + } + if (draw) + GrPlot0(base,x,y); +} + +public I8 GrPeek(GrBitMap *base,I8 x,I8 y) +{ //Clipping but No transformation + BoolU4 peek=TRUE; + if (base->flags & BMF_SCREEN_BITMAP) { + if (x<0) peek=FALSE; + x+=base->win_tss->win_pixel_left; + if (x>base->win_tss->win_pixel_right) peek=FALSE; + + if (y<0) peek=FALSE; + y+=base->win_tss->win_pixel_top; + if (y>base->win_tss->win_pixel_bottom) peek=FALSE; + if (x>=base->width) peek=FALSE; + if (y>=base->height) peek=FALSE; + if (IsPixelCovered(base->win_tss,x,y)) peek=FALSE; + } else { + if (x<0) peek=FALSE; + if (x>=base->width) peek=FALSE; + if (y<0) peek=FALSE; + if (y>=base->height) peek=FALSE; + } + if (peek) + return GrPeek0(base,x,y); + else + return -1; +} + +#define CC_LEFT 1 +#define CC_RIGHT 2 +#define CC_TOP 4 +#define CC_BOTTOM 8 + +U8 ClipCode(I8 x,I8 y,I8 right,I8 bottom) +{ + U8 result; + if (y>bottom) + result=CC_BOTTOM; + else if (y<0) + result=CC_TOP; + else + result=0; + if (x>right) + result|=CC_RIGHT; + else if (x<0) + result|=CC_LEFT; + return result; +} + +public BoolU8 ClipLine(GrBitMap *base,I8 *x1,I8 *y1,I8 *x2,I8 *y2) +{ + I8 x,y,right,bottom; + U8 cc,cc1,cc2; + if (base->flags & BMF_SCREEN_BITMAP) { + right=base->win_tss->win_pixel_right-base->win_tss->win_pixel_left-1; + if (base->width-1width-1; + bottom=base->win_tss->win_pixel_bottom-base->win_tss->win_pixel_top-1; + if (base->height-1height-1; + } else { + right=base->width-1; + bottom=base->height-1; + } + cc1=ClipCode(*x1,*y1,right,bottom); + cc2=ClipCode(*x2,*y2,right,bottom); + do { + if (!(cc1|cc2)) + return TRUE; + if (cc1&cc2) + return FALSE; + + if (cc1) + cc=cc1; + else + cc=cc2; + + if (cc&CC_BOTTOM) { + x=*x1+(*x2-*x1)*(bottom-*y1)/(*y2-*y1); + y=bottom; + } else if (cc&CC_TOP) { + x=*x1+(*x2-*x1)*(-*y1)/(*y2-*y1); + y=0; + } else if (cc&CC_RIGHT) { + y=*y1+(*y2-*y1)*(right-*x1)/(*x2-*x1); + x=right; + } else { + y=*y1+(*y2-*y1)*(-*x1)/(*x2-*x1); + x=0; + } + + if (cc==cc1) { + *x1=x; + *y1=y; + cc1=ClipCode(*x1,*y1,right,bottom); + } else { + *x2=x; + *y2=y; + cc2=ClipCode(*x2,*y2,right,bottom); + } + } while (TRUE); +} + +I8 GrFloodFillRay(GrBitMap *base,I8 x,I8 y) +{ + I8 cnt,j,x1,ray_len,ray_len2; + + cnt=ray_len=GrRayLen(base,&x,y); + + y--; + j=ray_len; + x1=x; + while (j>0) { + if (ray_len2=GrRayLenMinus(base,x1,y)) + cnt+=GrFloodFillRay(base,x1,y); + j-=ray_len2+1; + x1-=ray_len2+1; + } + + y+=2; + j=ray_len; + x1=x; + while (j>0) { + if (ray_len2=GrRayLenMinus(base,x1,y)) + cnt+=GrFloodFillRay(base,x1,y); + j-=ray_len2+1; + x1-=ray_len2+1; + } + return cnt; +} + + +public I8 GrFloodFill(GrBitMap *base,I8 x,I8 y,BoolU4 not_color=TRUE) +{ + I8 cnt=0,j,c,old_color2=base->color2,old_flags=base->flags; + GrBitMap *old_brush; + if (base->flags & BMF_DONT_DRAW) //TODO + return 0; + old_brush=base->brush; + base->brush=NULL; + j=GrPeek(base,x,y); + if (j>=0) { + switch (base->type) { + case BMT_COLOR4: + if (not_color) { + base->color2=base->color&0xFFFFFF; + base->flags|=BMF_FILL_NOT_COLOR; + } else { + base->color2=j; + if (base->color2==base->color&0xFFFFFF) + break; + base->flags&=~BMF_FILL_NOT_COLOR; + } + if (not_color && j!=base->color2 || + !not_color) + cnt=GrFloodFillRay(base,x,y); + break; + case BMT_MONO: + c=(base->color&0xFFFFFF)?1:0; + if (not_color) { + base->color2=c; + base->flags|=BMF_FILL_NOT_COLOR; + } else { + base->color2=(j)?1:0; + if (base->color2==c) + break; + base->flags&=~BMF_FILL_NOT_COLOR; + } + if (not_color && j!=c || + !not_color) + cnt=GrFloodFillRay(base,x,y); + break; + } + } + base->brush=old_brush; + base->flags=old_flags; + base->color2=old_color2; + return cnt; +} + +public void GrPlot2(GrBitMap *base,I8 x,I8 y,I8 z) +{ //Clipping and transformation but no pen_width + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x,&y,&z); + x+=base->x; + y+=base->y; + z+=base->z; + } + GrPlot(base,x,y); +} + +public void GrPlot3(GrBitMap *base,I8 x,I8 y,I8 z) +{ //clipping and transformation and pen width + + I8 i,j,w,old_color,dist; + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x,&y,&z); + x+=base->x; + y+=base->y; + z+=base->z; + } + w=base->pen_width>>1; + if (w<=0) + GrPlot(base,x,y); + else if (base->pen_widthcolor; + if (base->color.u1[3]==ROPB_EQU) + base->color.u1[3]=ROPB_TRANSPARENT; + if (GrBlot(base,x-w,y-w,gr_pen_brushes[base->pen_width])) { + if (base->flags & BMF_SCREEN_BITMAP) { + x+=base->win_tss->win_pixel_left; + y+=base->win_tss->win_pixel_top; + } + if (base->flags & BMF_LOCATE_NEAREST) { + dist=DistI8(x,y,base->cur_x,base->cur_y); + if (distnearest_dist) { + base->nearest_sub_grelem=base->cur_sub_grelem; + base->nearest_dist=dist; + } + } + } + base->color=old_color; + } else if (base->pen_width & 1) { + for (i=-w;i<=w;i++) + for (j=-w;j<=w;j++) + GrPlot(base,x+i,y+j); + } else { + for (i=-w;ibrush + BoolU4 draw=TRUE; + + if (x<0) draw=FALSE; + x+=base->win_tss->win_pixel_left; + if (x>base->win_tss->win_pixel_right) draw=FALSE; + + if (y<0) draw=FALSE; + y+=base->win_tss->win_pixel_top; + if (y>base->win_tss->win_pixel_bottom) draw=FALSE; + + if (x>=base->width) draw=FALSE; + if (y>=base->height) draw=FALSE; + + if (draw) { + if (base->brush) + GrBlot(base,x,y,base->brush); + else + GrPlot0(base,x,y); + } +} + +void GrLinePlot(GrBitMap *base,I8 x,I8 y,I8 z) +{ + nounusedwarn z; + GrPlot(base,x,y); +} + +public void GrLine(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0) +{ + if (ClipLine(base,&x1,&y1,&x2,&y2)) + Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start); +} + +public void GrCircle(GrBitMap *base,I8 cx,I8 cy,I8 radius, + I8 step=1,double start_rad=0,double len_rad=pi2) +{ + Circle(base,cx,cy,0,radius,&GrLinePlot,step,start_rad,len_rad); +} + +public void GrEllipse(GrBitMap *base, + I8 cx,I8 cy, + I8 x_radius,I8 y_radius, + double rot_angle=0, + I8 step=1, + double start_rad=0, + double len_rad=pi2) +{ + Ellipse(base,cx,cy,0,x_radius,y_radius,&GrLinePlot,rot_angle,step,start_rad,len_rad); +} + +public void Gr2Bezier(GrBitMap *base,P3I4 *ctrl) +{ + Bezier2(base,ctrl,&GrLinePlot); +} + +public void Gr3Bezier(GrBitMap *base,P3I4 *ctrl) +{ + Bezier3(base,ctrl,&GrLinePlot); +} + +public void Gr2BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) +{ + BSpline2(base,ctrl,cnt,&GrLinePlot,closed); +} + +public void Gr3BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) +{ + BSpline3(base,ctrl,cnt,&GrLinePlot,closed); +} + +public void GrLine2(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0) +{ //transformation but not pen width + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + GrRotate(base->r,&x2,&y2,&z2); + x2+=base->x; + y2+=base->y; + z2+=base->z; + } + if (ClipLine(base,&x1,&y1,&x2,&y2)) + Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start); +} + +void GrLine3Plot(GrBitMap *base,I8 x,I8 y,I8 z) +{ + GrPlot3(base,x,y,z); +} + +public void GrLine3(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0) +{ //transformation with pen width + U8 old_flags=base->flags; + + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + GrRotate(base->r,&x2,&y2,&z2); + x2+=base->x; + y2+=base->y; + z2+=base->z; + } + if (ClipLine(base,&x1,&y1,&x2,&y2)) { + base->flags&=~BMF_TRANSFORMATION; + Line(base,x1,y1,0,x2,y2,0,&GrLine3Plot,step,start); + base->flags=old_flags; + } +} + +public void GrText3(GrBitMap *base,I8 x1,I8 y1,I8 z1,I1 *s) +{ //transformation + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + } + GrText(base,x1,y1,s); +} + +public void GrCircle3(GrBitMap *base,I8 cx,I8 cy,I8 cz,I8 radius, + I8 step=1,double start_rad=0,double len_rad=pi2) +{ //transformation with pen width + I8 x,y,z; + double m1,a1,m2; + if (base->flags & BMF_TRANSFORMATION) { + base->flags&=~BMF_TRANSFORMATION; + GrRotate(base->r,&cx,&cy,&cz); + cx+=base->x; + cy+=base->y; + cz+=base->z; + + radius<<=24; + + x=radius; y=0; z=0; + GrRotate(base->r,&x,&y,&z); + R2P(&m1,&a1,x,y); + + x=0; y=radius; z=0; + GrRotate(base->r,&x,&y,&z); + m2=Sqrt(x*x+y*y); + + Ellipse(base,cx,cy,cz, + m1/0x1000000,m2/0x1000000, + &GrLine3Plot,-a1,step,start_rad,len_rad); + base->flags|=BMF_TRANSFORMATION; + } else + Circle(base,cx,cy,cz,radius,&GrLine3Plot,step,start_rad,len_rad); +} + + +public void GrEllipse3(GrBitMap *base, + I8 cx,I8 cy,I8 cz, + I8 x_radius,I8 y_radius, + double rot_angle=0, + I8 step=1, + double start_rad=0, + double len_rad=pi2) +{ + I8 x,y,z; + double m1,a1,m2,a2,s,c; + if (base->flags & BMF_TRANSFORMATION) { + base->flags&=~BMF_TRANSFORMATION; + GrRotate(base->r,&cx,&cy,&cz); + cx+=base->x; + cy+=base->y; + cz+=base->z; + + c=Cos(rot_angle); + s=Sin(rot_angle); + + x_radius<<=24; + y_radius<<=24; + + x=x_radius*c; + y=x_radius*s; + z=0; + GrRotate(base->r,&x,&y,&z); + R2P(&m1,&a1,x,y); + + x=-y_radius*s; + y=y_radius*c; + z=0; + GrRotate(base->r,&x,&y,&z); + R2P(&m2,&a2,x,y); + m2=m2*Abs(Sin(a2-a1)); + + Ellipse(base,cx,cy,cz, + m1/0x1000000,m2/0x1000000,&GrLine3Plot,-a1,step,start_rad,len_rad); + base->flags|=BMF_TRANSFORMATION; + } else + Ellipse(base,cx,cy,cz,x_radius,y_radius,&GrLine3Plot,rot_angle,step,start_rad,len_rad); +} + + +public I8 GrFloodFill3(GrBitMap *base,I8 x1,I8 y1,I8 z1,BoolU4 not_color=TRUE) +{ //transformation + I8 cnt,old_flags=base->flags; + + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + } + base->flags&=~BMF_TRANSFORMATION; + cnt=GrFloodFill(base,x1,y1,not_color); + base->flags=old_flags; + return cnt; +} + +public void GrBox3(GrBitMap *base,I8 x,I8 y,I8 z,I8 w,I8 h) +{ //Clipping and transformation + I8 x2,y2,z2,x3,y3,z3; + GrBitMap *old_brush=base->brush; + + if (base->flags & BMF_TRANSFORMATION) { + base->brush=NULL; + x2=x+w; y2=y; z2=z; + x3=x; y3=y+h; z3=z; + GrRotate(base->r,&x,&y,&z); + x+=base->x; + y+=base->y; + z+=base->z; + GrRotate(base->r,&x2,&y2,&z2); + x2+=base->x; + y2+=base->y; + z2+=base->z; + GrRotate(base->r,&x3,&y3,&z3); + x3+=base->x; + y3+=base->y; + z3+=base->z; + Box(base,x,y,z,x2,y2,z2,x3,y3,z3,&GrLinePlot); + base->brush=old_brush; + } else + GrBox(base,x,y,w,h); +} + +public BoolU8 GrBlot3(GrBitMap *base,I8 x1,I8 y1,I8 z1,GrBitMap *img) +{ //Clipping and transformation + I8 reg i,j,w=img->width,h=img->height,old_color=base->color,reg color, + d1,dx1,dy1,dz1, + reg d2,dx2,dy2,dz2, + adx1,ady1,adz1, + adx2,ady2,adz2, + x2,y2,z2,x3,y3,z3, + dw,reg dh,x,y; + GrBitMap *old_brush=base->brush; + + if (base->flags & BMF_TRANSFORMATION) { + x2=x1+w; y2=y1; z2=z1; + x3=x1; y3=y1+h; z3=z1; + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + GrRotate(base->r,&x2,&y2,&z2); + x2+=base->x; + y2+=base->y; + z2+=base->z; + GrRotate(base->r,&x3,&y3,&z3); + x3+=base->x; + y3+=base->y; + z3+=base->z; + + dx1=x2-x1; dy1=y2-y1; dz1=z2-z1; + dx2=x3-x1; dy2=y3-y1; dz2=z3-z1; + adx1=AbsI8(dx1); ady1=AbsI8(dy1); adz1=AbsI8(dz1); + adx2=AbsI8(dx2); ady2=AbsI8(dy2); adz2=AbsI8(dz2); + + if (adx1>=ady1) + d1=(adx1>=adz1) ? adx1:adz1; + else + d1=(ady1>=adz1) ? ady1:adz1; + d1<<=1; + if (d1) { + dx1=dx1<<32/d1; + dy1=dy1<<32/d1; + dz1=dz1<<32/d1; + } else + return FALSE; + + if (adx2>=ady2) + d2=(adx2>=adz2) ? adx2:adz2; + else + d2=(ady2>=adz2) ? ady2:adz2; + d2<<=1; + if (d2) { + dx2=dx2<<32/d2; + dy2=dy2<<32/d2; + dz2=dz2<<32/d2; + } else + return FALSE; + + base->brush=NULL; + + x=0;y=0; + dw=w<<32/d1; + dh=h<<32/d2; + + x1<<=32; y1<<=32; z1<<=32; + for (j=0;j<=d1;j++) { + x2=x1; y2=y1; z2=z1; + y=0; + for (i=0;i<=d2;i++) { + color=GrPeek(img,x.i4[1],y.i4[1]); + if (color>=0 && + (old_color.u1[3]!=ROPB_TRANSPARENT || + color&0xFFFFFF!=img->bkcolor&0xFFFFFF)) { + base->color=old_color&0xFF000000+color; + GrPlot(base,x2.i4[1],y2.i4[1]); + } + x2+=dx2; y2+=dy2; z2+=dz2; + y+=dh; + } + x1+=dx1; y1+=dy1; z1+=dz1; + x+=dw; + } + base->color=old_color; + base->brush=old_brush; + return TRUE; //TODO: check off screen + } else + return GrBlot(base,x1,y1,img); +} + +public void Gr2Bezier3(GrBitMap *base,P3I4 *ctrl) +{ + I8 i,x,y,z; + P3I4 *ctrl2; + if (base->flags & BMF_TRANSFORMATION) { + ctrl2=MAlloc(sizeof(P3I4)*3); + for (i=0;i<3;i++) { + x=ctrl[i].x; + y=ctrl[i].y; + z=ctrl[i].z; + GrRotate(base->r,&x,&y,&z); + ctrl2[i].x=x+base->x; + ctrl2[i].y=y+base->y; + ctrl2[i].z=z+base->z; + } + base->flags&=~BMF_TRANSFORMATION; + Bezier2(base,ctrl2,&GrLine3Plot); + base->flags|=BMF_TRANSFORMATION; + Free(ctrl2); + } else + Bezier2(base,ctrl,&GrLine3Plot); +} + +public void Gr3Bezier3(GrBitMap *base,P3I4 *ctrl) +{ + I8 i,x,y,z; + P3I4 *ctrl2; + if (base->flags & BMF_TRANSFORMATION) { + ctrl2=MAlloc(sizeof(P3I4)*4); + for (i=0;i<4;i++) { + x=ctrl[i].x; + y=ctrl[i].y; + z=ctrl[i].z; + GrRotate(base->r,&x,&y,&z); + ctrl2[i].x=x+base->x; + ctrl2[i].y=y+base->y; + ctrl2[i].z=z+base->z; + } + base->flags&=~BMF_TRANSFORMATION; + Bezier3(base,ctrl2,&GrLine3Plot); + base->flags|=BMF_TRANSFORMATION; + Free(ctrl2); + } else + Bezier3(base,ctrl,&GrLine3Plot); +} + +public void Gr2BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) +{ + I8 i,x,y,z; + P3I4 *ctrl2; + if (base->flags & BMF_TRANSFORMATION) { + ctrl2=MAlloc(sizeof(P3I4)*cnt); + for (i=0;ir,&x,&y,&z); + ctrl2[i].x=x+base->x; + ctrl2[i].y=y+base->y; + ctrl2[i].z=z+base->z; + } + base->flags&=~BMF_TRANSFORMATION; + BSpline2(base,ctrl2,cnt,&GrLine3Plot,closed); + base->flags|=BMF_TRANSFORMATION; + Free(ctrl2); + } else + BSpline2(base,ctrl,cnt,&GrLine3Plot,closed); +} + +public void Gr3BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE) +{ + I8 i,x,y,z; + P3I4 *ctrl2; + if (base->flags & BMF_TRANSFORMATION) { + ctrl2=MAlloc(sizeof(P3I4)*cnt); + for (i=0;ir,&x,&y,&z); + ctrl2[i].x=x+base->x; + ctrl2[i].y=y+base->y; + ctrl2[i].z=z+base->z; + } + base->flags&=~BMF_TRANSFORMATION; + BSpline3(base,ctrl2,cnt,&GrLine3Plot,closed); + base->flags|=BMF_TRANSFORMATION; + Free(ctrl2); + } else + BSpline3(base,ctrl,cnt,&GrLine3Plot,closed); +} + + +void GrLinePlot4(GrBitMap *base,I8 x,I8 y,I8 z) +{ + nounusedwarn z; + GrPlot4(base,x,y); +} + +public void GrLine4(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0) +{ //Line with base->brush + if (ClipLine(base,&x1,&y1,&x2,&y2)) + Line(base,x1,y1,0,x2,y2,0,&GrLinePlot4,step,start); +} + +public void GrSpeedLine(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,double speed) +{ + U8 old_flags=base->flags; + I8 old_pen_width=base->pen_width; + if (ClipLine(base,&x1,&y1,&x2,&y2)) { + base->pen_width=base->speedline_scale*speed; + base->flags&=~BMF_TRANSFORMATION; + GrLine3(base,x1,y1,0,x2,y2,0); + base->flags=old_flags; + base->pen_width=old_pen_width; + } +} + +public void GrSpeedLine2(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,double speed) +{ //transformation but not pen width + U8 old_flags=base->flags; + + if (base->flags & BMF_TRANSFORMATION) { + GrRotate(base->r,&x1,&y1,&z1); + x1+=base->x; + y1+=base->y; + z1+=base->z; + GrRotate(base->r,&x2,&y2,&z2); + x2+=base->x; + y2+=base->y; + z2+=base->z; + } + base->flags&=~BMF_TRANSFORMATION; + GrSpeedLine(base,x1,y1,x2,y2,speed); + base->flags=old_flags; +} + diff --git a/LT/Adam/Gr/GrScreen.APZ b/LT/Adam/Gr/GrScreen.APZ new file mode 100644 index 0000000..1aa5990 Binary files /dev/null and b/LT/Adam/Gr/GrScreen.APZ differ diff --git a/LT/Adam/GrAsm/Gr1.ASZ b/LT/Adam/GrAsm/Gr1.ASZ new file mode 100644 index 0000000..97d37fe --- /dev/null +++ b/LT/Adam/GrAsm/Gr1.ASZ @@ -0,0 +1,593 @@ + IMPORT sys_update_screen_tss; + + ALIGN 8,OC_NOP +NORMAL_KEY_SCAN_DECODE_TABLE:: + DU1 0,CH_ESC,"1234567890-=",8,9; + DU1 "qwertyuiop[]",CH_CR,0,"as"; + DU1 "dfghjkl;'\`",0,"\\zxcv"; + DU1 "bnm,./",0,'*',0,CH_SPACE,0,0,0,0,0,0; + DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0; +SHIFT_KEY_SCAN_DECODE_TABLE:: + DU1 0,CH_ESC,"!@#$$%^&*()_+",8,9; + DU1 "QWERTYUIOP{}",CH_CR,0,"AS"; + DU1 "DFGHJKL:\"~",0,"|ZXCV"; + DU1 "BNM<>?",0,'*',0,CH_SHIFT_SPACE,0,0,0,0,0,0; + DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0; +CTRL_KEY_SCAN_DECODE_TABLE:: + DU1 0,CH_ESC,"1234567890-=",8,9; + DU1 17,23,5,18,20,25,21,9,15,16,"[]",CH_CR,0,1,19; + DU1 4,6,7,8,CH_LINE_FEED,11,12,";'\`",0,"\\",26,24,3,22; + DU1 2,14,13,",./",0,'*',0,CH_SPACE,0,0,0,0,0,0; + DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0; + + ALIGN 8,OC_NOP +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +CP_PLOT_SCREEN_I1:: + PUSH RBP + MOV RBP,RSP + MOV RBX,U8 SF_PARAM2[RBP] + MOV RAX,U8 SF_PARAM3[RBP] + OR RBX,RBX + JS @@100 + OR RAX,RAX + JS @@100 + CMP RBX,TEXT_COLS + JGE @@100 + CMP RAX,TEXT_ROWS + JGE @@100 + IMUL2 RAX,TEXT_COLS + ADD RBX,RAX + SHL RBX,2 + ADD RBX,U8 [SYS_TEXTBASE] + MOV RAX,U8 SF_PARAM1[RBP] + MOV U4 [RBX],EAX + + POP RBP + MOV RAX,1 + RET +@@100: POP RBP + XOR EAX,EAX + RET +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +CP_PLOT_WIN_I1:: + PUSH RBP + MOV RBP,RSP + MOV RBX,U8 SF_PARAM3[RBP] + MOV RAX,U8 SF_PARAM4[RBP] + MOV RCX,U8 SF_PARAM1[RBP] + + OR RBX,RBX + JS @@100 + ADD RBX,U8 TSS_WIN_LEFT[RCX] + CMP RBX,U8 TSS_WIN_RIGHT[RCX] + JG @@100 + OR RBX,RBX + JS @@100 + CMP RBX,TEXT_COLS + JGE @@100 + + OR RAX,RAX + JS @@100 + ADD RAX,U8 TSS_WIN_TOP[RCX] + CMP RAX,U8 TSS_WIN_BOTTOM[RCX] + JG @@100 + OR RAX,RAX + JS @@100 + CMP RAX,TEXT_ROWS + JGE @@100 + + IMUL2 RAX,TEXT_COLS + ADD RBX,RAX + SHL RBX,2 + ADD RBX,U8 [SYS_TEXTBASE] + MOV RAX,U8 SF_PARAM2[RBP] + MOV U4 [RBX],EAX + + POP RBP + MOV RAX,1 + RET +@@100: POP RBP + XOR EAX,EAX + RET + +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +/* +BoolU4 PlotWinStr2(TssStruct *tss,I1 *s,I8 len, + U8 attr,I8 x,I8 y) +*/ + ALIGN 8,OC_NOP +CP_PLOT_WIN_STR2:: + PUSH RBP + MOV RBP,RSP + MOV R10,U8 [SYS_TEXTBASE] + PUSH RSI + PUSH RDI + MOV RBX,U8 SF_PARAM1[RBP] + MOV RSI,U8 SF_PARAM2[RBP] + MOV RDI,U8 SF_PARAM5[RBP] + MOV RCX,U8 SF_PARAM3[RBP] + + OR RDI,RDI + JNS @@10 + ADD RCX,RDI + SUB RSI,RDI + XOR EDI,EDI +@@10: ADD RDI,U8 TSS_WIN_LEFT[RBX] + MOV RDX,RCX + ADD RDX,RDI + DEC RDX + CMP RDX,U8 TSS_WIN_RIGHT[RBX] + JLE @@11 + MOV RAX,RDX + SUB RAX,U8 TSS_WIN_RIGHT[RBX] + SUB RDX,RAX + SUB RCX,RAX +@@11: OR RDI,RDI + JNS @@12 + ADD RCX,RDI + SUB RSI,RDI + XOR EDI,EDI +@@12: INC RDX + SUB RDX,TEXT_COLS + JLE @@13 + SUB RCX,RDX +@@13: CMP RCX,1 + JL @@100 + + MOV RAX,U8 SF_PARAM6[RBP] + OR RAX,RAX + JS @@100 + ADD RAX,U8 TSS_WIN_TOP[RBX] + CMP RAX,U8 TSS_WIN_BOTTOM[RBX] + JG @@100 + OR RAX,RAX + JS @@100 + CMP RAX,TEXT_ROWS + JGE @@100 + + IMUL2 RAX,TEXT_COLS + ADD RDI,RAX + SHL RDI,2 + ADD RDI,R10 + MOV RAX,U8 SF_PARAM4[RBP] +@@20: LODSB + STOSD + LOOP @@20 + + POP RDI + POP RSI + POP RBP + MOV RAX,TRUE + RET + +@@100: POP RDI + POP RSI + POP RBP + XOR EAX,EAX + RET +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +/* +BoolU4 PlotAttr(TssStruct *tss,I8 len, + U8 attr,I8 x,I8 y) +*/ + ALIGN 8,OC_NOP +CP_PLOT_ATTR:: + PUSH RBP + MOV RBP,RSP + MOV R10,U8 [SYS_TEXTBASE] + PUSH RSI + PUSH RDI + MOV RBX,U8 SF_PARAM1[RBP] + MOV RDI,U8 SF_PARAM4[RBP] + MOV RCX,U8 SF_PARAM2[RBP] + + OR RDI,RDI + JNS @@10 + ADD RCX,RDI + XOR EDI,EDI +@@10: ADD RDI,U8 TSS_WIN_LEFT[RBX] + MOV RDX,RCX + ADD RDX,RDI + DEC RDX + CMP RDX,U8 TSS_WIN_RIGHT[RBX] + JLE @@11 + MOV RAX,RDX + SUB RAX,U8 TSS_WIN_RIGHT[RBX] + SUB RDX,RAX + SUB RCX,RAX +@@11: OR RDI,RDI + JNS @@12 + ADD RCX,RDI + XOR EDI,EDI +@@12: INC RDX + SUB RDX,TEXT_COLS + JLE @@13 + SUB RCX,RDX +@@13: CMP RCX,1 + JL @@100 + + MOV RAX,U8 SF_PARAM5[RBP] + OR RAX,RAX + JS @@100 + ADD RAX,U8 TSS_WIN_TOP[RBX] + CMP RAX,U8 TSS_WIN_BOTTOM[RBX] + JG @@100 + OR RAX,RAX + JS @@100 + CMP RAX,TEXT_ROWS + JGE @@100 + + IMUL2 RAX,TEXT_COLS + ADD RDI,RAX + SHL RDI,2 + ADD RDI,R10 + MOV RBX,U8 SF_PARAM3[RBP] + MOV RSI,RDI +@@20: LODSD + OR AL,AL + JNZ @@21 + MOV RAX,RBX + STOSD + LOOP @@20 + +@@21: POP RDI + POP RSI + POP RBP + MOV RAX,TRUE + RET + +@@100: POP RDI + POP RSI + POP RBP + XOR EAX,EAX + RET +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +CP_PLOT_BORDER_I1:: + PUSH RBP + MOV RBP,RSP + MOV R10,U8 [SYS_TEXTBASE] + MOV RBX,U8 SF_PARAM3[RBP] + MOV RAX,U8 SF_PARAM4[RBP] + MOV RCX,U8 SF_PARAM1[RBP] + + MOV RDX,-1 + CMP RBX,RDX + JL @@100 + ADD RBX,U8 TSS_WIN_LEFT[RCX] + MOV RDX,U8 TSS_WIN_RIGHT[RCX] + INC RDX + CMP RBX,RDX + JG @@100 + OR RBX,RBX + JS @@100 + CMP RBX,TEXT_COLS + JGE @@100 + + MOV RDX,-1 + CMP RAX,RDX + JL @@100 + ADD RAX,U8 TSS_WIN_TOP[RCX] + MOV RDX,U8 TSS_WIN_BOTTOM[RCX] + INC RDX + CMP RAX,RDX + JG @@100 + OR RAX,RAX + JS @@100 + CMP RAX,TEXT_ROWS + JGE @@100 + + IMUL2 RAX,TEXT_COLS + ADD RBX,RAX + SHL RBX,2 + ADD RBX,R10 + MOV RAX,U8 SF_PARAM2[RBP] + MOV U4 [RBX],EAX + + POP RBP + MOV RAX,TRUE + RET +@@100: POP RBP + XOR EAX,EAX + RET +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +/* + GrXorLineU8(&dst3,&src,&src2,d5b,vga_image,reverse_table); + for (col=0;colnext_tss; + while (tss!=sys_update_screen_tss) { + if (Bt(&tss->crt_flags,CRTf_SHOW)) { //no short circuit logic + if (x>=tss->win_border_pixel_left) { + if (x<=tss->win_border_pixel_right) { + if (y>=tss->win_border_pixel_top) { + if (y<=tss->win_border_pixel_bottom) { + return TRUE; + }}}}} + tss=tss->next_tss; + } + return FALSE; +} +*********/ +CP_IS_PIXEL_COVERED:: + PUSH RBP + MOV RBP,RSP + MOV RAX,U8 SF_PARAM1[RBP] + MOV RBX,U8 SF_PARAM2[RBP] + MOV RCX,U8 SF_PARAM3[RBP] + MOV RDX,U8 [sys_update_screen_tss] + BT U4 TSS_CRT_FLAGS[RAX],CRTf_ON_TOP + JC @@100 + PUSHFD + CLI + MOV RAX,U8 TSS_NEXT_TSS[RAX] + JMP @@30 + +@@1: BT U4 TSS_CRT_FLAGS[RAX],CRTf_SHOW + JNC @@20 + CMP RBX,U8 TSS_WIN_BORDER_PIXEL_LEFT[RAX] + JL @@20 + CMP RCX,U8 TSS_WIN_BORDER_PIXEL_TOP[RAX] + JL @@20 + CMP RBX,U8 TSS_WIN_BORDER_PIXEL_RIGHT[RAX] + JG @@20 + CMP RCX,U8 TSS_WIN_BORDER_PIXEL_BOTTOM[RAX] + JG @@20 + POPFD + MOV RAX,TRUE + POP RBP + RET + +@@20: MOV RAX,U8 TSS_NEXT_TSS[RAX] +@@30: CMP RAX,RDX + JNE @@1 + POPFD + +@@100: XOR EAX,EAX + POP RBP + RET diff --git a/LT/Adam/GrAsm/GrAsm.BIZ b/LT/Adam/GrAsm/GrAsm.BIZ new file mode 100644 index 0000000..8ea6891 Binary files /dev/null and b/LT/Adam/GrAsm/GrAsm.BIZ differ diff --git a/LT/Adam/GrAsm/GrAsm.HPZ b/LT/Adam/GrAsm/GrAsm.HPZ new file mode 100644 index 0000000..d690968 --- /dev/null +++ b/LT/Adam/GrAsm/GrAsm.HPZ @@ -0,0 +1,19 @@ +#help_index "Graphics" +public LTextern CP_IS_PIXEL_COVERED BoolU4 IsPixelCovered(TssStruct *tss,I8 x,I8 y); + +LTextern GR_XOR_LINE_U8 void GrXorLineU8(U8 **dst3,U8 **src,U8 **src2,U8 d5b, + void **vga,U1 *reverse_bit_tab); +LTextern GR_XOR_BITMAP_U8 void GrXorBitMapU8(U8 *b1,U8 *b2,U8 cnt); +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); +//The callback is void Plot(aux_data,x,y,z) + +#help_index "Graphics/Char" +public LTextern CP_PLOT_SCREEN_I1 BoolU4 PlotScreenChar(U8 w,I8 x,I8 y); +public LTextern CP_PLOT_WIN_I1 BoolU4 PlotWinChar(TssStruct *tss,U8 w,I8 x,I8 y); +public LTextern CP_PLOT_WIN_STR2 BoolU4 PlotWinStr2( + TssStruct *tss,I1 *s,I8 len,U8 attr,I8 x,I8 y); +public LTextern CP_PLOT_ATTR BoolU4 PlotWinAttr( + TssStruct *tss,I8 len,U8 attr,I8 x,I8 y); +public LTextern CP_PLOT_BORDER_I1 BoolU4 PlotBorderChar(TssStruct *tss,U8 w,I8 x,I8 y); +#help_index "" diff --git a/LT/Adam/GrAsm/GrAsm.MPZ b/LT/Adam/GrAsm/GrAsm.MPZ new file mode 100644 index 0000000..cb9402f Binary files /dev/null and b/LT/Adam/GrAsm/GrAsm.MPZ differ diff --git a/LT/Adam/GrAsm/GrAsm.SPZ b/LT/Adam/GrAsm/GrAsm.SPZ new file mode 100644 index 0000000..0218add Binary files /dev/null and b/LT/Adam/GrAsm/GrAsm.SPZ differ diff --git a/LT/Adam/HashUtils.APZ b/LT/Adam/HashUtils.APZ new file mode 100644 index 0000000..7db67f9 --- /dev/null +++ b/LT/Adam/HashUtils.APZ @@ -0,0 +1,397 @@ +#help_index "Hash/Reports" + +class HashRepStruct +{ + SysHashEntry *h; + I1 *index; +}; + + +I8 CompareHashEntries(HashRepStruct *h1,HashRepStruct *h2) +{ + return StrCmp(h1->h->str,h2->h->str); +} + +I8 CompareHashEntries2(HashRepStruct *h1,HashRepStruct *h2) +{ + ClassStruct *tempc1=h1->h,*tempc2=h2->h; + I8 i1=0,i2=0; + if (tempc1->type & HTT_FUNCTION) + i1=tempc1->executable_address; + if (tempc2->type & HTT_FUNCTION) + i2=tempc2->executable_address; + return i1-i2; +} + +I8 HelpIndexCnt(I1 *ptr,I1 *index) +{ + I1 cnt=0,ch; + I8 index_len=StrLen(index); + while (*ptr) { + if (!StrNCmp(ptr,index,index_len)) + cnt++; + while (ch=*ptr++) + if (ch==';') + break; + if (!ch) + ptr--; + } + return cnt; +} + +I1 *HelpIndexStr(I1 **ptr_,I1 *index) +{ + I1 *ptr=*ptr_,*ptr2,ch,*result; + I8 index_len=StrLen(index); + while (*ptr) { + ptr2=ptr; + while (ch=*ptr++) + if (ch==';') + break; + if (!ch) + ptr--; + *ptr_=ptr; + if (!StrNCmp(ptr2,index,index_len)) { + if (ch==';') + ptr--; + *ptr=0; + result=NewStr(ptr2); + *ptr=ch; + return result; + } + } + return NULL; +} + +I8 CompareHashEntries3(HashRepStruct *h1,HashRepStruct *h2) +{ + I8 i,i1=0,i2=0; + i=StrCmp(h1->index,h2->index); + if (i) + return i; + else { + if (h1->h->type&HTT_HELP_FILE) + i1=1; + if (h2->h->type&HTT_HELP_FILE) + i2=1; + i=i2-i1; + if (i) + return i; + else + return StrCmp(h1->h->str,h2->h->str); + } +} + +//Possible choices for first parameter, "h" include +// "adam_tss->hash_table" +// "Fs->hash_table" +public void HashRep(SysHashTable *h=NULL, + U8 mask=HTT_ALL,I1 *outname=NULL,I1 *flags=NULL,I1 mapfile_drive=0,I1 *index=NULL, + Ltf *l_=NULL) +{ + SysHashTable *tempht; + SysHashEntry *ptr,*temph; + HashRepStruct *list; + U8 cnt,i,j,k,size,f=0; + I1 buf[512],*buf4,*last_index=NewStr(""),*cur_index; + Ltf *l,*l1; + BoolU4 recurse,publics,map; + LtfBinEntry *tempb; + DbgInfo *dbg; + BoolU4 old_preempt=Preempt(OFF); + + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r+p"); + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags); + recurse=Bt(&f,FUf_RECURSE); + publics=Bt(&f,FUf_PUBLIC); + map =Bt(&f,FUf_MAP); + + if (!h) h=Fs->hash_table; + + if (outname) { + l=LtfNew; + l->flags|=LTFF_NO_CURSOR; + StrCpy(l->filename.name,outname); + } else + l=NULL; + if (l_) + l=l_; + + cnt=0; + tempht=h; + while (tempht) { + for (i=0;i<=tempht->mask;i++) { + temph=tempht->body[i]; + while (temph) { + if (!(temph->type & (HTT_IMPORT | HTT_PRIVATE)) && + temph->type & mask && + (temph->type & HTT_PUBLIC || !publics)) + if (!index) + cnt++; + else + if (cur_index=temph->index) + cnt+=HelpIndexCnt(cur_index,index); + temph=temph->next; + } + } + if (recurse) + tempht=tempht->next; + else + break; + } + if (!cnt) goto end_hash; + + list=MAllocZ(cnt*sizeof(HashRepStruct)); + j=0; + tempht=h; + while (tempht) { + for (i=0;i<=tempht->mask;i++) { + temph=tempht->body[i]; + while (temph) { + if (!(temph->type & (HTT_IMPORT | HTT_PRIVATE)) && + temph->type & mask && + (temph->type & HTT_PUBLIC || !publics)) + if (!index) + list[j++].h=temph; + else + if (cur_index=temph->index) + if (k=HelpIndexCnt(cur_index,index)) { + while (k--) { + list[j].index=HelpIndexStr(&cur_index,index); + list[j++].h=temph; + } + } + temph=temph->next; + } + } + if (recurse) + tempht=tempht->next; + else + break; + } + Preempt(old_preempt); + + if (map) + QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries2); + else if (index) + QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries3); + else + QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries); + + for (i=0;itype & HTT_HELP_FILE) { + if (l) { + l1=LtfRead(ptr->str); + EditInsertLtf(l,l1); + LtfDel(l1); + } else + Type(ptr->str); + } else { + if (ptr->source_link) { + buf4=NewStr(ptr->source_link); + if (mapfile_drive && StrLen(buf4)>3) + buf4[3]=mapfile_drive; + if (l && ptr->type & HTT_FUNCTION) { + dbg=ptr><(ClassStruct *)->debug; + if (dbg) { + size=offset(DbgInfo.body)+ + sizeof(void *)* + (dbg->max_line-dbg->min_line+2); + if (size>MSize(dbg)) { + coutln "Corrupt Map Entry"; + dbg=NULL; + } else { + if (dbg->min_line<=dbg->max_line) { + tempb=MAllocZ(sizeof(LtfBinEntry)); + tempb->type=LTFBT_GENERIC_DATA; + tempb->size=size; + tempb->data=MAlloc(size); + MemCpy(tempb->data,dbg,size); + tempb->num=l->cur_bin_num; + tempb->use_cnt=1; + InsQue(tempb,l->bin_root.last); + } else + dbg=NULL; + } + } + } + if (dbg) + SPrintF(buf,"$$LK+BI,\"%-18s \",\"%s\",%d$$", + ptr->str,buf4,l->cur_bin_num++); + else + SPrintF(buf,"$$LK,\"%-18s \",\"%s\"$$", + ptr->str,buf4); + Free(buf4); + } else + SPrintF(buf,"%-18ts ",ptr->str); + + if (l) + LtfPutSExt(l,buf); + else + PutS(buf); + + if (!index) { + if (ptr->type & HTT_FUNCTION) + SPrintF(buf,"%08X",ptr><(ClassStruct *)->executable_address); + else if (ptr->type & HTT_STR_CONST) + SPrintF(buf,"%-8tQ",ptr><(StrConstStruct *)->data); + else if (ptr->type & HTT_GLBL_VAR) + SPrintF(buf,"%08X",ptr><(GlblVarStruct *)->data_address); + else if (ptr->type & HTT_SYSTEXT) + SPrintF(buf,"%-8tQ %04tX",ptr->user_data0,ptr->user_data1); + else + SPrintF(buf,"%08X",ptr->user_data0); + SPrintF(buf+StrLen(buf)," %04X ",ptr->use_cnt); + } else + *buf=0; + + k=ptr->type; + if (publics) + k&=~HTT_PUBLIC; + + for (j=0;j<32;j++) + if (Bt(&k,j)) + SPrintF(buf+StrLen(buf),"%Z ",j,"ST_HTT_TYPES"); + StrCat(buf,"\r\n"); + if (l) + LtfPutSExt(l,buf); + else + PutS(buf); + } + Free(list[i].index); + } + Free(list); + +end_hash: + if (l) { + if (!l_) { + LtfWrite(l); + LtfDel(l); + } else { + if (l->dummy.next==l) + LtfPutSExt(l,"No Match"); + } + } + Free(last_index); +} + +public void HFunsRep(I1 *flags="",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_FUNCTION,NULL,flags,0,index); +} + +public void HMapRep(I1 *flags="-p+m",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_FUNCTION,NULL,flags,0,index); +} + +public void HVarsRep(I1 *flags="",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_GLBL_VAR,NULL,flags,0,index); +} + +public void HClassesRep(I1 *flags="-p",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_CLASS,NULL,flags,0,index); +} + +public void HDefinesRep(I1 *flags="-p",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_STR_CONST,NULL,flags,0,index); +} + +public void HSymsRep(I1 *flags="-p",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_SYS_SYMBOL,NULL,flags,0,index); +} + +public void HSysTextsRep(I1 *flags="-p",I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_SYSTEXT,NULL,flags,0,index); +} + +public void HAllRep(I1 *index=NULL) +{ + HashRep(Fs->hash_table,HTT_ALL,NULL,"-p",0,index); +} + +public void LtfHelpIndex(Ltf *l,I1 *index) +{ + HashRep(Fs->hash_table,HTT_ALL,NULL,NULL,0,index,l); +} + +public void PopUpHelpIndex(I1 *index,TssStruct *parent=NULL) +{ + I1 *buf; + buf=MSPrintF("LtfHelpIndex(Fs->cur_ltf,\"%s\");View;",index); + PopUp(buf,parent); + Free(buf); +} + +#help_index "Hash" +public void LoadMapFile(I1 *filename) +{ + I1 *st,*name=DefaultExtension(filename,"MPZ"); + I1 *absname=AbsoluteFileName(name); + Ltf *l=LtfRead(name); + LtfEntry *cl; + SysHashEntry *temph; + U8 i,j,base=0; + DbgInfo *dbg; + + RemoveLastSeg(absname,"."); + if (absname[1]==':' && StrLen(absname)>2) { + temph=FindLocalHash(absname+2,HTT_MODULE); + if (temph) + base=temph->user_data0; + } + + if (!l) return; + cl=l->dummy.next; + while (cl!=l) { + if (cl->btype==LTFT_LINK) { + st=MStrUtil(cl->display,SU_REMOVE_TRAILING); + if (temph=FindLocalHash(st,HTT_ALL)) { + Free(temph->source_link); + temph->source_link=cl->aux_str; + cl->aux_str=NULL; + dbg=temph->debug; + if (!dbg && cl->bin_data) { + dbg=cl->bin_data->data; + if (dbg) { + if (cl->bin_data->size>MSize(dbg)) + coutln "Corrupt Map Entry"; + else { + cl->bin_data->data=NULL; + temph->debug=dbg; + for (i=dbg->min_line;i<=dbg->max_line+1;i++) { + j=i-dbg->min_line; + if (dbg->body[j]) + dbg->body[j]=dbg->body[j]+base; + } + } + } + } + } + Free(st); + } + cl=cl->next; + } + LtfDel(l); + Free(name); + Free(absname); +} +#help_index "" diff --git a/LT/ADAM/IncCompress.CPZ b/LT/Adam/IncCompress.APZ similarity index 91% rename from LT/ADAM/IncCompress.CPZ rename to LT/Adam/IncCompress.APZ index 85fbf15..108a751 100644 --- a/LT/ADAM/IncCompress.CPZ +++ b/LT/Adam/IncCompress.APZ @@ -1,3 +1,5 @@ +#help_index "Compression" + #define ICT_U2 1 #define ICT_U4 2 #define ICT_U8 3 @@ -35,7 +37,7 @@ class IntermediateIncCompressStruct 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; + I8 i,j,k,n,best_k=0,best_j,best_i; IntermediateIncCompressStruct *tempc; //$BK,1$TODO: improve this algorithm$BK,0$ @@ -43,8 +45,8 @@ void IncCompressRange(U1 *ref,U8 ref_size,U1 *b,U8 range_start,U8 range_end, for (i=range_start;ibest_k) { best_k=k; @@ -68,6 +70,10 @@ void IncCompressRange(U1 *ref,U8 ref_size,U1 *b,U8 range_start,U8 range_end, public IncCompressStructU2 *IncCompress(U1 *ref,U8 ref_size,U1 *b,U8 size) +//This is for incremental compression. +//In theory it works when only a few +//changes have been made. Might be +//better just to stick with $LK,"CompressBuf","MN:CompressBuf"$(). { U8 i,j=0,l=0,m=0,ic_type; U1 *u1,*result; @@ -302,3 +308,4 @@ public U1 *IncExpand(U1 *ref,IncCompressStructU2 *b,U8 *size=NULL) } return result; } +#help_index "" diff --git a/LT/ADAM/INPTR.CPZ b/LT/Adam/InputPointer.APZ similarity index 58% rename from LT/ADAM/INPTR.CPZ rename to LT/Adam/InputPointer.APZ index 1135f98..f81d010 100644 --- a/LT/ADAM/INPTR.CPZ +++ b/LT/Adam/InputPointer.APZ @@ -1,10 +1,15 @@ +#help_index "Input Pointer" +#help_file "::/LT/Doc/InputPointer.TXZ" + #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 ipx=0,ipy=0,ipz=0,ip_throttle=0; +public I8 ipx_snap=1,ipy_snap=1,ipz_snap=1; +public I8 ipx_snap_offset=0,ipy_snap_offset=0,ipz_snap_offset=0; +public double 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 @@ -12,3 +17,5 @@ public BoolU4 ip_on=TRUE, //Show or hide cursor 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; + +#help_index "" diff --git a/LT/Adam/JoyStick.APZ b/LT/Adam/JoyStick.APZ new file mode 100644 index 0000000..7271e61 Binary files /dev/null and b/LT/Adam/JoyStick.APZ differ diff --git a/LT/Adam/KbdMouse.APZ b/LT/Adam/KbdMouse.APZ new file mode 100644 index 0000000..9ea84f6 --- /dev/null +++ b/LT/Adam/KbdMouse.APZ @@ -0,0 +1,738 @@ +time_stamp_freq=SYS_TIMER_FREQ*( + GetTimeStamp-time_stamp_start)/ + (ReadSysTimer-sys_timer_start); +time_stamp_kHz_freq=time_stamp_freq/1000; + + +#help_index "Char/Input" + +U8Fifo *scan_code_fifo=NewU8Fifo(128); + +U8 last_down_scan_code=0; + +void KbdCmdSend(U8 port, U1 val,BoolU4 *btimeout=NULL) +{ + LTDate timeout=BootTime+LTDATE_FREQ/10; + do { + if (!(InP(KEYB_CTRL)&2)) { + timeout=0; + break; + } + } while (BootTime=0x50) + return 0; + else + return table[sc]; +} + +U1 scan_code_map[0x100]={ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,SC_SHIFT,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,SC_CR,SC_CTRL,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END, + SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INSERT,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + + +U1 num_lock_map[0x100]={ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,8,9,10,0,5,6,7,0,2, + 3,4,11,0x34,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,SC_CR,SC_CTRL,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END, + SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INSERT,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + + + +public void SetTypeMatic(U1 delay) +{ + KbdCmdSend(KEYB_CTRL,0xA7); //Disable Mouse + KbdCmdSend(KEYB_CTRL,0xAE); //Enable Keyboard + KbdCmdSend(KEYB_PORT,0xF3); + KbdCmdSend(KEYB_PORT,delay); //Typematic rate + KbdCmdSend(KEYB_CTRL,0xA8); //Enable Mouse +} + +#help_index "Char/Conversion" + +public I1 *ASCIIToKeyName(I8 ch,BoolU4 include_ctrl=TRUE) +{ + I8 i; + I1 buf[64]; + *buf=0; + if (ch) { + if (ch<26) { + if (ch==CH_CR) + StrCat(buf,"ENTER"); + else if (ch==CH_ESC) + StrCat(buf,"ESC"); + else if (ch==CH_BACKSPACE) + StrCat(buf,"BACKSPACE"); + else if (ch==CH_TAB) + StrCat(buf,"TAB"); + else if (ch==CH_CURSOR) + StrCat(buf,"CURSOR"); + else { + if (include_ctrl) + StrCat(buf,"CTRL "); + buf[i=StrLen(buf)]=ch-1+'A'; + buf[i+1]=0; + } + } else if (Bt(printable_chars_bitmap,ch)) { + if (ch==CH_SPACE) + StrCat(buf,"SPACE"); + else if (ch==CH_SHIFT_SPACE) + StrCat(buf,"SHIFT_SPACE"); + else { + buf[i=StrLen(buf)]=ch; + buf[i+1]=0; + } + } + } + return NewStr(buf); +} + +public I1 *ScanCodeToKeyName(I8 sc) +{ + I8 ch=ScanCodeToASCII(sc); + I1 buf[64],*st; + *buf=0; + if (sc&SCF_CTRL) + StrCat(buf,"CTRL "); + if (sc&SCF_ALT) + StrCat(buf,"ALT "); + if (sc&SCF_SHIFT) + StrCat(buf,"SHIFT "); + if (ch) { + st=ASCIIToKeyName(ch,FALSE); + StrCpy(buf+StrLen(buf),st); + Free(st); + } else { + switch (sc.u1[0]) { + case SC_BACKSPACE:StrCat(buf,"BACK"); break; + case SC_CAPS: StrCat(buf,"CAPS"); break; + case SC_NUM: StrCat(buf,"NUM"); break; + case SC_SCROLL: StrCat(buf,"SCROLL"); break; + case SC_CURSOR_UP:StrCat(buf,"UP"); break; + case SC_CURSOR_DOWN:StrCat(buf,"DOWN"); break; + case SC_CURSOR_LEFT:StrCat(buf,"LEFT"); break; + case SC_CURSOR_RIGHT:StrCat(buf,"RIGHT"); break; + case SC_PAGE_UP:StrCat(buf,"PAGE_UP"); break; + case SC_PAGE_DOWN:StrCat(buf,"PAGE_DOWN"); break; + case SC_HOME: StrCat(buf,"HOME"); break; + case SC_END: StrCat(buf,"END"); break; + case SC_INSERT: StrCat(buf,"INSERT"); break; + case SC_DELETE: StrCat(buf,"DELETE"); break; + case SC_F1: StrCat(buf,"F1"); break; + case SC_F2: StrCat(buf,"F2"); break; + case SC_F3: StrCat(buf,"F3"); break; + case SC_F4: StrCat(buf,"F4"); break; + case SC_F5: StrCat(buf,"F5"); break; + case SC_F6: StrCat(buf,"F6"); break; + case SC_F7: StrCat(buf,"F7"); break; + case SC_F8: StrCat(buf,"F8"); break; + case SC_F9: StrCat(buf,"F9"); break; + case SC_F10: StrCat(buf,"F10"); break; + case SC_F11: StrCat(buf,"F11"); break; + case SC_F12: StrCat(buf,"F12"); break; + case SC_GUI: StrCat(buf,"WINDOWS"); break; + case SC_PRTSCRN1: StrCat(buf,"PRTSCRN1"); break; + case SC_PRTSCRN2: StrCat(buf,"PRTSCRN2"); break; + } + } + return NewStr(buf); +} + + +#help_index "Training" + +I8 display_keys_row=TEXT_ROWS/2; +public BoolU4 kbd_display_special_keys=FALSE; + +void DisplayKeysPopUp() +{ + I8 i; + I1 *st; + InitLocalTask; + Fs->win_left=TEXT_COLS/2-8; + Fs->win_top=display_keys_row; + Fs->win_right=TEXT_COLS/2+8; + Fs->win_bottom=Fs->win_top; + Fs->text_attribute=(YELLOW<<4)+BLACK; + Fs->border_attribute=(YELLOW<<4)+BLACK; + Btr(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN); + UseConsoleLtf(NULL); + Fs->cur_ltf->flags&=~LTFF_ATTR_BY_PARTITION; + Fs->aux_ltf->flags&=~LTFF_ATTR_BY_PARTITION; + Fs->cur_ltf->start_text_attribute=(YELLOW<<4)+BLACK; + Fs->aux_ltf->start_text_attribute=(YELLOW<<4)+BLACK; + st=ScanCodeToKeyName(last_down_scan_code); + PrintF("%s",st); + Free(st); + LtfRecalc(Fs->cur_ltf); + Bts(&Fs->crt_flags,CRTf_SHOW); + + display_keys_row+=4; + for (i=0;i<1000;i++) { + WinToTop(Fs); + Sleep(1); + } + display_keys_row-=4; +} + +void DisplaySpecialKeys(I8 sc) +{ + I8 ch; + if (!(sc&SCF_KEY_UP) && + sc&SCF_NEW_KEY ) { + ch=ScanCodeToASCII(sc); + if (!ch || (ch='a' && ch<='z') { + if (ctrl_alt_letter_routines[ch-'a']) { + CallInd(ctrl_alt_letter_routines[ch-'a']); + goto mostly_done; + } + } + } + } + } + +new_key_done: + sc|=SCF_NEW_KEY; +mostly_done: + sys_cur_scan_code=sc|sc2| + (sc|sc_raw)<<32; + + if (kbd_display_special_keys) + DisplaySpecialKeys(sys_cur_scan_code); + if (Btr(&sys_cur_scan_code,SCf_NEW_KEY)) { + Btr(&sys_cur_scan_code,32+SCf_NEW_KEY); + U8FifoInsert(scan_code_fifo,sys_cur_scan_code); + if (!(sys_cur_scan_code&SCF_KEY_UP)) + last_down_scan_code=sys_cur_scan_code; + } +} + + +#help_index "Input Pointer" +public double mxx_scale=0.5, + myy_scale=0.5, + mzz_scale=1.0; + +public I8 mxx_prescale=GR_WIDTH/mxx_scale/2.0, + myy_prescale=GR_HEIGHT/myy_scale/2.0, + mzz_prescale=0/mzz_scale; + +public I8 mxx=GR_WIDTH>>1, + myy=GR_HEIGHT>>1, + mzz=0; + +BoolU4 mouse_buttons[5]; + +BoolU4 mouse_installed=FALSE; +U8 mouse_install_attempts=0; +BoolU4 mouse_has_wheel=FALSE; +BoolU4 mouse_has_ext_buttons=FALSE; +BoolU4 mouse_evt=FALSE; +BoolU4 mouse_irqs_working=FALSE; + +U8 mouse_pkt_size=3; + +BoolU8 MouseGetDeviceType() +{ + BoolU4 my_btimeout; + U1 b; + KbdMouseCmdAck(0xF2,&my_btimeout); + if (my_btimeout) + return FALSE; + b=KbdCmdRead; + if (b==3) + mouse_has_wheel=TRUE; + else if (b==4) + mouse_has_ext_buttons=TRUE; + + return TRUE; +} + +BoolU8 MouseReset() +{ + I8 i; + BoolU4 my_btimeout,result=FALSE; + + mouse_has_wheel=FALSE; + mouse_has_ext_buttons=FALSE; + + KbdCmdFlush; + KbdCmdSend(KEYB_CTRL,0xAD,&my_btimeout); //Disable Kbd + if (my_btimeout) goto done; + KbdCmdSend(KEYB_CTRL,0xA8,&my_btimeout); //Enable Mouse + if (my_btimeout) goto done; + + KbdMouseCmdAck(0xFF,&my_btimeout); //Reset + if (my_btimeout) goto done; + + for (i=0;i<250;i++) { + KbdCmdRead(&my_btimeout); + if (!my_btimeout) + break; + } + KbdCmdRead(&my_btimeout); + + KbdMouseCmdAck(0xF3,&my_btimeout); + if (my_btimeout) goto done; + KbdMouseCmdAck(200,&my_btimeout); + if (my_btimeout) goto done; + KbdMouseCmdAck(0xF3,&my_btimeout); // enable Mouse + if (my_btimeout) goto done; + KbdMouseCmdAck(100,&my_btimeout); // Set Rate + if (my_btimeout) goto done; + KbdMouseCmdAck(0xF3,&my_btimeout); + if (my_btimeout) goto done; + KbdMouseCmdAck(80,&my_btimeout); //Resolution + if (my_btimeout) goto done; + if (!MouseGetDeviceType) goto done; // enable Mouse + + KbdMouseCmdAck(0xF3,&my_btimeout); + if (my_btimeout) goto done; + KbdMouseCmdAck(10,&my_btimeout); + if (my_btimeout) goto done; + if (!MouseGetDeviceType) goto done; // enable Mouse + + KbdMouseCmdAck(0xE8,&my_btimeout); //Resolution + if (my_btimeout) goto done; + KbdMouseCmdAck(0x03,&my_btimeout); + if (my_btimeout) goto done; + KbdMouseCmdAck(0xE6,&my_btimeout); + if (my_btimeout) goto done; + + KbdMouseCmdAck(0xF3,&my_btimeout); // Set Rate + if (my_btimeout) goto done; + KbdMouseCmdAck(100,&my_btimeout); + if (my_btimeout) goto done; + + KbdMouseCmdAck(0xF4,&my_btimeout); // enable Mouse + if (my_btimeout) goto done; + result=TRUE; +done: + KbdCmdSend(KEYB_CTRL,0xAE); //Enable Keyboard + if (mouse_has_wheel || mouse_has_ext_buttons) + mouse_pkt_size=4; + else + mouse_pkt_size=3; + if (!result) + KbdCmdSend(KEYB_CTRL,0xA7); //Disable Mouse + return result; +} + + +void MouseHandler() +{ + I8 i,dx,dy,dz,old_x=mxx,old_y=myy,old_z=mzz; + U1 mouse_buf[4]; + BoolU4 old_buttons[5]; + + for (i=0;i<5;i++) + old_buttons[i]=mouse_buttons[i]; + + for (i=0;i<4;i++) + if (!U1FifoRemove(kbdmouse_fifo,&mouse_buf[i])) + mouse_buf[i]=0; + + 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_prescale+=dx; + myy_prescale+=dy; + mzz_prescale+=dz; + + mxx=mxx_prescale*mxx_scale; + myy=myy_prescale*myy_scale; + mzz=mzz_prescale*mzz_scale; + + if (mxx < 0) { + mxx=0; + mxx_prescale=0; + } + if (mxx>=GR_WIDTH) { + mxx=GR_WIDTH-1; + mxx_prescale=mxx/mxx_scale; + } + if (myy < 0) { + myy=0; + myy_prescale=0; + } + if (myy>=GR_HEIGHT) { + myy=GR_HEIGHT-1; + myy_prescale=myy/myy_scale; + } + if (mxx!=old_x||myy!=old_y||mzz!=old_z) + mouse_evt=TRUE; + else + for (i=0;i<5;i++) + if (mouse_buttons[i]!=old_buttons[i]) { + mouse_evt=TRUE; + break; + } +} + +U8 kbdmouse_timeout=0; + +void ResetKbdMouse(I8 Hz=50) +{ + Btr(&sys_semas[SYS_SEMA_KEY_PRESSED],0); + KbdCmdFlush(Hz); + U1FifoFlush(kbdmouse_fifo); + U8FifoFlush(scan_code_fifo); + kbdmouse_timeout=0; + OutP(0x21,InP(0x21)&~2); +} + +BoolU8 InstallMouseDriver() +{ + I8 i; + Preempt(ON); + mouse_installed=FALSE; + for(i=0;i<5;i++) + mouse_buttons[i]=0; + if (MouseReset) + mouse_installed=TRUE; + ResetKbdMouse; + mouse_install_attempts++; + mouse_evt=mouse_installed; + return mouse_installed; +} + +void HandleKbdMouse() +{ + U1 i; + if (U1FifoCnt(kbdmouse_fifo)) { + if (kbdmouse_timeout && + GetTimeStamp>kbdmouse_timeout) { + ResetKbdMouse; + return; + } + if (Btr(&sys_semas[SYS_SEMA_KEY_PRESSED],0)) { + while (U1FifoCnt(kbdmouse_fifo)) { + if (U1FifoCnt(kbdmouse_fifo)==1) { + U1FifoPeek(kbdmouse_fifo,&i); + if (i==0xE0) { + if (!kbdmouse_timeout) + kbdmouse_timeout=GetTimeStamp+time_stamp_freq/50; + Bts(&sys_semas[SYS_SEMA_KEY_PRESSED],0); + return; + } + } + kbdmouse_timeout=0; + KbdHandler; + OutP(0x21,InP(0x21)&~2); + } + } else { + if (!mouse_installed) + U1FifoFlush(kbdmouse_fifo); + else { + if (U1FifoCnt(kbdmouse_fifo)>=mouse_pkt_size) { + kbdmouse_timeout=0; + mouse_evt_time=GetTimeStamp; + while (U1FifoCnt(kbdmouse_fifo)>=mouse_pkt_size) + MouseHandler; + } else + if (!kbdmouse_timeout) + kbdmouse_timeout=GetTimeStamp+time_stamp_freq/50; + } + } + } else + kbdmouse_timeout=0; +} + +#define KBDMOUSE_POLL_RATE 500 +U8 last_kbdmouse_poll_time=GetTimeStamp; + +extern void PollKbdMouse(); + +TssStruct *poll_kbdmouse_tss=NULL; + +void PollKbdMouseTsk() +{ //Poll for a minute + I8 i; + for (i=0;itime_stamp_freq/KBDMOUSE_POLL_RATE*4) { + last_kbdmouse_poll_time=poll_time; + ResetKbdMouse(0); + if (!poll_kbdmouse_tss) + poll_kbdmouse_tss=Spawn(&PollKbdMouseTsk,"Poll KbdMouse"); + } else { + last_kbdmouse_poll_time=poll_time; + while (InP(KEYB_CTRL)&1) { + U1FifoInsert(kbdmouse_fifo,InP(KEYB_PORT)); + HandleKbdMouse; + } + } +} + + +#help_index "" + + +InitKbd; +Spawn(&InstallMouseDriver); diff --git a/LT/Adam/LPT.APZ b/LT/Adam/LPT.APZ new file mode 100644 index 0000000..4bd4bb1 Binary files /dev/null and b/LT/Adam/LPT.APZ differ diff --git a/LT/Adam/LogIn.APZ b/LT/Adam/LogIn.APZ new file mode 100644 index 0000000..96695a9 Binary files /dev/null and b/LT/Adam/LogIn.APZ differ diff --git a/LT/Adam/Ltf/Ltf.APZ b/LT/Adam/Ltf/Ltf.APZ new file mode 100644 index 0000000..59938f0 Binary files /dev/null and b/LT/Adam/Ltf/Ltf.APZ differ diff --git a/LT/Adam/Ltf/LtfBible.APZ b/LT/Adam/Ltf/LtfBible.APZ new file mode 100644 index 0000000..c1cb75f --- /dev/null +++ b/LT/Adam/Ltf/LtfBible.APZ @@ -0,0 +1,154 @@ +LoadStr("ST_BIBLE_FILE","::/LT/Text/Bible.TXZ"); + +LoadList("ST_BIBLE_BOOKS", +"Genesis\0" +"Exodus\0" +"Leviticus\0" +"Numbers\0" +"Deuteronomy\0" +"Joshua\0" +"Judges\0" +"Ruth\0" +"1 Samuel\0" +"2 Samuel\0" +"1 Kings\0" +"2 Kings\0" +"1 Chronicles\0" +"2 Chronicles\0" +"Ezra\0" +"Nehemiah\0" +"Tobit\0" +"Judith\0" +"Esther\0" +"1 Maccabees\0" +"2 Maccabees\0" +"Job\0" +"Psalms\0" +"Proverbs\0" +"Ecclesiastes\0" +"Song of Songs\0" +"Wisdom\0" +"Sirach\0" +"Isaiah\0" +"Jeremiah\0" +"Lamentations\0" +"Baruch\0" +"Ezekiel\0" +"Daniel\0" +"Hosea\0" +"Joel\0" +"Amos\0" +"Obadiah\0" +"Jonah\0" +"Micah\0" +"Nahum\0" +"Habakkuk\0" +"Zephaniah\0" +"Haggai\0" +"Zechariah\0" +"Malachi\0" +"Matthew\0" +"Mark\0" +"Luke\0" +"John\0" +"Acts\0" +"Romans\0" +"1 Corinthians\0" +"2 Corinthians\0" +"Galatians\0" +"Ephesians\0" +"Philippians\0" +"Colossians\0" +"1 Thessalonians\0" +"2 Thessalonians\0" +"1 Timothy\0" +"2 Timothy\0" +"Titus\0" +"Philemon\0" +"Hebrews\0" +"James\0" +"1 Peter\0" +"2 Peter\0" +"1 John\0" +"2 John\0" +"3 John\0" +"Jude\0" +"Revelation\0" +"\0"); + +LoadList("ST_BIBLE_BOOK_LINES", +"297\0" +"5068\0" +"9123\0" +"12005\0" +"15977\0" +"19168\0" +"21329\0" +"23598\0" +"23902\0" +"26892\0" +"29345\0" +"32241\0" +"34961\0" +"37633\0" +"40756\0" +"41671\0" +"Tobit\0" +"Judith\0" +"42963\0" +"1 Maccabees\0" +"2 Maccabees\0" +"43605\0" +"46190\0" +"53793\0" +"56267\0" +"56966\0" +"Wisdom\0" +"Sirach\0" +"57332\0" +"61806\0" +"66736\0" +"Baruch\0" +"67217\0" +"71804\0" +"73189\0" +"73876\0" +"74130\0" +"74615\0" +"74697\0" +"74860\0" +"75241\0" +"75416\0" +"75604\0" +"75806\0" +"75932\0" +"76684\0" +"76908\0" +"79970\0" +"81941\0" +"85266\0" +"87803\0" +"90914\0" +"92110\0" +"93323\0" +"94088\0" +"94514\0" +"94869\0" +"95153\0" +"95402\0" +"95647\0" +"95772\0" +"96090\0" +"96320\0" +"96440\0" +"96500\0" +"97370\0" +"97687\0" +"97976\0" +"98163\0" +"98506\0" +"98552\0" +"98597\0" +"98684\0" +"\0"); + diff --git a/LT/Adam/Ltf/LtfCtrlL.APZ b/LT/Adam/Ltf/LtfCtrlL.APZ new file mode 100644 index 0000000..13c0a58 --- /dev/null +++ b/LT/Adam/Ltf/LtfCtrlL.APZ @@ -0,0 +1,930 @@ +#define LK_FILE 0 +#define LK_FILE_ANCHOR 1 +#define LK_FILE_FIND 2 +#define LK_FILE_LINE 3 +#define LK_MAN_PAGE 4 +#define LK_PLAIN 5 +#define LK_PLAIN_FIND 6 +#define LK_PLAIN_LINE 7 +#define LK_BIBLE_FIND 8 +#define LK_DEF 9 +#define LK_HELP_INDEX 10 +#define LK_PLACE_ANCHOR 11 + +I8 PopUpLinkType(BoolU4 include_anchor) +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"To file\",LK_FILE$$\r\n"); + LtfPutSExt(l,"$$MU,\"To anchor in file\",LK_FILE_ANCHOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"To str in file\",LK_FILE_FIND$$\r\n"); + LtfPutSExt(l,"$$MU,\"To line in file\",LK_FILE_LINE$$\r\n"); + LtfPutSExt(l,"$$MU,\"To man page\",LK_MAN_PAGE$$\r\n"); + LtfPutSExt(l,"$$MU,\"To plain-text file\",LK_PLAIN$$\r\n"); + LtfPutSExt(l,"$$MU,\"To str in plain-text file\",LK_PLAIN_FIND$$\r\n"); + LtfPutSExt(l,"$$MU,\"To line in plain-text file\",LK_PLAIN_LINE$$\r\n"); + LtfPutSExt(l,"$$MU,\"To Bible chapter line and verse\",LK_BIBLE_FIND$$\r\n"); + LtfPutSExt(l,"$$MU,\"To Dictionary Definition\",LK_DEF$$\r\n"); + LtfPutSExt(l,"$$MU,\"To Help Index\",LK_HELP_INDEX$$\r\n"); + if (include_anchor) + LtfPutSExt(l,"$$MU,\"Place Anchor\",LK_PLACE_ANCHOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"CANCEL\",-1$$"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +class EditFileLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n"; + I1 aux[132]; + I8 num; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditFileAnchorLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n"; + I1 aux[132] fmtstr "$$DA-P,131,\"Anchor Label :%s\"$$\r\n"; + I8 num; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditFileFindLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n"; + I1 aux[132] fmtstr "$$DA-P,131,\"Str :%s\"$$\r\n"; + I8 num fmtstr "$$DA-T,131,\"Occurrence Num:%04d\"$$\r\n"; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditFileLineLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n"; + I1 aux[132]; + I8 num fmtstr "$$DA-T,131,\"Line Num :%04d\"$$\r\n"; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditManPageLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132]; + I1 aux[132] fmtstr "$$DA-P,131,\"Label :%s\"$$\r\n"; + I8 num; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditPlaceAnchorStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132]; + I1 aux[132] fmtstr "$$DA-P,131,\"Anchor Label :%s\"$$\r\n"; + I8 num; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide fmtstr "$$CB,\"Hide\"$$\r\n"; +}; + +class EditBibleLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132]; + I1 aux[132] fmtstr "$$DA-P,131,\"Chapter Verse :%s\"$$\r\n"; + I8 num; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + +class EditDefLinkStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 file[132]; + I1 aux[132] fmtstr "$$DA-P,131,\"Word :%s\"$$\r\n"; + I8 num fmtstr "$$DA-T,131,\"Def Num :%4d\"$$\r\n"; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; + BoolU4 hide; +}; + + + +I1 *ctrl_L_header="Press WINDOW's key for help\r\n\r\n"; + + +BoolU8 PmtLink(I8 type,I1 **display,I1 **link,BoolU4 *quote) +{ + I8 i; + BoolU4 result=FALSE; + if (quote) *quote=FALSE; + EditFileLinkStruct *el=MAllocZ(sizeof(EditFileLinkStruct)); + if (type>=0) { + el->num=1; + switch (type) { + case LK_FILE: + if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->file); + else + *display=NewStr(el->display); + *link=MSPrintF("FI:%s",el->file); + } + break; + case LK_PLAIN: + if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->file); + else + *display=NewStr(el->display); + *link=MSPrintF("PI:%s",el->file); + } + break; + case LK_FILE_ANCHOR: + if (DoForm(el,"EditFileAnchorLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("FA:%s,%s",el->file,el->aux); + } + break; + case LK_FILE_FIND: + if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (el->num==1) { + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("FF:%s,%s",el->file,el->aux); + } else { + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("FF:%s,%s:%d",el->file,el->aux,el->num); + } + } + break; + case LK_PLAIN_FIND: + if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (el->num==1) { + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("PF:%s,%s",el->file,el->aux); + } else { + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("PF:%s,%s:%d",el->file,el->aux,el->num); + } + } + break; + case LK_FILE_LINE: + if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->file); + else + *display=NewStr(el->display); + *link=MSPrintF("FL:%s,%d",el->file,el->num); + } + break; + case LK_PLAIN_LINE: + if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->file); + else + *display=NewStr(el->display); + *link=MSPrintF("PL:%s,%d",el->file,el->num); + } + break; + case LK_MAN_PAGE: + if (DoForm(el,"EditManPageLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("MN:%s",el->aux); + } + break; + case LK_PLACE_ANCHOR: + if (DoForm(el,"EditPlaceAnchorStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) { + if (el->hide) + *display=NewStr(""); + else + *display=NewStr(el->aux); + } else + *display=NewStr(el->display); + *link=NewStr(el->aux); + } + break; + case LK_BIBLE_FIND: //TODO + i=PopUpPickSysTextSub("ST_BIBLE_BOOKS"); + if (i>=0) { + if (DoForm(el,"EditBibleLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=MSPrintF("%Z,%s",i,"ST_BIBLE_BOOKS",el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("BF:%Z,%s",i,"ST_BIBLE_BOOKS",el->aux); + } + } + break; + case LK_DEF: + el->num=-1; + if (DoForm(el,"EditDefLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + if (el->num<0) + *link=MSPrintF("DF:%s",el->aux); + else + *link=MSPrintF("DF:%s,%d",el->aux,el->num); + + } + break; + case LK_HELP_INDEX: + if (DoForm(el,"EditManPageLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + result=TRUE; + if (!el->display[0]) + *display=NewStr(el->aux); + else + *display=NewStr(el->display); + *link=MSPrintF("HI:%s",el->aux); + } + break; + } + } + if (el->quote) *quote=TRUE; + Free(el); + return result; +} + +void EditInsertLink() +{ + I1 *display=NULL,*link=NULL,*st=NULL; + BoolU4 quote=FALSE; + I8 type=PopUpLinkType(TRUE); + if (type>=0) { + if (PmtLink(type,&display,&link,"e)) { + if (type==LK_PLACE_ANCHOR) + st=MSPrintF("$$AN,\"%s\",\"%s\"$$",display,link); + else + st=MSPrintF("$$LK,\"%s\",\"%s\"$$",display,link); + } + } + if (st) { + if (quote) + PrintF("%Q",st); + else + PutS(st); + } + Free(display); + Free(link); + Free(st); +} + +I8 PopUpColorType() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Foreground\" LTFT_FOREGROUND_COLOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"Background\" LTFT_BACKGROUND_COLOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"Default Foreground\" LTFT_DEFAULT_FOREGROUND_COLOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"Default Background\" LTFT_DEFAULT_BACKGROUND_COLOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"Link Foreground\" LTFT_LINK_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Link Background\" LTFT_LINK_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Macro Foreground\" LTFT_MACRO_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Macro Background\" LTFT_MACRO_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Anchor Foreground\" LTFT_ANCHOR_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Anchor Background\" LTFT_ANCHOR_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Hidden Foreground\" LTFT_HIDDEN_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Hidden Background\" LTFT_HIDDEN_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Tree Foreground\" LTFT_TREE_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"Tree Background\" LTFT_TREE_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"User Foreground\" LTFT_USER_FOREGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"User Background\" LTFT_USER_BACKGROUND$$\r\n"); + LtfPutSExt(l,"$$MU,\"CANCEL\" -1$$"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + + +I8 PopUpPageSettingType() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Page Length\",LTFT_PAGE_LENGTH$$\r\n"); + LtfPutSExt(l,"$$MU,\"Page Header\",LTFT_HEADER$$\r\n"); + LtfPutSExt(l,"$$MU,\"Page Footer\",LTFT_FOOTER$$\r\n"); + LtfPutSExt(l,"$$MU,\"Left Margin\",LTFT_LEFT_MARGIN$$\r\n"); + LtfPutSExt(l,"$$MU,\"Right Margin\",LTFT_RIGHT_MARGIN$$\r\n"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +void EditInsertColor() +{ + I8 type=PopUpColorType,col=LTF_DEFAULT; + if (type>=0) { + col=PopUpColor; + if (col==LTF_DEFAULT) + PrintF("$$%Z$$",type,"ST_LTF_CMDS"); + else if (col>=0) + PrintF("$$%Z,%d$$",type,"ST_LTF_CMDS",col); + } +} + +class EditPageSettingStruct +{ + I1 value[132] fmtstr "$$DA -P 131 \"Setting Value:%s\"$$\r\n"; +}; + +class EditPageSettingStruct2 +{ + I1 value[132] fmtstr "$$DA -P 131 \"Setting Value:%s\"$$\r\n"; + BoolU4 winrel fmtstr "$$CB \"Win Relative\"$$\r\n"; +}; + + +void EditInsertPageSetting() +{ + I8 type=PopUpPageSettingType; + EditPageSettingStruct *el=MAllocZ(sizeof(EditPageSettingStruct)); + EditPageSettingStruct2 *el2=MAllocZ(sizeof(EditPageSettingStruct2)); + if (type>=0) { + if (type==LTFT_RIGHT_MARGIN) { + if (DoForm(el2,"EditPageSettingStruct2")) { + if (el2->winrel) { + if (*el2->value) + PrintF("$$%Z+WR,%s$$",type,"ST_LTF_CMDS",el2->value); + else + PrintF("$$%Z+WR$$",type,"ST_LTF_CMDS"); + } else { + if (*el2->value) + PrintF("$$%Z,%s$$",type,"ST_LTF_CMDS",el2->value); + else + PrintF("$$%Z$$",type,"ST_LTF_CMDS"); + } + } + } else { + if (DoForm(el,"EditPageSettingStruct")) { + if (*el->value) + PrintF("$$%Z,%s$$",type,"ST_LTF_CMDS",el->value); + else + PrintF("$$%Z$$",type,"ST_LTF_CMDS"); + } + } + } + Free(el2); + Free(el); +} + +I8 PopUpDollarType() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Link\" LTFT_LINK$$\r\n"); + LtfPutSExt(l,"$$MU,\"Text\" LTFT_TEXT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Tree Branch\" LTFT_TREE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Color\" LTFT_FOREGROUND_COLOR$$\r\n"); + LtfPutSExt(l,"$$MU,\"Page Settings\" LTFT_PAGE_LENGTH$$\r\n"); + LtfPutSExt(l,"$$MU,\"Cursor Movement\" LTFT_CURSOR_MOVEMENT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n"); + LtfPutSExt(l,"$$MU,\"Check Box\" LTFT_CHECK_BOX$$\r\n"); + LtfPutSExt(l,"$$MU,\"Macro\" LTFT_MACRO$$\r\n"); + LtfPutSExt(l,"$$MU,\"Menu Value\" LTFT_MENU_VALUE$$\r\n"); + LtfPutSExt(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n"); + LtfPutSExt(l,"$$MU,\"Data\" LTFT_DATA$$\r\n"); + LtfPutSExt(l,"$$MU,\"Hex Edit\" LTFT_HEX_EDIT$$\r\n"); + LtfPutSExt(l,"$$MU,\"Hidden Widget\" LTFT_HIDE_START$$\r\n"); + LtfPutSExt(l,"$$MU,\"Song\" LTFT_SONG$$\r\n"); + LtfPutSExt(l,"$$MU,\"CANCEL\" -1$$"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +class EditDollarTextStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + BoolU4 left_x fmtstr "$$CB,\"Left X\"$$\r\n"; + BoolU4 center_x fmtstr "$$CB,\"Center X\"$$\r\n"; + BoolU4 right_x fmtstr "$$CB,\"Right X\"$$\r\n"; + BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n"; + BoolU4 blink fmtstr "$$CB,\"Blink\"$$\r\n"; + BoolU4 invert fmtstr "$$CB,\"Invert\"$$\r\n"; + BoolU4 underline fmtstr "$$CB,\"Underline\"$$\r\n"; + BoolU4 tree fmtstr "$$CB,\"Tree\"$$\r\n"; + BoolU4 collapsed fmtstr "$$CB,\"Collapsed\"$$\r\n"; + BoolU4 alias fmtstr "$$CB,\"Alias\"$$\r\n"; + I1 scroll_x [132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n"; + I1 shift_x [132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n"; + I1 shift_y [132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n"; +}; + +void EditInsertDollarText() +{ + I1 *st,buf[132]; + EditDollarTextStruct *dt=MAllocZ(sizeof(EditDollarTextStruct)); + if (DoForm(dt,"EditDollarTextStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (dt->left_x ) StrCat(buf,"+LX"); + if (dt->center_x) StrCat(buf,"+CX"); + if (dt->right_x ) StrCat(buf,"+RX"); + if (dt->margin_rel) StrCat(buf,"+MRX"); + if (dt->blink) StrCat(buf,"+BK"); + if (dt->invert) StrCat(buf,"+IV"); + if (dt->underline) StrCat(buf,"+UL"); + if (dt->tree) StrCat(buf,"+TR"); + if (dt->collapsed) StrCat(buf,"+C"); + if (dt->alias) StrCat(buf,"+AL"); + if (*dt->scroll_x) StrCat(buf,"+SCX"); + if (*dt->shift_x) StrCat(buf,"+SX"); + if (*dt->shift_y) StrCat(buf,"+SY"); + st=MSPrintF("%q",dt->display); + PrintF("$$TX%s,\"%Q\"",buf,st); + Free(st); + if (*dt->shift_x) + PrintF(",%s",dt->shift_x); + if (*dt->shift_y) + PrintF(",%s",dt->shift_y); + if (*dt->scroll_x) + PrintF(",%s",dt->scroll_x); + PrintF("$$"); + } + Free(dt); +} + +class EditSongStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I1 song[512] fmtstr "$$DA-P,511,\"Song :%s\"$$\r\n"; +}; + +void EditInsertSong() +{ + EditSongStruct *dt=MAllocZ(sizeof(EditSongStruct)); + if (DoForm(dt,"EditSongStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) + PrintF("$$SO,\"%s\",\"%s\"$$",dt->display,dt->song); + Free(dt); +} + +class EditMacroMenuStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n"; + I1 left_macro[512] fmtstr "$$DA-P,511,\"Left Click Macro :%s\"$$\r\n"; + I1 left_exp[132] fmtstr "$$DA-P,131,\"Left Click Expression :%s\"$$\r\n"; + BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n"; + BoolU4 left_is_auto fmtstr "$$CB,\"Left is AutoStr\"$$\r\n"; + BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n"; + BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n"; + BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n"; + BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n"; + BoolU4 blink fmtstr "$$CB,\"Blink\"$$\r\n"; + BoolU4 invert fmtstr "$$CB,\"Invert\"$$\r\n"; + BoolU4 underline fmtstr "$$CB,\"Underline\"$$\r\n"; + BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n"; + I1 scroll_x[132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n"; + I1 shift_x[132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n"; + I1 shift_y[132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n"; +}; + +void EditInsertMacroMenu(BoolU4 is_macro) +{ + I1 *st,buf[132]; + EditMacroMenuStruct *dt=MAllocZ(sizeof(EditMacroMenuStruct)); + dt->underline=TRUE; + dt->escape=TRUE; + if (DoForm(dt,"EditMacroMenuStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (is_macro && *dt->display) StrCat(buf,"+A "); + if (dt->popup) StrCat(buf,"+PU-X"); + if (dt->left_x ) StrCat(buf,"+LX"); + if (dt->center_x) StrCat(buf,"+CX"); + if (dt->right_x ) StrCat(buf,"+RX"); + if (dt->margin_rel) StrCat(buf,"+MRX"); + if (dt->blink) StrCat(buf,"+BK"); + if (dt->invert) StrCat(buf,"+IV"); + if (!dt->underline) StrCat(buf,"-UL"); + if (!dt->escape) StrCat(buf,"-X"); + if (*dt->scroll_x) StrCat(buf,"+SCX"); + if (*dt->shift_x) StrCat(buf,"+SX"); + if (*dt->shift_y) StrCat(buf,"+SY"); + if (is_macro) { + if (*dt->left_exp) StrCat(buf,"+LE"); + if (!*dt->left_macro) StrCat(buf,"-LM"); + } else { + if (!*dt->left_exp) StrCat(buf,"-LE"); + if (*dt->left_macro) StrCat(buf,"+LM"); + } + if (dt->left_is_auto) StrCat(buf,"+LA"); + if (*dt->display || is_macro) { + if (is_macro) { + if (*dt->display) { + st=MSPrintF("%q",dt->display); + PrintF("$$MA %s,\"%Q\"",buf,st); + Free(st); + } else + PrintF("$$MA %s,",buf); + } else { + st=MSPrintF("%q",dt->display); + PrintF("$$MU %s,\"%Q\"",buf,st); + Free(st); + } + if (*dt->left_exp) + PrintF(",%s",dt->left_exp); + if (*dt->left_macro) { + st=MSPrintF("%q",dt->left_macro); + PrintF(",\"%Q\"",st); + Free(st); + } + if (*dt->shift_x) + PrintF(",%s",dt->shift_x); + if (*dt->shift_y) + PrintF(",%s",dt->shift_y); + if (*dt->scroll_x) + PrintF(",%s",dt->scroll_x); + PutS("$$"); + } + } + Free(dt); +} + +class EditButtonStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n"; + BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n"; + BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n"; + BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n"; + BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n"; + BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n"; + I1 left_macro [132] fmtstr "$$DA-P,131,\"Left Click Macro:%s\"$$\r\n"; + BoolU4 left_is_auto fmtstr "$$CB,\"Left is AutoStr\"$$\r\n"; + I1 left_exp [132] fmtstr "$$DA-P,131,\"Left Click Expression:%s\"$$\r\n"; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; +}; + +void EditInsertButton() +{ + I1 *st,buf[132]; + EditButtonStruct *dt=MAllocZ(sizeof(EditButtonStruct)); + dt->escape=TRUE; + if (DoForm(dt,"EditButtonStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (dt->popup) StrCat(buf,"+PU-X"); + if (dt->left_x ) StrCat(buf,"+LX"); + if (dt->center_x) StrCat(buf,"+CX"); + if (dt->right_x ) StrCat(buf,"+RX"); + if (dt->margin_rel) StrCat(buf,"+MRX"); + if (!dt->escape) StrCat(buf,"-X"); + if (!*dt->left_exp) StrCat(buf,"-LE"); + if (*dt->left_macro) StrCat(buf,"+LM"); + if (dt->left_is_auto) StrCat(buf,"+LA"); + if (dt->display[0]) { + if (dt->quote) { + st=MSPrintF("%q",dt->display); + PrintF("$$$$BT%s,\\\"%Q\\\"",buf,st); + Free(st); + if (*dt->left_exp) + PrintF(",%s",dt->left_exp); + if (*dt->left_macro) { + st=MSPrintF("%q",dt->left_macro); + PrintF(",\\\"%Q\\\"",st); + Free(st); + } + PutS("$$$$"); + } else { + st=MSPrintF("%q",dt->display); + PrintF("$$BT%s,\"%Q\"",buf,st); + Free(st); + if (*dt->left_exp) + PrintF(",%s",dt->left_exp); + if (*dt->left_macro) { + st=MSPrintF("%q",dt->left_macro); + PrintF(",\"%Q\"",st); + Free(st); + } + PutS("$$"); + } + } + } + Free(dt); +} + + +class EditCursorMovementStruct +{ + I1 left_exp[132] fmtstr "$$DA-P,131,\"X Expression:%s\"$$\r\n"; + I1 right_exp[132] fmtstr "$$DA-P,131,\"Y Expression:%s\"$$\r\n"; + BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n"; + BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n"; + BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n"; + BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n"; + BoolU4 top_y fmtstr "$$CB,\"Top Y \"$$\r\n"; + BoolU4 center_y fmtstr "$$CB,\"Center Y \"$$\r\n"; + BoolU4 bottom_y fmtstr "$$CB,\"Bottom Y \"$$\r\n"; + BoolU4 page_rel fmtstr "$$CB,\"Page Rel Y\"$$\r\n"; + BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n"; +}; + +void EditInsertCursorMovement() +{ + I1 buf[132]; + EditCursorMovementStruct *dt=MAllocZ(sizeof(EditCursorMovementStruct)); + if (DoForm(dt,"EditCursorMovementStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (dt->left_x ) StrCat(buf,"+LX"); + if (dt->center_x) StrCat(buf,"+CX"); + if (dt->right_x ) StrCat(buf,"+RX"); + if (dt->margin_rel) StrCat(buf,"+MRX"); + if (dt->top_y ) StrCat(buf,"+TY"); + if (dt->center_y) StrCat(buf,"+CY"); + if (dt->bottom_y) StrCat(buf,"+BY"); + if (dt->page_rel) StrCat(buf,"+PRY"); + if (!*dt->left_exp) StrCat(buf,"-LE"); + if (!*dt->right_exp) StrCat(buf,"-RE"); + if (dt->quote) + PutS("$$"); + PrintF("$$CM%s",buf); + if (*dt->left_exp) + PrintF(",%s",dt->left_exp); + if (*dt->right_exp) + PrintF(",%s",dt->right_exp); + PutS("$$"); + if (dt->quote) + PutS("$$"); + } + Free(dt); +} + +class EditDataStruct +{ + I1 format_str [132] fmtstr "$$DA-P,131,\"Format Str:%s\"$$\r\n"; + U8 len fmtstr "$$DA,256,\"Length:%d\"$$\r\n"; + BoolU4 term fmtstr "$$CB,\"Terminator\"$$\r\n"; + BoolU4 str fmtstr "$$CB,\"Str\"$$\r\n"; + BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n"; +}; + +void EditInsertData() +{ + I1 *st,buf[132]; + EditDataStruct *dt=MAllocZ(sizeof(EditDataStruct)); + dt->term=TRUE; + dt->len=256; + if (DoForm(dt,"EditDataStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (dt->str) StrCat(buf,"-P"); + if (!dt->term) StrCat(buf,"-T"); + if (dt->refresh) StrCat(buf,"+RD"); + st=MSPrintF("%q",dt->format_str); + PrintF("$$$$DA%s,%d,\\\"%Q\\\"$$$$", + buf,dt->len,st); + Free(st); + } + Free(dt); +} + +class EditCheckBoxStruct +{ + I1 label [132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n"; +}; + +void EditInsertCheckBox() +{ + I1 *st,buf[132]; + EditCheckBoxStruct *dt=MAllocZ(sizeof(EditCheckBoxStruct)); + if (DoForm(dt,"EditCheckBoxStruct",CTRL_L_HELP,TRUE)) { + *buf=0; + if (dt->refresh) StrCat(buf,"+RD"); + st=MSPrintF("%q",dt->label); + PrintF("$$$$CB %s,\\\"%Q\\\"$$$$", + buf,st); + Free(st); + } + Free(dt); +} + +class EditHexEditStruct +{ + U8 cnt fmtstr "$$DA,256,\"Count:%d\"$$\r\n"; + U8 cols fmtstr "$$DA,256,\"Columns:%d\"$$\r\n"; + BoolU4 zero fmtstr "$$CB,\"Zero Based\"$$\r\n"; + BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n"; +}; + +void EditInsertHexEdit() +{ + I1 buf[132]; + EditHexEditStruct *dt=MAllocZ(sizeof(EditHexEditStruct)); + dt->cnt=128; + dt->cols=4; + dt->zero=TRUE; + if (DoForm(dt,"EditHexEditStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (!dt->zero) StrCat(buf,"-Z"); + if (dt->refresh) StrCat(buf,"+RD"); + PrintF("$$$$HX %s,%d,%d$$$$", + buf,dt->cnt,dt->cols); + } + Free(dt); +} + +class EditTreeStruct +{ + I1 label[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n"; + I8 indent fmtstr "$$DA,131,\"Indention:%d\"$$\r\n"; + BoolU4 collapsed fmtstr "$$CB,\"Collapsed\"$$\r\n"; +}; + +void EditInsertTree() +{ + I1 *st,*st2,buf[132]; + EditTreeStruct *dt=MAllocZ(sizeof(EditTreeStruct)); + dt->collapsed=TRUE; + dt->indent=2; + if (DoForm(dt,"EditTreeStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) { + *buf=0; + if (!dt->collapsed) StrCat(buf,"-C"); + st=MSPrintF("%q",dt->label); + st2=MSPrintF("$$TR %s,\"%Q\"$$\r\n$$ID,%d$$*\r\n$$ID,%d$$", + buf,st,dt->indent,-dt->indent); + LtfSafeInsert(Fs->cur_ltf,st2); + Free(st); + Free(st2); + } + Free(dt); +} + +void EditInsertHidden() +{ + LtfSafeInsert(Fs->cur_ltf,"$$HS$$*$$HE$$"); +} + +void EditInsertDollarCmd() +{ + I8 type=PopUpDollarType; + switch (type) { + case LTFT_FOREGROUND_COLOR: + EditInsertColor; + break; + case LTFT_PAGE_LENGTH: + EditInsertPageSetting; + break; + case LTFT_LINK: + EditInsertLink; + break; + case LTFT_TEXT: + EditInsertDollarText; + break; + case LTFT_TREE: + EditInsertTree; + break; + case LTFT_MACRO: + EditInsertMacroMenu(TRUE); + break; + case LTFT_MENU_VALUE: + EditInsertMacroMenu(FALSE); + break; + case LTFT_CURSOR_MOVEMENT: + EditInsertCursorMovement; + break; + case LTFT_BUTTON: + EditInsertButton; + break; + case LTFT_DATA: + EditInsertData; + break; + case LTFT_CHECK_BOX: + EditInsertCheckBox; + break; + case LTFT_HEX_EDIT: + EditInsertHexEdit; + break; + case LTFT_HIDE_START: + EditInsertHidden; + break; + case LTFT_SONG: + EditInsertSong; + break; + } +} +I8 PopUpPictureType() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$MU,\"Just Picture\",1$$\r\n"); + LtfPutSExt(l,"$$MU,\"Macro\",2$$\r\n"); + LtfPutSExt(l,"$$MU,\"Menu Item\",3$$\r\n"); + LtfPutSExt(l,"$$MU,\"Link\",4$$\r\n"); + LtfPutSExt(l,"$$MU,\"CANCEL\",-1$$"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +class EditJustPictureStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n"; +}; + +class EditMacroPictureStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n"; + I1 exp[512] fmtstr "$$DA-P,511,\"Macro :%s\"$$\r\n"; + BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n"; + BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n"; + BoolU4 is_auto fmtstr "$$CB,\"AutoStr\"$$\r\n"; +}; + +class EditMenuPictureStruct +{ + I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n"; + I1 exp[512] fmtstr "$$DA-P,511,\"Expression :%s\"$$\r\n"; + BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n"; +}; + +I1 *EditPictureLink() +{ + I1 *result=NULL,*display=NULL,*link=NULL; + BoolU4 quote=FALSE; + I8 type=PopUpLinkType(FALSE); + if (type>=0) { + if (PmtLink(type,&display,&link,"e)) + result=MSPrintF("\"%s\",\"%s\"",display,link); + } + Free(display); + Free(link); + return result; +} + +I1 *EditPicture() +{ + I8 type=PopUpPictureType; + I1 *st,*st1=NULL,*st2=NULL,buf[132]; + EditMacroPictureStruct *dt=MAllocZ(sizeof(EditMacroPictureStruct)); + *buf=0; + switch (type) { + case 1: + if (DoForm(dt,"EditJustPictureStruct",CTRL_L_HELP,TRUE)) + st1=MSPrintF("\"%Q\"",dt->display); + break; + case 2: + dt->escape=TRUE; + if (DoForm(dt,"EditMacroPictureStruct",CTRL_L_HELP,TRUE)) { + StrCat(buf,"+LM+UL"); + if (dt->is_auto) StrCat(buf,"+LA"); + if (dt->popup) StrCat(buf,"+PU"); + if (dt->escape) StrCat(buf,"+X"); + st=MSPrintF("%q",dt->exp); + st1=MSPrintF("\"%Q\",\"%Q\"",dt->display,st); + Free(st); + } + break; + case 3: + dt->escape=TRUE; + if (DoForm(dt,"EditMenuPictureStruct",CTRL_L_HELP,TRUE)) { + StrCat(buf,"+LE"); + if (dt->escape) StrCat(buf,"+X"); + st1=MSPrintF("\"%Q\",\"%Q\"",dt->display,dt->exp); + } + break; + case 4: + StrCat(buf,"+L+A"); + st1=EditPictureLink; + break; + } + if (st1) { + st2=MSPrintF("$$PI%s,%s$$",buf,st1); + Free(st1); + } + Free(dt); + return st2; +} diff --git a/LT/Adam/Ltf/LtfEdit.APZ b/LT/Adam/Ltf/LtfEdit.APZ new file mode 100644 index 0000000..89eb254 --- /dev/null +++ b/LT/Adam/Ltf/LtfEdit.APZ @@ -0,0 +1,1389 @@ +#define EDIT_MENU_NAME "::/LT/Doc/Edit.MUZ" + +public LtfEntry *LtfFindAnchor(Ltf *l,I1 *pattern) +{ + LtfEntry *ll=l->dummy.next; + while (ll!=l) { + if (ll->btype==LTFT_ANCHOR) { + if (!StrCmp(pattern,ll->aux_str)) { + l->cur_entry=ll; + l->cur_data_col=ll->min_col; + return ll; + } + } + ll=ll->next; + } + return NULL; +} + +void EditCursorLeft(Ltf *l,U8 sc) +{ + I1 *dst; + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *cl=l->cur_entry,*original_cl=cl,*nl; + I8 cc=l->cur_data_col,y=cl->y; + if (sc & SCF_CTRL) { + while (cl->last!=l && (cl->last->y==y || + cl->last->flags & LTFLF_SKIP)) + cl=cl->last; //TODO: select? recurse? + cc=cl->min_col; + } else { + if (cc>cl->min_col) { + if (cl->btype==LTFT_TEXT && ccmax_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + dst=cl->display+cc; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + *dst=0; + cl->max_col=cc; + InsQue(nl,cl); + } + cc--; + if (cl->btype==LTFT_TEXT && cc>cl->min_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + dst=cl->display+cc; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + *dst=0; + cl->max_col=cc; + InsQue(nl,cl); + cl=nl; + cc=cl->min_col; + } + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } else { + cc=cl->min_col; + while (cl->last!=l && + (cl->last->btype==LTFT_SOFT_CR || cl->last->btype==LTFT_INDENT || + cl->last->flags & LTFLF_SKIP)) { + cl=cl->last; + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } + if (cl->last!=l) { + cl=cl->last; + if (cl->max_col>cl->min_col) { + cc=cl->max_col-1; + if (cl->btype==LTFT_TEXT && cc>cl->min_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + dst=cl->display+cc; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + *dst=0; + cl->max_col=cc; + InsQue(nl,cl); + cl=nl; + cc=cl->min_col; + } + } else + cc=cl->max_col; + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } + } + } + l->cur_data_col=cc; + l->cur_entry=cl; + if (cl!=original_cl) + LtfFormBackward(l); + l->recalc_start=l->cur_entry->last; + Preempt(old_preempt); +} + +void EditCursorRight(Ltf *l,U8 sc) +{ + BoolU4 old_preempt=Preempt(OFF); + I1 *dst; + LtfEntry *cl=l->cur_entry,*original_cl=cl,*nl; + I8 cc=l->cur_data_col,y=cl->y,old_flags,old_color; + l->recalc_start=cl->last; + if (sc & SCF_CTRL) { + while (cl!=l && ((cl->next->y==y && + cl->next->btype!=LTFT_SOFT_CR) || + cl->flags & LTFLF_SKIP)) + cl=cl->next; + if (cl->max_col>cl->min_col) + cc=cl->max_col-1; + else + cc=cl->min_col; + } else { + if (ccmax_col) { + if (cl->btype==LTFT_TEXT && cc>cl->min_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + dst=cl->display+cc; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + *dst=0; + cl->max_col=cc; + InsQue(nl,cl); + cl=nl; + cc=cl->min_col; + } + cc++; + old_flags=cl->flags; + old_color=cl->type; + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + if (cl->btype==LTFT_TEXT && ccmax_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | old_color & -0x100; + nl->flags=old_flags; + dst=cl->display+cc; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + cl->max_col=cc; + *dst=0; + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + InsQue(nl,cl); + cl=nl; + cc=cl->min_col; + } else if (cc>=cl->max_col) { + cl=cl->next; + cc=cl->min_col; + } + } else { + if (cl!=l) { + if (cc<=cl->min_col) { + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } + cl=cl->next; + while (cl!=l && cl->flags & LTFLF_SKIP) { + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + cl=cl->next; + } + cc=cl->min_col; + if (cl->btype==LTFT_SOFT_CR) { + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + cl=cl->next; + cc=cl->min_col; + } + } + } + } + l->cur_data_col=cc; + l->cur_entry=cl; + if (cl!=original_cl) + LtfFormForward(l); + Preempt(old_preempt); +} + +void EditLineUp(Ltf *l,U8 sc) +{ + BoolU4 old_preempt=Preempt(OFF); + I1 *dst; + I8 y,x; + LtfEntry *cl=l->cur_entry,*nl; + + if (cl->btype==LTFT_HEX_EDIT) { + l->cur_data_col=l->cur_data_col-cl->hex_edit_width*3; + if (l->cur_data_col>=0) + return; + else + l->cur_data_col=0; + } + x=l->x; y=l->y; + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + dst=cl->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->y=cl->y; + nl->x=cl->x+l->cur_data_col; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + *dst=0; + cl->max_col=l->cur_data_col; + InsQue(nl,cl); + } else + if (l->cur_data_col==cl->min_col && cl->last!=l) + cl=cl->last; + } else + if (cl->last!=l) + cl=cl->last; + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + l->cur_entry=cl; + LtfFormBackward(l); + cl=l->cur_entry; + while (cl->last!=l && (cl->y>=y || cl->flags & LTFLF_SKIP)) { + cl=cl->last; + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } + y=cl->y; + l->y=y; + while (cl!=l && (cl->y>=y && cl->x>=x || cl->flags & LTFLF_SKIP)) { + if ((sc & SCF_SHIFT)) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + cl=cl->last; + } + + if (cl==l || cl->ynext; + else { + if (cl->btype!=LTFT_TEXT) { + if (sc & SCF_SHIFT) + cl->type|=LTFLT_SELECTED; + else + cl->type&=~LTFLT_SELECTED; + } else { + if (cl->next->x==x) { + cl=cl->next; + if (l->flags & LTFF_FORM) { + while (!Bt(ltf_form_types,cl->btype) && cl->next->x==x) + cl=cl->next; + } + } + } + } + if (Bt(ltf_display_types,cl->btype)) { + l->cur_data_col=(x-cl->x); + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_col>cl->max_col) + l->cur_data_col=cl->max_col; + } else { + if (l->cur_data_col>=cl->max_col) + l->cur_data_col=cl->max_col-1; + } + if (l->cur_data_colmin_col) + l->cur_data_col=cl->min_col; + } else + l->cur_data_col=cl->min_col; + if (cl->btype==LTFT_TEXT && cl->xcur_data_colmax_col-1) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + if ((sc & SCF_SHIFT)) + nl->type=cl->type | LTFLT_SELECTED; + else + nl->type=cl->type & ~LTFLT_SELECTED; + dst=cl->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + nl->y=cl->y; + nl->x=cl->x+l->cur_data_col; + *dst=0; + cl->max_col=l->cur_data_col; + InsQue(nl,cl); + cl=nl; + l->cur_data_col=cl->min_col; + } + } + l->cur_entry=cl; + l->x=cl->x+l->cur_data_col; + LtfFormForward(l); + l->recalc_start=l->cur_entry->last; + Preempt(old_preempt); +} + +void EditLineDown(Ltf *l,U8 sc) +{ + BoolU4 old_preempt=Preempt(OFF); + I1 *dst; + I8 y,x,old_flags=0,old_color; + LtfEntry *cl=l->cur_entry,*nl,*cl2; + if (cl->btype==LTFT_HEX_EDIT) { + l->cur_data_col=l->cur_data_col+cl->hex_edit_width*3; + if (l->cur_data_col/3>=cl->len) { + if (cl->next!=l) + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + } + return; + } + l->recalc_start=cl->last; + x=l->x; y=l->y; + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=cl->type; + nl->flags=cl->flags; + if ((sc & SCF_SHIFT)) + nl->type=cl->type | LTFLT_SELECTED; + else + nl->type=cl->type & ~LTFLT_SELECTED; + dst=cl->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + nl->y=cl->y; + nl->x=cl->x+l->cur_data_col; + *dst=0; + cl->max_col=l->cur_data_col; + InsQue(nl,cl); + cl=nl; + l->cur_data_col=cl->min_col; + } + } + cl2=cl; + while (cl!=l && (cl->y<=y || cl->flags & LTFLF_SKIP)) + cl=cl->next; + y=cl->y; + l->y=y; + while (cl!=l && (cl->y<=y && cl->x<=x || cl->flags & LTFLF_SKIP)) { + old_flags=cl->flags; + old_color=cl->type; + cl=cl->next; + } + if (cl->last!=l && (cl->x>x || cl->y>y)) { + cl=cl->last; + l->cur_entry=cl; + if (cl->btype!=LTFT_CR && + cl->btype!=LTFT_SOFT_CR) + LtfFormBackward(l); + cl=l->cur_entry; + } + while (cl2!=l && (cl2!=cl || cl->btype==LTFT_TEXT)) { + if (cl2->yxflags & LTFLF_SKIP || + cl2->x==x && !cl2->max_col && + Bt(ltf_nondisplay_invisible_types,cl2->btype)) { + if (sc & SCF_SHIFT) + cl2->type|=LTFLT_SELECTED; + else + cl2->type&=~LTFLT_SELECTED; + } + if (cl2==cl) break; + cl2=cl2->next; + } + if (Bt(ltf_display_types,cl->btype)) { + l->cur_data_col=(x-cl->x); + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_col>cl->max_col) + l->cur_data_col=cl->max_col; + } else { + if (l->cur_data_col>=cl->max_col) + l->cur_data_col=cl->max_col-1; + } + if (l->cur_data_colmin_col) + l->cur_data_col=cl->min_col; + } else + l->cur_data_col=cl->min_col; + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_col>cl->min_col && l->cur_data_colmax_col-1) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | old_color & -0x100; + nl->flags=old_flags; + dst=cl->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + *dst=0; + cl->max_col=l->cur_data_col; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + nl->x=cl->x+l->cur_data_col; + InsQue(nl,cl); + cl=nl; + l->cur_data_col=cl->min_col; + } + } + l->cur_entry=cl; + l->x=cl->x+l->cur_data_col; + LtfFormForward(l); + Preempt(old_preempt); +} + +void EditDelChar(Ltf *l) +{ + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *cl=l->cur_entry; + + if (cl==l) { + Preempt(old_preempt); + return; + } else + l->recalc_start=cl->last; + if (cl->max_col!=0 && (cl->btype==LTFT_TEXT || cl->btype==LTFT_DATA)) { + if (cl->btype==LTFT_DATA) { + if (cl->flags & LTFLF_HAS_TERMINATOR && l->cur_data_col==cl->max_col-1) { + Preempt(old_preempt); + return; + } + } + if (l->cur_data_colmax_col) + StrCpy(cl->display+l->cur_data_col,cl->display+l->cur_data_col+1); + if (l->cur_data_col>=cl->max_col-1) { + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + } + LtfRemoveSoftCRs(l,l->cur_entry); + Preempt(old_preempt); + return; + } + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + LtfDelEntry(l,cl); + LtfRemoveSoftCRs(l,l->cur_entry); + Preempt(old_preempt); +} + +void CheckDollarBufSize(Ltf *l) +{ + U1 *b; + if (l->dollar_buf_ptr>=l->dollar_buf_size-2) { + l->dollar_buf_size<<=1; + b=MAlloc(l->dollar_buf_size,l->mem_tss); + MemCpy(b,l->dollar_buf,l->dollar_buf_ptr); + Free(l->dollar_buf,l->mem_tss); + l->dollar_buf=b; + } +} + + +void EditInsertChar(I8 ch,U8 sc,Ltf *l,BoolU4 old_preempt) +{ + BoolU4 old_preempt2=Preempt(OFF); + I1 *b,*src,*dst; + LtfEntry *cl=l->cur_entry,*nl; + I8 i,j,m,x=cl->x,y=cl->y; + + l->recalc_start=cl->last; + while (l->recalc_start!=l && l->recalc_start->flags<FLF_SKIP) + l->recalc_start=l->recalc_start->last; + + if (l->flags & LTFF_IN_DOLLAR) { + if (!Bt(printable_chars_bitmap,ch)) + goto done; + CheckDollarBufSize(l); + l->dollar_buf[l->dollar_buf_ptr++]=ch; + if (ch!='$$') { + goto done; + } else { + l->dollar_buf[l->dollar_buf_ptr]=0; + LtfPutSExt(l,l->dollar_buf); + l->flags&=~LTFF_IN_DOLLAR; + l->dollar_buf_ptr=0; + goto done; + } + } else { + if (ch=='$$') { + if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) { + l->flags|=LTFF_IN_DOLLAR; + l->dollar_buf_ptr=0; + l->dollar_buf[l->dollar_buf_ptr++]=ch; + goto done; + } + } + } + + if (ch==CH_SPACE || ch==CH_CR) { + if (!(sc & SCF_CTRL) && !(sc & SCF_SHIFT)) { + if (cl->btype>=LTFT_BUTTON && cl->btype<=LTFT_MENU_VALUE || + cl->btype==LTFT_HIDE_START || + cl->flags & (LTFLF_LINK | LTFLF_TREE | + LTFLF_LEFT_MACRO|LTFLF_LEFT_EXP|LTFLF_LEFT_CB|LTFLF_LEFT_AUTO | + LTFLF_RIGHT_MACRO|LTFLF_RIGHT_EXP|LTFLF_RIGHT_CB|LTFLF_RIGHT_AUTO)) { + l->cmd_I1=ch; + LtfRunEntry(l,cl,FALSE,old_preempt); + goto done; + } + } + } + if (cl->btype==LTFT_HEX_EDIT) { + if (cl->flags & LTFLF_DATA_IS_PTR) + b=cl->data; + else + b=&cl->data; + i=l->cur_data_col; + j=i%(cl->hex_edit_width*3); + m=i/(cl->hex_edit_width*3)*cl->hex_edit_width; + if (j>=cl->hex_edit_width<<1) + b[j-cl->hex_edit_width<<1+m]=ch; + else { + ch=ToUpper(ch)-'0'; + if (ch>9) ch=ch+'0'-'A'+10; + if (ch>15) goto done; + m=j>>1+m; + if (j & 1) + b[m]=b[m] & 0xF0| ch; + else + b[m]=b[m] & 0xF | ch<<4; + } + l->cur_data_col++; + goto done; + } + if (cl->btype==LTFT_DATA && cl->flags & LTFLF_REFRESH_DATA) + goto done; + if (l->flags & LTFF_OVERSTRIKE) { + if (ch==13) { + while (l->cur_entry->next!=l && l->cur_entry->y==y) + l->cur_entry=l->cur_entry->next; + l->cur_data_col=l->cur_entry->min_col; + } else { + if (Bt(displayable_chars_bitmap,ch)) { +overstrike_char: + if (cl->btype==LTFT_TEXT) { + if (l->cur_data_colmax_col) { + if (cl->display[l->cur_data_col]) { + cl->display[l->cur_data_col++]=ch; + goto done; + } + } else { + cl=cl->next; + l->cur_entry=cl; + l->cur_data_col=cl->min_col; + goto overstrike_char; + } + + } else if (cl->btype==LTFT_DATA) { + if (cl->flags & LTFLF_HAS_TERMINATOR) { + if (cl->display[l->cur_data_col] && + l->cur_data_colmin_col+cl->len) { + cl->display[l->cur_data_col++]=ch; + if ( !(cl->display[l->cur_data_col])) { + cl->display[l->cur_data_col]='_'; + cl->display[l->cur_data_col+1]=0; + } + } + } else { + if (cl->display[l->cur_data_col]) + cl->display[l->cur_data_col++]=ch; + } + goto done; + } + b=MAlloc(2,l->mem_tss); + b[0]=ch; + b[1]=0; + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | l->text_attribute << 8; + nl->display=b; + nl->max_col=1; + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + InsQue(nl,cl->last); + } + } + goto done; + } + if (ch==CH_CR || ch==CH_TAB) { + nl=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + if (ch==CH_CR) { + if (sc & SCF_CTRL && !(sc & SCF_SHIFT)) + nl->type=LTFT_PAGE_BREAK | l->text_attribute << 8; + else + nl->type=LTFT_CR | l->text_attribute << 8; + } else + nl->type=LTFT_TAB | l->text_attribute << 8; + LtfInsert(l,nl); + } else { + if (ch>=CH_SHIFT_SPACE && ch<=0x7E) { + if (cl->btype==LTFT_DATA) { + i=cl->len+cl->min_col; + if (cl->flags & LTFLF_HAS_TERMINATOR) + i++; + if (i>cl->max_col) { + b=cl->display; + cl->max_col++; + for (i=cl->max_col;i>l->cur_data_col;i--) + b[i]=b[i-1]; + b[l->cur_data_col++]=ch; + } + } else if (cl->btype==LTFT_TEXT) { + b=MAlloc(cl->max_col+2,l->mem_tss); + dst=b; + src=cl->display; + i=l->cur_data_col; + while (i-->0) + *dst++=*src++; + *dst++=ch; + while (*dst++=*src++); + Free(cl->display,l->mem_tss); + cl->display=b; + cl->max_col++; + l->cur_data_col++; + } else { + b=MAlloc(2,l->mem_tss); + b[0]=ch; + b[1]=0; + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | l->text_attribute << 8; + nl->display=b; + nl->max_col=1; + nl->x=cl->x+1; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + InsQue(nl,cl->last); + } + } + } +done: + LtfRemoveSoftCRs(l,l->cur_entry); + Preempt(old_preempt2); +} + +void EditDelLine(Ltf *l) +{ + LtfEntry *cl=l->cur_entry,*cl2; + I8 y; + y=l->y; + while (cl!=l && cl->y==y) + cl=cl->next; + l->cur_entry=cl; + l->cur_data_col=cl->min_col; + cl=cl->last; + while (cl!=l && cl->y==y) { + cl2=cl->last; + LtfDelEntry(l,cl); + cl=cl2; + } + if (cl==l) + l->recalc_start=cl; + else + l->recalc_start=cl->last; +} + +public void EditFindNext(Ltf *l) +{ + I1 *ptr; + LtfEntry *ll,*cl=l->cur_entry; + U8 ss_flags; + if (l->find_replace->match_case) + ss_flags=0; + else + ss_flags=SS_IGNORE_CASE; + if (l->find_replace->whole_labels) + ss_flags|=SS_WHOLE_LABELS; + + ll=(l->find_replace->scan_forward)?cl->next:cl->last; + while (ll!=cl) { + if (ll!=l) { + if (Bt(ltf_display_types,ll->btype)) { + if ((ll->type & LTFLT_SELECTED) || !l->find_replace->scan_selected_text) { + if (ptr=SearchStr(ll->display,l->find_replace->find_text,ss_flags)) { + l->cur_entry=ll; + l->cur_data_col=ptr-ll->display; + if (l->cur_data_colmin_col) + l->cur_data_col=ll->min_col; + if (l->cur_data_col>ll->max_col) + l->cur_data_col=ll->max_col; + LtfCenter(l); + return; + } + } + } + } + ll=(l->find_replace->scan_forward) ?ll->next:ll->last; + } +} + + +void EditReplace(Ltf *l) +{ + BoolU4 first=TRUE,old_preempt; + I8 cmd=0,i,j,plen,rlen,dlen; + I1 *src,*dst,*dst2; + LtfEntry *cl=l->cur_entry,*ll; + U8 ss_flags; + if (DoForm(l->find_replace,"EditFindTextStruct")) { + if (l->find_replace->match_case) + ss_flags=0; + else + ss_flags=SS_IGNORE_CASE; + if (l->find_replace->whole_labels) + ss_flags|=SS_WHOLE_LABELS; + if (!(l->find_replace->replace)) { + EditFindNext(l); + return; + } + plen=StrLen(l->find_replace->find_text); + if (!plen) return; + rlen=StrLen(l->find_replace->replace_text); + ll=cl; + while ((ll!=cl || first) && cmd!=3) { + first=FALSE; + if (ll->btype==LTFT_TEXT && + ((ll->type & LTFLT_SELECTED) || !l->find_replace->scan_selected_text)) { + src=ll->display; + while (src && cmd!=3) { + src=SearchStr(src,l->find_replace->find_text,ss_flags); + if (src) { + l->cur_data_col=src-ll->display; + l->cur_entry=ll; + l->recalc_start=l; + if (cmd!=2) + LtfCenter(l); + ll=l->cur_entry; + src=l->cur_data_col+ll->display; + if (cmd!=2) { + cmd=PopUpReplaceSkipAllCancel(""); + if (cmd==2) + old_preempt=Preempt(OFF); + } + if (cmd==0 || cmd==2) { + dlen=StrLen(ll->display); + dst=MAlloc(dlen+1+rlen-plen,l->mem_tss); + dst2=dst; + j=src-ll->display; + for (i=0;idisplay[i]; + for (i=0;ifind_replace->replace_text[i]; + src=dst; + for (i=j+plen;i<=dlen;i++) + *dst++=ll->display[i]; + Free(ll->display,l->mem_tss); + ll->display=dst2; + l->cur_data_col=src-ll->display; + l->cur_entry=ll; + if (cmd!=2) { + l->recalc_start=l; + LtfRemoveSoftCRs(l,l->cur_entry); + LtfRecalc(l); + } + ll=l->cur_entry; + src=l->cur_data_col+ll->display; + } else + src++; + } + } + } + if (l->find_replace->scan_forward) { + ll=ll->next; + if (ll==l) { + if (cl==l) break; + ll=ll->next; + } + } else { + ll=ll->last; + if (ll==l) { + if (cl==l) break; + ll=ll->last; + } + } + } + } + if (cmd==2) { + l->recalc_start=l; + LtfRemoveSoftCRs(l,NULL); + LtfRecalc(l); + Preempt(old_preempt); + } +} + +public void LtfGotoLineNum(Ltf *l,I8 linenum) //one based +{ + l->x=0; + l->y=linenum-1; + LtfUpdateWinJoin(l,FALSE,FALSE,FALSE,TRUE,OFF); + LtfCenter(l); +} + +class EditGoToLineStruct +{ + I8 line fmtstr "$$DA,256,\"Go to Line:%d\"$$"; +}; + +public void EditGoToLine(Ltf *l) +{ + EditGoToLineStruct gtl; + gtl.line=1; + if (DoForm(>l,"EditGoToLineStruct")) + LtfGotoLineNum(l,gtl.line); +} + +void LtfToggleFlags(Ltf *l,I8 tog_flags) +{ + U8 size; + I1 *st=LtfSave(l,&size); + BoolU4 old_preempt=Preempt(OFF); + U8 flags=l->flags ^ tog_flags; + Ltf *menu=l->menu_ltf; + LtfUndo *u_next,*u_last; + + u_next=l->undo_root.next; + u_last=l->undo_root.last; + l->undo_root.next=&l->undo_root; + l->undo_root.last=&l->undo_root; + + LtfReset(l,TRUE); + l->menu_ltf=menu; + l->undo_root.next=u_next; + l->undo_root.last=u_last; + LtfSetUndoCnt(l); + l->flags=flags & ~(LTFF_WORD_WRAP|LTFF_INVERTED|LTFF_UNDERLINED|LTFF_BLINK); + LtfLoad(l,st,size); + LtfCenter(l); + Preempt(old_preempt); + Free(st); +} + +I1 *FavoritesFileName() +{ + return MSPrintF("::/LT/Accts/%s/Favor.MUZ", + Fs->account->name); +} + +public void DoFavorites() +{ + I1 *name=FavoritesFileName; + Edit(name); + Free(name); +} + +#help_index "Ltf/Output" +public void LtfPutKeyExt(Ltf *l,I8 ch,U8 sc,BoolU4 old_preempt2) +{ + I8 i,x,y; + U8 sc2; + LtfEntry *cl; + I1 *st; + BoolU4 old_preempt=Preempt(OFF); + + if (!Bt(ltf_clean_scancodes,sc.u1[0])) + l->flags|=LTFF_UNDO_DIRTY; + LtfCaptureUndo(l); + if (Bt(printable_chars_bitmap,ch) && + !(sc&(SCF_CTRL|SCF_ALT))) + EditInsertChar(ch,sc,l,old_preempt2); + else { + cl=l->cur_entry; + x=l->x; y=l->y; + sc2=sc.u1[0]; + if (ch>0 && ch<32) { + switch (ch) { + case CH_CTRLA: + LtfWrite(l,TRUE); + break; + case CH_CTRLB: + if (Bt(&l->win_tss->crt_flags,CRTf_NO_BORDER)) + WinBorder(ON,l->win_tss); + else + WinBorder(OFF,l->win_tss); + break; + case CH_CTRLD: + FileManager; + break; + case CH_CTRLF: + if (sc & SCF_SHIFT) + DoFavorites; + else + EditReplace(l); + break; + case CH_CTRLG: + EditGoToLine(l); + break; + case CH_BACKSPACE: //ctrl H + if (sc&SCF_ALT && !(sc&SCF_CTRL)) + LtfRestoreUndo(l); + else { + LtfCaptureUndo(l); + if (l->cur_data_col<=l->cur_entry->min_col) { + l->cur_entry=l->cur_entry->last; + if (l->cur_entry!=l && l->cur_entry->btype==LTFT_SOFT_CR) + l->cur_entry=l->cur_entry->last; + if (l->cur_entry==l || + (l->cur_entry->btype==LTFT_USER_FOREGROUND || + l->cur_entry->btype==LTFT_USER_BACKGROUND)) { + l->cur_entry=l->cur_entry->next; + l->cur_data_col=l->cur_entry->min_col; + } else { + l->cur_data_col=l->cur_entry->max_col; + if (l->cur_data_col>l->cur_entry->min_col) + l->cur_data_col--; + EditDelChar(l); + } + } else { + l->cur_data_col--; + EditDelChar(l); + } + } + break; + case CH_CTRLK: + if (sc & SCF_SHIFT) + LtfPutSExt(l,"$$BK,0$$"); + else + LtfPutSExt(l,"$$BK,1$$"); + break; + case CH_CTRLL: + EditInsertDollarCmd; + break; + case CH_CR: //ctrl M + EditInsertChar(ch,sc,l,old_preempt2); + break; + case CH_CTRLN: + if (sc & SCF_SHIFT) + LtfPutSExt(l,"$$ID,-2$$"); + else + LtfPutSExt(l,"$$ID,2$$"); + break; + case CH_CTRLO: + LtfToggleFlags(l,LTFF_NO_PICWORDS); + break; + case CH_CTRLP: + if (l->flags & (LTFF_SUPERSCRIPT_MODE | LTFF_SUBSCRIPT_MODE)) { + LtfPutSExt(l,"$$SY,0$$"); + l->flags&=~(LTFF_SUPERSCRIPT_MODE | LTFF_SUBSCRIPT_MODE); + } else if (sc & SCF_SHIFT) { + LtfPutSExt(l,"$$SY,3$$"); + l->flags|=LTFF_SUBSCRIPT_MODE; + } else { + LtfPutSExt(l,"$$SY,-3$$"); + l->flags|=LTFF_SUPERSCRIPT_MODE; + } + break; + case CH_CTRLR: + if (!(l->flags&(LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) { + if (cl->btype==LTFT_PICTURE|| + cl->btype==LTFT_PICWORD|| + cl->btype==LTFT_TOP_LEFT_TOOLBAR|| + cl->btype==LTFT_TOP_RIGHT_TOOLBAR) + EditExistingGraphic(l, + ((cl->x-l->line_start_col)+cl->max_col)*FONT_WIDTH, + (cl->y-l->cur_top_line_num)*FONT_HEIGHT); + else + EditInsertGraphic(l, + (cl->x+l->cur_data_col-l->line_start_col)*FONT_WIDTH, + (cl->y-l->cur_top_line_num)*FONT_HEIGHT); + } + break; + case CH_CTRLS: + LtfWrite(l); + break; + case CH_CTRLT: + LtfToggleFlags(l,LTFF_PLAIN_TEXT); + break; + case CH_CTRLU: + if (sc & SCF_SHIFT) + LtfPutSExt(l,"$$UL,0$$"); + else + LtfPutSExt(l,"$$UL,1$$"); + break; + case CH_CTRLW: + if (sc & SCF_SHIFT) + LtfPutSExt(l,"$$WW,0$$"); + else + LtfPutSExt(l,"$$WW,1$$"); + break; + case CH_CTRLY: + EditDelLine(l); + break; + case CH_CTRLZ: + if (sc & SCF_SHIFT) + LtfPutSExt(l,"$$IV,0$$"); + else + LtfPutSExt(l,"$$IV,1$$"); + break; + } + } else if (sc2>=SC_F1 && sc2<=SC_F10) { + if (!(sc & SCF_ALT)) { + if (sc & SCF_CTRL) { + if (WordStat) { + if (sc & SCF_SHIFT) + WsMan(sc2-SC_F1+1,Fs); + else + WsFillin(sc2-SC_F1+1); + } + } else { + switch (sc2) { + case SC_F2: + if (sc & SCF_SHIFT) + EditInsertCapturedMacro; + else + EditMacroUtil; + break; + case SC_F3: + l->find_replace->scan_forward=!(sc & SCF_SHIFT); + EditFindNext(l); + break; + case SC_F4: + if (sc & SCF_SHIFT) + st=PopUpPickDir; + else + st=PopUpPickFile; + if (st) { + LtfPrintF(l,"%s",st); + Free(st); + } + break; + case SC_F5: + if (IsDbgTsk) { + if (sc & SCF_SHIFT) + IDEStep(l); + else + IDEGo; + } + break; + case SC_F8: + if (IsDbgTsk) { + if (sc & SCF_SHIFT) + IDESetLineNum(l); + } + break; + case SC_F9: + if (IsDbgTsk) { + if (sc & SCF_SHIFT) + IDEClearAllBpts(l); + else + IDEToggleBpt(l); + } + break; + } + } + } + } else if (ch>='0' && ch<='9') { + if (!(sc & SCF_ALT)) { + if (sc & SCF_CTRL) { + if (WordStat) { + if (sc & SCF_SHIFT) + WsdDef(ch-'0',Fs); + else + WsdFillin(ch-'0'); + } + } + } + } else if (sc2==SC_GUI) { + if (l->menu_ltf) + DoMenu(l->menu_ltf); + } else if (sc2==SC_CURSOR_DOWN||sc2==SC_END) { + if (sc2==SC_END || sc & SCF_CTRL) { + while (l->cur_entry!=l) { + if ((sc & SCF_SHIFT)) + l->cur_entry->type|=LTFLT_SELECTED; + else + l->cur_entry->type&=~LTFLT_SELECTED; + l->cur_entry=l->cur_entry->next; + } + l->cur_data_col=l->cur_entry->min_col; + l->recalc_start=l; + } else + EditLineDown(l,sc); + } else if (sc2==SC_CURSOR_UP||sc2==SC_HOME) { + if (sc2==SC_HOME || sc & SCF_CTRL) { + while (l->cur_entry!=l) { + if ((sc & SCF_SHIFT)) + l->cur_entry->type|=LTFLT_SELECTED; + else + l->cur_entry->type&=~LTFLT_SELECTED; + l->cur_entry=l->cur_entry->last; + } + l->cur_entry=l->dummy.next; + l->cur_data_col=l->cur_entry->min_col; + l->recalc_start=l; + } else + EditLineUp(l,sc); + } else if (sc2==SC_PAGE_DOWN) { + for (i=l->win_tss->win_top;iwin_tss->win_bottom;i++) + EditLineDown(l,sc); + } else if (sc2==SC_PAGE_UP) { + for (i=l->win_tss->win_top;iwin_tss->win_bottom;i++) + EditLineUp(l,sc); + } else if (sc2==SC_CURSOR_LEFT) + EditCursorLeft(l,sc); + else if (sc2==SC_CURSOR_RIGHT) + EditCursorRight(l,sc); + else if (sc2==SC_DELETE) { + if ((sc & SCF_SHIFT)) + EditCutToClipboard(l); + else + EditDelChar(l); + } else if (sc2==SC_INSERT) { + if (sc & SCF_SHIFT) + EditInsertLtf(l,sys_clipboard_ltf); + else if (sc & SCF_CTRL) + EditCopyToClipboard(l); + else + l->flags^=LTFF_OVERSTRIKE; + } else if (sc2==SC_PRTSCRN2) + Lpt1PrintLtf(l); + } + if (!l->recalc_start) + l->recalc_start=l->cur_entry->last; + Preempt(old_preempt); + if (l==Fs->cur_ltf && old_preempt2 && + !(l->flags<FF_DONT_SWAP_OUT)) { + i=GetTimeStamp; + if (i>l->swap_out_time) { + l->swap_out_time=i+time_stamp_kHz_freq; + SwapInNext; + } + } +} + +public BoolU4 LtfPutKey(I8 ch,U8 scancode) +{ + Ltf *l; + BoolU4 old_preempt=Preempt(OFF); + if (l=Fs->aux_ltf) { + if (!l->best_d) { + LtfPutKeyExt(l,ch,scancode,old_preempt); + goto next; + } + } + if (l=Fs->cur_ltf) + LtfPutKeyExt(l,ch,scancode,old_preempt); +next: + Preempt(old_preempt); + return FALSE; +} + +public void LtfPutSPartial(Ltf *l,I1 *st,BoolU4 old_preempt2) +{ + U1 ch; + I1 *b,*src,*dst,*ptr=st,*ptr2; + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *cl,*nl; + I8 i,j; + if (!st) { + Preempt(old_preempt); + return; + } + while (ch=*ptr) { + if (!Bt(displayable_chars_bitmap,ch) || ch=='$$' || + l->flags & (LTFF_OVERSTRIKE | LTFF_IN_DOLLAR)) { + LtfPutKeyExt(l,ch,0,old_preempt2); + ptr++; + } else { + ptr2=ptr++; + while (TRUE) { + ch=*ptr++; + if (!Bt(displayable_chars_bitmap,ch) || ch=='$$') + break; + } + ptr--; + *ptr=0; + cl=l->cur_entry; + l->recalc_start=cl->last; + if (cl->btype==LTFT_TEXT) { + j=StrLen(ptr2); + b=MAlloc(cl->max_col+j+1,l->mem_tss); + dst=b; + src=cl->display; + i=l->cur_data_col; + l->cur_data_col=i+j; + cl->max_col+=j; + while (i-->0) + *dst++=*src++; + while (j-->0) + *dst++=*ptr2++; + while (*dst++=*src++); + Free(cl->display,l->mem_tss); + cl->display=b; + } else { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | l->text_attribute << 8; + nl->display=NewStr(ptr2,l->mem_tss); + nl->x=cl->x; + nl->y=cl->y; + nl->max_col=StrLen(ptr2); + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + InsQue(nl,cl->last); + l->cur_entry=nl; + l->cur_data_col=StrLen(ptr2); + } + *ptr=ch; + LtfRemoveSoftCRs(l,l->cur_entry); + } + } + Preempt(old_preempt); + if (l==Fs->cur_ltf && old_preempt2 && + !(l->flags<FF_DONT_SWAP_OUT)) { + i=GetTimeStamp; + if (i>l->swap_out_time) { + l->swap_out_time=i+time_stamp_kHz_freq; + SwapInNext; + } + } +} + +#help_index "Ltf" +public BoolU4 LtfEditFile(I8 type,I1 *filename, + I1 *pattern=NULL,I8 num=1) +{ + I1 *ptr; + I8 i,j,flags=0; + LtfEntry *ll; + Ltf *l,*m; + BoolU4 old_silent=Bt(&Fs->crt_flags,CRTf_SILENT), + old_preempt,result=FALSE; + + try { + switch (type) { + case LK_PLAIN: + type=LK_FILE; + flags=LTFF_PLAIN_TEXT; + break; + case LK_PLAIN_FIND: + type=LK_FILE_FIND; + flags=LTFF_PLAIN_TEXT; + break; + case LK_PLAIN_LINE: + type=LK_FILE_LINE; + flags=LTFF_PLAIN_TEXT; + break; + case LK_BIBLE_FIND: + flags=LTFF_PLAIN_TEXT; + break; + } + + flags|=LTFF_ALLOW_UNDO; + + if (!*filename) + l=Fs->cur_ltf; + else { + Silent(ON); + result=FindFile(filename,NULL,FALSE,TRUE); + l=LtfRead(filename,flags); + Silent(old_silent); + l->flags|=LTFF_ATTR_BY_FILENAME; + m=LtfRead(EDIT_MENU_NAME); + m->text_attribute=(WHITE<<4)+LTBLUE; + l->menu_ltf=m; + } + + switch (type) { + case LK_FILE_LINE: + l->y=num-1; + l->x=0; + LtfUpdateWinJoin(l,FALSE,FALSE,FALSE,TRUE,OFF); + break; + case LK_FILE_ANCHOR: + if (!(ll=LtfFindAnchor(l,pattern))) + result=FALSE; + break; + case LK_FILE_FIND: + result=FALSE; + i=num; + ll=l->dummy.next; + while (ll!=l) { + if (Bt(ltf_display_types,ll->btype)) { + if (ptr=StrIStr(ll->display,pattern)) { + j=ptr-ll->display; + i--; + if (i==0) { + l->cur_entry=ll; + if (jmin_col) j=ll->min_col; + if (j>ll->max_col) j=ll->max_col; + l->cur_data_col=j; + result=TRUE; + break; + } + } + } + ll=ll->next; + } + break; + case LK_BIBLE_FIND: + l->y=num-1; + l->x=0; + LtfUpdateWinJoin(l,FALSE,FALSE,FALSE,TRUE,OFF); + if (pattern && *pattern) { + result=FALSE; + ll=l->cur_entry; + while (ll!=l) { + if (Bt(ltf_display_types,ll->btype)) { + if (ptr=StrIStr(ll->display,pattern)) { + j=ptr-ll->display; + l->cur_entry=ll; + if (jmin_col) j=ll->min_col; + if (j>ll->max_col) j=ll->max_col; + l->cur_data_col=j; + result=TRUE; + break; + } + } + ll=ll->next; + } + } + break; + } + LtfCenter(l); + if (DoLtf(l,FALSE)) { + old_preempt=Preempt(OFF); + ll=l->cur_entry; + if (ll!=l) + LtfRunEntry(l,ll,TRUE,old_preempt); + Preempt(old_preempt); + LtfWrite(l); + } + if (Fs->cur_ltf!=l) + LtfDel(l); + } catch + Silent(old_silent); + return result; +} diff --git a/LT/Adam/Ltf/LtfFile.APZ b/LT/Adam/Ltf/LtfFile.APZ new file mode 100644 index 0000000..e959fbc --- /dev/null +++ b/LT/Adam/Ltf/LtfFile.APZ @@ -0,0 +1,313 @@ +public void LtfLoad(Ltf *l,I1 *src2,U8 size) +{ + I8 i; + I1 *src; + LtfBinEntry *tempb; + if (src2) { + LtfPutSExt(l,src2); + src=src2+StrLen(src2)+1; + i=size-(offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); + while (src<=src2+i) { + tempb=MAllocZ(sizeof(LtfBinEntry),l->mem_tss); + MemCpy(&tempb->start,src,offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); + src+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start); + tempb->data=MAlloc(tempb->size,l->mem_tss); + if (tempb->size) { + MemCpy(tempb->data,src,tempb->size); + src+=tempb->size; + } + InsQue(tempb,l->bin_root.last); + if (tempb->num>=l->cur_bin_num) + l->cur_bin_num=tempb->num+1; + } + } + if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) + LtfValidateBins(l); + l->recalc_start=l; + LtfRecalc(l); +} + +public Ltf *LtfRead(I1 *name,U8 flags=0) +{ + Ltf *l=LtfNew; + I1 *src,*name2; + U8 size=0; + l->flags|=flags; + name2=AbsoluteFileName(name); + StrCpy(l->filename.name,name2); + src=ReadFile(name2,&size,&l->file_attr); + Free(name2); + + if (src) { + LtfLoad(l,src,size); + Free(src); + } + return l; +} + +public void *LtfSave(Ltf *l,U8 *size=NULL) +{ + LtfEntry *cl; + LtfBinEntry *b; + I1 *st; + U8 cnt=2; //cursor + terminator + I1 *result,*dst,*src,ch; + I8 i; + if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) + LtfValidateBins(l); + l->recalc_start=l; + LtfRecalc(l); + for (cl=l->dummy.next;cl!=l;cl=cl->next) { + if (!Bt(ltf_data_types,cl->btype)) { + if (cl->btype==LTFT_TEXT && + !(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | + LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) { + cnt+=StrLen(cl->display); + if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) + cnt+=Occurrences(cl->display,'$$'); + } else if (cl->btype==LTFT_TAB || + cl->btype==LTFT_PAGE_BREAK) + cnt++; + else if (cl->btype==LTFT_CR) + cnt+=2; + else if (cl->btype==LTFT_PICWORD) + cnt+=StrLen(cl->aux_str); + else if (cl->btype!=LTFT_SOFT_CR && + cl->btype!=LTFT_CURSOR && + cl->btype!=LTFT_BPT) { + st=LtfToPlainText(l,cl); + cnt+=StrLen(st)+2; + Free(st,l->mem_tss); + } + } + } + for (b=l->bin_root.next;b!=&l->bin_root;b=b->next) { + if (b->use_cnt>b->temp_use_cnt) + cnt+=offset(LtfBinEntry.data)- + offset(LtfBinEntry.start)+b->size; + } + result=MAlloc(cnt); + dst=result; + for (cl=l->dummy.next;cl!=l;cl=cl->next) { + if (!Bt(ltf_data_types,cl->btype)) { + if (cl->btype==LTFT_TEXT && + !(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | + LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) { + src=cl->display; + i=0; + while (ch=*src++) { + if (cl==l->cur_entry && i++==l->cur_data_col) + *dst++=CH_CURSOR; + *dst++=ch; + if (ch=='$$') { + if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS))) + *dst++=ch; + } + } + if (cl==l->cur_entry && i++==l->cur_data_col) + *dst++=CH_CURSOR; + } else { + if (cl==l->cur_entry) + *dst++=CH_CURSOR; + if (cl->btype==LTFT_TAB) + *dst++=CH_TAB; + else if (cl->btype==LTFT_PAGE_BREAK) + *dst++=CH_FORM_FEED; + else if (cl->btype==LTFT_CR) { + *dst++=CH_CR; + *dst++=CH_LINE_FEED; + } else if (cl->btype==LTFT_PICWORD) { + StrCpy(dst,cl->aux_str); + dst+=StrLen(cl->aux_str); + } else if (cl->btype!=LTFT_SOFT_CR && + cl->btype!=LTFT_CURSOR && + cl->btype!=LTFT_BPT) { + *dst++='$$'; + st=LtfToPlainText(l,cl); + StrCpy(dst,st); + dst+=StrLen(st); + *dst++='$$'; + Free(st,l->mem_tss); + } + } + } + } + *dst++=0; + b=l->bin_root.next; + if (b!=&l->bin_root) { + while (b!=&l->bin_root) { + if (b->use_cnt>b->temp_use_cnt) { + MemCpy(dst,&b->type,offset(LtfBinEntry.data)-offset(LtfBinEntry.start)); + dst+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start); + MemCpy(dst,b->data,b->size); + dst+=b->size; + } + b=b->next; + } + } else + cnt--; + if (size) *size=cnt; + return result; +} + +public void LtfWrite(Ltf *l,BoolU4 prompt=FALSE) +{ + U8 size; + I1 *buf=LtfSave(l,&size); + if (prompt) { + if (DoForm(&l->filename,"EditFileNameStruct")) + WriteFile(l->filename.name,buf,size,0,l->file_attr); + } else + WriteFile(l->filename.name,buf,size,0,l->file_attr); + Free(buf); +} + +public void DelClipboard() +{ + LtfReset(sys_clipboard_ltf,TRUE); +} + +public void EditCopyToClipboard(Ltf *l) +{ + Ltf *b=sys_clipboard_ltf; + LtfEntry *cl=l->dummy.next,*nl; + DelClipboard; + while (cl!=l) { + if (cl->type & LTFLT_SELECTED) { + cl->type&=~LTFLT_SELECTED; + if (!Bt(ltf_data_types,cl->btype)) { + nl=LtfCopyEntry(b,cl); + InsQue(nl,b->dummy.last); + } + } + cl=cl->next; + } +} + +public void EditCutToClipboard(Ltf *l) +{ + Ltf *b=sys_clipboard_ltf; + LtfEntry *cl=l->dummy.next,*cl1,*nl,*cl2=NULL; + DelClipboard; + while (cl!=l) { + cl1=cl->next; + if (cl->type & LTFLT_SELECTED) { + cl->type&=~LTFLT_SELECTED; + if (!Bt(ltf_data_types,cl->btype)) { + nl=LtfCopyEntry(b,cl); + InsQue(nl,b->dummy.last); + } + if (cl==l->cur_entry || cl==cl2) + cl2=cl->next; + LtfDelEntry(l,cl); + } + cl=cl1; + } + if (cl2) { + l->cur_entry=cl2; + l->cur_data_col=cl2->min_col; + } + l->recalc_start=l; + LtfRemoveSoftCRs(l,NULL); +} + +public void EditInsertLtf(Ltf *l,Ltf *b) +{ //TODO: $LK,"LtfReset","MN:LtfReset"$ + I1 *dst; + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *nl,*cl=b->dummy.next; + LtfRemoveSoftCRs(l,NULL); + if (l->cur_entry->btype==LTFT_TEXT && + l->cur_data_col>l->cur_entry->min_col) { + if (l->cur_data_colcur_entry->max_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT | l->cur_entry->type & 0xFFFFFF00; + nl->flags=l->cur_entry->flags; + nl->x=l->cur_entry->x; + nl->y=l->cur_entry->y; + nl->indent=l->cur_entry->indent; + nl->page_line_num=l->cur_entry->page_line_num; + nl->left_margin=l->cur_entry->left_margin; + nl->right_margin=l->cur_entry->right_margin; + dst=l->cur_entry->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + nl->max_col=StrLen(dst); + *dst=0; + l->cur_entry->max_col=l->cur_data_col; + InsQue(nl,l->cur_entry); + l->cur_entry=nl; + l->cur_data_col=nl->min_col; + } else + if (l->cur_entry!=l) + l->cur_entry=l->cur_entry->next; + } + while (cl!=b) { + if (cl->btype!=LTFT_SOFT_CR) { + nl=LtfCopyEntry(l,cl); + InsQue(nl,l->cur_entry->last); + } + cl=cl->next; + } + l->recalc_start=l; + Preempt(old_preempt); +} + + +BoolU4 LtfCaptureUndo(Ltf *l) +{ + BoolU4 result=FALSE,old_preempt=Preempt(OFF); + U8 i=GetTimeStamp; + LtfUndo *u; + if (l->flags<FF_UNDO_DIRTY && + i>l->undo_root.last->timestamp+15*time_stamp_freq && + l->flags<FF_ALLOW_UNDO) { + u=MAllocZ(sizeof(LtfUndo),l->mem_tss); + u->timestamp=i; + u->body=LtfSave(l,&u->size); + InsQue(u,l->undo_root.last); + l->flags&=~LTFF_UNDO_DIRTY; + l->undo_cnt++; + u->ltf_flags=l->flags; + } + Preempt(old_preempt); + return result; +} + +void LtfRestoreUndo(Ltf *l) +{ + BoolU4 old_preempt=Preempt(OFF); + LtfUndo *u=l->undo_root.last,*u_next,*u_last; + Ltf *m; + if (u!=&l->undo_root) { + RemQue(u); + u_next=l->undo_root.next; + u_last=l->undo_root.last; + l->undo_root.next=&l->undo_root; + l->undo_root.last=&l->undo_root; + m=l->menu_ltf; + LtfReset(l,TRUE); + l->flags=u->ltf_flags; + LtfLoad(l,u->body,u->size); + LtfDelUndo(l,u); + l->undo_root.next=u_next; + l->undo_root.last=u_last; + l->menu_ltf=m; + } + LtfSetUndoCnt(l); + l->flags&=~LTFF_UNDO_DIRTY; + Preempt(old_preempt); +} + + +#help_index "File/Cmd Line (Typically);Ltf/Cmd Line (Typically)" + +public void Type(I1 *name) +//Output a file to the command line. +//Even graphics and macros will be sent. +{ + Ltf *l=LtfRead(name); + EditInsertLtf(Fs->cur_ltf,l); + LtfDel(l); +} +#help_index "Ltf" + \ No newline at end of file diff --git a/LT/Adam/Ltf/LtfMacro.APZ b/LT/Adam/Ltf/LtfMacro.APZ new file mode 100644 index 0000000..ac1bffb --- /dev/null +++ b/LT/Adam/Ltf/LtfMacro.APZ @@ -0,0 +1,126 @@ +I1 captured_macro_name[128]; +*captured_macro_name=0; + +I8 PopUpExitRecordPlayStopInsert() +{ + I8 result=0; + I1 buf[80]; + TssCmdStruct *tempc; + Ltf *l=LtfNew; + LtfEntry *ll; + ll=LtfPutSExt(l,"$$DA-P,127,\"Name:%s\"$$"); + ll->data=captured_macro_name; + LtfFormatData(ll); + LtfPutSExt(l,"$$CM+LX+TY,2,4$$$$BT, \"RECORD\",1$$"); + LtfPutSExt(l,"$$CM+LX+TY,18,4$$$$BT, \"PLAY\",2$$"); + LtfPutSExt(l,"$$CM+LX+TY,2,7$$$$BT, \"STOP\",3$$"); + LtfPutSExt(l,"$$CM+LX+TY,18,7$$$$BT, \"EXIT\",0$$"); + LtfPutSExt(l,"$$CM+LX+TY,2,10$$$$BT, \"INSERT\",4$$"); + l->flags|=LTFF_MIN_SIZE | LTFF_FORM; + SPrintF(buf,"DoMenu(0x%X);",l); + macro_util_tss=Spawn(&ServantUserCmdLine,"MACRO POPUP",Fs); + Fs->popup_tss=macro_util_tss; + tempc=QueueTaskRequest(macro_util_tss,Fs,buf, + 1<popup_tss=NULL; + Kill(macro_util_tss); + macro_util_tss=NULL; + LtfGetData(ll); + LtfDel(l); + return result; +} + +void DelSysMacro() +{ + TssCmdStruct *tempc,*tempc1; + tempc=sys_macro_queue.next; + while (tempc!=&sys_macro_queue) { + tempc1=tempc->next; + RemQue(tempc); + AFree(tempc); + tempc=tempc1; + } +} + +I1 *SysMacro2Str() +{ + TssCmdStruct *tempc; + I8 cnt=0; + I1 *ptr,*m; + LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + tempc=sys_macro_queue.next; + while (tempc!=&sys_macro_queue) { + if (tempc->cmd_code==TSSCT_MSG) + cnt++; + tempc=tempc->next; + } + m=MAlloc(cnt*54+1); + ptr=m; + + tempc=sys_macro_queue.next; + while (tempc!=&sys_macro_queue) { + if (tempc->cmd_code==TSSCT_MSG) { + SPrintF(ptr,"Msg(0x%08X,0x%016X,0x%016X);", + tempc->msg_code,tempc->p1,tempc->p2); + ptr+=54; + } + tempc=tempc->next; + } + return m; +} + +void PlaySysMacro() +{ + I1 *m=SysMacro2Str; + while (sys_cur_focus_task==Fs) + SwapInNext; + XTalkStrWithWait(sys_cur_focus_task,m); + Free(m); +} + +void MacroTask() +{ + I8 i; + StrCpy(captured_macro_name,"Click Here"); + do { + i=PopUpExitRecordPlayStopInsert; + RefocusWin; + switch (i) { + case 1: + LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + DelSysMacro; + LBts(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + break; + case 2: + LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + PlaySysMacro; + break; + case 3: + LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + break; + case 4: + LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); + if (sys_cur_focus_task) + QueueMsg(sys_cur_focus_task,0, + MSG_KEY_DOWN,0,SC_F2|SCF_SHIFT,0); + break; + } + } while (i>0); +} + +void EditMacroUtil() +{ + if (!macro_util_tss) + Spawn(&MacroTask,"MACRO TASK"); +} + +void EditInsertCapturedMacro() +{ + BoolU4 old_preempt=Preempt(OFF); + I1 *st=SysMacro2Str; + PrintF("$$MA+A+LM+LA,\"%s\",\"%s\"$$", + captured_macro_name,st); + Free(st); + Preempt(old_preempt); +} diff --git a/LT/Adam/Ltf/LtfMain.APZ b/LT/Adam/Ltf/LtfMain.APZ new file mode 100644 index 0000000..d4570c9 --- /dev/null +++ b/LT/Adam/Ltf/LtfMain.APZ @@ -0,0 +1,677 @@ +#help_index "Ltf/Cmd Line (Typically)" +public BoolU4 Edit(I1 *filename) +{ + I1 *buf=NewStr(filename), + *buf2=NewStr(filename); + U8 num=1; + I1 *temp_filename=NewStr(filename), + *tfn_ptr=temp_filename; + SysHashEntry *temph; + I8 i; + BoolU4 cont,result=FALSE; + Ltf *l; + + i=LK_FILE; + StrCpy(temp_filename,filename); + if (StrLen(filename)>3 && filename[2]==':') { + buf[2]=0; + i=MatchSysTextEntry(buf,"ST_LINK_TYPES",MLE_IGNORE_CASE); + tfn_ptr=temp_filename+3; + switch (i) { + case LK_MAN_PAGE: + temph=FindLocalHash(tfn_ptr, + HTT_GLBL_VAR|HTT_CLASS|HTT_FUNCTION| + HTT_STR_CONST|HTT_SYS_SYMBOL); + if (temph) + result=Edit(temph->source_link); + Free(temp_filename); + Free(buf); + Free(buf2); + return result; + case LK_DEF: + if (Occurrences(tfn_ptr,',')) { + RemoveLastSeg(tfn_ptr,",",buf); + i=AtoI(buf); + } else + i=-1; + WsdPopUpDef(tfn_ptr,i); + Free(temp_filename); + Free(buf); + Free(buf2); + return TRUE; + case LK_HELP_INDEX: + l=LtfNew; + LtfHelpIndex(l,tfn_ptr); + Free(temp_filename); + Free(buf); + Free(buf2); + DoLtf(l,TRUE); + LtfDel(l); + return TRUE; + case LK_BIBLE_FIND: + if (Occurrences(tfn_ptr,',')) { + RemoveLastSeg(tfn_ptr,",",buf); + } else + *buf=0; + num=AtoI(SysTextSub( + MatchSysTextEntry(tfn_ptr,"ST_BIBLE_BOOKS",MLE_IGNORE_CASE), + "ST_BIBLE_BOOK_LINES")); + tfn_ptr=SysText("ST_BIBLE_FILE"); + break; + case LK_FILE_LINE: + case LK_PLAIN_LINE: + if (Occurrences(tfn_ptr,',')) { + RemoveLastSeg(tfn_ptr,",",buf); + num=AtoI(buf); + } + break; + case LK_FILE_ANCHOR: + *buf=0; + if (Occurrences(tfn_ptr,',')) + RemoveLastSeg(tfn_ptr,",",buf); + break; + case LK_FILE_FIND: + case LK_PLAIN_FIND: + *buf=0; + *buf2=0; + if (Occurrences(tfn_ptr,',')) + RemoveLastSeg(tfn_ptr,",",buf); + if (Occurrences(buf,':')) { + RemoveLastSeg(buf,":",buf2); + num=AtoI(buf2); + } + break; + } + } + tfn_ptr=NewStr(tfn_ptr); + + cont=TRUE; + if (!IsTextFile(tfn_ptr)) { + if (!PopUpNoYes(ST_WARNING "Not Text File\r\n" + "Proceed anyway?\r\n\r\n")) + cont=FALSE; + } + if (cont) + result=LtfEditFile(i,tfn_ptr,buf,num); + + ClearWinText(Fs); + Free(tfn_ptr); + Free(temp_filename); + Free(buf); + Free(buf2); + return result; +} + +public void Plain(I1 *filename) +//Open a document in plain text mode, +//so that dollar signs are not special. +{ + I1 *buf=MSPrintF("PI:%s",filename); + Edit(buf); + Free(buf); +} + +#help_index "Ltf" +public Ltf *InitSysAuxLtf(BoolU4 has_menu) +{ + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *ll; + Ltf *aux; + + aux=LtfNew; + + LtfPutSExt(aux,"$$CM+H+BY+RX,-7,1$$"); + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->display_cb=&EditPreemptCB; + LtfPutSExt(aux,"$$CM+H+BY+RX,-6,1$$"); + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->user_data=Fs->cur_ltf; + ll->display_cb=&EditOverStrikeCB; + LtfPutSExt(aux,"$$CM+H+BY+RX,-5,1$$"); //gets merged without this + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->user_data=Fs->cur_ltf; + ll->display_cb=&EditDollarCB; + LtfPutSExt(aux,"$$CM+H+BY+RX,-4,1$$"); //gets merged without this + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->display_cb=&EditQuotesCB; + LtfPutSExt(aux,"$$CM+H+BY+RX,-3,1$$"); //gets merged without this + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->display_cb=&EditBracesCB; + LtfPutSExt(aux,"$$CM+H+BY+RX,-2,1$$"); //gets merged without this + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->display_cb=&EditSemicolonCB; + if (Fs->cur_ltf) { + LtfPutSExt(aux,"$$CM+H+BY+RX,-11,1$$"); + ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$"); + ll->user_data=Fs->cur_ltf; + ll->display_cb=&EditDollarTypeCB; + } + + if (Fs->user_num) + LtfPrintF(aux,"$$CM+H+TY+LX,5,-1$$$$TX+H+BD,\"#%d\"$$",Fs->user_num); + LtfPutSExt(aux,"$$CM+H+TY,0,-1$$"); + ll=LtfPutSExt(aux,"$$DA+H-T-P+BD+RD+CX+SCX+IV,140,\"%s...\",16$$"); + ll->data=&Fs->task_descriptor; + LtfFormatData(ll); + LtfPrintF(aux,"$$CM+H,1,0$$$$TX+H+BD+IV,\"%X\"$$",Fs); + aux->text_attribute=Fs->border_attribute; + if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN)) + LtfPutSExt(aux,"$$TX+H+RX+BD,\"[X]\"$$"); + if (has_menu) { + LtfPutSExt(aux,"$$TX+H+LX+BD,\"MENU\"$$"); + Bts(&Fs->crt_flags,CRTf_HAS_MENU); + } + Preempt(old_preempt); + return aux; +} + +public void UseConsoleLtf(I1 *menu_file) +{ + BoolU4 old_preempt=Preempt(OFF); + Ltf *l=LtfNew,*m; + + Fs->cur_ltf=l; + l->RightClickLink=&ConsoleRightClickLink; + l->max_entries=4096; + l->flags|=LTFF_ATTR_BY_PARTITION; + + if (menu_file) { + m=LtfRead(menu_file); + m->flags|=LTFF_ATTR_BY_PARTITION|LTFF_ALLOW_UNDO; + l->menu_ltf=m; + Fs->aux_ltf=InitSysAuxLtf(TRUE); + } else + Fs->aux_ltf=InitSysAuxLtf(FALSE); + + Fs->update_win=&LtfUpdateBothLtf; + Fs->scroll_speed=7; + Preempt(old_preempt); + Raw(OFF); +} + +#help_index "Ltf/Input" +public I1 *LtfGetLine(Ltf *l,LtfEntry *cl,I8 *cur_col=NULL) +{ + LtfEntry *cl2=cl; + BoolU4 old_preempt=Preempt(OFF); + I1 *result,*dst,*src,*start; + U8 i=0; + if (*cur_col) + *cur_col=-1; + while (cl2!=l && cl2->btype!=LTFT_CR) { + if (Bt(ltf_display_types,cl2->btype)) { + if (cl2->btype==LTFT_PICWORD) + src=cl2->aux_str; + else + src=cl2->display; + i+=StrLen(src); + } else if (cl2->btype==LTFT_TAB) + i++; + cl2=cl2->next; + } + result=MAlloc(i+1); + dst=result; + while (cl!=l && cl->btype!=LTFT_CR) { + start=dst; + if (Bt(ltf_display_types,cl->btype)) { + if (cl->btype==LTFT_PICWORD) + src=cl->aux_str; + else + src=cl->display; + while (*src) + *dst++=*src++; + } else if (cl->btype==LTFT_TAB) + *dst++=CH_TAB; + if (cl==l->cur_entry && cur_col) + *cur_col=start-result+l->cur_data_col; + cl=cl->next; + } + *dst++=0; + if (cl==l->cur_entry && cur_col && !l->cur_data_col) + *cur_col=dst-1-result; + Preempt(old_preempt); + return result; +} + +#help_index "Ltf/Output" +public void LtfDump(Ltf *l,U8 uS_delay=0) +{ + I1 *st; + LtfEntry *cl; + cl=l->dummy.next; + while (cl!=l) { + st=LtfGetLine(l,cl); + PutS(st); + Free(st); + do cl=cl->next; + while (cl!=l && cl->btype!=LTFT_CR); + if (cl->btype==LTFT_CR) { + cl=cl->next; + CrLf; + BusyWait(uS_delay); + } + } +} + +public BoolU4 View() +{ + I8 ch=0; + U8 sc=0; + BoolU4 old_preempt=Preempt(OFF); + while (ch!=CH_ESC && ch!=CH_CTRLQ) { + Preempt(OFF); + if (ScanKey(&ch,&sc)) { + Preempt(old_preempt); + PutKey(ch,sc); + LtfRecalc(Fs->cur_ltf); + } else { + Fs->task_flags|=1<rmt_chnl && + !(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) { + Fs->task_flags|=1<task_flags&=~(1<btype!=LTFT_ERROR && cl->btype!=LTFT_CR) { + if (Bt(ltf_display_types,cl->btype)) { + if (cl->btype==LTFT_PICWORD) + ptr=cl->aux_str; + else + ptr=cl->display; + do { + ptr2=ptr; + while (ch=*ptr) + if (ch=='$$') + break; + else + ptr++; + *ptr=0; + PutS(ptr2); + *ptr=ch; + if (ch=='$$') { + PutS("$$$$"); + ptr++; + } + } while (ch); + } else if (cl->btype==LTFT_TAB) + PutChar(CH_TAB); + cl=cl->next; + } + CrLf; + return (cl->btype==LTFT_ERROR) ? cl:cl->next; +} + +#help_index "Ltf/Input" +public I1 *LtfMGetS() +{ + Ltf *l=Fs->cur_ltf; + LtfEntry *cl; + BoolU4 old_preempt; + I1 *result; + U8 sc; + I8 ch; + old_preempt=Preempt(OFF); + PutS("$$FU$$$$BU$$"); + do { + Preempt(OFF); + if (ScanKey(&ch,&sc)) { + if (ch==CH_ESC) { + if (l=Fs->aux_ltf) { + if (!l->best_d && l->cur_entry!=l) { + cl=LtfCopyEntry(l,l->cur_entry); + if (Fs->cur_ltf) + LtfBottom(Fs->cur_ltf); + LtfRunEntry(l,cl,TRUE,old_preempt); + LtfDelEntry(l,cl); + goto next; + } + } + if (l=Fs->cur_ltf) { + if (l->cur_entry!=l) { + cl=LtfCopyEntry(l,l->cur_entry); + LtfBottom(l); + LtfRunEntry(l,cl,TRUE,old_preempt); + LtfDelEntry(l,cl); + } + } +next: + } if (ch==CH_CTRLQ) + Exit; + else { + Preempt(old_preempt); + PutKey(ch,sc); + LtfRecalc(Fs->cur_ltf); + } + } else { + Fs->task_flags|=1<rmt_chnl && + !(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) { + Fs->task_flags|=1<task_flags&=~(1< is a blank line without entry + } while (ch!=CH_CR || sc & SCF_CTRL && (sc & SCF_SHIFT)); + + Preempt(OFF); + l=Fs->cur_ltf; + cl=l->cur_entry; + do cl=cl->last; + while (cl!=l && cl->btype!=LTFT_CR && + cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND); + + + do cl=cl->last; + while (cl!=l && cl->btype!=LTFT_CR && + cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND); + + cl=cl->next; + result=LtfGetLine(l,cl,NULL); + PutS("$$FU$$$$FG$$$$BG$$"); + Preempt(old_preempt); + return result; +} + +#help_index "Char/Input" + +public I8 PmtI8(I1 *msg,I8 default,I8 lo=MIN_I8,I8 hi=MAX_I8) +{ + I8 result; + I1 *st; + while (TRUE) { + PrintF(msg,default); + st=MGetS; + if (!*st) { + Free(st); + return default; + } + result=AtoI(st); + Free(st); + if (result>=lo && result<=hi) + return result; + } +} + +public double PmtDouble(I1 *msg,double default,double lo=MIN_double,double hi=MAX_double) +{ + double result; + I1 *st; + while (TRUE) { + PrintF(msg,default); + st=MGetS; + if (!*st) { + Free(st); + return default; + } + result=A2Double(st); + Free(st); + if (result>=lo && result<=hi) + return result; + } +} + +public I1 *PmtStr(I1 *msg,I1 *default=NULL) +{ + I1 *st; + if (default) + PrintF(msg,default); + else + PrintF(msg); + st=MGetS; + if (!*st) { + Free(st); + if (default) + return NewStr(default); + else + return NewStr(""); + } + return st; +} + +public LTDate PmtLTDate(I1 *msg,LTDate default,LTDate lo=MIN_I8,LTDate hi=MAX_I8) +{ + LTDate result; + I1 *st; + while (TRUE) { + PrintF(msg,default,default); + st=MGetS; + if (!*st) { + Free(st); + return default; + } + result=A2LTDate(st); + Free(st); + if (result>=lo && result<=hi) + return result; + } +} + +#help_index "Ltf" + +I8 PopUpCancelIncludeDelAuto(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"INCLUDE (.CPZ)\",1$$"); + LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"DEBUG \",9$$"); + LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"COMPILE (.SPZ)\",5$$"); + LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"LOAD (.BIZ)\",6$$"); + LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"ADAM_INCLUDE (.APZ)\",4$$"); + LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"AUTOFILE (.AUZ)\",3$$"); + LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"COPY \",7$$"); + LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"MOVE \",8$$"); + LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"DELETE \",2$$"); + LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"CANCEL \",0$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +void EditLeftClickLink(Ltf *l,LtfEntry *cl,U2 old_preempt2) +{ + BoolU4 old_preempt=IsPreempt; + I1 *st; + nounusedwarn l; + if (cl->flags & LTFLF_AUX_STR) + st=NewStr(cl->aux_str); + else + st=NewStr(cl->display); + Preempt(old_preempt2); + Edit(st); + Preempt(old_preempt); + Free(st); +} + +void ConsoleRightClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2) +{ + BoolU4 send_cr=FALSE,old_preempt=IsPreempt; + I1 *st2,*st; + I8 i; + EditFileNameStruct fn; + if (cl->flags & LTFLF_AUX_STR) + st2=NewStr(cl->aux_str); + else + st2=NewStr(cl->display); + st=(st2[2]==':') ? st2+3:st2; + i=PopUpCancelIncludeDelAuto(st); + Preempt(old_preempt2); + if (i>0) { + LtfBottom(l); + switch (i) { + case 1: + if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "#include \"",st,"\";\r\n$$FU$$$$FG$$$$BG$$"; + ExecuteFile(st); + break; + case 2: + Del(st); + break; + case 3: + if (Occurrences(st,'.') && !WildCardMatch("*.AU?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .AU? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "AutoFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; + AutoStr("%F\r",st); + break; + case 4: + if (Occurrences(st,'.') && !WildCardMatch("*.AP?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "Adam(\"#include \\\"",st,"\\\"\" );\r\n$$FU$$$$FG$$$$BG$$"; + Adam(";#include \"%s\"",st); + break; + case 5: + if (Occurrences(st,'.') && !WildCardMatch("*.SP?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .SP? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "CompileFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; + CompileFile(st); + break; + case 6: + if (Occurrences(st,'.') && !WildCardMatch("*.BI?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .BI? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "Load(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; + Load(st); + break; + case 7: + StrCpy(fn.name,st); + if (DoForm(fn.name,"EditFileNameStruct")) + Copy(st,fn.name); + break; + case 8: + StrCpy(fn.name,st); + if (DoForm(fn.name,"EditFileNameStruct")) + Move(st,fn.name); + break; + case 9: + if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) { + if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n" + "Proceed anyway?\r\n\r\n")) { + send_cr=TRUE; + break; + } + } + cout "IDE(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$"; + IDE(st); + break; + } + } else + send_cr=TRUE; + LtfBottom(l); + cout "$$FU$$$$FG$$$$BG$$"; + if (send_cr) + PutChar(CH_CR); + Preempt(old_preempt); + Free(st2); +} + +#help_index "Ltf/Cmd Line (Typically)" + +public void Man(I1 *st) +//Enter the name of a symbol and this +//will jump to the source code. +{ + I1 *name=MAlloc(3+StrLen(st)+1); + StrCpy(name,"MN:"); + StrCat(name,st); + Edit(name); + Free(name); +} + +#help_index "Debugging;Ltf/Cmd Line (Typically);Ltf/Output" + +public void LtfDm(U1 *buf,U8 cnt=0x80) +//Dumps a chunk of memory, showing +//addresses. It is live and can be +//edited. +{ + 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) +//Dumps a chunk of memory, showing +//offsets. It is live and can be +//edited. +{ + 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); +} + +#help_index "Ltf/Output" +BoolU8 LtfPutS(I1 *st) +{ + Ltf *l; + BoolU4 old_preempt=Preempt(OFF); + l=Fs->cur_ltf; + if (l) + LtfPutSPartial(l,st,old_preempt); + Preempt(old_preempt); + return FALSE; +} + +AddKeyDev(&LtfPutKey,&LtfPutS,0x80000000); +ext[EXT_LTF_READ]=&LtfRead; +ext[EXT_LTF_WRITE]=&LtfWrite; +ext[EXT_LTF_NEW]=&LtfNew; +ext[EXT_LTF_RESET]=&LtfReset; +ext[EXT_LTF_DEL]=&LtfDel; +ext[EXT_MGETS]=&LtfMGetS; + +#help_index "Ltf" diff --git a/LT/Adam/Ltf/LtfNew.APZ b/LT/Adam/Ltf/LtfNew.APZ new file mode 100644 index 0000000..990f3ce --- /dev/null +++ b/LT/Adam/Ltf/LtfNew.APZ @@ -0,0 +1,505 @@ +U8 ltf_display_types[1],ltf_nondisplay_invisible_types[1], + ltf_form_types[1],ltf_data_types[1]; +U8 ltf_clean_scancodes[4]={0,0,0,0}; + +ltf_display_types[0]= + 1<bin_root.next; + while (b!=&l->bin_root) { + if (b->num==num) + return b; + b=b->next; + } + return NULL; +} + +void LtfValidateBins(Ltf *l) +{ + LtfBinEntry *b=l->bin_root.next,*b1; + LtfEntry *cl=l->dummy.next,*cl2; + while (b!=&l->bin_root) { + b->use_cnt=0; + b->temp_use_cnt=0; + b=b->next; + } + while (cl!=l) { + cl2=cl->next; + if (cl->flags & LTFLF_HAS_BIN) { + if (cl->bin_data=LtfFindBin(l,cl->bin_num)) { + cl->bin_data->use_cnt++; + if (cl->btype==LTFT_PICWORD) + cl->bin_data->temp_use_cnt++; + } else { + DbgStr("Bin Not Found",3000); + RemQue(cl); //don't attempt to delete + } + } + cl=cl2; + } + b=l->bin_root.next; + l->cur_bin_num=1; + while (b!=&l->bin_root) { + b1=b->next; + if (!b->use_cnt) { + RemQue(b); + Free(b->data,l->mem_tss); + Free(b,l->mem_tss); + } else { + if (b->num>=l->cur_bin_num) + l->cur_bin_num=b->num+1; + } + b=b1; + } +} + + +void LtfDelBin(Ltf *l,LtfBinEntry *b) +{ + b->use_cnt--; + if (!b->use_cnt) { + RemQue(b); + Free(b->data,l->mem_tss); + Free(b,l->mem_tss); + } +} + +void LtfDelEntry(Ltf *l,LtfEntry *cl) +{ + if (l==cl) + DbgStr("Ltf Del Header",10000); + else { + if (l->cur_entry==cl) + l->cur_entry=cl->next; + if (l->top_entry==cl) + l->top_entry=cl->next; + RemQue(cl); + if (Bt(ltf_display_types,cl->btype)) + Free(cl->display,l->mem_tss); + if (cl->flags & LTFLF_LEFT_MACRO) + Free(cl->left_macro,l->mem_tss); + if (cl->flags & LTFLF_RIGHT_MACRO) + Free(cl->right_macro,l->mem_tss); + if (cl->flags & LTFLF_AUX_STR) + Free(cl->aux_str,l->mem_tss); + if (cl->flags & LTFLF_HAS_BIN) + LtfDelBin(l,cl->bin_data); + Free(cl,l->mem_tss); + } +} + +void LtfDelUndo(Ltf *l,LtfUndo *u) +{ + Free(u->body,l->mem_tss); + Free(u,l->mem_tss); +} + +void LtfSetUndoCnt(Ltf *l) +{ + BoolU4 old_preempt=Preempt(OFF); + LtfUndo *u=l->undo_root.next; + l->undo_cnt=0; + while (u!=&l->undo_root) { + l->undo_cnt++; + u=u->next; + } + Preempt(old_preempt); +} + +BoolU8 LtfCheckBin(Ltf *l,LtfBinEntry *b) +{ + if (MTss(b->data)!=l->mem_tss) + return FALSE; + if (MTss(b)!=l->mem_tss) + return FALSE; + return TRUE; +} + +BoolU8 LtfCheckEntry(Ltf *l,LtfEntry *cl) +{ + if (l==cl) + DbgStr("Ltf Del Header",10000); + else { + if (Bt(ltf_display_types,cl->btype)) + if (MTss(cl->display)!=l->mem_tss) + return FALSE; + if (cl->flags & LTFLF_LEFT_MACRO) + if (MTss(cl->left_macro)!=l->mem_tss) + return FALSE; + if (cl->flags & LTFLF_RIGHT_MACRO) + if (MTss(cl->right_macro)!=l->mem_tss) + return FALSE; + if (cl->flags & LTFLF_AUX_STR) + if (MTss(cl->aux_str)!=l->mem_tss) + return FALSE; + if (cl->flags & LTFLF_HAS_BIN) + if (!LtfCheckBin(l,cl->bin_data)) + return FALSE; + if (MTss(cl)!=l->mem_tss) + return FALSE; + } + return TRUE; +} + + +LtfEntry *LtfCopyEntry(Ltf *l,LtfEntry *cl) +{ + LtfEntry *nl; + LtfBinEntry *tempb; + TssStruct *tss=l->mem_tss; + nl=MAllocIdentical(cl,tss); + nl->next=nl; + nl->last=nl; + if (Bt(ltf_display_types,cl->btype)) + nl->display=MAllocIdentical(cl->display,tss); + if (cl->flags & LTFLF_AUX_STR) + nl->aux_str=MAllocIdentical(cl->aux_str,tss); + if (cl->flags & LTFLF_LEFT_MACRO) + nl->left_macro=MAllocIdentical(cl->left_macro,tss); + if (cl->flags & LTFLF_RIGHT_MACRO) + nl->right_macro=MAllocIdentical(cl->right_macro,tss); + if (cl->flags & LTFLF_HAS_BIN) { + tempb=MAllocIdentical(cl->bin_data,tss); + tempb->data=MAllocIdentical(cl->bin_data->data,tss); + nl->bin_num=l->cur_bin_num; + tempb->num=l->cur_bin_num++; + nl->bin_data=tempb; + InsQue(tempb,l->bin_root.last); + } + return nl; +} + +void LtfFormForward(Ltf *l) +{ + LtfEntry *cl=l->cur_entry,*cl1=cl->last,*cl2=cl; + if (l->flags & LTFF_FORM) { + while (cl!=cl1 && !Bt(ltf_form_types,cl->btype)) + cl=cl->next; + } + while (cl->btype==LTFT_INDENT) + cl=cl->next; + if (cl!=cl2) { + l->cur_data_col=cl->min_col; + l->cur_entry=cl; + } +} + +void LtfFormBackward(Ltf *l) +{ + LtfEntry *cl=l->cur_entry,*cl1=cl->next,*cl2=cl; + if (l->flags & LTFF_FORM) { + while (cl!=cl1 && !Bt(ltf_form_types,cl->btype)) + cl=cl->last; + } + while (cl->btype==LTFT_INDENT) + cl=cl->next; + if (cl!=cl2) { + l->cur_data_col=cl->min_col; + l->cur_entry=cl; + } +} + +public void LtfHome(Ltf *l=NULL) +{ + if (!l) { + l=Fs->cur_ltf; + if (!l) return; + } + l->cur_entry=l->dummy.next; + l->cur_data_col=l->cur_entry->min_col; + l->x=0; + l->y=0; + l->line_start_col=0; + l->cur_top_line_num=0; + LtfFormForward(l); +} + +public BoolU4 LtfCheck(Ltf *l=NULL) +{ + LtfEntry *cl,*cl1; + if (!l) { + l=Fs->cur_ltf; + if (!l) return FALSE; + } + cl=l->dummy.next; + while (cl!=l) { + cl1=cl->next; + if (!LtfCheckEntry(l,cl)) + return FALSE; + cl=cl1; + } + return TRUE; +} + +public void LtfReset(Ltf *l,BoolU4 is_old) +{ + LtfEntry *cl,*cl1; + LtfUndo *u,*u1; + if (!l) { + l=Fs->cur_ltf; + if (!l) return; + } + if (is_old) { + cl=l->dummy.next; + while (cl!=l) { + cl1=cl->next; + LtfDelEntry(l,cl); + cl=cl1; + } + u=l->undo_root.next; + while (u!=&l->undo_root) { + u1=u->next; + LtfDelUndo(l,u); + u=u1; + } + } +//Check $LK,"EditInsertLtf","MN:EditInsertLtf"$ + l->start_text_attribute=(WHITE<<4)+BLUE; + l->text_attribute=l->start_text_attribute; + l->link_attribute=(WHITE<<4)+RED; + l->macro_attribute=(WHITE<<4)+LTBLUE; + l->anchor_attribute=(WHITE<<4)+BLACK; + l->hidden_attribute=(WHITE<<4)+BLACK; + l->tree_attribute=(WHITE<<4)+PURPLE; + l->user_attribute=(WHITE<<4)+GREEN; + l->flags=0; + l->dummy.next=l; + l->dummy.last=l; + l->bin_root.next=&l->bin_root; + l->bin_root.last=&l->bin_root; + l->undo_root.next=&l->undo_root; + l->undo_root.last=&l->undo_root; + l->undo_root.timestamp=0; + l->undo_cnt=0; + l->cur_bin_num=1; + l->recalc_start=l; + l->menu_ltf=NULL; + l->dollar_buf_ptr=0; + l->cmd_I1=CH_SPACE; + l->indent=0; + l->page_line_num=0; + l->page_length=66; + l->left_margin=LTF_DEFAULT; + l->right_margin=LTF_DEFAULT; + l->header=LTF_DEFAULT; + l->footer=LTF_DEFAULT; + l->best_d=MAX_I8; + + cl=&l->dummy; + cl->type=LTFT_ERROR; + cl->flags=0; + cl->x=0; + cl->y=0; + cl->min_col=0; + cl->max_col=0; + cl->indent=l->indent; + cl->page_line_num=l->page_line_num; + cl->left_margin=l->left_margin; + cl->right_margin=l->right_margin; + + LtfHome(l); +} + + +public void LtfDel(Ltf *l) +{ + Ltf *m; + if (!l) return; + m=l->menu_ltf; + LtfReset(l,TRUE); + Free(l->find_replace,l->mem_tss); + Free(l->dollar_buf,l->mem_tss); + LtfDel(m); + Free(l,l->mem_tss); +} + + +void LtfFormatData(LtfEntry *cl) +{ + BoolU4 *b; + U8 *d; + I8 i; + if (cl->btype==LTFT_DATA) { + d=cl->data; + if (cl->flags & LTFLF_DATA_IS_PTR) + SPrintF(cl->display,cl->aux_str,*d,cl->my_format_data); + else + SPrintF(cl->display,cl->aux_str,d,cl->my_format_data); + if (cl->flags & LTFLF_HAS_TERMINATOR) { + i=StrLen(cl->display); + cl->display[i++]='_'; + cl->display[i]=0; + } + cl->max_col=StrLen(cl->display); + } else if (cl->btype==LTFT_CHECK_BOX) { + if (cl->flags & LTFLF_DATA_IS_PTR) + b=cl->data; + else + b=&cl->data; + if (*b) + cl->flags|=LTFLF_CHECKED; + else + cl->flags&=~LTFLF_CHECKED; + } +} + +void LtfGetData(LtfEntry *cl) +{ + BoolU4 *b; + I8 i; + if (cl->btype==LTFT_DATA) { + i=StrLen(cl->display); + if (cl->flags & LTFLF_HAS_TERMINATOR) + cl->display[--i]=0; + if (i>cl->len+cl->min_col) + cl->display[cl->len+cl->min_col]=0; + if (cl->flags & LTFLF_DATA_IS_PTR) + GetF(cl->display,cl->aux_str,cl->data,cl->my_format_data); + else + GetF(cl->display,cl->aux_str,&cl->data,cl->my_format_data); + if (cl->flags & LTFLF_HAS_TERMINATOR) + cl->display[i]='_'; + } else if (cl->btype==LTFT_CHECK_BOX) { + if (cl->flags & LTFLF_DATA_IS_PTR) + b=cl->data; + else + b=&cl->data; + if (cl->flags & LTFLF_CHECKED) + *b=TRUE; + else + *b=FALSE; + } +} + +void LtfRemoveSoftCRs(Ltf *l=NULL,LtfEntry *cl=NULL) +{ + LtfEntry *cl2,*saved_cl=cl; + BoolU4 old_preempt=Preempt(OFF); + if (!l) { + l=Fs->cur_ltf; + if (!l) return; + } + if (!cl) cl=l->dummy.next; + while (cl!=l) { + cl2=cl->next; + if (cl->btype==LTFT_SOFT_CR) { + if (l->cur_entry==cl) { + l->cur_entry=cl2; + l->cur_data_col=l->cur_entry->min_col; + } + LtfDelEntry(l,cl); + } else if (saved_cl && cl->btype==LTFT_CR) + break; + cl=cl2; + } + Preempt(old_preempt); +} + +#help_index "Ltf/Cmd Line (Typically)" + +public void LtfMax(U8 i=MAX_I4) +//Adjusts the size of the Ltf buffer. +//Normally, the command line deletes +//entries after a while. +{ + Ltf *l=Fs->cur_ltf; + l->max_entries=i; +} + +#help_index "Ltf" +public Ltf *LtfNew() +{ + Ltf *l; + l=MAllocZ(sizeof(Ltf)); + StrCpy(l->filename.name,sys_temp_filename); + l->file_attr=0; + l->find_replace=MAllocZ(sizeof(EditFindTextStruct)); + l->find_replace->scan_forward=1; + l->find_replace->match_case=1; + l->LeftClickLink=&EditLeftClickLink; + l->dollar_buf_size=84; + l->dollar_buf=MAlloc(l->dollar_buf_size); + l->max_entries=MAX_I4; + l->ww_lines_back=32; + l->win_tss=Fs; + l->mem_tss=Fs; + LtfReset(l,FALSE); + return l; +} + +sys_clipboard_ltf=LtfNew; + diff --git a/LT/Adam/Ltf/LtfPlain.APZ b/LT/Adam/Ltf/LtfPlain.APZ new file mode 100644 index 0000000..83c11ba --- /dev/null +++ b/LT/Adam/Ltf/LtfPlain.APZ @@ -0,0 +1,688 @@ +void ParseLtfFlags(LexStruct *l,U8 *flags,U4 *type) +{ + I8 i; + BoolU4 turn_on; + while (l->token=='+' || l->token=='-') { + turn_on=(l->token=='+'); + if (Lex(l)==TK_IDENT) { + i=MatchSysTextEntry(l->ident,"ST_LTF_FLAGS",MLE_EXACT); + if (i<0) + *type=LTFT_ERROR; + else { + AssignBit(flags,i,turn_on); + if (i==LTFLf_SELECTED) + AssignBit(type,30,turn_on); + else if (i==LTFLf_UNDERLINED) + AssignBit(type,31,turn_on); + else if (i==LTFLf_INVERTED) + AssignBit(type,29,turn_on); + else if (i==LTFLf_BLINK) + AssignBit(type,28,turn_on); + } + Lex(l); //skip flag + } + } +} + +void LtfDefaultFlags(U4 *type,U8 *f1) +{ + switch (*type & 255) {$AN,"default_flags","default_flags"$ + case LTFT_TREE: + *f1=LTFLF_COLLAPSED|LTFLF_TREE; + *type|=LTFLT_UNDERLINE; + break; + case LTFT_DATA: + *f1=LTFLF_DATA_IS_PTR | LTFLF_HAS_TERMINATOR | LTFLF_AUX_STR; + break; + case LTFT_CURSOR_MOVEMENT: + *f1=LTFLF_LEFT_EXP | LTFLF_RIGHT_EXP; + break; + case LTFT_LINK: + *f1=LTFLF_LINK|LTFLF_AUX_STR; + *type|=LTFLT_UNDERLINE; + break; + case LTFT_ANCHOR: + *f1=LTFLF_AUX_STR; + break; + case LTFT_BUTTON: + *f1=LTFLF_ESC | LTFLF_LEFT_EXP | LTFLF_HAS_BORDER; + break; + case LTFT_CHECK_BOX: + *f1=LTFLF_DATA_IS_PTR; + break; + case LTFT_MACRO: + *f1=LTFLF_ESC | LTFLF_LEFT_MACRO; + *type|=LTFLT_UNDERLINE; + break; + case LTFT_MENU_VALUE: + *f1=LTFLF_ESC | LTFLF_LEFT_EXP; + *type|=LTFLT_UNDERLINE; + break; + case LTFT_HEX_EDIT: + *f1=LTFLF_DATA_IS_PTR | LTFLF_ZERO_BASED; + break; + case LTFT_PICWORD: + *f1=LTFLF_HAS_BIN|LTFLF_AUX_STR|LTFLF_FROM_START|LTFLF_WIDTH|LTFLF_HEIGHT; + break; + case LTFT_PICTURE: + *f1=LTFLF_HAS_BIN; + break; + case LTFT_TOP_LEFT_TOOLBAR: + *f1=LTFLF_HAS_BIN|LTFLF_TOP_LEFT_MENU|LTFLF_WIDTH|LTFLF_HEIGHT; + break; + case LTFT_TOP_RIGHT_TOOLBAR: + *f1=LTFLF_HAS_BIN|LTFLF_TOP_RIGHT_MENU|LTFLF_WIDTH|LTFLF_HEIGHT; + break; + case LTFT_INSERT_BINARY: + case LTFT_INSERT_BINARY_TYPE: + case LTFT_INSERT_BINARY_SIZE: + *f1=LTFLF_HAS_BIN; + break; + case LTFT_HIDE_START: + *f1=LTFLF_COLLAPSED; + *type|=LTFLT_UNDERLINE; + break; + case LTFT_SONG: + *f1=LTFLF_SONG; + break; + } +} + +I1 *LtfToPlainText(Ltf *l,LtfEntry *ll) +{ //TODO: break strs + I8 i,j; + U8 type=ll->btype,f1=0,flags; + I1 *buf,*buf2; + +buf=NewStr(SysTextSub(ll->btype,"ST_LTF_CMDS")); +if (ll->btype!=LTFT_ERROR) { + LtfDefaultFlags(&type,&f1); + + flags=ll->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | + LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP); + for (i=0;i<64;i++) + if (Bt(&f1,i)!=Bt(&flags,i)) { + if (Bt(&flags,i)) + buf=Add2Str(buf,"+"); + else + buf=Add2Str(buf,"-"); + buf=Add2Str(buf,SysTextSub(i,"ST_LTF_FLAGS")); + } + + for (i=28;i<32;i++) + if (Bt(&type,i)!=Bt(&ll->type,i)) { + if (Bt(&ll->type,i)) + buf=Add2Str(buf,"+"); + else + buf=Add2Str(buf,"-"); + switch (i) { + case 28: j=LTFLf_BLINK; break; + case 29: j=LTFLf_INVERTED; break; + case 30: j=LTFLf_SELECTED; break; + case 31: j=LTFLf_UNDERLINED; break; + } + buf=Add2Str(buf,SysTextSub(j,"ST_LTF_FLAGS")); + } + buf=Add2Str(buf,","); + switch (ll->btype) { + case LTFT_TEXT: + case LTFT_LINK: + case LTFT_ANCHOR: + case LTFT_MENU_VALUE: + case LTFT_BUTTON: + case LTFT_CHECK_BOX: + case LTFT_TREE: + case LTFT_PICTURE: + case LTFT_PICWORD: + case LTFT_INSERT_BINARY: + case LTFT_INSERT_BINARY_TYPE: + case LTFT_INSERT_BINARY_SIZE: + case LTFT_SONG: + buf=Add2Str(buf,"\""); + if (i==LTFT_CHECK_BOX) { + buf=Add2Str(buf,ll->display+4); + } else { + if (ll->flags & LTFLF_TREE) + buf=Add2Str(buf,ll->display+3); + else + buf=Add2Str(buf,ll->display); + } + buf=Add2Str(buf,"\","); + break; + case LTFT_DATA: + buf2=MSPrintF("%s%d,",buf,ll->len); + Free(buf); buf=buf2; + break; + case LTFT_HEX_EDIT: + buf2=MSPrintF("%s%d,",buf,ll->len); + Free(buf); buf=buf2; + buf2=MSPrintF("%s%d,",buf,ll->hex_edit_width); + Free(buf); buf=buf2; + break; + case LTFT_PAGE_LENGTH: + case LTFT_LEFT_MARGIN: + case LTFT_RIGHT_MARGIN: + case LTFT_HEADER: + case LTFT_FOOTER: + case LTFT_INDENT: + case LTFT_FOREGROUND_COLOR: + case LTFT_BACKGROUND_COLOR: + case LTFT_DEFAULT_FOREGROUND_COLOR: + case LTFT_DEFAULT_BACKGROUND_COLOR: + case LTFT_LINK_FOREGROUND: + case LTFT_LINK_BACKGROUND: + case LTFT_MACRO_FOREGROUND: + case LTFT_MACRO_BACKGROUND: + case LTFT_ANCHOR_FOREGROUND: + case LTFT_ANCHOR_BACKGROUND: + case LTFT_HIDDEN_FOREGROUND: + case LTFT_HIDDEN_BACKGROUND: + case LTFT_TREE_FOREGROUND: + case LTFT_TREE_BACKGROUND: + case LTFT_USER_FOREGROUND: + case LTFT_USER_BACKGROUND: + case LTFT_WORD_WRAP: + case LTFT_UNDERLINED: + case LTFT_INVERTED: + case LTFT_BLINK: + case LTFT_SHIFTED_X: + case LTFT_SHIFTED_Y: + if (ll->attr!=LTF_DEFAULT) { + buf2=MSPrintF("%s%d,",buf,ll->attr); + Free(buf); buf=buf2; + } + break; + } + flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y| + LTFLF_AUX_STR|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO| + LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO| + LTFLF_WIDTH|LTFLF_HEIGHT); + while (flags) { + j=Bsf(flags); + Btr(&flags,j); + switch (j) { + case LTFLf_SCROLLING_X: + buf2=MSPrintF("%s%d",buf,ll->scroll_len); + Free(buf); buf=buf2; + break; + case LTFLf_SHIFTED_X: + j=(ll->type.u2[1])&0x1F; + if (j&0x10) j|=0xFFFFFFF0; + buf2=MSPrintF("%s%d",buf,j); + Free(buf); buf=buf2; + break; + case LTFLf_SHIFTED_Y: + j=(ll->type>>21)&0x1F; + if (j&0x10) j|=0xFFFFFFF0; + buf2=MSPrintF("%s%d",buf,j); + Free(buf); buf=buf2; + break; + case LTFLf_AUX_STR: + buf2=MSPrintF("%s\"%Q\"",buf,ll->aux_str); + Free(buf); buf=buf2; + break; + case LTFLf_LEFT_EXP: + buf2=MSPrintF("%s%d",buf,ll->left_exp); + Free(buf); buf=buf2; + break; + case LTFLf_LEFT_MACRO: + buf2=MSPrintF("%s\"%Q\"",buf,ll->left_macro); + Free(buf); buf=buf2; + break; + case LTFLf_RIGHT_EXP: + buf2=MSPrintF("%s%d",buf,ll->right_exp); + Free(buf); buf=buf2; + break; + case LTFLf_RIGHT_MACRO: + buf2=MSPrintF("%s\"%Q\"",buf,ll->right_macro); + Free(buf); buf=buf2; + break; + case LTFLf_HAS_BIN: + buf2=MSPrintF("%s%d",buf,ll->bin_num); + Free(buf); buf=buf2; + break; + case LTFLf_WIDTH: + buf2=MSPrintF("%s%d",buf,ll->width); + Free(buf); buf=buf2; + break; + case LTFLf_HEIGHT: + buf2=MSPrintF("%s%d",buf,ll->height); + Free(buf); buf=buf2; + break; + } + buf=Add2Str(buf,","); + } + buf[StrLen(buf)-1]=0; //Kill last comma +} + buf2=NewStr(buf,l->mem_tss); //exact allocation + Free(buf); + return buf2; +} + + +LtfEntry *ParseDollarCmd(Ltf *l,I1 *st) +{ + I8 i,j,size,flags; + I1 *ptr,*st2; + LtfEntry *ll=NULL; + LexStruct *lx=LexNew(st,LF_DONT_FREE_BUFFER,NULL); + Lex(lx); + if (lx->token==TK_IDENT) { + i=MatchSysTextEntry(lx->ident,"ST_LTF_CMDS",MLE_IGNORE_CASE); + if (i<0) + i=LTFT_ERROR; + Lex(lx); //skip cmd code + ll=MAllocZ(sizeof(LtfEntry),l->mem_tss); + ll->type=i; + LtfDefaultFlags(&ll->type,&ll->flags); + ParseLtfFlags(lx,&ll->flags,&ll->type); + if (lx->token==',') + Lex(lx); + switch (i) { + case LTFT_TEXT: + case LTFT_LINK: + case LTFT_ANCHOR: + case LTFT_MENU_VALUE: + case LTFT_BUTTON: + case LTFT_CHECK_BOX: + case LTFT_TREE: + case LTFT_PICTURE: + case LTFT_PICWORD: + case LTFT_INSERT_BINARY: + case LTFT_INSERT_BINARY_TYPE: + case LTFT_INSERT_BINARY_SIZE: + case LTFT_SONG: + if (lx->token==TK_STR) { + st2=LexExtendStr(lx,&size); + if (i==LTFT_CHECK_BOX) { + st=MSPrintF("[X] %s",st2); + Free(st2); + ll->min_col=1; + } else if (ll->flags & LTFLF_TREE) { + st=MSPrintF("+] %s",st2); + Free(st2); + ll->min_col=1; + } else + st=st2; + ll->display=NewStr(st,l->mem_tss); + Free(st); + } else { + if (i>=LTFT_PICTURE && i<=LTFT_INSERT_BINARY_SIZE || + i==LTFT_SONG) + ll->display=NewStr("",l->mem_tss); + else { + ll->display=NULL; + ll->type=LTFT_ERROR; + } + } + break; + case LTFT_HIDE_START: + ll->display=NewStr("<-",l->mem_tss); + ll->min_col=1; + break; + case LTFT_HIDE_END: + ll->display=NewStr(">",l->mem_tss); + break; + case LTFT_DATA: + ll->flags|=LTFLF_AUX_STR; //don't allow switched off + ll->len=Expression(lx); + break; + case LTFT_HEX_EDIT: + ll->len=Expression(lx); + if (lx->token==',') + Lex(lx); + ll->hex_edit_width=Expression(lx); + break; + case LTFT_PAGE_LENGTH: + case LTFT_LEFT_MARGIN: + case LTFT_RIGHT_MARGIN: + case LTFT_HEADER: + case LTFT_FOOTER: + case LTFT_INDENT: + case LTFT_FOREGROUND_COLOR: + case LTFT_BACKGROUND_COLOR: + case LTFT_DEFAULT_FOREGROUND_COLOR: + case LTFT_DEFAULT_BACKGROUND_COLOR: + case LTFT_LINK_FOREGROUND: + case LTFT_LINK_BACKGROUND: + case LTFT_MACRO_FOREGROUND: + case LTFT_MACRO_BACKGROUND: + case LTFT_ANCHOR_FOREGROUND: + case LTFT_ANCHOR_BACKGROUND: + case LTFT_HIDDEN_FOREGROUND: + case LTFT_HIDDEN_BACKGROUND: + case LTFT_TREE_FOREGROUND: + case LTFT_TREE_BACKGROUND: + case LTFT_USER_FOREGROUND: + case LTFT_USER_BACKGROUND: + case LTFT_WORD_WRAP: + case LTFT_UNDERLINED: + case LTFT_INVERTED: + case LTFT_BLINK: + case LTFT_SHIFTED_X: + case LTFT_SHIFTED_Y: + if (!lx->token) + ll->attr=LTF_DEFAULT; + else + ll->attr=Expression(lx); + break; + case LTFT_ERROR: + ll->flags=0; + ll->type=LTFT_ERROR; + break; + } + + flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y| + LTFLF_AUX_STR|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO| + LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO| + LTFLF_WIDTH|LTFLF_HEIGHT); + while (flags) { + j=Bsf(flags); + Btr(&flags,j); + while (lx->token==',') + Lex(lx); + switch (j) { //TODO: Might check for expression errors + case LTFLf_SCROLLING_X: + ll->scroll_len=Expression(lx); + break; + case LTFLf_SHIFTED_X: + ll->type|=((Expression(lx) & 0x1F)<<16); + break; + case LTFLf_SHIFTED_Y: + ll->type|=((Expression(lx) & 0x1F)<<21); + break; + case LTFLf_AUX_STR: + if (lx->token==TK_STR) { + st2=LexExtendStr(lx,&size); + ll->aux_str=NewStr(st2,l->mem_tss); + Free(st2); + if (i==LTFT_MACRO && !ll->display) + ll->display=NewStr(ll->aux_str,l->mem_tss); + if (i==LTFT_DATA) { + if (ptr=StrStr(ll->aux_str,":")) + ll->min_col=ptr-ll->aux_str+1; + ll->display=MAlloc(ll->len+ll->min_col+2,l->mem_tss); + } + } else + ll->type=LTFT_ERROR; + break; + case LTFLf_LEFT_EXP: + ll->left_exp=Expression(lx); + break; + case LTFLf_LEFT_MACRO: + if (lx->token==TK_STR) { + st2=LexExtendStr(lx,&size); + ll->left_macro=NewStr(st2,l->mem_tss); + Free(st2); + if (i==LTFT_MACRO && !ll->display) + ll->display=NewStr(ll->left_macro,l->mem_tss); + } else + ll->type=LTFT_ERROR; + break; + case LTFLf_RIGHT_EXP: + ll->right_exp=Expression(lx); + break; + case LTFLf_RIGHT_MACRO: + if (lx->token==TK_STR) { + st2=LexExtendStr(lx,&size); + ll->right_macro=NewStr(st2,l->mem_tss); + Free(st2); + if (i==LTFT_MACRO && !ll->display) + ll->display=NewStr(ll->right_macro,l->mem_tss); + } else + ll->type=LTFT_ERROR; + break; + case LTFLf_HAS_BIN: + if (!lx->token) + ll->bin_num=0; + else + ll->bin_num=Expression(lx); + break; + case LTFLf_WIDTH: + ll->width=Expression(lx); + break; + case LTFLf_HEIGHT: + ll->height=Expression(lx); + break; + } + } + } else if (!ll) { + ll=MAllocZ(sizeof(LtfEntry),l->mem_tss); + ll->type=LTFT_ERROR; + } + LexDel(lx); + return ll; +} + +void LtfInsert(Ltf *l,LtfEntry *ll) +{ + I1 *dst; + LtfEntry *cl=l->cur_entry,*nl; + + ll->x=cl->x; + ll->y=cl->y; + ll->indent=cl->indent; + ll->page_line_num=cl->page_line_num; + ll->left_margin=cl->left_margin; + ll->right_margin=cl->right_margin; + if (l->cur_data_col>0 && + cl->btype==LTFT_TEXT && + l->cur_data_colmax_col) { + nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + nl->type=LTFT_TEXT|cl->type&-0x100; + nl->x=cl->x; + nl->y=cl->y; + nl->indent=cl->indent; + nl->page_line_num=cl->page_line_num; + nl->left_margin=cl->left_margin; + nl->right_margin=cl->right_margin; + nl->flags=cl->flags; + dst=cl->display+l->cur_data_col; + nl->display=NewStr(dst,l->mem_tss); + *dst=0; + cl->max_col=l->cur_data_col; + InsQue(nl,cl); + l->cur_data_col=0; + cl=nl; + cl->max_col=StrLen(cl->display); + } + if (cl->btype==LTFT_TEXT && l->cur_data_col>=cl->max_col) { + InsQue(ll,cl); + l->cur_entry=ll->next; + } else { + InsQue(ll,cl->last); + l->cur_entry=cl; + } + l->cur_data_col=l->cur_entry->min_col; + LtfRemoveSoftCRs(l,l->cur_entry); +} + + +#help_index "Ltf/Output" +public LtfEntry *LtfPutSExt(Ltf *l,I1 *st) +{ + I1 ch,*ptr=st,*ptr2,*st2,*ptr3,*ptr4,*src; + BoolU4 old_preempt=Preempt(OFF); + LtfEntry *ll=NULL,*result=NULL,*cl=l->cur_entry; + l->recalc_start=l; //TODO:This might be optimized + if (!st) { + Preempt(old_preempt); + return NULL; + } + while (*ptr) { + ptr2=ptr; + ch=*ptr++; + while (TRUE) { + if (l->flags & LTFF_PLAIN_TEXT_WITH_TABS) + while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_CURSOR) + ch=*ptr++; + else if (l->flags & LTFF_PLAIN_TEXT) + while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED) + ch=*ptr++; + else + while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED && ch!='$$') + ch=*ptr++; + if (ch==CH_CURSOR) { + if (l->flags & LTFF_NO_CURSOR) + ch=*ptr++; + else + break; + } else + break; + } + ptr--; + if (!ch) { + if (ptr!=ptr2) { + ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + ll->type=LTFT_TEXT | l->text_attribute << 8; + if (l->flags & LTFF_NO_CURSOR) { + src=NewStr(ptr2); + StrUtil(src,SU_REMOVE_CTRL_CHARS); + } else + src=ptr2; + ll->display=NewStr(src,l->mem_tss); + ll->max_col=StrLen(src); + LtfInsert(l,ll); + if (l->flags & LTFF_NO_CURSOR) + Free(src); + } + } else { + if (ptr!=ptr2) { + *ptr=0; + ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + ll->type=LTFT_TEXT | l->text_attribute << 8; + if (l->flags & LTFF_NO_CURSOR) { + src=NewStr(ptr2); + StrUtil(src,SU_REMOVE_CTRL_CHARS); + } else + src=ptr2; + ll->display=NewStr(src,l->mem_tss); + ll->max_col=StrLen(src); + LtfInsert(l,ll); + if (l->flags & LTFF_NO_CURSOR) + Free(src); + *ptr=ch; + } + if (ch==CH_CURSOR) { //cursor + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_CURSOR | l->text_attribute << 8; + LtfInsert(l,ll); + ptr++; + } else if (ch==CH_FORM_FEED) { + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8; + LtfInsert(l,ll); + ptr++; + } else if (ch==CH_TAB) { + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_TAB | l->text_attribute << 8; + LtfInsert(l,ll); + ptr++; + } else if (ch=='$$') { + ptr++; //skip first dollar + ptr2=ptr; + while (*ptr && *ptr!='$$') + ptr++; + if (*ptr) { + *ptr=0; //zero second dollar + if (ptr==ptr2) { + ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss); + ll->type=LTFT_TEXT | l->text_attribute << 8; + ll->max_col=1; + if (l->flags & LTFF_DOUBLE_DOLLARS) + ll->display=NewStr("$$$$",l->mem_tss); + else + ll->display=NewStr("$$",l->mem_tss); + LtfInsert(l,ll); + } else { + st2=MAlloc(ptr-ptr2+1); + ptr3=ptr2; + ptr4=st2; + while (*ptr3) { + ch=*ptr3++; + if (ch==CH_CURSOR) { + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_CURSOR | l->text_attribute << 8; + LtfInsert(l,ll); + } else if (ch==CH_FORM_FEED) { + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8; + LtfInsert(l,ll); + } else + *ptr4++=ch; + } + *ptr4=0; + if (ll=ParseDollarCmd(l,st2)) { + result=ll; + LtfInsert(l,ll); + } + Free(st2); + } + *ptr++='$$'; + } + } else { + ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss); + ll->type=LTFT_CR | l->text_attribute << 8; + LtfInsert(l,ll); + if (ch==CH_CR) + while (*ptr==CH_CR) + ptr++; + if (*ptr==CH_LINE_FEED) + ptr++; + while (*ptr==CH_CR) + ptr++; + } + } + } + Preempt(old_preempt); + return result; +} + + +public LtfEntry *LtfPrintF(Ltf *l,I1 *src,...) +{ + LtfEntry *result; + I1 *buf=SPrintFJoin(NULL,src,argc,argv); + result=LtfPutSExt(l,buf); + Free(buf); + return result; +} + +#help_index "PicWords" +#help_file "::/LT/Doc/PicWords.TXZ" +#help_index "PicWords;Ltf/Output" +public PicWordEntry *AddPicWord(I1 *st,GrElem *tempe,U8 size,I8 width=0,I8 height=0,I1 *txt=NULL) +{ +//If you set $FG,4$txt$FG$, then include dollar signs +//$FG,4$$$PW,"padspaces","Word",%d,width,height$$$FG$ +// +//If you want a macro picword +//$FG,4$$$PW+LM,"padspaces","Word","Macro",%d,width,height$$$FG$ + +//See $LK,"LtfWordsToPics","MN:LtfWordsToPics"$ + + I1 *st2; + I8 l; + PicWordEntry *temppw=MAllocZ(sizeof(PicWordEntry)); + temppw->type=HTT_PIC_WORD; + temppw->use_cnt=0; + temppw->grelem=tempe; + temppw->size=size; + temppw->width=width; + temppw->height=height; + if (txt) { + l=StrLen(txt); + if (l>2) { + st2=MAlloc(l-2+1); + MemCpy(st2,txt+1,l-2); + st2[l-2]=0; + temppw->txt=st2; + } + } + temppw->source_link=NULL; + temppw->str=NewStr(st); + AddSysHashEntry(temppw,Fs->hash_table); + return temppw; +} + +#help_index "Ltf" diff --git a/LT/Adam/Ltf/LtfPopUp.APZ b/LT/Adam/Ltf/LtfPopUp.APZ new file mode 100644 index 0000000..4765f7e --- /dev/null +++ b/LT/Adam/Ltf/LtfPopUp.APZ @@ -0,0 +1,621 @@ +public I8 LtfRunEntry(Ltf *l,LtfEntry *cl,BoolU4 exited,BoolU4 old_preempt) +{ //Call with preempt off + I8 result=-1; + I1 ch=l->cmd_I1,*st; + I8 cb(Ltf *l,LtfEntry *ll); + + if (!exited) { + if (cl->flags & LTFLF_ESC) { + Msg(MSG_KEY_DOWN,CH_ESC,0,1<flags & LTFLF_QUIT) { + Msg(MSG_KEY_DOWN,CH_CTRLQ,0,1<best_d=MAX_I8; + if (cl->flags & LTFLF_LINK) { + try { + if (ch==CH_SPACE) { + if (l->LeftClickLink) + l->LeftClickLink(l,cl,old_preempt); + } else if (ch==CH_CR) { + if (l->RightClickLink) + l->RightClickLink(l,cl,old_preempt); + } + } catch + LtfBottom(l); + return 0; + } + if (ch==CH_SPACE && cl->flags & LTFLF_TREE || cl->btype==LTFT_HIDE_START) + cl->flags^=LTFLF_COLLAPSED; + + if ((cl->btype>=LTFT_BUTTON && cl->btype<=LTFT_MENU_VALUE) || + cl->btype==LTFT_PICTURE || + cl->btype==LTFT_PICWORD || + cl->btype==LTFT_TOP_LEFT_TOOLBAR || + cl->btype==LTFT_TOP_RIGHT_TOOLBAR) { + if (cl->btype==LTFT_CHECK_BOX) + cl->flags^=LTFLF_CHECKED; + if (ch==CH_SPACE) { + if (cl->flags & LTFLF_LEFT_EXP) { + result=cl->left_exp; + Msg(MSG_CMD,result,0,1<flags & LTFLF_LEFT_CB) { + cb=cl->left_cb; + Preempt(old_preempt); + result=cb(l,cl); + Preempt(OFF); + Msg(MSG_CMD,result,0,1<flags & LTFLF_LEFT_MACRO) { + if (cl->flags & LTFLF_POPUP) { + st=NewStr(cl->left_macro); + Preempt(old_preempt); + PopUp(st,Fs); + Preempt(OFF); + Free(st); + } else { + if (cl->flags & LTFLF_LEFT_AUTO) + AutoStr("%s",cl->left_macro); + else + Auto(cl->left_macro); + } + } + } else if (ch==CH_CR) { + if (cl->flags & LTFLF_RIGHT_EXP) { + result=cl->right_exp; + Msg(MSG_CMD,result,0,1<flags & LTFLF_RIGHT_CB) { + cb=cl->right_cb; + Preempt(old_preempt); + result=cb(l,cl); + Preempt(OFF); + Msg(MSG_CMD,result,0,1<flags & LTFLF_RIGHT_MACRO) { + if (cl->flags & LTFLF_POPUP) { + st=NewStr(cl->right_macro); + Preempt(old_preempt); + PopUp(st,Fs); + Preempt(OFF); + Free(st); + } else { + if (cl->flags & LTFLF_RIGHT_AUTO) + AutoStr("%s",cl->right_macro); + else + Auto(cl->right_macro); + } + } + } + } + l->cmd_I1=CH_SPACE; + return result; +} + +I1 *EditOverStrikeCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + Ltf *ltf=ll->user_data; + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l; + st[0]=(ltf->flags & LTFF_OVERSTRIKE) ? 'O':130; + st[1]=0; + return st; +} + +I1 *EditDollarCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + Ltf *ltf=ll->user_data; + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l; + st[0]=(ltf->flags & LTFF_IN_DOLLAR) ? '$$':130; + st[1]=0; + return st; +} + +I1 *EditQuotesCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + LexStruct *lx=mem_tss->last_lex; + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l,ll; + st[0]=(lx->flags & LF_IN_QUOTES) ? '"':130; + st[1]=0; + return st; +} + +I1 *EditBracesCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + LexStruct *lx=mem_tss->last_lex; + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l,ll; + st[0]=(lx->braces_cnt) ? '}':130; + st[1]=0; + return st; +} + +I1 *EditSemicolonCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + LexStruct *lx=mem_tss->last_lex; + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l,ll; + st[0]=(lx->statement_cnt) ? ';':130; + st[1]=0; + return st; +} + +I1 *EditPreemptCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + I1 *st=MAlloc(8,mem_tss); + nounusedwarn l,ll; + st[0]=Bt(&mem_tss->task_flags,TSSf_PREEMPT) ? 'P':130; + st[1]=0; + return st; +} + +I1 *EditDollarTypeCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss) +{ + Ltf *ltf=ll->user_data; + I1 *src=SysTextSub(ltf->cur_entry->btype,"ST_LTF_CMDS"); + I1 *st=MAllocZ(8,mem_tss); + nounusedwarn l; + if (ltf->cur_entry==ltf) { + StrCpy(st,"EOF"); + } else if (src) StrCpy(st,src); + return st; +} + +public BoolU4 DoLtf(Ltf *l,BoolU4 home=TRUE,I1 *help=NULL,BoolU4 help_is_file=FALSE) +{ + Ltf *menu=NULL,*old_ltf=Fs->cur_ltf,*old_aux=Fs->aux_ltf,*aux; + I8 old_attribute=Fs->text_attribute; + I8 ch=0; + U8 sc=0; + LtfEntry *ll; + void * old_update=Fs->update_win; + BoolU4 old_preempt; + + if (help && !l->menu_ltf) { + if (help_is_file) + menu=LtfRead(help); + else { + menu=LtfNew; + menu->text_attribute=l->text_attribute; + LtfPutSExt(menu,help); + } + l->menu_ltf=menu; + } + + l->win_tss=Fs; + aux=LtfNew; + aux->text_attribute=Fs->border_attribute; + LtfPutSExt(aux,"$$CM +TY,0,-1$$"); + if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN)) + LtfPutSExt(aux,"$$TX+RX+BD,\"[X]\"$$"); + if (l->menu_ltf) + LtfPutSExt(aux,"$$TX+LX+BD,\"MENU\"$$"); + + ll=LtfPutSExt(aux,"$$DA-T-P+BD+RD+CX+SCX+IV,256,\"%s...\",16$$"); + ll->data=&l->filename.name; + LtfFormatData(ll); + + if (l->flags & LTFF_ALLOW_UNDO) { + LtfPutSExt(aux,"$$CM+BY+LX,0,1$$"); + ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Undo:%04d\"$$\r\n"); + ll->data=&l->undo_cnt; + LtfFormatData(ll); + } + + LtfPutSExt(aux,"$$CM+BY+RX,-24,1$$"); + ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$"); + ll->user_data=l; + ll->display_cb=&EditDollarTypeCB; + LtfPutSExt(aux,"$$CM+BY+RX,-21,1$$"); + ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$"); + ll->user_data=l; + ll->display_cb=&EditOverStrikeCB; + LtfPutSExt(aux,"$$CM+BY+RX,-20,1$$"); //gets merged without this + ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$"); + ll->user_data=l; + ll->display_cb=&EditDollarCB; + + ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Line:%04d \"$$"); + ll->data=&l->line; + LtfFormatData(ll); + ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Col:%04d\"$$\r\n"); + ll->data=&l->col; + LtfFormatData(ll); + + old_preempt=Preempt(OFF); + aux->recalc_start=aux; + LtfRecalc(aux); + Fs->aux_ltf=aux; + l->recalc_start=l; + LtfRecalc(l); + if (home) + LtfHome(l); + Fs->cur_ltf=l; + Fs->text_attribute=l->text_attribute; + AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,l->menu_ltf); + Fs->update_win=&LtfUpdateBothLtf; + Bts(&Fs->crt_flags,CRTf_SHOW); + do { + Preempt(OFF); + if (ScanKey(&ch,&sc)) { + Preempt(old_preempt); + PutKey(ch,sc); + LtfRecalc(Fs->cur_ltf); + } else { + Fs->task_flags|=1<rmt_chnl && + !(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) { + Fs->task_flags|=1<task_flags&=~(1<cur_ltf=old_ltf; + Fs->aux_ltf=old_aux; + AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,old_ltf->menu_ltf); + Fs->text_attribute=old_attribute; + Fs->update_win=old_update; + LtfDel(aux); + if (menu) { + l->menu_ltf=NULL; + LtfDel(menu); + } + Preempt(old_preempt); + return ch==CH_ESC; +} + + +#help_index "Ltf/Input" +public BoolU4 DoForm(U1 *D,I1 *class_name, + I1 *help=NULL,BoolU4 help_is_file=FALSE, + I1 *header=NULL,I1 *footer=NULL) +//Supply a class name that has fmtstr definitions +//and this routine will allow user input. +{ + BoolU4 result=FALSE,old_preempt; + MemberListStruct *ml; + LtfEntry *ll; + I8 ch=0; + ClassStruct *cl=FindLocalHash(class_name,HTT_CLASS); + Ltf *l; + if (!cl) return FALSE; + l=LtfNew; + if (header) LtfPutSExt(l,header); + l->flags|=LTFF_OVERSTRIKE | LTFF_FORM; + ml=cl->member_list; + while (ml) { + if (ml->fmtstr) { + ll=LtfPutSExt(l,ml->fmtstr); + ll->data=D+ml->offset; + ll->my_format_data=ml->fmtdata; + LtfFormatData(ll); + } + ml=ml->next; + } + if (footer) LtfPutSExt(l,footer); + if (l->dummy.next!=l) { + l->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME); + LtfRecalc(l); + if (DoLtf(l,TRUE,help,help_is_file)) { + old_preempt=Preempt(OFF); + ll=l->dummy.next; + while (ll!=l) { + if (ll->btype==LTFT_DATA || ll->btype==LTFT_CHECK_BOX) + LtfGetData(ll); + ll=ll->next; + } + ll=l->cur_entry; + if (ll!=l) + LtfRunEntry(l,ll,TRUE,old_preempt); + Preempt(old_preempt); + result=TRUE; + } + } + LtfDel(l); + return result; +} + +void EndDoMenuCb() +{ + WinToTop; + throw(EXCEPT_LOCAL); +} + +public I8 DoMenu(Ltf *m,I1 *help=NULL,U8 flags=0) +{ + void *old_end_cb=Fs->end_task_cb; + LtfEntry *ll; + I8 result=-1; + BoolU4 old_preempt; + Fs->end_task_cb=&EndDoMenuCb; + try { + if (m) { + m->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME); + if (DoLtf(m,TRUE,help)) { + old_preempt=Preempt(OFF); + ll=m->cur_entry; + if (ll!=m) + result=LtfRunEntry(m,ll,TRUE,old_preempt); + Preempt(old_preempt); + } + } + } catch { + if (Fs->except_argc==1 && Fs->except_argv[0]==EXCEPT_LOCAL) { + if (!(flags & LTFPUF_INTERCEPT_TASK_END)) + Exit; + Fs->catch_except=TRUE; + Preempt(old_preempt); + } + } + Fs->end_task_cb=old_end_cb; + return result; +} + +#help_index "Ltf" +public I8 PopUp(I1 *msg,TssStruct *parent=NULL,TssStruct **pu_tss=NULL) +{ + U8 result=0; + BoolU4 old_preempt=Preempt(OFF); + TssCmdStruct *tempc; + TssStruct *tss; + tss=Spawn(&ServantUserCmdLine,"SYSTEM TASK",parent); + if (!parent) { + QueueTaskRequest(tss,parent,msg,(1<popup_tss=tss; + tempc=QueueTaskRequest(tss,parent,msg, + 1<popup_tss=NULL; + Kill(tss); + if (pu_tss) *pu_tss=NULL; + Preempt(old_preempt); + return result; + } +} + +#help_index "Ltf/Output" +public TssStruct *PopUpViewLtf(Ltf *l,I1 *help=NULL) +{ + I1 *buf=MSPrintF("Preempt(ON);DoLtf(0x%X,TRUE,0x%X);",l,help); + TssStruct *tss=Spawn(&ServantUserCmdLine,"View",Fs); + QueueTaskRequest(tss,NULL,buf,1<user_data0); + Exit; +} + +public TssStruct *PopUpViewStr(I1 *msg) +{ + TssStruct *tss; + Ltf *l=LtfNew; + LtfPrintF(l,msg); + tss=PopUpViewLtf(l); + tss->user_data0=l; + tss->end_task_cb=&PopUpViewStrEndTsk; + return tss; +} + +#help_index "Ltf/Input" +public I8 PopUpMenu(Ltf *l,I1 *help=NULL,U8 flags=0) +{ + l->flags|=LTFF_MIN_SIZE | LTFF_FORM; + return ServantUser("DoMenu(0x%X,0x%X,0x%X);",l,help,flags); +} + +void LTDirEntryToFileLtf(Ltf *l,LTDirEntry *tempm) +{ + LtfEntry *ll; + while (tempm) { + if (tempm->attr & LT_ATTR_DIR) { + ll=LtfPrintF(l,"$$TR,\"%s\"$$",tempm->name); + ll->user_data=tempm; + LtfPutSExt(l,"\r\n$$ID,+2$$"); + if (tempm->sub) + LTDirEntryToFileLtf(l,tempm->sub); + LtfPutSExt(l,"$$ID,-2$$"); + } else + LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n", + tempm->name,tempm); + tempm=tempm->next; + } +} + +public I1 *PopUpPickFile(I1 *mask="/*",I1 *flags=NULL) +{ + I1 *result=NULL; + LTDirEntry *tempm,*tempm1; + U8 f=0; + Ltf *l=LtfNew; + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r"); + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags); + tempm=FindFiles(mask,f); + LtfPutSExt(l,"$$TR-C+AL,\"\"$$\r\n"); + LtfPutSExt(l,"$$ID,+2$$"); + LTDirEntryToFileLtf(l,tempm); + LtfPutSExt(l,"$$ID,-2$$"); + tempm1=PopUpMenu(l); + if (tempm1full_name); + else + result=NewStr(""); + LtfDel(l); + DelLTDirList(tempm); + return result; +} + +#help_index "Ltf/Output" +public void LTDirEntryToDirLtf(Ltf *l,LTDirEntry *tempm) +{ + while (tempm) { + LtfPrintF(l,"$$TR,\"\"$$"); + LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n", + tempm->name,tempm); + LtfPutSExt(l,"$$ID,+2$$"); + if (tempm->sub) + LTDirEntryToDirLtf(l,tempm->sub); + LtfPutSExt(l,"$$ID,-2$$"); + tempm=tempm->next; + } +} + +#help_index "Ltf/Input" +public I1 *PopUpPickDir(I1 *mask="/*",I1 *flags=NULL) +{ //+r=recurse +D=just dirs + I1 *result=NULL; + LTDirEntry *tempm,*tempm1; + U8 f=0; + Ltf *l=LtfNew; + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r+D"); + GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags); + tempm=FindFiles(mask,f); + LtfPutSExt(l,"$$TR-C+AL,\"\"$$\r\n"); + LtfPutSExt(l,"$$ID,+2$$"); + LTDirEntryToDirLtf(l,tempm); + LtfPutSExt(l,"$$ID,-2$$"); + tempm1=PopUpMenu(l); + if (tempm1full_name); + else + result=NewStr(""); + LtfDel(l); + DelLTDirList(tempm); + return result; +} + +#help_index "Ltf" +public BoolU4 PopUpCd() +{ + I1 *st=PopUpPickDir; + BoolU4 result=Cd(st); + Free(st); + return result; +} + +#help_index "Ltf/Input" +public I1 *PopUpPickListEntry(I1 *lst) +{ + I8 i=0; + Ltf *l=LtfNew; + while (*lst) { + if (*lst=='@') { /* Check for '@' alias list entry*/ + i--; + lst++; + } + LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n", + lst,i++); + lst+=StrLen(lst)+1; + } + LtfPrintF(l,"$$MU,\"CANCEL\",-1$$\r\n"); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +public I1 *PopUpPickSysTextSub(I1 *st) +{ + return PopUpPickListEntry(SysText(st)); +} + +public BoolU4 PopUpDoForm(U1 *d,I1 *class_name, + I1 *help=NULL,BoolU4 help_is_file=FALSE) +{ //TODO: add header/footer + BoolU4 result; + result=ServantUser("DoForm(0x%X,\"%s\",0x%X,%d);",d,class_name,help,help_is_file); + return result; +} + +public I8 PopUpOk(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM +CX,0,4$$$$BT, \"OKAY\" 1$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +public I8 PopUpNoYes(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM +LX, 2,4$$$$BT, \"YES\",1$$"); + LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"NO\",0$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +public I8 PopUpCancelOk(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM +LX, 2,4$$$$BT, \"OK\",1$$"); + LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",0$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +public I8 PopUpReplaceSkipAllCancel(I1 *header=NULL,I1 *footer=NULL) +{ + I8 i; + Ltf *l=LtfNew; + if (header) LtfPutSExt(l,header); + LtfPutSExt(l,"$$CM +LX,2,4$$$$BT, \"REPLACE\",0$$"); + LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"SKIP\",1$$"); + LtfPutSExt(l,"$$CM +LX, 2,3$$$$BT, \"ALL\",2$$"); + LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",3$$"); + if (footer) LtfPutSExt(l,footer); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +#help_index "Ltf/Input;Input Pointer" +public I8 PopUpInputPointer() +{ + I8 i; + Ltf *l=LtfNew; + LtfPutSExt(l,"$$CM+LX,2,4$$$$BT,\"Mouse\",IP_MOUSE$$"); + LtfPutSExt(l,"$$CM+LX,18,0$$$$BT,\"JoyStick\",IP_JOYSTICK0$$"); + i=PopUpMenu(l); + switch (i) { + case IP_MOUSE: + ip_pointer_type=i; + break; + case IP_JOYSTICK0: + ip_pointer_type=i; + LoadJoystickCalibration; + break; + } + LtfDel(l); + return i; +} +#help_index "Ltf" + diff --git a/LT/Adam/Ltf/LtfRecalc.APZ b/LT/Adam/Ltf/LtfRecalc.APZ new file mode 100644 index 0000000..84bba98 --- /dev/null +++ b/LT/Adam/Ltf/LtfRecalc.APZ @@ -0,0 +1,1657 @@ +I8 LtfCharDist(Ltf *l,I8 x,I8 y) +{ + I8 dx=(l->x-x)*FONT_WIDTH,dy=(l->y-y)*FONT_HEIGHT; + return dx*dx+dy*dy; +} + +I1 ltf_spaces[9]= +{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0}; + +void LtfUpdateWinJoin(Ltf *l,BoolU4 to_screen,BoolU4 has_cursor, + BoolU4 recalc,BoolU4 find_cur_entry,BoolU4 preempt, + LtfEntry *pg_found=NULL,I8 num_del_entries=0) +{ + I8 i,ii,j,k,x,x0,y,y0,D,d2,col,col2,best_col=0,best_d=MAX_I8; + I8 num_entries=0; + LtfEntry *cl,*cl2,*best_cl=l->cur_entry,*alias,*next_pg_found=NULL; + I8 ijif; + U8 w,w1; + U1 *bptr; + BoolU4 del_cl,skipped_update,tree_collapsed; + U8 hide_collapsed[2]; + TssStruct *win_tss=l->win_tss,*mem_tss=l->mem_tss,*tss1; + BoolU4 pg_found_present=pg_found?TRUE:FALSE,resize=FALSE; + BoolU4 extra_processing,same_win; + BoolU4 revert_default_color_eol=FALSE; + BoolU4 old_preempt=Preempt(preempt); + BoolU4 blink_flag=(Jiffies/(JIFFY_FREQ/5))&1; + GrBitMap *base=GrAlias(grbase2,win_tss); + I8 cursor_y=MIN_I8,left_margin=win_tss->win_left,right_margin=win_tss->win_right; + I8 y_plot_top,y_plot_bottom; + U1 *ptr,buf[16],ch; + U4 *u4_ptr; + I8 top_menu_left_x=0,top_menu_y=0,top_menu_row_height=FONT_HEIGHT; + I8 top_menu_right_x=win_tss->win_right*FONT_WIDTH; + I8 saved_x,saved_y; + BoolU4 use_saved_xy,full_refresh,restored_state; + + if (!l) return; +// if (!LtfCheck(l)) +// DbgStr("LtfJoin1",10000); + if (to_screen || find_cur_entry) { + recalc=TRUE; + l->recalc_start=l; + } + + i=win_refresh/10+1; + if (Bt(&l->flags,LTFf_DO_FULL_UPDATE) || + !to_screen || !(l->refresh_cnt%i) || + (l->flags<FF_BACKWARD_MOVEMENT)) + full_refresh=TRUE; + else + full_refresh=FALSE; + + if (has_cursor && full_refresh) { + if (Btr(&win_tss->crt_flags,CRTf_HAS_BEEN_RESIZED)) + resize=TRUE; + + if (Btr(&win_tss->crt_flags,CRTf_SCROLL_X)) { + if (i=right_margin-left_margin+1) + l->line_start_col=win_tss->scroll_x*(l->max_x-l->min_x+1)/i+l->min_x; + } + if (Btr(&win_tss->crt_flags,CRTf_SCROLL_Y)) { + if (i=win_tss->win_bottom-win_tss->win_top+1) + l->cur_top_line_num=win_tss->scroll_y*(l->max_y-l->min_y+1)/i+l->min_y; + } + } + x=0; y=0; + l->indent=0; + l->page_line_num=0; + l->left_margin=LTF_DEFAULT; + l->right_margin=LTF_DEFAULT; + l->header=LTF_DEFAULT; + l->footer=LTF_DEFAULT; + same_win=win_tss->win_top==l->old_win_top && + win_tss->win_bottom==l->old_win_bottom && + win_tss->win_left==l->old_win_left && + win_tss->win_right==l->old_win_right && + l->cur_entry==l->old_cur_entry && + l->cur_data_col==l->old_cur_data_col; + if (!find_cur_entry && full_refresh) { + l->x=0; + l->y=0; + } + l->flags&=~(LTFF_WORD_WRAP|LTFF_UNDERLINED|LTFF_INVERTED|LTFF_BLINK); + l->shifted_x=0; + l->shifted_y=0; + + x0=l->line_start_col; + y0=l->cur_top_line_num; + restored_state=FALSE; + if (to_screen) { + i=0; + j=0; + y_plot_top=y0-2; + y_plot_bottom=y0+2+win_tss->win_bottom-win_tss->win_top; + tss1=win_tss->next_tss; + while (tss1!=sys_update_screen_tss) { + if (tss1->win_left<=win_tss->win_left && + tss1->win_right>=win_tss->win_right && + Bt(&tss1->crt_flags,CRTf_SHOW)) { + if (tss1->win_bottom-win_tss->win_top+1>i && + tss1->win_top<=win_tss->win_top) + i=tss1->win_bottom-win_tss->win_top+1; + if (win_tss->win_bottom-tss1->win_top+1>j && + tss1->win_bottom>=win_tss->win_bottom) + j=win_tss->win_bottom-tss1->win_top+1; + } + tss1=tss1->next_tss; + } + y_plot_top+=i; + y_plot_bottom-=j; + if (cl=l->top_entry) { + while (cl->next!=l) + if (cl->ynext; + else + break; + while (cl->last!=l) + if (cl->y>=y_plot_top) + cl=cl->last; + else + break; + l->top_entry=cl; + if (l->flags & LTFF_TOP_ENTRY_COPIED && + cl!=l && + !full_refresh) { + MemCpy(&l->state_start, + &l->top_line_state_start, + offset(Ltf.state_end)- + offset(Ltf.state_start)); + w=l->w; + restored_state=TRUE; + } + } + } + if (!restored_state) { + l->text_attribute=l->start_text_attribute; + w=l->text_attribute<<8; + } + + if (recalc) { + if (to_screen) + l->flags&=~LTFF_MODIFIED; + else + l->flags|=LTFF_MODIFIED; + + if (l->cur_data_col<=l->cur_entry->min_col) + l->cur_data_col=l->cur_entry->min_col; + if (!l->recalc_start) + cl=l; //skip update + else { + cl=l->recalc_start; + if (!full_refresh) + if (l->top_entry) + cl=l->top_entry; + if (cl!=l) { + i=l->ww_lines_back; + ii=i/2; //Threshold for stopping on SOFT_CR + while (i-- && cl->btype!=LTFT_CR && + (i>ii || cl->btype!=LTFT_SOFT_CR) && + cl->flags & LTFLF_WORD_WRAP && + cl->last!=l) + cl=cl->last; + if (cl->flags & LTFLF_WORD_WRAP) + l->flags|=LTFF_WORD_WRAP; + else + l->flags&=~LTFF_WORD_WRAP; + if (cl->flags & LTFLF_UNDERLINED) { + l->flags|=LTFF_UNDERLINED; + w|=LTFLT_UNDERLINE; + } else + l->flags&=~LTFF_UNDERLINED; + if (cl->flags & LTFLF_INVERTED) { + l->flags|=LTFF_INVERTED; + w|=LTFLT_INVERT; + } else + l->flags&=~LTFF_INVERTED; + if (cl->flags & LTFLF_BLINK) { + l->flags|=LTFF_BLINK; + w|=LTFLT_BLINK; + } else + l->flags&=~LTFF_BLINK; + w|=cl->type&0x0C000000; + x=cl->x; y=cl->y; + l->indent=cl->indent; + l->page_line_num=cl->page_line_num; + l->left_margin=cl->left_margin; + l->right_margin=cl->right_margin; + } else + cl=l->dummy.next; + } + } else + cl=l->dummy.next; + if (cl==l->dummy.next) { + l->top_entry=NULL; + l->flags&=~LTFF_BACKWARD_MOVEMENT; + if (full_refresh) + l->flags&=~LTFF_HAS_SONG; + } + + if (l->dummy.next==l) { + best_cl=l; + best_col=0; + l->cur_entry=l; + l->top_entry=l; + l->cur_data_col=0; + cl=l; + + } + skipped_update=(cl==l && l->dummy.next!=l); + + extra_processing=recalc||find_cur_entry||resize; + + if (full_refresh) { + l->min_x=MAX_I4; l->min_y=MAX_I4; + l->max_x=MIN_I4; l->max_y=MIN_I4; + } + while (cl!=l) { + del_cl=FALSE; + if (cl->flags & LTFLF_SKIP) { + cl=cl->last; //for consistency handle skips the same + goto skip; + } + if (cl->flags & LTFLF_DISPLAY_CB) { + if (recalc || cl->flags & LTFLF_REFRESH_DATA) { + Free(cl->display,mem_tss); + cl->display=cl->display_cb(l,cl,mem_tss); + cl->max_col=StrLen(cl->display); + if (l->cur_entry==cl) { + if (l->cur_data_col>=cl->max_col && cl->max_col) + l->cur_data_col=cl->max_col-1; + } + } + } + if (extra_processing && full_refresh) { +word_wrap_start: + cl2=cl->next; + if (cl2->btype==LTFT_SOFT_CR) { + if (!same_win) { + if (l->cur_entry==cl2) { + l->cur_entry=cl2->next; + l->cur_data_col=l->cur_entry->min_col; + } + if (l->top_entry==cl2) + l->top_entry=cl2->next; + if (best_cl==cl2) { + best_cl=cl2->next; + best_col=0; + } + LtfDelEntry(l,cl2); + goto word_wrap_start; + } + } + if (cl->btype==LTFT_TEXT) { + if (cl->flags==cl2->flags && + cl->type==cl2->type) { + i=StrLen(cl->display); + j=StrLen(cl2->display); + ptr=MAlloc(i+j+1,mem_tss); + MemCpy(ptr,cl->display,i); + MemCpy(ptr+i,cl2->display,j+1); + Free(cl->display,mem_tss); + cl->display=ptr; + if (l->cur_entry==cl2) { + l->cur_entry=cl; + l->cur_data_col+=i; + } + if (l->top_entry==cl2) + l->top_entry=cl; + if (best_cl==cl2) { + best_cl=cl; + best_col=0; + } + LtfDelEntry(l,cl2); + goto word_wrap_start; + } + } + } + if (cl->flags & LTFLF_SCROLLING_X) + k=cl->scroll_len; + else if (Bt(ltf_display_types,cl->btype)) + k=StrLen(cl->display); + else + k=0; + use_saved_xy=FALSE; + if (cl->flags & + (LTFLF_LEFT_X|LTFLF_RIGHT_X|LTFLF_CENTER_X| + LTFLF_TOP_Y|LTFLF_BOTTOM_Y|LTFLF_CENTER_Y| + LTFLF_TOP_LEFT_MENU|LTFLF_TOP_RIGHT_MENU)) { + if (cl->flags & LTFLF_MARGIN_REL_X) { + if (cl->flags & LTFLF_LEFT_X) + x=left_margin-win_tss->win_left; + else if (cl->flags & LTFLF_RIGHT_X) + x=right_margin-(k-1)-win_tss->win_left; + else if (cl->flags & LTFLF_CENTER_X) + x=((right_margin+left_margin)>>1-k>>1-win_tss->win_left); + } else { + if (cl->flags & LTFLF_LEFT_X) + x=x0; + else if (cl->flags & LTFLF_RIGHT_X) + x=win_tss->win_right-win_tss->win_left+x0-(k-1); + else if (cl->flags & LTFLF_CENTER_X) + x=((win_tss->win_right-win_tss->win_left+x0-k)>>1); + } + if (cl->flags & LTFLF_TOP_LEFT_MENU) { + use_saved_xy=TRUE; + saved_x=x; + saved_y=y; + if (cl->btype==LTFT_TOP_LEFT_TOOLBAR) + i=cl->width; + else + i=k*FONT_WIDTH; + if (top_menu_left_x+i>top_menu_right_x) { + top_menu_y+=top_menu_row_height; + top_menu_row_height=FONT_HEIGHT; + top_menu_left_x=0; + top_menu_right_x=win_tss->win_right*FONT_WIDTH; + } + if (cl->btype==LTFT_TOP_LEFT_TOOLBAR && + cl->height>top_menu_row_height) + top_menu_row_height=cl->height; + y=top_menu_y/FONT_HEIGHT+y0; + x=x0+top_menu_left_x/FONT_WIDTH; + top_menu_left_x+=i; + } else if (cl->flags & LTFLF_TOP_RIGHT_MENU) { + use_saved_xy=TRUE; + saved_x=x; + saved_y=y; + if (cl->btype==LTFT_TOP_RIGHT_TOOLBAR) + i=cl->width; + else + i=k*FONT_WIDTH; + if (top_menu_left_x+i>top_menu_right_x) { + top_menu_y+=top_menu_row_height; + top_menu_row_height=FONT_HEIGHT; + top_menu_left_x=0; + top_menu_right_x=win_tss->win_right*FONT_WIDTH; + } + if (cl->btype==LTFT_TOP_RIGHT_TOOLBAR && + cl->height>top_menu_row_height) + top_menu_row_height=cl->height; + y=top_menu_y/FONT_HEIGHT+y0; + top_menu_right_x-=i; + x=x0+top_menu_right_x/FONT_WIDTH; + } + i=y; + if (cl->flags & LTFLF_PAGE_REL_Y) { + l->flags|=LTFF_BACKWARD_MOVEMENT; + if (cl->flags & LTFLF_TOP_Y) + y-=cl->page_line_num; + else if (cl->flags & LTFLF_BOTTOM_Y) + y+=l->page_length-cl->page_line_num; + else if (cl->flags & LTFLF_CENTER_Y) + y+=l->page_length>>1-cl->page_line_num; + } else { + l->flags|=LTFF_BACKWARD_MOVEMENT; + if (cl->flags & LTFLF_TOP_Y) + y=y0; + else if (cl->flags & LTFLF_BOTTOM_Y) + y=win_tss->win_bottom-win_tss->win_top+y0; + else if (cl->flags & LTFLF_CENTER_Y) + y=(win_tss->win_bottom-win_tss->win_top)>>1+y0; + } + if (y!=i) { + l->page_line_num+=y-i; + if (l->page_line_num<0) + l->page_line_num=l->page_length+l->page_line_num%l->page_length; + else + l->page_line_num=l->page_line_num%l->page_length; + if (l->header!=LTF_DEFAULT && + l->page_line_numheader) { + y+=l->header-l->page_line_num; + l->page_line_num=l->header; + } + if (l->footer==LTF_DEFAULT) { + if (l->page_line_num>=l->page_length) { + if (l->header==LTF_DEFAULT) + l->page_line_num=0; + else { + l->page_line_num=l->header; + y+=l->header; + } + } + } else { + if (l->page_line_num>=l->page_length-l->footer) { + y+=l->footer; + if (l->header==LTF_DEFAULT) + l->page_line_num=0; + else { + l->page_line_num=l->header; + y+=l->header; + } + } + } + } + } + + if (full_refresh &&extra_processing && k>0) { + if (l->flags & LTFF_WORD_WRAP) { + i=(right_margin+1-(x+win_tss->win_left)); //Space left ON line + ii=(x+1-l->left_margin); + if (cl->btype==LTFT_TEXT) { + if (l->cur_entry==cl->next) { + if (l->cur_data_col==cl->next->min_col) + i--; + } else { + if (l->cur_entry==cl) { + if (l->cur_data_col==i) + i--; + } + } + if (k>i) { + for (j=i;j>8-ii && j>=0;j--) + if (cl->display[j]==CH_SPACE || + cl->display[j]==CH_SHIFT_SPACE) { + i=j+1; + break; + } + if (k>i && i>0) { + cl2=MAllocIdentical(cl,mem_tss); + cl2->display=NewStr(cl->display+i,mem_tss); + InsQue(cl2,cl); + if (l->cur_entry==cl && l->cur_data_col>=i) { + l->cur_entry=cl2; + l->cur_data_col=l->cur_data_col-i; + } + cl->display[i]=0; + ptr=NewStr(cl->display,mem_tss); + Free(cl->display,mem_tss); + cl->display=ptr; + cl2=MAllocZ(sizeof(LtfEntryBase),mem_tss); + cl2->type=LTFT_SOFT_CR | cl->type & 0xFFFFFF00; + cl2->flags=cl->flags; + cl2->x=x; + cl2->y=y; + cl2->indent=l->indent; + cl2->page_line_num=l->page_line_num; + cl2->left_margin=l->left_margin; + cl2->right_margin=l->right_margin; + InsQue(cl2,cl); + k=StrLen(cl->display); + goto skip_soft_cr; + } + } + if (k==i) + goto skip_soft_cr; + } + if (k>=i && cl->btype!=LTFT_SOFT_CR && cl->btype!=LTFT_CR + && cl->btype!=LTFT_CURSOR_MOVEMENT) { + cl2=cl->last; + if (cl2->btype!=LTFT_SOFT_CR && + cl2->btype!=LTFT_CR && + cl2->btype!=LTFT_CURSOR_MOVEMENT) { + cl2=MAllocZ(sizeof(LtfEntryBase),mem_tss); + cl2->type=LTFT_SOFT_CR | cl->type & 0xFFFFFF00; + cl2->flags=LTFLF_WORD_WRAP | + cl->flags & (LTFLF_INVERTED|LTFLF_UNDERLINED| + LTFLF_BLINK|LTFLF_SKIP); + cl2->x=x; + cl2->y=y; + cl2->indent=l->indent; + cl2->page_line_num=l->page_line_num; + cl2->left_margin=l->left_margin; + cl2->right_margin=l->right_margin; + InsQue(cl2,cl->last); + if (l->left_margin==LTF_DEFAULT) + x=l->indent; + else + x=l->left_margin+l->indent; + y++; + } + cl2=cl->next; + } +skip_soft_cr: + } + } + if (full_refresh) { + cl->x=x; + cl->y=y; + cl->indent=l->indent; + cl->page_line_num=l->page_line_num; + cl->left_margin=l->left_margin; + cl->right_margin=l->right_margin; + if (xmin_x) l->min_x=x; + if (ymin_y) l->min_y=y; + + if (find_cur_entry) { + D=LtfCharDist(l,x,y); + col=0; + } + if (!l->top_entry) + if (y>=y_plot_top && to_screen) { + l->top_entry=cl; + l->w=w; + MemCpy(&l->top_line_state_start, + &l->state_start, + offset(Ltf.state_end)- + offset(Ltf.state_start)); + l->flags|=LTFF_TOP_ENTRY_COPIED; + } + } + col2=0; + + cl->type=w & 0xFF00 | cl->type & 0xFFFF00FF; + if (l->flags & LTFF_WORD_WRAP) + cl->flags|=LTFLF_WORD_WRAP; + else + cl->flags&=~LTFLF_WORD_WRAP; + if (l->flags & LTFF_UNDERLINED) { + cl->flags|=LTFLF_UNDERLINED; + w|=LTFLT_UNDERLINE; + } else { + cl->flags&=~LTFLF_UNDERLINED; + w&=~LTFLT_UNDERLINE; + } + if (l->flags & LTFF_INVERTED) { + cl->flags|=LTFLF_INVERTED; + w|=LTFLT_INVERT; + } else { + cl->flags&=~LTFLF_INVERTED; + w&=~LTFLT_INVERT; + } + if (l->flags & LTFF_BLINK) { + cl->flags|=LTFLF_BLINK; + w|=LTFLT_BLINK; + } else { + cl->flags&=~LTFLF_BLINK; + w&=~LTFLT_BLINK; + } + w=w&0xFC00FF00|(l->shifted_x & 0x1F)<<16|(l->shifted_y & 0x1F)<<21; + switch (cl->btype) { + case LTFT_PICTURE: + case LTFT_PICWORD: + case LTFT_TOP_LEFT_TOOLBAR: + case LTFT_TOP_RIGHT_TOOLBAR: + if (cl->flags & LTFLF_LINK) + w1=w & 0xFFFF0000 | l->link_attribute<<8; + else if (cl->flags & + (LTFLF_LEFT_MACRO|LTFLF_LEFT_EXP)) + w1=w & 0xFFFF0000 | l->macro_attribute<<8; + else if (cl->flags & LTFLF_TREE) + w1=w & 0xFFFF0000 | l->tree_attribute<<8; + else + w1=w; + break; + case LTFT_LINK: + w1=w & 0xFFFF0000 | l->link_attribute<<8; + break; + case LTFT_MACRO: + case LTFT_MENU_VALUE: + w1=w & 0xFFFF0000 | l->macro_attribute<<8; + break; + case LTFT_ANCHOR: + w1=w & 0xFFFF0000 | l->anchor_attribute<<8; + break; + case LTFT_TREE: + w1=w & 0xFFFF0000 | l->tree_attribute<<8; + break; + case LTFT_HIDE_START: + case LTFT_HIDE_END: + w1=w & 0xFFFF0000 | l->hidden_attribute<<8; + break; + default: + w1=w; + } + w1=w1 & 0xFFFFFF00 | cl->type & 0xF3FF0000; + if (cl==l->cur_entry) { + if (cl->btype!=LTFT_TEXT) + w1^=0xFF00; + cursor_y=cl->y; + } + + + if (cl->flags & LTFLF_REFRESH_DATA) { + if (cl->btype==LTFT_DATA || cl->btype==LTFT_CHECK_BOX) + LtfFormatData(cl); + } + + ptr=cl->display; + if (cl->flags & LTFLF_TREE) { + if (StrLen(ptr)>=2) { + if (cl->flags & LTFLF_COLLAPSED) + *ptr++='+'; + else + *ptr++='-'; + *ptr++=']'; + } + } + if (cl->btype==LTFT_CHECK_BOX) { + if (k>=3) { + *ptr++='['; + if (cl->flags & LTFLF_CHECKED) + *ptr++='X'; + else + *ptr++=' '; + *ptr++=']'; + } + } else if (cl->btype==LTFT_HIDE_START) { + if (k>=2) { + *ptr++='<'; + if (cl->flags & LTFLF_COLLAPSED) + *ptr++='+'; + else + *ptr++='-'; + } + } else if (cl->btype==LTFT_HIDE_END) { + if (k>=1) + *ptr++='>'; + } + if (Bt(ltf_display_types,cl->btype)) { + if (cl->flags & LTFLF_SCROLLING_X) { + j=StrLen(cl->display); + if (j && cl->scroll_len) { + ijif=Jiffies*FONT_WIDTH*win_tss->scroll_speed/JIFFY_FREQ; + ijif=ijif%(j*FONT_WIDTH); + w1=w1 & 0xFFE0FF00| + ((FONT_WIDTH-1-ijif%FONT_WIDTH)<<16); +#assert FONT_WIDTH==8 + ijif>>=3; + ptr=cl->display; + for (k=0;kscroll_len;k++) { + ch=ptr[(ijif+k)%j]; + if (!Bt(displayable_chars_bitmap,ch)) ch='.'; + if (to_screen) { + if (cl->flags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) + PlotBorderChar(win_tss,w1+ch,x-x0,y-y0); + else + PlotWinChar(win_tss,w1+ch,x-x0,y-y0); + } + x++; + } + } + if (find_cur_entry) { + D=LtfCharDist(l,cl->x,cl->y); + col=cl->min_col; + } + col2=cl->scroll_len; //TODO This is flawed + } else { + ptr=cl->display; + if (cl->flags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) { + while (ch=*ptr++) { + if (to_screen) + PlotBorderChar(win_tss,w1+ch,x-x0,y-y0); + else + if (find_cur_entry) { + d2=LtfCharDist(l,x,y); + if (d2=y_plot_top && y<=y_plot_bottom) + PlotWinStr2(win_tss,ptr,k,w1,x-x0,y-y0); + col2+=k; + x+=k; + } else { + if (find_cur_entry) { + while (k--) { + d2=LtfCharDist(l,x,y); + if (d2btype) { + case LTFT_TEXT: + if (!col2) { + if (!(cl->flags & LTFLF_TREE) && recalc) + del_cl=TRUE; + } + break; + case LTFT_HEX_EDIT: + if (cl->flags & LTFLF_DATA_IS_PTR) + bptr=cl->data; + else + bptr=&cl->data; + k=cl->hex_edit_width; //columns + for (i=0;ilen;i=i+k) { + if (cl->flags & LTFLF_ZERO_BASED) + SPrintF(buf,"%08tX ",i); + else + SPrintF(buf,"%08tX ",bptr); + ptr=buf; + while (ch=*ptr++) { + if (to_screen) { + if (cl->flags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) + PlotBorderChar(win_tss,w1+ch,x-x0,y-y0); + else + PlotWinChar(win_tss,w1+ch,x-x0,y-y0); + } + if (find_cur_entry) { + d2=LtfCharDist(l,x,y); + if (d2cl->len) k=cl->len-i; + for (j=0;jflags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) + PlotBorderChar(win_tss,w1+ch,x-x0,y-y0); + else + PlotWinChar(win_tss,w1+ch,x-x0,y-y0); + } + if (find_cur_entry) { + d2=LtfCharDist(l,x,y); + if (d2hex_edit_width-k)*3; + for (j=0;jflags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) + PlotBorderChar(win_tss,w1+ch,x-x0,y-y0); + else + PlotWinChar(win_tss,w1+ch,x-x0,y-y0); + } + if (find_cur_entry) { + d2=LtfCharDist(l,x,y); + if (d2hex_edit_width*3+k+9; + } + break; + case LTFT_TAB: + k=(x+8) & ~7; + if (cl->flags & LTFLF_BORDER_PLOT && + !Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) { + while (x=y_plot_top && y<=y_plot_bottom) + PlotWinStr2(win_tss,ltf_spaces,k,w1,x-x0,y-y0); + x+=k; + } else { + if (find_cur_entry) { + while (k--) { + d2=LtfCharDist(l,x,y); + if (d2=y_plot_top && y<=y_plot_bottom) + PlotWinAttr(win_tss, + win_tss->win_right-win_tss->win_left+1-(x-x0), + w&0xFF00,x-x0,y-y0); + y++; + l->page_line_num++; +start_of_line: + if (l->left_margin==LTF_DEFAULT) + x=l->indent; + else + x=l->indent+l->left_margin; + if (revert_default_color_eol) { + revert_default_color_eol=FALSE; + w=w & 0xF000 | l->text_attribute<<8 & 0xF00; + } +adjust_xy: + i=l->indent+l->left_margin; + if (xpage_line_num<0) + l->page_line_num=l->page_length+l->page_line_num%l->page_length; + else { + if (l->page_line_num>=l->page_length) { + l->page_line_num-=l->page_length; + if (l->page_line_num>=l->page_length) + l->page_line_num=l->page_line_num%l->page_length; + } + } + if (l->header!=LTF_DEFAULT) { + if (l->page_line_numheader) { + y+=l->header-l->page_line_num; + l->page_line_num=l->header; + goto start_of_line; + } + } + if (l->footer==LTF_DEFAULT) { + if (l->page_line_num>=l->page_length) { + if (l->header==LTF_DEFAULT) + l->page_line_num=0; + else { + l->page_line_num=l->header; + y+=l->header; + } + goto start_of_line; + } + } else { + if (l->page_line_num>=l->page_length-l->footer) { + y+=l->footer; + if (l->header==LTF_DEFAULT) + l->page_line_num=0; + else { + l->page_line_num=l->header; + y+=l->header; + } + goto start_of_line; + } + } + cl->left_margin=l->left_margin; + cl->right_margin=l->right_margin; + cl->page_line_num=l->page_line_num; + break; + case LTFT_CURSOR_MOVEMENT: + l->flags|=LTFF_BACKWARD_MOVEMENT; + x+=cl->cursor_x_offset; + if (cl->flags & LTFLF_PAGE_REL_Y) { + i=l->page_line_num; + if (cl->flags & LTFLF_TOP_Y) + l->page_line_num=0; + else if (cl->flags & LTFLF_BOTTOM_Y) + l->page_line_num=l->page_length-1; + else if (cl->flags & LTFLF_CENTER_Y) + l->page_line_num=l->page_length>>1; + y+=l->page_line_num-i; + } + y+=cl->cursor_y_offset; + l->page_line_num+=cl->cursor_y_offset; + goto adjust_xy; + case LTFT_PAGE_BREAK: + l->flags|=LTFF_BACKWARD_MOVEMENT; + y+=l->page_length-cl->page_line_num; + l->page_line_num=0; + goto start_of_line; + case LTFT_INDENT: + if (cl->flags & LTFLF_LEFT_X) + l->indent=cl->attr; + else + l->indent+=cl->attr; + goto start_of_line; + case LTFT_PAGE_LENGTH: + l->page_length=cl->attr; + goto adjust_xy; + case LTFT_LEFT_MARGIN: + l->left_margin=cl->attr; + left_margin=win_tss->win_left+l->left_margin; + goto start_of_line; + case LTFT_RIGHT_MARGIN: + if (cl->flags & LTFLF_WIN_REL) + l->right_margin=win_tss->win_right-win_tss->win_left-cl->attr; + else + l->right_margin=cl->attr; + right_margin=win_tss->win_left+l->right_margin; + goto adjust_xy; + case LTFT_HEADER: + l->header=cl->attr; + goto adjust_xy; + case LTFT_FOOTER: + l->footer=cl->attr; + goto adjust_xy; + case LTFT_FOREGROUND_COLOR: + if (cl->attr==LTF_DEFAULT) + w=w & 0xF000 | l->text_attribute<<8 & 0xF00; + else + w=w & 0xF000 | cl->attr<<8; + break; + case LTFT_BACKGROUND_COLOR: + if (cl->attr==LTF_DEFAULT) + w=w & 0xF00 | l->text_attribute<<8 & 0xF000; + else + w=w & 0xF00 | cl->attr<<12; + if (to_screen) + win_tss->text_attribute=w>>8&0xFF; + break; + case LTFT_DEFAULT_FOREGROUND_COLOR: + if (cl->attr==LTF_DEFAULT) + w=w & 0xF000 | l->text_attribute<<8 & 0xF00; + else + w=w & 0xF000 | cl->attr <<8; + l->text_attribute=l->text_attribute & 0xF0 | cl->attr; + break; + case LTFT_DEFAULT_BACKGROUND_COLOR: + if (cl->attr==LTF_DEFAULT) + w=w & 0xF00 | l->text_attribute<<8 & 0xF000; + else + w=w & 0xF00 | cl->attr <<12; + l->text_attribute=l->text_attribute & 0xF | cl->attr<<4; + if (to_screen) + win_tss->text_attribute=w>>8&0xFF; + break; + case LTFT_LINK_FOREGROUND: + l->link_attribute=l->link_attribute & 0xF0 | cl->attr; + break; + case LTFT_LINK_BACKGROUND: + l->link_attribute=l->link_attribute & 0xF | cl->attr<<4; + break; + case LTFT_MACRO_FOREGROUND: + l->macro_attribute=l->macro_attribute & 0xF0 | cl->attr; + break; + case LTFT_MACRO_BACKGROUND: + l->macro_attribute=l->macro_attribute & 0xF | cl->attr<<4; + break; + case LTFT_ANCHOR_FOREGROUND: + l->anchor_attribute=l->anchor_attribute & 0xF0 | cl->attr; + break; + case LTFT_ANCHOR_BACKGROUND: + l->anchor_attribute=l->anchor_attribute & 0xF | cl->attr<<4; + break; + case LTFT_HIDDEN_FOREGROUND: + l->hidden_attribute=l->hidden_attribute & 0xF0 | cl->attr; + break; + case LTFT_HIDDEN_BACKGROUND: + l->hidden_attribute=l->hidden_attribute & 0xF | cl->attr<<4; + break; + case LTFT_TREE_FOREGROUND: + l->tree_attribute=l->tree_attribute & 0xF0 | cl->attr; + break; + case LTFT_TREE_BACKGROUND: + l->tree_attribute=l->tree_attribute & 0xF | cl->attr<<4; + break; + case LTFT_USER_FOREGROUND: + if (cl->attr==LTF_DEFAULT) { + w=w & 0xF000 | l->user_attribute<<8 & 0xF00; + if (y==cursor_y) { + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + } + } else + l->user_attribute=l->user_attribute & 0xF0 | cl->attr; + break; + case LTFT_USER_BACKGROUND: + if (cl->attr==LTF_DEFAULT) { + w=w & 0xF00 | l->user_attribute<<8 & 0xF000; + if (y==cursor_y) { + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + } + } else + l->user_attribute=l->user_attribute & 0xF | cl->attr<<4; + break; + case LTFT_WORD_WRAP: + if (cl->attr) + l->flags|=LTFF_WORD_WRAP; + else + l->flags&=~LTFF_WORD_WRAP; + break; + case LTFT_UNDERLINED: + if (cl->attr) + l->flags|=LTFF_UNDERLINED; + else + l->flags&=~LTFF_UNDERLINED; + break; + case LTFT_INVERTED: + if (cl->attr) + l->flags|=LTFF_INVERTED; + else + l->flags&=~LTFF_INVERTED; + break; + case LTFT_BLINK: + if (cl->attr) + l->flags|=LTFF_BLINK; + else + l->flags&=~LTFF_BLINK; + break; + case LTFT_SHIFTED_X: + l->shifted_x=cl->attr; + break; + case LTFT_SHIFTED_Y: + l->shifted_y=cl->attr; + break; + case LTFT_CURSOR: + if (!find_cur_entry && !(l->flags & LTFF_NO_CURSOR)) { + l->cur_entry=cl->next; + l->cur_data_col=l->cur_entry->min_col; + } + del_cl=TRUE; + break; + case LTFT_PICTURE: + case LTFT_PICWORD: + case LTFT_TOP_LEFT_TOOLBAR: + case LTFT_TOP_RIGHT_TOOLBAR: + if (!cl->bin_data) + cl->bin_data=LtfFindBin(l,cl->bin_num); + if (cl->bin_data) { + GrReset(base); + base->flags&=~(BMF_DONT_DRAW|BMF_LOCATE_NEAREST|BMF_TRANSFORMATION); + if (!to_screen) + base->flags|=BMF_DONT_DRAW; + i=((w1>>12)&0xF)^(win_tss->text_attribute>>4 & 0xF); + if (w1 & LTFLT_SELECTED) + i^=0xF; + if (w1 & LTFLT_INVERT) + i^=0xF; + if (blink_flag && (cl==l->cur_entry || w1<FLT_BLINK)) + i^=0xF; + base->color=i; + if (find_cur_entry) + base->flags|=BMF_LOCATE_NEAREST; + base->nearest_sub_grelem=0; + base->nearest_dist=MAX_I8; + if (to_screen && (l->cur_GrElem==cl->bin_data->data)) { + base->flags|=BMF_LOCATE_NEAREST; + base->cur_x=ipx; + base->cur_y=ipy; + } else { + base->cur_x=(l->x-x0)*FONT_WIDTH+win_tss->win_pixel_left; + base->cur_y=(l->y-y0)*FONT_HEIGHT+win_tss->win_pixel_top; + } + base->cur_z=0; + base->bkcolor=i; + if (cl->flags & LTFLF_FROM_START) + GrElemsPlot(base,(x-k-x0)*FONT_WIDTH, //TODO: scrolling text is not length k + (y-y0)*FONT_HEIGHT,0,cl->bin_data->data); + else + GrElemsPlot(base,(x-x0)*FONT_WIDTH, + (y-y0)*FONT_HEIGHT,0,cl->bin_data->data); + if (to_screen && (l->cur_GrElem==cl->bin_data->data)) + l->cur_sub_grelem=base->nearest_sub_grelem; + base->flags&=~(BMF_LOCATE_NEAREST|BMF_DONT_DRAW); + if (base->nearest_dist<=D) { + D=base->nearest_dist; + col=cl->min_col; + } + } + break; + case LTFT_BPT: + w=w & 0xF000 | RED<<8; + revert_default_color_eol=TRUE; + break; + case LTFT_SONG: + if (sys_cur_focus_task==win_tss && to_screen) { + if (StrCmp(cur_song,cl->song)) { + AFree(cur_song); + ResetMusicSettings; + cur_song=ANewStr(cl->song); + } + } + l->flags|=LTFF_HAS_SONG; + break; + case LTFT_CLEAR: + if (recalc) { + if (pg_found==cl) { + del_cl=TRUE; + pg_found=NULL; + } else + next_pg_found=cl; + } + break; + } + + if (cl->flags & LTFLF_HAS_BORDER) { + if (cl->flags & LTFLF_SOLID_BORDER) + DrawBorder(win_tss,1,cl->x-x0,x-x0-1,cl->y-y0,y-y0,w1.u1[1],TRUE); + else + DrawBorder(win_tss,0,cl->x-x0,x-x0-1,cl->y-y0,y-y0,w1.u1[1],TRUE); + } + if (full_refresh) { + switch (cl->btype) { + case LTFT_CHECK_BOX: + case LTFT_HIDE_START: + cl->max_col=2; + break; + case LTFT_TREE: + case LTFT_BUTTON: + case LTFT_LINK: + case LTFT_MENU_VALUE: + case LTFT_MACRO: + case LTFT_HIDE_END: + cl->max_col=1; + break; + default: + cl->max_col=(cl->flags & LTFLF_TREE) ? 1:col2; + } + + if (x>l->max_x) l->max_x=x; + if (y>l->max_y) l->max_y=y; + if (D<=best_d) { + best_d=D; + best_cl=cl; + best_col=col; + } + if (cl->flags & LTFLF_TREE) { + if (cl->flags & LTFLF_ALIAS) + alias=cl; + else + alias=NULL; + if (cl->flags & LTFLF_COLLAPSED) + tree_collapsed=TRUE; + else + tree_collapsed=FALSE; + cl2=cl->next; + while (cl2!=l && cl2->btype!=LTFT_INDENT && !(cl2->flags & LTFLF_TREE)) + cl2=cl2->next; + if (cl2->btype==LTFT_INDENT) { + i=l->indent; + j=i; + do { + if (tree_collapsed) + cl2->flags|=LTFLF_SKIP; + else + cl2->flags&=~LTFLF_SKIP; + if (alias && cl2==l->cur_entry && Bt(ltf_display_types,cl2->btype)) { + Free(alias->display,mem_tss); + alias->display=MAlloc(StrLen(cl2->display)+8,mem_tss); + alias->display[0]='+'; + alias->display[1]=']'; + alias->display[2]=CH_SPACE; + StrCpy(alias->display+3,cl2->display); + alias->max_col=cl2->max_col+3; + } + if (cl2->btype==LTFT_INDENT) { + if (cl2->flags & LTFLF_LEFT_X) + j=cl2->attr; + else + j+=cl2->attr; + } + cl2=cl2->next; + } while (cl2!=l && j>i); + } + } + if (cl->btype == LTFT_HIDE_START) { + if (cl->flags & LTFLF_ALIAS) + alias=cl; + else + alias=NULL; + cl2=cl->next; + Btr(hide_collapsed,0); + j=1; + AssignBit(hide_collapsed,j,cl->flags & LTFLF_COLLAPSED); + while (cl2!=l && j>0) { + if (Bt(hide_collapsed,j)) + cl2->flags|=LTFLF_SKIP; + else + cl2->flags&=~LTFLF_SKIP; + if (cl2->btype==LTFT_HIDE_START) { + j++; + AssignBit(hide_collapsed,j,cl2->flags & LTFLF_COLLAPSED); + if (Bt(hide_collapsed,j-1)) + Bts(hide_collapsed,j); + } else if (cl2->btype==LTFT_HIDE_END) { + j--; + if (Bt(hide_collapsed,j)) + cl2->flags|=LTFLF_SKIP; + else + cl2->flags&=~LTFLF_SKIP; + } + cl2=cl2->next; + } + } + } + +skip: + cl2=cl->next; + while (cl2!=l && cl2->flags & LTFLF_SKIP) { + if (cl2==l->cur_entry) { + l->cur_entry=cl2->next; + l->cur_data_col=l->cur_entry->min_col; + } + if (full_refresh) { + cl2->x=x; + cl2->y=y; + cl2->indent=l->indent; + cl2->page_line_num=l->page_line_num; + cl2->left_margin=l->left_margin; + cl2->right_margin=l->right_margin; + cl2->type=w & 0xFF00 | cl2->type & 0xFFFF00FF; + if (l->flags & LTFF_WORD_WRAP) + cl2->flags|=LTFLF_WORD_WRAP; + else + cl2->flags&=~LTFLF_WORD_WRAP; + + if (l->flags & LTFF_UNDERLINED) { + cl2->flags|=LTFLF_UNDERLINED; + w|=LTFLT_UNDERLINE; + } else { + cl2->flags&=~LTFLF_UNDERLINED; + w&=~LTFLT_UNDERLINE; + } + + if (l->flags & LTFF_INVERTED) { + cl2->flags|=LTFLF_INVERTED; + w|=LTFLT_INVERT; + } else { + cl2->flags&=~LTFLF_INVERTED; + w&=~LTFLT_INVERT; + } + if (l->flags & LTFF_BLINK) { + cl2->flags|=LTFLF_BLINK; + w|=LTFLT_BLINK; + } else { + cl2->flags&=~LTFLF_BLINK; + w&=~LTFLT_BLINK; + } + } + cl2=cl2->next; + } + + if (full_refresh) { + if (del_cl || pg_found || num_entriesflags & LTFLF_HOLD)) { + if (cl==l->cur_entry) { + l->cur_entry=cl2; + l->cur_data_col=cl2->min_col; + } + if (cl==l->top_entry) + l->top_entry=cl2; + if (best_cl==cl) { + best_cl=cl2; + best_col=cl2->min_col; //TODO: might be bug + } + LtfDelEntry(l,cl); + } + } + } + if (use_saved_xy) { + x=saved_x; + y=saved_y; + } + num_entries++; + if (!full_refresh) + if (cl->y>y_plot_bottom) + break; + cl=cl2; + } + + if (full_refresh) { + if (l->min_x>l->max_x) { + l->max_x=0; + l->min_x=0; + } + if (l->min_y>l->max_y) { + l->max_y=0; + l->min_y=0; + } + + //Update header + if (!skipped_update) { + cl->x=x; + cl->y=y; + cl->indent=l->indent; + cl->page_line_num=l->page_line_num; + cl->left_margin=l->left_margin; + cl->right_margin=l->right_margin; + cl->type=w & 0xFF00 | cl->type & 0xFFFF00FF; + if (find_cur_entry) { + D=LtfCharDist(l,x,y); + if (Dflags & LTFF_MIN_SIZE) { + i=win_tss->win_left+l->max_x-l->min_x+1; + if (win_tss->win_right!=i) { + SetWinHorz(win_tss,win_tss->win_left,i); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + } + i=win_tss->win_top+l->max_y-l->min_y+1; + if (win_tss->win_bottom!=i) { + SetWinVert(win_tss,win_tss->win_top,i); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + } + } + if (find_cur_entry) { + l->cur_entry=best_cl; + l->cur_data_col=best_col; + LtfFormBackward(l); + + //We need this because text coordinates are used + if (best_dbest_d=best_d; + } + + if (l->cur_entry->btype!=LTFT_HEX_EDIT) { + l->y=l->cur_entry->y; + l->x=l->cur_entry->x+l->cur_data_col; + } else { + l->y=l->cur_entry->y+l->cur_data_col/3/l->cur_entry->hex_edit_width; + x=l->cur_data_col%(l->cur_entry->hex_edit_width*3); + i=x/l->cur_entry->hex_edit_width; + l->x=l->cur_entry->x+9; + if (i<2) + l->x+=x>>1*3+(x&1); + else + l->x+=l->cur_entry->hex_edit_width*3+ + (x-l->cur_entry->hex_edit_width<<1); + } + l->line=l->y+1; + l->col=l->x+1; + + if (has_cursor) { + if (l->cur_top_line_num+win_tss->win_bottom-win_tss->win_top>l->max_y) + l->cur_top_line_num=l->max_y-(win_tss->win_bottom-win_tss->win_top); + if (l->cur_top_line_nummin_y) + l->cur_top_line_num=l->min_y; + + if (l->y-l->cur_top_line_num>win_tss->win_bottom-win_tss->win_top) + l->cur_top_line_num=l->y-(win_tss->win_bottom-win_tss->win_top); + if (l->y-l->cur_top_line_num<0) + l->cur_top_line_num=l->y; + + if (l->line_start_col+win_tss->win_right-win_tss->win_left>l->max_x) + l->line_start_col=l->max_x-(win_tss->win_right-win_tss->win_left); + if (l->line_start_colmin_x) + l->line_start_col=l->min_x; + + if (l->x-l->line_start_col>win_tss->win_right-win_tss->win_left) + l->line_start_col=l->x-(win_tss->win_right-win_tss->win_left); + if (l->x-l->line_start_col<0) + l->line_start_col=l->x; + } + if (recalc) + l->recalc_start=NULL; + } + if (to_screen && has_cursor) { + y=l->y-l->cur_top_line_num+win_tss->win_top; + x=l->x-l->line_start_col+win_tss->win_left; + if (x<=win_tss->win_right && y<=win_tss->win_bottom && + x>=0 && y>=0 && + xmax_x-l->min_x+1) + win_tss->scroll_x=(((l->line_start_col-l->min_x)* + (win_tss->win_right-win_tss->win_left+1)+i-1)/i); + + if (i=l->max_y-l->min_y+1) + win_tss->scroll_y=((l->cur_top_line_num-l->min_y)* + (win_tss->win_bottom-win_tss->win_top+1)+i-1)/i; + } + if (!Bt(&win_tss->crt_flags,CRTf_NO_BORDER)) { + PlotBorderChar(win_tss,140+(win_tss->border_attribute<<8), + (win_tss->win_right-win_tss->win_left+1),win_tss->scroll_y); + PlotBorderChar(win_tss,140+(win_tss->border_attribute<<8), + win_tss->scroll_x,(win_tss->win_bottom-win_tss->win_top+1)); + } + } + if (!same_win && extra_processing) { + l->old_win_top=win_tss->win_top; + l->old_win_bottom=win_tss->win_bottom; + l->old_win_left=win_tss->win_left; + l->old_win_right=win_tss->win_right; + l->old_cur_entry=l->cur_entry; + l->old_cur_data_col=l->old_cur_data_col; + } +// if (!LtfCheck(l)) +// DbgStr("LtfJoin2",10000); + if (l->flags & LTFF_HAS_SONG) + Bts(&win_tss->task_flags,TSSf_HAS_SONG); + if (recalc && full_refresh) { + if (!num_del_entries && !pg_found_present) { + l->recalc_start=l; + if (next_pg_found) + LtfUpdateWinJoin(l,to_screen,has_cursor,recalc,find_cur_entry,preempt,next_pg_found,0); + else { + i=num_entries-l->max_entries; + if (i>1024) + LtfUpdateWinJoin(l,to_screen,has_cursor,recalc,find_cur_entry,preempt,NULL,i); + } + } + } + if (to_screen) + l->refresh_cnt++; + Preempt(old_preempt); + GrDel(base); +} + +public I8 LtfWordsToPics(Ltf *l=NULL,LtfEntry *start=NULL) +{ + PicWordEntry *temppw; + I1 *ptr,*ptr2,ch,*st,cnt=0; + TssStruct *mem_tss; + BoolU4 old_preempt=Preempt(OFF); + LtfBinEntry *tempb; + LtfEntry *cl,*cl2,*ll; + if (!l) { + l=Fs->cur_ltf; + if (!l) return 0; + } + mem_tss=l->mem_tss; + if (start) + cl=start; + else + cl=l->dummy.next; + while (cl!=l) { + if (cl->btype==LTFT_TEXT && + !(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED | + LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) { + ptr=cl->display; + while (*ptr) { + while (*ptr==CH_SPACE || *ptr==CH_SHIFT_SPACE) + ptr++; + ptr2=ptr; + while ((ch=*ptr) && ch!=CH_SPACE && ch!=CH_SHIFT_SPACE) + ptr++; + if (*ptr2) { + *ptr=0; + if (temppw=FindLocalHash(ptr2,HTT_PIC_WORD)) { + *ptr=ch; + *ptr2=0; + cl2=MAllocIdentical(cl,mem_tss); + cl2->display=NewStr(ptr,mem_tss); + cl ->max_col=StrLen(cl ->display); + cl2->max_col=StrLen(cl2->display); + InsQue(cl2,cl); + + cnt++; + tempb=MAllocZ(sizeof(LtfBinEntry),mem_tss); + tempb->type=LTFBT_GRELEM; + tempb->size=temppw->size; + tempb->data=MAlloc(temppw->size,mem_tss); + MemCpy(tempb->data,temppw->grelem,temppw->size); + tempb->num=l->cur_bin_num; + InsQue(tempb,l->bin_root.last); + if (temppw->txt) + st=MSPrintF(temppw->txt,l->cur_bin_num++); + else + st=MSPrintF("PW,\"%*ts\",\"%s\",%d,%d,%d",temppw->width/FONT_WIDTH," ",temppw->str,l->cur_bin_num++,temppw->width,temppw->height); + ll=ParseDollarCmd(l,st); + Free(st); + ll->bin_data=tempb; + ll->aux_str=NewStr(temppw->str,mem_tss); + InsQue(ll,cl); + + if (l->cur_entry==cl && l->cur_data_col>=ptr2-cl->display) { + if (l->cur_data_col>=ptr-cl->display) { + l->cur_entry=cl2; + l->cur_data_col-=ptr-cl->display; + } else { + l->cur_entry=ll; + l->cur_data_col=0; + } + } + ptr=cl2->display; + cl=cl2; + } else + *ptr=ch; + } + } + } + cl=cl->next; + } + Preempt(old_preempt); + return cnt; +} + +public void LtfRecalc(Ltf *l=NULL) +{ + BoolU4 old_preempt=Preempt(OFF); + if (!l) { + l=Fs->cur_ltf; + if (!l) { + Preempt(old_preempt); + return; + } + } + if (l->recalc_start) { + if (l->recalc_start!=l) + LtfRemoveSoftCRs(l,l->recalc_start); + if (!(l->flags<FF_NO_PICWORDS) && + !(l->flags&(LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS))) { + if (l->recalc_start!=l) + LtfWordsToPics(l,l->recalc_start); + else + LtfWordsToPics(l,l->dummy.next); + } + } + LtfUpdateWinJoin(l,FALSE,FALSE,TRUE,FALSE,OFF); + Preempt(old_preempt); +} + +public void LtfSafeInsert(Ltf *l,I1 *st) +{ //This is necessary when hidden text might screw-up + //inserts. It does them all-at-once. + BoolU4 old_preempt=Preempt(OFF); + U8 old_flags; + if (!l) { + l=Fs->cur_ltf; + if (!l) { + Preempt(old_preempt); + return; + } + } + old_flags=l->flags; + l->flags|=LTFF_NO_CURSOR; + LtfPutSExt(l,st); + LtfRecalc(l); + l->flags=old_flags; + Preempt(old_preempt); +} + +public void LtfCenter(Ltf *l=NULL) +{ + BoolU4 old_preempt=Preempt(OFF); + TssStruct *tss; + if (!l) { + l=Fs->cur_ltf; + if (!l) { + Preempt(old_preempt); + return; + } + } + tss=l->win_tss; +//TODO: l->recalc_start=l; + LtfRecalc(l); + l->cur_top_line_num=l->y-(tss->win_bottom-tss->win_top)>>1; + Preempt(old_preempt); +} + +public void LtfBottom(Ltf *l=NULL) +{ + BoolU4 old_preempt=Preempt(OFF); + if (!l) { + l=Fs->cur_ltf; + if (!l) { + Preempt(old_preempt); + return; + } + } + l->cur_entry=l; + l->cur_data_col=0; + l->recalc_start=l; + LtfRecalc(l); + Preempt(old_preempt); +} + +public void LtfClear(Ltf *l=NULL) +{ + BoolU4 old_preempt=Preempt(OFF); + if (!l) { + l=Fs->cur_ltf; + if (!l) { + Preempt(old_preempt); + return; + } + } + LtfPutSExt(l,"$$CL$$"); + l->recalc_start=l; + LtfRecalc(l); + Preempt(old_preempt); +} + +public Ltf *LtfUpdateCurLtf(TssStruct *tss) +{ + Ltf *main; + if (main=tss->cur_ltf) { + if (tss->double_buf_cur_ltf) + main=tss->double_buf_cur_ltf; + LtfUpdateWinJoin(main,TRUE,TRUE,FALSE,FALSE,ON); + } + return main; +} + +public Ltf *LtfUpdateAuxLtf(TssStruct *tss) +{ + Ltf *aux; + if (aux=tss->aux_ltf) { + if (tss->double_buf_aux_ltf) + aux=tss->double_buf_aux_ltf; + LtfUpdateWinJoin(aux,TRUE,FALSE,FALSE,FALSE,ON); + } + return aux; +} + +public void LtfUpdateBothLtf(TssStruct *tss) +{ + LTPartition *p; + U1 attr=0; + Ltf *main,*aux; + + ClearWinText(tss); + if (main=LtfUpdateCurLtf(tss)) { + if (main->flags & LTFF_ATTR_BY_PARTITION) { + p=tss->cur_partition; + attr=p->text_attr; + } + if (main->flags & LTFF_ATTR_BY_FILENAME) { + try { + p=DriveToPartition(main->filename.name[0]); + } catch { + p=NULL; + Fs->catch_except=TRUE; + } + if (p) + attr=p->text_attr; + } + } + + if ((attr & 0xF)!=(attr>>4)) + tss->border_attribute=attr; + if (aux=LtfUpdateAuxLtf(tss)) { + if ((attr & 0xF)!=(attr>>4)) + aux->start_text_attribute=attr; + } +} + +ext[EXT_LTF_RECALC]=&LtfRecalc; + \ No newline at end of file diff --git a/LT/ADAM/MATH.CPZ b/LT/Adam/Math.APZ similarity index 80% rename from LT/ADAM/MATH.CPZ rename to LT/Adam/Math.APZ index 6f5a05a..e7ea0c7 100644 --- a/LT/ADAM/MATH.CPZ +++ b/LT/Adam/Math.APZ @@ -1,3 +1,5 @@ +#help_index "Math" + public double Abs(double i) { if (i<0) @@ -41,15 +43,6 @@ public double Unwrap(double theta,double base=-pi) return result; } - -public I8 AbsI8(I8 i) -{ - if (i<0) - return -i; - else - return i; -} - public I8 SignI8(I8 i) { if (i<0) @@ -62,11 +55,12 @@ public I8 SignI8(I8 i) public I8 SqrI8(I8 i) { - return MulI8(i,i); + return 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); + return dx*dx+dy*dy; } +#help_index "" diff --git a/LT/Adam/Message.APZ b/LT/Adam/Message.APZ new file mode 100644 index 0000000..a07a5f4 --- /dev/null +++ b/LT/Adam/Message.APZ @@ -0,0 +1,142 @@ +#help_index "Messages" + +void InputFilterTask() +{ + I1 *st; + TssCmdStruct *tempc,*tempc1; + BoolU4 old_filter; + U8 old_flags=GetFlags; + InitUserTask; + Bts(&Fs->task_flags,TSSf_INPUT_FILTER_TASK); + old_filter=Bts(&Fs->last_input_filter_tss->task_flags,TSSf_FILTER_INPUT); + AssignBit(&Fs->task_flags,TSSf_FILTER_INPUT,old_filter); + while (TRUE) { + HandleServantCmds; + Cli; + tempc1=&Fs->next_servant_cmd; + tempc=tempc1->next; + if (tempc==tempc1) + break; + else { + if (tempc->cmd_code==TSSCT_TEXT_INPUT) { + RemQue(tempc); + SetFlags(old_flags); + st=tempc->data; + AFree(tempc); + Preempt(ON); + try + ExecuteStr(st); + catch + Fs->catch_except=TRUE; + Preempt(OFF); + AFree(st); + } else + break; + } + } + Fs->next_input_filter_tss->last_input_filter_tss=Fs->last_input_filter_tss; + Fs->last_input_filter_tss->next_input_filter_tss=Fs->next_input_filter_tss; + if (!old_filter) + Btr(&Fs->last_input_filter_tss->task_flags,TSSf_FILTER_INPUT); + SetFlags(old_flags); +} + +public U8 ScanMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL) +{ + U8 result,old_flags; + TssCmdStruct *tempc,*tempc1; + BoolU4 old_preempt; + if (!tss) tss=Fs; + old_flags=GetFlags; + tempc1=&tss->next_servant_cmd; + while (TRUE) { + if (tss==Fs) + HandleServantCmds; + Cli; + tempc=tempc1->next; + if (tempc==tempc1) + break; + else { + if (tempc->cmd_code==TSSCT_MSG) { + RemQue(tempc); + SetFlags(old_flags); + result=tempc->msg_code; + *param1=tempc->p1; + *param2=tempc->p2; + AFree(tempc); + if (Bt(&mask,result)) + goto done_msg; + } + } + SetFlags(old_flags); + } + if (tss->rmt_chnl) { + old_preempt=Preempt(OFF); +start_rmt_msg: + if (Jiffies>=tss->rmt_chnl->null_msg_jiffy) { + if (result=RmtGetMsg(tss->rmt_chnl,param1,param2)) { + if (Bt(&mask,result)) { + Preempt(old_preempt); + return result; + } else + goto start_rmt_msg; + } + } + Preempt(old_preempt); + } + result=0; + *param1=0; + *param2=0; + if (tss->parent_tss) { + if (tss->parent_tss->popup_tss==tss) { + SetFlags(old_flags); + return ScanMsg(param1,param2,mask,tss->parent_tss); + } + } +done_msg: + SetFlags(old_flags); + return result; +} + +public U8 FlushMsgs(TssStruct *tss=NULL) +{ + U8 result=0,p1,p2; + while (ScanMsg(&p1,&p2,-2,tss)) + result++; + return result; +} + +public U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL) +{ + U8 result; + BoolU4 old_preempt=Preempt(OFF); + if (!tss) tss=Fs; + tss->task_flags&=~(1<task_flags|=1<task_flags&=~(1<end_task_cb=&EndCurSong; + while (TRUE) + Play(cur_song); +} + +#help_index "" diff --git a/LT/ADAM/ODE.CPZ b/LT/Adam/ODE.APZ similarity index 65% rename from LT/ADAM/ODE.CPZ rename to LT/Adam/ODE.APZ index aee49ba..ccae3d3 100644 --- a/LT/ADAM/ODE.CPZ +++ b/LT/Adam/ODE.APZ @@ -1,3 +1,5 @@ +#help_index "Math" + //This is taken from the book, $UL,1$Numeric Recipies in C$UL,0$ Ode *OdeNew(U8 n) @@ -5,7 +7,8 @@ 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->internal_state=MAllocZ(n*sizeof(double)); + o->base_t=GetTimeStamp*1.0/time_stamp_freq; o->h=1.0e-6; o->DstateDt=MAllocZ(n*sizeof(double)); o->state_scale=MAllocZ(n*sizeof(double)); @@ -19,12 +22,15 @@ Ode *OdeNew(U8 n) o->temp5=MAllocZ(n*sizeof(double)); o->temp6=MAllocZ(n*sizeof(double)); o->temp7=MAllocZ(n*sizeof(double)); + o->win_tss=Fs; + o->mem_tss=Fs; return o; } void OdeDel(Ode *o) { Free(o->state); + Free(o->internal_state); Free(o->DstateDt); Free(o->state_scale); Free(o->initial_state); @@ -42,9 +48,9 @@ void OdeDel(Ode *o) void OdeOneStep(Ode *o) { I8 i; - o->derivative(o,o->t+o->base_t,o->state,o->DstateDt); + o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt); for (i=0;in;i++) - o->state[i]+=o->h*o->DstateDt[i]; + o->internal_state[i]+=o->h*o->DstateDt[i]; o->t+=o->h; } @@ -62,42 +68,58 @@ void OdeRK4OneStep(Ode *o) h6 =o->h / 6.0; xh =o->t +o->base_t+ hh; - o->derivative(o,o->t+o->base_t,o->state,o->DstateDt); + o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt); for (i=0;istate[i]+hh*DstateDt[i]; + yt[i]=o->internal_state[i]+hh*DstateDt[i]; o->derivative(o,xh,yt,dyt); for (i=0;istate[i]+hh*dyt[i]; + yt[i]=o->internal_state[i]+hh*dyt[i]; o->derivative(o,xh,yt,dym); for (i=0;istate[i]+o->h*dym[i]; + yt[i]=o->internal_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;istate[i]+=h6*(DstateDt[i]+dyt[i]+2.0*dym[i]); + o->internal_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; - - +#define ODEa2 0.2 +#define ODEa3 0.3 +#define ODEa4 0.6 +#define ODEa5 1.0 +#define ODEa6 0.875 +#define ODEb21 0.2 +#define ODEb31 (3.0/40.0) +#define ODEb32 (9.0/40.0) +#define ODEb41 0.3 +#define ODEb42 (-0.9) +#define ODEb43 1.2 +#define ODEb51 (-11.0/54.0) +#define ODEb52 2.5 +#define ODEb53 (-70.0/27.0) +#define ODEb54 (35.0/27.0) +#define ODEb61 (1631.0/55296.0) +#define ODEb62 (175.0/512.0) +#define ODEb63 (575.0/13824.0) +#define ODEb64 (44275.0/110592.0) +#define ODEb65 (253.0/4096.0) +#define ODEc1 (37.0/378.0) +#define ODEc3 (250.0/621.0) +#define ODEc4 (125.0/594.0) +#define ODEc6 (512.0/1771.0) +#define ODEdc1 (37.0/378.0-2825.0/27648.0) +#define ODEdc3 (250.0/621.0-18575.0/48384.0) +#define ODEdc4 (125.0/594.0-13525.0/55296.0) +#define ODEdc5 (-277.0/14336.0) +#define 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; + double h=o->h,*state=o->internal_state,*DstateDt=o->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,*tempstate,*stateerr,*outstate; ak2=o->temp0; ak3=o->temp1; @@ -164,8 +186,9 @@ void OdeRK5OneStep(Ode *o) o->h*=5.0; if (o->h>1.0e32) o->h=1.0e32; - MemCpy(o->state,tempstate,sizeof(double)*o->n); + MemCpy(o->internal_state,tempstate,sizeof(double)*o->n); break; } } } +#help_index "" diff --git a/LT/Adam/PicWords2.APZ b/LT/Adam/PicWords2.APZ new file mode 100644 index 0000000..bb66d8c Binary files /dev/null and b/LT/Adam/PicWords2.APZ differ diff --git a/LT/ADAM/COMM.CPZ b/LT/Adam/Remote.APZ similarity index 52% rename from LT/ADAM/COMM.CPZ rename to LT/Adam/Remote.APZ index 7e643eb..f02b6c8 100644 --- a/LT/ADAM/COMM.CPZ +++ b/LT/Adam/Remote.APZ @@ -1,21 +1,4 @@ -#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 +#help_index "Comm" #define RMT_MAX_PKT_LEN 64 //Must be less then PKT_SYNC #define RMT_PKT_ACK 0xA5 @@ -24,7 +7,9 @@ #define RMT_PKT_SYNC2 0xA7 #define RMT_PKT_CHAR 0xA4 #define RMT_PKT_REQUEST 0xA6 -#define RMT_PKT_CLOSE 0xA8 +#define RMT_PKT_RESET 0xA8 + +#define RMT_FILE_ACK 0x87566565 #define RMT_RQST_NONE 0x00 #define RMT_RQST_GETMSG 0x01 @@ -35,150 +20,24 @@ #define RMT_RQST_EXE_LOCAL 0x06 #define RMT_RQST_PUTS_CNT 0x07 -#define RMT_RQST_MAX 0x08 +#define RMT_NUM_RQST_TYPES 0x08 -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); -} +#define RMT_CHAR_DELAY (JIFFY_FREQ/50) +#define RMT_TX_TIMEOUT_DELAY (JIFFY_FREQ) +#define RMT_RX_TIMEOUT_DELAY (JIFFY_FREQ) +#define RMT_NULL_MSG_DELAY (JIFFY_FREQ/20) 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)) + if (Bt(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED)) { + Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED2); + Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED3); 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; @@ -191,31 +50,48 @@ public void RmtWaitTxDone(LTChnl *chnl) if (!chnl || !chnl->type) return; while (RmtTxFifoCnt(chnl)) SwapInNext; + while (Bt(&comm_flags[chnl->port],COMMf_OUTGOING_XOFFED)) + SwapInNext; + while (Bt(&comm_flags[chnl->port],COMMf_TX_XOFF)) + SwapInNext; + while (Bt(&comm_flags[chnl->port],COMMf_TX_XON)) + SwapInNext; while (!(InP(base+UART_LSR) & 0x20)) SwapInNext; } -void Irq03Handler() +public void RmtFlushTxFifo(LTChnl *chnl) { - CommRxTxChar(2); - CommRxTxChar(4); + U8 base=comm_base[chnl->port]; + if (!chnl || !chnl->type) return; + U1FifoFlush(comm_Tx_fifos[chnl->port]); + RmtWaitTxDone(chnl); } -void Irq04Handler() +void RmtReset(LTChnl *chnl) { - CommRxTxChar(1); - CommRxTxChar(3); + RmtFlushTxFifo(chnl); + RmtFlushRxFifo(chnl); + comm_flags[chnl->port]=0; } -public U1 CommGetChar(U8 port) + + +public void RmtPrintF(LTChnl *chnl,I1 *src,...) { - U8 ch=0; - while (!U1FifoRemove(comm_Rx_fifos[port],&ch)) - SwapInNext; - if (Bt(&comm_flags[port],COMMf_INCOMING_XOFFED) && - U1FifoCnt(comm_Rx_fifos[port])mask>>2) - CommPutChar(port,CH_XON); - return ch; + 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 I8 RmtRxFifoCnt(LTChnl *chnl) +{ + if (!chnl || !chnl->type) return 0; + return U1FifoCnt(comm_Rx_fifos[chnl->port]); } public U1 RmtGetChar(LTChnl *chnl) @@ -225,100 +101,19 @@ public U1 RmtGetChar(LTChnl *chnl) 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])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) { + b==RMT_PKT_RESET) { chnl->PutChar(chnl,CH_ESC); chnl->PutChar(chnl,b^0x80); return 2; @@ -328,7 +123,7 @@ U8 RmtTxPktU1(LTChnl *chnl,U1 b) } } -BoolU4 RmtRxPktU1(LTChnl *chnl,U1 *b, +BoolU8 RmtRxPktU1(LTChnl *chnl,U1 *b, U8 timeout_jiffies,BoolU4 *esc=NULL) { U1 b1; @@ -338,12 +133,12 @@ BoolU4 RmtRxPktU1(LTChnl *chnl,U1 *b, *esc=FALSE; if (!chnl || !chnl->type) return FALSE; - timeout=jiffies+timeout_jiffies; - while (jiffiesScanChar(chnl,&b1)) { if (b1==CH_ESC) { - timeout=jiffies+timeout_jiffies; - while (jiffiesScanChar(chnl,&b1)) { *b=b1^0x80; if (esc) *esc=TRUE; @@ -353,9 +148,9 @@ BoolU4 RmtRxPktU1(LTChnl *chnl,U1 *b, } return FALSE; } else { - if (b1==RMT_PKT_CLOSE) { - Fs->rmt_chnl=NULL; - throw; + if (b1==RMT_PKT_RESET) { + RmtReset(chnl); + throw(EXCP_RESET); } *b=b1; return TRUE; @@ -366,95 +161,159 @@ BoolU4 RmtRxPktU1(LTChnl *chnl,U1 *b, return FALSE; } -void RmtTxPkt(LTChnl *chnl,U1 *p,U8 size,U8 rqst=RMT_RQST_NONE) -{ +#define ERR_DELAY 1 + +void RmtTxPkt(LTChnl *chnl,U1 *p,U8 size,U8 rqst=RMT_RQST_NONE, + U8 timeout_delay=0) +{ //zero timeout_delay=none U1 b,xsum; - U8 i; + U8 i,timeout_jiffy; if (!chnl || !chnl->type) return; + + if (!timeout_delay && (Fs->rmt_chnl==chnl || Fs->local_chnl==chnl)) { + timeout_delay=RMT_TX_TIMEOUT_DELAY; + if (Fs->rmt_chnl==chnl && + chnl->pkt_rx_jiffy+RMT_NULL_MSG_DELAY<<1timeout_jiffy) + throw(EXCP_TIMEOUT); RmtFlushTxFifo(chnl); + RmtFlushRxFifo(chnl); chnl->PutChar(chnl,RMT_PKT_REQUEST); RmtWaitTxDone(chnl); - RmtFlushRxFifo(chnl); + if (RmtScanChar(chnl,&b)) { + Sleep(ERR_DELAY); + goto rt_err1; + } RmtTxPktU1(chnl,rqst); RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&b,JIFFY_FREQ/50); - if (b!=RMT_PKT_ACK) + RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY); + if (b!=(RMT_PKT_ACK^RMT_PKT_REQUEST^rqst)&0xFF) { + Sleep(ERR_DELAY); goto rt_err1; + } } else if (size==1) { rt_err2: + if (Jiffies>timeout_jiffy) + throw(EXCP_TIMEOUT); RmtFlushTxFifo(chnl); + RmtFlushRxFifo(chnl); chnl->PutChar(chnl,RMT_PKT_CHAR); RmtWaitTxDone(chnl); - RmtFlushRxFifo(chnl); + if (RmtScanChar(chnl,&b)) { + Sleep(ERR_DELAY); + goto rt_err2; + } RmtTxPktU1(chnl,p[0]); RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&b,JIFFY_FREQ/50); - if (b!=RMT_PKT_ACK) + RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY); + if (b!=RMT_PKT_ACK^RMT_PKT_CHAR^p[0]) { + Sleep(ERR_DELAY); goto rt_err2; + } } else { rt_err3: + if (Jiffies>timeout_jiffy) + throw(EXCP_TIMEOUT); RmtFlushTxFifo(chnl); + RmtFlushRxFifo(chnl); RmtTxPktU1(chnl,RMT_PKT_SYNC); RmtWaitTxDone(chnl); - RmtFlushRxFifo(chnl); + if (RmtScanChar(chnl,&b)) { + Sleep(ERR_DELAY); + goto rt_err3; + } RmtTxPktU1(chnl,RMT_PKT_SYNC2); RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&b,JIFFY_FREQ/50); - if (b!=RMT_PKT_ACK) + RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY); + if (b!=RMT_PKT_ACK^RMT_PKT_SYNC) { + Sleep(ERR_DELAY); goto rt_err3; + } + if (RmtScanChar(chnl,&b)) { + Sleep(ERR_DELAY); + goto rt_err3; + } RmtTxPktU1(chnl,size); RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&b,JIFFY_FREQ/50); - if (b!=RMT_PKT_ACK) + RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY); + if (b!=(RMT_PKT_ACK^size)&0xFF) { + Sleep(ERR_DELAY); goto rt_err3; + } xsum=0x3A; for (i=0;ipkt_tx_jiffy=Jiffies; } -void RmtRxPkt(LTChnl *chnl,U1 *p,U8 *size=NULL,U8 *rqst=NULL) -{ +void RmtRxPkt(LTChnl *chnl,U1 *p,U8 *size=NULL,U8 *rqst=NULL, + U8 timeout_delay=0) +{ //zero timeout_delay=none U1 b,b1,xsum; - U8 i,s,r; + U8 i=0,s,r,timeout_jiffy; BoolU4 esc; + if (!chnl || !chnl->type) { if (size) *size=0; if (rqst) *rqst=0; return; } + + if (!timeout_delay && (Fs->rmt_chnl==chnl || Fs->local_chnl==chnl)) { + timeout_delay=RMT_RX_TIMEOUT_DELAY; + if (Fs->rmt_chnl==chnl && + chnl->pkt_rx_jiffy+RMT_NULL_MSG_DELAY<<12) RmtFlushRxFifo(chnl); s=0; r=0; - RmtRxPktU1(chnl,&b,JIFFY_FREQ); - RmtRxPktU1(chnl,&b1,JIFFY_FREQ/50,&esc); + RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY); + rr_cont: + if (Jiffies>timeout_jiffy) + throw(EXCP_TIMEOUT); + RmtRxPktU1(chnl,&b1,RMT_CHAR_DELAY,&esc); if (b==RMT_PKT_REQUEST) { - if (b1>=RMT_RQST_MAX) { + if (b1>=RMT_NUM_RQST_TYPES) { if (b1==RMT_PKT_REQUEST && !esc) goto rr_cont; else @@ -462,12 +321,18 @@ rr_cont: } r=b1; s=0; + if (RmtScanChar(chnl,&b)) + goto rt_err; + RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_REQUEST^b1); goto rr_exit; } else if (b==RMT_PKT_CHAR) { if (b1==RMT_PKT_CHAR && !esc) goto rr_cont; *p=b1; s=1; + if (RmtScanChar(chnl,&b)) + goto rt_err; + RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_CHAR^b1); goto rr_exit; } else if (b==RMT_PKT_SYNC) { if (b1!=RMT_PKT_SYNC2) { @@ -476,35 +341,48 @@ rr_cont: else goto rr_err; } - RmtTxPktU1(chnl,RMT_PKT_ACK); + if (RmtScanChar(chnl,&b)) + goto rt_err; + RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_SYNC); RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&s,JIFFY_FREQ/50); + RmtRxPktU1(chnl,&s,RMT_CHAR_DELAY); if (s>RMT_MAX_PKT_LEN) goto rr_err; - RmtTxPktU1(chnl,RMT_PKT_ACK); + if (RmtScanChar(chnl,&b)) + goto rt_err; + RmtTxPktU1(chnl,(RMT_PKT_ACK^s)&0xFF); RmtWaitTxDone(chnl); xsum=0x3A; for (i=0;ipkt_rx_jiffy=Jiffies; } public void RmtTxBlk(LTChnl *chnl,U1 *buf,I8 cnt) @@ -545,27 +423,32 @@ public U1 *RmtRxBlk(LTChnl *chnl,I8 cnt) public U8 RmtGetMsg(LTChnl *chnl,I8 *p1,I8 *p2) { - U8 cmd,d,size; + U8 cmd=0,size; U1 b[RMT_MAX_PKT_LEN]; *p1=0; *p2=0; if (!chnl || !chnl->type) return 0; - if (jiffiesnull_msg_jiffy) + if (Jiffiesnull_msg_jiffy) return 0; - else { + try { 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; - else - chnl->null_msg_jiffy=0; + if (size==sizeof(U8)*3) { + cmd=b[0]><(U8); + *p1=b[8]><(U8); + *p2=b[16]><(U8); + } + } catch { + if (Fs->except_argc==1) { + if (Fs->except_argv[0]==EXCP_TIMEOUT) + Fs->catch_except=TRUE; + } } + if (cmd) + chnl->null_msg_jiffy=0; + else + chnl->null_msg_jiffy=Jiffies+RMT_NULL_MSG_DELAY; return cmd; } @@ -584,11 +467,20 @@ public void RmtSendMsg(LTChnl *chnl,U8 cmd,I8 p1,I8 p2) } } -public void RmtPutCharSC(LTChnl *chnl,I8 ch,U8 sc) +public BoolU4 RmtPutKey(I8 ch,U8 sc) { - if (!chnl || !chnl->type) return; - if (ch) - RmtTxPkt(chnl,&ch,1); + nounusedwarn sc; + if (ch && Fs->rmt_chnl) { + try { + RmtTxPkt(Fs->rmt_chnl,&ch,1); + } catch { + if (Fs->except_argc==1) { + if (Fs->except_argv[0]==EXCP_TIMEOUT) + Fs->catch_except=TRUE; + } + } + } + return FALSE; } public void RmtTxBuf(LTChnl *chnl,U1 *buf,U8 size) @@ -613,13 +505,16 @@ public U1 *RmtRxBuf(LTChnl *chnl,U8 *size=NULL) return buf; } -public void RmtTxFile(LTChnl *chnl,I1 *filename, +public BoolU4 RmtTxFile(LTChnl *chnl,I1 *filename, BoolU4 raw=TRUE) { - U8 size; + U8 size,tries=3; U1 *buf; + U4 *good; + U1 b[RMT_MAX_PKT_LEN]; LTDirEntry de; if (!chnl || !chnl->type) return; +start_tx: if (FindFile(filename,&de)) { buf=ReadFile(filename,&size,NULL,raw); if (buf) { @@ -628,23 +523,57 @@ public void RmtTxFile(LTChnl *chnl,I1 *filename, Free(buf); } } + RmtRxPkt(chnl,b,&size); + good=b; + if (size==4 && *good==RMT_FILE_ACK) + return TRUE; + else { + if (!--tries) { + coutln "Failed!"; + return FALSE; + } else { + coutln "Retry"; + goto start_tx; + } + } } public U8 RmtRxFile(LTChnl *chnl,I1 *filename, BoolU4 raw=TRUE) { - U8 size; + U8 size,tries=3; + U4 good; U1 *buf,*buf1; LTDirEntry *de; if (!chnl || !chnl->type) return 0; +start_rx: + good=0; buf1=RmtRxBuf(chnl); de=buf1-offset(LTDirEntry.start); if (buf=RmtRxBuf(chnl,&size)) { - WriteFile(filename,buf,size,de->datetime,de->attr,raw); + good=RMT_FILE_ACK; + if (de->xsum) { + if ((de->xsum^ArcCheckSum(buf,de->size))!=LT_XSUM) + good=0; + } + if (good) + WriteFile(filename,buf,size,de->datetime,de->attr,raw); + else + coutln "Bad XSUM"; Free(buf); } Free(buf1); - return size; + RmtTxPkt(chnl,&good,sizeof(BoolU4)); + if (!good) { + if (!--tries) { + coutln "Failed!"; + return 0; + } else { + coutln "Retry"; + goto start_rx; + } + } else + return size; } public void RmtTxPutS(LTChnl *chnl,I1 *st) @@ -693,9 +622,11 @@ public U1 *RmtRqstTxBuf() //Remote must fill-in remote's chnl->tx_buf //and remote's chnl->tx_size before calling. LTChnl *chnl=Fs->rmt_chnl; + U1 *result; if (!chnl || !chnl->type) return NULL; RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_BUF); - return RmtRxBuf(chnl); + result=RmtRxBuf(chnl); + return result; } public void RmtRqstRxBuf(U1 *src_local_buf,U8 size) @@ -732,43 +663,69 @@ public void RmtRqstExeLocal(I1 *st) RmtTxBuf(chnl,st,StrLen(st)+1); } -void TelnetHostOpen(LTChnl *chnl) +public void TelnetHostOpen(LTChnl *chnl) +//Allows remote telnet user to control +//this task. Will still allow local +//control. { if (!chnl || !chnl->type) return; Fs->rmt_chnl=chnl; } -void TelnetHostClose(LTChnl *chnl) +public void TelnetHostClose() { Fs->rmt_chnl=NULL; } -void TelnetGuestOpen(LTChnl *chnl) +public void TelnetGuestOpen(LTChnl *chnl) { U8 i,cmd,p1,p2,rqst; U1 *st,*st2; + BoolU4 cont=TRUE,msg_sent=TRUE; + BoolU4 old_preempt=Preempt(OFF); if (!chnl || !chnl->type) return; Fs->local_chnl=chnl; - coutln "CTRL-ALT-B to break"; - try - while (TRUE) { + coutln "$$BK 1$$CTRL-ALT-B to break$$BK 0$$"; + for (i=0;i<4;i++) { + chnl->PutChar(chnl,RMT_PKT_RESET); + chnl->PutChar(chnl,RMT_PKT_RESET); + Sleep(100); + } + while (cont) { + try { + Fs->task_flags&=~(1<task_flags&=~(1<null_msg_cnt=0; switch (rqst) { case RMT_RQST_NONE: PutS(st2); break; case RMT_RQST_GETMSG: - cmd=GetMsgNoWait(&p1,&p2, - 1<task_flags|=1<task_flags|=1<except_argc==1) { + if (Fs->except_argv[0]==EXCP_TIMEOUT) { + Fs->catch_except=TRUE; + cont=TRUE; + } + } + if (!cont) { + Fs->local_chnl=NULL; + Preempt(old_preempt); } - SwapInNext; } - catch - Fs->catch_except=TRUE; -tel_exit: -/****** - for (i=0;i<5;i++) { - chnl->PutChar(chnl,RMT_PKT_CLOSE); - chnl->PutChar(chnl,RMT_PKT_CLOSE); - Sleep(50); } -******/ Fs->local_chnl=NULL; + Preempt(old_preempt); } -ext[EXT_RMT_PUTCHAR]=&RmtTxPutChar; -ext[EXT_RMT_PUTS]=&RmtTxPutS; -ext[EXT_RMT_LTFPUTCHAR]=&RmtPutCharSC; -ext[EXT_RMT_GETMSG]=&RmtGetMsg; - \ No newline at end of file +BoolU8 RmtPutS(I1 *st) +{ + if (Fs->rmt_chnl) { + try + RmtTxPutS(Fs->rmt_chnl,st); + catch { + if (Fs->except_argc==1) { + if (Fs->except_argv[0]==EXCP_TIMEOUT) + Fs->catch_except=TRUE; + } + } + } + return FALSE; +} + +AddKeyDev(&RmtPutKey,&RmtPutS,0xA0000000); +#help_index "" diff --git a/LT/ADAM/UTILS.CPZ b/LT/Adam/Utils.APZ similarity index 58% rename from LT/ADAM/UTILS.CPZ rename to LT/Adam/Utils.APZ index 001122b..4b54cac 100644 --- a/LT/ADAM/UTILS.CPZ +++ b/LT/Adam/Utils.APZ @@ -1,26 +1,4 @@ -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); -} +#help_index "File/Cmd Line (Typically)" public U1 *PatchBlk(U8 blk,BoolU4 write=FALSE) { @@ -38,15 +16,13 @@ public U1 *PatchBlk(U8 blk,BoolU4 write=FALSE) return buf; } -public U1 *Patch(U8 c,U8 cnt=0,BoolU4 write=FALSE) +public U1 *Patch(U8 c,BoolU4 write=FALSE) { - U1 *buf=MAlloc(BLK_SIZE*Fs->cur_partition->spc); + U1 *buf=MAlloc(Fs->cur_partition->spc<cur_partition,c,cnt,TRUE); RClusters(Fs->cur_partition,buf,c,1,TRUE); coutln "Cluster:",c; - LtfD(buf,BLK_SIZE*Fs->cur_partition->spc); + LtfD(buf,Fs->cur_partition->spc<pages; + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; tempm=tempm->next; } - for (i=0;ipages; - 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); + Cli; + tempm=mem_free_2Meg_list; + while (tempm) { + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; } SetFlags(old_flags); + for (i=0;isignature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; + } + SetFlags(old_flags); + } + for (i=0;i<64;i++) { + Cli; + tempm=free_page_hash2[i]; + while (tempm) { + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; + } + SetFlags(old_flags); + } return result*PAGE_SIZE; } public U8 TaskAllocatedMem(TssStruct *tss=NULL) { - MemBlk *m; + MemBlk *m,*m1; 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=tss->next_mem_blk; + m1=&tss->next_mem_blk; + while (m!=m1) { + if (m->signature!=MBS_USED_SIGNATURE) + CorruptTaskMemory; + result+=m->pages*PAGE_SIZE; m=m->next; } SetFlags(old_flags); @@ -107,7 +115,7 @@ public U8 TaskUnusedAllocatedMem(TssStruct *tss=NULL) UnusedAllocatedMem *u; if (!tss) tss=Fs; Cli; - for (i=0;i>2;i++) { + for (i=0;i>3;i++) { u=tss->heap_hash[i]; while (u) { result+=u->size; @@ -123,6 +131,67 @@ public U8 TaskUnusedAllocatedMem(TssStruct *tss=NULL) return result; } +#help_index "Memory/Heap Ctrl" +public U8 UnusedHCMem(HeapCtrl *hc) +{ + U8 result=0,i,old_flags=GetFlags; + MemBlk *tempm; + UnusedAllocatedMem *u; + + Cli; + tempm=hc->mem_free_list; + while (tempm) { + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; + } + SetFlags(old_flags); + + for (i=0;ifree_page_hash[i]; + while (tempm) { + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; + } + SetFlags(old_flags); + } + + for (i=0;i<64;i++) { + Cli; + tempm=hc->free_page_hash2[i]; + while (tempm) { + if (tempm->signature!=MBS_UNUSED_SIGNATURE) + CorruptSysMemory; + result+=tempm->pages; + tempm=tempm->next; + } + SetFlags(old_flags); + } + result*=PAGE_SIZE; + + Cli; + for (i=0;i>3;i++) { + u=hc->heap_hash[i]; + while (u) { + result+=u->size; + u=u->next; + } + } + u=hc->malloc_free_list; + while (u) { + result+=u->size; + u=u->next; + } + SetFlags(old_flags); + + return result; +} + +#help_index "Memory;Debugging" I8 CompareUamPtrs(UnusedAllocatedMem **e1, UnusedAllocatedMem **e2) { @@ -144,7 +213,7 @@ public void HeapRep(TssStruct *tss=NULL) if (!tss) tss=Fs; Cli; - for (i=0;i>2;i++) { + for (i=0;i>3;i++) { cnt=0; u=tss->heap_hash[i]; while (u) { @@ -180,9 +249,9 @@ public BoolU4 IsInHeap(U1 *a,TssStruct *tss=NULL) return FALSE; } -public BoolU4 HeapChk(TssStruct *tss=NULL) -//This just detects one type of error-- -// when a freed value is not valid. +public BoolU4 HeapWalk(TssStruct *tss=NULL) +//Detects just one type of error -- +//a freed value, not valid. { I8 i; UnusedAllocatedMem *u; @@ -190,8 +259,9 @@ public BoolU4 HeapChk(TssStruct *tss=NULL) U8 old_flags=GetFlags; if (!tss) tss=Fs; + if (!ValidateTss(tss)) return FALSE; Cli; - for (i=0;i>2;i++) { + for (i=0;i>3;i++) { u=tss->heap_hash[i]; while (u) { if (!IsInHeap(u,tss)) @@ -210,6 +280,7 @@ public BoolU4 HeapChk(TssStruct *tss=NULL) } +#help_index "Memory" //TODO:Crashes ///More of a heap check at the moment @@ -239,7 +310,7 @@ void CollectFreedAllocatedMem(TssStruct *tss=NULL) SetFlags(old_flags); //We might disturb the Free list and irq's might Free some - sort_buf=MAlloc(((cnt+512)&-0x100)*PTR_SIZE); + sort_buf=MAlloc(((cnt+512)&-0x100)*sizeof(void *)); Cli; cnt=0; @@ -268,7 +339,7 @@ void CollectFreedAllocatedMem(TssStruct *tss=NULL) SetFlags(old_flags); - QSort(sort_buf,cnt,PTR_SIZE,&CompareUamPtrs); + QSort(sort_buf,cnt,sizeof(void *),&CompareUamPtrs); for (i=0;isize>sort_buf[i+1]) cout "****"; @@ -286,7 +357,7 @@ void CollectFreedAllocatedMem(TssStruct *tss=NULL) } if (cnt) { j++; - QSort(sort_buf,j,PTR_SIZE,&CompareUamSize); + QSort(sort_buf,j,sizeof(void *),&CompareUamSize); for (i=0;inext=sort_buf[i]->size; Free(sort_buf[i]+4,tss); @@ -296,20 +367,24 @@ void CollectFreedAllocatedMem(TssStruct *tss=NULL) Free(sort_buf); } +#help_index "Task" + void TaskRepTask(TssStruct *tss,I8 indent) { TssStruct *tss1; - I1 *st,*desc=MSPrintF("%Q",tss->task_descriptor); + 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", + PrintF("%*s%s $$TX+SCX,\"%Q...\",16$$ Mem:%08X\r\n", indent,"",st,desc, - TaskAllocatedMem(tss), - tss->task_flags,tss->crt_flags, + TaskAllocatedMem(tss)); + PrintF("%*s Flags:%04X:%04X %02X\r\n", + indent+2,"",tss->task_flags,tss->crt_flags, ExceptDepth(tss)); + PrintF("Time:%9.2fm\r\n",tss->total_time/60.0/time_stamp_freq); Free(st); Free(desc); tss1=tss->next_child_tss; - while (tss1!=tss+&tss->next_child_tss-&tss->next_sibling_tss) { + while (tss1!=&tss->next_child_tss-offset(TssStruct.next_sibling_tss)) { TaskRepTask(tss1,indent+2); tss1=tss1->next_sibling_tss; } @@ -317,107 +392,33 @@ void TaskRepTask(TssStruct *tss,I8 indent) public void TaskRep() { + U1 i; U8 old_flags=GetFlags; + CPUStruct *c; 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; + for (i=0;icain_tss,2); } SetFlags(old_flags); - return result; } -public BoolU4 SBpt(TssStruct *tss,U1 *a,U8 flags=SBPTF_BPT) //set Bpt + +void CtrlAltX() { - 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; + Bts(sys_flags,SYSf_CTRL_ALT_X); } +ctrl_alt_letter_routines['X'-'A']=&CtrlAltX; -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 +void CtrlAltC() { - 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); + Bts(sys_flags,SYSf_CTRL_ALT_C); } +ctrl_alt_letter_routines['C'-'A']=&CtrlAltC; + +#help_index "File/FileNames" public BoolU4 IsTextFile(I1 *filename) { @@ -440,3 +441,5 @@ public BoolU4 IsAsmFile(I1 *filename) } +#help_index "" + \ No newline at end of file diff --git a/LT/Adam/WallPaper.APZ b/LT/Adam/WallPaper.APZ new file mode 100644 index 0000000..720d60f Binary files /dev/null and b/LT/Adam/WallPaper.APZ differ diff --git a/LT/Adam/Window.APZ b/LT/Adam/Window.APZ new file mode 100644 index 0000000..bcb755e --- /dev/null +++ b/LT/Adam/Window.APZ @@ -0,0 +1,1080 @@ +#help_index "Windows" + +public void RefocusWin() +{ + TssStruct *tss_focus=sys_cur_focus_task; + if (!tss_focus) { + tss_focus=sys_update_screen_tss->last_tss; + while (tss_focus!=sys_update_screen_tss) { + if (Bt(&tss_focus->task_flags,TSSf_LOCAL_USER)) { + sys_cur_focus_task=tss_focus; + break; + } + tss_focus=tss_focus->last_tss; + } + } +} + +I8 old_ipx=-1000,old_ipy=-1000,old_ipz=0; +BoolU4 old_ip_lb=FALSE,old_ip_rb=FALSE; +U8 left_ip_double_time=0; +BoolU4 left_double=FALSE,left_down_sent=FALSE; +U8 right_ip_double_time=0; +BoolU4 right_double=FALSE,right_down_sent=FALSE; +public U8 double_click_mS=350; + +public I8 win_min_refresh=15, + win_max_refresh=50, + win_updates=0; +public double win_refresh=win_min_refresh; + +BoolU4 win_first_after_startup_complete=FALSE; + +void PlotInputPointer(GrBitMap *base) +{ + I8 x,y; + U8 old_flags=GetFlags; + Cli; + x=ipx; + y=ipy; + SetFlags(old_flags); + if (ip_on && ip_pointer_type!=IP_NULL) { + base->color=ROP_XOR+WHITE; + GrLine4(base,x,y,x+10,y+10); + GrLine4(base,x+2,y+1,x+11,y+10); + GrLine4(base,x+1,y+2,x+10,y+11); + GrLine4(base,x,y,x+5,y); + GrLine4(base,x,y,x,y+5); + } +} + + +void UpdateOdes(TssStruct *tss) +{ + I8 i,timeout_time=GetTimeStamp+time_stamp_freq/win_min_refresh; + double t_desired=GetTimeStamp*1.0/time_stamp_freq, + t_initial,interpolation; + Ode *o=tss->next_ode; + while (o!=&tss->next_ode) { + MemCpy(o->internal_state,o->state,o->n*sizeof(double)); + o->tolerance=o->tolerance_start; + o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt); + for (i=0;in;i++) + o->state_scale[i]=Abs(o->internal_state[i])+Abs(o->DstateDt[i]*o->h)+1e-4; + t_initial=o->t+o->base_t; + MemCpy(o->initial_state,o->internal_state,o->n*sizeof(double)); + do { + while (o->t+o->base_ttimeout_time) + o->base_t=t_desired-o->t; + } + if (interpolation=(o->t+o->base_t-t_initial)) + interpolation=(t_desired-t_initial)/interpolation; + else + interpolation=1.0; + if (interpolation>.1 || o->tolerance<1e-64) + break; + else { + MemCpy(o->internal_state,o->initial_state,sizeof(double)*o->n); + o->t=t_initial-o->base_t; + o->tolerance/=10; + } + } while (TRUE); + for (i=0;in;i++) + o->internal_state[i]=(o->internal_state[i]-o->initial_state[i])*interpolation+o->initial_state[i]; + o->t=t_desired-o->base_t; + MemCpy(o->state,o->internal_state,o->n*sizeof(double)); + o=o->next; + } +} + +void WinUpdateIP() +{ + I8 dd; + U8 temp,temp2; + BoolU8 set=FALSE; + double speed=0; + + if (ip_pointer_type==IP_MOUSE) { + ip_has_wheel=mouse_has_wheel; + if (mouse_evt) { + ipx=mxx/ipx_snap*ipx_snap+ipx_snap_offset; + ipy=myy/ipy_snap*ipy_snap+ipy_snap_offset; + + ip_throttle+=(mzz-ipz)*0x10000000; + if (ip_throttle>MAX_I4) + ip_throttle=MAX_I4; + if (ip_throttlejoymax[3]-joymin[3]) + ip_throttle=0x100000000*(joyv[2]-joyrest[2])/(joymax[2]-joymin[2]+1); + else + ip_throttle=0x100000000*(joyv[3]-joyrest[3])/(joymax[3]-joymin[3]+1); + if (ip_throttle>MAX_I4) + ip_throttle=MAX_I4; + if (ip_throttle0) { + temp2=GetTimeStamp; + temp=temp2-last_ip_move_time; + last_ip_move_time=temp2; + if (!temp) temp=1; + speed=Sqrt(dd)/(temp/(1.0*time_stamp_freq)); + } + iptx=ipx/FONT_WIDTH; + ipty=ipy/FONT_HEIGHT; + } + if (ip_speed<10.0) + ip_speed=speed; + else + ip_speed=0.75*ip_speed+0.25*speed; //digital filter for mouse speed +} + +U8 last_idle_point_hits[MP_MAX_PROCESSORS]={0,0,0,0}; +U8 last_swap_cnter[MP_MAX_PROCESSORS]={0,0,0,0}; +I8 last_refresh_time=GetTimeStamp, + last_refresh_start_time=0, + last_refresh_end_time=0, + refresh_time,refresh_delta_time; +U8 win_calc_refresh_cnt=0, + win_calc_refresh_skips=0; + +U8 WinCalcRefreshTimeout() +{ + double d=Gs->idle_factor,d1; + I8 i,k; + U8 old_flags=GetFlags; + U8 idle_point_hits[MP_MAX_PROCESSORS]; + CPUStruct *c; + + win_calc_refresh_skips++; + if (GetTimeStamp-last_refresh_time>time_stamp_freq>>2) { + refresh_time=GetTimeStamp; + + Cli; + for (i=0;iidle_point_hits; + } + SetFlags(old_flags); + + refresh_delta_time=refresh_time-last_refresh_time; + for (i=0;i0) { + k=idle_point_hits[i]-last_idle_point_hits[i]; + if (k>=0) + c->idle_factor= + k*time_stamp_freq*1.0 + /(JIFFY_FREQ*refresh_delta_time); + } + last_idle_point_hits[i]=idle_point_hits[i]; + if (c->idle_factor<.01) + c->idle_factor=0.01; + if (c->idle_factor>.99) + c->idle_factor=0.99; + } + + last_refresh_time=refresh_time; + + if (win_first_after_startup_complete) { + d1=(last_refresh_end_time-last_refresh_start_time)*1.0/ + (refresh_delta_time/win_calc_refresh_skips); + if (d1<0.2) + win_refresh*=1.25; + else if (d<=0.0) + win_refresh=win_min_refresh; + else if (d<0.02) { + d=win_min_refresh/win_refresh; + win_refresh=d*win_min_refresh+0.5*(1.0-d)*win_refresh; + } else if (d<0.99) { + if (d=(1.0-d)`0.25) + win_refresh*=(0.8`0.25)/d; + } else + win_refresh=win_max_refresh; + win_calc_refresh_cnt++; + win_calc_refresh_skips=0; + } else { + win_refresh=win_max_refresh; + win_first_after_startup_complete=TRUE; + } + } + if (win_refreshwin_max_refresh) win_refresh=win_max_refresh; + return GetTimeStamp+time_stamp_freq/win_refresh; +} + +U8 WinQueueKbdMouseMsgs() +{ + U8 jiffies=Jiffies,cmd=0; + I8 p1,p2; + TssStruct *tss_focus=sys_cur_focus_task; + + if (tss_focus) { + while (U8FifoRemove(scan_code_fifo,&p2)) { + p1=ScanCodeToASCII(p2); + if (p2 & SCF_KEY_UP) { + QueueMsg(tss_focus,0, + MSG_KEY_UP,p1,p2,0); + cmd=MSG_KEY_UP; + } else { + QueueMsg(tss_focus,0, + MSG_KEY_DOWN,p1,p2,0); + cmd=MSG_KEY_DOWN; + } + } + + p1=ipx-tss_focus->win_left*FONT_WIDTH; + p2=ipy-tss_focus->win_top*FONT_HEIGHT; + if (old_ipx!=ipx || old_ipy!=ipy) { + QueueMsg(tss_focus,0, + MSG_IP_MOVE,p1,p2,0); + cmd=MSG_IP_MOVE; + } + //TODO queue msg for ipz? + if (left_ip_double_time) { + if (jiffies>left_ip_double_time) { + if (left_double) { + if (!left_down_sent) { + QueueMsg(tss_focus,0, + MSG_IP_L_D_DOWN,p1,p2,0); + left_down_sent=TRUE; + cmd=MSG_IP_L_D_DOWN; + } + if (!ip_lb) { + QueueMsg(tss_focus,0, + MSG_IP_L_D_UP,p1,p2,0); + left_ip_double_time=0; + cmd=MSG_IP_L_D_UP; + } + } else { + if (!left_down_sent) { + QueueMsg(tss_focus,0, + MSG_IP_L_DOWN,p1,p2,0); + left_down_sent=TRUE; + cmd=MSG_IP_L_DOWN; + } + if (!ip_lb) { + QueueMsg(tss_focus,0, + MSG_IP_L_UP,p1,p2,0); + left_ip_double_time=0; + cmd=MSG_IP_L_UP; + } + } + } else { + if (ip_lb && !ip_lb_last) { + left_ip_double_time=jiffies; + left_double=TRUE; + } + } + } else { + if (Bt(&tss_focus->crt_flags,CRTf_NO_DOUBLE_CLICK)) { + if (ip_lb && !ip_lb_last) { + QueueMsg(tss_focus,0, + MSG_IP_L_DOWN,p1,p2,0); + cmd=MSG_IP_L_DOWN; + } else if (!ip_lb && ip_lb_last) { + QueueMsg(tss_focus,0, + MSG_IP_L_UP,p1,p2,0); + cmd=MSG_IP_L_UP; + } + } else { + if (ip_lb && !ip_lb_last) { + left_double=FALSE; + left_down_sent=FALSE; + left_ip_double_time=jiffies+ + double_click_mS*JIFFY_FREQ/1000; + } + } + } + + if (right_ip_double_time) { + if (jiffies>right_ip_double_time) { + if (right_double) { + if (!right_down_sent) { + QueueMsg(tss_focus,0, + MSG_IP_R_D_DOWN,p1,p2,0); + right_down_sent=TRUE; + cmd=MSG_IP_R_D_DOWN; + } + if (!ip_rb) { + QueueMsg(tss_focus,0, + MSG_IP_R_D_UP,p1,p2,0); + right_ip_double_time=0; + cmd=MSG_IP_R_D_UP; + } + } else { + if (!right_down_sent) { + QueueMsg(tss_focus,0, + MSG_IP_R_DOWN,p1,p2,0); + right_down_sent=TRUE; + cmd=MSG_IP_R_DOWN; + } + if (!ip_rb) { + QueueMsg(tss_focus,0, + MSG_IP_R_UP,p1,p2,0); + right_ip_double_time=0; + cmd=MSG_IP_R_UP; + } + } + } else { + if (ip_rb && !ip_rb_last) { + right_ip_double_time=jiffies; + right_double=TRUE; + } + } + } else { + if (Bt(&tss_focus->crt_flags,CRTf_NO_DOUBLE_CLICK)) { + if (ip_rb && !ip_rb_last) { + QueueMsg(tss_focus,0, + MSG_IP_R_DOWN,p1,p2,0); + cmd=MSG_IP_R_DOWN; + } else if (!ip_rb && ip_rb_last) { + QueueMsg(tss_focus,0, + MSG_IP_R_UP,p1,p2,0); + cmd=MSG_IP_R_UP; + } + } else { + if (ip_rb && !ip_rb_last) { + right_double=FALSE; + right_down_sent=FALSE; + right_ip_double_time=jiffies+ + double_click_mS*JIFFY_FREQ/1000; + } + } + } + + ip_lb_last=ip_lb; + ip_rb_last=ip_rb; + old_ip_lb=ip_lb; + old_ip_rb=ip_rb; + old_ipx=ipx; + old_ipy=ipy; + old_ipz=ipz; + } + return cmd; +} + +U8 WinPointAndSleep() +{ + U8 timeout_val,timeout_val2,cmd=0; + + if (sys_cur_focus_task) + cmd=WinQueueKbdMouseMsgs; + else { + RefocusWin; + if (!sys_cur_focus_task) + U8FifoFlush(scan_code_fifo); + } + + if (sys_cur_focus_task) + Btr(&sys_cur_focus_task->task_flags,TSSf_HAS_SONG); + + timeout_val=WinCalcRefreshTimeout; + WinUpdateIP; + last_refresh_start_time=TssTotalTime; + GrUpdateScreen(gr_merge_base,grbase2,textbase); + last_refresh_end_time=TssTotalTime; + + if (sys_cur_focus_task) { + if (!Bt(&sys_cur_focus_task->task_flags,TSSf_HAS_SONG)) { + AFree(cur_song); + cur_song=NULL; + } + } + if (cur_song) { + if (!cur_song_tss) + cur_song_tss=Spawn(&CurSongTsk,"Current Song"); + } else { + if (cur_song_tss) { + Kill(cur_song_tss); + cur_song_tss=NULL; + } + } + win_updates++; + if (!mouse_install_attempts) { + Fs->task_flags|=1<time_slice_starttask_flags&=~(1<timeout_val) + timeout_val2=timeout_val; + + Fs->task_flags|=1<time_slice_starttask_flags&=~(1<time_slice_starttask_flags,TSSf_IDLE); + + if (full_update) { + if (Fs->cur_ltf) + old_full_update=Bts(&Fs->cur_ltf->flags,LTFf_DO_FULL_UPDATE); + } + + //We might catch it in the middle of an update + //If do full update, set cur position + update_cnt=win_updates; + gr_update_cnt=gr_win_updates; + while (update_cnt==win_updates || + gr_update_cnt==gr_win_updates) + SwapInNext; + + if (full_update) { + //Do update with cur position + update_cnt=win_updates; + gr_update_cnt=gr_win_updates; + while (update_cnt==win_updates || + gr_update_cnt==gr_win_updates) + SwapInNext; + if (Fs->cur_ltf) + AssignBit(&Fs->cur_ltf->flags,LTFf_DO_FULL_UPDATE,old_full_update); + } + AssignBit(&Fs->task_flags,TSSf_IDLE,old_idle); +} + +#help_index "Windows" + +public BoolU8 WinToTop(TssStruct *tss=NULL) +{ + BoolU4 result=FALSE,old_flags=GetFlags; + TssStruct *next,*last; + if (!tss) tss=Fs; + //REMOVE + Cli; //TODO Multiprocessor safe + if (!ValidateTss(tss)) { + SetFlags(old_flags); + return result; + } + if (sys_update_screen_tss->last_tss!=tss) { + next=tss->next_tss; + last=tss->last_tss; + next->last_tss=last; + last->next_tss=next; + AddTaskToQueue(tss,sys_update_screen_tss); + result=TRUE; + } + if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) + sys_cur_focus_task=tss; + SetFlags(old_flags); + return result; +} +ext[EXT_WIN_TO_TOP]=&WinToTop; + +void SetWinHorz(TssStruct *tss,I8 i,I8 j) +{ + I8 d=j-i; + if (d<0) d=0; + if (i>=TEXT_COLS) { + i=TEXT_COLS-1; + j=i+d; + } + if (j<0) { + j=0; + i=j-d; + } + if (i>j) { + if (i>0) + j=i; + else + i=j; + } + if (tss->win_left!=i || tss->win_right!=j) { + Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED); + Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2); + } + tss->win_left=i; + tss->win_right=j; +} + +void SetWinVert(TssStruct *tss,I8 i,I8 j) +{ + I8 d=j-i; + if (d<0) d=0; + if (i>=TEXT_ROWS) { + i=TEXT_ROWS-1; + j=i+d; + } + if (j<=0) { + j=1; + i=j-d; + } + if (i>j) { + if (i>=0) + j=i; + else + i=j; + } + if (tss->win_top!=i || tss->win_bottom!=j) { + Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED); + Bts(&tss->crt_flags,CRTf_HAS_BEEN_RESIZED2); + } + tss->win_top=i; + tss->win_bottom=j; +} + +BoolU8 SetCursorPosition(TssStruct *tss,I8 iptx,I8 ipty,BoolU4 set_cursor=TRUE) +{ + Ltf *l; + if (tss->win_top<=ipty && tss->win_bottom>=ipty && + tss->win_left<=iptx && tss->win_right>=iptx) { + if (l=tss->aux_ltf) { + if (set_cursor) { + //set top line + l->recalc_start=l; + LtfUpdateWinJoin(l,FALSE,TRUE,TRUE,FALSE,OFF); + + l->x=iptx-tss->win_left+l->line_start_col; + l->y=ipty-tss->win_top+l->cur_top_line_num; + LtfUpdateWinJoin(l,FALSE,FALSE,FALSE,TRUE,OFF); + if (!l->best_d) + goto done; + } + } + if (l=tss->cur_ltf) { + if (set_cursor) { + + //set top line + l->recalc_start=l; + LtfUpdateWinJoin(l,FALSE,TRUE,TRUE,FALSE,OFF); + + l->x=iptx-tss->win_left+l->line_start_col; + l->y=ipty-tss->win_top+l->cur_top_line_num; + LtfUpdateWinJoin(l,FALSE,FALSE,FALSE,TRUE,OFF); + } + } +done: + WinToTop(tss); + return TRUE; + } + return FALSE; +} + +void UpdateDerivedTssValues(TssStruct *tss) +{ +//Inside the Border + tss->win_pixel_left =FONT_WIDTH*tss->win_left; + tss->win_pixel_right =FONT_WIDTH*(tss->win_right+1)-1; + tss->win_pixel_top =FONT_HEIGHT*tss->win_top; + tss->win_pixel_bottom=FONT_HEIGHT*(tss->win_bottom+1)-1; + +//Outside the border + if (Bt(&tss->crt_flags,CRTf_NO_BORDER)) { + tss->win_border_pixel_left =tss->win_pixel_left; + tss->win_border_pixel_right =tss->win_pixel_right; + tss->win_border_pixel_top =tss->win_pixel_top; + tss->win_border_pixel_bottom=tss->win_pixel_bottom; + } else { + tss->win_border_pixel_left =tss->win_pixel_left-FONT_WIDTH; + tss->win_border_pixel_right =tss->win_pixel_right+FONT_WIDTH; + tss->win_border_pixel_top =tss->win_pixel_top-FONT_HEIGHT; + tss->win_border_pixel_bottom=tss->win_pixel_bottom+FONT_HEIGHT; + } +} + +public void WinTileHorz() +{ + TssStruct *tss,*last_tss=Fs; + I8 cnt,c,i,vert_size; + BoolU4 old_preempt=Preempt(OFF); + + tss=sys_update_screen_tss; + cnt=0; + do { + if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) + cnt++; + tss=tss->last_tss; + } while (tss!=sys_update_screen_tss); + + + tss=sys_update_screen_tss; + i=0; + do { + if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) { + c=cnt-(i&~3); + if (!c) + c=1; + else if (c>4) + c=4; + vert_size=(TEXT_ROWS-1)/c; + + tss->win_right=TEXT_COLS-2; + tss->win_left=1; + tss->win_top=(i&3)*vert_size+2; + tss->win_bottom=((i&3)+1)*vert_size; + last_tss=tss; + if ((i&3)==3) + tss->win_bottom=TEXT_ROWS-2; + i++; + UpdateDerivedTssValues(tss); + } + tss=tss->last_tss; + } while (tss!=sys_update_screen_tss); + last_tss->win_bottom=TEXT_ROWS-2; + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + Preempt(old_preempt); +} + +public void WinTileVert() +{ + TssStruct *tss,*last_tss=Fs; + I8 cnt,c,i,horz_size; + BoolU4 old_preempt=Preempt(OFF); + tss=sys_update_screen_tss; + cnt=0; + do { + if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) + cnt++; + tss=tss->last_tss; + } while (tss!=sys_update_screen_tss); + + tss=sys_update_screen_tss; + i=0; + do { + if (Bt(&tss->task_flags,TSSf_LOCAL_USER)) { + c=cnt-(i&~3); + if (!c) + c=1; + else if (c>4) + c=4; + horz_size=TEXT_COLS/c; + + tss->win_top=2; + tss->win_bottom=TEXT_ROWS-2; + tss->win_left=(i&3)*horz_size+1; + tss->win_right=((i&3)+1)*horz_size-1; + last_tss=tss; + if ((i&3)==3) + tss->win_right=TEXT_COLS-2; + i++; + UpdateDerivedTssValues(tss); + } + tss=tss->last_tss; + } while (tss!=sys_update_screen_tss); + last_tss->win_right=TEXT_COLS-2; + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + Preempt(old_preempt); +} + + +public void WinMax(TssStruct *tss=NULL) +{ + BoolU4 old_preempt=Preempt(OFF); + if (!tss) tss=Fs; + if (Bt(&tss->crt_flags,CRTf_NO_BORDER)) { + tss->win_right=TEXT_COLS-1; + tss->win_left=0; + tss->win_top=1; + tss->win_bottom=TEXT_ROWS-1; + } else { + tss->win_right=TEXT_COLS-2; + tss->win_left=1; + tss->win_top=2; + tss->win_bottom=TEXT_ROWS-2; + } + UpdateDerivedTssValues(tss); + WinToTop(tss); + Preempt(old_preempt); +} + +public BoolU8 WinBorder(BoolU4 val,TssStruct *tss=NULL) +{ + BoolU4 old_has_border, + old_preempt=Preempt(OFF); + if (!tss) tss=Fs; + old_has_border=!Bt(&tss->crt_flags,CRTf_NO_BORDER); + if (val) { + if (!old_has_border) { + Btr(&tss->crt_flags,CRTf_NO_BORDER); + tss->win_right--; + tss->win_left++; + tss->win_top++; + tss->win_bottom--; + UpdateDerivedTssValues(tss); + } + } else { + if (old_has_border) { + Bts(&tss->crt_flags,CRTf_NO_BORDER); + tss->win_right++; + tss->win_left--; + tss->win_top--; + tss->win_bottom++; + UpdateDerivedTssValues(tss); + } + } + Preempt(old_preempt); + return old_has_border; +} + +void WinManagerTsk() +{ + TssStruct *tss=Fs; + I8 x,y,cmd; + Ltf *l; + LtfEntry *ll; + I8 my_ipz=0; + BoolU4 has_border; + U8 old_flags=GetFlags; + + InitCrt; + Fs->win_left=0; + Fs->win_right=TEXT_COLS-1; + Fs->win_top=0; + Fs->win_bottom=TEXT_ROWS-1; + UpdateDerivedTssValues(Fs); + Bts(&Fs->crt_flags,CRTf_NO_BORDER); + Bts(&Fs->crt_flags,CRTf_SHOW); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + Raw(OFF); + GrSetupTable(grbase2); + ext[EXT_SCAN_KEY]=&WinScanKey; + while (TRUE) { + try { +wmt_start: + Fs->update_win=ext[EXT_WALLPAPER]; + do { + Cli; + if (ValidateTss(tss)) + tss=tss->last_tss; + else + tss=Fs->last_tss; + SetFlags(old_flags); + if (tss==Fs) { + WinPointAndSleep; + FinishOffDyingTsses; + } + } while (!ValidateTss(tss) || tss==Fs || !Bt(&tss->crt_flags,CRTf_SHOW)); + UpdateDerivedTssValues(tss); + if (ip_inhibit_win_operations) + goto wmt_start; + + if (Bt(&tss->crt_flags,CRTf_NO_BORDER)) + has_border=FALSE; + else + has_border=TRUE; + + if (!old_ip_lb && ip_lb) { + if (SetCursorPosition(tss,iptx,ipty)) { + if (l=tss->aux_ltf) { + if (!l->best_d) { + ll=l->cur_entry; + if (ll!=l) { + if (ll->flags & LTFLF_HAS_BORDER) + ll->flags|=LTFLF_SOLID_BORDER; + } + old_ip_lb=TRUE; + goto wmt_start; + } + } + if (l=tss->cur_ltf) { + ll=l->cur_entry; + if (ll!=l) { + if (ll->flags & LTFLF_HAS_BORDER) + ll->flags|=LTFLF_SOLID_BORDER; + } + } + old_ip_lb=TRUE; + goto wmt_start; + } + } + if (old_ip_lb && !ip_lb) { + if (ipty==tss->win_top-1) { + if (iptx>=tss->win_left && iptxwin_left+4) { + if (Bt(&tss->crt_flags,CRTf_HAS_MENU)) { + QueueMsg(tss,0,MSG_KEY_DOWN,0,SC_GUI,0); + old_ip_lb=FALSE; + goto wmt_start; + } + } else if (iptx>=tss->win_right-2 && iptx<=tss->win_right) { + if (Bt(&tss->crt_flags,CRTf_HAS_CLOSE_WIN)) { + if (tss->cur_ltf) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_CTRLQ,0,0); + else + Kill(tss,FALSE); + old_ip_lb=FALSE; + goto wmt_start; + } + } + } else if (SetCursorPosition(tss,iptx,ipty,FALSE)) { + if (l=tss->aux_ltf) { + if (!l->best_d) { + do cmd=WinPointAndSleep; + while (ValidateTss(tss) && + (ip_lb || left_ip_double_time)); + if (ValidateTss(tss)) { + if (cmd==MSG_IP_L_UP) { + l=tss->aux_ltf; + ll=l->cur_entry; + if (ll!=l) { + if (ll->flags & LTFLF_HAS_BORDER) + ll->flags&=~LTFLF_SOLID_BORDER; + if (ll->btype==LTFT_CHECK_BOX || ll->btype==LTFT_HIDE_START || + (ll->flags & + (LTFLF_TREE | LTFLF_LINK | LTFLF_LEFT_CB | LTFLF_LEFT_MACRO | LTFLF_LEFT_EXP))) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_SPACE,0,0); + } + } else if (cmd==MSG_IP_L_D_UP) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_ESC,0,0); + } + old_ip_lb=FALSE; + goto wmt_start; + } + } + if (l=tss->cur_ltf) { + do cmd=WinPointAndSleep; + while (ValidateTss(tss) && + (ip_lb || left_ip_double_time)); + if (ValidateTss(tss)) { + if (cmd==MSG_IP_L_UP) { + l=tss->cur_ltf; + ll=l->cur_entry; + if (ll!=l) { + if (ll->flags & LTFLF_HAS_BORDER) + ll->flags&=~LTFLF_SOLID_BORDER; + if (ll->btype==LTFT_CHECK_BOX || ll->btype==LTFT_HIDE_START || + (ll->flags & + (LTFLF_TREE | LTFLF_LINK | LTFLF_LEFT_CB | LTFLF_LEFT_MACRO | LTFLF_LEFT_EXP))) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_SPACE,0,0); + } + } else if (cmd==MSG_IP_L_D_UP) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_ESC,0,0); + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + } + + if (ip_has_wheel) { + if (my_ipz!=ipz && tss==sys_cur_focus_task) { + tss->scroll_y+=ipz-my_ipz; + my_ipz=ipz; + if (tss->scroll_y<0) + tss->scroll_y=0; + if (tss->scroll_y>tss->win_bottom+1-tss->win_top) + tss->scroll_y=tss->win_bottom+1-tss->win_top; + Bts(&tss->crt_flags,CRTf_SCROLL_Y); + if (tss->cur_ltf) { + while (ValidateTss(tss) && + Bt(&tss->crt_flags,CRTf_SCROLL_Y)) + WinPointAndSleep; + } + if (ValidateTss(tss)) + SetCursorPosition(tss, + ((tss->win_left+tss->win_right)>>1), + (tss->win_top+tss->win_bottom)>>1); + goto wmt_start; + } + } + if (old_ip_rb && !ip_rb) { + if (SetCursorPosition(tss,iptx,ipty,FALSE)) { + if (l=tss->aux_ltf) { + if (!l->best_d) { + do cmd=WinPointAndSleep; + while (ValidateTss(tss) && + (ip_rb || right_ip_double_time)); + if (ValidateTss(tss)) { + if (cmd==MSG_IP_R_UP) { + if (SetCursorPosition(tss,iptx,ipty)) { + if (l=tss->aux_ltf) { + ll=l->cur_entry; + if (ll!=l) { + if (ll->btype==LTFT_LINK || + (ll->flags & + (LTFLF_RIGHT_CB | LTFLF_RIGHT_MACRO | LTFLF_RIGHT_EXP))) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_CR,0,0); + } + } + } + } else if (cmd==MSG_IP_R_D_UP) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_CTRLQ,0,0); + } + old_ip_rb=FALSE; + goto wmt_start; + } + } + if (l=tss->cur_ltf) { + do cmd=WinPointAndSleep; + while (ValidateTss(tss) && + (ip_rb || right_ip_double_time)); + if (ValidateTss(tss)) { + if (cmd==MSG_IP_R_UP) { + if (SetCursorPosition(tss,iptx,ipty)) { + if (l=tss->cur_ltf) { + ll=l->cur_entry; + if (ll!=l) { + if (ll->btype==LTFT_LINK || + (ll->flags & + (LTFLF_RIGHT_CB | LTFLF_RIGHT_MACRO | LTFLF_RIGHT_EXP))) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_CR,0,0); + } + } + } + } else if (cmd==MSG_IP_R_D_UP) + QueueMsg(tss,0,MSG_KEY_DOWN,CH_CTRLQ,0,0); + } + } + old_ip_rb=FALSE; + goto wmt_start; + } + } + if (ip_lb && !old_ip_lb) { + if (has_border && + tss->win_top==ipty+1 && + iptx>=tss->win_left-1 && iptx<=tss->win_right+1) { + if (iptx>=tss->win_left && iptxwin_left+4 && + Bt(&tss->crt_flags,CRTf_HAS_MENU)) { + old_ip_lb=TRUE; + goto wmt_start; + } + if (iptx>=tss->win_right-2 && iptx<=tss->win_right && + Bt(&tss->crt_flags,CRTf_HAS_CLOSE_WIN)) { + old_ip_lb=TRUE; + goto wmt_start; + } + x=iptx-tss->win_left; + if (ip_lb) { + WinToTop(tss); + while (ip_lb && ValidateTss(tss)) { + SetWinHorz(tss,iptx-x,tss->win_right+(iptx-x)-tss->win_left); + SetWinVert(tss,ipty+1,tss->win_bottom+ipty+1-tss->win_top); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + UpdateDerivedTssValues(tss); + WinPointAndSleep; + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + if (has_border && tss->win_left==iptx+1 && + (ipty>=tss->win_top-1 && ipty<=tss->win_bottom+1)) { + y=ipty-tss->win_top; + if (ip_lb) { + WinToTop(tss); + while (ip_lb && ValidateTss(tss)) { + SetWinHorz(tss,iptx+1,tss->win_right+iptx+1-tss->win_left); + SetWinVert(tss,ipty-y,tss->win_bottom+(ipty-y)-tss->win_top); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + UpdateDerivedTssValues(tss); + WinPointAndSleep; + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + if (has_border && tss->win_right+1==iptx && tss->win_bottom+1==ipty) { + if (ip_lb) { + WinToTop(tss); + while (ip_lb && ValidateTss(tss)) { + SetWinHorz(tss,tss->win_left,iptx-1); + SetWinVert(tss,tss->win_top,ipty-1); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + UpdateDerivedTssValues(tss); + WinPointAndSleep; + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + if (has_border && tss->win_bottom==ipty-1 && + iptx>=tss->win_left && iptx<=tss->win_right) { + if (iptx==(tss->scroll_x+tss->win_left)) { + while (ip_lb && ValidateTss(tss)) { + tss->scroll_x=iptx-tss->win_left; + Bts(&tss->crt_flags,CRTf_SCROLL_X); + WinPointAndSleep; + SetCursorPosition(tss, + ((tss->win_left+tss->win_right)>>1), + (tss->win_top+tss->win_bottom)>>1); + } + } else { + if (ip_lb) { + WinToTop(tss); + while (ip_lb && ValidateTss(tss)) { + SetWinVert(tss,tss->win_top,ipty-1); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + UpdateDerivedTssValues(tss); + WinPointAndSleep; + } + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + if (has_border && tss->win_right==iptx-1 && + ipty>=tss->win_top && ipty<=tss->win_bottom) { + if (ipty==(tss->scroll_y+tss->win_top)) { + while (ip_lb && ValidateTss(tss)) { + tss->scroll_y=ipty-tss->win_top; + Bts(&tss->crt_flags,CRTf_SCROLL_Y); + WinPointAndSleep; + SetCursorPosition(tss, + ((tss->win_left+tss->win_right)>>1), + (tss->win_top+tss->win_bottom)>>1); + } + } else { + if (ip_lb) { + WinToTop(tss); + while (ip_lb && ValidateTss(tss)) { + SetWinHorz(tss,tss->win_left,iptx-1); + LBts(&sys_semas[SYS_SEMA_CLEAR_SCREEN_TEXT],0); + UpdateDerivedTssValues(tss); + WinPointAndSleep; + } + } + } + old_ip_lb=FALSE; + goto wmt_start; + } + } + } catch { + Beep; + Fs->catch_except=TRUE; + tss=Fs; + } + } +} +#help_index "" diff --git a/LT/Adam/WordStat/WSDict.APZ b/LT/Adam/WordStat/WSDict.APZ new file mode 100644 index 0000000..dd84144 --- /dev/null +++ b/LT/Adam/WordStat/WSDict.APZ @@ -0,0 +1,450 @@ +I8 WsdNextCmd(I1 **ptr_) +{ + I8 result=-1; + I1 ch,*ptr=*ptr_,*ptr2; + do { + do { + if (!(ch=*ptr++)) goto done; + } while (ch!='<'); + + ptr2=ptr; + do { + if (!(ch=*ptr2++)) goto done; + } while (ch!='>'); + *--ptr2=0; + result=MatchListEntry(ptr,"h1\0/h1\0def\0/def\0hw\0/hw\0tt\0/tt\0" +"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0@cref\0@syn\0" +"/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0@/altname\0@/chform\0@/cref\0@/syn\0"); + *ptr2++='>'; + ptr=ptr2; + } while (result<0); + +done: + *ptr_=ptr; + return result; +} + +I1 *WsdNextEntry(I1 **ptr_) +{ + I1 *ignore,*result,ch,*ptr=*ptr_,buf[WSD_BLK_SIZE],*out_ptr=buf; + I8 l; + do { + do { + if (!(ch=*ptr++)) goto done; + if (ch!='<') { + *out_ptr++=ch; + if (ch=='$$') + *out_ptr++=ch; + } else + break; + } while (TRUE); + ignore="b>\0i>\0p>\0/b>\0/i>\0/p>\0" + "ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0" + "/er>\0/as>\0/cs>\0/cd>\0/ex>\0" + "note>\0/note>\0blockquote>\0/blockquote>\0"; + while (*ignore) { + l=StrLen(ignore); + if (!StrNCmp(ptr,ignore,l)) { + ptr+=l; + break; + } else + ignore+=l+1; + } + if (!*ignore) + break; + } while (TRUE); +done: + *out_ptr++=0; + result=NewStr(buf); + *ptr_=ptr-1; + return result; +} + +I8 WsdCompareWords(I1 **e1,I1 **e2) +{ + return StrCmp(*e1,*e2); +} + +I1 *WsdSortWords(I1 *start,I8 size,I8 word_cnt) +{ + I1 **ptr_array=MAlloc(sizeof(void *)*word_cnt), + *out_start=MAlloc(size), + *ptr=start,*ptr2; + I8 i=0; + while (*ptr) { + ptr_array[i++]=ptr; + ptr+=StrLen(ptr)+3; + } + coutln "Sorting..."; Sleep(100); + QSort(ptr_array,word_cnt,sizeof(void *),&WsdCompareWords); + coutln "Done..."; Sleep(100); + + ptr=out_start; + for (i=0;ilargest_entry) + largest_entry=out_ptr-def_word_start; + def_word_start=out_ptr; + if (st=WsdNextEntry(&in_ptr)) { + if (*st) { + if (StrICmp(st,last_word)) { + word_cnt++; + + *word_ptr++=WSD_WORD_CHAR; + last_word=word_ptr; + StrCpy(word_ptr,st); + word_ptr+=StrLen(st)+1; + + d=word_ptr; + *d=(out_ptr-out_start)/WSD_BLK_SIZE; + word_ptr+=2; + + *out_ptr++=WSD_WORD_CHAR; + StrCpy(out_ptr,st); + out_ptr+=StrLen(st)+1; + } + Free(st); + + do { + do { + cmd=WsdNextCmd(&in_ptr); + if (cmd==WSD_H1) + goto next_word; + } while (cmd>=0 && !(cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA)); + if (cmd==WSD_DEF) { + if(st=WsdNextEntry(&in_ptr)) { + if (*st) { + *out_ptr++=WSD_DEF_CHAR; + StrCpy(out_ptr,st); + out_ptr+=StrLen(st)+1; + } + Free(st); + } + } else if (cmd==WSD_PRONUNCIATION) { + if(st=WsdNextEntry(&in_ptr)) { + if (*st) { + *out_ptr++=WSD_PRONUNCIATION_CHAR; + StrCpy(out_ptr,st); + out_ptr+=StrLen(st)+1; + } + Free(st); + } + } else if (cmd==WSD_POS) { + if(st=WsdNextEntry(&in_ptr)) { + if (*st) { + *out_ptr++=WSD_POS_CHAR; + StrCpy(out_ptr,st); + out_ptr+=StrLen(st)+1; + } + Free(st); + } + } else if (cmd==WSD_EXTRA) { + if(st=WsdNextEntry(&in_ptr)) { + if (*st) { + *out_ptr++=WSD_EXTRA_CHAR; + StrCpy(out_ptr,st); + out_ptr+=StrLen(st)+1; + } + Free(st); + } + } + } while (cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA); + } else + Free(st); + } + } + } while (cmd>=0); + *out_ptr++=WSD_END_CHAR; + *word_ptr++=WSD_END_CHAR; + + Free(in_start); + + PrintF("Blk Size :%d\r\n",WSD_BLK_SIZE); + PrintF("Blk Cnt :%04X\r\n",(out_ptr-out_start+WSD_BLK_SIZE-1)/WSD_BLK_SIZE); + PrintF("Largest Entry :%d\r\n",largest_entry); + PrintF("Word Count :%d\r\n",word_cnt); + + WriteFile(WSD_DEF_FILENAME,out_start,out_ptr-out_start); + PrintF("Def File Size :%d\r\n",out_ptr-out_start); + + sorted_word_start=WsdSortWords(word_start,word_ptr-word_start,word_cnt); + WriteFile(WSD_WORD_FILENAME,sorted_word_start,word_ptr-word_start); + PrintF("Word File Size:%d\r\n",word_ptr-word_start); + + Free(out_start); + Free(word_start); + Free(sorted_word_start); +} + + +public void WsdLoadWords() +{ + I8 size; + SysHashEntry *temph; + I1 *in_ptr,*in_start,*st2; + U2 *d; + ws_dict_num_words=0; + if (in_ptr=ReadFile(WSD_WORD_FILENAME,&size)) { + in_start=in_ptr; + ws_dict_word_list=AMAlloc(size); + MemCpy(ws_dict_word_list,in_start,size); + ws_dict_word_list_size=size; + + while (in_ptrstr=temph+sizeof(SysHashEntry); + temph->use_cnt=1; + temph->type=HTT_DICT_WORD; + d=in_ptr; + temph->user_data0=*d; + in_ptr+=2; + AddSysHashEntry(temph,ws_hash_table); + ws_dict_num_words++; + } else + in_ptr+=3; + } + Free(in_start); + } +} + + +public I1 *WsdGetDef(I1 *st,I8 def_num=1) +{ + LTFile *f; + SysHashEntry *temph; + I1 *result=NULL,*buf,*in_ptr; + I1 *st2=MStrUtil(st,SU_TO_UPPER); + temph=FindHashEntry(st2,ws_hash_table,HTT_DICT_WORD); + Free(st2); + if (temph) { + if (f=FOpen(WSD_DEF_FILENAME,"r")) { + buf=MAlloc(WSD_BLK_SIZE*2+1); + buf[WSD_BLK_SIZE*2]=0; //terminate + FRBlks(f,buf,temph->user_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE); + FClose(f); + in_ptr=buf; + while (in_ptruser_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE); + FClose(f); + in_ptr=buf; + while (in_ptr>1; + r=r1; + while (*r!=WSD_WORD_CHAR && r>ws_dict_word_list) + r--; + if (r[2]==WSD_WORD_CHAR) + r+=2; + else + if (r[1]==WSD_WORD_CHAR) + r++; + if (*r==WSD_WORD_CHAR) + r++; + if (StrNICmp(st,r,n)<=0) + end=r1; + else + start=r1; + } + if (r>ws_dict_word_list) + r--; + } + return r; +} + + +void WsdAddDictWords(Ltf *l,I1 *st=NULL) +{ + I8 i; + I1 *ptr; + if (!st) + st=ws_cur_word; + if (st) { + if (ptr=WsdPointAtWord(st)) { + for (i=0;i=0 && nws_partial_len) + Auto(s+ws_partial_len); + } +} + + +public void WsdDisplayDefs(Ltf *l,I1 *st,I8 num=-1) +{ + I1 *st2,*st3,ch; + I8 i=0; + if (!st) return; + if (*st==WSD_WORD_CHAR) + st++; + LtfPrintF(l,"$$WW,1$$$$FG,RED$$%s:$$FG$$\r\n\r\n",st); + if (num<0) { + if (st3=WsdGetWord(st)) { + st2=st3; + while (ch=*st2++) { + switch (ch) { + case WSD_WORD_CHAR: + break; + case WSD_DEF_CHAR: + LtfPrintF(l,"$$FG,GREEN$$(%d)$$FG$$ %s\r\n", + ++i,st2); + break; + case WSD_PRONUNCIATION_CHAR: + LtfPrintF(l,"$$FG,LTGREEN$$%s$$FG$$\r\n",st2); + break; + case WSD_POS_CHAR: + LtfPrintF(l,"$$FG,BLACK$$%s$$FG$$\r\n",st2); + break; + case WSD_EXTRA_CHAR: + LtfPrintF(l,"$$FG,LTBLUE$$%s$$FG$$\r\n",st2); + break; + } + st2+=StrLen(st2)+1; + } + Free(st3); + } + } else { + while (st2=WsdGetDef(st,++i)) { + if (i==num) + LtfPrintF(l,"$$FG,GREEN$$(%d)$$FG$$ %s\r\n", + i,st2); + Free(st2); + } + } +} + +void WsdPopUpDef(I1 *st,I8 num=-1,TssStruct *parent=NULL) +{ + I1 *buf; + buf=MSPrintF("WsdDisplayDefs(Fs->cur_ltf,\"%s\",%d);View;",st,num); + PopUp(buf,parent); + Free(buf); +} + +void WsdDef(I8 n,TssStruct *parent=NULL) +{ + if (n>=0 && nhits++; return tempw; } - tempw1=FindHashBucket(w,ws_hash_table); tempw=AMAllocZ(sizeof(WsHashEntry)); - tempw->word=ANewString(w); + tempw->word=ANewStr(w); tempw->type=HTT_WORD; tempw->use_cnt=1; tempw->hits=1; tempw->num=-1; - tempw->next=*tempw1; - *tempw1=tempw; + AddSysHashEntry(tempw,ws_hash_table); ws_num_words++; return tempw; } @@ -129,7 +64,7 @@ void WsInitSides(WsMatrix *m) } WsStruct *WsFindStruct(WsMatrix *m,I8 col,I8 row, - I4 *row_base,I4 *substruct) + I8 *row_base,I8 *substruct) { WsStruct *tempa; if (row>=ws_num_matrix_words || @@ -169,41 +104,42 @@ WsStruct *WsFindStruct(WsMatrix *m,I8 col,I8 row, public I8 WsGetHits(WsMatrix *m,I8 col,I8 row) { I8 row_base,substruct; + WsStruct *tempa; if (row>=ws_num_matrix_words || col>=ws_num_matrix_words) return 0; - WsStruct *tempa=WsFindStruct(m,col,row, + 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; + I8 i=(s-&(*parent)->subs)>>WS_SUBSTRUCT_SIZE_BITS+1; if (i>=(*parent)->substructs) { i=0; *parent=(*parent)->next; if ((*parent)->substructs==-1) return NULL; } - return (*parent)->subs+i*sizeof(WsSubstruct); + return &(*parent)->subs[i]; } WsSubstruct *WsLast(WsSubstruct *s,WsStruct **parent) { - I8 i=(s-&(*parent)->subs)/sizeof(WsSubstruct)-1; + I8 i=(s-&(*parent)->subs)>>WS_SUBSTRUCT_SIZE_BITS-1; if (i<0) { *parent=(*parent)->last; if ((*parent)->substructs==-1) return NULL; i=(*parent)->substructs-1; } - return (*parent)->subs+i*sizeof(WsSubstruct); + return &(*parent)->subs[i]; } void WsRemove(WsSubstruct *s,WsStruct *parent) { - I8 i=(s-&parent->subs)/sizeof(WsSubstruct); + I8 i=(s-&parent->subs)>>WS_SUBSTRUCT_SIZE_BITS; if (i<0 || i>=WS_SUBSTRUCTS_PER_STRUCT || parent->substructs<1) return; if (parent->substructs==1) { @@ -220,7 +156,7 @@ void WsRemove(WsSubstruct *s,WsStruct *parent) WsSubstruct *WsInsert(WsSubstruct *s,WsStruct **parent,WsSubstruct *last) { WsStruct *tempa,*p=*parent; - I8 j,k,i=(last-&p->subs)/sizeof(WsSubstruct)+1; + I8 j,k,i=(last-&p->subs)>>WS_SUBSTRUCT_SIZE_BITS+1; if (i>=WS_SUBSTRUCTS_PER_STRUCT) { i=0; p=p->next; @@ -355,13 +291,11 @@ I8 WsIncHits(WsMatrix *m,I8 col,I8 row) 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; + WsHashEntry *cur_ptr,*last_ptr=NULL; + I8 k=0; buf=ReadTextFile(tempd->full_name); ptr=buf; @@ -381,27 +315,19 @@ void WsAddSingleFile(LTDirEntry *tempd,BoolU4 compile) 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;inum,(*f_ptr)->num); - } - } - } - fp=(fp+1)&(WS_FIFO_SIZE-1); + cur_ptr=FindHashEntry(ptr,ws_hash_table,HTT_WORD); + if (cur_ptr->num<0) + cur_ptr=NULL; + else + if (last_ptr) + WsIncHits(ws_matrix,last_ptr->num,cur_ptr->num); + last_ptr=cur_ptr; } ptr=ptr2+1; } if (!ch1) break; *ptr2=ch1; } - Free(fifo); Free(buf); } @@ -415,12 +341,12 @@ void WsAddGlossFile(LTDirEntry *tempd) ll=l->dummy.next; while (ll!=l) { if (ll->btype==LTFT_ANCHOR) { - if (temph=FindHashEntry(ll->aux_string, + if (temph=FindHashEntry(ll->aux_str, ws_hash_table,HTT_WORD)) { temp=MSPrintF("FA:%s,%s", - tempd->full_name,ll->aux_string); + tempd->full_name,ll->aux_str); AFree(temph->glossary); - temph->glossary=ANewString(temp); + temph->glossary=ANewStr(temp); Free(temp); } } @@ -437,24 +363,6 @@ I8 WsSort(WsHashEntry **e1,WsHashEntry **e2) 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; @@ -468,7 +376,7 @@ I8 WsSkipCrap(I1 *src,I8 len) return j+1; } -I8 WsPriorWordInString(I1 *src,I1 *dst,I8 len,I8 buf_size) +I8 WsPriorWordInStr(I1 *src,I1 *dst,I8 len,I8 buf_size) { I8 i,j=0,k; BoolU4 cont=TRUE; @@ -487,7 +395,7 @@ I8 WsPriorWordInString(I1 *src,I1 *dst,I8 len,I8 buf_size) } -BoolU4 WsPartialMatch(I1 *partial,I1 *complete) +BoolU8 WsPartialMatch(I1 *partial,I1 *complete) { I8 i,l=StrLen(partial); for (i=0;i=0 && nword; + s=ws_sorted_words[ws_fillin_matches[n]]->word; len=StrLen(s); if (len>ws_partial_len) Auto(s+ws_partial_len); @@ -522,7 +425,7 @@ void WsMan(I8 n,TssStruct *parent=NULL) BoolU4 old_preempt=Preempt(OFF); n--; if (n>=0 && nglossary; if (temph=FindHashEntry(tempw->word,Fs->hash_table,HTT_ALL)) { if (temph->source_link) @@ -543,34 +446,33 @@ void WsAddFillin(I8 i,I8 j,I8 old_num_fillins) { BoolU4 cont; I8 k; - if (ws_num_fillinsfillin_scores[ws_num_fillins-1] || - i==fillin_scores[ws_num_fillins-1] && ws_sorted_words[j]->hits>fillin_hits[ws_num_fillins-1]) { + if (ws_num_fillinsws_fillin_scores[ws_num_fillins-1] || + i==ws_fillin_scores[ws_num_fillins-1] && ws_sorted_words[j]->hits>ws_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]) { + if (i<=ws_fillin_scores[k] || i==ws_fillin_scores[k] && ws_sorted_words[j]->hits<=ws_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]; + ws_fillin_scores[k+1]=ws_fillin_scores[k]; + ws_fillin_matches[k+1]=ws_fillin_matches[k]; + ws_fillin_hits[k+1]=ws_fillin_hits[k]; } - if (ws_num_fillinshits; - fillin_matches[k+1]=j; + ws_fillin_scores[k+1]=i; + ws_fillin_hits[k+1]=ws_sorted_words[j]->hits; + ws_fillin_matches[k+1]=j; } } -void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll) +void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll,TssStruct *focus_tss) { I8 i,j,k,data_col; I1 ch=0,*buf,*buf1,*src=NULL,*st; WsHashEntry *w2; - U8 timeout_jiffies=jiffies+JIFFY_FREQ*20/1000; + U8 timeout_jiffies=Jiffies+JIFFY_FREQ*20/1000; SysHashEntry *temph; - TssStruct *tss; src=LtfGetLine(focus_l,ll,&data_col); i=StrLen(src); @@ -578,56 +480,67 @@ void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll) buf1=MAlloc(i+1); if (data_col==-1) data_col=StrLen(i); - data_col=WsPriorWordInString(src,buf,data_col,256); + data_col=WsPriorWordInStr(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); + data_col=WsPriorWordInStr(src,buf1,data_col,256); + + if (ws_cur_word) { + if (!StrCmp(ws_cur_word,buf)) + goto done; + } + st=ws_cur_word; + ws_cur_word=ANewStr(buf); + AFree(st); + Preempt(ON); if (StrLen(buf1)) w2=FindHashEntry(buf1,ws_hash_table,HTT_WORD); else w2=NULL; - Free(src); ws_num_fillins=0; if (w2 && w2->numword)) { - i=WsGetHits(&ws_matrices[0],w2->num,ws_sorted_words[j]->num); + for (j=0;jword)) { + i=WsGetHits(ws_matrix,w2->num,ws_sorted_words[j]->num); WsAddFillin(i,j,0); } k=ws_num_fillins; - for (j=0;jword)) + for (j=0;jword)) 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; + Preempt(OFF); - LtfPrintF(l,"Word:%-20ts\r\n",ws_cur_word); - for (i=0;iword; - 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='*'; - } +done: + LtfReset(l,TRUE); + l->flags|=LTFF_MIN_SIZE; + l->start_text_attribute=(LTBLUE<<4)+BLACK; + aux->start_text_attribute=(LTBLUE<<4)+BLACK; + Fs->text_attribute=l->start_text_attribute; + Fs->border_attribute=l->start_text_attribute; + + LtfPrintF(l,"Word:%-20ts\r\n",ws_cur_word); + for (i=0;iword; + if (ws_sorted_words[ws_fillin_matches[i]]->glossary) + ch='#'; + else + ch=CH_SPACE; + if (focus_tss) { + temph=FindHashEntry(st,focus_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); + LtfPrintF(l,"%cF%02d %-20ts\r\n",ch,i+1,st); } + WsdAddDictWords(l); + + LtfRecalc(l); + Bts(&Fs->crt_flags,CRTf_SHOW); + WinToTop(Fs); + + Free(src); Free(buf); Free(buf1); } @@ -635,22 +548,20 @@ void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll) 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; + Fs->win_left=50; do { - Sleep(500); - if (!ws_disable) { + Sleep(333); + if (Bt(&ws_flags,WSf_ENABLE)) { focus_tss=sys_cur_focus_task; - if (focus_tss) { + while (Bt(&focus_tss->task_flags,TSSf_INPUT_FILTER_TASK)) + focus_tss=focus_tss->parent_tss; + if (ValidateTss(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; @@ -659,77 +570,154 @@ void WsTsk() 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); + if (Bt(&ws_flags,WSf_ENABLE)) + WsPutChoices(Fs->cur_ltf,Fs->aux_ltf,l,ll,focus_tss); } } } } - } while (!ScanChar(&sc,&ch)); + } while (!ScanKey); ws_task=NULL; } - - -void WsAdd(I1 *wild=TEXT_FILE_MASK,BoolU4 gloss) +void WsTraverseMainFilelist(WsFilemaskEntry *tempfm,BoolU4 compile) { - 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; + WsFilemaskEntry *tempfm1; + LTDirEntry *tempm; + I8 i; + while (tempfm) { + tempfm1=tempfm->next; + if (!compile) { + tempm=FindFiles(tempfm->mask,1<flist=OrderFiles(tempm,&tempfm->cnt); + } + for (i=0;icnt;i++) { + tempm=tempfm->flist[i]; + if (IsTextFile(tempm->name)) { + coutln tempm->full_name; + WsAddSingleFile(tempm,compile); + } + if (compile) + DelLTDirEntry(tempm); + } + if (compile) { + Free(tempfm->flist); + Free(tempfm); + } + tempfm=tempfm1; } - tempfm->mask=ANewString(wild); - tempfm->flist=NULL; } -void WsTraverseFilelist(BoolU4 compile,BoolU4 gloss) +void WsTraverseGlossFilelist(WsFilemaskEntry *tempfm) { - WsFilemaskEntry *tempfm; - U8 my_flags=(1<flist=FindFiles(tempfm->mask,&my_flags); - WsAddFileList(tempfm->flist,compile,gloss); - tempfm=tempfm->next; + tempfm1=tempfm->next; + tempm=FindFiles(tempfm->mask,1<flist=OrderFiles(tempm,&tempfm->cnt); + for (i=0;icnt;i++) { + tempm=tempfm->flist[i]; + if (WildCardMatch("*.GL?",tempm->name)) { + coutln tempm->full_name; + WsAddGlossFile(tempm); + } + DelLTDirEntry(tempm); + } + Free(tempfm->flist); + Free(tempfm); + tempfm=tempfm1; } } + +void WsDelMatrix(WsMatrix *m) +{ + I8 i; + WsStruct *tempw,*tempw1,*tempw2; + if (!m) return; + for (i=0;iside[i]; + tempw=tempw1->next; + while (tempw!=tempw1) { + tempw2=tempw->next; + AFree(tempw); + tempw=tempw2; + } + } + AFree(m); +} + + +public BoolU8 WordStat(BoolU8 val=ON) +{ + BoolU4 old_wordstat=FALSE, + old_preempt=Preempt(OFF); + if (val) { + Bts(&ws_flags,WSf_ENABLE); + if (ValidateTss(ws_task)) + old_wordstat=TRUE; + else + ws_task=Spawn(&WsTsk,"WordStat"); + } else { + Btr(&ws_flags,WSf_ENABLE); + if (ValidateTss(ws_task)) { + old_wordstat=TRUE; + Kill(ws_task); + while (ValidateTss(ws_task)) + SwapInNext; + ws_task=NULL; + } + Bts(&ws_flags,WSf_ENABLE); + } + Preempt(old_preempt); + return old_wordstat; +} + public void WsInit(I1 *mask) +// Separate directories with ';' { I1 *buf,buf2[512]; I8 i,j=0; WsHashEntry *tempw; + BoolU4 old_wordstat; + WsFilemaskEntry *tempfm,*tempfm1; - ws_disable=TRUE; + while (Bts(&ws_flags,WSf_INIT_IN_PROGRESS)) + SwapInNext; + + old_wordstat=WordStat(OFF); + + if (Fs==adam_tss) + DelHashTable(ws_hash_table); + else + Adam("DelHashTable(ws_hash_table);"); + ws_hash_table=NewHashTable(0x4000,adam_tss); -//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)); + AFree(ws_cur_word); ws_cur_word=NULL; - ws_filemask_list=NULL; - ws_gloss_filemask_list=NULL; - buf=NewString(mask); + tempfm1=NULL; + buf=NewStr(mask); do { RemoveFirstSeg(buf,";",buf2); if (*buf2) { - StrCat(buf2,"/" TEXT_FILE_MASK); - WsAdd(buf2,FALSE); + tempfm=MAlloc(sizeof(WsFilemaskEntry)); + tempfm->next=tempfm1; + tempfm1=tempfm; + tempfm->mask=NewStr(buf2); + tempfm->flist=NULL; } } while (*buf2); Free(buf); coutln "\r\n\r\nPass #1"; - WsTraverseFilelist(FALSE,FALSE); - ws_sorted_words=AMAlloc(PTR_SIZE*ws_num_words); + WsTraverseMainFilelist(tempfm1,FALSE); + AFree(ws_sorted_words); + ws_sorted_words=AMAlloc(sizeof(void *)*ws_num_words); for (i=0;i<=ws_hash_table->mask;i++) { tempw=ws_hash_table->body[i]; @@ -738,7 +726,7 @@ public void WsInit(I1 *mask) tempw=tempw->next; } } - QSort(ws_sorted_words,ws_num_words,PTR_SIZE,&WsSort); + QSort(ws_sorted_words,ws_num_words,sizeof(void *),&WsSort); for (i=0;inum=i; if (ws_num_words<=WS_MAX_MATRIX_WORDS) @@ -746,24 +734,34 @@ public void WsInit(I1 *mask) else ws_num_matrix_words=WS_MAX_MATRIX_WORDS; - for (i=0;inext=tempfm1; + tempfm1=tempfm; + tempfm->mask=NewStr(buf2); + tempfm->flist=NULL; } } while (*buf2); Free(buf); - coutln "\r\n\r\nGlossary Pass"; - WsTraverseFilelist(FALSE,TRUE); - ws_disable=FALSE; + coutln "\r\n\r\nGlossary Pass"; + WsTraverseGlossFilelist(tempfm1); + AFree(ws_dict_word_list); + WsdLoadWords; + WordStat(old_wordstat); + Btr(&ws_flags,WSf_INIT_IN_PROGRESS); } + \ No newline at end of file diff --git a/LT/Adam/WordStat/WordStat.APZ b/LT/Adam/WordStat/WordStat.APZ new file mode 100644 index 0000000..87ed48b --- /dev/null +++ b/LT/Adam/WordStat/WordStat.APZ @@ -0,0 +1,100 @@ +#help_index "WordStat" +#help_file "::/LT/Doc/WordStat.TXZ" + +#define WS_SUBSTRUCT_SIZE_BITS 3 +class WsSubstruct +{ + I4 hits,repeats; +}; + +#define WS_SUBSTRUCTS_PER_STRUCT 8 +class WsStruct +{ + WsStruct *next,*last; + I8 substructs, //-1 means WsMatrixSide + entries; + WsSubstruct subs[WS_SUBSTRUCTS_PER_STRUCT]; +}; + +class WsMatrixSide +{ + WsStruct *next,*last; + I8 const_minus_one, //-1 used to header in queue + row_hits,col_hits; +}; + +#define WS_MAX_MATRIX_WORDS 0x8000 +class WsMatrix +{ + I8 n; + WsMatrixSide side[WS_MAX_MATRIX_WORDS]; +}; + +public I8 ws_num_words,ws_num_matrix_words; +SysHashTable *ws_hash_table=NULL; +public I1 *ws_cur_word=NULL; + +#define WSf_ENABLE 0 +#define WSf_INIT_IN_PROGRESS 1 +U8 ws_flags=0; + +public WsMatrix *ws_matrix=NULL; +public WsHashEntry **ws_sorted_words=NULL; +TssStruct *ws_task=NULL; + +class WsFilemaskEntry +{ + WsFilemaskEntry *next; + I1 *mask; + I8 cnt; + LTDirEntry **flist; +}; + + + +#define WS_MAX_FILLINS 10 +I8 ws_partial_len=0,ws_fillin_matches[WS_MAX_FILLINS+1]; +I8 ws_num_fillins=0,ws_fillin_scores[WS_MAX_FILLINS+1],ws_fillin_hits[WS_MAX_FILLINS+1]; + +/**************** Dictionary Stuff ************/ + +#define WSD_RAW_FILENAME "/Text/Dictionary.TTZ" //this is a file I got from project gutenburg +#define WSD_WORD_FILENAME "/LT/Adam/WordStat/WsWords.DTZ" +#define WSD_DEF_FILENAME "/LT/Adam/WordStat/WsDefs.DAT" + +#define WSD_H1 0 +#define WSD_H1_END 1 +#define WSD_DEF 2 +#define WSD_DEF_END 3 +#define WSD_PRONUNCIATION 4 +#define WSD_PRONUNCIATION_END 5 +#define WSD_POS 6 +#define WSD_POS_END 7 +#define WSD_EXTRA 8 +#define WSD_EXTRA_END 9 +#define WSD_BLK_SIZE 0x4000 + +#define WSD_END_CHAR 0x00 +#define WSD_WORD_CHAR 0x01 +#define WSD_DEF_CHAR 0x02 +#define WSD_PRONUNCIATION_CHAR 0x03 +#define WSD_POS_CHAR 0x04 +#define WSD_EXTRA_CHAR 0x05 + +I1 *ws_dict_word_list=NULL; +I8 ws_dict_word_list_size=0, + ws_dict_num_words=0; + +extern void WsdLoadWords(); +extern void WsdAddDictWords(Ltf *l,I1 *st=NULL); + +#define WSD_MAX_FILLINS 10 +I1 *wsd_fillins[WSD_MAX_FILLINS]; +I8 wsd_num_fillins=0; + +/******************************************/ + +#include "WSMain.APZ" +#include "WSDict.APZ" + +#help_index "" diff --git a/LT/Adam/WordStat/WsDefs.DAT b/LT/Adam/WordStat/WsDefs.DAT new file mode 100644 index 0000000..ce7cc05 Binary files /dev/null and b/LT/Adam/WordStat/WsDefs.DAT differ diff --git a/LT/Adam/WordStat/WsWords.DTZ b/LT/Adam/WordStat/WsWords.DTZ new file mode 100644 index 0000000..1ae5287 Binary files /dev/null and b/LT/Adam/WordStat/WsWords.DTZ differ diff --git a/LT/Apps/MusicOrgan/Examples/action.CPZ b/LT/Apps/MusicOrgan/Examples/action.CPZ new file mode 100644 index 0000000..918fd76 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/action.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/alike.CPZ b/LT/Apps/MusicOrgan/Examples/alike.CPZ new file mode 100644 index 0000000..18a5ccc Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/alike.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/almighty.CPZ b/LT/Apps/MusicOrgan/Examples/almighty.CPZ new file mode 100644 index 0000000..9eef72b Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/almighty.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/appreciate.CPZ b/LT/Apps/MusicOrgan/Examples/appreciate.CPZ new file mode 100644 index 0000000..107ca81 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/appreciate.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/approve.CPZ b/LT/Apps/MusicOrgan/Examples/approve.CPZ new file mode 100644 index 0000000..7f28ed9 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/approve.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/architects.CPZ b/LT/Apps/MusicOrgan/Examples/architects.CPZ new file mode 100644 index 0000000..b586a02 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/architects.CPZ @@ -0,0 +1,23 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3sFGFGetBFFDARqEC2G3FC"); + Play("sFGFGetBFFDARqEC2G3FC"); + Play("2eG3GetDB2G3qFDAReECsCRCR"); + Play("2eG3GetDB2G3qFDAReECsCRCR"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/bedewed.CPZ b/LT/Apps/MusicOrgan/Examples/bedewed.CPZ new file mode 100644 index 0000000..0bd3605 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/bedewed.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/blinded.CPZ b/LT/Apps/MusicOrgan/Examples/blinded.CPZ new file mode 100644 index 0000000..578fa5d --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/blinded.CPZ @@ -0,0 +1,36 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + tss=PopUpViewStr( + "$$LK-A,\"BF:Acts,9:3\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qEeACA2G3qCEC2G3E", + "Now... \0 \0 \0 \0 \0I \0see \0the \0light.\r\n\0 \0"); + Play("EeACA2G3qCEC2G3E", + "Now... \0 \0 \0 \0 \0I \0see \0the \0light.\r\n\0 \0"); + Play("GCGBEeDFCAqD", + "It's \0 \0quite \0 \0bright.\r\n\0 \0 \0 \0 \0 \0"); + Play("GCGBEeDFCAqD", + "It's \0 \0quite \0 \0bright.\r\n\0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/ceaseth.CPZ b/LT/Apps/MusicOrgan/Examples/ceaseth.CPZ new file mode 100644 index 0000000..128028d Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/ceaseth.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/childish.CPZ b/LT/Apps/MusicOrgan/Examples/childish.CPZ new file mode 100644 index 0000000..7a03ace Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/childish.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/comprise.CPZ b/LT/Apps/MusicOrgan/Examples/comprise.CPZ new file mode 100644 index 0000000..a6c44ad Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/comprise.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/depending.CPZ b/LT/Apps/MusicOrgan/Examples/depending.CPZ new file mode 100644 index 0000000..3af4acf --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/depending.CPZ @@ -0,0 +1,36 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + tss=PopUpViewStr( + "$$LK-A,\"BF:Luke,12:16\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + while (!ScanKey) { + Play("3etGREqDDBRGCB", + "It \0 \0de\0pends \0 \0on \0 \0the \0wea\0ther.\r\n\0"); + Play("etGREqDDBRGCB", + "If \0 \0we \0reach \0 \0the \0 \0end \0ev\0er.\r\n\0"); + Play("2sG3E2G3EqGsGBGBqDsFCFCqBRsCBCB", + "Hand \0 \0of \0 \0God, \0 \0just \0 \0might, \0 \0in\0 \0ter\0 \0cedes.\r\n\0 \0 \0 \0 \0 \0"); + Play("2G3E2G3EqGsGBGBqDsFCFCqBRsCBCB", + "If \0 \0it's \0 \0not \0 \0deemed \0 \0right, \0 \0won't \0 \0suc\0 \0ceed.\r\n\0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/discerning.CPZ b/LT/Apps/MusicOrgan/Examples/discerning.CPZ new file mode 100644 index 0000000..261fec1 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/discerning.CPZ @@ -0,0 +1,20 @@ +//star +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("etCCBetGGDetBBFeGCetBABeAAqEqF"); + Play("etCCBetGGDetBBFeGCetBABeAAqEqF"); + Play("eCGqFqDqDqCeDGqCqB"); + Play("eCGqFqDqDqCeDGqCqB"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/downfall.CPZ b/LT/Apps/MusicOrgan/Examples/downfall.CPZ new file mode 100644 index 0000000..530c7e6 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/downfall.CPZ @@ -0,0 +1,22 @@ +//has words,star,star +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("et2G32G3Gq2G3qCq2G3sFAFAq2G3etGDAqA", + "Don't \0 \0need \0 \0help. \0 \0Got \0 \0it \0 \0all \0figured \0 \0 \0out.\r\n\0"); + Play("et2G32G3Gq2G3qCq2G3sFAFAq2G3etGDAqA", + "Don't \0 \0need \0 \0help. \0 \0Got \0 \0it \0 \0all \0figured \0 \0 \0out.\r\n\0"); + Play("etCCCq2G3qDeDFetCF2G3qBeGFsAGAG"); + Play("etCCCq2G3qDeDFetCF2G3qBeGFsAGAG"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/eternity.CPZ b/LT/Apps/MusicOrgan/Examples/eternity.CPZ new file mode 100644 index 0000000..40239e0 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/eternity.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ b/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ new file mode 100644 index 0000000..e0b6c54 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/exalt.CPZ b/LT/Apps/MusicOrgan/Examples/exalt.CPZ new file mode 100644 index 0000000..d165b82 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/exalt.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/fairness.CPZ b/LT/Apps/MusicOrgan/Examples/fairness.CPZ new file mode 100644 index 0000000..a24e574 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/fairness.CPZ @@ -0,0 +1,41 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + tss=PopUpViewStr( + "$$LK-A,\"BF:Luke,7:42\"$$\r\n" + "\r\n" + "Prodigal Son\r\n" + "$$LK-A,\"BF:Luke,15:21\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + music_tempo=2.5; + try { + PutS("$$WW+H,1$$"); + while (!ScanKey) { + Play("3qGGsEAEAqAsF2G3F2G3qCeEFqD", + "Life, \0life, \0isn't \0 \0 \0 \0fair. \0Isn't \0 \0 \0 \0fair.\r\n\0 \0 \0 \0"); + Play("GGsEAEAqAsF2G3F2G3qCeEFqD", + "Life, \0life, \0isn't \0 \0 \0 \0fair. \0Isn't \0 \0 \0 \0fair.\r\n\0 \0 \0 \0"); + Play("eFCqEBDBE2eG3EsFEFE", + " \0 \0I \0 \0ne\0ver \0sin.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("eFCqEBDBE2eG3EsFEFE", + " \0 \0I \0 \0ne\0ver \0win.\r\n\0 \0 \0 \0 \0 \0 \0"); + PutS("$$FG,GREEN$$(A warning on presumption. 'Who loves more man -- forgiven big debt or little?' See prodigal son.)$$FG$$\r\n"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/first.CPZ b/LT/Apps/MusicOrgan/Examples/first.CPZ new file mode 100644 index 0000000..e6e5598 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/first.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/fishermen.CPZ b/LT/Apps/MusicOrgan/Examples/fishermen.CPZ new file mode 100644 index 0000000..54e37ac --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/fishermen.CPZ @@ -0,0 +1,38 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + tss=PopUpViewStr( + "$$LK-A,\"BF:Matthew,4:19\"$$\r\n" + "$$LK-A,\"BF:Luke,5:4\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + + while (!ScanKey) { + Play("3qEsGEGEeF2G3BCqCeDEqBsERER", + "$$FG$$Lord, \0I \0 \0am \0 \0feel\0ing \0just \0a \0bit \0un\0in\0spired.\r\n\0With \0 \0 \0 \0"); + Play("qEsGEGEeF2G3BCqCeDEqBsERER", + "net \0or \0 \0with \0 \0reel\0ing \0 \0I \0keep \0get\0ting \0mired.\r\n\0 \0 \0 \0 \0"); + Play("qDetRAFqDGetFC2G3sBCBCqDF", + "$$FG,PURPLE$$Throw \0 \0out \0your \0net.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("DetRAFqDGetFC2G3sBCBCqDF", + "Make \0 \0you \0a \0bet.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/forgive.CPZ b/LT/Apps/MusicOrgan/Examples/forgive.CPZ new file mode 100644 index 0000000..9250585 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/forgive.CPZ @@ -0,0 +1,20 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("eGFqCqAqCqAetFDBetDBGeAFeGFqCqAqCqAetFDBetDBGeAFsDEDEetAGEsARARqDsARARqAetRFEqBsDEDEetAGEsARARqDsARARqAetRFEqB"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/forstress.CPZ b/LT/Apps/MusicOrgan/Examples/forstress.CPZ new file mode 100644 index 0000000..54a06d6 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/forstress.CPZ @@ -0,0 +1,20 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("eEEeGGeRReRCetABCeEDsABABe2G3GeEEeGGeRReRCetABCeEDsABABe2G3GqRqFetFFDeCRqEeFCqFet2G3RFqRqFetFFDeCRqEeFCqFet2G3RF"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/fun.CPZ b/LT/Apps/MusicOrgan/Examples/fun.CPZ new file mode 100644 index 0000000..9e1f54e Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/fun.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/gladdened.CPZ b/LT/Apps/MusicOrgan/Examples/gladdened.CPZ new file mode 100644 index 0000000..4ab068e Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/gladdened.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/good.CPZ b/LT/Apps/MusicOrgan/Examples/good.CPZ new file mode 100644 index 0000000..77f8ca2 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/good.CPZ @@ -0,0 +1,27 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qFeRRqAeRAqGDetBACeCB", + "God \0 \0 \0is \0 \0a \0good \0God. \0(Thank \0 \0 \0God!!)\r\n\0 \0"); + Play("qFeRRqAeRAqGDetBACeCB", + "God \0 \0 \0is \0 \0a \0good \0God. \0(Thank \0 \0 \0God!!)\r\n\0 \0"); + Play("qGsCECEeC2GqR3FeEDqEF", + " \0 \0 \0 \0 \0 \0 \0 \0He \0is \0a \0good \0God.\r\n\0"); + Play("GsCECEeC2GqR3FeEDqEF", + " \0 \0 \0 \0 \0 \0 \0 \0He \0is \0a \0good \0God.\r\n\0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/heldest.CPZ b/LT/Apps/MusicOrgan/Examples/heldest.CPZ new file mode 100644 index 0000000..7a60b7b --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/heldest.CPZ @@ -0,0 +1,27 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3eGCBEqDAEetFECqED", + "Do \0an \0act \0of \0kind\0ness.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("eGCBEqDAEetFECqED", + "Do \0an \0act \0of \0kind\0ness.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("GFEEeAAqDFF", + " \0 \0 \0 \0Hold \0 \0a \0hand.\r\n\0 \0"); + Play("GFEEeAAqDFF", + " \0 \0 \0 \0Hold \0 \0a \0hand.\r\n\0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/heretofore.CPZ b/LT/Apps/MusicOrgan/Examples/heretofore.CPZ new file mode 100644 index 0000000..37ef216 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/heretofore.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/hope.CPZ b/LT/Apps/MusicOrgan/Examples/hope.CPZ new file mode 100644 index 0000000..8094bd5 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/hope.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/including.CPZ b/LT/Apps/MusicOrgan/Examples/including.CPZ new file mode 100644 index 0000000..5aca747 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/including.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/income.CPZ b/LT/Apps/MusicOrgan/Examples/income.CPZ new file mode 100644 index 0000000..7ff19c4 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/income.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/job.CPZ b/LT/Apps/MusicOrgan/Examples/job.CPZ new file mode 100644 index 0000000..fdd68d2 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/job.CPZ @@ -0,0 +1,27 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qGGGGsGGGGetFFFeEFsGGGG", + "I've \0been \0pat\0ient; \0Grant \0 \0 \0 \0me \0 \0 \0jus\0 \0tice.\r\n\0 \0 \0 \0"); + Play("qGGGGsGGGGetFFFeEFsGGGG", + "Not \0comp\0lan\0cient; \0You \0 \0 \0 \0are \0 \0 \0whit\0 \0ness.\r\n\0 \0 \0 \0"); + Play("BBBBeCCqDDA2G3etAAAqB", + "All \0 \0 \0 \0my \0 \0foes \0 \0re\0joice \0o\0ver \0 \0me.\r\n\0"); + Play("sBBBBeCCqDDA2G3etAAAqB", + "See \0 \0 \0 \0their \0 \0throes; \0 \0Now, \0it's \0they \0that \0are \0stoned.\r\n\0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/kept.CPZ b/LT/Apps/MusicOrgan/Examples/kept.CPZ new file mode 100644 index 0000000..3fed384 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/kept.CPZ @@ -0,0 +1,37 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + try { + tss=PopUpViewStr( + "$$LK-A,\"BF:Matthew,19:16\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + PutS("$$WW+H,1$$"); + while (!ScanKey) { + Play("3eGAetCCCFFDqAeAAFAAFqG", + "I \0 \0have \0 \0 \0kept \0 \0 \0 \0 \0 \0the \0 \0 \0com\0mands.\r\n\0"); + Play("eGAetCCCFFDqAeAAFAAFqG", + "I \0 \0have \0 \0 \0kept \0 \0 \0 \0 \0 \0the \0 \0 \0com\0mands.\r\n\0"); + Play("EeEGqEeEEqDBetCCGqC", + "What \0 \0 \0else \0 \0 \0must \0I \0do?\r\n\0 \0 \0 \0"); + Play("EeEGqEeEEqDBetCCGqC", + "What \0 \0 \0else \0 \0 \0must \0I \0do?\r\n\0 \0 \0 \0"); + PutS("$$FG,GREEN$$(Christ said sell all and follow me.)\r\n$$FG$$"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/king.CPZ b/LT/Apps/MusicOrgan/Examples/king.CPZ new file mode 100644 index 0000000..9e20452 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/king.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/knewest.CPZ b/LT/Apps/MusicOrgan/Examples/knewest.CPZ new file mode 100644 index 0000000..69e1b68 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/knewest.CPZ @@ -0,0 +1,20 @@ +//star +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("qCqFeDEetDCCetCCCqDqAqC"); + Play("qCqFeDEetDCCetCCCqDqAqC"); + Play("qFqEetFAFqAqDeGAqEeBC"); + Play("qFqEetFAFqAqDeGAqEeBC"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/leaving.CPZ b/LT/Apps/MusicOrgan/Examples/leaving.CPZ new file mode 100644 index 0000000..d799ee5 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/leaving.CPZ @@ -0,0 +1,38 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + tss=PopUpViewStr( + "$$LK-A,\"BF:John,16:28\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + PutS("$$WW+H,1$$"); + while (!ScanKey) { + Play("3qBBDsDGDGqFeFAFAqB", + "Now, \0I \0go \0 \0 \0 \0 \0to \0the \0 \0Fa\0th\0er.\r\n\0"); + Play("BBDsDGDGqFeFAFAqB", + "Now, \0I \0go \0 \0 \0 \0 \0to \0the \0 \0Fa\0th\0er.\r\n\0"); + Play("EDetBEA2eG3CsECECqGDeDD", + "Don't \0worry. \0 \0 \0 \0 \0 \0I'll \0 \0 \0 \0be \0back.\r\n\0 \0 \0"); + Play("qEDetBEA2eG3CsECECqGDeDD", + "Don't \0worry. \0 \0 \0 \0 \0 \0I'll \0 \0 \0 \0be \0back.\r\n\0 \0 \0"); + PutS("$$FG,GREEN$$(Christ promised to return.)\r\n$$FG$$"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/limit.CPZ b/LT/Apps/MusicOrgan/Examples/limit.CPZ new file mode 100644 index 0000000..6c4b06d --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/limit.CPZ @@ -0,0 +1,37 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qBDAGFFeBAsD2G3D2G", + "Do \0not \0push \0your \0luck.\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + Play("3qBDAGFFeBAsD2G3D2G", + "Do \0not \0push \0your \0luck.\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + Play("3qGFCeCGqFetAAFqEF", + "God \0is \0not \0 \0a \0schmuck.\r\n\0 \0 \0 \0 \0 \0"); + Play("GFCeCGqFetAAFqEF", + "God \0is \0not \0 \0a \0schmuck.\r\n\0 \0 \0 \0 \0 \0"); + + Play("3qBDAGFFeBAsD2G3D2G", + "\r\nDo \0not \0tell \0the \0Lord\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + Play("3qBDAGFFeBAsD2G3D2G", + "that \0you're \0feel\0ing \0bored.\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + Play("3qGFCeCGqFetAAFqEF", + "He \0will \0send \0 \0the \0sword.\r\n\0 \0 \0 \0 \0 \0"); + Play("GFCeCGqFetAAFqEF", + "He \0will \0send \0 \0the \0sword.\r\n\r\n\0 \0 \0 \0 \0 \0"); + + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/littleton.CPZ b/LT/Apps/MusicOrgan/Examples/littleton.CPZ new file mode 100644 index 0000000..7141aba --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/littleton.CPZ @@ -0,0 +1,24 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + music_stacatto_factor=0.8; + try { + while (!ScanKey) { + Play("3eEEqCGGeGBDGEBsG2G3G2G"); + Play("3eEEqCGGeGBDGEBsG2G3G2G"); + Play("3qFDetB2GGsGGGG3eEEetBEGqGeDA"); + Play("qFDetB2GGsGGGG3eEEetBEGqGeDA"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/meekness.CPZ b/LT/Apps/MusicOrgan/Examples/meekness.CPZ new file mode 100644 index 0000000..d7fb483 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/meekness.CPZ @@ -0,0 +1,28 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qBeGDetCBCqGAeGCqDC", + " \0I \0 \0don't \0 \0 \0mind, \0 \0 \0 \0you \0de\0"); + Play("BeGDetCBCqGAeGCqDC", + "cide.\r\n\0I \0 \0don't \0 \0 \0mind.\r\n\0 \0 \0 \0 \0 \0"); + Play("etDFGqEeDGqFEetDFFqBetBDB", + "I \0trust \0God \0 \0 \0 \0to \0 \0look-out \0for \0me.\r\n\0 \0 \0 \0 \0"); + Play("DFGqEeDGqFEetDFFqBetBDB", + "I \0trust \0God \0 \0 \0 \0to \0 \0look-out \0for \0me.\r\n\0 \0 \0 \0 \0"); + Play("qC"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/mentioned.CPZ b/LT/Apps/MusicOrgan/Examples/mentioned.CPZ new file mode 100644 index 0000000..a1d3d04 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/mentioned.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/mildly.CPZ b/LT/Apps/MusicOrgan/Examples/mildly.CPZ new file mode 100644 index 0000000..3858648 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/mildly.CPZ @@ -0,0 +1,36 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + TssStruct *tss; + tss=PopUpViewStr( + "$$LK-A,\"BF:Mark,4:37\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qEsGEGEqDsCCCCqBsDEDEqFG", + "Lord, \0there's \0 \0a \0 \0storm \0u\0 \0 \0 \0pon \0the \0 \0 \0 \0sea.\r\n\0 \0"); + Play("EsGEGEqDsCCCCqBsDEDEqFG", + "Lord, \0there's \0 \0a \0 \0storm \0u\0 \0 \0 \0pon \0the \0 \0 \0 \0sea.\r\n\0 \0"); + Play("GEC2G3etB2G3FGGEDBBeBE", + "$$FG,PURPLE$$Re\0lax \0fel\0las.$$FG$$\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("qGEC2G3etB2G3FGGEDBBeBE", + "$$FG,GREEN$$(Sea \0be\0came \0glass.)$$FG$$\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/minds.CPZ b/LT/Apps/MusicOrgan/Examples/minds.CPZ new file mode 100644 index 0000000..538cc93 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/minds.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/multiple.CPZ b/LT/Apps/MusicOrgan/Examples/multiple.CPZ new file mode 100644 index 0000000..75f0ab4 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/multiple.CPZ @@ -0,0 +1,36 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + tss=PopUpViewStr( + "$$LK-A,\"BF:Matthew,14:19\"$$\r\n" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + try { + while (!ScanKey) { + Play("3etGCECAFqFFAFBD", + "We \0 \0don't \0 \0have \0e\0nough.\r\n\0 \0 \0 \0 \0 \0"); + Play("etGCECAFqFFAFBD", + "$$FG,PURPLE$$You \0 \0don't \0 \0halve \0e\0nough.\r\n\0 \0 \0 \0 \0 \0"); + Play("AeGFGDqEAeCEGAetFAF", + " \0Try \0 \0 \0 \0to \0share.\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + Play("qAeGFGDqEAeCEGAetFAF", + " \0Try \0 \0 \0 \0to \0share.$$FG$$\r\n\0 \0 \0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/my.CPZ b/LT/Apps/MusicOrgan/Examples/my.CPZ new file mode 100644 index 0000000..594289a Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/my.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/nay.CPZ b/LT/Apps/MusicOrgan/Examples/nay.CPZ new file mode 100644 index 0000000..c76af34 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/nay.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/partake.CPZ b/LT/Apps/MusicOrgan/Examples/partake.CPZ new file mode 100644 index 0000000..3c88863 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/partake.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/permitted.CPZ b/LT/Apps/MusicOrgan/Examples/permitted.CPZ new file mode 100644 index 0000000..459ff75 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/permitted.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/preparing.CPZ b/LT/Apps/MusicOrgan/Examples/preparing.CPZ new file mode 100644 index 0000000..84d419b Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/preparing.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/pretend.CPZ b/LT/Apps/MusicOrgan/Examples/pretend.CPZ new file mode 100644 index 0000000..65af8bb Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/pretend.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/proponent.CPZ b/LT/Apps/MusicOrgan/Examples/proponent.CPZ new file mode 100644 index 0000000..ba6207d --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/proponent.CPZ @@ -0,0 +1,22 @@ +//has words,star,star,star +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("qCqAqAsEDEDqBqBetGGEs2G3C2G3C"); + Play("qCqAqAsEDEDqBqBetGGEs2G3C2G3C"); + Play("etCD2G3etEE2G3qFqFqAsACACsAFAFetECC", + "In \0my \0 \0corn\0 \0 \0er? \0 \0 \0 \0 \0 \0 \0Hope \0we're \0right.\r\n\0"); + Play("etCD2G3etEE2G3qFqFqAsACACsAFAFetECC", + "In \0my \0 \0corn\0 \0 \0er? \0 \0 \0 \0 \0 \0 \0Hope \0we're \0right.\r\n\0"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/prosper.CPZ b/LT/Apps/MusicOrgan/Examples/prosper.CPZ new file mode 100644 index 0000000..422e032 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/prosper.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/providence.CPZ b/LT/Apps/MusicOrgan/Examples/providence.CPZ new file mode 100644 index 0000000..3424aa5 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/providence.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/proximate.CPZ b/LT/Apps/MusicOrgan/Examples/proximate.CPZ new file mode 100644 index 0000000..c716302 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/proximate.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/quotation.CPZ b/LT/Apps/MusicOrgan/Examples/quotation.CPZ new file mode 100644 index 0000000..f773a7c Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/quotation.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/regarded.CPZ b/LT/Apps/MusicOrgan/Examples/regarded.CPZ new file mode 100644 index 0000000..fe17b0b --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/regarded.CPZ @@ -0,0 +1,27 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qB2G3DsBABABDBDqDeAD2sG3A2G3A", + "All \0seeing \0eye.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("qB2G3DsBABABDBDqDeAD2sG3A2G3A", + "It's \0no \0lie.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("qEGC2sG3B2G3B2G3B2G3BqDetBGAsGGGG", + "God \0sees \0you.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("qEGC2sG3B2G3B2G3B2G3BqDetBGAsGGGG", + "Yes, \0it's \0true.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/represented.CPZ b/LT/Apps/MusicOrgan/Examples/represented.CPZ new file mode 100644 index 0000000..70869a5 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/represented.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/riddle.CPZ b/LT/Apps/MusicOrgan/Examples/riddle.CPZ new file mode 100644 index 0000000..425ca51 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/riddle.CPZ @@ -0,0 +1,29 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + PutS("$$WW+H,1$$"); + while (!ScanKey) { + Play("qR3eG2G3qDsCCCCqDeCCetDDBsR2GRG", + " \0Be\0ing \0rid \0of \0 \0 \0 \0sin \0is \0a \0bit\0ter \0 \0 \0pill.\r\n\0 \0 \0"); + Play("qR3eG2G3qDsCCCCqDeCCetDDBsR2GRG", + " \0Be\0ing \0rid \0of \0 \0 \0 \0sin \0is \0a \0bit\0ter \0 \0 \0pill.\r\n\0 \0 \0"); + Play("3eCDqFAAeA2G3etA2G3AeCCAR", + " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("CDqFAAeA2G3etA2G3AeCCAR"); + PutS("$$FG,GREEN$$(This isn't a riddle, oddly enough.)$$FG$$\r\n"); + + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/risen.CPZ b/LT/Apps/MusicOrgan/Examples/risen.CPZ new file mode 100644 index 0000000..929032a Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/risen.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/rmunday.CPZ b/LT/Apps/MusicOrgan/Examples/rmunday.CPZ new file mode 100644 index 0000000..2b11bd1 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/rmunday.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/scarcely.CPZ b/LT/Apps/MusicOrgan/Examples/scarcely.CPZ new file mode 100644 index 0000000..a14e479 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/scarcely.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/seasons.CPZ b/LT/Apps/MusicOrgan/Examples/seasons.CPZ new file mode 100644 index 0000000..b9e512f Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/seasons.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/servant.CPZ b/LT/Apps/MusicOrgan/Examples/servant.CPZ new file mode 100644 index 0000000..5355515 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/servant.CPZ @@ -0,0 +1,36 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + TssStruct *tss; + tss=PopUpViewStr( + "$$LK-A,\"BF:Matthew,25:15\"$$" + ); + WaitTskIdle(tss); + tss->win_right=Fs->win_right; + tss->win_left=Fs->win_left; + tss->win_top=Fs->win_bottom+3; + tss->win_bottom=tss->win_top+12; + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3qDetBAReGEqCCA2G3etFAC", + "Ma\0as\0ter! \0 \0I \0made \0more \0for \0you.\r\n\0 \0 \0 \0 \0"); + Play("qDetBAReGEqCCA2G3etFAC", + "Ma\0as\0ter! \0 \0I \0made \0more \0for \0you!\r\n\0 \0 \0 \0 \0"); + Play("eCB2qG3EFFG2G3etCFG", + " \0 \0 \0Got \0some\0thing \0else?\r\n\0 \0 \0 \0 \0"); + Play("eCB2qG3EFFG2G3etCFG", + " \0 \0 \0Got \0some\0thing \0else?\r\n\0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/shield.CPZ b/LT/Apps/MusicOrgan/Examples/shield.CPZ new file mode 100644 index 0000000..b3cbb45 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/shield.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/sings.CPZ b/LT/Apps/MusicOrgan/Examples/sings.CPZ new file mode 100644 index 0000000..a7b0943 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/sings.CPZ @@ -0,0 +1,21 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("qGsCECEsGAGAsEBEBqFeFFeDEqF", + "Shout! \0 \0 \0Let \0 \0your \0 \0voice \0 \0be \0 \0heard.\r\n\0"); + Play("qGsCECEsGAGAsEBEBqFeFFeDEqF", + "Shout! \0 \0 \0Let \0 \0your \0 \0voice \0 \0be \0 \0heard.\r\n\0"); + Play("e2G3CetDAAetFBEsD2G3D2G3qDqCetBEEsAFAF"); + Play("e2G3CetDAAetFBEsD2G3D2G3qDqCetBEEsAFAF"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/small.CPZ b/LT/Apps/MusicOrgan/Examples/small.CPZ new file mode 100644 index 0000000..e79812e Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/small.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/soothed.CPZ b/LT/Apps/MusicOrgan/Examples/soothed.CPZ new file mode 100644 index 0000000..200aea8 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/soothed.CPZ @@ -0,0 +1,25 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3eDRetAAAsBCBCeEGqF2GsG3B2G3BeDF", + "Good! \0 \0Now, \0 \0 \0I \0 \0don't \0 \0have \0to \0wor\0ry.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("DRetAAAsBCBCeEGqF2GsG3B2G3BeDF", + "Good! \0 \0Now, \0 \0 \0I \0 \0don't \0 \0have \0to \0wor\0ry.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("qFRAetACEqEG2G3sBRBR"); + Play("qFRAetACEqEG2G3sBRBR"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/stiff.CPZ b/LT/Apps/MusicOrgan/Examples/stiff.CPZ new file mode 100644 index 0000000..f94f5e0 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/stiff.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/stores.CPZ b/LT/Apps/MusicOrgan/Examples/stores.CPZ new file mode 100644 index 0000000..d1406a4 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/stores.CPZ @@ -0,0 +1,23 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + while (TRUE) { + Play("qAqBqFqFqDeEGeFDeDE", + "Show \0some \0love.\r\n\0"); + Play("qAqBqFqFqDeEGeFDeDE", + "Show \0some \0love.\r\n\0"); + Play("eABeFAqFeFDetDBBqGeCGqA", + "As \0 \0you \0 \0mea\0 \0sure \0 \0 \0out...\r\n\0"); + Play("eABeFAqFeFDetDBBqGeCGqA", + "As \0 \0you \0 \0mea\0 \0sure \0 \0 \0out...\r\n\0"); + } +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/struggles.CPZ b/LT/Apps/MusicOrgan/Examples/struggles.CPZ new file mode 100644 index 0000000..3d2d7a5 --- /dev/null +++ b/LT/Apps/MusicOrgan/Examples/struggles.CPZ @@ -0,0 +1,27 @@ +void EndTsk() +{ + Sound(0); + Exit; +} + +void Song() +{ + Fs->end_task_cb=&EndTsk; + music_tempo=2.5; + try { + while (!ScanKey) { + Play("3sFGFGetDCFqD2G3DGDetDFB", + "God, \0 \0 \0 \0please \0 \0 \0help \0me.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("sFGFGetDCFqD2G3DGDetDFB", + "God, \0 \0 \0 \0please \0 \0 \0help \0me.\r\n\0 \0 \0 \0 \0 \0 \0"); + Play("qACADetF2G3B2sG3F2G3FetCDFsDFDF", + "Thy \0will \0be \0done.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + Play("qACADetF2G3B2sG3F2G3FetCDFsDFDF", + "Thy \0will \0be \0done.\r\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"); + } + } catch + Fs->catch_except=TRUE; + Sound(0); +} + +Song; diff --git a/LT/Apps/MusicOrgan/Examples/sweeter.CPZ b/LT/Apps/MusicOrgan/Examples/sweeter.CPZ new file mode 100644 index 0000000..9e6bd95 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/sweeter.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/thereby.CPZ b/LT/Apps/MusicOrgan/Examples/thereby.CPZ new file mode 100644 index 0000000..349b348 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/thereby.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/tolerated.CPZ b/LT/Apps/MusicOrgan/Examples/tolerated.CPZ new file mode 100644 index 0000000..0372c6f Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/tolerated.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/treating.CPZ b/LT/Apps/MusicOrgan/Examples/treating.CPZ new file mode 100644 index 0000000..de3eb6e Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/treating.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/unlearned.CPZ b/LT/Apps/MusicOrgan/Examples/unlearned.CPZ new file mode 100644 index 0000000..e00b126 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/unlearned.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/valued.CPZ b/LT/Apps/MusicOrgan/Examples/valued.CPZ new file mode 100644 index 0000000..c8d77c9 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/valued.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/vengeance.CPZ b/LT/Apps/MusicOrgan/Examples/vengeance.CPZ new file mode 100644 index 0000000..8f311fd Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/vengeance.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/warmth.CPZ b/LT/Apps/MusicOrgan/Examples/warmth.CPZ new file mode 100644 index 0000000..fef043b Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/warmth.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/wisdom.CPZ b/LT/Apps/MusicOrgan/Examples/wisdom.CPZ new file mode 100644 index 0000000..5932bfd Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/wisdom.CPZ differ diff --git a/LT/Apps/MusicOrgan/Examples/zip.CPZ b/LT/Apps/MusicOrgan/Examples/zip.CPZ new file mode 100644 index 0000000..629a7b8 Binary files /dev/null and b/LT/Apps/MusicOrgan/Examples/zip.CPZ differ diff --git a/LT/Apps/MusicOrgan/Install.CPZ b/LT/Apps/MusicOrgan/Install.CPZ new file mode 100644 index 0000000..83e52fc Binary files /dev/null and b/LT/Apps/MusicOrgan/Install.CPZ differ diff --git a/LT/Apps/MusicOrgan/JukeBox.CPZ b/LT/Apps/MusicOrgan/JukeBox.CPZ new file mode 100644 index 0000000..30036f5 Binary files /dev/null and b/LT/Apps/MusicOrgan/JukeBox.CPZ differ diff --git a/LT/Apps/MusicOrgan/Load.CPZ b/LT/Apps/MusicOrgan/Load.CPZ new file mode 100644 index 0000000..665bed6 Binary files /dev/null and b/LT/Apps/MusicOrgan/Load.CPZ differ diff --git a/LT/Apps/MusicOrgan/MakeSong.CPZ b/LT/Apps/MusicOrgan/MakeSong.CPZ new file mode 100644 index 0000000..e56b4e3 --- /dev/null +++ b/LT/Apps/MusicOrgan/MakeSong.CPZ @@ -0,0 +1,73 @@ +void InsertNote(I1 *buf,U4 k,U4 *j) +{ + if (k==0) { + buf[*j]='2'; + *j=*j+1; + + buf[*j]='G'; + *j=*j+1; + + buf[*j]='3'; + *j=*j+1; + } else if (k==8) { + buf[*j]='R'; + *j=*j+1; + } else { + buf[*j]=k-1+'A'; + *j=*j+1; + } +} + + +I1 *MakeSong() +{ + I1 *buf=MAllocZ(256), + buf2[256]; + U4 i,j=0,k,n,k2; + for (i=0;i<8;i++) { + SPrintF(buf2,"Picks Left:%d",8-i); + k=RandU4; + n=k/9; + k=k%9; + switch (n%6) { + case 0: + buf[j++]='e'; + InsertNote(buf,k,&j); + SPrintF(buf2,"Picks Left:%d:1",8-i); + k=RandU4; + k=k%9; + InsertNote(buf,k,&j); + break; + case 1: + buf[j++]='e'; + buf[j++]='t'; + InsertNote(buf,k,&j); + SPrintF(buf2,"Picks Left:%d:2",8-i); + k=RandU4; + k=k%9; + InsertNote(buf,k,&j); + SPrintF(buf2,"Picks Left:%d:1",8-i); + k=RandU4; + k=k%9; + InsertNote(buf,k,&j); + break; + case 2: + buf[j++]='s'; + InsertNote(buf,k,&j); + k2=k; + SPrintF(buf2,"Picks Left:%d:1",8-i); + k=RandU4; + k=k%9; + InsertNote(buf,k,&j); + InsertNote(buf,k2,&j); + InsertNote(buf,k,&j); + break; + default: + buf[j++]='q'; + InsertNote(buf,k,&j); + break; + } + } + buf[j++]=0; + return buf; +} diff --git a/LT/Apps/MusicOrgan/Organ.CPZ b/LT/Apps/MusicOrgan/Organ.CPZ new file mode 100644 index 0000000..f821265 --- /dev/null +++ b/LT/Apps/MusicOrgan/Organ.CPZ @@ -0,0 +1,992 @@ +class OrgNote +{ + OrgNote *next,*last; + I1 note,octive,duration; + I1 ascii[9]; + I1 *word; +}; + +class OrgCtrl +{ + OrgNote root; + BoolU4 record_on; + I8 screen_x; + OrgNote *cur_note,*insert_point; + void old_update(TssStruct *tss); +}; + +I1 *org_note_list="A\0A#\0B\0C\0C#\0D\0D#\0E\0F\0F#\0G\0G#\0\0"; +I1 org_note_map[12]={6,6,5,4,4,3,3,2,1,1,0,0}; +I1 org_note_inverse_map[7]={10,8,7,5,3,2,0}; + + + $PI,"",2$ + + + + $PI,"",3$ + + + + $PI,"",4$ + + + + $PI,"",5$ + + + + $PI,"",6$ + + + + $PI,"",7$ + + + + $PI,"",8$ + + + + $PI,"",9$ + + + + $PI,"",11$ + + + $PI,"",18$ + + + $PI,"",19$ + + + $PI,"",20$ + + + $PI,"",21$ + + + + +#define ORG_NOTE_SPACING 9 +#define ORG_NUM_DURATIONS 8 +double org_durations[ORG_NUM_DURATIONS+1]={2*.25/3,.25,2*.5/3,.5,2.0/3.0,1.0,2.0,4.0,1000000.0}; +I1 *org_duration_list="st\0s\0et\0e\0qt\0q\0h\0w\0\0"; +U1 *org_duration_PI_map[ORG_NUM_DURATIONS]={$IB,"",7$,$IB,"",2$,$IB,"",8$, + $IB,"",3$,$IB,"",9$,$IB,"",4$, + $IB,"",5$,$IB,"",6$}; + + +void DrawIt(TssStruct *tss) +{ + OrgCtrl *oc=tss->user_data0; + OrgNote *tempo; + I8 i,y; + I8 w=tss->win_pixel_right-tss->win_pixel_left; + I8 h=tss->win_pixel_bottom-tss->win_pixel_top; + GrBitMap *base=GrAlias(grbase2,tss); + + + ClearWinText(tss); + base->color=BLACK; + for (i=1;i<6;i++) + GrLine(base,0,i*8,w,i*8); + for (i=7;i<12;i++) + GrLine(base,0,i*8,w,i*8); + + i=0; + tempo=oc->root.next; + while (tempo!=&oc->root) { + if (tempo==oc->cur_note) + base->color=GREEN; + else { + if (tempo->octive) + base->color=BLACK; + else + base->color=DKGRAY; + if (tempo->word) + if (StrCmp(tempo->word," ")) + base->color=RED; + } + if (tempo->octive) + y=(15+(org_note_map[tempo->note]-7*(tempo->octive-3)))*4; + else + y=50; + base->bkcolor=WHITE; + GrElemsPlot(base,8+i*ORG_NOTE_SPACING-oc->screen_x,y,0, + org_duration_PI_map[tempo->duration]); + tempo=tempo->next; + i++; + } + GrDel(base); + oc->old_update(tss); +} + +OrgNote *OrgFindNote(I8 x,I8 y) +{ + OrgCtrl *oc=Fs->user_data0; + OrgNote *tempo=oc->root.next; + I8 i=(x+oc->screen_x-8+ORG_NOTE_SPACING/2)/ORG_NOTE_SPACING; + nounusedwarn y; + while (i-- && tempo!=&oc->root) + tempo=tempo->next; + if (tempo==&oc->root) + tempo=NULL; + return tempo; +} + +#define ORGR_REST -5 +#define ORGR_INSERT_NOTE -4 +#define ORGR_DELETE_NOTE -3 +#define ORGR_SET_WORD -2 + +double PopUpDuration() +{ + I8 i; + Ltf *l=LtfNew; + LtfPrintF(l,"$$MU,\"Set Word\" %d$$\r\n",ORGR_SET_WORD); + LtfPrintF(l,"$$MU,\"Make Rest\" %d$$\r\n",ORGR_REST); + LtfPrintF(l,"$$MU,\"Insert Note\" %d$$\r\n",ORGR_INSERT_NOTE); + LtfPrintF(l,"$$MU,\"Delete Note\" %d$$\r\n\r\n",ORGR_DELETE_NOTE); + for (i=0;iuser_data0; + I1 *st,*st2; + OrgNote *tempo=OrgFindNote(x,y),*tempo1; + I8 i; + U8 old_ltf_flags=Fs->cur_ltf->flags; + oc->insert_point=tempo; + oc->cur_note=tempo; + if (tempo) { + Btr(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + ip_inhibit_win_operations=FALSE; + i=PopUpDuration; + if (i>=0 && iduration=i; + else { + switch (i) { + case ORGR_REST: + tempo->octive=0; + tempo->note=0; + break; + case ORGR_SET_WORD: + Fs->cur_ltf->flags&=~LTFF_FORM; + if (tempo->word) + st2=MSPrintF("\r\nWord(\"%Q\"):",tempo->word); + else + st2=MSPrintF("\r\nWord(\"\"):"); + LtfBottom(Fs->cur_ltf); + st=PmtStr(st2); + Free(st2); + Free(tempo->word); + if (*st) { + tempo->word=MSPrintF("%q",st); + Free(st); + } else + tempo->word=NewStr(" "); + Fs->cur_ltf->flags=old_ltf_flags; + break; + case ORGR_INSERT_NOTE: + tempo1=MAllocIdentical(tempo); + tempo1->word=NewStr(tempo->word); + InsQue(tempo1,tempo); + break; + case ORGR_DELETE_NOTE: + oc->insert_point=tempo->next; + oc->cur_note=oc->insert_point; + RemQue(tempo); + Free(tempo->word); + Free(tempo); + break; + } + } + ip_inhibit_win_operations=TRUE; + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + } +} + +void OrgLeftClick(I8 x,I8 y) +{ + OrgCtrl *oc=Fs->user_data0; + OrgNote *tempo=OrgFindNote(x,y); + I8 o,n,cmd,p1,p2; + oc->insert_point=tempo; + oc->cur_note=tempo; + if (tempo) { + do { + cmd=GetMsg(&p1,&p2,1<note=n; + tempo->octive=o; + } + } while (cmd!=MSG_IP_L_UP); + } +} + +void OrgPlayEnd() +{ + Sound(0); + Exit; +} + +#define ORGPM_NORMAL 0 +#define ORGPM_REVERB1 1 + +#define ORGPM_NUM_PLAY_MODES 2 + +U8 org_play_mode=0; +double org_play_f=0; +void OrgPlayTsk() +{ + BoolU4 going_up=TRUE; + U8 i=0; + double f=0,f2=0; + Fs->end_task_cb=&OrgPlayEnd; + while (TRUE) { + i++; + switch (org_play_mode) { + case ORGPM_NORMAL: + if (org_play_f!=f) { + f=org_play_f; + Sound(f); + } + break; + case ORGPM_REVERB1: + if (org_play_f!=f) { + if (f>0) + f2=f; + f=org_play_f; + } + if (!(i&15)) { + if (i&16) + Sound(f); + else + Sound(f2); + } + break; + } + Sleep(1); + } +} + + +U1 OrgCvtDuration(double d) +{ + double d1,d2; + I8 j; + for (j=0;j='0' && ch<='9') { + *org_octive=ch-'0'; + ch=*st++; + } + return --st; +} + +I1 *OrgMusicSetNoteLen(I1 *st,double *org_duration) +{ + BoolU4 cont=TRUE; + do { + switch (*st++) { + case 'w': *org_duration=4.0; break; + case 'h': *org_duration=2.0; break; + case 'q': *org_duration=1.0; break; + case 'e': *org_duration=0.5; break; + case 's': *org_duration=0.25; break; + case 't': *org_duration=2.0* *org_duration/3.0; break; + case '.': *org_duration=1.5* *org_duration; break; + default: + st--; + cont=FALSE; + } + } while (cont); + return st; +} + +void OrgLoadSongStr(I1 *st,U8 *org_octive,double *org_duration) +{ + OrgCtrl *oc=Fs->user_data0; + OrgNote *tempo; + U8 note,i=0; + while (*st) { + tempo=MAllocZ(sizeof(OrgNote)); + st=OrgMusicSetOctive(st,org_octive); + st=OrgMusicSetNoteLen(st,org_duration); + st=OrgMusicSetOctive(st,org_octive); + if (!*st) break; + note=*st++-'A'; + if (note<7) { + note=music_note_map[note]; + if (*st=='b') { + note--; + st++; + } else if (*st=='#') { + note++; + st++; + } + tempo->note=note; + tempo->octive=*org_octive; + } else { + tempo->note=0; + tempo->octive=0; + } + if (*org_duration<=2*.25/3) + i=0; + else if (*org_duration<=.25) + i=1; + else if (*org_duration<=2*.5/3) + i=2; + else if (*org_duration<=.5) + i=3; + else if (*org_duration<=2.0/3) + i=4; + else if (*org_duration<=1.0) + i=5; + else if (*org_duration<=2.0) + i=6; + else + i=7; + tempo->duration=i; + InsQue(tempo,oc->root.last); + } +} + +void OrgLoadSong(I1 *filename,U8 *org_octive,double *org_duration) +{ + OrgCtrl *oc=Fs->user_data0; + I1 *st; + OrgNote *tempo; + LexStruct *lx=LexNew(ReadTextFile(filename),0,NewStr(filename)); + Lex(lx); + while (lx->token) { + if (lx->token==TK_IDENT) + if (!StrCmp(lx->ident,"Play")) + if (Lex(lx)=='(') + if (Lex(lx)==TK_STR) { + tempo=oc->root.last; + st=LexExtendStr(lx); + OrgLoadSongStr(st,org_octive,org_duration); + if (lx->token==',') { + if (Lex(lx)==TK_STR) { + st=LexExtendStr(lx); + do { + tempo=tempo->next; + tempo->word=NewStr(st); + st+=StrLen(st)+1; + } while (*st); + } + } + } + Lex(lx); + } + LexDel(lx); +} + +I1 *OrgCvtSong() +{ + OrgCtrl *oc=Fs->user_data0; + OrgNote *tempo; + I1 *buf,*src,*dst; + U8 i,note,octive,last_octive,last_duration; + + i=0; + tempo=oc->root.next; + last_octive=-1; + last_duration=-1; + while (tempo!=&oc->root) { + dst=&tempo->ascii; + octive=tempo->octive; + note=tempo->note; + if (octive!=last_octive && (note || octive)) { + *dst++=octive+'0'; + last_octive=octive; + } + if (tempo->duration!=last_duration) { + src=PointAtListEntry(tempo->duration,org_duration_list); + *dst++=src[0]; + if (src[1]) + *dst++=src[1]; + last_duration=tempo->duration; + } + if (note || octive) { + src=PointAtListEntry(note,org_note_list); + *dst++=src[0]; + if (src[1]) + *dst++=src[1]; + } else + *dst++='R'; + *dst++=0; + i+=StrLen(tempo->ascii); + tempo=tempo->next; + } + + buf=MAlloc(i+1); + dst=buf; + tempo=oc->root.next; + while (tempo!=&oc->root) { + StrCpy(dst,tempo->ascii); + dst+=StrLen(tempo->ascii); + tempo=tempo->next; + } + *dst++=0; + return buf; +} + +void OrgDelSong(I1 *full_filename) +{ + EditFileNameStruct fn; + if (full_filename) { + StrCpy(fn.name,full_filename); + if (DoForm(&fn,"EditFileNameStruct")) + Del(fn.name); + } +} + +void OrgSaveSong(I1 *dirname,I1 *full_filename=NULL) +{ + OrgCtrl *oc=Fs->user_data0; + Ltf *l=LtfNew; + BoolU4 has_words; + OrgNote *tempo,*tempo1; + double two_measure_left=8.0; + I1 *ptr,ch; + + Free(OrgCvtSong); //set tempo->ascii; + tempo=oc->root.next; + tempo1=tempo; + has_words=FALSE; + + LtfPutSExt(l, +"void EndTsk()\r\n" +"{\r\n" +" Sound(0);\r\n" +" Exit;\r\n" +"}\r\n" +"\r\n" +"void Song()\r\n" +"{\r\n" +" Fs->end_task_cb=&EndTsk;\r\n" +" music_tempo=2.5;\r\n" +" try {\r\n" +" while (!ScanKey) {\r\n" +"\tPlay(\""); + while (tempo!=&oc->root) { + LtfPutSExt(l,tempo->ascii); + if (tempo->word) has_words=TRUE; + two_measure_left-=org_durations[tempo->duration]; + tempo=tempo->next; + if (two_measure_left<0.001 && tempo!=&oc->root) { + if (has_words) { + LtfPutSExt(l,"\",\r\n\t\t\""); + while (tempo1!=tempo) { + if (tempo1->word) { + ptr=tempo1->word; + while (ch=*ptr) { + if (ch==CH_SPACE) + *ptr=CH_SHIFT_SPACE; + ptr++; + } + LtfPrintF(l,"%Q\\0",tempo1->word); + } else + LtfPrintF(l,"%c\\0",CH_SHIFT_SPACE); + tempo1=tempo1->next; + } + } + LtfPutSExt(l,"\");\r\n"); + LtfPutSExt(l,"\tPlay(\""); + two_measure_left=8.0; + tempo1=tempo; + has_words=FALSE; + } + } + if (has_words) { + LtfPutSExt(l,"\",\r\n\t\t\""); + while (tempo1!=tempo) { + if (tempo1->word) { + ptr=tempo1->word; + while (ch=*ptr) { + if (ch==CH_SPACE) + *ptr=CH_SHIFT_SPACE; + ptr++; + } + LtfPrintF(l,"%Q\\0",tempo1->word); + } else + LtfPrintF(l,"%c\\0",CH_SHIFT_SPACE); + tempo1=tempo1->next; + } + } + LtfPutSExt(l,"\");\r\n" +" }\r\n" +" } catch\r\n" +" Fs->catch_except=TRUE;\r\n" +" Sound(0);\r\n" +"}\r\n" +"\r\n" +"Song;\r\n"); + LtfRecalc(l); + if (full_filename) + StrCpy(l->filename.name,full_filename); + else + SPrintF(l->filename.name,"%s/Temp.CPZ",dirname); + LtfWrite(l,TRUE); + LtfDel(l); +} + +void OrgClearSong() +{ + OrgCtrl *oc=Fs->user_data0; + OrgNote *tempo,*tempo1; + tempo=oc->root.next; + while (tempo!=&oc->root) { + tempo1=tempo->next; + Free(tempo); + tempo=tempo1; + } + oc->root.next=&oc->root; + oc->root.last=&oc->root; +} + +void OrgHelp(I8 org_octive) +{ + I8 i; + coutln "$$CL$$$$BD,LTGRAY$$$$FD,YELLOW$$$$BU,LTGRAY$$$$FU,YELLOW$$$$FM,YELLOW$$$$BM,LTGRAY$$$$CM,0,12$$"; + coutln " E R T U I P [ ] "; + coutln "A S D F G H J K L ; ' ENTER"; + coutln; + coutln "$$FG,LTRED$$SPACE$$FG$$\t\tRest"; + coutln "$$FG,LTRED$$BACKSPACE$$FG$$\t$$MA+A-X,\"Deletes Last Note\",\"\\x08\"$$"; + coutln "$$FG,LTRED$$Left Mouse$$FG$$\tDrag note"; + coutln "$$FG,LTRED$$Right Mouse$$FG$$\tChange duration or set word"; + PutGrElem($IB,"",11$,$IS,"",11$,"$$PI+LM+LA,\"\",\"Msg(MSG_KEY_DOWN,0,SC_CURSOR_LEFT);\",%d$$"); + cout " "; + PutGrElem($IB,"",19$,$IS,"",19$,"$$PI+LM,\"\",\"x\",%d$$"); + cout " "; + if (Fs->user_data0><(OrgCtrl *)->record_on) + PutGrElem($IB,"",20$,$IS,"",20$,"$$PI+LM,\"\",\"z\",%d$$"); + else + PutGrElem($IB,"",21$,$IS,"",21$,"$$PI+LM,\"\",\"z\",%d$$"); + cout " "; + PutGrElem($IB,"",18$,$IS,"",18$,"$$PI+LM+LA,\"\",\"Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT);\",%d$$"); + cout "\r\n\r\n\rOctive: $$FG$$"; + for (i=1;i<6;i++) + if (org_octive==i) + PrintF("$$BT-LE+LM-X+S,\"%d\",\"%d\"$$$$CM,3,0$$",i,i); + else + PrintF("$$BT-LE+LM-X,\"%d\",\"%d\"$$$$CM,3,0$$",i,i); + cout "\r\n\r\n\r\n"; + cout " $$BT-LE+LM-X,\"Mode\",\"c\"$$$$CM,2,0$$"; + cout "$$BT-LE+LM-X\"File Menu\",\"v\"$$$$CM,2,0$$"; + cout "$$BT-LE+LM-X\"Random Song\",\",\"$$$$CM,2,0$$"; + cout "$$BT-LE+LM-X\"Clear Song\",\".\"$$$$CM,2,0$$"; + cout "$$BT-LE+LM-X,\"Exit\",\"\\x1B\"$$"; + cout "\r\n\r\n\r"; +} + +#define ORGF_CANCEL 0 +#define ORGF_SAVE 1 +#define ORGF_CD 2 +#define ORGF_JUKEBOX 3 +#define ORGF_DELETE 4 + +I8 OrgPopUpFileMenu(I1 *dirname) +{ + I8 i; + Ltf *l=LtfNew; + LtfPrintF(l,"%s\r\n\r\n",dirname); + LtfPrintF(l,"$$MU,\"Load Song\" %d$$\r\n",ORGF_JUKEBOX); + LtfPrintF(l,"$$MU,\"Save Song\" %d$$\r\n",ORGF_SAVE); + LtfPrintF(l,"$$MU,\"Delete Song\" %d$$\r\n",ORGF_DELETE); + LtfPrintF(l,"$$MU,\"Change Directory\" %d$$\r\n",ORGF_CD); + LtfPrintF(l,"$$MU,\"CANCEL\" %d$$\r\n",ORGF_CANCEL); + i=PopUpMenu(l); + LtfDel(l); + return i; +} + +void MusicOrgan(I1 *dirname=NULL) +{ + OrgCtrl *oc=MAlloc(sizeof(OrgCtrl)); + BoolU4 is_note; + U8 p1,p2,i,j,ch,sc,cmd=0,note_down_time; + U8 note,octive,org_octive=3; + double record_tempo=LTDATE_FREQ/2.5; + double f=0,last_f=0,org_duration=1.0; + I1 *buf,*filename=NULL; + TssStruct *tss=Spawn(&OrgPlayTsk); + OrgNote *tempo; + BoolU4 old_ip_double=Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + BoolU4 old_inhibit=ip_inhibit_win_operations; + BoolU4 old_wordstat=WordStat(OFF); + U8 old_user_data0=Fs->user_data0; + U8 old_ltf_flags=Fs->cur_ltf->flags; + BoolU4 old_border=WinBorder(OFF); + + Fs->cur_ltf->flags|=LTFF_FORM; + + oc->screen_x=0; + oc->record_on=FALSE; + oc->root.next=&oc->root; + oc->root.last=&oc->root; + oc->insert_point=NULL; + oc->cur_note=NULL; + + Fs->user_data0=oc; + WinMax; + + if (!dirname) + dirname=NewStr("HOME/MusicOrgan"); + else + dirname=NewStr(dirname); + ip_inhibit_win_operations=TRUE; + OrgHelp(org_octive); + oc->old_update=Fs->update_win; + Fs->update_win=&DrawIt; + + try { + do { +start: + if (ipty-Fs->win_top<13) + cmd=GetMsg(&p1,&p2,1<cur_ltf); + octive=org_octive; + if (cmd==MSG_KEY_DOWN) { + ch=p1; + sc=p2; + if (ch>='0' && ch<='9') { + org_octive=ch-'0'; + OrgHelp(org_octive); + } else { + is_note=TRUE; + switch (ch) { + case 0: + if (sc.u1[0]==SC_CURSOR_LEFT) { + oc->screen_x-=100; + } else if (sc.u1[0]==SC_CURSOR_RIGHT) { + oc->screen_x+=100; + } + is_note=FALSE; + break; + case 'a': note=7; octive--; break; + case 's': note=8; octive--; break; + case 'e': note=9; octive--; break; + case 'd': note=10; octive--; break; + case 'r': note=11; octive--; break; + case 'f': note=0; break; + case 't': note=1; break; + case 'g': note=2; break; + case 'h': note=3; break; + case 'u': note=4; break; + case 'j': note=5; break; + case 'i': note=6; break; + case 'k': note=7; break; + case 'l': note=8; break; + case 'p': note=9; break; + case ';': note=10; break; + case '[': note=11; break; + case '\'': note=0; octive++; break; + case ']': note=1; octive++; break; + case '\r': note=2; octive++; break; + case CH_SPACE: + note=0; + octive=0; + break; + case 'v': + Btr(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + ip_inhibit_win_operations=FALSE; + switch (OrgPopUpFileMenu(dirname)) { + case ORGF_SAVE: + OrgSaveSong(dirname,filename); + break; + case ORGF_DELETE: + OrgDelSong(filename); + break; + case ORGF_CD: + Free(filename); + filename=NULL; + buf=dirname; + if (dirname=PopUpPickDir) + Free(buf); + else + dirname=buf; + break; + case ORGF_JUKEBOX: + Free(filename); + filename=NULL; + JukeBox(dirname,&filename); + if (filename) { + oc->screen_x=0; + org_duration=1.0; + org_octive=3; + OrgClearSong; + OrgLoadSong(filename,&org_octive,&org_duration); + oc->record_on=OFF; + oc->insert_point=NULL; + oc->cur_note=NULL; + } + break; + } + ip_inhibit_win_operations=TRUE; + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + is_note=FALSE; + OrgHelp(org_octive); + break; + case ',': + Free(filename); + filename=NULL; + Btr(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + ip_inhibit_win_operations=FALSE; + buf=MakeSong(); + if (!oc->insert_point) { + oc->insert_point=&oc->root; + oc->cur_note=oc->insert_point; + } + OrgLoadSongStr(buf,&org_octive,&org_duration); + OrgLoadSongStr(buf,&org_octive,&org_duration); + Free(buf); + ip_inhibit_win_operations=TRUE; + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + is_note=FALSE; + OrgHelp(org_octive); + break; + case '.': + OrgHelp(org_octive); + Free(filename); + filename=NULL; + org_duration=1.0; + org_octive=3; + OrgClearSong; + oc->insert_point=NULL; + oc->cur_note=NULL; + oc->screen_x=0; + is_note=FALSE; + break; + case '?': + OrgHelp(org_octive); + is_note=FALSE; + break; + case 'x': + OrgHelp(org_octive); + tempo=oc->root.next; + while (tempo!=&oc->root) { + if (ipty-Fs->win_top<13) + cmd=ScanMsg(&p1,&p2,1<cur_note=oc->insert_point; + goto got_msg; + } + oc->cur_note=tempo; + if (tempo->word) + if (StrCmp(tempo->word," ")) + PutS(tempo->word); + note=tempo->note; + octive=tempo->octive; + if (note || octive) + f=Note2Freq(note,octive); + else + f=-1; //rest + if (f>0) + org_play_f=f; + else + org_play_f=0; + Sleep(org_durations[tempo->duration]*record_tempo*1000.0/LTDATE_FREQ); + org_play_f=0; + Sleep(3); + tempo=tempo->next; + } + oc->cur_note=oc->insert_point; + f=0; + org_play_f=0; + is_note=FALSE; + break; + case CH_BACKSPACE: + if (!oc->insert_point) { + oc->insert_point=&oc->root; + oc->cur_note=oc->insert_point; + } + tempo=oc->insert_point->last; + if (tempo!=&oc->root) { + PutChar(CH_BACKSPACE); + RemQue(tempo); + Free(tempo); + } + is_note=FALSE; + break; + case 'c': + org_play_mode++; + if (org_play_mode>=ORGPM_NUM_PLAY_MODES) org_play_mode=0; + is_note=FALSE; + OrgHelp(org_octive); + coutln "Mode:",org_play_mode; + break; + case 'z': + if (oc->record_on) { + oc->record_on=FALSE; + buf=OrgCvtSong; + coutln buf; + Free(buf); + } else { + coutln "\r\nCalibrate timing with 4 Quarter Notes"; + cmd=GetMsg(&ch,&sc,1<record_on=TRUE; + org_duration=1.0; + org_octive=3; + oc->screen_x=0; + } + is_note=FALSE; + OrgHelp(org_octive); + break; + default: + is_note=FALSE; + } + if (is_note) { + if (note || octive) + f=Note2Freq(note,octive); + else + f=-1; //rest + } + } + } else if (cmd==MSG_KEY_UP) + f=0; + else if (cmd==MSG_IP_MOVE) { + if (p2>13*FONT_HEIGHT) { + Btr(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + ip_inhibit_win_operations=FALSE; + } else { + Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + ip_inhibit_win_operations=TRUE; + } + } else if (cmd==MSG_IP_L_DOWN) + OrgLeftClick(p1,p2); + else + OrgRightClick(p1,p2); + if (f!=last_f) { + if (oc->record_on) { + if (last_f) { + tempo->duration=OrgCvtDuration((kbd_evt_time-note_down_time)/record_tempo); + if (!oc->insert_point) { + oc->insert_point=&oc->root; + oc->cur_note=oc->insert_point; + } + InsQue(tempo,oc->insert_point->last); + } + if (f) { + note_down_time=kbd_evt_time; + tempo=MAllocZ(sizeof(OrgNote)); + tempo->note=note; + tempo->octive=octive; + } + } + if (f>0) { + cout PointAtListEntry(note,org_note_list); + org_play_f=f; + } else { + if (f<0) + cout "R"; + org_play_f=0; + } + last_f=f; + } + } while (ch!=CH_ESC && ch!=CH_CTRLQ); + } catch + Fs->catch_except=TRUE; + AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double); + ip_inhibit_win_operations=old_inhibit; + OrgClearSong; + Kill(tss); + Fs->update_win=oc->old_update; + Fs->cur_ltf->flags=old_ltf_flags; + Free(oc); + Fs->user_data0=old_user_data0; + Free(dirname); + coutln "$$CL$$"; + WinBorder(old_border); + WordStat(old_wordstat); +} +Xòÿÿÿñÿÿÿñÿÿÿ +ñÿÿÿõÿÿÿ +õÿÿÿóÿÿÿ òÿÿÿöÿÿÿ +÷ÿÿÿÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿ0óÿÿÿ +óÿÿÿóÿÿÿóÿÿÿòÿÿÿ òÿÿÿÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿôÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿhÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿTÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿlþÿÿÿñÿÿÿòÿÿÿñÿÿÿñÿÿÿ +ñÿÿÿõÿÿÿ +õÿÿÿóÿÿÿ òÿÿÿöÿÿÿ +÷ÿÿÿÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿDþÿÿÿòÿÿÿóÿÿÿ +óÿÿÿóÿÿÿóÿÿÿòÿÿÿ òÿÿÿÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿ þÿÿÿñÿÿÿÿÿÿÿýÿÿÿüÿÿÿüÿÿÿÿÿÿÿÿÿÿÿýÿÿÿòÿÿÿþÿÿÿÿÿÿÿÿÿÿÿýÿÿÿÿÿÿÿýÿÿÿýÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿ        + + + + + +     + +      ]   + + +  + + +   + +  +  + +   + + + + + + + +W  + + \ No newline at end of file diff --git a/LT/Apps/MusicOrgan/Run.CPZ b/LT/Apps/MusicOrgan/Run.CPZ new file mode 100644 index 0000000..28f06fc Binary files /dev/null and b/LT/Apps/MusicOrgan/Run.CPZ differ diff --git a/LT/Apps/Rocks/Load.CPZ b/LT/Apps/Rocks/Load.CPZ new file mode 100644 index 0000000..c453afd Binary files /dev/null and b/LT/Apps/Rocks/Load.CPZ differ diff --git a/LT/Apps/Rocks/Rocks.CPZ b/LT/Apps/Rocks/Rocks.CPZ new file mode 100644 index 0000000..48532ca --- /dev/null +++ b/LT/Apps/Rocks/Rocks.CPZ @@ -0,0 +1,736 @@ +$BD,0$$FD,15$ +GrBitMap *RK_base=GrAlias(grbase2,Fs); + + +$PI,"",2$ + + +$PI,"",3$ + + + +$PI,"",19$ + + +$PI,"",20$ + + +$PI,"",24$ + +$PI,"",23$ + + +$PI,"",21$ + + +$PI,"",22$ + + +$PI,"",4$ + + +$PI,"",13$ + + + +$PI,"",5$ + + +$PI,"",14$ + + + + +$PI,"",6$ + + +$PI,"",15$ + + +$PI,"",7$ + + + + +$PI,"",18$ + + + + + +#define CMD_NULL 0 +#define CMD_SPIN_LEFT 1 +#define CMD_SPIN_RIGHT 2 +#define CMD_THRUST 3 +#define CMD_FIRE 4 +#define CMD_EXIT 5 +I8 cmd=CMD_NULL; + +#define NUM_STARS 100 +I8 stars_x[NUM_STARS],stars_y[NUM_STARS]; + +BoolU4 bounce=TRUE; + +#define OT_SHIP 1 +#define OT_CARGO 2 +#define OT_BULLET 3 +#define OT_SPECK 4 +#define OT_PEBBLE 5 +#define OT_TINY_ROCK 6 +#define OT_SMALL_ROCK 7 +#define OT_MEDIUM_ROCK 8 +#define OT_LARGE_ROCK 9 + +#define A_TRANSITION -1 +#define A_INACTIVE 0 +#define A_ACTIVE 1 + +class Order2D2Theta +{ + double x,y,theta; + double DxDt,DyDt,DthetaDt; +}; + +class Object +{ + I4 active; + I4 type; + U1 *img; + double mass,radius; + U8 timeout; +}; + +#define NUM_OBJECTS 256 + +Ode *ode; +Order2D2Theta *o; +Object *objs; + +void InitObject(I8 i, I8 type) +{ + objs[i].active=A_ACTIVE; + objs[i].timeout=0; + objs[i].type=type; + switch (type) { + case OT_SHIP: + objs[i].img=$IB,"",2$; + objs[i].radius=15; + break; + case OT_CARGO: + objs[i].img=$IB,"",18$; + objs[i].radius=30; + break; + case OT_BULLET: + objs[i].img=$IB,"",9$; + objs[i].radius=7; + break; + case OT_SPECK: + objs[i].img=$IB,"",24$; + objs[i].radius=3; + break; + case OT_PEBBLE: + objs[i].img=$IB,"",23$; + objs[i].radius=5; + break; + case OT_TINY_ROCK: + if (i&1) + objs[i].img=$IB,"",21$; + else + objs[i].img=$IB,"",22$; + objs[i].radius=5; + break; + case OT_SMALL_ROCK: + if (i&1) + objs[i].img=$IB,"",10$; + else + objs[i].img=$IB,"",13$; + objs[i].radius=11; + break; + case OT_MEDIUM_ROCK: + if (i&1) + objs[i].img=$IB,"",11$; + else + objs[i].img=$IB,"",14$; + objs[i].radius=20; + break; + case OT_LARGE_ROCK: + if (i&1) + objs[i].img=$IB,"",12$; + else + objs[i].img=$IB,"",15$; + objs[i].radius=26; + break; + } + objs[i].mass=objs[i].radius*objs[i].radius*objs[i].radius; +} + +I8 AllocObject(I8 type) +{ + I8 i; + for (i=0;icolor=WHITE; + for (i=0;iGR_WIDTH) { + x=x%GR_WIDTH; + o[i].x=x; + } + if (y<0) { + y=GR_HEIGHT-AbsI8(y)%GR_HEIGHT; + o[i].y=y; + } else if (y>GR_HEIGHT) { + y=y%GR_HEIGHT; + o[i].y=y; + } + switch (objs[i].type) { + case OT_SHIP: + RK_base->flags|=BMF_TRANSFORMATION; + r1=RK_base->r; + RK_base->r=GrTheta(o[i].theta); + RK_base->x=x; + RK_base->y=y; + RK_base->z=0; + if (cmd==CMD_THRUST && GetTimeStamp&8192) + GrElemsPlot(RK_base,0,0,0,$IB,"",3$); + else + GrElemsPlot(RK_base,0,0,0,$IB,"",2$); + Free(RK_base->r); + RK_base->r=r1; + RK_base->flags&=~BMF_TRANSFORMATION; + break; + case OT_BULLET: + case OT_SPECK: + case OT_PEBBLE: + case OT_TINY_ROCK: + case OT_SMALL_ROCK: + case OT_MEDIUM_ROCK: + case OT_LARGE_ROCK: + case OT_CARGO: + RK_base->flags|=BMF_TRANSFORMATION; + r1=RK_base->r; + RK_base->r=GrTheta(o[i].theta); + RK_base->x=x; + RK_base->y=y; + RK_base->z=0; + GrElemsPlot(RK_base,0,0,0,objs[i].img); + Free(RK_base->r); + RK_base->r=r1; + RK_base->flags&=~BMF_TRANSFORMATION; + break; + } + } + } + } +} + +void SongEndTsk() +{ + Sound(0); + Exit; +} + +void SongTsk() +{ + Fs->end_task_cb=&SongEndTsk; + ResetMusicSettings; + while (TRUE) { + Play("qDCDeEGBDetBBFqDeDB"); + Play("FAetAFDeDFqAetDFBeDFetFDEqD"); + Play("eFAetAFDeDFqAetDFBeDFetFDEqD"); + } +} + +void InitObjs() +{ + I8 i,j; + + for (i=0;i1000000.0) f=1000000.0; + } + } else + f=-2.5*objs[i].mass*objs[j].mass/(dd+1.0); + + DstateDt[i].DxDt+=f*dx/objs[i].mass; + DstateDt[i].DyDt+=f*dy/objs[i].mass; + } + } + } + } + switch (cmd) { + case CMD_SPIN_LEFT: + DstateDt[0].DthetaDt-=10.0; + break; + case CMD_SPIN_RIGHT: + DstateDt[0].DthetaDt+=10.0; + break; + case CMD_THRUST: + DstateDt[0].DxDt+=100.0*Cos(state[0].theta-pi/2.0); + DstateDt[0].DyDt+=100.0*Sin(state[0].theta-pi/2.0); + break; + } + + DstateDt[1].DxDt+=2.0*Cos(state[1].theta-pi/2.0); + DstateDt[1].DyDt+=2.0*Sin(state[1].theta-pi/2.0); +} + +void Collision(I8 i,I8 j) +{ + I8 i2; + switch (objs[i].type) { + case OT_SHIP: + if (!bounce) { + cmd=CMD_EXIT; + objs[i].active=A_INACTIVE; + } + break; + case OT_CARGO: + cmd=CMD_EXIT; + objs[i].active=A_INACTIVE; + break; + case OT_SPECK: + if (objs[j].type==OT_BULLET && !bounce) + objs[i].active=A_INACTIVE; + break; + case OT_BULLET: + if (!bounce) + objs[i].active=A_INACTIVE; + break; + case OT_PEBBLE: + case OT_TINY_ROCK: + case OT_SMALL_ROCK: + case OT_MEDIUM_ROCK: + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x+objs[i2].radius+2.0; + o[i2].y=o[i].y; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x-objs[i2].radius-2.0; + o[i2].y=o[i].y; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + objs[i].active=A_INACTIVE; + break; + case OT_LARGE_ROCK: + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x+objs[i2].radius+4.0; + o[i2].y=o[i].y+objs[i2].radius+4.0; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x-objs[i2].radius-4.0; + o[i2].y=o[i].y-objs[i2].radius-4.0; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x-objs[i2].radius-4.0; + o[i2].y=o[i].y+objs[i2].radius+4.0; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + i2=AllocObject(objs[i].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[i].x+objs[i2].radius+4.0; + o[i2].y=o[i].y-objs[i2].radius-4.0; + o[i2].theta=o[i].theta; + o[i2].DxDt=o[i].DxDt; + o[i2].DyDt=o[i].DyDt; + o[i2].DthetaDt=o[i].DthetaDt; + + objs[i].active=A_INACTIVE; + break; + } + + switch (objs[j].type) { + case OT_SHIP: + if (!bounce) { + cmd=CMD_EXIT; + objs[j].active=A_INACTIVE; + } + break; + case OT_CARGO: + cmd=CMD_EXIT; + objs[j].active=A_INACTIVE; + break; + case OT_SPECK: + if (objs[i].type==OT_BULLET && !bounce) + objs[j].active=A_INACTIVE; + break; + case OT_BULLET: + if (!bounce) + objs[j].active=A_INACTIVE; + break; + case OT_PEBBLE: + case OT_TINY_ROCK: + case OT_SMALL_ROCK: + case OT_MEDIUM_ROCK: + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x+objs[i2].radius+2.0; + o[i2].y=o[j].y; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x-objs[i2].radius-2.0; + o[i2].y=o[j].y; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + objs[j].active=A_INACTIVE; + break; + + case OT_LARGE_ROCK: + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x+objs[i2].radius+4.0; + o[i2].y=o[j].y+objs[i2].radius+4.0; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x-objs[i2].radius-4.0; + o[i2].y=o[j].y-objs[i2].radius-4.0; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x-objs[i2].radius-4.0; + o[i2].y=o[j].y+objs[i2].radius+4.0; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + i2=AllocObject(objs[j].type-1); + objs[i2].active=A_TRANSITION; + o[i2].x=o[j].x+objs[i2].radius+4.0; + o[i2].y=o[j].y-objs[i2].radius-4.0; + o[i2].theta=o[j].theta; + o[i2].DxDt=o[j].DxDt; + o[i2].DyDt=o[j].DyDt; + o[i2].DthetaDt=o[j].DthetaDt; + + objs[j].active=A_INACTIVE; + break; + } +} + +void CheckCollisions() +{ + I8 i,j,*r1; + double d,d1,dd,dx,dy; + GrBitMap *b; + for (i=0;iflags|=BMF_TRANSFORMATION; + + r1=b->r; + b->r=GrTheta(o[i].theta); + b->x=32; + b->y=32; + b->z=0; + GrElemsPlot(b,0,0,0,objs[i].img); + Free(b->r); + b->r=r1; + + b->bkcolor=ROP_COLLISION+BLACK; + + r1=b->r; + b->r=GrTheta(o[j].theta); + b->x=o[j].x-o[i].x+32; + b->y=o[j].y-o[i].y+32; + b->z=0; + GrElemsPlot(b,0,0,0,objs[j].img); + Free(b->r); + b->r=r1; + + if (b->collision_cnt>0) + Collision(i,j); + + GrDel(b); + } + } + } + } + } + for (i=0;iMUZZLE_VELOCITY*5.0) + Auto(" "); + } +} + +void Rocks() +{ + I8 ch=0,i=0,c,p1,p2,sc=0; + void *old_update=Fs->update_win; + Ltf *l,*old_cur_ltf=Fs->cur_ltf,*old_aux_ltf=Fs->aux_ltf; + BoolU4 old_preempt=Preempt(OFF), + old_border=WinBorder(OFF); + TssStruct *song_tss=Spawn(&SongTsk,"Rocks Song",Fs); + I8 old_attr=Fs->text_attribute; + + SetTypeMatic(0); + + ode=OdeNew(NUM_OBJECTS*6); + ode->derivative=&MyDerivative; + ode->tolerance_start=.1; + o=ode->state; + objs=MAlloc(NUM_OBJECTS*sizeof(Object)); + + Fs->text_attribute=0x0F; + WinMax; + + Fs->cur_ltf=NULL; + + Fs->aux_ltf=l=InitSysAuxLtf(TRUE); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Restart | \",\" \"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Bounce | \",\"b\"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Exit\",\"\\033\"$$"); + LtfPutSExt(l,"$$CM+LX+TY,2,2$$$$TX+BK,\"Escort the cargo ship\"$$"); + + InitObjs; + InsQue(ode,Fs->last_ode); + Fs->update_win=&DrawIt; + + while (ch!=CH_ESC && ch!=CH_CTRLQ) { + InitObjs; + ch=0; + cmd=CMD_NULL; + while (ch!=CH_ESC && ch!=CH_CR && ch!=CH_SPACE && ch!=CH_CTRLQ) { + while (c=ScanMsg(&p1,&p2,1<best_d && l->cur_entry!=l) { + LtfRunEntry(l,l->cur_entry,TRUE,old_preempt); + ch=0; + l->best_d=MAX_I8; + } + } else if (ch=='b') + bounce=!bounce; + else if (sc.u1[0]==SC_CURSOR_RIGHT) + cmd=CMD_SPIN_RIGHT; + else if (sc.u1[0]==SC_CURSOR_LEFT) + cmd=CMD_SPIN_LEFT; + else if (sc.u1[0]==SC_CURSOR_UP) + cmd=CMD_THRUST; + else if (sc.u1[0]==SC_CURSOR_DOWN) + Fire; + } else + cmd=CMD_NULL; + } + CheckCollisions; + CheckCrazy; + if (cmd==CMD_EXIT) { + Sleep(1000); + ch=CH_SPACE; + } + WinSync; //messages are only queued by winmngr + } + } + Kill(song_tss); + Sound(0); + LtfDel(l); + Fs->aux_ltf=old_aux_ltf; + if (Fs->cur_ltf=old_cur_ltf) + LtfBottom(Fs->cur_ltf); + + RemQue(ode); + OdeDel(ode); + Free(objs); + + Fs->text_attribute=old_attr; + Fs->update_win=old_update; + WinBorder(old_border); + Preempt(old_preempt); +} + ùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿ    + +  ôÿÿÿôÿÿÿôÿÿÿôÿÿÿùÿÿÿùÿÿÿùÿÿÿùÿÿÿþÿÿÿ þÿÿÿ  �ùÿÿÿüÿÿÿüÿÿÿúÿÿÿÿÿÿÿþÿÿÿþÿÿÿÿÿÿÿýÿÿÿýÿÿÿ÷ÿÿÿ÷ÿÿÿûÿÿÿûÿÿÿÿÿÿÿøÿÿÿøÿÿÿÿÿÿÿþÿÿÿ +þÿÿÿ + + +    ýÿÿÿ + + + + +óÿÿÿóÿÿÿøÿÿÿøÿÿÿûÿÿÿ ûÿÿÿ E þÿÿÿýÿÿÿólß$† n[½þÿÿÿd¨­hþÿÿÿûÿÿÿn[϶m’$C’$É$Q¶eÛ¼„ar–ͳíÙžW’"Cš¶½mÛ²úÿÿÿ¶m’6MÛ+€üÿÿÿ¤m þÿÿÿþÿÿÿ¤iÛT +I²rsüÿÿÿôÿÿÿóæy^ÝÚ³m“$íÛ¶mÛ³g’¡F CQŒ¢d["‰©( ³lÁ°lž×n.$I’T¤$à ÷ÿÿÿž=Û$Îúÿÿÿ«]»¶m“¦IFI’$I’„IrY–ms×zõÖm¶kÛ&MÛ¶m“¤%‘’l¶e[’$‰HÒ·m›d=*d; - tempt->desc=NewString(ptr); + tempt->desc=NewStr(ptr); ptr+=StrLen(ptr)+1; InsQue(tempt,header->last); } @@ -90,7 +90,7 @@ public BoolU4 TimeRep(TimeEntry **header=NULL) ReadTimeFile(my_header); tempt=my_header->next; while (tempt!=my_header) { - week=DivU8(tempt->d.date,7); //TODO + week=tempt->d.date/7; //TODO if (week!=cur_week) { if (is_in) week_total=week_total+GetCurTimeLTDate; @@ -99,42 +99,42 @@ public BoolU4 TimeRep(TimeEntry **header=NULL) week_total=0; } if (tempt->type==TET_PUNCH_IN) { - PutS("$$FG RED$$IN "); + PutS("$$FG,RED$$IN "); if (!is_in) week_total=week_total-tempt->d; is_in=TRUE; } else { - PutS("$$FG RED$$OUT"); + 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->d,tempt->d,tempt->desc); tempt=tempt->next; } if (is_in) week_total=week_total+GetCurTimeLTDate; - PrintF("$$FG RED$$Week Total:%h2T$$FG$$\r\n",week_total); + PrintF("$$FG,RED$$Week Total:%h2T$$FG$$\r\n",week_total); if (!header) DelTimeEntries(my_header); return is_in; } -public void PunchOut() +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"); + 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)) + if (!(tempt->desc=MGetS)) tempt->desc=MAllocZ(1); InsQue(tempt,header->last); WriteTimeFile(header); @@ -142,20 +142,20 @@ public void PunchOut() DelTimeEntries(header); } -public void PunchIn() +void PunchIn() { - U4 is_in; + BoolU4 is_in; TimeEntry *tempt,*header; is_in=TimeRep(&header); if (is_in) { - PutS("$$BK 1$$Already Punched-In$$BK 0$$\r\n"); + 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)) + if (!(tempt->desc=MGetS)) tempt->desc=MAllocZ(1); InsQue(tempt,header->last); WriteTimeFile(header); diff --git a/LT/Apps/Vocabulary/Load.CPZ b/LT/Apps/Vocabulary/Load.CPZ new file mode 100644 index 0000000..a3ed664 Binary files /dev/null and b/LT/Apps/Vocabulary/Load.CPZ differ diff --git a/LT/Apps/Vocabulary/Run.CPZ b/LT/Apps/Vocabulary/Run.CPZ new file mode 100644 index 0000000..6e0b291 --- /dev/null +++ b/LT/Apps/Vocabulary/Run.CPZ @@ -0,0 +1,2 @@ +#include "/LT/Apps/Vocabulary/Load" +VocabQuiz; \ No newline at end of file diff --git a/LT/Apps/Vocabulary/VocabQuiz.CPZ b/LT/Apps/Vocabulary/VocabQuiz.CPZ new file mode 100644 index 0000000..d21202f Binary files /dev/null and b/LT/Apps/Vocabulary/VocabQuiz.CPZ differ diff --git a/LT/Apps/WarGame/Load.CPZ b/LT/Apps/WarGame/Load.CPZ new file mode 100644 index 0000000..f92953e Binary files /dev/null and b/LT/Apps/WarGame/Load.CPZ differ diff --git a/LT/Apps/WarGame/Run.CPZ b/LT/Apps/WarGame/Run.CPZ new file mode 100644 index 0000000..85f8439 Binary files /dev/null and b/LT/Apps/WarGame/Run.CPZ differ diff --git a/LT/Apps/WarGame/WarGame.CPZ b/LT/Apps/WarGame/WarGame.CPZ new file mode 100644 index 0000000..937f99d --- /dev/null +++ b/LT/Apps/WarGame/WarGame.CPZ @@ -0,0 +1,385 @@ +#define p1_color (ROP_EQU+LTGREEN) +#define p2_color (ROP_EQU+PURPLE) +#define enemy_fire_color (ROP_EQU+LTBLUE) +#define friendly_fire_color (ROP_EQU+WHITE) + +GrBitMap *WG_base=GrAlias(grbase2,Fs); + +$PI,"+",1$ + + +$PI,"+",3$ + + +$PI,"+",2$ + + +$PI,"+",4$ + + +U1 *GrTrooper[7]={$IB,"",1$,$IB,"",3$,$IB,"",2$, + $IB,"",4$, + $IB,"",2$,$IB,"",3$,$IB,"",1$}; + +U8 fire_end_time=0; +BoolU4 sound_off=TRUE; + +class Trooper +{ + I8 num,x,y,dx,dy,fx,fy,att,def,rng,player; + U8 fire_end_time; +}; + +#define num_troopers 100 + +Trooper tr[num_troopers<<1]; +U8 cnt1,cnt2; +I8 text_area_size=(GR_HEIGHT/FONT_HEIGHT)*(GR_WIDTH/FONT_WIDTH); + + +#define mm_none 1 +#define mm_friendly_firepower 2 +#define mm_laps_time 3 +I8 map_mode=mm_none,cmd_intensity=128; +U2 *map_values; + + +#define ai_nothing 1 +#define ai_target 2 +#define ai_random 3 +U8 ai; + +void UpdateMap(TssStruct *tss) +{ + I8 i; + for (i=tss->win_top;i<=tss->win_bottom;i++) { + MemCpy(textbase+(i*TEXT_COLS+tss->win_left)*4, + map_values+(i*TEXT_COLS+tss->win_left)*4, + (tss->win_right+1-tss->win_left)*4); + } +} + +void ClearMapValues() +{ + MemSet(map_values,0,text_area_size*sizeof(U4)); +} + +void PutFriendlyFirepower(TssStruct *tss) +{ + I8 i,d,x,y,dx,dy; + I8 lt=tss->win_left,rt=tss->win_right, + tp=tss->win_top, bm=tss->win_bottom; + U4 *ptr; + U8 v; + for (y=0;y<=bm-tp;y++) { + ptr=map_values+((y+tp)*TEXT_COLS+tss->win_left)*4; + for (x=0;x<=rt-lt;x++) { + v=0; + for (i=0;i0 && tr[i].fire_end_time>16)-(x*FONT_WIDTH+FONT_WIDTH>>1); + dy=(tr[i].y>>16)-(y*FONT_HEIGHT+FONT_HEIGHT>>1); + d=dx*dx+dy*dy; + if (ddx>>12,y=t->dy>>12,s,fire_col, + speed=Sqrt(x*x+y*y); + + if (map_mode==mm_laps_time) { + x=(t->x+500*t->dx)>>16; + y=(t->y+500*t->dy)>>16; + } else { + x=t->x>>16; + y=t->y>>16; + } + s=t->def; + + if (s>0) { + s=s/3; + WG_base->color=color; + WG_base->bkcolor=BLACK; + GrElemsPlot(WG_base,x,y,0,GrTrooper[(t->num+Jiffies*speed/JIFFY_FREQ)%7]); + if (t->player==0) + fire_col=friendly_fire_color; + else + fire_col=enemy_fire_color; + if (Jiffiesfire_end_time) { + Sound(2000); + sound_off=FALSE; + WG_base->color=fire_col; + GrLine3(WG_base,x,y,0,t->fx>>16,t->fy>>16,0); + } + if (Jiffies>=fire_end_time) + if (!sound_off) { + sound_off=TRUE; + Sound(0); + } + } +} + +void DrawIt(TssStruct *tss) +{ + I1 buf[32]; + I8 i,c,x=ipx-tss->win_pixel_left,y=ipy-tss->win_pixel_top; + cmd_intensity=(ip_throttle*128)>>32; + + UpdateMap(tss); + LtfUpdateAuxLtf(tss); + + cnt1=0; + cnt2=0; + for (i=0;i0) { + DrawTrooper(&tr[i],p1_color); + cnt1++; + } + for (i=num_troopers;i0) { + DrawTrooper(&tr[i],p2_color); + cnt2++; + } + if (cmd_intensity>0) { + if (ip_lb) + c=ROP_EQU+LTGREEN; + else + c=ROP_EQU+GREEN; + } else { + if (ip_lb) + c=ROP_EQU+LTBLUE; + else + c=ROP_EQU+BLUE; + } + WG_base->color=c; + GrCircle(WG_base,x,y,AbsI8(cmd_intensity)); + SPrintF(buf,"%03d %03d",cnt1,cnt2); + PlotWinStr(tss,buf,WHITE,tss->win_right-8,0); +} + + +I8 targets[10]; +void InitTroopers() +{ + I8 i,j,dx,dy; + Trooper *t; + for (i=0;i<10;i++) { + targets[i]=RandU2%num_troopers; + dx=RandU2-0x8000; + dy=RandU2-0x8000; + for (j=0;j<10;j++) { + t=&tr[i*10+j]; + t->num=i*10+j; + t->x=(GR_WIDTH-100-i*10)<<16; + t->y=(GR_HEIGHT>>1-50+j*10)<<16; + t->dx=0; + t->dy=0; + t->fire_end_time=Jiffies; + t->att=3; + t->def=10; + t->rng=50*50; + t->player=0; + + t=&tr[i*10+j+num_troopers]; + t->num=i*10+j; + t->x=(100+i*10)<<16; + t->y=(GR_HEIGHT>>1-50+j*10)<<16; + t->dx=0; + t->dy=0; + if (ai==ai_random) { + t->dx=dx; + t->dy=dy; + } + t->fire_end_time=Jiffies; + t->att=3; + t->def=10; + t->rng=50*50; + t->player=1; + } + } +} + + +void DoAiTarget() +{ + I8 i,j; + Trooper *t,*t2; + for (i=0;i<10;i++) { + t2=&tr[targets[i]]; + for (j=0;j<10;j++) { + t=&tr[i*10+j+num_troopers]; + t->dx=(t2->x-t->x)>>11; + t->dy=(t2->y-t->y)>>11; + } + } +} + + +void UpdatePositions() +{ + I8 i; + Trooper *t; + for (i=0;ix+=t->dx; + if (t->x>=GR_WIDTH<<16) t->x-=GR_WIDTH<<16; + if (t->x<0) t->x+=GR_WIDTH<<16; + t->y+=t->dy; + if (t->y>=GR_HEIGHT<<16) t->y-=GR_HEIGHT<<16; + if (t->y<0) t->y+=GR_HEIGHT<<16; + } +} + +void ResolveFiring() +{ + I8 i,j,d,dx,dy; + for (i=0;i0 && tr[j].def>0) { + dx=(tr[i].x-tr[j].x)>>16; + dy=(tr[i].y-tr[j].y)>>16; + d=dx*dx+dy*dy; + if (d>3; + fire_end_time=tr[i].fire_end_time; + tr[i].fx=tr[j].x; + tr[i].fy=tr[j].y; + tr[j].def=tr[j].def-tr[i].att; + } + if (d>3; + fire_end_time=tr[i].fire_end_time; + tr[j].fx=tr[i].x; + tr[j].fy=tr[i].y; + tr[i].def=tr[i].def-tr[j].att; + } + } + } +} + +void UpdateVelocities() +{ + I8 i,x=ipx-Fs->win_pixel_left,y=ipy-Fs->win_pixel_top,dx,dy,d; + Trooper *t; + if (ip_lb) { + for (i=0;ix>>16)); + dy=(y-(t->y>>16)); + d=dx*dx+dy*dy+1; + dx=(cmd_intensity<<13*dx)/d; + dy=(cmd_intensity<<13*dy)/d; + t->dx=t->dx-dx; + t->dy=t->dy-dy; + } + } +} + +void SongEndTsk() +{ + Sound(0); + Exit; +} + +void SongTsk() +{ + Fs->end_task_cb=&SongEndTsk; + ResetMusicSettings; + while (TRUE) { + Play("3qAG2eG3DqDeBGqEsARAReFA"); + Play("qAG2eG3DqDeBGqEsARAReFA"); + Play("sCCCC2qG3G2G3ABD2eGR"); + Play("3sCCCC2qG3G2G3ABD2eGR"); + } +} + +void WarGame() +{ + I8 ch=0,i=0; + U8 sc=0,ms=0; + void *old_update=Fs->update_win; + Ltf *l,*m,*old_cur_ltf=Fs->cur_ltf,*old_aux_ltf=Fs->aux_ltf; + BoolU4 old_has_menu; + BoolU4 old_border=WinBorder(OFF); + BoolU4 old_ip_double=Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK); + BoolU4 old_preempt=Preempt(OFF); + TssStruct *song_tss=Spawn(&SongTsk,"WarGame Song",Fs); + + WinMax; + map_values=MAlloc(text_area_size*sizeof(U4)); + ip_throttle=-1<<30; + + Fs->cur_ltf=NULL; + + m=LtfRead("::/LT/Apps/WarGame/WarGame.MUZ"); + old_has_menu=Bts(&Fs->crt_flags,CRTf_HAS_MENU); //todo aux ltf to show "MENU" + + Fs->aux_ltf=l=InitSysAuxLtf(TRUE); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Restart | \",\" \"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Normal | \",\"1\"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"FirePower | \",\"2\"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"LapseTime | \",\"3\"$$"); + LtfPutSExt(l,"$$MA+A+TML+IV,\"Exit\",\"\\033\"$$"); + + ClearMapValues; + InitTroopers(); + Fs->update_win=&DrawIt; + PopUpOk("Wheel Controls Command Strength"); + + while (ms!=101 && ch!=CH_ESC && ch!=CH_CTRLQ) { + ch=0;ms=0; + ai=RandU2%3+1; + InitTroopers(); + while (ch!=CH_ESC && ch!=CH_CR && ch!=CH_SPACE && ch!=CH_CTRLQ && ms!=101 && ms!=100) { + ms=0; + if (ScanKey(&ch,&sc)) { + if (ch==CH_SPACE) { + if (!l->best_d && l->cur_entry!=l) { + LtfRunEntry(l,l->cur_entry,TRUE,old_preempt); + ch=0; + } + } + ClearMapValues; + if (sc.u1[0]==SC_GUI) + ms=DoMenu(m); + if (ms==1 || ch=='1') + map_mode=mm_none; + else if (ms==2 || ch=='2') + map_mode=mm_friendly_firepower; + else if (ms==3 || ch=='3') + map_mode=mm_laps_time; + } + if (!(++i&7) && map_mode==mm_friendly_firepower) + PutFriendlyFirepower(Fs); + Sleep(40); + if (ai==ai_target) + DoAiTarget; + UpdateVelocities; + UpdatePositions; + ResolveFiring; + } + } + Kill(song_tss); + Sound(0); + LtfDel(l); + Fs->aux_ltf=old_aux_ltf; + if (Fs->cur_ltf=old_cur_ltf) + LtfBottom(Fs->cur_ltf); + LtfDel(m); + + Fs->update_win=old_update; + Free(map_values); + AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double); + AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,old_has_menu); + WinBorder(old_border); + Preempt(old_preempt); +} +Tøÿÿÿýÿÿÿÿÿÿÿ þÿÿÿ|  ÿÿÿÿÿÿÿÿÿÿÿÿøÿÿÿýÿÿÿÿÿÿÿ þÿÿÿ| + + øÿÿÿýÿÿÿÿÿÿÿ þÿÿÿ|  ÿÿÿÿ ÿÿÿÿ ÿÿÿÿøÿÿÿýÿÿÿÿÿÿÿ þÿÿÿ \ No newline at end of file diff --git a/LT/Apps/WarGame/WarGame.MUZ b/LT/Apps/WarGame/WarGame.MUZ new file mode 100644 index 0000000..16ac1a4 --- /dev/null +++ b/LT/Apps/WarGame/WarGame.MUZ @@ -0,0 +1,14 @@ +$TX+CX,"WarGame"$ +$TX+CX,"------------"$ +$TX+CX,"Button #1 issues command"$s + +$TX+CX,"Throttle/Wheel adjusts command strength."$ + +$MA+A+CX,"SPACE Restart"," "$ +$MA+A+CX,"ESC Quit ","\033"$ + +$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"$ + diff --git a/LT/COMPILE/ASM.CPZ b/LT/COMPILE/ASM.CPZ deleted file mode 100644 index dfee4e3..0000000 --- a/LT/COMPILE/ASM.CPZ +++ /dev/null @@ -1,1411 +0,0 @@ - -ClassStruct *CmpClassNew() -{ - ClassStruct *result=MAllocZ(sizeof(ClassStruct)<<2), - *tempc=result; - - tempc->last_in_member_list=&tempc->member_list; - tempc->type=HTT_CLASS; - tempc->sub_type=IT_I4; - tempc->pointer_cnt=0; - - tempc+=sizeof(ClassStruct); - tempc->type=HTT_CLASS; - tempc->sub_type=IT_I4; - tempc->size=4; - tempc->pointer_cnt=1; - - tempc+=sizeof(ClassStruct); - tempc->type=HTT_CLASS; - tempc->sub_type=IT_I4; - tempc->size=4; - tempc->pointer_cnt=2; - - tempc+=sizeof(ClassStruct); - tempc->type=HTT_CLASS; - tempc->sub_type=IT_I4; - tempc->size=4; - tempc->pointer_cnt=3; - - return result; -} - -void LoadAsmHash(BoolU4 first) -{ - U8 i,type; - U4 *dd; - LexStruct *l; - I8 size,size1; - SysHashEntry *temph,**temph1; - ClassStruct *tempc; - OpcodeHashEntry *tempo,*tempo1; - InstructionEntry *tempi; - - asm_hash=NewHashTable(2048); - size1=offset(OpcodeHashEntry.ins)+sizeof(InstructionEntry)<<5; - tempo=MAlloc(size1); - - l=LexNew(ReadTextFile("ASM.TXZ"),0,NewString("ASM.TXZ")); - l->hash_table_list=NULL; - Lex(l); - while (l->token) { - if (l->token!=TK_IDENT) - PutAsmError(l,"ST_EXPECTING_IDENTIFIER"); - else { - i=MatchListEntry(l->ident,"OPCODE\0KEYWORD\0R8\0R16\0R32\0SEG\0\0",MLE_IGNORE_CASE); - Lex(l); //skip keyword - if (!i) { //OPCODE - MemSet(tempo,0,size1); - tempo->type=HTT_OPCODE; - tempo->instruction_entry_cnt=0; - tempo->string=l->ident; - l->ident=0; - Lex(l); //Skip OPCODE - while (l->token && l->token!=';') { - tempi=&tempo->ins[tempo->instruction_entry_cnt]; - tempi->ins_entry_num=tempo->instruction_entry_cnt++; - tempi->opcode_cnt=0; - while (l->token==TK_INTEGER) { - tempi->opcode[tempi->opcode_cnt++]=l->cur_i; - Lex(l); - } - if (l->token=='+') { - tempi->plus_opcode=1; - Lex(l); - } else - tempi->plus_opcode=0; - if (l->token=='/') { - if (Lex(l)==TK_INTEGER) { - tempi->slash_value=l->cur_i; - Lex(l); - } else if (l->token==TK_IDENT) { - tempi->slash_value=8; - Lex(l); - } - } else - tempi->slash_value=9; - if (l->token=='*') { - tempi->operand_size16=1; - Lex(l); - } else - tempi->operand_size16=0; - if (l->token=='%') { - tempi->operand_size32=1; - Lex(l); - } else - tempi->operand_size32=0; - if (l->token=='!') { - tempi->dont_switch_modes=1; - Lex(l); - } else - tempi->dont_switch_modes=0; - if (l->token=='&') { - tempi->default=1; - Lex(l); - } else - tempi->default=0; - if (l->token!=TK_IDENT) - PutAsmError(l,"ST_EXPECTING_IDENTIFIER"); - else { - tempi->opcode_modifier=MatchSysTextEntry(l->ident, - "ST_OPCODE_MODIFIERS",MLE_IGNORE_CASE); - tempi->arg1=0; - tempi->arg2=0; - if (Lex(l)==TK_IDENT) { - tempi->arg1=MatchSysTextEntry(l->ident, - "ST_ARGUMENT_TYPES",MLE_IGNORE_CASE); - if (Lex(l)==TK_IDENT) { - tempi->arg2=MatchSysTextEntry(l->ident, - "ST_ARGUMENT_TYPES",MLE_IGNORE_CASE); - Lex(l); - } - } - } - } - if (l->token==';') { - Lex(l); //Skip ';' - size=offset(OpcodeHashEntry.ins)+ - sizeof(InstructionEntry)*tempo->instruction_entry_cnt; - tempo1=MAlloc(size); - MemCpy(tempo1,tempo,size); - temph1=FindHashBucket(tempo1->string,asm_hash); - tempo1->use_cnt=0; - SetSourceFileInfo(l,tempo1); - tempo1->next=*temph1; - *temph1=tempo1; - } else - PutAsmError(l,"ST_MISSING_SEMICOLON"); - } else if (i>=1 && i<=5) { //KEYWORD,R8,R16,R32,SEG - if (l->token!=TK_IDENT) - PutAsmError(l,"ST_EXPECTING_IDENTIFIER"); - else { - temph=MAllocZ(sizeof(SysHashEntry)); - temph->string=l->ident; - l->ident=NULL; - temph->use_cnt=0; - SetSourceFileInfo(l,temph); - Lex(l); //skip keyword name - if (l->token!=TK_INTEGER) - PutAsmError(l,"ST_EXPECTING_INTEGER"); - else { - temph->user0=l->cur_i; - if (Lex(l)!=';') - PutAsmError(l,"ST_MISSING_SEMICOLON"); - else { - Lex(l); //skip ';' - temph1=FindHashBucket(temph->string,asm_hash); - temph->next=*temph1; - *temph1=temph; - } - } - switch (i) { - case 1: - temph->type=HTT_KEYWORD; - if (first) { - temph=MAllocIdentical(temph); - temph1=FindHashBucket(temph->string,adam_tss->hash_table); - temph->next=*temph1; - *temph1=temph; - } - break; - case 2: temph->type=HTT_R8; break; - case 3: temph->type=HTT_R16; break; - case 4: temph->type=HTT_R32; break; - case 5: temph->type=HTT_SEG; break; - } - } - } else - PutAsmError(l,"Unknown Statement"); - } - } - Free(tempo); - LexDel(l); - dd=internal_types_table; - while (*dd!=HTT_INVALID) { - tempc=CmpClassNew; - tempc->type=*dd; dd+=4; - tempc->use_cnt=0; - tempc->source_link=NULL; - tempc->sub_type=*dd; dd+=4; - tempc->size=*dd; dd+=4; - tempc->string=ANewString(dd); - dd+=StrLen(tempc->string)+1; - temph1=FindHashBucket(tempc->string,asm_hash); - tempc->next=*temph1; - *temph1=tempc; - sys_internal_types[tempc->sub_type]=tempc; - - if (first) { - tempc=MAllocIdentical(tempc); - temph1=FindHashBucket(tempc->string,adam_tss->hash_table); - tempc->next=*temph1; - *temph1=tempc; - } - } -} - -void AddUnresolved(AsmCtrlStruct *a,U1 *exp,I8 type,U8 ip,U8 rel_ip, - LexUndefEntry *undef_hash,I8 line_num,BoolU4 U1_avail,BoolU4 glbl) -{ - AsmUnresolvedRef *tempu=MAlloc(sizeof(AsmUnresolvedRef)); - tempu->exp=exp; - tempu->type=type; - tempu->ip=ip; - tempu->rel_ip=rel_ip; - tempu->undef_hash=undef_hash; - tempu->literal=FALSE; - tempu->line_num=line_num; - tempu->U1_avail=U1_avail; - tempu->string=NULL; - if (glbl) { - tempu->next=a->glbl_unresolved; - a->glbl_unresolved=tempu; - if (undef_hash->hash->type & HTT_IMPORT) { - tempu->string=NewString(undef_hash->hash->string); - if (undef_hash->hash->type & HTT_LITERAL) - tempu->literal=TRUE; - } - } else { - tempu->next=a->local_unresolved; - a->local_unresolved=tempu; - a->has_locals=TRUE; - } -} - -void AsmListLine(LexStruct *l) -{ - I8 i; - AsmCtrlStruct *a=l->a; - LexFileStruct *tempf=l->cur_lfn; - LtfEntry *cl=tempf->line_start,*cl3; - if (a->list && a->last_lfn==tempf && cl) { - if (cl3=a->last_line_listed) { - while (cl3->yy) { - for (i=a->display_col;i<8;i++) - cout " "; - a->display_col=0; - PrintF("%08X ",a->last_ip); - cl3=LexPutLine(l,cl3); - } - a->last_line_listed=cl3; - } else - a->last_line_listed=cl; - } else { - a->last_line_listed=NULL; - a->last_lfn=tempf; - } - a->last_ip=a->ip; -} - -exe {NoRegVar(ON);} -void AsmStoreCodeU1(LexStruct *l,U1 b) -{ - AsmCtrlStruct *a=l->a; - I8 i=a->ip>>ASM_CODE_BLK_BITS; - AsmCodeBlk *tempc=a->code; - while (i--) - if (!(tempc=tempc->next)) { - i=a->ip>>ASM_CODE_BLK_BITS+1; - tempc=&a->code; - while (i--) { - if (!*tempc) - *tempc=MAllocZ(sizeof(AsmCodeBlk)); - tempc=tempc->next; - } - break; - } - tempc->body[a->ip++ & (ASM_CODE_BLK_SIZE-1)]=b; - if (a->list) { - PrintF("%02X ",b); - a->display_col++; - if (a->display_col>8) { - a->display_col=0; - AsmListLine(l); - } - } - if (a->ip>a->num_code_U1s) - a->num_code_U1s=a->ip; -} -exe {NoRegVar(OFF);} - -void AsmStoreCodeU1At(LexStruct *l,U1 b,I8 ip) -{ - AsmCtrlStruct *a=l->a; - I8 i=ip>>ASM_CODE_BLK_BITS+1; - AsmCodeBlk *tempc=&a->code; - while (i--) { - if (!*tempc) { - *tempc=MAlloc(sizeof(AsmCodeBlk)); - **tempc=NULL; - } - tempc=tempc->next; - } - tempc->body[ip & (ASM_CODE_BLK_SIZE-1)]=b; - if (ip+1>a->num_code_U1s) - a->num_code_U1s=ip+1; -} - - -I8 AsmEvalExpression(LexStruct *l) -{ - U1 *exp; - I8 result=0; - l->undef_hash_entry=NULL; - l->flags&=~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); - l->absolute_address_cnt=0; - if (!GetExpression(l,&exp)) - LexSkipEol(l); - else { - if (!(l->flags & (LF_UNRESOLVED_LOCAL|LF_UNRESOLVED_GLBL))) { - result=Run(exp); - DelExpression(exp); - } else - PutAsmError(l,"ST_UNDEFINED_SYMBOL"); - } - return result; -} - -void ResolveLocals(LexStruct *l) -{ - AsmCtrlStruct *a=l->a; - AsmUnresolvedRef *tempu=a->local_unresolved,*tempu1; - I8 result=0; - LexUndefEntry *templu; - BoolU4 undefined; - I1 *label=NULL; - - if (!a->has_locals) - return; - while (tempu) { - undefined=FALSE; - tempu1=tempu->next; - templu=tempu->undef_hash; - while (templu) { - if (templu->hash->type & (HTT_UNRESOLVED_LOCAL | HTT_UNRESOLVED_GLBL)) { - cout SysText("ST_ERROR"),SysText("ST_UNDEFINED_SYMBOL"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - if (a->last_label) cout a->last_label," "; - coutln templu->hash->string; - l->error_cnt++; - undefined=TRUE; - } else - label=templu->hash->string; - templu=templu->next; - } - if (!undefined) { - result=Run(tempu->exp); - if (!(tempu->type & 1)) { - result-=tempu->rel_ip; - if (tempu->type==EIE_REL_U1 && (result<-128 || result>127) || - tempu->type==EIE_REL_U2 && (result<-0x8000 || result>0x7FFF) ) { - cout SysText("ST_ERROR"),SysText("ST_BRANCH_OUT_OF_RANGE"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - if (a->last_label) - PrintF("%s ",a->last_label); - if (label) cout label; - CrLf; - l->error_cnt++; - } - if (tempu->U1_avail && tempu->type>EIE_LIT_U1 && (result>=-124 && result<=123)) { - cout SysText("ST_WARNING"),SysText("ST_COULD_USE_U1_DISP"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - if (a->last_label) - PrintF("%s ",a->last_label); - if (label) cout label; - CrLf; - } - } - AsmStoreCodeU1At(l,result.u1[0],tempu->ip); - if (tempu->type>=EIE_REL_U2) - AsmStoreCodeU1At(l,result.u1[1],tempu->ip+1); - if (tempu->type>=EIE_REL_U4) { - AsmStoreCodeU1At(l,result.u1[2],tempu->ip+2); - AsmStoreCodeU1At(l,result.u1[3],tempu->ip+3); - } - } - DelExpression(tempu->exp); - DelLinkedList(tempu->undef_hash); - Free(tempu); - tempu=tempu1; - } - DelHashTable(a->local_hash); - a->local_hash=NewHashTable(16); - a->local_hash->next=a->glbl_hash; - l->hash_table_list=a->local_hash; - l->local_hash_table=a->local_hash; - a->local_unresolved=NULL; - a->has_locals=FALSE; -} - -void ResolveGlbls(LexStruct *l,ExeStruct *e) -{ - AsmCtrlStruct *a=l->a; - ClassStruct *tempc; - GlblVarStruct *tempg; - AsmUnresolvedRef *tempu=a->glbl_unresolved,*tempu1; - I8 result=0; - ExeImportExportStruct *tempe,*tempe1; - LexUndefEntry *templu; - I8 i; - SysHashEntry *temph; - I1 *label; - BoolU4 undefined; - l;//Ref so no warning - while (tempu) { - label=NULL; - undefined=FALSE; - tempu1=tempu->next; - templu=tempu->undef_hash; - while (templu) { - if (templu->hash->type & (HTT_UNRESOLVED_LOCAL | HTT_UNRESOLVED_GLBL)) { - if (!(templu->hash->type & HTT_IMPORT)) { - cout SysText("ST_ERROR"),SysText("ST_UNDEFINED_SYMBOL"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - cout templu->hash->string,"\r\n"; - l->error_cnt++; - } - undefined=TRUE; - } else - label=templu->hash->string; - templu=templu->next; - } - if (undefined) { - templu=tempu->undef_hash; - if (templu->hash->type & HTT_IMPORT) { - tempe=MAllocZ(sizeof(ExeImportExportStruct)); - tempe->next=templu->hash->user1; - tempe->string=NULL; - templu->hash->user1=tempe; - tempe->ip=tempu->ip; - tempe->type=tempu->type; - } - } else { - result=Run(tempu->exp); - if (!(tempu->type & 1)) { - result=result-tempu->rel_ip; - if ((tempu->type==EIE_REL_U1 && (result<-128 || result>127)) || - tempu->type==EIE_REL_U2 && (result<-0x8000 || result>0x7FFF)) { - cout SysText("ST_ERROR"),SysText("ST_BRANCH_OUT_OF_RANGE"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - if (label) cout label; - CrLf; - l->error_cnt++; - } - if (tempu->U1_avail && tempu->type>EIE_LIT_U1 && (result>=-124 && result<=123)) { - cout SysText("ST_WARNING"),SysText("ST_COULD_USE_U1_DISP"),SysText("ST_LINE"); - PrintF("%04d ",tempu->line_num); - if (a->last_label) - PrintF("%s ",a->last_label); - if (label) cout label; - CrLf; - } - } - AsmStoreCodeU1At(l,result.u1[0],tempu->ip); - if (tempu->type>=EIE_REL_U2) - AsmStoreCodeU1At(l,result.u1[1],tempu->ip+1); - if (tempu->type>=EIE_REL_U4) { - AsmStoreCodeU1At(l,result.u1[2],tempu->ip+2); - AsmStoreCodeU1At(l,result.u1[3],tempu->ip+3); - } - } - DelExpression(tempu->exp); - DelLinkedList(tempu->undef_hash); - Free(tempu); - tempu=tempu1; - } - - tempe1=&e->ie; - while (tempe1->next) - tempe1=tempe1->next; - - for (i=0;i<=a->glbl_hash->mask;i++) { - temph=a->glbl_hash->body[i]; - while (temph) { - if (temph->type & HTT_IMPORT && temph->use_cnt) { - if (temph->type & HTT_FUNCTION) { - tempe=MAllocZ(sizeof(ExeImportExportStruct)); - tempe->type=EIE_LIT_U4; - tempc=temph; - tempe->string=(tempc->import_name) ? - NewString(tempc->import_name):NewString(tempc->string); - tempe->ip=tempc->executable_address; - tempe1->next=tempe; - tempe1=tempe; - } else if (temph->type & HTT_GLBL_VAR) { - tempe=MAllocZ(sizeof(ExeImportExportStruct)); - tempe->type=EIE_LIT_U4; - tempg=temph; - if (tempg->import_name) - tempe->string=NewString(tempg->import_name); - else - tempe->string=NewString(tempg->string); - tempe->ip=tempg->data_address; - tempe1->next=tempe; - tempe1=tempe; - } else { - tempe=temph->user1; - if (tempe) { - tempe1->next=tempe; - tempe->string=NewString(temph->string); - while (tempe1->next) - tempe1=tempe1->next; - } - } - } else if (temph->type & HTT_EXPORT) { - if (temph->type & HTT_UNRESOLVED_GLBL) { - coutln SysText("ST_ERROR"),SysText("ST_UNDEFINED_SYMBOL"),temph->string; - l->error_cnt++; - } else { - tempe=MAlloc(sizeof(ExeImportExportStruct)); - tempe->type=EIE_REL_EXPORT; - if (temph->type & HTT_FUNCTION) { - tempc=temph; - tempe->ip=tempc->executable_address; - } else if (temph->type & HTT_GLBL_VAR) { - tempg=temph; - tempe->ip=tempg->data_address; - } else - tempe->ip=temph->user0; - if (temph->type & HTT_LITERAL) - tempe->type++; - *tempe1=tempe; - tempe->next=NULL; - tempe1=tempe; - tempe->string=NewString(temph->string); - } - } - temph=temph->next; - } - } -} - -BoolU4 ParseAsmImm(LexStruct *l,AsmCtrlStruct *aa,AsmArgStruct *a,U8 ip) -{ - if (a->imm_or_off_present) { - PutAsmError(l,"ST_ALREADY_ONE_IMMEDIATE"); - return FALSE; - } else { - a->imm_or_off_present=TRUE; - a->undef_local=NULL; - a->undef_glbl=NULL; - l->instruction_pointer=ip; - l->undef_hash_entry=NULL; - l->absolute_address_cnt=0; - l->flags&=~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); - if (!GetExpression(l,&a->exp)) - LexSkipEol(l); - else { - if (!(l->flags & (LF_UNRESOLVED_LOCAL|LF_UNRESOLVED_GLBL))) { - a->imm=Run(a->exp); - a->undef_glbl=l->undef_hash_entry; - l->undef_hash_entry=NULL; - DelExpression(a->exp); - a->exp=NULL; - } else { - if (l->flags & LF_UNRESOLVED_GLBL) { - a->undef_glbl=l->undef_hash_entry; - l->undef_hash_entry=NULL; - aa->has_locals=TRUE; - } else if (l->flags & LF_UNRESOLVED_LOCAL) { - a->undef_local=l->undef_hash_entry; - l->undef_hash_entry=NULL; - } - } - } - } - return TRUE; -} - -void ParseAsmArg(LexStruct *l,AsmCtrlStruct *aa,AsmArgStruct *a,U8 ip) -{ - I8 i,temp; - a->size=0; - a->absolute_address_cnt=0; - a->seg=8; - a->reg1=8; - a->reg2=8; - a->imm=0; - a->scale=1; - a->indirect=FALSE; - a->imm_or_off_present=FALSE; - a->undef_local=NULL; - a->undef_glbl=NULL; - a->just_seg=FALSE; - a->exp=NULL; - while (TRUE) { - if (l->token==TK_IDENT) { - if (l->hash_entry) { - if (l->hash_entry->type==HTT_R8) { - a->size=1; - a->reg1=l->hash_entry->user0; - Lex(l); - return; - } else if (l->hash_entry->type==HTT_R16) { - a->size=2; - a->reg1=l->hash_entry->user0; - Lex(l); - return; - } else if (l->hash_entry->type==HTT_R32) { - a->size=4; - a->reg1=l->hash_entry->user0; - Lex(l); - return; - } else if (l->hash_entry->type==HTT_SEG) { - a->seg=l->hash_entry->user0; - if (Lex(l)!=':') { - a->just_seg=TRUE; - return; - } else - Lex(l); //skip ":" - } else if (l->hash_entry->type==HTT_KEYWORD) { - i=l->hash_entry->user0; - if (i==AKW_U1) { - Lex(l); //skip keyword - a->size=1; - } else if (i==AKW_U2) { - Lex(l); //skip keyword - a->size=2; - } else if (i==AKW_U4) { - Lex(l); //skip keyword - a->size=4; - } else { - PutAsmError(l,"ST_SYNTAX_ERROR"); - return; - } - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - if (l->token!='[') - return; - } - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - if (l->token!='[') - return; - } - } else if (l->token=='[') { - a->indirect=TRUE; - Lex(l); // skip [ - while (l->token && l->token!=']') { - if (l->token==TK_IDENT) { - if (l->hash_entry) { - if (l->hash_entry->type==HTT_R16 || l->hash_entry->type==HTT_R32) { - if (a->reg1==8) - a->reg1=l->hash_entry->user0; - else - a->reg2=l->hash_entry->user0; - Lex(l); - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - } - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - } - } else if (l->token=='*') { - if (Lex(l)!=TK_INTEGER) - PutAsmError(l,"ST_EXPECTING_SCALE_FACTOR"); - else { - a->scale=l->cur_i; - Lex(l); //skip scale - if (a->reg2!=8) { - temp=a->reg1; - a->reg1=a->reg2; - a->reg2=temp; - } - } - } else if (l->token=='+') { - Lex(l); //skip '+' - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - } - } - if (l->token==']') { - Lex(l); //skip ] - return; - } else - PutAsmError(l,"ST_MISSING_RIGHT_BRACKET"); - } else { - ParseAsmImm(l,aa,a,ip); - a->absolute_address_cnt=l->absolute_address_cnt; - if (l->token!='[') - return; - } - } -} - -void AsmMakeArgMask(AsmArgStruct *a,U8 *mask) -{ - if (a->just_seg) { - mask->u4[0]=0; - if (!a->seg) - mask->u4[1]=0x24; - else if (a->seg==1) - mask->u4[1]=0x60; - else if (a->seg==2) - mask->u4[1]=0x21; - else if (a->seg==3) - mask->u4[1]=0x22; - else if (a->seg==4) - mask->u4[1]=0x28; - else - mask->u4[1]=0x30; - return; - } - mask->u4[1]=0; - - if (!a->size) - mask->u4[0]=0xFF07FFFE; - else if (a->size==1) - mask->u4[0]=0x19012492; - else if (a->size==2) - mask->u4[0]=0xA2024924; - else if (a->size==4) - mask->u4[0]=0x44049248; - - if (a->reg1!=8 && a->imm_or_off_present && !a->imm) { - if (!a->undef_glbl && !a->undef_local) - a->imm_or_off_present=FALSE; //Zero displacement - } - - if (a->reg2!=8 || a->scale!=1) { - mask->u4[0]&=0x0000E000; - return; - } - - if (a->indirect) { - if (a->imm_or_off_present) { - mask->u4[0]&=0x07FFE000; - } else - mask->u4[0]&=0x00FFE000; - } else { - if (a->imm_or_off_present) - mask->u4[0]&=0x00F81C7E; - else - mask->u4[0]&=0xF8F8E380; - } - if (a->seg!=8) - mask->u4[0]&=0x07FFE000; - if (a->reg1==8) { - if (a->indirect) - mask->u4[0]&=0x07FFE000; - else if (a->imm>=-128 && a->imm<=127) - mask->u4[0]&=0x00001C7E; - else if (a->imm>=-128 && a->imm<=255) - mask->u4[0]&=0x0000187E; - else if (a->imm>=-0x8000 && a->imm<=0x7FFF) - mask->u4[0]&=0x0000186E; - else if (a->imm>=-0x8000 && a->imm<=0xFFFF) - mask->u4[0]&=0x0000106E; - else - mask->u4[0]&=0x0000104E; - } else - mask->u4[0]&=0xF807E380; - if (a->reg1!=0) - mask->u4[0]&=0x8FFFFFFF; - if (a->reg1!=1) - mask->u4[0]&=0xF7FFFFFF; - if (a->reg1!=2) - mask->u4[0]&=0x7FFFFFFF; -// coutln "MASK:",mask->u4[0]; -} - -BoolU4 AsmStoreNum(LexStruct *l,AsmCtrlStruct *a,I8 num,BoolU4 is_question,I8 num_U1s,I8 cnt, - I8 num_ip_rel,I8 num_lit, - U1 *num_exp,LexUndefEntry *num_local_hash,LexUndefEntry *num_glbl_hash, - BoolU4 U1_avail,U8 abs_add_cnt) -{ - I8 i,j; - ExeAbsoluteAddressStruct *tempa; - if (!num_lit) - num=num-num_ip_rel; - for (i=0;iip,num_ip_rel, - num_local_hash,LexLineNum(l),U1_avail,FALSE); - else if (num_glbl_hash) - AddUnresolved(a,num_exp,EIE_REL_U1+num_lit,a->ip,num_ip_rel, - num_glbl_hash,LexLineNum(l),U1_avail,TRUE); - else { - if (!num_lit && (num<-128 || num>127)) { - LexPop(l); - PutAsmError(l,"ST_BRANCH_OUT_OF_RANGE"); - a->ip++; - return FALSE; - } - } - if (is_question) - a->ip++; - else - AsmStoreCodeU1(l,num.u1[0]); - - } else if (num_U1s==2) { - if (num_local_hash) - AddUnresolved(a,num_exp,EIE_REL_U2+num_lit,a->ip,num_ip_rel, - num_local_hash,LexLineNum(l),U1_avail,FALSE); - else if (num_glbl_hash) - AddUnresolved(a,num_exp,EIE_REL_U2+num_lit,a->ip,num_ip_rel, - num_glbl_hash,LexLineNum(l),U1_avail,TRUE); - else { - if (!num_lit && (num <-0x8000 || num>0x7FFF)) { - LexPop(l); - PutAsmError(l,"ST_BRANCH_OUT_OF_RANGE"); - a->ip+=2; - return FALSE; - } - } - if (is_question) - a->ip+=2; - else { - AsmStoreCodeU1(l,num.u1[0]); - AsmStoreCodeU1(l,num.u1[1]); - } - if (U1_avail && !num_local_hash && !num_glbl_hash && - !num_lit && num>=-124 && num<=123) { - LexPop(l); - PutAsmWarning(l,"ST_COULD_USE_U1_DISP"); - return FALSE; - } - } else if (num_U1s==4) { - if (num_local_hash) - AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, - num_local_hash,LexLineNum(l),U1_avail,FALSE); - else if (num_glbl_hash) - AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, - num_glbl_hash,LexLineNum(l),U1_avail,TRUE); - if (num_lit && abs_add_cnt & 1) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip; - } - if (is_question) - a->ip+=4; - else - for (j=0;j=-124 && num<=123) { - LexPop(l); - PutAsmWarning(l,"ST_COULD_USE_U1_DISP"); - return FALSE; - } - } else if (num_U1s==8) { -//dbgo - if (num_local_hash) - AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, - num_local_hash,LexLineNum(l),U1_avail,FALSE); - else if (num_glbl_hash) - AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, - num_glbl_hash,LexLineNum(l),U1_avail,TRUE); - if (num_lit && abs_add_cnt & 1) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip; - } - if (is_question) - a->ip+=8; - else - for (j=0;j=-124 && num<=123) { - LexPop(l); - PutAsmWarning(l,"ST_COULD_USE_U1_DISP"); - return FALSE; - } - } - } - return TRUE; -} - - -BoolU4 AsmCodeInstruction(LexStruct *l,AsmCtrlStruct *a, - OpcodeHashEntry *tempo,I8 argcnt) -{ - I8 i,j,a1,a2,om,seg; - U8 arg1mask,arg2mask; - AsmArgStruct *tempa1,*tempa2; - BoolU4 ModrM_complete,U1_avail=FALSE,found_second_possible=FALSE; - - I8 U1_cnt; - U1 last_opcode_U1; - InstructionEntry *tempi; - BoolU4 has_ModrM; - U1 ModrM; - BoolU4 has_SIB; - U1 SIB; - BoolU4 has_address_prefix; - BoolU4 has_operand_prefix; - BoolU4 is_default; - I8 disp,disp_U1s,disp_ip_rel,disp_lit,disp_abs_cnt; - I8 imm, imm_U1s, imm_ip_rel, imm_lit,imm_abs_cnt; - U1 *disp_exp,*imm_exp; - LexUndefEntry *disp_local_hash,*disp_glbl_hash; - LexUndefEntry *imm_local_hash,*imm_glbl_hash; - - I8 best_U1_cnt=255; - U1 blast_opcode_U1; - InstructionEntry *btempi; - BoolU4 bhas_ModrM; - U1 bModrM; - BoolU4 bhas_SIB; - U1 bSIB; - BoolU4 bhas_address_prefix; - BoolU4 bhas_operand_prefix; - BoolU4 bis_default; - I8 bdisp,bdisp_U1s,bdisp_ip_rel,bdisp_lit,bdisp_abs_cnt; - I8 bimm, bimm_U1s, bimm_ip_rel, bimm_lit,bimm_abs_cnt; - U1 *bdisp_exp,*bimm_exp; - LexUndefEntry *bdisp_local_hash,*bdisp_glbl_hash; - LexUndefEntry *bimm_local_hash,*bimm_glbl_hash; - - - if (argcnt>0) - AsmMakeArgMask(&a->arg1,&arg1mask); - else - arg1mask=1; - if (argcnt>1) - AsmMakeArgMask(&a->arg2,&arg2mask); - else - arg2mask=1; - - for (i=0;iinstruction_entry_cnt;i++) { - tempi=&tempo->ins[i]; - if (tempi->arg1==ARGT_REL8 || tempi->arg2==ARGT_REL8) - U1_avail=TRUE; - if (Bt(&arg1mask,tempi->arg1) && Bt(&arg2mask,tempi->arg2)) { - ModrM_complete=FALSE; - last_opcode_U1=0; - has_ModrM=FALSE; - ModrM=0; - has_SIB=FALSE; - SIB=0; - has_address_prefix=FALSE; - has_operand_prefix=FALSE; - if (tempi->default) - is_default=TRUE; - else - is_default=FALSE; - disp=0; disp_U1s=0; disp_ip_rel=0; disp_lit=1; - imm=0; imm_U1s=0; imm_ip_rel=0; imm_lit=1; - disp_exp=NULL; imm_exp=NULL; - disp_local_hash=NULL; disp_glbl_hash=NULL; - disp_abs_cnt=0; - imm_local_hash=NULL; imm_glbl_hash=NULL; - imm_abs_cnt=0; - om=tempi->opcode_modifier; - a1=tempi->arg1; - a2=tempi->arg2; - tempa1=&a->arg1; - tempa2=&a->arg2; - last_opcode_U1=tempi->opcode[tempi->opcode_cnt-1]; - - if (tempi->slash_value<8) { - ModrM+=tempi->slash_value<<3; - has_ModrM=TRUE; - } - - if ((a->use16 && tempi->operand_size32) || - (!a->use16 && tempi->operand_size16)) - has_operand_prefix=TRUE; - - if (om==OM_IB) imm_U1s=1; - else if (om==OM_IW) imm_U1s=2; - else if (om==OM_ID) imm_U1s=4; - - if (om==OM_CB) { - imm_U1s=1; - imm_lit=0; - } else if (om==OM_CW) { - imm_U1s=2; - imm_lit=0; - } else if (om==OM_CD) { - imm_U1s=4; - imm_lit=0; - } - - if (argcnt==1) { - if (best_U1_cnt!=255 && !found_second_possible && !bis_default) { - found_second_possible=TRUE; - if (!a->arg1.size) { - cout SysText("ST_WARNING"),SysText("ST_NO_SIZE_SPECIFIED"); - PrintF("%s,%04d\r\n",l->cur_lfn->name,l->cur_lfn->line_num-1); - } - } - if (tempi->plus_opcode) - last_opcode_U1=last_opcode_U1+tempa1->reg1; - if (a1>=ARGT_RM8 && a1<=ARGT_RM32) { - if (a->use16) - has_address_prefix=TRUE; - - has_ModrM=TRUE; - if (tempa1->imm_or_off_present && tempa1->indirect && tempa1->reg1==8) { - ModrM=ModrM+5; - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_U1s=4; - disp_abs_cnt=tempa1->absolute_address_cnt; - } else { - if (tempa1->reg2==8 && tempa1->scale==1) - ModrM+=tempa1->reg1; - else { - ModrM+=4; - has_SIB=TRUE; - if (tempa1->scale==1) - SIB=0; - else if (tempa1->scale==2) - SIB=0x40; - else if (tempa1->scale==4) - SIB=0x80; - else if (tempa1->scale==8) - SIB=0xC0; - if (tempa1->reg2==8) { - ModrM_complete=TRUE; - SIB=SIB+(tempa1->reg1<<3)+5; - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_U1s=4; - disp_abs_cnt=tempa1->absolute_address_cnt; - } else { - SIB=SIB+(tempa1->reg1<<3)+tempa1->reg2; - if (tempa1->reg2==5 && !tempa1->imm_or_off_present && tempa1->indirect) { - ModrM+=0x40; - disp_U1s=1; - ModrM_complete=TRUE; - } - } - } - if (!ModrM_complete) { - if (tempa1->imm_or_off_present) { - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_abs_cnt=tempa1->absolute_address_cnt; - if (!disp_exp && disp>=-128 && disp<=127) { - ModrM+=0x40; - disp_U1s=1; - } else if (a->use16) { - ModrM+=0x80; - disp_U1s=2; - } else { - ModrM+=0x80; - disp_U1s=4; - } - } else if (!tempa1->indirect) { - has_address_prefix=FALSE; - ModrM+=0xC0; - } else { - if (tempa1->reg1==5) { - ModrM+=0x40; - disp_U1s=1; - } - } - } - } - } else if (a1>=ARGT_REL8 && a1<=ARGT_REL32 || - a1>=ARGT_IMM8 && a1<=ARGT_IMM32 || - a1>=ARGT_UIMM8 && a1<=ARGT_UIMM32) { - imm=tempa1->imm; - imm_exp=tempa1->exp; - imm_local_hash=tempa1->undef_local; - imm_glbl_hash=tempa1->undef_glbl; - imm_abs_cnt=tempa1->absolute_address_cnt; - } - } else if (argcnt==2) { - if (best_U1_cnt!=255 && !found_second_possible && !bis_default) { - found_second_possible=TRUE; - if (a->arg1.size==0 && a->arg2.size==0) { - cout SysText("ST_WARNING"),SysText("ST_NO_SIZE_SPECIFIED"); - PrintF("%s,%04d\r\n",l->cur_lfn->name,l->cur_lfn->line_num-1); - } - } - if (tempi->plus_opcode) { - if (om>=OM_RB && om<=OM_RD) - last_opcode_U1+=tempa1->reg1; - else if (tempi->slash_value==8) { - if (a1>=ARGT_AL && a1<=ARGT_EAX) - last_opcode_U1+=tempa2->reg1; - else if (a2>=ARGT_AL && a2<=ARGT_EAX) - last_opcode_U1+=tempa1->reg1; - } - } - if (a1>=ARGT_RM8 && a1<=ARGT_RM32 ||a2>=ARGT_RM8 && a2<=ARGT_RM32) { - if (a->use16) - has_address_prefix=TRUE; - has_ModrM=TRUE; - if (a2>=ARGT_RM8 && a2<=ARGT_RM32) { - tempa1=&a->arg2; - tempa2=&a->arg1; - } - if (tempi->slash_value==8) { - if (tempa2->just_seg) - ModrM+=(tempa2->seg<<3); - else { - if (tempa2->reg1==8) - ModrM+=(tempa1->reg1<<3); - else - ModrM+=(tempa2->reg1<<3); - } - } - if (tempa1->reg2==8 && tempa1->scale==1) { - if (tempa1->reg1!=8) - ModrM+=tempa1->reg1; - } else { - ModrM+=4; - has_SIB=TRUE; - if (tempa1->scale==1) - SIB=0; - else if (tempa1->scale==2) - SIB=0x40; - else if (tempa1->scale==4) - SIB=0x80; - else if (tempa1->scale==8) - SIB=0xC0; - if (tempa1->reg2==8) { - ModrM_complete=TRUE; - SIB+=(tempa1->reg1<<3)+5; - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_U1s=4; - disp_abs_cnt=tempa1->absolute_address_cnt; - } else { - SIB+=(tempa1->reg1<<3)+tempa1->reg2; - if (tempa1->reg2==5 && !tempa1->imm_or_off_present && tempa1->indirect) { - ModrM+=0x40; - disp_U1s=1; - ModrM_complete=TRUE; - } - } - } - if (!ModrM_complete) { - if (tempa1->imm_or_off_present && tempa1->indirect && tempa1->reg1==8) { - ModrM=(ModrM & 0xF8)+5; - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_U1s=4; - disp_abs_cnt=tempa1->absolute_address_cnt; - } else { - if (tempa1->imm_or_off_present) { - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_abs_cnt=tempa1->absolute_address_cnt; - if (!disp_exp && disp>=-128 && disp<=127) { - ModrM+=0x40; - disp_U1s=1; - } else if (a->use16) { - ModrM+=0x80; - disp_U1s=2; - } else { - ModrM+=0x80; - disp_U1s=4; - } - } else if (!tempa1->indirect) { - has_address_prefix=FALSE; - ModrM+=0xC0; - } else { - if (tempa1->reg1==5) { - ModrM+=0x40; - disp_U1s=1; - } - } - } - } - } else if (a1>=ARGT_MOFFS8 && a1<=ARGT_MOFFS32) { - disp=tempa1->imm; - disp_exp=tempa1->exp; - disp_local_hash=tempa1->undef_local; - disp_glbl_hash=tempa1->undef_glbl; - disp_abs_cnt=tempa1->absolute_address_cnt; - if (a->use16) - disp_U1s=2; - else - disp_U1s=4; - has_address_prefix=FALSE; - } else if (a2>=ARGT_MOFFS8 && a2<=ARGT_MOFFS32) { - disp=tempa2->imm; - disp_exp=tempa2->exp; - disp_local_hash=tempa2->undef_local; - disp_glbl_hash=tempa2->undef_glbl; - disp_abs_cnt=tempa2->absolute_address_cnt; - if (a->use16) - disp_U1s=2; - else - disp_U1s=4; - has_address_prefix=FALSE; - } else if (a1>=ARGT_IMM8 && a1<=ARGT_IMM32 || - a1>=ARGT_UIMM8 && a1<=ARGT_UIMM32) { - imm=tempa1->imm; - imm_exp=tempa1->exp; - imm_local_hash=tempa1->undef_local; - imm_glbl_hash=tempa1->undef_glbl; - imm_abs_cnt=tempa1->absolute_address_cnt; - if (a1==ARGT_IMM8 || a1==ARGT_UIMM8) imm_U1s=1; - else if (a1==ARGT_IMM16 || a1==ARGT_UIMM16) imm_U1s=2; - else imm_U1s=4; - } - if (a2>=ARGT_IMM8 && a2<=ARGT_IMM32 || - a2>=ARGT_UIMM8 && a2<=ARGT_UIMM32) { - imm=tempa2->imm; - imm_exp=tempa2->exp; - imm_local_hash=tempa2->undef_local; - imm_glbl_hash=tempa2->undef_glbl; - imm_abs_cnt=tempa2->absolute_address_cnt; - if (a2==ARGT_IMM8 || a2==ARGT_UIMM8) imm_U1s=1; - else if (a2==ARGT_IMM16 || a2==ARGT_UIMM16) imm_U1s=2; - else imm_U1s=4; - } - } - U1_cnt=tempi->opcode_cnt+disp_U1s+imm_U1s; - if (has_ModrM) U1_cnt++; - if (has_SIB) U1_cnt++; - - if (U1_cntdont_switch_modes && - (has_address_prefix || has_operand_prefix))) { - best_U1_cnt=U1_cnt; - blast_opcode_U1=last_opcode_U1; - btempi=tempi; - bhas_ModrM=has_ModrM; - bModrM=ModrM; - bhas_SIB=has_SIB; - bSIB=SIB; - bhas_address_prefix=has_address_prefix; - bhas_operand_prefix=has_operand_prefix; - bis_default=is_default; - bdisp=disp; - bdisp_U1s=disp_U1s; - bdisp_ip_rel=disp_ip_rel; - bdisp_lit=disp_lit; - bdisp_abs_cnt=disp_abs_cnt; - bimm=imm; - bimm_U1s=imm_U1s; - bimm_ip_rel=imm_ip_rel; - bimm_lit=imm_lit; - bimm_abs_cnt=imm_abs_cnt; - bdisp_exp=disp_exp; - bimm_exp=imm_exp; - bdisp_local_hash=disp_local_hash; - bdisp_glbl_hash=disp_glbl_hash; - bimm_local_hash=imm_local_hash; - bimm_glbl_hash=imm_glbl_hash; - } - } - } - if (best_U1_cnt<255) { - if (bhas_operand_prefix) - AsmStoreCodeU1(l,0x66); //Operand size override - if (bhas_address_prefix || a->use16 && has_SIB) - AsmStoreCodeU1(l,0x67); //Operand size override - - seg=8; - if (argcnt>1 && a->arg2.seg!=8 && !a->arg2.just_seg) - seg=a->arg2.seg; - else if (argcnt>0 && a->arg1.seg!=8 && !a->arg1.just_seg) - seg=a->arg1.seg; - if (seg!=8) { - if (seg==0) - AsmStoreCodeU1(l,0x26); //ES: - else if (seg==1) - AsmStoreCodeU1(l,0x2E); //CS: - else if (seg==2) - AsmStoreCodeU1(l,0x36); //SS: - else if (seg==3) - AsmStoreCodeU1(l,0x3E); //DS: - else if (seg==4) - AsmStoreCodeU1(l,0x64); //FS: - else - AsmStoreCodeU1(l,0x65); //GS: - } - - for (j=0;jopcode_cnt-1;j++) - AsmStoreCodeU1(l,btempi->opcode[j]); - AsmStoreCodeU1(l,blast_opcode_U1); - - if (bhas_ModrM) - AsmStoreCodeU1(l,bModrM); - if (bhas_SIB) - AsmStoreCodeU1(l,bSIB); - - if (bdisp_U1s) { - bdisp_ip_rel=a->ip+bdisp_U1s+bimm_U1s; - if (!AsmStoreNum(l,a,bdisp,FALSE,bdisp_U1s,1,bdisp_ip_rel,bdisp_lit, - bdisp_exp,bdisp_local_hash,bdisp_glbl_hash,U1_avail,bdisp_abs_cnt)) - return FALSE; - } - - if (bimm_U1s) { - bimm_ip_rel=a->ip+bimm_U1s; - if (!AsmStoreNum(l,a,bimm,FALSE,bimm_U1s,1,bimm_ip_rel,bimm_lit, - bimm_exp,bimm_local_hash,bimm_glbl_hash,U1_avail,bimm_abs_cnt)) - return FALSE; - } - return TRUE; - } - LexPop(l); - PutAsmError(l,"ST_INVALID_INSTRUCTION"); - return FALSE; -} - - -void DefineU1s(LexStruct *l,AsmCtrlStruct *a,I8 num_U1s) -{ - BoolU4 is_question,is_dup; - I8 i,dup_value; - U1 *exp; - I1 *ptr; - LexUndefEntry *undef_locals,*undef_glbls; - - while (l->token && l->token!=';') { - undef_locals=NULL; - undef_glbls=NULL; - if (l->token==TK_STRING) { - ptr=l->ident; - i=l->ident_len-1; - while (i--) - AsmStoreCodeU1(l,*ptr++); - Lex(l); //SKip STRING - } else { - is_question=FALSE; - is_dup=FALSE; - l->absolute_address_cnt=0; - if (l->token=='?') { - is_question=TRUE; - Lex(l); - } else { - l->undef_hash_entry=NULL; - l->flags=l->flags & ~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); - if (!GetExpression(l,&exp)) - LexSkipEol(l); - else { - if (l->flags & (LF_UNRESOLVED_LOCAL | LF_UNRESOLVED_GLBL)) { - if (l->flags & LF_UNRESOLVED_LOCAL) { - undef_locals=l->undef_hash_entry; - l->undef_hash_entry=NULL; - a->has_locals=TRUE; - } else if (l->flags & LF_UNRESOLVED_GLBL) { - undef_glbls=l->undef_hash_entry; - l->undef_hash_entry=NULL; - } - } else { - i=Run(exp); - DelExpression(exp); - } - } - } - if (l->token==TK_IDENT && l->hash_entry) { - if (l->hash_entry->type & HTT_KEYWORD && l->hash_entry->user0==AKW_DUP) { - if (is_question) - PutAsmError(l,"ST_QUESTION_NOT_ALLOWED"); - else { - is_dup=TRUE; - if (Lex(l)!='(') - PutAsmError(l,"ST_EXPECTING_LEFT_PAREN"); - else { - if (Lex(l)=='?') { - is_question=TRUE; - Lex(l); //SKIP "?" - } else - dup_value=AsmEvalExpression(l); - if (l->token!=')') - PutAsmError(l,"ST_EXPECTING_RIGHT_PAREN"); - else - Lex(l); //SKIP ')' - } - } - } - } - if (is_dup) { - if (undef_locals || undef_glbls) - PutAsmError(l,"ST_UNDEFINED_DUP_CNT"); - else - AsmStoreNum(l,a,dup_value,is_question,num_U1s,i,0,1,exp,undef_locals,undef_glbls,FALSE,l->absolute_address_cnt); - } else - AsmStoreNum(l,a,i,is_question,num_U1s,1,0,1,exp,undef_locals,undef_glbls,FALSE,l->absolute_address_cnt); - } - if (l->token==',') - Lex(l); - } - if (l->token==';') - Lex(l); - else - PutAsmError(l,"ST_MISSING_SEMICOLON"); -} - - \ No newline at end of file diff --git a/LT/COMPILE/CMP.ASZ b/LT/COMPILE/CMP.ASZ deleted file mode 100644 index b7ec6b5..0000000 Binary files a/LT/COMPILE/CMP.ASZ and /dev/null differ diff --git a/LT/COMPILE/CMP.BIZ b/LT/COMPILE/CMP.BIZ deleted file mode 100644 index b90c5fe..0000000 Binary files a/LT/COMPILE/CMP.BIZ and /dev/null differ diff --git a/LT/COMPILE/CMP.HPZ b/LT/COMPILE/CMP.HPZ deleted file mode 100644 index 03bcafa..0000000 Binary files a/LT/COMPILE/CMP.HPZ and /dev/null differ diff --git a/LT/COMPILE/CMP.MPZ b/LT/COMPILE/CMP.MPZ deleted file mode 100644 index 49d0557..0000000 --- a/LT/COMPILE/CMP.MPZ +++ /dev/null @@ -1,1126 +0,0 @@ -$LK +BI,"A2Double ","FL:::/LT/COMPILE/SPRINTF2.CPZ,520",1$0000F10F 0001 Funct Export -$LK +BI,"A2LTDate ","FL:::/LT/COMPILE/SPRINTF2.CPZ,585",2$0000F6E9 0001 Funct Export -$LK "ADAM_STARTUP_NAME ","FL:::/LT/COMPILE/COMPILE.CPZ,2633"$"/LT/OSM 0002 StrConst -$LK +BI,"AdamStartUpFile ","FL:::/LT/COMPILE/COMPILE.CPZ,2634",3$000369E6 0000 Funct Export -$LK +BI,"AddUnresolved ","FL:::/LT/COMPILE/ASM.CPZ,207",4$0001189D 0008 Funct Export -$LK +BI,"AsmCodeInstruction ","FL:::/LT/COMPILE/ASM.CPZ,888",5$0001550D 0001 Funct Export -$LK +BI,"AsmEvalExpression ","FL:::/LT/COMPILE/ASM.CPZ,309",6$00012047 0003 Funct Export -$LK +BI,"AsmListLine ","FL:::/LT/COMPILE/ASM.CPZ,235",7$00011A92 0002 Funct Export -$LK +BI,"AsmMakeArgMask ","FL:::/LT/COMPILE/ASM.CPZ,700",8$00014347 0002 Funct Export -$LK +BI,"AsmStoreCodeU1 ","FL:::/LT/COMPILE/ASM.CPZ,261",9$00011CA3 0020 Funct Export -$LK +BI,"AsmStoreCodeU1At ","FL:::/LT/COMPILE/ASM.CPZ,291",10$00011F1A 000D Funct Export -$LK +BI,"AsmStoreNum ","FL:::/LT/COMPILE/ASM.CPZ,776",11$0001494D 0004 Funct Export -$LK "CODE_TABLE ","FL:::/LT/COMPILE/CODE.ASZ,153"$000001A0 0001 SysSym Export -$LK "COMPILER_END ","FL:::/LT/COMPILE/CMP.ASZ,23"$00036B9D 0000 SysSym Export -$LK "COMPILER_START ","FL:::/LT/COMPILE/CMP.ASZ,6"$00000000 0000 SysSym Export -$LK "CP_OPTNEXT ","FL:::/LT/COMPILE/CODE.ASZ,62"$00000110 0001 SysSym Export -$LK "CP_PRSPOP ","FL:::/LT/COMPILE/CODE.ASZ,138"$00000188 0001 SysSym Export -$LK "CP_PRSPUSH ","FL:::/LT/COMPILE/CODE.ASZ,124"$00000170 0001 SysSym Export -$LK +BI,"CatchAll ","FL:::/LT/COMPILE/COMPILE.CPZ,376",12$0002AF16 0002 Funct Export -$LK +BI,"CbAddIc ","FL:::/LT/COMPILE/LEX.CPZ,1115",13$00007A3B 0083 Funct Export -$LK +BI,"CbAppend ","FL:::/LT/COMPILE/LEX.CPZ,1227",14$000081A5 0003 Funct Export -$LK +BI,"CbCombine ","FL:::/LT/COMPILE/LEX.CPZ,1247",15$0000829F 0001 Funct Export -$LK +BI,"CbCompile ","FL:::/LT/COMPILE/LEX.CPZ,1357",16$00008D02 0004 Funct Export -$LK +BI,"CbCountCode ","FL:::/LT/COMPILE/LEX.CPZ,1272",17$0000844C 0002 Funct Export -$LK +BI,"CbFindGotoLabel ","FL:::/LT/COMPILE/LEX.CPZ,1175",18$00007E3E 0002 Funct Export -$LK +BI,"CbGetIc1 ","FL:::/LT/COMPILE/LEX.CPZ,1142",19$00007C22 0003 Funct Export -$LK +BI,"CbInitInPtrs ","FL:::/LT/COMPILE/LEX.CPZ,1096",20$0000796C 0005 Funct Export -$LK +BI,"CbInitOutPtrs ","FL:::/LT/COMPILE/LEX.CPZ,1083",21$000078A4 0008 Funct Export -$LK +BI,"CbMiscNew ","FL:::/LT/COMPILE/LEX.CPZ,1188",22$00007ED1 0014 Funct Export -$LK +BI,"CbPop ","FL:::/LT/COMPILE/LEX.CPZ,1166",23$00007D96 0007 Funct Export -$LK +BI,"CbPopNoFree ","FL:::/LT/COMPILE/LEX.CPZ,1218",24$00008104 0001 Funct Export -$LK +BI,"CbPush ","FL:::/LT/COMPILE/LEX.CPZ,1157",25$00007CDF 000C Funct Export -$LK +BI,"CbPutAllIc ","FL:::/LT/COMPILE/LEX.CPZ,1104",26$000079CE 0005 Funct Export -$LK +BI,"CbPutClass ","FL:::/LT/COMPILE/LEX.CPZ,1032",27$0000752E 0001 Funct Export -$LK +BI,"CbPutIc ","FL:::/LT/COMPILE/LEX.CPZ,1057",28$000076A6 0003 Funct Export -$LK +BI,"CmpClassNew ","FL:::/LT/COMPILE/ASM.CPZ,2",29$000108C0 0003 Funct Export -$LK +BI,"CmpKeyWord ","FL:::/LT/COMPILE/COMPILE.CPZ,1",30$0002921C 0008 Funct Export -$LK +BI,"CmpOptPass1 ","FL:::/LT/COMPILE/OPT.CPZ,108",31$0001CD04 0000 Funct Export -$LK +BI,"CmpOptPass2 ","FL:::/LT/COMPILE/OPT.CPZ,1228",32$00021D80 0000 Funct Export -$LK +BI,"CmpOptPass3 ","FL:::/LT/COMPILE/OPT.CPZ,1750",33$00024542 0000 Funct Export -$LK +BI,"CmpOptPass4 ","FL:::/LT/COMPILE/OPT.CPZ,2526",34$000279BD 0000 Funct Export -$LK +BI,"CmpParseAsmBlk ","FL:::/LT/COMPILE/COMPILE.CPZ,1021",35$0002E906 0001 Funct Export -$LK +BI,"CmpParseClass ","FL:::/LT/COMPILE/COMPILE.CPZ,216",36$0002A3B1 0004 Funct Export -$LK +BI,"CmpParseCout ","FL:::/LT/COMPILE/COMPILE.CPZ,869",37$0002DBF9 0002 Funct Export -$LK +BI,"CmpParseDoWhile ","FL:::/LT/COMPILE/COMPILE.CPZ,719",38$0002CDCF 0001 Funct Export -$LK +BI,"CmpParseExeBlk ","FL:::/LT/COMPILE/COMPILE.CPZ,907",39$0002DF06 0001 Funct Export -$LK +BI,"CmpParseFor ","FL:::/LT/COMPILE/COMPILE.CPZ,741",40$0002CFEF 0001 Funct Export -$LK +BI,"CmpParseFunction ","FL:::/LT/COMPILE/COMPILE.CPZ,319",41$0002A9CC 0001 Funct Export -$LK +BI,"CmpParseFunctionJoin ","FL:::/LT/COMPILE/COMPILE.CPZ,247",42$0002A5B2 0005 Funct Export -$LK +BI,"CmpParseGlblVarList ","FL:::/LT/COMPILE/COMPILE.CPZ,491",43$0002BA54 0006 Funct Export -$LK +BI,"CmpParseIf ","FL:::/LT/COMPILE/COMPILE.CPZ,668",44$0002C94B 0001 Funct Export -$LK +BI,"CmpParseStatement ","FL:::/LT/COMPILE/COMPILE.CPZ,1295",45$0002FE59 0002 Funct Export -$LK +BI,"CmpParseSwitch ","FL:::/LT/COMPILE/COMPILE.CPZ,787",46$0002D363 0001 Funct Export -$LK +BI,"CmpParseTryBlk ","FL:::/LT/COMPILE/COMPILE.CPZ,966",47$0002E37D 0001 Funct Export -$LK +BI,"CmpParseVarList ","FL:::/LT/COMPILE/COMPILE.CPZ,16",48$000292B1 0004 Funct Export -$LK +BI,"CmpParseWhile ","FL:::/LT/COMPILE/COMPILE.CPZ,697",49$0002CBDB 0001 Funct Export -$LK +BI,"CompileBuf ","FL:::/LT/COMPILE/COMPILE.CPZ,1635",50$000318A7 0001 Funct Export -$LK +BI,"CompileExpression ","FL:::/LT/COMPILE/PARSE.CPZ,736",51$0001C4E9 0004 Funct Export -$LK +BI,"CompileFile ","FL:::/LT/COMPILE/COMPILE.CPZ,1731",52$00032037 0000 Funct Export -$LK +BI,"CompileStatement ","FL:::/LT/COMPILE/COMPILE.CPZ,1597",53$000315FC 0002 Funct Export -$LK +BI,"ContinueUserTask ","FL:::/LT/COMPILE/COMPILE.CPZ,1870",54$00032CB6 0000 Funct Export -$LK "DCT_ABSOLUTE_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,3351"$00001FE8 0001 SysSym -$LK "DCT_ADD32 ","FL:::/LT/COMPILE/CODE.ASZ,3322"$00001FE8 0001 SysSym -$LK "DCT_ADD64 ","FL:::/LT/COMPILE/CODE.ASZ,3321"$00001FE8 0001 SysSym -$LK "DCT_ADD8 ","FL:::/LT/COMPILE/CODE.ASZ,3323"$00001FE8 0001 SysSym -$LK "DCT_ADDITION ","FL:::/LT/COMPILE/CODE.ASZ,3248"$00001EE0 0001 SysSym -$LK "DCT_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,3165"$00001E04 0001 SysSym -$LK "DCT_ADD_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3296"$00001FD0 0001 SysSym -$LK "DCT_ADD_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3295"$00001FD0 0001 SysSym -$LK "DCT_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3294"$00001FD0 0001 SysSym -$LK "DCT_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3427"$00002100 0001 SysSym -$LK "DCT_ADD_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3293"$00001FB8 0001 SysSym -$LK "DCT_ADD_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3425"$00002100 0001 SysSym -$LK "DCT_ADD_ESP32 ","FL:::/LT/COMPILE/CODE.ASZ,3335"$00001FE8 0001 SysSym -$LK "DCT_ADD_ESP8 ","FL:::/LT/COMPILE/CODE.ASZ,3336"$00001FE8 0001 SysSym -$LK "DCT_AND ","FL:::/LT/COMPILE/CODE.ASZ,3245"$00001EE0 0001 SysSym -$LK "DCT_AND_AND ","FL:::/LT/COMPILE/CODE.ASZ,3256"$00001F88 0001 SysSym -$LK "DCT_AND_AND_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,3393"$00002100 0001 SysSym -$LK "DCT_AND_AND_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3394"$00002100 0001 SysSym -$LK "DCT_AND_AND_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3391"$00002100 0001 SysSym -$LK "DCT_AND_AND_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3392"$00002100 0001 SysSym -$LK "DCT_AND_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3284"$00001FB8 0001 SysSym -$LK "DCT_AND_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3283"$00001FB8 0001 SysSym -$LK "DCT_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3282"$00001FB8 0001 SysSym -$LK "DCT_AND_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3281"$00001FB8 0001 SysSym -$LK "DCT_ASSIGN_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3264"$00001F88 0001 SysSym -$LK "DCT_ASSIGN_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3263"$00001F88 0001 SysSym -$LK "DCT_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3262"$00001F88 0001 SysSym -$LK "DCT_ASSIGN_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3261"$00001F88 0001 SysSym -$LK "DCT_BSF ","FL:::/LT/COMPILE/CODE.ASZ,3358"$00001FE8 0001 SysSym -$LK "DCT_BSR ","FL:::/LT/COMPILE/CODE.ASZ,3359"$00001FE8 0001 SysSym -$LK "DCT_BT ","FL:::/LT/COMPILE/CODE.ASZ,3354"$00001FE8 0001 SysSym -$LK "DCT_BTC ","FL:::/LT/COMPILE/CODE.ASZ,3357"$00001FE8 0001 SysSym -$LK "DCT_BTC_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,3422"$00002100 0001 SysSym -$LK "DCT_BTR ","FL:::/LT/COMPILE/CODE.ASZ,3356"$00001FE8 0001 SysSym -$LK "DCT_BTR_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,3421"$00002100 0001 SysSym -$LK "DCT_BTS ","FL:::/LT/COMPILE/CODE.ASZ,3355"$00001FE8 0001 SysSym -$LK "DCT_BTS_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,3420"$00002100 0001 SysSym -$LK "DCT_BT_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,3419"$00002100 0001 SysSym -$LK "DCT_CALL ","FL:::/LT/COMPILE/CODE.ASZ,3338"$00001FE8 0001 SysSym -$LK "DCT_CALL_INDIRECT ","FL:::/LT/COMPILE/CODE.ASZ,3339"$00001FE8 0001 SysSym -$LK "DCT_CALL_INDIRECT2 ","FL:::/LT/COMPILE/CODE.ASZ,3340"$00001FE8 0001 SysSym -$LK "DCT_CLI ","FL:::/LT/COMPILE/CODE.ASZ,3342"$00001FE8 0001 SysSym -$LK "DCT_COLON ","FL:::/LT/COMPILE/CODE.ASZ,3259"$00001F88 0001 SysSym -$LK "DCT_COM ","FL:::/LT/COMPILE/CODE.ASZ,3162"$00001DF4 0001 SysSym -$LK "DCT_DEC ","FL:::/LT/COMPILE/CODE.ASZ,3328"$00001FE8 0001 SysSym -$LK "DCT_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3197"$00001E04 0001 SysSym -$LK "DCT_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3196"$00001E04 0001 SysSym -$LK "DCT_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3195"$00001E04 0001 SysSym -$LK "DCT_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3194"$00001E04 0001 SysSym -$LK "DCT_DIVISION ","FL:::/LT/COMPILE/CODE.ASZ,3243"$00001EA7 0001 SysSym -$LK "DCT_DIV_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3280"$00001FB8 0001 SysSym -$LK "DCT_DIV_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3279"$00001FB8 0001 SysSym -$LK "DCT_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3278"$00001FB8 0001 SysSym -$LK "DCT_DIV_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3277"$00001FA0 0001 SysSym -$LK "DCT_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,3154"$00001DF4 0001 SysSym -$LK "DCT_EBP ","FL:::/LT/COMPILE/CODE.ASZ,3156"$00001DF4 0001 SysSym -$LK "DCT_EDI ","FL:::/LT/COMPILE/CODE.ASZ,3159"$00001DF4 0001 SysSym -$LK "DCT_EDI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3319"$00001FE8 0001 SysSym -$LK "DCT_EDI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3429"$00002100 0001 SysSym -$LK "DCT_EDI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3316"$00001FE8 0001 SysSym -$LK "DCT_EDI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3311"$00001FE8 0001 SysSym -$LK "DCT_EDI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3205"$00001E04 0001 SysSym -$LK "DCT_EDI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3204"$00001E04 0001 SysSym -$LK "DCT_EDI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3203"$00001E04 0001 SysSym -$LK "DCT_EDI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3202"$00001E04 0001 SysSym -$LK "DCT_EDI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3315"$00001FE8 0001 SysSym -$LK "DCT_EDI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3229"$00001E3C 0001 SysSym -$LK "DCT_EDI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3314"$00001FE8 0001 SysSym -$LK "DCT_EDI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3424"$00002100 0001 SysSym -$LK "DCT_EDI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3317"$00001FE8 0001 SysSym -$LK "DCT_EDI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3228"$00001E3C 0001 SysSym -$LK "DCT_EDI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3312"$00001FE8 0001 SysSym -$LK "DCT_EDI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3313"$00001FE8 0001 SysSym -$LK "DCT_EDI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3320"$00001FE8 0001 SysSym -$LK "DCT_EDI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3189"$00001E04 0001 SysSym -$LK "DCT_EDI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3193"$00001E04 0001 SysSym -$LK "DCT_EDI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3188"$00001E04 0001 SysSym -$LK "DCT_EDI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3192"$00001E04 0001 SysSym -$LK "DCT_EDI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3187"$00001E04 0001 SysSym -$LK "DCT_EDI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3191"$00001E04 0001 SysSym -$LK "DCT_EDI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,3227"$00001E3C 0001 SysSym -$LK "DCT_EDI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,3226"$00001E3C 0001 SysSym -$LK "DCT_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3186"$00001E04 0001 SysSym -$LK "DCT_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3190"$00001E04 0001 SysSym -$LK "DCT_EDI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3318"$00001FE8 0001 SysSym -$LK "DCT_END_EXP ","FL:::/LT/COMPILE/CODE.ASZ,3148"$00001DF4 0001 SysSym -$LK "DCT_ENTER ","FL:::/LT/COMPILE/CODE.ASZ,3329"$00001FE8 0001 SysSym -$LK "DCT_ENTER1 ","FL:::/LT/COMPILE/CODE.ASZ,3331"$00001FE8 0001 SysSym -$LK "DCT_ENTER2 ","FL:::/LT/COMPILE/CODE.ASZ,3333"$00001FE8 0001 SysSym -$LK "DCT_EQUAL_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,3250"$00001F0C 0001 SysSym -$LK "DCT_EQUAL_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3379"$00001FE8 0001 SysSym -$LK "DCT_EQUAL_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3380"$00001FE8 0001 SysSym -$LK "DCT_ESI ","FL:::/LT/COMPILE/CODE.ASZ,3158"$00001DF4 0001 SysSym -$LK "DCT_ESI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3309"$00001FE8 0001 SysSym -$LK "DCT_ESI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3428"$00002100 0001 SysSym -$LK "DCT_ESI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3306"$00001FE8 0001 SysSym -$LK "DCT_ESI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3301"$00001FE8 0001 SysSym -$LK "DCT_ESI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3201"$00001E04 0001 SysSym -$LK "DCT_ESI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3200"$00001E04 0001 SysSym -$LK "DCT_ESI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3199"$00001E04 0001 SysSym -$LK "DCT_ESI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3198"$00001E04 0001 SysSym -$LK "DCT_ESI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3305"$00001FE8 0001 SysSym -$LK "DCT_ESI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3225"$00001E3C 0001 SysSym -$LK "DCT_ESI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3304"$00001FE8 0001 SysSym -$LK "DCT_ESI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3423"$00002100 0001 SysSym -$LK "DCT_ESI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3307"$00001FE8 0001 SysSym -$LK "DCT_ESI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3224"$00001E3C 0001 SysSym -$LK "DCT_ESI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3302"$00001FE8 0001 SysSym -$LK "DCT_ESI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3303"$00001FE8 0001 SysSym -$LK "DCT_ESI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3310"$00001FE8 0001 SysSym -$LK "DCT_ESI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3181"$00001E04 0001 SysSym -$LK "DCT_ESI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3185"$00001E04 0001 SysSym -$LK "DCT_ESI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3180"$00001E04 0001 SysSym -$LK "DCT_ESI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3184"$00001E04 0001 SysSym -$LK "DCT_ESI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3179"$00001E04 0001 SysSym -$LK "DCT_ESI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3183"$00001E04 0001 SysSym -$LK "DCT_ESI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,3223"$00001E3C 0001 SysSym -$LK "DCT_ESI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,3222"$00001E3C 0001 SysSym -$LK "DCT_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3178"$00001E04 0001 SysSym -$LK "DCT_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3182"$00001E04 0001 SysSym -$LK "DCT_ESI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3308"$00001FE8 0001 SysSym -$LK "DCT_FS ","FL:::/LT/COMPILE/CODE.ASZ,3157"$00001DF4 0001 SysSym -$LK "DCT_FS_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3177"$00001E04 0001 SysSym -$LK "DCT_FS_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3176"$00001E04 0001 SysSym -$LK "DCT_FS_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3175"$00001E04 0001 SysSym -$LK "DCT_FS_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3174"$00001E04 0001 SysSym -$LK "DCT_GET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,3346"$00001FE8 0001 SysSym -$LK "DCT_GET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,3344"$00001FE8 0001 SysSym -$LK "DCT_GET_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,3350"$00001FE8 0001 SysSym -$LK "DCT_GET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,3348"$00001FE8 0001 SysSym -$LK "DCT_GREATER_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,3255"$00001F69 0001 SysSym -$LK "DCT_GREATER_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3389"$000020BA 0002 SysSym -$LK "DCT_GREATER_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3390"$000020DB 0001 SysSym -$LK "DCT_GREATER_THAN ","FL:::/LT/COMPILE/CODE.ASZ,3253"$00001F2B 0001 SysSym -$LK "DCT_GREATER_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3385"$0000202E 0002 SysSym -$LK "DCT_GREATER_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3386"$0000204F 0001 SysSym -$LK "DCT_INC ","FL:::/LT/COMPILE/CODE.ASZ,3324"$00001FE8 0001 SysSym -$LK "DCT_INP ","FL:::/LT/COMPILE/CODE.ASZ,3368"$00001FE8 0001 SysSym -$LK "DCT_INPD ","FL:::/LT/COMPILE/CODE.ASZ,3366"$00001FE8 0001 SysSym -$LK "DCT_INPW ","FL:::/LT/COMPILE/CODE.ASZ,3367"$00001FE8 0001 SysSym -$LK "DCT_INSQUE ","FL:::/LT/COMPILE/CODE.ASZ,3360"$00001FE8 0001 SysSym -$LK "DCT_INSQUE_REV ","FL:::/LT/COMPILE/CODE.ASZ,3361"$00001FE8 0001 SysSym -$LK "DCT_IRQ ","FL:::/LT/COMPILE/CODE.ASZ,3341"$00001FE8 0001 SysSym -$LK "DCT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,3372"$00001FE8 0001 SysSym -$LK "DCT_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,3352"$00001FE8 0001 SysSym -$LK "DCT_LEAVE ","FL:::/LT/COMPILE/CODE.ASZ,3330"$00001FE8 0001 SysSym -$LK "DCT_LEAVE1 ","FL:::/LT/COMPILE/CODE.ASZ,3332"$00001FE8 0001 SysSym -$LK "DCT_LEAVE2 ","FL:::/LT/COMPILE/CODE.ASZ,3334"$00001FE8 0001 SysSym -$LK "DCT_LEA_DISP32_EBP ","FL:::/LT/COMPILE/CODE.ASZ,3230"$00001E3C 0001 SysSym -$LK "DCT_LEA_DISP32_EDI ","FL:::/LT/COMPILE/CODE.ASZ,3401"$00002100 0001 SysSym -$LK "DCT_LEA_DISP32_ESI ","FL:::/LT/COMPILE/CODE.ASZ,3399"$00002100 0001 SysSym -$LK "DCT_LEA_DISP8_EBP ","FL:::/LT/COMPILE/CODE.ASZ,3231"$00001E3C 0001 SysSym -$LK "DCT_LEA_DISP8_EDI ","FL:::/LT/COMPILE/CODE.ASZ,3402"$00002100 0001 SysSym -$LK "DCT_LEA_DISP8_ESI ","FL:::/LT/COMPILE/CODE.ASZ,3400"$00002100 0001 SysSym -$LK "DCT_LESS_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,3254"$00001F4A 0001 SysSym -$LK "DCT_LESS_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3387"$00002074 0002 SysSym -$LK "DCT_LESS_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3388"$00002095 0001 SysSym -$LK "DCT_LESS_THAN ","FL:::/LT/COMPILE/CODE.ASZ,3252"$00001F0C 0001 SysSym -$LK "DCT_LESS_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3383"$00001FE8 0002 SysSym -$LK "DCT_LESS_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3384"$00002009 0001 SysSym -$LK "DCT_MEMCPY ","FL:::/LT/COMPILE/CODE.ASZ,3364"$00001FE8 0001 SysSym -$LK "DCT_MEMSET ","FL:::/LT/COMPILE/CODE.ASZ,3365"$00001FE8 0001 SysSym -$LK "DCT_MM_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3221"$00001E3C 0001 SysSym -$LK "DCT_MM_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3220"$00001E3C 0001 SysSym -$LK "DCT_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3219"$00001E3C 0001 SysSym -$LK "DCT_MM_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3218"$00001E2F 0001 SysSym -$LK "DCT_MULTIPLICATION ","FL:::/LT/COMPILE/CODE.ASZ,3242"$00001E91 0001 SysSym -$LK "DCT_MUL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3276"$00001FA0 0001 SysSym -$LK "DCT_MUL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3275"$00001FA0 0001 SysSym -$LK "DCT_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3274"$00001FA0 0001 SysSym -$LK "DCT_MUL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3273"$00001F88 0001 SysSym -$LK "DCT_NOP ","FL:::/LT/COMPILE/CODE.ASZ,3147"$00001DF4 0001 SysSym -$LK "DCT_NOT ","FL:::/LT/COMPILE/CODE.ASZ,3163"$00001DF4 0001 SysSym -$LK "DCT_NOT_EQUAL_TO ","FL:::/LT/COMPILE/CODE.ASZ,3251"$00001F0C 0001 SysSym -$LK "DCT_NOT_EQUAL_TO_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3381"$00001FE8 0001 SysSym -$LK "DCT_NOT_EQUAL_TO_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3382"$00001FE8 0001 SysSym -$LK "DCT_NULL ","FL:::/LT/COMPILE/CODE.ASZ,3146"$00001DF4 0001 SysSym -$LK "DCT_OR ","FL:::/LT/COMPILE/CODE.ASZ,3246"$00001EE0 0001 SysSym -$LK "DCT_OR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3288"$00001FB8 0001 SysSym -$LK "DCT_OR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3287"$00001FB8 0001 SysSym -$LK "DCT_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3286"$00001FB8 0001 SysSym -$LK "DCT_OR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3285"$00001FB8 0001 SysSym -$LK "DCT_OR_OR ","FL:::/LT/COMPILE/CODE.ASZ,3257"$00001F88 0001 SysSym -$LK "DCT_OR_OR_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,3397"$00002100 0001 SysSym -$LK "DCT_OR_OR_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3398"$00002100 0001 SysSym -$LK "DCT_OR_OR_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3395"$00002100 0001 SysSym -$LK "DCT_OR_OR_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3396"$00002100 0001 SysSym -$LK "DCT_OUTP ","FL:::/LT/COMPILE/CODE.ASZ,3371"$00001FE8 0001 SysSym -$LK "DCT_OUTPD ","FL:::/LT/COMPILE/CODE.ASZ,3369"$00001FE8 0001 SysSym -$LK "DCT_OUTPW ","FL:::/LT/COMPILE/CODE.ASZ,3370"$00001FE8 0001 SysSym -$LK "DCT_POWER ","FL:::/LT/COMPILE/CODE.ASZ,3241"$00001E3C 0001 SysSym -$LK "DCT_PP_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3217"$00001E2F 0001 SysSym -$LK "DCT_PP_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3216"$00001E2F 0001 SysSym -$LK "DCT_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3215"$00001E2F 0001 SysSym -$LK "DCT_PP_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3214"$00001E22 0001 SysSym -$LK "DCT_PUSH_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3417"$00002100 0001 SysSym -$LK "DCT_PUSH_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,3410"$00002100 0001 SysSym -$LK "DCT_PUSH_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3415"$00002100 0001 SysSym -$LK "DCT_PUSH_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3416"$00002100 0001 SysSym -$LK "DCT_PUSH_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3413"$00002100 0001 SysSym -$LK "DCT_PUSH_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3414"$00002100 0001 SysSym -$LK "DCT_PUSH_NEG_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3409"$00002100 0001 SysSym -$LK "DCT_PUSH_NEG_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3408"$00002100 0001 SysSym -$LK "DCT_PUSH_NEG_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3407"$00002100 0001 SysSym -$LK "DCT_PUSH_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3406"$00002100 0001 SysSym -$LK "DCT_PUSH_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3405"$00002100 0001 SysSym -$LK "DCT_PUSH_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3404"$00002100 0001 SysSym -$LK "DCT_PUSH_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3403"$00002100 0001 SysSym -$LK "DCT_PUSH_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3411"$00002100 0001 SysSym -$LK "DCT_PUSH_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,3418"$00002100 0001 SysSym -$LK "DCT_PUSH_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3412"$00002100 0001 SysSym -$LK "DCT_QUESTION ","FL:::/LT/COMPILE/CODE.ASZ,3260"$00001F88 0001 SysSym -$LK "DCT_REMAINDER ","FL:::/LT/COMPILE/CODE.ASZ,3244"$00001EBD 0001 SysSym -$LK "DCT_REMQUE ","FL:::/LT/COMPILE/CODE.ASZ,3362"$00001FE8 0001 SysSym -$LK "DCT_RET ","FL:::/LT/COMPILE/CODE.ASZ,3337"$00001FE8 0001 SysSym -$LK "DCT_SET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,3347"$00001FE8 0001 SysSym -$LK "DCT_SET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,3345"$00001FE8 0001 SysSym -$LK "DCT_SET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,3349"$00001FE8 0001 SysSym -$LK "DCT_SHL ","FL:::/LT/COMPILE/CODE.ASZ,3235"$00001E3C 0001 SysSym -$LK "DCT_SHL_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,3237"$00001E3C 0001 SysSym -$LK "DCT_SHL_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,3238"$00001E3C 0001 SysSym -$LK "DCT_SHL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3268"$00001F88 0001 SysSym -$LK "DCT_SHL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3267"$00001F88 0001 SysSym -$LK "DCT_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3266"$00001F88 0001 SysSym -$LK "DCT_SHL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3265"$00001F88 0001 SysSym -$LK "DCT_SHORT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,3373"$00001FE8 0001 SysSym -$LK "DCT_SHR ","FL:::/LT/COMPILE/CODE.ASZ,3236"$00001E3C 0001 SysSym -$LK "DCT_SHR_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,3239"$00001E3C 0001 SysSym -$LK "DCT_SHR_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,3240"$00001E3C 0001 SysSym -$LK "DCT_SHR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3272"$00001F88 0001 SysSym -$LK "DCT_SHR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3271"$00001F88 0001 SysSym -$LK "DCT_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3270"$00001F88 0001 SysSym -$LK "DCT_SHR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3269"$00001F88 0001 SysSym -$LK "DCT_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,3377"$00001FE8 0001 SysSym -$LK "DCT_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3378"$00001FE8 0001 SysSym -$LK "DCT_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,3375"$00001FE8 0001 SysSym -$LK "DCT_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,3376"$00001FE8 0001 SysSym -$LK "DCT_STI ","FL:::/LT/COMPILE/CODE.ASZ,3343"$00001FE8 0001 SysSym -$LK "DCT_STRING_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,3155"$00001DF4 0001 SysSym -$LK "DCT_STRLEN ","FL:::/LT/COMPILE/CODE.ASZ,3363"$00001FE8 0001 SysSym -$LK "DCT_SUB32 ","FL:::/LT/COMPILE/CODE.ASZ,3326"$00001FE8 0001 SysSym -$LK "DCT_SUB64 ","FL:::/LT/COMPILE/CODE.ASZ,3325"$00001FE8 0001 SysSym -$LK "DCT_SUB8 ","FL:::/LT/COMPILE/CODE.ASZ,3327"$00001FE8 0001 SysSym -$LK "DCT_SUBTRACTION ","FL:::/LT/COMPILE/CODE.ASZ,3249"$00001EF6 0001 SysSym -$LK "DCT_SUB_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3300"$00001FE8 0001 SysSym -$LK "DCT_SUB_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3299"$00001FE8 0001 SysSym -$LK "DCT_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3298"$00001FE8 0001 SysSym -$LK "DCT_SUB_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3297"$00001FD0 0001 SysSym -$LK "DCT_SUB_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3426"$00002100 0001 SysSym -$LK "DCT_SWITCH ","FL:::/LT/COMPILE/CODE.ASZ,3374"$00001FE8 0001 SysSym -$LK "DCT_TABLE_END ","FL:::/LT/COMPILE/CODE.ASZ,3430"$00002100 0001 SysSym -$LK "DCT_TO_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,3160"$00001DF4 0001 SysSym -$LK "DCT_TO_INT ","FL:::/LT/COMPILE/CODE.ASZ,3161"$00001DF4 0001 SysSym -$LK "DCT_TYPE ","FL:::/LT/COMPILE/CODE.ASZ,3353"$00001FE8 0001 SysSym -$LK "DCT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3153"$00001DF4 0001 SysSym -$LK "DCT_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3169"$00001E04 0001 SysSym -$LK "DCT_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3173"$00001E04 0001 SysSym -$LK "DCT_U1_MM ","FL:::/LT/COMPILE/CODE.ASZ,3213"$00001E22 0001 SysSym -$LK "DCT_U1_PP ","FL:::/LT/COMPILE/CODE.ASZ,3209"$00001E13 0001 SysSym -$LK "DCT_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3152"$00001DF4 0001 SysSym -$LK "DCT_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3168"$00001E04 0001 SysSym -$LK "DCT_U2_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,3234"$00001E3C 0001 SysSym -$LK "DCT_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3172"$00001E04 0001 SysSym -$LK "DCT_U2_MM ","FL:::/LT/COMPILE/CODE.ASZ,3212"$00001E22 0001 SysSym -$LK "DCT_U2_PP ","FL:::/LT/COMPILE/CODE.ASZ,3208"$00001E13 0001 SysSym -$LK "DCT_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3151"$00001DF4 0001 SysSym -$LK "DCT_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3167"$00001E04 0001 SysSym -$LK "DCT_U4_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,3233"$00001E3C 0001 SysSym -$LK "DCT_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3171"$00001E04 0001 SysSym -$LK "DCT_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,3211"$00001E22 0001 SysSym -$LK "DCT_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,3207"$00001E13 0001 SysSym -$LK "DCT_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3150"$00001DF4 0001 SysSym -$LK "DCT_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,3166"$00001E04 0001 SysSym -$LK "DCT_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,3232"$00001E3C 0001 SysSym -$LK "DCT_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,3170"$00001E04 0001 SysSym -$LK "DCT_U8_MM ","FL:::/LT/COMPILE/CODE.ASZ,3210"$00001E13 0001 SysSym -$LK "DCT_U8_PP ","FL:::/LT/COMPILE/CODE.ASZ,3206"$00001E04 0001 SysSym -$LK "DCT_UNARY_MINUS ","FL:::/LT/COMPILE/CODE.ASZ,3164"$00001DF4 0001 SysSym -$LK "DCT_XOR ","FL:::/LT/COMPILE/CODE.ASZ,3247"$00001EE0 0001 SysSym -$LK "DCT_XOR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,3292"$00001FB8 0001 SysSym -$LK "DCT_XOR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,3291"$00001FB8 0001 SysSym -$LK "DCT_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,3290"$00001FB8 0001 SysSym -$LK "DCT_XOR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,3289"$00001FB8 0001 SysSym -$LK "DCT_XOR_XOR ","FL:::/LT/COMPILE/CODE.ASZ,3258"$00001F88 0001 SysSym -$LK "DCT_ZERO ","FL:::/LT/COMPILE/CODE.ASZ,3149"$00001DF4 0001 SysSym -$LK "DOUBLE_CODE_TABLE ","FL:::/LT/COMPILE/CODE.ASZ,3145"$00001980 0001 SysSym Export -$LK +BI,"DefineU1s ","FL:::/LT/COMPILE/ASM.CPZ,1327",55$000180F5 0004 Funct Export -$LK +BI,"DelCbMiscList ","FL:::/LT/COMPILE/LEX.CPZ,1199",56$00007F76 0001 Funct Export -$LK +BI,"DelExpression ","FL:::/LT/COMPILE/LEX.CPZ,336",57$00003B6F 0009 Funct Export -$LK +BI,"DelHashTable ","FL:::/LT/COMPILE/LEX.CPZ,1651",58$0000A694 0003 Funct Export -$LK +BI,"DelMemberList ","FL:::/LT/COMPILE/LEX.CPZ,478",59$000043A3 0002 Funct Export -$LK +BI,"EvalExpression ","FL:::/LT/COMPILE/LEX.CPZ,342",60$00003BA0 0000 Funct Export -$LK +BI,"ExePrintF ","FL:::/LT/COMPILE/COMPILE.CPZ,959",61$0002E313 0000 Funct Export -$LK +BI,"ExePutS ","FL:::/LT/COMPILE/COMPILE.CPZ,949",62$0002E26C 0001 Funct Export -$LK +BI,"ExecuteCmdLine ","FL:::/LT/COMPILE/COMPILE.CPZ,1818",63$00032790 0003 Funct Export -$LK +BI,"ExecuteFile ","FL:::/LT/COMPILE/COMPILE.CPZ,1914",64$00032F5B 0001 Funct Export -$LK +BI,"ExecuteString ","FL:::/LT/COMPILE/COMPILE.CPZ,1887",65$00032D85 0002 Funct Export -$LK +BI,"Expression ","FL:::/LT/COMPILE/PARSE.CPZ,763",66$0001C66B 0003 Funct Export -$LK "FAR_AWAY ","FL:::/LT/COMPILE/CODE.ASZ,2"$00000000 0015 SysSym -$LK "FUT_32_4 ","FL:::/LT/COMPILE/LEX.CPZ,41"$8 001A StrConst -$LK "FUT_32_4P10_4 ","FL:::/LT/COMPILE/LEX.CPZ,55"$22 0002 StrConst -$LK "FUT_32_4P11_4 ","FL:::/LT/COMPILE/LEX.CPZ,50"$17 0001 StrConst -$LK "FUT_32_4_ABS ","FL:::/LT/COMPILE/LEX.CPZ,43"$10 0004 StrConst -$LK "FUT_32_4_ABS2 ","FL:::/LT/COMPILE/LEX.CPZ,44"$11 0006 StrConst -$LK "FUT_32_4_CALL ","FL:::/LT/COMPILE/LEX.CPZ,42"$9 0002 StrConst -$LK "FUT_32_4_ENTER ","FL:::/LT/COMPILE/LEX.CPZ,49"$16 0000 StrConst -$LK "FUT_32_5 ","FL:::/LT/COMPILE/LEX.CPZ,45"$12 0010 StrConst -$LK "FUT_32_6 ","FL:::/LT/COMPILE/LEX.CPZ,46"$13 0006 StrConst -$LK "FUT_32_7 ","FL:::/LT/COMPILE/LEX.CPZ,47"$14 0003 StrConst -$LK "FUT_32_9 ","FL:::/LT/COMPILE/LEX.CPZ,48"$15 0009 StrConst -$LK "FUT_32_JMP_4 ","FL:::/LT/COMPILE/LEX.CPZ,51"$18 001E StrConst -$LK "FUT_64_H9_L4 ","FL:::/LT/COMPILE/LEX.CPZ,52"$19 0005 StrConst -$LK "FUT_8_1 ","FL:::/LT/COMPILE/LEX.CPZ,34"$1 0013 StrConst -$LK "FUT_8_10 ","FL:::/LT/COMPILE/LEX.CPZ,39"$6 0003 StrConst -$LK "FUT_8_2 ","FL:::/LT/COMPILE/LEX.CPZ,35"$2 000A StrConst -$LK "FUT_8_4 ","FL:::/LT/COMPILE/LEX.CPZ,36"$3 0007 StrConst -$LK "FUT_8_5 ","FL:::/LT/COMPILE/LEX.CPZ,37"$4 0006 StrConst -$LK "FUT_8_6 ","FL:::/LT/COMPILE/LEX.CPZ,38"$5 000E StrConst -$LK "FUT_8_JMP_1 ","FL:::/LT/COMPILE/LEX.CPZ,40"$7 001F StrConst -$LK "FUT_ENTER1 ","FL:::/LT/COMPILE/LEX.CPZ,53"$20 0002 StrConst -$LK "FUT_ENTER2 ","FL:::/LT/COMPILE/LEX.CPZ,54"$21 0002 StrConst -$LK "FUT_NULL ","FL:::/LT/COMPILE/LEX.CPZ,33"$0 0000 StrConst -$LK +BI,"FillCompilerTables ","FL:::/LT/COMPILE/COMPILE.CPZ,2294",67$00034FFC 0001 Funct Export -$LK +BI,"FindMember ","FL:::/LT/COMPILE/LEX.CPZ,465",68$0000431E 0003 Funct Export -$LK +BI,"FixupBinaryOp1 ","FL:::/LT/COMPILE/OPT.CPZ,1",69$0001C6FC 0013 Funct Export -$LK +BI,"FixupBinaryOp2 ","FL:::/LT/COMPILE/OPT.CPZ,21",70$0001C899 0001 Funct Export -$LK +BI,"FixupBinaryOp3 ","FL:::/LT/COMPILE/OPT.CPZ,37",71$0001C9AC 0004 Funct Export -$LK +BI,"GetExpression ","FL:::/LT/COMPILE/PARSE.CPZ,754",72$0001C602 0000 Funct Export -$LK +BI,"GetFJoin2 ","FL:::/LT/COMPILE/SPRINTF2.CPZ,649",73$0000FD2D 0001 Funct Export -$LK "ICT_ABSOLUTE_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,359"$000009BC 0001 SysSym -$LK "ICT_ADD32 ","FL:::/LT/COMPILE/CODE.ASZ,330"$000009BC 0001 SysSym -$LK "ICT_ADD64 ","FL:::/LT/COMPILE/CODE.ASZ,329"$000009BC 0001 SysSym -$LK "ICT_ADD8 ","FL:::/LT/COMPILE/CODE.ASZ,331"$000009BC 0001 SysSym -$LK "ICT_ADDITION ","FL:::/LT/COMPILE/CODE.ASZ,256"$000007E7 0001 SysSym -$LK "ICT_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,173"$00000626 0001 SysSym -$LK "ICT_ADD_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,304"$00000922 0001 SysSym -$LK "ICT_ADD_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,303"$00000917 0001 SysSym -$LK "ICT_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,302"$0000090E 0001 SysSym -$LK "ICT_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,435"$00000A1A 0001 SysSym -$LK "ICT_ADD_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,301"$0000090E 0001 SysSym -$LK "ICT_ADD_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,433"$00000A1A 0001 SysSym -$LK "ICT_ADD_ESP32 ","FL:::/LT/COMPILE/CODE.ASZ,343"$000009BC 0001 SysSym -$LK "ICT_ADD_ESP8 ","FL:::/LT/COMPILE/CODE.ASZ,344"$000009BC 0001 SysSym -$LK "ICT_AND ","FL:::/LT/COMPILE/CODE.ASZ,253"$000007E7 0001 SysSym -$LK "ICT_AND_AND ","FL:::/LT/COMPILE/CODE.ASZ,264"$00000827 0001 SysSym -$LK "ICT_AND_AND_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,401"$00000A0C 0001 SysSym -$LK "ICT_AND_AND_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,402"$00000A0C 0001 SysSym -$LK "ICT_AND_AND_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,399"$00000A0C 0001 SysSym -$LK "ICT_AND_AND_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,400"$00000A0C 0001 SysSym -$LK "ICT_AND_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,292"$0000090E 0001 SysSym -$LK "ICT_AND_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,291"$0000090E 0001 SysSym -$LK "ICT_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,290"$0000090E 0001 SysSym -$LK "ICT_AND_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,289"$0000090E 0001 SysSym -$LK "ICT_ASSIGN_U1 ","FL:::/LT/COMPILE/CODE.ASZ,272"$00000827 0001 SysSym -$LK "ICT_ASSIGN_U2 ","FL:::/LT/COMPILE/CODE.ASZ,271"$00000827 0001 SysSym -$LK "ICT_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,270"$00000827 0001 SysSym -$LK "ICT_ASSIGN_U8 ","FL:::/LT/COMPILE/CODE.ASZ,269"$00000827 0001 SysSym -$LK "ICT_BSF ","FL:::/LT/COMPILE/CODE.ASZ,366"$000009BC 0001 SysSym -$LK "ICT_BSR ","FL:::/LT/COMPILE/CODE.ASZ,367"$000009BC 0001 SysSym -$LK "ICT_BT ","FL:::/LT/COMPILE/CODE.ASZ,362"$000009BC 0001 SysSym -$LK "ICT_BTC ","FL:::/LT/COMPILE/CODE.ASZ,365"$000009BC 0001 SysSym -$LK "ICT_BTC_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,430"$00000A0C 0001 SysSym -$LK "ICT_BTR ","FL:::/LT/COMPILE/CODE.ASZ,364"$000009BC 0001 SysSym -$LK "ICT_BTR_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,429"$00000A0C 0001 SysSym -$LK "ICT_BTS ","FL:::/LT/COMPILE/CODE.ASZ,363"$000009BC 0001 SysSym -$LK "ICT_BTS_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,428"$00000A0C 0001 SysSym -$LK "ICT_BT_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,427"$00000A0C 0001 SysSym -$LK "ICT_CALL ","FL:::/LT/COMPILE/CODE.ASZ,346"$000009BC 0001 SysSym -$LK "ICT_CALL_INDIRECT ","FL:::/LT/COMPILE/CODE.ASZ,347"$000009BC 0001 SysSym -$LK "ICT_CALL_INDIRECT2 ","FL:::/LT/COMPILE/CODE.ASZ,348"$000009BC 0001 SysSym -$LK "ICT_CLI ","FL:::/LT/COMPILE/CODE.ASZ,350"$000009BC 0001 SysSym -$LK "ICT_COLON ","FL:::/LT/COMPILE/CODE.ASZ,267"$00000827 0001 SysSym -$LK "ICT_COM ","FL:::/LT/COMPILE/CODE.ASZ,170"$00000626 0001 SysSym -$LK "ICT_DEC ","FL:::/LT/COMPILE/CODE.ASZ,336"$000009BC 0001 SysSym -$LK "ICT_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,205"$000006DF 0001 SysSym -$LK "ICT_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,204"$000006DB 0001 SysSym -$LK "ICT_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,203"$000006D8 0001 SysSym -$LK "ICT_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,202"$000006D8 0001 SysSym -$LK "ICT_DIVISION ","FL:::/LT/COMPILE/CODE.ASZ,251"$000007D7 0001 SysSym -$LK "ICT_DIV_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,288"$000008FC 0001 SysSym -$LK "ICT_DIV_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,287"$000008E9 0001 SysSym -$LK "ICT_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,286"$000008DB 0001 SysSym -$LK "ICT_DIV_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,285"$000008C8 0001 SysSym -$LK "ICT_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,162"$0000061C 0001 SysSym -$LK "ICT_EBP ","FL:::/LT/COMPILE/CODE.ASZ,164"$0000061C 0001 SysSym -$LK "ICT_EDI ","FL:::/LT/COMPILE/CODE.ASZ,167"$00000621 0001 SysSym -$LK "ICT_EDI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,327"$000009B2 0001 SysSym -$LK "ICT_EDI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,437"$00000A28 0001 SysSym -$LK "ICT_EDI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,324"$000009A3 0001 SysSym -$LK "ICT_EDI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,319"$00000983 0001 SysSym -$LK "ICT_EDI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,213"$000006FF 0001 SysSym -$LK "ICT_EDI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,212"$000006F9 0001 SysSym -$LK "ICT_EDI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,211"$000006F4 0001 SysSym -$LK "ICT_EDI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,210"$000006F4 0001 SysSym -$LK "ICT_EDI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,323"$00000998 0001 SysSym -$LK "ICT_EDI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,237"$00000783 0001 SysSym -$LK "ICT_EDI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,322"$00000991 0001 SysSym -$LK "ICT_EDI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,432"$00000A13 0001 SysSym -$LK "ICT_EDI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,325"$000009A8 0001 SysSym -$LK "ICT_EDI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,236"$0000077D 0001 SysSym -$LK "ICT_EDI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,320"$00000983 0001 SysSym -$LK "ICT_EDI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,321"$0000098A 0001 SysSym -$LK "ICT_EDI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,328"$000009B7 0001 SysSym -$LK "ICT_EDI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,197"$000006BA 0001 SysSym -$LK "ICT_EDI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,201"$000006D1 0001 SysSym -$LK "ICT_EDI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,196"$000006B0 0001 SysSym -$LK "ICT_EDI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,200"$000006CA 0001 SysSym -$LK "ICT_EDI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,195"$000006A7 0001 SysSym -$LK "ICT_EDI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,199"$000006C4 0001 SysSym -$LK "ICT_EDI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,235"$00000777 0001 SysSym -$LK "ICT_EDI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,234"$00000771 0001 SysSym -$LK "ICT_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,194"$000006A7 0001 SysSym -$LK "ICT_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,198"$000006C4 0001 SysSym -$LK "ICT_EDI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,326"$000009AD 0001 SysSym -$LK "ICT_END_EXP ","FL:::/LT/COMPILE/CODE.ASZ,156"$00000614 0001 SysSym -$LK "ICT_ENTER ","FL:::/LT/COMPILE/CODE.ASZ,337"$000009BC 0001 SysSym -$LK "ICT_ENTER1 ","FL:::/LT/COMPILE/CODE.ASZ,339"$000009BC 0001 SysSym -$LK "ICT_ENTER2 ","FL:::/LT/COMPILE/CODE.ASZ,341"$000009BC 0001 SysSym -$LK "ICT_EQUAL_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,258"$000007E7 0001 SysSym -$LK "ICT_EQUAL_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,387"$000009BC 0001 SysSym -$LK "ICT_EQUAL_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,388"$000009BC 0001 SysSym -$LK "ICT_ESI ","FL:::/LT/COMPILE/CODE.ASZ,166"$0000061C 0001 SysSym -$LK "ICT_ESI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,317"$00000979 0001 SysSym -$LK "ICT_ESI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,436"$00000A20 0001 SysSym -$LK "ICT_ESI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,314"$0000096A 0001 SysSym -$LK "ICT_ESI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,309"$0000094A 0001 SysSym -$LK "ICT_ESI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,209"$000006EE 0001 SysSym -$LK "ICT_ESI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,208"$000006E8 0001 SysSym -$LK "ICT_ESI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,207"$000006E3 0001 SysSym -$LK "ICT_ESI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,206"$000006E3 0001 SysSym -$LK "ICT_ESI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,313"$0000095F 0001 SysSym -$LK "ICT_ESI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,233"$0000076B 0001 SysSym -$LK "ICT_ESI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,312"$00000958 0001 SysSym -$LK "ICT_ESI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,431"$00000A0C 0001 SysSym -$LK "ICT_ESI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,315"$0000096F 0001 SysSym -$LK "ICT_ESI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,232"$00000765 0001 SysSym -$LK "ICT_ESI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,310"$0000094A 0001 SysSym -$LK "ICT_ESI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,311"$00000951 0001 SysSym -$LK "ICT_ESI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,318"$0000097E 0001 SysSym -$LK "ICT_ESI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,189"$00000689 0001 SysSym -$LK "ICT_ESI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,193"$000006A0 0001 SysSym -$LK "ICT_ESI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,188"$0000067F 0001 SysSym -$LK "ICT_ESI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,192"$00000699 0001 SysSym -$LK "ICT_ESI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,187"$00000676 0001 SysSym -$LK "ICT_ESI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,191"$00000693 0001 SysSym -$LK "ICT_ESI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,231"$0000075F 0001 SysSym -$LK "ICT_ESI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,230"$00000759 0001 SysSym -$LK "ICT_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,186"$00000676 0001 SysSym -$LK "ICT_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,190"$00000693 0001 SysSym -$LK "ICT_ESI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,316"$00000974 0001 SysSym -$LK "ICT_FS ","FL:::/LT/COMPILE/CODE.ASZ,165"$0000061C 0001 SysSym -$LK "ICT_FS_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,185"$0000066B 0001 SysSym -$LK "ICT_FS_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,184"$00000660 0001 SysSym -$LK "ICT_FS_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,183"$00000657 0001 SysSym -$LK "ICT_FS_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,182"$00000657 0001 SysSym -$LK "ICT_GET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,354"$000009BC 0001 SysSym -$LK "ICT_GET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,352"$000009BC 0001 SysSym -$LK "ICT_GET_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,358"$000009BC 0001 SysSym -$LK "ICT_GET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,356"$000009BC 0001 SysSym -$LK "ICT_GREATER_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,263"$00000817 0001 SysSym -$LK "ICT_GREATER_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,397"$000009F8 0002 SysSym -$LK "ICT_GREATER_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,398"$00000A00 0001 SysSym -$LK "ICT_GREATER_THAN ","FL:::/LT/COMPILE/CODE.ASZ,261"$000007F7 0001 SysSym -$LK "ICT_GREATER_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,393"$000009D0 0002 SysSym -$LK "ICT_GREATER_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,394"$000009D8 0001 SysSym -$LK "ICT_INC ","FL:::/LT/COMPILE/CODE.ASZ,332"$000009BC 0001 SysSym -$LK "ICT_INP ","FL:::/LT/COMPILE/CODE.ASZ,376"$000009BC 0001 SysSym -$LK "ICT_INPD ","FL:::/LT/COMPILE/CODE.ASZ,374"$000009BC 0001 SysSym -$LK "ICT_INPW ","FL:::/LT/COMPILE/CODE.ASZ,375"$000009BC 0001 SysSym -$LK "ICT_INSQUE ","FL:::/LT/COMPILE/CODE.ASZ,368"$000009BC 0001 SysSym -$LK "ICT_INSQUE_REV ","FL:::/LT/COMPILE/CODE.ASZ,369"$000009BC 0001 SysSym -$LK "ICT_IRQ ","FL:::/LT/COMPILE/CODE.ASZ,349"$000009BC 0001 SysSym -$LK "ICT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,380"$000009BC 0001 SysSym -$LK "ICT_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,360"$000009BC 0001 SysSym -$LK "ICT_LEAVE ","FL:::/LT/COMPILE/CODE.ASZ,338"$000009BC 0001 SysSym -$LK "ICT_LEAVE1 ","FL:::/LT/COMPILE/CODE.ASZ,340"$000009BC 0001 SysSym -$LK "ICT_LEAVE2 ","FL:::/LT/COMPILE/CODE.ASZ,342"$000009BC 0001 SysSym -$LK "ICT_LEA_DISP32_EBP ","FL:::/LT/COMPILE/CODE.ASZ,238"$00000789 0001 SysSym -$LK "ICT_LEA_DISP32_EDI ","FL:::/LT/COMPILE/CODE.ASZ,409"$00000A0C 0001 SysSym -$LK "ICT_LEA_DISP32_ESI ","FL:::/LT/COMPILE/CODE.ASZ,407"$00000A0C 0001 SysSym -$LK "ICT_LEA_DISP8_EBP ","FL:::/LT/COMPILE/CODE.ASZ,239"$00000789 0001 SysSym -$LK "ICT_LEA_DISP8_EDI ","FL:::/LT/COMPILE/CODE.ASZ,410"$00000A0C 0001 SysSym -$LK "ICT_LEA_DISP8_ESI ","FL:::/LT/COMPILE/CODE.ASZ,408"$00000A0C 0001 SysSym -$LK "ICT_LESS_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,262"$00000807 0001 SysSym -$LK "ICT_LESS_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,395"$000009E4 0002 SysSym -$LK "ICT_LESS_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,396"$000009EC 0001 SysSym -$LK "ICT_LESS_THAN ","FL:::/LT/COMPILE/CODE.ASZ,260"$000007E7 0001 SysSym -$LK "ICT_LESS_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,391"$000009BC 0002 SysSym -$LK "ICT_LESS_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,392"$000009C4 0001 SysSym -$LK "ICT_MEMCPY ","FL:::/LT/COMPILE/CODE.ASZ,372"$000009BC 0001 SysSym -$LK "ICT_MEMSET ","FL:::/LT/COMPILE/CODE.ASZ,373"$000009BC 0001 SysSym -$LK "ICT_MM_U1 ","FL:::/LT/COMPILE/CODE.ASZ,229"$00000753 0001 SysSym -$LK "ICT_MM_U2 ","FL:::/LT/COMPILE/CODE.ASZ,228"$0000074C 0001 SysSym -$LK "ICT_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,227"$00000747 0001 SysSym -$LK "ICT_MM_U8 ","FL:::/LT/COMPILE/CODE.ASZ,226"$00000747 0001 SysSym -$LK "ICT_MULTIPLICATION ","FL:::/LT/COMPILE/CODE.ASZ,250"$000007D1 0001 SysSym -$LK "ICT_MUL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,284"$000008BD 0001 SysSym -$LK "ICT_MUL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,283"$000008B1 0001 SysSym -$LK "ICT_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,282"$000008A7 0001 SysSym -$LK "ICT_MUL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,281"$0000089A 0001 SysSym -$LK "ICT_NOP ","FL:::/LT/COMPILE/CODE.ASZ,155"$00000614 0001 SysSym -$LK "ICT_NOT ","FL:::/LT/COMPILE/CODE.ASZ,171"$00000626 0001 SysSym -$LK "ICT_NOT_EQUAL_TO ","FL:::/LT/COMPILE/CODE.ASZ,259"$000007E7 0001 SysSym -$LK "ICT_NOT_EQUAL_TO_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,389"$000009BC 0001 SysSym -$LK "ICT_NOT_EQUAL_TO_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,390"$000009BC 0001 SysSym -$LK "ICT_NULL ","FL:::/LT/COMPILE/CODE.ASZ,154"$00000614 0001 SysSym -$LK "ICT_OR ","FL:::/LT/COMPILE/CODE.ASZ,254"$000007E7 0001 SysSym -$LK "ICT_OR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,296"$0000090E 0001 SysSym -$LK "ICT_OR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,295"$0000090E 0001 SysSym -$LK "ICT_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,294"$0000090E 0001 SysSym -$LK "ICT_OR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,293"$0000090E 0001 SysSym -$LK "ICT_OR_OR ","FL:::/LT/COMPILE/CODE.ASZ,265"$00000827 0001 SysSym -$LK "ICT_OR_OR_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,405"$00000A0C 0001 SysSym -$LK "ICT_OR_OR_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,406"$00000A0C 0001 SysSym -$LK "ICT_OR_OR_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,403"$00000A0C 0001 SysSym -$LK "ICT_OR_OR_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,404"$00000A0C 0001 SysSym -$LK "ICT_OUTP ","FL:::/LT/COMPILE/CODE.ASZ,379"$000009BC 0001 SysSym -$LK "ICT_OUTPD ","FL:::/LT/COMPILE/CODE.ASZ,377"$000009BC 0001 SysSym -$LK "ICT_OUTPW ","FL:::/LT/COMPILE/CODE.ASZ,378"$000009BC 0001 SysSym -$LK "ICT_POWER ","FL:::/LT/COMPILE/CODE.ASZ,249"$000007D1 0001 SysSym -$LK "ICT_PP_U1 ","FL:::/LT/COMPILE/CODE.ASZ,225"$00000741 0001 SysSym -$LK "ICT_PP_U2 ","FL:::/LT/COMPILE/CODE.ASZ,224"$0000073A 0001 SysSym -$LK "ICT_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,223"$00000735 0001 SysSym -$LK "ICT_PP_U8 ","FL:::/LT/COMPILE/CODE.ASZ,222"$00000735 0001 SysSym -$LK "ICT_PUSH_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,425"$00000A0C 0001 SysSym -$LK "ICT_PUSH_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,418"$00000A0C 0001 SysSym -$LK "ICT_PUSH_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,423"$00000A0C 0001 SysSym -$LK "ICT_PUSH_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,424"$00000A0C 0001 SysSym -$LK "ICT_PUSH_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,421"$00000A0C 0001 SysSym -$LK "ICT_PUSH_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,422"$00000A0C 0001 SysSym -$LK "ICT_PUSH_NEG_U1 ","FL:::/LT/COMPILE/CODE.ASZ,417"$00000A0C 0001 SysSym -$LK "ICT_PUSH_NEG_U2 ","FL:::/LT/COMPILE/CODE.ASZ,416"$00000A0C 0001 SysSym -$LK "ICT_PUSH_NEG_U4 ","FL:::/LT/COMPILE/CODE.ASZ,415"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U1 ","FL:::/LT/COMPILE/CODE.ASZ,414"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U2 ","FL:::/LT/COMPILE/CODE.ASZ,413"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U4 ","FL:::/LT/COMPILE/CODE.ASZ,412"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U8 ","FL:::/LT/COMPILE/CODE.ASZ,411"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,419"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,426"$00000A0C 0001 SysSym -$LK "ICT_PUSH_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,420"$00000A0C 0001 SysSym -$LK "ICT_QUESTION ","FL:::/LT/COMPILE/CODE.ASZ,268"$00000827 0001 SysSym -$LK "ICT_REMAINDER ","FL:::/LT/COMPILE/CODE.ASZ,252"$000007DE 0001 SysSym -$LK "ICT_REMQUE ","FL:::/LT/COMPILE/CODE.ASZ,370"$000009BC 0001 SysSym -$LK "ICT_RET ","FL:::/LT/COMPILE/CODE.ASZ,345"$000009BC 0001 SysSym -$LK "ICT_SET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,355"$000009BC 0001 SysSym -$LK "ICT_SET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,353"$000009BC 0001 SysSym -$LK "ICT_SET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,357"$000009BC 0001 SysSym -$LK "ICT_SHL ","FL:::/LT/COMPILE/CODE.ASZ,243"$0000079A 0001 SysSym -$LK "ICT_SHL_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,245"$000007B9 0002 SysSym -$LK "ICT_SHL_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,246"$000007B9 0001 SysSym -$LK "ICT_SHL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,276"$0000083F 0001 SysSym -$LK "ICT_SHL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,275"$00000832 0001 SysSym -$LK "ICT_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,274"$00000827 0001 SysSym -$LK "ICT_SHL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,273"$00000827 0001 SysSym -$LK "ICT_SHORT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,381"$000009BC 0001 SysSym -$LK "ICT_SHR ","FL:::/LT/COMPILE/CODE.ASZ,244"$0000079A 0001 SysSym -$LK "ICT_SHR_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,247"$000007B9 0001 SysSym -$LK "ICT_SHR_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,248"$000007C0 0001 SysSym -$LK "ICT_SHR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,280"$0000088E 0001 SysSym -$LK "ICT_SHR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,279"$00000881 0001 SysSym -$LK "ICT_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,278"$00000876 0001 SysSym -$LK "ICT_SHR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,277"$0000084B 0001 SysSym -$LK "ICT_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,385"$000009BC 0001 SysSym -$LK "ICT_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,386"$000009BC 0001 SysSym -$LK "ICT_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,383"$000009BC 0001 SysSym -$LK "ICT_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,384"$000009BC 0001 SysSym -$LK "ICT_STI ","FL:::/LT/COMPILE/CODE.ASZ,351"$000009BC 0001 SysSym -$LK "ICT_STRING_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,163"$0000061C 0001 SysSym -$LK "ICT_STRLEN ","FL:::/LT/COMPILE/CODE.ASZ,371"$000009BC 0001 SysSym -$LK "ICT_SUB32 ","FL:::/LT/COMPILE/CODE.ASZ,334"$000009BC 0001 SysSym -$LK "ICT_SUB64 ","FL:::/LT/COMPILE/CODE.ASZ,333"$000009BC 0001 SysSym -$LK "ICT_SUB8 ","FL:::/LT/COMPILE/CODE.ASZ,335"$000009BC 0001 SysSym -$LK "ICT_SUBTRACTION ","FL:::/LT/COMPILE/CODE.ASZ,257"$000007E7 0001 SysSym -$LK "ICT_SUB_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,308"$00000940 0001 SysSym -$LK "ICT_SUB_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,307"$00000935 0001 SysSym -$LK "ICT_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,306"$0000092C 0001 SysSym -$LK "ICT_SUB_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,305"$0000092C 0001 SysSym -$LK "ICT_SUB_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,434"$00000A1A 0001 SysSym -$LK "ICT_SWITCH ","FL:::/LT/COMPILE/CODE.ASZ,382"$000009BC 0001 SysSym -$LK "ICT_TABLE_END ","FL:::/LT/COMPILE/CODE.ASZ,438"$00000A30 0001 SysSym -$LK "ICT_TO_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,168"$00000626 0001 SysSym -$LK "ICT_TO_INT ","FL:::/LT/COMPILE/CODE.ASZ,169"$00000626 0001 SysSym -$LK "ICT_TYPE ","FL:::/LT/COMPILE/CODE.ASZ,361"$000009BC 0001 SysSym -$LK "ICT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,161"$0000061C 0001 SysSym -$LK "ICT_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,177"$00000639 0001 SysSym -$LK "ICT_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,181"$00000650 0001 SysSym -$LK "ICT_U1_MM ","FL:::/LT/COMPILE/CODE.ASZ,221"$0000072D 0001 SysSym -$LK "ICT_U1_PP ","FL:::/LT/COMPILE/CODE.ASZ,217"$00000715 0001 SysSym -$LK "ICT_U2 ","FL:::/LT/COMPILE/CODE.ASZ,160"$0000061C 0001 SysSym -$LK "ICT_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,176"$0000062F 0001 SysSym -$LK "ICT_U2_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,242"$00000791 0001 SysSym -$LK "ICT_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,180"$00000649 0001 SysSym -$LK "ICT_U2_MM ","FL:::/LT/COMPILE/CODE.ASZ,220"$00000724 0001 SysSym -$LK "ICT_U2_PP ","FL:::/LT/COMPILE/CODE.ASZ,216"$0000070C 0001 SysSym -$LK "ICT_U4 ","FL:::/LT/COMPILE/CODE.ASZ,159"$00000614 0001 SysSym -$LK "ICT_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,175"$00000626 0001 SysSym -$LK "ICT_U4_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,241"$00000789 0001 SysSym -$LK "ICT_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,179"$00000643 0001 SysSym -$LK "ICT_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,219"$0000071D 0001 SysSym -$LK "ICT_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,215"$00000705 0001 SysSym -$LK "ICT_U8 ","FL:::/LT/COMPILE/CODE.ASZ,158"$00000614 0001 SysSym -$LK "ICT_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,174"$00000626 0001 SysSym -$LK "ICT_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,240"$00000789 0001 SysSym -$LK "ICT_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,178"$00000643 0001 SysSym -$LK "ICT_U8_MM ","FL:::/LT/COMPILE/CODE.ASZ,218"$0000071D 0001 SysSym -$LK "ICT_U8_PP ","FL:::/LT/COMPILE/CODE.ASZ,214"$00000705 0001 SysSym -$LK "ICT_UNARY_MINUS ","FL:::/LT/COMPILE/CODE.ASZ,172"$00000626 0001 SysSym -$LK "ICT_XOR ","FL:::/LT/COMPILE/CODE.ASZ,255"$000007E7 0001 SysSym -$LK "ICT_XOR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,300"$0000090E 0001 SysSym -$LK "ICT_XOR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,299"$0000090E 0001 SysSym -$LK "ICT_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,298"$0000090E 0001 SysSym -$LK "ICT_XOR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,297"$0000090E 0001 SysSym -$LK "ICT_XOR_XOR ","FL:::/LT/COMPILE/CODE.ASZ,266"$00000827 0001 SysSym -$LK "ICT_ZERO ","FL:::/LT/COMPILE/CODE.ASZ,157"$00000614 0001 SysSym -$LK "INTERNAL_TYPES_TABLE ","FL:::/LT/COMPILE/CODE.ASZ,5"$00000000 0001 SysSym Export -$LK "I_OPT_NOP ","FL:::/LT/COMPILE/CODE.ASZ,43"$00000108 0001 SysSym -$LK +BI,"InitCompiler ","FL:::/LT/COMPILE/COMPILE.CPZ,2623",74$0003697A 0001 Funct Export -$LK +BI,"Lex ","FL:::/LT/COMPILE/LEX.CPZ,566",75$00004C7D 00D7 Funct Export -$LK +BI,"LexBackupLastChar ","FL:::/LT/COMPILE/LEX.CPZ,147",76$00002DBF 0003 Funct Export -$LK +BI,"LexDel ","FL:::/LT/COMPILE/LEX.CPZ,95",77$000029F1 0004 Funct Export -$LK +BI,"LexExtendString ","FL:::/LT/COMPILE/LEX.CPZ,925",78$00006DD8 0004 Funct Export -$LK +BI,"LexGetChar ","FL:::/LT/COMPILE/LEX.CPZ,158",79$00002E64 0020 Funct Export -$LK +BI,"LexInString ","FL:::/LT/COMPILE/LEX.CPZ,501",80$00004504 0001 Funct Export -$LK +BI,"LexIncludeLtf ","FL:::/LT/COMPILE/LEX.CPZ,377",81$00003D7D 0001 Funct Export -$LK +BI,"LexIncludeString ","FL:::/LT/COMPILE/LEX.CPZ,355",82$00003C43 0003 Funct Export -$LK +BI,"LexLineNum ","FL:::/LT/COMPILE/LEX.CPZ,968",83$00007168 0008 Funct Export -$LK +BI,"LexNew ","FL:::/LT/COMPILE/LEX.CPZ,65",84$000027AC 0005 Funct Export -$LK +BI,"LexPop ","FL:::/LT/COMPILE/LEX.CPZ,453",85$00004225 0007 Funct Export -$LK +BI,"LexPush ","FL:::/LT/COMPILE/LEX.CPZ,441",86$0000411C 0002 Funct Export -$LK +BI,"LexPutLine ","FL:::/LT/COMPILE/LEX.CPZ,950",87$00006FF0 0003 Funct Export -$LK +BI,"LexPutLink ","FL:::/LT/COMPILE/LEX.CPZ,973",88$000071A0 0002 Funct Export -$LK +BI,"LexPutToken ","FL:::/LT/COMPILE/LEX.CPZ,128",89$00002BF2 0003 Funct Export -$LK +BI,"LexSkipEol ","FL:::/LT/COMPILE/LEX.CPZ,329",90$00003AD9 0007 Funct Export -$LK +BI,"LoadAsmHash ","FL:::/LT/COMPILE/ASM.CPZ,33",91$00010A40 0001 Funct Export -$LK +BI,"LoadCompileSysText ","FL:::/LT/COMPILE/COMPILE.CPZ,1925",92$00033027 0001 Funct Export -$LK +BI,"MSPrintFDate ","FL:::/LT/COMPILE/SPRINTF2.CPZ,117",93$0000BA16 0001 Funct Export -$LK +BI,"MSPrintFPSect ","FL:::/LT/COMPILE/SPRINTF2.CPZ,39",94$0000AC33 0002 Funct Export -$LK +BI,"MSPrintFTime ","FL:::/LT/COMPILE/SPRINTF2.CPZ,57",95$0000AD93 0001 Funct Export -$LK +BI,"OptEnd ","FL:::/LT/COMPILE/OPT.CPZ,99",96$0001CC4D 0004 Funct Export -$LK +BI,"OptMissing ","FL:::/LT/COMPILE/OPT.CPZ,58",97$0001CA89 0004 Funct Export -$LK "OptNext ","FL:::/LT/COMPILE/OPT.CPZ,80"$00000110 0004 Funct -$LK +BI,"OptStart ","FL:::/LT/COMPILE/OPT.CPZ,66",98$0001CB60 0004 Funct Export -$LK +BI,"OutChar ","FL:::/LT/COMPILE/SPRINTF2.CPZ,1",99$0000A8B4 0016 Funct Export -$LK +BI,"OutString ","FL:::/LT/COMPILE/SPRINTF2.CPZ,19",100$0000A9D5 0008 Funct Export -$LK "PASS2_OFFSETS ","FL:::/LT/COMPILE/OPT.CPZ,1226"$4 0013 StrConst -$LK "PG_EXTERN ","FL:::/LT/COMPILE/COMPILE.CPZ,488"$4 0005 StrConst -$LK "PG_IMPORT ","FL:::/LT/COMPILE/COMPILE.CPZ,489"$5 0004 StrConst -$LK "PG_LTEXTERN ","FL:::/LT/COMPILE/COMPILE.CPZ,485"$1 0004 StrConst -$LK "PG_LTIMPORT ","FL:::/LT/COMPILE/COMPILE.CPZ,487"$3 0006 StrConst -$LK "PG_LTINTERN ","FL:::/LT/COMPILE/COMPILE.CPZ,486"$2 0002 StrConst -$LK "PG_NULL ","FL:::/LT/COMPILE/COMPILE.CPZ,484"$0 0001 StrConst -$LK "PRST_CHECK_BINARY_OPS ","FL:::/LT/COMPILE/PARSE.CPZ,18"$3 000E StrConst -$LK "PRST_DEREFERRENCE ","FL:::/LT/COMPILE/PARSE.CPZ,17"$2 0004 StrConst -$LK "PRST_UNARY_MODIFIERS ","FL:::/LT/COMPILE/PARSE.CPZ,16"$1 0009 StrConst -$LK "PRST_UNARY_TERM ","FL:::/LT/COMPILE/PARSE.CPZ,15"$0 0005 StrConst -$LK "PVLM_CLASS ","FL:::/LT/COMPILE/COMPILE.CPZ,14"$2 0001 StrConst -$LK "PVLM_FUNCTION_PARAM ","FL:::/LT/COMPILE/COMPILE.CPZ,13"$1 0003 StrConst -$LK "PVLM_LOCAL_VAR ","FL:::/LT/COMPILE/COMPILE.CPZ,12"$0 0004 StrConst -$LK "PVLM_UNION ","FL:::/LT/COMPILE/COMPILE.CPZ,15"$3 0000 StrConst -$LK +BI,"ParseAsmArg ","FL:::/LT/COMPILE/ASM.CPZ,579",101$00013A7E 0002 Funct Export -$LK +BI,"ParseAsmImm ","FL:::/LT/COMPILE/ASM.CPZ,542",102$0001381C 0006 Funct Export -$LK +BI,"PrsDereferrence ","FL:::/LT/COMPILE/PARSE.CPZ,693",103$0001C1D5 0000 Funct Export -$LK +BI,"PrsExcept ","FL:::/LT/COMPILE/LEX.CPZ,1025",104$000074D4 0064 Funct Export -$LK +BI,"PrsParseExpression ","FL:::/LT/COMPILE/PARSE.CPZ,20",105$00018720 000F Funct Export -$LK +BI,"PrsParseGlblInit ","FL:::/LT/COMPILE/COMPILE.CPZ,464",106$0002B832 0001 Funct Export -$LK "PrsPop ","FL:::/LT/COMPILE/PARSE.CPZ,13"$00000188 006A Funct -$LK "PrsPush ","FL:::/LT/COMPILE/PARSE.CPZ,12"$00000170 00E1 Funct -$LK +BI,"PrsUnaryModifier ","FL:::/LT/COMPILE/PARSE.CPZ,545",107$0001B4F5 0000 Funct Export -$LK +BI,"PrsUnaryTerm ","FL:::/LT/COMPILE/PARSE.CPZ,165",108$0001931C 0000 Funct Export -$LK +BI,"PrsVarInit ","FL:::/LT/COMPILE/COMPILE.CPZ,405",109$0002B293 0002 Funct Export -$LK +BI,"PutAsmError ","FL:::/LT/COMPILE/LEX.CPZ,1011",110$0000742A 0023 Funct Export -$LK +BI,"PutAsmWarning ","FL:::/LT/COMPILE/LEX.CPZ,1018",111$00007481 0003 Funct Export -$LK +BI,"PutLexError ","FL:::/LT/COMPILE/LEX.CPZ,980",112$00007249 0002 Funct Export -$LK +BI,"PutLexWarning ","FL:::/LT/COMPILE/LEX.CPZ,998",113$0000736D 0001 Funct Export -$LK +BI,"ResolveGlbls ","FL:::/LT/COMPILE/ASM.CPZ,400",114$000129A9 0001 Funct Export -$LK +BI,"ResolveLocals ","FL:::/LT/COMPILE/ASM.CPZ,328",115$0001216F 0004 Funct Export -$LK +BI,"SPrintFJoin2 ","FL:::/LT/COMPILE/SPRINTF2.CPZ,237",116$0000CFFD 0001 Funct Export -$LK +BI,"SetSourceFileInfo ","FL:::/LT/COMPILE/LEX.CPZ,120",117$00002B52 0009 Funct Export -$LK +BI,"ShiftNoPush ","FL:::/LT/COMPILE/OPT.CPZ,42",118$0001C9F0 0027 Funct Export -$LK "SwitchCaseEntry ","FL:::/LT/COMPILE/COMPILE.CPZ,781"$00000003 0003 Class -$LK "UCT_ABSOLUTE_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,1483"$0000163B 0001 SysSym -$LK "UCT_ADD32 ","FL:::/LT/COMPILE/CODE.ASZ,1454"$00001576 0001 SysSym -$LK "UCT_ADD64 ","FL:::/LT/COMPILE/CODE.ASZ,1453"$0000156E 0001 SysSym -$LK "UCT_ADD8 ","FL:::/LT/COMPILE/CODE.ASZ,1455"$0000157E 0001 SysSym -$LK "UCT_ADDITION ","FL:::/LT/COMPILE/CODE.ASZ,1380"$00001209 0001 SysSym -$LK "UCT_ADDRESS ","FL:::/LT/COMPILE/CODE.ASZ,1297"$00000F2B 0001 SysSym -$LK "UCT_ADD_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1428"$000014AC 0001 SysSym -$LK "UCT_ADD_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1427"$000014A0 0001 SysSym -$LK "UCT_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1426"$00001496 0001 SysSym -$LK "UCT_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1559"$00001966 0001 SysSym -$LK "UCT_ADD_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1425"$00001488 0001 SysSym -$LK "UCT_ADD_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1557"$0000194A 0001 SysSym -$LK "UCT_ADD_ESP32 ","FL:::/LT/COMPILE/CODE.ASZ,1467"$000015EF 0001 SysSym -$LK "UCT_ADD_ESP8 ","FL:::/LT/COMPILE/CODE.ASZ,1468"$000015F5 0001 SysSym -$LK "UCT_AND ","FL:::/LT/COMPILE/CODE.ASZ,1377"$000011F7 0001 SysSym -$LK "UCT_AND_AND ","FL:::/LT/COMPILE/CODE.ASZ,1388"$00001276 0001 SysSym -$LK "UCT_AND_AND_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,1525"$000017FE 0002 SysSym -$LK "UCT_AND_AND_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1526"$00001808 0002 SysSym -$LK "UCT_AND_AND_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1523"$000017E6 0002 SysSym -$LK "UCT_AND_AND_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1524"$000017F0 0001 SysSym -$LK "UCT_AND_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1416"$0000141F 0001 SysSym -$LK "UCT_AND_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1415"$00001413 0001 SysSym -$LK "UCT_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1414"$00001409 0001 SysSym -$LK "UCT_AND_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1413"$000013FB 0001 SysSym -$LK "UCT_ASSIGN_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1396"$000012DC 0001 SysSym -$LK "UCT_ASSIGN_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1395"$000012D5 0001 SysSym -$LK "UCT_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1394"$000012CF 0001 SysSym -$LK "UCT_ASSIGN_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1393"$000012C6 0001 SysSym -$LK "UCT_BSF ","FL:::/LT/COMPILE/CODE.ASZ,1490"$0000168D 0001 SysSym -$LK "UCT_BSR ","FL:::/LT/COMPILE/CODE.ASZ,1491"$00001695 0001 SysSym -$LK "UCT_BT ","FL:::/LT/COMPILE/CODE.ASZ,1486"$0000164D 0001 SysSym -$LK "UCT_BTC ","FL:::/LT/COMPILE/CODE.ASZ,1489"$0000167D 0001 SysSym -$LK "UCT_BTC_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,1554"$0000192D 0001 SysSym -$LK "UCT_BTR ","FL:::/LT/COMPILE/CODE.ASZ,1488"$0000166D 0001 SysSym -$LK "UCT_BTR_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,1553"$00001920 0001 SysSym -$LK "UCT_BTS ","FL:::/LT/COMPILE/CODE.ASZ,1487"$0000165D 0001 SysSym -$LK "UCT_BTS_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,1552"$00001913 0001 SysSym -$LK "UCT_BT_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,1551"$00001906 0001 SysSym -$LK "UCT_CALL ","FL:::/LT/COMPILE/CODE.ASZ,1470"$000015F9 0002 SysSym -$LK "UCT_CALL_INDIRECT ","FL:::/LT/COMPILE/CODE.ASZ,1471"$00001600 0001 SysSym -$LK "UCT_CALL_INDIRECT2 ","FL:::/LT/COMPILE/CODE.ASZ,1472"$0000160A 0001 SysSym -$LK "UCT_CLI ","FL:::/LT/COMPILE/CODE.ASZ,1474"$00001614 0001 SysSym -$LK "UCT_COLON ","FL:::/LT/COMPILE/CODE.ASZ,1391"$000012B2 0001 SysSym -$LK "UCT_COM ","FL:::/LT/COMPILE/CODE.ASZ,1294"$00000F13 0001 SysSym -$LK "UCT_DEC ","FL:::/LT/COMPILE/CODE.ASZ,1460"$0000159E 0001 SysSym -$LK "UCT_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1329"$00001054 0001 SysSym -$LK "UCT_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1328"$0000104F 0001 SysSym -$LK "UCT_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1327"$0000104B 0001 SysSym -$LK "UCT_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1326"$00001046 0001 SysSym -$LK "UCT_DIVISION ","FL:::/LT/COMPILE/CODE.ASZ,1375"$000011E5 0001 SysSym -$LK "UCT_DIV_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1412"$000013E7 0001 SysSym -$LK "UCT_DIV_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1411"$000013D2 0001 SysSym -$LK "UCT_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1410"$000013C2 0001 SysSym -$LK "UCT_DIV_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1409"$000013AE 0001 SysSym -$LK "UCT_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,1286"$00000EC6 0001 SysSym -$LK "UCT_EBP ","FL:::/LT/COMPILE/CODE.ASZ,1288"$00000EDB 0001 SysSym -$LK "UCT_EDI ","FL:::/LT/COMPILE/CODE.ASZ,1291"$00000EF1 0001 SysSym -$LK "UCT_EDI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1451"$00001562 0001 SysSym -$LK "UCT_EDI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1561"$00001976 0001 SysSym -$LK "UCT_EDI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1448"$00001550 0001 SysSym -$LK "UCT_EDI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1443"$0000152A 0001 SysSym -$LK "UCT_EDI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1337"$00001088 0001 SysSym -$LK "UCT_EDI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1336"$00001081 0001 SysSym -$LK "UCT_EDI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1335"$0000107B 0001 SysSym -$LK "UCT_EDI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1334"$00001074 0001 SysSym -$LK "UCT_EDI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1447"$00001544 0001 SysSym -$LK "UCT_EDI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1361"$0000115E 0001 SysSym -$LK "UCT_EDI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1446"$0000153C 0001 SysSym -$LK "UCT_EDI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1556"$00001942 0001 SysSym -$LK "UCT_EDI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1449"$00001556 0001 SysSym -$LK "UCT_EDI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1360"$00001157 0001 SysSym -$LK "UCT_EDI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1444"$0000152C 0001 SysSym -$LK "UCT_EDI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1445"$00001534 0001 SysSym -$LK "UCT_EDI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1452"$00001568 0001 SysSym -$LK "UCT_EDI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1321"$0000101A 0001 SysSym -$LK "UCT_EDI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1325"$0000103E 0001 SysSym -$LK "UCT_EDI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1320"$0000100F 0001 SysSym -$LK "UCT_EDI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1324"$00001036 0001 SysSym -$LK "UCT_EDI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1319"$00001005 0001 SysSym -$LK "UCT_EDI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1323"$0000102F 0001 SysSym -$LK "UCT_EDI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,1359"$00001150 0001 SysSym -$LK "UCT_EDI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,1358"$00001149 0001 SysSym -$LK "UCT_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1318"$00000FF8 0001 SysSym -$LK "UCT_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1322"$00001025 0001 SysSym -$LK "UCT_EDI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1450"$0000155C 0001 SysSym -$LK "UCT_END_EXP ","FL:::/LT/COMPILE/CODE.ASZ,1280"$00000EA4 0001 SysSym -$LK "UCT_ENTER ","FL:::/LT/COMPILE/CODE.ASZ,1461"$000015A4 0001 SysSym -$LK "UCT_ENTER1 ","FL:::/LT/COMPILE/CODE.ASZ,1463"$000015B5 0001 SysSym -$LK "UCT_ENTER2 ","FL:::/LT/COMPILE/CODE.ASZ,1465"$000015CE 0001 SysSym -$LK "UCT_EQUAL_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,1382"$00001218 0001 SysSym -$LK "UCT_EQUAL_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1511"$00001766 0003 SysSym -$LK "UCT_EQUAL_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1512"$00001770 0001 SysSym -$LK "UCT_ESI ","FL:::/LT/COMPILE/CODE.ASZ,1290"$00000EEB 0001 SysSym -$LK "UCT_ESI_ADD_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1441"$0000151E 0001 SysSym -$LK "UCT_ESI_ADD_EQUAL_U4_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1560"$0000196D 0001 SysSym -$LK "UCT_ESI_AND_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1438"$0000150C 0001 SysSym -$LK "UCT_ESI_ASSIGN_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1433"$000014E6 0001 SysSym -$LK "UCT_ESI_DEREF_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1333"$0000106D 0001 SysSym -$LK "UCT_ESI_DEREF_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1332"$00001066 0001 SysSym -$LK "UCT_ESI_DEREF_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1331"$00001060 0001 SysSym -$LK "UCT_ESI_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1330"$00001059 0001 SysSym -$LK "UCT_ESI_DIV_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1437"$00001500 0001 SysSym -$LK "UCT_ESI_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1357"$00001142 0001 SysSym -$LK "UCT_ESI_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1436"$000014F8 0001 SysSym -$LK "UCT_ESI_NEXT_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1555"$0000193A 0001 SysSym -$LK "UCT_ESI_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1439"$00001512 0001 SysSym -$LK "UCT_ESI_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1356"$0000113B 0001 SysSym -$LK "UCT_ESI_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1434"$000014E8 0001 SysSym -$LK "UCT_ESI_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1435"$000014F0 0001 SysSym -$LK "UCT_ESI_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1442"$00001524 0001 SysSym -$LK "UCT_ESI_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1313"$00000FCC 0001 SysSym -$LK "UCT_ESI_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1317"$00000FF0 0001 SysSym -$LK "UCT_ESI_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1312"$00000FC1 0001 SysSym -$LK "UCT_ESI_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1316"$00000FE8 0001 SysSym -$LK "UCT_ESI_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1311"$00000FB7 0001 SysSym -$LK "UCT_ESI_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1315"$00000FE1 0001 SysSym -$LK "UCT_ESI_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,1355"$00001134 0001 SysSym -$LK "UCT_ESI_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,1354"$0000112D 0001 SysSym -$LK "UCT_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1310"$00000FAA 0001 SysSym -$LK "UCT_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1314"$00000FD7 0001 SysSym -$LK "UCT_ESI_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1440"$00001518 0001 SysSym -$LK "UCT_FS ","FL:::/LT/COMPILE/CODE.ASZ,1289"$00000EE1 0001 SysSym -$LK "UCT_FS_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1309"$00000F9E 0001 SysSym -$LK "UCT_FS_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1308"$00000F92 0001 SysSym -$LK "UCT_FS_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1307"$00000F88 0001 SysSym -$LK "UCT_FS_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1306"$00000F79 0001 SysSym -$LK "UCT_GET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,1478"$00001622 0001 SysSym -$LK "UCT_GET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,1476"$0000161A 0001 SysSym -$LK "UCT_GET_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,1482"$00001632 0001 SysSym -$LK "UCT_GET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,1480"$0000162A 0001 SysSym -$LK "UCT_GREATER_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,1387"$00001266 0001 SysSym -$LK "UCT_GREATER_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1521"$000017D2 0002 SysSym -$LK "UCT_GREATER_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1522"$000017DA 0001 SysSym -$LK "UCT_GREATER_THAN ","FL:::/LT/COMPILE/CODE.ASZ,1385"$00001246 0001 SysSym -$LK "UCT_GREATER_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1517"$000017AA 0002 SysSym -$LK "UCT_GREATER_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1518"$000017B2 0001 SysSym -$LK "UCT_INC ","FL:::/LT/COMPILE/CODE.ASZ,1456"$00001584 0001 SysSym -$LK "UCT_INP ","FL:::/LT/COMPILE/CODE.ASZ,1500"$00001719 0001 SysSym -$LK "UCT_INPD ","FL:::/LT/COMPILE/CODE.ASZ,1498"$0000170C 0001 SysSym -$LK "UCT_INPW ","FL:::/LT/COMPILE/CODE.ASZ,1499"$00001711 0001 SysSym -$LK "UCT_INSQUE ","FL:::/LT/COMPILE/CODE.ASZ,1492"$0000169D 0001 SysSym -$LK "UCT_INSQUE_REV ","FL:::/LT/COMPILE/CODE.ASZ,1493"$000016AD 0001 SysSym -$LK "UCT_IRQ ","FL:::/LT/COMPILE/CODE.ASZ,1473"$00001612 0001 SysSym -$LK "UCT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,1504"$00001736 0001 SysSym -$LK "UCT_LABEL ","FL:::/LT/COMPILE/CODE.ASZ,1484"$00001644 0001 SysSym -$LK "UCT_LEAVE ","FL:::/LT/COMPILE/CODE.ASZ,1462"$000015AD 0001 SysSym -$LK "UCT_LEAVE1 ","FL:::/LT/COMPILE/CODE.ASZ,1464"$000015C5 0001 SysSym -$LK "UCT_LEAVE2 ","FL:::/LT/COMPILE/CODE.ASZ,1466"$000015E5 0001 SysSym -$LK "UCT_LEA_DISP32_EBP ","FL:::/LT/COMPILE/CODE.ASZ,1362"$00001165 0001 SysSym -$LK "UCT_LEA_DISP32_EDI ","FL:::/LT/COMPILE/CODE.ASZ,1533"$00001857 0001 SysSym -$LK "UCT_LEA_DISP32_ESI ","FL:::/LT/COMPILE/CODE.ASZ,1531"$00001846 0001 SysSym -$LK "UCT_LEA_DISP8_EBP ","FL:::/LT/COMPILE/CODE.ASZ,1363"$0000116F 0001 SysSym -$LK "UCT_LEA_DISP8_EDI ","FL:::/LT/COMPILE/CODE.ASZ,1534"$00001861 0001 SysSym -$LK "UCT_LEA_DISP8_ESI ","FL:::/LT/COMPILE/CODE.ASZ,1532"$00001850 0001 SysSym -$LK "UCT_LESS_OR_EQUAL ","FL:::/LT/COMPILE/CODE.ASZ,1386"$00001256 0001 SysSym -$LK "UCT_LESS_OR_EQUAL_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1519"$000017BE 0002 SysSym -$LK "UCT_LESS_OR_EQUAL_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1520"$000017C6 0001 SysSym -$LK "UCT_LESS_THAN ","FL:::/LT/COMPILE/CODE.ASZ,1384"$00001236 0002 SysSym -$LK "UCT_LESS_THAN_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1515"$00001796 0002 SysSym -$LK "UCT_LESS_THAN_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1516"$0000179E 0001 SysSym -$LK "UCT_MEMCPY ","FL:::/LT/COMPILE/CODE.ASZ,1496"$000016D6 0001 SysSym -$LK "UCT_MEMSET ","FL:::/LT/COMPILE/CODE.ASZ,1497"$000016F2 0001 SysSym -$LK "UCT_MM_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1353"$00001126 0001 SysSym -$LK "UCT_MM_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1352"$0000111E 0001 SysSym -$LK "UCT_MM_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1351"$00001118 0001 SysSym -$LK "UCT_MM_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1350"$00001106 0001 SysSym -$LK "UCT_MULTIPLICATION ","FL:::/LT/COMPILE/CODE.ASZ,1374"$000011DF 0001 SysSym -$LK "UCT_MUL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1408"$0000139E 0001 SysSym -$LK "UCT_MUL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1407"$0000138D 0001 SysSym -$LK "UCT_MUL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1406"$00001381 0001 SysSym -$LK "UCT_MUL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1405"$00001374 0001 SysSym -$LK "UCT_NOP ","FL:::/LT/COMPILE/CODE.ASZ,1279"$00000EA4 0001 SysSym -$LK "UCT_NOT ","FL:::/LT/COMPILE/CODE.ASZ,1295"$00000F17 0001 SysSym -$LK "UCT_NOT_EQUAL_TO ","FL:::/LT/COMPILE/CODE.ASZ,1383"$00001227 0002 SysSym -$LK "UCT_NOT_EQUAL_TO_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1513"$0000177E 0002 SysSym -$LK "UCT_NOT_EQUAL_TO_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1514"$00001788 0001 SysSym -$LK "UCT_NULL ","FL:::/LT/COMPILE/CODE.ASZ,1278"$00000EA4 0001 SysSym -$LK "UCT_OR ","FL:::/LT/COMPILE/CODE.ASZ,1378"$000011FD 0001 SysSym -$LK "UCT_OR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1420"$0000144E 0001 SysSym -$LK "UCT_OR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1419"$00001442 0001 SysSym -$LK "UCT_OR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1418"$00001438 0001 SysSym -$LK "UCT_OR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1417"$0000142A 0001 SysSym -$LK "UCT_OR_OR ","FL:::/LT/COMPILE/CODE.ASZ,1389"$00001289 0001 SysSym -$LK "UCT_OR_OR_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,1529"$0000182E 0002 SysSym -$LK "UCT_OR_OR_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1530"$00001838 0001 SysSym -$LK "UCT_OR_OR_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1527"$00001816 0003 SysSym -$LK "UCT_OR_OR_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1528"$00001820 0001 SysSym -$LK "UCT_OUTP ","FL:::/LT/COMPILE/CODE.ASZ,1503"$0000172F 0001 SysSym -$LK "UCT_OUTPD ","FL:::/LT/COMPILE/CODE.ASZ,1501"$00001720 0001 SysSym -$LK "UCT_OUTPW ","FL:::/LT/COMPILE/CODE.ASZ,1502"$00001727 0001 SysSym -$LK "UCT_POWER ","FL:::/LT/COMPILE/CODE.ASZ,1373"$000011DF 0001 SysSym -$LK "UCT_PP_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1349"$000010FF 0001 SysSym -$LK "UCT_PP_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1348"$000010F7 0001 SysSym -$LK "UCT_PP_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1347"$000010F1 0001 SysSym -$LK "UCT_PP_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1346"$000010E3 0001 SysSym -$LK "UCT_PUSH_DEREF_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1549"$000018F5 0001 SysSym -$LK "UCT_PUSH_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,1542"$000018A4 0001 SysSym -$LK "UCT_PUSH_EDI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1547"$000018DE 0001 SysSym -$LK "UCT_PUSH_EDI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1548"$000018EB 0001 SysSym -$LK "UCT_PUSH_ESI_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1545"$000018C7 0001 SysSym -$LK "UCT_PUSH_ESI_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1546"$000018D4 0001 SysSym -$LK "UCT_PUSH_NEG_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1541"$0000189E 0001 SysSym -$LK "UCT_PUSH_NEG_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1540"$00001895 0001 SysSym -$LK "UCT_PUSH_NEG_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1539"$0000188C 0001 SysSym -$LK "UCT_PUSH_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1538"$00001886 0001 SysSym -$LK "UCT_PUSH_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1537"$0000187D 0001 SysSym -$LK "UCT_PUSH_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1536"$00001874 0001 SysSym -$LK "UCT_PUSH_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1535"$00001868 0001 SysSym -$LK "UCT_PUSH_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1543"$000018B0 0001 SysSym -$LK "UCT_PUSH_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,1550"$000018FA 0001 SysSym -$LK "UCT_PUSH_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1544"$000018BD 0001 SysSym -$LK "UCT_QUESTION ","FL:::/LT/COMPILE/CODE.ASZ,1392"$000012C6 0001 SysSym -$LK "UCT_REMAINDER ","FL:::/LT/COMPILE/CODE.ASZ,1376"$000011ED 0001 SysSym -$LK "UCT_REMQUE ","FL:::/LT/COMPILE/CODE.ASZ,1494"$000016BE 0001 SysSym -$LK "UCT_RET ","FL:::/LT/COMPILE/CODE.ASZ,1469"$000015F8 0001 SysSym -$LK "UCT_SET_BASE_PTR ","FL:::/LT/COMPILE/CODE.ASZ,1479"$00001628 0001 SysSym -$LK "UCT_SET_FLAGS ","FL:::/LT/COMPILE/CODE.ASZ,1477"$00001620 0001 SysSym -$LK "UCT_SET_STACK_PTR ","FL:::/LT/COMPILE/CODE.ASZ,1481"$00001630 0001 SysSym -$LK "UCT_SHL ","FL:::/LT/COMPILE/CODE.ASZ,1367"$00001195 0001 SysSym -$LK "UCT_SHL_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,1369"$000011C1 0002 SysSym -$LK "UCT_SHL_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,1370"$000011C8 0001 SysSym -$LK "UCT_SHL_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1400"$0000131E 0001 SysSym -$LK "UCT_SHL_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1399"$00001310 0001 SysSym -$LK "UCT_SHL_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1398"$00001304 0001 SysSym -$LK "UCT_SHL_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1397"$000012E2 0001 SysSym -$LK "UCT_SHORT_JMP ","FL:::/LT/COMPILE/CODE.ASZ,1505"$0000173B 0002 SysSym -$LK "UCT_SHR ","FL:::/LT/COMPILE/CODE.ASZ,1368"$000011AB 0002 SysSym -$LK "UCT_SHR_CONSTANT1 ","FL:::/LT/COMPILE/CODE.ASZ,1371"$000011D0 0001 SysSym -$LK "UCT_SHR_CONSTANT2 ","FL:::/LT/COMPILE/CODE.ASZ,1372"$000011D7 0001 SysSym -$LK "UCT_SHR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1404"$00001367 0001 SysSym -$LK "UCT_SHR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1403"$00001359 0001 SysSym -$LK "UCT_SHR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1402"$0000134D 0001 SysSym -$LK "UCT_SHR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1401"$0000132B 0001 SysSym -$LK "UCT_SKIPNZ ","FL:::/LT/COMPILE/CODE.ASZ,1509"$00001759 0003 SysSym -$LK "UCT_SKIPNZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1510"$0000175D 0001 SysSym -$LK "UCT_SKIPZ ","FL:::/LT/COMPILE/CODE.ASZ,1507"$0000174C 0003 SysSym -$LK "UCT_SKIPZ2 ","FL:::/LT/COMPILE/CODE.ASZ,1508"$00001750 0001 SysSym -$LK "UCT_STI ","FL:::/LT/COMPILE/CODE.ASZ,1475"$00001617 0001 SysSym -$LK "UCT_STRING_CONSTANT ","FL:::/LT/COMPILE/CODE.ASZ,1287"$00000ED2 0001 SysSym -$LK "UCT_STRLEN ","FL:::/LT/COMPILE/CODE.ASZ,1495"$000016C8 0001 SysSym -$LK "UCT_SUB32 ","FL:::/LT/COMPILE/CODE.ASZ,1458"$00001590 0001 SysSym -$LK "UCT_SUB64 ","FL:::/LT/COMPILE/CODE.ASZ,1457"$00001588 0002 SysSym -$LK "UCT_SUB8 ","FL:::/LT/COMPILE/CODE.ASZ,1459"$00001598 0001 SysSym -$LK "UCT_SUBTRACTION ","FL:::/LT/COMPILE/CODE.ASZ,1381"$0000120F 0001 SysSym -$LK "UCT_SUB_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1432"$000014DB 0001 SysSym -$LK "UCT_SUB_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1431"$000014CF 0001 SysSym -$LK "UCT_SUB_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1430"$000014C5 0001 SysSym -$LK "UCT_SUB_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1429"$000014B7 0001 SysSym -$LK "UCT_SUB_EQUAL_U8_CONSTANT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1558"$00001958 0001 SysSym -$LK "UCT_SWITCH ","FL:::/LT/COMPILE/CODE.ASZ,1506"$0000173D 0001 SysSym -$LK "UCT_TABLE_END ","FL:::/LT/COMPILE/CODE.ASZ,1562"$0000197F 0001 SysSym -$LK "UCT_TO_DOUBLE ","FL:::/LT/COMPILE/CODE.ASZ,1292"$00000EF7 0001 SysSym -$LK "UCT_TO_INT ","FL:::/LT/COMPILE/CODE.ASZ,1293"$00000F05 0001 SysSym -$LK "UCT_TYPE ","FL:::/LT/COMPILE/CODE.ASZ,1485"$00001644 0001 SysSym -$LK "UCT_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1285"$00000EBF 0001 SysSym -$LK "UCT_U1_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1301"$00000F4D 0001 SysSym -$LK "UCT_U1_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1305"$00000F71 0001 SysSym -$LK "UCT_U1_MM ","FL:::/LT/COMPILE/CODE.ASZ,1345"$000010DA 0001 SysSym -$LK "UCT_U1_PP ","FL:::/LT/COMPILE/CODE.ASZ,1341"$000010AF 0001 SysSym -$LK "UCT_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1284"$00000EBF 0001 SysSym -$LK "UCT_U2_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1300"$00000F42 0001 SysSym -$LK "UCT_U2_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,1366"$0000118B 0001 SysSym -$LK "UCT_U2_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1304"$00000F69 0001 SysSym -$LK "UCT_U2_MM ","FL:::/LT/COMPILE/CODE.ASZ,1344"$000010D0 0001 SysSym -$LK "UCT_U2_PP ","FL:::/LT/COMPILE/CODE.ASZ,1340"$000010A5 0001 SysSym -$LK "UCT_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1283"$00000EB6 0001 SysSym -$LK "UCT_U4_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1299"$00000F38 0001 SysSym -$LK "UCT_U4_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,1365"$00001182 0001 SysSym -$LK "UCT_U4_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1303"$00000F62 0001 SysSym -$LK "UCT_U4_MM ","FL:::/LT/COMPILE/CODE.ASZ,1343"$000010C8 0001 SysSym -$LK "UCT_U4_PP ","FL:::/LT/COMPILE/CODE.ASZ,1339"$0000109D 0002 SysSym -$LK "UCT_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1282"$00000EAA 0001 SysSym -$LK "UCT_U8_DISP32 ","FL:::/LT/COMPILE/CODE.ASZ,1298"$00000F2B 0001 SysSym -$LK "UCT_U8_DISP32_SCALED ","FL:::/LT/COMPILE/CODE.ASZ,1364"$00001176 0001 SysSym -$LK "UCT_U8_DISP8 ","FL:::/LT/COMPILE/CODE.ASZ,1302"$00000F58 0001 SysSym -$LK "UCT_U8_MM ","FL:::/LT/COMPILE/CODE.ASZ,1342"$000010B8 0001 SysSym -$LK "UCT_U8_PP ","FL:::/LT/COMPILE/CODE.ASZ,1338"$0000108F 0001 SysSym -$LK "UCT_UNARY_MINUS ","FL:::/LT/COMPILE/CODE.ASZ,1296"$00000F24 0001 SysSym -$LK "UCT_XOR ","FL:::/LT/COMPILE/CODE.ASZ,1379"$00001203 0001 SysSym -$LK "UCT_XOR_EQUAL_U1 ","FL:::/LT/COMPILE/CODE.ASZ,1424"$0000147D 0001 SysSym -$LK "UCT_XOR_EQUAL_U2 ","FL:::/LT/COMPILE/CODE.ASZ,1423"$00001471 0001 SysSym -$LK "UCT_XOR_EQUAL_U4 ","FL:::/LT/COMPILE/CODE.ASZ,1422"$00001467 0001 SysSym -$LK "UCT_XOR_EQUAL_U8 ","FL:::/LT/COMPILE/CODE.ASZ,1421"$00001459 0001 SysSym -$LK "UCT_XOR_XOR ","FL:::/LT/COMPILE/CODE.ASZ,1390"$0000129A 0001 SysSym -$LK "UCT_ZERO ","FL:::/LT/COMPILE/CODE.ASZ,1281"$00000EA4 0001 SysSym -$LK "UNSIGNED_CODE_TABLE ","FL:::/LT/COMPILE/CODE.ASZ,1277"$00000A30 0001 SysSym Export -$LK +BI,"UndefinedExtern ","FL:::/LT/COMPILE/COMPILE.CPZ,240",119$0002A569 0001 Funct Export -$LK "asm_hash ","FL:::/LT/COMPILE/LEX.CPZ,27"$00002734 0005 GlbVar Export -$LK "assign_bitmap ","FL:::/LT/COMPILE/LEX.CPZ,61"$0000279C 0005 GlbVar Export -$LK "binary_ops_table ","FL:::/LT/COMPILE/LEX.CPZ,60"$00002790 0002 GlbVar Export -$LK "code_table ","FL:::/LT/COMPILE/LEX.CPZ,22"$000001A0 0008 GlbVar Export -$LK "deref_bitmap ","FL:::/LT/COMPILE/LEX.CPZ,61"$00002798 0005 GlbVar Export -$LK "double_code_table ","FL:::/LT/COMPILE/LEX.CPZ,24"$00001980 0008 GlbVar Export -$LK "double_fix_up_table ","FL:::/LT/COMPILE/LEX.CPZ,57"$00002780 0002 GlbVar Export -$LK "duel_I1_tokens1 ","FL:::/LT/COMPILE/LEX.CPZ,59"$00002784 0002 GlbVar Export -$LK "duel_I1_tokens2 ","FL:::/LT/COMPILE/LEX.CPZ,59"$00002788 0002 GlbVar Export -$LK "duel_I1_tokens3 ","FL:::/LT/COMPILE/LEX.CPZ,59"$0000278C 0002 GlbVar Export -$LK "internal_types_table ","FL:::/LT/COMPILE/LEX.CPZ,25"$00000000 0001 GlbVar Export -$LK "is_first_compiler ","FL:::/LT/COMPILE/LEX.CPZ,28"$00002738 0002 GlbVar Export -$LK "it_to_ec_offset ","FL:::/LT/COMPILE/LEX.CPZ,30"$0000276C 0006 GlbVar Export -$LK "lex_line_feed ","FL:::/LT/COMPILE/LEX.CPZ,145"$00002DB7 0001 GlbVar Export -$LK "lex_zeros ","FL:::/LT/COMPILE/LEX.CPZ,145"$00002DB3 000A GlbVar Export -$LK "opt_nop ","FL:::/LT/COMPILE/OPT.CPZ,65"$0001CB44 0003 GlbVar Export -$LK "push_bitmap ","FL:::/LT/COMPILE/LEX.CPZ,62"$000027A0 0004 GlbVar Export -$LK "push_map ","FL:::/LT/COMPILE/LEX.CPZ,63"$000027A4 0003 GlbVar Export -$LK "signed_fix_up_table ","FL:::/LT/COMPILE/LEX.CPZ,57"$00002778 0002 GlbVar Export -$LK "sys_internal_types ","FL:::/LT/COMPILE/LEX.CPZ,29"$0000273C 0037 GlbVar Export -$LK "unary_ops_table ","FL:::/LT/COMPILE/LEX.CPZ,60"$00002794 0002 GlbVar Export -$LK "unsigned_code_table ","FL:::/LT/COMPILE/LEX.CPZ,23"$00000A30 000F GlbVar Export -$LK "unsigned_fix_up_table ","FL:::/LT/COMPILE/LEX.CPZ,57"$0000277C 0002 GlbVar Export -  Iñ&ñ;ñwñˆñîñ ò(ò:òOò]ò~òºò¿ò4óZó_ótó…ó¤ó²ó×óô"ô'ô·ôþôõõ2õGõ]õsõˆõœõªõËõö öZö_ötöyö”öÛöJ‰éö÷÷4÷K÷\÷~÷ ÷É÷ò÷øø/øTø_øqø–ø¡ø³øØøãøõøùù\ù“ù®ù³ùÐùûùú4ú_úŒú¡úÆúËúøúû1ûQûvû{û«ûµûåûïû ü)üYü—üÐüåüùü ýHK -Z -æiïiôi>j[jj£jÇjëj÷j k.k‚_‚}‚‘‚làøŸ‚¶‚Í‚ø‚ÿ‚ƒƒ5ƒdƒsƒŠƒœƒ¨ƒ»ƒêƒ„„„>„œOs��G�X�t�‚���»�É�â�ý�Ž)Ž>ŽYŽwŽ…ŽšŽµŽÓŽáŽöŽ�/�=�[�Š�±��[�o�‰���¡�§�½�ß�‘‘'‘J‘e‘}‘�‘µ‘Ø‘ -’@’i’˜’²’Ö’ì’&“‚“´“ê“”B”Ó”•;•d•“•²•ŕؕé•–%–…–¶–ä–è–B—s—€—«—Á—Ü—á—÷—˜˜-˜H˜M˜c˜~˜ƒ˜™˜´˜¹˜Ï˜ê˜ï˜ ™™S™�™¦™º™¿™Ê™ä™é™í™Hšzš…š˜š�š¨šÂš›!›<›T›Ž›“›¯›³›ë›œ%œ8œwœ—œ²œÊœ� ��.�3�>�X�]�h�‚�‡�’�¬�±�¼�Ö�á�žžž+ž6žVž[žwž{ž¿žüžŸŸ Ÿ*ŸCŸNŸmŸrŸ}Ÿ—Ÿ¢Ÿ¼ŸÁŸÌŸæŸñŸ   0 5 Y z › Ä ã ö  ¡8¡E¡i¡Š¡«¡Ô¡ó¡¢¢H¢U¢`¢‡¢”¢·¢ £5£l£¡£Ô£á£¤¤4¤n¤�¤Ç¤ß¤ó¤¥,¥L¥k¥—¥¥¥\ùML„c„w„¡„·„΄ï„…!…+…@…“…®…¸…Ô…ü…9†e†È†Ù†ô† -‡;‡Ž‡ú‡}ˆîˆ ‰‰4‰O‰]‰‘‰£‰º‰Õ‰ã‰Š)Š@ŠtЉХнŠÎŠíŠ0‹R‹c‹‚‹ˆ‹¤‹°‹Æ‹Û‹ø‹Œ(ŒLŒQŒqŒŒÁŒâŒôŒ<˜¤>~U~h~o~…~š~«~°~Ã~Dw…"|9|S|_|{|ˆ|�|§|®|Ã|Ñ|(IPlyƒy‰y™y®yÀy<<H¤x»xÓxâxòxyy%y:yLy^y4¥¯Ñ~è~ý~2F[h,�—–}­}¶}ã}î}~0~,ÃË��$�Q�\�Š�—�,†Žß|ö| }8}Y}u}ˆ}4Q[Îyåy÷y -zz"z(z-zl !.u>uNucu’u—u¡u¦uÐuÝu -vv!v&vDvIvSvXvevp";¦v½vÕvîvw:wLwbwpw‚w˜wªwÀwÒwèwúwx"x8x>x„!À×ïô  * ; A S e w ‰ � ¡ ³ Å × Ý ï  - -% -2 -D’3’I’V’f’v’•’§’ ˆmÌÍÍ,ÍNÍSÍn͋͜ͰÍÖÍéÍîÍ Î'ÎJÎZÎyΊÎ�΢νÎÛÎêÎÏÏ,ÏKÏ\ÏoÏtÏ�Ï ÏÀÏÓÏØÏòÏ+ÐpЎЭÐÌÐÜÐûÐ Ñ Ñ$Ñ0ÑCÑHÑXÑsÑ�ўѾÑ×ÑíÑþÑÒ9ÒOÒoÒ…Ò¥Ò¸Ò½ÒÍÒèÒÓÓ=ÓUÓ‹Ó�Ó¯ÓÇÓýÓ Ô9ÔJÔZÔuÔ‹Ô›Ô°ÔÈÔØÔÝÔûÔ ÕÕ#Õ3ÕNÕvÕ„Õ£Õ»ÕñÕöÕÖ-ÖlÖ|Ö¨Ö¹ÖÉÖäÖúÖ -× ×7×G×L×j×z×�×’×¢×½×××èר!Ø7ØHØl؂اؽØÝØðØõØÙ+ÙJÙbÙ‹Ù�Ù¯ÙÇÙðÙÚ,Ú=ÚMÚ`ÚeÚƒÚµÚÐÚáÚñÚÛ -Û)Û:ÛOÛ_ÛrÛwÛ–Û§Û¼ÛÌÛßÛäÛÜÜ)Ü9ÜLÜQÜpÜ�ܖܦܹܾÜÝÜîÜÝÝ&Ý+Ý>Ý`݋ݳÝÃÝÓÝçÝìÝÞÞ'Þ7ÞJÞOÞeÞuÞŠÞšÞ­Þ²ÞÈÞØÞíÞýÞßß+ß;ßPß`ßsßxߎߞ߳ßÃßÖßÛßîßà àà6àPàaà�àšà°àÁàåàûà á6áVáiáná–á¿áÍáìáâ-â2âQâiâ’â¢âÎâßâïâãã$ãOãwã‡ã—ã«ã°ãÅãÕãèãíãää%ä*ä?äOäbägä|äŒäŸä¤ä¹äÉäÜäáäôä åå!å<åVågå‡å å¶åÇåëåæ*æ@æ`æsæxæ æÎæÜæûæç<çAç`çxç¡ç±çÝçîçþçèè&èAèièˆè èÆèÖèéé#é6é;éKéféŽé­éÅéëéûé'ê8êHê[ê`êpê‹ê³êÒêêêë ëLë]ëmë€ë…ë•ë°ëÊëÛëûëì*ì;ì_ìuìžì´ìØìëìðìí7íOíuí…í±íÂíÒíåíêí5îaîrî‚î•îÝîïï%ï9ïQïVïfï�ï›ï¬ïÌïéïÿïð4ðJðsð‰ð­ðÀðÅðíð ñ$ñMñ]ñ‰ñšñªñ½ñÂñò-ò=òMòcòwò�ò”ò¤ò¿òÙòêò -ó'ó=óNóróˆó±óÇóëóôô1ô6ô^ô}ô•ôÄôÔôõõ!õ>õQõVõfõ�õ›õ¬õÌõéõÿõö4öJösö‰ö­öÃöàöóöøö ÷?÷W÷†÷–÷Â÷Ó÷ã÷øøø(øCø]ønøŽø«øÁøÒøöø ù5ùKùoù…ù¢ùµùºùâùðùú'úWú\ú{ú“úÃúÓúÿúû û%û?û\ûoûtû„ûŸû¹ûÊûêûüü.üRühü‘ü§üËüáüþüýý>ýLýkýƒý³ý¸ý×ýïý þ/þ[þlþ|þ�þ þ½þÐþÕþåþÿÿ+ÿKÿhÿ~ÿ�ÿ³ÿÉÿòÿ,B_rwŸ­Ìä8P€�¼ÍÝâ16Fa{Œ¬Éßð*Si�£ÀÓØ-Euz™±áñ.>Cb’—§Âê !Td�¡±Îáæö9Xp¡±Ýîþ.3C^†¥½õ 1 B R o ‚ ‡ — ² Ì Ý ý  -0 -A -e -{ -¤ -º -Þ -é -ü -  , = a r ˆ ¬ ±  Ø ü   $ ? P f Š � ¢ Æ Ë î  F o Š � ¢ µ º Æ Ù Þ î  (6˜ÅÖäü)<ALQ\ot€�»ÍÝî1KZis…Šœ¡³¸ÊÏáæøý&+J[q�”™¥µàò%5Vp’œ®³ÅÊÜáóø -!&8=OTs„šª½ÂÍàåêöû/4>[x† 0ÍÖ€—¨¿ìKyž¸Åßa Ž Î ÿ Q � í !!&!>!R!W!n!!“!¹!Ë!Ð!Û!í!ò! "*"W"‰"Â"Ú"#,#u#�#«#Ô#ä#$Z$u$�$¹$É$î$6%%š%µ%Þ%î%&F&†&ž&°&µ&Ï&í&'L'…'�'Ç'ï'8(S(n(—(§(Ô()8)S)|)Œ)±)ù)B*]*x*¡*±*Þ* +I+a+s+x+’+°+Ý+,H,`,Š,²,û,-1-Z-j-—-à-û-.?.O.t.¼./ /;/d/t/¡/Ì/ 0$060;0U0s0 0Ò0 1#1M1u1¾1Ù1ô12-2Z2£2¾2Ù233$3)3C3a3Ž3À3ù324z4§4ã4545F5K5V5h5m5w5‰5Ž5®5¸5Ê5Ï5é56"6O6`6n6�6Ÿ6±6¶6Ö6à6ò6÷67+7B7o7€7Ž7­7¿7Ñ7Ö7à7ò7÷788828L8\8—8É89,919;9M9R9]9o9t9y9›9­9²9Ä9É9Û9à9ë9ý9:::$:6:;:M:R:]:o:t:†:‹:�:¢:¬:¾:Ã:Î:à:å:ï:;;;#;(;2;D;I;T;f;k;u;‡;Œ;–;›;¦;¸;½;Ç;Ù;Þ;<"<a<†<¥<ä< ====#=:=d=Œ=Ä=ß=ú='>c>š>²>¶>Ê>Ð>é>!?N?r?Î?ÿ?0@e@Š@�@®@Í@ä@!( ×Þ BEYE]E{E‰E«EÂEÓEçE F F%F8F=FPFUFaFtFyF�FªFÆFàFóFøF GGG/G4GGGLG\GyGšG¾GÎGÛGëGH5HEHRHbHŒH´HýHI3I\IlI”IÝIøIJWNWaWfWvW“W¸WÜWìWùW X3XWXgXtX„X—XœX¨X»XÀXËXÞXãXîXYY!Y1YNYsY—Y§Y´YÆYðYZ$Z1ZCZVZ[ZvZ†Z£ZÈZìZüZ [[E[i[y[†[˜[«[°[Ë[Û[ø[\A\Q\^\p\š\¾\Î\Û\í\]] ]0]M]r]–]¦]³]Å]ï]^#^0^B^U^Z^u^…^¢^Ç^ë^û^__D_h_x_…_—_ª_¯_Ê_Ú_÷_`@`P`]`o`™`½`Í`Ú`ì`ÿ`a a/aLaqa•a¥a²aÄaîab"b/bAbTbYbtb„b¡bÆbêbúbccCcgcwc„c–c©c®cÉcÙcøcd:d^dnd{d�d�d eeëKëaë|ë†ë­ë°ëÈëÔëéëúë ì ì0ìAìRìdì�ì¡ì°ì½ìèìúì%í*íOícízíí•íší¬íÌíÞíãíðíîî`îtî‹î¦îÜîñîï5ï:ï?ïeï{ï€ï—ïœï³ï¸ïÏïÔïëïðïýïð"ðQð^ðŽð¶ðãðððõðñ"ñ'ñVñcñ�ñžñÏñ÷ñ$ò9òFòKòdòiò�ò†ò¥òªòÅòãòóó!ó=óBó[ó`óxó}ó“ó˜óÃóÔóáóõóô&ôUôsô†ô“ô³ô¸ôÅôôôõ>õYõzõ›õÁõÝõýõö1öCönö‹ö¥öªöÊöêö÷÷K÷o÷t÷�÷¬÷¹÷Ñ÷ó÷øø8øSøXøsøˆø™øªø¼ø×øóøùù1ùBùOù—ùçù ú%úUúgúvú‘ú²ú¿ú×úäúéú û;ûHû`ûmûrûˆû�û±ûÌûÞûùûüü$hÙð±£È£Õ£û£¤¤#¤4¤E¤W¤h¤o¤¡¤ȤÚ¤é¤ö¤6¥C¥% f‹ùÛÜ$Ü?ÜRÜeÜ~ܜܫÜÁÜØÜÜÜæÜûÜÝKÝeÝ™ÝÓÝêÝïÝüÝ"ÞXÞ]Þ…Þ®ÞåÞ&`ÐåÏÍæÍûÍÎ@ÎkÎΥιÎßÎìÎýÎÏ#ÏIÏVÏ{Ï¡Ï'°Œµßß1ßBßSßkß�ߥ߹ßÍßòßàà1àEàYàtàŒà à­àÄàåà á!á:áKá\ápáˆá¼áÉáÖáÞáââ2â?â(¨æ ïÏÐÐ9ÐFÐrВиÐÉÐâÐ÷ÐÑ)ÑOÑ\ÑiÑ{Ñ›ÑÁÑïÑÒ!Ò;ÒHÒUÒ{ÒˆÒ³ÒÆÒìÒÓ)èAxÌ©ã©÷©ª#ªIª\ªiª{ª¡ª̪òª«.«;«Y«m«ˆ«¥«Ыÿ«.¬C¬[¬ެŸ¬¬¬ج­-­2­e­v­ˆ­•­©­º­Ç­Þ­$®`®·®Ë®Ю*$ù?²¥É¥Ý¥ê¥¦)¦3¦6¦e¦j¦~¦ަ°¦ĦΦަᦧ§§,§;§O§`§m§ˆ§–§¶§ѧé§ ¨¨/¨B¨U¨n¨€¨…¨š¨¯¨¼¨Á¨ݨù¨ -©©-©J©^©o©w©‡©›©±©¾©+ÈíœTºkºº�ºšº«ºúÛºòºÿº -»»B»¡»À»Þ»ó»¼"¼G¼]¼g¼м—¼¾¼Ô¼Þ¼ï¼½"½=½p½н¡½¸½½â½¾/¾F¾P¾l¾�¾š¾ç¾ë¾ ¿¿C¿`¿m¿ ¿Ì¿Ö¿Û¿û¿ÀÀ4ÀHÀ]ÀÀŒÀ²À¿ÀÜÀÁ Á4ÁIÁMÁeÁ|ÁÉÁÍÁíÁòÁÂÂ(ÂVÂ}˜¬ÂÁÂÞÂýÂÃ<ÃQÃbÃfÃ|ÕÚçôÃéÃÄÄ2ÄaÄrÄ’ÄÂÄÕÄòÄÅ+Å=ÅXÅžÅ¯ÅÆÅËÅçÅùÅ ÆÆ-ÆBÆWÆhÆzÆ´ÆÖÆãÆÇÇaÇsÇ‚Ç�ǪǼÇÉÇÛÇÈGÈ_ÈzȇȱȾÈÈÈÍÈ,xž¹KÉbÉoɕɢɳÉÌÉÙÉÿÉ Ê!ÊFÊrÊ�ʪʷÊ×ÊýÊ"ËNËtËžË-¸=Yþpþ�þ£þ´þÅþÖþèþûþÿ ÿ?ÿRÿ_ÿlÿ¢ÿ¼ÿÑÿÞÿùÿ3@E`oŠŸÊ×þ!<MR_z‹��¸ÉÎÛö +4Agm�Ÿ¿Ôè4FfjНÀÒ×äñ(9Msy™«ËÏï&7IN[h’ª¾èî%JNs˜©»ÀÍßèõ %J\�…ªÍÞðõ9?dv›ŸÄæ÷   ( 9 K P ] ƒ ™ ª ¯ ¼ × è í ú þ # -I -N -[ -_ -„ -ª -¯ -¼ -× -è -  D | « Ñ ð   # J z š ¡ ª Ù Þ  - > b z ~ ­ Ø Ý ê ÷ !Jh~�µÂÇÔçìù -6;H`er„–§¬¾Ããç:K]ty€› Éçý4Hc„•¬ºËéöJWr“¥Öå.PecÓzÓ‹ÓŸÓ°ÓäÓñÓÔ$ÔDÔdÔ‚Ô•Ô®ÔÝÔûÔ*ÕYÕwÕ�ÕÃÕÐÕöÕ -Ö0Ö=Öo֌ִ֧ÖÉÖéÖ×,×9×_×lל×Ì×ä×óר#Ø7ØNØt؆طØÁØëØÙÙDÙQÙ~Ù»ÙáÙÚ>ÚeÚšÚ·Ú½ÚÉÚÜÚÛ(Û.ÛIÛfÛ/äÇý}ã”ã¦ãÒãþãä:äZäzäŸäÄäéäå.å5ågå—åÊåíåùå5ælæ’æ²æ¹æëæçNçqç—ç«çÑçÞçèèLèŒè±è×è0$ر’È’ “G“^“l“�“Ù“æ“ð“ ”-”O”\”q”„”¡”Æ”à”•.•C•V•y•ž•°•ʕٕ–R–i–s–”–µ–Æ–Ý–î– ——/—F—S—~—ƒ—”—¯—Ï—Ü—é—ý—˜'˜4˜A˜T˜f˜Œ˜¡˜²˜ØÔ˜î˜ý˜™&™H™`™‚™‘™¬™¹™Ò™ß™ä™ñ™ š š=š\šiš�šœš¿šÒšùš -›'›^›z›”›±›Ù› œCœ]œxœ…œ’œ£œ¼œМðœ �"�I�q�v��� �»�È�à�û�žž2žQžfžxž„ž©žÁžëžúžÿžŸ1Ÿ[Ÿ�Ÿ”Ÿ®ŸËŸÜŸùŸ ( R s “ § Ñ ò :¡I¡d¡ª¡·¡¼¡ ¢¢ ¢@¢M¢ˆ¢œ¢¡¢¢ТÕ¢1`ºÏÛËòËÿË%Ì2ÌGÌlÌ}Ì–Ì£ÌÉÌÖÌöÌÍGÍlÍ’Í2„eç°ÂÓÞ ?d�¤Îí4Ph� ¹Øæ2Vs“ªÄÚê 5N^l‡®¿Îö,0`qvz»ÉÚñGi…™¶Ã׿ L i � • š ´ Õ ê ö 3PáòéÄÅÅÅ0ÅJÅpŕžÅÉÅÖÅëÅøÅ4dÄ7 N � • ¸ ô !B!F!o!š!¦!¬!½!Å!Ø!ì!""#"7"="M"^"k""�"©"¯"Ä"Õ"Ú"ë"ø" #'#7#Q#W#m#˜#Ô#ò#$$-$>$V$Œ$µ$Ù$%O%b%%™%²%Û%ð%ô%&G&v&‹&¢&¶&Ë&à&õ& -'C'U'5 >cü0A]o¡Çì+Fd�·ãíò+?HVwŒ™6LO_¶,¿,Í,ò,-8-F-T-i-x-}-7L0€õ€ �>�D�U�p���Ÿ�´�×�é�î�ÿ�‚'‚>‚P‚]‚b‚v‚š‚¯‚À‚Å‚ã‚ü‚ƒƒ2ƒPƒdƒxƒ}ƒœƒªƒÚƒ)„.„H„M„_„s„“„˜„¶„ȄՄ÷„…$…6…D…M…m…Ð…/†<†S†e†|†8T°Âv� ¬¿Ëü€\€w€Œ€¡€¶€Ê€Ð€Õ€9 QVo;;“;:Œt””¦«¦¼¦é¦ -§§)§>§C§[§p§ˆ§˜§¶§Ô§â§ù§¨-¨=¨[¨o¨u¨z¨;dßõ£CºCÀCÌCßCôC DD+D^DD“D™D¯DÁDÒDäDöD<<Wc ;·;Ë;à;ñ;ö;<#<5<=$ÀÆã*ãNã[ãoã>0¶¿lâƒâŒâ•â¢âÎâñâ?ØN�'§'»'Ã'"(4(F(n(‹(¨(ê(D)^)�)§)±)Â)Ç)Û)à)*/*P*k*Š*·*+{+Ù+,(,L,l,�,˜,@4{…[/r/Œ/©/Ì/à/ô/0At`z…-Ž- -¤-¿-ï- .5.C.a.q..ž.Û.ø. //,/1/C/S/B,ükƂƑƘƶÆÃÆÜÆC,÷? -üOP5PWPyPžP½PòPQ0QDQsQ§QâQñQ1RWRŠRœR±RÆRÛRðRSS&S8SMS_SqSƒS•SªS¼SÎSàSòSTT.TCTUTgTyT‹T TµTÊTßTôT UU3UHU]UoU�U“U¥UºUÏUäUùUV#V8VMVbVwVŒV¡V¶VËVàVõV -W W1WCWUWgW|WŽW W²WÄWÙWëWýWX!X6XHXZXlX~X�X¥XºXÏXáXóXYY/YDYVYkY€Y•YªY¿YÔYéYþYZ(Z=ZRZgZ|Z‘Z¦Z»ZÐZåZúZ[$[9[N[c[x[�[¢[º[Ì[á[ó[\\)\;\M\_\q\ƒ\•\§\¼\Ñ\æ\ø\ -]].]@]R]d]v]ˆ]š]¬]¾]Ð]â]ô]^^0^E^Z^o^„^™^®^Ã^Ø^í^__,_A_V_k_€_•_ª_¿_Ô_é_þ_`(`=`U`g`|`‘`¦`»`Ð`å`ú`a$aJa`a}aša·aÔaña b)bFbcb€bŸb¾bäbúbc4cQclc‰c¦cÅcäc -d d=dZdwd�d¡d¸dÌdàd÷de%efRfif€f—f®fÅfÜfóf -g!g8gOgfg~g�g§g¾gÕgìghh0hehšhÙhîhi8iD<ÒÞC5CDCKCcCpC}C‚C•CEPüÆÇÇ3ÇMÇmdžǜǢÇùÇ ÈÈ.È>È‹ÈFH%™È°È¹ÈÂÈÑÈÉÉ)ÉcÉrÉ�É�ÉžÉG&*¬É¼ÉãÉH,óûÆÆ1Æ7ÆJÆ]ÆI¨�ô-ýDýUý}ý…ý£ý½ýÕýáýåýêýþþþ.þBþ€þÃþàþäþ ÿ4ÿ^ÿoÿ™ÿ¯ÿ×ÿÜÿöÿ -H‹¨¬çü&R~¶Þ.3k„± 9�”ÁÓ"{˜Å×4m¦Óð/_~Ïì$GLy¦«ÀÑJ4@ -J -ziƒi—iœiÄiÉiÎiÚiK¤7�}L”L¢L¿LáL M MSMbMoMtM‘MšMŸMÁMøMýMNN,N[NaNlNtN—N°NÊNÔN÷NO;OTOgOkO›O O°OÅOëOPPPMPkPˆPÐPÞPQ1Q>Q{Q»QÀQØQôQ RRR!RCR‚R‡RÿRS3SHSMSjS|S£S·SËSÙST?TRTWTçT0UHUdUyU~U›U½UÒUíUV V4VBVdV¨V­VûVW/WDWIWfW‹W§W¸WÌWX5XBXpX…X–XØXÝXîX Y=YKY`Y„Y²YÇYßYúYZZ4ZQZ£ZÃZàZíZ [[=[O[n[€[Ÿ[±[Ô[æ[ \\>\^\r\€\¨\Ó\à\!]a]k]Œ]Û]ù]^R^•^ß^û^__1_Q_n_ƒ_�_º_×_ô_`+`C`X`]`}`’`¡`§`°`Â`Ë`à`ú`aa3aaa‹a¤aÀaóab(bBbebzb‹bœb­b¿bÑbåbcac«cÞcùcd1dNdid†dee e;eWeÉe -fffHfnf�f¢f±fÌfàfgNgfgkg‹g¨gògh h'hlKlplŒl­lÅlÊl m'mEmJmfm~mƒmˆmšm°mÂmL4”ž¿-Ö-ß-ó- .!.@.V.Ml`xñ)**,*A*^*„*¡*¸*Í*Ó*í*++0+D+Nlž¶Ømïmn nn9nInanƒn›n¬n½nénooLo�o¤o¹oÕoâoO´ŸId.{.”.³.Å.á.//8/T/e/v/Š/¢/³/Ä/ï/0>0C0U0i0n0‚0®0Â0å0ý01111@1T1€1¡1¶1Ç1Ü1ë1ÿ1+2N2c2t2‰2˜2¬2Ø2ù23 333I3~3”3é3ú3!484I4]4‰4–4Á4Ú4û45#575c5p5›5´5Õ5ì5ý56#616N6p6–6³6Ï6ä6õ6ú6ÿ67#787I7`7o77•7©7Ã7â7ô78898P8o8w8¹8¾8Ò8ì8ú8ÿ89 9 969;9N9f9w9Œ9¡9³9Á9P÷6EE/E@EbEE¼EæEøEF5FBFwF‰F¾FÐFGGLG^G“G¥GÚGìG!HAHUHcH‹H¶HÃHI@IJI}I™IèIJ#J_JžJèJK2K7KSK~KžK»KæKóKLLLaLsLQz¹}=”=¢=¹=Ð=ä=ý=><>g>k>�>†>—> >·>Ã>Ò>ß>î>û> -??&?3?B?O?^?c??�?§?½?Í?Ü?í?ò?@@)@:@Q@m@{@�@¢@¶@Ë@å@ö@AR\eyC<Z<g<v<‰<˜<©<¾<Ï<à<é<== =G=[=o=SÉÍhqxq“qT€B_¬'Ã'Û'å'("(2(J(d(~(”(¨(¼(Ï(ç(ÿ()/)E)X)|)‹)œ)­)Â)Ö)ã)U8ÆÑ%B1Y1t1�1ª1Å1à1û1212L2g2‚2�2¸2Ó2î2 3$3?3Z3u3�3«3Æ3á3ü3424M4h4ƒ4ž4¹4Ô4ï4 -5%5@5[5v5‘5¬5Ç5â5ý5636N6i6„6Ÿ6º6Õ6ð6 7#7]èvíº º3ºNºfº‘ºÐº*»¤»ó»]¼«¼½r½ë½9¾¢¾¿y¿Ø¿ÀqÀëÀ:Á¤ÁòÁ[¹Â2ÀÃéÃGÄÀÄ ÅnÅÍÅÆ{ÆÊÆÇ6ÇrÇ®ÇúÇFÈ¢ÈþÈJÉ–ÉòÉNʉʴÊË^P(93¬C¬f¬�¬Ž¬Ó¬­ ­@­l­_ø:u“­œ­´­ß­®5®”®ê®¯N¯’¯©¯°^°u°Â°±h±Ü±+²Œ²ÿ²…³3´Î´Tµ½µ9¶Ý¶n·ê·;¸`,dlMÌdÌz̡̽ÌÑÌa$;A‰Ê ÊáÊîÊ -Ëb@CP`ËwË�ˡ˰ËÃËìËÌ;ÌcP´¨Ë¨Ô¨á¨ê¨ ©-©S©ƒ©˜©§©¸©Ç©dT'թ쩪5ªWªeª‘ªµª -« «=«z«�«é« ¬%¬eìD¼~:•:¦:·:Ç:Ù:ë:ü:; ;0;A;R;c;t;‚;�;ª;Ë;Ý;ø;<<5<G<b<o<y<Ÿ<±<Ì<Ù<ã< =&=D=V=`=r=š=¸=Ï=Ü=î= ->>)>E>R>d>i>>‰>Ž>®>Æ>Ó>ç>ì> ?$?1?E?e?w?„?¶?Ñ?Þ?:@E@j@Š@—@œ@¼@Ô@Ù@ù@A1AEAeAjAAŒA¥A¹AÊAßAûAB B-BEBaBnBxB“B˜B¸BÐBÝBñBöBfœ C838<8R8`8e8w8ˆ8™8±8Å8Ü8÷8 99"9@9\9p9„9’9£9¨9Á9Õ9é9: :4:H:W:g´¶àÕÁìÁÂ#Â3ÂHÂ[Âyާ¼ÂËÂäÂÿÂÃ2ÃMÃbÀÛðÃÎÃéÃþÃÄÄ&Ä=ÄpÄœÄÌÄÛÄh$Ôtëtu u uiL¥ ‡)‡L‡n‡‘‡¡‡µ‡ɇò‡ˆ7ˆMˆZˆ‰ˆ›ˆºˆ؈óˆ0‰R‰n‰ˆ‰ɉà‰í‰ Š+ŠjІЋЦŠÍпЋ)‹:‹Q‹y‹‹‹�‹¤‹º‹Ù‹ŒŒ7ŒSŒXŒpŒ†ŒšŒ«Œ¼ŒÁŒÏŒúŒ�6�O�q�’�£�°�Î�î�/Ž}ޛ޶ŽÇŽØŽ�7�h�„�«�Å�Ê�û���*�L�f�z���¡�³�¸�Æ�Ô�â�ð�‘)‘1‘b‘l‘�‘›‘¼‘Õ‘î‘ÿ‘’2’L’z’•’¹’ã’ð’jtÑë2¸I¸[¸l¸}¸Џ¨¸и縹t¹¢¹ݹô¹/ºFºkX"µõ´ µ!µ4µOµmµ†µ›µÀµÕµ¶;¶J¶_¶i¶{¶›¶¯¶Õ¶õ¶·"·B·n·‰·›·¦··ç·û·¸6¸Y¸h¸…¸™¸¿¸Ó¸ù¸ÿ¸0¹V¹j¹z¹…¹£¹¸¹Źë¹ø¹º"º/ºMºkº€º¥ºµºƺ»"»H»M»\»q»{»‘»¼»Ï»è»õ»¼(¼J¼l¼‡¼–¼×¼õ¼½(½M½R½w½}½›½©½Á½ν۽セ!¾.¾E¾W¾j¾ƒ¾¨¾µ¾Ǿñ¾þ¾¿%¿9¿F¿Z¿n¿{¿�¿¢¿³¿è¿ÀQÀ`À{ÀˆÀ¤À³ÀÎÀÛÀ÷ÀÁÁlø¦!“3“N“Z“““ɓ֓哔”F”S”b”}”¡”¶”ñ”ö”•I•f•€•œ•«•ȕܕô•––'–b–g–…–º–×–ñ– ——+—d—•—¢—±—Ì—Ù—ì—˜˜8˜E˜x˜‡˜¼˜Õ˜â˜*™9™V™q™~™™™ ™¤™Ö™Û™ š:š?šFšJš|š�š°š¿šÒšèšöš ››(›C›Z›g›ƒ›‘›¨›µ›Ñ›ß› œ-œ^œmœ‰œ¦œÁœÖœûœ�+�J�\�x�~� �Ë�í�ú� ž#ž8žXžxžŽžŸž·žŸŸEŸJŸcŸŽŸ¤Ÿ·ŸÊŸÚŸðŸ > j Š ° Рæ ù  ¡*¡J¡k¡ ¡Ï¡Ô¡¢Q¢�¢œ¢«¢Ñ¢Þ¢ë¢ÿ¢££/£@£T£a£|£�£Ž£ £¾£Ë£â£ô£ -¤S¤˜¤°¤ɤΤÛ¤¥'¥4¥N¥[¥~¥�¥ª¥Í¥è¥¦G¦b¦˜¦Á¦æ¦ó¦§<§N§z§˜§½§ʧا󧨨)¨<¨U¨z¨‡¨š¨µ¨ݨë¨ø¨"©/©C©V©j©w©‹©Ÿ©¬©À©Ó©ä©û©)ªIªPªª«ªèªíª«P«ƒ«’«¶«Ç«Ü«÷«¬¬0¬U¬q¬�¬¦¬άð¬õ¬$­@­k­p­•­½­ß­®®,®G®l®�®Í®á® ¯(¯7¯€¯¿¯įʯû¯%°T°h°’°Ÿ°®°Ö°±(±R±f±~±ƒ±‰±º±ä±²²#²7²a²u²Ÿ²¿²ä²³0³Z³g³v³’³mô–Г²ª²¾²ϲÓ²ݲü² ³/³<³I³u³Œ³Õ³æ³<´}´Š´¡´å´ü´µ"µHµUµZµfµžµþµ=¶^¶Œ¶¤¶¶¶»¶Ó¶î¶· ·%·D·Y·k·˜·¬·Ö·æ·õ·n$ôú*tAtYtftsto$û�t˜t°t½tÊtpPÕæIr`rrrˆr¨r¯r½rØràrïr ss%sDsq<çóms„s–s¬s¯sÁsÅsØsåsòstr@‘©)À)Ü)í)***"*3*F*W*d*“*Â*%+A+€+š+¬+Ô+è+û+ ,;,P,r,ƒ,¡,³,Ä,É,è,-(-¥-4.—.³.Ö.Ü.ö.‹/î/ -00D0g0m0Š0•0Æ0Ý0 -171E1T1h1n1Š1‘1©1í1'242o2•2ª2¼2Í2á2;3U3d3t3�3²3Ä3Õ3â34A4\4k4{4€4�4œ4«4Ö4Ý4õ4ú4%5K5©5Ã5È5Ý5î56 6:6^6o6Š6ª6Ç6Ù6è6÷6727F7K7c7s(I�o!†!—! !´!Å!Í!Û!ç!ø! "")"X"»"×"#?#Y#k#“#§#º#Ù#ó# $w$%|%˜%Ÿ%Â%å%ë%&š&ý&' 'C'f'l'‰'”'Å'Ü' (6(D(S(g(m(‚( (²(Ê(â(ö( -)ttîýÏÐ%Ð9ÐAÐIÐOÐTÐwÐ~Ð�СпÐÙÐñÐÑÑÑ5ÑGÑKÑaÑuѳÑöÑÒÒRÒfÒ‚Ò†ÒÄÒÓ$Ó(ÓcÓ{ÓÓ‘Ó§Ó»Ó×ÓÛÓÔ\ÔyÔ}Ô¸ÔÉÔÝÔÕ@ÕoÕtÕ·ÕæÕëÕ4ÖAÖpÖ…ÖŠÖÂÖèÖþÖ×2×M×d×{×–×­×Ä×ã×úרØNØo؉ؓØñØÙ>ÙC١ٿÙîÙóÙ3Ú8Ú‚Ú±ÚÆÚËÚÛDÛYÛ^ÛcÛ¶ÛÜ2ÜGÜL܇ܟܱÜÐÜýÜCÝhÝmÝ£ÝÚÝ ÞÞHÞ_Þ©ÞÀÞÝÞøÞ.ß_ß~߹߿ß,àQà[àŽà§àæàøà á8áá á¾á`â¬â¹âòâ”ãàãñãöãäJäcä¢ä´äÜä-åNå~å½ååå÷å ææUæ‡æŒæÇæþæ:çlçqç¬çãçøçšèæèééOéé¾éÃéäéê0êoê�ê©êúêë½ëÌëÖëì>ìwìÏìâìííUí‚í»íî&îTî^î™îÆî -ï8ïBïYï^ï}ï›ï©ïu(y€R+i+r+¨+º+Û+vH+:ðÉÊÊ$Ê,Ê9ÊRÊhÊqÊwÊ|Êw$ñ÷i¥r¥„¥’¥ \ No newline at end of file diff --git a/LT/COMPILE/CODE.ASZ b/LT/COMPILE/CODE.ASZ deleted file mode 100644 index 009eb85..0000000 --- a/LT/COMPILE/CODE.ASZ +++ /dev/null @@ -1,4083 +0,0 @@ - ALIGN 8,0x90 -FAR_AWAY: //(FOR DUMMY U4 JMPS) - - ALIGN 4 -INTERNAL_TYPES_TABLE:: - DU4 HTT_INTERNAL_TYPE,IT_I4,4; - DU1 "void",0; - DU4 HTT_INTERNAL_TYPE,IT_DOUBLE,8; - DU1 "double",0; - - DU4 HTT_INTERNAL_TYPE,IT_I0,0; - DU1 "I0i",0; - DU4 HTT_INTERNAL_TYPE,IT_U0,0; - DU1 "U0i",0; - DU4 HTT_INTERNAL_TYPE,IT_I0,0; - DU1 "I0",0; - DU4 HTT_INTERNAL_TYPE,IT_U0,0; - DU1 "U0",0; - DU4 HTT_INTERNAL_TYPE,IT_I1,1; - DU1 "I1i",0; - DU4 HTT_INTERNAL_TYPE,IT_U1,1; - DU1 "U1i",0; - DU4 HTT_INTERNAL_TYPE,IT_I1,1; - DU1 "I1",0; - DU4 HTT_INTERNAL_TYPE,IT_U1,1; - DU1 "U1",0; - DU4 HTT_INTERNAL_TYPE,IT_I2,2; - DU1 "I2i",0; - DU4 HTT_INTERNAL_TYPE,IT_U2,2; - DU1 "U2i",0; - DU4 HTT_INTERNAL_TYPE,IT_I4,4; - DU1 "I4i",0; - DU4 HTT_INTERNAL_TYPE,IT_U4,4; - DU1 "U4i",0; - DU4 HTT_INTERNAL_TYPE,IT_I8,8; - DU1 "I8i",0; - DU4 HTT_INTERNAL_TYPE,IT_U8,8; - DU1 "U8i",0; - - DU4 HTT_INVALID; -//******************************************************* - ALIGN 8,0x90 -I_OPT_NOP: - DU4 EC_NOP; //Must be at IC_CODE offset - -/********** -void OptNext(IntermediateCode *tempi, - IntermediateCode **temp_lag) -{ - I8 i,j=0; - for (i=3;i>0;i--) - temp_lag[i]=temp_lag[i-1]; - temp_lag[0]=tempi; - for (i=0;i<4;i++) //TODO: move end_exp - if (temp_lag[i]->ic_code.u2[0]>EC_END_EXP) - temp_lag[j++]=temp_lag[i]; - while (j<4) - temp_lag[j++]=&opt_nop; -} -************/ - ALIGN 8,0x90 -CP_OPTNEXT:: - PUSH EBP - MOV EBP,ESP - PUSH EDI - MOV ECX,U4 SF_PARAM1[EBP] - MOV EDX,U4 SF_PARAM2[EBP] - - MOV EAX,U4 8[EDX] - MOV U4 12[EDX],EAX - MOV EAX,U4 4[EDX] - MOV U4 8[EDX],EAX - MOV EAX,U4 [EDX] - MOV U4 4[EDX],EAX - MOV U4 [EDX],ECX - - MOV EDI,EDX - - MOV EAX,U4 [EDX] - CMP U2 IC_CODE[EAX],EC_END_EXP - JBE @@10 - STOSD - -@@10: MOV EAX,U4 4[EDX] - CMP U2 IC_CODE[EAX],EC_END_EXP - JBE @@11 - STOSD - -@@11: MOV EAX,U4 8[EDX] - CMP U2 IC_CODE[EAX],EC_END_EXP - JBE @@12 - STOSD - -@@12: MOV EAX,U4 12[EDX] - CMP U2 IC_CODE[EAX],EC_END_EXP - JBE @@13 - STOSD - -@@13: MOV EAX,I_OPT_NOP - ADD EDX,16 - JMP @@15 - -@@14: STOSD -@@15: CMP EDI,EDX - JB @@14 - -@@100: MOV EAX,1 - XOR EDX,EDX - POP EDI - POP EBP - RET -//******************************************************* -/**** -void PrsPush(ParseStack *ps,U4 val) -{ - ps->stk[ps->ptr++]=val; -} -U8 PrsPop(ParseStack *ps) -{ - return ps->stk[--ps->ptr]; -} -******/ - ALIGN 8,0x90 -CP_PRSPUSH:: - PUSH EBP - MOV EBP,ESP - MOV ECX,U4 SF_PARAM1[EBP] - MOV EAX,U4 [ECX] - LEA EBX,U4 4[ECX+EAX*4] - INC EAX - MOV EDX,U4 SF_PARAM2[EBP] - MOV U4 [ECX],EAX - MOV U4 [EBX],EDX - POP EBP - RET - - ALIGN 8,0x90 -CP_PRSPOP:: - PUSH EBP - MOV EBP,ESP - MOV ECX,U4 SF_PARAM1[EBP] - MOV EAX,U4 [ECX] - DEC EAX - MOV U4 [ECX],EAX - MOV EAX,U4 4[ECX+EAX*4] - XOR EDX,EDX - POP EBP - RET - -//******************************************************* - - ALIGN 8,0x90 -CODE_TABLE:: - DU4 ICT_NULL; - DU4 ICT_NOP; - DU4 ICT_END_EXP; - DU4 ICT_ZERO; - DU4 ICT_U8; - DU4 ICT_U4; - DU4 ICT_U2; - DU4 ICT_U1; - DU4 ICT_DOUBLE; - DU4 ICT_STRING_CONSTANT; - DU4 ICT_EBP; - DU4 ICT_FS; - DU4 ICT_ESI; - DU4 ICT_EDI; - DU4 ICT_TO_DOUBLE; - DU4 ICT_TO_INT; - DU4 ICT_COM; - DU4 ICT_NOT; - DU4 ICT_UNARY_MINUS; - DU4 ICT_ADDRESS; - DU4 ICT_U8_DISP32; - DU4 ICT_U4_DISP32; - DU4 ICT_U2_DISP32; - DU4 ICT_U1_DISP32; - DU4 ICT_U8_DISP8; - DU4 ICT_U4_DISP8; - DU4 ICT_U2_DISP8; - DU4 ICT_U1_DISP8; - DU4 ICT_FS_U8_DISP32; - DU4 ICT_FS_U4_DISP32; - DU4 ICT_FS_U2_DISP32; - DU4 ICT_FS_U1_DISP32; - DU4 ICT_ESI_U8_DISP32; - DU4 ICT_ESI_U4_DISP32; - DU4 ICT_ESI_U2_DISP32; - DU4 ICT_ESI_U1_DISP32; - DU4 ICT_ESI_U8_DISP8; - DU4 ICT_ESI_U4_DISP8; - DU4 ICT_ESI_U2_DISP8; - DU4 ICT_ESI_U1_DISP8; - DU4 ICT_EDI_U8_DISP32; - DU4 ICT_EDI_U4_DISP32; - DU4 ICT_EDI_U2_DISP32; - DU4 ICT_EDI_U1_DISP32; - DU4 ICT_EDI_U8_DISP8; - DU4 ICT_EDI_U4_DISP8; - DU4 ICT_EDI_U2_DISP8; - DU4 ICT_EDI_U1_DISP8; - DU4 ICT_DEREF_U8; - DU4 ICT_DEREF_U4; - DU4 ICT_DEREF_U2; - DU4 ICT_DEREF_U1; - DU4 ICT_ESI_DEREF_U8; - DU4 ICT_ESI_DEREF_U4; - DU4 ICT_ESI_DEREF_U2; - DU4 ICT_ESI_DEREF_U1; - DU4 ICT_EDI_DEREF_U8; - DU4 ICT_EDI_DEREF_U4; - DU4 ICT_EDI_DEREF_U2; - DU4 ICT_EDI_DEREF_U1; - DU4 ICT_U8_PP; - DU4 ICT_U4_PP; - DU4 ICT_U2_PP; - DU4 ICT_U1_PP; - DU4 ICT_U8_MM; - DU4 ICT_U4_MM; - DU4 ICT_U2_MM; - DU4 ICT_U1_MM; - DU4 ICT_PP_U8; - DU4 ICT_PP_U4; - DU4 ICT_PP_U2; - DU4 ICT_PP_U1; - DU4 ICT_MM_U8; - DU4 ICT_MM_U4; - DU4 ICT_MM_U2; - DU4 ICT_MM_U1; - DU4 ICT_ESI_U4_PP; - DU4 ICT_ESI_U4_MM; - DU4 ICT_ESI_PP_U4; - DU4 ICT_ESI_MM_U4; - DU4 ICT_EDI_U4_PP; - DU4 ICT_EDI_U4_MM; - DU4 ICT_EDI_PP_U4; - DU4 ICT_EDI_MM_U4; - DU4 ICT_LEA_DISP32_EBP; - DU4 ICT_LEA_DISP8_EBP; - DU4 ICT_U8_DISP32_SCALED; - DU4 ICT_U4_DISP32_SCALED; - DU4 ICT_U2_DISP32_SCALED; - DU4 ICT_SHL; - DU4 ICT_SHR; - DU4 ICT_SHL_CONSTANT1; - DU4 ICT_SHL_CONSTANT2; - DU4 ICT_SHR_CONSTANT1; - DU4 ICT_SHR_CONSTANT2; - DU4 ICT_POWER; - DU4 ICT_MULTIPLICATION; - DU4 ICT_DIVISION; - DU4 ICT_REMAINDER; - DU4 ICT_AND; - DU4 ICT_OR; - DU4 ICT_XOR; - DU4 ICT_ADDITION; - DU4 ICT_SUBTRACTION; - DU4 ICT_EQUAL_EQUAL; - DU4 ICT_NOT_EQUAL_TO; - DU4 ICT_LESS_THAN; - DU4 ICT_GREATER_THAN; - DU4 ICT_LESS_OR_EQUAL; - DU4 ICT_GREATER_OR_EQUAL; - DU4 ICT_AND_AND; - DU4 ICT_OR_OR; - DU4 ICT_XOR_XOR; - DU4 ICT_COLON; - DU4 ICT_QUESTION; - DU4 ICT_ASSIGN_U8; - DU4 ICT_ASSIGN_U4; - DU4 ICT_ASSIGN_U2; - DU4 ICT_ASSIGN_U1; - DU4 ICT_SHL_EQUAL_U8; - DU4 ICT_SHL_EQUAL_U4; - DU4 ICT_SHL_EQUAL_U2; - DU4 ICT_SHL_EQUAL_U1; - DU4 ICT_SHR_EQUAL_U8; - DU4 ICT_SHR_EQUAL_U4; - DU4 ICT_SHR_EQUAL_U2; - DU4 ICT_SHR_EQUAL_U1; - DU4 ICT_MUL_EQUAL_U8; - DU4 ICT_MUL_EQUAL_U4; - DU4 ICT_MUL_EQUAL_U2; - DU4 ICT_MUL_EQUAL_U1; - DU4 ICT_DIV_EQUAL_U8; - DU4 ICT_DIV_EQUAL_U4; - DU4 ICT_DIV_EQUAL_U2; - DU4 ICT_DIV_EQUAL_U1; - DU4 ICT_AND_EQUAL_U8; - DU4 ICT_AND_EQUAL_U4; - DU4 ICT_AND_EQUAL_U2; - DU4 ICT_AND_EQUAL_U1; - DU4 ICT_OR_EQUAL_U8; - DU4 ICT_OR_EQUAL_U4; - DU4 ICT_OR_EQUAL_U2; - DU4 ICT_OR_EQUAL_U1; - DU4 ICT_XOR_EQUAL_U8; - DU4 ICT_XOR_EQUAL_U4; - DU4 ICT_XOR_EQUAL_U2; - DU4 ICT_XOR_EQUAL_U1; - DU4 ICT_ADD_EQUAL_U8; - DU4 ICT_ADD_EQUAL_U4; - DU4 ICT_ADD_EQUAL_U2; - DU4 ICT_ADD_EQUAL_U1; - DU4 ICT_SUB_EQUAL_U8; - DU4 ICT_SUB_EQUAL_U4; - DU4 ICT_SUB_EQUAL_U2; - DU4 ICT_SUB_EQUAL_U1; - DU4 ICT_ESI_ASSIGN_U4; - DU4 ICT_ESI_SHL_EQUAL_U4; - DU4 ICT_ESI_SHR_EQUAL_U4; - DU4 ICT_ESI_MUL_EQUAL_U4; - DU4 ICT_ESI_DIV_EQUAL_U4; - DU4 ICT_ESI_AND_EQUAL_U4; - DU4 ICT_ESI_OR_EQUAL_U4; - DU4 ICT_ESI_XOR_EQUAL_U4; - DU4 ICT_ESI_ADD_EQUAL_U4; - DU4 ICT_ESI_SUB_EQUAL_U4; - DU4 ICT_EDI_ASSIGN_U4; - DU4 ICT_EDI_SHL_EQUAL_U4; - DU4 ICT_EDI_SHR_EQUAL_U4; - DU4 ICT_EDI_MUL_EQUAL_U4; - DU4 ICT_EDI_DIV_EQUAL_U4; - DU4 ICT_EDI_AND_EQUAL_U4; - DU4 ICT_EDI_OR_EQUAL_U4; - DU4 ICT_EDI_XOR_EQUAL_U4; - DU4 ICT_EDI_ADD_EQUAL_U4; - DU4 ICT_EDI_SUB_EQUAL_U4; - DU4 ICT_ADD64; - DU4 ICT_ADD32; - DU4 ICT_ADD8; - DU4 ICT_INC; - DU4 ICT_SUB64; - DU4 ICT_SUB32; - DU4 ICT_SUB8; - DU4 ICT_DEC; - DU4 ICT_ENTER; - DU4 ICT_LEAVE; - DU4 ICT_ENTER1; - DU4 ICT_LEAVE1; - DU4 ICT_ENTER2; - DU4 ICT_LEAVE2; - DU4 ICT_ADD_ESP32; - DU4 ICT_ADD_ESP8; - DU4 ICT_RET; - DU4 ICT_CALL; - DU4 ICT_CALL_INDIRECT; - DU4 ICT_CALL_INDIRECT2; - DU4 ICT_IRQ; - DU4 ICT_CLI; - DU4 ICT_STI; - DU4 ICT_GET_FLAGS; - DU4 ICT_SET_FLAGS; - DU4 ICT_GET_BASE_PTR; - DU4 ICT_SET_BASE_PTR; - DU4 ICT_GET_STACK_PTR; - DU4 ICT_SET_STACK_PTR; - DU4 ICT_GET_LABEL; - DU4 ICT_ABSOLUTE_ADDRESS; - DU4 ICT_LABEL; - DU4 ICT_TYPE; - DU4 ICT_BT; - DU4 ICT_BTS; - DU4 ICT_BTR; - DU4 ICT_BTC; - DU4 ICT_BSF; - DU4 ICT_BSR; - DU4 ICT_INSQUE; - DU4 ICT_INSQUE_REV; - DU4 ICT_REMQUE; - DU4 ICT_STRLEN; - DU4 ICT_MEMCPY; - DU4 ICT_MEMSET; - DU4 ICT_INPD; - DU4 ICT_INPW; - DU4 ICT_INP; - DU4 ICT_OUTPD; - DU4 ICT_OUTPW; - DU4 ICT_OUTP; - DU4 ICT_JMP; - DU4 ICT_SHORT_JMP; - DU4 ICT_SWITCH; - DU4 ICT_SKIPZ; - DU4 ICT_SKIPZ2; - DU4 ICT_SKIPNZ; - DU4 ICT_SKIPNZ2; - DU4 ICT_EQUAL_EQUAL_SKIPZ; - DU4 ICT_EQUAL_EQUAL_SKIPZ2; - DU4 ICT_NOT_EQUAL_TO_SKIPZ; - DU4 ICT_NOT_EQUAL_TO_SKIPZ2; - DU4 ICT_LESS_THAN_SKIPZ; - DU4 ICT_LESS_THAN_SKIPZ2; - DU4 ICT_GREATER_THAN_SKIPZ; - DU4 ICT_GREATER_THAN_SKIPZ2; - DU4 ICT_LESS_OR_EQUAL_SKIPZ; - DU4 ICT_LESS_OR_EQUAL_SKIPZ2; - DU4 ICT_GREATER_OR_EQUAL_SKIPZ; - DU4 ICT_GREATER_OR_EQUAL_SKIPZ2; - DU4 ICT_AND_AND_SKIPZ; - DU4 ICT_AND_AND_SKIPZ2; - DU4 ICT_AND_AND_SKIPNZ; - DU4 ICT_AND_AND_SKIPNZ2; - DU4 ICT_OR_OR_SKIPZ; - DU4 ICT_OR_OR_SKIPZ2; - DU4 ICT_OR_OR_SKIPNZ; - DU4 ICT_OR_OR_SKIPNZ2; - DU4 ICT_LEA_DISP32_ESI; - DU4 ICT_LEA_DISP8_ESI; - DU4 ICT_LEA_DISP32_EDI; - DU4 ICT_LEA_DISP8_EDI; - DU4 ICT_PUSH_U8; - DU4 ICT_PUSH_U4; - DU4 ICT_PUSH_U2; - DU4 ICT_PUSH_U1; - DU4 ICT_PUSH_NEG_U4; - DU4 ICT_PUSH_NEG_U2; - DU4 ICT_PUSH_NEG_U1; - DU4 ICT_PUSH_DOUBLE; - DU4 ICT_PUSH_U8_DISP32; - DU4 ICT_PUSH_U8_DISP8; - DU4 ICT_PUSH_ESI_U8_DISP32; - DU4 ICT_PUSH_ESI_U8_DISP8; - DU4 ICT_PUSH_EDI_U8_DISP32; - DU4 ICT_PUSH_EDI_U8_DISP8; - DU4 ICT_PUSH_DEREF_U8; - DU4 ICT_PUSH_U8_DISP32_SCALED; - DU4 ICT_BT_CONSTANT; - DU4 ICT_BTS_CONSTANT; - DU4 ICT_BTR_CONSTANT; - DU4 ICT_BTC_CONSTANT; - DU4 ICT_ESI_NEXT_EQUAL_U4; - DU4 ICT_EDI_NEXT_EQUAL_U4; - DU4 ICT_ADD_EQUAL_U8_CONSTANT_U1; - DU4 ICT_SUB_EQUAL_U8_CONSTANT_U1; - DU4 ICT_ADD_EQUAL_U4_CONSTANT_U1; - DU4 ICT_ESI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 ICT_EDI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 ICT_TABLE_END; -ICT_NULL: -ICT_NOP: -ICT_END_EXP: -ICT_ZERO: -ICT_U8: -ICT_U4: - PUSH EDX - PUSH EAX - MOV EAX,0x12345678 - CDQ -ICT_U2: -ICT_U1: -ICT_DOUBLE: -ICT_STRING_CONSTANT: -ICT_EBP: -ICT_FS: -ICT_ESI: - PUSH EDX - PUSH EAX - MOV EAX,ESI - CDQ -ICT_EDI: - PUSH EDX - PUSH EAX - MOV EAX,EDI - CDQ -ICT_TO_DOUBLE: -ICT_TO_INT: -ICT_COM: -ICT_NOT: -ICT_UNARY_MINUS: -ICT_ADDRESS: -ICT_U8_DISP32: -ICT_U4_DISP32: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12345678[EBP] - CDQ -ICT_U2_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12345678[EBP] - CDQ -ICT_U1_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12345678[EBP] - CDQ -ICT_U8_DISP8: -ICT_U4_DISP8: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12[EBP] - CDQ -ICT_U2_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12[EBP] - CDQ -ICT_U1_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12[EBP] - CDQ -ICT_FS_U8_DISP32: -ICT_FS_U4_DISP32: - PUSH EDX - PUSH EAX - MOV EAX,U4 FS:[0x12345678] - CDQ -ICT_FS_U2_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 FS:[0x12345678] - CDQ -ICT_FS_U1_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 FS:[0x12345678] - CDQ -ICT_ESI_U8_DISP32: -ICT_ESI_U4_DISP32: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12345678[ESI] - CDQ -ICT_ESI_U2_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12345678[ESI] - CDQ -ICT_ESI_U1_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12345678[ESI] - CDQ -ICT_ESI_U8_DISP8: -ICT_ESI_U4_DISP8: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12[ESI] - CDQ -ICT_ESI_U2_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12[ESI] - CDQ -ICT_ESI_U1_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12[ESI] - CDQ -ICT_EDI_U8_DISP32: -ICT_EDI_U4_DISP32: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12345678[EDI] - CDQ -ICT_EDI_U2_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12345678[EDI] - CDQ -ICT_EDI_U1_DISP32: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12345678[EDI] - CDQ -ICT_EDI_U8_DISP8: -ICT_EDI_U4_DISP8: - PUSH EDX - PUSH EAX - MOV EAX,U4 0x12[EDI] - CDQ -ICT_EDI_U2_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 0x12[EDI] - CDQ -ICT_EDI_U1_DISP8: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 0x12[EDI] - CDQ -ICT_DEREF_U8: -ICT_DEREF_U4: - MOV EAX,U4 [EAX] - CDQ -ICT_DEREF_U2: - MOVSX EAX,U2 [EAX] - CDQ -ICT_DEREF_U1: - MOVSX EAX,U1 [EAX] - CDQ -ICT_ESI_DEREF_U8: -ICT_ESI_DEREF_U4: - PUSH EDX - PUSH EAX - MOV EAX,U4 [ESI] - CDQ -ICT_ESI_DEREF_U2: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 [ESI] - CDQ -ICT_ESI_DEREF_U1: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 [ESI] - CDQ -ICT_EDI_DEREF_U8: -ICT_EDI_DEREF_U4: - PUSH EDX - PUSH EAX - MOV EAX,U4 [EDI] - CDQ -ICT_EDI_DEREF_U2: - PUSH EDX - PUSH EAX - MOVSX EAX,U2 [EDI] - CDQ -ICT_EDI_DEREF_U1: - PUSH EDX - PUSH EAX - MOVSX EAX,U1 [EDI] - CDQ -ICT_U8_PP: -ICT_U4_PP: - MOV EBX,EAX - MOV EAX,U4 [EBX] - INC U4 [EBX] - CDQ -ICT_U2_PP: - MOV EBX,EAX - MOVSX EAX,U2 [EBX] - INC U2 [EBX] - CDQ -ICT_U1_PP: - MOV EBX,EAX - MOVSX EAX,U1 [EBX] - INC U1 [EBX] - CDQ -ICT_U8_MM: -ICT_U4_MM: - MOV EBX,EAX - MOV EAX,U4 [EBX] - DEC U4 [EBX] - CDQ -ICT_U2_MM: - MOV EBX,EAX - MOVSX EAX,U2 [EBX] - DEC U2 [EBX] - CDQ -ICT_U1_MM: - MOV EBX,EAX - MOVSX EAX,U1 [EBX] - DEC U1 [EBX] - CDQ -ICT_PP_U8: -ICT_PP_U4: - INC U4 [EAX] - MOV EAX,U4 [EAX] - CDQ -ICT_PP_U2: - INC U2 [EAX] - MOVSX EAX,U2 [EAX] - CDQ -ICT_PP_U1: - INC U1 [EAX] - MOVSX EAX,U1 [EAX] - CDQ -ICT_MM_U8: -ICT_MM_U4: - DEC U4 [EAX] - MOV EAX,U4 [EAX] - CDQ -ICT_MM_U2: - DEC U2 [EAX] - MOVSX EAX,U2 [EAX] - CDQ -ICT_MM_U1: - DEC U1 [EAX] - MOVSX EAX,U1 [EAX] - CDQ -ICT_ESI_U4_PP: - PUSH EDX - PUSH EAX - MOV EAX,ESI - INC ESI - CDQ -ICT_ESI_U4_MM: - PUSH EDX - PUSH EAX - MOV EAX,ESI - DEC ESI - CDQ -ICT_ESI_PP_U4: - PUSH EDX - PUSH EAX - INC ESI - MOV EAX,ESI - CDQ -ICT_ESI_MM_U4: - PUSH EDX - PUSH EAX - DEC ESI - MOV EAX,ESI - CDQ -ICT_EDI_U4_PP: - PUSH EDX - PUSH EAX - MOV EAX,EDI - INC EDI - CDQ -ICT_EDI_U4_MM: - PUSH EDX - PUSH EAX - MOV EAX,EDI - DEC EDI - CDQ -ICT_EDI_PP_U4: - PUSH EDX - PUSH EAX - INC EDI - MOV EAX,EDI - CDQ -ICT_EDI_MM_U4: - PUSH EDX - PUSH EAX - DEC EDI - MOV EAX,EDI - CDQ -ICT_LEA_DISP32_EBP: -ICT_LEA_DISP8_EBP: -ICT_U8_DISP32_SCALED: -ICT_U4_DISP32_SCALED: - MOV EAX,U4 0x12345678[EAX*4] - CDQ -ICT_U2_DISP32_SCALED: - MOVSX EAX,U2 0x12345678[EAX*2] - CDQ -ICT_SHL: -ICT_SHR: - MOV ECX,EAX - POP EAX - POP EDX - SUB CL,32 - JNC @@SR7 - SHRD EAX,EDX - SAR EDX,CL - JMP ICT_SHL_CONSTANT1 -@@SR7: MOV EAX,EDX - OR EDX,EDX - MOV EDX,0 - JNS @@SR6 - DEC EDX -@@SR6: SHRD EAX,EDX -ICT_SHL_CONSTANT1: -ICT_SHL_CONSTANT2: -ICT_SHR_CONSTANT1: - MOV CL,0x12 - SHRD EAX,EDX - SAR EDX,CL -ICT_SHR_CONSTANT2: - MOV EAX,EDX - OR EDX,EDX - MOV EDX,0 - JNS @@SC1 - DEC EDX -@@SC1: MOV CL,0x12 - SHRD EAX,EDX -ICT_POWER: -ICT_MULTIPLICATION: - POP EBX - ADD ESP,4 - IMUL EBX -ICT_DIVISION: - MOV EBX,EAX - POP EAX - POP EDX - IDIV EBX - CDQ -ICT_REMAINDER: - MOV EBX,EAX - POP EAX - POP EDX - IDIV EBX - MOV EAX,EDX - CDQ -ICT_AND: -ICT_OR: -ICT_XOR: -ICT_ADDITION: -ICT_SUBTRACTION: -ICT_EQUAL_EQUAL: -ICT_NOT_EQUAL_TO: -ICT_LESS_THAN: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - MOV EAX,0 - JGE @@LT1 - INC EAX -@@LT1: XOR EDX,EDX -ICT_GREATER_THAN: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - MOV EAX,0 - JGE @@GT1 - INC EAX -@@GT1: XOR EDX,EDX -ICT_LESS_OR_EQUAL: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - MOV EAX,0 - JL @@LE1 - INC EAX -@@LE1: XOR EDX,EDX -ICT_GREATER_OR_EQUAL: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - MOV EAX,0 - JL @@GE1 - INC EAX -@@GE1: XOR EDX,EDX -ICT_AND_AND: -ICT_OR_OR: -ICT_XOR_XOR: -ICT_COLON: -ICT_QUESTION: -ICT_ASSIGN_U8: -ICT_ASSIGN_U4: -ICT_ASSIGN_U2: -ICT_ASSIGN_U1: -ICT_SHL_EQUAL_U8: -ICT_SHL_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV CL,AL - SAL U4 [EBX],CL - MOV EAX,U4 [EBX] - CDQ -ICT_SHL_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV CL,AL - SAL U2 [EBX],CL - MOVSX EAX,U2 [EBX] - CDQ -ICT_SHL_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV CL,AL - SAL U1 [EBX],CL - MOVSX EAX,U1 [EBX] - CDQ -ICT_SHR_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - SUB ECX,32 - JNC @@SR9 - SHRD EAX,EDX - SAR EDX,CL - JMP @@SR10 -@@SR9: MOV EAX,EDX - OR EDX,EDX - MOV EDX,0 - JNS @@SR8 - DEC EDX -@@SR8: SHRD EAX,EDX -@@SR10: MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -ICT_SHR_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV CL,AL - SAR U4 [EBX],CL - MOV EAX,U4 [EBX] - CDQ -ICT_SHR_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV CL,AL - SAR U2 [EBX],CL - MOVSX EAX,U2 [EBX] - CDQ -ICT_SHR_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV CL,AL - SAR U1 [EBX],CL - MOVSX EAX,U1 [EBX] - CDQ -ICT_MUL_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV EDX,U4 [EBX] - IMUL EDX - MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -ICT_MUL_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV EDX,U4 [EBX] - IMUL EDX - MOV U4 [EBX],EAX -ICT_MUL_EQUAL_U2: - POP EBX - ADD ESP,4 - MOVSX EDX,U2 [EBX] - IMUL EDX - MOV U2 [EBX],AX -ICT_MUL_EQUAL_U1: - POP EBX - ADD ESP,4 - MOVSX EDX,U1 [EBX] - IMUL EDX - MOV U1 [EBX],AL -ICT_DIV_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - IDIV ECX - MOV U4 [EBX],EAX - CDQ - MOV U4 4[EBX],EDX -ICT_DIV_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - CDQ - IDIV ECX - MOV U4 [EBX],EAX - CDQ -ICT_DIV_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOVSX EAX,U2 [EBX] - CDQ - IDIV ECX - MOV U2 [EBX],AX - MOVSX EAX,AX - CDQ -ICT_DIV_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOVSX EAX,U1 [EBX] - CDQ - IDIV ECX - MOV U1 [EBX],AL - MOVSX EAX,AL - CDQ -ICT_AND_EQUAL_U8: -ICT_AND_EQUAL_U4: -ICT_AND_EQUAL_U2: -ICT_AND_EQUAL_U1: -ICT_OR_EQUAL_U8: -ICT_OR_EQUAL_U4: -ICT_OR_EQUAL_U2: -ICT_OR_EQUAL_U1: -ICT_XOR_EQUAL_U8: -ICT_XOR_EQUAL_U4: -ICT_XOR_EQUAL_U2: -ICT_XOR_EQUAL_U1: -ICT_ADD_EQUAL_U8: -ICT_ADD_EQUAL_U4: - POP EBX - ADD ESP,4 - ADD U4 [EBX],EAX - MOV EAX,U4 [EBX] - CDQ -ICT_ADD_EQUAL_U2: - POP EBX - ADD ESP,4 - ADD U2 [EBX],AX - MOVSX EAX,U2 [EBX] - CDQ -ICT_ADD_EQUAL_U1: - POP EBX - ADD ESP,4 - ADD U1 [EBX],AL - MOVSX EAX,U1 [EBX] - CDQ -ICT_SUB_EQUAL_U8: -ICT_SUB_EQUAL_U4: - POP EBX - ADD ESP,4 - SUB U4 [EBX],EAX - MOV EAX,U4 [EBX] - CDQ -ICT_SUB_EQUAL_U2: - POP EBX - ADD ESP,4 - SUB U2 [EBX],AX - MOVSX EAX,U2 [EBX] - CDQ -ICT_SUB_EQUAL_U1: - POP EBX - ADD ESP,4 - SUB U1 [EBX],AL - MOVSX EAX,U1 [EBX] - CDQ -ICT_ESI_ASSIGN_U4: -ICT_ESI_SHL_EQUAL_U4: - MOV ECX,EAX - SHL ESI,CL - MOV EAX,ESI - CDQ -ICT_ESI_SHR_EQUAL_U4: - MOV ECX,EAX - SAR ESI,CL - MOV EAX,ESI - CDQ -ICT_ESI_MUL_EQUAL_U4: - MOV EDX,ESI - IMUL EDX - MOV ESI,EAX - CDQ -ICT_ESI_DIV_EQUAL_U4: - MOV ECX,EAX - MOV EAX,ESI - XOR EDX,EDX - IDIV ECX - MOV ESI,EAX - CDQ -ICT_ESI_AND_EQUAL_U4: - AND ESI,EAX - MOV EAX,ESI - CDQ -ICT_ESI_OR_EQUAL_U4: - OR ESI,EAX - MOV EAX,ESI - CDQ -ICT_ESI_XOR_EQUAL_U4: - XOR ESI,EAX - MOV EAX,ESI - CDQ -ICT_ESI_ADD_EQUAL_U4: - ADD ESI,EAX - MOV EAX,ESI - CDQ -ICT_ESI_SUB_EQUAL_U4: - SUB ESI,EAX - MOV EAX,ESI - CDQ -ICT_EDI_ASSIGN_U4: -ICT_EDI_SHL_EQUAL_U4: - MOV ECX,EAX - SHL EDI,CL - MOV EAX,EDI - CDQ -ICT_EDI_SHR_EQUAL_U4: - MOV ECX,EAX - SAR EDI,CL - MOV EAX,EDI - CDQ -ICT_EDI_MUL_EQUAL_U4: - MOV EDX,EDI - IMUL EDX - MOV EDI,EAX - CDQ -ICT_EDI_DIV_EQUAL_U4: - MOV ECX,EAX - MOV EAX,EDI - XOR EDX,EDX - IDIV ECX - MOV EDI,EAX - CDQ -ICT_EDI_AND_EQUAL_U4: - AND EDI,EAX - MOV EAX,EDI - CDQ -ICT_EDI_OR_EQUAL_U4: - OR EDI,EAX - MOV EAX,EDI - CDQ -ICT_EDI_XOR_EQUAL_U4: - XOR EDI,EAX - MOV EAX,EDI - CDQ -ICT_EDI_ADD_EQUAL_U4: - ADD EDI,EAX - MOV EAX,EDI - CDQ -ICT_EDI_SUB_EQUAL_U4: - SUB EDI,EAX - MOV EAX,EDI - CDQ -ICT_ADD64: -ICT_ADD32: -ICT_ADD8: -ICT_INC: -ICT_SUB64: -ICT_SUB32: -ICT_SUB8: -ICT_DEC: -ICT_ENTER: -ICT_LEAVE: -ICT_ENTER1: -ICT_LEAVE1: -ICT_ENTER2: -ICT_LEAVE2: -ICT_ADD_ESP32: -ICT_ADD_ESP8: -ICT_RET: -ICT_CALL: -ICT_CALL_INDIRECT: -ICT_CALL_INDIRECT2: -ICT_IRQ: -ICT_CLI: -ICT_STI: -ICT_GET_FLAGS: -ICT_SET_FLAGS: -ICT_GET_BASE_PTR: -ICT_SET_BASE_PTR: -ICT_GET_STACK_PTR: -ICT_SET_STACK_PTR: -ICT_GET_LABEL: -ICT_ABSOLUTE_ADDRESS: -ICT_LABEL: -ICT_TYPE: -ICT_BT: -ICT_BTS: -ICT_BTR: -ICT_BTC: -ICT_BSF: -ICT_BSR: -ICT_INSQUE: -ICT_INSQUE_REV: -ICT_REMQUE: -ICT_STRLEN: -ICT_MEMCPY: -ICT_MEMSET: -ICT_INPD: -ICT_INPW: -ICT_INP: -ICT_OUTPD: -ICT_OUTPW: -ICT_OUTP: -ICT_JMP: -ICT_SHORT_JMP: -ICT_SWITCH: -ICT_SKIPZ: -ICT_SKIPZ2: -ICT_SKIPNZ: -ICT_SKIPNZ2: -ICT_EQUAL_EQUAL_SKIPZ: -ICT_EQUAL_EQUAL_SKIPZ2: -ICT_NOT_EQUAL_TO_SKIPZ: -ICT_NOT_EQUAL_TO_SKIPZ2: -ICT_LESS_THAN_SKIPZ: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JGE ICT_LESS_THAN_SKIPZ -ICT_LESS_THAN_SKIPZ2: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JGE U4 FAR_AWAY -ICT_GREATER_THAN_SKIPZ: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JGE ICT_GREATER_THAN_SKIPZ -ICT_GREATER_THAN_SKIPZ2: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JGE U4 FAR_AWAY -ICT_LESS_OR_EQUAL_SKIPZ: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JL ICT_LESS_OR_EQUAL_SKIPZ -ICT_LESS_OR_EQUAL_SKIPZ2: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JL U4 FAR_AWAY -ICT_GREATER_OR_EQUAL_SKIPZ: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JL ICT_GREATER_OR_EQUAL_SKIPZ -ICT_GREATER_OR_EQUAL_SKIPZ2: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JL U4 FAR_AWAY -ICT_AND_AND_SKIPZ: -ICT_AND_AND_SKIPZ2: -ICT_AND_AND_SKIPNZ: -ICT_AND_AND_SKIPNZ2: -ICT_OR_OR_SKIPZ: -ICT_OR_OR_SKIPZ2: -ICT_OR_OR_SKIPNZ: -ICT_OR_OR_SKIPNZ2: -ICT_LEA_DISP32_ESI: -ICT_LEA_DISP8_ESI: -ICT_LEA_DISP32_EDI: -ICT_LEA_DISP8_EDI: -ICT_PUSH_U8: -ICT_PUSH_U4: -ICT_PUSH_U2: -ICT_PUSH_U1: -ICT_PUSH_NEG_U4: -ICT_PUSH_NEG_U2: -ICT_PUSH_NEG_U1: -ICT_PUSH_DOUBLE: -ICT_PUSH_U8_DISP32: -ICT_PUSH_U8_DISP8: -ICT_PUSH_ESI_U8_DISP32: -ICT_PUSH_ESI_U8_DISP8: -ICT_PUSH_EDI_U8_DISP32: -ICT_PUSH_EDI_U8_DISP8: -ICT_PUSH_DEREF_U8: -ICT_PUSH_U8_DISP32_SCALED: -ICT_BT_CONSTANT: -ICT_BTS_CONSTANT: -ICT_BTR_CONSTANT: -ICT_BTC_CONSTANT: -ICT_ESI_NEXT_EQUAL_U4: - PUSH EDX - PUSH EAX - MOV ESI,U4 [ESI] - MOV EAX,ESI - CDQ -ICT_EDI_NEXT_EQUAL_U4: - PUSH EDX - PUSH EAX - MOV EDI,U4 [EDI] - MOV EAX,EDI - CDQ -ICT_ADD_EQUAL_U8_CONSTANT_U1: -ICT_SUB_EQUAL_U8_CONSTANT_U1: -ICT_ADD_EQUAL_U4_CONSTANT_U1: - ADD U4 [EAX],0x12 - MOV EAX,U4 [EAX] - CDQ -ICT_ESI_ADD_EQUAL_U4_CONSTANT_U1: - PUSH EDX - PUSH EAX - ADD ESI,0x12 - MOV EAX,ESI - CDQ -ICT_EDI_ADD_EQUAL_U4_CONSTANT_U1: - PUSH EDX - PUSH EAX - ADD EDI,0x12 - MOV EAX,EDI - CDQ -ICT_TABLE_END: - - ALIGN 8,0x90 -UNSIGNED_CODE_TABLE:: - DU4 UCT_NULL; - DU4 UCT_NOP; - DU4 UCT_END_EXP; - DU4 UCT_ZERO; - DU4 UCT_U8; - DU4 UCT_U4; - DU4 UCT_U2; - DU4 UCT_U1; - DU4 UCT_DOUBLE; - DU4 UCT_STRING_CONSTANT; - DU4 UCT_EBP; - DU4 UCT_FS; - DU4 UCT_ESI; - DU4 UCT_EDI; - DU4 UCT_TO_DOUBLE; - DU4 UCT_TO_INT; - DU4 UCT_COM; - DU4 UCT_NOT; - DU4 UCT_UNARY_MINUS; - DU4 UCT_ADDRESS; - DU4 UCT_U8_DISP32; - DU4 UCT_U4_DISP32; - DU4 UCT_U2_DISP32; - DU4 UCT_U1_DISP32; - DU4 UCT_U8_DISP8; - DU4 UCT_U4_DISP8; - DU4 UCT_U2_DISP8; - DU4 UCT_U1_DISP8; - DU4 UCT_FS_U8_DISP32; - DU4 UCT_FS_U4_DISP32; - DU4 UCT_FS_U2_DISP32; - DU4 UCT_FS_U1_DISP32; - DU4 UCT_ESI_U8_DISP32; - DU4 UCT_ESI_U4_DISP32; - DU4 UCT_ESI_U2_DISP32; - DU4 UCT_ESI_U1_DISP32; - DU4 UCT_ESI_U8_DISP8; - DU4 UCT_ESI_U4_DISP8; - DU4 UCT_ESI_U2_DISP8; - DU4 UCT_ESI_U1_DISP8; - DU4 UCT_EDI_U8_DISP32; - DU4 UCT_EDI_U4_DISP32; - DU4 UCT_EDI_U2_DISP32; - DU4 UCT_EDI_U1_DISP32; - DU4 UCT_EDI_U8_DISP8; - DU4 UCT_EDI_U4_DISP8; - DU4 UCT_EDI_U2_DISP8; - DU4 UCT_EDI_U1_DISP8; - DU4 UCT_DEREF_U8; - DU4 UCT_DEREF_U4; - DU4 UCT_DEREF_U2; - DU4 UCT_DEREF_U1; - DU4 UCT_ESI_DEREF_U8; - DU4 UCT_ESI_DEREF_U4; - DU4 UCT_ESI_DEREF_U2; - DU4 UCT_ESI_DEREF_U1; - DU4 UCT_EDI_DEREF_U8; - DU4 UCT_EDI_DEREF_U4; - DU4 UCT_EDI_DEREF_U2; - DU4 UCT_EDI_DEREF_U1; - DU4 UCT_U8_PP; - DU4 UCT_U4_PP; - DU4 UCT_U2_PP; - DU4 UCT_U1_PP; - DU4 UCT_U8_MM; - DU4 UCT_U4_MM; - DU4 UCT_U2_MM; - DU4 UCT_U1_MM; - DU4 UCT_PP_U8; - DU4 UCT_PP_U4; - DU4 UCT_PP_U2; - DU4 UCT_PP_U1; - DU4 UCT_MM_U8; - DU4 UCT_MM_U4; - DU4 UCT_MM_U2; - DU4 UCT_MM_U1; - DU4 UCT_ESI_U4_PP; - DU4 UCT_ESI_U4_MM; - DU4 UCT_ESI_PP_U4; - DU4 UCT_ESI_MM_U4; - DU4 UCT_EDI_U4_PP; - DU4 UCT_EDI_U4_MM; - DU4 UCT_EDI_PP_U4; - DU4 UCT_EDI_MM_U4; - DU4 UCT_LEA_DISP32_EBP; - DU4 UCT_LEA_DISP8_EBP; - DU4 UCT_U8_DISP32_SCALED; - DU4 UCT_U4_DISP32_SCALED; - DU4 UCT_U2_DISP32_SCALED; - DU4 UCT_SHL; - DU4 UCT_SHR; - DU4 UCT_SHL_CONSTANT1; - DU4 UCT_SHL_CONSTANT2; - DU4 UCT_SHR_CONSTANT1; - DU4 UCT_SHR_CONSTANT2; - DU4 UCT_POWER; - DU4 UCT_MULTIPLICATION; - DU4 UCT_DIVISION; - DU4 UCT_REMAINDER; - DU4 UCT_AND; - DU4 UCT_OR; - DU4 UCT_XOR; - DU4 UCT_ADDITION; - DU4 UCT_SUBTRACTION; - DU4 UCT_EQUAL_EQUAL; - DU4 UCT_NOT_EQUAL_TO; - DU4 UCT_LESS_THAN; - DU4 UCT_GREATER_THAN; - DU4 UCT_LESS_OR_EQUAL; - DU4 UCT_GREATER_OR_EQUAL; - DU4 UCT_AND_AND; - DU4 UCT_OR_OR; - DU4 UCT_XOR_XOR; - DU4 UCT_COLON; - DU4 UCT_QUESTION; - DU4 UCT_ASSIGN_U8; - DU4 UCT_ASSIGN_U4; - DU4 UCT_ASSIGN_U2; - DU4 UCT_ASSIGN_U1; - DU4 UCT_SHL_EQUAL_U8; - DU4 UCT_SHL_EQUAL_U4; - DU4 UCT_SHL_EQUAL_U2; - DU4 UCT_SHL_EQUAL_U1; - DU4 UCT_SHR_EQUAL_U8; - DU4 UCT_SHR_EQUAL_U4; - DU4 UCT_SHR_EQUAL_U2; - DU4 UCT_SHR_EQUAL_U1; - DU4 UCT_MUL_EQUAL_U8; - DU4 UCT_MUL_EQUAL_U4; - DU4 UCT_MUL_EQUAL_U2; - DU4 UCT_MUL_EQUAL_U1; - DU4 UCT_DIV_EQUAL_U8; - DU4 UCT_DIV_EQUAL_U4; - DU4 UCT_DIV_EQUAL_U2; - DU4 UCT_DIV_EQUAL_U1; - DU4 UCT_AND_EQUAL_U8; - DU4 UCT_AND_EQUAL_U4; - DU4 UCT_AND_EQUAL_U2; - DU4 UCT_AND_EQUAL_U1; - DU4 UCT_OR_EQUAL_U8; - DU4 UCT_OR_EQUAL_U4; - DU4 UCT_OR_EQUAL_U2; - DU4 UCT_OR_EQUAL_U1; - DU4 UCT_XOR_EQUAL_U8; - DU4 UCT_XOR_EQUAL_U4; - DU4 UCT_XOR_EQUAL_U2; - DU4 UCT_XOR_EQUAL_U1; - DU4 UCT_ADD_EQUAL_U8; - DU4 UCT_ADD_EQUAL_U4; - DU4 UCT_ADD_EQUAL_U2; - DU4 UCT_ADD_EQUAL_U1; - DU4 UCT_SUB_EQUAL_U8; - DU4 UCT_SUB_EQUAL_U4; - DU4 UCT_SUB_EQUAL_U2; - DU4 UCT_SUB_EQUAL_U1; - DU4 UCT_ESI_ASSIGN_U4; - DU4 UCT_ESI_SHL_EQUAL_U4; - DU4 UCT_ESI_SHR_EQUAL_U4; - DU4 UCT_ESI_MUL_EQUAL_U4; - DU4 UCT_ESI_DIV_EQUAL_U4; - DU4 UCT_ESI_AND_EQUAL_U4; - DU4 UCT_ESI_OR_EQUAL_U4; - DU4 UCT_ESI_XOR_EQUAL_U4; - DU4 UCT_ESI_ADD_EQUAL_U4; - DU4 UCT_ESI_SUB_EQUAL_U4; - DU4 UCT_EDI_ASSIGN_U4; - DU4 UCT_EDI_SHL_EQUAL_U4; - DU4 UCT_EDI_SHR_EQUAL_U4; - DU4 UCT_EDI_MUL_EQUAL_U4; - DU4 UCT_EDI_DIV_EQUAL_U4; - DU4 UCT_EDI_AND_EQUAL_U4; - DU4 UCT_EDI_OR_EQUAL_U4; - DU4 UCT_EDI_XOR_EQUAL_U4; - DU4 UCT_EDI_ADD_EQUAL_U4; - DU4 UCT_EDI_SUB_EQUAL_U4; - DU4 UCT_ADD64; - DU4 UCT_ADD32; - DU4 UCT_ADD8; - DU4 UCT_INC; - DU4 UCT_SUB64; - DU4 UCT_SUB32; - DU4 UCT_SUB8; - DU4 UCT_DEC; - DU4 UCT_ENTER; - DU4 UCT_LEAVE; - DU4 UCT_ENTER1; - DU4 UCT_LEAVE1; - DU4 UCT_ENTER2; - DU4 UCT_LEAVE2; - DU4 UCT_ADD_ESP32; - DU4 UCT_ADD_ESP8; - DU4 UCT_RET; - DU4 UCT_CALL; - DU4 UCT_CALL_INDIRECT; - DU4 UCT_CALL_INDIRECT2; - DU4 UCT_IRQ; - DU4 UCT_CLI; - DU4 UCT_STI; - DU4 UCT_GET_FLAGS; - DU4 UCT_SET_FLAGS; - DU4 UCT_GET_BASE_PTR; - DU4 UCT_SET_BASE_PTR; - DU4 UCT_GET_STACK_PTR; - DU4 UCT_SET_STACK_PTR; - DU4 UCT_GET_LABEL; - DU4 UCT_ABSOLUTE_ADDRESS; - DU4 UCT_LABEL; - DU4 UCT_TYPE; - DU4 UCT_BT; - DU4 UCT_BTS; - DU4 UCT_BTR; - DU4 UCT_BTC; - DU4 UCT_BSF; - DU4 UCT_BSR; - DU4 UCT_INSQUE; - DU4 UCT_INSQUE_REV; - DU4 UCT_REMQUE; - DU4 UCT_STRLEN; - DU4 UCT_MEMCPY; - DU4 UCT_MEMSET; - DU4 UCT_INPD; - DU4 UCT_INPW; - DU4 UCT_INP; - DU4 UCT_OUTPD; - DU4 UCT_OUTPW; - DU4 UCT_OUTP; - DU4 UCT_JMP; - DU4 UCT_SHORT_JMP; - DU4 UCT_SWITCH; - DU4 UCT_SKIPZ; - DU4 UCT_SKIPZ2; - DU4 UCT_SKIPNZ; - DU4 UCT_SKIPNZ2; - DU4 UCT_EQUAL_EQUAL_SKIPZ; - DU4 UCT_EQUAL_EQUAL_SKIPZ2; - DU4 UCT_NOT_EQUAL_TO_SKIPZ; - DU4 UCT_NOT_EQUAL_TO_SKIPZ2; - DU4 UCT_LESS_THAN_SKIPZ; - DU4 UCT_LESS_THAN_SKIPZ2; - DU4 UCT_GREATER_THAN_SKIPZ; - DU4 UCT_GREATER_THAN_SKIPZ2; - DU4 UCT_LESS_OR_EQUAL_SKIPZ; - DU4 UCT_LESS_OR_EQUAL_SKIPZ2; - DU4 UCT_GREATER_OR_EQUAL_SKIPZ; - DU4 UCT_GREATER_OR_EQUAL_SKIPZ2; - DU4 UCT_AND_AND_SKIPZ; - DU4 UCT_AND_AND_SKIPZ2; - DU4 UCT_AND_AND_SKIPNZ; - DU4 UCT_AND_AND_SKIPNZ2; - DU4 UCT_OR_OR_SKIPZ; - DU4 UCT_OR_OR_SKIPZ2; - DU4 UCT_OR_OR_SKIPNZ; - DU4 UCT_OR_OR_SKIPNZ2; - DU4 UCT_LEA_DISP32_ESI; - DU4 UCT_LEA_DISP8_ESI; - DU4 UCT_LEA_DISP32_EDI; - DU4 UCT_LEA_DISP8_EDI; - DU4 UCT_PUSH_U8; - DU4 UCT_PUSH_U4; - DU4 UCT_PUSH_U2; - DU4 UCT_PUSH_U1; - DU4 UCT_PUSH_NEG_U4; - DU4 UCT_PUSH_NEG_U2; - DU4 UCT_PUSH_NEG_U1; - DU4 UCT_PUSH_DOUBLE; - DU4 UCT_PUSH_U8_DISP32; - DU4 UCT_PUSH_U8_DISP8; - DU4 UCT_PUSH_ESI_U8_DISP32; - DU4 UCT_PUSH_ESI_U8_DISP8; - DU4 UCT_PUSH_EDI_U8_DISP32; - DU4 UCT_PUSH_EDI_U8_DISP8; - DU4 UCT_PUSH_DEREF_U8; - DU4 UCT_PUSH_U8_DISP32_SCALED; - DU4 UCT_BT_CONSTANT; - DU4 UCT_BTS_CONSTANT; - DU4 UCT_BTR_CONSTANT; - DU4 UCT_BTC_CONSTANT; - DU4 UCT_ESI_NEXT_EQUAL_U4; - DU4 UCT_EDI_NEXT_EQUAL_U4; - DU4 UCT_ADD_EQUAL_U8_CONSTANT_U1; - DU4 UCT_SUB_EQUAL_U8_CONSTANT_U1; - DU4 UCT_ADD_EQUAL_U4_CONSTANT_U1; - DU4 UCT_ESI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 UCT_EDI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 UCT_TABLE_END; -UCT_NULL: -UCT_NOP: -UCT_END_EXP: -UCT_ZERO: - PUSH EDX - PUSH EAX - XOR EAX,EAX - XOR EDX,EDX -UCT_U8: - PUSH EDX - PUSH EAX - MOV EDX,0x12345678 - MOV EAX,0x9ABCDEF0 -UCT_U4: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,0x12345678 -UCT_U2: //not used -UCT_U1: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12[EDX] -UCT_DOUBLE: - PUSH EDX - PUSH EAX - MOV EDX,0x12345678 - MOV EAX,0x9ABCDEF0 -UCT_STRING_CONSTANT: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,0x12345678 -UCT_EBP: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,EBP -UCT_FS: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 FS:[TSS_ABSOLUTE_ADDRESS] -UCT_ESI: - PUSH EDX - PUSH EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_EDI: - PUSH EDX - PUSH EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_TO_DOUBLE: - PUSH EDX - PUSH EAX - PUSH EBP - MOV EBP,ESP - FILD U4 4[EBP] - FSTP U4 4[EBP] - POP EBP - POP EAX - POP EDX -UCT_TO_INT: - PUSH EDX - PUSH EAX - PUSH EBP - MOV EBP,ESP - FLD U4 4[EBP] - FISTP U4 4[EBP] - POP EBP - POP EAX - POP EDX -UCT_COM: - NOT EAX - NOT EDX -UCT_NOT: - OR EAX,EDX - MOV EAX,1 - JZ @@N1 - XOR EAX,EAX -@@N1: XOR EDX,EDX -UCT_UNARY_MINUS: - NEG EAX - JC @@UM2 - DEC EDX -@@UM2: NOT EDX -UCT_ADDRESS: -UCT_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[EBP] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_U4_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12345678[EBP] -UCT_U2_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12345678[EBP] -UCT_U1_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12345678[EBP] -UCT_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[EBP] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_U4_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12[EBP] -UCT_U2_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12[EBP] -UCT_U1_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12[EBP] -UCT_FS_U8_DISP32: - PUSH EDX - PUSH EAX - MOV EDX,U4 FS:[0x12345678+4] - MOV EAX,U4 FS:[0x12345678] -UCT_FS_U4_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 FS:[0x12345678] -UCT_FS_U2_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 FS:[0x12345678] -UCT_FS_U1_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 FS:[0x12345678] -UCT_ESI_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[ESI] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_ESI_U4_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12345678[ESI] -UCT_ESI_U2_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12345678[ESI] -UCT_ESI_U1_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12345678[ESI] -UCT_ESI_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[ESI] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_ESI_U4_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12[ESI] -UCT_ESI_U2_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12[ESI] -UCT_ESI_U1_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12[ESI] -UCT_EDI_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[EDI] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_EDI_U4_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12345678[EDI] -UCT_EDI_U2_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12345678[EDI] -UCT_EDI_U1_DISP32: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12345678[EDI] -UCT_EDI_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[EDI] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_EDI_U4_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 0x12[EDI] -UCT_EDI_U2_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 0x12[EDI] -UCT_EDI_U1_DISP8: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 0x12[EDI] -UCT_DEREF_U8: - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_DEREF_U4: - XOR EDX,EDX - MOV EAX,U4 [EAX] -UCT_DEREF_U2: - XOR EDX,EDX - MOVZX EAX,U2 [EAX] -UCT_DEREF_U1: - XOR EDX,EDX - MOVZX EAX,U1 [EAX] -UCT_ESI_DEREF_U8: - PUSH EDX - PUSH EAX - MOV EDX,U4 4[ESI] - MOV EAX,U4 [ESI] -UCT_ESI_DEREF_U4: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 [ESI] -UCT_ESI_DEREF_U2: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 [ESI] -UCT_ESI_DEREF_U1: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 [ESI] -UCT_EDI_DEREF_U8: - PUSH EDX - PUSH EAX - MOV EDX,U4 4[EDI] - MOV EAX,U4 [EDI] -UCT_EDI_DEREF_U4: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,U4 [EDI] -UCT_EDI_DEREF_U2: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U2 [EDI] -UCT_EDI_DEREF_U1: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOVZX EAX,U1 [EDI] -UCT_U8_PP: - MOV EBX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - INC U4 [EBX] - JNZ UCT_U4_PP - INC U4 4[EBX] -UCT_U4_PP: - MOV EBX,EAX - MOV EAX,U4 [EBX] - INC U4 [EBX] - XOR EDX,EDX -UCT_U2_PP: - MOV EBX,EAX - MOVZX EAX,U2 [EBX] - INC U2 [EBX] - XOR EDX,EDX -UCT_U1_PP: - MOV EBX,EAX - MOVZX EAX,U1 [EBX] - INC U1 [EBX] - XOR EDX,EDX -UCT_U8_MM: - MOV EBX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - OR EAX,EAX - JNZ @@U8M - DEC U4 4[EBX] -@@U8M: DEC U4 [EBX] -UCT_U4_MM: - MOV EBX,EAX - MOV EAX,U4 [EBX] - DEC U4 [EBX] - XOR EDX,EDX -UCT_U2_MM: - MOV EBX,EAX - MOVZX EAX,U2 [EBX] - DEC U2 [EBX] - XOR EDX,EDX -UCT_U1_MM: - MOV EBX,EAX - MOVZX EAX,U1 [EBX] - DEC U1 [EBX] - XOR EDX,EDX -UCT_PP_U8: - MOV EBX,EAX - INC U4 [EBX] - JNZ @@UP8 - INC U4 4[EBX] -@@UP8: MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] -UCT_PP_U4: - INC U4 [EAX] - MOV EAX,U4 [EAX] - XOR EDX,EDX -UCT_PP_U2: - INC U2 [EAX] - MOVZX EAX,U2 [EAX] - XOR EDX,EDX -UCT_PP_U1: - INC U1 [EAX] - MOVZX EAX,U1 [EAX] - XOR EDX,EDX -UCT_MM_U8: - MOV EBX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - OR EAX,EAX - JNZ @@UM8 - DEC EDX -@@UM8: DEC EAX - MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -UCT_MM_U4: - DEC U4 [EAX] - MOV EAX,U4 [EAX] - XOR EDX,EDX -UCT_MM_U2: - DEC U2 [EAX] - MOVZX EAX,U2 [EAX] - XOR EDX,EDX -UCT_MM_U1: - DEC U1 [EAX] - MOVZX EAX,U1 [EAX] - XOR EDX,EDX -UCT_ESI_U4_PP: - PUSH EDX - PUSH EAX - MOV EAX,ESI - INC ESI - XOR EDX,EDX -UCT_ESI_U4_MM: - PUSH EDX - PUSH EAX - MOV EAX,ESI - DEC ESI - XOR EDX,EDX -UCT_ESI_PP_U4: - PUSH EDX - PUSH EAX - INC ESI - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_MM_U4: - PUSH EDX - PUSH EAX - DEC ESI - MOV EAX,ESI - XOR EDX,EDX -UCT_EDI_U4_PP: - PUSH EDX - PUSH EAX - MOV EAX,EDI - INC EDI - XOR EDX,EDX -UCT_EDI_U4_MM: - PUSH EDX - PUSH EAX - MOV EAX,EDI - DEC EDI - XOR EDX,EDX -UCT_EDI_PP_U4: - PUSH EDX - PUSH EAX - INC EDI - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_MM_U4: - PUSH EDX - PUSH EAX - DEC EDI - MOV EAX,EDI - XOR EDX,EDX -UCT_LEA_DISP32_EBP: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12345678[EBP] -UCT_LEA_DISP8_EBP: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12[EBP] -UCT_U8_DISP32_SCALED: - LEA EAX,U4 0x12345678[EAX*8] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -UCT_U4_DISP32_SCALED: - MOV EAX,U4 0x12345678[EAX*4] - XOR EDX,EDX -UCT_U2_DISP32_SCALED: - MOVZX EAX,U2 0x12345678[EAX*2] - XOR EDX,EDX -UCT_SHL: - MOV ECX,EAX - POP EAX - POP EDX - SUB ECX,32 - JNC @@SL5 - SHLD EDX,EAX - SHL EAX,CL - JMP UCT_SHR -@@SL5: MOV EDX,EAX - XOR EAX,EAX - SHL EDX,CL -UCT_SHR: - MOV ECX,EAX - POP EAX - POP EDX - SUB CL,32 - JNC @@SR5 - SHRD EAX,EDX - SHR EDX,CL - JMP UCT_SHL_CONSTANT1 -@@SR5: MOV EAX,EDX - XOR EDX,EDX - SHR EAX,CL -UCT_SHL_CONSTANT1: - MOV CL,0x12 - SHLD EDX,EAX - SHL EAX,CL -UCT_SHL_CONSTANT2: - MOV EDX,EAX - MOV CL,0x12 - XOR EAX,EAX - SHL EDX,CL -UCT_SHR_CONSTANT1: - MOV CL,0x12 - SHRD EAX,EDX - SHR EDX,CL -UCT_SHR_CONSTANT2: - MOV EAX,EDX - MOV CL,0x12 - XOR EDX,EDX - SHR EAX,CL -UCT_POWER: -UCT_MULTIPLICATION: - POP EBX - ADD ESP,4 - MUL EBX -UCT_DIVISION: - MOV EBX,EAX - POP EAX - POP EDX - DIV EBX - XOR EDX,EDX -UCT_REMAINDER: - MOV EBX,EAX - POP EAX - POP EDX - DIV EBX - MOV EAX,EDX - XOR EDX,EDX -UCT_AND: - POP EBX - POP ECX - AND EAX,EBX - AND EDX,ECX -UCT_OR: - POP EBX - POP ECX - OR EAX,EBX - OR EDX,ECX -UCT_XOR: - POP EBX - POP ECX - XOR EAX,EBX - XOR EDX,ECX -UCT_ADDITION: - POP EBX - POP ECX - ADD EAX,EBX - ADC EDX,ECX -UCT_SUBTRACTION: - POP EBX - POP ECX - XCHG EAX,EBX - XCHG EDX,ECX - SUB EAX,EBX - SBB EDX,ECX -UCT_EQUAL_EQUAL: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - XOR EDX,EDX - XOR EAX,EAX - OR EBX,ECX - JNZ UCT_NOT_EQUAL_TO - INC EAX -UCT_NOT_EQUAL_TO: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - XOR EDX,EDX - XOR EAX,EAX - OR EBX,ECX - JZ UCT_LESS_THAN - INC EAX -UCT_LESS_THAN: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - MOV EAX,0 - ADC EAX,0 - XOR EDX,EDX -UCT_GREATER_THAN: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - MOV EAX,0 - ADC EAX,0 - XOR EDX,EDX -UCT_LESS_OR_EQUAL: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - MOV EAX,1 - SBB EAX,0 - XOR EDX,EDX -UCT_GREATER_OR_EQUAL: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - MOV EAX,1 - SBB EAX,0 - XOR EDX,EDX -UCT_AND_AND: - POP EBX - POP ECX - OR EAX,EDX - OR EBX,ECX - AND EAX,EAX - JZ @@AA2 - XOR EAX,EAX - AND EBX,EBX - JZ @@AA2 - INC EAX -@@AA2: XOR EDX,EDX -UCT_OR_OR: - POP EBX - POP ECX - OR EDX,ECX - OR EAX,EBX - OR EAX,EDX - JZ @@OO2 - MOV EAX,1 -@@OO2: XOR EDX,EDX -UCT_XOR_XOR: - POP EBX - POP ECX - OR EAX,EDX - JZ @@XX1 - MOV EAX,1 -@@XX1: OR EBX,ECX - JZ @@XX2 - MOV EBX,1 -@@XX2: XOR EAX,EBX - XOR EDX,EDX -UCT_COLON: - PUSH EBP - MOV EBP,ESP - MOV EBX,12[EBP] - OR EBX,EBX - JZ @@C2 - MOV EAX,4[EBP] - MOV EDX,8[EBP] -@@C2: POP EBP - ADD ESP,16 -UCT_QUESTION: -UCT_ASSIGN_U8: - POP EBX - ADD ESP,4 - MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -UCT_ASSIGN_U4: - POP EBX - ADD ESP,4 - MOV U4 [EBX],EAX -UCT_ASSIGN_U2: - POP EBX - ADD ESP,4 - MOV U2 [EBX],AX -UCT_ASSIGN_U1: - POP EBX - ADD ESP,4 - MOV U1 [EBX],AL -UCT_SHL_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - SUB ECX,32 - JNC @@SL6 - SHLD EDX,EAX - SHL EAX,CL - JMP @@SL7 -@@SL6: MOV EDX,EAX - XOR EAX,EAX - SHL EDX,CL -@@SL7: MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -UCT_SHL_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV CL,AL - SHL U4 [EBX],CL - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_SHL_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV CL,AL - SHL U2 [EBX],CL - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_SHL_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV CL,AL - SHL U1 [EBX],CL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_SHR_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4[EBX] - MOV EDX,U4 4[EBX] - SUB ECX,32 - JNC @@SR8 - SHRD EAX,EDX - SHR EDX,CL - JMP @@SR9 -@@SR8: MOV EAX,EDX - XOR EDX,EDX - SHR EAX,CL -@@SR9: MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -UCT_SHR_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV CL,AL - SHR U4 [EBX],CL - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_SHR_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV CL,AL - SHR U2 [EBX],CL - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_SHR_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV CL,AL - SHR U1 [EBX],CL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_MUL_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV EDX,U4 [EBX] - MUL EDX - MOV U4 [EBX],EAX - MOV U4 4[EBX],EDX -UCT_MUL_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV EDX,U4 [EBX] - MUL EDX - MOV U4 [EBX],EAX - XOR EDX,EDX -UCT_MUL_EQUAL_U2: - POP EBX - ADD ESP,4 - MOVZX EDX,U2 [EBX] - MUL EDX - MOV U2 [EBX],AX - MOVZX EAX,AX - XOR EDX,EDX -UCT_MUL_EQUAL_U1: - POP EBX - ADD ESP,4 - MOVZX EDX,U1 [EBX] - MUL EDX - MOV U1 [EBX],AL - MOVZX EAX,AL - XOR EDX,EDX -UCT_DIV_EQUAL_U8: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] - DIV ECX - MOV U4 [EBX],EAX - XOR EDX,EDX - MOV U4 4[EBX],EDX -UCT_DIV_EQUAL_U4: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX - DIV ECX - MOV U4 [EBX],EAX - XOR EDX,EDX -UCT_DIV_EQUAL_U2: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX - DIV ECX - MOV U2 [EBX],AX - MOVZX EAX,AX - XOR EDX,EDX -UCT_DIV_EQUAL_U1: - POP EBX - ADD ESP,4 - MOV ECX,EAX - MOVZX EAX,U1 [EBX] - XOR EDX,EDX - DIV ECX - MOV U1 [EBX],AL - MOVZX EAX,AL - XOR EDX,EDX -UCT_AND_EQUAL_U8: - POP EBX - ADD ESP,4 - AND U4 [EBX],EAX - MOV EAX,U4 [EBX] - AND U4 4[EBX],EDX - MOV EDX,U4 4[EBX] -UCT_AND_EQUAL_U4: - POP EBX - ADD ESP,4 - AND U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_AND_EQUAL_U2: - POP EBX - ADD ESP,4 - AND U2 [EBX],AX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_AND_EQUAL_U1: - POP EBX - ADD ESP,4 - AND U1 [EBX],AL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_OR_EQUAL_U8: - POP EBX - ADD ESP,4 - OR U4 [EBX],EAX - MOV EAX,U4 [EBX] - OR U4 4[EBX],EDX - MOV EDX,U4 4[EBX] -UCT_OR_EQUAL_U4: - POP EBX - ADD ESP,4 - OR U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_OR_EQUAL_U2: - POP EBX - ADD ESP,4 - OR U2 [EBX],AX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_OR_EQUAL_U1: - POP EBX - ADD ESP,4 - OR U1 [EBX],AL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_XOR_EQUAL_U8: - POP EBX - ADD ESP,4 - XOR U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR U4 4[EBX],EDX - MOV EDX,U4 4[EBX] -UCT_XOR_EQUAL_U4: - POP EBX - ADD ESP,4 - XOR U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_XOR_EQUAL_U2: - POP EBX - ADD ESP,4 - XOR U2 [EBX],AX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_XOR_EQUAL_U1: - POP EBX - ADD ESP,4 - XOR U1 [EBX],AL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_ADD_EQUAL_U8: - POP EBX - ADD ESP,4 - ADD U4 [EBX],EAX - MOV EAX,U4 [EBX] - ADC U4 4[EBX],EDX - MOV EDX,U4 4[EBX] -UCT_ADD_EQUAL_U4: - POP EBX - ADD ESP,4 - ADD U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_ADD_EQUAL_U2: - POP EBX - ADD ESP,4 - ADD U2 [EBX],AX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_ADD_EQUAL_U1: - POP EBX - ADD ESP,4 - ADD U1 [EBX],AL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_SUB_EQUAL_U8: - POP EBX - ADD ESP,4 - SUB U4 [EBX],EAX - MOV EAX,U4 [EBX] - SBB U4 4[EBX],EDX - MOV EDX,U4 4[EBX] -UCT_SUB_EQUAL_U4: - POP EBX - ADD ESP,4 - SUB U4 [EBX],EAX - MOV EAX,U4 [EBX] - XOR EDX,EDX -UCT_SUB_EQUAL_U2: - POP EBX - ADD ESP,4 - SUB U2 [EBX],AX - MOVZX EAX,U2 [EBX] - XOR EDX,EDX -UCT_SUB_EQUAL_U1: - POP EBX - ADD ESP,4 - SUB U1 [EBX],AL - MOVZX EAX,U1 [EBX] - XOR EDX,EDX -UCT_ESI_ASSIGN_U4: - MOV ESI,EAX -UCT_ESI_SHL_EQUAL_U4: - MOV ECX,EAX - SHL ESI,CL - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_SHR_EQUAL_U4: - MOV ECX,EAX - SHR ESI,CL - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_MUL_EQUAL_U4: - MOV EDX,ESI - MUL EDX - MOV ESI,EAX - XOR EDX,EDX -UCT_ESI_DIV_EQUAL_U4: - MOV ECX,EAX - MOV EAX,ESI - XOR EDX,EDX - DIV ECX - MOV ESI,EAX - XOR EDX,EDX -UCT_ESI_AND_EQUAL_U4: - AND ESI,EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_OR_EQUAL_U4: - OR ESI,EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_XOR_EQUAL_U4: - XOR ESI,EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_ADD_EQUAL_U4: - ADD ESI,EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_ESI_SUB_EQUAL_U4: - SUB ESI,EAX - MOV EAX,ESI - XOR EDX,EDX -UCT_EDI_ASSIGN_U4: - MOV EDI,EAX -UCT_EDI_SHL_EQUAL_U4: - MOV ECX,EAX - SHL EDI,CL - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_SHR_EQUAL_U4: - MOV ECX,EAX - SHR EDI,CL - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_MUL_EQUAL_U4: - MOV EDX,EDI - MUL EDX - MOV EDI,EAX - XOR EDX,EDX -UCT_EDI_DIV_EQUAL_U4: - MOV ECX,EAX - MOV EAX,EDI - XOR EDX,EDX - DIV ECX - MOV EDI,EAX - XOR EDX,EDX -UCT_EDI_AND_EQUAL_U4: - AND EDI,EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_OR_EQUAL_U4: - OR EDI,EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_XOR_EQUAL_U4: - XOR EDI,EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_ADD_EQUAL_U4: - ADD EDI,EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_EDI_SUB_EQUAL_U4: - SUB EDI,EAX - MOV EAX,EDI - XOR EDX,EDX -UCT_ADD64: - ADD EAX,0x12345678 - ADC EDX,0 //TODO -UCT_ADD32: - ADD EAX,0x12345678 - ADC EDX,0 -UCT_ADD8: - ADD EAX,0x12 - ADC EDX,0 -UCT_INC: - INC EAX - JNZ UCT_SUB64 - INC EDX -UCT_SUB64: - SUB EAX,0x12345678 - SBB EDX,0 //TODO -UCT_SUB32: - SUB EAX,0x12345678 - SBB EDX,0 -UCT_SUB8: - SUB EAX,0x12 - SBB EDX,0 -UCT_DEC: - OR EAX,EAX - JNZ @@UD2 - DEC EDX -@@UD2: DEC EAX -UCT_ENTER: - PUSH EBP - MOV EBP,ESP - SUB ESP,0x012345678 -UCT_LEAVE: - ADD ESP,0x012345678 - POP EBP - RET -UCT_ENTER1: - PUSH EBP - MOV EBP,ESP - SUB ESP,0x012345678 - PUSH ESI - MOV ESI,U4 0x12345678[EBP] -UCT_LEAVE1: - POP ESI - ADD ESP,0x012345678 - POP EBP - RET -UCT_ENTER2: - PUSH EBP - MOV EBP,ESP - SUB ESP,0x012345678 - PUSH ESI - PUSH EDI - MOV ESI,U4 0x12345678[EBP] - MOV EDI,U4 0x12345678[EBP] -UCT_LEAVE2: - POP EDI - POP ESI - ADD ESP,0x012345678 - POP EBP - RET -UCT_ADD_ESP32: - ADD ESP,0x12345678 -UCT_ADD_ESP8: - ADD ESP,0x12 -UCT_RET: - RET -UCT_CALL: - PUSH EDX - PUSH EAX - CALL UCT_CALL -UCT_CALL_INDIRECT: - PUSH EDX - PUSH EAX - MOV EAX,ESP - CALL U4 0x12345678[EAX] -UCT_CALL_INDIRECT2: - PUSH EDX - PUSH EAX - CALL U4 [0x12345678] -UCT_IRQ: - INT I_COUT //Gets patched -UCT_CLI: - PUSH EDX - PUSH EAX - CLI -UCT_STI: - PUSH EDX - PUSH EAX - STI -UCT_GET_FLAGS: - PUSH EDX - PUSH EAX - PUSHFD - POP EAX - XOR EDX,EDX -UCT_SET_FLAGS: - PUSH EAX - POPFD -UCT_GET_BASE_PTR: - PUSH EDX - PUSH EAX - MOV EAX,EBP - XOR EDX,EDX -UCT_SET_BASE_PTR: - MOV EBP,EAX -UCT_GET_STACK_PTR: - PUSH EDX - PUSH EAX - MOV EAX,ESP - XOR EDX,EDX -UCT_SET_STACK_PTR: - MOV ESP,EAX -UCT_GET_LABEL: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,0x12345678 -UCT_ABSOLUTE_ADDRESS: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,0x12345678 -UCT_LABEL: -UCT_TYPE: - PUSH EDX - PUSH EAX - XOR EDX,EDX - MOV EAX,0x12345678 -UCT_BT: - MOV EBX,EAX - POP EDX - ADD ESP,4 - XOR EAX,EAX - BT U4 [EBX],EDX - ADC EAX,0 - XOR EDX,EDX -UCT_BTS: - MOV EBX,EAX - POP EDX - ADD ESP,4 - XOR EAX,EAX - BTS U4 [EBX],EDX - ADC EAX,0 - XOR EDX,EDX -UCT_BTR: - MOV EBX,EAX - POP EDX - ADD ESP,4 - XOR EAX,EAX - BTR U4 [EBX],EDX - ADC EAX,0 - XOR EDX,EDX -UCT_BTC: - MOV EBX,EAX - POP EDX - ADD ESP,4 - XOR EAX,EAX - BTC U4 [EBX],EDX - ADC EAX,0 - XOR EDX,EDX -UCT_BSF: - BSF EAX,EAX - JNZ @@BSF1 - NOT EAX -@@BSF1: CDQ -UCT_BSR: - BSR EAX,EAX - JNZ @@BSR1 - NOT EAX -@@BSR1: CDQ -UCT_INSQUE: - POP EDX - ADD ESP,4 - MOV EBX,[EDX] - MOV [EDX],EAX - MOV [EAX],EBX - MOV 4[EAX],EDX - MOV 4[EBX],EAX -UCT_INSQUE_REV: - POP EDX - ADD ESP,4 - MOV EBX,4[EDX] - MOV [EBX],EAX - MOV [EAX],EDX - MOV 4[EAX],EBX - MOV 4[EDX],EAX -UCT_REMQUE: - MOV EBX,[EAX] - MOV EDX,4[EAX] - MOV [EDX],EBX - MOV 4[EBX],EDX -UCT_STRLEN: - MOV EDX,EAX -@@SL3: MOV BL,U1 [EAX] - INC EAX - OR BL,BL - JNZ @@SL3 - SUB EAX,EDX - DEC EAX - XOR EDX,EDX -UCT_MEMCPY: - PUSH EDX - PUSH EAX - PUSH EBP - MOV EBP,ESP - PUSH ESI - PUSH EDI - MOV EDI,4[EBP] - MOV ESI,12[EBP] - MOV ECX,20[EBP] - OR ECX,ECX - JZ @@1 - REP_MOVSB -@@1: POP EDI - POP ESI - POP EBP - ADD ESP,24 -UCT_MEMSET: - PUSH EDX - PUSH EAX - PUSH EBP - MOV EBP,ESP - PUSH EDI - MOV EDI,4[EBP] - MOV ECX,20[EBP] - MOV EAX,12[EBP] - OR ECX,ECX - JZ @@2 - REP_STOSB -@@2: POP EDI - POP EBP - ADD ESP,24 -UCT_INPD: - MOV EDX,EAX - IN EAX,DX - XOR EDX,EDX -UCT_INPW: - MOV EDX,EAX - XOR EAX,EAX - IN AX,DX - XOR EDX,EDX -UCT_INP: - MOV EDX,EAX - XOR EAX,EAX - IN AL,DX - XOR EDX,EDX -UCT_OUTPD: - MOV EDX,EAX - POP EAX - ADD ESP,4 - OUT DX,EAX -UCT_OUTPW: - MOV EDX,EAX - POP EAX - ADD ESP,4 - OUT DX,AX -UCT_OUTP: - MOV EDX,EAX - POP EAX - ADD ESP,4 - OUT DX,AL -UCT_JMP: - JMP U4 FAR_AWAY -UCT_SHORT_JMP: - JMP UCT_SHORT_JMP -UCT_SWITCH: - POP EBX - ADD ESP,12 - CMP EBX,EAX - JAE UCT_SKIPZ - JMP U4 0x12345678[EBX*4] -UCT_SKIPZ: - OR EAX,EDX - JZ UCT_SKIPZ -UCT_SKIPZ2: - OR EAX,EDX - JNZ UCT_SKIPNZ - JMP U4 FAR_AWAY -UCT_SKIPNZ: - OR EAX,EDX - JNZ UCT_SKIPNZ -UCT_SKIPNZ2: - OR EAX,EDX - JZ UCT_EQUAL_EQUAL_SKIPZ - JMP U4 FAR_AWAY -UCT_EQUAL_EQUAL_SKIPZ: - POP EBX - POP ECX - CMP ECX,EDX - JNE @@EE2B - CMP EBX,EAX -@@EE2B: JNE UCT_EQUAL_EQUAL_SKIPZ -UCT_EQUAL_EQUAL_SKIPZ2: - POP EBX - POP ECX - CMP ECX,EDX - JNE @@EE2C - CMP EBX,EAX -@@EE2C: JNE U4 FAR_AWAY -UCT_NOT_EQUAL_TO_SKIPZ: - POP EBX - POP ECX - CMP ECX,EDX - JNE @@NE2B - CMP EBX,EAX -@@NE2B: JE UCT_NOT_EQUAL_TO_SKIPZ -UCT_NOT_EQUAL_TO_SKIPZ2: - POP EBX - POP ECX - CMP ECX,EDX - JNE @@NE2C - CMP EBX,EAX -@@NE2C: JE U4 FAR_AWAY -UCT_LESS_THAN_SKIPZ: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JNC UCT_LESS_THAN_SKIPZ -UCT_LESS_THAN_SKIPZ2: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JNC U4 FAR_AWAY -UCT_GREATER_THAN_SKIPZ: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JNC UCT_GREATER_THAN_SKIPZ -UCT_GREATER_THAN_SKIPZ2: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JNC U4 FAR_AWAY -UCT_LESS_OR_EQUAL_SKIPZ: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JC UCT_LESS_OR_EQUAL_SKIPZ -UCT_LESS_OR_EQUAL_SKIPZ2: - POP EBX - POP ECX - SUB EAX,EBX - SBB EDX,ECX - JC U4 FAR_AWAY -UCT_GREATER_OR_EQUAL_SKIPZ: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JC UCT_GREATER_OR_EQUAL_SKIPZ -UCT_GREATER_OR_EQUAL_SKIPZ2: - POP EBX - POP ECX - SUB EBX,EAX - SBB ECX,EDX - JC U4 FAR_AWAY -UCT_AND_AND_SKIPZ: - POP EBX - POP ECX - OR EAX,EDX - JZ @@AAZ1 - OR EBX,ECX -@@AAZ1: JZ UCT_AND_AND_SKIPZ -UCT_AND_AND_SKIPZ2: - POP EBX - POP ECX - OR EAX,EDX - JZ @@AAZ2 - OR EBX,ECX -@@AAZ2: JZ U4 FAR_AWAY -UCT_AND_AND_SKIPNZ: - POP EBX - POP ECX - OR EAX,EDX - JZ UCT_AND_AND_SKIPNZ2 - OR EBX,ECX - JNZ UCT_AND_AND_SKIPNZ -UCT_AND_AND_SKIPNZ2: - POP EBX - POP ECX - OR EAX,EDX - JZ UCT_OR_OR_SKIPZ - OR EBX,ECX - JNZ U4 FAR_AWAY -UCT_OR_OR_SKIPZ: - POP EBX - POP ECX - OR EAX,EDX - OR EBX,ECX - OR EAX,EBX - JZ UCT_OR_OR_SKIPZ -UCT_OR_OR_SKIPZ2: - POP EBX - POP ECX - OR EAX,EDX - OR EBX,ECX - OR EAX,EBX - JZ U4 FAR_AWAY -UCT_OR_OR_SKIPNZ: - POP EBX - POP ECX - OR EAX,EDX - OR EBX,ECX - OR EAX,EBX - JNZ UCT_OR_OR_SKIPNZ -UCT_OR_OR_SKIPNZ2: - POP EBX - POP ECX - OR EAX,EDX - OR EBX,ECX - OR EAX,EBX - JNZ U4 FAR_AWAY -UCT_LEA_DISP32_ESI: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12345678[ESI] -UCT_LEA_DISP8_ESI: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12[ESI] -UCT_LEA_DISP32_EDI: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12345678[EDI] -UCT_LEA_DISP8_EDI: - PUSH EDX - PUSH EAX - XOR EDX,EDX - LEA EAX,0x12[EDI] -UCT_PUSH_U8: - PUSH EDX - PUSH EAX - PUSH U4 0x12345678 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_U4: - PUSH EDX - PUSH EAX - PUSH 0 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_U2: - PUSH EDX - PUSH EAX - PUSH 0 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_U1: - PUSH EDX - PUSH EAX - PUSH 0 - PUSH 0x12 -UCT_PUSH_NEG_U4: - PUSH EDX - PUSH EAX - PUSH -1 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_NEG_U2: - PUSH EDX - PUSH EAX - PUSH -1 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_NEG_U1: - PUSH EDX - PUSH EAX - PUSH -1 - PUSH 0x12 -UCT_PUSH_DOUBLE: - PUSH EDX - PUSH EAX - PUSH U4 0x12345678 - PUSH U4 0x9ABCDEF0 -UCT_PUSH_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[EBP] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[EBP] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_ESI_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[ESI] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_ESI_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[ESI] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_EDI_U8_DISP32: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12345678[EDI] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_EDI_U8_DISP8: - PUSH EDX - PUSH EAX - LEA EAX,U4 0x12[EDI] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_DEREF_U8: - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_PUSH_U8_DISP32_SCALED: - LEA EAX,U4 0x12345678[EAX*8] - PUSH U4 4[EAX] - PUSH U4 [EAX] -UCT_BT_CONSTANT: - MOV EBX,EAX - XOR EAX,EAX - BT U4 [EBX],0x12 - ADC EAX,0 - XOR EDX,EDX -UCT_BTS_CONSTANT: - MOV EBX,EAX - XOR EAX,EAX - BTS U4 [EBX],0x12 - ADC EAX,0 - XOR EDX,EDX -UCT_BTR_CONSTANT: - MOV EBX,EAX - XOR EAX,EAX - BTR U4 [EBX],0x12 - ADC EAX,0 - XOR EDX,EDX -UCT_BTC_CONSTANT: - MOV EBX,EAX - XOR EAX,EAX - BTC U4 [EBX],0x12 - ADC EAX,0 - XOR EDX,EDX -UCT_ESI_NEXT_EQUAL_U4: - PUSH EDX - PUSH EAX - MOV ESI,U4 [ESI] - MOV EAX,ESI - XOR EDX,EDX -UCT_EDI_NEXT_EQUAL_U4: - PUSH EDX - PUSH EAX - MOV EDI,U4 [EDI] - MOV EAX,EDI - XOR EDX,EDX -UCT_ADD_EQUAL_U8_CONSTANT_U1: - MOV EBX,EAX - ADD U4 [EBX],0x12 - ADC U4 4[EBX],0 - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] -UCT_SUB_EQUAL_U8_CONSTANT_U1: - MOV EBX,EAX - SUB U4 [EBX],0x12 - SBB U4 4[EBX],0 - MOV EAX,U4 [EBX] - MOV EDX,U4 4[EBX] -UCT_ADD_EQUAL_U4_CONSTANT_U1: - ADD U4 [EAX],0x12 - MOV EAX,U4 [EAX] - XOR EDX,EDX -UCT_ESI_ADD_EQUAL_U4_CONSTANT_U1: - PUSH EDX - PUSH EAX - ADD ESI,0x12 - MOV EAX,ESI - XOR EDX,EDX -UCT_EDI_ADD_EQUAL_U4_CONSTANT_U1: - PUSH EDX - PUSH EAX - ADD EDI,0x12 - MOV EAX,EDI - XOR EDX,EDX -UCT_TABLE_END: - ALIGN 8,0x90 -DOUBLE_CODE_TABLE:: - DU4 DCT_NULL; - DU4 DCT_NOP; - DU4 DCT_END_EXP; - DU4 DCT_ZERO; - DU4 DCT_U8; - DU4 DCT_U4; - DU4 DCT_U2; - DU4 DCT_U1; - DU4 DCT_DOUBLE; - DU4 DCT_STRING_CONSTANT; - DU4 DCT_EBP; - DU4 DCT_FS; - DU4 DCT_ESI; - DU4 DCT_EDI; - DU4 DCT_TO_DOUBLE; - DU4 DCT_TO_INT; - DU4 DCT_COM; - DU4 DCT_NOT; - DU4 DCT_UNARY_MINUS; - DU4 DCT_ADDRESS; - DU4 DCT_U8_DISP32; - DU4 DCT_U4_DISP32; - DU4 DCT_U2_DISP32; - DU4 DCT_U1_DISP32; - DU4 DCT_U8_DISP8; - DU4 DCT_U4_DISP8; - DU4 DCT_U2_DISP8; - DU4 DCT_U1_DISP8; - DU4 DCT_FS_U8_DISP32; - DU4 DCT_FS_U4_DISP32; - DU4 DCT_FS_U2_DISP32; - DU4 DCT_FS_U1_DISP32; - DU4 DCT_ESI_U8_DISP32; - DU4 DCT_ESI_U4_DISP32; - DU4 DCT_ESI_U2_DISP32; - DU4 DCT_ESI_U1_DISP32; - DU4 DCT_ESI_U8_DISP8; - DU4 DCT_ESI_U4_DISP8; - DU4 DCT_ESI_U2_DISP8; - DU4 DCT_ESI_U1_DISP8; - DU4 DCT_EDI_U8_DISP32; - DU4 DCT_EDI_U4_DISP32; - DU4 DCT_EDI_U2_DISP32; - DU4 DCT_EDI_U1_DISP32; - DU4 DCT_EDI_U8_DISP8; - DU4 DCT_EDI_U4_DISP8; - DU4 DCT_EDI_U2_DISP8; - DU4 DCT_EDI_U1_DISP8; - DU4 DCT_DEREF_U8; - DU4 DCT_DEREF_U4; - DU4 DCT_DEREF_U2; - DU4 DCT_DEREF_U1; - DU4 DCT_ESI_DEREF_U8; - DU4 DCT_ESI_DEREF_U4; - DU4 DCT_ESI_DEREF_U2; - DU4 DCT_ESI_DEREF_U1; - DU4 DCT_EDI_DEREF_U8; - DU4 DCT_EDI_DEREF_U4; - DU4 DCT_EDI_DEREF_U2; - DU4 DCT_EDI_DEREF_U1; - DU4 DCT_U8_PP; - DU4 DCT_U4_PP; - DU4 DCT_U2_PP; - DU4 DCT_U1_PP; - DU4 DCT_U8_MM; - DU4 DCT_U4_MM; - DU4 DCT_U2_MM; - DU4 DCT_U1_MM; - DU4 DCT_PP_U8; - DU4 DCT_PP_U4; - DU4 DCT_PP_U2; - DU4 DCT_PP_U1; - DU4 DCT_MM_U8; - DU4 DCT_MM_U4; - DU4 DCT_MM_U2; - DU4 DCT_MM_U1; - DU4 DCT_ESI_U4_PP; - DU4 DCT_ESI_U4_MM; - DU4 DCT_ESI_PP_U4; - DU4 DCT_ESI_MM_U4; - DU4 DCT_EDI_U4_PP; - DU4 DCT_EDI_U4_MM; - DU4 DCT_EDI_PP_U4; - DU4 DCT_EDI_MM_U4; - DU4 DCT_LEA_DISP32_EBP; - DU4 DCT_LEA_DISP8_EBP; - DU4 DCT_U8_DISP32_SCALED; - DU4 DCT_U4_DISP32_SCALED; - DU4 DCT_U2_DISP32_SCALED; - DU4 DCT_SHL; - DU4 DCT_SHR; - DU4 DCT_SHL_CONSTANT1; - DU4 DCT_SHL_CONSTANT2; - DU4 DCT_SHR_CONSTANT1; - DU4 DCT_SHR_CONSTANT2; - DU4 DCT_POWER; - DU4 DCT_MULTIPLICATION; - DU4 DCT_DIVISION; - DU4 DCT_REMAINDER; - DU4 DCT_AND; - DU4 DCT_OR; - DU4 DCT_XOR; - DU4 DCT_ADDITION; - DU4 DCT_SUBTRACTION; - DU4 DCT_EQUAL_EQUAL; - DU4 DCT_NOT_EQUAL_TO; - DU4 DCT_LESS_THAN; - DU4 DCT_GREATER_THAN; - DU4 DCT_LESS_OR_EQUAL; - DU4 DCT_GREATER_OR_EQUAL; - DU4 DCT_AND_AND; - DU4 DCT_OR_OR; - DU4 DCT_XOR_XOR; - DU4 DCT_COLON; - DU4 DCT_QUESTION; - DU4 DCT_ASSIGN_U8; - DU4 DCT_ASSIGN_U4; - DU4 DCT_ASSIGN_U2; - DU4 DCT_ASSIGN_U1; - DU4 DCT_SHL_EQUAL_U8; - DU4 DCT_SHL_EQUAL_U4; - DU4 DCT_SHL_EQUAL_U2; - DU4 DCT_SHL_EQUAL_U1; - DU4 DCT_SHR_EQUAL_U8; - DU4 DCT_SHR_EQUAL_U4; - DU4 DCT_SHR_EQUAL_U2; - DU4 DCT_SHR_EQUAL_U1; - DU4 DCT_MUL_EQUAL_U8; - DU4 DCT_MUL_EQUAL_U4; - DU4 DCT_MUL_EQUAL_U2; - DU4 DCT_MUL_EQUAL_U1; - DU4 DCT_DIV_EQUAL_U8; - DU4 DCT_DIV_EQUAL_U4; - DU4 DCT_DIV_EQUAL_U2; - DU4 DCT_DIV_EQUAL_U1; - DU4 DCT_AND_EQUAL_U8; - DU4 DCT_AND_EQUAL_U4; - DU4 DCT_AND_EQUAL_U2; - DU4 DCT_AND_EQUAL_U1; - DU4 DCT_OR_EQUAL_U8; - DU4 DCT_OR_EQUAL_U4; - DU4 DCT_OR_EQUAL_U2; - DU4 DCT_OR_EQUAL_U1; - DU4 DCT_XOR_EQUAL_U8; - DU4 DCT_XOR_EQUAL_U4; - DU4 DCT_XOR_EQUAL_U2; - DU4 DCT_XOR_EQUAL_U1; - DU4 DCT_ADD_EQUAL_U8; - DU4 DCT_ADD_EQUAL_U4; - DU4 DCT_ADD_EQUAL_U2; - DU4 DCT_ADD_EQUAL_U1; - DU4 DCT_SUB_EQUAL_U8; - DU4 DCT_SUB_EQUAL_U4; - DU4 DCT_SUB_EQUAL_U2; - DU4 DCT_SUB_EQUAL_U1; - DU4 DCT_ESI_ASSIGN_U4; - DU4 DCT_ESI_SHL_EQUAL_U4; - DU4 DCT_ESI_SHR_EQUAL_U4; - DU4 DCT_ESI_MUL_EQUAL_U4; - DU4 DCT_ESI_DIV_EQUAL_U4; - DU4 DCT_ESI_AND_EQUAL_U4; - DU4 DCT_ESI_OR_EQUAL_U4; - DU4 DCT_ESI_XOR_EQUAL_U4; - DU4 DCT_ESI_ADD_EQUAL_U4; - DU4 DCT_ESI_SUB_EQUAL_U4; - DU4 DCT_EDI_ASSIGN_U4; - DU4 DCT_EDI_SHL_EQUAL_U4; - DU4 DCT_EDI_SHR_EQUAL_U4; - DU4 DCT_EDI_MUL_EQUAL_U4; - DU4 DCT_EDI_DIV_EQUAL_U4; - DU4 DCT_EDI_AND_EQUAL_U4; - DU4 DCT_EDI_OR_EQUAL_U4; - DU4 DCT_EDI_XOR_EQUAL_U4; - DU4 DCT_EDI_ADD_EQUAL_U4; - DU4 DCT_EDI_SUB_EQUAL_U4; - DU4 DCT_ADD64; - DU4 DCT_ADD32; - DU4 DCT_ADD8; - DU4 DCT_INC; - DU4 DCT_SUB64; - DU4 DCT_SUB32; - DU4 DCT_SUB8; - DU4 DCT_DEC; - DU4 DCT_ENTER; - DU4 DCT_LEAVE; - DU4 DCT_ENTER1; - DU4 DCT_LEAVE1; - DU4 DCT_ENTER2; - DU4 DCT_LEAVE2; - DU4 DCT_ADD_ESP32; - DU4 DCT_ADD_ESP8; - DU4 DCT_RET; - DU4 DCT_CALL; - DU4 DCT_CALL_INDIRECT; - DU4 DCT_CALL_INDIRECT2; - DU4 DCT_IRQ; - DU4 DCT_CLI; - DU4 DCT_STI; - DU4 DCT_GET_FLAGS; - DU4 DCT_SET_FLAGS; - DU4 DCT_GET_BASE_PTR; - DU4 DCT_SET_BASE_PTR; - DU4 DCT_GET_STACK_PTR; - DU4 DCT_SET_STACK_PTR; - DU4 DCT_GET_LABEL; - DU4 DCT_ABSOLUTE_ADDRESS; - DU4 DCT_LABEL; - DU4 DCT_TYPE; - DU4 DCT_BT; - DU4 DCT_BTS; - DU4 DCT_BTR; - DU4 DCT_BTC; - DU4 DCT_BSF; - DU4 DCT_BSR; - DU4 DCT_INSQUE; - DU4 DCT_INSQUE_REV; - DU4 DCT_REMQUE; - DU4 DCT_STRLEN; - DU4 DCT_MEMCPY; - DU4 DCT_MEMSET; - DU4 DCT_INPD; - DU4 DCT_INPW; - DU4 DCT_INP; - DU4 DCT_OUTPD; - DU4 DCT_OUTPW; - DU4 DCT_OUTP; - DU4 DCT_JMP; - DU4 DCT_SHORT_JMP; - DU4 DCT_SWITCH; - DU4 DCT_SKIPZ; - DU4 DCT_SKIPZ2; - DU4 DCT_SKIPNZ; - DU4 DCT_SKIPNZ2; - DU4 DCT_EQUAL_EQUAL_SKIPZ; - DU4 DCT_EQUAL_EQUAL_SKIPZ2; - DU4 DCT_NOT_EQUAL_TO_SKIPZ; - DU4 DCT_NOT_EQUAL_TO_SKIPZ2; - DU4 DCT_LESS_THAN_SKIPZ; - DU4 DCT_LESS_THAN_SKIPZ2; - DU4 DCT_GREATER_THAN_SKIPZ; - DU4 DCT_GREATER_THAN_SKIPZ2; - DU4 DCT_LESS_OR_EQUAL_SKIPZ; - DU4 DCT_LESS_OR_EQUAL_SKIPZ2; - DU4 DCT_GREATER_OR_EQUAL_SKIPZ; - DU4 DCT_GREATER_OR_EQUAL_SKIPZ2; - DU4 DCT_AND_AND_SKIPZ; - DU4 DCT_AND_AND_SKIPZ2; - DU4 DCT_AND_AND_SKIPNZ; - DU4 DCT_AND_AND_SKIPNZ2; - DU4 DCT_OR_OR_SKIPZ; - DU4 DCT_OR_OR_SKIPZ2; - DU4 DCT_OR_OR_SKIPNZ; - DU4 DCT_OR_OR_SKIPNZ2; - DU4 DCT_LEA_DISP32_ESI; - DU4 DCT_LEA_DISP8_ESI; - DU4 DCT_LEA_DISP32_EDI; - DU4 DCT_LEA_DISP8_EDI; - DU4 DCT_PUSH_U8; - DU4 DCT_PUSH_U4; - DU4 DCT_PUSH_U2; - DU4 DCT_PUSH_U1; - DU4 DCT_PUSH_NEG_U4; - DU4 DCT_PUSH_NEG_U2; - DU4 DCT_PUSH_NEG_U1; - DU4 DCT_PUSH_DOUBLE; - DU4 DCT_PUSH_U8_DISP32; - DU4 DCT_PUSH_U8_DISP8; - DU4 DCT_PUSH_ESI_U8_DISP32; - DU4 DCT_PUSH_ESI_U8_DISP8; - DU4 DCT_PUSH_EDI_U8_DISP32; - DU4 DCT_PUSH_EDI_U8_DISP8; - DU4 DCT_PUSH_DEREF_U8; - DU4 DCT_PUSH_U8_DISP32_SCALED; - DU4 DCT_BT_CONSTANT; - DU4 DCT_BTS_CONSTANT; - DU4 DCT_BTR_CONSTANT; - DU4 DCT_BTC_CONSTANT; - DU4 DCT_ESI_NEXT_EQUAL_U4; - DU4 DCT_EDI_NEXT_EQUAL_U4; - DU4 DCT_ADD_EQUAL_U8_CONSTANT_U1; - DU4 DCT_SUB_EQUAL_U8_CONSTANT_U1; - DU4 DCT_ADD_EQUAL_U4_CONSTANT_U1; - DU4 DCT_ESI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 DCT_EDI_ADD_EQUAL_U4_CONSTANT_U1; - DU4 DCT_TABLE_END; -DCT_NULL: -DCT_NOP: -DCT_END_EXP: -DCT_ZERO: -DCT_U8: -DCT_U4: -DCT_U2: -DCT_U1: -DCT_DOUBLE: -DCT_STRING_CONSTANT: -DCT_EBP: -DCT_FS: -DCT_ESI: -DCT_EDI: -DCT_TO_DOUBLE: -DCT_TO_INT: -DCT_COM: -DCT_NOT: -DCT_UNARY_MINUS: - PUSH EDX - PUSH EAX - PUSH EBP - MOV EBP,ESP - FLD U4 4[EBP] - FCHS - FSTP U4 4[EBP] - POP EBP - POP EAX - POP EDX -DCT_ADDRESS: -DCT_U8_DISP32: -DCT_U4_DISP32: -DCT_U2_DISP32: -DCT_U1_DISP32: -DCT_U8_DISP8: -DCT_U4_DISP8: -DCT_U2_DISP8: -DCT_U1_DISP8: -DCT_FS_U8_DISP32: -DCT_FS_U4_DISP32: -DCT_FS_U2_DISP32: -DCT_FS_U1_DISP32: -DCT_ESI_U8_DISP32: -DCT_ESI_U4_DISP32: -DCT_ESI_U2_DISP32: -DCT_ESI_U1_DISP32: -DCT_ESI_U8_DISP8: -DCT_ESI_U4_DISP8: -DCT_ESI_U2_DISP8: -DCT_ESI_U1_DISP8: -DCT_EDI_U8_DISP32: -DCT_EDI_U4_DISP32: -DCT_EDI_U2_DISP32: -DCT_EDI_U1_DISP32: -DCT_EDI_U8_DISP8: -DCT_EDI_U4_DISP8: -DCT_EDI_U2_DISP8: -DCT_EDI_U1_DISP8: -DCT_DEREF_U8: -DCT_DEREF_U4: -DCT_DEREF_U2: -DCT_DEREF_U1: -DCT_ESI_DEREF_U8: -DCT_ESI_DEREF_U4: -DCT_ESI_DEREF_U2: -DCT_ESI_DEREF_U1: -DCT_EDI_DEREF_U8: -DCT_EDI_DEREF_U4: -DCT_EDI_DEREF_U2: -DCT_EDI_DEREF_U1: -DCT_U8_PP: - MOV EBX,EAX - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] - FLD U4 [EBX] - FLD1 - FADDP - FSTP U4 [EBX] -DCT_U4_PP: -DCT_U2_PP: -DCT_U1_PP: -DCT_U8_MM: - MOV EBX,EAX - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] - FLD U4 [EBX] - FLD1 - FSUBP - FSTP U4 [EBX] -DCT_U4_MM: -DCT_U2_MM: -DCT_U1_MM: -DCT_PP_U8: - FLD U4 [EAX] - FLD1 - FADDP - FSTP U4 [EAX] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -DCT_PP_U4: -DCT_PP_U2: -DCT_PP_U1: -DCT_MM_U8: - FLD U4 [EAX] - FLD1 - FSUBP - FSTP U4 [EAX] - MOV EDX,U4 4[EAX] - MOV EAX,U4 [EAX] -DCT_MM_U4: -DCT_MM_U2: -DCT_MM_U1: -DCT_ESI_U4_PP: -DCT_ESI_U4_MM: -DCT_ESI_PP_U4: -DCT_ESI_MM_U4: -DCT_EDI_U4_PP: -DCT_EDI_U4_MM: -DCT_EDI_PP_U4: -DCT_EDI_MM_U4: -DCT_LEA_DISP32_EBP: -DCT_LEA_DISP8_EBP: -DCT_U8_DISP32_SCALED: -DCT_U4_DISP32_SCALED: -DCT_U2_DISP32_SCALED: -DCT_SHL: -DCT_SHR: -DCT_SHL_CONSTANT1: -DCT_SHL_CONSTANT2: -DCT_SHR_CONSTANT1: -DCT_SHR_CONSTANT2: -DCT_POWER: - PUSH EDX - PUSH EAX - PUSH 0 - PUSH EBP - MOV EBP,ESP - FSTCW U4 4[EBP] - MOV AX,U2 4[EBP] - MOV U2 6[EBP],AX - OR AX,0x0C00 - MOV U2 4[EBP],AX - FLDCW U4 4[EBP] - FLD U4 8[EBP] - FLD U4 16[EBP] - FYL2X // y*log2(x) - FST U4 16[EBP] - FRNDINT - FLD U4 16[EBP] - FSUBRP - F2XM1 - FLD1 - FADDP - FSTP U4 8[EBP] - FFREE - FINCSTP - FLD U4 16[EBP] - FLD U4 8[EBP] - FSCALE // ST0<token==TK_IDENT) - if (temph=l->hash_entry) - if (temph->type == HTT_KEYWORD) - result=temph->user0; - return result; -} - -#define PVLM_LOCAL_VAR 0 -#define PVLM_FUNCTION_PARAM 1 -#define PVLM_CLASS 2 -#define PVLM_UNION 3 -void CmpParseVarList(LexStruct *l,ClassStruct *tempc, - I8 mode,U8 union_base=MAX_I4) -{ - I8 i,j,k,old_flags; - U8 ptr_cnt,size; - ClassStruct *tempc1,*tempc2; - SysHashEntry *temph; - MemberListStruct *tempm; - U1 *e; - if (mode!=PVLM_LOCAL_VAR || union_base!=MAX_I4) { - if (l->token=='(' || l->token=='{') - Lex(l); - } - while (TRUE) { - while (l->token==';') Lex(l); - if (l->token==')' || l->token=='}') { - Lex(l); - return; - } - if (l->token=='.') { - if (Lex(l)=='.') { - if (Lex(l)=='.') { - Lex(l); - tempm=MAllocZ(sizeof(MemberListStruct)); - tempm->flags=MLF_DOT_DOT_DOT; - tempm->member_class=sys_internal_types[IT_U4]; - tempm->string=NewString("argc"); - tempc2=tempc->last_in_member_list; - tempc2->next=tempm; - tempc->last_in_member_list=tempm; - tempm->offset=tempc->size; - tempc->size+=8; - - tempm=MAllocZ(sizeof(MemberListStruct)); - tempm->flags=MLF_DOT_DOT_DOT; - tempm->member_class=sys_internal_types[IT_I8]+sizeof(ClassStruct); - tempm->string=NewString("argv"); - tempm->cnt=127; //nonzero - tempc2=tempc->last_in_member_list; - tempc2->next=tempm; - tempc->last_in_member_list=tempm; - tempm->offset=tempc->size; - tempc->size+=8; - - if (l->token==')' || l->token=='}') - Lex(l); - return; - } else - PrsExcept(l,"ST_EXPECTING_TYPE"); - } else - PrsExcept(l,"ST_EXPECTING_TYPE"); - } - temph=NULL; - if (l->token==TK_IDENT) { - temph=l->hash_entry; - k=CmpKeyWord(l); - } - if (!temph) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (k==KW_UNION) { - Lex(l); - CmpParseVarList(l,tempc,mode,tempc->size); - } else { - tempc1=temph; - if (!(tempc1->type & (HTT_CLASS | HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - do { - LexPush(l); - Lex(l); //skip type - ptr_cnt=0; - while (l->token=='*') { - l->stack_ptr--; //grows up - LexPush(l); - Lex(l); - ptr_cnt++; - } - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_IDENTIFIER"); - tempm=MAllocZ(sizeof(MemberListStruct)); - tempm->member_class=tempc1; - tempm->string=l->ident; - l->ident=NULL; - tempc2=tempc->last_in_member_list; - tempc2->next=tempm; - tempc->last_in_member_list=tempm; - tempc->member_cnt++; - - if (Lex(l)=='(') { - tempm->flags|=MLF_FUNCTION; - if (Lex(l)!=')') { - tempm->parameter_cnt++; - while (l->token!=')') { - if (l->token==',') - tempm->parameter_cnt++; - Lex(l); - } - } - Lex(l); //skip ) - } - - if (l->token=='[') { - if (Lex(l)==']) - ptr_cnt++; - else - tempm->cnt=Expression(l); - if (l->token!=']') - PrsExcept(l,"ST_MISSING_RIGHT_BRACKET"); - Lex(l); - } - tempm->member_class+=ptr_cnt*sizeof(ClassStruct); - if (tempm->flags & MLF_FUNCTION) - tempm->member_class=sys_internal_types[IT_U4]+sizeof(ClassStruct); - tempc2=tempm->member_class; - i=tempc2->size; - j=(tempm->cnt)? tempm->cnt:1; - i*=j; - if (mode==PVLM_LOCAL_VAR) { - if (union_base!=0x7FFFFFFF) { - if (union_base-tempc->sizesize=union_base-i; - } else - tempc->size=tempc->size-i; - tempm->offset=tempc->size; - if (l->token=='=') { - LexPop(l); - Lex(l); - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,7); - } else - l->stack_ptr--; - } else if (mode==PVLM_FUNCTION_PARAM) { - if (union_base!=0x7FFFFFFF) { - tempm->offset=union_base; - if (tempc->size-union_base<8) - tempc->size=8+union_base; - } else { - tempm->offset=tempc->size; - tempc->size+=8; - } - if (l->token=='=') { - Lex(l); - old_flags=l->flags; - l->flags&=~LF_HAS_MISC_DATA; - e=CompileExpression(l); - if (!e) - throw(EXCEPT_COMPILER,8); - tempm->default_value=Run(e); //TODO: if l->a - if (!(l->flags & LF_HAS_MISC_DATA)) - DelExpression(e); - else if (l->a) - PrsExcept(l,"ST_STRING_DEFAULT"); - tempm->flags|=MLF_DEFAULT_AVAILABLE; - l->flags|=old_flags&LF_HAS_MISC_DATA; - } - l->stack_ptr--; - } else { //CLASS - if (union_base!=MAX_I4) { - tempm->offset=union_base; - if (tempc->size-union_basesize=i+union_base; - } else { - tempm->offset=tempc->size; - tempc->size+=i; - } - do { - temph=NULL; - k=CmpKeyWord(l); - if (k==KW_FMTSTR) { - if (Lex(l)!=TK_STRING) - PrsExcept(l,"ST_EXPECTING_STRING"); - tempm->fmtstr=LexExtendString(l,&size); - } else if (k==KW_FMTDATA) { - if (Lex(l)!=TK_STRING) - PrsExcept(l,"ST_EXPECTING_STRING"); - tempm->fmtdata=LexExtendString(l,&size); - } - } while (k==KW_FMTSTR || k==KW_FMTDATA); - l->stack_ptr--; - } - - if (l->token==',') { - if (mode==PVLM_FUNCTION_PARAM && union_base==MAX_I4) { - Lex(l); - break; - } - } else if (l->token==')' || l->token=='}') { - Lex(l); - return; - } else if (l->token==';') { - Lex(l); - if (mode==PVLM_LOCAL_VAR && union_base==MAX_I4) - return; - break; - } else - PrsExcept(l,"ST_MISSING_SEMICOLON"); - } while (TRUE); - } - } -} - -ClassStruct *CmpParseClass(LexStruct *l,BoolU4 is_union,BoolU4 is_public) -{ - SysHashEntry *temph1; - ClassStruct *tempc; - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_IDENTIFIER"); - tempc=CmpClassNew; - if (is_public) - tempc->type|=HTT_PUBLIC; - tempc->string=l->ident; - l->ident=NULL; - SetSourceFileInfo(l,tempc); - tempc->use_cnt=0; - if (l->a) - temph1=FindHashBucket(tempc->string,l->a->glbl_hash); - else - temph1=FindHashBucket(tempc->string,l->hash_table_list); - tempc->next=temph1->next; - temph1->next=tempc; - Lex(l); - CmpParseVarList(l,tempc,PVLM_CLASS,(is_union)?0:0x7FFFFFFF); - return tempc; -} - -void UndefinedExtern() -{ - PutSysText("ST_UNDEFINED_EXTERN"); - throw(EXCEPT_UNDEF_EXTERN); -} - - -ClassStruct *CmpParseFunctionJoin(LexStruct *l, - ClassStruct *temp_return,I1 *name,BoolU4 is_public,BoolU4 needs_abs) -{ - MemberListStruct *tempm; - AsmCtrlStruct *a=l->a; - SysHashEntry *temph1; - SysHashTable *tempht; - ClassStruct *tempc; - ExeAbsoluteAddressStruct *tempa; - if (a) { - if (tempc=FindHashEntry(name,a->glbl_hash,HTT_ALL)) { - if (!(tempc->type & HTT_FUNCTION)) - tempc=NULL; - } - if (!tempc) - temph1=FindHashBucket(name,a->glbl_hash); - } else { - tempht=l->hash_table_list->next; - l->hash_table_list->next=NULL; - if (tempc=FindHashEntry(name,l->hash_table_list,HTT_ALL)) { - if (!(tempc->type & HTT_FUNCTION)) - tempc=NULL; - } - l->hash_table_list->next=tempht; - if (!tempc) - temph1=FindHashBucket(name,l->hash_table_list); - } - if (!tempc) { - tempc=CmpClassNew; - tempc->next=temph1->next; - temph1->next=tempc; - tempc->type=HTT_FUNCTION; - tempc->string=name; - if (a) { - tempc->executable_address=a->ip; - if (needs_abs) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip; - } - AsmStoreCodeU1(l,0); - AsmStoreCodeU1(l,0); - AsmStoreCodeU1(l,0); - AsmStoreCodeU1(l,0); - } else - tempc->executable_address=&UndefinedExtern; - Bts(&tempc->flags,Cf_EXTERN); - } else { - Free(tempc->source_link); - Free(name); - DelMemberList(tempc); - } - if (is_public) - tempc->type|=HTT_PUBLIC; - else - tempc->type&=~HTT_PUBLIC; - tempc->return_class=temp_return; - tempc->use_cnt=0; - SetSourceFileInfo(l,tempc); - CmpParseVarList(l,tempc,PVLM_FUNCTION_PARAM); - tempc->parameter_cnt=tempc->member_cnt; - tempm=tempc->member_list; - while (tempm) { - tempm->offset+=8; //EBP+RETURN - tempm=tempm->next; - } - - tempc->size=0; - return tempc; -} - -void CmpParseFunction(LexStruct *l, - ClassStruct *temp_return,I1 *name,BoolU4 is_public) -{ - U1 *result; - AsmCtrlStruct *a=l->a; - ClassStruct *tempc; - MemberListStruct *tempm; - U8 i,j,size; - DbgInfo *dbg=NULL; - - l->flags&=~LF_NO_REG_OPT; - tempc=CmpParseFunctionJoin(l,temp_return,name,is_public,TRUE); - l->local_var_list=tempc; - CbPush(l); - CbInitOutPtrs(&l->cb); - CbAddIc(l,EC_ENTER,0,0); - CmpParseStatement(l,tempc,0,NULL,NULL,FALSE); - CbAddIc(l,EC_LEAVE,0,0); - CbAddIc(l,0,0,0); - tempc->size&=-8; - if (a) { - i=a->ip; - j=tempc->executable_address; - if (Bt(&tempc->flags,Cf_EXTERN)) { - AsmStoreCodeU1At(l,i.u1[0],j); - AsmStoreCodeU1At(l,i.u1[1],j+1); - AsmStoreCodeU1At(l,i.u1[2],j+2); - AsmStoreCodeU1At(l,i.u1[3],j+3); - } - tempc->executable_address=i; - tempc->type|=HTT_EXPORT; - result=CbCompile(l,tempc,&size,&dbg); - tempc->debug=dbg; - if (result) { - for (i=0;iexecutable_address=CbCompile(l,tempc,&size,&dbg); - tempc->debug=dbg; - } - Btr(&tempc->flags,Cf_EXTERN); - CbPop(l); - l->local_var_list=NULL; - tempm=tempc->member_list; - while (tempm) { - if (!tempm->use_cnt) { - coutln SysText("ST_WARNING"),SysText("ST_UNUSED_VAR"); - PrintF(" $$LK -A \"FL:%s,%d\"$$ '", - l->cur_lfn->name,l->cur_lfn->line_num); - coutln tempm->string,"' in '",tempc->string,"'"; - } - tempm=tempm->next; - } -} - -void CatchAll() -{ - I8 i; - if (Fs->except_argc>0) { - if (Fs->except_argv[0]except_argv[0],"ST_EXCEPT_TYPES"); - if (Fs->except_argv[0]==EXCEPT_UNDEF_SYSTEXT) - PrintF("Name:'%s'\r\n",Fs->except_argv[1]); - else if (Fs->except_argv[0]==EXCEPT_ARITHMETIC) - PrintF("Address:%P\r\n",Fs->except_argv[1]); - else if (Fs->except_argv[0]==EXCEPT_FLOATING) - PrintF("Address:%P\r\n",Fs->except_argv[1]); - else { - for (i=1;iexcept_argc;i++) - cout Fs->except_argv[i]," "; - CrLf; - } - } else { - cout "Exception:"; - for (i=1;iexcept_argc;i++) - cout Fs->except_argv[i]," "; - CrLf; - } - } else - PrintF("Generic Exception\r\n"); - Fs->catch_except=TRUE; -} - - -BoolU4 PrsVarInit(LexStruct *l,U1 **dd,ClassStruct *cl,U8 cnt) -{ - U1 *d=*dd,*e; - U8 i,j,r,old_flags; - BoolU4 result=FALSE,stop; - MemberListStruct *ml; - - while (cl->return_class) - cl=cl->return_class; - if (ml=cl->member_list) { - if (l->token!='{') - PrsExcept(l,"ST_EXPECTING_LEFT_BRACE"); - Lex(l); - - while (ml) { - if (ml->cnt && l->token=='{') - Lex(l); - j=(ml->cnt) ? ml->cnt:1; - stop=FALSE; - for (i=0;imember_class,ml->cnt); - if (l->token==',') - Lex(l); - } - if (ml->cnt && l->token=='}') - Lex(l); - ml=ml->next; - } - if (l->token!='}') - PrsExcept(l,"ST_MISSING_RIGHT_BRACE"); - Lex(l); - } else { - if (cl->type & HTT_INTERNAL_TYPE && - !cl->pointer_cnt && cnt && - (cl->sub_type==IT_I1 || cl->sub_type==IT_U1) && - l->token==TK_STRING) { - e=LexExtendString(l,&i); - MemCpy(d,e,i); - d+=cnt; - result=TRUE; - } else { - old_flags=l->flags; - l->flags&=~LF_HAS_MISC_DATA; - e=CompileExpression(l); - if (!e) - throw(EXCEPT_COMPILER,10); - r=Run(e); - if (!(l->flags & LF_HAS_MISC_DATA)) - DelExpression(e); - - MemCpy(d,&r,cl->size); - d+=cl->size; - l->flags|=old_flags&LF_HAS_MISC_DATA; - } - } - *dd=d; - return result; -} - -void PrsParseGlblInit(LexStruct *l,GlblVarStruct *tempg) -{ - U1 *dd=&tempg->data; - U8 i,j; - ClassStruct *cl=tempg->var_class; - BoolU4 stop=FALSE; - while (cl->return_class) - cl=cl->return_class; - if (tempg->cnt && l->token=='{') - Lex(l); - j=(tempg->cnt) ? tempg->cnt:1; - for (i=0;icnt); - if (j>1 && l->token==',') - Lex(l); - } - if (tempg->cnt && l->token=='}') - Lex(l); -} - -#define PG_NULL 0 -#define PG_LTEXTERN 1 -#define PG_LTINTERN 2 -#define PG_LTIMPORT 3 -#define PG_EXTERN 4 -#define PG_IMPORT 5 - -void CmpParseGlblVarList(LexStruct *l,I8 saved_mode,ClassStruct *saved_tempc, - U8 saved_val,BoolU4 is_public) -{ - I8 i,j,mode; - U8 k,val; - I1 *st; - SysHashEntry *temph,*temph1; - GlblVarStruct *tempg,*tempg1; - AsmCtrlStruct *a=l->a; - ClassStruct *tempc,*tempc1; - U1 *u1; - while (TRUE) { - Lex(l); - tempc=saved_tempc; - val=saved_val; - mode=saved_mode; - while (l->token=='*') { - Lex(l); - tempc+=sizeof(ClassStruct); - } - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_IDENTIFIER"); - if ((temph=l->hash_entry) && mode==PG_EXTERN && !a) { - if (temph->type & HTT_SYS_SYMBOL) { - val=temph->user0; - mode=PG_LTEXTERN; - } - } - if (CmpKeyWord(l)==KW_UNION) { - Lex(l); - tempc1=CmpParseClass(l,TRUE,is_public); - tempc1->return_class=tempc; - return; - } else if (CmpKeyWord(l)==KW_CLASS) { - Lex(l); - tempc1=CmpParseClass(l,FALSE,is_public); - tempc1->return_class=tempc; - return; - } - st=l->ident; - l->ident=NULL; - if (Lex(l)=='(') { - if (mode==PG_LTINTERN) { - tempc1=CmpParseFunctionJoin(l,tempc,st,is_public,FALSE); - tempc1->executable_address=val; - Bts(&tempc1->flags,Cf_INTERNAL); - Btr(&tempc1->flags,Cf_EXTERN); - return; - } else if (mode==PG_LTEXTERN) { - tempc1=CmpParseFunctionJoin(l,tempc,st,is_public,FALSE); - tempc1->executable_address=val; - Btr(&tempc1->flags,Cf_EXTERN); - return; - } else if (mode==PG_EXTERN) { - CmpParseFunctionJoin(l,tempc,st,is_public,TRUE); - return; - } else if (mode==PG_IMPORT || mode==PG_LTIMPORT) { - if (!a) - PrsExcept(l,"ST_IMPORT_NOT_NEEDED"); - else { - tempc1=CmpParseFunctionJoin(l,tempc,st,is_public,FALSE); - tempc1->type|=HTT_IMPORT; - if (mode==PG_LTIMPORT) - tempc1->import_name=NewString(val); - else - tempc1->import_name=NewString(st); - } - return; - } else { - CmpParseFunction(l,tempc,st,is_public); - return; - } - } - i=0; - if (l->token=='[') { - if (Lex(l)==']') - tempc+=sizeof(ClassStruct); - else - i=Expression(l); - if (l->token!=']') - PrsExcept(l,"ST_MISSING_RIGHT_BRACKET"); - Lex(l); - } - j=tempc->size; - if (i) j*=i; - if (mode==PG_LTEXTERN) { - tempg=MAllocZ(sizeof(GlblVarStruct)-4); - tempg->data_address=val; - if (a) - tempg->type=HTT_GLBL_VAR | HTT_EXPORT; - else - tempg->type=HTT_GLBL_VAR; - } else if (mode==PG_LTIMPORT || mode==PG_IMPORT) { - if (!a) - PrsExcept(l,"ST_IMPORT_NOT_NEEDED"); - else { - tempg=MAllocZ(sizeof(GlblVarStruct)-4); - tempg->type=HTT_GLBL_VAR | HTT_IMPORT; - if (mode==PG_LTIMPORT) - tempg->import_name=NewString(val); - else - tempg->import_name=NewString(st); - tempg->data_address=a->ip; - k=0; - AsmStoreCodeU1(l,k.u1[0]); - AsmStoreCodeU1(l,k.u1[1]); - AsmStoreCodeU1(l,k.u1[2]); - AsmStoreCodeU1(l,k.u1[3]); - } - } else if (mode==PG_EXTERN) { - tempg=MAllocZ(sizeof(GlblVarStruct)-4); - tempg->data_address=0; - if (a) - tempg->type=HTT_GLBL_VAR; - else - tempg->type=HTT_GLBL_VAR|HTT_UNRESOLVED_GLBL; - } else { - if (a) { - if (l->token=='=') - tempg=MAllocZ(j+sizeof(GlblVarStruct)-4); - else - tempg=MAllocZ(sizeof(GlblVarStruct)-4); - tempg->data_address=a->ip; - tempg->type=HTT_GLBL_VAR | HTT_EXPORT; - if (temph && (temph->type & HTT_GLBL_VAR)) { - tempg1=temph; - tempg1->data_address=a->ip; - } - for (k=0;kdata_address=&tempg->data; - tempg->type=HTT_GLBL_VAR; - if (temph && temph->type&HTT_GLBL_VAR && - temph->type&HTT_UNRESOLVED_GLBL) { - tempg1=temph; //TODO: do not resolve extern variables in parent tasks - tempg1->data_address=&tempg->data; - } - } - } - if (is_public) - tempg->type|=HTT_PUBLIC; - tempg->flags=0; - tempg->parameter_cnt=0; - tempg->var_class=tempc; - tempg->string=st; - tempg->size=j; - tempg->cnt=i; - tempg->use_cnt=0; - SetSourceFileInfo(l,tempg); - if (mode==PG_IMPORT || mode==PG_LTIMPORT) - tempg->flags|=GVAF_IMPORT; - if (mode==PG_EXTERN) - tempg->flags|=GVAF_EXTERN; - temph1=(a) ?FindHashBucket(st,a->glbl_hash): - FindHashBucket(st,l->hash_table_list); - tempg->next=temph1->next; - temph1->next=tempg; - if (l->token=='=') { - Lex(l); - PrsParseGlblInit(l,tempg); - if (a) { - u1=&tempg->data; - for (k=0;ksize;k++) - AsmStoreCodeU1At(l,u1[k],tempg->data_address+k); - } - } - if (l->token!=',') { - if (l->token!=';') - PrsExcept(l,"ST_MISSING_SEMICOLON"); - Lex(l); - return; - } - } -} - -void CmpParseIf(LexStruct *l,ClassStruct *locals,I8 try_count, - CbMiscStruct *break_label,CbMiscStruct *continue_label) -{ - CbMiscStruct *templ,*templ1; - I8 k; - - if (l->token!='(') - PrsExcept(l,"ST_EXPECTING_LEFT_PAREN"); - Lex(l); - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,11); - if (l->token!=')') - PrsExcept(l,"ST_MISSING_RIGHT_PAREN"); - Lex(l); - templ=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_SKIPZ2,templ,0); - CmpParseStatement(l,locals,try_count,break_label,continue_label); - k=CmpKeyWord(l); - if (k==KW_ELSE) { - Lex(l); - templ1=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_JMP,templ1,0); - CbAddIc(l,EC_LABEL,templ,0); - CmpParseStatement(l,locals,try_count,break_label,continue_label); - CbAddIc(l,EC_LABEL,templ1,0); - } else - CbAddIc(l,EC_LABEL,templ,0); -} - -void CmpParseWhile(LexStruct *l,ClassStruct *locals,I8 try_count) -{ - CbMiscStruct *templ,*templ1; - - if (l->token!='(') - PrsExcept(l,"ST_EXPECTING_LEFT_PAREN"); - Lex(l); - templ=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_LABEL,templ,0); - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,12); - if (l->token!=')') - PrsExcept(l,"ST_MISSING_RIGHT_PAREN"); - Lex(l); - - templ1=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_SKIPZ2,templ1,0); - CmpParseStatement(l,locals,try_count,templ1,templ); - CbAddIc(l,EC_JMP,templ,0); - CbAddIc(l,EC_LABEL,templ1,0); -} - -void CmpParseDoWhile(LexStruct *l,ClassStruct *locals,I8 try_count) -{ - CbMiscStruct *templ,*templ1; - - templ=CbMiscNew(l,CBMT_LABEL); - templ1=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_LABEL,templ,0); - CmpParseStatement(l,locals,try_count,templ1,templ); - if (CmpKeyWord(l)!=KW_WHILE) - PrsExcept(l,"ST_MISSING_WHILE"); - if (Lex(l)!='(') - PrsExcept(l,"ST_EXPECTING_LEFT_PAREN"); - Lex(l); - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,13); - if (l->token!=')') - PrsExcept(l,"ST_MISSING_RIGHT_PAREN"); - Lex(l); - CbAddIc(l,EC_SKIPNZ2,templ,0); - CbAddIc(l,EC_LABEL,templ1,0); -} - -void CmpParseFor(LexStruct *l,ClassStruct *locals,I8 try_count) -{ - LexCbStack *templs; - CbMiscStruct *templ,*templ1,*templ2; - - if (l->token!='(') - PrsExcept(l,"ST_EXPECTING_LEFT_PAREN"); - Lex(l); - CmpParseStatement(l,locals,try_count); - - templ=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_LABEL,templ,0); - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,14); - templ1=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_SKIPZ2,templ1,0); - if (l->token!=';') - PrsExcept(l,"ST_MISSING_SEMICOLON"); - Lex(l); - - CbPush(l); - CbInitOutPtrs(&l->cb); - templ2=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_LABEL,templ2,0); - CmpParseStatement(l,locals,try_count,NULL,NULL,FALSE); - CbAddIc(l,0,0,0); - CbPush(l); - templs=CbPopNoFree(l); - CbPop(l); - if (l->token!=')') - PrsExcept(l,"ST_MISSING_RIGHT_PAREN"); - Lex(l); - - CmpParseStatement(l,locals,try_count,templ1,templ2); - CbAppend(l,templs); - CbAddIc(l,EC_JMP,templ,0); - CbAddIc(l,EC_LABEL,templ1,0); -} - - -class SwitchCaseEntry { - SwitchCaseEntry *next; - CbMiscStruct *label; - U8 value; -}; - -void CmpParseSwitch(LexStruct *l,ClassStruct *locals,I8 try_count) -{ - SwitchCaseEntry *header=NULL,*temps,*temps1; - CbMiscStruct *templ_break,*templ_default,*templ_jmp; - IntermediateCode *tempi_sub,*tempi_cmp; - AsmCtrlStruct *a=l->a; - BoolU4 default_found=FALSE; - I8 i,k; - I8 lo=MAX_I8,hi=MIN_I8,range; - U4 *jmp_table; - - if (l->token!='(') - PrsExcept(l,"ST_EXPECTING_LEFT_PAREN"); - Lex(l); - templ_break=CbMiscNew(l,CBMT_LABEL); - templ_default=CbMiscNew(l,CBMT_LABEL); - templ_jmp=CbMiscNew(l,CBMT_JMP_TABLE); - if (!PrsParseExpression(l,FALSE)) - throw(EXCEPT_COMPILER,15); - CbAddIc(l,EC_U8,0,sys_internal_types[IT_I4]); - tempi_sub=l->cb.cb_last_out_ptr; - CbAddIc(l,EC_SUBTRACTION,0,sys_internal_types[IT_I4]); - CbAddIc(l,EC_U8,0,sys_internal_types[IT_I4]); - tempi_cmp=l->cb.cb_last_out_ptr; - CbAddIc(l,EC_SWITCH,templ_jmp,0); - CbAddIc(l,EC_JMP,templ_default,0); - if (l->token!=')') - PrsExcept(l,"ST_MISSING_RIGHT_PAREN"); - if (Lex(l)!='{') - PrsExcept(l,"ST_EXPECTING_LEFT_BRACE"); - Lex(l); - while (l->token && l->token!='}') { - k=CmpKeyWord(l); - if (k==KW_CASE) { - Lex(l); - temps=MAlloc(sizeof(SwitchCaseEntry)); - temps->label=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_LABEL,temps->label,0); - k=Expression(l); - if (l->token!=':') - PrsExcept(l,"ST_EXPECTING_COLON"); - Lex(l); - if (khi) hi=k; - temps->value=k; - temps->next=header; - header=temps; - } else if (k==KW_DEFAULT) { - if (Lex(l)==':') - Lex(l); - CbAddIc(l,EC_LABEL,templ_default,0); - default_found=TRUE; - } else - CmpParseStatement(l,locals,try_count,templ_break,NULL); - } - if (!default_found) - CbAddIc(l,EC_LABEL,templ_default,0); - CbAddIc(l,EC_LABEL,templ_break,0); - if (l->token!='}') - PrsExcept(l,"ST_MISSING_RIGHT_BRACE"); - Lex(l); - - range=hi-lo+1; - if (range<=0 || range>0x4000) - PrsExcept(l,"ST_CASE_RANGE_ERROR"); - jmp_table=MAlloc(PTR_SIZE*range); - for (i=0;iic_data=lo; - tempi_cmp->ic_data=range; - temps=header; - while (temps) { - temps1=temps->next; - jmp_table[temps->value-lo]=temps->label; - Free(temps); - temps=temps1; - } - templ_jmp->jmp_table=jmp_table; - templ_jmp->st_len=range; -} - - -void CmpParseCout(LexStruct *l,BoolU4 linefeed) -{ - ClassStruct *tempc; - SysHashEntry *temph; - IntermediateCode *tempi; - I8 cnt=0,i,j; - - while (l->token!=';') { - cnt++; - if (!PrsParseExpression(l,FALSE)) - throw(EXCEPT_COMPILER,16); - tempi=l->cb.cb_last_out_ptr; - tempc=tempi->ic_class; - j=tempc->pointer_cnt; - tempc-=sizeof(ClassStruct)*j; - while (tempc->return_class) - tempc=tempc->return_class; - temph=tempc; - if (temph->type & HTT_INTERNAL_TYPE) - i=tempc->sub_type+j*IT_NUM_IT; - else - i=IT_U4; - CbAddIc(l,EC_TYPE,i,sys_internal_types[IT_U4]); - if (l->token==',' || l->token==TK_SHL) - Lex(l); - else { - if (l->token!=';') - PrsExcept(l,"ST_EXPECTING_COMMA"); - } - } - CbAddIc(l,EC_U8,cnt,sys_internal_types[IT_U4]); - if (linefeed) - CbAddIc(l,EC_IRQ,I_COUTLN,0); - else - CbAddIc(l,EC_IRQ,I_COUT,0); - CbAddIc(l,EC_ADD_ESP32,cnt<<4+8,0); -} - -void CmpParseExeBlk(LexStruct *l) -{ - AsmCtrlStruct *a=l->a; - SysHashTable *ht1=l->hash_table_list, - *ht2=l->define_hash_table; - U8 old_hash_mask=l->hash_mask; - U8 old_flags=l->flags & (LF_ASM_EXPRESSIONS | LF_EXE_BLK); - ExeBlkStruct *tempe=MAlloc(sizeof(ExeBlkStruct)); - U4 *old_var_list=l->local_var_list; - l->local_var_list=NULL; - - tempe->body=NewString(""); - InsQue(tempe,l->last_exe_blk); - CbPush(l); //TODO Misc lists - l->hash_mask=HTT_ALL; - l->hash_table_list=Fs->hash_table; - l->define_hash_table=Fs->hash_table; - l->flags=(l->flags & ~LF_ASM_EXPRESSIONS) | - LF_EXE_BLK; - l->a=NULL; - if (l->token=='{') - Lex(l); - else - PrsExcept(l,"ST_MISSING_RIGHT_BRACE"); - while (l->token && l->token!='}') - ExecuteCmdLine(l); - l->a=a; - l->hash_table_list=ht1, - l->define_hash_table=ht2; - l->local_var_list=old_var_list; - l->hash_mask=old_hash_mask; - l->flags=(l->flags&~LF_EXE_BLK) | old_flags; - CbPop(l); - RemQue(tempe); - if (*tempe->body) - LexIncludeString(l,"ExeBlk",tempe->body,FALSE); - else - Free(tempe->body); - Free(tempe); - Lex(l); //Skip "}" -} - -void ExePutS(I1 *st) -{ - LexStruct *l=Fs->last_lex; - ExeBlkStruct *tempe=l->last_exe_blk; - if (tempe!=&l->next_exe_blk) - tempe->body=Add2String(tempe->body,st); - else - coutln "Error: No exe{} blk"; -} - -void ExePrintF(I1 *src,...) -{ - I1 *buf=SPrintFJoin(NULL,src,argc,argv); - ExePutS(buf); - Free(buf); -} - -void CmpParseTryBlk(LexStruct *l,ClassStruct *locals,I8 try_count) -{ - CbMiscStruct *templ,*templ1,*templ2; - ClassStruct *d=sys_internal_types[IT_U4], - *temp_try=FindHashEntry("SysTry",l->hash_table_list,HTT_FUNCTION), - *temp_catch=FindHashEntry("SysCatch",l->hash_table_list,HTT_FUNCTION); - - l->flags|=LF_NO_REG_OPT; - - templ=CbMiscNew(l,CBMT_LABEL); - templ1=CbMiscNew(l,CBMT_LABEL); - templ2=CbMiscNew(l,CBMT_LABEL); - CbAddIc(l,EC_GET_STACK_PTR,0,d); - CbAddIc(l,EC_GET_BASE_PTR,0,d); - CbAddIc(l,EC_GET_LABEL,templ2,d); - CbAddIc(l,EC_GET_LABEL,templ,d); - if (Bt(&temp_try->flags,Cf_EXTERN)) { - if (l->a) - CbAddIc(l,EC_CALL_INDIRECT2,temp_try->executable_address,d); - else - CbAddIc(l,EC_CALL_INDIRECT2,&temp_try->executable_address,d); - } else - CbAddIc(l,EC_CALL,temp_try->executable_address,d); - CbAddIc(l,EC_ADD_ESP32,40,d); - - if (try_count<0) - CmpParseStatement(l,locals,try_count-1); - else - CmpParseStatement(l,locals,try_count+1); - - CbAddIc(l,EC_LABEL,templ2,0); - if (Bt(&temp_catch->flags,Cf_EXTERN)) { - if (l->a) - CbAddIc(l,EC_CALL_INDIRECT2,temp_catch->executable_address,d); - else - CbAddIc(l,EC_CALL_INDIRECT2,&temp_catch->executable_address,d); - } else - CbAddIc(l,EC_CALL,temp_catch->executable_address,d); - CbAddIc(l,EC_ADD_ESP32,8,d); - - CbAddIc(l,EC_JMP,templ1,0); - - if (CmpKeyWord(l)!=KW_CATCH) - PrsExcept(l,"ST_MISSING_CATCH"); - Lex(l); - - CbAddIc(l,EC_LABEL,templ,0); - if (try_count<0) - CmpParseStatement(l,locals,try_count-1); - else - CmpParseStatement(l,locals,-try_count-1); - CbAddIc(l,EC_RET,0,d); - CbAddIc(l,EC_LABEL,templ1,0); -} - -void CmpParseAsmBlk(LexStruct *l) -{ - AsmCtrlStruct *a=l->a; - I8 i,j; - OpcodeHashEntry *tempo; - SysHashEntry *temph,**temph1; - U8 argcnt,saved_ip; - BoolU4 is_literal; - U1 *file_buf,*b; - U8 file_size; - U8 old_hash_mask=l->hash_mask; - I1 *next_last_label; - ArcCompressStruct *ac; - void my_CmpParseExeBlk(LexStruct *l); - - if (!a) - PutAsmError(l,"ST_ASM_NOT_ALLOWED"); - - a->use16=FALSE; - l->flags|=LF_ASM_EXPRESSIONS; - l->hash_mask&=~(HTT_INTERNAL_TYPE|HTT_CLASS|HTT_PUBLIC| - HTT_WORD|HTT_LOCAL_VAR|HTT_GLBL_VAR|HTT_FUNCTION|HTT_FILE| - HTT_MODULE|HTT_PRIVATE|HTT_EXPORT|HTT_IMPORT); - if (l->token=='{') - Lex(l); - else - PrsExcept(l,"ST_MISSING_RIGHT_BRACE"); - while (l->token && l->token!='}') { - AsmListLine(l); - if (l->token==TK_IDENT && l->hash_entry) { - if (l->hash_entry->type==HTT_KEYWORD) { - i=l->hash_entry->user0; - Lex(l); //skip keyword - switch (i) { - case AKW_IMPORT: - case AKW_EXPORT: - while (l->token && l->token!=';') { - if (l->token=='#') { - is_literal=TRUE; - Lex(l); - } else - is_literal=FALSE; - if (l->token==TK_IDENT) { - if (temph=l->hash_entry) { - temph=FindHashEntry(l->ident,a->glbl_hash,HTT_ALL); - if (temph) - temph->type=HTT_SYS_SYMBOL+HTT_UNRESOLVED_GLBL; - } - if (!temph) { - temph=MAllocZ(sizeof(SysHashEntry)); - temph->string=l->ident; - l->ident=0; - temph->type=HTT_SYS_SYMBOL+HTT_UNRESOLVED_GLBL; - temph->use_cnt=0; - temph->user0=0; - temph->user1=NULL; - SetSourceFileInfo(l,temph); - temph1=FindHashBucket(temph->string,a->glbl_hash); - temph->next=*temph1; - *temph1=temph; - } - if (i==AKW_IMPORT) - temph->type=temph->type | HTT_IMPORT; - else if (i==AKW_EXPORT) - temph->type=temph->type | HTT_EXPORT; - if (is_literal) - temph->type=temph->type | HTT_LITERAL; - if (Lex(l)==',') - Lex(l); //skip ',' - } else { - PutAsmError(l,"ST_EXPECTING_IDENTIFIER"); - break; - } - } - if (l->token!=';') - PutAsmError(l,"ST_MISSING_SEMICOLON"); - else - Lex(l); //skip ';'; - break; - case AKW_ALIGN: - if (l->token!=TK_INTEGER) - PutAsmError(l,"ST_EXPECTING_INTEGER"); - else { - i=(a->ip+l->cur_i-1) & -l->cur_i; - if (Lex(l)==',') - Lex(l); - if (l->token==TK_INTEGER) { - for (j=a->ip;jcur_i); - Lex(l); - } else - a->ip=i; - } - break; - case AKW_END: - break; //TODO - case KW_EXE: - my_CmpParseExeBlk=ext[EXT_CMP_EXE_BLK]; - my_CmpParseExeBlk(l); - break; - case AKW_DU1: - DefineU1s(l,a,1); - break; - case AKW_DU2: - DefineU1s(l,a,2); - break; - case AKW_DU4: - DefineU1s(l,a,4); - break; - case AKW_DU8: - DefineU1s(l,a,8); - break; - case AKW_INSERT: - if (l->token!=TK_STRING) - PutAsmError(l,"ST_EXPECTING_STRING"); - else { - file_buf=ReadFile(l->ident,&file_size); - if (file_buf) { - for (i=0;itoken!=TK_STRING) - PutAsmError(l,"ST_EXPECTING_STRING"); - else { - file_buf=ReadFile(l->ident,&file_size); - if (file_buf) { - ac=CompressBuf(file_buf,file_size); - b=ac; - for (i=0;icompressed_size;i++) - AsmStoreCodeU1(l,b[i]); - Free(file_buf); - Free(ac); - } - Lex(l); - } - break; - case AKW_LIST: - a->list=TRUE; - break; - case AKW_NOLIST: - a->list=FALSE; - break; - case AKW_ORG: - a->ip=AsmEvalExpression(l); - break; - case AKW_STRUC: - a->flags|=ACSF_IN_STRUCT; - saved_ip=a->ip; - a->ip=AsmEvalExpression(l); - break; - case AKW_ENDS: - a->ip=saved_ip; - a->flags&=~ACSF_IN_STRUCT; - break; - case AKW_USE16: - a->use16=TRUE; - break; - case AKW_USE32: - a->use16=FALSE; - break; - default: - PutAsmError(l,"ST_SYNTAX_ERROR"); - break; - } - } else if (l->hash_entry->type & HTT_OPCODE) { - tempo=l->hash_entry; - Lex(l); //skip opcode - argcnt=0; - if (tempo->ins[0].arg1) { - argcnt++; - ParseAsmArg(l,a,&a->arg1,a->ip); - if (tempo->ins[0].arg2) { - argcnt++; - if (l->token!=',') - PutAsmError(l,"ST_EXPECTING_COMMA"); - else { - Lex(l); //skip ',' - ParseAsmArg(l,a,&a->arg2,a->ip); - } - } - } - AsmCodeInstruction(l,a,tempo,argcnt); - } else if (l->hash_entry->type & HTT_SYS_SYMBOL) { - if (a->flags & ACSF_IN_STRUCT) - l->hash_entry->type|=HTT_LITERAL; - else - l->hash_entry->type&=~HTT_LITERAL; - if (l->hash_entry->type & HTT_UNRESOLVED_LOCAL) { - l->hash_entry->type&=~HTT_UNRESOLVED_LOCAL; - l->hash_entry->user0=a->ip; - if (Lex(l)!=':') - PutAsmError(l,"ST_EXPECTING_COLON"); - else - Lex(l); - } else if (l->hash_entry->type & HTT_UNRESOLVED_GLBL) { - if (l->hash_entry->type & HTT_IMPORT) - PutAsmError(l,"ST_ATTEMPT_DEFINE_IMPORT"); - else { - l->hash_entry->type&=~HTT_UNRESOLVED_GLBL; - l->hash_entry->user0=a->ip; - next_last_label=l->hash_entry->string; - Lex(l); //Skip ident - if (l->token!=':' && l->token!=TK_DOUBLE_COLON) - PutAsmError(l,"ST_EXPECTING_COLON"); - else { - if (l->token==TK_DOUBLE_COLON) { - l->hash_entry->type|=HTT_EXPORT; - ResolveLocals(l); - a->last_label=next_last_label; - } - if (Lex(l)=='#') { - Lex(l); - l->hash_entry->type|=HTT_LITERAL | HTT_EXPORT; - } - } - } - } else - PutAsmError(l,"ST_REDEFINITION"); - } else - PutAsmError(l,"ST_SYNTAX_ERROR"); - } else { - if (l->token==TK_IDENT) { - temph=MAllocZ(sizeof(SysHashEntry)); - temph->string=l->ident; - l->ident=0; - temph->type=HTT_SYS_SYMBOL; - if (a->flags & ACSF_IN_STRUCT) - temph->type|=HTT_LITERAL; - temph->use_cnt=0; - SetSourceFileInfo(l,temph); - temph->user0=a->ip; - temph->user1=NULL; - Lex(l); //Skip ident - if (l->token==':' || l->token==TK_DOUBLE_COLON) { - if (temph->string[0]=='@' && temph->string[1]=='@') { - temph1=FindHashBucket(temph->string,a->local_hash); - a->has_locals=TRUE; - } else - temph1=FindHashBucket(temph->string,a->glbl_hash); - temph->next=*temph1; - *temph1=temph; - if (l->token==TK_DOUBLE_COLON) { - temph->type=temph->type | HTT_EXPORT; //Export - ResolveLocals(l); - a->last_label=temph->string; - Lex(l); - } else { - if (Lex(l)=='#') { - temph->type=temph->type | HTT_EXPORT | HTT_LITERAL; //Export - ResolveLocals(l); - a->last_label=temph->string; - Lex(l); - } - } - } else { - PutAsmError(l,"ST_EXPECTING_COLON"); - Free(temph->string); - Free(temph); - } - } else - PutAsmError(l,"ST_SYNTAX_ERROR"); - } - } - ResolveLocals(l); - l->flags&=~LF_ASM_EXPRESSIONS; - l->hash_mask=old_hash_mask; - Lex(l); //Skip "}" -} - -BoolU4 CmpParseStatement(LexStruct *l,ClassStruct *locals,I8 try_count=0, - CbMiscStruct *break_label=NULL,CbMiscStruct *continue_label=NULL, - BoolU4 saved_prs_semicolon=TRUE) -{ - BoolU4 prs_exp,cont,prs_semicolon,is_asm=FALSE, - is_public=FALSE,last_is_public=FALSE; - U8 i; - SysHashEntry *temph; - CbMiscStruct *templ; - I1 *import_name; - ClassStruct *d,*temp_catch; - void my_CmpParseExeBlk(LexStruct *l); - do { - is_public=FALSE; - cont=FALSE; - prs_exp=FALSE; - prs_semicolon=saved_prs_semicolon; - l->statement_cnt++; - while (l->token==',') - Lex(l); - if (l->token=='{') { - l->braces_cnt++; - Lex(l); - while (l->token!='}') - CmpParseStatement(l,locals,try_count,break_label,continue_label); - l->braces_cnt--; - l->statement_cnt--; - Lex(l); - } else if (l->token==TK_EOF) ; - else if (l->token==';') { - if (prs_semicolon) { - l->statement_cnt--; - Lex(l); - } - } else { - if (l->token==TK_IDENT) { - if (temph=l->hash_entry) { - if (temph->type & HTT_KEYWORD) { - i=temph->user0; - switch (i) { - case KW_IF: - Lex(l); - CmpParseIf(l,locals,try_count,break_label,continue_label); - prs_semicolon=FALSE; - break; - case KW_FOR: - Lex(l); - CmpParseFor(l,locals,try_count); - prs_semicolon=FALSE; - break; - case KW_WHILE: - Lex(l); - CmpParseWhile(l,locals,try_count); - prs_semicolon=FALSE; - break; - case KW_DO: - Lex(l); - CmpParseDoWhile(l,locals,try_count); - prs_semicolon=FALSE; - break; - case KW_SWITCH: - Lex(l); - CmpParseSwitch(l,locals,try_count); - prs_semicolon=FALSE; - break; - case KW_LTEXTERN: - Lex(l); - if (Bt(&l->flags,LFf_EXTERNS_TO_IMPORTS)) - goto keyword_LTimport; - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_SYS_SYMBOL"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_SYS_SYMBOL"); - if (!(temph->type & HTT_SYS_SYMBOL)) - PrsExcept(l,"ST_EXPECTING_SYS_SYMBOL"); - i=temph->user0; - if (Lex(l)!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (locals) - PrsExcept(l,"ST_NOT_ALLOWED_IN_FUNCTION"); - CmpParseGlblVarList(l,PG_LTEXTERN,temph,i,last_is_public); - prs_semicolon=FALSE; - cont=TRUE; - break; - case KW_LTIMPORT: - Lex(l); -keyword_LTimport: - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_SYS_SYMBOL"); - import_name=l->ident; - l->ident=0; - if (Lex(l)!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (locals) - PrsExcept(l,"ST_NOT_ALLOWED_IN_FUNCTION"); - CmpParseGlblVarList(l,PG_LTIMPORT,temph,import_name,FALSE); - Free(import_name); - prs_semicolon=FALSE; - cont=TRUE; - break; - case KW_INTERNAL: - Lex(l); - if (l->token!=TK_INTEGER) - PrsExcept(l,"ST_EXPECTING_INTEGER"); - i=l->cur_i; - if (Lex(l)!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (locals) - PrsExcept(l,"ST_NOT_ALLOWED_IN_FUNCTION"); - CmpParseGlblVarList(l,PG_LTINTERN,temph,i,last_is_public); - prs_semicolon=FALSE; - cont=TRUE; - break; - case KW_EXTERN: - Lex(l); - if (Bt(&l->flags,LFf_EXTERNS_TO_IMPORTS)) - goto keyword_import; - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (locals) - PrsExcept(l,"ST_NOT_ALLOWED_IN_FUNCTION"); - CmpParseGlblVarList(l,PG_EXTERN,temph,0,last_is_public); - prs_semicolon=FALSE; - cont=TRUE; - break; - case KW_IMPORT: - Lex(l); -keyword_import: - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph=l->hash_entry)) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) - PrsExcept(l,"ST_EXPECTING_TYPE"); - if (locals) - PrsExcept(l,"ST_NOT_ALLOWED_IN_FUNCTION"); - CmpParseGlblVarList(l,PG_IMPORT,temph,0,FALSE); - prs_semicolon=FALSE; - cont=TRUE; - break; - case KW_ASM: - Lex(l); - CmpParseAsmBlk(l); - prs_semicolon=FALSE; - is_asm=TRUE; - break; - case KW_EXE: - Lex(l); - my_CmpParseExeBlk=ext[EXT_CMP_EXE_BLK]; - my_CmpParseExeBlk(l); - prs_semicolon=FALSE; - break; - case KW_TRY: - Lex(l); - CmpParseTryBlk(l,locals,try_count); - prs_semicolon=FALSE; - break; - case KW_BREAK: - Lex(l); - if (!break_label) - PrsExcept(l,"ST_BREAK_NOT_ALLOWED"); - CbAddIc(l,EC_JMP,break_label,0); - break; - case KW_CONTINUE: - Lex(l); - if (!continue_label) - PrsExcept(l,"ST_CONTINUE_NOT_ALLOWED"); - CbAddIc(l,EC_JMP,continue_label,0); - break; - case KW_RETURN: - Lex(l); - if (l->token!=';') { - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,17); - } - if (try_count<0) {//inside catch{} - CbAddIc(l,EC_GET_BASE_PTR,0,0); - CbAddIc(l,EC_U8,locals->size,sys_internal_types[IT_U8]); - CbAddIc(l,EC_ADDITION,0,sys_internal_types[IT_U8]); - CbAddIc(l,EC_SET_STACK_PTR,0,0); - try_count=-try_count; //force removal from queue - } - if (try_count) { - d=sys_internal_types[IT_U4]; - temp_catch=FindHashEntry("SysCatch", - l->hash_table_list,HTT_FUNCTION); - for (i=0;iflags,Cf_EXTERN)) { - if (l->a) - CbAddIc(l,EC_CALL_INDIRECT2, - temp_catch->executable_address,d); - else - CbAddIc(l,EC_CALL_INDIRECT2, - &temp_catch->executable_address,d); - } else - CbAddIc(l,EC_CALL,temp_catch->executable_address,d); - CbAddIc(l,EC_ADD_ESP32,8,d); - } - } - if (locals) - CbAddIc(l,EC_LEAVE,0,0); - else - CbAddIc(l,EC_RET,0,0); - break; - case KW_GOTO: - Lex(l); - if (l->token!=TK_IDENT) - PrsExcept(l,"ST_EXPECTING_IDENTIFIER"); - if (!(templ=CbFindGotoLabel(l,l->ident))) { - templ=CbMiscNew(l,CBMT_GOTO_LABEL); - templ->string=l->ident; - l->ident=NULL; - } - CbAddIc(l,EC_JMP,templ,0); - Lex(l); - break; - case KW_COUT: - Lex(l); - CmpParseCout(l,FALSE); - break; - case KW_COUTLN: - Lex(l); - CmpParseCout(l,TRUE); - break; - case KW_CLASS: - Lex(l); - CmpParseClass(l,FALSE,last_is_public); - break; - case KW_UNION: - Lex(l); - CmpParseClass(l,TRUE,last_is_public); - break; - case KW_PUBLIC: - Lex(l); - is_public=TRUE; - cont=TRUE; - prs_semicolon=FALSE; - break; - default: - prs_exp=TRUE; - break; - } - } else if (temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE)) { - if (locals) - CmpParseVarList(l,locals,PVLM_LOCAL_VAR); - else - CmpParseGlblVarList(l,PG_NULL,temph,0,last_is_public); - prs_semicolon=FALSE; - cont=TRUE; - } else prs_exp=TRUE; - } else { - if (l->local_var_entry) - prs_exp=TRUE; - else { - if (!(templ=CbFindGotoLabel(l,l->ident))) { - templ=CbMiscNew(l,CBMT_GOTO_LABEL); - templ->string=l->ident; - l->ident=NULL; - } - CbAddIc(l,EC_LABEL,templ,0); - if (Lex(l)==':') //skip ident - Lex(l); //skip colon - else - PrsExcept(l,"ST_UNDEFINED_IDENTIFIER"); - prs_semicolon=FALSE; - } - } - } else prs_exp=TRUE; - if (prs_exp) { - if (!PrsParseExpression(l,TRUE)) - throw(EXCEPT_COMPILER,18); - } - if (l->token!=',') - l->statement_cnt--; - if (prs_semicolon && l->token!=',') { - if (l->token==';') - Lex(l); - else - PrsExcept(l,"ST_MISSING_SEMICOLON"); - } - } - last_is_public=is_public; - } while (l->token==',' || cont); - return is_asm; -} - -U1 *CompileStatement(LexStruct *l,U8 *type=NULL) -{ - U1 *result=INVALID_PTR; - AsmCtrlStruct *a=l->a; - U8 size,i,j; - DbgInfo *dbg=NULL; - if (type) *type=IT_U8; - CbInitOutPtrs(&l->cb); - if (!CmpParseStatement(l,NULL)) { - CbAddIc(l,EC_RET,0,0); - CbAddIc(l,0,0,0); - if (result=CbCompile(l,NULL,&size,&dbg,type)) { - if (a) { - if (size!=1) {//not just RET - j=a->ip; - for (i=0;icb.cb_out_first); - Free(dbg); - return result; -} - - -ExeStruct *CompileBuf(U1 *buf,I1 *map_name=NULL, - I8 *error_cnt=NULL, I8 *warning_cnt=NULL,I1 mapfile_drive=0) -{ - BoolU4 okay=TRUE; - LexStruct *l; - AsmCtrlStruct *a; - U8 i,j; - ExeStruct *result=NULL; - AsmCodeBlk *tempc; - ExeImportExportStruct *tempe,*tempe1; - void my_HashRep(SysHashTable *h,U8 mask,I1 *outname,I1 *flags,I1 drive); - - if (!is_first_compiler) - coutln "$$FG PURPLE$$**** Not First Compiler ****$$FG$$"; - - my_HashRep=FindExtern("HashRep"); - result=MAllocZ(sizeof(ExeStruct)); - l=LexNew(buf,LF_DONT_FREE_BUFFER,NULL); - InsQue(l,Fs->last_lex); - - a=MAllocZ(sizeof(AsmCtrlStruct)); - a->code=MAllocZ(sizeof(AsmCodeBlk)); - a->local_hash=NewHashTable(16); - a->glbl_hash=NewHashTable(2048); - a->glbl_hash->next=asm_hash; - a->local_hash->next=a->glbl_hash; - - l->a=a; - l->hash_table_list=a->local_hash; - l->define_hash_table=a->glbl_hash; - l->local_hash_table=a->local_hash; - l->glbl_hash_table=a->glbl_hash; - Lex(l); -try { - while (l->token!=TK_EOF) { - i=CompileStatement(l); - if (i!=INVALID_PTR) { - tempe=MAlloc(sizeof(ExeImportExportStruct)); - tempe->type=EIE_MAIN; - tempe->ip=i; - tempe->string=NULL; - tempe->next=NULL; - tempe1=&result->ie; - while (tempe1->next) //TODO:This could be optimized - tempe1=tempe1->next; - tempe1->next=tempe; - } - } - ResolveGlbls(l,result); -} catch { - if (Fs->except_argc>0) - if (Fs->except_argv[0]==EXCEPT_COMPILER) - Fs->catch_except=TRUE; - okay=FALSE; -} - RemQue(l); - if (error_cnt) *error_cnt=l->error_cnt; - if (warning_cnt) *warning_cnt=l->warning_cnt; - if (!okay) { - //TODO free debug info and possibly classes - if (error_cnt) - if (*error_cnt<1) *error_cnt=1; - result=NULL; - } else { - if (map_name) - my_HashRep(a->glbl_hash,HTT_ALL,map_name,"",mapfile_drive); - LexDel(l); - DelHashTable(a->local_hash); - DelHashTable(a->glbl_hash); - - if (!a->num_code_U1s) - result->code=NULL; - else { - result->code=MAlloc(a->num_code_U1s); - result->code_U1s=a->num_code_U1s; - tempc=a->code; - j=0; - l=a->num_code_U1s; - while (tempc) { - i=l; - if (i>ASM_CODE_BLK_SIZE) - i=ASM_CODE_BLK_SIZE; - MemCpy(result->code+j,tempc->body,i); - j+=i; - l-=i; - tempc=tempc->next; - } - } - DelLinkedList(a->code); - result->absolutes=a->absolutes; - Free(a); - } - return result; -} - - -I8 CompileFile(I1 *filename,I1 *map_name=NULL,I1 *out_name=NULL,I1 mapfile_drive=0) -{ - I1 *fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL; - ExeStruct *e; - U4 *dd; - U8 size=0; - U1 *header=MAlloc(0x20000),*ptr; - BinFileHeaderStruct *bfh; - U8 i,cnt=0,error_cnt=0,warning_cnt=0; - ExeImportExportStruct *tempe,*tempe1; - ExeAbsoluteAddressStruct *tempa,*tempa1; - - fbuf=DefaultExtension(filename,"CPZ"); - fbuf2=MSPrintF("#include \"%s\"",fbuf); - if (map_name) - fbuf3=DefaultExtension(map_name,"MPZ"); - e=CompileBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drive); - - if (e) { - ptr=header; - tempa=e->absolutes; - while (tempa) { - cnt++; - tempa=tempa->next; - } - if (cnt) { - *ptr++=EIE_ABSOLUTE_ADDRESS; - dd=ptr; - *dd=cnt; - ptr+=sizeof(U4); - *ptr++=0; - tempa=e->absolutes; - while (tempa) { - tempa1=tempa->next; - dd=ptr; - *dd=tempa->ip; - ptr+=sizeof(U4); - Free(tempa); - tempa=tempa1; - } - } - tempe=e->ie; - while (tempe) { - tempe1=tempe->next; - *ptr++=tempe->type; - dd=ptr; - *dd=tempe->ip; - ptr+=sizeof(U4); - if (tempe->string) { - i=StrLen(tempe->string); - MemCpy(ptr,tempe->string,i+1); - Free(tempe->string); - ptr+=i+1; - } else - *ptr++=0; - Free(tempe); - tempe=tempe1; - } - *ptr++=EIE_END; - i=(ptr-header+15) & -0x10; - size=i+e->code_U1s+sizeof(BinFileHeaderStruct); - bfh=MAlloc(size); - MemCpy(bfh+e->code_U1s+sizeof(BinFileHeaderStruct),header,i); - MemCpy(bfh+sizeof(BinFileHeaderStruct),e->code,e->code_U1s); - bfh->jmp=0xE9+256*(16-3); - bfh->header_offset=e->code_U1s+sizeof(BinFileHeaderStruct); - bfh->file_size=size; - bfh->xsum=LT_XSUM; - bfh->xsum=ArcCheckSum(bfh,size); - Free(fbuf2); - if (out_name) - fbuf2=DefaultExtension(out_name,"BIZ"); - else - fbuf2=ChangeExtension(fbuf,"BIZ"); - WriteFile(fbuf2,bfh,size); - Free(bfh); - Free(e->code); - Free(e); - } - Free(header); - Free(fbuf); - Free(fbuf2); - Free(fbuf3); - PrintF(SysText("ST_ERRORS_WARNINGS"),error_cnt,warning_cnt,size); - return error_cnt; -} - -I8 ExecuteCmdLine(LexStruct *l) -{ - I8 result=0,i,type; - double *resultd; - I1 *ptr,*ptr2,*ptr3; - U1 *code; - LtfEntry *cl; - Ltf *ltf; - while (l->token && - (l->token!='}' || !(l->flags & LF_EXE_BLK)) ) { - ptr2=&Fs->task_descriptor; - ptr3=ptr2+TSS_DESC_LENGTH; - if (l->cur_lfn->flags & LFSF_IS_LTF) { - cl=l->cur_lfn->line_start; - ltf=l->cur_lfn->l; - while (cl!=ltf && ptr2btype && ptr2display; - while (*ptr && ptr2next; - } - } else - if (ptr=l->cur_lfn->line_start) - MemCpy(ptr2,ptr,TSS_DESC_LENGTH); - code=CompileStatement(l,&type); - if (code!=INVALID_PTR) { - result=Run(code); - for (i=6;i>=0;i--) { - Fs->answers[i+1]=Fs->answers[i]; - Fs->double_answers[i+1]=Fs->double_answers[i]; - Fs->answers_types[i+1]=Fs->answers_types[i]; - } - Fs->answers[0]=result; - - resultd=&result; - Fs->double_answers[0]=*resultd; - - Fs->answers_types[0]=type; - Free(code); - } - } - return result; -} - -void ContinueUserTask() -{ - LexStruct *l; - while (TRUE) { - l=LexNew(NULL,LF_PROMPT,NULL); - InsQue(l,Fs->last_lex); - try { - Lex(l); - ExecuteCmdLine(l); - } catch - CatchAll; - RemQue(l); - //LexDel(l); //Sometimes crashes on BREAK - } -} - - -I8 ExecuteString(I1 *buf,I1 *filename=NULL) -{ - I8 result; - BoolU4 okay=TRUE; - LexStruct *l; - if (!filename) - filename=sys_temp_filename; - l=LexNew(buf,LF_DONT_FREE_BUFFER,AbsoluteFileName(filename)); - InsQue(l,Fs->last_lex); - try { - Lex(l); - result=ExecuteCmdLine(l); - } catch { - if (Fs->except_argc>0) - if (Fs->except_argv[0]==EXCEPT_COMPILER || - Fs->except_argv[0]==EXCEPT_BREAK) { - Fs->catch_except=TRUE; - okay=FALSE; - result=0; - } - } - RemQue(l); - if (okay) - LexDel(l); - return result; -} - -I8 ExecuteFile(I1 *name) -{ - I8 result; - I1 *name2=DefaultExtension(name,"CPZ"); - I1 *st=MSPrintF("#include \"%s\";",name2); - result=ExecuteString(st,name); - Free(st); - Free(name2); - return result; -} - -void LoadCompileSysText() -{ - LoadStr("ST_ERROR","ERROR: "); - LoadStr("ST_MISSING_SEMICOLON","missing ';' at"); - LoadStr("ST_MISSING_EXPRESSION","missing Expression at "); - LoadStr("ST_MISSING_RIGHT_PAREN","missing ')' at "); - LoadStr("ST_MISSING_RIGHT_BRACKET","missing ']' at "); - LoadStr("ST_UNDEFINED_SYMBOL","undefined symbol at "); - LoadStr("ST_UNDEFINED_IDENTIFIER","undefined identifier at "); - LoadStr("ST_INVALID_CLASS","invalid class at "); - LoadStr("ST_INVALID_MEMBER","invalid member at "); - LoadStr("ST_EXPECTING_TYPE","expecting type at "); - LoadStr("ST_EXPECTING_IDENTIFIER","expecting identifier at "); - LoadStr("ST_EXPECTING_RIGHT_PAREN","expecting ')' at "); - LoadStr("ST_EXPECTING_LEFT_BRACE","expecting '{' at "); - LoadStr("ST_MISSING_RIGHT_BRACE","missing '}' at "); - LoadStr("ST_INVALID_LVALUE","invalid lvalue at "); - LoadStr("ST_EXPECTING_EQUAL","expecting '=' at "); - LoadStr("ST_NOT_POINTER_TYPE","not pointer type at "); - LoadStr("ST_EXPECTING_COMMA","expecting ',' at "); - LoadStr("ST_EXPECTING_SYS_SYMBOL","expecting System symbol at "); - LoadStr("ST_EXPECTING_STRING","expecting string at "); - LoadStr("ST_MISSING_WHILE","missing 'while' at"); - LoadStr("ST_UNKNOWN_STATEMENT","unknown statement at "); - LoadStr("ST_ALREADY_ONE_IMMEDIATE","already one immediate at "); - LoadStr("ST_SYNTAX_ERROR","syntax error at "); - LoadStr("ST_EXPECTING_SCALE_FACTOR","expecting scale factor at "); - LoadStr("ST_QUESTION_NOT_ALLOWED","'?' not allowed at "); - LoadStr("ST_EXPECTING_LEFT_PAREN","expecting '(' at "); - LoadStr("ST_UNDEFINED_DUP_CNT","undefined DUP cnt at "); - LoadStr("ST_EXPECTING_COLON","expecting ':' at "); - LoadStr("ST_EXPECTING_DOUBLE_COLON","expecting '::' at "); - LoadStr("ST_EXPECTING_DOT","expecting '.' at "); - LoadStr("ST_REDEFINITION","redefinition at "); - LoadStr("ST_INVALID_INSTRUCTION","invalid instruction at "); - LoadStr("ST_INTERNAL_ERROR","LTintern error at "); - LoadStr("ST_BRANCH_OUT_OF_RANGE","branch out of range at "); - LoadStr("ST_ATTEMPT_DEFINE_IMPORT","attempt to define import at "); - LoadStr("ST_COULD_USE_U1_DISP","could use U1 displacement at "); - LoadStr("ST_WARNING","WARNING: "); - LoadStr("ST_LINE","line: "); - LoadStr("ST_NO_SIZE_SPECIFIED","no size specified at "); - LoadList("ST_U1_REGS","AL\0CL\0DL\0BL\0AH\0CH\0DH\0BH\0"); - LoadList("ST_U2_REGS","AX\0CX\0DX\0BX\0SP\0BP\0SI\0DI\0"); - LoadList("ST_U4_REGS","EAX\0ECX\0EDX\0EBX\0ESP\0EBP\0ESI\0EDI\0"); - LoadList("ST_OPCODE_MODIFIERS","NO\0R\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0RB\0RW\0RD\0"); - LoadList("ST_ARGUMENT_TYPES", - "NO\0REL8\0REL16\0REL32\0UIMM8\0UIMM16\0UIMM32\0R8\0R16\0R32\0" - "IMM8\0IMM16\0IMM32\0RM8\0RM16\0RM32\0M8\0M16\0M32\0" - "M1616\0M1632\0M16N32\0M16N16\0M32N32\0" - "MOFFS8\0MOFFS16\0MOFFS32\0CL\0" - "AL\0AX\0EAX\0DX\0SS\0DS\0ES\0FS\0GS\0SREG\0CS\0"); - LoadList("ST_SEG_REGS","ES\0CS\0SS\0DS\0FS\0GS\0"); - LoadStr("ST_EXPECTING_INTEGER","expecting integer at "); - LoadStr("ST_DIVIDE_BY_ZERO","Divide by zero at "); - LoadStr("ST_OPT_INTERNAL_ERROR","Compiler Optimization Error at "); - LoadStr("ST_UNRESOLVED_REFERENCE","Unresolved Reference:"); - LoadStr("ST_NOT_DEFINED","Not Defined"); - LoadStr("ST_SCANNING_DIRECTORY","Scanning Directory:"); - LoadStr("ST_ASM_NOT_ALLOWED","ASM not allowed"); - LoadStr("ST_UNUSED_VAR","Unused Var"); - LoadStr("ST_NOT_ALLOWED_IN_FUNCTION","Not allowed in function"); - LoadStr("ST_MISSING_CATCH","missing 'catch' at"); - LoadStr("ST_UNDEFINED_GOTO_LABEL","Undefined goto label:"); - LoadStr("ST_BREAK_NOT_ALLOWED","'break' not allowed\r\n"); - LoadStr("ST_CONTINUE_NOT_ALLOWED","'continue' not allowed\r\n"); - LoadStr("ST_ERRORS_WARNINGS","Errors:%04d Warnings:%04d Size:%08X\r\n"); - LoadStr("ST_IMPORT_NOT_NEEDED","import not needed at "); - LoadStr("ST_EXPECTING_CASE","expecting 'case' at "); - LoadStr("ST_CASE_RANGE_ERROR","switch range error at "); - LoadStr("ST_LEX_STACK_OVERFLOW","Lex Stack overflow"); - LoadStr("ST_STRING_DEFAULT","String defaults not implemented in static mode at "); - -$AN,"Anchor for inserting Compiler systext","COMPILE_SYSTEXT"$ - - - LoadList("ST_INTERMEDIATE_CODE", - -//The first character is a flag -// '*' means it is a dereferrence instruction -// '=' means it is an assignment instruction - -".NULL\0" -".NOP\0" -".END_EXP\0" -".ZERO\0" -".U8\0" -".U4\0" -".U2\0" -".U1\0" -".DOUBLE\0" -".STRING_CONSTANT\0" -".EBP\0" -".FS\0" -".ESI\0" -".EDI\0" -".TO_DOUBLE\0" -".TO_INT\0" -".COM\0" -".NOT\0" -".UNARY_MINUS\0" -".ADDRESS\0" -".U8_DISP32\0" -".U4_DISP32\0" -".U2_DISP32\0" -".U1_DISP32\0" -".U8_DISP8\0" -".U4_DISP8\0" -".U2_DISP8\0" -".U1_DISP8\0" -".FS_U8_DISP32\0" -".FS_U4_DISP32\0" -".FS_U2_DISP32\0" -".FS_U1_DISP32\0" -".ESI_U8_DISP32\0" -".ESI_U4_DISP32\0" -".ESI_U2_DISP32\0" -".ESI_U1_DISP32\0" -".ESI_U8_DISP8\0" -".ESI_U4_DISP8\0" -".ESI_U2_DISP8\0" -".ESI_U1_DISP8\0" -".EDI_U8_DISP32\0" -".EDI_U4_DISP32\0" -".EDI_U2_DISP32\0" -".EDI_U1_DISP32\0" -".EDI_U8_DISP8\0" -".EDI_U4_DISP8\0" -".EDI_U2_DISP8\0" -".EDI_U1_DISP8\0" -"*DEREF_U8\0" -"*DEREF_U4\0" -"*DEREF_U2\0" -"*DEREF_U1\0" -"*ESI_DEREF_U8\0" -"*ESI_DEREF_U4\0" -"*ESI_DEREF_U2\0" -"*ESI_DEREF_U1\0" -"*EDI_DEREF_U8\0" -"*EDI_DEREF_U4\0" -"*EDI_DEREF_U2\0" -"*EDI_DEREF_U1\0" -"*U8_PP\0" -"*U4_PP\0" -"*U2_PP\0" -"*U1_PP\0" -"*U8_MM\0" -"*U4_MM\0" -"*U2_MM\0" -"*U1_MM\0" -"*PP_U8\0" -"*PP_U4\0" -"*PP_U2\0" -"*PP_U1\0" -"*MM_U8\0" -"*MM_U4\0" -"*MM_U2\0" -"*MM_U1\0" -"*ESI_U4_PP\0" -"*ESI_U4_MM\0" -"*ESI_PP_U4\0" -"*ESI_MM_U4\0" -"*EDI_U4_PP\0" -"*EDI_U4_MM\0" -"*EDI_PP_U4\0" -"*EDI_MM_U4\0" -".LEA_DISP32_EBP\0" -".LEA_DISP8_EBP\0" -".U8_DISP32_SCALED\0" -".U4_DISP32_SCALED\0" -".U2_DISP32_SCALED\0" -".SHL\0" -".SHR\0" -".SHL_CONSTANT1\0" -".SHL_CONSTANT2\0" -".SHR_CONSTANT1\0" -".SHR_CONSTANT2\0" -".POWER\0" -".MULTIPLICATION\0" -".DIVISION\0" -".REMAINDER\0" -".AND\0" -".OR\0" -".XOR\0" -".ADDITION\0" -".SUBTRACTION\0" -".EQUAL_EQUAL\0" -".NOT_EQUAL_TO\0" -".LESS_THAN\0" -".GREATER_THAN\0" -".LESS_OR_EQUAL\0" -".GREATER_OR_EQUAL\0" -".AND_AND\0" -".OR_OR\0" -".XOR_XOR\0" -".COLON\0" -".QUESTION\0" -"=ASSIGN_U8\0" -"=ASSIGN_U4\0" -"=ASSIGN_U2\0" -"=ASSIGN_U1\0" -"=SHL_EQUAL_U8\0" -"=SHL_EQUAL_U4\0" -"=SHL_EQUAL_U2\0" -"=SHL_EQUAL_U1\0" -"=SHR_EQUAL_U8\0" -"=SHR_EQUAL_U4\0" -"=SHR_EQUAL_U2\0" -"=SHR_EQUAL_U1\0" -"=MUL_EQUAL_U8\0" -"=MUL_EQUAL_U4\0" -"=MUL_EQUAL_U2\0" -"=MUL_EQUAL_U1\0" -"=DIV_EQUAL_U8\0" -"=DIV_EQUAL_U4\0" -"=DIV_EQUAL_U2\0" -"=DIV_EQUAL_U1\0" -"=AND_EQUAL_U8\0" -"=AND_EQUAL_U4\0" -"=AND_EQUAL_U2\0" -"=AND_EQUAL_U1\0" -"=OR_EQUAL_U8\0" -"=OR_EQUAL_U4\0" -"=OR_EQUAL_U2\0" -"=OR_EQUAL_U1\0" -"=XOR_EQUAL_U8\0" -"=XOR_EQUAL_U4\0" -"=XOR_EQUAL_U2\0" -"=XOR_EQUAL_U1\0" -"=ADD_EQUAL_U8\0" -"=ADD_EQUAL_U4\0" -"=ADD_EQUAL_U2\0" -"=ADD_EQUAL_U1\0" -"=SUB_EQUAL_U8\0" -"=SUB_EQUAL_U4\0" -"=SUB_EQUAL_U2\0" -"=SUB_EQUAL_U1\0" -"=ESI_ASSIGN_U4\0" -"=ESI_SHL_EQUAL_U4\0" -"=ESI_SHR_EQUAL_U4\0" -"=ESI_MUL_EQUAL_U4\0" -"=ESI_DIV_EQUAL_U4\0" -"=ESI_AND_EQUAL_U4\0" -"=ESI_OR_EQUAL_U4\0" -"=ESI_XOR_EQUAL_U4\0" -"=ESI_ADD_EQUAL_U4\0" -"=ESI_SUB_EQUAL_U4\0" -"=EDI_ASSIGN_U4\0" -"=EDI_SHL_EQUAL_U4\0" -"=EDI_SHR_EQUAL_U4\0" -"=EDI_MUL_EQUAL_U4\0" -"=EDI_DIV_EQUAL_U4\0" -"=EDI_AND_EQUAL_U4\0" -"=EDI_OR_EQUAL_U4\0" -"=EDI_XOR_EQUAL_U4\0" -"=EDI_ADD_EQUAL_U4\0" -"=EDI_SUB_EQUAL_U4\0" -".ADD64\0" -".ADD32\0" -".ADD8\0" -".INC\0" -".SUB64\0" -".SUB32\0" -".SUB8\0" -".DEC\0" -".ENTER\0" -".LEAVE\0" -".ENTER1\0" -".LEAVE1\0" -".ENTER2\0" -".LEAVE2\0" -".ADD_ESP32\0" -".ADD_ESP8\0" -".RET\0" -".CALL\0" -".CALL_INDIRECT\0" -".CALL_INDIRECT2\0" -".IRQ\0" -".CLI\0" -".STI\0" -".GET_FLAGS\0" -".SET_FLAGS\0" -".GET_BASE_PTR\0" -".SET_BASE_PTR\0" -".GET_STACK_PTR\0" -".SET_STACK_PTR\0" -".GET_LABEL\0" -".ABSOLUTE_ADDRESS\0" -".LABEL\0" -".TYPE\0" -".BT\0" -".BTS\0" -".BTR\0" -".BTC\0" -".BSF\0" -".BSR\0" -".INSQUE\0" -".INSQUE_REV\0" -".REMQUE\0" -".STRLEN\0" -".MEMCPY\0" -".MEMSET\0" -".INPD\0" -".INPW\0" -".INP\0" -".OUTPD\0" -".OUTPW\0" -".OUTP\0" -".JMP\0" -".SHORT_JMP\0" -".SWITCH\0" -".SKIPZ\0" -".SKIPZ2\0" -".SKIPNZ\0" -".SKIPNZ2\0" -".EQUAL_EQUAL_SKIPZ\0" -".EQUAL_EQUAL_SKIPZ2\0" -".NOT_EQUAL_TO_SKIPZ\0" -".NOT_EQUAL_TO_SKIPZ2\0" -".LESS_THAN_SKIPZ\0" -".LESS_THAN_SKIPZ2\0" -".GREATER_THAN_SKIPZ\0" -".GREATER_THAN_SKIPZ2\0" -".LESS_OR_EQUAL_SKIPZ\0" -".LESS_OR_EQUAL_SKIPZ2\0" -".GREATER_OR_EQUAL_SKIPZ\0" -".GREATER_OR_EQUAL_SKIPZ2\0" -".AND_AND_SKIPZ\0" -".AND_AND_SKIPZ2\0" -".AND_AND_SKIPNZ\0" -".AND_AND_SKIPNZ2\0" -".OR_OR_SKIPZ\0" -".OR_OR_SKIPZ2\0" -".OR_OR_SKIPNZ\0" -".OR_OR_SKIPNZ2\0" -".LEA_DISP32_ESI\0" -".LEA_DISP8_ESI\0" -".LEA_DISP32_EDI\0" -".LEA_DISP8_EDI\0" -".PUSH_U8\0" -".PUSH_U4\0" -".PUSH_U2\0" -".PUSH_U1\0" -".PUSH_NEG_U4\0" -".PUSH_NEG_U2\0" -".PUSH_NEG_U1\0" -".PUSH_DOUBLE\0" -".PUSH_U8_DISP32\0" -".PUSH_U8_DISP8\0" -".PUSH_ESI_U8_DISP32\0" -".PUSH_ESI_U8_DISP8\0" -".PUSH_EDI_U8_DISP32\0" -".PUSH_EDI_U8_DISP8\0" -".PUSH_DEREF_U8\0" -".PUSH_U8_DISP32_SCALED\0" -".BT_CONSTANT\0" -".BTS_CONSTANT\0" -".BTR_CONSTANT\0" -".BTC_CONSTANT\0" -"*ESI_NEXT_EQUAL_U4\0" -"*EDI_NEXT_EQUAL_U4\0" -".ADD_EQUAL_U8_CONSTANT_U1\0" -".SUB_EQUAL_U8_CONSTANT_U1\0" -".ADD_EQUAL_U4_CONSTANT_U1\0" -".ESI_ADD_EQUAL_U4_CONSTANT_U1\0" -".EDI_ADD_EQUAL_U4_CONSTANT_U1\0" -); -} - -void FillCompilerTables() -{ - I1 *st,buf[128]; - U1 *d; - U8 i; - I8 j; - U2 *u; - U4 *d4; - - assign_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); - deref_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); - push_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); - push_map=MAllocZ(sizeof(U2)*EC_NUM_ENTRIES); - st=SysText("ST_INTERMEDIATE_CODE"); - for (i=0;i=0) - push_map[i]=j; - st+=StrLen(st)+1; - } - - d=MAllocZ(EC_NUM_ENTRIES); - unsigned_fix_up_table=d; - d[EC_ADD8]=FUT_8_4; - d[EC_SUB8]=FUT_8_4; - d[EC_IRQ]=FUT_8_1; - d[EC_ADD_ESP8]=FUT_8_1; - d[EC_U1_DISP8]=FUT_8_1; - d[EC_U2_DISP8]=FUT_8_1; - d[EC_U4_DISP8]=FUT_8_1; - d[EC_U8_DISP8]=FUT_8_6; - d[EC_PUSH_U8_DISP8]=FUT_8_6; - d[EC_ESI_U1_DISP8]=FUT_8_1; - d[EC_ESI_U2_DISP8]=FUT_8_1; - d[EC_ESI_U4_DISP8]=FUT_8_1; - d[EC_ESI_U8_DISP8]=FUT_8_6; - d[EC_PUSH_ESI_U8_DISP8]=FUT_8_6; - d[EC_EDI_U1_DISP8]=FUT_8_1; - d[EC_EDI_U2_DISP8]=FUT_8_1; - d[EC_EDI_U4_DISP8]=FUT_8_1; - d[EC_EDI_U8_DISP8]=FUT_8_6; - d[EC_PUSH_EDI_U8_DISP8]=FUT_8_6; - d[EC_LEA_DISP8_EBP]=FUT_8_1; - d[EC_LEA_DISP8_ESI]=FUT_8_1; - d[EC_LEA_DISP8_EDI]=FUT_8_1; - d[EC_SHL_CONSTANT1]=FUT_8_6; - d[EC_SHL_CONSTANT2]=FUT_8_5; - d[EC_SHR_CONSTANT1]=FUT_8_6; - d[EC_SHR_CONSTANT2]=FUT_8_5; - d[EC_ADD_EQUAL_U8_CONSTANT_U1]=FUT_8_10; - d[EC_SUB_EQUAL_U8_CONSTANT_U1]=FUT_8_10; - d[EC_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_5; - d[EC_ESI_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_5; - d[EC_EDI_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_5; - d[EC_BT_CONSTANT]=FUT_8_6; - d[EC_BTS_CONSTANT]=FUT_8_6; - d[EC_BTR_CONSTANT]=FUT_8_6; - d[EC_BTC_CONSTANT]=FUT_8_6; - - d[EC_CALL]=FUT_32_4_CALL; - - d[EC_U8]=FUT_64_H9_L4; - d[EC_U4]=FUT_32_4; - d[EC_U1]=FUT_8_1; - d[EC_DOUBLE]=FUT_64_H9_L4; - d[EC_PUSH_U8]=FUT_64_H9_L4; - d[EC_PUSH_DOUBLE]=FUT_64_H9_L4; - d[EC_PUSH_U4]=FUT_32_4; - d[EC_PUSH_U2]=FUT_32_4; - d[EC_PUSH_U1]=FUT_8_1; - d[EC_PUSH_NEG_U4]=FUT_32_4; - d[EC_PUSH_NEG_U2]=FUT_32_4; - d[EC_PUSH_NEG_U1]=FUT_8_1; - d[EC_ADD32]=FUT_32_7; - d[EC_SUB32]=FUT_32_7; - d[EC_ADD_ESP32]=FUT_32_4; - d[EC_ENTER]=FUT_32_4; - d[EC_ENTER1]=FUT_ENTER1; - d[EC_ENTER2]=FUT_ENTER2; - d[EC_LEAVE]=FUT_32_6; - d[EC_LEAVE1]=FUT_32_6; - d[EC_LEAVE2]=FUT_32_6; - d[EC_TYPE]=FUT_32_4; - d[EC_U1_DISP32]=FUT_32_4; - d[EC_U2_DISP32]=FUT_32_4; - d[EC_U4_DISP32]=FUT_32_4; - d[EC_U8_DISP32]=FUT_32_9; - d[EC_PUSH_U8_DISP32]=FUT_32_9; - d[EC_ESI_U1_DISP32]=FUT_32_4; - d[EC_ESI_U2_DISP32]=FUT_32_4; - d[EC_ESI_U4_DISP32]=FUT_32_4; - d[EC_ESI_U8_DISP32]=FUT_32_9; - d[EC_PUSH_ESI_U8_DISP32]=FUT_32_9; - d[EC_EDI_U1_DISP32]=FUT_32_4; - d[EC_EDI_U2_DISP32]=FUT_32_4; - d[EC_EDI_U4_DISP32]=FUT_32_4; - d[EC_EDI_U8_DISP32]=FUT_32_9; - d[EC_PUSH_EDI_U8_DISP32]=FUT_32_9; - d[EC_FS_U1_DISP32]=FUT_32_4; - d[EC_FS_U2_DISP32]=FUT_32_4; - d[EC_FS_U4_DISP32]=FUT_32_4; - d[EC_FS_U8_DISP32]=FUT_32_4P10_4; - d[EC_LEA_DISP32_EBP]=FUT_32_4; - d[EC_LEA_DISP32_ESI]=FUT_32_4; - d[EC_LEA_DISP32_EDI]=FUT_32_4; - d[EC_CALL_INDIRECT]=FUT_32_4; - d[EC_U2_DISP32_SCALED]=FUT_32_6; - d[EC_U4_DISP32_SCALED]=FUT_32_6; - d[EC_U8_DISP32_SCALED]=FUT_32_9; - d[EC_PUSH_U8_DISP32_SCALED]=FUT_32_9; - - d[EC_CALL_INDIRECT2]=FUT_32_4_ABS; - d[EC_ABSOLUTE_ADDRESS]=FUT_32_4_ABS; - - d[EC_STRING_CONSTANT]=FUT_32_4_ABS2; - d[EC_GET_LABEL]=FUT_32_4_ABS2; - d[EC_SWITCH]=FUT_32_4_ABS2; - - d[EC_SKIPZ2]=FUT_32_JMP_4; - d[EC_SKIPNZ2]=FUT_32_JMP_4; - d[EC_OR_OR_SKIPZ2]=FUT_32_JMP_4; - d[EC_OR_OR_SKIPNZ2]=FUT_32_JMP_4; - d[EC_AND_AND_SKIPZ2]=FUT_32_JMP_4; - d[EC_AND_AND_SKIPNZ2]=FUT_32_JMP_4; - d[EC_LESS_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_EQUAL_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_NOT_EQUAL_TO_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_LESS_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_JMP]=FUT_32_JMP_4; - - d[EC_SKIPZ]=FUT_8_JMP_1; - d[EC_SKIPNZ]=FUT_8_JMP_1; - d[EC_OR_OR_SKIPZ]=FUT_8_JMP_1; - d[EC_OR_OR_SKIPNZ]=FUT_8_JMP_1; - d[EC_AND_AND_SKIPZ]=FUT_8_JMP_1; - d[EC_AND_AND_SKIPNZ]=FUT_8_JMP_1; - d[EC_LESS_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_EQUAL_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_NOT_EQUAL_TO_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_LESS_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_SHORT_JMP]=FUT_8_JMP_1; - - d=MAllocZ(EC_NUM_ENTRIES); - signed_fix_up_table=d; - - d[EC_ADD_ESP8]=FUT_8_1; - d[EC_U1_DISP8]=FUT_8_2; - d[EC_U2_DISP8]=FUT_8_2; - d[EC_U4_DISP8]=FUT_8_2; - d[EC_ESI_U1_DISP8]=FUT_8_2; - d[EC_ESI_U2_DISP8]=FUT_8_2; - d[EC_ESI_U4_DISP8]=FUT_8_2; - d[EC_EDI_U1_DISP8]=FUT_8_2; - d[EC_EDI_U2_DISP8]=FUT_8_2; - d[EC_EDI_U4_DISP8]=FUT_8_2; - d[EC_SHR_CONSTANT1]=FUT_8_6; - d[EC_SHR_CONSTANT2]=FUT_8_4; - d[EC_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_4; - d[EC_ESI_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_4; - d[EC_EDI_ADD_EQUAL_U4_CONSTANT_U1]=FUT_8_4; - - d[EC_U4]=FUT_32_5; - d[EC_U1_DISP32]=FUT_32_5; - d[EC_U2_DISP32]=FUT_32_5; - d[EC_U4_DISP32]=FUT_32_5; - d[EC_ESI_U1_DISP32]=FUT_32_5; - d[EC_ESI_U2_DISP32]=FUT_32_5; - d[EC_ESI_U4_DISP32]=FUT_32_5; - d[EC_EDI_U1_DISP32]=FUT_32_5; - d[EC_EDI_U2_DISP32]=FUT_32_5; - d[EC_EDI_U4_DISP32]=FUT_32_5; - d[EC_FS_U1_DISP32]=FUT_32_5; - d[EC_FS_U2_DISP32]=FUT_32_5; - d[EC_FS_U4_DISP32]=FUT_32_5; - d[EC_LEA_DISP32_EBP]=FUT_32_4; - d[EC_U2_DISP32_SCALED]=FUT_32_5; - d[EC_U4_DISP32_SCALED]=FUT_32_5; - - d[EC_ABSOLUTE_ADDRESS]=FUT_32_4_ABS; - - d[EC_GET_LABEL]=FUT_32_4_ABS2; - d[EC_SWITCH]=FUT_32_4_ABS2; - - d[EC_SKIPZ2]=FUT_32_JMP_4; - d[EC_SKIPNZ2]=FUT_32_JMP_4; - d[EC_OR_OR_SKIPZ2]=FUT_32_JMP_4; - d[EC_OR_OR_SKIPNZ2]=FUT_32_JMP_4; - d[EC_AND_AND_SKIPZ2]=FUT_32_JMP_4; - d[EC_AND_AND_SKIPNZ2]=FUT_32_JMP_4; - d[EC_LESS_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_EQUAL_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_NOT_EQUAL_TO_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_LESS_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - - d[EC_SKIPZ]=FUT_8_JMP_1; - d[EC_SKIPNZ]=FUT_8_JMP_1; - d[EC_OR_OR_SKIPZ]=FUT_8_JMP_1; - d[EC_OR_OR_SKIPNZ]=FUT_8_JMP_1; - d[EC_AND_AND_SKIPZ]=FUT_8_JMP_1; - d[EC_AND_AND_SKIPNZ]=FUT_8_JMP_1; - d[EC_LESS_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_EQUAL_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_NOT_EQUAL_TO_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_LESS_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - - d=MAllocZ(EC_NUM_ENTRIES); - double_fix_up_table=d; - - d[EC_LESS_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_THAN_SKIPZ2]=FUT_32_JMP_4; - d[EC_GREATER_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - d[EC_LESS_OR_EQUAL_SKIPZ2]=FUT_32_JMP_4; - - d[EC_LESS_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_THAN_SKIPZ]=FUT_8_JMP_1; - d[EC_GREATER_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_LESS_OR_EQUAL_SKIPZ]=FUT_8_JMP_1; - d[EC_SHORT_JMP]=FUT_8_JMP_1; - - u=MAllocZ(sizeof(U2)*TK_NUM_TK); - duel_I1_tokens1=u; - u['!']=256*TK_NOT_EQUAL+'='; - u['&']=256*TK_AND_AND+'&'; - u['*']=256*TK_MUL_EQUAL+'='; - u['+']=256*TK_PLUS_PLUS+'+'; - u['-']=256*TK_DEREFERRENCE+'>'; - u['/']='*'; - u[':']=256*TK_DOUBLE_COLON+':'; - u['<']=256*TK_LESS_EQUAL+'='; - u['=']=256*TK_EQUAL_EQUAL+'='; - u['>']=256*TK_GREATER_EQUAL+'='; - u['^']=256*TK_XOR_EQUAL+'='; - u['|']=256*TK_OR_OR+'|'; - - u=MAllocZ(sizeof(U2)*TK_NUM_TK); - duel_I1_tokens2=u; - u['&']=256*TK_AND_EQUAL+'='; - u['+']=256*TK_ADD_EQUAL+'='; - u['-']=256*TK_MINUS_MINUS+'-'; - u['/']='/'; - u['<']=256*TK_SHL+'<'; - u['>']=256*TK_SHR+'>'; - u['^']=256*TK_XOR_XOR+'^'; - u['|']=256*TK_OR_EQUAL+'='; - - u=MAllocZ(sizeof(U2)*TK_NUM_TK); - duel_I1_tokens3=u; - u['-']=256*TK_SUB_EQUAL+'='; - u['/']=256*TK_DIV_EQUAL+'='; - u['>']=256*TK_CAST+'<'; - - d4=MAllocZ(sizeof(U4)*TK_NUM_TK); - binary_ops_table=d4; - - d4['`'] =0x20000+EC_POWER; - d4[TK_SHL] =0x20000+EC_SHL; - d4[TK_SHR] =0x20000+EC_SHR; - - d4['*'] =0x30000+EC_MULTIPLICATION; - d4['/'] =0x30000+EC_DIVISION; - d4['%'] =0x30000+EC_REMAINDER; - - d4['&'] =0x40000+EC_AND; - - d4['|'] =0x50000+EC_OR; - d4['^'] =0x50000+EC_XOR; - - d4['+'] =0x60000+EC_ADDITION; - d4['-'] =0x60000+EC_SUBTRACTION; - - d4[TK_EQUAL_EQUAL] =0x70000+EC_EQUAL_EQUAL; - d4[TK_NOT_EQUAL] =0x70000+EC_NOT_EQUAL_TO; - d4['<'] =0x70000+EC_LESS_THAN; - d4['>'] =0x70000+EC_GREATER_THAN; - d4[TK_LESS_EQUAL] =0x70000+EC_LESS_OR_EQUAL; - d4[TK_GREATER_EQUAL]=0x70000+EC_GREATER_OR_EQUAL; - - d4[TK_AND_AND] =0x80000+EC_AND_AND; - - d4[TK_OR_OR] =0x90000+EC_OR_OR; - d4[TK_XOR_XOR] =0x90000+EC_XOR_XOR; - - d4[':'] =0xA0000+EC_COLON; - d4['?'] =0xA0000+EC_QUESTION; - - d4['='] =0x100000+EC_ASSIGN_U8; - d4[TK_SHL_EQUAL]=0x100000+EC_SHL_EQUAL_U8; - d4[TK_SHR_EQUAL]=0x100000+EC_SHR_EQUAL_U8; - d4[TK_MUL_EQUAL]=0x100000+EC_MUL_EQUAL_U8; - d4[TK_DIV_EQUAL]=0x100000+EC_DIV_EQUAL_U8; - d4[TK_AND_EQUAL]=0x100000+EC_AND_EQUAL_U8; - d4[TK_OR_EQUAL] =0x100000+EC_OR_EQUAL_U8; - d4[TK_XOR_EQUAL]=0x100000+EC_XOR_EQUAL_U8; - d4[TK_ADD_EQUAL]=0x100000+EC_ADD_EQUAL_U8; - d4[TK_SUB_EQUAL]=0x100000+EC_SUB_EQUAL_U8; - - d4=MAllocZ(sizeof(U4)*TK_NUM_TK); - unary_ops_table=d4; - d4['~']=0x10000+EC_COM; - d4['!']=0x10000+EC_NOT; - d4['-']=0x10000+EC_UNARY_MINUS; - d4['&']=0x10000+EC_ADDRESS; - d4['*']=0x10000+EC_DEREF_U8; - - d4=unsigned_code_table[EC_ABSOLUTE_ADDRESS+1]-4; - *d4=offset(TssStruct.absolute_address); - - for (i=0;ilast_lex); - ext[EXT_SPRINTF_JOIN]=&SPrintFJoin2; - ext[EXT_GETF_JOIN]=&GetFJoin2; - ext[EXT_EXECUTE_FILE]=&ExecuteFile; - ext[EXT_EXECUTE_STRING]=&ExecuteString; - InitCompiler(TRUE); - try { - Lex(l); - ExecuteCmdLine(l); - } catch - CatchAll; - RemQue(l); - LexDel(l); -} diff --git a/LT/COMPILE/DoTest.CPZ b/LT/COMPILE/DoTest.CPZ deleted file mode 100644 index 3d62ee3..0000000 Binary files a/LT/COMPILE/DoTest.CPZ and /dev/null differ diff --git a/LT/COMPILE/LEX.CPZ b/LT/COMPILE/LEX.CPZ deleted file mode 100644 index 6a74637..0000000 --- a/LT/COMPILE/LEX.CPZ +++ /dev/null @@ -1,1687 +0,0 @@ -extern BoolU4 GetExpression(LexStruct *l,U1 **exp); -extern I8 Lex(LexStruct *l); -extern U8 PrsUnaryTerm(LexStruct *l,ParseStack *ps); -extern U8 PrsUnaryModifier(LexStruct *l,ParseStack *ps); -extern U8 PrsDereferrence(LexStruct *l,ParseStack *ps); -extern ClassStruct *CmpParseClass(LexStruct *l,BoolU4 is_union,BoolU4 is_public); -extern void PrsExcept(LexStruct *l,I1 *name=NULL,I1 *msg=NULL); -extern void CmpParseVarList(LexStruct *l,ClassStruct *tempc, - I8 mode,U8 union_base=MAX_I4); -extern BoolU4 CmpParseStatement(LexStruct *l,ClassStruct *locals,I8 try_count=0, - CbMiscStruct *break_label=NULL,CbMiscStruct *continue_label=NULL, - BoolU4 saved_prs_semicolon=TRUE); -extern I8 ExecuteCmdLine(LexStruct *l); -extern I8 ExecuteString(I1 *buf,I1 *filename=NULL); -extern I8 ExecuteFile(I1 *name); -extern void ContinueUserTask(); -extern IntermediateCode *CmpOptPass1(LexStruct *l,ClassStruct *fun_class,BoolU4 combined); -extern void CmpOptPass2(LexStruct *l,ClassStruct *fun_class); -extern void CmpOptPass3(LexStruct *l,ClassStruct *fun_class); -extern void CmpOptPass4(LexStruct *l,ClassStruct *fun_class); - -LTextern CODE_TABLE U4 code_table[1]; -LTextern UNSIGNED_CODE_TABLE U4 unsigned_code_table[1]; -LTextern DOUBLE_CODE_TABLE U4 double_code_table[1]; -LTextern INTERNAL_TYPES_TABLE U1 internal_types_table[1]; - -SysHashTable *asm_hash; -BoolU4 is_first_compiler; -SysHashEntry *sys_internal_types[IT_NUM_IT]; -U1 it_to_ec_offset[IT_NUM_IT]={0,0,3,3,2,2,1,1,0,0,0,0}; - - -#define FUT_NULL 0 -#define FUT_8_1 1 -#define FUT_8_2 2 -#define FUT_8_4 3 -#define FUT_8_5 4 -#define FUT_8_6 5 -#define FUT_8_10 6 -#define FUT_8_JMP_1 7 -#define FUT_32_4 8 -#define FUT_32_4_CALL 9 -#define FUT_32_4_ABS 10 -#define FUT_32_4_ABS2 11 -#define FUT_32_5 12 -#define FUT_32_6 13 -#define FUT_32_7 14 -#define FUT_32_9 15 -#define FUT_32_4_ENTER 16 -#define FUT_32_4P11_4 17 -#define FUT_32_JMP_4 18 -#define FUT_64_H9_L4 19 -#define FUT_ENTER1 20 -#define FUT_ENTER2 21 -#define FUT_32_4P10_4 22 - -U1 *signed_fix_up_table,*unsigned_fix_up_table,*double_fix_up_table; - -U2 *duel_I1_tokens1,*duel_I1_tokens2,*duel_I1_tokens3; -U4 *binary_ops_table,*unary_ops_table; -U1 *deref_bitmap,*assign_bitmap, - *push_bitmap; -U2 *push_map; - -LexStruct *LexNew(I1 *buf,U8 flags,I1 *filename) -{ - LexStruct *l=MAlloc(sizeof(LexStruct)); - LexFileStruct *tempf=&l->lfns[0]; - MemSet(l,0,offset(LexStruct.lfns)+sizeof(LexFileStruct)); - l->next=l; - l->last=l; - l->flags=flags; - l->ESI_offset=MAX_I8; - l->EDI_offset=MAX_I8; - l->hash_mask=HTT_ALL; - l->hash_table_list=Fs->hash_table; - l->define_hash_table=Fs->hash_table; - l->cur_lfn=tempf; - l->next_exe_blk=&l->next_exe_blk; - l->last_exe_blk=&l->next_exe_blk; - if (!filename) - tempf->name=NewString(sys_temp_filename); - else - tempf->name=filename; - if (flags & LF_PROMPT) - buf=MAllocZ(4); - tempf->buf=buf; - tempf->buf_ptr=buf; - tempf->line_start=buf; - tempf->line_num=1; - l->cur_buf_ptr=buf; - return l; -} - -void LexDel(LexStruct *l) -{ - LexFileStruct *tempf=l->cur_lfn; - void my_LtfDel(Ltf *l,BoolU4 adam_mem); - Ltf *ltf; - - while (tempf!=&l->lfns[0]) { - if (ltf=tempf->l) { - if (ext[EXT_LTF_DEL]) { - my_LtfDel=ext[EXT_LTF_DEL]; - my_LtfDel(ltf,FALSE); - } - } - Free(tempf->buf); - Free(tempf->name); - tempf-=sizeof(LexFileStruct); - } - Free(tempf->name); - if (!(l->flags & LF_DONT_FREE_BUFFER)) - Free(tempf->buf); - Free(l->ident); - Free(l); -} - - -void SetSourceFileInfo(LexStruct *l,SysHashEntry *h) -{ - LexFileStruct *tempf=l->cur_lfn; - h->source_link=MSPrintF("FL:%s,%d",tempf->name,tempf->line_num); - if (Bt(&l->flags,LFf_KEEP_PRIVATE)) - h->type|=HTT_PRIVATE; -} - -void LexPutToken(LexStruct *l) -{ - PutChar('"'); - if (l->token==TK_IDENT || l->token==TK_STRING) - PutS(l->ident); - else if (l->token==TK_INTEGER) - cout "INT:",l->cur_i; - else if (l->token==TK_DOUBLE) - cout "DBL:",l->cur_d; - else if (l->token>=CH_SHIFT_SPACE && l->token<=0x7E) - PutChar(l->token); - else { - cout "T:",l->token; - } - PutS("\" "); -} - -U4 lex_zeros=0,lex_line_feed=0x000A; - -void LexBackupLastChar(LexStruct *l) -{ - LexFileStruct *tempf=l->cur_lfn; - tempf->buf_ptr=l->cur_buf_ptr; - if (l->flags & LF_USE_LAST_I1) { - tempf->last_I1=l->last_I1; - l->flags&=~LF_USE_LAST_I1; - } else - tempf->last_I1=0; -} - -U8 LexGetChar(LexStruct *l) -{ - U1 *src; - LexFileStruct *tempf,*tempf1; - BoolU4 cont; - U8 result; - U1 *my_SysPrompt(BoolU4 double_semicolon); - Ltf *ltf; - LtfEntry *cl; - U1 *ptr; - void my_LtfDel(Ltf *l,BoolU4 adam_mem); - if (l->flags & LF_USE_LAST_I1) { - l->flags&=~LF_USE_LAST_I1; - return l->last_I1; - } - do { -lex_getchar_start: - src=l->cur_buf_ptr++; - switch (l->last_I1=result=*src++) { - case 0: - tempf=l->cur_lfn; - if (tempf->flags & LFSF_IS_LTF) { - ltf=tempf->l; - cl=tempf->cur_entry; - cl=cl->next; - while (cl!=ltf) { - cont=FALSE; - tempf->cur_entry=cl; - switch (cl->btype) { - case LTFT_TEXT: - if (*(src=cl->display)) - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - else { - cont=TRUE; - cl=cl->next; - } - break; - case LTFT_CR: - src=&lex_line_feed; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - tempf->line_start=cl->next; - tempf->line_num=cl->y+2; //+1 because CR is on previous line, +1 because ltf y starts at zero - compiled_lines++; - if (l->flags & LF_ECHO) - CrLf; - l->last_I1=CH_CR; - return CH_CR; - case LTFT_TAB: - src=&lex_zeros; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - tempf->line_num=cl->y+1; - if (l->flags & LF_ECHO) - PutChar(CH_TAB); - l->last_I1=CH_TAB; - return CH_TAB; - case LTFT_PAGE_BREAK: - src=&lex_zeros; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - tempf->line_num=cl->y+2; //TODO: should be a page down - if (l->flags & LF_ECHO) - PutChar(CH_FORM_FEED); - l->last_I1=CH_FORM_FEED; - return CH_FORM_FEED; - case LTFT_INSERT_BINARY: - src=&lex_zeros; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - tempf->line_num=cl->y+1; - Free(l->ident); - l->ident=NULL; - l->ident_len=0; - if (cl->bin_data) { - ptr=MAlloc(cl->bin_data->size); - if (cl->bin_data->data) - MemCpy(ptr,cl->bin_data->data,cl->bin_data->size); - l->ident=ptr; - l->ident_len=cl->bin_data->size; - } - l->last_I1=TK_INSERT_BINARY; - return TK_INSERT_BINARY; - case LTFT_INSERT_BINARY_TYPE: - src=&lex_zeros; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - if (cl->bin_data) - l->cur_i=cl->bin_data->type; - else - l->cur_i=0; - tempf->line_num=cl->y+1; - l->last_I1=TK_INSERT_BINARY_TYPE; - return TK_INSERT_BINARY_TYPE; - case LTFT_INSERT_BINARY_SIZE: - src=&lex_zeros; - tempf->buf=tempf->buf_ptr=l->cur_buf_ptr=src; - - if (cl->bin_data) - l->cur_i=cl->bin_data->size; - else - l->cur_i=0; - tempf->line_num=cl->y+1; - l->last_I1=TK_INSERT_BINARY_SIZE; - return TK_INSERT_BINARY_SIZE; - default: - cont=TRUE; - cl=cl->next; - } - if (!cont) break; - } - if (cl==ltf) { - if (ext[EXT_LTF_DEL]) { - my_LtfDel=ext[EXT_LTF_DEL]; - my_LtfDel(ltf,FALSE); - } - tempf->l=tempf->buf=NULL; - Free(tempf->name); - tempf->name=NULL; - goto here; - } - } else { -here: - tempf=l->cur_lfn; - if (tempf!=&l->lfns[0]) { - Free(tempf->name); - tempf->name=NULL; - Free(tempf->buf); - tempf->buf=NULL; - tempf1=tempf; - l->cur_lfn=tempf-=sizeof(LexFileStruct); - l->cur_buf_ptr=tempf->buf_ptr; - if (l->last_I1=tempf->last_I1) { - l->flags&=~LF_USE_LAST_I1; - return l->last_I1; - } else - l->flags&=~LF_USE_LAST_I1; - } else { - if (l->flags & LF_PROMPT) { - Free(tempf->buf); - my_SysPrompt=FindExtern("SysPrompt"); - l->cur_buf_ptr=tempf->line_start= - tempf->buf_ptr=tempf->buf=my_SysPrompt(TRUE); - } else { - l->last_I1=TK_EOF; - l->cur_buf_ptr=src-1; - return TK_EOF; - } - } - } - break; - case CH_CURSOR: - case CH_FORM_FEED: - goto lex_getchar_start; - case CH_LINE_FEED: - tempf=l->cur_lfn; - if (tempf->flags & LFSF_IS_LTF) - return result; - else { - tempf->line_num++; - compiled_lines++; - tempf->line_start=src; - } - default: - if (l->flags & LF_ECHO) - PutChar(result); - return result; - } - } while (TRUE); -} - -void LexSkipEol(LexStruct *l) -{ - U1 ch; - do ch=LexGetChar(l); - while (ch && ch!=CH_CR && ch!=CH_LINE_FEED); -} - -void DelExpression(U1 *code) -{ - Free(code); -} - - -U8 EvalExpression(LexStruct *l) -{ - U1 *exp; - U8 result=0; - if (!GetExpression(l,&exp)) - LexSkipEol(l); - else { - result=Run(exp); - DelExpression(exp); - } - return result; -} - -void LexIncludeString(LexStruct *l,I1 *filename, - I1 *src,BoolU4 actual_file) -{ - LexFileStruct *tempf; - LexBackupLastChar(l); - tempf=l->cur_lfn+sizeof(LexFileStruct); - l->cur_lfn=tempf; - tempf->buf=src; - tempf->buf_ptr=src; - tempf->line_num=1; - tempf->line_start=src; - tempf->last_I1=0; - if (actual_file) { - tempf->name=AbsoluteFileName(filename); - tempf->flags=LFSF_IS_INCLUDED; - } else { - tempf->name=NewString(sys_temp_filename); - tempf->flags=0; - } - l->cur_buf_ptr=src; -} - -void LexIncludeLtf(LexStruct *l,I1 *filename) -{ - BoolU4 is_null; - LtfEntry *cl; - Ltf *my_LtfRead(I1 *name,U8 flags); - Ltf *ltf; - LexFileStruct *tempf; - - LexBackupLastChar(l); - tempf=l->cur_lfn+sizeof(LexFileStruct); - l->cur_lfn=tempf; - tempf->line_start=&lex_zeros; - if (!ext[EXT_LTF_READ]) - throw(EXCEPT_COMPILER,1); //This should never happen - my_LtfRead=ext[EXT_LTF_READ]; - ltf=my_LtfRead(filename,LTFF_DOUBLE_DOLLARS); - if (!ltf) - is_null=TRUE; - else { - tempf->l=ltf; - cl=ltf->dummy.next; - while (cl!=ltf) { - if (cl->btype==LTFT_TEXT) - break; - if (cl->btype==LTFT_TAB) - break; - if (cl->btype==LTFT_CR) - break; - if (cl->btype==LTFT_INSERT_BINARY) - break; - if (cl->btype==LTFT_INSERT_BINARY_TYPE) - break; - if (cl->btype==LTFT_INSERT_BINARY_SIZE) - break; - cl=cl->next; - } - if (cl!=ltf) { - tempf->line_start=cl; - tempf->line_num=cl->y+1; - if (cl->btype==LTFT_TEXT) { - tempf->cur_entry=cl; - tempf->buf=cl->display; - tempf->buf_ptr=cl->display; - } else { - tempf->cur_entry=cl->last; //TODO might be problem at begining of file - tempf->buf=&lex_zeros; - tempf->buf_ptr=&lex_zeros; - } - is_null=FALSE; - } else - is_null=TRUE; - } - tempf->name=AbsoluteFileName(filename); - if (is_null) { - tempf->flags=LFSF_IS_INCLUDED; - tempf->buf=&lex_zeros; - tempf->buf_ptr=&lex_zeros; - tempf->line_num=1; - } else - tempf->flags=LFSF_IS_INCLUDED|LFSF_IS_LTF; - tempf->last_I1=0; - l->cur_buf_ptr=tempf->buf_ptr; -} - -void LexPush(LexStruct *l) -{ - LexFileStruct *tempf=l->cur_lfn, - *tempf1=&l->stack[l->stack_ptr++]; - if (l->stack_ptr>=LFN_STACK_CNT) - PrsExcept(l,"ST_LEX_STACK_OVERFLOW"); - LexBackupLastChar(l); - if (tempf->last_I1) - l->flags|=LF_USE_LAST_I1; - MemCpy(tempf1,tempf,sizeof(LexFileStruct)); -} - -void LexPop(LexStruct *l) -{ - LexFileStruct *tempf=l->cur_lfn, - *tempf1=&l->stack[--l->stack_ptr]; - l->cur_buf_ptr=tempf1->buf_ptr; - if (l->last_I1=tempf1->last_I1) - l->flags|=LF_USE_LAST_I1; - else - l->flags&=~LF_USE_LAST_I1; - MemCpy(tempf,tempf1,sizeof(LexFileStruct)); -} - -MemberListStruct *FindMember(I1 *st,ClassStruct *c) -{ - MemberListStruct *ml=c->member_list; - while (ml) { - if (!StrCmp(ml->string,st)) { - ml->use_cnt++; - return ml; - } - ml=ml->next; - } - return NULL; -} - -void DelMemberList(ClassStruct *tempc) -{ - MemberListStruct *tempm,*tempm1; - tempm=tempc->member_list; - while (tempm) { - tempm1=tempm->next; - Free(tempm->string); - Free(tempm->fmtstr); - Free(tempm->fmtdata); - if (tempm->flags & MLF_DEFAULT_AVAILABLE && - tempm->member_class==sys_internal_types[IT_I1]+sizeof(ClassStruct)) - Free(tempm->default_value); - Free(tempm); - tempm=tempm1; - } - tempc->size=0; - tempc->last_in_member_list=&tempc->member_list; - tempc->member_list=NULL; - tempc->member_cnt=0; - tempc->parameter_cnt=0; -} - - -I8 LexInString(LexStruct *l, - I1 *buf,I8 size,BoolU4 *done) -{ - I8 i=0,j,ch; - *done=TRUE; - while (iflags|=LF_USE_LAST_I1; - } else if (ch>='0' && ch<='7') { - j=ch-'0'; - do { - ch=LexGetChar(l); - if (ch>='0' && ch<='7') - j=j<<3+ch-'0'; - } while (ch>='0' && ch<='7'); - buf[i++]=j; - l->flags|=LF_USE_LAST_I1; - } else { - l->flags|=LF_USE_LAST_I1; - buf[i++]='\\'; - } - } else if (ch=='$$') { - ch=LexGetChar(l); - buf[i++]='$$'; - if (ch!='$$') - l->flags|=LF_USE_LAST_I1; - } else - buf[i++]=ch; - } - *done=FALSE; - return i; -} - -I8 Lex(LexStruct *l) -{ - U8 ch; - I8 i,j,k; - double d; - SysHashEntry *temph,**temph1; - BoolU4 cont,str_done; - I1 *fbuf; - I1 *buf2,*buf3,buf[LEX_MAX_IDENT]; - while (TRUE) { -lex_cont: - if (!(ch=LexGetChar(l))) - return l->token=TK_EOF; - if (Bt(alpha_bitmap,ch)) { - i=0; - buf[i++]=ch; - do { - if (i>=LEX_MAX_IDENT-1) - break; - else { - if (!(ch=LexGetChar(l))) - break; - else { - if (Bt(alpha_numeric_bitmap,ch)) - buf[i++]=ch; - else { - l->flags|=LF_USE_LAST_I1; - break; - } - } - } - } while (TRUE); - buf[i++]=0; - temph=NULL; - if (l->local_var_list) { - l->local_var_entry=FindMember(buf, - l->local_var_list); - } else - l->local_var_entry=NULL; - if (!l->local_var_entry && l->hash_table_list) - temph=FindHashEntry(buf, - l->hash_table_list,l->hash_mask); - if (temph && !(l->flags & LF_NO_DEFINES)) - j=temph->type; - else - j=0; - if (j & HTT_STRING_CONSTANT) - LexIncludeString(l, - temph->string,NewString(temph><(StringConstantStruct *)->data),FALSE); - else { - l->hash_entry=temph; - Free(l->ident); - l->ident=NewString(buf); - l->ident_len=i; - l->token=TK_IDENT; - goto lex_end; - } - } else if (Bt(dec_numeric_bitmap,ch)) { - i=ch-'0'; - ch=LexGetChar(l); - if (ch=='X' || ch=='x') { - while (TRUE) { - ch=ToUpper(LexGetChar(l)); - if (Bt(hex_numeric_bitmap,ch)) { - if (ch<='9') - i=i<<4+ch-'0'; - else - i=i<<4+ch-'A'+10; - } else { - l->cur_i=i; - l->flags|=LF_USE_LAST_I1; - l->token=TK_INTEGER; - goto lex_end; - } - } - } - while (TRUE) { - if (Bt(dec_numeric_bitmap,ch)) - i=MulU8(i,10)+ch-'0'; - else { - if (ch=='.' || ch=='e' || ch=='E') break; - l->cur_i=i; - l->flags|=LF_USE_LAST_I1; - l->token=TK_INTEGER; - goto lex_end; - } - ch=LexGetChar(l); - } - if (ch=='.') - ch=LexGetChar(l); -float_start: - //TODO:back-up for cases where i overflows - // (people should use 'e', so might not be worth it) - j=0; - k=0; - while (TRUE) { - //TODO: maybe replace with log2 and insert bit field - 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; - l->cur_d=d; - l->flags|=LF_USE_LAST_I1; - l->token=TK_DOUBLE; - goto lex_end; - } - ch=LexGetChar(l); - } - ch=LexGetChar(l); - k=1; - if (ch=='-') { - k=-1; - ch=LexGetChar(l); - } - j=0; - while (TRUE) { - //TODO: maybe replace with log2 and insert bit field - if (Bt(dec_numeric_bitmap,ch)) - j=MulU8(j,10)+ch-'0'; - else { - d*=Pow10(j*k); - l->cur_d=d; - l->flags|=LF_USE_LAST_I1; - l->token=TK_DOUBLE; - goto lex_end; - } - ch=LexGetChar(l); - } - } else if (ch=='"') { - l->flags|=LF_IN_QUOTES; - buf2=NULL; - i=0; - do { - j=LexInString(l,buf,LEX_MAX_IDENT,&str_done); - buf3=MAlloc(i+j); - if (buf2) { - MemCpy(buf3,buf2,i); - Free(buf2); - buf2=buf3; - MemCpy(buf2+i,buf,j); - } else { - buf2=buf3; - MemCpy(buf2,buf,j); - } - i+=j; - } while (!str_done); - Free(l->ident); - l->ident=MAlloc(i); - MemCpy(l->ident,buf2,i); - Free(buf2); - l->ident_len=i; - l->flags&=~LF_IN_QUOTES; - l->token=TK_STRING; - goto lex_end; - } else if (ch==0x27) { // "'" - ch=LexGetChar(l); - if (!ch || ch==0x27) i=0x27; - else if (ch=='\\') { - ch=LexGetChar(l); - if (ch=='n') - i=10; - else if (ch=='r') - i=13; - else if (ch=='"') - i='"'; - else if (ch==0x27) - i=0x27; - else if (ch=='\`') - i='\`'; - else if (ch=='\\') - i='\\'; - else if (ch=='t') - i=9; - else if (ch=='x') { - i=0; - while (TRUE) { - ch=ToUpper(LexGetChar(l)); - if (Bt(hex_numeric_bitmap,ch)) { - if (ch<='9') - i=i<<4+ch-'0'; - else - i=i<<4+ch-'A'+10; - } else - break; - } - l->flags|=LF_USE_LAST_I1; - } else if (ch>='0' && ch<='7') { - i=ch-'0'; - do { - ch=LexGetChar(l); - if (ch>='0' && ch<='7') - i=i<<3+ch-'0'; - } while (ch>='0' && ch<='7'); - l->flags|=LF_USE_LAST_I1; - } else { - l->flags|=LF_USE_LAST_I1; - i='\\'; - } - } else if (ch=='$$') { - ch=LexGetChar(l); - i='$$'; - if (ch!='$$') - l->flags|=LF_USE_LAST_I1; - } else - i=ch; - ch=LexGetChar(l); - if (ch!=0x27) - l->flags|=LF_USE_LAST_I1; - l->cur_i=i; - l->token=TK_INTEGER; - goto lex_end; - } else if (ch=='#') { - if (Lex(l)!=TK_IDENT) //skip '#' - goto lex_end; - if (!(temph=l->hash_entry)) - goto lex_end; - if (!(temph->type & HTT_KEYWORD)) - goto lex_end; - i=temph->user0; - if (i==KW_INCLUDE) { - if (Lex(l)!=TK_STRING) - goto lex_end; - if (l->flags & LF_ASM_EXPRESSIONS) - fbuf=DefaultExtension(l->ident,"ASZ"); - else - fbuf=DefaultExtension(l->ident,"CPZ"); - if (ext[EXT_LTF_READ]) - LexIncludeLtf(l,fbuf); - else - LexIncludeString(l,fbuf,ReadTextFile(fbuf),TRUE); - Free(fbuf); - } else if (i==KW_DEFINE) { - l->flags|=LF_NO_DEFINES; - if (Lex(l)==TK_IDENT) { - temph=MAllocZ(sizeof(StringConstantStruct)); - temph->string=l->ident; - l->ident=0; - temph->use_cnt=0; - temph->type=HTT_STRING_CONSTANT; - SetSourceFileInfo(l,temph); - i=0; - do ch=LexGetChar(l); - while (ch && (ch<=CH_SPACE || ch>0x7E)); - if (ch>CH_SPACE && ch<=0x7E) { - buf[i++]=ch; - while (i=CH_SHIFT_SPACE && ch<=0x7E || ch==CH_TAB); - break; - } else { - buf[i++]='/'; - l->flags|=LF_USE_LAST_I1; - } - } else if (ch>=CH_SHIFT_SPACE && ch<=0x7E || ch==CH_TAB) - buf[i++]=ch; - else - break; - } - } - buf[i++]=0; - temph><(StringConstantStruct *)->data=NewString(buf); - temph1=FindHashBucket(temph->string,l->define_hash_table); - temph->next=*temph1; - *temph1=temph; - } - l->flags&=~LF_NO_DEFINES; - } - } else if (ch==TK_INSERT_BINARY || - ch==TK_INSERT_BINARY_TYPE || - ch==TK_INSERT_BINARY_SIZE) { - l->token=ch; - goto lex_end; - } else if (ch=='.') { - ch=LexGetChar(l); - if (ch>='0' && ch<='9') { - i=0; - goto float_start; - } - l->flags|=LF_USE_LAST_I1; - l->token='.'; - goto lex_end; - } else if (ch>=0x21 && ch<=0x7E) { - i=duel_I1_tokens1[ch]; - if (!i) { - if (ch=='$$') { - do ch=LexGetChar(l); - while (ch && ch!='$$'); - goto lex_cont; - } else { - l->token=ch; - goto lex_end; - } - } else { - j=LexGetChar(l); - if (i.u1[0]==j) { - i>>=8; - if (!i) { // "/*" - cont=TRUE; - while (cont) { - do ch=LexGetChar(l); - while (ch && ch!='*'); - while (cont && ch=='*') { - ch=LexGetChar(l); - if (ch=='/') - cont=FALSE; - } - } - goto lex_cont; - } else { - l->token=i; - goto lex_end; - } - } - if (i=duel_I1_tokens2[ch]) { - if (i.u1[0]==j) { - i>>=8; - if (!i) { // "//" - LexSkipEol(l); - goto lex_cont; - } else { - if (i==TK_SHL || i==TK_SHR) { - j=LexGetChar(l); - if (j=='=') { - if (i==TK_SHL) - i=TK_SHL_EQUAL; - else - i=TK_SHR_EQUAL; - } else - l->flags|=LF_USE_LAST_I1; - } - l->token=i; - goto lex_end; - } - } - if (i=duel_I1_tokens3[ch]) { - if (i.u1[0]==j) { - l->token=i.u1[1]; - goto lex_end; - } - } - } - l->flags|=LF_USE_LAST_I1; - l->token=ch; - goto lex_end; - } - } - } -lex_end: - if (Bt(&l->flags,LFf_LEX_TRACE)) - LexPutToken(l); - return l->token; -} - -I1 *LexExtendString(LexStruct *l,U8 *size) -{ - U8 len=l->ident_len,len1,len2; - I1 *st=l->ident,*st1,*st2; - l->ident=NULL; - while (l->token==TK_STRING) { - st1=st; - len1=len; - if (Lex(l)==TK_STRING) { - len2=l->ident_len; - st2=l->ident; - l->ident=NULL; - len=len1+len2-1; - st=MAlloc(len); - if (len1>1) - MemCpy(st,st1,len1-1); - MemCpy(st+len1-1,st2,len2); - Free(st1); - Free(st2); - } - } - *size=len; - return st; -} - -I1 *LexPutLine(LexStruct *l,I1 *start) -{ - LtfEntry *my_LtfPutLine(LtfEntry *cl); - I1 *ptr; - if (!start) return; - if (l->cur_lfn->flags&LFSF_IS_LTF) { - if (my_LtfPutLine=FindExtern("LtfPutLine")) - return my_LtfPutLine(start); - } else { - ptr=start; - while (*ptr && *ptr!=CH_LINE_FEED && *ptr!=CH_CR) - PutChar(*ptr++); - CrLf; - return (*ptr) ? ptr+1:ptr; - } - return NULL; -} - -I8 LexLineNum(LexStruct *l) -{ - return l->cur_lfn->line_num; -} - -void LexPutLink(LexStruct *l) -{ - PutFileLink(l->cur_lfn->name,l->cur_lfn->line_num); - AdamErr("%s,%d\r",l->cur_lfn->name,l->cur_lfn->line_num); - PutS(" "); -} - -void PutLexError(LexStruct *l,I1 *name=NULL,I1 *msg=NULL) -{ - PutSysText("ST_ERROR"); - l->error_cnt++; - AdamErr("Tsk:%08X ",Fs); - if (name) { - PutSysText(name); - AdamErr("%S",name); - } - if (msg) { - PutS(msg); - AdamErr("%s\r\n",msg); - } - LexPutToken(l); - LexPutLink(l); - LexPutLine(l,l->cur_lfn->line_start); -} - -void PutLexWarning(LexStruct *l,I1 *name=NULL,I1 *msg=NULL) -{ - PutSysText("ST_WARNING"); - l->warning_cnt++; - if (name) - PutSysText(name); - if (msg) - PutS(msg); - LexPutToken(l); - LexPutLink(l); - LexPutLine(l,l->cur_lfn->line_start); -} - -void PutAsmError(LexStruct *l,I1 *name) -{ - PutLexError(l,name); - LexSkipEol(l); - Lex(l); -} - -void PutAsmWarning(LexStruct *l,I1 *name) -{ - PutLexWarning(l,name); - LexSkipEol(l); - Lex(l); -} - -void PrsExcept(LexStruct *l,I1 *name=NULL,I1 *msg=NULL) -{ - PutLexError(l,name,msg); - IntFlushMsgs; - throw(EXCEPT_COMPILER,0); -} - -void CbPutClass(ClassStruct *c) -{ - I8 i; - if (!c) return; - if (c->pointer_cnt>4) { - coutln "ERROR:put_class ptrcnt=",c->pointer_cnt; - while (TRUE) -//TODO: - SwapInNext; - } - for (i=0;ipointer_cnt;i++) - PutChar('*'); - c-=sizeof(ClassStruct)*c->pointer_cnt; - if (c->string) - PutS(c->string); - else { - coutln "ERROR:put_class string=NULL"; - while (TRUE) -//TODO: - SwapInNext; - } - PutChar(CH_SPACE); -} - - -void CbPutIc(IntermediateCode *tempi) -{ - I1 *st; - U8 opcode=tempi->ic_code.u2[0]; - if (opcode>EC_NOP) { - st=PointAtListEntry(opcode,SysText("ST_INTERMEDIATE_CODE")); - PrintF("%20ts %016X ", - st+1,tempi->ic_data); - if (tempi->ic_flags & ICF_NO_PUSHES) - PutS("!PUSH "); - CbPutClass(tempi->ic_class); - if (tempi->ic_flags & ICF_TO_DOUBLE) - PutS("->double "); - if (tempi->ic_flags & ICF_TO_INT) - PutS("->int "); - if (tempi->ic_flags & ICF_NO_PUSHES_TO_DOUBLE_OR_INT) - PutS("!PUSH2 "); - if (tempi->ic_flags & ICF_USE_DOUBLE_TEMPLATE) - PutS("[double] "); - if (tempi->ic_flags & ICF_USE_UNSIGNED_TEMPLATE) - PutS("[unsigned] "); - CrLf; - } -} - - -void CbInitOutPtrs(LexCbStack *ll) -{ - CodeBlk *cb=MAlloc(sizeof(CodeBlk)); - cb->next=NULL; - ll->cb_out_first=cb; - ll->cb_out_last=cb; - ll->cb_misc_list=NULL; - ll->cb_misc_list_end=&ll->cb_misc_list; - ll->cb_out_end=cb+sizeof(CodeBlk); - ll->cb_out_ptr=&cb->data; - ll->cb_last_out_ptr=&cb->data; -} - -void CbInitInPtrs(LexCbStack *ll) -{ - CodeBlk *cb=ll->cb_out_first; - ll->cb_in_first=cb; - ll->cb_in_end=cb+sizeof(CodeBlk); - ll->cb_in_ptr=&cb->data; -} - -void CbPutAllIc(LexStruct *l) -{ - IntermediateCode *tempi; - CbInitInPtrs(&l->cb); - tempi=l->cb.cb_in_ptr; - while (tempi->ic_code) { - CbPutIc(tempi); - tempi+=sizeof(IntermediateCode); - } -} - -void CbAddIc(LexStruct *l, - U8 opcode,U8 arg, ClassStruct *c,U8 flags=0) -{ - IntermediateCode *tempi=l->cb.cb_out_ptr; - CodeBlk *cb,*cb1; - l->cb.cb_last_out_ptr=tempi; - tempi->ic_code=opcode; - tempi->ic_data=arg; - tempi->ic_class=c; - tempi->ic_flags=flags; - tempi->ic_line=l->cur_lfn->line_num; - if (l->flags & LF_PARSE_TRACE) - CbPutIc(tempi); - - tempi+=sizeof(IntermediateCode); - if (tempi==l->cb.cb_out_end) { - cb=MAlloc(sizeof(CodeBlk)); - cb->next=NULL; - cb1=l->cb.cb_out_last; - cb1->next=cb; - l->cb.cb_out_last=cb; - tempi=&cb->data; - l->cb.cb_out_end=cb+sizeof(CodeBlk); - } - l->cb.cb_out_ptr=tempi; -} - -IntermediateCode *CbGetIc1(LexCbStack *l) -{ - IntermediateCode *tempi=l->cb_in_ptr, - *tempi1=tempi+sizeof(IntermediateCode); - CodeBlk *cb; - if (tempi1==l->cb_in_end) { - cb=tempi1-sizeof(CodeBlk); - cb=cb->next; - l->cb_in_end=cb+sizeof(CodeBlk); - tempi1=&cb->data; - } - l->cb_in_ptr=tempi1; - return tempi; -} - -void CbPush(LexStruct *l) -{ - LexCbStack *templ=MAlloc(sizeof(LexCbStack)); - MemCpy(templ,&l->cb,sizeof(LexCbStack)); - if (l->cb.cb_misc_list_end==&l->cb.cb_misc_list) - templ->cb_misc_list_end=&templ->cb_misc_list; - l->cb.cb_next=templ; -} - -void CbPop(LexStruct *l) -{ - LexCbStack *templ=l->cb.cb_next; - MemCpy(&l->cb,templ,sizeof(LexCbStack)); - if (templ->cb_misc_list_end==&templ->cb_misc_list) - l->cb.cb_misc_list_end=&l->cb.cb_misc_list; - Free(templ); -} - -CbMiscStruct *CbFindGotoLabel(LexStruct *l,I1 *name) -{ - CbMiscStruct *templ=l->cb.cb_misc_list; - while (templ) { - if (templ->type==CBMT_GOTO_LABEL) { - if (!StrCmp(templ->string,name)) - return templ; - } - templ=templ->next; - } - return NULL; -} - -CbMiscStruct *CbMiscNew(LexStruct *l,U8 t) -{ - CbMiscStruct *result=MAllocZ(sizeof(CbMiscStruct)); - l->cb.cb_misc_list_end->next=result; - l->cb.cb_misc_list_end=result; - result->address=INVALID_PTR; - result->type=t; - return result; -} - - -void DelCbMiscList(LexStruct *l) -{ - CbMiscStruct *mc=l->cb.cb_misc_list,*mc1; - while (mc) { - mc1=mc->next; - if (mc->type==CBMT_GOTO_LABEL && - !mc->address) { - l->cb.cb_misc_list=NULL; //prevent recursion - cout SysText("ST_ERROR"),SysText("ST_UNDEFINED_GOTO_LABEL"); - coutln mc->string; - throw(EXCEPT_COMPILER,1); - } - Free(mc->string); - Free(mc->jmp_table); - Free(mc); - mc=mc1; - } -} - -LexStruct *CbPopNoFree(LexStruct *l) -{ - LexCbStack *templ=l->cb.cb_next; - MemCpy(&l->cb,templ,sizeof(LexCbStack)); - if (templ->cb_misc_list_end==&templ->cb_misc_list) - l->cb.cb_misc_list_end=&l->cb.cb_misc_list; - return templ; -} - -void CbAppend(LexStruct *l, LexCbStack *ll) -{ - IntermediateCode *tempi; - CbInitInPtrs(ll); - do { - tempi=CbGetIc1(ll); - if (tempi->ic_code) { - CbAddIc(l,tempi->ic_code,tempi->ic_data, - tempi->ic_class,tempi->ic_flags); - } - } while (tempi->ic_code); - DelLinkedList(ll->cb_out_first); - - if (ll->cb_misc_list_end!=&ll->cb_misc_list) { - l->cb.cb_misc_list_end->next=ll->cb_misc_list; - l->cb.cb_misc_list_end=ll->cb_misc_list_end; - } - Free(ll); -} - -void CbCombine(LexStruct *l) -{ - CodeBlk *cb=l->cb.cb_out_first,*cb1,*cb2; - I8 i=0,j=sizeof(CodeBlk)-4; - U4 *ptr; - while (cb) { - i++; - cb=cb->next; - } - if (i>1) { - cb1=MAlloc(i*j+4); - cb1->next=NULL; - cb=l->cb.cb_out_first; - ptr=&cb1->data; - while (cb) { - cb2=cb->next; - MemCpy(ptr,&cb->data,j); - ptr+=j; - Free(cb); - cb=cb2; - } - l->cb.cb_out_first=cb1; - } -} - -U8 CbCountCode(LexStruct *l,I8 pass,I8 *min_line,I8 *max_line) -{ - U8 result=0,code; - I8 i,min_line2=-1,last_line=0; - ClassStruct *tempc; - IntermediateCode *tempi; - CbMiscStruct *lb; - CbInitInPtrs(&l->cb); - tempi=l->cb.cb_in_ptr; - while (code=tempi->ic_code.u2[0]) { - if (code>EC_END_EXP) { - if (code==EC_LABEL) { - lb=tempi->ic_data; - lb->address=result; - } else if (code>=EC_SKIPZ && code<=EC_OR_OR_SKIPNZ2) { - if (pass==2) { - lb=tempi->ic_data; - if (lb->address!=INVALID_PTR) { - i=lb->address-result; - if (i<116 && i>-116) //U1 disp - tempi->ic_code= --code; - } - } - } - i=unsigned_code_table[code+1]-unsigned_code_table[code]; - tempc=tempi->ic_class; - if (!(tempi->ic_flags & ICF_USE_UNSIGNED_TEMPLATE)) { - if (tempc->sub_type==IT_DOUBLE || - tempi->ic_flags & ICF_USE_DOUBLE_TEMPLATE) { - if (double_code_table[code+1]-double_code_table[code]) - i=double_code_table[code+1]-double_code_table[code]; - } else if (!(tempc->sub_type & 1) && code_table[code+1]-code_table[code]) - i=code_table[code+1]-code_table[code]; - } - result+=i; - if (tempi->ic_flags & ICF_NO_PUSHES) - result-=2; - if (tempi->ic_flags & ICF_TO_DOUBLE) { - result+=unsigned_code_table[EC_TO_DOUBLE+1]- - unsigned_code_table[EC_TO_DOUBLE]; - if (tempi->ic_flags & ICF_NO_PUSHES_TO_DOUBLE_OR_INT) - result-=2; - } - if (tempi->ic_flags & ICF_TO_INT) { - result+=unsigned_code_table[EC_TO_INT+1]- - unsigned_code_table[EC_TO_INT]; - if (tempi->ic_flags & ICF_NO_PUSHES_TO_DOUBLE_OR_INT) - result-=2; - } - if (pass==2 && i) { - i=tempi->ic_line; - if (i>=last_line) { - last_line=i; - if (i<*min_line) - *min_line=i; - if (i>*min_line && i*max_line) - *max_line=i; - } - } - } - tempi+=sizeof(IntermediateCode); - } - lb=l->cb.cb_misc_list; - while (lb) { - if (lb->type==CBMT_STRING_CONSTANT) { -// lb->address=result+sizeof(U4); -// result+=sizeof(U4)+lb->st_len; - lb->address=result; - result+=lb->st_len; - } else if (lb->type==CBMT_JMP_TABLE) { - lb->address=result; - result+=lb->st_len<<2; - } - lb=lb->next; - } - if (pass==2) { - if (min_line2!=-1 && - (min_line2-*min_line)>10) //Defines screw things up - *min_line=min_line2; - } - return result; -} - -U1 *CbCompile(LexStruct *l,ClassStruct *fun_class, - U8 *code_size,DbgInfo **dbg_info,U8 *type=NULL) -{ - U1 *result,*dst,*bb; - I8 min_line=MAX_I8,max_line=0; - U8 i,code,p1,p2,size,fix_up_type; - U4 *dd; - ClassStruct *tempc; - IntermediateCode *tempi; - CbMiscStruct *lb,*lb1; - DbgInfo *my_dbg=NULL; - ExeAbsoluteAddressStruct *tempa; - AsmCtrlStruct *a=l->a; - U8 Dasm2(U1 *ip,I8 cnt,BoolU4 use16); - - CbCombine(l); - if (Bt(&l->flags,LFf_OPT_TRACE)) { - coutln "$$IV 1$$Before Pass 1:$$IV 0$$"; - CbPutAllIc(l); - } - CmpOptPass1(l,fun_class,TRUE); - if (Bt(&l->flags,LFf_OPT_TRACE)) { - coutln "$$IV 1$$After Pass 1:$$IV 0$$"; - CbPutAllIc(l); - } - CmpOptPass2(l,fun_class); - if (Bt(&l->flags,LFf_OPT_TRACE)) { - coutln "$$IV 1$$After Pass 2:$$IV 0$$"; - CbPutAllIc(l); - } - CmpOptPass3(l,fun_class); - if (Bt(&l->flags,LFf_OPT_TRACE)) { - coutln "$$IV 1$$After Pass 3:$$IV 0$$"; - CbPutAllIc(l); - } - CmpOptPass4(l,fun_class); - if (Bt(&l->flags,LFf_OPT_TRACE)) { - coutln "$$IV 1$$After Pass 4:$$IV 0$$"; - CbPutAllIc(l); - } - - CbCountCode(l,1,NULL,NULL); - *code_size=CbCountCode(l,2,&min_line,&max_line); - result=MAlloc(*code_size); - if (max_line>=min_line && max_line-min_line<10000) { - my_dbg=MAllocZ(offset(DbgInfo.body)+sizeof(U4)*(max_line-min_line+1)); - my_dbg->min_line=min_line; - my_dbg->max_line=max_line; - } - if (dbg_info) - *dbg_info=my_dbg; - - dst=result; - CbInitInPtrs(&l->cb); - tempi=l->cb.cb_in_ptr; - while (code=tempi->ic_code.u2[0]) { - if (code>EC_END_EXP) { - if (type) { - if (tempc=tempi->ic_class) { - if (tempi->ic_flags & ICF_TO_DOUBLE) - *type=IT_DOUBLE; - else if (tempi->ic_flags & ICF_TO_INT) - *type=IT_I8; - else - *type=tempc->sub_type; - } - } - p1=unsigned_code_table[code]; - p2=unsigned_code_table[code+1]; - size=p2-p1; - fix_up_type=unsigned_fix_up_table[code]; - tempc=tempi->ic_class; - if (!(tempi->ic_flags & ICF_USE_UNSIGNED_TEMPLATE)) { - if (tempc->sub_type==IT_DOUBLE || - tempi->ic_flags & ICF_USE_DOUBLE_TEMPLATE) { - if (double_code_table[code+1]-double_code_table[code]) { - p1=double_code_table[code]; - p2=double_code_table[code+1]; - size=p2-p1; - fix_up_type=double_fix_up_table[code]; - } - } else if (!(tempc->sub_type & 1) && code_table[code+1]-code_table[code]) { - p1=code_table[code]; - p2=code_table[code+1]; - size=p2-p1; - fix_up_type=signed_fix_up_table[code]; - } - } - if (tempi->ic_flags & ICF_NO_PUSHES) { - p1+=2; - size-=2; - } - if (size) { - MemCpy(dst,p1,size); - if (my_dbg) { - if (tempi->ic_line>=min_line && tempi->ic_line<=max_line) { - i=tempi->ic_line-min_line; - if (!my_dbg->body[i]) { - if (a) - my_dbg->body[i]=a->ip+dst-result; - else - my_dbg->body[i]=dst; - } - } - } - } - dst+=size; - switch (fix_up_type) { - case FUT_8_1: - bb=dst-1; - *bb=tempi->ic_data; - break; - case FUT_8_2: - bb=dst-2; - *bb=tempi->ic_data; - break; - case FUT_8_4: - bb=dst-4; - *bb=tempi->ic_data; - break; - case FUT_8_5: - bb=dst-5; - *bb=tempi->ic_data; - break; - case FUT_8_6: - bb=dst-6; - *bb=tempi->ic_data; - break; - case FUT_8_10: - bb=dst-10; - *bb=tempi->ic_data; - break; - case FUT_8_JMP_1: - lb=tempi->ic_data; - if (a) - i=lb->address-(dst-result); - else - i=(result+lb->address)-dst; - bb=dst-1; - *bb=i; - break; - case FUT_32_4: - dd=dst-4; - *dd=tempi->ic_data; - break; - case FUT_32_4_CALL: - if (a) - i=tempi->ic_data-(a->ip+dst-result); - else - i=tempi->ic_data-dst; - dd=dst-4; - *dd=i; - break; - case FUT_32_4_ABS: - dd=dst-4; - *dd=tempi->ic_data; - if (a && !(l->flags & LF_ASM_EXPRESSIONS)) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip+dd-result; - } - break; - case FUT_32_4_ABS2: - lb=tempi->ic_data; - if (a) - i=lb->address+a->ip; - else - i=lb->address+result; - dd=dst-4; - *dd=i; - if (a && !(l->flags & LF_ASM_EXPRESSIONS)) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip+dd-result; - } - break; - case FUT_32_5: - dd=dst-5; - *dd=tempi->ic_data; - break; - case FUT_32_6: - dd=dst-6; - *dd=tempi->ic_data; - break; - case FUT_32_7: - dd=dst-7; - *dd=tempi->ic_data; - break; - case FUT_32_9: - dd=dst-9; - *dd=tempi->ic_data; - break; - case FUT_32_4P10_4: - dd=dst-4; - *dd=tempi->ic_data; - dd=dst-10; - *dd=tempi->ic_data+4; - break; - case FUT_32_4P11_4: - dd=dst-4; - *dd=tempi->ic_data; - dd=dst-11; - *dd=tempi->ic_data+4; - break; - case FUT_32_JMP_4: - lb=tempi->ic_data; - if (a) - i=lb->address-(dst-result); - else - i=(result+lb->address)-dst; - dd=dst-4; - *dd=i; - break; - case FUT_64_H9_L4: - dd=dst-4; - *dd=tempi->ic_data.u4[0]; - dd=dst-9; - *dd=tempi->ic_data.u4[1]; - break; - case FUT_ENTER1: - dd=dst-11; - *dd=tempi->ic_data; - dd=dst-4; - *dd=l->ESI_offset; - break; - case FUT_ENTER2: - dd=dst-18; - *dd=tempi->ic_data; - dd=dst-10; - *dd=l->ESI_offset; - dd=dst-4; - *dd=l->EDI_offset; - break; - } - if (tempi->ic_flags & ICF_TO_DOUBLE) { - p1=unsigned_code_table[EC_TO_DOUBLE]; - p2=unsigned_code_table[EC_TO_DOUBLE+1]; - size=p2-p1; - if (tempi->ic_flags & ICF_NO_PUSHES_TO_DOUBLE_OR_INT) { - p1+=2; - size-=2; - } - MemCpy(dst,p1,size); - dst+=size; - } - if (tempi->ic_flags & ICF_TO_INT) { - p1=unsigned_code_table[EC_TO_INT]; - p2=unsigned_code_table[EC_TO_INT+1]; - size=p2-p1; - if (tempi->ic_flags & ICF_NO_PUSHES_TO_DOUBLE_OR_INT) { - p1+=2; - size-=2; - } - MemCpy(dst,p1,size); - dst+=size; - } - } - tempi+=sizeof(IntermediateCode); - } - lb=l->cb.cb_misc_list; - while (lb) { - if (lb->type==CBMT_STRING_CONSTANT) { -/* - i=(lb->st_len+7) & -4; - MemCpy(result+lb->address-sizeof(U4),&i,sizeof(U4)); -*/ - MemCpy(result+lb->address,lb->string,lb->st_len); - } else if (lb->type==CBMT_JMP_TABLE) { - for (i=0;ist_len;i++) { - lb1=lb->jmp_table[i]; - dd=result+lb->address+i<<2; - if (a) { - tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); - tempa->next=a->absolutes; - a->absolutes=tempa; - tempa->ip=a->ip+dd-result; - *dd=lb1->address+a->ip; - } else - *dd=lb1->address+result; - } - } - lb=lb->next; - } - Free(l->cb.cb_out_first); - DelCbMiscList(l); - if (Bt(&l->flags,LFf_COMPILE_TRACE)) { - if (Dasm2=FindExtern("Dasm2")) - Dasm2(result,*code_size,FALSE); - } - return result; -} - -void DelHashTable(SysHashTable *tempht) -{ - I8 i; - SysHashEntry *temph,*temph1; - ClassStruct *tempc; - GlblVarStruct *tempg; - if (!tempht) return; - for (i=0;i<=tempht->mask;i++) { - temph=tempht->body[i]; - while (temph) { - temph1=temph->next; - Free(temph->string); - if (temph->type & (HTT_FUNCTION | HTT_CLASS | - HTT_STRING_CONSTANT | HTT_GLBL_VAR | - HTT_SYS_SYMBOL)) { - Free(temph->source_link); - if (temph->type & (HTT_FUNCTION | HTT_CLASS)) { - tempc=temph; - Free(tempc->debug); - Free(tempc->import_name); - DelMemberList(tempc); - //assumes code not on heap - } else if (temph->type&HTT_STRING_CONSTANT) - Free(temph><(StringConstantStruct *)->data); - else if (temph->type&HTT_GLBL_VAR) { - tempg=temph; - Free(tempg->import_name); - } - } - Free(temph); - temph=temph1; - } - } - Free(tempht); -} - - \ No newline at end of file diff --git a/LT/COMPILE/LoadCmp2.CPZ b/LT/COMPILE/LoadCmp2.CPZ deleted file mode 100644 index 6b36a70..0000000 Binary files a/LT/COMPILE/LoadCmp2.CPZ and /dev/null differ diff --git a/LT/COMPILE/OPT.CPZ b/LT/COMPILE/OPT.CPZ deleted file mode 100644 index 33e78c2..0000000 --- a/LT/COMPILE/OPT.CPZ +++ /dev/null @@ -1,3045 +0,0 @@ -BoolU4 FixupBinaryOp1(IntermediateCode *tempi, - IntermediateCode *tempi1,IntermediateCode *tempi2, - BoolU4 *is_unsigned) -{ - ClassStruct *tempc=tempi->ic_class,*tempc1,*tempc2; - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - *is_unsigned=tempc1->sub_type&1 || tempc2->sub_type&1; - tempi->ic_class=tempc; - if (tempc->sub_type==IT_DOUBLE) - return FALSE; - return tempi1->ic_code.u2[0]==EC_U8 && - tempi2->ic_code.u2[0]==EC_U8; -} - -BoolU4 FixupBinaryOp2(IntermediateCode **tempi1,IntermediateCode **tempi2) -{ - IntermediateCode *tempii1=*tempi1, - *tempii2=*tempi2; - if (tempii1->ic_code.u2[0]==EC_U8 && - !(tempii1->ic_flags & ICF_TO_DOUBLE)) - return TRUE; - if (tempii2->ic_code.u2[0]==EC_U8 && - !(tempii2->ic_flags & ICF_TO_DOUBLE)) { - *tempi1=tempii2; - *tempi2=tempii1; - return TRUE; - } - return FALSE; -} - -BoolU4 FixupBinaryOp3(IntermediateCode *tempi1) -{ - return tempi1->ic_code.u2[0]==EC_U8; -} - -void ShiftNoPush(IntermediateCode *tempi) -{ - if (tempi->ic_flags & ICF_NO_PUSHES) { - while (TRUE) { - if (!tempi->ic_code.u2[0]) - return; - if (tempi->ic_code.u2[0]!=EC_NOP) { - tempi->ic_flags |= ICF_NO_PUSHES; - return; - } - tempi+=sizeof(IntermediateCode); - } - } -} - - -void OptMissing(LexStruct *l,I8 pass,IntermediateCode *tempi) -{ - coutln "Pass:",pass," Missing IC handler"; - CbPutIc(tempi); - PrsExcept(l,"ST_OPT_INTERNAL_ERROR"); -} - -IntermediateCode opt_nop={EC_NOP,0,0,0,0}; -ParseStack *OptStart(LexStruct *l,IntermediateCode **temp_lag) -{ - I8 i; - ParseStack *ps=MAlloc(sizeof(ParseStack)); - CbInitInPtrs(&l->cb); - ps->ptr=0; - PrsPush(ps,0); - for (i=0;i<4;i++) - temp_lag[i]=&opt_nop; - return ps; -} - - - -LTextern CP_OPTNEXT BoolU4 OptNext(IntermediateCode *tempi, - IntermediateCode **temp_lag); - -/********** -void OptNext(IntermediateCode *tempi, - IntermediateCode **temp_lag) -{ - I8 i,j=0; - for (i=3;i>0;i--) - temp_lag[i]=temp_lag[i-1]; - temp_lag[0]=tempi; - for (i=0;i<4;i++) //TODO: move end_exp - if (temp_lag[i]->ic_code.u2[0]>EC_END_EXP) - temp_lag[j++]=temp_lag[i]; - while (j<4) - temp_lag[j++]=&opt_nop; -} -************/ - -void OptEnd(LexStruct *l,I8 pass,ParseStack *ps) -{ - if (ps->ptr>2) { - PrintF("Pass:%d Stack:%d\r\n",pass,ps->ptr); - PrsExcept(l,"ST_OPT_INTERNAL_ERROR"); - } - Free(ps); -} - -IntermediateCode *CmpOptPass1(LexStruct *l,ClassStruct *fun_class,BoolU4 combined) -{ //simplify constant arithmetic - I8 i1,i2; - U8 u1,u2; - BoolU4 is_unsigned; - ClassStruct *tempc,*tempc1,*tempc2; - IntermediateCode *tempi,*tempi1,*tempi2, - *temp_lag[4],*last_with_class=NULL; - ParseStack *ps=OptStart(l,temp_lag); - if (combined) - tempi=l->cb.cb_in_ptr; - else - tempi=CbGetIc1(&l->cb); - while (tempi->ic_code.u2[0]) { - OptNext(tempi,temp_lag); - switch (tempi->ic_code.u2[0]) { - case EC_U8: - case EC_U4: - case EC_U2: - case EC_U1: - case EC_DOUBLE: - case EC_STRING_CONSTANT: - case EC_EBP: - case EC_FS: - PrsPush(ps,tempi); - break; - case EC_COM: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_U8) { - tempi->ic_data=~tempi1->ic_data; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_NOT: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_U8) { - if (tempi1->ic_data) - tempi->ic_data=0; - else - tempi->ic_data=1; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_UNARY_MINUS: - tempi1=PrsPop(ps); - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - PrsPush(ps,tempi); - break; - } - tempc=tempi1->ic_class; - if (tempc->type&HTT_INTERNAL_TYPE && tempc->sub_type & 1) - tempi->ic_class=sys_internal_types[tempc->sub_type-1]; - if (tempi1->ic_code.u2[0]==EC_U8) { - i1=tempi1->ic_data; - tempi->ic_data=-i1; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U8: - case EC_DEREF_U4: - case EC_DEREF_U2: - case EC_DEREF_U1: - case EC_U8_PP: - case EC_U4_PP: - case EC_U2_PP: - case EC_U1_PP: - case EC_U8_MM: - case EC_U4_MM: - case EC_U2_MM: - case EC_U1_MM: - case EC_PP_U8: - case EC_PP_U4: - case EC_PP_U2: - case EC_PP_U1: - case EC_MM_U8: - case EC_MM_U4: - case EC_MM_U2: - case EC_MM_U1: - case EC_INC: - case EC_DEC: - case EC_SHL_CONSTANT1: - case EC_SHL_CONSTANT2: - case EC_SHR_CONSTANT1: - case EC_SHR_CONSTANT2: - case EC_ADD64: - case EC_ADD32: - case EC_ADD8: - case EC_SUB64: - case EC_SUB32: - case EC_SUB8: - ps->ptr--; - PrsPush(ps,tempi); - break; - - case EC_POWER: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - if (tempc->sub_type!=IT_DOUBLE) - tempi->ic_flags|=ICF_TO_INT|ICF_USE_DOUBLE_TEMPLATE; - PrsPush(ps,tempi); - break; - case EC_SHL: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1<ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1<ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } else if (FixupBinaryOp3(tempi2)) { - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - if (tempi2->ic_data<32) { - tempi->ic_data=tempi2->ic_data; - tempi->ic_code=EC_SHL_CONSTANT1; - } else { - tempi->ic_data=tempi2->ic_data-32; - tempi->ic_code=EC_SHL_CONSTANT2; - } - } - PrsPush(ps,tempi); - break; - case EC_SHR: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1>>u2; - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1>>i2; - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } else if (FixupBinaryOp3(tempi2)) { - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - if (tempi2->ic_data<32) { - tempi->ic_data=tempi2->ic_data; - tempi->ic_code=EC_SHR_CONSTANT1; - } else { - tempi->ic_data=tempi2->ic_data-32; - tempi->ic_code=EC_SHR_CONSTANT2; - } - } - PrsPush(ps,tempi); - break; - case EC_MULTIPLICATION: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=MulU8(u1,u2); - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=MulI8(i1,i2); - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - PrsPush(ps,tempi); - } else { - if (tempi1->ic_code.u2[0]==EC_U8) { - switch (tempi1->ic_data) { - case 1: - tempi1->ic_flags|=tempi->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; -// tempi2->ic_class=tempi->ic_class; - PrsPush(ps,tempi1); - break; - case 2: - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_data=1; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 4: - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_data=2; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 8: - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_data=3; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 16: - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_data=4; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 32: - tempi->ic_flags|=tempi1->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_data=5; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - default: - PrsPush(ps,tempi); - } - } else if (tempi2->ic_code.u2[0]==EC_U8) { - switch (tempi2->ic_data) { - case 1: - tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; -// tempi1->ic_class=tempi->ic_class; - PrsPush(ps,tempi1); - break; - case 2: - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_data=1; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 4: - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_data=2; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 8: - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_data=3; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 16: - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_data=4; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - case 32: - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_data=5; - tempi->ic_code=EC_SHL_CONSTANT1; - PrsPush(ps,tempi); - break; - default: - PrsPush(ps,tempi); - } - } else - PrsPush(ps,tempi); - } - break; - case EC_DIVISION: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (!tempi2->ic_data) PrsExcept(l,"ST_DIVIDE_BY_ZERO"); - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=DivU8(u1,u2); - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=DivI8(i1,i2); - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - PrsPush(ps,tempi); - } else { - if (tempi2->ic_code.u2[0]==EC_U8) { - switch (tempi2->ic_data) { - case 1: - tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; -// tempi1->ic_class=tempi->ic_class; - PrsPush(ps,tempi1); - break; - case 2: - tempi2->ic_data=1; - tempi->ic_code=EC_SHR; - PrsPush(ps,tempi); - break; - case 4: - tempi2->ic_data=2; - tempi->ic_code=EC_SHR; - PrsPush(ps,tempi); - break; - case 8: - tempi2->ic_data=3; - tempi->ic_code=EC_SHR; - PrsPush(ps,tempi); - break; - case 16: - tempi2->ic_data=4; - tempi->ic_code=EC_SHR; - PrsPush(ps,tempi); - break; - case 32: - tempi2->ic_data=5; - tempi->ic_code=EC_SHR; - PrsPush(ps,tempi); - break; - default: - PrsPush(ps,tempi); - } - } else - PrsPush(ps,tempi); - } - break; - case EC_REMAINDER: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (!tempi2->ic_data) PrsExcept(l,"ST_DIVIDE_BY_ZERO"); - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=ModU8(u1,u2); - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=ModI8(i1,i2); - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_AND: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1&u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_OR: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1|u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_XOR: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1^u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_ADDITION: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1+u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - PrsPush(ps,tempi); - } else { - if (tempi1->ic_code.u2[0]==EC_U8 && !tempi1->ic_data) { - tempi2->ic_flags|=tempi1->ic_flags|tempi->ic_flags; - tempi1->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; -// tempi2->ic_class=tempi->ic_class; - PrsPush(ps,tempi2); - } else if (tempi2->ic_code.u2[0]==EC_U8 && !tempi2->ic_data) { - tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; -// tempi1->ic_class=tempi->ic_class; - PrsPush(ps,tempi1); - } else - PrsPush(ps,tempi); - } - break; - case EC_SUBTRACTION: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1-u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - PrsPush(ps,tempi); - } else { - if (tempi2->ic_code.u2[0]==EC_U8 && !tempi2->ic_data) { - tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; - tempi2->ic_code=EC_NOP; - tempi->ic_code=EC_NOP; - tempi1->ic_class=tempi->ic_class; - PrsPush(ps,tempi1); - } else - PrsPush(ps,tempi); - } - break; - case EC_EQUAL_EQUAL: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1==u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_NOT_EQUAL_TO: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1!=u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_LESS_THAN: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - if (is_unsigned) - tempi->ic_flags|=ICF_USE_UNSIGNED_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_GREATER_THAN: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1>u2; - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1>i2; - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - if (is_unsigned) - tempi->ic_flags|=ICF_USE_UNSIGNED_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_LESS_OR_EQUAL: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1<=u2; - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1<=i2; - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - if (is_unsigned) - tempi->ic_flags|=ICF_USE_UNSIGNED_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_GREATER_OR_EQUAL: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - tempi->ic_flags|=ICF_USE_DOUBLE_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - } - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - if (is_unsigned) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1>=u2; - } else { - i1=tempi1->ic_data; - i2=tempi2->ic_data; - tempi->ic_data=i1>=i2; - } - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - if (is_unsigned) - tempi->ic_flags|=ICF_USE_UNSIGNED_TEMPLATE; - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_AND_AND: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1&&u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_OR_OR: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1||u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_XOR_XOR: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { - u1=tempi1->ic_data; - u2=tempi2->ic_data; - tempi->ic_data=u1^^u2; - tempi->ic_code=EC_U8; - tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; - tempi1->ic_code=EC_NOP; - tempi2->ic_code=EC_NOP; - } - tempi->ic_class=sys_internal_types[IT_I8]; - PrsPush(ps,tempi); - break; - case EC_COLON: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc1=tempi1->ic_class; - tempc2=tempi2->ic_class; - if (tempc1->sub_type>=tempc2->sub_type) - tempi->ic_class=tempc1; - else - tempi->ic_class=tempc2; - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - if (tempc1->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (tempc2->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - } - ps->ptr-=1; - PrsPush(ps,tempi); - break; - case EC_ASSIGN_U8: - case EC_MUL_EQUAL_U8: - case EC_DIV_EQUAL_U8: - case EC_ADD_EQUAL_U8: - case EC_SUB_EQUAL_U8: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc=tempi->ic_class; - if (tempc->sub_type==IT_DOUBLE) { - tempc=tempi2->ic_class; - if (tempc->sub_type!=IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_DOUBLE; - } else { - tempc=tempi2->ic_class; - if (tempc->sub_type==IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_INT; - } - PrsPush(ps,tempi); - break; - case EC_ASSIGN_U4: - case EC_ASSIGN_U2: - case EC_ASSIGN_U1: - case EC_SHL_EQUAL_U8: - case EC_SHL_EQUAL_U4: - case EC_SHL_EQUAL_U2: - case EC_SHL_EQUAL_U1: - case EC_SHR_EQUAL_U8: - case EC_SHR_EQUAL_U4: - case EC_SHR_EQUAL_U2: - case EC_SHR_EQUAL_U1: - case EC_MUL_EQUAL_U4: - case EC_MUL_EQUAL_U2: - case EC_MUL_EQUAL_U1: - case EC_DIV_EQUAL_U4: - case EC_DIV_EQUAL_U2: - case EC_DIV_EQUAL_U1: - case EC_AND_EQUAL_U8: - case EC_AND_EQUAL_U4: - case EC_AND_EQUAL_U2: - case EC_AND_EQUAL_U1: - case EC_OR_EQUAL_U8: - case EC_OR_EQUAL_U4: - case EC_OR_EQUAL_U2: - case EC_OR_EQUAL_U1: - case EC_XOR_EQUAL_U8: - case EC_XOR_EQUAL_U4: - case EC_XOR_EQUAL_U2: - case EC_XOR_EQUAL_U1: - case EC_ADD_EQUAL_U4: - case EC_ADD_EQUAL_U2: - case EC_ADD_EQUAL_U1: - case EC_SUB_EQUAL_U4: - case EC_SUB_EQUAL_U2: - case EC_SUB_EQUAL_U1: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - tempc=tempi2->ic_class; - if (tempc->sub_type==IT_DOUBLE) - tempi2->ic_flags|=ICF_TO_INT; - PrsPush(ps,tempi); - break; - case EC_ENTER: - case EC_LEAVE: - tempi->ic_data=-fun_class->size; - break; - case EC_ADD_ESP32: - ps->ptr-=1+tempi->ic_data>>3; - if (temp_lag[1]->ic_code.u2[0]==EC_ADD_ESP32) { - tempi->ic_data+=temp_lag[1]->ic_data; - tempi->ic_flags|=temp_lag[1]->ic_flags; - temp_lag[1]->ic_code=EC_NOP; - } - PrsPush(ps,tempi); - break; - case EC_CALL: - case EC_CALL_INDIRECT: - case EC_CALL_INDIRECT2: - case EC_CLI: - case EC_STI: - case EC_GET_FLAGS: - case EC_GET_BASE_PTR: - case EC_GET_STACK_PTR: - case EC_GET_LABEL: - case EC_ABSOLUTE_ADDRESS: - case EC_TYPE: - PrsPush(ps,tempi); - break; - case EC_SET_FLAGS: - case EC_SET_BASE_PTR: - case EC_SET_STACK_PTR: - case EC_BSF: - case EC_BSR: - case EC_BT_CONSTANT: - case EC_BTS_CONSTANT: - case EC_BTR_CONSTANT: - case EC_BTC_CONSTANT: - case EC_REMQUE: - case EC_INPD: - case EC_INPW: - case EC_INP: - case EC_STRLEN: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_BT: - case EC_BTS: - case EC_BTR: - case EC_BTC: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - i1=tempi1->ic_data; - if (FixupBinaryOp3(tempi1) && - i1>=-128 && i1<128) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_data=i1; - tempi->ic_code+=EC_BT_CONSTANT-EC_BT; - } - PrsPush(ps,tempi); - break; - case EC_INSQUE: - case EC_INSQUE_REV: - case EC_OUTPD: - case EC_OUTPW: - case EC_OUTP: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_SWITCH: - ps->ptr-=2; - break; - case EC_MEMCPY: - case EC_MEMSET: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - - case EC_SKIPZ2: - ps->ptr--; - tempi2=temp_lag[1]; -ec_skipz2: - switch (tempi2->ic_code.u2[0]) { - case EC_NOT: - tempi->ic_code=EC_SKIPNZ2; - tempi2->ic_code=EC_NOP; - tempi->ic_class=tempi2->ic_class; - tempi->ic_flags=tempi2->ic_flags; - tempi2=temp_lag[2]; - temp_lag[2]=temp_lag[3]; - temp_lag[3]=&opt_nop; - if (tempi2->ic_code.u2[0]!=EC_NOT) - goto ec_skipnz2; - else - goto ec_skipz_done; - case EC_EQUAL_EQUAL: - tempi->ic_code=EC_EQUAL_EQUAL_SKIPZ2; - break; - case EC_NOT_EQUAL_TO: - tempi->ic_code=EC_NOT_EQUAL_TO_SKIPZ2; - break; - case EC_LESS_THAN: - tempi->ic_code=EC_LESS_THAN_SKIPZ2; - break; - case EC_GREATER_THAN: - tempi->ic_code=EC_GREATER_THAN_SKIPZ2; - break; - case EC_LESS_OR_EQUAL: - tempi->ic_code=EC_LESS_OR_EQUAL_SKIPZ2; - break; - case EC_GREATER_OR_EQUAL: - tempi->ic_code=EC_GREATER_OR_EQUAL_SKIPZ2; - break; - case EC_OR_OR: - tempi->ic_code=EC_OR_OR_SKIPZ2; - break; - case EC_AND_AND: - tempi->ic_code=EC_AND_AND_SKIPZ2; - break; - } - if (tempi->ic_code.u2[0]!=EC_SKIPZ2) { - tempi->ic_class=tempi2->ic_class; - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - } -ec_skipz_done: - PrsPush(ps,tempi); - break; - case EC_SKIPNZ2: - ps->ptr--; - tempi2=temp_lag[1]; -ec_skipnz2: - switch (tempi2->ic_code.u2[0]) { - case EC_NOT: - tempi->ic_code=EC_SKIPZ2; - tempi2->ic_code=EC_NOP; - tempi->ic_class=tempi2->ic_class; - tempi->ic_flags=tempi2->ic_flags; - tempi2=temp_lag[2]; - temp_lag[2]=temp_lag[3]; - temp_lag[3]=&opt_nop; - if (tempi2->ic_code.u2[0]!=EC_NOT) - goto ec_skipz2; - else - goto ec_skipnz_done; - case EC_EQUAL_EQUAL: - tempi->ic_code=EC_NOT_EQUAL_TO_SKIPZ2; - break; - case EC_NOT_EQUAL_TO: - tempi->ic_code=EC_EQUAL_EQUAL_SKIPZ2; - break; - case EC_LESS_THAN: - tempi->ic_code=EC_GREATER_OR_EQUAL_SKIPZ2; - break; - case EC_GREATER_THAN: - tempi->ic_code=EC_LESS_OR_EQUAL_SKIPZ2; - break; - case EC_LESS_OR_EQUAL: - tempi->ic_code=EC_GREATER_THAN_SKIPZ2; - break; - case EC_GREATER_OR_EQUAL: - tempi->ic_code=EC_LESS_THAN_SKIPZ2; - break; - case EC_OR_OR: - tempi->ic_code=EC_OR_OR_SKIPNZ2; - break; - case EC_AND_AND: - tempi->ic_code=EC_AND_AND_SKIPNZ2; - break; - } - if (tempi->ic_code.u2[0]!=EC_SKIPNZ2) { - tempi->ic_class=tempi2->ic_class; - tempi->ic_flags|=tempi2->ic_flags; - tempi2->ic_code=EC_NOP; - } -ec_skipnz_done: - PrsPush(ps,tempi); - break; - case EC_EQUAL_EQUAL_SKIPZ2: - case EC_NOT_EQUAL_TO_SKIPZ2: - case EC_LESS_THAN_SKIPZ2: - case EC_GREATER_THAN_SKIPZ2: - case EC_LESS_OR_EQUAL_SKIPZ2: - case EC_GREATER_OR_EQUAL_SKIPZ2: - case EC_AND_AND_SKIPZ2: - case EC_AND_AND_SKIPNZ2: - case EC_OR_OR_SKIPZ2: - case EC_OR_OR_SKIPNZ2: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - - case EC_NULL: - case EC_LABEL: - case EC_ADDRESS: - case EC_QUESTION: - case EC_JMP: - case EC_IRQ: - case EC_NOP: - case EC_RET: - break; - - case EC_END_EXP: - ps->ptr--; - break; - - default: - OptMissing(l,1,tempi); - } - if (tempi->ic_class) - last_with_class=tempi; - if (combined) - tempi+=sizeof(IntermediateCode); - else - tempi=CbGetIc1(&l->cb); - } - OptEnd(l,1,ps); - return last_with_class; -} - -#define PASS2_OFFSETS 4 - -void CmpOptPass2(LexStruct *l,ClassStruct *fun_class) -{ - MemberListStruct *tempm; - ClassStruct *tempc; - IntermediateCode *tempi,*tempi1,*tempi2, - *temp_lag[4],*last_with_class=NULL; - I8 i,j,o[PASS2_OFFSETS+2],c[PASS2_OFFSETS+2],lea_s[PASS2_OFFSETS+2]; - ParseStack *ps=OptStart(l,temp_lag); - - for (i=0;imember_list; - while (tempm) { - tempc=tempm->member_class; - if (!tempm->cnt && tempc->pointer_cnt && tempm->use_cnt>c[PASS2_OFFSETS-1]) { - for (i=0;iuse_cnt>c[i]) { - for (j=i;juse_cnt; - o[i]=tempm->offset; - break; - } - } - tempm=tempm->next; - } - } - - tempi=l->cb.cb_in_ptr; - while (tempi->ic_code.u2[0]) { - OptNext(tempi,temp_lag); - switch (tempi->ic_code.u2[0]) { - case EC_U8: - case EC_U4: - case EC_U2: - case EC_U1: - case EC_DOUBLE: - case EC_STRING_CONSTANT: - case EC_EBP: - case EC_FS: - PrsPush(ps,tempi); - break; - case EC_COM: - case EC_NOT: - case EC_UNARY_MINUS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_DEREF_U8: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_EBP) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U8_DISP32; - } else if (temp_lag[2]->ic_code.u2[0]==EC_FS) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_FS_U8_DISP32; - } else if (temp_lag[2]->ic_data==3 && - temp_lag[2]->ic_code.u2[0]==EC_SHL_CONSTANT1) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U8_DISP32_SCALED; - for (i=0;iic_data) - lea_s[i]+=100000; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U4: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_EBP) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U4_DISP32; - } else if (temp_lag[2]->ic_code.u2[0]==EC_FS) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_FS_U4_DISP32; - } else if (temp_lag[2]->ic_data==2 && - temp_lag[2]->ic_code.u2[0]==EC_SHL_CONSTANT1) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U4_DISP32_SCALED; - for (i=0;iic_data) - lea_s[i]+=100000; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U2: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_EBP) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U2_DISP32; - } else if (temp_lag[2]->ic_code.u2[0]==EC_FS) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_FS_U2_DISP32; - } else if (temp_lag[2]->ic_data==1 && - temp_lag[2]->ic_code.u2[0]==EC_SHL_CONSTANT1) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U2_DISP32_SCALED; - for (i=0;iic_data) - lea_s[i]+=100000; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U1: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_EBP) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_U1_DISP32; - } else if (temp_lag[2]->ic_code.u2[0]==EC_FS) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_FS_U1_DISP32; - } - } - PrsPush(ps,tempi); - break; - case EC_U4_PP: - case EC_U4_MM: - case EC_PP_U4: - case EC_MM_U4: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } else if (temp_lag[1]->ic_code.u2[0]==EC_ADD32 && - temp_lag[2]->ic_code.u2[0]==EC_EBP) { - for (i=0;iic_data) - lea_s[i]--; - } - PrsPush(ps,tempi); - break; - case EC_U8_PP: - case EC_U2_PP: - case EC_U1_PP: - case EC_U8_MM: - case EC_U2_MM: - case EC_U1_MM: - case EC_PP_U8: - case EC_PP_U2: - case EC_PP_U1: - case EC_MM_U8: - case EC_MM_U2: - case EC_MM_U1: - case EC_SHL_CONSTANT1: - case EC_SHL_CONSTANT2: - case EC_SHR_CONSTANT1: - case EC_SHR_CONSTANT2: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_POWER: - case EC_SHL: - case EC_SHR: - case EC_MULTIPLICATION: - case EC_DIVISION: - case EC_REMAINDER: - case EC_AND: - case EC_OR: - case EC_XOR: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_ADDITION: - if (tempi->ic_class->sub_type==IT_DOUBLE) { - ps->ptr-=2; - PrsPush(ps,tempi); - break; - } - tempi1=PrsPop(ps); - tempi2=PrsPop(ps); - if (FixupBinaryOp2(&tempi1,&tempi2)) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_data=tempi1->ic_data; - tempi->ic_code=EC_ADD32; - } - PrsPush(ps,tempi); - break; - case EC_SUBTRACTION: - if (tempi->ic_class->sub_type==IT_DOUBLE) { - ps->ptr-=2; - PrsPush(ps,tempi); - break; - } - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (FixupBinaryOp3(tempi2)) { - tempi->ic_flags|=(tempi2->ic_flags&~ICF_NO_PUSHES); - tempi2->ic_code=EC_NOP; - ShiftNoPush(tempi2); - tempi->ic_data=tempi2->ic_data; - tempi->ic_code=EC_SUB32; - } - PrsPush(ps,tempi); - break; - case EC_EQUAL_EQUAL: - case EC_NOT_EQUAL_TO: - case EC_LESS_THAN: - case EC_GREATER_THAN: - case EC_LESS_OR_EQUAL: - case EC_GREATER_OR_EQUAL: - case EC_AND_AND: - case EC_OR_OR: - case EC_XOR_XOR: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_COLON: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - - case EC_ASSIGN_U4: - case EC_SHL_EQUAL_U4: - case EC_SHR_EQUAL_U4: - case EC_MUL_EQUAL_U4: - case EC_DIV_EQUAL_U4: - case EC_AND_EQUAL_U4: - case EC_OR_EQUAL_U4: - case EC_XOR_EQUAL_U4: - case EC_ADD_EQUAL_U4: - case EC_SUB_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) - for (i=0;iic_data) - lea_s[i]--; - PrsPush(ps,tempi); - break; - case EC_ASSIGN_U8: - case EC_ASSIGN_U2: - case EC_ASSIGN_U1: - case EC_SHL_EQUAL_U8: - case EC_SHL_EQUAL_U2: - case EC_SHL_EQUAL_U1: - case EC_SHR_EQUAL_U8: - case EC_SHR_EQUAL_U2: - case EC_SHR_EQUAL_U1: - case EC_MUL_EQUAL_U8: - case EC_MUL_EQUAL_U2: - case EC_MUL_EQUAL_U1: - case EC_DIV_EQUAL_U8: - case EC_DIV_EQUAL_U2: - case EC_DIV_EQUAL_U1: - case EC_AND_EQUAL_U8: - case EC_AND_EQUAL_U2: - case EC_AND_EQUAL_U1: - case EC_OR_EQUAL_U8: - case EC_OR_EQUAL_U2: - case EC_OR_EQUAL_U1: - case EC_XOR_EQUAL_U8: - case EC_XOR_EQUAL_U2: - case EC_XOR_EQUAL_U1: - case EC_ADD_EQUAL_U8: - case EC_ADD_EQUAL_U2: - case EC_ADD_EQUAL_U1: - case EC_SUB_EQUAL_U8: - case EC_SUB_EQUAL_U2: - case EC_SUB_EQUAL_U1: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_SHL_CONSTANT1: - case EC_SHL_CONSTANT2: - case EC_SHR_CONSTANT1: - case EC_SHR_CONSTANT2: - case EC_ADD64: - case EC_ADD32: - case EC_ADD8: - case EC_INC: - case EC_SUB64: - case EC_SUB32: - case EC_SUB8: - case EC_DEC: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_ENTER: - break; - case EC_ADD_ESP32: - ps->ptr-=1+tempi->ic_data>>3; - PrsPush(ps,tempi); - break; - case EC_CALL: - case EC_CALL_INDIRECT: - case EC_CALL_INDIRECT2: - PrsPush(ps,tempi); - break; - case EC_CLI: - case EC_STI: - case EC_GET_FLAGS: - PrsPush(ps,tempi); - break; - case EC_SET_FLAGS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_BASE_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_BASE_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_STACK_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_STACK_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_LABEL: - case EC_ABSOLUTE_ADDRESS: - PrsPush(ps,tempi); - break; - case EC_TYPE: - PrsPush(ps,tempi); - break; - case EC_BT: - case EC_BTS: - case EC_BTR: - case EC_BTC: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_BSF: - case EC_BSR: - case EC_BT_CONSTANT: - case EC_BTS_CONSTANT: - case EC_BTR_CONSTANT: - case EC_BTC_CONSTANT: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_INSQUE: - case EC_INSQUE_REV: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_REMQUE: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_MEMCPY: - case EC_MEMSET: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - case EC_INPD: - case EC_INPW: - case EC_INP: - case EC_STRLEN: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_OUTPD: - case EC_OUTPW: - case EC_OUTP: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_SWITCH: - ps->ptr-=2; - break; - case EC_SKIPZ: - case EC_SKIPZ2: - case EC_SKIPNZ: - case EC_SKIPNZ2: //not present yet - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_EQUAL_EQUAL_SKIPZ: - case EC_EQUAL_EQUAL_SKIPZ2: - case EC_NOT_EQUAL_TO_SKIPZ: - case EC_NOT_EQUAL_TO_SKIPZ2: - case EC_LESS_THAN_SKIPZ: - case EC_LESS_THAN_SKIPZ2: - case EC_GREATER_THAN_SKIPZ: - case EC_GREATER_THAN_SKIPZ2: - case EC_LESS_OR_EQUAL_SKIPZ: - case EC_LESS_OR_EQUAL_SKIPZ2: - case EC_GREATER_OR_EQUAL_SKIPZ: - case EC_GREATER_OR_EQUAL_SKIPZ2: - case EC_AND_AND_SKIPZ: - case EC_AND_AND_SKIPZ2: - case EC_AND_AND_SKIPNZ: - case EC_AND_AND_SKIPNZ2: - case EC_OR_OR_SKIPZ: - case EC_OR_OR_SKIPZ2: - case EC_OR_OR_SKIPNZ: - case EC_OR_OR_SKIPNZ2: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_LEAVE: - case EC_RET: - if (fun_class && (tempi1=last_with_class)) { - if (fun_class->return_class->sub_type==IT_DOUBLE && - tempi1->ic_class->sub_type!=IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_DOUBLE; - if (fun_class->return_class->sub_type!=IT_DOUBLE && - tempi1->ic_class->sub_type==IT_DOUBLE) - tempi1->ic_flags|=ICF_TO_INT; - } - break; - - case EC_NULL: - case EC_LABEL: - case EC_ADDRESS: - case EC_QUESTION: - case EC_JMP: - case EC_IRQ: - case EC_NOP: - break; - - case EC_END_EXP: - ps->ptr--; - break; - - default: - OptMissing(l,2,tempi); - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_EBP) { - temp_lag[1]->ic_flags|=temp_lag[2]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_LEA_DISP32_EBP; - for (i=0;iic_data) - lea_s[i]++; - } - } - if (tempi->ic_class) - last_with_class=tempi; - tempi+=sizeof(IntermediateCode); - } - j=0; - if (fun_class && !Bt(&l->flags,LFf_NO_REG_VAR)) { - for (i=0;iESI_offset=o[0]; - l->EDI_offset=o[1]; - } else { - l->ESI_offset=MAX_I8; - l->EDI_offset=MAX_I8; - } - OptEnd(l,2,ps); -} - - -void CmpOptPass3(LexStruct *l,ClassStruct *fun_class) -{ //Reg optimization - I8 i1; - IntermediateCode *tempi,*tempi1,*tempi2, - *temp_lag[4]; - ClassStruct *tempc,*tempc2; - ParseStack *ps; - fun_class; //no unused warning - - if (l->flags & LF_NO_REG_OPT) - return; - - ps=OptStart(l,temp_lag); - tempi=l->cb.cb_in_ptr; - while (tempi->ic_code.u2[0]) { - OptNext(tempi,temp_lag); - switch (tempi->ic_code.u2[0]) { - case EC_U8: - case EC_U4: - PrsPush(ps,tempi); - break; - case EC_U2: //doesn't occur - case EC_U1: //doesn't occur - case EC_DOUBLE: - case EC_STRING_CONSTANT: - case EC_EBP: - case EC_FS: - PrsPush(ps,tempi); - break; - case EC_LEA_DISP32_EBP: - PrsPush(ps,tempi); - break; - case EC_COM: - case EC_NOT: - case EC_UNARY_MINUS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_U4_DISP32: - if (tempi->ic_data==l->ESI_offset) - tempi->ic_code=EC_ESI; - else if (tempi->ic_data==l->EDI_offset) - tempi->ic_code=EC_EDI; - PrsPush(ps,tempi); - break; - case EC_U8_DISP32: - case EC_U2_DISP32: - case EC_U1_DISP32: - PrsPush(ps,tempi); - break; - case EC_U8_DISP32_SCALED: - case EC_U4_DISP32_SCALED: - case EC_U2_DISP32_SCALED: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_FS_U8_DISP32: - case EC_FS_U4_DISP32: - case EC_FS_U2_DISP32: - case EC_FS_U1_DISP32: - PrsPush(ps,tempi); - break; - case EC_DEREF_U8: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_DEREF_U8; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_DEREF_U8; - } - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_ESI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_ESI_U8_DISP32; - } - if (temp_lag[2]->ic_code.u2[0]==EC_EDI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_EDI_U8_DISP32; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U4: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_DEREF_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_DEREF_U4; - } - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_ESI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_ESI_U4_DISP32; - } - if (temp_lag[2]->ic_code.u2[0]==EC_EDI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_EDI_U4_DISP32; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U2: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_DEREF_U2; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_DEREF_U2; - } - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_ESI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_ESI_U2_DISP32; - } - if (temp_lag[2]->ic_code.u2[0]==EC_EDI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_EDI_U2_DISP32; - } - } - PrsPush(ps,tempi); - break; - case EC_DEREF_U1: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_DEREF_U1; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_DEREF_U1; - } - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_ESI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_ESI_U1_DISP32; - } - if (temp_lag[2]->ic_code.u2[0]==EC_EDI) { - tempi->ic_flags|=temp_lag[2]->ic_flags|temp_lag[1]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_NOP; - tempi->ic_data=temp_lag[1]->ic_data; - tempi->ic_code=EC_EDI_U1_DISP32; - } - } - PrsPush(ps,tempi); - break; - case EC_U4_PP: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_U4_PP; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_U4_PP; - } - } - PrsPush(ps,tempi); - break; - case EC_U4_MM: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_U4_MM; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_U4_MM; - } - } - PrsPush(ps,tempi); - break; - case EC_PP_U4: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_PP_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_PP_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_MM_U4: - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_MM_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags & ~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_MM_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_U8_PP: - case EC_U2_PP: - case EC_U1_PP: - case EC_U8_MM: - case EC_U2_MM: - case EC_U1_MM: - case EC_PP_U8: - case EC_PP_U2: - case EC_PP_U1: - case EC_MM_U8: - case EC_MM_U2: - case EC_MM_U1: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_POWER: - case EC_SHL: - case EC_SHR: - case EC_MULTIPLICATION: - case EC_DIVISION: - case EC_REMAINDER: - case EC_AND: - case EC_OR: - case EC_XOR: - case EC_ADDITION: - case EC_SUBTRACTION: - case EC_EQUAL_EQUAL: - case EC_NOT_EQUAL_TO: - case EC_LESS_THAN: - case EC_GREATER_THAN: - case EC_LESS_OR_EQUAL: - case EC_GREATER_OR_EQUAL: - case EC_AND_AND: - case EC_OR_OR: - case EC_XOR_XOR: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_COLON: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - case EC_ASSIGN_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_ASSIGN_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_ASSIGN_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_SHL_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_SHL_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_SHL_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_SHR_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_SHR_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_SHR_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_MUL_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_MUL_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_MUL_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_DIV_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_DIV_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_DIV_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_AND_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_AND_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_AND_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_OR_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_OR_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_OR_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_XOR_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_XOR_EQUAL_U4; - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_XOR_EQUAL_U4; - } - } - PrsPush(ps,tempi); - break; - case EC_ADD_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - i1=tempi2->ic_data; - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_ADD_EQUAL_U4; - if (tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_ESI_ADD_EQUAL_U4_CONSTANT_U1; - } - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_ADD_EQUAL_U4; - if (tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_EDI_ADD_EQUAL_U4_CONSTANT_U1; - } - } - } - if (tempi->ic_code.u2[0]==EC_ADD_EQUAL_U4 && - tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_ADD_EQUAL_U4_CONSTANT_U1; - } - PrsPush(ps,tempi); - break; - case EC_SUB_EQUAL_U4: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - i1=-tempi2->ic_data; - if (tempi1->ic_code.u2[0]==EC_LEA_DISP32_EBP) { - if (tempi1->ic_data==l->ESI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_ESI_SUB_EQUAL_U4; - if (tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_ESI_ADD_EQUAL_U4_CONSTANT_U1; - } - } else if (tempi1->ic_data==l->EDI_offset) { - tempi->ic_flags|=(tempi1->ic_flags&~ICF_NO_PUSHES); - tempi1->ic_code=EC_NOP; - ShiftNoPush(tempi1); - tempi->ic_code=EC_EDI_SUB_EQUAL_U4; - if (tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_EDI_ADD_EQUAL_U4_CONSTANT_U1; - } - } - } - if (tempi->ic_code.u2[0]==EC_SUB_EQUAL_U4 && - tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_ADD_EQUAL_U4_CONSTANT_U1; - } - PrsPush(ps,tempi); - break; - case EC_ASSIGN_U8: - case EC_ASSIGN_U2: - case EC_ASSIGN_U1: - case EC_SHL_EQUAL_U8: - case EC_SHL_EQUAL_U2: - case EC_SHL_EQUAL_U1: - case EC_SHR_EQUAL_U8: - case EC_SHR_EQUAL_U2: - case EC_SHR_EQUAL_U1: - case EC_MUL_EQUAL_U8: - case EC_MUL_EQUAL_U2: - case EC_MUL_EQUAL_U1: - case EC_DIV_EQUAL_U8: - case EC_DIV_EQUAL_U2: - case EC_DIV_EQUAL_U1: - case EC_AND_EQUAL_U8: - case EC_AND_EQUAL_U2: - case EC_AND_EQUAL_U1: - case EC_OR_EQUAL_U8: - case EC_OR_EQUAL_U2: - case EC_OR_EQUAL_U1: - case EC_XOR_EQUAL_U8: - case EC_XOR_EQUAL_U2: - case EC_XOR_EQUAL_U1: - case EC_ADD_EQUAL_U2: - case EC_ADD_EQUAL_U1: - case EC_SUB_EQUAL_U2: - case EC_SUB_EQUAL_U1: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - - case EC_ADD_EQUAL_U8: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - i1=tempi2->ic_data; - tempc=tempi->ic_class; - tempc2=tempi2->ic_class; - if (tempc->sub_type!=IT_DOUBLE && - tempc2->sub_type!=IT_DOUBLE && - tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_ADD_EQUAL_U8_CONSTANT_U1; - } - PrsPush(ps,tempi); - break; - - case EC_SUB_EQUAL_U8: - tempi2=PrsPop(ps); - tempi1=PrsPop(ps); - i1=tempi2->ic_data; - tempc=tempi->ic_class; - tempc2=tempi2->ic_class; - if (tempc->sub_type!=IT_DOUBLE && - tempc2->sub_type!=IT_DOUBLE && - tempi2->ic_code.u2[0]==EC_U8 && - i1>=-128 && i1<=127) { - tempi2->ic_code=EC_NOP; - tempi->ic_flags|=tempi2->ic_flags; - tempi->ic_data=i1; - tempi->ic_code=EC_SUB_EQUAL_U8_CONSTANT_U1; - } - PrsPush(ps,tempi); - break; - - case EC_SHL_CONSTANT1: - case EC_SHL_CONSTANT2: - case EC_SHR_CONSTANT1: - case EC_SHR_CONSTANT2: - case EC_ADD64: - case EC_ADD32: - case EC_SUB64: - case EC_SUB32: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_ENTER: - if (l->EDI_offset!=MAX_I8) - tempi->ic_code=EC_ENTER2; - else if (l->ESI_offset!=MAX_I8) - tempi->ic_code=EC_ENTER1; - break; - case EC_LEAVE: - if (l->EDI_offset!=MAX_I8) - tempi->ic_code=EC_LEAVE2; - else if (l->ESI_offset!=MAX_I8) - tempi->ic_code=EC_LEAVE1; - break; - case EC_ADD_ESP32: - i1=tempi->ic_data; - ps->ptr-=1+i1>>3; - PrsPush(ps,tempi); - break; - case EC_CALL: - case EC_CALL_INDIRECT: - case EC_CALL_INDIRECT2: - PrsPush(ps,tempi); - break; - case EC_IRQ: - break; - case EC_CLI: - case EC_STI: - case EC_GET_FLAGS: - PrsPush(ps,tempi); - break; - case EC_SET_FLAGS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_BASE_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_BASE_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_STACK_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_STACK_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_LABEL: - case EC_ABSOLUTE_ADDRESS: - PrsPush(ps,tempi); - break; - case EC_TYPE: - PrsPush(ps,tempi); - break; - case EC_BT: - case EC_BTS: - case EC_BTR: - case EC_BTC: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_BSF: - case EC_BSR: - case EC_BT_CONSTANT: - case EC_BTS_CONSTANT: - case EC_BTR_CONSTANT: - case EC_BTC_CONSTANT: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_INSQUE: - case EC_INSQUE_REV: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_REMQUE: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_MEMCPY: - case EC_MEMSET: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - case EC_INPD: - case EC_INPW: - case EC_INP: - case EC_STRLEN: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_OUTPD: - case EC_OUTPW: - case EC_OUTP: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_JMP: - case EC_SHORT_JMP: - break; - case EC_SWITCH: - ps->ptr-=2; - break; - case EC_SKIPZ: - case EC_SKIPZ2: - case EC_SKIPNZ: - case EC_SKIPNZ2: //not present yet - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_EQUAL_EQUAL_SKIPZ: - case EC_EQUAL_EQUAL_SKIPZ2: - case EC_NOT_EQUAL_TO_SKIPZ: - case EC_NOT_EQUAL_TO_SKIPZ2: - case EC_LESS_THAN_SKIPZ: - case EC_LESS_THAN_SKIPZ2: - case EC_GREATER_THAN_SKIPZ: - case EC_GREATER_THAN_SKIPZ2: - case EC_LESS_OR_EQUAL_SKIPZ: - case EC_LESS_OR_EQUAL_SKIPZ2: - case EC_GREATER_OR_EQUAL_SKIPZ: - case EC_GREATER_OR_EQUAL_SKIPZ2: - case EC_AND_AND_SKIPZ: - case EC_AND_AND_SKIPZ2: - case EC_AND_AND_SKIPNZ: - case EC_AND_AND_SKIPNZ2: - case EC_OR_OR_SKIPZ: - case EC_OR_OR_SKIPZ2: - case EC_OR_OR_SKIPNZ: - case EC_OR_OR_SKIPNZ2: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - - case EC_NULL: - case EC_LABEL: - case EC_ADDRESS: - case EC_QUESTION: - case EC_JMP: - case EC_IRQ: - case EC_NOP: - case EC_RET: - break; - - case EC_END_EXP: - ps->ptr--; - break; - - default: - OptMissing(l,3,tempi); - } - if (temp_lag[1]->ic_code.u2[0]==EC_ADD32) { - if (temp_lag[2]->ic_code.u2[0]==EC_ESI) { - temp_lag[1]->ic_flags|=temp_lag[2]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_LEA_DISP32_ESI; - } else if (temp_lag[2]->ic_code.u2[0]==EC_EDI) { - temp_lag[1]->ic_flags|=temp_lag[2]->ic_flags; - temp_lag[2]->ic_code=EC_NOP; - temp_lag[1]->ic_code=EC_LEA_DISP32_EDI; - } - } - tempi+=sizeof(IntermediateCode); - } - OptEnd(l,3,ps); -} - -void CmpOptPass4(LexStruct *l,ClassStruct *fun_class) -{ //adjust constants to smaller sizes - I8 i1,i; - IntermediateCode *tempi,*tempi1, - *temp_lag[4]; - ClassStruct *tempc; - ParseStack *ps=OptStart(l,temp_lag); - - fun_class; //no unused warning - tempi=l->cb.cb_in_ptr; - while (tempi->ic_code.u2[0]) { - OptNext(tempi,temp_lag); - switch (tempi->ic_code.u2[0]) { - case EC_U8: - if (!(tempi->ic_data&0xFFFFFFFF00000000)) { - if (!tempi->ic_data) - tempi->ic_code=EC_ZERO; - else if (tempi->ic_data<=127) { - tempc=tempi->ic_class; - if (!(tempc->sub_type&1)) - tempi->ic_class=sys_internal_types[tempc->sub_type+1]; - tempi->ic_code=EC_U1; - } else { - tempc=tempi->ic_class; - if (!(tempc->sub_type&1)) - tempi->ic_class=sys_internal_types[tempc->sub_type+1]; - tempi->ic_code=EC_U4; - } - } else if (tempi->ic_data&0xFFFFFFFF80000000==0xFFFFFFFF80000000) { - tempc=tempi->ic_class; - if (tempc->sub_type&1) - tempi->ic_class=sys_internal_types[tempc->sub_type-1]; - tempi->ic_code=EC_U4; - } - PrsPush(ps,tempi); - break; - case EC_U4: - if (!tempi->ic_data) - tempi->ic_code=EC_ZERO; - else if (tempi->ic_data<=127) { - tempc=tempi->ic_class; - if (!(tempc->sub_type&1)) - tempi->ic_class=sys_internal_types[tempc->sub_type+1]; - tempi->ic_code=EC_U1; - } - PrsPush(ps,tempi); - break; - case EC_U2: //doesn't occur - case EC_U1: //doesn't occur - case EC_DOUBLE: - case EC_STRING_CONSTANT: - case EC_EBP: - case EC_FS: - case EC_ESI: - case EC_EDI: - PrsPush(ps,tempi); - break; - case EC_LEA_DISP32_EBP: - i1=tempi->ic_data; - if (i1>=-128 && i1<=127) - tempi->ic_code=EC_LEA_DISP8_EBP; - PrsPush(ps,tempi); - break; - case EC_LEA_DISP32_ESI: - i1=tempi->ic_data; - if (i1>=-128 && i1<=127) - tempi->ic_code=EC_LEA_DISP8_ESI; - PrsPush(ps,tempi); - break; - case EC_LEA_DISP32_EDI: - i1=tempi->ic_data; - if (i1>=-128 && i1<=127) - tempi->ic_code=EC_LEA_DISP8_EDI; - PrsPush(ps,tempi); - break; - case EC_COM: - case EC_NOT: - case EC_UNARY_MINUS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_U8_DISP32: - case EC_U4_DISP32: - case EC_U2_DISP32: - case EC_U1_DISP32: - case EC_ESI_U8_DISP32: - case EC_ESI_U4_DISP32: - case EC_ESI_U2_DISP32: - case EC_ESI_U1_DISP32: - case EC_EDI_U8_DISP32: - case EC_EDI_U4_DISP32: - case EC_EDI_U2_DISP32: - case EC_EDI_U1_DISP32: - i1=tempi->ic_data; - if (i1>=-128 && i1<=127) - tempi->ic_code+=EC_U8_DISP8-EC_U8_DISP32; - PrsPush(ps,tempi); - break; - case EC_U8_DISP32_SCALED: - case EC_U4_DISP32_SCALED: - case EC_U2_DISP32_SCALED: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_FS_U8_DISP32: - case EC_FS_U4_DISP32: - case EC_FS_U2_DISP32: - case EC_FS_U1_DISP32: - case EC_ESI_DEREF_U8: - case EC_ESI_DEREF_U4: - case EC_ESI_DEREF_U2: - case EC_ESI_DEREF_U1: - case EC_EDI_DEREF_U8: - case EC_EDI_DEREF_U4: - case EC_EDI_DEREF_U2: - case EC_EDI_DEREF_U1: - case EC_ESI_U4_PP: - case EC_ESI_U4_MM: - case EC_ESI_PP_U4: - case EC_ESI_MM_U4: - case EC_EDI_U4_PP: - case EC_EDI_U4_MM: - case EC_EDI_PP_U4: - case EC_EDI_MM_U4: - PrsPush(ps,tempi); - break; - case EC_DEREF_U8: - case EC_DEREF_U4: - case EC_DEREF_U2: - case EC_DEREF_U1: - case EC_U8_PP: - case EC_U4_PP: - case EC_U2_PP: - case EC_U1_PP: - case EC_U8_MM: - case EC_U4_MM: - case EC_U2_MM: - case EC_U1_MM: - case EC_PP_U8: - case EC_PP_U4: - case EC_PP_U2: - case EC_PP_U1: - case EC_MM_U8: - case EC_MM_U4: - case EC_MM_U2: - case EC_MM_U1: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_POWER: - case EC_SHL: - case EC_SHR: - case EC_MULTIPLICATION: - case EC_DIVISION: - case EC_REMAINDER: - case EC_AND: - case EC_OR: - case EC_XOR: - case EC_ADDITION: - case EC_SUBTRACTION: - case EC_EQUAL_EQUAL: - case EC_NOT_EQUAL_TO: - case EC_LESS_THAN: - case EC_GREATER_THAN: - case EC_LESS_OR_EQUAL: - case EC_GREATER_OR_EQUAL: - case EC_AND_AND: - case EC_OR_OR: - case EC_XOR_XOR: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_COLON: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - case EC_ESI_ASSIGN_U4: - ps->ptr--; - if (temp_lag[1]->ic_code.u2[0]==EC_DEREF_U4 && - temp_lag[2]->ic_code.u2[0]==EC_ESI) { - temp_lag[1]->ic_code=EC_NOP; - temp_lag[2]->ic_code=EC_NOP; - tempi->ic_flags|=temp_lag[2]->ic_flags; - tempi->ic_code=EC_ESI_NEXT_EQUAL_U4; - } - PrsPush(ps,tempi); - break; - case EC_EDI_ASSIGN_U4: - ps->ptr--; - if (temp_lag[1]->ic_code.u2[0]==EC_DEREF_U4 && - temp_lag[2]->ic_code.u2[0]==EC_EDI) { - temp_lag[1]->ic_code=EC_NOP; - temp_lag[2]->ic_code=EC_NOP; - tempi->ic_flags|=temp_lag[2]->ic_flags; - tempi->ic_code=EC_EDI_NEXT_EQUAL_U4; - } - PrsPush(ps,tempi); - break; - case EC_ADD_EQUAL_U8_CONSTANT_U1: - case EC_SUB_EQUAL_U8_CONSTANT_U1: - case EC_ADD_EQUAL_U4_CONSTANT_U1: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_ESI_ADD_EQUAL_U4_CONSTANT_U1: - case EC_EDI_ADD_EQUAL_U4_CONSTANT_U1: - PrsPush(ps,tempi); - break; - - case EC_ESI_SHL_EQUAL_U4: - case EC_ESI_SHR_EQUAL_U4: - case EC_ESI_MUL_EQUAL_U4: - case EC_ESI_DIV_EQUAL_U4: - case EC_ESI_AND_EQUAL_U4: - case EC_ESI_OR_EQUAL_U4: - case EC_ESI_XOR_EQUAL_U4: - case EC_ESI_ADD_EQUAL_U4: - case EC_ESI_SUB_EQUAL_U4: - - case EC_EDI_SHL_EQUAL_U4: - case EC_EDI_SHR_EQUAL_U4: - case EC_EDI_MUL_EQUAL_U4: - case EC_EDI_DIV_EQUAL_U4: - case EC_EDI_AND_EQUAL_U4: - case EC_EDI_OR_EQUAL_U4: - case EC_EDI_XOR_EQUAL_U4: - case EC_EDI_ADD_EQUAL_U4: - case EC_EDI_SUB_EQUAL_U4: - ps->ptr--; - PrsPush(ps,tempi); - break; - - case EC_ASSIGN_U8: - case EC_ASSIGN_U4: - case EC_ASSIGN_U2: - case EC_ASSIGN_U1: - case EC_SHL_EQUAL_U8: - case EC_SHL_EQUAL_U4: - case EC_SHL_EQUAL_U2: - case EC_SHL_EQUAL_U1: - case EC_SHR_EQUAL_U8: - case EC_SHR_EQUAL_U4: - case EC_SHR_EQUAL_U2: - case EC_SHR_EQUAL_U1: - case EC_MUL_EQUAL_U8: - case EC_MUL_EQUAL_U4: - case EC_MUL_EQUAL_U2: - case EC_MUL_EQUAL_U1: - case EC_DIV_EQUAL_U8: - case EC_DIV_EQUAL_U4: - case EC_DIV_EQUAL_U2: - case EC_DIV_EQUAL_U1: - case EC_AND_EQUAL_U8: - case EC_AND_EQUAL_U4: - case EC_AND_EQUAL_U2: - case EC_AND_EQUAL_U1: - case EC_OR_EQUAL_U8: - case EC_OR_EQUAL_U4: - case EC_OR_EQUAL_U2: - case EC_OR_EQUAL_U1: - case EC_XOR_EQUAL_U8: - case EC_XOR_EQUAL_U4: - case EC_XOR_EQUAL_U2: - case EC_XOR_EQUAL_U1: - case EC_ADD_EQUAL_U8: - case EC_ADD_EQUAL_U4: - case EC_ADD_EQUAL_U2: - case EC_ADD_EQUAL_U1: - case EC_SUB_EQUAL_U8: - case EC_SUB_EQUAL_U4: - case EC_SUB_EQUAL_U2: - case EC_SUB_EQUAL_U1: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_SHL_CONSTANT1: - case EC_SHL_CONSTANT2: - case EC_SHR_CONSTANT1: - case EC_SHR_CONSTANT2: - case EC_ADD64: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_ADD32: - tempi1=PrsPop(ps); - if (!(i1=tempi->ic_data)) { - tempi1->ic_class=tempi->ic_class; - tempi1->ic_flags|=tempi->ic_flags; - tempi->ic_code=EC_NOP; - PrsPush(ps,tempi1); - } else { - if (i1==1) - tempi->ic_code=EC_INC; - else if (i1==-1) - tempi->ic_code=EC_DEC; - else if (i1>=-128 && i1<=127) - tempi->ic_code=EC_ADD8; - PrsPush(ps,tempi); - } - break; - case EC_SUB64: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_SUB32: - tempi1=PrsPop(ps); - if (!(i1=tempi->ic_data)) { - tempi1->ic_class=tempi->ic_class; - tempi1->ic_flags|=tempi->ic_flags; - tempi->ic_code=EC_NOP; - PrsPush(ps,tempi1); - } else { - if (i1==1) - tempi->ic_code=EC_DEC; - else if (i1==-1) - tempi->ic_code=EC_INC; - else if (i1>=-128 && i1<=127) - tempi->ic_code=EC_SUB8; - PrsPush(ps,tempi); - } - break; - case EC_ENTER: - case EC_ENTER1: - case EC_ENTER2: - break; - case EC_LEAVE: - if (temp_lag[1]->ic_code.u2[0]==EC_ADD_ESP32 || - temp_lag[1]->ic_code.u2[0]==EC_ADD_ESP8) { - tempi->ic_data+=temp_lag[1]->ic_data; - tempi->ic_flags|=temp_lag[1]->ic_flags; - temp_lag[1]->ic_code=EC_NOP; - } - break; - case EC_LEAVE1: - case EC_LEAVE2: - break; - case EC_ADD_ESP32: - i1=tempi->ic_data; - ps->ptr-=1+i1>>3; - if (i1>=-128 && i1<=127) { - if (!i1) { - temp_lag[1]->ic_flags|=tempi->ic_flags; - tempi->ic_code=EC_NOP; - } else - tempi->ic_code=EC_ADD_ESP8; - } - PrsPush(ps,tempi); - break; - case EC_CALL: - case EC_CALL_INDIRECT: - case EC_CALL_INDIRECT2: - PrsPush(ps,tempi); - break; - case EC_IRQ: - break; - case EC_CLI: - case EC_STI: - case EC_GET_FLAGS: - PrsPush(ps,tempi); - break; - case EC_SET_FLAGS: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_BASE_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_BASE_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_STACK_PTR: - PrsPush(ps,tempi); - break; - case EC_SET_STACK_PTR: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_GET_LABEL: - case EC_ABSOLUTE_ADDRESS: - PrsPush(ps,tempi); - break; - case EC_TYPE: - PrsPush(ps,tempi); - break; - case EC_BT: - case EC_BTS: - case EC_BTR: - case EC_BTC: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_BSF: - case EC_BSR: - case EC_BT_CONSTANT: - case EC_BTS_CONSTANT: - case EC_BTR_CONSTANT: - case EC_BTC_CONSTANT: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_INSQUE: - case EC_INSQUE_REV: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_REMQUE: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_MEMCPY: - case EC_MEMSET: - ps->ptr-=3; - PrsPush(ps,tempi); - break; - case EC_INPD: - case EC_INPW: - case EC_INP: - case EC_STRLEN: - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_OUTPD: - case EC_OUTPW: - case EC_OUTP: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - case EC_JMP: - case EC_SHORT_JMP: - break; - case EC_SWITCH: - ps->ptr-=2; - break; - case EC_SKIPZ: - case EC_SKIPZ2: - case EC_SKIPNZ: - case EC_SKIPNZ2: //not present yet - ps->ptr--; - PrsPush(ps,tempi); - break; - case EC_EQUAL_EQUAL_SKIPZ: - case EC_EQUAL_EQUAL_SKIPZ2: - case EC_NOT_EQUAL_TO_SKIPZ: - case EC_NOT_EQUAL_TO_SKIPZ2: - case EC_LESS_THAN_SKIPZ: - case EC_LESS_THAN_SKIPZ2: - case EC_GREATER_THAN_SKIPZ: - case EC_GREATER_THAN_SKIPZ2: - case EC_LESS_OR_EQUAL_SKIPZ: - case EC_LESS_OR_EQUAL_SKIPZ2: - case EC_GREATER_OR_EQUAL_SKIPZ: - case EC_GREATER_OR_EQUAL_SKIPZ2: - case EC_AND_AND_SKIPZ: - case EC_AND_AND_SKIPZ2: - case EC_AND_AND_SKIPNZ: - case EC_AND_AND_SKIPNZ2: - case EC_OR_OR_SKIPZ: - case EC_OR_OR_SKIPZ2: - case EC_OR_OR_SKIPNZ: - case EC_OR_OR_SKIPNZ2: - ps->ptr-=2; - PrsPush(ps,tempi); - break; - - case EC_NULL: - case EC_LABEL: - case EC_ADDRESS: - case EC_QUESTION: - case EC_JMP: - case EC_IRQ: - case EC_NOP: - case EC_RET: - break; - - case EC_END_EXP: - ps->ptr--; - break; - - default: - OptMissing(l,4,tempi); - } - if (Bt(push_bitmap,tempi->ic_code.u2[0]) && !(tempi->ic_flags & ICF_NO_PUSHES)) { - tempi1=temp_lag[1]; - i=push_map[tempi1->ic_code.u2[0]]; - i1=tempi1->ic_data; - tempc=tempi1->ic_class; - switch (i) { - case EC_PUSH_U4: - if (!(tempc->sub_type&1) && i1<0) - i=EC_PUSH_NEG_U4; - break; - case EC_PUSH_U2: - if (!(tempc->sub_type&1) && i1<0) - i=EC_PUSH_NEG_U2; - break; - case EC_PUSH_U1: - if (i1<-0x80 || i1>0x7F) { - i=EC_PUSH_U2; - if (!(tempc->sub_type&1) && i1<0) - i=EC_PUSH_NEG_U2; - } else { - if (!(tempc->sub_type&1) && i1<0) - i=EC_PUSH_NEG_U1; - } - break; - } - if (i) { - tempi1->ic_code=i; - if (!(tempi1->ic_flags & (ICF_TO_DOUBLE|ICF_TO_INT)) ) - tempi->ic_flags|=ICF_NO_PUSHES; - else - tempi1->ic_flags|=ICF_NO_PUSHES_TO_DOUBLE_OR_INT; - } - } - tempi+=sizeof(IntermediateCode); - } - OptEnd(l,4,ps); -} - \ No newline at end of file diff --git a/LT/COMPILE/PARSE.CPZ b/LT/COMPILE/PARSE.CPZ deleted file mode 100644 index 78a484e..0000000 --- a/LT/COMPILE/PARSE.CPZ +++ /dev/null @@ -1,773 +0,0 @@ -/* -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; -} diff --git a/LT/COMPILE/Test.CPZ b/LT/COMPILE/Test.CPZ deleted file mode 100644 index 7f135e7..0000000 --- a/LT/COMPILE/Test.CPZ +++ /dev/null @@ -1,34 +0,0 @@ -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; - } -} - diff --git a/LT/COMPILE/Test2.CPZ b/LT/COMPILE/Test2.CPZ deleted file mode 100644 index 3bb2e4a..0000000 Binary files a/LT/COMPILE/Test2.CPZ and /dev/null differ diff --git a/LT/Compiler/AsmMain.CPZ b/LT/Compiler/AsmMain.CPZ new file mode 100644 index 0000000..a72a107 --- /dev/null +++ b/LT/Compiler/AsmMain.CPZ @@ -0,0 +1,1655 @@ +ClassStruct *CmpClassNew() +{ + ClassStruct *result=MAllocZ(sizeof(ClassStruct)*5), + *tempc=result; + tempc->last_in_member_list=&tempc->member_list; + tempc->type=HTT_CLASS; + tempc->sub_type=IT_PTR; + tempc->ptr_cnt=0; + + tempc+=sizeof(ClassStruct); + tempc->type=HTT_CLASS; + tempc->sub_type=IT_PTR; + tempc->size=sizeof(void *); + tempc->ptr_cnt=1; + + tempc+=sizeof(ClassStruct); + tempc->type=HTT_CLASS; + tempc->sub_type=IT_PTR; + tempc->size=sizeof(void *); + tempc->ptr_cnt=2; + + tempc+=sizeof(ClassStruct); + tempc->type=HTT_CLASS; + tempc->sub_type=IT_PTR; + tempc->size=sizeof(void *); + tempc->ptr_cnt=3; + + tempc+=sizeof(ClassStruct); + tempc->type=HTT_CLASS; + tempc->sub_type=IT_PTR; + tempc->size=sizeof(void *); + tempc->ptr_cnt=4; + + return result; +} + +void AddUnresolved(AsmCtrlStruct *a,U1 *exp,I8 type,U8 ip,U8 rel_ip, + LexUndefEntry *undef_hash,I8 line_num,BoolU4 U1_avail,BoolU4 glbl) +{ + AsmUnresolvedRef *tempu=MAlloc(sizeof(AsmUnresolvedRef)); + tempu->exp=exp; + tempu->type=type; + tempu->ip=ip; + tempu->rel_ip=rel_ip; + tempu->undef_hash=undef_hash; + tempu->literal=FALSE; + tempu->line_num=line_num; + tempu->U1_avail=U1_avail; + tempu->str=NULL; + if (glbl) { + tempu->next=a->glbl_unresolved; + a->glbl_unresolved=tempu; + if (undef_hash->hash->type & HTT_IMPORT) { + tempu->str=NewStr(undef_hash->hash->str); + if (undef_hash->hash->type & HTT_LITERAL) + tempu->literal=TRUE; + } + } else { + tempu->next=a->local_unresolved; + a->local_unresolved=tempu; + a->has_locals=TRUE; + } +} + +void AsmListLine(LexStruct *lx) +{ + I8 i; + AsmCtrlStruct *a=lx->a; + LexFileStruct *tempf=lx->cur_lfn; + LtfEntry *cl=tempf->line_start,*cl3; + if (a->list && a->last_lfn==tempf && cl) { + if (cl3=a->last_line_listed) { + while (cl3->yy) { + for (i=a->display_col;i<8;i++) + cout " "; + a->display_col=0; + PrintF("%08X ",a->last_ip); + cl3=LexPutLine(lx,cl3); + } + a->last_line_listed=cl3; + } else + a->last_line_listed=cl; + } else { + a->last_line_listed=NULL; + a->last_lfn=tempf; + } + a->last_ip=a->ip; +} + +void AsmStoreCodeU1(LexStruct *lx,U1 b) +{ + AsmCtrlStruct *a=lx->a; + I8 i=a->ip>>ASM_CODE_BLK_BITS; + AsmCodeBlk *tempc=a->code; + while (i--) + if (!(tempc=tempc->next)) { + i=a->ip>>ASM_CODE_BLK_BITS+1; + tempc=&a->code; + while (i--) { + if (!*tempc) + *tempc=MAllocZ(sizeof(AsmCodeBlk)); + tempc=tempc->next; + } + break; + } + tempc->body[a->ip++ & (ASM_CODE_BLK_SIZE-1)]=b; + if (a->list) { + PrintF("%02X ",b); + a->display_col++; + if (a->display_col>8) { + a->display_col=0; + AsmListLine(lx); + } + } + if (a->ip>a->num_code_U1s) + a->num_code_U1s=a->ip; +} + +void AsmStoreCodeU4(LexStruct *lx,U4 d) +{ + AsmCtrlStruct *a=lx->a; + I8 i=a->ip>>ASM_CODE_BLK_BITS, + j=(a->ip+sizeof(U4))>>ASM_CODE_BLK_BITS; + U4 *dd; + AsmCodeBlk *tempc=a->code; + if (i!=j) { + for (i=0;icode; + while (i--) + if (!(tempc=tempc->next)) { + i=a->ip>>ASM_CODE_BLK_BITS+1; + tempc=&a->code; + while (i--) { + if (!*tempc) + *tempc=MAllocZ(sizeof(AsmCodeBlk)); + tempc=tempc->next; + } + break; + } + dd=tempc->body+(a->ip&(ASM_CODE_BLK_SIZE-1)); + *dd=d; + a->ip+=sizeof(U4); + if (a->list) { + PrintF("%08X ",d); + a->display_col+=sizeof(U4); + if (a->display_col>8) { + a->display_col=0; + AsmListLine(lx); + } + } + if (a->ip>a->num_code_U1s) + a->num_code_U1s=a->ip; +} + +void AsmStoreCodeU8(LexStruct *lx,U8 d) +{ + AsmCtrlStruct *a=lx->a; + I8 i=a->ip>>ASM_CODE_BLK_BITS, + j=(a->ip+sizeof(U8))>>ASM_CODE_BLK_BITS; + U8 *dd; + AsmCodeBlk *tempc=a->code; + if (i!=j) { + for (i=0;icode; + while (i--) + if (!(tempc=tempc->next)) { + i=a->ip>>ASM_CODE_BLK_BITS+1; + tempc=&a->code; + while (i--) { + if (!*tempc) + *tempc=MAllocZ(sizeof(AsmCodeBlk)); + tempc=tempc->next; + } + break; + } + dd=tempc->body+(a->ip&(ASM_CODE_BLK_SIZE-1)); + *dd=d; + a->ip+=sizeof(U8); + if (a->list) { + PrintF("%016X ",d); + a->display_col+=sizeof(U8); + if (a->display_col>8) { + a->display_col=0; + AsmListLine(lx); + } + } + if (a->ip>a->num_code_U1s) + a->num_code_U1s=a->ip; +} + +void AsmStoreCodeU1At(LexStruct *lx,U1 b,I8 ip) +{ + AsmCtrlStruct *a=lx->a; + I8 i=ip>>ASM_CODE_BLK_BITS+1; + AsmCodeBlk *tempc=&a->code; + while (i--) { + if (!*tempc) { + *tempc=MAlloc(sizeof(AsmCodeBlk)); + **tempc=NULL; + } + tempc=tempc->next; + } + tempc->body[ip & (ASM_CODE_BLK_SIZE-1)]=b; + if (ip+1>a->num_code_U1s) + a->num_code_U1s=ip+1; +} + + +I8 AsmEvalExpression(LexStruct *lx) +{ + U1 *exp; + I8 result=0; + lx->undef_hash_entry=NULL; + lx->flags&=~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); + lx->absolute_address_cnt=0; + if (!GetExpression(lx,&exp)) + LexSkipEol(lx); + else { + if (!(lx->flags & (LF_UNRESOLVED_LOCAL|LF_UNRESOLVED_GLBL))) { + result=Call(exp); + DelExpression(exp); + } else + PutAsmError(lx,"ST_UNDEFINED_SYMBOL"); + } + return result; +} + +void ResolveLocals(LexStruct *lx) +{ + AsmCtrlStruct *a=lx->a; + AsmUnresolvedRef *tempu=a->local_unresolved,*tempu1; + I8 result=0; + LexUndefEntry *templu; + BoolU4 undefined; + I1 *label=NULL; + + if (!a->has_locals) + return; + while (tempu) { + undefined=FALSE; + tempu1=tempu->next; + templu=tempu->undef_hash; + while (templu) { + if (templu->hash->type & (HTT_UNRESOLVED_LOCAL | HTT_UNRESOLVED_GLBL)) { + PrintFErr("%S%S%04d ","ST_UNDEFINED_SYMBOL","ST_LINE",tempu->line_num); + if (a->last_label) cout a->last_label," "; + coutln templu->hash->str; + lx->error_cnt++; + undefined=TRUE; + } else + label=templu->hash->str; + templu=templu->next; + } + if (!undefined) { + result=Call(tempu->exp); + if (!(tempu->type & 1)) { + result-=tempu->rel_ip; + if (tempu->type==EIE_REL_U1 && (resultMAX_I1) || + tempu->type==EIE_REL_U2 && (resultMAX_I2) ) { + PrintFErr("%S%S%04d ","ST_BRANCH_OUT_OF_RANGE","ST_LINE",tempu->line_num); + if (a->last_label) + PrintF("%s ",a->last_label); + if (label) cout label; + CrLf; + lx->error_cnt++; + } + if (tempu->U1_avail && tempu->type>EIE_LIT_U1 && (result>=-124 && result<=123)) { + PrintFWarn("%S%S%04d ","ST_COULD_USE_U1_DISP","ST_LINE",tempu->line_num); + if (a->last_label) + PrintF("%s ",a->last_label); + if (label) cout label; + CrLf; + } + } + AsmStoreCodeU1At(lx,result.u1[0],tempu->ip); + if (tempu->type>=EIE_REL_U2) + AsmStoreCodeU1At(lx,result.u1[1],tempu->ip+1); + if (tempu->type>=EIE_REL_U4) { + AsmStoreCodeU1At(lx,result.u1[2],tempu->ip+2); + AsmStoreCodeU1At(lx,result.u1[3],tempu->ip+3); + } + } + DelExpression(tempu->exp); + DelLinkedList(tempu->undef_hash); + Free(tempu); + tempu=tempu1; + } + DelHashTable(a->local_hash); + a->local_hash=NewHashTable(16); + a->local_hash->next=a->glbl_hash; + lx->hash_table_list=a->local_hash; + lx->local_hash_table=a->local_hash; + a->local_unresolved=NULL; + a->has_locals=FALSE; +} + +void ResolveGlbls(LexStruct *lx,ExeStruct *e) +{ + AsmCtrlStruct *a=lx->a; + ClassStruct *tempc; + GlblVarStruct *tempg; + AsmUnresolvedRef *tempu=a->glbl_unresolved,*tempu1; + I8 result=0; + ExeImportExportStruct *tempe,*tempe1; + LexUndefEntry *templu; + I8 i,j; + SysHashEntry *temph; + I1 *label; + BoolU4 undefined; + ExternUsage *tempeu,*tempeu1; + + while (tempu) { + label=NULL; + undefined=FALSE; + tempu1=tempu->next; + templu=tempu->undef_hash; + while (templu) { + if (templu->hash->type & (HTT_UNRESOLVED_LOCAL | HTT_UNRESOLVED_GLBL)) { + if (!(templu->hash->type & HTT_IMPORT)) { + PrintFErr("%S%S%04d ","ST_UNDEFINED_SYMBOL","ST_LINE",tempu->line_num); + cout templu->hash->str,"\r\n"; + lx->error_cnt++; + } + undefined=TRUE; + } else + label=templu->hash->str; + templu=templu->next; + } + if (undefined) { + templu=tempu->undef_hash; + if (templu->hash->type & HTT_IMPORT) { + tempe=MAllocZ(sizeof(ExeImportExportStruct)); + tempe->next=templu->hash->user_data1; + tempe->str=NULL; + templu->hash->user_data1=tempe; + tempe->ip=tempu->ip; + tempe->type=tempu->type; + } + } else { + result=Call(tempu->exp); + if (!(tempu->type & 1)) { + result-=tempu->rel_ip; + if ((tempu->type==EIE_REL_U1 && (resultMAX_I1)) || + tempu->type==EIE_REL_U2 && (resultMAX_I2)) { + PrintFErr("%S%S%04d ","ST_BRANCH_OUT_OF_RANGE","ST_LINE",tempu->line_num); + if (label) cout label; + CrLf; + lx->error_cnt++; + } + if (tempu->U1_avail && tempu->type>EIE_LIT_U1 && (result>=-124 && result<=123)) { + PrintFWarn("%S%S%04d ","ST_COULD_USE_U1_DISP","ST_LINE",tempu->line_num); + if (a->last_label) + PrintF("%s ",a->last_label); + if (label) cout label; + CrLf; + } + } + AsmStoreCodeU1At(lx,result.u1[0],tempu->ip); + if (tempu->type>=EIE_REL_U2) + AsmStoreCodeU1At(lx,result.u1[1],tempu->ip+1); + if (tempu->type>=EIE_REL_U4) { + AsmStoreCodeU1At(lx,result.u1[2],tempu->ip+2); + AsmStoreCodeU1At(lx,result.u1[3],tempu->ip+3); + } + } + DelExpression(tempu->exp); + DelLinkedList(tempu->undef_hash); + Free(tempu); + tempu=tempu1; + } + + tempe1=&e->ie; + while (tempe1->next) + tempe1=tempe1->next; + + for (i=0;i<=a->glbl_hash->mask;i++) { + temph=a->glbl_hash->body[i]; + while (temph) { + if (temph->type & HTT_IMPORT && temph->use_cnt) { + if (temph->type & HTT_FUNCTION) { + tempe=MAllocZ(sizeof(ExeImportExportStruct)); + tempe->type=EIE_LIT_U4; + tempc=temph; + tempe->str=(tempc->import_name) ? + NewStr(tempc->import_name):NewStr(tempc->str); + tempe->ip=tempc->executable_address; + tempe1->next=tempe; + tempe1=tempe; + } else if (temph->type & HTT_GLBL_VAR) { + tempe=MAllocZ(sizeof(ExeImportExportStruct)); + tempe->type=EIE_LIT_U4; + tempg=temph; + if (tempg->import_name) + tempe->str=NewStr(tempg->import_name); + else + tempe->str=NewStr(tempg->str); + tempe->ip=tempg->data_address; + tempe1->next=tempe; + tempe1=tempe; + } else { + tempe=temph->user_data1; + if (tempe) { + tempe1->next=tempe; + tempe->str=NewStr(temph->str); + while (tempe1->next) + tempe1=tempe1->next; + } + } + } else if (temph->type & HTT_EXPORT) { + if (temph->type & HTT_UNRESOLVED_GLBL) { + PrintFErr("%S%s\r\n","ST_UNDEFINED_SYMBOL",temph->str); + lx->error_cnt++; + } else { + tempe=MAlloc(sizeof(ExeImportExportStruct)); + tempe->type=EIE_REL_EXPORT; + if (temph->type & HTT_FUNCTION) { + tempc=temph; + tempe->ip=tempc->executable_address; + tempeu=tempc->ext_list; + while (tempeu) { + tempeu1=tempeu->next; + j=tempc->executable_address-(tempeu->ip+4); + AsmStoreCodeU1At(lx,j.u1[0],tempeu->ip); + AsmStoreCodeU1At(lx,j.u1[1],tempeu->ip+1); + AsmStoreCodeU1At(lx,j.u1[2],tempeu->ip+2); + AsmStoreCodeU1At(lx,j.u1[3],tempeu->ip+3); + Free(tempeu); + tempeu=tempeu1; + } + } else if (temph->type & HTT_GLBL_VAR) { + tempg=temph; + tempe->ip=tempg->data_address; + } else + tempe->ip=temph->user_data0; + if (temph->type & HTT_LITERAL) + tempe->type++; + *tempe1=tempe; + tempe->next=NULL; + tempe1=tempe; + tempe->str=NewStr(temph->str); + } + } + temph=temph->next; + } + } +} + +BoolU8 ParseAsmImm(LexStruct *lx,AsmCtrlStruct *aa,AsmArgStruct *a,U8 ip) +{ + if (a->imm_or_off_present) { + PutAsmError(lx,"ST_ALREADY_ONE_IMMEDIATE"); + return FALSE; + } else { + a->imm_or_off_present=TRUE; + a->undef_local=NULL; + a->undef_glbl=NULL; + lx->instruction_pointer=ip; + lx->undef_hash_entry=NULL; + lx->absolute_address_cnt=0; + lx->flags&=~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); + if (!GetExpression(lx,&a->exp)) + LexSkipEol(lx); + else { + if (!(lx->flags & (LF_UNRESOLVED_LOCAL|LF_UNRESOLVED_GLBL))) { + a->imm=Call(a->exp); + a->undef_glbl=lx->undef_hash_entry; + lx->undef_hash_entry=NULL; + DelExpression(a->exp); + a->exp=NULL; + } else { + if (lx->flags & LF_UNRESOLVED_GLBL) { + a->undef_glbl=lx->undef_hash_entry; + lx->undef_hash_entry=NULL; + aa->has_locals=TRUE; + } else if (lx->flags & LF_UNRESOLVED_LOCAL) { + a->undef_local=lx->undef_hash_entry; + lx->undef_hash_entry=NULL; + } + } + } + } + return TRUE; +} + +void ParseAsmArg(LexStruct *lx,AsmCtrlStruct *aa,AsmArgStruct *a,U8 ip) +{ + I8 i,temp; + a->size=0; + a->absolute_address_cnt=0; + a->seg=16; + a->reg1=16; + a->reg2=16; + a->imm=0; + a->scale=1; + a->indirect=FALSE; + a->imm_or_off_present=FALSE; + a->undef_local=NULL; + a->undef_glbl=NULL; + a->just_seg=FALSE; + a->exp=NULL; + while (TRUE) { + if (lx->token==TK_IDENT) { + if (lx->hash_entry) { + if (lx->hash_entry->type==HTT_R8) { + a->size=1; + a->reg1=lx->hash_entry->user_data0; + Lex(lx); + return; + } else if (lx->hash_entry->type==HTT_R16) { + a->size=2; + a->reg1=lx->hash_entry->user_data0; + Lex(lx); + return; + } else if (lx->hash_entry->type==HTT_R32) { + a->size=4; + a->reg1=lx->hash_entry->user_data0; + Lex(lx); + return; + } else if (lx->hash_entry->type==HTT_R64) { + a->size=8; + a->reg1=lx->hash_entry->user_data0; + Lex(lx); + return; + } else if (lx->hash_entry->type==HTT_SEG) { + a->seg=lx->hash_entry->user_data0; + if (Lex(lx)!=':') { + a->just_seg=TRUE; + return; + } else + Lex(lx); //skip ":" + } else if (lx->hash_entry->type==HTT_KEYWORD) { + i=lx->hash_entry->user_data0; + if (i==AKW_U1) { + Lex(lx); //skip keyword + a->size=1; + } else if (i==AKW_U2) { + Lex(lx); //skip keyword + a->size=2; + } else if (i==AKW_U4) { + Lex(lx); //skip keyword + a->size=4; + } else if (i==AKW_U8) { + Lex(lx); //skip keyword + a->size=8; + } else { + PutAsmError(lx,"ST_SYNTAX_ERROR"); + return; + } + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + if (lx->token!='[') + return; + } + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + if (lx->token!='[') + return; + } + } else if (lx->token=='[') { + a->indirect=TRUE; + Lex(lx); // skip [ + while (lx->token && lx->token!=']') { + if (lx->token==TK_IDENT) { + if (lx->hash_entry) { + if (lx->hash_entry->type==HTT_R16 || + lx->hash_entry->type==HTT_R32 || + lx->hash_entry->type==HTT_R64) { + if (a->reg1==16) + a->reg1=lx->hash_entry->user_data0; + else + a->reg2=lx->hash_entry->user_data0; + Lex(lx); + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + } + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + } + } else if (lx->token=='*') { + if (Lex(lx)!=TK_INTEGER) + PutAsmError(lx,"ST_EXPECTING_SCALE_FACTOR"); + else { + a->scale=lx->cur_i; + Lex(lx); //skip scale + if (a->reg2!=16) { + temp=a->reg1; + a->reg1=a->reg2; + a->reg2=temp; + } + } + } else if (lx->token=='+') { + Lex(lx); //skip '+' + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + } + } + if (lx->token==']') { + Lex(lx); //skip ] + return; + } else + PutAsmError(lx,"ST_MISSING_RIGHT_BRACKET"); + } else { + ParseAsmImm(lx,aa,a,ip); + a->absolute_address_cnt=lx->absolute_address_cnt; + if (lx->token!='[') + return; + } + } +} + + +void AsmMakeArgMask(AsmArgStruct *a,U8 *mask) +{ + if (a->just_seg) { + switch (a->seg) { + case 0: *mask=1<size) { + case 0: *mask=0x3FF07FFFFE; break; + case 1: *mask=0x1110111112; break; + case 2: *mask=0x2220222224; break; + case 4: *mask=0x0440444448; break; + case 8: *mask=0x0880088880; break; + } + + if (a->reg1!=16 && a->imm_or_off_present && !a->imm) { + if (!a->undef_glbl && !a->undef_local) + a->imm_or_off_present=FALSE; //Zero displacement + } + + if (a->reg2!=16 || a->scale!=1) { + *mask&= 0x00000F0000; + return; + } + + if (a->indirect) { + if (a->imm_or_off_present) + *mask&=0x00FFFF0000; + else + *mask&=0x000FFF0000; + } else { + if (a->imm_or_off_present) + *mask&=0x000F80F0FE; + else + *mask&=0x3F0F8F0F00; + } + if (a->seg!=16) + *mask&= 0x00FFFF0000; + if (a->reg1==16) { + if (a->indirect) + *mask&=0x00FFFF0000; + else if (MIN_I1<=a->imm<=MAX_I1) + *mask&=0x000000F0FE; + else if (MIN_I1<=a->imm<=MAX_U1) + *mask&=0x000000E0FE; + else if (MIN_I2<=a->imm<=MAX_I2) + *mask&=0x000000E0EE; + else if (MIN_I2<=a->imm<=MAX_U2) + *mask&=0x000000C0EE; + else if (MIN_I4<=a->imm<=MAX_I4) + *mask&=0x000000C0CE; + else if (MIN_I4<=a->imm<=MAX_U4) + *mask&=0x00000080CE; + else + *mask&=0x000000808E; + } else + *mask&= 0x3F007F0F00; + if (a->reg1!=0) + *mask&= 0x30FFFFFFFF; + if (a->reg1!=1) + *mask&= 0x2FFFFFFFFF; + if (a->reg1!=2) + *mask&= 0x1FFFFFFFFF; +} + +BoolU8 AsmStoreNum(LexStruct *lx,AsmCtrlStruct *a,I8 num,BoolU4 is_question,I8 num_U1s,I8 cnt, + I8 num_ip_rel,I8 num_lit, + U1 *num_exp,LexUndefEntry *num_local_hash,LexUndefEntry *num_glbl_hash, + BoolU4 U1_avail,U8 abs_add_cnt) +{ + I8 i; + ExeAbsoluteAddressStruct *tempa; + if (!num_lit) + num-=num_ip_rel; + for (i=0;iip,num_ip_rel, + num_local_hash,LexLineNum(lx),U1_avail,FALSE); + else if (num_glbl_hash) + AddUnresolved(a,num_exp,EIE_REL_U1+num_lit,a->ip,num_ip_rel, + num_glbl_hash,LexLineNum(lx),U1_avail,TRUE); + else { + if (!num_lit && (numMAX_I1)) { +// LexPop(lx); + PutAsmError(lx,"ST_BRANCH_OUT_OF_RANGE"); + a->ip++; + return FALSE; + } + } + if (is_question) + a->ip++; + else + AsmStoreCodeU1(lx,num.u1[0]); + + } else if (num_U1s==2) { + if (num_local_hash) + AddUnresolved(a,num_exp,EIE_REL_U2+num_lit,a->ip,num_ip_rel, + num_local_hash,LexLineNum(lx),U1_avail,FALSE); + else if (num_glbl_hash) + AddUnresolved(a,num_exp,EIE_REL_U2+num_lit,a->ip,num_ip_rel, + num_glbl_hash,LexLineNum(lx),U1_avail,TRUE); + else { + if (!num_lit && (num MAX_I2)) { +// LexPop(lx); + PutAsmError(lx,"ST_BRANCH_OUT_OF_RANGE"); + a->ip+=2; + return FALSE; + } + } + if (is_question) + a->ip+=2; + else { + AsmStoreCodeU1(lx,num.u1[0]); + AsmStoreCodeU1(lx,num.u1[1]); + } + if (U1_avail && !num_local_hash && !num_glbl_hash && + !num_lit && num>=-124 && num<=123) { +// LexPop(lx); + PutAsmWarning(lx,"ST_COULD_USE_U1_DISP"); + return FALSE; + } + } else if (num_U1s==4) { + if (num_local_hash) + AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, + num_local_hash,LexLineNum(lx),U1_avail,FALSE); + else if (num_glbl_hash) + AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, + num_glbl_hash,LexLineNum(lx),U1_avail,TRUE); + if (num_lit && abs_add_cnt & 1) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=a->ip; + } + if (is_question) + a->ip+=sizeof(U4); + else + AsmStoreCodeU4(lx,num.u4[0]); + if (U1_avail && !num_local_hash && !num_glbl_hash && + !num_lit && num>=-124 && num<=123) { +// LexPop(lx); + PutAsmWarning(lx,"ST_COULD_USE_U1_DISP"); + return FALSE; + } + } else if (num_U1s==8) { +//dbgo + if (num_local_hash) + AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, + num_local_hash,LexLineNum(lx),U1_avail,FALSE); + else if (num_glbl_hash) + AddUnresolved(a,num_exp,EIE_REL_U4+num_lit,a->ip,num_ip_rel, + num_glbl_hash,LexLineNum(lx),U1_avail,TRUE); + if (num_lit && abs_add_cnt & 1) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=a->ip; + } + if (is_question) + a->ip+=sizeof(U8); + else + AsmStoreCodeU8(lx,num); + if (U1_avail && !num_local_hash && !num_glbl_hash && + !num_lit && num>=-124 && num<=123) { +// LexPop(lx); + PutAsmWarning(lx,"ST_COULD_USE_U1_DISP"); + return FALSE; + } + } + } + return TRUE; +} + + +BoolU8 AsmCodeInstruction(LexStruct *lx,AsmCtrlStruct *a, + OpcodeHashEntry *tempo,I8 argcnt) +{ + I8 i,j,a1,a2,om,seg; + U8 arg1mask,arg2mask; + AsmArgStruct *tempa1,*tempa2; + BoolU4 ModrM_complete,U1_avail=FALSE,found_second_possible=FALSE; + + I8 U1_cnt; + U1 last_opcode_U1; + InstructionEntry *tempi; + BoolU4 has_ModrM; + U1 ModrM; + BoolU4 has_SIB; + U1 SIB,REX; + BoolU4 has_address_prefix; + BoolU4 has_operand_prefix; + BoolU4 is_default; + I8 disp,disp_U1s,disp_ip_rel,disp_lit,disp_abs_cnt; + I8 imm, imm_U1s, imm_ip_rel, imm_lit,imm_abs_cnt; + U1 *disp_exp,*imm_exp; + LexUndefEntry *disp_local_hash,*disp_glbl_hash; + LexUndefEntry *imm_local_hash,*imm_glbl_hash; + + I8 best_U1_cnt=255; + U1 blast_opcode_U1; + InstructionEntry *btempi; + BoolU4 bhas_ModrM; + U1 bModrM; + BoolU4 bhas_SIB; + U1 bSIB,bREX; + BoolU4 bhas_address_prefix; + BoolU4 bhas_operand_prefix; + BoolU4 bis_default; + I8 bdisp,bdisp_U1s,bdisp_ip_rel,bdisp_lit,bdisp_abs_cnt; + I8 bimm, bimm_U1s, bimm_ip_rel, bimm_lit,bimm_abs_cnt; + U1 *bdisp_exp,*bimm_exp; + LexUndefEntry *bdisp_local_hash,*bdisp_glbl_hash; + LexUndefEntry *bimm_local_hash,*bimm_glbl_hash; + + + if (argcnt>0) + AsmMakeArgMask(&a->arg1,&arg1mask); + else + arg1mask=1; + if (argcnt>1) + AsmMakeArgMask(&a->arg2,&arg2mask); + else + arg2mask=1; + for (i=0;iinstruction_entry_cnt;i++) { + tempi=&tempo->ins[i]; + if (tempi->arg1==ARGT_REL8 || tempi->arg2==ARGT_REL8) + U1_avail=TRUE; + if (Bt(&arg1mask,tempi->arg1) && Bt(&arg2mask,tempi->arg2)) { + ModrM_complete=FALSE; + last_opcode_U1=0; + has_ModrM=FALSE; + ModrM=0; + has_SIB=FALSE; + SIB=0; + has_address_prefix=FALSE; + has_operand_prefix=FALSE; + is_default=(tempi->flags & IEF_DEFAULT) ? TRUE:FALSE; + if (a->seg_size==64) { + REX=0x40; + if (tempi->flags & IEF_48_REX) + REX=0x48; + else if (tempi->flags & IEF_NO_REX) + REX=0x00; + } else + REX=0x00; + disp=0; disp_U1s=0; disp_ip_rel=0; disp_lit=1; + imm=0; imm_U1s=0; imm_ip_rel=0; imm_lit=1; + disp_exp=NULL; imm_exp=NULL; + disp_local_hash=NULL; disp_glbl_hash=NULL; + disp_abs_cnt=0; + imm_local_hash=NULL; imm_glbl_hash=NULL; + imm_abs_cnt=0; + om=tempi->opcode_modifier; + a1=tempi->arg1; + a2=tempi->arg2; + tempa1=&a->arg1; + tempa2=&a->arg2; + last_opcode_U1=tempi->opcode[tempi->opcode_cnt-1]; + + if (tempi->slash_value<8) { + ModrM+=tempi->slash_value<<3; + has_ModrM=TRUE; + } + + if ((a->seg_size==16 && tempi->flags & IEF_OP_SIZE32) || + (a->seg_size!=16 && tempi->flags & IEF_OP_SIZE16)) + has_operand_prefix=TRUE; + + if (om==OM_IB) imm_U1s=1; + else if (om==OM_IW) imm_U1s=2; + else if (om==OM_ID) imm_U1s=4; + + if (om==OM_CB) { + imm_U1s=1; + imm_lit=0; + } else if (om==OM_CW) { + imm_U1s=2; + imm_lit=0; + } else if (om==OM_CD) { + imm_U1s=4; + imm_lit=0; + } + + if (argcnt==1) { + if (best_U1_cnt!=255 && !found_second_possible && !bis_default) { + found_second_possible=TRUE; + if (!a->arg1.size) + PrintFWarn("%S%s,%04d\r\n","ST_NO_SIZE_SPECIFIED", + lx->cur_lfn->name,lx->cur_lfn->line_num-1); + } + if (tempi->flags & IEF_PLUS_OPCODE) { + last_opcode_U1=last_opcode_U1+tempa1->reg1&7; + if (tempa1->reg1>7) + REX|=1; + } + if (a1==ARGT_R64 || a1==ARGT_RM64) + REX|=8; + if (a1>=ARGT_RM8 && a1<=ARGT_RM64) { + if (a->seg_size==16) + has_address_prefix=TRUE; + + has_ModrM=TRUE; + if (tempa1->imm_or_off_present && tempa1->indirect && tempa1->reg1==16) { + ModrM=ModrM+5; + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_U1s=4; + disp_abs_cnt=tempa1->absolute_address_cnt; + if (a->seg_size==64) + disp_lit=0; + } else { + if (tempa1->reg2==16 && tempa1->scale==1) { + ModrM+=tempa1->reg1&7; + if (tempa1->reg1>7) + REX|=1; + } else { + ModrM+=4; + has_SIB=TRUE; + if (tempa1->scale==1) + SIB=0; + else if (tempa1->scale==2) + SIB=0x40; + else if (tempa1->scale==4) + SIB=0x80; + else if (tempa1->scale==8) + SIB=0xC0; + if (tempa1->reg2==16) { + ModrM_complete=TRUE; + SIB+=((tempa1->reg1&7)<<3)+5; + if (tempa1->reg1>7) + REX|=2; + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_U1s=4; + disp_abs_cnt=tempa1->absolute_address_cnt; + } else { + SIB+=((tempa1->reg1&7)<<3)+tempa1->reg2&7; + if (tempa1->reg1>7) + REX|=2; + if (tempa1->reg2>7) + REX|=1; + if (tempa1->reg2==5 && !tempa1->imm_or_off_present && tempa1->indirect) { + ModrM+=0x40; + disp_U1s=1; + ModrM_complete=TRUE; + } + } + } + if (!ModrM_complete) { + if (tempa1->imm_or_off_present) { + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_abs_cnt=tempa1->absolute_address_cnt; + if (!disp_exp && MIN_I1<=disp<=MAX_I1) { + ModrM+=0x40; + disp_U1s=1; + } else if (a->seg_size==16) { + ModrM+=0x80; + disp_U1s=2; + } else { + ModrM+=0x80; + disp_U1s=4; + } + } else if (!tempa1->indirect) { + has_address_prefix=FALSE; + ModrM+=0xC0; + } else { + if (tempa1->reg1==5) { + ModrM+=0x40; + disp_U1s=1; + } + } + } + } + } else if (a1>=ARGT_REL8 && a1<=ARGT_REL32 || + a1>=ARGT_IMM8 && a1<=ARGT_IMM64 || + a1>=ARGT_UIMM8 && a1<=ARGT_UIMM64) { + if (a1==ARGT_IMM64 || a2==ARGT_UIMM64) + REX|=8; + imm=tempa1->imm; + imm_exp=tempa1->exp; + imm_local_hash=tempa1->undef_local; + imm_glbl_hash=tempa1->undef_glbl; + imm_abs_cnt=tempa1->absolute_address_cnt; + } + } else if (argcnt==2) { + if (best_U1_cnt!=255 && !found_second_possible && !bis_default) { + found_second_possible=TRUE; + if (!a->arg1.size && !a->arg2.size) + PrintFWarn("%S%s,%04d\r\n","ST_NO_SIZE_SPECIFIED", + lx->cur_lfn->name,lx->cur_lfn->line_num-1); + } + if (tempi->flags & IEF_PLUS_OPCODE) { + if (om>=OM_RB && om<=OM_RD) { + last_opcode_U1+=tempa1->reg1&7; + if (tempa1->reg1>7) + REX|=1; + } else if (tempi->slash_value==SV_REGISTER) { + if (a1>=ARGT_AL && a1<=ARGT_EAX) { + last_opcode_U1+=tempa2->reg1&7; + if (tempa2->reg1>7) + REX|=1; + } else if (a2>=ARGT_AL && a2<=ARGT_EAX) { + last_opcode_U1+=tempa1->reg1&7; + if (tempa1->reg1>7) + REX|=1; + } + } + } + if (a1==ARGT_RM64 || a2==ARGT_RM64 || + a1==ARGT_R64 || a2==ARGT_R64) + REX|=8; + if (a1>=ARGT_RM8 && a1<=ARGT_RM64 ||a2>=ARGT_RM8 && a2<=ARGT_RM64) { + if (a->seg_size==16) + has_address_prefix=TRUE; + has_ModrM=TRUE; + if (a2>=ARGT_RM8 && a2<=ARGT_RM64) { + tempa1=&a->arg2; + tempa2=&a->arg1; + } + if (tempi->slash_value==SV_REGISTER) { + if (tempa2->just_seg) + ModrM+=(tempa2->seg<<3); + else { + if (tempa2->reg1==16) { + ModrM+=((tempa1->reg1&7)<<3); + if (tempa1->reg1>7) + REX|=4; + } else { + ModrM+=((tempa2->reg1&7)<<3); + if (tempa2->reg1>7) + REX|=4; + } + } + } + if (tempa1->reg2==16 && tempa1->scale==1) { + if (tempa1->reg1!=16) { + ModrM+=tempa1->reg1&7; + if (tempa1->reg1>7) + REX|=1; + } + } else { + ModrM+=4; + has_SIB=TRUE; + if (tempa1->scale==1) + SIB=0; + else if (tempa1->scale==2) + SIB=0x40; + else if (tempa1->scale==4) + SIB=0x80; + else if (tempa1->scale==8) + SIB=0xC0; + if (tempa1->reg2==16) { + ModrM_complete=TRUE; + SIB+=((tempa1->reg1&7)<<3)+5; + if (tempa1->reg1>7) + REX|=2; + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_U1s=4; + disp_abs_cnt=tempa1->absolute_address_cnt; + } else { + SIB+=((tempa1->reg1&7)<<3)+tempa1->reg2&7; + if (tempa1->reg1>7) + REX|=2; + if (tempa1->reg2>7) + REX|=1; + if (tempa1->reg2==5 && !tempa1->imm_or_off_present && tempa1->indirect) { + ModrM+=0x40; + disp_U1s=1; + ModrM_complete=TRUE; + } + } + } + if (!ModrM_complete) { + if (tempa1->imm_or_off_present && tempa1->indirect && tempa1->reg1==16) { + ModrM=(ModrM & 0xF8)+5; + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_U1s=4; + disp_abs_cnt=tempa1->absolute_address_cnt; + if (a->seg_size==64) + disp_lit=0; + } else { + if (tempa1->imm_or_off_present) { + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_abs_cnt=tempa1->absolute_address_cnt; + if (!disp_exp && MIN_I1<=disp<=MAX_I1) { + ModrM+=0x40; + disp_U1s=1; + } else if (a->seg_size==16) { + ModrM+=0x80; + disp_U1s=2; + } else { + ModrM+=0x80; + disp_U1s=4; + } + } else if (!tempa1->indirect) { + has_address_prefix=FALSE; + ModrM+=0xC0; + } else { + if (tempa1->reg1==5) { + ModrM+=0x40; + disp_U1s=1; + } + } + } + } + } else if (a1>=ARGT_MOFFS8 && a1<=ARGT_MOFFS64) { + disp=tempa1->imm; + disp_exp=tempa1->exp; + disp_local_hash=tempa1->undef_local; + disp_glbl_hash=tempa1->undef_glbl; + disp_abs_cnt=tempa1->absolute_address_cnt; + if (a->seg_size==16) + disp_U1s=2; + else + disp_U1s=4; + has_address_prefix=FALSE; + } else if (a2>=ARGT_MOFFS8 && a2<=ARGT_MOFFS64) { + disp=tempa2->imm; + disp_exp=tempa2->exp; + disp_local_hash=tempa2->undef_local; + disp_glbl_hash=tempa2->undef_glbl; + disp_abs_cnt=tempa2->absolute_address_cnt; + if (a->seg_size==16) + disp_U1s=2; + else + disp_U1s=4; + has_address_prefix=FALSE; + } else if (a1>=ARGT_IMM8 && a1<=ARGT_IMM64 || + a1>=ARGT_UIMM8 && a1<=ARGT_UIMM64) { + imm=tempa1->imm; + imm_exp=tempa1->exp; + imm_local_hash=tempa1->undef_local; + imm_glbl_hash=tempa1->undef_glbl; + imm_abs_cnt=tempa1->absolute_address_cnt; + if (a1==ARGT_IMM8 || a1==ARGT_UIMM8) imm_U1s=1; + else if (a1==ARGT_IMM16 || a1==ARGT_UIMM16) imm_U1s=2; + else if (a1==ARGT_IMM32 || a1==ARGT_UIMM32) imm_U1s=4; + else { + imm_U1s=8; + REX|=8; + } + } + if (a2>=ARGT_IMM8 && a2<=ARGT_IMM64 || + a2>=ARGT_UIMM8 && a2<=ARGT_UIMM64) { + imm=tempa2->imm; + imm_exp=tempa2->exp; + imm_local_hash=tempa2->undef_local; + imm_glbl_hash=tempa2->undef_glbl; + imm_abs_cnt=tempa2->absolute_address_cnt; + if (a2==ARGT_IMM8 || a2==ARGT_UIMM8) imm_U1s=1; + else if (a2==ARGT_IMM16 || a2==ARGT_UIMM16) imm_U1s=2; + else if (a2==ARGT_IMM32 || a2==ARGT_UIMM32) imm_U1s=4; + else { + imm_U1s=8; + REX|=8; + } + } + } + U1_cnt=tempi->opcode_cnt+disp_U1s+imm_U1s; + if (has_ModrM) U1_cnt++; + if (has_SIB) U1_cnt++; + if (a->seg_size==64) + if (REX&0x40==0x40 && + (REX!=0x40 || (tempi->flags&IEF_40_REX))) + U1_cnt++; + + if (U1_cntflags & IEF_DONT_SWITCH_MODES && + (has_address_prefix || has_operand_prefix))) { + best_U1_cnt=U1_cnt; + blast_opcode_U1=last_opcode_U1; + btempi=tempi; + bhas_ModrM=has_ModrM; + bModrM=ModrM; + bhas_SIB=has_SIB; + bSIB=SIB; + bREX=REX; + bhas_address_prefix=has_address_prefix; + bhas_operand_prefix=has_operand_prefix; + bis_default=is_default; + bdisp=disp; + bdisp_U1s=disp_U1s; + bdisp_ip_rel=disp_ip_rel; + bdisp_lit=disp_lit; + bdisp_abs_cnt=disp_abs_cnt; + bimm=imm; + bimm_U1s=imm_U1s; + bimm_ip_rel=imm_ip_rel; + bimm_lit=imm_lit; + bimm_abs_cnt=imm_abs_cnt; + bdisp_exp=disp_exp; + bimm_exp=imm_exp; + bdisp_local_hash=disp_local_hash; + bdisp_glbl_hash=disp_glbl_hash; + bimm_local_hash=imm_local_hash; + bimm_glbl_hash=imm_glbl_hash; + } + } + } + if (best_U1_cnt<255) { + if (bhas_operand_prefix) + AsmStoreCodeU1(lx,0x66); //Operand size override + if (bhas_address_prefix || a->seg_size==16 && has_SIB) + AsmStoreCodeU1(lx,0x67); //Operand size override + + seg=16; + if (argcnt>1 && a->arg2.seg!=16 && !a->arg2.just_seg) + seg=a->arg2.seg; + else if (argcnt>0 && a->arg1.seg!=16 && !a->arg1.just_seg) + seg=a->arg1.seg; + if (seg!=16) { + if (seg==0) + AsmStoreCodeU1(lx,0x26); //ES: + else if (seg==1) + AsmStoreCodeU1(lx,0x2E); //CS: + else if (seg==2) + AsmStoreCodeU1(lx,0x36); //SS: + else if (seg==3) + AsmStoreCodeU1(lx,0x3E); //DS: + else if (seg==4) + AsmStoreCodeU1(lx,0x64); //FS: + else + AsmStoreCodeU1(lx,0x65); //GS: + } + if (a->seg_size==64) + if (bREX&0x40==0x40 && + (bREX!=0x40 || (btempi->flags&IEF_40_REX))) + AsmStoreCodeU1(lx,bREX); + for (j=0;jopcode_cnt-1;j++) + AsmStoreCodeU1(lx,btempi->opcode[j]); + AsmStoreCodeU1(lx,blast_opcode_U1); + + if (bhas_ModrM) + AsmStoreCodeU1(lx,bModrM); + if (bhas_SIB) + AsmStoreCodeU1(lx,bSIB); + + if (bdisp_U1s) { + bdisp_ip_rel=a->ip+bdisp_U1s+bimm_U1s; + if (!AsmStoreNum(lx,a,bdisp,FALSE,bdisp_U1s,1,bdisp_ip_rel,bdisp_lit, + bdisp_exp,bdisp_local_hash,bdisp_glbl_hash,U1_avail,bdisp_abs_cnt)) + return FALSE; + } + + if (bimm_U1s) { + bimm_ip_rel=a->ip+bimm_U1s; + if (!AsmStoreNum(lx,a,bimm,FALSE,bimm_U1s,1,bimm_ip_rel,bimm_lit, + bimm_exp,bimm_local_hash,bimm_glbl_hash,U1_avail,bimm_abs_cnt)) + return FALSE; + } + return TRUE; + } +// LexPop(lx); + PutAsmError(lx,"ST_INVALID_INSTRUCTION"); + return FALSE; +} + + +void DefineU1s(LexStruct *lx,AsmCtrlStruct *a,I8 num_U1s) +{ + BoolU4 is_question,is_dup; + I8 i,dup_value; + void *exp; + I1 *ptr; + LexUndefEntry *undef_locals,*undef_glbls; + + while (lx->token && lx->token!=';') { + undef_locals=NULL; + undef_glbls=NULL; + if (lx->token==TK_STR) { + ptr=lx->ident; + i=lx->ident_len-1; + while (i--) + AsmStoreCodeU1(lx,*ptr++); + Lex(lx); //SKip STR + } else { + is_question=FALSE; + is_dup=FALSE; + lx->absolute_address_cnt=0; + if (lx->token=='?') { + is_question=TRUE; + Lex(lx); + } else { + lx->undef_hash_entry=NULL; + lx->flags=lx->flags & ~(LF_UNRESOLVED_LOCAL+LF_UNRESOLVED_GLBL); + if (!GetExpression(lx,&exp)) + LexSkipEol(lx); + else { + if (lx->flags & (LF_UNRESOLVED_LOCAL | LF_UNRESOLVED_GLBL)) { + if (lx->flags & LF_UNRESOLVED_LOCAL) { + undef_locals=lx->undef_hash_entry; + lx->undef_hash_entry=NULL; + a->has_locals=TRUE; + } else if (lx->flags & LF_UNRESOLVED_GLBL) { + undef_glbls=lx->undef_hash_entry; + lx->undef_hash_entry=NULL; + } + } else { + i=Call(exp); + DelExpression(exp); + } + } + } + if (lx->token==TK_IDENT && lx->hash_entry) { + if (lx->hash_entry->type & HTT_KEYWORD && lx->hash_entry->user_data0==AKW_DUP) { + if (is_question) + PutAsmError(lx,"ST_QUESTION_NOT_ALLOWED"); + else { + is_dup=TRUE; + if (Lex(lx)!='(') + PutAsmError(lx,"ST_EXPECTING_LEFT_PAREN"); + else { + if (Lex(lx)=='?') { + is_question=TRUE; + Lex(lx); //SKIP "?" + } else + dup_value=AsmEvalExpression(lx); + if (lx->token!=')') + PutAsmError(lx,"ST_EXPECTING_RIGHT_PAREN"); + else + Lex(lx); //SKIP ')' + } + } + } + } + if (is_dup) { + if (undef_locals || undef_glbls) + PutAsmError(lx,"ST_UNDEFINED_DUP_CNT"); + else + AsmStoreNum(lx,a,dup_value,is_question,num_U1s,i,0,1,exp,undef_locals,undef_glbls,FALSE,lx->absolute_address_cnt); + } else + AsmStoreNum(lx,a,i,is_question,num_U1s,1,0,1,exp,undef_locals,undef_glbls,FALSE,lx->absolute_address_cnt); + } + if (lx->token==',') + Lex(lx); + } + if (lx->token==';') + Lex(lx); + else + PutAsmError(lx,"ST_MISSING_SEMICOLON"); +} + +void CmpParseAsmBlk(LexStruct *lx) +{ + AsmCtrlStruct *a=lx->a; + I8 i,j; + OpcodeHashEntry *tempo; + SysHashEntry *temph; + U8 argcnt,saved_ip; + BoolU4 is_literal; + U1 *file_buf,*b; + U8 file_size; + U8 old_hash_mask=lx->hash_mask; + I1 *next_last_label; + ArcCompressStruct *ac; + + if (!a) + PutAsmError(lx,"ST_ASM_NOT_ALLOWED"); + + a->seg_size=64; + lx->flags|=LF_ASM_EXPRESSIONS; + lx->hash_mask&=~(HTT_INTERNAL_TYPE|HTT_CLASS|HTT_PUBLIC| + HTT_WORD|HTT_LOCAL_VAR|HTT_GLBL_VAR|HTT_FUNCTION|HTT_FILE| + HTT_MODULE|HTT_PRIVATE|HTT_EXPORT|HTT_IMPORT); + if (lx->token=='{') + Lex(lx); + else + PrsExcept(lx,"ST_MISSING_RIGHT_BRACE"); + while (lx->token && lx->token!='}') { + AsmListLine(lx); + if (lx->token==TK_IDENT && lx->hash_entry) { + if (lx->hash_entry->type==HTT_KEYWORD) { + i=lx->hash_entry->user_data0; + Lex(lx); //skip keyword + switch (i) { + case AKW_IMPORT: + case AKW_EXPORT: + while (lx->token && lx->token!=';') { + if (lx->token=='#') { + is_literal=TRUE; + Lex(lx); + } else + is_literal=FALSE; + if (lx->token==TK_IDENT) { + if (temph=lx->hash_entry) { + temph=FindHashEntry(lx->ident,a->glbl_hash,HTT_ALL); + if (temph) + temph->type=HTT_SYS_SYMBOL+HTT_UNRESOLVED_GLBL; + } + if (!temph) { + temph=MAllocZ(sizeof(SysHashEntry)); + temph->str=lx->ident; + lx->ident=0; + temph->type=HTT_SYS_SYMBOL+HTT_UNRESOLVED_GLBL; + temph->use_cnt=0; + temph->user_data0=0; + temph->user_data1=NULL; + SetSourceFileInfo(lx,temph); + AddSysHashEntry(temph,a->glbl_hash); + } + if (i==AKW_IMPORT) + temph->type|=HTT_IMPORT; + else if (i==AKW_EXPORT) + temph->type|=HTT_EXPORT; + if (is_literal) + temph->type|=HTT_LITERAL; + if (Lex(lx)==',') + Lex(lx); //skip ',' + } else { + PutAsmError(lx,"ST_EXPECTING_IDENTIFIER"); + break; + } + } + if (lx->token!=';') + PutAsmError(lx,"ST_MISSING_SEMICOLON"); + else + Lex(lx); //skip ';'; + break; + case AKW_ALIGN: + if (lx->token!=TK_INTEGER) + PutAsmError(lx,"ST_EXPECTING_INTEGER"); + else { + i=(a->ip+lx->cur_i-1) & -lx->cur_i; + if (Lex(lx)==',') + Lex(lx); + if (lx->token==TK_INTEGER) { + for (j=a->ip;jcur_i); + Lex(lx); + } else + a->ip=i; + } + break; + case AKW_END: + break; //TODO + case AKW_DU1: + DefineU1s(lx,a,1); + break; + case AKW_DU2: + DefineU1s(lx,a,2); + break; + case AKW_DU4: + DefineU1s(lx,a,4); + break; + case AKW_DU8: + DefineU1s(lx,a,8); + break; + case AKW_INSERT: + if (lx->token!=TK_STR) + PutAsmError(lx,"ST_EXPECTING_STR"); + else { + file_buf=ReadFile(lx->ident,&file_size); + if (file_buf) { + for (i=0;itoken!=TK_STR) + PutAsmError(lx,"ST_EXPECTING_STR"); + else { + file_buf=ReadFile(lx->ident,&file_size); + if (file_buf) { + ac=CompressBuf(file_buf,file_size); + b=ac; + for (i=0;icompressed_size;i++) + AsmStoreCodeU1(lx,b[i]); + Free(file_buf); + Free(ac); + } + Lex(lx); + } + break; + case AKW_LIST: + a->list=TRUE; + break; + case AKW_NOLIST: + a->list=FALSE; + break; + case AKW_ORG: + a->ip=AsmEvalExpression(lx); + break; + case AKW_STRUC: + a->flags|=ACSF_IN_STRUCT; + saved_ip=a->ip; + a->ip=AsmEvalExpression(lx); + break; + case AKW_ENDS: + a->ip=saved_ip; + a->flags&=~ACSF_IN_STRUCT; + break; + case AKW_USE16: + a->seg_size=16; + break; + case AKW_USE32: + a->seg_size=32; + break; + case AKW_USE64: + a->seg_size=64; + break; + default: + PutAsmError(lx,"ST_SYNTAX_ERROR"); + break; + } + } else if (lx->hash_entry->type & HTT_OPCODE) { + tempo=lx->hash_entry; + Lex(lx); //skip opcode + argcnt=0; + if (tempo->ins[0].arg1) { + argcnt++; + ParseAsmArg(lx,a,&a->arg1,a->ip); + if (tempo->ins[0].arg2) { + argcnt++; + if (lx->token!=',') + PutAsmError(lx,"ST_EXPECTING_COMMA"); + else { + Lex(lx); //skip ',' + ParseAsmArg(lx,a,&a->arg2,a->ip); + } + } + } + AsmCodeInstruction(lx,a,tempo,argcnt); + } else if (lx->hash_entry->type & HTT_SYS_SYMBOL) { + if (a->flags & ACSF_IN_STRUCT) + lx->hash_entry->type|=HTT_LITERAL; + else + lx->hash_entry->type&=~HTT_LITERAL; + if (lx->hash_entry->type & HTT_UNRESOLVED_LOCAL) { + lx->hash_entry->type&=~HTT_UNRESOLVED_LOCAL; + lx->hash_entry->user_data0=a->ip; + if (Lex(lx)!=':') + PutAsmError(lx,"ST_EXPECTING_COLON"); + else + Lex(lx); + } else if (lx->hash_entry->type & HTT_UNRESOLVED_GLBL) { + if (lx->hash_entry->type & HTT_IMPORT) + PutAsmError(lx,"ST_ATTEMPT_DEFINE_IMPORT"); + else { + lx->hash_entry->type&=~HTT_UNRESOLVED_GLBL; + lx->hash_entry->user_data0=a->ip; + next_last_label=lx->hash_entry->str; + Lex(lx); //Skip ident + if (lx->token!=':' && lx->token!=TK_DOUBLE_COLON) + PutAsmError(lx,"ST_EXPECTING_COLON"); + else { + if (lx->token==TK_DOUBLE_COLON) { + lx->hash_entry->type|=HTT_EXPORT; + ResolveLocals(lx); + a->last_label=next_last_label; + } + if (Lex(lx)=='#') { + Lex(lx); + lx->hash_entry->type|=HTT_LITERAL | HTT_EXPORT; + } + } + } + } else + PutAsmError(lx,"ST_REDEFINITION"); + } else + PutAsmError(lx,"ST_SYNTAX_ERROR"); + } else { + if (lx->token==TK_IDENT) { + temph=MAllocZ(sizeof(SysHashEntry)); + temph->str=lx->ident; + lx->ident=0; + temph->type=HTT_SYS_SYMBOL; + if (a->flags & ACSF_IN_STRUCT) + temph->type|=HTT_LITERAL; + temph->use_cnt=0; + SetSourceFileInfo(lx,temph); + temph->user_data0=a->ip; + temph->user_data1=NULL; + Lex(lx); //Skip ident + if (lx->token==':' || lx->token==TK_DOUBLE_COLON) { + if (temph->str[0]=='@' && temph->str[1]=='@') { + AddSysHashEntry(temph,a->local_hash); + a->has_locals=TRUE; + } else + AddSysHashEntry(temph,a->glbl_hash); + if (lx->token==TK_DOUBLE_COLON) { + temph->type|=HTT_EXPORT; + ResolveLocals(lx); + a->last_label=temph->str; + Lex(lx); + } else { + if (Lex(lx)=='#') { + temph->type|=HTT_EXPORT | HTT_LITERAL; + ResolveLocals(lx); + a->last_label=temph->str; + Lex(lx); + } + } + } else { + PutAsmError(lx,"ST_EXPECTING_COLON"); + Free(temph->str); + Free(temph); + } + } else + PutAsmError(lx,"ST_SYNTAX_ERROR"); + } + } + ResolveLocals(lx); + lx->flags&=~LF_ASM_EXPRESSIONS; + lx->hash_mask=old_hash_mask; + Lex(lx); //Skip "}" +} + diff --git a/LT/Compiler/CmpAsm.ASZ b/LT/Compiler/CmpAsm.ASZ new file mode 100644 index 0000000..0e02486 --- /dev/null +++ b/LT/Compiler/CmpAsm.ASZ @@ -0,0 +1,281 @@ + ALIGN 4,OC_NOP +CMP_INTERNAL_TYPES_TABLE:: + DU4 HTT_INTERNAL_TYPE,IT_I8,8; + DU1 "void",0; + DU4 HTT_INTERNAL_TYPE,IT_DOUBLE,8; + DU1 "double",0; + + DU4 HTT_INTERNAL_TYPE,IT_I0,0; + DU1 "I0i",0; + DU4 HTT_INTERNAL_TYPE,IT_U0,0; + DU1 "U0i",0; + DU4 HTT_INTERNAL_TYPE,IT_I0,0; + DU1 "I0",0; + DU4 HTT_INTERNAL_TYPE,IT_U0,0; + DU1 "U0",0; + DU4 HTT_INTERNAL_TYPE,IT_I1,1; + DU1 "I1i",0; + DU4 HTT_INTERNAL_TYPE,IT_U1,1; + DU1 "U1i",0; + DU4 HTT_INTERNAL_TYPE,IT_I1,1; + DU1 "I1",0; + DU4 HTT_INTERNAL_TYPE,IT_U1,1; + DU1 "U1",0; + DU4 HTT_INTERNAL_TYPE,IT_I2,2; + DU1 "I2i",0; + DU4 HTT_INTERNAL_TYPE,IT_U2,2; + DU1 "U2i",0; + DU4 HTT_INTERNAL_TYPE,IT_I4,4; + DU1 "I4i",0; + DU4 HTT_INTERNAL_TYPE,IT_U4,4; + DU1 "U4i",0; + DU4 HTT_INTERNAL_TYPE,IT_I8,8; + DU1 "I8i",0; + DU4 HTT_INTERNAL_TYPE,IT_U8,8; + DU1 "U8i",0; + + DU4 HTT_INVALID; +//******************************************************* + ALIGN 8,OC_NOP +CMP_OPT_NOP: + DU4 EC_NOP; //Must be at IC_CODE offset + DU1 256 DUP(0); + +/********** +void OptNext(IntermediateCode *tempi, + IntermediateCode **temp_lag) +{ + I8 i,j=0; + for (i=3;i>0;i--) + temp_lag[i]=temp_lag[i-1]; + temp_lag[0]=tempi; + for (i=0;i<4;i++) + if (temp_lag[i]->opcode>EC_END_EXP) + temp_lag[j++]=temp_lag[i]; + while (j<4) + temp_lag[j++]=&opt_nop; +} +************/ + ALIGN 8,OC_NOP +CP_OPTNEXT:: + PUSH RBP + MOV RBP,RSP + PUSH RDI + MOV RCX,U8 SF_PARAM1[RBP] + MOV RDX,U8 SF_PARAM2[RBP] + + MOV RAX,U8 16[RDX] + MOV U8 24[RDX],RAX + MOV RAX,U8 8[RDX] + MOV U8 16[RDX],RAX + MOV RAX,U8 [RDX] + MOV U8 8[RDX],RAX + MOV U8 [RDX],RCX + + MOV RDI,RDX + + MOV RAX,RCX + CMP U2 IC_CODE[RAX],EC_END_EXP + JBE @@10 + STOSQ + +@@10: MOV RAX,U8 8[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JBE @@11 + STOSQ + +@@11: MOV RAX,U8 16[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JBE @@12 + STOSQ + +@@12: MOV RAX,U8 24[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JBE @@13 + STOSQ + +@@13: MOV RAX,CMP_OPT_NOP + ADD RDX,32 + JMP @@15 + +@@14: STOSQ +@@15: CMP RDI,RDX + JB @@14 + + POP RDI + POP RBP + RET +/********** +void OptNext2(IntermediateCode *tempi, + IntermediateCode **temp_lag) +{ + I8 i,j=0; + for (i=3;i>0;i--) + temp_lag[i]=temp_lag[i-1]; + temp_lag[0]=tempi; + for (i=0;i<4;i++) + if (temp_lag[i]->opcode>=EC_END_EXP) + temp_lag[j++]=temp_lag[i]; + while (j<4) + temp_lag[j++]=&opt_nop; +} +************/ + ALIGN 8,OC_NOP +CP_OPTNEXT2:: + PUSH RBP + MOV RBP,RSP + PUSH RDI + MOV RCX,U8 SF_PARAM1[RBP] + MOV RDX,U8 SF_PARAM2[RBP] + + MOV RAX,U8 16[RDX] + MOV U8 24[RDX],RAX + MOV RAX,U8 8[RDX] + MOV U8 16[RDX],RAX + MOV RAX,U8 [RDX] + MOV U8 8[RDX],RAX + MOV U8 [RDX],RCX + + MOV RDI,RDX + + MOV RAX,RCX + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@10 + STOSQ + +@@10: MOV RAX,U8 8[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@11 + STOSQ + +@@11: MOV RAX,U8 16[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@12 + STOSQ + +@@12: MOV RAX,U8 24[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@13 + STOSQ + +@@13: MOV RAX,CMP_OPT_NOP + ADD RDX,32 + JMP @@15 + +@@14: STOSQ +@@15: CMP RDI,RDX + JB @@14 + + POP RDI + POP RBP + RET + + + ALIGN 8,OC_NOP +CP_OPTNEXT3:: + PUSH RBP + MOV RBP,RSP + PUSH RDI + MOV RCX,U8 SF_PARAM1[RBP] + MOV RDX,U8 SF_PARAM2[RBP] + + MOV RAX,U8 16[RDX] + MOV U8 24[RDX],RAX + MOV RAX,U8 8[RDX] + MOV U8 16[RDX],RAX + MOV RAX,U8 [RDX] + MOV U8 8[RDX],RAX + MOV U8 [RDX],RCX + + MOV RDI,RDX + + MOV RAX,RCX + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@10 + CMP U2 IC_CODE[RAX],EC_NOP1 + JE @@10 + STOSQ + +@@10: MOV RAX,U8 8[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@11 + CMP U2 IC_CODE[RAX],EC_NOP1 + JE @@11 + STOSQ + +@@11: MOV RAX,U8 16[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@12 + CMP U2 IC_CODE[RAX],EC_NOP1 + JE @@12 + STOSQ + +@@12: MOV RAX,U8 24[RDX] + CMP U2 IC_CODE[RAX],EC_END_EXP + JB @@13 + CMP U2 IC_CODE[RAX],EC_NOP1 + JE @@13 + STOSQ + +@@13: MOV RAX,CMP_OPT_NOP + ADD RDX,32 + JMP @@15 + +@@14: STOSQ +@@15: CMP RDI,RDX + JB @@14 + + POP RDI + POP RBP + RET + + +//******************************************************* +/**** +void PrsPush(ParseStack *ps,I8 val) +{ + ps->stk[ps->ptr++]=val; +} +I8 PrsPop(ParseStack *ps) +{ + return ps->stk[--ps->ptr]; +} +******/ + ALIGN 8,OC_NOP +CP_PRSPUSH:: + PUSH RBP + MOV RBP,RSP + MOV RCX,U8 SF_PARAM1[RBP] + MOV RAX,U8 [RCX] + INC RAX + MOV RDX,U8 SF_PARAM2[RBP] + MOV U8 [RCX+RAX*8],RDX + MOV U8 [RCX],RAX + POP RBP + RET + + ALIGN 8,OC_NOP +CP_PRSPOP:: + PUSH RBP + MOV RBP,RSP + MOV RCX,U8 SF_PARAM1[RBP] + MOV RBX,U8 [RCX] + MOV RAX,U8 [RCX+RBX*8] + DEC RBX + MOV U8 [RCX],RBX + POP RBP + RET + + +////**************************PROCEDURE************************* + ALIGN 8,OC_NOP +CP_HI_CALL:: + PUSH RBP + MOV RBP,RSP + MOV RAX,U8 SF_PARAM1[RBP] + OR RAX,RAX + JZ @@100 + CALL RAX +@@100: POP RBP + RET + diff --git a/LT/Compiler/CmpDefs.HPZ b/LT/Compiler/CmpDefs.HPZ new file mode 100644 index 0000000..5e76a63 --- /dev/null +++ b/LT/Compiler/CmpDefs.HPZ @@ -0,0 +1,254 @@ +//Intermediate compiler codes +#define EC_NULL 0x000 +#define EC_NOP 0x001 +#define EC_END_EXP 0x002 +#define EC_LABEL 0x003 +#define EC_CALL_START 0x004 +#define EC_CALL_END 0x005 +#define EC_RETURN_START 0x006 +#define EC_RETURN_END 0x007 +#define EC_NOP1 0x008 +#define EC_IMM 0x009 +#define EC_DOUBLE 0x00A +#define EC_STR_CONST 0x00B +#define EC_ABSOLUTE_ADDRESS 0x00C +#define EC_TYPE 0x00D //not used (yet) +#define EC_GET_LABEL 0x00E +#define EC_RBP 0x00F +#define EC_REG 0x010 +#define EC_FS 0x011 +#define EC_GS 0x012 + +#define EC_LEA 0x013 + +#define EC_MOV 0x014 + +#define EC_ADDRESS 0x015 +#define EC_COM 0x016 +#define EC_NOT 0x017 +#define EC_UNARY_MINUS 0x018 + +#define EC_DEREF 0x019 +#define EC__PP 0x01A +#define EC__MM 0x01B +#define EC_PP_ 0x01C +#define EC_MM_ 0x01D + +#define EC_SHL 0x01E +#define EC_SHR 0x01F + +#define EC_POWER 0x020 + +#define EC_MUL 0x021 +#define EC_DIV 0x022 +#define EC_MOD 0x023 + +#define EC_AND 0x024 + +#define EC_OR 0x025 +#define EC_XOR 0x026 + +#define EC_ADD 0x027 +#define EC_SUB 0x028 + +#define EC_EQUAL_EQUAL 0x029 +#define EC_NOT_EQUAL 0x02A +#define EC_LESS 0x02B +#define EC_GREATER 0x02C +#define EC_LESS_EQUAL 0x02D +#define EC_GREATER_EQUAL 0x02E + +#define EC_AND_AND 0x02F + +#define EC_OR_OR 0x030 +#define EC_XOR_XOR 0x031 + +#define EC_COLON 0x032 +#define EC_QUESTION 0x033 + +#define EC_ASSIGN 0x034 + +#define EC_SHL_EQUAL 0x035 +#define EC_SHR_EQUAL 0x036 +#define EC_MUL_EQUAL 0x037 +#define EC_DIV_EQUAL 0x038 +#define EC_AND_EQUAL 0x039 +#define EC_OR_EQUAL 0x03A +#define EC_XOR_EQUAL 0x03B +#define EC_ADD_EQUAL 0x03C +#define EC_SUB_EQUAL 0x03D + +#define EC_ADD_RSP 0x03E + +#define EC_ENTER 0x03F +#define EC_LEAVE 0x040 +#define EC_RET 0x041 + +#define EC_CALL 0x042 +#define EC_CALL_INDIRECT 0x043 +#define EC_CALL_INDIRECT2 0x044 +#define EC_IRQ 0x045 + +#define EC_CLI 0x046 +#define EC_STI 0x047 +#define EC_DISABLE_CACHE 0x048 +#define EC_ENABLE_CACHE 0x049 +#define EC_WBINVD 0x04A +#define EC_INVD 0x04B + +#define EC_GET_FLAGS 0x04C +#define EC_SET_FLAGS 0x04D +#define EC_GET_BASE_PTR 0x04E +#define EC_SET_BASE_PTR 0x04F +#define EC_GET_STACK_PTR 0x050 +#define EC_SET_STACK_PTR 0x051 +#define EC_SET_RAX 0x052 + +#define EC_BT 0x053 +#define EC_BTS 0x054 +#define EC_BTR 0x055 +#define EC_BTC 0x056 +#define EC_BSF 0x057 +#define EC_BSR 0x058 +#define EC_INSQUE 0x059 +#define EC_INSQUE_REV 0x05A +#define EC_REMQUE 0x05B +#define EC_STRLEN 0x05C +#define EC_MEMCPY 0x05D +#define EC_MEMSET 0x05E +#define EC_INPD 0x05F +#define EC_INPW 0x060 +#define EC_INP 0x061 +#define EC_OUTPD 0x062 +#define EC_OUTPW 0x063 +#define EC_OUTP 0x064 +#define EC_RDTSC 0x065 + +#define EC_JMP 0x066 +#define EC_SWITCH 0x067 + +#define EC_BR_ZERO 0x068 +#define EC_BR_NOT_ZERO 0x069 + +//ADDED DURING PASS1 +#define EC_BR_NOT_EQUAL 0x06A +#define EC_BR_EQUAL_EQUAL 0x06B +#define EC_BR_GREATER_EQUAL 0x06C +#define EC_BR_LESS_EQUAL 0x06D +#define EC_BR_GREATER 0x06E +#define EC_BR_LESS 0x06F +#define EC_BR_OR_OR_ZERO 0x070 +#define EC_BR_OR_OR_NOT_ZERO 0x071 + +#define EC_SHL_CONST 0x072 +#define EC_SHR_CONST 0x073 +#define EC_ADD_CONST 0x074 +#define EC_SUB_CONST 0x075 + +#define EC_PUSH_REGS 0x076 +#define EC_POP_REGS 0x077 + +#define EC_BR_BT 0x078 +#define EC_BR_BTS 0x079 +#define EC_BR_BTR 0x07A +#define EC_BR_BTC 0x07B +#define EC_BR_NOT_BT 0x07C +#define EC_BR_NOT_BTS 0x07D +#define EC_BR_NOT_BTR 0x07E +#define EC_BR_NOT_BTC 0x07F +#define EC_CALL_END2 0x080 + +#define EC_LBTS 0x081 +#define EC_LBTR 0x082 +#define EC_LBTC 0x083 +#define EC_BR_LBTS 0x084 +#define EC_BR_LBTR 0x085 +#define EC_BR_LBTC 0x086 +#define EC_BR_NOT_LBTS 0x087 +#define EC_BR_NOT_LBTR 0x088 +#define EC_BR_NOT_LBTC 0x089 +#define EC_BR_AND_AND_ZERO 0x08A +#define EC_BR_AND_AND_NOT_ZERO 0x08B + +#define EC_BR_AND_ZERO 0x08C +#define EC_BR_AND_NOT_ZERO 0x08D + +#define EC_MOD_EQUAL 0x08E +#define EC_CALL_EXTERN 0x08F + +#define EC_ABSI8 0x090 +#define EC_PUSH_CMP 0x091 +#define EC_PREEMPT 0x092 + +#define EC_NUM_ENTRIES 0x093 + + + +#define KW_INCLUDE 0 +#define KW_DEFINE 1 +#define KW_UNION 2 +#define KW_CATCH 3 +#define KW_CLASS 4 +#define KW_TRY 5 +#define KW_IF 6 +#define KW_ELSE 7 +#define KW_FOR 8 +#define KW_WHILE 9 +#define KW_EXTERN 10 +#define KW_LTEXTERN 11 +#define KW_RETURN 12 +#define KW_SIZEOF 13 +#define KW_INTERNAL 14 +#define KW_FMTSTR 15 +#define KW_FMTDATA 16 +#define KW_OUTPUT_FUN 17 +#define KW_INPUT_FUN 18 +#define KW_COUT 19 +#define KW_DO 20 +#define KW_ASM 21 +#define KW_GOTO 22 +#define KW_EXE 23 +#define KW_BREAK 24 +#define KW_CONTINUE 25 +#define KW_SWITCH 26 +#define KW_CASE 27 +#define KW_DEFAULT 28 +#define KW_PUBLIC 29 +#define KW_OFFSET 30 +#define KW_TYPEOF 31 +#define KW_IMPORT 32 +#define KW_LTIMPORT 33 +#define KW_COUTLN 34 +#define KW_IFDEF 35 +#define KW_IFNDEF 36 +#define KW_ENDIF 37 +#define KW_ASSERT 38 +#define KW_REG 39 +#define KW_NOREG 40 +#define KW_NOUNUSEDWARN 41 +#define KW_HELP_INDEX 42 +#define KW_HELP_FILE 43 + +#define AKW_ALIGN 64 +#define AKW_END 65 +#define AKW_U1 66 +#define AKW_U2 67 +#define AKW_U4 68 +#define AKW_U8 69 +#define AKW_DU1 70 +#define AKW_DU2 71 +#define AKW_DU4 72 +#define AKW_DU8 73 +#define AKW_DUP 74 +#define AKW_ORG 75 +#define AKW_STRUC 76 +#define AKW_ENDS 77 +#define AKW_USE16 78 +#define AKW_USE32 79 +#define AKW_USE64 80 +#define AKW_IMPORT 81 +#define AKW_EXPORT 82 +#define AKW_INSERT 83 +#define AKW_LIST 84 +#define AKW_NOLIST 85 +#define AKW_INSERT_COMPRESSED 86 diff --git a/LT/Compiler/CmpDefs2.HPZ b/LT/Compiler/CmpDefs2.HPZ new file mode 100644 index 0000000..84e57b4 --- /dev/null +++ b/LT/Compiler/CmpDefs2.HPZ @@ -0,0 +1,21 @@ +extern I8 Expression(LexStruct *lx); +extern BoolU8 GetExpression(LexStruct *lx,U1 **exp); +extern U8 PrsUnaryTerm(LexStruct *lx,ParseStack *ps,MemberListStruct **local_var,ArrayDimStruct **tempad); +extern U8 PrsUnaryModifier(LexStruct *lx,ParseStack *ps,MemberListStruct **local_var,ArrayDimStruct **tempad); +extern U8 PrsDereferrence(LexStruct *lx,ParseStack *ps); +extern void PrsExcept(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL); +extern BoolU8 CmpParseStatement(LexStruct *lx,ClassStruct *locals,I8 try_count=0, + CbMiscStruct *break_label=NULL,CbMiscStruct *continue_label=NULL, + BoolU4 saved_prs_semicolon=TRUE); +extern I8 ExecuteCmdLine(LexStruct *lx); +extern IntermediateCode *CmpOptPass1(LexStruct *lx,ClassStruct *fun_class,BoolU4 combined); +extern void CmpOptPass2(LexStruct *lx,ClassStruct *fun_class,I8 *register_offsets); +extern void CmpOptPass3(LexStruct *lx,I8 *register_offsets,U8 *type); +extern void CmpOptPass4(LexStruct *lx); +extern void CmpOptPass5(LexStruct *lx,ClassStruct *fun_class); +extern U8 CmpOptPass678(LexStruct *lx,ClassStruct *fun_class,I8 *register_offsets,U1 *buf,I8 pass,DbgInfo **dbg_info,I8 *min_line,I8 *max_line); +extern I8 CmpKeyWord(LexStruct *lx); +extern void PutLexWarning(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL); + +LTextern CMP_INTERNAL_TYPES_TABLE U1 internal_types_table[1]; + diff --git a/LT/Compiler/CmpGlbls.CPZ b/LT/Compiler/CmpGlbls.CPZ new file mode 100644 index 0000000..23ea06a --- /dev/null +++ b/LT/Compiler/CmpGlbls.CPZ @@ -0,0 +1,13 @@ +SysHashTable *asm_hash; +BoolU4 is_first_compiler,cmp_do_not_write_to_disk; +SysHashEntry *sys_internal_types[IT_NUM_IT]; + +U2 *duel_I1_tokens1,*duel_I1_tokens2,*duel_I1_tokens3; +U4 *binary_ops_table,*unary_ops_table; +U1 *cmp_param_cnt,*cmp_result_cnt; +U1 *deref_bitmap,*assign_bitmap,*not_constant_bitmap,*cmp_bitmap; +I8 num_stk_temps,num_reg_vars,num_non_ptr_vars; +U8 stk_temps_mask,reg_vars_mask,non_ptr_vars_mask; +U1 *to_stk_temps_map_odd; +U1 *to_stk_temps_map_even; +U1 *to_reg_vars_map,*to_non_ptr_vars_map; diff --git a/LT/Compiler/CmpInit.CPZ b/LT/Compiler/CmpInit.CPZ new file mode 100644 index 0000000..4e35d1b --- /dev/null +++ b/LT/Compiler/CmpInit.CPZ @@ -0,0 +1,603 @@ +void LoadAsmHash(BoolU4 first) +{ + U8 i,j,type; + U4 *dd; + LexStruct *lx; + I8 size,size1; + SysHashEntry *temph; + OpcodeHashEntry *tempo,*tempo1; + InstructionEntry *tempi; + ClassStruct *tempc; + + asm_hash=NewHashTable(2048); + size1=offset(OpcodeHashEntry.ins)+sizeof(InstructionEntry)<<5; + tempo=MAlloc(size1); + + lx=LexNew(ReadTextFile("OpCodes.TXZ"),0,NewStr("OpCodes.TXZ")); + lx->hash_table_list=NULL; + Lex(lx); + while (lx->token) { + if (lx->token!=TK_IDENT) + PutAsmError(lx,"ST_EXPECTING_IDENTIFIER"); + else { + i=MatchListEntry(lx->ident,"OPCODE\0KEYWORD\0R8\0R16\0R32\0R64\0SEG\0\0",MLE_IGNORE_CASE); + Lex(lx); //skip keyword + if (!i) { //OPCODE + MemSet(tempo,0,size1); + tempo->type=HTT_OPCODE; + tempo->instruction_entry_cnt=0; + tempo->str=lx->ident; + lx->ident=0; + Lex(lx); //Skip OPCODE + while (lx->token && lx->token!=';') { + tempi=&tempo->ins[tempo->instruction_entry_cnt]; + tempi->ins_entry_num=tempo->instruction_entry_cnt++; + tempi->opcode_cnt=0; + while (lx->token==TK_INTEGER) { + tempi->opcode[tempi->opcode_cnt++]=lx->cur_i; + Lex(lx); + } + tempi->flags=0; + if (lx->token=='+') { + tempi->flags|=IEF_PLUS_OPCODE; + Lex(lx); + } + if (lx->token=='/') { + if (Lex(lx)==TK_INTEGER) { + tempi->slash_value=lx->cur_i; + Lex(lx); + } else if (lx->token==TK_IDENT) { + tempi->slash_value=SV_REGISTER; + Lex(lx); + } + } else + tempi->slash_value=SV_NONE; + if (lx->token=='*') { + tempi->flags|=IEF_OP_SIZE16; + Lex(lx); + } + if (lx->token==TK_MOD_EQUAL) { + tempi->flags|=IEF_OP_SIZE32|IEF_48_REX; + Lex(lx); + } + if (lx->token=='%') { + tempi->flags|=IEF_OP_SIZE32; + Lex(lx); + } + if (lx->token=='!') { + tempi->flags|=IEF_DONT_SWITCH_MODES; + Lex(lx); + } + if (lx->token=='&') { + tempi->flags|=IEF_DEFAULT; + Lex(lx); + } + if (lx->token=='-') { + tempi->flags|=IEF_NO_REX; + Lex(lx); + } + if (lx->token=='~') { + tempi->flags|=IEF_40_REX; + Lex(lx); + } + if (lx->token=='~') { + tempi->flags|=IEF_40_REX; + Lex(lx); + } else if (lx->token=='=') { + tempi->flags|=IEF_48_REX; + Lex(lx); + } + if (lx->token!=TK_IDENT) + PutAsmError(lx,"ST_EXPECTING_IDENTIFIER"); + else { + tempi->opcode_modifier=MatchSysTextEntry(lx->ident, + "ST_OPCODE_MODIFIERS",MLE_IGNORE_CASE); + tempi->arg1=0; + tempi->arg2=0; + if (Lex(lx)==TK_IDENT) { + j=MatchSysTextEntry(lx->ident, + "ST_ARGUMENT_TYPES",MLE_IGNORE_CASE); + tempi->arg1=j; + if (j>=ARGT_REL8 && j<=ARGT_REL32 || + j>=ARGT_MOFFS8 && j<=ARGT_MOFFS64) + tempi|=IEF_NO_REX; + + if (Lex(lx)==TK_IDENT) { + j=MatchSysTextEntry(lx->ident, + "ST_ARGUMENT_TYPES",MLE_IGNORE_CASE); + Lex(lx); + tempi->arg2=j; + if (j>=ARGT_REL8 && j<=ARGT_REL32 || + j>=ARGT_MOFFS8 && j<=ARGT_MOFFS64) + tempi|=IEF_NO_REX; + } + } + } + } + if (lx->token==';') { + Lex(lx); //Skip ';' + size=offset(OpcodeHashEntry.ins)+ + sizeof(InstructionEntry)*tempo->instruction_entry_cnt; + tempo1=MAlloc(size); + MemCpy(tempo1,tempo,size); + tempo1->use_cnt=0; + SetSourceFileInfo(lx,tempo1); + AddSysHashEntry(tempo1,asm_hash); + } else + PutAsmError(lx,"ST_MISSING_SEMICOLON"); + } else if (i>=1 && i<=6) { //KEYWORD,R8,R16,R32,R64,SEG + if (lx->token!=TK_IDENT) + PutAsmError(lx,"ST_EXPECTING_IDENTIFIER"); + else { + temph=MAllocZ(sizeof(SysHashEntry)); + temph->str=lx->ident; + lx->ident=NULL; + temph->use_cnt=0; + SetSourceFileInfo(lx,temph); + Lex(lx); //skip keyword name + if (lx->token!=TK_INTEGER) + PutAsmError(lx,"ST_EXPECTING_INTEGER"); + else { + temph->user_data0=lx->cur_i; + if (Lex(lx)!=';') + PutAsmError(lx,"ST_MISSING_SEMICOLON"); + else { + Lex(lx); //skip ';' + AddSysHashEntry(temph,asm_hash); + } + } + switch (i) { + case 1: + temph->type=HTT_KEYWORD; + if (first) { + temph=MAllocIdentical(temph); + AddSysHashEntry(temph,adam_tss->hash_table); + } + break; + case 2: temph->type=HTT_R8; break; + case 3: temph->type=HTT_R16; break; + case 4: temph->type=HTT_R32; break; + case 5: temph->type=HTT_R64; break; + case 6: temph->type=HTT_SEG; break; + } + } + } else + PutAsmError(lx,"Unknown Statement"); + } + } + Free(tempo); + LexDel(lx); + dd=internal_types_table; + while (*dd!=HTT_INVALID) { + tempc=CmpClassNew; + tempc->type=*dd; dd+=4; + tempc->use_cnt=0; + tempc->source_link=NULL; + tempc->index=NULL; + tempc->sub_type=*dd; dd+=4; + tempc->size=*dd; dd+=4; + tempc->str=ANewStr(dd); + dd+=StrLen(tempc->str)+1; + AddSysHashEntry(tempc,asm_hash); + sys_internal_types[tempc->sub_type]=tempc; + if (first) { + tempc=MAllocIdentical(tempc); + AddSysHashEntry(tempc,adam_tss->hash_table); + } + } +} + + +void LoadCompileSysText() +{ + LoadStr("ST_ERROR",ST_ERROR); + LoadStr("ST_WARNING",ST_WARNING); + LoadStr("ST_MISSING_SEMICOLON","missing ';' at"); + LoadStr("ST_MISSING_EXPRESSION","missing Expression at "); + LoadStr("ST_MISSING_RIGHT_PAREN","missing ')' at "); + LoadStr("ST_MISSING_RIGHT_BRACKET","missing ']' at "); + LoadStr("ST_UNDEFINED_SYMBOL","undefined symbol at "); + LoadStr("ST_UNDEFINED_IDENTIFIER","undefined identifier at "); + LoadStr("ST_INVALID_CLASS","invalid class at "); + LoadStr("ST_INVALID_MEMBER","invalid member at "); + LoadStr("ST_EXPECTING_TYPE","expecting type at "); + LoadStr("ST_EXPECTING_IDENTIFIER","expecting identifier at "); + LoadStr("ST_EXPECTING_RIGHT_PAREN","expecting ')' at "); + LoadStr("ST_EXPECTING_LEFT_BRACE","expecting '{' at "); + LoadStr("ST_MISSING_RIGHT_BRACE","missing '}' at "); + LoadStr("ST_INVALID_LVALUE","invalid lvalue at "); + LoadStr("ST_EXPECTING_EQUAL","expecting '=' at "); + LoadStr("ST_NOT_POINTER_TYPE","not pointer type at "); + LoadStr("ST_EXPECTING_COMMA","expecting ',' at "); + LoadStr("ST_EXPECTING_SYS_SYMBOL","expecting System symbol at "); + LoadStr("ST_EXPECTING_STR","expecting str at "); + LoadStr("ST_MISSING_WHILE","missing 'while' at"); + LoadStr("ST_UNKNOWN_STATEMENT","unknown statement at "); + LoadStr("ST_ALREADY_ONE_IMMEDIATE","already one immediate at "); + LoadStr("ST_SYNTAX_ERROR","syntax error at "); + LoadStr("ST_EXPECTING_SCALE_FACTOR","expecting scale factor at "); + LoadStr("ST_QUESTION_NOT_ALLOWED","'?' not allowed at "); + LoadStr("ST_EXPECTING_LEFT_PAREN","expecting '(' at "); + LoadStr("ST_UNDEFINED_DUP_CNT","undefined DUP cnt at "); + LoadStr("ST_EXPECTING_COLON","expecting ':' at "); + LoadStr("ST_EXPECTING_DOUBLE_COLON","expecting '::' at "); + LoadStr("ST_EXPECTING_DOT","expecting '.' at "); + LoadStr("ST_EXPECTING_LOCAL_VARIABLE","expecting local variable at "); + LoadStr("ST_REDEFINITION","redefinition at "); + LoadStr("ST_INVALID_INSTRUCTION","invalid instruction at "); + LoadStr("ST_INTERNAL_ERROR","LTintern error at "); + LoadStr("ST_BRANCH_OUT_OF_RANGE","branch out of range at "); + LoadStr("ST_ATTEMPT_DEFINE_IMPORT","attempt to define import at "); + LoadStr("ST_COULD_USE_U1_DISP","could use U1 displacement at "); + LoadStr("ST_LINE","line: "); + LoadStr("ST_NO_SIZE_SPECIFIED","no size specified at "); + LoadList("ST_IT_TYPES","I0\0U0\0I1\0U1\0I2\0U2\0I4\0U4\0I8\0U8\0double\0udouble\0"); + LoadList("ST_TY_TYPES","NULL\0IMM\0REG\0DISP\0RIP\0STK\0\0"); + LoadList("ST_U1_REGS","AL\0CL\0DL\0BL\0AH\0CH\0DH\0BH\0" + "R8u1\0R9u1\0R10u1\0R11u1\0R12u1\0R13u1\0R14u1\0R15u1\0"); + LoadList("ST_U2_REGS","AX\0CX\0DX\0BX\0SP\0BP\0SI\0DI\0" + "R8u2\0R9u2\0R10u2\0R11u2\0R12u2\0R13u2\0R14u2\0R15u2\0"); + LoadList("ST_U4_REGS","EAX\0ECX\0EDX\0EBX\0ESP\0EBP\0ESI\0EDI\0" + "R8u4\0R9u4\0R10u4\0R11u4\0R12u4\0R13u4\0R14u4\0R15u4\0"); + LoadList("ST_U8_REGS","RAX\0RCX\0RDX\0RBX\0RSP\0RBP\0RSI\0RDI\0" + "R8\0R9\0R10\0R11\0R12\0R13\0R14\0R15\0"); + LoadList("ST_OPCODE_MODIFIERS","NO\0R\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0RB\0RW\0RD\0"); + LoadList("ST_ARGUMENT_TYPES", + "NO\0REL8\0REL16\0REL32\0UIMM8\0UIMM16\0UIMM32\0UIMM64\0" + "R8\0R16\0R32\0R64\0" + "IMM8\0IMM16\0IMM32\0IMM64\0RM8\0RM16\0RM32\0RM64\0" + "M8\0M16\0M32\0" + "M1616\0M1632\0M16N32\0M16N16\0M32N32\0" + "MOFFS8\0MOFFS16\0MOFFS32\0MOFFS64\0" + "AL\0AX\0EAX\0RAX\0CL\0DX\0 \0SREG\0" + "SS\0DS\0ES\0FS\0GS\0CS\0"); + LoadList("ST_SEG_REGS","ES\0CS\0SS\0DS\0FS\0GS\0"); + LoadStr("ST_EXPECTING_INTEGER","expecting integer at "); + LoadStr("ST_DIVIDE_BY_ZERO","Divide by zero at "); + LoadStr("ST_OPT_INTERNAL_ERROR","Compiler Optimization Error at "); + LoadStr("ST_UNRESOLVED_REFERENCE","Unresolved Reference:"); + LoadStr("ST_NOT_DEFINED","Not Defined"); + LoadStr("ST_SCANNING_DIRECTORY","Scanning Directory:"); + LoadStr("ST_ASM_NOT_ALLOWED","ASM not allowed"); + LoadStr("ST_UNUSED_VAR","Unused Var"); + LoadStr("ST_UNUSED_EXTERN","Unused extern"); + LoadStr("ST_NOT_ALLOWED_IN_FUNCTION","Not allowed in function"); + LoadStr("ST_MISSING_CATCH","missing 'catch' at"); + LoadStr("ST_UNDEFINED_GOTO_LABEL","Undefined goto label:"); + LoadStr("ST_BREAK_NOT_ALLOWED","'break' not allowed\r\n"); + LoadStr("ST_CONTINUE_NOT_ALLOWED","'continue' not allowed\r\n"); + LoadStr("ST_ERRORS_WARNINGS","Errors:%04d Warnings:%04d Size:%08X\r\n"); + LoadStr("ST_IMPORT_NOT_NEEDED","import not needed at "); + LoadStr("ST_EXPECTING_CASE","expecting 'case' at "); + LoadStr("ST_CASE_RANGE_ERROR","switch range error at "); + LoadStr("ST_LEX_STACK_OVERFLOW","Lex Stack overflow"); + LoadStr("ST_STR_DEFAULT","Str defaults not implemented in static mode at "); + LoadStr("ST_ASSERT_FAILED","Assert Failed "); + LoadStr("ST_ADDRESS_EXTERN","Can't take address of extern function"); + +$AN,"Anchor for inserting Compiler systext","COMPILE_SYSTEXT"$ + + + LoadList("ST_INTERMEDIATE_CODE", +// '*' means it is a dereferrence instruction +// '=' means it is an assignment instruction +// '^' means it is a compare instruction + +// '9' param count means variable + +// 'N' means not constant + +// param cnt,result cnt,push prior,deref/assign +"00..NULL\0" +"00..NOP\0" +"10..END_EXP\0" +"00..LABEL\0" +"00..CALL_START\0" +"01..CALL_END\0" +"00..RETURN_START\0" +"00..RETURN_END\0" +"00..NOP1\0" +"01..IMM\0" +"01..DOUBLE\0" +"01.NSTR_CONST\0" +"01.NABSOLUTE_ADDRESS\0" +"01.NTYPE\0" +"01.NGET_LABEL\0" +"01.NRBP\0" +"01.NREG\0" +"00.NFS\0" +"00.NGS\0" +"01.NLEA\0" +"01.NMOV\0" +"11.NADDRESS\0" +"11..COM\0" +"11..NOT\0" +"11..UNARY_MINUS\0" +"11*NDEREF\0" +"11*N_PP\0" +"11*N_MM\0" +"11*NPP_\0" +"11*NMM_\0" +"21..SHL\0" +"21..SHR\0" +"21..POWER\0" +"21..MUL\0" +"21..DIV\0" +"21..MOD\0" +"21..AND\0" +"21..OR\0" +"21..XOR\0" +"21..ADD\0" +"21..SUB\0" +"21^.EQUAL_EQUAL\0" +"21^.NOT_EQUAL\0" +"21^.LESS\0" +"21^.GREATER\0" +"21^.LESS_EQUAL\0" +"21^.GREATER_EQUAL\0" +"21..AND_AND\0" +"21..OR_OR\0" +"21..XOR_XOR\0" +"31..COLON\0" +"00..QUESTION\0" +"21=NASSIGN\0" +"21=NSHL_EQUAL\0" +"21=NSHR_EQUAL\0" +"21=NMUL_EQUAL\0" +"21=NDIV_EQUAL\0" +"21=NAND_EQUAL\0" +"21=NOR_EQUAL\0" +"21=NXOR_EQUAL\0" +"21=NADD_EQUAL\0" +"21=NSUB_EQUAL\0" +"90..ADD_RSP\0" +"00..ENTER\0" +"00..LEAVE\0" +"00..RET\0" +"00.NCALL\0" +"00.NCALL_INDIRECT\0" +"00.NCALL_INDIRECT2\0" +"00.NIRQ\0" +"00..CLI\0" +"00..STI\0" +"00..DISABLE_CACHE\0" +"00..ENABLE_CACHE\0" +"00..WBINVD\0" +"00..INVD\0" +"00.NGET_FLAGS\0" +"10.NSET_FLAGS\0" +"00.NGET_BASE_PTR\0" +"10.NSET_BASE_PTR\0" +"00.NGET_STACK_PTR\0" +"10.NSET_STACK_PTR\0" +"10.NSET_RAX\0" +"20.NBT\0" +"20.NBTS\0" +"20.NBTR\0" +"20.NBTC\0" +"10.NBSF\0" +"10.NBSR\0" +"20.NINSQUE\0" +"20.NINSQUE_REV\0" +"10.NREMQUE\0" +"10.NSTRLEN\0" +"30.NMEMCPY\0" +"30.NMEMSET\0" +"10.NINPD\0" +"10.NINPW\0" +"10.NINP\0" +"20.NOUTPD\0" +"20.NOUTPW\0" +"20.NOUTP\0" +"00.NRDTSC\0" +"00..JMP\0" +"20..SWITCH\0" +"10..BR_ZERO\0" +"10..BR_NOT_ZERO\0" +"20..BR_NOT_EQUAL\0" +"20..BR_EQUAL_EQUAL\0" +"20..BR_GREATER_EQUAL\0" +"20..BR_LESS_EQUAL\0" +"20..BR_GREATER\0" +"20..BR_LESS\0" +"20..BR_OR_OR_ZERO\0" +"20..BR_OR_OR_NOT_ZERO\0" +"11=.SHL_CONST\0" +"11=.SHR_CONST\0" +"11=.ADD_CONST\0" +"11=.SUB_CONST\0" +"00=.PUSH_REGS\0" +"00=.POP_REGS\0" +"20..BR_BT\0" +"20..BR_BTS\0" +"20..BR_BTR\0" +"20..BR_BTC\0" +"20..BR_NOT_BT\0" +"20..BR_NOT_BTS\0" +"20..BR_NOT_BTR\0" +"20..BR_NOT_BTC\0" +"00..CALL_END2\0" +"20.NLBTS\0" +"20.NLBTR\0" +"20.NLBTC\0" +"20.NBR_LBTS\0" +"20.NBR_LBTR\0" +"20.NBR_LBTC\0" +"20.NBR_NOT_LBTS\0" +"20.NBR_NOT_LBTR\0" +"20.NBR_NOT_LBTC\0" +"20..BR_AND_AND_ZERO\0" +"20..BR_AND_AND_NOT_ZERO\0" +"20..BR_AND_ZERO\0" +"20..BR_AND_NOT_ZERO\0" +"21=NMOD_EQUAL\0" +"00.NCALL_EXTERN\0" +"10.NABSI8\0" +"01..PUSH_CMP\0" +"10.NPREEMPT\0" +); +} + +void FillCompilerTables() +{ + I1 *st; + U8 i,k; + U2 *u; + U4 *d4; + + assign_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); + deref_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); + cmp_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); + not_constant_bitmap=MAllocZ((EC_NUM_ENTRIES+7)>>3); + cmp_param_cnt=MAllocZ(EC_NUM_ENTRIES); + cmp_result_cnt=MAllocZ(EC_NUM_ENTRIES); + st=SysText("ST_INTERMEDIATE_CODE"); + for (i=0;i'; + u['/']='*'; + u[':']=256*TK_DOUBLE_COLON+':'; + u['<']=256*TK_LESS_EQUAL+'='; + u['=']=256*TK_EQUAL_EQUAL+'='; + u['>']=256*TK_GREATER_EQUAL+'='; + u['^']=256*TK_XOR_EQUAL+'='; + u['|']=256*TK_OR_OR+'|'; + u['%']=256*TK_MOD_EQUAL+'='; + + u=MAllocZ(sizeof(U2)*TK_NUM_TK); + duel_I1_tokens2=u; + u['&']=256*TK_AND_EQUAL+'='; + u['+']=256*TK_ADD_EQUAL+'='; + u['-']=256*TK_MINUS_MINUS+'-'; + u['/']='/'; + u['<']=256*TK_SHL+'<'; + u['>']=256*TK_SHR+'>'; + u['^']=256*TK_XOR_XOR+'^'; + u['|']=256*TK_OR_EQUAL+'='; + + u=MAllocZ(sizeof(U2)*TK_NUM_TK); + duel_I1_tokens3=u; + u['-']=256*TK_SUB_EQUAL+'='; + u['/']=256*TK_DIV_EQUAL+'='; + u['>']=256*TK_CAST+'<'; + +//$AN,"","OP_Precidence"$Here the operator precidences are +//defined. + d4=MAllocZ(sizeof(U4)*TK_NUM_TK); + unary_ops_table=d4; + d4['~']=0x10000+EC_COM; + d4['!']=0x10000+EC_NOT; + d4['-']=0x10000+EC_UNARY_MINUS; + d4['&']=0x10000+EC_ADDRESS; + d4['*']=0x10000+EC_DEREF; + + + d4=MAllocZ(sizeof(U4)*TK_NUM_TK); + binary_ops_table=d4; +//There is an exponential operator and +//shift instructions are rightfully +//the precidence of exponentials. + d4['`'] =0x20000+EC_POWER; + d4[TK_SHL] =0x20000+EC_SHL; + d4[TK_SHR] =0x20000+EC_SHR; + + d4['*'] =0x30000+EC_MUL; + d4['/'] =0x30000+EC_DIV; + d4['%'] =0x30000+EC_MOD; + +//$FG,2$&$FG$ is higher precidence $FG,2$|$FG$, like in logic + d4['&'] =0x40000+EC_AND; + + d4['|'] =0x50000+EC_OR; + d4['^'] =0x50000+EC_XOR; + + d4['+'] =0x60000+EC_ADD; + d4['-'] =0x60000+EC_SUB; + + d4[TK_EQUAL_EQUAL] =0x70000+EC_EQUAL_EQUAL; + d4[TK_NOT_EQUAL] =0x70000+EC_NOT_EQUAL; + d4['<'] =0x70000+EC_LESS; + d4['>'] =0x70000+EC_GREATER; + d4[TK_LESS_EQUAL] =0x70000+EC_LESS_EQUAL; + d4[TK_GREATER_EQUAL]=0x70000+EC_GREATER_EQUAL; + +//$FG,2$&&$FG$ is higher precidence $FG,2$||$FG$, like in logic + d4[TK_AND_AND] =0x80000+EC_AND_AND; + + d4[TK_OR_OR] =0x90000+EC_OR_OR; + d4[TK_XOR_XOR] =0x90000+EC_XOR_XOR; + + d4[':'] =0xA0000+EC_COLON; + d4['?'] =0xA0000+EC_QUESTION; + + d4['='] =0x100000+EC_ASSIGN; + d4[TK_SHL_EQUAL]=0x100000+EC_SHL_EQUAL; + d4[TK_SHR_EQUAL]=0x100000+EC_SHR_EQUAL; + d4[TK_MUL_EQUAL]=0x100000+EC_MUL_EQUAL; + d4[TK_DIV_EQUAL]=0x100000+EC_DIV_EQUAL; + d4[TK_MOD_EQUAL]=0x100000+EC_MOD_EQUAL; + d4[TK_AND_EQUAL]=0x100000+EC_AND_EQUAL; + d4[TK_OR_EQUAL] =0x100000+EC_OR_EQUAL; + d4[TK_XOR_EQUAL]=0x100000+EC_XOR_EQUAL; + d4[TK_ADD_EQUAL]=0x100000+EC_ADD_EQUAL; + d4[TK_SUB_EQUAL]=0x100000+EC_SUB_EQUAL; +} + +void InitCompiler(BoolU4 first) +{ + is_first_compiler=first; + cmp_do_not_write_to_disk=FALSE; + if (first) + ext[EXT_CMP_EXE_BLK]=&CmpParseExeBlk; + LoadCompileSysText; + FillCompilerTables; + MemSet(&opt_nop,0,sizeof(IntermediateCode)); + opt_nop.ic_class=sys_internal_types[IT_I8]; + + opt_nop.ic_opcode=EC_NOP; + LoadAsmHash(first); +} diff --git a/LT/Compiler/CmpMain.CPZ b/LT/Compiler/CmpMain.CPZ new file mode 100644 index 0000000..1370da3 --- /dev/null +++ b/LT/Compiler/CmpMain.CPZ @@ -0,0 +1,422 @@ +void CatchAll() +{ + I8 i; + if (Fs->except_argc>0) { + if (Fs->except_argv[0]except_argv[0],"ST_EXCEPT_TYPES"); + if (Fs->except_argv[0]==EXCEPT_UNDEF_SYSTEXT) + PrintF("Name:'%s'\r\n",Fs->except_argv[1]); + else if (Fs->except_argv[0]==EXCEPT_ARITHMETIC) + PrintF("Address:%P\r\n",Fs->except_argv[1]); + else if (Fs->except_argv[0]==EXCEPT_FLOATING) + PrintF("Address:%P\r\n",Fs->except_argv[1]); + else { + for (i=1;iexcept_argc;i++) + cout Fs->except_argv[i]," "; + CrLf; + } + } else { + cout "Exception:"; + for (i=1;iexcept_argc;i++) + cout Fs->except_argv[i]," "; + CrLf; + } + } else + coutln "Generic Exception"; + Fs->catch_except=TRUE; +} + + +void ExePutS(I1 *st) +//Inserts text into the stream of +//characters being compiled. Called +//from withing $FG,2$#exe{}$FG$ block. +{ + LexStruct *lx=Fs->last_lex; + ExeBlkStruct *tempe=lx->last_exe_blk; + if (tempe!=&lx->next_exe_blk) + tempe->body=Add2Str(tempe->body,st); + else + PrintFErr("No exe{} blk\r\n"); +} + +void ExePrintF(I1 *src,...) +//Inserts text into the stream of +//characters being compiled. Called +//from withing $FG,2$#exe{}$FG$ block. +{ + I1 *buf=SPrintFJoin(NULL,src,argc,argv); + ExePutS(buf); + Free(buf); +} + +U1 *CompileStatement(LexStruct *lx,U8 *type=NULL) +{ + U8 *result=INVALID_PTR; + AsmCtrlStruct *a=lx->a; + U8 size,i,j,k; + DbgInfo *dbg=NULL; + IntermediateCode *tempi; + if (type) *type=IT_I8; + Btr(&lx->flags,LFf_OPT_TRACE_PRESENT); + CbInitOutPtrs(&lx->cb); + CbAddIc(lx,EC_RETURN_START,0,sys_internal_types[IT_I8]); + tempi=lx->cb.cb_last_out_ptr; + if (!CmpParseStatement(lx,NULL)) { + if (tempi!=lx->cb.cb_last_out_ptr) { + CbAddIc(lx,EC_RETURN_END,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_RET,0,0); + CbAddIc(lx,EC_NULL,0,0); + if (result=CbCompile(lx,NULL,&size,&dbg,type)) { + if (a) { + j=a->ip; + k=(size+7)>>3; + for (i=0;icb.cb_out_first); + } else + DelLinkedList(lx->cb.cb_out_first); + Free(dbg); + return result; +} + + +ExeStruct *CompileBuf(U1 *buf,I1 *map_name=NULL, + I8 *error_cnt=NULL, I8 *warning_cnt=NULL,I1 mapfile_drive=0) +{ + BoolU4 okay=TRUE; + LexStruct *lx; + AsmCtrlStruct *a; + U8 i,j; + ExeStruct *result=NULL; + AsmCodeBlk *tempc; + ExeImportExportStruct *tempe,*tempe1; + + if (!is_first_compiler) + coutln "$$FG PURPLE$$**** Not First Compiler ****$$FG$$"; + + result=MAllocZ(sizeof(ExeStruct)); + lx=LexNew(buf,LF_DONT_FREE_BUFFER,NULL); + InsQue(lx,Fs->last_lex); + + a=MAllocZ(sizeof(AsmCtrlStruct)); + a->code=MAllocZ(sizeof(AsmCodeBlk)); + a->local_hash=NewHashTable(16); + a->glbl_hash=NewHashTable(2048); + a->glbl_hash->next=asm_hash; + a->local_hash->next=a->glbl_hash; + + lx->a=a; + lx->hash_table_list=a->local_hash; + lx->define_hash_table=a->glbl_hash; + lx->local_hash_table=a->local_hash; + lx->glbl_hash_table=a->glbl_hash; + Lex(lx); +try { + while (lx->token!=TK_EOF) { + i=CompileStatement(lx); + if (i!=INVALID_PTR) { + tempe=MAlloc(sizeof(ExeImportExportStruct)); + tempe->type=EIE_MAIN; + tempe->ip=i; + tempe->str=NULL; + tempe->next=NULL; + tempe1=&result->ie; + while (tempe1->next) //TODO:This could be optimized + tempe1=tempe1->next; + tempe1->next=tempe; + } + } + ResolveGlbls(lx,result); +} catch { + if (Fs->except_argc>0) + if (Fs->except_argv[0]==EXCEPT_COMPILER) + Fs->catch_except=TRUE; + okay=FALSE; +} + RemQue(lx); + if (error_cnt) *error_cnt=lx->error_cnt; + if (warning_cnt) *warning_cnt=lx->warning_cnt; + if (!okay) { + //TODO free debug info and possibly classes + if (error_cnt) + if (*error_cnt<1) *error_cnt=1; + result=NULL; + } else { + if (map_name) + CallExtStr("HashRep",a->glbl_hash,HTT_ALL,map_name,"-r-p",mapfile_drive,NULL,NULL); + LexDel(lx); + DelHashTable(a->local_hash); + DelHashTable(a->glbl_hash); + + if (!a->num_code_U1s) + result->code=NULL; + else { + result->code=MAlloc(a->num_code_U1s); + result->code_U1s=a->num_code_U1s; + tempc=a->code; + j=0; + lx=a->num_code_U1s; + while (tempc) { + i=lx; + if (i>ASM_CODE_BLK_SIZE) + i=ASM_CODE_BLK_SIZE; + MemCpy(result->code+j,tempc->body,i); + j+=i; + lx-=i; + tempc=tempc->next; + } + } + DelLinkedList(a->code); + result->absolutes=a->absolutes; + Free(a); + } + return result; +} + + +I8 CompileFile(I1 *filename,I1 *map_name=NULL,I1 *out_name=NULL,I1 mapfile_drive=0) +{ + I1 *fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL; + ExeStruct *e; + U4 *dd; + U8 size=0; + U1 *header=MAlloc(0x20000),*ptr; + BinFileHeaderStruct *bfh; + U8 i,cnt=0,error_cnt=0,warning_cnt=0; + ExeImportExportStruct *tempe,*tempe1; + ExeAbsoluteAddressStruct *tempa,*tempa1; + + fbuf=DefaultExtension(filename,"SPZ"); + fbuf2=MSPrintF("#include \"%s\"",fbuf); + if (map_name) + fbuf3=DefaultExtension(map_name,"MPZ"); + e=CompileBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drive); + + if (e) { + ptr=header; + tempa=e->absolutes; + while (tempa) { + cnt++; + tempa=tempa->next; + } + if (cnt) { + *ptr++=EIE_ABSOLUTE_ADDRESS; + dd=ptr; + *dd=cnt; + ptr+=sizeof(U4); + *ptr++=0; + tempa=e->absolutes; + while (tempa) { + tempa1=tempa->next; + dd=ptr; + *dd=tempa->ip; + ptr+=sizeof(U4); + Free(tempa); + tempa=tempa1; + } + } + tempe=e->ie; + while (tempe) { + tempe1=tempe->next; + *ptr++=tempe->type; + dd=ptr; + *dd=tempe->ip; + ptr+=sizeof(U4); + if (tempe->str) { + i=StrLen(tempe->str); + MemCpy(ptr,tempe->str,i+1); + Free(tempe->str); + ptr+=i+1; + } else + *ptr++=0; + Free(tempe); + tempe=tempe1; + } + *ptr++=EIE_END; + i=(ptr-header+15) & -0x10; + size=i+e->code_U1s+sizeof(BinFileHeaderStruct); + bfh=MAlloc(size); + MemCpy(bfh+e->code_U1s+sizeof(BinFileHeaderStruct),header,i); + MemCpy(bfh+sizeof(BinFileHeaderStruct),e->code,e->code_U1s); + bfh->jmp=0xE9+256*(16-3); + bfh->type=0; + bfh->header_offset=e->code_U1s+sizeof(BinFileHeaderStruct); + bfh->file_size=size; + bfh->xsum=LT_XSUM; + bfh->xsum=ArcCheckSum(bfh,size); + Free(fbuf2); + if (out_name) + fbuf2=DefaultExtension(out_name,"BIZ"); + else + fbuf2=ChangeExtension(fbuf,"BIZ"); + if (!cmp_do_not_write_to_disk) + WriteFile(fbuf2,bfh,size); + Free(bfh); + Free(e->code); + Free(e); + } + Free(header); + Free(fbuf); + Free(fbuf2); + Free(fbuf3); + PrintF(SysText("ST_ERRORS_WARNINGS"),error_cnt,warning_cnt,size); + return error_cnt; +} + +I8 ExecuteCmdLine(LexStruct *lx) +{ + I8 result=0,i,type; + I1 *ptr,*ptr2,*ptr3; + U1 *code; + LtfEntry *cl; + Ltf *l; + while (lx->token && + (lx->token!='}' || !(lx->flags & LF_EXE_BLK)) ) { + if (!Bt(&Fs->task_flags,TSSf_DONT_CHANGE_DESC)) { + ptr2=&Fs->task_descriptor; + ptr3=ptr2+TSS_DESC_LENGTH; + if (lx->cur_lfn->flags & LFSF_IS_LTF) { + cl=lx->cur_lfn->line_start; + l=lx->cur_lfn->l; + while (cl!=l && ptr2btype && ptr2display; + while (*ptr && ptr2next; + } + } else + if (ptr=lx->cur_lfn->line_start) + MemCpy(ptr2,ptr,TSS_DESC_LENGTH); + } + code=CompileStatement(lx,&type); + if (code!=INVALID_PTR) { + result=Call(code); + for (i=6;i>=0;i--) { + Fs->answers[i+1]=Fs->answers[i]; + Fs->double_answers[i+1]=Fs->double_answers[i]; + Fs->answers_types[i+1]=Fs->answers_types[i]; + } + Fs->answers[0]=result; + Fs->double_answers[0]=result><(double); + Fs->answers_types[0]=type; + Free(code); + } + } + return result; +} + +void ContinueUserTask() +{ + LexStruct *lx; + while (TRUE) { + lx=LexNew(NULL,LF_PROMPT,NULL); + InsQue(lx,Fs->last_lex); + try { + Lex(lx); + ExecuteCmdLine(lx); + RemQue(lx); + LexDel(lx); //TODO: Sometimes crashes on BREAK + } catch + CatchAll; + } +} + + +I1 *CmpMGetS() +{ + I1 buf[512]; + GetS(buf,512,FALSE); + return NewStr(buf); +} + +void CmpDebugger() +{ + LBts(&sys_semas[SYS_SEMA_IN_DEBUGGER],0); + Fs->task_flags&=~(1<last_lex); + try { + Lex(lx); + result=ExecuteCmdLine(lx); + } catch { + if (Fs->except_argc>0) { + if (Fs->except_argv[0]==EXCEPT_COMPILER || + Fs->except_argv[0]==EXCEPT_BREAK) { + Fs->catch_except=TRUE; + okay=FALSE; + result=0; + } + } + } + RemQue(lx); + if (okay) + LexDel(lx); //TODO: can crash + return result; +} + +I8 ExecuteFile(I1 *name) +{ + I8 result; + I1 *name2=DefaultExtension(name,"CPZ"); + I1 *st=MSPrintF("#include \"%s\";",name2); + result=ExecuteStr(st,name); + Free(st); + Free(name2); + return result; +} + +#define ADAM_STARTUP_NAME "/LT/OSMain/AdamK.APZ" +void AdamStartUpFile() +{ + BoolU4 okay=TRUE; + LexStruct *lx=LexNew(ReadTextFile(ADAM_STARTUP_NAME),0, + NewStr(ADAM_STARTUP_NAME)); + InsQue(lx,Fs->last_lex); + ext[EXT_SPRINTF_JOIN]=&SPrintFJoin2; + ext[EXT_GETF_JOIN]=&GetFJoin2; + ext[EXT_EXECUTE_FILE]=&ExecuteFile; + ext[EXT_EXECUTE_STR]=&ExecuteStr; + ext[EXT_DEBUGGER]=&CmpDebugger; + InitCompiler(TRUE); + Bts(&lx->flags,LF_ECHO); +//Continues Here $LK,"/LT/OSMain/AdamK.APZ","FL:/LT/OSMain/AdamK.APZ,1"$ + try { + Lex(lx); + ExecuteCmdLine(lx); + RemQue(lx); + LexDel(lx); //TODO + } catch { + CatchAll; + okay=FALSE; + } + if (!okay) + Debugger; +} diff --git a/LT/Compiler/Code.CPZ b/LT/Compiler/Code.CPZ new file mode 100644 index 0000000..8fd1667 --- /dev/null +++ b/LT/Compiler/Code.CPZ @@ -0,0 +1,2452 @@ +$WW,1$/*$FG,5$$TX+CX,"Intermediate Code"$ +$TX+CX,"To"$ +$TX+CX,"Machine Code"$ +$FG$ +$FG,2$RAX$FG$,$FG,2$RBX$FG$,$FG,2$RCX$FG$ and $FG,2$RDX$FG$ can be trashed by each intermediate code's output code. However, intermediate codes must be coupled together based on the parameter and result type specifications in the $LK,"IcParam","MN:IcParam"$. $FG,2$RAX$FG$ is the most common register for coupling intermediate codes. + +Internal calculations take place on 64-bit values, so anything which has found it's way into a register has been sign or zero extended to 64-bits. However, calculations can lead to range violations. Performance can be boosted if you avoid causing this situation in your code. The $LK,"OPTf_IGNORE_OVERFLOW","MN:OPTf_IGNORE_OVERFLOW"$ flag sent to $LK,"OptOn","MN:OptOn"$() will make the compiler assume no range violations will occur. Since, I have the power of creating standards for this language, I should probably just mandate that nobody assume range restrictions for less than 64-bit variables will be enforced through-out intermediate calculations, but I want to try not to break with $FG,2$C$FG$ standards unless it's way better. I'm planning to make my code $LK,"OPTf_IGNORE_OVERFLOW","MN:OPTf_IGNORE_OVERFLOW"$ compliant. + +The $LK,"IcMov","MN:IcMov"$() routine is commonly used. It needs a register for zero-extensions when dealing with U4's and when shuffling things around. I try to use the $FG,2$RBX$FG$ register as a scratch register available for sub-intermediate codes to trash. Don't assume $FG,2$RBX$FG$ will be preserved by $LK,"IcMov","MN:IcMov"$() or other sub-intermediate code routines. If you are not calling such routines, you can use it. + +You might get away with returning a value from a $UL,1$sub$UL,0$intermediate code helper routine in $FG,2$RBX$FG$, but maybe not because it has to zero-extend $FG,2$U4$FG$'s and I know no way besides XORing ahead and moving a $FG,2$U4$FG$ in, which requires two registers. + + + + +Code size changing during passes could cause problems. Jumps will be shortened (not lengthened) on successive passes and contraction does not hurt jumps, but contraction can hurt a glbl displacement. I decided all code must reside in the lowest 2Gig allowing 32-bit relative addressing for $FG,2$CALLS$FG$ and $FG,2$JMPS$FG$. To allow code beyond 2Gig, indirect calls and jmps could be used. (Load a 64-bit value in a register and call the register.) + +*/$WW,0$ + +void IcU1(IntermediateCode *tempi,U1 b) +{ + if (tempi->ic_cnt>=IC_BODY_SIZE-1|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=b; + } else + tempi->ic_body[tempi->ic_cnt++]=b; +} + +void IcRex(IntermediateCode *tempi,U1 b) +{ + if (b) { + if (tempi->ic_cnt>=IC_BODY_SIZE-1|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=b; + } else + tempi->ic_body[tempi->ic_cnt++]=b; + } +} + +void Ic66Rex(IntermediateCode *tempi,U1 b) +{ + if (!b) { + if (tempi->ic_cnt>=IC_BODY_SIZE-1|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=0x66; + } else + tempi->ic_body[tempi->ic_cnt++]=0x66; + } else { + if (tempi->ic_cnt>=IC_BODY_SIZE-2|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=0x66; + tempi->ic_ext_body[tempi->ic_cnt++]=b; + } else { + tempi->ic_body[tempi->ic_cnt++]=0x66; + tempi->ic_body[tempi->ic_cnt++]=b; + } + } +} + +void IcU2(IntermediateCode *tempi,U2 w) +{ + if (tempi->ic_cnt>=IC_BODY_SIZE-2|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=w.u1[0]; + tempi->ic_ext_body[tempi->ic_cnt++]=w.u1[1]; + } else { + tempi->ic_body[tempi->ic_cnt++]=w.u1[0]; + tempi->ic_body[tempi->ic_cnt++]=w.u1[1]; + } +} + +void IcU3(IntermediateCode *tempi,U4 d) +{ + if (tempi->ic_cnt>=IC_BODY_SIZE-3|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + tempi->ic_ext_body[tempi->ic_cnt++]=d.u1[0]; + tempi->ic_ext_body[tempi->ic_cnt++]=d.u1[1]; + tempi->ic_ext_body[tempi->ic_cnt++]=d.u1[2]; + } else { + tempi->ic_body[tempi->ic_cnt++]=d.u1[0]; + tempi->ic_body[tempi->ic_cnt++]=d.u1[1]; + tempi->ic_body[tempi->ic_cnt++]=d.u1[2]; + } +} + +void IcU4(IntermediateCode *tempi,U4 d) +{ + U4 *dd; + if (tempi->ic_cnt>=IC_BODY_SIZE-4|| tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + dd=&tempi->ic_ext_body[tempi->ic_cnt]; + } else { + dd=&tempi->ic_body[tempi->ic_cnt]; + } + *dd=d; + tempi->ic_cnt+=4; +} + +void IcU8(IntermediateCode *tempi,U8 q) +{ + U8 *qq; + if (tempi->ic_cnt>=IC_BODY_SIZE-8 || tempi->ic_ext_body) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + qq=&tempi->ic_ext_body[tempi->ic_cnt]; + } else + qq=&tempi->ic_body[tempi->ic_cnt]; + *qq=q; + tempi->ic_cnt+=8; +} + +void IcCopyIrq(IntermediateCode *tempi,U8 op) +{ + U1 *ptr; + I8 i; + ptr=sys_irq_vectors[op]; + i=sys_irq_vectors[op+1]-2-ptr; //sub 2 because IRET + if (tempi->ic_cnt+i>=IC_BODY_SIZE) { + if (!tempi->ic_ext_body) { + tempi->ic_ext_body=MAlloc(256); + MemCpy(tempi->ic_ext_body,tempi->ic_body,tempi->ic_cnt); + } + MemCpy(&tempi->ic_ext_body[tempi->ic_cnt],ptr,i); + } else + MemCpy(&tempi->ic_body[tempi->ic_cnt],ptr,i); + tempi->ic_cnt+=i; +} + +extern void IcMov(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,U8 t2,U8 r2,I8 d2,I8 ip); + +U8 IcModr(U8 r,U8 t2,U8 r2,I8 d2) +{ + //result.u[0] is type 0=[REG],1=disp8[REG],2=disp32[REG],3=REG,4=RIP_REL + //result.u[1] is REX + //result.u[2] is ModR + U8 result=0; + if (t2&IT_MASK7) { + result.u1[1]+=4; + r&=7; + } + if (t2&TY_MASK==TY_RIP_DISP32) { + result.u1[2]=0x05+r<<3; + result.u1[0]=4; + if (result.u1[1]==0x40 && + (t2&IT_MASK>=IT_I2 || + r<4)) + result.u1[1]=0; + } else { + if (r2>7) { + result.u1[1]++; + r2&=7; + } + if (t2&TY_MASK==TY_REG) { + result.u1[2]=0xC0+r<<3+r2; + result.u1[0]=3; + if (result.u1[1]==0x40 && + (t2&IT_MASK>=IT_I2 || + (r<4 && r2<4))) + result.u1[1]=0; + } else if (t2&TY_MASK==TY_DISP) { + if (!d2) { + result.u1[2]=r<<3+r2; + result.u1[0]=0; + } else if (MIN_I1<=d2<=MAX_I1) { + result.u1[2]=0x40+r<<3+r2; + result.u1[0]=1; + } else { + result.u1[2]=0x80+r<<3+r2; + result.u1[0]=2; + } + if (result.u1[1]==0x40 && + (t2&IT_MASK>=IT_I2 || + r<4)) + result.u1[1]=0; + } + } + return result; +} + +#define SLASH_OP_INC 0xFFFE00 +#define SLASH_OP_DEC 0xFFFE01 +#define SLASH_OP_NOT 0xF7F602 +#define SLASH_OP_NEG 0xF7F603 +#define SLASH_OP_MUL 0xF7F604 +#define SLASH_OP_MOV 0x898800 + +void IcSlashOp(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,U8 op,I8 ip) +{ + I8 i=IcModr(op.u1[0],t1,r1,d1); + switch (t1&IT_MASK) { + case IT_I1: + case IT_U1: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+op.u1[1]); + break; + case IT_I2: + case IT_U2: + Ic66Rex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+op.u1[2]); + break; + default: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+op.u1[2]); + } + if (i.u1[0]==1) + IcU1(tempi,d1); + else if (i.u1[0]==2) + IcU4(tempi,d1); + else if (i.u1[0]==4) { + IcU4(tempi,d1-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } +} + +void IcPush(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,I8 ip) +{ + U8 i; + IntermediateCode *tempi_last=tempi-sizeof(IntermediateCode); + switch (t1>>4) { + case TY_REG>>4: + if (t1&IT_MASK7) + IcU2(tempi,0x5049+(r1&7)<<8); + else + IcU2(tempi,0x5048+r1<<8); + } + break; + case TY_IMM>>4: + if (MIN_I1<=d1<=MAX_I1) + IcU3(tempi,0x6A48+d1<<16); + else if (MIN_I4<=d1<=MAX_I4) { + IcU2(tempi,0x6848); + IcU4(tempi,d1); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,t1,r1,d1,ip); + IcU2(tempi,0x5048+CREG_RBX<<8); + } + break; + case TY_DISP>>4: + i=0x48; + switch (t1&IT_MASK) { + case IT_I8: + case IT_U8: + case IT_DOUBLE: + if (r1>7) { + i++; + r1&=7; + } + if (!d1) + IcU3(tempi,0x30FF00+r1<<16+i); + else if (MIN_I1<=d1<=MAX_I1) { + IcU3(tempi,0x70FF00+r1<<16+i); + IcU1(tempi,d1); + } else { + IcU3(tempi,0xB0FF00+r1<<16+i); + IcU4(tempi,d1); + } + break; + default: + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,t1,r1,d1,ip); + IcU2(tempi,0x5048+CREG_RBX<<8); + } + break; + case TY_RIP_DISP32>>4: + switch (t1&IT_MASK) { + case IT_I8: + case IT_U8: + case IT_DOUBLE: + IcU3(tempi,0x35FF48); + IcU4(tempi,d1-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + default: + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,t1,r1,d1,ip); + IcU2(tempi,0x5048+CREG_RBX<<8); + } + break; + default: + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,t1,r1,d1,ip); + IcU2(tempi,0x5048+CREG_RBX<<8); + break; + } +} + +void IcPushRegs(IntermediateCode *tempi,U8 mask) +{ + I8 i; + for (i=0;i7) + IcU2(tempi,0x5049+(i&7)<<8); + else + IcU2(tempi,0x5048+i<<8); + } + } +} + +void IcPop(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,I8 ip) +{ + switch (t1>>4) { + case TY_REG>>4: + if (r1>7) + IcU2(tempi,0x5849+(r1&7)<<8); + else + IcU2(tempi,0x5848+r1<<8); + break; + case TY_NULL>>4: + break; + default: + IcU2(tempi,0x5848+CREG_RBX<<8); + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RBX,0,ip); + } +} + +void IcPopRegs(IntermediateCode *tempi,U8 mask) +{ + I8 i; + for (i=NUM_REGS-1;i>=0;i--) { + if (Bt(&mask,i)) { + if (i>7) + IcU2(tempi,0x5849+(i&7)<<8); + else + IcU2(tempi,0x5848+i<<8); + } + } +} + +void IcZero(IntermediateCode *tempi,U8 r) +{ + if (r>7) { + r&=7; + IcU3(tempi,0xC0334D+r<<16+r<<19); + } else + IcU2(tempi,0xC033+r<<8+r<<11); +} + +void IcOr(IntermediateCode *tempi,U8 r) +{ + U8 i=0xC00B48; //OR R,R + if (r>7) { + i+=5; + r&=7; + } + IcU3(tempi,i+r<<16+r<<19); +} + + +void IcMov(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,U8 t2,U8 r2,I8 d2,I8 ip) +{ + I8 i,last_cnt=tempi->ic_cnt; + BoolU4 copy_from_rbx; + switch (t1>>4) { + case TY_REG>>4: + if (t2&TY_MASK==TY_IMM) { + if (!d2) + IcZero(tempi,r1); + else if (d2>=0 && d2<=MAX_U1) { + IcZero(tempi,r1); + if (r1>7) + IcU3(tempi,d2<<16+(0xB0+r1&7)<<8+0x41); + else + IcU3(tempi,d2<<16+(0xB0+r1)<<8+0x40); + } else if (MIN_I1<=d2<=MAX_I1) { + if (r1>7) { + r1&=7; + IcU3(tempi,d2<<16+(0xB0+r1)<<8+0x41); + IcU4(tempi,0xC0BE0F4D+r1<<24+r1<<27); + } else { + IcU3(tempi,d2<<16+(0xB0+r1)<<8+0x40); + IcU4(tempi,0xC0BE0F48+r1<<24+r1<<27); + } + } else if (MIN_I4<=d2<=MAX_I4) { + if (r1>7) { + r1&=7; + IcU2(tempi,(0xB8+r1)<<8+0x41); + IcU4(tempi,d2); + IcU3(tempi,0xC0634D+r1<<16+r1<<19); + } else { + IcU2(tempi,(0xB8+r1)<<8+0x40); + IcU4(tempi,d2); + IcU3(tempi,0xC06348+r1<<16+r1<<19); + } + } else if (d2>=0 && d2<=MAX_I4) { + IcZero(tempi,r1); + if (r1>7) { + IcU2(tempi,(0xB8+r1&7)<<8+0x41); + IcU4(tempi,d2); + } else { + IcU2(tempi,(0xB8+r1)<<8+0x40); + IcU4(tempi,d2); + } + } else { + i=0xB848; + if (r1>7) { + i++; + r1&=7; + } + IcU2(tempi,i+r1<<8); + IcU8(tempi,d2); + } + } else if (t2&TY_MASK==TY_STK) + IcPop(tempi,t1,r1,d1,ip); + else { + if (r1==r2) { + if (t2&TY_MASK==TY_REG) + if (t2&IT_MASK>=IT_I8) + return; + else + if (GetOpt(OPTf_IGNORE_OVERFLOW)) + return; + } + if (t2&TY_MASK==TY_REG) { + if (GetOpt(OPTf_IGNORE_OVERFLOW)) + t2=TY_REG+IT_I8; + if (t1&TY_MASK==TY_REG) { + i=tempi->ic_cnt; + if (tempi->ic_last_cnt==i-3 && i>=3) { + if (tempi->ic_body[i-2]==0x8B) + if (tempi->ic_body[i-1]==0xC0+(r1&7)+(r2&7)<<3) + if (tempi->ic_body[i-3]==0x48+((r2>7)?4:0)+((r1>7)?1:0) ) + return; + } + } + } + i=IcModr(r1,t2,r2,d2); + if (t2&IT_MASK==IT_U4) { + if (r1!=r2) { + IcZero(tempi,r1); + copy_from_rbx=FALSE; + } else { + IcZero(tempi,CREG_RBX); + copy_from_rbx=TRUE; + i=IcModr(CREG_RBX,t2,r2,d2); + } + } else + i|=0x4800; + IcRex(tempi,i.u1[1]); + switch (t2&IT_MASK) { + case IT_I1: + IcU3(tempi,i.u1[2]<<16+0xBE0F); + break; + case IT_I2: + IcU3(tempi,i.u1[2]<<16+0xBF0F); + break; + case IT_I4: + IcU2(tempi,i.u1[2]<<8+0x63); + break; + + case IT_U1: + IcU3(tempi,i.u1[2]<<16+0xB60F); + break; + case IT_U2: + IcU3(tempi,i.u1[2]<<16+0xB70F); + break; + case IT_U4: + IcU2(tempi,i.u1[2]<<8+0x8B); + if (i.u1[0]==1) + IcU1(tempi,d2); + else if (i.u1[0]==2) + IcU4(tempi,d2); + else if (i.u1[0]==4) { + IcU4(tempi,d2-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + if (copy_from_rbx) { + if (r1>7) + IcU3(tempi,0xC38B4C+(r1&7)<<19); + else + IcU3(tempi,0xC38B48+r1<<19); + } + i=0; // no further disp + break; + default: + IcU2(tempi,i.u1[2]<<8+0x8B); + break; + } + if (i.u1[0]==1) + IcU1(tempi,d2); + else if (i.u1[0]==2) + IcU4(tempi,d2); + else if (i.u1[0]==4) { + IcU4(tempi,d2-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + } + break; + case TY_STK>>4: + if (t1&IT_MASK>4: + case TY_RIP_DISP32>>4: + if (t2&TY_MASK==TY_IMM && + (t1&IT_MASKic_cnt+4); + switch (t1&IT_MASK) { + case IT_I1: + case IT_U1: + i--; + break; + case IT_I2: + case IT_U2: + i-=2; + break; + default: + i-=4; + } + IcU4(tempi,i); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + switch (t1&IT_MASK) { + case IT_I1: + case IT_U1: + IcU1(tempi,d2); + break; + case IT_I2: + case IT_U2: + IcU2(tempi,d2); + break; + default: + IcU4(tempi,d2); + break; + } + } else { + if (t2&TY_MASK==TY_REG) + IcSlashOp(tempi,t1,r1,d1,r2+SLASH_OP_MOV,ip); + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,t2,r2,d2,ip); + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RBX,0,ip); + } + } + break; + } + tempi->ic_last_cnt=last_cnt; +} + +void IcLea(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1,U8 t2,U8 r2,I8 d2,I8 ip) +{ + I8 i; + if (t1&TY_MASK==TY_REG) { + i=IcModr(r1,t2,r2,d2); + i.u1[1]|=0x48; + IcU3(tempi,i.u1[2]<<16+0x8D00+i.u1[1]); + if (i.u1[0]==1) + IcU1(tempi,d2); + else if (i.u1[0]==2) + IcU4(tempi,d2); + else if (i.u1[0]==4) { + IcU4(tempi,d2-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + } else { + IcLea(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RCX,0,ip); + } +} + +void IcDeref(IntermediateCode *tempi,I8 ip) +{ + I8 t; + t=tempi->r.type&IT_MASK; + if (t>tempi->p1.ptype) + t=tempi->p1.ptype; + + if (tempi->p1.type&TY_MASK==TY_REG) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_DISP+t,tempi->p1.reg,tempi->p1.disp,ip); + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_DISP+t,CREG_RCX,0,ip); + } +} + +void IcAddEct(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1, + U8 t2,U8 r2,I8 d2,U8 t3,U8 r3,I8 d3,U8 op,I8 ip) +{ + I8 i=0x48; + if (t2&TY_MASK==TY_DISP && + t2&IT_MASK>=IT_I8 && + r2!=CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + if (r2>7) { + i++; + r2&=7; + } + if (!d2) { + IcU3(tempi,0x000000+i+r2<<16+op<<8); + } else if (MIN_I1<=d2<=MAX_I1) { + IcU3(tempi,0x400000+i+r2<<16+op<<8); + IcU1(tempi,d2); + } else { + IcU3(tempi,0x800000+i+r2<<16+op<<8); + IcU4(tempi,d2); + } + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + r2=CREG_RCX; + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + if (t2&TY_MASK!=TY_REG || t2&IT_MASK7) { + i++; + r2&=7; + } + IcU3(tempi,0xC00000+i+r2<<16+op<<8); + } + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcAddConst(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1, + U8 t2,U8 r2,I8 d2,I8 disp,U8 op,I8 ip) +{ + I8 i,r; + if (op.u1[0]==0x2B) { + op=0x0003; + disp=-disp; + } + if (t1&TY_MASK==TY_REG) { + if (t2&TY_MASK!=TY_REG) { + IcMov(tempi,t1,r1,d1,t2,r2,d2,ip); + t2=t1; + r2=r1; + d2=d1; + } + if (r1==r2) { + if (r1>7) + i=0x49; + else + i=0x48; + if (!disp && + (op.u1[0]==0x03||op.u1[0]==0x2B|| + op.u1[0]==0x33||op.u1[0]==0x0B)) + return; + else if (disp==1 && op.u1[0]==0x03) { + IcU3(tempi,0xC0FF00+op.u1[1]<<19+i+(r1&7)<<16); + return; + } else if (disp==-1 && op.u1[0]==0x03) { + IcU3(tempi,0xC8FF00+i+(r1&7)<<16); + return; + } else if (MIN_I1<=disp<=MAX_I1) { + IcU3(tempi,0xC08300+op.u1[1]<<19+i+(r1&7)<<16); + IcU1(tempi,disp); + return; + } else if (MIN_I4<=disp<=MAX_I4) { + IcU3(tempi,0xC08100+op.u1[1]<<19+i+(r1&7)<<16); + IcU4(tempi,disp); + return; + } + } + if (op.u1[0]==0x03 && MIN_I4<=disp<=MAX_I4 && + !Bt(&non_ptr_vars_mask,r2)) { + i=IcModr(r1,TY_DISP+IT_I8,r2,disp); + i.u1[1]|=0x48; + IcU3(tempi,i.u1[2]<<16+0x8D00+i.u1[1]); + if (i.u1[0]==1) + IcU1(tempi,disp); + else if (i.u1[0]==2) + IcU4(tempi,disp); + else if (i.u1[0]==4) { + IcU4(tempi,disp-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + return; + } + } + switch (t1>>4) { + case TY_REG>>4: + case TY_DISP>>4: + case TY_RIP_DISP32>>4: + if (t1!=t2 || r1!=r2 || d1!=d2) { + IcMov(tempi,t1,r1,d1,t2,r2,d2,ip); + t2=t1; + r2=r1; + d2=d1; + } + + if (!disp && + (op.u1[0]==0x03||op.u1[0]==0x2B|| + op.u1[0]==0x33||op.u1[0]==0x0B)) + return; + r=op.u1[1]; + if (op.u1[0]==0x03 && disp==-1) + r=1; + + if (op.u1[0]==0x03 && (disp==1 || disp==-1)) { + i=IcModr(r,t1,r1,d1); + switch (t1&IT_MASK) { + case IT_I1: + case IT_U1: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0xFE); + break; + case IT_I2: + case IT_U2: + Ic66Rex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0xFF); + break; + default: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0xFF); + break; + } + if (i.u1[0]==1) + IcU1(tempi,d1); + else if (i.u1[0]==2) + IcU4(tempi,d1); + else if (i.u1[0]==4) { + IcU4(tempi,d1-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + return; + } + if (MIN_I1<=disp<=MAX_I1 || + t1&IT_MASK==IT_I1 || + t1&IT_MASK==IT_U1) { + i=IcModr(r,t1,r1,d1); + switch (t1&IT_MASK) { + case IT_I1: + case IT_U1: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0x80); + break; + case IT_I1: + case IT_U1: + Ic66Rex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0x83); + break; + default: + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0x83); + break; + } + if (i.u1[0]==1) + IcU1(tempi,d1); + else if (i.u1[0]==2) + IcU4(tempi,d1); + else if (i.u1[0]==4) { + IcU4(tempi,d1-(ip+tempi->ic_cnt+5)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + IcU1(tempi,disp); + return; + } + if (MIN_I4<=disp<=MAX_I4 || + t1&IT_MASKic_cnt+6)); + else + IcU4(tempi,d1-(ip+tempi->ic_cnt+8)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + if (t1&IT_MASK==IT_U2 || + t1&IT_MASK==IT_I2) + IcU2(tempi,disp); + else + IcU4(tempi,disp); + return; + } + break; + case TY_STK>>4: + IcAddConst(tempi,TY_REG+IT_I8,CREG_RAX,0,t2,r2,d2,disp,op,ip); + IcPushRegs(tempi,1<=IT_I8) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + if (r3>7) { + i++; + r3&=7; + } + if (!d3) + IcU3(tempi,0x080000+i+r3<<16+op<<8); + else if (MIN_I1<=d3<=MAX_I1) { + IcU3(tempi,0x480000+i+r3<<16+op<<8); + IcU1(tempi,d3); + } else { + IcU3(tempi,0x880000+i+r3<<16+op<<8); + IcU4(tempi,d3); + } + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + if (t3&TY_MASK!=TY_REG || t3&IT_MASK7) { + i++; + r3&=7; + } + IcU3(tempi,0xC80000+i+r3<<16+op<<8); + } + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RCX,0,ip); +} + +void IcMul(IntermediateCode *tempi,I8 ip) +{ + I8 i,r2,r=CREG_RAX,j; + IcParam *p1,*p2; + if (tempi->p1.type&TY_MASK==TY_IMM) { + p1=&tempi->p2; + p2=&tempi->p1; + tempi->ic_flags|=ICF_P1_FIRST; + } else { + p1=&tempi->p1; + p2=&tempi->p2; + } + i=p2->disp; + if (!(tempi->ic_class->sub_type&1) && + p2->type&TY_MASK==TY_IMM && MIN_I4<=i<=MAX_I4) { + if (tempi->r.type==TY_REG+IT_I8) { + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,p1->type,p1->reg,p1->disp,ip); + r=tempi->r.reg; + } else + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p1->type,p1->reg,p1->disp,ip); + if (r>7) + j=0xC0004D; + else + j=0xC00048; + if (MIN_I1<=i<=MAX_I1) + IcU4(tempi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19); + else { + IcU3(tempi,0x6900+j+(r&7)<<16+(r&7)<<19); + IcU4(tempi,i); + } + } else { + if (tempi->ic_class->sub_type&1) + i=0xE0F748; + else + i=0xE8F748; + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,p1->type,p1->reg,p1->disp,ip); + r2=CREG_RCX; + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p2->type,p2->reg,p2->disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p2->type,p2->reg,p2->disp,ip); + if (p1->type&TY_MASK!=TY_REG || + p1->type&IT_MASKtype,p1->reg,p1->disp,ip); + r2=CREG_RCX; + } else + r2=p1->reg; + } + if (r2>7) { + i++; + r2&=7; + } + IcU3(tempi,i+r2<<16); + } + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,r,0,ip); +} + +void IcMulEqual(IntermediateCode *tempi,I8 ip) +{ + I8 i=tempi->p2.disp,r=CREG_RAX,j; + if (!(tempi->ic_class->sub_type&1) && + tempi->p2.type&TY_MASK==TY_IMM && MIN_I4<=i<=MAX_I4) { + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->p1.type==TY_REG+IT_I8) + r=tempi->p1.reg; + else + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + if (r>7) + j=0xC0004D; + else + j=0xC00048; + if (MIN_I1<=i<=MAX_I1) + IcU4(tempi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19); + else { + IcU3(tempi,0x6900+j+(r&7)<<16+(r&7)<<19); + IcU4(tempi,i); + } + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,r,0,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,TY_DISP+tempi->p1.ptype,CREG_RCX,0,ip); + r=CREG_RBX; + if (MIN_I1<=i<=MAX_I1) + IcU4(tempi,i<<24+0xDB6B48); + else { + IcU3(tempi,0xDB6948); + IcU4(tempi,i); + } + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RCX,0,TY_REG+IT_I8,CREG_RBX,0,ip); + } + } else { + if (tempi->ic_class->sub_type&1) + i=0xE3F748; + else + i=0xEBF748; + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } + IcU3(tempi,i); + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,TY_DISP+tempi->p1.ptype,CREG_RCX,0,ip); + IcU3(tempi,i); + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RCX,0,TY_REG+IT_I8,CREG_RAX,0,ip); + } + } + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,r,0,ip); +} + + +void IcDiv(IntermediateCode *tempi,I8 ip) +{ + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + if (tempi->ic_class->sub_type&1) { + IcZero(tempi,CREG_RDX); + IcU3(tempi,0xF1F748); + } else { + IcU2(tempi,0x9948); + IcU3(tempi,0xF9F748); + } + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcDivEqual(IntermediateCode *tempi,BoolU4 is_mod,I8 ip) +{ + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } + if (tempi->ic_class->sub_type&1) { + IcZero(tempi,CREG_RDX); + IcU3(tempi,0xF1F748); + } else { + IcU2(tempi,0x9948); + IcU3(tempi,0xF9F748); + } + if (is_mod) + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RDX,0,ip); + else + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcU3(tempi,0xD98748); //xchg bx,cx + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + //dangerous might trash RBX in Mov, but it doesn't + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,TY_DISP+tempi->p1.ptype,CREG_RBX,0,ip); + if (tempi->ic_class->sub_type&1) { + IcZero(tempi,CREG_RDX); + IcU3(tempi,0xF1F748); + } else { + IcU2(tempi,0x9948); + IcU3(tempi,0xF9F748); + } + if (is_mod) + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RBX,0,TY_REG+IT_I8,CREG_RDX,0,ip); + else + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RBX,0,TY_REG+IT_I8,CREG_RAX,0,ip); + } + if (tempi->r.type&TY_MASK) { + if (is_mod) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RDX,0,ip); + else + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); + } +} + +void IcMod(IntermediateCode *tempi,I8 ip) +{ + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + if (tempi->ic_class->sub_type&1) { + IcZero(tempi,CREG_RDX); + IcU3(tempi,0xF1F748); + } else { + IcU2(tempi,0x9948); + IcU3(tempi,0xF9F748); + } + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RDX,0,ip); +} + +void IcAddSubEctEqual(IntermediateCode *tempi,U8 ptype,U8 t1,U8 r1,I8 d1, + U8 t2,U8 r2,I8 d2,U8 t3,U8 r3,I8 d3,U8 op,I8 ip) +{ + BoolU4 done; + I8 result_reg,i; + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (t3&TY_MASK==TY_IMM) { + IcAddConst(tempi, + t2,r2,d2,t2,r2,d2,d3,op,ip); + if (t1&TY_MASK) + IcMov(tempi,t1,r1,d1,t2,r2,d2,ip); + return; + } else { + done=FALSE; + if (ptype>=IT_I8 && t3&IT_MASK>=IT_I8) { + if (t3&TY_MASK==TY_REG || + t3&TY_MASK==TY_DISP || + t3&TY_MASK==TY_RIP_DISP32) { + if (t2&TY_MASK==TY_REG) + result_reg=r2; + else { + result_reg=CREG_RCX; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2&TY_MASK+ptype,r2,d2,ip); + } + i=IcModr(result_reg,t3&TY_MASK+ptype,r3,d3); + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+op.u1[0]); + if (i.u1[0]==1) + IcU1(tempi,d3); + else if (i.u1[0]==2) + IcU4(tempi,d3); + else if (i.u1[0]==4) { + IcU4(tempi,d3-(ip+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + IcMov(tempi,t2&TY_MASK+ptype,r2,d2,TY_REG+IT_I8,result_reg,0,ip); + done=TRUE; + } + } + if (!done) { + if (tempi->ic_flags & ICF_P1_FIRST) { + if (t2&TY_MASK==TY_REG && r2!=CREG_RAX) { + result_reg=r2; + if (!GetOpt(OPTf_IGNORE_OVERFLOW)) + IcMov(tempi,TY_REG+IT_I8,result_reg,0, + TY_REG+ptype,result_reg,0,ip); + } else { + result_reg=CREG_RCX; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2&TY_MASK+ptype,r2,d2,ip); + } + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + if (t2&TY_MASK==TY_REG && r2!=CREG_RAX) { + result_reg=r2; + if (!GetOpt(OPTf_IGNORE_OVERFLOW)) + IcMov(tempi,TY_REG+IT_I8,result_reg,0, + TY_REG+ptype,result_reg,0,ip); + } else { + result_reg=CREG_RCX; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2&TY_MASK+ptype,r2,d2,ip); + } + } + if (result_reg>7) + IcU1(tempi,0x4C); + else + IcU1(tempi,0x48); + IcU2(tempi,0xC000+op.u1[0]+(result_reg&7)<<11); + IcMov(tempi,t2&TY_MASK+ptype,r2,d2,TY_REG+IT_I8,result_reg,0,ip); + } + } + } else { + done=FALSE; + if (t3&TY_MASK==TY_IMM && op.u1[2]) { + if (op.u1[2]==0x24) {//and + i=~d3; + if (!i.u4[1]) { + if (tempi->ic_flags&ICF_NO_DEPEND_RESULT && + t2&TY_MASK==TY_REG && 0>d3>=MIN_I1) { + IcSlashOp(tempi,TY_DISP+ptype,r2,0,0x838000+op.u1[4],ip); + IcU1(tempi,d3); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,TY_DISP+ptype,CREG_RCX,0,ip); + result_reg=CREG_RAX; + if (i.u2[1]) { + IcU2(tempi,op.u1[3]<<8+0x40); + IcU4(tempi,d3); + } else if (i.u1[1]) { + IcU3(tempi,op.u1[3]<<16+0x4066); + IcU2(tempi,d3); + } else { + IcU2(tempi,op.u1[2]<<8+0x40); + IcU1(tempi,d3); + } + IcMov(tempi,TY_DISP+ptype,CREG_RCX,0,TY_REG+IT_I8,result_reg,0,ip); + } + done=TRUE; + } + } else if (!d3.u4[1]) { //xor or + if (tempi->ic_flags&ICF_NO_DEPEND_RESULT && + t2&TY_MASK==TY_REG && d3><(U8)<=MAX_I1) { + IcSlashOp(tempi,TY_DISP+ptype,r2,0,0x838000+op.u1[4],ip); + IcU1(tempi,d3); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,TY_DISP+ptype,CREG_RCX,0,ip); + result_reg=CREG_RAX; + if (d3.u2[1]) { + IcU2(tempi,op.u1[3]<<8+0x40); + IcU4(tempi,d3); + } else if (d3.u1[1]) { + IcU3(tempi,op.u1[3]<<16+0x4066); + IcU2(tempi,d3); + } else { + IcU2(tempi,op.u1[2]<<8+0x40); + IcU1(tempi,d3); + } + IcMov(tempi,TY_DISP+ptype,CREG_RCX,0,TY_REG+IT_I8,result_reg,0,ip); + } + done=TRUE; + } + + } + if (!done) { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t3,r3,d3,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t2,r2,d2,ip); + } + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,TY_DISP+ptype,CREG_RCX,0,ip); + result_reg=CREG_RBX; + IcU1(tempi,0x48); + IcU2(tempi,0xC000+op.u1[0]+(result_reg&7)<<11); + IcMov(tempi,TY_DISP+ptype,CREG_RCX,0,TY_REG+IT_I8,result_reg,0,ip); + } + } + if (t1&TY_MASK) + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,result_reg,0,ip); +} + +void IcShift(IntermediateCode *tempi,U8 t1,U8 r1,I8 d1, + U8 t2,U8 r2,I8 d2,U8 t3,U8 r3,I8 d3,U8 us,U8 is,I8 ip) +{ + if (tempi->ic_class->sub_type&1 || tempi->ic_flags & ICF_USE_UNSIGNED) + is=us; + if (t3&TY_MASK==TY_IMM) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t2,r2,d2,ip); + IcU3(tempi,0x00C148+is<<16); + IcU1(tempi,d3); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t2,r2,d2,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t2,r2,d2,ip); + } + IcU3(tempi,0x00D348+is<<16); + } + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcShiftEqual(IntermediateCode *tempi,U8 ptype,U8 t1,U8 r1,I8 d1, + U8 t2,U8 r2,I8 d2,U8 t3,U8 r3,I8 d3,U8 us,U8 is,I8 ip) +{ + I8 result_reg; + if (tempi->ic_class->sub_type&1 || tempi->ic_flags & ICF_USE_UNSIGNED) + is=us; + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->ic_flags & ICF_P1_FIRST) { + if (t2&TY_MASK==TY_REG) { + result_reg=r2; + if (!GetOpt(OPTf_IGNORE_OVERFLOW)) + IcMov(tempi,TY_REG+IT_I8,result_reg,0, + TY_REG+ptype,result_reg,0,ip); + } else { + result_reg=CREG_RAX; + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t2&TY_MASK+ptype,r2,d2,ip); + } + if (t3&TY_MASK!=TY_IMM) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + } else { + if (t3&TY_MASK!=TY_IMM) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + if (t2&TY_MASK==TY_REG) { + result_reg=r2; + if (!GetOpt(OPTf_IGNORE_OVERFLOW)) + IcMov(tempi,TY_REG+IT_I8,result_reg,0, + TY_REG+ptype,result_reg,0,ip); + } else { + result_reg=CREG_RAX; + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,t2&TY_MASK+ptype,r2,d2,ip); + } + } + if (result_reg>7) + IcU1(tempi,0x49); + else + IcU1(tempi,0x48); + if (t3&TY_MASK==TY_IMM) { + IcU2(tempi,0x00C1+(is+result_reg&7)<<8); + IcU1(tempi,d3); + } else + IcU2(tempi,0x00D3+(is+result_reg&7)<<8); + IcMov(tempi,t2&TY_MASK+ptype,r2,d2,TY_REG+IT_I8,result_reg,0,ip); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,t2,r2,d2,ip); + if (t3&TY_MASK!=TY_IMM) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + } else { + if (t3&TY_MASK!=TY_IMM) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,t3,r3,d3,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,t2,r2,d2,ip); + } + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,TY_DISP+ptype,CREG_RDX,0,ip); + result_reg=CREG_RAX; + IcU1(tempi,0x48); + if (t3&TY_MASK==TY_IMM) { + IcU2(tempi,0x00C1+(is+result_reg&7)<<8); + IcU1(tempi,d3); + } else + IcU2(tempi,0x00D3+(is+result_reg&7)<<8); + IcMov(tempi,TY_DISP+ptype,CREG_RDX,0,TY_REG+IT_I8,result_reg,0,ip); + } + if (t1&TY_MASK) + IcMov(tempi,t1,r1,d1,TY_REG+IT_I8,result_reg,0,ip); +} + +void IcUnaries(IntermediateCode *tempi,U8 op,I8 ip) +{ + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcSlashOp(tempi,TY_REG+IT_I8,CREG_RAX,0,op,ip); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcNot(IntermediateCode *tempi,I8 ip) +{ + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcZero(tempi,CREG_RAX); + IcOr(tempi,CREG_RBX); + IcU2(tempi,0x0375); + IcU3(tempi,0xC0FF48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_U8,CREG_RAX,0,ip); +} + +void IcAndAnd(IntermediateCode *tempi,I8 ip) +{ + I8 i=0x48,r2; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + } + IcZero(tempi,CREG_RAX); + IcOr(tempi,r2); + IcU2(tempi,0x0874); + IcOr(tempi,CREG_RCX); + IcU2(tempi,0x0374); + IcU3(tempi,0xC0FF48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcOrOr(IntermediateCode *tempi,I8 ip) +{ + I8 i=0x48,r2; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + } + + if (r2>7) { + i++; + r2&=7; + } + IcZero(tempi,CREG_RAX); + IcU3(tempi,0xC80B00+i+r2<<16); + IcU2(tempi,0x0374); + IcU3(tempi,0xC0FF48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcXorXor(IntermediateCode *tempi,I8 ip) +{ + I8 i=0x48,r2; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + } + IcZero(tempi,CREG_RBX); + IcOr(tempi,r2); + IcU2(tempi,0x0374); + IcU3(tempi,0xC3FF48); + + IcZero(tempi,CREG_RAX); + IcOr(tempi,CREG_RCX); + IcU2(tempi,0x0374); + IcU3(tempi,0xC0FF48); + + IcU3(tempi,0xC33348); + + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcColon(IntermediateCode *tempi,I8 ip) +{ + I8 i=0x48,r2; + if (tempi->p1.type&TY_MASK==TY_REG && + tempi->p1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else if (tempi->p2.type&TY_MASK==TY_REG && + tempi->p2.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip); + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->p1.type&TY_MASK!=TY_REG || + tempi->p1.type&IT_MASKp1.type,tempi->p1.reg,tempi->p1.disp,ip); + r2=CREG_RDX; + } else + r2=tempi->p1.reg; + } + IcOr(tempi,r2); + IcU2(tempi,0x0374); + IcU3(tempi,0xC18B48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcCmp(IntermediateCode *tempi,U8 us,U8 is,I8 ip) +{ + I8 r1,d1,r2,i=0x48,j=tempi->p2.disp; + if (tempi->p2.type&TY_MASK==TY_IMM && MIN_I4<=j<=MAX_I4) { + if (!(tempi->ic_flags&(ICF_POP_CMP|ICF_PUSH_CMP|ICF_RCX_CMP|ICF_RCX_CMP2)) && + tempi->p1.type&TY_MASK==TY_DISP && + tempi->p1.type&IT_MASK>=IT_I8 && tempi->p1.reg!=CREG_RAX) { + r1=tempi->p1.reg; + d1=tempi->p1.disp; + IcZero(tempi,CREG_RAX); + if (r1>7) + i++; + if (MIN_I1<=j<=MAX_I1) + i+=0x388300; + else + i+=0x388100; + if (!d1) { + IcU3(tempi,0x000000+i+(r1&7)<<16); + } else if (MIN_I1<=d1<=MAX_I1) { + IcU3(tempi,0x400000+i+(r1&7)<<16); + IcU1(tempi,d1); + } else { + IcU3(tempi,0x800000+i+(r1&7)<<16); + IcU4(tempi,d1); + } + if (MIN_I1<=j<=MAX_I1) + IcU1(tempi,j); + else + IcU4(tempi,j); + } else { + if (tempi->ic_flags & ICF_POP_CMP) { + IcPopRegs(tempi,1<p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r1=CREG_RCX; + } + } + IcZero(tempi,CREG_RAX); + if (r1>7) + i++; + if (MIN_I1<=j<=MAX_I1) { + IcU3(tempi,0xF88300+i+(r1&7)<<16); + IcU1(tempi,j); + } else { + IcU3(tempi,0xF88100+i+(r1&7)<<16); + IcU4(tempi,j); + } + } + if (tempi->ic_flags & ICF_PUSH_CMP) + IcPush(tempi,TY_IMM+IT_I8,0,j,ip); + if (tempi->ic_class->sub_type&1 || tempi->ic_flags & ICF_USE_UNSIGNED) + is=us; + IcU2(tempi,0x300+is); + IcU3(tempi,0xC0FF48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->ic_flags & ICF_POP_CMP) { + IcPopRegs(tempi,1<p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r1=CREG_RCX; + } + } + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + r2=CREG_RBX; + } + } else { + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + r2=CREG_RCX; + } + if (tempi->ic_flags & ICF_POP_CMP) { + IcPopRegs(tempi,1<p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r1=CREG_RBX; + } + } + } + IcZero(tempi,CREG_RAX); + if (r2>7) + i++; + if (r1>7) + i+=4; + if (tempi->ic_flags & ICF_PUSH_CMP) + IcPushRegs(tempi,1<ic_class->sub_type&1 || tempi->ic_flags & ICF_USE_UNSIGNED) + is=us; + IcU2(tempi,0x300+is); + IcU3(tempi,0xC0FF48); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } +} + +void IcBitOps(IntermediateCode *tempi,U8 op,U8 op_imm,BoolU4 locked,I8 ip) +{ + IntermediateCode *tempi2=tempi+sizeof(IntermediateCode); + I8 r1=0,r2,i=0x48; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else if (tempi->p1.type&TY_MASK!=TY_IMM) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r1=CREG_RCX; + } + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + r2=CREG_RBX; + } + } else { + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + r2=CREG_RCX; + } + if (tempi->p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else if (tempi->p1.type&TY_MASK!=TY_IMM) { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r1=CREG_RBX; + } + } + if (!(tempi2->ic_flags&ICF_NO_DEPEND_RESULT)) + IcZero(tempi,CREG_RAX); + if (r2>7) { + i++; + r2&=7; + } + if (r1>7) { + i+=4; + r1&=7; + } + if (locked) { + if (op!=0xA30F) + IcU1(tempi,0xF0); + } + IcU1(tempi,i); + if (tempi->p1.type&TY_MASK==TY_IMM) { + IcU3(tempi,0x000000+op_imm+r2<<16); + IcU1(tempi,tempi->p1.disp); + } else + IcU3(tempi,0x000000+op+r2<<16+r1<<19); + if (!(tempi2->ic_flags&ICF_NO_DEPEND_RESULT)) + IcU4(tempi,0x00D08348); +} + + +void IcPreempt(IntermediateCode *tempi,I8 ip) +{ + IntermediateCode *tempi2=tempi+sizeof(IntermediateCode); + if (tempi->p1.type&TY_MASK==TY_IMM) { + IcZero(tempi,CREG_RBX); + IcU4(tempi,0x1B8B4864); + if (!(tempi2->ic_flags&ICF_NO_DEPEND_RESULT)) + IcZero(tempi,CREG_RAX); + if (tempi->p1.disp) + IcU3(tempi,0x6BBA0F); + else + IcU3(tempi,0x73BA0F); + IcU2(tempi,TSS_TASK_FLAGS+TSSf_PREEMPT<<8); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + if (!(tempi2->ic_flags&ICF_NO_DEPEND_RESULT)) + IcZero(tempi,CREG_RAX); + IcZero(tempi,CREG_RBX); + IcU4(tempi,0x1B8B4864); + IcOr(tempi,CREG_RCX); + IcU2(tempi,0x0774); + IcU3(tempi,0x6BBA0F); + IcU2(tempi,TSS_TASK_FLAGS+TSSf_PREEMPT<<8); + IcU2(tempi,0x05EB); + IcU3(tempi,0x73BA0F); + IcU2(tempi,TSS_TASK_FLAGS+TSSf_PREEMPT<<8); + } + if (!(tempi2->ic_flags&ICF_NO_DEPEND_RESULT)) + IcU4(tempi,0x00D08348); +} + +void IcPreIncDec(IntermediateCode *tempi,U8 op,I8 ip) +{ + I8 r; + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + IcSlashOp(tempi, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,op,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } else { + if (tempi->p1.type&TY_MASK==TY_REG) + r=tempi->p1.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r=CREG_RCX; + } + IcSlashOp(tempi, + TY_DISP+tempi->p1.ptype,r,0,op,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_DISP+tempi->p1.ptype,r,0,ip); + } +} + + +void IcPostIncDec(IntermediateCode *tempi,U8 op,I8 ip) +{ + I8 r; + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->r.type&TY_MASK) { + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } + IcSlashOp(tempi, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,op,ip); + } else { + if (tempi->p1.type&TY_MASK==TY_REG && + !(tempi->r.type&TY_MASK==TY_REG && tempi->r.reg==tempi->p1.reg)) + r=tempi->p1.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + r=CREG_RCX; + } + if (tempi->r.type&TY_MASK) { + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_DISP+tempi->p1.ptype,r,0,ip); + } + IcSlashOp(tempi, + TY_DISP+tempi->p1.ptype,r,0,op,ip); + } +} + +void IcCmpAndBranch(IntermediateCode *tempi,U8 ip, + U8 us,U8 is,U8 not_us,U8 not_is, + U1 *buf,I8 ip2) +{ + I8 r1,d1,r2,i=0x48,j; + BoolU4 short_jmp=FALSE,done; + CbMiscStruct *lb,*lb1; + IcParam *p1=&tempi->p1,*p2=&tempi->p2,*swap; + + if (tempi->ic_flags&ICF_RCX_CMP2) { + p1->type=TY_REG+IT_I8; + p1->reg=CREG_RCX; + p1->disp=0; + } + j=p1->disp; + if (p1->type&TY_MASK==TY_IMM && MIN_I4<=j<=MAX_I4) { + swap=p1; p1=p2; p2=swap; + us=not_us; + is=not_is; + } + if (tempi->ic_class->sub_type&1 || tempi->ic_flags & ICF_USE_UNSIGNED) + is=us; + + j=p2->disp; + if (p2->type&TY_MASK==TY_IMM && MIN_I4<=j<=MAX_I4) { + if (!(tempi->ic_flags&(ICF_POP_CMP|ICF_PUSH_CMP|ICF_RCX_CMP|ICF_RCX_CMP2)) && + p1->type&TY_MASK==TY_DISP && + p1->type&IT_MASK>=IT_I8) { + r1=p1->reg; + d1=p1->disp; + if (r1>7) { + i++; + r1&=7; + } + if (MIN_I1<=j<=MAX_I1) + i+=0x388300; + else + i+=0x388100; + if (!d1) { + IcU3(tempi,0x000000+i+r1<<16); + } else if (MIN_I1<=d1<=MAX_I1) { + IcU3(tempi,0x400000+i+r1<<16); + IcU1(tempi,d1); + } else { + IcU3(tempi,0x800000+i+r1<<16); + IcU4(tempi,d1); + } + if (MIN_I1<=j<=MAX_I1) + IcU1(tempi,j); + else + IcU4(tempi,j); + } else { + if (tempi->ic_flags&ICF_POP_CMP) { + IcPopRegs(tempi,1<type&TY_MASK==TY_REG && + (p1->type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW))) + r1=p1->reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,p1->type,p1->reg,p1->disp,ip2); + r1=CREG_RBX; + } + } + if (!j) { + if (is.u1[2]==0x7C) { + IcOr(tempi,r1); + is=0x78880F; + } else if (is.u1[2]==0x7D) { + IcOr(tempi,r1); + is=0x79890F; + } else if (is.u1[2]==0x74 || is.u1[2]==0x75) + IcOr(tempi,r1); + else { + if (r1>7) + i++; + IcU3(tempi,0xF88300+i+(r1&7)<<16); + IcU1(tempi,j); + } + } else { + if (r1>7) + i++; + if (MIN_I1<=j<=MAX_I1) { + IcU3(tempi,0xF88300+i+(r1&7)<<16); + IcU1(tempi,j); + } else { + IcU3(tempi,0xF88100+i+(r1&7)<<16); + IcU4(tempi,j); + } + } + } + if (tempi->ic_flags&ICF_PUSH_CMP) { + if (!swap) + IcPush(tempi,TY_IMM+IT_I8,0,j,ip2); + else + IcPush(tempi,TY_REG+IT_I8,r1,0,ip2); + } else if (tempi->ic_flags&ICF_RCX_CMP) { + if (!swap) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,TY_IMM+IT_I8,0,j,ip2); + else + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,TY_REG+IT_I8,r1,0,ip2); + } + } else { + done=FALSE; + if (p1->type&IT_MASK>=IT_I8 && + p2->type&IT_MASK>=IT_I8 && + !(tempi->ic_flags&ICF_POP_CMP)) { + if (p1->type&TY_MASK==TY_REG && + !(tempi->ic_flags&(ICF_PUSH_CMP|ICF_RCX_CMP)) && + (p2->type&TY_MASK==TY_DISP || + p2->type&TY_MASK==TY_RIP_DISP32)) { + i=IcModr(p1->reg,p2->type,p2->reg,p2->disp); + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0x3B); + if (i.u1[0]==1) + IcU1(tempi,p2->disp); + else if (i.u1[0]==2) + IcU4(tempi,p2->disp); + else if (i.u1[0]==4) { + IcU4(tempi,p2->disp-(ip2+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + done=TRUE; + } else if (p2->type&TY_MASK==TY_REG && + (p1->type&TY_MASK==TY_REG || + p1->type&TY_MASK==TY_DISP || + p1->type&TY_MASK==TY_RIP_DISP32)) { + i=IcModr(p2->reg,p1->type,p1->reg,p1->disp); + IcRex(tempi,i.u1[1]); + IcU2(tempi,i.u1[2]<<8+0x39); + if (i.u1[0]==1) + IcU1(tempi,p1->disp); + else if (i.u1[0]==2) + IcU4(tempi,p1->disp); + else if (i.u1[0]==4) { + IcU4(tempi,p1->disp-(ip2+tempi->ic_cnt+4)); + tempi->ic_flags&=~ICF_CODE_FINAL; + } + if (tempi->ic_flags&ICF_PUSH_CMP) + IcPushRegs(tempi,1<reg); + else if (tempi->ic_flags&ICF_RCX_CMP) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,TY_REG+IT_I8,p2->reg,0,ip2); + done=TRUE; + } + } + if (!done) { + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->ic_flags&ICF_POP_CMP) { + IcPopRegs(tempi,1<type&TY_MASK==TY_REG && + (p1->type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW))) + r1=p1->reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p1->type,p1->reg,p1->disp,ip2); + r1=CREG_RAX; + } + } + if (p2->type&TY_MASK==TY_REG && + (p2->type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW))) + r2=p2->reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,p2->type,p2->reg,p2->disp,ip2); + r2=CREG_RCX; + } + } else { + if (p2->type&TY_MASK==TY_REG && + (p2->type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW))) + r2=p2->reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p2->type,p2->reg,p2->disp,ip2); + r2=CREG_RAX; + } + if (tempi->ic_flags&ICF_POP_CMP) { + IcPopRegs(tempi,1<type&TY_MASK==TY_REG && + (p1->type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW))) + r1=p1->reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,p1->type,p1->reg,p1->disp,ip2); + r1=CREG_RCX; + } + } + } + if (r2>7) + i++; + if (r1>7) + i+=4; + IcU3(tempi,0xC03B00+i+(r2&7)<<16+(r1&7)<<19); + if (tempi->ic_flags&ICF_PUSH_CMP) + IcPushRegs(tempi,1<ic_flags&ICF_RCX_CMP) + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,TY_REG+IT_I8,r2,0,ip2); + } + } + ip+=tempi->ic_cnt; + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + if (MIN_I1+2ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + + if (short_jmp) { + tempi->ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + IcU2(tempi,i<<8+is.u1[2]); + } else { + tempi->ic_flags&=~ICF_SHORT_JMP; + i=lb->address-(ip+6); + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + IcU2(tempi,is.u2[0]); + IcU4(tempi,i); + } +} + +void IcTestAndBranch(IntermediateCode *tempi,U8 ip,U8 is,U1 *buf,I8 ip2) +{ + I8 i; + BoolU4 short_jmp=FALSE; + CbMiscStruct *lb,*lb1; + + if (tempi->p1.type&TY_MASK!=TY_REG) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcOr(tempi,CREG_RAX); + } else + IcOr(tempi,tempi->p1.reg); + ip+=tempi->ic_cnt; + + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (lb->flags&CBMF_POP_CMP) + i+=8; + if (MIN_I1+2ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + if (short_jmp) { + tempi->ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,i<<8+is.u1[2]); + } else { + tempi->ic_flags&=~ICF_SHORT_JMP; + i=lb->address-(ip+6); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,is.u2[0]); + IcU4(tempi,i); + } +} + +void IcAndBranch(IntermediateCode *tempi,U8 ip,U8 is,U1 *buf,I8 ip2) +{ + I8 i; + BoolU4 short_jmp=FALSE; + CbMiscStruct *lb,*lb1; + IcParam *p1,*p2; + if (tempi->p1.type&TY_MASK==TY_IMM) { + p1=&tempi->p2; + p2=&tempi->p1; + tempi->ic_flags|=ICF_P1_FIRST; + } else { + p1=&tempi->p1; + p2=&tempi->p2; + } + i=p2->disp; + if (p2->type&TY_MASK==TY_IMM && i>=0 && i<=MAX_U4) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p1->type,p1->reg,p1->disp,ip2); + if (i<=MAX_U1) + IcU2(tempi,i<<8+0x24); + else if (i<=MAX_U2) + IcU4(tempi,i<<16+0x2566); + else { + IcU1(tempi,0x25); + IcU4(tempi,i); + } + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,p1->type,p1->reg,p1->disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p2->type,p2->reg,p2->disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0,p2->type,p2->reg,p2->disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,p1->type,p1->reg,p1->disp,ip2); + } + IcU3(tempi,0xC12348); + } + ip+=tempi->ic_cnt; + + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (lb->flags&CBMF_POP_CMP) + i+=8; + if (MIN_I1+2ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + if (short_jmp) { + tempi->ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,i<<8+is.u1[2]); + } else { + tempi->ic_flags&=~ICF_SHORT_JMP; + i=lb->address-(ip+6); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,is.u2[0]); + IcU4(tempi,i); + } +} + +void IcAssign(IntermediateCode *tempi,I8 ip) +{ + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->r.type&TY_MASK) { + if (tempi->p1.type&TY_MASK==TY_REG) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + else + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } + } else { + if (tempi->p1.type&TY_MASK==TY_REG) { + IcMov(tempi,TY_DISP+tempi->p1.ptype,tempi->p1.reg,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RCX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } + } +} + +void IcFOp1(IntermediateCode *tempi,U8 op,I8 ip) +{ + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + // IcU2(tempi,op<<8+0x00CD); + IcCopyIrq(tempi,op); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcFOp2(IntermediateCode *tempi,U8 op,I8 ip) +{ + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + // IcU2(tempi,op<<8+0x00CD); + IcCopyIrq(tempi,op); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcFCmp(IntermediateCode *tempi,U8 op,I8 ip) +{ + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->ic_flags&ICF_POP_CMP) + IcPopRegs(tempi,1<p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + if (tempi->ic_flags&ICF_POP_CMP) + IcPopRegs(tempi,1<p1.type,tempi->p1.reg,tempi->p1.disp,ip); + } + if (tempi->ic_flags&ICF_PUSH_CMP) + IcPushRegs(tempi,1<r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcFOp2Equal(IntermediateCode *tempi,U8 op,I8 ip) +{ + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } + // IcU2(tempi,op<<8+0x00CD); + IcCopyIrq(tempi,op); + IcMov(tempi,tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type&TY_MASK+tempi->p1.ptype,tempi->p1.reg,tempi->p1.disp,ip); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + TY_DISP+tempi->p1.ptype,CREG_RCX,0,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + TY_DISP+tempi->p1.ptype,CREG_RCX,0,ip); + } + // IcU2(tempi,op<<8+0x00CD); + IcCopyIrq(tempi,op); + IcMov(tempi,TY_DISP+tempi->p1.ptype,CREG_RCX,0,TY_REG+IT_I8,CREG_RAX,0,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } +} + +void IcFCmpAndBranch(IntermediateCode *tempi,U8 ip,U8 op,U1 *buf,I8 ip2) +{ + I8 i; + BoolU4 short_jmp=FALSE; + CbMiscStruct *lb,*lb1; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->ic_flags&ICF_POP_CMP) + IcPopRegs(tempi,1<p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + if (tempi->ic_flags&ICF_POP_CMP) + IcPopRegs(tempi,1<p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + if (tempi->ic_flags&ICF_PUSH_CMP) + IcPushRegs(tempi,1<ic_cnt; + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + if (MIN_I1+2ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + + if (short_jmp) { + tempi->ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + IcU2(tempi,i<<8+0x75); + } else { + tempi->ic_flags&=~ICF_SHORT_JMP; + i=lb->address-(ip+6); + if (lb->flags&CBMF_POP_CMP) + if(tempi->ic_flags&ICF_PUSH_CMP) + i+=4; + else + i+=8; + IcU2(tempi,0x850F); + IcU4(tempi,i); + } +} + +void IcFPreIncDec(IntermediateCode *tempi,U8 op,I8 ip) +{ + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type&TY_MASK+IT_I8,tempi->p1.reg,tempi->p1.disp,ip); + IcCopyIrq(tempi,op); + IcMov(tempi,tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + TY_DISP+IT_I8,CREG_RCX,0,ip); + IcCopyIrq(tempi,op); + IcMov(tempi,TY_DISP+IT_I8,CREG_RCX,0, + TY_REG+IT_I8,CREG_RAX,0,ip); + } + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); +} + +void IcFPostIncDec(IntermediateCode *tempi,U8 op,I8 ip) +{ + if (tempi->ic_flags & ICF_NOT_ADDRESS) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type&TY_MASK+IT_I8,tempi->p1.reg,tempi->p1.disp,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + TY_REG+IT_I8,CREG_RAX,0,ip); + IcCopyIrq(tempi,op); + IcMov(tempi,tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + TY_REG+IT_I8,CREG_RAX,0,ip); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + TY_DISP+IT_I8,CREG_RCX,0,ip); + if (tempi->r.type&TY_MASK) + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + TY_REG+IT_I8,CREG_RAX,0,ip); + IcCopyIrq(tempi,op); + IcMov(tempi,TY_DISP+IT_I8,CREG_RCX,0, + TY_REG+IT_I8,CREG_RAX,0,ip); + } + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RDX,0,ip); +} + +void IcBrBitOps(IntermediateCode *tempi,U8 ip,U8 op,U8 op_imm,U8 is,BoolU4 locked,U1 *buf,I8 ip2) +{ + I8 i=0x48,r1=0,r2; + BoolU4 short_jmp=FALSE; + CbMiscStruct *lb,*lb1; + + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else if (tempi->p1.type&TY_MASK!=TY_IMM) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + r1=CREG_RCX; + } + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + r2=CREG_RBX; + } + } else { + if (tempi->p2.type&TY_MASK==TY_REG && + (tempi->p2.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p2.reg!=CREG_RAX) + r2=tempi->p2.reg; + else { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0,tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + r2=CREG_RCX; + } + if (tempi->p1.type&TY_MASK==TY_REG && + (tempi->p1.type&IT_MASK>=IT_I8||GetOpt(OPTf_IGNORE_OVERFLOW)) && + tempi->p1.reg!=CREG_RAX) + r1=tempi->p1.reg; + else if (tempi->p1.type&TY_MASK!=TY_IMM) { + IcMov(tempi,TY_REG+IT_I8,CREG_RBX,0,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + r1=CREG_RBX; + } + } + + if (r2>7) { + i++; + r2&=7; + } + if (r1>7) { + i+=4; + r1&=7; + } + if (locked) { + if (op!=0xA30F) + IcU1(tempi,0xF0); + } + IcU1(tempi,i); + if (tempi->p1.type&TY_MASK==TY_IMM) { + IcU3(tempi,0x000000+op_imm+r2<<16); + IcU1(tempi,tempi->p1.disp); + } else + IcU3(tempi,0x000000+op+r2<<16+r1<<19); + + ip+=tempi->ic_cnt; + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (lb->flags&CBMF_POP_CMP) + i+=8; + if (MIN_I1+2ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + if (short_jmp) { + tempi->ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,i<<8+is.u1[2]); + } else { + tempi->ic_flags&=~ICF_SHORT_JMP; + i=lb->address-(ip+6); + if (lb->flags&CBMF_POP_CMP) + i+=8; + IcU2(tempi,is.u2[0]); + IcU4(tempi,i); + } +} + \ No newline at end of file diff --git a/LT/Compiler/CodeGen.CPZ b/LT/Compiler/CodeGen.CPZ new file mode 100644 index 0000000..46637d3 --- /dev/null +++ b/LT/Compiler/CodeGen.CPZ @@ -0,0 +1,431 @@ +void CbPutClass(ClassStruct *c) +{ + I8 i; + if (!c) return; + if (c->ptr_cnt>4) { + PrintFErr("put_class ptrcnt=%d\r\n",c->ptr_cnt); + while (TRUE) +//TODO: + SwapInNext; + } + for (i=0;iptr_cnt;i++) + PutChar('*'); + c-=sizeof(ClassStruct)*c->ptr_cnt; + if (c->str) + PutS(c->str); + else { + PrintFErr("put_class str=NULL\r\n"); + while (TRUE) +//TODO: + SwapInNext; + } + PutChar(CH_SPACE); +} + + +void CbPutIcParam(IcParam *p) +{ + if (p->ptype) + PrintF("%Z %Z %Z ", + p->type&IT_MASK,"ST_IT_TYPES", + p->ptype&IT_MASK,"ST_IT_TYPES", + p->type>>4,"ST_TY_TYPES"); + else + PrintF("%Z %Z ", + p->type&IT_MASK,"ST_IT_TYPES", + p->type>>4,"ST_TY_TYPES"); + switch (p->type>>4) { + case TY_IMM>>4: + PrintF("#%X",p->disp); + break; + case TY_REG>>4: + PrintF("%Z",p->reg,"ST_U8_REGS"); + break; + case TY_DISP>>4: + PrintF("%X[%Z]",p->disp,p->reg,"ST_U8_REGS"); + break; + case TY_RIP_DISP32>>4: + PrintF("[%X]",p->disp); + break; + } +} + +void CbPutIc(IntermediateCode *tempi) +{ + U8 opcode=tempi->ic_opcode; + if (opcode>=EC_END_EXP && opcode!=EC_NOP1) { + PrintF("%15ts %016X ", + SysTextSub(opcode,"ST_INTERMEDIATE_CODE")+4, + tempi->ic_data); + if (tempi->r.type&TY_MASK) { + CbPutIcParam(&tempi->r); + cout "<-"; + } + if (tempi->p1.type&TY_MASK) + CbPutIcParam(&tempi->p1); + cout ","; + if (tempi->p2.type&TY_MASK) + CbPutIcParam(&tempi->p2); + cout ","; + if (tempi->p3.type&TY_MASK) + CbPutIcParam(&tempi->p3); + cout " "; + CbPutClass(tempi->ic_class); + if (tempi->ic_flags & ICF_P3_TO_DOUBLE) + PutS("$$FG,LTBLUE$$p3d$$FG$$ "); + if (tempi->ic_flags & ICF_P3_TO_INT) + PutS("$$FG,GREEN$$p3i$$FG$$ "); + if (tempi->ic_flags & ICF_P2_TO_DOUBLE) + PutS("$$FG,LTBLUE$$p2d$$FG$$ "); + if (tempi->ic_flags & ICF_P2_TO_INT) + PutS("$$FG,GREEN$$p2i$$FG$$ "); + if (tempi->ic_flags & ICF_P1_TO_DOUBLE) + PutS("$$FG,LTBLUE$$p1d$$FG$$ "); + if (tempi->ic_flags & ICF_P1_TO_INT) + PutS("$$FG,GREEN$$p1i$$FG$$ "); + if (tempi->ic_flags & ICF_R_TO_DOUBLE) + PutS("$$FG,LTBLUE$$rd$$FG$$ "); + if (tempi->ic_flags & ICF_R_TO_INT) + PutS("$$FG,GREEN$$ri$$FG$$ "); + if (tempi->ic_flags & ICF_USE_DOUBLE) + PutS("[double] "); + if (tempi->ic_flags & ICF_USE_UNSIGNED) + PutS("[unsigned] "); + if (tempi->ic_flags & ICF_USE_INT) + PutS("[int] "); + if (tempi->ic_flags & ICF_NO_DEPEND_RESULT) + PutS("-DEP "); + if (tempi->ic_flags & ICF_DEPEND_RESULT) + PutS("+DEP "); + if (tempi->ic_flags & ICF_NOT_ADDRESS) + PutS("(NOT_ADDRESS) "); + if (tempi->ic_flags & ICF_PUSH_RESULT) + PutS("(PUSH) "); + if (tempi->ic_flags & ICF_PUSH_CMP) + PutS("(PUSH_CMP) "); + if (tempi->ic_flags & ICF_POP_CMP) + PutS("(POP_CMP) "); + if (tempi->ic_flags & ICF_RCX_CMP) + PutS("(RCX_CMP) "); + if (tempi->ic_flags & ICF_RCX_CMP2) + PutS("(RCX_CMP2) "); + CrLf; + } +} + +void CbInitOutPtrs(LexCbStack *ll) +{ + CodeBlk *cb=MAllocZ(sizeof(CodeBlk)); + cb->next=NULL; + ll->cb_out_first=cb; + ll->cb_out_last=cb; + ll->cb_misc_list=NULL; + ll->cb_misc_list_end=&ll->cb_misc_list; + ll->cb_out_ptr=&cb->data; + ll->cb_out_end=ll->cb_out_ptr+sizeof(IntermediateCode)*CB_IC_CNT; + ll->cb_last_out_ptr=&cb->data; +} + +void CbInitInPtrs(LexCbStack *ll) +{ + CodeBlk *cb=ll->cb_out_first; + ll->cb_in_first=cb; + ll->cb_in_ptr=&cb->data; + ll->cb_in_end=ll->cb_in_ptr+sizeof(IntermediateCode)*CB_IC_CNT; +} + +void CbPutAllIc(LexStruct *lx) +{ + IntermediateCode *tempi; + CbInitInPtrs(&lx->cb); + tempi=lx->cb.cb_in_ptr; + while (tempi->ic_opcode) { + if (tempi->ic_flags&ICF_TRACE) + CbPutIc(tempi); + tempi+=sizeof(IntermediateCode); + } +} + +void CbAddIc(LexStruct *lx, + U8 opcode_and_precidence,U8 arg, ClassStruct *c,U8 flags=0) +{ + IntermediateCode *tempi=lx->cb.cb_out_ptr; + CodeBlk *cb,*cb1; + lx->cb.cb_last_out_ptr=tempi; + tempi->ic_opcode=opcode_and_precidence.u2[0]; + tempi->ic_precidence=opcode_and_precidence.u2[1]; + tempi->ic_data=arg; + tempi->ic_class=c; + if (Bt(&lx->flags,LFf_OPT_TRACE)) { + Bts(&lx->flags,LFf_OPT_TRACE_PRESENT); + flags|=ICF_TRACE; + } + tempi->ic_flags=flags; + tempi->ic_line=lx->lag_line_num; + if (lx->flags & LF_PARSE_TRACE) + CbPutIc(tempi); + + tempi+=sizeof(IntermediateCode); + if (tempi>=lx->cb.cb_out_end) { + cb=MAllocZ(sizeof(CodeBlk)); + cb->next=NULL; + cb1=lx->cb.cb_out_last; + cb1->next=cb; + lx->cb.cb_out_last=cb; + tempi=&cb->data; + lx->cb.cb_out_end=tempi+sizeof(IntermediateCode)*CB_IC_CNT; + } + lx->cb.cb_out_ptr=tempi; +} + +IntermediateCode *CbGetIc1(LexCbStack *lx) +{ + IntermediateCode *tempi=lx->cb_in_ptr, + *tempi1=tempi+sizeof(IntermediateCode); + CodeBlk *cb; + if (tempi1>=lx->cb_in_end) { + cb=tempi1-sizeof(IntermediateCode)*CB_IC_CNT-offset(CodeBlk.data); + cb=cb->next; + tempi1=&cb->data; + lx->cb_in_end=tempi1+sizeof(IntermediateCode)*CB_IC_CNT; + } + lx->cb_in_ptr=tempi1; + return tempi; +} + +void CbPush(LexStruct *lx) +{ + LexCbStack *templ=MAlloc(sizeof(LexCbStack)); + MemCpy(templ,&lx->cb,sizeof(LexCbStack)); + if (lx->cb.cb_misc_list_end==&lx->cb.cb_misc_list) + templ->cb_misc_list_end=&templ->cb_misc_list; + lx->cb.cb_next=templ; +} + +void CbPop(LexStruct *lx) +{ + LexCbStack *templ=lx->cb.cb_next; + MemCpy(&lx->cb,templ,sizeof(LexCbStack)); + if (templ->cb_misc_list_end==&templ->cb_misc_list) + lx->cb.cb_misc_list_end=&lx->cb.cb_misc_list; + Free(templ); +} + +CbMiscStruct *CbFindGotoLabel(LexStruct *lx,I1 *name) +{ + CbMiscStruct *templ=lx->cb.cb_misc_list; + while (templ) { + if (templ->type==CBMT_GOTO_LABEL) { + if (!StrCmp(templ->str,name)) + return templ; + } + templ=templ->next; + } + return NULL; +} + +CbMiscStruct *CbMiscNew(LexStruct *lx,U8 t) +{ + CbMiscStruct *result=MAllocZ(sizeof(CbMiscStruct)); + lx->cb.cb_misc_list_end->next=result; + lx->cb.cb_misc_list_end=result; + result->address=INVALID_PTR; + result->type=t; + return result; +} + + +void DelCbMiscList(LexStruct *lx) +{ + CbMiscStruct *mc=lx->cb.cb_misc_list,*mc1; + while (mc) { + mc1=mc->next; + if (mc->type==CBMT_GOTO_LABEL && + !mc->address) { + lx->cb.cb_misc_list=NULL; //prevent recursion + PrintFErr("%S%s\r\n","ST_UNDEFINED_GOTO_LABEL",mc->str); + throw(EXCEPT_COMPILER,1); + } + Free(mc->str); + Free(mc->jmp_table); + Free(mc); + mc=mc1; + } +} + +LexStruct *CbPopNoFree(LexStruct *lx) +{ + LexCbStack *templ=lx->cb.cb_next; + MemCpy(&lx->cb,templ,sizeof(LexCbStack)); + if (templ->cb_misc_list_end==&templ->cb_misc_list) + lx->cb.cb_misc_list_end=&lx->cb.cb_misc_list; + return templ; +} + +void CbAppend(LexStruct *lx, LexCbStack *ll) +{ + IntermediateCode *tempi; + CbInitInPtrs(ll); + do { + tempi=CbGetIc1(ll); + if (tempi->ic_opcode) { + CbAddIc(lx,tempi->ic_opcode+tempi->ic_precidence<<16,tempi->ic_data, + tempi->ic_class,tempi->ic_flags); + } + } while (tempi->ic_opcode); + DelLinkedList(ll->cb_out_first); + + if (ll->cb_misc_list_end!=&ll->cb_misc_list) { + lx->cb.cb_misc_list_end->next=ll->cb_misc_list; + lx->cb.cb_misc_list_end=ll->cb_misc_list_end; + } + Free(ll); +} + +void CbCombine(LexStruct *lx) +{ + CodeBlk *cb=lx->cb.cb_out_first,*cb1,*cb2; + I8 i=0,j=sizeof(IntermediateCode)*CB_IC_CNT; + void *ptr; + while (cb) { + i++; + cb=cb->next; + } + if (i>1) { + cb1=MAlloc(i*j+offset(CodeBlk.data)); + cb1->next=NULL; + cb=lx->cb.cb_out_first; + ptr=&cb1->data; + while (cb) { + cb2=cb->next; + MemCpy(ptr,&cb->data,j); + ptr+=j; + Free(cb); + cb=cb2; + } + lx->cb.cb_out_first=cb1; + } +} + +U1 *CbCompile(LexStruct *lx,ClassStruct *fun_class, + U8 *code_size,DbgInfo **dbg_info,U8 *type=NULL) +{ + U1 *result; + I8 register_offsets[NUM_REGS],min_line=MAX_I8,max_line=0; + if (dbg_info) + *dbg_info=NULL; + + CbCombine(lx); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,0)) { + coutln "$$IV 1$$Before Pass 1:$$IV 0$$"; + CbPutAllIc(lx); + } + } + CmpOptPass1(lx,fun_class,TRUE); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,1)) { + coutln "$$IV 1$$After Pass 1:$$IV 0$$"; + CbPutAllIc(lx); + } + } + CmpOptPass2(lx,fun_class,register_offsets); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,2)) { + coutln "$$IV 1$$After Pass 2:$$IV 0$$"; + CbPutAllIc(lx); + } + } + CmpOptPass3(lx,register_offsets,type); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,3)) { + coutln "$$IV 1$$After Pass 3:$$IV 0$$"; + CbPutAllIc(lx); + } + } + CmpOptPass4(lx); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,4)) { + coutln "$$IV 1$$After Pass 4:$$IV 0$$"; + CbPutAllIc(lx); + } + } + CmpOptPass5(lx,fun_class); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + if (Bt(&lx->pass_trace_mask,5)) { + coutln "$$IV 1$$After Pass 5:$$IV 0$$"; + CbPutAllIc(lx); + } + } + + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) + if (Bt(&lx->pass_trace_mask,6)) + coutln "$$IV 1$$Pass 6:$$IV 0$$"; + CmpOptPass678(lx,fun_class,register_offsets,NULL,6,dbg_info,&min_line,&max_line); + + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) + if (Bt(&lx->pass_trace_mask,7)) + coutln "$$IV 1$$Pass 7:$$IV 0$$"; + *code_size=CmpOptPass678(lx,fun_class,register_offsets,NULL,7,dbg_info,&min_line,&max_line); + + result=MAlloc(*code_size); + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) + if (Bt(&lx->pass_trace_mask,8)) + coutln "$$IV 1$$Pass 8:$$IV 0$$"; + *code_size=CmpOptPass678(lx,fun_class,register_offsets,result,8,dbg_info,&min_line,&max_line); + + DelLinkedList(lx->cb.cb_out_first); + DelCbMiscList(lx); + if (Bt(&lx->flags,LFf_COMPILE_TRACE)) { + if (lx->a) { + if (lx->a->seg_size==16) + CallExtStr("Dasm2",result,*code_size,16); + else if (lx->a->seg_size==64) + CallExtStr("Dasm2",result,*code_size,64); + else + CallExtStr("Dasm2",result,*code_size,32); + } else + CallExtStr("Dasm2",result,*code_size,64); + } + return result; +} + +void DelHashTable(SysHashTable *tempht) +{ + I8 i; + SysHashEntry *temph,*temph1; + ClassStruct *tempc; + GlblVarStruct *tempg; + if (!tempht) return; + for (i=0;i<=tempht->mask;i++) { + temph=tempht->body[i]; + while (temph) { + temph1=temph->next; + if (!(temph->type&HTT_DICT_WORD)) + Free(temph->str); + if (temph->type & (HTT_FUNCTION | HTT_CLASS | + HTT_STR_CONST | HTT_GLBL_VAR | + HTT_SYS_SYMBOL)) { + Free(temph->source_link); + Free(temph->index); + if (temph->type & (HTT_FUNCTION | HTT_CLASS)) { + tempc=temph; + Free(tempc->debug); + Free(tempc->import_name); + DelMemberList(tempc); + //assumes code not on heap + } else if (temph->type&HTT_STR_CONST) + Free(temph><(StrConstStruct *)->data); + else if (temph->type&HTT_GLBL_VAR) { + tempg=temph; + DelLinkedList(tempg->dim_list); + Free(tempg->import_name); + } + } + Free(temph); + temph=temph1; + } + } + Free(tempht); +} + diff --git a/LT/Compiler/Compiler.BIZ b/LT/Compiler/Compiler.BIZ new file mode 100644 index 0000000..197e191 Binary files /dev/null and b/LT/Compiler/Compiler.BIZ differ diff --git a/LT/Compiler/Compiler.HPZ b/LT/Compiler/Compiler.HPZ new file mode 100644 index 0000000..586476d --- /dev/null +++ b/LT/Compiler/Compiler.HPZ @@ -0,0 +1,53 @@ +#help_index "Char/Conversion" +public extern double A2Double(I1 *src,I1 **end_ptr=NULL); +#help_index "Char/Conversion;Time/LTDate" +public extern LTDate A2LTDate(I1 *src2); + +#help_index "Hash" +public extern SysHashEntry *FindPSect(U8 *add,I8 *offset); +public extern void DelHashTable(SysHashTable *table); + +#help_index "Compiler/Lex" +public extern LexStruct *LexNew(I1 *buf,U8 flags,I1 *filename); +public extern void LexDel(LexStruct *lx); +public extern void SetSourceFileInfo(LexStruct *lx,SysHashEntry *h); +public extern void LexPutToken(LexStruct *lx); +public extern U8 LexGetChar(LexStruct *lx); +public extern void LexSkipEol(LexStruct *lx); +public extern U8 EvalExpression(LexStruct *lx); +public extern void LexPush(LexStruct *lx); +public extern void LexPop(LexStruct *lx); +//public extern void LexSubStackPtr(LexStruct *lx); +public extern I8 Lex(LexStruct *lx); +public extern I1 *LexExtendStr(LexStruct *lx,U8 *size=NULL); +public extern void LexPutLine(LexStruct *lx,I1 *start); +public extern I8 LexLineNum(LexStruct *lx); +public extern void LexPutLink(LexStruct *lx); +public extern void PutLexError(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL); +public extern void PutLexWarning(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL); +public extern U8 GetExpression(LexStruct *lx,U1 **e); //FALSE=no err +public extern I8 Expression(LexStruct *lx); +public extern void DelExpression(void *code); +public extern MemberListStruct *FindMember(I1 *st,ClassStruct *c); + +#help_index "Compiler/Directive" +public extern void ExePutS(I1 *st); +public extern void ExePrintF(I1 *src,...); +#help_index "Compiler" +public extern I8 CompileFile(I1 *filename,I1 *map_name=NULL,I1 *out_name=NULL,I1 mapfile_drive=0); +public extern I8 ExecuteStr(I1 *buf,I1 *filename=NULL); +public extern I8 ExecuteFile(I1 *name); +public extern void ContinueUserTask(); +extern SysHashTable *asm_hash; +extern void InitCompiler(BoolU4 first); + +//The following is for benchmarking +extern BoolU4 cmp_do_not_write_to_disk; + +LTextern CP_HI_CALL U8 HiCall(void *s); +extern I8 ExecuteCmdLine(LexStruct *lx); + +#help_index "Exceptions" +public extern void CatchAll(); + +#help_index "" diff --git a/LT/Compiler/Compiler.MPZ b/LT/Compiler/Compiler.MPZ new file mode 100644 index 0000000..cdf425b --- /dev/null +++ b/LT/Compiler/Compiler.MPZ @@ -0,0 +1,552 @@ +$LK+BI,"A2Double ","FL:::/LT/Compiler/SPrintF2.CPZ,730",1$0000AA60 0001 Funct Export +$LK+BI,"A2LTDate ","FL:::/LT/Compiler/SPrintF2.CPZ,807",2$0000AD38 0001 Funct Export +$LK,"ADAM_STARTUP_NAME ","FL:::/LT/Compiler/CmpMain.CPZ,396"$\"/LT/OSMain/AdamK.APZ\" 0002 StrConst +$LK,"AKW_ALIGN ","FL:::/LT/Compiler/CmpDefs.HPZ,232"$64 0001 StrConst +$LK,"AKW_DU1 ","FL:::/LT/Compiler/CmpDefs.HPZ,238"$70 0001 StrConst +$LK,"AKW_DU2 ","FL:::/LT/Compiler/CmpDefs.HPZ,239"$71 0001 StrConst +$LK,"AKW_DU4 ","FL:::/LT/Compiler/CmpDefs.HPZ,240"$72 0001 StrConst +$LK,"AKW_DU8 ","FL:::/LT/Compiler/CmpDefs.HPZ,241"$73 0001 StrConst +$LK,"AKW_DUP ","FL:::/LT/Compiler/CmpDefs.HPZ,242"$74 0001 StrConst +$LK,"AKW_END ","FL:::/LT/Compiler/CmpDefs.HPZ,233"$65 0001 StrConst +$LK,"AKW_ENDS ","FL:::/LT/Compiler/CmpDefs.HPZ,245"$77 0001 StrConst +$LK,"AKW_EXPORT ","FL:::/LT/Compiler/CmpDefs.HPZ,250"$82 0002 StrConst +$LK,"AKW_IMPORT ","FL:::/LT/Compiler/CmpDefs.HPZ,249"$81 0002 StrConst +$LK,"AKW_INSERT ","FL:::/LT/Compiler/CmpDefs.HPZ,251"$83 0001 StrConst +$LK,"AKW_INSERT_COMPRESSED ","FL:::/LT/Compiler/CmpDefs.HPZ,254"$86 0001 StrConst +$LK,"AKW_LIST ","FL:::/LT/Compiler/CmpDefs.HPZ,252"$84 0001 StrConst +$LK,"AKW_NOLIST ","FL:::/LT/Compiler/CmpDefs.HPZ,253"$85 0001 StrConst +$LK,"AKW_ORG ","FL:::/LT/Compiler/CmpDefs.HPZ,243"$75 0001 StrConst +$LK,"AKW_STRUC ","FL:::/LT/Compiler/CmpDefs.HPZ,244"$76 0001 StrConst +$LK,"AKW_U1 ","FL:::/LT/Compiler/CmpDefs.HPZ,234"$66 0001 StrConst +$LK,"AKW_U2 ","FL:::/LT/Compiler/CmpDefs.HPZ,235"$67 0001 StrConst +$LK,"AKW_U4 ","FL:::/LT/Compiler/CmpDefs.HPZ,236"$68 0001 StrConst +$LK,"AKW_U8 ","FL:::/LT/Compiler/CmpDefs.HPZ,237"$69 0001 StrConst +$LK,"AKW_USE16 ","FL:::/LT/Compiler/CmpDefs.HPZ,246"$78 0001 StrConst +$LK,"AKW_USE32 ","FL:::/LT/Compiler/CmpDefs.HPZ,247"$79 0001 StrConst +$LK,"AKW_USE64 ","FL:::/LT/Compiler/CmpDefs.HPZ,248"$80 0001 StrConst +$LK+BI,"AdamStartUpFile ","FL:::/LT/Compiler/CmpMain.CPZ,397",3$00031BF0 0000 Funct Export +$LK+BI,"AddUnresolved ","FL:::/LT/Compiler/AsmMain.CPZ,37",4$0000BBC0 0008 Funct Export +$LK+BI,"AsmCodeInstruction ","FL:::/LT/Compiler/AsmMain.CPZ,804",5$0000E3B0 0001 Funct Export +$LK+BI,"AsmEvalExpression ","FL:::/LT/Compiler/AsmMain.CPZ,215",6$0000C380 0003 Funct Export +$LK+BI,"AsmListLine ","FL:::/LT/Compiler/AsmMain.CPZ,65",7$0000BCE8 0004 Funct Export +$LK+BI,"AsmMakeArgMask ","FL:::/LT/Compiler/AsmMain.CPZ,623",8$0000D958 0002 Funct Export +$LK+BI,"AsmStoreCodeU1 ","FL:::/LT/Compiler/AsmMain.CPZ,90",9$0000BE20 0018 Funct Export +$LK+BI,"AsmStoreCodeU1At ","FL:::/LT/Compiler/AsmMain.CPZ,197",10$0000C2B8 000D Funct Export +$LK+BI,"AsmStoreCodeU4 ","FL:::/LT/Compiler/AsmMain.CPZ,119",11$0000BF78 0001 Funct Export +$LK+BI,"AsmStoreCodeU8 ","FL:::/LT/Compiler/AsmMain.CPZ,158",12$0000C118 0005 Funct Export +$LK+BI,"AsmStoreNum ","FL:::/LT/Compiler/AsmMain.CPZ,694",13$0000DDD0 0004 Funct Export +$LK,"CMP_INTERNAL_TYPES_TABLE ","FL:::/LT/Compiler/CmpAsm.ASZ,2"$00000E50 0001 SysSym Export +$LK,"CMP_OPT_NOP ","FL:::/LT/Compiler/CmpAsm.ASZ,40"$00000F58 0003 SysSym +$LK,"COMPILER_END ","FL:::/LT/Compiler/Compiler.SPZ,27"$00031E18 0000 SysSym Export +$LK,"COMPILER_START ","FL:::/LT/Compiler/Compiler.SPZ,5"$00000E50 0000 SysSym Export +$LK,"CP_HI_CALL ","FL:::/LT/Compiler/CmpAsm.ASZ,272"$00001220 0000 SysSym Export +$LK,"CP_OPTNEXT ","FL:::/LT/Compiler/CmpAsm.ASZ,60"$00001060 0001 SysSym Export +$LK,"CP_OPTNEXT2 ","FL:::/LT/Compiler/CmpAsm.ASZ,124"$000010D8 0001 SysSym Export +$LK,"CP_OPTNEXT3 ","FL:::/LT/Compiler/CmpAsm.ASZ,175"$00001150 0001 SysSym Export +$LK,"CP_PRSPOP ","FL:::/LT/Compiler/CmpAsm.ASZ,258"$00001200 0001 SysSym Export +$LK,"CP_PRSPUSH ","FL:::/LT/Compiler/CmpAsm.ASZ,245"$000011E0 0001 SysSym Export +$LK+BI,"CatchAll ","FL:::/LT/Compiler/CmpMain.CPZ,1",14$00030368 0002 Funct Export +$LK+BI,"CbAddIc ","FL:::/LT/Compiler/CodeGen.CPZ,149",15$00005700 00A9 Funct Export +$LK+BI,"CbAppend ","FL:::/LT/Compiler/CodeGen.CPZ,265",16$00005BA8 0003 Funct Export +$LK+BI,"CbCombine ","FL:::/LT/Compiler/CodeGen.CPZ,285",17$00005C78 0001 Funct Export +$LK+BI,"CbCompile ","FL:::/LT/Compiler/CodeGen.CPZ,310",18$00005D60 0004 Funct Export +$LK+BI,"CbFindGotoLabel ","FL:::/LT/Compiler/CodeGen.CPZ,214",19$00005960 0002 Funct Export +$LK+BI,"CbGetIc1 ","FL:::/LT/Compiler/CodeGen.CPZ,181",20$00005808 0003 Funct Export +$LK+BI,"CbInitInPtrs ","FL:::/LT/Compiler/CodeGen.CPZ,129",21$00005660 0003 Funct Export +$LK+BI,"CbInitOutPtrs ","FL:::/LT/Compiler/CodeGen.CPZ,116",22$000055E0 0008 Funct Export +$LK+BI,"CbMiscNew ","FL:::/LT/Compiler/CodeGen.CPZ,227",23$000059C8 0017 Funct Export +$LK+BI,"CbPop ","FL:::/LT/Compiler/CodeGen.CPZ,205",24$000058E8 0007 Funct Export +$LK+BI,"CbPopNoFree ","FL:::/LT/Compiler/CodeGen.CPZ,256",25$00005B48 0001 Funct Export +$LK+BI,"CbPush ","FL:::/LT/Compiler/CodeGen.CPZ,196",26$00005868 000C Funct Export +$LK+BI,"CbPutAllIc ","FL:::/LT/Compiler/CodeGen.CPZ,137",27$000056A0 0006 Funct Export +$LK+BI,"CbPutClass ","FL:::/LT/Compiler/CodeGen.CPZ,1",28$00004CC0 0001 Funct Export +$LK+BI,"CbPutIc ","FL:::/LT/Compiler/CodeGen.CPZ,53",29$00005060 0006 Funct Export +$LK+BI,"CbPutIcParam ","FL:::/LT/Compiler/CodeGen.CPZ,26",30$00004E18 0004 Funct Export +$LK+BI,"CmpClassNew ","FL:::/LT/Compiler/AsmMain.CPZ,1",31$0000BB00 0004 Funct Export +$LK+BI,"CmpDebugger ","FL:::/LT/Compiler/CmpMain.CPZ,346",32$00031930 0001 Funct Export +$LK+BI,"CmpKeyWord ","FL:::/LT/Compiler/StmtParser.CPZ,1",33$00013DB0 000B Funct Export +$LK+BI,"CmpMGetS ","FL:::/LT/Compiler/CmpMain.CPZ,339",34$000318D0 0001 Funct Export +$LK+BI,"CmpOffsetToReg ","FL:::/LT/Compiler/OptPass1.CPZ,122",35$000215B0 0004 Funct Export +$LK+BI,"CmpOptIc3 ","FL:::/LT/Compiler/OptPass3.CPZ,1",36$00026A58 0001 Funct Export +$LK+BI,"CmpOptIc5 ","FL:::/LT/Compiler/OptPass5.CPZ,1",37$00028818 0001 Funct Export +$LK+BI,"CmpOptPass1 ","FL:::/LT/Compiler/OptPass1.CPZ,479",38$000226B8 0000 Funct Export +$LK+BI,"CmpOptPass2 ","FL:::/LT/Compiler/OptPass2.CPZ,23",39$00025520 0000 Funct Export +$LK+BI,"CmpOptPass3 ","FL:::/LT/Compiler/OptPass3.CPZ,201",40$000272B8 0000 Funct Export +$LK+BI,"CmpOptPass4 ","FL:::/LT/Compiler/OptPass4.CPZ,1",41$00028078 0000 Funct Export +$LK+BI,"CmpOptPass5 ","FL:::/LT/Compiler/OptPass5.CPZ,153",42$00028E50 0000 Funct Export +$LK+BI,"CmpOptPass5Lag ","FL:::/LT/Compiler/OptPass5.CPZ,43",43$000289B0 0001 Funct Export +$LK+BI,"CmpOptPass678 ","FL:::/LT/Compiler/OptPass6.CPZ,1",44$000293A8 0000 Funct Export +$LK+BI,"CmpPType ","FL:::/LT/Compiler/OptPass2.CPZ,11",45$000254E0 0006 Funct Export +$LK+BI,"CmpParseAsmBlk ","FL:::/LT/Compiler/AsmMain.CPZ,1388",46$0000FFC0 0001 Funct Export +$LK+BI,"CmpParseClass ","FL:::/LT/Compiler/StmtParser.CPZ,269",47$000149D0 0006 Funct Export +$LK+BI,"CmpParseCout ","FL:::/LT/Compiler/StmtParser.CPZ,994",48$00016ED8 0002 Funct Export +$LK+BI,"CmpParseDoWhile ","FL:::/LT/Compiler/StmtParser.CPZ,824",49$00016498 0001 Funct Export +$LK+BI,"CmpParseExeBlk ","FL:::/LT/Compiler/StmtParser.CPZ,1038",50$00017138 0001 Funct Export +$LK+BI,"CmpParseFor ","FL:::/LT/Compiler/StmtParser.CPZ,848",51$00016678 0001 Funct Export +$LK+BI,"CmpParseFunction ","FL:::/LT/Compiler/StmtParser.CPZ,401",52$00014F20 0001 Funct Export +$LK+BI,"CmpParseFunctionJoin ","FL:::/LT/Compiler/StmtParser.CPZ,331",53$00014C78 0005 Funct Export +$LK+BI,"CmpParseGlblVarList ","FL:::/LT/Compiler/StmtParser.CPZ,582",54$00015848 0006 Funct Export +$LK+BI,"CmpParseIf ","FL:::/LT/Compiler/StmtParser.CPZ,773",55$00016150 0001 Funct Export +$LK+BI,"CmpParseNoUnusedWarn ","FL:::/LT/Compiler/StmtParser.CPZ,977",56$00016E18 0001 Funct Export +$LK+BI,"CmpParseStatement ","FL:::/LT/Compiler/StmtParser.CPZ,1142",57$000177A0 0002 Funct Export +$LK+BI,"CmpParseSwitch ","FL:::/LT/Compiler/StmtParser.CPZ,895",58$000168F8 0001 Funct Export +$LK+BI,"CmpParseTryBlk ","FL:::/LT/Compiler/StmtParser.CPZ,1081",59$000173A0 0001 Funct Export +$LK+BI,"CmpParseVarList ","FL:::/LT/Compiler/StmtParser.CPZ,16",60$00013E00 0004 Funct Export +$LK+BI,"CmpParseWhile ","FL:::/LT/Compiler/StmtParser.CPZ,802",61$00016320 0001 Funct Export +$LK+BI,"CmpPmt ","FL:::/LT/Compiler/Lex.CPZ,1",62$0000134C 0001 Funct Export +$LK+BI,"CmpType ","FL:::/LT/Compiler/OptPass2.CPZ,1",63$000254B0 0004 Funct Export +$LK+BI,"CompileBuf ","FL:::/LT/Compiler/CmpMain.CPZ,89",64$00030990 0001 Funct Export +$LK+BI,"CompileExpression ","FL:::/LT/Compiler/ExpParser.CPZ,796",65$00013BB8 0004 Funct Export +$LK+BI,"CompileFile ","FL:::/LT/Compiler/CmpMain.CPZ,183",66$00030F90 0000 Funct Export +$LK+BI,"CompileStatement ","FL:::/LT/Compiler/CmpMain.CPZ,53",67$00030780 0002 Funct Export +$LK+BI,"ContinueUserTask ","FL:::/LT/Compiler/CmpMain.CPZ,322",68$000317F0 0001 Funct Export +$LK+BI,"DefineU1s ","FL:::/LT/Compiler/AsmMain.CPZ,1304",69$0000FBE8 0004 Funct Export +$LK+BI,"DelCbMiscList ","FL:::/LT/Compiler/CodeGen.CPZ,238",70$00005A30 0001 Funct Export +$LK+BI,"DelExpression ","FL:::/LT/Compiler/Lex.CPZ,315",71$00002368 000A Funct Export +$LK+BI,"DelHashTable ","FL:::/LT/Compiler/CodeGen.CPZ,393",72$00006328 0003 Funct Export +$LK+BI,"DelMemberList ","FL:::/LT/Compiler/Lex.CPZ,453",73$000028A0 0002 Funct Export +$LK,"EC_ABSI8 ","FL:::/LT/Compiler/CmpDefs.HPZ,179"$0x090 0004 StrConst +$LK,"EC_ABSOLUTE_ADDRESS ","FL:::/LT/Compiler/CmpDefs.HPZ,14"$0x00C 000E StrConst +$LK,"EC_ADD ","FL:::/LT/Compiler/CmpDefs.HPZ,51"$0x027 0011 StrConst +$LK,"EC_ADDRESS ","FL:::/LT/Compiler/CmpDefs.HPZ,26"$0x015 0007 StrConst +$LK,"EC_ADD_CONST ","FL:::/LT/Compiler/CmpDefs.HPZ,145"$0x074 0007 StrConst +$LK,"EC_ADD_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,78"$0x03C 0005 StrConst +$LK,"EC_ADD_RSP ","FL:::/LT/Compiler/CmpDefs.HPZ,81"$0x03E 000B StrConst +$LK,"EC_AND ","FL:::/LT/Compiler/CmpDefs.HPZ,46"$0x024 0008 StrConst +$LK,"EC_AND_AND ","FL:::/LT/Compiler/CmpDefs.HPZ,61"$0x02F 000E StrConst +$LK,"EC_AND_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,75"$0x039 0006 StrConst +$LK,"EC_ASSIGN ","FL:::/LT/Compiler/CmpDefs.HPZ,69"$0x034 0007 StrConst +$LK,"EC_BR_AND_AND_NOT_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,171"$0x08B 0003 StrConst +$LK,"EC_BR_AND_AND_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,170"$0x08A 0003 StrConst +$LK,"EC_BR_AND_NOT_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,174"$0x08D 0005 StrConst +$LK,"EC_BR_AND_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,173"$0x08C 0005 StrConst +$LK,"EC_BR_BT ","FL:::/LT/Compiler/CmpDefs.HPZ,151"$0x078 0005 StrConst +$LK,"EC_BR_BTC ","FL:::/LT/Compiler/CmpDefs.HPZ,154"$0x07B 0005 StrConst +$LK,"EC_BR_BTR ","FL:::/LT/Compiler/CmpDefs.HPZ,153"$0x07A 0005 StrConst +$LK,"EC_BR_BTS ","FL:::/LT/Compiler/CmpDefs.HPZ,152"$0x079 0005 StrConst +$LK,"EC_BR_EQUAL_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,135"$0x06B 0006 StrConst +$LK,"EC_BR_GREATER ","FL:::/LT/Compiler/CmpDefs.HPZ,138"$0x06E 0006 StrConst +$LK,"EC_BR_GREATER_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,136"$0x06C 0006 StrConst +$LK,"EC_BR_LBTC ","FL:::/LT/Compiler/CmpDefs.HPZ,166"$0x086 0005 StrConst +$LK,"EC_BR_LBTR ","FL:::/LT/Compiler/CmpDefs.HPZ,165"$0x085 0005 StrConst +$LK,"EC_BR_LBTS ","FL:::/LT/Compiler/CmpDefs.HPZ,164"$0x084 0005 StrConst +$LK,"EC_BR_LESS ","FL:::/LT/Compiler/CmpDefs.HPZ,139"$0x06F 0006 StrConst +$LK,"EC_BR_LESS_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,137"$0x06D 0006 StrConst +$LK,"EC_BR_NOT_BT ","FL:::/LT/Compiler/CmpDefs.HPZ,155"$0x07C 0005 StrConst +$LK,"EC_BR_NOT_BTC ","FL:::/LT/Compiler/CmpDefs.HPZ,158"$0x07F 0005 StrConst +$LK,"EC_BR_NOT_BTR ","FL:::/LT/Compiler/CmpDefs.HPZ,157"$0x07E 0005 StrConst +$LK,"EC_BR_NOT_BTS ","FL:::/LT/Compiler/CmpDefs.HPZ,156"$0x07D 0005 StrConst +$LK,"EC_BR_NOT_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,134"$0x06A 0006 StrConst +$LK,"EC_BR_NOT_LBTC ","FL:::/LT/Compiler/CmpDefs.HPZ,169"$0x089 0005 StrConst +$LK,"EC_BR_NOT_LBTR ","FL:::/LT/Compiler/CmpDefs.HPZ,168"$0x088 0005 StrConst +$LK,"EC_BR_NOT_LBTS ","FL:::/LT/Compiler/CmpDefs.HPZ,167"$0x087 0005 StrConst +$LK,"EC_BR_NOT_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,131"$0x069 000B StrConst +$LK,"EC_BR_OR_OR_NOT_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,141"$0x071 0003 StrConst +$LK,"EC_BR_OR_OR_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,140"$0x070 0003 StrConst +$LK,"EC_BR_ZERO ","FL:::/LT/Compiler/CmpDefs.HPZ,130"$0x068 000D StrConst +$LK,"EC_BSF ","FL:::/LT/Compiler/CmpDefs.HPZ,111"$0x057 0004 StrConst +$LK,"EC_BSR ","FL:::/LT/Compiler/CmpDefs.HPZ,112"$0x058 0004 StrConst +$LK,"EC_BT ","FL:::/LT/Compiler/CmpDefs.HPZ,107"$0x053 0006 StrConst +$LK,"EC_BTC ","FL:::/LT/Compiler/CmpDefs.HPZ,110"$0x056 0006 StrConst +$LK,"EC_BTR ","FL:::/LT/Compiler/CmpDefs.HPZ,109"$0x055 0006 StrConst +$LK,"EC_BTS ","FL:::/LT/Compiler/CmpDefs.HPZ,108"$0x054 0006 StrConst +$LK,"EC_CALL ","FL:::/LT/Compiler/CmpDefs.HPZ,87"$0x042 0008 StrConst +$LK,"EC_CALL_END ","FL:::/LT/Compiler/CmpDefs.HPZ,7"$0x005 000D StrConst +$LK,"EC_CALL_END2 ","FL:::/LT/Compiler/CmpDefs.HPZ,159"$0x080 0014 StrConst +$LK,"EC_CALL_EXTERN ","FL:::/LT/Compiler/CmpDefs.HPZ,177"$0x08F 0005 StrConst +$LK,"EC_CALL_INDIRECT ","FL:::/LT/Compiler/CmpDefs.HPZ,88"$0x043 0005 StrConst +$LK,"EC_CALL_INDIRECT2 ","FL:::/LT/Compiler/CmpDefs.HPZ,89"$0x044 000C StrConst +$LK,"EC_CALL_START ","FL:::/LT/Compiler/CmpDefs.HPZ,6"$0x004 000A StrConst +$LK,"EC_CLI ","FL:::/LT/Compiler/CmpDefs.HPZ,92"$0x046 0004 StrConst +$LK,"EC_COLON ","FL:::/LT/Compiler/CmpDefs.HPZ,66"$0x032 0006 StrConst +$LK,"EC_COM ","FL:::/LT/Compiler/CmpDefs.HPZ,27"$0x016 0005 StrConst +$LK,"EC_DEREF ","FL:::/LT/Compiler/CmpDefs.HPZ,31"$0x019 0012 StrConst +$LK,"EC_DISABLE_CACHE ","FL:::/LT/Compiler/CmpDefs.HPZ,94"$0x048 0004 StrConst +$LK,"EC_DIV ","FL:::/LT/Compiler/CmpDefs.HPZ,43"$0x022 0005 StrConst +$LK,"EC_DIV_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,74"$0x038 0005 StrConst +$LK,"EC_DOUBLE ","FL:::/LT/Compiler/CmpDefs.HPZ,12"$0x00A 0019 StrConst +$LK,"EC_ENABLE_CACHE ","FL:::/LT/Compiler/CmpDefs.HPZ,95"$0x049 0004 StrConst +$LK,"EC_END_EXP ","FL:::/LT/Compiler/CmpDefs.HPZ,4"$0x002 001F StrConst +$LK,"EC_ENTER ","FL:::/LT/Compiler/CmpDefs.HPZ,83"$0x03F 0005 StrConst +$LK,"EC_EQUAL_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,54"$0x029 0007 StrConst +$LK,"EC_FS ","FL:::/LT/Compiler/CmpDefs.HPZ,19"$0x011 0004 StrConst +$LK,"EC_GET_BASE_PTR ","FL:::/LT/Compiler/CmpDefs.HPZ,101"$0x04E 0005 StrConst +$LK,"EC_GET_FLAGS ","FL:::/LT/Compiler/CmpDefs.HPZ,99"$0x04C 0004 StrConst +$LK,"EC_GET_LABEL ","FL:::/LT/Compiler/CmpDefs.HPZ,16"$0x00E 0006 StrConst +$LK,"EC_GET_STACK_PTR ","FL:::/LT/Compiler/CmpDefs.HPZ,103"$0x050 0004 StrConst +$LK,"EC_GREATER ","FL:::/LT/Compiler/CmpDefs.HPZ,57"$0x02C 0007 StrConst +$LK,"EC_GREATER_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,59"$0x02E 0007 StrConst +$LK,"EC_GS ","FL:::/LT/Compiler/CmpDefs.HPZ,20"$0x012 0004 StrConst +$LK,"EC_IMM ","FL:::/LT/Compiler/CmpDefs.HPZ,11"$0x009 0054 StrConst +$LK,"EC_INP ","FL:::/LT/Compiler/CmpDefs.HPZ,121"$0x061 0004 StrConst +$LK,"EC_INPD ","FL:::/LT/Compiler/CmpDefs.HPZ,119"$0x05F 0004 StrConst +$LK,"EC_INPW ","FL:::/LT/Compiler/CmpDefs.HPZ,120"$0x060 0004 StrConst +$LK,"EC_INSQUE ","FL:::/LT/Compiler/CmpDefs.HPZ,113"$0x059 0004 StrConst +$LK,"EC_INSQUE_REV ","FL:::/LT/Compiler/CmpDefs.HPZ,114"$0x05A 0004 StrConst +$LK,"EC_INVD ","FL:::/LT/Compiler/CmpDefs.HPZ,97"$0x04B 0004 StrConst +$LK,"EC_IRQ ","FL:::/LT/Compiler/CmpDefs.HPZ,90"$0x045 0006 StrConst +$LK,"EC_JMP ","FL:::/LT/Compiler/CmpDefs.HPZ,127"$0x066 000F StrConst +$LK,"EC_LABEL ","FL:::/LT/Compiler/CmpDefs.HPZ,5"$0x003 001E StrConst +$LK,"EC_LBTC ","FL:::/LT/Compiler/CmpDefs.HPZ,163"$0x083 0006 StrConst +$LK,"EC_LBTR ","FL:::/LT/Compiler/CmpDefs.HPZ,162"$0x082 0006 StrConst +$LK,"EC_LBTS ","FL:::/LT/Compiler/CmpDefs.HPZ,161"$0x081 0006 StrConst +$LK,"EC_LEA ","FL:::/LT/Compiler/CmpDefs.HPZ,22"$0x013 000B StrConst +$LK,"EC_LEAVE ","FL:::/LT/Compiler/CmpDefs.HPZ,84"$0x040 0005 StrConst +$LK,"EC_LESS ","FL:::/LT/Compiler/CmpDefs.HPZ,56"$0x02B 0007 StrConst +$LK,"EC_LESS_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,58"$0x02D 0007 StrConst +$LK,"EC_MEMCPY ","FL:::/LT/Compiler/CmpDefs.HPZ,117"$0x05D 0004 StrConst +$LK,"EC_MEMSET ","FL:::/LT/Compiler/CmpDefs.HPZ,118"$0x05E 0004 StrConst +$LK,"EC_MM_ ","FL:::/LT/Compiler/CmpDefs.HPZ,35"$0x01D 0005 StrConst +$LK,"EC_MOD ","FL:::/LT/Compiler/CmpDefs.HPZ,44"$0x023 0005 StrConst +$LK,"EC_MOD_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,176"$0x08E 0005 StrConst +$LK,"EC_MOV ","FL:::/LT/Compiler/CmpDefs.HPZ,24"$0x014 0013 StrConst +$LK,"EC_MUL ","FL:::/LT/Compiler/CmpDefs.HPZ,42"$0x021 0007 StrConst +$LK,"EC_MUL_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,73"$0x037 0005 StrConst +$LK,"EC_NOP ","FL:::/LT/Compiler/CmpDefs.HPZ,3"$0x001 0055 StrConst +$LK,"EC_NOP1 ","FL:::/LT/Compiler/CmpDefs.HPZ,10"$0x008 001C StrConst +$LK,"EC_NOT ","FL:::/LT/Compiler/CmpDefs.HPZ,28"$0x017 0007 StrConst +$LK,"EC_NOT_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,55"$0x02A 0007 StrConst +$LK,"EC_NULL ","FL:::/LT/Compiler/CmpDefs.HPZ,2"$0x000 000E StrConst +$LK,"EC_NUM_ENTRIES ","FL:::/LT/Compiler/CmpDefs.HPZ,183"$0x093 0007 StrConst +$LK,"EC_OR ","FL:::/LT/Compiler/CmpDefs.HPZ,48"$0x025 0005 StrConst +$LK,"EC_OR_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,76"$0x03A 0005 StrConst +$LK,"EC_OR_OR ","FL:::/LT/Compiler/CmpDefs.HPZ,63"$0x030 000B StrConst +$LK,"EC_OUTP ","FL:::/LT/Compiler/CmpDefs.HPZ,124"$0x064 0004 StrConst +$LK,"EC_OUTPD ","FL:::/LT/Compiler/CmpDefs.HPZ,122"$0x062 0004 StrConst +$LK,"EC_OUTPW ","FL:::/LT/Compiler/CmpDefs.HPZ,123"$0x063 0004 StrConst +$LK,"EC_POP_REGS ","FL:::/LT/Compiler/CmpDefs.HPZ,149"$0x077 0005 StrConst +$LK,"EC_POWER ","FL:::/LT/Compiler/CmpDefs.HPZ,40"$0x020 0005 StrConst +$LK,"EC_PP_ ","FL:::/LT/Compiler/CmpDefs.HPZ,34"$0x01C 0005 StrConst +$LK,"EC_PREEMPT ","FL:::/LT/Compiler/CmpDefs.HPZ,181"$0x092 0004 StrConst +$LK,"EC_PUSH_CMP ","FL:::/LT/Compiler/CmpDefs.HPZ,180"$0x091 0006 StrConst +$LK,"EC_PUSH_REGS ","FL:::/LT/Compiler/CmpDefs.HPZ,148"$0x076 0006 StrConst +$LK,"EC_QUESTION ","FL:::/LT/Compiler/CmpDefs.HPZ,67"$0x033 0006 StrConst +$LK,"EC_RBP ","FL:::/LT/Compiler/CmpDefs.HPZ,17"$0x00F 0004 StrConst +$LK,"EC_RDTSC ","FL:::/LT/Compiler/CmpDefs.HPZ,125"$0x065 0004 StrConst +$LK,"EC_REG ","FL:::/LT/Compiler/CmpDefs.HPZ,18"$0x010 000B StrConst +$LK,"EC_REMQUE ","FL:::/LT/Compiler/CmpDefs.HPZ,115"$0x05B 0004 StrConst +$LK,"EC_RET ","FL:::/LT/Compiler/CmpDefs.HPZ,85"$0x041 0008 StrConst +$LK,"EC_RETURN_END ","FL:::/LT/Compiler/CmpDefs.HPZ,9"$0x007 000D StrConst +$LK,"EC_RETURN_START ","FL:::/LT/Compiler/CmpDefs.HPZ,8"$0x006 0009 StrConst +$LK,"EC_SET_BASE_PTR ","FL:::/LT/Compiler/CmpDefs.HPZ,102"$0x04F 0004 StrConst +$LK,"EC_SET_FLAGS ","FL:::/LT/Compiler/CmpDefs.HPZ,100"$0x04D 0004 StrConst +$LK,"EC_SET_RAX ","FL:::/LT/Compiler/CmpDefs.HPZ,105"$0x052 0007 StrConst +$LK,"EC_SET_STACK_PTR ","FL:::/LT/Compiler/CmpDefs.HPZ,104"$0x051 0005 StrConst +$LK,"EC_SHL ","FL:::/LT/Compiler/CmpDefs.HPZ,37"$0x01E 0005 StrConst +$LK,"EC_SHL_CONST ","FL:::/LT/Compiler/CmpDefs.HPZ,143"$0x072 0006 StrConst +$LK,"EC_SHL_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,71"$0x035 0006 StrConst +$LK,"EC_SHR ","FL:::/LT/Compiler/CmpDefs.HPZ,38"$0x01F 0005 StrConst +$LK,"EC_SHR_CONST ","FL:::/LT/Compiler/CmpDefs.HPZ,144"$0x073 0006 StrConst +$LK,"EC_SHR_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,72"$0x036 0006 StrConst +$LK,"EC_STI ","FL:::/LT/Compiler/CmpDefs.HPZ,93"$0x047 0004 StrConst +$LK,"EC_STRLEN ","FL:::/LT/Compiler/CmpDefs.HPZ,116"$0x05C 0004 StrConst +$LK,"EC_STR_CONST ","FL:::/LT/Compiler/CmpDefs.HPZ,13"$0x00B 0006 StrConst +$LK,"EC_SUB ","FL:::/LT/Compiler/CmpDefs.HPZ,52"$0x028 0008 StrConst +$LK,"EC_SUB_CONST ","FL:::/LT/Compiler/CmpDefs.HPZ,146"$0x075 0003 StrConst +$LK,"EC_SUB_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,79"$0x03D 0005 StrConst +$LK,"EC_SWITCH ","FL:::/LT/Compiler/CmpDefs.HPZ,128"$0x067 0005 StrConst +$LK,"EC_TYPE ","FL:::/LT/Compiler/CmpDefs.HPZ,15"$0x00D 0004 StrConst +$LK,"EC_UNARY_MINUS ","FL:::/LT/Compiler/CmpDefs.HPZ,29"$0x018 0005 StrConst +$LK,"EC_WBINVD ","FL:::/LT/Compiler/CmpDefs.HPZ,96"$0x04A 0004 StrConst +$LK,"EC_XOR ","FL:::/LT/Compiler/CmpDefs.HPZ,49"$0x026 0005 StrConst +$LK,"EC_XOR_EQUAL ","FL:::/LT/Compiler/CmpDefs.HPZ,77"$0x03B 0005 StrConst +$LK,"EC_XOR_XOR ","FL:::/LT/Compiler/CmpDefs.HPZ,64"$0x031 0005 StrConst +$LK,"EC__MM ","FL:::/LT/Compiler/CmpDefs.HPZ,33"$0x01B 0005 StrConst +$LK,"EC__PP ","FL:::/LT/Compiler/CmpDefs.HPZ,32"$0x01A 0005 StrConst +$LK+BI,"EvalExpression ","FL:::/LT/Compiler/Lex.CPZ,321",74$00002398 0000 Funct Export +$LK+BI,"ExePrintF ","FL:::/LT/Compiler/CmpMain.CPZ,43",75$00030710 0000 Funct Export +$LK+BI,"ExePutS ","FL:::/LT/Compiler/CmpMain.CPZ,30",76$00030678 0001 Funct Export +$LK+BI,"ExecuteCmdLine ","FL:::/LT/Compiler/CmpMain.CPZ,272",77$000314F0 0003 Funct Export +$LK+BI,"ExecuteFile ","FL:::/LT/Compiler/CmpMain.CPZ,385",78$00031B28 0001 Funct Export +$LK+BI,"ExecuteStr ","FL:::/LT/Compiler/CmpMain.CPZ,357",79$000319C0 0002 Funct Export +$LK+BI,"Expression ","FL:::/LT/Compiler/ExpParser.CPZ,827",80$00013D48 0003 Funct Export +$LK,"FBO1_DOUBLE ","FL:::/LT/Compiler/OptPass1.CPZ,4"$2 0002 StrConst +$LK,"FBO1_INT ","FL:::/LT/Compiler/OptPass1.CPZ,3"$1 0011 StrConst +$LK,"FBO1_NOT_CONST ","FL:::/LT/Compiler/OptPass1.CPZ,2"$0 0004 StrConst +$LK+BI,"FillCompilerTables ","FL:::/LT/Compiler/CmpInit.CPZ,441",81$0002FC50 0001 Funct Export +$LK+BI,"FindMember ","FL:::/LT/Compiler/Lex.CPZ,440",82$00002840 0003 Funct Export +$LK+BI,"FindPSect ","FL:::/LT/Compiler/SPrintF2.CPZ,42",83$000066D8 0001 Funct Export +$LK+BI,"FixupBinaryOp1 ","FL:::/LT/Compiler/OptPass1.CPZ,7",84$000211D0 0013 Funct Export +$LK+BI,"FixupBinaryOp2 ","FL:::/LT/Compiler/OptPass1.CPZ,67",85$00021428 0001 Funct Export +$LK+BI,"FixupUnaryOp ","FL:::/LT/Compiler/OptPass1.CPZ,83",86$00021490 0001 Funct Export +$LK+BI,"GetExpression ","FL:::/LT/Compiler/ExpParser.CPZ,818",87$00013D08 0000 Funct Export +$LK+BI,"GetFJoin2 ","FL:::/LT/Compiler/SPrintF2.CPZ,872",88$0000B218 0001 Funct Export +$LK+BI,"Ic66Rex ","FL:::/LT/Compiler/Code.CPZ,99",89$00018A68 0005 Funct Export +$LK+BI,"IcAddConst ","FL:::/LT/Compiler/Code.CPZ,725",90$0001AA90 0004 Funct Export +$LK+BI,"IcAddEct ","FL:::/LT/Compiler/Code.CPZ,683",91$0001A818 0005 Funct Export +$LK+BI,"IcAddSubEctEqual ","FL:::/LT/Compiler/Code.CPZ,1160",92$0001C580 0005 Funct Export +$LK+BI,"IcAndAnd ","FL:::/LT/Compiler/Code.CPZ,1411",93$0001D550 0001 Funct Export +$LK+BI,"IcAndBranch ","FL:::/LT/Compiler/Code.CPZ,2103",94$0001FCA8 0002 Funct Export +$LK+BI,"IcAssign ","FL:::/LT/Compiler/Code.CPZ,2168",95$0001FFD0 0001 Funct Export +$LK+BI,"IcBitOps ","FL:::/LT/Compiler/Code.CPZ,1678",96$0001E5C8 0007 Funct Export +$LK+BI,"IcBrBitOps ","FL:::/LT/Compiler/Code.CPZ,2416",97$00020D58 000E Funct Export +$LK+BI,"IcCmp ","FL:::/LT/Compiler/Code.CPZ,1553",98$0001DE88 0006 Funct Export +$LK+BI,"IcCmpAndBranch ","FL:::/LT/Compiler/Code.CPZ,1825",99$0001EDE8 0006 Funct Export +$LK+BI,"IcColon ","FL:::/LT/Compiler/Code.CPZ,1517",100$0001DBB8 0001 Funct Export +$LK+BI,"IcCopyIrq ","FL:::/LT/Compiler/Code.CPZ,188",101$00018F38 001C Funct Export +$LK+BI,"IcDeref ","FL:::/LT/Compiler/Code.CPZ,665",102$0001A730 0001 Funct Export +$LK+BI,"IcDiv ","FL:::/LT/Compiler/Code.CPZ,1068",103$0001BF38 0001 Funct Export +$LK+BI,"IcDivEqual ","FL:::/LT/Compiler/Code.CPZ,1087",104$0001C078 0002 Funct Export +$LK+BI,"IcFCmp ","FL:::/LT/Compiler/Code.CPZ,2229",105$00020388 0004 Funct Export +$LK+BI,"IcFCmpAndBranch ","FL:::/LT/Compiler/Code.CPZ,2300",106$000207E8 0004 Funct Export +$LK+BI,"IcFOp1 ","FL:::/LT/Compiler/Code.CPZ,2200",107$00020200 0001 Funct Export +$LK+BI,"IcFOp2 ","FL:::/LT/Compiler/Code.CPZ,2210",108$00020280 0006 Funct Export +$LK+BI,"IcFOp2Equal ","FL:::/LT/Compiler/Code.CPZ,2256",109$000204E0 0005 Funct Export +$LK+BI,"IcFPostIncDec ","FL:::/LT/Compiler/Code.CPZ,2388",110$00020BC8 0002 Funct Export +$LK+BI,"IcFPreIncDec ","FL:::/LT/Compiler/Code.CPZ,2366",111$00020A88 0002 Funct Export +$LK+BI,"IcLea ","FL:::/LT/Compiler/Code.CPZ,644",112$0001A5F0 0003 Funct Export +$LK+BI,"IcMod ","FL:::/LT/Compiler/Code.CPZ,1141",113$0001C440 0001 Funct Export +$LK+BI,"IcModr ","FL:::/LT/Compiler/Code.CPZ,207",114$00019050 000C Funct Export +$LK+BI,"IcMov ","FL:::/LT/Compiler/Code.CPZ,431",115$00019A18 0141 Funct Export +$LK+BI,"IcMul ","FL:::/LT/Compiler/Code.CPZ,943",116$0001B6C8 0001 Funct Export +$LK+BI,"IcMulEqual ","FL:::/LT/Compiler/Code.CPZ,1000",117$0001BA08 0001 Funct Export +$LK+BI,"IcNot ","FL:::/LT/Compiler/Code.CPZ,1400",118$0001D4A8 0001 Funct Export +$LK+BI,"IcOr ","FL:::/LT/Compiler/Code.CPZ,420",119$000199B8 000D Funct Export +$LK+BI,"IcOrOr ","FL:::/LT/Compiler/Code.CPZ,1444",120$0001D768 0001 Funct Export +$LK+BI,"IcPop ","FL:::/LT/Compiler/Code.CPZ,381",121$000197E8 0003 Funct Export +$LK+BI,"IcPopRegs ","FL:::/LT/Compiler/Code.CPZ,398",122$000198C8 000F Funct Export +$LK+BI,"IcPostIncDec ","FL:::/LT/Compiler/Code.CPZ,1798",123$0001EC60 0002 Funct Export +$LK+BI,"IcPreIncDec ","FL:::/LT/Compiler/Code.CPZ,1773",124$0001EAF8 0002 Funct Export +$LK+BI,"IcPreempt ","FL:::/LT/Compiler/Code.CPZ,1742",125$0001E948 0001 Funct Export +$LK+BI,"IcPush ","FL:::/LT/Compiler/Code.CPZ,295",126$000193B8 0007 Funct Export +$LK+BI,"IcPushRegs ","FL:::/LT/Compiler/Code.CPZ,368",127$00019768 000A Funct Export +$LK+BI,"IcRex ","FL:::/LT/Compiler/Code.CPZ,85",128$000189B8 000D Funct Export +$LK+BI,"IcShift ","FL:::/LT/Compiler/Code.CPZ,1303",129$0001CE68 0004 Funct Export +$LK+BI,"IcShiftEqual ","FL:::/LT/Compiler/Code.CPZ,1325",130$0001CFE0 0002 Funct Export +$LK+BI,"IcSlashOp ","FL:::/LT/Compiler/Code.CPZ,267",131$00019220 0008 Funct Export +$LK+BI,"IcSubEct ","FL:::/LT/Compiler/Code.CPZ,900",132$0001B448 0001 Funct Export +$LK+BI,"IcTestAndBranch ","FL:::/LT/Compiler/Code.CPZ,2062",133$0001FB00 0002 Funct Export +$LK+BI,"IcU1 ","FL:::/LT/Compiler/Code.CPZ,73",134$00018910 0042 Funct Export +$LK+BI,"IcU2 ","FL:::/LT/Compiler/Code.CPZ,125",135$00018BE0 0073 Funct Export +$LK+BI,"IcU3 ","FL:::/LT/Compiler/Code.CPZ,140",136$00018CC0 0076 Funct Export +$LK+BI,"IcU4 ","FL:::/LT/Compiler/Code.CPZ,157",137$00018DD8 005D Funct Export +$LK+BI,"IcU8 ","FL:::/LT/Compiler/Code.CPZ,173",138$00018E88 0002 Funct Export +$LK+BI,"IcUnaries ","FL:::/LT/Compiler/Code.CPZ,1391",139$0001D420 0002 Funct Export +$LK+BI,"IcXorXor ","FL:::/LT/Compiler/Code.CPZ,1480",140$0001D980 0001 Funct Export +$LK+BI,"IcZero ","FL:::/LT/Compiler/Code.CPZ,411",141$00019948 0018 Funct Export +$LK+BI,"InitCompiler ","FL:::/LT/Compiler/CmpInit.CPZ,590",142$000302C0 0001 Funct Export +$LK,"KW_ASM ","FL:::/LT/Compiler/CmpDefs.HPZ,208"$21 0001 StrConst +$LK,"KW_ASSERT ","FL:::/LT/Compiler/CmpDefs.HPZ,225"$38 0001 StrConst +$LK,"KW_BREAK ","FL:::/LT/Compiler/CmpDefs.HPZ,211"$24 0001 StrConst +$LK,"KW_CASE ","FL:::/LT/Compiler/CmpDefs.HPZ,214"$27 0001 StrConst +$LK,"KW_CATCH ","FL:::/LT/Compiler/CmpDefs.HPZ,190"$3 0001 StrConst +$LK,"KW_CLASS ","FL:::/LT/Compiler/CmpDefs.HPZ,191"$4 0003 StrConst +$LK,"KW_CONTINUE ","FL:::/LT/Compiler/CmpDefs.HPZ,212"$25 0001 StrConst +$LK,"KW_COUT ","FL:::/LT/Compiler/CmpDefs.HPZ,206"$19 0001 StrConst +$LK,"KW_COUTLN ","FL:::/LT/Compiler/CmpDefs.HPZ,221"$34 0001 StrConst +$LK,"KW_DEFAULT ","FL:::/LT/Compiler/CmpDefs.HPZ,215"$28 0001 StrConst +$LK,"KW_DEFINE ","FL:::/LT/Compiler/CmpDefs.HPZ,188"$1 0001 StrConst +$LK,"KW_DO ","FL:::/LT/Compiler/CmpDefs.HPZ,207"$20 0001 StrConst +$LK,"KW_ELSE ","FL:::/LT/Compiler/CmpDefs.HPZ,194"$7 0005 StrConst +$LK,"KW_ENDIF ","FL:::/LT/Compiler/CmpDefs.HPZ,224"$37 0005 StrConst +$LK,"KW_EXE ","FL:::/LT/Compiler/CmpDefs.HPZ,210"$23 0001 StrConst +$LK,"KW_EXTERN ","FL:::/LT/Compiler/CmpDefs.HPZ,197"$10 0001 StrConst +$LK,"KW_FMTDATA ","FL:::/LT/Compiler/CmpDefs.HPZ,203"$16 0002 StrConst +$LK,"KW_FMTSTR ","FL:::/LT/Compiler/CmpDefs.HPZ,202"$15 0002 StrConst +$LK,"KW_FOR ","FL:::/LT/Compiler/CmpDefs.HPZ,195"$8 0001 StrConst +$LK,"KW_GOTO ","FL:::/LT/Compiler/CmpDefs.HPZ,209"$22 0001 StrConst +$LK,"KW_HELP_FILE ","FL:::/LT/Compiler/CmpDefs.HPZ,230"$43 0001 StrConst +$LK,"KW_HELP_INDEX ","FL:::/LT/Compiler/CmpDefs.HPZ,229"$42 0001 StrConst +$LK,"KW_IF ","FL:::/LT/Compiler/CmpDefs.HPZ,193"$6 0006 StrConst +$LK,"KW_IFDEF ","FL:::/LT/Compiler/CmpDefs.HPZ,222"$35 0006 StrConst +$LK,"KW_IFNDEF ","FL:::/LT/Compiler/CmpDefs.HPZ,223"$36 0006 StrConst +$LK,"KW_IMPORT ","FL:::/LT/Compiler/CmpDefs.HPZ,219"$32 0001 StrConst +$LK,"KW_INCLUDE ","FL:::/LT/Compiler/CmpDefs.HPZ,187"$0 0001 StrConst +$LK,"KW_INPUT_FUN ","FL:::/LT/Compiler/CmpDefs.HPZ,205"$18 0000 StrConst +$LK,"KW_INTERNAL ","FL:::/LT/Compiler/CmpDefs.HPZ,201"$14 0001 StrConst +$LK,"KW_LTEXTERN ","FL:::/LT/Compiler/CmpDefs.HPZ,198"$11 0001 StrConst +$LK,"KW_LTIMPORT ","FL:::/LT/Compiler/CmpDefs.HPZ,220"$33 0001 StrConst +$LK,"KW_NOREG ","FL:::/LT/Compiler/CmpDefs.HPZ,227"$40 0001 StrConst +$LK,"KW_NOUNUSEDWARN ","FL:::/LT/Compiler/CmpDefs.HPZ,228"$41 0001 StrConst +$LK,"KW_OFFSET ","FL:::/LT/Compiler/CmpDefs.HPZ,217"$30 0001 StrConst +$LK,"KW_OUTPUT_FUN ","FL:::/LT/Compiler/CmpDefs.HPZ,204"$17 0000 StrConst +$LK,"KW_PUBLIC ","FL:::/LT/Compiler/CmpDefs.HPZ,216"$29 0001 StrConst +$LK,"KW_REG ","FL:::/LT/Compiler/CmpDefs.HPZ,226"$39 0001 StrConst +$LK,"KW_RETURN ","FL:::/LT/Compiler/CmpDefs.HPZ,199"$12 0001 StrConst +$LK,"KW_SIZEOF ","FL:::/LT/Compiler/CmpDefs.HPZ,200"$13 0001 StrConst +$LK,"KW_SWITCH ","FL:::/LT/Compiler/CmpDefs.HPZ,213"$26 0001 StrConst +$LK,"KW_TRY ","FL:::/LT/Compiler/CmpDefs.HPZ,192"$5 0001 StrConst +$LK,"KW_TYPEOF ","FL:::/LT/Compiler/CmpDefs.HPZ,218"$31 0000 StrConst +$LK,"KW_UNION ","FL:::/LT/Compiler/CmpDefs.HPZ,189"$2 0004 StrConst +$LK,"KW_WHILE ","FL:::/LT/Compiler/CmpDefs.HPZ,196"$9 0002 StrConst +$LK+BI,"Lex ","FL:::/LT/Compiler/Lex.CPZ,542",143$00002CA0 00F4 Funct Export +$LK+BI,"LexBackupLastChar ","FL:::/LT/Compiler/Lex.CPZ,119",144$00001A70 0003 Funct Export +$LK+BI,"LexDel ","FL:::/LT/Compiler/Lex.CPZ,68",145$00001788 0005 Funct Export +$LK+BI,"LexExtendStr ","FL:::/LT/Compiler/Lex.CPZ,1113",146$000046A0 0004 Funct Export +$LK+BI,"LexGetChar ","FL:::/LT/Compiler/Lex.CPZ,130",147$00001AD0 0026 Funct Export +$LK+BI,"LexInStr ","FL:::/LT/Compiler/Lex.CPZ,477",148$000029C0 0001 Funct Export +$LK+BI,"LexIncludeLtf ","FL:::/LT/Compiler/Lex.CPZ,356",149$000024D0 0001 Funct Export +$LK+BI,"LexIncludeStr ","FL:::/LT/Compiler/Lex.CPZ,334",150$00002408 0003 Funct Export +$LK+BI,"LexLineNum ","FL:::/LT/Compiler/Lex.CPZ,1155",151$000048B8 0008 Funct Export +$LK+BI,"LexNew ","FL:::/LT/Compiler/Lex.CPZ,38",152$00001630 0005 Funct Export +$LK+BI,"LexPop ","FL:::/LT/Compiler/Lex.CPZ,428",153$00002790 0002 Funct Export +$LK+BI,"LexPush ","FL:::/LT/Compiler/Lex.CPZ,416",154$000026C8 000A Funct Export +$LK+BI,"LexPutLine ","FL:::/LT/Compiler/Lex.CPZ,1139",155$000047D0 0003 Funct Export +$LK+BI,"LexPutLink ","FL:::/LT/Compiler/Lex.CPZ,1160",156$000048D8 0002 Funct Export +$LK+BI,"LexPutToken ","FL:::/LT/Compiler/Lex.CPZ,100",157$00001948 0003 Funct Export +$LK+BI,"LexSkipEol ","FL:::/LT/Compiler/Lex.CPZ,308",158$00002328 0007 Funct Export +$LK+BI,"LoadAsmHash ","FL:::/LT/Compiler/CmpInit.CPZ,1",159$0002D2F8 0001 Funct Export +$LK+BI,"LoadCompileSysText ","FL:::/LT/Compiler/CmpInit.CPZ,191",160$0002DCD0 0001 Funct Export +$LK+BI,"MSPrintFDate ","FL:::/LT/Compiler/SPrintF2.CPZ,175",161$00007518 0001 Funct Export +$LK+BI,"MSPrintFTime ","FL:::/LT/Compiler/SPrintF2.CPZ,96",162$000068F8 0001 Funct Export +$LK+BI,"OptBrNotZero ","FL:::/LT/Compiler/OptPass1.CPZ,343",163$00022000 0004 Funct Export +$LK+BI,"OptBrZero ","FL:::/LT/Compiler/OptPass1.CPZ,206",164$00021948 0006 Funct Export +$LK+BI,"OptEnd ","FL:::/LT/Compiler/OptPass1.CPZ,161",165$000217D0 0005 Funct Export +$LK+BI,"OptLag ","FL:::/LT/Compiler/OptPass1.CPZ,171",166$00021878 0004 Funct Export +$LK+BI,"OptLag1 ","FL:::/LT/Compiler/OptPass1.CPZ,182",167$000218B8 0002 Funct Export +$LK+BI,"OptLead1 ","FL:::/LT/Compiler/OptPass1.CPZ,193",168$00021900 0002 Funct Export +$LK+BI,"OptMissing ","FL:::/LT/Compiler/OptPass1.CPZ,131",169$00021600 0004 Funct Export +$LK,"OptNext ","FL:::/LT/Compiler/OptPass1.CPZ,152"$00001060 0002 Funct +$LK,"OptNext2 ","FL:::/LT/Compiler/OptPass1.CPZ,155"$000010D8 0002 Funct +$LK,"OptNext3 ","FL:::/LT/Compiler/OptPass1.CPZ,158"$00001150 0001 Funct +$LK+BI,"OptStart ","FL:::/LT/Compiler/OptPass1.CPZ,141",170$00021740 0005 Funct Export +$LK+BI,"OutChar ","FL:::/LT/Compiler/SPrintF2.CPZ,1",171$000064F8 0026 Funct Export +$LK+BI,"OutStr ","FL:::/LT/Compiler/SPrintF2.CPZ,19",172$000065B8 0008 Funct Export +$LK,"PG_EXTERN ","FL:::/LT/Compiler/StmtParser.CPZ,579"$4 0007 StrConst +$LK,"PG_IMPORT ","FL:::/LT/Compiler/StmtParser.CPZ,580"$5 0004 StrConst +$LK,"PG_LTEXTERN ","FL:::/LT/Compiler/StmtParser.CPZ,576"$1 0004 StrConst +$LK,"PG_LTIMPORT ","FL:::/LT/Compiler/StmtParser.CPZ,578"$3 0006 StrConst +$LK,"PG_LTINTERN ","FL:::/LT/Compiler/StmtParser.CPZ,577"$2 0002 StrConst +$LK,"PG_NULL ","FL:::/LT/Compiler/StmtParser.CPZ,575"$0 0001 StrConst +$LK,"PRST_CHECK_BINARY_OPS ","FL:::/LT/Compiler/ExpParser.CPZ,7"$3 000E StrConst +$LK,"PRST_DEREFERRENCE ","FL:::/LT/Compiler/ExpParser.CPZ,6"$2 0004 StrConst +$LK,"PRST_UNARY_MODIFIERS ","FL:::/LT/Compiler/ExpParser.CPZ,5"$1 000A StrConst +$LK,"PRST_UNARY_TERM ","FL:::/LT/Compiler/ExpParser.CPZ,4"$0 0005 StrConst +$LK,"PVLM_CLASS ","FL:::/LT/Compiler/StmtParser.CPZ,14"$2 0001 StrConst +$LK,"PVLM_FUNCTION_PARAM ","FL:::/LT/Compiler/StmtParser.CPZ,13"$1 0004 StrConst +$LK,"PVLM_LOCAL_VAR ","FL:::/LT/Compiler/StmtParser.CPZ,12"$0 0005 StrConst +$LK,"PVLM_UNION ","FL:::/LT/Compiler/StmtParser.CPZ,15"$3 0000 StrConst +$LK+BI,"ParseAsmArg ","FL:::/LT/Compiler/AsmMain.CPZ,491",173$0000D3A8 0002 Funct Export +$LK+BI,"ParseAsmImm ","FL:::/LT/Compiler/AsmMain.CPZ,454",174$0000D238 0006 Funct Export +$LK+BI,"PrsDereferrence ","FL:::/LT/Compiler/ExpParser.CPZ,757",175$00013A88 0000 Funct Export +$LK+BI,"PrsExcept ","FL:::/LT/Compiler/Lex.CPZ,1215",176$00004C50 006E Funct Export +$LK+BI,"PrsParseExpression ","FL:::/LT/Compiler/ExpParser.CPZ,9",177$00010CF0 0011 Funct Export +$LK+BI,"PrsParseGlblInit ","FL:::/LT/Compiler/StmtParser.CPZ,551",178$00015738 0001 Funct Export +$LK,"PrsPop ","FL:::/LT/Compiler/ExpParser.CPZ,2"$00001200 001B Funct +$LK,"PrsPush ","FL:::/LT/Compiler/ExpParser.CPZ,1"$000011E0 0015 Funct +$LK+BI,"PrsUnaryModifier ","FL:::/LT/Compiler/ExpParser.CPZ,571",179$00013098 0000 Funct Export +$LK+BI,"PrsUnaryTerm ","FL:::/LT/Compiler/ExpParser.CPZ,175",180$00011630 0000 Funct Export +$LK+BI,"PrsVarInit ","FL:::/LT/Compiler/StmtParser.CPZ,458",181$00015240 0002 Funct Export +$LK+BI,"PutAsmError ","FL:::/LT/Compiler/Lex.CPZ,1201",182$00004BD0 0023 Funct Export +$LK+BI,"PutAsmWarning ","FL:::/LT/Compiler/Lex.CPZ,1208",183$00004C10 0003 Funct Export +$LK+BI,"PutLexError ","FL:::/LT/Compiler/Lex.CPZ,1171",184$000049E0 0002 Funct Export +$LK+BI,"PutLexWarning ","FL:::/LT/Compiler/Lex.CPZ,1192",185$00004B48 0001 Funct Export +$LK+BI,"ResolveGlbls ","FL:::/LT/Compiler/AsmMain.CPZ,303",186$0000C8F8 0001 Funct Export +$LK+BI,"ResolveLocals ","FL:::/LT/Compiler/AsmMain.CPZ,234",187$0000C448 0004 Funct Export +$LK,"SLASH_OP_DEC ","FL:::/LT/Compiler/Code.CPZ,261"$0xFFFE01 0002 StrConst +$LK,"SLASH_OP_INC ","FL:::/LT/Compiler/Code.CPZ,260"$0xFFFE00 0002 StrConst +$LK,"SLASH_OP_MOV ","FL:::/LT/Compiler/Code.CPZ,265"$0x898800 0001 StrConst +$LK,"SLASH_OP_MUL ","FL:::/LT/Compiler/Code.CPZ,264"$0xF7F604 0000 StrConst +$LK,"SLASH_OP_NEG ","FL:::/LT/Compiler/Code.CPZ,263"$0xF7F603 0001 StrConst +$LK,"SLASH_OP_NOT ","FL:::/LT/Compiler/Code.CPZ,262"$0xF7F602 0001 StrConst +$LK+BI,"SPrintFJoin2 ","FL:::/LT/Compiler/SPrintF2.CPZ,295",188$00008818 0001 Funct Export +$LK+BI,"SPrintFPSect ","FL:::/LT/Compiler/SPrintF2.CPZ,77",189$000067C8 0002 Funct Export +$LK+BI,"SetSourceFileInfo ","FL:::/LT/Compiler/Lex.CPZ,88",190$00001898 000B Funct Export +$LK,"SwitchCaseEntry ","FL:::/LT/Compiler/StmtParser.CPZ,889"$1800000003 0003 Class +$LK,"TEMP_BUF_LEN ","FL:::/LT/Compiler/SPrintF2.CPZ,293"$256 0008 StrConst +$LK+BI,"UndefinedExtern ","FL:::/LT/Compiler/StmtParser.CPZ,257",191$00014908 0001 Funct Export +$LK+BI,"UnusedExternWarning ","FL:::/LT/Compiler/StmtParser.CPZ,263",192$00014960 0004 Funct Export +$LK,"asm_hash ","FL:::/LT/Compiler/CmpGlbls.CPZ,1"$00001234 0005 GlbVar Export +$LK,"assign_bitmap ","FL:::/LT/Compiler/CmpGlbls.CPZ,8"$000012E4 0005 GlbVar Export +$LK,"binary_ops_table ","FL:::/LT/Compiler/CmpGlbls.CPZ,6"$000012BC 0002 GlbVar Export +$LK,"cmp_bitmap ","FL:::/LT/Compiler/CmpGlbls.CPZ,8"$000012F4 0004 GlbVar Export +$LK,"cmp_do_not_write_to_disk ","FL:::/LT/Compiler/CmpGlbls.CPZ,2"$00001240 0002 GlbVar Export +$LK,"cmp_param_cnt ","FL:::/LT/Compiler/CmpGlbls.CPZ,7"$000012CC 0008 GlbVar Export +$LK,"cmp_result_cnt ","FL:::/LT/Compiler/CmpGlbls.CPZ,7"$000012D4 0005 GlbVar Export +$LK,"deref_bitmap ","FL:::/LT/Compiler/CmpGlbls.CPZ,8"$000012DC 0005 GlbVar Export +$LK,"duel_I1_tokens1 ","FL:::/LT/Compiler/CmpGlbls.CPZ,5"$000012A4 0002 GlbVar Export +$LK,"duel_I1_tokens2 ","FL:::/LT/Compiler/CmpGlbls.CPZ,5"$000012AC 0002 GlbVar Export +$LK,"duel_I1_tokens3 ","FL:::/LT/Compiler/CmpGlbls.CPZ,5"$000012B4 0002 GlbVar Export +$LK,"internal_types_table ","FL:::/LT/Compiler/CmpDefs2.HPZ,20"$00000E50 0001 GlbVar Export +$LK,"is_first_compiler ","FL:::/LT/Compiler/CmpGlbls.CPZ,2"$0000123C 0002 GlbVar Export +$LK,"lex_line_feed ","FL:::/LT/Compiler/Lex.CPZ,117"$00001A6C 0001 GlbVar Export +$LK,"lex_zeros ","FL:::/LT/Compiler/Lex.CPZ,117"$00001A68 0009 GlbVar Export +$LK,"non_ptr_vars_mask ","FL:::/LT/Compiler/CmpGlbls.CPZ,10"$00001324 0006 GlbVar Export +$LK,"not_constant_bitmap ","FL:::/LT/Compiler/CmpGlbls.CPZ,8"$000012EC 0003 GlbVar Export +$LK,"num_non_ptr_vars ","FL:::/LT/Compiler/CmpGlbls.CPZ,9"$0000130C 0003 GlbVar Export +$LK,"num_reg_vars ","FL:::/LT/Compiler/CmpGlbls.CPZ,9"$00001304 0003 GlbVar Export +$LK,"num_stk_temps ","FL:::/LT/Compiler/CmpGlbls.CPZ,9"$000012FC 0004 GlbVar Export +$LK,"opt_nop ","FL:::/LT/Compiler/OptPass1.CPZ,138"$000216A0 0007 GlbVar Export +$LK,"reg_vars_mask ","FL:::/LT/Compiler/CmpGlbls.CPZ,10"$0000131C 0002 GlbVar Export +$LK,"stk_temps_mask ","FL:::/LT/Compiler/CmpGlbls.CPZ,10"$00001314 0003 GlbVar Export +$LK,"sys_internal_types ","FL:::/LT/Compiler/CmpGlbls.CPZ,3"$00001244 0089 GlbVar Export +$LK,"to_non_ptr_vars_map ","FL:::/LT/Compiler/CmpGlbls.CPZ,13"$00001344 0003 GlbVar Export +$LK,"to_reg_vars_map ","FL:::/LT/Compiler/CmpGlbls.CPZ,13"$0000133C 0003 GlbVar Export +$LK,"to_stk_temps_map_even ","FL:::/LT/Compiler/CmpGlbls.CPZ,12"$00001334 0008 GlbVar Export +$LK,"to_stk_temps_map_odd ","FL:::/LT/Compiler/CmpGlbls.CPZ,11"$0000132C 0008 GlbVar Export +$LK,"unary_ops_table ","FL:::/LT/Compiler/CmpGlbls.CPZ,6"$000012C4 0002 GlbVar Export +ØÚ`ªyªƒª‹ª’ª¤ª°ª¶ª½ªÇªÕªâªöªøª « «%«/«1«7«A«O«\«p«s«x«¬¬¬!¬&¬0¬5¬;¬B¬L¬O¬]¬j¬~¬ƒ¬Ò¬Ô¬Þ¬ã¬÷¬%­8­'f8­M­U­t­‘­•­›­¡­¸­Ï­ù­þ­®3®8®>®m®r®x®¤®©®¯®Å®È®ä® ¯5¯:¯^¯~¯£¯Ç¯ç¯ °°"°'°L°Š°‘°°°Å°Ê°è°ò°±±8±?±]±y±¢±¼±Ö±í±²à�¦ðùV{�¿á%1Ahu‚”¡´¹ÀÁËæà&?À»é»¼ ¼¼¼¼ ¼&¼.¼6¼>¼H¼R¼Y¼o¼–¼¬¼³¼µ¼¿¼Æ¼Ð¼ã¼˜%°ãÌãÚãåãìãä ää*ä4äUäkä�äˆä´ä»ä¿äÆäÉäÓäÚäääîäåå#å,å2å=å@åEåqå�å³åÉåÔåêåõåþåæ æææ4æ?æKæRæeæxæ‚æ”æ¨æ¼æÃæÎæÙæåæðæûæççç(çXç_çlç¿çÌçàçççëç÷çûçèè#è*èQèUè`èkèvè�èŒè—è¥è°èµèËè×èâèæèëèïèùèéééé*é1é=éDéOéVéxééƒéŽé™é¤é¯éºéÅéÊé÷éêêêê<ê@êKêRê`ênêyê„ê�êšê¥êÓê×êâêõêüêë ëëë1ë;ëBëGëRëVëaëzëŽë¢ë·ë»ëÆëÑëÜëçëòëì2ì9ìVì©ì¶ìÌìàìëìïìíí8íMíQílí€í‹í�í¤í¹í½íçíõíÿíîî&î.î=îUîcîhî}î�î˜îœî¡î¾îÓî×îíîøîïïïïï&ï1ï8ïHïOï_ïfïvï}ïˆï�ï±ï¼ïÀïËïÖïáïìï÷ïðð4ð?ðCðNðRðyð}ðˆð�ð�ðÄðÓðÞðéðôðÿð +ññ#ñ.ñ3ñAñLñWñbñmñxñ¦ñªñµñÈñÏñÚñßñæñññòòòò%ò)ò4òMòXòcònòyò„ò’ò�ò­ò·òÒòäòöòóó,ó:óEóUó_óxóŒó—ó¢ó­ó¸óÃóâóô*ô/ô:ô>ôTôjô|ôŽô ô²ôÄôåô õ1õ6õAõEõeõzõ’õ õµõÐõÓõçõôõö!ö,ö3ö>öEöSöaöhövö„ö’ö ö®ö¼öÊöØöæöôö÷÷÷,÷:÷H÷V÷d÷r÷~÷�÷ ÷°÷à÷ð÷ø÷"ø-øVø^øiøtø„ø”ø¤ø´øÄøÔøäøôøùù'ùAùjù�ù¤ùÕùìùýùú%ú<úLúkúÈúÏúßúñúNûUû_ûuûwûæû ×è€Ã‘ÔßçòÃÈÃÓÃÕÃàÃüÃ Ä Ä"ÄAÄÐAXè¼û¼ ½½½B½U½b½o½‹½–½¾½Ð½Õ½Ü½å½ç½ò½ù½¾ ¾@o´XÙiÙwÙŽÙ�٬ٻÙÊÙÙÙæÙëÙÚÚ!Ú0Ú?ÚLÚfÚxÚÚ�Ú¢Ú§ÚµÚ¿ÚÕÚïÚôÚþÚÛ+Û1ÛGÛRÛ\ÛrÛŠÛŸÛ¾ÛÓÛõÛ +Ü,ÜAÜgÜ|ܨܽÜ×ÜòÜùÜÝÝ0Ý;ÝQÝÐÝ ðZu ¾;¾B¾M¾T¾_¾j¾v¾€¾‹¾“¾´¾·¾¹¾»¾½¾ã¾ð¾¿ ¿*¿5¿@¿P¿[¿r¿ +�ÅÔ¸ÂÙÂàÂëÂõÂÃÃ)Ã3Ã6Ã8ÃNÃ]ÃkÃ~à @wœx¿‘¿˜¿£¿²¿¹¿¾¿Ç¿ê¿ï¿ö¿À ÀÀ"À-À5ÀVÀYÀ[À]À_ÀvÀ~ÀƒÀ�À¸ÀÀÀÊÀÕÀàÀðÀûÀÁ @žÃÁ1Á8ÁCÁRÁYÁ^ÁgÁŠÁ�Á–Á¡Á¬Á¸ÁÂÁÍÁÕÁöÁùÁûÁýÁÿÁÂÂ"Â/ÂTÂ\ÂfÂqÂ|Œ—±Â X¹!ÐÝýÝÞÞ'Þ2Þ7ÞnÞxÞ¯Þ±ÞÄÞØÞßÞæÞðÞ÷Þßß#ßZßdß›ß�ß¶ßÊßÏßÖßàßåßçßùß à&àEàYà`àpàuà¬à¶àíàá!á/á:áIáSáXálá‡á¦áºáÁáÑáÚáâ âVâkâŠâ˜â£â²â¼âÁâÒâíâããã(ã-ã­ãèhsŠÅÿGb”¯áæþ7HMd|µÆßòw–³W!W(W/W7W@WDWLWZWfWmWqWyW�WŒW“WœW½WÄWËWÎWÕWÜWêWñWX¨ ¨[¿[Ê[Ø[á[ +\\,\6\D\O\i\v\Ð4x\‘\˜\¤\©\¬\¯\±\»\â\é\ð\÷\ü\]#]&]@]D]F]M]`]˜7‡`]€]œ]¥]°]»]É]Ú]ñ]ü] ^^+^B^M^c^q^‚^™^¤^¼^Ê^Û^ò^ý^__'_>_I_V_d_u_Œ_—_¥_¶_Í_ÿ_ ``5`j`ˆ`–`§`¾`ò`aa+a;aRa{a›aÄaòa b#b&cpÖá`YwY~YƒYŽY®Y³Y¶Y¸YºYÇY€µÂXX!X(X.X9XnAnQn[n^nwn|n�n•n˜n�nµn¸n¼nÄnÌnånênònooo3o?oVolovo‡ožo´oÇoÌoÜoìoþopp#p&p?pDpIpephpmp‰pŒp�p˜p p¹p¾pÆpÖpæpðpþp q#q:qBq^qzq†q‹q“q›q«q»qÀqÌqÔqÜqæqôq rrr!r(F(M(a(n(„(ž(£(§(±(µ(½(Å(Í(ã(ë(ð())) ),)2):)?)I)T)Y)e)k)s)ˆ)š)¬)Ã)È)Ú)è)ú)ÿ) ****(*:*?*K*Q*Y*n*€*’*©*®*Í*Ó*Þ*ã*è*ò*++ +7+<+_+‰+ž+°+Â+Ù+Þ+ã+ø+ +,,3,8,U,],g,o,�,†,˜,�,¯,·,Ì,Þ,ð,- ---7-A-P-a-f-k-z--’-ž-£-«-³-¸-Í-ß-ñ-. ...8.B.Q.e.j.o.~.ƒ.–.¢.§.¯.·.¼.Ñ.ç.ù.//6/@/N/]/q/v/{/‰/½/Â/Ç/í/ò/÷/0 0000(060:0T0Y0l0r0z00‡0�0�0¥0¨0­0Ñ0Ý0å0ë0ó011131E1X1j1�1†1§1Í1×1å1ö1 222<2A2F2T2X2r2‹2�2£2¨2°2µ2½2Å2Ó2Û2Þ2ã2333 30353J3`3r3…3—3®3³3Ô3ú344#494>4C4w4|4�4�4“4­4Æ4Ë4õ4ý455-5?5R5d5{5€5¡5­5³5¸5Â5×5í5ÿ56$6;6@6a6m6w6|6†6›6±6Ã6Ö6è6ÿ67%717;7@7J7_7u7‡7š7¬7Ã7È7é7ó7ÿ78 88K8P8U8{8€8…8“8¡8¯8Ä8Ð8Þ8ù89 9'9,949<9J9R9U9o9{9‰9¤9Ä9Ê9Ò9×9ß9ç9õ9ý9::!:/:D:P:^:y:™:ž:¦:«:³:»:É:Ñ:Ô:î:ú:;#;C;H;P;U;];e;s;{;~;“;©;»;Î;à;÷;ü;<'<3<8<=<c<h<m<ˆ<›< <¨<­<µ<½<Ë<Ó<Ö<ë<==&=8=O=T=r=ˆ=�=¨=°=Å=Û=í=>>)>8>@>W>\>z>�>•>°>¸>Í>ã>õ>??1?@?H?_?d?…?�?�?³?Î?Ó?@ @@@$@:@B@W@m@@’@¤@»@Ê@Ò@é@î@AA'A=AXA]AŽA“A˜A¦A®AÄAÌAáA÷A BB.BEBTB\BsBxB™B£B±BÇBâBçBCC"C0C8CNCVCkC�C“C¦C¸CÏCÞCæCýCD#D-D;DQDlDqD¢D§D¬DºDÂDØDàDõD EE0EBEYEhEpE‡EŒEªEÅEÊEßEõEFF,FCFUFZFxFŽF“F¨F¾FÐFãFõF GG#GAGdGiG~G”G¦G¹GËGâGôGùGH"H/H7HMH_HdHzH†H›H±HÃHÚHßHíHII)IMI]IbIxIŽI“I˜I®I³I¸IÆIÜIòIJ&J6J;JYJoJ…JŠJ�J¥JªJ¯J½JÓJéJùJ'K/K4KRKhK~KƒKˆKžK£K¨K¾KÔKÙKÞKôKùKþKLLL0L5LGL]LsL|L‹L�L•L£LµLºLÈLÚLßLäLMMM$M>MFMKMfMkMvM‹M£M¯MÈMâMíMNN&N?NDNIN[NvNŠNœN©N½NÄNÒNÙN÷NüNO®T'H ½ UZCZGZLZQZaZsZ‰Z’Z¡Z°ZÄZÌZÑZàZíZ[ [7[I[m[v[[Ž[–[ª[²[·[¼[Î[ï[\\=\O\_\o\t\y\‹\�\®\Ä\Í\Ý\å\ô\ù\ ] ] ]5]K]T]Y]]]q]y]†]§]¹]¾]Ð]Õ]ç]ý]^^^^#^(^:^[^q^~^©^»^Ë^Û^à^å^ô^_4_h_l_w_€_†_‹_�_´_Ê_à_ì_``(`-`?`J`R`d`o`w`…`�`˜`œ`¥`«`°`µ`º`Ñ`Ö`è`õ`ÿ`a aa auRuVueusu‚u¤u³u½uÅuÏuÛuàuðuvvvv(v?vNvbvkvwv|v„vˆvœv v¨v·vÅvÔvövwww#w-w2wBwRwbwjwowtw‚w™w¨w¼wÁwÍwÒwÚwÞwâwæwúwÿw xxxx x(x,x@xBxNxSx[x_xcxkxsx‡x�xžx¬x»xÝxìxøxyy yy-y1yIyQyVy[yeyjytyyy~y‰y˜y¦y¸y½yÈyâyìyñyûyz +zzz+zLzbzvzzz z«z­z½zÛzìzýz{ {{{){1{H{U{\{a{j{q{x€)¸µx€�€¤€«€¹€΀߀õ€��=�H�`�x��’�£�³�¼�Ë�Ü�ì�‚‚!‚+‚9‚A‚T‚j‚w‚�‚”‚ª‚±‚Á‚Ñ‚Û‚Þ‚î‚ø‚û‚ƒƒƒ.ƒ1ƒ6ƒFƒIƒMƒUƒ]ƒvƒ{ƒƒƒ“ƒ£ƒºƒʃ؃âƒðƒüƒ„)„3„D„[„q„x„ˆ„˜„¢„¥„µ„ÄÆ„ß„ä„é„…… …)…,…0…8…@…Y…^…f…v…†…�…­…»…É…×…ã…ú…††+†B†X†k†p†€†�†¢†¥†µ†džʆã†è†í† ‡ ‡‡-‡0‡4‡<‡D‡]‡b‡j‡z‡Ї•‡œ‡¬‡³‡ʇÙ‡à‡å‡ˆ*�™PŽpŽxŽ�Ž�Ž¥ŽªŽ»ŽÉŽÔŽ׎àŽçŽ÷Ž� ��*�5�<�R�t�|�Œ�œ�¡�®�Å�Ü�ë�ÿ���� �7�N�]�e�s����� �®�º�Æ�à�ü�‘ ‘%‘@‘H‘P‘X‘‹‘“‘�‘ª‘¾‘‘Ö‘Ú‘ò‘’’$’(’<’@’K’n’t’�’¡’¨’­’¿’È’Ð’á’é’û’“9“¤“+h-—°‰щ؉ã‰ç‰ó‰ø‰ŠŠ;ŠFŠPŠUŠYŠ_ŠgŠoŠwŠ˜Š¢ŠÊØŠêŠòŠôŠ‹(‹0‹=‹L‹W‹f‹t‹‚‹ˆ‹–‹ž‹¨‹°‹º‹Ñ‹Ü‹ó‹ö‹ÿ‹ŒŒ/ŒEŒ\Œ_ŒhŒ|Œ„Œ˜Œ®ŒÅŒÈŒÑŒåŒíŒ��.�=�@�I�]�i�€�Ÿ�¤�»�Ú�ú� Ž Ž&Ž1ŽIŽ,X%ª¨“ēǓדß“ñ“ú“1”r”€”’”›”¦”´”ɔԔߔ÷”•••-•2•@•H•n•†•™•£•«•±•¿•̕ԕü• +––––'–O–]–a–e–m–z–†–�–¸–¼–À–È–ð–þ–——— —)—Q—U—Y—a—‰———›—Ÿ—¤—±—¹—á—ï—ó—÷—˜,˜:˜>˜B˜N˜[˜g˜�˜�˜¡˜¥˜²˜Ú˜è˜ì˜ð˜ü˜ ™™=™K™O™S™d™Œ™š™ž™¢™§™´™À™è™ö™ú™þ™š7šEšIšMšTšYšfšrššš¨š¬š°šÁšéš÷šûšÿš ››@›N›R›V›g›�›�›¡›¥›À›Ñ›à›ì›œ7œLœ^œ}œ¥œ­œ²œ¶œ¿œÑœÝœ� �� �0�X�]�k�|�¤�©�¼�Á�Î�Ó�æ�ö�žžDžIžVž[žežxž�ž’žœž¯žÄžÉžÓžæžûžŸ +ŸŸ2Ÿ7ŸhŸmŸ}Ÿ‚ŸÑŸÖŸ% * 4 A V [ e r ‡ Œ – £ ¸ ½ ¡¡N¡S¡™¡ž¡¬¡ò¡¢ ¢¢`¢u¢z¢�¢’¢¥¢ª¢¸¢Ë¢à¢å¢ó¢££ £.£A£V£[£i£|£‘£–£££¨£µ£º£Ç£Ì£Ù£Þ£ë£ð£F¤K¤¡¤¦¤´¤Á¤Ö¤Û¤é¤ù¤¥¥!¥1¥F¥K¥¡¥¦¥ü¥¦W¦\¦j¦·¦̦Ѧߦ/§D§I§�§•§ܧ᧨¨Y¨^¨t¨“¨£¨º¨˨بݨî¨û¨©3©?©x©¦©«©»©Ò©ã©ð©õ©ªªª)ª:ªGªOªTªeªsª|ª‡ª©ªÁªÖªêªòª÷ª««(«-«>«R«a«o«€«‘«¢«Ϋí«¬¬ ¬'¬,¬=¬B¬S¬X¬i¬n¬¬„¬›¬¬¬½¬Ô¬Ù¬ð¬­­)­.­?­U­Z­k­|­�­¤­©­È­Ù­Þ­ý­®*®/®N®S®{®€®…®­®²®ήÓ®ï®ô®¯¯1¯6¯R¯W¯s¯x¯”¯™¯Á¯دé¯ú¯ÿ¯'°>°O°`°e°r°w°Ÿ°°°Á°Ò°×°å° ±5±:±b±б›±¬±½±αß±ä±ò±²B²G²o²—²¨²¹²ʲÛ²ì²ñ²³*³;³L³]³b³y³‡³¯³׳ÿ³´)´Q´y´¡´¦´δö´µ/µNµmµ~µ�µ”µ«µ¹µáµ ¶1¶M¶[¶ƒ¶«¶Ó¶ض·(·P·a·€·Ÿ·°·Á·Æ·î·ÿ·¸!¸2¸C¸T¸e¸j¸�¸ ¸¼¸Á¸é¸ú¸ ¹¹5¹F¹b¹g¹�¹ ¹±¹¶¹Û¹ì¹º º5ºFºWº\º�º©ºźʺغ»(»-»U»}»Ž»“»¸»à»ü»¼¼7¼_¼d¼Œ¼´¼żʼï¼½3½8½F½n½–½›½ýë½ü½¾¾7¾_¾d¾Œ¾´¾žÖ¾í¾ñ¾þ¾¿ ¿O¿\¿ˆ¿§¿¼¿οÝ¿å¿ê¿À ÀÀ%À-À2À[ÀcÀhÀ‘À™ÀžÀ¬ÀÀÀîÀöÀûÀ ÁÁKÁSÁXÁfÁzÁ¨Á°ÁµÁÃÁ×Á ÂÂ8Â@ÂEÂkÂsÂxž¦«ÂÑÂÙÂÞÂà ÃÃ7Ã?ÃDÃjÃrÃwÃ�åêÃÐÃØÃÝÃÄ ÄÄ6Ä;ÄaÄiÄnĔĜġÄÇÄÏÄÔÄëÄóÄøÄÅÅÅ)ÅTÅdÅ{ŌřŞůżÅÒÅãÅèÅùÅþÅ Æ$Æ5Æ;ÆDÆRÆ\ÆoÆvƄƌÆ�ƸƽÆÎÆ߯ìÆôÆùÆþÆÇÇÇ%Ç3ÇDÇRÇZÇ_ÇdÇuDŽljǎÇ�ǢǧǶÇÃÇëÇðÇÿÇÈ ÈÈ(È4ÈEÈVÈgÈxȉȎȶÈÄÈìÈýÈ%É3É[ÉiÉtÉxɂɆɖÉ�ɳɷÉÇÉÎÉ×ÉäÉÊ Ê'ÊNÊ[Ê}ʎʬÊÁÊÐÊìÊõÊËËMËdËrË•Ë�ˤ˩˷ËÀËÐËÔËÝËûËÿËÌ5Ì9ÌBÌNÌ`Ìẉ̸̄ÌÊÌöÌÍ6Í>ÍIÍLÍQÍ\ÍgÍ‚Í�ͨÍÃÍÚÍÎ*ÎôÒ-h àTëTðTúTþTU UUUU.`luÀÿÙÿàÿëÿðÿ")4Mep‹§µÀáù&5X]enŒ”œ¤¬´¼Éäêòú )49MOT[o„‹Ÿ¤½ÎÙàî $49IN^csx“˜ÀÉÒî 38`i‹“¢¿Ùõ#27<DSX`ejuz…Š•š®ÏÚåèý,/6JOZt‡¦®Èä->Rb„�±¶Ðâôÿ).9S^i~‰£¼ÕÚå    # + 3 @ H P [ m ” ® ¸ Ø ã ë ö  + + +& +. +9 +D +O +T +h +„ +ž +· +¼ +Ç +Ï +Ú +é /ø IÐIñIøIÿIJ J%J)J2J:JBJJJcJoJ|J‡JŒJ‘J¹JÇJÉJÖJãJçJìJöJK/K=K?KLKVKcKmKtKyK�K‰K‘KªK¬KÈKäKðKõKýK +LLLDLGLrL0hâ Ønñnôn ooo,oJodooozoo‰o’o˜o›o¥o·o¿oàoúoppp#p:p?p`p‚pŒp£p¼pÙpûpq8q1È8N˜d·dÈdÙdïdee-e>eUe`ese‘e˜e¯eÅeÛeìefftf2X68qQqXq_qgqnq~qœq§q²q×qòqýqrr-r:rMrXr_rjrƒr“r r§r®r¶rÁrÈrârírþr +s%sCs]shsšs3HPvxf—fžfµfÀfØféfÿfg0gAgWg^gug€g‹g�g¯gÇgÎgægýghh"h)h@hKhchrhˆhžhóh4À’Ç O9O@OHOPOpOwO‚OŽO O·OÂO×OðO PP.PEPJPSP[PcPƒP‹P˜P§P¯PÍPÕPèPQQ&Q.Q:QEQPQTQ]QyQ¿QðQóQøQ;R50L�xL™L L¥LÐLÜLÞLëLøLüLM MMGMUMWMdMnM{M…MŒM•M�M¤M«M²MºM¿MÇMÌMÚMêMöMNNN7NSNoNzNN‡N‘N™N N­NÃNÌNÔNÝNõNOO O O O6øGHXdXkXyX„XŒX”X˜XŸXªX¯X±X¸XÏXñXYYY*Y5YZYbYgYxYƒY¨Y°YµY½YÅYÚYàYZZZ Z%Z+ZKZSZ_ZdZjZ‡ZŒZœZ¡Z¸Z½ZÝZåZëZ [-[2[L[Q[Y[_[g[r[ƒ[ˆ[�[›[£[¯[É[Ô[Ö[õ[\ \\+\9\@\W\b\g\r\ˆ\’\°\¸\½\Ä\Ð\å\ê\]]$]+]5]U]z]‚]�]Ÿ]½]Å]Ê]Ñ]Ý]â]ë]ö]^A^I^P^p^x^‡^™^°^µ^Ý^å^ì^_&_._=_E_O_W_]_c_k_s_w_~_…_’_ž_£_©_®_·_Ò_õ_` ``#`,`4`N`z`„`�`š`±`¼`Á`Æ`La7è Paqaxa�aša­aËaÒaéaôabb5bCbMbXbibb•b¯bÅbÝb c8�Ñàn)n0n?nVn[nfnmnxnzn�n˜nšnÔn9¸ x¬ wÁwÈwÖwÝwàwçwîwõwüw xxx"x)xExLxSx^xjxvxx†x‘x–x¡x´xÁxÉxëxöx yyy y/y2y7yByQyTyYydysyvy{y†y•y˜y�y¨y¶y»yÂyÙyèyÿyz z'z8zOz^zuz~z•zšz±zÌzÏzÕzÚzåzìz{ {{${;{J{a{j{�{†{�{´{Ð{Ó{Ù{Þ{é{ð{|| |7|F|]|f|}|‚|™|´|·|½|Â|Í|Ô|ë|ò|÷|}#}.}F}`}k}ƒ}ˆ}š}±}¿}Ä}Þ}á}ç}ì}÷}~~"~9~L~c~p~‡~�~ ~¦~«~¶~Á~Ä~Ë~Ð~Û~ê~í~ò~ý~ +!9>IVm…Š¡¬·Îìõ €1€S€j€s€|€Ž€½€Ï€å€õ€��9�^�v�‚�š�£�¾�Ú�ß�ê�õ� ‚(‚:‚I‚Q‚i‚t‚y‚„‚�‚”‚Ÿ‚­‚²‚½‚Ë‚ЂÛ‚ó‚ø‚ƒƒ ƒ+ƒ2ƒ8ƒ;ƒ@ƒGƒYƒbƒxƒƒ‚ƒ�ƒ’ƒ¬ƒ²ƒµƒÁƒƃÖƒ݃âƒþƒ„ „'„?„T„_„{„~„Š„˜„¯„̈́Ԅۄï„ú„…!…)…=… ‰:˜Ïøhii'i.iFiMidioi�i’i¤i·iÕi÷ij$jFjQjijj†j�j®jÅjÐjèjöjk k)k;kSk^klkskŠk•k�k§k«k²k¶kÁkÒkÝkókúkl!l+lAlYl`lwl‚l�lŸl¶lÛlélm mmm m'm@mZm^m`momzmn;è9s s»sÉs÷s%t-t?tQtctzt‘t«tÂtÜtêtöt u(uAuWumu„u‰u©uËuãuúuvv+vFv_vuvŒv¤vµvÌv×vïvôvw9wOwgw™w<ˆÿ>!>1>?>J>X>l>z>…>Š>•>ª>¿>Ê>è>ì>ò>?)?1?8?0$La£úüS[o† ¸ÌÕí03hmp‰•¡­¶Õïò)?X °T»TÀTÉTÏTÖTØTÝT@èZ´� ™   ¨ µ Ì ë  +' +I +y +Ÿ +Ì +á +ú + % ? U r  ¦ º Î Ø ÷    + 7 C P [ ` q „ — ­ À Ç È Ú ø   ) A I N W   ­ ½ Ñ ä ï ô %BT\n{ƒ•ÆÒÞéî.JNŽA¸0¸;Ñ;Ù;î;ù; <"<5<W<n<…<¤<¨<³<Ï<ò<õ<=Bз�¨ÀÃåý#LU{¢«¯·ÄÇÒÔáêîøü $(9=Ydfjsz‡‹•™¢»Û÷ %).7U`}ŸºÀÇÔØàý"Hp}£½Øò*Fb¤¨ïC 5V€�¦­µÁÍß /Ce|“»ÄÈØáþ  9 W s v ‰ DˆBPðùBivƒ•¢¸¾ÃÊE¨jèûüü ü"ü)ü1ü8üCücünüsüvü}üˆü�ü•ü ü¥ü°üÁü×üâüçüòüýüýýý'ý.ý9ý;ýWýdýý±ý¶ýÊýÏýÖýçýûýþþþ"þ3þ:þNþ[þiþsþ‡þÀþõþÿ ÿÿÿ"ÿ8ÿ¾ÿF˜îþ0ZCZJZSZVZaZjZuZ£ZÁZÝZùZ[[[G0;>h#s#�#’#H8‰­(c?cIcVcgcpcwc‚cžc«cÇcãcìcïc d'd2d@d\dgdjdƒdŸd¹d½dÂdÊdõdIÀÅÚ (³(·(À(Ã(ß(û()0)9)Q)m)‡)Š)�)–)ž)¦)¬)²)¿)JpAL˜#©#¬#Â#Í#Ï#ë#ø#û#$KX+3'LWq~Lp)x‹˜Ÿ«Êí M˜@ð  /GW_uƒ•©åéø  8Shv’¡ÛS[k{Žª¯²ðNp�Œ(=`†–°ÊÍïOèeÀÉÐÙä8_l}�£¹Ïâéñò &P`;DH=[=l=q=‹=–=›=«=Q°¹LPücü…ü§üÉüëüý5ýVýfý�ý�ý¨ý³ýÀýËýØýãýîýùýþþ>þIþTþ]þpþ�þ²þ½þÈþÑþäþÿ&ÿHÿSÿ^ÿgÿzÿšÿ¡ÿªÿ½ÿÕÿöÿýÿ !'-39BKQry…‹‘—�¦¯Ð×Ýãé +%/9Cdku|ƒ�—¡«µ¿ÉÓÚáëõü +",6@JT^hr|†�šÀRp¸Ã@(W([(`(€(†(‹(Ž(�(’(Ÿ(S *KØfífðfýfg$g+g2g;gDgUgZgcgggrgxg‚g‹g�g“g–g™g›g g£g¥g¬g¯gÂgTØ AÐíõù 1GKU]s�‹¡³¸ÅÊÔêü$.9LQY^fp¹ÇÑÜïôü !UˆCQ(ADGQY`jrux��V0Ux�©­¶¼ÀÄÓÝçý!&0<AIP\oy…Š’™›ªWP29==*=2=9=;=B=XXhð²5²<²G²L²j²€²�²�² ²£²¥²¯²¶²¹²Â²Ê²Þ²ý²³ +³³.³B³O³b³j³Œ³‘³�³¢³±³¹³Í³ì³ö³ù³ÿ³´1´>´b´w´ž´¨´Ë´Ñ´ï´µ!µ&µ,µJµ^µhµmµsµ‘µ¥µÆµËµ×µõµ¶5¶:¶F¶d¶t¶¤¶©¶¯¶Í¶Ý¶ä¶ñ¶·!·&·0·N·^·e·r·†·°·¼·Ð·Õ·Ú·ä·¸¸¸&¸:¸]¸b¸l¸Š¸ž¸³¸¸¸Â¸à¸ð¸þ¸¹$¹»YØc{hŠyŠ‚Š–ŠŸŠÁŠáŠöŠ‹‹0‹9‹[‹{‹�‹¥‹§‹¿‹׋Þ‹ZxÖ‚�ª½ªȪЪÙªëªúª«« «$«-«3«;«E«J«`«v«{«Œ«Å«Ê«Û«¬¬¬W¬d¬i¬†¬¿¬̬Ѭý¬­*­/­W­b­o­­Œ­™­¹­Á­Æ­ë­ü­® ®"®&®/®I®_®d®m®~®†®¥®¼®â®ô®¯¯(¯E¯J¯\¯y¯„¯‘¯¥¯²¯Ưæ¯î¯ó¯°°*°A°g°y°–°›°­°ʰϰá°þ° ±±.±;±O±o±w±„±‰±¦±¸±ϱõ±²$²)²;²X²g²t²ˆ²•²©²»²Ͳí²³³,³>³K³]³b³g³�³�³¢³гH´[P¬Ó¨A¨G¨Y¨k¨t¨–¨œ¨Ÿ¨£¨¨¨Ш䨩 ©%©T©a©f©p©Œ©’©´©¹©Û©÷©ªª ª"ª&ªUªwªŠª\x‰€Å©Å·ÅÆÅëÅóÅÆÆ Æ=ÆLÆ[ÆnÆ|ÆÆ�ƇƶÆáÆóÆÇ Ç.Ç>ÇMÇZÇzǂǰǷÇÅÇÓÇæÇéÇ +È*È,È2ÈaȃȈȪÈÁÈÄÈåÈÉÉ É<ÉBÉPÉ`ɈɶɻÉÂÉãÉòÉýÉ ÊÊAÊgÊvÊ{ʙʻʾÊÈÊâÊñÊËË,Ë.ËHËWËxË˒ˠ˽ËãËòË÷ËÌ7Ì:ÌHÌbÌq̵̡̰̄ÌÏÌÞÌÿÌÍÍ"Í@ÍbÍg͉ͧÍÉÍÏÍÝÍÎ&Î.ÎOÎbÎ]ƒ¢PÕiÕnÕ|Õ�Õ¢Õ¿ÕÉÕñÕ÷ÕþÕ&Ö+ÖSÖfÖyÖ–Ö ÖÈÖÎÖÕÖãÖðÖ×× ×1×Y×h×^7v¨üÅüÌüßüæüíüõü÷üþüý ý;ýbýkýƒý‘ý¬ý±ý¿ýÌýÑýÛýþ)þ+þRþyþŠþšþžþ¯þµþ¿þÊþÔþØþêþñþúþÿ*ÿ2ÿDÿNÿRÿqÿvÿ~ÿ�ÿšÿžÿ°ÿ½ÿÐÿ_x–Ðÿáÿïÿ3@S—œÍÒé*[`ˆ¸Áòù`ŽËÈåååìåõåææFæPæUæjæ’æ˜æ«æÛæåæêæïæçç"ç5çeçoçtçvçžç¤ç»çëçõçúçè:è@èJèXè^èaèeèkèoèsè}è‡è˜è¥è¼è×èæèéé.éAéaÈp Æ X u ~ … “ ¦ Ö à å ú $*=mw|�«±¶Éù +4:Q�‹�¨ÒØÞáåëïóý%<Wf“›Ÿ°¶ÄÎ×Ûíô#19GPTsx€Ž—›­ÍbðŒˆÞ¥Þ¯ÞãÞòÞ ß.ß3ß;ßIßOßRßaßhßqßzߙ߱ß×ßæßèßàà,à9àKàPà[àiàoàtà‡à·àÁàÆàÈàðàöàá +á á áFáSáXá~á‹á–á«áÅáÍáåáöáâ#â1â<âJâPâUâlâœâ¦â«â°âØâÞâõâ)ã3ã8ã=ãeãkãpã‡ã¿ãÉãÎãÓãûãäää$ä)ä@äxä‚ä‡äŒä´äºäÈäÎäÑä×äÛäêäå:å\ådå|å�åµåÈåc`# èíî îî"î-î0î4î<î@îgîrîzî‚îœî¤î¨îÛîêîïïï#ï-ï0ï4ïCïKïUï^ïyï‘ï³ïÂïÄïæïõïðð#ð(ð3ðAðGðLðbð‘ð–ð›ðÂðÈðÑðÜðéðñðñññ1ñ>ñCñMñPñwñ„ñ‰ñ“ñ–ñ­ñÔñáñæñ òò)ò6òKòeòyò†ò¤òÇòÌòÓòéòÿòó$ó3óEó[ó€ó’ó¬ó·óÆóÚóéóýóô%ô,ôGô]ôsô‰ô®ôÀôÚôéôøô õõ/õOõWõfõ€õ”õ·õ¾õÌõÚõéõ÷õúõÿõöHöMöRöyö|ö’öÉöÒö×öþö÷ ÷!÷X÷a÷f÷�÷•÷¤÷²÷¸÷½÷Ó÷ø øø7ø=øHøKøUøZø”ø£ø¼øÐøðøùù ù*ùBùXùoù~ùƒù�ù«ù²ù¿ùáùïù÷ùú+ú:ú?úIúiúnúvú“úªú¹ú¾úÈúÚúéúüúd(í¸ÛÑÛÖÛíÛûÛ#Ü)ÜQÜyܕܣÜËÜóÜÝÝ6Ý^ÝdÝnÝsÝ›ÝÃÝÖÝéÝÞÞÞ+Þ<ÞMÞuÞ„Þe�¼Ë8�Q�f�Ž�Ÿ�¨�Ê�ê� �0�?�N�f˜™©0§G§W§a§f§y§¬§®§Ö§¨¨g ,=8¿I¿S¿{¿£¿¥¿Í¿õ¿ÀÀ$À&À7ÀHÀpÀwÀh¸?sxÀ�À�À§ÀâÀ +Á Á4ÁoÁÁ�ÁžÁ Á±ÁÂÁÇÁÂÂBÂGÂQÂy¡²´ÂÜÂÃ+Ã;ÃIÃZÃ\ÃmÃ~ÃêÃÓÃàÃåà Ä7Ä@ÄiàµÎˆŸ©´ÂÄìALZ\„��ªÒÛjü< è  !/1Y�†®¹ÇÉñü +  ' / 3 D J T ^ g r v | Ž ” � ¿ È Ð á ê õ ù ÿ  + +$ +5 +> +I +M +S +d +q +„ +kX˜ ?Lt}l ¢³€—¡ÉñóCPx�mhÐúà÷Jrtœ×ä ,puƒ«Óúÿ'Ovƒª³ÛänèT n È ß í ! * I V ~ ƒ « Ê Ó ò ÿ  ' O X o¸> R ˆ +Ÿ +© +Ý +ê +  ? ^ k Š “ » Ä p°„—ð¥¦/¦F¦K¦s¦~¦‹¦›¦¨¦¸¦צߦá¦ÿ¦§0§q u†@ÄQÄ[ăīĭÄÕÄýÄ ÅÅ,Å.Å?ÅPÅxÅÅrèÏ P�q�y�‡�‹�‘�—�œ� �®�¼�À�Ï�Ý�ç�ë�ð�ú�ü�‘‘(‘,‘;‘I‘]‘a‘x‘}‘�‘”‘¨‘¿‘Ñőߑã‘î‘ü‘’’ +’’s°¯‚šEšNšsš…šŠš—š²š¿šÅšöš'›C›I›M›y›ª›¯›Û› œ.œ4œ8œWœdœ‰œŽœ­œºœßœúœ� �1�>�C�b�o�q�y�ƒ�†�Š�¢�¯�Â�Ù�Þ�ã�ñ�ÿ�ž!ž&ž8žUžZžlžuž–ž¶žïžHŸMŸbŸtŸyŸ†Ÿ�Ÿ�Ÿ�Ÿ¤ŸºŸÄŸÖŸüŸ  ; @ Z _ | � ž £ À Ë Ø è õ ¡%¡-¡;¡A¡a¡~¡†¡ˆ¡¥¡°¡½¡Í¡Ú¡î¡¢¢¢7¢b¢|¢�¢“¢¢Ú¢££/£4£F£c£h£z£—£¢£±£Á£Уä£ü£"¤)¤.¤3¤5¤:¤I¤Q¤w¤„¤‰¤–¤›¤¨¤­¤¿¤ߤ䤥"¥*¥ð¥tЯæȶå¶è¶û¶· ····!·%·9·l·w·§·¬·Õ·Û·ã·í·ü·E¸J¸ƒ¸�¸•¸¥¸®¸¹¸Ǹî¸ö¸¹"¹I¹[¹m¹”¹œ¹§¹®¹±¹¶¹ιõ¹ºu è)º#º*º>ºrº€º‹º�ºͺÓºܺçºöº>»@»u»‚»¼»Á»é»¼¼%¼@¼B¼S¼`¼‡¼Œ¼œ¼¥¼°¼¾¼̼½/½4½\½—½¤½ß½ä½ò½¾B¾G¾o¾—¾¾¾˾ò¾û¾"¿3¿v`x�¨Ô¹ÔáÔïÔýÔÕ ÕGÕNÕwX¤¬¸™Ï™Ø™Þ™â™æ™ +ššx(¤Æh×�׆הק׺×××á× ØØØ>ØCØkØ~ؑخظØàØæØíØóØöØúØÙ&Ù7ÙHÙpÙÙy�}Œè— ˜)˜/˜O˜l˜n˜p˜�˜�˜ȘzpŽ™ȘÙ˜ä˜ñ˜÷˜™4™9™D™{à `ì}ì‹ì”ìØì íí$íFíKíMíuí{í„í³íÒíáí|Èíøêë#ëWëdë¨ë­ëÀëÅëÇëïëõëììLì[ì}ÎëHé_éfé}é‹éœé¦é´é½éÎéáéòé÷é ê)ê7êEêVêdêuê†ê—ê¨ê¹êÊêÔêåêòê~P'n¸“á“í“” ”;”L”Q”W”w”—”œ”«”Æ”à”ñ”þ”• •0•5•;•a•g•j•n•s•—•«•ϕܕᕖ––3–D–I–l–}–œ–¤–©–Å–Ö–Ø–ô–—h—pp{h—y—‚—�—•—µ—Ò—×—â—€xUa¸‰ɉÒ‰æ‰ï‰Š1ŠFŠ`ŠgŠ�°+hΑΫγÎÁÎÝÎùÎÏ ÏÏ3ÏSÏUÏuϑϭÏÏÏÞÏ‚.màÏ Ð#Ð+Ð9ÐGÐUÐYÐvЖИЛÐÌÐÞÐþÐÑÑ1Ñ?ÑCÑ`ртхѶѼÑÊÑÚÑèÑ ÒÒAÒqÒvÒ„Ò¤Ò¶ÒÖÒÛÒéÒ Ó)ÓKÓNÓ\ÓjÓŽÓ�ÓÃÓäÓìÓ Ô Ôƒè % ’G’a’„’–’·’¹’Ë’ì’î’“!“,“9“F“S“`““‡“¸“„X…­H´q´v´ˆ´š´¼´´Å´É´δú´µ:µGµLµxµ…µе”µ¶µÖµòµõµúµ¶2¶5¶W¶]¶`¶d¶�¶²¶Ŷ…P5ûû û3û]ûkûû‡û‹û—ûœû¦û°û¹û½ûÏûÕûÞûüü üü'ü+üJüLüTüeünürü„ü‘ü¤ü†hIS‰!‰5‰>‰`‰€‰•‰¯‰¶‰‡€}Šà‹ë‹Œ Œ.ŒNŒgŒ€Œ‚ŒžŒºŒ¿Œˆ�Œ›ÀŒËŒãŒìŒ�.�G�`�y�{�—�³�Ï�Ô�‰ˆ�«Ø�ï�Ž Ž.ŽNŽZŽ\ŽnŽqŽvŽƒŽŠ€­ºˆŽŸŽ³Ž¼ŽÞŽþŽ +��!�&�3�‹Pov Ô7Ô_ÔwÔŸÔ¨ÔŒ0Èë€Ù™ÙžÙ¬Ù¿ÙÒÙïÙÚÚ$ÚLÚQÚyڌڟڼÚäÚêÚñÚÿÚ ÛÛ.Û<ÛJÛ[ÛlÛ}Û¥Û´Û�P›¢H™Y™_™c™ˆ™¯™¶™ŽxNZÀËÒÜáÿ 0OTg�àW ,¼,Î,Ü,ï,ú, ----7-<-O-Q-e-x-z-�-‘-¢-µ-·-Ã-ã-ð-.7.<.C.H.W.‡.Œ.“.¯.Ô.Ü.ä.é.ÿ.//&/4/Y/j/p/Š/¦/«/³/È/Ð/Õ/Ú/ê/ø/0 00 00020:0O0W0\0^0l0y0“0˜0·0¿0Ô0Ü0á0ï0ô0ú01 11!121J1M1R1Ý1ò1ú1222*2/2=2E2K2S2a2d2r2ƒ2—2œ2î2ö2 333&3+3:3B3E3M3p3•3ž3¹3Ó3×3û344$4/4=4Y4y4”4®4¶4¾4Æ4Ë4Õ4ã4ö4555!50585G5O5^5f5u5}5Œ5”5£5«5º5Â5Ð5õ566*6F6M6R6g6€6‰6—6«6Å6Ñ6æ6ë6777%7-777L7U7c7m7‚7Š7’7—7¡7¶7»7Î7Ó7à7å7 8 8%848Y8z8Ÿ8É8ã8ð8!9;9@9E9Z9x9€9ˆ9�9–9£9«9¹9Ü9ú9 ::,:::D:R:\:j:€:…:Œ:Ÿ:´:Þ:ñ:û:;;;?;Z;_;d;p;x;};ƒ;š;¤;¸;½;Ì;í;ð;<<<<<<#</<7<<<A<U<Z<_<s<x<‚<„<’<—<¥<ª<¸<½<Ë<Ð<Õ<Ú<ß<û< =%=0=G=Q=e=j=y=š=�=­=°=Ê=Ï=Ô=Ü=á=ê=ï=û=>> >!>&>+>0>;>@>P>U>[>r>|>�>•>¤>Å>È>Ø>Û>õ>ú>ÿ>? ???&?.?3?8?L?Q?V?[?f?k?{?€?†?�?§?»?À?Ï?ð?ó?@@ @%@*@2@7@@@E@Q@Y@^@c@w@|@�@§@¬@À@Å@â@ç@ü@AA%A-A2AGALAjA‡AŽA›A¹AËAØAåAéAîAøABB"B'BÖFÖQÖ\ÖdÖfÖzÖÖ�Ö’Ö�Ö¤Ö©Ö®Ö¿ÖÊÖÕÖÚÖêÖñÖüÖ× ×/×J×eׄ׋×�×±×¼×Á×Ò×Ý×â×ó×þר Ø3Ø8Ø@ØKØVØZØbØfØrØ}؂ؓ؞أتصغØÎØÓØäØïØúØüØÙWÙ®0Æé8ÒUÒ_ÒsÒzÒ�Ò‰Ò‘Ò•Ò Ò«Ò³ÒÉÒÔÒÙÒäÒÓ ÓÓ$Ó,Ó.Ó9ÓDÓOÓZÓgÓrÓ}Ó‚Ó¦Ó¯@õˆ:£:®:´:Â:Í:×:Þ:æ:ñ:õ:ÿ: +;;;(;0;6;C;K;Q;^;f;l;t;};ƒ;¢;§;¸;°8¿ÃPLgLvL”L»L±0 ¬ð ù   ; C N ^ n • ¬ Í Ô Û þ '8Tfo~ ¥µÆÎÓÚìø "+0KRWhyˆ¢¸Üçîû  '.3@Vhwƒ”­¶Æ×Ûìý$6HO`gu�³Îàí(L^u‹¡¸ÜþAFWhz‰š«²¹»É×åó"<`{ˆš±Õù ").D[u„“š­®Êæÿ/²'D8WUW]WaWdWmWsW„WŽW™W¤W¾WËWêWõWX XX#X.XAX³Ø;ó˜0±0¼0Æ0Í0Ô0ß0ç01111'131>1P1W1[1f1j1s1Š1›1²1Ê1á1ì12"2*2>2P2U2]2m2…2 2¨2À2Ê2Ø2é233(3/3=3T3e3k3o3v3z3�3˜3£3­3¸3Ã3Ê3Ù3á3ó3ù34444(4,454I4w4Ž4¥4Ã4Ê4á4ì4ó45 +5 5/5E5T5\5f5‹5¢5À5Ë5â5í5ô56 6!606F6U6]6g6�6ˆ6�6Ÿ6Á6Ç6é6 7!777G7W7Z7e7p7{7†7•7œ7§7¹7Ð7î7888 878B8M8[8f8q8|8‡8”8Ÿ8®8È8Ð8Ò8î89$9D9N9Y9d9l9v9�9Œ9”9ž9£9…:´h ¯90LWy€£ÈÓÝå  4?fhz£²½ÅÏÓÛãîù "4]lw‰¬·ÁÌßý&FPjxƒ�°½ÏÚìø6X]iŒŽ±»ÊÛâéôû  '.9AH^iŒ–­ÀÈÐÙáò$(>Wmx‰œ§¾Üäìô ,4OQYw…’Ÿ©ºÙäòý +Ach‰¬Ôßé÷þ   * - 6 : = D K M X _ u | ‡ ¥ ¼ Î Û ð  % C H O Z q † ‘   ´ Å Í á ò !!*!E!W!c!z!…!ˆ!�!£!µ!Í!Ø!ï!ú!""")"<"S"e"|"š"¡"¸"Ã"Æ"Ñ"â"ð"û"##+#9#D#O#Z#h#~#‹#™#¨#º#Ô#ß#á#ó# $#$3$C$\${$›$¾$Ã$Ü$ÿ$%6%@%N%R%a%i%�%“%—%Ÿ%¯%·%Ç%Û%ø%&&'&I&_&‚&‡&›&¸&Î&ñ&ü&''+'6'b'w'Ž'¡'¥'­'¼'Í'Ò'Ù'ï'((#(6(>(a(l(ƒ(Ž(˜(£(Ï(ä(û())))4)K)])a)v)�)¢)¹)Ô)ë)*%*<*G*Q*h*‘0µðÊ%@RaRlRoRxR~RŽR•R¬R¶RÁRÌRÕRçRñRüRS$S+SJSnSyS€S‹S”S¦S±S´S¹SÃSÊSáSìSñSþST/T:TDTXTsT~T„T‰T‘T™T­TËTÖTìT÷TU$ULUfUyU—U¢U°U¹UÏUåUêUôUùUV2V=VHVOVZVpVyV„VšV¼VËVãVîVñV3W¶@±¶ÐKáKñKüKLL·@¸½L!L1L‰e‰w‰z‰€‰ž‰³‰»‰Ñ‰Ô‰ð‰Š)Š,Š2ŠPŠeŠwŠzŠ�ŠŠŠ’Š¨Š«ŠÇŠîŠ‹‹ ‹+‹@‹G‹J‹y‹‹�‹²‹Õ‹Ú‹à‹þ‹(ŒKŒPŒVŒtŒ¡ŒÄŒàŒåŒëŒ �'�E�P�a�r����Ÿ�¬�¼�Ì�Ü�ì�ü�ŽŽ Ž1ŽBŽGŽWŽ}Ž£Ž¿ŽÄŽÉŽÓŽñŽ�-�9�D�O�c�f�s�‡�Š�š�®�±�Á�Õ�Ø�è�ü�ÿ��#�&�6�J�M�h�y�|�‘�§�Â�Ð�á�÷�‘'‘*‘@‘E‘J‘Z‘x‘°‘´‘×‘Ü‘ì‘ +’B’F’i’n’x’–’´’¹’Ã’á’““%“C“e“ˆ“¤“©“³“Ñ“ó“”2”7”A”_”m”””¿”ç”ì”ö”•)•4•;•F•l•�•¢•¤•²•º•Ǖҕñ•ü• ––– –3–L–e–~–Œ–œ–¯–Ü–á–ë– ——H—l—~—€—…—�—­—¾—ñ—ø—˜#˜n˜ˆ˜²˜+™l™q™…™‘™˜™šRšhšmš‚šŒšªš»šîšõš ››E›M›„›·›Í›Ô›à›é›$œNœ\œ†œµœõœ �-�W�†�Ž�•�žOž|ž‘ž¤ž°žÑžÖžëžõžŸ$ŸWŸ^ŸtŸ}Ÿ®Ÿ¶ŸO T Y n x – § Ú á ÷ ¡|¡„¡»¡î¡¢ ¢¢ ¢[¢…¢“¢½¢ì¢,£V£d£Ž£½£Å£Ì£E¤†¤³¤È¤Û¤ç¤¥ ¥¥5¥J¥t¥�¥Ï¥Ò¥Þ¥ã¥è¥ò¥¦%¦O¦k¦ª¦­¦¹¦¾¦Ã¦Í¦ë¦§*§F§R§T§Y§i§§„§”§˜§`ª½ M^Ègågh hhFhshuhzh¡hÈhñh¾hXb˜¯¶ãñù",B¿8I I+IFI]IÀ8 `IqIŸI©IËI \ No newline at end of file diff --git a/LT/Compiler/Compiler.SPZ b/LT/Compiler/Compiler.SPZ new file mode 100644 index 0000000..5ffbb49 Binary files /dev/null and b/LT/Compiler/Compiler.SPZ differ diff --git a/LT/Compiler/ExpParser.CPZ b/LT/Compiler/ExpParser.CPZ new file mode 100644 index 0000000..c11e4e3 --- /dev/null +++ b/LT/Compiler/ExpParser.CPZ @@ -0,0 +1,837 @@ +LTextern CP_PRSPUSH void PrsPush(ParseStack *ps,I8 val); +LTextern CP_PRSPOP I8 PrsPop(ParseStack *ps); + +#define PRST_UNARY_TERM 0 +#define PRST_UNARY_MODIFIERS 1 +#define PRST_DEREFERRENCE 2 +#define PRST_CHECK_BINARY_OPS 3 + +BoolU8 PrsParseExpression(LexStruct *lx,BoolU4 end_exp=FALSE) +{ + BoolU4 result=TRUE,question_clause=FALSE, + cont_unary,cont_check_binary_ops,is_lower; + I8 i,j,k; + IntermediateCode *tempi,*tempi_first=lx->cb.cb_out_ptr,*tempi2; + ClassStruct *tempc; + ParseStack *ps=MAlloc(sizeof(ParseStack)); + MemberListStruct *local_var; + ArrayDimStruct *tempad=NULL; + + ps->ptr=0; + PrsPush(ps,0); //terminate + PrsPush(ps,0); //terminate +try { + do { + lx->flags&=~(LF_PREINC+LF_PREDEC+LF_POSTINC+LF_POSTDEC+LF_FUNCTION); + do i=PrsUnaryTerm(lx,ps,&local_var,&tempad); + while (i==PRST_UNARY_TERM); + + while (i==PRST_UNARY_MODIFIERS) + i=PrsUnaryModifier(lx,ps,&local_var,&tempad); + + if (i==PRST_DEREFERRENCE) + PrsDereferrence(lx,ps); + + //Check for binary Ops + do { + i=PrsPop(ps); + tempc=PrsPop(ps); + if (i && i.u1[2]<=1) { + tempi=lx->cb.cb_last_out_ptr; + i=i.u2[0]; + tempc=tempi->ic_class; + if (Bt(deref_bitmap,i) && tempc->ptr_cnt) { + tempc-=sizeof(ClassStruct); + while (tempc->return_class) + tempc=tempc->return_class; + i=EC_DEREF+0x10000; + } else { + if (i==EC_ADDRESS) { + if (!(lx->flags & (LF_RAX|LF_ARRAY))) { + j=tempi->ic_opcode; + if (!Bt(deref_bitmap,j)) + PrsExcept(lx,"ST_INVALID_LVALUE"); + tempi->ic_opcode=EC_NOP; + tempc+=sizeof(ClassStruct); + } + } + } + CbAddIc(lx,i,0,tempc); + cont_check_binary_ops=TRUE; + } else { + PrsPush(ps,tempc); + PrsPush(ps,i); + i=lx->token; + k=binary_ops_table[i]; + if (k.u2[0]==EC_AND_AND || k.u2[0]==EC_OR_OR) + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + 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.u1[2]) { + cont_check_binary_ops=FALSE; + cont_unary=FALSE; //DONE + } else { + Lex(lx); //skip op + if (Bt(assign_bitmap,k.u2[0])) { + tempi=lx->cb.cb_last_out_ptr; + tempc=tempi->ic_class; + j=tempi->ic_opcode; + if (!Bt(deref_bitmap,j)) + PrsExcept(lx,"ST_INVALID_LVALUE"); + tempi->ic_opcode=EC_NOP; + while (tempc->return_class) + tempc=tempc->return_class; + k.u1[2]=0x10; + } + do { + i=PrsPop(ps); //pop ops of higher prec + tempc=PrsPop(ps); + is_lower=FALSE; + if (i) { + if (k.u1[2]==i.u1[2]) { + if (!Bt(assign_bitmap,k.u2[0]) || + !Bt(assign_bitmap,i.u2[0])) + is_lower=TRUE; + } else if (k.u1[2]>i.u1[2]) + is_lower=TRUE; + } + if (is_lower) { + if (i.u2[0]==EC_AND_AND || i.u2[0]==EC_OR_OR) + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + CbAddIc(lx,i,0,tempc); + tempi2=lx->cb.cb_last_out_ptr; + if (i.u1[3]&ECF_HAS_PUSH_CMP) { + tempi2->ic_flags|=ICF_POP_CMP; + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_AND_AND,0,sys_internal_types[IT_I8]); + tempi=lx->cb.cb_last_out_ptr; + tempi->ic_flags|=ICF_POP_CMP; + } + if (Bt(cmp_bitmap,k.u2[0]) && + Bt(cmp_bitmap,i.u2[0])) { + tempi2->ic_flags|=ICF_PUSH_CMP; + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_PUSH_CMP,0,tempc); + k.u1[3]|=ECF_HAS_PUSH_CMP; + } else if (k.u2[0]==EC_AND_AND || k.u2[0]==EC_OR_OR) + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + } else { + PrsPush(ps,tempc); + PrsPush(ps,i); + tempi=lx->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) { + if (i.u2[0]==EC_AND_AND || i.u2[0]==EC_OR_OR) + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + CbAddIc(lx,i,0,tempc); + if (i.u1[3]&ECF_HAS_PUSH_CMP) { + tempi=lx->cb.cb_last_out_ptr; + tempi->ic_flags|=ICF_POP_CMP; + CbAddIc(lx,EC_NOP,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_AND_AND,0,sys_internal_types[IT_I8]); + tempi=lx->cb.cb_last_out_ptr; + tempi->ic_flags|=ICF_POP_CMP; + } + } else + break; + } +} catch { + if (Fs->except_argc>0) { + if (Fs->except_argv[0]==EXCEPT_COMPILER) { + lx->statement_cnt=0; + lx->braces_cnt=0; + result=FALSE; + Fs->catch_except=TRUE; + } + } +} + Free(ps); + if (end_exp && result) + CbAddIc(lx,EC_END_EXP,0,0); + return result; +} + + +U8 PrsUnaryTerm(LexStruct *lx,ParseStack *ps,MemberListStruct **local_var,ArrayDimStruct **tempad) +{ + I8 i,*i_ptr; + I8 argc_cnt,size; + U8 d; + SysHashEntry *temph; + ClassStruct *tempc,*tempc1,*tempc2; + GlblVarStruct *tempg; + MemberListStruct *tempm; + LexUndefEntry *templu; + CbMiscStruct *tempmc; + IntermediateCode *tempi; + BoolU4 needs_right_paren,is_first_param; + LexCbStack *templ,*templ1; + + *local_var=NULL; + switch (lx->token) { + case TK_INTEGER: + if (lx->cur_i<0) + CbAddIc(lx,EC_IMM,lx->cur_i,sys_internal_types[IT_U8]); + else + CbAddIc(lx,EC_IMM,lx->cur_i,sys_internal_types[IT_I8]); + Lex(lx); + return PRST_CHECK_BINARY_OPS; + case TK_DOUBLE: + i_ptr=&lx->cur_d; + CbAddIc(lx,EC_DOUBLE,*i_ptr,sys_internal_types[IT_DOUBLE]); + Lex(lx); + return PRST_CHECK_BINARY_OPS; + case TK_STR: + d=LexExtendStr(lx,&size); + if (lx->flags & LF_ASM_EXPRESSIONS) + CbAddIc(lx,EC_IMM,d,sys_internal_types[IT_I1]+sizeof(ClassStruct)); + else { + tempmc=CbMiscNew(lx,CBMT_STR_CONST); + CbAddIc(lx,EC_STR_CONST,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct)); + tempmc->st_len=size; + tempmc->str=d; + lx->flags|=LF_HAS_MISC_DATA; + } + return PRST_CHECK_BINARY_OPS; + case TK_INSERT_BINARY: + d=lx->ident; + size=lx->ident_len; + lx->ident=NULL; + Lex(lx); + if (lx->flags & LF_ASM_EXPRESSIONS) + CbAddIc(lx,EC_IMM,d,sys_internal_types[IT_I1]+sizeof(ClassStruct)); + else { + tempmc=CbMiscNew(lx,CBMT_STR_CONST); + CbAddIc(lx,EC_STR_CONST,tempmc,sys_internal_types[IT_I1]+sizeof(ClassStruct)); + tempmc->st_len=size; + tempmc->str=d; + lx->flags|=LF_HAS_MISC_DATA; + } + return PRST_CHECK_BINARY_OPS; + case TK_INSERT_BINARY_TYPE: + case TK_INSERT_BINARY_SIZE: + CbAddIc(lx,EC_IMM,lx->cur_i,sys_internal_types[IT_U8]); + Lex(lx); + return PRST_CHECK_BINARY_OPS; + case '(': + Lex(lx); //Skip ( + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,2); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); //skip ) + lx->flags=(lx->flags & ~(LF_ARRAY+LF_FUNCTION)) | LF_RAX; + return PRST_UNARY_MODIFIERS; + } + i=unary_ops_table[lx->token]; + if (i.u1[2]) { + Lex(lx); //Skip op + if (i.u2[0]==EC_ADDRESS && lx->token==TK_IDENT) { + if (tempc=lx->hash_entry) { + if (tempc->type & HTT_FUNCTION) { + if (!Bt(&tempc->flags,Cf_INTERNAL)) { + Lex(lx); //skip fun name + if (Bt(&tempc->flags,Cf_EXTERN)) { + if (lx->a) + PrsExcept(lx,"ST_ADDRESS_EXTERN"); + else + CbAddIc(lx,EC_IMM, + &tempc->executable_address,sys_internal_types[IT_PTR]); + CbAddIc(lx,EC_DEREF,0, + sys_internal_types[IT_PTR]); + } else { + if (lx->a) + CbAddIc(lx,EC_ABSOLUTE_ADDRESS, + tempc->executable_address,sys_internal_types[IT_PTR]); + else + CbAddIc(lx,EC_IMM, + tempc->executable_address,sys_internal_types[IT_PTR]); + } + return PRST_CHECK_BINARY_OPS; + } + } + } + } + PrsPush(ps,tempc); + PrsPush(ps,i); + return PRST_UNARY_TERM; + } + if (lx->token=='+') { + Lex(lx); + return PRST_UNARY_TERM; + } + + if (lx->token!=TK_IDENT) { + if (lx->token==TK_PLUS_PLUS) { + Lex(lx); + lx->flags|=LF_PREINC; + return PRST_UNARY_TERM; + } + if (lx->token==TK_MINUS_MINUS) { + Lex(lx); + lx->flags|=LF_PREDEC; + return PRST_UNARY_TERM; + } + if (lx->token=='$$' && lx->flags & LF_ASM_EXPRESSIONS) { + Lex(lx); + CbAddIc(lx,EC_IMM,lx->instruction_pointer,sys_internal_types[IT_I8]); + return PRST_CHECK_BINARY_OPS; + } + PrsExcept(lx,"ST_MISSING_EXPRESSION"); + } + + if (tempm=lx->local_var_entry) { + lx->flags&=~(LF_RAX+LF_ARRAY+LF_FUNCTION); + tempc=tempm->member_class+sizeof(ClassStruct); + if (tempm->flags & MLF_FUNCTION) { + lx->flags|=LF_FUNCTION; + PrsPush(ps,tempm->return_class); + PrsPush(ps,tempm->parameter_cnt); + } + if (tempm->cnt) { + *tempad=tempm->dim_list; + lx->flags|=LF_ARRAY; + tempc+=sizeof(ClassStruct); + } + CbAddIc(lx,EC_RBP,0,tempc); + CbAddIc(lx,EC_IMM,tempm->offset,tempc); + CbAddIc(lx,EC_ADD,0,tempc); + Lex(lx); //skip var name + *local_var=tempm; + return PRST_UNARY_MODIFIERS; + } + + if (!(temph=lx->hash_entry)) { + if (!(lx->flags & LF_ASM_EXPRESSIONS)) + PrsExcept(lx,"ST_INVALID_LVALUE"); + temph=MAllocZ(sizeof(SysHashEntry)); + temph->str=lx->ident; + lx->ident=NULL; + temph->use_cnt=0; + SetSourceFileInfo(lx,temph); + temph->user_data0=0; + if (temph->str[0]=='@' && + temph->str[1]=='@') { + temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_LOCAL; + AddSysHashEntry(temph,lx->local_hash_table); + } else { + temph->type=HTT_SYS_SYMBOL | HTT_UNRESOLVED_GLBL; + AddSysHashEntry(temph,lx->glbl_hash_table); + } + } + + if (temph->type & HTT_SYS_SYMBOL) { + if (!(temph->type & HTT_LITERAL) && + !(temph->type & HTT_IMPORT)) + lx->absolute_address_cnt++; + if (temph->type & (HTT_UNRESOLVED_LOCAL|HTT_UNRESOLVED_GLBL)) { + templu=MAlloc(sizeof(LexUndefEntry)); + templu->hash=temph; + templu->next=lx->undef_hash_entry; + lx->undef_hash_entry=templu; + if (temph->type & HTT_UNRESOLVED_LOCAL) + lx->flags|=LF_UNRESOLVED_LOCAL; + else + lx->flags|=LF_UNRESOLVED_GLBL; + CbAddIc(lx,EC_IMM,&temph->user_data0,sys_internal_types[IT_PTR]); + CbAddIc(lx,EC_DEREF,0,sys_internal_types[IT_PTR]); + } else { + if (lx->a && !(temph->type & HTT_LITERAL)) + CbAddIc(lx,EC_ABSOLUTE_ADDRESS,temph->user_data0,sys_internal_types[IT_PTR]); + else + CbAddIc(lx,EC_IMM,temph->user_data0,sys_internal_types[IT_PTR]); + } + Lex(lx); + return PRST_CHECK_BINARY_OPS; + } + + if (temph->type & HTT_FUNCTION) { + is_first_param=TRUE; + Lex(lx); //skip fun name + CbPush(lx); + templ=lx->cb.cb_next; + lx->cb.cb_next=NULL; + tempc=temph; + i=tempc->parameter_cnt; + tempm=tempc->member_list; + argc_cnt=0; + if (lx->token!='(') + needs_right_paren=FALSE; + else { + Lex(lx); + needs_right_paren=TRUE; + } + while (i--) { + if (lx->token==',') + Lex(lx); + else if (!is_first_param && lx->token!=')') + PrsExcept(lx,"ST_EXPECTING_COMMA"); + CbInitOutPtrs(&lx->cb); + if (tempm->flags & MLF_DEFAULT_AVAILABLE && + (lx->token==')' || !needs_right_paren)) + CbAddIc(lx,EC_IMM,tempm->default_value,tempm->member_class); + else + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,3); + else { + is_first_param=FALSE; + CbPush(lx); + CbAddIc(lx,EC_NULL,0,0); + tempi=CmpOptPass1(lx,NULL,FALSE); + CbPop(lx); + 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_R_TO_DOUBLE; + else + if (tempc2->sub_type!=IT_DOUBLE && + tempc1->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_R_TO_INT; + } + CbAddIc(lx,EC_NULL,0,0); + CbPush(lx); + tempm=tempm->next; + } + if (tempm && tempm->flags & MLF_DOT_DOT_DOT) { + CbInitOutPtrs(&lx->cb); + CbAddIc(lx,EC_IMM,0,tempm->member_class); + tempi=lx->cb.cb_last_out_ptr; + CbAddIc(lx,EC_NULL,0,0); + CbPush(lx); + if (needs_right_paren) { + if (lx->token!=')') { + do { + if (lx->token==',') + Lex(lx); + else if (!is_first_param) + PrsExcept(lx,"ST_EXPECTING_COMMA"); + CbInitOutPtrs(&lx->cb); + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,4); + is_first_param=FALSE; + CbAddIc(lx,EC_NULL,0,0); + CbPush(lx); + argc_cnt++; + } while (lx->token==','); + } + } + tempi->ic_data=argc_cnt++; //++ so add_esp latter works + } + if (needs_right_paren) { + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + } + templ1=templ->cb_next; + templ->cb_next=lx->cb.cb_next; + lx->cb.cb_next=templ; + CbPop(lx); + templ=lx->cb.cb_next; + lx->cb.cb_next=templ1; + CbAddIc(lx,EC_CALL_START,tempc,0); + while (templ) { + templ1=templ->cb_next; + CbAppend(lx,templ); + if (!Bt(&tempc->flags,Cf_INTERNAL)) + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + templ=templ1; + } + if (Bt(&tempc->flags,Cf_INTERNAL)) + CbAddIc(lx,tempc->executable_address,0,tempc->return_class); + else if (Bt(&tempc->flags,Cf_EXTERN)) { + if (lx->a) { + if (tempc->type&HTT_IMPORT) + CbAddIc(lx,EC_CALL_INDIRECT2,tempc->executable_address,tempc->return_class); + else + CbAddIc(lx,EC_CALL_EXTERN,tempc,tempc->return_class); + } else + CbAddIc(lx,EC_CALL_INDIRECT2,&tempc->executable_address,tempc->return_class); + CbAddIc(lx,EC_ADD_RSP,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class); + } else { + CbAddIc(lx,EC_CALL,tempc->executable_address,tempc->return_class); + CbAddIc(lx,EC_ADD_RSP,(argc_cnt+tempc->parameter_cnt)<<3,tempc->return_class); + } + CbAddIc(lx,EC_CALL_END,tempc,tempc->return_class); + lx->flags=(lx->flags|LF_RAX) & ~(LF_ARRAY|LF_FUNCTION); + return PRST_UNARY_MODIFIERS; + } + if (temph->type & HTT_GLBL_VAR) { + tempg=temph; + tempc=tempg->var_class+sizeof(ClassStruct); + lx->flags&=~(LF_RAX|LF_ARRAY|LF_FUNCTION); + if (tempg->cnt) { + *tempad=tempg->dim_list; + tempc+=sizeof(ClassStruct); + lx->flags|=LF_ARRAY; + } + if (tempg->flags & GVAF_FUNCTION) { + //TODO:Not implemented + lx->flags|=LF_FUNCTION; + } + if (lx->a) { + if (tempg->flags & GVAF_EXTERN) { + CbAddIc(lx,EC_IMM,&tempg->data_address,tempc); + CbAddIc(lx,EC_DEREF,0,tempc); + } else { + if (tempg->flags & GVAF_IMPORT) { + CbAddIc(lx,EC_ABSOLUTE_ADDRESS,tempg->data_address,tempc+sizeof(ClassStruct)); + CbAddIc(lx,EC_DEREF,0,tempc); + } else + CbAddIc(lx,EC_ABSOLUTE_ADDRESS,tempg->data_address,tempc); + } + } else { + if (tempg->flags & GVAF_EXTERN) { + CbAddIc(lx,EC_IMM,&tempg->data_address,tempc); + CbAddIc(lx,EC_DEREF,0,tempc); + } else + CbAddIc(lx,EC_IMM,tempg->data_address,tempc); + } + Lex(lx); + return PRST_UNARY_MODIFIERS; + } + if (!(temph->type & HTT_KEYWORD)) + PrsExcept(lx,"ST_MISSING_EXPRESSION"); + if (temph->user_data0==KW_SIZEOF) { + if (Lex(lx)!='(') PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_INVALID_CLASS"); + if (tempm=lx->local_var_entry) { + tempc=tempm->member_class; + i=tempc->size; + if (tempm->cnt) + i*=tempm->cnt; + } else { + tempc=lx->hash_entry; + if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE|HTT_GLBL_VAR))) + PrsExcept(lx,"ST_INVALID_CLASS"); + i=tempc->size; + } //TODO: should allow '.member', etc; + if (Lex(lx)=='*') { + while (Lex(lx)=='*'); + i=sizeof(void *); + } + CbAddIc(lx,EC_IMM,i,sys_internal_types[IT_I8]); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + return PRST_CHECK_BINARY_OPS; + } else if (temph->user_data0==KW_OFFSET) { + if (Lex(lx)!='(') PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_INVALID_CLASS"); + if (tempm=lx->local_var_entry) + tempc=tempm->member_class; + else { + tempc=lx->hash_entry; + if (!tempc || !(tempc->type & (HTT_CLASS|HTT_GLBL_VAR))) + PrsExcept(lx,"ST_INVALID_CLASS"); + else if (tempc->type & HTT_GLBL_VAR) + tempc=tempc><(GlblVarStruct *)->var_class; + } + if (Lex(lx)!='.') + PrsExcept(lx,"ST_EXPECTING_DOT"); + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_INVALID_MEMBER"); + if (!(tempm=FindMember(lx->ident,tempc))) + PrsExcept(lx,"ST_INVALID_MEMBER"); + CbAddIc(lx,EC_IMM,tempm->offset,sys_internal_types[IT_I8]); + if (Lex(lx)!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + return PRST_CHECK_BINARY_OPS; + } + PrsExcept(lx,"ST_MISSING_EXPRESSION"); +} + +U8 PrsUnaryModifier(LexStruct *lx,ParseStack *ps,MemberListStruct **local_var,ArrayDimStruct **tempad) +{ + I8 i,j; + LexCbStack *templ,*templ2,*templl; + ClassStruct *tempc,*tempc1; + MemberListStruct *tempm; + IntermediateCode *tempi,*tempi1; + ArrayDimStruct *tempad1; + if (lx->flags & LF_ASM_EXPRESSIONS) + return PRST_CHECK_BINARY_OPS; + if (lx->token==TK_DEREFERRENCE) { + tempi=lx->cb.cb_last_out_ptr; + if (!(lx->flags & (LF_RAX | LF_ARRAY))) { + tempc=tempi->ic_class-sizeof(ClassStruct); + CbAddIc(lx,EC_DEREF+0x10000,0,tempc); + } else + tempi->ic_class-=sizeof(ClassStruct); + } else if (lx->token=='.') { + if (*local_var) { + tempm=*local_var; + tempm->flags|=MLF_NO_REG_VARIABLE; + } + } + *local_var=NULL; + if (lx->token=='.' || lx->token==TK_DEREFERRENCE) { + tempi=lx->cb.cb_last_out_ptr; + tempc=tempi->ic_class; + if (!(lx->flags & LF_RAX)) + tempc-=sizeof(ClassStruct); + if (!(tempc->type & HTT_CLASS)) + PrsExcept(lx,"ST_INVALID_CLASS"); + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_INVALID_MEMBER"); + if (!(tempm=FindMember(lx->ident,tempc))) + PrsExcept(lx,"ST_INVALID_MEMBER"); + Lex(lx); //skip member name + tempc1=tempm->member_class+sizeof(ClassStruct); + CbAddIc(lx,EC_IMM,tempm->offset,tempc1); + lx->flags&=~(LF_RAX|LF_ARRAY|LF_FUNCTION); + if (tempm->cnt) { + *tempad=tempm->dim_list; + tempc1+=sizeof(ClassStruct); + lx->flags|=LF_ARRAY; + } + if(tempm->flags & MLF_FUNCTION) { + PrsPush(ps,tempm->return_class); + PrsPush(ps,tempm->parameter_cnt); + lx->flags|=LF_FUNCTION; + } + CbAddIc(lx,EC_ADD,0,tempc1); + return PRST_UNARY_MODIFIERS; + } + if (lx->token==TK_CAST) { + if (Lex(lx)!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_INVALID_CLASS"); + tempc=lx->hash_entry; + if (!tempc || !(tempc->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_INVALID_CLASS"); + while (Lex(lx)=='*') + tempc+=sizeof(ClassStruct); + tempc+=sizeof(ClassStruct); + tempi=lx->cb.cb_last_out_ptr; + tempi->ic_class=tempc; + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + return PRST_UNARY_MODIFIERS; + } + if (lx->token=='[') { + Lex(lx); + tempi=lx->cb.cb_last_out_ptr; + if (!(lx->flags & (LF_ARRAY | LF_RAX))) { + tempc=tempi->ic_class-sizeof(ClassStruct); + while (!(tempc->type & HTT_INTERNAL_TYPE) && tempc->return_class) + tempc=tempc->return_class; + i=EC_DEREF+0x10000; + CbAddIc(lx,i,0,tempc); + } else { + tempc=tempi->ic_class; + if (!(lx->flags & LF_RAX)) + tempc-=sizeof(ClassStruct); + } + tempc1=tempc-sizeof(ClassStruct); + if (tempad1=*tempad) { + CbAddIc(lx,EC_IMM,tempad1->cnt*tempc1->size,tempc); + if (*tempad=tempad1->next) { + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,5); + if (lx->token!=']') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACKET"); + Lex(lx); //skip ] + tempi1=lx->cb.cb_last_out_ptr; + if (tempi1->ic_class->sub_type==IT_DOUBLE) + tempi1->ic_flags|=ICF_R_TO_INT; + CbAddIc(lx,EC_MUL,0,tempc); + tempi1=lx->cb.cb_last_out_ptr; + tempi1->ic_flags|=ICF_USE_INT; + CbAddIc(lx,EC_ADD,0,tempc); + tempi1=lx->cb.cb_last_out_ptr; + tempi1->ic_flags|=ICF_USE_INT; + lx->flags|=LF_RAX; + return PRST_UNARY_MODIFIERS; + } + } else + CbAddIc(lx,EC_IMM,tempc1->size,tempc); + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,5); + if (lx->token!=']') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACKET"); + Lex(lx); //skip ] + tempi1=lx->cb.cb_last_out_ptr; + if (tempi1->ic_class->sub_type==IT_DOUBLE) + tempi1->ic_flags|=ICF_R_TO_INT; + CbAddIc(lx,EC_MUL,0,tempc); + tempi1=lx->cb.cb_last_out_ptr; + tempi1->ic_flags|=ICF_USE_INT; + CbAddIc(lx,EC_ADD,0,tempc); + tempi1=lx->cb.cb_last_out_ptr; + tempi1->ic_flags|=ICF_USE_INT; + lx->flags&=~(LF_RAX|LF_ARRAY); + return PRST_UNARY_MODIFIERS; + } + if (lx->token=='(' && lx->flags & LF_FUNCTION) { + tempi=lx->cb.cb_last_out_ptr; + tempc=tempi->ic_class-sizeof(ClassStruct); + if (!(lx->flags & (LF_RAX | LF_ARRAY))) + CbAddIc(lx,EC_DEREF,0,sys_internal_types[IT_PTR]); + else + tempi->ic_class=tempc; + CbAddIc(lx,EC_SET_RAX,0,sys_internal_types[IT_PTR]); + CbAddIc(lx,EC_NOP1,1,sys_internal_types[IT_PTR]); //balance the books + CbAddIc(lx,EC_CALL_START,0,tempc); + CbAddIc(lx,EC_PUSH_REGS,1<cb.cb_next; + lx->cb.cb_next=NULL; + while (i--) { + if (lx->token==',') + Lex(lx); + CbInitOutPtrs(&lx->cb); + if (!PrsParseExpression(lx)) + throw(EXCEPT_COMPILER,6); + CbAddIc(lx,EC_NULL,0,0); + CbPush(lx); + } + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); //skip ')' + templl=templ->cb_next; + templ->cb_next=lx->cb.cb_next; + lx->cb.cb_next=templ; + CbPop(lx); + templ=lx->cb.cb_next; + lx->cb.cb_next=templl; + while (templ) { + templ2=templ->cb_next; + CbAppend(lx,templ); + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + templ=templ2; + } + CbAddIc(lx,EC_CALL_INDIRECT,j<<3,tempc); + CbAddIc(lx,EC_ADD_RSP,j<<3+8,tempc); + CbAddIc(lx,EC_CALL_END,0,tempc); + lx->flags=(lx->flags | LF_RAX)&~(LF_ARRAY | LF_FUNCTION); + return PRST_UNARY_MODIFIERS; + } + if (lx->token==TK_PLUS_PLUS) { + Lex(lx); + lx->flags|=LF_POSTINC; + return PRST_DEREFERRENCE; + } + if (lx->token==TK_MINUS_MINUS) { + Lex(lx); + lx->flags|=LF_POSTDEC; + return PRST_DEREFERRENCE; + } + return PRST_DEREFERRENCE; +} + +U8 PrsDereferrence(LexStruct *lx,ParseStack *ps) +{ + I8 i; + ClassStruct *tempc; + IntermediateCode *tempi; + if (lx->flags & LF_FUNCTION) { + ps->ptr--; + tempc=PrsPop(ps); + } + if (lx->flags & LF_RAX) + return PRST_CHECK_BINARY_OPS; + tempi=lx->cb.cb_last_out_ptr; + tempc=tempi->ic_class-sizeof(ClassStruct); + if (lx->flags & LF_ARRAY) { + tempi->ic_class=tempc; + return PRST_CHECK_BINARY_OPS; + } + + if (lx->flags & LF_PREINC) { + lx->flags&=~LF_PREINC; + i=EC_PP_; + } else if (lx->flags & LF_PREDEC) { + lx->flags&=~LF_PREDEC; + i=EC_MM_; + } else if (lx->flags & LF_POSTINC) { + lx->flags&=~LF_POSTINC; + i=EC__PP; + } else if (lx->flags & LF_POSTDEC) { + lx->flags&=~LF_POSTDEC; + i=EC__MM; + } else + i=EC_DEREF; + + while (tempc->return_class) + tempc=tempc->return_class; + CbAddIc(lx,i+0x10000,0,tempc); + return PRST_CHECK_BINARY_OPS; +} + +void *CompileExpression(LexStruct *lx,U8 *type=NULL) +{ + void *result; + U8 size; + DbgInfo *dbg=NULL; + BoolU4 old_trace=Btr(&lx->flags,LFf_OPT_TRACE_PRESENT); + CbPush(lx); + CbInitOutPtrs(&lx->cb); + CbAddIc(lx,EC_RETURN_START,0,0); + if (PrsParseExpression(lx,TRUE)) { + CbAddIc(lx,EC_RETURN_END,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_RET,0,0); + CbAddIc(lx,EC_NULL,0,0); + result=CbCompile(lx,NULL,&size,&dbg,type); + } else + result=NULL; + CbPop(lx); + Free(dbg); + AssignBit(&lx->flags,LFf_OPT_TRACE_PRESENT,old_trace); + return result; +} + +BoolU8 GetExpression(LexStruct *lx,void **e) //FALSE=no err +{ + *e=CompileExpression(lx); + if (*e) + return TRUE; + else + return FALSE; +} + +I8 Expression(LexStruct *lx) //FALSE=no err +{ + I8 result; + void *e=CompileExpression(lx); + if (e) { + result=Call(e); + DelExpression(e); + } else + result=0; + return result; +} diff --git a/LT/Compiler/Lex.CPZ b/LT/Compiler/Lex.CPZ new file mode 100644 index 0000000..4a275a8 --- /dev/null +++ b/LT/Compiler/Lex.CPZ @@ -0,0 +1,1222 @@ +I1 *CmpPmt(BoolU4 double_semicolon=FALSE) +{ + I8 i; + I1 *s,*result; + + for (i=Fs->answers_displayed-1;i>=0;i--) { + if (Fs->answers_types[i]==IT_DOUBLE) + PrintF("ansd%d=%15.7g=%15e\r\n",i, + Fs->double_answers[i],Fs->double_answers[i]); + else + PrintF("ans%d=0x%016X=%d\r\n",i, + Fs->answers[i],Fs->answers[i]); + } + s=CurDir; + PutS(s); + Free(s); + PutChar('>'); + s=MGetS; + if (double_semicolon) { + i=StrLen(s); + result=MAlloc(i+4); + MemCpy(result,s,i+1); + i--; + while (i>=0 && (result[i]==CH_SPACE || result[i]==CH_SHIFT_SPACE || result[i]==CH_TAB)) + i--; + i++; + if (i>0 && result[i-1]==';') + result[i++]=';'; //The Lex goes one beyond + result[i++]=13;//#define goes to + result[i++]=10; + result[i]=0; + } else + result=NewStr(s); + Free(s); + return result; +} + +LexStruct *LexNew(I1 *buf,U8 flags,I1 *filename) +{ + LexStruct *lx=MAlloc(sizeof(LexStruct)); + LexFileStruct *tempf=&lx->lfns[0]; + MemSet(lx,0,offset(LexStruct.lfns)+sizeof(LexFileStruct)); + lx->next=lx; + lx->last=lx; + lx->flags=flags; + lx->lag_line_num=1; + lx->pass_trace_mask=0b100111111; + lx->hash_mask=HTT_ALL; + lx->hash_table_list=Fs->hash_table; + lx->define_hash_table=Fs->hash_table; + lx->cur_lfn=tempf; + lx->next_exe_blk=&lx->next_exe_blk; + lx->last_exe_blk=&lx->next_exe_blk; + if (!filename) + tempf->name=NewStr(sys_temp_filename); + else + tempf->name=filename; + if (flags & LF_PROMPT) + buf=MAllocZ(4); + tempf->buf=buf; + tempf->buf_ptr=buf; + tempf->line_start=buf; + tempf->line_num=1; + lx->cur_buf_ptr=buf; + return lx; +} + +void LexDel(LexStruct *lx) +{ + LexFileStruct *tempf=lx->cur_lfn; + Ltf *l; + + while (tempf!=&lx->lfns[0]) { + if (l=tempf->l) + CallExtNum(EXT_LTF_DEL,l); + Free(tempf->buf); + Free(tempf->name); + tempf-=sizeof(LexFileStruct); + } + Free(tempf->name); + if (!(lx->flags & LF_DONT_FREE_BUFFER)) + Free(tempf->buf); + Free(lx->ident); + Free(lx); +} + + +void SetSourceFileInfo(LexStruct *lx,SysHashEntry *h) +{ + LexFileStruct *tempf=lx->cur_lfn; + h->source_link=MSPrintF("FL:%s,%d",tempf->name,tempf->line_num); + if (Bt(&lx->flags,LFf_KEEP_PRIVATE)) + h->type|=HTT_PRIVATE; + if (lx->cur_index) + h->index=NewStr(lx->cur_index); + else + h->index=NULL; +} + +void LexPutToken(LexStruct *lx) +{ + PutChar('"'); + if (lx->token==TK_IDENT || lx->token==TK_STR) + PutS(lx->ident); + else if (lx->token==TK_INTEGER) + cout "INT:",lx->cur_i; + else if (lx->token==TK_DOUBLE) + cout "DBL:",lx->cur_d; + else if (lx->token>=CH_SHIFT_SPACE && lx->token<=0x7E) + PutChar(lx->token); + else { + cout "T:",lx->token; + } + PutS("\" "); +} + +U4 lex_zeros=0,lex_line_feed=0x000A; + +void LexBackupLastChar(LexStruct *lx) +{ + LexFileStruct *tempf=lx->cur_lfn; + tempf->buf_ptr=lx->cur_buf_ptr; + if (lx->flags & LF_USE_LAST_I1) { + tempf->last_I1=lx->last_I1; + lx->flags&=~LF_USE_LAST_I1; + } else + tempf->last_I1=0; +} + +U8 LexGetChar(LexStruct *lx) +{ + U1 *src; + LexFileStruct *tempf,*tempf1; + BoolU4 cont; + U8 result; + Ltf *l; + LtfEntry *cl; + U1 *ptr; + if (lx->flags & LF_USE_LAST_I1) { + lx->flags&=~LF_USE_LAST_I1; + if (lx->last_I1==CH_SHIFT_SPACE) + return CH_SPACE; + else + return lx->last_I1; + } + do { +lex_getchar_start: + + src=lx->cur_buf_ptr++; + switch (lx->last_I1=result=*src++) { + case 0: + tempf=lx->cur_lfn; + if (tempf->flags & LFSF_IS_LTF) { + l=tempf->l; + cl=tempf->cur_entry; + cl=cl->next; + while (cl!=l) { + cont=FALSE; + tempf->cur_entry=cl; + switch (cl->btype) { + case LTFT_TEXT: + if (*(src=cl->display)) + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + else { + cont=TRUE; + cl=cl->next; + } + break; + case LTFT_CR: + src=&lex_line_feed; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + tempf->line_start=cl->next; + tempf->line_num=cl->y+2; //+1 because CR is on previous line, +1 because l y starts at zero + compiled_lines++; + if (lx->flags & LF_ECHO) + CrLf; + lx->last_I1=CH_CR; + return CH_CR; + case LTFT_TAB: + src=&lex_zeros; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + tempf->line_num=cl->y+1; + if (lx->flags & LF_ECHO) + PutChar(CH_TAB); + lx->last_I1=CH_TAB; + return CH_TAB; + case LTFT_PAGE_BREAK: + src=&lex_zeros; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + tempf->line_num=cl->y+2; //TODO: should be a page down + if (lx->flags & LF_ECHO) + PutChar(CH_FORM_FEED); + lx->last_I1=CH_FORM_FEED; + return CH_FORM_FEED; + case LTFT_INSERT_BINARY: + src=&lex_zeros; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + tempf->line_num=cl->y+1; + Free(lx->ident); + lx->ident=NULL; + lx->ident_len=0; + if (cl->bin_data) { + ptr=MAlloc(cl->bin_data->size); + if (cl->bin_data->data) + MemCpy(ptr,cl->bin_data->data,cl->bin_data->size); + lx->ident=ptr; + lx->ident_len=cl->bin_data->size; + } + lx->last_I1=TK_INSERT_BINARY; + return TK_INSERT_BINARY; + case LTFT_INSERT_BINARY_TYPE: + src=&lex_zeros; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + if (cl->bin_data) + lx->cur_i=cl->bin_data->type; + else + lx->cur_i=0; + tempf->line_num=cl->y+1; + lx->last_I1=TK_INSERT_BINARY_TYPE; + return TK_INSERT_BINARY_TYPE; + case LTFT_INSERT_BINARY_SIZE: + src=&lex_zeros; + tempf->buf=tempf->buf_ptr=lx->cur_buf_ptr=src; + + if (cl->bin_data) + lx->cur_i=cl->bin_data->size; + else + lx->cur_i=0; + tempf->line_num=cl->y+1; + lx->last_I1=TK_INSERT_BINARY_SIZE; + return TK_INSERT_BINARY_SIZE; + default: + cont=TRUE; + cl=cl->next; + } + if (!cont) break; + } + if (cl==l) { + CallExtNum(EXT_LTF_DEL,l); + tempf->l=tempf->buf=NULL; + Free(tempf->name); + tempf->name=NULL; + goto here; + } + } else { +here: + tempf=lx->cur_lfn; + if (tempf!=&lx->lfns[0]) { + Free(tempf->name); + tempf->name=NULL; + Free(tempf->buf); + tempf->buf=NULL; + tempf1=tempf; + lx->cur_lfn=tempf-=sizeof(LexFileStruct); + lx->cur_buf_ptr=tempf->buf_ptr; + if (lx->last_I1=tempf->last_I1) { + lx->flags&=~LF_USE_LAST_I1; + if (lx->last_I1==CH_SHIFT_SPACE) + return CH_SPACE; + else + return lx->last_I1; + } else + lx->flags&=~LF_USE_LAST_I1; + } else { + if (lx->flags & LF_PROMPT) { + Free(tempf->buf); + lx->cur_buf_ptr=tempf->line_start= + tempf->buf_ptr=tempf->buf=CmpPmt(TRUE); + } else { + lx->last_I1=TK_EOF; + lx->cur_buf_ptr=src-1; + return TK_EOF; + } + } + } + break; + case CH_CURSOR: + case CH_FORM_FEED: + goto lex_getchar_start; + case CH_LINE_FEED: + tempf=lx->cur_lfn; + if (tempf->flags & LFSF_IS_LTF) + if (result==CH_SHIFT_SPACE) + return CH_SPACE; + else + return result; + else { + tempf->line_num++; + compiled_lines++; + tempf->line_start=src; + } + default: + if (lx->flags & LF_ECHO) + PutChar(result); + if (result==CH_SHIFT_SPACE) + return CH_SPACE; + else + return result; + } + } while (TRUE); +} + +void LexSkipEol(LexStruct *lx) +{ + U1 ch; + do ch=LexGetChar(lx); + while (ch && ch!=CH_CR && ch!=CH_LINE_FEED); +} + +void DelExpression(U1 *code) +{ + Free(code); +} + + +U8 EvalExpression(LexStruct *lx) +{ + U1 *exp; + U8 result=0; + if (!GetExpression(lx,&exp)) + LexSkipEol(lx); + else { + result=Call(exp); + DelExpression(exp); + } + return result; +} + +void LexIncludeStr(LexStruct *lx,I1 *filename, + I1 *src,BoolU4 actual_file) +{ + LexFileStruct *tempf; + LexBackupLastChar(lx); + tempf=lx->cur_lfn+sizeof(LexFileStruct); + lx->cur_lfn=tempf; + tempf->buf=src; + tempf->buf_ptr=src; + tempf->line_num=1; + tempf->line_start=src; + tempf->last_I1=0; + if (actual_file) { + tempf->name=AbsoluteFileName(filename); + tempf->flags=LFSF_IS_INCLUDED; + } else { + tempf->name=NewStr(sys_temp_filename); + tempf->flags=0; + } + lx->cur_buf_ptr=src; +} + +void LexIncludeLtf(LexStruct *lx,I1 *filename) +{ + BoolU4 is_null; + LtfEntry *cl; + Ltf *l; + LexFileStruct *tempf; + + LexBackupLastChar(lx); + tempf=lx->cur_lfn+sizeof(LexFileStruct); + lx->cur_lfn=tempf; + tempf->line_start=&lex_zeros; + if (ext[EXT_LTF_READ]) + l=CallExtNum(EXT_LTF_READ,filename,LTFF_DOUBLE_DOLLARS+LTFF_NO_PICWORDS); + else + throw(EXCEPT_COMPILER,1); //This should never happen + tempf->l=l; + cl=l->dummy.next; + while (cl!=l) { + if (cl->btype==LTFT_TEXT) + break; + if (cl->btype==LTFT_TAB) + break; + if (cl->btype==LTFT_CR) + break; + if (cl->btype==LTFT_INSERT_BINARY) + break; + if (cl->btype==LTFT_INSERT_BINARY_TYPE) + break; + if (cl->btype==LTFT_INSERT_BINARY_SIZE) + break; + cl=cl->next; + } + if (cl!=l) { + tempf->line_start=cl; + tempf->line_num=cl->y+1; + if (cl->btype==LTFT_TEXT) { + tempf->cur_entry=cl; + tempf->buf=cl->display; + tempf->buf_ptr=cl->display; + } else { + tempf->cur_entry=cl->last; //TODO might be problem at begining of file + tempf->buf=&lex_zeros; + tempf->buf_ptr=&lex_zeros; + } + is_null=FALSE; + } else + is_null=TRUE; + tempf->name=AbsoluteFileName(filename); + if (is_null) { +// LtfDel(lx); TODO + tempf->flags=LFSF_IS_INCLUDED; + tempf->buf=MAllocZ(1); + tempf->buf_ptr=&lex_zeros; + tempf->line_num=1; + } else + tempf->flags=LFSF_IS_INCLUDED|LFSF_IS_LTF; + tempf->last_I1=0; + lx->cur_buf_ptr=tempf->buf_ptr; +} + +void LexPush(LexStruct *lx) +{ + LexFileStruct *tempf=lx->cur_lfn, + *tempf1=&lx->stack[lx->stack_ptr++]; + if (lx->stack_ptr>=LFN_STACK_CNT) + PrsExcept(lx,"ST_LEX_STACK_OVERFLOW"); + LexBackupLastChar(lx); + if (tempf->last_I1) + lx->flags|=LF_USE_LAST_I1; + MemCpy(tempf1,tempf,sizeof(LexFileStruct)); +} + +void LexPop(LexStruct *lx) +{ + LexFileStruct *tempf=lx->cur_lfn, + *tempf1=&lx->stack[--lx->stack_ptr]; + lx->cur_buf_ptr=tempf1->buf_ptr; + if (lx->last_I1=tempf1->last_I1) + lx->flags|=LF_USE_LAST_I1; + else + lx->flags&=~LF_USE_LAST_I1; + MemCpy(tempf,tempf1,sizeof(LexFileStruct)); +} + +MemberListStruct *FindMember(I1 *st,ClassStruct *c) +{ + MemberListStruct *ml=c->member_list; + while (ml) { + if (!StrCmp(ml->str,st)) { + ml->use_cnt++; + return ml; + } + ml=ml->next; + } + return NULL; +} + +void DelMemberList(ClassStruct *tempc) +{ + MemberListStruct *tempm,*tempm1; + tempm=tempc->member_list; + while (tempm) { + tempm1=tempm->next; + Free(tempm->str); + Free(tempm->fmtstr); + Free(tempm->fmtdata); + DelLinkedList(tempm->dim_list); + if (tempm->flags & MLF_DEFAULT_AVAILABLE && + tempm->member_class==sys_internal_types[IT_I1]+sizeof(ClassStruct)) + Free(tempm->default_value); + Free(tempm); + tempm=tempm1; + } + tempc->size=0; + tempc->last_in_member_list=&tempc->member_list; + tempc->member_list=NULL; + tempc->member_cnt=0; + tempc->parameter_cnt=0; +} + + +I8 LexInStr(LexStruct *lx, + I1 *buf,I8 size,BoolU4 *done) +{ + I8 i=0,j,ch; + *done=TRUE; + while (iflags|=LF_USE_LAST_I1; + } else if (ch>='0' && ch<='7') { + j=ch-'0'; + do { + ch=LexGetChar(lx); + if (ch>='0' && ch<='7') + j=j<<3+ch-'0'; + } while (ch>='0' && ch<='7'); + buf[i++]=j; + lx->flags|=LF_USE_LAST_I1; + } else { + lx->flags|=LF_USE_LAST_I1; + buf[i++]='\\'; + } + } else if (ch=='$$') { + ch=LexGetChar(lx); + buf[i++]='$$'; + if (ch!='$$') + lx->flags|=LF_USE_LAST_I1; + } else + buf[i++]=ch; + } + *done=FALSE; + return i; +} + +I8 Lex(LexStruct *lx) +{ + U8 ch; + I8 i,j,k; + double d; + SysHashEntry *temph; + BoolU4 str_done; + I1 *fbuf; + I1 *buf2,*buf3,buf[LEX_MAX_IDENT]; + lx->lag_line_num=lx->cur_lfn->line_num; + while (TRUE) { +lex_cont: + if (!(ch=LexGetChar(lx))) + return lx->token=TK_EOF; + if (Bt(alpha_bitmap,ch)) { + i=0; + buf[i++]=ch; + do { + if (i>=LEX_MAX_IDENT-1) + break; + else { + if (!(ch=LexGetChar(lx))) + break; + else { + if (Bt(alpha_numeric_bitmap,ch)) + buf[i++]=ch; + else { + lx->flags|=LF_USE_LAST_I1; + break; + } + } + } + } while (TRUE); + buf[i++]=0; + temph=NULL; + if (lx->local_var_list) { + lx->local_var_entry=FindMember(buf, + lx->local_var_list); + } else + lx->local_var_entry=NULL; + if (!lx->local_var_entry && lx->hash_table_list) + temph=FindHashEntry(buf, + lx->hash_table_list,lx->hash_mask); + if (temph) + j=temph->type; + else + j=0; + if (j & HTT_STR_CONST && !(lx->flags & LF_NO_DEFINES)) + LexIncludeStr(lx, + temph->str,NewStr(temph><(StrConstStruct *)->data),FALSE); + else { + lx->hash_entry=temph; + Free(lx->ident); + lx->ident=NewStr(buf); + lx->ident_len=i; + lx->token=TK_IDENT; + goto lex_end; + } + } else if (Bt(dec_numeric_bitmap,ch)) { + i=ch-'0'; + ch=LexGetChar(lx); + if (ch=='X' || ch=='x') { + while (TRUE) { + ch=ToUpper(LexGetChar(lx)); + if (Bt(hex_numeric_bitmap,ch)) { + if (ch<='9') + i=i<<4+ch-'0'; + else + i=i<<4+ch-'A'+10; + } else { + lx->cur_i=i; + lx->flags|=LF_USE_LAST_I1; + lx->token=TK_INTEGER; + goto lex_end; + } + } + } + if (ch=='B' || ch=='b') { + while (TRUE) { + ch=LexGetChar(lx); + if (ch=='0') + i=i<<1; + else if (ch=='1') + i=i<<1+1; + else { + lx->cur_i=i; + lx->flags|=LF_USE_LAST_I1; + lx->token=TK_INTEGER; + goto lex_end; + } + } + } + while (TRUE) { + if (Bt(dec_numeric_bitmap,ch)) + i=i*10+ch-'0'; + else { + if (ch=='.' || ch=='e' || ch=='E') break; + lx->cur_i=i; + lx->flags|=LF_USE_LAST_I1; + lx->token=TK_INTEGER; + goto lex_end; + } + ch=LexGetChar(lx); + } + if (ch=='.') + ch=LexGetChar(lx); +float_start: + //TODO:back-up for cases where i overflows + // (people should use 'e', so might not be worth it) + j=0; + k=0; + while (TRUE) { + //TODO: maybe replace with log2 and insert bit field + if (Bt(dec_numeric_bitmap,ch)) { + j=j*10+ch-'0'; + k++; + } else { + d=i+j*Pow10(-k); + if (ch=='e' || ch=='E') break; + lx->cur_d=d; + lx->flags|=LF_USE_LAST_I1; + lx->token=TK_DOUBLE; + goto lex_end; + } + ch=LexGetChar(lx); + } + ch=LexGetChar(lx); + k=1; + if (ch=='-') { + k=-1; + ch=LexGetChar(lx); + } + j=0; + while (TRUE) { + //TODO: maybe replace with log2 and insert bit field + if (Bt(dec_numeric_bitmap,ch)) + j=j*10+ch-'0'; + else { + d*=Pow10(j*k); + lx->cur_d=d; + lx->flags|=LF_USE_LAST_I1; + lx->token=TK_DOUBLE; + goto lex_end; + } + ch=LexGetChar(lx); + } + } else if (ch=='"') { + lx->flags|=LF_IN_QUOTES; + buf2=NULL; + i=0; + do { + j=LexInStr(lx,buf,LEX_MAX_IDENT,&str_done); + buf3=MAlloc(i+j); + if (buf2) { + MemCpy(buf3,buf2,i); + Free(buf2); + buf2=buf3; + MemCpy(buf2+i,buf,j); + } else { + buf2=buf3; + MemCpy(buf2,buf,j); + } + i+=j; + } while (!str_done); + Free(lx->ident); + lx->ident=MAlloc(i); + MemCpy(lx->ident,buf2,i); + Free(buf2); + lx->ident_len=i; + lx->flags&=~LF_IN_QUOTES; + lx->token=TK_STR; + goto lex_end; + } else if (ch==0x27) { // "'" + ch=LexGetChar(lx); + if (!ch || ch==0x27) i=0x27; + else if (ch=='\\') { + ch=LexGetChar(lx); + if (ch=='n') + i=10; + else if (ch=='r') + i=13; + else if (ch=='"') + i='"'; + else if (ch==0x27) + i=0x27; + else if (ch=='\`') + i='\`'; + else if (ch=='\\') + i='\\'; + else if (ch=='t') + i=9; + else if (ch=='x') { + i=0; + while (TRUE) { + ch=ToUpper(LexGetChar(lx)); + if (Bt(hex_numeric_bitmap,ch)) { + if (ch<='9') + i=i<<4+ch-'0'; + else + i=i<<4+ch-'A'+10; + } else + break; + } + lx->flags|=LF_USE_LAST_I1; + } else if (ch>='0' && ch<='7') { + i=ch-'0'; + do { + ch=LexGetChar(lx); + if (ch>='0' && ch<='7') + i=i<<3+ch-'0'; + } while (ch>='0' && ch<='7'); + lx->flags|=LF_USE_LAST_I1; + } else { + lx->flags|=LF_USE_LAST_I1; + i='\\'; + } + } else if (ch=='$$') { + ch=LexGetChar(lx); + i='$$'; + if (ch!='$$') + lx->flags|=LF_USE_LAST_I1; + } else + i=ch; + ch=LexGetChar(lx); + if (ch!=0x27) + lx->flags|=LF_USE_LAST_I1; + lx->cur_i=i; + lx->token=TK_INTEGER; + goto lex_end; + } else if (ch=='#') { + if (Lex(lx)!=TK_IDENT) //skip '#' + goto lex_end; + if (!(temph=lx->hash_entry)) + goto lex_end; + if (!(temph->type & HTT_KEYWORD)) + goto lex_end; + switch (i=temph->user_data0) { + case KW_INCLUDE: + if (Lex(lx)!=TK_STR) + goto lex_end; + if (lx->flags & LF_ASM_EXPRESSIONS) + fbuf=DefaultExtension(lx->ident,"ASZ"); + else if (Fs==adam_tss) + fbuf=DefaultExtension(lx->ident,"APZ"); + else + fbuf=DefaultExtension(lx->ident,"CPZ"); + if (ext[EXT_LTF_READ]) + LexIncludeLtf(lx,fbuf); + else + LexIncludeStr(lx,fbuf,ReadTextFile(fbuf),TRUE); + Free(fbuf); + break; + case KW_DEFINE: + lx->flags|=LF_NO_DEFINES; + if (Lex(lx)==TK_IDENT) { + temph=MAllocZ(sizeof(StrConstStruct)); + temph->str=lx->ident; + lx->ident=0; + temph->use_cnt=0; + temph->type=HTT_STR_CONST; + SetSourceFileInfo(lx,temph); + i=0; + do ch=LexGetChar(lx); + while (ch && (ch<=CH_SPACE || ch>0x7E) && ch!=CH_CR); + if (ch>CH_SPACE && ch<=0x7E || ch==CH_CR) { + if (ch!=CH_CR) + buf[i++]=ch; + while (i=CH_SHIFT_SPACE && ch<=0x7E || ch==CH_TAB); + break; + } else { + buf[i++]='/'; + lx->flags|=LF_USE_LAST_I1; + } + } else if (ch>=CH_SHIFT_SPACE && ch<=0x7E || ch==CH_TAB) + buf[i++]=ch; + else + break; + } + } + buf[i++]=0; + temph><(StrConstStruct *)->data=NewStr(buf); + AddSysHashEntry(temph,lx->define_hash_table); + } + lx->flags&=~LF_NO_DEFINES; + break; + case KW_ELSE: + if (lx->flags & LF_IN_IF) { + lx->token=TK_ELSE; + goto lex_end; + } +lex_else: + j=1; + do { + if (ch=LexGetChar(lx)) { + if (ch=='#') { + if (!Lex(lx)) + goto lex_end; + i=CmpKeyWord(lx); + if (i==KW_IF || i==KW_IFDEF || i==KW_IFNDEF) + j++; + else if (i==KW_ENDIF) + j--; + } + } else { + lx->token=TK_EOF; + goto lex_end; + } + } while (j); + break; + case KW_IF: + if (lx->flags & LF_IN_IF) { + lx->token=TK_IF; + goto lex_end; + } +lex_if: + lx->flags|=LF_IN_IF; + if (!Lex(lx)) { + lx->flags&=~LF_IN_IF; + goto lex_end; + } + if (Expression(lx)) { + lx->flags&=~LF_IN_IF; + if (lx->token==TK_IF) + goto lex_if; + else if (lx->token==TK_IFDEF) + goto lex_ifdef; + else if (lx->token==TK_IFNDEF) + goto lex_ifndef; + else if (lx->token==TK_ELSE) + goto lex_else; + else if (lx->token==TK_ENDIF) + goto lex_cont; + else + goto lex_end; + } else { + lx->flags&=~LF_IN_IF; + if (lx->token!=TK_ENDIF && lx->token!=TK_ELSE) { + if (lx->token==TK_IF || lx->token==KW_IFDEF || lx->token==KW_IFNDEF) + j=2; + else + j=1; + do { + if (ch=LexGetChar(lx)) { + if (ch=='#') { + if (!Lex(lx)) + goto lex_end; + i=CmpKeyWord(lx); + if (i==KW_IF || i==KW_IFDEF || i==KW_IFNDEF) + j++; + else if (i==KW_ENDIF) + j--; + else if (i==KW_ELSE && j==1) + break; + } + } else { + lx->token=TK_EOF; + goto lex_end; + } + } while (j); + } + } + break; + case KW_IFDEF: + if (lx->flags & LF_IN_IF) { + lx->token=TK_IFDEF; + goto lex_end; + } +lex_ifdef: + lx->flags|=LF_NO_DEFINES; + if (!Lex(lx)) { + lx->flags&=~LF_NO_DEFINES; + goto lex_end; + } + lx->flags&=~LF_NO_DEFINES; + if (lx->token!=TK_IDENT) + goto lex_end; + if (lx->hash_entry) + goto lex_cont; + j=1; + do { + if (ch=LexGetChar(lx)) { + if (ch=='#') { + if (!Lex(lx)) + goto lex_end; + i=CmpKeyWord(lx); + if (i==KW_IF || i==KW_IFDEF || i==KW_IFNDEF) + j++; + else if (i==KW_ENDIF) + j--; + else if (i==KW_ELSE && j==1) + break; + } + } else { + lx->token=TK_EOF; + goto lex_end; + } + } while (j); + break; + case KW_IFNDEF: + if (lx->flags & LF_IN_IF) { + lx->token=TK_IFNDEF; + goto lex_end; + } +lex_ifndef: + lx->flags|=LF_NO_DEFINES; + if (!Lex(lx)) { + lx->flags&=~LF_NO_DEFINES; + goto lex_end; + } + lx->flags&=~LF_NO_DEFINES; + if (lx->token!=TK_IDENT) + goto lex_end; + if (!lx->hash_entry) + goto lex_cont; + j=1; + do { + if (ch=LexGetChar(lx)) { + if (ch=='#') { + if (!Lex(lx)) + goto lex_end; + i=CmpKeyWord(lx); + if (i==KW_IF || i==KW_IFDEF || i==KW_IFNDEF) + j++; + else if (i==KW_ENDIF) + j--; + else if (i==KW_ELSE && j==1) + break; + } + } else { + lx->token=TK_EOF; + goto lex_end; + } + } while (j); + break; + case KW_ENDIF: + if (lx->flags & LF_IN_IF) { + lx->token=TK_ENDIF; + goto lex_end; + } + break; + case KW_ASSERT: + if (!Lex(lx)) + goto lex_end; + if (!Expression(lx)) + PutLexWarning(lx,"ST_ASSERT_FAILED"); + goto lex_end; + case KW_EXE: + if (!Lex(lx)) + goto lex_end; + CallExtNum(EXT_CMP_EXE_BLK,lx); + goto lex_end; + case KW_HELP_INDEX: + if (Lex(lx)!=TK_STR) + goto lex_end; + Free(lx->cur_index); + lx->cur_index=lx->ident; + lx->ident=NULL; + break; + case KW_HELP_FILE: + if (Lex(lx)!=TK_STR) + goto lex_end; + temph=MAllocZ(sizeof(SysHashEntry)); + temph->str=AbsoluteFileName(lx->ident); + temph->type=HTT_HELP_FILE|HTT_PUBLIC; + SetSourceFileInfo(lx,temph); + AddSysHashEntry(temph,lx->hash_table_list); + break; + } + } else if (ch==TK_INSERT_BINARY || + ch==TK_INSERT_BINARY_TYPE || + ch==TK_INSERT_BINARY_SIZE) { + lx->token=ch; + goto lex_end; + } else if (ch=='.') { + ch=LexGetChar(lx); + if (ch>='0' && ch<='9') { + i=0; + goto float_start; + } + lx->flags|=LF_USE_LAST_I1; + lx->token='.'; + goto lex_end; + } else if (ch>=0x21 && ch<=0x7E) { + i=duel_I1_tokens1[ch]; + if (!i) { + if (ch=='$$') { + do ch=LexGetChar(lx); + while (ch && ch!='$$'); + goto lex_cont; + } else { + lx->token=ch; + goto lex_end; + } + } else { + j=LexGetChar(lx); + if (i.u1[0]==j) { + i>>=8; + if (!i) { // "/*" + j=1; + do { + if (!(ch=LexGetChar(lx))) + return lx->token=TK_EOF; +lex_check_comment: + if (ch=='*') { + if (!(ch=LexGetChar(lx))) + return lx->token=TK_EOF; + if (ch=='/') + j--; + else + goto lex_check_comment; + } else if (ch=='/') { + if (!(ch=LexGetChar(lx))) + return lx->token=TK_EOF; + if (ch=='*') + j++; + else + goto lex_check_comment; + } + } while (j); + goto lex_cont; + } else { + lx->token=i; + goto lex_end; + } + } + if (i=duel_I1_tokens2[ch]) { + if (i.u1[0]==j) { + i>>=8; + if (!i) { // "//" + LexSkipEol(lx); + goto lex_cont; + } else { + if (i==TK_SHL || i==TK_SHR) { + j=LexGetChar(lx); + if (j=='=') { + if (i==TK_SHL) + i=TK_SHL_EQUAL; + else + i=TK_SHR_EQUAL; + } else + lx->flags|=LF_USE_LAST_I1; + } + lx->token=i; + goto lex_end; + } + } + if (i=duel_I1_tokens3[ch]) { + if (i.u1[0]==j) { + lx->token=i.u1[1]; + goto lex_end; + } + } + } + lx->flags|=LF_USE_LAST_I1; + lx->token=ch; + goto lex_end; + } + } + } +lex_end: + if (Bt(&lx->flags,LFf_LEX_TRACE)) + LexPutToken(lx); + return lx->token; +} + +I1 *LexExtendStr(LexStruct *lx,U8 *size=NULL) +{ + U8 len=lx->ident_len,len1,len2; + I1 *st=lx->ident,*st1,*st2; + lx->ident=NULL; + while (lx->token==TK_STR) { + st1=st; + len1=len; + if (Lex(lx)==TK_STR) { + len2=lx->ident_len; + st2=lx->ident; + lx->ident=NULL; + len=len1+len2-1; + st=MAlloc(len); + if (len1>1) + MemCpy(st,st1,len1-1); + MemCpy(st+len1-1,st2,len2); + Free(st1); + Free(st2); + } + } + if (size) + *size=len; + return st; +} + +I1 *LexPutLine(LexStruct *lx,I1 *start) +{ + I1 *ptr; + if (!start) return; + if (lx->cur_lfn->flags&LFSF_IS_LTF) + return CallExtStr("LtfPutLine",start); + else { + ptr=start; + while (*ptr && *ptr!=CH_LINE_FEED && *ptr!=CH_CR) + PutChar(*ptr++); + CrLf; + return (*ptr) ? ptr+1:ptr; + } + return NULL; +} + +I8 LexLineNum(LexStruct *lx) +{ + return lx->cur_lfn->line_num; +} + +void LexPutLink(LexStruct *lx) +{ + if (IsRaw) + PrintF("%s,%d ",lx->cur_lfn->name,lx->cur_lfn->line_num); + else { + PutFileLink(lx->cur_lfn->name,lx->cur_lfn->line_num); + AdamErr("%s,%d\r",lx->cur_lfn->name,lx->cur_lfn->line_num); + PutS(" "); + } +} + +void PutLexError(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL) +{ + PutErr; + lx->error_cnt++; + if (!IsRaw) + AdamErr("Tsk:%08X ",Fs); + if (name) { + PutSysText(name); + if (!IsRaw) + AdamErr("%S",name); + } + if (msg) { + PutS(msg); + if (!IsRaw) + AdamErr("%s\r\n",msg); + } + LexPutToken(lx); + LexPutLink(lx); + LexPutLine(lx,lx->cur_lfn->line_start); +} + +void PutLexWarning(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL) +{ + PrintFWarn("%S%s",name,msg); + lx->warning_cnt++; + LexPutToken(lx); + LexPutLink(lx); + LexPutLine(lx,lx->cur_lfn->line_start); +} + +void PutAsmError(LexStruct *lx,I1 *name) +{ + PutLexError(lx,name); + LexSkipEol(lx); + Lex(lx); +} + +void PutAsmWarning(LexStruct *lx,I1 *name) +{ + PutLexWarning(lx,name); + LexSkipEol(lx); + Lex(lx); +} + +void PrsExcept(LexStruct *lx,I1 *name=NULL,I1 *msg=NULL) +{ + PutLexError(lx,name,msg); + CallExtNum(EXT_FLUSH_MSGS,NULL); + throw(EXCEPT_COMPILER,0); +} + + \ No newline at end of file diff --git a/LT/COMPILE/ASM.TXZ b/LT/Compiler/OpCodes.TXZ similarity index 65% rename from LT/COMPILE/ASM.TXZ rename to LT/Compiler/OpCodes.TXZ index 5730ad2..e1354ed 100644 --- a/LT/COMPILE/ASM.TXZ +++ b/LT/Compiler/OpCodes.TXZ @@ -3,6 +3,9 @@ '*'= 16 bit '!'= don't switch modes '&'= default + '-'= NoRex + '='= Rex 0x48 + '~'= Rex 0x40 */ R8 AL 0; R8 CL 1; @@ -12,6 +15,15 @@ R8 AH 4; R8 CH 5; R8 DH 6; R8 BH 7; +R8 R8u1 8; +R8 R9u1 9; +R8 R10u1 10; +R8 R11u1 11; +R8 R12u1 12; +R8 R13u1 13; +R8 R14u1 14; +R8 R15u1 15; + R16 AX 0; R16 CX 1; R16 DX 2; @@ -20,6 +32,15 @@ R16 SP 4; R16 BP 5; R16 SI 6; R16 DI 7; +R16 R8u2 8; +R16 R9u2 9; +R16 R10u2 10; +R16 R11u2 11; +R16 R12u2 12; +R16 R13u2 13; +R16 R14u2 14; +R16 R15u2 15; + R32 EAX 0; R32 ECX 1; R32 EDX 2; @@ -28,6 +49,40 @@ R32 ESP 4; R32 EBP 5; R32 ESI 6; R32 EDI 7; +R32 R8u4 8; +R32 R9u4 9; +R32 R10u4 10; +R32 R11u4 11; +R32 R12u4 12; +R32 R13u4 13; +R32 R14u4 14; +R32 R15u4 15; + +R64 RAX 0; +R64 RCX 1; +R64 RDX 2; +R64 RBX 3; +R64 RSP 4; +R64 RBP 5; +R64 RSI 6; +R64 RDI 7; +R64 R8 8; +R64 R9 9; +R64 R10 10; +R64 R11 11; +R64 R12 12; +R64 R13 13; +R64 R14 14; +R64 R15 15; +R64 R8u8 8; +R64 R9u8 9; +R64 R10u8 10; +R64 R11u8 11; +R64 R12u8 12; +R64 R13u8 13; +R64 R14u8 14; +R64 R15u8 15; + SEG ES 0; SEG CS 1; SEG SS 2; @@ -71,29 +126,39 @@ KEYWORD import 32; KEYWORD LTimport 33; KEYWORD coutln 34; KEYWORD dbgoln 34; +KEYWORD ifdef 35; +KEYWORD ifndef 36; +KEYWORD endif 37; +KEYWORD assert 38; +KEYWORD reg 39; +KEYWORD noreg 40; +KEYWORD nounusedwarn 41; +KEYWORD help_index 42; +KEYWORD help_file 43; 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; +KEYWORD U8 69; +KEYWORD DU1 70; +KEYWORD DU2 71; +KEYWORD DU4 72; +KEYWORD DU8 73; +KEYWORD DUP 74; +KEYWORD ORG 75; +KEYWORD STRUC 76; +KEYWORD ENDS 77; +KEYWORD USE16 78; +KEYWORD USE32 79; +KEYWORD USE64 80; +KEYWORD IMPORT 81; +KEYWORD EXPORT 82; +KEYWORD INSERT 83; +KEYWORD LIST 84; +KEYWORD NOLIST 85; +KEYWORD INSERT_COMPRESSED 86; OPCODE PUSH 0x0E NO CS @@ -107,12 +172,12 @@ OPCODE PUSH 0x68 %!ID IMM32 0x50 +/R *NO R16 0x50 +/R %NO R32 + 0x50 +/R %NO R64 0xFF /6 *NO RM16 - 0xFF /6 %NO RM32; -OPCODE PUSHA 0x60 NO; + 0xFF /6 %NO RM32 + 0xFF /6 %NO RM64; OPCODE PUSHAW 0x60 *NO; OPCODE PUSHAD 0x60 %NO; -OPCODE PUSHF 0x9C NO; OPCODE PUSHFW 0x9C *NO; OPCODE PUSHFD 0x9C %NO; OPCODE POP @@ -123,12 +188,12 @@ OPCODE POP 0x0F 0xA9 NO GS 0x58 +*RW R16 0x58 +%RD R32 + 0x58 +%RD R64 0x8F /0 *NO RM16 - 0x8F /0 %NO RM32; -OPCODE POPA 0x61 NO; + 0x8F /0 %NO RM32 + 0x8F /0 %NO RM64; OPCODE POPAW 0x61 *NO; OPCODE POPAD 0x61 %NO; -OPCODE POPF 0x9D NO; OPCODE POPFW 0x9D *NO; OPCODE POPFD 0x9D %NO; OPCODE MOV @@ -141,33 +206,41 @@ OPCODE MOV 0x8A /R NO R8 RM8 0x8B /R *NO R16 RM16 0x8B /R %NO R32 RM32 + 0x8B /R %NO R64 RM64 0x88 /R NO RM8 R8 0x89 /R *NO RM16 R16 0x89 /R %NO RM32 R32 + 0x89 /R %NO RM64 R64 0x8C /R %NO RM16 SREG 0x8E /R %NO SREG RM16 0xB0 +RB R8 UIMM8 0xB8 +*RW R16 UIMM16 0xB8 +%RD R32 UIMM32 + 0xB8 +%RD R64 UIMM64 0xC6 NO RM8 UIMM8 0xC7 *NO RM16 UIMM16 - 0xC7 %NO RM32 UIMM32; + 0xC7 %NO RM32 UIMM32 + 0xC7 %NO RM64 IMM32; OPCODE ADC 0x14 IB AL UIMM8 0x15 *IW AX UIMM16 0x15 %ID EAX UIMM32 - 0x80 /2 IB RM8 UIMM8 + 0x80 /2 IB RM8 IMM8 0x83 /2 *IB RM16 IMM8 0x83 /2 %IB RM32 IMM8 - 0x81 /2 *IW RM16 UIMM16 - 0x81 /2 %ID RM32 UIMM32 + 0x83 /2 %IB RM64 IMM8 + 0x81 /2 *IW RM16 IMM16 + 0x81 /2 %ID RM32 IMM32 + 0x81 /2 %ID RM64 IMM32 0x12 /R NO R8 RM8 0x13 /R *NO R16 RM16 0x13 /R %NO R32 RM32 + 0x13 /R %NO R64 RM64 0x10 /R NO RM8 R8 0x11 /R *NO RM16 R16 - 0x11 /R %NO RM32 R32; + 0x11 /R %NO RM32 R32 + 0x11 /R %NO RM64 R64; OPCODE ADD 0x04 IB AL UIMM8 0x05 *IW AX UIMM16 @@ -175,14 +248,18 @@ OPCODE ADD 0x80 /0 IB RM8 UIMM8 0x83 /0 *IB RM16 IMM8 0x83 /0 %IB RM32 IMM8 + 0x83 /0 %IB RM64 IMM8 0x81 /0 *IW RM16 UIMM16 0x81 /0 %ID RM32 UIMM32 + 0x81 /0 %ID RM64 UIMM32 0x02 /R NO R8 RM8 0x03 /R *NO R16 RM16 0x03 /R %NO R32 RM32 + 0x03 /R %NO R64 RM64 0x00 /R NO RM8 R8 0x01 /R *NO RM16 R16 - 0x01 /R %NO RM32 R32; + 0x01 /R %NO RM32 R32 + 0x01 /R %NO RM64 R64; OPCODE AND 0x24 IB AL UIMM8 0x25 *IW AX UIMM16 @@ -190,14 +267,18 @@ OPCODE AND 0x80 /4 IB RM8 UIMM8 0x83 /4 *IB RM16 IMM8 0x83 /4 %IB RM32 IMM8 + 0x83 /4 %IB RM64 IMM8 0x81 /4 *IW RM16 UIMM16 0x81 /4 %ID RM32 UIMM32 + 0x81 /4 %ID RM64 UIMM32 0x22 /R NO R8 RM8 0x23 /R *NO R16 RM16 0x23 /R %NO R32 RM32 + 0x23 /R %NO R64 RM64 0x20 /R NO RM8 R8 0x21 /R *NO RM16 R16 - 0x21 /R %NO RM32 R32; + 0x21 /R %NO RM32 R32 + 0x21 /R %NO RM64 R64; OPCODE CMP 0x3C IB AL UIMM8 0x3D *IW AX UIMM16 @@ -205,14 +286,18 @@ OPCODE CMP 0x80 /7 IB RM8 UIMM8 0x83 /7 *IB RM16 IMM8 0X83 /7 %IB RM32 IMM8 + 0X83 /7 %IB RM64 IMM8 0x81 /7 *IW RM16 UIMM16 0x81 /7 %ID RM32 UIMM32 + 0x81 /7 %ID RM64 UIMM32 0x3A /R NO R8 RM8 0x3B /R *NO R16 RM16 //ERROR? 0x3B /R %NO R32 RM32 + 0x3B /R %NO R64 RM64 0x38 /R NO RM8 R8 0x39 /R *NO RM16 R16 - 0x39 /R %NO RM32 R32; + 0x39 /R %NO RM32 R32 + 0x39 /R %NO RM64 R64; OPCODE OR 0x0C IB AL UIMM8 0x0D *IW AX UIMM16 @@ -220,14 +305,18 @@ OPCODE OR 0x80 /1 IB RM8 UIMM8 0x83 /1 *IB RM16 IMM8 0x83 /1 %IB RM32 IMM8 + 0x83 /1 %IB RM64 IMM8 0x81 /1 *IW RM16 UIMM16 0x81 /1 %ID RM32 UIMM32 + 0x81 /1 %ID RM64 UIMM32 0x0A /R NO R8 RM8 0x0B /R *NO R16 RM16 0x0B /R %NO R32 RM32 + 0x0B /R %NO R64 RM64 0x08 /R NO RM8 R8 0x09 /R *NO RM16 R16 - 0x09 /R %NO RM32 R32; + 0x09 /R %NO RM32 R32 + 0x09 /R %NO RM64 R64; OPCODE SBB 0x1C IB AL UIMM8 0x1D *IW AX UIMM16 @@ -235,14 +324,18 @@ OPCODE SBB 0x80 /3 IB RM8 UIMM8 0x83 /3 *IB RM16 IMM8 0x83 /3 %IB RM32 IMM8 + 0x83 /3 %IB RM64 IMM8 0x81 /3 *IW RM16 UIMM16 0x81 /3 %ID RM32 UIMM32 + 0x81 /3 %ID RM64 UIMM32 0x1A /R NO R8 RM8 0x1B /R *NO R16 RM16 0x1B /R %NO R32 RM32 + 0x1B /R %NO R64 RM64 0x18 /R NO RM8 R8 0x19 /R *NO RM16 R16 - 0x19 /R %NO RM32 R32; + 0x19 /R %NO RM32 R32 + 0x19 /R %NO RM64 R64; OPCODE SUB 0x2C IB AL UIMM8 0x2D *IW AX UIMM16 @@ -250,14 +343,18 @@ OPCODE SUB 0x80 /5 IB RM8 UIMM8 0x83 /5 *IB RM16 IMM8 0x83 /5 %IB RM32 IMM8 + 0x83 /5 %IB RM64 IMM8 0x81 /5 *IW RM16 UIMM16 0x81 /5 %ID RM32 UIMM32 + 0x81 /5 %ID RM64 UIMM32 0x2A /R NO R8 RM8 0x2B /R *NO R16 RM16 0x2B /R %NO R32 RM32 + 0x2B /R %NO R64 RM64 0x28 /R NO RM8 R8 0x29 /R *NO RM16 R16 - 0x29 /R %NO RM32 R32; + 0x29 /R %NO RM32 R32 + 0x29 /R %NO RM64 R64; OPCODE TEST 0xA8 IB AL UIMM8 0xA9 *IW AX UIMM16 @@ -265,9 +362,11 @@ OPCODE TEST 0xF6 /0 IB RM8 UIMM8 0xF7 /0 *IW RM16 UIMM16 0xF7 /0 %ID RM32 UIMM32 + 0xF7 /0 %ID RM64 UIMM32 0x84 /R NO RM8 R8 0x85 /R *NO RM16 R16 - 0x85 /R %NO RM32 R32; + 0x85 /R %NO RM32 R32 + 0x85 /R %NO RM64 R64; OPCODE NOP 0x90 NO; OPCODE XCHG 0x90 +/R *NO R16 AX @@ -277,9 +376,11 @@ OPCODE XCHG 0x86 /R NO R8 RM8 0x87 /R *NO R16 RM16 0x87 /R %NO R32 RM32 + 0x87 /R %NO R64 RM64 0x86 /R NO RM8 R8 0x87 /R *NO RM16 R16 - 0x87 /R %NO RM32 R32; + 0x87 /R %NO RM32 R32 + 0x87 /R %NO RM64 R64; OPCODE XOR 0x34 IB AL UIMM8 0x35 *IW AX UIMM16 @@ -287,20 +388,25 @@ OPCODE XOR 0x80 /6 IB RM8 UIMM8 0x83 /6 *IB RM16 IMM8 0x83 /6 %IB RM32 IMM8 + 0x83 /6 %IB RM64 IMM8 0x81 /6 *IW RM16 UIMM16 0x81 /6 %ID RM32 UIMM32 + 0x81 /6 %ID RM64 UIMM32 0x32 /R NO R8 RM8 0x33 /R *NO R16 RM16 0x33 /R %NO R32 RM32 + 0x33 /R %NO R64 RM64 0x30 /R NO RM8 R8 0x31 /R *NO RM16 R16 - 0x31 /R %NO RM32 R32; + 0x31 /R %NO RM32 R32 + 0x31 /R %NO RM64 R64; OPCODE CALL 0xE8 *!&CW REL16 0xFF /2 *!NO RM16 0xE8 %!&CD REL32 0xFF /2 %!NO RM32 + 0xFF /2 %!NO RM64 // 0x9A CD PTR1616 // 0xFF /3 *NO M1616 // 0x9A *CP PTR1632 @@ -313,7 +419,8 @@ OPCODE JMP 0xE9 *!CW REL16 0xE9 %!CD REL32 0xFF /4 *!NO RM16 - 0xFF /4 %!NO RM32; + 0xFF /4 %!NO RM32 + 0xFF /4 %!NO RM64; OPCODE JA 0x77 &CB REL8 0x0F 0x87 *!CW REL16 @@ -342,10 +449,6 @@ 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 @@ -445,48 +548,59 @@ OPCODE JZ OPCODE INC - 0x40 +*RW R16 - 0x40 +%RD R32 +// 0x40 +*RW R16 +// 0x40 +%RD R32 0xFE /0 NO RM8 0xFF /0 *NO RM16 - 0xFF /0 %NO RM32; + 0xFF /0 %NO RM32 + 0xFF /0 %NO RM64; OPCODE DEC - 0x48 +*RW R16 - 0x48 +%RD R32 +// 0x48 +*RW R16 +// 0x48 +%RD R32 0xFE /1 NO RM8 0xFF /1 *NO RM16 - 0xFF /1 %NO RM32; + 0xFF /1 %NO RM32 + 0xFF /1 %NO RM64; OPCODE NOT 0xF6 /2 NO RM8 0xF7 /2 *NO RM16 - 0xF7 /2 %NO RM32; + 0xF7 /2 %NO RM32 + 0xF7 /2 %NO RM64; OPCODE NEG 0xF6 /3 NO RM8 0xF7 /3 *NO RM16 - 0xF7 /3 %NO RM32; + 0xF7 /3 %NO RM32 + 0xF7 /3 %NO RM64; OPCODE MUL 0xF6 /4 NO RM8 0xF7 /4 *NO RM16 - 0xF7 /4 %NO RM32; + 0xF7 /4 %NO RM32 + 0xF7 /4 %NO RM64; OPCODE IMUL 0xF6 /5 NO RM8 0xF7 /5 *NO RM16 - 0xF7 /5 %NO RM32; + 0xF7 /5 %NO RM32 + 0xF7 /5 %NO RM64; OPCODE IMUL2 0x0F 0xAF /R *NO R16 RM16 0x0F 0xAF /R *NO R32 RM32 + 0x0F 0xAF /R *NO R64 RM64 0x6B /R *IB RM16 IMM8 0x6B /R %IB RM32 IMM8 + 0x6B /R %IB RM64 IMM8 0x69 /R *IW RM16 UIMM16 - 0x69 /R %ID RM32 UIMM32; + 0x69 /R %ID RM32 UIMM32 + 0x69 /R %ID RM64 UIMM32; OPCODE DIV 0xF6 /6 NO RM8 0xF7 /6 *NO RM16 - 0xF7 /6 %NO RM32; + 0xF7 /6 %NO RM32 + 0xF7 /6 %NO RM64; OPCODE IDIV 0xF6 /7 NO RM8 0xF7 /7 *NO RM16 - 0xF7 /7 %NO RM32; + 0xF7 /7 %NO RM32 + 0xF7 /7 %NO RM64; OPCODE AAA 0x37 NO; OPCODE AAD 0xD5 0x0A NO; @@ -495,37 +609,50 @@ OPCODE AAS 0x3F NO; OPCODE ARPL 0x63 /R NO RM16 R16; OPCODE BOUND 0x62 /R *NO RM16 R16 - 0x62 /R %NO RM32 R32; + 0x62 /R %NO RM32 R32 + 0x62 /R %NO RM64 R64; OPCODE BSF 0x0F 0xBC /R *NO R16 RM16 - 0x0F 0xBC /R %NO R32 RM32; + 0x0F 0xBC /R %NO R32 RM32 + 0x0F 0xBC /R %NO R64 RM64; OPCODE BSR 0x0F 0xBD /R *NO R16 RM16 - 0x0F 0xBD /R %NO R32 RM32; + 0x0F 0xBD /R %NO R32 RM32 + 0x0F 0xBD /R %NO R64 RM64; OPCODE BSWAP - 0x0F 0xC8 /R %NO R32; + 0x0F 0xC8 /R %NO R32 + 0x0F 0xC8 /R %NO R64; OPCODE BT 0x0F 0xA3 /R *NO RM16 R16 0x0F 0xA3 /R %NO RM32 R32 + 0x0F 0xA3 /R %NO RM64 R64 0x0F 0xBA /4 *IB RM16 UIMM8 - 0x0F 0xBA /4 %IB RM32 UIMM8; + 0x0F 0xBA /4 %IB RM32 UIMM8 + 0x0F 0xBA /4 %IB RM64 UIMM8; OPCODE BTC 0x0F 0xBB /R *NO RM16 R16 0x0F 0xBB /R %NO RM32 R32 + 0x0F 0xBB /R %NO RM64 R64 0x0F 0xBA /7 *IB RM16 UIMM8 - 0x0F 0xBA /7 %IB RM32 UIMM8; + 0x0F 0xBA /7 %IB RM32 UIMM8 + 0x0F 0xBA /7 %IB RM64 UIMM8; OPCODE BTR 0x0F 0xB3 /R *NO RM16 R16 0x0F 0xB3 /R %NO RM32 R32 + 0x0F 0xB3 /R %NO RM64 R64 0x0F 0xBA /6 *IB RM16 UIMM8 - 0x0F 0xBA /6 %IB RM32 UIMM8; + 0x0F 0xBA /6 %IB RM32 UIMM8 + 0x0F 0xBA /6 %IB RM64 UIMM8; OPCODE BTS 0x0F 0xAB /R *NO RM16 R16 0x0F 0xAB /R %NO RM32 R32 + 0x0F 0xAB /R %NO RM64 R64 0x0F 0xBA /5 *IB RM16 UIMM8 - 0x0F 0xBA /5 %IB RM32 UIMM8; + 0x0F 0xBA /5 %IB RM32 UIMM8 + 0x0F 0xBA /5 %IB RM64 UIMM8; OPCODE CBW 0x98 NO; OPCODE CDQ 0x99 NO; +OPCODE CQO 0x99 =NO; OPCODE CLC 0xF8 NO; OPCODE CLD 0xFC NO; OPCODE CLI 0xFA NO; @@ -534,12 +661,13 @@ OPCODE CMC 0xF5 NO; OPCODE CMPSB 0xA6 NO; OPCODE CMPSW 0xA7 *NO; OPCODE CMPSD 0xA7 %NO; +OPCODE CMPSQ 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; + 0x0F 0xB1 /R %NO RM32 R32 + 0x0F 0xB1 /R %NO RM64 R64; +OPCODE CHPXCHG8B 0x0F 0xC7 NO RM64; OPCODE CWD 0x99 NO; OPCODE CWDE 0x98 NO; OPCODE DAA 0x27 NO; @@ -556,41 +684,50 @@ OPCODE IN OPCODE INS 0x6C NO RM8 DX 0x6D *NO RM16 DX - 0x6D %NO RM32 DX; + 0x6D %NO RM32 DX + 0x6D %NO RM64 DX; OPCODE INSB 0x6C NO; OPCODE INSW 0x6D *NO; OPCODE INSD 0x6D %NO; +OPCODE INSQ 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 IRET 0xCF =NO; OPCODE LAHF 0x9F NO; OPCODE LAR 0x0F 0x02 /R *NO R16 RM16 - 0x0F 0x02 /R %NO R32 RM32; + 0x0F 0x02 /R %NO R32 RM32 + 0x0F 0x02 /R %NO R64 RM64; OPCODE LEA 0x8D /R *NO R16 RM16 - 0x8D /R %NO R32 RM32; + 0x8D /R %NO R32 RM32 + 0x8D /R %NO R64 RM64; OPCODE LEAVE 0xC9 NO; OPCODE LGDT - 0x0F 0x01 /2 *NO M16 - 0x0F 0x01 /2 %NO M32; + 0x0F 0x01 /2 *NO RM16 + 0x0F 0x01 /2 %NO RM32 + 0x0F 0x01 /2 %NO RM64; OPCODE LIDT - 0x0F 0x01 /3 *NO M16 - 0x0F 0x01 /3 %NO M32; + 0x0F 0x01 /3 *NO RM16 + 0x0F 0x01 /3 %NO RM32 + 0x0F 0x01 /3 %NO RM64; //OPCODE LGS LSS LFS LDS LES OPCODE LLDT 0x0F 0x00 /2 *NO RM16 - 0x0F 0x00 /2 %NO RM32; + 0x0F 0x00 /2 %NO RM32 + 0x0F 0x00 /2 %NO RM64; OPCODE LMSW 0x0F 0x01 /6 *NO RM16 - 0x0F 0x01 /6 %NO RM32; + 0x0F 0x01 /6 %NO RM32 + 0x0F 0x01 /6 %NO RM64; OPCODE LOCK 0xF0 NO; OPCODE LODSB 0xAC NO; OPCODE LODSW 0xAD *NO; OPCODE LODSD 0xAD %NO; +OPCODE LODSQ 0xAD %=NO; OPCODE LOOP 0xE2 CB REL8; OPCODE LOOPE 0xE1 CB REL8; OPCODE LOOPZ 0xE1 CB REL8; @@ -598,21 +735,30 @@ OPCODE LOOPNE 0xE0 CB REL8; OPCODE LOOPNZ 0xE0 CB REL8; OPCODE LSL 0x0F 0x03 /R *NO R16 RM16 - 0x0F 0x03 /R %NO R32 RM32; + 0x0F 0x03 /R %NO R32 RM32 + 0x0F 0x03 /R %NO R64 RM64; OPCODE LTR 0x0F 0x00 /3 *NO RM16 - 0x0F 0x00 /3 %NO RM32; + 0x0F 0x00 /3 %NO RM32 + 0x0F 0x00 /3 %NO RM64; OPCODE MOVSB 0xA4 NO; OPCODE MOVSW 0xA5 *NO; OPCODE MOVSD 0xA5 %NO; +OPCODE MOVSQ 0xA5 %=NO; OPCODE MOVSX 0x0F 0xBE /R *NO R16 RM8 0x0F 0xBE /R %NO R32 RM8 - 0x0F 0xBF /R %NO R32 RM16; + 0x0F 0xBE /R %NO R64 RM8 + 0x0F 0xBF /R %NO R32 RM16 + 0x0F 0xBF /R %NO R64 RM16; +OPCODE MOVSXD + 0x63 /R %NO R64 RM32; OPCODE MOVZX 0x0F 0xB6 /R *NO R16 RM8 0x0F 0xB6 /R %NO R32 RM8 - 0x0F 0xB7 /R %NO R32 RM16; + 0x0F 0xB6 /R %NO R64 RM8 + 0x0F 0xB7 /R %NO R32 RM16 + 0x0F 0xB7 /R %NO R64 RM16; OPCODE OUT 0xE6 IB UIMM8 AL 0xE7 *IB UIMM8 AX @@ -623,43 +769,56 @@ OPCODE OUT OPCODE OUTSB 0x6E NO; OPCODE OUTSW 0x6F *NO; OPCODE OUTSD 0x6F %NO; -OPCODE RDMSR 0x0F 0x32 NO; +OPCODE OUTSQ 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_INSQ 0xF3 0x6D %=NO; OPCODE REP_MOVSB 0xF3 0xA4 NO; OPCODE REP_MOVSW 0xF3 0xA5 *NO; OPCODE REP_MOVSD 0xF3 0xA5 %NO; +OPCODE REP_MOVSQ 0xF3 0xA5 %=NO; OPCODE REP_OUTSB 0xF3 0x6E NO; OPCODE REP_OUTSW 0xF3 0x6F *NO; OPCODE REP_OUTSD 0xF3 0x6F %NO; +OPCODE REP_OUTSQ 0xF3 0x6F %=NO; OPCODE REP_LODSB 0xF2 0xAC NO; OPCODE REP_LODSW 0xF2 0xAD *NO; OPCODE REP_LODSD 0xF2 0xAD %NO; +OPCODE REP_LODSQ 0xF2 0xAD %=NO; OPCODE REP_STOSB 0xF3 0xAA NO; OPCODE REP_STOSW 0xF3 0xAB *NO; OPCODE REP_STOSD 0xF3 0xAB %NO; +OPCODE REP_STOSQ 0xF3 0xAB %=NO; OPCODE REPE_CMPSB 0xF3 0xA6 NO; OPCODE REPE_CMPSW 0xF3 0xA7 *NO; OPCODE REPE_CMPSD 0xF3 0xA7 %NO; +OPCODE REPE_CMPSQ 0xF3 0xA7 %=NO; OPCODE REPE_SCASB 0xF3 0xAE NO; OPCODE REPE_SCASW 0xF3 0xAF *NO; OPCODE REPE_SCASD 0xF3 0xAF %NO; +OPCODE REPE_SCASQ 0xF3 0xAF %=NO; OPCODE REPNE_CMPSB 0xF2 0xA6 NO; OPCODE REPNE_CMPSW 0xF2 0xA7 *NO; OPCODE REPNE_CMPSD 0xF2 0xA7 %NO; +OPCODE REPNE_CMPSQ 0xF2 0xA7 %=NO; OPCODE REPNE_SCASB 0xF2 0xAE NO; OPCODE REPNE_SCASW 0xF2 0xAF *NO; OPCODE REPNE_SCASD 0xF2 0xAF %NO; +OPCODE REPNE_SCASQ 0xF2 0xAF %=NO; OPCODE RET 0xC3 NO; OPCODE RET2 0xC2 IW UIMM16; OPCODE RETF 0xCB NO; OPCODE RETF2 0xCA IW UIMM16; +OPCODE REX 0x48 NO; +OPCODE REX2 0x40 NO; OPCODE RSM 0x0F 0xAA NO; OPCODE SAHF 0x9E NO; OPCODE SCASB 0xAE NO; OPCODE SCASW 0xAF *NO; OPCODE SCASD 0xAF %NO; +OPCODE SCASQ 0xAF %=NO; OPCODE SEGCS 0x2E NO; OPCODE SEGSS 0x36 NO; OPCODE SEGDS 0x3E NO; @@ -700,38 +859,48 @@ OPCODE SETZ 0x0F 0x94 NO RM8; //OPCODE SIDT 0x0F 0x01 /0 m OPCODE SHLD 0x0F 0xA5 /R *NO RM16 R16 - 0x0F 0xA5 /R %NO RM32 R32; + 0x0F 0xA5 /R %NO RM32 R32 + 0x0F 0xA5 /R %NO RM64 R64; OPCODE SHRD 0x0F 0xAD /R *NO RM16 R16 - 0x0F 0xAD /R %NO RM32 R32; + 0x0F 0xAD /R %NO RM32 R32 + 0x0F 0xAD /R %NO RM64 R64; OPCODE SLDT 0x0F 0x00 /0 *NO RM16 - 0x0F 0x00 /0 %NO RM32; + 0x0F 0x00 /0 %NO RM32 + 0x0F 0x00 /0 %NO RM64; OPCODE SMSW 0x0F 0x01 /4 *NO RM16 - 0x0F 0x01 /4 %NO RM32; + 0x0F 0x01 /4 %NO RM32 + 0x0F 0x01 /4 %NO RM64; 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 STOSD $MA+A+LA,"","NO;"$0xAB %NO; +OPCODE STOSQ 0xAB %=NO; OPCODE STR 0x0F 0x00 /1 *NO RM16 - 0x0F 0x00 /1 %NO RM32; + 0x0F 0x00 /1 %NO RM32 + 0x0F 0x00 /1 %NO RM64; OPCODE VERR 0x0F 0x00 /4 *NO RM16 - 0x0F 0x00 /4 %NO RM32; + 0x0F 0x00 /4 %NO RM32 + 0x0F 0x00 /4 %NO RM64; OPCODE VERW 0x0F 0x00 /5 *NO RM16 - 0x0F 0x00 /5 %NO RM32; + 0x0F 0x00 /5 %NO RM32 + 0x0F 0x00 /5 %NO RM64; OPCODE WAIT 0x9B NO; +OPCODE FWAIT 0x9B NO; OPCODE WBINVD 0x0F 0x09 NO; -OPCODE WRMSR 0x0F 0x30 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; + 0x0F 0xC1 /R %NO RM32 R32 + 0x0F 0xC1 /R %NO RM64 R64; OPCODE XLATB 0xD7 NO; @@ -739,109 +908,135 @@ OPCODE RCL 0xD2 /2 NO RM8 CL 0xD3 /2 *NO RM16 CL 0xD3 /2 %NO RM32 CL + 0xD3 /2 %NO RM64 CL 0xC0 /2 IB RM8 UIMM8 0xC1 /2 *IB RM16 UIMM8 - 0xC1 /2 %IB RM32 UIMM8; + 0xC1 /2 %IB RM32 UIMM8 + 0xC1 /2 %IB RM64 UIMM8; OPCODE RCL1 0xD0 /2 NO RM8 0xD1 /2 *NO RM16 - 0xD1 /2 %NO RM32; + 0xD1 /2 %NO RM32 + 0xD1 /2 %NO RM64; OPCODE RCR 0xD2 /3 NO RM8 CL 0xD3 /3 *NO RM16 CL 0xD3 /3 %NO RM32 CL + 0xD3 /3 %NO RM64 CL 0xC0 /3 IB RM8 UIMM8 0xC1 /3 *IB RM16 UIMM8 - 0xC1 /3 %IB RM32 UIMM8; + 0xC1 /3 %IB RM32 UIMM8 + 0xC1 /3 %IB RM64 UIMM8; OPCODE RCR1 0xD0 /3 NO RM8 0xD1 /3 *NO RM16 - 0xD1 /3 %NO RM32; + 0xD1 /3 %NO RM32 + 0xD1 /3 %NO RM64; OPCODE ROL 0xD2 /0 NO RM8 CL 0xD3 /0 *NO RM16 CL 0xD3 /0 %NO RM32 CL + 0xD3 /0 %NO RM64 CL 0xC0 /0 IB RM8 UIMM8 0xC1 /0 *IB RM16 UIMM8 - 0xC1 /0 %IB RM32 UIMM8; + 0xC1 /0 %IB RM32 UIMM8 + 0xC1 /0 %IB RM64 UIMM8; OPCODE ROL1 0xD0 /0 NO RM8 0xD1 /0 *NO RM16 - 0xD1 /0 %NO RM32; + 0xD1 /0 %NO RM32 + 0xD1 /0 %NO RM64; OPCODE ROR 0xD2 /1 NO RM8 CL 0xD3 /1 *NO RM16 CL 0xD3 /1 %NO RM32 CL + 0xD3 /1 %NO RM64 CL 0xC0 /1 IB RM8 UIMM8 0xC1 /1 *IB RM16 UIMM8 - 0xC1 /1 %IB RM32 UIMM8; + 0xC1 /1 %IB RM32 UIMM8 + 0xC1 /1 %IB RM64 UIMM8; OPCODE ROR1 0xD0 /1 NO RM8 0xD1 /1 *NO RM16 - 0xD1 /1 %NO RM32; + 0xD1 /1 %NO RM32 + 0xD1 /1 %NO RM64; OPCODE SAL 0xD2 /4 NO RM8 CL 0xD3 /4 *NO RM16 CL 0xD3 /4 %NO RM32 CL + 0xD3 /4 %NO RM64 CL 0xC0 /4 IB RM8 UIMM8 0xC1 /4 *IB RM16 UIMM8 - 0xC1 /4 %IB RM32 UIMM8; + 0xC1 /4 %IB RM32 UIMM8 + 0xC1 /4 %IB RM64 UIMM8; OPCODE SAL1 0xD0 /4 NO RM8 0xD1 /4 *NO RM16 - 0xD1 /4 %NO RM32; + 0xD1 /4 %NO RM32 + 0xD1 /4 %NO RM64; OPCODE SAR 0xD2 /7 NO RM8 CL 0xD3 /7 *NO RM16 CL 0xD3 /7 %NO RM32 CL + 0xD3 /7 %NO RM64 CL 0xC0 /7 IB RM8 UIMM8 0xC1 /7 *IB RM16 UIMM8 - 0xC1 /7 %IB RM32 UIMM8; + 0xC1 /7 %IB RM32 UIMM8 + 0xC1 /7 %IB RM64 UIMM8; OPCODE SAR1 0xD0 /7 NO RM8 0xD1 /7 *NO RM16 - 0xD1 /7 %NO RM32; + 0xD1 /7 %NO RM32 + 0xD1 /7 %NO RM64; OPCODE SHL 0xD2 /4 NO RM8 CL 0xD3 /4 *NO RM16 CL 0xD3 /4 %NO RM32 CL + 0xD3 /4 %NO RM64 CL 0xC0 /4 IB RM8 UIMM8 0xC1 /4 *IB RM16 UIMM8 - 0xC1 /4 %IB RM32 UIMM8; + 0xC1 /4 %IB RM32 UIMM8 + 0xC1 /4 %IB RM64 UIMM8; OPCODE SHL1 0xD0 /4 NO RM8 0xD1 /4 *NO RM16 - 0xD1 /4 %NO RM32; + 0xD1 /4 %NO RM32 + 0xD1 /4 %NO RM64; OPCODE SHR 0xD2 /5 NO RM8 CL 0xD3 /5 *NO RM16 CL 0xD3 /5 %NO RM32 CL + 0xD3 /5 %NO RM64 CL 0xC0 /5 IB RM8 UIMM8 0xC1 /5 *IB RM16 UIMM8 - 0xC1 /5 %IB RM32 UIMM8; + 0xC1 /5 %IB RM32 UIMM8 + 0xC1 /5 %IB RM64 UIMM8; OPCODE SHR1 0xD0 /5 NO RM8 0xD1 /5 *NO RM16 - 0xD1 /5 %NO RM32; + 0xD1 /5 %NO RM32 + 0xD1 /5 %NO RM64; OPCODE FILD - 0xDF /5 NO RM32; //Load 64 bit I4 + 0xDF /5 NO RM64; //Load 64 bit I4 OPCODE FISTP - 0xDF /7 NO RM32; //Store 64 bit I4 + 0xDF /7 NO RM64; //Store 64 bit I4 OPCODE FLD - 0xDD /0 NO RM32; //Load 64 bit double + 0xDD /0 NO RM64; //Load 64 bit double OPCODE FSTP - 0xDD /3 NO RM32; //Store 64 bit double + 0xDD /3 NO RM64; //Store 64 bit double OPCODE FST - 0xDD /2 NO RM32; //Store 64 bit double + 0xDD /2 NO RM64; //Store 64 bit double OPCODE FRSTOR - 0xDD /4 NO RM32; + 0xDD /4 NO RM32 + 0xDD /4 NO RM64; OPCODE FSAVE - 0x9B 0xDD /6 NO RM32; + 0x9B 0xDD /6 NO RM32 + 0x9B 0xDD /6 NO RM64; OPCODE FYL2X 0xD9 0xF1 NO; OPCODE FYL2XP1 0xD9 0xF9 NO; @@ -877,5 +1072,14 @@ 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; +OPCODE FSTCW + 0x9B 0xD9 /7 NO RM32 + 0x9B 0xD9 /7 NO RM64; +OPCODE FLDCW + 0xD9 /5 NO RM32 + 0xD9 /5 NO RM64; + +OPCODE WBINVD 0x0F 0x09 NO; +OPCODE CLFLUSH 0x0F 0xAE /7 NO RM8; +OPCODE CPUID 0x0F 0xA2 =NO; +OPCODE RDTSC 0x0F 0x31 =NO; diff --git a/LT/Compiler/OptPass1.CPZ b/LT/Compiler/OptPass1.CPZ new file mode 100644 index 0000000..f9e8e9f --- /dev/null +++ b/LT/Compiler/OptPass1.CPZ @@ -0,0 +1,1540 @@ + +#define FBO1_NOT_CONST 0 +#define FBO1_INT 1 +#define FBO1_DOUBLE 2 + + +BoolU8 FixupBinaryOp1(IntermediateCode *tempi, + IntermediateCode *tempi1,IntermediateCode *tempi2, + BoolU4 *is_unsigned) +{ + ClassStruct *tempc=tempi->ic_class,*tempc1,*tempc2; + tempc1=tempi1->ic_class; + while (tempc1->return_class) + tempc1=tempc1->return_class; + tempc2=tempi2->ic_class; + while (tempc2->return_class) + tempc2=tempc2->return_class; + if (tempc1->sub_type>tempc2->sub_type) + tempi->ic_class=tempc1; + else + tempi->ic_class=tempc2; + tempc=tempi->ic_class; + if (tempc->sub_type==IT_DOUBLE) { + if (!(tempi->ic_flags&ICF_USE_INT)) { + if (tempi1->ic_opcode==EC_IMM) { + tempi1->ic_data><(double)=tempi1->ic_data; + tempi1->ic_class=sys_internal_types[IT_DOUBLE]; + tempi1->ic_opcode=EC_DOUBLE; + } else + if (tempc1->sub_type!=IT_DOUBLE) + tempi1->ic_flags|=ICF_R_TO_DOUBLE; + if (tempi2->ic_opcode==EC_IMM) { + tempi2->ic_data><(double)=tempi2->ic_data; + tempi2->ic_class=sys_internal_types[IT_DOUBLE]; + tempi2->ic_opcode=EC_DOUBLE; + } else + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + } + if (tempi1->ic_opcode==EC_DOUBLE && + tempi2->ic_opcode==EC_DOUBLE && + !(tempi->ic_flags&(ICF_PUSH_CMP|ICF_POP_CMP))) { + tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + return FBO1_DOUBLE; + } else + return FBO1_NOT_CONST; + } + tempi->ic_flags&=~ICF_USE_INT; + *is_unsigned=tempc1->sub_type&1 || tempc2->sub_type&1; + if (tempi1->ic_opcode==EC_IMM && + tempi2->ic_opcode==EC_IMM && + !(tempi->ic_flags&(ICF_PUSH_CMP|ICF_POP_CMP))) { + tempi->ic_flags|=tempi1->ic_flags|tempi2->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + return FBO1_INT; + } else + return FBO1_NOT_CONST; +} + +BoolU8 FixupBinaryOp2(IntermediateCode **tempi1,IntermediateCode **tempi2) +{ + IntermediateCode *tempii1=*tempi1, + *tempii2=*tempi2; + if (tempii1->ic_opcode==EC_IMM && + !(tempii1->ic_flags & ICF_R_TO_DOUBLE)) + return TRUE; + if (tempii2->ic_opcode==EC_IMM && + !(tempii2->ic_flags & ICF_R_TO_DOUBLE)) { + *tempi1=tempii2; + *tempi2=tempii1; + return TRUE; + } + return FALSE; +} + +BoolU8 FixupUnaryOp(IntermediateCode *tempi, + IntermediateCode *tempi1, + BoolU4 *is_unsigned) +{ + ClassStruct *tempc,*tempc1; + tempc1=tempi1->ic_class; + while (tempc1->return_class) + tempc1=tempc1->return_class; + tempi->ic_class=tempc1; + tempc=tempi->ic_class; + if (tempc->sub_type==IT_DOUBLE) { + if (!(tempi->ic_flags&ICF_USE_INT)) { + if (tempi1->ic_opcode==EC_IMM) { + tempi1->ic_data><(double)=tempi1->ic_data; + tempi1->ic_class=sys_internal_types[IT_DOUBLE]; + tempi1->ic_opcode=EC_DOUBLE; + } else + if (tempc1->sub_type!=IT_DOUBLE) + tempi1->ic_flags|=ICF_R_TO_DOUBLE; + } + if (tempi1->ic_opcode==EC_DOUBLE) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + return FBO1_DOUBLE; + } else + return FBO1_NOT_CONST; + } + tempi->ic_flags&=~ICF_USE_INT; + *is_unsigned=tempc1->sub_type&1; + if (tempi1->ic_opcode==EC_IMM) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + return FBO1_INT; + } else + return FBO1_NOT_CONST; +} + +I8 CmpOffsetToReg(I8 offset,I8 *register_offsets) +{ + I8 i; + for (i=0;icb); + ps->ptr=0; + for (i=0;i<4;i++) + temp_lag[i]=&opt_nop; + return ps; +} + +LTextern CP_OPTNEXT BoolU4 OptNext(IntermediateCode *tempi, + IntermediateCode **temp_lag); + +LTextern CP_OPTNEXT2 BoolU4 OptNext2(IntermediateCode *tempi, + IntermediateCode **temp_lag); + +LTextern CP_OPTNEXT3 BoolU4 OptNext3(IntermediateCode *tempi, + IntermediateCode **temp_lag); + +void OptEnd(LexStruct *lx,I8 pass,ParseStack *ps) +{ + if (ps->ptr>2) { + PrintF("Pass:%d Stack:%08X\r\n",pass,ps->ptr); + PrsExcept(lx,"ST_OPT_INTERNAL_ERROR"); + } + Free(ps); +} + + +IntermediateCode *OptLag(LexStruct *lx,IntermediateCode *tempi) +{ + do { + if (tempi==lx->cb.cb_in_ptr) + return NULL; + else + tempi-=sizeof(IntermediateCode); + } while (tempi->ic_opcode<=EC_END_EXP); + return tempi; +} + +IntermediateCode *OptLag1(LexStruct *lx,IntermediateCode *tempi) +{ + do { + if (tempi==lx->cb.cb_in_ptr) + return NULL; + else + tempi-=sizeof(IntermediateCode); + } while (tempi->ic_opcode==EC_NOP||tempi->ic_opcode==EC_NOP1); + return tempi; +} + +IntermediateCode *OptLead1(LexStruct *lx,IntermediateCode *tempi) +{ + nounusedwarn lx; + do { + tempi+=sizeof(IntermediateCode); + if (tempi->ic_opcode==EC_NULL) + return NULL; + } while (tempi->ic_opcode==EC_NOP||tempi->ic_opcode==EC_NOP1); + return tempi; +} + +extern void OptBrNotZero(LexStruct *lx,IntermediateCode *tempi); + +IntermediateCode *OptBrZero(LexStruct *lx,IntermediateCode *tempi) +{ + CbMiscStruct *templ_true,*templ_false; + IntermediateCode *tempii=OptLag(lx,tempi),*tempii2; + switch (tempii->ic_opcode) { + case EC_NOT: + tempi->ic_opcode=EC_BR_NOT_ZERO; + tempi->ic_class=tempii->ic_class; + tempi->ic_flags|=tempii->ic_flags; + tempi->p1c=tempii->p1c; + tempi->p1t=tempii->p1t; + tempii->ic_opcode=EC_NOP; + tempii->ic_flags=0; + return OptBrNotZero(lx,tempi); + case EC_EQUAL_EQUAL: + tempi->ic_opcode=EC_BR_NOT_EQUAL; + break; + case EC_NOT_EQUAL: + tempi->ic_opcode=EC_BR_EQUAL_EQUAL; + break; + case EC_LESS: + tempi->ic_opcode=EC_BR_GREATER_EQUAL; + break; + case EC_GREATER: + tempi->ic_opcode=EC_BR_LESS_EQUAL; + break; + case EC_LESS_EQUAL: + tempi->ic_opcode=EC_BR_GREATER; + break; + case EC_GREATER_EQUAL: + tempi->ic_opcode=EC_BR_LESS; + break; + case EC_OR_OR: + tempi->ic_opcode=EC_BR_OR_OR_ZERO; + break; + case EC_AND_AND: + tempi->ic_opcode=EC_BR_AND_AND_ZERO; + break; + case EC_AND: + tempi->ic_opcode=EC_BR_AND_ZERO; + break; + case EC_CALL_END: + tempii2=OptLag(lx,tempii); + switch (tempii2->ic_opcode) { + case EC_BT: + tempii2->ic_opcode=EC_BR_NOT_BT; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTS: + tempii2->ic_opcode=EC_BR_NOT_BTS; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTR: + tempii2->ic_opcode=EC_BR_NOT_BTR; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTC: + tempii2->ic_opcode=EC_BR_NOT_BTC; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTS: + tempii2->ic_opcode=EC_BR_NOT_LBTS; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTR: + tempii2->ic_opcode=EC_BR_NOT_LBTR; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTC: + tempii2->ic_opcode=EC_BR_NOT_LBTC; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + } + break; + } + if (tempi->ic_opcode!=EC_BR_ZERO) { + tempi->ic_class=tempii->ic_class; + tempi->ic_flags|=tempii->ic_flags; + tempi->p1c=tempii->p1c; + tempi->p2c=tempii->p2c; + tempi->p1t=tempii->p1t; + tempi->p2t=tempii->p2t; + tempii->ic_opcode=EC_NOP; + tempii->ic_flags=0; + templ_true=tempi->ic_data; + if (tempi->ic_opcode==EC_BR_AND_AND_ZERO) { + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempii=tempi->p1t+sizeof(IntermediateCode); + tempii->ic_data=templ_true; + tempii->p1t=tempi->p1t; + tempii->p1c=tempi->p1c; + tempii->ic_opcode=EC_BR_ZERO; + OptBrZero(lx,tempii); + tempii=tempi->p2t+sizeof(IntermediateCode); + tempii->p1t=tempi->p2t; + tempii->p1c=tempi->p2c; + tempii->ic_data=templ_true; + tempii->ic_opcode=EC_BR_ZERO; + return OptBrZero(lx,tempii); + } else if (tempi->ic_opcode==EC_BR_OR_OR_ZERO) { + templ_false=CbMiscNew(lx,CBMT_LABEL); + tempi->ic_opcode=EC_LABEL; + tempi->ic_flags=0; + tempi->ic_data=templ_false; + tempii=tempi->p1t+sizeof(IntermediateCode); + tempii->p1t=tempi->p1t; + tempii->p1c=tempi->p1c; + tempii->ic_data=templ_false; + tempii->ic_opcode=EC_BR_NOT_ZERO; + OptBrNotZero(lx,tempii); + tempii=tempi->p2t+sizeof(IntermediateCode); + tempii->p1t=tempi->p2t; + tempii->p1c=tempi->p2c; + tempii->ic_data=templ_true; + tempii->ic_opcode=EC_BR_ZERO; + return OptBrZero(lx,tempii); + } + } + return tempi; +} + + +IntermediateCode *OptBrNotZero(LexStruct *lx,IntermediateCode *tempi) +{ + CbMiscStruct *templ_true,*templ_false; + IntermediateCode *tempii=OptLag(lx,tempi),*tempii2; + switch (tempii->ic_opcode) { + case EC_NOT: + tempi->ic_opcode=EC_BR_ZERO; + tempi->ic_class=tempii->ic_class; + tempi->ic_flags|=tempii->ic_flags; + tempi->p1c=tempii->p1c; + tempi->p1t=tempii->p1t; + tempii->ic_opcode=EC_NOP; + tempii->ic_flags=0; + return OptBrZero(lx,tempi); + case EC_EQUAL_EQUAL: + tempi->ic_opcode=EC_BR_EQUAL_EQUAL; + break; + case EC_NOT_EQUAL: + tempi->ic_opcode=EC_BR_NOT_EQUAL; + break; + case EC_LESS: + tempi->ic_opcode=EC_BR_LESS; + break; + case EC_GREATER: + tempi->ic_opcode=EC_BR_GREATER; + break; + case EC_LESS_EQUAL: + tempi->ic_opcode=EC_BR_LESS_EQUAL; + break; + case EC_GREATER_EQUAL: + tempi->ic_opcode=EC_BR_GREATER_EQUAL; + break; + case EC_OR_OR: + tempi->ic_opcode=EC_BR_OR_OR_NOT_ZERO; + break; + case EC_AND_AND: + tempi->ic_opcode=EC_BR_AND_AND_NOT_ZERO; + break; + case EC_AND: + tempi->ic_opcode=EC_BR_AND_NOT_ZERO; + break; + case EC_CALL_END: + tempii2=OptLag(lx,tempii); + switch (tempii2->ic_opcode) { + case EC_BT: + tempii2->ic_opcode=EC_BR_BT; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTS: + tempii2->ic_opcode=EC_BR_BTS; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTR: + tempii2->ic_opcode=EC_BR_BTR; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_BTC: + tempii2->ic_opcode=EC_BR_BTC; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTS: + tempii2->ic_opcode=EC_BR_LBTS; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTR: + tempii2->ic_opcode=EC_BR_LBTR; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + case EC_LBTC: + tempii2->ic_opcode=EC_BR_LBTC; + tempii2->ic_data=tempi->ic_data; + tempii->ic_opcode=EC_CALL_END2; + tempi->ic_opcode=EC_NOP; + return tempii; + } + break; + } + if (tempi->ic_opcode!=EC_BR_NOT_ZERO) { + tempi->ic_class=tempii->ic_class; + tempi->ic_flags|=tempii->ic_flags; + tempi->p1c=tempii->p1c; + tempi->p2c=tempii->p2c; + tempi->p1t=tempii->p1t; + tempi->p2t=tempii->p2t; + tempii->ic_opcode=EC_NOP; + tempii->ic_flags=0; + templ_true=tempi->ic_data; + if (tempi->ic_opcode==EC_BR_OR_OR_NOT_ZERO) { + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempii=tempi->p1t+sizeof(IntermediateCode); + tempii->p1t=tempi->p1t; + tempii->p1c=tempi->p1c; + tempii->ic_data=templ_true; + tempii->ic_opcode=EC_BR_NOT_ZERO; + OptBrNotZero(lx,tempii); + tempii=tempi->p2t+sizeof(IntermediateCode); + tempii->p1t=tempi->p2t; + tempii->p1c=tempi->p2c; + tempii->ic_data=templ_true; + tempii->ic_opcode=EC_BR_NOT_ZERO; + return OptBrNotZero(lx,tempii); + } else if (tempi->ic_opcode==EC_BR_AND_AND_NOT_ZERO) { + templ_false=CbMiscNew(lx,CBMT_LABEL); + tempi->ic_opcode=EC_LABEL; + tempi->ic_flags=0; + tempi->ic_data=templ_false; + tempii=tempi->p1t+sizeof(IntermediateCode); + tempii->p1t=tempi->p1t; + tempii->p1c=tempi->p1c; + tempii->ic_data=templ_false; + tempii->ic_opcode=EC_BR_ZERO; + OptBrZero(lx,tempii); + tempii=tempi->p2t+sizeof(IntermediateCode); + tempii->p1t=tempi->p2t; + tempii->p1c=tempi->p2c; + tempii->ic_data=templ_true; + tempii->ic_opcode=EC_BR_NOT_ZERO; + return OptBrNotZero(lx,tempii); + } + } + return tempi; +} + +IntermediateCode *CmpOptPass1(LexStruct *lx,ClassStruct *fun_class,BoolU4 combined) +{ +/* + Simplify CONST arithmetic. + Sets the class throughout Expression trees. + Returns the type of an Expression for use + in int<-->double conversions of function + parameters. +*/ + I8 code,i; + BoolU4 is_unsigned; + ClassStruct *tempc,*tempc1,*tempc2,*tempc3,*tempcc; + IntermediateCode *tempi,*tempi1,*tempi2,*tempi3,*tempi_push, + *temp_lag[4],*last_with_class=NULL,*tempii; + ParseStack *ps=OptStart(lx,temp_lag); + if (combined) + tempi=lx->cb.cb_in_ptr; + else + tempi=CbGetIc1(&lx->cb); + while (code=tempi->ic_opcode) { + OptNext(tempi,temp_lag); + tempc=tempi->ic_class; + tempi->original_class=tempc; + tempi_push=tempi; + switch (cmp_param_cnt[code]) { + case 9: + ps->ptr-=tempi->ic_data>>2; + break; + case 3: + tempi3=PrsPop(ps); + tempc3=tempi3->ic_class; + tempi->p3t=tempi3; + tempi->p3c=PrsPop(ps); + case 2: + tempi2=PrsPop(ps); + tempc2=tempi2->ic_class; + tempi->p2t=tempi2; + tempi->p2c=PrsPop(ps); + case 1: + tempi1=PrsPop(ps); + tempc1=tempi1->ic_class; + tempi->p1t=tempi1; + tempi->p1c=PrsPop(ps); + break; + } + if (Bt(not_constant_bitmap,code)) + lx->flags|=LF_NOT_CONSTANT; + switch (code) { + case EC_IMM: + case EC_DOUBLE: + case EC_STR_CONST: + case EC_RBP: + case EC_FS: + case EC_GS: + break; + case EC_PUSH_CMP: + tempi1=temp_lag[1]; + if (tempi1->ic_opcode==EC_AND_AND) + tempi1=temp_lag[2]; + tempi->ic_class=tempi1->ic_class; + tempi->original_class=tempi->ic_class; + tempi->ic_data=0; + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + break; + case EC_COM: + if (tempc->sub_type==IT_DOUBLE) { + if (tempi1->ic_opcode==EC_DOUBLE) { + tempi->ic_data><(double)=~tempi1->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + } + break; + } + if (tempi1->ic_opcode==EC_IMM) { + tempi->ic_data=~tempi1->ic_data; + tempi->ic_opcode=EC_IMM; + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_NOT: + if (tempc->sub_type==IT_DOUBLE) { + if (tempi1->ic_opcode==EC_DOUBLE) { + tempi->ic_data><(double)=!tempi1->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + } + break; + } + if (tempi1->ic_opcode==EC_IMM) { + tempi->ic_data=!tempi1->ic_data; + tempi->ic_opcode=EC_IMM; + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_UNARY_MINUS: + if (i=FixupUnaryOp(tempi,tempi1,&is_unsigned)) { + if (i==FBO1_INT) { + tempi->ic_data=-tempi1->ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + if (tempi->ic_flags&ICF_USE_INT) { + tempi->ic_data=-tempi1->ic_data><(double); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=-tempi1->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } + } + if (tempc1->type&HTT_INTERNAL_TYPE && tempc1->sub_type& 1) + tempi->ic_class=sys_internal_types[tempc1->sub_type-1]; + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_DEREF: + case EC__PP: + case EC__MM: + case EC_PP_: + case EC_MM_: + break; + case EC_SHL_CONST: + case EC_SHR_CONST: + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + + case EC_POWER: + if (tempc1->sub_type>tempc2->sub_type) + tempi->ic_class=tempc1; + else + tempi->ic_class=tempc2; + tempc=tempi->ic_class; + if (tempc1->sub_type!=IT_DOUBLE) + tempi1->ic_flags|=ICF_R_TO_DOUBLE; + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + if (tempc->sub_type!=IT_DOUBLE) + tempi->ic_flags|=ICF_R_TO_INT|ICF_USE_DOUBLE; + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_SHL: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)<ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)<ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double) << tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } else if (tempi2->ic_opcode==EC_IMM) { + tempi->ic_flags|=tempi2->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_data=tempi2->ic_data; + tempi->ic_opcode=EC_SHL_CONST; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_SHR: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)>>tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)>>tempi2->ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double) >> tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } else if (tempi2->ic_opcode==EC_IMM) { + tempi->ic_flags|=tempi2->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_data=tempi2->ic_data; + tempi->ic_opcode=EC_SHR_CONST; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_MUL: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)*tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)*tempi2->ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + if (tempi->ic_flags&ICF_USE_INT) { + tempi->ic_data=tempi1->ic_data><(double)* + tempi2->ic_data><(double); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double)* + tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } + } else { + if (tempi2->ic_opcode==EC_IMM) { + tempcc=tempi->p1c; + tempii=tempi2; + tempi2=tempi1; + tempi1=tempii; + } else + tempcc=tempi->p2c; + + if (tempi1->ic_opcode==EC_IMM) { + i=tempi1->ic_data; + switch (i) { + case 0: + break; + case 1: + tempi2->ic_flags|=tempi->ic_flags|tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi2->p1c=tempi->p1c; + tempi2->p1t=tempi->p1t; + tempi2->original_class=tempi->original_class; + tempi_push=tempi2; + break; + default: + if (Bsf(i)==Bsr(i)) { + tempi->ic_flags|=tempi1->ic_flags; + tempi->p1c=tempcc; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi->ic_data=Bsf(i); + tempi->ic_opcode=EC_SHL_CONST; + } + break; + } + } + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_DIV: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (!tempi2->ic_data) PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)/tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)/tempi2->ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double)/ + tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } else { + if (tempi2->ic_opcode==EC_IMM) { + i=tempi2->ic_data; + switch (i) { + case 0: + PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + break; + case 1: + tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi1->p1c=tempi->p1c; + tempi1->p1t=tempi->p1t; + tempi1->original_class=tempi->original_class; + tempi_push=tempi1; + break; + default: + if (Bsf(i)==Bsr(i)) { + tempi->ic_flags|=tempi2->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_data=Bsf(i); + tempi->ic_opcode=EC_SHR_CONST; + } + break; + } + } + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_MOD: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (!tempi2->ic_data) PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)%tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)%tempi2->ic_data><(I8); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double)% + tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } else { + if (tempi2->ic_opcode==EC_IMM) { + i=tempi2->ic_data; + switch (i) { + case 0: + PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + break; + default: + if (i>0 && Bsf(i)==Bsr(i)) { + tempi2->ic_data=i-1; + tempi->ic_opcode=EC_AND; + } + break; + } + } + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_AND: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data&tempi2->ic_data; + if (i==FBO1_INT) + tempi->ic_opcode=EC_IMM; + else + tempi->ic_opcode=EC_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_OR: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data|tempi2->ic_data; + if (i==FBO1_INT) + tempi->ic_opcode=EC_IMM; + else + tempi->ic_opcode=EC_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_XOR: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data^tempi2->ic_data; + if (i==FBO1_INT) + tempi->ic_opcode=EC_IMM; + else + tempi->ic_opcode=EC_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_ADD: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + tempi->ic_data=tempi1->ic_data+tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } else { + if (tempi->ic_flags&ICF_USE_INT) { + tempi->ic_data=tempi1->ic_data><(double)* + tempi2->ic_data><(double); + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double)+ + tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } + } else { + if (tempi1->ic_opcode==EC_IMM) { +/******* we got problems--class needs to propigate back + if (!tempi1->ic_data) { + tempi2->ic_flags|=tempi1->ic_flags|tempi->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi2->p1c=tempi->p1c; + tempi2->p1t=tempi->p1t; + tempi2->original_class=tempi->original_class; + tempi_push=tempi2; + } else +*******/ + +// we got problems--class needs to propigate back + if (tempi2->ic_opcode==EC_ADD|| + tempi2->ic_opcode==EC_SUB) { + if (tempi2->p1t->ic_opcode==EC_IMM) { + tempi2->ic_flags|=tempi->ic_flags; + if (tempi2->ic_opcode==EC_ADD) + tempi2->p1t->ic_data+=tempi1->ic_data; + else + tempi2->p1t->ic_data-=tempi1->ic_data; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi2->p1c=tempi->p1c; + tempi2->p1t=tempi->p1t; + tempi2->original_class=tempi->original_class; + tempi_push=tempi2; + } else if (tempi2->p2t->ic_opcode==EC_IMM) { + tempi2->ic_flags|=tempi->ic_flags; + if (tempi2->ic_opcode==EC_ADD) + tempi2->p2t->ic_data+=tempi1->ic_data; + else + tempi2->p2t->ic_data-=tempi1->ic_data; + tempi1->ic_opcode=EC_NOP; + tempi1->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi2->p1c=tempi->p1c; + tempi2->p1t=tempi->p1t; + tempi2->original_class=tempi->original_class; + tempi_push=tempi2; + } + } + } else if (tempi2->ic_opcode==EC_IMM) { +/******* we got problems--class needs to propigate back + if (!tempi2->ic_data) { + tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi1->p1c=tempi->p1c; + tempi1->p1t=tempi->p1t; + tempi1->original_class=tempi->original_class; + tempi_push=tempi1; + } else +*******/ + +// we got problems--class needs to propigate back + if (tempi1->ic_opcode==EC_ADD || + tempi1->ic_opcode==EC_SUB) { + if (tempi1->p1t->ic_opcode==EC_IMM) { + tempi1->ic_flags|=tempi->ic_flags; + if (tempi1->ic_opcode==EC_ADD) + tempi1->p1t->ic_data+=tempi2->ic_data; + else + tempi1->p1t->ic_data-=tempi2->ic_data; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi1->p1c=tempi->p1c; + tempi1->p1t=tempi->p1t; + tempi1->original_class=tempi->original_class; + tempi_push=tempi1; + } else if (tempi1->p2t->ic_opcode==EC_IMM) { + tempi1->ic_flags|=tempi->ic_flags; + if (tempi1->ic_opcode==EC_ADD) + tempi1->p2t->ic_data+=tempi2->ic_data; + else + tempi1->p2t->ic_data-=tempi2->ic_data; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi1->p1c=tempi->p1c; + tempi1->p1t=tempi->p1t; + tempi1->original_class=tempi->original_class; + tempi_push=tempi1; + } + } + } + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_SUB: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + tempi->ic_data=tempi1->ic_data-tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } else { + tempi->ic_data><(double)=tempi1->ic_data><(double)- + tempi2->ic_data><(double); + tempi->ic_opcode=EC_DOUBLE; + } + } else { + if (tempi2->ic_opcode==EC_IMM && !tempi2->ic_data) { + tempi1->ic_flags|=tempi2->ic_flags|tempi->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi2->ic_flags=0; + tempi->ic_opcode=EC_NOP; + tempi->ic_flags=0; + tempi1->p1c=tempi->p1c; + tempi1->p1t=tempi->p1t; + tempi1->original_class=tempi->original_class; + tempi_push=tempi1; + } + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_EQUAL_EQUAL: + if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data==tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } else + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_NOT_EQUAL: + if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data!=tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } else + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_LESS: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)ic_data><(I8); + } else { + tempi->ic_data=tempi1->ic_data><(double)< + tempi2->ic_data><(double); + } + tempi->ic_opcode=EC_IMM; + } else { + if (is_unsigned) + tempi->ic_flags|=ICF_USE_UNSIGNED; + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_GREATER: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)>tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)>tempi2->ic_data><(I8); + } else { + tempi->ic_data=tempi1->ic_data><(double)> + tempi2->ic_data><(double); + } + tempi->ic_opcode=EC_IMM; + } else { + if (is_unsigned) + tempi->ic_flags|=ICF_USE_UNSIGNED; + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_LESS_EQUAL: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)<=tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)<=tempi2->ic_data><(I8); + } else { + tempi->ic_data=tempi1->ic_data><(double)<= + tempi2->ic_data><(double); + } + tempi->ic_opcode=EC_IMM; + } else { + if (is_unsigned) + tempi->ic_flags|=ICF_USE_UNSIGNED; + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_GREATER_EQUAL: + if (i=FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + if (i==FBO1_INT) { + if (is_unsigned) + tempi->ic_data=tempi1->ic_data><(U8)>=tempi2->ic_data><(U8); + else + tempi->ic_data=tempi1->ic_data><(I8)>=tempi2->ic_data><(I8); + } else { + tempi->ic_data=tempi1->ic_data><(double)>= + tempi2->ic_data><(double); + } + tempi->ic_opcode=EC_IMM; + } else { + if (is_unsigned) + tempi->ic_flags|=ICF_USE_UNSIGNED; + if (tempi->ic_class->sub_type==IT_DOUBLE) + tempi->ic_flags|=ICF_USE_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + if (tempi_push->ic_flags & ICF_PUSH_CMP) + tempi->ic_class=tempi->original_class; + else + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_AND_AND: + if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data&&tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_OR_OR: + if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data||tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_XOR_XOR: + if (FixupBinaryOp1(tempi,tempi1,tempi2,&is_unsigned)) { + tempi->ic_data=tempi1->ic_data^^tempi2->ic_data; + tempi->ic_opcode=EC_IMM; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else if (is_unsigned) + tempi_push->original_class=sys_internal_types[IT_U8]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + tempi->ic_class=sys_internal_types[IT_I8]; + break; + case EC_COLON: + if (tempc2->sub_type>tempc3->sub_type) + tempi->ic_class=tempc2; + else + tempi->ic_class=tempc3; + tempc=tempi->ic_class; + if (tempc->sub_type==IT_DOUBLE) { + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + if (tempc3->sub_type!=IT_DOUBLE) + tempi3->ic_flags|=ICF_R_TO_DOUBLE; + } + if (!tempi_push->ic_class->ptr_cnt) { + if (tempi_push->ic_class->sub_type==IT_DOUBLE) + tempi_push->original_class=sys_internal_types[IT_DOUBLE]; + else + tempi_push->original_class=sys_internal_types[IT_I8]; + } + break; + case EC_MUL_EQUAL: + if (tempi2->ic_opcode==EC_IMM && + tempc->sub_type!=IT_DOUBLE && + tempc2->sub_type!=IT_DOUBLE) { + if (i=tempi2->ic_data) { + if (Bsf(i)==Bsr(i)) { + tempi2->ic_data=Bsf(i); + tempi->ic_opcode=EC_SHL_EQUAL; + } + } + } + if (tempc->sub_type==IT_DOUBLE) { + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + } else { + if (tempc2->sub_type==IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_INT; + } + break; + case EC_DIV_EQUAL: + if (tempi2->ic_opcode==EC_IMM && + tempc->sub_type!=IT_DOUBLE && + tempc2->sub_type!=IT_DOUBLE) { + if (i=tempi2->ic_data) { + if (Bsf(i)==Bsr(i)) { + tempi2->ic_data=Bsf(i); + tempi->ic_opcode=EC_SHR_EQUAL; + } + } else + PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + } + if (tempc->sub_type==IT_DOUBLE) { + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + } else { + if (tempc2->sub_type==IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_INT; + } + break; + case EC_MOD_EQUAL: + if (tempi2->ic_opcode==EC_IMM && + tempc->sub_type!=IT_DOUBLE && + tempc2->sub_type!=IT_DOUBLE) { + if (i=tempi2->ic_data) { + if (i>0 && Bsf(i)==Bsr(i)) { + tempi2->ic_data=i-1; + tempi->ic_opcode=EC_AND_EQUAL; + } + } else + PrsExcept(lx,"ST_DIVIDE_BY_ZERO"); + } + if (tempc->sub_type==IT_DOUBLE) { + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + } else { + if (tempc2->sub_type==IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_INT; + } + break; + case EC_ADD_EQUAL: + case EC_SUB_EQUAL: + case EC_ASSIGN: + if (tempc->sub_type==IT_DOUBLE) { + if (tempc2->sub_type!=IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_DOUBLE; + } else { + if (tempc2->sub_type==IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_INT; + } + break; + case EC_SHL_EQUAL: + case EC_SHR_EQUAL: + case EC_AND_EQUAL: + case EC_OR_EQUAL: + case EC_XOR_EQUAL: + if (tempc2->sub_type==IT_DOUBLE) + tempi2->ic_flags|=ICF_R_TO_INT; + break; + case EC_ENTER: + case EC_LEAVE: + tempi->ic_data=-fun_class->size; + break; + case EC_ADD_RSP: + if (temp_lag[1]->ic_opcode==EC_ADD_RSP) { + tempi->ic_data+=temp_lag[1]->ic_data; + tempi->ic_flags|=temp_lag[1]->ic_flags; + temp_lag[1]->ic_opcode=EC_NOP; + temp_lag[1]->ic_flags=0; + } + break; + + case EC_CALL: + case EC_CALL_INDIRECT: + case EC_CALL_INDIRECT2: + case EC_CALL_EXTERN: + case EC_CLI: + case EC_STI: + case EC_WBINVD: + case EC_INVD: + case EC_ENABLE_CACHE: + case EC_DISABLE_CACHE: + case EC_GET_FLAGS: + case EC_GET_BASE_PTR: + case EC_GET_STACK_PTR: + case EC_RETURN_START: + case EC_RETURN_END: + case EC_ABSOLUTE_ADDRESS: + case EC_GET_LABEL: + case EC_TYPE: + case EC_RDTSC: + case EC_SET_FLAGS: + case EC_SET_BASE_PTR: + case EC_SET_STACK_PTR: + case EC_SET_RAX: + case EC_BSF: + case EC_BSR: + case EC_PREEMPT: + case EC_ABSI8: + case EC_REMQUE: + case EC_INPD: + case EC_INPW: + case EC_INP: + case EC_STRLEN: + case EC_BT: + case EC_BTS: + case EC_BTR: + case EC_BTC: + case EC_LBTS: + case EC_LBTR: + case EC_LBTC: + case EC_INSQUE: + case EC_INSQUE_REV: + case EC_OUTPD: + case EC_OUTPW: + case EC_OUTP: + case EC_SWITCH: + case EC_MEMCPY: + case EC_MEMSET: + break; + + case EC_BR_ZERO: + if (combined) + tempi_push=OptBrZero(lx,tempi); + break; + case EC_BR_NOT_ZERO: + if (combined) + tempi_push=OptBrNotZero(lx,tempi); + break; + case EC_BR_NOT_EQUAL: + case EC_BR_EQUAL_EQUAL: + case EC_BR_GREATER_EQUAL: + case EC_BR_LESS_EQUAL: + case EC_BR_GREATER: + case EC_BR_LESS: + case EC_BR_OR_OR_NOT_ZERO: + case EC_BR_OR_OR_ZERO: + case EC_BR_AND_AND_NOT_ZERO: + case EC_BR_AND_AND_ZERO: + case EC_BR_AND_NOT_ZERO: + case EC_BR_AND_ZERO: + case EC_BR_BT: + case EC_BR_BTS: + case EC_BR_BTR: + case EC_BR_BTC: + case EC_BR_NOT_BT: + case EC_BR_NOT_BTS: + case EC_BR_NOT_BTR: + case EC_BR_NOT_BTC: + case EC_BR_LBTS: + case EC_BR_LBTR: + case EC_BR_LBTC: + case EC_BR_NOT_LBTS: + case EC_BR_NOT_LBTR: + case EC_BR_NOT_LBTC: + break; + + case EC_NOP: + if (combined && tempi->ic_flags&ICF_PUSH_RESULT) { + tempii=tempi; + do tempii-=sizeof(IntermediateCode); + while (tempii->ic_opcode==EC_NOP); + tempii->ic_flags|=ICF_PUSH_RESULT; + tempi->ic_flags&=~ICF_PUSH_RESULT; + } + break; + case EC_NOP1: + ps->ptr+=tempi->ic_data<<1; + break; + case EC_LABEL: + tempii=temp_lag[1]; + if (tempii->ic_opcode==EC_JMP) { + if (tempii->ic_data==tempi->ic_data) { + tempii->ic_opcode=EC_NOP; + tempi->ic_flags|=tempii->ic_flags; + } + } else if (tempii->ic_opcode==EC_LABEL) { + tempii=temp_lag[2]; + if (tempii->ic_opcode==EC_JMP) { + if (tempii->ic_data==tempi->ic_data) { + tempii->ic_opcode=EC_NOP; + tempi->ic_flags|=tempii->ic_flags; + } + } + } + break; + case EC_NULL: + case EC_ADDRESS: + case EC_QUESTION: + case EC_RET: + case EC_END_EXP: + case EC_CALL_START: + case EC_CALL_END: + case EC_CALL_END2: + case EC_PUSH_REGS: + case EC_POP_REGS: + case EC_IRQ: + case EC_JMP: + break; + default: + OptMissing(lx,1,tempi); + } + if (cmp_result_cnt[tempi_push->ic_opcode]) { + PrsPush(ps,tempi->original_class); + PrsPush(ps,tempi_push); + } + if (tempi->ic_class) { + if (code!=EC_RETURN_END && code>EC_END_EXP) + last_with_class=tempi; + } + if (combined) + tempi+=sizeof(IntermediateCode); + else + tempi=CbGetIc1(&lx->cb); + } + OptEnd(lx,1,ps); + + /* + This is for determining type conversions + for passing parameters to functions. + */ + return last_with_class; +} + diff --git a/LT/Compiler/OptPass2.CPZ b/LT/Compiler/OptPass2.CPZ new file mode 100644 index 0000000..990d07a --- /dev/null +++ b/LT/Compiler/OptPass2.CPZ @@ -0,0 +1,447 @@ +I8 CmpType(ClassStruct *tempc) +{ + if (tempc) { + while (tempc->return_class) + tempc=tempc->return_class; + return tempc->sub_type; + } + return 0; +} + +I8 CmpPType(ClassStruct *tempc) +{ + if (tempc) { + if (tempc->ptr_cnt) + tempc-=sizeof(ClassStruct); + while (tempc->return_class) + tempc=tempc->return_class; + return tempc->sub_type; + } + return 0; +} + +void CmpOptPass2(LexStruct *lx,ClassStruct *fun_class,I8 *register_offsets) +{ + ClassStruct *tempc,*tempc1,*tempc2,*tempc3; + CbMiscStruct *lb; + IntermediateCode *tempi,*tempi1,*tempi2,*tempi3,*tempii, + *tempil1,*tempil2, + *temp_lag[4],*last_with_class=NULL; + I8 code,i,j,k,l,o[NUM_REGS],c[NUM_REGS],lea_s[NUM_REGS]; + MemberListStruct *tempm,*m[NUM_REGS]; + ParseStack *ps=OptStart(lx,temp_lag); + + for (i=0;imember_list; + while (tempm) { + if (!(tempm->flags & MLF_NO_REG_VARIABLE)) { + k=tempm->use_cnt; + if (tempm->flags & MLF_USE_REG_VARIABLE) + k+=MAX_I8/2; //big but not too big + if (k>c[NUM_REGS-1]) { + for (i=0;ic[i]) { + for (j=NUM_REGS-2;j>=i;j--) { + c[j+1]=c[j]; + o[j+1]=o[j]; + m[j+1]=m[j]; + } + c[i]=k; + o[i]=tempm->offset; + m[i]=tempm; + break; + } + } + } + tempm=tempm->next; + } + } + tempi=lx->cb.cb_in_ptr; + while (code=tempi->ic_opcode) { + OptNext(tempi,temp_lag); + if (code!=EC_NOP) { + tempil1=temp_lag[1]; + tempil2=temp_lag[2]; + tempc=tempi->ic_class; + switch (cmp_param_cnt[code]) { + case 9: + ps->ptr-=tempi->ic_data>>3; + break; + case 3: + tempi3=PrsPop(ps); + if (tempi3->ic_flags&ICF_R_TO_DOUBLE) + tempc3=sys_internal_types[IT_DOUBLE]; + else if (tempi3->ic_flags & ICF_R_TO_INT) + tempc3=sys_internal_types[IT_I8]; + else + tempc3=tempi->p3c; + tempi->p3.type=TY_STK+CmpType(tempc3); + tempi->p3.ptype=CmpPType(tempc3); + tempi->ic_flags|=ICF_P3_WAS_STK; + case 2: + tempi2=PrsPop(ps); + if (tempi2->ic_flags&ICF_R_TO_DOUBLE) + tempc2=sys_internal_types[IT_DOUBLE]; + else if (tempi2->ic_flags & ICF_R_TO_INT) + tempc2=sys_internal_types[IT_I8]; + else + tempc2=tempi->p2c; + tempi->p2.type=TY_STK+CmpType(tempc2); + tempi->p2.ptype=CmpPType(tempc2); + tempi->ic_flags|=ICF_P2_WAS_STK; + case 1: + tempi1=PrsPop(ps); + if (tempi1->ic_flags&ICF_R_TO_DOUBLE) + tempc1=sys_internal_types[IT_DOUBLE]; + else if (tempi1->ic_flags & ICF_R_TO_INT) + tempc1=sys_internal_types[IT_I8]; + else + tempc1=tempi->p1c; + tempi->p1.type=TY_STK+CmpType(tempc1); + tempi->p1.ptype=CmpPType(tempc1); + tempi->ic_flags|=ICF_P1_WAS_STK; + break; + } + if (cmp_result_cnt[code]) { + tempi->r.type=TY_STK+CmpType(tempc); + tempi->r.ptype=CmpPType(tempc); + tempi->ic_flags|=ICF_R_WAS_STK; + PrsPush(ps,tempi); + } + switch (code) { + case EC_IMM: + case EC_DOUBLE: + case EC_STR_CONST: + case EC_FS: + case EC_GS: + case EC_PUSH_CMP: + break; + case EC_RBP: + tempi->ic_opcode=EC_REG; + tempi->p1.reg=CREG_RBP; + break; + case EC_REG: + case EC_COM: + case EC_NOT: + case EC_UNARY_MINUS: + break; + case EC_DEREF: + tempi->p1.ptype=tempi->r.type&IT_MASK; + if (tempi1->ic_opcode==EC_LEA) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi->p1.reg=tempi1->p1.reg; + tempi->p1.disp=tempi1->p1.disp; + tempi->p1.type=TY_DISP+tempi->r.type&IT_MASK; + tempi->p1.ptype=tempi->r.ptype; + tempi->ic_opcode=EC_MOV; + if (tempi->p1.reg==CREG_RBP) + for (i=0;ip1.disp) + lea_s[i]--; + } else if (tempil1->ic_opcode==EC_ADD_CONST) { + if (tempil2->ic_opcode==EC_REG) { + tempi->ic_flags|=tempil2->ic_flags|tempil1->ic_flags; + tempil2->ic_opcode=EC_NOP; + tempil1->ic_opcode=EC_NOP; + tempi->p1.reg=tempil2->p1.reg; + tempi->p1.disp=tempi->ic_data; + tempi->p1.type=TY_DISP+tempi->r.type&IT_MASK; + tempi->p1.ptype=tempi->r.ptype; + tempi->ic_opcode=EC_MOV; + } + } + break; + case EC__PP: + case EC__MM: + case EC_PP_: + case EC_MM_: + if (tempi1->ic_opcode==EC_LEA && + tempi1->p1.type&TY_MASK==TY_DISP && + tempi1->p1.reg==CREG_RBP) + for (i=0;ip1.disp) + lea_s[i]--; + tempi->p1.ptype=tempi->r.type&IT_MASK; + tempi->r.ptype=CmpPType(tempi->p1c); + break; + case EC_POWER: + case EC_SHL: + case EC_SHR: + case EC_MUL: + case EC_DIV: + case EC_MOD: + case EC_AND: + case EC_OR: + case EC_XOR: + break; + case EC_ADD: + if (tempi->ic_class->sub_type==IT_DOUBLE) + break; + if (FixupBinaryOp2(&tempi1,&tempi2)) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + if (tempi->p1t!=tempi2) + tempi->p1c=tempi->p2c; + tempi->ic_data=tempi1->ic_data; + tempi->ic_opcode=EC_ADD_CONST; + tempi->p1.ptype=tempi->r.type&IT_MASK; + tempi->p2.type=TY_NULL; + if (tempil2->ic_opcode==EC_REG && + tempil2->p1.reg==CREG_RBP) { + tempi->ic_flags|=tempil2->ic_flags; + tempil2->ic_opcode=EC_NOP; + tempi->ic_opcode=EC_LEA; + tempi->p1.reg=CREG_RBP; + tempi->p1.type=TY_DISP+tempi->p1.type&IT_MASK; + tempi->p1.disp=tempi->ic_data; + for (i=0;iic_data) + lea_s[i]++; + } + } + break; + case EC_SUB: + if (tempi->ic_class->sub_type==IT_DOUBLE) + break; + if (tempi2->ic_opcode==EC_IMM) { + tempi->ic_flags|=tempi2->ic_flags; + tempi2->ic_opcode=EC_NOP; + tempi->ic_data=tempi2->ic_data; + tempi->ic_opcode=EC_SUB_CONST; + tempi->p2.type=TY_NULL; + } + break; + case EC_EQUAL_EQUAL: + case EC_NOT_EQUAL: + case EC_LESS: + case EC_GREATER: + case EC_LESS_EQUAL: + case EC_GREATER_EQUAL: + case EC_AND_AND: + case EC_OR_OR: + case EC_XOR_XOR: + case EC_COLON: + break; + + case EC_ASSIGN: + case EC_SHL_EQUAL: + case EC_SHR_EQUAL: + case EC_MUL_EQUAL: + case EC_DIV_EQUAL: + case EC_MOD_EQUAL: + case EC_AND_EQUAL: + case EC_OR_EQUAL: + case EC_XOR_EQUAL: + case EC_ADD_EQUAL: + case EC_SUB_EQUAL: + if (tempi1->ic_opcode==EC_LEA && + tempi1->p1.type&TY_MASK==TY_DISP && + tempi1->p1.reg==CREG_RBP) + for (i=0;ip1.disp) + lea_s[i]--; + tempi->p1.ptype=tempi->r.type&IT_MASK; + tempi->r.ptype=CmpPType(tempi->p1c); + break; + case EC_SHL_CONST: + case EC_SHR_CONST: + case EC_ENTER: + case EC_ADD_RSP: + case EC_CALL: + case EC_CALL_INDIRECT: + case EC_CALL_INDIRECT2: + case EC_CALL_EXTERN: + case EC_CLI: + case EC_STI: + case EC_WBINVD: + case EC_INVD: + case EC_ENABLE_CACHE: + case EC_DISABLE_CACHE: + case EC_GET_FLAGS: + case EC_RDTSC: + case EC_SET_FLAGS: + case EC_GET_BASE_PTR: + case EC_SET_BASE_PTR: + case EC_GET_STACK_PTR: + case EC_SET_STACK_PTR: + case EC_SET_RAX: + case EC_RETURN_START: + case EC_RETURN_END: + case EC_ABSOLUTE_ADDRESS: + case EC_TYPE: + case EC_BT: + case EC_BTS: + case EC_BTR: + case EC_BTC: + case EC_LBTS: + case EC_LBTR: + case EC_LBTC: + case EC_BSF: + case EC_BSR: + case EC_PREEMPT: + case EC_ABSI8: + case EC_INSQUE: + case EC_INSQUE_REV: + case EC_REMQUE: + case EC_MEMCPY: + case EC_MEMSET: + case EC_INPD: + case EC_INPW: + case EC_INP: + case EC_STRLEN: + case EC_OUTPD: + case EC_OUTPW: + case EC_OUTP: + case EC_SWITCH: + break; + case EC_BR_ZERO: + case EC_BR_NOT_ZERO: + case EC_BR_NOT_EQUAL: + case EC_BR_EQUAL_EQUAL: + case EC_BR_GREATER_EQUAL: + case EC_BR_LESS_EQUAL: + case EC_BR_GREATER: + case EC_BR_LESS: + case EC_BR_AND_NOT_ZERO: + case EC_BR_AND_ZERO: + if (tempi->ic_flags&ICF_POP_CMP && + !(tempi->ic_flags&ICF_USE_DOUBLE) && + tempi2->ic_opcode==EC_IMM) { + tempi->ic_flags=(tempi->ic_flags&~ICF_POP_CMP)|ICF_RCX_CMP2; + temp_lag[3]->ic_flags=(temp_lag[3]->ic_flags&~ICF_PUSH_CMP)|ICF_RCX_CMP; + } //fall through + case EC_GET_LABEL: + case EC_BR_BT: + case EC_BR_BTS: + case EC_BR_BTR: + case EC_BR_BTC: + case EC_BR_NOT_BT: + case EC_BR_NOT_BTS: + case EC_BR_NOT_BTR: + case EC_BR_NOT_BTC: + case EC_BR_LBTS: + case EC_BR_LBTR: + case EC_BR_LBTC: + case EC_BR_NOT_LBTS: + case EC_BR_NOT_LBTR: + case EC_BR_NOT_LBTC: + lb=tempi->ic_data; + if (!(tempi->ic_flags&ICF_PUSH_CMP)) + while (lb->forward) + lb=lb->forward; + lb->flags|=CBMF_USED; + break; + case EC_LEAVE: + case EC_RET: + if (fun_class && (tempii=last_with_class)) { + if (fun_class->return_class->sub_type==IT_DOUBLE && + tempii->ic_class->sub_type!=IT_DOUBLE) + tempii->ic_flags|=ICF_R_TO_DOUBLE; + if (fun_class->return_class->sub_type!=IT_DOUBLE && + tempii->ic_class->sub_type==IT_DOUBLE) + tempii->ic_flags|=ICF_R_TO_INT; + } + break; + + case EC_JMP: + if (tempil1->ic_opcode==EC_LABEL) { + lb=tempil1->ic_data; + lb->forward=tempi->ic_data; + if (tempil2->ic_opcode==EC_LABEL) { + lb=tempil2->ic_data; + lb->forward=tempi->ic_data; + if (temp_lag[3]->ic_opcode==EC_LABEL) { + lb=temp_lag[3]->ic_data; + lb->forward=tempi->ic_data; + } + } + } + lb=tempi->ic_data; + while (lb->forward) + lb=lb->forward; + lb->flags|=CBMF_USED; + break; + case EC_NOP: + case EC_NULL: + case EC_LABEL: + case EC_ADDRESS: + case EC_QUESTION: + case EC_IRQ: + case EC_END_EXP: + case EC_CALL_END: + case EC_CALL_END2: + case EC_CALL_START: + case EC_PUSH_REGS: + case EC_POP_REGS: + break; + case EC_NOP1: + ps->ptr+=tempi->ic_data; + break; + + default: + OptMissing(lx,2,tempi); + } + if (tempi->ic_class) { + if (code!=EC_RETURN_END) + last_with_class=tempi; + } + } + tempi+=sizeof(IntermediateCode); + } + + for (i=0;iused_reg_mask&=~(CREG_VARS_MASK|CREG_NON_PTR_MASK); + if (fun_class && !Bt(&lx->flags,LFf_NO_REG_VAR) && + !(lx->flags & LF_NO_REG_OPT)) { + j=0; + for (i=0;i0) { + l=0; + for (i=0;imember_class; + while (tempc->return_class) + tempc=tempc->return_class; + if (!tempc->ptr_cnt && !tempm->cnt) { + tempm->register=to_non_ptr_vars_map[l++]; + register_offsets[tempm->register]=o[i]; + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) { + PrintF("Function:%s\r\n",fun_class->str); + PrintF("Reg %Z Var \"%s\" %08X[RBP]\r\n",tempm->register,"ST_U8_REGS", + tempm->str,register_offsets[tempm->register]); + } + o[i]=MAX_I8; + Bts(&fun_class->used_reg_mask,tempm->register); + } + } + l=0; + for (i=0;iregister=to_reg_vars_map[l++]; + register_offsets[tempm->register]=o[i]; + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) + PrintF("Reg %Z Var \"%s\" %08X[RBP]\r\n",tempm->register,"ST_U8_REGS", + tempm->str,tempm->register); + Bts(&fun_class->used_reg_mask,tempm->register); + } + } + } + } + OptEnd(lx,2,ps); +} + diff --git a/LT/Compiler/OptPass3.CPZ b/LT/Compiler/OptPass3.CPZ new file mode 100644 index 0000000..00c705f --- /dev/null +++ b/LT/Compiler/OptPass3.CPZ @@ -0,0 +1,574 @@ +BoolU8 CmpOptIc3(LexStruct *lx,IntermediateCode *tempi,BoolU4 inside_return) +{ + I8 i,t,pt,t1,pt1; + IntermediateCode *tempil1,*tempil2; + + if (tempi->ic_opcoder.type&TY_MASK==TY_STK && + !(tempil2->ic_flags&ICF_PUSH_RESULT)) { + if (tempil1->ic_opcode==EC_ADD_CONST && + tempil1->p1.type&TY_MASK==TY_STK) { + if ((tempil2->ic_opcode==EC_REG || + tempil2->ic_opcode==EC_MOV) && + tempil2->p1.type&TY_MASK==TY_REG) { + i=tempil1->ic_data; + if (i>=MIN_I4 && i<=MAX_I4 && + !Bt(&non_ptr_vars_mask,tempil2->p1.reg)) { + tempil1->ic_flags|=tempil2->ic_flags&ICF_NO_CVT_MASK; + tempil2->ic_opcode=EC_NOP; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + tempil1->ic_opcode=EC_LEA; + tempil1->p1.type=TY_DISP+tempil1->p1.type&IT_MASK; + tempil1->p1.reg=tempil2->p1.reg; + tempil1->p1.disp=i; + return TRUE; + } + } + } + if (tempil2->ic_opcode==EC_MOV || + tempil2->ic_opcode==EC_REG) { + if (!inside_return) { + if (tempil1->p3.type&TY_MASK==TY_STK) { + if (tempil2->ic_flags & ICF_R_TO_INT) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp=tempil2->p1.disp><(double); + else + tempil1->ic_flags|=ICF_P3_TO_INT; + } else if (tempil2->ic_flags&ICF_R_TO_DOUBLE) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp><(double)=tempil2->p1.disp; + else + tempil1->ic_flags|=ICF_P3_TO_DOUBLE; + } + + t=tempil1->p3.type&IT_MASK; + t1=tempil2->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p3.type=tempil2->p1.type&TY_MASK+t; + + pt=tempil1->p3.ptype; + pt1=tempil2->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p3.ptype=pt; + + tempil1->p3.reg=tempil2->p1.reg; + tempil1->p3.disp=tempil2->p1.disp; + tempil1->ic_flags|=tempil2->ic_flags&ICF_NO_CVT_MASK; + tempil2->ic_opcode=EC_NOP1; + tempil2->ic_data=1; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + return TRUE; + } + if (tempil1->p2.type&TY_MASK==TY_STK) { + if (tempil2->ic_flags & ICF_R_TO_INT) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp=tempil2->p1.disp><(double); + else + tempil1->ic_flags|=ICF_P2_TO_INT; + } else if (tempil2->ic_flags&ICF_R_TO_DOUBLE) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp><(double)=tempil2->p1.disp; + else + tempil1->ic_flags|=ICF_P2_TO_DOUBLE; + } + + t=tempil1->p2.type&IT_MASK; + t1=tempil2->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p2.type=tempil2->p1.type&TY_MASK+t; + + pt=tempil1->p2.ptype; + pt1=tempil2->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p2.ptype=pt; + + tempil1->p2.reg=tempil2->p1.reg; + tempil1->p2.disp=tempil2->p1.disp; + tempil1->ic_flags|=tempil2->ic_flags&ICF_NO_CVT_MASK; + tempil2->ic_opcode=EC_NOP1; + tempil2->ic_data=1; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + return TRUE; + } + if (tempil1->p1.type&TY_MASK==TY_STK) { + if (tempil2->ic_flags & ICF_R_TO_INT) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp=tempil2->p1.disp><(double); + else + tempil1->ic_flags|=ICF_P1_TO_INT; + } else if (tempil2->ic_flags&ICF_R_TO_DOUBLE) { + if (tempil2->p1.type&TY_MASK==TY_IMM) + tempil2->p1.disp><(double)=tempil2->p1.disp; //dbgo signed/unsigned + else if (!(tempil1->ic_flags&ICF_USE_INT)) + tempil1->ic_flags|=ICF_P1_TO_DOUBLE; + } + + t=tempil1->p1.type&IT_MASK; + t1=tempil2->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p1.type=tempil2->p1.type&TY_MASK+t; + + pt=tempil1->p1.ptype; + pt1=tempil2->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p1.ptype=pt; + + tempil1->p1.reg=tempil2->p1.reg; + tempil1->p1.disp=tempil2->p1.disp; + tempil1->ic_flags|=tempil2->ic_flags&ICF_NO_CVT_MASK; + tempil2->ic_opcode=EC_NOP1; + tempil2->ic_data=1; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + return TRUE; + } + } + } + if (tempil1->ic_opcode==EC_DEREF) { + if (tempil2->ic_opcode==EC_ADD_CONST && + tempil2->p1.type&TY_MASK==TY_REG && + tempil1->p1.type&TY_MASK==TY_STK) { + i=tempil2->ic_data; + if (i>=MIN_I4 && i<=MAX_I4 && + !Bt(&non_ptr_vars_mask,tempil2->p1.reg)) { + tempil1->ic_flags|=tempil2->ic_flags; + tempil2->ic_opcode=EC_NOP1; + tempil2->ic_data=1; + tempil2->ic_data=-1; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + tempil1->ic_opcode=EC_MOV; + tempil1->p1.type=TY_DISP+tempil1->p1.ptype; + tempil1->p1.reg=tempil2->p1.reg; + tempil1->p1.disp=i; + return TRUE; + } + } + if (tempil2->ic_opcode==EC_LEA && + tempil1->p1.type&TY_MASK==TY_STK) { + tempil1->ic_flags|=tempil2->ic_flags; + tempil2->ic_opcode=EC_NOP; + tempil1->ic_opcode=EC_MOV; + tempil1->p1.type=tempil2->p1.type&TY_MASK+tempil1->p1.ptype; + tempil1->p1.reg=tempil2->p1.reg; + tempil1->p1.disp=tempil2->p1.disp; + return TRUE; + } + } + } + if (tempil1->ic_opcode==EC_DEREF) { + if (tempil1->p1.type&TY_MASK==TY_REG) { + tempil1->p1.type=TY_DISP+tempil1->p1.ptype; + tempil1->p1.disp=0; + tempil1->ic_opcode=EC_MOV; + return TRUE; + } + } + return FALSE; +} + +void CmpOptPass3(LexStruct *lx,I8 *register_offsets,U8 *type_) +{ + ClassStruct *tempc,*tempc1,*tempc2,*tempc3; + IntermediateCode *tempi,*tempi1,*tempi2,*tempi3,*tempil1,*tempil2,*tempil3, + *temp_lag[4]; + I8 code,i,type=IT_I8; + ParseStack *ps=OptStart(lx,temp_lag); + BoolU4 inside_return=FALSE,dead_code=FALSE; + CbMiscStruct *lb; + + tempi=lx->cb.cb_in_ptr; + while (code=tempi->ic_opcode) { + OptNext2(tempi,temp_lag); + if (dead_code&&code!=EC_LABEL) + tempi->ic_opcode=EC_NOP; + else { + tempc=tempi->ic_class; + + tempi3=&opt_nop; + tempi2=&opt_nop; + tempi1=&opt_nop; + + tempil1=temp_lag[1]; + tempil2=temp_lag[2]; + tempil3=temp_lag[3]; + switch (cmp_param_cnt[code]) { + case 9: + ps->ptr-=tempi->ic_data>>3; + break; + case 3: + tempi3=PrsPop(ps); + tempc3=tempi3->ic_class; + case 2: + tempi2=PrsPop(ps); + tempc2=tempi2->ic_class; + case 1: + tempi1=PrsPop(ps); + tempc1=tempi1->ic_class; + break; + } + switch (code) { + case EC_IMM: + case EC_TYPE: + tempi->p1.type=TY_IMM+IT_I8; + tempi->p1.disp=tempi->ic_data; + tempi->ic_opcode=EC_MOV; + break; + case EC_DOUBLE: + tempi->p1.type=TY_IMM+IT_I8; + tempi->p1.disp=tempi->ic_data; + tempi->p1.ptype=IT_DOUBLE; + tempi->ic_opcode=EC_MOV; + break; + case EC_STR_CONST: + case EC_FS: + case EC_GS: + case EC_RBP: + case EC_REG: + case EC_COM: + case EC_NOT: + case EC_UNARY_MINUS: + case EC_PUSH_CMP: + break; + case EC_MOV: + if (tempi->p1.type&TY_MASK==TY_DISP && + tempi->p1.reg==CREG_RBP) { + i=CmpOffsetToReg(tempi->p1.disp,register_offsets); + if (i>=0) { + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + tempi->p1.reg=i; + } + } + break; + case EC_DEREF: + if (tempi1->ic_opcode==EC_LEA) { + if (tempi1->p1.type&TY_MASK==TY_DISP && + tempi1->p1.reg==CREG_RBP) { + i=CmpOffsetToReg(tempi1->p1.disp,register_offsets); + if (i>=0) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi->ic_opcode=EC_REG; + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + tempi->p1.reg=i; + } + } + } else if ((tempi1->ic_opcode==EC_ABSOLUTE_ADDRESS || + (tempi1->ic_opcode==EC_MOV && + tempi1->p1.type==TY_IMM+IT_I8 && + tempi1->p1.disp>=0 && tempi1->p2.disp<0x80000000)) && + !(lx->flags & LF_ASM_EXPRESSIONS)) { + if (tempi1->ic_opcode==EC_ABSOLUTE_ADDRESS) + tempi->p1.disp=tempi1->ic_data; + else + tempi->p1.disp=tempi1->p1.disp; + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + tempi->ic_opcode=EC_MOV; + tempi->p1.type=TY_RIP_DISP32+tempi->p1.ptype; + tempi->p1.reg=CREG_RIP; + } + break; + case EC__PP: + case EC__MM: + case EC_PP_: + case EC_MM_: + if (tempi1->ic_opcode==EC_LEA) { + if (tempi1->p1.type&TY_MASK==TY_DISP && + tempi1->p1.reg==CREG_RBP) { + i=CmpOffsetToReg(tempi1->p1.disp,register_offsets); + if (i>=0) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->r.type=TY_NULL; + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + tempi->p1.reg=i; + tempi->ic_flags|=ICF_NOT_ADDRESS; + } + } + } else if ((tempi1->ic_opcode==EC_ABSOLUTE_ADDRESS || + (tempi1->ic_opcode==EC_MOV && + tempi1->p1.type==TY_IMM+IT_I8 && + tempi1->p1.disp>=0 && tempi1->p2.disp<0x80000000)) && + !(lx->flags & LF_ASM_EXPRESSIONS)) { + tempi->ic_flags|=tempi1->ic_flags; + if (tempi1->ic_opcode==EC_ABSOLUTE_ADDRESS) + tempi->p1.disp=tempi1->ic_data; + else + tempi->p1.disp=tempi1->p1.disp; + tempi1->ic_opcode=EC_NOP; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + tempi->p1.type=TY_RIP_DISP32+tempi->p1.ptype; + tempi->p1.reg=CREG_RIP; + tempi->ic_flags|=ICF_NOT_ADDRESS; + } + break; + case EC_LEA: + case EC_SHL_CONST: + case EC_SHR_CONST: + case EC_POWER: + case EC_SHL: + case EC_SHR: + case EC_MUL: + case EC_DIV: + case EC_MOD: + case EC_AND: + case EC_OR: + case EC_XOR: + case EC_ADD: + case EC_SUB: + case EC_EQUAL_EQUAL: + case EC_NOT_EQUAL: + case EC_LESS: + case EC_GREATER: + case EC_LESS_EQUAL: + case EC_GREATER_EQUAL: + case EC_AND_AND: + case EC_OR_OR: + case EC_XOR_XOR: + case EC_COLON: + break; + case EC_ASSIGN: + case EC_SHL_EQUAL: + case EC_SHR_EQUAL: + case EC_MUL_EQUAL: + case EC_DIV_EQUAL: + case EC_MOD_EQUAL: + case EC_AND_EQUAL: + case EC_OR_EQUAL: + case EC_XOR_EQUAL: + case EC_ADD_EQUAL: + case EC_SUB_EQUAL: + if (tempi1->ic_opcode==EC_LEA) { + if (tempi1->p1.type&TY_MASK==TY_DISP) { + if (tempi1->p1.reg==CREG_RBP) { + i=CmpOffsetToReg(tempi1->p1.disp,register_offsets); + if (i>=0) { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->p1.type=TY_NULL; + tempi1->r.type=TY_NULL; + tempi->p1.reg=i; + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + } else { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->r.type=TY_NULL; + tempi1->p1.type=TY_NULL; + tempi->p1.disp=tempi1->p1.disp; + tempi->p1.reg=CREG_RBP; + tempi->p1.type=TY_DISP+tempi->p1.type&IT_MASK; + } + } else { + tempi->ic_flags|=tempi1->ic_flags; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->r.type=TY_NULL; + tempi1->p1.type=TY_NULL; + tempi->p1.disp=tempi1->p1.disp; + tempi->p1.reg=tempi1->p1.reg; + tempi->p1.type=TY_DISP+tempi->p1.type&IT_MASK; + } + tempi->ic_flags|=ICF_NOT_ADDRESS; + } + } else if ((tempi1->ic_opcode==EC_ABSOLUTE_ADDRESS || + (tempi1->ic_opcode==EC_MOV && + tempi1->p1.type==TY_IMM+IT_I8 && + tempi1->p1.disp>=0 && tempi1->p2.disp<0x80000000)) && + !(lx->flags & LF_ASM_EXPRESSIONS)) { + tempi->ic_flags|=tempi1->ic_flags; + tempi->p1.disp=tempi1->ic_data; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + tempi1->r.type=TY_NULL; + tempi->p1.type=TY_RIP_DISP32+tempi->p1.type&IT_MASK; + tempi->p1.reg=CREG_RIP; + tempi->ic_flags|=ICF_NOT_ADDRESS; + } + break; + case EC_ADD_CONST: + case EC_SUB_CONST: + case EC_ENTER: + case EC_ADD_RSP: + case EC_CALL: + case EC_CALL_INDIRECT: + case EC_CALL_INDIRECT2: + case EC_CALL_EXTERN: + case EC_CLI: + case EC_STI: + case EC_WBINVD: + case EC_INVD: + case EC_ENABLE_CACHE: + case EC_DISABLE_CACHE: + case EC_GET_FLAGS: + case EC_RDTSC: + case EC_SET_FLAGS: + case EC_GET_BASE_PTR: + case EC_SET_BASE_PTR: + case EC_GET_STACK_PTR: + case EC_SET_STACK_PTR: + case EC_SET_RAX: + break; + case EC_RETURN_START: + inside_return=TRUE; + break; + case EC_RETURN_END: + inside_return=FALSE; + break; + case EC_GET_LABEL: + case EC_ABSOLUTE_ADDRESS: + case EC_BT: + case EC_BTS: + case EC_BTR: + case EC_BTC: + case EC_LBTS: + case EC_LBTR: + case EC_LBTC: + case EC_BSF: + case EC_BSR: + case EC_PREEMPT: + case EC_ABSI8: + case EC_INSQUE: + case EC_INSQUE_REV: + case EC_REMQUE: + case EC_MEMCPY: + case EC_MEMSET: + case EC_INPD: + case EC_INPW: + case EC_INP: + case EC_STRLEN: + case EC_OUTPD: + case EC_OUTPW: + case EC_OUTP: + case EC_SWITCH: + case EC_RET: + case EC_NULL: + case EC_ADDRESS: + case EC_QUESTION: + case EC_IRQ: + case EC_NOP: + case EC_CALL_START: + case EC_LEAVE: + case EC_PUSH_REGS: + case EC_POP_REGS: + case EC_BR_BT: + case EC_BR_BTS: + case EC_BR_BTR: + case EC_BR_BTC: + case EC_BR_NOT_BT: + case EC_BR_NOT_BTS: + case EC_BR_NOT_BTR: + case EC_BR_NOT_BTC: + case EC_BR_LBTS: + case EC_BR_LBTR: + case EC_BR_LBTC: + case EC_BR_NOT_LBTS: + case EC_BR_NOT_LBTR: + case EC_BR_NOT_LBTC: + break; + case EC_BR_ZERO: + case EC_BR_NOT_ZERO: + case EC_BR_NOT_EQUAL: + case EC_BR_EQUAL_EQUAL: + case EC_BR_GREATER_EQUAL: + case EC_BR_LESS_EQUAL: + case EC_BR_GREATER: + case EC_BR_LESS: + case EC_BR_AND_NOT_ZERO: + case EC_BR_AND_ZERO: + lb=tempi->ic_data; + if (tempi->ic_flags&ICF_PUSH_CMP) { + lb->flags|=CBMF_POP_CMP; + lb->forward=NULL; + } + break; + case EC_LABEL: + lb=tempi->ic_data; + if (lb->flags&CBMF_USED) + dead_code=FALSE; + break; + case EC_JMP: + dead_code=TRUE; + break; + case EC_NOP1: + ps->ptr+=tempi->ic_data; + break; + case EC_CALL_END2: + break; + case EC_CALL_END: + case EC_END_EXP: + if (tempi->p1.type&TY_MASK==TY_STK) { + if (tempil1->r.type&TY_MASK==TY_STK && + !(tempil1->ic_flags&ICF_PUSH_RESULT)) { + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + tempi->p1.reg=CREG_RAX; + tempil1->r.type=TY_REG+tempil1->r.type&IT_MASK; + tempil1->r.reg=CREG_RAX; + } + } + break; + default: + OptMissing(lx,3,tempi); + } + + while (CmpOptIc3(lx,tempi,inside_return)); + if (inside_return) { + if (tempc=tempi->ic_class) { + if (tempi->ic_flags & ICF_R_TO_DOUBLE) + type=IT_DOUBLE; + else if (tempi->ic_flags & ICF_R_TO_INT) + type=IT_I8; + else + type=tempc->sub_type; + } + } + code=tempi->ic_opcode; + if (cmp_result_cnt[code]) + PrsPush(ps,tempi); + } + tempi+=sizeof(IntermediateCode); + } + if (type_) + *type_=type; + + OptEnd(lx,3,ps); +} diff --git a/LT/Compiler/OptPass4.CPZ b/LT/Compiler/OptPass4.CPZ new file mode 100644 index 0000000..e1a103b --- /dev/null +++ b/LT/Compiler/OptPass4.CPZ @@ -0,0 +1,182 @@ +void CmpOptPass4(LexStruct *lx) +{ + IntermediateCode *tempi,*tempi1, + *temp_lag[4]; + I8 code,i,t,pt,t1,pt1; + ParseStack *ps=OptStart(lx,temp_lag); + BoolU4 inside_return=FALSE; + + tempi=lx->cb.cb_in_ptr; + while (code=tempi->ic_opcode) { + OptNext2(tempi,temp_lag); + if (code>EC_END_EXP && code!=EC_NOP1) { + + if (tempi->ic_flags&ICF_TRACE) { + if (Bt(&lx->pass_trace_mask,4)) { + PrintF("%2d:",ps->ptr); + CbPutIc(tempi); + } + } + + if (cmp_param_cnt[code]==9) + ps->ptr-=tempi->ic_data>>3; + if (code==EC_PUSH_REGS) { + for (i=0;iic_data,i)) + ps->ptr++; + } else if (code==EC_POP_REGS) { + for (i=0;iic_data,i)) + ps->ptr--; + } + + if (tempi->p3.type&TY_MASK==TY_STK) { + tempi1=PrsPop(ps); + if (!inside_return) { + if (tempi1->ic_opcode==EC_MOV || + tempi1->ic_opcode==EC_REG) { + if (tempi1->ic_flags & ICF_R_TO_INT) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp=tempi1->p1.disp><(double); + else + tempi->ic_flags|=ICF_P3_TO_INT; + } else if (tempi1->ic_flags&ICF_R_TO_DOUBLE) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp><(double)=tempi1->p1.disp; + else + tempi->ic_flags|=ICF_P3_TO_DOUBLE; + } + + t=tempi->p3.type&IT_MASK; + t1=tempi1->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p3.type=tempi1->p1.type&TY_MASK+t; + + pt=tempi->p3.ptype; + pt1=tempi1->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p3.ptype=pt; + + tempi->p3.reg=tempi1->p1.reg; + tempi->p3.disp=tempi1->p1.disp; + tempi->ic_flags|=tempi1->ic_flags&ICF_NO_CVT_MASK; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + } + } + } + + if (tempi->p2.type&TY_MASK==TY_STK) { + tempi1=PrsPop(ps); + if (!inside_return) { + if (tempi1->ic_opcode==EC_MOV || + tempi1->ic_opcode==EC_REG) { + if (tempi1->ic_flags & ICF_R_TO_INT) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp=tempi1->p1.disp><(double); + else + tempi->ic_flags|=ICF_P2_TO_INT; + } else if (tempi1->ic_flags&ICF_R_TO_DOUBLE) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp><(double)=tempi1->p1.disp; + else + tempi->ic_flags|=ICF_P2_TO_DOUBLE; + } + + t=tempi->p2.type&IT_MASK; + t1=tempi1->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p2.type=tempi1->p1.type&TY_MASK+t; + + pt=tempi->p2.ptype; + pt1=tempi1->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p2.ptype=pt; + + tempi->p2.reg=tempi1->p1.reg; + tempi->p2.disp=tempi1->p1.disp; + tempi->ic_flags|=tempi1->ic_flags&ICF_NO_CVT_MASK; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + } + } + } + + if (tempi->p1.type&TY_MASK==TY_STK) { + tempi1=PrsPop(ps); + if (!inside_return) { + if (tempi1->ic_opcode==EC_MOV || + tempi1->ic_opcode==EC_REG) { + if (tempi1->ic_flags & ICF_R_TO_INT) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp=tempi1->p1.disp><(double); + else + tempi->ic_flags|=ICF_P1_TO_INT; + } else if (tempi1->ic_flags&ICF_R_TO_DOUBLE) { + if (tempi1->p1.type&TY_MASK==TY_IMM) + tempi1->p1.disp><(double)=tempi1->p1.disp; //dbgo signed/unsigned + else if (!(tempi->ic_flags&ICF_USE_INT)) + tempi->ic_flags|=ICF_P1_TO_DOUBLE; + } + + t=tempi->p1.type&IT_MASK; + t1=tempi1->p1.type&IT_MASK; + if (t1 && t1r.type&IT_MASK; + if (t1 && t1p1.type=tempi1->p1.type&TY_MASK+t; + + pt=tempi->p1.ptype; + pt1=tempi1->p1.ptype; + if (pt1 && pt1r.ptype; + if (pt1 && pt1p1.ptype=pt; + + tempi->p1.reg=tempi1->p1.reg; + tempi->p1.disp=tempi1->p1.disp; + tempi->ic_flags|=tempi1->ic_flags&ICF_NO_CVT_MASK; + tempi1->ic_opcode=EC_NOP1; + tempi1->ic_data=1; + tempi1->p1.type=TY_NULL+tempi1->p1.type&IT_MASK; + tempi1->r.type=TY_NULL+tempi1->r.type&IT_MASK; + } + } + } + + if (code==EC_RETURN_START) + inside_return=TRUE; + else if (code==EC_RETURN_END) + inside_return=FALSE; + + if (tempi->r.type&TY_MASK==TY_STK) + PrsPush(ps,tempi); + } + tempi+=sizeof(IntermediateCode); + } + OptEnd(lx,4,ps); +} diff --git a/LT/Compiler/OptPass5.CPZ b/LT/Compiler/OptPass5.CPZ new file mode 100644 index 0000000..c659114 --- /dev/null +++ b/LT/Compiler/OptPass5.CPZ @@ -0,0 +1,267 @@ +BoolU8 CmpOptIc5(LexStruct *lx,IntermediateCode *tempi,BoolU4 inside_return) +{ + I8 i; + IntermediateCode *tempil1,*tempil2; + + nounusedwarn inside_return; + + if (tempi->ic_opcodeic_opcode==EC_ADD_CONST) { + if (tempil1->ic_opcode==EC_DEREF) { + if (tempil1->ic_flags&ICF_P1_WAS_STK) { + if (tempil1->p1.type&TY_MASK==TY_REG && + tempil2->p1.type&TY_MASK==TY_REG && + tempil2->r.type&TY_MASK==TY_REG && + tempil2->r.reg==tempil1->p1.reg) { + i=tempil2->ic_data; + if (i>=MIN_I4 && i<=MAX_I4 && + !Bt(&non_ptr_vars_mask,tempil2->p1.reg)) { + tempil1->ic_flags=(tempil1->ic_flags & ~ICF_P1_WAS_STK)| + tempil2->ic_flags; + tempil2->ic_opcode=EC_NOP1; + tempil2->ic_data=1; + tempil2->ic_data=-1; + tempil2->p1.type=TY_NULL+tempil2->p1.type&IT_MASK; + tempil2->r.type=TY_NULL+tempil2->r.type&IT_MASK; + tempil1->ic_opcode=EC_MOV; + tempil1->p1.type=TY_DISP+tempil1->p1.ptype; + tempil1->p1.reg=tempil2->p1.reg; + tempil1->p1.disp=i; + return TRUE; + } + } + } + } + } + return FALSE; +} + +void CmpOptPass5Lag(LexStruct *lx, + ParseStack *ps,IntermediateCode *tempi,I8 *i_,I8 num_stk,BoolU4 *inside_return, + U8 *trashed_reg_mask_,U8 fun_num) +{ + I8 i=*i_; + I8 j,k,l,code; + U8 trashed_reg_mask=*trashed_reg_mask_; + ClassStruct *tempc; + code=tempi->ic_opcode; + if (code<=EC_END_EXP || code==EC_NOP1) + return; + else { + if (tempi->ic_flags&ICF_TRACE) { + if (Bt(&lx->pass_trace_mask,5)) { + PrintF("%2d:",i); + CbPutIc(tempi); + } + } + if (code==EC_CALL_START) { + if (iic_data) { + if (Bt(&tempc->flags,Cf_INTERNAL)) + j=0; + else { + j&=tempc->trashed_reg_mask; + trashed_reg_mask|=tempc->trashed_reg_mask; + } + } + tempi->ic_data=j; + PrsPush(ps,i); + PrsPush(ps,j); + } else if (code==EC_CALL_END) { + tempi->ic_data=PrsPop(ps); + i=PrsPop(ps); + } +// else if (code==EC_LEAVE) +// i=0; + else if (code==EC_CALL_END2) { + ps->ptr--; + i=PrsPop(ps); + } else if (code==EC_RETURN_START) + *inside_return=TRUE; + else if (code==EC_RETURN_END) + *inside_return=FALSE; + if (cmp_param_cnt[code]==9) + i-=tempi->ic_data>>3; + if (tempi->p3.type&TY_MASK==TY_STK) { + i--; + if (ip3.type=tempi->p3.type&IT_MASK+TY_REG; + if (fun_num&1) + tempi->p3.reg=to_stk_temps_map_odd[i]; + else + tempi->p3.reg=to_stk_temps_map_even[i]; + } + } + + if (tempi->p2.type&TY_MASK==TY_STK) { + i--; + if (ip2.type=tempi->p2.type&IT_MASK+TY_REG; + if (fun_num&1) + tempi->p2.reg=to_stk_temps_map_odd[i]; + else + tempi->p2.reg=to_stk_temps_map_even[i]; + } + } + if (tempi->p1.type&TY_MASK==TY_STK) { + i--; + if (ip1.type=TY_REG+tempi->p1.type&IT_MASK; + if (fun_num&1) + tempi->p1.reg=to_stk_temps_map_odd[i]; + else + tempi->p1.reg=to_stk_temps_map_even[i]; + } + } + if (tempi->r.type&TY_MASK==TY_STK && + !(tempi->ic_flags & ICF_PUSH_RESULT)) { + i++; + if (i<=num_stk) { + tempi->r.type=TY_REG+tempi->r.type&IT_MASK; + if (fun_num&1) { + tempi->r.reg=to_stk_temps_map_odd[i-1]; + Bts(&trashed_reg_mask,to_stk_temps_map_odd[i-1]); + } else { + tempi->r.reg=to_stk_temps_map_even[i-1]; + Bts(&trashed_reg_mask,to_stk_temps_map_even[i-1]); + } + } + } + while (CmpOptIc5(lx,tempi,*inside_return)); + if (tempi->r.type&IT_MASK!=IT_DOUBLE && + !(tempi->ic_flags&ICF_USE_DOUBLE)) + tempi->ic_flags|=ICF_USE_INT; + } + *i_=i; + *trashed_reg_mask_=trashed_reg_mask; +} + +void CmpOptPass5(LexStruct *lx,ClassStruct *fun_class) +{ + IntermediateCode *tempi,*tempil1,*tempif1,*tempif2, + *temp_lag[4],*old_tempil1=NULL; + BoolU4 inside_return; + ParseStack *ps=OptStart(lx,temp_lag); + I8 code; + I8 i=0,num_stk,trashed_reg_mask=CALWAYS_TRASHED_MASK; + U8 fun_num=0; + + if (fun_class) + fun_num=compiled_functions++; + + if (Bt(&lx->flags,LFf_NO_REG_VAR) || + lx->flags&LF_NO_REG_OPT) + num_stk=0; + else + num_stk=num_stk_temps; + + tempi=lx->cb.cb_in_ptr; + while (code=tempi->ic_opcode) { + OptNext3(tempi,temp_lag); + tempil1=temp_lag[1]; + if (tempil1->ic_opcode==EC_END_EXP) { + if (code!=EC_RETURN_END && code!=EC_NOP) { + if (!(temp_lag[2]->ic_flags& + (ICF_R_TO_DOUBLE|ICF_R_TO_INT|ICF_PUSH_RESULT|ICF_DEPEND_RESULT))) { + temp_lag[2]->ic_flags|=ICF_NO_DEPEND_RESULT; + temp_lag[2]->r.type=TY_NULL+temp_lag[2]->r.type&IT_MASK; + tempil1->ic_flags|=ICF_NO_DEPEND_RESULT; + tempil1->r.type=TY_NULL+tempil1->r.type&IT_MASK; + } + } + } + if (code<=EC_END_EXP || code==EC_NOP1) { + } else { + if (tempi->p3.type&TY_MASK) { + if (tempi->p3.type&TY_MASK==TY_STK) { + if (tempil1->r.type&TY_MASK==TY_STK && + !(tempil1->ic_flags&ICF_PUSH_RESULT)) { + tempi->p3.type=TY_REG+tempi->p3.type&IT_MASK; + tempi->p3.reg=CREG_RAX; + tempil1->r.type=TY_REG+tempil1->r.type&IT_MASK; + tempil1->r.reg=CREG_RAX; + } + } + } else { + if (tempi->p2.type&TY_MASK==TY_STK) { + if (tempil1->r.type&TY_MASK==TY_STK && + !(tempil1->ic_flags&ICF_PUSH_RESULT)) { + tempif2=NULL; + if (tempi->ic_opcode==EC_ASSIGN && + tempi->ic_flags&ICF_NOT_ADDRESS && + tempil1->ic_opcode!=EC_CALL_END && + tempil1->ic_opcode!=EC_CALL_END2 && + tempil1->ic_opcode!=EC_SET_RAX && + !(tempi->ic_flags& + (ICF_P2_TO_DOUBLE|ICF_P2_TO_INT)) && + !(tempil1->ic_flags& + (ICF_R_TO_DOUBLE|ICF_R_TO_INT))) { + if (tempif1=OptLead1(lx,tempi)) //predict NO_DEPEND + if (tempif2=OptLead1(lx,tempif1)) + if (tempif1->ic_opcode==EC_END_EXP && + tempif2->ic_opcode!=EC_RETURN_END) { + tempi->ic_opcode=EC_NOP; + tempil1->r.type =tempi->p1.type&TY_MASK+tempi->p1.ptype; + tempil1->r.ptype=tempi->p1.ptype; + tempil1->r.reg =tempi->p1.reg; + tempil1->r.disp =tempi->p1.disp; + tempil1->ic_flags=tempil1->ic_flags&~(ICF_NO_DEPEND_RESULT|ICF_R_WAS_STK)| + tempi->ic_flags&~(ICF_NOT_ADDRESS|ICF_P1_WAS_STK|ICF_P2_WAS_STK)|ICF_DEPEND_RESULT; + old_tempil1=NULL; + } else + tempif2=NULL; + } + if (!tempif2) { + tempi->p2.type=TY_REG+tempi->p2.type&IT_MASK; + tempi->p2.reg=CREG_RAX; + tempil1->r.type=TY_REG+tempil1->r.type&IT_MASK; + tempil1->r.reg=CREG_RAX; + } + } + } else if (tempi->p1.type&TY_MASK==TY_STK) { + if (tempil1->r.type&TY_MASK==TY_STK && + !(tempil1->ic_flags&ICF_PUSH_RESULT)) { + tempi->p1.type=TY_REG+tempi->p1.type&IT_MASK; + tempi->p1.reg=CREG_RAX; + tempil1->r.type=TY_REG+tempil1->r.type&IT_MASK; + tempil1->r.reg=CREG_RAX; + } + } + } + if (tempi->ic_flags & ICF_PUSH_RESULT) + tempi->r.type==TY_STK+tempi->r.type&IT_MASK; + + } + if (old_tempil1!=tempil1) { + CmpOptPass5Lag(lx,ps,tempil1,&i,num_stk,&inside_return,&trashed_reg_mask,fun_num); + old_tempil1=tempil1; + } + tempi+=sizeof(IntermediateCode); + } + OptEnd(lx,5,ps); + + if (fun_class) { + fun_class->used_reg_mask&=~CSTK_TEMPS_MASK; + fun_class->used_reg_mask|=trashed_reg_mask; + fun_class->trashed_reg_mask=trashed_reg_mask; + if (Bt(&lx->flags,LFf_OPT_TRACE_PRESENT)) + if (Bt(&lx->pass_trace_mask,4)) { + PrintF("Used Reg Mask:%04X\r\n",fun_class->used_reg_mask); + PrintF("Trashed Reg Mask:%04X\r\n",trashed_reg_mask); + } + } +} diff --git a/LT/Compiler/OptPass6.CPZ b/LT/Compiler/OptPass6.CPZ new file mode 100644 index 0000000..faa95f5 --- /dev/null +++ b/LT/Compiler/OptPass6.CPZ @@ -0,0 +1,1195 @@ +U8 CmpOptPass678(LexStruct *lx,ClassStruct *fun_class, + I8 *register_offsets,U1 *buf,I8 pass,DbgInfo **dbg_info,I8 *min_line,I8 *max_line) +{ + IntermediateCode *tempi; + I8 code,i,j,ip=0,ip2; + I8 min_line2=-1,last_line=0; + CbMiscStruct *lb,*lb1; + ExeAbsoluteAddressStruct *tempa; + DbgInfo *my_dbg=NULL; + AsmCtrlStruct *a=lx->a; + BoolU4 short_jmp; + I8 *qq; + IcParam saved_p123[3]; + ClassStruct *tempc; + ExternUsage *tempeu; + + if (buf) { + if (*max_line>=*min_line && *max_line-*min_line<10000) { + my_dbg=MAllocZ(offset(DbgInfo.body)+sizeof(void *)*(*max_line-*min_line+2)); + my_dbg->min_line=*min_line; + my_dbg->max_line=*max_line; + } + if (dbg_info) + *dbg_info=my_dbg; + } + + tempi=lx->cb.cb_in_ptr; + while (code=tempi->ic_opcode) { + if (code>EC_END_EXP) { + if (tempi->ic_flags&ICF_TRACE) + if (Bt(&lx->pass_trace_mask,pass)) + CbPutIc(tempi); + ip2=ip; + if (lx->a) + ip2+=lx->a->ip; + else + ip2+=buf; + if (!(tempi->ic_flags &ICF_CODE_FINAL)) { + tempi->ic_flags|=ICF_CODE_FINAL; + MemCpy(saved_p123,&tempi->p1,3*sizeof(IcParam)); + if (cmp_param_cnt[code]==2) { + if (tempi->p1.type&TY_MASK==TY_REG && + tempi->p1.reg==CREG_RAX) + tempi->ic_flags|=ICF_P1_FIRST; + } + tempi->ic_cnt=0; + if (tempi->ic_flags & ICF_P1_FIRST) { + if (tempi->p1.type&TY_MASK) { + if (tempi->ic_flags & ICF_P1_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + tempi->ic_flags&=~ICF_P1_FIRST; + } else if (tempi->ic_flags & ICF_P1_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + tempi->ic_flags&=~ICF_P1_FIRST; + } + } + if (tempi->p2.type&TY_MASK) { + if (tempi->ic_flags & ICF_P2_TO_DOUBLE) { + if (tempi->ic_flags&ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + tempi->ic_flags&=~ICF_P1_FIRST; + } + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RAX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RAX; + tempi->p2.disp=0; + } else if (tempi->ic_flags & ICF_P2_TO_INT) { + if (tempi->ic_flags&ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + tempi->ic_flags&=~ICF_P1_FIRST; + } + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RAX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RAX; + } + } + } else { + if (tempi->p3.type&TY_MASK) { + if (tempi->ic_flags & ICF_P3_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RAX); + tempi->p3.type=TY_REG+IT_I8; + tempi->p3.reg=CREG_RAX; + } else if (tempi->ic_flags & ICF_P3_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RAX); + tempi->p3.type=TY_REG+IT_I8; + tempi->p3.reg=CREG_RAX; + } + if (tempi->ic_flags & (ICF_P3_TO_DOUBLE | ICF_P3_TO_INT)) { + if (tempi->p2.type&TY_MASK) { + if (tempi->ic_flags & ICF_P2_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RDX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RDX; + } else if (tempi->ic_flags & ICF_P2_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RDX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RDX; + } + } + if (tempi->ic_flags & (ICF_P2_TO_DOUBLE | ICF_P2_TO_INT)) { + if (tempi->p1.type&TY_MASK) { //TODO: RCX might cause problems + if (tempi->ic_flags & ICF_P1_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RCX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RCX; + } else if (tempi->ic_flags & ICF_P1_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RCX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RCX; + } + } + } else { + if (tempi->p1.type&TY_MASK) { + if (tempi->ic_flags & ICF_P1_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + } else if (tempi->ic_flags & ICF_P1_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + } + } + } + } else + goto p2_RAX_p1_RDX; + } else { +p2_RAX_p1_RDX: + if (tempi->p2.type&TY_MASK) { + if (tempi->ic_flags & ICF_P2_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RAX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RAX; + } else if (tempi->ic_flags & ICF_P2_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RAX); + tempi->p2.type=TY_REG+IT_I8; + tempi->p2.reg=CREG_RAX; + } + } + if (tempi->p1.type&TY_MASK) { + if (tempi->ic_flags & ICF_P1_TO_DOUBLE) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + } else if (tempi->ic_flags & ICF_P1_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RDX); + tempi->p1.type=TY_REG+IT_I8; + tempi->p1.reg=CREG_RDX; + } + } + } + } + switch (code) { + case EC_ABSOLUTE_ADDRESS: + IcU2(tempi,0xB848); + IcU8(tempi,tempi->ic_data); + i=ip+tempi->ic_cnt-8; + if (buf && a && !(lx->flags & LF_ASM_EXPRESSIONS)) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=a->ip+i; + } + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_STR_CONST: + case EC_GET_LABEL: + lb=tempi->ic_data; + if (a) + i=lb->address+a->ip; + else + i=lb->address+buf; + IcLea(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_RIP_DISP32+IT_PTR,0,i,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_FS: + IcZero(tempi,CREG_RAX); + IcU4(tempi,0x008B4864); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + break; + case EC_GS: + IcZero(tempi,CREG_RAX); + IcU4(tempi,0x008B4865); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + break; + case EC_COM: + IcUnaries(tempi,SLASH_OP_NOT,ip2); + break; + case EC_NOT: + IcNot(tempi,ip2); + break; + case EC_UNARY_MINUS: + if (tempi->r.type&IT_MASK==IT_DOUBLE) + IcFOp1(tempi,I_UNARY_MINUS,ip2); + else + IcUnaries(tempi,SLASH_OP_NEG,ip2); + break; + case EC_ADDRESS: + case EC_MOV: + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + break; + case EC_DEREF: + IcDeref(tempi,ip2); + break; + case EC__PP: + if (tempi->ic_flags&ICF_USE_INT) + IcPostIncDec(tempi,SLASH_OP_INC,ip2); + else + IcFPostIncDec(tempi,I_INC,ip2); + break; + case EC__MM: + if (tempi->ic_flags&ICF_USE_INT) + IcPostIncDec(tempi,SLASH_OP_DEC,ip2); + else + IcFPostIncDec(tempi,I_DEC,ip2); + break; + case EC_PP_: + if (tempi->ic_flags&ICF_USE_INT) + IcPreIncDec(tempi,SLASH_OP_INC,ip2); + else + IcFPreIncDec(tempi,I_INC,ip2); + break; + case EC_MM_: + if (tempi->ic_flags&ICF_USE_INT) + IcPreIncDec(tempi,SLASH_OP_DEC,ip2); + else + IcFPreIncDec(tempi,I_DEC,ip2); + break; + case EC_LEA: + IcLea(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + break; + case EC_POWER: + IcFOp2(tempi,I_POWER,ip2); + break; + case EC_SHL: + IcShift(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0xE0,0xE0,ip2); + break; + case EC_SHR: + IcShift(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0xE8,0xF8,ip2); + break; + case EC_MUL: + if (tempi->ic_flags&ICF_USE_INT) + IcMul(tempi,ip2); + else + IcFOp2(tempi,I_MUL,ip2); + break; + case EC_DIV: + if (tempi->ic_flags&ICF_USE_INT) + IcDiv(tempi,ip2); + else + IcFOp2(tempi,I_DIV,ip2); + break; + case EC_MOD: + if (tempi->ic_flags&ICF_USE_INT) + IcMod(tempi,ip2); + else + IcFOp2(tempi,I_MOD,ip2); + break; + case EC_AND: + IcAddEct(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x23,ip2); + break; + case EC_OR: + IcAddEct(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x0B,ip2); + break; + case EC_XOR: + IcAddEct(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x33,ip2); + break; + case EC_ADD: + if (tempi->ic_flags&ICF_USE_INT) + IcAddEct(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x03,ip2); + else + IcFOp2(tempi,I_ADD,ip2); + break; + case EC_SUB: + if (tempi->ic_flags&ICF_USE_INT) + IcSubEct(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x2B,ip2); + else + IcFOp2(tempi,I_SUB,ip2); + break; + case EC_EQUAL_EQUAL: + IcCmp(tempi,0x75,0x75,ip2); + break; + case EC_NOT_EQUAL: + IcCmp(tempi,0x74,0x74,ip2); + break; + case EC_LESS: + if (tempi->ic_flags&ICF_USE_INT) + IcCmp(tempi,0x73,0x7D,ip2); + else + IcFCmp(tempi,I_LESS,ip2); + break; + case EC_GREATER: + if (tempi->ic_flags&ICF_USE_INT) + IcCmp(tempi,0x76,0x7E,ip2); + else + IcFCmp(tempi,I_GREATER,ip2); + break; + case EC_LESS_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcCmp(tempi,0x77,0x7F,ip2); + else + IcFCmp(tempi,I_LESS_EQUAL,ip2); + break; + case EC_GREATER_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcCmp(tempi,0x72,0x7C,ip2); + else + IcFCmp(tempi,I_GREATER_EQUAL,ip2); + break; + case EC_AND_AND: + IcAndAnd(tempi,ip2); + break; + case EC_OR_OR: + IcOrOr(tempi,ip2); + break; + case EC_XOR_XOR: + IcXorXor(tempi,ip2); + break; + case EC_COLON: + IcColon(tempi,ip2); + break; + case EC_ASSIGN: + IcAssign(tempi,ip2); + break; + case EC_SHL_EQUAL: + IcShiftEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0xE0,0xE0,ip2); + break; + case EC_SHR_EQUAL: + IcShiftEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0xE8,0xF8,ip2); + break; + case EC_MUL_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcMulEqual(tempi,ip2); + else + IcFOp2Equal(tempi,I_MUL,ip2); + break; + case EC_DIV_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcDivEqual(tempi,FALSE,ip2); + else + IcFOp2Equal(tempi,I_DIV,ip2); + break; + case EC_MOD_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcDivEqual(tempi,TRUE,ip2); + else + IcFOp2Equal(tempi,I_MOD,ip2); + break; + case EC_AND_EQUAL: + IcAddSubEctEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x0425240423,ip2); + break; + case EC_OR_EQUAL: + IcAddSubEctEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x010D0C010B,ip2); + break; + case EC_XOR_EQUAL: + IcAddSubEctEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x0635340633,ip2); + break; + case EC_ADD_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcAddSubEctEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x00000003,ip2); + else + IcFOp2Equal(tempi,I_ADD,ip2); + break; + case EC_SUB_EQUAL: + if (tempi->ic_flags&ICF_USE_INT) + IcAddSubEctEqual(tempi,tempi->p1.ptype, + tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,0x0000052B,ip2); + else + IcFOp2Equal(tempi,I_SUB,ip2); + break; + case EC_SHL_CONST: + IcShift(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + TY_IMM+IT_I8,0,tempi->ic_data,0xE0,0xE0,ip2); + break; + case EC_SHR_CONST: + IcShift(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp, + TY_IMM+IT_I8,0,tempi->ic_data,0xE8,0xF8,ip2); + break; + case EC_ADD_CONST: + IcAddConst(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,tempi->ic_data,0x0003,ip2); + break; + case EC_SUB_CONST: + IcAddConst(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,tempi->ic_data,0x052B,ip2); + break; + case EC_ENTER: + IcPush(tempi,TY_REG+IT_I8,CREG_RBP,0,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RBP,0, + TY_REG+IT_I8,CREG_RSP,0,ip2); + if (i=tempi->ic_data) { + if (MIN_I1<=i<=MAX_I1) { + IcU3(tempi,0xEC8348); + IcU1(tempi,i); + } else { + IcU3(tempi,0xEC8148); + IcU4(tempi,i); + } + } + if (fun_class) + IcPushRegs(tempi,fun_class->used_reg_mask&(CREG_VARS_MASK|CREG_NON_PTR_MASK)); + for (i=0;i0 && register_offsets[i]!=MAX_I8) + IcMov(tempi,TY_REG+IT_I8,i,0, + TY_DISP+IT_I8,CREG_RBP,register_offsets[i],ip2); + break; + case EC_ADD_RSP: + if (i=tempi->ic_data) { + if (MIN_I1<=i<=MAX_I1) { + IcU3(tempi,0xC48348); + IcU1(tempi,i); + } else { + IcU3(tempi,0xC48148); + IcU4(tempi,i); + } + } + break; + case EC_CALL: + i=tempi->ic_data-(ip2+5); + IcU1(tempi,0xE8); + IcU4(tempi,i); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_CALL_EXTERN: + IcU1(tempi,0xE8); + IcU4(tempi,0); + if (buf) { + tempc=tempi->ic_data; + tempeu=MAllocZ(sizeof(ExternUsage)); + tempeu->next=tempc->ext_list; + tempc->ext_list=tempeu; + tempeu->ip=ip2+1; + } + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_CALL_INDIRECT: //TODO: calls>32 disp + IcU3(tempi,0xDC8B48); + IcU3(tempi,0x93FF48); + IcU4(tempi,tempi->ic_data); + break; + case EC_CALL_INDIRECT2: + IcU2(tempi,0xBB48); + if (a) i=ip2+tempi->ic_cnt; + IcU4(tempi,tempi->ic_data); + IcU4(tempi,0); + IcU2(tempi,0xC033); + IcU2(tempi,0x038B); + IcU3(tempi,0xD0FF48); + if (buf && a && !(lx->flags & LF_ASM_EXPRESSIONS)) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=i; + } + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_CLI: + IcU1(tempi,0xFA); + break; + case EC_STI: + IcU1(tempi,0xFB); + break; + case EC_WBINVD: + IcU2(tempi,0x090F); + break; + case EC_INVD: + IcU2(tempi,0x080F); + break; + case EC_ENABLE_CACHE: + IcU4(tempi,0xC0200F40); + IcU2(tempi, 0x2540); + IcU4(tempi,~0x60000000); + IcU4(tempi, 0xC0220F40); + break; + case EC_DISABLE_CACHE: + IcU4(tempi,0xC0200F40); + IcU2(tempi, 0x0D40); + IcU4(tempi,0x60000000); + IcU4(tempi, 0xC0220F40); + break; + case EC_GET_FLAGS: + IcU1(tempi,0x9C); + IcPop(tempi,TY_REG+IT_I8,CREG_RAX,0,ip2); + break; + case EC_RDTSC: + IcU2(tempi,0xC033); + IcU3(tempi,0x310F40); + IcU3(tempi,0xE2C148); + IcU4(tempi,0xC2034820); + break; + case EC_SET_FLAGS: + IcPush(tempi,tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU1(tempi,0x9D); + break; + case EC_GET_BASE_PTR: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + TY_REG+IT_I8,CREG_RBP,0,ip2); + break; + case EC_SET_BASE_PTR: + IcMov(tempi,TY_REG+IT_I8,CREG_RBP,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + break; + case EC_GET_STACK_PTR: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + TY_REG+IT_I8,CREG_RSP,0,ip2); + break; + case EC_SET_STACK_PTR: + IcMov(tempi,TY_REG+IT_I8,CREG_RSP,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + break; + case EC_RETURN_START: + case EC_RETURN_END: + break; + case EC_SET_RAX: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + break; + case EC_BT: + IcBitOps(tempi,0xA30F,0x20BA0F,FALSE,ip2); + break; + case EC_BTS: + IcBitOps(tempi,0xAB0F,0x28BA0F,FALSE,ip2); + break; + case EC_BTR: + IcBitOps(tempi,0xB30F,0x30BA0F,FALSE,ip2); + break; + case EC_BTC: + IcBitOps(tempi,0xBB0F,0x38BA0F,FALSE,ip2); + break; + case EC_LBTS: + IcBitOps(tempi,0xAB0F,0x28BA0F,TRUE,ip2); + break; + case EC_LBTR: + IcBitOps(tempi,0xB30F,0x30BA0F,TRUE,ip2); + break; + case EC_LBTC: + IcBitOps(tempi,0xBB0F,0x38BA0F,TRUE,ip2); + break; + case EC_BSF: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU4(tempi,0xC0BC0F48); + IcU2(tempi,0x0375); + IcU3(tempi,0xD0F748); + break; + case EC_BSR: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU4(tempi,0xC0BD0F48); + IcU2(tempi,0x0375); + IcU3(tempi,0xD0F748); + break; + case EC_PREEMPT: + IcPreempt(tempi,ip2); + break; + case EC_ABSI8: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU3(tempi,0xC00B48); + IcU2(tempi,0x0379); + IcU3(tempi,0xD8F748); + break; + case EC_INSQUE: + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU3(tempi,0x1A8B48); + IcU3(tempi,0x028948); + IcU3(tempi,0x188948); + IcU4(tempi,sizeof(void *)<<24+0x508948); + IcU4(tempi,sizeof(void *)<<24+0x438948); + break; + case EC_INSQUE_REV: + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU4(tempi,sizeof(void *)<<24+0x5A8B48); + IcU3(tempi,0x038948); + IcU3(tempi,0x108948); + IcU4(tempi,sizeof(void *)<<24+0x588948); + IcU4(tempi,sizeof(void *)<<24+0x428948); + break; + case EC_REMQUE: + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU3(tempi,0x188B48); + IcU4(tempi,sizeof(void *)<<24+0x508B48); + IcU3(tempi,0x1A8948); + IcU4(tempi,sizeof(void *)<<24+0x538948); + break; + case EC_MEMCPY: + if (tempi->p1.type&TY_MASK==TY_REG && + tempi->p1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else if (tempi->p2.type&TY_MASK==TY_REG && + tempi->p2.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcPushRegs(tempi,1<p1.type&TY_MASK==TY_REG && + tempi->p1.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else if (tempi->p2.type&TY_MASK==TY_REG && + tempi->p2.reg==CREG_RAX) { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p3.type,tempi->p3.reg,tempi->p3.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RCX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcPushRegs(tempi,1<p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU3(tempi,0xD08B48); + IcU2(tempi,0x188A); + IcU3(tempi,0xC0FF48); + IcU2(tempi,0xDB0A); + IcU2(tempi,0xF775); + IcU3(tempi,0xC22B48); + IcU3(tempi,0xC8FF48); + break; + case EC_INPD: + if (tempi->p1.type&TY_MASK==TY_IMM && tempi->p1.disp<=MAX_U1) { + IcU2(tempi,0xC033); + IcU2(tempi,0x00E5+tempi->p1.disp<<8); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU2(tempi,0xC033); + IcU1(tempi,0xED); + } + break; + case EC_INPW: + if (tempi->p1.type&TY_MASK==TY_IMM && tempi->p1.disp<=MAX_U1) { + IcU2(tempi,0xC033); + IcU3(tempi,0x00E566+tempi->p1.disp<<16); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU2(tempi,0xC033); + IcU2(tempi,0xED66); + } + break; + case EC_INP: + if (tempi->p1.type&TY_MASK==TY_IMM && tempi->p1.disp<=MAX_U1) { + IcU2(tempi,0xC033); + IcU2(tempi,0x00E4+tempi->p1.disp<<8); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU2(tempi,0xC033); + IcU1(tempi,0xEC); + } + break; + case EC_OUTPD: + if (tempi->p2.type&TY_MASK==TY_IMM && tempi->p2.disp<=MAX_U1) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU2(tempi,0x00E7+tempi->p2.disp<<8); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU1(tempi,0xEF); + } + break; + case EC_OUTPW: + if (tempi->p2.type&TY_MASK==TY_IMM && tempi->p2.disp<=MAX_U1) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU3(tempi,0x00E766+tempi->p2.disp<<16); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU2(tempi,0xEF66); + } + break; + case EC_OUTP: + if (tempi->p2.type&TY_MASK==TY_IMM && tempi->p2.disp<=MAX_U1) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcU2(tempi,0x00E6+tempi->p2.disp<<8); + } else { + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RDX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU1(tempi,0xEE); + } + break; + case EC_SWITCH: + if (tempi->ic_flags & ICF_P1_FIRST) { + IcMov(tempi,TY_REG+IT_U2,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + IcMov(tempi,TY_REG+IT_U2,CREG_RCX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + } else { + IcMov(tempi,TY_REG+IT_U2,CREG_RCX,0, + tempi->p2.type,tempi->p2.reg,tempi->p2.disp,ip2); + IcMov(tempi,TY_REG+IT_U2,CREG_RDX,0, + tempi->p1.type,tempi->p1.reg,tempi->p1.disp,ip2); + } + IcU3(tempi,0xD13B48); + IcU2(tempi,0x0873); + IcU4(tempi,0xD524FF48); + lb=tempi->ic_data; + if (a) + i=lb->address+a->ip; + else + i=lb->address+buf; + if (a) j=a->ip+ip+tempi->ic_cnt; + IcU4(tempi,i); + if (buf && a && !(lx->flags & LF_ASM_EXPRESSIONS)) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=j; + } + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_ZERO: + IcTestAndBranch(tempi,ip,0x74840F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_ZERO: + IcTestAndBranch(tempi,ip,0x75850F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_EQUAL_EQUAL: + IcCmpAndBranch(tempi,ip,0x74840F,0x74840F,0x74840F,0x74840F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_EQUAL: + IcCmpAndBranch(tempi,ip,0x75850F,0x75850F,0x75850F,0x75850F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_GREATER_EQUAL: + if (tempi->ic_flags&ICF_USE_DOUBLE) + IcFCmpAndBranch(tempi,ip,I_GREATER_EQUAL,buf,ip2); + else + IcCmpAndBranch(tempi,ip,0x73830F,0x7D8D0F,0x76860F,0x7E8E0F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_LESS_EQUAL: + if (tempi->ic_flags&ICF_USE_DOUBLE) + IcFCmpAndBranch(tempi,ip,I_LESS_EQUAL,buf,ip2); + else + IcCmpAndBranch(tempi,ip,0x76860F,0x7E8E0F,0x73830F,0x7D8D0F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_GREATER: + if (tempi->ic_flags&ICF_USE_DOUBLE) + IcFCmpAndBranch(tempi,ip,I_GREATER,buf,ip2); + else + IcCmpAndBranch(tempi,ip,0x77870F,0x7F8F0F,0x72820F,0x7C8C0F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_LESS: + if (tempi->ic_flags&ICF_USE_DOUBLE) + IcFCmpAndBranch(tempi,ip,I_LESS,buf,ip2); + else + IcCmpAndBranch(tempi,ip,0x72820F,0x7C8C0F,0x77870F,0x7F8F0F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_BT: + IcBrBitOps(tempi,ip,0xA30F,0x20BA0F,0x72820F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_BTS: + IcBrBitOps(tempi,ip,0xAB0F,0x28BA0F,0x72820F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_BTR: + IcBrBitOps(tempi,ip,0xB30F,0x30BA0F,0x72820F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_BTC: + IcBrBitOps(tempi,ip,0xBB0F,0x38BA0F,0x72820F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_BT: + IcBrBitOps(tempi,ip,0xA30F,0x20BA0F,0x73830F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_BTS: + IcBrBitOps(tempi,ip,0xAB0F,0x28BA0F,0x73830F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_BTR: + IcBrBitOps(tempi,ip,0xB30F,0x30BA0F,0x73830F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_BTC: + IcBrBitOps(tempi,ip,0xBB0F,0x38BA0F,0x73830F,FALSE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_LBTS: + IcBrBitOps(tempi,ip,0xAB0F,0x28BA0F,0x72820F,TRUE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_LBTR: + IcBrBitOps(tempi,ip,0xB30F,0x30BA0F,0x72820F,TRUE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_LBTC: + IcBrBitOps(tempi,ip,0xBB0F,0x38BA0F,0x72820F,TRUE,buf,ip2); + break; + case EC_BR_NOT_LBTS: + IcBrBitOps(tempi,ip,0xAB0F,0x28BA0F,0x73830F,TRUE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_LBTR: + IcBrBitOps(tempi,ip,0xB30F,0x30BA0F,0x73830F,TRUE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_NOT_LBTC: + IcBrBitOps(tempi,ip,0xBB0F,0x38BA0F,0x73830F,TRUE,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_AND_ZERO: + IcAndBranch(tempi,ip,0x74840F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_BR_AND_NOT_ZERO: + IcAndBranch(tempi,ip,0x75850F,buf,ip2); + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_LEAVE: + if (fun_class) + IcPopRegs(tempi,fun_class->used_reg_mask&(CREG_VARS_MASK|CREG_NON_PTR_MASK)); + if (i=tempi->ic_data) { + if (MIN_I1<=i<=MAX_I1) { + IcU3(tempi,0xC48348); + IcU1(tempi,i); + } else { + IcU3(tempi,0xC48148); + IcU4(tempi,i); + } + } + IcPop(tempi,TY_REG+IT_I8,CREG_RBP,0,ip2); + IcU1(tempi,0xC3); + break; + case EC_RET: + IcU1(tempi,0xC3); + break; + case EC_JMP: + short_jmp=(tempi->ic_flags & ICF_SHORT_JMP) ? TRUE:FALSE; + lb=tempi->ic_data; + while (lb1=lb->forward) + lb=lb1; + if (!buf) { + if (lb->address!=INVALID_PTR) { + i=lb->address-ip; + if (MIN_I1+5ic_flags|=ICF_SHORT_JMP; + i=lb->address-(ip+2); + IcU2(tempi,i<<8+0xEB); + } else { + i=lb->address-(ip+5); + IcU1(tempi,0xE9); + IcU4(tempi,i); + } + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_NULL: + break; + case EC_LABEL: + lb=tempi->ic_data; + lb->address=ip; + if (lb->flags&CBMF_POP_CMP) { + IcU3(tempi,0xC48348); + IcU1(tempi,-8); + IcU3(tempi,0xC48348); + IcU1(tempi,8); + } + tempi->ic_flags&=~ICF_CODE_FINAL; + break; + case EC_QUESTION: + break; + case EC_IRQ: + IcU1(tempi,0xCD); + IcU1(tempi,tempi->ic_data); + break; + case EC_NOP: + case EC_NOP1: + case EC_PUSH_CMP: + break; + case EC_CALL_START: + case EC_PUSH_REGS: + IcPushRegs(tempi,tempi->ic_data); + break; + case EC_CALL_END2: + break; + case EC_CALL_END: + IcPopRegs(tempi,tempi->ic_data); + if (tempi->r.type&TY_MASK) + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + break; + case EC_POP_REGS: + IcPopRegs(tempi,tempi->ic_data); + break; + case EC_END_EXP: + break; + + default: + OptMissing(lx,6,tempi); + } + if (tempi->r.type&TY_MASK) { + if (tempi->ic_flags & ICF_R_TO_DOUBLE) { + if (tempi->ic_opcode==EC_PUSH_CMP) { + IcU3(tempi,0xDC8B48); + IcU3(tempi,0x2BDF48); + IcU3(tempi,0x1BDD48); + IcU1(tempi,0x9B); + } else { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->r.type,tempi->r.reg,tempi->r.disp,ip2); + IcCopyIrq(tempi,I_TO_DOUBLE_RAX); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + } + } else if (tempi->ic_flags & ICF_R_TO_INT) { + IcMov(tempi,TY_REG+IT_I8,CREG_RAX,0, + tempi->r.type,tempi->r.reg,tempi->r.disp,ip2); + IcCopyIrq(tempi,I_TO_INT_RAX); + IcMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp, + TY_REG+IT_I8,CREG_RAX,0,ip2); + } + } + } + if (tempi->ic_cnt) { + if (pass==7) { + i=tempi->ic_line; + if (i>=last_line) { + last_line=i; + if (i<*min_line) + *min_line=i; + if (i>*min_line && i*max_line) + *max_line=i; + } + } + if (buf) { + if (tempi->ic_ext_body) { + MemCpy(buf+ip,tempi->ic_ext_body,tempi->ic_cnt); + Free(tempi->ic_ext_body); + tempi->ic_ext_body=NULL; + } else + MemCpy(buf+ip,tempi->ic_body,tempi->ic_cnt); + if (my_dbg) { + if (tempi->ic_line>=*min_line && tempi->ic_line<=*max_line) { + i=tempi->ic_line-*min_line; + if (!my_dbg->body[i]) + my_dbg->body[i]=ip2; + } + } + } + } + if (tempi->ic_flags&ICF_TRACE) { + if (Bt(&lx->pass_trace_mask,pass)) { + if (buf) { + if (tempi->ic_cnt) { + cout "$$FG,RED$$"; + CallExtStr("Dasm2",buf+ip,tempi->ic_cnt,64); + cout "$$FG$$"; + } + } + } + } + if (!(tempi->ic_flags&ICF_CODE_FINAL)) + MemCpy(&tempi->p1,saved_p123,3*sizeof(IcParam)); + ip+=tempi->ic_cnt; + } + tempi+=sizeof(IntermediateCode); + } + + lb=lx->cb.cb_misc_list; + while (lb) { + if (lb->type==CBMT_STR_CONST) { + lb->address=ip; + if (buf) + MemCpy(buf+ip,lb->str,lb->st_len); + ip+=lb->st_len; + } else if (lb->type==CBMT_JMP_TABLE) { + ip+=(8-ip&7)&7; //aligned to 8 + lb->address=ip; + if (buf) { + for (i=0;ist_len;i++) { + lb1=lb->jmp_table[i]; + qq=buf+ip+i<<3; + if (a) { + tempa=MAllocZ(sizeof(ExeAbsoluteAddressStruct)); + tempa->next=a->absolutes; + a->absolutes=tempa; + tempa->ip=a->ip+ip+i<<3; + *qq=lb1->address+a->ip; + } else + *qq=lb1->address+buf; + } + } + ip+=lb->st_len<<3; + } + lb=lb->next; + } + if (pass==7) { + if (min_line2!=-1 && + (min_line2-*min_line)>10) //Defines screw things up + *min_line=min_line2; + } else if (buf && my_dbg) { + i=*max_line-*min_line+1; + if (lx->a) + my_dbg->body[i]=ip+lx->a->ip; + else + my_dbg->body[i]=ip+buf; + } + + return ip; +} diff --git a/LT/DEMO/AutoFile/Demo3.AUZ b/LT/Compiler/Renum.AUZ similarity index 67% rename from LT/DEMO/AutoFile/Demo3.AUZ rename to LT/Compiler/Renum.AUZ index a11a799..1430948 100644 --- a/LT/DEMO/AutoFile/Demo3.AUZ +++ b/LT/Compiler/Renum.AUZ @@ -1,7 +1,7 @@ /* 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. +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 @@ -11,16 +11,17 @@ and running this demo. U1 i; -PutS("Edit(\"Demo3.TXZ\");\r"); +PutS("Edit(\"CmpDefs.HPZ\");\r"); //Go to start of file Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL); -for (i=0;i<=0xD6;i++) { +for (i=0;i<=0x8A;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); + Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT); + PrintF("%c%c%c",CH_BACKSPACE,CH_BACKSPACE,CH_BACKSPACE); + PrintF("%03X",i); Sleep(5); } \ No newline at end of file diff --git a/LT/COMPILE/SPRINTF2.CPZ b/LT/Compiler/SPrintF2.CPZ similarity index 62% rename from LT/COMPILE/SPRINTF2.CPZ rename to LT/Compiler/SPrintF2.CPZ index 3c348fc..bb8c1c5 100644 --- a/LT/COMPILE/SPRINTF2.CPZ +++ b/LT/Compiler/SPrintF2.CPZ @@ -16,110 +16,166 @@ void OutChar(I1 **addr_dst,I1 ch,I1 **addr_buf) *addr_dst=dst; } -void OutString(I1 *ptr,I1 **addr_buf,I1 *addr_dst, +void OutStr(I1 *ptr,I1 **addr_buf,I1 *addr_dst, I8 len,BoolU4 left_justify,BoolU4 truncate) { I8 i,j; - i=StrLen(ptr); + if (!ptr) + i=0; + else + i=StrLen(ptr); if (truncate && i>len) i=len; if (left_justify) { for (j=0;jhash_table; + ClassStruct *tempc; + U8 i,best=0x8000,j; + if (!CheckPtr(add)) { + *offset=best; + return NULL; + } + while (h) { + for (i=0;i<=h->mask;i++) { + temph=h->body[i]; + while (temph) { + if (temph->type&HTT_FUNCTION) { + tempc=temph; + j=tempc->executable_address; + } else + j=temph->user_data0; + j=add-j; + if (temph->type&(HTT_SYS_SYMBOL|HTT_FUNCTION)) { + if (jnext; + } + } + h=h->next; + } + *offset=best; + return result; +} + +void SPrintFPSect(I1 *buf,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); + SPrintF(buf,"%*ts,%04X",field_length-5,temph->str,offset); else - return MSPrintF("%s,%04X",temph->string,offset); + SPrintF(buf,"%s,%04X",temph->str,offset); } + return; } if (field_length) - return MSPrintF("%*tX",field_length,add); + SPrintF(buf,"%*tX",field_length,add); else - return MSPrintF("%X",add); + SPrintF(buf,"%X",add); } I1 *MSPrintFTime(LTDate ltdt,U8 sub_format) { LTDateStruct d; - ToLTDateStruct(&d,ltdt); switch (sub_format) { case 1: + ToLTDateStruct(&d,ltdt+local_time_offset); return MSPrintF("%02d:%02d",d.hours,d.minutes); case 2: + ToLTDateStruct(&d,ltdt+local_time_offset); 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: + ToLTDateStruct(&d,ltdt+local_time_offset); 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: + ToLTDateStruct(&d,ltdt+local_time_offset); 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: + ToLTDateStruct(&d,ltdt+local_time_offset); if (d.hours>=12) return MSPrintF("%02d:%02dp",d.hours-12,d.minutes); else return MSPrintF("%02d:%02da",d.hours,d.minutes); case 6: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dh %02dm",d.hours+ltdt.date*24,d.minutes); case 7: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dh %02dm %02ds",d.hours+ltdt.date*24,d.minutes,d.seconds); case 8: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dd %02dh %02dm",ltdt.date,d.hours,d.minutes); case 9: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dd %02dh %02dm %02ds",ltdt.date,d.hours,d.minutes,d.seconds); case 10: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dd %02dh %02dm %02d.%02ds",ltdt.date,d.hours,d.minutes,d.seconds,d.hundredths); case 11: + ToLTDateStruct(&d,ltdt); 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); + ToLTDateStruct(&d,ltdt); + return MSPrintF("%d.%02d",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); + ToLTDateStruct(&d,ltdt); + return MSPrintF("%02d:%02d.%02d",60*(ltdt.date*24+d.hours)+d.minutes,d.seconds,d.hundredths); case 14: + ToLTDateStruct(&d,ltdt); return MSPrintF("%02d:%02d:%02d.%02d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.hundredths); case 15: + ToLTDateStruct(&d,ltdt); return MSPrintF("%dd %02dh %02dm %02d.%04ds",ltdt.date,d.hours,d.minutes,d.seconds,d.ten_thousandths); case 16: + ToLTDateStruct(&d,ltdt); 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); + ToLTDateStruct(&d,ltdt); + return MSPrintF("%d.%04d",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); + ToLTDateStruct(&d,ltdt); + return MSPrintF("%02d:%02d.%04d",60*(ltdt.date*24+d.hours)+d.minutes,d.seconds,d.ten_thousandths); case 19: + ToLTDateStruct(&d,ltdt); return MSPrintF("%02d:%02d:%02d.%04d",ltdt.date*24+d.hours,d.minutes,d.seconds,d.ten_thousandths); default: + ToLTDateStruct(&d,ltdt+local_time_offset); return MSPrintF("%02d:%02d:%02d",d.hours,d.minutes,d.seconds); } } -I1 *MSPrintFDate(U8 dt,U8 sub_format) +I1 *MSPrintFDate(LTDate dt,U8 sub_format) { LTDateStruct d; - LTDate ltdt=0; - ltdt.date=dt; - ToLTDateStruct(&d,ltdt); + ToLTDateStruct(&d,dt+local_time_offset); switch (sub_format) { case 1: return MSPrintF("%02d/%02d",d.month,d.day_of_month); @@ -234,21 +290,25 @@ I1 *MSPrintFDate(U8 dt,U8 sub_format) } } -I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) +#define TEMP_BUF_LEN 256 + +I1 *SPrintFJoin2(I1 *dst,I1 *src,I8 argc,I8 *argv) { - I1 ch,*ptr,**addr_buf,*buf=NULL,*addr_dst, + I1 *ptr,**addr_buf,*buf,*addr_dst, *temp1; BoolU4 pad_zero,left_justify,truncate,neg,neg_e; - I8 i; - I8 k,len,dec_len,sub_format; + I8 i,ch,ch1,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 + double dd,dd1; + I1 temp_buf[TEMP_BUF_LEN]; + + if (!src) + throw(EXCEPT_SPRINTF,0); if (dst) { addr_buf=NULL; + buf=dst; } else { - buf=MAlloc(256); + buf=MAlloc(128); addr_buf=&buf; dst=buf; } @@ -271,6 +331,8 @@ I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) len=len*10+ *(src++)-'0'; if (*src=='*') { src++; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); len=argv[cur_param++]; } dec_len=0; @@ -280,6 +342,8 @@ I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) dec_len=dec_len*10+ *(src++)-'0'; if (*src=='*') { src++; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); dec_len=argv[cur_param++]; } } @@ -296,6 +360,8 @@ I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) sub_format=sub_format*10+ *(src++)-'0'; if (*src=='*') { src++; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); sub_format=argv[cur_param++]; } } @@ -303,22 +369,28 @@ I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) k=0; switch (*src++) { case 's': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); ptr=argv[cur_param++]; - OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); break; case 'S': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); ptr=SysText(argv[cur_param++]); - OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); break; case 'F': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); ptr=ReadTextFile(argv[cur_param++]); - if (ptr) { - OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate); - Free(ptr); - } + OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); + Free(ptr); break; case 'Q': - ptr=argv[cur_param++]; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); + if (ptr=argv[cur_param++]) while (ch=*ptr++) { if (ch=='$$') { OutChar(addr_dst,ch,addr_buf); @@ -335,55 +407,134 @@ I1 *SPrintFJoin2(I1 *dst,I1 *src,I8i argc,I8i *argv) } else { if (ch=='"' || ch=='\\') OutChar(addr_dst,'\\',addr_buf); - OutChar(addr_dst,ch,addr_buf); + if (ch>=CH_SHIFT_SPACE && ch<=0x7F) + OutChar(addr_dst,ch,addr_buf); + else { + OutChar(addr_dst,'\\',addr_buf); + OutChar(addr_dst,ch>>6&7+'0',addr_buf); + OutChar(addr_dst,ch>>3&7+'0',addr_buf); + OutChar(addr_dst,ch&7+'0',addr_buf); + } } } break; + case 'q': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); + if (ptr=argv[cur_param++]) + while (ch=*ptr++) { + ch1=*ptr; + if (ch=='\\') { + if (ch1=='n') { + OutChar(addr_dst,CH_LINE_FEED,addr_buf); + ptr++; + } else if (ch1=='r') { + OutChar(addr_dst,CH_CR,addr_buf); + ptr++; + } else if (ch1=='"') { + OutChar(addr_dst,'"',addr_buf); + ptr++; + } else if (ch1==0x27) { // "\'" + OutChar(addr_dst,0x27,addr_buf); + ptr++; + } else if (ch1=='\`') { + OutChar(addr_dst,'\`',addr_buf); + ptr++; + } else if (ch1=='\\') { + OutChar(addr_dst,'\\',addr_buf); + ptr++; + } else if (ch1=='t') { + OutChar(addr_dst,CH_TAB,addr_buf); + ptr++; + } else if (ch1>='0' && ch1<='7') { + i=ch1-'0'; + ptr++; + do { + ch1=*ptr++; + if (ch1>='0' && ch1<='7') + i=i<<3+ch1-'0'; + } while (ch1>='0' && ch1<='7'); + OutChar(addr_dst,i,addr_buf); + } else + OutChar(addr_dst,ch,addr_buf); + } else if (ch=='$$' && ch1=='$$') { + OutChar(addr_dst,ch,addr_buf); + ptr++; + } else + OutChar(addr_dst,ch,addr_buf); + } + break; case 'z': + if (cur_param+1>=argc) + throw(EXCEPT_SPRINTF,1); ptr=PointAtListEntry(argv[cur_param],argv[cur_param+1]); cur_param=cur_param+2; - OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); break; case 'Z': + if (cur_param+1>=argc) + throw(EXCEPT_SPRINTF,1); ptr=SysTextSub(argv[cur_param],argv[cur_param+1]); cur_param=cur_param+2; - OutString(ptr,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); break; case 'c': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); OutChar(addr_dst,argv[cur_param++],addr_buf); break; + case 'C': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); + OutChar(addr_dst,ToUpper(argv[cur_param++]),addr_buf); + break; case 'D': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); temp1=MSPrintFDate(argv[cur_param++],sub_format); - OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(temp1,addr_buf,addr_dst,len,left_justify,truncate); Free(temp1); break; case 'T': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); temp1=MSPrintFTime(argv[cur_param++],sub_format); - OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate); + OutStr(temp1,addr_buf,addr_dst,len,left_justify,truncate); Free(temp1); break; case 'P': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); if (truncate) - temp1=MSPrintFPSect(argv[cur_param++],len); + SPrintFPSect(temp_buf,argv[cur_param++],len); else - temp1=MSPrintFPSect(argv[cur_param++],0); - OutString(temp1,addr_buf,addr_dst,len,left_justify,truncate); - Free(temp1); + SPrintFPSect(temp_buf,argv[cur_param++],0); + OutStr(temp_buf,addr_buf,addr_dst,len,left_justify,truncate); break; case 'd': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); 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); + while ((!k || i) && klen) - k=len-i; + if (neg) + i=1; + else + i=0; + if (len>0) { + if (truncate && k+i>len) + k=len-i; + } else + len=0; + if (k<0) + k=0; if (pad_zero) for (;i=argc) + throw(EXCEPT_SPRINTF,1); d=argv[cur_param++]; - while (!k|| d) { - temp_buf[k++]=ModU8(d,10)+'0'; - d=DivU8(d,10); + while ((!k|| d) && k=argc) + throw(EXCEPT_SPRINTF,1); + dd=argv[cur_param++]><(double); if (dd<0) { neg=TRUE; dd=-dd; @@ -413,7 +567,7 @@ out_f: if (i=dec_len) dd*=Pow10(i); dd=Round(dd); - while (i--) { + while (i-- && k=argc) + throw(EXCEPT_SPRINTF,1); + dd=argv[cur_param++]><(double); if (dd<0) { neg=TRUE; dd=-dd; } - dd1=(dd) ? Log10(dd):0; - dd1=Round(dd1); + if (dd) + dd1=Floor(Log10(dd)); + else + dd1=0; out_e: dd/=Pow10(dd1); if (dd1<0) { @@ -468,21 +625,71 @@ out_e: goto out_f; case 'g': if (!len) len=12; - dd_ptr=&argv[cur_param++]; - dd=*dd_ptr; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); + dd=argv[cur_param++]><(double); if (dd<0) { neg=TRUE; dd=-dd; } - dd1=(dd) ? Log10(dd):0; - dd1=Round(dd1); + if (dd) + dd1=Floor(Log10(dd)); + else + dd1=0; if (dd1>=(len-1-dec_len) || dd1<-(dec_len-1)) goto out_e; else goto out_f; + case 'n': + if (!len) len=12; + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); + dd=argv[cur_param++]><(double); + if (dd<0) { + neg=TRUE; + dd=-dd; + } + if (dd) + dd1=3.0*Floor(Log10(dd)/3); + else + dd1=0; +out_n: + dd/=Pow10(dd1); + if (dd1<0) { + dd1=-dd1; + neg_e=TRUE; + } else + neg_e=FALSE; + if (dd) { + if (dd<1.0) { + dd*=1000; + if (neg_e) + dd1+=3; + else + dd1-=3; + } else if (dd>=1000.0) { + dd/=1000; + if (neg_e) + dd1-=3; + else + dd1+=3; + } + } + 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 'X': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); d=argv[cur_param++]; - while (!k || d) { + while ((!k || d) && k'9') temp_buf[k]+='A'-0x3A; k++; @@ -490,8 +697,10 @@ out_e: } goto out_num; case 'x': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); d=argv[cur_param++]; - while (!k || d) { + while ((!k || d) && k'9') temp_buf[k]+='a'-0x3A; k++; @@ -499,8 +708,10 @@ out_e: } goto out_num; case 'b': + if (cur_param>=argc) + throw(EXCEPT_SPRINTF,1); d=argv[cur_param++]; - while (!k || d) { + while ((!k || d) && k>=1; } @@ -516,8 +727,8 @@ out_e: return buf; } - double A2Double(I1 *src,I1 **end_ptr=NULL) +//ASCII string to double { I1 ch=*src++; I8 i=0,j=0,k=0; @@ -532,7 +743,7 @@ double A2Double(I1 *src,I1 **end_ptr=NULL) } while (TRUE) { if (Bt(dec_numeric_bitmap,ch)) - i=MulU8(i,10)+ch-'0'; + i=i*10+ch-'0'; else { if (ch=='.' || ch=='e' || ch=='E') break; d=i; @@ -544,7 +755,7 @@ double A2Double(I1 *src,I1 **end_ptr=NULL) ch=*src++; while (TRUE) { if (Bt(dec_numeric_bitmap,ch)) { - j=MulU8(j,10)+ch-'0'; + j=j*10+ch-'0'; k++; } else { d=i+j*Pow10(-k); @@ -562,7 +773,7 @@ double A2Double(I1 *src,I1 **end_ptr=NULL) j=0; while (TRUE) { if (Bt(dec_numeric_bitmap,ch)) - j=MulU8(j,10)+ch-'0'; + j=j*10+ch-'0'; else { d*=Pow10(j*k); goto a2d_end; @@ -575,19 +786,31 @@ a2d_end: } /* -A2LTDate() +$FG,2$A2LTDate() This routine recognizes the following formats: - 1) "*+nnnn" "*-nnnnn" - 2) mm/dd - 3) mm/dd/yy -*/ + 1) "$FG,4$*+nnnn$FG,2$" "$FG,4$*-nnnnn$FG,2$" + 2) $FG,4$mm/dd$FG,2$ + 3) $FG,4$mm/dd/yy$FG,2$ +It also supports some functions + $FG,4$SM()$FG,2$ start of month + $FG,4$EM()$FG,2$ end of month + $FG,4$SM()$FG,2$ start of year + $FG,4$EY()$FG,2$ end of year +Full expressions are not implimented +but you can do stuff like $FG,4$SM(*-7)+3$FG,2$ +and it will return the 3rd day after +the start of month for seven days before +today. + +$FG$*/ LTDate A2LTDate(I1 *src2) +//ASCII date to LTDate { LTDate result=0; LTDateStruct d,d1; - I1 *src=MStringUtil(src2,SU_REMOVE_SPACES|SU_TO_UPPER), - *v=NewString(src), + I1 *src=MStrUtil(src2,SU_REMOVE_SPACES|SU_TO_UPPER), + *v=NewStr(src), *p1=src; BoolU4 start_month=FALSE,end_month=FALSE; BoolU4 start_year=FALSE,end_year=FALSE; @@ -611,7 +834,7 @@ LTDate A2LTDate(I1 *src2) p1++; if (*p1=='+' || *p1=='-') result.date=AtoI(p1,10,&p1); - result+=GetCurTimeLTDate; + result+=GetCurTimeLTDate+local_time_offset; } else { RemoveFirstSeg(p1,"/",v); //Put month into v d.month=AtoI(v); @@ -623,7 +846,7 @@ LTDate A2LTDate(I1 *src2) d.year+=2000; } else { d.day_of_month=AtoI(p1,10,&p1); - ToLTDateStruct(&d1,GetCurTimeLTDate); + ToLTDateStruct(&d1,GetCurTimeLTDate+local_time_offset); d.year=d1.year; } result=ToLTDate(&d); @@ -643,7 +866,7 @@ LTDate A2LTDate(I1 *src2) result.date+=AtoI(p1); Free(src); Free(v); - return result; + return result-local_time_offset; } void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) @@ -655,7 +878,8 @@ void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) 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 + if (!fmt) + throw(EXCEPT_GETF,0); while (ch = *(fmt++)) { if (ch=='%') { if (*fmt=='%') { @@ -672,6 +896,8 @@ void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) len=len*10+ (*(fmt++)-'0'); if (*fmt=='*') { fmt++; + if (cur_param>=argc) + throw(EXCEPT_GETF,1); len=argv[cur_param++]; } ch=*(fmt++); @@ -687,6 +913,8 @@ void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) dec_len=dec_len*10+ (*(fmt++)-'0'); if (*fmt=='*') { fmt++; + if (cur_param>=argc) + throw(EXCEPT_GETF,1); dec_len=argv[cur_param++]; } ch=*(fmt++); @@ -698,29 +926,47 @@ void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) buf[i]=0; switch (ch) { case 's': + if (cur_param>=argc) + throw(EXCEPT_GETF,1); pptr=argv[cur_param++]; StrCpy(*pptr,buf); break; case 'c': + if (cur_param>=argc) + throw(EXCEPT_GETF,1); ptr=argv[cur_param++]; *ptr=*buf; break; + case 'C': + if (cur_param>=argc) + throw(EXCEPT_GETF,1); + ptr=argv[cur_param++]; + *ptr=ToUpper(*buf); + break; case 'z': + if (cur_param+1>=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; *i_ptr=MatchListEntry(buf,argv[cur_param++]); break; case 'Z': + if (cur_param+1>=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; *i_ptr=MatchSysTextEntry(buf,argv[cur_param++]); break; case 'd': + if (cur_param>=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; *i_ptr=0; for (k=0;k=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; *i_ptr=0; for (k=0;k=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; *i_ptr=0; for (k=0;k=argc) + throw(EXCEPT_GETF,1); d_ptr=argv[cur_param++]; *d_ptr=A2Double(buf); break; case 'D': + if (cur_param>=argc) + throw(EXCEPT_GETF,1); i_ptr=argv[cur_param++]; - *i_ptr=A2LTDate(buf)>>32; + *i_ptr=A2LTDate(buf); break; } Free(buf); @@ -754,6 +1007,3 @@ void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) src++; } } - - - \ No newline at end of file diff --git a/LT/Compiler/StmtParser.CPZ b/LT/Compiler/StmtParser.CPZ new file mode 100644 index 0000000..9a956bb --- /dev/null +++ b/LT/Compiler/StmtParser.CPZ @@ -0,0 +1,1453 @@ +I8 CmpKeyWord(LexStruct *lx) +{ + I8 result=-1; + SysHashEntry *temph; + if (lx->token==TK_IDENT) + if (temph=lx->hash_entry) + if (temph->type == HTT_KEYWORD) + result=temph->user_data0; + return result; +} + +#define PVLM_LOCAL_VAR 0 +#define PVLM_FUNCTION_PARAM 1 +#define PVLM_CLASS 2 +#define PVLM_UNION 3 +void CmpParseVarList(LexStruct *lx,ClassStruct *tempc, + I8 mode,U8 union_base=MAX_I4) +{ + I8 i,j,k,old_flags; + U8 ptr_cnt,size; + ClassStruct *tempc1,*tempc2; + SysHashEntry *temph; + MemberListStruct *tempm; + ArrayDimStruct *tempad,*tempad1; + U1 *e; + if (mode!=PVLM_LOCAL_VAR || union_base!=MAX_I4) { + if (lx->token=='(' || lx->token=='{') + Lex(lx); + } + while (TRUE) { + while (lx->token==';') Lex(lx); + if (lx->token==')' || lx->token=='}') { + Lex(lx); + return; + } + if (lx->token=='.') { + if (Lex(lx)=='.') { + if (Lex(lx)=='.') { + Lex(lx); + tempm=MAllocZ(sizeof(MemberListStruct)); + tempm->register=-1; + tempm->flags=MLF_DOT_DOT_DOT; + tempm->member_class=sys_internal_types[IT_U8]; + tempm->str=NewStr("argc"); + tempc2=tempc->last_in_member_list; + tempc2->next=tempm; + tempc->last_in_member_list=tempm; + tempm->offset=tempc->size; + tempc->size+=8; + + tempm=MAllocZ(sizeof(MemberListStruct)); + tempm->register=-1; + tempm->flags=MLF_DOT_DOT_DOT; + tempm->member_class=sys_internal_types[IT_I8]; + tempm->str=NewStr("argv"); + tempm->cnt=127; //nonzero + tempc2=tempc->last_in_member_list; + tempc2->next=tempm; + tempc->last_in_member_list=tempm; + tempm->offset=tempc->size; + tempc->size+=8; + + if (lx->token==')' || lx->token=='}') + Lex(lx); + return; + } else + PrsExcept(lx,"ST_EXPECTING_TYPE"); + } else + PrsExcept(lx,"ST_EXPECTING_TYPE"); + } + temph=NULL; + if (lx->token==TK_IDENT) { + temph=lx->hash_entry; + k=CmpKeyWord(lx); + } + if (!temph) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (k==KW_UNION) { + Lex(lx); + CmpParseVarList(lx,tempc,mode,tempc->size); + } else { + tempc1=temph; + if (!(tempc1->type & (HTT_CLASS | HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + do { + LexPush(lx); + Lex(lx); //skip type + ptr_cnt=0; + tempm=MAllocZ(sizeof(MemberListStruct)); + tempm->register=-1; + if (mode==PVLM_FUNCTION_PARAM || mode==PVLM_LOCAL_VAR) { + k=CmpKeyWord(lx); + if (k==KW_REG) { + tempm->flags|=MLF_USE_REG_VARIABLE; + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + } else if (k==KW_NOREG) { + tempm->flags|=MLF_NO_REG_VARIABLE; + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + } + } + while (lx->token=='*') { + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + ptr_cnt++; + } + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_IDENTIFIER"); + tempm->member_class=tempc1; + tempm->str=lx->ident; + lx->ident=NULL; + tempc2=tempc->last_in_member_list; + tempc2->next=tempm; + tempc->last_in_member_list=tempm; + tempc->member_cnt++; + + if (Lex(lx)=='(') { + tempm->flags|=MLF_FUNCTION; + if (Lex(lx)!=')') { + tempm->parameter_cnt++; + while (lx->token!=')') { + if (lx->token==',') + tempm->parameter_cnt++; + Lex(lx); + } + } + Lex(lx); //skip ) + } + + i=1; + while (lx->token=='[') { + if (Lex(lx)==']) + ptr_cnt++; + else { + j=Expression(lx); + tempad1=&tempm->dim_list; + while (tempad1->next) { + tempad1->next->cnt*=j; + tempad1=tempad1->next; + } + tempad=MAlloc(sizeof(ArrayDimStruct)); + tempad1->next=tempad; + tempad->next=NULL; + tempad->cnt=1; + tempm->cnt= i*=j; + } + if (lx->token!=']') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACKET"); + Lex(lx); + } + tempm->member_class+=ptr_cnt*sizeof(ClassStruct); + if (tempm->flags & MLF_FUNCTION) { + tempm->return_class=tempm->member_class; + tempm->member_class=sys_internal_types[IT_PTR]+sizeof(ClassStruct); + } + tempc2=tempm->member_class; + i=tempc2->size; + j=(tempm->cnt)? tempm->cnt:1; + i*=j; + if (mode==PVLM_LOCAL_VAR) { + if (union_base!=MAX_I4) { + if (union_base-tempc->sizesize; + else + i=0; + } + if (i>=8) + tempc->size=(tempc->size-i)&~7; + else if (i>=4) + tempc->size=(tempc->size-i)&~3; + else if (i>=2) + tempc->size=(tempc->size-i)&~1; + else + tempc->size-=i; + tempm->offset=tempc->size; + if (lx->token=='=') { + LexPop(lx); + Lex(lx); + if (!PrsParseExpression(lx,TRUE)) + throw(EXCEPT_COMPILER,7); + } else + lx->stack_ptr--; + } else if (mode==PVLM_FUNCTION_PARAM) { + if (union_base!=MAX_I4) { + tempm->offset=union_base; + if (tempc->size-union_base<8) + tempc->size=8+union_base; + } else { + tempm->offset=tempc->size; + tempc->size+=8; + } + if (lx->token=='=') { + Lex(lx); + old_flags=lx->flags; + lx->flags&=~LF_HAS_MISC_DATA; + e=CompileExpression(lx); + if (!e) + throw(EXCEPT_COMPILER,8); + tempm->default_value=Call(e); //TODO: if lx->a + if (!(lx->flags & LF_HAS_MISC_DATA)) + DelExpression(e); + else if (lx->a) + PrsExcept(lx,"ST_STR_DEFAULT"); + tempm->flags|=MLF_DEFAULT_AVAILABLE; + lx->flags|=old_flags&LF_HAS_MISC_DATA; + } + lx->stack_ptr--; + } else { //CLASS + if (union_base!=MAX_I4) { + tempm->offset=union_base; + if (tempc->size-union_basesize=i+union_base; + } else { + tempm->offset=tempc->size; + tempc->size+=i; + } + do { + temph=NULL; + k=CmpKeyWord(lx); + if (k==KW_FMTSTR) { + if (Lex(lx)!=TK_STR) + PrsExcept(lx,"ST_EXPECTING_STR"); + tempm->fmtstr=LexExtendStr(lx,&size); + } else if (k==KW_FMTDATA) { + if (Lex(lx)!=TK_STR) + PrsExcept(lx,"ST_EXPECTING_STR"); + tempm->fmtdata=LexExtendStr(lx,&size); + } + } while (k==KW_FMTSTR || k==KW_FMTDATA); + lx->stack_ptr--; + } + + if (lx->token==',') { + if (mode==PVLM_FUNCTION_PARAM && union_base==MAX_I4) { + Lex(lx); + break; + } + } else if (lx->token==')' || lx->token=='}') { + Lex(lx); + return; + } else if (lx->token==';') { + Lex(lx); + if (mode==PVLM_LOCAL_VAR && union_base==MAX_I4) + return; + break; + } else + PrsExcept(lx,"ST_MISSING_SEMICOLON"); + } while (TRUE); + } + } +} + +void UndefinedExtern() +{ + PutSysTextErr("ST_UNDEFINED_EXTERN"); + throw(EXCEPT_UNDEF_EXTERN); +} + +void UnusedExternWarning(LexStruct *lx,ClassStruct *tempc) +{ + PrintFWarn("%S '%s'\r\n","ST_UNUSED_EXTERN",tempc->str); + lx->warning_cnt++; +} + +ClassStruct *CmpParseClass(LexStruct *lx,BoolU4 is_union,BoolU4 is_public,BoolU4 is_extern) +{ + ClassStruct *tempc; + SysHashTable *tempht; + AsmCtrlStruct *a=lx->a; + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_IDENTIFIER"); + if (is_extern) { + if (a) + tempht=a->glbl_hash; + else + tempht=lx->hash_table_list; + tempc=CmpClassNew; + tempc->str=lx->ident; + lx->ident=NULL; + AddSysHashEntry(tempc,tempht); + Bts(&tempc->flags,Cf_EXTERN); + SetSourceFileInfo(lx,tempc); + Lex(lx); + } else { + if (a) { + if (tempc=FindHashEntry(lx->ident,a->glbl_hash,HTT_CLASS)) { + if (!Bt(&tempc->flags,Cf_EXTERN)) + tempc=NULL; + else if (tempc->use_cnt<3) + UnusedExternWarning(lx,tempc); + } + tempht=a->glbl_hash; + } else { + tempht=lx->hash_table_list->next; + lx->hash_table_list->next=NULL; + if (tempc=FindHashEntry(lx->ident,lx->hash_table_list,HTT_CLASS)) { + if (!Bt(&tempc->flags,Cf_EXTERN)) + tempc=NULL; + else if (tempc->use_cnt<3) { + lx->hash_table_list->next=tempht; + UnusedExternWarning(lx,tempc); + } + } + lx->hash_table_list->next=tempht; + tempht=lx->hash_table_list; + } + if (!tempc) { + tempc=CmpClassNew; + tempc->str=lx->ident; + lx->ident=NULL; + AddSysHashEntry(tempc,tempht); + } else { + Free(tempc->source_link); + Free(tempc->index); + } + Btr(&tempc->flags,Cf_EXTERN); + if (is_public) + tempc->type|=HTT_PUBLIC; + SetSourceFileInfo(lx,tempc); + tempc->use_cnt=0; + Lex(lx); + CmpParseVarList(lx,tempc,PVLM_CLASS,(is_union)?0:MAX_I4); + } + return tempc; +} + +ClassStruct *CmpParseFunctionJoin(LexStruct *lx, + ClassStruct *temp_return,I1 *name,BoolU4 is_public,BoolU4 indirect) +{ + MemberListStruct *tempm; + AsmCtrlStruct *a=lx->a; + SysHashTable *tempht; + ClassStruct *tempc; + if (a) { + if (tempc=FindHashEntry(name,a->glbl_hash,HTT_FUNCTION)) { + if (tempc->type & HTT_IMPORT) + tempc=NULL; + else + if (tempc->use_cnt<3) + UnusedExternWarning(lx,tempc); + } + tempht=a->glbl_hash; + } else { + tempht=lx->hash_table_list->next; + lx->hash_table_list->next=NULL; + if (tempc=FindHashEntry(name,lx->hash_table_list,HTT_FUNCTION)) { + if (!Bt(&tempc->flags,Cf_EXTERN)) + tempc=NULL; + else if (tempc->use_cnt<3) { + lx->hash_table_list->next=tempht; + UnusedExternWarning(lx,tempc); + } + } + lx->hash_table_list->next=tempht; + tempht=lx->hash_table_list; + } + if (!tempc) { + tempc=CmpClassNew; + tempc->used_reg_mask=CALWAYS_TRASHED_MASK+CSTK_TEMPS_MASK; + tempc->trashed_reg_mask=CALWAYS_TRASHED_MASK+CSTK_TEMPS_MASK; + tempc->type=HTT_FUNCTION; + tempc->str=name; + if (a) { + tempc->executable_address=a->ip; + if (indirect) + AsmStoreCodeU8(lx,0); + } else + tempc->executable_address=&UndefinedExtern; + Bts(&tempc->flags,Cf_EXTERN); + AddSysHashEntry(tempc,tempht); + } else { + tempc->used_reg_mask=CALWAYS_TRASHED_MASK+CSTK_TEMPS_MASK; + Free(tempc->source_link); + Free(tempc->index); + Free(name); + DelMemberList(tempc); + } + if (is_public) + tempc->type|=HTT_PUBLIC; + else + tempc->type&=~HTT_PUBLIC; + tempc->return_class=temp_return; + tempc->use_cnt=0; + SetSourceFileInfo(lx,tempc); + CmpParseVarList(lx,tempc,PVLM_FUNCTION_PARAM); + tempc->parameter_cnt=tempc->member_cnt; + tempm=tempc->member_list; + while (tempm) { + tempm->offset+=16; //RBP+RETURN + tempm=tempm->next; + } + + tempc->size=0; + return tempc; +} + +void CmpParseFunction(LexStruct *lx, + ClassStruct *temp_return,I1 *name,BoolU4 is_public) +{ + U8 *result; + AsmCtrlStruct *a=lx->a; + ClassStruct *tempc; + MemberListStruct *tempm; + CbMiscStruct *saved_leave_label; + U8 i,j,size; + DbgInfo *dbg=NULL; + lx->flags&=~LF_NO_REG_OPT; + tempc=CmpParseFunctionJoin(lx,temp_return,name,is_public,FALSE); + lx->local_var_list=tempc; + CbPush(lx); + Btr(&lx->flags,LFf_OPT_TRACE_PRESENT); + CbInitOutPtrs(&lx->cb); + CbAddIc(lx,EC_ENTER,0,0); + saved_leave_label=lx->leave_label; + lx->leave_label=CbMiscNew(lx,CBMT_LABEL); + CmpParseStatement(lx,tempc,0,NULL,NULL,FALSE); + CbAddIc(lx,EC_LABEL,lx->leave_label,0); + lx->leave_label=saved_leave_label; + CbAddIc(lx,EC_LEAVE,0,tempc->return_class); + CbAddIc(lx,EC_NULL,0,0); + tempc->size&=~7; + if (a) { + tempc->executable_address=a->ip; + tempc->type|=HTT_EXPORT; + result=CbCompile(lx,tempc,&size,&dbg); + tempc->debug=dbg; + if (result) { + j=(size+7)>>3; + for (i=0;iip&7) + AsmStoreCodeU1(lx,OC_NOP); + Free(result); + } + } else { + tempc->executable_address=CbCompile(lx,tempc,&size,&dbg); + tempc->debug=dbg; + } + Btr(&tempc->flags,Cf_EXTERN); + CbPop(lx); + lx->local_var_list=NULL; + tempm=tempc->member_list; + while (tempm) { + if (!tempm->use_cnt && !(tempm->flags & MLF_NO_UNUSED_WARN)) { + PrintFWarn("%S\r\n $$LK-A,\"FL:%s,%d\"$$ '","ST_UNUSED_VAR", + lx->cur_lfn->name,lx->cur_lfn->line_num); + coutln tempm->str,"' in '",tempc->str,"'"; + } + tempm=tempm->next; + } +} + + +BoolU8 PrsVarInit(LexStruct *lx,U1 **dd,ClassStruct *tempc,U8 cnt,GlblVarStruct *tempg) +{ + U1 *d=*dd,*e; + U8 i,j,r,old_flags,type; + BoolU4 result=FALSE,stop; + MemberListStruct *tempm; + IntermediateCode *tempi; + + while (tempc->return_class) + tempc=tempc->return_class; + if (tempm=tempc->member_list) { + if (lx->token!='{') + PrsExcept(lx,"ST_EXPECTING_LEFT_BRACE"); + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + + while (tempm) { + if (tempm->cnt && lx->token=='{') { + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + } + j=(tempm->cnt) ? tempm->cnt:1; + stop=FALSE; + for (i=0;imember_class,tempm->cnt,tempg); + LexPush(lx); + if (lx->token==',') + Lex(lx); + } + if (tempm->cnt && lx->token=='}') + Lex(lx); + tempm=tempm->next; + } + lx->stack_ptr--; //grows up + if (lx->token!='}') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACE"); + Lex(lx); + } else { + if (tempc->type & HTT_INTERNAL_TYPE && + !tempc->ptr_cnt && cnt && + (tempc->sub_type==IT_I1 || tempc->sub_type==IT_U1) && + lx->token==TK_STR) { + lx->stack_ptr--; //grows up + e=LexExtendStr(lx,&i); + MemCpy(d,e,i); + d+=cnt; + result=TRUE; + } else { + old_flags=lx->flags; + lx->flags&=~(LF_HAS_MISC_DATA|LF_NOT_CONSTANT); + e=CompileExpression(lx,&type); + if (lx->a && lx->flags&LF_NOT_CONSTANT) { + DelExpression(e); + MemSet(d,0,tempc->size); + LexPop(lx); + Lex(lx); + CbAddIc(lx,EC_ABSOLUTE_ADDRESS,tempg->data_address,tempc+sizeof(ClassStruct)); + CbAddIc(lx,EC_IMM,d-&tempg->data,tempc+sizeof(ClassStruct)); + CbAddIc(lx,EC_ADD,0,tempc+sizeof(ClassStruct)); + if (!PrsParseExpression(lx,TRUE)) + throw(EXCEPT_COMPILER,10); + tempi=lx->cb.cb_last_out_ptr; + if (tempi->ic_opcode==EC_END_EXP) + tempi->ic_opcode=EC_NOP; + CbAddIc(lx,EC_ASSIGN,0,tempc); + CbAddIc(lx,EC_END_EXP,0,tempc); + } else { + lx->stack_ptr--; //grows up + if (!e) + throw(EXCEPT_COMPILER,10); + r=Call(e); + if (!(lx->flags & LF_HAS_MISC_DATA)) + DelExpression(e); + + if (type==IT_DOUBLE && + tempc->sub_type!=IT_DOUBLE) + r=r><(double); + else if (type!=IT_DOUBLE && + tempc->sub_type==IT_DOUBLE) + r><(double)=r; + + MemCpy(d,&r,tempc->size); + } + d+=tempc->size; + lx->flags|=old_flags&LF_HAS_MISC_DATA; + } + } + *dd=d; + return result; +} + +void PrsParseGlblInit(LexStruct *lx,GlblVarStruct *tempg) +{ + U1 *dd=&tempg->data; + U8 i,j; + ClassStruct *tempc=tempg->var_class; + BoolU4 stop=FALSE; + while (tempc->return_class) + tempc=tempc->return_class; + if (tempg->cnt && lx->token=='{') { + lx->stack_ptr--; //grows up + LexPush(lx); + Lex(lx); + } + j=(tempg->cnt) ? tempg->cnt:1; + for (i=0;icnt,tempg); + LexPush(lx); + if (j>1 && lx->token==',') + Lex(lx); + } + if (tempg->cnt && lx->token=='}') + Lex(lx); +} + +#define PG_NULL 0 +#define PG_LTEXTERN 1 +#define PG_LTINTERN 2 +#define PG_LTIMPORT 3 +#define PG_EXTERN 4 +#define PG_IMPORT 5 + +void CmpParseGlblVarList(LexStruct *lx,I8 saved_mode,ClassStruct *saved_tempc, + U8 saved_val,BoolU4 is_public) +{ + I8 i,j,mode; + U8 k,val; + I1 *st; + SysHashEntry *temph; + GlblVarStruct *tempg,*tempg1; + AsmCtrlStruct *a=lx->a; + ClassStruct *tempc,*tempc1; + ArrayDimStruct *tempad,*tempad1,*tempad2; + U1 *u1; + while (TRUE) { + Lex(lx); + tempc=saved_tempc; + val=saved_val; + mode=saved_mode; + while (lx->token=='*') { + Lex(lx); + tempc+=sizeof(ClassStruct); + } + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_IDENTIFIER"); + if ((temph=lx->hash_entry) && mode==PG_EXTERN && !a) { + if (temph->type & HTT_SYS_SYMBOL) { + val=temph->user_data0; + mode=PG_LTEXTERN; + } + } + if (CmpKeyWord(lx)==KW_UNION) { + Lex(lx); + tempc1=CmpParseClass(lx,TRUE,is_public,mode==PG_EXTERN); + tempc1->return_class=tempc; + return; + } else if (CmpKeyWord(lx)==KW_CLASS) { + Lex(lx); + tempc1=CmpParseClass(lx,FALSE,is_public,mode==PG_EXTERN); + tempc1->return_class=tempc; + return; + } + st=lx->ident; + lx->ident=NULL; + if (Lex(lx)=='(') { + if (mode==PG_LTINTERN) { + tempc1=CmpParseFunctionJoin(lx,tempc,st,is_public,FALSE); + tempc1->executable_address=val; + Bts(&tempc1->flags,Cf_INTERNAL); + Btr(&tempc1->flags,Cf_EXTERN); + return; + } else if (mode==PG_LTEXTERN) { + tempc1=CmpParseFunctionJoin(lx,tempc,st,is_public,FALSE); + tempc1->executable_address=val; + Btr(&tempc1->flags,Cf_EXTERN); + return; + } else if (mode==PG_EXTERN) { + CmpParseFunctionJoin(lx,tempc,st,is_public,FALSE); + return; + } else if (mode==PG_IMPORT || mode==PG_LTIMPORT) { + if (!a) + PrsExcept(lx,"ST_IMPORT_NOT_NEEDED"); + else { + tempc1=CmpParseFunctionJoin(lx,tempc,st,is_public,TRUE); + tempc1->type|=HTT_IMPORT; + if (mode==PG_LTIMPORT) + tempc1->import_name=NewStr(val); + else + tempc1->import_name=NewStr(st); + } + return; + } else { + CmpParseFunction(lx,tempc,st,is_public); + return; + } + } + i=0; + j=1; + tempad2=NULL; + while (lx->token=='[') { + if (Lex(lx)==']') + tempc+=sizeof(ClassStruct); + else { + j=Expression(lx); + tempad1=&tempad2; + while (tempad1->next) { + tempad1->next->cnt*=j; + tempad1=tempad1->next; + } + tempad=MAlloc(sizeof(ArrayDimStruct)); + tempad1->next=tempad; + tempad->next=NULL; + tempad->cnt=1; + if (!i) i=1; + i*=j; + } + if (lx->token!=']') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACKET"); + Lex(lx); + } + j=tempc->size; + if (i) j*=i; + if (mode==PG_LTEXTERN) { + tempg=MAllocZ(sizeof(GlblVarStruct)-8); + tempg->data_address=val; + if (a) + tempg->type=HTT_GLBL_VAR | HTT_EXPORT; + else + tempg->type=HTT_GLBL_VAR; + } else if (mode==PG_LTIMPORT || mode==PG_IMPORT) { + if (!a) + PrsExcept(lx,"ST_IMPORT_NOT_NEEDED"); + else { + tempg=MAllocZ(sizeof(GlblVarStruct)-8); + tempg->type=HTT_GLBL_VAR | HTT_IMPORT; + if (mode==PG_LTIMPORT) + tempg->import_name=NewStr(val); + else + tempg->import_name=NewStr(st); + tempg->data_address=a->ip; + AsmStoreCodeU8(lx,0); + } + } else if (mode==PG_EXTERN) { + tempg=MAllocZ(sizeof(GlblVarStruct)-8); + tempg->data_address=0; + if (a) + tempg->type=HTT_GLBL_VAR; + else + tempg->type=HTT_GLBL_VAR|HTT_UNRESOLVED_GLBL; + } else { + if (a) { + if (lx->token=='=') + tempg=MAllocZ(j+sizeof(GlblVarStruct)-8); + else + tempg=MAllocZ(sizeof(GlblVarStruct)-8); + tempg->data_address=a->ip; + tempg->type=HTT_GLBL_VAR | HTT_EXPORT; + if (temph && (temph->type & HTT_GLBL_VAR)) { + tempg1=temph; + tempg1->data_address=a->ip; + } + for (k=0;kdata_address=&tempg->data; + tempg->type=HTT_GLBL_VAR; + if (temph && temph->type&HTT_GLBL_VAR && + temph->type&HTT_UNRESOLVED_GLBL) { + tempg1=temph; //TODO: do not resolve extern variables in parent tasks + tempg1->data_address=&tempg->data; + } + } + } + tempg->dim_list=tempad2; + if (is_public) + tempg->type|=HTT_PUBLIC; + tempg->flags=0; + tempg->parameter_cnt=0; + tempg->var_class=tempc; + tempg->str=st; + tempg->size=j; + tempg->cnt=i; + tempg->use_cnt=0; + SetSourceFileInfo(lx,tempg); + if (mode==PG_IMPORT || mode==PG_LTIMPORT) + tempg->flags|=GVAF_IMPORT; + if (mode==PG_EXTERN) + tempg->flags|=GVAF_EXTERN; + if (a) + AddSysHashEntry(tempg,a->glbl_hash); + else + AddSysHashEntry(tempg,lx->hash_table_list); + if (lx->token=='=') { + LexPush(lx); + Lex(lx); + PrsParseGlblInit(lx,tempg); + if (a) { + u1=&tempg->data; + for (k=0;ksize;k++) + AsmStoreCodeU1At(lx,u1[k],tempg->data_address+k); + } + lx->stack_ptr--; //grows up + } + if (lx->token!=',') { + if (lx->token!=';') + PrsExcept(lx,"ST_MISSING_SEMICOLON"); + Lex(lx); + return; + } + } +} + +void CmpParseIf(LexStruct *lx,ClassStruct *locals,I8 try_count, + CbMiscStruct *break_label,CbMiscStruct *continue_label) +{ + CbMiscStruct *templ,*templ1; + I8 k; + + if (lx->token!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + Lex(lx); + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,11); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + templ=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_BR_ZERO,templ,0); + CmpParseStatement(lx,locals,try_count,break_label,continue_label); + k=CmpKeyWord(lx); + if (k==KW_ELSE) { + Lex(lx); + templ1=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_JMP,templ1,0); + CbAddIc(lx,EC_LABEL,templ,0); + CmpParseStatement(lx,locals,try_count,break_label,continue_label); + CbAddIc(lx,EC_LABEL,templ1,0); + } else + CbAddIc(lx,EC_LABEL,templ,0); +} + +void CmpParseWhile(LexStruct *lx,ClassStruct *locals,I8 try_count) +{ + CbMiscStruct *templ,*templ1; + + if (lx->token!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + Lex(lx); + templ=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_LABEL,templ,0); + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,12); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + + templ1=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_BR_ZERO,templ1,0); + CmpParseStatement(lx,locals,try_count,templ1,templ); + CbAddIc(lx,EC_JMP,templ,0); + CbAddIc(lx,EC_LABEL,templ1,0); +} + +void CmpParseDoWhile(LexStruct *lx,ClassStruct *locals,I8 try_count) +{ + CbMiscStruct *templ,*templ1; + + templ=CbMiscNew(lx,CBMT_LABEL); + templ1=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_LABEL,templ,0); + CmpParseStatement(lx,locals,try_count,templ1,templ); + if (CmpKeyWord(lx)!=KW_WHILE) + PrsExcept(lx,"ST_MISSING_WHILE"); + if (Lex(lx)!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + Lex(lx); + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,13); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + CbAddIc(lx,EC_BR_NOT_ZERO,templ,0); + CbAddIc(lx,EC_LABEL,templ1,0); + if (Lex(lx)!=';') + PrsExcept(lx,"ST_MISSING_SEMICOLON"); + Lex(lx); +} + +void CmpParseFor(LexStruct *lx,ClassStruct *locals,I8 try_count) +{ + LexCbStack *templs; + CbMiscStruct *templ,*templ1,*templ2; + + if (lx->token!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + Lex(lx); + CmpParseStatement(lx,locals,try_count); + + templ=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_LABEL,templ,0); + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,14); + templ1=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_BR_ZERO,templ1,0); + if (lx->token!=';') + PrsExcept(lx,"ST_MISSING_SEMICOLON"); + Lex(lx); + + CbPush(lx); + CbInitOutPtrs(&lx->cb); + templ2=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_LABEL,templ2,0); + if (lx->token!=')') + CmpParseStatement(lx,locals,try_count,NULL,NULL,FALSE); + CbAddIc(lx,EC_NULL,0,0); + CbPush(lx); + templs=CbPopNoFree(lx); + CbPop(lx); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + Lex(lx); + + CmpParseStatement(lx,locals,try_count,templ1,templ2); + CbAppend(lx,templs); + CbAddIc(lx,EC_JMP,templ,0); + CbAddIc(lx,EC_LABEL,templ1,0); +} + + +class SwitchCaseEntry { + SwitchCaseEntry *next; + CbMiscStruct *label; + U8 value; +}; + +void CmpParseSwitch(LexStruct *lx,ClassStruct *locals,I8 try_count) +{ + SwitchCaseEntry *header=NULL,*temps,*temps1; + CbMiscStruct *templ_break,*templ_default,*templ_jmp; + IntermediateCode *tempi_sub,*tempi_cmp; + AsmCtrlStruct *a=lx->a; + BoolU4 default_found=FALSE; + I8 i,k; + I8 lo=MAX_I8,hi=MIN_I8,range; + U8 *jmp_table; + + if (lx->token!='(') + PrsExcept(lx,"ST_EXPECTING_LEFT_PAREN"); + Lex(lx); + templ_break=CbMiscNew(lx,CBMT_LABEL); + templ_default=CbMiscNew(lx,CBMT_LABEL); + templ_jmp=CbMiscNew(lx,CBMT_JMP_TABLE); + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,15); + CbAddIc(lx,EC_IMM,0,sys_internal_types[IT_I8]); + tempi_sub=lx->cb.cb_last_out_ptr; + CbAddIc(lx,EC_SUB,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_IMM,0,sys_internal_types[IT_I8]); + tempi_cmp=lx->cb.cb_last_out_ptr; + CbAddIc(lx,EC_SWITCH,templ_jmp,0); + CbAddIc(lx,EC_JMP,templ_default,0); + if (lx->token!=')') + PrsExcept(lx,"ST_MISSING_RIGHT_PAREN"); + if (Lex(lx)!='{') + PrsExcept(lx,"ST_EXPECTING_LEFT_BRACE"); + Lex(lx); + while (lx->token && lx->token!='}') { + k=CmpKeyWord(lx); + if (k==KW_CASE) { + Lex(lx); + temps=MAlloc(sizeof(SwitchCaseEntry)); + temps->label=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_LABEL,temps->label,0); + temps->label->flags|=CBMF_USED; + k=Expression(lx); + if (lx->token!=':') + PrsExcept(lx,"ST_EXPECTING_COLON"); + Lex(lx); + if (khi) hi=k; + temps->value=k; + temps->next=header; + header=temps; + } else if (k==KW_DEFAULT) { + if (Lex(lx)==':') + Lex(lx); + CbAddIc(lx,EC_LABEL,templ_default,0); + default_found=TRUE; + } else + CmpParseStatement(lx,locals,try_count,templ_break,NULL); + } + if (!default_found) + CbAddIc(lx,EC_LABEL,templ_default,0); + CbAddIc(lx,EC_LABEL,templ_break,0); + if (lx->token!='}') + PrsExcept(lx,"ST_MISSING_RIGHT_BRACE"); + Lex(lx); + + range=hi-lo+1; + if (range<=0 || range>0x4000) + PrsExcept(lx,"ST_CASE_RANGE_ERROR"); + jmp_table=MAlloc(sizeof(U8)*range); + for (i=0;iic_data=lo; + tempi_cmp->ic_data=range; + temps=header; + while (temps) { + temps1=temps->next; + jmp_table[temps->value-lo]=temps->label; + Free(temps); + temps=temps1; + } + templ_jmp->jmp_table=jmp_table; + templ_jmp->st_len=range; +} + +void CmpParseNoUnusedWarn(LexStruct *lx) +{ + MemberListStruct *tempm; + while (lx->token==TK_IDENT) { + if (!(tempm=lx->local_var_entry)) + PrsExcept(lx,"ST_EXPECTING_LOCAL_VARIABLE"); + tempm->flags|=MLF_NO_UNUSED_WARN; + Lex(lx); + if (lx->token==',') + Lex(lx); + else { + if (lx->token!=';') + PrsExcept(lx,"ST_EXPECTING_COMMA"); + } + } +} + +void CmpParseCout(LexStruct *lx,BoolU4 linefeed) +{ + ClassStruct *tempc; + SysHashEntry *temph; + IntermediateCode *tempi; + I8 cnt=0,i,j; + + CbAddIc(lx,EC_CALL_START,0,0); + while (lx->token!=';') { + cnt++; + if (!PrsParseExpression(lx,FALSE)) + throw(EXCEPT_COMPILER,16); + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + tempi=lx->cb.cb_last_out_ptr; + tempc=tempi->ic_class; + j=tempc->ptr_cnt; + tempc-=sizeof(ClassStruct)*j; + while (tempc->return_class) + tempc=tempc->return_class; + temph=tempc; + if (temph->type & HTT_INTERNAL_TYPE) + i=tempc->sub_type+j*IT_NUM_IT; + else + i=IT_I8; + CbAddIc(lx,EC_TYPE,i,sys_internal_types[IT_I8]); + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + if (lx->token==',' || lx->token==TK_SHL) + Lex(lx); + else { + if (lx->token!=';') + PrsExcept(lx,"ST_EXPECTING_COMMA"); + } + } + CbAddIc(lx,EC_IMM,cnt,sys_internal_types[IT_U8]); + CbAddIc(lx,EC_SET_RAX,0,sys_internal_types[IT_U8]); + if (linefeed) + CbAddIc(lx,EC_IRQ,I_COUTLN,0); + else + CbAddIc(lx,EC_IRQ,I_COUT,0); + CbAddIc(lx,EC_ADD_RSP,cnt<<4,0); + CbAddIc(lx,EC_CALL_END,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_END_EXP,0,0); +} + +void CmpParseExeBlk(LexStruct *lx) +{ + AsmCtrlStruct *a=lx->a; + SysHashTable *ht1=lx->hash_table_list, + *ht2=lx->define_hash_table; + U8 old_hash_mask=lx->hash_mask; + U8 old_flags=lx->flags & (LF_ASM_EXPRESSIONS | LF_EXE_BLK); + ExeBlkStruct *tempe=MAlloc(sizeof(ExeBlkStruct)); + MemberListStruct *old_var_list=lx->local_var_list; + lx->local_var_list=NULL; + + tempe->body=NewStr(""); + InsQue(tempe,lx->last_exe_blk); + CbPush(lx); //TODO Misc lists + lx->hash_mask=HTT_ALL; + lx->hash_table_list=Fs->hash_table; + lx->define_hash_table=Fs->hash_table; + lx->flags=(lx->flags & ~LF_ASM_EXPRESSIONS) | + LF_EXE_BLK; + lx->a=NULL; + if (lx->token=='{') + Lex(lx); + else + PrsExcept(lx,"ST_MISSING_RIGHT_BRACE"); + while (lx->token && lx->token!='}') + ExecuteCmdLine(lx); + lx->a=a; + lx->hash_table_list=ht1, + lx->define_hash_table=ht2; + lx->local_var_list=old_var_list; + lx->hash_mask=old_hash_mask; + lx->flags=(lx->flags&~LF_EXE_BLK) | old_flags; + CbPop(lx); + RemQue(tempe); + if (*tempe->body) + LexIncludeStr(lx,"ExeBlk",tempe->body,FALSE); + else + Free(tempe->body); + Free(tempe); + Lex(lx); //Skip "}" +} + + +void CmpParseTryBlk(LexStruct *lx,ClassStruct *locals,I8 try_count) +{ + CbMiscStruct *templ,*templ1,*templ2; + ClassStruct *d=sys_internal_types[IT_PTR], + *temp_try=FindHashEntry("SysTry",lx->hash_table_list,HTT_FUNCTION), + *temp_catch=FindHashEntry("SysCatch",lx->hash_table_list,HTT_FUNCTION); + + lx->flags|=LF_NO_REG_OPT; //TODO + + templ=CbMiscNew(lx,CBMT_LABEL); + templ1=CbMiscNew(lx,CBMT_LABEL); + templ2=CbMiscNew(lx,CBMT_LABEL); + CbAddIc(lx,EC_CALL_START,0,0); + CbAddIc(lx,EC_GET_LABEL,templ2,d); + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + CbAddIc(lx,EC_GET_LABEL,templ,d); + lx->cb.cb_last_out_ptr->ic_flags|=ICF_PUSH_RESULT; + if (Bt(&temp_try->flags,Cf_EXTERN)) { + if (lx->a) + CbAddIc(lx,EC_CALL_INDIRECT2,temp_try->executable_address,d); + else + CbAddIc(lx,EC_CALL_INDIRECT2,&temp_try->executable_address,d); + } else + CbAddIc(lx,EC_CALL,temp_try->executable_address,d); + CbAddIc(lx,EC_ADD_RSP,16,d); + CbAddIc(lx,EC_CALL_END,0,d); + CbAddIc(lx,EC_END_EXP,0,0); + + if (try_count<0) + CmpParseStatement(lx,locals,try_count-1); + else + CmpParseStatement(lx,locals,try_count+1); + + CbAddIc(lx,EC_LABEL,templ2,0); + CbAddIc(lx,EC_CALL_START,0,0); + if (Bt(&temp_catch->flags,Cf_EXTERN)) { + if (lx->a) + CbAddIc(lx,EC_CALL_INDIRECT2,temp_catch->executable_address,d); + else + CbAddIc(lx,EC_CALL_INDIRECT2,&temp_catch->executable_address,d); + } else + CbAddIc(lx,EC_CALL,temp_catch->executable_address,d); + CbAddIc(lx,EC_CALL_END,0,d); + CbAddIc(lx,EC_END_EXP,0,0); + + CbAddIc(lx,EC_JMP,templ1,0); + + if (CmpKeyWord(lx)!=KW_CATCH) + PrsExcept(lx,"ST_MISSING_CATCH"); + Lex(lx); + + CbAddIc(lx,EC_LABEL,templ,0); + if (try_count<0) + CmpParseStatement(lx,locals,try_count-1); + else + CmpParseStatement(lx,locals,-try_count-1); + CbAddIc(lx,EC_RET,0,d); + CbAddIc(lx,EC_LABEL,templ1,0); +} + + +BoolU8 CmpParseStatement(LexStruct *lx,ClassStruct *locals,I8 try_count=0, + CbMiscStruct *break_label=NULL,CbMiscStruct *continue_label=NULL, + BoolU4 saved_prs_semicolon=TRUE) +{ + BoolU4 prs_exp,cont,prs_semicolon,is_asm=FALSE, + is_public=FALSE,last_is_public=FALSE; + U8 i; + SysHashEntry *temph; + CbMiscStruct *templ; + I1 *import_name; + ClassStruct *d,*temp_catch; + do { + is_public=FALSE; + cont=FALSE; + prs_exp=FALSE; + prs_semicolon=saved_prs_semicolon; + lx->statement_cnt++; + while (lx->token==',') + Lex(lx); + if (lx->token=='{') { + lx->braces_cnt++; + Lex(lx); + while (lx->token!='}') + CmpParseStatement(lx,locals,try_count,break_label,continue_label); + lx->braces_cnt--; + lx->statement_cnt--; + Lex(lx); + } else if (lx->token==TK_EOF) ; + else if (lx->token==';') { + if (prs_semicolon) { + lx->statement_cnt--; + Lex(lx); + } + } else { + if (lx->token==TK_IDENT) { + if (temph=lx->hash_entry) { + if (temph->type & HTT_KEYWORD) { + i=temph->user_data0; + switch (i) { + case KW_IF: + Lex(lx); + CmpParseIf(lx,locals,try_count,break_label,continue_label); + prs_semicolon=FALSE; + break; + case KW_FOR: + Lex(lx); + CmpParseFor(lx,locals,try_count); + prs_semicolon=FALSE; + break; + case KW_WHILE: + Lex(lx); + CmpParseWhile(lx,locals,try_count); + prs_semicolon=FALSE; + break; + case KW_DO: + Lex(lx); + CmpParseDoWhile(lx,locals,try_count); + prs_semicolon=FALSE; + break; + case KW_SWITCH: + Lex(lx); + CmpParseSwitch(lx,locals,try_count); + prs_semicolon=FALSE; + break; + case KW_LTEXTERN: + Lex(lx); + if (Bt(&lx->flags,LFf_EXTERNS_TO_IMPORTS)) + goto keyword_LTimport; + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_SYS_SYMBOL"); + if (!(temph=lx->hash_entry)) + PrsExcept(lx,"ST_EXPECTING_SYS_SYMBOL"); + if (!(temph->type & HTT_SYS_SYMBOL)) + PrsExcept(lx,"ST_EXPECTING_SYS_SYMBOL"); + i=temph->user_data0; + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph=lx->hash_entry)) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (locals) + PrsExcept(lx,"ST_NOT_ALLOWED_IN_FUNCTION"); + CmpParseGlblVarList(lx,PG_LTEXTERN,temph,i,last_is_public); + prs_semicolon=FALSE; + cont=TRUE; + break; + case KW_LTIMPORT: + Lex(lx); +keyword_LTimport: + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_SYS_SYMBOL"); + import_name=lx->ident; + lx->ident=0; + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph=lx->hash_entry)) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (locals) + PrsExcept(lx,"ST_NOT_ALLOWED_IN_FUNCTION"); + CmpParseGlblVarList(lx,PG_LTIMPORT,temph,import_name,FALSE); + Free(import_name); + prs_semicolon=FALSE; + cont=TRUE; + break; + case KW_INTERNAL: + Lex(lx); + if (lx->token!=TK_INTEGER) + PrsExcept(lx,"ST_EXPECTING_INTEGER"); + i=lx->cur_i; + if (Lex(lx)!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph=lx->hash_entry)) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (locals) + PrsExcept(lx,"ST_NOT_ALLOWED_IN_FUNCTION"); + CmpParseGlblVarList(lx,PG_LTINTERN,temph,i,last_is_public); + prs_semicolon=FALSE; + cont=TRUE; + break; + case KW_EXTERN: + Lex(lx); + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + temph=lx->hash_entry; + if (locals) + PrsExcept(lx,"ST_NOT_ALLOWED_IN_FUNCTION"); + if (CmpKeyWord(lx)==KW_CLASS) { + Lex(lx); + CmpParseClass(lx,FALSE,last_is_public,TRUE); + } else if (CmpKeyWord(lx)==KW_UNION) { + Lex(lx); + CmpParseClass(lx,TRUE,last_is_public,TRUE); + } else { + if (!temph || !(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (Bt(&lx->flags,LFf_EXTERNS_TO_IMPORTS)) + goto keyword_import; + CmpParseGlblVarList(lx,PG_EXTERN,temph,0,last_is_public); + prs_semicolon=FALSE; + cont=TRUE; + } + break; + case KW_IMPORT: + Lex(lx); + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (locals) + PrsExcept(lx,"ST_NOT_ALLOWED_IN_FUNCTION"); + if (!(temph=lx->hash_entry)) + PrsExcept(lx,"ST_EXPECTING_TYPE"); + if (!(temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE))) + PrsExcept(lx,"ST_EXPECTING_TYPE"); +keyword_import: + CmpParseGlblVarList(lx,PG_IMPORT,temph,0,FALSE); + prs_semicolon=FALSE; + cont=TRUE; + break; + case KW_ASM: + Lex(lx); + CmpParseAsmBlk(lx); + prs_semicolon=FALSE; + is_asm=TRUE; + break; + case KW_TRY: + Lex(lx); + CmpParseTryBlk(lx,locals,try_count); + prs_semicolon=FALSE; + break; + case KW_BREAK: + Lex(lx); + if (!break_label) + PrsExcept(lx,"ST_BREAK_NOT_ALLOWED"); + CbAddIc(lx,EC_JMP,break_label,0); + break; + case KW_CONTINUE: + Lex(lx); + if (!continue_label) + PrsExcept(lx,"ST_CONTINUE_NOT_ALLOWED"); + CbAddIc(lx,EC_JMP,continue_label,0); + break; + case KW_RETURN: + CbAddIc(lx,EC_RETURN_START,0,0); + Lex(lx); + if (lx->token!=';') { + if (!PrsParseExpression(lx,TRUE)) + throw(EXCEPT_COMPILER,17); + } + if (try_count<0) {//inside catch{} + CbAddIc(lx,EC_GET_BASE_PTR,0,0); + CbAddIc(lx,EC_IMM,locals->size,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_ADD,0,sys_internal_types[IT_I8]); + CbAddIc(lx,EC_SET_STACK_PTR,0,0); + try_count=-try_count; //force removal from queue + } + if (try_count) { + d=sys_internal_types[IT_PTR]; + temp_catch=FindHashEntry("SysCatch", + lx->hash_table_list,HTT_FUNCTION); + for (i=0;iflags,Cf_EXTERN)) { + if (lx->a) + CbAddIc(lx,EC_CALL_INDIRECT2, + temp_catch->executable_address,d); + else + CbAddIc(lx,EC_CALL_INDIRECT2, + &temp_catch->executable_address,d); + } else + CbAddIc(lx,EC_CALL,temp_catch->executable_address,d); + CbAddIc(lx,EC_ADD_RSP,8,d); + } + } + CbAddIc(lx,EC_RETURN_END,0,locals->return_class); + if (locals) + CbAddIc(lx,EC_JMP,lx->leave_label,0); + else + CbAddIc(lx,EC_RET,0,0); + break; + case KW_GOTO: + Lex(lx); + if (lx->token!=TK_IDENT) + PrsExcept(lx,"ST_EXPECTING_IDENTIFIER"); + if (!(templ=CbFindGotoLabel(lx,lx->ident))) { + templ=CbMiscNew(lx,CBMT_GOTO_LABEL); + templ->str=lx->ident; + lx->ident=NULL; + } + CbAddIc(lx,EC_JMP,templ,0); + Lex(lx); + break; + case KW_NOUNUSEDWARN: + Lex(lx); + CmpParseNoUnusedWarn(lx); + break; + case KW_COUT: + Lex(lx); + CmpParseCout(lx,FALSE); + break; + case KW_COUTLN: + Lex(lx); + CmpParseCout(lx,TRUE); + break; + case KW_CLASS: + Lex(lx); + CmpParseClass(lx,FALSE,last_is_public,FALSE); + break; + case KW_UNION: + Lex(lx); + CmpParseClass(lx,TRUE,last_is_public,FALSE); + break; + case KW_PUBLIC: + Lex(lx); + is_public=TRUE; + cont=TRUE; + prs_semicolon=FALSE; + break; + default: + prs_exp=TRUE; + break; + } + } else if (temph->type & (HTT_CLASS|HTT_INTERNAL_TYPE)) { + if (locals) { + CmpParseVarList(lx,locals,PVLM_LOCAL_VAR); + if (lx->token=='}') + cont=FALSE; + else + cont=TRUE; + } else { + CmpParseGlblVarList(lx,PG_NULL,temph,0,last_is_public); + cont=TRUE; + } + prs_semicolon=FALSE; + } else prs_exp=TRUE; + } else { + if (lx->local_var_entry) + prs_exp=TRUE; + else { + if (!(templ=CbFindGotoLabel(lx,lx->ident))) { + templ=CbMiscNew(lx,CBMT_GOTO_LABEL); + templ->str=lx->ident; + lx->ident=NULL; + } + CbAddIc(lx,EC_LABEL,templ,0); + if (Lex(lx)==':') //skip ident + Lex(lx); //skip colon + else + PrsExcept(lx,"ST_UNDEFINED_IDENTIFIER"); + prs_semicolon=FALSE; + } + } + } else prs_exp=TRUE; + if (prs_exp) { + if (!PrsParseExpression(lx,TRUE)) + throw(EXCEPT_COMPILER,18); + } + if (lx->token!=',') + lx->statement_cnt--; + if (prs_semicolon && lx->token!=',') { + if (lx->token==';') + Lex(lx); + else + PrsExcept(lx,"ST_MISSING_SEMICOLON"); + } + } + last_is_public=is_public; + } while (lx->token==',' || cont); + return is_asm; +} diff --git a/LT/DEMO/AutoFile/Demo2.AUZ b/LT/DEMO/AutoFile/Demo2.AUZ deleted file mode 100644 index 897cc5c..0000000 --- a/LT/DEMO/AutoFile/Demo2.AUZ +++ /dev/null @@ -1,9 +0,0 @@ -/* 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"); \ No newline at end of file diff --git a/LT/DEMO/AutoFile/Demo3.TXZ b/LT/DEMO/AutoFile/Demo3.TXZ deleted file mode 100644 index 95d1e28..0000000 Binary files a/LT/DEMO/AutoFile/Demo3.TXZ and /dev/null differ diff --git a/LT/DEMO/AutoFile/Demo4.CPZ b/LT/DEMO/AutoFile/Demo4.CPZ deleted file mode 100644 index 8105a47..0000000 --- a/LT/DEMO/AutoFile/Demo4.CPZ +++ /dev/null @@ -1,12 +0,0 @@ -/* 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; diff --git a/LT/DEMO/Caller.CPZ b/LT/DEMO/Caller.CPZ deleted file mode 100644 index 31f647d..0000000 --- a/LT/DEMO/Caller.CPZ +++ /dev/null @@ -1,23 +0,0 @@ -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; diff --git a/LT/DEMO/CircleTrace.CPZ b/LT/DEMO/CircleTrace.CPZ deleted file mode 100644 index 6f6bb09..0000000 Binary files a/LT/DEMO/CircleTrace.CPZ and /dev/null differ diff --git a/LT/DEMO/DateTime.CPZ b/LT/DEMO/DateTime.CPZ deleted file mode 100644 index 9fd5e68..0000000 --- a/LT/DEMO/DateTime.CPZ +++ /dev/null @@ -1,9 +0,0 @@ -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); - diff --git a/LT/DEMO/Dawg.CPZ b/LT/DEMO/Dawg.CPZ deleted file mode 100644 index 331b5dd..0000000 --- a/LT/DEMO/Dawg.CPZ +++ /dev/null @@ -1,145 +0,0 @@ -//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;jtimeout_jiffies && j<20) { - key_hit=TRUE; - ch=0; - break; - } - if (ScanChar(&sc,&ch)) { - key_hit=TRUE; - break; - } - for (i=0;itimeout_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_lotimeout_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 diff --git a/LT/DEMO/Debug/Test.CPZ b/LT/DEMO/Debug/Test.CPZ deleted file mode 100644 index d29f0a0..0000000 Binary files a/LT/DEMO/Debug/Test.CPZ and /dev/null differ diff --git a/LT/DEMO/Doodle.CPZ b/LT/DEMO/Doodle.CPZ deleted file mode 100644 index 603aa9f..0000000 Binary files a/LT/DEMO/Doodle.CPZ and /dev/null differ diff --git a/LT/DEMO/Doodle2.CPZ b/LT/DEMO/Doodle2.CPZ deleted file mode 100644 index b362357..0000000 Binary files a/LT/DEMO/Doodle2.CPZ and /dev/null differ diff --git a/LT/DEMO/GetInput.CPZ b/LT/DEMO/GetInput.CPZ deleted file mode 100644 index aa50e52..0000000 Binary files a/LT/DEMO/GetInput.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/Blot.CPZ b/LT/DEMO/Graphics/Blot.CPZ deleted file mode 100644 index bce68c4..0000000 --- a/LT/DEMO/Graphics/Blot.CPZ +++ /dev/null @@ -1,29 +0,0 @@ -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); - diff --git a/LT/DEMO/Graphics/Box.CPZ b/LT/DEMO/Graphics/Box.CPZ deleted file mode 100644 index 2b28da0..0000000 --- a/LT/DEMO/Graphics/Box.CPZ +++ /dev/null @@ -1,60 +0,0 @@ -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; \ No newline at end of file diff --git a/LT/DEMO/Graphics/DotNet.CPZ b/LT/DEMO/Graphics/DotNet.CPZ deleted file mode 100644 index 9d50d64..0000000 --- a/LT/DEMO/Graphics/DotNet.CPZ +++ /dev/null @@ -1,12 +0,0 @@ -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 \ No newline at end of file diff --git a/LT/DEMO/Graphics/Sprite1.CPZ b/LT/DEMO/Graphics/Sprite1.CPZ deleted file mode 100644 index 8538991..0000000 Binary files a/LT/DEMO/Graphics/Sprite1.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/Sprite2.CPZ b/LT/DEMO/Graphics/Sprite2.CPZ deleted file mode 100644 index 59f66b8..0000000 Binary files a/LT/DEMO/Graphics/Sprite2.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/Sprite3.CPZ b/LT/DEMO/Graphics/Sprite3.CPZ deleted file mode 100644 index 3665e1a..0000000 Binary files a/LT/DEMO/Graphics/Sprite3.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/StarTrek1.CPZ b/LT/DEMO/Graphics/StarTrek1.CPZ deleted file mode 100644 index 75f20c3..0000000 Binary files a/LT/DEMO/Graphics/StarTrek1.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/StarTrek2.CPZ b/LT/DEMO/Graphics/StarTrek2.CPZ deleted file mode 100644 index 3a28665..0000000 Binary files a/LT/DEMO/Graphics/StarTrek2.CPZ and /dev/null differ diff --git a/LT/DEMO/Graphics/StarTrek3.CPZ b/LT/DEMO/Graphics/StarTrek3.CPZ deleted file mode 100644 index 3959fbd..0000000 Binary files a/LT/DEMO/Graphics/StarTrek3.CPZ and /dev/null differ diff --git a/LT/DEMO/Music.CPZ b/LT/DEMO/Music.CPZ deleted file mode 100644 index baa6aec..0000000 --- a/LT/DEMO/Music.CPZ +++ /dev/null @@ -1,20 +0,0 @@ -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"); \ No newline at end of file diff --git a/LT/DEMO/Sound.CPZ b/LT/DEMO/Sound.CPZ deleted file mode 100644 index 3d88bbb..0000000 --- a/LT/DEMO/Sound.CPZ +++ /dev/null @@ -1,15 +0,0 @@ -//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; \ No newline at end of file diff --git a/LT/DEMO/Spy.CPZ b/LT/DEMO/Spy.CPZ deleted file mode 100644 index 57e2a4b..0000000 --- a/LT/DEMO/Spy.CPZ +++ /dev/null @@ -1,15 +0,0 @@ -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); -} \ No newline at end of file diff --git a/LT/DEMO/TreeDemo.CPZ b/LT/DEMO/TreeDemo.CPZ deleted file mode 100644 index 5b43f3b..0000000 Binary files a/LT/DEMO/TreeDemo.CPZ and /dev/null differ diff --git a/LT/DEMO/TreeDemoJoin.CPZ b/LT/DEMO/TreeDemoJoin.CPZ deleted file mode 100644 index 00446e4..0000000 --- a/LT/DEMO/TreeDemoJoin.CPZ +++ /dev/null @@ -1,22 +0,0 @@ -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; - } -} diff --git a/LT/DEMO/WinMgr2.CPZ b/LT/DEMO/WinMgr2.CPZ deleted file mode 100644 index e121a34..0000000 --- a/LT/DEMO/WinMgr2.CPZ +++ /dev/null @@ -1,183 +0,0 @@ -//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;iend_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;istate+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->xx=x-8; - if (tempo->yy=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"); diff --git a/LT/DOC/GuideLines.TXZ b/LT/DOC/GuideLines.TXZ deleted file mode 100644 index a486e1f..0000000 --- a/LT/DOC/GuideLines.TXZ +++ /dev/null @@ -1,88 +0,0 @@ -$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$. diff --git a/LT/DOC/Help.TXZ b/LT/DOC/Help.TXZ deleted file mode 100644 index 92d7bf5..0000000 --- a/LT/DOC/Help.TXZ +++ /dev/null @@ -1,78 +0,0 @@ -$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. - diff --git a/LT/DOC/Install.TXZ b/LT/DOC/Install.TXZ deleted file mode 100644 index 21789b9..0000000 --- a/LT/DOC/Install.TXZ +++ /dev/null @@ -1,31 +0,0 @@ -$WW,1$$FG,5$$TX+CX,"Preinstallation Notes"$$FG$ - -1) The CD-ROM INSTALL or UPGRADE boot options will automate much of this. - -2) Make partitions with Windows or Linux. You used to do it with FDISK, now you do it during installation. - -3) Only LBA 28 bit disk access is supported, so drives of size 120Gig are the limit. Ancient drives with CHS are not supported. - -4) Test your hard drive by adding it with $LK,"AddDrives","MN:AddDrives"$(). Typically, hard drives are "ATA" not "ATAPI", and are found at port address 0x1F0, unit 0. When AddDrives() displays defined partitions, make sure your partition shows-up. Note the drive letter, though you can move them around. $LK,"PartitionRep","MN:PartitionRep"$() will give a report. - -5) $BK,1$WARNING!!!$BK,0$ Each partition has one boot record, so do not attempt to boot both LoseThos and some other operating system from the same partition. - -6) More than one LoseThos partition on a hard drive is very useful for development work (I have three). You might accidentally change files rendering your partition unbootable, needing to resort to a back-up to fix it. A floppy or CD will work. - -$FG,5$$TX+CX,"Installing to a hard drive"$$FG$ - -1) Create a FAT32 partition or two (highly recommended) on your hard drive. You'll need Linux and Linux's LILO present on the hard drive as well. I have Windows, Linux and LoseThos all on my hard drive. (Install Windows before Linux.) - -2) Boot to a LoseThos floppy or CD and add your hard disk with $LK,"AddDrives","MN:AddDrives"$(). Note the partition (drive) letter of the partition you wish to boot from in the future. - -3) Use $LK,"Format","MN:Format"$() to make it a LoseThos partition. - -4) Copy the "/LT" directory to the partition with $LK,"CopyTree","MN:CopyTree"$("T:/LT","D:/LT"); where "T" is the source drive letter and "D" is the destination. - -5) Type "$LK,"InstallBoot","MN:InstallBoot"$('?');" where the question is the drive. Enter the requested prompts during recompilation, making sure to add your hard drive (again) so it will be present when you boot. - -6) Boot to Linux and modify LILO. Go to the "/etc" directory, edit "lilo.conf" and run "lilo". You'll need to know the Linux name for the LoseThos partition--something like "hda3" or whatever. - -$FG,5$$TX+CX,"Postinstallation Notes"$$FG$ - -1) Once installed, you can recompile the hard drive OSmain with "$LK,"InstallBoot","MN:InstallBoot"$('D');" or whatever drive. diff --git a/LT/DOC/News.TXZ b/LT/DOC/News.TXZ deleted file mode 100644 index 699bbc9..0000000 --- a/LT/DOC/News.TXZ +++ /dev/null @@ -1,136 +0,0 @@ -$WW,1$ - -$IV,1$----07/19/06 21:44:00----$IV,0$ -* Worked on serial port null modem support. You can network two computers and do a telnet type thing. There is now a $LK,"RmtMergeChk","MN:RmtMergeChk"$() routine which will sync two computers. One has to have a window running $LK,"TelnetHostOpen","MN:TelnetHostOpen"$() which you pass a channel from $LK,"CommOpen8N1","MN:CommOpen8N1"$(). - -$IV,1$----07/18/06 10:25:00----$IV,0$ -* Unmask IRQ's during mouse polling. Might have side-effects. - -$IV,1$----07/16/06 11:44:46----$IV,0$ -* Changed "Message" to "Msg" -* Expanded serial communication -* Cleaned-up externs in Adam directory - -$IV,1$----07/13/06 09:22:24----$IV,0$ -* Fixed some bugs in disassembler. - -$IV,1$----07/12/06 16:47:29----$IV,0$ -* Modified FlagsStruct converting from 128-bit to 64-bit. -* Fixed bad default flag in $LK,"FileOccurrences","MN:FileOccurrences"$(). -* Fixed bug in FindFile for CD-ROM. Cd() result was bad. - -$IV,1$----07/11/06 17:51:02----$IV,0$ -* Probably fixed problem with SHIFT or CTRL keys getting locked on. - -$IV,1$----07/11/06 09:02:06----$IV,0$ -* Fixed bugs with use of HOME directory in Cd() and other spots. Wasn't changing partitions to the home drive. -* Moved $LK,"FindFiles","MN:FindFiles"$() to $LK,"SysFindFiles","MN:SysFindFiles"$() and enveloped it so it now supports specifying directories. - -$IV,1$----07/11/06 04:43:20----$IV,0$ -* Changed $LK,"Dir","MN:Dir"$() listing--shortened date/time, sorts by filename extension. -* Moved stuff around in files - -$IV,1$----07/10/06 10:46:36----$IV,0$ -* Combined Ltf flags and flags2 - -$IV,1$----07/10/06 04:24:01----$IV,0$ -* sped-up screen update -* Enhanced $LK,"ProfRep","MN:ProfRep"$(); -* Increased RAM disk size from 2880 blks to 8192 blks. This is the 'B' drive. - -$IV,1$----07/08/06 05:27:06----$IV,0$ -* Changed music_tempo. It is now a recripocal and a different scale. -$IV,1$ -----07/08/06 00:07:23----$IV,0$ -* Changed eigth note tripolets in $LK,"Play","MN:Play"$() from 'S' to "et". - -$IV,1$----07/06/06 23:33:18----$IV,0$ -* Fixed $LK,"Edit","MN:Edit"$() menu so that it is active when you click commands. -* Fixed $LK,"WriteCdImage","MN:WriteCdImage"$() to use proper path in filename. - -$IV,1$----07/03/06 23:53:32----$IV,0$ -* Converted some compression routines to asm to speed things up. - -$IV,1$----07/01/06 22:30:45----$IV,0$ -* Improved $LK,"::/LT/DEMO/WinMgr2.CPZ","FI:::/LT/DEMO/WinMgr2.CPZ"$. You really should try it. It demo's the Ode feature. - -$IV,1$----07/01/06 03:55:58----$IV,0$ -* Sped-up compiler$IV,1$ - -----06/30/06 21:55:59----$IV,0$ -* Fixed some memory leaks in compiler. -* Changed syntax for type casting. Now, requires parenthesis. It's designated with "><(class *)" and it is post-fix. -$IV,1$----06/30/06 16:40:43----$IV,0$ -* Fixed compiler bugs - -$IV,1$----06/29/06 03:32:32----$IV,0$ -* Added $LK,"CurDir","MN:CurDir"$() which returns both drive and directory. -* Fixed $LK,"CopyTree","MN:CopyTree"$() -$IV,1$ -----06/28/06 11:13:23----$IV,0$ -* Made major improvement in screen update speed. -* Sped-up compile time a little - -$IV,1$----06/28/06 05:30:34----$IV,0$ -* Added significant compiler optimization -* Probably fixed bug on Install option for distributed CD-ROMs (fixed SysGetChar) -$IV,1$ -----06/27/06 23:32:19----$IV,0$ -* Added minor compiler optimization - -$IV,1$----06/27/06 21:20:14----$IV,0$ -* Fixed bug with F2 macro -* Added minor compiler optimization - -$IV,1$----06/27/06 03:50:53----$IV,0$ -* Added compiled_lines to wallpaper - -$IV,1$----06/26/06 22:43:23----$IV,0$ -* Fixed $LK,"GrCircle","MN:GrCircle"$() and $LK,"Circle","MN:Circle"$(); -* Added minor compiler optimization. -* Fixed bug in editor involving cursor-up on nontext widgets. -* Fixed lacking feature with CTRL-R, adding "END" for text insert points. - -$IV,1$ -----06/25/06 19:13:38----$IV,0$ -* Altered the way string constants and Pictures are stored when compiled so that it looks like it is on the heap. This might fix lots of bugs. -* Added $LK,"LtfPutGrElem","MN:LtfPutGrElem"$(); -See $LK,"::/LT/DEMO/Graphics/Sprite3.CPZ","FI:::/LT/DEMO/Graphics/Sprite3.CPZ"$. -$IV,1$ -----06/24/06 18:20:28----$IV,0$ -* fixed missed optimization in compiler--code is smaller and faster - -$IV,1$----06/20/06 19:36:07----$IV,0$ -* $BK,1$WARNING$BK,0$: swapped keyboard scan-code flags SCf_KEY_UP and SCf_E0_PREFIX. If you have a EditPlugIn, you might need to change it. See $LK,"My_EditPlugIns","FF:::/LT/ACCOUNTS/ADAM3.CPZ,My_EditPlugIns"$. -* Added numeric keypad support -* Added HOME/END keys to editor - $IV,1$ -----06/20/06 13:00:25----$IV,0$ -* $BK,1$WARNING$BK,0$: renamed "trap" to "except" -* renamed "heap_cache" stuff to "heap_hash". - -$IV,1$----06/14/06 21:01:01----$IV,0$ -* Fixed a word-wrap bug, pretty-much. -$IV,1$ -----06/12/06 06:02:07----$IV,0$ -* Fixed bug on cursor movement in forms. -* Added $LK,"::/LT/DEMO/WinMgr2.CPZ","FI:::/LT/DEMO/WinMgr2.CPZ"$ - -$IV,1$----06/10/06 15:29:42----$IV,0$ -* worked on mouse and mouse wheel -* modified $LK,"Grep","MN:Grep"$() to return match count. -* added $LK,"FileOccurrences","MN:FileOccurrences"$() -$IV,1$ -----06/07/06 15:08:58----$IV,0$ -* Implemented Scroll-Lock -* Sets keyboard LEDs -* Added BSplines - -$IV,1$----06/05/06 12:47:59----$IV,0$ -* implemented returns out of catch{} -$IV,1$----06/05/06 08:51:40----$IV,0$ -* fixed bug in exception handling and implenmented returns out of try{} but not catch {} statements. -$IV,1$----06/04/06 07:39:40----$IV,0$ -* Added array nd structure initialization for global variables -$IV,1$----05/20/06 04:20:38----$IV,0$ -* Added F4 and SHIFT-F4 for picking directories and files. \ No newline at end of file diff --git a/LT/DOC/Quirks.TXZ b/LT/DOC/Quirks.TXZ deleted file mode 100644 index dc57e82..0000000 --- a/LT/DOC/Quirks.TXZ +++ /dev/null @@ -1,9 +0,0 @@ -$WW,1$* Call $LK,"ChangeDisk","MN:ChangeDisk"$() when you insert a new removable media. -* You can only $FG,2$extern$FG$ something once. There is a varient called $FG,2$LTextern$FG$ which binds a C+ definition to a asm symbol. This, too, can only be done once. -* Use $FG,2$MulI8,MulU8,DivI8,DivU8,ModI8,ModU8$FG$ when doing 64-bit arithmetic, except if 32-bit results are guarenteed. When I move to a true 64-bit CPU, these won't be needed. -* $FG,2$switch/case$FG$ statements allocate a single jump table--do not use with wide, sparce ranges of case values. Eventually, this might be fixed. -* Don't use default string constant parameters on functions compiled in $LK,"Static Compiled Mode","FF:::/LT/DOC/OSGlossary.GLZ,Static Compiled Mode"$ because there is a bug. -* A $LK,"Cd","MN:Cd"$() cmd must be followed by two semicolons if a $FG,2$#include$FG$ is after it. This is because the precompiler processes the next instruction early. -* The last semicolon on the cmd 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 "$FG,2$if$FG$" statements with "$FG,2$else$FG$" clauses it presents problems. -* You cannot use $FG,2$$$IB$$,$$IT$$ or $$IS$$$FG$ at the command line or before the $LK,"::/LT/ADAM/EDIT.CPZ","FI:::/LT/ADAM/EDIT.CPZ"$ file has been included during start-up. -* The assembler error messages are often off by a line and undefines are cryptic. diff --git a/LT/DOC/StartUp.TXZ b/LT/DOC/StartUp.TXZ deleted file mode 100644 index 8d73531..0000000 Binary files a/LT/DOC/StartUp.TXZ and /dev/null differ diff --git a/LT/DOC/Tips.TXZ b/LT/DOC/Tips.TXZ deleted file mode 100644 index 849c158..0000000 --- a/LT/DOC/Tips.TXZ +++ /dev/null @@ -1,78 +0,0 @@ -$WW,1$$FG,5$$IV,1$$TX+CX,"MISC"$$IV,0$$FG$ - -* Press the $FG,2$WINDOW$FG$'s key at the command line to access your macro/menu area. Place macros there with $FG,2$CTRL-L$FG$. Use the "$FG,2$Pop-Up$FG$" option on macros to $LK,"Spawn","MN:Spawn"$ a task to run a file. It dies when it is finished. This returns memory to the system allocated by programs. Be sure to press $FG,2$CTRL-S$FG$ to save your macro/menu area after making changes. - -* You can adjust the screen refresh rate (software). It is automatically adjusted based on load. The range is $LK,"win_min_refresh","MN:win_min_refresh"$,$LK,"win_max_refresh","MN:win_max_refresh"$. - -* You can adjust the number of answers displayed by setting $FG,2$Fs->answers_displayed$FG$ to a number from 0-8. See $LK,"answers_displayed","FF:HOME/USER.CPZ,answers_displayed"$ in your $LK,"HOME/USER.CPZ","FI:HOME/USER.CPZ"$ file. - -* You can use "$FG,2$ans0$FG$","$FG,2$ans1$FG$", etc in expressions. You can use the cmd prompt as a calculator by just entering expressions like "$FG,2$1+2*3;$FG$". $FG,2$double$FG$ results can be accessed with "$FG,2$ansd0$FG$" or "$FG,2$ansd1$FG$". - -* You can recompile and reinstall the kernel with $LK,"InstallBoot","MN:InstallBoot"$(). You can upgrade to 800x600 VGA resolution if your video chip supports it. You can turn-off $FG,2$WORDSTAT$FG$ initialization by entering $FG,2$$FG$ at the prompt. To start $FG,2$WORDSTAT$FG$ later, use $LK,"WsInit","MN:WsInit"$(). - -* Filenames ending in "$FG,2$Z$FG$" will be automatically compressed and uncompressed when read or written. The compression method is not supported elsewhere. - -* The joystick can be recalibrated with $LK,"JoyCalibration","MN:JoyCalibration"$(). - -* You might speed-up CD-ROM access by changing $FG,2$bdev->max_reads$FG$ if your drive can handle more. See $LK+S,"InitBlkDev","MN:InitBlkDev"$() under ATAPI. - -* $LK,"MergeChk","MN:MergeChk"$() can be used to see what's changed. The "$FG,2$+d$FG$" flag will show differences of files which have changed and allow you to merge code. (The "$FG,2$+r$FG$" flag will recurse.) - -* Use $LK,"Plain","MN:Plain"$() to edit a plain text file. You'll need this if your file has $FG,2$$$$FG$'s. - -* Use $LK,"Silent","MN:Silent"$() to disable output. Or, $LK,"Btr","MN:Btr"$(&sys_flags,SYSf_NO_IO_SOUND) to turn-off disk IO feedback. - -* There are handy functions--$FG,2$F(),R(),FD()$FG$ and $FG,2$RD()$FG$ which are defined in $LK,"HOME/USER.CPZ","FI:HOME/USER.CPZ"$. They will perform find-and-replace operations accross multiple files. The "$FG,2$+l$FG$" flag is particularly useful since it limits to whole labels. - -* You can save files after making changes, anytime you are within the editor, like when viewing help/macro files. $FG,2$CTRL-A$FG$ saves as, $FG,2$CTRL-S$FG$ saves with the same name in the scrolling title bar. Hitting $FG,2$ESC$FG$ will exit and save. ($FG,2$CTRL-Q$FG$ will exit and not save). You can save the cmd line window to a file, too, since you're actually in the editor when you're at the cmd line. - -* When using $FG,2$CTRL-L$FG$ to insert links in documents, you can usually leave the "Display Text" blank and it will be filled-in automatically based on other entries. - -* There is a feature of the compiler/assembler which allows code to be executed in the middle of compilation and data inserted into the compilation stream. You do a "$FG,2$exe{}$FG$" blk similar to an "$FG,2$asm{}$FG$" blk. Click here for an example: $LK,"exe {","FF:::/LT/OSMain/END.CPZ,exe {"$. - -* Use $LK,"LtfSetMax","MN:LtfSetMax"$() to adjust the size of the cmd line buf. - -* If you output to the cmd line and wish to allow users to scroll around and view data, you can use $LK,"View","MN:View"$(). $LK,"Example","MN:WsPutMatrix"$ - -* Use $LK+S,"View","MN:View"$() in Pop-up macros to linger until the user presses $FG,2$ESC$FG$ or $FG,2$CTRL-Q$FG$. - -* You can access the word under the cursor at $LK,"ws_cur_word","MN:ws_cur_word"$, but you should probably turn-off preemption or interrupts momentarily to copy it. - -* You can reactivate WORDSTAT after closing it by pressing $FG,2$CTRL-FUNCTION KEY$FG$. - -* $LK,"Preempt","MN:Preempt"$() is used to keep a task from being interrupted and swapped-out. It has a similar effect to turning-off interrupts. Each task has it's own preemption control. A task with preemption turned-off can voluntarily $LK,"SwapInNext","MN:SwapInNext"$() with preemption off. - -* You can set a color for different drives with $LK,"SetDriveTextAttr","MN:SetDriveTextAttr"$(). Place calls to this in $LK,"::HOME/USER.CPZ","FI:::HOME/USER.CPZ"$. - -* If you toggle to plain text when you are working with graphics in a document, you can add duplicate entries for pictures by entering a "$FG,2$PI$FG$" command with the same number. - -* If you toggle to plain text when working with graphics, you can add a string to the $FG,2$$$PI$$$FG$ entry to keep track of it. Try "$FG,2$$$PI,"+",2$$$FG$" where '2' is the picture number. - -* I use spaces-to-tab operations on all my files to keep them small. You have to be careful, though, because spaces in messages will be converted. I use $FG,2$SHIFT-SPACE$FG$ ' ' in such cases. See $LK,"S2T","MN:S2T"$() for spaces-to-tabs. - -* You can edit an existing Graphic Element by putting the cursor on it and pressing $FG,2$CTRL-R$FG$. - -* You can customize the "wallpaper" by adding stuff to the $LK,"WallPaper","MN:WallPaper"$() routine. - -$FG,5$$IV,1$$TX+CX,"DEBUGGING"$$FG$$IV,0$ - -* While debugging, you specify addresses of assembly OSmain $FG,2$asm{}$FG$ routines with just the label, as in "$FG,2$CP_MALLOC+0x20$FG$". You specify C+ labels with "&" before functions as in "$FG,2$&Printf+0x10$FG$". - -$LK,"D","MN:D"$() $LK,"LtfD","MN:LtfD"$() to hex dump mem with numbering from zero. With $LK,"LtfD","MN:LtfD"$ the values are updated continually and you can alter mem by editing. - -$LK,"Dm","MN:Dm"$() $LK,"LtfDm","MN:LtfDm"$() to hex dump mem with addresses showing. - -$LK,"Dasm","MN:Dasm"$() to disassemble mem. - -$LK,"Prof","MN:Prof"$() and $LK,"ProfRep","MN:ProfRep"$() provide code profiling. See $LK,"::/LT/DEMO/AutoFile/Demo2.AUZ","FI:::/LT/DEMO/AutoFile/Demo2.AUZ"$ (This is an "$LK,"AutoFile","FF:::/LT/DOC/OSGlossary.GLZ,AutoFile"$".) - -* Use $LK,"DbgNum","MN:DbgNum"$(), $LK,"DbgStr","MN:DbgStr"$() and $LK,"DbgAdd","MN:DbgAdd"$() to print debug info bypassing the window framework. You can use $LK,"Raw","MN:Raw"$($FG,2$TRUE$FG$) to make all output bypass the window framework. - -* Use $LK,"SysDbg","MN:SysDbg"$() to set a flag which you can read with $LK,"IsSysDbg","MN:IsSysDbg"$() when you wish to trigger some debug activity. - -* There are flags for various trace options that can help debugging. $LK,"Echo","MN:Echo"$() turns on or off raw data going into the lexical analyzer. $LK,"LTrace","MN:LTrace"$() shows the tokens coming out of the lexical analyzer. $LK,"CTrace","MN:CTrace"$() disassembles code generated from the C+ compiler. $LK,"PTrace","MN:PTrace"$() shows "intermediate code" comming out of the first stage of the compiler (it's not 100% valid because it hasn't been fixed-up). $LK,"OTrace","MN:OTrace"$() shows intermediate code coming-out after optimization. These flags can be set and reset by placing them in "$FG,2$exe{}$FG$" code blks. - -* $FG,4$dbgo$FG$ is an alias for "$FG,2$cout$FG$" and can be used to place output. You can easily find and remove them doing a $LK,"Grep","MN:Grep"$(). - -* $LK,"SBpt","MN:SBpt"$() to set breakpoints. When the fault screen appears, use $LK,"Go","MN:Go"$() to continue. You can altering modify what is displayed each break-point by $LK,"HOME/FAULT.CPZ","FI:HOME/FAULT.CPZ"$ in your account's home directory. - diff --git a/LT/Demo/ASCIIOrgan.CPZ b/LT/Demo/ASCIIOrgan.CPZ new file mode 100644 index 0000000..7abad7e --- /dev/null +++ b/LT/Demo/ASCIIOrgan.CPZ @@ -0,0 +1,16 @@ +//Practice your ASCII knowledge ;-) + +void ASCIIOrgan() +{ + U1 ch; + coutln "Press keys to make sounds"; + coutln "and press ESC to exit."; + do { + //We don't want echo or scan codes, so we use NULL and FALSE... + ch=GetChar(NULL,FALSE); + Sound((ch-28)*25); + } while (ch!=CH_ESC && ch!=CH_CTRLQ); + Sound(0); +} + +ASCIIOrgan; \ No newline at end of file diff --git a/LT/DEMO/AutoFile/Demo1.AUZ b/LT/Demo/AutoFile/Demo1.AUZ similarity index 56% rename from LT/DEMO/AutoFile/Demo1.AUZ rename to LT/Demo/AutoFile/Demo1.AUZ index dcdb90e..2a80c29 100644 --- a/LT/DEMO/AutoFile/Demo1.AUZ +++ b/LT/Demo/AutoFile/Demo1.AUZ @@ -1,15 +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. +See $LK,"AutoFile","FF:::/LT/Doc/OSGlossary.GLZ,AutoFile"$ in the glossary for more info. */ //This is to demo autofiles. -I4 i; +I8 i; for (i=0;i<3;i++) PutS("Dir;\r"); -PutS("$$FG RED$$//Press a letter to complete the mask$$FG$$\r"); +PutS("$$FG,RED$$//Press a letter to complete the mask$$FG$$\r"); PutS("Dir(\"*."); -I1 ch=GetKey; //Prompt for first digit of mask +I1 ch=GetChar(NULL,FALSE); //Prompt for first digit of mask PrintF("%c*\");\r",ch); \ No newline at end of file diff --git a/LT/Demo/AutoFile/Demo2.AUZ b/LT/Demo/AutoFile/Demo2.AUZ new file mode 100644 index 0000000..02b2ba5 --- /dev/null +++ b/LT/Demo/AutoFile/Demo2.AUZ @@ -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$$ProfAll;$$FG$$\r"); +PutS("$$FG,RED$$//Collecting Data$$FG$$"); +PressAKey; +PutS("\r$$FG,RED$$ProfRep;$$FG$$\r"); \ No newline at end of file diff --git a/LT/Demo/AutoFile/Demo3.AUZ b/LT/Demo/AutoFile/Demo3.AUZ new file mode 100644 index 0000000..b0be68e Binary files /dev/null and b/LT/Demo/AutoFile/Demo3.AUZ differ diff --git a/LT/Demo/AutoFile/Demo3.TXZ b/LT/Demo/AutoFile/Demo3.TXZ new file mode 100644 index 0000000..9bed5ce --- /dev/null +++ b/LT/Demo/AutoFile/Demo3.TXZ @@ -0,0 +1,260 @@ +#define EC_NULL 0xD7 +#define EC_NOP 0xD8 + +#define EC_U8 0xD9 +#define EC_U4 0xDA +#define EC_U2 0x04 +#define EC_U1 0x05 +#define EC_DOUBLE 0x06 +#define EC_STR_CONST 0x07 +#define EC_RBP 0x08 +#define EC_FS 0x09 + +#define EC_COM 0x0A +#define EC_NOT 0x0B +#define EC_UNARY_MINUS 0x0C +#define EC_ADDRESS 0x0D + +#define EC_U8_DISP32 0x0E +#define EC_U4_DISP32 0x0F +#define EC_U2_DISP32 0x10 +#define EC_U1_DISP32 0x11 +#define EC_U8_DISP8 0x12 +#define EC_U4_DISP8 0x13 +#define EC_U2_DISP8 0x14 +#define EC_U1_DISP8 0x15 +#define EC_DEREF_U8 0x16 +#define EC_DEREF_U4 0x17 +#define EC_DEREF_U2 0x18 +#define EC_DEREF_U1 0x19 +#define EC_U8_PP 0x1A +#define EC_U4_PP 0x1B +#define EC_U2_PP 0x1C +#define EC_U1_PP 0x1D +#define EC_U8_MM 0x1E +#define EC_U4_MM 0x1F +#define EC_U2_MM 0x20 +#define EC_U1_MM 0x21 +#define EC_PP_U8 0x22 +#define EC_PP_U4 0x23 +#define EC_PP_U2 0x24 +#define EC_PP_U1 0x25 +#define EC_MM_U8 0x26 +#define EC_MM_U4 0x27 +#define EC_MM_U2 0x28 +#define EC_MM_U1 0x29 + +#define EC_SHL 0x2A +#define EC_SHR 0x2B + +#define EC_MULTIPLICATION 0x2C +#define EC_DIVISION 0x2D +#define EC_REMAINDER 0x2E + +#define EC_AND 0x2F + +#define EC_OR 0x30 +#define EC_XOR 0x31 + +#define EC_ADDITION 0x32 +#define EC_SUBTRACTION 0x33 + +#define EC_EQUAL_EQUAL 0x34 +#define EC_NOT_EQUAL_TO 0x35 +#define EC_LESS_THAN 0x36 +#define EC_GREATER_THAN 0x37 +#define EC_LESS_OR_EQUAL 0x38 +#define EC_GREATER_OR_EQUAL 0x39 + +#define EC_AND_AND 0x3A + +#define EC_OR_OR 0x3B +#define EC_XOR_XOR 0x3C + +#define EC_COLON 0x3D +#define EC_QUESTION 0x3E + +#define EC_ASSIGN_U8 0x3F +#define EC_ASSIGN_U4 0x40 +#define EC_ASSIGN_U2 0x41 +#define EC_ASSIGN_U1 0x42 + +#define EC_SHL_EQUAL_U8 0x43 +#define EC_SHL_EQUAL_U4 0x44 +#define EC_SHL_EQUAL_U2 0x45 +#define EC_SHL_EQUAL_U1 0x46 + +#define EC_SHR_EQUAL_U8 0x47 +#define EC_SHR_EQUAL_U4 0x48 +#define EC_SHR_EQUAL_U2 0x49 +#define EC_SHR_EQUAL_U1 0x4A + +#define EC_MUL_EQUAL_U8 0x4B +#define EC_MUL_EQUAL_U4 0x4C +#define EC_MUL_EQUAL_U2 0x4D +#define EC_MUL_EQUAL_U1 0x4E + +#define EC_DIV_EQUAL_U8 0x4F +#define EC_DIV_EQUAL_U4 0x50 +#define EC_DIV_EQUAL_U2 0x51 +#define EC_DIV_EQUAL_U1 0x52 + +#define EC_AND_EQUAL_U8 0x53 +#define EC_AND_EQUAL_U4 0x54 +#define EC_AND_EQUAL_U2 0x55 +#define EC_AND_EQUAL_U1 0x56 + +#define EC_OR_EQUAL_U8 0x57 +#define EC_OR_EQUAL_U4 0x58 +#define EC_OR_EQUAL_U2 0x59 +#define EC_OR_EQUAL_U1 0x5A + +#define EC_XOR_EQUAL_U8 0x5B +#define EC_XOR_EQUAL_U4 0x5C +#define EC_XOR_EQUAL_U2 0x5D +#define EC_XOR_EQUAL_U1 0x5E + +#define EC_ADD_EQUAL_U8 0x5F +#define EC_ADD_EQUAL_U4 0x60 +#define EC_ADD_EQUAL_U2 0x61 +#define EC_ADD_EQUAL_U1 0x62 + +#define EC_SUB_EQUAL_U8 0x63 +#define EC_SUB_EQUAL_U4 0x64 +#define EC_SUB_EQUAL_U2 0x65 +#define EC_SUB_EQUAL_U1 0x66 + +#define EC_ADD64 0x67 +#define EC_ADD32 0x68 +#define EC_ADD8 0x69 +#define EC_INC 0x6A +#define EC_SUB64 0x6B +#define EC_SUB32 0x6C +#define EC_SUB8 0x6D +#define EC_DEC 0x6E + +#define EC_ENTER 0x6F +#define EC_LEAVE 0x70 +#define EC_ADD_RSP64 0x71 +#define EC_ADD_RSP32 0x72 +#define EC_ADD_RSP8 0x73 +#define EC_RET 0x74 +#define EC_CALL 0x75 +#define EC_CALL_INDIRECT 0x76 +#define EC_CALL_INDIRECT2 0x77 +#define EC_IRQ 0x78 + +#define EC_CLI 0x79 +#define EC_STI 0x7A +#define EC_GET_FLAGS 0x7B +#define EC_SET_FLAGS 0x7C +#define EC_GET_BASE_PTR 0x7D +#define EC_SET_BASE_PTR 0x7E +#define EC_GET_STACK_PTR 0x7F +#define EC_SET_STACK_PTR 0x80 +#define EC_GET_LABEL 0x81 +#define EC_ABSOLUTE_ADDRESS 0x82 +#define EC_LABEL 0x83 +#define EC_TYPE 0x84 + +#define EC_BT 0x85 +#define EC_BTS 0x86 +#define EC_BTR 0x87 +#define EC_BTC 0x88 +#define EC_BSF 0x89 +#define EC_BSR 0x8A +#define EC_INSQUE 0x8B +#define EC_INSQUE_REV 0x8C +#define EC_REMQUE 0x8D +#define EC_MEMCPY 0x8E +#define EC_MEMSET 0x8F +#define EC_INPD 0x90 +#define EC_INPW 0x91 +#define EC_INP 0x92 +#define EC_OUTPD 0x93 +#define EC_OUTPW 0x94 +#define EC_OUTP 0x95 +#define EC_REP_INSW 0x96 +#define EC_REP_INSB 0x97 +#define EC_REP_OUTSW 0x98 +#define EC_REP_OUTSB 0x99 + +#define EC_JMP 0x9A +#define EC_SHORT_JMP 0x9B +#define EC_SWITCH 0x9C + +#define EC_SKIPZ 0x9D +#define EC_SKIPZ2 0x9E +#define EC_SKIPNZ 0x9F +#define EC_SKIPNZ2 0xA0 + +#define EC_EQUAL_EQUAL_SKIPZ 0xA1 +#define EC_EQUAL_EQUAL_SKIPZ2 0xA2 + +#define EC_NOT_EQUAL_TO_SKIPZ 0xA3 +#define EC_NOT_EQUAL_TO_SKIPZ2 0xA4 + +#define EC_LESS_THAN_SKIPZ 0xA5 +#define EC_LESS_THAN_SKIPZ2 0xA6 + +#define EC_GREATER_THAN_SKIPZ 0xA7 +#define EC_GREATER_THAN_SKIPZ2 0xA8 + +#define EC_LESS_OR_EQUAL_SKIPZ 0xA9 +#define EC_LESS_OR_EQUAL_SKIPZ2 0xAA + +#dABine EC_GREATER_OR_EQUAL_SKIPZ 0xAB +#dACine EC_GREATER_OR_EQUAL_SKIPZ2 0xAC + +#define EC_AND_AND_SKIPZ 0xAD +#define EC_AND_AND_SKIPZ2 0xAE +#define EC_AND_AND_SKIPNZ 0xAF +#define EC_AND_AND_SKIPNZ2 0xB0 + +#define EC_OR_OR_SKIPZ 0xB1 +#define EC_OR_OR_SKIPZ2 0xB2 +#define EC_OR_OR_SKIPNZ 0xB3 +#define EC_OR_OR_SKIPNZ2 0xB4 + +#define EC_FILD 0xB5 +#define EC_FISTP 0xB6 +#define EC_FLD 0xB7 +#define EC_FSTP 0xB8 +#define EC_FYL2X 0xB9 +#define EC_FABS 0xBA +#define EC_FCHS 0xBB +#define EC_FSIN 0xBC +#define EC_FCOS 0xBD +#define EC_FPTAN 0xBE +#define EC_FPATAN 0xBF +#define EC_FSQRT 0xC0 +#define EC_FMULP 0xC1 +#define EC_FDIVP 0xC2 +#define EC_FDIVRP 0xC3 +#define EC_FADDP 0xC4 +#define EC_FSUBP 0xC5 +#define EC_FSUBRP 0xC6 + +#define EC_LEA_DISP32_RBP 0xC7 +#define EC_LEA_DISP8_RBP 0xC8 + +#define EC_FS_U8_DISP32 0xC9 +#define EC_FS_U4_DISP32 0xCA +#define EC_FS_U2_DISP32 0xCB +#define EC_FS_U1_DISP32 0xCC + +#define EC_SHL_CONST1 0xCD +#define EC_SHL_CONST2 0xCE +#define EC_SHR_CONST1 0xCF +#define EC_SHR_CONST2 0xD0 + +#define EC_U8_DISP32_SCALED 0xD1 +#define EC_U4_DISP32_SCALED 0xD2 +#define EC_U2_DISP32_SCALED 0xD3 + +#define EC_STRLEN 0xD4 +#define EC_ZERO 0xD5 + +#define EC_NUM_ENTRIES 0xD6 + + diff --git a/LT/Demo/AutoFile/Demo4.CPZ b/LT/Demo/AutoFile/Demo4.CPZ new file mode 100644 index 0000000..602a889 Binary files /dev/null and b/LT/Demo/AutoFile/Demo4.CPZ differ diff --git a/LT/Demo/ByteAccess.CPZ b/LT/Demo/ByteAccess.CPZ new file mode 100644 index 0000000..c4bfb8d --- /dev/null +++ b/LT/Demo/ByteAccess.CPZ @@ -0,0 +1,26 @@ +/* + LoseThos has a feature that allows + access to bytes and words of larger + integers. + + See $LK,"U8i union","FF:::/LT/OSMain/AdamK.HPZ,U8i union"$ + + The versions with "i" are internal data types. + Use "U8" instead of "U8i" and you + will have access to subbytes and + subwords. +*/ + +U8 q=0xFEDCBA9876543210,q1; + +PrintF("q\t\t=%016X\r\n",q); +q1=q.i2[2]; +PrintF("q.i2[2]\t\t=%016X\r\n",q1); +q1=q.u1[5]; +PrintF("q.u1[5]\t\t=%016X\r\n",q1); +q1=q.i4[1].u1[2]; +PrintF("q.i4[1].u1[2]\t=%016X\r\n",q1); +q1=q.i4[0].i1[1]; +PrintF("q.i4[0].i1[1]\t=%016X\r\n",q1); + + diff --git a/LT/Demo/CircleTrace.CPZ b/LT/Demo/CircleTrace.CPZ new file mode 100644 index 0000000..14160bf Binary files /dev/null and b/LT/Demo/CircleTrace.CPZ differ diff --git a/LT/DEMO/CommTerminal.CPZ b/LT/Demo/CommTerminal.CPZ similarity index 75% rename from LT/DEMO/CommTerminal.CPZ rename to LT/Demo/CommTerminal.CPZ index c326e25..1d593f7 100644 --- a/LT/DEMO/CommTerminal.CPZ +++ b/LT/Demo/CommTerminal.CPZ @@ -1,5 +1,5 @@ // COM port Terminal -void CommTerm(U4 port=1,U4 baud=9600) +void CommTerm(I8 port=1,U8 baud=9600) { U8 sc; U8 ch=0; @@ -9,7 +9,7 @@ void CommTerm(U4 port=1,U4 baud=9600) if (CommScanChar(port,&ch)) PutChar(ch); ch=0; - if (ScanChar(&sc,&ch)) + if (ScanKey(&ch,&sc)) CommPutChar(port,ch); SwapInNext; } diff --git a/LT/Demo/DataBase.CPZ b/LT/Demo/DataBase.CPZ new file mode 100644 index 0000000..0a4c4e9 --- /dev/null +++ b/LT/Demo/DataBase.CPZ @@ -0,0 +1,68 @@ +#define DB_FILENAME "HOME/DataBaseDemo.BIN" +#define DB_MAX_ACCOUNT 100 +#define DB_ACCOUNT_BLKS 1 + +class Account +{ //Use $FG,2$CTRL-L$FG$ to help generate $FG,2$fmtstr$FG$s. + I1 name[32] fmtstr "$$DA-P,32,\"Name:%s\"$$\r\n"; + I1 address[64] fmtstr "$$DA-P,64,\"Address:%s\"$$\r\n"; + U1 pad[DB_ACCOUNT_BLKS*BLK_SIZE-64-32]; +}; + + +void InitDatabase() +{ + LTFile *f; + //Write new contiguous file + f=FOpen(DB_FILENAME,"wc",DB_MAX_ACCOUNT*DB_ACCOUNT_BLKS); + FClose(f); +} + + +void WriteAcct() +{ + LTFile *f; + Account a; + I8 acctnum; + + acctnum=PmtI8("Account #",-1); + if (acctnum>=0 && acctnum=0 && acctnum