@DATABASE "Screens"
@AUTHOR "Paul Manias"
@NODE "Main" "Screens.GPI"

Name:         @{"SCREENS.GPI" LINK "GPIFunctions"} AUTODOC
Version:      0.6 Beta.
Date:         11 May 1997
Author:       Paul Manias
Copyright:    DreamWorld Productions, 1996-1997.  All rights reserved.
Notes:        This  document is still being written and will contain errors
              in  a  number  of  places.   The information within cannot be
	      treated as official until this autodoc reaches version 1.0.

@EndNode
@NODE "GPIFunctions" "Screens.GPI Functions"

 @{b}SCREENS.GPI@{ub}
 @{"AddScreen()"     LINK "AddScreen()"}
 @{"AllocVideoMem()" LINK "AllocVideoMem()"}
 @{"AutoSwitch()"    LINK "AutoSwitch()"}
 @{"BlankOn()"       LINK "BlankOn()"}
 @{"BlankOff()"      LINK "BlankOff()"}
 @{"DeleteScreen()"  LINK "DeleteScreen()"}
 @{"FreeVideoMem()"  LINK "FreeVideoMem()"}
 @{"GetScreen()"     LINK "GetScreen()"}
 @{"GetScrType()"    LINK "GetScrType()"}
 @{"HideDisplay()"   LINK "HideDisplay()"}
 @{"MovePicture()"   LINK "MovePicture()"}
 @{"RefreshScreen()" LINK "RefreshScreen()"}
 @{"RemakeScreen()"  LINK "RemakeScreen()"}
 @{"ResetPicture()"  LINK "ResetPicture()"}
 @{"ReturnDisplay()" LINK "ReturnDisplay()"}
 @{"Switch()"        LINK "Switch()"}
 @{"ShowScreen()"    LINK "ShowScreen()"}
 @{"SwapBuffers()"   LINK "SwapBuffers()"}
 @{"TakeDisplay()"   LINK "TakeDisplay()"}
 @{"WaitVBL()"       LINK "WaitVBL()"}
 @{"WaitRastLine()"  LINK "WaitRastLine()"}

 @{b}Colour Functions@{ub}
 @{"BlankColours()"    LINK "BlankColours()"}
 @{"ChangeColours()"   LINK "ChangeColours()"}
 @{"ColourMorph()"     LINK "ColourMorph()"}
 @{"ColourToPalette()" LINK "ColourToPalette()"}
 @{"PaletteToColour()" LINK "PaletteToColour()"}
 @{"PaletteMorph()"    LINK "PaletteMorph()"}
 @{"UpdatePalette()"   LINK "UpdatePalette()"}
 @{"UpdateColour()"    LINK "UpdateColour()"}

 @{b}Rasterlist Functions@{ub}
 @{"InitRasterlist()"       LINK "InitRasterlist()"}
 @{"HideRasterlist()"       LINK "HideRasterlist()"}
 @{"RemoveRasterlist()"     LINK "RemoveRasterlist()"}
 @{"ShowRasterlist()"       LINK "ShowRasterlist()"}
 @{"UpdateRasterlist()"     LINK "UpdateRasterlist()"}
 @{"UpdateRasterLines()"    LINK "UpdateRasterLines()"}
 @{"UpdateRasterCommand()"  LINK "UpdateRasterCommand()"}
 @{"UpdateRasterCommands()" LINK "UpdateRasterCommands()"}

 @{b}Sprite Functions@{ub}
 @{"InitSprite()"       LINK "InitSprite()"}
 @{"FreeSprite()"       LINK "FreeSprite()"}
 @{"HideSprite()"       LINK "HideSprite()"}
 @{"HideSpriteList()"   LINK "HideSpriteList()"}
 @{"MoveSprite()"       LINK "MoveSprite()"}
 @{"RemoveAllSprites()" LINK "RemoveAllSprites()"}
 @{"ReturnAllSprites()" LINK "ReturnAllSprites()"}
 @{"UpdateSprite()"     LINK "UpdateSprite()"}
 @{"UpdateSpriteList()" LINK "UpdateSpriteList()"}

@EndNode
---------------------------------------------------------------------------
@NODE "AddScreen()" "Screens.GPI/AddScreen"

@{b}NAME@{ub}	AddScreen -- Sets up a screen from given parameters.

@{b}SYNOPSIS@{ub}
	GameScreen = AddScreen(GameScreen)
	   d0                     a0

	struct GameScreen * AddScreen(APTR GameScreen);

	struct GameScreen * AddScreenTags(ULONG tag, ...);

@{b}FUNCTION@{ub}
	Initialises  a GameScreen structure by allocating the screen memory
	and making the rasterlist.  A little more complex than it sounds...

	All GameScreens must be initialised from tag lists, or if necessary
	a screen structure obtained from GetScreen().

	After  calling  this  function you need to call ShowScreen() to get
	the screen on the display.

