;$VER: WandererLevelEditor.s v1.00 (01-Apr-98)
;Code by Ivan Oliver
;See the comments at the end of the file...

	opt	o+,w-
	section	main,code

ProgStart
	move.l	4.w,a6
	sub.l	a1,a1
	jsr	-$126(a6)	;FindTask(a1)exec
	move.l	d0,a4
	tst.l	$ac(a4)
	bne.b	FromDOS
	lea	$5c(a4),a0
	jsr	-$180(a6)	;WaitPort(a0)exec
	lea	$5c(a4),a0
	jsr	-$174(a6)	;GetMsg(a0)exec
	move.l	d0,WbMsg
FromDOS	lea	Dos_L(pc),a1
	moveq.l	#0,d0
	bsr	OpenLibrary
	move.l	d0,Dos_B
	beq	Quit
	lea	Intui_L(pc),a1
	moveq.l	#0,d0
	bsr	OpenLibrary
	move.l	d0,Intui_B
	beq	ClDos
	lea	Gfx_L(pc),a1
	moveq.l	#0,d0
	bsr	OpenLibrary
	move.l	d0,Gfx_B
	beq	ClIntui
	lea	ReqT_L(pc),a1
	moveq.l	#37,d0
	bsr	OpenLibrary
	move.l	d0,ReqT_B
	beq	Err_ShowNoReqTools
	move.l	Intui_B(pc),a6
	lea	WinDefs(pc),a0
	jsr	-$cc(a6)	;OpenWindow(a0)int
	move.l	d0,WinPtr
	beq	Err_ShowNoWindow
	move.l	d0,a0
	move.l	$32(a0),RPort
	move.l	$56(a0),MsgPort
	lea	BoxA1(pc),a1
	bsr	DrawBorder
	lea	BoxB1(pc),a1
	bsr	DrawBorder
	lea	BoxC1(pc),a1
	bsr	DrawBorder
	moveq.l	#1,d0
	bsr	SetAPen
	lea	MsgText(pc),a4
	moveq.l	#11,d0
	moveq.l	#21,d1
	moveq.l	#40,d7
	bsr	PrintText
	lea	GadText(pc),a4	;New
	move.l	#403,d0
	moveq.l	#23,d1
	moveq.l	#3,d7
	bsr	PrintText
	addq.l	#3,a4		;Load Level
	move.l	#375,d0
	moveq.l	#35,d1
	moveq.l	#10,d7
	bsr	PrintText
	lea	10(a4),a4	;Save Level
	move.l	#375,d0
	moveq.l	#47,d1
	moveq.l	#10,d7
	bsr	PrintText
	lea	10(a4),a4	;Set Moves
	move.l	#379,d0
	moveq.l	#83,d1
	moveq.l	#9,d7
	bsr	PrintText
	lea	9(a4),a4	;Help
	move.l	#399,d0
	moveq.l	#107,d1
	moveq.l	#4,d7
	bsr	PrintText
	moveq.l	#0,d0
	bsr	SetDrMd
	addq.l	#4,a4		;Level Info
	move.l	#375,d0
	moveq.l	#119,d1
	moveq.l	#10,d7
	bsr	PrintText
	moveq.l	#1,d0
	bsr	SetDrMd
	lea	10(a4),a4	;About
	move.l	#395,d0
	move.l	#131,d1
	moveq.l	#5,d7
	bsr	PrintText
	addq.l	#5,a4		;Quit Editor
	move.l	#371,d0
	move.l	#152,d1
	moveq.l	#11,d7
	bsr	PrintText
	bsr	UpdateMap
	bsr	CountTreasures
WinLoop	move.l	MsgPort(pc),a0
	move.l	4.w,a6
	jsr	-$180(a6)	;WaitPort(a0)exec
	move.l	MsgPort(pc),a0
	move.l	4.w,a6
	jsr	-$174(a6)	;GetMsg(a0)exec
	move.l	d0,a0
	move.l	d0,a5
	move.l	$1C(a0),-(sp)
	move.l	$14(a0),d7
	move.l	d0,a1
	move.l	4.w,a6
	jsr	-$17A(a6)	;ReplyMsg(a1)exec
	move.l	(sp)+,a0
	moveq.l	#0,d0
	move.w	$26(a0),d0
	cmp.w	#$40,d7		;IDCMP_GADGETUP
	beq	GadgetSelect
	cmp.l	#$200000,d7	;IDCMP_VANILLAKEY
	beq	VanillaKey
	bra.b	WinLoop
ClWin	move.l	Intui_B(pc),a6
	move.l	WinPtr(pc),a0
	jsr	-$48(a6)	;CloseWindow(a0)int
ClReqT	move.l	ReqT_B(pc),a1
	bsr.b	CloseLibrary
ClGfx	move.l	Gfx_B(pc),a1
	bsr.b	CloseLibrary
ClIntui	move.l	Intui_B(pc),a1
	bsr.b	CloseLibrary
ClDos	move.l	Dos_B(pc),a1
	bsr.b	CloseLibrary
Quit	tst.l	WbMsg
	beq.b	QuitDOS
	move.l	4.w,a6
	move.l	WbMsg(pc),a1
	jsr	-$17a(a6)	;ReplyMsg(a1)exec
QuitDOS	moveq.l	#0,d0
	rts

OpenLibrary
	move.l	4.w,a6
	jmp	-$228(a6)	;OpenLibrary(a1,d0)exec

CloseLibrary
	move.l	4.w,a6
	jmp	-$19e(a6)	;CloseLibrary(a1)exec

DrawBorder
	move.l	Intui_B(pc),a6
	move.l	RPort(pc),a0
	moveq.l	#0,d0
	moveq.l	#0,d1
	jmp	-$6c(a6)	;DrawBorder(a0,a1,d0,d1)int

Err_ShowNoReqTools
	bsr.b	Output
	move.l	d0,d1
	beq.b	ClGfx
	lea	NoReqT(pc),a2
	move.l	a2,d2
	moveq.l	#43,d3
	bsr.b	Write
	bra.b	ClGfx

Err_ShowNoWindow
	bsr.b	Output
	move.l	d0,d1
	beq.b	ClReqT
	lea	NoWin(pc),a2
	move.l	a2,d2
	moveq.l	#33,d3
	bsr.b	Write
	bra.b	ClReqT

Output
	move.l	Dos_B(pc),a6
	jmp	-$3c(a6)	;Output()dos

Open
	move.l	Dos_B(pc),a6
	jmp	-$1e(a6)	;Open(d1,d2,d3)dos

Read
	move.l	Dos_B(pc),a6
	jmp	-$2a(a6)	;Read(d1,d2,d3)dos

Write
	move.l	Dos_B(pc),a6
	jmp	-$30(a6)	;Write(d1,d2,d3)dos

Close
	move.l	Dos_B(pc),a6
	jmp	-$24(a6)	;Close(d1)dos

GadgetSelect
	cmp.b	#1,d0
	beq	CheckNew
	cmp.b	#2,d0
	beq	LoadLevel
	cmp.b	#3,d0
	beq	SaveLevel
	cmp.b	#6,d0
	beq	SetMoves
	cmp.b	#8,d0
	beq	ShowHelp
	cmp.b	#10,d0
	beq	ShowAbout
	cmp.b	#11,d0
	beq	CheckQuit
	bra	WinLoop

VanillaKey
	move.l	a5,a0
	move.l	20(a0),d0	;intuimessage.class	(IDCMP_VANILLAKEY)
	move.w	24(a0),d1	;intuimessage.code	(key pressed)
	move.w	26(a0),d2	;intuimessage.qualifier	(shift, alt etc.)
	cmp.b	#"n",d1
	beq	CheckNew
	cmp.b	#"l",d1
	beq	LoadLevel
	cmp.b	#"v",d1
	beq	SaveLevel
	cmp.b	#"e",d1
	beq	SetMoves
	cmp.b	#"?",d1
	beq	ShowAbout
	cmp.b	#"h",d1
	beq	ShowHelp
	cmp.b	#"q",d1
	beq	CheckQuit
	cmp.b	#"4",d1
	beq	CheckMoveLeft
	cmp.b	#"6",d1
	beq	CheckMoveRight
	cmp.b	#"8",d1
	beq	CheckMoveUp
	cmp.b	#"2",d1
	beq	CheckMoveDown
	cmp.b	#"5",d1
	beq	EraseCharacter
	cmp.b	#" ",d1
	beq	EraseCharacter
	cmp.b	#"o",d1
	beq	InsertUpper
	cmp.b	#"<",d1
	beq	InsertCharacter
	cmp.b	#">",d1
	beq	InsertCharacter
	cmp.b	#"^",d1
	beq	InsertCharacter
	cmp.b	#":",d1
	beq	InsertCharacter
	cmp.b	#"!",d1
	beq	InsertCharacter
	cmp.b	#"*",d1
	beq	InsertCharacter
	cmp.b	#"/",d1
	beq	InsertCharacter
	cmp.b	#"\",d1
	beq	InsertCharacter
	cmp.b	#"+",d1
	beq	InsertCharacter
	cmp.b	#"=",d1
	beq	InsertCharacter
	cmp.b	#"#",d1
	beq	InsertCharacter
	cmp.b	#"t",d1
	beq	InsertUpper
	cmp.b	#"a",d1
	beq	InsertUpper
	cmp.b	#"x",d1
	beq	InsertUpper
	cmp.b	#"@",d1
	beq	InsertCharacter
	cmp.b	#"m",d1
	beq	InsertUpper
	cmp.b	#"s",d1
	beq	InsertUpper
	cmp.b	#"-",d1
	beq	InsertCharacter
	cmp.b	#"c",d1
	beq	InsertUpper
	bra	WinLoop

SetAPen
	move.l	Gfx_B(pc),a6
	move.l	RPort(pc),a1
	jmp	-$156(a6)	;SetAPen(a1,d0)gfx

SetBPen
	move.l	Gfx_B(pc),a6
	move.l	RPort(pc),a1
	jmp	-$15c(a6)	;SetCPen(a1,d0)gfx

PrintText
	move.l	Gfx_B(pc),a6
	move.l	a4,a0
	move.l	RPort(pc),a1
	jsr	-$f0(a6)	;Move(a1,d0,d1)gfx
	move.l	RPort(pc),a1
	move.l	d7,d0
	jmp	-$3c(a6)	;Text(a1,a0,d0)gfx

UpdateMap
	moveq.l	#34,d6
	lea	Map(pc),a4
.loop	moveq.l	#12,d0
	move.l	d6,d1
	moveq.l	#40,d7
	bsr.b	PrintText
	lea	41(a4),a4
	addq.l	#8,d6
	cmp.b	#162,d6
	bne.b	.loop
	bsr	UpdateCursor
	rts

ShowAbout
	lea	Rq01T(pc),a0
	lea	Rq01B(pc),a1
	lea	OkText(pc),a2
	bsr.b	EZRequest
	bra	WinLoop

CheckQuit
	lea	Rq02T(pc),a0
	lea	RUSure(pc),a1
	lea	YesNo(pc),a2
	bsr.b	EZRequest
	cmp.b	#1,d0
	beq	ClWin
	bra	WinLoop

ShowHelp
	lea	Rq03T(pc),a0
	lea	Rq03B(pc),a1
	lea	MoreXit(pc),a2
	bsr.b	EZRequest
	cmp.b	#1,d0
	beq.b	ShowMoreHelp
	bra	WinLoop

ShowMoreHelp
	lea	Rq05T(pc),a0
	lea	Rq05B(pc),a1
	lea	OkText(pc),a2
	bsr.b	EZRequest
	bra	WinLoop

CheckNew
	lea	Rq04T(pc),a0
	lea	RUSure(pc),a1
	lea	YesNo(pc),a2
	bsr.b	EZRequest
	cmp.b	#1,d0
	beq.b	ClearMap
	bra	WinLoop

EZRequest
	move.l	ReqT_B(pc),a6
	move.w	#0,a3
	move.w	#0,a4
	jmp	-$42(a6)	;RtEZRequest(a1,a2,a3,a4,a0)rt

CountTreasures
	lea	Map(pc),a0
	move.l	#655,d0
	moveq.l	#0,d1
.next	cmp.b	#'*',(a0)+
	beq.b	.found
	dbra	d0,.next
	bra.b	.exit
.found	addq.l	#1,d1
	dbra	d0,.next
.exit	rts

ClearMap
	lea	Map(pc),a0
	moveq.l	#15,d0
.row	moveq.l	#9,d1
.loop	move.l	#'    ',(a0)+
	dbra	d1,.loop
	addq.l	#1,a0
	dbra	d0,.row
	bsr	UpdateMap
	lea	Cleared(pc),a4
	bsr	ShowMessage
	bra	WinLoop

