Skip to content

Commit

Permalink
TempleOSCDV5.03.ISO
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry A. Davis authored and minexew committed Sep 8, 2018
1 parent 4b32f05 commit 6028804
Show file tree
Hide file tree
Showing 111 changed files with 3,464 additions and 2,283 deletions.
Binary file modified 0000Boot/0000Kernel.BIN.C
Binary file not shown.
4 changes: 2 additions & 2 deletions Adam/ADefine.HC
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ U0 LoadDocDefines()
//$LK,"DD_BOOT_HIGH_LOC_DVD",A="FF:::/Adam/Opt/Boot/BootDVD.HC,DD_BOOT_HIGH_LOC_DVD"$

$TR-C,"LineRep"$
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","119,873");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","81,990");
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","120,834");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","82,152");
$ID,-4$
DefinePrint("DD_MP_VECT","%08X",MP_VECT_ADDR);
DefinePrint("DD_MP_VECT_END","%08X",
Expand Down
8 changes: 3 additions & 5 deletions Adam/AHash.HC
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ U8 *idx=NULL,CDoc *doc=NULL)
CHashGeneric *ptr;
CWho *lst;
I64 cnt,i,j,k,f=0;
U8 buf[512],*st,*last_idx=StrNew(""),*cur_idx,*comment;
U8 buf[512],*last_idx=StrNew(""),*cur_idx,*comment;
Bool recurse,publics,map;
CTask *task;

Expand Down Expand Up @@ -267,13 +267,11 @@ U8 *idx=NULL,CDoc *doc=NULL)

if (!idx) {
if (ptr->type & HTT_DEFINE_STR) {
st=MStrUtil(ptr(CHashDefineStr *)->data,SUF_SAFE_DOLLAR);
j=ptr(CHashDefineStr *)->cnt;
if (j==-1)
StrPrint(buf,"%-10tQ ",st);
StrPrint(buf,"%-10t$$Q ",ptr(CHashDefineStr *)->data);
else
StrPrint(buf,"%-10tQ %02X",st,j);
Free(st);
StrPrint(buf,"%-10t$$Q %02X",ptr(CHashDefineStr *)->data,j);
} else if (ptr->type & HTT_GLBL_VAR)
StrPrint(buf,"%010X ",ptr(CHashGlblVar *)->data_addr);
else
Expand Down
169 changes: 124 additions & 45 deletions Adam/AMathODE.HC
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,52 @@ U0 ODERstPtrs(CMathODE *ode)

public CMathODE *ODENew(I64 n,F64 max_tolerance=1e-6,I64 flags=0)
{//Make differential equation ctrl struct. See $LK,"flags",A="MN:ODEF_HAS_MASSES"$.

//The tolerance is not precise.
//You can min_tolerance and it will
//dynamically adjust tolerance to utilize
//the CPU.

I64 s=n*sizeof(F64);
CMathODE *ode=MAlloc(sizeof(CMathODE));

ode->t=0;
CMathODE *ode=CAlloc(sizeof(CMathODE));
ode->t_scale=1.0;
ode->base_t=0;
ode->flags=flags;
ode->n_internal=ode->n=n;
ode->h=1e-6;
ode->h_min=1e-64;
ode->h_max=1e32;
ode->max_tolerance=ode->min_tolerance=ode->tolerance_internal=max_tolerance;
ode->win_task=ode->mem_task=Fs;
ode->derivative=NULL;
QueInit(&ode->next_mass);
QueInit(&ode->next_spring);
ode->acceleration_limit=ode->drag_v=ode->drag_v2=ode->drag_v3=0;

ode->state=CAlloc(s);
ode->array_base=MAlloc(12*s);
ODERstPtrs(ode);
return ode;
}


public Bool ODEPause(CMathODE *ode,Bool val=ON)
{//Pause ODE.
Bool res;
if (!ode) return OFF;
res=LBEqu(&ode->flags,ODEf_PAUSED,val);
if (val)
while (Bt(&ode->flags,ODEf_BUSY))
Yield;
return res;
}

public U0 ODEDel(CMathODE *ode)
{//Free ODE node, but not masses or springs.
I64 i;
if (!ode) return;
ODEPause(ode);
Free(ode->state);
Free(ode->array_base);
if (ode->slave_tasks) {
for (i=0;i<mp_cnt;i++)
Kill(ode->slave_tasks[i]);
Free(ode->slave_tasks);
}
Free(ode);
}

Expand Down Expand Up @@ -319,6 +330,53 @@ U0 ODEApplyAccelerationLimit(CMathODE *ode)
}
}

U0 ODEMPTask(CMathODE *ode)
{
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);
LBtr(&ode->mp_not_done_flags,Gs->num);
}
}

