TempleOSCDV3.11.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:29 +02:00
1 parent f8c05f98f4
commit ed64d7e3b8
549 files changed
+10643 -12855

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4 -3
View File
@@ -186,6 +186,7 @@ U0 DrawIt(CTask *task,CDC *dc)
Mat4x4RotX(r3,-ã/2);
Mat4x4Scale(r3,PLANT_SCALE);
Seed(1);
x1h=man_xx+yh*PLOT_GRID_WIDTH/2+xh*(PLOT_GRID_HEIGHT-1);
y1h=man_yy-xh*PLOT_GRID_WIDTH/2+yh*(PLOT_GRID_HEIGHT-1);
xh>>=1; yh>>=1;
@@ -370,6 +371,7 @@ U0 DrawIt(CTask *task,CDC *dc)
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",
monsters_left,tt-t0,best_score);
Free(s2w);
Seed(0);
}
U0 Fire()
@@ -541,14 +543,13 @@ U0 CastleFrankenstein()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=DKGRAY<<4+WHITE;
Preempt;
AutoComplete;
WinBorder;
WinMax;
AutoComplete;
DocCursor;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
DocCursor;
Fs->draw_it=&DrawIt;
try {
+5 -3
View File
@@ -1,6 +1,6 @@
//Practice tracing circles
//Giotto, a famous artist, drew a freehand circle as a portfolio for a job.
//Giotto, a famous artist, drew a freehand circle to get a job.
RegSetDftEntry("TempleOS/CircleTrace","F64 best_score=999;\n");
RegExeBranch("TempleOS/CircleTrace");
@@ -42,13 +42,15 @@ U0 CircleTrace()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
cx=Fs->pix_width/2;
cy=Fs->pix_height/2;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
DCFill;
Binary file not shown.
+4 -4
View File
@@ -334,13 +334,13 @@ U0 DunGen()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
Preempt;
WinMax;
AutoComplete;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
WinBorder;
WinMax;
DocCursor;
DocClear;
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
Fs->draw_it=&DrawIt;
try {
+18 -16
View File
@@ -500,7 +500,6 @@ U0 MPDrawIt(CTask *task,CDC *dc)
U0 APEagleDiveTask(CTask *master_task)
{
CDC *dc=DCAlias(main_dc,master_task);
Preempt(ON);
while (!mp.app_done) {
while (!Bt(&mp.update_not_done_flags,Gs->num) && !mp.app_done)
Sleep(1);
@@ -609,10 +608,8 @@ U0 DrawHorizon(CDC *dc)
U0 BSPEagleDive()
{
CDC *dc=DCAlias(main_dc,Fs);
I64 i,xx,yy,height,bkcolor,
cx=Fs->pix_width>>1,
cy=Fs->pix_height>>1;
F64 min_strip_width;
I64 i,xx,yy,height,bkcolor,cx=Fs->pix_width>>1,cy=Fs->pix_height>>1;
F64 min_strip_width,roll,pitch,heading;
Fish *tempf;
update_jiffy_limit=cnts.jiffies+JIFFY_FREQ/40;
@@ -673,13 +670,18 @@ U0 BSPEagleDive()
dc->flags&=~DCF_TRANSFORMATION;
GrLine3(dc,cx+5,cy,0,cx-5,cy,0);
GrLine3(dc,cx,cy+5,0,cx,cy-5,0);
GrPrint(dc,0,0,"é1:%5.1f è:%5.1f é2:%5.1f Strip:%5d",
é1*180/ã,è*180/ã,é2*180/ã,strip_height);
GrPrint(dc,0,FONT_HEIGHT,
"x:%5.1f y:%5.1f z:%5.1f height:%3d score:%d high:%d",
ToF64(x)/COORDINATE_SCALE,
ToF64(y)/COORDINATE_SCALE,ToF64(z)/COORDINATE_SCALE,
height,game_score,best_score);
heading=Wrap(é2,0);
roll=é1;
pitch=Wrap(-è-ã/2,-ã);
if (Abs(pitch)>ã/2) {
pitch=Wrap(ã-pitch,-ã);
roll=Wrap(roll+ã,-ã);
heading=Wrap(heading+ã,0);
}
GrPrint(dc,0,0,"Roll:%5.1f Pitch:%5.1f Heading:%5.1f",
roll*180/ã,pitch*180/ã,heading*180/ã);
GrPrint(dc,0,FONT_HEIGHT,"Height:%5d Score:%d High:%d [Core Strip:%3d]",
height,game_score,best_score,strip_height);
if (game_over && Blink) {
dc->color=RED;
@@ -840,7 +842,6 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
F64 pp,tt1,tt2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
AutoComplete;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
@@ -854,14 +855,15 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
WinMax;
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
"Initializing...\n";
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Init(_mp_cnt);
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try //in case <CTRL-ALT-c> is pressed.
do {
Binary file not shown.
Binary file not shown.
+4 -7
View File
@@ -162,7 +162,6 @@ U0 DrawIt(CTask *task,CDC *dc)
F64 d,cur_time=tS;
Obj *tempo;
Torpedo *tempt;
Bool old_preempt=Preempt;
tempt=torpedo_root.next;
while (tempt!=&torpedo_root) {
@@ -272,7 +271,6 @@ U0 DrawIt(CTask *task,CDC *dc)
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
}
}
Preempt(old_preempt);
}
U0 Init()
@@ -693,7 +691,7 @@ U0 Combat(F64 period)
#define ANIMATE_FREQ 50
U0 AnimateTask(I64)
{//Preemption is off after Spawn
{
Obj *tempo;
Torpedo *tempt,*tempt1;
F64 d,period;
@@ -787,17 +785,16 @@ U0 FlatTops()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLUE<<4+WHITE;
WinMax;
WinBorder;
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
PopUpOk("$$GREEN$${Left-Mouse}$$FG$$\t\tChange Course\n"
"$$GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
"$$GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Screen\n");
Preempt,
MenuPush(
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
+2 -4
View File
@@ -12,7 +12,6 @@ U0 DrawIt(CTask *task,CDC *dc)
{
I64 w=task->pix_width,h=task->pix_height;
I64 i,x,y,xx;
Bool old_preempt=Preempt;
xx=w>>1-car_x+road_x[road_ptr&(NUM_ROAD-1)];
dc->color=LTGRAY;
@@ -40,7 +39,6 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=YELLOW;
if (crash)
GrPrint(dc,w>>1-FONT_WIDTH*4,(h-FONT_HEIGHT)>>1,"Game Over");
Preempt(old_preempt);
}
U0 UpdateRoad()
@@ -94,11 +92,11 @@ U0 Halogen()
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
Preempt;
AutoComplete;
WinBorder;
WinMax;
Init;
DocCursor;
Init;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
+4 -17
View File
@@ -107,24 +107,13 @@ U0 MassSpringDemo()
"connect with spring.\n\n"
"Springs are 100 pixs long.\n");
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
AutoComplete;
WinBorder;
WinMax;
/*Preempt 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;
DocCursor;
DocClear;
Fs->win_inhibit|=WIG_DBL_CLICK;
AutoComplete;
MenuPush(
"File {"
@@ -137,8 +126,6 @@ since we will yield during GetMsg().
);
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
+2 -2
View File
@@ -79,9 +79,9 @@ U0 Maze()
I64 ch,x,y;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
WinBorder;
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
+4 -5
View File
@@ -56,13 +56,11 @@ U0 DrawDrops(CTask *,CDC *dc)
U0 UpdateCurBase(CTask *task,CDC *dc)
{
Bool old_preempt=Preempt;
cur_dc->color=ROP_EQU;
dc->flags|=DCF_NO_TRANSPARENTS;
GrBlot(cur_dc,-task->pix_left-task->scroll_x,
-task->pix_top-task->scroll_y,dc);
dc->flags&=~DCF_NO_TRANSPARENTS;
Preempt(old_preempt);
}
U0 DrawIt(CTask *task,CDC *dc)
@@ -162,16 +160,17 @@ U0 RainDrops()
"}"
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
AutoComplete;
WinBorder;
WinMax;
DocCursor;
DocClear;
cur_dc=DCNew(GR_WIDTH,GR_HEIGHT);
sc_1=Char2ScanCode('1');
sc_2=Char2ScanCode('2');
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
AutoComplete;
try {
do
switch (ch=GetKey(&sc)) {
+66 -13
View File
@@ -13,6 +13,10 @@ I64 outside_cnt;
#define MAP_BORDER 3
CDC *map_dc;
#define GATE_WIDTH 22
#define GATE_HEIGHT 7
F64 gate_é,gate_t;
$BG,10$#define GE_COW 0
@@ -153,8 +157,7 @@ U0 RiverDropsNext(CTask *mem_task)
Free(tempr);
} else {
do {
if (RandU16&1 &&
GrPeek(map_dc,r_x[tempr->index]+tempr->dx,
if (RandU16&1 && GrPeek(map_dc,r_x[tempr->index]+tempr->dx,
r_y[tempr->index]+tempr->dy)==BLUE)
break;
tempr->dx=ClampI64(tempr->dx+RandU16%3-1,-r_width[tempr->index]/2,
@@ -271,6 +274,52 @@ U0 BuddySelect(I64 i)
a[i].buddy=best_b;
}
U0 RedrawGate()
{
F64 tt=tS-gate_t;
I64 x1=FENCE_WIDTH-63,y1=FENCE_HEIGHT-1,dx,dy;
if (tt<0.5)
gate_é=Clamp(gate_é+0.02,0,ă/2);
else if (tt>5.0)
gate_é=Clamp(gate_é-0.02,0,ă/2);
dx=GATE_WIDTH*Cos(gate_é); dy=-0.8*GATE_WIDTH*Sin(gate_é);
map_dc->color=LTGREEN;
GrRect(map_dc,x1,y1-0.8*GATE_WIDTH-GATE_HEIGHT,
46,0.8*GATE_WIDTH+GATE_HEIGHT+3);
map_dc->color=BLACK;
GrLine(map_dc,x1,y1,x1+dx,y1+dy);
GrLine(map_dc,x1,y1,x1,y1-GATE_HEIGHT);
GrLine(map_dc,x1+dx,y1+dy,x1+dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1,y1-GATE_HEIGHT,x1+dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1,y1,x1+dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1,y1-GATE_HEIGHT,x1+dx,y1+dy);
GrLine(map_dc,x1+45,y1,x1+45-dx,y1+dy);
GrLine(map_dc,x1+45,y1,x1+45,y1-GATE_HEIGHT);
GrLine(map_dc,x1+45-dx,y1+dy,x1+45-dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1+45,y1-GATE_HEIGHT,x1+45-dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1+45,y1,x1+45-dx,y1+dy-GATE_HEIGHT);
GrLine(map_dc,x1+45,y1-GATE_HEIGHT,x1+45-dx,y1+dy);
}
Bool CheckMap(I64 x,I64 y)
{
I64 i,j,c;
for (j=-4;j<=2;j++)
for (i=-4;i<=4;i++) {
c=GrPeek(map_dc,x+i,y+j);
if (c==LTGRAY || c==BLACK)
return FALSE;
}
return TRUE;
}
U0 AnimateTask(CTask *parent)
{
I64 i,cx,cy,cursor_x,cursor_y,dd,ddx,ddy,cnt,max_speed=MAX_I64,updates=0,
@@ -285,6 +334,9 @@ U0 AnimateTask(CTask *parent)
cursor_y=ip.pos.y+cy-parent->pix_top -parent->scroll_y;
cnt=0;stress=0;
my_outside_cnt=0;
if (cursor_x<FENCE_WIDTH && cursor_y<FENCE_HEIGHT)
gate_t=tS;
RedrawGate;
for (i=0;i<NUM_ANIMALS;i++) {
tempa=&a[i];
if (!tempa->dead) {
@@ -335,8 +387,7 @@ U0 AnimateTask(CTask *parent)
tempa->dy/=2;
}
if (GrPeek(map_dc,(tempa->x+tempa->dx)>>32,(tempa->y+tempa->dy)>>32)
!=LTGRAY) {
if (CheckMap((tempa->x+tempa->dx)>>32,(tempa->y+tempa->dy)>>32)) {
tempa->x+=tempa->dx;
tempa->y+=tempa->dy;
}
@@ -420,9 +471,7 @@ U0 ReInit()
GrLine(map_dc,FENCE_WIDTH-1,i,FENCE_WIDTH-1,i+7);
map_dc->color=LTGRAY;
GrLine(map_dc,FENCE_WIDTH,0,FENCE_WIDTH,FENCE_HEIGHT-6);
map_dc->color=LTGREEN;
GrRect(map_dc,FENCE_WIDTH-63,FENCE_HEIGHT-8,46,9);
RedrawGate;
map_dc->pen_width=MAP_BORDER;
map_dc->color=RED;
@@ -435,8 +484,10 @@ U0 ReInit()
MemSet(a,0,NUM_ANIMALS*sizeof(Animal));
for (i=0;i<NUM_ANIMALS;i++) {
a[i].num=i;
a[i].x=(64+RandU32%(MAP_WIDTH-128))<<32;
a[i].y=(64+RandU32%(MAP_WIDTH-128))<<32;
do {
a[i].x=(64+RandU32%(MAP_WIDTH-128))<<32;
a[i].y=(64+RandU32%(MAP_WIDTH-128))<<32;
} while (!CheckMap(a[i].x>>32,a[i].y>>32));
if (i&1)
a[i].ge=&rh_sprite[GE_COW];
else
@@ -444,6 +495,8 @@ U0 ReInit()
BuddySelect(i);
}
outside_cnt=NUM_ANIMALS;
gate_t=0;
gate_é=0;
t0=tS;
tf=0;
}
@@ -497,13 +550,13 @@ U0 RawHide()
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
WinMax;
AutoComplete;
Preempt;
Init;
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",,Fs);
WinBorder;
WinMax;
DocCursor;
DocClear;
Init;
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",,Fs);
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -6,13 +6,13 @@ U0 StadiumGen()
CDC *dc,*dc2;
Cd(__DIR__);
WinMax;
WinBorder;
AutoComplete;
WinBorder;
WinMax;
DocCursor(OFF);
DocClear;
Type("StadiumBG.TXT");
"$$CM,0,%d$$",TEXT_ROWS-3;
DocCursor(OFF);
fp_old_update=gr.fp_final_screen_update; //hide mouse cursor
gr.fp_final_screen_update=NULL;
Binary file not shown.
+10 -6
View File
@@ -204,12 +204,15 @@ CDC *DrawHexMap(I64 *_w,I64 *_h)
U0 Init()
{
I64 i,j,j1,j2,dd,best_dd,best,w=Fs->pix_width,h=Fs->pix_height;
map_dc=DrawHexMap(&w,&h);
cur_player=0;
for (i=0;i<NUM_UNITS/2;i++) {
u[i].num=i;
u[i+NUM_UNITS/2].num=i+NUM_UNITS/2;
ti_restart:
u[i].y=FloorI64(RandU32%h,CIRCLE_RAD*2)+CIRCLE_RAD;
u[i+NUM_UNITS/2].y=h-1-u[i].y;
j1=u[i].y/(CIRCLE_RAD*2);
@@ -217,11 +220,14 @@ U0 Init()
u[i].y+=BORDER_Y;
u[i+NUM_UNITS/2].y+=BORDER_Y;
if (!i)
if (!i) {
u[i].x=CIRCLE_RAD;
else
if (j1&1)
goto ti_restart;
} else
u[i].x=FloorI64(RandU32%((w-CIRCLE_RAD*2*2)/2),CIRCLE_RAD*2)+CIRCLE_RAD;
u[i+NUM_UNITS/2].x=w-1-u[i].x;
if (j1&1)
u[i].x+=CIRCLE_RAD;
if (j2&1)
@@ -281,7 +287,6 @@ U0 TreeCheckers()
Unit *tempu;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Preempt;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
@@ -291,10 +296,9 @@ U0 TreeCheckers()
" Restart(,'\n');"
"}"
);
WinMax;
WinBorder;
AutoComplete;
Preempt;
WinBorder;
WinMax;
DocCursor;
DocClear;
PopUpOk("Step on the link mid points.\n");
+319 -130
View File
@@ -93,6 +93,29 @@ RegExeBranch("TempleOS/Varoom");
F64 distance,t0,tf;
Bool game_over;
#define BORDER 7500
#define R 10000
#define WIDTH 2000
#define SHOULDER 200
#define D_é (2*ã/360) //Curve track slice is one degree.
#define D_S (2*ã*R/360) //Straight track slice is degree at 10000.
#define DIPS 5
#define DIP_DEPTH 50
class Track
{
Track *next,*last;
I32 num;
CColorROPU16 c,pad;
I64 x,z;
F64 é,d;
CD3I32 left[4],center[4],right[4];
} track_root,
*track_start[MP_MAX_PROCESSORS],*track_end[MP_MAX_PROCESSORS];
CDC *track_map;
#define MAP_BITS 9
I64 t_minx,t_maxx,t_minz,t_maxz;
#define NUM_BUSHES 512
class Bush
{
@@ -105,29 +128,16 @@ class Bush
class Car
{
CD3I32 p;
F64 é,speed;
F64 é,dé,speed;
CSprite *img;
Track *t;
} c[NUM_CARS];
#define TRACK_INNER 16000
#define TRACK_OUTER 18000
#define SHOULDER 200
#define SLICES 500
#define D_é (2*ã/SLICES)
#define TRACK_POLYS (3*SLICES)
#define DIPS 5
#define DIP_DEPTH 100
class TrackPoly
{
CColorROPU16 c,pad[3];
CD3I32 p[4];
} track[TRACK_POLYS];
I64 DipY(I64 x,I64 z)
{
F64 m,a;
R2P(&m,&a,x,z);
return DIP_DEPTH*m*Cos(DIPS*a)/((TRACK_INNER+TRACK_OUTER)/2);
return DIP_DEPTH*m*Cos(DIPS*a)/R;
}
#define CAR_LENGTH 400
@@ -140,62 +150,210 @@ F64 Dip
return ASin((y_front-y_back)/CAR_LENGTH);
}
U0 InitTrackPoly(TrackPoly *tempt,CColorROPU16 c,
I64 inner,I64 outer,F64 é1,F64 é2)
Track *TrackFind(Track *_tempt,I64 x,I64 z)
{
tempt->c=c;
tempt->p[0].x=inner*Cos(é1);
tempt->p[0].z=inner*Sin(é1);
tempt->p[0].y=DipY(tempt->p[0].x,tempt->p[0].z);
tempt->p[1].x=outer*Cos(é1);
tempt->p[1].z=outer*Sin(é1);
tempt->p[1].y=DipY(tempt->p[1].x,tempt->p[1].z);
tempt->p[2].x=outer*Cos(é2);
tempt->p[2].z=outer*Sin(é2);
tempt->p[2].y=DipY(tempt->p[2].x,tempt->p[2].z);
tempt->p[3].x=inner*Cos(é2);
tempt->p[3].z=inner*Sin(é2);
tempt->p[3].y=DipY(tempt->p[3].x,tempt->p[3].z);
Track *result=_tempt,*tempt;
I64 dd,best=SqrI64(result->x-x)+SqrI64(result->z-z);
tempt=_tempt;
while (TRUE) {
tempt=tempt->next;
if (tempt==&track_root)
tempt=tempt->next;
dd=SqrI64(tempt->x-x)+SqrI64(tempt->z-z);
if (dd<best) {
best=dd;
result=tempt;
} else
break;
}
tempt=_tempt;
while (TRUE) {
tempt=tempt->last;
if (tempt==&track_root)
tempt=tempt->last;
dd=SqrI64(tempt->x-x)+SqrI64(tempt->z-z);
if (dd<best) {
best=dd;
result=tempt;
} else
break;
}
return result;
}
U0 TrackSlice(F64 *_x,F64 *_z,F64 é,F64 d)
{
F64 x=*_x,z=*_z,c=Cos(é),s=Sin(é),dx=d*s,dz=-d*c;
Track *tempt,*last=track_root.last;
if (last==&track_root)
last=NULL;
tempt=CAlloc(sizeof(Track));
if (last) {
MemCpy(&tempt->center[0],&last->center[3],sizeof(CD3I32));
MemCpy(&tempt->center[1],&last->center[2],sizeof(CD3I32));
}
tempt->center[2].x=x+(WIDTH/2)*c+dx;
tempt->center[2].z=z+(WIDTH/2)*s+dz;
tempt->center[2].y=DipY(tempt->center[2].x,tempt->center[2].z);
tempt->center[3].x=x-(WIDTH/2)*c+dx;
tempt->center[3].z=z-(WIDTH/2)*s+dz;
tempt->center[3].y=DipY(tempt->center[3].x,tempt->center[3].z);
if (last) {
MemCpy(&tempt->left[0],&last->left[3],sizeof(CD3I32));
MemCpy(&tempt->left[1],&last->left[2],sizeof(CD3I32));
}
tempt->left[2].x=x-(WIDTH/2)*c+dx;
tempt->left[2].z=z-(WIDTH/2)*s+dz;
tempt->left[2].y=DipY(tempt->left[2].x,tempt->left[2].z);
tempt->left[3].x=x-(WIDTH/2+SHOULDER)*c+dx;
tempt->left[3].z=z-(WIDTH/2+SHOULDER)*s+dz;
tempt->left[3].y=DipY(tempt->left[3].x,tempt->left[3].z);
if (last) {
MemCpy(&tempt->right[0],&last->right[3],sizeof(CD3I32));
MemCpy(&tempt->right[1],&last->right[2],sizeof(CD3I32));
}
tempt->right[2].x=x+(WIDTH/2+SHOULDER)*c+dx;
tempt->right[2].z=z+(WIDTH/2+SHOULDER)*s+dz;
tempt->right[2].y=DipY(tempt->right[2].x,tempt->right[2].z);
tempt->right[3].x=x+(WIDTH/2)*c+dx;
tempt->right[3].z=z+(WIDTH/2)*s+dz;
tempt->right[3].y=DipY(tempt->right[3].x,tempt->right[3].z);
tempt->x=x;
tempt->z=z;
tempt->é=é;
tempt->num=track_root.last->num+1;
tempt->d =track_root.last->d+d;
QueIns(tempt,track_root.last);
if (tempt->num&1)
tempt->c=RED;
else
tempt->c=WHITE;
if (x<t_minx) t_minx=x;
if (x>t_maxx) t_maxx=x;
if (z<t_minz) t_minz=z;
if (z>t_maxz) t_maxz=z;
x+=dx;
*_x=x;
z+=dz;
*_z=z;
if (x<t_minx) t_minx=x;
if (x>t_maxx) t_maxx=x;
if (z<t_minz) t_minz=z;
if (z>t_maxz) t_maxz=z;
}
U0 CoupleEnds()
{
Track *first=track_root.next,*last=track_root.last;
MemCpy(&first->center[0],&last->center[3],sizeof(CD3I32));
MemCpy(&first->center[1],&last->center[2],sizeof(CD3I32));
MemCpy(&first->left[0] ,&last->left[3] ,sizeof(CD3I32));
MemCpy(&first->left[1] ,&last->left[2] ,sizeof(CD3I32));
MemCpy(&first->right[0] ,&last->right[3] ,sizeof(CD3I32));
MemCpy(&first->right[1] ,&last->right[2] ,sizeof(CD3I32));
}
U0 InitTrack()
{
TrackPoly *tempt=track;
I64 i;
for (i=0;i<SLICES;i++) {
InitTrackPoly(tempt++,DKGRAY,TRACK_INNER,TRACK_OUTER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
if (i&1) {
InitTrackPoly(tempt++,RED,TRACK_INNER-SHOULDER,TRACK_INNER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
InitTrackPoly(tempt++,WHITE,TRACK_OUTER,TRACK_OUTER+SHOULDER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
} else {
InitTrackPoly(tempt++,WHITE,TRACK_INNER-SHOULDER,TRACK_INNER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
InitTrackPoly(tempt++,RED,TRACK_OUTER,TRACK_OUTER+SHOULDER,
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
}
I64 i,j;
Track *tempt;
F64 x,z,é,d;
MemSet(&track_root,0,sizeof(Track));
QueInit(&track_root);
t_minx=t_minz=MAX_I64;
t_maxx=t_maxz=MIN_I64;
x=0; z=0; é=0;
for (d=0;d<6*R;d+=D_S)
TrackSlice(&x,&z,é,D_S);
for (i=0;i<180;i++,é+=D_é)
TrackSlice(&x,&z,é,D_é*R);
for (d=0;d<R;d+=D_S)
TrackSlice(&x,&z,é,D_S);
for (i=0;i<90;i++,é-=D_é)
TrackSlice(&x,&z,é,D_é*R);
for (i=0;i<180;i++,é+=D_é)
TrackSlice(&x,&z,é,D_é*R);
for (i=0;i<90;i++,é-=D_é)
TrackSlice(&x,&z,é,D_é*R);
for (d=0;d<R;d+=D_S)
TrackSlice(&x,&z,é,D_S);
for (i=0;i<180;i++,é+=D_é)
TrackSlice(&x,&z,é,D_é*R);
CoupleEnds;
tempt=track_root.next;
for (i=0;i<mp_cnt;i++) {
j=(i+1)*track_root.last->num/mp_cnt+1;
track_start[i]=tempt;
while (tempt!=&track_root && tempt->num!=j)
tempt=tempt->next;
track_end[i]=tempt;
}
t_minx-=BORDER; t_minz-=BORDER;
t_maxx+=BORDER; t_maxz+=BORDER;
track_map=DCNew((t_maxx-t_minx+1<<MAP_BITS-1)>>MAP_BITS,
(t_maxz-t_minz+1<<MAP_BITS-1)>>MAP_BITS);
track_map->color=LTGRAY;
GrRect(track_map,0,0,track_map->width,track_map->height);
tempt=track_root.next;
track_map->color=YELLOW;
track_map->pen_width=3;
while (tempt!=&track_root) {
GrPlot3(track_map,track_map->width-(tempt->x-t_minx)>>MAP_BITS,
(tempt->z-t_minz)>>MAP_BITS,0);
tempt=tempt->next;
}
}
#define HORIZON_DIP 200
Bool PrepPoly(CD3I32 *p,I64 *r,I64 cx,I64 h,CD3I32 *poly)
{
I64 x,y,z,i;
F64 s;
for (i=0;i<4;i++) {
x=p[i].x-c[0].p.x;
y=p[i].y-c[0].p.y;
z=p[i].z-c[0].p.z;
Mat4x4MulXYZ(r,&x,&y,&z);
s=100.0/(AbsI64(z)+50);
poly[i].y=s*y+h;
if (z<-200 || !(-h<poly[i].y<2*h))
return FALSE;
poly[i].x=s*x+cx;
poly[i].z=z+GR_Z_ALL;
}
return TRUE;
}
I64 mp_not_done_flags;
U0 MPUpdateWin(CDC *dc2)
{
CTask *task=dc2->win_task;
I64 i,j,x,y,z,lo,hi,
w=task->pix_width,
h=task->pix_height,r[16],
cx=w>>1;
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc;
Bool draw;
I64 i,x,y,z,
w=task->pix_width,h=task->pix_height,r[16],cx=w>>1;
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc;
CD3I32 poly[4];
TrackPoly *tempt;
CDC *dc=DCAlias(gr.dc2,task);
Track *tempt,*tempt1;
CDC *dc=DCAlias(gr.dc2,task);
Mat4x4IdentEqu(r);
Mat4x4RotY(r,ă-c[0].é);
@@ -204,27 +362,19 @@ U0 MPUpdateWin(CDC *dc2)
dc->depth_buf=dc2->depth_buf;
//Track
lo=Gs->num*TRACK_POLYS/mp_cnt;
hi=(Gs->num+1)*TRACK_POLYS/mp_cnt;
for (i=lo,tempt=&track[lo];i<hi;i++,tempt++) {
dc->color=tempt->c;
draw=TRUE;
for (j=0;j<4;j++) {
x=tempt->p[j].x-c[0].p.x;
y=tempt->p[j].y-c[0].p.y;
z=tempt->p[j].z-c[0].p.z;
Mat4x4MulXYZ(r,&x,&y,&z);
s=100.0/(AbsI64(z)+50);
poly[j].y=s*y+h;
if (z<-200 || !(-h<poly[j].y<2*h)) {
draw=FALSE;
break;
}
poly[j].x=s*x+cx;
poly[j].z=z+GR_Z_ALL;
}
if (draw)
tempt =track_start[Gs->num];
tempt1=track_end [Gs->num];
while (tempt!=tempt1) {
dc->color=DKGRAY;
if (PrepPoly(&tempt->center,r,cx,h,poly)) {
GrFillPoly3(dc,4,poly);
dc->color=tempt->c;
if (PrepPoly(&tempt->left,r,cx,h,poly))
GrFillPoly3(dc,4,poly);
if (PrepPoly(&tempt->right,r,cx,h,poly))
GrFillPoly3(dc,4,poly);
}
tempt=tempt->next;
}
dc->flags|=DCF_TRANSFORMATION;
@@ -278,11 +428,12 @@ U0 VRTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,x,y,z,
I64 i,x,y,z,
w=task->pix_width,
h=task->pix_height,r[16],
cx=w>>1;
F64 s,è,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc=&c[0];
dc->color=LTCYAN;
GrRect(dc,0,0,w,HORIZON_DIP*Sin(dip_é)+FONT_HEIGHT*4.5);
@@ -310,14 +461,8 @@ U0 DrawIt(CTask *task,CDC *dc)
while (mp_not_done_flags)
Yield;
if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT))
è=-0.5;
else if (Bt(kbd.down_bitmap,SC_CURSOR_RIGHT))
è=0.5;
else
è=0;
Mat4x4IdentEqu(r);
Mat4x4RotY(r,è);
Mat4x4RotY(r,tempc->dé);
Mat4x4RotX(r,0.4-8*dip_é); //Made this up
dc->transform=&VRTransform;
dc->x=task->pix_width>>1;
@@ -326,12 +471,7 @@ U0 DrawIt(CTask *task,CDC *dc)
SpriteMat3B(dc,0,0,-100,c[0].img,r);
//Map
dc->color=LTGRAY;
GrRect(dc,w-64,h-64,64,64);
dc->color=LTGREEN;
for (i=0;i<NUM_BUSHES;i++)
GrPlot(dc,w-64+64*(0x5000-b[i].p.x)/0xA000,
h-64*(-b[i].p.z+0x5000)/0xA000);
GrBlot(dc,w-track_map->width,h-track_map->height,track_map);
dc->pen_width=2;
for (i=0;i<NUM_CARS;i++) {
@@ -339,8 +479,8 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=LTPURPLE;
else
dc->color=LTCYAN;
GrPlot3(dc,w-64+64*(0x5000-c[i].p.x)/0xA000,
h-64*(-c[i].p.z+0x5000)/0xA000,0);
GrPlot3(dc,w-(c[i].p.x-t_minx)>>MAP_BITS,
h-track_map->height+(c[i].p.z-t_minz)>>MAP_BITS,0);
}
if (game_over) {
@@ -357,44 +497,58 @@ U0 DrawIt(CTask *task,CDC *dc)
} else
s=tS-t0;
dc->color=BLACK;
GrPrint(dc,0,0,"é:%0.1f %0.1f%% Time:%0.2f Best:%0.2f",
180+180/ã*Arg(c[0].p.x,c[0].p.z),
100.0*distance/(2*ã*TRACK_INNER),s,best_score);
GrPrint(dc,0,0,"%0.1f%% Time:%0.2f Best:%0.2f",
100.0*distance/track_root.last->d,s,best_score);
}
U0 AnimateTask(I64)
{
Car *tempc;
I64 i;
F64 m,a;
I64 i,x,z;
Bool on_track;
Track *tempt,*tempt2;
while (TRUE) {
if (!game_over)
Snd(c[0].speed*3+10);
Snd(0.01*c[0].speed*3+10);
else
Snd(0);
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
tempc->p.x-=tempc->speed*Cos(tempc->é-ã/2);
tempc->p.z+=tempc->speed*Sin(tempc->é-ã/2);
tempc->p.x-=0.01*tempc->speed*Cos(tempc->é-ã/2);
tempc->p.z+=0.01*tempc->speed*Sin(tempc->é-ã/2);
tempt=TrackFind(tempc->t,tempc->p.x,tempc->p.z);
if (i) {
tempc->é=Arg(-tempc->p.x,tempc->p.z);
tempc->p.x=-(TRACK_INNER+TRACK_OUTER)/2*Cos(tempc->é);
tempc->p.z= (TRACK_INNER+TRACK_OUTER)/2*Sin(tempc->é);
if (tempt!=tempc->t) {
tempt2=tempt->next;
if (tempt2==&track_root)
tempt2=tempt2->next;
tempc->é=Arg(-tempt2->z+tempc->p.z,-tempt2->x+tempc->p.x);
}
} else {
tempc->é+=0.01*tempc->dé;
x=track_map->width-(tempc->p.x-t_minx)>>MAP_BITS;
z=(tempc->p.z-t_minz)>>MAP_BITS;
if (GrPeek(track_map,x,z)!=YELLOW) {
on_track=FALSE;
tempc->speed-=0.01*tempc->speed;
if (tempc->speed<0) tempc->speed=0;
} else
on_track=TRUE;
}
tempc->t=tempt;
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
}
R2P(&m,&a,c[0].p.x,c[0].p.z);
if (!game_over && TRACK_INNER<=m<=TRACK_OUTER) {
if (!game_over && on_track) {
for (i=1;i<NUM_CARS;i++)
if (D3I32DistSqr(&c[i].p,&c[0].p)<CAR_LENGTH*CAR_LENGTH>>1) {
if (D3I32DistSqr(&c[i].p,&c[0].p)<CAR_LENGTH>>1*CAR_LENGTH>>1) {
game_over=TRUE;
Noise(500,50,100);
Sleep(500);
break;
}
if (!game_over) {
distance+=c[0].speed;
if (distance>2*ã*TRACK_INNER && Wrap(a+ã,-ã)>0.0) {
distance+=0.01*c[0].speed;
if (distance>track_root.last->d&& c[0].t->num<track_root.last->num>>1) {
tf=tS;
game_over=TRUE;
Beep;
@@ -411,36 +565,61 @@ U0 AnimateTask(I64)
CSprite *imgs[8]={$IB,"<1>",BI=1$,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"<2>",BI=2$,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$,$IB,"<4>",BI=4$,$IB,"<4>",BI=4$};
U0 Init()
U0 InitBushes()
{
Bush *tempb;
Car *tempc;
I64 i;
I64 i,j,x,z;
track_map->color=LTGREEN;
track_map->pen_width=1;
for (i=0;i<NUM_BUSHES;i++) {
tempb=&b[i];
do {
tempb->p.x=RandU32&0x7FFF-0x4000;
tempb->p.z=RandU32&0x7FFF-0x4000;
} while (TRACK_INNER-SHOULDER<=
Sqrt(SqrI64(tempb->p.x)+SqrI64(tempb->p.z))<=TRACK_OUTER+SHOULDER);
ib_restart:
tempb->p.x=Rand*(t_maxx-t_minx)+t_minx;
tempb->p.z=Rand*(t_maxz-t_minz)+t_minz;
x=track_map->width-(tempb->p.x-t_minx)>>MAP_BITS;
z=(tempb->p.z-t_minz)>>MAP_BITS;
for (j=0;j<8;j++)
if (GrPeek(track_map,x+gr_x_offsets[j],z+gr_y_offsets[j])!=LTGRAY)
goto ib_restart;
GrPlot(track_map,x,z);
tempb->p.y=DipY(tempb->p.x,tempb->p.z);
tempb->sym=RandU16&1;
tempb->img=imgs[i&7];
}
}
U0 Init()
{
Car *tempc;
Track *tempt;
F64 d;
I64 i;
InitTrack;
InitBushes;
tempt=track_root.next;
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
if (i==0) {
tempc->t=tempt;
tempc->p.x=tempt->x;
tempc->p.z=tempt->z;
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
tempc->é =-tempt->é;
tempc->dé=0;
if (!i) {
tempc->img=$IB,"<5>",BI=5$;
tempc->speed=0;
} else {
tempc->img=$IB,"<6>",BI=6$;
tempc->speed=50.0;
tempc->speed=2500.0;
}
tempc->é=i*2*ã/NUM_CARS;
tempc->p.x=-(TRACK_INNER+TRACK_OUTER)/2*Cos(tempc->é);
tempc->p.z= (TRACK_INNER+TRACK_OUTER)/2*Sin(tempc->é);
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
d=(i+1)*track_root.last->d/NUM_CARS;
while (tempt->next!=&track_root && tempt->d<d)
tempt=tempt->next;
}
distance=0;
tf=0;
@@ -448,6 +627,14 @@ U0 Init()
game_over=FALSE;
}
U0 CleanUp()
{
while (mp_not_done_flags)
Yield;
QueDel(&track_root,TRUE);
DCDel(track_map);
}
U0 Varoom()
{
I64 sc;
@@ -470,12 +657,11 @@ U0 Varoom()
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
AutoComplete;
WinMax;
WinBorder;
Preempt;
Init;
WinMax;
DocCursor;
DocClear;
Init;
Fs->draw_it=&DrawIt;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
while (TRUE)
@@ -483,20 +669,22 @@ U0 Varoom()
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_LEFT:
c[0].é-=ã/100;
c[0].dé-=ã/60;
break;
case SC_CURSOR_RIGHT:
c[0].é+=ã/100;
c[0].dé+=ã/60;
break;
case SC_CURSOR_UP:
c[0].speed+=3;
c[0].speed+=300;
break;
case SC_CURSOR_DOWN:
c[0].speed-=3;
c[0].speed-=900;
if (c[0].speed<0) c[0].speed=0;
break;
}
break;
case '\n':
CleanUp;
Init;
break;
case CH_SHIFT_ESC:
@@ -506,6 +694,7 @@ U0 Varoom()
vr_done: //Don't goto out of try
} catch
Fs->catch_except=TRUE;
CleanUp;
SettingsPop(,TSF_SAME_SONG);
MenuPop;
RegWriteBranch("TempleOS/Varoom","F64 best_score=%5.4f;\n",best_score);
+5 -9
View File
@@ -128,7 +128,6 @@ U0 DrawIt(CTask *task,CDC *dc)
Step *tempst;
Peasant *tempp;
F64 tt;
Bool old_preempt=Preempt;
dc->pen_width=1;
for (i=0;i<NUM_TREES;i++) {
@@ -225,8 +224,6 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=LTBLUE;
GrPrint(dc,0,0,"Freezing Peasants:%d Time:%3.2f Best:%3.2f",
not_stopped_cnt,tt-t0,best_score);
Preempt(old_preempt);
}
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool left_right,Bool king)
@@ -337,7 +334,7 @@ U0 Follow(CTask *,Peasant *tempp)
}
U0 AnimateTask(I64)
{//Preempt off by default after spawned.
{
Step *temps,*temps1;
Peasant *tempp;
I64 i,w,h;
@@ -472,8 +469,11 @@ U0 Wenceslas()
);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
AutoComplete;
WinBorder;
WinMax;
Preempt;
DocCursor;
DocClear;
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
PopUpOk("
@@ -536,10 +536,6 @@ Lead peasants to fires.
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
AutoComplete;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
+2 -2
View File
@@ -110,9 +110,9 @@ U0 Whap()
CMathODE *ode=ODENew(0,1e-2,ODEF_HAS_MASSES);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
AutoComplete;
Preempt;
WinBorder;
WinMax;
MenuPush(
"File {"
Binary file not shown.
Binary file not shown.