
	load 'macros.dump'
	include 'driver.equ'

;-----------------------------------------------
;
;   Imported addresses
;
;-----------------------------------------------

	IMPORT	D_AlertBox
	IMPORT	D_Deref
	IMPORT	T_Ascent
	IMPORT	T_Descent
	IMPORT	T_Length
	IMPORT	T_LineCount
	IMPORT	T_LineInfoSize
	IMPORT	T_LineWidth
	IMPORT	T_LinesHdl
	IMPORT	T_ObjHdl
	IMPORT	T_Offset
	IMPORT	T_ParHeight
	IMPORT	T_ParInfoSize
	IMPORT	T_ParOffset
	IMPORT	T_ParStart
	IMPORT	T_RulerHdl
	IMPORT	T_TextBlock
	IMPORT	D_UseStdColors

;-----------------------------------------------
;
;   Forward addresses and entries
;
;-----------------------------------------------

	ENTRY	CancelItem
	ENTRY	PAItem1
	ENTRY	PAItem2
	ENTRY	PAItem3
	ENTRY	PAItem4
	ENTRY	PAItem5
	ENTRY	PAItem6
	ENTRY	PAString1
	ENTRY	PAString2
	ENTRY	PAString3
	ENTRY	PAString4
	ENTRY	PAString5
	ENTRY	PAString6
	ENTRY	PBItem2
	ENTRY	PBItem3
	ENTRY	PBItem4
	ENTRY	PBItem5
	ENTRY	PBItem6
	ENTRY	PBString2
	ENTRY	PBString3
	ENTRY	PBString4
	ENTRY	PBString5
	ENTRY	PBString6
	ENTRY	PCItem1
	ENTRY	PCItem10
	ENTRY	PCItem2
	ENTRY	PCItem3
	ENTRY	PCItem4
	ENTRY	PCItem5
	ENTRY	PCItem6
	ENTRY	PCItem7
	ENTRY	PCItem8
	ENTRY	PCItem9
	ENTRY	PCString1
	ENTRY	PCString10
	ENTRY	PCString2
	ENTRY	PCString3
	ENTRY	PCString4
	ENTRY	PCString5
	ENTRY	PCString6
	ENTRY	PCString7
	ENTRY	PCString8
	ENTRY	PCString9
	ENTRY	PDItem10
	ENTRY	PDItem3
	ENTRY	PDItem4
	ENTRY	PDItem5
	ENTRY	PDItem6
	ENTRY	PDItem7
	ENTRY	PDItem8
	ENTRY	PDItem9
	ENTRY	PDString10
	ENTRY	PDString3
	ENTRY	PDString4
	ENTRY	PDString5
	ENTRY	PDString6
	ENTRY	PDString7
	ENTRY	PDString8
	ENTRY	PDString9
	ENTRY	String1
	ENTRY	String2
	ENTRY	String3
	ENTRY	String4
	ENTRY	String5
	ENTRY	String6
	ENTRY	String7
	ENTRY	String8
	ENTRY	String9
	ENTRY	TItem1
	ENTRY	TItem2
	ENTRY	TItem3
	ENTRY	TItem4
	ENTRY	TItem5
	ENTRY	TItem6
	ENTRY	TItem7
	ENTRY	TItem8
	ENTRY	T_CancelStr
	ENTRY	T_LineAlert
	ENTRY	T_ParagAlert
	ENTRY	T_Str
	;KEEP	obj/tdbg
		INCLUDE	'mac/tdbg.mac'




;----------------------------------------------------------------------
; T_NumbAlert (Numb:word)
;

T_NumbAlert	PROC		EXPORT
			;Using T_DebugData

		INPUT Numb:w
		BEGIN +b

		spacelong
		_GetPort

		pushword Numb
		pushlong #T_Str+1
		pushword #6
		pushword #0
		_Int2Dec
		spaceword
		pushword #1
		pushlong #T_Str
		jsl	D_UseStdColors
		jsl D_AlertBox
		pla

		_SetPort

		RETURN
		ENDP




;-------------------------------------------------------------------------------
;
; T_DebugTextObj (ObjHdl:l)
;

