;-------T-------T------------------------T----------------------------------;
;Name:      Chunky Picture
;Author:    Paul Manias
;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
;
;This demo loads in a picture in chunky format and then calls RefreshScreen()
;to do the C2P conversion.

	INCDIR	"INCLUDES:"
	INCLUDE	"games/games_lib.i"
	INCLUDE	"games/games.i"

;===========================================================================;
;                             INITIALISE DEMO
;===========================================================================;

	SECTION	"Demo",CODE

	STARTGMS

Start:	MOVEM.L	A0-A6/D1-D7,-(SP)
	move.l	GMSBase(pc),a6
	lea	ScreenTags(pc),a0
	CALL	AddScreen
	tst.l	d0
	beq.s	.Error_Screen

	move.l	Screen(pc),a0
	lea	PictureTags(pc),a1
	move.l	GS_MemPtr1(a0),PicData
	CALL	LoadPic
	tst.l	d0
	beq.s	.Error_Picture

	move.l	Picture(pc),a1
	move.l	PIC_Palette(a1),GS_Palette(a0)
	CALL	UpdatePalette

	CALL	ShowScreen

	bsr.s	Main

.ReturnToDOS
	move.l	GMSBase(pc),a6
	move.l	Picture(pc),a1
	CALL	FreePic
.Error_Picture
	move.l	Screen(pc),a0
	CALL	DeleteScreen
.Error_Screen
	MOVEM.L	(SP)+,A0-A6/D1-D7
	moveq	#ERR_OK,d0
	rts

;===========================================================================;
;                                MAIN LOOP
;===========================================================================;

Main:	move.l	GMSBase(pc),a6
	move.l	Screen(pc),a0
	CALL	RefreshScreen
	CALL	WaitLMB
	rts

;===========================================================================;
;                                  DATA
;===========================================================================;

ScreenTags:
	dc.l	TAGS_GAMESCREEN
Screen:	dc.l	0
	dc.l	GSA_ScrWidth,320
	dc.l	GSA_ScrHeight,256
	dc.l	GSA_ScrType,CHUNKY8
	dc.l	TAGEND

PictureTags:
	dc.l	TAGS_PICTURE
Picture	dc.l	0
	dc.l	PCA_Data
PicData	dc.l	0
	dc.l	PCA_Width,320
	dc.l	PCA_Height,256
	dc.l	PCA_ScrType,CHUNKY8
	dc.l	PCA_Options,GETPALETTE
	dc.l	PCA_File,.file
	dc.l	TAGEND

.file	dc.b	"GMS:demos/data/PIC.Green",0
	even

