spacing to more files

This commit is contained in:
TomAwezome 2020-05-23 01:33:35 -04:00
parent 3e8690799c
commit 0293e0d373
9 changed files with 1124 additions and 980 deletions

Binary file not shown.

View File

@ -1,4 +1,5 @@
$FG,7$Files reformatted starting from ::/ 'root' directory.$FG,0$
HomeKeyPlugins.CC
HomeLocalize.CC
HomeSys.CC
@ -6,7 +7,6 @@ HomeWrappers.CC
Once.CC
StartOS.CC
/Zenith/
DevInfo.CC
InFile.CC
@ -17,6 +17,14 @@ StartOS.CC
WallPaper.CC
Win.CC
WinMgr.CC
ZDebug.CC
ZDefine.CC
ZExterns.CC ... ?
ZHash.CC
ZMath.CC
ZMathODE.CC
ZMouse.CC
ZBlkDev/
Mount.CC

View File

@ -6,124 +6,162 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,Bool u8_chars,Bool forc
CDocEntry *doc_e;
Bool unlock;
CHashClass *tmpc, *tmpc2;
if (depth>=max_depth) return TRUE;
if (!(tmpc=HashFind(class_name,Fs->hash_table,types))) {
if (depth >= max_depth)
return TRUE;
if (!(tmpc = HashFind(class_name, Fs->hash_table, types)))
{
DocPrint(doc, "Class Not Found.\n");
return FALSE;
}
if (!force && (!CheckPtr(_d) || !CheckPtr(_d(U8 *)+tmpc->size))) {
if (!force && (!CheckPtr(_d) || !CheckPtr(_d(U8 *) + tmpc->size)))
{
DocPrint(doc, "Bad Ptr:%016X\n", _d);
return FALSE;
}
if (tmpc->base_class && !ClassRep2(doc,_d,tmpc->base_class->str,
depth,max_depth,dynamic,types,offset))
if (tmpc->base_class && !ClassRep2(doc, _d, tmpc->base_class->str, depth, max_depth, dynamic, types, offset))
return FALSE;
unlock = DocLock(doc);
DocPrint(doc, "Class:\"%s\"\n", class_name);
ml = tmpc->member_list_and_root;
while (ml) {
while (ml)
{
tmpc2 = ml->member_class;
ptr = _d(U8 *) + ml->offset;
DocPrint(doc, "%08X ", ptr(U8 *) + offset);
stars = tmpc2->ptr_stars_count;
tmpc2 = OptClassFwd(tmpc2);
tmpc2 -= tmpc2->ptr_stars_count;
if (tmpc2->type & HTT_INTERNAL_TYPE) {
if (tmpc2->type & HTT_INTERNAL_TYPE)
{
DocPrint(doc, "$$GREEN$$%-20ts:$$FG$$", ml->str);
if (stars==1 && (tmpc2->raw_type==RT_I8 || tmpc2->raw_type==RT_U8)) {
if (stars == 1 && (tmpc2->raw_type == RT_I8 || tmpc2->raw_type == RT_U8))
{
ptr = *ptr;
if (CheckPtr(ptr)) {
if (dynamic) {
if (CheckPtr(ptr))
{
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
doc_e->data = ptr;
DocDataFormat(doc, doc_e);
} else
}
else
DocPrint(doc, "%40ts\n", ptr);
}
} else if (!stars) {
}
else if (!stars)
{
j = MinI64(ml->dim.total_count, 32);
if ((tmpc2->raw_type==RT_I8 || tmpc2->raw_type==RT_U8) && u8_chars) {
if (j==1) {
if (dynamic) {
if ((tmpc2->raw_type == RT_I8 || tmpc2->raw_type == RT_U8) && u8_chars)
{
if (j == 1)
{
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=U8,A=\"%%c\"$$\n");
doc_e->data = ptr;
} else
}
else
DocPrint(doc, "%c\n", *ptr(U8 *));
} else {
if (dynamic) {
}
else
{
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
doc_e->data = ptr;
DocDataFormat(doc, doc_e);
} else
}
else
DocPrint(doc, "%40ts\n", ptr);
}
}
for (i=0;i<j;i++) {
switch (tmpc2->raw_type) {
for (i = 0; i < j; i++)
{
switch (tmpc2->raw_type)
{
case RT_I0:
case RT_U0:
break;
case RT_I8:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=I8,A=\"%%02X\"$$ ");
doc_e->data = ptr(I8 *)++;
} else
}
else
DocPrint(doc, "%02X ", *ptr(I8 *)++);
break;
case RT_U8:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=U8,A=\"%%02X\"$$ ");
doc_e->data = ptr(U8 *)++;
} else
}
else
DocPrint(doc, "%02X ", *ptr(U8 *)++);
break;
case RT_I16:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=I16,A=\"%%04X\"$$ ");
doc_e->data = ptr(I16 *)++;
} else
}
else
DocPrint(doc, "%04X ", *ptr(I16 *)++);
break;
case RT_U16:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=U16,A=\"%%04X\"$$ ");
doc_e->data = ptr(U16 *)++;
} else
}
else
DocPrint(doc, "%04X ", *ptr(U16 *)++);
break;
case RT_I32:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=I32,A=\"%%08X\"$$ ");
doc_e->data = ptr(I32 *)++;
} else
}
else
DocPrint(doc, "%08X ", *ptr(I32 *)++);
break;
case RT_U32:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=U32,A=\"%%08X\"$$ ");
doc_e->data = ptr(U32 *)++;
} else
}
else
DocPrint(doc, "%08X ", *ptr(U32 *)++);
break;
case RT_U64:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=U64,A=\"%%08X\"$$ ");
doc_e->data = ptr(U64 *)++;
} else
}
else
DocPrint(doc, "%08X ", *ptr(U64 *)++);
break;
case RT_F64:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,RT=F64,A=\"%%16g\"$$ ");
doc_e->data = ptr(F64 *)++;
} else
}
else
DocPrint(doc, "%16g ", *ptr(I64 *)++);
break;
default:
if (dynamic) {
if (dynamic)
{
doc_e = DocPrint(doc, "$$DA-TRM+RD+UD,A=\"%%016X\"$$ ");
doc_e->data = ptr(I64 *)++;
} else
}
else
DocPrint(doc, "%016X ", *ptr(I64 *)++);
}
if (dynamic)
@ -131,14 +169,19 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,Bool u8_chars,Bool forc
}
if (j < ml->dim.total_count)
DocPrint(doc, "...");
} else
}
else
DocPrint(doc, "%016X", *ptr);
DocPrint(doc,"\n");
} else {
if (depth<2) {
}
else
{
if (depth < 2)
{
if (stars == 1 && !CheckPtr(*ptr))
DocPrint(doc, "%-20ts:%016X\n", ml->str, *ptr);
else {
else
{
DocPrint(doc, "$$TR,\"%s\"$$\n", ml->str);
DocPrint(doc, "$$ID,2$$");
if (!stars)
@ -147,7 +190,8 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,Bool u8_chars,Bool forc
ClassRep2(doc, *ptr, tmpc2->str, u8_chars, force, depth + 1, max_depth, dynamic);
DocPrint(doc, "$$ID,-2$$");
}
} else
}
else
DocPrint(doc, "%-20ts\n", ml->str);
}
ml = ml->next;
@ -186,13 +230,13 @@ public U0 ClassRep(U8 *_d, U8 *class_name=lastclass, I64 max_depth=2, Bool u8_ch
}
}
public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,
I64 max_depth=2,Bool u8_chars=FALSE,Bool force=FALSE,Bool fun=FALSE,I64 offset=0)
public U0 ClassRepD(U8 *_d, U8 *class_name=lastclass, I64 max_depth=2, Bool u8_chars=FALSE, Bool force=FALSE, Bool fun=FALSE, I64 offset=0)
{//Dynamic ClassRep. Uses hex_ed widget for live changes.
CDoc *doc;
if (IsRaw)
doc = DocNew;
else {
else
{
DocMax;
doc = DocPut;
}
@ -202,7 +246,8 @@ public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,
ClassRep2(doc, _d, class_name, u8_chars, force, 0, max_depth, TRUE, HTT_CLASS, offset);
DocPrint(doc, "\n");
DocRecalc(doc);
if (IsRaw) {
if (IsRaw)
{
DocDump(doc, 100000);
DocDel(doc);
}
@ -213,8 +258,10 @@ U0 UpdateRegVarImg(CHashFun *tmpf,U8 *_b,CTask *task)
CMemberList *ml;
CHashClass *tmpc;
ml = tmpf->member_list_and_root;
while (ml) {
if (ml->reg!=REG_NONE) {
while (ml)
{
if (ml->reg != REG_NONE)
{
tmpc = OptClassFwd(ml->member_class);
MemCopy(_b + ml->offset, TaskRegAddr(task, ml->reg), tmpc->size);
}
@ -228,10 +275,12 @@ public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
U8 *img;
CHashFun *tmpf = HashFind(st, Fs->hash_table, HTT_FUN);
CMemberList *tmpm;
if (tmpf) {
if (rbp) {
if (task) {
//tmpf->size is negative. It's the bottom
if (tmpf)
{
if (rbp)
{
if (task)
{ //tmpf->size is negative. It's the bottom
//of the fun local var space relative to RBP.
size = tmpf->arg_count * 8 - tmpf->size + 16;
@ -240,11 +289,15 @@ public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
UpdateRegVarImg(tmpf, img - tmpf->size, task);
ClassRep(img - tmpf->size, st, max_depth, FALSE, FALSE, TRUE, rbp - img + tmpf->size);
Free(img);
} else
}
else
ClassRep(rbp, st, max_depth, FALSE, FALSE, TRUE);
} else {
}
else
{
tmpm = tmpf->member_list_and_root;
while (tmpm) {
while (tmpm)
{
if (0 <= tmpm->reg < REG_REGS_NUM)
"%08Z %s\n", tmpm->reg, "ST_U64_REGS", tmpm->str;
else
@ -262,15 +315,17 @@ public U0 Uf(U8 *st)
I64 i;
CHashSrcSym *tmpf;
CDebugInfo *debug_info;
if (tmpf=HashFind(st,Fs->hash_table,HTT_FUN|HTT_EXPORT_SYS_SYM)) {
if (tmpf = HashFind(st, Fs->hash_table, HTT_FUN | HTT_EXPORT_SYS_SYM))
{
if (tmpf->type & HTT_FUN)
FunRep(st);
if (debug_info=tmpf->debug_info) {
i=debug_info->body[debug_info->max_line+1-debug_info->min_line]
-debug_info->body[0];
if (debug_info = tmpf->debug_info)
{
i = debug_info->body[debug_info->max_line + 1 - debug_info->min_line] - debug_info->body[0];
Un(debug_info->body[0], i);
"Code Size:%04X\n", i;
} else
}
else
U(HashVal(tmpf));
}
}

View File

@ -5,8 +5,7 @@ U0 LoadDocDefines()
CBinFile *bfh = mem_boot_base - sizeof(CBinFile);
DefinePrint("DD_OS_NAME_VERSION", "ZenithOS V%0.2f", sys_os_version);
DefinePrint("DD_TEMPLEOS_AGE","%0.1f",
(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
DefinePrint("DD_TEMPLEOS_AGE", "%0.1f", (Now - Str2Date("8/1/2003")) / ToF64(1 << 32) / CDATE_YEAR_DAYS);
DefinePrint("DD_KERNEL", "%08X", bfh);
bfh(I64) += bfh->file_size - 1;
@ -18,20 +17,16 @@ $TR,"LineRep"$
$ID,2$DefinePrint("DD_TEMPLEOS_LOC", "80,849");
$ID,-2$
DefinePrint("DD_MP_VECT", "%08X", MP_VECT_ADDR);
DefinePrint("DD_MP_VECT_END","%08X",
MP_VECT_ADDR+COREAP_16BIT_INIT_END-COREAP_16BIT_INIT-1);
DefinePrint("DD_MP_VECT_END", "%08X", MP_VECT_ADDR + COREAP_16BIT_INIT_END - COREAP_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_FIXED_AREA_END", "%08X", SYS_FIXED_AREA + sizeof(CSysFixedArea) - 1);
DefinePrint("DD_MEM_HEAP_BASE", "%08X", mem_heap_base);
DefinePrint("DD_MEM_HEAP_LIMIT", "%08X", mem_heap_limit);
DefinePrint("DD_MEM_MIN_MEG", "%dMeg", MEM_MIN_MEG);
DefinePrint("DD_UNCACHED_ALIAS", "%010X", dev.uncached_alias);
DefinePrint("DD_PHYSICAL_SPACE_END","%010X",
mem_physical_space-1);
DefinePrint("DD_MAPPED_SPACE_END","%010X",
mem_mapped_space-1);
DefinePrint("DD_PHYSICAL_SPACE_END", "%010X", mem_physical_space - 1);
DefinePrint("DD_MAPPED_SPACE_END", "%010X", mem_mapped_space - 1);
DefinePrint("DD_JIFFY_HZ", "%dHz", JIFFY_FREQ);
}

View File

@ -22,8 +22,7 @@ extern CDoc *DocDisplay(CTask *task=NULL);
extern U0 DocDump(CDoc *doc, I64 uS_delay=0);
extern CDocEntry *DocEntryCopy(CDoc *doc, CDocEntry *doc_e);
extern U0 DocEntryDel(CDoc *doc, CDocEntry *doc_e);
extern Bool DocForm(U8 *_d,U8 *class_name=lastclass,
I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL);
extern Bool DocForm(U8 *_d, U8 *class_name=lastclass, I64 dof_flags=0, U8 *header=NULL, U8 *footer=NULL);
extern U0 DocHelpIdx(CDoc *doc, U8 *idx);
extern Bool DocHighlightCursor(Bool show=OFF, CDoc *doc=NULL);
extern U0 DocInsDoc(CDoc *doc=NULL, CDoc *doc2);
@ -55,24 +54,19 @@ extern CMenu *MenuPush(U8 *st);
extern U8 Mount(Bool caller_is_prtdisk=FALSE);
extern CTask *Noise(I64 mS, F64 min_ona, F64 max_ona);
extern Bool PopUpCancelOk(U8 *header=NULL, U8 *footer=NULL);
extern I64 PopUpColor(U8 *header=NULL,
Bool allow_transparent=TRUE,Bool allow_default=TRUE);
extern I64 PopUpColor(U8 *header=NULL, Bool allow_transparent=TRUE, Bool allow_default=TRUE);
extern I64 PopUpColorDither(U8 *header=NULL);
extern I64 PopUpColorLighting(U8 *header=NULL);
extern I64 PopUpFile(U8 *filename,
Bool warn_ext=TRUE,CTask *parent=NULL,CTask **_pu_task=NULL);
extern Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,
I64 dof_flags=DOF_SIZE_MIN,U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpFile(U8 *filename, Bool warn_ext=TRUE, CTask *parent=NULL, CTask **_pu_task=NULL);
extern Bool PopUpForm(U8 *_d, U8 *class_name=lastclass, I64 dof_flags=DOF_SIZE_MIN, U8 *header=NULL, U8 *footer=NULL);
extern I64 PopUpI64Get(U8 *message, I64 default, I64 lo=I64_MIN, I64 hi=I64_MAX);
extern U8 *PopUpGetStr(U8 *header=NULL);
extern I64 PopUpMenu(CDoc *doc, I64 dof_flags=0);
extern Bool PopUpNoYes(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 I64 RedSeaISO(U8 *_iso_filename=NULL,U8 *_src_dir,
U8 *_stage2_filename=NULL);
extern I64 RedSeaISO(U8 *_iso_filename=NULL, U8 *_src_dir, U8 *_stage2_filename=NULL);
extern U0 Refresh(I64 count=1, Bool force=FALSE);
extern U0 RegOneTimePopUp(I64 flag_num, U8 *message);
extern Bool RegWrite(U8 *path, U8 *format, ...);

View File

@ -19,7 +19,8 @@ I64 HashEntriesCompare2(CWho *h1,CWho *h2)
{
CHashFun *tmpf1 = h1->h, *tmpf2 = h2->h;
I64 i1 = HashVal(tmpf1), i2 = HashVal(tmpf2);
if (i1==i2) {
if (i1 == i2)
{
i1 = HashTypeNum(tmpf1);
i2 = HashTypeNum(tmpf2);
if (i1 == i2)
@ -31,7 +32,8 @@ I64 HashEntriesCompare2(CWho *h1,CWho *h2)
I64 HelpIndexCount(U8 *ptr, U8 *idx)
{
I64 count = 0, ch, idx_len = StrLen(idx);
while (*ptr) {
while (*ptr)
{
if (!StrNCompare(ptr, idx, idx_len))
count++;
while (ch = *ptr++)
@ -47,7 +49,8 @@ U8 *HelpIndexStr(U8 **_ptr,U8 *idx)
{
U8 *ptr = *_ptr, *ptr2, *res;
I64 ch, idx_len = StrLen(idx);
while (*ptr) {
while (*ptr)
{
ptr2 = ptr;
while (ch = *ptr++)
if (ch == ';')
@ -55,7 +58,8 @@ U8 *HelpIndexStr(U8 **_ptr,U8 *idx)
if (!ch)
ptr--;
*_ptr = ptr;
if (!StrNCompare(ptr2,idx,idx_len)) {
if (!StrNCompare(ptr2, idx, idx_len))
{
if (ch == ';')
ptr--;
*ptr = 0;
@ -80,19 +84,19 @@ U8 *HelpComment(CTask *task,CHash *tmph,U8 *_src_link)
doc = DocPut(task);
doc_e = doc->cur_entry;
if (tmph->type&HTT_FUN) {
if (Bt(&tmph(CHashFun *)->flags,Ff__EXTERN) ||
Bt(&tmph(CHashFun *)->flags,Ff_INTERNAL))
while (doc_e!=doc &&
(!(doc_e->de_flags&DOCEF_TAG)||!StrOcc(doc_e->tag,';')))
if (tmph->type & HTT_FUN)
{
if (Bt(&tmph(CHashFun *)->flags, Ff__EXTERN) || Bt(&tmph(CHashFun *)->flags, Ff_INTERNAL))
while (doc_e != doc && (!(doc_e->de_flags & DOCEF_TAG) || !StrOcc(doc_e->tag, ';')))
doc_e = doc_e->next;
else
while (doc_e!=doc &&
(!(doc_e->de_flags&DOCEF_TAG)||!StrOcc(doc_e->tag,'{')))
while (doc_e != doc && (!(doc_e->de_flags & DOCEF_TAG) || !StrOcc(doc_e->tag, '{')))
doc_e = doc_e->next;
}
if (doc_e!=doc) {
if (doc_e->de_flags&DOCEF_TAG) {
if (doc_e != doc)
{
if (doc_e->de_flags & DOCEF_TAG)
{
ptr = doc_e->tag;
if (ptr2 = StrMatch("//", ptr))
ptr = ptr2 + 2;
@ -105,12 +109,16 @@ U8 *HelpComment(CTask *task,CHash *tmph,U8 *_src_link)
res = StrNew(ptr);
doc_e = doc_e->next;
}
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
if (doc_e->type_u8==DOCT_TAB) {
while (doc_e != doc && doc_e->type_u8 != DOCT_NEW_LINE)
{
if (doc_e->type_u8 == DOCT_TAB)
{
ptr = MStrPrint("%s ", res);
Free(res);
res = ptr;
} else if (doc_e->de_flags&DOCEF_TAG) {
}
else if (doc_e->de_flags & DOCEF_TAG)
{
ptr = MStrPrint("%s%s", res, doc_e->tag);
Free(res);
res = ptr;
@ -119,7 +127,8 @@ U8 *HelpComment(CTask *task,CHash *tmph,U8 *_src_link)
}
}
XTalkWait(task, "%c", CH_SHIFT_ESC);
if (res) {
if (res)
{
ptr = MStrUtil(res, SUF_REM_TRAILING | SUF_REM_LEADING | SUF_SINGLE_SPACE);
Free(res);
res = ptr;
@ -133,7 +142,8 @@ I64 HashEntriesCompare3(CWho *h1,CWho *h2)
i = StrCompare(h1->idx, h2->idx);
if (i)
return i;
else {
else
{
if (h1->h->type & HTT_HELP_FILE)
i1 = 1;
if (h2->h->type & HTT_HELP_FILE)
@ -146,8 +156,7 @@ I64 HashEntriesCompare3(CWho *h1,CWho *h2)
}
}
public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
U8 *idx=NULL,CDoc *doc=NULL)
public U0 Who(U8 *fu_flags=NULL, CHashTable *h=NULL, U8 *idx=NULL, CDoc *doc=NULL)
{ //Dump hash symbol table.
// "+p" for only public symbols
// "+m" to order by number (normally alphabetical)
@ -169,23 +178,29 @@ U8 *idx=NULL,CDoc *doc=NULL)
publics = Bt(&f, FUf_PUBLIC);
map = Bt(&f, FUf_MAP);
if (!h) h=Fs->hash_table;
if (!h)
h = Fs->hash_table;
if (idx) {
if (idx)
{
task = User;
TaskWait(task);
LBtr(&task->display_flags, DISPLAYf_SHOW);
} else
}
else
task = NULL;
count = 0;
table = h;
while (table) {
for (i=0;i<=table->mask;i++) {
while (table)
{
for (i = 0; i <= table->mask; i++)
{
tmph = table->body[i];
while (tmph) {
if (!(tmph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
(tmph->type & HTF_PUBLIC || !publics)) {
while (tmph)
{
if (!(tmph->type & (HTF_IMPORT | HTF_PRIVATE)) && (tmph->type & HTF_PUBLIC || !publics))
{
if (!idx)
count++;
else if (tmph->type & HTG_SRC_SYM && (cur_idx = tmph->idx))
@ -204,17 +219,19 @@ U8 *idx=NULL,CDoc *doc=NULL)
list = CAlloc(count * sizeof(CWho));
j = 0;
table = h;
while (table) {
for (i=0;i<=table->mask;i++) {
while (table)
{
for (i = 0; i <= table->mask; i++)
{
tmph = table->body[i];
while (tmph) {
if (!(tmph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
(tmph->type & HTF_PUBLIC || !publics))
while (tmph)
{
if (!(tmph->type & (HTF_IMPORT | HTF_PRIVATE)) && (tmph->type & HTF_PUBLIC || !publics))
if (!idx)
list[j++].h = tmph;
else if (tmph->type&HTG_SRC_SYM && (cur_idx=tmph->idx) &&
(k=HelpIndexCount(cur_idx,idx)))
while (k--) {
else if (tmph->type & HTG_SRC_SYM && (cur_idx=tmph->idx) && (k = HelpIndexCount(cur_idx, idx)))
while (k--)
{
list[j].idx = HelpIndexStr(&cur_idx, idx);
list[j++].h = tmph;
}
@ -234,16 +251,20 @@ U8 *idx=NULL,CDoc *doc=NULL)
else
QuickSort(list, count, sizeof(CWho), &HashEntriesCompare);
if (idx) {
if (idx)
{
progress1_max = count;
progress1 = 0;
}
for (i=0;i<count;i++) {
for (i = 0; i < count; i++)
{
comment = NULL;
ptr = list[i].h;
if (idx)
if (cur_idx=list[i].idx) {
if (StrCompare(cur_idx,last_idx)) {
if (cur_idx = list[i].idx)
{
if (StrCompare(cur_idx, last_idx))
{
Free(last_idx);
last_idx = StrNew(cur_idx);
if (i)
@ -252,27 +273,34 @@ U8 *idx=NULL,CDoc *doc=NULL)
}
}
if (idx && ptr->type & HTT_HELP_FILE) {
if (idx && ptr->type & HTT_HELP_FILE)
{
DocPrint(doc, "$$WW,1$$");
DocType(doc, ptr->str);
DocPrint(doc, "$$WW,0$$");
} else {
if (ptr->type&HTG_SRC_SYM && ptr(CHashSrcSym *)->src_link) {
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\"$$",
ptr->str,ptr(CHashSrcSym *)->src_link);
}
else
{
if (ptr->type & HTG_SRC_SYM && ptr(CHashSrcSym *)->src_link)
{
DocPrint(doc, "$$LK,\"%-20s\",A=\"%s\"$$", ptr->str, ptr(CHashSrcSym *)->src_link);
if (idx)
comment = HelpComment(task, ptr, ptr(CHashSrcSym *)->src_link);
} else
}
else
DocPrint(doc, "%-20s", ptr->str);
if (!idx) {
if (ptr->type & HTT_DEFINE_STR) {
if (!idx)
{
if (ptr->type & HTT_DEFINE_STR)
{
j = ptr(CHashDefineStr *)->count;
if (j == -1)
StrPrint(buf, "%-10t$$Q ", ptr(CHashDefineStr *)->data);
else
StrPrint(buf, "%-10t$$Q %02X", ptr(CHashDefineStr *)->data, j);
} else if (ptr->type & HTT_GLOBAL_VAR)
}
else if (ptr->type & HTT_GLOBAL_VAR)
StrPrint(buf, "%010X ", ptr(CHashGlobalVar *)->data_addr);
else
StrPrint(buf, "%010X ", HashVal(ptr));
@ -281,7 +309,8 @@ U8 *idx=NULL,CDoc *doc=NULL)
CatPrint(buf, " %04X ", ptr->use_count);
else
CatPrint(buf, " %04X %010X ", ptr->use_count, j);
} else
}
else
*buf = 0;
k = ptr->type;
@ -289,7 +318,8 @@ U8 *idx=NULL,CDoc *doc=NULL)
k &= ~HTF_PUBLIC;
if (!(k & HTG_TYPE_MASK))
CatPrint(buf, "NULL ");
while (k) {
while (k)
{
j = Bsf(k);
if (j < 0)
break;
@ -297,7 +327,8 @@ U8 *idx=NULL,CDoc *doc=NULL)
CatPrint(buf, "%Z ", j, "ST_HTT_TYPES");
}
DocPrint(doc, "%s", buf);
if (comment) {
if (comment)
{
DocPrint(doc, "$$GREEN$$%s$$FG$$", comment);
Free(comment);
}
@ -312,7 +343,8 @@ U8 *idx=NULL,CDoc *doc=NULL)
progress1 = progress1_max = 0;
wh_done:
if (doc) {
if (doc)
{
if (doc->head.next == doc)
DocPrint(doc, "No Match");
else
@ -330,11 +362,14 @@ public I64 HashDepthRep(CHashTable *table=NULL)
//Histogram of collision count.
I64 i, j, longest = 0, count = 0, a[HDR_NUM];
CHash *tmph;
if (!table) table=Fs->hash_table;
if (!table)
table = Fs->hash_table;
MemSet(a, 0, sizeof(a));
for (i=0;i<=table->mask;i++) {
for (i = 0; i <= table->mask; i++)
{
tmph = table->body[i];
if (tmph) {
if (tmph)
{
j = LinkedListCount(tmph);
if (j < HDR_NUM)
a[j]++;
@ -347,8 +382,7 @@ public I64 HashDepthRep(CHashTable *table=NULL)
for (i = 0; i < HDR_NUM; i++)
if (a[i])
"%02d:%d\n", i, a[i];
"Size:%d Count:%d Longest:%d\n",
table->mask+1,count,longest;
"Size:%d Count:%d Longest:%d\n", table->mask + 1, count, longest;
return longest;
}
@ -371,8 +405,7 @@ public U0 PopUpHelpIndex(U8 *idx,CTask *parent=NULL)
#help_index "Hash/System"
public U0 MapFileLoad(U8 *filename)
{//Load map file so we have src line info.
U8 *st,*ptr,*name=ExtDefault(filename,"MAP"),
*absname=FileNameAbs(name);
U8 *st, *ptr, *name = ExtDefault(filename, "MAP"), *absname = FileNameAbs(name);
CDoc *doc = DocRead(name);
CDocEntry *doc_e;
CHashSrcSym *tmph;
@ -380,24 +413,28 @@ public U0 MapFileLoad(U8 *filename)
CDebugInfo *debug_info;
FileExtRemove(absname);
if (absname[1]==':' && StrLen(absname)>2 &&
(tmph=HashSingleTableFind(absname+2,Fs->hash_table,HTT_MODULE)))
if (absname[1] == ':' && StrLen(absname) > 2 && (tmph = HashSingleTableFind(absname + 2, Fs->hash_table, HTT_MODULE)))
base = tmph(CHashGeneric *)->user_data0 + sizeof(CBinFile);
if (!doc) return;
doc_e = doc->head.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_LINK) {
while (doc_e != doc)
{
if (doc_e->type_u8 == DOCT_LINK)
{
if (*doc_e->tag)
st = MStrUtil(doc_e->tag, SUF_REM_TRAILING);
else
st = MStrUtil(doc_e->aux_str, SUF_REM_TRAILING);
if (tmph=HashSingleTableFind(st,Fs->hash_table,HTG_SRC_SYM)) {
if (*doc_e->tag) {
if (tmph = HashSingleTableFind(st, Fs->hash_table, HTG_SRC_SYM))
{
if (*doc_e->tag)
{
Free(tmph->src_link);
tmph->src_link = doc_e->aux_str;
ptr = tmph->src_link;
if (ptr[0] && ptr[1] && ptr[2]==':') {
if (ptr[0] && ptr[1] && ptr[2] == ':')
{
if (ptr[3] == ':')
ptr[3] = blkdev.boot_drive_let;
else if (ptr[3] == '~')
@ -407,13 +444,16 @@ public U0 MapFileLoad(U8 *filename)
}
if (tmph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM) &&
!(debug_info = tmph->debug_info) && doc_e->bin_data &&
(debug_info=doc_e->bin_data->data)) {
(debug_info = doc_e->bin_data->data))
{
if (doc_e->bin_data->size > MSize(debug_info))
"Corrupt Map Entry\n";
else {
else
{
doc_e->bin_data->data = NULL;
tmph->debug_info = debug_info;
for (i=debug_info->min_line;i<=debug_info->max_line+1;i++) {
for (i = debug_info->min_line; i <= debug_info->max_line + 1; i++)
{
j = i - debug_info->min_line;
if (debug_info->body[j])
debug_info->body[j] = debug_info->body[j] + base;

View File

@ -123,13 +123,16 @@ public Complex *CPoly(Complex *dst,I64 n,Complex *zeros,Complex *x)
{//Eval complex polynomial
I64 i;
Complex n1, n2;
if (n>0) {
if (n > 0)
{
CSub(dst, x, &zeros[0]);
for (i=1;i<n;i++) {
for (i = 1; i < n; i++)
{
CCopy(&n1, dst);
CMul(dst, &n1, CSub(&n2, x, &zeros[i]));
}
} else
}
else
CEqu(dst, 1.0, 0.0);
return dst;
}

View File

@ -55,7 +55,8 @@ public CMathODE *ODENew(I64 n,F64 max_tolerance=1e-6,I64 flags=0)
public Bool ODEPause(CMathODE *ode, Bool val=ON)
{//Pause ODE.
Bool res;
if (!ode) return OFF;
if (!ode)
return OFF;
res = LBEqual(&ode->flags, ODEf_PAUSED, val);
if (val)
while (Bt(&ode->flags, ODEf_BUSY))
@ -66,11 +67,13 @@ public Bool ODEPause(CMathODE *ode,Bool val=ON)
public U0 ODEDel(CMathODE *ode)
{//Free ODE node, but not masses or springs.
I64 i;
if (!ode) return;
if (!ode)
return;
ODEPause(ode);
Free(ode->state);
Free(ode->array_base);
if (ode->slave_tasks) {
if (ode->slave_tasks)
{
for (i = 0; i < mp_count; i++)
Kill(ode->slave_tasks[i]);
Free(ode->slave_tasks);
@ -88,10 +91,10 @@ public I64 ODESize(CMathODE *ode)
U0 ODESetMassesPtrs(CMathODE *ode, F64 *state, F64 *DstateDt)
{
COrder2D3 *ptr1=state(F64 *)+ode->n,
*ptr2=DstateDt(F64 *)+ode->n;
COrder2D3 *ptr1 = state(F64 *) + ode->n, *ptr2 = DstateDt(F64 *) + ode->n;
CMass *tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
tmpm->state = ptr1++;
tmpm->DstateDt = ptr2++;
tmpm = tmpm->next;
@ -104,10 +107,12 @@ U0 ODEState2Internal(CMathODE *ode)
F64 *old_array_base;
I64 mass_count;
if (ode->flags&ODEF_HAS_MASSES) {
if (ode->flags & ODEF_HAS_MASSES)
{
mass_count = 0;
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
mass_count++;
tmpm = tmpm->next;
}
@ -119,7 +124,8 @@ U0 ODEState2Internal(CMathODE *ode)
ODESetMassesPtrs(ode, ode->state_internal, ode->state_internal);
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
MemCopy(tmpm->state, &tmpm->saved_state, sizeof(COrder2D3));
tmpm = tmpm->next;
}
@ -131,10 +137,12 @@ U0 ODEInternal2State(CMathODE *ode)
{
CMass *tmpm;
MemCopy(ode->state, ode->state_internal, ode->n * sizeof(F64));
if (ode->flags&ODEF_HAS_MASSES) {
if (ode->flags & ODEF_HAS_MASSES)
{
ODESetMassesPtrs(ode, ode->state_internal, ode->state_internal);
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
MemCopy(&tmpm->saved_state, tmpm->state, sizeof(COrder2D3));
tmpm = tmpm->next;
}
@ -149,14 +157,16 @@ public U0 ODERenum(CMathODE *ode)
i = 0;
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
tmpm->num = i++;
tmpm = tmpm->next;
}
i = 0;
tmps = ode->next_spring;
while (tmps!=&ode->next_spring) {
while (tmps != &ode->next_spring)
{
tmps->num = i++;
tmps->end1_num = tmps->end1->num;
tmps->end2_num = tmps->end2->num;
@ -170,9 +180,11 @@ public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
F64 dd, best_dd = F64_MAX;
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
dd = Sqr(tmpm->x - x) + Sqr(tmpm->y - y) + Sqr(tmpm->z - z);
if (dd<best_dd) {
if (dd < best_dd)
{
best_dd = dd;
best_mass = tmpm;
}
@ -187,11 +199,14 @@ public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
F64 dd, best_dd = F64_MAX;
tmps = ode->next_spring;
while (tmps!=&ode->next_spring) {
while (tmps != &ode->next_spring)
{
dd = Sqr((tmps->end1->x + tmps->end2->x) / 2 - x) +
Sqr((tmps->end1->y + tmps->end2->y) / 2 - y) +
Sqr((tmps->end1->z + tmps->end2->z) / 2 - z);
if (dd<best_dd) {
if (dd < best_dd)
{
best_dd = dd;
best_spring = tmps;
}
@ -200,18 +215,18 @@ public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
return best_spring;
}
public U0 MassOrSpringFind(
CMathODE *ode,CMass **res_mass,CSpring **res_spring,
F64 x,F64 y,F64 z=0)
public U0 MassOrSpringFind(CMathODE *ode, CMass **res_mass, CSpring **res_spring, F64 x, F64 y, F64 z=0)
{//Find spring or mass nearest x,y,z.
CMass *tmpm, *best_mass = NULL;
CSpring *tmps, *best_spring = NULL;
F64 dd, best_dd = F64_MAX;
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
dd = Sqr(tmpm->x - x) + Sqr(tmpm->y - y) + Sqr(tmpm->z - z);
if (dd<best_dd) {
if (dd < best_dd)
{
best_dd = dd;
best_mass = tmpm;
}
@ -219,25 +234,31 @@ public U0 MassOrSpringFind(
}
tmps = ode->next_spring;
while (tmps!=&ode->next_spring) {
while (tmps != &ode->next_spring)
{
dd = Sqr((tmps->end1->x + tmps->end2->x) / 2 - x) +
Sqr((tmps->end1->y + tmps->end2->y) / 2 - y) +
Sqr((tmps->end1->z + tmps->end2->z) / 2 - z);
if (dd<best_dd) {
if (dd < best_dd)
{
best_dd = dd;
best_spring = tmps;
best_mass = NULL;
}
tmps = tmps->next;
}
if (res_mass) *res_mass =best_mass;
if (res_spring) *res_spring=best_spring;
if (res_mass)
*res_mass = best_mass;
if (res_spring)
*res_spring = best_spring;
}
public CMass *MassFindNum(CMathODE *ode, I64 num)
{//Return mass number N.
CMass *tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
if (tmpm->num == num)
return tmpm;
tmpm = tmpm->next;
@ -250,12 +271,14 @@ public U0 ODEResetInactive(CMathODE *ode)
CMass *tmpm;
CSpring *tmps;
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
while (tmpm != &ode->next_mass)
{
tmpm->flags &= ~MSF_INACTIVE;
tmpm = tmpm->next;
}
tmps = ode->next_spring;
while (tmps!=&ode->next_spring) {
while (tmps != &ode->next_spring)
{
tmps->flags &= ~SSF_INACTIVE;
tmps = tmps->next;
}
@ -267,11 +290,15 @@ U0 ODECalcSprings(CMathODE *ode)
CMass *e1, *e2;
F64 d;
CD3 p;
while (tmps!=&ode->next_spring) {
if (tmps->flags&SSF_INACTIVE) {
while (tmps != &ode->next_spring)
{
if (tmps->flags & SSF_INACTIVE)
{
tmps->displacement = 0;
tmps->f = 0;
} else {
}
else
{
e1 = tmps->end1;
e2 = tmps->end2;
d = D3Norm(D3Sub(&p, &e2->state->x, &e1->state->x));
@ -281,7 +308,8 @@ U0 ODECalcSprings(CMathODE *ode)
tmps->f = 0;
else if (tmps->f < 0 && tmps->flags & SSF_NO_COMPRESSION)
tmps->f = 0;
if (d>0) {
if (d > 0)
{
D3MulEqu(&p, tmps->f / d);
D3AddEqu(&e1->DstateDt->DxDt, &p);
D3SubEqu(&e2->DstateDt->DxDt, &p);
@ -296,19 +324,19 @@ U0 ODECalcDrag(CMathODE *ode)
CMass *tmpm;
F64 d, dd;
CD3 p;
if (ode->drag_v || ode->drag_v2 || ode->drag_v3) {
if (ode->drag_v || ode->drag_v2 || ode->drag_v3)
{
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
if (!(tmpm->flags & MSF_INACTIVE) &&
tmpm->drag_profile_factor &&
(dd=D3NormSqr(&tmpm->state->DxDt))) {
while (tmpm != &ode->next_mass)
{
if (!(tmpm->flags & MSF_INACTIVE) && tmpm->drag_profile_factor && (dd = D3NormSqr(&tmpm->state->DxDt)))
{
d = ode->drag_v;
if (ode->drag_v2)
d += ode->drag_v2 * Sqrt(dd);
if (ode->drag_v3)
d += dd * ode->drag_v3;
D3SubEqu(&tmpm->DstateDt->DxDt,
D3Mul(&p,d*tmpm->drag_profile_factor,&tmpm->state->DxDt));
D3SubEqu(&tmpm->DstateDt->DxDt, D3Mul(&p, d * tmpm->drag_profile_factor, &tmpm->state->DxDt));
}
tmpm = tmpm->next;
}
@ -319,11 +347,12 @@ U0 ODEApplyAccelerationLimit(CMathODE *ode)
{
CMass *tmpm;
F64 d;
if (ode->acceleration_limit) {
if (ode->acceleration_limit)
{
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
if (!(tmpm->flags & MSF_INACTIVE) &&
(d=D3Norm(&tmpm->DstateDt->DxDt))>ode->acceleration_limit)
while (tmpm != &ode->next_mass)
{
if (!(tmpm->flags & MSF_INACTIVE) && (d = D3Norm(&tmpm->DstateDt->DxDt)) > ode->acceleration_limit)
D3MulEqu(&tmpm->DstateDt->DxDt, ode->acceleration_limit / d);
tmpm = tmpm->next;
}
@ -332,12 +361,12 @@ U0 ODEApplyAccelerationLimit(CMathODE *ode)
U0 ODEMPTask(CMathODE *ode)
{
while (TRUE) {
while (TRUE)
{
while (!Bt(&ode->mp_not_done_flags, Gs->num))
Yield;
if (ode->mp_derive)
(*ode->mp_derive)(ode,ode->mp_t,
Gs->num,ode->mp_state,ode->mp_DstateDt);
(*ode->mp_derive)(ode, ode->mp_t, Gs->num, ode->mp_state, ode->mp_DstateDt);
LBtr(&ode->mp_not_done_flags, Gs->num);
}
}
@ -345,12 +374,14 @@ U0 ODEMPTask(CMathODE *ode)
U0 ODEMPWake(CMathODE *ode)
{
I64 i;
if (!ode->slave_tasks) {
if (!ode->slave_tasks)
{
ode->slave_tasks = CAlloc(mp_count * sizeof(CTask *));
for (i = 0; i < mp_count; i++)
ode->slave_tasks[i] = Spawn(&ODEMPTask, ode, "ODE Slave", i);
}
for (i=0;i<mp_count;i++) {
for (i = 0; i < mp_count; i++)
{
Suspend(ode->slave_tasks[i], FALSE);
MPInt(I_WAKE, i);
}
@ -359,7 +390,8 @@ U0 ODEMPWake(CMathODE *ode)
U0 ODEMPSleep(CMathODE *ode)
{
I64 i;
if (ode->slave_tasks) {
if (ode->slave_tasks)
{
while (ode->mp_not_done_flags)
Yield;
for (i = 0; i < mp_count; i++)
@ -373,18 +405,22 @@ U0 ODECallMPDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
ode->mp_state = state;
ode->mp_DstateDt = DstateDt;
ode->mp_not_done_flags = 1 << mp_count - 1;
do Yield;
do
Yield;
while (ode->mp_not_done_flags);
}
U0 ODECallDerivative(CMathODE *ode, F64 t, F64 *state, F64 *DstateDt)
{
CMass *tmpm;
if (ode->flags&ODEF_HAS_MASSES) {
if (ode->flags & ODEF_HAS_MASSES)
{
ODESetMassesPtrs(ode, state, DstateDt);
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
if (!(tmpm->flags&MSF_INACTIVE)) {
while (tmpm != &ode->next_mass)
{
if (!(tmpm->flags & MSF_INACTIVE))
{
D3Zero(&tmpm->DstateDt->DxDt);
D3Copy(&tmpm->DstateDt->x, &tmpm->state->DxDt);
}
@ -397,18 +433,24 @@ U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
if (ode->derive)
(*ode->derive)(ode, t, state, DstateDt);
tmpm = ode->next_mass;
while (tmpm!=&ode->next_mass) {
if (!(tmpm->flags&MSF_INACTIVE)) {
if (tmpm->flags&MSF_FIXED) {
while (tmpm != &ode->next_mass)
{
if (!(tmpm->flags & MSF_INACTIVE))
{
if (tmpm->flags & MSF_FIXED)
{
D3Zero(&tmpm->DstateDt->DxDt);
D3Zero(&tmpm->DstateDt->x);
} else if (tmpm->mass)
}
else if (tmpm->mass)
D3DivEqu(&tmpm->DstateDt->DxDt, tmpm->mass);
}
tmpm = tmpm->next;
}
ODEApplyAccelerationLimit(ode);
} else {
}
else
{
if (ode->mp_derive)
ODECallMPDerivative(ode, t, state, DstateDt);
if (ode->derive)
@ -445,7 +487,8 @@ U0 ODERK4OneStep(CMathODE *ode)
for (i = 0; i < n; i++)
yt[i] = ode->state_internal[i] + hh * dyt[i];
ODECallDerivative(ode, xh, yt, dym);
for (i=0;i<n;i++) {
for (i = 0; i < n; i++)
{
yt[i] = ode->state_internal[i] + ode->h * dym[i];
dym[i] += dyt[i];
}
@ -488,9 +531,7 @@ U0 ODERK4OneStep(CMathODE *ode)
U0 ODECashKarp(CMathODE *ode)
{
I64 i, n = ode->n_internal;
F64 h=ode->h,*state=ode->state_internal,
*DstateDt=ode->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,
*tmpstate,*stateerr,*outstate;
F64 h = ode->h, *state = ode->state_internal, *DstateDt = ode->DstateDt, *ak2, *ak3, *ak4, *ak5, *ak6, *tmpstate, *stateerr, *outstate;
ak2 = ode->tmp0;
ak3 = ode->tmp1;
@ -511,20 +552,16 @@ U0 ODECashKarp(CMathODE *ode)
tmpstate[i] = state[i] + h * (ODEb41 * DstateDt[i] + ODEb42 * ak2[i] + ODEb43 * ak3[i]);
ODECallDerivative(ode, ode->t + ODEa4 * h, tmpstate, ak4);
for (i = 0; i < n; i++)
tmpstate[i]=state[i]+h*(ODEb51*DstateDt[i]+
ODEb52*ak2[i]+ODEb53*ak3[i]+ODEb54*ak4[i]);
tmpstate[i] = state[i] + h * (ODEb51 * DstateDt[i] + ODEb52 * ak2[i] + ODEb53 * ak3[i] + ODEb54*ak4[i]);
ODECallDerivative(ode, ode->t + ODEa5 * h, tmpstate,ak5);
for (i = 0; i < n; i++)
tmpstate[i]=state[i]+h*(ODEb61*DstateDt[i]+
ODEb62*ak2[i]+ODEb63*ak3[i]+ODEb64*ak4[i]+ODEb65*ak5[i]);
tmpstate[i] = state[i] + h * (ODEb61 * DstateDt[i]+ ODEb62 * ak2[i] + ODEb63 * ak3[i] + ODEb64 * ak4[i] + ODEb65 * ak5[i]);
ODECallDerivative(ode, ode->t + ODEa6 * h, tmpstate, ak6);
for (i = 0; i < n; i++)
outstate[i]=state[i]+h*(ODEc1*DstateDt[i]+
ODEc3*ak3[i]+ODEc4*ak4[i]+ODEc6*ak6[i]);
outstate[i] = state[i] + h * (ODEc1 * DstateDt[i] + ODEc3 * ak3[i] + ODEc4 * ak4[i] + ODEc6 * ak6[i]);
for (i = 0; i < n; i++)
stateerr[i]=h*(ODEdc1*DstateDt[i]+ODEdc3*ak3[i]+
ODEdc4*ak4[i]+ODEdc5*ak5[i]+ODEdc6*ak6[i]);
stateerr[i] = h * (ODEdc1 * DstateDt[i] + ODEdc3 * ak3[i] + ODEdc4 * ak4[i] + ODEdc5 * ak5[i] + ODEdc6 * ak6[i]);
}
#define SAFETY 0.9
@ -536,17 +573,20 @@ U0 ODERK5OneStep(CMathODE *ode)
{
I64 i;
F64 errmax, tmp, *tmpstate = ode->tmp6, *stateerr = ode->tmp7;
while (TRUE) {
while (TRUE)
{
ode->h = Clamp(ode->h, ode->h_min, ode->h_max);
ODECashKarp(ode);
errmax = 0.0;
for (i=0;i<ode->n_internal;i++) {
for (i = 0; i < ode->n_internal; i++)
{
tmp = Abs(stateerr[i] / ode->state_scale[i]);
if (tmp > errmax)
errmax = tmp;
}
errmax /= ode->tolerance_internal;
if (errmax<=1.0 || ode->h==ode->h_min) break;
if (errmax <= 1.0 || ode->h == ode->h_min)
break;
tmp = ode->h * SAFETY * errmax ` PSHRNK;
if (tmp < 0.1 * ode->h)
ode->h *= 0.1;
@ -580,22 +620,22 @@ it has a timeout.
if (task->next_ode == &task->next_ode)
task->last_ode_time = 0;
else if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
//See $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateTaskODEs",A="MN:GrUpdateTaskODEs"$().
else if (!Bt(&task->win_inhibit, WIf_SELF_ODE))
{//See $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateTaskODEs",A="MN:GrUpdateTaskODEs"$().
//We will not pick a time limit based on
//how busy the CPU is, what percent of the
//last refresh cycle was spent on ODE's
//and what the refresh cycle rate was.
start_time = tS;
d = 1.0 / winmgr.fps;
timeout_time=start_time+
(task->last_ode_time/d+0.1)/(winmgr.last_ode_time/d+0.1)*
ode_alloced_factor*d;
timeout_time = start_time + (task->last_ode_time / d + 0.1) / (winmgr.last_ode_time / d + 0.1) * ode_alloced_factor * d;
ode = task->next_ode;
while (ode!=&task->next_ode) {
while (ode != &task->next_ode)
{
t_initial = ode->t;
d = tS;
if (!(ode->flags&ODEF_STARTED)) {
if (!(ode->flags & ODEF_STARTED))
{
ode->base_t = d;
ode->flags |= ODEF_STARTED;
}
@ -603,25 +643,30 @@ it has a timeout.
t_desired = ode->t_scale * d + t_initial;
if (ode->flags & ODEF_PAUSED)
ode->base_t += t_desired - ode->t; //Slip
else {
else
{
ode->flags |= ODEF_BUSY;
if (ode->flags & ODEF_PAUSED)
ode->base_t += t_desired-ode->t; //Slip
else {
if (ode->derive || ode->mp_derive) {
else
{
if (ode->derive || ode->mp_derive)
{
if (ode->mp_derive)
ODEMPWake(ode);
ODEState2Internal(ode);
MemCopy(ode->initial_state,ode->state_internal,
ode->n_internal*sizeof(F64));
while (ode->t<t_desired) {
MemCopy(ode->initial_state, ode->state_internal, ode->n_internal * sizeof(F64));
while (ode->t < t_desired)
{
ode->h_max = t_desired - ode->t;
ODECallDerivative(ode, ode->t, ode->state_internal, ode->DstateDt);
for (i = 0; i < ode->n_internal; i++)
ode->state_scale[i] = Abs(ode->state_internal[i]) +
Abs(ode->DstateDt[i]*ode->h)+ode->tolerance_internal;
Abs(ode->DstateDt[i] * ode->h) +
ode->tolerance_internal;
ODERK5OneStep(ode);
if (tS>timeout_time) {
if (tS > timeout_time)
{
ode->base_t += t_desired - ode->t; //Slip
goto ode_done;
@ -629,8 +674,10 @@ it has a timeout.
}
//Interpolate if end time was not exact.
if (ode->t!=t_desired) {
if (interpolation=ode->t-t_initial) {
if (ode->t != t_desired)
{
if (interpolation = ode->t - t_initial)
{
interpolation = (t_desired - t_initial) / interpolation;
if (interpolation != 1.0)
for (i = 0; i < ode->n_internal; i++)
@ -670,16 +717,18 @@ ode_done:
d = (tS - start_time) / (timeout_time - start_time) - 0.75;
ode = task->next_ode;
while (ode!=&task->next_ode) {
if (!(ode->flags&ODEF_PAUSED) && ode->derive) {
if (ode->min_tolerance!=ode->max_tolerance) {
while (ode != &task->next_ode)
{
if (!(ode->flags & ODEF_PAUSED) && ode->derive)
{
if (ode->min_tolerance != ode->max_tolerance)
{
if (d > 0)
ode->tolerance_internal *= 10.0 ` d;
else
ode->tolerance_internal *= 2.0 ` d;
}
ode->tolerance_internal=Clamp(ode->tolerance_internal,
ode->min_tolerance,ode->max_tolerance);
ode->tolerance_internal = Clamp(ode->tolerance_internal, ode->min_tolerance, ode->max_tolerance);
}
ode = ode->next;
}

Binary file not shown.