;-------T-------T------------------------T----------------------------------;
;Name:      Random Plot
;Author:    Paul Manias
;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
;
;This is a graphical demonstration of the Random() functions.  The default
;is to use FastRandom, but you can change it to SlowRandom if you look
;below.
;
;LMB exits.

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

Random	=	_LVOFastRandom	;_LVOFastRandom() or _LVOSlowRandom().

	SECTION	"RandomPlot",CODE

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

	STARTGMS

Start:	MOVEM.L	A0-A6/D1-D7,-(SP)
	move.l	GMSBase(pc),a6
	CALL	AllocBlitter
	tst.l	d0
	bne.s	.Error_Blitter

	lea	ScreenTags(pc),a0
	CALL	ShowScreen
	tst.l	d0
	beq.s	.Error_Screen

	bsr.s	Main

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

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

Main:	move.l	GMSBase(pc),a6
.loop	moveq	#JPORT1,d0
	moveq	#JT_ZBXY,d1
	CALL	ReadJoyPort
	btst	#MB_LMB,d0
	bne.s	.done

	move.l	Screen(pc),a0
	move.l	GS_AmtColours(a0),d1	;Get random colour.
	subq.l	#1,d1
	jsr	Random(a6)	;>> = Get random number.
	addq.l	#1,d0
	move.l	d0,d3	;d3 = Colour to use.

	move.w	GS_ScrWidth(a0),d1	;Get random X.
	jsr	Random(a6)	;>> = Get random number.
	move.w	d0,d4	;d4 = Store X to use.

	move.w	GS_ScrHeight(a0),d1	;Get random Y.
	jsr	Random(a6)	;>> = Get random number.
	move.w	d0,d2	;d2 = Y to use.
	move.w	d4,d1	;d1 = Get back X.

	move.l	Screen(pc),a0
	move.l	GS_Bitmap(a0),a0
	CALL	DrawUCPixel
	CALL	AutoSwitch
	bra.s	.loop

.done	rts

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

ScreenTags:
	dc.l	TAGS_GAMESCREEN
Screen:	dc.l	0
	dc.l	GSA_Palette,.palette
	dc.l	GSA_AmtColours,32
	dc.l	GSA_ScrWidth,640
	dc.l	GSA_ScrHeight,512
	dc.l	GSA_ScrMode,HIRES|LACED
	dc.l	TAGEND
.palette
	dc.l	$000000,$109000,$F0C0B0,$F0A090,$D08080,$906050,$604040,$201010
	dc.l	$400060,$404040,$F0F000,$403020,$C0C000,$109000,$500010,$808000
	dc.l	$206010,$207010,$308020,$409020,$50A030,$50B040,$607070,$60C040
	dc.l	$708080,$90A0A0,$B0C0C0,$800010,$900010,$A00020,$700010,$600010

