 			output	work:huntwindows
			OPT o+,ow-
			;no includes - i use them all preassembled!

			;.... nearly all ....

			incdir	"sys:devpac/include/"
			include "workbench/startup.i"
			include "workbench/workbench.i"
			include	"workbench/icon_lib.i"
			include	"libraries/commodities.i"

;TODO:
;Hotkey for GUI

;BUGS:
;SOMETIMES... there is a guru at closedown
	
			;Some helpful macros
CALL			macro
			jsr	_LVO\1(a6)
			endm
Push			macro
			movem.l	\1,-(sp)
			endm
Pull			macro
			movem.l	(sp)+,\1
			endm
RSave			macro
			movem.l	a0-a6/d0-d7,-(sp)
			endm
RLoad			macro
			movem.l	(sp)+,a0-a6/d0-d7
			endm

MaxScreens		equ	64	;Maximum of 64 Screens - who has more?
ScreenMemSize		equ	MaxScreens*8	

		;Bits for Communication
SignalWindow		equ	0
SignalScreen		equ	1

			RSave

			move.l	$04,a6
			move.l	#AllocLength,d0
			move.l	#MEMF_CLEAR,d1
			CALL	AllocMem
			move.l	d0,a4
			tst.l	d0
			beq	EndeRaus

			move.l	d0,RememberA4
			move.l	a7,RememberStack

			lea	intuition(pc),a1
			moveq.l	#36,d0
			CALL	OpenLibrary
			move.l	d0,IntBase(a4)
			beq	EndeRaus2

			lea	DosName(pc),a1
			moveq.l	#36,d0
			CALL	OpenLibrary	
			move.l	d0,DosBase(a4)
			beq	Error2

			lea	GadName(pc),a1
			moveq.l	#0,d0
			CALL	OpenLibrary
			move.l	d0,GadBase(a4)
			beq	Error2

			lea	CommName(pc),a1
			moveq.l	#0,d0
			CALL	OpenLibrary
			move.l	d0,CommBase(a4)
			beq	Error2

			CALL	CreateMsgPort
			move.l	d0,MouseMsgPort(a4)
			beq	Error2

			move.l	#SIGBREAKF_CTRL_C,SignalMask(a4)

			move.l	d0,a0
			move.l	#IOSTD_SIZE,d0
			CALL	CreateIORequest
			move.l	d0,MyIORequest(a4)
			beq	Error2

			lea	InputName(pc),a0
			moveq.l	#0,d0
			move.l	MyIORequest(a4),a1
			moveq.l	#0,d1
			CALL	OpenDevice
			tst.l	d0
			bne	Error2

			lea	IconName(pc),a1
			moveq.l	#33,d0
			CALL	OpenLibrary
			move.l	d0,IconBase(a4)
			beq	Error2

			move.l	ThisTask(a6),a1
			move.l	a1,OwnTask(a4)
			tst.l	pr_CLI(a1)
			bne	CliStart
			lea	pr_MsgPort(a1),a2
			move.l	a2,a0
			CALL	WaitPort
			move.l	a2,a0
			CALL	GetMsg
			move.l	d0,WBMessage(a4)
			move.l	d0,a3
		
			move.l	sm_ArgList(a3),d7
			beq	DisableSave
			move.l	d7,a0
			move.l	wa_Lock(a0),d1
			move.l	DosBase(a4),a6
			CALL	CurrentDir

			move.l	IconBase(a4),a6
			move.l	d7,a0
			move.l	wa_Name(a0),a0
			CALL	GetDiskObject
			move.l	d0,DObject(a4)
			beq	Error2

			lea	WBTemplate(pc),a3

			move.l	d0,a0
			move.l	do_ToolTypes(a0),a0
			
GetEmLoop		tst.l	(a3)
			beq.s	FreeDobj
			move.l	TemplateText(a3),a1
			beq.s	FreeDobj
			move.l	a0,-(sp)
			CALL	FindToolType
			move.l	(sp)+,a0
			sub.l	a2,a2
			move.w	TemplateA4(a3),a2
			add.l	a4,a2
			move.l	d0,(a2)
			add.l	#TemplateSize,a3
			bra.s	GetEmLoop

FreeDobj		bsr	BuildPatterns

			bra.s	SkipReadArgs

CliStart		move.l	DosBase(a4),a6

			move.l	#Template,d1
			lea	TemplateArray(a4),a0
			move.l	a0,d2
			moveq.l	#0,d3
			CALL	ReadArgs	;Get options
			tst.l	d0
			beq	Error2
			move.l	d0,Args(a4)
	
			bsr	BuildPatterns

DisableSave		move.l	#1,TempSave(a4)

SkipReadArgs		move.l	$04,a6
			lea	GraphicsName(pc),a1
			moveq.l	#36,d0
			CALL	OpenLibrary
			move.l	d0,GraphicsBase(a4)
			beq	Error2

			tst.l	TempHADJ(a4)
			beq	GotIt1
			move.l	TempHADJ(a4),a0
			bsr	GetNexta0
			clr.l	TempHADJ(a4)
			cmp.b	#"l",d0
			beq.s	GotIt1
			add.l	#1,TempHADJ(a4)
			cmp.b	#"r",d0
			beq.s	GotIt1
			add.l	#1,TempHADJ(a4)
			cmp.b	#"c",d0
			beq.s	GotIt1
			add.l	#1,TempHADJ(a4)

GotIt1			tst.l	TempVADJ(a4)
			beq	GotIt2
			move.l	TempVADJ(a4),a0
			bsr	GetNexta0
			clr.l	TempVADJ(a4)
			cmp.b	#"t",d0
			beq.s	GotIt2
			add.l	#1,TempVADJ(a4)
			cmp.b	#"b",d0
			beq.s	GotIt2
			add.l	#1,TempVADJ(a4)
			cmp.b	#"c",d0
			beq.s	GotIt2
			add.l	#1,TempVADJ(a4)

GotIt2			move.l	IconBase(a4),a6
			tst.l	DObject(a4)
			beq.s	SkipFreeDD
			move.l	DObject(a4),a0
			CALL	FreeDiskObject

SkipFreeDD		move.l	$04,a6
			CALL	CreateMsgPort
			move.l	d0,BrokerPort
			move.l	d0,MyPort(a4)
			move.l	d0,a0
			move.b	MP_SIGBIT(a0),d0
			move.l	SignalMask(a4),d1		;Enter signal into
			bset	d0,d1			;mask for waiting
			move.l	d1,SignalMask(a4)

			move.l	CommBase(a4),a6
			lea	MyNewBroker(pc),a0
			clr.l	d0
			CALL	CxBroker
			tst.l	d0
			beq	QuitPrg
			move.l	d0,Broker(a4)

			move.l	d0,a0
			moveq.l	#1,d0
			CALL	ActivateCxObj

			move.l	$04,a6
	                moveq   #-1,d0			;A Signal for telling
	                jsr     _LVOAllocSignal(a6)	;our task that sth happened
	                tst.l   d0
	                bmi     Error2
	                move.l  d0,Signal(a4)
			move.l	SignalMask(a4),d1
	                bset    d0,d1
	                move.l	d1,SignalMask(a4)

			lea	MyInterrupt(a4),a1
			move.l	#Interrupt3,IS_CODE(a1)
			clr.l	IS_DATA(a1)
			move.b	#NT_INTERRUPT,LN_TYPE(a1)
			move.b	#0,LN_PRI(a1)
			move.l	#HandlerName,LN_NAME(a1)
			move.l	#5,d0	;INTB_VERTB
			jsr	_LVOAddIntServer(a6)

			tst.l	TempCXPOPUP(a4)
			beq.s	WaitOn
			bsr	OpenGUI

