

* This file is for the InfoReq that's put up whenever the
* program is to give User some information. As well as the
* InfoReq structure, there's the routines to access text &
* link them into the IntuiTexts linked to the requester.


InfoReq:
	dc.l	NULL
	dc.w	0,20
	dc.w	320,160
	dc.w	0,0
	dc.l	NULL		;gadget ptr
	dc.l	IFB		;Border ptr
	dc.l	IRT_1		;text ptr
	dc.w	NOISYREQ		;Allow mouse button sensing!
	dc.b	4,1
	dc.l	NULL
	dcb.b	32,0
	dc.l	NULL
	dc.l	NULL
	dcb.b	36,0


* Border


IFB:
	dc.w	0,0
	dc.b	1,0,RP_JAM1
	dc.b	5
	dc.l	IFBList
	dc.l	NULL

IFBList:
	dc.w	0,0
	dc.w	319,0
	dc.w	319,159
	dc.w	0,159
	dc.w	0,0


* InfoTexts IntuiText structures.


IRT_1:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL		;font ptr
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_ 16(An)

;IRT_2:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_3:
	dc.b	8,0,RP_JAM1,0
	dc.w	1,1
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_

;IRT_4:
	dc.b	1,0,RP_JAM1,0
	dc.w	0,0
	dc.l	NULL
	dc.l	NULL		;text pointer 12(An)
	dc.l	NULL		;ptr to next IRT_


* LinkInfoText(a6)
* a6 = ptr to main program variables

* Link texts described by the irt_ arguments
* into the InfoReq IntuiTexts. This to be done
* ALWAYS before popping up the requester.

* NOTE : each text is popped into TWO consecutive IntuiTexts.
* The first is the brown background text, the second is the
* main white text (using the colours in the CrossWord.s main
* colour map). This assumes that there is always an even no.
* of ITexts. At the moment there are 20 of them. Colour and
* jam mode info is fixed for now.


* d0-d4/a0-a2 corrupt


LinkInfoText	move.l	irt_itext(a6),a0		;ptr to InfoReq ITexts

		move.l	irt_tlist(a6),a1		;ptr to my text list

		move.w	irt_count(a6),d0		;no. to insert

LITxt_1		move.w	(a1)+,d1			;get position info
		move.w	(a1)+,d2			;from my text list

		move.w	d1,d3			;copy positions
		move.w	d2,d4

		addq.w	#1,d3			;first position is
		addq.w	#1,d4			;displaced slightly

		move.l	a1,12(a0)		;insert text ptr

		move.w	d3,4(a0)			;pop in position
		move.w	d4,6(a0)			;info

		lea	20(a0),a2		;ptr to next IText
		move.l	a2,16(a0)		;and connect them up

		move.l	a2,a0			;point to next IText

		move.l	a1,12(a0)		;insert text ptr

		move.w	d1,4(a0)			;pop in position
		move.w	d2,6(a0)			;info

		lea	20(a0),a2		;ptr to next IText
		move.l	a2,16(a0)		;and connect them up

LITxt_3		tst.b	(a1)+			;scan until next
		bne.s	LITxt_3			;text reached

		move.l	a1,d1			;check for true
		and.b	#1,d1			;even alignment
		beq.s	LITxt_4			;after text scan

		addq.l	#1,a1			;here ensure even!

LITxt_4		subq.w	#1,d0			;done them all?
		beq.s	LITxt_2			;skip if so

		move.l	a2,a0			;point to next
		bra.s	LITxt_1

LITxt_2		clr.l	16(a0)			;signal last IText

		rts


* ShowInfoReq(a6)
* a6 = ptr to main program variables

* Display the InfoRequester until any mouse button pressed.
* This requester needs to be a NOISYREQ requester to allow
* mouse button sensing.

* d0-d1/a0-a1 corrupt


ShowInfoReq	move.l	mw_handle(a6),a0	;kill off IDCMPs for now

		moveq	#MOUSEBUTTONS+MOUSEMOVE,d0	;except these

		CALLINT	ModifyIDCMP

		lea	InfoReq(pc),a0
		move.l	mw_handle(a6),a1

		CALLINT	Request		;pop up requester

		bset	#0,applic_flag2(a6)

SIR_L1		move.l	mw_userport(a6),a0
		lea	ehb_info(pc),a5
		bsr	DoEvent

		btst	#0,applic_flag2(a6)	;finished?
		bne.s	SIR_L1

		lea	InfoReq(pc),a0
		move.l	mw_handle(a6),a1

		CALLINT	EndRequest	;kill the requester

		move.l	mw_handle(a6),a0
		move.l	mw_IDCMP(a6),d0

		CALLINT	ModifyIDCMP	;& recover old IDCMP

		rts


* ShowDiscInfo(a6)
* a6 = ptr to main program variables

* Alternative InfoReq using a window for the Disc Access Panel.
* Used because standard one hiccups.

* Call with the correct irt_ variables preset!

* d0-d1/a0-a1 corrupt


