*************************************************************************
*									*
*	S220to8SVX Version 1.4 is FREEWARE !!!				*
*	NO commercial use without written permission of the author	*
*									*
*	Copyright (c) 1991 Dieter Bruns					*
*	Lilienweg 131							*
*	W-2725 Hemsbünde						*
*	GERMANY								*
*									*
*	Assembler: Devpac Version 2.14D					*
*		   or A68K 						*
*									*
*************************************************************************

	IFND .A68K
	incdir	"sys:devpac/include/"	; FOR DEVPAC
	ENDC
	include	intuition/intuition.i
	include	arpbase.i
	include	hardware/custom.i


custom		equ	$dff000
rmb		equ	$dff016

aud1lc		equ	$b0
aud1len		equ	$b4
aud1per		equ	$b6
aud1vol		equ	$b8
aud0lc		equ	$a0
aud0len		equ	$a4
aud0per		equ	$a6
aud0vol		equ	$a8

IREQW		equ	240
IREQH		equ	40
GX		equ	20
GY		equ	27
XO		equ	20
YO		equ	160
PAPERXO		equ	XO
PAPERYO		equ	YO-33
PAPERXU		equ	533
PAPERYU		equ	YO+32
REQW		equ	210
REQH		equ	65
REQOFFX		equ	REQW-40
REQOFFY		equ	REQH-20
TX		equ	20
TY		equ	PAPERYO-50
blue		equ	0
white		equ	1
black		equ	2
orange		equ	3

NULL		equ	0

PRINTDEZ	MACRO
	movem.l	d0-d7/a0-a6,-(sp)
	move.l	\1,d2
	bsr	decl
	movem.l	(sp)+,d0-d7/a0-a6
		ENDM

RELOL	MACRO
	lea	\2(pc),a0
	move.l	\1,(a0)
	ENDM

RELOB	MACRO
	lea	\2(pc),a0
	move.b	\1,(a0)
	ENDM

RELOW	MACRO
	lea	\2(pc),a0
	move.w	\1,(a0)
	ENDM

	movem.l	d0/a0,-(sp)		;save Para
	sub.l	a1,a1
	move.l	4,a6
	jsr	-294(a6)		;FindTask
	move.l	d0,a2
	tst.l	$ac(a2)			;Process.pr_CLI
	beq.s	Workbench
; CLI
	movem.l	(sp)+,d0/a0		;CLI-Para
	bra	start
Workbench
	lea	$5c(a2),a0		;Process.pr_MsgPort
	jsr	-384(a6)		;WaitPort
	lea	$5c(a2),a0		;Process.pr_MsgPort
	jsr	-372(a6)		;GetMsg
	lea	WBmsg(pc),a0
	move.l	d0,(a0)			;save WBmsg
	movem.l	(sp)+,d0/a0
start
	bsr.s	_main			;Hauptprog.
	move.l	d0,-(sp)
	move.l	WBmsg(pc),d0
	beq.s	exit			;CLI-Start
	jsr	-132(a6)		;Forbid
	move.l	WBmsg(pc),a1
	jsr	-378(a6)		;ReplyMsg
exit
	move.l	(sp)+,d0
	rts

_main
	move.l	#custom,a5
	move.l	4,a6
	lea	arpname(pc),a1
	moveq	#ArpVersion,d0
	jsr	-552(a6)		;OpenLibrary
	lea	_ArpBase(pc),a0
	move.l	d0,(a0)+
	beq	arpfailed
	move.l	d0,a1

	move.l	IntuiBase(a1),(a0)+
	move.l	DosBase(a1),(a0)+
	move.l	GfxBase(a1),(a0)

	bsr	getmem
	tst.l	d0
	beq	memfailed

	lea	NewWindowStructure1(pc),a0
	lea	_IntuitionBase(pc),a1
	move.l	(a1),a6
	jsr	-204(a6)		;OpenWindow
	tst.l	d0
	beq	windowfailed
	lea	FirstWindow(pc),a0
	move.l	d0,(a0)
	move.l	d0,a0

	lea	WScreen(pc),a1
	move.l	46(a0),(a1)
	lea	Port(pc),a1
	move.l	wd_UserPort(a0),(a1)
	move.l	wd_RPort(a0),a0
	move.l	a0,a4
	lea	LogoImage(pc),a1
	move.w	#0,d0
	move.w	#0,d1
	jsr	-114(a6)		;DrawImage

	move.w	#0,d0
	move.w	#0,d1
	move.l	a4,a0
	lea	PlayText(pc),a1
	jsr	-216(a6)		;PrintItext
	bsr	balken
	bsr	paper

event
	move.l	4,a6
	move.l	Port(pc),d2
	move.l	d2,a0
	jsr	-384(a6)		;WaitPort
	move.l	d2,a0
	jsr	-372(a6)		;GetMsg
	move.l	d0,a1			;for ReplyMsg
	move.l	im_Class(a1),d4
	move.l	im_IAddress(a1),a2	;grab the potential Gadget address
	move.w	gg_GadgetID(a2),d3
	move.w	im_Code(a1),d5		;Code for MOUSEBUTTONS
	jsr	-378(a6)		;ReplyMsg

	cmpi.l	#GADGETUP,d4
	beq	gadget

	cmpi.l	#GADGETDOWN,d4
	beq	gadget

	cmpi.l	#CLOSEWINDOW,d4
	beq	closewindow

	cmpi.l	#MOUSEBUTTONS,d4
	bne	event

	cmpi.w	#MENUUP,d5		;rmb released
	beq	doplay
	bra	event

gadget
	move.l	40(a2),a0
	jmp	(a0)

closewindow
	lea	errornr(pc),a0
	move.l	#0,(a0)
	bra	ende

getmem
	move.l	#67584,d0
	move.l	#$10000,d1
	jsr	-198(a6)		;AllocMem
	tst.l	d0
	beq	fail
	lea	bu(pc),a0
	move.l	d0,(a0)

	move.l	#131072,d0
	move.l	#$02+$10000,d1
	jsr	-198(a6)		;AllocMem
	tst.l	d0
	beq	fail
	lea	conw(pc),a0
	move.l	d0,(a0)

	move.l	#131072,d0
	move.l	#$10000,d1
	jsr	-198(a6)		;AllocMem
	tst.l	d0
	beq	fail
	lea	undo(pc),a0
	move.l	d0,(a0)
fail
	rts

loadgadget
	lea	fchar(pc),a0
	move.b	#0,(a0)
	lea	gethead(pc),a0
	bsr	_filereq
	tst.l	d0
	beq	event
	lea	filename(pc),a0
	move.l	d0,(a0)
	bsr	readsample
	tst.l	d0
	bne	event

	lea	type(pc),a0
	move.b	(a0),d0

	cmp.b	#3,d0
	ble	stru1

	cmp.b	#5,d0
	ble	stru2

	cmp.b	#6,d0
	ble	stru4

	cmp.b	#8,d0
	ble	stru2

	cmp.b	#10,d0
	ble	stru4

stru1
	RELOL	#32768,conlen
	RELOW	#6,step
	RELOW	#64,multi
	RELOW	#16,shift
	RELOW	#1,add
	moveq	#0,d4
	bra	make
stru2
	RELOL	#65536,conlen
	RELOW	#7,step
	RELOW	#128,multi
	RELOW	#32,shift
	RELOW	#1,add
	moveq	#1,d4
	bra	make
stru4
	RELOL	#131072,conlen
	RELOW	#8,step
	RELOW	#256,multi
	RELOW	#64,shift
	RELOW	#1,add
	moveq	#3,d4
make
	bsr	OpenMessage
	move.l	conw(pc),a2
	RELOL	#0,samplestart
	lea	conlen(pc),a1
	RELOL	(a1),sampleend
	RELOL	(a1),undoconlen
	RELOL	#0,sampleend
	RELOW	#PAPERXO,oldstartd4
	RELOW	#512+PAPERXO+2,oldendd4
	RELOB	#0,from30to15
doit
	RELOL	#0,counter
	move.l	file(pc),d1
	move.l	bu(pc),d2
	move.l	len(pc),d3
	move.l	_DOSBase(pc),a6
	jsr	-42(a6)			;Read
	cmp.l	d3,d0
	bne	Req2
	move.l	bu(pc),a0
cont
	move.l	#4,d0
	move.l	#63,d1
convertloop
	moveq	#0,d2
	move.b	3(a0),d2
	lsl.l	#5,d2
	lea	ber(pc),a1
	move.l	d2,(a1)
	moveq	#0,d2
	move.b	4(a0),d2
	lsr.b	#2,d2
	or.l	d2,(a1)
	move.l	ber(pc),d2
	asr.w	d0,d2
	move.b	d2,(a2)+
	add.l	#2,a0
	dbra	d1,convertloop

	lea	counter(pc),a1
	add.l	#132,(a1)
	move.l	counter(pc),d0
	cmp.l	len(pc),d0
	bge	done
	add.l	#4,a0
	bra	cont
done
	dbra	d4,doit

makeundo
	move.l	conlen(pc),d4
	move.l	conw(pc),a0
	move.l	undo(pc),a1
1$	move.b	(a0)+,(a1)+
	sub.l	#1,d4
	beq	undodone
	bra	1$
undodone
	move.l	_DOSBase(pc),a6
	move.l	file(pc),d1
	lea	wavepara(pc),a0
	move.l	a0,d2
	move.l	#$30,d3
	jsr	-42(a6)			;Read
	cmp.l	d3,d0
	bne	Req2
	lea	wavepara(pc),a0		;for filename
	addq.l	#3,a0			;offset
	moveq	#8,d1
	lea	samplename(pc),a1
copy
	move.b	(a0)+,(a1)+
	dbra	d1,copy
	move.b	#0,(a1)

	lea	sname(pc),a1
	lea	samplename(pc),a0
	moveq	#8,d0
1$
	move.b	(a0)+,(a1)+
	dbra	d0,1$

	lea	samplename(pc),a0
	moveq	#9,d0
	move.b	#0,0(a0,d0)
filtspace
	cmp.b	#32,0(a0,d0)
	beq	addnull
	bgt	switch3015
t2
	dbra	d0,filtspace
	bra	switch3015
addnull
	move.b	#0,0(a0,d0)
	bra	t2

