TempleOSCD_150720.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:22 +02:00
1 parent 401601816c
commit f8c05f98f4
554 files changed
+26046 -24853

No files matched your search

+14 -14
View File
@@ -2,24 +2,24 @@
class SpanHeader
{
F64 version;
I32 num_masses,num_springs;
F64 version;
I32 num_masses,num_springs;
};
class MyMass:CMass
{
F64 radius,cost,load_t;
CColorROPU32 color;
F64 radius,cost,load_t;
CColorROPU32 color;
} *cursor_mass;
class MySpring:CSpring
{
F64 compression_strength,tensile_strength,cost;
F64 base_compression_strength,base_tensile_strength,
base_const,base_cost;
CColorROPU32 color;
I32 pen_width;
F64 compression_strength,tensile_strength,cost;
F64 base_compression_strength,base_tensile_strength,
base_const,base_cost;
CColorROPU32 color;
I32 pen_width;
};
CMathODE *ode=NULL;
@@ -37,11 +37,11 @@ CColorROPU32 run_colors[2]={RED,GREEN};
#define MD_NUM_MODES 6
CColorROPU32 mode_colors[MD_NUM_MODES]=
{BROWN,LTGRAY,DKGRAY,RED,PURPLE,RED};
DefineLstLoad("ST_SPAN_MODES","Mass\0Concrete\0Steel\0Wire\0Move\0Delete\0");
DefineLstLoad("ST_SPAN_MODES","Mass\0Concrete\0Steel\0Wire\0Move\0Delete\0");
class SpanAnimateStruct
{
U8 *saved_ode;
class SpanAnimateStruct
{
U8 *saved_ode;
F64 elapsed_t,start_wall_t;
} a;
+1 -1
View File
@@ -39,7 +39,7 @@ U0 SpanBridge1Init(CMathODE *)
for (i=0;i<LOAD_WEIGHTS;i++) {
tempm=PlaceMass(FIXED_X1+(i+1)*(GR_WIDTH-2*FIXED_X1)/(LOAD_WEIGHTS+1),
FIXED_Y1);
FIXED_Y1);
tempm->load_t=(i+1.0)/LOAD_WEIGHTS;
tempm->color=RED;
}
+3 -3
View File
@@ -1,9 +1,9 @@
U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
{
//The forces due to springs and drag are
//automatically handled by the
//ode code. We can add new forces
//here.
//automatically handled by the
//ode code. We can add new forces
//here.
CTask *task=ode->win_task;
F64 d,dd;
CD3 p,p2;
+43 -49
View File
@@ -26,20 +26,16 @@ F64 Cost(CMathODE *ode)
U0 DrawIt(CTask *task,CDC *dc)
{
Bool old_suspend1,old_suspend2;
I64 i,j;
MyMass *tempm;
MySpring *temps;
old_suspend1=Suspend(task);
old_suspend2=Suspend(task->animate_task);
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
if (!(temps->flags&SSF_INACTIVE)) {
dc->color=temps->color;
dc->pen_width=temps->pen_width;
GrLine3(dc,temps->end1->x,temps->end1->y,0,
temps->end2->x,temps->end2->y,0);
temps->end2->x,temps->end2->y,0);
}
temps=temps->next;
}
@@ -47,8 +43,9 @@ U0 DrawIt(CTask *task,CDC *dc)
if (cursor_mass) {
dc->color=RED;
dc->pen_width=2;
GrLine3(dc,ip.pos.x-task->pix_left-task->scroll_x,ip.pos.y-task->pix_top-task->scroll_y,0,
cursor_mass->x,cursor_mass->y,0);
GrLine3(dc,ip.pos.x-task->pix_left-task->scroll_x,
ip.pos.y-task->pix_top-task->scroll_y,0,
cursor_mass->x,cursor_mass->y,0);
}
tempm=ode->next_mass;
@@ -69,8 +66,6 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=BLACK;
GrPrint(dc,90,0,"Cost:%12.2,f",Cost(ode));
GrPrint(dc,90,FONT_HEIGHT,"Time:%12.2f",SpanTime);
Suspend(task,old_suspend1);
Suspend(task->animate_task,old_suspend2);
}
MyMass PlaceMass(I64 x, I64 y)
@@ -91,7 +86,8 @@ U0 NullSpring(MySpring *temps,F64 scale)
{
F64 d=D3Dist(&temps->end1->x,&temps->end2->x);
temps->rest_len=d*scale;
temps->compression_strength=temps->base_compression_strength/(temps->rest_len+1.0);
temps->compression_strength=
temps->base_compression_strength/(temps->rest_len+1.0);
temps->tensile_strength=temps->base_tensile_strength/(temps->rest_len+1.0);
temps->const=temps->base_const/(temps->rest_len+1.0);
temps->cost=temps->base_cost*temps->rest_len;
@@ -203,8 +199,10 @@ U0 AnimateTask(SpanAnimateStruct *a)
while (temps!=&ode->next_spring) {
temps1=temps->next;
f=temps->f;
if (f>0 && f>temps->compression_strength && !(temps->flags&SSF_NO_COMPRESSION)||
f<0 && -f>temps->tensile_strength && !(temps->flags&SSF_NO_TENSION))
if (f>0 && f>temps->compression_strength &&
!(temps->flags&SSF_NO_COMPRESSION)||
f<0 && -f>temps->tensile_strength &&
!(temps->flags&SSF_NO_TENSION))
temps->flags|=SSF_INACTIVE;
temps=temps1;
}
@@ -250,10 +248,10 @@ U0 SongTask(I64)
music.tempo= 3.636;
music.stacatto_factor= 0.902;
while (TRUE) {
Play("3q.EeDqED2G3DhE");
Play("q.EeDqED2G3DhE");
Play("q.FeEFEqF2G3EhF");
Play("q.FeEFEqF2G3EhF");
Play("3q.EeDqED2G3DhE");
Play("q.EeDqED2G3DhE");
Play("q.FeEFEqF2G3EhF");
Play("q.FeEFEqF2G3EhF");
}
}
@@ -271,22 +269,17 @@ U0 Span()
WinMax;
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
bt_run =CtrlButtonNew(0,0, 80,,2,"Stopped\0Running\0",run_colors,&run_button);
bt_mode=CtrlButtonNew(0,3.0*FONT_HEIGHT,80,,MD_NUM_MODES,Define("ST_SPAN_MODES"),mode_colors,&mode_button);
bt_run =CtrlButtonNew(0,0, 80,,
2,"Stopped\0Running\0",run_colors,&run_button);
bt_mode=CtrlButtonNew(0,3.0*FONT_HEIGHT,80,,
MD_NUM_MODES,Define("ST_SPAN_MODES"),mode_colors,&mode_button);
a.saved_ode=NULL;
//Preempt(OFF) eliminates a lot of hassles.
//The concern is about changing
//que links while the winmgr task
//is updating the ode or screen.
//The Window mgr suspends this
//task while updating the ode. It
//will not be interrupted and with this
//preempt, we will not be interrupted.
//There is little downside to Preempt()
//since we will yield during GetMsg().
Preempt(OFF);
//Preempt eliminates a lot of hassles.
//The concern is about changing
//que links while the winmgr task
//is updating the ode or screen.
Preempt;
DocCursor;
WinBorder;
@@ -294,24 +287,24 @@ U0 Span()
Fs->win_inhibit|=WIG_DBL_CLICK;
MenuPush(
"File {"
" New(,CH_CTRLN);"
" Open(,CH_CTRLO);"
" SaveAs(,CH_CTRLA);"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" RunStop(,CH_SPACE);"
" Mass(,'m');"
" Concrete(,'c');"
" Steel(,'s');"
" Wire(,'w');"
" Move(,'v');"
" Delete(,'d');"
"}"
);
"File {"
" New(,CH_CTRLN);"
" Open(,CH_CTRLO);"
" SaveAs(,CH_CTRLA);"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,'\n');"
" RunStop(,CH_SPACE);"
" Mass(,'m');"
" Concrete(,'c');"
" Steel(,'s');"
" Wire(,'w');"
" Move(,'v');"
" Delete(,'d');"
"}"
);
ode=NULL;
Init(&a);
@@ -336,7 +329,8 @@ U0 Span()
try {
while (TRUE) {
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_L_UP|1<<MSG_KEY_DOWN|1<<MSG_IP_MOVE);
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|
1<<MSG_IP_L_UP|1<<MSG_KEY_DOWN|1<<MSG_IP_MOVE);
DCFill(dc);
switch (msg_code) {
case MSG_IP_L_DOWN: