#ifndef  CLIB_GAMES_PROTOS_H
#define  CLIB_GAMES_PROTOS_H

/*
**   $VER: games_protos.h V0.7B
**
**   C prototypes.
**
**   (C) Copyright 1996-1997 DreamWorld Productions.
**       All Rights Reserved.
*/

#ifndef  GAMES_GMS_H
#include <games/games.h>
#endif

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

#ifndef  EXEC_TASKS_H
#include <exec/tasks.h>
#endif

/************************************************************************************
** Kernal Functions
*/

LONG  OpenGPI(WORD ID);
LONG  CloseGPI(WORD ID);
LONG  SetUserPrefs(char *PrefsName);
void  CloseGMS(void);
void  AddInputHandler(void);
void  RemInputHandler(void);
void  AddInterrupt(APTR Interrupt, WORD IntNum, WORD IntPri);
void  RemInterrupt(APTR IntBase);
APTR  AllocMemBlock(LONG Size, LONG MemType);
void  FreeMemBlock(APTR MemBlock);
LONG  AddTrack(LONG Resource, LONG Data, void *Routine);
void  DeleteTrack(LONG Key);
struct GMSTask * FindGMSTask();
void  GMSForbid(void);
void  GMSPermit(void);
LONG  GetMemSize(APTR MemBlock);
LONG  GetMemType(APTR MemBlock);

LONG RemapGPI(LONG GPI, APTR Functions);

/************************************************************************************
** Standard functions
*/

LONG InitTags(APTR Structure, APTR TagList);
LONG FastRandom(LONG Range);
LONG SlowRandom(LONG Range);
APTR WriteDec(LONG Number, LONG AmtDigits, char *Destination);
APTR WriteHex(LONG Number, LONG AmtDigits, char *Destination);
LONG ReadKey(struct Keys *);
void WaitLMB(void);
void WaitTime(WORD MicroSeconds);

/* JoyPorts */

void  InitJoyPorts(void);
LONG ReadJoyPort(WORD PortName, WORD ReturnType);

/* Files */

struct File * OpenFile(char *Filename, LONG Flags);
LONG ReadFile(struct File *, APTR Buffer, LONG Length);
LONG WriteFile(struct File *, APTR Buffer, LONG Length);
void CloseFile(struct File *);
APTR SmartLoad(char *FileName, APTR Destination, LONG MemType);
APTR QuickLoad(char *FileName, APTR Destination, LONG MemType);
LONG SmartSave(char *FileName, APTR Source, APTR SrcLength);

APTR SmartUnpack(APTR Source, APTR Destination, LONG Password, LONG MemType);

/* Pictures */

APTR  GetPicInfo(APTR PicHeader, struct Picture *);
LONG  UnpackPic(APTR Source, struct Picture *);
struct Picture * LoadPic(struct Picture *);
struct Picture * LoadPicTags(ULONG tag1Type, ...);
struct Picture * LoadPicTagList(struct TagItem *);
struct Picture * LoadPicFile(char *Filename, LONG Options);
void  FreePic(struct Picture *);
APTR  GetPicture(void);

void InitDestruct(void *DestructCode, APTR DestructStack);
void SelfDestruct(void);
void Armageddon(LONG Key);
LONG FingerOfDeath(struct GMSTask *);

APTR  GetStructure(LONG ID);
APTR  FreeStructure(APTR Structure);

/* Objects */

APTR  LoadObjectFile(char *Filename);
APTR  GetObject(APTR ObjectBase, char *Name);
APTR  GetObjectList(APTR ObjectBase, APTR);
void  FreeObjectFile(APTR ObjectBase);
APTR  GrabObjectList(APTR ObjectBase);
APTR  CopyOjbect(APTR ObjectBase, char *Name);

void DebugMessage(LONG Type, char *Text);
void ErrorMessage(LONG ErrorCode);
void StepBack(void);
LONG DebugActive(void);
void DebugInactive(void);
LONG Awaken(struct GMSTask *);
void CopyStructure(APTR Source, APTR Destination);

/************************************************************************************
** Screens.GPI functions
*/

APTR  AllocVideoMem(LONG Size);
APTR  GetScreen(void);
struct GameScreen * AddScreen(APTR GameScreen);
struct GameScreen * AddScreenTags(ULONG tag1Type, ...);
struct GameScreen * AddScreenTagList(struct TagItem *);
void  DeleteScreen(struct GameScreen *);
void  ShowScreen(struct GameScreen *);
APTR  HideScreen(struct GameScreen *);
void  Switch(void);
void  AutoSwitch(void);
void  SwapBuffers(struct GameScreen *);
void  WaitVBL(void);
void  WaitRastLine(WORD LinePosition);
void  RefreshScreen(struct GameScreen *);
void  RemakeScreen(struct GameScreen *);
void  MovePicture(struct GameScreen *);
void  ResetPicture(struct GameScreen *);

/* Palette alteration functions */

void  UpdatePalette(struct GameScreen *);
WORD PaletteMorph(struct GameScreen *, WORD FadeState, WORD Speed,
 LONG StartColour, LONG AmtColours, APTR SrcPalette, APTR DestPalette);
WORD PaletteToColour(struct GameScreen *, WORD FadeState, WORD Speed,
 LONG StartColour, LONG AmtColours, APTR Palette, LONG RRGGBB);
WORD ColourMorph(struct GameScreen *, WORD FadeState, WORD Speed,
 LONG StartColour, LONG AmtColours, LONG SrcColour, LONG DestColour);
WORD ColourToPalette(struct GameScreen *, WORD FadeState, WORD Speed,
  LONG StartColour, LONG AmtColours, APTR Palette, LONG RRGGBB);