switch3015
	lea	wavepara(pc),a0
	moveq	#0,d2
	moveq	#0,d0
	move.b	$10(a0),d2
	move.b	$11(a0),d0
	rol	#4,d0
	or.w	d0,d2
	sub.w	#$18,d2
	lea	tnr(pc),a1
	move.l	d2,(a1)
	move.b	$E(a0),d0
	move.l	d0,d2
	btst	#0,d0
	beq	dosamp30
	RELOB	#0,loaded30
	bsr	data15
	bra	contswitch
dosamp30
	RELOB	#1,loaded30
	bsr	data30
contswitch
	lea	reckey(pc),a0
	move.l	tnr(pc),d1
	lsl.l	#2,d1
	add.l	d1,a0
	move.l	#3,d1
	lea	tonenrtext(pc),a1
1$
	move.b	(a0)+,(a1)+
	dbra	d1,1$

	bsr	prep
	lea	rkey(pc),a1
	jsr	-216(a6)		;PrintItext

	lea	nameItexttext(pc),a1
	moveq	#8,d0
3$
	move.b	#32,(a1)+
	dbra	d0,3$

	lea	samplename(pc),a0
	lea	nameItexttext(pc),a1
	moveq	#8,d0
2$
	move.b	(a0)+,(a1)+
	tst.b	(a0)
	dbeq	d1,2$
	bsr	prep
	lea	nameItext(pc),a1
	jsr	-216(a6)		;PrintItext

	move.l	file(pc),d1
	move.l	_DOSBase(pc),a6
	jsr	-36(a6)			;Close
	move.l	#0,d0
	RELOB	#1,sound

	lea	VolumeGadget1SIBuff(pc),a0
	move.w	#"10",(a0)+
	move.b	#"0",(a0)
	lea	Volumepropgad1SInfo(pc),a0
	move.w	#6600,2(a0)
	lea	multiVolume(pc),a0
	move.l	#100,(a0)

	lea	Startgad(pc),a0
	move.w	#PAPERXO-SEGW,4(a0)
	lea	Endgad(pc),a0
	move.w	#PAPERXU,4(a0)

	bsr	CloseMessage
	bsr	drawloop
	bra	event

undoVolume
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	move.l	undoconlen(pc),d4
	bsr	OpenMessage
	move.l	undo(pc),a0
	move.l	conw(pc),a1
1$
	move.b	(a0)+,(a1)+
	sub.l	#1,d4
	beq	2$
	bra	1$
2$
	lea	VolumeGadget1SIBuff(pc),a0
	move.w	#"10",(a0)+
	move.b	#"0",(a0)
	lea	Volumepropgad1SInfo(pc),a0
	move.w	#6600,2(a0)
	lea	multiVolume(pc),a0
	move.l	#100,(a0)
	bsr	CloseMessage
	move.b	from30to15(pc),d0
	beq	3$
	bsr	data1530
	bra	c3015
3$
	bsr	drawloop
	bra	event

drawloop
	move.l	conw(pc),a2
	move.w	multi(pc),d7
	move.w	shift(pc),d5
	move.l	conlen(pc),d4
	moveq	#XO+1,d6
	bsr	paper
nextdraw
	sub.l	#1,d4
	beq     fillstartend
	move.b	(a2)+,d2
	sub.w	#1,d7
	bne	nodraw
	add.w	add(pc),d6
	move.w	multi(pc),d7
nodraw
	asr.b	#2,d2
	and.b	#$FF,d2
	ext.w	d2
	move.w	#YO,d1
	add.w	d2,d1
	sub.w	#1,d5
	bne	nextdraw
	move.w	shift(pc),d5
	move.l	a4,a1
	move.w	d6,d0
	jsr	-246(a6)		;Draw
	bra	nextdraw
fillstartend
	move.l	a4,a1
	bclr	#3,33(a1)		;NOAREAOUTLINE
	move.w	#2,d0			;COMPLEMENT
	jsr	-354(a6)		;SetDrMd
	move.l	a4,a1
	move.w	#blue,d0
	jsr	-342(a6)		;SetAPen

	lea	Endgad(pc),a0
	move.w	4(a0),d0
	move.w	#PAPERYO,d1		;yo
	move.w	#PAPERXU,d2		;xu
	cmp.w	d0,d2
	beq	senofill1
	move.w	#PAPERYU,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill
senofill1
	lea	Startgad(pc),a0
	move.w	4(a0),d2
	add.w	#SEGW,d2
	move.l	a4,a1
	move.w	#PAPERXO,d0		;xo
	cmp.w	d0,d2
	beq     newstartend
	move.w	#PAPERYO,d1		;yo
	move.w	#PAPERYU,d3		;yu
	jsr	-306(a6)		;RectFill
newstartend
	lea	samplestart(pc),a0
	move.l	(a0),d0
	PRINTDEZ d0
	lea	StartGadgetSIBuff(pc),a1
	lea	buffer(pc),a0
	moveq	#6,d0
1$
	move.b	(a0)+,(a1)+
	dbra	d0,1$

	lea	conlen(pc),a0
	move.l	(a0),d0
	sub.l	sampleend(pc),d0

	PRINTDEZ d0
	lea	EndGadgetSIBuff(pc),a1
	lea	buffer(pc),a0
	moveq	#6,d0
2$
	move.b	(a0)+,(a1)+
	dbra	d0,2$
	bra	balken			;(bsr rts)

drawstart
	move.l	_GfxBase(pc),a6
	move.l	a4,a1
	bclr	#3,33(a1)		;NOAREAOUTLINE
	move.w	#2,d0			;COMPLEMENT
	jsr	-354(a6)
	move.l	a4,a1
	move.w	#blue,d0
	jsr	-342(a6)		;SetAPen

	moveq	#0,d0
	move.w	step(pc),d0
	move.l	samplestart(pc),d4
	lsr.l	d0,d4
	add.w	#PAPERXO,d4

	move.l	a4,a1
	move.w	#PAPERXO,d0		;xo
	move.w	#PAPERYO,d1		;yo
	move.w	oldstartd4(pc),d2	;xu
	cmp.w	d0,d2
	beq	snofill1
	move.w	#PAPERYU,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill
snofill1
	move.l	a4,a1
	move.w	#PAPERXO,d0		;xo
	move.w	#PAPERYO,d1		;yo
	move.w	d4,d2			;xu
	cmp.w	d0,d2
	beq	snofill2
	move.w	#PAPERYU,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill
snofill2
	RELOW	d4,oldstartd4
	rts

data1530
	move.w	step(pc),d0
	addq	#1,d0
	RELOW	d0,step
	lea	samplestart(pc),a0
	move.l	(a0),d0
	asl.l	#1,d0
	move.l	d0,(a0)
	lea	conlen(pc),a0
	move.l	(a0),d0
	asl.l	#1,d0
	move.l	d0,(a0)
	lea	sampleend(pc),a0
	move.l	(a0),d0
	asl.l	#1,d0
	move.l	d0,(a0)
	rts

data3015
	move.w	step(pc),d0
	subq	#1,d0
	RELOW	d0,step
	lea	samplestart(pc),a0
	move.l	(a0),d0
	asr.l	#1,d0
	move.l	d0,(a0)
	lea	conlen(pc),a0
	move.l	(a0),d0
	asr.l	#1,d0
	move.l	d0,(a0)
	lea	sampleend(pc),a0
	move.l	(a0),d0
	asr.l	#1,d0
	move.l	d0,(a0)
	bra	data15			;bsr rts

drawend
	move.l	_GfxBase(pc),a6
	move.l	a4,a1
	bclr	#3,33(a1)		;NOAREAOUTLINE
	move.w	#2,d0			;COMPLEMENT
	jsr	-354(a6)
	move.l	a4,a1
	move.w	#blue,d0
	jsr	-342(a6)		;SetAPen
	moveq	#0,d0
	move.w	step(pc),d0
	move.l	conlen(pc),d1
	sub.l	sampleend(pc),d1
	lsr.l	d0,d1
	move.w	d1,d4
	add.w	#PAPERXO+1,d4

	move.w	oldendd4(pc),d0		;xo
	move.w	#PAPERYO,d1		;yo
	move.w	#PAPERXU,d2		;xu
	cmp.w	d0,d2
	beq	enofill1
	move.w	#PAPERYU,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill
enofill1
	move.w	d4,d0			;xo
	move.w	#PAPERYO,d1		;yo
	move.w	#PAPERXU,d2		;xu
	cmp.w	d0,d2
	beq	enofill2
	move.w	#PAPERYU,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill
enofill2
	RELOW	d4,oldendd4
	rts

adjustVolume
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	lea	Volumerequester(pc),a0
	move.w	28(a0),d0
	btst	#13,d0
	bne	event
	move.l	FirstWindow(pc),a1
	move.l	_IntuitionBase(pc),a6
	jsr	-240(a6)		;Request
	bra	event

propVolume
	move.l	a4,-(sp)
	lea	Volumepropgad1SInfo(pc),a3
	lea	Volumepropgad(pc),a4
	lea	13(a4),a4		;GADGET Flags
propagain
	moveq	#0,d0
	move.w	2(a3),d0
	divu	#66,d0
	and.l	#$0000ffff,d0
	lea	multiVolume(pc),a0
	move.l	d0,(a0)
	bsr	multiupdate
	btst	#7,(a4)
	bne	propagain
	move.l	(sp)+,a4
	bra	event

minus1Volume
	moveq	#-1,d0
	bra	dopmVolume
plus1Volume
	moveq	#1,d0
dopmVolume
	lea	multiVolume(pc),a1
	add.l	d0,(a1)
	move.l	(a1),d0
	RELOL	#0,min
	RELOL	#992,max
	jsr	minmax
	move.l	d0,(a1)
	move.l	d0,d1
	cmp.w	#992,d0
	bne	notfull
	move.w	#$FFFF,d1
	bra	setfull
notfull
	mulu	#66,d1
setfull
	lea	Volumepropgad1SInfo(pc),a0
	move.w	d1,2(a0)
	bsr	multiupdate

	lea	Volumepropgad(pc),a0
	move.l	FirstWindow(pc),a1
	sub.l	a2,a2
	moveq	#1,d0
	jsr	-432(a6)		;RefreshGList
	bra	event

multiupdate
	PRINTDEZ d0
	lea	buffer(pc),a0
	lea	4(a0),a0
	lea	VolumeGadget1SIBuff(pc),a1
	moveq	#2,d0
1$
	move.b	(a0)+,(a1)+
	dbra	d0,1$

	move.l	_IntuitionBase(pc),a6
	lea	VolumeGadget1(pc),a0
	move.l	FirstWindow(pc),a1
	sub.l	a2,a2
	moveq	#1,d0
	jsr	-432(a6)		;RefreshGList
	rts

doadjustVolume
	bsr	OpenMessage
	move.l	undoconlen(pc),d4
	move.l	conw(pc),a2
	move.l	undo(pc),a1
	move.l	multiVolume(pc),d1
Volumeloop
	sub.l	#1,d4
	beq	Volumedone
	move.b	(a1)+,d2
	ext.w	d2
	muls	d1,d2
	divs	#100,d2
	cmp.w	#127,d2
	ble	notovermax
	move.w	#127,d2
notovermax
	cmp.w	#-128,d2
	bgt	notovermin
	move.w	#-128,d2
notovermin
	move.b	d2,(a2)+
	bra	Volumeloop
Volumedone
	bsr	CloseMessage
	move.b	from30to15(pc),d0
	beq	1$
	bsr	data1530
	bra	c3015
1$
	bsr	drawloop
	bra	event

c30_to_15
	move.b	loaded30(pc),d0
	beq	Req3
	lea	samplefreq(pc),a0
	cmp.l	#$7530,(a0)
	bne	c1530
c3015
	move.l	conlen(pc),d0
	move.l	conw(pc),a0
	move.l	a0,a1
	subq	#1,d0
1$
	move.b	(a0),(a1)+
	addq	#2,a0
	dbra	d0,1$

	bsr	data3015

	RELOB	#1,from30to15
	RELOW	#2,add
	bsr	drawloop
	bra	event

c1530
	bsr	data1530
	move.l	conlen(pc),d0
	move.l	conw(pc),a1
	move.l	undo(pc),a0
	subq	#1,d0
1$
	move.b	(a0)+,(a1)+
	dbra	d0,1$

	bsr	data30

	RELOB	#0,from30to15
	RELOW	#1,add
	bsr	drawloop
	bra	event

Req3
	lea	ReqText3(pc),a1
	bsr	showreq
	bra	event

data15
	bsr	prep
	lea	srate15(pc),a1
	jsr	-216(a6)		;PrintItext
	lea	per(pc),a0
	move.w	#248,(a0)
	lea	rate(pc),a0
	move.w	#$3a98,(a0)
	lea	samplefreq(pc),a0
	move.l	#$3a98,(a0)
	rts

data30
	bsr	prep
	lea	srate30(pc),a1
	jsr	-216(a6)		;PrintItext
	lea	per(pc),a0
	move.w	#124,(a0)
	lea	rate(pc),a0
	lea	samplefreq(pc),a1
	move.l	#$7530,(a1)
	move.w	#$7530,(a0)
	rts

headerdata
	move.l	conlen(pc),d0
	sub.l	samplestart(pc),d0
	sub.l	sampleend(pc),d0
	lea	bodylen(pc),a0
	move.l	d0,4(a0)
	add.l	#$90,d0
	lea	header(pc),a0
	move.l	d0,4(a0)
	move.l	conlen(pc),d0
	sub.l	samplestart(pc),d0
	sub.l	sampleend(pc),d0
	lea	shotlen(pc),a0
	move.l	d0,(a0)

	lea	frequenz(pc),a0
	move.l	tnr(pc),d1
	lsl.l	#1,d1
	add.l	d1,a0
	lea	tonefreq(pc),a1
	move.w	(a0),(a1)
	move.l	samplefreq(pc),d0
	moveq	#0,d1
	move.w	tonefreq(pc),d1
	divu	d1,d0
	and.l	#$00ff,d0
	move.l	d0,d2
	lea	hicycle(pc),a0
	move.l	d0,(a0)
	rts

prep
	move.w	#0,d0
	move.w	#0,d1
	lea	_IntuitionBase(pc),a0
	move.l	(a0),a6
	move.l	FirstWindow(pc),a1
	move.l	a4,a0
	rts

save8SVX
	lea	samplename(pc),a0
	lea	fchar(pc),a1
	moveq	#8,d0
1$
	move.b	(a0)+,(a1)+
	tst.b	(a0)
	dbeq	d0,1$
	move.b	#0,(a1)

	lea	fchar(pc),a0
	bsr	getlen
	sub.l	#1,a0
	move.b	#".",(a0)+
	move.b	#"8",(a0)+
	move.b	#"S",(a0)+
	move.b	#"V",(a0)+
	move.b	#"X",(a0)+
	move.b	#0,(a0)

	lea	savehead(pc),a0
	bsr	_filereq
	tst.l	d0
	beq	event
	lea	filename(pc),a0
	move.l	d0,(a0)
	bsr	savesample
	bra	event

doplay
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4
play
	move.w	#$0180,intreq(a5)
	move.w	#$000f,dmacon(a5)
	lea	aud1lc(a5),a0
	move.l	conw(pc),d0
	add.l	samplestart(pc),d0
	move.l	d0,(a0)
	lea	aud0lc(a5),a0
	move.l	d0,(a0)
	move.l	conlen(pc),d1
	sub.l	samplestart(pc),d1
	sub.l	sampleend(pc),d1
	beq	event
	lsr.l	#1,d1
	RELOW	d1,audlen
	move.w	audlen(pc),aud1len(a5)
	move.w	#64,aud1vol(a5)
	move.w	per(pc),aud1per(a5)

	move.w	audlen(pc),aud0len(a5)
	move.w	#64,aud0vol(a5)
	move.w	per(pc),aud0per(a5)

	move.w	#$00ff,adkcon(a5)	;Modulation off
	move.w	#$8203,dmacon(a5)	;Kanal 1 on
wait
	btst	#8,intreqr(a5)		;audio1 set ?
	beq	wait
	move.w	#$0180,intreq(a5)
1$
	move.w	#$0f00,$dff186		;Color03 ROT
	btst	#10,rmb
	beq	3$
	btst	#8,intreqr(a5)		;audio1 set ?
	beq	1$
3$
	move.w	#$0003,dmacon(a5)	;Kanal 1 off
	bra	event

Req4
	lea	ReqText4(pc),a1
	bsr	showreq
	bra	event

memfailed
	RELOL	#1,errornr
	bra	ende
windowfailed
	RELOL	#2,errornr
	bra	ende
requesterfailed
	RELOL	#3,errornr
	bra	ende
arpfailed
	move.l	4,a6
	lea	intname(pc),a1
	moveq	#0,d0
	jsr	-552(a6)		;OpenLibrary
	lea	_IntuitionBase(pc),a0
	move.l	d0,(a0)
	RELOL	#4,errornr
ende
	move.l	errornr(pc),d0
	bne	dispalert
closeall
	move.l	FirstWindow(pc),d0
	beq	nowclose
	move.l	#0,a1
	move.l	_ArpBase(pc),a6
	move.l	d0,a0
	jsr	_LVOCloseWindowSafely(a6) ;CloseWindow
nowclose
	move.l	4,a6
	move.l	_ArpBase(pc),d0
	beq	bigfail
	move.l	d0,a1
	jsr	-414(a6)		;CloseLibrary

	move.l	bu(pc),d0
	beq	no1
	move.l	bu(pc),a1
	move.l	#67584,d0
	jsr	-210(a6)		;FreeMem
no1
	move.l	conw(pc),d0
	beq	no2
	move.l	conw(pc),a1
	move.l	#131072,d0
	jsr	-210(a6)		;FreeMem
no2
	move.l	undo(pc),d0
	beq	bigfail
	move.l	undo(pc),a1
	move.l	#131072,d0
	jsr	-210(a6)		;FreeMem
bigfail
	moveq	#0,d0
	rts

dispalert
	lea	_IntuitionBase(pc),a0
	move.l	(a0),d0
	beq	closeall
	move.l	d0,a6
	lea	Alertstring(pc),a0
	move.l	#Alertlen,d2
	move.l	errornr(pc),d1
	subq.l	#1,d1
	mulu	d1,d2
	add.l	d2,a0
	move.w	#80,d1
	moveq	#0,d0
	jsr	-90(a6)			;DisplayAlert
	bra	closeall

readsample
	move.l	_DOSBase(pc),a6
	move.l	filename(pc),d1
	move.l	#1005,d2
	jsr	-30(a6)			;Open
	lea	file(pc),a0
	move.l	d0,(a0)
	beq	Req2

	move.l	d0,d1
	lea	ctrl(pc),a0
	move.l	a0,d2
	moveq	#7,d3
	move.l	_DOSBase(pc),a6
	jsr	-42(a6)			;Read
	cmp.l	d3,d0
	bne	Req2
	lea	ctrlname(pc),a1
	bsr	comp
	tst.l	d0
	beq	s220
	lea	ctrlnames10(pc),a1
	bsr	comp
	tst.l	d0
	bne	Req1
s220
	move.l	file(pc),d1
	lea	type(pc),a0
	move.l	a0,d2
	moveq	#1,d3
	move.l	_DOSBase(pc),a6
	jsr	-42(a6)			;Read
	cmp.l	d0,d3
	bne	Req2
	move.l	#0,d0
	rts

Req1
	move.l	file(pc),d1
	jsr	-36(a6)			;Close
	lea	ReqText1(pc),a1
	bsr	showreq
	moveq	#1,d0
	rts

Req2
	lea	ReqText2(pc),a1
	bsr	showreq
	move.l	file(pc),d0
	bne	closefile
cReq2
	moveq	#1,d0
	rts
closefile
	move.l	_DOSBase(pc),a6
	move.l	file(pc),d1
	jsr	-36(a6)			;Close
	bra	cReq2

savesample
	bsr	headerdata
	move.l	_DOSBase(pc),a6
	move.l	filename(pc),d1
	move.l	#1006,d2
	jsr	-30(a6)			;Open
	tst.l	d0
	beq	wopenf
	lea	file(pc),a0
	move.l	d0,(a0)

	move.l	file(pc),d1
	lea	header(pc),a0
	move.l	a0,d2
	move.l	#headersize,d3
	jsr	-48(a6)			;Write
	cmp.l	d3,d0
	bne	writefail

	move.l	file(pc),d1
	move.l	conw(pc),d2
	add.l	samplestart(pc),d2
	move.l	conlen(pc),d3
	sub.l	samplestart(pc),d3
	sub.l	sampleend(pc),d3
	jsr	-48(a6)			;Write
	cmp.l	d3,d0
	bne	writefail

