/*
 * functions.h (this name used by Aztec C)
 *
 * proto/all.h (this name used by Lattice C / SAS C)
 *
 * Created by TetiSoft 25.5.90 (DOS and Exec)
 *
 * 10-01-91 TetiSoft Added Intuition
 *
 * 11-01-91 TetiSoft Took Returnvalues from Commodore's Autodocs 1.3.
 *
 * 11-01-91 TetiSoft Added Diskfont
 *
 * 11-01-91 TetiSoft Added Expansion
 *
 * 11-01-91 TetiSoft Added Graphics
 *
 * 11-01-91 TetiSoft Added Icon
 *
 * 11-01-91 TetiSoft Added Layers
 *
 * 11-01-91 TetiSoft Added Mathffp
 *
 * 11-01-91 TetiSoft Added Mathieeedoubbas and commented it out
 *
 * 11-01-91 TetiSoft Added Mathieeedoubtrans and commented it out
 *
 * 11-01-91 TetiSoft Added Mathtrans
 *
 * 11-01-91 TetiSoft Added Translator
 *
 * 11-01-91 TetiSoft Removed all 'extern' words
 *
 * 13-01-91 TetiSoft Changed mathffp return values from long to int
 *                   to be compatible with libraries/mathffp.h
 *
 * 13-01-91 TetiSoft Changed icon return values from BOOL to LONG
 *                   to be compatible with workbench/icon.h
 *
 * 13-01-91 TetiSoft Changed expansion return value from BYTE to CPTR
 *                   to be compatible with libraries/expansion.h
 *
 * 20-01-91 TetiSoft Added amigalib functions to be compatible with Aztec C
 *
 * 20-01-91 TetiSoft Added CIA Resource, Potgo Resource, Console Device,
 *                   Timer Device
 *
 * 24-01-91 TetiSoft Corrected BOOL returns of dos library to long since
 *                   libraries/dos.h declares DOSTRUE and DOSFALSE to be long,
 *                   but exec/types.h declares BOOL as short. This is in
 *                   contrast to the AutoDocs1.3, but confirms with AmigaDOS1.3
 *                   Programmers Handbook (German version). Corrected other dos
 *                   functions to return a BCPL Pointer.
 *
 * 24-02-91 TetiSoft Added #include <libraries/dos.h> for BPTR.
 */

#ifndef FUNCTIONS_H
#define FUNCTIONS_H 1

#ifndef PROTO_ALL_H
#define PROTO_ALL_H 1

#ifndef  EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef  LIBRARIES_DOS_H
#include <libraries/dos.h>
#endif


/* CIA RESOURCE */

/* These calls require ciabase as first arg, the stubs for C programmers are
 * located in amiga.lib
 */

UBYTE			 AbleICR();
struct Interrupt	*AddICRVector();
void			 RemICRVector();
UBYTE			 SetICR();


/* CONSOLE DEVICE */

struct InputEvent	*CDInputHandler();
long			 RawKeyConvert();


/* DISKFONT LIBRARY */

long			 AvailFonts();
struct FontContentsHeader *DisposeFontContents();
struct FontContentsHeader *NewFontContents();
struct TextFont		*OpenDiskFont();


/* DOS LIBRARY */

/* private
 *
 *			 GetPacket();
 *			 QueuePacket();
 */

void			 Close();
BPTR			 CreateDir();		/* struct FileLock * */
struct MsgPort		*CreateProc();
BPTR			 CurrentDir();		/* struct FileLock * */
long			*DateStamp();
void			 Delay();
long			 DeleteFile();
struct MsgPort		*DeviceProc();
BPTR			 DupLock();		/* struct FileLock * */
long			 Examine();
long			 Execute();
void			 Exit();
long			 ExNext();
long			 Info();
BPTR			 Input();		/* struct FileHandle * */
long			 IoErr();
long			 IsInteractive();
BPTR			 LoadSeg();
BPTR			 Lock();		/* struct FileLock * */
BPTR			 Open();		/* struct FileHandle * */
BPTR			 Output();		/* struct FileHandle * */
BPTR			 ParentDir();		/* struct FileLock * */
LONG			 Read();
long			 Rename();
LONG			 Seek();
long			 SetComment();
long			 SetProtection();
void			 UnLoadSeg();
void			 Unlock();
long			 WaitForChar();
LONG			 Write();