void  ChangeColours(struct GameScreen *, WORD FadeState, APTR Colours,
  WORD StartColour, WORD AmtColours);
void  BlankColours(struct GameScreen *);

/* Rasterlist functions */

LONG InitRasterlist(struct GameScreen *);
void  UpdateRasterlist(struct GameScreen *);
void  UpdateRasterCommand(struct GameScreen *, APTR Command);
void  UpdateRasterCommands(struct GameScreen *, APTR Command, WORD Amount);
void  UpdateRasterLines(struct GameScreen *);
void  RemoveRasterlist(struct GameScreen *);
void  HideRasterlist(struct GameScreen *);
void  ShowRasterlist(struct GameScreen *);

/* Sprite functions */

struct Sprite * InitSprite(struct GameScreen *, struct Sprite *);
struct Sprite * InitSpriteTags(struct GameScreen *, ULONG tag1Type, ...);
struct Sprite * InitSpriteTagList(struct GameScreen *, struct TagItem *);

void UpdateSprite(struct GameScreen *, struct Sprite *);
void MoveSprite(struct GameScreen *, struct Sprite *);
void HideSprite(struct GameScreen *, WORD SpriteNum);
void UpdateSpriteList(APTR SpriteList);
void HideSpriteList(APTR SpriteList);
void RemoveAllSprites(void);
void ReturnAllSprites(void);
void FreeSprite(struct Sprite *);

void UpdateColour(struct GameScreen *, LONG Colour, LONG Value);
void BlankOn(void);
void BlankOff(void);
LONG MoveToFront(struct GameScreen *);
LONG MoveToBack(struct GameScreen *);
LONG TakeDisplay(struct GameScreen *);
struct GameScreen * ReturnDisplay(void);

void FreeVideoMem(APTR MemBlock);
APTR GetSprite(void);

/************************************************************************************
** Blitter.GPI functions.
*/

APTR AllocBlitMem(LONG Size);
APTR GetBob(void);
APTR GetMBob(void);
LONG AllocBlitter(void);
void FreeBlitter(void);
APTR InitBob(APTR Bitmap, APTR Bob);
APTR InitBobTags(APTR Bitmap, ULONG tag1Type, ...);
APTR InitBobTagList(APTR Bitmap, struct TagItem *);
void FreeBob(APTR Bob);
void DrawBob(APTR Bob);
void DrawBobList(LONG *BobList[]);
void ClearBob(APTR Bob);
void DrawLine(struct Bitmap *, WORD StartX, WORD StartY, WORD EndX, WORD EndY,
       LONG Colour);
void DrawUCLine(struct Bitmap *, WORD StartX, WORD StartY, WORD EndX, WORD EndY,
       LONG Colour);

void  CopyBuffer(struct GameScreen *, WORD SrcBuffer, WORD DestBuffer);
void  ClearBitmap(struct Bitmap *);
void  ClearArea(struct GameScreen *, WORD StartX, WORD StartY, WORD EndX, WORD EndY);

struct Restorelist * InitRestore(APTR Bitmap, LONG AmtBuffers, LONG Entries);
void  FreeRestore(APTR Bitmap);
void  ResetRestore(struct Bitmap *);
void  Restore(struct Bitmap *);
void  CleanUpRestore(struct Bitmap *);

LONG InitMap(struct GameScreen *, struct Map *);
void  DrawMap(struct GameScreen *, struct Map *);
void  DrawMapRow(struct GameScreen *, struct Map *);
void  FreeMap(struct Map *);
void  DrawMapTile(struct GameScreen *, struct Map *, WORD XCoord, WORD YCoord);

void  DrawPixel(struct Bitmap *, WORD XCoord, WORD YCoord, LONG Colour);
void  DrawUCPixel(struct Bitmap *, WORD XCoord, WORD YCoord, LONG Colour);
void  DrawPixelList(struct Bitmap *, struct PixelList *);
void  DrawUCPixelList(struct Bitmap *, struct PixelList *);
LONG ReadPixel(struct Bitmap *, WORD XCoord, WORD YCoord);
void  ReadPixelList(struct Bitmap *, struct PixelLIst *);

void  FreeBlitMem(APTR MemBlock);
void  SetBobDimensions(APTR Bob);
LONG SetBobDrawMode(APTR Bob, LONG Attrib);

struct Bitmap * GetBitmap(void);
LONG InitBitmap(struct Bitmap *);
void  FreeBitmap(struct Bitmap *);

/************************************************************************************
** Sound.GPI functions
*/

LONG AllocAudio(void);
void  FreeAudio(void);
struct Sound * InitSound(APTR Sound);
struct Sound * InitSoundTags(ULONG tag1Type, ...);
struct Sound * InitSoundTagList(struct TagItem *);
void  FreeSound(APTR Sound);
WORD CheckChannel(WORD ChannelName);

void  PlaySound(APTR Sound);
void  PlaySoundDAC1(APTR Sound);
void  PlaySoundDAC2(APTR Sound);
void  PlaySoundDAC3(APTR Sound);
void  PlaySoundDAC4(APTR Sound);
void  PlaySoundPri(APTR Sound);
void  PlaySoundPriDAC1(APTR Sound);
void  PlaySoundPriDAC2(APTR Sound);
void  PlaySoundPriDAC3(APTR Sound);
void  PlaySoundPriDAC4(APTR Sound);

void  SetVolume(WORD Channel, WORD Volume);
void  FadeVolume(WORD Channel);
void  StopSound(struct Sound *);
void  StopChannel(WORD Channel);

APTR  AllocSoundMem(LONG Size);
APTR  GetSound(void);
void  FreeSoundMem(APTR Memblock);

#endif /* CLIB_GAMES_PROTOS_H */