writefail
	move.l	file(pc),d1
	jsr	-36(a6)			;Close
	moveq	#0,d0
	rts
wopenf
	move.l	#1,d0
	rts
comp
	lea	ctrl(pc),a0
	moveq	#6,d0
h1
	cmp.b	(a0)+,(a1)+
	bne	diff
	dbra	d0,h1
	moveq	#0,d0
	rts
diff
	moveq	#1,d0
	rts

showreq
	lea	_IntuitionBase(pc),a0
	move.l	(a0),a6
	lea	Messreq(pc),a0
	move.l	a1,24(a0)

	move.w	#1,-(sp)
	move.l	FirstWindow(pc),a1
	move.l	a1,-(sp)
	move.w	#REQOFFY,-(sp)		;offy
	move.w	#REQOFFX,-(sp)		;offx
	move.w	#REQH+3,-(sp)		;reqy
	move.w	#REQW+5,-(sp)		;reqx
	bsr	mousetest
	add.l	#14,sp

	move.w	d0,4(a0)
	move.w	d1,6(a0)
	move.w	28(a0),d0
	btst	#13,d0
	bne	reqret
	move.l	FirstWindow(pc),a1
	jsr	-240(a6)		;Request
reqret
	rts

_filereq
	lea	freq(pc),a1
	move.l	a0,(a1)
	move.l	_ArpBase(pc),a6
	lea	freq(pc),a0
	move.b	#%00001000,16(a0)
	move.l	FirstWindow(pc),12(a0)
	jsr	_LVOFileRequest(a6)
	tst.l	d0
	beq	retnull
	bsr	_build
	lea	fchar(pc),a0
	move.b	#0,(a0)
	lea	filetext(pc),a0
	move.b	(a0),d0
	beq.b	retnull
	move.l	a0,d0
	rts
retnull
	moveq	#0,d0
	rts

_build
	lea	dchar(pc),a0
	bsr	getlen			;get len directory
	lea	filetext(pc),a1
	tst.l	d0
	beq	done2
	lea	dchar(pc),a0
	lea	filetext(pc),a1
cp
	move.b	(a0)+,(a1)+
	dbra	d0,cp
	cmp.b	#':',-2(a1)		;subdirectory ?
	beq	done1			;no
	move.b	#'/',-1(a1)		;add /
	bra	done2
done1
	subq.l	#1,a1
done2
	lea	fchar(pc),a0
	bsr	getlen
	lea	fchar(pc),a0
paste
	move.b	(a0)+,(a1)+
	dbra	d0,paste
	rts

getlen
	moveq	#0,d0
w1
	cmp.b	#0,(a0)+
	beq	1$
	addq.l	#1,d0
	bra	w1
1$
	rts

paper
	move.l	_GfxBase(pc),a6
	move.l	a4,a1
	move.w	#0,d0			;JAM1
	jsr	-354(a6)

	move.l	a4,a1
	move.b	#black,27(a1)		;OPen
	bset	#3,33(a1)		;AREAOUTLINE
	move.w	#white,d0
	jsr	-342(a6)		;SetAPen
	move.w	#PAPERXO-1,d0		;xo
	move.w	#PAPERYO-1,d1		;yo
	move.w	#PAPERXU+1,d2		;xu
	move.w	#PAPERYU+1,d3		;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill

	move.l	a4,a1
	move.w	#black,d0
	jsr	-342(a6)		;SetAPen

	move.l	a4,a1
	move.w	#XO,d0
	move.w	#YO,d1
	jsr	-240(a6)		;Move Nullpkt.

	move.l	a4,a1
	move.w	#PAPERXU,d0
	move.w	#YO,d1
	jsr	-246(a6)		;Draw

	move.l	a4,a1
	move.w	#XO,d0
	move.w	#YO,d1
	jsr	-240(a6)		;Move Nullpkt.

	move.l	a4,a1
	move.w	#orange,d0
	jsr	-342(a6)		;SetAPen
	rts

OpenMessage
	lea	InfoReq(pc),a0
	move.w	28(a0),d1
	btst	#13,d1
	bne	ret1

	move.l	FirstWindow(pc),a1
	move.l	_IntuitionBase(pc),a6
	jsr	-240(a6)		;Request
	tst.l	d0
	beq	ret1
	RELOB	#1,closereq
ret1
	rts


CloseMessage
	move.b	closereq(pc),d0
	beq	ret2
	lea	InfoReq(pc),a0
	move.l	FirstWindow(pc),a1
	move.l	_IntuitionBase(pc),a6
	jsr	-120(a6)		;EndRequest
ret2
	RELOB	#0,closereq
	rts

mousetest
	movem.l	a0/a1/d2/d3/d4,-(sp)

	RELOW	24(sp),reqw
	RELOW	26(sp),reqh
	RELOW	28(sp),offx
	RELOW	30(sp),offy
	move.l	32(sp),a1
	RELOW	36(sp),flag
	move.w	flag(pc),d0
	beq	screen

	move.w	14(a1),d0		;MouseX
	move.w	12(a1),d1		;MouseY
	move.w	8(a1),d2		;WindowW
	move.w	10(a1),d3		;WindowH
	bra	mdoit
screen
	move.w	18(a1),d0		;MouseX
	move.w	16(a1),d1		;MouseY
	move.w	12(a1),d2		;WindowW
	move.w	14(a1),d3		;WindowH
mdoit
	sub.w	d0,d2
	move.w	reqw(pc),d4
	sub.w	offx(pc),d4
	cmp.w	d4,d2
	blt	corx
bcorx
	sub.w	d1,d3
	move.w	reqh(pc),d4
	sub.w	offy(pc),d4
	cmp.w	d4,d3
	blt	cory
bcory
	bra	makeoff
corx
	move.w	flag(pc),d0
	beq	getscreenW
	move.w	8(a1),d0		;WindowW
	bra	mcont1
getscreenW
	move.w	12(a1),d0		;ScreenW
mcont1
	sub.w	d4,d0
	bra	bcorx
cory
	move.w	flag(pc),d0
	beq	getscreenH
	move.w	10(a1),d1		;WindowH
	bra	mcont2
getscreenH
	move.w	14(a1),d1		;ScreenH
mcont2
	sub.w	d4,d1
	bra	bcory

makeoff
	sub.w	offx(pc),d0
	bmi	negx
bnegx
	sub.w	offy(pc),d1
	bmi	negy
	bra	mback
negx
	move.w	#0,d0
	bra	bnegx
negy
	move.w	#0,d1
mback
	movem.l	(sp)+,a0/a1/d2/d3/d4
	rts

AdjustFilereq
	move.w	#0,-(sp)
	move.l	WScreen(pc),a1
	move.l	a1,-(sp)
	move.w	#20,-(sp)		;offy
	move.w	#150,-(sp)		;offx
	move.w	6(a0),-(sp)		;reqy
	move.w	4(a0),-(sp)		;reqx

	bsr	mousetest
	add.l	#14,sp

	move.w	d0,(a0)
	move.w	d1,2(a0)
	rts

dostart
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	move.l	FirstWindow(pc),a3
	move.w	14(a3),-(sp)
	move.w	12(a3),-(sp)
nextstart
	moveq	#0,d0
	move.w	14(a3),d1
	move.w	2(sp),d6
	cmp.w	d1,d6
	beq	wait1
	sub.w	d6,d1
	move.w	14(a3),2(sp)
	lea	Startgad(pc),a2
	add.w	d1,4(a2)
	moveq	#0,d0
	move.w	4(a2),d0
	RELOL	#PAPERXO-SEGW,min
	lea	Endgad(pc),a0
	moveq	#0,d1
	move.w	4(a0),d1
	sub.w	#SEGW+1,d1
	RELOL	d1,max
	bsr	minmax
	move.w	d0,4(a2)
	move.w	d0,d4
	move.w	#PAPERXO-SEGW,d0
	lea	Startgad(pc),a0
	move.w	4(a0),d1
	sub.w	d0,d1
	and.w	#$ffff,d1
	moveq	#0,d0
	move.w	step(pc),d0
	lsl.l	d0,d1
	RELOL	d1,samplestart
	bsr	newstartend
	bsr	drawstart
wait1
	btst	#6,$BFE001		;lmb
	beq	nextstart
	add.l	#4,sp
	bra	event

doend
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	move.l	FirstWindow(pc),a3
	move.w	14(a3),-(sp)
	move.w	12(a3),-(sp)
nextend
	moveq	#0,d0
	move.w	14(a3),d1
	move.w	2(sp),d6
	cmp.w	d1,d6
	beq	wait2
	sub.w	d6,d1
	move.w	14(a3),2(sp)
	lea	Endgad(pc),a2
	add.w	d1,4(a2)
	moveq	#0,d0
	move.w	4(a2),d0
	RELOL	#PAPERXU,max
	lea	Startgad(pc),a0
	moveq	#0,d1
	move.w	4(a0),d1
	add.w	#SEGW+1,d1
	RELOL	d1,min
	bsr	minmax
	move.w	d0,4(a2)
	move.w	d0,d4
	move.w	#PAPERXU,d0
	lea	Endgad(pc),a0
	move.w	4(a0),d1
	sub.w	d1,d0
	and.w	#$ffff,d0
	moveq	#0,d1
	move.w	step(pc),d1
	lsl.l	d1,d0
	RELOL	d0,sampleend
	bsr	newstartend
	bsr	drawend
wait2
	btst	#6,$BFE001		;lmb
	beq	nextend
	add.l	#4,sp
	bra	event

startstring
	bsr	CorrInt
	lea	samplestart(pc),a1
	move.l	d0,(a1)
	bra	dospm
startplus
	moveq	#2,d0
	bra	startgpm
startminus
	moveq	#-2,d0
startgpm
	lea	samplestart(pc),a1
	add.l	d0,(a1)
dospm
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	move.l	(a1),d0
	RELOL	#0,min
	move.l	conlen(pc),d1
	sub.l	sampleend(pc),d1
	RELOL	d1,max
	bsr	minmax
	move.l	d0,(a1)
	bsr	drawstart
	move.l	samplestart(pc),d0
	moveq	#0,d1
	move.w	step(pc),d1
	lsr.l	d1,d0
	lea	Startgad(pc),a0
	move.w	d0,4(a0)
	add.w	#PAPERXO-SEGW,4(a0)
	bsr	newstartend
	bra	event

