

* Anciliary routines go in this file.


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

* Initialise Undo array.


InitUndo		move.l	undo_array(a6),a0		;ptr to undo array
		moveq	#" ",d2

		move.w	grid_down(a6),d0		;vertical size
		bra.s	IUN_a1

IUN_l1		move.w	grid_across(a6),d1	;horiz size
		bra.s	IUN_a2

IUN_l2		move.w	d2,(a0)+		;insert space

IUN_a2		dbra	d1,IUN_l2	;do this many across

IUN_a1		dbra	d0,IUN_l1	;do this many down

		rts


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

* Change editing state according to status of the
* SELECTED flag of the new Grid Editing switch (as
* it's a TOGGLESELECT job).

* d0/a0 corrupt


SetEditing	move.l	gadget_id(a6),d0		;got gadget?
		beq.s	SEDT_Done		;oops..
		move.l	d0,a0
		move.w	gg_Flags(a0),d0		;get flags
		and.w	#SELECTED,d0		;SELECTED state?
		sne	d0			;make edit state byte
		move.b	d0,editon(a6)		;set editing state

SEDT_Done	rts



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

* Sets screen mouse pointer to "PLEASE WAIT"
* as a sign that something processor-intensive
* is about to happen.

* d0-d3/a0-a1 corrupt


HangPointer	move.l	mw_handle(a6),a0
		lea	CWHangPtr,a1
		moveq	#49,d0		;height
		moveq	#16,d1		;width
		moveq	#0,d2		;XOffset to HotSpot
		moveq	#0,d3		;YOffset to HotSpot
		CALLINT	SetPointer

		rts


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

* Sets main program pointer on screen.

* d0-d3/a0-a1 corrupt


MainPointer	move.l	mw_handle(a6),a0
		lea	CWPointer,a1
		moveq	#15,d0		;height
		moveq	#16,d1		;width
		moveq	#0,d2		;XOffset to HotSpot
		moveq	#-12,d3		;YOffset to HotSpot
		CALLINT	SetPointer

		rts


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

* Sets main program pointer on screen.

* d0-d3/a0-a1 corrupt


DiscPointer	move.l	dp_window1(a6),a0
		lea	CWPointer,a1
		moveq	#15,d0		;height
		moveq	#16,d1		;width
		moveq	#0,d2		;XOffset to HotSpot
		moveq	#-12,d3		;YOffset to HotSpot
		CALLINT	SetPointer

		move.l	dp_window2(a6),a0
		lea	CWPointer,a1
		moveq	#15,d0		;height
		moveq	#16,d1		;width
		moveq	#0,d2		;XOffset to HotSpot
		moveq	#-12,d3		;YOffset to HotSpot
		CALLINT	SetPointer

		rts


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

* Link the font pointer into all of the IntuiTexts that
* need it.

* d0-d1/a0 corrupt


LinkFonts	nop

;		move.l	topaz_font(a6),d0	;get font pointer

		lea	Topaz_80(pc),a0	;ptr to font TextAttr
		move.l	a0,d0

		lea	IRT_1(pc),a0	;point to InfoReq ITexts
		moveq	#20,d1		;number to do

LFNT_1		move.l	d0,8(a0)		;link in Font
		add.w	#20,a0		;point to next
		subq.l	#1,d1		;do this many
		bne.s	LFNT_1		;back until done

		lea	QRT_1(pc),a0	;point to QueryReq ITexts
		moveq	#20,d1		;number to do

LFNT_2		move.l	d0,8(a0)		;link in Font
		add.w	#20,a0		;point to next
		subq.l	#1,d1		;do this many
		bne.s	LFNT_2		;back until done

		rts


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

* Set all entries in clue list to the unsolved state.

* d0/a0-a1 corrupt


SetUnsolved	move.l	clue_list(a6),d0	;get clue list
		beq.s	SUS_4		;exit if it doesn't exist

		move.l	d0,a0		;else point to it

		move.l	clh_AcList(a0),d0	;across list exists?
		beq.s	SUS_2		;skip if not

		move.l	d0,a1
		move.w	clh_AcCount(a0),d0	;else get entry count
		
SUS_1		clr.b	cle_Solved(a1)	;set unsolved
		add.w	#cle_sizeof,a1	;point to next entry
		subq.w	#1,d0
		bne.s	SUS_1

SUS_2		move.l	clh_DnList(a0),d0	;down list exists?
		beq.s	SUS_4		;skip if not

		move.l	d0,a1
		move.w	clh_DnCount(a0),d0	;else get entry count

SUS_3		clr.b	cle_Solved(a1)	;set unsolved
		add.w	#cle_sizeof,a1	;point to next entry
		subq.w	#1,d0
		bne.s	SUS_3

SUS_4		rts


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

* Display the InfoReq for "Function Not Implemented".

* d0-a0-a1 corrupt


SodOff		lea	NoGo(pc),a0
		lea	IRT_1(pc),a1
		moveq	#4,d0
		move.l	a0,irt_tlist(a6)
		move.l	a1,irt_itext(a6)
		move.w	d0,irt_count(a6)

		bsr	LinkInfoText

		bsr	ShowInfoReq		;pop up requester

		rts