WaitOn			tst.w	QuitMe(a4)
			bne	QuitPrg

			move.l	$04,a6
			move.l	SignalMask(a4),d0		;Wait for Port and Break
			CALL	Wait
			btst	#SIGBREAKB_CTRL_C,d0	;This means quit
			bne	QuitPrg
			move.l	Signal(a4),d1
			btst	d1,d0			;Signal from Interrupt?
			beq.s	TryNextMsg

			tst.w	DisableHW(a4)
			bne.s	TryNextMsg		;Do nothing

			move.l	IntBase(a4),a0
			btst	#SignalWindow,What(a4)
			beq.s	NoWindowStuff
			
			move.l	ib_ActiveWindow(a0),a0
			bsr	DoYourJob
			bclr	#SignalWindow,What(a4)

NoWindowStuff		btst	#SignalScreen,What(a4)
			beq.s	TryNextMsg
			move.l	IntBase(a4),a0
			move.l	ib_FirstScreen(a0),a0
			bsr	AdjustScreen
			bclr	#SignalScreen,What(a4)

TryNextMsg		move.l	MyPort(a4),a0		;Get the message awaiting
			CALL	GetMsg
			tst.l	d0
			bne.s	GotMsg
			bsr	CheckGUI
			bra	WaitOn

GotMsg			move.l	d0,a3
			move.l	d0,a0
			move.l	CommBase(a4),a6
			CALL	CxMsgType
			move.l	d0,d6
			move.l	a3,a0
			CALL	CxMsgID
			move.l	d0,d5
			move.l	a3,a1
			move.l	$04,a6
			CALL	ReplyMsg
			cmp.w	#CXM_IEVENT,d6
			bne.s	OtherCommand
			bsr	OpenGUI

OtherCommand		cmp.w	#CXM_COMMAND,d6
			bne	WaitOn

			cmp.w	#CXCMD_DISABLE,d5
			bne.s	OtherI1
			move.w	#1,DisableHW(a4)

OtherI1			cmp.w	#CXCMD_ENABLE,d5
			bne.s	OtherI2
			clr.w	DisableHW(a4)

OtherI2			cmp.w	#CXCMD_UNIQUE,d5
			beq.s	OtherII
			cmp.w	#CXCMD_APPEAR,d5
			bne.s	OtherI3
OtherII			bsr	OpenGUI

OtherI3			cmp.w	#CXCMD_DISAPPEAR,d5
			bne.s	OtherI4
			bsr	CloseGUI

OtherI4			cmp.w	#CXCMD_KILL,d5
			beq	QuitPrg

			bra	TryNextMsg

Error2			lea	Text1(pc),a0		;Seems there is an error
			bsr	OpenRequester		;in the given arguments
			bra.s	QuitPrg

EndeRaus2		lea	Text2(pc),a0		;Wrong Kickstart
			bsr	PrintText

QuitPrg			move.l	RememberStack,a7
			bsr	CloseGUI
			move.l	$04,a6	
			move.l	#5,d0
			lea	MyInterrupt(a4),a1
			tst.l	IS_CODE(a1)
			beq.s	NoHandler
			CALL	RemIntServer		;Remove the Interrupt-Server

NoHandler		tst.l	MyIORequest(a4)
			beq.s	NoDevIO
			move.l	MyIORequest(a4),a1
			CALL	CloseDevice
			move.l	MyIORequest(a4),a0
			CALL	DeleteIORequest	
NoDevIO			tst.l	MouseMsgPort(a4)
			beq.s	NoMouseMsg

			move.l	MouseMsgPort(a4),a0
			bsr	CloseMsgPort

NoMouseMsg		move.l	Signal(a4),d0		;Free the signal
			beq.s	DontFreeS
	                CALL	FreeSignal

DontFreeS		tst.l	Args(a4)
			beq.s	HmmNoArgs
			move.l	DosBase(a4),a6
			move.l	Args(a4),d1
			CALL	FreeArgs

HmmNoArgs		tst.l	Broker(a4)
			beq.s	NoCX
			move.l	CommBase(a4),a6
			move.l	Broker(a4),a0
			CALL	DeleteCxObjAll

NoCX			move.l	$04,a6
			tst.l	MyPort(a4)
			beq.s	NoPort
			move.l	MyPort(a4),a0
			bsr	CloseMsgPort

NoPort			move.l	IntBase(a4),d0		;Close librarys
			beq.s	ErrorX2
			move.l	d0,a1
			CALL	CloseLibrary

ErrorX2			move.l	GraphicsBase(a4),d0
			beq.s	ErrorX1
			move.l	d0,a1
			CALL	CloseLibrary

ErrorX1			move.l	IconBase(a4),d0
			beq.s	NoIconLib
			move.l	d0,a1
			CALL	CloseLibrary
			
NoIconLib		move.l	CommBase(a4),d0
			beq.s	NoCommLib
			move.l	d0,a1
			CALL	CloseLibrary

NoCommLib		move.l	GadBase(a4),d0
			beq.s	OnlyDOS
			move.l	d0,a1
			CALL	CloseLibrary

OnlyDOS			move.l	DosBase(a4),d0
			beq.s	FreeOnly
			move.l	d0,a1
			CALL	CloseLibrary

FreeOnly		move.l	ScreenPatLen(a4),d0
			beq.s	NoScreenPat
			move.l	ScreenPattern(a4),a1
			CALL	FreeMem

NoScreenPat		move.l	WindowPatLen(a4),d0
			beq.s	NoWindowPat
			move.l	WindowPattern(a4),a1
			CALL	FreeMem

NoWindowPat		move.l	WBMessage(a4),d7
			move.l	a4,a1
			move.l	#AllocLength,d0
			CALL	FreeMem			

			move.l	d7,a1
			tst.l	d7
			beq.s	EndeRaus
			CALL	Forbid
			CALL	ReplyMsg

EndeRaus		RLoad
			moveq.l	#0,d0
			rts

CloseMsgPort		move.l	a0,a3
ClosePortRout		move.l	a3,a0
			CALL	GetMsg
			tst.l	d0
			beq.s	NoMsgLeft
			move.l	d0,a1
			CALL	ReplyMsg
			bra.s	ClosePortRout
NoMsgLeft		move.l	a3,a0
			CALL	DeleteMsgPort		;and free it
			rts


			;Subroutine to print a text to stdout
PrintText		Push	d0-d4/a0-a1/a6
			move.l	a0,a1
			moveq.l	#0,d0
TestLen			tst.b	(a1)+
			beq.s	LaengeOk
			addq	#1,d0
			bra.s	TestLen
LaengeOk		move.l	$04,a6
			lea	DosName(pc),a1
			moveq.l	#0,d0
			CALL	OpenLibrary	
			move.l	d0,DosBase(a4)
			beq	SkipWrite
			move.l	d0,a6
			move.l	a0,d2
			move.l	d0,d3
			CALL	Output
			move.l	d0,d1
			beq.s	SkipWrite
			CALL	Write