@{b}INPUTS@{ub}	GameScreen - Pointer  to  a  valid  GameScreen,  Taglist,  List, or
		     ObjectList.

	Here follows a description of each GameScreen field:

	@{b}GS_MemPtr1, GS_MemPtr2, GS_MemPtr3@{ub}
	These fields point to the screen display data.  They should be NULL
	if  you  want  this function to allocate the memory for you (highly
	recommended).   Otherwise  AddScreen()  will assume that the values
	are valid pointers to video memory and will use them as such.

	@{b}GS_ScreenLink@{ub}
	If  you  want  to set up a second screen at a different position in
	the  viewport,  or create an extra (double) playfield, point to the
	next GameScreen structure here.

	@{b}GS_Palette@{ub}
	Points  to  the  palette  for  this  screen, or NULL if you want to
	install   a  clear  palette  (all  colours  black).   Your  palette
	array must be represented in 24 bit colours (0x00RRGGBB).

	@{b}GS_Rasterlist@{ub}
	Points  to  a valid rasterlist structure, or NULL.  Rasterlists are
	made  up  of  instructions  that  are  executed as the monitor beam
	travels   down   the   screen.    See  InitRasterlist()  for  more
	information on rasterlists.

	@{b}GS_AmtColours@{ub}
	The  amount  of  colours  in  the  screen palette, as pointed to by
	GS_Palette.   If  you  set this value to NULL then AddScreen() will
	fill  it  in  for  you,  via  a check to GS_Planes.  This parameter
	exists  so  that  you can set colours that can't be accessed by the
	screen's bitmap.  For example, if your screen is 16 colours but you
	want  to  set  the  colours  for the sprites, then you can use a 32
	colour palette.

	@{b}GS_ScrWidth, GS_ScrHeight@{ub}
	Defines the screen height and width.  This is the "window" that the
	picture data is displayed through.  The width of the screen must be
	divisible  by  16.

	These  fields will inherit the values specified by the user if they
	are set at zero.

	@{b}GS_PicWidth, GS_PicByteWidth, GS_PicHeight@{ub}
	Defines  the  picture height and width.  The picture is the display
	data  that  shows  through  onto screen.  It can be larger than the
	screen  area,  but must never be smaller than the screen area.  The
	pixel  width  must  be divisible by 16.  If you omit the GS_ScrType
	field  (further  down)  then  you  are  not  expected  to  set  the
	PicByteWidth  value.  In most circumstances setting PicByteWidth is
	unnecessary as it will be initialised from the PicWidth value.

	These   fields   will  inherit  the  values  from  GS_ScrWidth  and
	GS_ScrHeight if they are set at zero.

	@{b}GS_Planes@{ub}
	Specifies the amount of bitplanes that will be used by this screen.
	The  amount  of colours you can use is completely dependent on this
	value.   For  interleaved  or  planar screens you can calculate the
	amount  of  colours  you  get  with the formula 2^n, where n is the
	amount  of  planes.  If you are going to set up a 256 colour chunky
	screen, you must specify only 1 plane here.

	@{b}GS_ScrXOffset, GS_SrcYOffset@{ub}
	Specifies the hardware offset for the screen.  These two values are
	added  to  the  user's screen offset in GMSPrefs.  A setting of 0,0
	should be sufficient, unless you are going to create an extra large
	screen (eg overscan).  Negative values are allowed.

	@{b}GS_PicXOffset, GS_PicYOffset@{ub}
	These  two  fields  set  the  offsets  for the picture "behind" the
	screen.  If you want to do any sort of hardware scrolling, you will
	want to use these values in conjunction with MovePicture().  It is
	perfectly   legal   to   preset   these   values  before  you  call
	ShowScreen().

	@{b}GS_ScrAttrib@{ub}
	Defines  the  special attributes for the screen.  Current available
	are:

	 DBLBUFFER  - Allocates  an  extra screen buffer which is placed in
	              GS_MemPtr2.  See  the SwapBuffers() function for more
	              information on double buffering.

	 TPLBUFFER  - Allocates  two  extra  buffers  which  are  placed in
	              GS_MemPtr2 and GS_MemPtr3.  See the SwapBuffers() for
	              more information on triple buffering.

	              Note:  Never set  the  DBLBUFFER  flag in conjunction
	              with the TPLBUFFER flag.

	 PLAYFIELD  - Must be set if this screen forms part of a playfield.

	 HSCROLL    - Set if you want to use horizontal picture scrolling.

	 VSCROLL    - Set if you want to use vertical picture scrolling.

	 SBUFFER    - Allocates  extra  space  to allow you to horizontally
	              scroll up to 50 screens in both X directions.

	 SPRITES    - Set if you intend to use sprites with this screen.

	 BLKBDR     - Turns  all  colours  outside of the display window to
	              black.  Works on AGA only.

	 NOSCRBDR   - Allows  sprites  and  other  displayable  objects  to
		      appear outside of the viewport.  Works on AGA only.

	 CENTRE     - Centres the screen by calculating the correct offsets
		      for  GS_ScrXOffset  and  GS_ScrYOffset for any screen
		      mode.   The new settings will over-write any previous
		      values in these fields.

	 GETSCRMODE - Obtains  the preferred user screen mode and writes it
		      to GS_ScrMode.

	@{b}GS_ScrMode@{ub}
	Defines  the  display  mode  for the screen.  If you do not fill in
	this  field,  you  will get the default of low resolution.  NB:  If
	you  require  compatibility  for  NTSC,  ScrMode will not help you.
	Instead you must set ScrHeight to 200.

	  LORES    - Specifies  a  low  resolution  screen.   This  is  the
		     default, so you do not have to specify it if you don't
		     want to.

	  HIRES    - Specifies a high resolution screen (1/2 lores).

	  SHIRES   - Specifies a super-high resolution screen (1/4 lores).

	  LACED    - Creates an interlaced display (1/2 pixel height).

	  HAM      - HAM  mode.  The amount of colours you get is dependant
		     on the amount of planes in the screen.

	If  the  user  has  selected  mode  promotion in GMSPrefs, then the
	display  frequencies will be altered accordingly.  You cannot force
	mode promotion from inside your program.

	@{b}GS_ScrType@{ub}
	The  display  data  type  -  either PLANAR, INTERLEAVED or CHUNKY8.
	Descriptions  of  these  display types are out of the scope of this
	autodoc,  so  if you require further information perhaps you should
	try  the  RKM's.   Note  that  for planar screens the bitplanes are
	stored  sequentially,  one after the other.  There is no scattering
	of planar bitplane memory.

	If  you  set this field to NULL then AddScreen() will initialise it
	to the preferred user screen type.  This is exceptionally useful as
	some  screen  types  are  faster  than  others for certain effects.
	ScreenType  independence  is  strongly  encouraged  because of this
	reason.

	@{b}GS_Task@{ub}
	Points  to  a  GMSTask structure that identifies the task that this
	screen  belongs  to.  This field is available for reading only.  If
	you  want  to initialise this screen on behalf of another task, you
	can set it before you call AddScreen().

@{b}RESULT@{ub}	ErrorCode - NULL if successful.

@{b}BUGS@{ub}	If  you  set  up  your  screen  structure  incorrectly or try to do
	something this routine doesn't, you will run into trouble.  Not all
	features  are  working  even  though  the flags are present, but it
	shouldn't be too long before this function is finished.

@{b}SEE ALSO@{ub}
	@{"DeleteScreen" LINK "DeleteScreen()"}, @{"ShowScreen" LINK "ShowScreen()}, @{"HideDisplay" LINK "HideDisplay()}, @{"games/games.i" LINK "INCLUDES:games/games.i/Main"}

@EndNode
---------------------------------------------------------------------------
@NODE "DeleteScreen()" "Screens.GPI/DeleteScreen"

@{b}NAME@{ub}	DeleteScreen -- Deactivates a screen, returns memory, etc.

@{b}SYNOPSIS@{ub}
	DeleteScreen(GameScreen)
	                a0

	void DeleteScreen(struct GameScreen *);

@{b}FUNCTION@{ub}
	This  function will deallocate everything that was initialised when
	you called AddScreen().

	If  the  screen  you  delete is currently active when you call this
	function,  intution will be given back the display.  If you want to
	get  around  this, initialise and display your next screen and then
	delete the old one.

	This  function  will  clear  MemPtr1,  MemPtr2  and  MemPtr3 in the
	GameScreen   structure,   if   those   fields   were  allocated  by
	AddScreen().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"AddScreen" LINK "AddScreen()"}, @{"HideDisplay" LINK "HideDisplay()"}, @{"ShowScreen" LINK "ShowScreen()"}

@EndNode
---------------------------------------------------------------------------
@NODE "ShowScreen()" "Screens.GPI/ShowScreen"

@{b}NAME@{ub}	ShowScreen -- Displays an initialised game screen.

@{b}SYNOPSIS@{ub}
	ShowScreen(GameScreen)
	              a0

	void ShowScreen(struct GameScreen *);

@{b}FUNCTION@{ub}
	Displays  an  initialised GameScreen.  A GameScreen is incompatible
	with  intuition  screens, so calling this function will result in a
	complete take-over of the viewport.

	This  function  makes a call to AddInputHandler() to prevent input
	falling through to intuition screens.

	It  is  perfectly  admissable  to  call  this function when another
	GameScreen is already being displayed.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"AddScreen" LINK "AddScreen()"}, @{"HideDisplay" LINK "HideDisplay()"}, @{"DeleteScreen" LINK "DeleteScreen()"}

@EndNode
---------------------------------------------------------------------------
@NODE "HideDisplay()" "Screens.GPI/HideDisplay"

@{b}NAME@{ub}	HideDisplay -- Hides the GMS display from view.

@{b}SYNOPSIS@{ub}
        GameScreen = HideDisplay()
	   d0

	struct GameScreen * HideDisplay(void);

@{b}FUNCTION@{ub}
	Hides  the  currently  displayed screen from view.  This will cause
	the OS viewport to be returned, but your task will still be running
	"in the background".

	If  no  GameScreen  is present then this function does nothing, and
	returns a NULL value.

	On  its  own  this is not good for screen-switching - use functions
	like AutoSwitch() for that.

@{b}RESULT@{ub}	GameScreen - Points  to  the  structure  of the GameScreen that has
		     been  hidden  by  this function.  Otherwise NULL if no
		     GameScreen was active.

@{b}SEE ALSO@{ub}
	@{"ShowScreen" LINK "ShowScreen()"}, @{"Switch" LINK "Switch()"}, {"AutoSwitch" LINK "AutoSwitch()"}

@EndNode
---------------------------------------------------------------------------
@NODE "Switch()" "Screens.GPI/Switch"

@{b}NAME@{ub}	Switch -- Stops your task and resumes execution of the next primary
		  task in the queue.

@{b}SYNOPSIS@{ub}
	Switch()

	void Switch(void);