endstring
	bsr	CorrInt
	move.l	conlen(pc),d1
	sub.l	d0,d1
	lea	sampleend(pc),a1
	move.l	d1,(a1)
	bra	doepm
endplus
	move.l	#-2,d2
	bra	endgpm
endminus
	move.l	#2,d2
endgpm
	lea	sampleend(pc),a1
	add.l	d2,(a1)
doepm
	move.b	sound(pc),d0
	tst.b	d0
	beq	Req4

	move.l	(a1),d0
	RELOL	#0,min
	move.l	conlen(pc),d1
	sub.l	samplestart(pc),d1
	RELOL	d1,max
	bsr	minmax
	move.l	d0,(a1)
	bsr	drawend
	move.l	conlen(pc),d1
	sub.l	sampleend(pc),d1
	moveq	#0,d0
	move.w	step(pc),d0
	lsr.l	d0,d1
	move.w	#PAPERXO,d0
	add.w	d1,d0
	lea	Endgad(pc),a0
	move.w	d0,4(a0)
	bsr	newstartend
	bra	event

balken
	move.l	_GfxBase(pc),a6
	move.l	a4,a1
	bclr	#3,33(a1)		;NOAREAOUTLINE
	move.w	#0,d0			;JAM1
	jsr	-354(a6)

	move.l	a4,a1
	move.w	#black,d0
	jsr	-342(a6)		;SetAPen

	move.w	#PAPERXO-SEGW,d0	;xo
	move.w	#PAPERYO-10,d1		;yo
	move.w	#PAPERXU+SEGW,d2	;xu
	move.w	#PAPERYO-10+SEGH,d3	;yu
	move.l	a4,a1
	jsr	-306(a6)		;RectFill

	move.l	_IntuitionBase(pc),a6
	lea	Startgad(pc),a0
	move.l	FirstWindow(pc),a1
	sub.l	a2,a2
	moveq	#4,d0
	jsr	-432(a6)		;RefreshGList

	move.l	conlen(pc),d0
	sub.l	samplestart(pc),d0
	sub.l	sampleend(pc),d0
	PRINTDEZ d0
	lea	buffer(pc),a0
	lea	samplelentext(pc),a1
	moveq	#6,d0
1$	move.b	(a0)+,(a1)+
	dbra	d0,1$
	move.w	#0,d0
	move.w	#0,d1
	move.l	a4,a0
	lea	sampleleninfo(pc),a1
	jsr	-216(a6)		;PrintItext
	rts


*****	a2=StrGadget LONGINT
CorrInt
	move.l	a6,-(sp)
	move.l	34(a2),a0		;SInfo
	move.l	(a0),a0			;StrBuff
	move.l	_ArpBase(pc),a6
	jsr	_LVOAtol(a6)
	move.l	(sp)+,a6
	rts

minmax
	movem.l	d1/d2,-(sp)
	ext.l	d0
	add.l	#50,d0
	move.l	min(pc),d2
	add.l	#50,d2

	cmp.l	d2,d0
	blt	setmin

	move.l	max(pc),d2
	add.l	#50,d2
	cmp.l	d2,d0
	bgt	setmax
	beq	domax

	sub.l	#50,d0
	bra	mmback
setmin
	bsr	_beep
	move.l	min(pc),d0
	bra	mmback
setmax
	bsr	_beep
domax
	move.l	max(pc),d0
mmback
	movem.l	(sp)+,d1/d2
	rts

_beep
	movem.l	d0/d1/a0/a1/a6,-(sp)
	move.w	#$0003,dmacon(a5)	;clear audio 0+1 DMA-Kanal
	move.l	#wave,aud0lc(a5)
	move.w	#wavesize/2,aud0len(a5)
	move.w	#64,aud0vol(a5)
	move.w	#220,aud0per(a5)

	move.l	#wave,aud1lc(a5)
	move.w	#wavesize/2,aud1len(a5)
	move.w	#64,aud1vol(a5)
	move.w	#225,aud1per(a5)

	move.w	#$00ff,adkcon(a5)	;Modulation off

	move.w	#$8203,dmacon(a5)	;channel 0+1 on
	move.l	_DOSBase(pc),a6
	move.l	#7,d1
	jsr	-198(a6)		;Delay
	move.w	#$0003,dmacon(a5)	;channel 0+1 off
	movem.l	(sp)+,d0/d1/a0/a1/a6
	rts

decl
	clr.b	d3
	move.l	d2,d4
	bpl	plus
	neg.l	d2
	move.b	#1,d3
plus
	moveq	#5,d0			;digits-1
	lea	buffer(pc),a0
	add.l	#1,a0
	lea	table10(pc),a1
ne	moveq	#'0',d1
dec	addq	#1,d1
	sub.l	(a1),d2
	bcc.s	dec
	subq	#1,d1
	add.l	(a1),d2
	move.b	d1,(a0)+
	lea	4(a1),a1
	dbra	d0,ne
	lea	buffer(pc),a0
rep
	move.b	#' ',(a0)+
	cmp.b	#'0',(a0)
	beq	rep
	tst.b	d3
	beq	done3
	move.b	#'-',-1(a0)
done3
	tst.l	d4
	bne	done4
	lea	buffer(pc),a0
	move.b	#"0",6(a0)
done4
	rts

table10
	dc.l	100000
	dc.l	10000
	dc.l	1000
	dc.l	100
	dc.l	10
	dc.l	1

buffer	ds.b	7
	dc.b	0
	cnop	0,2
freq
	dc.l	head
fname	dc.l	fchar
	dc.l	dchar
	dc.l	0
	dc.w	0
	dc.l	AdjustFilereq
	dc.l	0

head	ds.b	30
	cnop	0,2
fchar	ds.b	33
	cnop	0,2
dchar	ds.b	34
	cnop	0,2

header	dc.b	"FORM",$00,$00,$00,$00
	dc.b	"8SVXVHDR",$00,$00,$00,$14
shotlen	dc.b	$00,$00,$40,$00
	dc.b	$00,$00,$00,$00
hicycle	dc.b	$00,$00,$00,$00
rate	dc.b	$00,$00,$01,$00
	dc.b	$00,$01,$00,$00
	dc.b	"NAME",$00,$00,$00,$0c
sname	ds.b	12
	dc.b	"(c) ",$00,$00,$00,$2a
	dc.b	"for converter software: Dieter Bruns 1989",0
	dc.b	"ANNO",$00,$00,$00,$1a
	dc.b	"Sampling Hardware ROLAND",$00,$00

bodylen
	dc.b "BODY",$00,$00,$80,$00
headersize	equ *-header
	cnop	0,2
reckey
 dc.b 32,"C 1",32,"C#1",32,"D 1",32,"D#1",32,"E 1",32,"F 1",32,"F#1",32,"G 1",32,"G#1",32,"A 1",32,"A#1",32,"B 1"
 dc.b 32,"C 2",32,"C#2",32,"D 2",32,"D#2",32,"E 2",32,"F 2",32,"F#2",32,"G 2",32,"G#2",32,"A 2",32,"A#2",32,"B 2"
 dc.b 32,"C 3",32,"C#3",32,"D 3",32,"D#3",32,"E 3",32,"F 3",32,"F#3",32,"G 3",32,"G#3",32,"A 3",32,"A#3",32,"B 3"
 dc.b 32,"C 4",32,"C#4",32,"D 4",32,"D#4",32,"E 4",32,"F 4",32,"F#4",32,"G 4",32,"G#4",32,"A 4",32,"A#4",32,"B 4"
 dc.b 32,"C 5",32,"C#5",32,"D 5",32,"D#5",32,"E 5",32,"F 5",32,"F#5",32,"G 5",32,"G#5",32,"A 5",32,"A#5",32,"B 5"
 dc.b 32,"C 6",32,"C#6",32,"D 6",32,"D#6",32,"E 6",32,"F 6",32,"F#6",32,"G 6",32,"G#6",32,"A 6",32,"A#6",32,"B 6"
 dc.b 32,"C 7",32,"C#7",32,"D 7",32,"D#7",32,"E 7",32,"F 7",32,"F#7",32,"G 7"

frequenz
 dc.w 33,35,37,39,41,44,46,49,52,55,58,62
 dc.w 65,69,73,78,82,87,92,98,104,110,117,123
 dc.w 131,139,147,156,165,175,185,196,208,220,233,247
 dc.w 262,277,293,311,330,349,370,392,415,440,466,494
 dc.w 523,554,587,622,659,699,740,784,831,880,932,988
 dc.w 1047,1109,1175,1245,1319,1397,1480,1568,1661,1760,1865,1976
 dc.w 2094,2218,2350,2490,2638,2794,2960,3136


ctrlname	dc.b	"ROLAND",0
		cnop	0,2
ctrlnames10	dc.b	"ROLS10",0
		cnop	0,2
gethead		dc.b	"Load Roland_S-220 file",0
		cnop	0,2
savehead	dc.b	"Save S-220 file as 8SVX",0
		cnop	0,2

filetext	ds.b	80
		cnop	0,2

samplename	ds.b	10
		cnop	0,2

* Variables

intname		dc.b	'intuition.library',0
		cnop	0,2

arpname		ArpName

_ArpBase	ds.l	1
_IntuitionBase	ds.l	1
_DOSBase	ds.l	1
_GfxBase	ds.l	1
FirstWindow	ds.l	1
Messwindowptr	ds.l	1
errornr		ds.l	1
bu		ds.l	1
conw		ds.l	1
undo		ds.l	1
filename	ds.l	1
file		ds.l	1
Port		ds.l	1
ber		ds.l	1
counter		ds.l	1
conlen		ds.l	1
undoconlen	ds.l	1
tnr		ds.l	1
samplefreq	ds.l	1
WScreen		ds.l	1
min		ds.l	1
max		ds.l	1

WBmsg		dc.l	0
len		dc.l	67584

multi		ds.w	1
shift		ds.w	1
audlen		ds.w	1
per		ds.w	1
tonefreq	ds.w	1
add		ds.w	1
step		ds.w	1
reqw		ds.w	1
reqh		ds.w	1
offx		ds.w	1
offy		ds.w	1
flag		ds.w	1

oldstartd4	dc.w	PAPERXO
oldendd4	dc.w	512+PAPERXO+2

