/*
** Scroll Screen 336
** -----------------
** This demo allows you to legally scroll up to 50 screens in either
** direction by setting the HBUFFER flag.  Normally we would blit blocks down
** the left and right hand side to give an impression of heaps of screens -
** maybe later...
** 
*/

MODULE 'games','games/games'

PROC main()
   DEF screen:PTR TO gamescreen, palette:PTR TO INT, zbxy:LONG,
       loadpic:PTR TO picture

   palette := [	$000,$130,$FCB,$FA9,$D88,$965,$644,$211,
		$400,$444,$FF0,$432,$CC0,$150,$501,$880,
		$261,$271,$382,$492,$5A3,$5B4,$677,$6C4,
		$788,$9AA,$BCC,$801,$901,$A02,$701,$601
	      ]:INT;

   screen :=  [	GSV1,0,
		0,0,0,			-> Screen_Mem1/2/3
		0,			-> Screen link.
		palette,		-> Address of palette.
		0,			-> Address of rasterlist.
		0,			-> Amt of colours in palette.
		320,256,		-> Screen Width and Height.
		336/8,256,		-> Screen & Pic Height/Width
		5,			-> Amt of planes.
		0,0,			-> X/Y screen offset.
		0,0,			-> X/Y picture offset.
		HSCROLL OR HBUFFER,	-> Special attributes.
		LORES OR COL12BIT,	-> Screen mode.
		INTERLEAVED,		-> Screen type
		0			-> Reserved.               
	      ]:gamescreen;

   loadpic := [	PCV1,0,			-> Version header.
		0,			-> Destination.
		336/8,256,		-> Width, Height.
		5,			-> Amount of Planes.
		32,			-> Amount of colours.
		palette,		-> Palette (remap).
		LORES OR COL12BIT,	-> Screen mode.
		INTERLEAVED,		-> Destination.
		0,			-> Parameters.
		'GAMESLIB:data/IFF.Pic336'
	      ]:picture;

   IF gmsbase := OpenLibrary('games.library',0)
      SetUserPrefs(0)
      IF (Add_Screen(screen) = ERR_OK)
	 loadpic.data := screen.memptr1;
	 IF (LoadPic(loadpic) = ERR_OK)
	    Show_Screen(screen)
	    Read_Mouse(JPORT1)

	    REPEAT
	      zbxy := Read_Mouse(JPORT1)
	      screen.picxoffset := screen.picxoffset+getZBXYx(zbxy)
	      Move_Picture(screen)
	      Wait_OSVBL()
	    UNTIL !(zbxy AND MB_LMB)

	 ENDIF
	 Delete_Screen(screen)        
      ENDIF
   CloseLibrary(gmsbase)
   ENDIF
ENDPROC