LoadLevel
	lea	Temp(pc),a0
	move.b	#0,(a0)
	moveq.l	#0,d0
	bsr	AllocRequest
	move.l	d0,ReqPtr
	beq	Err_NoRequester
	lea	Rf01Tl(pc),a3
	move.l	#'Load',(a3)
	bsr	FileRequest
	tst.l	d0
	beq.b	.free
	lea	ReqPtr(pc),a1
	move.l	(a1),a1
	move.l	16(a1),a0
	lea	LoadFil(pc),a1
	bsr	ExtractPathFile
	lea	LoadFil(pc),a0
	bsr	GetFileSize
	sub.l	#697,d0
	move.l	d0,FileLen
	bsr	LoadLevelFile
	bsr	UpdateMap
	lea	DiskOk(pc),a4
	move.l	#'load',5(a4)
	move.l	#'ed o',9(a4)
	move.l	#'k.  ',13(a4)
	bsr	ShowMessage
.free	bsr	FreeRequest
	bra	WinLoop

SaveLevel
	lea	Temp(pc),a0
	move.b	#0,(a0)
	moveq.l	#0,d0
	bsr.b	AllocRequest
	move.l	d0,ReqPtr
	beq	Err_NoRequester
	lea	Rf01Tl(pc),a3
	move.l	#'Save',(a3)
	bsr.b	FileRequest
	tst.l	d0
	beq.b	.free
	lea	ReqPtr(pc),a1
	move.l	(a1),a1
	move.l	16(a1),a0
	lea	SaveFil(pc),a1
	bsr.b	ExtractPathFile
	bsr	SaveLevelFile
	lea	DiskOk(pc),a4
	move.l	#'save',5(a4)
	move.l	#'d ok',9(a4)
	move.l	#'.   ',13(a4)
	bsr	ShowMessage
.free	bsr.b	FreeRequest
	bra	WinLoop

ExtractPathFile
	movem.l	d0-d7/a0-a6,-(sp)
	clr.b	(a5)
.loopp	move.b	(a0)+,(a1)+
	bne.b	.loopp
	cmp.w	#$3a00,-(a1)	;":"0
	beq.b	.back
	move.b	(a1)+,(a5)
	move.b	#'/',(a1)+
	bra.b	.loopn
.back	move.b	(a1)+,(a5)
.loopn	move.b	(a2)+,(a1)+
	bne.b	.loopn
.exit	movem.l	(sp)+,d0-d7/a0-a6
	rts

AllocRequest
	move.l	ReqT_B(pc),a6
	move.w	#0,a0
	jmp	-$1e(a6)	;RtAllocRequestA(d0,a0)rt

FreeRequest
	move.l	ReqT_B(pc),a6
	move.l	ReqPtr(pc),a1
	jmp	-$24(a6)	;RtFreeRequest(a1)rt

FileRequest
	move.l	ReqT_B(pc),a6
	lea	Rf01T(pc),a0
	move.l	ReqPtr(pc),a1
	lea	Temp(pc),a2
	jmp	-$36(a6)	;RtFileRequestA(a1,a2,a3,a0)rt

GetFileSize
	move.l	Dos_B(pc),a6
	move.l	a0,d1
	moveq.l	#-2,d2
	jsr	-$54(a6)	;Lock(d1,d2)dos
	move.l	d0,FileLok
	beq.b	.quit
	move.l	Dos_B(pc),a6
	move.l	FileLok(pc),d1
	move.l	#NfoBlok,d2
	jsr	-$66(a6)	;Examine(d1/d2)dos
	tst.l	d0
	beq.b	.noinfo
	lea	NfoBlok,a0
	move.l	$7c(a0),-(sp)
.noinfo	move.l	Dos_B(pc),a6
	move.l	FileLok(pc),d1
	jsr	-$5a(a6)	;UnLock(d1)dos
	move.l	(sp)+,d0
.quit	rts

LoadLevelFile
	lea	LoadFil(pc),a1
	move.l	a1,d1
	move.l	#$3ed,d2
	bsr	Open
	move.l	d0,FilePtr
	beq	Err_DiskError
	move.l	d0,d1
	lea	Map(pc),a2
	move.l	a2,d2
	move.l	#656,d3
	bsr	Read
	move.l	FilePtr(pc),d1
	lea	Temp(pc),a2
	move.l	a2,d2
	moveq.l	#41,d3
	bsr	Read
	move.l	FilePtr(pc),d1
	lea	Moves(pc),a2
	move.l	a2,d2
	move.l	#"    ",(a2)
	move.l	FileLen(pc),d3
	bsr	Read
	move.l	FilePtr(pc),d1
	bsr	Close
	bsr	ShowMaxMoves
	rts