closereq	ds.b	1
type		ds.b	1
sound		ds.b	1
from30to15	ds.b	1

loaded30	dc.b	0
		cnop	0,2

ctrl		ds.b	7
		cnop	0,2
wavepara	ds.b	$30


SEGH	equ	6
SEGW	equ	12

Startgad:
	dc.l	startstr
VHXY1	dc.w	PAPERXO-SEGW,PAPERYO-10
	dc.w	SEGW,SEGH
	dc.w	NULL
	dc.w	GADGIMMEDIATE
	dc.w	BOOLGADGET
	dc.l	SEBorder1
	dc.l	NULL
	dc.l	NULL
	dc.l	NULL
	dc.l	NULL
	dc.w	36
	dc.l	dostart

STRY		equ	105
STRWX		equ	70
STRWY		equ	10

SMINUSX		equ	20
SSTRX		equ	SMINUSX+22
SPLUSX		equ	SSTRX+STRWX+4

EMINUSX		equ	420
ESTRX		equ	EMINUSX+22
EPLUSX		equ	ESTRX+STRWX+4


StringBorder:
	dc.w	-2,-1
	dc.b	black,blue,RP_JAM1,9
	dc.l	StringBorderVectors,StringBorder2
StringBorderVectors:
	dc.w	0,0
	dc.w	STRWX-1,0
	dc.w	STRWX-1,STRWY
	dc.w	0,STRWY
	dc.w	0,0
	dc.w	2,-2
	dc.w	STRWX+1,-2
	dc.w	STRWX+1,STRWY-2
	dc.w	STRWX-1,STRWY
StringBorder2:
	dc.w	-2,-1
	dc.b	white,blue,RP_JAM1,3
	dc.l	StringBorderVectors2,NULL
StringBorderVectors2:
	dc.w	STRWX,STRWY-2
	dc.w	STRWX,-1
	dc.w	1,-1

startstr
	dc.l	Endgad
	dc.w	SSTRX,STRY,STRWX,STRWY,GADGHCOMP,RELVERIFY+STRINGCENTER+LONGINT
	dc.w	STRGADGET
	dc.l	StringBorder,NULL,StartText,NULL,StartGadgetSInfo
	dc.w	44
	dc.l	startstring
StartGadgetSInfo:
	dc.l	StartGadgetSIBuff
	dc.l	NULL
	dc.w	0,7,0,0,0,0,0,0
	dc.l	0
samplestart
	dc.l	00
	dc.l	NULL
StartGadgetSIBuff:
	dc.b	'     0',0
	cnop	0,2


Endgad:
	dc.l	Endstr
	dc.w	PAPERXU,PAPERYO-10
	dc.w	SEGW,SEGH
	dc.w	NULL
	dc.w	GADGIMMEDIATE
	dc.w	BOOLGADGET
	dc.l	SEBorder1
	dc.l	NULL
	dc.l	NULL
	dc.l	NULL
	dc.l	NULL
	dc.w	40
	dc.l	doend
Endstr
	dc.l	Startplusgad
	dc.w	ESTRX,STRY,STRWX,STRWY,GADGHCOMP,RELVERIFY+STRINGCENTER+LONGINT
	dc.w	STRGADGET
	dc.l	StringBorder,NULL,EndText,NULL,EndGadgetSInfo
	dc.w	56
	dc.l	endstring
EndGadgetSInfo:
	dc.l	EndGadgetSIBuff
	dc.l	NULL
	dc.w	0,7,0,0,0,0,0,0
	dc.l	0
sampleend
	dc.l	00
	dc.l	NULL
EndGadgetSIBuff:
	dc.b	'     0',0
	cnop	0,2

PlusText
	dc.b	black,0,RP_JAM1,0
	dc.w	3,0
	dc.l	TOPAZ80
	dc.l	PlusTextText
	dc.l	NULL
PlusTextText
	dc.b	'+',0
	cnop	0,2

MinusText
	dc.b	black,0,RP_JAM1,0
	dc.w	3,0
	dc.l	TOPAZ80
	dc.l	MinusTextText
	dc.l	NULL
MinusTextText
	dc.b	'-',0
	cnop	0,2

StartText
	dc.b	black,0,RP_JAM1,0
	dc.w	12,-12
	dc.l	TOPAZ80
	dc.l	StartTextText
	dc.l	NULL
StartTextText
	dc.b	'Start',0
	cnop	0,2

EndText
	dc.b	black,0,RP_JAM1,0
	dc.w	20,-12
	dc.l	TOPAZ80
	dc.l	EndTextText
	dc.l	NULL
EndTextText
	dc.b	'End',0
	cnop	0,2

PlayText
	dc.b	black,0,RP_JAM1,0
	dc.w	TX,TY-16
	dc.l	TOPAZ80
	dc.l	PlayTextText
	dc.l	NULL
PlayTextText
	dc.b	'Right Mousebutton: Play Sample',0
	cnop	0,2

PMBX	equ	17
PMBY	equ	10

Startplusgad:
	dc.l	Startminusgad
	dc.w	SPLUSX,STRY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET
	dc.l	StartBorder3
	dc.l	NULL
	dc.l	PlusText
	dc.l	NULL
	dc.l	NULL
	dc.w	48
	dc.l	startplus
Startminusgad:
	dc.l	Endplusgad
	dc.w	SMINUSX,STRY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET
	dc.l	StartBorder3
	dc.l	NULL
	dc.l	MinusText
	dc.l	NULL
	dc.l	NULL
	dc.w	52
	dc.l	startminus
StartBorder3:
	dc.w	-1,-1
	dc.b	black,blue,RP_JAM1,9
	dc.l	StartBorderVectors3,StartBorder4
StartBorderVectors3:
	dc.w	0,0
	dc.w	PMBX-1,0
	dc.w	PMBX-1,PMBY
	dc.w	0,PMBY
	dc.w	0,0
	dc.w	2,-2
	dc.w	PMBX+1,-2
	dc.w	PMBX+1,PMBY-2
	dc.w	PMBX-1,PMBY
StartBorder4:
	dc.w	-1,-1
	dc.b	white,blue,RP_JAM1,3
	dc.l	StartBorderVectors4,NULL
StartBorderVectors4:
	dc.w	PMBX,PMBY-2
	dc.w	PMBX,-1
	dc.w	1,-1

Endplusgad:
	dc.l	Endminusgad
	dc.w	EPLUSX,STRY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET
	dc.l	PMBorder1
	dc.l	NULL
	dc.l	PlusText
	dc.l	NULL
	dc.l	NULL
	dc.w	60
	dc.l	endplus
Endminusgad:
	dc.l	NULL
	dc.w	EMINUSX,STRY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET
	dc.l	PMBorder1
	dc.l	NULL
	dc.l	MinusText
	dc.l	NULL
	dc.l	NULL
	dc.w	64
	dc.l	endminus

PMBorder1:
	dc.w	-1,-1
	dc.b	black,blue,RP_JAM1,9
	dc.l	PMBorder1Vectors,PMBorder2
PMBorder1Vectors:
	dc.w	0,0
	dc.w	PMBX-1,0
	dc.w	PMBX-1,PMBY
	dc.w	0,PMBY
	dc.w	0,0
	dc.w	2,-2
	dc.w	PMBX+1,-2
	dc.w	PMBX+1,PMBY-2
	dc.w	PMBX-1,PMBY
PMBorder2:
	dc.w	-1,-1
	dc.b	white,blue,RP_JAM1,3
	dc.l	PMBorder2Vectors,NULL
PMBorder2Vectors:
	dc.w	PMBX,PMBY-2
	dc.w	PMBX,-1
	dc.w	1,-1

SEBorder1:
	dc.w	0,0
	dc.b	orange,black,RP_JAM1
	dc.b	5
	dc.l	SEBorderVectors1
	dc.l	NULL
SEBorderVectors1:
	dc.w	0,0
	dc.w	SEGW,0
	dc.w	SEGW,SEGH
	dc.w	0,SEGH
	dc.w	0,0

srate15
	dc.b	3,0,RP_JAM2,0
	dc.w	TX+352,TY
	dc.l	TOPAZ80
	dc.l	srate15text
	dc.l	0
srate15text
	dc.b	'Sampling-Rate 15 kHz',0
	cnop	0,2

srate30
	dc.b	3,0,RP_JAM2,0
	dc.w	TX+352,TY
	dc.l	TOPAZ80
	dc.l	srate30text
	dc.l	0
srate30text
	dc.b	'Sampling-Rate 30 kHz',0
	cnop	0,2

rkey
	dc.b	3,0,RP_JAM2,0
	dc.w	TX+212,TY
	dc.l	TOPAZ80
	dc.l	rkeytext
	dc.l	tonenr
rkeytext
	dc.b	'REC KEY =',0
	cnop	0,2

nameItext
	dc.b	3,0,RP_JAM2,0
	dc.w	TX,TY
	dc.l	TOPAZ80
	dc.l	nameItexttexthead
	dc.l	tonenr
nameItexttexthead
	dc.b	'Samplename: '
nameItexttext
	ds.b	9
	dc.b	0
	cnop	0,2

tonenr
	dc.b	3,0,RP_JAM2,0
	dc.w	TX+284,TY
	dc.l	TOPAZ80
	dc.l	tonenrtext
	dc.l	0
tonenrtext
	dc.b	'    ',0
	cnop	0,2

INFOX	equ	SPLUSX+65
INFOY	equ	STRY
sampleleninfo
	dc.b	black,0,RP_JAM1,0
	dc.w	INFOX,INFOY
	dc.l	TOPAZ80
	dc.l	sampleinfotext
	dc.l	samplelen
sampleinfotext
	dc.b	'Samplelen:',0
	cnop	0,2

samplelen
	dc.b	white,0,RP_JAM2,0
	dc.w	INFOX+80,INFOY
	dc.l	TOPAZ80
	dc.l	samplelentext
	dc.l	bytes
samplelentext
	dc.b	'      ',0
	cnop	0,2

bytes
	dc.b	white,0,RP_JAM1,0
	dc.w	INFOX+140,INFOY
	dc.l	TOPAZ80
	dc.l	bytestext
	dc.l	NULL
bytestext
	dc.b 'Bytes',0
	cnop 0,2

TOPAZ80
	dc.l	TOPAZ80name
	dc.w	TOPAZ_EIGHTY
	dc.b	FS_NORMAL,FPF_ROMFONT
