*
*	A public domain Colour Requester by Rick Morris, Panorama User's Group
*
*
*	This program was developed from an example by Joe Bostic in the Amigan
*	and uses his Intuition Message handler 'Dispatcher' as a subroutine.
*
*	This code may be freely distributed and included in any program you
*	write, with the proviso that you send me a copy of the program, 
*	or release said program into the public domain, free of charge.
*
*	Disclaimer: this program definitely does exactly what it does.
*	Anything you think it may do is entirely a figment of your imagination,
*	and as such, I will not be held responsible for your halucinations.
*
*	How it works:
*
*
*--------- include these statements in your code--------------
*
*	XDEF	ColourReq
*
*
*	MOVE.L	ScreenPointer,a0	;Address of your Screen, 0 if WorkBench Screen
*	MOVE.L	CurrentColour,d0	;The currently selected colour
*	BSR	ColourReq
*	....	more of your code 
*
*-------------------------------------------------------------
*
*
*	I have no idea about how you would call this routine in C or any 
*	other foreign language, and invite you to give it a try. 
*
*	This routine conforms to Intuition register usage, i.e d0,d1,a0,a1
*	are destroyed (definitely) and d2-d7,a2-a7 are preserved.
*	Also, it opens/closes all libraries internally, so the only XDEF
*	you need in your program is ColourReq itself
*
*	Basically, the routine puts up a nice little gadget panel allowing
*	you to change colours, swap colours, copy one to another, spread
*	out a range, etc. It includes cancel and undo functions. The 
*	routine takes care of how deep the screen is, and stuff like that
*	you really don't want to deal with.
*
*	Bug reports/Questions/Answers/Free Software/Cash to:
*	Rick Morris
*	4179 William St.
*	Burnaby,B.C.
*	Canada
*	V5C 3J5
*
*	I am a member of PaNorAmA and can usually be found at their meetings. 
*	Sorry, no Usenet/CI$ contacts, I'm to cheap (and busy).
*
*	If you're using CED or some other editor with adjustable tabs, 
*	Put 'em here.
*       X           X                           XX


	include	'ram:includes&stuff'

	XDEF	ColourReq

	SECTION	one,CODE

ColourReq:
	movem.l	d2-d7/a2-a6,-(sp)	Save the registers

	move.l	d0,Screen.Ptr	save the screen pointer

*	first thing we do...kill all the lawyers

	bne	CustomType 	its a custom screen

	moveq	#2,d0	its a WorkBench Screen
	bra	SetupBoxes


CustomType:
	move.l	d0,a0
	move.b	sc_BitMap+bm_Depth(a0),d0	get screen depth
	and.l	#$0000000f,d0
	subq	#1,d0
	mulu	#4,d0	make d0 longword length

SetupBoxes:
	move.l	#BoxTableArray,a0	
	add.l	d0,a0
	move.l	(a0),a0	get pointer to gadget sizes
	lea	ZeroGadg+gg_LeftEdge,a1
1$	moveq	#3,d7
2$	move.w	(a0)+,(a1)+	move the TopEdge etc. into 
	dbf	d7,2$	 the gadget structure
	cmp.w	#0,(a0)	Last in chain?
	beq	3$
	add.l	#$24,a1	move on to next gadget
	bra	1$
	
3$	sub.l	#$c,a1	orient back to NextGadget
	move.l	#0,(a1)	sever the gadget chain

	move.l	#RenderTable,a0	now fix the Render structs
	add.l	d0,a0
	move.l	(a0),a0
	move.l	#ZeroRender+4,a1	first width/height pair
	move.l	#31,d7	do all 32 renders
4$	move.l	(a0),(a1)	this gets both at once
	add.l	#ig_SIZEOF,a1	goto next image
	dbf	d7,4$

DoneBoxes:
	
	move.l	#PolyArray,a0	the gadget's box border array
	move.l	#PolyArrayTable,a1	table of border values
	add.l	d0,a1
	move.l	(a1),a1	 and the proper one
	
	moveq	#9,d7
1$	move.w	(a1)+,(a0)+	
	dbf	d7,1$


	lea	INTUIT.NAME,a1	Open Intuition
	clr.l	d0
	LINKLIB	_LVOOpenLibrary,_AbsExecBase	Macro, save typing
	move.l	d0,Intuit.Ptr

	lea	GRAPHIC.NAME,a1	Open the graphics library
	clr.l	d0
	LINKLIB	_LVOOpenLibrary,_AbsExecBase
	move.l	d0,Graphic.Ptr

OpenWindow:

	lea	AWindow,a0
	LINKLIB 	_LVOOpenWindow,Intuit.Ptr	And open the window
	move.l	d0,Window.Ptr
	beq	NoWindow	did the window open?
	move.l	d0,a0	Yup.
	move.l	wd_RPort(a0),RPort	Get the RastPort address

*	set the font

	move.l	#TextAttr,a0	80column text attribute pointer
	LINKLIB	_LVOOpenFont,Graphic.Ptr	get the 80 column font
	tst.l	d0
	beq	NoFont	make sure the font exists
	move.l	d0,a0
	move.l	a0,Font.Ptr	save its pointer

	move.l	RPort,A1
	LINKLIB	_LVOSetFont,Graphic.Ptr	set the font

	move.l	Window.Ptr,a0
	move.l	wd_WScreen(a0),a0	Get the Screen Address
	move.l	sc_ViewPort+vp_ColorMap(a0),a2 This is the colourmap
	lea	ColourTable,a3	Here's where we get the colour
	lea	ColourTemp,a4	 Table for the screen
	move.l	#0,d7
1$	move.l	a2,a0
	move.l	d7,d0
	LINKLIB	_LVOGetRGB4,Graphic.Ptr	Get Colour # described in d0
	move.w	d0,(a3)+
	move.w	d0,(a4)+
	addq	#1,d7
	cmp.b	#Colours+1,d7
	bne	1$
	