SaveLevelFile
	lea	SaveFil(pc),a1
	move.l	a1,d1
	move.l	#$3ee,d2
	bsr	Open
	move.l	d0,FilePtr
	beq.b	Err_DiskError
	move.l	d0,d1
	lea	Map(pc),a2
	move.l	a2,d2
	move.l	#697,d3
	bsr	Write
	move.l	FilePtr(pc),d1
	lea	Moves(pc),a2
	move.l	a2,d2
	move.l	FileLen(pc),d3
	bsr	Write
	move.l	FilePtr(pc),d1
	bsr	Close
	rts

Err_DiskError
	lea	DiskErr(pc),a4
	bsr	ShowMessage
	bra	WinLoop

SetMoves
	moveq.l	#5,d0		;type
	bsr	AllocRequest
	move.l	d0,ReqPtr
	beq.b	Err_NoRequester
	lea	Rl01T(pc),a0
	lea	MovesD(pc),a1
	bsr.b	GetLong
	lea	MovesD(pc),a1
	lea	Moves(pc),a0
	move.l	(a1),d1
	bsr.b	DecToAscii
	bsr	FreeRequest
	bra	WinLoop

GetLong
	move.l	ReqT_B(pc),a6
	move.w	#0,a2
	move.l	ReqPtr(pc),a3
	jmp	-$4e(a6)	;RtGetLongA(a1,a2,a3,a0)rt

Err_NoRequester
	lea	NoReqP(pc),a4
	bsr	ShowMessage
	bra	WinLoop

DecToAscii
	divu	#1000,d1
	bsr.b	.digit
	divu	#100,d1
	bsr.b	.digit
	divu	#10,d1
	bsr.b	.digit
	nop
.digit	add	#$30,d1
	move.b	d1,(a0)+
	clr	d1
	swap	d1
	rts

ShowMaxMoves
	lea	MovesIs(pc),a4
	lea	Moves(pc),a1
	move.l	#"    ",27(a4)
	move.l	(a1),27(a4)
	moveq.l	#11,d0
	moveq.l	#21,d1
	moveq.l	#40,d7
	bsr	PrintText
	rts

CheckMoveLeft
	cmp.w	#1,X_Pos
	ble	WinLoop
	bsr	UpdateCursor
	subq.w	#1,X_Pos
	bra.b	UpdateX_Pos

CheckMoveRight
	cmp.w	#40,X_Pos
	bge	WinLoop
	bsr.b	UpdateCursor
	addq.w	#1,X_Pos
	bra.b	UpdateX_Pos

CheckMoveUp
	cmp.w	#1,Y_Pos
	ble	WinLoop
	bsr.b	UpdateCursor
	subq.w	#1,Y_Pos
	bra.b	UpdateY_Pos

CheckMoveDown
	cmp.w	#16,Y_Pos
	bge	WinLoop
	bsr.b	UpdateCursor
	addq.w	#1,Y_Pos
	bra.b	UpdateY_Pos

UpdateX_Pos
	lea	MsgText(pc),a0
	addq.l	#2,a0
	move.w	X_Pos,d1
	bsr.b	ConvertCoords
	bsr.b	UpdateMessage
	bra.b	ContinueXY

UpdateY_Pos
	lea	MsgText(pc),a0
	addq.l	#7,a0
	move.w	Y_Pos,d1
	bsr.b	ConvertCoords
	bsr.b	UpdateMessage

ContinueXY
	bsr.b	UpdateCursor
	bra	WinLoop

ConvertCoords
	divu	#10,d1
	bsr.b	.digit
	nop
.digit	add	#$30,d1
	move.b	d1,(a0)+
	clr	d1
	swap	d1
	rts

UpdateCursor
	moveq.l	#-1,d0
	bsr.b	SetDrMd
	moveq.l	#3,d0
	bsr	SetAPen
	moveq.l	#0,d0
	bsr	SetBPen
	moveq.l	#0,d0
	moveq.l	#0,d1
	move.w	X_Pos(pc),d0
	bsr.b	CalculateX
	move.w	Y_Pos(pc),d1
	bsr.b	CalculateY
	move.l	d0,d2
	move.l	d1,d3
	bsr.b	ShowCursor
	moveq.l	#1,d0
	bsr	SetAPen
	move.l	Gfx_B(pc),a6
	move.l	RPort(pc),a1
	moveq.l	#1,d0
	bsr.b	SetDrMd
	rts