@{b}FUNCTION@{ub}
	Switches  your  task  over  to  the  next  task in the queue.  This
	function  will  not return until the user reactivates your task, so
	your   tasks  execution  is  effectively  stopped.   Any  secondary
	processes  and  interrupts  that  you have spawned will continue to
	execute, so multi-tasking can still be effective.

	If  the next task is screen-based, then your screen display will be
	removed  and  the  new  screen  will be displayed.  If you have any
	secondary  tasks  running, then take note:  You must not allow them
	to use the drawing/blitter operations as your display memory may be
	temporarily  moved  to  free  up  video  memory.   Blitting  to  an
	invisible display is also considered to be bad practice as most GMS
	tasks  require  all  available  blitter  time.   We also ask you to
	refrain  from  using  the  audio  functions  as  the next task will
	probably be needing all available channels.

	If  there  are  no  more  GMS  tasks  in the queue, then the screen
	display  will  return  to  intuition.   GMS supports two methods of
	screen  switching  to  intuition,  Switch-To-Window  and Switch-To-
	Screen.   The  method  used  depends on the setting in the GMSPrefs
	utility.

	Switch-To-Window drops out to workbench and places a window on the
	screen.   It will wait until the close gadget is pressed, whereupon
	your game will continue where it left off.

	Switch-To-Screen opens an intution screen and busy-waits until that
	screen comes to the front.  At that point the intuition screen will
	be closed and your game will resume execution.

@{b}SEE ALSO@{ub}
	@{"AutoSwitch" LINK "AutoSwitch()"}, @{"HideDisplay" LINK "HideDisplay()"}, @{"WaitVBL" LINK "WaitVBL()"}

@EndNode
---------------------------------------------------------------------------
@NODE "AutoSwitch()" "Screens.GPI/AutoSwitch"

@{b}NAME@{ub}
	AutoSwitch -- Returns  the  screen  display  to  intuition  if  the
			Left-Amiga + M key combination was pressed.

@{b}SYNOPSIS@{ub}
	AutoSwitch()

	void AutoSwitch(void)

@{b}FUNCTION@{ub}
	Returns  the  screen  display  to intuition if the user pressed the
	Left-Amiga+M key combination.  Your game's execution will be halted
	until  the  user brings your screen back.

	GMS  supports two methods of screen switching, Switch-To-Window and
	Switch-To-Screen.   The  method  used depends on the setting in the
	GMSPrefs utility.

	Switch-To-Window drops out to workbench and places a window on the
	screen.   It will wait until the close gadget is pressed, whereupon
	your game will continue where it left off.

	Switch-To-Screen opens an intution screen and busy-waits until that
	screen comes to the front.  At that point the intuition screen will
	be closed and your game will resume execution.

@{b}SEE ALSO@{ub}
	@{"Switch" LINK "Switch()"}, @{"HideDisplay" LINK "HideDisplay()"}, @{"WaitVBL" LINK "WaitVBL()"}

@EndNode
---------------------------------------------------------------------------
@NODE "SwapBuffers()" "Screens.GPI/SwapBuffers"

@{b}NAME@{ub}	SwapBuffers -- Switch the screen display buffers.

@{b}SYNOPSIS@{ub}
	SwapBuffers(GameScreen)
	               a0

	void SwapBuffers(struct GameScreen *)

@{b}FUNCTION@{ub}
	Swaps  GS_MemPtr1  and  GS_MemPtr2 and activates the new bitmap for
	the  display.   If  triple  buffered,  then  all three MemPtr's are
	switched.  Visually:

	@{b}BEFORE          AFTER@{ub}
	MemPtr1         MemPtr2
	MemPtr2  ---->  MemPtr3
	MemPtr3         MemPtr1

	You  can  get the addresses contained in these values, but you must
	never physically change these pointers yourself.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@EndNode
---------------------------------------------------------------------------
@NODE "RemakeScreen()" "Screens.GPI/RemakeScreen"

@{b}NAME@{ub}	RemakeScreen -- Remakes  the screen display according to its size,
			 width, and position on the monitor.

@{b}SYNOPSIS@{ub}
	RemakeScreen(GameScreen)
	                a0

	void RemakeScreen(struct GameScreen *)

@{b}FUNCTION@{ub}
	Remakes  the  GameScreen's  display  @{i}window@{ui} as quickly as possible.

	If  the GameScreen is hidden then the changes will show up the next
	time you call ShowScreen().

	You cannot change the display mode, screen type or amount of screen
	colours with this function.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@EndNode
---------------------------------------------------------------------------
@NODE "MovePicture()" "Screens.GPI/MovePicture"

@{b}NAME@{ub}	MovePicture -- Moves the screen to specified X/Y values.

@{b}SYNOPSIS@{ub}
	MovePicture(GameScreen)
                       a0

	void MovePicture(struct GameScreen *)

@{b}FUNCTION@{ub}
	This  routine  has two uses:  Moving the picture to any position on
	the display, and for Hardware Scrolling.

	It  will  take  the  values  from  PicXOffset and PicYOffset in the
	GameScreen  structure and use them to set the new picture position.
	This function will execute at the same speed for all offset values.

	You  must have set the HSCROLL bit for horizontal scrolling and the
	VSCROLL  bit  for  vertical  scrolling  if  you  wish  to  use this
	function.   If  you  set the HBUFFER flag in ScrAttrib then you can
	also  use this function to legally hardware-scroll up to 50 screens
	in   either  X  direction.   Do  not  draw  graphics  beyond  these
	boundaries as you will damage the system.

@{b}NOTES@{ub}	If  the graphics hardware does not support hardware scrolling, this
	routine will probably blit the entire picture to the new position.
	This is very slow but is the only other option.

	The normal execution time for this function on ECS/AGA is 2/3rds of
	a single rasterline on an A1200+Fast.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	  The  PicXOffset  and  PicYOffset  values  will be used to set the
	  picture's new on-screen position.

@{b}SEE ALSO@{ub}
	@{"ResetPicture" LINK "ResetPicture()"}

@EndNode
---------------------------------------------------------------------------
@NODE "ResetPicture()" "Screens.GPI/ResetPicture"

@{b}NAME@{ub}	ResetPicture -- Resets the picture position to position 0X, 0Y.

@{b}SYNOPSIS@{ub}
	ResetPicture(GameScreen)
	                a0

	void ResetPicture(struct GameScreen *)

@{b}FUNCTION@{ub}
	Resets  the picture position to 0X, 0Y.  This method is faster than
	clearing  the  PicXOffset  and  PicYOffset  fields and then calling
	MovePicture().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}RESULT@{ub}	PicXOffset and PicYOffset in the GameScreen will be cleared.

@{b}SEE ALSO@{ub}
	@{"MovePicture" LINK "MovePicture()"}

@EndNode
----------------------------------------- ----------------------------------
@NODE "ColourMorph()" "Screens.GPI/ColourMorph"

@{b}NAME@{ub}	ColourMorph -- Fades a of set of colours into one colour value.

@{b}SYNOPSIS@{ub}
	FadeState = ColourMorph(GameScreen, FadeState, Speed, StartColour,
	   d0			   a0          d0        d1       d3
				AmtColours, SrcColour, DestColour)
				   d4	       d2	  d5

	UWORD ColourMorph(struct GameScreen *, UWORD FadeState, UWORD Speed,
			   ULONG StartColour, ULONG AmtColours,
			   ULONG SrcColour, ULONG DestColour)

@{b}FUNCTION@{ub}
	Fades  the  screen  from  one colour into another colour.  Once you
	call  this  function, you have to keep on calling it until it gives
	you  a  result  of NULL.  This allows you to put this function in a
	loop and do other things while the fade is active.

	This function uses the proportional fading algorithm to acheive its
	effect.

@{b}NOTE@{ub}	All  fading  functions  ignore  the  colour  values  that  are kept
	internally.   This  will  cause problems for you if you do not know
	what  your  current  palette looks like when using these functions.

@{b}EXAMPLE@{ub}	FadeState = NULL;
	do {
           WaitVBL();
	   FadeState = ColourMorph(GameScreen,FadeState,1,0,32,0xFF00AA,0xA7BC30);
	   }
	while (FadeState != NULL)

@{b}INPUTS@{ub}	GameScreen  - Pointer to an initialised GameScreen structure.
	FadeState   - Initialise  to  zero,  then keep sending the returned
		      value back until you get a NULL in this field.
	Speed	    - The required speed for the fade.
	SrcColour   - The colour that you are fading from, 0xRRGGBB format.
	DestColour  - The colour that you are fading to, 0xRRGGBB format.
	StartColour - The colour to start fading from (0 ... AmtColours-1).
	AmtColours  - The amount of colours to fade (1 ... MaximumColours).
		      You must never use a value of 0 here.