*	draw window border

	lea	WindowBorder,a1	the window's BORDER struct
	moveq	#0,d0	the x,y offsets
	move.l	d0,d1
	move.l	RPort,a0	
	LINKLIB	_LVODrawBorder,Intuit.Ptr	draw the border


*	draw box around current picked colour

	lea	ZeroGadg,a0
	move.l	a0,CurrentColGadg
	moveq	#1,d0
	bsr	DrawBorder

	jsr	Update	set up the prop gadgets


	move.l	Window.Ptr,a0	These are set-ups for 
	move.l	wd_UserPort(a0),a0	 Dispatcher, the Intuition
	lea	VectorList,a1	 handling routine.
	jsr	Dispatcher

*	Dispatcher has returned, someone did an RTS with d0<>0
*	therefore time to end the program
	
NoFont

	move.l	Font.Ptr,D0	Close the font
	move.l	d0,a1
	LINKLIB	_LVOCloseFont,Graphic.Ptr


NoWindow
	move.l	Window.Ptr,a0	Close the window
	LINKLIB	_LVOCloseWindow,Intuit.Ptr


	move.l 	Intuit.Ptr,a1		Close the libraries
	LINKLIB	_LVOCloseLibrary,_AbsExecBase
	move.l	Graphic.Ptr,a1
	LINKLIB 	_LVOCloseLibrary,_AbsExecBase
	clr.l	d0

*	the end of the program. Restore the registers

	movem.l	(sp)+,d2-d7/a2-a6

	rts	

*
*	That's the end of the program. Now come the subroutines to handle
*	the various gadgets as they are clicked
*
*	
*Modify the screen's colour register according to selected gadget
*
*	This routine handles the Prop gadgets foe colour modification.
*
*	Dispatcher gives us on entry;
*	 a1=Pointer to the Gadget Structure
*	 d0=gg.GadgetID Value
*	 d1=0,gadget down   d1=1,gadget up
*
Modify:
	cmp.l	#0,d1	Is this a Gadget Down?
	beq	Update
	move.l 	a1,Currentgadg	save gadget info
	move.l 	d0,CurrentID
Modify1:
	move.l 	Currentgadg,a1
	move.l 	CurrentID,d0
	move	OldRed,d1	get the old colours
	move	OldGreen,d2
	move	OldBlue,d3
	move.l 	gg_SpecialInfo(a1),a0	get prop info pointer
	btst	#3,d0	Is this a vertical only gadget
	beq	1$

*
*	This next section checks to see which colours have been modified by 
*	checking the Gadget id value for specific bits. See in the menus for
*	which bit does what
*
	btst	#0,d0	Is it a vertical only gadget?
	beq	5$
	move	pi_VertPot(a0),d3
	bra	endif.m1
5$	btst	#1,d0
	beq	6$
	move	pi_VertPot(a0),d2
	bra	endif.m1
6$	move	pi_VertPot(a0),d1
	bra	endif.m1


1$	btst	#2,d0
	beq	else.m1
	move	pi_VertPot(a0),d1
	btst	#1,d0
	beq	else.m2
	move	pi_HorizPot(a0),d2
	bra	endif.m1
else.m2:
	move	pi_HorizPot(a0),d3
else.m1:
	btst	#1,d0
	beq	3$
	move	pi_VertPot(a0),d2
3$	move	pi_HorizPot(a0),d3

endif.m1:
	and	#$f000,d1
	lsr	#8,d1
	lsr	#4,d1
	and	#$f000,d2
	lsr	#8,d2
	lsr	#4,d2
	and	#$f000,d3
	lsr	#8,d3
	lsr	#4,d3
	move.l	Window.Ptr,a0
	move.l	wd_WScreen(a0),a0
	lea	sc_ViewPort(a0),a0
	move.l	CurrentColour,d0
	LINKLIB	_LVOSetRGB4,Graphic.Ptr
	bra	DoneUpdate	
	
*Reflect the colour in gadgets
Update:
	bsr	GetColour

	mulu	#$1111,d1	propogate byte through 
;	ror.w	#4,d4	 longword, ie $0004 
;	or	d4,d1	 becomes $4444
;	move.w	d1,d4
;	ror.w	#8,d4
;	or	d4,d1

	mulu	#$1111,d2
;	ror.w	#4,d4
;	or	d4,d2
;	move.w	d2,d4
;	ror.w	#8,d4
;	or	d4,d2

	mulu	#$1111,d3
;	ror.w	#4,d4
;	or	d4,d3
;	move.w	d3,d4
;	ror.w	#8,d4
;	or	d4,d3

	move.w	d1,OldRed	save the colour values
	move.w	d2,OldGreen
	move.w	d3,OldBlue
	lea	Red_G,a0
	cmp.l	Currentgadg,a0	if eq, this one's already adjusted
	beq	1$	 so leave it alone
	jsr	FixProp
1$	lea	Green_G,a0
	cmp.l	Currentgadg,a0
	beq	2$
	jsr	FixProp	adjust the prop gadget structure
2$:	
	lea	Blue_G,a0
	cmp.l	Currentgadg,a0
	beq	3$
	jsr	FixProp

3$:
	lea	RedV_G,a0
	cmp.l	Currentgadg,a0
	beq	4$
	jsr	FixProp
4$:
	lea	GreenV_G,a0
	cmp.l	Currentgadg,a0
	beq	5$
	jsr	FixProp
5$:
	lea	BlueV_G,a0
	cmp.l	Currentgadg,a0
	beq	DoneUpdate
	jsr	FixProp


DoneUpdate:
	move.l 	#0,d0	back to dispatcher
	rts
	
GetColour:
	move.l 	Window.Ptr,a0	get current colour
	move.l 	wd_WScreen(a0),a0
	move.l 	sc_ViewPort+vp_ColorMap(a0),a0
	move.l 	CurrentColour,d0
	LINKLIB 	_LVOGetRGB4,Graphic.Ptr
	lea	ColourTemp,a0	plant the colour in temp table
	add.l	CurrentColour,a0
	add.l	CurrentColour,a0
	move.w	d0,(a0)
	bsr	BreakDown	make into d1,d2,d3
	rts