SkipWrite		Pull	d0-d4/a0-a1/a6
			rts

			;MainPart: does the scrolling if necessary
			;Gets window in a0
DoYourJob		RSave
			move.l	a0,d0		;No Window - let it be!
			beq	LeaveIt
			move.l	a0,a5

			move.l	wd_WScreen(a5),a3
			
			move.l	DosBase(a4),a6

			tst.b	ScreenPatternMem(a4)
			beq.s	NoMatter2
			move.l	ScreenPattern(a4),d1
			move.l	sc_DefaultTitle(a3),d2
			CALL	MatchPatternNoCase
			beq	LeaveIt

NoMatter2		tst.b	WindowPatternMem(a4)
			beq.s	NoMatter3
			move.l	WindowPattern(a4),d1
			move.l	wd_Title(a5),d2
			CALL	MatchPatternNoCase
			beq	LeaveIt

NoMatter3		move.l	a3,a0
			move.l	a5,d0
			bsr	RememberWindow
NoInterest		move.l	a0,d0		;Screen not valid? - let it be!
			beq	LeaveIt

NoMatter		move.l	GraphicsBase(a4),a6		;Get the visible size
			lea	sc_ViewPort(a3),a0	;of the screen to
			CALL	GetVPModeID		;determine when a window
			move.l	d0,d2			;is visible and when not
			lea	DisplayInfer(a4),a1
			move.l	#dim_SIZEOF,d0
			move.l	#DTAG_DIMS,d1
			sub.l	a0,a0
			CALL	GetDisplayInfoData
			lea	DisplayInfer(a4),a0
			lea	dim_TxtOScan(a0),a0
			move.w	ra_MaxX(a0),d0
			sub.w	ra_MinX(a0),d0
			addq	#1,d0
			move.w	d0,VisualX(a4)

			move.w	ra_MaxY(a0),d0
			sub.w	ra_MinY(a0),d0
			addq	#1,d0
			move.w	d0,VisualY(a4)

			move.l	a3,a0
			move.l	IntBase(a4),a6
			tst.l	TempSFront(a4)		;do we want screentofront?
			beq.s	NoFront
			CALL	ScreenToFront
			bset	#SignalScreen,What(a4)	;ScreenChange!

NoFront			move.l	wd_Flags(a5),d0
			and.l	#WFLG_BACKDROP,d0
			bne	LeaveIt		;Not with backdrops!

			tst.l	TempWFront(a4)		;do we WindowToFront() ?
			beq.s	NoFront2
			move.l	a5,a0
			move.l	wd_Flags(a0),d0
			and.l	#WBENCHWINDOW,d0	;does not work - but why?
			bne.s	NoFront2
			CALL	WindowToFront

NoFront2		tst.l	TempMove(a4)
			beq	LeaveIt
			move.l	wd_WScreen(a5),a0	;If the screen is smaller
			move.w	sc_Width(a0),d0		;that the visible size
			cmp.w	VisualX(a4),d0		;in any way, we use the
			bcc.s	NoMat1			;original screen-size
			move.w	sc_Width(a0),VisualX(a4)
NoMat1			move.w	sc_Height(a0),d0
			cmp.w	VisualY(a4),d0
			bcc.s	NoMat2
			move.w	sc_Height(a0),VisualX(a4)
			

NoMat2			moveq.l	#0,d7
			moveq.l	#0,d6
			moveq.l	#0,d0
			moveq.l	#0,d2
			move.w	wd_LeftEdge(a5),d0
			add.w	wd_Width(a5),d0
			move.w	sc_LeftEdge(a0),d2
			neg.w	d2
			add.w	VisualX(a4),d2
			sub.w	d0,d2
			beq.s	SeemsOk2
			bpl.s	SeemsOk
			move.w	d2,d7		;MOVEX!
			ext.l	d7
SeemsOk			move.w	wd_LeftEdge(a5),d0
			move.w	sc_LeftEdge(a0),d2
			neg.w	d2
			sub.w	d2,d0
			bne.s	TestAgain
			moveq.l	#0,d7
TestAgain		bpl.s	SeemsOk2
			move.w	d0,d7		;MOVEX!	- Prefer Leftedge
			ext.l	d7
			neg.l	d7
SeemsOk2		move.w	wd_TopEdge(a5),d0
			move.w	sc_TopEdge(a0),d2
			neg.w	d2
			sub.w	d2,d0
			beq.s	SeemsOk4
			bpl.s	SeemsOk3
			move.w	d0,d6
			ext.l	d6		;MOVEY!
			neg.l	d6
SeemsOk3		move.w	wd_TopEdge(a5),d0
			add.w	wd_Height(a5),d0
			move.w	sc_TopEdge(a0),d2
			neg.w	d2
			add.w	VisualY(a4),d2
			sub.w	d0,d2
			bne.s	TestAgain2
			moveq.l	#0,d6
TestAgain2		bpl.s	SeemsOk4
			move.w	d2,d6		;MOVEY! - Prefer bottom
			ext.l	d6
SeemsOk4		tst.l	TempAlways(a4)
			bne.s	DOOO
			tst.l	d7
			bne.s	DOOO
			tst.l	d6
			beq	LeaveIt

DOOO			move.l	d7,d0
			tst.l	TempAlways(a4)
			bne.s	DoAlways1
			tst.l	d0
			beq.s	NoMoveAny1
DoAlways1		cmp.l	#2,TempHADJ(a4)
			bne.s	NoCentering1

			moveq.l	#0,d0
			move.w	wd_Width(a5),d0
			lsr.w	#1,d0
			add.w	wd_LeftEdge(a5),d0
			moveq.l	#0,d2
			move.w	VisualX(a4),d2
			lsr.w	#1,d2
			move.w	sc_LeftEdge(a0),d3
			neg.w	d3
			add.w	d3,d2
			sub.w	d0,d2
			move.l	d2,d0
			ext.l	d0
			bra	NoMoveAny1
			
NoCentering1		tst.l	TempHADJ(a4)
			bne.s	RightAdj
			moveq.l	#0,d0
			move.w	wd_LeftEdge(a5),d0
			add.w	sc_LeftEdge(a0),d0
			neg.w	d0
			ext.l	d0
			bra.s	NoMoveAny1

RightAdj		cmp.l	#1,TempHADJ(a4)
			bne.s	NoMoveAny1
			move.w	wd_LeftEdge(a5),d0
			add.w	wd_Width(a5),d0
			move.w	sc_LeftEdge(a0),d2
			neg.w	d2
			add.w	VisualX(a4),d2
			sub.w	d0,d2
			move.l	d2,d0
			ext.l	d0

NoMoveAny1		move.l	d6,d1
			tst.l	TempAlways(a4)
			bne.s	DoAlways2
			tst.l	d1
			beq.s	NoMoveAny2
DoAlways2		cmp.l	#2,TempVADJ(a4)
			bne.s	NoCentering2

			moveq.l	#0,d1
			move.w	wd_Height(a5),d1
			lsr.w	#1,d1
			add.w	wd_TopEdge(a5),d1
			moveq.l	#0,d2
			move.w	VisualY(a4),d2
			lsr.w	#1,d2
			move.w	sc_TopEdge(a0),d3
			neg.w	d3
			add.w	d3,d2
			sub.w	d1,d2
			move.l	d2,d1
			ext.l	d1
			bra	NoMoveAny2