TOPAZ80name
	dc.b	"topaz.font",0
	cnop 0,2

boldfont
	dc.l	boldfontname
	dc.w	TOPAZ_EIGHTY
	dc.b	FSF_BOLD,FPF_ROMFONT
boldfontname
	dc.b	"topaz.font",0
	cnop	0,2

NewWindowStructure1:
 dc.w	40,0
 dc.w	555,200
 dc.b	blue,white
 dc.l	CLOSEWINDOW+GADGETUP+GADGETDOWN+MOUSEBUTTONS
 dc.l	WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH+RMBTRAP
 dc.l	Gadget1
 dc.l	NULL
 dc.l	NewWindowName1
 dc.l	NULL
 dc.l	NULL
 dc.w	5,5
 dc.w	-1,-1
 dc.w	WBENCHSCREEN
NewWindowName1:
 dc.b	'S220to8SVX  Version 1.4 © 1991 Dieter Bruns',0
 cnop 0,2
Gadget1:
	dc.l	Gadget2
	dc.w	GX,GY
	dc.w	85,28
	dc.w	GADGHCOMP
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	NULL
	dc.l	IText1
	dc.l	NULL
	dc.l	NULL
	dc.w	NULL
	dc.l	loadgadget

BX	equ	85
BY	equ	28
Border1:
	dc.w	-1,-1
	dc.b	black,blue,RP_JAM1,9
	dc.l	BorderVectors1,Border2
BorderVectors1:
	dc.w	0,0
	dc.w	BX-1,0
	dc.w	BX-1,BY
	dc.w	0,BY
	dc.w	0,0
	dc.w	2,-2
	dc.w	BX+1,-2
	dc.w	BX+1,BY-2
	dc.w	BX-1,BY
Border2:
	dc.w	-1,-1
	dc.b	white,blue,RP_JAM1,3
	dc.l	BorderVectors2,NULL
BorderVectors2:
	dc.w	BX,BY-2
	dc.w	BX,-1
	dc.w	1,-1
IText1:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,4
	dc.l	TOPAZ80
	dc.l	ITextText1
	dc.l	IText2
ITextText1:
	dc.b	'Load and',0
	cnop 0,2
IText2:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,15
	dc.l	TOPAZ80
	dc.l	ITextText2
	dc.l	NULL
ITextText2:
	dc.b	'convert',0
	cnop 0,2
Gadget2:
	dc.l	Gadget3
	dc.w	GX+100,GY
	dc.w	85,28
	dc.w	GADGHCOMP
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	NULL
	dc.l	IText3
	dc.l	NULL
	dc.l	NULL
	dc.w	4
	dc.l	save8SVX
IText3:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,4
	dc.l	TOPAZ80
	dc.l	ITextText3
	dc.l	IText4
ITextText3:
	dc.b	'Save as',0
	cnop 0,2
IText4:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,15
	dc.l	TOPAZ80
	dc.l	ITextText4
	dc.l	NULL
ITextText4:
	dc.b	'8SVX',0
	cnop 0,2
Gadget3:
	dc.l	Gadget4
	dc.w	GX+200,GY
	dc.w	85,28
	dc.w	GADGHCOMP
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	NULL
	dc.l	IText5
	dc.l	NULL
	dc.l	NULL
	dc.w	8
	dc.l	c30_to_15
IText5:
	dc.b	2,0,RP_JAM1,0
	dc.w	5,9
	dc.l	TOPAZ80
	dc.l	ITextText5
	dc.l	NULL
ITextText5:
	dc.b	'30<>15kHz',0
	cnop 0,2
Gadget4
	dc.l	Gadget5
	dc.w	GX+300,GY
	dc.w	85,28
	dc.w	GADGHCOMP
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	NULL
	dc.l	IText8
	dc.l	NULL
	dc.l	NULL
	dc.w	16
	dc.l	adjustVolume
IText8:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,4
	dc.l	TOPAZ80
	dc.l	ITextText8
	dc.l	IText9
ITextText8:
	dc.b	'Change',0
	cnop 0,2
IText9:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,15
	dc.l	TOPAZ80
	dc.l	ITextText9
	dc.l	NULL
ITextText9:
	dc.b	'Volume',0
	cnop 0,2

Gadget5:
	dc.l	Startgad
	dc.w	GX+400,GY
	dc.w	85,28
	dc.w	GADGHCOMP
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	NULL
	dc.l	IText10
	dc.l	NULL
	dc.l	NULL
	dc.w	20
	dc.l	undoVolume
IText10:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,4
	dc.l	TOPAZ80
	dc.l	ITextText10
	dc.l	IText11
ITextText10:
	dc.b	'Original',0
	cnop 0,2
IText11:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,15
	dc.l	TOPAZ80
	dc.l	ITextText11
	dc.l	NULL
ITextText11:
	dc.b	'Volume',0
	cnop 0,2

ReqText1
	dc.b	black,0,RP_JAM1,0
	dc.w	40,25
	dc.l	boldfont
	dc.l	ReqText1text
	dc.l	ReqText11
ReqText1text
	dc.b	"ROLAND File !",0
	cnop	0,2
ReqText11
	dc.b	black,0,RP_JAM1,0
	dc.w	40,10
	dc.l	TOPAZ80
	dc.l	ReqText11text
	dc.l	0
ReqText11text
	dc.b	"Not an",0
	cnop	0,2

ReqText2
	dc.b	black,0,RP_JAM1,0
	dc.w	20,20
	dc.l	boldfont
	dc.l	ReqText2text
	dc.l	0
ReqText2text
	dc.b	"DISK-Error !",0
	cnop	0,2

ReqText3
	dc.b	black,0,RP_JAM1,0
	dc.w	20,25
	dc.l	boldfont
	dc.l	ReqText3text
	dc.l	ReqText31
ReqText3text
	dc.b	"is not 30 kHz !",0
	cnop	0,2
ReqText31
	dc.b	black,0,RP_JAM1,0
	dc.w	20,10
	dc.l	TOPAZ80
	dc.l	ReqText31text
	dc.l	0
ReqText31text
	dc.b	"Sampling-Rate",0
	cnop	0,2

ReqText4
	dc.b	black,0,RP_JAM1,0
	dc.w	30,20
	dc.l	TOPAZ80
	dc.l	ReqText4text
	dc.l	0
ReqText4text
	dc.b	"There is no sound !",0
	cnop	0,2

ReqBorder
	dc.w	0,2
	dc.b	2,0,RP_JAM1
	dc.b	9
	dc.l	ReqVectors1
	dc.l	ReqBorder2
ReqVectors1
	dc.w	0,0
	dc.w	REQW-4,0
	dc.w	REQW-4,REQH-3
	dc.w	0,REQH-3
	dc.w	0,0
	dc.w	0,-2
	dc.w	REQW-1,-2
	dc.w	REQW-1,REQH-3
	dc.w	REQW-3,REQH-3

ReqBorder2
	dc.w	0,2
	dc.b	1,0,RP_JAM1
	dc.b	3
	dc.l	ReqVectors2
	dc.l	NULL
ReqVectors2
	dc.w	REQW-2,REQH-4
	dc.w	REQW-2,-1
	dc.w	1,-1

Messreq
	dc.l	0
	dc.w	50,100
	dc.w	REQW,REQH
	dc.w	0,0
	dc.l	MessreqGadget1
	dc.l	ReqBorder
	dc.l	0
	dc.w	0
	dc.b	3,0
	dc.l	0
	ds.b	32
	dc.l	0
	dc.l	0
	ds.b	36

MessreqGadget1
	dc.l	0
	dc.w	110,40
	dc.w	OKBX,OKBY+2
	dc.w	GADGHCOMP
	dc.w	RELVERIFY+ENDGADGET
	dc.w	BOOLGADGET+REQGADGET
	dc.l	OkCancelBorder1
	dc.l	0
	dc.l	OkText
	dc.l	0
	dc.l	0
	dc.w	12
	dc.l	event

InfoReq
	dc.l	0
	dc.w	180,80
	dc.w	IREQW,IREQH
	dc.w	0,0
	dc.l	0
	dc.l	InfoBorder1
	dc.l	InfoIText1
	dc.w	0
	dc.b	3,0
	dc.l	0
	ds.b	32
	dc.l	0
	dc.l	0
	ds.b	36

InfoBorder1:
	dc.w	0,2
	dc.b	2,0,RP_JAM1
	dc.b	9
	dc.l	InfoBorderVectors1
	dc.l	InfoBorder2
InfoBorderVectors1:
	dc.w	0,0
	dc.w	IREQW-4,0
	dc.w	IREQW-4,IREQH-3
	dc.w	0,IREQH-3
	dc.w	0,0
	dc.w	0,-2
	dc.w	IREQW-1,-2
	dc.w	IREQW-1,IREQH-3
	dc.w	IREQW-3,IREQH-3

InfoBorder2:
	dc.w	0,2
	dc.b	1,0,RP_JAM1
	dc.b	3
	dc.l	InfoBorderVectors2
	dc.l	NULL
InfoBorderVectors2:
	dc.w	IREQW-2,IREQH-4
	dc.w	IREQW-2,-1
	dc.w	1,-1

InfoIText1:
	dc.b	2,0,RP_JAM1,0
	dc.w	10,6
	dc.l	TOPAZ80
	dc.l	InfoITextText1
	dc.l	InfoIText2
InfoITextText1:
	dc.b	'Please wait...',0
	cnop 0,2

InfoIText2:
	dc.b	2,0,RP_JAM1,0
	dc.w	90,18
	dc.l	TOPAZ80
	dc.l	InfoITextText2
	dc.l	0
InfoITextText2
	dc.b	"I'm working",0
	cnop	0,2

VolumeREQW	equ     190
VolumeREQH	equ     60
VolumeBX	equ	VolumeREQW-3
VolumeBY	equ	VolumeREQH-5

Volumerequester
	dc.l	0
	dc.w	200,30
	dc.w	VolumeREQW,VolumeREQH
	dc.w	0,0
	dc.l	VolumeGadget1
	dc.l	VolumeBorder1
	dc.l	VolumeText
	dc.w	0
	dc.b	0,0
	dc.l	0
	ds.b	32
	dc.l	0
	dc.l	0
	ds.b	36

VolumeText:
	dc.b	black,0,RP_JAM1,0
	dc.w	20,10
	dc.l	TOPAZ80
	dc.l	VolumeTextText
	dc.l	NULL