/* EXEC LIBRARY */

/*
 * Private
 *
 *			 Dispatch();
 *			 Exception();
 *			 ExitIntr();
 *			 Reschedule();
 *			 Schedule();
 *			 Supervisor();
 *			 Switch();
 *			 RawIOInit();
 *			 RawMayGetChar();
 *			 RawPutChar();
 */

BYTE			 AbortIO();
void			 AddDevice();
void			 AddHead();
void			 AddIntServer();
void			 AddLibrary();
void			 AddMemList();
void			 AddPort();
void			 AddResource();
void			 AddSemaphore();
void			 AddTail();
void			 AddTask();
void			 Alert();
void			*AllocAbs();
void			*Allocate();
struct MemList		*AllocEntry();
void			*AllocMem();
BYTE			 AllocSignal();
LONG			 AllocTrap();
LONG			 AttemptSemaphore();
ULONG			 AvailMem();
void			 Cause();
struct IORequest	*CheckIO();
void			 CloseDevice();
void			 CloseLibrary();
void			 CopyMem();
void			 CopyMemQuick();
void			 Deallocate();
void			 Debug();
void			 Disable();
BYTE			 DoIO();
void			 Enable();
void			 Enqueue();
struct Node		*FindName();
struct MsgPort		*FindPort();
struct Resident		*FindResident();
struct SignalSemaphore	*FindSemaphore();
struct Task		*FindTask();
void			 Forbid();
void			 FreeEntry();
void			 FreeMem();
void			 FreeSignal();
void			 FreeTrap();
UWORD			 GetCC();
struct Message		*GetMsg();
void			 InitCode();
void			 InitResident();
void			 InitSemaphore();
void			 InitStruct();
void			 Insert();
ULONG			 MakeFunctions();
struct Library		*MakeLibrary();
void			 ObtainSemaphore();
void			 ObtainSemaphoreList();
struct Library		*OldOpenLibrary();
BYTE			 OpenDevice();
struct Library		*OpenLibrary();
APTR			 OpenResource();
void			 Permit();
BYTE			 Procure();
void			 PutMsg();
void			 RawDoFmt();
void			 ReleaseSemaphore();
void			 ReleaseSemaphoreList();
void			 RemDevice();
struct Node		*RemHead();
void			 RemIntServer();
void			 RemLibrary();
void			 Remove();
void			 RemPort();
void			 RemResource();
void			 RemSemaphore();
struct Node		*RemTail();
void			 RemTask();
void			 ReplyMsg();
void			 SendIO();
ULONG			 SetExcept();
APTR			 SetFunction();
struct Interrupt	*SetIntVector();
ULONG			 SetSignal();
ULONG			 SetSR();
BYTE			 SetTaskPri();
void			 Signal();
void			 SumKickData();
void			 SumLibrary();
APTR			 SuperState();
ULONG			 TypeOfMem();
void			 UserState();
void			 Vacate();
ULONG			 Wait();
BYTE			 WaitIO();
struct Message		*WaitPort();


/* EXPANSION LIBRARY */

/*
 * private
 *
 *			 expansionUnused();
 */

long			 AddDosNode();
struct DeviceNode	*MakeDosNode();
void			 AddConfigDev();
long			 AllocBoardMem();
struct ConfigDev	*AllocConfigDev();
long			 AllocExpansionMem();
long			 ConfigBoard();
long			 ConfigChain();
struct ConfigDev	*FindConfigDev();
void			 FreeBoardMem();
void			 FreeConfigDev();
void			 FreeExpansionMem();
LONG			 GetCurrentBinding();
void			 ObtainConfigBinding();
long			 ReadExpansionByte();
long			 ReadExpansionRom();
void			 ReleaseConfigBinding();
void			 RemConfigDev();
void			 SetCurrentBinding();
long			 WriteExpansionByte();


/* GRAPHICS LIBRARY */		/* BOOLEAN replaced by BOOL */

#ifndef  GRAPHICS_GFX_H
#include <graphics/gfx.h>	/* for PLANEPTR */
#endif

