home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
306.lha
/
Gravity-Well
/
GW-Include.h
< prev
next >
Wrap
Text File
|
1980-12-03
|
17KB
|
480 lines
/*
GW-Include.h
Shared code include for Gravity-Well
Gary Teachout
Copyright July 1989
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <graphics/gfxmacros.h>
#include <string.h>
#include <math.h>
#include <float.h>
#define LINEPEN 1 /* pen colors */
#define DOTPEN 3
#define BPEN 2
#define DPEN 0
#define MFPEN 0
#define MBPEN 2
#define NEWCENTER 1 /* awaiting */
#define NEWPOSITION 2
#define NEWVELOCITY 3
#define NEWMASS 4
#define NEWCREATE 5
struct dv /* double 3 - d vector */
{ double x , y , z ; } ;
struct obv /* orthogonal basis vectors */
{ struct dv i , j , k ; } ;
struct object /* data for each body */
{
struct dv position ,
velocity ,
oldpos ,
startpos ,
startvel ;
double mass ,
startmass ,
radius ;
short flags ,
collision ;
char name[ 68 ] ;
} ;
struct filedata /* data for the entire simulation */
{
char tag[ 16 ] ;
struct object objects[ 20 ] ;
struct obv viewbasis ,
unviewbasis ;
struct dv viewoffset ;
double elapsedtime ,
timestep ,
scale ,
magic ;
USHORT stopflag ,
awaiting ,
trailson ,
objectnum ,
follow ;
char filecomment1[ 66 ] ,
filecomment2[ 66 ] ;
} ;
struct menubox /* text menu items */
{
struct MenuItem item ;
struct IntuiText text ;
} ;
/* System prototypes */
char *AllocMem() ;
struct Screen *OpenScreen() ;
struct Window *OpenWindow() ;
struct IntuiMessage *GetMsg() ;
struct FileHandle *Open() ;
struct TextFont *OpenDiskFont() ;
/* GW-Main prototypes */
void main( void ) ;
void takestep( double ) ;
/* GW-Interface prototypes */
void startup( void ) ;
void cleanup( void ) ;
void openmainview( void ) ;
void opentopview( void ) ;
void openrightview( void ) ;
void openviewcontrol( void ) ;
void pixel( struct Window * , double , double ) ;
void blankwindow( struct Window * ) ;
void line( struct Window * , double , double , double , double ) ;
void linelong( struct Window * , long , long , long , long ) ;
void interface( void ) ;
void readmes( void ) ;
void handelmenu( void ) ;
void stoploop( void ) ;
void resetdisplay( void ) ;
void screentitle( long ) ;
void setupdisplay( struct Window * ) ;
void set( void ) ;
void create( void ) ;
void setstrings( void ) ;
void deleteobject( long ) ;
void endtrail( long , long ) ;
void updatedisplay( void ) ;
/* GW-Vectors prototypes */
void rotatedv( struct dv * , struct dv * , double * , double * ) ;
void rotatedvpair10( struct dv * , struct dv * ) ;
void adddv( struct dv * , struct dv * , struct dv * ) ;
void subdv( struct dv * , struct dv * , struct dv * ) ;
void scaledv( struct dv * , double * , struct dv * ) ;
void dotdv( struct dv * , struct dv * , double * ) ;
void crossdv( struct dv * , struct dv * , struct dv * ) ;
void magdv( struct dv * , double * ) ;
void basis( struct dv * , struct obv * , struct dv * ) ;
/* Global Data */
/* all but one file must be compiled with the -x option */
struct IntuitionBase *IntuitionBase ;
struct GfxBase *GfxBase ;
struct Library *DiskfontBase ;
struct IntuiMessage *mes ;
struct Screen *screen ;
struct Window *control , /* renamed the Data window */
*viewcontrol ,
*mainview ,
*topview ,
*rightview ;
struct TextAttr stext = { "topaz.font" , 8 , 0 , 0 } ;
struct TextAttr rtext = { "topaz.font" , 11 , 0 , 0 } ;
struct TextFont *rfont ;
ULONG class ;
USHORT code ;
short mousex ,
mousey ;
struct Gadget *iadd ;
char *titletext[ 6 ] =
{
" Gravity Well" ,
" Gravity Well Awating New Center Point" ,
" Gravity Well Awating New Position" ,
" Gravity Well Awating New Velocity" ,
" Gravity Well Awating New Mass" ,
" Gravity Well Create Mode"
} ;
char ettext[ 33 ] ;
char numbertext[] =
" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 " ;
char *controlgtext[ 11 ] =
{
"Position" , "Velocity" , "Mass " ,
"Delete " , "Zero M " , "Start " ,
" Load " , " Save " , " New " ,
" Create " , " Enter "
} ;
char *conlabel[ 10 ] =
{
"File Name:" ,
"Comment:" ,
"" ,
"Name:" ,
"Time Step:" ,
"Magic:" ,
"Mass:" ,
"Radius:" ,
"Start Position:" ,
"Start Velocity:"
} ;
short conlabellength[ 10 ] =
{ 10 , 8 , 0 , 5 , 10 , 6 , 5 , 7 , 15 , 15 } ;
short clut[ 4 ][ 3 ] = /* screen colors */
{
{ 0 , 0 , 0 } ,
{ 15 , 0 , 0 } ,
{ 10 , 8 , 0 } ,
{ 15 , 15 , 15 }
} ;
struct NewScreen ns =
{
0 , 0 , 640 , 400 , 2 , DPEN , BPEN , HIRES | LACE ,
CUSTOMSCREEN , NULL , " Gravity Well" , NULL , NULL
} ;
struct NewWindow
controlnw = /* the Data window */
{
0 , 12 , 640 , 388 , DPEN , BPEN , MENUPICK | GADGETUP ,
WINDOWDEPTH
| SMART_REFRESH | ACTIVATE ,
NULL , NULL , " Data " ,
NULL , NULL , 0 , 0 , 0 , 0 , CUSTOMSCREEN
} ,
viewcontrolnw =
{
490 , 0 , 100 , 173 , DPEN , BPEN , CLOSEWINDOW | MENUPICK | GADGETUP ,
WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , "VC " ,
NULL , NULL , 0 , 0 , 0 , 0 , CUSTOMSCREEN
} ,
mainviewnw =
{
80 , 92 , 460 , 308 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Main View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ,
topviewnw =
{
80 , 12 , 460 , 80 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Top View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ,
rightviewnw =
{
540 , 92 , 100 , 308 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Right View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ;
struct Menu menustrip[ 3 ] = /* all windows share this menu strip */
{
{ NULL , 1 , 0 , 120 , 10 , MENUENABLED , " QUIT" , NULL } ,
{ NULL , 121 , 0 , 120 , 10 , MENUENABLED , " Open Window" , NULL } ,
{ NULL , 241 , 0 , 120 , 10 , MENUENABLED , " Control" , NULL }
} ;
struct menubox
menu0[ 1 ] =
{
{
{ NULL , 0 , 0 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "QUIT" , NULL }
}
} ,
menu1[ 5 ] =
{
{
{ NULL , 0 , 0 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Main View" , NULL }
} ,
{
{ NULL , 0 , 14 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Top View" , NULL }
} ,
{
{ NULL , 0 , 28 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Right View" , NULL }
} ,
{
{ NULL , 0 , 42 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "View Control" , NULL }
} ,
{
{ NULL , 0 , 56 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Data" , NULL }
}
} ,
menu2[ 5 ] =
{
{
{ NULL , 0 , 0 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Start" , NULL }
} ,
{
{ NULL , 0 , 14 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Stop" , NULL }
} ,
{
{ NULL , 0 , 28 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Set" , NULL }
} ,
{
{ NULL , 0 , 42 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Reset" , NULL }
}
} ;
struct Gadget
viewcongadg[ 12 ] = /* gadgets for View Control window */
{
{ NULL , 8 , 60 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 72 , 60 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 8 , 76 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 72 , 76 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 8 , 92 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 72 , 92 + 16 , 20 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 10 , 108 + 16 , 80 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 8 , 140 + 16 , 28 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 56 , 140 + 16 , 36 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 10 , 28 + 16 , 80 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 10 , 12 + 16 , 80 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 10 , 12 , 80 , 15 , GADGHCOMP , RELVERIFY , BOOLGADGET }
} ,
controlgadg[ 45 ] = /* gadgets for Data window */
{
{ NULL , 6 , 12 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 26 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 40 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 54 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 68 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 82 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 96 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 110 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 124 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 138 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 152 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 166 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 180 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 194 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 208 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 222 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 236 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 250 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 264 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 278 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 294 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 308 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 322 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 336 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 350 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 6 , 364 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 100 , 87 - 5 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 200 , 87 - 5 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 300 , 87 - 5 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 100 , 217 + 5 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
/* 30 */
{ NULL , 200 , 217 + 5 , 72 , 13 , GADGHCOMP , RELVERIFY , BOOLGADGET } ,
{ NULL , 100 , 74 - 5 , 528 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 126 - 5 , 528 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 139 - 4 , 528 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 256 + 5 , 528 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 178 - 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 370 , 178 - 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 295 + 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 370 , 295 + 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 334 + 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 370 , 334 + 5 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 347 + 6 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 370 , 347 + 6 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 100 , 360 + 7 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET } ,
{ NULL , 370 , 360 + 7 , 264 , 8 ,
GADGHCOMP , TOGGLESELECT | RELVERIFY , STRGADGET }
} ;
struct StringInfo controlinfo[ 14 ] ;
struct Border textbox = { -2 , -2 , BPEN , 0 , JAM1 , 5 } ,
numberbox = { -2 , -2 , BPEN , 0 , JAM1 , 5 } ;
short xytextbox[ 10 ] = { 0 , 0 , 532 , 0 , 532 , 11 , 0 , 11 , 0 , 0 } ,
xynumbox[ 10 ] = { 0 , 0 , 268 , 0 , 268 , 11 , 0 , 11 , 0 , 0 } ;
char undobuffer[ 100 ] ,
filename[ 100 ] ,
numberbuff[ 10 ][ 34 ] ;
struct dv zerodv = { 0.0 , 0.0 , 0.0 } ; /* reference vectors */
struct obv refobv =
{ { 1.0 , 0.0 , 0.0 } , { 0.0 , 1.0 , 0.0 } , { 0.0 , 0.0 , 1.0 } } ;
struct filedata g = /* data for the entire simulation */
{
"Gravity-Well-10" ,
{
{
{ 0.2539644458873187 , 0.0570845085389242 , 0.0 } ,
{ 0.0133749752769728 , -0.0183469991534279 , 0.0 } ,
{ 0.0 , 0.0 , 0.0 } ,
{ 0.0 , 0.0 , 0.0 } ,
{ 0.0 , 0.0 , 0.0 } ,
1.0 , 0.0 , 0.9 ,
1 , 0 ,
"Planet Not the earth"
} ,
{
{ 13.4603555411268747 , 9.1291549146107567 , 0.0 } ,
{ -0.133749752769728 , 0.1834699915342789 , 0.0 } ,
{ 0.0 , 0.0 , 0.0 } ,
{ 1.0 , 0.0 , 0.0 } ,
{ 0.0 , 1.0 , 0.0 } ,
0.1 , 0.0 , 0.2 ,
1 , 0 ,
"Moon"
} ,
{
{ 0.492 , -1.3 , -0.02 } ,
{ 1.16 , 0.15 , 0.12 } ,
{ 0.0 , 0.0 , 0.0 } ,
{ 1.0 , 0.0 , 0.0 } ,
{ 0.0 , 1.0 , 0.0 } ,
0.0 , 0.0 , 0.0 ,
1 , 0 ,
"Space Ship"
}
} ,
{ { 1.0 , 0.0 , 0.0 } , { 0.0 , 1.0 , 0.0 } , { 0.0 , 0.0 , 1.0 } } ,
{ { 1.0 , 0.0 , 0.0 } , { 0.0 , 1.0 , 0.0 } , { 0.0 , 0.0 , 1.0 } } ,
{ 0.0 , 0.0 , 0.0 } ,
0.0 , 0.5 , 0.0298023223876953 , 100.0 ,
0 , 0 , 1 , 0 , 0 ,
"Example simulation" ,
"At play in space and time"
} ;