BreakDown:
	and	#$fff,d0
	swap	d0	break the color down into 3 16 bit #'s
	clr	d0
	swap	d0
	move.l 	d0,d1
	move.l 	d0,d2
	move.l 	d0,d3
	clr.b	d1
	asl	#4,d1
	asl	#4,d2
	clr.b	d2
	asl	#4,d2
	asl	#8,d3
	asl	#4,d3
	rts

FixProp:
*	find out which vertical and horizontal body values we need to adjust
*	for each of the gadgets by testing bits in the SpecialInfo thus:
*	 bit 4= vertical gadget, off= 2-dimensional
*	 bit 2= RED
*	 bit 1= GREEN
*	 bit 0= BLUE

	move.l	gg_SpecialInfo(a0),a1
	btst	#3,gg_GadgetID+1(a0)	If this bit is on,
	bne 4$		 its a vertical only gadg

	btst	#2,gg_GadgetID+1(a0)	the RED bit
	beq	1$
	move	d1,pi_VertPot(a1)
	btst	#1,gg_GadgetID+1(a0)	the GREEN bit
	beq	3$
	move.w	d2,pi_HorizPot(a1)
	bra	2$
3$:
	move.w	d3,pi_HorizPot(a1)
	bra	2$
1$:
	move.w	d2,pi_VertPot(a1)
	move.w	d3,pi_HorizPot(a1)
	bra	2$
*		a one-dimensional gadget
4$:
	btst	#0,gg_GadgetID+1(a0)	the BLUE bit
	beq	5$
	move.w	d3,pi_VertPot(a1)
	bra	2$
5$	btst	#1,gg_GadgetID+1(a0)
	beq	6$
	move.w	d2,pi_VertPot(a1)
	bra	2$
6$	move.w	d1,pi_VertPot(a1)

2$:

*	got body values moved properly, now adjust the display of the gadget

	movem.l	d1-d3,-(sp)
	move.l	gg_SpecialInfo(a0),a1
	move.w	pi_HorizPot(a1),d1
	move.w	pi_VertPot(a1),d2
	move.w	pi_HorizBody(a1),d3
	move.w	pi_VertBody(a1),d4
	move.w	pi_Flags(a1),d0
	move.l	#1,d5
	move.l	Window.Ptr,a1
	LINKLIB	_LVONewModifyProp,Intuit.Ptr
	movem.l 	(sp)+,d1-d3
	
	rts


*
ChangeColour:

*
*	user has picked a different colour to adjust, draw a border around it
*
	andi.l	#$7f,d0	strip valid gadget bit
	move.l	d0,CurrentColour	update colour
	move.l	#0,Currentgadg	for the fixprop routine
	move.w	#31,d7	counter for gadgets to update
	move.l	a1,-(sp)	save the gadget pointer

*	clear the border around the last gadget

	move.l	CurrentColGadg,a0
	moveq	#0,d0
	bsr	DrawBorder


	move.l	(sp)+,a0	get pointer back in a0!

	move.l	a0,CurrentColGadg

*	draw a border around this gadget

	moveq	#1,d0
	bsr	DrawBorder

*	change the colour of the large colour block

	move.l	CurrentColour,d0
	move.l	RPort,a1
	LINKLIB	_LVOSetAPen,Graphic.Ptr

	move.l	RPort,a1	
	move.l	#2,d0
	moveq	#HEIGHT_OFFSET,d1
	move.l	#27,d2
	move.l	#HEIGHT_OFFSET+25,d3
	LINKLIB	_LVORectFill,Graphic.Ptr
	bra	Update



DrawBorder:
*	a0 contains gadget ptr,d0 contains frontpen

	lea	Border,a1	
	move.b	d0,bd_FrontPen(a1)
	move.w	gg_LeftEdge(a0),d0
	subq	#1,d0
	move.w	gg_TopEdge(a0),d1
	subq	#1,d1

	move.l	RPort,a0	
	LINKLIB	_LVODrawBorder,Intuit.Ptr
	rts



Restore:

*	put all colours back to original

	lea	ColourTable,a1
	lea	ColourTemp,a2
	move.l	#15,d7
1$	move.l	(a1)+,(a2)+
	dbf	d7,1$
	lea	ColourTable,a1

Restore1:		;entry point for the swap routine
	move.l	Window.Ptr,a0
	move.l	wd_WScreen(a0),a0
	add.l	#sc_ViewPort,a0	viewport is a struct in screen
	move	#Colours+1,d0
	LINKLIB	_LVOLoadRGB4,Graphic.Ptr

	move.l	#0,Currentgadg	for the fixprop routine
	
	bra	Update


SwapColours:
*		Change the pointer, swap colours, change back

	bsr	SetPointer	

*		now get the next message, check for a gadget

	bsr	GetNextColour

*		now the gadget user data is in d7
*		and its time to swap the two colours


	move.l	d7,d0	get colour # back
	move.l 	Window.Ptr,a0
	move.l 	wd_WScreen(a0),a0
	move.l 	sc_ViewPort+vp_ColorMap(a0),a0
	LINKLIB	_LVOGetRGB4,Graphic.Ptr	get its colour value
	lea	ColourTemp,a0
	add.l	CurrentColour,a0
	add.l	CurrentColour,a0
	move.w	d0,(a0)	plant it in the table

	move.l	CurrentColour,d0	get the other colour
	move.l 	Window.Ptr,a0
	move.l 	wd_WScreen(a0),a0
	move.l 	sc_ViewPort+vp_ColorMap(a0),a0
	LINKLIB 	_LVOGetRGB4,Graphic.Ptr

	lea	ColourTemp,a0	plant it in the table
	add.l	d7,a0
	add.l	d7,a0
	move.w	d0,(a0)	
	
*	put the pointer back to original

	bsr	ClearPointer

*		now plant the colour table

	lea	ColourTemp,a1
	bra	Restore1

