TempleOSCD_150216.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:15 +02:00
1 parent 64f679eeb9
commit 401601816c
531 files changed
+22836 -21566

No files matched your search

Binary file not shown.
-10
View File
@@ -1,10 +0,0 @@
//Change anything you want in this
//acct file or others.
#include "HOME/Adam3aLocalize"
#include "HOME/Adam3bPkgs"
#include "HOME/Adam3cKeyPlugIns"
#include "HOME/Adam3dWrappers"
#include "HOME/Adam3eSys"
#help_index ""
-26
View File
@@ -1,26 +0,0 @@
//Change anything you want in this
//acct file or others.
#help_index "Cmd Line (Typically)"
//These are customized quick commands.
//Feel free to add more or change.
public I64 F(U8 *needle_str,U8 *fu_flags=NULL)
{//Find (Grep) all text files.
return Grep(needle_str,"/*",fu_flags);
}
public I64 R(U8 *needle_str,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
{//Find (Grep) and replace string with string in all files.
return Grep(needle_str,"/*",fu_flags,replace_text);
}
public I64 FD(U8 *needle_str,U8 *fu_flags=NULL)
{//Find (Grep) text files in cur dir.
return Grep(needle_str,"*",fu_flags);
}
public I64 RD(U8 *needle_str,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
{//Find (Grep) and replace string with string in cur dir.
return Grep(needle_str,"*",fu_flags,replace_text);
}
-41
View File
@@ -1,41 +0,0 @@
//Change anything you want in this
//acct file or others.
U0 UserStartUp()
{//Run each time a user a spawned
DocTermNew;
Type("::/Doc/Start.TXT");
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
Dir;
}
U0 SrvStartUp()
{//Run each time a srv task is spawned.
DocTermNew;
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
}
U0 StartUpTasks()
{
CTask *user1,*user2;
user1=SpawnUser;
user2=SpawnUser;
WinToTop(user1);
WinTileVert;
PopUp("#include \"::/Adam/Start\";");
"Boot Time:%7.3fs\n",tS;
XTalk(user1,"Cd(\"HOME\");#include \"DoOnce\";\n");
Silent(ON); //no output to screen
WSInit("/*;~*Bible.TXT*");
Silent(OFF); //no output to screen
}
StartUpTasks;
"\nOS Compile Time:%D %T\n",sys_compile_time,sys_compile_time;
-16
View File
@@ -1,16 +0,0 @@
//This file is executed by the
//first terminal window upon start-up.
//See $LK,"DoOnce",A="FF:HOME/Adam3eSys.CPP,DoOnce"$ and $LK,"Acct Files",A="FF:::/Doc/GuideLines.TXT,ACCT FILES"$.
//It goes in your HOME directory and
//you can customize it.
//Delete this to get rid of
//default start-up msg.
Type("::/Doc/Customize.TXT");
"\nTake Tour";
if (YorN) {
Cd("::/Misc/Tour");
AutoFile("Tour");
}
Binary file not shown.
+105
View File
@@ -0,0 +1,105 @@
//This is executed by the Adam task at boot.
//See $LK,"Adam Start-up",A="FF:::/Kernel/KEnd.CPP,\"Adam:2"$.
//You do not place this file in /Home. (It would be ignored.)
//but look at the bottom of this file to see
//files you do customize.
extern I8i OptEqu(I64i num,I8i val);
OptEqu(0,0); //(0,0)=EchoOff (0,1)=EchoOn
#include "/Kernel/KernelA.HPP"
#include "/Compiler/CompilerA.HPP"
#include "/Kernel/KernelB.HPP"
#include "/Kernel/KernelC.HPP"
#include "/Compiler/CompilerB.HPP"
Cd("/Adam");;
#exe {OptOn(OPTf_WARN_PAREN);};
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
HashTablePurge(adam_task->hash_table);
#help_index "Misc"
//Use Dbg("Type 'G;'"); to debug before window mgr is running.
public F64 os_version=3.03;//Operating system version.
#include "AExts.HPP"
#include "AMath"
#include "Training"
#include "AUtils"
#include "AMathODE"
Cd("::/Adam/Gr");;
#include "Gr"
Cd("::/Adam/Snd");;
#include "Snd"
Cd("::/Adam/Dsk");;
#include "ADsk"
Cd("::/Adam");;
#include "Menu"
#include "WinA"
#include "WinB"
#include "ADbg"
#include "::/Adam/God/GodExt"
Cd("::/Adam/DolDoc");;
#include "Doc"
LBts(&sys_run_level,RLf_DOC);
Cd("::/Adam/Ctrls");;
#include "Ctrls"
Cd("::/Adam");;
#include "AutoFile"
#include "Acct"
Cd("::/Adam/AutoComplete");;
#include "AutoComplete"
Cd("::/Adam/God");;
#include "God"
Cd("::/Adam");;
#include "AHash"
#include "TaskSettings"
#include "DevInfo"
#include "ADefine"
//Dbg("Type 'G;'");
DocTermNew;
WinVert(2,10);
sys_winmgr_task=Spawn(&WinMgrTask,NULL,"Window Mgr");
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_SELF_CTRLS;
LBts(&Fs->display_flags,DISPLAYf_CHILDREN_NOT_ON_TOP);
LBts(&Fs->display_flags,DISPLAYf_SHOW);
RegistryInit;
LBts(&sys_run_level,RLf_REGISTRY);
Cd("::/Adam");;
#include "WallPaper"
if (IsDrvWritable)
MkDir("/Temp"); //Good to have a Temp
#exe {OptOff(OPTf_WARN_PAREN);};
#exe {OptOff(OPTf_WARN_DUP_TYPES);};
LBts(&sys_run_level,RLf_HOME);
#help_index ""
Cd("::/Home");;
//If these are not present in /Home, it uses the version in the root dir.
//You should make your own version of these files in you /Home directory.
#include "::/Home/AdamLocalize"
#include "::/Home/AdamPkgs"
#include "::/Home/AdamKeyPlugIns"
#include "::/Home/AdamWrappers"
#include "::/Home/AdamSys"
//After this file, the Adam task enters $LK,"server mode",A="HI:Task/Srv"$.
+8 -8
View File
@@ -1,7 +1,7 @@
#help_index "Debugging/Dump" #help_index "Debugging/Dump"
Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth,Bool dynamic,I64 types=HTT_CLASS,I64 offset=0) Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth,Bool dynamic,I64 types=HTT_CLASS,I64 offset=0)
{//See $LK,"::/Demo/LastClass.CPP"$. {//See $LK,"::/Demo/LastClass.CPP"$.
I64 i,j,*ptr; I64 i,j,stars,*ptr;
CMemberLst *ml; CMemberLst *ml;
CDocEntry *doc_e; CDocEntry *doc_e;
Bool unlock; Bool unlock;
@@ -24,12 +24,12 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth
tempc2=ml->member_class; tempc2=ml->member_class;
ptr=_d(U8 *)+ml->offset; ptr=_d(U8 *)+ml->offset;
DocPrint(doc,"%08X ",ptr(U8 *)+offset); DocPrint(doc,"%08X ",ptr(U8 *)+offset);
j=tempc2->ptr_cnt; stars=tempc2->ptr_stars_cnt;
tempc2=OptClassFwd(tempc2); tempc2=OptClassFwd(tempc2);
tempc2-=tempc2->ptr_cnt; tempc2-=tempc2->ptr_stars_cnt;
if (tempc2->type & HTT_INTERNAL_TYPE) { if (tempc2->type & HTT_INTERNAL_TYPE) {
DocPrint(doc,"$$GREEN$$%-20ts:$$FG$$",ml->str); DocPrint(doc,"$$GREEN$$%-20ts:$$FG$$",ml->str);
if (j==1 && (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8)) { if (stars==1 && (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8)) {
ptr=*ptr; ptr=*ptr;
if (ChkPtr(ptr)) { if (ChkPtr(ptr)) {
if (dynamic) { if (dynamic) {
@@ -39,7 +39,7 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth
} else } else
DocPrint(doc,"%40ts\n",ptr); DocPrint(doc,"%40ts\n",ptr);
} }
} else if (!j) { } else if (!stars) {
j=MinI64(ml->dim.total_cnt,32); j=MinI64(ml->dim.total_cnt,32);
if (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8) { if (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8) {
if (j==1) { if (j==1) {
@@ -128,14 +128,14 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth
DocPrint(doc,"\n"); DocPrint(doc,"\n");
} else { } else {
if (depth<2) { if (depth<2) {
if (j==1 && !ChkPtr(*ptr)) if (stars==1 && !ChkPtr(*ptr))
DocPrint(doc,"%-20ts:%016X\n",ml->str,*ptr); DocPrint(doc,"%-20ts:%016X\n",ml->str,*ptr);
else { else {
DocPrint(doc,"$$TR,\"%s\"$$\n",ml->str); DocPrint(doc,"$$TR,\"%s\"$$\n",ml->str);
DocPrint(doc,"$$ID,2$$"); DocPrint(doc,"$$ID,2$$");
if (!j) if (!stars)
ClassRep2(doc,ptr,tempc2->str,depth+1,max_depth,dynamic); ClassRep2(doc,ptr,tempc2->str,depth+1,max_depth,dynamic);
else if (j==1) else if (stars==1)
ClassRep2(doc,*ptr,tempc2->str,depth+1,max_depth,dynamic); ClassRep2(doc,*ptr,tempc2->str,depth+1,max_depth,dynamic);
DocPrint(doc,"$$ID,-2$$"); DocPrint(doc,"$$ID,-2$$");
} }
+51
View File
@@ -0,0 +1,51 @@
#help_index "Define;Char/Define"
U0 LoadDocDefines()
{
CBinFile *bfh=sys_boot_base-sizeof(CBinFile);
DefinePrint(
"DD_OS_NAME_VERSION","TempleOS V%0.2f",os_version);
DefinePrint(
"DD_TEMPLEOS_AGE","%0.1f",(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
//This is cut and replaced when I generate a distro.
//See $LK,"DD_TEMPLEOS_LOC",A="FF:::/Demo/AcctExample/TOSDistro.CPP,DD_TEMPLEOS_LOC"$.
$TR-C,"LineRep"$
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","120,789");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","79,959");
$ID,-4$
DefinePrint(
"DD_KERNEL","%08X",bfh);
bfh(I64)+=bfh->file_size-1;
DefinePrint(
"DD_KERNEL_END","%08X",bfh);
DefinePrint(
"DD_PROTECTED_LOW","%08X",MEM_PROTECTED_LOW_LIMIT);
//$LK,"DD_BOOT_HIGH_LOC_CD",A="FF:::/Adam/Boot/BootCD.CPP,DD_BOOT_HIGH_LOC_CD"$
DefinePrint(
"DD_MP_VECT","%08X",MP_VECT_ADDR);
DefinePrint(
"DD_MP_VECT_END","%08X",MP_VECT_ADDR+AP_16BIT_INIT_END-AP_16BIT_INIT-1);
DefinePrint(
"DD_SYS_FIXED_AREA_BASE","%08X",SYS_FIXED_AREA);
DefinePrint(
"DD_SYS_FIXED_AREA_END","%08X",SYS_FIXED_AREA+sizeof(CSysFixedArea)-1);
DefinePrint(
"DD_SYS_HEAP_BASE","%08X",sys_heap_base);
DefinePrint(
"DD_SYS_HEAP_LIMIT","%08X",sys_heap_limit);
DefinePrint(
"DD_MEM_MIN_MEG","%d Meg",MEM_MIN_MEG);
DefinePrint(
"DD_MEM_MAPPED_SPACE_GIG","%d Gig",MEM_MAPPED_SPACE/0x40000000);
DefinePrint(
"DD_MEM_MAPPED_SPACE_END","%010X",MEM_MAPPED_SPACE-1);
DefinePrint(
"DD_JIFFY_HZ","%d Hz",JIFFY_FREQ);
}
LoadDocDefines;
+14 -15
View File
@@ -1,13 +1,20 @@
extern U0 ACDDef(I64 n,CTask *parent=NULL);
extern U0 ACDDefsPut(CDoc *doc,U8 *st,I64 num=-1);
extern U0 ACDFillin(I64 n);
extern U0 ACFillIn(I64 n);
extern U0 ACFindMisspelled(CDoc *doc);
extern U0 ACMan(I64 n,CTask *parent=NULL);
extern U0 AcctOneTimePopUp(I64 flag_num,U8 *msg); extern U0 AcctOneTimePopUp(I64 flag_num,U8 *msg);
extern I64 AdamFile(U8 *filename,Bool warn_ext=TRUE); extern I64 AdamFile(U8 *filename,Bool warn_ext=TRUE);
extern I64 BMPFileWrite(U8 *filename,CDC *dc,I64 bits=4); extern Bool AutoComplete(Bool val=OFF);
extern I64 BMPWrite(U8 *filename,CDC *dc,I64 bits=4);
extern I64 CDFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,U8 *fu_flags=NULL, extern I64 CDFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,U8 *fu_flags=NULL,
U8 *_stage2_filename=NULL); U8 *_stage2_filename=NULL);
extern U0 ClipboardDel(); extern U0 ClipboardDel();
extern CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type); extern CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type);
extern Bool CtrlInside(CCtrl *c,I64 x,I64 y); extern Bool CtrlInside(CCtrl *c,I64 x,I64 y);
extern U8 *DC2Sprite(CDC *tempb); extern U8 *DC2Sprite(CDC *tempb);
extern U0 DocBMPFile(CDoc *doc=NULL,U8 *filename,Bool use_ms_paint_palette=FALSE); extern U0 DocBMP(CDoc *doc=NULL,U8 *filename,Bool dither_probability=FALSE,Bool use_ms_paint_palette=FALSE);
extern U0 DocBinDel(CDoc *doc,CDocBin *b); extern U0 DocBinDel(CDoc *doc,CDocBin *b);
extern U0 DocBinsValidate(CDoc *doc); extern U0 DocBinsValidate(CDoc *doc);
extern U0 DocBottom(CDoc *doc=NULL); extern U0 DocBottom(CDoc *doc=NULL);
@@ -52,8 +59,7 @@ extern CMenu *MenuFilePush(U8 *filename);
extern U0 MenuPop(); extern U0 MenuPop();
extern CMenu *MenuPush(U8 *st); extern CMenu *MenuPush(U8 *st);
extern CTask *Noise(I64 mS,I64 min_freq,I64 max_freq); extern CTask *Noise(I64 mS,I64 min_freq,I64 max_freq);
extern Bool Plain(U8 *filename); extern Bool Plain(U8 *filename,I64 edf_dof_flags=0);
extern I64 PopUp(U8 *msg,CTask *parent=NULL,CTask **_pu_task=NULL);
extern Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL); extern Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpColor(U8 *header=NULL,Bool allow_transpant=TRUE,Bool allow_dft=TRUE); extern I64 PopUpColor(U8 *header=NULL,Bool allow_transpant=TRUE,Bool allow_dft=TRUE);
extern I64 PopUpColorDither(U8 *header=NULL); extern I64 PopUpColorDither(U8 *header=NULL);
@@ -67,27 +73,20 @@ extern Bool PopUpNoYes(U8 *header=NULL,U8 *footer=NULL);
extern Bool PopUpOk(U8 *header=NULL,U8 *footer=NULL); extern Bool PopUpOk(U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpRangeI64(I64 lo,I64 hi,I64 step=1,U8 *header=NULL,U8 *footer=NULL); extern I64 PopUpRangeI64(I64 lo,I64 hi,I64 step=1,U8 *header=NULL,U8 *footer=NULL);
extern Bool PopUpTransform(I64 *r); extern Bool PopUpTransform(I64 *r);
extern CDoc *SetCursorPos(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE);
extern Bool SetWinHorz(I64 left,I64 right,CTask *task=NULL);
extern Bool SetWinVert(I64 top,I64 bottom,CTask *task=NULL);
extern U0 SettingsPop(CTask *task=NULL,I64 flags=0); extern U0 SettingsPop(CTask *task=NULL,I64 flags=0);
extern CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0); extern CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0);
extern U0 TemplateSliderCtrl(CDoc *doc); extern U0 TemplateCtrlSlider(CDoc *doc);
extern Bool View(); extern Bool View();
extern U0 ViewAnglesDel(CTask *task=NULL); extern U0 ViewAnglesDel(CTask *task=NULL);
extern CCtrl *ViewAnglesNew(CTask *task=NULL); extern CCtrl *ViewAnglesNew(CTask *task=NULL);
extern U0 WSDDef(I64 n,CTask *parent=NULL);
extern U0 WSDDefsPut(CDoc *doc,U8 *st,I64 num=-1);
extern U0 WSDFillin(I64 n);
extern U0 WSFillIn(I64 n);
extern U0 WSFindMisspelled(CDoc *doc);
extern U0 WSMan(I64 n,CTask *parent=NULL);
extern Bool WinBorder(Bool val,CTask *task=NULL); extern Bool WinBorder(Bool val,CTask *task=NULL);
extern CDoc *WinCursorPosSet(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE);
extern Bool WinHorz(I64 left,I64 right,CTask *task=NULL);
extern U0 WinMax(CTask *task=NULL); extern U0 WinMax(CTask *task=NULL);
extern U0 WinMgrSync(I64 cnt=1,Bool force=FALSE); extern U0 WinMgrSync(I64 cnt=1,Bool force=FALSE);
extern U0 WinScrollNull(CTask *task,CD3I64 *s); extern U0 WinScrollNull(CTask *task,CD3I64 *s);
extern U0 WinScrollRestore(CTask *task,CD3I64 *s); extern U0 WinScrollRestore(CTask *task,CD3I64 *s);
extern U0 WinScrollsInit(CTask *task); extern U0 WinScrollsInit(CTask *task);
extern Bool WinToTop(CTask *task=NULL,Bool update_z_buf=TRUE); extern Bool WinToTop(CTask *task=NULL,Bool update_z_buf=TRUE);
extern Bool WordStat(Bool val=OFF); extern Bool WinVert(I64 top,I64 bottom,CTask *task=NULL);
extern CWinMgrGlbls winmgr; extern CWinMgrGlbls winmgr;
+16 -16
View File
@@ -144,8 +144,8 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
U8 *outname=NULL,U8 mapfile_drv=0,U8 *index=NULL,CDoc *_doc=NULL) U8 *outname=NULL,U8 mapfile_drv=0,U8 *index=NULL,CDoc *_doc=NULL)
{//Dump hash symbol table. {//Dump hash symbol table.
// "+p" for only public symbols // "+p" for only public symbols
// "+m" to order by number (normally alphabetical) // "+m" to order by number (normally alphabetical)
// "-r" just local hash table // "-r" just local hash table
CHashTable *table; CHashTable *table;
CHashSrcSym *temph; CHashSrcSym *temph;
CHashGeneric *ptr; CHashGeneric *ptr;
@@ -177,7 +177,7 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
doc=NULL; doc=NULL;
if (index) { if (index) {
task=SpawnUser; task=User;
TaskWait(task); TaskWait(task);
LBtr(&task->display_flags,DISPLAYf_SHOW); LBtr(&task->display_flags,DISPLAYf_SHOW);
} else } else
@@ -186,8 +186,9 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
cnt=0; cnt=0;
table=h; table=h;
while (table) { while (table) {
temph=table->next_added; for (i=0;i<=table->mask;i++) {
while (temph!=table) { temph=table->body[i];
while (temph) {
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) && if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
(temph->type & HTF_PUBLIC || !publics)) { (temph->type & HTF_PUBLIC || !publics)) {
if (!index) if (!index)
@@ -195,7 +196,8 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
else if (temph->type&HTG_SRC_SYM && (cur_index=temph->index)) else if (temph->type&HTG_SRC_SYM && (cur_index=temph->index))
cnt+=HelpIndexCnt(cur_index,index); cnt+=HelpIndexCnt(cur_index,index);
} }
temph=temph->next_added; temph=temph->next;
}
} }
if (recurse) if (recurse)
table=table->next; table=table->next;
@@ -208,8 +210,9 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
j=0; j=0;
table=h; table=h;
while (table) { while (table) {
temph=table->next_added; for (i=0;i<=table->mask;i++) {
while (temph!=table) { temph=table->body[i];
while (temph) {
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) && if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
(temph->type & HTF_PUBLIC || !publics)) (temph->type & HTF_PUBLIC || !publics))
if (!index) if (!index)
@@ -220,7 +223,8 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
lst[j].index=HelpIndexStr(&cur_index,index); lst[j].index=HelpIndexStr(&cur_index,index);
lst[j++].h=temph; lst[j++].h=temph;
} }
temph=temph->next_added; temph=temph->next;
}
} }
if (recurse) if (recurse)
table=table->next; table=table->next;
@@ -347,7 +351,7 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
if (index) if (index)
progress1=progress1_max=0; progress1=progress1_max=0;
wh_done: wh_done:
Preempt(old_preempt); Preempt(old_preempt);
if (doc) { if (doc) {
DocBinsValidate(doc); DocBinsValidate(doc);
@@ -376,11 +380,7 @@ public I64 HashDepthRep(CHashTable *table=NULL)
for (i=0;i<=table->mask;i++) { for (i=0;i<=table->mask;i++) {
temph=table->body[i]; temph=table->body[i];
if (temph) { if (temph) {
j=1; j=LinkedLstCnt(temph);
while (temph->next) {
temph=temph->next;
j++;
}
if (j<HDR_MAX) if (j<HDR_MAX)
a[j]++; a[j]++;
cnt+=j; cnt+=j;
@@ -444,7 +444,7 @@ public U0 MapFileLoad(U8 *filename)
ptr=temph->src_link; ptr=temph->src_link;
if (ptr[0] && ptr[1] && ptr[2]==':' && ptr[3]==':') if (ptr[0] && ptr[1] && ptr[2]==':' && ptr[3]==':')
ptr[3]=*sys_acct; ptr[3]=dsk.boot_drv_let;
doc_e->aux_str=NULL; doc_e->aux_str=NULL;
} }
View File
File renamed without changes.
+21 -28
View File
@@ -1,7 +1,7 @@
#help_index "Math/ODE" #help_index "Math/ODE"
#help_file "::/Doc/ODE" #help_file "::/Doc/ODE"
//See $LK,"::/Doc/Acknowledgements.TXT"$. //See $LK,"::/Doc/Credits.TXT"$.
F64 LowPass1(F64 a,F64 y0,F64 y,F64 dt=1.0) F64 LowPass1(F64 a,F64 y0,F64 y,F64 dt=1.0)
{//First order low pass filter {//First order low pass filter
@@ -56,14 +56,12 @@ public CMathODE *ODENew(I64 n,F64 max_tolerance=1e-6,I64 flags=0)
ode->state=CAlloc(s); ode->state=CAlloc(s);
ode->array_base=MAlloc(12*s); ode->array_base=MAlloc(12*s);
ODERstPtrs(ode); ODERstPtrs(ode);
ode->ode_signature=ODE_SIGNATURE_VAL;
return ode; return ode;
} }
public U0 ODEDel(CMathODE *ode) public U0 ODEDel(CMathODE *ode)
{//Free ODE node, but not masses or springs. {//Free ODE node, but not masses or springs.
if (!ode) return; if (!ode) return;
ode->ode_signature=0;
Free(ode->state); Free(ode->state);
Free(ode->array_base); Free(ode->array_base);
Free(ode); Free(ode);
@@ -158,13 +156,13 @@ public U0 ODERenum(CMathODE *ode)
public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0) public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
{//Search for mass nearest to x,y,z. {//Search for mass nearest to x,y,z.
CMass *tempm,*best_mass=NULL; CMass *tempm,*best_mass=NULL;
F64 d,best_d=MAX_F64; F64 dd,best_dd=MAX_F64;
tempm=ode->next_mass; tempm=ode->next_mass;
while (tempm!=&ode->next_mass) { while (tempm!=&ode->next_mass) {
d=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z); dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
if (d<best_d) { if (dd<best_dd) {
best_d=d; best_dd=dd;
best_mass=tempm; best_mass=tempm;
} }
tempm=tempm->next; tempm=tempm->next;
@@ -175,15 +173,15 @@ public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0) public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
{//Find spring midpoint nearest x,y,z. {//Find spring midpoint nearest x,y,z.
CSpring *temps,*best_spring=NULL; CSpring *temps,*best_spring=NULL;
F64 d,best_d=MAX_F64; F64 dd,best_dd=MAX_F64;
temps=ode->next_spring; temps=ode->next_spring;
while (temps!=&ode->next_spring) { while (temps!=&ode->next_spring) {
d=Sqr((temps->end1->x+temps->end2->x)/2-x)+ dd=Sqr((temps->end1->x+temps->end2->x)/2-x)+
Sqr((temps->end1->y+temps->end2->y)/2-y)+ Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z); Sqr((temps->end1->z+temps->end2->z)/2-z);
if (d<best_d) { if (dd<best_dd) {
best_d=d; best_dd=dd;
best_spring=temps; best_spring=temps;
} }
temps=temps->next; temps=temps->next;
@@ -196,13 +194,13 @@ public U0 MassOrSpringFind(CMathODE *ode,CMass **result_mass,CSpring **result_sp
{//Find spring or mass nearest x,y,z. {//Find spring or mass nearest x,y,z.
CMass *tempm,*best_mass=NULL; CMass *tempm,*best_mass=NULL;
CSpring *temps,*best_spring=NULL; CSpring *temps,*best_spring=NULL;
F64 d,best_d=MAX_F64; F64 dd,best_dd=MAX_F64;
tempm=ode->next_mass; tempm=ode->next_mass;
while (tempm!=&ode->next_mass) { while (tempm!=&ode->next_mass) {
d=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z); dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
if (d<best_d) { if (dd<best_dd) {
best_d=d; best_dd=dd;
best_mass=tempm; best_mass=tempm;
} }
tempm=tempm->next; tempm=tempm->next;
@@ -210,11 +208,11 @@ public U0 MassOrSpringFind(CMathODE *ode,CMass **result_mass,CSpring **result_sp
temps=ode->next_spring; temps=ode->next_spring;
while (temps!=&ode->next_spring) { while (temps!=&ode->next_spring) {
d=Sqr((temps->end1->x+temps->end2->x)/2-x)+ dd=Sqr((temps->end1->x+temps->end2->x)/2-x)+
Sqr((temps->end1->y+temps->end2->y)/2-y)+ Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z); Sqr((temps->end1->z+temps->end2->z)/2-z);
if (d<best_d) { if (dd<best_dd) {
best_d=d; best_dd=dd;
best_spring=temps; best_spring=temps;
best_mass=NULL; best_mass=NULL;
} }
@@ -491,7 +489,7 @@ U0 ODERK5OneStep(CMathODE *ode)
MemCpy(ode->state_internal,tempstate,sizeof(F64)*ode->n_internal); MemCpy(ode->state_internal,tempstate,sizeof(F64)*ode->n_internal);
} }
F64 ode_allocated_factor=0.75; F64 ode_alloced_factor=0.75;
U0 ODEsUpdate(CTask *task) U0 ODEsUpdate(CTask *task)
{/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScreen.CPP,ODEsUpdate"$ on a continuous {/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScreen.CPP,ODEsUpdate"$ on a continuous
@@ -510,9 +508,8 @@ it has a timeout.
if (task->next_ode==&task->next_ode) if (task->next_ode==&task->next_ode)
task->last_ode_time=0; task->last_ode_time=0;
else { else if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
//See $LK,"GrUpdateWins",A="MN:GrUpdateWins"$() //See $LK,"GrUpdateWins",A="MN:GrUpdateWins"$()
if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
//TODO: Being preempted here woulds be bad //TODO: Being preempted here woulds be bad
if (task!=Fs) if (task!=Fs)
old_suspend=Suspend(task); old_suspend=Suspend(task);
@@ -524,10 +521,9 @@ it has a timeout.
d=1.0/winmgr.fps; d=1.0/winmgr.fps;
timeout_time=start_time+ timeout_time=start_time+
(task->last_ode_time/d+0.1)/(winmgr.last_ode_time/d+0.1)* (task->last_ode_time/d+0.1)/(winmgr.last_ode_time/d+0.1)*
ode_allocated_factor*d; ode_alloced_factor*d;
ode=task->next_ode; ode=task->next_ode;
while (ode!=&task->next_ode) { while (ode!=&task->next_ode) {
if (ode->ode_signature==ODE_SIGNATURE_VAL) {
t_initial=ode->t; t_initial=ode->t;
d=tS; d=tS;
if (!(ode->flags&ODEF_STARTED)) { if (!(ode->flags&ODEF_STARTED)) {
@@ -574,7 +570,6 @@ ode_done:
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt); ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
} }
ode->base_t+=(1.0-ode->t_scale)*d; ode->base_t+=(1.0-ode->t_scale)*d;
}
ode=ode->next; ode=ode->next;
} }
@@ -588,13 +583,12 @@ ode_done:
//This algorithm is probably not stable or very good, but it's something. //This algorithm is probably not stable or very good, but it's something.
//Target is 75% of allocated time. //Target is 75% of alloced time.
d=(tS-start_time)/(timeout_time-start_time)-0.75; d=(tS-start_time)/(timeout_time-start_time)-0.75;
ode=task->next_ode; ode=task->next_ode;
while (ode!=&task->next_ode) { while (ode!=&task->next_ode) {
if (ode->ode_signature==ODE_SIGNATURE_VAL && if (!(ode->flags&ODEF_PAUSED) && ode->derivative) {
!(ode->flags&ODEF_PAUSED) && ode->derivative) {
if (ode->min_tolerance!=ode->max_tolerance) { if (ode->min_tolerance!=ode->max_tolerance) {
if (d>0) if (d>0)
ode->tolerance_internal*=10.0`d; ode->tolerance_internal*=10.0`d;
@@ -610,5 +604,4 @@ ode_done:
if (task!=Fs) if (task!=Fs)
Suspend(task,old_suspend); Suspend(task,old_suspend);
} }
}
} }
+211
View File
@@ -0,0 +1,211 @@
#help_index "Memory/Task"
public I64 TaskMemAlloced(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task, used+unused.
I64 result;
if (!task) task=Fs;
if (override_validate || TaskValidate(task)) {
result=task->code_heap->alloced_u8s;
if (task->code_heap!=task->data_heap)
result+=task->data_heap->alloced_u8s;
return result;
} else
return 0;
}
public I64 TaskMemUsed(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task and in use.
I64 result;
if (!task) task=Fs;
if (override_validate || TaskValidate(task)) {
result=task->code_heap->used_u8s;
if (task->data_heap!=task->code_heap)
result+=task->data_heap->used_u8s;
return result;
} else
return 0;
}
public Bool HeapRep(CTask *task)
{//Report status of task's heap.
I64 i,cnt;
CMemUnused *uum;
if (!task || task==Fs) {
"Task can't HeapRep on self.\n";
return FALSE;
}
if (!TaskValidate(task)) return FALSE;
PUSHFD
CLI
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->data_heap!=task->code_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
cnt=0;
uum=task->code_heap->heap_hash[i];
while (uum) {
cnt+=uum->size;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->heap_hash[i];
while (uum) {
cnt+=uum->size;
uum=uum->next;
}
}
if (cnt)
"%03X:%08X\n",i<<3,cnt;
}
'\n';
uum=task->code_heap->malloc_free_lst;
while (uum) {
"%X, ",uum->size;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->malloc_free_lst;
while (uum) {
"%X, ",uum->size;
uum=uum->next;
}
}
if (task->data_heap!=task->code_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
'\n';
}
#help_index "Memory/HeapCtrl;Debugging/Heap"
public Bool IsInHeapCtrl(U8 *a,CHeapCtrl *hc,Bool lock=TRUE)
{//Check addr if on heap.
CMemBlk *m;
PUSHFD
CLI
if (lock)
while (LBts(&hc->locked_flags,HClf_LOCKED))
PAUSE
m=hc->next_mem_blk;
while (m!=&hc->next_mem_blk) {
if (a>=m && a<m(U8 *)+m->pages*PAGE_SIZE) {
if (lock)
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return TRUE;
}
m=m->next;
}
if (lock)
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return FALSE;
}
public Bool HeapCtrlWalk(CHeapCtrl *hc)
{//Check integrity of HeapCtrl.
I64 i;
CMemUnused *uum;
PUSHFD
CLI
while (LBts(&hc->locked_flags,HClf_LOCKED))
PAUSE
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
uum=hc->heap_hash[i];
while (uum) {
if (!IsInHeapCtrl(uum,hc,FALSE))
goto hc_false;
uum=uum->next;
}
}
uum=hc->malloc_free_lst;
while (uum) {
if (!IsInHeapCtrl(uum,hc,FALSE))
goto hc_false;
uum=uum->next;
}
#if _CFG_HEAP_DBG
CMemUsed *um,*um1;
um1=(&hc->next_um)(U8 *)-offset(CMemUsed.next);
um=um1->next;
while (um!=um1) {
if (!IsInHeapCtrl(um,hc,FALSE))
goto hc_false;
um=um->next;
}
#endif
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return TRUE;
hc_false:
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return FALSE;
}
#help_index "Memory/Task;Debugging/Heap"
public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
{//Check addr if on heap.
if (!task) task=Fs;
if (TaskValidate(task) && (IsInHeapCtrl(a,task->code_heap,lock)||
task->data_heap!=task->code_heap && IsInHeapCtrl(a,task->data_heap,lock)))
return TRUE;
else
return FALSE;
}
public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heaps.
if (!task) task=Fs;
if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) ||
task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
return FALSE;
else
return TRUE;
}
#help_index "Info;Task"
U0 TaskRepTask(CTask *task,I64 indent)
{
CTask *task1;
U8 *st,*desc=MStrUtil(task->task_title,SUF_SAFE_DOLLAR);
st=MStrPrint("$$MA,T=\"%08X\",LM=\"Kill(0x%X);\n\",$$",task,task,task);
"%h*c%s $$TX,\"%Q...\",SCX=16$$ Mem:%08X\n",indent,CH_SPACE,
st,desc,TaskMemAlloced(task);
"%h*cFlags:%04X:%04X Time:%0.2fm\n",indent+2,CH_SPACE,
task->task_flags,task->display_flags,
task->total_time/60.0/cnts.time_stamp_freq_initial;
Free(st);
Free(desc);
task1=task->next_child_task;
while (task1!=(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task)) {
TaskRepTask(task1,indent+2);
task1=task1->next_sibling_task;
}
}
public U0 TaskRep()
{//Report current tasks on all cores.
I64 i;
CCPU *c;
PUSHFD
CLI
for (i=0;i<mp_cnt;i++) {
c=&cpu_structs[i];
"$$RED$$CPU:%d$$FG$$\n",i;
TaskRepTask(c->seth_task,2);
}
POPFD
}
+5 -67
View File
@@ -1,66 +1,5 @@
#help_index "Misc/Accts" #help_index "Misc/Accts"
#define ACCT_REGISTRY_FILENAME "::/Home/Registry.CPP.Z"
U0 UserStartUp()
{//Temporary until defined in $LK,"HOME/Adam3eSys.CPP"$.
//Run each time a user a spawned
DocTermNew;
Type("::/Doc/Start.TXT");
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
}
U0 SrvStartUp()
{//Temporary until defined in $LK,"HOME/Adam3eSys.CPP"$.
//Run each time a srv task is spawned.
DocTermNew;
LBts(&Fs->display_flags,DISPLAYf_SHOW);
WinToTop;
WinZBufUpdate;
Preempt(ON);
}
U8 *PopUpSysAcct()
{
U8 *result,*st;
CDoc *doc=DocNew;
CDirEntry *tempde=FilesFind("/Accts/*",FUF_RECURSE|FUF_JUST_DIRS|FUF_FLATTEN_TREE),
*tempde1=tempde;
DocPrint(doc,"$$CM+CX-LE,10$$");
DocSprite(doc,$IB,"<1>",BI=1,BP="::/Misc/StockSprites.TXT,TempleOSLogo"$,"$$SP+SIF,\"\",BI=%d$$");
DocPrint(doc,"$$CM+LX,0,12$$Select Account.\nCursor down and press <SPACE>.\n");
while (tempde) {
if (*tempde->name!='.') {
st=tempde->full_name;
if (!StrNCmp(st+2,"/Accts/",7))
st+=9;
DocPrint(doc,"$$CM+LX,2,3$$$$BT,\"%s\",LE=%d$$",st,tempde);
}
tempde=tempde->next;
}
DocPrint(doc,"\n\n\n\nLog-in as USER if you are new and get familiar\n"
"before you try to install.\n");
do tempde=PopUpMenu(doc,DOF_WIN_MAX);
while (tempde<=0);
DocDel(doc);
result=AStrNew(tempde->full_name);
DirTreeDel(tempde1);
return result;
}
U0 SysLogin()
{
U8 *st;
if (!FileFind(sys_acct)||!StrCmp(sys_acct+2,"/Accts")) {
st=sys_acct;
sys_acct=PopUpSysAcct;
Free(st);
}
}
#define ACCT_REGISTRY_FILENAME "HOME/Registry.CPP.Z"
CDoc *sys_registry_doc=NULL; CDoc *sys_registry_doc=NULL;
I64 sys_msg_flags[1]={0}; I64 sys_msg_flags[1]={0};
F64 registry_version; F64 registry_version;
@@ -69,7 +8,7 @@ Bool AcctCacheRegistry()
{ {
Bool old_silent; Bool old_silent;
if (!sys_registry_doc) { if (!sys_registry_doc) {
old_silent=Silent(ON); old_silent=Silent;
sys_registry_doc=DocRead(ACCT_REGISTRY_FILENAME); sys_registry_doc=DocRead(ACCT_REGISTRY_FILENAME);
Silent(old_silent); Silent(old_silent);
return FALSE; return FALSE;
@@ -91,7 +30,7 @@ public Bool AcctRegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
else else
Adam("%s",val); Adam("%s",val);
} }
if (IsDrvWritable(*sys_acct)) if (IsDrvWritable(':'))
DocWrite(sys_registry_doc); DocWrite(sys_registry_doc);
result=FALSE; result=FALSE;
} else } else
@@ -118,7 +57,7 @@ public Bool AcctRegWriteBranch(U8 *path,U8 *fmt,...)
DocCut(sys_registry_doc,tree_branch,end_indent); DocCut(sys_registry_doc,tree_branch,end_indent);
DocTreeMake(sys_registry_doc,path); DocTreeMake(sys_registry_doc,path);
DocPrint(sys_registry_doc,"%s",buf); DocPrint(sys_registry_doc,"%s",buf);
if (IsDrvWritable(*sys_acct)) if (IsDrvWritable(':'))
DocWrite(sys_registry_doc); DocWrite(sys_registry_doc);
if (unlock_doc) if (unlock_doc)
DocUnlock(sys_registry_doc); DocUnlock(sys_registry_doc);
@@ -147,8 +86,7 @@ public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *msg)
U0 AcctOneTimePopUp(I64 flag_num,U8 *msg) U0 AcctOneTimePopUp(I64 flag_num,U8 *msg)
{//You're not supposed to make system pop-up flags, only me. {//You're not supposed to make system pop-up flags, only me.
if (OneTimePopUp(sys_msg_flags,flag_num,msg)) if (OneTimePopUp(sys_msg_flags,flag_num,msg))
AcctRegWriteBranch("Adam/SysMsgFlags", AcctRegWriteBranch("Adam/SysMsgFlags","sys_msg_flags[0]=0x%X;\n",
"sys_msg_flags[0]=0x%X;\n",
sys_msg_flags[0]); sys_msg_flags[0]);
} }
-80
View File
@@ -1,80 +0,0 @@
#exe {OptOn(OPTf_WARN_PAREN);};
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
HashTablePurge(adam_task->hash_table);
#help_index "Misc"
//Use Dbg("Type 'G;'"); to debug before window mgr is running.
public F64 os_version=2.11;//Operating system version.
//Fix here, too: $LK,"::/Demo/AcctExample/DbgAdam2.CPP"$
#include "AdamExts.HPP"
#include "Math2a"
#include "Training"
#include "Utils2a"
#include "MathODE"
Cd("::/Adam/Gr");;
#include "Gr"
Cd("::/Adam/Snd");;
#include "Snd"
Cd("::/Adam/Dsk");;
#include "Dsk2"
Cd("::/Adam");;
#include "Menu"
#include "Win2a"
#include "Win2b"
#include "Dbg2a"
#include "::/Adam/God/GodExt"
Cd("::/Adam/DolDoc");;
#include "Doc"
LBts(&sys_run_level,RLf_DOC);
Cd("::/Adam/Ctrls");;
#include "Ctrls"
Cd("::/Adam");;
#include "AutoFile2a"
#include "LogIn"
Cd("::/Adam/WordStat");;
#include "WordStat"
Cd("::/Adam/God");;
#include "God"
Cd("::/Adam");;
#include "Hash2a"
#include "TaskSettings"
#include "DevInfo"
#include "DocDefines"
//Dbg("Type 'G;'");
DocTermNew;
SetWinVert(2,10);
sys_winmgr_task=Spawn(&WinMgrTask,NULL,"Window Mgr");
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_SELF_CTRLS;
LBts(&Fs->display_flags,DISPLAYf_CHILDREN_NOT_ON_TOP);
LBts(&Fs->display_flags,DISPLAYf_SHOW);
SysLogin;
LBts(&sys_run_level,RLf_LOGIN);
RegistryInit;
LBts(&sys_run_level,RLf_REGISTRY);
Cd("::/Adam");;
#include "WallPaper"
#exe {OptOff(OPTf_WARN_PAREN);};
#exe {OptOff(OPTf_WARN_DUP_TYPES);};
LBts(&sys_run_level,RLf_ADAM2);
#help_index ""
Cd("HOME");;
#include "Adam3"
File renamed without changes.
@@ -1,21 +1,21 @@
#help_index "WordStat/Dictionary" #help_index "AutoComplete/Dictionary"
public U0 WSDWordsLoad() public U0 ACDWordsLoad()
{//Put words from word list into hash table. {//Put words from word list into hash table.
I64 size; I64 size;
CHashGeneric *temph; CHashGeneric *temph;
U8 *in_ptr,*in_start,*st2; U8 *in_ptr,*in_start,*st2;
U16 *d; U16 *d;
wsd.num_words=0; acd.num_words=0;
if (in_ptr=FileRead(WSD_WORD_FILENAME,&size)) { if (in_ptr=FileRead(ACD_WORD_FILENAME,&size)) {
in_start=in_ptr; in_start=in_ptr;
Free(wsd.word_lst); Free(acd.word_lst);
wsd.word_lst=AMAlloc(size); acd.word_lst=AMAlloc(size);
MemCpy(wsd.word_lst,in_start,size); MemCpy(acd.word_lst,in_start,size);
wsd.word_lst_size=size; acd.word_lst_size=size;
while (in_ptr<in_start+size) { while (in_ptr<in_start+size) {
if (*in_ptr==WSD_WORD_CHAR) if (*in_ptr==ACD_WORD_CHAR)
in_ptr++; in_ptr++;
if (*in_ptr) { if (*in_ptr) {
st2=MStrUtil(in_ptr,SUF_TO_UPPER); st2=MStrUtil(in_ptr,SUF_TO_UPPER);
@@ -29,8 +29,8 @@ public U0 WSDWordsLoad()
d=in_ptr; d=in_ptr;
temph->user_data0=*d; temph->user_data0=*d;
in_ptr+=2; in_ptr+=2;
HashAdd(temph,ws.hash_table); HashAdd(temph,ac.hash_table);
wsd.num_words++; acd.num_words++;
} else } else
in_ptr+=3; in_ptr+=3;
} }
@@ -38,29 +38,29 @@ public U0 WSDWordsLoad()
} }
} }
public U8 *WSDDefGet(U8 *st,I64 def_num=1) public U8 *ACDDefGet(U8 *st,I64 def_num=1)
{//MAlloc str holding single dict definition of word. {//MAlloc str holding single dict definition of word.
CFile *f; CFile *f;
CHashGeneric *temph; CHashGeneric *temph;
U8 *result=NULL,*buf,*in_ptr, U8 *result=NULL,*buf,*in_ptr,
*st2=MStrUtil(st,SUF_TO_UPPER); *st2=MStrUtil(st,SUF_TO_UPPER);
temph=HashFind(st2,ws.hash_table,HTT_DICT_WORD); temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
Free(st2); Free(st2);
if (temph) { if (temph) {
if (f=FOpen(WSD_DEF_FILENAME,"r")) { if (f=FOpen(ACD_DEF_FILENAME,"r")) {
buf=MAlloc(WSD_BLK_SIZE*2+1); buf=MAlloc(ACD_BLK_SIZE*2+1);
buf[WSD_BLK_SIZE*2]=0; //terminate buf[ACD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE); FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
FClose(f); FClose(f);
in_ptr=buf; in_ptr=buf;
while (in_ptr<buf+WSD_BLK_SIZE*2) { while (in_ptr<buf+ACD_BLK_SIZE*2) {
while (*in_ptr!=WSD_WORD_CHAR && in_ptr<buf+WSD_BLK_SIZE*2) while (*in_ptr!=ACD_WORD_CHAR && in_ptr<buf+ACD_BLK_SIZE*2)
in_ptr++; in_ptr++;
if (*in_ptr++==WSD_WORD_CHAR) { if (*in_ptr++==ACD_WORD_CHAR) {
if (!StrICmp(st,in_ptr)) { if (!StrICmp(st,in_ptr)) {
while (def_num && *in_ptr!=WSD_WORD_CHAR while (def_num && *in_ptr!=ACD_WORD_CHAR
&& in_ptr<buf+WSD_BLK_SIZE*2) { && in_ptr<buf+ACD_BLK_SIZE*2) {
if (*in_ptr==WSD_DEF_CHAR) { if (*in_ptr==ACD_DEF_CHAR) {
if (!--def_num) if (!--def_num)
break; break;
else else
@@ -68,7 +68,7 @@ public U8 *WSDDefGet(U8 *st,I64 def_num=1)
} else } else
in_ptr++; in_ptr++;
} }
if (*in_ptr++==WSD_DEF_CHAR) { if (*in_ptr++==ACD_DEF_CHAR) {
result=StrNew(in_ptr); result=StrNew(in_ptr);
break; break;
} }
@@ -81,35 +81,35 @@ public U8 *WSDDefGet(U8 *st,I64 def_num=1)
return result; return result;
} }
public U8 *WSDDefsGet(U8 *st) public U8 *ACDDefsGet(U8 *st)
{//MAlloc str with all dict definitions of word. {//MAlloc str with all dict definitions of word.
CFile *f; CFile *f;
CHashGeneric *temph; CHashGeneric *temph;
U8 *result=NULL,*buf,*in_ptr,*in_ptr2, U8 *result=NULL,*buf,*in_ptr,*in_ptr2,
*st2=MStrUtil(st,SUF_TO_UPPER); *st2=MStrUtil(st,SUF_TO_UPPER);
temph=HashFind(st2,ws.hash_table,HTT_DICT_WORD); temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
Free(st2); Free(st2);
if (temph) { if (temph) {
if (f=FOpen(WSD_DEF_FILENAME,"r")) { if (f=FOpen(ACD_DEF_FILENAME,"r")) {
buf=MAlloc(WSD_BLK_SIZE*2+1); buf=MAlloc(ACD_BLK_SIZE*2+1);
buf[WSD_BLK_SIZE*2]=0; //terminate buf[ACD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE); FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
FClose(f); FClose(f);
in_ptr=buf; in_ptr=buf;
while (in_ptr<buf+WSD_BLK_SIZE*2) { while (in_ptr<buf+ACD_BLK_SIZE*2) {
while (*in_ptr!=WSD_WORD_CHAR && in_ptr<buf+WSD_BLK_SIZE*2) while (*in_ptr!=ACD_WORD_CHAR && in_ptr<buf+ACD_BLK_SIZE*2)
in_ptr++; in_ptr++;
if (*in_ptr++==WSD_WORD_CHAR) { if (*in_ptr++==ACD_WORD_CHAR) {
if (!StrICmp(st,in_ptr)) { if (!StrICmp(st,in_ptr)) {
in_ptr2=in_ptr; in_ptr2=in_ptr;
in_ptr--; in_ptr--;
while (*in_ptr2!=WSD_WORD_CHAR while (*in_ptr2!=ACD_WORD_CHAR
&& in_ptr2<buf+WSD_BLK_SIZE*2) { && in_ptr2<buf+ACD_BLK_SIZE*2) {
in_ptr2++; in_ptr2++;
} }
result=MAlloc(in_ptr2+1-in_ptr); result=MAlloc(in_ptr2+1-in_ptr);
MemCpy(result,in_ptr,in_ptr2-in_ptr); MemCpy(result,in_ptr,in_ptr2-in_ptr);
result[in_ptr2-in_ptr]=WSD_END_CHAR; result[in_ptr2-in_ptr]=ACD_END_CHAR;
break; break;
} }
} }
@@ -121,29 +121,29 @@ public U8 *WSDDefsGet(U8 *st)
} }
/*Fmt of word lst entry: /*Fmt of word lst entry:
U8 WSD_WORD_CHAR U8 ACD_WORD_CHAR
U8 word[] with terminating zero U8 word[] with terminating zero
I16 block; I16 block;
*/ */
public U8 *WSDWordPtAt(U8 *st) public U8 *ACDWordPtAt(U8 *st)
{//Point to word in word list. {//Point to word in word list.
I64 i; I64 i;
U8 *start=wsd.word_lst,*r=start, U8 *start=acd.word_lst,*r=start,
*end=wsd.word_lst+wsd.word_lst_size; *end=acd.word_lst+acd.word_lst_size;
if (!st || !*st) if (!st || !*st)
return wsd.word_lst; return acd.word_lst;
if (wsd.word_lst_size) { if (acd.word_lst_size) {
while (start+3<end) { while (start+3<end) {
r=(start+end)>>1; r=(start+end)>>1;
while (TRUE) { while (TRUE) {
while (*r!=WSD_WORD_CHAR && r>wsd.word_lst) while (*r!=ACD_WORD_CHAR && r>acd.word_lst)
r--; r--;
if ((r[2]==WSD_WORD_CHAR||r[1]==WSD_WORD_CHAR)&&r-3>wsd.word_lst) if ((r[2]==ACD_WORD_CHAR||r[1]==ACD_WORD_CHAR)&&r-3>acd.word_lst)
r--; r--;
else else
break; break;
} }
if (*r==WSD_WORD_CHAR) { if (*r==ACD_WORD_CHAR) {
i=StrICmp(st,r+1); i=StrICmp(st,r+1);
if (i<0) if (i<0)
end=r-1; end=r-1;
@@ -156,80 +156,78 @@ public U8 *WSDWordPtAt(U8 *st)
} }
r=(start+end)>>1; r=(start+end)>>1;
while (TRUE) { while (TRUE) {
while (*r!=WSD_WORD_CHAR && r>wsd.word_lst) while (*r!=ACD_WORD_CHAR && r>acd.word_lst)
r--; r--;
if ((r[2]==WSD_WORD_CHAR||r[1]==WSD_WORD_CHAR)&&r-3>wsd.word_lst) if ((r[2]==ACD_WORD_CHAR||r[1]==ACD_WORD_CHAR)&&r-3>acd.word_lst)
r--; r--;
else else
break; break;
} }
if (*r==WSD_WORD_CHAR && StrICmp(st,r+1)>0) if (*r==ACD_WORD_CHAR && StrICmp(st,r+1)>0)
r+=StrLen(r)+3; r+=StrLen(r)+3;
} }
if (*r==WSD_WORD_CHAR) if (*r==ACD_WORD_CHAR)
return r; return r;
else else
return wsd.word_lst; return acd.word_lst;
} }
U0 WSDDictWordsAdd(CDoc *doc,U8 *st=NULL) U0 ACDDictWordsAdd(CDoc *doc,U8 *st)
{ {
I64 i; I64 i;
U8 *ptr; U8 *ptr;
if (!st) if (st && *st && (ptr=ACDWordPtAt(st))) {
st=ws.cur_word; for (i=0;i<ACD_MAX_FILLINS;i++) {
if (st && (ptr=WSDWordPtAt(st))) { if (*ptr++!=ACD_WORD_CHAR)
for (i=0;i<WSD_MAX_FILLINS;i++) {
if (*ptr++!=WSD_WORD_CHAR)
break; break;
if (i) if (i)
DocPrint(doc,"\n"); DocPrint(doc,"\n");
wsd.fillins[i]=ptr-1; acd.fillins[i]=ptr-1;
DocPrint(doc,"'%d' %-23ts",i,ptr); DocPrint(doc,"$$GREEN$$'%d'$$FG$$ %-23ts",i,ptr);
ptr+=StrLen(ptr)+3; ptr+=StrLen(ptr)+3;
} }
wsd.num_fillins=i; acd.num_fillins=i;
} }
} }
U0 WSDFillin(I64 n) U0 ACDFillin(I64 n)
{ {
U8 *s; U8 *s;
I64 len; I64 len;
if (0<=n<wsd.num_fillins) { if (0<=n<acd.num_fillins) {
s=wsd.fillins[n]+1; s=acd.fillins[n]+1;
len=StrLen(s); len=StrLen(s);
if (len>ws.partial_len) if (len>ac.partial_len)
Auto(s+ws.partial_len); Auto(s+ac.partial_len);
} }
} }
public U0 WSDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1) public U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
{//Put to doc a dictionary definition(s) of a word. {//Put to doc a dictionary definition(s) of a word.
U8 *st2,*st3; U8 *st2,*st3;
I64 ch,i=0; I64 ch,i=0;
if (!st) return; if (!st) return;
if (*st==WSD_WORD_CHAR) if (*st==ACD_WORD_CHAR)
st++; st++;
DocPrint(doc,"$$WW,1$$$$RED$$%s:$$FG$$\n\n",st); DocPrint(doc,"$$WW,1$$$$RED$$%s:$$FG$$\n\n",st);
if (num<0) { if (num<0) {
if (st3=WSDDefsGet(st)) { if (st3=ACDDefsGet(st)) {
st2=st3; st2=st3;
while (ch=*st2++) { while (ch=*st2++) {
switch (ch) { switch (ch) {
case WSD_WORD_CHAR: case ACD_WORD_CHAR:
break; break;
case WSD_DEF_CHAR: case ACD_DEF_CHAR:
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n", DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
++i,st2); ++i,st2);
break; break;
case WSD_PRONUNCIATION_CHAR: case ACD_PRONUNCIATION_CHAR:
DocPrint(doc,"$$LTGREEN$$%s$$FG$$\n",st2); DocPrint(doc,"$$LTGREEN$$%s$$FG$$\n",st2);
break; break;
case WSD_POS_CHAR: case ACD_POS_CHAR:
DocPrint(doc,"$$BLACK$$%s$$FG$$\n",st2); DocPrint(doc,"$$BLACK$$%s$$FG$$\n",st2);
break; break;
case WSD_EXTRA_CHAR: case ACD_EXTRA_CHAR:
DocPrint(doc,"$$LTBLUE$$%s$$FG$$\n",st2); DocPrint(doc,"$$LTBLUE$$%s$$FG$$\n",st2);
break; break;
} }
@@ -238,7 +236,7 @@ public U0 WSDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
Free(st3); Free(st3);
} }
} else { } else {
while (st2=WSDDefGet(st,++i)) { while (st2=ACDDefGet(st,++i)) {
if (i==num) if (i==num)
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n", DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
i,st2); i,st2);
@@ -247,21 +245,21 @@ public U0 WSDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
} }
} }
U0 WSDPopUpDef(U8 *st,I64 num=-1,CTask *parent=NULL) U0 ACDPopUpDef(U8 *st,I64 num=-1,CTask *parent=NULL)
{ {
U8 *buf; U8 *buf;
buf=MStrPrint("WSDDefsPut(DocPut,\"%s\",%d);View;",st,num); buf=MStrPrint("ACDDefsPut(DocPut,\"%s\",%d);View;",st,num);
PopUp(buf,parent); PopUp(buf,parent);
Free(buf); Free(buf);
} }
U0 WSDDef(I64 n,CTask *parent=NULL) U0 ACDDef(I64 n,CTask *parent=NULL)
{ {
if (0<=n<wsd.num_fillins) if (0<=n<acd.num_fillins)
WSDPopUpDef(wsd.fillins[n],-1,parent); ACDPopUpDef(acd.fillins[n],-1,parent);
} }
U0 WSFindMisspelled(CDoc *doc) U0 ACFindMisspelled(CDoc *doc)
{ {
Bool unlock=DocLock(doc); Bool unlock=DocLock(doc);
CDocEntry *doc_e=doc->cur_entry; CDocEntry *doc_e=doc->cur_entry;
@@ -277,7 +275,7 @@ U0 WSFindMisspelled(CDoc *doc)
col2++; col2++;
ch=doc_e->tag[col2]; ch=doc_e->tag[col2];
doc_e->tag[col2]=0; doc_e->tag[col2]=0;
if (StrICmp(&doc_e->tag[col],WSDWordPtAt(&doc_e->tag[col])+1)) { if (StrICmp(&doc_e->tag[col],ACDWordPtAt(&doc_e->tag[col])+1)) {
doc_e->tag[col2]=ch; doc_e->tag[col2]=ch;
doc->cur_entry=doc_e; doc->cur_entry=doc_e;
doc->cur_data_col=col; doc->cur_data_col=col;
@@ -10,10 +10,10 @@ and #include this file.
I ran $LK,"::/Misc/ToDolDoc.CPP"$ on it, first. I ran $LK,"::/Misc/ToDolDoc.CPP"$ on it, first.
See $LK,"::/Doc/Acknowledgements.TXT"$. See $LK,"::/Doc/Credits.TXT"$.
*/ */
I64 WSDNextCmd(U8 **_ptr) I64 ACDNextCmd(U8 **_ptr)
{ {
U8 ch,*ptr=*_ptr,*ptr2; U8 ch,*ptr=*_ptr,*ptr2;
I64 result=-1; I64 result=-1;
@@ -39,9 +39,9 @@ ncmd_done:
return result; return result;
} }
U8 *WSDNextEntry(U8 **_ptr) U8 *ACDNextEntry(U8 **_ptr)
{ {
U8 *result,*ignore,ch,*ptr=*_ptr,buf[WSD_BLK_SIZE],*out_ptr=buf; U8 *result,*ignore,ch,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
I64 l; I64 l;
while (TRUE) { while (TRUE) {
while (TRUE) { while (TRUE) {
@@ -53,7 +53,7 @@ U8 *WSDNextEntry(U8 **_ptr)
} else } else
break; break;
} }
ignore="b>\0i>\0p>\0/b>\0/i>\0/p>\0" ignore="b>\0i>\0ppp>\0/b>\0/i>\0/p>\0"
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\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" "/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
"note>\0/note>\0blockquote>\0/blockquote>\0"; "note>\0/note>\0blockquote>\0/blockquote>\0";
@@ -75,12 +75,12 @@ nentry_done:
return result; return result;
} }
I64 WSDCompareWords(U8 *e1,U8 *e2) I64 ACDCompareWords(U8 *e1,U8 *e2)
{ {
return StrICmp(e1,e2); return StrICmp(e1,e2);
} }
U8 *WSDSortWords(U8 *start,I64 size,I64 word_cnt) U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
{ {
U8 **ptr_array=MAlloc(sizeof(U8 *)*word_cnt), U8 **ptr_array=MAlloc(sizeof(U8 *)*word_cnt),
*out_start=MAlloc(size), *out_start=MAlloc(size),
@@ -91,7 +91,7 @@ U8 *WSDSortWords(U8 *start,I64 size,I64 word_cnt)
ptr+=StrLen(ptr)+3; ptr+=StrLen(ptr)+3;
} }
"Sorting...\n"; Sleep(100); "Sorting...\n"; Sleep(100);
QSortI64(ptr_array,word_cnt,&WSDCompareWords); QSortI64(ptr_array,word_cnt,&ACDCompareWords);
"Done...\n"; Sleep(100); "Done...\n"; Sleep(100);
ptr=out_start; ptr=out_start;
@@ -107,7 +107,7 @@ U8 *WSDSortWords(U8 *start,I64 size,I64 word_cnt)
return out_start; return out_start;
} }
U0 WSDGen(U8 *raw_dict_filename) U0 ACDGen(U8 *raw_dict_filename)
{ {
I64 cmd,size,word_cnt=0,largest_entry=0; I64 cmd,size,word_cnt=0,largest_entry=0;
U8 *st,*in_ptr=FileRead(raw_dict_filename,&size),*in_start=in_ptr, U8 *st,*in_ptr=FileRead(raw_dict_filename,&size),*in_start=in_ptr,
@@ -118,27 +118,27 @@ U0 WSDGen(U8 *raw_dict_filename)
U16 *d; U16 *d;
if (!in_ptr) return; if (!in_ptr) return;
do { do {
cmd=WSDNextCmd(&in_ptr); cmd=ACDNextCmd(&in_ptr);
if (cmd==WSD_H1) { if (cmd==ACD_H1) {
next_word: next_word:
if (out_ptr-def_word_start>largest_entry) if (out_ptr-def_word_start>largest_entry)
largest_entry=out_ptr-def_word_start; largest_entry=out_ptr-def_word_start;
def_word_start=out_ptr; def_word_start=out_ptr;
if (st=WSDNextEntry(&in_ptr)) { if (st=ACDNextEntry(&in_ptr)) {
if (*st) { if (*st) {
if (StrICmp(st,last_word)) { if (StrICmp(st,last_word)) {
word_cnt++; word_cnt++;
*word_ptr++=WSD_WORD_CHAR; *word_ptr++=ACD_WORD_CHAR;
last_word=word_ptr; last_word=word_ptr;
StrCpy(word_ptr,st); StrCpy(word_ptr,st);
word_ptr+=StrLen(st)+1; word_ptr+=StrLen(st)+1;
d=word_ptr; d=word_ptr;
*d=(out_ptr-out_start)/WSD_BLK_SIZE; *d=(out_ptr-out_start)/ACD_BLK_SIZE;
word_ptr+=2; word_ptr+=2;
*out_ptr++=WSD_WORD_CHAR; *out_ptr++=ACD_WORD_CHAR;
StrCpy(out_ptr,st); StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1; out_ptr+=StrLen(st)+1;
} }
@@ -146,68 +146,68 @@ next_word:
do { do {
do { do {
cmd=WSDNextCmd(&in_ptr); cmd=ACDNextCmd(&in_ptr);
if (cmd==WSD_H1) if (cmd==ACD_H1)
goto next_word; goto next_word;
} while (cmd>=0 && !(cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA)); } while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA));
if (cmd==WSD_DEF) { if (cmd==ACD_DEF) {
if(st=WSDNextEntry(&in_ptr)) { if(st=ACDNextEntry(&in_ptr)) {
if (*st) { if (*st) {
*out_ptr++=WSD_DEF_CHAR; *out_ptr++=ACD_DEF_CHAR;
StrCpy(out_ptr,st); StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1; out_ptr+=StrLen(st)+1;
} }
Free(st); Free(st);
} }
} else if (cmd==WSD_PRONUNCIATION) { } else if (cmd==ACD_PRONUNCIATION) {
if(st=WSDNextEntry(&in_ptr)) { if(st=ACDNextEntry(&in_ptr)) {
if (*st) { if (*st) {
*out_ptr++=WSD_PRONUNCIATION_CHAR; *out_ptr++=ACD_PRONUNCIATION_CHAR;
StrCpy(out_ptr,st); StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1; out_ptr+=StrLen(st)+1;
} }
Free(st); Free(st);
} }
} else if (cmd==WSD_POS) { } else if (cmd==ACD_POS) {
if(st=WSDNextEntry(&in_ptr)) { if(st=ACDNextEntry(&in_ptr)) {
if (*st) { if (*st) {
*out_ptr++=WSD_POS_CHAR; *out_ptr++=ACD_POS_CHAR;
StrCpy(out_ptr,st); StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1; out_ptr+=StrLen(st)+1;
} }
Free(st); Free(st);
} }
} else if (cmd==WSD_EXTRA) { } else if (cmd==ACD_EXTRA) {
if(st=WSDNextEntry(&in_ptr)) { if(st=ACDNextEntry(&in_ptr)) {
if (*st) { if (*st) {
*out_ptr++=WSD_EXTRA_CHAR; *out_ptr++=ACD_EXTRA_CHAR;
StrCpy(out_ptr,st); StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1; out_ptr+=StrLen(st)+1;
} }
Free(st); Free(st);
} }
} }
} while (cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA); } while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA);
} else } else
Free(st); Free(st);
} }
} }
} while (cmd>=0); } while (cmd>=0);
*out_ptr++=WSD_END_CHAR; *out_ptr++=ACD_END_CHAR;
*word_ptr++=WSD_END_CHAR; *word_ptr++=ACD_END_CHAR;
Free(in_start); Free(in_start);
"Blk Size :%d\n",WSD_BLK_SIZE; "Blk Size :%d\n",ACD_BLK_SIZE;
"Blk Cnt :%04X\n",(out_ptr-out_start+WSD_BLK_SIZE-1)/WSD_BLK_SIZE; "Blk Cnt :%04X\n",(out_ptr-out_start+ACD_BLK_SIZE-1)/ACD_BLK_SIZE;
"Largest Entry :%d\n",largest_entry; "Largest Entry :%d\n",largest_entry;
"Word Count :%d\n",word_cnt; "Word Count :%d\n",word_cnt;
FileWrite(WSD_DEF_FILENAME,out_start,out_ptr-out_start); FileWrite(ACD_DEF_FILENAME,out_start,out_ptr-out_start);
"Def File Size :%d\n",out_ptr-out_start; "Def File Size :%d\n",out_ptr-out_start;
sorted_word_start=WSDSortWords(word_start,word_ptr-word_start,word_cnt); sorted_word_start=ACDSortWords(word_start,word_ptr-word_start,word_cnt);
FileWrite(WSD_WORD_FILENAME,sorted_word_start,word_ptr-word_start); FileWrite(ACD_WORD_FILENAME,sorted_word_start,word_ptr-word_start);
"Word File Size:%d\n",word_ptr-word_start; "Word File Size:%d\n",word_ptr-word_start;
Free(out_start); Free(out_start);
@@ -215,4 +215,4 @@ next_word:
Free(sorted_word_start); Free(sorted_word_start);
} }
WSDGen("DICTIONARY.TXT"); ACDGen("DICTIONARY.TXT");
+342
View File
@@ -0,0 +1,342 @@
#help_index "AutoComplete"
CHashAC *ACHashAdd(U8 *w)
{
CHashAC *tempw=HashFind(w,ac.hash_table,HTT_WORD);
if (tempw) {
tempw->hits++;
return tempw;
}
tempw=ACAlloc(sizeof(CHashAC));
tempw->str=AStrNew(w);
tempw->type=HTT_WORD;
tempw->use_cnt=1;
tempw->hits=1;
HashAdd(tempw,ac.hash_table);
ac.num_words++;
return tempw;
}
U0 ACSingleFileAdd(U8 *buf)
{
I64 ch;
U8 *ptr=buf,*ptr2,*ptr3;
while (TRUE) {
while (TRUE) {
if (ch=*ptr++) {
if (Bt(chars_bitmap_alpha_numeric,ch))
break;
} else
return;
}
ptr3=ptr;
ptr2=ptr;
ptr--;
while (TRUE) {
if (ch=*ptr2++) {
if (Bt(chars_bitmap_alpha_numeric,ch))
*ptr3++=ch;
else if (ch!=CH_CURSOR)
break;
} else {
ptr2--;
break;
}
}
*ptr3=0;
ACHashAdd(ptr);
ptr=ptr2;
}
}
I64 ACSkipCrap(U8 *src,I64 len)
{
I64 j;
j=len-1;
while (j>=0) {
if (Bt(chars_bitmap_alpha_numeric,src[j]))
break;
else
j--;
}
return j+1;
}
I64 ACPriorWordInStr(U8 *src,U8 *dst,I64 len,I64 buf_size)
{
I64 i,j=0,k;
i=len-1;
while (i>=0)
if (!Bt(chars_bitmap_alpha_numeric,src[i]))
break;
else
i--;
if (i>=-1 && len>0)
for (k=i+1;k<len && j<buf_size-1;k++)
dst[j++]=src[k];
dst[j]=0;
return i+1;
}
U0 ACFillIn(I64 n)
{
U8 *s;
if (0<=--n<ac.num_fillins) {
s=ac.fillin_matches[n]->str;
if (StrLen(s)>ac.partial_len)
Auto(s+ac.partial_len);
}
}
U0 ACMan(I64 n,CTask *parent_task=NULL)
{
CHashAC *tempw;
CHashSrcSym *temph;
Bool old_preempt=Preempt(OFF);
if (0<=--n<ac.num_fillins && (tempw=ac.fillin_matches[n]) &&
(temph=HashFind(tempw->str,Fs->hash_table,HTG_SRC_SYM)) &&
temph->src_link) {
Preempt(old_preempt);
PopUpEd(temph->src_link,parent_task);
}
Preempt(old_preempt);
}
U0 ACFillInAdd(CHashAC *tempw)
{
I64 k;
if (ac.num_fillins<AC_MAX_FILLINS || tempw->hits>ac.fillin_hits[ac.num_fillins-1]) {
for (k=ac.num_fillins-1;k>=0;k--) {
if (tempw->hits<=ac.fillin_hits[k])
break;
else {
ac.fillin_matches[k+1]=ac.fillin_matches[k];
ac.fillin_hits[k+1] =ac.fillin_hits[k];
}
}
ac.fillin_matches[k+1]=tempw;
ac.fillin_hits[k+1] =tempw->hits;
if (ac.num_fillins<AC_MAX_FILLINS)
ac.num_fillins++;
}
}
U0 ACPutChoices(CDoc *focus_l,CDocEntry *doc_e,CTask *focus_task)
{
I64 i,data_col;
U8 *buf,*buf1,*src=NULL,*st;
CHashAC *tempw;
F64 timeout_time=tS+0.5;
CHashSrcSym *temph;
CDoc *doc=DocPut;
src=DocScanLine(focus_l,doc_e,&data_col);
DocUnlock(focus_l);
i=StrLen(src);
buf =MAlloc(MaxI64(i+1,256));
buf1=MAlloc(MaxI64(i+1,256));
if (data_col==-1)
data_col=0;
data_col=ACPriorWordInStr(src,buf,data_col,256);
ac.partial_len=StrLen(buf);
data_col=ACSkipCrap(src,data_col);
data_col=ACPriorWordInStr(src,buf1,data_col,256);
if (!ac.cur_word || StrCmp(ac.cur_word,buf)) {
st=ac.cur_word;
ac.cur_word=AStrNew(buf);
Free(st);
ac.num_fillins=0;
if (*ac.cur_word) {
Preempt(ON);
for (i=0;i<=ac.hash_table->mask;i++) {
tempw=ac.hash_table->body[i];
while (tempw && tS<timeout_time) {
if (!MemCmp(ac.cur_word,tempw->str,StrLen(ac.cur_word)))
ACFillInAdd(tempw);
tempw=tempw->next;
}
}
Preempt(OFF);
}
DocRst(doc,TRUE);
doc->flags|=DOCF_MIN_SIZE;
DocCursor;
Fs->border_src=BDS_CONST;
Fs->text_attr =Fs->border_attr=LTGRAY<<4+BLUE;
if (ac.cur_word && *ac.cur_word) {
DocPrint(doc,"$$PURPLE$$Word:%s$$FG$$\n",ac.cur_word);
for (i=0;i<ac.num_fillins;i++) {
st=ac.fillin_matches[i]->str;
DocPrint(doc,"$$GREEN$$F%02d$$FG$$ ",i+1);
if (TaskValidate(focus_task) &&
(temph=HashFind(st,focus_task->hash_table,HTG_SRC_SYM)) &&
temph->src_link) {
if (temph->type&HTF_PUBLIC)
DocPrint(doc,"$$RED$$");
DocPrint(doc,"$$TX+UL+L+PU,\"%Q\",A=\"%s\"$$$$FG$$\n",st,temph->src_link);
} else
DocPrint(doc,"%s\n",st);
}
if (acd.has_words)
ACDDictWordsAdd(doc,ac.cur_word);
} else if (FileFind("::/Doc/StandBy.TXT.Z"))
DocType(doc,"::/Doc/StandBy.TXT.Z",0);
DocRecalc(doc);
}
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
WinZBufUpdate;
Free(src);
Free(buf);
Free(buf1);
}
U0 ACTask(I64)
{
CTask *focus_task,*original_focus_task;
CDoc *doc;
CDocEntry *doc_e;
I64 ch;
DocTermNew;
WinHorz(51,Fs->win_right);
LBts(&Fs->display_flags,DISPLAYf_WIN_ON_TOP);
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER-WIF_SELF_IP_L-WIF_SELF_IP_R-WIG_DBL_CLICK;
Free(ac.cur_word);
ac.cur_word=NULL;
while (TRUE) {
original_focus_task=focus_task=sys_focus_task;
while (TaskValidate(focus_task) && Bt(&focus_task->task_flags,TASKf_INPUT_FILTER_TASK))
focus_task=focus_task->parent_task;
if (TaskValidate(focus_task) && (doc=DocPut(focus_task)) &&
focus_task!=Fs && Bt(&focus_task->display_flags,DISPLAYf_SHOW)) {
DocLock(doc);
if (TaskValidate(focus_task) && original_focus_task==sys_focus_task &&
doc && doc==DocPut(focus_task) && (doc_e=doc->cur_entry)) {
if (doc_e==doc) doc_e=doc_e->last;
while (doc_e->last!=doc && (doc_e->type_u8==DOCT_NEW_LINE ||
doc_e->type_u8==DOCT_SOFT_NEW_LINE))
doc_e=doc_e->last;
while (doc_e->last->type_u8!=DOCT_NEW_LINE && doc_e->last!=doc)
doc_e=doc_e->last;
ACPutChoices(doc,doc_e,focus_task);
} else
DocUnlock(doc);
}
Sleep(333);
if (ScanMsg(&ch,,1<<MSG_KEY_DOWN) && (ch==CH_ESC||ch==CH_SHIFT_ESC))
break;
doc=DocPut;
DocLock(doc);
if (doc->cur_entry->de_flags & DOCEF_LINK) {
'' CH_SPACE;
doc->cur_entry=doc;
}
DocUnlock(doc);
}
ac.task=NULL;
}
U0 ACMainFileLstTraverse(U8 *files_find_mask)
{
U8 *buf;
CDirEntry *tempde,*tempde1;
try {
tempde=tempde1=FilesFind(files_find_mask,FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES|FUF_CLUSTER_ORDER);
while (tempde) {
"%s\n",tempde->full_name;
buf=FileRead(tempde->full_name);
ACSingleFileAdd(buf);
Free(buf);
tempde=tempde->next;
}
} catch
Fs->catch_except=TRUE;
DirTreeDel(tempde1);
}
public Bool AutoComplete(Bool val=OFF)
{//Turn AutoComplete OFF (or ON).
Bool old_autocomplete=FALSE,
old_preempt=Preempt(OFF);
if (val) {
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
Sleep(10);
if (TaskValidate(ac.task))
old_autocomplete=TRUE;
else {
ac.task=Spawn(&ACTask,NULL,"AutoComplete");
TaskWait(ac.task);
}
WinToTop(ac.task);
} else {
if (TaskValidate(ac.task)) {
old_autocomplete=TRUE;
Kill(ac.task);
while (TaskValidate(ac.task))
Yield;
ac.task=NULL;
}
}
Preempt(old_preempt);
return old_autocomplete;
}
U0 ACProgressTask(Bool *_start_flag)
{
I64 start=dsk.write_cnt;
progress1=0;
progress1_max=(Size(ACD_DEF_FILENAME_Z,"+x+s")+BLK_SIZE-1)>>BLK_SIZE_BITS;
StrCpy(progress1_desc,"Uncompressing Dictionary");
start=dsk.write_cnt;
*_start_flag=TRUE;
while (progress1<progress1_max) {
progress1=dsk.write_cnt-start;
Sleep(10);
}
*progress1_desc=progress1=progress1_max=0;
}
public U0 ACInit(U8 *mask=NULL)
{//Read files and build AutoComplete statistics.
Bool start_flag;
CBlkDev *bd=Let2BlkDev;
while (LBts(&ac.flags,ACf_INIT_IN_PROGRESS))
Yield;
AutoComplete;
if (IsDrvWritable && FileFind(ACD_DEF_FILENAME_Z) && !FileFind(ACD_DEF_FILENAME)) {
if (bd->type!=BDT_RAM) {
start_flag=FALSE;
Spawn(&ACProgressTask,&start_flag);
while (!start_flag)
Yield;
}
Move(ACD_DEF_FILENAME_Z,ACD_DEF_FILENAME);
}
HashTableDel(ac.hash_table);
ac.hash_table=HashTableNew(2048,adam_task);
ac.num_words=0;
Free(ac.cur_word);
ac.cur_word=NULL;
if (mask)
ACMainFileLstTraverse(mask);
ACDWordsLoad;
LBtr(&ac.flags,ACf_INIT_IN_PROGRESS);
AutoComplete(ON);
}
I64 AutoCompleteSize()
{
if (ac.hash_table)
return HashTableSize2(ac.hash_table)+MSize2(acd.word_lst);
else
return 0;
}
File renamed without changes.
+67
View File
@@ -0,0 +1,67 @@
#help_index "AutoComplete"
#help_file "::/Doc/AutoComplete"
//See $LK,"::/Doc/AutoComplete.TXT"$
#define ACf_INIT_IN_PROGRESS 0
#define AC_MAX_FILLINS 10
public class CAutoCompleteGlbls
{
I64 num_words;
CHashTable *hash_table;
U8 *cur_word;
I64 flags;
CTask *task;
I64 partial_len,num_fillins,
fillin_hits [AC_MAX_FILLINS+1];
CHashAC *fillin_matches[AC_MAX_FILLINS+1];
} ac={0,NULL,NULL,0,NULL,0,0,
{0,0,0,0,0,0,0,0,0,0,0},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}};
//Dictionary Stuff
#help_index "AutoComplete/Dictionary"
#define ACD_WORD_FILENAME "/Adam/AutoComplete/ACWords.DAT.Z"
#define ACD_DEF_FILENAME "/Adam/AutoComplete/ACDefs.DAT"
#define ACD_DEF_FILENAME_Z "/Adam/AutoComplete/ACDefs.DAT.Z"
#define ACD_H1 0
#define ACD_H1_END 1
#define ACD_DEF 2
#define ACD_DEF_END 3
#define ACD_PRONUNCIATION 4
#define ACD_PRONUNCIATION_END 5
#define ACD_POS 6
#define ACD_POS_END 7
#define ACD_EXTRA 8
#define ACD_EXTRA_END 9
#define ACD_BLK_SIZE 0x4000
#define ACD_END_CHAR 0x00
#define ACD_WORD_CHAR 0x01
#define ACD_DEF_CHAR 0x02
#define ACD_PRONUNCIATION_CHAR 0x03
#define ACD_POS_CHAR 0x04
#define ACD_EXTRA_CHAR 0x05
#define ACD_MAX_FILLINS 10
public class CAutoCompleteDictGlbls
{
U8 *word_lst;
I64 word_lst_size,num_words,num_fillins;
U8 *fillins[ACD_MAX_FILLINS];
Bool has_words,has_defs;
} acd={NULL,0,0,0,{0,0,0,0,0,0,0,0,0,0},FALSE,FALSE};
acd.has_words=FileFind(ACD_WORD_FILENAME);
acd.has_defs =FileFind(ACD_DEF_FILENAME)||FileFind(ACD_DEF_FILENAME_Z);
extern U0 ACDWordsLoad();
extern U0 ACDDictWordsAdd(CDoc *doc,U8 *st);
#include "ACMain"
#include "ACDict"
+1 -1
View File
@@ -108,7 +108,7 @@ I64 af_l,af_r;
Bool AFSetIPPlot(I64 mS,I64 x,I64 y,I64 z) Bool AFSetIPPlot(I64 mS,I64 x,I64 y,I64 z)
{ {
SetIP(x,y,z,af_l,af_r); IPSet(x,y,z,af_l,af_r);
Sleep(mS); Sleep(mS);
return TRUE; return TRUE;
} }
+64
View File
@@ -0,0 +1,64 @@
#include "BootCD"
#include "BootHD"
#include "BootMHD"
#include "BootMHD2"
#include "DskCDDVD"
#include "BootIns"
#help_index "Call"
asm {
USE64
_HI_CALL::
PUSH RBP
MOV RBP,RSP
MOV RAX,U64 16[RBP]
TEST RAX,RAX
JZ @@05
CALL RAX
@@05: POP RBP
RET1 8
//************************************
_HI_MEMCPY::
PUSH RBP
MOV RBP,RSP
PUSH RSI
PUSH RDI
CLD
MOV RDI,U64 SF_ARG1[RBP]
MOV RSI,U64 SF_ARG2[RBP]
MOV RCX,U64 SF_ARG3[RBP]
REP_MOVSB
MOV RAX,RDI
POP RDI
POP RSI
POP RBP
RET1 24
}
_extern _HI_CALL I64 HiCall(U8 *s);
_extern _HI_MEMCPY U8 *HiMemCpy(U8 *dst,U8 *src,I64 cnt);
#help_index "Boot"
public U0 RAMReboot(U8 *filename)
{//Softboot Kernel Bin file. No hardware reset.
I64 size;
CKernel *hi_image,*lo_image=sys_boot_base-sizeof(CBinFile),reg *sys_ram_reboot;
do if (!(hi_image=FileRead(filename,&size))) return;
while (hi_image<0x100000);
do sys_ram_reboot=MAlloc(SYS_RAM_REBOOT_END-SYS_RAM_REBOOT,Fs->code_heap);
while (sys_ram_reboot<0x100000);
hi_image->boot_src=BOOT_SRC_RAM;
hi_image->boot_patch_table_base=lo_image(U8 *)+hi_image->h.patch_table_offset;
hi_image->sys_run_level =lo_image->sys_run_level&(RLF_VGA|RLF_16BIT);
MemCpy(&hi_image->start,&lo_image->start,sizeof(CKernel)-offset(CKernel.start));
CLI
if (mp_cnt>1)
MPHalt;
HiMemCpy(sys_ram_reboot,SYS_RAM_REBOOT,SYS_RAM_REBOOT_END-SYS_RAM_REBOOT);
HiMemCpy(lo_image,hi_image,size);
HiCall(sys_ram_reboot);
}
+9 -9
View File
@@ -1,17 +1,17 @@
#define CD_BOOT_LOADER_SIZE CD_BLK_SIZE*1 //Max CD_BLK_SIZE*4, I think #define CD_BOOT_LOADER_SIZE CD_BLK_SIZE*1 //Max CD_BLK_SIZE*4, I think
#define BOOT_HIGH_LOC ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+CD_BOOT_LOADER_SIZE))>>4) #define BOOT_HIGH_LOC_CD ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+CD_BOOT_LOADER_SIZE))>>4)
DefinePrint( DefinePrint(
"DD_BOOT_HIGH_LOC","%08X",BOOT_HIGH_LOC<<4); "DD_BOOT_HIGH_LOC_CD","%08X",BOOT_HIGH_LOC_CD<<4);
DefinePrint( DefinePrint(
"DD_BOOT_HIGH_LOC_END","%08X",BOOT_RAM_LIMIT-1); "DD_BOOT_HIGH_LOC_CD_END","%08X",BOOT_RAM_LIMIT-1);
asm { asm {
USE16 USE16
BCD_START:: BCD_START::
//DL is supposed to have the BIOS drive number //DL is supposed to have the BIOS drive number
CLD CLD
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_CD
MOV ES,AX MOV ES,AX
CLI CLI
@@ -24,7 +24,7 @@ BCD_GET_IP:
POP BX POP BX
SUB BX,BCD_GET_IP-BCD_START SUB BX,BCD_GET_IP-BCD_START
SHR BX,4 SHR BX,4
//Copy this bootloader code to just under 0x80000 //This copies this bootloader's code to 0x$TX,"00096600",D="DD_BOOT_HIGH_LOC_CD"$
MOV AX,CS MOV AX,CS
ADD AX,BX ADD AX,BX
MOV DS,AX MOV DS,AX
@@ -33,12 +33,12 @@ BCD_GET_IP:
XOR DI,DI XOR DI,DI
REP_MOVSB REP_MOVSB
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_CD
MOV DS,AX MOV DS,AX
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_HIGH_LOC:BCD_MAIN DU8 0xEA; //JMP BOOT_HIGH_LOC_CD:BCD_MAIN
DU16 BCD_MAIN-BCD_START,BOOT_HIGH_LOC; DU16 BCD_MAIN-BCD_START,BOOT_HIGH_LOC_CD;
BCD_BIOS_DRV_NUM: DU8 0; BCD_BIOS_DRV_NUM: DU8 0;
BCD_PAGE: DU8 0; BCD_PAGE: DU8 0;
@@ -152,7 +152,7 @@ BCD_MAIN::
//See $LK,"BootCdProbe",A="MN:BootCdProbe"$(). //See $LK,"BootCdProbe",A="MN:BootCdProbe"$().
MOV EBX,U32 [BCD_BLK_LO-BCD_START] //TODO: oops overflow? MOV EBX,U32 [BCD_BLK_LO-BCD_START] //TODO: oops overflow?
SHL EBX,16 SHL EBX,16
MOV BX,BOOT_CODE_CDROM //$MA-X+PU,"See sys_boot_code",LM="Grep(\"sys_boot_code\",\"/*\");View;\n"$ MOV BX,BOOT_SRC_CDROM //$MA-X+PU,"See sys_boot_src",LM="Find(\"sys_boot_src\",\"/*\");View;\n"$
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_RAM_BASE:0000 DU8 0xEA; //JMP BOOT_RAM_BASE:0000
+13 -10
View File
@@ -1,5 +1,8 @@
#define MODULE_SIZE 1*BLK_SIZE #define MODULE_SIZE 1*BLK_SIZE
#define BOOT_HIGH_LOC ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4) #define BOOT_HIGH_LOC_HD ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4)
DefinePrint(
"DD_BOOT_HIGH_LOC_HD","%08X",BOOT_HIGH_LOC_HD<<4);
asm { asm {
USE16 USE16
@@ -9,11 +12,11 @@ BHD_CODE::
CLD CLD
MOV AX,VGA_TEXT_MEM_BASE/16 MOV AX,VGAM_TEXT/16
MOV FS,AX MOV FS,AX
MOV U32 FS:[0],'B'+GREEN<<12+('2'+GREEN<<12)<<16 MOV U32 FS:[0],'B'+GREEN<<12+('2'+GREEN<<12)<<16
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_HD
MOV ES,AX MOV ES,AX
CLI CLI
@@ -26,7 +29,7 @@ BHD_GET_IP:
POP BX POP BX
SUB BX,BHD_GET_IP-BHD_START SUB BX,BHD_GET_IP-BHD_START
SHR BX,4 SHR BX,4
//Copy this bootloader code to just under 0x80000 //This copies this bootloader's code to 0x$TX,"00096C00",D="DD_BOOT_HIGH_LOC_HD"$
MOV AX,CS MOV AX,CS
ADD AX,BX ADD AX,BX
MOV DS,AX MOV DS,AX
@@ -35,21 +38,21 @@ BHD_GET_IP:
XOR DI,DI XOR DI,DI
REP_MOVSB REP_MOVSB
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_HD
MOV DS,AX MOV DS,AX
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_HIGH_LOC:BHD_HISTART DU8 0xEA; //JMP BOOT_HIGH_LOC_HD:BHD_HISTART
DU16 BHD_HISTART-BHD_START,BOOT_HIGH_LOC; DU16 BHD_HISTART-BHD_START,BOOT_HIGH_LOC_HD;
BHD_BIOS_DRV_NUM: DU8 0; BHD_BIOS_DRV_NUM: DU8 0;
//Gets patched by $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$(). //Gets patched by $LK,"MakeOSDrvBootInstall",A="MN:MakeOSDrvBootInstall"$().
BHD_BLK_CNT:: DU16 0; BHD_BLK_CNT:: DU16 0;
BHD_DAP: DU8 16,0,1,0; //One blk at a time BHD_DAP: DU8 16,0,1,0; //One blk at a time
BHD_DAP_BUF: DU16 0,0; BHD_DAP_BUF: DU16 0,0;
//Gets patched by $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$(). //Gets patched by $LK,"MakeOSDrvBootInstall",A="MN:MakeOSDrvBootInstall"$().
BHD_DAP_BLK:: //64-bit BHD_DAP_BLK:: //64-bit
BHD_DAP_BLK_LO: DU32 0; BHD_DAP_BLK_LO: DU32 0;
BHD_DAP_BLK_HI: DU32 0; BHD_DAP_BLK_HI: DU32 0;
@@ -82,7 +85,7 @@ BHD_HISTART:
@@10: POP CX @@10: POP CX
LOOP @@05 LOOP @@05
MOV EBX,BOOT_CODE_HARDDRV //$MA-X+PU,"See sys_boot_code",LM="Grep(\"sys_boot_code\",\"/*\");View;\n"$ MOV EBX,BOOT_SRC_HARDDRV //$MA-X+PU,"See sys_boot_src",LM="Find(\"sys_boot_src\",\"/*\");View;\n"$
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_RAM_BASE:0000 DU8 0xEA; //JMP BOOT_RAM_BASE:0000
DU16 0,BOOT_RAM_BASE/16; DU16 0,BOOT_RAM_BASE/16;
+233
View File
@@ -0,0 +1,233 @@
//See $LK,"Install Documentation",A="FI:::/Doc/Install.TXT"$ or $LK,"Upgrading Documentation",A="FI:::/Doc/Upgrade.TXT"$.
#help_index "Install"
#define KERNEL_BIN_C "Kernel.BIN.C"
#define BOOT_DIR "/0000Boot"
#define BOOT_DIR_KERNEL_BIN_C BOOT_DIR "/0000" KERNEL_BIN_C
//Stage 2 of master boot loader
#define BOOT_DIR_BOOTMHD2_BIN_C BOOT_DIR "/BootMHD2.BIN.C"
//Old master boot record
#define BOOT_DIR_OLDMBR_BIN_C BOOT_DIR "/OldMBR.BIN.C"
public U0 MakeAll()
{//Use $LK,"MakeOSDrvBootInstall",A="MN:MakeOSDrvBootInstall"$. Loader must be patched.
//These 2 modules (and bootloaders at top) are the only AOT
//compiled code in TempleOS. Everything else is JIT.
//You are doing it wrong if you make AOT compiled code.
if (Cmp("/Compiler/Compiler","Compiler",,':'))
throw;
if (Cmp("/Kernel/Kernel","Kernel",,':'))
throw;
}
public Bool MakeOSDrvBootInstall(U8 src_drv=0,U8 dst_drv=0)
{// Does $LK,"MakeAll",A="MN:MakeAll"$ and installs new boot-loader.
//Normally, you just supply a src_drv. It will compile
//the code on that drive and update the boot sect.
//If you are making a bootable CD-ROM, you supply a dst_drv.
//See $LK,"::/Misc/MakeDistro.CPP"$
//See $LK,"Install Documentation",A="FI:::/Doc/Install.TXT"$
//Study my account examples my technique: $LK,"Cfg Strs",A="FL:::/Demo/AcctExample/TOSCfg.CPP,1"$, $LK,"Update Funs",A="FL:::/Demo/AcctExample/TOSDistro.CPP,1"$
CBlkDev *bd;
CDrv *dv;
CFAT32Boot br;
CDirEntry de;
Bool result=FALSE;
I64 i;
try {
if (!src_drv) src_drv=Drv2Let(Fs->cur_dv);
if (!dst_drv) dst_drv=src_drv;
if (!Drv(src_drv))
throw;
MakeAll;
bd=Let2BlkDev(dst_drv);
dv=Let2Drv (dst_drv);
switch (bd->type) {
case BDT_ATAPI:
Move("/Kernel/Kernel.BIN.Z",BOOT_DIR_KERNEL_BIN_C);
result=TRUE;
break;
case BDT_RAM:
case BDT_ATA:
Move("/Kernel/Kernel.BIN.Z","/" KERNEL_BIN_C);
if (!FileFind("/" KERNEL_BIN_C,&de,FUF_JUST_FILES))
"No Kernel.BIN.C\n";
else {
Free(de.full_name);
"Modifying partition boot record.\n";
RBlks(dv,&br,dv->base_offset,1);
br.jump_and_nop[0]=OC_JMP_REL8;
br.jump_and_nop[1]=offset(CFAT32Boot.code)-2;
#assert offset(CFAT32Boot.code)>=offset(CRedSeaBoot.code)
br.jump_and_nop[2]=OC_NOP;
*BHD_BLK_CNT(U16 *)=(de.size+BLK_SIZE-1)>>BLK_SIZE_BITS;
*BHD_DAP_BLK(I64 *)=Cluster2Blk(dv,de.cluster);
for (i=0;i<BHD_END-BHD_CODE;i++)
br.code[i]=BHD_CODE(U8 *)[i];
#assert sizeof(CFAT32Boot.code)>=BHD_END-BHD_CODE
for (;i<sizeof(CFAT32Boot.code);i++)
br.code[i]=0;
WBlks(dv,&br,dv->base_offset,1);
result=TRUE;
}
break;
}
} catch {
PutExcept;
Beep;
}
return result;
}
public U0 MasterBootOldRead(U8 src_drv,U8 dst_drv)
{//Reads MBR from disk drive containing src partition.
//Writes a single blk file to dst /0000Boot directory.
CBlkDev *bd=Let2BlkDev(src_drv);
CDrv *dv;
CMasterBoot mbr;
Drv(dst_drv);
dv=Fs->cur_dv;
if (dv->type!=DVT_REDSEA && dv->type!=DVT_FAT32)
PrintErr("Not RedSea Drv\n");
else {
//Bypass partition bounds-checking
BlkDevLock(bd);
ATAReadBlks(bd,&mbr,0,1);
BlkDevUnlock(bd);
Drv(dst_drv);
MkDir(BOOT_DIR);
FileWrite(BOOT_DIR_OLDMBR_BIN_C,&mbr,BLK_SIZE);
}
}
public U0 MasterBootOldWrite(U8 src_drv,U8 dst_drv)
{//Reads OldMBR from src drive /0000Boot directory
//writes it to the MBR of the drive with dst partition.
CBlkDev *bd=Let2BlkDev(dst_drv);
CMasterBoot *mbr;
Drv(src_drv);
if (mbr=FileRead(BOOT_DIR_OLDMBR_BIN_C)) {
//Bypass partition bounds-checking
BlkDevLock(bd);
ATAWriteBlks(bd,mbr,0,1);
BlkDevUnlock(bd);
}
Free(mbr);
}
public U0 MasterBootZero(U8 dst_drv)
{//Set MBR of disk with dst partition to zero.
//This is dangerous!!
//The TempleOS partitioner doesn't play well
//with other operating systems at this time and you need
//to do this on a drive partitioned by TempleOS
//if you wish to partition with another operating system.
CBlkDev *bd=Let2BlkDev(dst_drv);
CMasterBoot mbr;
MemSet(&mbr,0,BLK_SIZE);
//Bypass partition bounds-checking
BlkDevLock(bd);
ATAWriteBlks(bd,&mbr,0,1);
BlkDevUnlock(bd);
}
public Bool MasterBootIntall(U8 drv_let,U8 *drv_lst=NULL)
{//Create new MBR on the disk that has drv_let as a partition.
//Puts stage 2 in /0000Boot dir of drv_let.
CBlkDev *bd,*bd1;
CDrv *dv,*p1;
CMasterBoot mbr;
CDirEntry de;
I64 i,j,size,*_q;
U8 *menu_ptr,*ptr,ch,buf[128];
Bool result=FALSE;
try {
if (drv_lst)
StrCpy(buf,drv_lst);
else {
j=0;
for (i='A';i<='Z';i++)
buf[j++]=i;
buf[j++]=0;
}
Drv(drv_let);
dv=Fs->cur_dv;
if (dv->type!=DVT_REDSEA && dv->type!=DVT_FAT32)
PrintErr("Not RedSea Drv\n");
else {
bd=Let2BlkDev(drv_let);
if (!FileFind(BOOT_DIR_OLDMBR_BIN_C,,FUF_JUST_FILES))
MasterBootOldRead(drv_let,drv_let);
_q=BMHD2_BLK_ARRAY;
MemSet(_q,0,sizeof(I64)*8);
menu_ptr=BMHD2_BOOT_MSG;
StrPrint(menu_ptr,"\n\r\n\rTempleOS Boot Loader\n\r\n\r");
j=0;
if (FileFind(BOOT_DIR_OLDMBR_BIN_C,&de,FUF_JUST_FILES)) {
Free(de.full_name);
*_q++=Cluster2Blk(dv,de.cluster);
CatPrint(menu_ptr,"0. Old Boot Record\n\r");
j++;
}
ptr=buf;
while (ch=*ptr++) {
try {
p1 =Let2Drv(ch);
bd1=Let2BlkDev(ch);
} catch {
Fs->catch_except=TRUE;
p1 =NULL;
bd1=NULL;
}
if (p1 && bd1==bd) {
*_q=p1->base_offset;
"Drive %C:%16X\n",Drv2Let(p1),*_q;
CatPrint(menu_ptr,"%d. Drive %C\n\r",j++,Drv2Let(p1));
_q++;
}
}
CatPrint(menu_ptr,"\n\rSelection:");
size=BMHD2_END-BMHD2_START;
FileWrite(BOOT_DIR_BOOTMHD2_BIN_C,BMHD2_START,size);
if (!FileFind(BOOT_DIR_BOOTMHD2_BIN_C,&de,FUF_JUST_FILES))
"No Boot Loader Image\n";
else {
Free(de.full_name);
*BMHD_BLK_CNT(U16 *)=(size+BLK_SIZE-1)>>BLK_SIZE_BITS;
*BMHD_DAP_BLK(I64 *)=Cluster2Blk(dv,de.cluster);
//Bypass partition bounds-checking
BlkDevLock(bd);
ATAReadBlks(bd,&mbr,0,1);
for (i=0;i<BMHD_END-BMHD_CODE;i++)
mbr.code[i]=BMHD_CODE(U8 *)[i];
#assert sizeof(CMasterBoot.code)>=BMHD_END-BMHD_CODE
for (;i<sizeof(CMasterBoot.code);i++)
mbr.code[i]=0;
if (!mbr.media_id)
mbr.media_id=RandU32;
mbr.zero=0;
mbr.signature=0xAA55;
ATAWriteBlks(bd,&mbr,0,1);
BlkDevUnlock(bd);
result=TRUE;
}
}
} catch
PutExcept;
return result;
}
+12 -9
View File
@@ -1,5 +1,8 @@
#define MODULE_SIZE 1*BLK_SIZE #define MODULE_SIZE 1*BLK_SIZE
#define BOOT_HIGH_LOC ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4) #define BOOT_HIGH_LOC_MHD ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4)
DefinePrint(
"DD_BOOT_HIGH_LOC_MHD","%08X",BOOT_HIGH_LOC_MHD<<4);
asm { asm {
USE16 USE16
@@ -7,7 +10,7 @@ BMHD_START::
BMHD_CODE:: BMHD_CODE::
CLD CLD
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_MHD
CLI CLI
MOV SS,AX MOV SS,AX
@@ -26,7 +29,7 @@ BMHD_CODE::
MOV ES,AX MOV ES,AX
MOV AX,VGA_TEXT_MEM_BASE/16 MOV AX,VGAM_TEXT/16
MOV FS,AX MOV FS,AX
MOV U32 FS:[0],'B'+GREEN<<12+('1'+GREEN<<12)<<16 MOV U32 FS:[0],'B'+GREEN<<12+('1'+GREEN<<12)<<16
CALL BMHD_GET_IP CALL BMHD_GET_IP
@@ -35,7 +38,7 @@ BMHD_GET_IP:
SUB BX,BMHD_GET_IP-BMHD_START SUB BX,BMHD_GET_IP-BMHD_START
MOV CX,BX MOV CX,BX
SHR BX,4 SHR BX,4
//Copy this bootloader code to just under 0x80000 //This copies this bootloader's code to 0x$TX,"00096C00",D="DD_BOOT_HIGH_LOC_MHD"$
MOV AX,CS MOV AX,CS
PUSH AX PUSH AX
ADD AX,BX ADD AX,BX
@@ -48,21 +51,21 @@ BMHD_GET_IP:
XOR DI,DI XOR DI,DI
REP_MOVSB REP_MOVSB
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_MHD
MOV DS,AX MOV DS,AX
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_HIGH_LOC:BMHD_HISTART DU8 0xEA; //JMP BOOT_HIGH_LOC_MHD:BMHD_HISTART
DU16 BMHD_HISTART-BMHD_START,BOOT_HIGH_LOC; DU16 BMHD_HISTART-BMHD_START,BOOT_HIGH_LOC_MHD;
BMHD_BIOS_DRV_NUM: DU8 0; BMHD_BIOS_DRV_NUM: DU8 0;
BMHD_OLD_CS_IP: DU16 0,0; BMHD_OLD_CS_IP: DU16 0,0;
//Gets patched by $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$(). //Gets patched by $LK,"MakeOSDrvBootInstall",A="MN:MakeOSDrvBootInstall"$().
BMHD_BLK_CNT:: DU16 0; BMHD_BLK_CNT:: DU16 0;
BMHD_DAP: DU8 16,0,1,0; //One blk at a time BMHD_DAP: DU8 16,0,1,0; //One blk at a time
BMHD_DAP_BUF: DU16 0,0; BMHD_DAP_BUF: DU16 0,0;
//Gets patched by $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$(). //Gets patched by $LK,"MakeOSDrvBootInstall",A="MN:MakeOSDrvBootInstall"$().
BMHD_DAP_BLK:: //64-bit BMHD_DAP_BLK:: //64-bit
BMHD_DAP_BLK_LO: DU32 0; BMHD_DAP_BLK_LO: DU32 0;
BMHD_DAP_BLK_HI: DU32 0; BMHD_DAP_BLK_HI: DU32 0;
+9 -6
View File
@@ -1,14 +1,17 @@
#define MODULE_SIZE 2*BLK_SIZE #define MODULE_SIZE 2*BLK_SIZE
#define BOOT_HIGH_LOC ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4) #define BOOT_HIGH_LOC_MHD2 ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MODULE_SIZE))>>4)
DefinePrint(
"DD_BOOT_HIGH_LOC_MHD2","%08X",BOOT_HIGH_LOC_MHD2<<4);
asm { asm {
USE16 USE16
BMHD2_START:: BMHD2_START::
MOV U32 FS:[0],'B'+0x2000+('2'+0x2000)<<16 MOV U32 FS:[0],'B'+0x2000+('2'+0x2000)<<16
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_MHD2
MOV ES,AX MOV ES,AX
//Copy this bootloader code to just under 0x80000 //This copies this bootloader's code to 0x$TX,"00096A00",D="DD_BOOT_HIGH_LOC_MHD2"$
MOV AX,CS MOV AX,CS
MOV DS,AX MOV DS,AX
MOV U32 [BMHD2_OLD_CS_IP-BMHD2_START],EBX MOV U32 [BMHD2_OLD_CS_IP-BMHD2_START],EBX
@@ -19,12 +22,12 @@ BMHD2_START::
XOR DI,DI XOR DI,DI
REP_MOVSB REP_MOVSB
MOV AX,BOOT_HIGH_LOC MOV AX,BOOT_HIGH_LOC_MHD2
MOV DS,AX MOV DS,AX
//My assembler doesn't support 16-bit very well. //My assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_HIGH_LOC:BMHD2_HISTART DU8 0xEA; //JMP BOOT_HIGH_LOC_MHD2:BMHD2_HISTART
DU16 BMHD2_HISTART-BMHD2_START,BOOT_HIGH_LOC; DU16 BMHD2_HISTART-BMHD2_START,BOOT_HIGH_LOC_MHD2;
BMHD2_BOOT_MSG:: BMHD2_BOOT_MSG::
DU8 256 DUP(0); DU8 256 DUP(0);
-346
View File
@@ -1,346 +0,0 @@
#help_index "Install"
//See $LK,"Install Documentation",A="FI:::/Doc/Install.TXT"$ or $LK,"Upgrading Documentation",A="FI:::/Doc/Upgrade.TXT"$.
//Kernel module: Kernel.BIN.Z
#define KERNEL_BIN_C "Kernel.BIN.C"
#define BOOT_DIR "/0000Boot"
#define BOOT_DIR_KERNEL_BIN_C BOOT_DIR "/0000" KERNEL_BIN_C
//Stage 2 of master boot loader
#define BOOTMHD2_BIN_C BOOT_DIR "/BootMHD2.BIN.C"
//Old master boot record
#define OLDMBR_BIN_C BOOT_DIR "/OldMBR.BIN.C"
if (IsDrvWritable)
MkDir("/Temp"); //Good to have a Temp
#include "BootCD"
#include "BootHD"
#include "BootMHD"
#include "BootMHD2"
#include "DskCDDVD"
#help_index "Call"
asm {
USE64
_HI_CALL::
PUSH RBP
MOV RBP,RSP
MOV RAX,U64 16[RBP]
TEST RAX,RAX
JZ @@05
CALL RAX
@@05: POP RBP
RET1 8
//************************************
_HI_MEMCPY::
PUSH RBP
MOV RBP,RSP
PUSH RSI
PUSH RDI
CLD
MOV RDI,U64 SF_ARG1[RBP]
MOV RSI,U64 SF_ARG2[RBP]
MOV RCX,U64 SF_ARG3[RBP]
REP_MOVSB
MOV RAX,RDI
POP RDI
POP RSI
POP RBP
RET1 24
}
_extern _HI_CALL I64 HiCall(U8 *s);
_extern _HI_MEMCPY U8 *HiMemCpy(U8 *dst,U8 *src,I64 cnt);
#help_index "Boot"
public U0 SoftBoot(U8 *filename)
{//Softboot Kernel Bin file. No hardware reset.
I64 size;
CKernel *hi_image,*lo_image=sys_boot_base-sizeof(CBinFile),
reg *shutdown,*hi_image2;
if (!(hi_image2=FileRead(filename,&size))) return;
shutdown=MAlloc(SYS_RESTART_KERNEL_END-SYS_RESTART_KERNEL,Fs->code_heap);
hi_image=MAlloc(size,Fs->code_heap);
HiMemCpy(hi_image,hi_image2,size);
Free(hi_image2);
hi_image->boot_base=lo_image(U8 *)+sizeof(CBinFile);
hi_image->boot_patch_table_base=lo_image(U8 *)+hi_image->h.patch_table_offset;
HiMemCpy(&hi_image->sys_mem_E801,&lo_image->sys_mem_E801,2*2);
HiMemCpy(&hi_image->sys_mem_E820,&lo_image->sys_mem_E820,MEM_NUM_E820_ENTRIES*MEM_E820_ENTRY_SIZE);
hi_image->sys_gr_mode=lo_image->sys_gr_mode;
hi_image->sys_pci_busses=lo_image->sys_pci_busses;
hi_image->boot_code=BOOT_CODE_RAM;
CLI
if (mp_cnt>1)
MPHalt;
HiMemCpy(shutdown,SYS_RESTART_KERNEL,SYS_RESTART_KERNEL_END-SYS_RESTART_KERNEL);
HiMemCpy(&hi_image->sys_gdt,&lo_image->sys_gdt,sizeof(CGDT));
HiMemCpy(lo_image,hi_image,size);
HiCall(shutdown);
}
#help_index "Install"
U8 ChkWritable(U8 drv_let=0)
{
Bool cont=TRUE;
I64 writable_drv=drv_let;
U8 buf_s[136],buf_d[136];
CPrt *p;
CBlkDev *bdev;
if (!IsDrvWritable(drv_let)) {
'' drv_let;
": Drive is read-only.\n";
do {
"Enter RAM drive (usually 'B') for temporary files:";
writable_drv=ToUpper(GetChar);
'\n';
p=Drv2Prt(writable_drv);
bdev=p->bdev;
if (bdev->type!=BDT_RAM ||
!IsDrvWritable(writable_drv))
"Not A RAM Drive\n";
else
cont=FALSE;
} while (cont);
if (drv_let!=writable_drv) {
Fmt(writable_drv,FALSE,FALSE);
StrPrint(buf_s,"%c:/",drv_let);
StrPrint(buf_d,"%c:/",writable_drv);
CopyTree(buf_s,buf_d);
}
}
return writable_drv;
}
#help_index "Install"
public U0 MakeAll()
{//Use $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$. Loader must be patched.
//These 2 modules (and bootloaders at top) are the only AOT
//compiled code in TempleOS. Everything else is JIT.
//You are doing it wrong if you make AOT compiled code.
Cd("/Compiler");
if (Cmp("Compiler","Compiler",,':'))
throw;
Cd("/Kernel");
if (Cmp("Kernel","Kernel",,':'))
throw;
}
public Bool MakeOSPrtBootInstall(U8 src_drv=0,U8 dst_drv=0)
{// Does $LK,"MakeAll",A="MN:MakeAll"$ and installs new boot-loader.
//Normally, you just supply a src_drv. It will compile
//the code on that drive and update the boot sect.
//If you are making a bootable CD-ROM, you supply a dst_drv.
//See $LK,"::/Misc/MakeDistro.CPP"$
//See $LK,"Install Documentation",A="FI:::/Doc/Install.TXT"$
//Study my account examples my technique: $LK,"Cfg Strs",A="FL:::/Demo/AcctExample/TSAdam.CPP,1"$ $LK,"Update Funs",A="FL:::/Demo/AcctExample/TSDistro.CPP,1"$
CBlkDev *bdev;
CPrt *p;
CFAT32Boot br;
CDirEntry de;
Bool result=FALSE;
I64 i;
try {
if (!src_drv) src_drv=Fs->cur_prt->drv_let;
if (!dst_drv) dst_drv=src_drv;
src_drv=ChkWritable(src_drv);
if (!Drv(src_drv))
throw;
MakeAll;
Cd("/");
bdev=Drv2BlkDev(dst_drv);
p =Drv2Prt (dst_drv);
switch (bdev->type) {
case BDT_ATAPI:
Move("/Kernel/Kernel.BIN.Z",BOOT_DIR_KERNEL_BIN_C);
result=TRUE;
break;
case BDT_RAM:
case BDT_ATA:
Move("/Kernel/Kernel.BIN.Z",KERNEL_BIN_C);
if (!FileFind(KERNEL_BIN_C,&de,FUF_JUST_FILES))
"No Kernel.BIN.C\n";
else {
Free(de.full_name);
"Modifying partition boot record.\n";
RBlks(p,&br,p->offset,1);
br.jump_and_nop[0]=OC_JMP_REL8;
br.jump_and_nop[1]=offset(CFAT32Boot.code)-2;
br.jump_and_nop[2]=OC_NOP;
*BHD_BLK_CNT(U16 *)=(de.size+BLK_SIZE-1)>>BLK_SIZE_BITS;
*BHD_DAP_BLK(I64 *)=p->data+de.cluster*p->spc;
for (i=0;i<BHD_END-BHD_CODE;i++)
br.code[i]=BHD_CODE(U8 *)[i];
for (;i<420;i++)
br.code[i]=0;
WBlks(p,&br,p->offset,1);
result=TRUE;
}
break;
}
} catch {
PutExcept;
Beep;
}
return result;
}
public U0 MasterBootOldRead(U8 src_drv,U8 dst_drv)
{//Reads MBR from disk drive containing src partition.
//Writes a single blk file to dst /0000Boot directory.
CBlkDev *bdev=Drv2BlkDev(src_drv);
CPrt *p;
CMasterBoot mbr;
Drv(dst_drv);
p=Fs->cur_prt;
if (p->type!=PT_REDSEA && p->type!=PT_FAT32)
PrintErr("Not RedSea Partition\n");
else {
//Bypass partition bounds-checking
BlkDevLock(bdev);
ATAReadBlks(bdev,&mbr,0,1);
BlkDevUnlock(bdev);
Drv(dst_drv);
MkDir(BOOT_DIR);
FileWrite(OLDMBR_BIN_C,&mbr,BLK_SIZE);
}
}
public U0 MasterBootOldWrite(U8 src_drv,U8 dst_drv)
{//Reads OldMBR from src drive /0000Boot directory
//writes it to the MBR of the drive with dst partition.
CBlkDev *bdev=Drv2BlkDev(dst_drv);
CMasterBoot *mbr;
Drv(src_drv);
if (mbr=FileRead(OLDMBR_BIN_C)) {
//Bypass partition bounds-checking
BlkDevLock(bdev);
ATAWriteBlks(bdev,mbr,0,1);
BlkDevUnlock(bdev);
}
Free(mbr);
}
public U0 MasterBootZero(U8 dst_drv)
{//Set MBR of disk with dst partition to zero.
//This is dangerous!!
//The TempleOS partitioner doesn't play well
//with other operating systems at this time and you need
//to do this on a drive partitioned by TempleOS
//if you wish to partition with another operating system.
CBlkDev *bdev=Drv2BlkDev(dst_drv);
CMasterBoot mbr;
MemSet(&mbr,0,BLK_SIZE);
//Bypass partition bounds-checking
BlkDevLock(bdev);
ATAWriteBlks(bdev,&mbr,0,1);
BlkDevUnlock(bdev);
}
public Bool MasterBootIntall(U8 drv_let,U8 *drv_lst=NULL)
{//Create new MBR on the disk that has drv_let as a partition.
//Puts stage 2 in /0000Boot dir of drv_let.
CBlkDev *bdev,*bdev1;
CPrt *p,*p1;
CMasterBoot mbr;
CDirEntry de;
I64 i,j,size,*_q;
U8 *menu_ptr,*ptr,ch,buf[128];
Bool result=FALSE;
try {
if (drv_lst)
StrCpy(buf,drv_lst);
else {
j=0;
for (i='A';i<='Z';i++)
buf[j++]=i;
buf[j++]=0;
}
Drv(drv_let);
p=Fs->cur_prt;
if (p->type!=PT_REDSEA && p->type!=PT_FAT32)
PrintErr("Not RedSea Partition\n");
else {
bdev=Drv2BlkDev(drv_let);
if (!FileFind(OLDMBR_BIN_C,,FUF_JUST_FILES))
MasterBootOldRead(drv_let,drv_let);
_q=BMHD2_BLK_ARRAY;
MemSet(_q,0,sizeof(I64)*8);
menu_ptr=BMHD2_BOOT_MSG;
StrPrint(menu_ptr,"\n\r\n\rTempleOS Boot Loader\n\r\n\r");
j=0;
if (FileFind(OLDMBR_BIN_C,&de,FUF_JUST_FILES)) {
Free(de.full_name);
*_q++=p->data+de.cluster*p->spc;
CatPrint(menu_ptr,"0. Old Boot Record\n\r");
j++;
}
ptr=buf;
while (ch=*ptr++) {
try {
p1 =Drv2Prt(ch);
bdev1=Drv2BlkDev(ch);
} catch {
Fs->catch_except=TRUE;
p1 =NULL;
bdev1=NULL;
}
if (p1 && bdev1==bdev) {
*_q=p1->offset;
"Drive %C:%16X\n",Prt2Drv(p1),*_q;
CatPrint(menu_ptr,"%d. Drive %C\n\r",j++,Prt2Drv(p1));
_q++;
}
}
CatPrint(menu_ptr,"\n\rSelection:");
size=BMHD2_END-BMHD2_START;
FileWrite(BOOTMHD2_BIN_C,BMHD2_START,size);
if (!FileFind(BOOTMHD2_BIN_C,&de,FUF_JUST_FILES))
"No Boot Loader Image\n";
else {
Free(de.full_name);
*BMHD_BLK_CNT(U16 *)=(size+BLK_SIZE-1)>>BLK_SIZE_BITS;
*BMHD_DAP_BLK(I64 *)=p->data+de.cluster*p->spc;
//Bypass partition bounds-checking
BlkDevLock(bdev);
ATAReadBlks(bdev,&mbr,0,1);
for (i=0;i<BMHD_END-BMHD_CODE;i++)
mbr.boot_code[i]=BMHD_CODE(U8 *)[i];
for (;i<440;i++)
mbr.boot_code[i]=0;
if (!mbr.media_id)
mbr.media_id=RandU32;
mbr.zero=0;
mbr.signature=0xAA55;
ATAWriteBlks(bdev,&mbr,0,1);
BlkDevUnlock(bdev);
result=TRUE;
}
}
} catch
PutExcept;
return result;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#help_index "Ctrls" #help_index "Ctrls"
#help_file "::/Doc/Ctrls" #help_file "::/Doc/Ctrls"
#include "Ctrls2a" #include "CtrlsA"
#include "CtrlsButton" #include "CtrlsButton"
#include "CtrlsSlider" #include "CtrlsSlider"
@@ -346,7 +346,7 @@ U0 LeftClickViewAngles(CCtrl *c,I64 x,I64 y,Bool)
} }
public CCtrl *ViewAnglesNew(CTask *task=NULL) public CCtrl *ViewAnglesNew(CTask *task=NULL)
{//Create view angle ctrl. See $LK,"::/Demo/Graphics/Shading.CPP.Z"$. {//Create view angle ctrl. See $LK,"::/Demo/Graphics/Shading.CPP"$.
Bool old_preempt; Bool old_preempt;
CCtrl *c; CCtrl *c;
CViewAngles *s; CViewAngles *s;
+1 -1
View File
@@ -40,7 +40,7 @@ U0 LeftClickCtrlButton(CCtrl *c,I64,I64,Bool down)
public CCtrl *CtrlButtonNew(I64 x,I64 y,I64 width=-1,I64 height=-1, public CCtrl *CtrlButtonNew(I64 x,I64 y,I64 width=-1,I64 height=-1,
I64 num_states=1,U8 *state_texts,I32 state_colors[],CCtrlButtonState *_s=NULL) I64 num_states=1,U8 *state_texts,I32 state_colors[],CCtrlButtonState *_s=NULL)
{//Create button ctrl. See $LK,"::/Apps/Strut/Strut.CPP.Z"$. {//Create button ctrl. See $LK,"::/Apps/Strut/Strut.CPP"$.
Bool old_preempt; Bool old_preempt;
CCtrl *result; CCtrl *result;
CCtrlButtonState *s; CCtrlButtonState *s;
+20 -20
View File
@@ -1,24 +1,24 @@
class CTemplateSCSlider class CTemplateCSSlider
{ {
CTemplateSCSlider *next,*last; CTemplateCSSlider *next,*last;
U8 *name; U8 *name;
I64 num; I64 num;
}; };
class CTemplateSC class CTemplateCS
{ {
CTemplateSCSlider *next_slider,*last_slider; CTemplateCSSlider *next_slider,*last_slider;
I64 num_sliders,range,spacing,border; I64 num_sliders,range,spacing,border;
U8 *glbl_name; U8 *glbl_name;
}; };
CTemplateSC *GetSliderCtrl() CTemplateCS *CtrlSliderGet()
{ {
CTemplateSCSlider *temps; CTemplateCSSlider *temps;
U8 *st,pmt[136]; U8 *st,pmt[136];
CTemplateSC *result=CAlloc(sizeof(CTemplateSC)); CTemplateCS *result=CAlloc(sizeof(CTemplateCS));
"$$PURPLE$$Slider Ctrl$$FG$$\n\n"; "$$PURPLE$$Ctrl Slider$$FG$$\n\n";
result->glbl_name=GetStr("Glbl Struct Name (ENTER for No Glbl):"); result->glbl_name=GetStr("Glbl Struct Name (ENTER for No Glbl):");
result->range=GetI64 ("Range (%4d):",30); result->range=GetI64 ("Range (%4d):",30);
@@ -33,7 +33,7 @@ CTemplateSC *GetSliderCtrl()
Free(st); Free(st);
break; break;
} }
temps=CAlloc(sizeof(CTemplateSCSlider)); temps=CAlloc(sizeof(CTemplateCSSlider));
temps->name=st; temps->name=st;
QueIns(temps,result->last_slider); QueIns(temps,result->last_slider);
temps->num=result->num_sliders++; temps->num=result->num_sliders++;
@@ -41,25 +41,25 @@ CTemplateSC *GetSliderCtrl()
return result; return result;
} }
U0 TemplateSliderCtrl(CDoc *doc) U0 TemplateCtrlSlider(CDoc *doc)
{ {
CTask *task; CTask *task;
CTemplateSC *m=NULL; CTemplateCS *m=NULL;
CTemplateSCSlider *temps; CTemplateCSSlider *temps;
I64 i; I64 i;
DocUnlock(doc); DocUnlock(doc);
DocRecalc(doc); DocRecalc(doc);
DocCaptureUndo(doc,TRUE); DocCaptureUndo(doc,TRUE);
task=SpawnUser("CTemplateSC **_m=0x%X;*_m=GetSliderCtrl;\n",&m); task=User("CTemplateCS **_m=0x%X;*_m=CtrlSliderGet;\n",&m);
while (!m) while (!m)
Yield; Yield;
DocPrint(doc, DocPrint(doc,
"#define SLIDER_RANGE %d "#define SLIDER_RANGE\t%d
#define SLIDER_SPACING %d #define SLIDER_SPACING\t%d
#define SLIDER_BORDER %d #define SLIDER_BORDER\t%d
class CSliderState class CSliderState
{ {
@@ -77,7 +77,7 @@ class CSliderState
DocPrint(doc, DocPrint(doc,
" "
U0 DrawSliderCtrl(CDC *dc,CCtrl *c) U0 DrawCtrlSlider(CDC *dc,CCtrl *c)
{ {
CSliderState *s=c->state; CSliderState *s=c->state;
@@ -124,7 +124,7 @@ U0 DrawSliderCtrl(CDC *dc,CCtrl *c)
DocPrint(doc, DocPrint(doc,
"} "}
U0 UpdateDerivedSliderCtrl(CCtrl *c) U0 UpdateDerivedCtrlSlider(CCtrl *c)
{ {
CSliderState *s=c->state; CSliderState *s=c->state;
c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2; c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2;
@@ -181,9 +181,9 @@ CCtrl *SliderNew()
else else
DocPrint(doc, " c->state=CAlloc(sizeof(CSliderState));\n"); DocPrint(doc, " c->state=CAlloc(sizeof(CSliderState));\n");
DocPrint(doc, DocPrint(doc,
" c->draw_it=&DrawSliderCtrl; " c->draw_it=&DrawCtrlSlider;
c->left_click=&LeftClickSlider; c->left_click=&LeftClickSlider;
c->update_derived_vals=&UpdateDerivedSliderCtrl; c->update_derived_vals=&UpdateDerivedCtrlSlider;
old_preempt=Preempt(OFF); old_preempt=Preempt(OFF);
QueIns(c,Fs->last_ctrl); QueIns(c,Fs->last_ctrl);
TaskDerivedValsUpdate; TaskDerivedValsUpdate;
-70
View File
@@ -1,70 +0,0 @@
#help_index "Define;Char/Define"
U0 LoadDocDefines()
{//These are used in documents such as $LK,"::/Doc/TrivialSolutions.TXT"$
//The $LK,"CDoc",A="MN:CDoc"$ framework will search the sym table for define string
//consts if you specify that.
CBinFile *bfh=sys_boot_base-sizeof(CBinFile);
DefinePrint(
"DD_KERNEL","%08X",bfh);
DefinePrint(
"DD_KERNEL2","%09,X",bfh);
bfh(I64)+=bfh->file_size-1;
DefinePrint(
"DD_KERNEL_END","%08X",bfh);
DefinePrint(
"DD_KERNEL_END2","%09,X",bfh);
DefinePrint(
"DD_PROTECTED_LOW","%08X",MEM_PROTECTED_LOW_LIMIT);
DefinePrint(
"DD_PROTECTED_LOW2","%09,X",MEM_PROTECTED_LOW_LIMIT);
//$LK,"DD_BOOT_HIGH_LOC",A="FF:::/Adam/Boot/BootCD.CPP,DD_BOOT_HIGH_LOC"$
DefinePrint(
"DD_MP_VECT","%08X",MP_VECT_ADDR);
DefinePrint(
"DD_MP_VECT_END","%08X",MP_VECT_ADDR+SYS_MP_INIT_END-SYS_MP_INIT_START-1);
DefinePrint(
"DD_OS_NAME_VERSION","TempleOS V%0.2f",os_version);
DefinePrint(
"DD_TEMPLEOS_AGE","%0.1f",(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
//This is cut and replaced when I generate a distro.
//See $LK,"DD_TEMPLEOS_LOC",A="FF:::/Demo/AcctExample/TSDistro.CPP,DD_TEMPLEOS_LOC"$.
$TR-C,"LineRep"$
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","121,504");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","81,303");
$ID,-4$
DefinePrint(
"DD_FIXED_AREA_BASE","%08X",SYS_FIXED_AREA);
DefinePrint(
"DD_FIXED_AREA_BASE2","%09,X",SYS_FIXED_AREA);
DefinePrint(
"DD_FIXED_AREA_END","%08X",SYS_FIXED_AREA+sizeof(CSysFixedArea)-1);
DefinePrint(
"DD_SYS_HEAP_BASE","%08X",sys_heap_base);
DefinePrint(
"DD_SYS_HEAP_BASE2","%09,X",sys_heap_base);
DefinePrint(
"DD_SYS_HEAP_LIMIT","%08X",sys_heap_limit);
DefinePrint(
"DD_SYS_HEAP_LIMIT2","%09,X",sys_heap_limit);
DefinePrint(
"DD_MAPPED_MEM_SPACE_GIG","%d Gig",MEM_MAPPED_SPACE/0x40000000);
DefinePrint(
"DD_MAPPED_MEM_SPACE_END","%010X",MEM_MAPPED_SPACE-1);
DefinePrint(
"DD_MAPPED_MEM_SPACE_END2","%014,X",MEM_MAPPED_SPACE-1);
DefinePrint(
"DD_JIFFY_HZ","%d Hz",JIFFY_FREQ);
}
LoadDocDefines;
+7 -4
View File
@@ -76,12 +76,15 @@ public class CDolDocGlbls
} doldoc; } doldoc;
MemSet(&doldoc,0,sizeof(CDolDocGlbls)); MemSet(&doldoc,0,sizeof(CDolDocGlbls));
#help_index "God"
#define BIBLE_FILENAME "::/Misc/Bible.TXT.Z"
#include "DocNew" #include "DocNew"
#include "DocPlain" #include "DocPlain"
#include "DocInit" #include "DocInit"
#include "DocHighlight" #include "DocHighlight"
#include "DocRecalc2a" #include "DocRecalcA"
#include "DocRecalc2b" #include "DocRecalcB"
sys_clipboard_doc=DocNew; sys_clipboard_doc=DocNew;
#include "DocFile" #include "DocFile"
#include "DocOpt" #include "DocOpt"
@@ -89,8 +92,8 @@ sys_clipboard_doc=DocNew;
#include "DocCtrlL" #include "DocCtrlL"
#include "DocMacro" #include "DocMacro"
#include "DocFind" #include "DocFind"
#include "DocEd2a" #include "DocEdA"
#include "DocEd2b" #include "DocEdB"
#include "DocCodeTools" #include "DocCodeTools"
#include "DocTree" #include "DocTree"
#include "DocMain" #include "DocMain"
+24 -37
View File
@@ -6,7 +6,7 @@
#define EF_REINDENT 0 #define EF_REINDENT 0
#define EF_CHK_COMPILE 1 #define EF_CHK_COMPILE 1
#define EF_RENUM_ASM 2 #define EF_RENUM_ASM 2
#define EF_SLIDER_CTRL 3 #define EF_CTRL_SLIDER 3
#define EF_CH_SC 4 #define EF_CH_SC 4
I64 PopUpEdFmt() I64 PopUpEdFmt()
@@ -16,7 +16,7 @@ I64 PopUpEdFmt()
DocPrint(doc,"$$LTBLUE$$$$MU,\"Check Compile\",LE=EF_CHK_COMPILE$$\n" DocPrint(doc,"$$LTBLUE$$$$MU,\"Check Compile\",LE=EF_CHK_COMPILE$$\n"
"$$MU,\"Reindent CPP.Z Fun\",LE=EF_REINDENT$$\n" "$$MU,\"Reindent CPP.Z Fun\",LE=EF_REINDENT$$\n"
"$$MU,\"Renum Asm Local @@ Labels for Fun\",LE=EF_RENUM_ASM$$\n" "$$MU,\"Renum Asm Local @@ Labels for Fun\",LE=EF_RENUM_ASM$$\n"
"$$MU,\"Insert Template Code: Slider Ctrl\",LE=EF_SLIDER_CTRL$$\n" "$$MU,\"Insert Template Code: Ctrl Slider\",LE=EF_CTRL_SLIDER$$\n"
"$$MU,\"Insert ASCII/Scan Code Hex Codes for key pressed\",LE=EF_CH_SC$$\n\n" "$$MU,\"Insert ASCII/Scan Code Hex Codes for key pressed\",LE=EF_CH_SC$$\n\n"
"$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n\n" "$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n\n"
"$$GREEN$$<ALT-BACKSPACE>$$FG$$ to undo if not happy\n" "$$GREEN$$<ALT-BACKSPACE>$$FG$$ to undo if not happy\n"
@@ -30,43 +30,32 @@ class CRILex
{ {
CLex *lx1,*lx2; CLex *lx1,*lx2;
CQueVectU8 *indent; CQueVectU8 *indent;
I64 depth,exp_depth; I64 depth,exp_depth,one_shot;
Bool was_new_line,is_not_cont,one_shot; Bool was_new_line,is_not_cont;
}; };
I64 EdRILex(CRILex *rx) I64 EdRILex(CRILex *rx)
{ {
Bool is_not_cont=FALSE; rx->is_not_cont=FALSE;
I64 i,k; I64 i;
do { do {
Lex(rx->lx1); Lex(rx->lx1);
Lex(rx->lx2); Lex(rx->lx2);
if (rx->lx1->token=='\n') {
if (rx->lx2->token==TK_IDENT)
i=PrsKeyWord(rx->lx2); i=PrsKeyWord(rx->lx2);
else if (rx->lx1->token=='\n' && rx->lx2->token==';' || rx->lx2->token=='{' ||
i=-1; rx->lx2->token=='}' || rx->lx2->token==':' || rx->lx2->token==')' &&
if (rx->lx2->token==';' || rx->lx2->token=='{' || rx->lx2->token=='}' || !rx->exp_depth || i==KW_ELSE || i==KW_CATCH || i==KW_DO)
rx->lx2->token==':' || rx->lx2->token==')' && !rx->exp_depth || rx->is_not_cont=TRUE;
i==KW_ELSE || i==KW_CATCH || i==KW_DO)
is_not_cont=TRUE;
}
k=PrsKeyWord(rx->lx2);
if (rx->was_new_line && (rx->lx1->token!=':' || if (rx->was_new_line && (rx->lx1->token!=':' ||
k==KW_DFT || k==KW_SUB_SWITCH_START || k==KW_SUB_SWITCH_END)) { i==KW_DFT || i==KW_SUB_SWITCH_START || i==KW_SUB_SWITCH_END)) {
if (rx->one_shot) { QueVectU8Put(rx->indent,rx->lx2->lfns[0].cur_entry->y,rx->depth+rx->one_shot);
QueVectU8Put(rx->indent,rx->lx2->lfns[0].cur_entry->y,rx->depth+3); rx->one_shot=0;
rx->one_shot=FALSE;
} else
QueVectU8Put(rx->indent,rx->lx2->lfns[0].cur_entry->y,rx->depth);
} }
if (rx->lx2->token=='\n') if (rx->lx2->token=='\n')
rx->was_new_line=TRUE; rx->was_new_line=TRUE;
else else
rx->was_new_line=FALSE; rx->was_new_line=FALSE;
} while (rx->lx1->token=='\n'); } while (rx->lx1->token=='\n');
rx->is_not_cont=is_not_cont;
return rx->lx1->token; return rx->lx1->token;
} }
@@ -182,16 +171,14 @@ U0 EdRIStmt(CRILex *rx,Bool indent)
default: default:
if (rx->lx1->token==TK_IDENT && rx->lx1->hash_entry && if (rx->lx1->token==TK_IDENT && rx->lx1->hash_entry &&
rx->lx1->hash_entry->type&(HTT_OPCODE|HTT_ASM_KEYWORD)) { rx->lx1->hash_entry->type&(HTT_OPCODE|HTT_ASM_KEYWORD)) {
i=rx->depth; rx->one_shot=4-rx->depth;
rx->depth=4;
rx->one_shot=FALSE;
do EdRILex(rx); do EdRILex(rx);
while (rx->lx2->token && rx->lx2->token!='\n'); while (rx->lx2->token && rx->lx2->token!='\n');
rx->depth=i; rx->is_not_cont=TRUE;
} else { } else {
while (rx->lx1->token && rx->lx1->token!=';' && rx->lx1->token!=':') { while (rx->lx1->token && rx->lx1->token!=';' && rx->lx1->token!=':') {
if (rx->lx2->token=='\n' && !rx->is_not_cont) if (rx->lx2->token=='\n' && !rx->is_not_cont)
rx->one_shot=TRUE; rx->one_shot=3;
EdRILex(rx); EdRILex(rx);
} }
if (rx->lx1->token==':') if (rx->lx1->token==':')
@@ -211,11 +198,11 @@ CQueVectU8 *EdRICode(CDoc *doc)
CRILex *rx=CAlloc(sizeof(CRILex)); CRILex *rx=CAlloc(sizeof(CRILex));
rx->lx1=LexNew(,LF_KEEP_NEW_LINES|LF_DONT_FREE_BUF,doc->filename.name); rx->lx1=LexNew(,LF_KEEP_NEW_LINES|LF_DONT_FREE_BUF,doc->filename.name);
Free(rx->lx1->lfns[0].name); Free(rx->lx1->lfns[0].full_name);
LexAttachDoc(rx->lx1,&rx->lx1->lfns[0],doc,,doc->cur_entry,doc->cur_data_col); LexAttachDoc(rx->lx1,&rx->lx1->lfns[0],doc,,doc->cur_entry,doc->cur_data_col);
rx->lx2=LexNew(,LF_KEEP_NEW_LINES|LF_DONT_FREE_BUF,doc->filename.name); rx->lx2=LexNew(,LF_KEEP_NEW_LINES|LF_DONT_FREE_BUF,doc->filename.name);
Free(rx->lx2->lfns[0].name); Free(rx->lx2->lfns[0].full_name);
LexAttachDoc(rx->lx2,&rx->lx2->lfns[0],doc,,doc->cur_entry,doc->cur_data_col); LexAttachDoc(rx->lx2,&rx->lx2->lfns[0],doc,,doc->cur_entry,doc->cur_data_col);
rx->indent=QueVectU8New(doc->cur_entry->y); rx->indent=QueVectU8New(doc->cur_entry->y);
@@ -400,16 +387,16 @@ U0 EdCodeTools2(CDoc *doc,I64 tool_action)
if (doc->flags&DOCF_PLAIN_TEXT) if (doc->flags&DOCF_PLAIN_TEXT)
DocFlagsToggle(doc,DOCF_PLAIN_TEXT); DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
DocWrite(doc); DocWrite(doc);
task=Spawn(&SrvUserCmdLine,NULL,"Srv",,Fs); task=Spawn(&SrvCmdLine,NULL,"Srv",,Fs);
st2=CurDir; st2=CurDir;
st=MStrPrint("Cd(\"%s\");",st2); st=MStrPrint("Cd(\"%s\");",st2);
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
Free(st2); Free(st2);
Free(st); Free(st);
SetWinHorz(Fs->win_left,Fs->win_right, task); WinHorz(Fs->win_left,Fs->win_right, task);
SetWinVert(Fs->win_top, Fs->win_bottom,task); WinVert(Fs->win_top, Fs->win_bottom,task);
if (ScanResult(tempc,&r)) { if (ScanResult(tempc,&r)) {
st=DirFile(doc->filename.name,,"PRJ.Z"), st=DirFile(doc->filename.name,,"PRJ.Z");
prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z); prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
Free(st); Free(st);
if (FileFind(prj_file)) { if (FileFind(prj_file)) {
@@ -597,8 +584,8 @@ U0 EdCodeTools(CDoc *doc)
case EF_RENUM_ASM: case EF_RENUM_ASM:
EdCodeTools2(doc,tool_action); EdCodeTools2(doc,tool_action);
break; break;
case EF_SLIDER_CTRL: case EF_CTRL_SLIDER:
TemplateSliderCtrl(doc); TemplateCtrlSlider(doc);
break; break;
case EF_CH_SC: case EF_CH_SC:
EdChSC(doc); EdChSC(doc);
+21 -21
View File
@@ -1005,13 +1005,13 @@ U0 EdInsDollarCmd()
} }
} }
#define PT_SPRITE 0 #define DVT_SPRITE 0
#define PT_SPRITE_PTR 1 #define DVT_SPRITE_PTR 1
#define PT_DUP_SPRITE 2 #define DVT_DUP_SPRITE 2
#define PT_SPRITE_SIZE 3 #define DVT_SPRITE_SIZE 3
#define PT_SPRITE_MACRO 4 #define DVT_SPRITE_MACRO 4
#define PT_SPRITE_MENU 5 #define DVT_SPRITE_MENU 5
#define PT_SPRITE_LINK 6 #define DVT_SPRITE_LINK 6
I64 PopUpSpriteType() I64 PopUpSpriteType()
{ {
@@ -1019,13 +1019,13 @@ I64 PopUpSpriteType()
CDoc *doc=DocNew; CDoc *doc=DocNew;
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Graphic Resource Menu\"$$\n" DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Graphic Resource Menu\"$$\n"
"$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/Resource.TXT.Z\"$$\n" "$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/Resource.TXT.Z\"$$\n"
"\n$$LTBLUE$$$$MU,\"Make Sprite\",LE=PT_SPRITE$$\n" "\n$$LTBLUE$$$$MU,\"Make Sprite\",LE=DVT_SPRITE$$\n"
"$$MU,\"Pointer to Sprite\",LE=PT_SPRITE_PTR$$\n" "$$MU,\"Pointer to Sprite\",LE=DVT_SPRITE_PTR$$\n"
"$$MU,\"Duplicate Sprite\",LE=PT_DUP_SPRITE$$\n" "$$MU,\"Duplicate Sprite\",LE=DVT_DUP_SPRITE$$\n"
"$$MU,\"Sprite Size (not really needed)\",LE=PT_SPRITE_SIZE$$\n" "$$MU,\"Sprite Size (not really needed)\",LE=DVT_SPRITE_SIZE$$\n"
"$$MU,\"Sprite Macro (Icon)\",LE=PT_SPRITE_MACRO$$\n" "$$MU,\"Sprite Macro (Icon)\",LE=DVT_SPRITE_MACRO$$\n"
"$$MU,\"Sprite Menu Item\",LE=PT_SPRITE_MENU$$\n" "$$MU,\"Sprite Menu Item\",LE=DVT_SPRITE_MENU$$\n"
"$$MU,\"Sprite Link\",LE=PT_SPRITE_LINK$$\n" "$$MU,\"Sprite Link\",LE=DVT_SPRITE_LINK$$\n"
"\n$$MU,\"Abort\",LE=DOCM_CANCEL$$\n\n"); "\n$$MU,\"Abort\",LE=DOCM_CANCEL$$\n\n");
i=PopUpMenu(doc); i=PopUpMenu(doc);
DocDel(doc); DocDel(doc);
@@ -1074,12 +1074,12 @@ U8 *EdSprite(I64 bin_num)
CEdMacroSprite *e=CAlloc(sizeof(CEdMacroSprite)); CEdMacroSprite *e=CAlloc(sizeof(CEdMacroSprite));
*buf=0; *buf=0;
switch (type) { switch (type) {
case PT_SPRITE: case DVT_SPRITE:
StrPrint(e->tag,"<%d>",bin_num); StrPrint(e->tag,"<%d>",bin_num);
if (DocFormDo(e,"CEdJustSprite",,,ctrl_L_footer)) if (DocFormDo(e,"CEdJustSprite",,,ctrl_L_footer))
st1=MStrPrint("\"%Q\"",e->tag); st1=MStrPrint("\"%Q\"",e->tag);
break; break;
case PT_SPRITE_MACRO: case DVT_SPRITE_MACRO:
e->escape=TRUE; e->escape=TRUE;
if (DocFormDo(e,,,,ctrl_L_footer)) { if (DocFormDo(e,,,,ctrl_L_footer)) {
CatPrint(buf,"+UL"); CatPrint(buf,"+UL");
@@ -1091,26 +1091,26 @@ U8 *EdSprite(I64 bin_num)
Free(st); Free(st);
} }
break; break;
case PT_SPRITE_MENU: case DVT_SPRITE_MENU:
e->escape=TRUE; e->escape=TRUE;
if (DocFormDo(e,"CEdMenuSprite",,,ctrl_L_footer)) { if (DocFormDo(e,"CEdMenuSprite",,,ctrl_L_footer)) {
if (e->escape) CatPrint(buf,"+X"); if (e->escape) CatPrint(buf,"+X");
st1=MStrPrint("\"%Q\",LE=%s",e->tag,e->exp); st1=MStrPrint("\"%Q\",LE=%s",e->tag,e->exp);
} }
break; break;
case PT_SPRITE_LINK: case DVT_SPRITE_LINK:
CatPrint(buf,"+L"); CatPrint(buf,"+L");
st1=EdSpriteLink(&pop_up,&html_link); st1=EdSpriteLink(&pop_up,&html_link);
if (pop_up) if (pop_up)
CatPrint(buf,"+PU"); CatPrint(buf,"+PU");
break; break;
case PT_SPRITE_PTR: case DVT_SPRITE_PTR:
EdInsBinary(--bin_num,DOCT_INS_BINARY); EdInsBinary(--bin_num,DOCT_INS_BINARY);
break; break;
case PT_SPRITE_SIZE: case DVT_SPRITE_SIZE:
EdInsBinary(--bin_num,DOCT_INS_BINARY_SIZE); EdInsBinary(--bin_num,DOCT_INS_BINARY_SIZE);
break; break;
case PT_DUP_SPRITE: case DVT_DUP_SPRITE:
EdInsBinary(--bin_num,DOCT_SPRITE); EdInsBinary(--bin_num,DOCT_SPRITE);
break; break;
} }
@@ -224,7 +224,8 @@ public U0 EdLineUp(CDoc *doc,I64 sc=MIN_I64)
doc_ce=doc_ce->next; doc_ce=doc_ce->next;
if (doc->flags & DOCF_FORM) { if (doc->flags & DOCF_FORM) {
while (doc_ce->next->x==x && while (doc_ce->next->x==x &&
(!Bt(doldoc.type_flags_form,doc_ce->type_u8) || (!Bt(doldoc.type_flags_form,doc_ce->type_u8) &&
!(doc_ce->de_flags&DOCEF_LINK)||
doc_ce->de_flags&DOCEF_SKIP_IN_FORM)) doc_ce->de_flags&DOCEF_SKIP_IN_FORM))
doc_ce=doc_ce->next; doc_ce=doc_ce->next;
} }
@@ -566,7 +567,8 @@ ic_overstrike_char:
DocInsEntry(doc,doc_ne); DocInsEntry(doc,doc_ne);
} else if (ch=='\t') { } else if (ch=='\t') {
if (doc->flags&DOCF_FORM && if (doc->flags&DOCF_FORM &&
Bt(doldoc.type_flags_form,doc->cur_entry->type_u8) && (Bt(doldoc.type_flags_form,doc->cur_entry->type_u8) ||
doc->cur_entry->de_flags&DOCEF_LINK) &&
!(doc->cur_entry->de_flags&DOCEF_SKIP_IN_FORM)) { !(doc->cur_entry->de_flags&DOCEF_SKIP_IN_FORM)) {
ic_form_tab: ic_form_tab:
doc->cur_entry=doc->cur_entry->next; doc->cur_entry=doc->cur_entry->next;
@@ -652,12 +654,16 @@ U0 DocEntryToggle(CDoc *doc)
U8 ch,*st,*st2; U8 ch,*st,*st2;
I64 i,j,k; I64 i,j,k;
if (doc_ce!=doc && !(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) { if (doc_ce!=doc && !(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
if (doc_ce->type_u8==DOCT_TEXT && !(doc_ce->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP))) { if (doc_ce->type_u8==DOCT_TEXT &&
!(doc_ce->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP)) &&
!(doc_ce->type&DOCG_BL_IV_UL)) {
doc_ce2=doc_ce->last; doc_ce2=doc_ce->last;
for (k=0;k<20;k++) { for (k=0;k<20;k++) {
if (doc_ce2!=doc) { if (doc_ce2!=doc) {
cl1=doc_ce2->last; cl1=doc_ce2->last;
if (doc_ce2->type_u8==DOCT_TEXT && doc_ce->de_flags==doc_ce2->de_flags && doc_ce->type==doc_ce2->type) { if (doc_ce2->type_u8==DOCT_TEXT &&
doc_ce->de_flags==doc_ce2->de_flags &&
doc_ce->type==doc_ce2->type) {
i=StrLen(doc_ce2->tag); i=StrLen(doc_ce2->tag);
j=StrLen(doc_ce->tag); j=StrLen(doc_ce->tag);
st=MAlloc(i+j+1,doc->mem_task); st=MAlloc(i+j+1,doc->mem_task);
@@ -680,7 +686,9 @@ U0 DocEntryToggle(CDoc *doc)
for (k=0;k<20;k++) { for (k=0;k<20;k++) {
if (doc_ce2!=doc) { if (doc_ce2!=doc) {
cl1=doc_ce2->next; cl1=doc_ce2->next;
if (doc_ce2->type_u8==DOCT_TEXT && doc_ce->de_flags==doc_ce2->de_flags && doc_ce->type==doc_ce2->type) { if (doc_ce2->type_u8==DOCT_TEXT &&
doc_ce->de_flags==doc_ce2->de_flags &&
doc_ce->type==doc_ce2->type) {
i=StrLen(doc_ce->tag); i=StrLen(doc_ce->tag);
j=StrLen(doc_ce2->tag); j=StrLen(doc_ce2->tag);
st=MAlloc(i+j+1,doc->mem_task); st=MAlloc(i+j+1,doc->mem_task);
@@ -704,7 +712,8 @@ U0 DocEntryToggle(CDoc *doc)
j=doc->cur_data_col+1; j=doc->cur_data_col+1;
while (j<doc_ce->max_col && doc_ce->tag[j]!='$$') while (j<doc_ce->max_col && doc_ce->tag[j]!='$$')
j++; j++;
if (i<j-1 && doc_ce->min_col<=i<j<doc_ce->max_col && doc_ce->tag[i]=='$$' && doc_ce->tag[j]=='$$') { if (i<j-1 && doc_ce->min_col<=i<j<doc_ce->max_col &&
doc_ce->tag[i]=='$$' && doc_ce->tag[j]=='$$') {
ch=doc_ce->tag[j+1]; ch=doc_ce->tag[j+1];
doc_ce->tag[j+1]=0; doc_ce->tag[j+1]=0;
st=StrNew(doc_ce->tag+i); st=StrNew(doc_ce->tag+i);
@@ -20,7 +20,7 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
!(sc&(SCF_CTRL|SCF_ALT))) { !(sc&(SCF_CTRL|SCF_ALT))) {
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
st=Char2KeyName(ch,FALSE); st=Char2KeyName(ch,FALSE);
SetKeyDesc("Char/'%s'",st); KeyDescSet("Char/'%s'",st);
Free(st); Free(st);
} else } else
EdInsChar(ch,sc,doc); EdInsChar(ch,sc,doc);
@@ -31,25 +31,25 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
switch (ch) { switch (ch) {
case CH_CTRLA: case CH_CTRLA:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Save As"); KeyDescSet("Edit/Save As");
else else
DocWrite(doc,TRUE); DocWrite(doc,TRUE);
break; break;
case CH_CTRLB: case CH_CTRLB:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Toggle Border"); KeyDescSet("Win/Toggle Border");
else else
WinBorder(Bt(&doc->win_task->display_flags,DISPLAYf_NO_BORDER),doc->win_task); WinBorder(Bt(&doc->win_task->display_flags,DISPLAYf_NO_BORDER),doc->win_task);
break; break;
case CH_CTRLC: case CH_CTRLC:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Copy to Clipboard"); KeyDescSet("Edit/Copy to Clipboard");
else else
EdCopyToClipboard(doc); EdCopyToClipboard(doc);
break; break;
case CH_CTRLD: case CH_CTRLD:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Cmd/Jump to File Manager"); KeyDescSet("Cmd/Jump to File Manager");
else { else {
DocUnlock(doc); DocUnlock(doc);
FileMgr; FileMgr;
@@ -59,31 +59,31 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLF: case CH_CTRLF:
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Cmd/Grep Wizard"); KeyDescSet("Cmd/Find Wizard");
else else
GrepWiz; GrepWiz;
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Find & Replace"); KeyDescSet("Edit/Find & Replace");
else else
EdFindReplace(doc); EdFindReplace(doc);
} }
break; break;
case CH_CTRLG: case CH_CTRLG:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/GoTo Line Num"); KeyDescSet("Edit/GoTo Line Num");
else else
EdGoToLine(doc); EdGoToLine(doc);
break; break;
case CH_BACKSPACE: //<CTRL-H> case CH_BACKSPACE: //<CTRL-H>
if (sc&SCF_ALT && !(sc&SCF_CTRL)) { if (sc&SCF_ALT && !(sc&SCF_CTRL)) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Undo"); KeyDescSet("Edit/Undo");
else else
DocUndoRestore(doc); DocUndoRestore(doc);
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Char/Back Space"); KeyDescSet("Char/Back Space");
else { else {
DocCaptureUndo(doc); DocCaptureUndo(doc);
doc_ce=doc->cur_entry; doc_ce=doc->cur_entry;
@@ -110,12 +110,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLI: case CH_CTRLI:
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Indent Out"); KeyDescSet("Dollar/Indent Out");
else else
DocPrint(doc,"$$ID,-2$$"); DocPrint(doc,"$$ID,-2$$");
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Indent In"); KeyDescSet("Dollar/Indent In");
else else
DocPrint(doc,"$$ID,2$$"); DocPrint(doc,"$$ID,2$$");
} }
@@ -123,15 +123,15 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case '\n': case '\n':
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Char/Return"); KeyDescSet("Char/Return");
else else
SetKeyDesc("Char/Page Break"); KeyDescSet("Char/Page Break");
} else } else
EdInsChar(ch,sc,doc); EdInsChar(ch,sc,doc);
break; break;
case CH_CTRLK: case CH_CTRLK:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Blinking Text"); KeyDescSet("Dollar/Toggle Blinking Text");
else if (sc&SCF_SHIFT) else if (sc&SCF_SHIFT)
DocPrint(doc,"$$BK,0$$"); DocPrint(doc,"$$BK,0$$");
else else
@@ -140,9 +140,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLL: case CH_CTRLL:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Code Tools"); KeyDescSet("Edit/Code Tools");
else else
SetKeyDesc("Dollar/Wizard"); KeyDescSet("Dollar/Wizard");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
EdCodeTools(doc); EdCodeTools(doc);
@@ -156,14 +156,14 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLM: case CH_CTRLM:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Cmd/Jump to Notes File"); KeyDescSet("Cmd/Jump to Notes File");
else else
SetKeyDesc("Cmd/Jump to Menu"); KeyDescSet("Cmd/Jump to Menu");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
Ed("HOME/PersonalNotes.TXT.Z"); Ed("::/Home/PersonalNotes.TXT.Z");
else { else {
m=DocRead("HOME/PersonalMenu.TXT.Z"); m=DocRead("::/Home/PersonalMenu.TXT.Z");
DocMenuDo(m); DocMenuDo(m);
DocDel(m); DocDel(m);
} }
@@ -172,9 +172,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLO: case CH_CTRLO:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Collapse"); KeyDescSet("Edit/Collapse");
else else
SetKeyDesc("Edit/Uncolapse"); KeyDescSet("Edit/Uncolapse");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
DocCollapse(TRUE,doc); DocCollapse(TRUE,doc);
@@ -185,21 +185,21 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLP: case CH_CTRLP:
if (doc->flags & (DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE)) { if (doc->flags & (DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE)) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Super or Sub script"); KeyDescSet("Dollar/Toggle Super or Sub script");
else { else {
DocPrint(doc,"$$SY,0$$"); DocPrint(doc,"$$SY,0$$");
doc->flags&=~(DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE); doc->flags&=~(DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE);
} }
} else if (sc&SCF_SHIFT) { } else if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Subscript"); KeyDescSet("Dollar/Toggle Subscript");
else { else {
DocPrint(doc,"$$SY,3$$"); DocPrint(doc,"$$SY,3$$");
doc->flags|=DOCF_SUBSCRIPT_MODE; doc->flags|=DOCF_SUBSCRIPT_MODE;
} }
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Superscript"); KeyDescSet("Dollar/Toggle Superscript");
else { else {
DocPrint(doc,"$$SY,-3$$"); DocPrint(doc,"$$SY,-3$$");
doc->flags|=DOCF_SUPERSCRIPT_MODE; doc->flags|=DOCF_SUPERSCRIPT_MODE;
@@ -210,7 +210,7 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
break; break;
case CH_CTRLR: case CH_CTRLR:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Edit or Create Graphic"); KeyDescSet("Dollar/Edit or Create Graphic");
else { else {
if (!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) { if (!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
DocUnlock(doc); DocUnlock(doc);
@@ -229,12 +229,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLS: case CH_CTRLS:
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Find Misspelled"); KeyDescSet("Edit/Find Misspelled");
else else
WSFindMisspelled(doc); ACFindMisspelled(doc);
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Save"); KeyDescSet("Edit/Save");
else else
DocWrite(doc); DocWrite(doc);
} }
@@ -242,12 +242,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case CH_CTRLT: case CH_CTRLT:
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Single Entry Toggle Plain Text"); KeyDescSet("Edit/Single Entry Toggle Plain Text");
else else
DocEntryToggle(doc); DocEntryToggle(doc);
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Toggle Plain Text Display"); KeyDescSet("Edit/Toggle Plain Text Display");
else else
if (!(doc->flags&DOCF_FORM) || doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS)) if (!(doc->flags&DOCF_FORM) || doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))
DocFlagsToggle(doc,DOCF_PLAIN_TEXT); DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
@@ -255,7 +255,7 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
break; break;
case CH_CTRLU: case CH_CTRLU:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Underline"); KeyDescSet("Dollar/Toggle Underline");
else if (sc&SCF_SHIFT) else if (sc&SCF_SHIFT)
DocPrint(doc,"$$UL,0$$"); DocPrint(doc,"$$UL,0$$");
else else
@@ -263,13 +263,13 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
break; break;
case CH_CTRLV: case CH_CTRLV:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Paste Clipboard"); KeyDescSet("Edit/Paste Clipboard");
else else
EdPasteClipboard(doc); EdPasteClipboard(doc);
break; break;
case CH_CTRLW: case CH_CTRLW:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Word Wrap"); KeyDescSet("Dollar/Toggle Word Wrap");
else if (sc&SCF_SHIFT) else if (sc&SCF_SHIFT)
DocPrint(doc,"$$WW,0$$"); DocPrint(doc,"$$WW,0$$");
else else
@@ -277,19 +277,19 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
break; break;
case CH_CTRLX: case CH_CTRLX:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Cut To Clipboard"); KeyDescSet("Edit/Cut To Clipboard");
else else
EdCutToClipboard(doc); EdCutToClipboard(doc);
break; break;
case CH_CTRLY: case CH_CTRLY:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Delete Line"); KeyDescSet("Edit/Delete Line");
else else
EdDelLine(doc); EdDelLine(doc);
break; break;
case CH_CTRLZ: case CH_CTRLZ:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Dollar/Toggle Inverted Text"); KeyDescSet("Dollar/Toggle Inverted Text");
else if (sc&SCF_SHIFT) else if (sc&SCF_SHIFT)
DocPrint(doc,"$$IV,0$$"); DocPrint(doc,"$$IV,0$$");
else else
@@ -300,23 +300,23 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (sc&SCF_CTRL) { if (sc&SCF_CTRL) {
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Jump to Word Definition"); KeyDescSet("Edit/Jump to Word Definition");
else else
SetKeyDesc("Edit/Autocomplete Word"); KeyDescSet("Edit/Autocomplete Word");
} else { } else {
if (WordStat(ON)) { if (AutoComplete(ON)) {
DocUnlock(doc); DocUnlock(doc);
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
WSDDef(ch-'0',Fs); ACDDef(ch-'0',Fs);
else else
WSDFillin(ch-'0'); ACDFillin(ch-'0');
DocLock(doc); DocLock(doc);
} }
} }
} }
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Enter extended-ASCII"); KeyDescSet("Edit/Enter extended-ASCII");
else { else {
if (++doc->ext_ascii_cnt==1) if (++doc->ext_ascii_cnt==1)
doc->ext_ascii_val=ch-'0'; doc->ext_ascii_val=ch-'0';
@@ -333,12 +333,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (!(sc&SCF_ALT) && sc&SCF_CTRL) { if (!(sc&SCF_ALT) && sc&SCF_CTRL) {
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/GoTo matching brace"); KeyDescSet("Edit/GoTo matching brace");
else else
EdFindPaired(doc,'}','{',FALSE); EdFindPaired(doc,'}','{',FALSE);
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/GoTo matching bracket"); KeyDescSet("Edit/GoTo matching bracket");
else else
EdFindPaired(doc,']','[',FALSE); EdFindPaired(doc,']','[',FALSE);
} }
@@ -348,12 +348,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (!(sc&SCF_ALT) && sc&SCF_CTRL) { if (!(sc&SCF_ALT) && sc&SCF_CTRL) {
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/GoTo matching brace"); KeyDescSet("Edit/GoTo matching brace");
else else
EdFindPaired(doc,'{','}',TRUE); EdFindPaired(doc,'{','}',TRUE);
} else { } else {
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/GoTo matching bracket"); KeyDescSet("Edit/GoTo matching bracket");
else else
EdFindPaired(doc,'[',']',TRUE); EdFindPaired(doc,'[',']',TRUE);
} }
@@ -366,16 +366,16 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (sc&SCF_CTRL) { if (sc&SCF_CTRL) {
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Jump to Src of Sym"); KeyDescSet("Edit/Jump to Src of Sym");
else else
SetKeyDesc("Edit/Autocomplete Sym"); KeyDescSet("Edit/Autocomplete Sym");
} else { } else {
DocUnlock(doc); DocUnlock(doc);
if (WordStat(ON)) { if (AutoComplete(ON)) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
WSMan(sc2-SC_F1+1,Fs); ACMan(sc2-SC_F1+1,Fs);
else else
WSFillIn(sc2-SC_F1+1); ACFillIn(sc2-SC_F1+1);
} }
DocLock(doc); DocLock(doc);
} }
@@ -384,12 +384,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F1: case SC_F1:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("About"); KeyDescSet("About");
else else
SetKeyDesc("Help"); KeyDescSet("Help");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
Ed("::/Doc/Splash.TXT.Z"); Ed("::/Doc/AboutTempleOS.TXT.Z");
else else
Ed("::/Doc/HelpIndex.TXT.Z"); Ed("::/Doc/HelpIndex.TXT.Z");
} }
@@ -397,9 +397,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F2: case SC_F2:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Play Macro"); KeyDescSet("Edit/Play Macro");
else else
SetKeyDesc("Edit/Macro"); KeyDescSet("Edit/Macro");
} else { } else {
DocUnlock(doc); DocUnlock(doc);
if (sc&SCF_SHIFT) { if (sc&SCF_SHIFT) {
@@ -415,9 +415,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F3: case SC_F3:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Find Last"); KeyDescSet("Edit/Find Last");
else else
SetKeyDesc("Edit/Find Next"); KeyDescSet("Edit/Find Next");
}else { }else {
doc->find_replace->scan_fwd=!(sc&SCF_SHIFT); doc->find_replace->scan_fwd=!(sc&SCF_SHIFT);
EdFindNext(doc); EdFindNext(doc);
@@ -426,9 +426,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F4: case SC_F4:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Misc/Insert Directory Name"); KeyDescSet("Misc/Insert Directory Name");
else else
SetKeyDesc("Misc/Insert FileName"); KeyDescSet("Misc/Insert FileName");
} else { } else {
DocUnlock(doc); DocUnlock(doc);
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
@@ -445,9 +445,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F5: case SC_F5:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Cmd/Adam Include"); KeyDescSet("Cmd/Adam Include");
else else
SetKeyDesc("Cmd/Run (Execute);Dbg/Go"); KeyDescSet("Cmd/Run (Execute);Dbg/Go");
} else { } else {
if (st2=DocEntryLink(doc,doc_ce)) { if (st2=DocEntryLink(doc,doc_ce)) {
st=DocLinkFile(st2); st=DocLinkFile(st2);
@@ -475,9 +475,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F6: case SC_F6:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("God Doodle"); KeyDescSet("God Doodle");
else else
SetKeyDesc("God Song"); KeyDescSet("God Song");
} else { } else {
//$LK,"::/Adam/God/HSNotes.TXT"$ //$LK,"::/Adam/God/HSNotes.TXT"$
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
@@ -489,9 +489,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_F7: case SC_F7:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("God Passage"); KeyDescSet("God Passage");
else else
SetKeyDesc("God Word"); KeyDescSet("God Word");
} else { } else {
//$LK,"::/Adam/God/HSNotes.TXT"$ //$LK,"::/Adam/God/HSNotes.TXT"$
FifoU8Flush(god.fifo); FifoU8Flush(god.fifo);
@@ -511,9 +511,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (sc2==SC_END || sc&SCF_CTRL) { if (sc2==SC_END || sc&SCF_CTRL) {
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/GoTo Doc End, Select"); KeyDescSet("Edit/GoTo Doc End, Select");
else else
SetKeyDesc("Edit/GoTo Doc End"); KeyDescSet("Edit/GoTo Doc End");
} else { } else {
while (doc_ce!=doc) { while (doc_ce!=doc) {
BEqu(&doc_ce->type,DOCEt_SELECTED,sc&SCF_SHIFT); BEqu(&doc_ce->type,DOCEt_SELECTED,sc&SCF_SHIFT);
@@ -524,9 +524,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
} }
} else if (sc&SCF_KEY_DESC) { } else if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Cursor Down, Select"); KeyDescSet("Edit/Cursor Down, Select");
else else
SetKeyDesc("Edit/Cursor Down"); KeyDescSet("Edit/Cursor Down");
} else } else
EdLineDown(doc,sc); EdLineDown(doc,sc);
break; break;
@@ -535,9 +535,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
if (sc2==SC_HOME || sc&SCF_CTRL) { if (sc2==SC_HOME || sc&SCF_CTRL) {
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/GoTo Top of Doc, Select"); KeyDescSet("Edit/GoTo Top of Doc, Select");
else else
SetKeyDesc("Edit/GoTo Top of Doc"); KeyDescSet("Edit/GoTo Top of Doc");
} else { } else {
if (doc_ce==doc) doc_ce=doc_ce->last; if (doc_ce==doc) doc_ce=doc_ce->last;
while (doc_ce!=doc) { while (doc_ce!=doc) {
@@ -550,18 +550,18 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
} }
} else if (sc&SCF_KEY_DESC) { } else if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Cursor Up, Select"); KeyDescSet("Edit/Cursor Up, Select");
else else
SetKeyDesc("Edit/Cursor Up"); KeyDescSet("Edit/Cursor Up");
} else } else
EdLineUp(doc,sc); EdLineUp(doc,sc);
break; break;
case SC_PAGE_DOWN: case SC_PAGE_DOWN:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Page Down, Select"); KeyDescSet("Edit/Page Down, Select");
else else
SetKeyDesc("Edit/Page Down"); KeyDescSet("Edit/Page Down");
} else { } else {
i=doc_ce->y+doc->win_task->win_height-1; i=doc_ce->y+doc->win_task->win_height-1;
if (doc_ce->type_u8==DOCT_HEX_ED) if (doc_ce->type_u8==DOCT_HEX_ED)
@@ -580,9 +580,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_PAGE_UP: case SC_PAGE_UP:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Page Up, Select"); KeyDescSet("Edit/Page Up, Select");
else else
SetKeyDesc("Edit/Page Up"); KeyDescSet("Edit/Page Up");
}else { }else {
i=doc_ce->y-(doc->win_task->win_height-1); i=doc_ce->y-(doc->win_task->win_height-1);
if (doc_ce->type_u8==DOCT_HEX_ED) if (doc_ce->type_u8==DOCT_HEX_ED)
@@ -602,12 +602,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_CURSOR_LEFT: case SC_CURSOR_LEFT:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_CTRL) if (sc&SCF_CTRL)
SetKeyDesc("Edit/GoTo Start of Line"); KeyDescSet("Edit/GoTo Start of Line");
else { else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Cursor Left, Select"); KeyDescSet("Edit/Cursor Left, Select");
else else
SetKeyDesc("Edit/Cursor Left"); KeyDescSet("Edit/Cursor Left");
} }
} else } else
EdCursorLeft(doc,sc); EdCursorLeft(doc,sc);
@@ -615,12 +615,12 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_CURSOR_RIGHT: case SC_CURSOR_RIGHT:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_CTRL) if (sc&SCF_CTRL)
SetKeyDesc("Edit/GoTo End of Line"); KeyDescSet("Edit/GoTo End of Line");
else { else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Cursor Right, Select"); KeyDescSet("Edit/Cursor Right, Select");
else else
SetKeyDesc("Edit/Cursor Right"); KeyDescSet("Edit/Cursor Right");
} }
} else } else
EdCursorRight(doc,sc); EdCursorRight(doc,sc);
@@ -628,9 +628,9 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_DELETE: case SC_DELETE:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Cut To Clipboard"); KeyDescSet("Edit/Cut To Clipboard");
else else
SetKeyDesc("Char/Delete"); KeyDescSet("Char/Delete");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
EdCutToClipboard(doc); EdCutToClipboard(doc);
@@ -641,11 +641,11 @@ public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
case SC_INS: case SC_INS:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
SetKeyDesc("Edit/Paste Clipboard"); KeyDescSet("Edit/Paste Clipboard");
else if (sc&SCF_CTRL) else if (sc&SCF_CTRL)
SetKeyDesc("Edit/Copy to Clipboard"); KeyDescSet("Edit/Copy to Clipboard");
else else
SetKeyDesc("Edit/Toggle Overstrike"); KeyDescSet("Edit/Toggle Overstrike");
} else { } else {
if (sc&SCF_SHIFT) if (sc&SCF_SHIFT)
EdPasteClipboard(doc); EdPasteClipboard(doc);
@@ -791,7 +791,7 @@ Bool DocFileEd(I64 _type,U8 *filename,
if (!FileNameChk(st2)) if (!FileNameChk(st2))
doc=NULL; doc=NULL;
else { else {
Silent(ON); Silent;
if (Bt(&edf_dof_flags,EDf_BAIL)) //if bail, scan parents if (Bt(&edf_dof_flags,EDf_BAIL)) //if bail, scan parents
result=FileFind(filename,, result=FileFind(filename,,
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS); FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
@@ -802,7 +802,7 @@ Bool DocFileEd(I64 _type,U8 *filename,
doc=DocRead(filename,flags); doc=DocRead(filename,flags);
doc->desc='Edit'; doc->desc='Edit';
Silent(old_silent); Silent(old_silent);
Fs->border_src=BDS_ED_FILENAME_PRT; Fs->border_src=BDS_ED_FILENAME_DRV;
} }
Free(st1); Free(st1);
@@ -835,14 +835,19 @@ Bool DocFileEd(I64 _type,U8 *filename,
} }
*_num=doc->cur_entry->y+1; *_num=doc->cur_entry->y+1;
if (edf_dof_flags&EDF_WAS_WRITE)
result=FALSE;
if (!(edf_dof_flags&EDF_BAIL) && DocDo(doc,edf_dof_flags|DOF_DONT_HOME)) { if (!(edf_dof_flags&EDF_BAIL) && DocDo(doc,edf_dof_flags|DOF_DONT_HOME)) {
DocLock(doc); DocLock(doc);
doc_e=doc->cur_entry; doc_e=doc->cur_entry;
if (doc_e!=doc) if (doc_e!=doc)
DocEntryRun(doc,doc_e,TRUE); DocEntryRun(doc,doc_e,TRUE);
DocUnlock(doc); DocUnlock(doc);
if (!(LK_DOC<=_type<=LK_DOC_LINE)) if (!(LK_DOC<=_type<=LK_DOC_LINE)) {
DocWrite(doc); DocWrite(doc);
if (edf_dof_flags&EDF_WAS_WRITE)
result=TRUE;
}
} }
if (!(LK_DOC<=_type<=LK_DOC_LINE)) if (!(LK_DOC<=_type<=LK_DOC_LINE))
DocDel(doc); DocDel(doc);
@@ -912,7 +917,7 @@ public I64 EdLinkCvt(U8 *link_st,U8 **_filename=NULL,U8 **_needle_str=NULL,
result=-1; result=-1;
else { else {
num=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES")); num=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES"));
filename2=Define("ST_BIBLE_FILE"); filename2=BIBLE_FILENAME;
} }
break; break;
case LK_FILE_LINE: case LK_FILE_LINE:
+10 -9
View File
@@ -81,7 +81,8 @@ public U8 *DocSave(CDoc *doc,I64 *_size=NULL)
cnt++; cnt++;
break; break;
case DOCT_TEXT://$BK,1$Update $LK,"DOCT_TEXT",A="FF:D:/Compiler/Lex.CPP,DOCT_TEXT"$$BK,0$ case DOCT_TEXT://$BK,1$Update $LK,"DOCT_TEXT",A="FF:D:/Compiler/Lex.CPP,DOCT_TEXT"$$BK,0$
if (!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP))) { if (!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP)) &&
!(doc_e->type&DOCG_BL_IV_UL)) {
cnt+=StrLen(doc_e->tag); cnt+=StrLen(doc_e->tag);
if (!(doc->flags & (DOCF_PLAIN_TEXT | DOCF_PLAIN_TEXT_WITH_TABS)) || if (!(doc->flags & (DOCF_PLAIN_TEXT | DOCF_PLAIN_TEXT_WITH_TABS)) ||
doc->flags&DOCF_DBL_DOLLARS) doc->flags&DOCF_DBL_DOLLARS)
@@ -112,7 +113,8 @@ public U8 *DocSave(CDoc *doc,I64 *_size=NULL)
for (doc_e=doc->root.next;doc_e!=doc;doc_e=doc_e->next) { for (doc_e=doc->root.next;doc_e!=doc;doc_e=doc_e->next) {
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) { if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
if (doc_e->type_u8==DOCT_TEXT && if (doc_e->type_u8==DOCT_TEXT &&
!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP))) { !(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP)) &&
!(doc_e->type&DOCG_BL_IV_UL)) {
src=doc_e->tag; src=doc_e->tag;
i=0; i=0;
while (ch=*src++) { while (ch=*src++) {
@@ -187,10 +189,9 @@ public Bool DocWrite(CDoc *doc,Bool prompt=FALSE)
{//Store doc to disk. {//Store doc to disk.
I64 size; I64 size;
U8 *buf; U8 *buf;
if (prompt && !DocFormDo(&doc->filename)) if (prompt && !DocFormDo(&doc->filename) ||
return FALSE; doc->filename.name[0]=='A' && doc->filename.name[2]==':')
if (doc->filename.name[0]=='A'&&doc->filename.name[2]==':') return FALSE; //CANCEL || LK_DOC,LK_DOC_ANCHOR,LK_DOC_FIND,LK_DOC_LINE?
return FALSE; //LK_DOC,LK_DOC_ANCHOR,LK_DOC_FIND,LK_DOC_LINE
buf=DocSave(doc,&size); buf=DocSave(doc,&size);
FileWrite(doc->filename.name,buf,size,0,doc->file_attr); FileWrite(doc->filename.name,buf,size,0,doc->file_attr);
Free(buf); Free(buf);
@@ -440,13 +441,13 @@ public Bool DocType(CDoc *doc=NULL,U8 *filename,I64 trailing_new_lines=1)
DocDel(doc2); DocDel(doc2);
result=TRUE; result=TRUE;
} else if (FilesFindMatch(filename,"*.BMP.Z")) { } else if (FilesFindMatch(filename,"*.BMP.Z")) {
DocBMPFile(doc,filename,FALSE); DocBMP(doc,filename,,FALSE);
result=TRUE; result=TRUE;
} else if (FilesFindMatch(filename,"*.BMP;*.bmp")) { } else if (FilesFindMatch(filename,"*.BMP;*.bmp")) {
DocBMPFile(doc,filename,TRUE); DocBMP(doc,filename,,TRUE);
result=TRUE; result=TRUE;
} else if (FilesFindMatch(filename,"*.GRA*")) { } else if (FilesFindMatch(filename,"*.GRA*")) {
DocGRAFile(doc,filename); DocGRA(doc,filename);
result=TRUE; result=TRUE;
} }
if (result) if (result)
+2 -2
View File
@@ -14,8 +14,8 @@ U0 DocInit()
"T\0A\0D\0HTML\0LE\0LM\0RE\0RM\0BI\0BP\0RT\0SX\0SY\0SCX\0U\0" "T\0A\0D\0HTML\0LE\0LM\0RE\0RM\0BI\0BP\0RT\0SX\0SY\0SCX\0U\0"
"LC\0LA\0RC\0RA\0TC\0LX\0CX\0RX\0TY\0CY\0BY\0" "LC\0LA\0RC\0RA\0TC\0LX\0CX\0RX\0TY\0CY\0BY\0"
"HL\0WW\0BK\0IV\0SEL\0UL\0" "HL\0WW\0BK\0IV\0SEL\0UL\0"
"PRY\0MRX\0WR\0L\0X\0Q\0FST\0B\0S\0BD\0C\0CA\0RD\0P\0TRM\0Z\0H\0" "PRY\0MRX\0WR\0L\0X\0Q\0FST\0B\0S\0BD\0C\0CA\0RD\0UD\0P\0TRM\0Z\0H\0"
"TR\0LS\0SK\0PU\0SIF\0HS\0FS\0NC\0DD\0UD\0"); "TR\0LS\0SK\0PU\0SIF\0HS\0FS\0NC\0DD\0");
DefineLstLoad("ST_LINK_TYPES", DefineLstLoad("ST_LINK_TYPES",
"FI\0FA\0FF\0FL\0MN\0PI\0PF\0PL\0BF\0DF\0HI\0AD\0AI\0AA\0AF\0AL\0"); "FI\0FA\0FF\0FL\0MN\0PI\0PF\0PL\0BF\0DF\0HI\0AD\0AI\0AA\0AF\0AL\0");
+2 -2
View File
@@ -168,7 +168,7 @@ I64 PopUpMacroMenu()
"\n\n\n$$GREEN$$SHIFT-F2$$FG$$ will play macro.\n"); "\n\n\n$$GREEN$$SHIFT-F2$$FG$$ will play macro.\n");
doc->flags|=DOCF_MIN_SIZE | DOCF_FORM; doc->flags|=DOCF_MIN_SIZE | DOCF_FORM;
StrPrint(buf,"DocMenuDo(%d);",doc); StrPrint(buf,"DocMenuDo(%d);",doc);
sys_macro_util_task=Spawn(&SrvUserCmdLine,NULL,"Macro Popup",,Fs); sys_macro_util_task=Spawn(&SrvCmdLine,NULL,"Macro Popup",,Fs);
Fs->popup_task=sys_macro_util_task; Fs->popup_task=sys_macro_util_task;
LBts(&sys_macro_util_task->display_flags,DISPLAYf_WIN_ON_TOP); LBts(&sys_macro_util_task->display_flags,DISPLAYf_WIN_ON_TOP);
tempc=TaskExe(sys_macro_util_task,Fs,buf, tempc=TaskExe(sys_macro_util_task,Fs,buf,
@@ -189,7 +189,7 @@ U0 MacroTask(I64)
sys_macro_repeat_n=1; sys_macro_repeat_n=1;
do { do {
i=PopUpMacroMenu; i=PopUpMacroMenu;
WinRefocus; WinRefocus(sys_focus_task);
switch (i) { switch (i) {
case SM_RECORD: case SM_RECORD:
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0); LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
+8 -7
View File
@@ -13,7 +13,7 @@ public Bool Ed(U8 *link_st,I64 edf_dof_flags=0)
case LK_DEF: case LK_DEF:
doc=DocNew; doc=DocNew;
doc->desc='DictDef'; doc->desc='DictDef';
WSDDefsPut(doc,filename,num); ACDDefsPut(doc,filename,num);
goto ej_doc; goto ej_doc;
case LK_HELP_INDEX: case LK_HELP_INDEX:
doc=DocNew; doc=DocNew;
@@ -24,11 +24,12 @@ ej_doc:
DocDo(doc); DocDo(doc);
DocDel(doc); DocDel(doc);
} }
if (!(edf_dof_flags&EDF_WAS_WRITE))
result=TRUE; result=TRUE;
break; break;
default: default:
if (IsRaw) if (IsRaw)
EdLite(filename,num); result=EdLite(filename,num,edf_dof_flags);
else { else {
cont=TRUE; cont=TRUE;
if (!(edf_dof_flags&EDF_BAIL) && !(LK_DOC<=i<=LK_DOC_LINE) && if (!(edf_dof_flags&EDF_BAIL) && !(LK_DOC<=i<=LK_DOC_LINE) &&
@@ -44,11 +45,11 @@ ej_doc:
return result; return result;
} }
public Bool Plain(U8 *filename) public Bool Plain(U8 *filename,I64 edf_dof_flags=0)
{//Edit document in plain text mode, so dollar signs are not special. {//Edit document in plain text mode, so dollar signs are not special.
Bool result; Bool result;
U8 *st=MStrPrint("PI:%s",filename); U8 *st=MStrPrint("PI:%s",filename);
result=Ed(st); result=Ed(st,edf_dof_flags);
Free(st); Free(st);
return result; return result;
} }
@@ -97,7 +98,7 @@ public U8 *DocLinkFile(U8 *link_st,CTask *mem_task=NULL)
Free(st); Free(st);
break; break;
case LK_BIBLE_FIND: case LK_BIBLE_FIND:
result=StrNew(Define("ST_BIBLE_FILE"),mem_task); result=StrNew(BIBLE_FILENAME,mem_task);
break; break;
} }
Free(filename); Free(filename);
@@ -148,7 +149,7 @@ public U0 DocTermNew()
CDoc *pdoc=DocNew; CDoc *pdoc=DocNew;
pdoc->right_click_link=&TermRightClickLink; pdoc->right_click_link=&TermRightClickLink;
pdoc->max_entries=4096; pdoc->max_entries=4096;
Fs->border_src=BDS_CUR_PRT; Fs->border_src=BDS_CUR_DRV;
pdoc->desc='Term'; pdoc->desc='Term';
Fs->put_doc=Fs->display_doc=pdoc; Fs->put_doc=Fs->display_doc=pdoc;
Fs->border_doc=DocBorderNew(pdoc); Fs->border_doc=DocBorderNew(pdoc);
@@ -531,7 +532,7 @@ I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e)
} }
"AutoFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st; "AutoFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
WinZBufUpdate; WinZBufUpdate;
AutoStr("%F\n",st); AutoFile(st);
result=TRUE; result=TRUE;
break; break;
} }
+4 -2
View File
@@ -265,7 +265,8 @@ U0 DocFormFwd(CDoc *doc,Bool giveup=FALSE)
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e; CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
if (doc->flags & DOCF_FORM) { if (doc->flags & DOCF_FORM) {
if (doc_e==doc) goto ff_recover; if (doc_e==doc) goto ff_recover;
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) || while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
!(doc_e->de_flags&DOCEF_LINK) ||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) { doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
doc_e=doc_e->next; doc_e=doc_e->next;
if (doc_e==doc) { if (doc_e==doc) {
@@ -292,7 +293,8 @@ U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE)
{ {
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e; CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
if (doc->flags & DOCF_FORM) { if (doc->flags & DOCF_FORM) {
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) || while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
!(doc_e->de_flags&DOCEF_LINK) ||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) { doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
doc_e=doc_e->last; doc_e=doc_e->last;
if (doc_e==doc) { if (doc_e==doc) {
+9 -34
View File
@@ -302,8 +302,8 @@ public Bool DocDo(CDoc *doc,I64 dof_flags=0)
Free(old_task_title); Free(old_task_title);
DocDel(bdoc); DocDel(bdoc);
if (dof_flags&DOF_MIN_SIZE) { if (dof_flags&DOF_MIN_SIZE) {
SetWinHorz(old_left,old_right); WinHorz(old_left,old_right);
SetWinVert(old_top,old_bottom); WinVert(old_top,old_bottom);
} }
Preempt(old_preempt); Preempt(old_preempt);
return result; return result;
@@ -403,32 +403,7 @@ md_restart:
return result; return result;
} }
#help_index "Task/Srv" #help_index "DolDoc;Task/Srv/Exe"
public I64 PopUp(U8 *buf,CTask *parent=NULL,CTask **_pu_task=NULL)
{//Execute code text in PopUp win task.
I64 result;
CSrvCmd *tempc;
Bool old_preempt=Preempt(OFF);
CTask *task=Spawn(&SrvUserCmdLine,NULL,"System",,parent);
if (!parent) {
TaskExe(task,parent,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE);
if (_pu_task) *_pu_task=task;
Preempt(old_preempt);
return 0;
} else {
Fs->popup_task=task;
tempc=TaskExe(task,parent,buf,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
if (_pu_task) *_pu_task=task;
ScanResult(tempc,&result);
Fs->popup_task=NULL;
Kill(task);
if (_pu_task) *_pu_task=NULL;
Preempt(old_preempt);
return result;
}
}
#help_index "DolDoc;Task/Srv"
public I64 PopUpEd(U8 *filename,CTask *parent=NULL,CTask **_pu_task=NULL) public I64 PopUpEd(U8 *filename,CTask *parent=NULL,CTask **_pu_task=NULL)
{//Create PopUp win task and edit a doc. {//Create PopUp win task and edit a doc.
U8 *st=MStrPrint("Ed(\"%Q\");",filename); U8 *st=MStrPrint("Ed(\"%Q\");",filename);
@@ -441,7 +416,7 @@ public I64 PopUpEd(U8 *filename,CTask *parent=NULL,CTask **_pu_task=NULL)
public CTask *PopUpViewDoc(CDoc *doc,I64 dof_flags=0) public CTask *PopUpViewDoc(CDoc *doc,I64 dof_flags=0)
{//Pass doc to PopUp win task for viewing. {//Pass doc to PopUp win task for viewing.
U8 *buf=MStrPrint("Preempt(ON);DocDo(0x%X,0x%X);",doc,dof_flags); U8 *buf=MStrPrint("Preempt(ON);DocDo(0x%X,0x%X);",doc,dof_flags);
CTask *task=Spawn(&SrvUserCmdLine,NULL,"View",,Fs); CTask *task=Spawn(&SrvCmdLine,NULL,"View",,Fs);
TaskExe(task,NULL,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE); TaskExe(task,NULL,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE);
Free(buf); Free(buf);
return task; return task;
@@ -470,13 +445,13 @@ public CTask *PopUpViewPrint(U8 *fmt,...)
public I64 PopUpMenu(CDoc *doc,I64 dof_flags=0) public I64 PopUpMenu(CDoc *doc,I64 dof_flags=0)
{//Do (Run) menu chooser doc in PopUp win task. {//Do (Run) menu chooser doc in PopUp win task.
doc->flags|=DOCF_MIN_SIZE | DOCF_FORM; doc->flags|=DOCF_MIN_SIZE | DOCF_FORM;
return SrvUser("DocMenuDo(0x%X,0x%X);",doc,dof_flags); return PopUpPrint("DocMenuDo(0x%X,0x%X);",doc,dof_flags);
} }
public Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,I64 dof_flags=DOF_MIN_SIZE, public Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,I64 dof_flags=DOF_MIN_SIZE,
U8 *header=NULL,U8 *footer=NULL) U8 *header=NULL,U8 *footer=NULL)
{//See $LK,"::/Demo/DolDoc/Form.CPP"$ and $LK,"::/Demo/LastClass.CPP"$. {//See $LK,"::/Demo/DolDoc/Form.CPP"$ and $LK,"::/Demo/LastClass.CPP"$.
return SrvUser("DocFormDo(0x%X,0x%X,0x%X,0x%X,0x%X);",_d,class_name, return PopUpPrint("DocFormDo(0x%X,0x%X,0x%X,0x%X,0x%X);",_d,class_name,
dof_flags,header,footer); dof_flags,header,footer);
} }
@@ -727,7 +702,7 @@ public F64 PopUpRangeF64Log(F64 lo,F64 hi,I64 steps,
return PopUpRangeF64Exp(lo,hi,Exp(Ln(hi/lo)/(steps-1)),fmt,header,footer); return PopUpRangeF64Exp(lo,hi,Exp(Ln(hi/lo)/(steps-1)),fmt,header,footer);
} }
#help_index "Task/Srv" #help_index "Task/Srv/Exe"
public I64 AdamFile(U8 *filename,Bool warn_ext=TRUE) public I64 AdamFile(U8 *filename,Bool warn_ext=TRUE)
{//Tell adam task to compile and run a file. {//Tell adam task to compile and run a file.
Bool okay=TRUE; Bool okay=TRUE;
@@ -875,8 +850,8 @@ U0 DrawIt(CTask *task,CDC *dc)
} }
i=(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH; i=(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH;
if (doc->max_x>i) i=doc->max_x; if (doc->max_x>i) i=doc->max_x;
SetWinHorz(task->win_left,task->win_left+i,task); WinHorz(task->win_left,task->win_left+i,task);
SetWinVert(task->win_top,task->win_top+doc->max_y+(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH,task); WinVert(task->win_top,task->win_top+doc->max_y+(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH,task);
} }
I64 DitherColorDo(U8 *header=NULL) I64 DitherColorDo(U8 *header=NULL)
@@ -169,23 +169,23 @@ public U0 DocPrintAtomic(CDoc *doc,U8 *fmt,...)
#help_index "DolDoc/Task" #help_index "DolDoc/Task"
U0 DocUpdateTaskDocs(CTask *task) U0 DocUpdateTaskDocs(CTask *task)
{//This is called from $LK,"GrUpdateWins",A="MN:GrUpdateWins"$() by the winmgr at 30fps. {//This is called from $LK,"GrUpdateWins",A="MN:GrUpdateWins"$() by the winmgr at 30fps.
CPrt *p; CDrv *dv;
CDoc *doc; CDoc *doc;
CD3I64 saved_scroll; CD3I64 saved_scroll;
Bool old_preempt=Preempt(OFF); Bool old_preempt=Preempt(OFF);
I64 border_attr; I64 border_attr;
if (task->border_src==BDS_CUR_PRT && task->cur_prt) { if (task->border_src==BDS_CUR_DRV && task->cur_dv) {
border_attr=task->cur_prt->text_attr; border_attr=task->cur_dv->text_attr;
if (border_attr&15!=border_attr>>4) if (border_attr&15!=border_attr>>4)
task->border_attr=border_attr; task->border_attr=border_attr;
} }
if (task->title_src==TTS_TASK_NAME) if (task->title_src==TTS_TASK_NAME)
StrCpy(task->task_title,task->task_name); StrCpy(task->task_title,task->task_name);
if ((doc=DocDisplay(task)) && !(doc->flags&DOCF_DONT_SHOW)) { if ((doc=DocDisplay(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
if (task->border_src==BDS_ED_FILENAME_PRT) if (task->border_src==BDS_ED_FILENAME_DRV)
try { try {
if (p=Drv2Prt(*doc->filename.name)) { if (dv=Let2Drv(*doc->filename.name)) {
border_attr=p->text_attr; border_attr=dv->text_attr;
if (border_attr&15!=border_attr>>4) if (border_attr&15!=border_attr>>4)
task->border_attr=border_attr; task->border_attr=border_attr;
} }
@@ -294,7 +294,7 @@ public Bool DocRecalc(CDoc *doc,Bool has_cursor=FALSE,I64 recalc=DOC_RECALC)
dc=DCAlias(gr.dc2,win_task); //Necessary for sprites dc=DCAlias(gr.dc2,win_task); //Necessary for sprites
break; break;
case DOC_RECALC_TO_SCREEN: case DOC_RECALC_TO_SCREEN:
if (doc->refresh_cnt++%(ToI64(winmgr.fps/10)+1) && if (doc->updates_cnt++%(ToI64(winmgr.fps/10)+1) &&
!Bt(&doc->flags,DOCf_DO_FULL_REFRESH) && !Bt(&doc->flags,DOCf_DO_FULL_REFRESH) &&
!(doc->flags&DOCF_BWD_MOVEMENT)) !(doc->flags&DOCF_BWD_MOVEMENT))
full_refresh=FALSE; full_refresh=FALSE;
@@ -1127,26 +1127,26 @@ rc_skip:
i=left+doc->max_x-doc->min_x; i=left+doc->max_x-doc->min_x;
if (i>TEXT_COLS-1) if (i>TEXT_COLS-1)
i=TEXT_COLS-1; i=TEXT_COLS-1;
SetWinHorz(left,i,win_task); WinHorz(left,i,win_task);
if (top<0) if (top<0)
top=0; top=0;
i=top+doc->max_y-doc->min_y; i=top+doc->max_y-doc->min_y;
if (i>TEXT_ROWS-1) if (i>TEXT_ROWS-1)
i=TEXT_ROWS-1; i=TEXT_ROWS-1;
SetWinVert(top,i,win_task); WinVert(top,i,win_task);
} else { } else {
if (left<1) if (left<1)
left=1; left=1;
i=left+doc->max_x-doc->min_x; i=left+doc->max_x-doc->min_x;
if (i>TEXT_COLS-2) if (i>TEXT_COLS-2)
i=TEXT_COLS-2; i=TEXT_COLS-2;
SetWinHorz(left,i,win_task); WinHorz(left,i,win_task);
if (top<1) if (top<1)
top=1; top=1;
i=top+doc->max_y-doc->min_y; i=top+doc->max_y-doc->min_y;
if (i>TEXT_ROWS-2) if (i>TEXT_ROWS-2)
i=TEXT_ROWS-2; i=TEXT_ROWS-2;
SetWinVert(top,i,win_task); WinVert(top,i,win_task);
} }
} }
if (find_cursor) { if (find_cursor) {
+2 -2
View File
@@ -1,4 +1,4 @@
#include "Dsk2a" #include "ADskA"
#include "Dsk2b" #include "ADskB"
#include "ChkDsk" #include "ChkDsk"
#include "FileMgr" #include "FileMgr"
+52 -33
View File
@@ -7,13 +7,13 @@ public U8 *DBlk(I64 blk,Bool write=FALSE)
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$. //See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
U8 *buf=MAlloc(BLK_SIZE); U8 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_prt,buf,blk,1); RBlks(Fs->cur_dv,buf,blk,1);
DocD(buf,BLK_SIZE); DocD(buf,BLK_SIZE);
if (write) { if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n"; "Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) { if (View) {
"Write\n"; "Write\n";
WBlks(Fs->cur_prt,buf,blk,1); WBlks(Fs->cur_dv,buf,blk,1);
} }
} }
return buf; return buf;
@@ -25,16 +25,35 @@ public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
//be written when you press <ESC>. //be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$. //See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files. //Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
U8 *buf=MAlloc(Fs->cur_prt->spc<<BLK_SIZE_BITS); U8 *buf=MAlloc(Fs->cur_dv->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_prt,c,num); c=ClusterNumNext(Fs->cur_dv,c,num);
RClusters(Fs->cur_prt,buf,c,1); RClusters(Fs->cur_dv,buf,c,1);
"Cluster:%X\n",c; "Cluster:%X\n",c;
DocD(buf,Fs->cur_prt->spc<<BLK_SIZE_BITS); DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
if (write) { if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n"; "Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) { if (View) {
"Write\n"; "Write\n";
WClusters(Fs->cur_prt,buf,c,1); WClusters(Fs->cur_dv,buf,c,1);
}
}
return buf;
}
public U8 *Dump(U8 *filename,Bool write=FALSE)
{//Dump file. Optionally, write.
//If you set write to TRUE, the file will
//be written when you press <ESC>.
U8 *buf;
I64 size;
if (buf=FileRead(filename,&size)) {
DocD(buf,size);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
FileWrite(filename,buf,size);
}
} }
} }
return buf; return buf;
@@ -218,7 +237,7 @@ public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64) U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
{ {
CPrt *p=Drv2Prt(*filename); CDrv *dv=Let2Drv(*filename);
CDirEntry de; CDirEntry de;
U8 *cur_dir=StrNew(filename), U8 *cur_dir=StrNew(filename),
buf[136]; buf[136];
@@ -236,7 +255,7 @@ U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
de.datetime=Now; de.datetime=Now;
else else
de.datetime=cdt; de.datetime=cdt;
DirNew(p,cur_dir,&de,FALSE); DirNew(dv,cur_dir,&de,FALSE);
} }
} else } else
PrintErr("File not found.\n"); PrintErr("File not found.\n");
@@ -279,69 +298,69 @@ public I64 FF(U8 *files_find_mask,U8 *fu_flags=NULL)
return cnt; return cnt;
} }
public U0 SetDrvTextAttr(U8 drv_let,U8 attr) public U0 DrvTextAttrSet(U8 drv_let,U8 attr)
{//Set color of the window border text {//Set color of the window border text
//for when this drive is the current drive. //for when this drive is the current drive.
CPrt *p; CDrv *dv;
try { try {
p=Drv2Prt(drv_let); dv=Let2Drv(drv_let);
p->text_attr=attr; dv->text_attr=attr;
} catch } catch
Fs->catch_except=TRUE; Fs->catch_except=TRUE;
} }
I64 RedSeaFSUnusedDrvSpace(U8 drv_let=0) I64 RedSeaUnusedDrvSpace(U8 drv_let=0)
{ {
CPrt *p=Drv2Prt(drv_let); CDrv *dv=Let2Drv(drv_let);
I64 result=0,i,l; I64 result=0,i,l;
U8 *bitmap; U8 *bitmap;
try { try {
l=(p->size+p->spc-1)/p->spc; l=(dv->size+dv->spc-1)/dv->spc;
i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS; i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS); bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i); RBlks(dv,bitmap,dv->map1,i);
for (i=0;i<l;i++) for (i=0;i<l;i++)
if (!Bt(bitmap,i)) if (!Bt(bitmap,i))
result++; result++;
Free(bitmap); Free(bitmap);
} catch } catch
PrtUnlock(p); DrvUnlock(dv);
return result*BLK_SIZE*p->spc; return result*BLK_SIZE*dv->spc;
} }
I64 FAT32UnusedDrvSpace(U8 drv_let=0) I64 FAT32UnusedDrvSpace(U8 drv_let=0)
{ {
CPrt *p=Drv2Prt(drv_let); CDrv *dv=Let2Drv(drv_let);
I64 result=0,i,l; I64 result=0,i,l;
U32 *bitmap; U32 *bitmap;
try { try {
l=(p->size+p->spc-1)/p->spc; l=(dv->size+dv->spc-1)/dv->spc;
i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS; i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS); bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i); RBlks(dv,bitmap,dv->map1,i);
for (i=0;i<l;i++) for (i=0;i<l;i++)
if (!bitmap[i]) if (!bitmap[i])
result++; result++;
Free(bitmap); Free(bitmap);
} catch } catch
PrtUnlock(p); DrvUnlock(dv);
return result*BLK_SIZE*p->spc; return result*BLK_SIZE*dv->spc;
} }
public I64 UnusedDrvSpace(U8 drv_let=0) public I64 UnusedDrvSpace(U8 drv_let=0)
{//Returns unused size in bytes. {//Returns unused size in bytes.
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt; CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *old_dir=StrNew(Fs->cur_dir); U8 *old_dir=StrNew(Fs->cur_dir);
I64 result=0; I64 result=0;
Drv(drv_let); Drv(drv_let);
switch (p->type) { switch (dv->type) {
case PT_REDSEA: case DVT_REDSEA:
result=RedSeaFSUnusedDrvSpace(drv_let); result=RedSeaUnusedDrvSpace(drv_let);
break; break;
case PT_FAT32: case DVT_FAT32:
result=FAT32UnusedDrvSpace(drv_let); result=FAT32UnusedDrvSpace(drv_let);
break; break;
default: default:
PrintErr("File System Not Supported\n"); PrintErr("File System Not Supported\n");
} }
Drv(Prt2Drv(p_old)); Drv(Drv2Let(old_dv));
Cd(old_dir); Cd(old_dir);
Free(old_dir); Free(old_dir);
return result; return result;
@@ -352,12 +371,12 @@ I64 Size1(CDirEntry *tempde,I64 *_fuf_flags,I64 round_to)
{ {
U8 buf[BLK_SIZE]; U8 buf[BLK_SIZE];
I64 result=0,i; I64 result=0,i;
CPrt *p; CDrv *dv;
while (tempde) { while (tempde) {
if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) && if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) &&
!(tempde->attr&RS_ATTR_DIR) && FileAttr(tempde->name)&RS_ATTR_COMPRESSED) { !(tempde->attr&RS_ATTR_DIR) && FileAttr(tempde->name)&RS_ATTR_COMPRESSED) {
p=Drv2Prt(*tempde->full_name); dv=Let2Drv(*tempde->full_name);
RBlks(p,buf,Cluster2Blk(p,tempde->cluster),1); RBlks(dv,buf,Cluster2Blk(dv,tempde->cluster),1);
i=(&buf)(CArcCompress *)->expanded_size; i=(&buf)(CArcCompress *)->expanded_size;
} }
if (round_to) if (round_to)
+53 -53
View File
@@ -62,25 +62,25 @@ public CDirEntry *DirTreeUnserialize(U8 *src)
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)" #help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)"
#define ROUND_PRT_TO (63*255) #define ROUND_DRV_TO (63*255)
#define PRT_HEADER 63 #define DRV_HEADER 63
class CPlannedPrt class CPlannedDrv
{ {
CPlannedPrt *next,*last; CPlannedDrv *next,*last;
I64 size; I64 size;
Bool pri; Bool pri;
}; };
//Available to assist in writing scripts. //Available to assist in writing scripts.
I64 prt_dsk_dsk_size; I64 drv_dsk_dsk_size;
public U0 PrtDsk(U8 drv_let=0) public U0 PrtDsk(U8 drv_let=0)
{//Partition the disk containing partition drv_let. {//Partition the disk containing partition drv_let.
//drv_let=0 means add new drive that //drv_let=0 means add new drive that
//is not already mounted. //is not already mounted.
CBlkDev *bdev; CBlkDev *bd;
CPlannedPrt root,*temppp; CPlannedDrv root,*temppp;
CMasterBoot mbr; CMasterBoot mbr;
Bool pri=TRUE; Bool pri=TRUE;
I64 ext_base,drv_let2,pri_cnt=0, I64 ext_base,drv_let2,pri_cnt=0,
@@ -99,7 +99,7 @@ public U0 PrtDsk(U8 drv_let=0)
if (drv_let) if (drv_let)
try try
Drv2BlkDev(drv_let); Let2BlkDev(drv_let);
catch { catch {
drv_let=0; drv_let=0;
Fs->catch_except=TRUE; Fs->catch_except=TRUE;
@@ -110,18 +110,18 @@ public U0 PrtDsk(U8 drv_let=0)
return; return;
} }
bdev=Drv2BlkDev(drv_let); bd=Let2BlkDev(drv_let);
if (!bdev || bdev->type!=BDT_ATA) if (!bd || bd->type!=BDT_ATA)
return; return;
prt_dsk_dsk_size=bdev->max_blk+1; drv_dsk_dsk_size=bd->max_blk+1;
QueInit(&root); QueInit(&root);
drv_let2=bdev->first_drv_let; drv_let2=bd->first_drv_let;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO); remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO);
while (FloorU64(remaining,ROUND_PRT_TO)>=ROUND_PRT_TO) { while (FloorU64(remaining,ROUND_DRV_TO)>=ROUND_DRV_TO) {
temppp=MAlloc(sizeof(CPlannedPrt)); temppp=MAlloc(sizeof(CPlannedDrv));
do { do {
"$$RED$$Partition %C$$FG$$\n",drv_let2; "$$RED$$Partition %C$$FG$$\n",drv_let2;
temppp->pri=FALSE; temppp->pri=FALSE;
@@ -136,10 +136,10 @@ public U0 PrtDsk(U8 drv_let=0)
pri=FALSE; pri=FALSE;
} }
"Blocks Remaining:%d (0x%X)\n", "Blocks Remaining:%d (0x%X)\n",
remaining-PRT_HEADER,remaining-PRT_HEADER; remaining-DRV_HEADER,remaining-DRV_HEADER;
temppp->size=CeilU64(GetI64("Size in Blocks :", temppp->size=CeilU64(GetI64("Size in Blocks :",
remaining-PRT_HEADER)+PRT_HEADER,ROUND_PRT_TO); remaining-DRV_HEADER)+DRV_HEADER,ROUND_DRV_TO);
} while (!(ROUND_PRT_TO<=temppp->size<=FloorU64(remaining,ROUND_PRT_TO))); } while (!(ROUND_DRV_TO<=temppp->size<=FloorU64(remaining,ROUND_DRV_TO)));
QueIns(temppp,root.last); QueIns(temppp,root.last);
remaining-=temppp->size; remaining-=temppp->size;
drv_let2++; drv_let2++;
@@ -147,7 +147,7 @@ public U0 PrtDsk(U8 drv_let=0)
"\n\n!!! Repartition Drive !!!\n\n"; "\n\n!!! Repartition Drive !!!\n\n";
temppp=root.next; temppp=root.next;
drv_let2=bdev->first_drv_let; drv_let2=bd->first_drv_let;
while (temppp!=&root) { while (temppp!=&root) {
"Drive %C:%08X ",drv_let2,temppp->size; "Drive %C:%08X ",drv_let2,temppp->size;
if (temppp->pri) if (temppp->pri)
@@ -160,7 +160,7 @@ public U0 PrtDsk(U8 drv_let=0)
if (!AreYouSure) if (!AreYouSure)
goto pd_done; goto pd_done;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO)-ROUND_PRT_TO; remaining=FloorU64(bd->max_blk+1,ROUND_DRV_TO)-ROUND_DRV_TO;
temppp=root.next; temppp=root.next;
MemSet(&mbr,0,BLK_SIZE); MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55; mbr.signature=0xAA55;
@@ -172,8 +172,8 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[i].type=1; //Will get set different. mbr.p[i].type=1; //Will get set different.
mbr.p[i].end_head=0xFE; mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF; mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=PRT_HEADER+offset; mbr.p[i].offset=DRV_HEADER+offset;
mbr.p[i].size=temppp->size-PRT_HEADER; mbr.p[i].size=temppp->size-DRV_HEADER;
offset+=temppp->size; offset+=temppp->size;
remaining-=temppp->size; remaining-=temppp->size;
temppp=temppp->next; temppp=temppp->next;
@@ -190,7 +190,7 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[i].size=remaining; mbr.p[i].size=remaining;
ext_base=offset; ext_base=offset;
} }
ATAWriteBlks(bdev,&mbr,0,1); ATAWriteBlks(bd,&mbr,0,1);
while (temppp!=&root) { while (temppp!=&root) {
start_offset=offset; start_offset=offset;
@@ -203,8 +203,8 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[0].type=1; //Will get set different. mbr.p[0].type=1; //Will get set different.
mbr.p[0].end_head=0xFE; mbr.p[0].end_head=0xFE;
mbr.p[0].end_cyl=0xFFFF; mbr.p[0].end_cyl=0xFFFF;
mbr.p[0].offset=PRT_HEADER; mbr.p[0].offset=DRV_HEADER;
mbr.p[0].size=temppp->size-PRT_HEADER; mbr.p[0].size=temppp->size-DRV_HEADER;
offset+=temppp->size; offset+=temppp->size;
temppp=temppp->next; temppp=temppp->next;
if (temppp!=&root) { if (temppp!=&root) {
@@ -217,12 +217,12 @@ public U0 PrtDsk(U8 drv_let=0)
mbr.p[1].offset=offset-ext_base; mbr.p[1].offset=offset-ext_base;
mbr.p[1].size=temppp->size; mbr.p[1].size=temppp->size;
} }
ATAWriteBlks(bdev,&mbr,start_offset,1); ATAWriteBlks(bd,&mbr,start_offset,1);
} }
bdev->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS); bd->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS);
BlkDevAdd(bdev,FALSE,TRUE); BlkDevAdd(bd,FALSE,TRUE);
for (i=bdev->first_drv_let;i<drv_let2;i++) for (i=bd->first_drv_let;i<drv_let2;i++)
Fmt(i,,FALSE); Fmt(i,,FALSE);
pd_done: pd_done:
@@ -235,15 +235,15 @@ pd_done:
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)" #help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
U0 RedSeaFSDrvView(U8 drv_let=0) U0 RedSeaDrvView(U8 drv_let=0)
{ {
CPrt *p=Drv2Prt(drv_let); CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l,s; I64 lohi,c1,i,x,y,l,s;
U8 *bitmap; U8 *bitmap;
CDC *dc=DCAlias; CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1), l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc; s=(dv->size+dv->spc-1)/dv->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax; WinMax;
@@ -253,7 +253,7 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
try { try {
i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS; i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS); bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i); RBlks(dv,bitmap,dv->map1,i);
i=0; i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) { for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey) if (ScanKey)
@@ -271,7 +271,7 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
} }
Free(bitmap); Free(bitmap);
} catch } catch
PrtUnlock(p); DrvUnlock(dv);
GetChar; GetChar;
SettingsPop; SettingsPop;
@@ -280,12 +280,12 @@ U0 RedSeaFSDrvView(U8 drv_let=0)
} }
U0 FAT32DrvView(U8 drv_let=0) U0 FAT32DrvView(U8 drv_let=0)
{ {
CPrt *p=Drv2Prt(drv_let); CDrv *dv=Let2Drv(drv_let);
I64 lohi,c1,i,x,y,l,s; I64 lohi,c1,i,x,y,l,s;
U32 *bitmap; U32 *bitmap;
CDC *dc=DCAlias; CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1), l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc; s=(dv->size+dv->spc-1)/dv->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax; WinMax;
@@ -295,7 +295,7 @@ U0 FAT32DrvView(U8 drv_let=0)
try { try {
i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS; i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS); bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i); RBlks(dv,bitmap,dv->map1,i);
i=0; i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) { for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey) if (ScanKey)
@@ -313,7 +313,7 @@ U0 FAT32DrvView(U8 drv_let=0)
} }
Free(bitmap); Free(bitmap);
} catch } catch
PrtUnlock(p); DrvUnlock(dv);
GetChar; GetChar;
SettingsPop; SettingsPop;
@@ -322,19 +322,19 @@ U0 FAT32DrvView(U8 drv_let=0)
} }
public U0 DrvView(U8 drv_let=0) public U0 DrvView(U8 drv_let=0)
{//Drive view. Graph the allocation map's fragmentation. {//Drive view. Graph the allocation map's fragmentation.
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt; CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
Drv(drv_let); Drv(drv_let);
switch (p->type) { switch (dv->type) {
case PT_REDSEA: case DVT_REDSEA:
RedSeaFSDrvView(drv_let); RedSeaDrvView(drv_let);
break; break;
case PT_FAT32: case DVT_FAT32:
FAT32DrvView(drv_let); FAT32DrvView(drv_let);
break; break;
default: default:
PrintErr("File System Not Supported\n"); PrintErr("File System Not Supported\n");
} }
Drv(Prt2Drv(p_old)); Drv(Drv2Let(old_dv));
} }
public U0 DskView(U8 drv_let=0) public U0 DskView(U8 drv_let=0)
@@ -343,8 +343,8 @@ public U0 DskView(U8 drv_let=0)
h=Fs->pix_width, h=Fs->pix_width,
v=Fs->pix_height, v=Fs->pix_height,
radius; radius;
CPrt *p; CDrv *dv;
CBlkDev *bdev=Drv2BlkDev(drv_let); CBlkDev *bd=Let2BlkDev(drv_let);
CDC *dc=DCAlias; CDC *dc=DCAlias;
F64 sect_start,sect_end; F64 sect_start,sect_end;
@@ -360,11 +360,11 @@ public U0 DskView(U8 drv_let=0)
GrCircle(dc,h>>1,v>>1,radius); GrCircle(dc,h>>1,v>>1,radius);
j=1; j=1;
for (i=0;i<NUM_PRTS;i++) { for (i=0;i<NUM_DRVS;i++) {
p=&dsk.prts[i]; dv=&dsk.drvs[i];
if (bdev==p->bdev && p->type) { if (bd==dv->bd && dv->type) {
sect_start=-(p->offset*2*ã/(bdev->max_blk+1)); sect_start=-(dv->base_offset*2*ã/(bd->max_blk+1));
sect_end =-((p->offset+p->size)*2*ã/(bdev->max_blk+1)); sect_end =-((dv->base_offset+dv->size)*2*ã/(bd->max_blk+1));
dc->color=BLACK; dc->color=BLACK;
GrLine(dc,h>>1,v>>1, GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_start), h>>1+radius*Cos(sect_start),
@@ -374,8 +374,8 @@ public U0 DskView(U8 drv_let=0)
v>>1+radius*Sin(sect_end)); v>>1+radius*Sin(sect_end));
dc->color=j; dc->color=j;
GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Prt2Drv(p), GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Drv2Let(dv),
p->type.u16[0],"ST_PRT_TYPES"); dv->type.u16[0],"ST_DRV_TYPES");
GrFloodFill(dc, GrFloodFill(dc,
h>>1+(radius-4)*Cos((sect_start+sect_end)/2), h>>1+(radius-4)*Cos((sect_start+sect_end)/2),
v>>1+(radius-4)*Sin((sect_start+sect_end)/2),FALSE); v>>1+(radius-4)*Sin((sect_start+sect_end)/2),FALSE);
+44 -48
View File
@@ -11,30 +11,28 @@ Bool ChkDskConfirm(Bool *_fix,Bool *_confirm)
return *_fix; return *_fix;
} }
I64 RedSeaFSChkDskLst(CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc) I64 RedSeaChkDskLst(CDrv *dv,CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
{ {
CDirEntry *tempde2; CDirEntry *tempde2;
I64 i,j,errs=0; I64 i,j,errs=0;
while (tempde1) { while (tempde1) {
tempde2=tempde1->next; tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) { if (tempde1->attr & RS_ATTR_DIR && tempde1->sub)
if (tempde1->sub) errs+=RedSeaChkDskLst(dv,tempde1->sub,bits,bits2,size,bpc);
errs+=RedSeaFSChkDskLst(tempde1->sub,bits,bits2,size,bpc);
}
j=(tempde1->size+bpc-1)/bpc; j=(tempde1->size+bpc-1)/bpc;
for (i=0;i<j;i++) { for (i=0;i<j;i++) {
if (i+tempde1->cluster>size) { if (i+tempde1->cluster-dv->data_area>size) {
PrintErr("Invalid Cluster:%s Cluster:%X\n",tempde1->full_name, PrintErr("Invalid Cluster:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster); i+tempde1->cluster);
errs++; errs++;
break; break;
} }
if (LBts(bits,i+tempde1->cluster)) { if (LBts(bits,i+tempde1->cluster-dv->data_area)) {
PrintErr("Dbl Alloc:%s Cluster:%X\n",tempde1->full_name, PrintErr("Dbl Alloc:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster); i+tempde1->cluster);
errs++; errs++;
} }
if (!LBtr(bits2,i+tempde1->cluster)) { if (!LBtr(bits2,i+tempde1->cluster-dv->data_area)) {
PrintErr("UnAlloc:%s Cluster:%X\n",tempde1->full_name, PrintErr("UnAlloc:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster); i+tempde1->cluster);
errs++; errs++;
@@ -46,74 +44,72 @@ I64 RedSeaFSChkDskLst(CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
return errs; return errs;
} }
I64 RedSeaFSChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm) I64 RedSeaChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{ {
I64 i,j,bpc,size,errs=0; I64 i,j,bpc,size,errs=0;
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt; CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *files_find_mask=MStrPrint("%c:/*",Prt2Drv(p)), U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
*old_dir=StrNew(Fs->cur_dir), *old_dir=StrNew(Fs->cur_dir),
*bits,*bits2; *bits,*bits2;
CDirEntry *ptr,*ptr2; CDirEntry *ptr,*ptr2;
Drv(drv_let); Drv(drv_let);
"Scanning...\n"; "Scanning...\n";
size=(p->size-(p->data-p->offset))/p->spc; size=(dv->size-(dv->data_area-dv->base_offset))/dv->spc;
bpc=p->spc<<BLK_SIZE_BITS; bpc=dv->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3); bits=CAlloc((size+7)>>3);
bits2=CAlloc((size+7)>>3+BLK_SIZE); bits2=CAlloc((size+7)>>3+BLK_SIZE);
RBlks(p,bits2,p->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS); RBlks(dv,bits2,dv->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
//Get Root Dir size //Get Root Dir size
ptr2=MAlloc(bpc); ptr2=MAlloc(bpc);
RClusters(p,ptr2,p->root_cluster,1); RBlks(dv,ptr2,dv->root_cluster,1);
ptr=ptr2(U8 *)-offset(CDirEntry.start); ptr=ptr2(U8 *)-offset(CDirEntry.start);
j=(ptr->size+bpc-1)/bpc; j=(ptr->size+bpc-1)/bpc;
Free(ptr2); Free(ptr2);
for (i=0;i<j;i++) { for (i=0;i<j;i++) {
if (i+p->root_cluster>size) { if (i+dv->root_cluster-dv->data_area>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+p->root_cluster); PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++; errs++;
break; break;
} }
if (LBts(bits,i+p->root_cluster)) { if (LBts(bits,i+dv->root_cluster-dv->data_area)) {
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+p->root_cluster); PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++; errs++;
} }
if (!LBtr(bits2,i+p->root_cluster)) { if (!LBtr(bits2,i+dv->root_cluster-dv->data_area)) {
PrintErr("UnAlloc: RootDir Cluster:%X\n",i+p->root_cluster); PrintErr("UnAlloc: RootDir Cluster:%X\n",i+dv->root_cluster);
errs++; errs++;
} }
} }
errs+=RedSeaFSChkDskLst(FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc); errs+=RedSeaChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
for (i=1;i<size;i++) for (i=1;i<size;i++)
if (Bt(bits2,i)) { if (Bt(bits2,i)) {
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i); PrintWarn("Shouldn't Alloc Cluster:%0X\n",i+dv->data_area);
errs++; errs++;
if (ChkDskConfirm(_fix,_confirm)) if (ChkDskConfirm(_fix,_confirm))
RedSeaFSFreeClusters(p,i,1); RedSeaFreeClusters(dv,i+dv->data_area,1);
} }
Free(files_find_mask); Free(files_find_mask);
Free(bits); Free(bits);
Free(bits2); Free(bits2);
Drv(Prt2Drv(old_prt)); Drv(Drv2Let(old_dv));
Cd(old_dir); Cd(old_dir);
Free(old_dir); Free(old_dir);
return errs; return errs;
} }
I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 bpc) I64 FAT32ChkDskLst(CDrv *dv,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 bpc)
{ {
CDirEntry *tempde2; CDirEntry *tempde2;
I64 i,c,errs=0; I64 i,c,errs=0;
while (tempde1) { while (tempde1) {
tempde2=tempde1->next; tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) { if (tempde1->attr & RS_ATTR_DIR && tempde1->sub)
if (tempde1->sub) errs+=FAT32ChkDskLst(dv,tempde1->sub,bits,bits2,size,bpc);
errs+=FAT32ChkDskLst(p,tempde1->sub,bits,bits2,size,bpc);
}
i=0; i=0;
c=tempde1->cluster; c=tempde1->cluster;
while (0<c<0x0FFFFFF8) { while (0<c<0x0FFFFFF8) {
@@ -131,17 +127,17 @@ I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 b
errs++; errs++;
} else } else
bits2[c]=0; bits2[c]=0;
c=ClusterNumNext(p,c); c=ClusterNumNext(dv,c);
i++; i++;
} }
if (!(tempde1->attr & RS_ATTR_DIR)) { if (!(tempde1->attr & RS_ATTR_DIR)) {
i*=bpc; i*=bpc;
if (tempde1->size>i) { if (tempde1->size>i) {
PrintErr("Allocated File Too Short:%s\n",tempde1->full_name); PrintErr("Alloced File Too Short:%s\n",tempde1->full_name);
errs++; errs++;
} }
if (i>tempde1->size+bpc-1) { if (i>tempde1->size+bpc-1) {
PrintWarn("Allocated File Too Long:%s\n",tempde1->full_name); PrintWarn("Alloced File Too Long:%s\n",tempde1->full_name);
errs++; errs++;
} }
} }
@@ -154,20 +150,20 @@ I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 b
I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm) I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{ {
I64 i,bpc,size,c,errs=0; I64 i,bpc,size,c,errs=0;
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt; CDrv *dv=Let2Drv(drv_let),*old_dv=Fs->cur_dv;
U8 *files_find_mask=MStrPrint("%c:/*",Prt2Drv(p)), U8 *files_find_mask=MStrPrint("%c:/*",Drv2Let(dv)),
*old_dir=StrNew(Fs->cur_dir), *old_dir=StrNew(Fs->cur_dir),
*bits; *bits;
U32 *bits2; U32 *bits2;
Drv(drv_let); Drv(drv_let);
"Scanning...\n"; "Scanning...\n";
size=(p->size-(p->data-p->offset))/p->spc; size=(dv->size-(dv->data_area-dv->base_offset))/dv->spc;
bpc=p->spc<<BLK_SIZE_BITS; bpc=dv->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3); bits=CAlloc((size+7)>>3);
bits2=CAlloc(size*4+BLK_SIZE); bits2=CAlloc(size*4+BLK_SIZE);
RBlks(p,bits2,p->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS); RBlks(dv,bits2,dv->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
c=p->root_cluster; c=dv->root_cluster;
while (0<c<0x0FFFFFF8) { while (0<c<0x0FFFFFF8) {
if (c>size) { if (c>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",c); PrintErr("Invalid Cluster: RootDir Cluster:%X\n",c);
@@ -183,10 +179,10 @@ I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
errs++; errs++;
} else } else
bits2[c]=0; bits2[c]=0;
c=ClusterNumNext(p,c); c=ClusterNumNext(dv,c);
} }
errs+=FAT32ChkDskLst(p,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc); errs+=FAT32ChkDskLst(dv,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
bits2[1]=0; //See $LK,"FAT32Fmt",A="MN:FAT32Fmt"$() bits2[1]=0; //See $LK,"FAT32Fmt",A="MN:FAT32Fmt"$()
for (i=1;i<size;i++) for (i=1;i<size;i++)
@@ -194,12 +190,12 @@ I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i); PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
errs++; errs++;
if (ChkDskConfirm(_fix,_confirm)) if (ChkDskConfirm(_fix,_confirm))
FAT32FreeClusters(p,i); FAT32FreeClusters(dv,i);
} }
Free(files_find_mask); Free(files_find_mask);
Free(bits); Free(bits);
Free(bits2); Free(bits2);
Drv(Prt2Drv(old_prt)); Drv(Drv2Let(old_dv));
Cd(old_dir); Cd(old_dir);
Free(old_dir); Free(old_dir);
return errs; return errs;
@@ -209,12 +205,12 @@ public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
{//Check disk for allocation errors and, optionally, fix. {//Check disk for allocation errors and, optionally, fix.
//You probably want to reformat and reinstall. //You probably want to reformat and reinstall.
I64 errs=0; I64 errs=0;
CPrt *p=Drv2Prt(drv_let); CDrv *dv=Let2Drv(drv_let);
switch (p->type) { switch (dv->type) {
case PT_REDSEA: case DVT_REDSEA:
errs=RedSeaFSChkDsk(drv_let,&fix,&confirm); errs=RedSeaChkDsk(drv_let,&fix,&confirm);
break; break;
case PT_FAT32: case DVT_FAT32:
errs=FAT32ChkDsk(drv_let,&fix,&confirm); errs=FAT32ChkDsk(drv_let,&fix,&confirm);
break; break;
default: default:
+24 -24
View File
@@ -140,7 +140,7 @@ CDirEntry *FMRebuildDocDrv(U8 drv_let,CDoc *doc,CDirEntry **_root,Bool init)
U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode) U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
{ {
CPrt *p; CDrv *dv;
I64 i; I64 i;
CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc; CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc;
CFMUncollapsedLst *tempc=NULL; CFMUncollapsedLst *tempc=NULL;
@@ -211,15 +211,15 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
break; break;
} }
DocPrint(doc,"$$LTBLUE$$"); DocPrint(doc,"$$LTBLUE$$");
for (i=0;i<NUM_PRTS;i++) { for (i=0;i<NUM_DRVS;i++) {
p=&dsk.prts[i]; dv=&dsk.drvs[i];
if (p->type==PT_REDSEA||p->type==PT_FAT32) if (dv->type==DVT_REDSEA||dv->type==DVT_FAT32)
FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE); FMRebuildDocDrv(Drv2Let(dv),doc,_root,TRUE);
else if (p->type==PT_ISO9660) { else if (dv->type==DVT_ISO9660) {
if (p->bdev->flags&BDF_INITIALIZED) if (dv->bd->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE); tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_root,TRUE);
else { else {
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,FALSE); tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_root,FALSE);
tempde->flags|=DEF_NOT_INITIALIZED; tempde->flags|=DEF_NOT_INITIALIZED;
} }
tempde->flags|=DEF_REMOVABLE; tempde->flags|=DEF_REMOVABLE;
@@ -248,7 +248,7 @@ U0 FMRename(CDoc *doc)
Cd(parent->full_name); Cd(parent->full_name);
StrCpy(fn.name,tempde->name); StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) { if (DocFormDo(&fn)) {
Silent(ON); Silent;
Move(tempde->name,fn.name); Move(tempde->name,fn.name);
Silent(OFF); Silent(OFF);
} }
@@ -260,7 +260,7 @@ U0 FMRename(CDoc *doc)
StrCpy(fn.name,tempde->name); StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) { if (DocFormDo(&fn)) {
if (StrCmp(tempde->name,fn.name)) { if (StrCmp(tempde->name,fn.name)) {
Silent(ON); Silent;
if (CopyTree(tempde->name,fn.name)) if (CopyTree(tempde->name,fn.name))
DelTree(tempde->name); DelTree(tempde->name);
Silent(OFF); Silent(OFF);
@@ -281,7 +281,7 @@ U0 FMMkDir(CDoc *doc)
if (parent=tempde->parent) { if (parent=tempde->parent) {
Cd(parent->full_name); Cd(parent->full_name);
if (DocFormDo(&fn)) { if (DocFormDo(&fn)) {
Silent(ON); Silent;
MkDir(fn.name); MkDir(fn.name);
Silent(OFF); Silent(OFF);
} }
@@ -290,7 +290,7 @@ U0 FMMkDir(CDoc *doc)
tempde=doc_e->user_data; tempde=doc_e->user_data;
Cd(tempde->full_name); Cd(tempde->full_name);
if (DocFormDo(&fn)) { if (DocFormDo(&fn)) {
Silent(ON); Silent;
MkDir(fn.name); MkDir(fn.name);
Silent(OFF); Silent(OFF);
} }
@@ -304,7 +304,7 @@ U0 FMDelete(CDoc *doc)
CDirEntry *tempde; CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_MENU_VAL) { if (doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data; tempde=doc_ce->user_data;
Silent(ON); Silent;
st=MStrPrint("Delete: %s",tempde->full_name); st=MStrPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st)) if (PopUpCancelOk(st))
Del(tempde->full_name); Del(tempde->full_name);
@@ -312,7 +312,7 @@ U0 FMDelete(CDoc *doc)
Silent(OFF); Silent(OFF);
} else if (doc_ce->type_u8==DOCT_TREE) { } else if (doc_ce->type_u8==DOCT_TREE) {
tempde=doc_ce->user_data; tempde=doc_ce->user_data;
Silent(ON); Silent;
st=MStrPrint("Delete: %s",tempde->full_name); st=MStrPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st)) if (PopUpCancelOk(st))
DelTree(tempde->full_name); DelTree(tempde->full_name);
@@ -332,7 +332,7 @@ U0 FMMount(CDoc *doc)
if (tempde) { if (tempde) {
while (tempde->parent) while (tempde->parent)
tempde=tempde->parent; tempde=tempde->parent;
Silent(ON); Silent;
ChgDsk(*tempde->full_name); ChgDsk(*tempde->full_name);
Silent(OFF); Silent(OFF);
} }
@@ -352,7 +352,7 @@ U0 FMFmtDrv(CDoc *doc)
tempde=tempde->parent; tempde=tempde->parent;
st=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name); st=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
if (PopUpCancelOk(st)) { if (PopUpCancelOk(st)) {
Silent(ON); Silent;
Fmt(*tempde->full_name,,FALSE); Fmt(*tempde->full_name,,FALSE);
Silent(OFF); Silent(OFF);
} }
@@ -373,7 +373,7 @@ U0 FMMakeISO(CDoc *doc)
if (doc_ce->type_u8==DOCT_MENU_VAL) if (doc_ce->type_u8==DOCT_MENU_VAL)
tempde=tempde->parent; tempde=tempde->parent;
if (tempde && *tempde->full_name) { if (tempde && *tempde->full_name) {
Silent(ON); Silent;
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/') if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
st=MStrPrint("%s*",tempde->full_name); st=MStrPrint("%s*",tempde->full_name);
else else
@@ -396,7 +396,7 @@ U0 FMBurnISO(CDoc *doc)
if (tempde) { if (tempde) {
while (tempde->parent) while (tempde->parent)
tempde=tempde->parent; tempde=tempde->parent;
Silent(ON); Silent;
CDImageWrite(*tempde->full_name); CDImageWrite(*tempde->full_name);
Silent(OFF); Silent(OFF);
} }
@@ -423,7 +423,7 @@ U0 FMCopy(CDoc *doc)
tempde->flags|=DEF_PROCESSED; tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent; tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) { if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON); Silent;
Copy(tempde->full_name,tempde1->full_name); Copy(tempde->full_name,tempde1->full_name);
Silent(OFF); Silent(OFF);
} }
@@ -432,7 +432,7 @@ U0 FMCopy(CDoc *doc)
tempde->flags|=DEF_PROCESSED; tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent; tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) { if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON); Silent;
if (*tempde1->name) if (*tempde1->name)
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name); st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
else else
@@ -581,7 +581,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
case MSG_IP_L_UP: case MSG_IP_L_UP:
if (doc_ce) { if (doc_ce) {
gr.fp_final_screen_update=fp_old_final_screen_update; gr.fp_final_screen_update=fp_old_final_screen_update;
if (SetCursorPos(Fs,a1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,a2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) { if (WinCursorPosSet(Fs,a1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,a2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) {
doc_e=doc->cur_entry; doc_e=doc->cur_entry;
if (doc_e!=doc_ce) { if (doc_e!=doc_ce) {
st2=NULL; st2=NULL;
@@ -595,7 +595,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
} }
if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) { if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data; tempde=doc_ce->user_data;
Silent(ON); Silent;
Move(tempde->full_name,st2); Move(tempde->full_name,st2);
Silent(OFF); Silent(OFF);
FMRebuildDoc(&doc,&root,mode); FMRebuildDoc(&doc,&root,mode);
@@ -617,7 +617,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
else else
st=MStrPrint("%s%s",tempde1->full_name,tempde->name); st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
if (StrCmp(tempde->full_name,st)) { if (StrCmp(tempde->full_name,st)) {
Silent(ON); Silent;
CopyTree(tempde->full_name,st); CopyTree(tempde->full_name,st);
DelTree(tempde->full_name); DelTree(tempde->full_name);
Silent(OFF); Silent(OFF);
+5 -6
View File
@@ -1,7 +1,6 @@
#help_index "God" #help_index "God"
U0 BibleInit() U0 BibleInit()
{ {
DefineLoad("ST_BIBLE_FILE","::/Misc/Bible.TXT.Z");
DefineLstLoad("ST_BIBLE_BOOKS", DefineLstLoad("ST_BIBLE_BOOKS",
"Genesis\0" "Genesis\0"
"Exodus\0" "Exodus\0"
@@ -157,7 +156,7 @@ public U8 *BibleLine2Verse(I64 line,I64 separate_ch=CH_SPACE)
ptr+=StrLen(ptr)+1; ptr+=StrLen(ptr)+1;
} }
if (0<=--i<cnt) { if (0<=--i<cnt) {
doc=DocRead(Define("ST_BIBLE_FILE"),DOCF_PLAIN_TEXT); doc=DocRead(BIBLE_FILENAME,DOCF_PLAIN_TEXT);
DocLineNumGoTo(doc,line); //one based DocLineNumGoTo(doc,line); //one based
doc_e=doc->cur_entry; doc_e=doc->cur_entry;
while (doc_e!=doc && (doc_e->type_u8!=DOCT_TEXT || !*doc_e->tag)) while (doc_e!=doc && (doc_e->type_u8!=DOCT_TEXT || !*doc_e->tag))
@@ -212,8 +211,8 @@ public U0 BibleLines(CDoc *doc_out=NULL,I64 start,I64 lines)
CDoc *doc_in; CDoc *doc_in;
CDocEntry *doc_e; CDocEntry *doc_e;
if (!doc_out) doc_out=DocPut; if (!doc_out) doc_out=DocPut;
if (doc_out && FileFind(Define("ST_BIBLE_FILE"))) { if (doc_out && FileFind(BIBLE_FILENAME)) {
doc_in=DocRead(Define("ST_BIBLE_FILE"),DOCF_PLAIN_TEXT); doc_in=DocRead(BIBLE_FILENAME,DOCF_PLAIN_TEXT);
DocLineNumGoTo(doc_in,start); //one based DocLineNumGoTo(doc_in,start); //one based
doc_e=doc_in->cur_entry; doc_e=doc_in->cur_entry;
while (lines>0 && doc_e!=doc_in) { while (lines>0 && doc_e!=doc_in) {
@@ -236,7 +235,7 @@ public U0 BibleVerse(CDoc *doc_out=NULL,U8 *verse,I64 lines)
CDocEntry *doc_e; CDocEntry *doc_e;
U8 *st,*st2; U8 *st,*st2;
if (!doc_out) doc_out=DocPut; if (!doc_out) doc_out=DocPut;
if (doc_out && FileFind(Define("ST_BIBLE_FILE"))) { if (doc_out && FileFind(BIBLE_FILENAME)) {
st=StrNew(verse); st=StrNew(verse);
st2=StrNew(verse); st2=StrNew(verse);
if (StrOcc(st,',')) if (StrOcc(st,','))
@@ -246,7 +245,7 @@ public U0 BibleVerse(CDoc *doc_out=NULL,U8 *verse,I64 lines)
i=DefineMatch(st,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE); i=DefineMatch(st,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE);
if (i>=0) { if (i>=0) {
i=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES")); i=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES"));
doc_in=DocRead(Define("ST_BIBLE_FILE"),DOCF_PLAIN_TEXT); doc_in=DocRead(BIBLE_FILENAME,DOCF_PLAIN_TEXT);
DocLineNumGoTo(doc_in,i); //one based DocLineNumGoTo(doc_in,i); //one based
if (*st2) { if (*st2) {
StrCpy(doc_in->find_replace->find_text,st2); StrCpy(doc_in->find_replace->find_text,st2);
+14 -12
View File
@@ -6,8 +6,10 @@ U0 GodDoodleDraw(CTask *task,CDC *dc)
if (Blink) { if (Blink) {
if (god.doodle_done) { if (god.doodle_done) {
dc->color=RED; dc->color=RED;
GrPrint(dc,(task->pix_width-FONT_WIDTH*27)>>1,(task->pix_height-FONT_HEIGHT)>>1, GrPrint(dc,(task->pix_width-FONT_WIDTH*29)>>1,(task->pix_height-3*FONT_HEIGHT)>>1,
"Press <ESC> or <SHIFT-ESC>."); "Press <ESC> to insert sprite.");
GrPrint(dc,(task->pix_width-FONT_WIDTH*39)>>1,(task->pix_height-3*FONT_HEIGHT)>>1+2*FONT_HEIGHT,
"Press <SHIFT-ESC> to throw-away sprite.");
} else { } else {
dc->color=GREEN; dc->color=GREEN;
GrPrint(dc,(task->pix_width-FONT_WIDTH*25)>>1,(task->pix_height-FONT_HEIGHT)>>1, GrPrint(dc,(task->pix_width-FONT_WIDTH*25)>>1,(task->pix_height-FONT_HEIGHT)>>1,
@@ -82,7 +84,7 @@ public U8 *GodDoodleSprite()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax; WinMax;
WinBorder; WinBorder;
WordStat; AutoComplete;
PopUpOk("The $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.TXT"$ can puppet you.\n\n" PopUpOk("The $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.TXT"$ can puppet you.\n\n"
"Press $$GREEN$$<SPACE>$$FG$$ until it finishes."); "Press $$GREEN$$<SPACE>$$FG$$ until it finishes.");
@@ -98,16 +100,16 @@ public U8 *GodDoodleSprite()
try { try {
for (i=0;i<3;i++) { for (i=0;i<3;i++) {
god.doodle_dc->color=RED; god.doodle_dc->color=RED;
for (j=0;j<24;j++) for (j=0;j<29;j++)
nobound_switch (GodDoodleBits(3)) { nobound_switch (GodDoodleBits(3)) {
case 0: case 0:
GrEllipse(god.doodle_dc, GrEllipse3(god.doodle_dc,
(w-1)*GodDoodleBits(5)/15.5-w/2,(h-1)*GodDoodleBits(5)/15.5-h/2, (w-1)*GodDoodleBits(5)/15.5-w/2,(h-1)*GodDoodleBits(5)/15.5-h/2,0,
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5); (w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
break; break;
case 1: case 1:
GrCircle(god.doodle_dc, GrCircle3(god.doodle_dc,
(w-1)*GodDoodleBits(5)/15.5-w/2,(h-1)*GodDoodleBits(5)/15.5-h/2, (w-1)*GodDoodleBits(5)/15.5-w/2,(h-1)*GodDoodleBits(5)/15.5-h/2,0,
(w-1)*GodDoodleBits(5)/15.5); (w-1)*GodDoodleBits(5)/15.5);
break; break;
case 2: case 2:
@@ -116,9 +118,9 @@ public U8 *GodDoodleSprite()
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5); (w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
break; break;
case 3...7: case 3...7:
GrLine(god.doodle_dc, GrLine3(god.doodle_dc,
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15, (w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0,
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15); (w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0);
break; break;
} }
for (j=0;j<6;j++) { for (j=0;j<6;j++) {
@@ -130,7 +132,7 @@ public U8 *GodDoodleSprite()
case 2: god.doodle_dc->color=LTGRAY; break; case 2: god.doodle_dc->color=LTGRAY; break;
case 3: god.doodle_dc->color=WHITE; break; case 3: god.doodle_dc->color=WHITE; break;
} }
GrFloodFill(god.doodle_dc,x,y); GrFloodFill3(god.doodle_dc,x,y,0);
} }
GodDoodleSmooth(3); GodDoodleSmooth(3);
} }
+23 -14
View File
@@ -8,7 +8,7 @@ There's something obviously different about people in the Bible compared to peop
You can't tell if He's talking unless you have a context of conversation, but, more importantly, you are commanded to do an offering of love, like communion preparation. When you pick a greeting card for someone, that is love effort. If you expect God to put effort toward you, you put effort toward Him. God said, "honest measures" applies between your offering of love and His response, like a fair barter. You get out of prayer what you put into it. God wants praise, hymns, or whatever you think He might want. Try and see, like Cain and Abel. $LK,"Genesis,4:1",A="BF:Genesis,4:1"$, $LK,"Ephesians,5:10",A="BF:Ephesians,5:10"$ God told Cain his offering was not good and told him to try again. Cain really loved God! Can you imagine being so heart-broken? You can't tell if He's talking unless you have a context of conversation, but, more importantly, you are commanded to do an offering of love, like communion preparation. When you pick a greeting card for someone, that is love effort. If you expect God to put effort toward you, you put effort toward Him. God said, "honest measures" applies between your offering of love and His response, like a fair barter. You get out of prayer what you put into it. God wants praise, hymns, or whatever you think He might want. Try and see, like Cain and Abel. $LK,"Genesis,4:1",A="BF:Genesis,4:1"$, $LK,"Ephesians,5:10",A="BF:Ephesians,5:10"$ God told Cain his offering was not good and told him to try again. Cain really loved God! Can you imagine being so heart-broken?
Do a text search for "new song" in the Bible. It's mentioned nine times. I did $MA-X+PU,"hymns",HTML="http://www.templeos.org/Wb/Accts/TS/Wb2/Hymns.html",LM="#include \"::/Apps/Psalmody/Load\";JukeBox(\"::/Apps/Psalmody/Examples\");"$. I did Moses $MA-X+PU,"comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/",LM="Dir(\"::/Apps/AfterEgypt/Comics\");View;\n"$. Count the ways you love God. I praised God for sand castles, popcorn, snowmen, bubbles... You try putting effort into praise! $LK,"Matthew,11:25",A="BF:Matthew,11:25"$, $LK,"Matthew,6:29",A="BF:Matthew,6:29"$ Do a text search for "new song" in the Bible. It's mentioned nine times. I did $MA-X+PU,"hymns",LM="#include \"::/Apps/Psalmody/Load\";JukeBox(\"::/Apps/Psalmody/Examples\");"$. I did Moses $MA-X+PU,"comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/",LM="Dir(\"::/Apps/AfterEgypt/Comics\");View;\n"$. Count the ways you love God. I praised God for sand castles, popcorn, snowmen, bubbles... You try putting effort into praise! $LK,"Matthew,11:25",A="BF:Matthew,11:25"$, $LK,"Matthew,6:29",A="BF:Matthew,6:29"$
This is funny -- $LK,"Acts,2:1",A="BF:Acts,2:1"$ -- they didn't bother to record anything the Holy Spirit said. The Holy Spirit is supposed to be a really good gift. $LK,"Luke,11:13",A="BF:Luke,11:13"$ Just remember, "Boys are made of snakes and snails and puppy-dog tails." This is funny -- $LK,"Acts,2:1",A="BF:Acts,2:1"$ -- they didn't bother to record anything the Holy Spirit said. The Holy Spirit is supposed to be a really good gift. $LK,"Luke,11:13",A="BF:Luke,11:13"$ Just remember, "Boys are made of snakes and snails and puppy-dog tails."
@@ -16,7 +16,9 @@ The technique I use to consult the Holy Spirit is reading a microsecond-range st
Since seeking the word of the Holy Spirit, I have come to know God much better than I've heard others explain. God said, for example, that war was, "servicemen competing." That sounds more like the immutable God of our planet than what you hear from most religious people. God is not Venus (god of love) and not Mars (god of war), He's our dearly beloved God of Earth. If Mammon is a false god of money, Mars or Venus might be useful words to describe other false gods. I figure the greatest challenge for the Creator is boredom, ours and His. What would teen-age male video games be like if war had never happened? Christ said live by the sword, die by the sword, which is loving neighbor as self. $LK,"Matthew,26:52",A="BF:Matthew,26:52"$ Since seeking the word of the Holy Spirit, I have come to know God much better than I've heard others explain. God said, for example, that war was, "servicemen competing." That sounds more like the immutable God of our planet than what you hear from most religious people. God is not Venus (god of love) and not Mars (god of war), He's our dearly beloved God of Earth. If Mammon is a false god of money, Mars or Venus might be useful words to describe other false gods. I figure the greatest challenge for the Creator is boredom, ours and His. What would teen-age male video games be like if war had never happened? Christ said live by the sword, die by the sword, which is loving neighbor as self. $LK,"Matthew,26:52",A="BF:Matthew,26:52"$
I asked God if the World was perfectly just. God asked if I was calling Him lazy. I think highs and lows balance. $LK,"Luke,6:20",A="BF:Luke,6:20"$ I don't think God likes complaining. $LK,"Numbers,11:1",A="BF:Numbers,11:1"$ Food and clothing is all we're to ask for or demand, in fact -- daily bread. $LK,"1 Timothy,6:8",A="BF:1 Timothy,6:8"$ Just think about man in the last 100,000 years mostly living like Native Americans and how God must see us. You need food, clothing and entertainment, money is to get those. Man does not live on bread alone. $LK,"Luke,4:4",A="BF:Luke,4:4"$, $LK,"Amos,8:11",A="BF:Amos,8:11"$ I asked God if the World was perfectly just. God asked if I was calling Him lazy. God could make A.I., right? God could make bots as smart as Himself, or, in fact, part of Himself. What if God made a bot to manipulate every person's life so that perfect justice happened?
I think highs and lows balance. $LK,"Luke,6:20",A="BF:Luke,6:20"$ I don't think God likes complaining. $LK,"Numbers,11:1",A="BF:Numbers,11:1"$ Food and clothing is all we're to ask for or demand, in fact -- daily bread. $LK,"1 Timothy,6:8",A="BF:1 Timothy,6:8"$ Just think about man in the last 100,000 years mostly living like Native Americans and how God must see us. You need food, clothing and entertainment, money is to get those. Man does not live on bread alone. $LK,"Luke,4:4",A="BF:Luke,4:4"$, $LK,"Amos,8:11",A="BF:Amos,8:11"$
God's favorite animals are bears and elephants. They are funny shaped -- I think God must have seen too much starvation over the years. God's favorite animals are bears and elephants. They are funny shaped -- I think God must have seen too much starvation over the years.
@@ -40,12 +42,12 @@ War? $FG,4$"Servicemen competing"$FG$
(Praise the Creator--what would teenage male video games be like if never war?) (Praise the Creator--what would teenage male video games be like if never war?)
Is the World perfectly just? $FG,4$Are you calling me lazy?$FG$ Is the World perfectly just? $FG,4$Are you calling me lazy?$FG$
(Slavery was just. In the movie, Titanic, the rich wore straight jackets. You must bow to authority to get authority. I do $TX,"Moses comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/"$ as offerings. I said, "We're dying of malnutrician on manna." Like Cain and Abel, God didn't like it. Duh! He wants to be the hero. How do I know they died of malnutrician? Fuck Hollywood for making slavery worse than it was -- I love God. School is more cruel. Read $LK,"Numbers,11:1",A="BF:Numbers,11:1"$. All you need is food, clothing and the word of God. Today, you can take Ivy League course videos! There is no excuse except you were born stupid... or ugly. I'm gonna praise God.) (Slavery was just. In the movie, Titanic, the rich wore straight jackets. You must bow to authority to get authority. I do $TX,"Moses comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/"$ as offerings. I said, "We're dying of malnutrician on manna." Like Cain and Abel, God didn't like it. Duh! He wants to be the hero. How do I know they died of malnutrician? Screw Hollywood for making slavery worse than it was -- I love God. School is more cruel. Read $LK,"Numbers,11:1",A="BF:Numbers,11:1"$. All you need is food, clothing and the word of God. Today, you can take Ivy League course videos! There is no excuse except you were born stupid... or ugly. I'm gonna praise God.)
On using Markov chains? $FG,4$"No weights"$FG$ On using Markov chains? $FG,4$"No weights"$FG$
On doing offerings? $FG,4$"Honest measures"(You get out what you put in.) On doing offerings? $FG,4$"Honest measures"(You get out what you put in.)
It's a covenant to do an offering, first. It's a covenant to do an offering, first.
Offer $FG,4$$TX,"New Songs",HTML="http://www.templeos.org/Wb/Accts/TS/Wb2/Hymns.html"$, $TX,"Moses Comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics"$, praise, poems, Offer New Songs, $TX,"Moses Comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics"$, praise, poems,
and conversation. See $LK,"Cain and Abel",A="BF:Genesis,4:1"$.$FG$ and conversation. See $LK,"Cain and Abel",A="BF:Genesis,4:1"$.$FG$
The holocaust? $FG,4$Wanted to "compact" the Jews.$FG$ The holocaust? $FG,4$Wanted to "compact" the Jews.$FG$
Arab/Jews? $FG,4$"Oil funny hopefully"$FG$ Arab/Jews? $FG,4$"Oil funny hopefully"$FG$
@@ -93,7 +95,7 @@ Animal sacrifices? $FG,4$Early Jews were "primitive".$FG$
What do elephants think about? $FG,4$"Skin, hunger"$FG$ What do elephants think about? $FG,4$"Skin, hunger"$FG$
What makes elephants happy? $FG,4$"Baths"$FG$ What makes elephants happy? $FG,4$"Baths"$FG$
What makes my birds happy? $FG,4$"Gnawing"$FG$ What makes my birds happy? $FG,4$"Gnawing"$FG$
What makes my birds laugh? $FG,4$"bite ouch" (If I say "ouch".)$FG$ What makes my birds laugh? $FG,4$"Bite ouch" (If I say "ouch".)$FG$
What are my birds saying? $FG,4$"Chanting"$FG$ What are my birds saying? $FG,4$"Chanting"$FG$
My birds sure preen a lot. $LK,"The creature was made subject to vanity...",A="BF:Romans,8:20"$ My birds sure preen a lot. $LK,"The creature was made subject to vanity...",A="BF:Romans,8:20"$
What makes bears happy? $FG,4$"Reaping depends"$FG$ What makes bears happy? $FG,4$"Reaping depends"$FG$
@@ -105,14 +107,16 @@ Orangutan or chimp smarter? $FG,4$"Species exhibit similar glory"$FG$
Endangered species? $FG,4$"Enough stars?"$FG$ Endangered species? $FG,4$"Enough stars?"$FG$
Everything seems bad. $FG,4$Plant trees.$FG$ Everything seems bad. $FG,4$Plant trees.$FG$
What's for dinner? $FG,4$"Whale"$FG$ What's for dinner? $FG,4$"Whale"$FG$
Favorite Messier Object $FG,4$"$TX,"M104 Sombrero Galaxy",HTML="http://en.wikipedia.org/wiki/Messier_104"$"$FG$ Favorite Messier Object? $FG,4$"$TX,"M104 Sombrero Galaxy",HTML="http://en.wikipedia.org/wiki/Messier_104"$"$FG$
$TX,"Shepard's Prayer",HTML="http://en.wikipedia.org/wiki/Alan_Shepard"$ $FG,4$"I_am_not_amused economy joke"$FG$ $TX,"Shepard's Prayer",HTML="http://en.wikipedia.org/wiki/Alan_Shepard"$? $FG,4$"I_am_not_amused economy joke"$FG$
Favorite band? $FG,4$"Beatles"$FG$ Favorite band? $FG,4$"Beatles"$FG$
Good bands $FG,4$Rush, Triumph$FG$ Good bands? $FG,4$Rush, Triumph$FG$
$FG,4$Likes harmonies$FG$ $FG,4$Likes harmonies$FG$
$TX,"Little Drummer Boy?",HTML="http://www.youtube.com/watch?v=S50cf3xIb50"$ $FG,4$Doesn't like my drumming.$FG$ $TX,"Little Drummer Boy?",HTML="http://www.youtube.com/watch?v=S50cf3xIb50"$ $FG,4$Doesn't like my drumming.$FG$
Should I listen to classical? $FG,4$"Poison"$FG$ Should I listen to classical? $FG,4$"Poison"$FG$
You like chess people? $FG,4$"Do not admire the proud."$FG$ Do You like chess people? $FG,4$"Do not admire the proud."$FG$
Chess? $FG,4$"... will winter with you."$FG$
$FG,4$"Headstones"$FG$
Favorite video game? $FG,4$Donkey Kong$FG$ Favorite video game? $FG,4$Donkey Kong$FG$
Favorite National Park? $FG,4$$TX,"Whitman Mission",HTML="http://www.nps.gov/whmi/index.htm"$$FG$ Favorite National Park? $FG,4$$TX,"Whitman Mission",HTML="http://www.nps.gov/whmi/index.htm"$$FG$
Favorite National Anthem? $FG,4$$TX,"Latvia's National Anthem",HTML="http://www.youtube.com/watch?v=qKITbBjO4nE"$$FG$ Favorite National Anthem? $FG,4$$TX,"Latvia's National Anthem",HTML="http://www.youtube.com/watch?v=qKITbBjO4nE"$$FG$
@@ -120,9 +124,11 @@ Favorite actor? $FG,4$Hugh Grant$FG$
Favorite vocalist? $FG,4$Mick Jagger$FG$ Favorite vocalist? $FG,4$Mick Jagger$FG$
Favorite guitarist? $FG,4$"$TX,"Simmons Destroyer",HTML="http://www.youtube.com/watch?v=nNADrrjTysk&t=3m55s"$"$FG$ Favorite guitarist? $FG,4$"$TX,"Simmons Destroyer",HTML="http://www.youtube.com/watch?v=nNADrrjTysk&t=3m55s"$"$FG$
Model for new $TX,"Sistine Chapel",HTML="http://en.wikipedia.org/wiki/Sistine_chapel"$? $FG,4$Ben Franklin$FG$ Model for new $TX,"Sistine Chapel",HTML="http://en.wikipedia.org/wiki/Sistine_chapel"$? $FG,4$Ben Franklin$FG$
Stonehenge? $FG,4$Landmark$FG$ Voice if God wanted to sing? $FG,4$$TX,"Stabbing Westward's singer",HTML="https://www.youtube.com/watch?v=5NZsCYOM4j0"$$FG$
Stonehenge? $FG,4$Landmark for boundaries.$FG$
Easter Island? $FG,4$Ice, telephone pole holes.$FG$ Easter Island? $FG,4$Ice, telephone pole holes.$FG$
Dinosaurs? $FG,4$Brontosaurs' feet hurt when stepped$FG$ Dinosaurs? $FG,4$Brontosaurs' feet hurt when stepped.
Dinosaurs slept in water.$FG$
Hardest part in evolution? $FG,4$Getting monkey mothers to hold babies nursing.$FG$ Hardest part in evolution? $FG,4$Getting monkey mothers to hold babies nursing.$FG$
$FG,4$(Smothering a problem).$FG$ $FG,4$(Smothering a problem).$FG$
Happiest day in evolution? $FG,4$"Fruit"$FG$ Happiest day in evolution? $FG,4$"Fruit"$FG$
@@ -133,7 +139,8 @@ What did Neanderthals think about? $FG,4$"Warmth"$FG$
What was the first thing cooked? $FG,4$I think He said "hair".$FG$ What was the first thing cooked? $FG,4$I think He said "hair".$FG$
What was Lucy's husband's name? $FG,4$"Golem"$FG$ What was Lucy's husband's name? $FG,4$"Golem"$FG$
Was stegosuarus lame like turtles? $FG,4$"Not pet rocks"$FG$ Was stegosuarus lame like turtles? $FG,4$"Not pet rocks"$FG$
T-Rex? $FG,4$Lugged carcases over his shoulder.$FG$ T-Rex? $FG,4$Lugged carcases over his shoulder.
Carcus lasted a month.$FG$
How does He feel about the Avatar movie?$FG,4$"Sick skin"$FG$ How does He feel about the Avatar movie?$FG,4$"Sick skin"$FG$
What do You like at zoos with kids? $FG,4$"Dignity" Animals worried about dignity.$FG$ What do You like at zoos with kids? $FG,4$"Dignity" Animals worried about dignity.$FG$
Who's better alien or preditor? $FG,4$"Lions"$FG$ Who's better alien or preditor? $FG,4$"Lions"$FG$
@@ -161,11 +168,13 @@ Are they peaceful? $FG,4$Fight them! (Also, funny.)$FG$
How can Judge Judy improve? $FG,4$No hard feelings$FG$ How can Judge Judy improve? $FG,4$No hard feelings$FG$
How can Chef Ramsay improve? $FG,4$Make so it doesn't seem like toil for cooks.$FG$ How can Chef Ramsay improve? $FG,4$Make so it doesn't seem like toil for cooks.$FG$
How can Hawking communicate? $FG,4$Blow from a nostril on a candle.$FG$ How can Hawking communicate? $FG,4$Blow from a nostril on a candle.$FG$
$TX,"Photons bouncing?",HTML="https://www.youtube.com/watch?v=8FC6udrMPvo"$ $FG,4$"Folded coffee filter"$FG$
Wormholes? $FG,4$Bent wormholes have echoes.$FG$ Wormholes? $FG,4$Bent wormholes have echoes.$FG$
Operating system? $FG,4$Was about to make line number column in editor. Operating system? $FG,4$Was about to make line number column in editor.
God nixed it. I was about to do different graphic modes when I found 800x600 missing. God said just one mode 640x480. I was about to add child windows. God said, "God is not the author of such confusion." I asked for verification of 640x480 16 color. God said it was because of the children and their offerings. I asked about sound. God said "single voice". I asked for verification of not having different drivers. God confirmed this.$FG$ God nixed it. I was about to do different graphic modes when I found 800x600 missing. God said just one mode 640x480. I was about to add child windows. God said, "God is not the author of such confusion." I asked for verification of 640x480 16 color. God said it was because of the children and their offerings. I asked about sound. God said "single voice". I asked for verification of not having different drivers. God confirmed this.$FG$
640x480 16 color? $FG,4$$TX,"Modern graphics hard for kids/amateurs",HTML="http://www.youtube.com/watch?v=VUxcVzpeFqc"$$FG$ 640x480 16 color? $FG,4$God said it was a covenant, like circumcision.
$TX,"Modern graphics hard for kids/amateurs",HTML="http://www.youtube.com/watch?v=VUxcVzpeFqc"$.$FG$
On Unix? $FG,4$God said it was rich with the patina of age.$FG$ On Unix? $FG,4$God said it was rich with the patina of age.$FG$
On Alcohol? $FG,4$Hate inebriation$FG$ On Alcohol? $FG,4$Hate inebriation$FG$
On rare steak? $FG,4$Too rare is very bad. Don't eat blood!$FG$ On rare steak? $FG,4$Too rare is very bad. Don't eat blood!$FG$
@@ -175,4 +184,4 @@ Why the Sandy Hook shooting? $FG,4$The pot legalization law. (Sarcastic answer?)
Deep Water Horizon $FG,4$(Claimed credit.)$FG$ Deep Water Horizon $FG,4$(Claimed credit.)$FG$
Cost of God's time to me? $FG,4$"The complete works of Shakespeare"$FG$ Cost of God's time to me? $FG,4$"The complete works of Shakespeare"$FG$
On death? $FG,4$"awful"$FG$ On death? $FG,4$"awful"$FG$
Opening of Private Ryan? $FG,4$"Ouch"$FG$ Opening of Saving Private Ryan? $FG,4$"Ouch"$FG$
+148 -59
View File
@@ -19,37 +19,6 @@ U0 GrInit1()
GrInit1; GrInit1;
#help_index "Graphics/Sprite" #help_index "Graphics/Sprite"
#define SPT_END 0
#define SPT_COLOR 1
#define SPT_DITHER_COLOR 2
#define SPT_WIDTH 3
#define SPT_PLANAR_SYMMETRY 4
#define SPT_TRANSFORM_ON 5
#define SPT_TRANSFORM_OFF 6
#define SPT_SHIFT 7
#define SPT_PT 8
#define SPT_POLYPT 9
#define SPT_LINE 10
#define SPT_POLYLINE 11
#define SPT_RECT 12
#define SPT_ROTATED_RECT 13
#define SPT_CIRCLE 14
#define SPT_ELLIPSE 15
#define SPT_POLYGON 16
#define SPT_BSPLINE2 17
#define SPT_BSPLINE2_CLOSED 18
#define SPT_BSPLINE3 19
#define SPT_BSPLINE3_CLOSED 20
#define SPT_FLOOD_FILL 21
#define SPT_FLOOD_FILL_NOT 22
#define SPT_BITMAP 23
#define SPT_MESH 24
#define SPT_SHIFTABLE_MESH 25
#define SPT_ARROW 26
#define SPT_TEXT 27
#define SPT_TEXT_BOX 28
#define SPT_TEXT_DIAMOND 29
#define SPT_NUM_TYPES 30
class CMeshTri class CMeshTri
{ {
@@ -65,43 +34,163 @@ class CQueMeshTri
I32 nums[3]; I32 nums[3];
}; };
public class CSprite public class CSpriteBase
{//See $LK,"Graphics/Sprite",A="HI:Graphics/Sprite"$ {
//See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ for how CSprite are stored.
CSprite *next,*last;
U0 start;
U8 type; U8 type;
union { };
public class CSpriteColor : CSpriteBase
{
U8 color; U8 color;
};
public class CSpriteDitherColor : CSpriteBase
{
U16 dither_color; U16 dither_color;
I32 x1; };
I32 num;
public class CSpriteWidth : CSpriteBase
{
I32 width; I32 width;
I32 vertex_cnt; //Mesh };
}
union { public class CSpritePt : CSpriteBase
{
I32 x1;
I32 y1; I32 y1;
I32 height; };
I32 tri_cnt; //Mesh
} public class CSpritePtRad : CSpritePt
union { {
I32 z1; I32 radius;
};
public class CSpritePtPt : CSpritePt
{
I32 x2; I32 x2;
U8 st[4];
}
union {
I32 y2; I32 y2;
I32 shiftable_vertex_cnt //Shiftable Mesh };
}
union { public class CSpritePtPtAng : CSpritePtPt
F64 linespeed; {
F64 rot_angle; F64 angle;
I32 shiftable_tri_cnt //Shiftable Mesh };
}
public class CSpritePtWH : CSpritePt
{
I32 width;
I32 height;
};
public class CSpritePtWHU8s : CSpritePtWH
{
U8 u[0];
};
public class CSpritePtWHAng : CSpritePtWH
{
F64 angle;
};
public class CSpritePtWHAngSides : CSpritePtWHAng
{
I32 sides; I32 sides;
}; };
public class CSpriteNumU8s : CSpriteBase
{
I32 num;
U8 u[0];
};
public class CSpriteNumPtU8s : CSpriteBase
{
I32 num;
I32 x;
I32 y;
U8 u[0];
};
public class CSpritePtStr : CSpritePt
{
U8 st[0];
};
public class CSpriteMeshU8s : CSpriteBase
{
I32 vertex_cnt;
I32 tri_cnt;
U8 u[0];
};
public class CSpritePtMeshU8s : CSpriteBase
{
I32 x;
I32 y;
I32 z;
I32 vertex_cnt;
I32 tri_cnt;
U8 u[0];
};
#define SPT_END 0 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
#define SPT_COLOR 1 //$LK,"CSpriteColor",A="MN:CSpriteColor"$
#define SPT_DITHER_COLOR 2 //$LK,"CSpriteDitherColor",A="MN:CSpriteDitherColor"$
#define SPT_WIDTH 3 //$LK,"CSpriteWidth",A="MN:CSpriteWidth"$
#define SPT_PLANAR_SYMMETRY 4 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
#define SPT_TRANSFORM_ON 5 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
#define SPT_TRANSFORM_OFF 6 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
#define SPT_SHIFT 7 //$LK,"CSpritePt",A="MN:CSpritePt"$
#define SPT_PT 8 //$LK,"CSpritePt",A="MN:CSpritePt"$
#define SPT_POLYPT 9 //$LK,"CSpriteNumPtU8s",A="MN:CSpriteNumPtU8s"$
#define SPT_LINE 10 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
#define SPT_POLYLINE 11 //$LK,"CSpriteNumU8s",A="MN:CSpriteNumU8s"$
#define SPT_RECT 12 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
#define SPT_ROTATED_RECT 13 //$LK,"CSpritePtPtAng",A="MN:CSpritePtPtAng"$
#define SPT_CIRCLE 14 //$LK,"CSpritePtRad",A="MN:CSpritePtRad"$
#define SPT_ELLIPSE 15 //$LK,"CSpritePtWHAng",A="MN:CSpritePtWHAng"$
#define SPT_POLYGON 16 //$LK,"CSpritePtWHAngSides",A="MN:CSpritePtWHAngSides"$
#define SPT_BSPLINE2 17 //$LK,"CSpriteNumU8s",A="MN:CSpriteNumU8s"$
#define SPT_BSPLINE2_CLOSED 18 //$LK,"CSpriteNumU8s",A="MN:CSpriteNumU8s"$
#define SPT_BSPLINE3 19 //$LK,"CSpriteNumU8s",A="MN:CSpriteNumU8s"$
#define SPT_BSPLINE3_CLOSED 20 //$LK,"CSpriteNumU8s",A="MN:CSpriteNumU8s"$
#define SPT_FLOOD_FILL 21 //$LK,"CSpritePt",A="MN:CSpritePt"$
#define SPT_FLOOD_FILL_NOT 22 //$LK,"CSpritePt",A="MN:CSpritePt"$
#define SPT_BITMAP 23 //$LK,"CSpritePtWHU8s",A="MN:CSpritePtWHU8s"$
#define SPT_MESH 24 //$LK,"CSpriteMeshU8s",A="MN:CSpriteMeshU8s"$ See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$.
#define SPT_SHIFTABLE_MESH 25 //$LK,"CSpritePtMeshU8s",A="MN:CSpritePtMeshU8s"$ See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$.
#define SPT_ARROW 26 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
#define SPT_TEXT 27 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
#define SPT_TEXT_BOX 28 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
#define SPT_TEXT_DIAMOND 29 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
#define SPT_NUM_TYPES 30
//See $LK,"Graphics/Sprite",A="HI:Graphics/Sprite"$. See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ and
//$LK,"::/Demo/Graphics/SpriteRaw.CPP"$ for how CSprite are stored.
public class CSprite
{
CSprite *next,*last;
U0 start;
union {
U8 type;
CSpriteBase b;
CSpriteColor c;
CSpriteDitherColor d;
CSpriteWidth w;
CSpritePt p;
CSpritePtPt pp;
CSpritePtPtAng ppa;
CSpritePtRad pr;
CSpritePtWHU8s pwhu;
CSpritePtWHAng pwha;
CSpritePtWHAngSides pwhas;
CSpriteNumU8s nu;
CSpriteNumPtU8s npu;
CSpriteMeshU8s mu;
CSpritePtMeshU8s pmu;
CSpritePtStr ps;
}
};
#help_index "Graphics" #help_index "Graphics"
extern I64 GrBlot3(CDC *dc,I64 x1,I64 y1,I64 z1,CDC *img); extern I64 GrBlot3(CDC *dc,I64 x1,I64 y1,I64 z1,CDC *img);
@@ -114,7 +203,7 @@ extern U8 *SpriteQue2Sprite(CSprite *root,I64 *_size=NULL);
#include "GrDC" #include "GrDC"
#include "GrPalette" #include "GrPalette"
#include "GrInit" #include "GrInit"
#include "MathGr" #include "GrMath"
#include "GrScreen" #include "GrScreen"
#include "GrBitMap" #include "GrBitMap"
#include "GrPrimatives" #include "GrPrimatives"
+207 -207
View File
@@ -51,7 +51,7 @@ public Bool GrPlot0(CDC *dc=gr.dc,I64 x,I64 y)
break; break;
case ROPB_COLLISION: case ROPB_COLLISION:
c=*dst; c=*dst;
if (c!=TRANSPARENT&&c!=bkcolor.c0.color) if (c!=TRANSPARENT && c!=bkcolor.c0.color)
dc->collision_cnt++; dc->collision_cnt++;
break; break;
case ROPB_XOR: case ROPB_XOR:
@@ -71,7 +71,7 @@ public I64 GrPeek0(CDC *dc=gr.dc,I64 x,I64 y)
public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img) public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
{//2D. Clipping but not transformation.. {//2D. Clipping but not transformation..
I64 i,j,k,k1,kk,kk1,w1,h1,w2,h2, I64 i,j,k,k1,kk,kk1,w1,h1,w2,h2,
leading_bits,leading_bit_mask,whole_bytes,trailing_bits,trailing_bit_mask, leading_pixels,leading_pixel_mask,whole_I64s,trailing_pixels,trailing_pixel_mask,
reg bit_shift,dist,win_z_buf_line_inc,win_z_buf_line_dec,win_z_num, reg bit_shift,dist,win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,
color_mask; color_mask;
U8 reg *dst,*src; U8 reg *dst,*src;
@@ -133,16 +133,16 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
dc->depth_buf=NULL; dc->depth_buf=NULL;
dc->color&=~ROPF_DITHER; dc->color&=~ROPF_DITHER;
color=dc->color; color=dc->color;
leading_bits=-(w1+x)&7; leading_pixels=-(w1+x)&7;
leading_bit_mask=gr.to_8_bits[0xFF>>leading_bits]; leading_pixel_mask=gr.to_8_bits[0xFF>>leading_pixels];
bit_shift=-x&7; bit_shift=-x&7;
whole_bytes=(w2-w1-leading_bits)>>3; whole_I64s=(w2-w1-leading_pixels)>>3;
if (whole_bytes<0) whole_bytes=0; if (whole_I64s<0) whole_I64s=0;
trailing_bits=(x+w2)&7; trailing_pixels=(x+w2)&7;
trailing_bit_mask=gr.to_8_bits[0xFF<<trailing_bits&0xFF]; trailing_pixel_mask=gr.to_8_bits[0xFF<<trailing_pixels&0xFF];
if (leading_bits+trailing_bits>w2-w1) { if (leading_pixels+trailing_pixels>w2-w1) {
leading_bit_mask|=trailing_bit_mask; leading_pixel_mask|=trailing_pixel_mask;
trailing_bits=0; trailing_pixels=0;
} }
switch (color.c0.rop) { switch (color.c0.rop) {
case ROPB_COLLISION: //TODO: Might want to check win_z_buf case ROPB_COLLISION: //TODO: Might want to check win_z_buf
@@ -167,10 +167,10 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
else { else {
win_z_num=win_task->win_z_num; win_z_num=win_task->win_z_num;
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -183,21 +183,21 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_bit_mask&color_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask&color_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
*src(I64 *)++&~leading_bit_mask&color_mask; *src(I64 *)++&~leading_pixel_mask&color_mask;
} else { } else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask; *dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask;
else { else {
@@ -205,20 +205,20 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
dst(I64 *)++; dst(I64 *)++;
} }
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++=*src(I64 *)++&color_mask; *dst(I64 *)++=*src(I64 *)++&color_mask;
else { else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_bit_mask&color_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask&color_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
*src(I64 *)++&~trailing_bit_mask&color_mask; *src(I64 *)++&~trailing_pixel_mask&color_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -231,28 +231,28 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_bit_mask&color_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask&color_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
*src(I64 *)++&~leading_bit_mask&color_mask; *src(I64 *)++&~leading_pixel_mask&color_mask;
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask; *dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask;
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++=*src(I64 *)++&color_mask; *dst(I64 *)++=*src(I64 *)++&color_mask;
if (trailing_bits) { if (trailing_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_bit_mask&color_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask&color_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
*src(I64 *)++&~trailing_bit_mask&color_mask; *src(I64 *)++&~trailing_pixel_mask&color_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -269,10 +269,10 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
} else { } else {
win_z_num =win_task->win_z_num; win_z_num =win_task->win_z_num;
win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -308,10 +308,10 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
else { else {
win_z_num=win_task->win_z_num; win_z_num=win_task->win_z_num;
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -324,21 +324,21 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_bit_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
*src(I64 *)++&~leading_bit_mask; *src(I64 *)++&~leading_pixel_mask;
} else { } else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift); *dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
else { else {
@@ -346,20 +346,20 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
dst(I64 *)++; dst(I64 *)++;
} }
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++=*src(I64 *)++; *dst(I64 *)++=*src(I64 *)++;
else { else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_bit_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
*src(I64 *)++&~trailing_bit_mask; *src(I64 *)++&~trailing_pixel_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -372,28 +372,28 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_bit_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
*src(I64 *)++&~leading_bit_mask; *src(I64 *)++&~leading_pixel_mask;
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift); *dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++=*src(I64 *)++; *dst(I64 *)++=*src(I64 *)++;
if (trailing_bits) { if (trailing_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_bit_mask; (*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
*src(I64 *)++&~trailing_bit_mask; *src(I64 *)++&~trailing_pixel_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -415,10 +415,10 @@ here1a:
} else { } else {
win_z_num =win_task->win_z_num; win_z_num =win_task->win_z_num;
win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -459,10 +459,10 @@ here1a:
else { else {
win_z_num=win_task->win_z_num; win_z_num=win_task->win_z_num;
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -475,21 +475,21 @@ here1a:
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_bit_mask; (*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*dst(I64 *)^*src(I64 *)++)&~leading_bit_mask; (*dst(I64 *)^*src(I64 *)++)&~leading_pixel_mask;
} else { } else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift); *dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
else { else {
@@ -497,20 +497,20 @@ here1a:
dst(I64 *)++; dst(I64 *)++;
} }
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
if (win_z_num>=*win_z_buf_ptr++) if (win_z_num>=*win_z_buf_ptr++)
*dst(I64 *)++^=*src(I64 *)++; *dst(I64 *)++^=*src(I64 *)++;
else { else {
src(I64 *)++; src(I64 *)++;
dst(I64 *)++; dst(I64 *)++;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_bit_mask; (*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*dst(I64 *)^*src(I64 *)++)&~trailing_bit_mask; (*dst(I64 *)^*src(I64 *)++)&~trailing_pixel_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -523,27 +523,27 @@ here1a:
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
src=img->body+kk&~7; src=img->body+kk&~7;
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_bit_mask; (*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
else else
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask| *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
(*dst(I64 *)^*src(I64 *)++)&~leading_bit_mask; (*dst(I64 *)^*src(I64 *)++)&~leading_pixel_mask;
} }
if (bit_shift) if (bit_shift)
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift); *dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
else else
for (i=0;i<whole_bytes;i++) for (i=0;i<whole_I64s;i++)
*dst(I64 *)++^=*src(I64 *)++; *dst(I64 *)++^=*src(I64 *)++;
if (trailing_bits) { if (trailing_pixels) {
if (bit_shift) if (bit_shift)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_bit_mask; (*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
else else
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask| *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
(*dst(I64 *)^*src(I64 *)++)&~trailing_bit_mask; (*dst(I64 *)^*src(I64 *)++)&~trailing_pixel_mask;
} }
kk +=img->width_internal; kk +=img->width_internal;
kk1+=dc->width_internal; kk1+=dc->width_internal;
@@ -612,7 +612,7 @@ public CDC *DCExtract(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,CTask *task=NULL
public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch) public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
{//2D. Clipping but not transformation. {//2D. Clipping but not transformation.
U8 reg *src,reg *dst,*font_ptr; U8 reg *src,reg *dst,*font_ptr;
I64 i,m,leading_bits,trailing_bits,leading_bit_mask,trailing_bit_mask, I64 i,m,leading_pixels,trailing_pixels,leading_pixel_mask,trailing_pixel_mask,
j,k1,kk1,w1,h1,w2,h2,reg bit_shift,dist,reg color_mask; j,k1,kk1,w1,h1,w2,h2,reg bit_shift,dist,reg color_mask;
CColorROPU32 color,c; CColorROPU32 color,c;
CTask *win_task; CTask *win_task;
@@ -668,17 +668,17 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
if (dc->flags & DCF_DONT_DRAW) if (dc->flags & DCF_DONT_DRAW)
return 1; return 1;
color=dc->color; color=dc->color;
leading_bits=-(w1+x)&7; leading_pixels=-(w1+x)&7;
if (!leading_bits) leading_bits=8; if (!leading_pixels) leading_pixels=8;
leading_bit_mask=gr.to_8_bits[0xFF>>leading_bits]; leading_pixel_mask=gr.to_8_bits[0xFF>>leading_pixels];
bit_shift=-x&7; bit_shift=-x&7;
trailing_bits=(x+w2)&7; trailing_pixels=(x+w2)&7;
trailing_bit_mask=gr.to_8_bits[0xFF<<trailing_bits&0xFF]; trailing_pixel_mask=gr.to_8_bits[0xFF<<trailing_pixels&0xFF];
if (leading_bits+trailing_bits>w2-w1) { if (leading_pixels+trailing_pixels>w2-w1) {
leading_bit_mask|=trailing_bit_mask; leading_pixel_mask|=trailing_pixel_mask;
trailing_bits=0; trailing_pixels=0;
} }
font_ptr=&text.font[(FONT_WIDTH*(FONT_HEIGHT*ch+h1))>>3]; font_ptr=&text.font(U8 *)[FONT_HEIGHT*ch+h1];
if (color.c0.rop==ROPB_COLLISION) { if (color.c0.rop==ROPB_COLLISION) {
m=w1&(FONT_WIDTH-1); m=w1&(FONT_WIDTH-1);
#assert FONT_WIDTH==8 #assert FONT_WIDTH==8
@@ -699,7 +699,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
k1=x+w1; k1=x+w1;
kk1=(h1+y)*dc->width_internal+k1; kk1=(h1+y)*dc->width_internal+k1;
if (!(dc->flags & DCF_SCREEN_BITMAP) || dc->flags&DCF_ON_TOP) { if (!(dc->flags & DCF_SCREEN_BITMAP) || dc->flags&DCF_ON_TOP) {
if (leading_bits) { if (leading_pixels) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
src=font_ptr; src=font_ptr;
if (bit_shift) if (bit_shift)
@@ -709,7 +709,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
case ROPB_MONO: case ROPB_MONO:
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF]; m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -717,7 +717,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
case ROPB_XOR: case ROPB_XOR:
if (color_mask) { if (color_mask) {
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -726,7 +726,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
} }
kk1+=8; kk1+=8;
} }
if (trailing_bits) { if (trailing_pixels) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
src=font_ptr+1; src=font_ptr+1;
if (bit_shift) if (bit_shift)
@@ -736,7 +736,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
case ROPB_MONO: case ROPB_MONO:
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF]; m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -744,7 +744,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
case ROPB_XOR: case ROPB_XOR:
if (color_mask) { if (color_mask) {
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -753,7 +753,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
} }
} }
} else { } else {
if (leading_bits) { if (leading_pixels) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
src=font_ptr; src=font_ptr;
if (bit_shift) if (bit_shift)
@@ -764,7 +764,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
if (!IsPixCovered0(win_task,k1,y+j)) { if (!IsPixCovered0(win_task,k1,y+j)) {
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF]; m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
} }
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
@@ -774,7 +774,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
if (color_mask) { if (color_mask) {
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
if (!IsPixCovered0(win_task,k1,y+j)) if (!IsPixCovered0(win_task,k1,y+j))
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -784,7 +784,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
k1+=8; k1+=8;
kk1+=8; kk1+=8;
} }
if (trailing_bits) { if (trailing_pixels) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
src=font_ptr+1; src=font_ptr+1;
if (bit_shift) if (bit_shift)
@@ -795,7 +795,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
if (!IsPixCovered0(win_task,k1,y+j)) { if (!IsPixCovered0(win_task,k1,y+j)) {
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF]; m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
} }
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
@@ -805,7 +805,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
if (color_mask) { if (color_mask) {
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
if (!IsPixCovered0(win_task,k1,y+j)) if (!IsPixCovered0(win_task,k1,y+j))
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_pixel_mask;
src++; src++;
dst+=dc->width_internal; dst+=dc->width_internal;
} }
@@ -886,7 +886,7 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
{//2D. Width Height. Clipping but not transformation. {//2D. Width Height. Clipping but not transformation.
//Returns cnt of pixs changed. //Returns cnt of pixs changed.
I64 i,result=0,j,k1,kk1,w1,h1,w2,h2,dist, I64 i,result=0,j,k1,kk1,w1,h1,w2,h2,dist,
leading_bits,original_leading_bits,whole_bytes,trailing_bits,leading_bit_mask,trailing_bit_mask, leading_pixels,original_leading_pixels,whole_I64s,trailing_pixels,leading_pixel_mask,trailing_pixel_mask,
win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,color_mask; win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,color_mask;
U8 reg *dst; U8 reg *dst;
U16 reg *win_z_buf_ptr; U16 reg *win_z_buf_ptr;
@@ -963,16 +963,16 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
} }
} else } else
dither=FALSE; dither=FALSE;
original_leading_bits=leading_bits=-(w1+x)&7; original_leading_pixels=leading_pixels=-(w1+x)&7;
leading_bit_mask=gr.to_8_bits[0xFF>>leading_bits]; leading_pixel_mask=gr.to_8_bits[0xFF>>leading_pixels];
whole_bytes=(w2-w1-leading_bits)>>3; whole_I64s=(w2-w1-leading_pixels)>>3;
if (whole_bytes<0) whole_bytes=0; if (whole_I64s<0) whole_I64s=0;
trailing_bits=(x+w2)&7; trailing_pixels=(x+w2)&7;
trailing_bit_mask=gr.to_8_bits[0xFF<<trailing_bits&0xFF]; trailing_pixel_mask=gr.to_8_bits[0xFF<<trailing_pixels&0xFF];
if (leading_bits+trailing_bits>w2-w1) { if (leading_pixels+trailing_pixels>w2-w1) {
leading_bit_mask|=trailing_bit_mask; leading_pixel_mask|=trailing_pixel_mask;
leading_bits=w2-w1; //Correct so it's right for result. leading_pixels=w2-w1; //Correct so it's right for result.
trailing_bits=0; trailing_pixels=0;
} }
if (color.c0.rop==ROPB_COLLISION) {//TODO: Might want to check win_z_buf if (color.c0.rop==ROPB_COLLISION) {//TODO: Might want to check win_z_buf
color =dc->bkcolor.c0.color; color =dc->bkcolor.c0.color;
@@ -993,10 +993,10 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
else { else {
win_z_num=win_task->win_z_num; win_z_num=win_task->win_z_num;
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16); win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
win_z_buf_line_dec=whole_bytes; win_z_buf_line_dec=whole_I64s;
if (leading_bits) if (leading_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
if (trailing_bits) if (trailing_pixels)
win_z_buf_line_dec++; win_z_buf_line_dec++;
win_z_buf_line_dec*=sizeof(U16); win_z_buf_line_dec*=sizeof(U16);
win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec; win_z_buf_line_inc=TEXT_COLS*sizeof(U16)-win_z_buf_line_dec;
@@ -1016,21 +1016,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
color_mask=gr.to_8_colors[color.c0.color]; color_mask=gr.to_8_colors[color.c0.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1046,12 +1046,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
color_mask=gr.to_8_colors[color.c0.color]; color_mask=gr.to_8_colors[color.c0.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
if (RandU16<dc->dither_probability_u16) if (RandU16<dc->dither_probability_u16)
color.c0=dither_colors.c1; color.c0=dither_colors.c1;
@@ -1067,21 +1067,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
color_mask=gr.to_8_colors[color.c0.color]; color_mask=gr.to_8_colors[color.c0.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1097,12 +1097,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
color_mask=gr.to_8_colors[color.c0.color]; color_mask=gr.to_8_colors[color.c0.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
if (RandU16<dc->dither_probability_u16) if (RandU16<dc->dither_probability_u16)
color.c0=dither_colors.c1; color.c0=dither_colors.c1;
@@ -1114,7 +1114,7 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
break; break;
} }
} else { } else {
if (((x+w1-original_leading_bits)^(y+h1))&1) if (((x+w1-original_leading_pixels)^(y+h1))&1)
SwapU16(&color.c0,&color.c1); SwapU16(&color.c0,&color.c1);
nobound_switch (color.c0.rop) { nobound_switch (color.c0.rop) {
case ROPB_EQU: case ROPB_EQU:
@@ -1125,21 +1125,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]| color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]|
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color]; gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1153,12 +1153,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]| color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]|
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color]; gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
SwapU16(&color.c0,&color.c1); SwapU16(&color.c0,&color.c1);
} }
@@ -1172,21 +1172,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]| color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]|
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color]; gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1200,12 +1200,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]| color_mask=gr.to_8_bits[0x55]&gr.to_8_colors[color.c0.color]|
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color]; gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
SwapU16(&color.c0,&color.c1); SwapU16(&color.c0,&color.c1);
} }
@@ -1223,21 +1223,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
result=0; result=0;
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1248,12 +1248,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
} else { } else {
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
dst(I64 *)=dc->body+kk1&~7; dst(I64 *)=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)=color_mask; *dst(I64 *)=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
} }
result=(h2-h1)*(w2-w1); result=(h2-h1)*(w2-w1);
@@ -1264,21 +1264,21 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
result=0; result=0;
for (j=h1;j<h2;j++) { for (j=h1;j<h2;j++) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) { if (leading_pixels) {
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
result+=leading_bits; result+=leading_pixels;
} }
dst(I64 *)++; dst(I64 *)++;
} }
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
if (win_z_num>=*win_z_buf_ptr++) { if (win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
result+=8; result+=8;
} }
if (trailing_bits && win_z_num>=*win_z_buf_ptr++) { if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
result+=trailing_bits; result+=trailing_pixels;
} }
if ((j+y)&7==7) if ((j+y)&7==7)
win_z_buf_ptr(U8 *)+=win_z_buf_line_inc; win_z_buf_ptr(U8 *)+=win_z_buf_line_inc;
@@ -1289,12 +1289,12 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
} else { } else {
for (j=h2-h1;j;j--) { for (j=h2-h1;j;j--) {
dst=dc->body+kk1&~7; dst=dc->body+kk1&~7;
if (leading_bits) if (leading_pixels)
*dst(I64 *)++=*dst(I64 *)&leading_bit_mask|*dst(I64 *)^color_mask&~leading_bit_mask; *dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
for (i=0;i<whole_bytes;i++,dst(I64 *)++) for (i=0;i<whole_I64s;i++,dst(I64 *)++)
*dst(I64 *)^=color_mask; *dst(I64 *)^=color_mask;
if (trailing_bits) if (trailing_pixels)
*dst(I64 *)=*dst(I64 *)&trailing_bit_mask|*dst(I64 *)^color_mask&~trailing_bit_mask; *dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
kk1+=dc->width_internal; kk1+=dc->width_internal;
} }
result=(h2-h1)*(w2-w1); result=(h2-h1)*(w2-w1);
+40 -34
View File
@@ -41,17 +41,21 @@ public I64 *GrIdentEqu(I64 r[4][4])
return r; return r;
} }
public I64 GrRotNormSqr65536(I64 r[4][4])
{//Norm Squared of r.
//(1.0/Sqrt(3))*65536=37837.22
return SqrI64((r[0][0]*37838+r[0][1]*37838+r[0][2]*37838)>>32)+
SqrI64((r[1][0]*37837+r[1][1]*37837+r[1][2]*37837)>>32)+
SqrI64((r[2][0]*37837+r[2][1]*37837+r[2][2]*37837)>>32);
}
public U0 GrSetRotMat(CDC *dc=NULL,I64 r[4][4]) public U0 GrSetRotMat(CDC *dc=NULL,I64 r[4][4])
{//Set device context's rot matrix. Will be $LK,"Free",A="MN:Free"$d() in $LK,"DCDel",A="MN:DCDel"$(). Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$. {//Set device context's rot matrix. Will be $LK,"Free",A="MN:Free"$d() in $LK,"DCDel",A="MN:DCDel"$(). Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//The main purpose is to set matrix norm for pen width scaling. //The main purpose is to set matrix norm for pen width scaling.
//NULL as dc means gr.dc //NULL as dc means gr.dc
//Note: (1.0/Sqrt(3))*65536=37837.22
I64 xx=37838,yy=37837,zz=37837;
if (!dc) dc=gr.dc; if (!dc) dc=gr.dc;
dc->r=r; dc->r=r;
GrRot(r,&xx,&yy,&zz); dc->r_norm=Sqrt(GrRotNormSqr65536(r))*65536; //scaled 32 bits
//scaled 32 bits
dc->r_norm=Sqrt(xx*xx+yy*yy+zz*zz)*65536;
} }
#help_index "Graphics/Mesh" #help_index "Graphics/Mesh"
@@ -171,7 +175,7 @@ public CDC *DCAlias(CDC *dc=NULL,CTask *task=NULL)
if (!dc) dc=gr.dc; if (!dc) dc=gr.dc;
if (!task) task=Fs; if (!task) task=Fs;
if (dc->dc_signature!=DCS_SIGNATURE_VAL) if (dc->dc_signature!=DCS_SIGNATURE_VAL)
Dbg; throw('Graphics');
result=MAlloc(sizeof(CDC),task); result=MAlloc(sizeof(CDC),task);
MemCpy(result,dc,sizeof(CDC)); MemCpy(result,dc,sizeof(CDC));
result->win_task=result->mem_task=task; result->win_task=result->mem_task=task;
@@ -185,7 +189,7 @@ public CDC *DCAlias(CDC *dc=NULL,CTask *task=NULL)
public CDC *DCNew(I64 width,I64 height,CTask *task=NULL,Bool null_bitmap=FALSE) public CDC *DCNew(I64 width,I64 height,CTask *task=NULL,Bool null_bitmap=FALSE)
{//Create new width x height device context. {//Create new width x height device context.
//Internally only allows widths which are divisible by 8. //Internally only allows widths which are divisible by 8.
//Don't forget these $MA-X+PU,"sizeof(CDC)",LM="Grep(\"sizeof(CDC)\",\"/*\");View;"$. //Don't forget these $MA-X+PU,"sizeof(CDC)",LM="Find(\"sizeof(CDC)\",\"/*\");View;"$.
CDC *result; CDC *result;
if (!task) task=Fs; if (!task) task=Fs;
result=CAlloc(sizeof(CDC),task); result=CAlloc(sizeof(CDC),task);
@@ -194,11 +198,10 @@ public CDC *DCNew(I64 width,I64 height,CTask *task=NULL,Bool null_bitmap=FALSE)
result->width=width; result->width=width;
result->width_internal=(width+7)&~7; result->width_internal=(width+7)&~7;
result->height=height; result->height=height;
result->body_size=result->width_internal*result->height;
if (null_bitmap) if (null_bitmap)
result->flags|=DCF_DONT_DRAW; result->flags|=DCF_DONT_DRAW;
else else
result->body=CAlloc(result->body_size,task); result->body=CAlloc(result->width_internal*result->height,task);
result->r=MAlloc(16*sizeof(I64),task); result->r=MAlloc(16*sizeof(I64),task);
DCRst(result); DCRst(result);
result->dc_signature=DCS_SIGNATURE_VAL; result->dc_signature=DCS_SIGNATURE_VAL;
@@ -209,7 +212,7 @@ public U0 DCDel(CDC *dc)
{//Free dc, image body, rot mat and depth buf. {//Free dc, image body, rot mat and depth buf.
if (!dc) return; if (!dc) return;
if (dc->dc_signature!=DCS_SIGNATURE_VAL) if (dc->dc_signature!=DCS_SIGNATURE_VAL)
Dbg; throw('Graphics');
dc->dc_signature=0; dc->dc_signature=0;
Free(dc->r); Free(dc->r);
if (!(dc->flags & DCF_ALIAS)) if (!(dc->flags & DCF_ALIAS))
@@ -233,7 +236,7 @@ public U0 DCDepthBufRst(CDC *dc)
} }
public U0 DCAllocDepthBuf(CDC *dc) public U0 DCAllocDepthBuf(CDC *dc)
{//Allocate a 32-bit depth buffer for device context. {//Alloc a 32-bit depth buffer for device context.
Free(dc->depth_buf); Free(dc->depth_buf);
dc->depth_buf=MAlloc(dc->width_internal*dc->height*sizeof(I32),dc->mem_task); dc->depth_buf=MAlloc(dc->width_internal*dc->height*sizeof(I32),dc->mem_task);
DCDepthBufRst(dc); DCDepthBufRst(dc);
@@ -244,7 +247,7 @@ public CDC *DCCopy(CDC *dc,CTask *task=NULL)
CDC *result; CDC *result;
if (!dc) return NULL; if (!dc) return NULL;
if (dc->dc_signature!=DCS_SIGNATURE_VAL) if (dc->dc_signature!=DCS_SIGNATURE_VAL)
Dbg; throw('Graphics');
result=MAllocIdentical(dc,task); result=MAllocIdentical(dc,task);
GrSetRotMat(result,MAllocIdentical(dc->r,task)); GrSetRotMat(result,MAllocIdentical(dc->r,task));
result->mem_task=task; result->mem_task=task;
@@ -287,32 +290,27 @@ public U8 *DCSave(CDC *dc,I64 *_size=NULL,Bool compressed=TRUE)
U8 *result,*ptr,*body; U8 *result,*ptr,*body;
Bool old_preempt; Bool old_preempt;
CArcCompress *ac; CArcCompress *ac;
I64 i,old_flags=dc->flags; I64 i=dc->width_internal*dc->height,old_flags=dc->flags;
if (compressed) { if (compressed) {
ac=CompressBuf(dc->body,dc->body_size); ac=CompressBuf(dc->body,i);
i=ac->compressed_size; i=ac->compressed_size;
body=ac; body=ac;
} else { } else {
ac=NULL; ac=NULL;
i=dc->body_size;
body=dc->body; body=dc->body;
} }
ptr=result=MAlloc(offset(CDC.end_saved_area)- ptr=result=MAlloc(offset(CDC.end)-offset(CDC.start)+i);
offset(CDC.start_saved_area)+i);
old_preempt=Preempt(OFF); //in case it is a screen bitmap old_preempt=Preempt(OFF); //in case it is a screen bitmap
if (compressed) dc->flags|=DCF_COMPRESSED; if (compressed) dc->flags|=DCF_COMPRESSED;
dc->flags&=DCF_COMPRESSED; dc->flags&=DCF_COMPRESSED;
MemCpy(result,&dc->start_saved_area, MemCpy(result,&dc->start,offset(CDC.end)-offset(CDC.start));
offset(CDC.end_saved_area)-
offset(CDC.start_saved_area));
dc->flags=old_flags; dc->flags=old_flags;
Preempt(old_preempt); Preempt(old_preempt);
ptr+=offset(CDC.end_saved_area)- ptr+=offset(CDC.end)-offset(CDC.start);
offset(CDC.start_saved_area);
MemCpy(ptr,body,i); MemCpy(ptr,body,i);
ptr+=i; ptr+=i;
@@ -326,22 +324,24 @@ public CDC *DCLoad(U8 *src,I64 *_size=NULL,CTask *task=NULL)
CDC *result; CDC *result;
U8 *ptr=src; U8 *ptr=src;
CArcCompress *ac; CArcCompress *ac;
I64 body_size;
if (!task) task=Fs; if (!task) task=Fs;
result=CAlloc(sizeof(CDC),task); result=CAlloc(sizeof(CDC),task);
result->win_task=task; result->win_task=task;
result->mem_task=task; result->mem_task=task;
MemCpy(&result->start_saved_area,src, MemCpy(&result->start,src,
offset(CDC.end_saved_area)-offset(CDC.start_saved_area)); offset(CDC.end)-offset(CDC.start));
ptr+=offset(CDC.end_saved_area)-offset(CDC.start_saved_area); ptr+=offset(CDC.end)-offset(CDC.start);
body_size=result->width_internal*result->height;
if (result->flags&DCF_COMPRESSED) { if (result->flags&DCF_COMPRESSED) {
result->flags&=~DCF_COMPRESSED; result->flags&=~DCF_COMPRESSED;
ac=ptr; ac=ptr;
result->body=ExpandBuf(ac,task); result->body=ExpandBuf(ac,task);
ptr+=ac->compressed_size; ptr+=ac->compressed_size;
} else { } else {
result->body=MAlloc(result->body_size,task); result->body=MAlloc(body_size,task);
MemCpy(result->body,ptr,result->body_size); MemCpy(result->body,ptr,body_size);
ptr+=result->body_size; ptr+=body_size;
} }
result->pen_width=1; result->pen_width=1;
result->r=GrIdentNew(task); result->r=GrIdentNew(task);
@@ -351,6 +351,8 @@ public CDC *DCLoad(U8 *src,I64 *_size=NULL,CTask *task=NULL)
return result; return result;
} }
#help_index "Graphics/GRA Files"
#help_file "::/Doc/GRAFiles"
#help_index "Graphics/Device Contexts;Graphics/GRA Files" #help_index "Graphics/Device Contexts;Graphics/GRA Files"
public I64 GRAWrite(U8 *filename,CDC *dc) public I64 GRAWrite(U8 *filename,CDC *dc)
{//TempleOS GRA File. {//TempleOS GRA File.
@@ -376,7 +378,7 @@ public CDC *GRARead(U8 *filename,CTask *task=NULL)
} }
#help_index "Graphics/Sprite;Graphics/GRA Files;DolDoc/Output" #help_index "Graphics/Sprite;Graphics/GRA Files;DolDoc/Output"
public U0 DocGRAFile(CDoc *doc=NULL,U8 *filename) public U0 DocGRA(CDoc *doc=NULL,U8 *filename)
{//Put a GRA file into a document as a sprite. {//Put a GRA file into a document as a sprite.
CDC *dc=GRARead(filename); CDC *dc=GRARead(filename);
CSprite *elems=DC2Sprite(dc); CSprite *elems=DC2Sprite(dc);
@@ -386,25 +388,29 @@ public U0 DocGRAFile(CDoc *doc=NULL,U8 *filename)
} }
#help_index "Graphics/Device Contexts;Graphics/Screen" #help_index "Graphics/Device Contexts;Graphics/Screen"
public CDC *DCCaptureScreen(CTask *task=NULL) public CDC *DCCaptureScreen(Bool include_zoom=TRUE,CTask *task=NULL)
{//Capture screen to a device context. {//Capture screen to a device context.
CDC *dc; CDC *dc;
U8 *dst; U8 *dst;
WinMgrSync(2,TRUE); WinMgrSync(2,TRUE);
if (include_zoom)
dc=DCCopy(gr.screen_image,task); dc=DCCopy(gr.screen_image,task);
dst=MAlloc(dc->body_size,task); else
dc=DCCopy(gr.dc1,task);
dc->flags&=~DCF_SCREEN_BITMAP;
dst=MAlloc(dc->width_internal*dc->height,task);
//Pick background color that never occurs. COLOR_INVALID //Pick background color that never occurs. COLOR_INVALID
GrBitMap4ToBitMap8(dst,dc->body,dc->body_size/2,COLOR_INVALID); GrBitMap4ToBitMap8(dst,dc->body,(dc->width_internal*dc->height)>>1,COLOR_INVALID);
Free(dc->body); Free(dc->body);
dc->body=dst; dc->body=dst;
return dc; return dc;
} }
#help_index "Graphics/GRA Files;Graphics/Screen" #help_index "Graphics/GRA Files;Graphics/Screen"
public I64 GRACaptureScreen(U8 *filename) public I64 GRACaptureScreen(U8 *filename,Bool include_zoom=TRUE)
{//Capture screen to a TempleOS GRA File. {//Capture screen to a TempleOS GRA File.
I64 size; I64 size;
CDC *dc=DCCaptureScreen; CDC *dc=DCCaptureScreen(include_zoom);
size=GRAWrite(filename,dc); size=GRAWrite(filename,dc);
DCDel(dc); DCDel(dc);
return size; return size;
+2 -2
View File
@@ -7,7 +7,7 @@ U0 CtrlAltZ(I64 sc)
else else
GrScaleZoom(2.0); GrScaleZoom(2.0);
} }
SetCtrlAltLetCB('Z',&CtrlAltZ,"Sys/Zoom In or Out"); CtrlAltLetCBSet('Z',&CtrlAltZ,"Sys/Zoom In or Out");
U0 Screen2Clipboard(I64) U0 Screen2Clipboard(I64)
{ {
@@ -25,4 +25,4 @@ U0 CtrlAltS(I64)
{ {
Spawn(&Screen2Clipboard); Spawn(&Screen2Clipboard);
} }
SetCtrlAltLetCB('S',&CtrlAltS,"Sys/Screen Shot to Clipboard"); CtrlAltLetCBSet('S',&CtrlAltS,"Sys/Screen Shot to Clipboard");
+3 -7
View File
@@ -9,7 +9,7 @@ public class CGrGlbls
*dc2, //Updated every refresh *dc2, //Updated every refresh
*dc_cache, *dc_cache,
*zoomed_dc; *zoomed_dc;
U32 *text_base; //See $LK,"TextBase Layer",A="HI:TextBase Layer"$. U32 *text_base; //See $LK,"TextBase Layer",A="HI:TextBase Layer"$. (Similar to 0xB8000 but 32 bits)
U16 *win_z_buf; U16 *win_z_buf;
#define SPHT_ELEM_CODE 1 #define SPHT_ELEM_CODE 1
@@ -19,7 +19,7 @@ public class CGrGlbls
I64 highest_uncovered; I64 highest_uncovered;
U16 *vga_text_cache; U16 *vga_text_cache;
I64 pan_text_x,pan_text_y; //[-7,7] I64 pan_text_x,pan_text_y; //[-7,7]
U0 (*fp_final_screen_update)(CDC *dc); U0 (*fp_final_screen_update)(CDC *dc);//Mouse cursor is handled here.
U0 (*fp_wall_paper)(CTask *task); U0 (*fp_wall_paper)(CTask *task);
U0 (*fp_draw_input_ptr)(CDC *dc,I64 x,I64 y); U0 (*fp_draw_input_ptr)(CDC *dc,I64 x,I64 y);
U0 (*fp_draw_grab_input_ptr)(CDC *dc,I64 x,I64 y,Bool closed); U0 (*fp_draw_grab_input_ptr)(CDC *dc,I64 x,I64 y,Bool closed);
@@ -31,10 +31,6 @@ public class CGrGlbls
*even_pen_brushes[GR_NUM_PEN_BRUSHES], *even_pen_brushes[GR_NUM_PEN_BRUSHES],
*odd_pen_brushes[GR_NUM_PEN_BRUSHES]; *odd_pen_brushes[GR_NUM_PEN_BRUSHES];
#define GR_REFRESH_LOG_CNT 16
F64 refresh_time_stamps[GR_REFRESH_LOG_CNT];
I64 refresh_ts_ptr;
#define GR_MAX_SCREEN_ZOOM 8 #define GR_MAX_SCREEN_ZOOM 8
U8 *screen_zoom_tables[GR_MAX_SCREEN_ZOOM+1]; U8 *screen_zoom_tables[GR_MAX_SCREEN_ZOOM+1];
I64 screen_zoom,sx,sy; I64 screen_zoom,sx,sy;
@@ -43,7 +39,7 @@ public class CGrGlbls
Bool continuous_scroll; Bool continuous_scroll;
} gr; } gr;
//See $LK,"SYS_BIOS_GR_MODE",A="FF:D:/Kernel/KStart.CPP,SYS_BIOS_GR_MODE:2"$ //See $LK,"RLf_VGA",A="FF:::/Kernel/KStart.CPP,RLf_VGA"$
//See $LK,"SysGrInit",A="MN:SysGrInit"$() //See $LK,"SysGrInit",A="MN:SysGrInit"$()
//Allows consts to be used instead of vars. //Allows consts to be used instead of vars.
HashPublic("GR_WIDTH",HTT_DEFINE_STR);; HashPublic("GR_WIDTH",HTT_DEFINE_STR);;
+5 -7
View File
@@ -55,14 +55,14 @@ U0 GrSetUpTables()
if (((x-1)^(y-1))&1 && SqrI64(y*2-k)+SqrI64(x*2-k)<rr) if (((x-1)^(y-1))&1 && SqrI64(y*2-k)+SqrI64(x*2-k)<rr)
GrPlot0(dc,x-1,y-1); GrPlot0(dc,x-1,y-1);
} }
if (!sys_bios_gr_mode) { //if text mode if (!Bt(&sys_run_level,RLf_VGA)) { //if text mode
MemSet(VGA_TEXT_MEM_BASE,0,TEXT_ROWS*TEXT_COLS*sizeof(U16)); MemSet(VGAM_TEXT,0,TEXT_ROWS*TEXT_COLS*sizeof(U16));
MemSet(gr.vga_text_cache,0,TEXT_ROWS*TEXT_COLS*sizeof(U16)); MemSet(gr.vga_text_cache,0,TEXT_ROWS*TEXT_COLS*sizeof(U16));
} else { } else {
OutU8(VGA_SC_INDEX,VGA_MAP_MASK); OutU8(VGAP_INDEX,VGAR_MAP_MASK);
OutU8(VGA_SC_DATA,0x0F); OutU8(VGAP_DATA,0x0F);
//Virtual Box crashes on the following for some reason. //Virtual Box crashes on the following for some reason.
// MemSet(VGA_GRAPHIC_MEM_BASE,0,GR_HEIGHT*GR_WIDTH>>3); // MemSet(VGAM_GRAPHICS,0,GR_HEIGHT*GR_WIDTH>>3);
MemSet(gr.screen_image->body,0,GR_WIDTH*GR_HEIGHT>>1); MemSet(gr.screen_image->body,0,GR_WIDTH*GR_HEIGHT>>1);
} }
for (i=1;i<=GR_MAX_SCREEN_ZOOM;i++) { for (i=1;i<=GR_MAX_SCREEN_ZOOM;i++) {
@@ -79,8 +79,6 @@ U0 GrSetUpTables()
dst[j+l*256]=m.u8[l]; dst[j+l*256]=m.u8[l];
} }
} }
for (i=0;i<GR_REFRESH_LOG_CNT;i++)
gr.refresh_time_stamps[i]=tS;
} }
#help_index "Graphics/Screen;Windows" #help_index "Graphics/Screen;Windows"
File renamed without changes.
+19 -19
View File
@@ -18,35 +18,35 @@ we never need to worry about indexes,
just DAC palette settings. just DAC palette settings.
*/ */
I64 i; I64 i;
if (!sys_bios_gr_mode) return; if (!Bt(&sys_run_level,RLf_VGA)) return;
PUSHFD PUSHFD
CLI CLI
while (LBts(&sys_semas[SYS_SEMA_VGA],0)) while (LBts(&sys_semas[SYS_SEMA_VGA],0))
Yield; Yield;
InU8(VGA_INPUT_STAT); //Rsts attr index/data InU8(VGAP_INPUT_STAT); //Rsts attr index/data
for (i=0;i<16;i++) { for (i=0;i<16;i++) {
OutU8(VGA_ATTR_INDEX,i); OutU8(VGAP_ATTR_INDEX,i);
OutU8(VGA_ATTR_DATA_WRITE,i); OutU8(VGAP_ATTR_DATA_WRITE,i);
} }
OutU8(VGA_ATTR_INDEX,0x20); OutU8(VGAP_ATTR_INDEX,0x20);
OutU8(VGA_ATTR_DATA_WRITE,0); //Dummy write OutU8(VGAP_ATTR_DATA_WRITE,0); //Dummy write
InU8(VGA_INPUT_STAT); //Rsts attr index/data InU8(VGAP_INPUT_STAT); //Rsts attr index/data
LBtr(&sys_semas[SYS_SEMA_VGA],0); LBtr(&sys_semas[SYS_SEMA_VGA],0);
POPFD POPFD
} }
public U0 SetVGAPaletteColor(I64 color_num,CBGR bgr) public U0 SetVGAPaletteColor(I64 color_num,CBGR bgr)
{//6-bits per b, g and r. {//6-bits per b, g and r.
if (!sys_bios_gr_mode) return; if (!Bt(&sys_run_level,RLf_VGA)) return;
PUSHFD PUSHFD
CLI CLI
while (LBts(&sys_semas[SYS_SEMA_VGA],0)) while (LBts(&sys_semas[SYS_SEMA_VGA],0))
Yield; Yield;
OutU8(VGA_PALETTE_MASK,0xFF); OutU8(VGAP_PALETTE_MASK,0xFF);
OutU8(VGA_REG_WRITE,color_num); OutU8(VGAP_REG_WRITE,color_num);
OutU8(VGA_PALETTE_DATA,bgr.r>>2); OutU8(VGAP_PALETTE_DATA,bgr.r>>2);
OutU8(VGA_PALETTE_DATA,bgr.g>>2); OutU8(VGAP_PALETTE_DATA,bgr.g>>2);
OutU8(VGA_PALETTE_DATA,bgr.b>>2); OutU8(VGAP_PALETTE_DATA,bgr.b>>2);
LBtr(&sys_semas[SYS_SEMA_VGA],0); LBtr(&sys_semas[SYS_SEMA_VGA],0);
POPFD POPFD
} }
@@ -54,16 +54,16 @@ public U0 SetVGAPaletteColor(I64 color_num,CBGR bgr)
public CBGR GetVGAPaletteColor(I64 color_num) public CBGR GetVGAPaletteColor(I64 color_num)
{//6-bits per b, g and r. {//6-bits per b, g and r.
CBGR result=0; CBGR result=0;
if (!sys_bios_gr_mode) return 0; if (!Bt(&sys_run_level,RLf_VGA)) return 0;
PUSHFD PUSHFD
CLI CLI
while (LBts(&sys_semas[SYS_SEMA_VGA],0)) while (LBts(&sys_semas[SYS_SEMA_VGA],0))
Yield; Yield;
OutU8(VGA_PALETTE_MASK,0xFF); OutU8(VGAP_PALETTE_MASK,0xFF);
OutU8(VGA_REG_READ,color_num); OutU8(VGAP_REG_READ,color_num);
result.r=InU8(VGA_PALETTE_DATA)<<2; result.r=InU8(VGAP_PALETTE_DATA)<<2;
result.g=InU8(VGA_PALETTE_DATA)<<2; result.g=InU8(VGAP_PALETTE_DATA)<<2;
result.b=InU8(VGA_PALETTE_DATA)<<2; result.b=InU8(VGAP_PALETTE_DATA)<<2;
LBtr(&sys_semas[SYS_SEMA_VGA],0); LBtr(&sys_semas[SYS_SEMA_VGA],0);
POPFD POPFD
return result; return result;
+1 -1
View File
@@ -235,7 +235,7 @@ I64 GrFloodFillRay(CDC *dc,I64 x,I64 y,I64 z,I32 *db)
} }
public I64 GrFloodFill(CDC *dc=gr.dc,I64 x,I64 y,Bool not_color=FALSE,I64 z=0,I32 *db=NULL) public I64 GrFloodFill(CDC *dc=gr.dc,I64 x,I64 y,Bool not_color=FALSE,I64 z=0,I32 *db=NULL)
{//3D. Ignore z and db. {//2D. Ignore z and db.
//not_color=TRUE means fill up to everything which is not the current color. //not_color=TRUE means fill up to everything which is not the current color.
//not_color=FALSE means fill all parts equal to the color under the point. //not_color=FALSE means fill all parts equal to the color under the point.
//Returns cnt of pixs changed //Returns cnt of pixs changed
+11 -17
View File
@@ -89,16 +89,10 @@ U0 GrUpdateWins()
PutExcept(FALSE); PutExcept(FALSE);
Dbg("Exception in WinMgr"); Dbg("Exception in WinMgr");
} }
winmgr.last_ode_time=winmgr.ode_time; winmgr.last_ode_time=winmgr.ode_time;
ode_allocated_factor=LowPass1(0.1,ode_allocated_factor, ode_alloced_factor=LowPass1(0.1,ode_alloced_factor,
Clamp(Gs->idle_factor-0.1,0.2,0.8),1/winmgr.fps); Clamp(Gs->idle_factor-0.1,0.2,0.8),1/winmgr.fps);
sys_task_being_screen_updated=NULL; sys_task_being_screen_updated=NULL;
gr.refresh_time_stamps[gr.refresh_ts_ptr++&(GR_REFRESH_LOG_CNT-1)]=tS;
winmgr.fps=(GR_REFRESH_LOG_CNT-1)/
(gr.refresh_time_stamps[(gr.refresh_ts_ptr-1)&(GR_REFRESH_LOG_CNT-1)]-
gr.refresh_time_stamps[gr.refresh_ts_ptr&(GR_REFRESH_LOG_CNT-1)]);
} }
U0 GrFixZoomScale() U0 GrFixZoomScale()
@@ -339,7 +333,7 @@ U0 GrUpdateTextModeText()
{ {
U32 *src=gr.text_base; U32 *src=gr.text_base;
I64 cur_ch,i,d0=TEXT_COLS*TEXT_ROWS; I64 cur_ch,i,d0=TEXT_COLS*TEXT_ROWS;
U16 *dst=VGA_TEXT_MEM_BASE,*dst2=gr.vga_text_cache; U16 *dst=VGAM_TEXT,*dst2=gr.vga_text_cache;
Bool blink_flag=Blink; Bool blink_flag=Blink;
if (LBtr(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0)) { if (LBtr(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0)) {
i=d0; i=d0;
@@ -390,18 +384,18 @@ U0 GrUpdateVGAGraphics()
dst=gr.screen_image->body; dst=gr.screen_image->body;
if (LBtr(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0)) { if (LBtr(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0)) {
for (plane=1;plane<0x10;plane<<=1) { for (plane=1;plane<0x10;plane<<=1) {
OutU8(VGA_SC_INDEX,VGA_MAP_MASK); OutU8(VGAP_INDEX,VGAR_MAP_MASK);
OutU8(VGA_SC_DATA,plane); OutU8(VGAP_DATA,plane);
vga=VGA_GRAPHIC_MEM_BASE; vga=VGAM_GRAPHICS;
row=gr.zoomed_dc->height; row=gr.zoomed_dc->height;
while (row--) while (row--)
GrUpdateLine64FlushCache(&vga,&src,d,&dst); GrUpdateLine64FlushCache(&vga,&src,d,&dst);
} }
} else { } else {
for (plane=1;plane<0x10;plane<<=1) { for (plane=1;plane<0x10;plane<<=1) {
OutU8(VGA_SC_INDEX,VGA_MAP_MASK); OutU8(VGAP_INDEX,VGAR_MAP_MASK);
OutU8(VGA_SC_DATA,plane); OutU8(VGAP_DATA,plane);
vga=VGA_GRAPHIC_MEM_BASE; vga=VGAM_GRAPHICS;
row=gr.zoomed_dc->height; row=gr.zoomed_dc->height;
while (row--) while (row--)
GrUpdateLine64(&vga,&src,d,&dst); GrUpdateLine64(&vga,&src,d,&dst);
@@ -410,10 +404,10 @@ U0 GrUpdateVGAGraphics()
} }
U0 GrUpdateScreen() U0 GrUpdateScreen()
{//Called by the Window Manager $LK,"HERE",A="FF:::/Adam/Win2b.CPP,GrUpdateScreen"$, 60 times a second. {//Called by the Window Manager $LK,"HERE",A="FF:::/Adam/WinB.CPP,GrUpdateScreen"$, 60 times a second.
CDC *dc; CDC *dc;
Preempt(ON); Preempt(ON);
if (!sys_bios_gr_mode) //if text mode if (!Bt(&sys_run_level,RLf_VGA)) //if text mode
GrUpdateWins; GrUpdateWins;
else { else {
GrUpdateTextBG; GrUpdateTextBG;
@@ -429,7 +423,7 @@ U0 GrUpdateScreen()
(*gr.fp_final_screen_update)(dc); (*gr.fp_final_screen_update)(dc);
DCDel(dc); DCDel(dc);
if (!sys_bios_gr_mode) //if text mode if (!Bt(&sys_run_level,RLf_VGA)) //if text mode
GrUpdateTextModeText; GrUpdateTextModeText;
else { else {
DCBlotColor4(gr.dc1->body,gr.dc2->body,gr.dc_cache->body, DCBlotColor4(gr.dc1->body,gr.dc2->body,gr.dc_cache->body,
+97 -99
View File
@@ -39,15 +39,15 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
dc->cur_sprite_elem_num=cur_sprite_elem_num++; dc->cur_sprite_elem_num=cur_sprite_elem_num++;
switch (tempg->type) { switch (tempg->type) {
case SPT_COLOR: case SPT_COLOR:
dc->color=dc->color&~(COLORROP_COLORS_MASK|ROPF_DITHER)|tempg->color; dc->color=dc->color&~(COLORROP_COLORS_MASK|ROPF_DITHER)|tempg->c.color;
break; break;
case SPT_DITHER_COLOR: case SPT_DITHER_COLOR:
dc->color=dc->color&~COLORROP_COLORS_MASK| dc->color=dc->color&~COLORROP_COLORS_MASK|
tempg->dither_color.u8[0]| tempg->d.dither_color.u8[0]|
tempg->dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER; tempg->d.dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER;
break; break;
case SPT_WIDTH: case SPT_WIDTH:
dc->pen_width=tempg->width; dc->pen_width=tempg->w.width;
GrScalePenWidth(dc); GrScalePenWidth(dc);
break; break;
case SPT_TRANSFORM_ON: case SPT_TRANSFORM_ON:
@@ -67,86 +67,87 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
dc->flags&=~DCF_TRANSFORMATION; dc->flags&=~DCF_TRANSFORMATION;
break; break;
case SPT_PT: case SPT_PT:
GrPlot3(dc,tempg->x1+x,tempg->y1+y,z); GrPlot3(dc,tempg->p.x1+x,tempg->p.y1+y,z);
break; break;
case SPT_TEXT: case SPT_TEXT:
GrPrint3(dc,tempg->x1+x,tempg->y1+y,z,"%s",tempg->st); GrPrint3(dc,tempg->ps.x1+x,tempg->ps.y1+y,z,"%s",tempg->ps.st);
break; break;
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
GrTextBox3(dc,tempg->x1+x,tempg->y1+y,z,tempg->st); GrTextBox3(dc,tempg->ps.x1+x,tempg->ps.y1+y,z,tempg->ps.st);
break; break;
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
GrTextDiamond3(dc,tempg->x1+x,tempg->y1+y,z,tempg->st); GrTextDiamond3(dc,tempg->ps.x1+x,tempg->ps.y1+y,z,tempg->ps.st);
break; break;
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
GrFloodFill3(dc,tempg->x1+x,tempg->y1+y,z,FALSE); GrFloodFill3(dc,tempg->p.x1+x,tempg->p.y1+y,z,FALSE);
break; break;
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
i=dc->color; i=dc->color;
dc->color=dc->color.c0; dc->color=dc->color.c0;
GrFloodFill3(dc,tempg->x1+x,tempg->y1+y,z,TRUE); GrFloodFill3(dc,tempg->p.x1+x,tempg->p.y1+y,z,TRUE);
dc->color=i; dc->color=i;
break; break;
case SPT_SHIFT: case SPT_SHIFT:
x+=tempg->x1; x+=tempg->p.x1;
y+=tempg->y1; y+=tempg->p.y1;
break; break;
case SPT_LINE: case SPT_LINE:
GrLine3(dc,tempg->x1+x,tempg->y1+y,z,tempg->x2+x,tempg->y2+y,z); GrLine3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z);
break; break;
case SPT_ARROW: case SPT_ARROW:
GrArrow3(dc,tempg->x1+x,tempg->y1+y,z,tempg->x2+x,tempg->y2+y,z); GrArrow3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z);
break; break;
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
if (GrSetSymmetry3(dc,tempg->x1+x,tempg->y1+y,z,tempg->x2+x,tempg->y2+y,z,tempg->x2+x,tempg->y2+y,z+1)) if (GrSetSymmetry3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z+1))
dc->flags|=DCF_SYMMETRY; dc->flags|=DCF_SYMMETRY;
else else
dc->flags&=~DCF_SYMMETRY; dc->flags&=~DCF_SYMMETRY;
break; break;
case SPT_BITMAP: case SPT_BITMAP:
img=CAlloc(sizeof(CDC)); img=CAlloc(sizeof(CDC));
img->width=tempg->width; img->width=tempg->pwhu.width;
img->width_internal=(tempg->width+7)&~7; img->width_internal=(tempg->pwhu.width+7)&~7;
img->height=tempg->height; img->height=tempg->pwhu.height;
img->body_size=img->width_internal*img->height; img->body=&tempg->pwhu.u;
img->body=tempg(U8 *)+offset(CSprite.linespeed);
img->dc_signature=DCS_SIGNATURE_VAL; img->dc_signature=DCS_SIGNATURE_VAL;
GrBlot3(dc,tempg->x2+x,tempg->y2+y,z,img); GrBlot3(dc,tempg->pwhu.x1+x,tempg->pwhu.y1+y,z,img);
Free(img); Free(img);
break; break;
case SPT_RECT: case SPT_RECT:
GrRect3(dc,tempg->x1+x,tempg->y1+y,z,tempg->x2-tempg->x1,tempg->y2-tempg->y1); GrRect3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
break; break;
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
x1=tempg->x1+x; x1=tempg->ppa.x1+x;
y1=tempg->y1+y; y1=tempg->ppa.y1+y;
z1=z; z1=z;
GrRot(dc->r,&x1,&y1,&z1); GrRot(dc->r,&x1,&y1,&z1);
old_r=dc->r; old_r=dc->r;
dc->flags|=DCF_TRANSFORMATION; dc->flags|=DCF_TRANSFORMATION;
r2=GrRotZNew(-tempg->rot_angle); r2=GrRotZNew(-tempg->ppa.angle);
GrSetTranslation(r2,x1,y1,z1); GrSetTranslation(r2,x1,y1,z1);
GrSetRotMat(dc,GrMulMat(old_r,r2)); GrSetRotMat(dc,GrMulMat(old_r,r2));
GrRect3(dc,0,0,0,tempg->x2-tempg->x1,tempg->y2-tempg->y1); GrRect3(dc,0,0,0,tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1);
Free(dc->r); Free(dc->r);
Free(r2); Free(r2);
GrSetRotMat(dc,old_r); GrSetRotMat(dc,old_r);
dc->flags=dc->flags&~DCF_TRANSFORMATION|old_flags; dc->flags=dc->flags&~DCF_TRANSFORMATION|old_flags;
break; break;
case SPT_CIRCLE: case SPT_CIRCLE:
GrCircle3(dc,tempg->x1+x,tempg->y1+y,z,tempg->x2); GrCircle3(dc,tempg->pr.x1+x,tempg->pr.y1+y,z,tempg->pr.radius);
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
GrEllipse3(dc,tempg->x2+x,tempg->y2+y,z,tempg->width,tempg->height,tempg->rot_angle); GrEllipse3(dc,tempg->pwha.x1+x,tempg->pwha.y1+y,z,tempg->pwha.width,
tempg->pwha.height,tempg->pwha.angle);
break; break;
case SPT_POLYGON: case SPT_POLYGON:
GrRegPoly3(dc,tempg->x2+x,tempg->y2+y,z,tempg->width,tempg->height,tempg->sides,tempg->rot_angle); GrRegPoly3(dc,tempg->pwhas.x1+x,tempg->pwhas.y1+y,z,tempg->pwhas.width,
tempg->pwhas.height,tempg->pwhas.sides,tempg->pwhas.angle);
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr=&tempg->y1; ptr=&tempg->nu.u;
x1=ptr[0]; x1=ptr[0];
y1=ptr[1]; y1=ptr[1];
for (i=1;i<tempg->num;i++) { for (i=1;i<tempg->nu.num;i++) {
x2=ptr[i<<1]; x2=ptr[i<<1];
y2=ptr[i<<1+1]; y2=ptr[i<<1+1];
GrLine3(dc,x1+x,y1+y,z,x2+x,y2+y,z); GrLine3(dc,x1+x,y1+y,z,x2+x,y2+y,z);
@@ -154,11 +155,10 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
} }
break; break;
case SPT_POLYPT: case SPT_POLYPT:
ptr=&tempg->y1; x1=tempg->npu.x;
x1=ptr[0]; y1=tempg->npu.y;
y1=ptr[1]; ptr=&tempg->npu.u;
ptr+=2; k=tempg->npu.num*3;
k=tempg->num*3;
GrPlot3(dc,x1+x,y1+y,z); GrPlot3(dc,x1+x,y1+y,z);
for (i=0;i<k;i+=3) { for (i=0;i<k;i+=3) {
j=BFieldExtU32(ptr,i,3); j=BFieldExtU32(ptr,i,3);
@@ -168,42 +168,43 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
} }
break; break;
sub_switch_start: sub_switch_start:
p=&tempg->y1; p=&tempg->nu.u;
for (i=0;i<tempg->num;i++,p++) { for (i=0;i<tempg->nu.num;i++,p++) {
p->x+=x; p->x+=x;
p->y+=y; p->y+=y;
p->z+=z; p->z+=z;
} }
case SPT_BSPLINE2: case SPT_BSPLINE2:
Gr2BSpline3(dc,&tempg->y1,tempg->num,FALSE); Gr2BSpline3(dc,&tempg->nu.u,tempg->nu.num,FALSE);
break; break;
case SPT_BSPLINE3: case SPT_BSPLINE3:
Gr3BSpline3(dc,&tempg->y1,tempg->num,FALSE); Gr3BSpline3(dc,&tempg->nu.u,tempg->nu.num,FALSE);
break; break;
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
Gr2BSpline3(dc,&tempg->y1,tempg->num,TRUE); Gr2BSpline3(dc,&tempg->nu.u,tempg->nu.num,TRUE);
break; break;
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
Gr3BSpline3(dc,&tempg->y1,tempg->num,TRUE); Gr3BSpline3(dc,&tempg->nu.u,tempg->nu.num,TRUE);
break; break;
sub_switch_end: sub_switch_end:
p=&tempg->y1; p=&tempg->nu.u;
for (i=0;i<tempg->num;i++,p++) { for (i=0;i<tempg->nu.num;i++,p++) {
p->x-=x; p->x-=x;
p->y-=y; p->y-=y;
p->z-=z; p->z-=z;
} }
break; break;
case SPT_MESH: case SPT_MESH:
p=&tempg->x2; p=&tempg->mu.u;
for (i=0;i<tempg->vertex_cnt;i++,p++) { for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
p->x+=x; p->x+=x;
p->y+=y; p->y+=y;
p->z+=z; p->z+=z;
} }
Gr3Mesh(dc,tempg->vertex_cnt,&tempg->x2,tempg->tri_cnt,(&tempg->x2)(U8 *)+sizeof(CD3I32)*tempg->vertex_cnt); Gr3Mesh(dc,tempg->mu.vertex_cnt,&tempg->mu.u,tempg->mu.tri_cnt,
p=&tempg->x2; (&tempg->mu.u)(U8 *)+sizeof(CD3I32)*tempg->mu.vertex_cnt);
for (i=0;i<tempg->vertex_cnt;i++,p++) { p=&tempg->mu.u;
for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
p->x-=x; p->x-=x;
p->y-=y; p->y-=y;
p->z-=z; p->z-=z;
@@ -211,35 +212,35 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
if (dc->flags&DCF_TRANSFORMATION) { if (dc->flags&DCF_TRANSFORMATION) {
dc->x+=tempg->x1; dc->x+=tempg->pmu.x;
dc->y+=tempg->y1; dc->y+=tempg->pmu.y;
dc->z+=tempg->z1; dc->z+=tempg->pmu.z;
x1=x; x1=x;
y1=y; y1=y;
z1=z; z1=z;
} else { } else {
x1=tempg->x1+x; x1=tempg->pmu.x+x;
y1=tempg->y1+y; y1=tempg->pmu.y+y;
z1=tempg->z1+z; z1=tempg->pmu.z+z;
} }
p=(&tempg->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg->pmu.u;
for (i=0;i<tempg->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
p->x+=x1; p->x+=x1;
p->y+=y1; p->y+=y1;
p->z+=z1; p->z+=z1;
} }
p=(&tempg->shiftable_tri_cnt)(U8 *)+sizeof(I32); Gr3Mesh(dc,tempg->pmu.vertex_cnt,&tempg->pmu.u,tempg->pmu.tri_cnt,
Gr3Mesh(dc,tempg->shiftable_vertex_cnt,p,tempg->shiftable_tri_cnt,p(U8 *)+sizeof(CD3I32)*tempg->shiftable_vertex_cnt); (&tempg->pmu.u)(U8 *)+sizeof(CD3I32)*tempg->pmu.vertex_cnt);
p=(&tempg->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg->pmu.u;
for (i=0;i<tempg->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
p->x-=x1; p->x-=x1;
p->y-=y1; p->y-=y1;
p->z-=z1; p->z-=z1;
} }
if (dc->flags&DCF_TRANSFORMATION) { if (dc->flags&DCF_TRANSFORMATION) {
dc->x-=tempg->x1; dc->x-=tempg->pmu.x;
dc->y-=tempg->y1; dc->y-=tempg->pmu.y;
dc->z-=tempg->z1; dc->z-=tempg->pmu.z;
} }
break; break;
} }
@@ -355,13 +356,13 @@ public U8 *SpriteInterpolate(U8 *elems0,U8 *elems1,F64 t)
throw('Graphics'); throw('Graphics');
switch (tempg0->type) { switch (tempg0->type) {
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
tempgr->rot_angle=(tempg0->rot_angle*t0+tempg1->rot_angle*t1)/GR_SCALE; tempgr->ppa.angle=(tempg0->ppa.angle*t0+tempg1->ppa.angle*t1)/GR_SCALE;
case SPT_RECT: case SPT_RECT:
case SPT_LINE: case SPT_LINE:
case SPT_ARROW: case SPT_ARROW:
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
tempgr->x2=(tempg0->x2*t0+tempg1->x2*t1)>>32; tempgr->pp.x2=(tempg0->pp.x2*t0+tempg1->pp.x2*t1)>>32;
tempgr->y2=(tempg0->y2*t0+tempg1->y2*t1)>>32; tempgr->pp.y2=(tempg0->pp.y2*t0+tempg1->pp.y2*t1)>>32;
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
@@ -369,69 +370,66 @@ public U8 *SpriteInterpolate(U8 *elems0,U8 *elems1,F64 t)
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
case SPT_SHIFT: case SPT_SHIFT:
tempgr->x1=(tempg0->x1*t0+tempg1->x1*t1)>>32; tempgr->p.x1=(tempg0->p.x1*t0+tempg1->p.x1*t1)>>32;
tempgr->y1=(tempg0->y1*t0+tempg1->y1*t1)>>32; tempgr->p.y1=(tempg0->p.y1*t0+tempg1->p.y1*t1)>>32;
break; break;
case SPT_CIRCLE: case SPT_CIRCLE:
tempgr->x2=(tempg0->x2*t0+tempg1->x2*t1)>>32; tempgr->pr.radius=(tempg0->pr.radius*t0+tempg1->pr.radius*t1)>>32;
tempgr->x1=(tempg0->x1*t0+tempg1->x1*t1)>>32; tempgr->pr.x1=(tempg0->pr.x1*t0+tempg1->pr.x1*t1)>>32;
tempgr->y1=(tempg0->y1*t0+tempg1->y1*t1)>>32; tempgr->pr.y1=(tempg0->pr.y1*t0+tempg1->pr.y1*t1)>>32;
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
case SPT_POLYGON: case SPT_POLYGON:
tempgr->x2=(tempg0->x2*t0+tempg1->x2*t1)>>32; tempgr->pwha.x1=(tempg0->pwha.x1*t0+tempg1->pwha.x1*t1)>>32;
tempgr->y2=(tempg0->y2*t0+tempg1->y2*t1)>>32; tempgr->pwha.y1=(tempg0->pwha.y1*t0+tempg1->pwha.y1*t1)>>32;
tempgr->width=(tempg0->width*t0+tempg1->width*t1)>>32; tempgr->pwha.width =(tempg0->pwha.width *t0+tempg1->pwha.width*t1)>>32;
tempgr->height=(tempg0->height*t0+tempg1->height*t1)>>32; tempgr->pwha.height=(tempg0->pwha.height*t0+tempg1->pwha.height*t1)>>32;
break; break;
case SPT_BITMAP: case SPT_BITMAP:
tempgr->x2=(tempg0->x2*t0+tempg1->x2*t1)>>32; tempgr->pwhu.x1=(tempg0->pwhu.x1*t0+tempg1->pwhu.x1*t1)>>32;
tempgr->y2=(tempg0->y2*t0+tempg1->y2*t1)>>32; tempgr->pwhu.y1=(tempg0->pwhu.y1*t0+tempg1->pwhu.y1*t1)>>32;
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr0=&tempg0->y1; ptr0=&tempg0->nu.u;
ptr1=&tempg1->y1; ptr1=&tempg1->nu.u;
ptrr=&tempgr->y1; ptrr=&tempgr->nu.u;
for (i=0;i<tempg0->num;i++) { for (i=0;i<tempg0->nu.num;i++) {
ptrr[i<<1]=(ptr0[i<<1]*t0+ptr1[i<<1]*t1)>>32; ptrr[i<<1]=(ptr0[i<<1]*t0+ptr1[i<<1]*t1)>>32;
ptrr[i<<1+1]=(ptr0[i<<1+1]*t0+ptr1[i<<1+1]*t1)>>32; ptrr[i<<1+1]=(ptr0[i<<1+1]*t0+ptr1[i<<1+1]*t1)>>32;
} }
break; break;
case SPT_POLYPT: case SPT_POLYPT:
ptr0=&tempg0->y1; tempgr->npu.x=(tempg0->npu.x*t0+tempg1->npu.x*t1)>>32;
ptr1=&tempg1->y1; tempgr->npu.y=(tempg0->npu.y*t0+tempg1->npu.y*t1)>>32;
ptrr=&tempgr->y1;
ptrr[0]=(ptr0[0]*t0+ptr1[0]*t1)>>32;
ptrr[1]=(ptr0[1]*t0+ptr1[1]*t1)>>32;
break; break;
case SPT_BSPLINE2: case SPT_BSPLINE2:
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
p0=&tempg0->y1; p0=&tempg0->nu.u;
p1=&tempg1->y1; p1=&tempg1->nu.u;
pr=&tempgr->y1; pr=&tempgr->nu.u;
for (i=0;i<tempg0->num;i++) { for (i=0;i<tempg0->nu.num;i++) {
pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32; pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32; pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32; pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
} }
break; break;
case SPT_MESH: case SPT_MESH:
p0=&tempg0->x2; p0=&tempg0->mu.u;
p1=&tempg1->x2; p1=&tempg1->mu.u;
pr=&tempgr->x2; pr=&tempgr->mu.u;
for (i=0;i<tempg0->vertex_cnt;i++) { for (i=0;i<tempg0->mu.vertex_cnt;i++) {
pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32; pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32; pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32; pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
} }
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
p0=(&tempg0->shiftable_tri_cnt)(U8 *)+sizeof(I32); p0=&tempg0->pmu.u;
p1=(&tempg1->shiftable_tri_cnt)(U8 *)+sizeof(I32); p1=&tempg1->pmu.u;
pr=(&tempgr->shiftable_tri_cnt)(U8 *)+sizeof(I32); pr=&tempgr->pmu.u;
for (i=0;i<tempg0->shiftable_vertex_cnt;i++) { for (i=0;i<tempg0->pmu.vertex_cnt;i++) {
pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32; pr[i].x=(p0[i].x*t0+p1[i].x*t1)>>32;
pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32; pr[i].y=(p0[i].y*t0+p1[i].y*t1)>>32;
pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32; pr[i].z=(p0[i].z*t0+p1[i].z*t1)>>32;
+12 -11
View File
@@ -5,7 +5,7 @@ asm {
USE64 USE64
//************************************ //************************************
_TEXT_CHAR:://Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d); _TEXT_CHAR:://Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d);
//Must be called 60fps in Fs->draw_it() callback. //Must be called 30fps in Fs->draw_it() callback.
PUSH RBP PUSH RBP
MOV RBP,RSP MOV RBP,RSP
MOV RCX,U64 SF_ARG1[RBP] MOV RCX,U64 SF_ARG1[RBP]
@@ -82,7 +82,7 @@ _TEXT_CHAR:://Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64
RET1 40 RET1 40
//************************************ //************************************
_TEXT_LEN_STR:://Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s) _TEXT_LEN_STR:://Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s)
//Must be called 60fps in Fs->draw_it() callback. //Must be called 30fps in Fs->draw_it() callback.
PUSH RBP PUSH RBP
MOV RBP,RSP MOV RBP,RSP
PUSH RSI PUSH RSI
@@ -157,7 +157,7 @@ _TEXT_LEN_STR:://Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s)
RET1 48 RET1 48
//************************************ //************************************
_TEXT_LEN_ATTR_STR:://Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr) _TEXT_LEN_ATTR_STR:://Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr)
//Must be called 60fps in Fs->draw_it() callback. //Must be called 30fps in Fs->draw_it() callback.
PUSH RBP PUSH RBP
MOV RBP,RSP MOV RBP,RSP
PUSH RSI PUSH RSI
@@ -232,7 +232,7 @@ _TEXT_LEN_ATTR_STR:://Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_
RET1 40 RET1 40
//************************************ //************************************
_TEXT_LEN_ATTR:://Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr) _TEXT_LEN_ATTR:://Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr)
//Must be called 60fps in Fs->draw_it() callback. //Must be called 30fps in Fs->draw_it() callback.
PUSH RBP PUSH RBP
MOV RBP,RSP MOV RBP,RSP
PUSH RSI PUSH RSI
@@ -307,13 +307,13 @@ _TEXT_LEN_ATTR:://Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr)
POP RBP POP RBP
RET1 40 RET1 40
} }
public _extern _TEXT_CHAR Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d); //Plot char. Must be called 60fps in Fs->draw_it() callback. public _extern _TEXT_CHAR Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d); //Plot char. Must be called 30fps in Fs->draw_it() callback.
public _extern _TEXT_LEN_STR Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s); //Plot str with len. Must be called 60fps in Fs->draw_it() callback. public _extern _TEXT_LEN_STR Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s); //Plot str with len. Must be called 30fps in Fs->draw_it() callback.
public _extern _TEXT_LEN_ATTR_STR Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr); //Plot attr str with len. Must be called 60fps in Fs->draw_it() callback. public _extern _TEXT_LEN_ATTR_STR Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr); //Plot attr str with len. Must be called 30fps in Fs->draw_it() callback.
public _extern _TEXT_LEN_ATTR Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr); //Plot attrs with len. Must be called 60fps in Fs->draw_it() callback. public _extern _TEXT_LEN_ATTR Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr); //Plot attrs with len. Must be called 30fps in Fs->draw_it() callback.
public U0 TextPrint(CTask *task,I64 x,I64 y,I64 attr,U8 *fmt,...) public U0 TextPrint(CTask *task,I64 x,I64 y,I64 attr,U8 *fmt,...)
{//Plot chars. Must be called 60fps in Fs->draw_it() callback. {//Plot chars. Must be called 30fps in Fs->draw_it() callback.
//You probably want $LK,"GrPrint",A="MN:GrPrint"$() or just $LK,"Print",A="MN:Print"$(). //You probably want $LK,"GrPrint",A="MN:GrPrint"$() or just $LK,"Print",A="MN:Print"$().
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv); U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
TextLenStr(task,x,y,StrLen(buf),attr<<8,buf); TextLenStr(task,x,y,StrLen(buf),attr<<8,buf);
@@ -321,7 +321,7 @@ public U0 TextPrint(CTask *task,I64 x,I64 y,I64 attr,U8 *fmt,...)
} }
public U0 TextBorder(CTask *task=NULL,I64 l,I64 r,I64 t,I64 b,I64 attr,Bool solid) public U0 TextBorder(CTask *task=NULL,I64 l,I64 r,I64 t,I64 b,I64 attr,Bool solid)
{//Plot border square. Must be called 60fps in Fs->draw_it() callback. {//Plot border square. Must be called 30fps in Fs->draw_it() callback.
//Draws window borders or DolDoc text button borders. //Draws window borders or DolDoc text button borders.
//Set task=sys_winmgr_task for no clipping. //Set task=sys_winmgr_task for no clipping.
I64 i; I64 i;
@@ -357,7 +357,7 @@ public U0 TextBorder(CTask *task=NULL,I64 l,I64 r,I64 t,I64 b,I64 attr,Bool soli
} }
public U0 TextRect(I64 l,I64 r,I64 t,I64 b,I64 d) public U0 TextRect(I64 l,I64 r,I64 t,I64 b,I64 d)
{//Fill text rect. Must be called 60fps in Fs->draw_it() callback. {//Fill text rect. Must be called 30fps in Fs->draw_it() callback.
I64 y,w; I64 y,w;
if (l>r || t>b) return; if (l>r || t>b) return;
if (t<0) t=0; if (t<0) t=0;
@@ -368,3 +368,4 @@ public U0 TextRect(I64 l,I64 r,I64 t,I64 b,I64 d)
for (y=t;y<=b;y++) for (y=t;y<=b;y++)
MemSetU32(gr.text_base(U8 *)+(y*TEXT_COLS+l)*sizeof(U32),d,w); MemSetU32(gr.text_base(U8 *)+(y*TEXT_COLS+l)*sizeof(U32),d,w);
} }
+16 -13
View File
@@ -85,8 +85,8 @@ I64 PopUpSpriteBitMap(CColorROPU32 color,I64 width)
"\n$$MU-UL,\"Undo\",LE=GBM_UNDO$$\n" "\n$$MU-UL,\"Undo\",LE=GBM_UNDO$$\n"
"\n$$PURPLE$$$$MU-UL,\"+] Sprite Main Menu\",LE=GBM_MAIN_MENU$$$$LTBLUE$$\n" "\n$$PURPLE$$$$MU-UL,\"+] Sprite Main Menu\",LE=GBM_MAIN_MENU$$$$LTBLUE$$\n"
"$$MU-UL,\"Exit Sprite\",LE=GBM_EXIT$$\n" "$$MU-UL,\"Exit Sprite\",LE=GBM_EXIT$$\n"
"$$MU-UL,\"Abort Sprite\",LE=DOCM_CANCEL$$\n",st1,st2,width); "$$MU-UL,\"Abort Sprite\",LE=DOCM_CANCEL$$\n"
DocPrint(doc,"\nRight-Click to get back to this menu."); "\nRight-Click to get back to this menu.",st1,st2,width);
i=PopUpMenu(doc); i=PopUpMenu(doc);
DocDel(doc); DocDel(doc);
return i; return i;
@@ -224,12 +224,21 @@ I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,I64 *_xx2
1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN)) { 1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN)) {
switch (msg_code) { switch (msg_code) {
case MSG_KEY_DOWN: case MSG_KEY_DOWN:
if (a1==CH_SHIFT_ESC) { switch (a1) {
case CH_SHIFT_ESC:
result=GE_ABORT; result=GE_ABORT;
goto bm_key_up_done; goto bm_key_up_done;
} else if (a1==CH_ESC) { case CH_ESC:
result=GE_CONT; result=GE_CONT;
goto bm_key_up_done; goto bm_key_up_done;
case 'c': //eye-dropper
dc2=DCCaptureScreen(FALSE);
color=GrPeek(dc2,ip.pos.x,ip.pos.y)^15;//Mouse cursor is XORed.
DCDel(dc2);
break;
case 't': //Set to transparent color
color=TRANSPARENT;
break;
} }
break; break;
@@ -291,7 +300,7 @@ bm_menu:
case GBM_SAVE_BMP: case GBM_SAVE_BMP:
*filename.name=0; *filename.name=0;
if (DocFormDo(&filename) && *filename.name) if (DocFormDo(&filename) && *filename.name)
BMPFileWrite(filename.name,img); BMPWrite(filename.name,img);
goto bm_menu; goto bm_menu;
case GBM_SAVE_GRA: case GBM_SAVE_GRA:
@@ -363,19 +372,13 @@ bm_menu:
GrPlot3(img,a1-xx1,a2-yy1,0); GrPlot3(img,a1-xx1,a2-yy1,0);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img); GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break; break;
case GBM_LINE: sub_switch_start:
case GBM_ARROW:
case GBM_RECT:
case GBM_CIRCLE:
case GBM_COPY:
case GBM_DELETE:
if (down) if (down)
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img); GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
x1=a1; y1=a2; x1=a1; y1=a2;
down=TRUE; down=TRUE;
dc->color=color; dc->color=color;
dc->pen_width=width; dc->pen_width=width;
switch (mode) {
case GBM_LINE: case GBM_LINE:
GrLine3(dc,x1,y1,0,a1,a2,0); GrLine3(dc,x1,y1,0,a1,a2,0);
break; break;
@@ -394,7 +397,7 @@ bm_menu:
dc->pen_width=1; dc->pen_width=1;
GrBorder(dc,x1,y1,x1,y1); GrBorder(dc,x1,y1,x1,y1);
break; break;
} sub_switch_end:
break; break;
case GBM_PASTE: case GBM_PASTE:
case GBM_PASTE_TRANSPARENT: case GBM_PASTE_TRANSPARENT:
+92 -100
View File
@@ -12,11 +12,11 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
switch (tempg->type) { switch (tempg->type) {
case SPT_COLOR: case SPT_COLOR:
DocPrint(doc,"{%s}", DocPrint(doc,"{%s}",
Color2Str(buf1,tempg->color)); Color2Str(buf1,tempg->c.color));
break; break;
case SPT_DITHER_COLOR: case SPT_DITHER_COLOR:
DocPrint(doc,"{%s}", DocPrint(doc,"{%s}",
Color2Str(buf2,ROPF_DITHER|tempg->dither_color.u8[0]|tempg->dither_color.u8[1]<<COLORROP_BITS)); Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|tempg->d.dither_color.u8[1]<<COLORROP_BITS));
break; break;
case SPT_TRANSFORM_ON: case SPT_TRANSFORM_ON:
DocPrint(doc,"{ON}"); DocPrint(doc,"{ON}");
@@ -27,55 +27,53 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
case SPT_LINE: case SPT_LINE:
case SPT_ARROW: case SPT_ARROW:
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
DocPrint(doc,"{(%d,%d),(%d,%d)}",tempg->x1,tempg->y1,tempg->x2,tempg->y2); DocPrint(doc,"{(%d,%d),(%d,%d)}",tempg->pp.x1,tempg->pp.y1,tempg->pp.x2,tempg->pp.y2);
break; break;
case SPT_RECT: case SPT_RECT:
DocPrint(doc,"{(%d,%d):(%d,%d)}",tempg->x1,tempg->y1, DocPrint(doc,"{(%d,%d):(%d,%d)}",tempg->pp.x1,tempg->pp.y1,
tempg->x2-tempg->x1,tempg->y2-tempg->y1); tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
break; break;
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->x1,tempg->y1, DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->ppa.x1,tempg->ppa.y1,
tempg->x2-tempg->x1,tempg->y2-tempg->y1, tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1,
180/ã*Wrap(tempg->rot_angle)); 180/ã*Wrap(tempg->ppa.angle));
break; break;
case SPT_PT: case SPT_PT:
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_SHIFT: case SPT_SHIFT:
DocPrint(doc,"{(%d,%d)}",tempg->x1,tempg->y1); DocPrint(doc,"{(%d,%d)}",tempg->p.x1,tempg->p.y1);
break; break;
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
DocPrint(doc,"{(%d,%d),TRUE}",tempg->x1,tempg->y1); DocPrint(doc,"{(%d,%d),TRUE}",tempg->p.x1,tempg->p.y1);
break; break;
case SPT_CIRCLE: case SPT_CIRCLE:
DocPrint(doc,"{(%d,%d):%d}",tempg->x1,tempg->y1,tempg->x2); DocPrint(doc,"{(%d,%d):%d}",tempg->pr.x1,tempg->pr.y1,tempg->pr.radius);
break; break;
case SPT_WIDTH: case SPT_WIDTH:
DocPrint(doc,"{%d}",tempg->width); DocPrint(doc,"{%d}",tempg->w.width);
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->x2,tempg->y2, DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->pwha.x1,tempg->pwha.y1,
tempg->width,tempg->height,180/ã*Wrap(tempg->rot_angle)); tempg->pwha.width,tempg->pwha.height,180/ã*Wrap(tempg->pwha.angle));
break; break;
case SPT_POLYGON: case SPT_POLYGON:
DocPrint(doc,"{%d,(%d,%d):(%d,%d),%0.4f}",tempg->sides,tempg->x2,tempg->y2, DocPrint(doc,"{%d,(%d,%d):(%d,%d),%0.4f}",tempg->pwhas.sides,
tempg->width,tempg->height,180/ã*Wrap(tempg->rot_angle)); tempg->pwhas.x1,tempg->pwhas.y1,tempg->pwhas.width,tempg->pwhas.height,
180/ã*Wrap(tempg->pwhas.angle));
break; break;
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
DocPrint(doc,"{(%d,%d),\"%Q\"}",tempg->x1,tempg->y1,tempg->st); DocPrint(doc,"{(%d,%d),\"%Q\"}",tempg->ps.x1,tempg->ps.y1,tempg->ps.st);
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr=&tempg->y1; ptr=&tempg->nu.u;
DocPrint(doc,"{(%d,%d)",ptr[0],ptr[1]); DocPrint(doc,"{");
if (tempg->num>1) DocPrint(doc,","); for (i=0;i<tempg->nu.num;i++,ptr+=2) {
ptr+=2;
for (i=1;i<tempg->num;i++) {
DocPrint(doc,"(%d,%d)",ptr[0],ptr[1]); DocPrint(doc,"(%d,%d)",ptr[0],ptr[1]);
if (i+1<tempg->num) DocPrint(doc,","); if (i+1<tempg->nu.num) DocPrint(doc,",");
if (i&3==3 && i+1<tempg->num) if (i&3==3 && i+1<tempg->nu.num)
DocPrint(doc,"\n"); DocPrint(doc,"\n");
ptr+=2;
} }
DocPrint(doc,"}"); DocPrint(doc,"}");
break; break;
@@ -83,14 +81,12 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
ptr=&tempg->y1; ptr=&tempg->nu.u;
DocPrint(doc,"{(%d,%d,%d)",ptr[0],ptr[1],ptr[2]); DocPrint(doc,"{");
ptr+=3; for (i=0;i<tempg->nu.num;i++,ptr+=3) {
if (tempg->num>1) DocPrint(doc,",");
for (i=1;i<tempg->num;i++,ptr+=3) {
DocPrint(doc,"(%d,%d,%d)",ptr[0],ptr[1],ptr[2]); DocPrint(doc,"(%d,%d,%d)",ptr[0],ptr[1],ptr[2]);
if (i+1<tempg->num) DocPrint(doc,","); if (i+1<tempg->nu.num) DocPrint(doc,",");
if (i&3==3 && i+1<tempg->num) if (i&3==3 && i+1<tempg->nu.num)
DocPrint(doc,"\n"); DocPrint(doc,"\n");
} }
if (tempg->type==SPT_BSPLINE2||tempg->type==SPT_BSPLINE3) if (tempg->type==SPT_BSPLINE2||tempg->type==SPT_BSPLINE3)
@@ -99,13 +95,12 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
DocPrint(doc,",TRUE}"); DocPrint(doc,",TRUE}");
break; break;
case SPT_POLYPT: case SPT_POLYPT:
ptr=&tempg->y1; DocPrint(doc,"{(%d,%d),",tempg->npu.x,tempg->npu.y);
DocPrint(doc,"{(%d,%d),",ptr[0],ptr[1]); ptr=&tempg->npu.u;
ptr+=2;
col=16; col=16;
for (i=0;i<tempg->num;i++) { for (i=0;i<tempg->npu.num;i++) {
DocPrint(doc,"%d",BFieldExtU32(ptr,i*3,3)); DocPrint(doc,"%d",BFieldExtU32(ptr,i*3,3));
if (++col>=64 && i+1<tempg->num) { if (++col>=64 && i+1<tempg->npu.num) {
DocPrint(doc,"\n"); DocPrint(doc,"\n");
col=0; col=0;
} }
@@ -113,23 +108,24 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
DocPrint(doc,"}"); DocPrint(doc,"}");
break; break;
case SPT_BITMAP: case SPT_BITMAP:
DocPrint(doc,"{(%d,%d):(%d,%d),\n",tempg->x2,tempg->y2,tempg->width,tempg->height); DocPrint(doc,"{(%d,%d):(%d,%d),\n",tempg->pwhu.x1,tempg->pwhu.y1,
width_internal=(tempg->width+7)&~7; tempg->pwhu.width,tempg->pwhu.height);
width_internal=(tempg->pwhu.width+7)&~7;
if (width_internal<80) if (width_internal<80)
k=width_internal; k=width_internal;
else else
k=64; k=64;
ptr=tempg(U8 *)+offset(CSprite.linespeed); ptr=&tempg->pwhu.u;
col=0; col=0;
for (j=0;j<tempg->height;j++) for (j=0;j<tempg->pwhu.height;j++)
for (i=0;i<width_internal;i++,ptr(U8 *)++) { for (i=0;i<width_internal;i++,ptr(U8 *)++) {
if (i>=tempg->width) if (i>=tempg->pwhu.width)
DocPrint(doc,"_"); DocPrint(doc,"_");
else if (*ptr(U8 *)<16) else if (*ptr(U8 *)<16)
DocPrint(doc,"%X",*ptr(U8 *)); DocPrint(doc,"%X",*ptr(U8 *));
else else
DocPrint(doc,"%c",CH_SHIFT_SPACE); DocPrint(doc,"%c",CH_SHIFT_SPACE);
if (++col>=k && (i+1<width_internal||j+1<tempg->height)) { if (++col>=k && (i+1<width_internal||j+1<tempg->pwhu.height)) {
DocPrint(doc,"\n"); DocPrint(doc,"\n");
col=0; col=0;
} }
@@ -138,11 +134,11 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
break; break;
case SPT_MESH: case SPT_MESH:
DocPrint(doc,"{FALSE,"); DocPrint(doc,"{FALSE,");
p=(&tempg->tri_cnt)(U8 *)+sizeof(I32); p=&tempg->mu.u;
col=0; col=0;
for (i=0;i<tempg->vertex_cnt;i++,p++) { for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
DocPrint(doc,"(%d,%d,%d)",p->x,p->y,p->z); DocPrint(doc,"(%d,%d,%d)",p->x,p->y,p->z);
if (i+1<tempg->vertex_cnt) DocPrint(doc,","); if (i+1<tempg->mu.vertex_cnt) DocPrint(doc,",");
if (++col==4) { if (++col==4) {
DocPrint(doc,"\t//%d\n",i); DocPrint(doc,"\t//%d\n",i);
col=0; col=0;
@@ -150,11 +146,11 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
} }
DocPrint(doc,":"); DocPrint(doc,":");
tri=p; tri=p;
for (i=0;i<tempg->tri_cnt;i++,tri++) { for (i=0;i<tempg->mu.tri_cnt;i++,tri++) {
DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color), DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color),
tri->nums[0],tri->nums[1],tri->nums[2]); tri->nums[0],tri->nums[1],tri->nums[2]);
if (i+1<tempg->tri_cnt) DocPrint(doc,","); if (i+1<tempg->mu.tri_cnt) DocPrint(doc,",");
if (++col>=3 && i+1<tempg->tri_cnt) { if (++col>=3 && i+1<tempg->mu.tri_cnt) {
DocPrint(doc,"\n"); DocPrint(doc,"\n");
col=0; col=0;
} }
@@ -162,12 +158,12 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
DocPrint(doc,"}"); DocPrint(doc,"}");
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
DocPrint(doc,"{TRUE,(%d,%d,%d):",tempg->x1,tempg->y1,tempg->z1); DocPrint(doc,"{TRUE,(%d,%d,%d):",tempg->pmu.x,tempg->pmu.y,tempg->pmu.z);
p=(&tempg->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg->pmu.u;
col=1; col=1;
for (i=0;i<tempg->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
DocPrint(doc,"(%d,%d,%d)",p->x,p->y,p->z); DocPrint(doc,"(%d,%d,%d)",p->x,p->y,p->z);
if (i+1<tempg->shiftable_vertex_cnt) DocPrint(doc,","); if (i+1<tempg->pmu.vertex_cnt) DocPrint(doc,",");
if (++col==4) { if (++col==4) {
DocPrint(doc,"\t//%d\n",i); DocPrint(doc,"\t//%d\n",i);
col=0; col=0;
@@ -175,11 +171,11 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
} }
DocPrint(doc,":"); DocPrint(doc,":");
tri=p; tri=p;
for (i=0;i<tempg->shiftable_tri_cnt;i++,tri++) { for (i=0;i<tempg->pmu.tri_cnt;i++,tri++) {
DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color), DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color),
tri->nums[0],tri->nums[1],tri->nums[2]); tri->nums[0],tri->nums[1],tri->nums[2]);
if (i+1<tempg->shiftable_tri_cnt) DocPrint(doc,","); if (i+1<tempg->pmu.tri_cnt) DocPrint(doc,",");
if (++col>=3 && i+1<tempg->shiftable_tri_cnt) { if (++col>=3 && i+1<tempg->pmu.tri_cnt) {
DocPrint(doc,"\n"); DocPrint(doc,"\n");
col=0; col=0;
} }
@@ -217,9 +213,9 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
color=Str2ColorU32(st); color=Str2ColorU32(st);
Free(st); Free(st);
Lex(lx); //Skip color Lex(lx); //Skip color
g.color=color.c0.color; g.c.color=color.c0.color;
if (color&ROPF_DITHER) { if (color&ROPF_DITHER) {
g.dither_color.u8[1]=color.c1.color; g.d.dither_color.u8[1]=color.c1.color;
g.type=SPT_DITHER_COLOR; g.type=SPT_DITHER_COLOR;
} else } else
g.type=SPT_COLOR; g.type=SPT_COLOR;
@@ -237,25 +233,25 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
Lex(lx); //Skip { Lex(lx); //Skip {
g.type=type; g.type=type;
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.pp.x1);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
Lex(lx); //Skip , Lex(lx); //Skip ,
LexD2I32(lx,&g.x2); LexD2I32(lx,&g.pp.x2);
break; break;
case SPT_RECT: case SPT_RECT:
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
Lex(lx); //Skip { Lex(lx); //Skip {
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.pp.x1);
if (lx->token!=':') if (lx->token!=':')
LexExcept(lx,"expecting ':' at "); LexExcept(lx,"expecting ':' at ");
Lex(lx); //Skip : Lex(lx); //Skip :
LexD2I32(lx,&g.x2); LexD2I32(lx,&g.pp.x2);
g.x2+=g.x1; g.ppa.x2+=g.pp.x1;
g.y2+=g.y1; g.ppa.y2+=g.pp.y1;
if (lx->token==',') { if (lx->token==',') {
Lex(lx); //Skip , Lex(lx); //Skip ,
g.rot_angle=ã/180*LexExpressionF64(lx); g.ppa.angle=ã/180*LexExpressionF64(lx);
g.type=SPT_ROTATED_RECT; g.type=SPT_ROTATED_RECT;
} else } else
g.type=SPT_RECT; g.type=SPT_RECT;
@@ -264,12 +260,12 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
case SPT_SHIFT: case SPT_SHIFT:
Lex(lx); //Skip { Lex(lx); //Skip {
g.type=type; g.type=type;
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.p.x1);
break; break;
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
Lex(lx); //Skip { Lex(lx); //Skip {
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.p.x1);
if (lx->token==',') { if (lx->token==',') {
Lex(lx); //Skip , Lex(lx); //Skip ,
i=LexExpressionI64(lx); i=LexExpressionI64(lx);
@@ -282,36 +278,35 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
break; break;
case SPT_WIDTH: case SPT_WIDTH:
Lex(lx); //Skip { Lex(lx); //Skip {
g.width=LexExpressionI64(lx); g.w.width=LexExpressionI64(lx);
g.type=SPT_WIDTH; g.type=SPT_WIDTH;
break; break;
case SPT_CIRCLE: case SPT_CIRCLE:
Lex(lx); //Skip { Lex(lx); //Skip {
g.type=SPT_CIRCLE; g.type=SPT_CIRCLE;
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.pr.x1);
if (lx->token!=':') if (lx->token!=':')
LexExcept(lx,"expecting ':' at "); LexExcept(lx,"expecting ':' at ");
Lex(lx); //Skip : Lex(lx); //Skip :
g.x2=LexExpressionI64(lx); g.pr.radius=LexExpressionI64(lx);
break; break;
case SPT_POLYGON: case SPT_POLYGON:
Lex(lx); //Skip { Lex(lx); //Skip {
g.sides=LexExpressionI64(lx); g.pwhas.sides=LexExpressionI64(lx);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
Lex(lx); //Skip ,
case SPT_ELLIPSE: case SPT_ELLIPSE:
Lex(lx); //Skip { Lex(lx); //Skip {
g.type=type; g.type=type;
LexD2I32(lx,&g.x2); LexD2I32(lx,&g.pwha.x1);
if (lx->token!=':') if (lx->token!=':')
LexExcept(lx,"expecting ':' at "); LexExcept(lx,"expecting ':' at ");
Lex(lx); //Skip : Lex(lx); //Skip :
LexD2I32(lx,&g.width); LexD2I32(lx,&g.pwha.width);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
Lex(lx); //Skip , Lex(lx); //Skip ,
g.rot_angle=ã/180*LexExpressionF64(lx); g.pwha.angle=ã/180*LexExpressionF64(lx);
break; break;
sub_switch_end: sub_switch_end:
size=SpriteElemSize(&g)+offset(CSprite.start); size=SpriteElemSize(&g)+offset(CSprite.start);
@@ -323,7 +318,7 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
Lex(lx); //Skip { Lex(lx); //Skip {
g.type=type; g.type=type;
LexD2I32(lx,&g.x1); LexD2I32(lx,&g.ps.x1);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
if (Lex(lx)==TK_STR) //Skip , if (Lex(lx)==TK_STR) //Skip ,
@@ -345,17 +340,16 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
tempp=CAlloc(sizeof(CQueD3I32)); tempp=CAlloc(sizeof(CQueD3I32));
LexD2I32(lx,&tempp->p); LexD2I32(lx,&tempp->p);
QueIns(tempp,rootp.last); QueIns(tempp,rootp.last);
g.num++; g.nu.num++;
if (lx->token==',') if (lx->token==',')
Lex(lx); //Skip , Lex(lx); //Skip ,
} }
if (!g.num) if (g.nu.num<2)
LexExcept(lx,"expecting point at "); LexExcept(lx,"expecting point at ");
size=SpriteElemQuedBaseSize(SPT_POLYLINE); size=SpriteElemQuedBaseSize(SPT_POLYLINE);
i=g.num*sizeof(CD2I32); result=MAlloc(size+g.nu.num*sizeof(CD2I32));
result=MAlloc(size+i);
MemCpy(result,&g,size); MemCpy(result,&g,size);
ptr=&result->y1; ptr=&result->nu.u;
tempp=rootp.next; tempp=rootp.next;
while (tempp!=&rootp) { while (tempp!=&rootp) {
tempa1=tempp->next; tempa1=tempp->next;
@@ -375,15 +369,14 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
tempp=CAlloc(sizeof(CQueD3I32)); tempp=CAlloc(sizeof(CQueD3I32));
LexD3I32(lx,&tempp->p); LexD3I32(lx,&tempp->p);
QueIns(tempp,rootp.last); QueIns(tempp,rootp.last);
g.num++; g.nu.num++;
if (lx->token==',') if (lx->token==',')
Lex(lx); //Skip , Lex(lx); //Skip ,
} }
if (!g.num) if (g.nu.num<2)
LexExcept(lx,"expecting point at "); LexExcept(lx,"expecting point at ");
size=SpriteElemQuedBaseSize(type); size=SpriteElemQuedBaseSize(type);
i=g.num*sizeof(CD3I32); result=MAlloc(size+g.nu.num*sizeof(CD3I32));
result=MAlloc(size+i);
if (LexExpressionI64(lx)) { if (LexExpressionI64(lx)) {
if (type==SPT_BSPLINE2||type==SPT_BSPLINE2_CLOSED) if (type==SPT_BSPLINE2||type==SPT_BSPLINE2_CLOSED)
g.type=SPT_BSPLINE2_CLOSED; g.type=SPT_BSPLINE2_CLOSED;
@@ -396,7 +389,7 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
g.type=SPT_BSPLINE3; g.type=SPT_BSPLINE3;
} }
MemCpy(result,&g,size); MemCpy(result,&g,size);
ptr=&result->y1; ptr=&result->nu.u;
tempp=rootp.next; tempp=rootp.next;
while (tempp!=&rootp) { while (tempp!=&rootp) {
tempa1=tempp->next; tempa1=tempp->next;
@@ -408,7 +401,7 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
break; break;
case SPT_POLYPT: case SPT_POLYPT:
Lex(lx); //Skip { Lex(lx); //Skip {
LexD2I32(lx,&g.y1); LexD2I32(lx,&g.npu.x);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
tempv=QueVectU8New; tempv=QueVectU8New;
@@ -418,27 +411,26 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
if (i=='}') if (i=='}')
break; break;
if ('0'<=i<='7') if ('0'<=i<='7')
QueVectU8Put(tempv,g.num++,i-'0'); QueVectU8Put(tempv,g.npu.num++,i-'0');
} }
Bts(&lx->flags,Lf_USE_LAST_U16); Bts(&lx->flags,Lf_USE_LAST_U16);
Lex(lx); //Load '}' Lex(lx); //Load '}'
g.type=SPT_POLYPT; g.type=SPT_POLYPT;
size=SpriteElemQuedBaseSize(SPT_POLYPT); size=SpriteElemQuedBaseSize(SPT_POLYPT);
i=(g.num*3+7)>>3; result=CAlloc(size+(g.npu.num*3+7)>>3);
result=CAlloc(size+i);
MemCpy(result,&g,size); MemCpy(result,&g,size);
ptr=&result->y2; ptr=&result->npu.u;
for (i=0;i<g.num;i++) for (i=0;i<g.npu.num;i++)
BFieldOrU32(ptr,i*3,QueVectU8Get(tempv,i)); BFieldOrU32(ptr,i*3,QueVectU8Get(tempv,i));
QueVectU8Del(tempv); QueVectU8Del(tempv);
break; break;
case SPT_BITMAP: case SPT_BITMAP:
Lex(lx); //Skip { Lex(lx); //Skip {
LexD2I32(lx,&g.x2); LexD2I32(lx,&g.pwhu.x1);
if (lx->token!=':') if (lx->token!=':')
LexExcept(lx,"expecting ':' at "); LexExcept(lx,"expecting ':' at ");
Lex(lx); //Skip : Lex(lx); //Skip :
LexD2I32(lx,&g.width); LexD2I32(lx,&g.pwhu.width);
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
tempv=QueVectU8New; tempv=QueVectU8New;
@@ -463,7 +455,7 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
size=SpriteElemQuedBaseSize(SPT_BITMAP); size=SpriteElemQuedBaseSize(SPT_BITMAP);
result=CAlloc(size+num1); result=CAlloc(size+num1);
MemCpy(result,&g,size); MemCpy(result,&g,size);
ptr=&result->linespeed; ptr=&result->pwhu.u;
for (i=0;i<num1;i++) for (i=0;i<num1;i++)
*ptr++=QueVectU8Get(tempv,i); *ptr++=QueVectU8Get(tempv,i);
QueVectU8Del(tempv); QueVectU8Del(tempv);
@@ -476,7 +468,7 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
if (lx->token!=',') if (lx->token!=',')
LexExcept(lx,"expecting ',' at "); LexExcept(lx,"expecting ',' at ");
Lex(lx); //Skip , Lex(lx); //Skip ,
LexD3I32(lx,&g.x1); LexD3I32(lx,&g.pmu.x);
if (lx->token!=':') if (lx->token!=':')
LexExcept(lx,"expecting ':' at "); LexExcept(lx,"expecting ':' at ");
Lex(lx); //Skip : Lex(lx); //Skip :
@@ -528,12 +520,12 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
Lex(lx); //Skip , Lex(lx); //Skip ,
} }
if (g.type==SPT_MESH) { if (g.type==SPT_MESH) {
g.vertex_cnt=num1; g.mu.vertex_cnt=num1;
g.tri_cnt=num2; g.mu.tri_cnt=num2;
size=SpriteElemQuedBaseSize(SPT_MESH); size=SpriteElemQuedBaseSize(SPT_MESH);
} else { } else {
g.shiftable_vertex_cnt=num1; g.pmu.vertex_cnt=num1;
g.shiftable_tri_cnt=num2; g.pmu.tri_cnt=num2;
} }
size=SpriteElemQuedBaseSize(g.type); size=SpriteElemQuedBaseSize(g.type);
result=MAlloc(size+num1*sizeof(CD3I32)+num2*sizeof(CMeshTri)); result=MAlloc(size+num1*sizeof(CD3I32)+num2*sizeof(CMeshTri));
+149 -189
View File
@@ -4,8 +4,8 @@ Bool SpritePolyPtPlot(CSprite *root,I64 x,I64 y,I64)
{ {
CSprite *tempg=CAlloc(SpriteElemQuedBaseSize(SPT_PT)); CSprite *tempg=CAlloc(SpriteElemQuedBaseSize(SPT_PT));
tempg->type=SPT_PT; tempg->type=SPT_PT;
tempg->x1=x; tempg->p.x1=x;
tempg->y1=y; tempg->p.y1=y;
QueIns(tempg,root->last); QueIns(tempg,root->last);
return TRUE; return TRUE;
} }
@@ -16,8 +16,8 @@ CSprite *SpriteElemNum2QueEntry(CSprite *root,I64 elem_num,I64 *_x=NULL,I64 *_y=
CSprite *result=root->next; CSprite *result=root->next;
while (result!=root && elem_num--) { while (result!=root && elem_num--) {
if (result->type==SPT_SHIFT) { if (result->type==SPT_SHIFT) {
xx+=result->x1; xx+=result->p.x1;
yy+=result->y1; yy+=result->p.y1;
} }
result=result->next; result=result->next;
} }
@@ -83,75 +83,60 @@ U0 SpriteSetOrigin(CSprite *root,I64 dx,I64 dy,I64 dz)
CSprite *tempg=root->next; CSprite *tempg=root->next;
while (tempg!=root) { while (tempg!=root) {
switch (tempg->type) { switch (tempg->type) {
case SPT_PT:
case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT:
tempg->x1+=dx;
tempg->y1+=dy;
break;
case SPT_ARROW: case SPT_ARROW:
case SPT_LINE: case SPT_LINE:
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
tempg->x1+=dx;
tempg->y1+=dy;
tempg->x2+=dx;
tempg->y2+=dy;
break;
case SPT_BITMAP:
case SPT_ELLIPSE:
case SPT_POLYGON:
tempg->x2+=dx;
tempg->y2+=dy;
break;
case SPT_RECT: case SPT_RECT:
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
tempg->x1+=dx; tempg->pp.x2+=dx;
tempg->y1+=dy; tempg->pp.y2+=dy;
tempg->x2+=dx; case SPT_PT:
tempg->y2+=dy; case SPT_FLOOD_FILL:
break; case SPT_FLOOD_FILL_NOT:
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
case SPT_CIRCLE: case SPT_CIRCLE:
tempg->x1+=dx; case SPT_BITMAP:
tempg->y1+=dy; case SPT_ELLIPSE:
case SPT_POLYGON:
tempg->p.x1+=dx;
tempg->p.y1+=dy;
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr=&tempg->y1; ptr=&tempg->nu.u;
for (i=0;i<tempg->num;i++) { for (i=0;i<tempg->nu.num;i++) {
ptr[i<<1]+=dx; ptr[i<<1]+=dx;
ptr[i<<1+1]+=dy; ptr[i<<1+1]+=dy;
} }
break; break;
case SPT_POLYPT: case SPT_POLYPT:
ptr=&tempg->y1; tempg->npu.x+=dx;
ptr[0]+=dx; tempg->npu.y+=dy;
ptr[1]+=dy;
break; break;
case SPT_BSPLINE2: case SPT_BSPLINE2:
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
p=&tempg->y1; p=&tempg->nu.u;
for (i=0;i<tempg->num;i++,p++) { for (i=0;i<tempg->nu.num;i++,p++) {
p->x+=dx; p->x+=dx;
p->y+=dy; p->y+=dy;
p->z+=dz; p->z+=dz;
} }
break; break;
case SPT_MESH: case SPT_MESH:
p=&tempg->x2; p=&tempg->mu.u;
for (i=0;i<tempg->vertex_cnt;i++,p++) { for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
p->x+=dx; p->x+=dx;
p->y+=dy; p->y+=dy;
p->z+=dz; p->z+=dz;
} }
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
tempg->x1+=dx; tempg->pmu.x+=dx;
tempg->y1+=dy; tempg->pmu.y+=dy;
tempg->z1+=dz; tempg->pmu.z+=dz;
break; break;
} }
tempg=tempg->next; tempg=tempg->next;
@@ -161,14 +146,14 @@ U0 SpriteSetOrigin(CSprite *root,I64 dx,I64 dy,I64 dz)
CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg) CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
{ {
I64 x,y,z; I64 x,y,z;
F64 m1,a1,m2,radius=tempg->x2<<16; F64 m1,a1,m2,radius=tempg->pr.radius<<16;
CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(SPT_ELLIPSE)); CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(SPT_ELLIPSE));
tempg1->type=SPT_ELLIPSE; tempg1->type=SPT_ELLIPSE;
x=tempg->x1; y=tempg->y1; z=0; x=tempg->pr.x1; y=tempg->pr.y1; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg1->x2=x; tempg1->pwha.x1=x;
tempg1->y2=y; tempg1->pwha.y1=y;
x=radius; y=0; z=0; x=radius; y=0; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
@@ -178,9 +163,9 @@ CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
m2=Sqrt(x*x+y*y); m2=Sqrt(x*x+y*y);
tempg1->width =ToI64(m1)/0x10000; tempg1->pwha.width =ToI64(m1)/0x10000;
tempg1->height=ToI64(m2)/0x10000; tempg1->pwha.height=ToI64(m2)/0x10000;
tempg1->rot_angle=-a1; tempg1->pwha.angle=-a1;
return tempg1; return tempg1;
} }
@@ -188,19 +173,20 @@ CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg) CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
{ {
I64 x,y,z; I64 x,y,z;
F64 m1,a1,m2,a2,s,c,x_radius=tempg->width<<16,y_radius=tempg->height<<16; F64 m1,a1,m2,a2,s,c,x_radius=tempg->pwha.width<<16,
y_radius=tempg->pwha.height<<16;
CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(tempg->type)); CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(tempg->type));
tempg1->type=tempg->type; tempg1->type=tempg->type;
if (tempg->type==SPT_POLYGON) if (tempg->type==SPT_POLYGON)
tempg1->sides=tempg->sides; tempg1->pwhas.sides=tempg->pwhas.sides;
x=tempg->x2; y=tempg->y2; z=0; x=tempg->pwha.x1; y=tempg->pwha.y1; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg1->x2=x; tempg1->pwha.x1=x;
tempg1->y2=y; tempg1->pwha.y1=y;
c=Cos(-tempg->rot_angle); c=Cos(-tempg->pwha.angle);
s=Sin(-tempg->rot_angle); s=Sin(-tempg->pwha.angle);
x=x_radius*c; x=x_radius*c;
y=x_radius*s; y=x_radius*s;
@@ -215,11 +201,11 @@ CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
R2P(&m2,&a2,x,y); R2P(&m2,&a2,x,y);
m2*=Abs(Sin(a2-a1)); m2*=Abs(Sin(a2-a1));
tempg1->width=ToI64(m1)/0x10000; tempg1->pwha.width=ToI64(m1)/0x10000;
if (tempg1->width<1) tempg1->width=1; if (tempg1->pwha.width<1) tempg1->pwha.width=1;
tempg1->height=ToI64(m2)/0x10000; tempg1->pwha.height=ToI64(m2)/0x10000;
if (tempg1->height<1) tempg1->height=1; if (tempg1->pwha.height<1) tempg1->pwha.height=1;
tempg1->rot_angle=-a1; tempg1->pwha.angle=-a1;
return tempg1; return tempg1;
} }
@@ -228,15 +214,15 @@ CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64
{ {
I64 x,y,z,w,h; I64 x,y,z,w,h;
F64 m1,a1,m2,a2,s,c, F64 m1,a1,m2,a2,s,c,
x_radius=(tempg->x2-tempg->x1)<<16, x_radius=(tempg->pp.x2-tempg->pp.x1)<<16,
y_radius=(tempg->y2-tempg->y1)<<16; y_radius=(tempg->pp.y2-tempg->pp.y1)<<16;
CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(SPT_ROTATED_RECT)); CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(SPT_ROTATED_RECT));
tempg1->type=SPT_ROTATED_RECT; tempg1->type=SPT_ROTATED_RECT;
x=tempg->x1; y=tempg->y1; z=0; x=tempg->pp.x1; y=tempg->pp.y1; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg1->x1=x; tempg1->ppa.x1=x;
tempg1->y1=y; tempg1->ppa.y1=y;
c=Cos(-é); c=Cos(-é);
s=Sin(-é); s=Sin(-é);
@@ -258,9 +244,9 @@ CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64
if (w<1) w=1; if (w<1) w=1;
h=ToI64(m2)/0x10000; h=ToI64(m2)/0x10000;
if (h<1) h=1; if (h<1) h=1;
tempg1->x2=tempg1->x1+w; tempg1->ppa.x2=tempg1->ppa.x1+w;
tempg1->y2=tempg1->y1+h; tempg1->ppa.y2=tempg1->ppa.y1+h;
tempg1->rot_angle=-a1; tempg1->ppa.angle=-a1;
return tempg1; return tempg1;
} }
@@ -278,7 +264,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
miny=maxy=y; miny=maxy=y;
minz=maxz=z; minz=maxz=z;
x=0; y=tempg->height; z=0; x=0; y=tempg->pwhu.height; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
if (x<minx) minx=x; if (x<minx) minx=x;
if (x>maxx) maxx=x; if (x>maxx) maxx=x;
@@ -287,7 +273,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
if (z<minx) minz=z; if (z<minx) minz=z;
if (z>maxx) maxz=z; if (z>maxx) maxz=z;
x=tempg->width; y=0; z=0; x=tempg->pwhu.width; y=0; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
if (x<minx) minx=x; if (x<minx) minx=x;
if (x>maxx) maxx=x; if (x>maxx) maxx=x;
@@ -296,7 +282,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
if (z<minx) minz=z; if (z<minx) minz=z;
if (z>maxx) maxz=z; if (z>maxx) maxz=z;
x=tempg->width; y=tempg->height; z=0; x=tempg->pwhu.width; y=tempg->pwhu.height; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
if (x<minx) minx=x; if (x<minx) minx=x;
if (x>maxx) maxx=x; if (x>maxx) maxx=x;
@@ -308,11 +294,10 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
tempb=DCNew(maxx-minx+1,maxy-miny+1); tempb=DCNew(maxx-minx+1,maxy-miny+1);
img=CAlloc(sizeof(CDC)); img=CAlloc(sizeof(CDC));
img->width=tempg->width; img->width=tempg->pwhu.width;
img->width_internal=(tempg->width+7)&~7; img->width_internal=(tempg->pwhu.width+7)&~7;
img->height=tempg->height; img->height=tempg->pwhu.height;
img->body_size=img->width_internal*img->height; img->body=&tempg->pwhu.u;
img->body=tempg(U8 *)+offset(CSprite.linespeed);
img->dc_signature=DCS_SIGNATURE_VAL; img->dc_signature=DCS_SIGNATURE_VAL;
tempb->color=TRANSPARENT; tempb->color=TRANSPARENT;
@@ -335,15 +320,15 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
MemCpy(tempg1(U8 *)+offset(CSprite.start),elems,MSize(elems)); MemCpy(tempg1(U8 *)+offset(CSprite.start),elems,MSize(elems));
tempg1->type=tempg->type; tempg1->type=tempg->type;
x=tempg->x2; y=tempg->y2; z=0; x=tempg->pwhu.x1; y=tempg->pwhu.y1; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg1->x2=x; tempg1->pwhu.x1=x;
tempg1->y2=y; tempg1->pwhu.y1=y;
x=0; y=0; z=0; x=0; y=0; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg1->x2+=minx-x; tempg1->pwhu.x1+=minx-x;
tempg1->y2+=miny-y; tempg1->pwhu.y1+=miny-y;
return tempg1; return tempg1;
} }
@@ -358,32 +343,26 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
while (tempg!=root) { while (tempg!=root) {
switch (tempg->type) { switch (tempg->type) {
case SPT_WIDTH: case SPT_WIDTH:
// (1.0/Sqrt(3))*65536=37837.22 tempg->w.width*=Sqrt(GrRotNormSqr65536(r))/65536;
x=37838;y=37838;z=37838; if (tempg->w.width<0) tempg->w.width=0;
GrRot(r,&x,&y,&z);
//scaled 32 bits
tempg->width*=Sqrt(x*x+y*y+z*z)/65536;
if (tempg->width<0) tempg->width=0;
break;
case SPT_PT:
case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT:
x=tempg->x1; y=tempg->y1; z=0;
GrRot(r,&x,&y,&z);
tempg->x1=x;
tempg->y1=y;
break; break;
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
case SPT_ARROW: case SPT_ARROW:
case SPT_LINE: case SPT_LINE:
x=tempg->x1; y=tempg->y1; z=0; x=tempg->pp.x2; y=tempg->pp.y2; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg->x1=x; tempg->pp.x2=x;
tempg->y1=y; tempg->pp.y2=y;
x=tempg->x2; y=tempg->y2; z=0; case SPT_PT:
case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT:
case SPT_TEXT:
case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND:
x=tempg->p.x1; y=tempg->p.y1; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg->x2=x; tempg->p.x1=x;
tempg->y2=y; tempg->p.y1=y;
break; break;
case SPT_BITMAP: case SPT_BITMAP:
tempg1=SpriteTransformBitmap(r,tempg); tempg1=SpriteTransformBitmap(r,tempg);
@@ -393,7 +372,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
tempg=tempg1; tempg=tempg1;
break; break;
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
tempg1=SpriteTransformRect(r,tempg,tempg->rot_angle); tempg1=SpriteTransformRect(r,tempg,tempg->ppa.angle);
QueIns(tempg1,tempg); QueIns(tempg1,tempg);
QueRem(tempg); QueRem(tempg);
Free(tempg); Free(tempg);
@@ -406,14 +385,6 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
Free(tempg); Free(tempg);
tempg=tempg1; tempg=tempg1;
break; break;
case SPT_TEXT:
case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND:
x=tempg->x1; y=tempg->y1; z=0;
GrRot(r,&x,&y,&z);
tempg->x1=x;
tempg->y1=y;
break;
case SPT_CIRCLE: case SPT_CIRCLE:
tempg1=SpriteTransformCircle(r,tempg); tempg1=SpriteTransformCircle(r,tempg);
QueIns(tempg1,tempg); QueIns(tempg1,tempg);
@@ -430,8 +401,8 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
tempg=tempg1; tempg=tempg1;
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr=&tempg->y1; ptr=&tempg->nu.u;
for (i=0;i<tempg->num;i++) { for (i=0;i<tempg->nu.num;i++) {
x=ptr[i<<1]; y=ptr[i<<1+1]; z=0; x=ptr[i<<1]; y=ptr[i<<1+1]; z=0;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
ptr[i<<1]=x; ptr[i<<1]=x;
@@ -440,12 +411,11 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
break; break;
case SPT_POLYPT: case SPT_POLYPT:
QueInit(&root2); QueInit(&root2);
ptr=&tempg->y1; x=tempg->npu.x; y=tempg->npu.y; z=0;
x=ptr[0]; y=ptr[1]; z=0;
x1=x; y1=y; z1=z; //unrotated cur coordinates x1=x; y1=y; z1=z; //unrotated cur coordinates
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
ptr+=2; ptr=&tempg->npu.u;
k=tempg->num*3; k=tempg->npu.num*3;
x2=x; y2=y; z2=z; //rotated start coordinates x2=x; y2=y; z2=z; //rotated start coordinates
x3=x; y3=y; z3=z; //lag 1 rotated coordinates x3=x; y3=y; z3=z; //lag 1 rotated coordinates
for (i=0;i<k;i+=3) { for (i=0;i<k;i+=3) {
@@ -463,38 +433,37 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
x3=0; y3=0; z3=0; x3=0; y3=0; z3=0;
while (tempg1!=&root2) { while (tempg1!=&root2) {
tempg2=tempg1->next; tempg2=tempg1->next;
if (tempg1->x1==x3 && tempg1->y1==y3) { if (tempg1->p.x1==x3 && tempg1->p.y1==y3) {
QueRem(tempg1); QueRem(tempg1);
Free(tempg1); Free(tempg1);
} else { } else {
num++; num++;
x3=tempg1->x1; x3=tempg1->p.x1;
y3=tempg1->y1; y3=tempg1->p.y1;
} }
tempg1=tempg2; tempg1=tempg2;
} }
tempg3=CAlloc(SpriteElemQuedBaseSize(SPT_POLYPT)+(num*3+7)>>3); tempg3=CAlloc(SpriteElemQuedBaseSize(SPT_POLYPT)+(num*3+7)>>3);
ptr=&tempg3->y1; tempg3->npu.x=x2;
ptr[0]=x2; tempg3->npu.y=y2;
ptr[1]=y2; ptr=&tempg3->npu.u;
ptr+=2;
x3=0;y3=0; z3=0; x3=0;y3=0; z3=0;
i=0; i=0;
tempg1=root2.next; tempg1=root2.next;
while (tempg1!=&root2) { while (tempg1!=&root2) {
tempg2=tempg1->next; tempg2=tempg1->next;
BFieldOrU32(ptr,i, BFieldOrU32(ptr,i,
polypt_map[SignI64(tempg1->x1-x3)+1+ polypt_map[SignI64(tempg1->p.x1-x3)+1+
3*(SignI64(tempg1->y1-y3)+1)]); 3*(SignI64(tempg1->p.y1-y3)+1)]);
i+=3; i+=3;
x3=tempg1->x1;y3=tempg1->y1; x3=tempg1->p.x1;y3=tempg1->p.y1;
QueRem(tempg1); QueRem(tempg1);
Free(tempg1); Free(tempg1);
tempg1=tempg2; tempg1=tempg2;
} }
tempg3->type=SPT_POLYPT; tempg3->type=SPT_POLYPT;
tempg3->num=num; tempg3->npu.num=num;
QueIns(tempg3,tempg); QueIns(tempg3,tempg);
QueRem(tempg); QueRem(tempg);
Free(tempg); Free(tempg);
@@ -504,8 +473,8 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
p=&tempg->y1; p=&tempg->nu.u;
for (i=0;i<tempg->num;i++,p++) { for (i=0;i<tempg->nu.num;i++,p++) {
x=p->x; y=p->y; z=p->z; x=p->x; y=p->y; z=p->z;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
p->x=x; p->x=x;
@@ -514,13 +483,13 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
} }
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
x=tempg->x1; y=tempg->y1; z=tempg->z1; x=tempg->pmu.x; y=tempg->pmu.y; z=tempg->pmu.z;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
tempg->x1=x; tempg->pmu.x=x;
tempg->y1=y; tempg->pmu.y=y;
tempg->z1=z; tempg->pmu.z=z;
p=(&tempg->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg->pmu.u;
for (i=0;i<tempg->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
x=p->x; y=p->y; z=p->z; x=p->x; y=p->y; z=p->z;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
p->x=x; p->x=x;
@@ -529,8 +498,8 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
} }
break; break;
case SPT_MESH: case SPT_MESH:
p=&tempg->x2; p=&tempg->mu.u;
for (i=0;i<tempg->vertex_cnt;i++,p++) { for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
x=p->x; y=p->y; z=p->z; x=p->x; y=p->y; z=p->z;
GrRot(r,&x,&y,&z); GrRot(r,&x,&y,&z);
p->x=x; p->x=x;
@@ -614,9 +583,9 @@ U0 SpriteSideBarTask2(CTask *grand_parent)
pu_task=grand_parent->popup_task; pu_task=grand_parent->popup_task;
if (TaskValidate(pu_task)) { if (TaskValidate(pu_task)) {
w=parent->win_right-parent->win_left; w=parent->win_right-parent->win_left;
SetWinHorz(pu_task->win_right+2,pu_task->win_right+2+w,parent); WinHorz(pu_task->win_right+2,pu_task->win_right+2+w,parent);
h=parent->win_bottom-parent->win_top; h=parent->win_bottom-parent->win_top;
SetWinVert(pu_task->win_top,pu_task->win_top+h,parent); WinVert(pu_task->win_top,pu_task->win_top+h,parent);
} }
WinMgrSync; WinMgrSync;
} }
@@ -651,7 +620,7 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
Sprite2Code(doc,elems); Sprite2Code(doc,elems);
Free(elems); Free(elems);
while (TRUE) { while (TRUE) {
if (result=SrvUser("DocDo(0x%X,0x%X);",doc,0)) { if (result=PopUpPrint("DocDo(0x%X,0x%X);",doc,0)) {
Fs->put_doc=doc2=DocNew; Fs->put_doc=doc2=DocNew;
"$$WW,1$$"; "$$WW,1$$";
if (elems=Code2Sprite(doc)) { if (elems=Code2Sprite(doc)) {
@@ -664,7 +633,7 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
*_cur_elem_num=QueCnt(root); //TODO: Might want to improve this. *_cur_elem_num=QueCnt(root); //TODO: Might want to improve this.
break; break;
} else { } else {
SrvUser("DocDo(0x%X,0x%X);",doc2,0); PopUpPrint("DocDo(0x%X,0x%X);",doc2,0);
DocDel(doc2); DocDel(doc2);
Fs->put_doc=old_put; Fs->put_doc=old_put;
} }
@@ -735,19 +704,19 @@ I64 PopUpSpriteEd(CSprite **_root,I64 *_cur_elem_num)
#define GSPF_SELECTED 1 #define GSPF_SELECTED 1
class CSpritePt class CEdSprite
{ {
CSpritePt *next,*last; CEdSprite *next,*last;
I32 type,num,flags,xx,yy,zz; I32 type,num,flags,xx,yy,zz;
I32 *x,*y,*z,*w,*h; I32 *x,*y,*z,*w,*h;
}; };
U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root) U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CEdSprite *root)
{ {
I64 i,num=0; I64 i,num=0;
I32 *ptr; I32 *ptr;
CD3I32 *p; CD3I32 *p;
CSpritePt *temppe; CEdSprite *temppe;
CSprite *tempg=elems-offset(CSprite.start); CSprite *tempg=elems-offset(CSprite.start);
QueInit(root); QueInit(root);
while (tempg->type) { while (tempg->type) {
@@ -757,60 +726,52 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root)
case SPT_LINE: case SPT_LINE:
case SPT_ARROW: case SPT_ARROW:
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
temppe->x=&tempg->x2; temppe->x=&tempg->pp.x2;
temppe->y=&tempg->y2; temppe->y=&tempg->pp.y2;
temppe->num=num; temppe->num=num;
QueIns(temppe,root->last); QueIns(temppe,root->last);
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
case SPT_PT: case SPT_PT:
case SPT_BITMAP:
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
case SPT_CIRCLE: case SPT_CIRCLE:
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
temppe->x=&tempg->x1; temppe->x=&tempg->p.x1;
temppe->y=&tempg->y1; temppe->y=&tempg->p.y1;
temppe->num=num; temppe->num=num;
QueIns(temppe,root->last); QueIns(temppe,root->last);
break; break;
case SPT_SHIFT: case SPT_SHIFT:
x+=tempg->x1; x+=tempg->p.x1;
y+=tempg->y1; y+=tempg->p.y1;
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
case SPT_POLYGON: case SPT_POLYGON:
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_WIDTH_HEIGHT; temppe->type=GSPT_WIDTH_HEIGHT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
temppe->x=&tempg->x2; temppe->x=&tempg->pwha.x1;
temppe->y=&tempg->y2; temppe->y=&tempg->pwha.y1;
temppe->w=&tempg->width; temppe->w=&tempg->pwha.width;
temppe->h=&tempg->height; temppe->h=&tempg->pwha.height;
temppe->num=num;
QueIns(temppe,root->last);
case SPT_BITMAP:
temppe=CAlloc(sizeof(CSpritePt));
temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x;
temppe->yy=y;
temppe->x=&tempg->x2;
temppe->y=&tempg->y2;
temppe->num=num; temppe->num=num;
QueIns(temppe,root->last); QueIns(temppe,root->last);
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
ptr=&tempg->y1; ptr=&tempg->nu.u;
for (i=0;i<tempg->num;i++) { for (i=0;i<tempg->nu.num;i++) {
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
@@ -821,13 +782,12 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root)
} }
break; break;
case SPT_POLYPT: case SPT_POLYPT:
ptr=&tempg->y1; temppe=CAlloc(sizeof(CEdSprite));
temppe=CAlloc(sizeof(CSpritePt));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
temppe->x=&ptr[0]; temppe->x=&tempg->npu.x;
temppe->y=&ptr[1]; temppe->y=&tempg->npu.y;
temppe->num=num; temppe->num=num;
QueIns(temppe,root->last); QueIns(temppe,root->last);
break; break;
@@ -835,9 +795,9 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root)
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
p=&tempg->y1; p=&tempg->nu.u;
for (i=0;i<tempg->num;i++) { for (i=0;i<tempg->nu.num;i++) {
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
@@ -851,13 +811,13 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root)
case SPT_MESH: case SPT_MESH:
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
temppe=CAlloc(sizeof(CSpritePt)); temppe=CAlloc(sizeof(CEdSprite));
temppe->type=GSPT_SIMPLE_PT; temppe->type=GSPT_SIMPLE_PT;
temppe->xx=x; temppe->xx=x;
temppe->yy=y; temppe->yy=y;
temppe->x=&tempg->x1; temppe->x=&tempg->pmu.x;
temppe->y=&tempg->y1; temppe->y=&tempg->pmu.y;
temppe->z=&tempg->z1; temppe->z=&tempg->pmu.z;
temppe->num=num; temppe->num=num;
QueIns(temppe,root->last); QueIns(temppe,root->last);
break; break;
@@ -867,10 +827,10 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CSpritePt *root)
} }
} }
U0 SpriteCtrlPtsDraw(CDC *dc,CSpritePt *root) U0 SpriteCtrlPtsDraw(CDC *dc,CEdSprite *root)
{ {
I64 x,y; I64 x,y;
CSpritePt *temppe; CEdSprite *temppe;
WinMgrSync; WinMgrSync;
DCFill(dc); DCFill(dc);
if (Blink(20)) { if (Blink(20)) {
@@ -898,9 +858,9 @@ U0 SpriteCtrlPtsDraw(CDC *dc,CSpritePt *root)
} }
} }
U0 SpriteCtrlPtsMove(CSpritePt *root,I64 dx,I64 dy) U0 SpriteCtrlPtsMove(CEdSprite *root,I64 dx,I64 dy)
{ {
CSpritePt *temppe; CEdSprite *temppe;
temppe=root->next; temppe=root->next;
while (temppe!=root) { while (temppe!=root) {
if (temppe->flags&GSPF_SELECTED) if (temppe->flags&GSPF_SELECTED)
@@ -923,7 +883,7 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
I64 msg_code,a1,a2,xx,yy,xx2,yy2,dd,best_dd,cur_elem_num; I64 msg_code,a1,a2,xx,yy,xx2,yy2,dd,best_dd,cur_elem_num;
Bool old_preempt,result=TRUE; Bool old_preempt,result=TRUE;
CDC *dc=DCAlias; CDC *dc=DCAlias;
CSpritePt root,*temppe,*best_pe; CEdSprite root,*temppe,*best_pe;
SpritePtQueNew(elems,x,y,&root); SpritePtQueNew(elems,x,y,&root);
cur_elem_num=0; cur_elem_num=0;
@@ -1140,16 +1100,16 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
insert_pt=SpriteElemNum2QueEntry(*_root,*_cur_elem_num); insert_pt=SpriteElemNum2QueEntry(*_root,*_cur_elem_num);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFT)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFT));
tempg->type=SPT_SHIFT; tempg->type=SPT_SHIFT;
tempg->x1=0; tempg->p.x1=0;
tempg->y1=0; tempg->p.y1=0;
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN); GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN);
xx=a1; yy=a2; xx=a1; yy=a2;
do { do {
msg_code=GetMsg(&a1,&a2, msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE); 1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
tempg->x1=a1-xx; tempg->p.x1=a1-xx;
tempg->y1=a2-yy; tempg->p.y1=a2-yy;
SpriteEdUpdate(doc,tempb,*_root); SpriteEdUpdate(doc,tempb,*_root);
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
*_cur_elem_num+=1; *_cur_elem_num+=1;
+196 -165
View File
@@ -46,8 +46,8 @@ I64 PopUpSpriteMain(CSprite **_root,I64 *_cur_elem_num)
"\n" "\n"
"$$PURPLE$$$$MU-UL,\"+] Sprite Edit Menu\",LE=SPT_ED_MENU$$$$LTBLUE$$\n" "$$PURPLE$$$$MU-UL,\"+] Sprite Edit Menu\",LE=SPT_ED_MENU$$$$LTBLUE$$\n"
"$$MU-UL,\"Exit Sprite\",LE=SPT_EXIT$$\n" "$$MU-UL,\"Exit Sprite\",LE=SPT_EXIT$$\n"
"$$MU-UL,\"Abort Sprite\",LE=DOCM_CANCEL$$\n"); "$$MU-UL,\"Abort Sprite\",LE=DOCM_CANCEL$$\n"
DocPrint(doc,"\nRight-Click to get back to this menu."); "\nRight-Click to get back to this menu.");
st=MStrPrint("SpriteSideBarTask(0x%X,0x%X,0x%X);",Fs,_root,_cur_elem_num); st=MStrPrint("SpriteSideBarTask(0x%X,0x%X,0x%X);",Fs,_root,_cur_elem_num);
PopUp(st,NULL,&pu_task); PopUp(st,NULL,&pu_task);
Free(st); Free(st);
@@ -97,18 +97,18 @@ U0 SpriteSetSettings(CDC *dc,CSprite *root,I64 cur_elem_num,CColorROPU32 *_color
while (cur_elem_num>0 && tempg!=root) { while (cur_elem_num>0 && tempg!=root) {
switch (tempg->type) { switch (tempg->type) {
case SPT_COLOR: case SPT_COLOR:
dc->color=*_color=tempg->color; dc->color=*_color=tempg->c.color;
break; break;
case SPT_DITHER_COLOR: case SPT_DITHER_COLOR:
dc->color=*_color= dc->color=*_color=
tempg->dither_color.u8[0]| tempg->d.dither_color.u8[0]|
tempg->dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER; tempg->d.dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER;
break; break;
case SPT_WIDTH: case SPT_WIDTH:
dc->pen_width=*_width=tempg->width; dc->pen_width=*_width=tempg->w.width;
break; break;
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
if (GrSetSymmetry3(dc,tempg->x1+x,tempg->y1+y,0,tempg->x2+x,tempg->y2+y,0,tempg->x2+x,tempg->y2+y,1)) if (GrSetSymmetry3(dc,tempg->pp.x1+x,tempg->pp.y1+y,0,tempg->pp.x2+x,tempg->pp.y2+y,0,tempg->pp.x2+x,tempg->pp.y2+y,1))
dc->flags|=DCF_SYMMETRY; dc->flags|=DCF_SYMMETRY;
else else
dc->flags&=~DCF_SYMMETRY; dc->flags&=~DCF_SYMMETRY;
@@ -166,7 +166,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
U8 *st,*old_task_title=StrNew(Fs->task_title); U8 *st,*old_task_title=StrNew(Fs->task_title);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WordStat; AutoComplete;
WinMgrSync(2,TRUE); WinMgrSync(2,TRUE);
dc2->flags|=DCF_ON_TOP; dc2->flags|=DCF_ON_TOP;
root=Sprite2SpriteQue(tempb->data); root=Sprite2SpriteQue(tempb->data);
@@ -229,7 +229,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
color=i; color=i;
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_COLOR)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_COLOR));
tempg->type=SPT_COLOR; tempg->type=SPT_COLOR;
tempg->color=color; tempg->c.color=color;
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -244,7 +244,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
color=i; color=i;
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_DITHER_COLOR)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_DITHER_COLOR));
tempg->type=SPT_DITHER_COLOR; tempg->type=SPT_DITHER_COLOR;
tempg->dither_color=color.c0.color|color.c1.color<<8; tempg->d.dither_color=color.c0.color|color.c1.color<<8;
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -270,24 +270,24 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
tempg1=insert_pt; tempg1=insert_pt;
if (tempg1!=root && tempg1->type==SPT_MESH) if (tempg1!=root && tempg1->type==SPT_MESH)
old_mesh=&tempg1->vertex_cnt; old_mesh=&tempg1->mu.vertex_cnt;
else if (tempg1!=root && tempg1->type==SPT_SHIFTABLE_MESH) { else if (tempg1!=root && tempg1->type==SPT_SHIFTABLE_MESH) {
x1=tempg1->x1; x1=tempg1->pmu.x;
y1=tempg1->y1; y1=tempg1->pmu.y;
z1=tempg1->z1; z1=tempg1->pmu.z;
p=(&tempg1->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg1->pmu.u;
for (i=0;i<tempg1->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg1->pmu.vertex_cnt;i++,p++) {
p->x+=x1; p->x+=x1;
p->y+=y1; p->y+=y1;
p->z+=z1; p->z+=z1;
} }
old_mesh=&tempg1->shiftable_vertex_cnt; old_mesh=&tempg1->pmu.vertex_cnt;
} else } else
old_mesh=NULL; old_mesh=NULL;
if (mesh=SpriteMeshEd(old_mesh,&size,TRUE)) { if (mesh=SpriteMeshEd(old_mesh,&size,TRUE)) {
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_MESH)-sizeof(I32)*2+size); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_MESH)-sizeof(I32)*2+size);
tempg->type=SPT_MESH; tempg->type=SPT_MESH;
MemCpy(&tempg->vertex_cnt,mesh,size); MemCpy(&tempg->mu.vertex_cnt,mesh,size);
Free(mesh); Free(mesh);
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
@@ -299,11 +299,11 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
} else } else
cur_elem_num++; cur_elem_num++;
} else if (old_mesh && tempg1->type==SPT_SHIFTABLE_MESH) { } else if (old_mesh && tempg1->type==SPT_SHIFTABLE_MESH) {
x1=tempg1->x1; x1=tempg1->pmu.x;
y1=tempg1->y1; y1=tempg1->pmu.y;
z1=tempg1->z1; z1=tempg1->pmu.z;
p=(&tempg1->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg1->pmu.u;
for (i=0;i<tempg1->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg1->pmu.vertex_cnt;i++,p++) {
p->x-=x1; p->x-=x1;
p->y-=y1; p->y-=y1;
p->z-=z1; p->z-=z1;
@@ -372,7 +372,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
width=i; width=i;
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_WIDTH)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_WIDTH));
tempg->type=SPT_WIDTH; tempg->type=SPT_WIDTH;
tempg->width=width; tempg->w.width=width;
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -415,9 +415,9 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT)+StrLen(st)+1); tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT)+StrLen(st)+1);
tempg->type=SPT_TEXT; tempg->type=SPT_TEXT;
tempg->x1=x1-x; tempg->ps.x1=x1-x;
tempg->y1=y1-y; tempg->ps.y1=y1-y;
StrCpy(tempg->st,st); StrCpy(tempg->ps.st,st);
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -441,9 +441,9 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT_BOX)+StrLen(st)+1); tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT_BOX)+StrLen(st)+1);
tempg->type=SPT_TEXT_BOX; tempg->type=SPT_TEXT_BOX;
tempg->x1=x1-x; tempg->ps.x1=x1-x;
tempg->y1=y1-y; tempg->ps.y1=y1-y;
StrCpy(tempg->st,st); StrCpy(tempg->ps.st,st);
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -467,9 +467,9 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT_DIAMOND)+StrLen(st)+1); tempg=CAlloc(SpriteElemQuedBaseSize(SPT_TEXT_DIAMOND)+StrLen(st)+1);
tempg->type=SPT_TEXT_DIAMOND; tempg->type=SPT_TEXT_DIAMOND;
tempg->x1=x1-x; tempg->ps.x1=x1-x;
tempg->y1=y1-y; tempg->ps.y1=y1-y;
StrCpy(tempg->st,st); StrCpy(tempg->ps.st,st);
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
cur_elem_num++; cur_elem_num++;
@@ -502,13 +502,33 @@ ei_restart:
eletype=SPT_MENU; eletype=SPT_MENU;
} }
if (msg_code==MSG_KEY_DOWN) { if (msg_code==MSG_KEY_DOWN) {
if (a1==CH_ESC) { switch (a1) {
case CH_ESC:
result=GE_EXIT; result=GE_EXIT;
goto ei_done; goto ei_done;
} else if (a1==CH_SHIFT_ESC) { case CH_SHIFT_ESC:
result=GE_ABORT; result=GE_ABORT;
goto ei_done; goto ei_done;
} else case 'c': //eye-dropper
dc3=DCCaptureScreen(FALSE);
color=GrPeek(dc3,ip.pos.x,ip.pos.y)^15;//Mouse cursor is XORed.
DCDel(dc3);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_COLOR));
tempg->type=SPT_COLOR;
tempg->c.color=color;
QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root);
cur_elem_num++;
break;
case 't': //Set to transparent color
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_COLOR));
tempg->type=SPT_COLOR;
tempg->c.color=TRANSPARENT;
QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root);
cur_elem_num++;
break;
}
goto ei_restart; goto ei_restart;
} else { } else {
x1=a1; y1=a2; x1=a1; y1=a2;
@@ -564,10 +584,10 @@ ei_restart:
tempg->type=SPT_PLANAR_SYMMETRY; tempg->type=SPT_PLANAR_SYMMETRY;
break; break;
sub_switch_end: sub_switch_end:
tempg->x1=x1-x; tempg->pp.x1=x1-x;
tempg->y1=y1-y; tempg->pp.y1=y1-y;
tempg->x2=x2-x; tempg->pp.x2=x2-x;
tempg->y2=y2-y; tempg->pp.y2=y2-y;
break; break;
case SPT_RECT: case SPT_RECT:
xx1=a1; yy1=a2; xx1=a1; yy1=a2;
@@ -594,10 +614,10 @@ ei_restart:
GrRect3(dc,xx1,yy1,0,xx2-xx1,yy2-yy1); GrRect3(dc,xx1,yy1,0,xx2-xx1,yy2-yy1);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_RECT)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_RECT));
tempg->type=SPT_RECT; tempg->type=SPT_RECT;
tempg->x1=xx1-x; tempg->pp.x1=xx1-x;
tempg->y1=yy1-y; tempg->pp.y1=yy1-y;
tempg->x2=xx2-x; tempg->pp.x2=xx2-x;
tempg->y2=yy2-y; tempg->pp.y2=yy2-y;
break; break;
case SPT_INS_SCREEN_BITMAP: case SPT_INS_SCREEN_BITMAP:
case SPT_INS_TRANSPARENT_SCREEN_BITMAP: case SPT_INS_TRANSPARENT_SCREEN_BITMAP:
@@ -628,10 +648,10 @@ ei_restart:
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+ tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+
((xx2-xx1+7)&~7)*(yy2-yy1)); ((xx2-xx1+7)&~7)*(yy2-yy1));
tempg->type=SPT_BITMAP; tempg->type=SPT_BITMAP;
tempg->width=xx2-xx1; tempg->pwhu.width=xx2-xx1;
tempg->height=yy2-yy1; tempg->pwhu.height=yy2-yy1;
tempg->x2=0; tempg->pwhu.x1=0;
tempg->y2=0; tempg->pwhu.y1=0;
SpriteScreenInit(dc,x,y); SpriteScreenInit(dc,x,y);
i=gr.screen_zoom; i=gr.screen_zoom;
GrScaleZoom(1.0/i); GrScaleZoom(1.0/i);
@@ -644,7 +664,7 @@ ei_restart:
if (eletype==SPT_INS_TRANSPARENT_SCREEN_BITMAP) if (eletype==SPT_INS_TRANSPARENT_SCREEN_BITMAP)
DCColorChg(img,bm_bkcolor); DCColorChg(img,bm_bkcolor);
GrScaleZoom(i); GrScaleZoom(i);
MemCpy(tempg(U8 *)+offset(CSprite.linespeed),img->body,((xx2-xx1+7)&~7)*(yy2-yy1)); MemCpy(&tempg->pwhu.u,img->body,((xx2-xx1+7)&~7)*(yy2-yy1));
DCDel(img); DCDel(img);
DCDel(dc3); DCDel(dc3);
dc2->pen_width=old_width; dc2->pen_width=old_width;
@@ -664,9 +684,9 @@ ei_restart:
GrCircle3(dc,x1,y1,0,Sqrt(SqrI64(x1-x2)+SqrI64(y1-y2))); GrCircle3(dc,x1,y1,0,Sqrt(SqrI64(x1-x2)+SqrI64(y1-y2)));
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_CIRCLE)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_CIRCLE));
tempg->type=SPT_CIRCLE; tempg->type=SPT_CIRCLE;
tempg->x1=x1-x; tempg->pr.x1=x1-x;
tempg->y1=y1-y; tempg->pr.y1=y1-y;
tempg->x2=Sqrt(SqrI64(x1-x2)+SqrI64(y1-y2)); tempg->pr.radius=Sqrt(SqrI64(x1-x2)+SqrI64(y1-y2));
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
do { do {
@@ -680,37 +700,37 @@ ei_restart:
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_ELLIPSE)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_ELLIPSE));
tempg->type=SPT_ELLIPSE; tempg->type=SPT_ELLIPSE;
tempg->x2=(x1+x2)>>1-x; tempg->pwha.x1=(x1+x2)>>1-x;
tempg->y2=(y1+y2)>>1-y; tempg->pwha.y1=(y1+y2)>>1-y;
tempg->width =AbsI64(x1-x2)>>1; tempg->pwha.width =AbsI64(x1-x2)>>1;
tempg->height=AbsI64(y1-y2)>>1; tempg->pwha.height=AbsI64(y1-y2)>>1;
angle2=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle2=Arg(x2-(tempg->pwha.x1+x),y2-(tempg->pwha.y1+y));
if (tempg->width<tempg->height) if (tempg->pwha.width<tempg->pwha.height)
angle2-=ă/2.0; angle2-=ă/2.0;
do { do {
angle1=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle1=Arg(x2-(tempg->pwha.x1+x),y2-(tempg->pwha.y1+y));
if (tempg->width>=tempg->height) if (tempg->pwha.width>=tempg->pwha.height)
tempg->rot_angle=-(angle1-angle2); tempg->pwha.angle=-(angle1-angle2);
else else
tempg->rot_angle=-(angle1-angle2)+ã/2.0; tempg->pwha.angle=-(angle1-angle2)+ã/2.0;
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
GrEllipse3(dc,tempg->x2+x,tempg->y2+y,0, GrEllipse3(dc,tempg->pwha.x1+x,tempg->pwha.y1+y,0,
tempg->width,tempg->height,tempg->rot_angle); tempg->pwha.width,tempg->pwha.height,tempg->pwha.angle);
msg_code=GetMsg(&a1,&a2, msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE); 1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
SpriteScreenInit(dc,x,y); SpriteScreenInit(dc,x,y);
x2=a1; y2=a2; x2=a1; y2=a2;
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
angle1=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle1=Arg(x2-(tempg->pwha.x1+x),y2-(tempg->pwha.y1+y));
if (tempg->width>=tempg->height) if (tempg->pwha.width>=tempg->pwha.height)
tempg->rot_angle=-(angle1-angle2); tempg->pwha.angle=-(angle1-angle2);
else else
tempg->rot_angle=-(angle1-angle2)+ã/2.0; tempg->pwha.angle=-(angle1-angle2)+ã/2.0;
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
GrEllipse3(dc,tempg->x2+x,tempg->y2+y,0, GrEllipse3(dc,tempg->pwha.x1+x,tempg->pwha.y1+y,0,
tempg->width,tempg->height,tempg->rot_angle); tempg->pwha.width,tempg->pwha.height,tempg->pwha.angle);
break; break;
case SPT_POLYGON: case SPT_POLYGON:
eletype=SPT_MENU; eletype=SPT_MENU;
@@ -729,115 +749,128 @@ ei_restart:
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_POLYGON)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_POLYGON));
tempg->type=SPT_POLYGON; tempg->type=SPT_POLYGON;
tempg->x2=(x1+x2)>>1-x; tempg->pwhas.x1=(x1+x2)>>1-x;
tempg->y2=(y1+y2)>>1-y; tempg->pwhas.y1=(y1+y2)>>1-y;
tempg->width =AbsI64(x1-x2)>>1; tempg->pwhas.width =AbsI64(x1-x2)>>1;
tempg->height=AbsI64(y1-y2)>>1; tempg->pwhas.height=AbsI64(y1-y2)>>1;
tempg->sides=i; tempg->pwhas.sides=i;
angle2=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle2=Arg(x2-(tempg->pwhas.x1+x),y2-(tempg->pwhas.y1+y));
if (tempg->width<tempg->height) if (tempg->pwhas.width<tempg->pwhas.height)
angle2-=ă/2.0; angle2-=ă/2.0;
do { do {
angle1=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle1=Arg(x2-(tempg->pwhas.x1+x),y2-(tempg->pwhas.y1+y));
if (tempg->width>=tempg->height) if (tempg->pwhas.width>=tempg->pwhas.height)
tempg->rot_angle=-(angle1-angle2); tempg->pwhas.angle=-(angle1-angle2);
else else
tempg->rot_angle=-(angle1-angle2)+ã/2.0; tempg->pwhas.angle=-(angle1-angle2)+ã/2.0;
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
GrRegPoly3(dc,tempg->x2+x,tempg->y2+y,0, GrRegPoly3(dc,tempg->pwhas.x1+x,tempg->pwhas.y1+y,0,
tempg->width,tempg->height,tempg->sides,tempg->rot_angle); tempg->pwhas.width,tempg->pwhas.height,
tempg->pwhas.sides,tempg->pwhas.angle);
msg_code=GetMsg(&a1,&a2, msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE); 1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
SpriteScreenInit(dc,x,y); SpriteScreenInit(dc,x,y);
x2=a1; y2=a2; x2=a1; y2=a2;
} while (msg_code!=MSG_IP_L_UP); } while (msg_code!=MSG_IP_L_UP);
angle1=Arg(x2-(tempg->x2+x),y2-(tempg->y2+y)); angle1=Arg(x2-(tempg->pwhas.x1+x),y2-(tempg->pwhas.y1+y));
if (tempg->width>=tempg->height) if (tempg->pwhas.width>=tempg->pwhas.height)
tempg->rot_angle=-(angle1-angle2); tempg->pwhas.angle=-(angle1-angle2);
else else
tempg->rot_angle=-(angle1-angle2)+ã/2.0; tempg->pwhas.angle=-(angle1-angle2)+ã/2.0;
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
GrRegPoly3(dc,tempg->x2+x,tempg->y2+y,0, GrRegPoly3(dc,tempg->pwhas.x1+x,tempg->pwhas.y1+y,0,
tempg->width,tempg->height,tempg->sides,tempg->rot_angle); tempg->pwhas.width,tempg->pwhas.height,tempg->pwhas.sides,
tempg->pwhas.angle);
break; break;
case SPT_PT: case SPT_PT:
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
tempg=MAlloc(SpriteElemQuedBaseSize(eletype)); tempg=MAlloc(SpriteElemQuedBaseSize(eletype));
tempg->type=eletype; tempg->type=eletype;
tempg->x1=x1-x; tempg->p.x1=x1-x;
tempg->y1=y1-y; tempg->p.y1=y1-y;
break; break;
sub_switch_start: sub_switch_start:
QueInit(&root2); QueInit(&root2);
num=0; num=0;
x3=a1-x; y3=a2-y;
do { do {
do { do {
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
if (num)
GrLine3(dc,x1,y1,0,x2,y2,0); GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&a1,&a2, msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE+ 1<<MSG_IP_L_UP+1<<MSG_IP_MOVE+
1<<MSG_IP_R_UP); 1<<MSG_IP_R_UP);
dc->color=TRANSPARENT; dc->color=TRANSPARENT;
if (num)
GrLine3(dc,x1,y1,0,x2,y2,0); GrLine3(dc,x1,y1,0,x2,y2,0);
x2=a1; y2=a2; x2=a1; y2=a2;
} while (msg_code!=MSG_IP_L_UP && msg_code!=MSG_IP_R_UP); } while (msg_code!=MSG_IP_L_UP && msg_code!=MSG_IP_R_UP);
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
if (msg_code==MSG_IP_L_UP) { if (msg_code==MSG_IP_L_UP) {
if (num)
GrLine3(dc,x1,y1,0,x2,y2,0); GrLine3(dc,x1,y1,0,x2,y2,0);
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_PT)); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_PT));
tempg->type=SPT_PT; tempg->type=SPT_PT;
tempg->x1=x2-x; tempg->p.x1=x2-x;
tempg->y1=y2-y; tempg->p.y1=y2-y;
QueIns(tempg,root2.last); QueIns(tempg,root2.last);
x1=x2;y1=y2; x1=x2;y1=y2;
num++; num++;
} }
} while (msg_code!=MSG_IP_R_UP); } while (msg_code!=MSG_IP_R_UP);
if (!num) {
tempg=NULL;
break;
}
case SPT_POLYLINE: case SPT_POLYLINE:
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYLINE)+ if (num>1) {
(num+1)<<1*sizeof(I32)); tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYLINE)+num*sizeof(CD2I32));
ptr=&tempg->y1; ptr=&tempg->nu.u;
tempg2=root2.next; tempg2=root2.next;
ptr[0]=x3;
ptr[1]=y3;
ptr+=2;
for (i=0;i<num;i++) { for (i=0;i<num;i++) {
tempg1=tempg2->next; tempg1=tempg2->next;
ptr[i<<1]=tempg2->x1; ptr[i<<1]=tempg2->p.x1;
ptr[i<<1+1]=tempg2->y1; ptr[i<<1+1]=tempg2->p.y1;
Free(tempg2); Free(tempg2);
tempg2=tempg1; tempg2=tempg1;
} }
tempg->type=SPT_POLYLINE; tempg->type=SPT_POLYLINE;
tempg->num=num+1; tempg->nu.num=num;
} else {
tempg2=root2.next;
for (i=0;i<num;i++) {
tempg1=tempg2->next;
Free(tempg2);
tempg2=tempg1;
}
tempg=NULL;
}
break; break;
case SPT_BSPLINE2: case SPT_BSPLINE2:
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYLINE)+ if (num>2) {
(num+1)*sizeof(CD3I32)); tempg=CAlloc(SpriteElemQuedBaseSize(eletype)+num*sizeof(CD3I32));
p=&tempg->y1; p=&tempg->nu.u;
tempg2=root2.next; tempg2=root2.next;
p[0].x=x3; for (i=0;i<num;i++) {
p[0].y=y3;
for (i=1;i<=num;i++) {
tempg1=tempg2->next; tempg1=tempg2->next;
p[i].x=tempg2->x1; p[i].x=tempg2->p.x1;
p[i].y=tempg2->y1; p[i].y=tempg2->p.y1;
Free(tempg2); Free(tempg2);
tempg2=tempg1; tempg2=tempg1;
} }
tempg->type=eletype; tempg->type=eletype;
tempg->num=num+1; tempg->nu.num=num;
} else {
tempg2=root2.next;
for (i=0;i<num;i++) {
tempg1=tempg2->next;
Free(tempg2);
tempg2=tempg1;
}
tempg=NULL;
}
break; break;
sub_switch_end: sub_switch_end:
break; break;
@@ -846,8 +879,7 @@ ei_restart:
x3=a1-x; y3=a2-y; x3=a1-x; y3=a2-y;
dc->color=color&COLORROP_NO_ROP0_MASK; dc->color=color&COLORROP_NO_ROP0_MASK;
do { do {
msg_code=GetMsg(&a1,&a2, msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
x2=a1; y2=a2; x2=a1; y2=a2;
GrLine3(dc,x1,y1,0,x2,y2,0); GrLine3(dc,x1,y1,0,x2,y2,0);
Line(&root2,x1-x,y1-y,0,x2-x,y2-y,0,&SpritePolyPtPlot); Line(&root2,x1-x,y1-y,0,x2-x,y2-y,0,&SpritePolyPtPlot);
@@ -859,38 +891,37 @@ ei_restart:
x1=x3;y1=y3; x1=x3;y1=y3;
while (tempg!=&root2) { while (tempg!=&root2) {
tempg1=tempg->next; tempg1=tempg->next;
if (tempg->x1==x1 && tempg->y1==y1) { if (tempg->p.x1==x1 && tempg->p.y1==y1) {
QueRem(tempg); QueRem(tempg);
Free(tempg); Free(tempg);
} else { } else {
num++; num++;
x1=tempg->x1; x1=tempg->p.x1;
y1=tempg->y1; y1=tempg->p.y1;
} }
tempg=tempg1; tempg=tempg1;
} }
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYPT)+(num*3+7)>>3); tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYPT)+(num*3+7)>>3);
ptr=&tempg->y1; tempg->npu.x=x3;
ptr[0]=x3; tempg->npu.y=y3;
ptr[1]=y3; ptr=&tempg->npu.u;
ptr+=2;
x1=x3;y1=y3; x1=x3;y1=y3;
i=0; i=0;
tempg2=root2.next; tempg2=root2.next;
while (tempg2!=&root2) { while (tempg2!=&root2) {
tempg1=tempg2->next; tempg1=tempg2->next;
BFieldOrU32(ptr,i, BFieldOrU32(ptr,i,
polypt_map[SignI64(tempg2->x1-x1)+1+ polypt_map[SignI64(tempg2->p.x1-x1)+1+
3*(SignI64(tempg2->y1-y1)+1)]); 3*(SignI64(tempg2->p.y1-y1)+1)]);
i+=3; i+=3;
x1=tempg2->x1;y1=tempg2->y1; x1=tempg2->p.x1;y1=tempg2->p.y1;
QueRem(tempg2); QueRem(tempg2);
Free(tempg2); Free(tempg2);
tempg2=tempg1; tempg2=tempg1;
} }
tempg->type=SPT_POLYPT; tempg->type=SPT_POLYPT;
tempg->num=num; tempg->npu.num=num;
break; break;
sub_switch_end: sub_switch_end:
if (tempg) { if (tempg) {
@@ -926,14 +957,14 @@ ei_bitmap:
xx2++; yy2++; xx2++; yy2++;
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+ tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+
((xx2-xx1+7)&~7)*(yy2-yy1)); ((xx2-xx1+7)&~7)*(yy2-yy1));
tempg->type=eletype; tempg->type=SPT_BITMAP;
tempg->width=xx2-xx1; tempg->pwhu.width=xx2-xx1;
tempg->height=yy2-yy1; tempg->pwhu.height=yy2-yy1;
tempg->x2=xx1-x; tempg->pwhu.x1=xx1-x;
tempg->y2=yy1-y; tempg->pwhu.y1=yy1-y;
img=DCNew(tempg->width,tempg->height,Fs); img=DCNew(tempg->pwhu.width,tempg->pwhu.height,Fs);
img->color=bm_bkcolor; img->color=bm_bkcolor;
GrRect(img,0,0,tempg->width,tempg->height); GrRect(img,0,0,tempg->pwhu.width,tempg->pwhu.height);
tempg1=insert_pt; tempg1=insert_pt;
if (tempg1==root || tempg1->type!=SPT_BITMAP) { if (tempg1==root || tempg1->type!=SPT_BITMAP) {
SpriteSetSettings(img,root,0,&color,&width,-(xx1-x),-(yy1-y)); SpriteSetSettings(img,root,0,&color,&width,-(xx1-x),-(yy1-y));
@@ -943,12 +974,12 @@ ei_bitmap:
cur_elem_num=1; cur_elem_num=1;
} else { } else {
SpriteSetSettings(img,root,cur_elem_num,&color,&width,-(xx1-x),-(yy1-y)); SpriteSetSettings(img,root,cur_elem_num,&color,&width,-(xx1-x),-(yy1-y));
Sprite3(img,-(xx1-x),-(yy1-y),0,tempg1(U8 *)+offset(CSprite.start),TRUE); Sprite3(img,-(xx1-x),-(yy1-y),0,&tempg1->start,TRUE);
insert_pt=tempg1->next; insert_pt=tempg1->next;
QueRem(tempg1); QueRem(tempg1);
Free(tempg1); Free(tempg1);
} }
MemCpy(tempg(U8 *)+offset(CSprite.linespeed),img->body,((xx2-xx1+7)&~7)*(yy2-yy1)); MemCpy(&tempg->pwhu.u,img->body,((xx2-xx1+7)&~7)*(yy2-yy1));
switch (i=SpriteBitMapEd(doc,doc_e,dc,&xx1,&yy1,&xx2,&yy2,&img,bm_bkcolor)) { switch (i=SpriteBitMapEd(doc,doc_e,dc,&xx1,&yy1,&xx2,&yy2,&img,bm_bkcolor)) {
case GE_EXIT: case GE_EXIT:
@@ -957,11 +988,11 @@ ei_bitmap:
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+ tempg=CAlloc(SpriteElemQuedBaseSize(SPT_BITMAP)+
((xx2-xx1+7)&~7)*(yy2-yy1)); ((xx2-xx1+7)&~7)*(yy2-yy1));
tempg->type=eletype; tempg->type=eletype;
tempg->width=xx2-xx1; tempg->pwhu.width=xx2-xx1;
tempg->height=yy2-yy1; tempg->pwhu.height=yy2-yy1;
tempg->x2=xx1-x; tempg->pwhu.x1=xx1-x;
tempg->y2=yy1-y; tempg->pwhu.y1=yy1-y;
MemCpy(tempg(U8 *)+offset(CSprite.linespeed),img->body,((xx2-xx1+7)&~7)*(yy2-yy1)); MemCpy(&tempg->pwhu.u,img->body,((xx2-xx1+7)&~7)*(yy2-yy1));
break; break;
} }
doc_e->de_flags=old_de_flags; doc_e->de_flags=old_de_flags;
@@ -987,25 +1018,25 @@ ei_shiftable_mesh:
x1=-(a1-x); x1=-(a1-x);
y1=-(a2-y); y1=-(a2-y);
z1=z; z1=z;
p=&tempg1->x2; p=&tempg1->mu.u;
for (i=0;i<tempg1->vertex_cnt;i++,p++) { for (i=0;i<tempg1->mu.vertex_cnt;i++,p++) {
p->x+=x1; p->x+=x1;
p->y+=y1; p->y+=y1;
p->z+=z1; p->z+=z1;
} }
old_mesh=&tempg1->vertex_cnt; old_mesh=&tempg1->mu.vertex_cnt;
} else if (tempg1!=root && tempg1->type==SPT_SHIFTABLE_MESH) { } else if (tempg1!=root && tempg1->type==SPT_SHIFTABLE_MESH) {
z=-tempg1->z1; z=-tempg1->pmu.z;
x1=tempg1->x1-(a1-x); x1=tempg1->pmu.x-(a1-x);
y1=tempg1->y1-(a2-y); y1=tempg1->pmu.y-(a2-y);
z1=tempg1->z1+z; z1=tempg1->pmu.z+z;
p=(&tempg1->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg1->pmu.u;
for (i=0;i<tempg1->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg1->pmu.vertex_cnt;i++,p++) {
p->x+=x1; p->x+=x1;
p->y+=y1; p->y+=y1;
p->z+=z1; p->z+=z1;
} }
old_mesh=&tempg1->shiftable_vertex_cnt; old_mesh=&tempg1->pmu.vertex_cnt;
} else { } else {
z=0; z=0;
old_mesh=NULL; old_mesh=NULL;
@@ -1013,11 +1044,11 @@ ei_shiftable_mesh:
if (mesh=SpriteMeshEd(old_mesh,&size,TRUE)) { if (mesh=SpriteMeshEd(old_mesh,&size,TRUE)) {
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFTABLE_MESH)-sizeof(I32)*2+size); tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFTABLE_MESH)-sizeof(I32)*2+size);
tempg->type=SPT_SHIFTABLE_MESH; tempg->type=SPT_SHIFTABLE_MESH;
MemCpy(&tempg->shiftable_vertex_cnt,mesh,size); MemCpy(&tempg->pmu.vertex_cnt,mesh,size);
Free(mesh); Free(mesh);
tempg->x1=a1-x; tempg->pmu.x=a1-x;
tempg->y1=a2-y; tempg->pmu.y=a2-y;
tempg->z1=-z; tempg->pmu.z=-z;
QueIns(tempg,insert_pt->last); QueIns(tempg,insert_pt->last);
SpriteEdUpdate(doc,tempb,root); SpriteEdUpdate(doc,tempb,root);
if (old_mesh) { if (old_mesh) {
@@ -1028,11 +1059,11 @@ ei_shiftable_mesh:
} else } else
cur_elem_num++; cur_elem_num++;
} else if (old_mesh && tempg1->type==SPT_SHIFTABLE_MESH) { } else if (old_mesh && tempg1->type==SPT_SHIFTABLE_MESH) {
x1=tempg1->x1-(a1-x); x1=tempg1->pmu.x-(a1-x);
y1=tempg1->y1-(a2-y); y1=tempg1->pmu.y-(a2-y);
z1=tempg1->z1+z; z1=tempg1->pmu.z+z;
p=(&tempg1->shiftable_tri_cnt)(U8 *)+sizeof(I32); p=&tempg1->pmu.u;
for (i=0;i<tempg1->shiftable_vertex_cnt;i++,p++) { for (i=0;i<tempg1->pmu.vertex_cnt;i++,p++) {
p->x-=x1; p->x-=x1;
p->y-=y1; p->y-=y1;
p->z-=z1; p->z-=z1;
@@ -1041,8 +1072,8 @@ ei_shiftable_mesh:
x1=-(a1-x); x1=-(a1-x);
y1=-(a2-y); y1=-(a2-y);
z1= z; z1= z;
p=&tempg1->x2; p=&tempg1->mu.u;
for (i=0;i<tempg1->vertex_cnt;i++,p++) { for (i=0;i<tempg1->mu.vertex_cnt;i++,p++) {
p->x-=x1; p->x-=x1;
p->y-=y1; p->y-=y1;
p->z-=z1; p->z-=z1;
@@ -1077,7 +1108,7 @@ U0 EdSpriteIns(CDoc *doc,I64 x,I64 y)
CDocEntry *doc_e; CDocEntry *doc_e;
CDocBin *tempb; CDocBin *tempb;
if (Fs!=doc->mem_task) if (Fs!=doc->mem_task)
Dbg; throw('Graphics');
if (st=EdSprite(doc->cur_bin_num)) { if (st=EdSprite(doc->cur_bin_num)) {
unlock=DocLock(doc); unlock=DocLock(doc);
tempb=CAlloc(sizeof(CDocBin),doc->mem_task); tempb=CAlloc(sizeof(CDocBin),doc->mem_task);
+2 -2
View File
@@ -384,7 +384,7 @@ U0 MPDrawIt(CMeshFrame *e)
CMeshEdTri *tempt=e->tri_root.next; CMeshEdTri *tempt=e->tri_root.next;
I64 i,*old_r=dc->r; I64 i,*old_r=dc->r;
//$LK,"DCAlias",A="MN:DCAlias"$() allocates a new identity rotation matrix. //$LK,"DCAlias",A="MN:DCAlias"$() alllocs a new identity rotation matrix.
//We want e->dc's rotation matrix. //We want e->dc's rotation matrix.
dc->r=e->dc->r; dc->r=e->dc->r;
@@ -955,7 +955,7 @@ $WW,0$*/
"}"); "}");
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WordStat; AutoComplete;
Preempt(OFF); //We don't really want window update while modifying links Preempt(OFF); //We don't really want window update while modifying links
AcctOneTimePopUp(ARf_MESH_ED, AcctOneTimePopUp(ARf_MESH_ED,
"$$GREEN$$Right Mouse$$FG$$: Hold and move to shift cursor z\n" "$$GREEN$$Right Mouse$$FG$$: Hold and move to shift cursor z\n"
+55 -56
View File
@@ -5,36 +5,36 @@ U8 polypt_map[9]={0,1,2,3,0,4,5,6,7};
I64 sprite_elem_base_sizes[SPT_NUM_TYPES]= I64 sprite_elem_base_sizes[SPT_NUM_TYPES]=
{ {
offset(CSprite.x1)-offset(CSprite.start), //SPT_END sizeof(CSpriteBase), //SPT_END
1+offset(CSprite.color)-offset(CSprite.start), //SPT_COLOR sizeof(CSpriteColor), //SPT_COLOR
2+offset(CSprite.dither_color)-offset(CSprite.start), //SPT_DITHER_COLOR sizeof(CSpriteDitherColor), //SPT_DITHER_COLOR
offset(CSprite.y1)-offset(CSprite.start), //SPT_WIDTH sizeof(CSpriteWidth), //SPT_WIDTH
offset(CSprite.linespeed)-offset(CSprite.start), //SPT_PLANAR_SYMMETRY sizeof(CSpritePtPt), //SPT_PLANAR_SYMMETRY
offset(CSprite.x1)-offset(CSprite.start), //SPT_TRANSFORM_ON sizeof(CSpriteBase), //SPT_TRANSFORM_ON
offset(CSprite.x1)-offset(CSprite.start), //SPT_TRANSFORM_OFF sizeof(CSpriteBase), //SPT_TRANSFORM_OFF
offset(CSprite.x2)-offset(CSprite.start), //SPT_SHIFT sizeof(CSpritePt), //SPT_SHIFT
offset(CSprite.x2)-offset(CSprite.start), //SPT_PT sizeof(CSpritePt), //SPT_PT
offset(CSprite.y2)-offset(CSprite.start), //SPT_POLYPT sizeof(CSpriteNumPtU8s), //SPT_POLYPT
offset(CSprite.linespeed)-offset(CSprite.start), //SPT_LINE sizeof(CSpritePtPt), //SPT_LINE
offset(CSprite.y1)-offset(CSprite.start), //SPT_POLYLINE sizeof(CSpriteNumU8s), //SPT_POLYLINE
offset(CSprite.linespeed)-offset(CSprite.start), //SPT_RECT sizeof(CSpritePtPt), //SPT_RECT
offset(CSprite.sides)-offset(CSprite.start), //SPT_ROTATED_RECT sizeof(CSpritePtPtAng), //SPT_ROTATED_RECT
offset(CSprite.y2)-offset(CSprite.start), //SPT_CIRCLE sizeof(CSpritePtRad), //SPT_CIRCLE
offset(CSprite.sides)-offset(CSprite.start), //SPT_ELLIPSE sizeof(CSpritePtWHAng), //SPT_ELLIPSE
sizeof(CSprite)-offset(CSprite.start), //SPT_POLYGON sizeof(CSpritePtWHAngSides), //SPT_POLYGON
offset(CSprite.y1)-offset(CSprite.start), //SPT_BSPLINE2 sizeof(CSpriteNumU8s), //SPT_BSPLINE2
offset(CSprite.y1)-offset(CSprite.start), //SPT_BSPLINE2_CLOSED sizeof(CSpriteNumU8s), //SPT_BSPLINE2_CLOSED
offset(CSprite.y1)-offset(CSprite.start), //SPT_BSPLINE3 sizeof(CSpriteNumU8s), //SPT_BSPLINE3
offset(CSprite.y1)-offset(CSprite.start), //SPT_BSPLINE3_CLOSED sizeof(CSpriteNumU8s), //SPT_BSPLINE3_CLOSED
offset(CSprite.x2)-offset(CSprite.start), //SPT_FLOOD_FILL sizeof(CSpritePt), //SPT_FLOOD_FILL
offset(CSprite.x2)-offset(CSprite.start), //SPT_FLOOD_FILL_NOT sizeof(CSpritePt), //SPT_FLOOD_FILL_NOT
offset(CSprite.linespeed)-offset(CSprite.start), //SPT_BITMAP sizeof(CSpritePtWHU8s), //SPT_BITMAP
offset(CSprite.x2)-offset(CSprite.start), //SPT_MESH sizeof(CSpriteMeshU8s), //SPT_MESH
offset(CSprite.shiftable_tri_cnt)+sizeof(I32)-offset(CSprite.start), //SPT_SHIFTABLE_MESH sizeof(CSpritePtMeshU8s), //SPT_SHIFTABLE_MESH
offset(CSprite.linespeed)-offset(CSprite.start), //SPT_ARROW sizeof(CSpritePtPt), //SPT_ARROW
offset(CSprite.st)-offset(CSprite.start), //SPT_TEXT sizeof(CSpritePtStr), //SPT_TEXT
offset(CSprite.st)-offset(CSprite.start), //SPT_TEXT_BOX sizeof(CSpritePtStr), //SPT_TEXT_BOX
offset(CSprite.st)-offset(CSprite.start), //SPT_TEXT_DIAMOND sizeof(CSpritePtStr), //SPT_TEXT_DIAMOND
}; };
I64 SpriteElemQuedBaseSize(I64 type) I64 SpriteElemQuedBaseSize(I64 type)
@@ -47,30 +47,30 @@ I64 SpriteElemSize(CSprite *tempg)
I64 i=sprite_elem_base_sizes[tempg->type]; I64 i=sprite_elem_base_sizes[tempg->type];
switch (tempg->type) { switch (tempg->type) {
case SPT_POLYLINE: case SPT_POLYLINE:
i+=tempg->num*sizeof(CD2I32); i+=tempg->nu.num*sizeof(CD2I32);
break; break;
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
i+=StrLen(tempg->st)+1; i+=StrLen(tempg->ps.st)+1;
break; break;
case SPT_BITMAP: case SPT_BITMAP:
i+=((tempg->width+7)&~7)*tempg->height; i+=((tempg->pwhu.width+7)&~7)*tempg->pwhu.height;
break; break;
case SPT_POLYPT: case SPT_POLYPT:
i+=(tempg->num*3+7)>>3; i+=(tempg->npu.num*3+7)>>3;
break; break;
case SPT_BSPLINE2: case SPT_BSPLINE2:
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
i+=tempg->num*sizeof(CD3I32); i+=tempg->nu.num*sizeof(CD3I32);
break; break;
case SPT_MESH: case SPT_MESH:
i+=tempg->vertex_cnt*sizeof(CD3I32)+tempg->tri_cnt*sizeof(CMeshTri); i+=tempg->mu.vertex_cnt*sizeof(CD3I32)+tempg->mu.tri_cnt*sizeof(CMeshTri);
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
i+=tempg->shiftable_vertex_cnt*sizeof(CD3I32)+tempg->shiftable_tri_cnt*sizeof(CMeshTri); i+=tempg->pmu.vertex_cnt*sizeof(CD3I32)+tempg->pmu.tri_cnt*sizeof(CMeshTri);
break; break;
} }
return i; return i;
@@ -105,12 +105,11 @@ public U8 *DC2Sprite(CDC *tempb)
sprite_elem_base_sizes[SPT_END]) sprite_elem_base_sizes[SPT_END])
(U8 *)-offset(CSprite.start); (U8 *)-offset(CSprite.start);
tempg->type=SPT_BITMAP; tempg->type=SPT_BITMAP;
tempg->width=tempb->width; tempg->pwhu.width=tempb->width;
tempg->height=tempb->height; tempg->pwhu.height=tempb->height;
tempg->x2=0; tempg->pwhu.x1=0;
tempg->y2=0; tempg->pwhu.y1=0;
MemCpy(tempg(U8 *)+offset(CSprite.linespeed),tempb->body, MemCpy(&tempg->pwhu.u,tempb->body,tempb->width_internal*tempb->height);
tempb->width_internal*tempb->height);
return tempg(U8 *)+offset(CSprite.start); return tempg(U8 *)+offset(CSprite.start);
} }
@@ -121,56 +120,56 @@ public U8 *SpriteElem2OneLineSummary(CSprite *tempg)
StrPrint(buf,"%Z",tempg->type,"ST_SPRITE_ELEM_TYPES"); StrPrint(buf,"%Z",tempg->type,"ST_SPRITE_ELEM_TYPES");
switch (tempg->type) { switch (tempg->type) {
case SPT_COLOR: case SPT_COLOR:
CatPrint(buf," %s",Color2Str(buf2,tempg->color)); CatPrint(buf," %s",Color2Str(buf2,tempg->c.color));
break; break;
case SPT_DITHER_COLOR: case SPT_DITHER_COLOR:
CatPrint(buf," %s",Color2Str(buf2,ROPF_DITHER|tempg->dither_color.u8[0]|tempg->dither_color.u8[1]<<COLORROP_BITS)); CatPrint(buf," %s",Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|tempg->d.dither_color.u8[1]<<COLORROP_BITS));
break; break;
case SPT_PT: case SPT_PT:
case SPT_FLOOD_FILL: case SPT_FLOOD_FILL:
case SPT_FLOOD_FILL_NOT: case SPT_FLOOD_FILL_NOT:
case SPT_SHIFT: case SPT_SHIFT:
CatPrint(buf," (%d,%d)",tempg->x1,tempg->y1); CatPrint(buf," (%d,%d)",tempg->p.x1,tempg->p.y1);
break; break;
case SPT_LINE: case SPT_LINE:
case SPT_ARROW: case SPT_ARROW:
case SPT_PLANAR_SYMMETRY: case SPT_PLANAR_SYMMETRY:
case SPT_RECT: case SPT_RECT:
case SPT_ROTATED_RECT: case SPT_ROTATED_RECT:
CatPrint(buf," (%d,%d),(%d,%d)",tempg->x1,tempg->y1,tempg->x2,tempg->y2); CatPrint(buf," (%d,%d),(%d,%d)",tempg->pp.x1,tempg->pp.y1,tempg->pp.x2,tempg->pp.y2);
break; break;
case SPT_CIRCLE: case SPT_CIRCLE:
CatPrint(buf," (%d,%d):%dR",tempg->x1,tempg->y1,tempg->x2); CatPrint(buf," (%d,%d):%dR",tempg->pr.x1,tempg->pr.y1,tempg->pr.radius);
break; break;
case SPT_WIDTH: case SPT_WIDTH:
CatPrint(buf," %d",tempg->width); CatPrint(buf," %d",tempg->w.width);
break; break;
case SPT_TEXT: case SPT_TEXT:
case SPT_TEXT_BOX: case SPT_TEXT_BOX:
case SPT_TEXT_DIAMOND: case SPT_TEXT_DIAMOND:
CatPrint(buf," %d,%d:%-16tQ",tempg->x1,tempg->y1,tempg->st); CatPrint(buf," %d,%d:%-16tQ",tempg->ps.x1,tempg->ps.y1,tempg->ps.st);
break; break;
case SPT_POLYLINE: case SPT_POLYLINE:
case SPT_POLYPT: case SPT_POLYPT:
ptr=&tempg->y1; ptr=&tempg->npu.x;
CatPrint(buf," %d (%d,%d)",tempg->num,ptr[0],ptr[1]); CatPrint(buf," %d (%d,%d)",tempg->npu.num,ptr[0],ptr[1]);
break; break;
case SPT_ELLIPSE: case SPT_ELLIPSE:
case SPT_POLYGON: case SPT_POLYGON:
case SPT_BITMAP: case SPT_BITMAP:
CatPrint(buf," (%d,%d):%dW,%dH",tempg->x2,tempg->y2,tempg->width,tempg->height); CatPrint(buf," (%d,%d):%dW,%dH",tempg->pwhu.x1,tempg->pwhu.y1,tempg->pwhu.width,tempg->pwhu.height);
break; break;
case SPT_BSPLINE2: case SPT_BSPLINE2:
case SPT_BSPLINE3: case SPT_BSPLINE3:
case SPT_BSPLINE2_CLOSED: case SPT_BSPLINE2_CLOSED:
case SPT_BSPLINE3_CLOSED: case SPT_BSPLINE3_CLOSED:
CatPrint(buf," %d",tempg->num); CatPrint(buf," %d",tempg->nu.num);
break; break;
case SPT_MESH: case SPT_MESH:
CatPrint(buf," %dV,%dT",tempg->vertex_cnt,tempg->tri_cnt); CatPrint(buf," %dV,%dT",tempg->mu.vertex_cnt,tempg->mu.tri_cnt);
break; break;
case SPT_SHIFTABLE_MESH: case SPT_SHIFTABLE_MESH:
CatPrint(buf," %dV,%dT",tempg->shiftable_vertex_cnt,tempg->shiftable_tri_cnt); CatPrint(buf," %dV,%dT",tempg->pmu.vertex_cnt,tempg->pmu.tri_cnt);
break; break;
} }
return StrNew(buf); return StrNew(buf);
+5 -11
View File
@@ -26,7 +26,7 @@ public CMenuEntry *MenuEntryFind(CMenu *haystack_menu,U8 *needle_full_name)
//Just 2 levels -- across top and down are valid, currently. //Just 2 levels -- across top and down are valid, currently.
U8 *st,*st2; U8 *st,*st2;
CMenuEntry *tempse; CMenuEntry *tempse;
if (!haystack_menu || haystack_menu->mu_signature!=MENU_SIGNATURE_VAL || !needle_full_name) if (!haystack_menu || !needle_full_name)
return NULL; return NULL;
st=StrNew(needle_full_name); st=StrNew(needle_full_name);
st2=StrNew(needle_full_name); st2=StrNew(needle_full_name);
@@ -91,13 +91,11 @@ public CMenu *MenuNew(U8 *st,I64 flags=0,CTask *task=NULL)
m=CAlloc(sizeof(CMenu),task); m=CAlloc(sizeof(CMenu),task);
m->task=task; m->task=task;
m->flags=flags; m->flags=flags;
m->attr =LTBLUE<<4 +YELLOW; m->attr =BLUE<<4+YELLOW;
m->checked_attr=LTGREEN<<4+BROWN;
tempse=&m->sub; tempse=&m->sub;
while (tempse) while (tempse)
tempse=tempse->next=MenuNewSub(lx,task); tempse=tempse->next=MenuNewSub(lx,task);
LexDel(lx); LexDel(lx);
m->mu_signature=MENU_SIGNATURE_VAL;
return m; return m;
} }
@@ -127,9 +125,7 @@ U0 MenuDelSub(CMenuEntry *tempme)
public U0 MenuDel(CMenu *m) public U0 MenuDel(CMenu *m)
{//Delete a manu. You probably don't need this. {//Delete a manu. You probably don't need this.
CMenuEntry *tempme,*tempme1; CMenuEntry *tempme,*tempme1;
if (!m || m->mu_signature!=MENU_SIGNATURE_VAL) if (!m) return;
return;
m->mu_signature=0;
tempme=m->sub; tempme=m->sub;
while (tempme) { while (tempme) {
tempme1=tempme->next; tempme1=tempme->next;
@@ -181,12 +177,10 @@ U0 DrawMenu(CDC *dc)
U8 *st=NULL; U8 *st=NULL;
CTask *task=MenuTask; CTask *task=MenuTask;
I64 i,w,x0,y0,x1=ip.pos.x,y1=ip.pos.y; I64 i,w,x0,y0,x1=ip.pos.x,y1=ip.pos.y;
if (!TaskValidate(task) || !(m=task->cur_menu) || if (!TaskValidate(task) || !(m=task->cur_menu)) {
m->mu_signature!=MENU_SIGNATURE_VAL) {
sys_cur_submenu_entry=NULL; sys_cur_submenu_entry=NULL;
return; return;
} }
dc->color=m->attr>>4; dc->color=m->attr>>4;
GrRect(dc,0,0,GR_WIDTH,FONT_HEIGHT); GrRect(dc,0,0,GR_WIDTH,FONT_HEIGHT);
x0=0; x0=0;
@@ -205,7 +199,7 @@ U0 DrawMenu(CDC *dc)
tempse=tempme->sub; tempse=tempme->sub;
while (tempse) { while (tempse) {
if (tempse->checked) if (tempse->checked)
i=m->checked_attr; i=m->attr^0xFF;
else else
i=m->attr; i=m->attr;
if (y0<=y1<y0+FONT_HEIGHT) { if (y0<=y1<y0+FONT_HEIGHT) {
+2 -2
View File
@@ -13,7 +13,7 @@ public U0 SndTaskEndCB()
Exit; Exit;
} }
#include "MathAudio" #include "SndMath"
#include "Music" #include "SndMusic"
#include "SndEffects" #include "SndEffects"
#include "SndFile" #include "SndFile"
+15 -1
View File
@@ -17,7 +17,7 @@ class CFileSND
#define MAX_SND_FILE_DATA 0x7FFFFF00 #define MAX_SND_FILE_DATA 0x7FFFFF00
public I64 SndFileCreate(U8 *base_filename,F64 normalized_vol=1.0,F64 averaging=0.0,I64 waveform=WF_SQUARE, public I64 SndFileCreate(U8 *base_filename,F64 normalized_vol=1.0,F64 averaging=0.0,I64 waveform=WF_SQUARE,
F64 reverb_delay=0,F64 reverb_intensity=0) F64 reverb_delay=0,F64 reverb_intensity=0,F64 time_shift=0)
{//Use "snd.record" flag to start or stop recording, then call this routine. {//Use "snd.record" flag to start or stop recording, then call this routine.
//Averaging should be a num from 0.0 to 0.999. //Averaging should be a num from 0.0 to 0.999.
//Vol should be from 0.0 to 1.0. //Vol should be from 0.0 to 1.0.
@@ -46,6 +46,20 @@ public I64 SndFileCreate(U8 *base_filename,F64 normalized_vol=1.0,F64 averaging=
s->sample_rate=EndianU32(SNDFILE_SAMPLE_RATE); s->sample_rate=EndianU32(SNDFILE_SAMPLE_RATE);
s->channels=EndianU32(1); s->channels=EndianU32(1);
if (time_shift) {
d=snd.record_root.next;
d->time-=time_shift;
while (d->next!=&snd.record_root) {
d1=d->next;
dt=d1->time-d->time;
if (dt<0) {
QueRem(d1);
Free(d1);
} else
break;
}
}
d=snd.record_root.next; d=snd.record_root.next;
k=0; k=0;
while (d->next!=&snd.record_root) { while (d->next!=&snd.record_root) {
File renamed without changes.
File renamed without changes.
-12
View File
@@ -1,12 +0,0 @@
U0 Start()
{
Type("::/Doc/Splash.TXT");
SetWinHorz(TEXT_COLS/4-1,3*TEXT_COLS/4);
SetWinVert(6,Fs->win_bottom);
"$$GREEN$$Tip of day$$FG$$\n";
TipOfDay;
"$$GREEN$$<SHIFT-ESC>$$FG$$ to exit.\n";
View;
}
Start;
+9 -6
View File
@@ -10,6 +10,7 @@ public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
if (!task) task=Fs; if (!task) task=Fs;
if (!TaskValidate(task)) return NULL; if (!TaskValidate(task)) return NULL;
tempse=CAlloc(sizeof(CTaskSettings),task); tempse=CAlloc(sizeof(CTaskSettings),task);
tempse->cur_dir=CurDir(task,task);
tempse->draw_it=task->draw_it; tempse->draw_it=task->draw_it;
GetVGAPalette4(tempse->palette4); GetVGAPalette4(tempse->palette4);
tempse->task_end_cb=task->task_end_cb; tempse->task_end_cb=task->task_end_cb;
@@ -48,10 +49,10 @@ public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
tempse->border_src =task->border_src; tempse->border_src =task->border_src;
tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER); tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER);
tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT); tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT);
if (TaskValidate(ws.task)) if (TaskValidate(ac.task))
tempse->wordstat=TRUE; tempse->autocomplete=TRUE;
else else
tempse->wordstat=FALSE; tempse->autocomplete=FALSE;
tempse->next=task->next_settings; tempse->next=task->next_settings;
task->next_settings=tempse; task->next_settings=tempse;
@@ -68,8 +69,8 @@ U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
} }
WinBorder(tempse->border,task); WinBorder(tempse->border,task);
SetWinHorz(tempse->left,tempse->right,task); WinHorz(tempse->left,tempse->right,task);
SetWinVert(tempse->top,tempse->bottom,task); WinVert(tempse->top,tempse->bottom,task);
task->scroll_x=tempse->scroll_x; task->scroll_x=tempse->scroll_x;
task->scroll_y=tempse->scroll_y; task->scroll_y=tempse->scroll_y;
task->scroll_z=tempse->scroll_z; task->scroll_z=tempse->scroll_z;
@@ -79,7 +80,7 @@ U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
task->border_src =tempse->border_src; task->border_src =tempse->border_src;
task->title_src =tempse->title_src; task->title_src =tempse->title_src;
StrCpy(task->task_title,tempse->task_title); StrCpy(task->task_title,tempse->task_title);
WordStat(tempse->wordstat); AutoComplete(tempse->autocomplete);
SetVGAPalette4(tempse->palette4); SetVGAPalette4(tempse->palette4);
Snd(0); Snd(0);
} }
@@ -95,6 +96,8 @@ public U0 SettingsPop(CTask *task=NULL,I64 flags=0)
} }
if (tempse=task->next_settings) { if (tempse=task->next_settings) {
task->next_settings=tempse->next; task->next_settings=tempse->next;
Cd(tempse->cur_dir);
Free(tempse->cur_dir);
task->draw_it=tempse->draw_it; task->draw_it=tempse->draw_it;
task->task_end_cb=tempse->task_end_cb; task->task_end_cb=tempse->task_end_cb;
+1 -1
View File
@@ -49,7 +49,7 @@ U0 KeyMapCtrlAltFamily()
a2=SC_ESC+SCF_CTRL+SCF_ALT; a2=SC_ESC+SCF_CTRL+SCF_ALT;
st2=ScanCode2KeyName(a2); st2=ScanCode2KeyName(a2);
st=SrcEdLink(&SpawnUser,256); st=SrcEdLink(&User,256);
"%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,"Sys/Spawn New User Task",st; "%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,"Sys/Spawn New User Task",st;
Free(st); Free(st);
Free(st2); Free(st2);
+101 -60
View File
@@ -24,23 +24,21 @@ class CFileBMP
CBGR palette[16]; CBGR palette[16];
}; };
public CFileBMP *BMPFile4To(CDC *dc) public CFileBMP *BMP4To(CDC *dc)
{//To Windows 4-bit BMP. {//To Windows 4-bit BMP.
U8 *src,*ptr; U8 *src,*ptr;
I64 x,y,w=dc->width>>1, I64 x,y,w=dc->width>>1,
size=offset(CFileBMP.end)+dc->width*dc->height>>1+16*sizeof(CBGR); size=sizeof(CFileBMP)+dc->width*dc->height>>1;
CFileBMP *r=CAlloc(size); CFileBMP *r =CAlloc(size);
r->type='BM'; r->type ='BM';
r->planes=1; r->planes =1;
r->file_size=size; r->file_size =size;
r->data_offset=offset(CFileBMP.end); r->data_offset=sizeof(CFileBMP);
r->header_size=offset(CFileBMP.end)- r->header_size=offset(CFileBMP.end)-offset(CFileBMP.header_size);
offset(CFileBMP.header_size); r->width =dc->width;
r->width=dc->width; r->height =dc->height;
r->height=dc->height; r->bit_cnt =4;
r->bit_cnt=4; r->image_size =dc->width*dc->height>>1;
r->image_size=dc->width*dc->height>>1;
r->data_offset+=16*sizeof(CBGR);
GetVGAPalette4(r->palette); GetVGAPalette4(r->palette);
ptr=r(U8 *)+r->data_offset; ptr=r(U8 *)+r->data_offset;
for (y=dc->height-1;y>=0;y--) { for (y=dc->height-1;y>=0;y--) {
@@ -54,23 +52,21 @@ public CFileBMP *BMPFile4To(CDC *dc)
return r; return r;
} }
public CFileBMP *BMPFileRLE4To(CDC *dc) public CFileBMP *BMPRLE4To(CDC *dc)
{//To Windows RLE4 bit BMP. {//To Windows RLE4 bit BMP.
U8 *src,*ptr; U8 *src,*ptr,*start;
I64 x,y,w=dc->width,cnt,pattern; I64 x,y,w=dc->width,cnt,pattern;
CFileBMP *r=CAlloc(offset(CFileBMP.end)+2*(dc->width+1)*dc->height+16*sizeof(CBGR)); CFileBMP *r =CAlloc(sizeof(CFileBMP)+2*(dc->width+1)*dc->height);
r->type='BM'; r->type ='BM';
r->planes=1; r->planes =1;
r->data_offset=offset(CFileBMP.end); r->data_offset=sizeof(CFileBMP);
r->header_size=offset(CFileBMP.end)- r->header_size=offset(CFileBMP.end)-offset(CFileBMP.header_size);
offset(CFileBMP.header_size); r->width =dc->width;
r->width=dc->width; r->height =dc->height;
r->height=dc->height; r->bit_cnt =4;
r->bit_cnt=4;
r->compression=2; //RLE4 r->compression=2; //RLE4
r->data_offset+=16*sizeof(CBGR);
GetVGAPalette4(r->palette); GetVGAPalette4(r->palette);
ptr=r(U8 *)+r->data_offset; start=ptr=r(U8 *)+r->data_offset;
for (y=dc->height-1;y>=0;y--) { for (y=dc->height-1;y>=0;y--) {
src=y*dc->width_internal+dc->body; src=y*dc->width_internal+dc->body;
x=0; x=0;
@@ -101,27 +97,26 @@ public CFileBMP *BMPFileRLE4To(CDC *dc)
} }
*ptr(U16 *)++=0; *ptr(U16 *)++=0;
} }
r->image_size=ptr-(&r->data_offset)(U8 *); r->image_size=ptr-start;
r->file_size=offset(CFileBMP.end)+r->image_size+16*sizeof(CBGR); r->file_size=sizeof(CFileBMP)+r->image_size;
return r; return r;
} }
public CFileBMP *BMPFile24To(CDC *dc) public CFileBMP *BMP24To(CDC *dc)
{//To Windows 24-bit BMP. {//To Windows 24-bit BMP.
U8 *src; U8 *src;
I64 i,x,y,size=offset(CFileBMP.end)+dc->width*dc->height*sizeof(CRGB); I64 i,x,y,size=offset(CFileBMP.end)+dc->width*dc->height*sizeof(CRGB);
CBGR *bgr; CBGR *bgr;
CFileBMP *r=CAlloc(size); CFileBMP *r =CAlloc(size);
r->type='BM'; r->type ='BM';
r->planes=1; r->planes =1;
r->file_size=size; r->file_size =size;
r->data_offset=offset(CFileBMP.end); r->data_offset=offset(CFileBMP.end);
r->header_size=offset(CFileBMP.end)- r->header_size=offset(CFileBMP.end)-offset(CFileBMP.header_size);
offset(CFileBMP.header_size); r->width =dc->width;
r->width=dc->width; r->height =dc->height;
r->height=dc->height; r->bit_cnt =32;
r->bit_cnt=32; r->image_size =dc->width*dc->height<<2;
r->image_size=dc->width*dc->height<<2;
bgr=r(U8 *)+r->data_offset; bgr=r(U8 *)+r->data_offset;
for (y=dc->height-1;y>=0;y--) { for (y=dc->height-1;y>=0;y--) {
@@ -142,22 +137,22 @@ public CFileBMP *BMPFile24To(CDC *dc)
return r; return r;
} }
public I64 BMPFileWrite(U8 *filename,CDC *dc,I64 bits=4) public I64 BMPWrite(U8 *filename,CDC *dc,I64 bits=4)
{//Window's BMP Files. {//Window's BMP Files.
I64 size; I64 size;
CFileBMP *r; CFileBMP *r;
if (bits==4) { if (bits==4) {
if (IsDotZ(filename)) //.Z compression is better than RLE if (IsDotZ(filename)) //.Z compression is better than RLE
r=BMPFile4To(dc); r=BMP4To(dc);
else { else {
r=BMPFileRLE4To(dc); r=BMPRLE4To(dc);
if (r->file_size>offset(CFileBMP.end)+dc->width*dc->height>>1+16*sizeof(CBGR)) { if (r->file_size>sizeof(CFileBMP)+dc->width*dc->height>>1) {
Free(r); Free(r);
r=BMPFile4To(dc); r=BMP4To(dc);
} }
} }
} else if (bits==24) } else if (bits==24)
r=BMPFile24To(dc); r=BMP24To(dc);
else { else {
"Format Not Supported.\n"; "Format Not Supported.\n";
return 0; return 0;
@@ -168,7 +163,7 @@ public I64 BMPFileWrite(U8 *filename,CDC *dc,I64 bits=4)
return size; return size;
} }
U8 *BMPFilePaletteNew(CFileBMP *r) U8 *BMPPaletteNew(CFileBMP *r)
{ {
I64 i,j,best,score,best_score; I64 i,j,best,score,best_score;
CBGR palette[16]; CBGR palette[16];
@@ -193,11 +188,39 @@ U8 *BMPFilePaletteNew(CFileBMP *r)
U8 ms_paint_palette[16]={0,4,2,6,1,5,3,8,7,12,10,14,9,13,11,15}; U8 ms_paint_palette[16]={0,4,2,6,1,5,3,8,7,12,10,14,9,13,11,15};
public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE) I64 BMP24Color(CBGR *ptr,Bool dither_probability)
{
I64 result,k;
if (dither_probability) {
k=RandU32;
if (SqrI64(ptr->r)+SqrI64(ptr->g)+SqrI64(ptr->b)>=3*SqrI64(k.u8[0]))
result=8;
else
result=0;
if (ptr->r>=k.u8[1]) result|=RED;
if (ptr->g>=k.u8[2]) result|=GREEN;
if (ptr->b>=k.u8[3]) result|=BLUE;
} else {
if (SqrI64(ptr->r)+SqrI64(ptr->g)+SqrI64(ptr->b)>=SqrI64(0x80)) {
result=8;
if (ptr->r>=0x80) result|=RED;
if (ptr->g>=0x80) result|=GREEN;
if (ptr->b>=0x80) result|=BLUE;
} else {
result=0;
if (ptr->r>=0x40) result|=RED;
if (ptr->g>=0x40) result|=GREEN;
if (ptr->b>=0x40) result|=BLUE;
}
}
return result;
}
public CDC *BMPRead(U8 *filename,Bool dither_probability=FALSE,Bool use_ms_paint_palette=FALSE)
{//Window's BMP Files. {//Window's BMP Files.
I64 i,j,cnt; I64 i,j,cnt;
U8 *palette_map,*ptr; U8 *palette_map,*ptr;
Bool rle4; Bool rle;
CFileBMP *r; CFileBMP *r;
CDC *result=NULL; CDC *result=NULL;
if (ptr=FileRead(filename)) { if (ptr=FileRead(filename)) {
@@ -205,17 +228,17 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
if (0<r->width<MAX_I32 && 0<r->height<MAX_I32) { if (0<r->width<MAX_I32 && 0<r->height<MAX_I32) {
result=DCNew(r->width,r->height); result=DCNew(r->width,r->height);
ptr+=r->data_offset; ptr+=r->data_offset;
if (r->bit_cnt==4) {
if (r->compression==2) if (r->compression==2)
rle4=TRUE; rle=TRUE;
else else
rle4=FALSE; rle=FALSE;
if (use_ms_paint_palette) if (use_ms_paint_palette)
palette_map=ms_paint_palette; palette_map=ms_paint_palette;
else else
palette_map=BMPFilePaletteNew(r); palette_map=BMPPaletteNew(r);
if (r->bit_cnt==4) {
for (i=r->height-1;i>=0;i--) for (i=r->height-1;i>=0;i--)
if (rle4) {//We don't support full RLE4, just our own subset if (rle) {//We don't support full RLE4, just our own subset
j=0; j=0;
while (cnt=*ptr++) { while (cnt=*ptr++) {
if (cnt==1) { if (cnt==1) {
@@ -238,7 +261,7 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
} }
ptr++; ptr++;
} else } else
for (j=0;j<(r->width+7)&-8;) { for (j=0;j<(r->width+7)&~7;) {
result->color=palette_map[*ptr&15]; result->color=palette_map[*ptr&15];
GrPlot(result,j+1,i); GrPlot(result,j+1,i);
result->color=palette_map[*ptr>>4]; result->color=palette_map[*ptr>>4];
@@ -248,6 +271,24 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
} }
if (!use_ms_paint_palette) if (!use_ms_paint_palette)
Free(palette_map); Free(palette_map);
} else if (r->bit_cnt==24) {
for (i=r->height-1;i>=0;i--) {
for (j=0;j<r->width;j++,ptr+=3) {
result->color=BMP24Color(ptr,dither_probability);
GrPlot(result,j,i);
}
ptr+=r->width&3;
}
if (!use_ms_paint_palette)
Free(palette_map);
} else if (r->bit_cnt>=32) {
for (i=r->height-1;i>=0;i--)
for (j=0;j<r->width;j++,ptr+=4) {
result->color=BMP24Color(ptr,dither_probability);
GrPlot(result,j,i);
}
if (!use_ms_paint_palette)
Free(palette_map);
} else { } else {
"Format Not Supported.\n"; "Format Not Supported.\n";
DCDel(result); DCDel(result);
@@ -261,9 +302,9 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
} }
#help_index "Graphics/Sprite;Graphics/Windows BMP Files;DolDoc/Output" #help_index "Graphics/Sprite;Graphics/Windows BMP Files;DolDoc/Output"
public U0 DocBMPFile(CDoc *doc=NULL,U8 *filename,Bool use_ms_paint_palette=FALSE) public U0 DocBMP(CDoc *doc=NULL,U8 *filename,Bool dither_probability=FALSE,Bool use_ms_paint_palette=FALSE)
{//Put a BMP file into a document as a sprite. {//Put a BMP file into a document as a sprite.
CDC *dc=BMPFileRead(filename,use_ms_paint_palette); CDC *dc=BMPRead(filename,dither_probability,use_ms_paint_palette);
CSprite *elems=DC2Sprite(dc); CSprite *elems=DC2Sprite(dc);
DocSprite(doc,elems); DocSprite(doc,elems);
Free(elems); Free(elems);
@@ -271,10 +312,10 @@ public U0 DocBMPFile(CDoc *doc=NULL,U8 *filename,Bool use_ms_paint_palette=FALSE
} }
#help_index "Graphics/Windows BMP Files;Graphics/Screen" #help_index "Graphics/Windows BMP Files;Graphics/Screen"
public I64 BMPFileCaptureScreen(U8 *filename,I64 bits=4) public I64 BMPCaptureScreen(U8 *filename,I64 bits=4,Bool include_zoom=TRUE)
{//Capture screen as BMP file. {//Capture screen as BMP file.
CDC *dc=DCCaptureScreen; CDC *dc=DCCaptureScreen(include_zoom);
I64 size=BMPFileWrite(filename,dc,bits); I64 size=BMPWrite(filename,dc,bits);
DCDel(dc); DCDel(dc);
return size; return size;
} }
+5 -5
View File
@@ -140,7 +140,7 @@ I64 GrepFile(U8 *needle_str,U8 *haystack_filename,I64 *_fuf_flags,U8 *replace_te
return cnt; return cnt;
} }
public I64 Grep(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags=NULL,U8 *replace_text=NULL) public I64 Find(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags=NULL,U8 *replace_text=NULL)
{/*Find occurrences of a string in files. {/*Find occurrences of a string in files.
This does not do regular expressions. This does not do regular expressions.
Anyway, it's good for searching and replacing. Anyway, it's good for searching and replacing.
@@ -184,7 +184,7 @@ public I64 FileOcc(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags="+r+i+l")
*/ */
I64 cnt=0; I64 cnt=0;
Bool old_silent=Silent(TRUE); Bool old_silent=Silent(TRUE);
cnt=Grep(needle_str,files_find_mask,fu_flags); cnt=Find(needle_str,files_find_mask,fu_flags);
Silent(old_silent); Silent(old_silent);
return cnt; return cnt;
} }
@@ -215,7 +215,7 @@ I64 GrepWiz()
g->match_case=doc->find_replace->match_case; g->match_case=doc->find_replace->match_case;
g->whole_labels=doc->find_replace->whole_labels; g->whole_labels=doc->find_replace->whole_labels;
} }
if (DocFormDo(g,,0,"$$PURPLE$$$$TX+CX,\"Grep\"$$\n$$FG$$")) { if (DocFormDo(g,,0,"$$PURPLE$$$$TX+CX,\"Find\"$$\n$$FG$$")) {
if (doc) { if (doc) {
StrCpy(doc->find_replace->find_text,g->find_text); StrCpy(doc->find_replace->find_text,g->find_text);
StrCpy(doc->find_replace->replace_text,g->replace_text); StrCpy(doc->find_replace->replace_text,g->replace_text);
@@ -233,9 +233,9 @@ I64 GrepWiz()
if (g->whole_labels) if (g->whole_labels)
CatPrint(buf,"+l"); CatPrint(buf,"+l");
if (g->replace) if (g->replace)
st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf,g->replace_text); st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Find(\"%Q\",\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf,g->replace_text);
else else
st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf); st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Find(\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf);
result=PopUp(st); result=PopUp(st);
} }
Free(dir); Free(dir);
+3 -3
View File
@@ -56,14 +56,14 @@ I64 SizeRep1(CDirEntry *tempde,I64 *_fuf_flags)
{ {
I64 result=0,i; I64 result=0,i;
U8 buf[BLK_SIZE]; U8 buf[BLK_SIZE];
CPrt *p; CDrv *dv;
while (tempde) { while (tempde) {
if (tempde->attr&RS_ATTR_DIR) if (tempde->attr&RS_ATTR_DIR)
i=SizeRep1(tempde->sub,_fuf_flags); i=SizeRep1(tempde->sub,_fuf_flags);
else if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) && else if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) &&
FileAttr(tempde->name)&RS_ATTR_COMPRESSED) { FileAttr(tempde->name)&RS_ATTR_COMPRESSED) {
p=Drv2Prt(*tempde->full_name); dv=Let2Drv(*tempde->full_name);
RBlks(p,buf,Cluster2Blk(p,tempde->cluster),1); RBlks(dv,buf,Cluster2Blk(dv,tempde->cluster),1);
i=(&buf)(CArcCompress *)->expanded_size; i=(&buf)(CArcCompress *)->expanded_size;
} }
tempde->user_data=i; tempde->user_data=i;
+28 -36
View File
@@ -2,21 +2,15 @@
I64 TSSSize(CTSS *tss) I64 TSSSize(CTSS *tss)
{ {
return MSize2(tss)+ return MSize2(tss)+MSize2(tss->st0)+MSize2(tss->st1)+MSize2(tss->st2);
MSize2(tss->st0)+
MSize2(tss->st1)+
MSize2(tss->st2);
} }
I64 PenBrushesSize() I64 PenBrushesSize()
{ {
I64 result=0,i; I64 result=0,i;
for (i=0;i<GR_NUM_PEN_BRUSHES;i++) for (i=0;i<GR_NUM_PEN_BRUSHES;i++)
result+= result+=DCSize(gr.pen_brushes[i])+DCSize(gr.collision_pen_brushes[i])+
DCSize(gr.pen_brushes[i])+ DCSize(gr.even_pen_brushes[i])+DCSize(gr.odd_pen_brushes[i]);
DCSize(gr.collision_pen_brushes[i])+
DCSize(gr.even_pen_brushes[i])+
DCSize(gr.odd_pen_brushes[i] );
return result; return result;
} }
@@ -70,26 +64,25 @@ I64 TaskQueSize(CTask *task)
I64 BlkDevsSize() I64 BlkDevsSize()
{ {
I64 i,result=MSize2(dsk.blkdevs); I64 i,result=MSize2(dsk.blkdevs);
CBlkDev *bdev; CBlkDev *bd;
for (i=0;i<NUM_BLKDEVS;i++) { for (i=0;i<NUM_BLKDEVS;i++) {
bdev=&dsk.blkdevs[i]; bd=&dsk.blkdevs[i];
if (bdev->bd_signature==BD_SIGNATURE_VAL) { if (bd->bd_signature==BD_SIGNATURE_VAL) {
if (bdev->type==BDT_RAM) if (bd->type==BDT_RAM)
"RAMDsk %C\t:%010X Unused:%010X\n", "RAMDsk %C\t:%010X Unused:%010X\n",
bdev->first_drv_let,(bdev->max_blk+1)<<BLK_SIZE_BITS, bd->first_drv_let,(bd->max_blk+1)<<BLK_SIZE_BITS,
UnusedDrvSpace(bdev->first_drv_let); UnusedDrvSpace(bd->first_drv_let);
result+=MSize2(bdev->dev_id_record); result+=MSize2(bd->dev_id_record);
} }
} }
return result; return result;
} }
I64 PrtsSize() I64 DrvsSize()
{ {
I64 i,result=MSize2(dsk.prts); I64 i,result=MSize2(dsk.drvs);
for (i=0;i<NUM_PRTS;i++) for (i=0;i<NUM_DRVS;i++)
result+=MSize2(dsk.prts[i].buffered_map_dirty_bits)+ result+=MSize2(dsk.drvs[i].cur_map_blk)+MSize2(dsk.drvs[i].fis);
MSize2(dsk.prts[i].fis);
return result; return result;
} }
@@ -110,10 +103,9 @@ Bool MemRepTask(CTask *task,Bool override_validate=FALSE)
st=MStrUtil(task->task_title,SUF_REM_CTRL_CHARS|SUF_SAFE_DOLLAR); st=MStrUtil(task->task_title,SUF_REM_CTRL_CHARS|SUF_SAFE_DOLLAR);
"$$GREEN$$Task:%010X$$CYAN$$ %-30ts$$FG$$\n$$ID,2$$",task,st; "$$GREEN$$Task:%010X$$CYAN$$ %-30ts$$FG$$\n$$ID,2$$",task,st;
Free(st); Free(st);
"$$PURPLE$$Alloced:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n", "$$PURPLE$$Alloced:%010X Used:%010X$$FG$$\n",
TaskAllocatedMem(task,override_validate), TaskMemAlloced(task,override_validate),
TaskUsedMem(task,override_validate), TaskMemUsed(task,override_validate);
TaskUnusedAllocatedMem(task,override_validate);
"HashTable\t:%010X\n",HashTableSize2(task->hash_table); "HashTable\t:%010X\n",HashTableSize2(task->hash_table);
i=UnusedStk(task); i=UnusedStk(task);
@@ -169,15 +161,15 @@ Bool MemRepTask(CTask *task,Bool override_validate=FALSE)
"TaskStructs\t:%010X\n",j; "TaskStructs\t:%010X\n",j;
"TSSes\t:%010X\n",k; "TSSes\t:%010X\n",k;
"HeapCtrls\t:%010X\n",m; "HeapCtrls\t:%010X\n",m;
if (n)
"TaskQues\t:%010X\n",n; "TaskQues\t:%010X\n",n;
"BlkDevs\t:%010X\n",BlkDevsSize; "BlkDevs\t:%010X\n",BlkDevsSize;
"Prts\t:%010X\n",PrtsSize; "Drvs\t:%010X\n",DrvsSize;
"Audio\t:%010X\n",CallExtStr("AudioSize");
if (dsk.cache_base) if (dsk.cache_base)
"DskCache\t:%010X\n", "DskCache\t:%010X\n",
MSize2(dsk.cache_base)+MSize2(dsk.cache_hash_table)+MSize2(dsk.cache_ctrl); MSize2(dsk.cache_base)+MSize2(dsk.cache_hash_table)+MSize2(dsk.cache_ctrl);
"WordStat\t:%010X\n",CallExtStr("WordStatSize");
"Clipboard\t:%010X\n",DocSize(sys_clipboard_doc); "Clipboard\t:%010X\n",DocSize(sys_clipboard_doc);
"AutoComplete:%010X\n",CallExtStr("AutoCompleteSize");
"gr.to_8_bits\t:%010X\n",MSize2(gr.to_8_bits); "gr.to_8_bits\t:%010X\n",MSize2(gr.to_8_bits);
"gr.to_8_colors\t:%010X\n",MSize2(gr.to_8_colors); "gr.to_8_colors\t:%010X\n",MSize2(gr.to_8_colors);
"gr.text_base\t:%010X\n",MSize2(gr.text_base); "gr.text_base\t:%010X\n",MSize2(gr.text_base);
@@ -214,13 +206,13 @@ public U0 MemRep()
"$$ID,-2$$"; "$$ID,-2$$";
if (sys_data_bp) { if (sys_data_bp) {
"$$BLACK$$Code Heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n", "$$BLACK$$Code Heap:%010X Used:%010X$$FG$$\n",
sys_code_bp->size*PAGE_SIZE,sys_code_bp->allocated_u8s,UnusedBPMem(sys_code_bp); sys_code_bp->alloced_u8s,sys_code_bp->used_u8s;
"$$BLACK$$Data Heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n", "$$BLACK$$Data Heap:%010X Used:%010X$$FG$$\n",
sys_data_bp->size*PAGE_SIZE,sys_data_bp->allocated_u8s,UnusedBPMem(sys_data_bp); sys_data_bp->alloced_u8s,sys_data_bp->used_u8s;
} else } else
"$$BLACK$$Code/Data Heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n", "$$BLACK$$Code/Data Heap:%010X Used:%010X$$FG$$\n",
sys_code_bp->size*PAGE_SIZE,sys_code_bp->allocated_u8s,UnusedBPMem(sys_code_bp); sys_code_bp->alloced_u8s,sys_code_bp->used_u8s;
for (i=0;i<mp_cnt;i++) { for (i=0;i<mp_cnt;i++) {
c=&cpu_structs[i]; c=&cpu_structs[i];
@@ -236,8 +228,8 @@ public U0 MemRep()
} }
"$$GREEN$$Independent Heaps$$FG$$\n$$ID,2$$"; "$$GREEN$$Independent Heaps$$FG$$\n$$ID,2$$";
"$$BLACK$$dev.uncached_heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n", "$$BLACK$$dev.uncached_heap:%010X Used:%010X$$FG$$\n",
dev.uncached_heap->bp->size*PAGE_SIZE,dev.uncached_heap->used_u8s,UnusedBPMem(dev.uncached_heap->bp); dev.uncached_heap->bp->alloced_u8s,dev.uncached_heap->used_u8s;
"$$ID,-2$$\n"; "$$ID,-2$$\n";
Preempt(old_preempt); Preempt(old_preempt);
} }
+9 -9
View File
@@ -1,6 +1,6 @@
#help_index "DolDoc/Conversion" #help_index "DolDoc/Conversion"
//See $LK,"::/Doc/Acknowledgements.TXT"$. //See $LK,"::/Doc/Credits.TXT"$.
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,U8 *st,I64 *_col,U8 *style_bitmap=NULL) U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{ {
@@ -61,7 +61,7 @@ U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,U8 *st,I64 *_col,U8 *style
} }
} }
U8 *TSLinkCvt2(U8 *filename,I64 line_num) U8 *TOSLinkCvt2(U8 *filename,I64 line_num)
{// ::/ --> http://www.templeos.org/Wb/ {// ::/ --> http://www.templeos.org/Wb/
//Make your own LinkCvt routine //Make your own LinkCvt routine
U8 *result=NULL,*st; U8 *result=NULL,*st;
@@ -74,7 +74,7 @@ U8 *TSLinkCvt2(U8 *filename,I64 line_num)
return result; return result;
} }
U8 *TSLinkCvt1(U8 *link_st) U8 *TOSLinkCvt1(U8 *link_st)
{ {
static CDoc *bible=NULL; static CDoc *bible=NULL;
static I64 locks=0; static I64 locks=0;
@@ -85,7 +85,7 @@ U8 *TSLinkCvt1(U8 *link_st)
case LK_FILE_LINE: case LK_FILE_LINE:
case LK_PLAIN_LINE: case LK_PLAIN_LINE:
case LK_FILE: case LK_FILE:
result=TSLinkCvt2(filename,num); result=TOSLinkCvt2(filename,num);
break; break;
case -1: case -1:
case LK_DEF: case LK_DEF:
@@ -101,12 +101,12 @@ U8 *TSLinkCvt1(U8 *link_st)
if (!bible) if (!bible)
bible=Adam("DocRead(\"%s\");",filename); bible=Adam("DocRead(\"%s\");",filename);
if (DocFind(bible,num,needle)) if (DocFind(bible,num,needle))
result=TSLinkCvt2(filename,bible->cur_entry->y+1); result=TOSLinkCvt2(filename,bible->cur_entry->y+1);
LBtr(&locks,0); LBtr(&locks,0);
break; break;
default: default:
if (DocFileEd(i,filename,needle,&num,EDF_UNCOLLAPSE|EDF_BAIL)) if (DocFileEd(i,filename,needle,&num,EDF_UNCOLLAPSE|EDF_BAIL))
result=TSLinkCvt2(filename,num); result=TOSLinkCvt2(filename,num);
} }
Free(filename); Free(filename);
Free(needle); Free(needle);
@@ -117,7 +117,7 @@ U8 *TSLinkCvt1(U8 *link_st)
public CDoc *Doc2Html(CDoc *doc_in, public CDoc *Doc2Html(CDoc *doc_in,
U8 *html_header=NULL, U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,Bool line_anchors=TRUE, U8 *body_header=NULL,U8 *body_footer=NULL,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TSLinkCvt1) U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1)
{//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ doc to HTML file. {//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ doc to HTML file.
CDocEntry *doc_e,*style,*doc_e2; CDocEntry *doc_e,*style,*doc_e2;
I64 i,y,old_y=MIN_I64,col,_old_u32_attr=-1,old_attr; I64 i,y,old_y=MIN_I64,col,_old_u32_attr=-1,old_attr;
@@ -279,14 +279,14 @@ public CDoc *Doc2Html(CDoc *doc_in,
#help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)" #help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)"
public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL, public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,I64 width=80, U8 *body_header=NULL,U8 *body_footer=NULL,I64 width=80,
Bool line_anchors=TRUE,U8 (*link_cvt)(U8 *link_st)=&TSLinkCvt1) Bool line_anchors=TRUE,U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1)
{//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ file to HTML. {//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ file to HTML.
//Supply your own link_cvt routine. //Supply your own link_cvt routine.
U8 *in_name,*out_name; U8 *in_name,*out_name;
CDoc *doc_in,*doc_out; CDoc *doc_in,*doc_out;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
SetWinHorz(0,width-1); //Sets doc width for word wrap. WinHorz(0,width-1); //Sets doc width for word wrap.
in_name=DftExt(_in_name,"CPP.Z"), in_name=DftExt(_in_name,"CPP.Z"),
if (_out_name) if (_out_name)
+1 -1
View File
@@ -108,7 +108,7 @@ public U0 ToTXT(U8 *_in_name,U8 *_out_name=NULL,I64 width=70)
CDoc *doc_in,*doc_out; CDoc *doc_in,*doc_out;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
SetWinHorz(0,width-1); //Sets doc width for word wrap. WinHorz(0,width-1); //Sets doc width for word wrap.
in_name=DftExt(_in_name,"TXT.Z"), in_name=DftExt(_in_name,"TXT.Z"),
if (_out_name) if (_out_name)
-416
View File
@@ -1,416 +0,0 @@
#help_index "Memory/Blk Pool"
public I64 UnusedBPMem(CBlkPool *bp)
{//Count of unused bytes in bp.
I64 result=0,i;
CMemBlk *tempm;
if (!bp) return 0;
PUSHFD
CLI
while (LBts(&bp->locked_flags,BPlf_LOCKED))
PAUSE
tempm=bp->mem_free_lst;
while (tempm) {
if (tempm->mb_signature!=MBS_UNUSED_SIGNATURE_VAL)
Dbg("Corrupt Sys Memory");
result+=tempm->pages;
tempm=tempm->next;
}
for (i=0;i<FREE_PAGE_HASH_SIZE;i++) {
tempm=bp->free_page_hash[i];
while (tempm) {
if (tempm->mb_signature!=MBS_UNUSED_SIGNATURE_VAL)
Dbg("Corrupt Sys Memory");
result+=tempm->pages;
tempm=tempm->next;
}
}
for (i=0;i<64-PAGE_BITS;i++) {
tempm=bp->free_page_hash2[i];
while (tempm) {
if (tempm->mb_signature!=MBS_UNUSED_SIGNATURE_VAL)
Dbg("Corrupt Sys Memory");
result+=tempm->pages;
tempm=tempm->next;
}
}
LBtr(&bp->locked_flags,BPlf_LOCKED);
POPFD
return result*PAGE_SIZE;
}
#help_index "Memory/Heap Ctrl"
I64 MemBlkLstSize(CHeapCtrl *hc)
{
CMemBlk *m;
I64 result=0;
m=hc->next_mem_blk;
while (m!=&hc->next_mem_blk) {
result+=sizeof(CMemBlk);
m=m->next;
}
return result;
}
public I64 UnusedHCMem(CHeapCtrl *hc)
{//Unused bytes alloced to a heap ctrl.
I64 result,i;
CMemUnusedAllocated *u;
if (!hc) return 0;
result=UnusedBPMem(hc->bp);
PUSHFD
CLI
while (LBts(&hc->locked_flags,HClf_LOCKED))
PAUSE
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
u=hc->heap_hash[i];
while (u) {
result+=u->size;
u=u->next;
}
}
u=hc->malloc_free_lst;
while (u) {
result+=u->size;
u=u->next;
}
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return result;
}
#help_index "Memory/Task"
public I64 TaskAllocatedMem(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task, used+unused.
CMemBlk *m,*m1;
I64 result=0;
if (!task) task=Fs;
if (!override_validate && !TaskValidate(task)) return 0;
PUSHFD
CLI
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->code_heap!=task->data_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
m=task->code_heap->next_mem_blk;
m1=&task->code_heap->next_mem_blk;
while (m!=m1) {
if (m->mb_signature!=MBS_USED_SIGNATURE_VAL)
Dbg("Corrupt Task Memory");
result+=m->pages*PAGE_SIZE;
m=m->next;
}
if (task->code_heap!=task->data_heap) {
m=task->data_heap->next_mem_blk;
m1=&task->data_heap->next_mem_blk;
while (m!=m1) {
if (m->mb_signature!=MBS_USED_SIGNATURE_VAL)
Dbg("Corrupt Task Memory");
result+=m->pages*PAGE_SIZE;
m=m->next;
}
}
if (task->code_heap!=task->data_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
return result;
}
public I64 TaskUnusedAllocatedMem(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task but unused.
I64 result=0,i;
CMemUnusedAllocated *uum;
if (!task) task=Fs;
if (!override_validate && !TaskValidate(task)) return 0;
PUSHFD
CLI
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->data_heap!=task->code_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
result+=MemBlkLstSize(task->code_heap);
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
uum=task->code_heap->heap_hash[i];
while (uum) {
result+=uum->size;
uum=uum->next;
}
}
uum=task->code_heap->malloc_free_lst;
while (uum) {
result+=uum->size;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
result+=MemBlkLstSize(task->data_heap);
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
uum=task->data_heap->heap_hash[i];
while (uum) {
result+=uum->size;
uum=uum->next;
}
}
uum=task->data_heap->malloc_free_lst;
while (uum) {
result+=uum->size;
uum=uum->next;
}
}
if (task->data_heap!=task->code_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
return result;
}
public I64 TaskUsedMem(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task and in use.
I64 result=0;
if (!task) task=Fs;
if (!override_validate && !TaskValidate(task)) return 0;
result=task->code_heap->used_u8s;
if (task->data_heap!=task->code_heap)
result+=task->data_heap->used_u8s;
return result;
}
public Bool HeapRep(CTask *task)
{//Report status of task's heap.
I64 i,cnt;
CMemUnusedAllocated *uum;
if (!task || task==Fs) {
"Task can't HeapRep on self.\n";
return FALSE;
}
if (!TaskValidate(task)) return FALSE;
PUSHFD
CLI
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->data_heap!=task->code_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
cnt=0;
uum=task->code_heap->heap_hash[i];
while (uum) {
cnt+=uum->size;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->heap_hash[i];
while (uum) {
cnt+=uum->size;
uum=uum->next;
}
}
if (cnt)
"%03X:%08X\n",i<<3,cnt;
}
'\n';
uum=task->code_heap->malloc_free_lst;
while (uum) {
"%X, ",uum->size;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->malloc_free_lst;
while (uum) {
"%X, ",uum->size;
uum=uum->next;
}
}
if (task->data_heap!=task->code_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
'\n';
}
#help_index "Memory/Task;Debugging/Heap"
public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
{//Check addr if on heap.
CMemBlk *m;
if (!task) task=Fs;
if (!TaskValidate(task)) return FALSE;
PUSHFD
CLI
if (lock) {
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->data_heap!=task->code_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
}
m=task->code_heap->next_mem_blk;
while (m!=&task->code_heap->next_mem_blk) {
if (a>=m && a<m(U8 *)+m->pages*PAGE_SIZE) {
if (lock)
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
return TRUE;
}
m=m->next;
}
if (task->data_heap!=task->code_heap) {
m=task->data_heap->next_mem_blk;
while (m!=&task->code_heap->next_mem_blk) {
if (a>=m && a<m(U8 *)+m->pages*PAGE_SIZE) {
if (lock)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
POPFD
return TRUE;
}
m=m->next;
}
}
if (lock) {
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
if (task->data_heap!=task->code_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
}
POPFD
return FALSE;
}
public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heap.
I64 i;
CMemUnusedAllocated *uum;
Bool result=TRUE;
if (!task) task=Fs;
if (!TaskValidate(task)) return FALSE;
PUSHFD
CLI
while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
PAUSE
if (task->data_heap!=task->code_heap)
while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
PAUSE
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
uum=task->code_heap->heap_hash[i];
while (uum) {
if (!IsInHeap(uum,task,FALSE))
result=FALSE;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->heap_hash[i];
while (uum) {
if (!IsInHeap(uum,task,FALSE))
result=FALSE;
uum=uum->next;
}
}
}
uum=task->code_heap->malloc_free_lst;
while (uum) {
if (!IsInHeap(uum,task,FALSE))
result=FALSE;
uum=uum->next;
}
if (task->data_heap!=task->code_heap) {
uum=task->data_heap->malloc_free_lst;
while (uum) {
if (!IsInHeap(uum,task,FALSE))
result=FALSE;
uum=uum->next;
}
}
#if _CFG_HEAP_DBG
CMemUsedAllocated *um,*um1;
um1=(&task->code_heap->next_um)(U8 *)-offset(CMemUsedAllocated.next);
um=um1->next;
while (um!=um1) {
if (!IsInHeap(um,task,FALSE))
result=FALSE;
um=um->next;
}
if (task->data_heap!=task->code_heap) {
um1=(&task->data_heap->next_um)(U8 *)-offset(CMemUsedAllocated.next);
um=um1->next;
while (um!=um1) {
if (!IsInHeap(um,task,FALSE))
result=FALSE;
um=um->next;
}
}
#endif
if (task->data_heap!=task->code_heap)
LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
POPFD
return result;
}
#help_index "Info;Task"
U0 TaskRepTask(CTask *task,I64 indent)
{
CTask *task1;
U8 *st,*desc=MStrUtil(task->task_title,SUF_SAFE_DOLLAR);
st=MStrPrint("$$MA,T=\"%08X\",LM=\"Kill(0x%X);\n\",$$",task,task,task);
"%h*c%s $$TX,\"%Q...\",SCX=16$$ Mem:%08X\n",indent,CH_SPACE,
st,desc,TaskAllocatedMem(task);
"%h*cFlags:%04X:%04X Time:%0.2fm\n",indent+2,CH_SPACE,
task->task_flags,task->display_flags,
task->total_time/60.0/cnts.time_stamp_freq_initial;
Free(st);
Free(desc);
task1=task->next_child_task;
while (task1!=(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task)) {
TaskRepTask(task1,indent+2);
task1=task1->next_sibling_task;
}
}
public U0 TaskRep()
{//Report current tasks on all cores.
I64 i;
CCPU *c;
PUSHFD
CLI
for (i=0;i<mp_cnt;i++) {
c=&cpu_structs[i];
"$$RED$$CPU:%d$$FG$$\n",i;
TaskRepTask(c->seth_task,2);
}
POPFD
}
Binary file not shown.
+25 -26
View File
@@ -5,9 +5,9 @@ CIPStateGlbls old_ip={IP_NULL,{-1000,-1000,0},{-1000,-1000,0},{-1000,-1000,0},
0,(MAX_I32+1)>>3,0.0,GetTSC,0.350,0,0, 0,(MAX_I32+1)>>3,0.0,GetTSC,0.350,0,0,
FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE}; FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE};
public CWinMgrGlbls winmgr={0,0,0,15,15,NULL,NULL,FALSE,FALSE,FALSE,FALSE}; public CWinMgrGlbls winmgr={0,0,0,WMG_FPS,tS,NULL,NULL,FALSE,FALSE,FALSE};
winmgr.t=CAlloc(sizeof(CWinMgrTimingGlbls)); winmgr.t=CAlloc(sizeof(CWinMgrTimingGlbls));
winmgr.t->last_refresh_time=tS; winmgr.t->last_calc_idle_time=tS;
#define PROGRESS_BAR_HEIGHT 20 #define PROGRESS_BAR_HEIGHT 20
#define PROGRESS_BAR_WIDTH (3*GR_WIDTH/4) #define PROGRESS_BAR_WIDTH (3*GR_WIDTH/4)
@@ -90,7 +90,7 @@ U0 CtrlAltG(I64 sc)
else else
PopUp("WinGrid(TRUE);"); PopUp("WinGrid(TRUE);");
} }
SetCtrlAltLetCB('G',&CtrlAltG,"Sys/Grid On or Off"); CtrlAltLetCBSet('G',&CtrlAltG,"Sys/Grid On or Off");
CTask *ext_ASCII_task; CTask *ext_ASCII_task;
U0 ExtendedASCII() U0 ExtendedASCII()
@@ -99,11 +99,11 @@ U0 ExtendedASCII()
CDoc *doc=DocNew; CDoc *doc=DocNew;
DocPrint(doc,"Select Char and Press <ESC>\n$$LTBLUE$$"); DocPrint(doc,"Select Char and Press <ESC>\n$$LTBLUE$$");
for (i=0;i<256;i++) { for (i=0;i<256;i++) {
if (i>=CH_SHIFT_SPACE && i!=127) { if (i>=CH_SHIFT_SPACE && i!=0x7F) {
if (i==CH_SHIFT_SPACE) if (i==CH_SHIFT_SPACE)
DocPrint(doc,"$$MU-UL,\"\\37\",LE=%d$$",i); DocPrint(doc,"$$MU-UL,\"\\x1F\",LE=%d$$",i);
else if (i=='$$') else if (i=='$$')
DocPrint(doc,"$$MU-UL,\"\\44\",LE=%d$$",i); DocPrint(doc,"$$MU-UL,\"\\x24\",LE=%d$$",i);
else if (i=='\"'||i=='\\') else if (i=='\"'||i=='\\')
DocPrint(doc,"$$MU-UL,\"\\%c\",LE=%d$$",i,i); DocPrint(doc,"$$MU-UL,\"\\%c\",LE=%d$$",i,i);
else else
@@ -124,7 +124,7 @@ U0 CtrlAltA(I64)
if (ext_ASCII_task=sys_focus_task) if (ext_ASCII_task=sys_focus_task)
Spawn(&ExtendedASCII); Spawn(&ExtendedASCII);
} }
SetCtrlAltLetCB('A',&CtrlAltA,"Sys/Extended ASCII"); CtrlAltLetCBSet('A',&CtrlAltA,"Sys/Extended ASCII");
public U0 WinScrollNull(CTask *task,CD3I64 *s) public U0 WinScrollNull(CTask *task,CD3I64 *s)
{//If panning a window has been done, restore to zero. {//If panning a window has been done, restore to zero.
@@ -152,7 +152,7 @@ U0 DrawInputPtr(CDC *dc)
y=ip.pos.y; y=ip.pos.y;
POPFD POPFD
if (ip.show && ip.dev!=IP_NULL) { if (ip.show && ip.dev!=IP_NULL) {
if (!sys_bios_gr_mode) //if text mode if (!Bt(&sys_run_level,RLf_VGA)) //if text mode
gr.text_base[ip.pos_text.x+ip.pos_text.y*TEXT_COLS]^=0x7F00; gr.text_base[ip.pos_text.x+ip.pos_text.y*TEXT_COLS]^=0x7F00;
else { else {
if (gr.fp_draw_input_ptr) { if (gr.fp_draw_input_ptr) {
@@ -223,12 +223,10 @@ U0 WinIPUpdate()
} }
} }
CTask *WinRefocus() public CTask *WinRefocus(CTask *task=NULL)
{ {//Reset the focus task if NULL.
CTask *task;
PUSHFD PUSHFD
CLI CLI
task=sys_focus_task;
if (!task) { if (!task) {
task=sys_winmgr_task->last_task; task=sys_winmgr_task->last_task;
while (TaskValidate(task) && task!=sys_winmgr_task) { while (TaskValidate(task) && task!=sys_winmgr_task) {
@@ -313,18 +311,19 @@ public I64 WinToTop(CTask *task=NULL,Bool update_z_buf=TRUE)
} }
ext[EXT_WIN_TO_TOP]=&WinToTop; ext[EXT_WIN_TO_TOP]=&WinToTop;
public U0 WinFocus(CTask *task=NULL) public CTask *WinFocus(CTask *task=NULL)
{//Set task as focus task. {//Set task as focus task.
PUSHFD PUSHFD
CLI CLI
if (!TaskValidate(task)||Bt(&task->win_inhibit,WIf_SELF_FOCUS)) if (!TaskValidate(task)||Bt(&task->win_inhibit,WIf_SELF_FOCUS))
task=WinRefocus; task=WinRefocus(sys_focus_task);
WinToTop(sys_focus_task=task); WinToTop(sys_focus_task=task);
POPFD POPFD
return sys_focus_task;
} }
ext[EXT_WIN_FOCUS]=&WinFocus; ext[EXT_WIN_FOCUS]=&WinFocus;
public Bool SetWinHorz(I64 left,I64 right,CTask *task=NULL) public Bool WinHorz(I64 left,I64 right,CTask *task=NULL)
{//Set task's win left and right columns. {//Set task's win left and right columns.
I64 d=right-left; I64 d=right-left;
if (!task) task=Fs; if (!task) task=Fs;
@@ -358,7 +357,7 @@ public Bool SetWinHorz(I64 left,I64 right,CTask *task=NULL)
} }
} }
public Bool SetWinVert(I64 top,I64 bottom,CTask *task=NULL) public Bool WinVert(I64 top,I64 bottom,CTask *task=NULL)
{//Set task's win top and bottom rows. {//Set task's win top and bottom rows.
I64 d=bottom-top; I64 d=bottom-top;
if (!task) task=Fs; if (!task) task=Fs;
@@ -419,16 +418,16 @@ public U0 WinTileHorz()
c=4; c=4;
vert_size=(TEXT_ROWS-1)/c; vert_size=(TEXT_ROWS-1)/c;
SetWinHorz(1-no_border,TEXT_COLS-2+no_border,task); WinHorz(1-no_border,TEXT_COLS-2+no_border,task);
SetWinVert((i&3)*vert_size+2-no_border,(i&3+1)*vert_size+no_border,task); WinVert((i&3)*vert_size+2-no_border,(i&3+1)*vert_size+no_border,task);
last_task=task; last_task=task;
if (i&3==3) if (i&3==3)
SetWinVert(task->win_top,TEXT_ROWS-2,task); WinVert(task->win_top,TEXT_ROWS-2,task);
i++; i++;
} }
task=task->last_task; task=task->last_task;
} while (task!=sys_winmgr_task); } while (task!=sys_winmgr_task);
SetWinVert(last_task->win_top,TEXT_ROWS-2,last_task); WinVert(last_task->win_top,TEXT_ROWS-2,last_task);
POPFD POPFD
} }
@@ -457,16 +456,16 @@ public U0 WinTileVert()
else if (c>4) else if (c>4)
c=4; c=4;
horz_size=TEXT_COLS/c; horz_size=TEXT_COLS/c;
SetWinHorz((i&3)*horz_size+1-no_border,(i&3+1)*horz_size-1+no_border,task); WinHorz((i&3)*horz_size+1-no_border,(i&3+1)*horz_size-1+no_border,task);
SetWinVert(2-no_border,TEXT_ROWS-2+no_border,task); WinVert(2-no_border,TEXT_ROWS-2+no_border,task);
last_task=task; last_task=task;
if (i&3==3) if (i&3==3)
SetWinHorz(task->win_left,TEXT_COLS-2,task); WinHorz(task->win_left,TEXT_COLS-2,task);
i++; i++;
} }
task=task->last_task; task=task->last_task;
} while (task!=sys_winmgr_task); } while (task!=sys_winmgr_task);
SetWinHorz(last_task->win_left,TEXT_COLS-2,last_task); WinHorz(last_task->win_left,TEXT_COLS-2,last_task);
POPFD POPFD
} }
@@ -478,8 +477,8 @@ public U0 WinMax(CTask *task=NULL)
PUSHFD PUSHFD
CLI //TODO Multiprocessor safe CLI //TODO Multiprocessor safe
no_border=Bt(&task->display_flags,DISPLAYf_NO_BORDER); no_border=Bt(&task->display_flags,DISPLAYf_NO_BORDER);
SetWinHorz(1-no_border,TEXT_COLS-2+no_border,task); WinHorz(1-no_border,TEXT_COLS-2+no_border,task);
SetWinVert(2-no_border,TEXT_ROWS-2+no_border,task); WinVert(2-no_border,TEXT_ROWS-2+no_border,task);
WinToTop(task); WinToTop(task);
POPFD POPFD
} }
+43 -83
View File
@@ -189,16 +189,14 @@ I64 WinQueIPMsgs(Bool que)
return msg_code; return msg_code;
} }
I64 WinCalcRefreshTimeOut(Bool was_forced) U0 WinCalcIdles()
{ {
F64 d,d1; F64 calc_idle_time;
I64 i,k,total, I64 i,k,total_jiffies,total_jiffies_delta,idle_pt_hits[MP_MAX_PROCESSORS];
total_jiffies,idle_pt_hits[MP_MAX_PROCESSORS];
CCPU *c; CCPU *c;
CWinMgrTimingGlbls *t=winmgr.t; CWinMgrTimingGlbls *t=winmgr.t;
t->refresh_skips++; if ((t->calc_idle_delta_time=(calc_idle_time=tS)-t->last_calc_idle_time)>.25) {
if ((t->refresh_time=tS)-t->last_refresh_time>.25) {
PUSHFD PUSHFD
CLI CLI
total_jiffies=cpu_structs[0].total_jiffies; total_jiffies=cpu_structs[0].total_jiffies;
@@ -206,67 +204,35 @@ I64 WinCalcRefreshTimeOut(Bool was_forced)
idle_pt_hits[i]=cpu_structs[i].idle_pt_hits; idle_pt_hits[i]=cpu_structs[i].idle_pt_hits;
POPFD POPFD
t->refresh_delta_time=t->refresh_time-t->last_refresh_time; total_jiffies_delta=total_jiffies-t->last_total_jiffies;
total=total_jiffies-t->last_total_jiffies;
for (i=0;i<mp_cnt;i++) { for (i=0;i<mp_cnt;i++) {
c=&cpu_structs[i]; c=&cpu_structs[i];
d1=0.01; if (total_jiffies_delta && (k=idle_pt_hits[i]-t->last_idle_pt_hits[i])>=0)
if (t->refresh_delta_time>0) { c->idle_factor=Clamp(ToF64(k)/total_jiffies_delta,0.01,0.99);
if (total) { else
if ((k=idle_pt_hits[i]-t->last_idle_pt_hits[i])>=0) { c->idle_factor=0.01;
d1=ToF64(k)/total;
d=ToF64(k*cnts.time_stamp_freq)
/(JIFFY_FREQ*t->refresh_delta_time);
if (d<d1) d1=d;
}
} else {
if ((k=idle_pt_hits[i]-t->last_idle_pt_hits[i])>=0)
d1=ToF64(k*cnts.time_stamp_freq)
/(JIFFY_FREQ*t->refresh_delta_time);
}
}
t->last_idle_pt_hits[i]=idle_pt_hits[i]; t->last_idle_pt_hits[i]=idle_pt_hits[i];
c->idle_factor=Clamp(d1,0.01,0.99);
} }
t->last_total_jiffies=total_jiffies; t->last_total_jiffies=total_jiffies;
t->last_refresh_time=t->refresh_time; t->last_calc_idle_time=calc_idle_time;
if (!was_forced) { t->calc_idle_cnt++;
if (winmgr.first) {
d=Gs->idle_factor;
d1=(t->last_refresh_end_time-t->last_refresh_start_time)/
(t->refresh_delta_time/t->refresh_skips);
if (d1<0.2)
winmgr.desired_fps*=1.25;
else if (d<=0.0)
winmgr.desired_fps=15.0;
else if (d<0.02) {
d=15.0/winmgr.fps;
winmgr.desired_fps=d*15.0+0.5*(1.0-d)*winmgr.desired_fps;
} else if (d<0.99) {
if (d=(1.0-d)`0.25)
winmgr.desired_fps*= 0.8`0.25/d;
} else
winmgr.desired_fps=30.0;
t->refresh_cnt++;
t->refresh_skips=0;
} else {
winmgr.desired_fps=30.0;
winmgr.first=TRUE;
} }
}
}
winmgr.desired_fps=Clamp(winmgr.desired_fps,15.0,30.0);
return cnts.jiffies+JIFFY_FREQ/winmgr.desired_fps;
} }
I64 WinMgrSleep(Bool flush_msgs=FALSE) I64 WinMgrSleep(Bool flush_msgs=FALSE)
{ {
static Bool was_forced=FALSE;
I64 timeout_val,msg_code=0; I64 timeout_val,msg_code=0;
CCtrl *c; CCtrl *c;
Bool que; Bool que;
F64 t,t_delta;
TimeStampFreqCal; TimeStampFreqCal;
if ((t_delta=(t=tS)-winmgr.last_refresh_tS)>0.01)
winmgr.fps=Max(1.0/t_delta,1);
else
winmgr.fps=99;
winmgr.last_refresh_tS=t;
WinCalcIdles;
if (!flush_msgs && winmgr.old_focus_task!=sys_focus_task) { if (!flush_msgs && winmgr.old_focus_task!=sys_focus_task) {
TaskMsg(winmgr.old_focus_task,0,MSG_FOCUS,FALSE,0,0); TaskMsg(winmgr.old_focus_task,0,MSG_FOCUS,FALSE,0,0);
@@ -293,20 +259,17 @@ I64 WinMgrSleep(Bool flush_msgs=FALSE)
} }
msg_code=WinQueIPMsgs(que); msg_code=WinQueIPMsgs(que);
} else { } else {
WinRefocus; WinRefocus(sys_focus_task);
if (!TaskValidate(sys_focus_task)) if (!TaskValidate(sys_focus_task))
FifoI64Flush(kbd.scan_code_fifo); FifoI64Flush(kbd.scan_code_fifo);
} }
if (sys_focus_task) if (sys_focus_task)
LBtr(&sys_focus_task->task_flags,TASKf_HAS_SONG); LBtr(&sys_focus_task->task_flags,TASKf_HAS_SONG);
timeout_val=WinCalcRefreshTimeOut(was_forced);
WinIPUpdate; WinIPUpdate;
timeout_val=cnts.jiffies+JIFFY_FREQ/WMG_FPS;
LBts(&sys_semas[SYS_SEMA_REFRESH_IN_PROGRESS],0); LBts(&sys_semas[SYS_SEMA_REFRESH_IN_PROGRESS],0);
winmgr.t->last_refresh_start_time=tS;
GrUpdateScreen; GrUpdateScreen;
winmgr.t->last_refresh_end_time=tS;
LBtr(&sys_semas[SYS_SEMA_REFRESH_IN_PROGRESS],0); LBtr(&sys_semas[SYS_SEMA_REFRESH_IN_PROGRESS],0);
if (sys_focus_task && !Bt(&sys_focus_task->task_flags,TASKf_HAS_SONG)) { if (sys_focus_task && !Bt(&sys_focus_task->task_flags,TASKf_HAS_SONG)) {
@@ -322,17 +285,17 @@ I64 WinMgrSleep(Bool flush_msgs=FALSE)
} }
winmgr.updates++; winmgr.updates++;
if (!mouse.install_attempts) if (!mouse.install_attempts)
SleepUntil(timeout_val); SleepUntil(timeout_val); //Just for before mouse install attempt at boot.
else else
do { do {
KbdMouseHandler(FALSE,TRUE); KbdMouseHandler(FALSE,TRUE);
SleepUntil(MinI64(timeout_val,cnts.jiffies+JIFFY_FREQ/500)); SleepUntil(MinI64(timeout_val,cnts.jiffies+JIFFY_FREQ/500));
} while (!Bt(&sys_semas[SYS_SEMA_FORCE_WINMGR],0)&&cnts.jiffies<timeout_val); } while (cnts.jiffies<timeout_val && !Bt(&sys_semas[SYS_SEMA_FORCE_WINMGR],0));
was_forced=LBtr(&sys_semas[SYS_SEMA_FORCE_WINMGR],0); LBtr(&sys_semas[SYS_SEMA_FORCE_WINMGR],0);
return msg_code; return msg_code;
} }
CDoc *SetCursorPos(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE) CDoc *WinCursorPosSet(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE)
{ {
CDoc *result=NULL; CDoc *result=NULL;
Bool unlock; Bool unlock;
@@ -368,10 +331,8 @@ CDoc *SetCursorPos(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE)
U0 WinChkMoveSize(CTask *task) U0 WinChkMoveSize(CTask *task)
{ {
if (task->win_left!=task->win_old_left || if (task->win_left!=task->win_old_left || task->win_top!=task->win_old_top)
task->win_top!=task->win_old_top) TaskMsg(task,0,MSG_MOVE,task->win_left,task->win_top,0);
TaskMsg(task,0,
MSG_MOVE,task->win_left,task->win_top,0);
if (task->win_right-task->win_left!=task->win_old_right-task->win_old_left || if (task->win_right-task->win_left!=task->win_old_right-task->win_old_left ||
task->win_bottom-task->win_top!=task->win_old_bottom-task->win_old_top) task->win_bottom-task->win_top!=task->win_old_bottom-task->win_old_top)
TaskMsg(task,0, TaskMsg(task,0,
@@ -389,13 +350,12 @@ Bool WinKeyNavMenu()
CMenu *m; CMenu *m;
CMenuEntry *tempme; CMenuEntry *tempme;
CTask *focus=MenuTask; CTask *focus=MenuTask;
if (Bt(kbd.down_bitmap,SC_GUI) && if (Bt(kbd.down_bitmap,SC_GUI) && focus && (m=focus->cur_menu)) {
focus && (m=focus->cur_menu)) {
winmgr.show_menu=TRUE; winmgr.show_menu=TRUE;
sys_cur_submenu_entry=NULL; sys_cur_submenu_entry=NULL;
old_pos.x=ip.pos.x; old_pos.y=ip.pos.y; old_pos.x=ip.pos.x; old_pos.y=ip.pos.y;
ip.pos.x=new_pos.x=ip.pos.y=new_pos.y=0; ip.pos.x=new_pos.x=ip.pos.y=new_pos.y=0;
while (m->mu_signature==MENU_SIGNATURE_VAL && Bt(kbd.down_bitmap,SC_GUI)) { while (Bt(kbd.down_bitmap,SC_GUI)) {
old_key_cnt=kbd.cnt; old_key_cnt=kbd.cnt;
if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT)) { if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT)) {
while (Bt(kbd.down_bitmap,SC_CURSOR_LEFT) && kbd.cnt==old_key_cnt) while (Bt(kbd.down_bitmap,SC_CURSOR_LEFT) && kbd.cnt==old_key_cnt)
@@ -466,8 +426,8 @@ U0 WinMgrTask(I64)
old_flags=GetRFlags; old_flags=GetRFlags;
Bool has_border; Bool has_border;
CCtrl *c; CCtrl *c;
SetWinHorz(0,TEXT_COLS-1); WinHorz(0,TEXT_COLS-1);
SetWinVert(0,TEXT_ROWS-1); WinVert(0,TEXT_ROWS-1);
LBts(&Fs->display_flags,DISPLAYf_NO_BORDER); LBts(&Fs->display_flags,DISPLAYf_NO_BORDER);
LBts(&Fs->display_flags,DISPLAYf_SHOW); LBts(&Fs->display_flags,DISPLAYf_SHOW);
gr.dc->win_task=Fs; gr.dc->win_task=Fs;
@@ -703,7 +663,7 @@ wmt_start:
if (!Bt(&task->win_inhibit,WIf_SELF_IP_L)&& if (!Bt(&task->win_inhibit,WIf_SELF_IP_L)&&
(!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_L))) { (!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_L))) {
if (!old_ip.lb && ip.lb) { if (!old_ip.lb && ip.lb) {
if (doc=SetCursorPos(task,ip.pos_text.x,ip.pos_text.y)) { if (doc=WinCursorPosSet(task,ip.pos_text.x,ip.pos_text.y)) {
DocLock(doc); DocLock(doc);
if (doc->doc_signature==DOC_SIGNATURE_VAL) { if (doc->doc_signature==DOC_SIGNATURE_VAL) {
doc_e=doc->cur_entry; doc_e=doc->cur_entry;
@@ -721,7 +681,7 @@ wmt_start:
if (!Bt(&task->win_inhibit,WIf_SELF_IP_R)&& if (!Bt(&task->win_inhibit,WIf_SELF_IP_R)&&
(!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_R))) { (!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_R))) {
if (!old_ip.rb && ip.rb) { if (!old_ip.rb && ip.rb) {
if (SetCursorPos(task,ip.pos_text.x,ip.pos_text.y)) { if (WinCursorPosSet(task,ip.pos_text.x,ip.pos_text.y)) {
old_ip.rb=TRUE; old_ip.rb=TRUE;
goto wmt_start; goto wmt_start;
} }
@@ -749,7 +709,7 @@ wmt_start:
if (!Bt(&task->win_inhibit,WIf_SELF_IP_L)&& if (!Bt(&task->win_inhibit,WIf_SELF_IP_L)&&
(!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_L))) { (!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_L))) {
if (old_ip.lb && !ip.lb) { if (old_ip.lb && !ip.lb) {
if (doc=SetCursorPos(task,ip.pos_text.x,ip.pos_text.y,FALSE)) { if (doc=WinCursorPosSet(task,ip.pos_text.x,ip.pos_text.y,FALSE)) {
do msg_code=WinMgrSleep; do msg_code=WinMgrSleep;
while (TaskValidate(task) && while (TaskValidate(task) &&
(ip.lb || ip.left_dbl_time)); (ip.lb || ip.left_dbl_time));
@@ -783,7 +743,7 @@ wmt_start:
if (!Bt(&task->win_inhibit,WIf_SELF_IP_R)&& if (!Bt(&task->win_inhibit,WIf_SELF_IP_R)&&
(!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_R))) { (!TaskValidate(sys_focus_task)||!Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_IP_R))) {
if (old_ip.rb && !ip.rb) { if (old_ip.rb && !ip.rb) {
if (doc=SetCursorPos(task,ip.pos_text.x,ip.pos_text.y,FALSE)) { if (doc=WinCursorPosSet(task,ip.pos_text.x,ip.pos_text.y,FALSE)) {
do msg_code=WinMgrSleep; do msg_code=WinMgrSleep;
while (TaskValidate(task) && while (TaskValidate(task) &&
(ip.rb || ip.right_dbl_time)); (ip.rb || ip.right_dbl_time));
@@ -829,8 +789,8 @@ wmt_start:
if (ip.lb) { if (ip.lb) {
WinToTop(task); WinToTop(task);
while (ip.lb && TaskValidate(task)) { while (ip.lb && TaskValidate(task)) {
SetWinHorz(ip.pos_text.x-x,task->win_width-1+ip.pos_text.x-x,task); WinHorz(ip.pos_text.x-x,task->win_width-1+ip.pos_text.x-x,task);
SetWinVert(ip.pos_text.y+1,task->win_height+ip.pos_text.y,task); WinVert(ip.pos_text.y+1,task->win_height+ip.pos_text.y,task);
WinChkMoveSize(task); WinChkMoveSize(task);
WinMgrSleep; WinMgrSleep;
} }
@@ -844,8 +804,8 @@ wmt_start:
if (ip.lb) { if (ip.lb) {
WinToTop(task); WinToTop(task);
while (ip.lb && TaskValidate(task)) { while (ip.lb && TaskValidate(task)) {
SetWinHorz(ip.pos_text.x+1,task->win_width+ip.pos_text.x,task); WinHorz(ip.pos_text.x+1,task->win_width+ip.pos_text.x,task);
SetWinVert(ip.pos_text.y-y,task->win_height-1+ip.pos_text.y-y,task); WinVert(ip.pos_text.y-y,task->win_height-1+ip.pos_text.y-y,task);
WinChkMoveSize(task); WinChkMoveSize(task);
WinMgrSleep; WinMgrSleep;
} }
@@ -857,8 +817,8 @@ wmt_start:
if (ip.lb) { if (ip.lb) {
WinToTop(task); WinToTop(task);
while (ip.lb && TaskValidate(task)) { while (ip.lb && TaskValidate(task)) {
SetWinHorz(task->win_left,ip.pos_text.x-1,task); WinHorz(task->win_left,ip.pos_text.x-1,task);
SetWinVert(task->win_top,ip.pos_text.y-1,task); WinVert(task->win_top,ip.pos_text.y-1,task);
WinChkMoveSize(task); WinChkMoveSize(task);
WinMgrSleep; WinMgrSleep;
} }
@@ -871,7 +831,7 @@ wmt_start:
if (ip.lb) { if (ip.lb) {
WinToTop(task); WinToTop(task);
while (ip.lb && TaskValidate(task)) { while (ip.lb && TaskValidate(task)) {
SetWinVert(task->win_top,ip.pos_text.y-1,task); WinVert(task->win_top,ip.pos_text.y-1,task);
WinChkMoveSize(task); WinChkMoveSize(task);
WinMgrSleep; WinMgrSleep;
} }
@@ -884,7 +844,7 @@ wmt_start:
if (ip.lb) { if (ip.lb) {
WinToTop(task); WinToTop(task);
while (ip.lb && TaskValidate(task)) { while (ip.lb && TaskValidate(task)) {
SetWinHorz(task->win_left,ip.pos_text.x-1,task); WinHorz(task->win_left,ip.pos_text.x-1,task);
WinChkMoveSize(task); WinChkMoveSize(task);
WinMgrSleep; WinMgrSleep;
} }
-688
View File
@@ -1,688 +0,0 @@
#help_index "WordStat"
CHashWS *WSHashAdd(U8 *w)
{
CHashWS *tempw=HashFind(w,ws.hash_table,HTT_WORD);
if (tempw) {
tempw->hits++;
return tempw;
}
tempw=ACAlloc(sizeof(CHashWS));
tempw->str=AStrNew(w);
tempw->type=HTT_WORD;
tempw->use_cnt=1;
tempw->hits=1;
tempw->num=-1;
HashAdd(tempw,ws.hash_table);
ws.num_words++;
return tempw;
}
U0 WSSidesInit(CWSMatrix *m)
{
I64 i;
CWS *tempa;
m->n=0;
for (i=0;i<WS_MAX_MATRIX_WORDS;i++) {
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(CWS));
ws.structs_size+=MSize2(tempa);
tempa->subs[0].hits=0;
tempa->subs[0].repeats=ws.num_matrix_words;
tempa->entries=ws.num_matrix_words;
tempa->substructs=1;
QueIns(tempa,m->side[i].last);
}
}
CWS *WSStructFind(CWSMatrix *m,I64 col,I64 row,
I64 *_row_base,I64 *_substruct)
{
CWS *tempa;
I64 row_base,i,j;
if (row>=ws.num_matrix_words ||
col>=ws.num_matrix_words)
return NULL;
if (row<ws.num_matrix_words>>1) {
tempa=m->side[col].next;
row_base=0;
j=row;
while (row>=(i=tempa->entries)) {
row-=i;
tempa=tempa->next;
}
row_base+=j-row;
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;
j=row;
while (row>(i=tempa->entries)) {
row-=i;
tempa=tempa->last;
}
row_base+=j-row;
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;
}
*_row_base=row_base;
return tempa;
}
public I64 WSHitsGet(CWSMatrix *m,I64 col,I64 row)
{//Look-up markov stats for word followed by word.
I64 row_base,substruct;
CWS *tempa;
if (row>=ws.num_matrix_words ||
col>=ws.num_matrix_words)
return 0;
tempa=WSStructFind(m,col,row,
&row_base,&substruct);
return tempa->subs[substruct].hits;
}
CWSSub *WSNext(CWSSub *s,CWS **_parent)
{
I64 i=(s(U8 *)-(&(*_parent)->subs)(U8 *))/sizeof(CWSSub)+1;
if (i>=(*_parent)->substructs) {
i=0;
*_parent=(*_parent)->next;
if ((*_parent)->substructs==-1)
return NULL;
}
return &(*_parent)->subs[i];
}
CWSSub *WSLast(CWSSub *s,CWS **_parent)
{
I64 i=(s(U8 *)-(&(*_parent)->subs)(U8 *))/sizeof(CWSSub)-1;
if (i<0) {
*_parent=(*_parent)->last;
if ((*_parent)->substructs==-1)
return NULL;
i=(*_parent)->substructs-1;
}
return &(*_parent)->subs[i];
}
U0 WSRem(CWSSub *s,CWS *parent)
{
I64 i=(s(U8 *)-(&parent->subs)(U8 *))/sizeof(CWSSub);
if (i<0 || i>=WS_SUBSTRUCTS_PER_STRUCT || parent->substructs<1)
return;
if (parent->substructs==1) {
QueRem(parent);
ws.structs_size-=MSize2(parent);
Free(parent);
} else {
parent->entries-=s->repeats;
parent->substructs--;
MemCpy(&parent->subs[i],&parent->subs[i+1],
(parent->substructs-i)*sizeof(CWSSub));
}
}
CWSSub *WSIns(CWSSub *s,CWS **_parent,CWSSub *last)
{
CWS *tempa,*parent=*_parent;
I64 j,k,i=(last(U8 *)-(&parent->subs)(U8 *))/sizeof(CWSSub)+1;
if (i>=WS_SUBSTRUCTS_PER_STRUCT) {
i=0;
parent=parent->next;
*_parent=parent;
if (parent->substructs==-1) {
tempa=AMAlloc(sizeof(CWS));
ws.structs_size+=MSize2(tempa);
QueIns(tempa,parent->last);
parent=tempa;
*_parent=parent;
tempa->entries=0;
tempa->substructs=0;
}
}
if (parent->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=parent->next;
if (tempa->substructs==-1 || tempa->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=AMAlloc(sizeof(CWS));
ws.structs_size+=MSize2(tempa);
tempa->entries=0;
tempa->substructs=0;
QueIns(tempa,parent);
k=0;
for (j=i;j<parent->substructs;j++) {
MemCpy(&tempa->subs[k],&parent->subs[j],sizeof(CWSSub));
tempa->entries+=tempa->subs[k++].repeats;
tempa->substructs++;
}
parent->entries-=tempa->entries;
parent->substructs-=tempa->substructs;
} else {
for (j=tempa->substructs-1;j>=0;j--)
MemCpy(&tempa->subs[j+1],&tempa->subs[j],sizeof(CWSSub));
MemCpy(&tempa->subs[0],
&parent->subs[WS_SUBSTRUCTS_PER_STRUCT-1],
sizeof(CWSSub));
parent->entries-=tempa->subs[0].repeats;
parent->substructs--;
tempa->entries+=tempa->subs[0].repeats;
tempa->substructs++;
for (j=WS_SUBSTRUCTS_PER_STRUCT-2;j>=i;j--)
MemCpy(&parent->subs[j+1],
&parent->subs[j],sizeof(CWSSub));
}
} else {
for (j=parent->substructs-1;j>=i;j--)
MemCpy(&parent->subs[j+1],
&parent->subs[j],sizeof(CWSSub));
}
parent->entries+=s->repeats;
parent->substructs++;
MemCpy(&parent->subs[i],s,sizeof(CWSSub));
return &parent->subs[i];
}
CWSSub *WSCondense(CWSSub *s,CWS **_parent)
{
CWSSub *temps,*temps_l,*temps_n;
CWS *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;
WSRem(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;
WSRem(temps_n,tempa_n);
}
return temps;
}
I64 WSHitsInc(CWSMatrix *m,I64 col,I64 row)
{
I64 row_base,substruct,repeats;
CWSSub sn,*temps,*temps1,*temps_l;
CWS *tempa,*tempa1,*tempa_l;
if (row>=ws.num_matrix_words ||
col>=ws.num_matrix_words)
return 0;
tempa=WSStructFind(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=WSIns(&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=WSIns(&sn,&tempa,temps);
temps=WSCondense(temps,&tempa);
} else {
tempa->entries-=repeats;
sn.hits=temps->hits+1;
sn.repeats=1;
tempa1=tempa;
temps1=temps;
temps=WSIns(&sn,&tempa1,temps1);
temps1->repeats=row-row_base;
tempa->entries+=temps1->repeats;
sn.repeats=row_base+repeats-(row+1);
sn.hits=temps1->hits;
WSIns(&sn,&tempa1,temps);
}
}
m->n++;
m->side[col].col_hits++;
m->side[row].row_hits++;
return temps->hits;
}
U0 WSSingleFileAdd(U8 *buf,I64 pass)
{
I64 ch;
U8 *ptr=buf,*ptr2,*ptr3;
CHashWS *cur_ptr,*last_ptr=NULL;
while (TRUE) {
while (TRUE) {
if (ch=*ptr++) {
if (Bt(chars_bitmap_alpha_numeric,ch))
break;
} else
return;
}
ptr3=ptr;
ptr2=ptr;
ptr--;
while (TRUE) {
if (ch=*ptr2++) {
if (Bt(chars_bitmap_alpha_numeric,ch))
*ptr3++=ch;
else if (ch!=CH_CURSOR)
break;
} else {
ptr2--;
break;
}
}
*ptr3=0;
if (pass==1)
WSHashAdd(ptr);
else {
cur_ptr=HashFind(ptr,ws.hash_table,HTT_WORD);
if (cur_ptr->num<0)
cur_ptr=NULL;
else
if (last_ptr)
WSHitsInc(ws.matrix,last_ptr->num,cur_ptr->num);
last_ptr=cur_ptr;
}
ptr=ptr2;
}
}
I64 WSCompare(CHashWS *e1,CHashWS *e2)
{
I64 r;
if (!(r=e2->hits - e1->hits))
r=StrCmp(e1->str,e2->str);
return r;
}
I64 WSSkipCrap(U8 *src,I64 len)
{
I64 j;
j=len-1;
while (j>=0) {
if (Bt(chars_bitmap_alpha_numeric,src[j]))
break;
else
j--;
}
return j+1;
}
I64 WSPriorWordInStr(U8 *src,U8 *dst,I64 len,I64 buf_size)
{
I64 i,j=0,k;
Bool cont=TRUE;
i=len-1;
while (i>=0 && cont) {
if (!Bt(chars_bitmap_alpha_numeric,src[i]))
cont=FALSE;
else
i--;
}
if (i>=-1 && len>0)
for (k=i+1;k<len && j<buf_size-1;k++)
dst[j++]=src[k];
dst[j]=0;
return i+1;
}
Bool WSPartialMatch(U8 *partial,U8 *complete)
{
I64 i,l=StrLen(partial);
for (i=0;i<l;i++)
if (partial[i]!=complete[i])
return FALSE;
return TRUE;
}
U0 WSFillIn(I64 n)
{
U8 *s;
I64 len;
if (0<=--n<ws.num_fillins) {
s=ws.sorted_words[ws.fillin_matches[n]]->str;
len=StrLen(s);
if (len>ws.partial_len)
Auto(s+ws.partial_len);
}
}
U0 WSMan(I64 n,CTask *parent_task=NULL)
{
CHashWS *tempw;
CHashSrcSym *temph;
Bool old_preempt=Preempt(OFF);
if (0<=--n<ws.num_fillins && (tempw=ws.sorted_words[ws.fillin_matches[n]]) &&
(temph=HashFind(tempw->str,Fs->hash_table,HTG_SRC_SYM)) &&
temph->src_link) {
Preempt(old_preempt);
PopUpEd(temph->src_link,parent_task);
}
Preempt(old_preempt);
}
U0 WSFillInAdd(I64 i,I64 j,I64 old_num_fillins)
{
Bool cont;
I64 k;
if (ws.num_fillins<WS_MAX_FILLINS || i>ws.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_fillins<WS_MAX_FILLINS)
ws.num_fillins++;
ws.fillin_scores[k+1]=i;
ws.fillin_hits[k+1]=ws.sorted_words[j]->hits;
ws.fillin_matches[k+1]=j;
}
}
U0 WSPutChoices(CDoc *focus_l,CDocEntry *doc_e,CTask *focus_task)
{
I64 i,j,k,data_col;
U8 ch=0,*buf,*buf1,*src=NULL,*st;
CHashWS *w2;
F64 timeout_time=tS+0.5;
CHashSrcSym *temph;
CDoc *doc=DocPut;
src=DocScanLine(focus_l,doc_e,&data_col);
DocUnlock(focus_l);
i=StrLen(src);
buf =MAlloc(MaxI64(i+1,256));
buf1=MAlloc(MaxI64(i+1,256));
if (data_col==-1)
data_col=0;
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 && !StrCmp(ws.cur_word,buf))
goto pc_done;
st=ws.cur_word;
ws.cur_word=AStrNew(buf);
Free(st);
Preempt(ON);
if (StrLen(buf1)&&ws.hash_table)
w2=HashFind(buf1,ws.hash_table,HTT_WORD);
else
w2=NULL;
ws.num_fillins=0;
if (w2 && w2->num<ws.num_matrix_words)
for (j=0;j<ws.num_matrix_words && tS<timeout_time;j++)
if (WSPartialMatch(ws.cur_word,ws.sorted_words[j]->str)) {
i=WSHitsGet(ws.matrix,w2->num,ws.sorted_words[j]->num);
WSFillInAdd(i,j,0);
}
k=ws.num_fillins;
for (j=0;j<ws.num_words && tS<timeout_time;j++)
if (WSPartialMatch(ws.cur_word,ws.sorted_words[j]->str))
WSFillInAdd(0,j,k);
Preempt(OFF);
pc_done:
DocRst(doc,TRUE);
doc->flags|=DOCF_MIN_SIZE;
DocCursor;
Fs->text_attr=LTBLUE<<4+WHITE;
Fs->border_src =BDS_CONST;
Fs->border_attr=LTBLUE<<4+BLACK;
DocPrint(doc,"Word:%s\n",ws.cur_word);
for (i=0;i<ws.num_fillins;i++) {
st=ws.sorted_words[ws.fillin_matches[i]]->str;
ch=CH_SPACE;
DocPrint(doc,"F%02d ",i+1);
if (TaskValidate(focus_task) &&
(temph=HashFind(st,focus_task->hash_table,HTG_SRC_SYM)) &&
temph->src_link) {
if (temph->type&HTF_PUBLIC)
DocPrint(doc,"$$RED$$");
DocPrint(doc,"$$TX+UL+L+PU,\"%Q\",A=\"%s\"$$$$FG$$\n",st,temph->src_link);
} else
DocPrint(doc,"%s\n",st);
}
if (wsd.has_words)
WSDDictWordsAdd(doc);
DocRecalc(doc);
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
WinZBufUpdate;
Free(src);
Free(buf);
Free(buf1);
}
U0 WSTask(I64)
{
CTask *focus_task,*original_focus_task;
CDoc *doc;
CDocEntry *doc_e;
I64 ch;
DocTermNew;
SetWinHorz(51,Fs->win_right);
LBts(&Fs->display_flags,DISPLAYf_WIN_ON_TOP);
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER-WIF_SELF_IP_L-WIF_SELF_IP_R-WIG_DBL_CLICK;
while (TRUE) {
if (Bt(&ws.flags,WSf_ENABLE)) {
original_focus_task=focus_task=sys_focus_task;
while (TaskValidate(focus_task) && Bt(&focus_task->task_flags,TASKf_INPUT_FILTER_TASK))
focus_task=focus_task->parent_task;
if (TaskValidate(focus_task) && (doc=DocPut(focus_task)) &&
focus_task!=Fs && Bt(&focus_task->display_flags,DISPLAYf_SHOW)) {
DocLock(doc);
if (TaskValidate(focus_task) && original_focus_task==sys_focus_task &&
doc && doc==DocPut(focus_task) && (doc_e=doc->cur_entry)) {
if (doc_e==doc) doc_e=doc_e->last;
while (doc_e->last!=doc && (doc_e->type_u8==DOCT_NEW_LINE ||
doc_e->type_u8==DOCT_SOFT_NEW_LINE))
doc_e=doc_e->last;
while (doc_e->last->type_u8 !=DOCT_NEW_LINE && doc_e->last!=doc)
doc_e=doc_e->last;
if (Bt(&ws.flags,WSf_ENABLE))
WSPutChoices(doc,doc_e,focus_task);
else
DocUnlock(doc);
} else
DocUnlock(doc);
}
}
Sleep(333);
if (ScanMsg(&ch,,1<<MSG_KEY_DOWN) && (ch==CH_ESC||ch==CH_SHIFT_ESC))
break;
doc=DocPut;
DocLock(doc);
if (doc->cur_entry!=doc && doc->cur_entry->de_flags & DOCEF_LINK)
'' CH_SPACE;
DocUnlock(doc);
}
ws.task=NULL;
}
U0 WSMainFileLstTraverse(U8 *files_find_mask,I64 pass)
{
U8 *buf;
CDirEntry *tempde,*tempde1;
try {
tempde=tempde1=FilesFind(files_find_mask,FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES|FUF_CLUSTER_ORDER);
while (tempde) {
"%s\n",tempde->full_name;
buf=FileRead(tempde->full_name);
WSSingleFileAdd(buf,pass);
Free(buf);
tempde=tempde->next;
}
} catch
Fs->catch_except=TRUE;
DirTreeDel(tempde1);
}
U0 WSMatrixDel(CWSMatrix *m)
{
I64 i;
CWS *tempw,*tempw1,*tempw2;
if (!m) return;
for (i=0;i<WS_MAX_MATRIX_WORDS;i++) {
tempw1=&m->side[i];
tempw=tempw1->next;
while (tempw!=tempw1) {
tempw2=tempw->next;
Free(tempw);
tempw=tempw2;
}
}
Free(m);
}
public Bool WordStat(Bool val=OFF)
{//Turn WordStat OFF (or ON).
Bool old_wordstat=FALSE,
old_preempt=Preempt(OFF);
if (val) {
while (Bt(&ws.flags,WSf_INIT_IN_PROGRESS))
Sleep(10);
if (TaskValidate(ws.task))
old_wordstat=TRUE;
else {
ws.task=Spawn(&WSTask,NULL,"WordStat");
TaskWait(ws.task);
}
if (!LBts(&ws.flags,WSf_ENABLE))
WinToTop(ws.task);
} else {
LBtr(&ws.flags,WSf_ENABLE);
if (TaskValidate(ws.task)) {
old_wordstat=TRUE;
Kill(ws.task);
while (TaskValidate(ws.task))
Yield;
ws.task=NULL;
}
}
Preempt(old_preempt);
return old_wordstat;
}
U0 WSProgressTask(Bool *_start_flag)
{
I64 start=dsk.write_cnt;
progress1=0;
progress1_max=(Size(WSD_DEF_FILENAME_Z,"+x+s")+BLK_SIZE-1)>>BLK_SIZE_BITS;
StrCpy(progress1_desc,"Uncompressing Dictionary");
start=dsk.write_cnt;
*_start_flag=TRUE;
while (progress1<progress1_max) {
progress1=dsk.write_cnt-start;
Sleep(10);
}
*progress1_desc=progress1=progress1_max=0;
}
public U0 WSInit(U8 *mask=NULL)
{//Read files and build WordStat statistics.
I64 i,j=0;
Bool start_flag;
CHashWS *tempw;
CBlkDev *bdev=Drv2BlkDev;
while (LBts(&ws.flags,WSf_INIT_IN_PROGRESS))
Yield;
WordStat;
if (IsDrvWritable && FileFind(WSD_DEF_FILENAME_Z) && !FileFind(WSD_DEF_FILENAME)) {
if (bdev->type!=BDT_RAM) {
start_flag=FALSE;
Spawn(&WSProgressTask,&start_flag);
while (!start_flag)
Yield;
}
Move(WSD_DEF_FILENAME_Z,WSD_DEF_FILENAME);
}
HashTableDel(ws.hash_table);
ws.hash_table=HashTableNew(0x4000,adam_task);
ws.num_words=0;
ws.num_matrix_words=0;
ws.structs_size=0;
Free(ws.cur_word);
ws.cur_word=NULL;
"\n\nPass #1\n";
if (mask) WSMainFileLstTraverse(mask,1);
Free(ws.sorted_words);
ws.sorted_words=AMAlloc(sizeof(U8 *)*ws.num_words);
tempw=ws.hash_table->next_added;
while (tempw!=ws.hash_table) {
ws.sorted_words[j++]=tempw;
tempw=tempw->next_added;
}
QSortI64(ws.sorted_words,ws.num_words,&WSCompare);
for (i=0;i<ws.num_words;i++)
ws.sorted_words[i]->num=i;
if (ws.num_words<=WS_MAX_MATRIX_WORDS)
ws.num_matrix_words=ws.num_words;
else
ws.num_matrix_words=WS_MAX_MATRIX_WORDS;
WSMatrixDel(ws.matrix);
ws.matrix=AMAlloc(sizeof(CWSMatrix));
WSSidesInit(ws.matrix);
"\n\nPass #2\n";
if (mask) WSMainFileLstTraverse(mask,2);
WSDWordsLoad;
LBtr(&ws.flags,WSf_INIT_IN_PROGRESS);
WordStat(ON);
}
I64 WordStatSize()
{
if (ws.hash_table)
return HashTableSize2(ws.hash_table)+ws.structs_size+
MSize2(ws.sorted_words)+MSize2(ws.matrix)+MSize2(wsd.word_lst);
else
return 0;
}
-101
View File
@@ -1,101 +0,0 @@
#help_index "WordStat"
#help_file "::/Doc/WordStat"
//See $LK,"::/Doc/WordStat.TXT"$
class CWSSub
{
I32 hits,repeats;
};
#define WS_SUBSTRUCTS_PER_STRUCT 8
class CWS
{
CWS *next,*last;
I64 substructs, //-1 means CWSMatrixSide
entries;
CWSSub subs[WS_SUBSTRUCTS_PER_STRUCT];
};
class CWSMatrixSide
{
CWS *next,*last;
I64 const_minus_one, //-1 used to header in que
row_hits,col_hits;
};
#define WS_MAX_MATRIX_WORDS 0x8000
class CWSMatrix
{
I64 n;
CWSMatrixSide side[WS_MAX_MATRIX_WORDS];
};
#define WSf_ENABLE 0
#define WSf_INIT_IN_PROGRESS 1
#define WS_MAX_FILLINS 10
public class CWordStatGlbls
{
I64 num_words,num_matrix_words;
CHashTable *hash_table;
U8 *cur_word;
I64 flags;
CWSMatrix *matrix;
CHashWS **sorted_words;
CTask *task;
I64 partial_len,num_fillins,
structs_size,
fillin_matches [WS_MAX_FILLINS+1],
fillin_scores [WS_MAX_FILLINS+1],
fillin_hits [WS_MAX_FILLINS+1];
} ws={0,0,NULL,NULL,0,NULL,NULL,NULL,0,0,0,
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0}};
//Dictionary Stuff
#help_index "WordStat/Dictionary"
#define WSD_WORD_FILENAME "/Adam/WordStat/WSWords.DAT.Z"
#define WSD_DEF_FILENAME "/Adam/WordStat/WSDefs.DAT"
#define WSD_DEF_FILENAME_Z "/Adam/WordStat/WSDefs.DAT.Z"
#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
#define WSD_MAX_FILLINS 10
public class CWordStatDictGlbls
{
U8 *word_lst;
I64 word_lst_size,num_words,num_fillins;
U8 *fillins[WSD_MAX_FILLINS];
Bool has_words,has_defs;
} wsd={NULL,0,0,0,{0,0,0,0,0,0,0,0,0,0},FALSE,FALSE};
wsd.has_words=FileFind(WSD_WORD_FILENAME);
wsd.has_defs =FileFind(WSD_DEF_FILENAME)||FileFind(WSD_DEF_FILENAME_Z);
extern U0 WSDWordsLoad();
extern U0 WSDDictWordsAdd(CDoc *doc,U8 *st=NULL);
#include "WSMain"
#include "WSDict"
@@ -1,7 +1,7 @@
//Change anything you want in this //Place this file in /Home and change
//acct file or others. //anything you want.
U0 FillInTime() U0 InsTime()
{ {
CDate cdt; CDate cdt;
cdt=Now; cdt=Now;
@@ -33,9 +33,9 @@ Bool MyPutKey(I64 ch,I64 sc)
case SC_F1: case SC_F1:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTPURPLE"); KeyDescSet("Dollar/LTPURPLE");
else else
SetKeyDesc("Dollar/PURPLE"); KeyDescSet("Dollar/PURPLE");
} else { } else {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
"$$LTPURPLE$$"; "$$LTPURPLE$$";
@@ -46,9 +46,9 @@ Bool MyPutKey(I64 ch,I64 sc)
case SC_F2: case SC_F2:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTRED"); KeyDescSet("Dollar/LTRED");
else else
SetKeyDesc("Dollar/RED"); KeyDescSet("Dollar/RED");
} else { } else {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
"$$LTRED$$"; "$$LTRED$$";
@@ -59,9 +59,9 @@ Bool MyPutKey(I64 ch,I64 sc)
case SC_F3: case SC_F3:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTGREEN"); KeyDescSet("Dollar/LTGREEN");
else else
SetKeyDesc("Dollar/GREEN"); KeyDescSet("Dollar/GREEN");
} else { } else {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
"$$LTGREEN$$"; "$$LTGREEN$$";
@@ -72,21 +72,21 @@ Bool MyPutKey(I64 ch,I64 sc)
case SC_F4: case SC_F4:
if (sc&SCF_KEY_DESC) { if (sc&SCF_KEY_DESC) {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
SetKeyDesc("Dollar/LTBLUE"); KeyDescSet("Dollar/Default Color");
else else
SetKeyDesc("Dollar/Default Color"); KeyDescSet("Dollar/BLUE");
} else { } else {
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
"$$LTBLUE$$";
else
"$$FG$$"; "$$FG$$";
else
"$$BLUE$$";
} }
break; break;
case SC_F7: case SC_F7:
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Misc/Insert Datetime"); KeyDescSet("Misc/Ins Datetime");
else else
FillInTime; InsTime;
break; break;
} }
return TRUE; return TRUE;
@@ -94,15 +94,28 @@ Bool MyPutKey(I64 ch,I64 sc)
if (!(sc & SCF_CTRL)) { if (!(sc & SCF_CTRL)) {
if (sc & SCF_ALT) { if (sc & SCF_ALT) {
switch (ch) { switch (ch) {
case 'a':
if (sc&SCF_KEY_DESC)
KeyDescSet("Win/AutoComplete(ON);");
else
AutoComplete(ON);
return TRUE;
case 'A':
if (sc&SCF_KEY_DESC)
KeyDescSet("Win/AutoComplete;");
else
AutoComplete;
return TRUE;
case 'h': case 'h':
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Tile Horizontally"); KeyDescSet("Win/Tile Horizontally");
else else
WinTileHorz; WinTileHorz;
return TRUE; return TRUE;
case 'm': case 'm':
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Maximize"); KeyDescSet("Win/Maximize");
else { else {
WinMax; WinMax;
WinBorder; WinBorder;
@@ -110,17 +123,17 @@ Bool MyPutKey(I64 ch,I64 sc)
return TRUE; return TRUE;
case 'v': case 'v':
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/Tile Vertically"); KeyDescSet("Win/Tile Vertically");
else else
WinTileVert; WinTileVert;
return TRUE; return TRUE;
case 'l': case 'l':
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Put Link to Cur Pos on Clipboard"); KeyDescSet("Edit/Put Link to Cur Pos on Clipboard");
else { else {
ClipboardDel; ClipboardDel;
st1=FileNameAbs(Define("ST_BIBLE_FILE")); st1=FileNameAbs(BIBLE_FILENAME);
st2=FileNameAbs(DocPut->filename.name); st2=FileNameAbs(DocPut->filename.name);
if (!StrCmp(st1,st2)) { if (!StrCmp(st1,st2)) {
Free(st1); Free(st1);
@@ -135,7 +148,7 @@ Bool MyPutKey(I64 ch,I64 sc)
return TRUE; return TRUE;
case 'L': case 'L':
if (sc&SCF_KEY_DESC) if (sc&SCF_KEY_DESC)
SetKeyDesc("Edit/Place Anchor, Put Link to Clipboard"); KeyDescSet("Edit/Place Anchor, Put Link to Clipboard");
else { else {
i=RandU32; i=RandU32;
ClipboardDel; ClipboardDel;
@@ -145,19 +158,6 @@ Bool MyPutKey(I64 ch,I64 sc)
} }
return TRUE; return TRUE;
case 'w':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/WordStat(ON);");
else
WordStat(ON);
return TRUE;
case 'W':
if (sc&SCF_KEY_DESC)
SetKeyDesc("Win/WordStat;");
else
WordStat;
return TRUE;
} }
} }
} }
@@ -1,8 +1,8 @@
//Change anything you want in this //Place this file in /Home and change
//acct file or others. //anything you want.
//This makes your keyboard fast //This makes your keyboard fast
SetTypeMatic(0); KbdTypeMatic(0);
//Set Time Zone //Set Time Zone
local_time_offset=0*60*60*CDATE_FREQ; //Do daylight savings by hand local_time_offset=0*60*60*CDATE_FREQ; //Do daylight savings by hand
+5 -5
View File
@@ -1,12 +1,12 @@
//Change anything you want in this //Place this file in /Home and change
//acct file or others. //anything you want.
Cd("/Adam/Boot");; Cd("/Adam/Boot");;
#include "InsBoot" #include "Boot"
Cd("/Adam/Utils");; Cd("/Adam/Utils");;
#include "Profiler" #include "Profiler"
#include "Diff" #include "Diff"
#include "Grep" #include "Find"
#include "LineRep" #include "LineRep"
#include "Merge" #include "Merge"
#include "S2T" #include "S2T"
@@ -20,6 +20,6 @@ Cd("/Adam/Utils");;
MapFileLoad("::/Kernel/Kernel"); MapFileLoad("::/Kernel/Kernel");
MapFileLoad("::/Compiler/Compiler"); MapFileLoad("::/Compiler/Compiler");
Cd("HOME");; Cd("::/Home");;
#help_index "" #help_index ""
+8 -8
View File
@@ -1,5 +1,5 @@
//Change anything you want in this //Place this file in /Home and change
//acct file or others. //anything you want.
U0 UserStartUp() U0 UserStartUp()
{//Run each time a user a spawned {//Run each time a user a spawned
@@ -9,6 +9,7 @@ U0 UserStartUp()
WinToTop; WinToTop;
WinZBufUpdate; WinZBufUpdate;
Preempt(ON); Preempt(ON);
Dir;
} }
U0 SrvStartUp() U0 SrvStartUp()
@@ -23,15 +24,14 @@ U0 SrvStartUp()
U0 StartUpTasks() U0 StartUpTasks()
{ {
CTask *user1,*user2; CTask *user1,*user2;
user1=SpawnUser; user1=User;
user2=SpawnUser("Ed(\"::/Doc/Install.TXT.Z\");\n"); user2=User;
WinToTop(user1); WinToTop(user1);
WinTileVert; WinTileVert;
"Boot Time:%7.3fs\n",tS; "Boot Time:%7.3fs\n",tS;
XTalk(user1,"Cd(\"HOME\");#include \"DoOnce\";\n"); XTalk(user1,"Cd(\"::/Home\");#include \"DoOnce\";\n");
Silent(ON); //no output to screen Silent; //no output to screen
WSInit; ACInit("/*;~*Bible.TXT*");
WordStat;
Silent(OFF); //no output to screen Silent(OFF); //no output to screen
} }
+26
View File
@@ -0,0 +1,26 @@
//Place this file in /Home and change
//anything you want.
#help_index "Cmd Line (Typically)"
//These are customized quick commands.
//Feel free to add more or change.
public I64 F(U8 *needle_str,U8 *fu_flags=NULL)
{//Find (Find) all text files.
return Find(needle_str,"/*",fu_flags);
}
public I64 R(U8 *needle_str,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
{//Find (Find) and replace string with string in all files.
return Find(needle_str,"/*",fu_flags,replace_text);
}
public I64 FD(U8 *needle_str,U8 *fu_flags=NULL)
{//Find (Find) text files in cur dir.
return Find(needle_str,"*",fu_flags);
}
public I64 RD(U8 *needle_str,U8 *replace_text=NULL,U8 *fu_flags="+l-i")
{//Find (Find) and replace string with string in cur dir.
return Find(needle_str,"*",fu_flags,replace_text);
}
Binary file not shown.
Loaded 100 of 531 files, more files were not shown because too many files have changed in this diff. Show more