ShowDiscInfo	lea	DiscWindow3(pc),a0
		move.l	ms_handle(a6),d0
		move.l	d0,30(a0)
		CALLINT	OpenWindow
		move.l	d0,dp_window3(a6)		;got window?
		beq	SDI_B1			;skip if not

		move.l	d0,a0
		move.l	UserPort(a0),di_userport(a6)
		move.l	RastPort(a0),a1
		move.l	a1,di_rastport(a6)	;now set green
		moveq	#4,d0			;background
		CALLGRAF	SetRast

		bsr	LinkInfoText		;pop in info text

		move.l	di_rastport(a6),a0
		lea	IFB(pc),a1
		moveq	#0,d0
		move.l	d0,d1

		CALLINT	DrawBorder		;draw the border

		move.l	irt_itext(a6),a1
		move.l	di_rastport(a6),a0
		moveq	#0,d0
		move.l	d0,d1

		CALLINT	PrintIText		;print the text

		bset	#0,applic_flag2(a6)
		bset	#2,applic_flag2(a6)	;set holding flag

SDI_L1		move.l	di_userport(a6),a0
		lea	ehb_info(pc),a5
		bsr	DoEvent

		btst	#0,applic_flag2(a6)	;finished?
		bne.s	SDI_L1			;back if not

		move.l	dp_window3(a6),a0		;get rid of the
		CALLINT	CloseWindow		;window

SDI_B1		bra	ShowDir

		rts


* ExitInfo(a6)
* a6 = ptr to main program variables
* signal exiting the InfoRequester

* If holding required, caller must set bit 2
* of applic_flag2 prior to entry.

* d0 corrupt

ExitInfo		move.w	menu_id(a6),d0		;check for button
		cmp.w	#SELECTUP,d0		;released &
		beq.s	EIF_1			;skip if so
		cmp.w	#MENUUP,d0
		beq.s	EIF_1

		bclr	#2,applic_flag2(a6)	;clear hold flag

		rts

EIF_1		bclr	#2,applic_flag2(a6)	;holding?
;		btst	#2,applic_flag2(a6)	;holding?
		bne.s	EIF_2

		bclr	#0,applic_flag2(a6)
EIF_2		rts


* Following routines to do with HELP function.


* ToggleHelp(a6)
* a6 = ptr to main program variables
* Turn HELP function on or off according to each
* press of the HELP key.

* d0-d2/a0-a2 corrupt


ToggleHelp	lea	IRT_1(pc),a0

		bchg	#1,applic_flag2(a6)	;toggle help flag
		bne.s	THelp_1			;was on, now off.

		lea	Help_On(pc),a1
		moveq	#7,d0
		bra.s	THelp_2

THelp_1		lea	Help_Off(pc),a1
		moveq	#3,d0

THelp_2		move.l	a0,irt_itext(a6)
		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		btst	#1,applic_flag2(a6)	;HELP now on?
		beq.s	THelp_Done

		lea	IRT_1(pc),a0
		lea	Help_On2(pc),a1
		moveq	#8,d0

		move.l	a0,irt_itext(a6)
		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

THelp_Done	rts


* HandleKey(a6)
* a6 = ptr to main program variables
* Handle RAWKEY events. Copies IntuiMessage
* data to an InputEvent structure for use by
* RawKeyConvert() if the key isn't one of our
* special keys.

* d0-d2/a0-a2 corrupt


HandleKey	nop

		move.w	menu_id(a6),d0	;get key press
		cmp.w	#$5F,d0		;HELP key?
		bne.s	HKey_B1		;skip if not

		bra	ToggleHelp	;else set Help Mode

		rts

HKey_B1		lea	IRT_1(pc),a0
		move.l	a0,irt_itext(a6)

		cmp.w	#$50,d0		;F1 key?
		bne.s	HKey_B2

		lea	HelpF1_1(pc),a1
		moveq	#7,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF1_2(pc),a1
		moveq	#6,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		rts


HKey_B2		cmp.w	#$51,d0		;F2 key?
		bne.s	HKey_B3

		lea	HelpF2_1(pc),a1
		moveq	#8,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF2_2(pc),a1
		moveq	#8,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF2_3(pc),a1
		moveq	#6,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF2_4(pc),a1
		moveq	#4,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		rts

HKey_B3		cmp.w	#$52,d0		;F3 key?
		bne.s	HKey_B4

		lea	HelpF3_1(pc),a1
		moveq	#6,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF3_2(pc),a1
		moveq	#7,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		lea	HelpF3_3(pc),a1
		moveq	#6,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		rts

HKey_B4		cmp.w	#$53,d0		;F4 key?
		bne.s	HKey_B5

		lea	HelpF4_1(pc),a1
		moveq	#7,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

		rts

HKey_B5		cmp.w	#$54,d0		;F5 key?
		bne.s	HKey_B6

		lea	HelpF5_1(pc),a1
		moveq	#7,d0

		move.l	a1,irt_tlist(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq

HKey_B6		rts

HKey_Done	rts


* Here copy IntuiMessage data to InputEvent structure


		nop


* Here do a RawKeyConvert() to get a key press if it isn't one
* of our special keys.


		lea	CW_IE(pc),a0
		lea	iebuffer(pc),a1
		moveq	#10,d1
		sub.l	a2,a2

		move.l	a6,-(sp)
		move.l	consoledev(a6),a6
		jsr	RawKeyConvert(a6)
		move.l	(sp)+,a6

		rts


* InputEvent structure for use with above


CW_IE		dc.l	0
		dc.b	0,0	;class, subclass
		dc.w	0	;code
		dc.w	0	;qualifier
		dc.l	0	;eventaddr
		dc.l	0,0	;timestamp

iebuffer		ds.b	10	;10 byte convert buffer