NoCentering2		tst.l	TempVADJ(a4)
			bne.s	BotAdj
			moveq.l	#0,d1
			move.w	wd_TopEdge(a5),d1
			add.w	sc_TopEdge(a0),d1
			neg.w	d1
			ext.l	d1
			bra.s	NoMoveAny2

BotAdj			cmp.l	#1,TempVADJ(a4)
			bne.s	NoMoveAny2
			move.w	wd_TopEdge(a5),d1
			add.w	wd_Height(a5),d1
			move.w	sc_TopEdge(a0),d2
			neg.w	d2
			add.w	VisualY(a4),d2
			sub.w	d1,d2
			move.l	d2,d1
			ext.l	d1

NoMoveAny2		move.w	sc_TopEdge(a0),d5
			move.w	sc_LeftEdge(a0),d6
			RSave
			CALL	MoveScreen
			RLoad
			sub.w	sc_TopEdge(a0),d5	;Find out how far the
			sub.w	sc_LeftEdge(a0),d6	;screen really moves
			move.l	d6,d0
			move.l	d5,d1
			neg.l	d0
			neg.l	d1

			tst.l	TempMoveMouse(a4)
			beq.s	LeaveIt

			;If a window becomes active without clicking, the Mouse
			;can be out of range, and moving it would scroll the
			;Screen back, so we check this here and disable movement
			;if "dangerous"
			move.w	ib_MouseX(a6),d2
			add.w	d0,d2	;Movement in X
			bmi.s	ClearXMovement
			cmp.w	VisualX(a4),d2
			bcs.s	LeaveXMovement
ClearXMovement		moveq.l	#0,d0
LeaveXMovement		move.w	ib_MouseY(a6),d2
			add.w	d1,d2	;Movement in Y
			bmi.s	ClearYMovement
			cmp.w	VisualY(a4),d2
			bcs.s	LeaveYMoveMent
ClearYMovement		moveq.l	#0,d1
LeaveYMoveMent		bsr	SetPointer
LeaveIt			RLoad
			rts

			;ScreenID in a0
AdjustScreen		RSave
			move.l	a0,a3
			tst.b	ScreenPatternMem(a4)
			beq.s	NoMatter5
			move.l	ScreenPattern(a4),d1
			move.l	sc_DefaultTitle(a3),d2
			move.l	DosBase(a4),a6
			CALL	MatchPatternNoCase
			beq	SkipActive
			move.l	a3,a0

NoMatter5		tst.l	TempPDef(a4)	;Enter FirstScreen as Default
						;PublicScreen ?
			beq.s	Skip_NoPub
			bsr	GetPubFromID
			move.l	a0,d0
			beq.s	Skip_NoPub
			move.l	IntBase(a4),a6
			CALL	SetDefaultPubScreen

Skip_NoPub		tst.l	TempRemWin(a4)	;Activate a Window on the new
						;Screen?
			beq.s	SkipActive
			bsr	GetScreenWindow
			tst.l	d0
			bne.s	FoundActive

			move.l	sc_FirstWindow(a0),d0	;Take Firstwindow if none
			beq.s	SkipActive		;known

FoundActive		move.l	d0,a5
			tst.b	WindowPatternMem(a4)
			beq.s	NoMatter4
			move.l	WindowPattern(a4),d1
			move.l	wd_Title(a5),d2
			move.l	DosBase(a4),a6
			CALL	MatchPatternNoCase
			beq	SkipActive
NoMatter4		move.l	a5,a0
			move.l	IntBase(a4),a6
			CALL	ActivateWindow
SkipActive		RLoad
			rts

		;a0=Screen 		Back:d0=Window
GetScreenWindow		Push	a1/d1
			lea	ScreenMem(a4),a1
			move.w	#MaxScreens-1,d1
ScreenFindLoop		cmp.l	(a1),a0
			beq.s	FoundScreen
			lea	8(a1),a1
			dbf	d1,ScreenFindLoop
FoundScreen		move.l	4(a1),d0
			bsr	TestWindowOnScreen
			Pull	a1/d1
			rts

		;a0=Screen d0=Window
RememberWindow		Push	a1-a3/a6/d1
			move.l	IntBase(a4),a6
			lea	ScreenMem(a4),a1
			move.w	#MaxScreens-1,d1
ScreenFindLoop2		tst.l	(a1)
			beq.s	FoundEmpty
			move.l	(a1),a2
			cmp.l	a0,a2
			beq.s	FoundEmpty	;because Identical

			move.l	ib_FirstScreen(a6),a3
CheckAllScreens		cmp.l	a3,a2
			beq	ScreenValid
			move.l	sc_NextScreen(a3),a3
			cmp.l	#0,a3
			bne.s	CheckAllScreens
			bra.s	FoundEmpty	;because Entry is invalid

ScreenValid		lea	8(a1),a1
			dbf	d1,ScreenFindLoop2
			;Reaching this Point our List is full of valid
			;Screens - not the best thing, but we simply ignore...
			bra.s	IgnoreOver
FoundEmpty		move.l	a0,(a1)
			move.l	d0,4(a1)
IgnoreOver		Pull	a1-a3/a6/d1
			rts

		;d0=Window , a0=Screen	=Back: d0=0 no window
TestWindowOnScreen	tst.l	d0
			beq.s	NotWindow
			move.l	sc_FirstWindow(a0),a1
WindowListOn		cmp.l	d0,a1
			beq.s	WindowIsOK
			move.l	wd_NextWindow(a1),a1
			cmp.l	#0,a1
			bne.s	WindowListOn
NotWindow		clr.l	d0
			rts
WindowIsOK		move.l	a1,d0
			rts

			;ScreenID in a0	;Return a0=PubScreenName or Zero
GetPubFromID		Push	d0/a3/a6
			move.l	a0,a3
			move.l	IntBase(a4),a6
			CALL	LockPubScreenList

CarryListOn		move.l	d0,a0
			cmp.l	psn_Screen(a0),a3
			beq.s	ScreenFound
			move.l	LN_SUCC(a0),d0
			bne.s	CarryListOn
			sub.l	a0,a0
			bra.s	ENDPS

ScreenFound		move.l	LN_NAME(a0),a0
ENDPS			move.l	a0,-(sp)
			CALL	UnlockPubScreenList
			move.l	(sp)+,a0
			Pull	d0/a3/a6
			rts

Interrupt3		RSave
			move.l	RememberA4,a4
			move.l	IntBase(a4),a0
			move.l	Active(a4),d0
			cmp.l	ib_ActiveWindow(a0),d0		;New ActiveWindow?
			beq.s	DoNothing
			move.l	ib_ActiveWindow(a0),Active(a4)

			bsr	SignalMyself

			bset	#SignalWindow,What(a4)
			
DoNothing		move.l	IntBase(a4),a0
			move.l	FirstSc(a4),d0
			cmp.l	ib_FirstScreen(a0),d0		;New FirstScreen?
			beq.s	DoNothing2
			move.l	ib_FirstScreen(a0),FirstSc(a4)

			bsr	SignalMyself

			bset	#SignalScreen,What(a4)