/*
 * Macros
 *
 * void			 SetOPen();
 * struct UCopList	*CINIT();
 * void			 CMOVE();
 * void			 CWAIT();
 * void			 CEND();
 */

/*
 * private
 *
 *			 GraphicsReserved1();
 *			 GraphicsReserved2();
 */

/*
 * No Autodocs
 *
 */
void			 CMove();
void			 CWait();
void			 UCopperListInit();

/*
 * public
 */
void			 AddAnimOb();
void			 AddBob();
void			 AddFont();
void			 AddVSprite();
PLANEPTR		 AllocRaster();
void			 AndRectRegion();
BOOL			 AndRegionRegion();
void			 Animate();
LONG			 AreaCircle();
LONG			 AreaDraw();
LONG			 AreaEllipse();
LONG			 AreaEnd();
LONG			 AreaMove();
void			 AskFont();
ULONG			 AskSoftStyle();
BOOL			 AttemptLockLayerRom();
ULONG			 BltBitMap();
BOOL			 BltBitMapRastPort();
void			 BltClear();
void			 BltMaskBitMapRastPort();
void			 BltPattern();
void			 BltTemplate();
void			 CBump();
void			 ChangeSprite();
void			 ClearEOL();
BOOL			 ClearRectRegion();
void			 ClearRegion();
void			 ClearScreen();
void			 ClipBlit();
void			 CloseFont();
void			 CopySBitMap();
void			 DisownBlitter();
void			 DisposeRegion();
void			 DoCollision();
void			 Draw();
void			 DrawEllipse();
void			 DrawGList();
BOOL			 Flood();
void			 FreeColorMap();
void			 FreeCopList();
void			 FreeCprList();
void			 FreeGBuffers();
void			 FreeRaster();
void			 FreeSprite();
void			 FreeVPortCopLists();
struct ColorMap		*GetColorMap();
BOOL			 GetGBuffers();
ULONG			 GetRGB4();
SHORT			 GetSprite();
void			 InitArea();
void			 InitBitMap();
void			 InitGels();
void			 InitGMasks();
void			 InitMasks();
void			 InitRastPort();
void			 InitTmpRas();
void			 InitView();
void			 InitVPort();
void			 LoadRGB4();
void			 LoadView();
void			 LockLayerRom();
void			 MakeVPort();
void			 Move();
void			 MoveSprite();
void			 MrgCop();
struct Region		*NewRegion();
struct TextFont		*OpenFont();
BOOL			 OrRectRegion();
BOOL			 OrRegionRegion();
void			 OwnBlitter();
void			 PolyDraw();
void			 QBlit();
void			 QBSBlit();
LONG			 ReadPixel();
void			 RectFill();
void			 RemBob();
void			 RemFont();
void			 RemIBob();
void			 RemVSprite();
void			 ScrollRaster();
void			 ScrollVPort();
void			 SetAPen();
void			 SetBPen();
void			 SetCollision();
void			 SetDrMd();
void			 SetFont();
void			 SetRast();
void			 SetRGB4();
void			 SetRGB4CM();
ULONG			 SetSoftStyle();
void			 SortGList();
void			 SyncSBitMap();
void			 Text();
SHORT			 TextLength();
void			 UnlockLayerRom();
LONG			 VBeamPos();
void			 WaitBlit();
void			 WaitBOVP();
void			 WaitTOF();
LONG			 WritePixel();
BOOL			 XorRectRegion();
BOOL			 XorRegionRegion();


/* ICON LIBRARY */

struct WBObject		*AllocWBObject();
VOID			 AddFreeList();
char			*BumpRevision();
char			*FindToolType();
void			 FreeDiskObject();
VOID			 FreeFreeList();
VOID			 FreeWBObject();
struct DiskObject	*GetDiskObject();
LONG			 GetIcon();
struct WBObject		*GetWBObject();
LONG			 MatchToolValue();
LONG			 PutDiskObject();
LONG			 PutIcon();
LONG			 PutWBObject();


/* INTUITION LIBRARY */