SetPointer:
	move.l	Window.Ptr,a0
	lea	PointerImage,a1	change to special pointer
	moveq	#17,d0
	move.l	#16,d1
	move.l	#-2,d2
	move.l	d2,d3
	LINKLIB	_LVOSetPointer,Intuit.Ptr
	rts

ClearPointer:
*	restore the default pointer
	move.l	Window.Ptr,a0
	LINKLIB	_LVOClearPointer,Intuit.Ptr
	rts


GetNextColour

*	get the next gadget clicked, make sure it's a colour gadget

2$	move.l	Window.Ptr,a0
	move.l	wd_UserPort(a0),a0
	move.l	a0,-(sp)
	LINKLIB	_LVOWaitPort,_AbsExecBase	wait for the next gadget
	move.l	(sp)+,a0
	jsr	_LVOGetMsg(a6)
	move.l	d0,-(sp)	remember the IDCMP msg type
	move.l	d0,a0
	move.l	im_IAddress(a0),a1	
	move.w	gg_GadgetID(a1),d7	Pointer to the gadget's colour
	move.l	im_Class(a0),d1
	cmp.l	#GADGETUP,d1	make sure its a gadget
	beq	1$	colour gadget has been clicked?
	move.l	#0,d7	set d7 to retry
1$	move.l	d0,a0
	ext.l	d7
	move.l	(sp)+,a1	message # (well, address actually)
	jsr	_LVOReplyMsg(a6)	reply to the IntuiMessage
	bclr	#7,d7
	beq	2$	not a colour gadget that was picked
	rts

Range:
*	Routine to spread colour out between gadgets

	bsr	SetPointer
	bsr	GetNextColour

*	d7 is selected colour, CurrentColour is one highlighted

	cmp.l	CurrentColour,d7
	beq	NoRange	hit the same gadget, the dolt

*	now break down the colour and calculate the spread

	lea	ColourTemp,a3	holds high colour address
	add.l	d7,a3
	add.l	d7,a3

	lea	ColourTemp,a2	holds low colour address
	add.l	CurrentColour,a2
	add.l	CurrentColour,a2

	sub.l	CurrentColour,d7

	cmp.l	a2,a3
	bgt	5$

	move.l	a2,a4	make sure a2 is lower
	move.l	a3,a2	 of the two addresses
	move.l	a4,a3
	eor.l	#-1,d7	make d7 positive again
	addq	#1,d7

5$:
*	move.l	d7,d6

	moveq	#1,d5	current colour for divide

	move.w	(a2)+,d0	get low colour,point to next

	bsr	UnCrunch

	move.w	d1,OldRed	put in byte form in temp
	move.w	d2,OldGreen	 storage
	move.w	d3,OldBlue

1$	move.w	(a3),d0	get value to spread to

	bsr	UnCrunch

	sub.w	OldRed,d1	get the difference
	bne	2$
	move.w	OldRed,d1	make sure there is a difference
2$	sub.w	OldGreen,d2
	bne	3$
	move.w	OldGreen,d2
3$	sub.w	OldBlue,d3
	bne	4$
	move.w	OldBlue,d3

4$	muls	d5,d1	multiply by current cell #
	muls	d5,d2
	muls	d5,d3

	divs	d7,d1	divide by # of cells
	divs	d7,d2
	divs	d7,d3

	add.w	OldRed,d1	add back the base colour
	cmp	#$f,d1	 make sure it doesn't overflow
	ble	6$
	move.w	OldRed,d1
6$	add.w	OldGreen,d2
	cmp	#$f,d2
	ble	7$
	move.w	OldGreen,d2
7$	add.w	OldBlue,d3
	cmp	#$f,d3
	ble	8$
	move.w	OldBlue,d3

8$	bsr	Crunch	make back to one word

	move.w	d0,(a2)+	plant the colour in the table
	addq	#1,d5	increment curren cell #
	cmp.l	a2,a3	done the table yet?
	bgt	1$

NoRange:
	bsr	ClearPointer	back to default pointer
	lea	ColourTemp,a1	show the colours
	bra	Restore1

Crunch:
*	make d1,d2,d3 fit in d0, 4 bits each

	lsl	#8,d1
	lsl	#4,d2
	move.w	d3,d0
	add.w	d2,d0
	add.w	d1,d0
	rts

UnCrunch:
*	do just the opposite..d0 to d1,d2,d3, 4 bits each

	move.w	d0,d1
	and.l	#$0f00,d1
	lsr	#8,d1
	move.w	d0,d2
	and.l	#$00f0,d2
	lsr	#4,d2
	move.w	d0,d3
	and.l	#$000f,d3
	rts


Copy:
*	copy the colour between gadgets

	bsr	SetPointer	set the 'to' pointer
	bsr	GetNextColour	get next colour gadget picked

	lea	ColourTemp,a2	'from'
	add.l	CurrentColour,a2
	add.l	CurrentColour,a2

	lea	ColourTemp,a3	'to'
	add.l	d7,a3
	add.l	d7,a3

	move.w	(a2),(a3)	move the colour

	bra	NoRange	a convenient exit

Cancel:
*	restore the original colours and close window

	bsr	Restore	
	moveq	#1,d0
	rts




*	The vector list for the dispatcher routine follows
VectorList:
	dc.l	CLOSEWINDOW,QuitCode
	dc.l	NEWPREFS,Update
	dc.l	MOUSEMOVE,Modify1
	dc.l	0

QuitCode	move.l #-1,d0
	rts

 
	SECTION  two,DATA,CHIP
PKnobImage:
	dc.w	%000011111110000
	dc.w	%111111111111111
	dc.w	%111111111111111
	dc.w	%000011111110000

KnobImage:
	dc.w	%000000111000000
	dc.w	%000111111111000
	dc.w	%000111111111000
	dc.w	%000000111000000