DoNothing2		RLoad
			moveq.l	#0,d0
			rts

SignalMyself		move.l  $04,a6
			move.l  OwnTask(a4),a1
			move.l  Signal(a4),d1		;send a signal to move Screen
			moveq.l	#0,d0
			bset	d1,d0
			CALL	Signal
			rts

OpenGUI			RSave
			tst.w	GUIOpened(a4)
			bne	OpenNoGUI
			move.l	IntBase(a4),a6
			sub.l	a0,a0
			CALL	LockPubScreen
			move.l	d0,PublicScreen(a4)
			move.l	d0,StorePublicScreen

			move.l	d0,a0
			lea	sc_RastPort(a0),a1
			move.l	a1,PublicRastport(a4)
			lea	TagListDone(pc),a1
			move.l	GadBase(a4),a6
			CALL	GetVisualInfoA
			move.l	d0,MyVisual(a4)
			lea	MyNewGadget(a4),a3
			move.l	d0,gng_VisualInfo(a3)

			lea	GadgetList(a4),a0
			CALL	CreateContext
			move.l	d0,Gadget0(a4)

			move.l	GraphicsBase(a4),a6
			move.l	PublicRastport(a4),a1
			lea	GUI_Text5(pc),a0
			moveq.l	#GUI_Text6-GUI_Text5-1,d0
			CALL	TextLength
			add.w	#40,d0		;CheckBox
			lsr.w	#1,d0
			move.w	d0,RemLen(a4)

			moveq.l	#1,d0
			add.w	RemLen(a4),d0
			lsl.l	#2,d0
			move.l	d0,StoreInnerWidth

			move.l	PublicScreen(a4),a0
			moveq.l	#6,d0
			add.b	sc_WBorLeft(a0),d0
			move.w	d0,RemLeft(a4)

			move.l	sc_Font(a0),a1
			move.l	a1,gng_TextAttr(a3)
			moveq.l	#1,d0
			add.b	sc_WBorTop(a0),d0	;Base (Top)
			move.w	d0,RemTop(a4)

			move.w	ta_YSize(a1),d6
			add.w	#4,d6			;Height of One Line
			move.w	d6,RemHeight(a4)

			add.w	#2,d6
			mulu	#9,d6
			add.w	#8,d6
			move.l	d6,StoreInnerHeight

			move.l	Gadget0(a4),d7

			bsr	DoAllGadgets

			move.l	d7,LastGadget(a4)

			sub.l	a0,a0
			lea	WindowTagList(pc),a1
			move.l	IntBase(a4),a6
			CALL	OpenWindowTagList
			move.l	d0,MyWindow(a4)
			beq	FailWindow

			move.l	d0,a0
			bsr	EnterSignal
			;move.l	d0,a0
			move.l	GadgetList(a4),a1
			moveq.l	#-1,d0
			moveq.l	#-1,d1
			sub.l	a2,a2
			CALL	AddGList

			move.l	GadgetList(a4),a0
			move.l	MyWindow(a4),a1
			moveq.l	#-1,d0
			sub.l	a2,a2
			CALL	RefreshGList
			
			move.l	GadBase(a4),a6
			move.l	MyWindow(a4),a0
			sub.l	a1,a1
			CALL	GT_RefreshWindow

			move.w	#1,GUIOpened(a4)
			RLoad
			rts
OpenNoGUI		move.l	IntBase(a4),a6
			move.l	MyWindow(a4),a0
			CALL	ActivateWindow
			RLoad
			rts

			rsreset
MyGadgetFlags		rs.l	1
MyGadgetText		rs.l	1
MyGadgetKind		rs.l	1
MyGadgetList		rs.l	1
MyGadgetRowNr		rs.w	1
MyGadgetXPos		rs.w	1
MyGadgetWidth		rs.w	1
MyGadgetStore		rs.w	1
MyGadgetSize		rs.w	1
			
			;	gng_Flags      ,gng_Text ,CreateKind   ,CreateTags
			;	gng_TopEdge    ,gng_LeftEdge
AllGadgets		dc.l	PLACETEXT_LEFT,GUI_Text8,CYCLE_KIND,CycleTagList
			dc.w	1,2,2,TempHADJ
			dc.l	PLACETEXT_LEFT,GUI_Text9,CYCLE_KIND,CycleTagList2
			dc.w	2,2,2,TempVADJ
			dc.l	PLACETEXT_LEFT,GUI_Text12,STRING_KIND,StringTagList
			dc.w	3,2,2,TempScreen
			dc.l	PLACETEXT_LEFT,GUI_Text13,STRING_KIND,StringTagList
			dc.w	4,2,2,TempWindow

			dc.l	PLACETEXT_RIGHT,GUI_Text1,CHECKBOX_KIND,GadgetTagList
			dc.w	5,0,2,TempMove
			dc.l	PLACETEXT_RIGHT,GUI_Text2,CHECKBOX_KIND,GadgetTagList
			dc.w	5,2,2,TempSFront
			dc.l	PLACETEXT_RIGHT,GUI_Text3,CHECKBOX_KIND,GadgetTagList
			dc.w	6,0,2,TempWFront
			dc.l	PLACETEXT_RIGHT,GUI_Text5,CHECKBOX_KIND,GadgetTagList
			dc.w	6,2,2,TempPDef
			dc.l	PLACETEXT_RIGHT,GUI_Text6,CHECKBOX_KIND,GadgetTagList
			dc.w	7,0,2,TempAlways
			dc.l	PLACETEXT_RIGHT,GUI_Text7,CHECKBOX_KIND,GadgetTagList
			dc.w	7,2,2,TempRemWin
			dc.l	PLACETEXT_RIGHT,GUI_Text7_1,CHECKBOX_KIND,GadgetTagList
			dc.w	8,0,2,TempMoveMouse
			dc.l	PLACETEXT_RIGHT,GUI_Text7_2,CHECKBOX_KIND,GadgetTagList
			dc.w	8,2,2,TempCXPOPUP
			

			dc.l	PLACETEXT_IN,GUI_Text10,BUTTON_KIND,TagList
			dc.w	9,0,1,TempZero
			dc.l	PLACETEXT_IN,GUI_Text11,BUTTON_KIND,TagList
			dc.w	9,3,1,TempZero
SaveGadgData		dc.l	PLACETEXT_IN,GUI_Text14,BUTTON_KIND,TagList
			dc.w	9,1,1,TempSave
			dc.l	PLACETEXT_IN,GUI_Text15,BUTTON_KIND,TagList
			dc.w	9,2,1,TempZero


			dc.l	-1



;a3:Pointer to the GadgetStructure
;d7:Previous Gadget

DoAllGadgets		lea	AllGadgets(pc),a5
			move.l	GadBase(a4),a6
			moveq.l	#1,d6