BOOL			 ActivateGadget();
void			 ActivateWindow();
USHORT			 AddGadget();
USHORT			 AddGList();
void			*AllocRemember();
void			 AlohaWorkbench();
BOOL			 AutoRequest();
void			 BeginRefresh();
struct Window		*BuildSysRequest();
BOOL			 ClearDMRequest();
void			 ClearMenuStrip();
void			 ClearPointer();
void			 CloseScreen();
void			 CloseWindow();
BOOL			 CloseWorkBench();
void			 CurrentTime();
BOOL			 DisplayAlert();
void			 DisplayBeep();
BOOL			 DoubleClick();
void			 DrawBorder();
void			 DrawImage();
void			 EndRefresh();
void			 EndRequest();
void			 FreeRemember();
void			 FreeSysRequest();
struct Preferences	*GetDefPrefs();
struct Preferences	*GetPrefs();
BOOL			 GetScreenData();
void			 InitRequester();
long			 IntuiTextLength();
struct InputEvent	*Intuition();
struct MenuItem		*ItemAddress();
ULONG			 LockIBase();
void			 MakeScreen();
void			 ModifyIDCMP();
void			 ModifyProp();
void			 MoveScreen();
void			 MoveWindow();
void			 NewModifyProp();
void			 OffGadget();
void			 OffMenu();
void			 OnGadget();
void			 OnMenu();
void			 OpenIntuition();
struct Screen		*OpenScreen();
struct Window		*OpenWindow();
long			 OpenWorkBench();	/* See Autodocs */
void			 PrintIText();
void			 RefreshGadgets();
void			 RefreshGList();
void			 RefreshWindowFrame();
void			 RemakeDisplay();
USHORT			 RemoveGadget();
USHORT			 RemoveGList();
void			 ReportMouse();
BOOL			 Request();
void			 RethinkDisplay();
void			 ScreenToBack();
void			 ScreenToFront();
BOOL			 SetDMRequest();
BOOL			 SetMenuStrip();
void			 SetPointer();
struct Preferences	*SetPrefs();
void			 SetWindowTitles();
void			 ShowTitle();
void			 SizeWindow();
void			 UnlockIBase();
struct View		*ViewAddress();
struct ViewPort		*ViewPortAddress();
BOOL			 WBenchToBack();
BOOL			 WBenchToFront();
BOOL			 WindowLimits();
void			 WindowToBack();
void			 WindowToFront();


/* LAYERS LIBRARY */

BOOL			 BeginUpdate();
BOOL			 BehindLayer();
struct Layer		*CreateBehindLayer();
struct Layer		*CreateUpfrontLayer();
BOOL			 DeleteLayer();
void			 DisposeLayerInfo();
void			 EndUpdate();
void			 FattenLayerInfo();
void			 InitLayers();
struct Region		*InstallClipRegion();
void			 LockLayer();
void			 LockLayerInfo();
void			 LockLayers();
BOOL			 MoveLayer();
BOOL			 MoveLayerInFrontOf();
struct Layer_Info	*NewLayerInfo();
void			 ScrollLayer();
BOOL			 SizeLayer();
void			 SwapBitsRastPortClipRect();
void			 ThinLayerInfo();
void			 UnlockLayer();
void			 UnlockLayerInfo();
void			 UnlockLayers();
BOOL			 UpfrontLayer();
struct Layer		*WhichLayer();


/* MATHFFP LIBRARY */

float			 SPAbs();
float			 SPAdd();
float			 SPCeil();
int			 SPCmp();
float			 SPDiv();
int			 SPFix();
float			 SPFloor();
float			 SPFlt();
float			 SPMul();
float			 SPNeg();
float			 SPSub();
int			 SPTst();

/* MATHIEEEDOUBBAS LIBRARY */

/* TETISOFT I commented it out since HCC
 * handles double equal to float (32 bit Motorola FFP)
 *
 * double		 IEEEDPAbs();
 * double		 IEEEDPAdd();
 * double		 IEEEDPCeil();
 * LONG			 IEEEDPCmp();
 * double		 IEEEDPDiv();
 * LONG			 IEEEDPFix();
 * double		 IEEEDPFloor();
 * double		 IEEEDPFlt();
 * double		 IEEEDPMul();
 * double		 IEEEDPNeg();
 * double		 IEEEDPSub();
 * LONG			 IEEEDPTst();
 */