T_DebugTextObj	PROC		EXPORT
			;Using P_ObjData
			;Using P_Data

		INPUT ObjHdl:l
		LOCAL ObjPtr:l,PrevObject:l

		BEGIN


Loop	movelong [ObjHdl],ObjPtr
		movelong [ObjPtr]:#P_PThread,PrevObject

		cpzl PrevObject
		beq AtStart
		movelong PrevObject,ObjHdl
		bra Loop


AtStart

Loop2	cpzl ObjHdl
		beq Exit

		movelong [ObjHdl],ObjPtr
		pushword [ObjPtr]:#P_StartParag
		jsl T_NumbAlert
		pushword [ObjPtr]:#P_StartLine
		jsl T_NumbAlert
		pushword [ObjPtr]:#P_EndParag
		jsl T_NumbAlert
		pushword [ObjPtr]:#P_EndLine
		jsl T_NumbAlert

		movelong [ObjPtr]:#P_NThread,ObjHdl
		bra Loop2

Exit	RETURN
		ENDP





;-----------------------------------------------------------------------------
;
; T_DebugLines (LinePtr:l,LineCount:w)
;

T_DebugLines	PROC		EXPORT
			;Using T_Data
			;Using T_DebugData
			;Using T_TextEqu

		INPUT LinePtr:l,LineCount:w
		LOCAL CurLine:w
		BEGIN +b

		stz CurLine

Loop
		inc CurLine

		pushword [LinePtr]:#T_Offset
		pushlong #PBString2+1
		pushword #6
		pushword #0
		_Int2Dec

		pushword [LinePtr]:#T_Length
		pushlong #PBString3+1
		pushword #6
		pushword #0
		_Int2Dec

		pushword [LinePtr]:#T_LineWidth
		pushlong #PBString4+1
		pushword #6
		pushword #0
		_Int2Dec

		moveword [LinePtr]:#T_Ascent,a
		and #$ff
		pha
		pushlong #PBString5+1
		pushword #6
		pushword #0
		_Int2Dec

		moveword [LinePtr]:#T_Descent,a
		and #$ff
		pha
		pushlong #PBString6+1
		pushword #6
		pushword #0
		_Int2Dec


		spaceword
		pushlong #T_LineAlert
		pushlong #0
		_Alert
		pla

		cmp #1
		bne Exit

		cmpw CurLine,LineCount
		bge Exit

		addwl #T_LineInfoSize,LinePtr
		brl Loop


Exit	RETURN
		ENDP




;------------------------------------------------------------------------------
;
; T_DebugParag (ParagPtr:l) : Continue:w
;

T_DebugParag	PROC		EXPORT
			;Using T_Data
			;Using T_TextEqu
			;Using T_DebugData

		INPUT  ParagPtr:l
		OUTPUT Continue:w
		LOCAL  LinesHdl:l,LinePtr:l,Result:w

		BEGIN +b

		pushlong [ParagPtr]:#T_TextBlock
		pushlong #PDString3+1
		pushword #6
		_Long2Hex

		pushword [ParagPtr]:#T_ParOffset
		pushlong #PDString4+1
		pushword #6
		pushword #0
		_Int2Dec

		pushword [ParagPtr]:#T_ParStart
		pushlong #PDString5+1
		pushword #6
		pushword #0
		_Int2Dec

		pushlong [ParagPtr]:#T_RulerHdl
		pushlong #PDString6+1
		pushword #6
		_Long2Hex

		pushword [ParagPtr]:#T_ParHeight
		pushlong #PDString7+1
		pushword #6
		pushword #0
		_Int2Dec

		pushlong [ParagPtr]:#T_LinesHdl
		pushlong #PDString8+1
		pushword #6
		_Long2Hex

		pushword [ParagPtr]:#T_LineCount
		pushlong #PDString9+1
		pushword #6
		pushword #0
		_Int2Dec

		pushlong [ParagPtr]:#T_ObjHdl
		pushlong #PDString10+1
		pushword #6
		_Long2Hex



		spaceword
		pushlong #T_ParagAlert
		pushlong #0
		_Alert
		pullword Result

		cmpw Result,#1
		beq Yes
		cmpw Result,#2
		bne No

		movelong [ParagPtr]:#T_LinesHdl,LinesHdl
		movelong LinesHdl,ax
		jsl D_Deref
		movelong ax,LinePtr

		pushlong LinePtr
		pushword [ParagPtr]:#T_LineCount
		jsl T_DebugLines

		pushlong LinesHdl
		_HUnlock