DoAllGadgets2		tst.l	(a5)
			bmi.s	WasLastGadget

			move.w	MyGadgetRowNr(a5),d0
			move.w	RemHeight(a4),d1
			addq.w	#2,d1
			mulu	d1,d0
			add.w	RemTop(a4),d0	;Top
			move.w	d0,gng_TopEdge(a3)

			move.w	MyGadgetXPos(a5),d0
			mulu	RemLen(a4),d0
			add.w	RemLeft(a4),d0
			move.w	d0,gng_LeftEdge(a3)

			move.w	MyGadgetWidth(a5),d0
			mulu	RemLen(a4),d0
			sub.w	#8,d0
			move.w	d0,gng_Width(a3)

			move.w	RemHeight(a4),gng_Height(a3)

			move.l	MyGadgetFlags(a5),gng_Flags(a3)
			add.w	#1,gng_GadgetID(a3)

			move.l	MyGadgetText(a5),gng_GadgetText(a3)

			move.w	d6,gng_GadgetID(a3)

			sub.l	a2,a2
			move.w	MyGadgetStore(a5),a2
			add.l	a4,a2
			move.l	(a2),d4

			move.l	MyGadgetKind(a5),d0
			move.l	d7,a0		;Previous Gadget
			move.l	a3,a1
			move.l	MyGadgetList(a5),a2
			move.l	d4,4(a2)
			CALL	CreateGadgetA
			move.l	d0,d7		;Remember Previous Gadget
			add.l	#MyGadgetSize,a5
			addq.l	#1,d6
			bra.s	DoAllGadgets2
WasLastGadget		rts

CheckGUI		RSave

			tst.w	GUIOpened(a4)
			beq	NoGUI

			move.l	GadBase(a4),a6
			move.l	MyWindow(a4),a0
			move.l  wd_UserPort(a0),a0
			CALL	GT_GetIMsg
			tst.l   d0         
			beq     NoGUI
			move.l  d0,a1
			moveq.l	#0,d6
			move.w	im_Code(a1),d6	;Value of Gadget
			move.l  im_IAddress(a1),a2

			move.l	im_Class(a1),d7
			CALL	GT_ReplyIMsg

			cmp.l	#GADGETUP,d7
			bne.s	Others

			move.w	gg_GadgetID(a2),d0
			move.l	gg_SpecialInfo(a2),a3
			cmp.w	#13,d0
			beq	HideGad
			cmp.w	#14,d0
			beq	QuitGad
			cmp.w	#15,d0
			beq	SaveGad
			cmp.w	#16,d0
			beq	AboutGad

			subq.l	#1,d0

			lea	AllGadgets(pc),a5
			mulu	#MyGadgetSize,d0
			sub.l	a2,a2
			move.w	MyGadgetStore(a5,d0.w),a2
			add.l	a4,a2

			cmp.l	#STRING_KIND,MyGadgetKind(a5,d0.w)
			bne.s	StandardGUI
			move.l	si_Buffer(a3),a0
			move.l	(a2),a1
			bsr	CopyPattern
			bsr	BuildPatterns
			bra.s	NoGUI

StandardGUI		move.l	d6,(a2)
			bra.s	NoGUI

SaveGad			bsr	SaveConfig
			bra.s	NoGUI

AboutGad		lea	AboutText(pc),a0
			bsr	OpenRequester
			bra.s	NoGUI

QuitGad			bsr	CloseGUI
			move.w	#1,QuitMe(a4)
			bra.s	HideGad

Others	                cmp.l   #CLOSEWINDOW,d7
	                bne.s	NoGUI
HideGad			bsr	CloseGUI
NoGUI			RLoad
			rts

CloseGUI		RSave
			tst.w	GUIOpened(a4)
			beq.s	NotOpened
			move.l	IntBase(a4),a6
			move.l	MyWindow(a4),a0
			bsr	RemoveSignal
			;move.l	MyWindow(a4),a0
			move.l	GadgetList(a4),a1
			moveq.l	#-1,d0
			CALL	RemoveGList

			move.l	MyWindow(a4),a0
			clr.l	d0
			move.w	wd_TopEdge(a0),d0
			move.l	d0,RemWindowY
			move.w	wd_LeftEdge(a0),d0
			move.l	d0,RemWindowX
			CALL	CloseWindow
			
FailWindow		move.l	GadgetList(a4),a0
			move.l	GadBase(a4),a6
			CALL	FreeGadgets

			move.l	MyVisual(a4),a0
			CALL	FreeVisualInfo

			move.l	IntBase(a4),a6
			sub.l	a0,a0
			move.l	PublicScreen(a4),a1
			CALL	UnlockPubScreen

NotOpened		clr.w	GUIOpened(a4)

			RLoad
			rts

EnterSignal		Push    d0-d1/a0          
			move.l  wd_UserPort(a0),a0
			move.b  MP_SIGBIT(a0),d0  
			move.l	SignalMask(a4),d1
			bset	d0,d1             
			move.l  d1,SignalMask(a4) 
			Pull    d0-d1/a0          
			rts                       
                                          
RemoveSignal		Push    d0-d1/a0          
			move.l  wd_UserPort(a0),a0
			move.b  MP_SIGBIT(a0),d0
			move.l	SignalMask(a4),d1
			bclr	d0,d1             
			move.l	d1,SignalMask(a4) 
			Pull    d0-d1/a0          
			rts

GetNexta0		move.b	(a0)+,d0
			cmp.b	#"=",d0
			beq.s	GetNexta0
			cmp.b	#" ",d0
			beq.s	GetNexta0
			or.w	#$20,d0
			rts

;Screen in a0, X-Coord(rel) in d0, Y-Coord(rel) in d1
SetPointer		Push	a0-a2/d0-d1/a6
			lea	PointerPixEvent(a4),a2
			move.l	a0,iepp_Screen(a2)
			move.w	d0,iepp_PositionX(a2)
			move.w	d1,iepp_PositionY(a2)

			move.l	MyIORequest(a4),a1
			move.w	#IND_WRITEEVENT,io_Command(a1)
			lea	MyInputEvent(a4),a0
			move.l	#0,ie_NextEvent(a0)
			move.b	#IECLASS_NEWPOINTERPOS,ie_Class(a0)
			move.b	#IESUBCLASS_PIXEL,ie_SubClass(a0)
			move.w	#IECODE_NOBUTTON,ie_Code(a0)
			move.w	#IEQUALIFIER_RELATIVEMOUSE,ie_Qualifier(a0)
			move.l	a2,ie_EventAddress(a0)
			move.l	a0,io_Data(a1)
			move.l	#ie_SIZEOF,io_Length(a1)
			move.l	$04,a6
			CALL	DoIO
			Pull	a0-a2/a6/d0-d1
			rts

BuildPatterns		RSave
			tst.l	TempScreen(a4)
			beq.s	NoScreenPattern
			move.l	TempScreen(a4),a0
			lea	ScreenPatternMem(a4),a1
			bsr	CopyPattern

			lea	ScreenPatternMem(a4),a0
			lea	ScreenPatLen(a4),a2
			lea	ScreenPattern(a4),a3
			bsr	GetLen
			bpl	NoScreenPattern
			bsr	PatternError

NoScreenPattern		lea	ScreenPatternMem(a4),a0
			move.l	a0,TempScreen(a4)
			tst.l	TempWindow(a4)
			beq.s	NoWindowPattern
			move.l	TempWindow(a4),a0
			lea	WindowPatternMem(a4),a1
			bsr	CopyPattern

			lea	WindowPatternMem(a4),a0
			lea	WindowPatLen(a4),a2
			lea	WindowPattern(a4),a3
			bsr	GetLen
			bpl.s	NoWindowPattern
			bsr	PatternError
	
NoWindowPattern		lea	WindowPatternMem(a4),a0
			move.l	a0,TempWindow(a4)
			RLoad
			rts		