@{b}RESULT@{ub}	FadeState - Returns NULL if the fade has finished.

@{b}SEE ALSO@{ub}
	@{"PaletteToColour" LINK "PaletteToColour()"}, @{"PaletteMorph" LINK "PaletteMorph()"}, @{"ColourToPalette" LINK "ColourToPalette()"}

@EndNode
---------------------------------------------------------------------------
@NODE "ColourToPalette()" "Screens.GPI/ColourToPalette"

@{b}NAME@{ub}	ColourToPalette -- Fades a set of colours into a range of values.

@{b}SYNOPSIS@{ub}
	FadeState = ColourToPalette(GameScreen, FadeState, Speed,
	   d0                          a0          d0        d1
				    StartColour, AmtColours, Palette,
				        d3	     d4	       a1
				    Colour)
				      d2

	UWORD ColourToPalette(struct GameScreen *, UWORD FadeState,
			       UWORD Speed, UWORD StartColour,
			       UWORD AmtColours, APTR Palette,
			       ULONG Colour);

@{b}FUNCTION@{ub}
	Fades  a  set of colours of the same value, into a range of colours
	specified  in  Palette.   Once  you call this function, you have to
	keep  on  calling  it  until  it  gives you a result of NULL.  This
	allows you to put this function in a loop and do other things while
	the fade is active.

	This function uses the proportional fading algorithm to acheive its
	effect.

@{b}NOTE@{ub}	All  fading  functions  ignore  the  colour  values  that  are kept
	internally.   This  will  cause problems for you if you do not know
	what  your  current  palette looks like when using these functions.
	Keep  track  of  your  current  palette  values  to  help  you with
	functions like PaletteMorph().

@{b}INPUTS@{ub}	GameScreen  - Pointer to an initialised GameScreen structure.
	FadeState - Initialise  to  zero,  then keep sending the returned
		    value back until you get a NULL in this field.
	Speed	  - The required speed for the fade.
	Palette   - Pointer to the palette used as the source.
	Colour    - The colour that you are fading from, 0xRRGGBB format.
	StartColour - The colour to start fading from (0 ... AmtColours-1).
	AmtColours  - The amount of colours to fade (1 ... MaximumColours).
		      You must never use a value of 0 here.

@{b}RESULT@{ub}	FadeState - Returns NULL if the fade has finished.

@{b}SEE ALSO@{ub}
	@{"PaletteMorph" LINK "PaletteMorph()"}, @{"ColourToPalette" LINK "ColourToPalette()"}, @{"ColourMorph" LINK "ColourMorph()"}

@EndNode
---------------------------------------------------------------------------
@NODE "PaletteMorph()" "Screens.GPI/PaletteMorph"

@{b}NAME@{ub}	PaletteMorph -- Fades a set of colours into a new set of values.

@{b}SYNOPSIS@{ub}
	FadeState = PaletteMorph(GameScreen, FadeState, Speed, StartColour
	   d0                       a0         d0         d1       d3
				 AmtColours, SrcPalette, DestPalette)
				     d4		 a1	     a2

	UWORD PaletteMorph(struct GameScreen *, UWORD FadeState,
			    UWORD Speed, UWORD StartColour,
			    UWORD AmtColours, APTR SrcPalette,
			    APTR DestPalette)

@{b}FUNCTION@{ub}
	This  function  will  take the palette in SrcPalette, and use it to
	fade  a colour set into the palette given in DestPalette.  Once you
	call  this  function, you have to keep on calling it until it gives
	you  a  result  of NULL.  This allows you to put this function in a
	loop and do other things while the fade is active.

	This function uses the proportional fading algorithm to acheive its
	effect.

@{b}NOTE@{ub}	All  fading  functions  ignore  the  colour  values  that  are kept
	internally.   This  will  cause problems for you if you do not know
	what  your  current  palette looks like when using these functions.
	Keep track of your palette's values and point to them in SrcPalette
	if you find that this problem is occurring for you.

@{b}INPUTS@{ub}	GameScreen  - Pointer to an initialised GameScreen structure.
	FadeState   - Initialise  to  zero,  then keep sending the returned
		      value back until you get a NULL in this field.
	Speed	    - The required speed for the fade.
	SrcPalette  - Pointer to the palette used as the source.
	Destpalette - Pointer to the palette that you want to fade to.
	StartColour - The colour to start fading from (0 ... AmtColours-1).
	AmtColours  - The amount of colours to fade (1 ... MaximumColours).
		      You must never use a value of 0 here.

@{b}RESULT@{ub}	FadeState - Returns NULL if the fade has finished.

@{b}SEE ALSO@{ub}
	@{"ColourToPalette" LINK "ColourToPalette()"}, @{"PaletteToColour" LINK "PaletteToColour()"}, @{"ColourMorph" LINK "ColourMorph()"}

@EndNode
---------------------------------------------------------------------------
@NODE "PaletteToColour()" "Screens.GPI/PaletteToColour"

@{b}NAME@{ub}	PaletteToColour -- Fades  a  set  of colours into a specific colour
	  value.

@{b}SYNOPSIS@{ub}
	FadeState = PaletteToColour(GameScreen, FadeState, Speed,
	   d0			       a0          d0        d1
				    StartColour, AmtColours, Palette,
					d3	    d4         a1
				    Colour)
				      d2

	UWORD PaletteToColour(struct GameScreen *, UWORD FadeState,
	                      UWORD Speed, ULONG StartColour,
			      ULONG AmtColours, APTR Palette, ULONG Colour)

@{b}FUNCTION@{ub}
	This  function  will  fade  a  set  of various colour values into a
	single colour value.  This is useful for fading the screen to black
	for  example.   Once  you  call  this function, you have to keep on
	calling it until it gives you a result of NULL.  This allows you to
	put  this  function in a loop and do other things while the fade is
	active.

	This function uses the proportional fading algorithm to acheive its
	effect.

@{b}NOTE@{ub}	All  fading  functions  ignore  the  colour  values  that  are kept
	internally.   This  will  cause problems for you if you do not know
	what  your  current  palette looks like when using these functions.

@{b}INPUTS@{ub}	GameScreen  - Pointer to an initialised GameScreen structure.
	FadeState   - Initialise  to  zero,  then keep sending the returned
		      value back until you get a NULL in this field.
	Speed	    - The required speed for the fade.
	Palette     - Pointer to the palette used as the source.
	Colour	    - The colour you want to fade to, in 0xRRGGBB format.
	StartColour - The colour to start fading from (0 ... AmtColours-1).
	AmtColours  - The amount of colours to fade (1 ... MaximumColours).
		      You must never use a value of 0 here.

@{b}RESULT@{ub}	FadeState - Returns NULL if the fade has finished.

@{b}SEE ALSO@{ub}
	@{"PaletteMorph" LINK "PaletteMorph()"}, @{"PaletteToColour" LINK "PaletteToColour()"}, @{"ColourMorph" LINK "ColourMorph()"}

@EndNode
---------------------------------------------------------------------------
@NODE "ChangeColours()" "Screens.GPI/ChangeColours"

@{b}NAME@{ub}	ChangeColours -- Change a set of colours in a GameScreen's internal
	                  palette.

@{b}SYNOPSIS@{ub}
	ChangeColours(GameScreen, Colours, StartColour, AmtColours)
	                 a0         a1         d0           d1

	void ChangeColours(struct GameScreen *, APTR Colours,
	                     ULONG StartColour, ULONG AmtColours).

@{b}FUNCTION@{ub}
	Changes all colours within the set range.  Alterations will only be
	made to the screen's internal palette.

@{b}INPUTS@{ub}	GameScreen  - Pointer to an initialised GameScreen structure.
	Colours     - Pointer to a list of 24 bit colours.
	StartColour - The  first  colour to be affected by the change.  NB:
		      The first colour is defined as 0.
	AmtColours  - The  amount  of colours to be affected by the change.
		      Must be at least 1.