PointerImage:
	dc.w	0,0
	dc.w	%000000000000000,%111111000000000
	dc.w	%011111000000000,%111111100000000
	dc.w	%011111000000000,%100001100000000
	dc.w	%011110000000000,%100011000000000
	dc.w	%011111000000000,%100001100000000
	dc.w	%011111100000000,%100000110000000
	dc.w	%000111110000000,%011000011000000
	dc.w	%000011111000000,%000100001100000
	dc.w	%000001111100000,%000010000110000
	dc.w	%000000111000000,%000001001100000
	dc.w	%000000010000000,%000111101110000
	dc.w	%000111011110000,%001000100001000
	dc.w	%000010010010000,%000101100001000
	dc.w	%000010010010000,%000101100001000
	dc.w	%000010010010000,%000101100001000
	dc.w	%000010011110000,%000101100001000
	dc.w	%000000000000000,%000010011110000

RGImage:
	dc.w	%0000000111110000
	dc.w	%0010001100011000
	dc.w	%0110011000000000
	dc.w	%0001011000111000
	dc.w	%0000111000011000
	dc.w	%1111111100011000
	dc.w	%0110011111111000
	dc.w	%0110011100000000
	dc.w	%0111110010000000
	dc.w	%0110110001100000
	dc.w	%0110011001000000
	dc.w	%1110001100000000

RGHImage:
	dc.w	%1111111000001111
	dc.w	%1101110011100111
	dc.w	%1001100111111111
	dc.w	%1110100111000111
	dc.w	%1111000111100111
	dc.w	%0000000011100111
	dc.w	%1001100000000111
	dc.w	%1001100011111111
	dc.w	%1000001101111111
	dc.w	%1001001110011111
	dc.w	%1001100110111111
	dc.w	%0001110011111111

GBImage:
	dc.w	%0000000111110000
	dc.w	%0010001100011000
	dc.w	%0110011000000000
	dc.w	%0001011000111000
	dc.w	%0000111000011000
	dc.w	%1111111100011000
	dc.w	%0110011111111000
	dc.w	%0110011100000000
	dc.w	%0111110010000000
	dc.w	%0110110001100000
	dc.w	%0110011001000000
	dc.w	%1110001100000000

GBHImage:
	dc.w	%1111111000001111
	dc.w	%1101110011100111
	dc.w	%1001100111111111
	dc.w	%1110100111000111
	dc.w	%1111000111100111
	dc.w	%0000000011100111
	dc.w	%1001100000000111
	dc.w	%1001100011111111
	dc.w	%1000001101111111
	dc.w	%1001001110011111
	dc.w	%1001100110111111
	dc.w	%0001110011111111

RBImage:
	dc.w	%0000000111110000
	dc.w	%0010001100011000
	dc.w	%0110011000000000
	dc.w	%0001011000111000
	dc.w	%0000111000011000
	dc.w	%1111111100011000
	dc.w	%0110011111111000
	dc.w	%0110011100000000
	dc.w	%0111110010000000
	dc.w	%0110110001100000
	dc.w	%0110011001000000
	dc.w	%1110001100000000

RBHImage:
	dc.w	%1111111000001111
	dc.w	%1101110011100111
	dc.w	%1001100111111111
	dc.w	%1110100111000111
	dc.w	%1111000111100111
	dc.w	%0000000011100111
	dc.w	%1001100000000111
	dc.w	%1001100011111111
	dc.w	%1000001101111111
	dc.w	%1001001110011111
	dc.w	%1001100110111111
	dc.w	%0001110011111111


	SECTION	three,CODE
NScreen			;NewScreen structure

*			Lo-Res 5 deep

	DC.W	0,0,320,200,5	LeftEdge,TopEdge,Width,Height,Depth
	DC.B	0,1	DetailPen,BlockPen
	DC.W	0	V_HIRES	ViewModes
	DC.W	CUSTOMSCREEN	Type
	DC.L	0	*Font
	DC.L	0	*DefaultTitle
	DC.L	0	*Gadgets
	DC.L	0	*CustomBitMap


AWindow:
	dc.w	0,0,163,99
	dc.b	-1,-1
	dc.l	CLOSEWINDOW!GADGETUP!GADGETDOWN!NEWPREFS!MOUSEMOVE
	dc.l	BORDERLESS!WINDOWCLOSE!WINDOWDEPTH!WINDOWDRAG!SMART_REFRESH!ACTIVATE
	dc.l	Red_G,0,Title
Screen.Ptr:		;actually a part of new window
	dc.l	0
	dc.l	0
	dc.w	100,50,-1,-1
	dc.w	CUSTOMSCREEN

*List of prop-gadgets
*bit	meaning
*0	blue on horizontal axis
*1	green on horizontal if red is set or on vertical if blue is set
*2	red on vertical axis

	CNOP	0,4

Red_G:
	dc.l	Green_G
	dc.w	61-8,57+HEIGHT_OFFSET-8,26+7,26+7
	dc.w	GADGHIMAGE,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	Red_Gx,Red_HGx,0,0,Red_GP	;no text for now Red_T,0,Red_GP
	dc.w	%0110	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
	
Green_G:
	dc.l	Blue_G
	dc.w	97,57+HEIGHT_OFFSET,26,26
	dc.w	GADGHCOMP,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	Green_Gx,0,Green_T,0,Green_GP
	dc.w	%0011	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
	
Blue_G:
	dc.l	RedV_G
	dc.w	135,57+HEIGHT_OFFSET,26,26
	dc.w	GADGHCOMP,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	Blue_Gx,0,Blue_T,0,Blue_GP
	dc.w	%0101	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
RedV_G:
	dc.l	GreenV_G
	dc.w	1,58+HEIGHT_OFFSET,14,24
	dc.w	GADGHIMAGE,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	RedV_Gx,RedV_HGx,RedV_T,0,RedV_GP
	dc.w	%1100	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
	
GreenV_G:
	dc.l	BlueV_G
	dc.w	19,58+HEIGHT_OFFSET,14,24
	dc.w	GADGHIMAGE,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	GreenV_Gx,GreenV_HGx,GreenV_T,0,GreenV_GP
	dc.w	%1010	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
	
