/* defs.h -- common defines, types and prototypes for ASpringies
 * Copyright (C) 1991  Douglas M. DeCarlo
 *
 * Modifications for the Amiga port Copyright (C) 1994  Torsten Klein
 *
 * This file is part of ASpringies, a mass and spring simulation system for the Amiga
 *
 * ASpringies is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 1, or (at your option)
 * any later version.
 *
 * ASpringies is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ASpringies; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: defs.h,v 1.5 1994/06/26 20:37:19 Torsten_Klein Exp $
 */

#include <stdio.h>

#include <math.h>
#include <stdlib.h>
#include <exec/types.h>

typedef char boolean;

#define TRUE            1
#define FALSE           0

#define MAXPATHLEN 128

#define COORD_X(x)	(x)
#define COORD_Y(y)	(draw_ht - (y))
#define COORD_DX(dx)	(dx)
#define COORD_DY(dy)	(-(dy))

/* File operations */
#define F_NONE		0
#define F_LOAD		1
#define F_SAVE		2
#define F_INSERT	3

#define F_SAVEAS        4

#define SQR(x)          ((x) * (x))
#define SGN(x)          ((x) < 0 ? (-1) : 1)
#ifndef ABS
#define ABS(x)          ((x) < 0 ? (-(x)) : (x))
#endif
#ifndef MIN
#define MIN(x,y)        ((x) < (y) ? (x) : (y))
#define MAX(x,y)        ((x) < (y) ? (y) : (x))
#endif

/* Types of mouse actions */
#define M_DOWN		0
#define M_UP		1
#define M_DRAG		2
#define M_HOLD		3
#define M_REDISPLAY	4

/* Forces */
#define FR_GRAV		0
#define FR_CMASS	1
#define FR_PTATTRACT	2
#define FR_WALL		3

#define BF_NUM		4

/* Defaults */
#define DEF_TSTEP	0.025

typedef struct {
  double  
    cur_mass, cur_rest, cur_ks, cur_kd;
  boolean 
    fix_mass, show_spring;
  int
    center_id, bf_mode[BF_NUM];
  double  
    cur_grav_val[BF_NUM], cur_misc_val[BF_NUM],
    cur_visc, cur_stick,  cur_dt, cur_prec;
  boolean
    adaptive_step, grid_snap;
  double 
    cur_gsnap;
  boolean 
    w_top, w_left, w_right, w_bottom;
} t_state;


/* -------- Variables defined --------- */

/* misc.c */
char *xmalloc (int size);
char *xrealloc (char *ptr, int size);

/* file.c */
boolean file_command(char *file, int command);


/* newmain.c */
extern int draw_wid, draw_ht;
extern t_state mst;

void new_main(void);
void redisplay_widgets(void);
int mass_radius(double m);
void review_system(void);

/* obj.h */

void init_objects(void);
void attach_fake_spring(int );
void kill_fake_spring(void);
void move_fake_mass(int , int );
int create_mass(void);
int create_spring(void);
void add_massparent(int , int );
void del_massparent(int , int );
void delete_spring(int );
void delete_mass(int );
void delete_selected(void);
void delete_all(void);
void reconnect_masses(void);
void restore_state(void);
void save_state(void);
int nearest_object(int , int , boolean *);
void eval_selection(void);
boolean anything_selected(void);
void select_object(int , boolean , boolean );
void select_objects(int , int , int , int , boolean );
void unselect_all(void);
void select_all(void);
void duplicate_selected(void);
void translate_selobj(int , int );
void changevel_selobj(int , int , boolean );
void tempfixed_obj(boolean );
void set_sel_restlen(void);
void set_center(void);

/* phys.c
 */
boolean animate_obj(void);

