/* prototyp.h  14-12-93 */
/* function prototypes for Tierra Simulator, included at end of tierra.h */
/* Tierra Simulator V4.1: Copyright (c) 1991, 1992, 1993 */
/* Tom Ray & Virtual Life */

/*
 * h_sccsid: @(#)prototyp.h	1.4	4/26/92
 */

#include "license.h"
#include "configur.h"

#ifndef PROTOTYP_H
#define PROTOTYP_H

extern void Emigrate P_((I32s  gen, I32s  siz));
extern void FreeGen P_((GList  *g, I32s qr));
extern GList * GetAGen P_((I8s  *crit));
extern I8s IsFree P_((I32s  x));
extern I32s MemAlloc P_((I32s  size, I32s  pref, I32s  tol));
extern void MemDealloc P_((I32s  x, I32s  y));
extern void MemInit P_((void));
extern void Inject P_((FpInst  g, I32s  size, I32s  sad, I32s  tol,
        I32s  disk, float  *rrpi));
extern void InjectFromBank P_((I8s  *crit, I32s  sad, I32s  tol));
extern Pcells GetFreeCell P_((void));
extern Pcells FindPutCell P_((Pcells  ce, I32s  adre));
extern I32s Hash P_((I32s  size, FpInst  v));
extern void FreeDynMem P_((void));
extern void GBGarbageCollect P_((void));
extern void CellsGarbageCollect P_((void));
extern void VerifyGB P_((void));
extern void SavGeneBank P_((void));
extern void SavDynMem P_((I8s  filename[]));
extern void ReadGeneBank P_((void));
extern void ReadDynMem P_((I8s  filename[]));
extern void DivideBookeep P_((Pcells  ce, Pcells  ne));
extern void DivGenBook P_((Pcells  ce, Event  InstExe,
        I32s  reaped, I32s  mom, I32s  same, I32s  disk));