/* MATHIEEEDOUBTRANS LIBRARY */

/* TETISOFT I commented it out since HCC
 * handles double equal to float (32 bit Motorola FFP)
 *
 * double		 IEEEDPAcos();
 * double		 IEEEDPAsin();
 * double		 IEEEDPAtan();
 * double		 IEEEDPCos();
 * double		 IEEEDPCosh();
 * double		 IEEEDPExp();
 * double		 IEEEDPFieee();
 * double		 IEEEDPLog();
 * double		 IEEEDPLog10();
 * double		 IEEEDPPow();
 * double		 IEEEDPSin();
 * double		 IEEEDPSincos();
 * double		 IEEEDPSinh();
 * double		 IEEEDPSqrt();
 * double		 IEEEDPTan();
 * double		 IEEEDPTanh();
 * float		 IEEEDPTieee();
 */ /* float means ieee single precision */


/* MATHTRANS LIBRARY */

float			 SPAcos();
float			 SPAsin();
float			 SPAtan();
float			 SPCos();
float			 SPCosh();
float			 SPExp();
float			 SPFieee();
float			 SPLog();
float			 SPLog10();
float			 SPPow();
float			 SPSin();
float			 SPSincos();
float			 SPSinh();
float			 SPSqrt();
float			 SPTan();
float			 SPTanh();
/* Caution! this 'float' means ieee single precision! */
float			 SPTieee();


/* POTGO RESOURCE */

UWORD			 AllocPotBits();
void			 FreePotBits();
void			 WritePotgo();


/* TIMER DEVICE */

void			 AddTime();
void			 SubTime();
BYTE			 CmpTime();


/* TRANSLATOR LIBRARY */

LONG			 Translate();


/************************
 *			*
 *	AMIGALIB	*
 *			*
 ************************/

/*
 *
 * MISC
 *
 */

void			 AddTOF();
void			 RemTOF();

ULONG			 RangeRand();
ULONG			 FastRand();

/*
 *
 * EXECSUPPORT
 *
 */

struct IORequest	*CreateExtIO();
void			 DeleteExtIO();

/* The 'Std' versions are undocumented by Commodore in AutoDocs 1.3
 * Maybe you shouldn't use them ?
 */
struct IOStdReq		*CreateStdIO();
void			 DeleteStdIO();

void			 BeginIO();
struct MsgPort		*CreatePort();
void			 DeletePort();
struct Task		*CreateTask();
void			 DeleteTask();
void			 NewList();

/*
 *
 * STDIO
 *
 *
 * This is commented out to avoid confusion with HCC.lib
 * The routines only work with filehandles and stdin/out,
 * open files have to be closed manually,
 * no floating point, etc.
 */
/*
			 printf();
			 sprintf();
			 fclose();
			 fgetc();
			 fprintf();
			 fputc();
			 fputs();
			 getchar();
			 printf();
			 putchar();
			 puts();
			 sprintf();
*/

/*
 *
 * MATH
 *
 */

float			 afp();
void			 arnd();
float			 dbf();
long			 fpa();
/*
 * This is commented out since all versions before and including Release 1.3
 * of amiga.lib have several bugs in this function (see Addison Wesley
 * Amiga ROM Kernel Reference Manual Libraries & Devices)
 */
/* void			 fpbcd(); */

/*
 * The following is a list of the 1.3 amigalib math routines.
 * The routines used by HCC are in lmath.asm (HCC.lib).
 */
/*
			 IMulU();
			 umuls();
			 IMulS();
			 smuls();
			 IDivS();
			 sdiv();
			 IDivU();
			 abs();
*/

/*
 * The following routines were without leading underscore (only for assembler
 * programmers or library routines)
 */
/*
			 ulmult
			 lmult
			 ulmodt
			 uldivt
			 lmodt
			 ldivt

			 fmuli
			 faddi
			 fsubi
			 fdivi
			 fcmpi
			 fsmuli
			 fsaddi
			 fsdivi
			 fsfixi
			 ffixi
			 ffltis
			 fflti
			 fststi
			 fabsi
			 fnegi
*/

#endif /* PROTO_ALL_H */

#endif /* FUNCTIONS_H */