PatternError		lea	Text3(pc),a0
			bra	OpenRequester

CopyPattern		move.w	#511,d0
DoCopy			move.b	(a0)+,(a1)+
			beq.s	EndCopy
			dbf	d0,DoCopy
			bsr	PatternError
EndCopy			rts


;In: (a2): LEN - (a3): MEMORY - a0: Source-Pattern	:back: d0=pattern ok?
GetLen			move.l	a0,d6
			clr.l	d3
GetLen2			tst.b	(a0)+
			beq.s	EndOfString
			addq.l	#1,d3
			bra.s	GetLen2
EndOfString		lsl.w	#1,d3	;StandardLen Of Pattern
			addq	#2,d3
			move.l	$04,a6
			tst.l	(a3)
			beq	AllocNew
			move.l	(a3),a1
			move.l	(a2),d0
			CALL	FreeMem
			clr.l	(a3)
AllocNew		move.l	d3,(a2)
			move.l	d3,d0
			move.l	#MEMF_CLEAR,d1
			CALL	AllocMem
			move.l	d0,d2
			beq	QuitPrg		;No Memory? Good bye !
			move.l	d0,(a3)
			move.l	d6,d1
			move.l	DosBase(a4),a6
			CALL	ParsePatternNoCase
			rts

			
;a0: Requester-Text
OpenRequester		Push	a0-a3
			lea	EasyReqStruct(a4),a1
			lea	PortName(pc),a2
			move.l	a2,es_Title(a1)
			move.l	a0,es_TextFormat(a1)
			lea	GadgetText(pc),a2
			move.l	a2,es_GadgetFormat(a1)
			move.l	IntBase(a4),a6
			sub.l	a0,a0
			;a1: EasyReq
			sub.l	a2,a2
			sub.l	a3,a3
			CALL	EasyRequestArgs
			Pull	a0-a3
			rts

SaveConfig		RSave
			tst.l	WBMessage(a4)
			beq	SkipConfig
			move.l	WBMessage(a4),a3
			move.l	sm_ArgList(a3),d0
			beq	SkipConfig
			move.l	d0,a0

			move.l	IconBase(a4),a6
			move.l	wa_Name(a0),a0
			move.l	a0,d5
			CALL	GetDiskObject
			move.l	d0,DObject(a4)
			beq	SkipConfig

			move.l	d0,a0
			move.l	do_ToolTypes(a0),a5	;Remember Old
			move.l	#1,TempDummy(a4)

			Push	a0/a6
			move.l	$04,a6
			move.l	#NumberOfTemps*10+2*512+2*8,d0	;Memory for tool arrays
			move.l	#MEMF_CLEAR,d1
			CALL	AllocMem
			move.l	d0,a3
			beq	MemErrTool
			move.l	DObject(a4),a0
			move.l	d0,do_ToolTypes(a0)

			move.l	d0,a1
			add.l	#(NumberOfTemps+1)*4,a1	;Maximum Number of Pointers

			clr.l	d7
			lea	WBTemplate(pc),a2
LoopAllTemps		sub.l	a0,a0
			move.w	TemplateA4(a2),a0
			add.l	a4,a0
			move.l	(a0),d6
			beq.s	IsDefault
			move.l	a1,(a3,d7)
			move.l	TemplateText(a2),a0
			bsr	CopyPattern
			move.w	TemplateType(a2),d1
			beq	ThatsAllTemp
			move.b	#"=",-1(a1)
			
			cmp.w	#T_CYCLE,d1
			bne.s	ThatsString
			move.l	TemplateSpecial(a2),a0
			lsl.l	#2,d6
			move.l	(a0,d6.w),a0
			bsr	CopyPattern
			bra.s	ThatsAllTemp

ThatsString		move.l	d6,a0
			bsr	CopyPattern

ThatsAllTemp		addq.l	#4,d7
			move.l	a1,d0
			and.l	#$ffffffc,d0
			move.l	d0,a1
			lea	4(a1),a1	;Align on Longwords
IsDefault		add.l	#TemplateSize,a2
			tst.l	TemplateText(a2)
			bne	LoopAllTemps

			move.l	d5,a0
			move.l	DObject(a4),a1
			move.l	IconBase(a4),a6
			CALL	PutDiskObject
			bne.s	Done
			lea	Text4(pc),a0
			bsr	OpenRequester

Done			move.l	$04,a6
			move.l	#NumberOfTemps*10+2*512+2*8,d0
			move.l	a3,a1
			CALL	FreeMem
MemErrTool		Pull	a0/a6

			move.l	a5,do_ToolTypes(a0)
			move.l	DObject(a4),a0
			CALL	FreeDiskObject
				
			bra.s	DoneConfig

SkipConfig		lea	Text4(pc),a0
			bsr	OpenRequester
DoneConfig		RLoad
			rts


		;GetDiskObject(Name)


StringTagList		dc.l	GTST_String
			dc.l	0
			dc.l	GTST_MaxChars
			dc.l	511
			dc.l	TAG_DONE

CycleTagList		dc.l	GTCY_Active
			dc.l	0
			dc.l	GTCY_Labels
			dc.l	CycleList
			dc.l	TAG_DONE

CycleTagList2		dc.l	GTCY_Active
			dc.l	0
			dc.l	GTCY_Labels
			dc.l	CycleList2
			dc.l	TAG_DONE

GadgetTagList		dc.l	GTCB_Checked
			dc.l	0
			dc.l	TAG_DONE

TagList			dc.l	GA_Disabled
			dc.l	0
TagListDone		dc.l	TAG_DONE

WindowTagList		dc.l	WA_InnerWidth
StoreInnerWidth			dc.l	0
			dc.l	WA_InnerHeight
StoreInnerHeight		dc.l	0
			dc.l	WA_IDCMP
				dc.l	BUTTONIDCMP!CLOSEWINDOW
			dc.l	WA_Flags
				dc.l	WINDOWCLOSE!WINDOWDRAG!WINDOWDEPTH!ACTIVATE	
			dc.l	WA_PubScreen
StorePublicScreen		dc.l	0
			dc.l	WA_Title
				dc.l	Texth
			dc.l	WA_AutoAdjust
				dc.l	1
			dc.l	WA_Left
RemWindowX			dc.l	-1
			dc.l	WA_Top
RemWindowY			dc.l	-1
			dc.l	TAG_DONE
RememberA4		dc.l	0
RememberStack		dc.l	0

			rsreset

DisplayInfer		rs.b	dim_SIZEOF
ScreenPatLen		rs.l	1
ScreenPattern		rs.l	1
WindowPatLen		rs.l	1
WindowPattern		rs.l	1
GadgetList		rs.l	1
What			rs.w	1
DisableHW		rs.w	1
GUIOpened		rs.w	1
QuitMe			rs.w	1
RemFontSize		rs.w	1
GadgetInside		rs.w	11
MyPort			rs.l	1
MyVisual		rs.l	1
Broker			rs.l	1
ScreenMem		rs.b	ScreenMemSize
IntBase			rs.l	1
RemLen			rs.w	1
RemHeight		rs.w	1
RemTop			rs.w	1
RemLeft			rs.w	1