extern void OutDisk P_((I32s bd, Pcells nc));
extern void ReapBookeep P_((Pcells  ce));
extern void ReapGenBook P_((Pcells  ce));
extern void MutBookeep P_((I32s i));
extern void plan P_((void));
extern void stats P_((void));
extern void MemoryProfile P_((void));
extern void CalcAverages P_((void));
extern void CalcSoupMaxes P_((void));
extern void CalcSoupStats P_((void));
extern void CalcGBMaxes P_((SList Fp Fp  lsl, I32s  lsiz_sl));
extern void CalcGBStats P_((SList Fp Fp  lsl, I32s  lsiz_sl));
extern void CalcTimeSoup P_((void));
extern SList Fp Fp MkGBFromSoup P_((I32s  *lsiz_sl));
extern void FreeGB P_((SList Fp Fp lsl, I32s lsiz_sl));
extern void extract P_((Pcells  ce));
extern void GetGenList P_((I32s  flags));
extern void InitGList P_((Pgl g, I32s si, I32s gi, I32s size));
#ifdef CM5
extern void CheckGenotype P_((Dem  * ce, I32s  flags, I32u sourcePN, I32u pass_back_parent, I32u pending));
#else /* CM5 */
extern void CheckGenotype P_((Dem  * ce, I32s  flags));
#endif /* CM5 */
extern int gc P_((void));
extern I8s IsNewSize P_((I32s  si));
extern void NewSize P_((Dem  *ce, I32s  flags));
extern I16s IsInGenQueue P_((Dem  *ce, I32s  hash));
extern I16s IsInGenBank P_((Dem  *ce, I32s  hash, I32s  flags));
extern void JumpTrack P_((Pcells  ce));
extern I16s NewGenotype P_((Dem  *ce, I32s  hash));
extern I32u WhoIs P_((Pcells  Fp ce, I32s a));
extern I8s IsSameGen P_((I32s size, FpInst g1, FpInst g2));
extern void gq_add P_((GList  *p));
extern void gq_movtop P_((GList  *p));
extern I8s gq_swap P_((void));
extern void gq_rem P_((GList  *p));
extern GList *gq_read P_((int si, int gi));
extern void printq P_((void));
extern void IncrLbl P_((I8s *lbln, I8s *lblo));
extern void MaxLbl P_((I8s *lbl, I8s *s));
extern I8s *Int2Lbl P_((I32s i));
extern I16s Lbl2Int P_((I8s  *s));
extern void DelGenFile P_((Pgl tgl));
extern FILE *open_ar P_((I8s *file, I32s size, I32s format, I32s mode));
extern head_t read_head P_((FILE * fp));
extern void write_head P_((FILE * fp, head_t * head));
extern indx_t *read_indx P_((FILE * fp, head_t * head));
extern void write_indx P_((FILE * fp, head_t * head, indx_t * indx));
extern I32s find_gen P_((FILE  *fp, indx_t  *indx, I8s  *gen, I32s  n));
extern Pgl get_gen P_((FILE * fp, head_t * head, indx_t * indxn, I32s n));
extern I32s add_gen P_((FILE * fp, head_t * head, indx_t ** indx, Pgl gen));
extern I16s GetAscGen P_((Pgl g, I8s ifile[]));
extern I8s WritGenFile P_((Pgl  g, I8s  file[]));
extern void WritAscFile P_((Pgl  g, I8s  *file));
extern I16s GetGenFormat P_((Pgl g, I8s file[]));
extern Ascii2Ebcdic P_((I8s *s));
extern Ebcdic2Ascii P_((I8s *s));
extern void WritEcoB P_((I32u bits, I8s * buf));
extern void SetBit P_((I32u *seed, I32u bit, I32u value));
extern void nop P_((Pcells ce));
extern void not0 P_((Pcells ce));
extern void skip P_((Pcells ce));
extern void math P_((Pcells ce));
extern void push P_((Pcells ce));
extern void pop P_((Pcells ce));
extern void tcall P_((Pcells ce));
extern void call P_((Pcells ce));
extern void mov P_((Pcells ce));
extern void movdd P_((Pcells ce));
extern void movdi P_((Pcells ce));
extern void movid P_((Pcells ce));
extern void movii P_((Pcells ce));
extern void adr P_((Pcells ce));
extern I32s mal P_((Pcells  ce, I32s  *sug_addr, I32s  sug_size, I32s  mode));
extern I8s  chmode P_((Pcells ce, I32s start, I32s size, I32s mode));
extern void malchm P_((Pcells ce));
extern void divide P_((Pcells ce));
extern void CheckCells P_((void));
extern I32s flaw P_((Pcells ce));
extern I32s template P_((I32s f, I32s b, I32s  *slim, I32s tz, I32s dir,
    I32s mode, Pcells ce));
extern I32s ctemplate P_((I32s  *f, I32s  *b, I32s  *slim, I8s  *mode,
    I32s  tz, I32s  dir, Pcells  ce));
extern I32s btemplate P_((I32s f, I32s b, I32s  *slim, I32s tz, I32s dir,
    I32s mode, Pcells ce));
extern I8s IsPriv P_((Pcells ce, I32s a));
extern I8s IsBitPriv P_((Pcells ce, I32s a, I32s mode));
extern I8s PrivExec P_((Pcells ce, I32s a));
extern I8s PrivWrite P_((Pcells ce, I32s a));
extern I8s PrivRead P_((Pcells ce, I32s a));
extern I8s IsInsideCell P_((Pcells ce, I32s a));
extern void WhichCell P_((I32s  a, Pcells Fp  ce, I8s  *md));
/* extern void SetFlag P_((Pcells ce)); */
extern void thfree P_((I8s Hp ptr));
extern void tfree P_((I8s Fp ptr));
extern I8s Hp threcalloc P_((I8s  Hp ptr, I32u  nsiz, I32u  osiz));
extern I8s Fp trecalloc P_((I8s  Fp ptr, I32u  nsiz, I32u  osiz));
extern I8s Hp thcalloc P_((I32u num, I32u siz));
extern I8s Fp tcalloc P_((I32u  num, I32u  siz));
extern I32u tfread P_((I8s Hp ptr, I32s size, I32s n, FILE * stream));
extern I32u tfwrite P_((I8s Hp ptr, I32s size, I32s n, FILE * stream));
extern void IncrSliceQueue P_((void));
extern void EntBotSlicer P_((Pcells  ce));
extern void UpReaper P_((Pcells  ce));
extern void DownReaper P_((Pcells  ce));
extern void UpRprIf P_((Pcells  ce));
extern void DownReperIf P_((Pcells  ce));
extern void EntBotReaper P_((Pcells  ce));
extern void RmvFrmReaper P_((Pcells  ce));
extern void RmvFrmSlicer P_((Pcells  ce));
extern void SlicerPhoton P_((void));
extern I32s PhotonFit P_((I32s a, I8s *PhotonInst, I32s PhotonSize));
extern I32s PhotonSlide P_((I32s a, I8s *PhotonInst, I32s PhotonSize,
			    I32s PhotonWidth));
