TempleOSTS_140317.ISO
This commit is contained in:
1 parent
2d2a65d572
commit
7ef616a20e
1416 files changed
+223873
-53917
No files matched your search
Binary file not shown.
@@ -0,0 +1,198 @@
|
||||
I64 num_people=100;
|
||||
|
||||
|
||||
U0 SongTask(I64)
|
||||
{ //Song by the Holy Spirit
|
||||
Fs->task_end_cb=&SndTaskEndCB;
|
||||
MusicSettingsRst;
|
||||
while (TRUE) {
|
||||
Play("3eGFqGetBEFeBEEFetBDCeCFqF");
|
||||
Play("eGFqGetBEFeBEEFetBDCeCFqF");
|
||||
Play("AetDAAqBDeBEqEetECDGBG");
|
||||
Play("qAetDAAqBDeBEqEetECDGBG");
|
||||
}
|
||||
}
|
||||
|
||||
U0 HoldCourt()
|
||||
{
|
||||
I64 accused,crime,victim;
|
||||
Bool old_form=LBts(&(DocPut)->flags,DOCf_FORM);
|
||||
|
||||
FlushMsgs;
|
||||
DocDblBufStart;
|
||||
|
||||
NewLine;
|
||||
accused=RandU32%3;
|
||||
"%s",LstSub(accused,"A man \0A woman \0A child \0");
|
||||
|
||||
crime=RandU32&3;
|
||||
"%s",LstSub(crime,"commits murder\0commits adultery\0commits blasphemy\0commits idolatry\0");
|
||||
|
||||
if (crime<=1) {
|
||||
'' CH_SPACE;
|
||||
victim=RandU32%3;
|
||||
"%s",LstSub(victim,"to a man\0to a woman\0to a child\0to an animal\0");
|
||||
}
|
||||
if (!(RandU32%5))
|
||||
", again!";
|
||||
else
|
||||
'.';
|
||||
NewLine(4);
|
||||
|
||||
"$$LM,4$$"
|
||||
"\n\n$$BT,\"Show Mercy\",LE=0$$\n\n"
|
||||
"\n\n$$BT,\"Punish\",LE=1$$\n\n"
|
||||
"\n\n$$BT,\"Really Punish\",LE=2$$\n\n"
|
||||
"$$LM,0$$";
|
||||
DocDblBufEnd;
|
||||
DocMenuDo(DocPut);
|
||||
|
||||
LBEqu(&(DocPut)->flags,DOCf_FORM,old_form);
|
||||
DocBottom;
|
||||
}
|
||||
|
||||
#define T_BREAK_CAMP 0
|
||||
#define T_TALK_WITH_GOD 1
|
||||
#define T_VIEW_CLOUDS 2
|
||||
#define T_HOLD_COURT 3
|
||||
#define T_VIEW_MAP 4
|
||||
#define T_WATER_ROCK 5
|
||||
#define T_BATTLE 6
|
||||
#define T_QUAIL 7
|
||||
#define T_MOSES_COMICS 8
|
||||
#define T_HELP 9
|
||||
#define T_QUIT 10
|
||||
|
||||
|
||||
Bool TakeTurn()
|
||||
{
|
||||
I64 i;
|
||||
Bool result,old_form=LBts(&(DocPut)->flags,DOCf_FORM);
|
||||
num_people*=1.0+0.01*((RandU16%100)-30);
|
||||
if (num_people>MAX_PEOPLE)
|
||||
num_people=MAX_PEOPLE;
|
||||
|
||||
if (!Fs->song_task)
|
||||
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
|
||||
Camp(num_people);
|
||||
Kill(Fs->song_task);
|
||||
|
||||
FlushMsgs;
|
||||
DocDblBufStart;
|
||||
"$$LM,4$$"
|
||||
"\n\n$$BT,\"Break Camp\",LE=T_BREAK_CAMP$$\n\n"
|
||||
"\n\n$$BT,\"Talk with God\",LE=T_TALK_WITH_GOD$$\n\n"
|
||||
"\n\n$$BT,\"View Clouds\",LE=T_VIEW_CLOUDS$$\n\n"
|
||||
"\n\n$$BT,\"Hold Court\",LE=T_HOLD_COURT$$\n\n"
|
||||
"\n\n$$BT,\"View Map\",LE=T_VIEW_MAP$$\n\n"
|
||||
"\n\n$$BT,\"Make Water\",LE=T_WATER_ROCK$$\n\n"
|
||||
"\n\n$$BT,\"Battle\",LE=T_BATTLE$$\n\n"
|
||||
"\n\n$$BT,\"Beg for Meat\",LE=T_QUAIL$$\n\n"
|
||||
"\n\n$$BT,\"Moses Comics\",LE=T_MOSES_COMICS$$\n\n"
|
||||
"\n\n$$BT,\"Help\",LE=T_HELP$$\n\n"
|
||||
"\n\n$$BT,\"Quit\",LE=T_QUIT$$\n\n"
|
||||
"$$LM,0$$";
|
||||
DocDblBufEnd;
|
||||
i=DocMenuDo(DocPut,DOF_DONT_TEXT_ATTR);
|
||||
|
||||
LBEqu(&(DocPut)->flags,DOCf_FORM,old_form);
|
||||
DocBottom;
|
||||
|
||||
if (!(0<=i<T_QUIT))
|
||||
result=FALSE;
|
||||
else {
|
||||
switch (i) {
|
||||
case T_BREAK_CAMP:
|
||||
break;
|
||||
case T_TALK_WITH_GOD:
|
||||
UpTheMountain;
|
||||
break;
|
||||
case T_VIEW_CLOUDS:
|
||||
CloudScene;
|
||||
break;
|
||||
case T_HOLD_COURT:
|
||||
HoldCourt;
|
||||
break;
|
||||
case T_VIEW_MAP:
|
||||
AEMap;
|
||||
break;
|
||||
case T_WATER_ROCK:
|
||||
WaterRock;
|
||||
break;
|
||||
case T_BATTLE:
|
||||
Battle;
|
||||
break;
|
||||
case T_QUAIL:
|
||||
Quail;
|
||||
break;
|
||||
case T_MOSES_COMICS:
|
||||
ViewComics;
|
||||
break;
|
||||
case T_HELP:
|
||||
PopUp("Ed(\"::/Adam/God/HSNotes.TXT.Z\");",Fs);
|
||||
PopUpOk("Add your own story-line...\nLike old school toys.\n");
|
||||
break;
|
||||
}
|
||||
result=TRUE;
|
||||
}
|
||||
WinMgrSync;
|
||||
Fs->song_task=NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 TMsg(CDC *dc,U8 *msg)
|
||||
{
|
||||
F64 t0=tS;
|
||||
while (tS-t0<1.5) {
|
||||
if (Blink(5))
|
||||
dc->color=BLACK;
|
||||
else
|
||||
dc->color=RED;
|
||||
GrRect(dc,0,GR_HEIGHT-FONT_HEIGHT*3,GR_WIDTH,FONT_HEIGHT*2);
|
||||
dc->color=BLACK;
|
||||
GrRect(dc,2,GR_HEIGHT-FONT_HEIGHT*3+2,GR_WIDTH-4,FONT_HEIGHT*2-4);
|
||||
dc->color=YELLOW;
|
||||
GrPrint(dc,(GR_WIDTH-StrLen(msg)*FONT_WIDTH)/2,GR_HEIGHT-5*FONT_HEIGHT/2,"%s",msg);
|
||||
WinMgrSync;
|
||||
if (ScanChar)
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
U0 Trailer()
|
||||
{
|
||||
CDC *dc=DCAlias;
|
||||
WinMax;
|
||||
WinBorder;
|
||||
Cd(Fs->parent_task->cur_dir);
|
||||
Type("AESplash.TXT");
|
||||
Sleep(500);
|
||||
FlushMsgs;
|
||||
try {
|
||||
TMsg(dc,"Leaving all behind, they fled.");
|
||||
TMsg(dc,"Found themselves in a desert.");
|
||||
TMsg(dc,"God! We're gonna die!");
|
||||
TMsg(dc,"\"Trust Me!\"");
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
DCFill;
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
U0 AfterEgypt()
|
||||
{
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
|
||||
WinBorder;
|
||||
WordStat;
|
||||
DocClear;
|
||||
WinMax;
|
||||
PopUp("Trailer;",Fs);
|
||||
WordStat;
|
||||
try //This is to catch <CTRL-ALT-C>.
|
||||
while (TakeTurn);
|
||||
catch
|
||||
PutExcept;
|
||||
DocClear;
|
||||
SettingsPop;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
U0 ViewComics()
|
||||
{
|
||||
I64 i=0;
|
||||
U8 *st;
|
||||
CDirEntry *tempde=FilesFind("Comics/*.TXT*"),*tempde1=tempde;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
while (tempde) {
|
||||
st=StrNew(tempde->name);
|
||||
FileExtRem(st);
|
||||
tempde->user_data=DocPrint(doc,"$$MU-UL,\"%-10ts\",LE=%d$$ ",st,tempde);
|
||||
Free(st);
|
||||
tempde=tempde->next;
|
||||
if ((i++&3)==3)
|
||||
DocPrint(doc,"\n");
|
||||
}
|
||||
while (TRUE) {
|
||||
if ((tempde=PopUpMenu(doc))>0)
|
||||
Ed(tempde->full_name);
|
||||
else
|
||||
break;
|
||||
}
|
||||
DocDel(doc);
|
||||
DirLstDel(tempde1);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,90 @@
|
||||
I64 type_weights[OT_NUM_TYPES]={30,30,15,30,30,1,1,1};
|
||||
|
||||
I64 mp_not_done_flags;
|
||||
U0 MPDrawHoreb(CDC *dc2)
|
||||
{
|
||||
CTask *task=dc2->win_task;
|
||||
CDC *dc=DCAlias(dc2,task);
|
||||
I64 lo=Gs->num*O_NUM_OBJS/mp_cnt,hi=(Gs->num+1)*O_NUM_OBJS/mp_cnt,
|
||||
i,j,dx,dy,dz,w=task->pix_width,h=task->pix_height,r[16],cx=w>>1;
|
||||
F64 s,m,a,x1,y1,x2,y2;
|
||||
Obj *tempo;
|
||||
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,-é);
|
||||
GrRotXEqu(r,77*ã/180);
|
||||
for (i=lo;i<hi;i++) {
|
||||
tempo=&objs[i];
|
||||
tempo->x1=tempo->x+vx; tempo->y1=tempo->y; tempo->z1=tempo->z+vz;
|
||||
GrRot(r,&tempo->x1,&tempo->y1,&tempo->z1);
|
||||
if (tempo->type==OT_SHEEP || tempo->type==OT_GOAT1 || tempo->type==OT_GOAT2) {
|
||||
dx=100*tempo->dx; dy=100*tempo->dy; dz=100*tempo->dz;
|
||||
GrRot(r,&dx,&dy,&dz);
|
||||
if (dx<0)
|
||||
tempo->sym=TRUE;
|
||||
else
|
||||
tempo->sym=FALSE;
|
||||
}
|
||||
if (tempo->z1>=0) {
|
||||
s=100.0/(AbsI64(tempo->z1)+50);
|
||||
GrIdentEqu(dc->r);
|
||||
GrScaleEqu(dc->r,s*2);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
if (tempo->sym) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,s*tempo->x1+cx,s*tempo->y1+h,s*tempo->x1+cx,s*tempo->y1+h+10);
|
||||
}
|
||||
Sprite3B(dc,s*tempo->x1+cx,s*tempo->y1+h,tempo->z1,imgs[tempo->type]);
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
if (tempo==&objs[O_BURNING_BUSH]) { //draw burning bush
|
||||
dc->x=s*tempo->x1+cx;
|
||||
dc->y=s*tempo->y1+h;
|
||||
dc->z=tempo->z1;
|
||||
dc->pen_width=1;
|
||||
dc->color=win_updates&15;
|
||||
for (j=0;j<45;j++) {
|
||||
m=Sqr(Rand); a=2*ã*Rand;
|
||||
P2R(&x1,&y1,m,a);
|
||||
m=Sqr(Rand); a=2*ã*Rand;
|
||||
P2R(&x2,&y2,m,a);
|
||||
GrLine3(dc,20*x1,20*y1-25,0,20*x2,20*y2-25,0);
|
||||
}
|
||||
if (SqrI64(s*tempo->x1)+SqrI64(s*tempo->y1)<300*300)
|
||||
horeb_done=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
dc->depth_buf=NULL;
|
||||
DCDel(dc);
|
||||
LBtr(&mp_not_done_flags,Gs->num);
|
||||
}
|
||||
|
||||
U0 DrawHoreb(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,x,y,z,w=task->pix_width,h=task->pix_height,r[16],cx=w>>1,cy=h>>1;
|
||||
F64 s;
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,-é);
|
||||
GrRotXEqu(r,77*ã/180);
|
||||
//Sun
|
||||
x=vx; y=0; z=1000000+vz;
|
||||
GrRot(r,&x,&y,&z);
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
if (y<0) {
|
||||
dc->color=BROWN;
|
||||
GrCircle(dc,s*x+cx,15,15);
|
||||
dc->color=YELLOW;
|
||||
GrFloodFill(dc,s*x+cx,15);
|
||||
}
|
||||
DCAllocDepthBuf(dc);
|
||||
mp_not_done_flags=1<<mp_cnt-1;
|
||||
for (i=0;i<mp_cnt;i++)
|
||||
JobQue(&MPDrawHoreb,dc,i);
|
||||
while (mp_not_done_flags)
|
||||
Yield;
|
||||
if (Blink) {
|
||||
dc->color=LTRED;
|
||||
GrPrint(dc,cx-21*FONT_WIDTH/2,cy-FONT_HEIGHT/2,"Find the Burning Bush.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
I64 type_weights[OT_NUM_TYPES]={30,30,15,30,3,1,1,1};
|
||||
|
||||
I64 ObjCompare(Obj *o1,Obj *o2)
|
||||
{
|
||||
return o2->z1-o1->z1;
|
||||
}
|
||||
|
||||
U0 DrawHoreb(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,x,y,z,dx,dy,dz,
|
||||
w=task->pix_width,
|
||||
h=task->pix_height,r[16],
|
||||
cx=w>>1,cy=h>>1;
|
||||
F64 s,m,a,x1,y1,x2,y2;
|
||||
Obj *o_sort[O_NUM_OBJS],*tempo;
|
||||
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,-é);
|
||||
GrRotXEqu(r,77*ã/180);
|
||||
|
||||
//Sun
|
||||
x=vx; y=0; z=1000000+vz;
|
||||
GrRot(r,&x,&y,&z);
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
if (y<0) {
|
||||
dc->color=BROWN;
|
||||
GrCircle(dc,s*x+cx,15,15);
|
||||
dc->color=YELLOW;
|
||||
GrFloodFill(dc,s*x+cx,15);
|
||||
}
|
||||
|
||||
for (i=0;i<O_NUM_OBJS;i++) {
|
||||
tempo=&objs[i];
|
||||
o_sort[i]=tempo;
|
||||
tempo->x1=tempo->x+vx; tempo->y1=tempo->y; tempo->z1=tempo->z+vz;
|
||||
GrRot(r,&tempo->x1,&tempo->y1,&tempo->z1);
|
||||
if (tempo->type==OT_SHEEP || tempo->type==OT_GOAT1 || tempo->type==OT_GOAT2) {
|
||||
dx=100*tempo->dx; dy=100*tempo->dy; dz=100*tempo->dz;
|
||||
GrRot(r,&dx,&dy,&dz);
|
||||
if (dx<0)
|
||||
tempo->sym=TRUE;
|
||||
else
|
||||
tempo->sym=FALSE;
|
||||
}
|
||||
}
|
||||
QSortI64(o_sort,O_NUM_OBJS,&ObjCompare);
|
||||
|
||||
for (i=0;i<O_NUM_OBJS;i++) {
|
||||
tempo=o_sort[i];
|
||||
if (tempo->z1<0) break;
|
||||
s=100.0/(AbsI64(tempo->z1)+50);
|
||||
GrIdentEqu(dc->r);
|
||||
GrScaleEqu(dc->r,s*2);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
if (tempo->sym) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,s*tempo->x1+cx,s*tempo->y1+h,s*tempo->x1+cx,s*tempo->y1+h+10);
|
||||
}
|
||||
Sprite3B(dc,s*tempo->x1+cx,s*tempo->y1+h,0,imgs[tempo->type]);
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
if (o_sort[i]==&objs[O_BURNING_BUSH]) { //draw burning bush
|
||||
dc->x=s*tempo->x1+cx;
|
||||
dc->y=s*tempo->y1+h;
|
||||
dc->z=0;
|
||||
|
||||
dc->pen_width=1;
|
||||
dc->color=win_updates&15;
|
||||
for (j=0;j<45;j++) {
|
||||
m=Sqr(Rand); a=2*ã*Rand;
|
||||
P2R(&x1,&y1,m,a);
|
||||
m=Sqr(Rand); a=2*ã*Rand;
|
||||
P2R(&x2,&y2,m,a);
|
||||
GrLine3(dc,20*x1,20*y1-25,0,20*x2,20*y2-25,0);
|
||||
}
|
||||
|
||||
if (SqrI64(s*tempo->x1)+SqrI64(s*tempo->y1)<300*300)
|
||||
horeb_done=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Blink) {
|
||||
dc->color=LTRED;
|
||||
GrPrint(dc,cx-21*FONT_WIDTH/2,cy-FONT_HEIGHT/2,"Find the Burning Bush.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
U0 AnimateTask(I64)
|
||||
{ //Preemption is off after Spawn
|
||||
I64 i;
|
||||
F64 t;
|
||||
Obj *tempo;
|
||||
while (TRUE) {
|
||||
t=tS;
|
||||
for (i=0;i<O_NUM_OBJS;i++) {
|
||||
tempo=&objs[i];
|
||||
if (tempo->type==OT_SHEEP || tempo->type==OT_GOAT1 || tempo->type==OT_GOAT2) {
|
||||
tempo->x+=tempo->dx;
|
||||
tempo->y+=tempo->dy;
|
||||
tempo->z+=tempo->dz;
|
||||
tempo->dx=5*Cos(0.5*t+tempo->é);
|
||||
tempo->dz=5*Sin(0.5*t+tempo->é);
|
||||
}
|
||||
}
|
||||
Sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
Obj *tempo;
|
||||
I64 i,j,k,total=0;
|
||||
|
||||
for (i=0;i<OT_NUM_TYPES;i++)
|
||||
total+=type_weights[i];
|
||||
|
||||
MemSet(objs,0,sizeof(objs));
|
||||
for (i=0;i<O_NUM_OBJS;i++) {
|
||||
tempo=&objs[i];
|
||||
tempo->x=RandU32&0x1FFF-0x1000;
|
||||
tempo->y=0;
|
||||
tempo->z=RandU32&0x1FFF-0x1000;
|
||||
tempo->é=2*ã*Rand;
|
||||
tempo->sym=RandU16&1;
|
||||
|
||||
k=0;
|
||||
j=RandU32%total;
|
||||
while (TRUE) {
|
||||
j-=type_weights[k];
|
||||
if (j<0)
|
||||
break;
|
||||
else
|
||||
k++;
|
||||
}
|
||||
|
||||
tempo->type=k;
|
||||
}
|
||||
objs[O_BURNING_BUSH].type=OT_BUSH1;
|
||||
|
||||
vx=0; vz=0; é=0;
|
||||
horeb_done=FALSE;
|
||||
}
|
||||
|
||||
#define ANIMATE_STEPS 10
|
||||
|
||||
U0 AnimateéTask(F64 a)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<ANIMATE_STEPS;i++) {
|
||||
é+=a/ANIMATE_STEPS;
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
U0 AnimateVTask(F64 v)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<ANIMATE_STEPS;i++) {
|
||||
vx+=v/ANIMATE_STEPS*Sin(é);
|
||||
vz+=v/ANIMATE_STEPS*Cos(é);
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
U0 Horeb()
|
||||
{
|
||||
I64 ch,sc;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Fwd(,,SC_CURSOR_UP);"
|
||||
" Backward(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
SettingsPush(Fs,TSF_SAME_SONG); //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
try {
|
||||
Fs->text_attr=YELLOW<<4+BLUE;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_GRAB_SCROLL-WIF_MENU;
|
||||
WordStat;
|
||||
WinMax;
|
||||
WinBorder;
|
||||
Preempt(OFF);
|
||||
|
||||
DocClear;
|
||||
"$$BG,LTCYAN$$"; NewLine(6);
|
||||
"$$BG,YELLOW$$"; NewLine(30);
|
||||
BibleVerse(,"Exodus,3:1",21);
|
||||
Init;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||
Fs->draw_it=&DrawHoreb;
|
||||
while (!horeb_done) {
|
||||
while (ScanKey(&ch,&sc))
|
||||
switch (ch) {
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_LEFT:
|
||||
Spawn(&AnimateéTask,(-ã/100)(I64),"Animate é",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_RIGHT:
|
||||
Spawn(&AnimateéTask,( ã/100)(I64),"Animate é",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
Spawn(&AnimateVTask,(-40.0 )(I64),"Animate V",,Fs);
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
Spawn(&AnimateVTask,( 40.0 )(I64),"Animate V",,Fs);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
Init;
|
||||
break;
|
||||
case CH_SHIFT_ESC:
|
||||
case CH_ESC:
|
||||
goto hr_done;
|
||||
}
|
||||
WinMgrSync;
|
||||
}
|
||||
hr_done: //Don't goto out of try
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
DocClear;
|
||||
SettingsPop(Fs,TSF_SAME_SONG);
|
||||
MenuPop;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#help_index "Games"
|
||||
|
||||
Cd("/Apps/AfterEgypt");;
|
||||
#include "Comics"
|
||||
#include "/Demo/Graphics/Camp"
|
||||
#include "/Demo/MultiCore/Clouds"
|
||||
#include "/Demo/Graphics/Mountain"
|
||||
#include "Map"
|
||||
#include "Battle"
|
||||
#include "WaterRock"
|
||||
#include "Quail"
|
||||
#include "Horeb1"
|
||||
|
||||
#if mp_cnt>=4
|
||||
#include "Horeb2MP"
|
||||
#else
|
||||
#include "Horeb2SP"
|
||||
#endif
|
||||
|
||||
#include "Horeb3"
|
||||
#include "GodTalking"
|
||||
#include "AfterEgypt"
|
||||
|
||||
#help_index ""
|
||||
@@ -0,0 +1,76 @@
|
||||
I64 x=0,y=0;
|
||||
|
||||
U0 DrawMap(CTask *,CDC *dc)
|
||||
{
|
||||
static I64 last_x;
|
||||
static Bool last_left;
|
||||
if (x<last_x)
|
||||
last_left=TRUE;
|
||||
else if (x>last_x)
|
||||
last_left=FALSE;
|
||||
dc->pen_width=1;
|
||||
if (last_left)
|
||||
Sprite3(dc,x,y,0,left_imgs [ToI64(6.0*tS)&3]);
|
||||
else
|
||||
Sprite3(dc,x,y,0,right_imgs[ToI64(6.0*tS)&3]);
|
||||
last_x=x;
|
||||
}
|
||||
|
||||
#define A1_MIN 0.02
|
||||
#define A1_MAX 0.05
|
||||
#define A2_MIN 0.15
|
||||
#define A2_MAX 0.30
|
||||
|
||||
U0 AEMap()
|
||||
{
|
||||
I64 i=0,
|
||||
cx=Fs->pix_width>>1,
|
||||
cy=Fs->pix_height>>1,
|
||||
c_min=MinI64(cx,cy),
|
||||
*r=NULL,
|
||||
x1=0,y1=0,z1=0,
|
||||
x_last=x1,y_last=y1;
|
||||
F64 a,a1=(A1_MAX+A1_MIN)/2,a2=(A2_MAX+A2_MIN)/2,a2_total=a2,
|
||||
x_scale=ToF64(cx)/c_min,y_scale=ToF64(cy)/c_min;
|
||||
CDC *dc=DCAlias;
|
||||
|
||||
SettingsPush(Fs,TSF_SAME_SONG); //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=YELLOW<<4+BLUE;
|
||||
DocClear;
|
||||
"$$BG,YELLOW$$"; NewLine(TEXT_ROWS);
|
||||
BibleVerse(,"Exodus,16:35",3);
|
||||
Fs->draw_it=&DrawMap;
|
||||
try {
|
||||
while (!ScanChar) {
|
||||
dc->color=BLACK;
|
||||
a1=Clamp(Wrap(a1+(A1_MAX+A1_MIN)/5.0*(Rand-0.5)),-A1_MAX,A1_MAX);
|
||||
a=a1;
|
||||
if ( 0.0<=a<=A1_MIN) a=A1_MIN;
|
||||
if (-A1_MIN<=a<=0.0) a=-A1_MIN;
|
||||
Free(r);
|
||||
r=GrRotZNew(a);
|
||||
GrRot(r,&x1,&y1,&z1);
|
||||
|
||||
a2=Clamp(Wrap(a2+(A2_MAX+A2_MIN)/5.0*(Rand-0.5)),-A2_MAX,A2_MAX);
|
||||
a=a2;
|
||||
if ( 0.0<=a<=A2_MIN) a=A2_MIN;
|
||||
if (-A2_MIN<=a<=0.0) a=-A2_MIN;
|
||||
a2_total+=a;
|
||||
|
||||
x1=ClampI64(x1+6.0*Cos(a2_total),-c_min+10,c_min-10);
|
||||
y1=ClampI64(y1+6.0*Sin(a2_total),-c_min+10,c_min-10);
|
||||
|
||||
x=x_scale*x1+cx; y=y_scale*y1+cy;
|
||||
if (i++&1)
|
||||
GrLine(dc,x_last,y_last,x,y);
|
||||
x_last=x; y_last=y;
|
||||
Sleep(15);
|
||||
}
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
DocClear;
|
||||
SettingsPop(Fs,TSF_SAME_SONG);
|
||||
Free(r);
|
||||
DCFill(dc);
|
||||
DCDel(dc);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
Cd("/Apps/AfterEgypt");;
|
||||
#include "Load"
|
||||
AfterEgypt;
|
||||
Binary file not shown.
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
This makes a mesh ball.
|
||||
*/
|
||||
|
||||
|
||||
#define MAX_VERTICES 1024
|
||||
#define MAX_TRIS 1024
|
||||
|
||||
class Ball
|
||||
{
|
||||
I32 vertex_cnt;
|
||||
I32 tri_cnt;
|
||||
CD3I32 v[MAX_VERTICES];
|
||||
CMeshTri t[MAX_TRIS];
|
||||
} *b;
|
||||
|
||||
|
||||
class BallDefineStruct
|
||||
{
|
||||
F64 radius fmtstr "$$DA-TRM,32,A=\"Radius :%8.3f\"$$\n";
|
||||
I64 n_longitude fmtstr "$$DA-TRM,32,A=\"Longitude Faces:%5d\"$$\n";
|
||||
I64 n_lattitude fmtstr "$$DA-TRM,32,A=\"Lattitude Rings:%5d\"$$\n";
|
||||
};
|
||||
|
||||
U0 BDInit(BallDefineStruct *bd)
|
||||
{
|
||||
MemSet(bd,0,sizeof(BallDefineStruct));
|
||||
bd->n_longitude=16;
|
||||
bd->n_lattitude=8;
|
||||
bd->radius =20.0;
|
||||
}
|
||||
|
||||
U0 BDCorrect(BallDefineStruct *bd)
|
||||
{
|
||||
bd->n_longitude=(bd->n_longitude+1)/2;
|
||||
bd->n_lattitude=(bd->n_lattitude+1)/2;
|
||||
}
|
||||
|
||||
|
||||
I64 AddVertex(BallDefineStruct *,I64 x,I64 y,I64 z)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<b->vertex_cnt;i++)
|
||||
if (b->v[i].x==x && b->v[i].y==y && b->v[i].z==z)
|
||||
return i;
|
||||
i=b->vertex_cnt++;
|
||||
b->v[i].x=x;
|
||||
b->v[i].y=y;
|
||||
b->v[i].z=z;
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 AddTri(BallDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
||||
{
|
||||
I64 result=b->tri_cnt++;
|
||||
b->t[result].color=c;
|
||||
b->t[result].nums[0]=n0;
|
||||
b->t[result].nums[1]=n1;
|
||||
b->t[result].nums[2]=n2;
|
||||
return result;
|
||||
}
|
||||
|
||||
U8 *Ball2CSprite()
|
||||
{
|
||||
//See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ for how CSprite are stored.
|
||||
U8 *result=MAlloc(sizeof(U8)+2*sizeof(I32)+
|
||||
b->vertex_cnt*sizeof(CD3I32)+b->tri_cnt*sizeof(CMeshTri)+sprite_base_size[GRST_END]),
|
||||
*dst=result;
|
||||
*dst(U8 *)++ =GRST_MESH;
|
||||
*dst(I32 *)++ =b->vertex_cnt;
|
||||
*dst(I32 *)++ =b->tri_cnt;
|
||||
MemCpy(dst,&b->v,b->vertex_cnt*sizeof(CD3I32));
|
||||
dst+=b->vertex_cnt*sizeof(CD3I32);
|
||||
MemCpy(dst,&b->t,b->tri_cnt*sizeof(CMeshTri));
|
||||
dst+=b->tri_cnt*sizeof(CMeshTri);
|
||||
*dst(U8 *)++ =GRST_END;
|
||||
return result;
|
||||
}
|
||||
|
||||
public U8 *BallGen()
|
||||
{
|
||||
U8 *result;
|
||||
I64 i,j,n,m,c,p1,p2,p3,p4;
|
||||
BallDefineStruct bd1,bd2;
|
||||
F64 r,r1,r2,z1,z2,d_a1,d_a2;
|
||||
|
||||
BDInit(&bd1);
|
||||
|
||||
while (TRUE) {
|
||||
if (!DocFormDo(&bd1))
|
||||
return NULL;
|
||||
MemCpy(&bd2,&bd1,sizeof(BallDefineStruct));
|
||||
BDCorrect(&bd2);
|
||||
|
||||
c=PopUpColorLighting;
|
||||
if (c<0) return NULL;
|
||||
|
||||
b=CAlloc(sizeof(Ball));
|
||||
r=bd2.radius;
|
||||
n=bd2.n_lattitude;
|
||||
m=bd2.n_longitude;
|
||||
d_a1=2*ã/n/4;
|
||||
d_a2=2*ã/m/2;
|
||||
for (j=-n;j<n;j++) {
|
||||
r1=r*Cos( j *d_a1);
|
||||
r2=r*Cos((j+1)*d_a1);
|
||||
z1=r*Sin( j *d_a1);
|
||||
z2=r*Sin((j+1)*d_a1);
|
||||
for (i=0;i<m;i++) {
|
||||
p1=AddVertex(&bd2,r1*Cos((2*i +j)*d_a2),r1*Sin((2*i +j)*d_a2),z1);
|
||||
p2=AddVertex(&bd2,r1*Cos((2*i+2+j)*d_a2),r1*Sin((2*i+2+j)*d_a2),z1);
|
||||
p3=AddVertex(&bd2,r2*Cos((2*i+1+j)*d_a2),r2*Sin((2*i+1+j)*d_a2),z2);
|
||||
p4=AddVertex(&bd2,r2*Cos((2*i+3+j)*d_a2),r2*Sin((2*i+3+j)*d_a2),z2);
|
||||
AddTri(&bd2,c,p1,p2,p3);
|
||||
AddTri(&bd2,c,p3,p2,p4);
|
||||
}
|
||||
}
|
||||
|
||||
result=Ball2CSprite;
|
||||
NewLine(7);
|
||||
Sprite(result,"\t\t$$SP,\"<1>\",BI=%d$$");
|
||||
NewLine(7);
|
||||
"Vertices:%d\n",b->vertex_cnt;
|
||||
Free(b);
|
||||
"Do another";
|
||||
if (YorN)
|
||||
Free(result);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "/Apps/GrModels/ManGen"
|
||||
#include "/Apps/GrModels/BallGen"
|
||||
#include "/Apps/GrModels/Models"
|
||||
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
This makes a mesh man.
|
||||
*/
|
||||
|
||||
|
||||
#define MAX_VERTICES 1024
|
||||
#define MAX_TRIS 1024
|
||||
|
||||
class Man
|
||||
{
|
||||
I32 vertex_cnt;
|
||||
I32 tri_cnt;
|
||||
CD3I32 v[MAX_VERTICES];
|
||||
CMeshTri t[MAX_TRIS];
|
||||
} *m;
|
||||
|
||||
|
||||
class ManDefineStruct
|
||||
{
|
||||
F64 head_rad fmtstr "$$DA-TRM,32,A=\"Head Radius :%8.3f\"$$\n";
|
||||
|
||||
F64 torso_len fmtstr "$$DA-TRM,32,A=\"Torso Length :%8.3f\"$$\n";
|
||||
F64 arm_len fmtstr "$$DA-TRM,32,A=\"Arm Length :%8.3f\"$$\n";
|
||||
F64 hand_len fmtstr "$$DA-TRM,32,A=\"Hand Length :%8.3f\"$$\n";
|
||||
F64 leg_len fmtstr "$$DA-TRM,32,A=\"Leg Length :%8.3f\"$$\n";
|
||||
F64 foot_len fmtstr "$$DA-TRM,32,A=\"Foot Length :%8.3f\"$$\n";
|
||||
F64 torso_width fmtstr "$$DA-TRM,32,A=\"Torso Width :%8.3f\"$$\n";
|
||||
F64 torso_depth fmtstr "$$DA-TRM,32,A=\"Torso Depth :%8.3f\"$$\n";
|
||||
F64 arm_rad fmtstr "$$DA-TRM,32,A=\"Arm Radius :%8.3f\"$$\n";
|
||||
F64 hand_rad fmtstr "$$DA-TRM,32,A=\"Hand Radius :%8.3f\"$$\n";
|
||||
F64 leg_rad fmtstr "$$DA-TRM,32,A=\"Leg Radius :%8.3f\"$$\n";
|
||||
F64 foot_rad fmtstr "$$DA-TRM,32,A=\"Foot Radius :%8.3f\"$$\n\n";
|
||||
|
||||
F64 r_shoulder_a1 fmtstr "$$DA-TRM,32,A=\"R.Shoulder Front/Back Angle:%8.3f\"$$\n";
|
||||
F64 l_shoulder_a1 fmtstr "$$DA-TRM,32,A=\"L.Shoulder Front/Back Angle:%8.3f\"$$\n";
|
||||
F64 r_hip_a1 fmtstr "$$DA-TRM,32,A=\"R.Hip Front/Back Angle :%8.3f\"$$\n";
|
||||
F64 l_hip_a1 fmtstr "$$DA-TRM,32,A=\"L.Hip Front/Back Angle :%8.3f\"$$\n";
|
||||
|
||||
F64 r_shoulder_a2 fmtstr "$$DA-TRM,32,A=\"R.Shoulder Side Angle :%8.3f\"$$\n";
|
||||
F64 l_shoulder_a2 fmtstr "$$DA-TRM,32,A=\"L.Shoulder Side Angle :%8.3f\"$$\n";
|
||||
F64 r_hip_a2 fmtstr "$$DA-TRM,32,A=\"R.Hip Side Angle :%8.3f\"$$\n";
|
||||
F64 l_hip_a2 fmtstr "$$DA-TRM,32,A=\"L.Hip Side Angle :%8.3f\"$$\n";
|
||||
|
||||
F64 r_elbow_a fmtstr "$$DA-TRM,32,A=\"R.Elbow Angle :%8.3f\"$$\n";
|
||||
F64 l_elbow_a fmtstr "$$DA-TRM,32,A=\"L.Elbow Angle :%8.3f\"$$\n";
|
||||
F64 r_knee_a fmtstr "$$DA-TRM,32,A=\"R.Knee Angle :%8.3f\"$$\n";
|
||||
F64 l_knee_a fmtstr "$$DA-TRM,32,A=\"L.Knee Angle :%8.3f\"$$\n";
|
||||
|
||||
F64 r_wrist_a fmtstr "$$DA-TRM,32,A=\"R.Wrist Angle :%8.3f\"$$\n";
|
||||
F64 l_wrist_a fmtstr "$$DA-TRM,32,A=\"L.Wrist Angle :%8.3f\"$$\n";
|
||||
F64 r_ankle_a fmtstr "$$DA-TRM,32,A=\"R.Ankle Angle :%8.3f\"$$\n";
|
||||
F64 l_ankle_a fmtstr "$$DA-TRM,32,A=\"L.Ankle Angle :%8.3f\"$$\n";
|
||||
|
||||
};
|
||||
|
||||
U0 MDInit(ManDefineStruct *md)
|
||||
{
|
||||
MemSet(md,0,sizeof(ManDefineStruct));
|
||||
|
||||
md->head_rad =5.0;
|
||||
|
||||
md->torso_len =35.0;
|
||||
md->arm_len =30.0;
|
||||
md->hand_len =8.0;
|
||||
md->leg_len =32.0;
|
||||
md->foot_len =16.0;
|
||||
md->torso_width=20.0;
|
||||
md->torso_depth=10.0;
|
||||
md->arm_rad =3.5;
|
||||
md->hand_rad =2.0;
|
||||
md->leg_rad =4.0;
|
||||
md->foot_rad =3.0;
|
||||
|
||||
md->r_shoulder_a1 =30;
|
||||
md->l_shoulder_a1 =-30;
|
||||
md->r_hip_a1 =-45;
|
||||
md->l_hip_a1 =45;
|
||||
|
||||
md->r_shoulder_a2 =10;
|
||||
md->l_shoulder_a2 =10;
|
||||
md->r_hip_a2 =-5;
|
||||
md->l_hip_a2 =-5;
|
||||
|
||||
md->r_elbow_a =30;
|
||||
md->l_elbow_a =0;
|
||||
md->r_knee_a =0;
|
||||
md->l_knee_a =30;
|
||||
|
||||
md->r_wrist_a =0;
|
||||
md->l_wrist_a =0;
|
||||
md->r_ankle_a =0;
|
||||
md->l_ankle_a =0;
|
||||
}
|
||||
|
||||
U0 MDCorrect(ManDefineStruct *md)
|
||||
{
|
||||
md->r_ankle_a =-md->r_ankle_a;
|
||||
md->l_ankle_a =-md->l_ankle_a;
|
||||
md->r_knee_a =-md->r_knee_a;
|
||||
md->l_knee_a =-md->l_knee_a;
|
||||
md->r_hip_a2 =-md->r_hip_a2;
|
||||
md->r_shoulder_a2=-md->r_shoulder_a2;
|
||||
md->r_ankle_a+=90;
|
||||
md->l_ankle_a+=90;
|
||||
|
||||
md->foot_len-=md->leg_rad;
|
||||
|
||||
md->r_elbow_a+=md->r_shoulder_a1;
|
||||
md->l_elbow_a+=md->l_shoulder_a1;
|
||||
md->r_knee_a+=md->r_hip_a1;
|
||||
md->l_knee_a+=md->l_hip_a1;
|
||||
|
||||
md->r_wrist_a+=md->r_elbow_a;
|
||||
md->l_wrist_a+=md->l_elbow_a;
|
||||
md->r_ankle_a+=md->r_knee_a;
|
||||
md->l_ankle_a+=md->l_knee_a;
|
||||
}
|
||||
|
||||
|
||||
I64 AddVertex(ManDefineStruct *md,I64 x,I64 y,I64 z)
|
||||
{
|
||||
I64 result=m->vertex_cnt++;
|
||||
m->v[result].x=-x;
|
||||
m->v[result].y=-y-md->leg_len-md->foot_rad*2;
|
||||
m->v[result].z=-z;
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 AddTri(ManDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
||||
{
|
||||
I64 result=m->tri_cnt++;
|
||||
m->t[result].color=c;
|
||||
m->t[result].nums[0]=n1;
|
||||
m->t[result].nums[1]=n0;
|
||||
m->t[result].nums[2]=n2;
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 AddBox(ManDefineStruct *md,I64 c,I64 x1,I64 y1,I64 z1,F64 w,F64 h,F64 d,F64 h2,F64 h3,F64 az,F64 ay,F64 ax,
|
||||
I64 *ox,I64 *oy,I64 *oz)
|
||||
{
|
||||
I64 *r;
|
||||
I64 p1a,p2a,p3a,p4a;
|
||||
I64 p1b,p2b,p3b,p4b;
|
||||
I64 wx=w/2,wy=0,wz=0,hx=0,hy=h,hz=0,h2x=0,h2y=h2,h2z=0,h3x=0,h3y=h3,h3z=0,dx=0,dy=0,dz=d/2;
|
||||
|
||||
r=GrIdentNew;
|
||||
GrRotZEqu(r,az*ã/180.0);
|
||||
GrRotYEqu(r,ay*ã/180.0);
|
||||
GrRotXEqu(r,ax*ã/180.0);
|
||||
GrRot(r,&wx,&wy,&wz);
|
||||
GrRot(r,&hx,&hy,&hz);
|
||||
GrRot(r,&h2x,&h2y,&h2z);
|
||||
GrRot(r,&h3x,&h3y,&h3z);
|
||||
GrRot(r,&dx,&dy,&dz);
|
||||
|
||||
p1a=AddVertex(md,x1+dx -wx+h2x,y1+dy -wy+h2y,z1+dz -wz+h2z);
|
||||
p2a=AddVertex(md,x1+dx +wx+h2x,y1+dy +wy+h2y,z1+dz +wz+h2z);
|
||||
p3a=AddVertex(md,x1+dx+hx-wx ,y1+dy+hy-wy ,z1+dz+hz-wz);
|
||||
p4a=AddVertex(md,x1+dx+hx+wx ,y1+dy+hy+wy ,z1+dz+hz+wz);
|
||||
AddTri(md,c,p1a,p2a,p3a);
|
||||
AddTri(md,c,p4a,p3a,p2a);
|
||||
|
||||
p1b=AddVertex(md,x1-dx -wx+h2x,y1-dy -wy+h2y,z1-dz -wz+h2z);
|
||||
p2b=AddVertex(md,x1-dx +wx+h2x,y1-dy +wy+h2y,z1-dz +wz+h2z);
|
||||
p3b=AddVertex(md,x1-dx+hx-wx ,y1-dy+hy-wy ,z1-dz+hz-wz);
|
||||
p4b=AddVertex(md,x1-dx+hx+wx ,y1-dy+hy+wy ,z1-dz+hz+wz);
|
||||
AddTri(md,c,p1b,p2b,p3b);
|
||||
AddTri(md,c,p4b,p3b,p2b);
|
||||
|
||||
AddTri(md,c,p1a,p2a,p1b);
|
||||
AddTri(md,c,p2b,p1b,p2a);
|
||||
AddTri(md,c,p3a,p4a,p3b);
|
||||
AddTri(md,c,p4b,p3b,p4a);
|
||||
AddTri(md,c,p1a,p3a,p1b);
|
||||
AddTri(md,c,p3b,p1b,p3a);
|
||||
AddTri(md,c,p2a,p4a,p2b);
|
||||
AddTri(md,c,p4b,p2b,p4a);
|
||||
|
||||
*ox=x1+hx-h3x;
|
||||
*oy=y1+hy-h3y;
|
||||
*oz=z1+hz-h3z;
|
||||
|
||||
Free(r);
|
||||
}
|
||||
|
||||
|
||||
U8 *Man2CSprite()
|
||||
{
|
||||
//See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ for how CSprite are stored.
|
||||
U8 *result=MAlloc(sizeof(U8)+2*sizeof(I32)+
|
||||
m->vertex_cnt*sizeof(CD3I32)+m->tri_cnt*sizeof(CMeshTri)+sprite_base_size[GRST_END]),
|
||||
*dst=result;
|
||||
*dst(U8 *)++ =GRST_MESH;
|
||||
*dst(I32 *)++ =m->vertex_cnt;
|
||||
*dst(I32 *)++ =m->tri_cnt;
|
||||
MemCpy(dst,&m->v,m->vertex_cnt*sizeof(CD3I32));
|
||||
dst+=m->vertex_cnt*sizeof(CD3I32);
|
||||
MemCpy(dst,&m->t,m->tri_cnt*sizeof(CMeshTri));
|
||||
dst+=m->tri_cnt*sizeof(CMeshTri);
|
||||
*dst(U8 *)++ =GRST_END;
|
||||
return result;
|
||||
}
|
||||
|
||||
public U8 *ManGen()
|
||||
{
|
||||
U8 *result;
|
||||
I64 x,y,z,c1,c2,c3,c4;
|
||||
ManDefineStruct md1,md2;
|
||||
MDInit(&md1);
|
||||
|
||||
while (TRUE) {
|
||||
if (!DocFormDo(&md1))
|
||||
return NULL;
|
||||
MemCpy(&md2,&md1,sizeof(ManDefineStruct));
|
||||
MDCorrect(&md2);
|
||||
|
||||
c1=PopUpColorLighting("$$BK,1$$Shirt$$BK,0$$\n");
|
||||
if (c1<0) return NULL;
|
||||
c2=PopUpColorLighting("$$BK,1$$Pants$$BK,0$$\n");
|
||||
if (c2<0) return NULL;
|
||||
c3=PopUpColorLighting("$$BK,1$$Skin$$BK,0$$\n");
|
||||
if (c3<0) return NULL;
|
||||
c4=PopUpColorLighting("$$BK,1$$Shoes$$BK,0$$\n");
|
||||
if (c4<0) return NULL;
|
||||
|
||||
m=CAlloc(sizeof(Man));
|
||||
|
||||
//Head
|
||||
AddBox(&md2,c3,0,md2.torso_len+md2.head_rad*2,0,
|
||||
md2.head_rad*2,-md2.head_rad*2,md2.head_rad*2,0,0, 0,0,0,
|
||||
&x,&y,&z);
|
||||
|
||||
//Torso
|
||||
AddBox(&md2,c1,0,md2.torso_len,0,
|
||||
md2.torso_width,-md2.torso_len,md2.torso_depth,0,0, 0,0,0,
|
||||
&x,&y,&z);
|
||||
|
||||
//Right Arm
|
||||
AddBox(&md2,c1,-md2.torso_width/2-md2.arm_rad,md2.torso_len-md2.arm_rad,0,
|
||||
md2.arm_rad*2,-md2.arm_len/2,md2.arm_rad*2,md2.arm_rad,0,
|
||||
md2.r_shoulder_a2,0,md2.r_shoulder_a1,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.arm_rad*2,-md2.arm_len/2,md2.arm_rad*2,0,0,
|
||||
md2.r_shoulder_a2,0,md2.r_elbow_a,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.arm_rad*2,-md2.hand_len,md2.hand_rad*2,0,0,
|
||||
md2.r_shoulder_a2,0,md2.r_wrist_a,&x,&y,&z);
|
||||
|
||||
//Left Arm
|
||||
AddBox(&md2,c1,md2.torso_width/2+md2.arm_rad,md2.torso_len-md2.arm_rad,0,
|
||||
md2.arm_rad*2,-md2.arm_len/2,md2.arm_rad*2,md2.arm_rad,0,
|
||||
md2.l_shoulder_a2,0,md2.l_shoulder_a1,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.arm_rad*2,-md2.arm_len/2,md2.arm_rad*2,0,0,
|
||||
md2.l_shoulder_a2,0,md2.l_elbow_a,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.arm_rad*2,-md2.hand_len,md2.hand_rad*2,0,0,
|
||||
md2.l_shoulder_a2,0,md2.l_wrist_a,&x,&y,&z);
|
||||
|
||||
//Right Leg
|
||||
AddBox(&md2,c2,-md2.torso_width/2+md2.leg_rad,0,0,
|
||||
md2.leg_rad*2,-md2.leg_len/2,md2.leg_rad*2,0,0,
|
||||
md2.r_hip_a2,0,md2.r_hip_a1,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.leg_rad*2,-md2.leg_len/2,md2.leg_rad*2,0,md2.foot_rad,
|
||||
md2.r_hip_a2,0,md2.r_knee_a,&x,&y,&z);
|
||||
AddBox(&md2,c4,x,y,z,
|
||||
md2.leg_rad*2,-md2.foot_len,md2.foot_rad*2,md2.leg_rad,0,
|
||||
md2.r_hip_a2,0,md2.r_ankle_a,&x,&y,&z);
|
||||
|
||||
//Left Leg
|
||||
AddBox(&md2,c2,md2.torso_width/2-md2.leg_rad,0,0,
|
||||
md2.leg_rad*2,-md2.leg_len/2,md2.leg_rad*2,0,0,
|
||||
md2.l_hip_a2,0,md2.l_hip_a1,&x,&y,&z);
|
||||
AddBox(&md2,c3,x,y,z,
|
||||
md2.leg_rad*2,-md2.leg_len/2,md2.leg_rad*2,0,md2.foot_rad,
|
||||
md2.l_hip_a2,0,md2.l_knee_a,&x,&y,&z);
|
||||
AddBox(&md2,c4,x,y,z,
|
||||
md2.leg_rad*2,-md2.foot_len,md2.foot_rad*2,md2.leg_rad,0,
|
||||
md2.l_hip_a2,0,md2.l_ankle_a,&x,&y,&z);
|
||||
|
||||
result=Man2CSprite;
|
||||
NewLine(7);
|
||||
Sprite(result,"\t\t$$SP,\"<1>\",BI=%d$$");
|
||||
NewLine(7);
|
||||
Free(m);
|
||||
"Do another";
|
||||
if (YorN)
|
||||
Free(result);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#define T_MAN 0
|
||||
#define T_BALL 1
|
||||
|
||||
U0 Models()
|
||||
{
|
||||
I64 i;
|
||||
Bool old_form=LBts(&(DocPut)->flags,DOCf_FORM);
|
||||
DocClear;
|
||||
"Make a CSprite model. Then, cut-and-Paste it.\n\n";
|
||||
"$$LM,4$$";
|
||||
"\n\n$$BT,\"Man\",LE=T_MAN$$\n\n";
|
||||
"\n\n$$BT,\"Ball\",LE=T_BALL$$\n\n";
|
||||
"$$LM,0$$";
|
||||
i=DocMenuDo(DocPut);
|
||||
LBEqu(&(DocPut)->flags,DOCf_FORM,old_form);
|
||||
DocBottom;
|
||||
switch (i) {
|
||||
case T_MAN:
|
||||
ManGen;
|
||||
break;
|
||||
case T_BALL:
|
||||
BallGen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "/Apps/GrModels/Load"
|
||||
Models;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
#include "/Apps/KeepAway/KeepAway"
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "/Apps/KeepAway/Load"
|
||||
KeepAway;
|
||||
@@ -0,0 +1 @@
|
||||
#include "/Apps/Logic/Logic"
|
||||
@@ -0,0 +1,602 @@
|
||||
#define MAX_TABLE_SIZE 0x10000
|
||||
|
||||
I64 output_found,passes,table_size;
|
||||
|
||||
U8 *gate_type_table =NULL,
|
||||
*displayed_design=NULL,
|
||||
*added_this_pass =NULL;
|
||||
|
||||
U16 *input1_table=NULL,
|
||||
*input2_table=NULL,
|
||||
*input3_table=NULL;
|
||||
|
||||
#define CONNECT_WIDTH 16
|
||||
#define GATE_WIDTH 37
|
||||
|
||||
$ID,6$
|
||||
$SP,"",BI=1$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=2$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=3$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=4$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=5$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=6$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=7$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=8$
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=9$
|
||||
|
||||
|
||||
|
||||
$SP,"",BI=10$
|
||||
|
||||
$ID,-6$
|
||||
|
||||
U8 *gate_type_lst="NULL\0OUTPUT\0INPUT\0"
|
||||
"NOT\0AND\0OR\0NAND\0NOR\0XOR\0AND3\0OR3\0NAND3\0NOR3\0";
|
||||
|
||||
#define GT_NULL 0 //Specifies that table entry has not been filled-in
|
||||
#define GT_OUTPUT 1 //Specifies the table entry is a desired output
|
||||
#define GT_INPUT 2 //Specifies that table entry comes from an input signal
|
||||
|
||||
#define GT_FIRST_REAL_GATE 3
|
||||
#define GT_NOT 3
|
||||
#define GT_AND 4
|
||||
#define GT_OR 5
|
||||
#define GT_NAND 6
|
||||
#define GT_NOR 7
|
||||
#define GT_XOR 8
|
||||
#define GT_AND3 9
|
||||
#define GT_OR3 10
|
||||
#define GT_NAND3 11
|
||||
#define GT_NOR3 12
|
||||
#define GT_NUM_ENTRIES 13
|
||||
|
||||
#define MAX_SELECTED_GATES 128
|
||||
|
||||
CSprite *imgs[GT_NUM_ENTRIES]={NULL,NULL,NULL,
|
||||
$IB,"<NOT>",BI=1$,$IB,"<AND>",BI=2$,$IB,"<OR>",BI=3$,$IB,"<NAND>",BI=4$,$IB,"<NOR>",BI=5$,$IB,"<XOR>",BI=6$,$IB,"<AND3>",BI=7$,$IB,"<OR3>",BI=8$,$IB,"<NAND3>",BI=9$,$IB,"<NOR3>",BI=10$};
|
||||
|
||||
I64 num_inputs_entered,num_outputs_entered;
|
||||
I64 num_selected_gates,
|
||||
selected_gates[MAX_SELECTED_GATES];
|
||||
|
||||
U0 PmtGates()
|
||||
{
|
||||
I64 i;
|
||||
U8 *st;
|
||||
|
||||
"\nEnter the available gate types in the order you prefer them to be used.\n"
|
||||
"Your choices are:\n";
|
||||
for (i=GT_FIRST_REAL_GATE;i<GT_NUM_ENTRIES;i++)
|
||||
"%z ",i,gate_type_lst;
|
||||
NewLine;
|
||||
|
||||
num_selected_gates=0;
|
||||
while (num_selected_gates<GT_NUM_ENTRIES) {
|
||||
"%d",num_selected_gates;
|
||||
st=PmtStr(" Gate: ");
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return;
|
||||
}
|
||||
i=LstMatch(st,gate_type_lst,LMF_IGNORE_CASE);
|
||||
Free(st);
|
||||
if (i<GT_FIRST_REAL_GATE)
|
||||
"Invalid response\n";
|
||||
else
|
||||
selected_gates[num_selected_gates++]=i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
I64 i;
|
||||
|
||||
do {
|
||||
table_size=PmtI64("\nTable size in hex (3 input=0x100,4=0x10000): ",0);
|
||||
if (table_size>MAX_TABLE_SIZE)
|
||||
"Too large\n";
|
||||
else if (table_size<1) {
|
||||
"No table specified, aborting.\n";
|
||||
ThrowBreak;
|
||||
}
|
||||
} while (table_size>MAX_TABLE_SIZE);
|
||||
|
||||
gate_type_table =CAlloc(table_size*sizeof(U8));
|
||||
displayed_design=MAlloc((table_size+7)/8);
|
||||
added_this_pass =MAlloc((table_size+7)/8);
|
||||
input1_table =MAlloc(table_size*sizeof(U16));
|
||||
input2_table =MAlloc(table_size*sizeof(U16));
|
||||
input3_table =MAlloc(table_size*sizeof(U16));
|
||||
|
||||
"\nEnter the hex truth table column values of inputs.\n";
|
||||
if (table_size<=0x100)
|
||||
"For example, enter A=0xF0, B=0xCC and C=0xAA.\n";
|
||||
else
|
||||
"For example, enter A=0xFF00, B=0xF0F0, C=0xCCCC and D=0xAAAA.\n";
|
||||
num_inputs_entered=0;
|
||||
while (TRUE) {
|
||||
"Input %C: ",'A'+num_inputs_entered;
|
||||
i=PmtI64("",-1);
|
||||
if (i<0) break;
|
||||
if (i>table_size)
|
||||
"Too large\n";
|
||||
else {
|
||||
if (gate_type_table[i])
|
||||
"Duplicate\n";
|
||||
else {
|
||||
gate_type_table[i]=GT_INPUT;
|
||||
input1_table[i]=num_inputs_entered++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!num_inputs_entered) {
|
||||
"No inputs specified, aborting.\n";
|
||||
ThrowBreak;
|
||||
}
|
||||
|
||||
"\nEnter the hex truth table columns values of the outputs.\n";
|
||||
num_outputs_entered=0;
|
||||
while (TRUE) {
|
||||
"Output %C: ",'A'+num_outputs_entered;
|
||||
i=PmtI64("",-1);
|
||||
if (i<0) break;
|
||||
if (i>table_size)
|
||||
"Too large\n";
|
||||
else {
|
||||
if (gate_type_table[i]==GT_INPUT)
|
||||
"To produce this output, connect to input %C\n",
|
||||
'A'+input1_table[i];
|
||||
else if (gate_type_table[i]==GT_OUTPUT)
|
||||
"Duplicate\n";
|
||||
else {
|
||||
gate_type_table[i]=GT_OUTPUT;
|
||||
input1_table[i]=num_outputs_entered++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!num_outputs_entered) {
|
||||
"No output specified, aborting.\n";
|
||||
ThrowBreak;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DrawDesign(CDC *dc,I64 *_y,I64 output,I64 depth,I64 *_x_out,I64 *_y_out)
|
||||
{
|
||||
I64 y=*_y,type=gate_type_table[output],
|
||||
xx=(passes-depth)*(GATE_WIDTH+CONNECT_WIDTH),yy=y,
|
||||
x1,y1,x2,y2,x3,y3;
|
||||
if (_x_out) *_x_out=xx;
|
||||
if (_y_out) *_y_out=yy;
|
||||
if (Bt(displayed_design,output) && type!=GT_INPUT) {
|
||||
dc->color=GREEN;
|
||||
GrPrint(dc,xx-FONT_WIDTH*3,y-4,"Dup");
|
||||
y+=10;
|
||||
} else
|
||||
switch (type) {
|
||||
case GT_INPUT:
|
||||
dc->color=GREEN;
|
||||
GrPrint(dc,xx-FONT_WIDTH-4,y-4,"%C",'A'+input1_table[output]);
|
||||
y+=10;
|
||||
break;
|
||||
case GT_NOT:
|
||||
if (!Bt(displayed_design,output)) {
|
||||
y+=16;
|
||||
DrawDesign(dc,&y,input1_table[output],depth+1,&x1,&y1);
|
||||
yy=y1;
|
||||
|
||||
dc->color=BLUE;
|
||||
Sprite3(dc,xx,yy,0,imgs[type]);
|
||||
|
||||
dc->color=RED;
|
||||
GrLine(dc,xx-GATE_WIDTH,yy,x1,y1);
|
||||
if (_y_out) *_y_out=yy;
|
||||
}
|
||||
break;
|
||||
case GT_AND:
|
||||
case GT_OR:
|
||||
case GT_NAND:
|
||||
case GT_NOR:
|
||||
case GT_XOR:
|
||||
if (!Bt(displayed_design,output)) {
|
||||
y+=24;
|
||||
DrawDesign(dc,&y,input1_table[output],depth+1,&x1,&y1);
|
||||
DrawDesign(dc,&y,input2_table[output],depth+1,&x2,&y2);
|
||||
yy=(y1+y2)/2;
|
||||
|
||||
dc->color=BLUE;
|
||||
Sprite3(dc,xx,yy,0,imgs[type]);
|
||||
|
||||
dc->color=RED;
|
||||
GrLine(dc,xx-GATE_WIDTH,yy-4,x1,y1);
|
||||
GrLine(dc,xx-GATE_WIDTH,yy+4,x2,y2);
|
||||
if (_y_out) *_y_out=yy;
|
||||
}
|
||||
break;
|
||||
case GT_AND3:
|
||||
case GT_OR3:
|
||||
case GT_NAND3:
|
||||
case GT_NOR3:
|
||||
if (!Bt(displayed_design,output)) {
|
||||
y+=32;
|
||||
DrawDesign(dc,&y,input1_table[output],depth+1,&x1,&y1);
|
||||
DrawDesign(dc,&y,input2_table[output],depth+1,&x2,&y2);
|
||||
DrawDesign(dc,&y,input3_table[output],depth+1,&x3,&y3);
|
||||
yy=(y1+y2+y3)/3;
|
||||
|
||||
dc->color=BLUE;
|
||||
Sprite3(dc,xx,yy,0,imgs[type]);
|
||||
|
||||
dc->color=RED;
|
||||
GrLine(dc,xx-GATE_WIDTH,yy-8,x1,y1);
|
||||
GrLine(dc,xx-GATE_WIDTH,yy ,x2,y2);
|
||||
GrLine(dc,xx-GATE_WIDTH,yy+8,x3,y3);
|
||||
if (_y_out) *_y_out=yy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
dc->color=BLACK;
|
||||
GrPrint(dc,xx,yy+3,"%04X",output);
|
||||
Bts(displayed_design,output);
|
||||
if (_y) *_y=y;
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *,CDC *dc)
|
||||
{
|
||||
I64 y=0;
|
||||
MemSet(displayed_design,0,(table_size+7)/8*sizeof(Bool));
|
||||
DrawDesign(dc,&y,output_found,0,NULL,NULL);
|
||||
}
|
||||
|
||||
U0 FillNot(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i)) {
|
||||
progress1=i;
|
||||
j= (~i) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_NOT;
|
||||
input1_table[j]=i;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillAnd(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k)) {
|
||||
progress1=i;
|
||||
j= (i & k) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_AND;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillOr(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k)) {
|
||||
progress1=i;
|
||||
j= (i | k) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_OR;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillNAnd(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k)) {
|
||||
progress1=i;
|
||||
j= (~ (i & k)) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_NAND;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillNOr(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k)) {
|
||||
progress1=i;
|
||||
j= (~ (i | k)) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_NOR;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillXor(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k)) {
|
||||
progress1=i;
|
||||
j= (i ^ k) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_XOR;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillAnd3(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,l,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k))
|
||||
for (l=0;l<table_size;l++)
|
||||
if (gate_type_table[l]>GT_OUTPUT && !Bt(added_this_pass,l)) {
|
||||
progress1=i;
|
||||
j= (i & k & l) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_AND3;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
input3_table[j]=l;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillOr3(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,l,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k))
|
||||
for (l=0;l<table_size;l++)
|
||||
if (gate_type_table[l]>GT_OUTPUT && !Bt(added_this_pass,l)) {
|
||||
progress1=i;
|
||||
j= (i | k | l) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_OR3;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
input3_table[j]=l;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillNAnd3(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,l,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k))
|
||||
for (l=0;l<table_size;l++)
|
||||
if (gate_type_table[l]>GT_OUTPUT && !Bt(added_this_pass,l)) {
|
||||
progress1=i;
|
||||
j= (~(i & k & l)) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_NAND3;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
input3_table[j]=l;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FillNOr3(Bool *chged,I64 *num_outputs_found)
|
||||
{
|
||||
I64 i,j,k,l,old_type;
|
||||
for (i=0;i<table_size;i++)
|
||||
if (gate_type_table[i]>GT_OUTPUT && !Bt(added_this_pass,i))
|
||||
for (k=0;k<table_size;k++)
|
||||
if (gate_type_table[k]>GT_OUTPUT && !Bt(added_this_pass,k))
|
||||
for (l=0;l<table_size;l++)
|
||||
if (gate_type_table[l]>GT_OUTPUT && !Bt(added_this_pass,l)) {
|
||||
progress1=i;
|
||||
j= (~(i | k | l)) & (table_size-1);
|
||||
old_type=gate_type_table[j];
|
||||
if (old_type<GT_INPUT) {
|
||||
gate_type_table[j]=GT_NOR3;
|
||||
input1_table[j]=i;
|
||||
input2_table[j]=k;
|
||||
input3_table[j]=l;
|
||||
Bts(added_this_pass,j);
|
||||
*chged=TRUE;
|
||||
if (old_type==GT_OUTPUT) {
|
||||
if (output_found<0) output_found=j;
|
||||
*num_outputs_found=*num_outputs_found+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
I64 FillGateTable()
|
||||
{
|
||||
I64 current_gate,num_outputs_found=0;
|
||||
Bool chged=TRUE;
|
||||
passes=1;
|
||||
output_found=-1;
|
||||
ProgressBarsRst;
|
||||
progress1_max=table_size;
|
||||
NewLine;
|
||||
while (num_outputs_found<num_outputs_entered && chged) {
|
||||
"Pass : %d\n",passes++;
|
||||
chged=FALSE;
|
||||
MemSet(added_this_pass,0,(table_size+7)/8);
|
||||
for (current_gate=0;current_gate<num_selected_gates &&
|
||||
num_outputs_found<num_outputs_entered;current_gate++) {
|
||||
switch (selected_gates[current_gate]) {
|
||||
case GT_NOT: FillNot (&chged,&num_outputs_found); break;
|
||||
case GT_AND: FillAnd (&chged,&num_outputs_found); break;
|
||||
case GT_OR: FillOr (&chged,&num_outputs_found); break;
|
||||
case GT_NAND: FillNAnd (&chged,&num_outputs_found); break;
|
||||
case GT_NOR: FillNOr (&chged,&num_outputs_found); break;
|
||||
case GT_XOR: FillXor (&chged,&num_outputs_found); break;
|
||||
case GT_AND3: FillAnd3 (&chged,&num_outputs_found); break;
|
||||
case GT_OR3: FillOr3 (&chged,&num_outputs_found); break;
|
||||
case GT_NAND3: FillNAnd3(&chged,&num_outputs_found); break;
|
||||
case GT_NOR3: FillNOr3 (&chged,&num_outputs_found); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ProgressBarsRst;
|
||||
return num_outputs_found;
|
||||
}
|
||||
|
||||
U0 CleanUp()
|
||||
{
|
||||
Free(gate_type_table);
|
||||
Free(displayed_design);
|
||||
Free(added_this_pass);
|
||||
Free(input1_table);
|
||||
Free(input2_table);
|
||||
Free(input3_table);
|
||||
}
|
||||
|
||||
U0 DigitalLogic()
|
||||
{
|
||||
gate_type_table =NULL;
|
||||
displayed_design=NULL;
|
||||
added_this_pass =NULL;
|
||||
input1_table =NULL;
|
||||
input2_table =NULL;
|
||||
input3_table =NULL;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
WordStat;
|
||||
WinBorder(ON);
|
||||
DocClear;
|
||||
PmtGates;
|
||||
try {
|
||||
Init;
|
||||
if (FillGateTable) {
|
||||
DocCursor;
|
||||
DocClear;
|
||||
Fs->draw_it=&DrawIt;
|
||||
GetChar;
|
||||
DocClear;
|
||||
WinMgrSync(2,TRUE);
|
||||
DocBottom;
|
||||
}
|
||||
} catch
|
||||
PutExcept;
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
}
|
||||
| ||||