UpdateMessage
	lea	MsgText(pc),a4
	moveq.l	#11,d0
	moveq.l	#21,d1
	moveq.l	#40,d7
	bsr	PrintText
	rts

CalculateX
	mulu.w	#8,d0
	addq.w	#4,d0
	rts

CalculateY
	mulu.w	#8,d1
	add.w	#26,d1
	rts

ShowCursor
	lea	Crsr(pc),a4
	moveq.l	#1,d7
	bsr	PrintText
	rts

SetDrMd
	move.l	Gfx_B(pc),a6
	move.l	RPort(pc),a1
	jmp	-$162(a6)	;SetDrMd(a1,d0)gfx

EraseCharacter
	move.b	#32,d1
	bra.b	InsertCharacter

InsertUpper
	sub.b	#" ",d1

InsertCharacter
	move.w	d1,d7
	moveq.l	#0,d0
	move.w	Y_Pos(pc),d0
	mulu.w	#41,d0
	sub.w	#41,d0
	add.w	X_Pos(pc),d0
	subq.w	#1,d0
	lea	Map(pc),a0
	add.l	d0,a0
	move.b	d7,(a0)
	bsr	UpdateMap
	bra	WinLoop

ShowMessage
	moveq.l	#11,d0
	moveq.l	#21,d1
	moveq.l	#40,d7
	bsr	PrintText
	rts

Dos_L	dc.b	'dos.library',0
Intui_L	dc.b	'intuition.library',0
Gfx_L	dc.b	'graphics.library',0
ReqT_L	dc.b	'reqtools.library',0
Dos_B	dc.l	0
Intui_B	dc.l	0
Gfx_B	dc.l	0
ReqT_B	dc.l	0
FilePtr	dc.l	0
MsgPort	dc.l	0
RPort	dc.l	0
ReqPtr	dc.l	0
FileLok	dc.l	0
FileLen	dc.l	5
X_Pos	dc.w	1
Y_Pos	dc.w	1
WbMsg	dc.l	0
NoReqT	dc.b	'ERROR: Unable to open reqtools.library v37',$a
NoWin	dc.b	'ERROR: Unable to open the window',$a
WinDefs	dc.w	0,11			;x,y
	dc.w	499,161			;w,h
	dc.b	0,1			;detailPen,blockPen
	dc.l	$200040			;IDCMP:GADGETUP!VANILLAKEY
	dc.l	$11006			;WFLG:DRAGBAR!DEPTHGADGET!CLOSEGADGET!ACTIVATE!RMBTRAP
	dc.l	Gad01			;first gadget
	dc.l	0			;checkmark image
	dc.l	WinTitl			;Window title
	dc.l	0			;screen
	dc.l	0			;bitmap
	dc.w	50,20			;min w,min h
	dc.w	640,256			;max w,max h
	dc.w	1			;in workbench
WinTitl	dc.b	'Wanderer Level Editor by Ivan Oliver',0
WinPtr	dc.l	0
SmlFont	dc.l	TopazF,$80000
BigFont	dc.l	TopazF,$90000
TopazF	dc.b	'topaz.font',0
Gad01	dc.l	Gad02			;New
	dc.w	343,15,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	1
	dc.l	0
Gad02	dc.l	Gad03			;Load Level
	dc.w	343,27,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	2
	dc.l	0
Gad03	dc.l	Gad04			;Save Level
	dc.w	343,39,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	3
	dc.l	0
Gad04	dc.l	Gad05			;DISABLED
	dc.w	343,51,144,11
	dc.w	$103,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	4
	dc.l	0
Gad05	dc.l	Gad06			;DISABLED
	dc.w	343,63,144,11
	dc.w	$103,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	5
	dc.l	0
Gad06	dc.l	Gad07			;Set Moves
	dc.w	343,75,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	6
	dc.l	0
Gad07	dc.l	Gad08			;DISABLED
	dc.w	343,87,144,11
	dc.w	$103,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	7
	dc.l	0
Gad08	dc.l	Gad09			;Help
	dc.w	343,99,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	8
	dc.l	0