U0 ODEMPWake(CMathODE *ode)
{
I64 i;
if (!ode->slave_tasks) {
ode->slave_tasks=CAlloc(mp_cnt*sizeof(CTask *));
for (i=0;i<mp_cnt;i++)
ode->slave_tasks[i]=Spawn(&ODEMPTask,ode,"ODE Slave",i);
}
for (i=0;i<mp_cnt;i++) {
Suspend(ode->slave_tasks[i],FALSE);
MPInt(I_WAKE,i);
}
}

U0 ODEMPSleep(CMathODE *ode)
{
I64 i;
if (ode->slave_tasks) {
while (ode->mp_not_done_flags)
Yield;
for (i=0;i<mp_cnt;i++)
Suspend(ode->slave_tasks[i]);
}
}

U0 ODECallMPDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
{
ode->mp_t=t;
ode->mp_state=state;
ode->mp_DstateDt=DstateDt;
ode->mp_not_done_flags=1<<mp_cnt-1;
do Yield;
while (ode->mp_not_done_flags);
}

U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
{
CMass *tmpm;
Expand All @@ -334,7 +392,10 @@ U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
}
ODECalcSprings(ode);
ODECalcDrag(ode);
(*ode->derivative)(ode,t,state,DstateDt);
if (ode->mp_derive)
ODECallMPDerivative(ode,t,state,DstateDt);
if (ode->derive)
(*ode->derive)(ode,t,state,DstateDt);
tmpm=ode->next_mass;
while (tmpm!=&ode->next_mass) {
if (!(tmpm->flags&MSF_INACTIVE)) {
Expand All @@ -347,8 +408,12 @@ U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
tmpm=tmpm->next;
}
ODEApplyAccelerationLimit(ode);
} else
(*ode->derivative)(ode,t,state,DstateDt);
} else {
if (ode->mp_derive)
ODECallMPDerivative(ode,t,state,DstateDt);
if (ode->derive)
(*ode->derive)(ode,t,state,DstateDt);
}
}

U0 ODEOneStep(CMathODE *ode)
Expand Down Expand Up @@ -453,6 +518,7 @@ U0 ODECashKarp(CMathODE *ode)
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]);
Expand Down Expand Up @@ -499,7 +565,7 @@ U0 ODERK5OneStep(CMathODE *ode)
F64 ode_alloced_factor=0.75;

U0 ODEsUpdate(CTask *task)
{/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScrn.HC,ODEsUpdate"$ on a continuous
{/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScrn.HC,ODEsUpdate"$on a continuous
basis to allow real-time simulation. It is intended
to provide ress good enough for games. It uses a runge-kutta
integrator which is a better algorithm than doing it with Euler.
Expand Down Expand Up @@ -537,41 +603,54 @@ 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 if (ode->derivative) {
ODEState2Internal(ode);
MemCpy(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;
ODERK5OneStep(ode);
if (tS>timeout_time) {
ode->base_t+=t_desired-ode->t; //Slip
goto ode_done;
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) {
if (ode->mp_derive)
ODEMPWake(ode);
ODEState2Internal(ode);
MemCpy(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;
ODERK5OneStep(ode);
if (tS>timeout_time) {
ode->base_t+=t_desired-ode->t; //Slip
goto ode_done;

}
}

//Interpolate if end time was not exact.
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++)
ode->state_internal[i]=(ode->state_internal[i]-
ode->initial_state[i])*interpolation+
ode->initial_state[i];
}
ode->t=t_desired;
}
ode_done:
ODEInternal2State(ode);

}
}
//Convenience call to set vals
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);

//Interpolate if end time was not exact.
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++)
ode->state_internal[i]=(ode->state_internal[i]-
ode->initial_state[i])*interpolation+
ode->initial_state[i];
if (ode->mp_derive)
ODEMPSleep(ode);
}
ode->t=t_desired;
}
ode_done:
ODEInternal2State(ode);

//Convenience call to set vals
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
ode->flags&=~ODEF_BUSY;
}
ode->base_t+=(1.0-ode->t_scale)*d;
ode=ode->next;
Expand All @@ -592,7 +671,7 @@ ode_done:

ode=task->next_ode;
while (ode!=&task->next_ode) {
if (!(ode->flags&ODEF_PAUSED) && ode->derivative) {
if (!(ode->flags&ODEF_PAUSED) && ode->derive) {
if (ode->min_tolerance!=ode->max_tolerance) {
if (d>0)
ode->tolerance_internal*=10.0`d;
Expand Down
3 changes: 2 additions & 1 deletion Adam/DolDoc/DocExt.HC
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ extern Bool DocEd(CDoc *doc,I64 dof_flags=0);
extern I64 DocEntryRun(CDoc *doc,CDocEntry *doc_e,
Bool exited,I64 *_has_action=NULL);
extern U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE);
extern Bool DocGoToLine(CDoc *doc,I64 line_num);
extern U0 DocLoad(CDoc *doc,U8 *src2,I64 size);
extern U0 DocPrintAtomic(CDoc *doc=NULL,U8 *fmt,...);
extern U0 DocPrintPartial(CDoc *doc=NULL,U8 *fmt,...);
extern CDocEntry *DocPutS(CDoc *doc,U8 *st);
extern U8 *DocSave(CDoc *doc,I64 *_size=NULL);
extern I64 EdLeftClickLink(CDoc *doc,CDocEntry *doc_e);
extern U8 *PopUpPickLst(U8 *lst);
extern I64 PopUpPickLst(U8 *lst);
extern I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e);
29 changes: 29 additions & 0 deletions Adam/DolDoc/DocFile.HC
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,32 @@ public Bool Type(U8 *filename,I64 trailing_new_lines=1)
{//Output txt or graphic file to command line.
return DocType(,filename,trailing_new_lines);
}

#help_index "DolDoc/File"

public U8 *DocLineRead(U8 *filename,I64 line,CTask *mem_task=NULL)
{//Extract line from stored doc file. (Slow.)
U8 *res=NULL;
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);
if (DocGoToLine(doc,line) && doc->cur_entry->type_u8==DOCT_TEXT)
res=StrNew(doc->cur_entry->tag,mem_task);
DocDel(doc);
return res;
}

public U8 *DocLineWrite(U8 *filename,I64 line,U8 *st)
{//Write line to stored doc file. (Slow.)
U8 *res=NULL;
CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);
if (DocGoToLine(doc,line)) {
if (doc->cur_entry->type_u8==DOCT_TEXT) {
Free(doc->cur_entry->tag);
doc->cur_entry->tag=StrNew(st);
} else
DocPrint(doc,"%s",st);
DocTop(doc);
DocWrite(doc);
}
DocDel(doc);
return res;
}
19 changes: 19 additions & 0 deletions Adam/DolDoc/DocGet.HC
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public U8 *DocScanLine(CDoc *doc,CDocEntry *doc_e,
i+=StrLen(src);
} else if (doc_e2->type_u8==DOCT_TAB)
i++;
else if (doc_e2->type_u8==DOCT_SHIFTED_X ||
doc_e2->type_u8==DOCT_SHIFTED_Y) {
if (doc_e2->attr<0)
i++;
i+=6; //$$SY,3$$
}
doc_e2=doc_e2->next;
}
res=MAlloc(i+1);
Expand All @@ -63,6 +69,19 @@ public U8 *DocScanLine(CDoc *doc,CDocEntry *doc_e,
*dst++=*src++;
} else if (doc_e->type_u8==DOCT_TAB)
*dst++='\t';
else if (doc_e->type_u8==DOCT_SHIFTED_Y) {
*dst(U32 *)++='$$SY,';
if (doc_e->attr<0)
*dst++='-';
*dst++='0'+AbsI64(doc_e->attr); //Supposedly -7 to 7 (single digit)
*dst++='$$';
} else if (doc_e->type_u8==DOCT_SHIFTED_X) {
*dst(U32 *)++='$$SX,';
if (doc_e->attr<0)
*dst++='-';
*dst++='0'+AbsI64(doc_e->attr); //Supposedly -7 to 7 (single digit)
*dst++='$$';
}
if (doc_e==doc->cur_entry && cur_col)
*cur_col=start-res+doc->cur_col;
doc_e=doc_e->next;
Expand Down
8 changes: 4 additions & 4 deletions Adam/DolDoc/DocPopUp.HC
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ Bool PopUpCd()
}

#help_index "DolDoc/Input;Char/Lists;StdIn/DolDoc"
public U8 *PopUpPickLst(U8 *lst)
public I64 PopUpPickLst(U8 *lst)
{//Prompt for lst entry in PopUp win task.
I64 i=0;
I64 res,i=0;
CDoc *doc=DocNew;
DocPrint(doc,"$$LTBLUE$$");
while (*lst) {
Expand All @@ -101,9 +101,9 @@ public U8 *PopUpPickLst(U8 *lst)
lst+=StrLen(lst)+1;
}
DocPrint(doc,"\n$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n");
i=PopUpMenu(doc);
res=PopUpMenu(doc);
DocDel(doc);
return i;
return res;
}

#help_index "DolDoc/Input;Char/Lists;Char/Define;StdIn/DolDoc"
Expand Down
Loading

0 comments on commit 6028804

Please sign in to comment.