BlueV_G:
	dc.l	YesGadg
	dc.w	37,58+HEIGHT_OFFSET,14,24
	dc.w	GADGHIMAGE,GADGIMMEDIATE!FOLLOWMOUSE!RELVERIFY,PROPGADGET
	dc.l	BlueV_Gx,BlueV_HGx,BlueV_T,0,BlueV_GP
	dc.w	%1001	bits to indicate which colours to use
	dc.l	Modify	Routine to be executed by dispatcher
YesGadg:
	dc.l	NoGadg
	dc.w	128,14+HEIGHT_OFFSET,28,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	YesBorder,0,Yes_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	QuitCode	Routine to be executed by dispatcher

NoGadg:
	dc.l	SwapGadg
	dc.w	89,14+HEIGHT_OFFSET,36,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	NoBorder,0,No_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	Restore	Routine to be executed by dispatcher

SwapGadg:
	dc.l	RangeGadg
	dc.w	111,0+HEIGHT_OFFSET,36,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	SwapBorder,0,Swap_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	SwapColours	Routine to be executed by dispatcher

RangeGadg:
	dc.l	CopyGadg
	dc.w	29,0+HEIGHT_OFFSET,42,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	RangeBorder,0,Range_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	Range	Routine to be executed by dispatcher

CopyGadg:
	dc.l	CancelGadg
	dc.w	74,0+HEIGHT_OFFSET,34,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	CopyBorder,0,Copy_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	Copy	Routine to be executed by dispatcher

CancelGadg:
	dc.l	ZeroGadg
	dc.w	36,14+HEIGHT_OFFSET,50,11
	dc.w	GADGHBOX,RELVERIFY,BOOLGADGET
	dc.l	CancelBorder,0,Cancel_T,0,0
	dc.w	0	bits to indicate which 
	dc.l	Cancel	Stub for now

ZeroGadg:
	dc.l	OneGadg
	dc.w	LeftColour,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ZeroRender,0,0,0,0
	dc.w	$80	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

OneGadg:
	dc.l	TwoGadg
	dc.w	LeftColour+ColourSep*1+WidthColour*1,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	OneRender,0,0,0,0
	dc.w	$81	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TwoGadg:
	dc.l	ThreeGadg
	dc.w	LeftColour+ColourSep*2+WidthColour*2,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TwoRender,0,0,0,0
	dc.w	$82	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

ThreeGadg:
	dc.l	FourGadg
	dc.w	LeftColour+ColourSep*3+WidthColour*3,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ThreeRender,0,0,0,0
	dc.w	$83	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

FourGadg:
	dc.l	FiveGadg
	dc.w	LeftColour+ColourSep*4+WidthColour*4,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	FourRender,0,0,0,0
	dc.w	$84	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

FiveGadg:
	dc.l	SixGadg
	dc.w	LeftColour+ColourSep*5+WidthColour*5,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	FiveRender,0,0,0,0
	dc.w	$85	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

SixGadg:
	dc.l	SevenGadg
	dc.w	LeftColour+ColourSep*6+WidthColour*6,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	SixRender,0,0,0,0
	dc.w	$86	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

SevenGadg:
	dc.l	EightGadg
	dc.w	LeftColour+ColourSep*7+WidthColour*7,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	SevenRender,0,0,0,0
	dc.w	$87	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

EightGadg:
	dc.l	NineGadg
	dc.w	LeftColour+ColourSep*8+WidthColour*8,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	EightRender,0,0,0,0
	dc.w	$88	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

NineGadg:
	dc.l	TenGadg
	dc.w	LeftColour+ColourSep*9+WidthColour*9,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	NineRender,0,0,0,0
	dc.w	$89	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TenGadg:
	dc.l	ElevenGadg
	dc.w	LeftColour+ColourSep*10+WidthColour*10,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TenRender,0,0,0,0
	dc.w	$8A	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

ElevenGadg:
	dc.l	TwelveGadg
	dc.w	LeftColour+ColourSep*11+WidthColour*11,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ElevenRender,0,0,0,0
	dc.w	$8B	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TwelveGadg:
	dc.l	ThirteenGadg
	dc.w	LeftColour+ColourSep*12+WidthColour*12,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TwelveRender,0,0,0,0
	dc.w	$8C	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

ThirteenGadg:
	dc.l	FourteenGadg
	dc.w	LeftColour+ColourSep*13+WidthColour*13,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ThirteenRender,0,0,0,0
	dc.w	$8D	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

FourteenGadg:
	dc.l	FifteenGadg
	dc.w	LeftColour+ColourSep*14+WidthColour*14,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	FourteenRender,0,0,0,0
	dc.w	$8E	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

FifteenGadg:
	dc.l	SixteenGadg
	dc.w	LeftColour+ColourSep*15+WidthColour*15,TopColour,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	FifteenRender,0,0,0,0
	dc.w	$8F	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

SixteenGadg:
	dc.l	SeventeenGadg
	dc.w	LeftColour,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	SixteenRender,0,0,0,0
	dc.w	$90	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

SeventeenGadg:
	dc.l	EighteenGadg
	dc.w	LeftColour+ColourSep*1+WidthColour*1,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	SeventeenRender,0,0,0,0
	dc.w	$91	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

EighteenGadg:
	dc.l	NineteenGadg
	dc.w	LeftColour+ColourSep*2+WidthColour*2,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	EighteenRender,0,0,0,0
	dc.w	$92	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