Gad09	dc.l	Gad10			;Level Info
	dc.w	343,111,144,11
	dc.w	$302,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	9
	dc.l	0
Gad10	dc.l	Gad11			;About
	dc.w	343,123,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	10
	dc.l	0
Gad11	dc.l	0			;Quit Editor
	dc.w	343,144,144,11
	dc.w	2,1,1
	dc.l	BdrUp3,BdrDn3,0,0,0
	dc.w	11
	dc.l	0
BdrUp3	dc.w	0,-1
	dc.l	$1020005,BdrUp3L,BdrUp4
BdrUp3L	dc.w	0,11, 143,11, 143,1, 142,2, 142,11
BdrUp4	dc.w	0,-1
	dc.l	$2010005,BdrUp4L,0
BdrUp4L	dc.w	142,1, 0,1, 0,11, 1,10, 1,1
BdrDn3	dc.w	0,-1
	dc.l	$2010005,BdrDn3L,BdrDn4
BdrDn3L	dc.w	0,11, 143,11, 143,1, 142,2, 142,11
BdrDn4	dc.w	0,-1
	dc.l	$1020005,BdrDn4L,0
BdrDn4L	dc.w	142,1, 0,1, 0,11, 1,10, 1,1
BoxA1	dc.w	8,12			;Message window
	dc.l	$2010005,BoxA1L,BoxA2
BoxA1L	dc.w	0,11, 326,11, 326,1, 325,2, 325,11
BoxA2	dc.w	8,12
	dc.l	$1020005,BoxA2L,0
BoxA2L	dc.w	325,1, 0,1, 0,11, 1,10, 1,1
BoxB1	dc.w	8,25			;Map window
	dc.l	$2010005,BoxB1L,BoxB2
BoxB1L	dc.w	0,131, 326,131, 326,1, 325,2, 325,131
BoxB2	dc.w	8,25
	dc.l	$1020005,BoxB2L,0
BoxB2L	dc.w	325,1, 0,1, 0,131, 1,130, 1,1
BoxC1	dc.w	339,12			;Gadgets window
	dc.l	$2010005,BoxC1L,BoxC2
BoxC1L	dc.w	0,144, 151,144, 151,1, 150,2, 150,144
BoxC2	dc.w	339,12
	dc.l	$1020005,BoxC2L,0
BoxC2L	dc.w	150,1, 0,1, 0,144, 1,143, 1,1
MsgText	dc.b	'X=01 Y=01 *=000 C=?                     '
MovesIs	dc.b	'Maximum number of moves is XXXX         '
DiskOk	dc.b	'File loaded ok.                         '
DiskErr	dc.b	'Problem accessing file                  '
NoReqP	dc.b	'Problem allocating ReqTools requester   '
Cleared	dc.b	'Here you are, have a nice empty level...'
GadText	dc.b	'NewLoad LevelSave LevelSet MovesHelpLevel InfoAboutQuit Editor'
Map	dc.b	'=======================\OOO*OOOO/#OO####',$a
	dc.b	'*O       O:#         O/ \OOOOOO/# ::A**#',$a
	dc.b	'# O #### #:#       **/   \OOOO/   ######',$a
	dc.b	'# #  O  *#:#              \OO/   ##    -',$a
	dc.b	'# #* * ###:# OOO           O/    ##    -',$a
	dc.b	'# ######:::#*****         :/  *###* O  -',$a
	dc.b	'#    #*                 @     *<*###*< -',$a
	dc.b	'#*#! ###                  \   *###*    -',$a
	dc.b	'###              !     ::  \     ##    -',$a
	dc.b	'# #          \ /=O=   ::::   \O     / O/',$a
	dc.b	'#*           O O  =    ::   / \*   / */-',$a
	dc.b	'###         #***# =        /   \    O/ -',$a
	dc.b	'X < !!!     #\*/# =       /    O*O*O*O -',$a
	dc.b	'>*   *   *<  # #  =      /     =**O*O= -',$a
	dc.b	'    !!!   ! !# #! =! \    /    =:O*O:= -',$a
	dc.b	'          ! *#T#*:::::\**/     =::::::*-',$a
	dc.b	'########################################',$a
Moves	dc.b	'1000',$a,0
Rq01T	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	$80000014,Rq01Tl	;RTEZ_REQTITLE
	dc.l	$80000016,4		;RTEZ_FLAGS (EZREQF_CENTERTEXT)
	dc.l	0			;End of taglist