Yes
		moveword #1,Continue
		bra Exit

No
		stz Continue

Exit	RETURN
		ENDP





;-------------------------------------------------------------------------------
;
; T_DebugThread (ParagHdl:l)
;

T_DebugThread	PROC		EXPORT
			;Using T_Data
			;Using T_TextEqu

		INPUT ParagHdl:l
		LOCAL ParagPtr:l,ParCount:w

		BEGIN +b

		pushlong ParagHdl
		_HLock

		movelong [ParagHdl],ParagPtr
		moveword [ParagPtr],ParCount
		pushword ParCount
		jsl T_NumbAlert

ParLoop	lda ParCount
		beq Done

		spaceword
		pushlong ParagPtr
		jsl T_DebugParag
		pla
		beq Done

		addwl #T_ParInfoSize,ParagPtr
		dec ParCount
		bra ParLoop

Done
		pushlong ParagHdl
		_HUnlock

		RETURN
		ENDP





;-----------------------------------------------------------------------------
;
; T_DebugData
;

T_DebugData	PROC		EXPORT
		EXPORT	T_Str
		EXPORT	T_String
		EXPORT	ContStr
		EXPORT	T_ParagAlert
		EXPORT	PCItem1
		EXPORT	PCItem2
		EXPORT	PCItem3
		EXPORT	PCItem4
		EXPORT	PCItem5
		EXPORT	PCItem6
		EXPORT	PCItem7
		EXPORT	PCItem8
		EXPORT	PCItem9
		EXPORT	PCItem10
		EXPORT	PDItem3
		EXPORT	PDItem4
		EXPORT	PDItem5
		EXPORT	PDItem6
		EXPORT	PDItem7
		EXPORT	PDItem8
		EXPORT	PDItem9
		EXPORT	PDItem10
		EXPORT	PCString1
		EXPORT	PCString2
		EXPORT	PCString3
		EXPORT	PCString4
		EXPORT	PCString5
		EXPORT	PCString6
		EXPORT	PCString7
		EXPORT	PCString8
		EXPORT	PCString9
		EXPORT	PCString10
		EXPORT	PDString3
		EXPORT	PDString4
		EXPORT	PDString5
		EXPORT	PDString6
		EXPORT	PDString7
		EXPORT	PDString8
		EXPORT	PDString9
		EXPORT	PDString10
		EXPORT	T_LineAlert
		EXPORT	PAItem1
		EXPORT	PAItem2
		EXPORT	PAItem3
		EXPORT	PAItem4
		EXPORT	PAItem5
		EXPORT	PAItem6
		EXPORT	PBItem2
		EXPORT	PBItem3
		EXPORT	PBItem4
		EXPORT	PBItem5
		EXPORT	PBItem6
		EXPORT	CancelItem
		EXPORT	PAString1
		EXPORT	PAString2
		EXPORT	PAString3
		EXPORT	PAString4
		EXPORT	PAString5
		EXPORT	PAString6
		EXPORT	PBString2
		EXPORT	PBString3
		EXPORT	PBString4
		EXPORT	PBString5
		EXPORT	PBString6
		EXPORT	T_CancelStr
		EXPORT	T_ThreadDlg
		EXPORT	TItem1
		EXPORT	TItem2
		EXPORT	TItem3
		EXPORT	TItem4
		EXPORT	TItem5
		EXPORT	TItem6
		EXPORT	TItem7
		EXPORT	TItem8
		EXPORT	TItem9
		EXPORT	String1
		EXPORT	String2
		EXPORT	String3
		EXPORT	String4
		EXPORT	String5
		EXPORT	String6
		EXPORT	String7
		EXPORT	String8
		EXPORT	String9

T_Str	DC.B	6
T_String		DS.B 255

ContStr	STR  'Continue?'