@EndNode
---------------------------------------------------------------------------
@NODE "BlankColours()" "Screens.GPI/BlankColours"

@{b}NAME@{ub}	BlankColours -- Drives all screen colours to zero (black).

@{b}SYNOPSIS@{ub}
	BlankColours(GameScreen)
	                a0

	void BlankColours(struct GameScreen *)

@{b}FUNCTION@{ub}
	Drives  all  the colours to zero, which should give a black screen.
	You  won't  be  able  to  see any picture detail after calling this
	routine.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@EndNode
---------------------------------------------------------------------------
@NODE "UpdatePalette()" "Screens.GPI/UpdatePalette"

@{b}NAME@{ub}	UpdatePalette - Updates  an entire GameScreen palette to new colour
			values.

@{b}SYNOPSIS@{ub}
	UpdatePalette(GameScreen)
			 a0

	void UpdatePalette(struct GameScreen *)

@{b}FUNCTION@{ub}
	Updates an entire GameScreen palette to new colour values as set in
	GS_Palette.

	Under  current  circumstances  the  changes will appear immediately
	after the next vertical blank.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"UpdateColour" LINK "UpdateColour"}

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateColour()" "Screens.GPI/UpdateColour"

@{b}NAME@{ub}	UpdateColour -- Updates a 24 bit $RRGGBB colour value.

@{b}SYNOPSIS@{ub}
	UpdateColour(GameScreen, Colour, RRGGBB)
			a0	   d0	   d1

	void UpdateRGB(struct GameScreen *, ULONG Colour, ULONG RRGGBB)

@{b}FUNCTION@{ub}
	Updates  a single colour value in the screen's palette.  The change
	is immediately visible following the next vertical blank.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Colour     - The   colour   number   to   update,   between  0  and
		     GameScreen->AmtColours.
	RRGGBB	   - Colour value in standard RRGGBB format.

@{b}SEE ALSO@{ub}
	@{"UpdatePalette" LINK "UpdatePalette()"}

@EndNode
---------------------------------------------------------------------------
@NODE "InitRasterlist()" "Screens.GPI/InitRasterlist"

@{b}NAME@{ub}	InitRasterlist -- Initialise a new rasterlist.

@{b}SYNOPSIS@{ub}
	ErrorCode = InitRasterlist(GameScreen)
	   d0                         a0

	UWORD InitRasterlist(struct GameScreen *)

@{b}FUNCTION@{ub}
	Initialises   a  new  rasterlist  in  a  GameScreen  structure.   A
	rasterlist is a group of commands executed at specific areas of the
	display.   On  current  Amiga's,  rasterlists  are  executed by the
	copper (copperlist's) at preset lines on the screen.  When you call
	this function a copperlist will be set up according to the commands
	you  give  in  your  rasterlist  structure.   In  the past creating
	copperlists  was  a major compatibility concern because you need to
	pass  the  copper  direct  hardware addresses.  Thankfully with GMS
	this is no longer such a problem.

	There  is  still  the issue of gfx boards not having a copper style
	chip  on  them.   Luckily many of these commands can in some way be
	emulated,  so all is not lost on that front.

	Current valid commands are:

	@{b}WAITLINE <Line>@{ub}
	Waits for the vertical beam to reach the specified screen position.
	It  is  perfectly  legal  to  enter numbers that go outside of your
	screen's  vertical  limits (ie negative numbers and numbers greater
	than the screen height), but no more than a value of 10.

	Note  that  the  purpose  of  this command is to specify the screen
	position  at  which  the  next  command will be executed.  All line
	values  must  be  specified  in  lo-res  pixels, regardless of your
	screen resolution.

	@{b}COLOUR <ColNum>,<RRGGBB>@{ub}
	Changes  a 24 bit colour value to another.

	@{b}COLOURLIST <Line>,<Skip>,<ColNum>,<RRGGBB>@{ub}
	Allows you to generate the classic coloured lines used by games and
	demos everywhere.  This command is mostly useful for sky/background
	effects,  although  you  could  probably  use  it  for all sorts of
	things.

	@{b}SPRITE <SpriteStruct>@{ub}
	Re-activates a sprite bank at the specified line.  This is commonly
	known as sprite-splitting.  This function is considered "dangerous"
	and may simply do nothing on many gfx boards (although emulation is
	a certain possibility).

	@{b}REPOINT <Bitmap>@{ub}
	Repoints  the  screen bitmap to another area in chip ram, causing a
	screen split at the point that this command is executed.

	@{b}SCROLL <Offset>@{ub}
	Alters the scroll position of a bitplane to within 16 pixels.  This
	is really only useful for scrolling parallax landscapes.

	@{b}FSCROLL <Offset1>,<Offset2>@{ub}
	Alters  the  scroll position of a bitplane to within 16 + 4 quarter
	pixels.    This  is  really  only  useful  for  scrolling  parallax
	landscapes.

	@{b}FLOOD@{ub}
	A  special  effect  that  reverses the bitplane modulo, causing the
	bitplane  to  repeat itself.  This effect is used as a novel way of
	"fading in" the screen.

	@{b}MIRROR@{ub}
	Similar  to  Flood,  but  does a complete reversal of the modulo so
	that  the  bitplane is "flipped over".  See examples/AGAMirror.s to
	see how this works.

	@{b}RASTEND@{ub}
	You must terminate your rasterlist with this command.

	[If you have any other ideas for commands, mail me.  - Paul]

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	  GS_Rasterlist  in  this  structure  must  contain  a pointer to a
	  standard rasterlist.

	Look  at  the  examples  in this package to help you with designing
	your rasterlists.

@{b}RESULT@{ub}	ErrorCode - Is NULL if the initialisation was successful.  Otherwise
	  it will return one of the following values:

          ERR_NOMEM = Not enough memory was available for one of the
	              allocations.

	  ERR_NOPTR = You didn't put an address pointer in GS_Rasterlist.

	  ERR_INUSE = A rasterlist is still in use by this screen (remove
	              the old one).

@{b}SEE ALSO@{ub}
	UpdateRasterlist, ShowRasterlist, HideRasterlist,
	RemoveRasterlist, @{"games/games.i" LINK "INCLUDES:games/games.i/Main"}

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateRasterlist()" "Screens.GPI/UpdateRasterlist"

@{b}NAME@{ub}	UpdateRasterlist -- Update an existing rasterlist.

@{b}SYNOPSIS@{ub}
	UpdateRasterlist(GameScreen)
	                    a0

	void UpdateRasterlist(struct GameScreen *)

@{b}FUNCTION@{ub}
	Completely  updates  a  rasterlist's  commands  and  waitline's  to
	whatever  values GS_Rasterlist may now hold.  The length of time to
	do  this  depends on how big your rasterlist is (generally, it will
	do the update very fast though).

	Make  sure  that any changes are within the limits of your original
	values,  for  example  you  cannot  make  changes  to the amount of
	colours used in a NEWPALETTE command.

	If you only want to update the lines or the command datas, then you
	can call UpdateRastCommands() or UpdateRastLines(), which can be a
	bit faster in certain situations.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	InitRasterlist, ShowRasterlist, HideRasterlist,
	RemoveRasterlist, UpdateRastCommands, UpdateRastLines,
	@{"games/games.i" LINK "INCLUDES:games/games.i/Main"}

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateRasterLines()" "Screens.GPI/UpdateRasterLines"

@{b}NAME@{ub}	UpdateRasterLines -- Updates all the WaitLine's in an active
			      rasterlist.

@{b}SYNOPSIS@{ub}
	void UpdateRasterLines(GameScreen)
	                          a0

	void UpdateRasterLines(struct GameScreen *)

@{b}FUNCTION@{ub}
	Updates  every  occurance  of  a  WAITLINE  command  in  an  active
	rasterlist.  This includes the update of waitline's within commands
	such  as  COLOURLIST.   All  other commands are excluded from being
	updated by this function.

	This  function has been provided because for other functions it can
	be  unsafe  to  update single WAITLINE commands.  Whenever you want
	one  or  more  raster line's updated we insist that you use this or
	the UpdateRasterlist() routine.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	UpdateRasterCommand, UpdateRasterCommands, UpdateRasterlist

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateRasterCommand()" "Screens.GPI/UpdateRasterCommand"