Rq01Tl	dc.b	'About...',0
Rq01B	dc.b	'Wanderer Level Editor v1.00',$a
	dc.b	'by Ivan Oliver (01-Apr-98)',$a,$a
	dc.b	'Written using assembler',$a,$a
	dc.b	'Write to me at:',$a
	dc.b	'6 Bridgefield, Ottery St Mary',$a
	dc.b	'East Devon, EX11 1HL, ENGLAND',0
OkText	dc.b	'_Ok',0
Rq02T	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	$80000014,Rq02Tl	;RTEZ_REQTITLE
	dc.l	$80000017,0		;RTEZ_DEFAULTRESPONSE
	dc.l	0			;End of taglist
Rq02Tl	dc.b	'Quit...',0
RUSure	dc.b	'Are you sure ?',0
YesNo	dc.b	'_Yes|_No',0
Rq03T	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	$80000014,Rq03Tl	;RTEZ_REQTITLE
	dc.l	$80000017,0		;RTEZ_DEFAULTRESPONSE
	dc.l	0			;End of taglist
Rq03Tl	dc.b	'Help (Symbols)...',0
Rq03B	dc.b	'O  Boulder',$a
	dc.b	'<> Arrows',$a
	dc.b	'^  Balloon',$a
	dc.b	':  Earth',$a
	dc.b	'!  Bomb',$a
	dc.b	'*  Treasure',$a
	dc.b	'/\ Slopes',$a
	dc.b	'+  Cage',$a
	dc.b	'=# Rock',$a
	dc.b	'T  Teleport',$a
	dc.b	'A  Arrival (1 max)',$a
	dc.b	'X  Exit (always 1)',$a
	dc.b	'@  Start (always 1)',$a
	dc.b	'M  Big monster (1 max)',$a
	dc.b	'S  Baby monster',$a
	dc.b	'-  Alternative space',$a
	dc.b	'C  Time capsule',0
MoreXit	dc.b	'_More|_Cancel',0
Rq04T	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	$80000014,Rq04Tl	;RTEZ_REQTITLE
	dc.l	$80000017,0		;RTEZ_DEFAULTRESPONSE
	dc.l	0			;End of taglist
Rq04Tl	dc.b	'New...',0
Rf01Tl	dc.b	'ZBD! Level...',0
	even
LoadFil	dcb.b	255,0
SaveFil	dcb.b	255,0
Temp	dcb.b	255,0
Rf01T	dc.l	$8000000b,'_',$8000002a,OkText,0
Rq05T	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	$80000014,Rq05Tl	;RTEZ_REQTITLE
	dc.l	$80000017,0		;RTEZ_DEFAULTRESPONSE
	dc.l	0			;End of taglist
Rq05B	dc.b	'4  Left            6  Right',$a
	dc.b	'8  Up              2  Down',$a
	dc.b	'5  Erase           H  Help',$a
	dc.b	'N  New             L  Load Level',$a
	dc.b	'V  Save Level      E  Set Moves',$a
	dc.b	'I  Level Info      ?  About',$a
	dc.b	'Q  Quit Editor',$a,$a
	dc.b	'Press the key corresponding to',$a
	dc.b	'the desired symbol to insert it.',0
Rq05Tl	dc.b	'Help (Controls)...',0
Rl01T	dc.l	$80000022,AccCncl	;RTGS_GADFMT
	dc.l	$80000026,Rl01B		;RTGS_TEXTFMT
	dc.l	$80000016,4		;RTGS_FLAGS,GSREQF_CENTERTEXT
	dc.l	$8000000b,'_'		;RT_UNDERSCORE
	dc.l	0
MovesD	dc.l	1000
AccCncl	dc.b	'_Accept|_Cancel',0
Rl01B	dc.b	'Enter the number of moves:',0
Crsr	dc.b	'?'

	section	fib,data
	cnop	0,4

NfoBlok	dcb.b	260,0
	end

I knocked this up in a day before I realised that there were pull-down menus
telling me that there was an editor already built-in.  I hope you enjoy this
code even though I admit it's not been tidied up much - I didn't see much
point after using the built-in editor!

It assembles fine using DevPac (which I used to write it) and although I've
not been able to test it, it should work on Kickstart 1.3 upwards but the
only problem will arise with reqtools.library.

No external files are required during assembly.  I *HATE* includes!!!   :D

Zebedee.