T_ParagAlert
	DC.W	60,140,190,500
	DC.W	789
	DC.B	%10000000
	DC.B	%10000000
	DC.B	%10000000
	DC.B	%10000000
	DC.L	PCItem1
	DC.L	PCItem2
	DC.L	PCItem2
	DC.L	PCItem3
	DC.L	PCItem4
	DC.L	PCItem5
	DC.L	PCItem6
	DC.L	PCItem7
	DC.L	PCItem8
	DC.L	PCItem9
	DC.L	PCItem10
	DC.L	PDItem3
	DC.L	PDItem4
	DC.L	PDItem5
	DC.L	PDItem6
	DC.L	PDItem7
	DC.L	PDItem8
	DC.L	PDItem9
	DC.L	PDItem10
	DC.L	CancelItem
	DC.L	0


PCItem1	DC.W	1	;Number
	DC.W	65,230,80,320	;Rectangle
	DC.W	10	;Type
	DC.L	PCString1	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem2	DC.W	2	;Number
	DC.W	85,230,100,320	;Rectangle
	DC.W	10	;Type
	DC.L	PCString2	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PCItem3	DC.W	3	;Number
	DC.W	5,30,17,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString3	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem4	DC.W	4	;Number
	DC.W	20,30,32,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString4	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem5	DC.W	5	;Number
	DC.W	35,30,47,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString5	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem6	DC.W	6	;Number
	DC.W	50,30,62,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString6	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem7	DC.W	7	;Number
	DC.W	65,30,77,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString7	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem8	DC.W	8	;Number
	DC.W	80,30,92,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString8	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PCItem9	DC.W	9	;Number
	DC.W	95,30,107,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString9	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PCItem10	DC.W	10	;Number
	DC.W	110,30,122,100	;Rectangle
	DC.W	15	;Type
	DC.L	PCString10	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PDItem3	DC.W	11	;Number
	DC.W	5,130,17,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString3	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem4	DC.W	12	;Number
	DC.W	20,130,32,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString4	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem5	DC.W	13	;Number
	DC.W	35,130,47,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString5	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem6	DC.W	14	;Number
	DC.W	50,130,62,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString6	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem7	DC.W	15	;Number
	DC.W	65,130,77,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString7	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem8	DC.W	16	;Number
	DC.W	80,130,92,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString8	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem9	DC.W	17	;Number
	DC.W	95,130,107,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString9	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PDItem10	DC.W	18	;Number
	DC.W	110,130,122,200	;Rectangle
	DC.W	15	;Type
	DC.L	PDString10	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0




PCString1	STR  'Continue'
PCString2	STR  'LineInfo'

PCString3	STR  'TextHdl'
PCString4	STR  'ParOffset'
PCString5	STR  'ParStart'
PCString6	STR  'RulerHdl'
PCString7	STR  'ParHeight'
PCString8	STR  'LinesHdl'
PCString9	STR  'LineCount'
PCString10	STR  'ObjHdl'


PDString3	DC.B	6
		DS.B 6
PDString4	DC.B	6
		DS.B 6
PDString5	DC.B	6
		DS.B 6
PDString6	DC.B	6
		DS.B 6
PDString7	DC.B	6
		DS.B 6
PDString8	DC.B	6
		DS.B 6
PDString9	DC.B	6
		DS.B 6
PDString10	DC.B	6
		DS.B 6







T_LineAlert
	DC.W	60,140,160,500
	DC.W	789
	DC.B	%10000000
	DC.B	%10000000
	DC.B	%10000000
	DC.B	%10000000
	DC.L	PAItem1
	DC.L	PAItem2
	DC.L	PAItem3
	DC.L	PAItem4
	DC.L	PAItem5
	DC.L	PAItem6
	DC.L	PBItem2
	DC.L	PBItem3
	DC.L	PBItem4
	DC.L	PBItem5
	DC.L	PBItem6
	DC.L	CancelItem
	DC.L	0