@{b}NAME@{ub}	UpdateRasterCommand -- Update a single rasterlist command.

@{b}SYNOPSIS@{ub}
	UpdateRasterCommand(GameScreen, Command)
	                       a0         a2

	void UpdateRasterCommand(struct GameScreen *, APTR Command)

@{b}FUNCTION@{ub}
	Updates a single raster command.  This is the fastest way to update
	any  single  command  in  a rasterlist.  For the update of multiple
	commands, use UpdateRasterlist() or UpdateRasterCommands().

	You  must  never  use  this  command  to update changes in WAITLINE
	commands.   Doing  so  can  have  unpredictable  effects  on  other
	line related commands on screen.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Command - Points to the rasterlist command to be updated.

@{b}SEE ALSO@{ub}
	UpdateRasterCommands, UpdateRasterLines, UpdateRasterlist

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateRasterCommands()" "Screens.GPI/UpdateRasterCommands"

@{b}NAME@{ub}	UpdateRasterCommands -- Update a group of rasterlist commands'.

@{b}SYNOPSIS@{ub}
	UpdateRasterCommands(GameScreen, Command, Amount)
	                        a0         a2       d0

@{b}FUNCTION@{ub}
	Updates a group of raster commands in a screen's active rasterlist.
	This  is  the  fastest  way  to  update a group of commands without
	having  to  do  a  complete rasterlist update.  If you only want to
	update  a  single command, use UpdateRasterCommand().  For all the
	commands, use UpdateRasterlist().

	You  must  never  use  this  command  to update changes in WAITLINE
	commands.   Doing  so  can  have  unpredictable  effects  on  other
	line related commands on screen.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Command    - Points to the first rasterlist command to be updated.
	Amount     - The amount of commands to be updated.

@{b}SEE ALSO@{ub}
	UpdateRasterCommand, UpdateRasterLines, UpdateRasterlist

@EndNode
---------------------------------------------------------------------------
@NODE "RemoveRasterlist()" "Screens.GPI/RemoveRasterlist"

@{b}NAME@{ub}	RemoveRasterlist -- Hide and delete Rasterlist from memory.

@{b}SYNOPSIS@{ub}
	RemoveRasterlist(GameScreen)
	                    a0

	void RemoveRasterlist(struct GameScreen *)

@{b}FUNCTION@{ub}
	Removes the memory used by the rasterlist's internal setup.  If the
	rasterlist  is  currently displayed then it will be hidden from the
	view before the deletion.

	Once  this  function is called the rasterlist is gone - if you want
	to  redisplay your rasterlist, you must reinitialise it with a call
	to InitRasterlist().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	InitRasterlist, ShowRasterlist, HideRasterlist, RemoveRasterlist,
	@{"games/games.i" LINK "INCLUDES:games/games.i/Main"}

@EndNode
---------------------------------------------------------------------------
@NODE "HideRasterlist()" "Screens.GPI/HideRasterlist"

@{b}NAME@{ub}	HideRasterlist -- Hide a rasterlist from the display.

@{b}SYNOPSIS@{ub}
	HideRasterlist(GameScreen)
	                  a0

	void HideRasterlist(struct GameScreen *)

@{b}FUNCTION@{ub}
	Hides a rasterlist from the screen display.  This function does not
	delete  the  internal rasterlist or change the GameScreen structure
	in  any  way.   You  can  return  the list to the display simply by
	calling ShowRasterlist().

@{b}NOTE@{ub}	There is a VBL delay in this function so that the rasterlist is not
	removed while the beam is still executing its instructions.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	InitRasterlist, RemoveRasterlist, ShowRasterlist, HideRasterlist,
	UpdateRasterlist

@EndNode
---------------------------------------------------------------------------
@NODE "ShowRasterlist()" "Screens.GPI/ShowRasterlist"

@{b}NAME@{ub}	ShowRasterlist -- Display a rasterlist on screen.

@{b}SYNOPSIS@{ub}
	ShowRasterlist(GameScreen)
	                  a0

	void ShowRasterlist(struct GameScreen *)

@{b}FUNCTION@{ub}
	Display  a rasterlist on the screen.  The pointer to the rasterlist
	must lie in GS_Rasterlist, and must have been initialised by a call
	to InitRasterlist().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	InitRasterlist, HideRasterlist, ShowRasterlist, RemoveRasterlist,
	UpdateRasterlist

@EndNode
---------------------------------------------------------------------------
@NODE "InitSprite()" "Screens.GPI/InitSprite"

@{b}NAME@{ub}	InitSprite -- Initialise a sprite structure.

@{b}SYNOPSIS@{ub}
	Sprite = InitSprite(GameScreen, Sprite)
	  d0                   a0         a1

	struct Sprite * InitSprite(struct GameScreen *, struct Sprite *)

@{b}FUNCTION@{ub}
	Initialises  a  sprite  ready  for  placement on the screen.  After
	calling  this  function  you  can  use  sprite  functions  such  as
	UpdateSprite(), MoveSprite() etc.

	If  it is impossible to show the sprite, then an error code will be
	returned.   In  such  a  case it helps to have a blitter routine as
	back  up,  so  that  you can instead display the sprite as a BOB on
	screen.

	Sprites  are  very  much  dependent  on the machine hardware, so be
	aware that the image may not show on some machines.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Sprite     - A sprite structure or tag list.

	Here follows a description of each Sprite field:

	@{b}SPR_Number@{ub}
	The bank number that this sprite is going to use.

	@{b}SPR_Data@{ub}
	Points  to  the  beginning  of the sprite data (starts with the two
	control words).

	@{b}SPR_XCoord@{ub}
	Defines  the  horizontal  position  of  the  sprite when displayed.
	Negative  or  extreme  values  that  put  the sprite outside of the
	screen are permitted.

	@{b}SPR_YCoord@{ub}
	Defines  the  vertical  position  of  the  sprite  when  displayed.
	Negative  or  extreme  values  that  put  the sprite outside of the
	screen are permitted.

	@{b}SPR_Frame@{ub}
	The number of the frame to display.  The first frame is 0, the last
	frame  is  defined  by  the  amount  of  following graphics for the
	sprite.

	@{b}SPR_Width@{ub}
	The  width  of  the  sprite  in  pixels.   Under  OCS/ECS  the only
	available  range  is  16  pixels.   Under  AGA  this is extended by
	permission of values 32 and 64.

	@{b}SPR_Height@{ub}
	The height of the sprite in pixels.  A valid range is between 0 and
	256.

	@{b}SPR_AmtColours@{ub}
	The  amount  of colours used by this sprite.  This will be either 4
	colours or 16 colours if the sprite is to work on OCS/ECS/AGA.

	@{b}SPR_ColStart@{ub}
	The  colour  bank  at which the colours are going to start for this
	sprite.   This  value goes up in increments of 16, eg 0,16,32,48...
	Under  OCS/ECS  you must set this value to 16.  For AGA the maximum
	limit  is  240.   Note  that under current hardware conditions, all
	sprites  must  share the same colour bank.  Do not attempt to set a
	different colour bank for each individual sprite.

	@{b}SPR_Planes@{ub}
	Specifies the amount of planes used per bank.  Set this value to 2.

	@{b}SPR_Resolution@{ub}
	Defines  the  display  mode  for the sprite.  Possible flags are:

	  LORES      - Puts the sprite in low resolution.  (Default)

	  HIRES      - Specifies a high resolution sprite.

	  SHIRES     - Specifies a super-high resolution sprite.

	  XLONG      - Use  this  flag  if  you  want  to  join two sprites
	               together  on  the X axis.  The  second sprite's data
	               must  follow  the  first  sprite  and  fit  the same
	               attributes.

	@{b}SPR_FieldPriority@{ub}
	Defines  the  position  of  the  sprite  in  relation to the screen
	playfields.   If  set to 0 then the sprite is at the very front, if
	set to 1 then the sprite is one field behind, and so on.

@{b}SEE ALSO@{ub}
	MoveSprite, UpdateSprite, UpdateSpriteList, HideSpriteList,
	@{"games/games.i" LINK "INCLUDES:games/games.i/Main"}

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateSprite()" "Screens.GPI/UpdateSprite"