NineteenGadg:
	dc.l	TwentyGadg
	dc.w	LeftColour+ColourSep*3+WidthColour*3,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	NineteenRender,0,0,0,0
	dc.w	$93	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TwentyGadg:
	dc.l	TOneGadg
	dc.w	LeftColour+ColourSep*4+WidthColour*4,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TwentyRender,0,0,0,0
	dc.w	$94	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TOneGadg:
	dc.l	TTwoGadg
	dc.w	LeftColour+ColourSep*5+WidthColour*5,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TOneRender,0,0,0,0
	dc.w	$95	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TTwoGadg:
	dc.l	TThreeGadg
	dc.w	LeftColour+ColourSep*6+WidthColour*6,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TTwoRender,0,0,0,0
	dc.w	$96	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TThreeGadg:
	dc.l	TFourGadg
	dc.w	LeftColour+ColourSep*7+WidthColour*7,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TThreeRender,0,0,0,0
	dc.w	$97	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TFourGadg:
	dc.l	TFiveGadg
	dc.w	LeftColour+ColourSep*8+WidthColour*8,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TFourRender,0,0,0,0
	dc.w	$98	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TFiveGadg:
	dc.l	TSixGadg
	dc.w	LeftColour+ColourSep*9+WidthColour*9,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TFiveRender,0,0,0,0
	dc.w	$99	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TSixGadg:
	dc.l	TSevenGadg
	dc.w	LeftColour+ColourSep*10+WidthColour*10,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TSixRender,0,0,0,0
	dc.w	$9A	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TSevenGadg:
	dc.l	TEightGadg
	dc.w	LeftColour+ColourSep*11+WidthColour*11,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TSevenRender,0,0,0,0
	dc.w	$9B	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TEightGadg:
	dc.l	TNineGadg
	dc.w	LeftColour+ColourSep*12+WidthColour*12,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TEightRender,0,0,0,0
	dc.w	$9C	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

TNineGadg:
	dc.l	ThirtyGadg
	dc.w	LeftColour+ColourSep*13+WidthColour*13,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	TNineRender,0,0,0,0
	dc.w	$9D	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

ThirtyGadg:
	dc.l	ThirtyOneGadg
	dc.w	LeftColour+ColourSep*14+WidthColour*14,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ThirtyRender,0,0,0,0
	dc.w	$9E	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher

ThirtyOneGadg:
	dc.l	0
	dc.w	LeftColour+ColourSep*15+WidthColour*15,TopColour+HeightColour+ColourSep,WidthColour,HeightColour
	dc.w	GADGHBOX!GADGIMAGE,RELVERIFY,BOOLGADGET
	dc.l	ThirtyOneRender,0,0,0,0
	dc.w	$9F	bits to indicate which 
	dc.l	ChangeColour	Routine to be executed by dispatcher



ZeroRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,0
	dc.l	0

OneRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,1
	dc.l	0

TwoRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,2
	dc.l	0

ThreeRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,3
	dc.l	0

FourRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,4
	dc.l	0

FiveRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,5
	dc.l	0

SixRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,6
	dc.l	0

SevenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,7
	dc.l	0

EightRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,8
	dc.l	0

NineRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,9
	dc.l	0

TenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,10
	dc.l	0

ElevenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,11
	dc.l	0

TwelveRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,12
	dc.l	0

ThirteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,13
	dc.l	0

FourteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,14
	dc.l	0

FifteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,15
	dc.l	0

SixteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,16
	dc.l	0

SeventeenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,17
	dc.l	0

EighteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,18
	dc.l	0

NineteenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,19
	dc.l	0

TwentyRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,20
	dc.l	0

TOneRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,21
	dc.l	0

TTwoRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,22
	dc.l	0

TThreeRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,23
	dc.l	0

TFourRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,24
	dc.l	0

TFiveRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,25
	dc.l	0

TSixRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,26
	dc.l	0

TSevenRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,27
	dc.l	0

TEightRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,28
	dc.l	0

TNineRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,29
	dc.l	0

ThirtyRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,30
	dc.l	0

ThirtyOneRender:
	dc.w	0,0,WidthColour,HeightColour,0
	dc.l	0
	dc.b	0,31
	dc.l	0

YesBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	YesXY
	dc.l	0
NoBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	NoXY
	dc.l	0

CopyBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	CopyXY
	dc.l	0

RangeBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	RangeXY
	dc.l	0

SwapBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	SwapXY
	dc.l	0

CancelBorder:
	dc.w	0,0
	dc.b	1,0,JAM1,5
	dc.l	CancelXY
	dc.l	0



Red_GP dc.w	FREEVERT!FREEHORIZ!$8,0,0,KnobSize,KnobSize
	dc.w	0,0,0,0,0,0

Green_GP	dc.w	AUTOKNOB!FREEVERT!FREEHORIZ,0,0,KnobSize,KnobSize
	dc.w	0,0,0,0,0,0

Blue_GP dc.w	AUTOKNOB!FREEVERT!FREEHORIZ,0,0,KnobSize,KnobSize
	dc.w	0,0,0,0,0,0

Red_Gx: 				;ds.b	20
	dc.w	0,0,13,12,1
	dc.l	RGImage
	dc.b	1,0
	dc.l	0

Red_HGx: 				;ds.b	20
	dc.w	0,0,12,12,1
	dc.l	RGHImage
	dc.b	1,0
	dc.l	0

;Red_Gx ds.b	20
Green_Gx	ds.b	20
Blue_Gx ds.b	20

Red_T	dc.b	1,0,1,0
	dc.w	0,-9
	dc.l	0,Red_Tex,Red_1

Red_1	dc.b	1,0,1,0
	dc.w	-9,0
	dc.l	0,Red_Tex1,0

Green_T dc.b	1,0,1,0
	dc.w	0,-9
	dc.l	0,Green_Tex,Green_1

Green_1 dc.b	1,0,1,0
	dc.w	-9,0
	dc.l	0,Green_Tex1,0

Blue_T dc.b	1,0,1,0
	dc.w	0,-9
	dc.l	0,Blue_Tex,Blue_1

Blue_1 dc.b	1,0,1,0
	dc.w	-9,0
	dc.l	0,Blue_Tex1,0

Red_Tex dc.b	'G',0
Red_Tex1	dc.b	'R',0

Green_Tex	dc.b	'B',0
Green_Tex1	dc.b	'G',0

Blue_Tex	dc.b	'B',0
Blue_Tex1	dc.b	'R',0

RedV_GP dc.w	FREEVERT!$8,0,0,$ffff,KnobSize
	dc.w	0,0,0,0,0,0