VolumeTextText:
	dc.b	'Set percentage',0
	cnop 0,2

VolumeBorder1:
	dc.w	0,2
	dc.b	2,0,RP_JAM1
	dc.b	9
	dc.l	VolumeBorderVectors1
	dc.l	VolumeBorder2
VolumeBorderVectors1:
	dc.w	0,0
	dc.w	VolumeBX,0
	dc.w	VolumeBX,VolumeBY+2
	dc.w	0,VolumeBY+2
	dc.w	0,0
	dc.w	2,-2
	dc.w	VolumeBX+2,-2
	dc.w	VolumeBX+2,VolumeBY
	dc.w	VolumeBX,VolumeBY+2
VolumeBorder2:
	dc.w	0,2
	dc.b	1,0,RP_JAM1
	dc.b	3
	dc.l	VolumeBorderVectors2
	dc.l	NULL
VolumeBorderVectors2:
	dc.w	VolumeBX+1,VolumeBY
	dc.w	VolumeBX+1,-1
	dc.w	1,-1

LGY	equ	25

VolumeGadget1
	dc.l	VolumeGadget2
	dc.w	VolumeTRX,LGY,34,9,GADGHCOMP,RELVERIFY+STRINGRIGHT+LONGINT
	dc.w	STRGADGET+REQGADGET
	dc.l	Border3,NULL,NULL,NULL,VolumeGadget1SInfo
	dc.w	24
	dc.l	event
VolumeGadget1SInfo:
	dc.l	VolumeGadget1SIBuff
	dc.l	NULL
	dc.w	0,4,0,0,0,0,0,0
	dc.l	0
multiVolume
	dc.l	100
	dc.l	NULL
VolumeGadget1SIBuff:
	dc.b	'100',0
	cnop 0,2

OKBX	equ	68
OKBY	equ	10

VolumeGadget2:
	dc.l	VolumeGadget3
	dc.w	18,40
	dc.w	OKBX,OKBY+2
	dc.w	GADGHCOMP
	dc.w	RELVERIFY+ENDGADGET
	dc.w	BOOLGADGET+REQGADGET
	dc.l	OkCancelBorder1
	dc.l	NULL
	dc.l	CancelText
	dc.l	NULL
	dc.l	NULL
	dc.w	28
	dc.l	event

VolumeGadget3:
	dc.l	Volumeplus1gad
	dc.w	98,40
	dc.w	OKBX,OKBY+2
	dc.w	GADGHCOMP
	dc.w	RELVERIFY+ENDGADGET
	dc.w	BOOLGADGET+REQGADGET
	dc.l	OkCancelBorder1
	dc.l	NULL
	dc.l	OkText
	dc.l	NULL
	dc.l	NULL
	dc.w	32
	dc.l	doadjustVolume

OkCancelBorder1:
	dc.w	0,0
	dc.b	2,0,RP_JAM1
	dc.b	9
	dc.l	OkCancelBorderVectors1
	dc.l	OkCancelBorder2
OkCancelBorderVectors1:
	dc.w	0,0
	dc.w	OKBX,0
	dc.w	OKBX,OKBY+2
	dc.w	0,OKBY+2
	dc.w	0,0
	dc.w	2,-2
	dc.w	OKBX+2,-2
	dc.w	OKBX+2,OKBY
	dc.w	OKBX,OKBY+2

OkCancelBorder2:
	dc.w	0,0
	dc.b	1,0,RP_JAM1
	dc.b	3
	dc.l	OkCancelBorderVectors2
	dc.l	NULL
OkCancelBorderVectors2:
	dc.w	OKBX+1,OKBY
	dc.w	OKBX+1,-1
	dc.w	1,-1

Volumeplus1gad:
	dc.l	Volumeminus1gad
	dc.w	VolumeTRX+VolumeTRM+LMPROP+LMPP,LGY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET+REQGADGET
	dc.l	PMBorder1
	dc.l	NULL
	dc.l	PlusText
	dc.l	NULL
	dc.l	NULL
	dc.w	68
	dc.l	plus1Volume

VolumeTRX	equ     20
VolumeTRM	equ	38
LMPROP		equ	18
LMPP		equ	82

Volumeminus1gad:
	dc.l	Volumepropgad
	dc.w	VolumeTRX+VolumeTRM,LGY
	dc.w	PMBX,PMBY
	dc.w	NULL
	dc.w	GADGHCOMP+RELVERIFY
	dc.w	BOOLGADGET+REQGADGET
	dc.l	PMBorder1
	dc.l	NULL
	dc.l	MinusText
	dc.l	NULL
	dc.l	NULL
	dc.w	72
	dc.l	minus1Volume

Volumepropgad:
	dc.l	NULL
	dc.w	VolumeTRX+VolumeTRM+LMPROP,LGY-3
	dc.w	80,13
	dc.w	GADGHIMAGE
	dc.w	GADGIMMEDIATE
	dc.w	PROPGADGET+REQGADGET
	dc.l	PropImage1
	dc.l	NULL
	dc.l	NULL
	dc.l	NULL
	dc.l	Volumepropgad1SInfo
	dc.w	76
	dc.l	propVolume
Volumepropgad1SInfo:
	dc.w	FREEHORIZ+PROPBORDERLESS
	dc.w	0,-1
	dc.w	660,-1
	dc.w	0,0,0,0,0,0
PropImage1:
	dc.w	0,0
	dc.w	22,13
	dc.w	0
	dc.l	PropImageData1
	dc.b	$0003,$0000
	dc.l	NULL

CancelText:
	dc.b	black,0,RP_JAM1,0
	dc.w	10,3
	dc.l	TOPAZ80
	dc.l	CancelTextText
	dc.l	NULL
CancelTextText:
	dc.b	'Cancel',0
	cnop 0,2

OkText:
	dc.b	black,0,RP_JAM1,0
	dc.w	28,3
	dc.l	TOPAZ80
	dc.l	OKTextText
	dc.l	NULL
OKTextText:
	dc.b	'OK',0
	cnop 0,2

GBX	equ	43
GBY	equ	10

Border3:
	dc.w	-10,-1
	dc.b	black,blue,RP_JAM1,9
	dc.l	BorderVectors3,Border4
BorderVectors3:
	dc.w	0,0
	dc.w	GBX-1,0
	dc.w    GBX-1,GBY
	dc.w    0,GBY
	dc.w    0,0
	dc.w	2,-2
	dc.w	GBX+1,-2
	dc.w	GBX+1,GBY-2
	dc.w	GBX-1,GBY

Border4:
	dc.w	-10,-1
	dc.b	white,blue,RP_JAM1,3
	dc.l	BorderVectors4,NULL
BorderVectors4:
	dc.w	GBX,GBY-2
	dc.w    GBX,-1
	dc.w	1,-1

* begin of alerts

Alertstring
	dc.w 200
	dc.b 24,"    NOT ENOUGH MEMORY        ",0,$01
	dc.w 200
	dc.b 44,"    GOODBYE !!               ",0,$01
	dc.w 200
	dc.b 64,"=== Press any MOUSEBUTTON ===",0,$00
	cnop 0,2

Alertlen equ *-Alertstring

	dc.w 200
	dc.b 24,"    Can't open Window        ",0,$01
	dc.w 200
	dc.b 44,"    Might be memoryproblem   ",0,$01
	dc.w 200
	dc.b 64,"=== Press any MOUSEBUTTON ===",0,$00
	cnop 0,2

	dc.w 200
	dc.b 24,"    Can't open requester     ",0,$01
	dc.w 200
	dc.b 44,"    Might be memoryproblem   ",0,$01
	dc.w 200
	dc.b 64,"=== Press any MOUSEBUTTON ===",0,$00
	cnop 0,2

	dc.w 200
	dc.b 24,"    Can't open arp.library   ",0,$01
	dc.w 200
	dc.b 44,"    must be in drawer libs   ",0,$01
	dc.w 200
	dc.b 54,"      or memoryproblem       ",0,$01
	dc.w 200
	dc.b 64,"=== Press any MOUSEBUTTON ===",0,$00
	cnop 0,2

LogoImage:
	dc.w	20,13
	dc.w	104,8
	dc.w	2
	dc.l	LogoImagedata
	dc.b	$0002,$0000
	dc.l	NULL

	IFND	.A68K
	SECTION customdata,DATA_C	;Assembler: DEVPAC
	ENDC

	IFD	.A68K
	DATA customdata,CHIP		;Assembler: A68K
	ENDC

LogoImagedata:
	dc.w	$1002,$007E,$0002,$0000,$3F00,$0000,$0000,$2001
	dc.w	$01E3,$0002,$0000,$F180,$0000,$0000,$4000,$8361
	dc.w	$8C1F,$8001,$B0C0,$0000,$0000,$8000,$8061,$8004
	dc.w	$0000,$3F80,$0000,$0000,$81C0,$8061,$B3CD,$E760
	dc.w	$39CE,$D99D,$8C00,$8221,$00C3,$629B,$4D80,$619B
	dc.w	$7336,$DE00,$4602,$01F6,$E77B,$9980,$FB76,$676D
	dc.w	$B300,$23C4,$03BD,$BBCC,$F301,$DECC,$3D99,$EE00

PropImageData1:
	dc.w	$0000,$0000,$3FFF,$F000,$0000,$0800,$0000,$0800
	dc.w	$0000,$0800,$0000,$0800,$0000,$0800,$0000,$0800
	dc.w	$0000,$0800,$0000,$0800,$0000,$0800,$0000,$0800
	dc.w	$0000,$0000,$7FFF,$F800,$C000,$0C00,$C048,$0400
	dc.w	$C1CE,$0400,$C7CF,$8400,$DFCF,$E400,$FFCF,$F400
	dc.w	$DFCF,$E400,$C7CF,$8400,$C1CE,$0400,$C048,$0400
	dc.w	$C000,$0400,$7FFF,$F800

wave
	dc.b	0,10
	dc.b	20,38
	dc.b	47,56
	dc.b	63,72
	dc.b	81,90
	dc.b	106,118
	dc.b	122,127

	dc.b	-127,-122
	dc.b	-118,-106
	dc.b	-90,-81
	dc.b	-72,-63
	dc.b	-56,-47
	dc.b	-38,-20
	dc.b	-10,0
wavesize equ *-wave
        END