@{b}NAME@{ub}	UpdateSprite -- Place a sprite on the screen.

@{b}SYNOPSIS@{ub}
	UpdateSprite(GameScreen, Sprite)
	                a0         a1

	void UpdateSprite(struct GameScreen *, struct Sprite *)

@{b}FUNCTION@{ub}
	Updates  the sprite co-ordinates (screen location) and recalculates
	the sprite image pointers for animation.

	This  function  cannot  make  sudden changes to the width, colours,
	resolution, or height of the sprite.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Sprite     - Pointer to an initialised Sprite structure.

@{b}SEE ALSO@{ub}
	@{"InitSprite" LINK "InitSprite()"}, @{"MoveSprite" LINK "MoveSprite()"}

@EndNode
---------------------------------------------------------------------------
@NODE "MoveSprite()" "Screens.GPI/MoveSprite"

@{b}NAME@{ub}	MoveSprite -- Move a sprite to a new screen location.

@{b}SYNOPSIS@{ub}
	MoveSprite(GameScreen, Sprite)
	              a0         a1

	void MoveSprite(struct GameScreen *, struct Sprite *)

@{b}FUNCTION@{ub}
	Moves  a  sprite  to a new screen location according to the X and Y
	co-ordinates   found   SPR_XCoord  and  SPR_YCoord  in  the  Sprite
	structure.   This  function does not act on any other Sprite fields
	and is intended for use with non-animated sprites.

@{b}NOTES@{ub}	On  graphics  hardware  where sprites are not supported, the sprite
	may be drawn to screen as a BOB.

	There is no list support as static sprites are a rarity in games.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Sprite     - Pointer to an initialised Sprite structure.

@{b}SEE ALSO@{ub}
	@{"InitSprite" LINK "InitSprite()"}, @{"UpdateSprite" LINK "UpdateSprite()"}

@EndNode
---------------------------------------------------------------------------
@NODE "HideSprite()" "Screens.GPI/HideSprite"

@{b}NAME@{ub}	HideSprite -- Remove a sprite from the screen display.

@{b}SYNOPSIS@{ub}
	HideSprite(GameScreen, Sprite)
	              a0         a1

	void HideSprite(struct GameScreen *, struct Sprite *)

@{b}FUNCTION@{ub}
	Hides a sprite from the screen display.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	Sprite     - Pointer to an initialised Sprite structure.

@{b}SEE ALSO@{ub}
	@{"HideSpriteList" LINK "HideSpriteList()"}

@EndNode
---------------------------------------------------------------------------
@NODE "UpdateSpriteList()" "Screens.GPI/UpdateSpriteList"

@{b}NAME@{ub}	UpdateSpriteList -- Update a list of initialised sprites.

@{b}SYNOPSIS@{ub}
	UpdateSpriteList(GameScreen, SpriteList)
	                    a0           a1

	void UpdateSpriteList(struct GameScreen *, APTR SpriteList)

@{b}FUNCTION@{ub}
	Update  a  series of initialised sprites according to a SpriteList.
	This  function  is  provided  as  an alternative to making constant
	calls to UpdateSprite(), which can be quite time consuming.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	SpriteList - Pointer  to  a SpriteList containing a list of up to 8
		     initialised  sprites.  The  list must be terminated by
		     a LISTEND, eg:

			SpriteList:
			  dc.l   "LIST"
			  dc.l   Sprite1
			  dc.l   Sprite2
			  dc.l   Sprite3
			  dc.l   Sprite4
			  dc.l   LISTEND

@{b}SEE ALSO@{ub}
	@{"UpdateSprite" LINK "UpdateSprite()"}

@EndNode
---------------------------------------------------------------------------
@NODE "HideSpriteList()" "Screens.GPI/HideSpriteList"

@{b}NAME@{ub}	HideSpriteList -- Hide sprites as specified by a SpriteList.

@{b}SYNOPSIS@{ub}
	HideSpriteList(GameScreen, SpriteList)
	                  a0           a1

	void HideSpriteList(struct GameScreen *, APTR SpriteList)

@{b}FUNCTION@{ub}
	Hide a series of currently displayed sprites from the screen.  This
	function  is provided as an alternative to making constant calls to
	HideSprite(), which can be quite time consuming.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.
	SpriteList - Pointer  to  a SpriteList containing a list of up to 8
		     initialised  sprites.  The  list must be terminated by
		     a LISTEND, eg:

			SpriteList:
			  dc.l   "LIST"
			  dc.l   Sprite1
			  dc.l   Sprite2
			  dc.l   Sprite3
			  dc.l   Sprite4
			  dc.l   LISTEND

@{b}SEE ALSO@{ub}
	@{"HideSprite" LINK "HideSprite()"}

@EndNode
---------------------------------------------------------------------------
@NODE "RemoveAllSprites()" "Screens.GPI/RemoveAllSprites"

@{b}NAME@{ub}	RemoveAllSprites -- Remove all sprites from the display.

@{b}SYNOPSIS@{ub}
	RemoveAllSprites(GameScreen)
	                    a0

	void RemoveAllSprites(struct GameScreen *)

@{b}FUNCTION@{ub}
	Removes  all  displayed  sprites from the screen simply by altering
	the  DMA Controller.  This is the fastest way to remove all sprites
	from the display quickly and easily.

@{b}NOTE@{ub}	After  you  have  called  this  function you cannot see any visible
	changes to sprites until you call ReturnAllSprites().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"ReturnAllSprites" LINK "ReturnAllSprites()"}

@EndNode
---------------------------------------------------------------------------
@NODE "ReturnAllSprites()" "Screens.GPI/ReturnAllSprites"

@{b}NAME@{ub}	ReturnAllSprites -- Return all sprites to the display.

@{b}SYNOPSIS@{ub}
	ReturnAllSprites(GameScreen)
	                    a0

	void ReturnAllSprites(struct GameScreen *)

@{b}FUNCTION@{ub}
	Returns  all  sprites  that  were  previously removed by RemoveAll-
	Sprites().

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"RemoveAllSprites" LINK "RemoveAllSPrites()"}

@EndNode
---------------------------------------------------------------------------
@NODE "AllocVideoMem()" "Screens.GPI/AllocVideoMem"

@{b}NAME@{ub}	AllocVideoMem -- Allocate blitter memory.

@{b}SYNOPSIS@{ub}
	Memory = AllocVideoMem(Size)
	  d0		       d0

	APTR AllocVideoMem(ULONG Size)

@{b}FUNCTION@{ub}
	Allocates  a  block of memory suitable for the video display.  This
	type  of memory is also compatible with the Blitter.GPI, and should
	continue to do so for all hardware configurations.

	The  memory  will  be  tracked  as  outlined  in AllocMemBlock() if
	resource tracking is turned on.

@{b}INPUTS@{ub}	Size - The Size of the memory to allocate.

@{b}RESULT@{ub}	Memory - Pointer  to  the  allocated  memory.  All  video memory is
		 formatted with 0's when allocated.  Returns NULL if error.

@{b}SEE ALSO@{ub}
	@{"FreeMemBlock" LINK "GMSAutodoc.guide/FreeMemBlock()"}

@EndNode
---------------------------------------------------------------------------
@NODE "WaitVBL()" "Screens.GPI/WaitVBL"

@{b}NAME@{ub}	WaitVBL -- Waits for a vertical blank.

@{b}SYNOPSIS@{ub}
	WaitVBL()

	void WaitVBL(void);

@{b}FUNCTION@{ub}
	Waits  until  the  horizontal beam reaches the Vertical BLank area.
	This  routine  will try and give you as much VBL space as possible,
	usually by waiting for the exact point where the display stops.  If
	this  is  not possible, then it will wait for the beam to reach the
	top of the monitor display.

	This  function  has  an  implanted AutoSwitch() call to make screen
	switching very easy to implement.

@{b}SEE ALSO@{ub}
	@{"WaitRastLine" LINK "WaitRastLine()"}

@EndNode
---------------------------------------------------------------------------
@NODE "WaitRastLine()" "Screens.GPI/WaitRastLine"