GreenV_GP:
	dc.w	FREEVERT!$8,0,0,$ffff,KnobSize
	dc.w	0,0,0,0,0,0

BlueV_GP dc.w	FREEVERT!$8,0,0,$ffff,KnobSize
	dc.w	0,0,0,0,0,0

RedV_Gx: 				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	KnobImage
	dc.b	1,0
	dc.l	0

GreenV_Gx:				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	KnobImage
	dc.b	1,0
	dc.l	0

BlueV_Gx:				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	KnobImage
	dc.b	1,0
	dc.l	0

RedV_HGx: 				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	PKnobImage
	dc.b	1,0
	dc.l	0

GreenV_HGx:				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	PKnobImage
	dc.b	1,0
	dc.l	0

BlueV_HGx:				;ds.b	20
	dc.w	0,0,15,4,1
	dc.l	PKnobImage
	dc.b	1,0
	dc.l	0

RedV_T	dc.b	1,0,1,0
	dc.w	2,-9
	dc.l	0,RedV_Tex,0

GreenV_T dc.b	1,0,1,0
	dc.w	2,-9
	dc.l	0,GreenV_Tex,0

BlueV_T dc.b	1,0,1,0
	dc.w	2,-9
	dc.l	0,BlueV_Tex,0

RedV_Tex 	dc.b	'R',0

GreenV_Tex	dc.b	'G',0

BlueV_Tex	dc.b	'B',0

	CNOP 0,4

Yes_T	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,Yes_Tex,0

No_T	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,No_Tex,0

Swap_T	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,Swap_Tex,0

Range_T	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,Range_Tex,0

Copy_T	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,Copy_Tex,0

Cancel_T:
	dc.b	1,0,1,0
	dc.w	2,2
	dc.l	0,Cancel_Tex,0

Yes_Tex	dc.b	'OK',0
No_Tex	dc.b	'Undo',0
Swap_Tex	dc.b	'Swap',0
Range_Tex	dc.b	'Range',0
Copy_Tex	dc.b	'Copy',0
Cancel_Tex	dc.b	'Cancel',0
	CNOP 0,4


TextAttr

	dc.l	FontName
	dc.w	8
	dc.b	0
	dc.b	0

	
Window.Ptr	dc.l	0
Intuit.Ptr	dc.l	0
Graphic.Ptr	dc.l	0
RPort		dc.l	0
Currentgadg	dc.l	0
CurrentColGadg	dc.l	0
CurrentID	dc.l	0
ButtonValue	dc.l	0
WhichPointer	dc.l	0
Font.Ptr	dc.l	0
ColourTable	ds.w	33
OldRed:
		dc.w	0
OldGreen:
		dc.w	0
OldBlue:
		dc.w	0
CurrentColour:
		dc.l	0
ColourTemp:
		ds.w	33	max of 32 colours
INTUIT.NAME	dc.b	'intuition.library',0
GRAPHIC.NAME	dc.b	'graphics.library',0
Title	dc.b	'Color Changer',0
MouseEvents	dc.b	0
FontName	dc.b	'topaz.font',0
	CNOP	0,4


PolyArray:
	dc.w	0,0
	dc.w	0,WidthColour+1
	dc.w	WidthColour+1,HeightColour+1
	dc.w	HeightColour+1,0
	dc.w	0,0

Border:
	dc.w	0
	dc.w	0
	dc.b	0	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	5	# of point pairs
	dc.l	PolyArray	
	dc.l	0	NextBorder

WindowBorder:
	dc.w	0
	dc.w	0
	dc.b	1	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	4	# of point pairs
	dc.l	WindowBorderXY
	dc.l	PGBorderA		NextBorder

PGBorderA:
	dc.w	0
	dc.w	57+HEIGHT_OFFSET
	dc.b	1	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	5	# of point pairs
	dc.l	PGBorderAXY
	dc.l	PGBorderB		NextBorder

PGBorderB:
	dc.w	18
	dc.w	57+HEIGHT_OFFSET
	dc.b	1	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	5	# of point pairs
	dc.l	PGBorderAXY
	dc.l	PGBorderC		NextBorder

PGBorderC:
	dc.w	36
	dc.w	57+HEIGHT_OFFSET
	dc.b	1	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	5	# of point pairs
	dc.l	PGBorderAXY
	dc.l	PGBorderD		NextBorder

PGBorderD
	dc.w	61-9
	dc.w	57+HEIGHT_OFFSET-9
	dc.b	1	frontpen
	dc.b	0	backpen
	dc.b	JAM1	drawmode
	dc.b	5	# of point pairs
	dc.l	PGBorderDXY
	dc.l	0	NextBorder

YesXY:
	dc.w	0,0
	dc.w	28,0
	dc.w	28,11
	dc.w	0,11
	dc.w	0,0
NoXY:
	dc.w	0,0
	dc.w	36,0
	dc.w	36,11
	dc.w	0,11
	dc.w	0,0
SwapXY:
	dc.w	0,0
	dc.w	36,0
	dc.w	36,11
	dc.w	0,11
	dc.w	0,0
RangeXY:
	dc.w	0,0
	dc.w	42,0
	dc.w	42,11
	dc.w	0,11
	dc.w	0,0
CopyXY:
	dc.w	0,0
	dc.w	34,0
	dc.w	34,11
	dc.w	0,11
	dc.w	0,0

CancelXY:
	dc.w	0,0
	dc.w	50,0
	dc.w	50,11
	dc.w	0,11
	dc.w	0,0

WindowBorderXY:
	dc.w	0,0
	dc.w	0,98
	dc.w	162,98
	dc.w	162,0
	
PGBorderAXY:
	dc.w	0,0
	dc.w	16,0
	dc.w	16,26
	dc.w	0,26
	dc.w	0,0
	
PGBorderDXY:
	dc.w	0,0
	dc.w	0,35
	dc.w	35,35
	dc.w	35,0
	dc.w	0,0

	include	'ram:boxes&bows'

	END

