diff --git a/0000Boot/0000OSMain.BIN.C b/0000Boot/0000OSMain.BIN.C new file mode 100644 index 0000000..f283ba3 Binary files /dev/null and b/0000Boot/0000OSMain.BIN.C differ diff --git a/0000Boot/Boot.BIC b/0000Boot/Boot.BIC deleted file mode 100644 index e86e292..0000000 Binary files a/0000Boot/Boot.BIC and /dev/null differ diff --git a/0000Boot/BootCD.BIN b/0000Boot/BootCD.BIN new file mode 100644 index 0000000..d2211b5 Binary files /dev/null and b/0000Boot/BootCD.BIN differ diff --git a/0000Boot/BootLoader.BIC b/0000Boot/BootLoader.BIC deleted file mode 100644 index 82eeb50..0000000 Binary files a/0000Boot/BootLoader.BIC and /dev/null differ diff --git a/0000Boot/BootMHD2.BIN.C b/0000Boot/BootMHD2.BIN.C new file mode 100644 index 0000000..eba93f5 Binary files /dev/null and b/0000Boot/BootMHD2.BIN.C differ diff --git a/0000Boot/CDBoot.BIZ b/0000Boot/CDBoot.BIZ deleted file mode 100644 index 176e3c3..0000000 Binary files a/0000Boot/CDBoot.BIZ and /dev/null differ diff --git a/0000Boot/OldMBR.BIN.C b/0000Boot/OldMBR.BIN.C new file mode 100644 index 0000000..1075add Binary files /dev/null and b/0000Boot/OldMBR.BIN.C differ diff --git a/LT/Accts/Adam3.APZ b/LT/Accts/Adam3.APZ deleted file mode 100644 index 98c87ce..0000000 --- a/LT/Accts/Adam3.APZ +++ /dev/null @@ -1,181 +0,0 @@ -//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); - -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 deleted file mode 100644 index d021567..0000000 --- a/LT/Accts/Fault.CPZ +++ /dev/null @@ -1,51 +0,0 @@ -/* 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 deleted file mode 100644 index 4ed6e52..0000000 --- a/LT/Accts/Favor.MUZ +++ /dev/null @@ -1,16 +0,0 @@ -$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 deleted file mode 100644 index f90645e..0000000 --- a/LT/Accts/Install/Adam3.APZ +++ /dev/null @@ -1,181 +0,0 @@ -//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 deleted file mode 100644 index 85d31f3..0000000 Binary files a/LT/Accts/Install/DoIt.CPZ and /dev/null differ diff --git a/LT/Accts/Install/User.CPZ b/LT/Accts/Install/User.CPZ deleted file mode 100644 index f14a113..0000000 Binary files a/LT/Accts/Install/User.CPZ and /dev/null differ diff --git a/LT/Accts/PicWords3.APZ b/LT/Accts/PicWords3.APZ deleted file mode 100644 index 649cfc5..0000000 --- a/LT/Accts/PicWords3.APZ +++ /dev/null @@ -1,9 +0,0 @@ -// Create Pictures Here - -void LoadUserPicWords() -{ -//Call $LK,"AddPicWord","MN:AddPicWord"$() -} - - -LoadUserPicWords; diff --git a/LT/Accts/Servant.CPZ b/LT/Accts/Servant.CPZ deleted file mode 100644 index 25e03c8..0000000 --- a/LT/Accts/Servant.CPZ +++ /dev/null @@ -1,11 +0,0 @@ -/* -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/Accts/Songs/Adam3.APZ b/LT/Accts/Songs/Adam3.APZ deleted file mode 100644 index 3ed008b..0000000 --- a/LT/Accts/Songs/Adam3.APZ +++ /dev/null @@ -1,176 +0,0 @@ -//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; - - 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 deleted file mode 100644 index 5e83c80..0000000 --- a/LT/Accts/Songs/DoIt.CPZ +++ /dev/null @@ -1,4 +0,0 @@ -Cd("::/LT/Apps/MusicOrgan");; -#include "Load";; -JukeBox("Examples"); - diff --git a/LT/Accts/Songs/User.CPZ b/LT/Accts/Songs/User.CPZ deleted file mode 100644 index 12601d4..0000000 --- a/LT/Accts/Songs/User.CPZ +++ /dev/null @@ -1,5 +0,0 @@ -UseConsoleLtf("User.MUZ"); -PutSysText("ST_USER_STARTUP"); -Type("::/LT/Doc/Help.TXZ"); -Bts(&Fs->crt_flags,CRTf_SHOW); -Preempt(ON); diff --git a/LT/Accts/System.CPZ b/LT/Accts/System.CPZ deleted file mode 100644 index faa52ec..0000000 Binary files a/LT/Accts/System.CPZ and /dev/null differ diff --git a/LT/Accts/Tour/DoIt.CPZ b/LT/Accts/Tour/DoIt.CPZ deleted file mode 100644 index 02bbd14..0000000 --- a/LT/Accts/Tour/DoIt.CPZ +++ /dev/null @@ -1 +0,0 @@ -AutoFile("Tour"); diff --git a/LT/Accts/Tour/Tour.AUZ b/LT/Accts/Tour/Tour.AUZ deleted file mode 100644 index 78c2eec..0000000 --- a/LT/Accts/Tour/Tour.AUZ +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 14dfba2..0000000 --- a/LT/Accts/Tour/Tour1.AUZ +++ /dev/null @@ -1,105 +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" -"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 deleted file mode 100644 index 6ba6918..0000000 --- a/LT/Accts/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;"); -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 deleted file mode 100644 index 571acc1..0000000 --- a/LT/Accts/Tour/Tour3.AUZ +++ /dev/null @@ -1,110 +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 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 deleted file mode 100644 index f5cc513..0000000 --- a/LT/Accts/Tour/Tour4.AUZ +++ /dev/null @@ -1,58 +0,0 @@ -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 deleted file mode 100644 index 9b699f3..0000000 --- a/LT/Accts/Tour/Tour5.AUZ +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index f14a113..0000000 Binary files a/LT/Accts/Tour/User.CPZ and /dev/null differ diff --git a/LT/Accts/User.CPZ b/LT/Accts/User.CPZ deleted file mode 100644 index c9d04ff..0000000 --- a/LT/Accts/User.CPZ +++ /dev/null @@ -1,37 +0,0 @@ -#help_index "Utils" -/* -This is the startup file for new local users. - -If you modify this file, you should place it -into your HOME directory. This version is the -default for accounts without a version in HOME. -*/ - -UseConsoleLtf("User.MUZ"); - -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="+l-i") -{ - return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text); -} - -U8 FD(I1 *pattern,I1 *flags=NULL) -{ - return Grep(pattern,TEXT_FILE_MASK,flags); -} - -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"); -Fs->scroll_speed=10; -Bts(&Fs->crt_flags,CRTf_SHOW); -Preempt(ON); -#help_index "" diff --git a/LT/Accts/User.MUZ b/LT/Accts/User.MUZ deleted file mode 100644 index 91a590b..0000000 Binary files a/LT/Accts/User.MUZ and /dev/null differ diff --git a/LT/Accts/User/DoIt.CPZ b/LT/Accts/User/DoIt.CPZ deleted file mode 100644 index 91e8f06..0000000 --- a/LT/Accts/User/DoIt.CPZ +++ /dev/null @@ -1,2 +0,0 @@ -Type("::/LT/Doc/Customize.TXZ"); - diff --git a/LT/Adam/Adam2.APZ b/LT/Adam/Adam2.APZ deleted file mode 100644 index 1b77639..0000000 --- a/LT/Adam/Adam2.APZ +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index ca6ecab..0000000 --- a/LT/Adam/AdamExt.HPZ +++ /dev/null @@ -1,46 +0,0 @@ -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 deleted file mode 100644 index cacd4ef..0000000 Binary files a/LT/Adam/AutoFile.APZ and /dev/null differ diff --git a/LT/Adam/Comm.APZ b/LT/Adam/Comm.APZ deleted file mode 100644 index 07f669f..0000000 Binary files a/LT/Adam/Comm.APZ and /dev/null differ diff --git a/LT/Adam/Dbg.APZ b/LT/Adam/Dbg.APZ deleted file mode 100644 index 645fba4..0000000 --- a/LT/Adam/Dbg.APZ +++ /dev/null @@ -1,1410 +0,0 @@ -#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 deleted file mode 100644 index a458cb2..0000000 Binary files a/LT/Adam/Disk10.APZ and /dev/null differ diff --git a/LT/Adam/DiskCDDVD.APZ b/LT/Adam/DiskCDDVD.APZ deleted file mode 100644 index 6a634e5..0000000 --- a/LT/Adam/DiskCDDVD.APZ +++ /dev/null @@ -1,543 +0,0 @@ -#help_index "File/CD DVD" - -void FillBigEndianU2(U2 *dst,U2 w) -{ - U2 *src=&w; - dst->u1[0]=src->u1[1]; - dst->u1[1]=src->u1[0]; -} - -void FillBigEndianU4(U4 *dst,U8 d) -{ - U8 *src=&d; - dst->u1[0]=src->u1[3]; - dst->u1[1]=src->u1[2]; - dst->u1[2]=src->u1[1]; - dst->u1[3]=src->u1[0]; -} - -void FillU2Palindrome(U2Palindrome *dst,U2 w) -{ - FillBigEndianU2(&dst->big,w); - dst->little=w; -} - -void FillU4Palindrome(U4Palindrome *dst,U8 d) -{ - FillBigEndianU4(&dst->big,d); - dst->little=d; -} - - -class CCdUserData -{ - U8 location,path_entry_num, - short_dir_blks,long_dir_blks; -}; - -U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm, - ISODirEntry *tempi,ISODirEntry *tempi2, - U8 *cur_blk, - LTDirEntry *parent,BoolU4 write) -{ - CCdUserData *tempc; - LTDirEntry *tempm1,*tempm2; - LTFile *in_file; - U1 *buf=MAlloc(CD_BLK_SIZE),*ptr1,*ptr2; - ISODirEntry *dir_blk_buf=MAllocZ(CD_BLK_SIZE*128), - *de=dir_blk_buf,*de1; - ISODirEntry *dir_blk_buf2=MAllocZ(CD_BLK_SIZE*128), - *de2=dir_blk_buf2,*de12; - U8 i,n; - - tempc=parent->user_data; - - de->length=sizeof(ISODirEntry)-1; - de->ext_attr_length=0; - FillU2Palindrome(&de->volume_sequence_num,1); - LTDateToISO(&de->date,tempm->datetime); - de->flags=ISO_ATTR_DIR; - de->name_len=1; - de->name=0; - de->length+=de->name_len; - de+=de->length; - - de->length=sizeof(ISODirEntry)-1; - de->ext_attr_length=0; - FillU4Palindrome(&de->location,tempc->location); - FillU4Palindrome(&de->size,tempc->short_dir_blks*CD_BLK_SIZE); - FillU2Palindrome(&de->volume_sequence_num,1); - LTDateToISO(&de->date,parent->datetime); - de->flags=ISO_ATTR_DIR; - de->name_len=1; - de->name=1; - de->length+=de->name_len; - de+=de->length; - - de2->length=sizeof(ISODirEntry)-1; - de2->ext_attr_length=0; - FillU2Palindrome(&de2->volume_sequence_num,1); - LTDateToISO(&de2->date,tempm->datetime); - de2->flags=ISO_ATTR_DIR; - de2->name_len=1; - de2->name=0; - de2->length=de2->length+de2->name_len; - de2+=de2->length; - - de2->length=sizeof(ISODirEntry)-1; - de2->ext_attr_length=0; - FillU4Palindrome(&de2->location,tempc->location+tempc->short_dir_blks); - FillU4Palindrome(&de2->size,tempc->long_dir_blks*CD_BLK_SIZE); - FillU2Palindrome(&de2->volume_sequence_num,1); - LTDateToISO(&de2->date,parent->datetime); - de2->flags=ISO_ATTR_DIR; - de2->name_len=1; - de2->name=1; - de2->length+=de2->name_len; - de2+=de2->length; - - tempm1=tempm->sub; - while (tempm1) { - tempm2=tempm1->next; - if (!write) tempm1->user_data=MAllocZ(sizeof(CCdUserData)); - de1=de; - de12=de2; - if (tempm1->attr & LT_ATTR_DIR) { - 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; - de->ext_attr_length=0; - FillU4Palindrome(&de->location,*cur_blk); - tempc->location=*cur_blk; - if (write) - coutln *cur_blk,":",tempm1->full_name; - FillU4Palindrome(&de->size,tempm1->size); - FillU2Palindrome(&de->volume_sequence_num,1); - LTDateToISO(&de->date,tempm1->datetime); - de->flags=0; - de->name_len=StrLen(tempm1->name); - StrCpy(&de->name,tempm1->name); - de->length=de->length+de->name_len; - de+=de->length; - - de2->length=sizeof(ISODirEntry)-1; - de2->ext_attr_length=0; - FillU4Palindrome(&de2->location,*cur_blk); - FillU4Palindrome(&de2->size,tempm1->size); - FillU2Palindrome(&de2->volume_sequence_num,1); - LTDateToISO(&de2->date,tempm1->datetime); - de2->flags=0; - de2->name_len=StrLen(tempm1->name)<<1; - ptr1=&de2->name; - ptr2=&tempm1->name; - for (i=0;iname_len;i=i+2) { - ptr1++; - *ptr1++=*ptr2++; - } - de2->length+=de2->name_len; - de2+=de2->length; - - in_file=FOpen(tempm1->full_name,"r"); - for (i=0;i<(FSize(in_file)+CD_BLK_SIZE-1)/CD_BLK_SIZE;i++) { - 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,n); - FWBlks(out_file,buf,(*cur_blk)<<2,n); - } - *cur_blk+=1; - } - FClose(in_file); - } - if ((de1-dir_blk_buf)/CD_BLK_SIZE!= - (de -dir_blk_buf)/CD_BLK_SIZE) { - i=de1->length; - MemCpy(buf,de1,i); - MemSet(de1,0,i); - de=dir_blk_buf+((de-dir_blk_buf)/CD_BLK_SIZE)*CD_BLK_SIZE; - MemCpy(de,buf,i); - de+=i; - } - if ((de12-dir_blk_buf2)/CD_BLK_SIZE!= - (de2 -dir_blk_buf2)/CD_BLK_SIZE) { - i=de12->length; - MemCpy(buf,de12,i); - MemSet(de12,0,i); - de2=dir_blk_buf2+((de2-dir_blk_buf2)/CD_BLK_SIZE)*CD_BLK_SIZE; - MemCpy(de2,buf,i); - de2+=i; - } - tempm1=tempm2; - } - - tempc=tempm->user_data; - - tempi->length=sizeof(ISODirEntry)-1; - tempi->ext_attr_length=0; - tempi->flags=ISO_ATTR_DIR; - if (!tempm->name[0]) { - tempi->name_len=1; - tempi->name=1; - } else { - tempi->name_len=StrLen(tempm->name); - StrCpy(&tempi->name,tempm->name); - } - tempi->length+=tempi->name_len; - - 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=n; - tempc->location=*cur_blk; - 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,n<<2); - *cur_blk+=n; - - tempi2->length=sizeof(ISODirEntry)-1; - tempi2->ext_attr_length=0; - tempi2->flags=ISO_ATTR_DIR; - if (!tempm->name[0]) { - tempi2->name_len=1; - tempi->name=1; - } else { - tempi2->name_len=StrLen(tempm->name)<<1; - ptr1=&tempi2->name; - ptr2=&tempm->name; - for (i=0;iname_len;i=i+2) { - ptr1++; - *ptr1++=*ptr2++; - } - } - tempi2->length+=tempi2->name_len; - 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=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,n<<2); - *cur_blk+=n; - - Free(dir_blk_buf); - Free(dir_blk_buf2); - Free(buf); - return tempi->name_len; -} - -U8 CDTableLength(LTDirEntry *tempm,U8 *size1,U8 *size2,U8 cur_depth) -//returns depth -{ - LTDirEntry *tempm1=tempm->sub; - U8 max_depth=cur_depth,i; - while (tempm1) { - if (tempm1->attr & LT_ATTR_DIR) { - *size1+=sizeof(ISOPathTableEntry)-2+((StrLen(tempm1->name)+1) & -0x2); - *size2+=sizeof(ISOPathTableEntry)-2+StrLen(tempm1->name)<<1; - i=CDTableLength(tempm1,size1,size2,cur_depth+1); - if (i>max_depth) max_depth=i; - } - tempm1=tempm1->next; - } - return max_depth; -} - -void CDFillPathTable(LTDirEntry *tempm, - ISOPathTableEntry *itabbuf,ISOPathTableEntry *itabbuf2, - U8 parent_entry_num,BoolU4 big_endian,U8 *first_free,I8 cur_level,I8 output_level) -{ - I1 *ptr1,*ptr2; - U8 i; - ISOPathTableEntry *tabbuf=*itabbuf; - ISOPathTableEntry *tabbuf2=*itabbuf2; - LTDirEntry *tempm1=tempm->sub,*tempm2; - CCdUserData *tempc; - - if (cur_level==output_level) { - while (tempm1) { - if (tempm1->attr & LT_ATTR_DIR) { - tempc=tempm1->user_data; - tempc->path_entry_num=*first_free; - tabbuf->name_len=StrLen(tempm1->name); - if (big_endian) { - FillBigEndianU4(&tabbuf->blk,tempc->location); - FillBigEndianU2(&tabbuf->parent_entry_num,parent_entry_num); - } else { - tabbuf->blk=tempc->location; - tabbuf->parent_entry_num=parent_entry_num; - } - StrCpy(&tabbuf->name,tempm1->name); - - tabbuf+=sizeof(ISOPathTableEntry)-2+ - ((StrLen(tempm1->name)+1) & -0x2); - - tabbuf2->name_len=StrLen(tempm1->name)<<1; - if (big_endian) { - FillBigEndianU4(&tabbuf2->blk,tempc->location+tempc->short_dir_blks); - FillBigEndianU2(&tabbuf2->parent_entry_num,parent_entry_num); - } else { - tabbuf2->blk=tempc->location+tempc->short_dir_blks; - tabbuf2->parent_entry_num=parent_entry_num; - } - ptr1=&tabbuf2->name; - ptr2=&tempm1->name; - for (i=0;iname_len;i=i+2) { - ptr1++; - *ptr1++=*ptr2++; - } - tabbuf2+=sizeof(ISOPathTableEntry)-2+ - StrLen(tempm1->name)<<1; - *first_free+=1; - } - tempm1=tempm1->next; - } - *itabbuf=tabbuf; - *itabbuf2=tabbuf2; - } - tempm1=tempm->sub; - while (tempm1) { - tempm2=tempm1->next; - if (tempm1->attr & LT_ATTR_DIR) { - tempc=tempm1->user_data; - CDFillPathTable(tempm1,itabbuf,itabbuf2,tempc->path_entry_num, - big_endian,first_free,cur_level+1,output_level); - } - tempm1=tempm2; - } -} - -class ElTorito -{ - U2 w[16]; - U1 bootable; //88=bootable 00=not bootable - U1 media_type; //0=no emulation 4=hard disk - U2 load_seg; //0000->07C0 - U1 sys_type; - U1 zero; - U2 sector_cnt; - U4 load_rba; //start address of virtual disk - U1 zero2[20]; -}; - -public U8 CreateCDFile(I1 *filename,I1 src_drive, - I1 *bootfile=NULL) -{ - ISOPrimaryDescriptor *iso =MAllocZ(CD_BLK_SIZE), - *iso1=MAllocZ(CD_BLK_SIZE), - *iso2=MAllocZ(CD_BLK_SIZE), - *iso3=MAllocZ(CD_BLK_SIZE); - LTDirEntry *rootdir=MAllocZ(sizeof(LTDirEntry)); - U8 cur_blk=0,bsize,tabsize,tabsize2,first_free,max_depth; - U4 *d; - I1 mask[8]; - I1 *filename2; - ElTorito *et=MAllocZ(CD_BLK_SIZE); - U1 *buf=MAllocZ(CD_BLK_SIZE), - *bootfile_buf=NULL; - ISOPathTableEntry *tabbuf=NULL,*tabbuf2=NULL, - *itabbuf,*itabbuf2; - BoolU4 okay=TRUE; - U8 i,j; - LTFile *out_file=NULL; - ISODirEntry *tempi; - CCdUserData *tempc; - - if (!filename) - filename=default_iso_name; - filename2=DefaultExtension(filename,"ISO"); - - SPrintF(mask,"%c:/*",src_drive); - if (bootfile) - bootfile_buf=ReadFile(bootfile,&bsize); - rootdir->attr=LT_ATTR_DIR; - rootdir->sub=FindFiles(mask,1<datetime=GetCurTimeLTDate; - rootdir->user_data=MAllocZ(sizeof(CCdUserData)); - tempc=rootdir->user_data; - tempc->path_entry_num=1; - - if (okay) { - cur_blk=CD_FILE_OFFSET>>2; - if (bootfile_buf) - cur_blk+=2; - DoCreateCDFile(out_file,rootdir, - &iso->root_directory_record, - &iso2->root_directory_record, - &cur_blk,rootdir,FALSE); - tabsize=sizeof(ISOPathTableEntry); - tabsize2=sizeof(ISOPathTableEntry); - max_depth=CDTableLength(rootdir,&tabsize,&tabsize2,1); - FillU4Palindrome(&iso->path_table_size,tabsize); - FillU4Palindrome(&iso2->path_table_size,tabsize2); - tabsize=(tabsize+CD_BLK_SIZE-1)/CD_BLK_SIZE; - cur_blk+=tabsize<<1; - tabsize2=(tabsize2+CD_BLK_SIZE-1)/CD_BLK_SIZE; - cur_blk+=tabsize2<<1; - } - if (okay) { - if (FileAttr(filename2) & LT_ATTR_CONTIGUOUS) - out_file=FOpen(filename2,"wc",cur_blk<<2); - else - out_file=FOpen(filename2,"w",cur_blk<<2); - if (!out_file) - okay=FALSE; - } - if (okay) { - cur_blk=0; - while (cur_blk>2) { - FWBlks(out_file,buf,cur_blk<<2,4); - cur_blk++; - } - iso->type=ISOT_PRIMARY_VOLUME_DESC; - StrCpy(iso->id,"CD001"); - iso->version=1; - FillU2Palindrome(&iso->volume_set_size,1); - FillU2Palindrome(&iso->volume_sequence_number,1); - FillU2Palindrome(&iso->logical_block_size,CD_BLK_SIZE); - iso->file_structure_version=1; - - iso2->type=ISOT_SUPPLEMENTARY_DESC; - StrCpy(iso2->id,"CD001"); - iso2->version=1; - FillU2Palindrome(&iso2->volume_set_size,1); - FillU2Palindrome(&iso2->volume_sequence_number,1); - FillU2Palindrome(&iso2->logical_block_size,CD_BLK_SIZE); - iso2->file_structure_version=1; - - iso1->type=ISOT_BOOT_RECORD; - StrCpy(iso1->id,"CD001"); - iso1->version=1; - StrCpy(iso1+7,"EL TORITO SPECIFICATION"); - - cur_blk=CD_FILE_OFFSET>>2; - - if (bootfile_buf) { - d=iso1+0x47; - *d=cur_blk; - et->w[0]=1; - StrCpy(&et->w[2],"LoseThos"); - et->w[15]=0xAA55; - j=0; - for (i=0;i<16;i++) //Checksum - j+=et->w[i]; - et->w[14]=-j; - if (bootfile_buf) - et->bootable=0x88; - et->media_type=0; //0=no emu 2=1.44meg 4=hard drive - et->sector_cnt=4; - et->load_rba=cur_blk+1; - coutln cur_blk,": Pre Boot Blk"; - FWBlks(out_file,et,cur_blk<<2,4); - cur_blk++; - - coutln cur_blk,": Boot Blk"; - FWBlks(out_file,bootfile_buf,cur_blk<<2,4); - cur_blk++; - } - - DoCreateCDFile(out_file,rootdir, - &iso->root_directory_record, - &iso2->root_directory_record, - &cur_blk,rootdir,TRUE); - - tabbuf=MAllocZ(tabsize*CD_BLK_SIZE); - iso->type_l_path_table=cur_blk; - tabbuf->name_len=2; //Fill-in adam entry - tempi=&iso->root_directory_record; - tabbuf->blk=tempi->location.little; - tabbuf->parent_entry_num=1; - tabbuf2=MAllocZ(tabsize2*CD_BLK_SIZE); - iso2->type_l_path_table=cur_blk+tabsize; - tabbuf2->name_len=2; //Fill-in adam entry - tempi=&iso2->root_directory_record; - tabbuf2->blk=tempi->location.little; - tabbuf2->parent_entry_num=1; - itabbuf=tabbuf+sizeof(ISOPathTableEntry); - itabbuf2=tabbuf2+sizeof(ISOPathTableEntry); - first_free=2; - for (i=1;i<=max_depth;i++) - CDFillPathTable(rootdir,&itabbuf,&itabbuf2, - 1,FALSE,&first_free,1,i); - coutln cur_blk,": Path Table 0"; - FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2); - cur_blk+=tabsize; - coutln cur_blk,": Path Table 1"; - FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2); - cur_blk+=tabsize2; - - - MemSet(tabbuf,0,tabsize*CD_BLK_SIZE); - FillBigEndianU4(&iso->type_m_path_table,cur_blk); - tabbuf->name_len=2; //Fill-in adam entry - tempi=&iso->root_directory_record; - tabbuf->blk=tempi->location.big; - FillBigEndianU2(&tabbuf->parent_entry_num,1); - MemSet(tabbuf2,0,tabsize2*CD_BLK_SIZE); - FillBigEndianU4(&iso2->type_m_path_table,cur_blk+tabsize); - tabbuf2->name_len=2; //Fill-in adam entry - tempi=&iso2->root_directory_record; - tabbuf2->blk=tempi->location.big; - FillBigEndianU2(&tabbuf2->parent_entry_num,1); - itabbuf=tabbuf+sizeof(ISOPathTableEntry); - itabbuf2=tabbuf2+sizeof(ISOPathTableEntry); - first_free=2; - for (i=1;i<=max_depth;i++) - CDFillPathTable(rootdir,&itabbuf,&itabbuf2, - 1,TRUE,&first_free,1,i); - coutln cur_blk,": Path Table 2"; - FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2); - cur_blk+=tabsize; - coutln cur_blk,": Path Table 3"; - FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2); - cur_blk+=tabsize2; - - DelLTDirList(rootdir); //TODO: Free user_data - FillU4Palindrome(&iso->volume_space_size,cur_blk); - FillU4Palindrome(&iso2->volume_space_size,cur_blk); - FWBlks(out_file,iso,16<<2,4); - - iso3->type=ISOT_TERMINATOR; - StrCpy(iso3->id,"CD001"); - iso3->version=1; - if (bootfile_buf) { - FWBlks(out_file,iso1,17<<2,4); - FWBlks(out_file,iso2,18<<2,4); - FWBlks(out_file,iso3,19<<2,4); - } else { - FWBlks(out_file,iso2,17<<2,4); - FWBlks(out_file,iso3,18<<2,4); - } - } else - cur_blk=0; - - FClose(out_file); - Free(tabbuf); - Free(tabbuf2); - Free(et); - Free(bootfile_buf); - Free(iso); - Free(iso1); - Free(iso2); - Free(iso3); - Free(filename2); - return cur_blk; -} -#help_index "" diff --git a/LT/Adam/DisplayKeys.APZ b/LT/Adam/DisplayKeys.APZ deleted file mode 100644 index f76dd23..0000000 Binary files a/LT/Adam/DisplayKeys.APZ and /dev/null differ diff --git a/LT/Adam/FileManager.APZ b/LT/Adam/FileManager.APZ deleted file mode 100644 index c3161a3..0000000 --- a/LT/Adam/FileManager.APZ +++ /dev/null @@ -1,684 +0,0 @@ -#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 deleted file mode 100644 index ac9a166..0000000 --- a/LT/Adam/Gr/Gr.APZ +++ /dev/null @@ -1,13 +0,0 @@ -#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 deleted file mode 100644 index 92c241c..0000000 --- a/LT/Adam/Gr/GrBitMap.APZ +++ /dev/null @@ -1,1465 +0,0 @@ -#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 deleted file mode 100644 index c71faa4..0000000 Binary files a/LT/Adam/Gr/GrChar.APZ and /dev/null differ diff --git a/LT/Adam/Gr/GrElem.APZ b/LT/Adam/Gr/GrElem.APZ deleted file mode 100644 index 6c9da8c..0000000 --- a/LT/Adam/Gr/GrElem.APZ +++ /dev/null @@ -1,1664 +0,0 @@ -#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 deleted file mode 100644 index 24f5e3e..0000000 --- a/LT/Adam/Gr/GrMath.APZ +++ /dev/null @@ -1,569 +0,0 @@ -#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 deleted file mode 100644 index 1aa5990..0000000 Binary files a/LT/Adam/Gr/GrScreen.APZ and /dev/null differ diff --git a/LT/Adam/GrAsm/Gr1.ASZ b/LT/Adam/GrAsm/Gr1.ASZ deleted file mode 100644 index 97d37fe..0000000 --- a/LT/Adam/GrAsm/Gr1.ASZ +++ /dev/null @@ -1,593 +0,0 @@ - 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 deleted file mode 100644 index 8ea6891..0000000 Binary files a/LT/Adam/GrAsm/GrAsm.BIZ and /dev/null differ diff --git a/LT/Adam/GrAsm/GrAsm.HPZ b/LT/Adam/GrAsm/GrAsm.HPZ deleted file mode 100644 index d690968..0000000 --- a/LT/Adam/GrAsm/GrAsm.HPZ +++ /dev/null @@ -1,19 +0,0 @@ -#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 deleted file mode 100644 index cb9402f..0000000 Binary files a/LT/Adam/GrAsm/GrAsm.MPZ and /dev/null differ diff --git a/LT/Adam/GrAsm/GrAsm.SPZ b/LT/Adam/GrAsm/GrAsm.SPZ deleted file mode 100644 index 0218add..0000000 Binary files a/LT/Adam/GrAsm/GrAsm.SPZ and /dev/null differ diff --git a/LT/Adam/HashUtils.APZ b/LT/Adam/HashUtils.APZ deleted file mode 100644 index 7db67f9..0000000 --- a/LT/Adam/HashUtils.APZ +++ /dev/null @@ -1,397 +0,0 @@ -#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.APZ b/LT/Adam/IncCompress.APZ deleted file mode 100644 index 108a751..0000000 --- a/LT/Adam/IncCompress.APZ +++ /dev/null @@ -1,311 +0,0 @@ -#help_index "Compression" - -#define ICT_U2 1 -#define ICT_U4 2 -#define ICT_U8 3 - -class IncCompressStructU2 -{ - U2 match_start; - U2 match_size; - U2 diff_size; - U0 diff_data; -}; - -class IncCompressStructU4 -{ - U4 match_start; - U2 match_size; - U2 diff_size; - U0 diff_data; -}; - -class IncCompressStructU8 -{ - U8 match_start; - U2 match_size; - U2 diff_size; - U0 diff_data; -}; - -class IntermediateIncCompressStruct -{ - IntermediateIncCompressStruct *next,*last; - U8 match_start_ref,match_start,match_size; -}; - -void IncCompressRange(U1 *ref,U8 ref_size,U1 *b,U8 range_start,U8 range_end, - IntermediateIncCompressStruct *root,U8 type_size) -{ - I8 i,j,k,n,best_k=0,best_j,best_i; - IntermediateIncCompressStruct *tempc; - -//$BK,1$TODO: improve this algorithm$BK,0$ - - for (i=range_start;ibest_k) { - best_k=k; - best_j=j; - best_i=i; - } - } - } - if (best_k>type_size) { - if (range_start+type_sizematch_start_ref=best_j; - tempc->match_start=best_i; - tempc->match_size=best_k; - InsQue(tempc,root->last); - if (best_i+best_k+type_sizematch_size-sizeof(IncCompressStructU2); - tempc=tempc->next; - } - } - } else if (ref_size<=0xFFFFFFFF && size<=0xFFFFFFFF) { - ic_type=ICT_U4; - i=sizeof(U1)+size+2*sizeof(U4); - IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU4)); - if (root.next==&root) - i+=sizeof(IncCompressStructU4); - else { - tempc=root.next; - while (tempc!=&root) { - i-=tempc->match_size-sizeof(IncCompressStructU4); - tempc=tempc->next; - } - } - } else { - ic_type=ICT_U8; - i=sizeof(U1)+size+2*sizeof(U8); - IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU8)); - if (root.next==&root) - i+=sizeof(IncCompressStructU8); - else { - tempc=root.next; - while (tempc!=&root) { - i-=tempc->match_size-sizeof(IncCompressStructU8); - tempc=tempc->next; - } - } - } - result=MAlloc(i); - u1=result; - *u1=ic_type; - switch (ic_type) { - case ICT_U2: - u2=result+sizeof(U1); - *u2=i; - u2+=sizeof(U2); - *u2=size; - tempi2=u2+sizeof(U2); - - tempc=root.next; - while (tempc!=&root) { - tempc1=tempc->next; - if (l || tempc->match_start-(j+l)) { - tempi2->match_start=m; - tempi2->match_size=l; - tempi2->diff_size=tempc->match_start-(j+l); - if (tempi2->diff_size) - MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size); - tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size; - } - m=tempc->match_start_ref; - j=tempc->match_start; - l=tempc->match_size; - Free(tempc); - tempc=tempc1; - } - tempi2->match_start=m; - tempi2->match_size=l; - tempi2->diff_size=size-(j+l); - if (tempi2->diff_size) - MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size); - break; - case ICT_U4: - u4=result+sizeof(U1); - *u4=i; - u4+=sizeof(U4); - *u4=size; - tempi4=u4+sizeof(U4); - -//$BK,1$TODO: deal with >65536 matches and differences$BK,0$ - tempc=root.next; - while (tempc!=&root) { - tempc1=tempc->next; - if (l || tempc->match_start-(j+l)) { - tempi4->match_start=m; - tempi4->match_size=l; - tempi4->diff_size=tempc->match_start-(j+l); - if (tempi4->diff_size) - MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size); - tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size; - } - m=tempc->match_start_ref; - j=tempc->match_start; - l=tempc->match_size; - Free(tempc); - tempc=tempc1; - } - tempi4->match_start=m; - tempi4->match_size=l; - tempi4->diff_size=size-(j+l); - if (tempi4->diff_size) - MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size); - break; - case ICT_U8: - u8=result+sizeof(U1); - *u8=i; - u8+=sizeof(U8); - *u8=size; - tempi8=u8+sizeof(U8); - -//$BK,1$TODO: deal with >65536 matches and differences$BK,0$ - tempc=root.next; - while (tempc!=&root) { - tempc1=tempc->next; - if (l || tempc->match_start-(j+l)) { - tempi8->match_start=m; - tempi8->match_size=l; - tempi8->diff_size=tempc->match_start-(j+l); - if (tempi8->diff_size) - MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size); - tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size; - } - m=tempc->match_start_ref; - j=tempc->match_start; - l=tempc->match_size; - Free(tempc); - tempc=tempc1; - } - tempi8->match_start=m; - tempi8->match_size=l; - tempi8->diff_size=size-(j+l); - if (tempi8->diff_size) - MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size); - break; - } - return result; -} - -public U1 *IncExpand(U1 *ref,IncCompressStructU2 *b,U8 *size=NULL) -{ - U1 *result,*dst,*u1=b,*b_end; - U2 *u2; - U4 *u4; - U8 *u8=b,s,ic_type; - IncCompressStructU2 *tempi2; - IncCompressStructU4 *tempi4; - IncCompressStructU8 *tempi8; - - ic_type=*u1; - - switch (ic_type) { - case ICT_U2: - u2=b+sizeof(U1); - b_end=b+*u2; - u2+=sizeof(U2); - s=*u2; - break; - case ICT_U4: - u4=b+sizeof(U1); - b_end=b+*u4; - u4+=sizeof(U4); - s=*u4; - break; - case ICT_U8: - u8=b+sizeof(U1); - b_end=b+*u8; - u8+=sizeof(U8); - s=*u8; - break; - } - result=MAlloc(s); - if (size) *size=s; - dst=result; - - switch (ic_type) { - case ICT_U2: - tempi2=b+sizeof(U1)+2*sizeof(U2); - while (tempi2match_size) { - MemCpy(dst,ref+tempi2->match_start,tempi2->match_size); - dst+=tempi2->match_size; - } - if (tempi2->diff_size) { - MemCpy(dst,&tempi2->diff_data,tempi2->diff_size); - dst+=tempi2->diff_size; - } - tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size; - } - break; - case ICT_U4: - tempi4=b+sizeof(U1)+2*sizeof(U4); - while (tempi4match_size) { - MemCpy(dst,ref+tempi4->match_start,tempi4->match_size); - dst+=tempi4->match_size; - } - if (tempi4->diff_size) { - MemCpy(dst,&tempi4->diff_data,tempi4->diff_size); - dst+=tempi4->diff_size; - } - tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size; - } - break; - case ICT_U8: - tempi8=b+sizeof(U1)+2*sizeof(U8); - while (tempi8match_size) { - MemCpy(dst,ref+tempi8->match_start,tempi8->match_size); - dst+=tempi8->match_size; - } - if (tempi8->diff_size) { - MemCpy(dst,&tempi8->diff_data,tempi8->diff_size); - dst+=tempi8->diff_size; - } - tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size; - } - break; - } - return result; -} -#help_index "" diff --git a/LT/Adam/InputPointer.APZ b/LT/Adam/InputPointer.APZ deleted file mode 100644 index f81d010..0000000 --- a/LT/Adam/InputPointer.APZ +++ /dev/null @@ -1,21 +0,0 @@ -#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=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 - ip_lb_last=FALSE,ip_rb_last=FALSE, - ip_lb=FALSE,ip_cb=FALSE,ip_rb=FALSE; //Left/center/right buttons -public BoolU4 ip_has_wheel=FALSE; -public LTDate last_ip_move_time=BootTime; - -#help_index "" diff --git a/LT/Adam/JoyStick.APZ b/LT/Adam/JoyStick.APZ deleted file mode 100644 index 7271e61..0000000 Binary files a/LT/Adam/JoyStick.APZ and /dev/null differ diff --git a/LT/Adam/KbdMouse.APZ b/LT/Adam/KbdMouse.APZ deleted file mode 100644 index 9ea84f6..0000000 --- a/LT/Adam/KbdMouse.APZ +++ /dev/null @@ -1,738 +0,0 @@ -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 deleted file mode 100644 index 4bd4bb1..0000000 Binary files a/LT/Adam/LPT.APZ and /dev/null differ diff --git a/LT/Adam/LogIn.APZ b/LT/Adam/LogIn.APZ deleted file mode 100644 index 96695a9..0000000 Binary files a/LT/Adam/LogIn.APZ and /dev/null differ diff --git a/LT/Adam/Ltf/Ltf.APZ b/LT/Adam/Ltf/Ltf.APZ deleted file mode 100644 index 59938f0..0000000 Binary files a/LT/Adam/Ltf/Ltf.APZ and /dev/null differ diff --git a/LT/Adam/Ltf/LtfBible.APZ b/LT/Adam/Ltf/LtfBible.APZ deleted file mode 100644 index c1cb75f..0000000 --- a/LT/Adam/Ltf/LtfBible.APZ +++ /dev/null @@ -1,154 +0,0 @@ -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 deleted file mode 100644 index 13c0a58..0000000 --- a/LT/Adam/Ltf/LtfCtrlL.APZ +++ /dev/null @@ -1,930 +0,0 @@ -#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 deleted file mode 100644 index 89eb254..0000000 --- a/LT/Adam/Ltf/LtfEdit.APZ +++ /dev/null @@ -1,1389 +0,0 @@ -#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 deleted file mode 100644 index e959fbc..0000000 --- a/LT/Adam/Ltf/LtfFile.APZ +++ /dev/null @@ -1,313 +0,0 @@ -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 deleted file mode 100644 index ac1bffb..0000000 --- a/LT/Adam/Ltf/LtfMacro.APZ +++ /dev/null @@ -1,126 +0,0 @@ -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 deleted file mode 100644 index d4570c9..0000000 --- a/LT/Adam/Ltf/LtfMain.APZ +++ /dev/null @@ -1,677 +0,0 @@ -#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 deleted file mode 100644 index 990f3ce..0000000 --- a/LT/Adam/Ltf/LtfNew.APZ +++ /dev/null @@ -1,505 +0,0 @@ -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 deleted file mode 100644 index 83c11ba..0000000 --- a/LT/Adam/Ltf/LtfPlain.APZ +++ /dev/null @@ -1,688 +0,0 @@ -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 deleted file mode 100644 index 4765f7e..0000000 --- a/LT/Adam/Ltf/LtfPopUp.APZ +++ /dev/null @@ -1,621 +0,0 @@ -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 deleted file mode 100644 index 84bba98..0000000 --- a/LT/Adam/Ltf/LtfRecalc.APZ +++ /dev/null @@ -1,1657 +0,0 @@ -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.APZ b/LT/Adam/Math.APZ deleted file mode 100644 index e7ea0c7..0000000 --- a/LT/Adam/Math.APZ +++ /dev/null @@ -1,66 +0,0 @@ -#help_index "Math" - -public double Abs(double i) -{ - if (i<0) - return -i; - else - return i; -} - -public double Sign(double i) -{ - if (i<0) - return -1.0; - else if (!i) - return 0.0; - else - return 1.0; -} - -public double Sqr(double d) -{ - return d*d; -} - -public void R2P(double *mag,double *arg,double x,double y) -{ //Rect to polar - *arg=Arg(x,y); - *mag=Sqrt(x*x+y*y); -} - -public void P2R(double *x,double *y,double mag,double arg) -{ //Polar to Rect - *x=mag*Cos(arg); - *y=mag*Sin(arg); -} - -public double Unwrap(double theta,double base=-pi) -{ - double result=theta%pi2; - if (resultbase+pi2) result-=pi2; - return result; -} - -public I8 SignI8(I8 i) -{ - if (i<0) - return -1; - else if (!i) - return 0; - else - return 1; -} - -public I8 SqrI8(I8 i) -{ - return i*i; -} - -public I8 DistI8(I8 x1,I8 y1,I8 x2,I8 y2) -{ - I8 dx=x1-x2,dy=y1-y2; - return dx*dx+dy*dy; -} -#help_index "" diff --git a/LT/Adam/Message.APZ b/LT/Adam/Message.APZ deleted file mode 100644 index a07a5f4..0000000 --- a/LT/Adam/Message.APZ +++ /dev/null @@ -1,142 +0,0 @@ -#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<='0' && ch<='9') { - music_octive=ch-'0'; - ch=*st++; - } - return --st; -} - -I1 *MusicSetNoteLen(I1 *st) -{ - BoolU4 cont=TRUE; - do { - switch (*st++) { - case 'w': music_note_len=4.0; break; - case 'h': music_note_len=2.0; break; - case 'q': music_note_len=1.0; break; - case 'e': music_note_len=0.5; break; - case 's': music_note_len=0.25; break; - case 't': music_note_len=2.0*music_note_len/3.0; break; - case '.': music_note_len=1.5*music_note_len; break; - default: - st--; - cont=FALSE; - } - } while (cont); - return st; -} - -public double Note2Freq(I8 note,I8 octive=3) -{ - return 2.0`(6+octive+(note-3)/12.0); -} - -public void Play(I1 *st,I1 *words=NULL) -/* - Notes are entered with a capital letter. - - Octives are entered with a digit and - stay set until changed. - - Durations are entered with - 'w' whole note - 'h' half note - 'q' quarter note - 'e' eighth note - 't' sets to 2/3rds the current duration - '.' sets to 1.5 times the current duration - durations stay set until changed. - - Sharp and flat are done with '#' or 'b'. - - The variable $FG,4$music_stacatto_factor$FG$ can - be set to a range from 0.0 to 1.0. - - The variable $FG,4$music_tempo$FG$ defaults to - 2.5 and gets faster when bigger. - -*/ - -{ - I1 *word; - U8 note,i=0; - double f; - music_play_note_num=0; - while (*st) { - st=MusicSetOctive(st); - st=MusicSetNoteLen(st); - st=MusicSetOctive(st); - if (!*st) break; - note=*st++-'A'; - if (note<7) { - note=music_note_map[note]; - if (*st=='b') { - note--; - st++; - } else if (*st=='#') { - note++; - st++; - } - f=Note2Freq(note,music_octive); - } else - f=0; - if (words) { - if (word=PointAtListEntry(i++,words)) - if (StrCmp(word," ")) - PutS(word); - } - if (!music_mute) - Sound(f); - Sleep(1000*music_stacatto_factor*music_note_len/music_tempo); - if (!music_mute) - Sound(0); - Sleep(1000*(1.0-music_stacatto_factor)*music_note_len/music_tempo); - music_play_note_num++; - } -} - -void ResetMusicSettings() -{ - music_stacatto_factor=1.0; - music_tempo=2.5; - music_octive=3; - music_note_len=1.0; -} - -ResetMusicSettings; - - -void EndCurSong() -{ - Sound(0); - Exit; -} - -void CurSongTsk() -{ - Preempt(ON); - Fs->end_task_cb=&EndCurSong; - while (TRUE) - Play(cur_song); -} - -#help_index "" diff --git a/LT/Adam/ODE.APZ b/LT/Adam/ODE.APZ deleted file mode 100644 index ccae3d3..0000000 --- a/LT/Adam/ODE.APZ +++ /dev/null @@ -1,194 +0,0 @@ -#help_index "Math" - -//This is taken from the book, $UL,1$Numeric Recipies in C$UL,0$ - -Ode *OdeNew(U8 n) -{ - Ode *o=MAllocZ(sizeof(Ode)); - o->n=n; - o->state=MAllocZ(n*sizeof(double)); - o->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)); - o->initial_state=MAllocZ(n*sizeof(double)); - o->tolerance_start=1.0e-6; - o->temp0=MAllocZ(n*sizeof(double)); - o->temp1=MAllocZ(n*sizeof(double)); - o->temp2=MAllocZ(n*sizeof(double)); - o->temp3=MAllocZ(n*sizeof(double)); - o->temp4=MAllocZ(n*sizeof(double)); - o->temp5=MAllocZ(n*sizeof(double)); - o->temp6=MAllocZ(n*sizeof(double)); - o->temp7=MAllocZ(n*sizeof(double)); - 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); - Free(o->temp0); - Free(o->temp1); - Free(o->temp2); - Free(o->temp3); - Free(o->temp4); - Free(o->temp5); - Free(o->temp6); - Free(o->temp7); - Free(o); -} - -void OdeOneStep(Ode *o) -{ - I8 i; - o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt); - for (i=0;in;i++) - o->internal_state[i]+=o->h*o->DstateDt[i]; - o->t+=o->h; -} - -void OdeRK4OneStep(Ode *o) -{ - I8 i,n=o->n; - double xh,hh,h6; - double *dym,*dyt,*yt,*DstateDt; - - dym =o->temp0; - dyt =o->temp1; - yt =o->temp2; - DstateDt=o->temp3; - hh =0.5*o->h; - h6 =o->h / 6.0; - xh =o->t +o->base_t+ hh; - - o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt); - for (i=0;iinternal_state[i]+hh*DstateDt[i]; - o->derivative(o,xh,yt,dyt); - for (i=0;iinternal_state[i]+hh*dyt[i]; - o->derivative(o,xh,yt,dym); - for (i=0;iinternal_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;iinternal_state[i]+=h6*(DstateDt[i]+dyt[i]+2.0*dym[i]); -} - - -#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->internal_state,*DstateDt=o->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,*tempstate,*stateerr,*outstate; - - ak2=o->temp0; - ak3=o->temp1; - ak4=o->temp2; - ak5=o->temp3; - ak6=o->temp4; - tempstate=o->temp5; - outstate=o->temp6; - stateerr=o->temp7; - - for (i=0;iderivative(o,o->t+o->base_t+ODEa2*h,tempstate,ak2); - for (i=0;iderivative(o,o->t+o->base_t+ODEa3*h,tempstate,ak3); - for (i=0;iderivative(o,o->t+o->base_t+ODEa4*h,tempstate,ak4); - for (i=0;iderivative(o,o->t+o->base_t+ODEa5*h,tempstate,ak5); - for (i=0;iderivative(o,o->t+o->base_t+ODEa6*h,tempstate,ak6); - for (i=0;itemp6,*stateerr=o->temp7; - while (TRUE) { - OdeCashKarp(o); - errmax=0.0; - for (i=0;in;i++) { - temp=Abs(stateerr[i]/o->state_scale[i]); - if (temp>errmax) - errmax=temp; - } - errmax/=o->tolerance; - if (errmax>1.0 && o->h>1.0e-64) { - temp=o->h*SAFETY*errmax`PSHRNK; - if (temp<0.1*o->h) - o->h*=0.1; - else - o->h=temp; - } else { - o->t+=o->h; - if (errmax>ERRCON) - o->h*=SAFETY*errmax`PGROW; - else - o->h*=5.0; - if (o->h>1.0e32) - o->h=1.0e32; - MemCpy(o->internal_state,tempstate,sizeof(double)*o->n); - break; - } - } -} -#help_index "" diff --git a/LT/Adam/PicWords2.APZ b/LT/Adam/PicWords2.APZ deleted file mode 100644 index bb66d8c..0000000 Binary files a/LT/Adam/PicWords2.APZ and /dev/null differ diff --git a/LT/Adam/Remote.APZ b/LT/Adam/Remote.APZ deleted file mode 100644 index f02b6c8..0000000 --- a/LT/Adam/Remote.APZ +++ /dev/null @@ -1,798 +0,0 @@ -#help_index "Comm" - -#define RMT_MAX_PKT_LEN 64 //Must be less then PKT_SYNC -#define RMT_PKT_ACK 0xA5 -#define RMT_PKT_NACK 0x5A -#define RMT_PKT_SYNC 0xA3 -#define RMT_PKT_SYNC2 0xA7 -#define RMT_PKT_CHAR 0xA4 -#define RMT_PKT_REQUEST 0xA6 -#define RMT_PKT_RESET 0xA8 - -#define RMT_FILE_ACK 0x87566565 - -#define RMT_RQST_NONE 0x00 -#define RMT_RQST_GETMSG 0x01 -#define RMT_RQST_TX_FILE 0x02 -#define RMT_RQST_RX_FILE 0x03 -#define RMT_RQST_TX_BUF 0x04 -#define RMT_RQST_RX_BUF 0x05 -#define RMT_RQST_EXE_LOCAL 0x06 -#define RMT_RQST_PUTS_CNT 0x07 - -#define RMT_NUM_RQST_TYPES 0x08 - -#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)) { - Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED2); - Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED3); - chnl->PutChar(chnl,CH_XON); - } -} - -public I8 RmtTxFifoCnt(LTChnl *chnl) -{ - if (!chnl || !chnl->type) return 0; - return U1FifoCnt(comm_Tx_fifos[chnl->port]); -} - -public void RmtWaitTxDone(LTChnl *chnl) -{ - U8 base=comm_base[chnl->port]; - if (!chnl || !chnl->type) return; - while (RmtTxFifoCnt(chnl)) - SwapInNext; - while (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; -} - -public void RmtFlushTxFifo(LTChnl *chnl) -{ - U8 base=comm_base[chnl->port]; - if (!chnl || !chnl->type) return; - U1FifoFlush(comm_Tx_fifos[chnl->port]); - RmtWaitTxDone(chnl); -} - -void RmtReset(LTChnl *chnl) -{ - RmtFlushTxFifo(chnl); - RmtFlushRxFifo(chnl); - comm_flags[chnl->port]=0; -} - - - -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 I8 RmtRxFifoCnt(LTChnl *chnl) -{ - if (!chnl || !chnl->type) return 0; - return U1FifoCnt(comm_Rx_fifos[chnl->port]); -} - -public U1 RmtGetChar(LTChnl *chnl) -{ - if (!chnl || !chnl->type) - return 0; - return CommGetChar(chnl->port); -} - -public BoolU4 RmtScanChar(LTChnl *chnl,U1 *ch) -{ - if (!chnl || !chnl->type) - return 0; - return CommScanChar(chnl->port,ch); -} -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_RESET) { - chnl->PutChar(chnl,CH_ESC); - chnl->PutChar(chnl,b^0x80); - return 2; - } else { - chnl->PutChar(chnl,b); - return 1; - } -} - -BoolU8 RmtRxPktU1(LTChnl *chnl,U1 *b, - U8 timeout_jiffies,BoolU4 *esc=NULL) -{ - U1 b1; - U8 timeout; - *b=RMT_PKT_NACK; - if (esc) - *esc=FALSE; - if (!chnl || !chnl->type) - return FALSE; - timeout=Jiffies+timeout_jiffies; - while (JiffiesScanChar(chnl,&b1)) { - if (b1==CH_ESC) { - timeout=Jiffies+timeout_jiffies; - while (JiffiesScanChar(chnl,&b1)) { - *b=b1^0x80; - if (esc) *esc=TRUE; - return TRUE; - } - SwapInNext; - } - return FALSE; - } else { - if (b1==RMT_PKT_RESET) { - RmtReset(chnl); - throw(EXCP_RESET); - } - *b=b1; - return TRUE; - } - } - SwapInNext; - } - return FALSE; -} - -#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,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); - if (RmtScanChar(chnl,&b)) { - Sleep(ERR_DELAY); - goto rt_err1; - } - RmtTxPktU1(chnl,rqst); - RmtWaitTxDone(chnl); - 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); - if (RmtScanChar(chnl,&b)) { - Sleep(ERR_DELAY); - goto rt_err2; - } - RmtTxPktU1(chnl,p[0]); - RmtWaitTxDone(chnl); - 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); - if (RmtScanChar(chnl,&b)) { - Sleep(ERR_DELAY); - goto rt_err3; - } - RmtTxPktU1(chnl,RMT_PKT_SYNC2); - RmtWaitTxDone(chnl); - 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,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, - U8 timeout_delay=0) -{ //zero timeout_delay=none - U1 b,b1,xsum; - 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,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_NUM_RQST_TYPES) { - if (b1==RMT_PKT_REQUEST && !esc) - goto rr_cont; - else - goto rr_err; - } - 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) { - if (b1==RMT_PKT_SYNC) - goto rr_cont; - else - goto rr_err; - } - if (RmtScanChar(chnl,&b)) - goto rt_err; - RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_SYNC); - RmtWaitTxDone(chnl); - RmtRxPktU1(chnl,&s,RMT_CHAR_DELAY); - if (s>RMT_MAX_PKT_LEN) - goto rr_err; - 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) -{ - U1 b[RMT_MAX_PKT_LEN]; - U8 size; - if (!chnl || !chnl->type) return; - while (cnt>0) { - if (cnttype) return NULL; - result=MAlloc(cnt); - buf=result; - while (cnt>0) { - RmtRxPkt(chnl,b,&size); - MemCpy(buf,b,size); - cnt-=size; - buf+=size; - progress1=cnt; - } - return result; -} - -public U8 RmtGetMsg(LTChnl *chnl,I8 *p1,I8 *p2) -{ - U8 cmd=0,size; - U1 b[RMT_MAX_PKT_LEN]; - *p1=0; - *p2=0; - if (!chnl || !chnl->type) - return 0; - if (Jiffiesnull_msg_jiffy) - return 0; - try { - RmtTxPkt(chnl,NULL,0,RMT_RQST_GETMSG); - RmtRxPkt(chnl,b,&size); - 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; -} - -public void RmtSendMsg(LTChnl *chnl,U8 cmd,I8 p1,I8 p2) -{ - U1 b[RMT_MAX_PKT_LEN]; - if (!chnl || !chnl->type) return; - if (cmd) { - b[0]><(U8)=cmd; - b[8]><(U8)=p1; - b[16]><(U8)=p2; - RmtTxPkt(chnl,b,sizeof(U8)*3); - } else { - RmtTxPkt(chnl,b,1); - chnl->null_msg_cnt++; - } -} - -public BoolU4 RmtPutKey(I8 ch,U8 sc) -{ - 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) -{ - if (!chnl || !chnl->type) return; - if (buf) { - RmtTxBlk(chnl,&size,sizeof(U8)); - RmtTxBlk(chnl,buf,size); - } -} - -public U1 *RmtRxBuf(LTChnl *chnl,U8 *size=NULL) -{ - U1 *buf; - U8 *size2; - if (size) *size=0; - if (!chnl || !chnl->type) return NULL; - size2=RmtRxBlk(chnl,sizeof(U8)); - buf=RmtRxBlk(chnl,*size2); - if (size) *size=*size2; - Free(size2); - return buf; -} - -public BoolU4 RmtTxFile(LTChnl *chnl,I1 *filename, - BoolU4 raw=TRUE) -{ - 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) { - RmtTxBuf(chnl,&de.start,LT_DIR_ENTRY_SIZE); - RmtTxBuf(chnl,buf,size); - 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,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)) { - 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); - 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) -{ - U8 len; - if (!chnl || !chnl->type) return; - if (st) { - len=StrLen(st); - if (len) { - if (len>RMT_MAX_PKT_LEN) { - RmtTxPkt(chnl,NULL,0,RMT_RQST_PUTS_CNT); - RmtTxBuf(chnl,st,len+1); - } else - RmtTxBlk(chnl,st,len); - } - } -} - -public void RmtTxPutChar(LTChnl *chnl,I8 ch) -{ - if (!chnl || !chnl->type) return; - if (ch) - RmtTxPkt(chnl,&ch,1); -} - -public I1 *RmtRxPutS(LTChnl *chnl,U8 *rqst=NULL) -{ - U1 b[RMT_MAX_PKT_LEN]; - U8 size; - U1 *buf=NULL; - if (!chnl || !chnl->type) return NULL; - if (RmtRxFifoCnt(chnl)>=2) { - RmtRxPkt(chnl,b,&size,rqst); - if (size) { - buf=MAlloc(size+1); - MemCpy(buf,b,size); - buf[size]=0; - } else - buf=MAllocZ(1); - } - return buf; -} - -public U1 *RmtRqstTxBuf() -{ -//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); - result=RmtRxBuf(chnl); - return result; -} - -public void RmtRqstRxBuf(U1 *src_local_buf,U8 size) -{ //Dst buf address is placed in remote's chnl->rx_buf - LTChnl *chnl=Fs->rmt_chnl; - if (!chnl || !chnl->type) return; - RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_BUF); - RmtTxBuf(chnl,src_local_buf,size); -} - -public void RmtRqstTxFile(I1 *dst_local_filename,I1 *src_remote_filename) -{ - LTChnl *chnl=Fs->rmt_chnl; - if (!chnl || !chnl->type) return; - RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_FILE); - RmtTxBuf(chnl,src_remote_filename,StrLen(src_remote_filename)+1); - RmtRxFile(chnl,dst_local_filename); -} - -public void RmtRqstRxFile(I1 *src_local_filename,I1 *dst_remote_filename) -{ - LTChnl *chnl=Fs->rmt_chnl; - if (!chnl || !chnl->type) return; - RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_FILE); - RmtTxBuf(chnl,dst_remote_filename,StrLen(dst_remote_filename)+1); - RmtTxFile(chnl,src_local_filename); -} - -public void RmtRqstExeLocal(I1 *st) -{ - LTChnl *chnl=Fs->rmt_chnl; - if (!chnl || !chnl->type) return; - RmtTxPkt(chnl,NULL,0,RMT_RQST_EXE_LOCAL); - RmtTxBuf(chnl,st,StrLen(st)+1); -} - -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; -} - -public void TelnetHostClose() -{ - Fs->rmt_chnl=NULL; -} - -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 "$$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: - if (msg_sent) - cmd=ScanMsg(&p1,&p2, - 1<task_flags|=1<tx_buf,chnl->tx_size); - break; - case RMT_RQST_RX_BUF: - chnl->rx_buf=RmtRxBuf(chnl); - break; - case RMT_RQST_EXE_LOCAL: - st=RmtRxBuf(chnl); - ExecuteStr(st); - Free(st); - break; - case RMT_RQST_PUTS_CNT: - Free(st2); - st2=RmtRxBuf(chnl); - PutS(st2); - break; - } - Free(st2); - st2=NULL; - } else { - Fs->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); - } - } - } - Fs->local_chnl=NULL; - Preempt(old_preempt); -} - -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.APZ b/LT/Adam/Utils.APZ deleted file mode 100644 index 4b54cac..0000000 --- a/LT/Adam/Utils.APZ +++ /dev/null @@ -1,445 +0,0 @@ -#help_index "File/Cmd Line (Typically)" - -public U1 *PatchBlk(U8 blk,BoolU4 write=FALSE) -{ - U1 *buf=MAlloc(BLK_SIZE); - - RBlks(Fs->cur_partition,buf,blk,1,TRUE); - LtfD(buf,BLK_SIZE); - if (write) { - coutln "Edit and press ESC to write or ^Q"; - if (View) { - coutln "Write"; - WBlks(Fs->cur_partition,buf,blk,1,TRUE); - } - } - return buf; -} - -public U1 *Patch(U8 c,BoolU4 write=FALSE) -{ - U1 *buf=MAlloc(Fs->cur_partition->spc<cur_partition,buf,c,1,TRUE); - coutln "Cluster:",c; - LtfD(buf,Fs->cur_partition->spc<cur_partition,buf,c,1,TRUE); - } - } - return buf; -} - -#help_index "Memory" -void CorruptSysMemory() -{ - Debugger; -} - -void CorruptTaskMemory() -{ - Debugger; -} - -public U8 UnusedSysMem() -{ - MemBlk *tempm; - U8 i,result=0,old_flags=GetFlags; - Cli; - tempm=mem_free_list; - while (tempm) { - if (tempm->signature!=MBS_UNUSED_SIGNATURE) - CorruptSysMemory; - 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,*m1; - U8 result=0,old_flags=GetFlags; - if (!tss) tss=Fs; - Cli; - 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); - return result; -} - -public U8 TaskUnusedAllocatedMem(TssStruct *tss=NULL) -{ - U8 result=0,i,old_flags=GetFlags; - UnusedAllocatedMem *u; - if (!tss) tss=Fs; - Cli; - for (i=0;i>3;i++) { - u=tss->heap_hash[i]; - while (u) { - result+=u->size; - u=u->next; - } - } - u=tss->malloc_free_list; - while (u) { - result+=u->size; - u=u->next; - } - SetFlags(old_flags); - return result; -} - -#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) -{ - return *e1-*e2; -} - -I8 CompareUamSize(UnusedAllocatedMem **e1, - UnusedAllocatedMem **e2) -{ - return (*e2)->size-(*e1)->size; -} - - -public void HeapRep(TssStruct *tss=NULL) -{ - I8 i,cnt; - UnusedAllocatedMem *u; - U8 old_flags=GetFlags; - - if (!tss) tss=Fs; - Cli; - for (i=0;i>3;i++) { - cnt=0; - u=tss->heap_hash[i]; - while (u) { - cnt+=u->size; - u=u->next; - } - if (cnt) - PrintF("%03X:%08X\r\n",i<<2,cnt); - } - u=tss->malloc_free_list; - while (u) { - PrintF("%08X\r\n",u->size); - u=u->next; - } - SetFlags(old_flags); -} - -public BoolU4 IsInHeap(U1 *a,TssStruct *tss=NULL) -{ - MemBlk *m; - U8 old_flags=GetFlags; - if (!tss) tss=Fs; - m=tss->next_mem_blk; - Cli; - while (m!=&tss->next_mem_blk) { - if (a>=m && apages*PAGE_SIZE) { - SetFlags(old_flags); - return TRUE; - } - m=m->next; - } - SetFlags(old_flags); - return FALSE; -} - -public BoolU4 HeapWalk(TssStruct *tss=NULL) -//Detects just one type of error -- -//a freed value, not valid. -{ - I8 i; - UnusedAllocatedMem *u; - BoolU4 result=TRUE; - U8 old_flags=GetFlags; - - if (!tss) tss=Fs; - if (!ValidateTss(tss)) return FALSE; - Cli; - for (i=0;i>3;i++) { - u=tss->heap_hash[i]; - while (u) { - if (!IsInHeap(u,tss)) - result=FALSE; - u=u->next; - } - } - u=tss->malloc_free_list; - while (u) { - if (!IsInHeap(u,tss)) - result=FALSE; - u=u->next; - } - SetFlags(old_flags); - return result; -} - - -#help_index "Memory" - -//TODO:Crashes -///More of a heap check at the moment -void CollectFreedAllocatedMem(TssStruct *tss=NULL) -{ - I8 i,cnt; -//I8 j; - UnusedAllocatedMem *u,**sort_buf; - U8 old_flags=GetFlags; -// U4 *dd; - - if (!tss) tss=Fs; - Cli; - cnt=0; - for (i=0;i>2;i++) { - u=tss->heap_hash[i]; - while (u) { - cnt++; - u=u->next; - } - } - u=tss->malloc_free_list; - while (u) { - cnt++; - u=u->next; - } - SetFlags(old_flags); - - //We might disturb the Free list and irq's might Free some - sort_buf=MAlloc(((cnt+512)&-0x100)*sizeof(void *)); - - Cli; - cnt=0; - - for (i=0;i>2;i++) { - u=tss->heap_hash[i]; - while (u) { - sort_buf[cnt++]=u; - u=u->next; - } - tss->heap_hash[i]=NULL; - } - - u=tss->malloc_free_list; - while (u) { - sort_buf[cnt++]=u; - u=u->next; - } - tss->malloc_free_list=NULL; - - for (i=0;isize>sort_buf[i+1]) - cout "****"; - coutln sort_buf[i]," ",sort_buf[i]->size; - } -/* - j=0; - for (i=0;isize && - sort_buf[j]->size+sort_buf[i]->sizesize=sort_buf[j]->size+ - sort_buf[i]->size; - else - sort_buf[++j]=sort_buf[i]; - } - if (cnt) { - j++; - QSort(sort_buf,j,sizeof(void *),&CompareUamSize); - for (i=0;inext=sort_buf[i]->size; - Free(sort_buf[i]+4,tss); - } - } -*/ - Free(sort_buf); -} - -#help_index "Task" - -void TaskRepTask(TssStruct *tss,I8 indent) -{ - TssStruct *tss1; - I1 *st,*desc=MSPrintF("%q",tss->task_descriptor); - st=MSPrintF("$$MA+A,\"%08X\",\"Kill(0x%X);\r\",$$",tss,tss,tss); - PrintF("%*s%s $$TX+SCX,\"%Q...\",16$$ Mem:%08X\r\n", - indent,"",st,desc, - 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->next_child_tss-offset(TssStruct.next_sibling_tss)) { - TaskRepTask(tss1,indent+2); - tss1=tss1->next_sibling_tss; - } -} - -public void TaskRep() -{ - U1 i; - U8 old_flags=GetFlags; - CPUStruct *c; - Cli; - for (i=0;icain_tss,2); - } - SetFlags(old_flags); -} - - -void CtrlAltX() -{ - Bts(sys_flags,SYSf_CTRL_ALT_X); -} -ctrl_alt_letter_routines['X'-'A']=&CtrlAltX; - - -void CtrlAltC() -{ - Bts(sys_flags,SYSf_CTRL_ALT_C); -} -ctrl_alt_letter_routines['C'-'A']=&CtrlAltC; - -#help_index "File/FileNames" - -public BoolU4 IsTextFile(I1 *filename) -{ - return WildFileNameList(TEXT_FILE_MASK,filename); -} - -public BoolU4 IsSourceFile(I1 *filename) -{ - return WildFileNameList(SOURCE_FILE_MASK,filename); -} - -public BoolU4 IsCFile(I1 *filename) -{ - return WildFileNameList(C_FILE_MASK,filename); -} - -public BoolU4 IsAsmFile(I1 *filename) -{ - return WildFileNameList(ASM_FILE_MASK,filename); -} - - -#help_index "" - \ No newline at end of file diff --git a/LT/Adam/WallPaper.APZ b/LT/Adam/WallPaper.APZ deleted file mode 100644 index 720d60f..0000000 Binary files a/LT/Adam/WallPaper.APZ and /dev/null differ diff --git a/LT/Adam/Window.APZ b/LT/Adam/Window.APZ deleted file mode 100644 index bcb755e..0000000 --- a/LT/Adam/Window.APZ +++ /dev/null @@ -1,1080 +0,0 @@ -#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 deleted file mode 100644 index dd84144..0000000 --- a/LT/Adam/WordStat/WSDict.APZ +++ /dev/null @@ -1,450 +0,0 @@ -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 && nn; - for (i=0;iside[i]; - coutln "col:",i," rhits:",ms->row_hits," chits:",ms->col_hits; - tempw=ms->next; - while (tempw!=ms) { - coutln " substructs:",tempw->substructs, - " entries:",tempw->entries; - for (j=0;jsubstructs;j++) { - PrintF("(%04X %04X) ", - tempw->subs[j].hits, - tempw->subs[j].repeats); - } - CrLf; - tempw=tempw->next; - } - } - - View; -} - -WsHashEntry *WsAddHash(I1 *w) -{ - WsHashEntry *tempw=FindHashEntry(w,ws_hash_table,HTT_WORD); - if (tempw) { - tempw->hits++; - return tempw; - } - tempw=AMAllocZ(sizeof(WsHashEntry)); - tempw->word=ANewStr(w); - tempw->type=HTT_WORD; - tempw->use_cnt=1; - tempw->hits=1; - tempw->num=-1; - AddSysHashEntry(tempw,ws_hash_table); - ws_num_words++; - return tempw; -} - -void WsInitSides(WsMatrix *m) -{ - I8 i; - WsStruct *tempa; - m->n=0; - for (i=0;iside[i].next=&m->side[i].next; - m->side[i].last=&m->side[i].next; - m->side[i].const_minus_one=-1; - m->side[i].row_hits=0; - m->side[i].col_hits=0; - tempa=AMAlloc(sizeof(WsStruct)); - tempa->subs[0].hits=0; - tempa->subs[0].repeats=ws_num_matrix_words; - tempa->entries=ws_num_matrix_words; - tempa->substructs=1; - InsQue(tempa,m->side[i].last); - } -} - -WsStruct *WsFindStruct(WsMatrix *m,I8 col,I8 row, - I8 *row_base,I8 *substruct) -{ - WsStruct *tempa; - if (row>=ws_num_matrix_words || - col>=ws_num_matrix_words) - return NULL; - if (row>1) { - tempa=m->side[col].next; - *row_base=0; - while (row>=tempa->entries) { - row-=tempa->entries; - *row_base+=tempa->entries; - tempa=tempa->next; - } - for (*substruct=0;row>=tempa->subs[*substruct].repeats;*substruct=*substruct+1) { - row-=tempa->subs[*substruct].repeats; - *row_base+=tempa->subs[*substruct].repeats; - } - } else { - row=ws_num_matrix_words-row; - tempa=m->side[col].last; - *row_base=ws_num_matrix_words; - while (row>tempa->entries) { - row-=tempa->entries; - *row_base-=tempa->entries; - tempa=tempa->last; - } - for (*substruct=tempa->substructs-1;row>tempa->subs[*substruct].repeats; - *substruct=*substruct-1) { - row-=tempa->subs[*substruct].repeats; - *row_base-=tempa->subs[*substruct].repeats; - } - *row_base-=tempa->subs[*substruct].repeats; - } - return tempa; -} - -public I8 WsGetHits(WsMatrix *m,I8 col,I8 row) -{ - I8 row_base,substruct; - WsStruct *tempa; - if (row>=ws_num_matrix_words || - col>=ws_num_matrix_words) - return 0; - tempa=WsFindStruct(m,col,row, - &row_base,&substruct); - return tempa->subs[substruct].hits; -} - -WsSubstruct *WsNext(WsSubstruct *s,WsStruct **parent) -{ - 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]; -} - -WsSubstruct *WsLast(WsSubstruct *s,WsStruct **parent) -{ - 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]; -} - -void WsRemove(WsSubstruct *s,WsStruct *parent) -{ - 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) { - RemQue(parent); - AFree(parent); - } else { - parent->entries-=s->repeats; - parent->substructs--; - MemCpy(&parent->subs[i],&parent->subs[i+1], - (parent->substructs-i)*sizeof(WsSubstruct)); - } -} - -WsSubstruct *WsInsert(WsSubstruct *s,WsStruct **parent,WsSubstruct *last) -{ - WsStruct *tempa,*p=*parent; - I8 j,k,i=(last-&p->subs)>>WS_SUBSTRUCT_SIZE_BITS+1; - if (i>=WS_SUBSTRUCTS_PER_STRUCT) { - i=0; - p=p->next; - *parent=p; - if (p->substructs==-1) { - tempa=AMAlloc(sizeof(WsStruct)); - InsQue(tempa,p->last); - p=tempa; - *parent=p; - tempa->entries=0; - tempa->substructs=0; - } - } - if (p->substructs==WS_SUBSTRUCTS_PER_STRUCT) { - tempa=p->next; - if (tempa->substructs==-1 || tempa->substructs==WS_SUBSTRUCTS_PER_STRUCT) { - tempa=AMAlloc(sizeof(WsStruct)); - tempa->entries=0; - tempa->substructs=0; - InsQue(tempa,p); - k=0; - for (j=i;jsubstructs;j++) { - MemCpy(&tempa->subs[k],&p->subs[j],sizeof(WsSubstruct)); - tempa->entries+=tempa->subs[k++].repeats; - tempa->substructs++; - } - p->entries-=tempa->entries; - p->substructs-=tempa->substructs; - } else { - for (j=tempa->substructs-1;j>=0;j--) - MemCpy(&tempa->subs[j+1],&tempa->subs[j],sizeof(WsSubstruct)); - MemCpy(&tempa->subs[0], - &p->subs[WS_SUBSTRUCTS_PER_STRUCT-1], - sizeof(WsSubstruct)); - p->entries-=tempa->subs[0].repeats; - p->substructs--; - tempa->entries+=tempa->subs[0].repeats; - tempa->substructs++; - for (j=WS_SUBSTRUCTS_PER_STRUCT-2;j>=i;j--) - MemCpy(&p->subs[j+1], - &p->subs[j],sizeof(WsSubstruct)); - } - } else { - for (j=p->substructs-1;j>=i;j--) - MemCpy(&p->subs[j+1], - &p->subs[j],sizeof(WsSubstruct)); - } - p->entries+=s->repeats; - p->substructs++; - MemCpy(&p->subs[i],s,sizeof(WsSubstruct)); - return &p->subs[i]; -} - -WsSubstruct *WsCondense(WsSubstruct *s,WsStruct **parent) -{ - WsSubstruct *temps,*temps_l,*temps_n; - WsStruct *tempa_l,*tempa_n; - if ((*parent)->substructs==-1) - return NULL; - temps=s; - tempa_l=*parent; - temps_l=WsLast(temps,&tempa_l); - if (temps_l && temps_l->hits==temps->hits) { - temps_l->repeats+=temps->repeats; - tempa_l->entries+=temps->repeats; - WsRemove(temps,*parent); - *parent=tempa_l; - temps=temps_l; - } - tempa_n=*parent; - temps_n=WsNext(temps,&tempa_n); - if (temps_n && temps_n->hits==temps->hits) { - temps->repeats=temps->repeats+temps_n->repeats; - (*parent)->entries=(*parent)->entries+temps_n->repeats; - WsRemove(temps_n,tempa_n); - } - return temps; -} - -I8 WsIncHits(WsMatrix *m,I8 col,I8 row) -{ - I8 row_base,substruct,repeats; - WsSubstruct sn,*temps,*temps1,*temps_l; - WsStruct *tempa,*tempa1,*tempa_l; - - if (row>=ws_num_matrix_words || - col>=ws_num_matrix_words) - return 0; - tempa=WsFindStruct(m,col,row,&row_base,&substruct); - temps=&tempa->subs[substruct]; - repeats=temps->repeats; - if (repeats==1) { - temps->hits++; - temps=WsCondense(temps,&tempa); - } else { - if (row==row_base) { - temps->repeats--; - tempa->entries--; - sn.hits=1; - sn.repeats=1; - tempa_l=tempa; - if (!(temps_l=WsLast(&tempa->subs[substruct],&tempa_l))) { - tempa_l=tempa->last; //header - temps_l=&tempa_l->subs[WS_SUBSTRUCTS_PER_STRUCT-1]; - } - temps=WsInsert(&sn,&tempa_l,temps_l); - temps=WsCondense(temps,&tempa_l); - } else if (row==repeats-1+row_base) { - temps->repeats--; - tempa->entries--; - sn.hits=1; - sn.repeats=1; - temps=WsInsert(&sn,&tempa,temps); - temps=WsCondense(temps,&tempa); - } else { - tempa->entries-=repeats; - sn.hits=temps->hits+1; - sn.repeats=1; - tempa1=tempa; - temps1=temps; - temps=WsInsert(&sn,&tempa1,temps1); - temps1->repeats=row-row_base; - tempa->entries+=temps1->repeats; - sn.repeats=row_base+repeats-(row+1); - sn.hits=temps1->hits; - WsInsert(&sn,&tempa1,temps); - } - } - m->n++; - m->side[col].col_hits++; - m->side[row].row_hits++; - return temps->hits; -} - -void WsAddSingleFile(LTDirEntry *tempd,BoolU4 compile) -{ - I1 ch,ch1,*buf,*ptr,*ptr2; - WsHashEntry *cur_ptr,*last_ptr=NULL; - I8 k=0; - buf=ReadTextFile(tempd->full_name); - ptr=buf; - - while (ch=*ptr++) { - while (ch && !Bt(alpha_numeric_bitmap,ch)) - ch=*ptr++; - if (!ch) break; - ptr--; - ptr2=ptr; - do ch=*ptr2++; - while (Bt(alpha_numeric_bitmap,ch)); - ptr2--; - ch1=*ptr2; - *ptr2=0; - - if (*ptr) { - if (!compile) - WsAddHash(ptr); - else { - 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(buf); -} - -void WsAddGlossFile(LTDirEntry *tempd) -{ - LtfEntry *ll; - WsHashEntry *temph; - Ltf *l=LtfRead(tempd->full_name); - I1 *temp; - - ll=l->dummy.next; - while (ll!=l) { - if (ll->btype==LTFT_ANCHOR) { - if (temph=FindHashEntry(ll->aux_str, - ws_hash_table,HTT_WORD)) { - temp=MSPrintF("FA:%s,%s", - tempd->full_name,ll->aux_str); - AFree(temph->glossary); - temph->glossary=ANewStr(temp); - Free(temp); - } - } - ll=ll->next; - } - LtfDel(l); -} - -I8 WsSort(WsHashEntry **e1,WsHashEntry **e2) -{ - I8 r; - if (!(r=(*e2)->hits - (*e1)->hits)) - r=StrCmp((*e1)->word,(*e2)->word); - return r; -} - -I8 WsSkipCrap(I1 *src,I8 len) -{ - I8 j; - j=len-1; - while (j>=0) { - if (Bt(alpha_numeric_bitmap,src[j])) - break; - else - j--; - } - return j+1; -} - -I8 WsPriorWordInStr(I1 *src,I1 *dst,I8 len,I8 buf_size) -{ - I8 i,j=0,k; - BoolU4 cont=TRUE; - i=len-1; - while (i>=0 && cont) { - if (!Bt(alpha_numeric_bitmap,src[i])) - cont=FALSE; - else - i--; - } - if (i>=-1 && len>0) - for (k=i+1;k=0 && nword; - len=StrLen(s); - if (len>ws_partial_len) - Auto(s+ws_partial_len); - } -} - -void WsMan(I8 n,TssStruct *parent=NULL) -{ - I1 *buf; - WsHashEntry *tempw; - SysHashEntry *temph; - BoolU4 old_preempt=Preempt(OFF); - n--; - if (n>=0 && nglossary; - if (temph=FindHashEntry(tempw->word,Fs->hash_table,HTT_ALL)) { - if (temph->source_link) - buf=temph->source_link; - } - if (buf) { - buf=MSPrintF("Edit(\"%s\");",buf); - Preempt(old_preempt); - PopUp(buf,parent); - Free(buf); - } - } - } - Preempt(old_preempt); -} - -void WsAddFillin(I8 i,I8 j,I8 old_num_fillins) -{ - BoolU4 cont; - I8 k; - if (ws_num_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<=ws_fillin_scores[k] || i==ws_fillin_scores[k] && ws_sorted_words[j]->hits<=ws_fillin_hits[k]) { - cont=FALSE; - k++; //offset k-- - } else { - 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; - ws_fillin_matches[k+1]=j; - } -} - -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; - SysHashEntry *temph; - - src=LtfGetLine(focus_l,ll,&data_col); - i=StrLen(src); - buf=MAlloc(i+1); - buf1=MAlloc(i+1); - if (data_col==-1) - data_col=StrLen(i); - data_col=WsPriorWordInStr(src,buf,data_col,256); - ws_partial_len=StrLen(buf); - data_col=WsSkipCrap(src,data_col); - 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; - ws_num_fillins=0; - if (w2 && w2->numword)) { - i=WsGetHits(ws_matrix,w2->num,ws_sorted_words[j]->num); - WsAddFillin(i,j,0); - } - k=ws_num_fillins; - for (j=0;jword)) - WsAddFillin(0,j,k); - Preempt(OFF); - -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); - } - WsdAddDictWords(l); - - LtfRecalc(l); - Bts(&Fs->crt_flags,CRTf_SHOW); - WinToTop(Fs); - - Free(src); - Free(buf); - Free(buf1); -} - -void WsTsk() -{ - TssStruct *focus_tss; - Ltf *l; - LtfEntry *ll; - InitLocalTask; - UseConsoleLtf(NULL); - Fs->win_left=50; - do { - Sleep(333); - if (Bt(&ws_flags,WSf_ENABLE)) { - focus_tss=sys_cur_focus_task; - 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) { - ll=l->cur_entry; - if (ll) { - if (ll==l) ll=ll->last; - while (ll->last!=l && (ll->btype==LTFT_CR || - ll->btype==LTFT_SOFT_CR)) - ll=ll->last; - while ((ll->last->btype)!=LTFT_CR && ll->last!=l) - ll=ll->last; - if (Bt(&ws_flags,WSf_ENABLE)) - WsPutChoices(Fs->cur_ltf,Fs->aux_ltf,l,ll,focus_tss); - } - } - } - } - } while (!ScanKey); - ws_task=NULL; -} - -void WsTraverseMainFilelist(WsFilemaskEntry *tempfm,BoolU4 compile) -{ - 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; - } -} - -void WsTraverseGlossFilelist(WsFilemaskEntry *tempfm) -{ - WsFilemaskEntry *tempfm1; - LTDirEntry *tempm; - I8 i; - while (tempfm) { - 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; - - 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); - - ws_num_words=0; - ws_num_matrix_words=0; - AFree(ws_cur_word); - ws_cur_word=NULL; - - tempfm1=NULL; - buf=NewStr(mask); - do { - RemoveFirstSeg(buf,";",buf2); - if (*buf2) { - 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"; - 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]; - while (tempw) { - ws_sorted_words[j++]=tempw; - tempw=tempw->next; - } - } - QSort(ws_sorted_words,ws_num_words,sizeof(void *),&WsSort); - for (i=0;inum=i; - if (ws_num_words<=WS_MAX_MATRIX_WORDS) - ws_num_matrix_words=ws_num_words; - else - ws_num_matrix_words=WS_MAX_MATRIX_WORDS; - - WsDelMatrix(ws_matrix); - ws_matrix=AMAlloc(sizeof(WsMatrix)); - - WsInitSides(ws_matrix); - coutln "\r\n\r\nPass #2"; - WsTraverseMainFilelist(tempfm1,TRUE); - - tempfm1=NULL; - buf=NewStr(mask); - do { - RemoveFirstSeg(buf,";",buf2); - if (*buf2) { - tempfm=MAlloc(sizeof(WsFilemaskEntry)); - tempfm->next=tempfm1; - tempfm1=tempfm; - tempfm->mask=NewStr(buf2); - tempfm->flist=NULL; - } - } while (*buf2); - Free(buf); - - 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 deleted file mode 100644 index 87ed48b..0000000 --- a/LT/Adam/WordStat/WordStat.APZ +++ /dev/null @@ -1,100 +0,0 @@ -#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 deleted file mode 100644 index ce7cc05..0000000 Binary files a/LT/Adam/WordStat/WsDefs.DAT and /dev/null differ diff --git a/LT/Adam/WordStat/WsWords.DTZ b/LT/Adam/WordStat/WsWords.DTZ deleted file mode 100644 index 1ae5287..0000000 Binary files a/LT/Adam/WordStat/WsWords.DTZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/action.CPZ b/LT/Apps/MusicOrgan/Examples/action.CPZ deleted file mode 100644 index 918fd76..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/action.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/alike.CPZ b/LT/Apps/MusicOrgan/Examples/alike.CPZ deleted file mode 100644 index 18a5ccc..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/alike.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/almighty.CPZ b/LT/Apps/MusicOrgan/Examples/almighty.CPZ deleted file mode 100644 index 9eef72b..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/almighty.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/appreciate.CPZ b/LT/Apps/MusicOrgan/Examples/appreciate.CPZ deleted file mode 100644 index 107ca81..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/appreciate.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/approve.CPZ b/LT/Apps/MusicOrgan/Examples/approve.CPZ deleted file mode 100644 index 7f28ed9..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/approve.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/architects.CPZ b/LT/Apps/MusicOrgan/Examples/architects.CPZ deleted file mode 100644 index b586a02..0000000 --- a/LT/Apps/MusicOrgan/Examples/architects.CPZ +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 0bd3605..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/bedewed.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/blinded.CPZ b/LT/Apps/MusicOrgan/Examples/blinded.CPZ deleted file mode 100644 index 578fa5d..0000000 --- a/LT/Apps/MusicOrgan/Examples/blinded.CPZ +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index 128028d..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/ceaseth.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/childish.CPZ b/LT/Apps/MusicOrgan/Examples/childish.CPZ deleted file mode 100644 index 7a03ace..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/childish.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/comprise.CPZ b/LT/Apps/MusicOrgan/Examples/comprise.CPZ deleted file mode 100644 index a6c44ad..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/comprise.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/depending.CPZ b/LT/Apps/MusicOrgan/Examples/depending.CPZ deleted file mode 100644 index 3af4acf..0000000 --- a/LT/Apps/MusicOrgan/Examples/depending.CPZ +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index 261fec1..0000000 --- a/LT/Apps/MusicOrgan/Examples/discerning.CPZ +++ /dev/null @@ -1,20 +0,0 @@ -//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 deleted file mode 100644 index 530c7e6..0000000 --- a/LT/Apps/MusicOrgan/Examples/downfall.CPZ +++ /dev/null @@ -1,22 +0,0 @@ -//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 deleted file mode 100644 index 40239e0..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/eternity.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ b/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ deleted file mode 100644 index e0b6c54..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/everlastingly.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/exalt.CPZ b/LT/Apps/MusicOrgan/Examples/exalt.CPZ deleted file mode 100644 index d165b82..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/exalt.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/fairness.CPZ b/LT/Apps/MusicOrgan/Examples/fairness.CPZ deleted file mode 100644 index a24e574..0000000 --- a/LT/Apps/MusicOrgan/Examples/fairness.CPZ +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index e6e5598..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/first.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/fishermen.CPZ b/LT/Apps/MusicOrgan/Examples/fishermen.CPZ deleted file mode 100644 index 54e37ac..0000000 --- a/LT/Apps/MusicOrgan/Examples/fishermen.CPZ +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index 9250585..0000000 --- a/LT/Apps/MusicOrgan/Examples/forgive.CPZ +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 54a06d6..0000000 --- a/LT/Apps/MusicOrgan/Examples/forstress.CPZ +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 9e1f54e..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/fun.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/gladdened.CPZ b/LT/Apps/MusicOrgan/Examples/gladdened.CPZ deleted file mode 100644 index 4ab068e..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/gladdened.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/good.CPZ b/LT/Apps/MusicOrgan/Examples/good.CPZ deleted file mode 100644 index 77f8ca2..0000000 --- a/LT/Apps/MusicOrgan/Examples/good.CPZ +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 7a60b7b..0000000 --- a/LT/Apps/MusicOrgan/Examples/heldest.CPZ +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 37ef216..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/heretofore.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/hope.CPZ b/LT/Apps/MusicOrgan/Examples/hope.CPZ deleted file mode 100644 index 8094bd5..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/hope.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/including.CPZ b/LT/Apps/MusicOrgan/Examples/including.CPZ deleted file mode 100644 index 5aca747..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/including.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/income.CPZ b/LT/Apps/MusicOrgan/Examples/income.CPZ deleted file mode 100644 index 7ff19c4..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/income.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/job.CPZ b/LT/Apps/MusicOrgan/Examples/job.CPZ deleted file mode 100644 index fdd68d2..0000000 --- a/LT/Apps/MusicOrgan/Examples/job.CPZ +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 3fed384..0000000 --- a/LT/Apps/MusicOrgan/Examples/kept.CPZ +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 9e20452..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/king.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/knewest.CPZ b/LT/Apps/MusicOrgan/Examples/knewest.CPZ deleted file mode 100644 index 69e1b68..0000000 --- a/LT/Apps/MusicOrgan/Examples/knewest.CPZ +++ /dev/null @@ -1,20 +0,0 @@ -//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 deleted file mode 100644 index d799ee5..0000000 --- a/LT/Apps/MusicOrgan/Examples/leaving.CPZ +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index 6c4b06d..0000000 --- a/LT/Apps/MusicOrgan/Examples/limit.CPZ +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 7141aba..0000000 --- a/LT/Apps/MusicOrgan/Examples/littleton.CPZ +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index d7fb483..0000000 --- a/LT/Apps/MusicOrgan/Examples/meekness.CPZ +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index a1d3d04..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/mentioned.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/mildly.CPZ b/LT/Apps/MusicOrgan/Examples/mildly.CPZ deleted file mode 100644 index 3858648..0000000 --- a/LT/Apps/MusicOrgan/Examples/mildly.CPZ +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index 538cc93..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/minds.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/multiple.CPZ b/LT/Apps/MusicOrgan/Examples/multiple.CPZ deleted file mode 100644 index 75f0ab4..0000000 --- a/LT/Apps/MusicOrgan/Examples/multiple.CPZ +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index 594289a..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/my.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/nay.CPZ b/LT/Apps/MusicOrgan/Examples/nay.CPZ deleted file mode 100644 index c76af34..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/nay.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/partake.CPZ b/LT/Apps/MusicOrgan/Examples/partake.CPZ deleted file mode 100644 index 3c88863..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/partake.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/permitted.CPZ b/LT/Apps/MusicOrgan/Examples/permitted.CPZ deleted file mode 100644 index 459ff75..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/permitted.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/preparing.CPZ b/LT/Apps/MusicOrgan/Examples/preparing.CPZ deleted file mode 100644 index 84d419b..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/preparing.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/pretend.CPZ b/LT/Apps/MusicOrgan/Examples/pretend.CPZ deleted file mode 100644 index 65af8bb..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/pretend.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/proponent.CPZ b/LT/Apps/MusicOrgan/Examples/proponent.CPZ deleted file mode 100644 index ba6207d..0000000 --- a/LT/Apps/MusicOrgan/Examples/proponent.CPZ +++ /dev/null @@ -1,22 +0,0 @@ -//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 deleted file mode 100644 index 422e032..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/prosper.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/providence.CPZ b/LT/Apps/MusicOrgan/Examples/providence.CPZ deleted file mode 100644 index 3424aa5..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/providence.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/proximate.CPZ b/LT/Apps/MusicOrgan/Examples/proximate.CPZ deleted file mode 100644 index c716302..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/proximate.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/quotation.CPZ b/LT/Apps/MusicOrgan/Examples/quotation.CPZ deleted file mode 100644 index f773a7c..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/quotation.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/regarded.CPZ b/LT/Apps/MusicOrgan/Examples/regarded.CPZ deleted file mode 100644 index fe17b0b..0000000 --- a/LT/Apps/MusicOrgan/Examples/regarded.CPZ +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 70869a5..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/represented.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/riddle.CPZ b/LT/Apps/MusicOrgan/Examples/riddle.CPZ deleted file mode 100644 index 425ca51..0000000 --- a/LT/Apps/MusicOrgan/Examples/riddle.CPZ +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 929032a..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/risen.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/rmunday.CPZ b/LT/Apps/MusicOrgan/Examples/rmunday.CPZ deleted file mode 100644 index 2b11bd1..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/rmunday.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/scarcely.CPZ b/LT/Apps/MusicOrgan/Examples/scarcely.CPZ deleted file mode 100644 index a14e479..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/scarcely.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/seasons.CPZ b/LT/Apps/MusicOrgan/Examples/seasons.CPZ deleted file mode 100644 index b9e512f..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/seasons.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/servant.CPZ b/LT/Apps/MusicOrgan/Examples/servant.CPZ deleted file mode 100644 index 5355515..0000000 --- a/LT/Apps/MusicOrgan/Examples/servant.CPZ +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index b3cbb45..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/shield.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/sings.CPZ b/LT/Apps/MusicOrgan/Examples/sings.CPZ deleted file mode 100644 index a7b0943..0000000 --- a/LT/Apps/MusicOrgan/Examples/sings.CPZ +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index e79812e..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/small.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/soothed.CPZ b/LT/Apps/MusicOrgan/Examples/soothed.CPZ deleted file mode 100644 index 200aea8..0000000 --- a/LT/Apps/MusicOrgan/Examples/soothed.CPZ +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index f94f5e0..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/stiff.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/stores.CPZ b/LT/Apps/MusicOrgan/Examples/stores.CPZ deleted file mode 100644 index d1406a4..0000000 --- a/LT/Apps/MusicOrgan/Examples/stores.CPZ +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 3d2d7a5..0000000 --- a/LT/Apps/MusicOrgan/Examples/struggles.CPZ +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 9e6bd95..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/sweeter.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/thereby.CPZ b/LT/Apps/MusicOrgan/Examples/thereby.CPZ deleted file mode 100644 index 349b348..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/thereby.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/tolerated.CPZ b/LT/Apps/MusicOrgan/Examples/tolerated.CPZ deleted file mode 100644 index 0372c6f..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/tolerated.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/treating.CPZ b/LT/Apps/MusicOrgan/Examples/treating.CPZ deleted file mode 100644 index de3eb6e..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/treating.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/unlearned.CPZ b/LT/Apps/MusicOrgan/Examples/unlearned.CPZ deleted file mode 100644 index e00b126..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/unlearned.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/valued.CPZ b/LT/Apps/MusicOrgan/Examples/valued.CPZ deleted file mode 100644 index c8d77c9..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/valued.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/vengeance.CPZ b/LT/Apps/MusicOrgan/Examples/vengeance.CPZ deleted file mode 100644 index 8f311fd..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/vengeance.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/warmth.CPZ b/LT/Apps/MusicOrgan/Examples/warmth.CPZ deleted file mode 100644 index fef043b..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/warmth.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/wisdom.CPZ b/LT/Apps/MusicOrgan/Examples/wisdom.CPZ deleted file mode 100644 index 5932bfd..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/wisdom.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Examples/zip.CPZ b/LT/Apps/MusicOrgan/Examples/zip.CPZ deleted file mode 100644 index 629a7b8..0000000 Binary files a/LT/Apps/MusicOrgan/Examples/zip.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Install.CPZ b/LT/Apps/MusicOrgan/Install.CPZ deleted file mode 100644 index 83e52fc..0000000 Binary files a/LT/Apps/MusicOrgan/Install.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/JukeBox.CPZ b/LT/Apps/MusicOrgan/JukeBox.CPZ deleted file mode 100644 index 30036f5..0000000 Binary files a/LT/Apps/MusicOrgan/JukeBox.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/Load.CPZ b/LT/Apps/MusicOrgan/Load.CPZ deleted file mode 100644 index 665bed6..0000000 Binary files a/LT/Apps/MusicOrgan/Load.CPZ and /dev/null differ diff --git a/LT/Apps/MusicOrgan/MakeSong.CPZ b/LT/Apps/MusicOrgan/MakeSong.CPZ deleted file mode 100644 index e56b4e3..0000000 --- a/LT/Apps/MusicOrgan/MakeSong.CPZ +++ /dev/null @@ -1,73 +0,0 @@ -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 deleted file mode 100644 index f821265..0000000 --- a/LT/Apps/MusicOrgan/Organ.CPZ +++ /dev/null @@ -1,992 +0,0 @@ -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 deleted file mode 100644 index 28f06fc..0000000 Binary files a/LT/Apps/MusicOrgan/Run.CPZ and /dev/null differ diff --git a/LT/Apps/Rocks/Load.CPZ b/LT/Apps/Rocks/Load.CPZ deleted file mode 100644 index c453afd..0000000 Binary files a/LT/Apps/Rocks/Load.CPZ and /dev/null differ diff --git a/LT/Apps/Rocks/Rocks.CPZ b/LT/Apps/Rocks/Rocks.CPZ deleted file mode 100644 index 48532ca..0000000 --- a/LT/Apps/Rocks/Rocks.CPZ +++ /dev/null @@ -1,736 +0,0 @@ -$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›next=header; - header->last=header; - ptr=buf; - while (type=*ptr++) { - tempt=MAllocZ(sizeof(TimeEntry)); - tempt->type=type; - d=ptr; - ptr+=sizeof(LTDate); - tempt->d=*d; - tempt->desc=NewStr(ptr); - ptr+=StrLen(ptr)+1; - InsQue(tempt,header->last); - } - Free(buf); -} - -void WriteTimeFile(TimeEntry *header) -{ - U1 *buf,*ptr; - TimeEntry *tempt; - LTDate *d; - U8 size=1; //for eof - - tempt=header->next; - while (tempt!=header) { - size+=sizeof(U1)+sizeof(LTDate)+StrLen(tempt->desc)+1; - tempt=tempt->next; - } - buf=MAlloc(size); - - ptr=buf; - tempt=header->next; - while (tempt!=header) { - *ptr++=tempt->type; - d=ptr; - *d=tempt->d; - ptr+=sizeof(LTDate); - StrCpy(ptr,tempt->desc); - ptr+=StrLen(tempt->desc)+1; - tempt=tempt->next; - } - *ptr=TET_EOF; - WriteFile(TIME_FILENAME,buf,size); - Free(buf); -} - -void DelTimeEntries(TimeEntry *header) -{ - TimeEntry *tempt=header->next,*tempt1; - while (tempt!=header) { - tempt1=tempt->next; - Free(tempt->desc); - Free(tempt); - tempt=tempt1; - } - Free(header); -} - -public BoolU4 TimeRep(TimeEntry **header=NULL) -{ - BoolU4 is_in=FALSE; - TimeEntry *tempt; - U8 week,cur_week,week_total=0; - TimeEntry *my_header=MAlloc(sizeof(TimeEntry)); - if (header) - *header=my_header; - ReadTimeFile(my_header); - tempt=my_header->next; - while (tempt!=my_header) { - week=tempt->d.date/7; //TODO - if (week!=cur_week) { - if (is_in) - week_total=week_total+GetCurTimeLTDate; - PrintF("Week Total:%h2T\r\n",week_total); - cur_week=week; - week_total=0; - } - if (tempt->type==TET_PUNCH_IN) { - PutS("$$FG,RED$$IN "); - if (!is_in) - week_total=week_total-tempt->d; - is_in=TRUE; - } else { - PutS("$$FG,RED$$OUT"); - if (is_in) - week_total=week_total+tempt->d; - is_in=FALSE; - } - PrintF(" %h2D %T:$$FG$$\r\n%s\r\n", - tempt->d,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); - if (!header) - DelTimeEntries(my_header); - return is_in; -} - -void PunchOut() -{ - BoolU4 is_in; - TimeEntry *tempt,*header; - is_in=TimeRep(&header); - if (!is_in) { - PutS("$$BK,1$$Already Punched-Out$$BK,0$$\r\n"); - View; - } else { - tempt=MAlloc(sizeof(TimeEntry)); - tempt->type=TET_PUNCH_OUT; - tempt->d=GetCurTimeLTDate; - PrintF("\r\nEnter Description:\r\n"); - if (!(tempt->desc=MGetS)) - tempt->desc=MAllocZ(1); - InsQue(tempt,header->last); - WriteTimeFile(header); - } - DelTimeEntries(header); -} - -void PunchIn() -{ - BoolU4 is_in; - TimeEntry *tempt,*header; - is_in=TimeRep(&header); - if (is_in) { - PutS("$$BK,1$$Already Punched-In$$BK,0$$\r\n"); - View; - } else { - tempt=MAlloc(sizeof(TimeEntry)); - tempt->type=TET_PUNCH_IN; - tempt->d=GetCurTimeLTDate; - PrintF("\r\nEnter Description:\r\n"); - if (!(tempt->desc=MGetS)) - tempt->desc=MAllocZ(1); - InsQue(tempt,header->last); - WriteTimeFile(header); - } - DelTimeEntries(header); -} diff --git a/LT/Apps/Vocabulary/Load.CPZ b/LT/Apps/Vocabulary/Load.CPZ deleted file mode 100644 index a3ed664..0000000 Binary files a/LT/Apps/Vocabulary/Load.CPZ and /dev/null differ diff --git a/LT/Apps/Vocabulary/Run.CPZ b/LT/Apps/Vocabulary/Run.CPZ deleted file mode 100644 index 6e0b291..0000000 --- a/LT/Apps/Vocabulary/Run.CPZ +++ /dev/null @@ -1,2 +0,0 @@ -#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 deleted file mode 100644 index d21202f..0000000 Binary files a/LT/Apps/Vocabulary/VocabQuiz.CPZ and /dev/null differ diff --git a/LT/Apps/WarGame/Load.CPZ b/LT/Apps/WarGame/Load.CPZ deleted file mode 100644 index f92953e..0000000 Binary files a/LT/Apps/WarGame/Load.CPZ and /dev/null differ diff --git a/LT/Apps/WarGame/Run.CPZ b/LT/Apps/WarGame/Run.CPZ deleted file mode 100644 index 85f8439..0000000 Binary files a/LT/Apps/WarGame/Run.CPZ and /dev/null differ diff --git a/LT/Apps/WarGame/WarGame.CPZ b/LT/Apps/WarGame/WarGame.CPZ deleted file mode 100644 index 937f99d..0000000 --- a/LT/Apps/WarGame/WarGame.CPZ +++ /dev/null @@ -1,385 +0,0 @@ -#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 deleted file mode 100644 index 16ac1a4..0000000 --- a/LT/Apps/WarGame/WarGame.MUZ +++ /dev/null @@ -1,14 +0,0 @@ -$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/Compiler/AsmMain.CPZ b/LT/Compiler/AsmMain.CPZ deleted file mode 100644 index a72a107..0000000 --- a/LT/Compiler/AsmMain.CPZ +++ /dev/null @@ -1,1655 +0,0 @@ -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 deleted file mode 100644 index 0e02486..0000000 --- a/LT/Compiler/CmpAsm.ASZ +++ /dev/null @@ -1,281 +0,0 @@ - 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 deleted file mode 100644 index 5e76a63..0000000 --- a/LT/Compiler/CmpDefs.HPZ +++ /dev/null @@ -1,254 +0,0 @@ -//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 deleted file mode 100644 index 84e57b4..0000000 --- a/LT/Compiler/CmpDefs2.HPZ +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 23ea06a..0000000 --- a/LT/Compiler/CmpGlbls.CPZ +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 4e35d1b..0000000 --- a/LT/Compiler/CmpInit.CPZ +++ /dev/null @@ -1,603 +0,0 @@ -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 deleted file mode 100644 index 1370da3..0000000 --- a/LT/Compiler/CmpMain.CPZ +++ /dev/null @@ -1,422 +0,0 @@ -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 deleted file mode 100644 index 8fd1667..0000000 --- a/LT/Compiler/Code.CPZ +++ /dev/null @@ -1,2452 +0,0 @@ -$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 deleted file mode 100644 index 46637d3..0000000 --- a/LT/Compiler/CodeGen.CPZ +++ /dev/null @@ -1,431 +0,0 @@ -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 deleted file mode 100644 index 197e191..0000000 Binary files a/LT/Compiler/Compiler.BIZ and /dev/null differ diff --git a/LT/Compiler/Compiler.HPZ b/LT/Compiler/Compiler.HPZ deleted file mode 100644 index 586476d..0000000 --- a/LT/Compiler/Compiler.HPZ +++ /dev/null @@ -1,53 +0,0 @@ -#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 deleted file mode 100644 index cdf425b..0000000 --- a/LT/Compiler/Compiler.MPZ +++ /dev/null @@ -1,552 +0,0 @@ -$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@WDWLWZWfWmWqWyWWŒ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|nn•n˜nnµn¸n¼nÄnÌnånênònooo3o?oVolovo‡ožo´oÇoÌoÜoìoþopp#p&p?pDpIpephpmp‰pŒpp˜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‡000¥0¨0­0Ñ0Ý0å0ë0ó011131E1X1j11†1§1Í1×1å1ö1 222<2A2F2T2X2r2‹22£2¨2°2µ2½2Å2Ó2Û2Þ2ã2333 30353J3`3r3…3—3®3³3Ô3ú344#494>4C4w4|444“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"C0C8CNCVCkCC“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ŠJJ¥JªJ¯J½JÓJéJùJ'K/K4KRKhK~KƒKˆKžK£K¨K¾KÔKÙKÞKôKùKþKLLL0L5LGL]LsL|L‹LL•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‡xxž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<Rt|Œœ¡®ÅÜëÿ 7N]es ®ºÆàü‘ ‘%‘@‘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œ^œ}œ¥œ­œ²œ¶œ¿œÑœÝœ  0X]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?KLKVKcKmKtKyKK‰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‹gg¯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;R50LxL™L L¥LÐLÜLÞLëLøLüLM MMGMUMWMdMnM{M…MŒM•MM¤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è Paqaxaaša­aËaÒaéaôabb5bCbMbXbibb•b¯bÅbÝb c8Ñàn)n0n?nVn[nfnmnxnznn˜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˜yy¨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.iFiMidioii’i¤i·iÕi÷ij$jFjQjijj†jj®jÅjÐjèjöjk k)k;kSk^klkskŠk•kk§k«k²k¶kÁkÒkÝkókúkl!l+lAlYl`lwl‚llŸ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‹gg“g–g™g›g g£g¥g¬g¯gÂgTØ AÐíõù 1GKU]s‹¡³¸ÅÊÔêü$.9LQY^fp¹ÇÑÜïôü !UˆCQ(ADGQY`jruxV0Ux©­¶¼ÀÄÓÝçý!&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¼Ë8QfŽŸ¨Êê 0?Nf˜™©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 ¢³€—¡ÉñóCPxmhÐúà÷Jrtœ×ä ,puƒ«Óúÿ'Ovƒª³ÛänèT n È ß í ! * I V ~ ƒ « Ê Ó ò ÿ  ' O X o¸> R ˆ -Ÿ -© -Ý -ê -  ? ^ k Š “ » Ä p°„—ð¥¦/¦F¦K¦s¦~¦‹¦›¦¨¦¸¦צߦá¦ÿ¦§0§q u†@ÄQÄ[ăīĭÄÕÄýÄ ÅÅ,Å.Å?ÅPÅxÅÅrèÏ Pqy‡‹‘—œ ®¼ÀÏÝçëðúü‘‘(‘,‘;‘I‘]‘a‘x‘}‘‘”‘¨‘¿‘Ñőߑã‘î‘ü‘’’ -’’s°¯‚šEšNšsš…šŠš—š²š¿šÅšöš'›C›I›M›y›ª›¯›Û› œ.œ4œ8œWœdœ‰œŽœ­œºœßœúœ 1>Cboqyƒ†Š¢¯ÂÙÞãñÿž!ž&ž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ˆ99–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=3T3e3k3o3v3z33˜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]6g66ˆ66Ÿ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$9D9N9Y9d9l9v99Œ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Œ¡ŒÄŒàŒåŒëŒ 'EParŸ¬¼ÌÜìüŽŽ Ž1ŽBŽGŽWŽ}Ž£Ž¿ŽÄŽÉŽÓŽñŽ-9DOcfs‡Šš®±ÁÕØèüÿ#&6JMhy|‘§ÂÐá÷‘'‘*‘@‘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 deleted file mode 100644 index 5ffbb49..0000000 Binary files a/LT/Compiler/Compiler.SPZ and /dev/null differ diff --git a/LT/Compiler/ExpParser.CPZ b/LT/Compiler/ExpParser.CPZ deleted file mode 100644 index c11e4e3..0000000 --- a/LT/Compiler/ExpParser.CPZ +++ /dev/null @@ -1,837 +0,0 @@ -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 deleted file mode 100644 index 4a275a8..0000000 --- a/LT/Compiler/Lex.CPZ +++ /dev/null @@ -1,1222 +0,0 @@ -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/Compiler/OpCodes.TXZ b/LT/Compiler/OpCodes.TXZ deleted file mode 100644 index e1354ed..0000000 --- a/LT/Compiler/OpCodes.TXZ +++ /dev/null @@ -1,1085 +0,0 @@ -/* - '%'= 32 bit - '*'= 16 bit - '!'= don't switch modes - '&'= default - '-'= NoRex - '='= Rex 0x48 - '~'= Rex 0x40 -*/ -R8 AL 0; -R8 CL 1; -R8 DL 2; -R8 BL 3; -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; -R16 BX 3; -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; -R32 EBX 3; -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; -SEG DS 3; -SEG FS 4; -SEG GS 5; -KEYWORD include 0; -KEYWORD define 1; -KEYWORD union 2; -KEYWORD catch 3; -KEYWORD class 4; -KEYWORD try 5; -KEYWORD if 6; -KEYWORD else 7; -KEYWORD for 8; -KEYWORD while 9; -KEYWORD extern 10; -KEYWORD LTextern 11; -KEYWORD return 12; -KEYWORD sizeof 13; -KEYWORD LTintern 14; -KEYWORD fmtstr 15; -KEYWORD fmtdata 16; -KEYWORD output_fun 17; -KEYWORD input_fun 18; -KEYWORD cout 19; -KEYWORD dbgo 19; /*used for debugging*/ -KEYWORD do 20; -KEYWORD asm 21; -KEYWORD goto 22; -KEYWORD exe 23; -KEYWORD break 24; -KEYWORD continue 25; -KEYWORD switch 26; -KEYWORD case 27; -KEYWORD default 28; -KEYWORD public 29; -KEYWORD offset 30; -KEYWORD typeof 31; -KEYWORD import 32; -KEYWORD LTimport 33; -KEYWORD coutln 34; -KEYWORD dbgoln 34; -KEYWORD 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 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 - 0x16 NO SS - 0x1E NO DS - 0x06 NO ES - 0x0F 0xA0 NO FS - 0x0F 0xA8 NO GS - 0x6A &IB IMM8 - 0x68 *!IW IMM16 - 0x68 %!ID IMM32 - 0x50 +/R *NO R16 - 0x50 +/R %NO R32 - 0x50 +/R %NO R64 - 0xFF /6 *NO RM16 - 0xFF /6 %NO RM32 - 0xFF /6 %NO RM64; -OPCODE PUSHAW 0x60 *NO; -OPCODE PUSHAD 0x60 %NO; -OPCODE PUSHFW 0x9C *NO; -OPCODE PUSHFD 0x9C %NO; -OPCODE POP - 0x1F NO DS - 0x07 NO ES - 0x17 NO SS - 0x0F 0xA1 NO FS - 0x0F 0xA9 NO GS - 0x58 +*RW R16 - 0x58 +%RD R32 - 0x58 +%RD R64 - 0x8F /0 *NO RM16 - 0x8F /0 %NO RM32 - 0x8F /0 %NO RM64; -OPCODE POPAW 0x61 *NO; -OPCODE POPAD 0x61 %NO; -OPCODE POPFW 0x9D *NO; -OPCODE POPFD 0x9D %NO; -OPCODE MOV -// 0xA0 NO AL MOFFS8 - 0xA1 *NO AX MOFFS16 - 0xA1 %NO EAX MOFFS32 -// 0xA2 NO MOFFS8 AL - 0xA3 *NO MOFFS16 AX - 0xA3 %NO MOFFS32 EAX - 0x8A /R NO R8 RM8 - 0x8B /R *NO R16 RM16 - 0x8B /R %NO R32 RM32 - 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 RM64 IMM32; - -OPCODE ADC - 0x14 IB AL UIMM8 - 0x15 *IW AX UIMM16 - 0x15 %ID EAX UIMM32 - 0x80 /2 IB RM8 IMM8 - 0x83 /2 *IB RM16 IMM8 - 0x83 /2 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE ADD - 0x04 IB AL UIMM8 - 0x05 *IW AX UIMM16 - 0x05 %ID EAX UIMM32 - 0x80 /0 IB RM8 UIMM8 - 0x83 /0 *IB RM16 IMM8 - 0x83 /0 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE AND - 0x24 IB AL UIMM8 - 0x25 *IW AX UIMM16 - 0x25 %ID EAX UIMM32 - 0x80 /4 IB RM8 UIMM8 - 0x83 /4 *IB RM16 IMM8 - 0x83 /4 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE CMP - 0x3C IB AL UIMM8 - 0x3D *IW AX UIMM16 - 0x3D %ID EAX UIMM32 - 0x80 /7 IB RM8 UIMM8 - 0x83 /7 *IB RM16 IMM8 - 0X83 /7 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE OR - 0x0C IB AL UIMM8 - 0x0D *IW AX UIMM16 - 0x0D %ID EAX UIMM32 - 0x80 /1 IB RM8 UIMM8 - 0x83 /1 *IB RM16 IMM8 - 0x83 /1 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE SBB - 0x1C IB AL UIMM8 - 0x1D *IW AX UIMM16 - 0x1D %ID EAX UIMM32 - 0x80 /3 IB RM8 UIMM8 - 0x83 /3 *IB RM16 IMM8 - 0x83 /3 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE SUB - 0x2C IB AL UIMM8 - 0x2D *IW AX UIMM16 - 0x2D %ID EAX UIMM32 - 0x80 /5 IB RM8 UIMM8 - 0x83 /5 *IB RM16 IMM8 - 0x83 /5 %IB RM32 IMM8 - 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 RM64 R64; -OPCODE TEST - 0xA8 IB AL UIMM8 - 0xA9 *IW AX UIMM16 - 0xA9 %ID EAX UIMM32 - 0xF6 /0 IB RM8 UIMM8 - 0xF7 /0 *IW RM16 UIMM16 - 0xF7 /0 %ID RM32 UIMM32 - 0xF7 /0 %ID RM64 UIMM32 - 0x84 /R NO RM8 R8 - 0x85 /R *NO RM16 R16 - 0x85 /R %NO RM32 R32 - 0x85 /R %NO RM64 R64; -OPCODE NOP 0x90 NO; -OPCODE XCHG - 0x90 +/R *NO R16 AX - 0x90 +/R *NO AX R16 - 0x90 +/R %NO R32 EAX - 0x90 +/R %NO EAX R32 - 0x86 /R NO R8 RM8 - 0x87 /R *NO R16 RM16 - 0x87 /R %NO R32 RM32 - 0x87 /R %NO R64 RM64 - 0x86 /R NO RM8 R8 - 0x87 /R *NO RM16 R16 - 0x87 /R %NO RM32 R32 - 0x87 /R %NO RM64 R64; -OPCODE XOR - 0x34 IB AL UIMM8 - 0x35 *IW AX UIMM16 - 0x35 %ID EAX UIMM32 - 0x80 /6 IB RM8 UIMM8 - 0x83 /6 *IB RM16 IMM8 - 0x83 /6 %IB RM32 IMM8 - 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 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 -// 0x9A %CP PTR3232 -// 0xFF /3 %NO M1632 - ; - -OPCODE JMP - 0xEB &CB REL8 - 0xE9 *!CW REL16 - 0xE9 %!CD REL32 - 0xFF /4 *!NO RM16 - 0xFF /4 %!NO RM32 - 0xFF /4 %!NO RM64; -OPCODE JA - 0x77 &CB REL8 - 0x0F 0x87 *!CW REL16 - 0x0F 0x87 %!CD REL32; -OPCODE JAE - 0x73 &CB REL8 - 0x0F 0x83 *!CW REL16 - 0x0F 0x83 %!CD REL32; -OPCODE JB - 0x72 &CB REL8 - 0x0F 0x82 *!CW REL16 - 0x0F 0x82 %!CD REL32; -OPCODE JBE - 0x76 &CB REL8 - 0x0F 0x86 *!CW REL16 - 0x0F 0x86 %!CD REL32; -OPCODE JC - 0x72 &CB REL8 - 0x0F 0x82 *!CW REL16 - 0x0F 0x82 %!CD REL32; -OPCODE JCXZ - 0xE3 CB REL8; -OPCODE JECXZ - 0xE3 CB REL8; -OPCODE JE - 0x74 &CB REL8 - 0x0F 0x84 *!CW REL16 - 0x0F 0x84 %!CD REL32; -OPCODE JG - 0x7F &CB REL8 - 0x0F 0x8F *!CW REL16 - 0x0F 0x8F %!CD REL32; -OPCODE JGE - 0x7D &CB REL8 - 0x0F 0x8D *!CW REL16 - 0x0F 0x8D %!CD REL32; -OPCODE JL - 0x7C &CB REL8 - 0x0F 0x8C *!CW REL16 - 0x0F 0x8C %!CD REL32; -OPCODE JLE - 0x7E &CB REL8 - 0x0F 0x8E *!CW REL16 - 0x0F 0x8E %!CD REL32; -OPCODE JNA - 0x76 &CB REL8 - 0x0F 0x86 *!CW REL16 - 0x0F 0x86 %!CD REL32; -OPCODE JNAE - 0x72 &CB REL8 - 0x0F 0x82 *!CW REL16 - 0x0F 0x82 %!CD REL32; -OPCODE JNB - 0x73 &CB REL8 - 0x0F 0x83 *!CW REL16 - 0x0F 0x83 %!CD REL32; -OPCODE JNBE - 0x77 &CB REL8 - 0x0F 0x87 *!CW REL16 - 0x0F 0x87 %!CD REL32; -OPCODE JNC - 0x73 &CB REL8 - 0x0F 0x83 *!CW REL16 - 0x0F 0x83 %!CD REL32; -OPCODE JNE - 0x75 &CB REL8 - 0x0F 0x85 *!CW REL16 - 0x0F 0x85 %!CD REL32; -OPCODE JNG - 0x7E &CB REL8 - 0x0F 0x8E *!CW REL16 - 0x0F 0x8E %!CD REL32; -OPCODE JNGE - 0x7C &CB REL8 - 0x0F 0x8C *!CW REL16 - 0x0F 0x8C %!CD REL32; -OPCODE JNL - 0x7D &CB REL8 - 0x0F 0x8D *!CW REL16 - 0x0F 0x8D %!CD REL32; -OPCODE JNLE - 0x7F &CB REL8 - 0x0F 0x8F *!CW REL16 - 0x0F 0x8F %!CD REL32; -OPCODE JNO - 0x71 &CB REL8 - 0x0F 0x81 *!CW REL16 - 0x0F 0x81 %!CD REL32; -OPCODE JNP - 0x7B &CB REL8 - 0x0F 0x8B *!CW REL16 - 0x0F 0x8B %!CD REL32; -OPCODE JNS - 0x79 &CB REL8 - 0x0F 0x89 *!CW REL16 - 0x0F 0x89 %!CD REL32; -OPCODE JNZ - 0x75 &CB REL8 - 0x0F 0x85 *!CW REL16 - 0x0F 0x85 %!CD REL32; -OPCODE JO - 0x70 &CB REL8 - 0x0F 0x80 *!CW REL16 - 0x0F 0x80 %!CD REL32; -OPCODE JP - 0x7A &CB REL8 - 0x0F 0x8A *!CW REL16 - 0x0F 0x8A %!CD REL32; -OPCODE JPE - 0x7A &CB REL8 - 0x0F 0x8A *!CW REL16 - 0x0F 0x8A %!CD REL32; -OPCODE JPO - 0x7B &CB REL8 - 0x0F 0x8B *!CW REL16 - 0x0F 0x8B %!CD REL32; -OPCODE JS - 0x78 &CB REL8 - 0x0F 0x88 *!CW REL16 - 0x0F 0x88 %!CD REL32; -OPCODE JZ - 0x74 &CB REL8 - 0x0F 0x84 *!CW REL16 - 0x0F 0x84 %!CD REL32; - - -OPCODE INC -// 0x40 +*RW R16 -// 0x40 +%RD R32 - 0xFE /0 NO RM8 - 0xFF /0 *NO RM16 - 0xFF /0 %NO RM32 - 0xFF /0 %NO RM64; -OPCODE DEC -// 0x48 +*RW R16 -// 0x48 +%RD R32 - 0xFE /1 NO RM8 - 0xFF /1 *NO RM16 - 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 RM64; -OPCODE NEG - 0xF6 /3 NO RM8 - 0xF7 /3 *NO RM16 - 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 RM64; -OPCODE IMUL - 0xF6 /5 NO RM8 - 0xF7 /5 *NO RM16 - 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 RM64 UIMM32; -OPCODE DIV - 0xF6 /6 NO RM8 - 0xF7 /6 *NO RM16 - 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 RM64; - -OPCODE AAA 0x37 NO; -OPCODE AAD 0xD5 0x0A NO; -OPCODE AAM 0xD4 0x0A NO; -OPCODE AAS 0x3F NO; -OPCODE ARPL 0x63 /R NO RM16 R16; -OPCODE BOUND - 0x62 /R *NO RM16 R16 - 0x62 /R %NO RM32 R32 - 0x62 /R %NO RM64 R64; -OPCODE BSF - 0x0F 0xBC /R *NO R16 RM16 - 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 R64 RM64; -OPCODE BSWAP - 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 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 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 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 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; -OPCODE CLTS 0x0F 0x06 NO; -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 - 0x0F 0xB1 /R %NO RM64 R64; -OPCODE CHPXCHG8B 0x0F 0xC7 NO RM64; -OPCODE CWD 0x99 NO; -OPCODE CWDE 0x98 NO; -OPCODE DAA 0x27 NO; -OPCODE DAS 0x2F NO; -//OPCODE ENTER 0xC8 IW IB IMM16 IMM8; -OPCODE HLT 0xF4 NO; -OPCODE IN - 0xE4 IB AL UIMM8 - 0xE5 *IB AX UIMM8 - 0xE5 %IB EAX UIMM8 - 0xEC NO AL DX - 0xED *NO AX DX - 0xED %NO EAX DX; -OPCODE INS - 0x6C NO RM8 DX - 0x6D *NO RM16 DX - 0x6D %NO RM32 DX - 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 LAHF 0x9F NO; -OPCODE LAR - 0x0F 0x02 /R *NO R16 RM16 - 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 R64 RM64; -OPCODE LEAVE 0xC9 NO; -OPCODE LGDT - 0x0F 0x01 /2 *NO RM16 - 0x0F 0x01 /2 %NO RM32 - 0x0F 0x01 /2 %NO RM64; -OPCODE LIDT - 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 RM64; -OPCODE LMSW - 0x0F 0x01 /6 *NO RM16 - 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; -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 R64 RM64; -OPCODE LTR - 0x0F 0x00 /3 *NO RM16 - 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 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 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 - 0xE7 %IB UIMM8 EAX - 0xEE NO DX AL - 0xEF *NO DX AX - 0xEF %NO DX EAX; -OPCODE OUTSB 0x6E NO; -OPCODE OUTSW 0x6F *NO; -OPCODE OUTSD 0x6F %NO; -OPCODE 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; -OPCODE SEGES 0x26 NO; -OPCODE SEGFS 0x64 NO; -OPCODE SEGGS 0x65 NO; -OPCODE SETA 0x0F 0x97 NO RM8; -OPCODE SETAE 0x0F 0x93 NO RM8; -OPCODE SETB 0x0F 0x92 NO RM8; -OPCODE SETBE 0x0F 0x96 NO RM8; -OPCODE SETC 0x0F 0x92 NO RM8; -OPCODE SETE 0x0F 0x94 NO RM8; -OPCODE SETG 0x0F 0x9F NO RM8; -OPCODE SETGE 0x0F 0x9D NO RM8; -OPCODE SETL 0x0F 0x9C NO RM8; -OPCODE SETLE 0x0F 0x9E NO RM8; -OPCODE SETNA 0x0F 0x96 NO RM8; -OPCODE SETNAE 0x0F 0x92 NO RM8; -OPCODE SETNB 0x0F 0x93 NO RM8; -OPCODE SETNBE 0x0F 0x97 NO RM8; -OPCODE SETNC 0x0F 0x93 NO RM8; -OPCODE SETNE 0x0F 0x95 NO RM8; -OPCODE SETNG 0x0F 0x9E NO RM8; -OPCODE SETNGE 0x0F 0x9C NO RM8; -OPCODE SETNL 0x0F 0x9D NO RM8; -OPCODE SETNLE 0x0F 0x9F NO RM8; -OPCODE SETNO 0x0F 0x91 NO RM8; -OPCODE SETNP 0x0F 0x9B NO RM8; -OPCODE SETNS 0x0F 0x99 NO RM8; -OPCODE SETNZ 0x0F 0x95 NO RM8; -OPCODE SETO 0x0F 0x90 NO RM8; -OPCODE SETP 0x0F 0x9A NO RM8; -OPCODE SETPE 0x0F 0x9A NO RM8; -OPCODE SETPO 0x0F 0x9B NO RM8; -OPCODE SETS 0x0F 0x98 NO RM8; -OPCODE SETZ 0x0F 0x94 NO RM8; -//OPCODE SGDT 0x0F 0x01 /0 m -//OPCODE SIDT 0x0F 0x01 /0 m -OPCODE SHLD - 0x0F 0xA5 /R *NO RM16 R16 - 0x0F 0xA5 /R %NO RM32 R32 - 0x0F 0xA5 /R %NO RM64 R64; -OPCODE SHRD - 0x0F 0xAD /R *NO RM16 R16 - 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 RM64; -OPCODE SMSW - 0x0F 0x01 /4 *NO RM16 - 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 $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 RM64; -OPCODE VERR - 0x0F 0x00 /4 *NO RM16 - 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 RM64; -OPCODE WAIT 0x9B NO; -OPCODE FWAIT 0x9B NO; -OPCODE WBINVD 0x0F 0x09 NO; -OPCODE WRMSR 0x0F 0x30 =NO; -OPCODE XADD - 0x0F 0xC0 /R NO RM8 R8 - 0x0F 0xC1 /R *NO RM16 R16 - 0x0F 0xC1 /R %NO RM32 R32 - 0x0F 0xC1 /R %NO RM64 R64; -OPCODE XLATB 0xD7 NO; - - -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 RM64 UIMM8; -OPCODE RCL1 - 0xD0 /2 NO RM8 - 0xD1 /2 *NO RM16 - 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 RM64 UIMM8; -OPCODE RCR1 - 0xD0 /3 NO RM8 - 0xD1 /3 *NO RM16 - 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 RM64 UIMM8; -OPCODE ROL1 - 0xD0 /0 NO RM8 - 0xD1 /0 *NO RM16 - 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 RM64 UIMM8; -OPCODE ROR1 - 0xD0 /1 NO RM8 - 0xD1 /1 *NO RM16 - 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 RM64 UIMM8; -OPCODE SAL1 - 0xD0 /4 NO RM8 - 0xD1 /4 *NO RM16 - 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 RM64 UIMM8; -OPCODE SAR1 - 0xD0 /7 NO RM8 - 0xD1 /7 *NO RM16 - 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 RM64 UIMM8; -OPCODE SHL1 - 0xD0 /4 NO RM8 - 0xD1 /4 *NO RM16 - 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 RM64 UIMM8; -OPCODE SHR1 - 0xD0 /5 NO RM8 - 0xD1 /5 *NO RM16 - 0xD1 /5 %NO RM32 - 0xD1 /5 %NO RM64; - -OPCODE FILD - 0xDF /5 NO RM64; //Load 64 bit I4 -OPCODE FISTP - 0xDF /7 NO RM64; //Store 64 bit I4 -OPCODE FLD - 0xDD /0 NO RM64; //Load 64 bit double -OPCODE FSTP - 0xDD /3 NO RM64; //Store 64 bit double -OPCODE FST - 0xDD /2 NO RM64; //Store 64 bit double -OPCODE FRSTOR - 0xDD /4 NO RM32 - 0xDD /4 NO RM64; -OPCODE FSAVE - 0x9B 0xDD /6 NO RM32 - 0x9B 0xDD /6 NO RM64; - -OPCODE FYL2X 0xD9 0xF1 NO; -OPCODE FYL2XP1 0xD9 0xF9 NO; -OPCODE F2XM1 0xD9 0xF0 NO; -OPCODE FABS 0xD9 0xE1 NO; -OPCODE FCHS 0xD9 0xE0 NO; -OPCODE FSIN 0xD9 0xFE NO; -OPCODE FCOS 0xD9 0xFF NO; -OPCODE FPTAN 0xD9 0xF2 NO; -OPCODE FPATAN 0xD9 0xF3 NO; -OPCODE FSQRT 0xD9 0xFA NO; -OPCODE FMULP 0xDE 0xC9 NO; -OPCODE FDIVP 0xDE 0xF9 NO; -OPCODE FDIVRP 0xDE 0xF1 NO; -OPCODE FPREM 0xD9 0xF8 NO; -OPCODE FADDP 0xDE 0xC1 NO; -OPCODE FSUBP 0xDE 0xE9 NO; -OPCODE FSUBRP 0xDE 0xE1 NO; -OPCODE FCOMIP 0xDF 0xF1 NO; -OPCODE FCLEX 0x9B 0xDB 0xE2 NO; -OPCODE FSTSW 0x98 0xDF 0xE0 NO; -OPCODE FDECSTP 0xD9 0xF6 NO; -OPCODE FINCSTP 0xD9 0xF7 NO; -OPCODE FFREE 0xDD 0xC0 NO; -OPCODE FRNDINT 0xD9 0xFC NO; -OPCODE FSCALE 0xD9 0xFD NO; -OPCODE FXTRACT 0xD9 0xF4 NO; -OPCODE FLD1 0xD9 0xE8 NO; -OPCODE FLDL2T 0xD9 0xE9 NO; -OPCODE FLDL2E 0xD9 0xEA NO; -OPCODE FLDPI 0xD9 0xEB NO; -OPCODE FLDLG2 0xD9 0xEC NO; -OPCODE FLDLN2 0xD9 0xED NO; -OPCODE FLDZ 0xD9 0xEE NO; -OPCODE FXCH 0xD9 0xC9 NO; -OPCODE FSTCW - 0x9B 0xD9 /7 NO RM32 - 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 deleted file mode 100644 index f9e8e9f..0000000 --- a/LT/Compiler/OptPass1.CPZ +++ /dev/null @@ -1,1540 +0,0 @@ - -#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 deleted file mode 100644 index 990d07a..0000000 --- a/LT/Compiler/OptPass2.CPZ +++ /dev/null @@ -1,447 +0,0 @@ -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 deleted file mode 100644 index 00c705f..0000000 --- a/LT/Compiler/OptPass3.CPZ +++ /dev/null @@ -1,574 +0,0 @@ -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 deleted file mode 100644 index e1a103b..0000000 --- a/LT/Compiler/OptPass4.CPZ +++ /dev/null @@ -1,182 +0,0 @@ -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 deleted file mode 100644 index c659114..0000000 --- a/LT/Compiler/OptPass5.CPZ +++ /dev/null @@ -1,267 +0,0 @@ -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 deleted file mode 100644 index faa95f5..0000000 --- a/LT/Compiler/OptPass6.CPZ +++ /dev/null @@ -1,1195 +0,0 @@ -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/Compiler/Renum.AUZ b/LT/Compiler/Renum.AUZ deleted file mode 100644 index 1430948..0000000 --- a/LT/Compiler/Renum.AUZ +++ /dev/null @@ -1,27 +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. - -This autofile will renumber the defines in -Demo3.TXZ. Test it by numbering a few wrong -and running this demo. - -*/ - -U1 i; - -PutS("Edit(\"CmpDefs.HPZ\");\r"); -//Go to start of file -Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL); -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); - Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT); - Msg(MSG_KEY_DOWN,0,SC_CURSOR_RIGHT); - 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/Compiler/SPrintF2.CPZ b/LT/Compiler/SPrintF2.CPZ deleted file mode 100644 index bb8c1c5..0000000 --- a/LT/Compiler/SPrintF2.CPZ +++ /dev/null @@ -1,1009 +0,0 @@ -void OutChar(I1 **addr_dst,I1 ch,I1 **addr_buf) -{ - I8 i; - I1 *dst=*addr_dst,*buf; - if (addr_buf) { - buf=*addr_buf; - i=dst-buf; - if (i>=MSize(buf)) { - buf=MAlloc(i<<1+1); - MemCpy(buf,*addr_buf,i); - dst=buf+i; - *addr_buf=buf; - } - } - *dst++=ch; - *addr_dst=dst; -} - -void OutStr(I1 *ptr,I1 **addr_buf,I1 *addr_dst, - I8 len,BoolU4 left_justify,BoolU4 truncate) -{ - I8 i,j; - 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) - SPrintF(buf,"%*ts,%04X",field_length-5,temph->str,offset); - else - SPrintF(buf,"%s,%04X",temph->str,offset); - } - return; - } - if (field_length) - SPrintF(buf,"%*tX",field_length,add); - else - SPrintF(buf,"%X",add); -} - -I1 *MSPrintFTime(LTDate ltdt,U8 sub_format) -{ - LTDateStruct d; - 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: - ToLTDateStruct(&d,ltdt); - return MSPrintF("%d.%02d",60*((ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.hundredths); - case 13: - 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: - ToLTDateStruct(&d,ltdt); - return MSPrintF("%d.%04d",60*((ltdt.date*24+d.hours)*60+d.minutes)+d.seconds,d.ten_thousandths); - case 18: - 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(LTDate dt,U8 sub_format) -{ - LTDateStruct d; - ToLTDateStruct(&d,dt+local_time_offset); - switch (sub_format) { - case 1: - return MSPrintF("%02d/%02d",d.month,d.day_of_month); - case 2: - return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month,d.day_of_month); - case 3: - return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month,d.day_of_month,(d.year)%100); - case 4: - return MSPrintF("%02d/%02d/%d",d.month,d.day_of_month,d.year); - case 5: - return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month,d.day_of_month,d.year); - case 6: - return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",d.day_of_month); - case 7: - return MSPrintF("%3tZ, %3tZ %02d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month-1,"ST_MONTHS",d.day_of_month); - case 8: - return MSPrintF("%3tZ %02d,%04d",d.month-1,"ST_MONTHS",d.day_of_month,d.year); - case 9: - return MSPrintF("%3tZ, %3tZ %02d,%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month-1,"ST_MONTHS",d.day_of_month,d.year); - case 10: - return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.day_of_month); - case 11: - return MSPrintF("%Z, %Z %d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month-1,"ST_MONTHS",d.day_of_month); - case 12: - return MSPrintF("%Z %d,%d",d.month-1,"ST_MONTHS",d.day_of_month,d.year); - case 13: - return MSPrintF("%Z, %Z %d,%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.month-1,"ST_MONTHS",d.day_of_month,d.year); - case 14: - return MSPrintF("%02d/%02d/%02d",d.day_of_month,d.month,(d.year)%100); - case 15: - return MSPrintF("%02d/%02d",d.day_of_month,d.month); - case 16: - return MSPrintF("%3tZ %02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month); - case 17: - return MSPrintF("%3tZ %02d/%02d/%02d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month,(d.year)%100); - case 18: - return MSPrintF("%02d/%02d/%d",d.day_of_month,d.month,d.year); - case 19: - return MSPrintF("%3tZ %02d/%02d/%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month,d.year); - case 20: - return MSPrintF("%02d %3tZ",d.day_of_month,d.month-1,"ST_MONTHS"); - case 21: - return MSPrintF("%3tZ, %02d %3tZ",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month-1,"ST_MONTHS"); - case 22: - return MSPrintF("%02d %3tZ,%04d",d.day_of_month,d.month-1,"ST_MONTHS",d.year); - case 23: - return MSPrintF("%3tZ, %02d %3tZ,%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month-1,"ST_MONTHS",d.year); - case 24: - return MSPrintF("%d %Z",d.day_of_month,d.month-1,"ST_MONTHS"); - case 25: - return MSPrintF("%Z, %d %Z",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month-1,"ST_MONTHS"); - case 26: - return MSPrintF("%d %Z,%d",d.day_of_month,d.month-1,"ST_MONTHS",d.year); - case 27: - return MSPrintF("%Z, %d %Z,%d",d.day_of_week,"ST_DAYS_OF_WEEK", - d.day_of_month,d.month-1,"ST_MONTHS",d.year); - case 28: - return MSPrintF("%02d/%02d/%02d",(d.year)%100,d.month,d.day_of_month); - case 29: - return MSPrintF("%d/%02d/%02d",d.year,d.month,d.day_of_month); - case 30: - return MSPrintF("%02d%02d%02d",(d.year)%100,d.month,d.day_of_month); - case 31: - return MSPrintF("%d%02d%02d",d.year,d.month,d.day_of_month); - case 32: - return MSPrintF("%02d%02d%02d",d.month,d.day_of_month,(d.year)%100); - case 33: - return MSPrintF("%02d%02d%d",d.month,d.day_of_month,d.year); - case 34: - return MSPrintF("%3tZ",d.day_of_week,"ST_DAYS_OF_WEEK"); - case 35: - return MSPrintF("%Z",d.day_of_week,"ST_DAYS_OF_WEEK"); - case 36: - return MSPrintF("%3tZ",d.month-1,"ST_MONTHS"); - case 37: - return MSPrintF("%Z",d.month-1,"ST_MONTHS"); - case 38: - return MSPrintF("%d %3tZ",d.year,d.month-1,"ST_MONTHS"); - case 39: - return MSPrintF("%d %Z",d.year,d.month-1,"ST_MONTHS"); - case 40: - return MSPrintF("%02d %3tZ",(d.year)%100,d.month-1,"ST_MONTHS"); - case 41: - return MSPrintF("%02d %Z",(d.year)%100,d.month-1,"ST_MONTHS"); - case 42: - return MSPrintF("%3tZ %d",d.month-1,"ST_MONTHS",d.year); - case 43: - return MSPrintF("%Z %d",d.month-1,"ST_MONTHS",d.year); - case 44: - return MSPrintF("%3tZ %02d",d.month-1,"ST_MONTHS",(d.year)%100); - case 45: - return MSPrintF("%Z %02d",d.month-1,"ST_MONTHS",(d.year)%100); - case 46: - return MSPrintF("%02d",(d.year)%100); - case 47: - return MSPrintF("%d",d.year); - default: - return MSPrintF("%02d/%02d/%02d",d.month,d.day_of_month,(d.year)%100); - } -} - -#define TEMP_BUF_LEN 256 - -I1 *SPrintFJoin2(I1 *dst,I1 *src,I8 argc,I8 *argv) -{ - I1 *ptr,**addr_buf,*buf,*addr_dst, - *temp1; - BoolU4 pad_zero,left_justify,truncate,neg,neg_e; - I8 i,ch,ch1,k,len,dec_len,sub_format; - U8 d,cur_param=0; - 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(128); - addr_buf=&buf; - dst=buf; - } - addr_dst=&dst; - - while (ch = *(src++)) { - if (ch=='%') { - if (*src=='-') { - left_justify=TRUE; - src++; - } else - left_justify=FALSE; - if (*src=='0') { - pad_zero=TRUE; - src++; - } else - pad_zero=FALSE; - len=0; - while (*src>='0' && *src<='9') - len=len*10+ *(src++)-'0'; - if (*src=='*') { - src++; - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - len=argv[cur_param++]; - } - dec_len=0; - if (*src=='.') { - src++; - while (*src>='0' && *src<='9') - dec_len=dec_len*10+ *(src++)-'0'; - if (*src=='*') { - src++; - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - dec_len=argv[cur_param++]; - } - } - if (*src=='t') { - src++; - truncate=TRUE; - } else - truncate=FALSE; - - sub_format=0; - if (*src=='h') { - src++; - while (*src>='0' && *src<='9') - sub_format=sub_format*10+ *(src++)-'0'; - if (*src=='*') { - src++; - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - sub_format=argv[cur_param++]; - } - } - neg=FALSE; - k=0; - switch (*src++) { - case 's': - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - ptr=argv[cur_param++]; - 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++]); - 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++]); - OutStr(ptr,addr_buf,addr_dst,len,left_justify,truncate); - Free(ptr); - break; - case 'Q': - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - if (ptr=argv[cur_param++]) - while (ch=*ptr++) { - if (ch=='$$') { - OutChar(addr_dst,ch,addr_buf); - OutChar(addr_dst,ch,addr_buf); - } else if (ch==CH_LINE_FEED){ - OutChar(addr_dst,'\\',addr_buf); - OutChar(addr_dst,'n',addr_buf); - } else if (ch==CH_CR){ - OutChar(addr_dst,'\\',addr_buf); - OutChar(addr_dst,'r',addr_buf); - } else if (ch==CH_TAB){ - OutChar(addr_dst,'\\',addr_buf); - OutChar(addr_dst,'t',addr_buf); - } else { - if (ch=='"' || ch=='\\') - OutChar(addr_dst,'\\',addr_buf); - 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; - 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; - 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); - 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); - 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) - SPrintFPSect(temp_buf,argv[cur_param++],len); - else - 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) && k0) { - if (truncate && k+i>len) - k=len-i; - } else - len=0; - if (k<0) - k=0; - if (pad_zero) - for (;i=0;i--) - OutChar(addr_dst,temp_buf[i],addr_buf); - break; - case 'u': - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - d=argv[cur_param++]; - while ((!k|| d) && k=argc) - throw(EXCEPT_SPRINTF,1); - dd=argv[cur_param++]><(double); - if (dd<0) { - neg=TRUE; - dd=-dd; - } -out_f: - if (i=dec_len) - dd*=Pow10(i); - dd=Round(dd); - while (i-- && k=argc) - throw(EXCEPT_SPRINTF,1); - dd=argv[cur_param++]><(double); - if (dd<0) { - neg=TRUE; - dd=-dd; - } - if (dd) - dd1=Floor(Log10(dd)); - else - dd1=0; -out_e: - dd/=Pow10(dd1); - if (dd1<0) { - dd1=-dd1; - neg_e=TRUE; - } else - neg_e=FALSE; - if (dd) { - if (dd<1.0) { - dd*=10; - if (neg_e) - dd1+=1; - else - dd1-=1; - } else if (dd>=10.0) { - dd/=10; - if (neg_e) - dd1-=1; - else - dd1+=1; - } - } - i=3; - do { - temp_buf[k++]=dd1%10+'0'; - dd1=Floor(dd1/10); - } while (dd1 && i--); - if (neg_e) - temp_buf[k++]='-'; - temp_buf[k++]='e'; - dec_len=len-k-neg-2; - goto out_f; - case 'g': - if (!len) len=12; - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - dd=argv[cur_param++]><(double); - if (dd<0) { - neg=TRUE; - dd=-dd; - } - 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) && k'9') temp_buf[k]+='A'-0x3A; - k++; - d>>=4; - } - goto out_num; - case 'x': - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - d=argv[cur_param++]; - while ((!k || d) && k'9') temp_buf[k]+='a'-0x3A; - k++; - d>>=4; - } - goto out_num; - case 'b': - if (cur_param>=argc) - throw(EXCEPT_SPRINTF,1); - d=argv[cur_param++]; - while ((!k || d) && k>=1; - } - goto out_num; - case '%': - OutChar(addr_dst,'%',addr_buf); - break; - } - } else - OutChar(addr_dst,ch,addr_buf); - } - OutChar(addr_dst,0,addr_buf); - return buf; -} - -double A2Double(I1 *src,I1 **end_ptr=NULL) -//ASCII string to double -{ - I1 ch=*src++; - I8 i=0,j=0,k=0; - double d; - BoolU4 neg=FALSE; - - while (ch==CH_SPACE||ch==CH_TAB||ch==CH_SHIFT_SPACE) - ch=*src++; - if (ch=='-') { - neg=TRUE; - ch=*src++; - } - while (TRUE) { - if (Bt(dec_numeric_bitmap,ch)) - i=i*10+ch-'0'; - else { - if (ch=='.' || ch=='e' || ch=='E') break; - d=i; - goto a2d_end; - } - ch=*src++; - } - if (ch=='.') - ch=*src++; - while (TRUE) { - if (Bt(dec_numeric_bitmap,ch)) { - j=j*10+ch-'0'; - k++; - } else { - d=i+j*Pow10(-k); - if (ch=='e' || ch=='E') break; - goto a2d_end; - } - ch=*src++; - } - ch=*src++; - k=1; - if (ch=='-') { - k=-1; - ch=*src++; - } - j=0; - while (TRUE) { - if (Bt(dec_numeric_bitmap,ch)) - j=j*10+ch-'0'; - else { - d*=Pow10(j*k); - goto a2d_end; - } - ch=*src++; - } -a2d_end: - if (end_ptr) *end_ptr=src-1; - return (neg) ? -d:d; -} - -/* -$FG,2$A2LTDate() - This routine recognizes the following formats: - 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=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; - - MemSet(&d,0,sizeof(LTDateStruct)); - MemSet(&d1,0,sizeof(LTDateStruct)); - if (!StrNCmp(p1,"SM(",3)) { - p1+=3; - start_month=TRUE; - } else if (!StrNCmp(p1,"EM(",3)) { - p1+=3; - end_month=TRUE; - } else if (!StrNCmp(p1,"SY(",3)) { - p1+=3; - start_year=TRUE; - } else if (!StrNCmp(p1,"EY(",3)) { - p1+=3; - end_year=TRUE; - } - if (*p1=='*') { - p1++; - if (*p1=='+' || *p1=='-') - result.date=AtoI(p1,10,&p1); - result+=GetCurTimeLTDate+local_time_offset; - } else { - RemoveFirstSeg(p1,"/",v); //Put month into v - d.month=AtoI(v); - if (Occurrences(p1,'/')) { - RemoveFirstSeg(p1,"/",v); //Put day into v leaving year in p1 - d.day_of_month=AtoI(v); - d.year=AtoI(p1,10,&p1); - if (d.year<100) //if not 4 digit year - d.year+=2000; - } else { - d.day_of_month=AtoI(p1,10,&p1); - ToLTDateStruct(&d1,GetCurTimeLTDate+local_time_offset); - d.year=d1.year; - } - result=ToLTDate(&d); - } - if (*p1==')') p1++; - - if (start_month) - result.date=FirstDayOfMonth(result.date); - else if (end_month) - result.date=LastDayOfMonth(result.date); - else if (start_year) - result.date=FirstDayOfYear(result.date); - else if (end_year) - result.date=LastDayOfYear(result.date); - - if (*p1=='+' || *p1=='-') - result.date+=AtoI(p1); - Free(src); - Free(v); - return result-local_time_offset; -} - -void GetFJoin2(I1 *src,I1 *fmt,I8i argc,I8i *argv) -//Pass pointer to data, -//For %s pass pointer to pointer (be careful because address -// of array is the same as array--create ptr to array and take address -{ - I1 ch,*buf,*ptr,**pptr; - BoolU4 left_justify=FALSE; - I8 cur_param=0,i,j,k,len,*i_ptr,sub_format=0,dec_len; - double *d_ptr; - if (!fmt) - throw(EXCEPT_GETF,0); - while (ch = *(fmt++)) { - if (ch=='%') { - if (*fmt=='%') { - src++; - fmt++; - } else { - if (*fmt=='-') { - left_justify=TRUE; - fmt++; - } else - left_justify=FALSE; - len=0; - while (*fmt>='0' && *fmt<='9') - len=len*10+ (*(fmt++)-'0'); - if (*fmt=='*') { - fmt++; - if (cur_param>=argc) - throw(EXCEPT_GETF,1); - len=argv[cur_param++]; - } - ch=*(fmt++); - if (ch && !len) { - ptr=src; - while (*ptr && *ptr!=*fmt) - ptr++; - len=ptr-src; - } else { - if (ch=='.') { - dec_len=0; - while (*fmt>='0' && *fmt<='9') - dec_len=dec_len*10+ (*(fmt++)-'0'); - if (*fmt=='*') { - fmt++; - if (cur_param>=argc) - throw(EXCEPT_GETF,1); - dec_len=argv[cur_param++]; - } - ch=*(fmt++); - } - } - buf=MAlloc(len+1); - for (i=0;i=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;k9) j=j-'A'+('9'+1); - *i_ptr=(*i_ptr<<4)+j; - } - break; - case 'b': - 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); - 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); - break; - } - Free(buf); - } - } else - src++; - } -} diff --git a/LT/Compiler/StmtParser.CPZ b/LT/Compiler/StmtParser.CPZ deleted file mode 100644 index 9a956bb..0000000 --- a/LT/Compiler/StmtParser.CPZ +++ /dev/null @@ -1,1453 +0,0 @@ -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/ASCIIOrgan.CPZ b/LT/Demo/ASCIIOrgan.CPZ deleted file mode 100644 index 7abad7e..0000000 --- a/LT/Demo/ASCIIOrgan.CPZ +++ /dev/null @@ -1,16 +0,0 @@ -//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 deleted file mode 100644 index 2a80c29..0000000 --- a/LT/Demo/AutoFile/Demo1.AUZ +++ /dev/null @@ -1,15 +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. -*/ - - -//This is to demo autofiles. -I8 i; -for (i=0;i<3;i++) - PutS("Dir;\r"); -PutS("$$FG,RED$$//Press a letter to complete the mask$$FG$$\r"); -PutS("Dir(\"*."); -I1 ch=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 deleted file mode 100644 index 02b2ba5..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$$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 deleted file mode 100644 index b0be68e..0000000 Binary files a/LT/Demo/AutoFile/Demo3.AUZ and /dev/null differ diff --git a/LT/Demo/AutoFile/Demo3.TXZ b/LT/Demo/AutoFile/Demo3.TXZ deleted file mode 100644 index 9bed5ce..0000000 --- a/LT/Demo/AutoFile/Demo3.TXZ +++ /dev/null @@ -1,260 +0,0 @@ -#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 deleted file mode 100644 index 602a889..0000000 Binary files a/LT/Demo/AutoFile/Demo4.CPZ and /dev/null differ diff --git a/LT/Demo/ByteAccess.CPZ b/LT/Demo/ByteAccess.CPZ deleted file mode 100644 index c4bfb8d..0000000 --- a/LT/Demo/ByteAccess.CPZ +++ /dev/null @@ -1,26 +0,0 @@ -/* - 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 deleted file mode 100644 index 14160bf..0000000 Binary files a/LT/Demo/CircleTrace.CPZ and /dev/null differ diff --git a/LT/Demo/CommTerminal.CPZ b/LT/Demo/CommTerminal.CPZ deleted file mode 100644 index 1d593f7..0000000 --- a/LT/Demo/CommTerminal.CPZ +++ /dev/null @@ -1,19 +0,0 @@ -// COM port Terminal -void CommTerm(I8 port=1,U8 baud=9600) -{ - U8 sc; - U8 ch=0; - coutln "ESC to exit"; - CommOpen8N1(port,baud); - while (ch!=CH_ESC) { - if (CommScanChar(port,&ch)) - PutChar(ch); - ch=0; - if (ScanKey(&ch,&sc)) - CommPutChar(port,ch); - SwapInNext; - } - CommClose(port); -} - -CommTerm; diff --git a/LT/Demo/DataBase.CPZ b/LT/Demo/DataBase.CPZ deleted file mode 100644 index 0a4c4e9..0000000 --- a/LT/Demo/DataBase.CPZ +++ /dev/null @@ -1,68 +0,0 @@ -#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