@{b}NAME@{ub}	WaitRastLine -- Waits for the strobe to reach a specific line.

@{b}SYNOPSIS@{ub}
	WaitRastLine(LineNumber)
		         d0

	void WaitRastLine(WORD LineNumber)

@{b}FUNCTION@{ub}
	Waits   for   the  strobe  to  reach  the  scan-line  specified  in
	LineNumber.    The   recognised  range  is  dependent  on  the  low
	resolution  height  of your screen, eg 0-255 for a standard 320x256
	screen.  It is permissable to enter negative values and values that
	exceed this range, but only do so if absolutely necessary.

	This  function  has  been  specially  written  to avoid beam misses
	caused by the untimely activation of interrupts.

@{b}INPUTS@{ub}	LineNumber - Vertical beam position to wait for.

@{b}BUGS@{ub}	If  you  enter  a  large value that is well beyond the range limit,
	like  #350,  the strobe will never reach this line because line 350
	doesn't  even  exist.   This  will  cause  your program to lock up.
	Please keep your values restricted to the height of your screen.

@{b}SEE ALSO@{ub}
	@{"WaitVBL" LINK "WaitVBL()"}

@EndNode
---------------------------------------------------------------------------
@NODE "BlankOn()" "Screens.GPI/BlankOn"

@{b}NAME@{ub}	BlankOn -- Blanks out the entire display until BlankOff() is called.

@{b}SYNOPSIS@{ub}
	BlankOn()

	void BlankOn(void)

@{b}FUNCTION@{ub}
	After  calling  this function the screen display will be completely
	blanked  out until BlankOff() is called.  For the duration that the
	display  is  blanked  out,  there will be no visible screen effects
	whatsoever.   Note  that  ShowScreen()  is  completely incapable of
	ending  a  screen  blanking  period, but once the screen display is
	returned any screen alterations will be visible.

	This function is intended for making a clean transition between two
	screens, ie closing one screen then opening another.

@{b}SEE ALSO@{ub}
	@{"BlankOff" LINK "BlankOff()"}

@EndNode
---------------------------------------------------------------------------
@NODE "BlankOff()" "Screens.GPI/BlankOff"

@{b}NAME@{ub}	BlankOff -- Gives back the display after BlankOn() was called.

@{b}SYNOPSIS@{ub}
	BlankOff()

	void BlankOff(void)

@{b}FUNCTION@{ub}
	This  function  returns the screen display after calling BlankOn().
	Any  hidden  visual  changes that occurred after the BlankOn() call
	will become immediately visible after calling this function.

@{b}SEE ALSO@{ub}
	@{"BlankOn" LINK "BlankOn()"}

@EndNode
---------------------------------------------------------------------------
@NODE "FreeSprite()" "Screens.GPI/FreeSprite"

@{b}NAME@{ub}	FreeSprite -- Frees a sprite from the system.

@{b}SYNOPSIS@{ub}
	FreeSprite(Sprite)
		     a1

	void FreeSprite(struct Sprite *);

@{b}FUNCTION@{ub}
	Frees  a  previously  initialised  sprite  from  the  system.  This
	function has garbage protection and will safely ignore sprites that
	have not actually been initialised.

@{b}INPUT@{ub}	Sprite - Pointer to an initialised sprite structure.

@{b}SEE ALSO@{ub}
	@{"InitSprite" LINK "InitSprite()"}

@EndNode
---------------------------------------------------------------------------
@NODE "GetScreen()" "Screens.GPI/GetScreen"

@{b}NAME@{ub}	GetScreen -- Gets the latest version of the GameScreen structure.

@{b}SYNOPSIS@{ub}
	GameScreen = GetScreen()
	    d0

	struct GameScreen * GetScreen(void);

@{b}FUNCTION@{ub}
	Allocates  the  latest  version  of  a GMS GameScreen structure and
	returns it back to you.  The structure fields will be empty so that
	you  can  fill  them  out  to  suit your requirements.  Before your
	program  exits  you  will  need  to  free  the  structure,  this is
	automatically done in the DeleteScreen() function.

	You  have  to use this function if you do not want to use tag lists
	to  initialise  your  GameScreen  (remember  that  it is illegal to
	compile and use pre-initialised structures in GMS programs).

@{b}RESULT@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}
	@{"AddScreen" LINK "AddScreen()"}

@EndNode
---------------------------------------------------------------------------
@NODE "TakeDisplay()" "Screens.GPI/TakeDisplay"

@{b}NAME@{ub}	TakeDisplay -- Private function.

@{b}SYNOPSIS@{ub}
	ErrorCode = TakeDisplay(GameScreen)
	   d0			   a0

	ULONG TakeDisplay(struct GameScreen *);

@{b}FUNCTION@{ub}
	Takes the display from the Operating System that GMS is running on.
	This  is a special function in the monitor drivers, and is reserved
	for use in the Screens GPI.

@{b}INPUTS@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}RESULT@{ub}	ErrorCode - Returns ERR_OK if successful.

@{b}SEE ALSO@{ub}
	@{"ReturnDisplay" LINK "ReturnDisplay"}

@EndNode
---------------------------------------------------------------------------
@NODE "ReturnDisplay()" "Screens.GPI/ReturnDisplay"

@{b}NAME@{ub}	ReturnDisplay -- Private function.

@{b}SYNOPSIS@{ub}
	GameScreen = ReturnDisplay();

	struct GameScreen * ReturnDisplay();

@{b}FUNCTION@{ub}
	Returns the monitor display to the OS that GMS is running on.  This
	is  a  special function in the monitor drivers, and is reserved for
	use in the Screens GPI.

@{b}RESULT@{ub}	GameScreen - Pointer to the GameScreen that was removed.

@{b}SEE ALSO@{ub}
	@{"TakeDisplay" LINK "TakeDisplay"}

@EndNode
---------------------------------------------------------------------------
@NODE "FreeVideoMem()" "Screens.GPI/FreeVideoMem"

@{b}NAME@{ub}	FreeVideoMem -- Frees a memory block allocated from FreeVideoMem().

@{b}SYNOPSIS@{ub}
	FreeVideoMem(MemBlock)

	void FreeVideoMem(APTR MemBlock);

@{b}FUNCTION@{ub}
	Frees a memory block allocated from AllocVideoMem().

@{b}INPUT@{ub}	MemBlock - The memory block to be freed.

@{b}SEE ALSO@{ub}
	@{"AllocVideoMem" LINK "AllocVideoMem()"}, @{"AllocMemBlock" LINK "AllocMemBlock()"}

@EndNode
---------------------------------------------------------------------------
@NODE "GetScrType()" "Screens.GPI/GetScrType"

@{b}NAME@{ub}	GetScrType -- Gets the default/user screen type.

@{b}SYNOPSIS@{ub}
	ScrType = GetScrType()

	ULONG GetScrType(void);

@{b}FUNCTION@{ub}
	Returns  the  screen  type that is being used as the default in the
	Screens GPI.  This function is often used by other GPI's, since the
	ScrType  is  a  common  field  in structures not initialised by the
	Screens GPI.

@{b}RESULT@{ub}	ScrType - The default screen type (eg PLANAR).

@EndNode
---------------------------------------------------------------------------
@NODE "RefreshScreen()" "Screens.GPI/RefreshScreen"

@{b}NAME@{ub}	RefreshScreen - Update the screen display.

@{b}SYNOPSIS@{ub}
	RefreshScreen(GameScreen)
			 a0

	void RefreshScreen(struct GameScreen *);

@{b}FUNCTION@{ub}



@{b}INPUT@{ub}	GameScreen - Pointer to an initialised GameScreen structure.

@{b}SEE ALSO@{ub}	@{"WaitVBL" LINK "WaitVBL()"}

@EndNode
---------------------------------------------------------------------------
@NODE "()" "Screens.GPI/"

@{b}NAME@{ub}

@{b}SYNOPSIS@{ub}

@{b}FUNCTION@{ub}

@{b}INPUTS@{ub}

@{b}RESULT@{ub}

@{b}SEE ALSO@{ub}

@EndNode