GadBase			rs.l	1
DosBase			rs.l	1
CommBase		rs.l	1
IconBase		rs.l	1
DObject			rs.l	1
Active			rs.l	1
FirstSc			rs.l	1
GraphicsBase		rs.l	1
PublicScreen		rs.l	1
PublicRastport		rs.l	1
Gadget0			rs.l	1
VisualX			rs.w	1
VisualY			rs.w	1
TemplateArray		rs.l	0	;Do not change order!
TempMove		rs.l	1
TempSFront		rs.l	1
TempWFront		rs.l	1
TempPDef		rs.l	1
TempAlways		rs.l	1
TempRemWin		rs.l	1
TempMoveMouse		rs.l	1
TempCXPOPUP		rs.l	1
TempHADJ		rs.l	1
TempVADJ		rs.l	1
TempScreen		rs.l	1
TempWindow		rs.l	1
TempDummy		rs.l	1
TempZero		rs.l	1
TempSave		rs.l	1

OwnTask			rs.l	1
Signal			rs.l	1
Args			rs.l	1
WBMessage		rs.l	1
SignalMask		rs.l	1
MyWindow		rs.l	1
LastGadget		rs.l	1
MyIORequest		rs.l	1
MouseMsgPort		rs.l	1
MyNewGadget		rs.b	gng_SIZEOF
MyInterrupt		rs.b	IS_SIZE
MyInputEvent		rs.b	ie_SIZEOF
PointerPixEvent		rs.b	IEPointerPixel_SIZEOF
EasyReqStruct		rs.b	es_SIZEOF
ScreenPatternMem	rs.b	512	;sufficient I think
WindowPatternMem	rs.b	512
AllocLength		rs.w	1

intuition		dc.b	"intuition.library",0
DosName			dc.b	"dos.library",0
InputName		dc.b	"input.device",0
GraphicsName		dc.b	"graphics.library",0
IconName		dc.b	"icon.library",0
GadName			dc.b	"gadtools.library",0
CommName		dc.b	"commodities.library",0
			even

MyNewBroker		dc.b	NB_VERSION	;Version
			dc.b	0		;Reserve1
			dc.l	HandlerName	;Name
			dc.l	PortName	;Title
			dc.l	DescText	;Description
			dc.w	NBU_NOTIFY!NBU_UNIQUE		;Unique
			dc.w	COF_SHOW_HIDE	;Flags
			dc.b	0		;Pri
			dc.b	0		;Reserve2
BrokerPort		dc.l	0		;Port
			dc.w	0		;ReservedChannel

CycleList	dc.l	GUI_Choose1.1,GUI_Choose1.2,GUI_Choose1.3,GUI_Choose1.4,0
CycleList2	dc.l	GUI_Choose2.1,GUI_Choose2.2,GUI_Choose2.3,GUI_Choose2.4,0

		rsreset
TemplateText	rs.l	1
TemplateSpecial	rs.l	1
TemplateA4	rs.w	1
TemplateType	rs.w	1
TemplateSize	rs.w	0

T_CHECK		=	0
T_CYCLE		=	1
T_STRING	=	2

NumberOfTemps	=	12

WBTemplate	dc.l	TextDNW,0
		dc.w	TempDummy,T_CHECK

		dc.l	TextMove,0
		dc.w	TempMove,T_CHECK

		dc.l	TextSFront,0
		dc.w	TempSFront,T_CHECK

		dc.l	TextWFront,0
		dc.w	TempWFront,T_CHECK

		dc.l	TextPDef,0
		dc.w	TempPDef,T_CHECK

		dc.l	TextAlways,0
		dc.w	TempAlways,T_CHECK

		dc.l	TextRemWin,0
		dc.w	TempRemWin,T_CHECK

		dc.l	TextMoveMouse,0
		dc.w	TempMoveMouse,T_CHECK

		dc.l	TextCXPOPUP,0
		dc.w	TempCXPOPUP,T_CHECK

		dc.l	TextScreen,0
		dc.w	TempScreen,T_STRING

		dc.l	TextWindow,0
		dc.w	TempWindow,T_STRING

		dc.l	TextHADJ,CycleList
		dc.w	TempHADJ,T_CYCLE

		dc.l	TextVADJ,CycleList2
		dc.w	TempVADJ,T_CYCLE

		dc.l	0


TextDNW		dc.b	"DONOTWAIT",0
TextMove	dc.b	"MOVE",0
TextSFront	dc.b	"SFRONT",0
TextWFront	dc.b	"WFRONT",0
TextPDef	dc.b	"DEFPUB",0
TextAlways	dc.b	"ALWAYS",0
TextCXPOPUP	dc.b	"CX_POPUP",0
TextRemWin	dc.b	"REMWIN",0
TextMoveMouse	dc.b	"MOVEMOUSE",0
TextHADJ	dc.b	"HADJ",0
TextVADJ	dc.b	"VADJ",0
TextScreen	dc.b	"SCREEN",0
TextWindow	dc.b	"WINDOW",0
Template	dc.b	"MOVE/S,SFRONT/S,WFRONT/S,DEFPUB/S,ALWAYS/S,REMWIN/S,MOVEMOUSE/S,CX_POPUP/S,HADJ/K,VADJ/K,SCREEN/K,WINDOW/K",0
PortName	dc.b	"Huntwindows 2.4",0
HandlerName	dc.b	"Huntwindows",0
GadgetText	dc.b	"Ok",0
AboutText	dc.b	"© by Jörg Bublath 1992-1993",$0a,"EMAIL:",$0a,"bublath@forwiss.uni-passau.de",0
Text1		dc.b	"Error in arguments or libraries!",$0a,0
Text2		dc.b	"I need V36+ !",$0a,0
Text3		dc.b	"Error in given patterns!",$0a,0
Text4		dc.b	"Cannot Save!",$0a,0
		dc.b	"$VER: "	;for version information
Texth		dc.b	"Huntwindows 2.4 (31.3.93) by Jörg Bublath",0
DescText	dc.b	"Moves screen to show windows",0
GUI_Text1	dc.b	"Move Screen",0
GUI_Text2	dc.b	"ScreenToFront",0
GUI_Text3	dc.b	"WindowToFront",0
GUI_Text5	dc.b	"Set Default PubScreen",0
GUI_Text6	dc.b	"Always",0
GUI_Text7	dc.b	"Remember Window",0
GUI_Text7_1	dc.b	"Move Mouse",0
GUI_Text7_2	dc.b	"GUI Popup",0
GUI_Text8	dc.b	"Horizontal Adjustment",0
GUI_Text9	dc.b	"Vertical Adjustment",0
GUI_Text10	dc.b	"Hide",0
GUI_Text11	dc.b	"Quit",0
GUI_Text12	dc.b	"Screen Pattern",0
GUI_Text13	dc.b	"Window Pattern",0
GUI_Text14	dc.b	"Save",0
GUI_Text15	dc.b	"About",0
GUI_TextEnd	;
GUI_Choose1.1	dc.b	"left",0
GUI_Choose1.2	dc.b	"right",0
GUI_Choose1.3	dc.b	"center",0
GUI_Choose1.4	dc.b	"off",0
GUI_Choose2.1	dc.b	"top",0
GUI_Choose2.2	dc.b	"bottom",0
GUI_Choose2.3	dc.b	"center",0
GUI_Choose2.4	dc.b	"off",0
		even