extern void PhotonTranslate P_((I8s *PhotonInst, I8s *PhotonWord));
extern void SlicerQueue P_((void));
extern void RanSlicerQueue P_((void));
extern int main P_((int argc, char *argv[]));
extern void life P_((void));
extern void TimeSlice P_((Pcells  ce, I32s size_slice));
extern I16s FetchDecode P_((Pcells  ce));
extern void IncrementIp P_((Pcells  ce));
extern void IncrNPrIp P_((Pcells  ce));
extern void SystemWork P_((Pcells  ce));
extern void mutate P_((void));
extern void mut_site P_((HpInst s, I32s t));
extern void ReapCheck P_((void));
extern void reaper P_((I32s  ex, I32s  sad));
extern I32s SubEvent P_((Event * event1, Event * event2, Event * result));
extern void tsrand P_((I32s seed));
extern double tdrand P_((void));
extern I8s GetAVar P_((I8s data[85]));
extern void GetAMap P_((I8s  file[85]));
extern void GetSoup P_((I32s argc, I8s *argv[]));
extern void StupGenLists P_((void));
extern void GetNewSoup P_((void));
extern void GetOldSoup P_((FILE * inf));
extern void WriteSoup P_((I32s close_disk));
extern void ToggleLog P_((void));
extern I16s glcmp P_((const void *gl1, const void *gl2));
extern I16s slcmp P_((const void *sl1, const void *sl2));
extern void InitCell P_((I32s  ar, I32s  ci, Pcells  ce));
extern void GenExExe P_((Pcells  ce, I32s adrt));
extern void GenExMov P_((Pcells  ce, I32s  to, I32s  from));
extern void GenExTemp P_((I32s adrt, Pcells  ce, I32s tsize));
extern void FEExit P_((I32s n));
extern void FEMemCheck P_((I8s  *msg));
extern void FEMemProf P_((I32s  SizSoup, I32s  SizCells, I32s  SizFreeMem,
    I32s  SizSl, I32s  SizSli, I32s  SizGl, I32s  SizGli, I32s  SizGen));
extern void FEMessage P_((I32s n));
extern void FEStats P_((void));
extern void FEClrmsg P_((I32s n));
extern void FECeol P_((void));
extern I16s FEGetc P_((void));
extern void FEStartup P_((void));
extern void FEPlan P_((void));
extern void FEPrintf P_((I32s scr_x, I32s scr_y, I32s scr_a, ...));
/* turbo c insanity in line above */
extern void FEError P_((I32s err_no, I32s err_exit, I32s err_write, ...));
extern void query_size P_((I32s size_class));
extern void query_species P_((I32s num));
extern void FESoupImage	P_((FILE *fp, I32s x, I32s y, I32s n));
extern void FEPrintSI	P_((FILE *fp,I32s addr,I32s x,I32s n,I32s sz,I32s md));
extern void (*execute) P_((Cell  *));  /* pointer to execute function */
extern void (*decode) P_((Cell  *));    /* pointer to parse function */