PAItem1	DC.W	1	;Number
	DC.W	65,230,80,320	;Rectangle
	DC.W	10	;Type
	DC.L	PAString1	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PAItem2	DC.W	2	;Number
	DC.W	5,30,17,100	;Rectangle
	DC.W	15	;Type
	DC.L	PAString2	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PAItem3	DC.W	3	;Number
	DC.W	20,30,32,100	;Rectangle
	DC.W	15	;Type
	DC.L	PAString3	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PAItem4	DC.W	4	;Number
	DC.W	35,30,47,100	;Rectangle
	DC.W	15	;Type
	DC.L	PAString4	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PAItem5	DC.W	5	;Number
	DC.W	50,30,62,100	;Rectangle
	DC.W	15	;Type
	DC.L	PAString5	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PAItem6	DC.W	6	;Number
	DC.W	65,30,77,100	;Rectangle
	DC.W	15	;Type
	DC.L	PAString6	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PBItem2	DC.W	13	;Number
	DC.W	5,130,17,200	;Rectangle
	DC.W	15	;Type
	DC.L	PBString2	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PBItem3	DC.W	14	;Number
	DC.W	20,130,32,200	;Rectangle
	DC.W	15	;Type
	DC.L	PBString3	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PBItem4	DC.W	15	;Number
	DC.W	35,130,47,200	;Rectangle
	DC.W	15	;Type
	DC.L	PBString4	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PBItem5	DC.W	16	;Number
	DC.W	50,130,62,200	;Rectangle
	DC.W	15	;Type
	DC.L	PBString5	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

PBItem6	DC.W	17	;Number
	DC.W	65,130,77,200	;Rectangle
	DC.W	15	;Type
	DC.L	PBString6	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0



CancelItem	DC.W	24	;Number
	DC.W	40,230,55,320	;Rectangle
	DC.W	10	;Type
	DC.L	T_CancelStr	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


PAString1	STR  'Continue'
PAString2	STR  'Offset'
PAString3	STR  'Length'
PAString4	STR  'Width'
PAString5	STR  'Ascent'
PAString6	STR  'Descent'


PBString2	DC.B	6
		DS.B 6
PBString3	DC.B	6
		DS.B 6
PBString4	DC.B	6
		DS.B 6
PBString5	DC.B	6
		DS.B 6
PBString6	DC.B	6
		DS.B 6


T_CancelStr	STR 'Cancel'





T_ThreadDlg
	DC.W	40,120,180,520
	DC.W	1
	DC.L	0
	DC.L	TItem1
	DC.L	TItem2
	DC.L	TItem3
	DC.L	TItem4
	DC.L	TItem5
	DC.L	TItem6
	DC.L	TItem7
	DC.L	TItem8
	DC.L	0


TItem1	DC.W	1	;Number
	DC.W	30,30,45,150	;Rectangle
	DC.W	10	;Type
	DC.L	String1	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem2	DC.W	2	;Number
	DC.W	50,30,65,150	;Rectangle
	DC.W	10	;Type
	DC.L	String2	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem3	DC.W	3	;Number
	DC.W	70,30,85,150	;Rectangle
	DC.W	10	;Type
	DC.L	String3	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem4	DC.W	4	;Number
	DC.W	90,30,105,150	;Rectangle
	DC.W	10	;Type
	DC.L	String4	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem5	DC.W	5	;Number
	DC.W	30,175,45,275	;Rectangle
	DC.W	15	;Type
	DC.L	String5	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem6	DC.W	6	;Number
	DC.W	50,175,65,275	;Rectangle
	DC.W	15	;Type
	DC.L	String6	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem7	DC.W	7	;Number
	DC.W	30,300,45,375	;Rectangle
	DC.W	15	;Type
	DC.L	String7	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem8	DC.W	8	;Number
	DC.W	50,300,65,375	;Rectangle
	DC.W	15	;Type
	DC.L	String8	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0

TItem9	DC.W	9	;Number
	DC.W	0,0,0,0	;Rectangle
	DC.W	15	;Type
	DC.L	String9	;Descriptor
	DC.W	0	;Value
	DC.W	0
	DC.L	0


String1	STR  'LineInfo'
String2	STR  'Cancel'
String3	STR  'Next'
String4	STR  'Previous'
String5	STR  'StartOffset'
String6	STR  'LineCount'

String7	DC.B	6
		DS.B 6
String8	DC.B	6
		DS.B 6
String9	DC.B	6
		DS.B 6


		ENDP
		END