#ifdef CM5
void SendTNdataToHost() ;
void SendGBdataToHost() ;
#endif /* CM5 */

#if FRONTEND != STDIO
extern void query_spec_d P_((I32s size, I32s lbl));
extern void FEMenu P_((void));
#endif /* FRONTEND != STDIO */

#ifdef __TURBOC__

#if FRONTEND == STDIO
extern int T_sig_int   P_((void));
#endif /* FRONTEND == STDIO */

#if FRONTEND == BASIC
extern void FE_DosVideoToggle P_((I16s mode));
#endif /* FRONTEND == BASIC */

#endif /* __TURBOC__ */

#ifdef unix
extern void T_sig_int  P_((I32s sig, I32s code, I32s *scp, I8s *addr));
extern void T_sig_read P_((I32s sig, I32s code, I32s * scp, I8s *addr));
extern void T_sig_write P_((I32s sig, I32s code, I32s * scp, I8s *addr));
extern void T_sig_info P_((I32s sig, I32s code, I32s * scp, I8s *addr));
#endif /* unix */

#ifdef ALCOMM
extern void	_t_init_alcomm P_((void));
extern void	_t_life_bookeep P_((void));
extern void     _t_memory_stats P_(( unsigned char which, void *indata,
                    int inlen, void **outdata, int *outdatalen ));
extern void     _t_sim_runcontrol P_(( unsigned char which, void *data,
                    int datalen ));
extern void     _t_init_birthdeath P_(( ALtCLink * clink ));
extern void     _t_query_org P_(( I32s which, void * indata, int inlen, 
                    void **outdata, int *outdatalen ));
#endif /* ALCOMM */

#ifdef MICRO
extern void Micro_Spy P_(( Pcells ce));
#endif /* MICRO */

#ifdef HSEX
extern I8s  FindMate P_((Pcells ce));
extern I16s SetXover P_((Pcells ce));
extern I8s  DoMate   P_((void));
#endif /* HSEX */

#ifdef I/O

extern void put P_((Pcells  ce));
extern void puticc P_((Pcells  ce));
extern void pputicc P_((Pcells  ce));
extern I8s ReadFPut P_((Pcells  ce, I32s  *value));
extern void get P_((Pcells  ce));
extern void pget P_((Pcells  ce));
extern void Write2Get P_((Pcells  ce, I32s  value));
extern void Broad2Get P_((I32s  value));

#endif /* I/O */

extern void csync P_((Pcells ce));
extern void dec1s P_((Pcells  ce));
extern void dec2s P_((Pcells  ce));
extern void dec1d P_((Pcells  ce));
extern void dec1d1s P_((Pcells  ce));
extern void dec1d2s P_((Pcells  ce));
extern void dec1d3s P_((Pcells  ce));
extern void decadr P_((Pcells  ce));
extern void decjmp P_((Pcells  ce));
extern void enter P_((Pcells  ce));
extern void exch P_((Pcells  ce));
extern void getregs P_((Pcells  ce));
extern void join P_((Pcells  ce));
extern void not P_((Pcells  ce));
extern void offset P_((Pcells  ce));
extern void pmovdi P_((Pcells  ce));
extern void pmovid P_((Pcells  ce));
extern void pmovii P_((Pcells  ce));
extern void pnop P_((Pcells  ce));
extern void ptcall P_((Pcells  ce));
extern void rolld P_((Pcells  ce));
extern void rollu P_((Pcells  ce));
extern void shl P_((Pcells  ce));
extern void shr P_((Pcells  ce));
extern void split P_((Pcells  ce));

#ifdef SHADOW

extern void regorder P_((Pcells  ce));
extern void pushst P_((Pcells  ce));

#endif /* SHADOW */

#if PLOIDY > 1

extern void trex P_((Pcells  ce));
extern void trso P_((Pcells  ce));
extern void trde P_((Pcells  ce));
extern void ptrack P_((Pcells  ce));

#endif /* PLOIDY > 1 */

#endif /* PROTOTYP_H */
/* ---------------------------------------------------------------------- */
