rasttime		=0
mix_buflen		=128
default_mixrate		=250

save			=1
usernr			=3
spasti			=0
lang			=0	; 0=englisch,1=deutsch
copylock		=1	; 0=on , 1=off	REMOVED!!! PARTY ON!

;+--------------------------------------------------------------------------+
;|									    |
;| Program	:	ArtOfNoise (System-Version)				    |
;| Author	:	Bastian Spiegel ( "Twice of LEGO" )		    |
;| Date		:	Jun'93 - Feb'95					    |
;| System	:	** Needs at least kickstart V2.04 **		    |
;| Assembler	:	The best! - ASM-ONE V1.2 by Promax&T.F.A.	    |
;|									    |
;+--------------------------------------------------------------------------+
; Contact me at :                                             Bastian Spiegel
;                                                    Trupermoorer Landstr.17a
;                                                             28865 Liliental
;                                                              United Germany
;                                                            Tel: 04298- 4873
;                                                                      -30731

; History	:	- Mar'93-Jul'93 : Replayer was developed
;			- Jul'93 : Changed to flexible file format
;			- Oct'93 : Changed from Protracker-like to Oktalyzer-
;			-	   like geos
;			- Jan'94 : Changed to Octamed-like Amiga-OS Geos!
;			- Jan'94 : Changed to even better file-format
;				   (less memory)
;			- May'94 : Changed to tag-item fileformat
;			- Aug'94 : Changed back to if-format

			REM
         =================----> KeyShortCuts <----=================
 General:
 ŻŻŻŻŻŻŻŻ
 RightAlt	:	Start Songplay
 RightAmiga	:	Start Patternplay
 RightShift	:×	Start Record
 LShift+RAlt	:	Continue Songplay
 LShift+RAmi	:	Continue Patternplay
 LShift+RShift	:	Continue Record
 <		:	Set volumes to 0,DMA OFF
 F1		:	Select octave 1 (c-1 > G#3)
 F2		:	select octave 2 (C-2 > B-3)
 F3		:	??
 F4		:	??
 F5		:	??
 sft&F3		:	Cut track to buffer
 sft&F4		:	Copy track to buffer
 sft&F5		:	Paste buffer to track
 lalt&F3	:	Cut pattern to buffer
 lalt&F4	:	Copy pattern to buffer
 lalt&F5	:	Paste buffer to pattern
 ctrl&F3	:	Cut commands to buffer
 ctrl&F4	:	Copy commands to buffer
 ctrl&F5	:	Paste command-buffer to track
 lalt+y		:	Toggle channel 1
 lalt+x		:	Toggle channel 2
 lalt+c		:	Toggle channel 3
 lalt+v		:	Toggle channel 4

 Patternedit	:
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
 CursorKeys	:	Scroll through pattern
 SPACE		:	Stop song /Toggle edit on/off
 tab		:	channeljump
 Alt&->		:	Skip Pattern +
 Alt&<-		:	Skip Pattern -
 sft&->		:	songpos +1
 sft&<-		:	songpos -1
 lalt+lsft&->	:	songpat +1
 lalt+lsft&<-	:	songpat -1
 ctrl&0		:	Jump down 0 steps after editing a step
 ctrl&1		:	Jump down 1 steps after editing a step
 ctrl&2		:	Jump down 2 steps after editing a step
 ctrl&3		:	Jump down 3 steps after editing a step
 ctrl&4		:	Jump down 4 steps after editing a step
 ctrl&5		:	Jump down 5 steps after editing a step
 ctrl&6		:	Jump down 6 steps after editing a step
 ctrl&7		:	Jump down 7 steps after editing a step
 ctrl&8		:	Jump down 8 steps after editing a step
 ctrl&9		:	Jump down 9 steps after editing a step
 sft&return	:	Insert step (when edit is on!)
 sft&backspace	:	Delete step (when edit is on!)
 alt&del	:	Delete pos
 alt&help	;	Insert pos


 NumericPad 	:
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
 sft+enter	:	change instrtranspose for numeric-pad (np)
			instr. selection
 np[		:	set instr 1 (+instrtrp)
 np]		:	set instr 2 (+instrtrp)
 np/		:	set instr 3 (+instrtrp)
 np*		:	set instr 4 (+instrtrp)
 np7		:	set instr 5 (+instrtrp)
 and so on...
 npShft+[	:	set instr 17 (+instrtrp)
 npShft+]	:	set instr 18 (+instrtrp)
 npShft+/	:	set instr 19 (+instrtrp)
 npShft+*	:	set instr 20 (+instrtrp)
 npShft+7	:	set instr 21 (+instrtrp)

 Direct Instr.Select:
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
 Use LAmiga+instrnr (1-9,a-z,A-Z)!




analfatal
			EREM
;--------------------------------------------------------------------
; Aufbau des DSEQUENCE-FORMATs

; + 0	"DSEQ"	;kennung
; + 4	.1	;Sequence-Speed
; + 5	.1	;Sequence-Tempo
; + 6	.1	;Sequence-Pitch
; + 7	.1	;Ğfillbyteğ
; + 8	.64	;16 .l die die längen der wellenformen in bytes darstellen
; + 72	.17	;17 bytes, die die additional sequence data enthalten
; + 89	.384	;384 bytes, die den sequence-pattern enthalten
; + 473 .???	;wellenform daten

; _____________________________________________________________________________
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;                 <<<<<< aRt Of nOise  -  MoDuLeFoRmAt V4.0 >>>>>>>
; _____________________________________________________________________________
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
; (C) Bastian Spiegel ('TWICE/LEGO') Jul'94    ctct at: +0049-(0)4298-4873
;
; this modformat makes use of the known iff-format which is built upon
; socalled chunks.. just check out what chunks Ğart of noiseğ has to offer...
; don't change the sequence of the chunks or my loader might get a bit confused

;	'FORM'		+4 bytes filelength-8
;	'AON4'		kennung
;	'ANNO'
;		'ArtOfNoise by Bastian Spiegel (TWICE/LEGO)'
;
; SONGNAME-STRING    :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'NAME'
;			up to 255 bytes containing the songname ,
;			terminated with a zero byte , always an even lenght!
; SONGAUTHOR-STRING  :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'AUTH'
;			up to 255 bytes containing the songauthor's name ,
;			terminated with a zero byte , always an even lenght!
; SONGDATE-STRING    :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'DATE'
;			up to 255 bytes containing the songdate ,
;			terminated with a zero byte , always an even lenght!
; REMARK-TEXT        :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'RMRK'
;			Here you can include a normal textfile (use ced or
;			whatever! Smart or what?! Length will be adjusted to
;			even bytesize
; SONGINFORMATION    :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'INFO'
;			.b	Moduleformat version
;			.b	Maxpos
;			.b	Restartpos
;			.b	fillbyte

; ARPEGGIOTAB	     :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'ARPG'
;			16 entries , the first arpeggio should be $00000000
;			Use as following: n1234567
;			Ğnğ is the number of notes in this arpeggio , Ğ1-7ğ
;			are the notes (offsets from base-note , for a 'c'
;			accord you'll have to set the lword as following: $3037
;			or for a 'C' accord : $3047
;			(and don't 4get about the base-note('c-1','c-2','c-3'))
; POSITIONTAB	     :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'PLST'
;			A tab which contains Ğmaxlenğ bytes (if maxlen is odd,
;			then a fillbyte will be added).These bytes store up
;			to 256 positions.On each position , a different pattern
;			can be played,WHICH pattern shall be played is stored
;			in this tab.
;			(e.g.: $00 01 10 1c 4     Play patterns 0,1,$10,$1c,4
;			then return to song-start (if maxlen=5)
; PATTERNS	     :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'PATT'
;			This chunk stores the patterndata.Every pattern has
;			got 64 steps , a step is build up as following:
;
; 				1.byte	2.byte		3.byte	4.byte
; 				C-3	Instrument	Fx-Com	Fx-Val
; 					%yyxxxxxx	%yyxxxxxx
; 				note    arp instr.	arp fxcom
;					0/1		2/3
; 				the two arp-bits of these two bytes form a
; 				4-bit arpeggio-value,used as an offset (*4)
; 				in the arp-table)
; INSTRUMENTS	     :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'INST'
;			This chunk stores the data for up to 61 instruments.
;			size=61*32=1952 (attention! depends on max-instr.)
;
;
; INSTRUMENTNAMES    :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'INAM'
;			A field with the bytesize 61*32=1952 . It contains
;			for each of the 61 instruments a 32 bytes long string
;			containing the instrumentname (the string has to be
;			terminated with zero!)
; WAVES		     :
; ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
;	'WLEN'
;			are the lengths of the 64 waveforms.
;
;			dc.l	wavelen1
;			dc.l	wavelen2
;			dc.l	wavelen3	and so on..
;	'WAVE'
;			this chunk stores the wave-data.


; /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

; ## AON-INCLUDES ##

aon.songinfo_mfver	=0
aon.songinfo_maxpos	=1
aon.songinfo_respos	=2

aon.instrtypeSample8bit	=0
aon.instrtypeSynth1	=1

			rsreset
instr_control		rs.b	1	; Instr-Type (check out aon.instrtypexxxxx)
instr_volume		rs.b	1	; volume 0-64
instr_finetune		rs.b	1	; finetune -7 to 7  bits 4-7 are unused
instr_waveform		rs.b	1	; waveform 0-63

; Sample 8 bit
			rsset	4
sample8_dmaoffset	rs.l	1	; Sampleoffset/2 (words)
sample8_dmalen		rs.l	1	; Samplelen/2 (words)
sample8_dmarepoffset	rs.l	1	; Repeatstrt/2 (words)
sample8_dmareplen	rs.l	1	; Repeatlen/2 (words)

; Wavetable 8 bit
			rsset	4
synth8_partwaveDmaLen	rs.b	1	; in words (--> up to 512 bytes)

			rs.b	1	; Unused
			rs.b	1
			rs.b	1
			rs.b	1
			rs.b	1

synth8_VIBpara		rs.b	1	; the same param. like with effect '4'
synth8_vibdelay		rs.b	1	; framecnt
synth8_vibwave		rs.b	1	; sine,triangle,rectangle
synth8_WAVEspd		rs.b	1	; framecnt
synth8_WAVElen		rs.b	1
synth8_WAVErep		rs.b	1
synth8_WAVEreplen	rs.b	1
synth8_WAVErepCtrl	rs.b	1	; 0=Repeatnormal/1=Backwards/1=PingPong

			rsset	32-4
instr_Astart		rs.b	1	; Vol_startlevel
instr_Aadd		rs.b	1	; Zeit bis maximalLevel
instr_Aend		rs.b	1	; Vol_endlevel
instr_Asub		rs.b	1	; Zeit bis endlevel



; ·------------------------------------------------------------------------·
; | FX are:								   |
; | ŻŻŻŻŻŻŻ    					     (ripped from ptdoc2.3)|
; | 0 - Normal play or Arpeggio       0xy : x-first halfnote add, y-second |
; | 1 - Slide Up                      1xx : upspeed			   |
; | 2 - Slide Down                    2xx : downspeed			   |
; | 3 - Tone Portamento               3xx : up/down speed		   |
; | 4 - Vibrato                       4xy : x-speed,   y-depth		   |
; | 5 - Tone Portamento + Vol. Slide  5xy : x-upspeed, y-downspeed	   |
; | 6 - Vibrato + Volume Slide        6xy : x-upspeed, y-downspeed	   |
; | 7 - Tremolo                       7xy : x-speed,   y-depth		   |
; | 8 - NOT USED                                                           |
; | 9 - Set SampleOffset              9xx : offset (23 -> 2300)		   |
; | a - VolumeSlide                   axy : x-upspeed, y-downspeed	   |
; | b - Position Jump                 bxx : songposition		   |
; | c - Set Volume                    cxx : volume, 00-40		   |
; | d - Pattern Break                 dxx : break position in next patt	   |
; | e - E-Commands                    exy : see below...		   |
; | f - Set Speed                     fxx : speed (00-1F) / tempo (20-FF)  |
; ·------------------------------------------------------------------------·
; | e0- Set Filter                    e0x : 0-filter on, 1-filter off	   |
; | e1- FineSlide Up                  e1x : value			   |
; | e2- FineSlide Down                e2x : value			   |
; | e3- Glissando Control             e3x : 0-off, 1-on (use with tonep.)  |
; | e4- Set Vibrato Waveform          e4x : 0-sine, 1-ramp down, 2-square  |
; | e5- Set Loop                      e5x : set loop point		   |
; | e6- Jump to Loop                  e6x : jump to loop, play x times	   |
; | e7- Set Tremolo Waveform          e7x : 0-sine, 1-ramp down. 2-square  |
; | e8- NOT USED							   |
; | e9- Retrig Note                   e9x : retrig from note + x vblanks   |
; | eA- Fine VolumeSlide Up           eAx : add x to volume		   |
; | eB- Fine VolumeSlide Down         eBx : subtract x from volume	   |
; | eC- NoteCut                       eCx : cut from note + x vblanks	   |
; | eD- NoteDelay                     eDx : delay note x vblanks	   |
; | eE- PatternDelay                  eEx : delay pattern x notes	   |
; |                                                        		   |
; ·------------------------------------------------------------------------·
; | OWN (SYNTH)FX:							   |
; | ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ							   |
; | g - New volume                    gxy : set vol. to 4+(x*$4)+y vblanks |
; | h - synth control		      hxy : x<>0=keepwave y<>0=keep adsr   |
; | i - wave&adsrspd control	      ixy : wavespd=x ;Adsrspd=y	   |
; | j - Set arpspeed		      jxy : Set arpspd=y		   |
; | k - set volume &do vibrato	      kxx : set volume=xx		   |
; | l - fineslide&fineportamento UP   lxy : volslide=x  , portamento=y     |
; | m - fineslide&fineportamento DOWN mxy : volslide=x  , portamento=y     |
; ·------------------------------------------------------------------------·



; /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


			incdir	"dh1:asm/include/"
; An ASM-1 angepasste includes werden gebraucht! (keine IFND ENDC etc.
; Befehle)


False			=0
True			=1
;---------------------- EXEC --------------------------------------------

exec			=4
exec_addintserver	=-168
exec_remintserver	=-174
exec_openlib		=-552
exec_closelib		=-414
exec_allocmem		=-198
exec_freemem		=-210
exec_openresource	=-498
exec_allocsignal	=-330
exec_freesignal		=-336
exec_wait		=-318
exec_waitport		=-384
exec_allocvec		=-684
exec_freevec		=-690
exec_availmem		=-216
exec_signal		=-324
exec_cause		=-180
exec_setfunction	=-420

;exec_getmsg		=-372
;exec_wait		=-318
;exec_replymsg		=-378

			include	"exec/types.i"
			include	"exec/exec.i"

;---------------------- Utility -----------------------------------------

util_umult32		=-144
util_udivmod32		=-156

			include	"utility/tagitem.i"


;---------------------- CIA-Resource ------------------------------------
cia_AddICRVector	=-6
cia_RemICRVector	=-12
;---------------------- INTUITION ---------------------------------------
rk_leftshift		=$01
rk_rightshift		=$02
rk_capslock		=$04
rk_control		=$08
rk_leftalt		=$10
rk_rightalt		=$20
rk_leftamiga		=$40
rk_rightamiga		=$80

int_activateGadget	=-462
int_activatewindow	=-450
int_openscreen		=-198
int_closescreen		=-66
int_setmenustrip	=-264
int_CloseWindow		=-72
int_OpenWindowTagList	=-606
int_OpenScreenTagList	=-612
int_AddGList		=-438
int_RefreshGList	=-432
int_RemoveGList		=-444	; a0=Window,a1=Glist,d0=NumGad (-1=Alle)
int_AutoRequest		=-348
int_ClearMenuStrip	=-54
int_rethinkdisplay	=-390
int_viewportaddress	=-300
int_easyRequestArgs	=-588
int_refreshwindowframe	=-456
int_makescreen		=-378
int_printitext		=-216
int_screentofront	=-252


int_activewindow	=$34
int_activescreen	=$38	; Offset in intuitionbase
int_frontscreen		=$3c	; Offset in intuitionbase
int_mousey		=$44
int_mousex		=$46
int_minXmouse		=$50
int_maxXmouse		=$52
int_minYmouse		=$54
int_maxYmouse		=$56

SA_Colors		=$80000029
SA_DisplayID		=$80000032
SA_Overscan		=$80000034
SA_Autoscroll		=$80000039
SA_Pens			=$8000003a
SA_FullPalette		=$8000003b
SA_Parent		=$8000003d
SA_Draggable		=$8000003e
SA_Interleaved		=$80000042

OSCAN_Text		=1
OSCAN_Standard		=2
OSCAN_Max		=3
OSCAN_Video		=4


WA_NewLookMenus		=$80000093
WA_Pointer		=$80000097
WA_BusyPointer		=$80000098
WA_PointerDelay		=$80000099

POINTERA_Bitmap		=$80039001
POINTERA_XOffset	=$80039002
POINTERA_YOffset	=$80039003
POINTERA_WordWidth	=$80039004
POINTERA_XResolution	=$80039005
POINTERA_YResolution	=$80039006

scr_bitmap		=184	; Screen-Struktur


sizeverify		equ	$00000001 ; Ripped from
newsize			equ	$00000002 ; Ğinclude/intuition/intuition.iğ
refreshwindow		equ	$00000004
mousebuttons		equ	$00000008
mousemove		equ	$00000010
gadgetdown		equ	$00000020
gadgetup		equ	$00000040
reqset			equ	$00000080
menupick		equ	$00000100
closewindow		equ	$00000200
rawkey			equ	$00000400
reqverify		equ	$00000800
reqclear		equ	$00001000
menuverify		equ	$00002000
newprefs		equ	$00004000
diskinserted		equ	$00008000
diskremoved		equ	$00010000
wbenchmessage		equ	$00020000	; system use only
activewindow		equ	$00040000
inactivewindow		equ	$00080000
deltamove		equ	$00100000
vanillakey		equ	$00200000
intuiticks		equ	$00400000
;  for notifications from "boopsi" gadgets:
idcmpupdate		equ	$00800000	; new for v36
; for getting help key report during menu session:
menuhelp		equ	$01000000	; new for v36
; for notification of any move/size/zoom/change window:
changewindow		equ	$02000000	; new for v36
gadgethelp		equ	$04000000	; new for v39

; notez-bien:		$80000000 is reserved for internal use by idcmp

; the idcmp flags do not use this special bit, which is cleared when
; intuition sends its special message to the task, and set when intuition
; gets its message back from the task.	therefore, i can check here to
; find out fast whether or not this message is available for me to send
lonelymessage		equ	$80000000
						; END OF RIP
menuenabled		=$0001

checkit		equ $0001	; set to indicate checkmarkable item
itemtext	equ $0002	; set if textual, clear if graphical item
commseq		equ $0004	; set if there's an command sequence
menutoggle	equ $0008	; set for toggling checks (else mut. exclude)
itemenabled	equ $0010	; set if this item is enabled

; these are the special highlight flag state meanings
highflags	equ $00c0	; see definitions below for these bits
highimage	equ $0000	; use the user's "select image"
highcomp	equ $0040	; highlight by complementing the select box
highbox		equ $0080	; highlight by drawing a box around the image
highnone	equ $00c0	; don't highlight

checked	equ $0100	; state of the checkmark


isdrawn		equ $1000	; this item's subs are currently drawn
highitem	equ $2000	; this item is currently highlighted
menutoggled	equ $4000	; this item was already toggled 



boolgadget		=1	; Gadget-Typen
propgadget		=3
strgadget		=4

gflg_selected		=$80	; Gadget highlighted

			include	"intuition/gadgetclass.i"

;---------------------- GRAPHICS ----------------------------------------
InitRastPort		=-198
bm_bytesPerRow		=0	; Anzahl der Bytes,die dazuaddiert werden
			; müssen,um zur nächsten Zeile der Bitplane zu kommen!
bm_planes		=8	; Bitmap-Struktur

			include	"graphics/text.i"

euro72_productivity	=$69024
pal_hires		=$29000
super72_superhires	=$89020
multiscan_productivity	=$39024
dblpal			=$a9000

def1			=euro72_productivity
def2			=pal_hires

;vm_palhires		=$d000
;vm_euro72		=$d024

gfx_mrgcop		=-210

gfx_getrgb4		=-582
gfx_setrgb4		=-288 
gfx_getrgb32		=-900
gfx_loadrgb32		=-882
gfx_ucopperlistinit	=-594
gfx_cwait		=-378
gfx_cmove		=-372
gfx_cbump		=-366
gfx_coercemode		=-936
gfx_setapen		=-342
gfx_setbpen		=-348
gfx_move		=-240
gfx_text		=-60
gfx_draw		=-246
gfx_waitblit		=-228
gfx_ownblitter		=-456
gfx_disownblitter	=-462


;---------------------- REQTOOLS ----------------------------------------
rtAllocRequestA		=-30
rtFileRequestA		=-54
rtFreeRequest		=-36
rtGetlongA		=-78
rtGetStringA		=-72
rtpaletterequestA	=-102
rtEZRequestA		=-$42


rt_filereq		=0	; Typ
rt_palettereq		=2	; Typ

rt_window		=tag_user+1	; Tags
rt_reqpos		=tag_user+3
rt_screen		=tag_user+7	; Tags
rt_textattr		=tag_user+15
rtfi_height		=tag_user+41
rt_lockwindow		=tag_user+13
rtgl_min		=tag_user+30
rtgl_max		=tag_user+31
rtgl_showdefault	=tag_user+33
rtez_reqtitle		=tag_user+$14
rtgs_width		=tag_user+32

reqpos_pointer		=0

rt_dirname		=16	; Offset in der req-struktur!

;include	"libraries/reqtools.i"
;------------------------------------------------------------------------
** Gadgets **
			rsset	1
gad_quit		rs.b	1
gad_remark		rs.b	1
gad_instred		rs.b	1
gad_clear		rs.b	1
gad_setup		rs.b	1
gad_waveed		rs.b	1
gad_about		rs.b	1
gad_drumseq		rs.b	1
gad_arped		rs.b	1
gad_playsong		rs.b	1
gad_contsong		rs.b	1
gad_stop		rs.b	1
gad_playpat		rs.b	1
gad_contpat		rs.b	1
gad_edit		rs.b	1
gad_record		rs.b	1
gad_contrecord		rs.b	1
gad_songname		rs.b	1	; string-Gadget!
gad_songauthor		rs.b	1	; string-Gadget!
gad_songdate		rs.b	1	; string-Gadget!
gad_instrumentname	rs.b	1	; string-Gadget!
gad_pos			rs.b	1	; Integer-Gadget
gad_max			rs.b	1	; Integer-Gadget
gad_res			rs.b	1	; Integer-Gadget
gad_addpos		rs.b	1
gad_subpos		rs.b	1
gad_addmax		rs.b	1
gad_submax		rs.b	1
gad_addres		rs.b	1
gad_subres		rs.b	1
gad_pat			rs.b	1	; Integer-Gadget
gad_insertpos		rs.b	1
gad_deletepos		rs.b	1
gad_addpat		rs.b	1
gad_subpat		rs.b	1
gad_editpat		rs.b	1
gad_addeditpat		rs.b	1
gad_subeditpat		rs.b	1
gad_changeinstrnr	rs.b	1
gad_resettimer		rs.b	1
gad_changepos		rs.b	1

rog_instrnr		rs.b	1
rog_modtimer		rs.b	1
rog_speed		rs.b	1
rog_tempo		rs.b	1
rog_wavesize		rs.b	1
rog_volume		rs.b	1
rog_poslist		rs.b	1

; Arpeggio-Editor

gad_arp0		=1
gad_arp1		=2
gad_arp2		=3
gad_arp3		=4
gad_arp4		=5
gad_arp5		=6
gad_arp6		=7
gad_arp7		=8
gad_arp8		=9
gad_arp9		=10
gad_arpa		=11
gad_arpb		=12
gad_arpc		=13
gad_arpd		=14
gad_arpe		=15
gad_arpf		=16

; Drum-Sequencer

			rsset	1
gad_drumseqnr		rs.b	1
gad_drumseqnrtxt	rs.b	1
gad_drumseqlen		rs.b	1
gad_drumseqlentxt	rs.b	1
gad_dseqoptions0_2	rs.b	1
gad_dseqoptions1_2	rs.b	1
gad_dseqoptions2_2	rs.b	1
gad_dseqoptions3_2	rs.b	1
gad_dseqoptions4_2	rs.b	1
gad_dseqoptions5_2	rs.b	1
gad_dseqoptions6_2	rs.b	1
gad_dseqoptions7_2	rs.b	1
gad_dseqoptions8_2	rs.b	1
gad_dseqoptions9_2	rs.b	1
gad_dseqoptions10_2	rs.b	1
gad_dseqoptions11_2	rs.b	1
gad_dseqoptions12_2	rs.b	1
gad_dseqoptions13_2	rs.b	1
gad_dseqoptions14_2	rs.b	1
gad_dseqoptions15_2	rs.b	1

gad_dseqcompute		rs.b	1
gad_dseqdelete		rs.b	1
gad_dseqdelnotes	rs.b	1
gad_dseqcut2buffer	rs.b	1
gad_dseqcopy2buffer	rs.b	1
gad_dseqpastebuffer	rs.b	1
gad_loadseq		rs.b	1
gad_saveseq		rs.b	1
gad_dseqspeed		rs.b	1
gad_dseqtempo		rs.b	1
gad_dseqdestwave	rs.b	1
gad_dseqnote		rs.b	1
gad_dseqbytelen		rs.b	1

			rsset	1
gad_instrchangeinstrnr		rs.b	1
gad_instrchangeinstrnrTXT	rs.b	1
gad_instredname			rs.b	1
gad_instrchangewavenr		rs.b	1
gad_instrchangewavenrTXT	rs.b	1
gad_instrsampleoffset		rs.b	1
gad_instrsamplelen		rs.b	1
gad_instrrepeatoffset		rs.b	1
gad_instrrepeatlen		rs.b	1
gad_instrchangevolume		rs.b	1
gad_instrchangevolumeTXT	rs.b	1
gad_instrchangefinetune		rs.b	1
gad_instrchangefinetuneTXT	rs.b	1
gad_instrmode			rs.b	1
gad_instrchangesampleoffset	rs.b	1
gad_instrchangesamplelen	rs.b	1
gad_instrchangerepeatoffset	rs.b	1
gad_instrchangerepeatlen	rs.b	1
gad_instrload			rs.b	1
gad_instrsave			rs.b	1
gad_instrdelete			rs.b	1
;gad_instrCut			rs.b	1
;gad_instrCopy			rs.b	1
;gad_instrPaste			rs.b	1
;gad_instrchangeCopyFrom	rs.b	1
;gad_instrchangeCopyFromTXT	rs.b	1
;gad_instrchangeCopyTo		rs.b	1
;gad_instrchangeCopyToTXT	rs.b	1
gad_instrmoveFT			rs.b	1
gad_instrcopyFT			rs.b	1
gad_instrexchangeFT		rs.b	1
gad_instrWAVEspd		rs.b	1
gad_instrWAVElen		rs.b	1
gad_instrWAVErep		rs.b	1
gad_instrWAVEreplen		rs.b	1
gad_instrWAVErepctrl		rs.b	1
gad_instrVIBdelay		rs.b	1
gad_instrVIBpara		rs.b	1
gad_instrVIBwave		rs.b	1
;gad_instrLoadwave		rs.b	1
;gad_instrFlushwave		rs.b	1
gad_instrsaveall		rs.b	1
gad_instrAstart			rs.b	1
gad_instrAadd			rs.b	1
gad_instrAsub			rs.b	1
gad_instrAend			rs.b	1
gad_instrreturn			rs.b	1
gad_instrMixFT			rs.b	1

gad_wavewavelenTXT		rs.b	1
gad_waveload			rs.b	1
gad_wavesave			rs.b	1
;gad_wavedelete			rs.b	1
gad_waveCut			rs.b	1
gad_waveCopy			rs.b	1
gad_wavePaste			rs.b	1
gad_waveSaveBuf			rs.b	1
gad_waveclrbuf			rs.b	1
gad_waveinvertbuf		rs.b	1
;gad_wavechangeCopyFrom		rs.b	1
;gad_wavechangeCopyFromTXT	rs.b	1
;gad_wavechangeCopyTo		rs.b	1
;gad_wavechangeCopyToTXT		rs.b	1
;gad_wavemoveFT			rs.b	1
;gad_wavecopyFT			rs.b	1
;gad_waveexchangeFT		rs.b	1
gad_wavedisplaylenTXT		rs.b	1
gad_waverangelenTXT		rs.b	1
gad_waveposTXT			rs.b	1
gad_waveshowrange		rs.b	1
gad_wavezoom			rs.b	1
gad_wavetele			rs.b	1
;gad_waveplaywave		rs.b	1
;gad_waveplaydisplay		rs.b	1
gad_waveplayrange		rs.b	1
gad_waverangedisplay		rs.b	1
gad_wavestop			rs.b	1
gad_waveshowall			rs.b	1
gad_waveshow121			rs.b	1
gad_waverangeALL		rs.b	1
gad_waveeditmode		rs.b	1
gad_wavepartwave		rs.b	1
gad_wavepartwaveTXT		rs.b	1
gad_wavepartwaveSIZE		rs.b	1
gad_wavesettozero		rs.b	1
gad_wavechangevol		rs.b	1
gad_wavephaser			rs.b	1
gad_waveboost			rs.b	1
gad_waveinterpol		rs.b	1
gad_waveoctup			rs.b	1
gad_waveoctdn			rs.b	1
gad_waveinvert			rs.b	1
gad_wavebackwards		rs.b	1
gad_wavey			rs.b	1
gad_wavenoiselimiter		rs.b	1
gad_wavedigifilter		rs.b	1
gad_waveresampleDOWN		rs.b	1
gad_waveresampleUP		rs.b	1
;gad_wavehipass			rs.b	1
gad_wavelopass			rs.b	1
gad_wavelfo			rs.b	1
gad_wavemixwithbuf		rs.b	1
gad_wavemaximize		rs.b	1
gad_wavecutzeros		rs.b	1
;gad_wavechangeWave		rs.b	1
gad_wavechangeWaveTXT		rs.b	1
gad_wavechangePos		rs.b	1
;gad_waveadjust			rs.b	1
gad_wavesample			rs.b	1
gad_waveSamplefreq		rs.b	1
gad_wavesampledlen		rs.b	1
gad_wavetrig			rs.b	1
gad_wavecreateinstr		rs.b	1
gad_wavecreateinstrFIX		rs.b	1
;gad_wavedelinstr		rs.b	1
gad_wavepitch			rs.b	1
gad_waveGainTXT			rs.b	1
gad_waveGainADD			rs.b	1
gad_waveGainSUB			rs.b	1
gad_waverangeloop		rs.b	1
gad_waveSeekZero		rs.b	1
gad_waveEcho			rs.b	1
gad_waveVibrato			rs.b	1
gad_waveFM			rs.b	1
gad_waveNormalDC		rs.b	1
gad_waveHQHPF			rs.b	1
gad_waveadd			rs.b	1
gad_wavesub			rs.b	1
gad_wavemul			rs.b	1
gad_wavemix			rs.b	1
gad_waveAM			rs.b	1
gad_wavelogicFREE		rs.b	1
gad_waveHardSync		rs.b	1
gad_waveWave2WT			rs.b	1
gad_waveWT2Wave			rs.b	1
gad_waveVariousFree		rs.b	1
gad_waveAddSpace		rs.b	1
gad_waveTimeWrap		rs.b	1
gad_wavePitchCng		rs.b	1

				rsset	1
gad_setupmodpath		rs.b	1
gad_setupmodpathGET		rs.b	1
gad_setupsamplepath		rs.b	1
gad_setupsamplepathGET		rs.b	1
gad_setupinstrpath		rs.b	1
gad_setupinstrpathGET		rs.b	1
gad_setupdseqpath		rs.b	1
gad_setupdseqpathGET		rs.b	1
gad_setuptexteditor		rs.b	1
gad_setupblanker		rs.b	1
gad_setupblankerGET		rs.b	1
gad_setupblankertimeout		rs.b	1
gad_setupfiltermode		rs.b	1
gad_setupwavedrawmode		rs.b	1
gad_setupload			rs.b	1
gad_setupsave			rs.b	1
gad_setupuse			rs.b	1
gad_setupabort			rs.b	1
gad_setupsaveremarkmode		rs.b	1
gad_setupsaveinstrnamesmode	rs.b	1
gad_setupaddppmode		rs.b	1
gad_setupcruncheffmode		rs.b	1
gad_setupcrunchmode		rs.b	1
gad_setupcrunchbufmode		rs.b	1
gad_setupbottomstatusmode	rs.b	1
gad_setupforcepalmode		rs.b	1


		rsset	1
gad_fmedfreq1			rs.b	1
gad_fmedattack1			rs.b	1
gad_fmeddecay1			rs.b	1
gad_fmedlevel1			rs.b	1
gad_fmedfreq2			rs.b	1
gad_fmedattack2			rs.b	1
gad_fmeddecay2			rs.b	1
gad_fmedlevel2			rs.b	1
gad_fmedpartwavesize		rs.b	1
gad_fmedpartwaves		rs.b	1
gad_fmedload			rs.b	1
gad_fmedsave			rs.b	1
gad_fmeddelete			rs.b	1
gad_fmeddo			rs.b	1
gad_fmeddestwave		rs.b	1
gad_fmedwavesel1		rs.b	1
gad_fmedwavesel2		rs.b	1
gad_fmedmake			rs.b	1

gyoff			=11	; Gadgets unter die Titelzeile verlegen!
ghi			=13	; Höhe eines Gadgets




;---------------------- GADTOOLS ----------------------------------------
; ASM-One - gadtools_lib.i
; (Release 3.0)
;
; by SCHWARZENEGGER/R.A.F

gadtools_CreateGadgetA		EQU	-30
gadtools_FreeGadgets		EQU	-36
gadtools_GT_SetGadgetAttrsA	EQU	-42
gadtools_CreateMenusA		EQU	-48
gadtools_FreeMenus		EQU	-54
gadtools_LayoutMenuItemsA	EQU	-60
gadtools_LayoutMenusA		EQU	-66
gadtools_GT_GetIMsg		EQU	-72
gadtools_GT_ReplyIMsg		EQU	-78
gadtools_GT_RefreshWindow	EQU	-84
gadtools_GT_BeginRefresh	EQU	-90
gadtools_GT_EndRefresh		EQU	-96
gadtools_GT_FilterIMsg		EQU	-102
gadtools_GT_PostFilterIMsg	EQU	-108
gadtools_CreateContext		EQU	-114
gadtools_DrawBevelBoxA		EQU	-120
gadtools_GetVisualInfoA		EQU	-126
gadtools_FreeVisualInfo		EQU	-132
gadtools_GT_GetGadgetAttrsA	EQU	-174

gtfi_matchpat		=tag_user+51
rtfi_flags		=tag_user+40
freqf_patgad		=2^4

			include	"libraries/gadtools.i2"
;---------------------- DOS ---------------------------------------------
dos_open		=-30
dos_close		=-36
dos_read		=-42
dos_write		=-48
dos_seek		=-66
dos_execute		=-222
dos_delay		=-198
dos_examineFH		=-390
dos_delete		=-72
dos_exit		=-144
dos_currentdir		=-126
dos_getprogramdir	=-600

;---------------------- POWERPACKER -------------------------------------
_LVOppLoadData		=-$1e
_LVOppDecrunchBuffer	=-$24
_LVOppCalcChecksum	=-$2a
_LVOppCalcPasskey	=-$30
_LVOppDecrypt		=-$36
_LVOppGetPassword	=-$3c
_LVOppAllocCrunchInfo	=-$60
_LVOppFreeCrunchInfo	=-$66
_LVOppCrunchBuffer	=-$6c
_LVOppWriteDataHeader	=-$72
_LVOppEnterPassword	=-$78
_LVOppErrorMessage	=-$84

;------------------------------------------------------------------------
credits			=0*4
pattedit		=1*4
arpedit			=2*4
drumseq			=3*4
setup			=4*4
fmsynthed		=5*4
;------------------------------------------------------------------------
visible			=0
invisible		=1
;------------------------------------------------------------------------
ls			=135	; lower screen
;------------------------------------------------------------------------
;longclickdelay		=30
;midclickdelay		=12
;fastclickdelay		=9
;------------------------------------------------------------------------
instred_dispoff		=41
patbploff		=128-12
woff			=161	; Offsets der Gadgets des Waveeditors
doff			=80*(3*ghi+(165+4+4-6-instred_dispoff+12))
				; Offset der Waveanzeige

wgOFF			=gyoff+woff+6+6*ghi
;------------------------------------------------------------------------
replayst_off		=0
replayst_pat		=1
replayst_all		=2
;------------------------------------------------------------------------
;------------------------------------------------------------------------
TEXTx			MACRO
			dc.b	1,0
			dc.b	0
			even
			dc	\1
			dc	\2
			dc.l	topaz8
			dc.l	\3
			dc.l	\4
			ENDM

lmouserel		MACRO
			btst	#6,$bfe001
			beq.s	*-8
			ENDM
lmouseclk		MACRO
			btst	#6,$bfe001
			bne.s	*-8
			ENDM

;GADGET			macro	; Asm-One bug: first arguement musn't be
; a label! (hmhm but only in this case!  strANGE fuck)
;			dc.l	\1	; Naechstes Gadget
;			dc	\2	; Obere X
;			dc	\3	; Obere Y
;			dc	\4	; Breite
;			dc	\5	; Höhe
;			dc	\6	; Flags
;			dc	3	; Activation flags
;			dc	\7	; Gadget-Typ
;			dc.l	\8	; Gadget-Border
;			dc.l	0	; Kein Select-Gadget
;			dc.l	\9	; Text-Gadget
;			dc.l	0	; Kein Exclude von anderen Gadgets
;			dc.l	\10	; Special info
;			dc	\11	; Gadget-ID
;			dc.l	0	; User-Data
;			endm

GADTEXT			MACRO
			dc.b	1,0	; Farben
			dc.b	0	; Farbmodus
			even
			dc	5	; X-Koordinate
			dc	4	; Y-Koordinate
			dc.l	topaz8	; ZEichensatz (=Topaz)
			dc.l	\1	; Textzeiger
			dc.l	0	; Kein weiterer Text
			ENDM

READ1			MACRO
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi	ioerror
			ENDM
READ2			MACRO
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi	ioerror2
			ENDM
WRITE1			MACRO
			move.l	filehandle(a5),d1
			jsr	dos_write(a6)
			tst.l	d0
			bmi	ioerror
			ENDM
CLOSEFILE		MACRO
			move.l	filehandle(a5),d1
			beq.b	.closed
			jmp	dos_close(a6)
.closed
			ENDM

WRITE2			MACRO
			move.l	filehandle(a5),d1
			jsr	dos_write(a6)
			tst.l	d0
			bmi	ioerror2
			ENDM
;------------------------------------------------------------------------
;------------------------------------------------------------------------


			SECTION	artOfNoise,code


	bra.b	wbstartup
	dc.b	"$VER: ArtOfNoise V1.9  Assembled on 23-Oct-95",0
		even
regchecksum 	dc.l	$1696

wbmsg		dc.l	0


wbstartup	

;			lea	msg_betatester,a0
;			moveq	#0,d0
;			moveq	#0,d1
;			move	#$90-1,d7
;.addloop		move.b	(a0)+,d0
;			add.l	d0,d1
;			dbf	d7,.addloop
;			rts



		move.l	$4.w,a6
		sub.l	a1,a1
		jsr	-294(a6)
		move.l	d0,a4
		tst.l	$ac(a4)
		bne.b	.cli
		lea	$5c(a4),a0
		jsr	-384(a6)
		jsr	-372(a6)	; GetMSG
		move.l	d0,wbmsg
.cli


			move.l	exec,a6
			lea	main_data,a5

;--------------------------------------------------------------------
; Check processor
			clr.l	vbreg(a5)

			btst	#1,297(a6)
			beq.b	.no68020
			move.b	#1,extproc(a5)

			movem.l	d1-a6,-(sp)
			lea	getVBR(pc),a5
			jsr	-30(a6)
			movem.l	(sp)+,d1-a6
			move.l	d0,vbreg(a5)

.no68020

;--------------------------------------------------------------------
; Init sampler
			move	#214,sample_period(a5)	; c-5
			move.l	#65536,sample_len(a5)
			move.b	#10,trig_sens(a5)

;--------------------------------------------------------------------
; 8ch init
			move	#default_mixrate,mix_mixrate
			lea	mix_buff1data,a0
			lea	mix_buff1,a1
			lea	mix_buff1hear,a2
			move.l	a0,(a1)+
			lea	128(a0),a0
			move.l	a0,(a2)+
			lea	128(a0),a0
			move.l	a0,(a1)+
			lea	128(a0),a0
			move.l	a0,(a2)+
			lea	128(a0),a0
			move.l	a0,(a1)+
			lea	128(a0),a0
			move.l	a0,(a2)+
			lea	128(a0),a0
			move.l	a0,(a1)+
			lea	128(a0),a0
			move.l	a0,(a2)+

;------------------------------------------------------------------------
			move.l	thistask(a6),mytask(a5)

;---------------------- Open Libraries ----------------------------------

			lea	intname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,intbase(a5)
;;;;;;;;;;;;;;  setfunction benutzen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

			move.l	d0,a1
			sub.l	a0,a0
			move	#-96,a0
			move.l	#patch_displaybeep,d0
			jsr	exec_setfunction(A6)
			move.l	d0,old_displaybeep(a5)

;;;;;;;;;;;;;;  setfunction benutzen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


			lea	diskfontname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,diskfontbase(a5)
			bne.b	.diskok
			lea	msg_nodiskfontlib,a2
			jsr	displaymessage
			jmp	diskfont_error
.diskok
			lea	utilname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,utilbase(a5)
			bne.b	.utilok
			lea	msg_noutillib,a2
			jsr	displaymessage
			jmp	util_error
.utilok
			lea	gfxname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,gfxbase(a5)
			bne.b	.gfxok
			jmp	gfx_error
.gfxok
			lea	gadtoolsname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,gadtoolsbase(a5)
			bne.b	.gadok
			jmp	gadtools_error
.gadok
			lea	reqtoolsname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,rtbase(a5)
			bne.b	.reqok
			lea	msg_noreqlib,a2
			jsr	displaymessage
			jmp	reqtools_error
.reqok
			lea	dosname,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,dosbase(a5)
			bne.b	.dosok
			jmp	dos_error
.dosok
			lea	powerpackername,a1
			moveq	#0,d0
			jsr	exec_openlib(a6)
			move.l	d0,pp_base(a5)
			bne.b	.penisok
			lea	msg_nopplib,a2
			jsr	displaymessage
			jmp	pp_error
.penisok

			clr.l	window1ptr(a5)

;		ifne	copylock
;		jsr	copyprotect
;		endif

; --------------------- Alloc memory .....-------------------------------

;---------------------- Modul initalisieren -----------------------------

			jsr	init_module

			move.l	#module_songname,mp_songnameptr
			move.l	#module_songauthor,mp_authorptr
			move.l	#module_songdate,mp_dateptr

;---------------------- Preferences einlesen ----------------------------
			move.l	#prf_filename,d1
			bsr	readprefsDEF

;--------------------------------------------------------------------
; Instr. Namen mit ' ' füllen
			lea	module_instrnames,a0

			moveq	#61-1,d7
			move.l	#"    ",d0
			move.l	#$20202000,d1
.initmenunames		move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d0,(a0)+
			move.l	d1,(a0)+
			dbf	d7,.initmenunames

;---------------------- Init artofnoise-font ------------------------

			move.l	diskfontbase(a5),a6
			lea	topaz8,a0
			jsr	-30(a6)
			tst.l	d0
			bne.b	.ok235r
			lea	msg_nofont,a2
			jsr	displaymessage
			jmp	fonterror
.ok235r

;---------------------- Open Screen & Window ------------------------
			move	#240,filereqH+2
			move	#240,filereqH2+2
			move	#240,dirreqH+2

			move.l	intbase(a5),a6

			tst.b	prf_data+prf_forcepal
			bne.b	.palface
			move.l	#52980,hzticks(a5)
			move.l	#def1,screenmode
			move	#400,win1h
			move	#400,win1h2
			move	#389,win1h3
			move	#400,screenheigth
			lea	screendata1,a0
			lea	screentags1,a1
			jsr	int_openscreenTagList(a6) ; Screen öffnen
			tst.l	d0
			bne.b	.gotit
.palface
			move.l	#74172,hzticks(a5)
			move.l	#def2,screenmode
			move	#241,win1h
			move	#241,win1h2
			move	#241,win1h3
			move	#252,screenheigth
			lea	screendata1,a0
			lea	screentags1,a1
			jsr	int_openscreenTagList(a6) ; Screen öffnen
			tst.l	d0
			bne.b	.screenok
			jmp	errorscreen
.screenok
.gotit			move.l	d0,screenptr(a5)
			move.l	d0,window1screenptr
			move.l	d0,window2screenptr
			move.l	d0,dseq_windowscreenptr
			move.l	d0,setup_windowscreenptr
			move.l	d0,pp_windowscreenptr
			move.l	d0,fmed_windowscreenptr
			move.l	d0,a0
			lea	scr_bitmap(a0),a0	; Bitmap-Struktur
			move.l	bm_planes+0(a0),bitplane1_startadr(a5)
			move.l	bm_planes+4(a0),bitplane2_startadr(a5)
; rowsize=80 (non-interleaved)

			lea	window1struct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window1ptr(a5)
			bne.b	.winok
			jmp	errorWindow1
.winok
			move.l	d0,a0
			move.l	$32(a0),rastport1(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userport1(a5)
			move.l	d0,mod_filereqWINPTR	; Für Filerequester
			move.l	d0,mod_dirreqWINPTR	; Für Filerequester

			move.l	gadtoolsbase(a5),a6
			move.l	screenptr(a5),a0
			lea	VisualInfo_Tag,a1
			jsr	gadtools_GetVisualInfoA(a6)
			move.l	d0,getvisual(a5)

			lea	gadgetlist(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;--------- Bevel-Box zeichnen -----------
; Für Positionsliste
			move.l	rastport1(a5),a0
			move.l	#480,d0
			moveq	#gyoff,d1
			move.l	#140,d2
			move.l	#ghi*6,d3
			lea	bevel_recessed_tags,a1
			move.l	getvisual(a5),4(a1)
			jsr	gadtools_drawbevelboxa(a6)
; Patterndisplay
			moveq	#0,d3
			move	win1h,d3
			sub	#102,d3

			move.l	rastport1(a5),a0
			moveq	#0,d0
			moveq	#102,d1
			move.l	#640,d2
;		move.l	#139,d3
			lea	bevel_recessed_tags,a1
			move.l	getvisual(a5),4(a1)
			jsr	gadtools_drawbevelboxa(a6)

			move.l	gfxbase(a5),a6
			jsr	gfx_waitblit(a6)
			move.l	gadtoolsbase(a5),a6

;; Track1
;			move.l	rastport1(a5),a0
;			move.l	#5*8,d0
;			moveq	#102,d1
;			move.l	#18*8,d2
;			move.l	#67,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)
;			move.l	rastport1(a5),a0
;			move.l	#5*8,d0
;			move.l	#177,d1
;			move.l	#18*8,d2
;			move.l	#64,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)
;; Track2
;			move.l	rastport1(a5),a0
;			move.l	#23*8,d0
;			moveq	#102,d1
;			move.l	#(18)*8,d2
;			move.l	#67,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)
;			move.l	rastport1(a5),a0
;			move.l	#23*8,d0
;			move.l	#177,d1
;			move.l	#(18)*8,d2
;			move.l	#64,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)
							; Gadget initalisieren
;--------- Menu-Zeile initalisieren -----
			lea	menustruct,a0
			lea	menutags,a1
			jsr	gadtools_CreateMenusA(a6)
			move.l	d0,menuaddr(a5)
			move.l	d0,a0
			move.l	getvisual(a5),a1
			lea	layouttags,a2
			jsr	gadtools_LayoutMenusA(a6)
			move.l	window1ptr(a5),a0
			move.l	menuaddr(a5),a1
			move.l	intbase(a5),a6
			jsr	int_SetMenuStrip(a6)

;--------- Gadgets eintragen ------------
			move.l	gadtoolsbase(a5),a6

			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mp_gadgetptrs+4,a5
			lea	mp_gadgetstructptrs,a4
allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.s	allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	allocGadgetsLoop
AllocGadgetsEND		move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6

			move.l	window1ptr(a5),a0	; Gadget in
			move.l	gadgetlist(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

			move.l	gadgetlist(a5),a0	; Gadgets zeichnen
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)

; String-Gadgetbuffer auf eigene buffer unlenken
			lea	mp_gadgetptrs,a0
			move.l	gad_songname*4(a0),a1	; a1=Ptr auf Gadget
			move.l	$22(a1),a2	; Gadget-Special-Info
			move.l	#module_songname,(a2)	; Songname
			move.l	gad_songauthor*4(a0),a1
			move.l	$22(a1),a2	; Songauthor
			move.l	#module_songauthor,(a2)
			move.l	gad_songdate*4(a0),a1
			move.l	$22(a1),a2	; Songdate
			move.l	#module_songdate,(a2)
			move.l	gad_instrumentname*4(a0),a1
			move.l	$22(a1),a2
			move.l	#module_instrnames,(a2)	; Instrname
; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6

			move.l	window1ptr(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)

;--------------------------------------------------------------------
;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
; Wave-Screen initalisieren
ALLOCSCREEN2
			move.l	intbase(a5),a6
			move.l	screenmode,screenmode2

			lea	screendata2,a0
			lea	screentags2,a1
			jsr	int_openscreenTagList(a6) ; Screen öffnen
			tst.l	d0
			bne.b	.gotit2
			jmp	errorscreen2
.gotit2			move.l	d0,screenptr2(a5)
			move.l	d0,instred_windowscreenptr
			move.l	d0,a0
			lea	scr_bitmap(a0),a0	; Bitmap-Struktur
			move.l	bm_planes+0(a0),bitplane1_startadr2(a5)
			move.l	bm_planes+4(a0),bitplane2_startadr2(a5)
			move.l	bm_planes+8(a0),bitplane3_startadr2(a5)

			move.l	gadtoolsbase(a5),a6
			move.l	screenptr2(a5),a0
			lea	VisualInfo_Tag,a1
			jsr	gadtools_GetVisualInfoA(a6)
			move.l	d0,getvisual2(a5)

			move.l	intbase(a5),a6
			lea	instred_windowstruct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,windowptrwave(a5)
			bne.b	.windowopened
			jmp	instredwindowerror
.windowopened
				; ausgegeben wird!

			move.l	d0,a0
			move.l	$32(a0),rastportwave(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userportwave(a5)
			move.l	d0,mod_filereqWINPTRwave ; Für Filerequester

			move.l	gadtoolsbase(a5),a6
			lea	gadgetlistwave(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;-------------------------------------- Zahlen Hintergrund mit Blau füllen

			move.l	a6,-(sp)
			move.l	gfxbase(a5),a6

; Wavenr
			move.l	rastportwave(a5),a1
			moveq	#0,d0
			move	#258,d1
			move	#54,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill
; Wave
			move.l	rastportwave(a5),a1
			move	#116,d0
			move	#258,d1
			move	#160,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill
; Display
			move.l	rastportwave(a5),a1
			move	#224,d0
			move	#258,d1
			move	#292,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill
; Pos
			move.l	rastportwave(a5),a1
			move	#356,d0
			move	#258,d1
			move	#394,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill
; Range
			move.l	rastportwave(a5),a1
			move	#456,d0
			move	#258,d1
			move	#510,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill
; Gain
			move.l	rastportwave(a5),a1
			move	#570,d0
			move	#258,d1
			move	#615,d2
			move	#258+8,d3
			jsr	-306(a6)	rectfill



			move.l	(sp)+,a6

;--------- Gadgets eintragen ------------
			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mpwave_gadgetptrs+4,a5
			lea	instred_gadgetstructptrs,a4
.allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.b	.allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual2+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	.allocGadgetsLoop
.AllocGadgetsEND	move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6
			move.l	windowptrwave(a5),a0	; Gadget in
			move.l	gadgetlistwave(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

			move.l	gadgetlistwave(a5),a0	; Gadgets zeichnen
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)

; String-Gadgets umlenken
			lea	mpwave_gadgetptrs,a0
			move.l	gad_instredname*4(a0),a1
			move.l	$22(a1),a2
			move.l	#module_instrnames,(a2)	; Instrname

			move.l	gad_instrVIBpara*4(a0),a1
			move.l	$22(a1),a2
			move.l	#instred_actVIBparaASC,(a2)	; Instrname
; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)

;--------------- ???????? -----------------

; Bevel-Boxen designen INSTRUMENTED
			move.l	rastportwave(a5),a0
			moveq	#4,d0
			move.l	#165-6-instred_dispoff+3*ghi,d1
			move.l	#640-8,d2
			move.l	#64+8,d3
			lea	bevel_recessed_tags,a1
			move.l	getvisual2(a5),4(a1)
			jsr	gadtools_drawbevelboxa(a6)

;		jsr	refresh_instredCopyFrom
;		jsr	refresh_instredCopyto

;; Bevel-Box designen WAVEED
;
;			move.l	rastportwave(a5),a0
;			move.l	#640-136-4,d0
;			move.l	#gyoff+woff+ghi*6+7,d1
;			move.l	#136,d2
;			move.l	#ghi*4,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)


; Gadgetgruppen-Betitelungen

; Sample-Edit funktionen
			move.l	bitplane1_startadr2(a5),a1
			lea	297*80(a1),a1
			lea	gfx_wavetitles1,a0
			moveq	#6-1,d7
.wavetitles1		rept	20
			move.l	(a0)+,(a1)+
			endr
			dbf	d7,.wavetitles1

; Sampler etc
			move.l	bitplane1_startadr2(a5),a1
			lea	388*80(a1),a1
			lea	gfx_wavetitles2,a0
			moveq	#6-1,d7
.wavetitles2		rept	20
			move.l	(a0)+,(a1)+
			endr
			dbf	d7,.wavetitles2

; Sample options
			move.l	bitplane1_startadr2(a5),a1
			lea	27*80+38(a1),a1
			lea	gfx_wavetitles2+8*80,a0
			moveq	#6-1,d7
.wavetitles3		rept	20
			move.b	(a0)+,(a1)+
			endr
			lea	80-20(a0),a0
			lea	80-20(a1),a1
			dbf	d7,.wavetitles3
; Wavetable options
			move.l	bitplane1_startadr2(a5),a1
			lea	66*80+38(a1),a1
			lea	gfx_wavetitles2+16*80,a0
			moveq	#6-1,d7
.wavetitles4		rept	20
			move.b	(a0)+,(a1)+
			endr
			lea	80-20(a0),a0
			lea	80-20(a1),a1
			dbf	d7,.wavetitles4
; Envelope options
			move.l	bitplane1_startadr2(a5),a1
			lea	(66+5*13)*80+38(a1),a1
			lea	gfx_wavetitles2+24*80,a0
			moveq	#6-1,d7
.wavetitles5		rept	20
			move.b	(a0)+,(a1)+
			endr
			lea	80-20(a0),a0
			lea	80-20(a1),a1
			dbf	d7,.wavetitles5


;; Logo einblenden
;			move.l	bitplane1_startadr2(a5),a1
;			lea	171*80(a1),a1
;			lea	190*80+1(a1),a1
;			lea	gfx_wavelogo+1,a0
;			moveq	#19-1,d7
;wavelogoloop		moveq	#46-1,d6
;.xloop			move.b	(a0)+,(a1)+
;			dbf	d6,.xloop
;			addq.l	#4,a0
;			lea	34(a1),a1
;			dbf	d7,wavelogoloop

;			move.l	rastportwave(a5),a0
;			moveq	#4,d0
;			move.l	#348,d1
;			move.l	#400,d2
;			move.l	#ghi*2,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)


			jsr	waveed_setshowall
			jsr	refresh_waveedwaveALL
			jsr	refresh_wavewaveslider
;	jsr	refresh_waveedCopyFrom
;	jsr	refresh_waveedCopyTo
			jsr	refresh_waveedpartwavelen
			jsr	refresh_waveedsamplefreq
			jsr	refresh_waveedsampledlen
			jsr	refresh_waveedtrig
			jsr	refresh_waveedsamplefreq


;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


;---------------------- Filerequester initalisieren ---------------------
			move.l	rtbase(a5),a6
			moveq	#rt_palettereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,palettereqptr(a5)
			bne.b	.palok
			jmp	palette_reqERROR
.palok
			moveq	#rt_filereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,modreqptr(a5)
			bne.b	.modok
			jmp	mod_filereqERROR
.modok
			moveq	#rt_filereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,instrreqptr(a5)
			bne.b	.instrok
			jmp	instr_filereqERROR
.instrok
			moveq	#rt_filereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,sampleReqptr(a5)
			bne.b	.sampok
			jmp	sample_filereqERROR
.sampok

			moveq	#rt_filereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,dseqReqptr(a5)
			bne.b	.dseqok
			jmp	dseq_filereqERROR
.dseqok
			moveq	#rt_filereq,d0
			sub.l	a0,a0
			jsr	rtAllocRequestA(a6)
			move.l	d0,varreqptr(a5)
			bne.b	.varok
			jmp	var_filereqERROR
.varok


; Bis hier läufts KICK2.0 500er


;---------------------- Umwandlungstabelle für Integer>Ascii erstellen --

			lea	txt_3charsnrs,a1
			moveq	#0,d7
ifiat_loOOp		move.l	d7,d0
			and.l	#$000003ff,d0
			beq.s	ifiat_div1ZERO
			divu	#100,d0		; 100-Stelle
ifiat_div1zero		add.b	#"0",d0
			move.b	d0,(a1)+
			clr	d0
			swap	d0		; Rest
			tst	d0
			beq.s	ifiat_div2ZERO
			divu	#10,d0		; 10-Stelle
ifiat_div2zero		add.b	#"0",d0
			move.b	d0,(a1)+
			clr	d0
			swap	d0
			add.b	#"0",d0
			move.b	d0,(a1)+
			move.b	#1,(a1)+
			addq	#1,d7
			cmp	#1000,d7
			bne.s	ifiat_loOOp
; das gleiche nochmal ,aber nur mit 2 stellen diesmal!
			lea	txt_2charsnrs,a1
			moveq	#0,d7
ifiat_loOOp2		move.l	d7,d0
			and.l	#$0000007f,d0
			beq.s	ifiat_div1ZERO2
			divu	#10,d0		; 100-Stelle
ifiat_div1zero2		add.b	#"0",d0
			move.b	d0,(a1)+
			clr	d0
			swap	d0		; Rest
			add.b	#"0",d0
			move.b	d0,(a1)+
			move.b	#1,(a1)+
			move.b	#1,(a1)+
			addq	#1,d7
			cmp	#100,d7
			bne.s	ifiat_loOOp2


; -------------------------------------------------------------------

makefastosctab		lea	FASTosctab,a0
			moveq	#0,d5
.loop1			moveq	#0,d7
.loop2			move	d7,d0
			mulu	d5,d0
			lsr	#6,d0
			mulu	#80,d0
			move	d0,(a0)+
			addq	#1,d7
			cmp	#128,d7
			bne.b	.loop2
			addq	#1,d5
			cmp	#17,d5
			bne	.loop1

; --------------------- Init Interrupts -----------------------------


intinit
		move.b	#1,lockint(a5)	; Interrupts noch nicht starten

; -------------------------------------------------------------------
; CIA-Interrupts

			move.l	exec,a6
; CIA B allokieren
			moveq	#0,d0
			lea	ciaBname,a1
			move.l	exec,a6
			jsr	exec_openresource(a6)
			move.l	d0,ciaBbase
			bne.b	.ciaBok
			lea	msg_sys_notimerB,a2
			jsr	displaymessage
			jmp	ciaErrorB	; Resource geöffnet?!
.ciaBok

			move.l	d0,a6

			lea	TimerIntServerB,a1
			moveq	#1,d0			; bit 1: timer b
			jsr	cia_addicrvector(a6)	; Timer-Interrupt dazu
			tst.l	d0
			beq.b	.ciaBok2
			lea	msg_sys_notimerB,a2
			jsr	displaymessage
			jmp	CiaErrorB	; Installiert?!?!?!
.ciaBok2

			move.b	#$6c,$bfd600
			move.b	#$37,$bfd700
			bset	#0,$bfdf00	; Timer Start


;--------------------------------------------------------------------
; VBI installieren
			moveq	#5,d0
			lea	vbintserver,a1
			move.l	exec,a6
			jsr	exec_addintserver(a6)

;--------------------------------------------------------------------
; Serial-Interrupt installieren (midi!!)

midi_init
			move	$dff01c,d0
			btst	#11,d0		; ist der rbf interrupt
			bne	.initfail	; zur zeit
			btst	#12,d0		; noch unbenutzt?!
			bne	.initfail
			btst	#0,d0		; tbe interrupt
			bne	.initfail
			move	#$4000,$dff09a
			move.l	$64,old_level1+2
			move.l	$74,old_level5(a5)
			move.l	#tbe,$64
			move.l	#rbf,$74
			move	#$c801,$dff09a
			move	#113,$dff032
			bra.b	.ok
.initfail		lea	msg_midi_noserial,a2
			jsr	displaymessage
			jmp	midi_fail
.ok


;------------------------------------------------------------------------
initdseqvoltab		lea	dseq_volbytetab,a0
			moveq	#0,d0
			moveq	#1,d7		; zählt von 1-15
.loop			move	d0,d1
			ext	d1
			muls	d7,d1
			asr	#4,d1
			move.b	d1,(a0)+
			addq.b	#1,d0
			bne.b	.loop
			addq.b	#1,d7
			cmp.b	#16,d7
			bne.b	.loop

;--------------------------------------------------------------------



;---------------------- Init module -------------------------------------

initmod
			moveq	#0,d0			; startpos
			jsr	aon_init


;-------- FONT KONVERTIEREN -----------------*
			lea	gfx_fontor,a0
			lea	gfx_font,a1
			moveq	#3-1,d7
convfont_rowloop	moveq	#80-1,d6
convfont_lineloop
			move.b	160*0(a0),480*0(a1)
			move.b	160*0+1(a0),480*0+1(a1)
			move.b	160*1(a0),480*1(a1)
			move.b	160*1+1(a0),480*1+1(a1)
			move.b	160*2(a0),480*2(a1)
			move.b	160*2+1(a0),480*2+1(a1)
			move.b	160*3(a0),480*3(a1)
			move.b	160*3+1(a0),480*3+1(a1)
			move.b	160*4(a0),480*4(a1)
			move.b	160*4+1(a0),480*4+1(a1)
			move.b	160*5(a0),480*5(a1)
			move.b	160*5+1(a0),480*5+1(a1)
			move.b	160*6(a0),480*6(a1)
			move.b	160*6+1(a0),480*6+1(a1)
			move.b	160*7(a0),480*7(a1)
			move.b	160*7+1(a0),480*7+1(a1)
			addq.l	#2,a0
			addq.l	#2,a1
			dbf	d6,convfont_lineloop
			lea	160*7(a0),a0
			dbf	d7,convfont_rowloop



			jsr	init_newpatterns

			move.b	#replayst_off,replaystatus(a5)
			move.b	#%00001111,ch_enable(a5)
			clr	acteditinstr(a5)
;move	#1,acteditinstr(a5)


			move.b	#pattedit,programmode(a5)	; set startmode
;bsr	print_abouttext


a



			jsr	refresh_pos
			jsr	refresh_pat
			jsr	refresh_editpat
			jsr	refresh_max
			jsr	refresh_res
			move.b	#$f,pattdspreq(a5)


			bsr	drawhilitepattern

;---------------------- Default-Pfade setzen ----------------------------

			tst.b	defpref(a5)
			beq.b	.notwbcols

			lea	prf_data+prf_col0,a1
			move.l	gfxbase(a5),a0
			move.l	50(a0),a0	; clist
			moveq	#4-1,d7
			move	#$180,d3
.search0		cmp	(a0)+,d3
			bne.b	.search0
			move	(a0)+,d0
			move	d0,d1
			move	d0,d2
			and	#$f00,d0
			and	#$0f0,d1
			and	#$00f,d2
			lsr	#8,d0
			lsr	#4,d1
			move.b	d0,(a1)+
			move.b	d1,(a1)+
			move.b	d2,(a1)+
			addq	#2,d3
			dbf	d7,.search0
.notwbcols
			bsr	initprefs

			move.l	modreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	prf_data+prf_modulepath,a1
			moveq	#32-1,d7
.modpfad		move.b	(a1)+,(a0)+
			dbf	d7,.modpfad

			move.l	samplereqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	prf_data+prf_samplepath,a1
			moveq	#32-1,d7
.samplepfad		move.b	(a1)+,(a0)+
			dbf	d7,.samplepfad

			move.l	instrReqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	prf_data+prf_instrpath,a1
			moveq	#32-1,d7
.instrpfad		move.b	(a1)+,(a0)+
			dbf	d7,.instrpfad

			move.l	dseqreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	prf_data+prf_dseqpath,a1
			moveq	#32-1,d7
.dseqpfad		move.b	(a1)+,(a0)+
			dbf	d7,.dseqpfad

			move.b	#4,addstep(a5)

			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			clr.b	(a0)

;---------------------- User-CList initalisieren --------------------

;			move.l	exec,a6
;			moveq	#32,d0
;			move.l	#$10002,d1
;			jsr	exec_allocmem(a6)
;			move.l	d0,myclist(a5)
;
;			move.l	gfxbase(a5),a6
;			move.l	myclist(a5),d7
;			move.l	d7,a0
;			moveq	#32,d0
;			jsr	gfx_ucopperlistinit(a6)
;
;			move.l	d7,a1
;			move	#$73,d0
;			move	#$d1,d1
;			jsr	gfx_cwait(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$100,d0
;			move	#$0,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$1fe,d0
;			move	#$1977,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$0e0,d0
;			move.l	bitplane1_startadr(a5),d1
;			add.l	#patbploff*80,d1
;			swap	d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;			move.l	d7,a1
;			move	#$0e2,d0
;			move.l	bitplane1_startadr(a5),d1
;			add.l	#patbploff*80+1,d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$0e4,d0
;			move.l	bitplane2_startadr(a5),d1
;			add.l	#patbploff*80,d1
;			swap	d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;			move.l	d7,a1
;			move	#$0e6,d0
;			move.l	bitplane2_startadr(a5),d1
;			add.l	#patbploff*80,d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$74,d0
;			move	#$0f,d1
;			jsr	gfx_cwait(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	d7,a1
;			move	#$100,d0
;			move	#$a200,d1
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;
;			cmp	#400,win1h
;			beq.b	.euro
;			move.l	d7,a1
;			move	#$fc,d0
;			move	#$f,d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cwait(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;			move.l	d7,a1
;			move	#$100,d0
;			moveq	#1,d1
;			and.l	#$ffff,d0
;			jsr	gfx_cmove(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;.euro
;			move.l	d7,a1
;			move	#10000,d0
;			move	#$ff,d1
;			and.l	#$ffff,d0
;			and.l	#$ffff,d1
;			jsr	gfx_cwait(a6)
;			move.l	d7,a1
;			jsr	gfx_cbump(a6)
;
;			move.l	screenptr(a5),a0
;			lea	44(a0),a0
;			move.l	a0,viewport(a5)
;
;			move.l	d7,20(a0)
;
;			move.l	intbase(a5),a6
;			jsr	int_rethinkdisplay(a6)

			move.l	screenptr(a5),a0
			move.l	intbase(a5),a6
			jsr	int_screentofront(a6)

;--------------------------------------------------------------------
; Signal allokieren (neuen pattern zeichnen ?!)	

			move.l	#-1,d0
			move.l	exec,a6
			jsr	exec_allocSignal(a6)	Signal allokieren
			tst.l	d0
			bpl.b	.sigok

.waiterr		move	#$f00,$dff180
			btst	#6,$bfe001
			bne.b	.waiterr

.sigOK
			move.l	d0,signalnr(a5)

;--------------------------------------------------------------------
; Default-Preferences Warnung ausgeben ?!
			tst.b	defpref(a5)
			beq.b	.prefloaded
			lea	msg_prf_usingdefault,a2
			jsr	displaymessage
.prefloaded
			bsr	initprefs


;	jsr	checkhertzschmerz

;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
;---------------------- Main loop ---------------------------------------
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

			jsr	printnewpatterns
			bsr	aboutaon

			move.b	#34,dseq_pitch(a5)
			move.b	#6,dseq_speed(a5)
			move.b	#125,dseq_tempo(a5)
PATTERNED:
			clr.b	screen(a5)

			clr.b	lockint(a5)

			move.l	window1ptr(a5),a0
			move.l	intbase(a5),a6
			jsr	int_activatewindow(a6)

			bsr	printposlist
			jsr	adjust_pattdisplay

;------------------------------------------------------------------------
; MAIN loop..  check gadgets,execute subroutines etc..
mmm

			move.l	userport1(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.s	m_messyDa

			move.l	window1ptr(a5),a0
			jsr	waitsignal

;		moveq	#-1,d0
;		move.l	exec,a6
;		move.l	a3,a0			; aus dem
;		jsr	exec_waitport(a6)	; 'Faszination

			jsr	printnewpatterns
			jsr	adjust_pattdisplay

			bra.b	mmm

;	moveq	#-1,d0
;	move.l	exec,a6
;	jsr	exec_allocSignal(a6)
;	tst.b	d0		; War eins frei?!
;	bmi.b	mmm
;	move.b	d0,mp_sigbit(a3)
;	move.l	thistask(a6),mp_sigtask(a3)
;	clr.b	mp_flags(a3)		; message-routine
;	move.l	a3,a0			; aus dem
;	jsr	exec_waitport(a6)	; 'Faszination
;	move.b	#pa_ignore,mp_flags(a3)	;  Programmieren'
;	move.b	mp_sigbit(a3),d0	; 2/93'
;	jsr	exec_freesignal(a6)	; by Markus Adamski
;	clr.b	mp_sigbit(a3)
;	bsr	printnewpatterns
;	bra.b	mmm


m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#menupick,$14(a0)
			beq	menupicked


			cmp.l	#rawkey,$14(a0)
			beq	keypressedMAIN

			cmp.l	#gadgetup,$14(a0)
			beq	m_checkgadgetsUP
			cmp.l	#gadgetdown,$14(a0)
			beq	m_checkgadgetsDOWN

			cmp.l	#intuiticks,$14(a0)
			beq	intuiticks_update

			cmp.l	#activewindow,$14(a0)
			beq	activatewindow

			cmp.l	#inactivewindow,$14(a0)
			beq	instred_inactivated

			cmp.l	#mousebuttons,$14(a0)
			beq.b	adjustpattcursor

			cmp.l	#mousemove,$14(a0)
			bne.b	.not
			cmp	#gad_changeinstrnr,lastdownid(a5)
			beq	instrnrchangeNOW
			cmp	#gad_changepos,lastdownid(a5)
			beq	poslistchangeNOW
.not

			bra	mmm

;---------------------- Auf Signal warten (exec) ------------------------
; a0=windowptr
WaitSignal:
			movem.l	d0-a6,-(sp)
			move.l	86(a0),a0	; userport
			moveq	#0,d1
			move.b	15(a0),d1	; mp_sigbit
			moveq	#0,d0		; aus bit
			bset	d1,d0		; nr machen
			move.l	signalnr(a5),d1	; allokierte signalnr holen
			bset	d1,d0
			move.l	exec,a6
			jsr	exec_Wait(a6)
			movem.l	(sp)+,d0-a6
			rts

;---------------------- Mouse-Button pressed ----------------------------
adjustpattcursor
			btst	#6,$bfe001
			bne	mmm

			moveq	#0,d1
			move.b	aon_data+aon_patcnt+1,d1
			move.l	window1ptr(a5),a0
			moveq	#0,d0
			move	$c(a0),d0	; mouse-y

; Kanäle an/aus schalten?!
			cmp	#100,d0
			bhs.b	.notchtoggle
			cmp	#92,d0
			bls.b	.notchtoggle
			move	$e(a0),d1
			cmp	#490,d1
			bls.b	.notchtoggle
			cmp	#616,d1
			bhs.b	.notchtoggle
			sub	#490,d1
			move.l	#mmm,-(sp)
			lsr	#4,d1
			beq	togglech1now
			cmp.b	#1,d1
			beq	togglech2now
			cmp.b	#2,d1
			beq	togglech3now
			cmp.b	#3,d1
			beq	togglech4now
			cmp.b	#4,d1
			beq	togglech5now
			cmp.b	#5,d1
			beq	togglech6now
			cmp.b	#6,d1
			beq	togglech7now
			bra	togglech8now
.notchtoggle
			sub	#106,d0
			bmi.w	testposlist
			tst.b	replaystatus(a5)
			bne	mmm
			cmp	#400,win1h
			bne.b	.pal
			lsr	#1,d0
.pal			lsr	#3,d0		; /8
			add	d0,d0
			add	d0,d0
			add	d0,d1		; + First step in pic
			sub	#8*4,d1
			bmi	mmm
			cmp	#256,d1
			bhs	mmm
			move.b	d1,aon_data+aon_patcnt+1
			move	$e(a0),d0	; mouse-x
			tst.b	chmode(a5)
			bne.b	.8chnoadd
			lsr	#4,d0		; /8
			add	d0,d0
			bra.b	.4chadd
.8chnoadd		lsr	#3,d0
.4chadd

; d0=0-79
			subq	#2,d0
			bmi	mmm

			tst.b	chmode(a5)
			beq.b	.4ch

			lea	cursorpositions8,a0
			moveq	#0,d1
			moveq	#6*8-1,d7
.searchpos8		cmp.b	(a0)+,d0
			beq.b	.posfound
			addq.b	#2,d1
			dbf	d7,.searchpos8
			bsr	actmarkpos
			bra	mmm
.4ch
			lea	cursorpositions,a0
			moveq	#0,d1
			moveq	#6*4-1,d7
.searchpos		cmp.b	(a0)+,d0
			beq.b	.posfound
			addq.b	#2,d1
			dbf	d7,.searchpos
			bsr	actmarkpos
			bra	mmm
.posfound		move.b	d1,patcntx(a5)
			bsr	actmarkpos
			bra	mmm
;.togglequadrascope	move.l	#mmm,-(sp)
;			bra	togglequadrascope
testposlist
			move	$e(a0),d1	; mouse-x
			cmp	#484,d1
			blt	mmm
			cmp	#612,d1
			bhi	mmm
			cmp	#-91,d0
			blt	mmm
			cmp	#-20,d0
			bgt	mmm
			add	#60,d0
			asr	#3,d0
			moveq	#0,d1
			move.b	aon_data+aon_pos,d1
			add	d0,d1
			bmi	mmm
			cmp	#255,d1
			bhi	mmm
			move.b	d1,d0
			bsr	spc_routentry
			bra	mmm

;---------------------- Intuiticks_Update -------------------------------
intuiticks_update
			jsr	showrecord

			moveq	#0,d0
			move.b	aon_speed+aon_data,d0
			cmp.b	oldspeed(a5),d0
			beq.s	iu_nospeedchange
			move.b	d0,oldspeed(a5)
			move.l	d0,rog_taglist+4
			moveq	#rog_speed,d0
			jsr	refresh_number_kind
iu_nospeedchange
			moveq	#0,d0
			move.b	aon_tempo+aon_data,d0
			cmp.b	oldtempo(a5),d0
			beq.s	iu_notempochange
			move.b	d0,oldtempo(a5)
			move.l	d0,rog_taglist+4
			moveq	#rog_tempo,d0
			jsr	refresh_number_kind
iu_notempochange

			move.b	acteditpattern+1(a5),d0
			cmp.b	last_edpat(a5),d0
			beq.s	itt_patNotChanged
			move.b	d0,last_edpat(a5)
			jsr	refresh_editpat
itt_patNotChanged
			moveq	#gad_edit,d0
			clr.l	cbox_taglist+4
			btst	#0,patteditstatus(a5)
			beq.s	itt_editaus
			move.l	#true,cbox_taglist+4
itt_editaus		jsr	refresh_checkbox

			jsr	check_mem
			jsr	updatetimer
			jsr	updatetoggles
			jsr	blanker
			bra	mmm
;---------------------- Menu-Abfrage ------------------------------------
MenuPicked		moveq	#0,d0
			move	$18(a0),d0
			cmp	#-1,d0
			beq	mmm		; Kein MenuPunkt gewählt?!

			moveq	#0,d1
			moveq	#0,d2
			move	d0,d1
			move	d0,d2
			and	#%11111,d0		; Nur Menunummer
			and	#%11111100000,d1	; Nur Itemnummer
			and	#%1111100000000000,d2
			rol	#5,d2
			add	d0,d0
			add	d0,d0
			lea	MenuPtrs,a0
			move.l	(a0,d0.l),a0	; Zeiger auf MenuItems
			lsr	#5,d1
			add	d1,d1
			add	d1,d1
			move.l	(a0,d1.l),a0
			cmp.b	#$1f,d2

			beq.b	.nosubmenu
			add	d2,d2
			add	d2,d2
			move.l	(a0,d2.l),a0
.nosubmenu		cmp.l	#0,a0
			beq	mmm
			jsr	(a0)
			bra	mmm
;---------------------- TastaturAbfrage ---------------------------------
keypressedsetup:	move.l	#setup_mmm,-(sp)
			bra.b	keypressed
keypressedmain:		move.l	#mmm,-(sp)
			bra.b	keypressed
keypressedarped:	move.l	#arp_mmm,-(sp)
			bra.b	keypressed
keypresseddrumseq:	move.l	#dseq_mmm,-(sp)
			bra.b	keypressed
keypressedfmed:		move.l	#fmed_mmm,-(sp)
;	bra.b	keypressed

keypressed:
			moveq	#0,d0
			move	$18(a0),d0	; ScanCode
			swap	d0
			move.b	$1b(A0),d0
			swap	d0
			move.l	d0,scancode(a5)
			jmp	check_for_keys

;---------------------- Active-Window -----------------------------------
ActivateWindow		move.b	#1,itt_adpd_flag(a5)
			bra	mmm
;---------------------- InActive-Window ---------------------------------
;INActivateWindow
;			move.l	intbase(a5),a6
;			move.l	screenptr2(a5),d0
;			cmp.l	int_activescreen(A6),d0
;			bne.b	.not
;			jmp	instrumented
;.not			clr.b	itt_adpd_flag(a5)
;			bra	mmm
;---------------------- Gadget-Überprüfung ------------------------------
m_CheckGadgetsUP	moveq	#0,d3
			bsr	checkgadgets
			bra	mmm
m_CheckGadgetsDOWN	moveq	#4,d3
			bsr	checkgadgets
			bra	mmm
; d3=Up (4) down (0) offset
CheckGadgets
			lea	gadgetroutineptrs,a2
			moveq	#0,d0
			move.b	programmode(a5),d0
			move.l	(a2,d0),a2

			move.l	$1c(a0),a1
			move	$26(a1),d0	; Gadget-ID
.loop			tst	2(a2)
			beq.b	.exit
			cmp	2(a2),d0
			beq.b	.Found
			lea	12(a2),a2
			bra.b	.loop
.found			move.l	4(a2,d3),a2
			cmp.l	#0,a2
			beq.b	.exit
			jmp	(a2)
.exit			rts
;--------------------------------------------------------------------
; d3=Up (4) down (0) offset
CheckGadgetsWave
			lea	instred_gadgetroutines,a2

			move.l	$1c(a0),a1
			move	$26(a1),d0	; Gadget-ID
.loop			tst	2(a2)
			beq.b	.exit
			cmp	2(a2),d0
			beq.b	.Found
			lea	12(a2),a2
			bra.b	.loop
.found			move.l	4(a2,d3),a2
			cmp.l	#0,a2
			beq.b	.exit
			jmp	(a2)
.exit			rts
;----------------------------------------------------- Programm verlassen ?!
cg_quit
			tst	songchanged(a5)
			beq.b	.loadit
		
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	vload_str,a1
			jsr	patcheasyreqargs
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.loadit
			rts
.loadit

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	window1ptr(a5),a0	; ausgeben
			lea	vquit_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0
			bne.b	cg_quitNOW
			rts
cg_quitNOW
			addq.l	#4,sp
			jmp	leaveprogram

; -------------------------------------------------------------------
; Vector-Basis-Register holen
getVBR:			movec	vbr,d0
			nop
			nop
			rte
;--------------------------------------------------------------------
;			ifne	copylock
;CopyProtect:
;			ifne	save
;
;			movem.l	d0-a6,-(sp)
;			lea	msg_betatester,a0
;			moveq	#0,d0
;			moveq	#0,d1
;			move	#$90-1,d7
;.addloop		move.b	(a0)+,d0
;			add.l	d0,d1
;			dbf	d7,.addloop
;			move.l	regchecksum,d0
;			cmp.l	d0,d1
;			beq.w	.geht
;			lea	msg_nicetry,a2
;			jsr	displaymessage
;.infinite		move.b	$dff006,$dff181
;			bra.b	.infinite
;.geht			movem.l	(sp)+,d0-a6
;			endif
			rts
;			endif

; -------------------------------------------------------------------
; 		T      I      M       E       R
; -------------------------------------------------------------------
; a5=Main_data!!!
Addtimer
			cmp	#400,win1h
			beq.b	.euro
			cmp.b	#49,framecnt(a5)
			beq.b	at_addtime
			addq.b	#1,framecnt(a5)
			rts
.euro			cmp.b	#68,framecnt(a5)
			beq.b	at_addtime
			addq.b	#1,framecnt(a5)
			rts

at_addtime		clr.b	framecnt(a5)
			cmp.b	#59,playtimer+1(a5)
			bne.b	at_notAddMin
			cmp.b	#59,playtimer(a5)
			beq.b	resettimer
			clr.b	playtimer+1(a5)
			addq.b	#1,playtimer(a5)
			rts
at_notaddmin		addq.b	#1,playtimer+1(a5)
			rts
ResetTimer		clr	playtimer(a5)
			clr.b	framecnt(a5)
			rts
updatetimer		moveq	#0,d0
			move	playtimer(a5),d0
			cmp	oldtimer(a5),d0
			beq.b	ut_nochange
			move	d0,oldtimer(a5)

			lea	txt_2charsnrs,a0
			moveq	#0,d1
			move.b	d0,d1		; sekunden
			add	d1,d1
			add	d1,d1
			lsr	#8,d0
			add	d0,d0
			add	d0,d0
			move	(a0,d0),txt_acttimer
			move.b	(a0,d1),txt_acttimer+3
			move.b	1(a0,d1),txt_acttimer+4

			move.l	mp_gadgetptrs+rog_modtimer*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	mp_rog8tags,a3
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
ut_nochange		rts
;--------------------------------------------------------------------
togglescreen		move.l	intbase(a5),a6
			move.l	int_frontscreen(a6),d0
			cmp.l	screenptr(a5),d0
			bne.b	.activate1
			move.l	screenptr2(a5),a0
			jsr	int_screentofront(a6)
			move.l	windowptrwave(a5),a0
			jsr	int_activatewindow(a6)
			bra.b	.activate2
.activate1		move.l	screenptr(a5),a0
			jsr	int_screentofront(a6)
			move.l	window1ptr(a5),a0
			jsr	int_activatewindow(a6)
.activate2
			rts
;-----------------------------------------------------	StartALLPlay
StartAllPlay		bsr	resettimer
			clr	aon_patcnt+aon_data
			clr.b	disppatcnt(a5)
StartAllPlayCONT	jsr	equ_resetchannels
			move.b	#replayst_all,replaystatus(a5)
			bclr	#0,patteditstatus(a5)
			moveq	#0,d7
			move.b	aon_pos+aon_data,d7
			move.l	aon_posdata+aon_data,a1	; get start of posdat
			moveq	#0,d0
			move.b	(a1,d7),d0		; d7=act. pos + choff
			move.b	d0,acteditpattern+main_data+1
			move.b	#$f,pattdspreq(a5)
			tst.b	aon_speed+aon_data
			bne.b	sap_return
			lea	aon_data,a6
			move.b	#6,aon_speed(a6)
			jmp	aon_resettimer
sap_return		rts
;-----------------------------------------------------
StartPatPlay		clr	aon_patcnt+aon_data
			clr.b	disppatcnt(a5)
StartPatPlayCONT	jsr	equ_resetchannels
			move.b	#replayst_pat,replaystatus(a5)
			bclr	#0,patteditstatus(a5)
			tst.b	aon_speed+aon_data
			bne.b	sap_return
			lea	aon_data,a6
			move.b	#6,aon_speed(a6)
			jmp	aon_resettimer
;------------------------------------------------------------------------
StartRecord		clr	aon_patcnt+aon_data
			clr.b	disppatcnt(a5)
StartRecordCONT
			jsr	equ_resetchannels
			move.b	#replayst_pat,replaystatus(A5)
			bset	#0,patteditstatus(a5)
			rts
;-----------------------------------------------------	StopSong
StopSongEditOnOff	tst.b	replaystatus(a5)
			beq.s	.toggle
			bclr	#0,patteditstatus(a5)
			bra.b	stopsong
.toggle			bchg	#0,patteditstatus(a5)
StopSong		jsr	equ_resetchannels
			move.b	#replayst_off,replaystatus(a5)
			jmp	aon_end
;-----------------------------------------------------
FreezeDisplay:		
			bchg	#0,freezedsp(a5)
			tst	freezedsp(a5)
			beq	.freezeoff

			move.l	bitplane1_startadr(a5),a0
			lea	(patbploff+14)*80+2(a0),a0
			lea	.freezebitmap(pc),a1
			moveq	#11-1,d7
.copymap		move.l	(a1)+,(a0)+
			move.l	(a1)+,(a0)+
			lea	80-8(a0),a0
			dbf	d7,.copymap

			lea	freezeASC,a0
			ifeq	lang
			move.b	#"O",(a0)+
			move.b	#"n",(a0)+
			move.b	#" ",(a0)+
			else
			move.b	#"A",(a0)+
			move.b	#"n",(a0)+
			move.b	#" ",(a0)+
			endif
			rts
.freezeoff
			lea	freezeASC,a0
			ifeq	lang
			move.b	#"O",(a0)+
			move.b	#"f",(a0)+
			move.b	#"f",(a0)+
			else
			move.b	#"A",(a0)+
			move.b	#"u",(a0)+
			move.b	#"s",(a0)+
			endif
			jsr	adjust_pattdisplayNOW
			rts
.freezebitmap
 dc.l	0,0
 dc.l	0,0
 dc.l	%11111011110011111011111011111011,%11100000000000000000000000000000
 dc.l	%11000011011011000011000000011011,0
 dc.l	%11000011011011000011000000110011,0
 dc.l	%11110011110011110011110001100011,%11000000000000000000000000000000
 dc.l	%11000011011011000011000001100011,0
 dc.l	%11000011011011000011000011000011,0
 dc.l	%11000011011011111011111011111011,%11100000000000000000000000000000
 dc.l	0,0
 dc.l	0,0

;-----------------------------------------------------
LoadSong:
			tst	songchanged(a5)
			beq.b	.loadit
		
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	vload_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.loadit
			rts
.loadit
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	modreqptr(a5),a1
			lea	mod_filename,a2
			lea	mod_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	ls_notfilereqcancel
			rts
ls_notfilereqcancel
			clr	songchanged(a5)

			move	#$4000,$dff09a
			move.l	oldaudio,d0
			beq.b	.alreadycleared
			move.l	vbreg(a5),a0
			move.l	d0,$70(a0)
			move	#$0780,$dff09a
.alreadycleared		move	#$c000,$dff09a
			move	#$0780,$dff09c

			clr.b	chmode(a5)
			move.b	#%1111,ch_enable(a5)
			jsr	stopsong

			move.b	#replayst_off,replaystatus(a5)
			clr.b	patteditstatus(a5)
			move.b	#1,silence(a5)
			jsr	init_module	; Modul löschen

			move.l	modreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	mod_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			tst.l	d0
			beq	ls_errorandexit
			move.l	d0,filehandle(a5)

			move.l	#iobuffer,d2
			moveq	#4,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bpl.b	.okxyc
			jmp	ioerror
.okxyc
			cmp	#"PP",iobuffer
			beq	ls_crunched
			cmp.l	#"S404",iobuffer
			beq	ls_crunched
;====================================================================
std_loader
			move.l	filehandle(a5),d1	; Filezeiger
			moveq	#0,d2			; zurückstellen
			moveq	#-1,d3
			jsr	dos_seek(a6)
			move.l	exec,a6
			move.l	#150000,d0		; 150k allokieren
			move.l	#$10001,d1
			jsr	exec_allocmem(a6)
			tst.l	d0
			bne.b	.headerdata
			lea	msg_ls_outofmem,a2	; Kein Speicher
			jsr	displaymessage
			bra	ls_doserrorandexit
.headerdata

			move.l	d0,pp_loadadr(a5)	; adr & länge
			move.l	#150000,pp_loadlen(a5)	; absaven

			move.l	d0,a4
			move.l	d0,d2
			move.l	#150000,d3
			move.l	filehandle(a5),d1	; file einladen
			move.l	dosbase(a5),a6
			jsr	dos_read(a6)
			tst.l	d0			; is putt?
			bpl.b	.dataok
			lea	msg_io_fileerror,a2
			jsr	displaymessage		; messy raus
			bra	ls_doscloseandexit
.dataok

			cmp.l	#"AON8",(a4)
			beq.b	.8chaon
			cmp.l	#"AON4",(a4)
			bne	std_CheckProNoiseFormat
			clr.b	chmode(a5)
			bra.b	.4chaon
.8chaon			tst.b	extproc(a5)
			bne.b	.isok
			lea	msg_noextproc,a2
			jsr	displaymessage

			move.l	dosbase(a5),a6
			bra	ls_doscloseandexit
.isok
			move.b	#1,chmode(a5)
.4chaon
;-----------------------------------------------------
;ArtOfNoise-Loader 4channel/8Channel


			lea	4+42(a4),a4	; skip annotation
			cmp.l	#"NAME",(a4)
			bne	.noremarks
			lea	module_songname,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongname
.copysongname		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongname
.nosongname
			lea	module_songauthor,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongauthor
.copysongauthor		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongauthor
.nosongauthor
			lea	module_songdate,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongdate
.copysongdate		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongdate
.nosongdate

			move.l	dosbase(a5),a6
			move.l	#rem_filename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			tst.l	d0
			bne.b	.remok
			addq.l	#4,a4
			move.l	(a4)+,d0
			lea	(a4,d0.l),a4		; skip remark
			lea	msg_ss_remerror,a2
			jsr	displaymessage
			bra.b	.noremarks
.remok			addq.l	#4,a4
			move.l	(a4)+,d3	; get len
			move.l	a4,d2
			lea	(a4,d3.l),a4
			move.l	d0,d1
			move.l	d0,d7		; for l8r use
			jsr	dos_write(a6)
			tst.l	d0
			bpl.b	.remok2
			move.l	d7,d1
			jsr	dos_close(a6)
			lea	msg_ss_remerror,a2
			jsr	displaymessage
			bra.b	.noremarks
.remok2			move.l	d7,d1
			jsr	dos_close(a6)
.noremarks

			addq.l	#8,a4
			move.l	(a4)+,module_songinfo

			addq.l	#8,a4
			lea	module_arptab,a0
			rept	16
			move.l	(a4)+,(a0)+
			endr

			addq.l	#4,a4
			move.l	(a4)+,d7
			beq.b	.noplst
			lea	module_postab,a0
.copypos		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copypos
.noplst
			addq.l	#4,a4
			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_patterns,a0
.copypatterns		move.l	(a4)+,(a0)+
			subq.l	#1,d7
			bne.b	.copypatterns


			addq.l	#4,a4
			move.l	(a4)+,d7
			lsr.l	#2,d7
			beq.b	.noins
			lea	module_instruments,a0
.copyinstr		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copyinstr
.noins

			cmp.l	#"INAM",(a4)+
			bne.b	.skipnames
			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_instrnames,a0
.copyinstrnames		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copyinstrnames
			addq.l	#4,a4
.skipnames

			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_wavelenlist,a0
.copywlens		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copywlens

			addq.l	#8,a4

; a4=zeiger auf waves
			move.l	dosbase(a5),a6
			move.l	a4,d2
			sub.l	pp_loadadr(a5),d2	; offset bilden
			moveq	#-1,d3
			move.l	filehandle(a5),d1	; dateizeiger
			jsr	dos_seek(a6)		; positionieren

			bsr	std_loadwaves

.eold
			move.l	dosbase(a5),a6

			tst.b	chmode(a5)
			beq.b	.4ch2
			jsr	set8channels3
			bra.b	.8ch2
.4ch2			jsr	set4channels2
.8ch2
			moveq	#0,d0
			jsr	aon_init

			bra	ls_doscloseandexit
;------------------------------------------
; filehandle=ptr on file
; Ğmodule_wavelenlistğ has to be initalized
std_loadwaves
			lea	module_wavelenlist,a3
			lea	aon_data+aon_wavestarts,a4
			moveq	#64-1,d7
.loadem			move.l	(a3)+,d0	; wavelen
			beq.b	.emptywave
			move.l	d0,d6		; save in d6
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1	; public (fast)
			bra.b	.8ch
.4ch			move.l	#$10002,d1	; chip
.8ch			move.l	exec,a6
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq.b	.nomem		; no mem
			move.l	d0,(a4)+
			move.l	d0,d2
			move.l	d6,d3
			move.l	filehandle(a5),d1
			move.l	dosbase(a5),a6
			jsr	dos_read(a6)
			tst.l	d0
			bmi.b	.fileerr
.nextwave		dbf	d7,.loadem
			rts
.emptywave		clr.l	-4(a3)
			clr.l	(a4)+
			bra.b	.nextwave
.fileerr
.nomem			clr.l	-4(a3)		; restliche waves
			clr.l	(a4)+		; auf 0 setzen
			addq.l	#4,a3
			dbf	d7,.nomem
			rts
;------------------------------------------
std_outofmemerror	
			movem.l	(sp)+,a0-a1/a5-a6
std_now_oom
			lea	msg_ls_outofmem,a2
			jsr	displaymessage

			move.l	dosbase(a5),a6

			jsr	init_module	; Bereits geladenes MOD
					; wieder löschen

			bra	ls_doscloseandexit

;;-----------------------------------------------------	NOISE/PROTRACKER LOADER
;loads 'FLT4' 'M.K.' (pro/noisetracker) data
std_checkproNoiseFormat
			cmp.l	#"M.K.",1080(a4)	; be sure !
			bne	std_notprotracker
std_convertprotracker
			clr.b	prf_data+prf_oversize
			clr.b	aon_data+aon_oversize

			movem.l	d0-d7/a0-a6,-(sp)
; Start Pro/Noise -> AON Converter
			move.l	a4,a0		; Protracker/Noisetracker
; Convert modulename	------------------
			lea	module_songname,a4
			moveq	#20-1,d7	; Protracker: 20 bytes
.copysongname		move.b	(a0)+,(a4)+	; ArtOfNoise: 256 bytes!
			dbf	d7,.copysongname
; Create authorname	------------------
			lea	module_songauthor,a4
			lea	authtxt,a6
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
; Create songdate	-------------------
			move.l	#$3f3f3f00,module_songdate

; Convert instrnames	------------------
			lea	module_instrnames,a4
			moveq	#31-1,d7
.copyinstrnames		move.l	(a0)+,(a4)+	; Protracker: 22 bytes
			move.l	(a0)+,(a4)+	; Artofnoise: 32 bytes
			move.l	(a0)+,(a4)+
			move.l	(a0)+,(a4)+
			move.l	(a0)+,(a4)+
			move	(a0)+,(a4)+
			addq.l	#30-22,a0
			lea	32-22(a4),a4
			dbf	d7,.copyinstrnames
; Create songinformation ------------------
			move.l	pp_loadadr(a5),a0
			lea	module_songinfo,a4
			move.b	#$34,aon.songinfo_mfver(a4)	; V3,4channels
			move.b	950(a0),aon.songinfo_maxpos(a4)
			move.b	951(a0),d0
			cmp.b	#255,d0
			beq.b	.zerores
			cmp.b	#120,d0
			beq.b	.zerores
			cmp.b	#127,d0
			beq.b	.zerores
			move.b	d0,aon.songinfo_respos(a4)
.zerores

; Copy positiontab	-------------------
			lea	952(a0),a6
			lea	module_postab,a4
			moveq	#128-1,d7
			moveq	#0,d1		; Hitrack
.copypostab		moveq	#0,d0
			move.b	(a6)+,d0
			cmp.b	d1,d0
			bls.b	.nohitrack
			move.b	d0,d1
.nohitrack		move.b	d0,(a4)+
			dbf	d7,.copypostab

; Create wavelenlist	------------------
			lea	20+22(a0),a6
			lea	module_wavelenlist,a4
			moveq	#31-1,d7
.createwavelenlist	moveq	#0,d0
			move	(a6),d0		; Unused samples in protracker
			cmp	#1,d0		; always have the len 2!
			bne.s	.notbuglen	; correct that........
			moveq	#0,d0
.notbuglen		add.l	d0,d0
			move.l	d0,(a4)+
			lea	30(a6),a6
			dbf	d7,.createwavelenlist
; Create instruments	------------------
			lea	module_instruments,a4
			lea	20+22(a0),a6
			moveq	#31-1,d7
			moveq	#0,d0		; ((,cin_loop))
			moveq	#0,d6		; wavenr.
			moveq	#31-1,d7
.createinstruments	move.b	3(a6),instr_volume(a4)
			move.b	2(a6),instr_finetune(a4)
			move.b	d6,instr_waveform(a4)
			move	(a6),d0
			cmp	#1,d0
			bne.s	.notbugwavelen2
			moveq	#0,d0
.notbugwavelen2		move.l	d0,sample8_dmalen(a4)
			move	4(a6),d0
			move.l	d0,sample8_dmarepoffset(a4)
			move	6(a6),d0
			cmp	#1,d0		; replen2 ->replen 0!!
			bne.b	.notbug
			moveq	#0,d0
.notbug			move.l	d0,sample8_dmareplen(a4)
			lea	32(a4),a4
			lea	30(a6),a6
			addq.b	#1,d6
			dbf	d7,.createinstruments

; Copy patterns		----------------------
; d1=max.patnr.

			move.l	pp_loadadr+main_data,a1
			lea	1084(a1),a1
			lea	module_patterns,a4
.copyallpat		move	#(64*4)-1,d7
.copypattern
			moveq	#0,d2
			moveq	#0,d3
			moveq	#0,d4		; copy ONE STEP
			moveq	#0,d5
			moveq	#0,d6
			move.b	0(a1),d2
			move.b	1(a1),d3
			move.b	2(a1),d4
			move.b	3(a1),d5
			move	0(a1),d6
			and	#$0fff,d6
			moveq	#0,d0		; counter for noteposcnt
			tst	d6		; pause ?!!
			beq.b	.cp_pause	; skip notesearch!!
			lea	aon_periods,a2
.cp_searchper		cmp.b	#36+24,d0
			beq.b	.cp_pause0
			addq.b	#1,d0		; notepos+1
			cmp	(a2)+,d6	; period found?
			bne.s	.cp_searchper	; continue search!
			bra.b	.cp_pause
.cp_pause0		clr.l	(a4)
			bra.b	.cp_steperr
.cp_pause		move.b	d0,0(a4)	; write note
			and.b	#$f0,d2		; upper 4 bits of samplenr.
			move.b	d4,d6
			lsr.b	#4,d6		; to the right position
			or.b	d6,d2		; or to 8-bit samplenr.
			move.b	d2,1(a4)	; write instrnr.
			and.b	#$0f,d4
			move.b	d4,2(a4)	; write effectcommand
			move.b	d5,3(a4)	; write effectparameters
.cp_steperr
			addq.l	#4,a1
			addq.l	#4,a4
			dbf	d7,.copypattern
			dbf	d1,.copyallpat

			move.l	a1,pt_sampledataadr+main_data
			movem.l	(sp)+,d0-d7/a0-a6	; Speicher für

; Samples einlesen
			move.l	dosbase(a5),a6
			move.l	pt_sampledataadr(a5),d2
			sub.l	pp_loadadr(a5),d2
			moveq	#-1,d3
			move.l	filehandle(a5),d1	; Dateizeiger
			jsr	dos_seek(a6)		; positionieren


			bsr	std_loadwaves

			moveq	#0,d0
			jsr	aon_init

			jsr	set4channels2

			bra	ls_doscloseandexit
;;-----------------------------------------------------
std_notprotracker
			cmp.l	#"FLT4",1080(a4)	; noisetracker module?!
			beq	std_convertprotracker


;;;;;;;;;Kein anderes Format---> Also nicht ladbar!

			lea	msg_ls_unknownformat,a2
			jsr	displaymessage

			move.l	dosbase(a5),a6
			bra	ls_doscloseandexit


;====================================================================
;====================================================================
;====================================================================
;	CRUNCHED MODULE LOADER	-  (C) 1993 BASTIAN SPIEGEL
;====================================================================
;====================================================================
ls_crunched
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

			lea	iofilename,a0	; filename
			moveq	#2,d0		; Decrunch_Color
			moveq	#0,d1
			lea	pp_loadadr(a5),a1
			lea	pp_loadlen(a5),a2
			sub.l	a3,a3
			move.l	pp_base(a5),a6
			jsr	_LVOppLoadData(a6)

			tst.l	d0
			bne	ls_errorandexit
ls_startcheck
			move.l	pp_loadadr(a5),a4

			cmp.l	#"S404",(a4)
			beq	ls_decrunchs404

			cmp.l	#"AON8",(a4)
			beq.b	.8chaon
			cmp.l	#"AON4",(a4)
			bne	ls_CheckProNoiseFormat
			clr.b	chmode(a5)
			bra.b	.4chaon
.8chaon			tst.b	extproc(a5)
			bne.b	.isok
			lea	msg_noextproc,a2
			jsr	displaymessage

			move.l	dosbase(a5),a6
			bra	ls_closeandexit
.isok
			move.b	#1,chmode(a5)
.4chaon
;-----------------------------------------------------
;ArtOfNoise-Loader 4channel/8Channel
			lea	4+42(a4),a4	; skip annotation
			cmp.l	#"NAME",(a4)
			bne	.noremarks
			lea	module_songname,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongname
.copysongname		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongname
.nosongname
			lea	module_songauthor,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongauthor
.copysongauthor		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongauthor
.nosongauthor
			lea	module_songdate,a0
			addq.l	#8,a4
			move.l	-4(a4),d7
			beq.b	.nosongdate
.copysongdate		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copysongdate
.nosongdate
			move.l	dosbase(a5),a6
			move.l	#rem_filename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			tst.l	d0
			bne.b	.remok
			addq.l	#4,a4
			move.l	(a4)+,d0
			lea	(a4,d0.l),a4		; skip remark
			lea	msg_ss_remerror,a2
			jsr	displaymessage
			bra.b	.noremarks
.remok			addq.l	#4,a4
			move.l	(a4)+,d3	; get len
			move.l	a4,d2
			lea	(a4,d3.l),a4
			move.l	d0,d1
			move.l	d0,d7		; for l8r use
			jsr	dos_write(a6)
			tst.l	d0
			bpl.b	.remok2
			move.l	d7,d1
			jsr	dos_close(a6)
			lea	msg_ss_remerror,a2
			jsr	displaymessage
			bra.b	.noremarks
.remok2			move.l	d7,d1
			jsr	dos_close(a6)
.noremarks

			addq.l	#8,a4
			move.l	(a4)+,module_songinfo

			addq.l	#8,a4
			lea	module_arptab,a0
			rept	16
			move.l	(a4)+,(a0)+
			endr

			addq.l	#4,a4
			move.l	(a4)+,d7
			beq.b	.noplst
			lea	module_postab,a0
.copypos		move.b	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copypos
.noplst

			addq.l	#4,a4
			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_patterns,a0
.copypatterns		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copypatterns

			addq.l	#4,a4
			move.l	(a4)+,d7
			lsr.l	#2,d7
			beq.b	.noins
			lea	module_instruments,a0
.copyinstr		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copyinstr
.noins
			cmp.l	#"INAM",(a4)+
			bne.b	.skipnames
			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_instrnames,a0
.copyinstrnames		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copyinstrnames
			addq.l	#4,a4
.skipnames
			move.l	(a4)+,d7
			lsr.l	#2,d7
			lea	module_wavelenlist,a0
.copywlens		move.l	(a4)+,(a0)+
			subq	#1,d7
			bne.b	.copywlens

			addq.l	#8,a4

			move.l	exec,a6
			lea	aon_wavestarts+aon_data,a2
			lea	module_wavelenlist,a3
			moveq	#64-1,d7
.allocwaves		move.l	(a3)+,d0
			beq.b	.emptywave
			move.l	d0,d6
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1
			bra.b	.8ch
.4ch			move.l	#$10002,d1
.8ch			movem.l	a2/a3,-(sp)
			jsr	exec_allocvec(a6)
			movem.l	(sp)+,a2/a3
			tst.l	d0
			beq.b	.outofmemWAVES
			move.l	d0,(a2)+
			move.l	d0,a0
.copywave		move.b	(a4)+,(a0)+
			subq.l	#1,d6
			bne.b	.copywave
			bra.b	.nextwave
.emptywave		clr.l	(a2)+
.nextwave		dbf	d7,.allocwaves

			move.l	dosbase(a5),a6

			tst.b	chmode(a5)
			beq.b	.4ch2
			jsr	set8channels3
			bra.b	.8ch2
.4ch2			jsr	set4channels2
.8ch2
			moveq	#0,d0
			jsr	aon_init

			bra	ls_closeandexit
.outofmemwaves
			move.l	dosbase(a5),a6
			lea	msg_instred_outofmemory,a2
			jsr	displaymessage
			bra	ls_closeandexit
;------------------------------------------
ls_outofmemerror	
			movem.l	(sp)+,a0-a1/a5-a6

			lea	msg_ls_outofmem,a2
			jsr	displaymessage

			move.l	dosbase(a5),a6

			jsr	init_module	; Bereits geladenes MOD
					; wieder löschen

			bra	ls_closeandexit

;;-----------------------------------------------------	NOISE/PROTRACKER LOADER
ls_checkproNoiseFormat
			cmp.l	#"M.K.",1080(a4)
			bne	ls_notprotracker
ls_convertprotracker
			clr.b	prf_data+prf_oversize
			clr.b	aon_data+aon_oversize

			movem.l	d0-d7/a0-a6,-(sp)
; Start Pro/Noise -> AON Converter
			move.l	a4,a0		; Protracker/Noisetracker
; Convert modulename	------------------
			lea	module_songname,a4
			moveq	#20-1,d7	; Protracker: 20 bytes
copysongname		move.b	(a0)+,(a4)+	; ArtOfNoise: 256 bytes!
			dbf	d7,copysongname
; Create authorname	------------------
			lea	module_songauthor,a4
			lea	authtxt,a6
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
			move.l	(a6)+,(a4)+
; Create songdate	-------------------
			move.l	#$3f3f3f00,module_songdate

; Convert instrnames	------------------
			lea	module_instrnames,a4
			moveq	#31-1,d7
copyinstrnames		move.l	(a0)+,(a4)+	; Protracker: 22 bytes
			move.l	(a0)+,(a4)+	; Artofnoise: 32 bytes
			move.l	(a0)+,(a4)+
			move.l	(a0)+,(a4)+
			move.l	(a0)+,(a4)+
			move	(a0)+,(a4)+
			addq.l	#30-22,a0
			lea	32-22(a4),a4
			dbf	d7,copyinstrnames
; Create songinformation ------------------
			move.l	pp_loadadr(a5),a0
			lea	module_songinfo,a4
			move.b	#$34,aon.songinfo_mfver(a4)	; V3,4channels
			move.b	950(a0),aon.songinfo_maxpos(a4)
			move.b	951(a0),d0
			cmp.b	#255,d0
			beq.b	pt_zerores
			cmp.b	#120,d0
			beq.b	pt_zerores
			cmp.b	#127,d0
			beq.b	pt_zerores
			move.b	d0,aon.songinfo_respos(a4)
pt_zerores

; Copy positiontab	-------------------
			lea	952(a0),a6
			lea	module_postab,a4
			moveq	#128-1,d7
			moveq	#0,d1		; Hitrack
copypostab		moveq	#0,d0
			move.b	(a6)+,d0
			cmp.b	d1,d0
			bls.b	nohitrack
			move.b	d0,d1
nohitrack		move.b	d0,(a4)+
			dbf	d7,copypostab

; Create wavelenlist	------------------
			lea	20+22(a0),a6
			lea	module_wavelenlist,a4
			moveq	#31-1,d7
createwavelenlist	moveq	#0,d0
			move	(a6),d0		; Unused samples in protracker
			cmp	#1,d0		; always have the len 2!
			bne.s	cwll_notbuglen	; correct that........
			moveq	#0,d0
cwll_notbuglen		add.l	d0,d0
			move.l	d0,(a4)+
			lea	30(a6),a6
			dbf	d7,createwavelenlist
; Create instruments	------------------
			lea	module_instruments,a4
			lea	20+22(a0),a6
			moveq	#31-1,d7
cin_loop		moveq	#0,d0
			moveq	#0,d6		; wavenr.
			moveq	#31-1,d7
createinstruments	move.b	3(a6),instr_volume(a4)
			move.b	2(a6),instr_finetune(a4)
			move.b	d6,instr_waveform(a4)
			move	(a6),d0
			cmp	#1,d0
			bne.s	notbugwavelen2
			moveq	#0,d0
notbugwavelen2		move.l	d0,sample8_dmalen(a4)
			move	4(a6),d0
			move.l	d0,sample8_dmarepoffset(a4)
			move	6(a6),d0
			cmp	#1,d0		; replen2 ->replen 0!!
			bne.b	.notbug
			moveq	#0,d0
.notbug			move.l	d0,sample8_dmareplen(a4)
			lea	32(a4),a4
			lea	30(a6),a6
			addq.b	#1,d6
			dbf	d7,createinstruments

; Copy patterns		----------------------
; d1=max.patnr.

			move.l	pp_loadadr+main_data,a1
			lea	1084(a1),a1
			lea	module_patterns,a4
copyallpat		move	#(64*4)-1,d7
copypattern
			moveq	#0,d2
			moveq	#0,d3
			moveq	#0,d4		; copy ONE STEP
			moveq	#0,d5
			moveq	#0,d6
			move.b	0(a1),d2
			move.b	1(a1),d3
			move.b	2(a1),d4
			move.b	3(a1),d5
			move	0(a1),d6
			and	#$0fff,d6
			moveq	#0,d0		; counter for noteposcnt
			tst	d6		; pause ?!!
			beq.s	cp_pause	; skip notesearch!!
			lea	aon_periods,a2
cp_searchper		cmp.b	#36+24,d0
			beq.b	cp_pause0
			addq.b	#1,d0		; notepos+1
			cmp	(a2)+,d6	; period found?
			bne.s	cp_searchper	; continue search!
			bra.b	cp_pause
cp_pause0		clr.l	(a4)
			bra.b	cp_steperr
cp_pause		move.b	d0,0(a4)	; write note
			and.b	#$f0,d2		; upper 4 bits of samplenr.
			move.b	d4,d6
			lsr.b	#4,d6		; to the right position
			or.b	d6,d2		; or to 8-bit samplenr.
			move.b	d2,1(a4)	; write instrnr.
			and.b	#$0f,d4
			move.b	d4,2(a4)	; write effectcommand
			move.b	d5,3(a4)	; write effectparameters
cp_steperr
			addq.l	#4,a1
			addq.l	#4,a4
			dbf	d7,copypattern
			dbf	d1,copyallpat

			move.l	a1,pt_sampledataadr+main_data
			movem.l	(sp)+,d0-d7/a0-a6	; Speicher für

; Samples einlesen
			movem.l	a0-a1/a5-a6,-(sp)
			lea	aon_wavestarts+aon_data,a4
			lea	module_wavelenlist,a5
			move.l	exec,a6
			moveq	#64-1,d7
ls_allocWavesPT		move.l	(a5)+,d0		; Get Wavelen
			beq.s	ls_skipzerowavesPT
			moveq	#memf_chip,d1
			jsr	exec_allocvec(a6)	; Speicher für
			tst.l	d0			; Wellenformen
			beq	ls_outofmemerror	; bereitstellen
ls_skipzerowavesPT	move.l	d0,(a4)+
			dbf	d7,ls_allocwavesPT
			movem.l	(sp)+,a0-a1/a5-a6

			move.l	pt_sampledataadr+main_data,a6
			move.l	a5,-(sp)
			lea	module_wavelenlist,a4	; WLEN start
			lea	aon_wavestarts+aon_data,a5
			moveq	#64-1,d7
ls_readwavesloopPT	move.l	(a4)+,d3		; Länge
			move.l	(a5)+,a0		; Zeiger auf Wave
			beq	ls_skipthiswavePT
ls_copywavePT		move.b	(a6)+,(a0)+
			subq.l	#1,d3
			bne.s	ls_copywavePT

			move.l	-4(a5),a0
			clr	(a0)	; ersten beiden bytes der wave löschen
ls_skipthiswavePT	dbf	d7,ls_readwavesloopPT
			move.l	(sp)+,a5

			moveq	#0,d0
			jsr	aon_init

			jsr	set4channels2

			bra	ls_closeandexit
;;-----------------------------------------------------
ls_notprotracker
			cmp.l	#"FLT4",1080(a4)	; noisetracker module?!
			beq	ls_convertprotracker


;;;;;;;;;Kein anderes Format---> Also nicht ladbar!

			lea	msg_ls_unknownformat,a2
			jsr	displaymessage

;move.l	dosbase(a5),a6
;-----------------------------------------------------
ls_closeandexit		move.l	$4,a6
			move.l	pp_loadadr(a5),a1
			move.l	pp_loadlen(a5),d0
			jsr	exec_freemem(a6)
ls_errorandexit
			clr	aon_data+aon_patcnt
			clr	acteditinstr(a5)
			clr	acteditpattern(a5)
			jsr	refresh_pos
			jsr	refresh_pat
			jsr	refresh_max
			jsr	refresh_res
			jsr	refresh_instrument

			clr.b	silence(a5)
			jsr	refreshgadgets

		lea	aon_channels,a0
		move.b	#1,aon_arpeggiospd(a0)
		move.b	#1,aon_arpeggiospd+1*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+2*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+3*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+4*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+5*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+6*aon_chdatasize(a0)
		move.b	#1,aon_arpeggiospd+7*aon_chdatasize(a0)

		move	#$40,aon_trackvol+0*aon_chdatasize(a0)
		move	#$40,aon_trackvol+1*aon_chdatasize(a0)
		move	#$40,aon_trackvol+2*aon_chdatasize(a0)
		move	#$40,aon_trackvol+3*aon_chdatasize(a0)
		move	#$40,aon_trackvol+4*aon_chdatasize(a0)
		move	#$40,aon_trackvol+5*aon_chdatasize(a0)
		move	#$40,aon_trackvol+6*aon_chdatasize(a0)
		move	#$40,aon_trackvol+7*aon_chdatasize(a0)

			move	#$0f06,aon_fxcom+aon_channels+3*aon_chdatasize
			move	#$0f06,aon_fxcom+aon_channels+7*aon_chdatasize

			lea	aon_data,a6
			jsr	aon_resettimer

			move.b	#$f,pattdspreq(a5)
			bset	#1,$bfe001
			bsr	showfilterstatus

			tst.b	chmode(a5)
			beq.b	.4ch
			jsr	set8channels3
.4ch			bra	stopsong
;_-------------------------------------------------------------------
ls_doserrorandexit	move.l	dosbase(a5),a6
			move.l	filehandle(a5),d1	; File schließen
			jsr	dos_close(a6)
			bra	ls_errorandexit
;_-------------------------------------------------------------------
ls_doscloseandexit
			move.l	dosbase(a5),a6
			move.l	filehandle(a5),d1	; File schließen
			jsr	dos_close(a6)
			bra	ls_closeandexit
;-----------------------------------------------------
; a4=crunched data ptr
ls_decrunchs404
			movem.l	d0-a6,-(sp)
			clr.l	(a4)		; 'S404' löschen
			move.l	8(a4),d0	; original-length
			move.l	d0,stc_origlen(a5)

			move.l	exec,a6
			moveq	#memf_public,d1
			jsr	exec_allocmem(a6)
			tst.l	d0
			beq.b	.nomem

			move.l	d0,stc_origdata(a5)
			move.l	d0,a0
			move.l	pp_loadadr(a5),a1

			movem.l	d0-a6,-(sp)
			bsr	decrunchS404	; file decrunchen
			movem.l	(sp)+,d0-a6

			move.l	pp_loadadr(a5),a1
			move.l	pp_loadlen(a5),d0
			jsr	exec_freemem(a6)

			move.l	stc_origdata(a5),pp_loadadr(a5)
			move.l	stc_origlen(a5),pp_loadlen(a5)
			movem.l	(sp)+,d0-a6
			bra	ls_startcheck

.nomem			lea	msg_ls_nostcmem,a2
			jsr	displaymessage
			movem.l	(sp)+,d0-a6
			bra	ls_startcheck
;-----------------------------------------------------------------------------
;- S404 highly optimized data decruncher v1.1 turbo
;- 27.11.93 by Marcus 'Cozine' Ottosson
;-----------------------------------------------------------------------------
;- Based on S404 data_decruncher v0.2
;- (c) 1993 by Jouni 'Mr.Spiv' Korhonen (SWSW)
;-----------------------------------------------------------------------------
;- call with registers: a0 = destination address
;-                      a1 = crunched data
;-----------------------------------------------------------------------------
; uses d0-a6
decrunchS404:
_l0:		addq	#8,a1			; Skip ID string & security
						; length..
		move.l	a0,a5
		add.l	(a1)+,a0
		add.l	(a1),a1
		moveq	#0,d4
		moveq	#16,d5
		movem.w	(a1),d2/d6/d7
		not.w	d4
		lea	_loff6(pc),a3
		lea	_llen5a(pc),a4
		moveq	#1,d0
		moveq	#-1,d3
		bra.s	_ltest1

_lins:		subq.w	#8,d7
		bpl.s	_lins2
_lins1:		move.w	d7,d1
		addq.w	#8,d7
		lsl.l	d7,d6
		move.w	-(a1),d6
		neg.w	d1
		lsl.l	d1,d6
		addq.w	#8,d7
		swap	d6
		move.b	d6,-(a0)
		swap	d6
		cmp.l	a0,a5
		dbhs	d7,_lmain
		bra.s	_lexma

_lins2:		rol.w	#8,d6
		move.b	d6,-(a0)
_ltest1:	cmp.l	a0,a5
		dbhs	d7,_lmain
_lexma		bhs.s	_lexit

_lmain1:	move.w	-(a1),d6
		moveq	#15,d7
_lmain:		add.w	d6,d6
		bcc.s	_lins

		dbf	d7,_llen1
		move.w	-(a1),d6
		moveq	#15,d7
_llen1:		add.w	d6,d6
		bcs.s	_llen6
		dbf	d7,_llen2
		move.w	-(a1),d6
		moveq	#15,d7
_llen2:		moveq	#2,d1
		moveq	#2,d3
		add.w	d6,d6
		bcs.s	_llen5
		dbf	d7,_llen3
		move.w	-(a1),d6
		moveq	#15,d7
_llen3:		add.w	d6,d6
		bcc.s	_llen4
		moveq	#4,d1
		moveq	#6,d3
		lea	_llen3a(pc),a6
		bra.s	_lbits
_llen3a:	add.w	d1,d3
		cmp.w	#15,d1
		blo.s	_loff1

		moveq	#5,d1
		moveq	#14,d3
		lea	_llen3b(pc),a6
		bra.s	_lbits

_llen4:		moveq	#21,d3
_lloop:		moveq	#8,d1
_llen5:		move.l	a4,a6
		bra.s	_lbits
_llen5a:	add.w	d1,d3
		not.b	d1
		dbeq	d7,_loff2
		bne.s	_loff2a	
		beq.s	_lloop

_loff6:		add.w	d1,a2
		move.b	(a2),-(a0)
_lcopy:		move.b	-(a2),-(a0)
		dbf	d3,_lcopy
_ltest:		cmp.l	a0,a5
		dbhs	d7,_lmain
		blo.s	_lmain1
_lexit:		rts

_llen6:		dbf	d7,_llen7
		move.w	-(a1),d6
		moveq	#15,d7
_llen7:		add.w	d6,d6
		addx.w	d0,d3
_loff1:		dbf	d7,_loff2
_loff2a:	move.w	-(a1),d6
		moveq	#15,d7
_loff2:		add.w	d6,d6
		bcs.s	_loff3

		dbf	d7,_loff4
		move.w	-(a1),d6
		moveq	#15,d7
_loff4:		moveq	#9,d1
		lea	32(a0),a2
		add.w	d6,d6
		bcc.s	_loff5
		moveq	#5,d1
		move.l	a0,a2
		bra.s	_loff5
_loff3:		lea	544(a0),a2
		move.w	d2,d1
_loff5:		move.l	a3,a6

_lbits:		and.l	d4,d6
		sub.w	d1,d7
		bpl.s	_lbits2
		add.w	d7,d1
		lsl.l	d1,d6
		move.w	d7,d1
		move.w	-(a1),d6
		neg.w	d1
		add.w	d5,d7
_lbits2:	lsl.l	d1,d6
		move.l	d6,d1
		swap.w	d1
		jmp	(a6)

_lpins2:	moveq	#-1,d3
		bra.w	_lins2

_l2ins2:	rol.w	#8,d6
		move.b	d6,-(a0)
_l2ins1:	lsl.l	d7,d6
		move.w	-(a1),d6
		lsl.l	d1,d6
		swap	d6
		move.b	d6,-(a0)
		swap	d6
		subq.w	#2,d3
		bgt.s	_l2ins2
		beq.s	_lpins2
		addq.w	#8,d7
		bra.s	_ltest

_llen3b:	add.w	d1,d3
		move.b	_lnewd1(pc,d7),d1
		bpl.s	_l2ins1
		subq.w	#8,d7
		dbf	d3,_l2ins2

_lnewd1:	dc.b	$08,$07,$06,$05,$04,$03,$02,$01
		dc.b	$88,$87,$86,$85,$84,$83,$82,$81


;-----------------------------------------------------
;-----------------------------------------------------	ENDE LOADSONG
;------------------------------------------------------------------------
SavePlayerMod:
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage
			else

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			lea	var_filename,a2
			move.l	a2,a0
			tst.b	chmode(a5)
			beq.b	.4chprefix
			move.l	#"aon8",(a0)+
			move.l	#"IMG.",(a0)+
			bra.b	.8chprefix
.4chprefix		move.l	#"aonI",(a0)+
			move	#"MG",(a0)+
			move.b	#".",(a0)+
.8chprefix
			lea	module_songname,a3
.loop			move.b	(a3)+,(a0)+
			tst.b	-1(a3)
			bne.b	.loop

			lea	var_img_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.found
			lea	msg_io_filenotfound,a2
			jmp	displaymessage
.found
			tst.b	chmode(a5)
			beq	makeIMG4ch
			closefile

makeimg4ch
			move.l	#player4ch,d2
			move.l	#player4chlen,d3
			write1

			bsr	audirqoff
			bsr	savesong_do
			bsr	resirq
			closefile
			endif
;------------------------------------------------------------------------
SaveExecutable:
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage
			else

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			lea	var_filename,a2
			move.l	a2,a0
			lea	module_songname,a3
.loop			move.b	(a3)+,(a0)+
			tst.b	(a3)
			bne.b	.loop

			move.b	#".",(a0)+
			move.b	#"e",(a0)+
			move.b	#"x",(a0)+
			move.b	#"e",(a0)+
			clr.b	(a0)+

			lea	var_exe_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.found
			lea	msg_io_filenotfound,a2
			jmp	displaymessage
.found
			tst.b	chmode(a5)
			beq	makeEXE4ch
			closefile

makeEXE4ch
			move.l	#exe4ch,d2
			move.l	#exe4chlen-4,d3
			write1

			bsr	audirqoff
			bsr	savesong_do
			bsr	resirq

			move.l	dosbase(a5),a6
			move.l	filehandle(a5),d1
			moveq	#0,d2
			moveq	#0,d3
			jsr	dos_seek(a6)
			move.l	d0,exeSTARTOFRELOC(a5)
			sub.l	#exe4chlen,d0
; d0=modulesize
			lsr.l	#2,d0		; anzahl langworte
			add.l	#$7e9-8,d0	; exe+player size
			or.l	#$40000000,d0
			move.l	d0,iobuffer
	
			move.l	filehandle(a5),d1
			moveq	#$14,d2
			moveq	#-1,d3
			jsr	dos_seek(a6)
			move.l	#iobuffer,d2
			moveq	#4,d3
			write1

			move.l	filehandle(a5),d1
			moveq	#$1c,d2
			moveq	#-1,d3
			jsr	dos_seek(a6)
			sub.l	#$40000000,iobuffer
			move.l	#iobuffer,d2
			moveq	#4,d3
			write1

			move.l	filehandle(a5),d1	; dateizeiger
			move.l	exeSTARTOFRELOC(a5),d2	; zum dateiende
			moveq	#-1,d3			; verstellen
			jsr	dos_seek(a6)

			move.l	#exe4chrel,d2		; reloc-teil
			move.l	#exe4chrellen,d3	; schreiben
			write1

			closefile

			endif

;------------------------------------------------------------------------
SaveSong:
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage
			else

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	modreqptr(a5),a1
			lea	mod_filename,a2
			move.l	a2,a0
			tst.b	chmode(a5)
			beq.b	.4chprefix
			move.l	#"aon8",(a0)+
			move.b	#".",(a0)+
			bra.b	.8chprefix
.4chprefix		move.l	#"aon.",(a0)+
.8chprefix		lea	module_songname,a3
.loop			move.b	(a3)+,(a0)+
			tst.b	-1(a3)
			bne.b	.loop

			lea	mod_filereqtitleSAVE,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			clr	songchanged(a5)

			move.l	modreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	mod_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			tst.l	d0
			beq.b	.filedoesntexist
			move.l	d0,d1
			jsr	dos_close(a6)

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	overwrite_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0
			beq.b	.filedoesntexist	; Overwrite!!
			rts
.filedoesntexist
			move.l	dosbase(a5),a6



			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.found
			lea	msg_io_filenotfound,a2
			jmp	displaymessage
.found

			bsr	audirqoff
			bsr	savesong_do
			bsr	resirq
			closefile
savesong_do

			lea	iobuffer,a4
			tst.b	chmode(a5)
			beq.b	.4chmark
			move.l	#"AON8",(a4)
			bra.b	.8chmark
.4chmark		move.l	#"AON4",(a4)
.8chmark
			moveq	#4,d3
			move.l	a4,d2
			write1
			move.l	#.annostring,d2
			moveq	#42,d3
			write1

			tst.b	prf_data+prf_saveremark
			beq	.leaveoutremarks

			move.l	#"NAME",(a4)
			lea	module_songname,a3
			moveq	#0,d7
.getlen1		tst.b	(a3,d7)
			beq.b	.out1
			addq	#1,d7
			bra.b	.getlen1
.out1			btst	#0,d7
			beq.b	.leneven1
			addq	#1,d7
.leneven1		move.l	d7,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	a3,d2
			move.l	d7,d3
			write1

			move.l	#"AUTH",(a4)
			lea	module_songauthor,a3
			moveq	#0,d7
.getlen2		tst.b	(a3,d7)
			beq.b	.out2
			addq	#1,d7
			bra.b	.getlen2
.out2			btst	#0,d7
			beq.b	.leneven2
			addq	#1,d7
.leneven2		move.l	d7,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	a3,d2
			move.l	d7,d3
			write1

			move.l	#"DATE",(a4)
			lea	module_songdate,a3
			moveq	#0,d7
.getlen3		tst.b	(a3,d7)
			beq.b	.out3
			addq	#1,d7
			bra.b	.getlen3
.out3			btst	#0,d7
			beq.b	.leneven3
			addq	#1,d7
.leneven3		move.l	d7,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	a3,d2
			move.l	d7,d3
			write1

			move.l	#"RMRK",(a4)

			move.l	#rem_filename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandleREM(a5)
			bne.b	.theresaremark
.remarkerror		clr.l	4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			bra.b	.leaveoutremarks
.theresaremark
			move.l	filehandleREM(a5),d1
			move.l	#iobuffer+1000,d2
			jsr	dos_examineFH(a6)
			move.l	iobuffer+1122,d7	; d7=filelen

			move.l	filehandleREM(a5),d1
			move.l	#iobuffer+8,d2
			move.l	d7,d3
			jsr	dos_read(a6)
			tst.l	d0
			bpl.b	.remok2
			move.l	filehandleREM(a5),d1
			jsr	dos_close(a6)
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			move.l	#iofilename,d1
			jsr	dos_delete(a6)
			lea	msg_ss_remerror,a2
			jmp	displaymessage
			
.remok2			btst	#0,d7
			beq.b	.remevenlen
			addq	#1,d7
.remevenlen		move.l	d7,4(a4)
			move.l	d7,d3
			addq	#8,d3
			move.l	a4,d2
			write1

			move.l	filehandleREM(a5),d1
			jsr	dos_close(a6)
.leaveoutremarks

			move.l	#"INFO",(a4)
			move.l	#4,4(a4)
			move.l	module_songinfo,8(a4)
			move.l	a4,d2
			moveq	#12,d3
			write1

			move.l	#"ARPG",(a4)
			move.l	#16*4,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	#module_arptab,d2
			moveq	#16*4,d3
			write1

			move.l	#"PLST",(a4)
			moveq	#0,d0
			move.b	module_songinfo+aon.songinfo_maxpos,d0
			btst	#0,d0
			beq.b	.plstevenlen
			addq	#1,d0
.plstevenlen		move.l	d0,4(a4)
			move.l	d0,d7
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	d7,d3
			move.l	#module_postab,d2
			write1

			move.l	#"PATT",(a4)
			moveq	#0,d0
			moveq	#0,d6
			lea	module_postab,a0
			move	#256-1,d7
.searchmaxpos		move.b	(a0)+,d0
			cmp	d0,d6
			bge.b	.staymax
			move.b	d0,d6
.staymax		dbf	d7,.searchmaxpos
			addq	#1,d6
			tst.b	chmode(a5)
			beq.b	.4chlsl
			moveq	#11,d0
			bra.b	.8chlsl
.4chlsl			moveq	#10,d0
.8chlsl
			lsl.l	d0,d6
			move.l	d6,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	#module_patterns,d2
			move.l	d6,d3
			write1

			move.l	#"INST",(a4)
			moveq	#0,d0
			moveq	#0,d6
			lea	module_instruments,a3
.searchmaxins		tst.b	instr_control(a3)
			bne.b	.newmax
			tst.l	sample8_dmalen(a3)
			beq.b	.nextins
.newmax			move.b	d0,d6
.nextins		addq.b	#1,d0
			lea	32(a3),a3
			cmp.b	#61,d0
			bne.b	.searchmaxins
			addq	#1,d6
			lsl	#5,d6
			move.l	d6,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	#module_instruments,d2
			move.l	d6,d3
			write1

			tst.b	prf_data+prf_saveinstrnames
			beq.b	.leaveoutinstrnames

			move.l	#"INAM",(a4)
			move.l	#61*32,4(a4)
			move.l	a4,d2
			moveq	#8,d3
			write1
			move.l	#module_instrnames,d2
			move.l	#61*32,d3
			write1
.leaveoutinstrnames

			move.l	#"WLEN",(a4)
			move.l	#64*4,4(a4)
			moveq	#8,d3
			move.l	a4,d2
			write1
			move.l	#module_wavelenlist,d2
			move.l	#64*4,d3
			write1

			move.l	#"WAVE",(a4)
			lea	module_wavelenlist,a0
			move.l	a0,a3
			moveq	#0,d0
			moveq	#64-1,d7
.addwavelens		add.l	(a0)+,d0
			dbf	d7,.addwavelens
			move.l	d0,4(a4)
			moveq	#8,d3
			move.l	a4,d2
			write1
			lea	aon_wavestarts+aon_data,a4
			moveq	#64-1,d7
.writewaves		move.l	(a4)+,d2	; get waveadr
			move.l	(a3)+,d3	; get wavelen
			beq.b	.nextwave	; skip when zero
			write1
.nextwave		dbf	d7,.writewaves

			move.l	filehandle(a5),d1	; auf langwort
			moveq	#0,d2			; grenze
			moveq	#0,d3			; bringen
			jsr	dos_seek(a6)
			and.l	#%11,d0
			beq.b	.noalign
			move.l	#"????",iobuffer
			move.l	#iobuffer,d2
			moveq	#4,d3
			sub.b	d0,d3
			write1
.noalign

			rts

.annostring		dc.b	"ArtOfNoise by Bastian Spiegel(twice/lego)"
			even
			endif

;------------------------------------------------------------------------
ppcrunchfile
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			lea	var_filename,a2

;			move.l	rt_dirname(a1),a0
;			move.l	modreqptr(a5),a3
;			move.l	rt_dirname(a3),a3
;.loopdir		move.b	(a3)+,(a0)+
;			tst.b	-1(a3)
;			bne.b	.loopdir
;
;			move.l	a2,a0
;			lea	mod_filename,a3
;.loopname		move.b	(a3)+,(a0)+
;			tst.b	-1(a3)
;			bne.b	.loopname

			lea	.title(pc),a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6

			move.l	#iofilename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.theresafile
			lea	msg_io_filenotfound,a2
			jmp	displaymessage

.theresafile
			move.l	filehandle(a5),d1
			move.l	#iobuffer,d2
			jsr	dos_examineFH(a6)

			move.l	iobuffer+122,d0
			moveq	#0,d1
			move.l	$4.w,a6
			jsr	exec_allocvec(a6)
			move.l	d0,.memadr
			bne.b	.thereismem

			move.l	filehandle(a5),d1
			move.l	dosbase(a5),a6
			jsr	dos_close(a6)
			lea	msg_pp_outofmemload,a2
			jmp	displaymessage
.thereismem
			move.l	dosbase(a5),a6

			move.l	.memadr(pc),d2
			move.l	iobuffer+122,d3
			read1

			move.l	.memadr(pc),a0
			cmp.l	#"PP20",(a0)
			bne.b	.notalreadypacked
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			lea	msg_pp_alreadypacked,a2
			jmp	displaymessage
.notalreadypacked

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			movem.l	d0-a6,-(sp)
			move.l	intbase(a5),a6
			lea	pp_windowstruct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window2ptr(a5)
			move.l	d0,a0
			move.l	$32(a0),rastport2(a5)	; Rast-Port
			movem.l	(sp)+,d0-A6


			movem.l	d0-a6,-(sp)
			move.l	gfxbase(a5),a6

			lea	.total(pc),a0
			move.l	iobuffer+122,d0
			jsr	integerTOascii7

			move.l	rastport2(a5),a1
			moveq	#1,d0
			jsr	gfx_setapen(a6)
			move.l	rastport2(a5),a1
			moveq	#10,d0
			moveq	#20,d1
			jsr	gfx_move(a6)
			move.l	rastport2(a5),a1
			lea	.status(pc),a0
			moveq	#.statuse-.status,d0
			jsr	gfx_text(a6)

			move.l	rastport2(a5),a1
			moveq	#10,d0
			moveq	#29,d1
			jsr	gfx_move(a6)
			move.l	rastport2(a5),a1
			lea	.status2(pc),a0
			moveq	#.status2e-.status2,d0
			jsr	gfx_text(a6)
			movem.l	(sp)+,d0-a6

			move.l	pp_base(a5),a6
			lea	.func(pc),a0
			sub.l	a1,a1
			moveq	#0,d0
			move.b	prf_data+prf_cruncheff,d0
			moveq	#0,d1
			move.b	prf_data+prf_crunchbuf,d1
			jsr	_LVOppAllocCrunchInfo(a6)
			move.l	d0,.crunchinfo

			move.l	d0,a0
			move.l	.memadr(pc),a1
			move.l	iobuffer+122,d0
			jsr	_LVOppCrunchBuffer(a6)
			tst.l	d0
			beq.w	.canceled
			bmi.w	.overflow

			move.l	d0,.crunchedlen

			move.l	dosbase(a5),a6
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

			tst.b	prf_data+prf_addpp
			beq.b	.noaddpp
			lea	iofilename,a0
.seekzero		tst.b	(a0)+
			bne.b	.seekzero
			move.b	#".",-1(a0)
			move.b	#"p",(a0)
			move.b	#"p",1(a0)
			clr.b	2(a0)
.noaddpp
			move.l	dosbase(a5),a6
			move.l	#iofilename,d1
			jsr	dos_delete(a6)

			move.l	#iofilename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.fileopened
			bsr	.freedata2
			lea	msg_io_filenotfound,a2
			jmp	displaymessage
.fileopened
			move.l	pp_base(a5),a6
			move.l	filehandle(a5),d0
			moveq	#0,d1
			move.b	prf_data+prf_cruncheff,d1
			moveq	#0,d2
			moveq	#0,d3
			jsr	_lvoppwritedataheader(a6)
			tst.l	d0
			bpl.b	.dataheaderok
			bsr	.freedata2
			lea	msg_io_fileerror,a2
			jmp	displaymessage
.dataheaderok
			move.l	dosbase(a5),a6
			move.l	.memadr(pc),d2
			move.l	.crunchedlen(pc),d3
			move.l	filehandle(a5),d1
			jsr	dos_write(a6)
			tst.l	d0
			bpl.b	.finished
.error			bsr	.freedata2
			bra	ioerror
.finished		bra	.freedata

.canceled
			bsr	.freedata

			lea	msg_pp_canceled,a2
			jmp	displaymessage
.overflow
			bsr	.freedata

			lea	msg_pp_overflow,a2
			jmp	displaymessage

.crunchedlen		ds.l	1
.crunchinfo		ds.l	1
.memadr			ds.l	1
			ifeq	lang
.title			dc.b	"Select file to powerpack...",0
.status			dc.b	"To go...         "
			else
.title			dc.b	"Datei zum Packen auswählen...",0
.status			dc.b	"Übrig...         "
			endif

.actual			dc.b	"0000000 / "
.total			dc.b	"0000000"
.statusE

			ifeq	lang
.status2		dc.b	"Crunched size... "
			else
.status2		dc.b	"Gecrunchte Länge "
			endif
.crunched		dc.b	"0000000 /     "
.gain			dc.b	"00%"
.status2E
			even
.func
			move.l	8(sp),d0	; lensofar
			move.l	4(sp),d7

			movem.l	d0-a6,-(sp)
			lea	main_data,a5

			move.l	utilbase(a5),a6
			moveq	#100,d1
			jsr	util_umult32(a6)
			move.l	d7,d1
			jsr	util_udivmod32(a6)
; d0=prozent!
			move.l	d0,d5
			moveq	#100,d0
			sub	d5,d0
			lea	.gain(pc),a0
			jsr	integertoascii2

			move.l	d5,d1
			move.l	iobuffer+122,d0
			jsr	util_umult32(a6)
			moveq	#100,d1
			jsr	util_udivmod32(a6)

			lea	.crunched(pc),a0
			jsr	integertoascii7

			move.l	gfxbase(a5),a6

			move.l	d7,d0
			lea	.actual(pc),a0
			jsr	integerTOascii7

			move.l	rastport2(a5),a1
			move.l	#10+17*8,d0
			moveq	#20,d1
			jsr	gfx_move(a6)
			move.l	rastport2(a5),a1
			lea	.actual(pc),a0
			moveq	#7,d0
			jsr	gfx_text(a6)

			move.l	rastport2(a5),a1
			move.l	#10+17*8,d0
			moveq	#29,d1
			jsr	gfx_move(a6)
			move.l	rastport2(a5),a1
			lea	.crunched(pc),a0
			moveq	#7,d0
			jsr	gfx_text(a6)

			move.l	rastport2(a5),a1
			move.l	#10+31*8,d0
			moveq	#29,d1
			jsr	gfx_move(a6)
			move.l	rastport2(a5),a1
			lea	.gain(pc),a0
			moveq	#2,d0
			jsr	gfx_text(a6)
			movem.l	(sp)+,d0-a6

			btst	#6,$bfe001
			beq.b	.yes
.no			moveq	#1,d0
			rts
.yes			btst	#10,$dff016
			bne.b	.no
			moveq	#0,d0
			rts
.freedata
			move.l	dosbase(a5),a6
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
.freedata2
			move.l	pp_base(a5),a6
			move.l	.crunchinfo(pc),a0
			jsr	_LvoppFreeCrunchInfo(a6)
			move.l	exec,a6
			move.l	.memADR(PC),a1
			jsr	exec_freevec(a6)

			movem.l	d0-a6,-(sp)
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
			movem.l	(sp)+,d0-a6

			move.b	#1,itt_adpd_flag(a5)

			rts

;------------------------------------------------------------------------
DeleteFile:
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			lea	var_filename,a2
			lea	.title(pc),a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename

			lea	iofilename,a0
			lea	vdel_name,a1
			moveq	#75-1,d7
.loop			move.b	(a0)+,(a1)+
			tst.b	-1(a1)
			dbeq	d7,.loop

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	vdel_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0
			bne.b	.yes
			rts
.yes
			move.l	#iofilename,d1
			move.l	dosbase(a5),a6
			jmp	dos_delete(a6)

			ifeq	lang
.title			dc.b	"Select file to delete...",0
			else
.title			dc.b	"Datei löschen...",0
			endif
			even
;------------------------------------------------------------------------
ActivateinstrName	move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_instrumentname*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateSongName	move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_songname*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateAuthor		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_songauthor*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateDate		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_songdate*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateSongPos		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_pos*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;-----------------------------------------------------	SongPosChanged
SongPosChange		move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
spc_routentry		move.b	d0,aon_data+aon_pos

spc_checkup		tst.b	replaystatus(a5)	; Replay aus ?!
			beq.s	spc_getout
			move.b	#$f,pattdspreq(a5)  ; sonst neuen pat. ausgeben

			move.l	aon_posdata+aon_data,a1	; get start of posdat
			move.b	(a1,d0),d0
			move.b	d0,acteditpattern+main_data+1
spc_getout		
			jsr	refresh_pos
			jsr	refresh_pat
			rts
;------------------------------------------------------------------------
EditStatusChange	bchg	#0,patteditstatus(a5)
			rts
;------------------------------------------------------------------------
SongPosAdd
			lea	aon_pos+aon_data,a0
			addq.b	#1,(a0)
spa_ok			move.b	(a0),d0
			bra.b	spc_checkup
;------------------------------------------------------------------------
SongPosSUB		lea	aon_pos+aon_data,a0
			subq.b	#1,(a0)
			bpl.b	spa_ok
			move.l	aon_statdata+aon_data,a1
			move.b	aon.songinfo_maxpos(a1),(a0)
			subq.b	#1,(a0)
			bra.b	spa_ok
;------------------------------------------------------------------------
ActivateMaxPos		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_max*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
MaxPosChange		move.l	$22(a1),a1
			move.l	$1c(a1),d0
mpc_checkrange		and.l	#255,d0
			bne.b	mpc_notzero
			moveq	#1,d0
mpc_notzero		move.l	aon_statdata+aon_data,a0
			move.b	d0,aon.songinfo_maxpos(a0)
			bsr	poslistsetgadget
			jmp	refresh_max
;------------------------------------------------------------------------
MaxPosADD		move.l	aon_statdata+aon_data,a0
			moveq	#0,d0
			move.b	aon.songinfo_maxpos(a0),d0
			addq	#1,d0
			bra.b	mpc_checkrange
;------------------------------------------------------------------------
MaxPosSUB		move.l	aon_statdata+aon_data,a0
			moveq	#0,d0
			move.b	aon.songinfo_maxpos(a0),d0
			subq	#1,d0
			bra.b	mpc_checkrange
;------------------------------------------------------------------------
ActivateResPos		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_res*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ResPosChange		move.l	$22(a1),a1
			move.l	$1c(a1),d0
			move.l	aon_statdata+aon_data,a0
			move.b	d0,aon.songinfo_respos(a0)
			jmp	refresh_res
;------------------------------------------------------------------------
ResPosADD		move.l	aon_statdata+aon_data,a0
			addq.b	#1,aon.songinfo_respos(a0)
			jmp	refresh_res
;------------------------------------------------------------------------
ResPosSUB		move.l	aon_statdata+aon_data,a0
			subq.b	#1,aon.songinfo_respos(a0)
			jmp	refresh_res
;------------------------------------------------------------------------
Activatepat		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_pat*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
PatChange		move.l	$22(a1),a1
			move.l	$1c(a1),d0
			and.b	#$7f,d0
			move.l	aon_posdata+aon_data,a0
			moveq	#0,d1
			move.b	aon_data+aon_pos,d1
			move.b	d0,(a0,d1.l)
			jsr	refresh_pos
			jmp	refresh_pat
;------------------------------------------------------------------------
PatADD			move.l	aon_posdata+aon_data,a0
			moveq	#0,d0
			move.b	aon_data+aon_pos,d0
			addq.b	#1,(a0,d0.l)
			tst.b	chmode(a5)
			beq.b	.4ch
			and.b	#$3f,(a0,d0.l)
			bra.b	.8ch
.4ch			and.b	#$7f,(a0,d0.l)
.8ch			jsr	refresh_pos
			jmp	refresh_pat
;------------------------------------------------------------------------
PatSUB			move.l	aon_posdata+aon_data,a0
			moveq	#0,d0
			move.b	aon_data+aon_pos,d0
			subq.b	#1,(a0,d0.l)
			tst.b	chmode(a5)
			beq.b	.4ch
			and.b	#$3f,(a0,d0.l)
			bra.b	.8ch
.4ch			and.b	#$7f,(a0,d0.l)
.8ch			jsr	refresh_pos
			jmp	refresh_pat
;------------------------------------------------------------------------
InsertPos		move.l	aon_posdata+aon_data,a0
			moveq	#0,d0
			move.b	aon_pos+aon_data,d0
			move.l	#255,d1
			sub	d0,d1
			beq.b	ip_lastpos
			lea	256(a0),a1	; end of postab
			lea	255(a0),a0	; end of postab-1
			subq	#1,d1
ip_copyposloop		move.b	-(a0),-(a1)
			dbf	d1,ip_copyposloop
			clr.b	(a0)

			move.l	aon_statdata+aon_data,a0
			cmp.b	#255,aon.songinfo_maxpos(a0)
			beq.b	ip_notmaxposadd
			addq.b	#1,aon.songinfo_maxpos(a0)
			jsr	refresh_max
ip_notmaxposadd		jsr	refresh_pos
			jmp	refresh_pat
ip_lastpos		rts
;------------------------------------------------------------------------
DeletePos		move.l	aon_posdata+aon_data,a0
			moveq	#0,d0
			move.b	aon_pos+aon_data,d0
			move.l	#255,d1
			sub	d0,d1
			beq.b	ip_lastpos
			lea	(a0,d0),a0
			lea	1(a0),a1	; pos+1
			subq	#1,d1
dp_copyposloop		move.b	(a1)+,(a0)+
			dbf	d1,dp_copyposloop
			clr.b	(a0)
			move.l	aon_statdata+aon_data,a0
			cmp.b	#1,aon.songinfo_maxpos(a0)
			beq.b	dp_nomaxpossub
			subq.b	#1,aon.songinfo_maxpos(a0)
			jsr	refresh_max
dp_nomaxpossub		jsr	refresh_pos
			jmp	refresh_pat
;------------------------------------------------------------------------
ActivateEditPat		move.l	intbase(a5),a6
			move.l	mp_gadgetptrs+gad_editpat*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
EditPatChange		move.l	$22(a1),a1
			move.l	$1c(a1),d0
			tst.b	chmode(a5)
			bne.b	.8ch
			and.l	#$7f,d0
			bra.b	.4ch
.8ch			and.l	#$3f,d0
.4ch			move	d0,acteditpattern(a5)
			move.b	#$f,pattdspreq(a5)
			jmp	refresh_editpat
;------------------------------------------------------------------------
EditPatADD		addq.b	#1,acteditpattern+1(a5)
			move.b	#$f,pattdspreq(a5)
			tst.b	chmode(a5)
			bne.b	.8ch
			and.b	#$7f,acteditpattern+1(a5)
			rts
.8ch			and.b	#$3f,acteditpattern+1(a5)
			rts
;------------------------------------------------------------------------
EditPatSUB		subq.b	#1,acteditpattern+1(a5)
			move.b	#$f,pattdspreq(a5)
			tst.b	chmode(a5)
			bne.b	.8ch
			and.b	#$7f,acteditpattern+1(a5)
			rts
.8ch			and.b	#$3f,acteditpattern+1(a5)
			rts
;------------------------------------------------------------------------
InstrNrADD		addq	#1,acteditinstr(a5)
			cmp	#61,acteditinstr(a5)
			bne.b	ina_inrange
			move	#60,acteditinstr(a5)
ina_inrange
;	cmp.b	#waveformed,programmode(a5)
;	bne.b	.notwaveed
			jsr	setnewwave

			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jmp	refresh_instrument
;------------------------------------------------------------------------
InstrNrSUB		subq	#1,acteditinstr(a5)
			bpl.b	ins_inrange
			clr	acteditinstr(a5)
ins_inrange
			jsr	setnewwave
			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jmp	refresh_instrument
;------------------------------------------------------------------------
InstrNrChange		move	#gad_changeinstrnr,lastdownID(a5)
			move	$18(a0),acteditinstr(a5)
			
			clr.l	waveed_rangesize(a5)
			clr.l	waveed_wavepos(a5)
			jsr	instred_actualdata
			move.b	instr_waveform(a0),waveed_actwave(a5)
			jsr	waveed_setshowall
			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jmp	refresh_instrument
InstrNrChangeNOW
			move	$18(a0),acteditinstr(a5)

			jsr	setnewwave

			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jsr	refresh_instrument
			bra	mmm
;------------------------------------------------------------------------
set_instr		move	d0,acteditinstr(a5)
			jsr	setnewwave
			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jmp	refresh_instrument
SET_INSTR1		moveq	#0,d0
			bra.b	set_instr
SET_INSTR2		moveq	#1,d0
			bra.b	set_instr
SET_INSTR3		moveq	#2,d0
			bra.b	set_instr
SET_INSTR4		moveq	#3,d0
			bra.b	set_instr
SET_INSTR5		moveq	#4,d0
			bra.b	set_instr
SET_INSTR6		moveq	#5,d0
			bra.b	set_instr
SET_INSTR7		moveq	#6,d0
			bra.b	set_instr
SET_INSTR8		moveq	#7,d0
			bra.b	set_instr
SET_INSTR9		moveq	#8,d0
			bra.b	set_instr
SET_INSTRa		moveq	#9,d0
			bra.b	set_instr
SET_INSTRb		moveq	#10,d0
			bra.b	set_instr
SET_INSTRc		moveq	#11,d0
			bra.b	set_instr
SET_INSTRd		moveq	#12,d0
			bra.b	set_instr
SET_INSTRe		moveq	#13,d0
			bra.b	set_instr
SET_INSTRf		moveq	#14,d0
			bra.b	set_instr
SET_INSTRg		moveq	#15,d0
			bra.b	set_instr
SET_INSTRh		moveq	#16,d0
			bra.b	set_instr
SET_INSTRi		moveq	#17,d0
			bra.b	set_instr
SET_INSTRj		moveq	#18,d0
			bra.b	set_instr
SET_INSTRk		moveq	#19,d0
			bra.b	set_instr
SET_INSTRl		moveq	#20,d0
			bra.w	set_instr
SET_INSTRm		moveq	#21,d0
			bra.w	set_instr
SET_INSTRn		moveq	#22,d0
			bra.w	set_instr
SET_INSTRo		moveq	#23,d0
			bra.w	set_instr
SET_INSTRp		moveq	#24,d0
			bra.w	set_instr
SET_INSTRq		moveq	#25,d0
			bra.w	set_instr
SET_INSTRr		moveq	#26,d0
			bra.w	set_instr
SET_INSTRs		moveq	#27,d0
			bra.w	set_instr
SET_INSTRt		moveq	#28,d0
			bra.w	set_instr
SET_INSTRu		moveq	#29,d0
			bra.w	set_instr
SET_INSTRv		moveq	#30,d0
			bra	set_instr
SET_INSTRw		moveq	#31,d0
			bra	set_instr
SET_INSTRx		moveq	#32,d0
			bra	set_instr
SET_INSTRy		moveq	#33,d0
			bra	set_instr
SET_INSTRz		moveq	#34,d0
			bra	set_instr
SET_INSTRA2		moveq	#35,d0
			bra	set_instr
SET_INSTRB2		moveq	#36,d0
			bra	set_instr
SET_INSTRC2		moveq	#37,d0
			bra	set_instr
SET_INSTRD2		moveq	#38,d0
			bra	set_instr
SET_INSTRE2		moveq	#39,d0
			bra	set_instr
SET_INSTRF2		moveq	#40,d0
			bra	set_instr
SET_INSTRG2		moveq	#41,d0
			bra	set_instr
SET_INSTRH2		moveq	#42,d0
			bra	set_instr
SET_INSTRI2		moveq	#43,d0
			bra	set_instr
SET_INSTRJ2		moveq	#44,d0
			bra	set_instr
SET_INSTRK2		moveq	#45,d0
			bra	set_instr
SET_INSTRL2		moveq	#46,d0
			bra	set_instr
SET_INSTRM2		moveq	#47,d0
			bra	set_instr
SET_INSTRN2		moveq	#48,d0
			bra	set_instr
SET_INSTRO2		moveq	#49,d0
			bra	set_instr
SET_INSTRP2		moveq	#50,d0
			bra	set_instr
SET_INSTRQ2		moveq	#51,d0
			bra	set_instr
SET_INSTRR2		moveq	#52,d0
			bra	set_instr
SET_INSTRS2		moveq	#53,d0
			bra	set_instr
SET_INSTRT2		moveq	#54,d0
			bra	set_instr
SET_INSTRU2		moveq	#55,d0
			bra	set_instr
SET_INSTRV2		moveq	#56,d0
			bra	set_instr
SET_INSTRW2		moveq	#57,d0
			bra	set_instr
SET_INSTRX2		moveq	#58,d0
			bra	set_instr
SET_INSTRY2		moveq	#59,d0
			bra	set_instr
SET_INSTRZ2		moveq	#60,d0
			bra	set_instr
;-----------!!!!!!!!!
SET_INSTRTRP		add.b	#16,instrtrp(a5)
			and.b	#63,instrtrp(a5)
			rts
sin_setit		add.b	instrtrp(a5),d0
			cmp.b	#61,d0
			bge.b	sin_out
			move	d0,acteditinstr(a5)
;	cmp.b	#waveformed,programmode(a5)
;	bne.b	.notwaveed

			jsr	setnewwave

			tst.b	screen(a5)
			beq.b	.not
			jsr	refresh_instrumentED
.not			jmp	refresh_instrument
sin_out			rts
set_instrnx1		moveq	#0,d0
			bra.b	sin_setit
set_instrnx2		moveq	#1,d0
			bra.b	sin_setit
set_instrnx3		moveq	#2,d0
			bra.b	sin_setit
set_instrnx4		moveq	#3,d0
			bra.b	sin_setit
set_instrnx5		moveq	#4,d0
			bra.b	sin_setit
set_instrnx6		moveq	#5,d0
			bra.b	sin_setit
set_instrnx7		moveq	#6,d0
			bra.b	sin_setit
set_instrnx8		moveq	#7,d0
			bra.b	sin_setit
set_instrnx9		moveq	#8,d0
			bra.b	sin_setit
set_instrnxa		moveq	#9,d0
			bra.b	sin_setit
set_instrnxb		moveq	#10,d0
			bra.b	sin_setit
set_instrnxc		moveq	#11,d0
			bra.b	sin_setit
set_instrnxd		moveq	#12,d0
			bra.b	sin_setit
set_instrnxe		moveq	#13,d0
			bra.b	sin_setit
set_instrnxf		moveq	#14,d0
			bra.b	sin_setit
set_instrnxg		moveq	#15,d0
			bra.b	sin_setit
set_instrnxh		moveq	#16,d0
			bra.b	sin_setit
set_instrnxi		moveq	#17,d0
			bra.w	sin_setit
set_instrnxj		moveq	#18,d0
			bra.w	sin_setit
set_instrnxk		moveq	#19,d0
			bra.w	sin_setit
set_instrnxl		moveq	#20,d0
			bra.w	sin_setit
set_instrnxm		moveq	#21,d0
			bra.w	sin_setit
set_instrnxn		moveq	#22,d0
			bra.w	sin_setit
set_instrnxo		moveq	#23,d0
			bra.w	sin_setit
set_instrnxp		moveq	#24,d0
			bra.w	sin_setit
set_instrnxq		moveq	#25,d0
			bra.w	sin_setit
set_instrnxr		moveq	#26,d0
			bra.w	sin_setit
set_instrnxs		moveq	#27,d0
			bra	sin_setit
set_instrnxt		moveq	#28,d0
			bra	sin_setit
set_instrnxu		moveq	#29,d0
			bra	sin_setit
set_instrnxv		moveq	#30,d0
			bra	sin_setit
set_instrnxw		moveq	#31,d0
			bra	sin_setit
set_instrnxx		moveq	#32,d0
			bra	sin_setit
;--------------------------------------------------------------------
MovePatCursorRight	addq.b	#2,patcntX(a5)
			tst.b	chmode(a5)
			beq.b	.4ch
			cmp.b	#48*2,patcntX(a5)
			bne	actmarkpos
			clr.b	patcntx(a5)
			bra	actmarkpos
.4ch
			cmp.b	#48,patcntX(a5)
			bne	actmarkpos
			clr.b	patcntx(a5)
			jmp	actmarkpos
;--------------------------------------------------------------------
MovePatCursorLEFT	subq.b	#2,patcntX(a5)
			bpl	actmarkpos
			tst.b	chmode(a5)
			beq.b	.4ch
			move.b	#96-2,patcntx(a5)
			jmp	actmarkpos
.4ch			move.b	#48-2,patcntx(a5)
			jmp	actmarkpos
;--------------------------------------------------------------------
MovePatCursorDown	tst.b	replaystatus(a5)
			bne.b	mpc_raus
			addq.b	#4,aon_patcnt+aon_data+1
			jmp	actmarkpos
mpc_raus		rts
;--------------------------------------------------------------------
MovePatCursorUp		tst.b	replaystatus(a5)
			bne.b	mpc_raus
			subq.b	#4,aon_patcnt+aon_data+1
			jmp	actmarkpos
;------------------------------------------------------------------------
; d0=KeyCode
noteedit_key2int
			bsr	getchanneloff

			tst.b	d1
			beq	ne_playnote

			tst.b	patteditstatus(a5)
			beq.b	nek2i_noedit

			move	#1,songchanged(a5)

			movem.l	d0/d1,-(sp)
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd
			lea	(a0,d0.l),a0
			add.l	iobuffer,a0	; +choffset!!
			movem.l	(sp)+,d0/d1

			bsr	raw2val
			tst.b	d0
			bmi.b	nek2i_noedit

			cmp.b	#2,d1
			beq.b	ne_instrnr
			cmp.b	#4,d1
			beq.b	ne_arpeggio
			cmp.b	#6,d1
			beq.b	ne_effectcom
			cmp.b	#8,d1
			beq.b	ne_fxpar1
			cmp.b	#10,d1
			beq.b	ne_fxpar2

nek2i_noedit		rts

;----------!!!!!!!!!!
ne_instrnr
			and.b	#%11000000,1(a0)
			or.b	d0,1(a0)
			jmp	pnp_printline
;----------!!!!!!!!!!
ne_arpeggio
			cmp.b	#$f,d0
			bhi.b	nek2i_noedit
			move.b	d0,d1
			and.b	#%0011,d0
			ror.b	#2,d0
			and.b	#%1100,d1
			ror.b	#4,d1
			and.b	#%00111111,2(a0)
			and.b	#%00111111,1(a0)
			or.b	d1,2(a0)
			or.b	d0,1(a0)

			jmp	pnp_printline
;----------!!!!!!!!!!
ne_effectcom
			and.b	#%11000000,2(a0)
			or.b	d0,2(a0)
			jmp	pnp_printline
;----------!!!!!!!!!!
ne_fxpar1
			cmp.b	#$f,d0
			bhi.b	nek2i_noedit
			and.b	#$0f,3(a0)
			lsl.b	#4,d0
			or.b	d0,3(a0)
			jmp	pnp_printline
;----------!!!!!!!!!!
ne_fxpar2
			cmp.b	#$f,d0
			bhi.b	nek2i_noedit
			and.b	#$f0,3(a0)
			or.b	d0,3(a0)
			jmp	pnp_printline
;----------!!!!!!!!!!

;---------------------- Note auf angewähltem Kanal spielen -------------
ne_playnote		tst.b	octave(a5)
			beq.b	ne_octave00
			cmp.b	#1,octave(a5)
			beq.b	ne_octave0
			lea	ne_raw2notetab_oct1,a1
			bra.b	ne_octave1
ne_octave0		lea	ne_raw2notetab_oct0,a1
			bra.b	ne_octave1
ne_octave00		lea	ne_raw2notetab_oct00,a1
ne_octave1
; d0=RawKeyCode
			lea	ne_playstep,a0
			moveq	#-1,d2
ne_findnote		cmp	(a1),d2
			beq	ne_notanotekey
			cmp.l	(a1),d0
			beq.b	ne_notefound
			addq.l	#8,a1
			bra.b	ne_findnote
ne_notefound		move.b	7(a1),(a0)
			move.b	acteditinstr+1(a5),1(a0)
			addq.b	#1,1(a0)

;		bra	nowplaystep
;--------------------------------------------------------------------
; a0=Stepadr
; iobuffer=channeloff
nowplaystep
			tst.b	patteditstatus(a5)
			beq.b	.noedit
			tst.b	replaystatus(a5)
			bne.b	.notplaynote
.noedit
			move.l	a5,-(sp)
			lea	aon_multab120,a5	; needed for periodtab
			lea	aon_data,a6
			jsr	aon_getdachannel
			move.l	(sp)+,a5
.notplaynote
			tst.b	cheditmode(a5)
			beq.b	.notjmpch
			bsr	jumpchannel
.notjmpch

			tst.b	patteditstatus(a5)
			beq.w	ne_notanotekey
			move	ne_playstep,d0
			move.b	d0,d1
			lsr	#8,d0
			and	#63,d0
			and	#63,d1
			movem	d0/d1,-(sp)
			
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0

			moveq	#0,d6
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			beq.b	.quant0

			tst.b	replaystatus(a5)
			beq.b	.stepbystep
			moveq	#0,d1
			move.b	addstep(a5),d1
			bne.b	.notquant0
.stepbystep		move.b	d0,d6
			bra.b	.quant0
.notquant0
			lsl	#6,d0		; step *256
			lsr	#2,d1
			divu	d1,d0		/addstep
			tst.b	d0
			bpl.b	.backwd
			add	#$100,d0
.backwd			lsr	#8,d0
			moveq	#0,d1
			move.b	addstep(a5),d1
			mulu	d1,d0
			move.b	d0,d6
.quant0
			tst.b	chmode(a5)
			beq.b	.4chadd2
			lsl	#3,d0
			bra.b	.8chadd2
.4chadd2		add	d0,d0
			add	d0,d0
.8chadd2
			lea	(a0,d0.l),a0
			movem	(sp)+,d0/d1
			and.b	#%11000000,(a0)
			and.b	#%11000000,1(a0)
			or.b	d0,(a0)
			or.b	d1,1(a0)

			move	#1,songchanged(a5)

			tst.b	patteditstatus(a5)
			beq.b	ne_notanotekey

			move.b	#1,stepdspreq(a5)
			moveq	#0,d0
			move.b	d6,d0
			jsr	printnewpatterns.step
ne_notanotekey		rts
;--------------------------------------------------------------------
; d0=ScAnCode
; <-- d0=Digit (0-61) or -1 if failed

raw2val			movem.l	d1/a0,-(sp)
			moveq	#-1,d1
			lea	key2int_tab,a0
nek2i_checkkey		cmp	(a0),d1
			beq.b	nek2i_overandout
			cmp.l	(a0),d0
			beq.b	nek2i_keyfound
			addq.l	#8,a0
			bra.b	nek2i_checkkey
nek2i_overandout	move	d1,d0
			movem.l	(sp)+,d1/a0
			rts
nek2i_keyfound		move.l	4(a0),d0
			movem.l	(sp)+,d1/a0
			rts
;------------------------------------------------------------------------
jumpChannel
			moveq	#0,d0
			move.b	patcntx(a5),d0
			beq.b	.div0
			divu	#12,d0
.div0			addq.b	#1,d0
			tst.b	chmode(a5)
			beq.b	.4ch
			and.b	#7,d0
			bra.b	.8ch
.4ch			and.b	#3,d0
.8ch			mulu	#12,d0
			move.b	d0,patcntx(a5)
			bra	actmarkpos
;------------------------------------------------------------------------
jumpChannelbk
			moveq	#0,d0
			move.b	patcntx(a5),d0
			beq.b	.div0
			divu	#12,d0
.div0			subq.b	#1,d0
			tst.b	chmode(a5)
			beq.b	.4ch
			and.b	#7,d0
			bra.b	.8ch
.4ch			and.b	#3,d0
.8ch			mulu	#12,d0
			move.b	d0,patcntx(a5)
			bra	actmarkpos
;------------------------------------------------------------------------
Move16stepsdown		tst.b	replaystatus(a5)
			bne.b	msd_replayison
			add.b	#8*4,aon_patcnt+1+aon_data
			and.b	#%11100000,aon_patcnt+1+aon_data
			bsr	actmarkpos
msd_replayison		rts
;------------------------------------------------------------------------
Move16stepsup		tst.b	replaystatus(a5)
			bne.b	msd_replayison
			subq.b	#4,aon_patcnt+1+aon_data
			and.b	#%11100000,aon_patcnt+1+aon_data
			bra	actmarkpos
;------------------------------------------------------------------------
SetOctave0		clr.b	octave(a5)
			rts
SetOctave1		move.b	#1,octave(a5)
			rts
SetOctave2		move.b	#2,octave(a5)
			rts
;------------------------------------------------------------------------
ne_deletestep
			tst.b	patteditstatus(a5)
			beq	ds_outtaspace

			move	#1,songchanged(a5)

			bsr	getchanneloff

			tst.b	d1
			bne.b	ds_outtaspace


			swap	d0
			move	d0,-(sp)
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd
			lea	(a0,d0.l),a0

			move	(sp)+,d0		; keylevel
			bne.b	ds_wholestep		; <>0 (=1)

			and.b	#%11000000,(a0)
			and.b	#%11000000,1(a0)
			jmp	pnp_printline
ds_wholestep		clr.l	(a0)
			jmp	pnp_printline
ds_outtaspace		rts
;------------------------------------------------------------------------
; <--d1		=	channelcntxoffset
; <--a4		=	aon_channels+chdatasizeOffset
; <--iobuffer	=	chbyteoffset
Getchanneloff		moveq	#0,d1
			move.b	patcntx(a5),d1
			cmp.b	#12*7,d1
			bge.w	ds_ch8
			cmp.b	#12*6,d1
			bge.w	ds_ch7
			cmp.b	#12*5,d1
			bge.w	ds_ch6
			cmp.b	#12*4,d1
			bge.b	ds_ch5
			cmp.b	#12*3,d1
			bge.s	ds_ch4
			cmp.b	#12*2,d1
			bge.s	ds_ch3
			cmp.b	#12*1,d1
			bge.s	ds_ch2

ds_ch1			lea	aon_channels,a4
			clr.l	iobuffer
			bra.w	ds_chc
ds_ch2			lea	aon_channels+aon_chdatasize,a4
			move.l	#4,iobuffer
			sub.b	#12,d1
			bra.w	ds_chc
ds_Ch3			lea	aon_channels+(aon_chdatasize*2),a4
			move.l	#8,iobuffer
			sub.b	#24,d1
			bra.b	ds_chc
ds_Ch4			lea	aon_channels+(aon_chdatasize*3),a4
			move.l	#12,iobuffer
			sub.b	#36,d1
			bra.b	ds_chc
ds_Ch5			lea	aon_channels+(aon_chdatasize*4),a4
			move.l	#16,iobuffer
			sub.b	#12*4,d1
			bra.b	ds_chc
ds_Ch6			lea	aon_channels+(aon_chdatasize*5),a4
			move.l	#20,iobuffer
			sub.b	#12*5,d1
			bra.b	ds_chc
ds_Ch7			lea	aon_channels+(aon_chdatasize*6),a4
			move.l	#24,iobuffer
			sub.b	#12*6,d1
			bra.b	ds_chc
ds_Ch8			lea	aon_channels+(aon_chdatasize*7),a4
			move.l	#28,iobuffer
			sub.b	#12*7,d1
ds_chC			rts
;------------------------------------------------------------------------
quant0			clr.b	addstep(a5)
			rts
quant1			move.b	#4,addstep(a5)
			rts
quant2			move.b	#8,addstep(a5)
			rts
quant3			move.b	#12,addstep(a5)
			rts
quant4			move.b	#16,addstep(a5)
			rts
quant5			move.b	#20,addstep(a5)
			rts
quant6			move.b	#24,addstep(a5)
			rts
quant7			move.b	#28,addstep(a5)
			rts
quant8			move.b	#32,addstep(a5)
			rts
quant9			move.b	#36,addstep(a5)
			rts
;------------------------------------------------------------------------
deletestepcmds:	
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			jsr	getchanneloff
			add.l	iobuffer,a0
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd			add.l	d0,a0

			move.l	(a0),d0

			move.l	d0,d1
			and.l	#%11111111001111110000000000000000,d0
			move.l	d0,(a0)
			and.l	#%00000000110000001111111111111111,d1
			move.l	d1,smallcmdbuf
			
			jmp	pnp_printline
smallcmdbuf		dc.l	0
;------------------------------------------------------------------------
replacestepcmds:	
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			jsr	getchanneloff
			add.l	iobuffer,a0
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd			add.l	d0,a0

			move.l	(a0),d0
			and.l	#%11111111001111110000000000000000,d0
			or.l	smallcmdbuf(pc),d0
			move.l	d0,(a0)
			
			jmp	pnp_printline
;------------------------------------------------------------------------

;------------------------------------------------------------------------
CutPattern2Buf
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			tst.b	chmode(a5)
			beq.w	.4ch

			lea	patternbuf+2048,a1
			REPT	2048/32
			movem.l	(a0)+,d0-d7
			movem.l	d0-d7,-(a1)
			ENDR
			moveq	#0,d0
			moveq	#0,d1
			moveq	#0,d2
			moveq	#0,d3
			moveq	#0,d4
			moveq	#0,d5
			moveq	#0,d6
			moveq	#0,d7
			REPT	2048/32
			movem.l	d0-d7,-(a0)
			ENDR
			move.b	#$f,pattdspreq(a5)
			rts

.4ch			lea	patternbuf+1024,a1
			REPT	1024/32
			movem.l	(a0)+,d0-d7
			movem.l	d0-d7,-(a1)
			ENDR
			moveq	#0,d0
			moveq	#0,d1
			moveq	#0,d2
			moveq	#0,d3
			moveq	#0,d4
			moveq	#0,d5
			moveq	#0,d6
			moveq	#0,d7
			REPT	1024/32
			movem.l	d0-d7,-(a0)
			ENDR
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
CopyPattern2Buf		move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			tst.b	chmode(a5)
			beq	.4ch

			lea	patternbuf+2048,a1
			REPT	2048/32
			movem.l	(a0)+,d0-d7
			movem.l	d0-d7,-(a1)
			ENDR
			rts
.4ch
			lea	patternbuf+1024,a1
			REPT	1024/32
			movem.l	(a0)+,d0-d7
			movem.l	d0-d7,-(a1)
			ENDR
			rts
;------------------------------------------------------------------------
CopyBuf2Pattern
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			tst.b	chmode(a5)
			beq.w	.4ch
			lea	patternbuf,a1
			lea	2048(a0),a0
			REPT	2048/32
			movem.l	(a1)+,d0-d7
			movem.l	d0-d7,-(a0)
			ENDR
			move.b	#$f,pattdspreq(a5)
			rts
.4ch			lea	patternbuf,a1
			lea	1024(a0),a0
			REPT	1024/32
			movem.l	(a1)+,d0-d7
			movem.l	d0-d7,-(a0)
			ENDR
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
CutTrack2Buf
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			lea	trackbuf,a1
			moveq	#0,d0
			tst.b	chmode(a5)
			beq.w	.4ch

			REPT	64-1
			move.l	(a0),(a1)+
			move.l	d0,(a0)
			lea	32(a0),a0
			ENDR
			move.l	(a0),(a1)
			move.l	d0,(a0)
			move.b	#$f,pattdspreq(a5)
			rts
.4ch
			REPT	64-1
			move.l	(a0),(a1)+
			move.l	d0,(a0)
			lea	16(a0),a0
			ENDR
			move.l	(a0),(a1)
			move.l	d0,(a0)
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
CopyTrack2Buf
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			lea	trackbuf,a1
			tst.b	chmode(a5)
			beq.w	.4ch

			REPT	64-1
			move.l	(a0),(a1)+
			lea	32(a0),a0
			ENDR
			move.l	(a0),(a1)
			rts
.4ch			REPT	64-1
			move.l	(a0),(a1)+
			lea	16(a0),a0
			ENDR
			move.l	(a0),(a1)
			rts
;------------------------------------------------------------------------
CopyBuf2Track
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			lea	trackbuf,a1
			tst.b	chmode(a5)
			beq.w	.4ch

			REPT	64-1
			move.l	(a1)+,(a0)
			lea	32(a0),a0
			ENDR
			move.l	(a1),(a0)
			move.b	#$f,pattdspreq(a5)
			rts
.4ch
			REPT	64-1
			move.l	(a1)+,(a0)
			lea	16(a0),a0
			ENDR
			move.l	(a1),(a0)
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
CutCmds2Buf		bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0
			lea	cmdbuf,a1
			move.l	#%11000000110000001111111111111111,d1
			move.l	#%00111111001111110000000000000000,d2
			moveq	#64-1,d7
cc2b_loop		move.l	(a0),d0
			and.l	d1,d0
			and.l	d2,(a0)
			move.l	d0,(a1)+
			tst.b	chmode(a5)
			beq.b	.4ch
			lea	16(a0),a0
.4ch			lea	16(a0),a0
			dbf	d7,cc2b_loop
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
CopyCmds2Buf		bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0
			lea	cmdbuf,a1
			move.l	#%11000000110000001111111111111111,d1
			moveq	#64-1,d7
cc2b2_loop		move.l	(a0),d0
			and.l	d1,d0
			move.l	d0,(a1)+
			tst.b	chmode(a5)
			beq.b	.4ch
			lea	16(a0),a0
.4ch			lea	16(a0),a0
			dbf	d7,cc2b2_loop
			rts
;------------------------------------------------------------------------
CopyBuf2TrackCMD	bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0
			lea	cmdbuf,a1
			move.l	#%11000000110000001111111111111111,d1
			move.l	#%00111111001111110000000000000000,d2
			moveq	#64-1,d7
cb2t_loop		move.l	(a1)+,d0
			and.l	d2,(a0)
			or.l	d0,(a0)
			tst.b	chmode(a5)
			beq.b	.4ch
			lea	16(a0),a0
.4ch			lea	16(a0),a0
			dbf	d7,cb2t_loop
			move.b	#$f,pattdspreq(a5)
			rts
;------------------------------------------------------------------------
InsertStep
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			tst.b	chmode(a5)
			beq.b	.4ch

			lea	2016(a0),a0	; end of pattern
			moveq	#64-1,d7
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			lsr	#2,d0
			sub	d0,d7
			bne.b	.notlast8
			clr.l	(a0)
			bra.b	.exit
.notlast8		move.l	-32(a0),(a0)
			lea	-32(a0),a0
			dbf	d7,.notlast8
			clr.l	32(a0)
			bra.b	.exit

.4ch
			lea	1008(a0),a0	; end of pattern
			moveq	#64-1,d7
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			lsr	#2,d0
			sub	d0,d7
			bne.b	.notlast
			clr.l	(a0)
			bra.b	.exit
.notlast		move.l	-16(a0),(a0)
			lea	-16(a0),a0
			dbf	d7,.notlast
			clr.l	16(a0)

.exit			addq.b	#4,aon_data+aon_patcnt+1
			move.b	#$f,pattdspreq(a5)
			bsr	actmarkpos
.cancel			rts
;------------------------------------------------------------------------
DeleteStep
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			bne.b	.notlast
			move.b	#$f,pattdspreq(a5)
			rts
.notlast		tst.b	chmode(a5)
			beq.b	.4ch

			move	#63*4,d7	; dbf!!
			sub	d0,d7
			lsl	#3,d0
			lea	-32(a0,d0),a0
			lsr	#2,d7
.loop8			move.l	32(a0),(a0)
			lea	32(a0),a0
			dbf	d7,.loop8
			clr.l	(a0)
			bra.b	.fin

.4ch
			move	#63*4,d7	; dbf!!
			sub	d0,d7
			add	d0,d0
			add	d0,d0
			lea	-16(a0,d0),a0
			lsr	#2,d7

.loop			move.l	16(a0),(a0)
			lea	16(a0),a0
			dbf	d7,.loop

			clr.l	(a0)
.fin
			subq.b	#4,aon_data+aon_patcnt+1

			bsr	actmarkpos
			move.b	#$f,pattdspreq(a5)
.exit			rts
;------------------------------------------------------------------------
togglech1now		bchg	#0,ch_enable(a5)
			rts
togglech2now		bchg	#1,ch_enable(a5)
			rts
togglech3now		bchg	#2,ch_enable(a5)
			rts
togglech4now		bchg	#3,ch_enable(a5)
			rts
togglech5now		bchg	#4,ch_enable(a5)
			rts
togglech6now		bchg	#5,ch_enable(a5)
			rts
togglech7now		bchg	#6,ch_enable(a5)
			rts
togglech8now		bchg	#7,ch_enable(a5)
			rts
updatetoggles
			move.b	ch_enable(a5),d6
			cmp.b	ch_oldenable(a5),d6
			beq.w	.nochange

			move.b	d6,ch_oldenable(a5)

			move.l	bitplane1_startadr(a5),a2
			lea	26*80+62+(75*80)(a2),a2
			moveq	#0,d0
			lea	number1,a1

			moveq	#0,d7
.lop			btst	d7,d6
			beq.b	.off
			move.b	d0,0*80(a2)
			move.b	0(a1),1*80(a2)
			move.b	1(a1),2*80(a2)
			move.b	2(a1),3*80(a2)
			move.b	3(a1),4*80(a2)
			move.b	4(a1),5*80(a2)
			move.b	5(a1),6*80(a2)
			move.b	6(a1),7*80(a2)
			move.b	7(a1),8*80(a2)
			move.b	d0,9*80(a2)
			not.b	0*80(a2)
			not.b	1*80(a2)
			not.b	2*80(a2)
			not.b	3*80(a2)
			not.b	4*80(a2)
			not.b	5*80(a2)
			not.b	6*80(a2)
			not.b	7*80(a2)
			not.b	8*80(a2)
			not.b	9*80(a2)
			bra.b	.on
.off			
			move.b	d0,0*80(a2)
			move.b	0(a1),1*80(a2)
			move.b	1(a1),2*80(a2)
			move.b	2(a1),3*80(a2)
			move.b	3(a1),4*80(a2)
			move.b	4(a1),5*80(a2)
			move.b	5(a1),6*80(a2)
			move.b	6(a1),7*80(a2)
			move.b	7(a1),8*80(a2)
			move.b	d0,9*80(a2)
.on
			addq.l	#8,a1
			addq.l	#2,a2
			addq.b	#1,d7
			cmp.b	#8,d7
			bne.w	.lop
.nochange		rts

			even
;------------------------------------------------------------------------
ABOUTAON
;			movem.l	d0-a6,-(sp)
;
;			clr.b	itt_adpd_flag(a5)
;
;.m			btst	#6,$bfe001
;			beq.b	.m
;
;;	jsr	adpd_realadjust
;
;			move.l	exec,a6
;			move.l	#225*80*2,d0
;			move.l	#$10001,d1
;			jsr	exec_allocvec(a6)
;			tst.l	d0
;			beq.w	.nomem
;			move.l	d0,.bufadr
;			move.l	d0,a2
;
;			move.l	bitplane1_startadr(a5),a0
;			move.l	bitplane2_startadr(a5),a1
;			lea	26*80(a0),a0
;			lea	26*80(a1),a1
;			move.l	a0,a4
;			move.l	a1,a5
;			move.l	#(225*80)/4,d7
;.backup			move.l	(a0)+,(a2)+
;			move.l	(a1)+,(a2)+
;			subq.l	#1,d7
;			bne.b	.backup
;
;			move.l	a4,a2
;			move.l	a5,a3
;
;
;			lea	gfx_about,a0
;			lea	78(a0),a1
;			addq.l	#1,a4
;			addq.l	#1,a5
;			move	#215-1,d7
;.showpic		moveq	#78-1,d6
;.inline			move.b	(a0)+,(a4)+
;			move.b	(a1)+,(a5)+
;			dbf	d6,.inline
;			lea	78(a0),a0
;			lea	78(a1),a1
;			addq.l	#2,a4
;			addq.l	#2,a5
;			dbf	d7,.showpic
;
;.n			btst	#6,$bfe001
;			bne.b	.n
;
;			move.l	.bufadr(pc),a0
;			move.l	a0,a4
;			move.l	#(225*80)/4,d7
;.restore		move.l	(a0)+,(a2)+
;			move.l	(a0)+,(a3)+
;			subq.l	#1,d7
;			bne.b	.restore
;
;			move.l	#(225*80)/4,d7
;.clrpats		clr.l	(a4)+
;			subq.l	#1,d7
;			bne.b	.clrpats
;
;			move.l	exec,a6
;			move.l	.bufadr(pc),a1
;			jsr	exec_freevec(a6)
;
;.nomem
;			movem.l	(sp)+,d0-a6
;			move.b	#1,itt_adpd_flag(a5)

			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage
			else

			lea	msg_betatester,a2
			jmp	displaymessage
			endif
.bufadr			dc.l	0
;------------------------------------------------------------------------
FUTUREAON:
			lea	msg_cracks,a2
			jmp	displaymessage

;------------------------------------------------------------------------
FXPAGE			clr.b	itt_adpd_flag(a5)

;	jsr	adpd_realadjust

			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	effects_str,a1
			jsr	patcheasyreqARGS

			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	effects2_str,a1
			jsr	patcheasyreqARGS

			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	effects3_str,a1
			jsr	patcheasyreqARGS

			move.b	#1,itt_adpd_flag(a5)
			rts
.idcmpflags		dc.l	rawkey
;------------------------------------------------------------------------
FREQPAGE		clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	freqs_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)
			rts
.idcmpflags		dc.l	rawkey
;------------------------------------------------------------------------
CLR.NEW
			tst	songchanged(a5)
			beq.b	.loadit
		
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	window1ptr(a5),a0	; ausgeben
			lea	vload_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.loadit
			rts
.loadit

			clr	songchanged(a5)

; Requester öffnen und auf Eingabe warten...........................
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			lea	clrwhat_str,a1
			jsr	patchEasyReqArgs
			move.b	#1,itt_adpd_flag(a5)

			tst.b	d0
			beq.b	clrn_cancel
			cmp.b	#1,d0
			beq.w	clrn_ALL
			cmp.b	#2,d0
			beq.w	clrn_SONG
			cmp.b	#3,d0
			beq.w	clrn_inswave
			cmp.b	#4,d0
			beq.w	clrn_instruments
			cmp.b	#5,d0
			beq.w	clrn_waveforms
clrn_cancel		rts
clrn_suc
			clr	aon_data+aon_patcnt
			clr.b	aon_data+aon_pos
			clr	acteditinstr(a5)
			clr	acteditpattern(a5)
			clr.b	replaystatus(a5)
			clr.b	patteditstatus(a5)

			jsr	refresh_pos
			jsr	refresh_pat
			jsr	refresh_max
			jsr	refresh_res
			jsr	refresh_instrument
			jsr	refreshgadgets

			move	#$0f06,aon_fxcom+aon_channels+3*aon_chdatasize

			tst.b	chmode(a5)
			beq.b	.4ch
			move.b	#%11111111,ch_enable(a5)
			bra.b	.8ch
.4ch			move.b	#%1111,ch_enable(a5)
.8ch			move.b	#$f,pattdspreq(a5)
			jmp	aon_end
;------------------------------------------------
clrn_all		move.l	#rem_filename,d1
			move.l	dosbase(A5),a6
			jsr	dos_delete(a6)
			jsr	init_module
			bra.b	clrn_suc
;------------------------------------------------
clrn_song		move.l	#rem_filename,d1
			move.l	dosbase(A5),a6
			jsr	dos_delete(a6)
			jsr	init_song
			bra.w	clrn_suc
;------------------------------------------------
clrn_inswave		bsr	clrn_instruments
;------------------------------------------------
clrn_waveforms		jsr	freewaves
			bra.w	clrn_suc
;------------------------------------------------
clrn_instruments	jsr	init_instruments
			bra	clrn_suc
;------------------------------------------------------------------------
PlayStep
			clr.b	patteditstatus(a5)
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd
			lea	(a0,d0.l),a0
			move.l	a5,-(sp)
			lea	aon_channels,a4
			lea	aon_multab120,a5	; needed for periodtab
			lea	aon_data,a6
			jsr	aon_getdachannel

			tst.b	chmode(a5)
			beq.b	.4chadd
			moveq	#7-1,d7
			bra.b	.8chdbf
.4chdbf			moveq	#3-1,d7
.8chdbf
			addq.l	#4,a0
			lea	aon_chdatasize(a4),a4
			jsr	aon_getdachannel
			dbf	d7,.8chdbf
			move.l	(sp)+,a5

			tst.b	replaystatus(a5)
			bne.b	.notadd
			addq.b	#4,aon_patcnt+1+aon_data
.notadd			rts
;------------------------------------------------------------------------
MarkBlock		tst.b	markingblock(a5)
			bne.b	mb_endmark
			move.b	#1,markingblock(a5)
			bsr	getchanneloff
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			move.b	d0,blockstart(a5)
			move.l	iobuffer,d0
			move.b	d0,blockstart+1(a5)
			move	blockstart(a5),blockend(a5)
			lea	txt_blockstart,a3
			bsr	updatemarkblock
			lea	txt_blockend,a3
			bra	updatemarkblock
mb_endmark		clr.l	blockstart(a5)
			clr.b	markingblock(a5)
			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			move.l	#window1title,$20(a0)
			move.l	$3e(a0),d7	; gadgets sollen nicht mit
			clr.l	$3e(a0)		; refresht werden
			move.l	a0,d6
			jsr	int_refreshwindowframe(a6)
			move.l	d6,a0
			move.l	d7,$3e(a0)	; zeiger auf 1st gadget zurück
			rts
;------------------------------------------------------------------------
ActMarkPos		tst.b	markingblock(a5)
			beq.b	.exit
			movem.l	d0-a6,-(sp)
			bsr	getchanneloff
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			move.l	iobuffer,d1
			moveq	#0,d2
			move.b	blockstart(a5),d2
			cmp	d2,d0
			blt.b	.exitsp
			moveq	#0,d2
			move.b	blockstart+1(a5),d2
			cmp	d2,d1
			blt.b	.exitsp
			move.b	d0,blockend(a5)
			move.b	d1,blockend+1(a5)
			lea	txt_blockend,a3
			bsr	updatemarkblock
.exitsp			movem.l	(sp)+,d0-a6
.exit			rts
;--------------------------------------------------------------------
; in:	a3=Ptr auf string für blockposition ('st:c')
updatemarkblock		move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			move.l	#txt_markblock,$20(a0)
			lea	txt_2charsnrs,a2
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			move	(a2,d0),(a3)
			bsr	getchanneloff
			move.l	iobuffer,d0
			lsr.b	#2,d0
			add.b	#"0",d0
			move.b	d0,3(a3)
			move.l	$3e(a0),d7	; gadgets sollen nicht mit
			clr.l	$3e(a0)		; refresht werden
			move.l	a0,d6
			jsr	int_refreshwindowframe(a6)
			move.l	d6,a0
			move.l	d7,$3e(a0)	; zeiger auf 1st gadget zurück
			rts
;------------------------------------------------------------------------
CopyBlock2buf		move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff

			moveq	#0,d0
			move.b	blockstart(a5),d0	; Y-pos
			add	d0,d0
			add	d0,d0
			lea	(a0,d0),a0
			moveq	#0,d1
			move.b	blockstart+1(a5),d1	; x-pos start
			lea	(a0,d1),a0
			moveq	#0,d6
			move.b	blockend+1(a5),d6	; x-pos end
			sub.b	d1,d6		; d6=Anzahl Kanäle -1
			tst.b	chmode(a5)
			beq.b	.4chmod
			moveq	#32-4,d5
			bra.b	.8chmod
.4chmod			moveq	#16-4,d5
.8chmod			sub.b	d6,d5			; modulo

			moveq	#0,d7
			move.b	blockend(a5),d7
			sub.b	blockstart(a5),d7
			lsr.b	#2,d7
			lea	blockbuf,a1
			move.b	d6,-2(a1)		; anzahl kanäle (-1)
			move.b	d7,-1(a1)		; Höhe des blocks (-1)

			move.l	a1,a2
			moveq	#64-1,d0
.clrblockbuf		rept	8
			clr.l	(a2)+
			endr
			dbf	d0,.clrblockbuf
.copyblock		move	d6,d0		; anzahl kanäle -1
.innerloop		move.l	(a0)+,(a1)+
			dbf	d0,.innerloop
			lea	(a0,d5),a0
			lea	(a1,d5),a1
			dbf	d7,.copyblock
.exit			bra	mb_endmark
;------------------------------------------------------------------------
MoveBlock2buf		move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff

			moveq	#0,d0
			move.b	blockstart(a5),d0	; Y-pos
			add	d0,d0
			add	d0,d0
			lea	(a0,d0),a0
			moveq	#0,d1
			move.b	blockstart+1(a5),d1	; x-pos start
			lea	(a0,d1),a0
			moveq	#0,d6
			move.b	blockend+1(a5),d6	; x-pos end
			sub.b	d1,d6		; d6=Anzahl Kanäle -1
			tst.b	chmode(a5)
			beq.b	.4chmod
			moveq	#32-4,d5
			bra.b	.8chmod
.4chmod			moveq	#16-4,d5
.8chmod			sub.b	d6,d5			; modulo

			moveq	#0,d7
			move.b	blockend(a5),d7
			sub.b	blockstart(a5),d7
			lsr.b	#2,d7

			lea	blockbuf,a1
			move.b	d6,-2(a1)		; anzahl kanäle (-1)
			move.b	d7,-1(a1)		; Höhe des blocks (-1)

			move.l	a1,a2
			moveq	#64-1,d0
.clrblockbuf		rept	8
			clr.l	(a2)+
			endr
			dbf	d0,.clrblockbuf
.copyblock		move	d6,d0		; anzahl kanäle -1
.innerloop		move.l	(a0)+,(a1)+
			clr.l	-4(a0)
			dbf	d0,.innerloop
			lea	(a0,d5),a0
			lea	(a1,d5),a1
			dbf	d7,.copyblock
			move.b	#$f,pattdspreq(a5)
.exit			bra	mb_endmark

;------------------------------------------------------------------------
CopyBuf2Block		move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff

			moveq	#0,d0
			move.b	aon_patcnt+aon_data+1,d0
			tst.b	chmode(a5)
			beq.b	.4chadd
			lsl	#3,d0
			bra.b	.8chadd
.4chadd			add	d0,d0
			add	d0,d0
.8chadd
			lea	(a0,d0),a1
			add.l	iobuffer,a1	; +choffset

			moveq	#0,d6
			move.b	blockbuf-2,d4
			move	d4,d6		; anzahl tracks (blockbreite)
			lsr.b	#2,d6
			tst.b	chmode(a5)
			beq.b	.4chmod
			moveq	#32-4,d5
			bra.b	.8chmod
.4chmod			moveq	#16-4,d5
.8chmod			sub.b	d4,d5
			moveq	#0,d7
			move.b	blockbuf-1,d7	; Anzahl steps (blocklänge)


;			moveq	#0,d0
;			move.b	d7,d0		; 0-63
;			move.b	aon_patcnt+aon_data+1,d0
;			lsr.b	#2,d0		; 0-63
;			add	d7,d0
;;	subq	#1,d0
;			cmp	#63,d0
;			blt.b	.ok1
;			sub.b	#63,d0
;			move.b	d0,d7
;.ok1

			
			tst.b	chmode(a5)
			bne.w	copyblock2buf_8ch


			movem.l	d0-a6,-(sp)
; TrACK(s) richtig zurechtrücken
			move	d7,d3
			moveq	#0,d2
.movedown		move	d6,d4		; anzahl kanäle (-1)
.mdch			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			move.l	a0,d1
			add.l	#1024,d1
			moveq	#0,d0
			move.l	iobuffer,d0
			add.l	d2,d0
			lea	(a0,d0),a0
			lea	1008(a0),a0	; end of pattern
			moveq	#64-1,d7
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			lsr	#2,d0
			sub	d0,d7
			bne.b	.notlast
			clr.l	(a0)
			bra.b	.exit2
.notlast		move.l	a0,d0
			cmp.l	d1,d0
			bge.b	.skip
			move.l	-16(a0),(a0)
.skip			lea	-16(a0),a0
			dbf	d7,.notlast
			addq	#4,d2
			dbf	d4,.mdch
			add	d5,d2
			dbf	d3,.movedown
.exit2			movem.l	(sp)+,d0-a6


; d7=blocklen (0-63)
			moveq	#0,d0
			moveq	#63,d1
			move.b	aon_patcnt+1+aon_data,d0	, z.b 60*4
			lsr.b	#2,d0		; =60
			sub	d0,d1		; z.b.3		z.bd7=6
			move	d1,d3
			sub	d7,d1		; z.b -4
			bpl.b	.okcopy
			move	d3,d7		
.okcopy


			lea	blockbuf,a0
.copyblock		move	d6,d0		; anzahl kanäle -1
.innerloop		move.l	(a0)+,(a1)+
			dbf	d0,.innerloop
			lea	(a0,d5),a0
			lea	(a1,d5),a1
			dbf	d7,.copyblock
			move.b	#$f,pattdspreq(a5)
			move.b	blockbuf-1,d0
			addq.b	#1,d0
			add.b	d0,d0
			add.b	d0,d0
			add.b	d0,aon_patcnt+1+aon_data
.exit			bra	mb_endmark


copyblock2buf_8ch

			movem.l	d0-a6,-(sp)
; TrACK(s) richtig zurechtrücken
			move	d7,d3
			moveq	#0,d2
.movedown		move	d6,d4		; anzahl kanäle (-1)
.mdch			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			move.l	a0,d1
			add.l	#2048,d1
			moveq	#0,d0
			move.l	iobuffer,d0
			add.l	d2,d0
			lea	(a0,d0),a0
			lea	2048-32(a0),a0	; end of pattern
			moveq	#64-1,d7
			moveq	#0,d0
			move.b	aon_patcnt+1+aon_data,d0
			lsr	#2,d0
			sub	d0,d7
			bne.b	.notlast
			clr.l	(a0)
			bra.b	.exit2
.notlast		move.l	a0,d0
			cmp.l	d1,d0
			bge.b	.skip
			move.l	-32(a0),(a0)
.skip			lea	-32(a0),a0
			dbf	d7,.notlast
			addq	#4,d2
			dbf	d4,.mdch
			add	d5,d2
			dbf	d3,.movedown
.exit2			movem.l	(sp)+,d0-a6


; d7=blocklen (0-63)
			moveq	#0,d0
			moveq	#63,d1
			move.b	aon_patcnt+1+aon_data,d0	, z.b 60*4
			lsr.b	#2,d0		; =60
			sub	d0,d1		; z.b.3		z.bd7=6
			move	d1,d3
			sub	d7,d1		; z.b -4
			bpl.b	.okcopy
			move	d3,d7		
.okcopy


			lea	blockbuf,a0
.copyblock		move	d6,d0		; anzahl kanäle -1
.innerloop		move.l	(a0)+,(a1)+
			dbf	d0,.innerloop
			lea	(a0,d5),a0
			lea	(a1,d5),a1
			dbf	d7,.copyblock
			move.b	#$f,pattdspreq(a5)
			move.b	blockbuf-1,d0
			addq.b	#1,d0
			add.b	d0,d0
			add.b	d0,d0
			add.b	d0,aon_patcnt+1+aon_data
.exit			bra	mb_endmark


;------------------------------------------------------------------------
LoadPrefs:		move.b	#1,win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			move.l	rt_dirname(a1),a2
			clr.b	(a2)
			lea	var_filename,a2
			lea	var_prf_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			clr.b	win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled		move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename
			move.l	#iofilename,d1
			bsr	readprefs
			bsr	initprefs

			bsr	setcolors

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_refreshwindowframe(a6)
			jsr	refresh_setupWavedrawmode
			jsr	refresh_setupFiltermode
			jmp	refresh_setupBlankertimeout
;------------------------------------------------------------------------
; in:	d1=Filename
readprefsDEF:		move.l	d1,-(sp)
			move.l	dosbase(a5),a6
			jsr	dos_getprogramdir(a6)
			move.l	d0,d1
			jsr	dos_currentdir(a6)
			move.l	(sp)+,d1
; in:	d1=Pfad+Filename
readprefs:
			move.l	dosbase(a5),a6
			move.l	#1005,d2
			jsr	dos_open(a6)
			clr.b	defpref(a5)
			tst.l	d0
			bne.b	.found
			move.b	#1,defpref(a5)
			bra.b	readprf_defaultprefs
.found
			move.l	d0,filehandle(a5)
			move.l	d0,d1
			move.l	#prf_data,d2
			move.l	#prf_datasize,d3
			jsr	dos_read(a6)
			tst.l	d0
			bmi.s	readprf_closeanddefaultprefs
			cmp.l	#"AONP",prf_data
			beq.b	.ok1
			lea	msg_prf_noconfigfile,a2
			jsr	displaymessage
			bra.b	readprf_closeanddefaultprefs
.ok1			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			bra.b	prefs_initalize
readprf_closeanddefaultprefs
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
readprf_defaultprefs
			lea	prf_default,a0
			lea	prf_data,a1
			move	#prf_datasize-1,d7
readprf_copydef		move.b	(a0)+,(a1)+
			dbf	d7,readprf_copydef

prefs_initalize		lea	prf_data,a0
			rts
;--------------------------------------------------------------------
INITprefs:
			tst.b	prf_data+prf_filtermode
			beq.s	readprf_filteroff
			bclr	#1,$bfe001
			bra.b	readprf_filteron
readprf_filteroff	bset	#1,$bfe001
readprf_filteron
			jsr	showfilterstatus
			bsr	setcolors
			move.b	prf_data+prf_oversize,aon_data+aon_oversize
			rts
;--------------------------------------------------------------------
CheckOut_midiinput:	lea	ser_capture,a0
			moveq	#0,d0
			move	ser_captureoff+2(a5),d0
			lea	(a0,d0.l),a0
			cmp.b	#$fe,-2(a0)
			beq.b	.activesensing
			tst.b	-2(a0)
			beq.b	.activesensing
			moveq	#0,d0
			move.b	-2(a0),d0
			clr.b	-2(a0)
			tst.b	-1(a0)
			beq.b	.activesensing
			clr.b	-1(a0)
			sub.b	#48,d0
			bmi.b	.activesensing
			addq.b	#1,d0
			cmp.b	#36,d0
			bhi.b	.activesensing
			lea	ne_playstep,a0
			move.b	d0,(a0)
			move.b	acteditinstr+1(a5),1(a0)
			addq.b	#1,1(a0)
			bsr	getchanneloff
			tst.b	d1
			bne.b	.activesensing
			bsr	nowplaystep
.activesensing		rts

;--------------------------------------------------------------------
togglemidiinputstatus:
			bchg	#0,midieditstatus(a5)
			lea	midi_inputst.txt,a0
			tst.b	midieditstatus(a5)
			beq.b	.off
			move.b	#" ",(a0)
			move.b	#"O",1(a0)
			move.b	#"n",2(a0)
			rts
.off			move.b	#"O",(a0)
			move.b	#"f",1(a0)
			move.b	#"f",2(a0)
			rts
;--------------------------------------------------------------------
PosListChanged:		move	#gad_changepos,lastdownID(a5)
			moveq	#0,d0
			move.b	$19(a0),d0
			bra	spc_routentry
PosListChangeNOW:
			moveq	#0,d0
			move.b	$19(a0),d0
			bsr	spc_routentry
			bra	mmm
PosListSETGADGET:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	mp_gadgetptrs+gad_changepos*4,a0
			move.l	window1ptr(a5),a1
			lea	.tags(pc),a3
			move.b	aon_data+aon_pos,7(a3)
			move.l	aon_data+aon_statdata,a2
			move.b	aon.songinfo_maxpos(a2),7+8(a3)
			addq	#1,6+8(a3)
			sub.l	a2,a2
			jsr	gadtools_gt_setgadgetattrsa(a6)
			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	gtsc_total,0
			dc.l	tag_done
PrintPoslist
			tst.b	itt_adpd_flag(a5)
			beq.b	.ex
			cmp.b	#pattedit,programmode(a5)
			beq.b	.ok
.ex			rts
.ok
			move.l	bitplane1_startadr(a5),a0
			lea	26*80+62(a0),a0
			moveq	#9*8-1,d7
.clrit			clr.l	(a0)
			clr.l	4(a0)
			clr.l	8(a0)
			clr	12(a0)
			lea	80(a0),a0
			dbf	d7,.clrit

			lea	txt_3charsnrs,a4
			moveq	#0,d0
			move.b	aon_data+aon_pos,d0
			move.l	aon_data+aon_posdata,a6
			move.l	d0,d6
			subq	#4,d6

			add	d0,d0
			add	d0,d0
			lea	-4*4(a4,d0),a1
			lea	txt_3chars,a0
			moveq	#0,d3
			moveq	#9-1,d7

			move	d7,-(sp)

			moveq	#0,d2
			move	d6,d4
			move.b	aon_data+aon_pos,d2
			cmp	#256,d2
			bls.b	.loop1
			move	#255,d7
			sub	d2,d7
			move	d7,(sp)
.loop1
			cmp	#-4,d4
			blt.b	.next1
			cmp	#255,d4
			bgt.b	.next1
			moveq	#0,d2
			move.l	(a1)+,(a0)
			move.b	#1,3(a0)
			jsr	printposscreen
.next1			add	#8*80,d3
			addq	#1,d4
			dbf	d7,.loop1
			

			moveq	#0,d3
			move	(sp)+,d7
.loop2			moveq	#8,d2
			moveq	#0,d0
			cmp	#255,d6
			bhi.b	.next
			move.b	(a6,d6),d0
			add	d0,d0
			add	d0,d0
			move.l	(a4,d0),(a0)
			move.b	#1,3(a0)
			jsr	printposscreen
.next			add	#8*80,d3
			addq	#1,d6
			dbf	d7,.loop2
			rts
; -----------------------------------------------------------------------
NoteUp:			moveq	#1,d6
			bra.b	transpose
NoteDown:		moveq	#-1,d6
			bra.b	transpose
OctaveUp:		moveq	#12,d6
			bra.b	transpose
OctaveDown:		moveq	#-12,d6
;	bra.b	transposetrack

; in:	d6=NoteTranspose
Transpose:		move.b	areamode(a5),d0
			beq.b	transposeBlock
			cmp.b	#1,d0
			beq.w	transposeTrack
TransPosePattern:
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			tst.b	chmode(a5)
			beq.b	.4ch
			move	#64*8-1,d7
			bra.b	.loop
.4ch			move	#64*4-1,d7
.loop			move.b	(a0),d0
			move.b	d0,d1
			and.b	#$3f,d0
			beq.b	.notoverb3
			add.b	d6,d0
			cmp.b	#36+24,d0
			bls.b	.notoverb3
			clr.b	d0
.notoverb3		and.b	#$c0,d1
			or.b	d1,d0
			move.b	d0,(a0)
			addq.l	#4,a0
			dbf	d7,.loop
			move.b	#$f,pattdspreq(a5)
			rts
TransposeBlock:
			tst.b	markingblock(a5)
			beq.b	.exit
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	blockstart(a5),d0
			tst.b	chmode(a5)
			beq.b	.4ch
			add	d0,d0
.4ch			add	d0,d0
			add	d0,d0
			lea	(a0,d0),a0
			moveq	#0,d0
			move.b	blockstart+1(a5),d0
			lea	(a0,d0),a0
			moveq	#0,d7
			move.b	blockend(a5),d7
			sub.b	blockstart(a5),d7
			lsr.b	#2,d7

			moveq	#0,d4
			tst.b	chmode(a5)
			beq.b	.4chmod
			moveq	#32-4,d5
			bra.b	.8chmod
.4chmod			moveq	#12,d5
.8chmod			move.b	blockend+1(a5),d4
			sub.b	blockstart+1(a5),d4
			sub.b	d4,d5
			lsr.b	#2,d4
; a0=Zeiger auf Pattern
; d4=Anzahl der Spalten (->3)
; d5=Spaltenmodulo
; d6=Transpose-Wert
; d7=Anzahl zeilen
.loop2			move	d4,d3
.loop1			move.b	(a0),d0
			move.b	d0,d1
			and.b	#$3f,d0
			beq.b	.notoverb3
			add.b	d6,d0
.notoverb3		and.b	#$c0,d1
			or.b	d1,d0
			move.b	d0,(a0)
			addq.l	#4,a0
			dbf	d3,.loop1
			lea	(a0,d5),a0
			dbf	d7,.loop2
			move.b	#$f,pattdspreq(a5)
.exit			rts


TransposeTrack:
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			moveq	#64-1,d7
.loop			move.b	(a0),d0
			move.b	d0,d1
			and.b	#$3f,d0
			beq.b	.notoverb3
			add.b	d6,d0
			cmp.b	#36+24,d0
			bls.b	.notoverb3
			clr.b	d0
.notoverb3		and.b	#$c0,d1
			or.b	d1,d0
			move.b	d0,(a0)
			tst.b	chmode(a5)
			beq.b	.4ch
			lea	16(a0),a0
.4ch			lea	16(a0),a0
			dbf	d7,.loop
			move.b	#$f,pattdspreq(a5)
			rts
; -----------------------------------------------------------------------
AreaMode_Block:		clr.b	areamode(a5)
			lea	areamodeasc,a0
			move.b	#"B",(a0)
			move.b	#"l",1(a0)
			move.b	#"o",2(a0)
			move.b	#"c",3(a0)
			move.b	#"k",4(a0)
			clr.b	5(a0)
			rts
; -----------------------------------------------------------------------
AreaMode_Track:		move.b	#1,areamode(a5)
			lea	areamodeasc,a0
			move.b	#"T",(a0)
			move.b	#"r",1(a0)
			move.b	#"a",2(a0)
			move.b	#"c",3(a0)
			move.b	#"k",4(a0)
			clr.b	5(a0)
			rts
; -----------------------------------------------------------------------
AreaMode_Pattern:	move.b	#2,areamode(a5)
			lea	areamodeasc,a0
			move.b	#"P",(a0)
			move.b	#"a",1(a0)
			move.b	#"t",2(a0)
			move.b	#"t",3(a0)
			move.b	#"e",4(a0)
			move.b	#"r",5(a0)
			move.b	#"n",6(a0)
			clr.b	7(a0)
			rts
; -----------------------------------------------------------------------
CutArea:		tst.b	areamode(a5)
			beq	moveblock2buf
			cmp.b	#1,areamode(a5)
			beq	cuttrack2buf
			bra	cutpattern2buf
CopyArea:		tst.b	areamode(a5)
			beq	copyblock2buf
			cmp.b	#1,areamode(a5)
			beq	copytrack2buf
			bra	copypattern2buf
PasteArea:		tst.b	areamode(a5)
			beq	copybuf2block
			cmp.b	#1,areamode(a5)
			beq	copybuf2track
			bra	copybuf2pattern
; -----------------------------------------------------------------------
ChangeVolume:
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			lea	.tags(pc),a0
			move.l	window1ptr(a5),4(a0)
			lea	iobuffer,a1
			move.l	#100,(a1)
			lea	.percent(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok			move	#256,d6
			mulu	iobuffer+2,d6
			beq.b	.not0
			divu	#100,d6
.not0			tst.b	areamode(a5)
			beq.b	cv_block
			cmp.b	#1,areamode(a5)
			beq	cv_track
			bra	cv_pattern
.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,200
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.percent		dc.b	"Enter volume (in %)",0
			even
; /* Block-Volume ändern */
CV_block:
			tst.b	markingblock(a5)
			beq.w	.exit
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	blockstart(a5),d0
			add	d0,d0
			add	d0,d0
			lea	(a0,d0),a0
			moveq	#0,d0
			move.b	blockstart+1(a5),d0
			lea	(a0,d0),a0
			moveq	#0,d7
			move.b	blockend(a5),d7
			sub.b	blockstart(a5),d7
			lsr.b	#2,d7

			moveq	#0,d4
			tst.b	chmode(a5)
			beq.b	.4chmod
			moveq	#32-4,d5
			bra.b	.8chmod
.4chmod			moveq	#12,d5
.8chmod			move.b	blockend+1(a5),d4
			sub.b	blockstart+1(a5),d4
			sub.b	d4,d5
			lsr.b	#2,d4
; a0=Zeiger auf Pattern
; d4=Anzahl der Spalten (->3)
; d5=Spaltenmodulo
; d6=Volume-Wert(% 0-255)
; d7=Anzahl zeilen
.loop2			move	d4,d3
.loop1			move.b	2(a0),d0
			and.b	#$3f,d0
			beq.b	.noCcom
			cmp.b	#$c,d0
			bne.b	.noCcom
			moveq	#0,d0
			move.b	3(a0),d0
			mulu	d6,d0
			lsr	#8,d0

			cmp	#$40,d0
			bls.b	.volok
			moveq	#$40,d0
.volok			move.b	d0,3(a0)
.noCcom			addq.l	#4,a0
			dbf	d3,.loop1
			lea	(a0,d5),a0
			dbf	d7,.loop2
			move.b	#$f,pattdspreq(a5)
.exit			rts
; /* Track-VOlume ändern */
CV_track:
			bsr	getchanneloff
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			add.l	iobuffer,a0
			moveq	#64-1,d7
.loop			move.b	2(a0),d0
			and.b	#$3f,d0
			beq.b	.noCcom
			cmp.b	#$c,d0
			bne.b	.noCcom
			moveq	#0,d0
			move.b	3(a0),d0
			mulu	d6,d0
			lsr	#8,d0
			cmp	#$40,d0
			bls.b	.volok
			moveq	#$40,d0
.volok			move.b	d0,3(a0)
.noCcom			tst.b	chmode(a5)
			beq.b	.4chmod
			lea	16(a0),a0
.4chmod			lea	16(a0),a0
			dbf	d7,.loop
			move.b	#$f,pattdspreq(a5)
			rts

; /* Pattern-VOlume ändern */
CV_pattern:
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			tst.b	chmode(a5)
			beq.b	.4ch
			move	#64*8-1,d7
			bra.b	.loop
.4ch			move	#64*4-1,d7
.loop			move.b	2(a0),d0
			and.b	#$3f,d0
			beq.b	.noCcom
			cmp.b	#$c,d0
			bne.b	.noCcom
			moveq	#0,d0
			move.b	3(a0),d0
			mulu	d6,d0
			lsr	#8,d0
			cmp	#$40,d0
			bls.b	.volok
			moveq	#$40,d0
.volok			move.b	d0,3(a0)
.noCcom			addq.l	#4,a0
			dbf	d7,.loop
			move.b	#$f,pattdspreq(a5)
			rts
;--------------------------------------------------------------------
togglefilter:		bchg	#1,$bfe001
showfilterstatus:
			move.l	a0,-(sp)
			lea	filteronoff_txt,a0
			btst	#1,$bfe001
			bne.b	.off
			move.b	#" ",(a0)
			ifeq	lang
			move.b	#"O",1(a0)
			move.b	#"n",2(a0)
			else
			move.b	#"A",1(a0)
			move.b	#"n",2(a0)
			endif
			move.l	(sp)+,a0
			rts
.off
			ifeq	lang
			move.b	#"O",(a0)
			move.b	#"f",1(a0)
			move.b	#"f",2(a0)
			else
			move.b	#"A",(a0)
			move.b	#"u",1(a0)
			move.b	#"s",2(a0)
			endif
			move.l	(sp)+,a0
			rts

DRAWHILITEPATTERN:
; ĞğĞğ HiLite-Zeile für Patterns zeichnen ĞğĞğ

			move.l	bitplane2_startadr(a5),a0
			cmp	#400,win1h
			beq.b	.euro
			lea	(patbploff+63)*80(a0),a0
			bra.b	.pal
.euro			lea	(patbploff+127)*80(a0),a0
.pal			move.l	a0,bitplane2_barstartadr(a5)
			moveq	#-1,d0
			addq.l	#1,a0
			cmp	#400,win1h
			beq	.euro2
			moveq	#8-1,d7
.drawbar		REPT	78
			move.b	d0,(a0)+
			ENDR
			addq.l	#2,a0
			dbf	d7,.drawbar
			bra.b	.pal2
.euro2			moveq	#16-1,d7
			bra	.drawbar
.pal2

adpd_bardrawn

; Hi-Lite Zeile für Pos-List zeichnen
drawposhilite:		move.l	bitplane2_startadr(a5),a0
			lea	57*80+60(a0),a0
			moveq	#-1,d0
			move.l	#$03ffffff,d1
			move.b	#$fc,d2
			moveq	#9-1,d7
.drawit			move.l	d1,(a0)
			move.l	d0,4(a0)
			move.l	d0,8(a0)
			move.l	d0,12(a0)
			move.b	d2,16(a0)
			lea	80(a0),a0
			dbf	d7,.drawit

			move.l	bitplane2_startadr(a5),a0
			lea	122*80+4(a0),a0
			move.l	a0,a1
			moveq	#8-1,d7
.clrit			rept	74
			clr.b	(a1)+
			endr
			addq.l	#6,a1
			dbf	d7,.clrit

			tst.b	chmode(a5)
			beq.b	.4ch

			moveq	#8-1,d7
			lea	number1(pc),a1
.lop8			move.b	(a1)+,0*80(a0)
			move.b	(a1)+,1*80(a0)
			move.b	(a1)+,2*80(a0)
			move.b	(a1)+,3*80(a0)
			move.b	(a1)+,4*80(a0)
			move.b	(a1)+,5*80(a0)
			move.b	(a1)+,6*80(a0)
			move.b	(a1)+,7*80(a0)
			lea	9(a0),a0
			dbf	d7,.lop8
			rts

.4ch
			addq.l	#2,a0
			moveq	#4-1,d7
			lea	number1(pc),a1
.lop4			move.b	(a1)+,0*80(a0)
			move.b	(a1)+,1*80(a0)
			move.b	(a1)+,2*80(a0)
			move.b	(a1)+,3*80(a0)
			move.b	(a1)+,4*80(a0)
			move.b	(a1)+,5*80(a0)
			move.b	(a1)+,6*80(a0)
			move.b	(a1)+,7*80(a0)
			lea	18(a0),a0
			dbf	d7,.lop4
			rts

number1
			dc.b	%00000000
			dc.b	%00011000
			dc.b	%01111000
			dc.b	%00011000
			dc.b	%00011000
			dc.b	%00011000
			dc.b	%00011000
			dc.b	%01111110
number2
			dc.b	%00000000
			dc.b	%01111100
			dc.b	%00000110
			dc.b	%01111100
			dc.b	%11000000
			dc.b	%11000000
			dc.b	%11000110
			dc.b	%11111110
number3
			dc.b	%00000000
			dc.b	%01111100
			dc.b	%00000110
			dc.b	%00011100
			dc.b	%00000110
			dc.b	%00000110
			dc.b	%00000110
			dc.b	%11111100
number4
			dc.b	%00000000
			dc.b	%11000110
			dc.b	%11000110
			dc.b	%01111110
			dc.b	%00000110
			dc.b	%00000110
			dc.b	%00000110
			dc.b	%00000110
number5
			dc.b	%00000000
			dc.b	%11111110
			dc.b	%11000000
			dc.b	%11111100
			dc.b	%00000110
			dc.b	%00000110
			dc.b	%11000110
			dc.b	%01111100
number6
			dc.b	%00000000
			dc.b	%01111100
			dc.b	%11000000
			dc.b	%11111100
			dc.b	%11000110
			dc.b	%11000110
			dc.b	%11000110
			dc.b	%01111100
number7
			dc.b	%00000000
			dc.b	%11111110
			dc.b	%00000110
			dc.b	%00001100
			dc.b	%00011000
			dc.b	%00011000
			dc.b	%00011000
			dc.b	%00011000
number8
			dc.b	%00000000
			dc.b	%01111100
			dc.b	%11000110
			dc.b	%01111100
			dc.b	%11000110
			dc.b	%11000110
			dc.b	%11000110
			dc.b	%01111100



CLRFUNCDISPLAYALL:	move.l	bitplane1_startadr(a5),d0
			add.l	#(patbploff-1)*80,d0
			move.l	d0,a0
			move	#(137*80)-1,d7
.clrbpl1		clr.b	(a0)+
			dbf	d7,.clrbpl1
			move.l	bitplane2_startadr(a5),d0
			add.l	#(patbploff-1)*80,d0
			move.l	d0,a0
			move	#(137*80)-1,d7
.clrbpl2		clr.b	(a0)+
			dbf	d7,.clrbpl2
			rts
;--------------------------------------------------------------------
ChangePalette		clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			move.l	rtbase(a5),a6
			lea	.tags(pc),a0
			move.l	window1ptr(a5),4(a0)
			move.l	screenptr(a5),12(a0)
			lea	.title(pc),a2
			move.l	palettereqptr(a5),a3
			jsr	rtpaletterequestA(a6)

			move.b	#1,itt_adpd_flag(a5)
			rts
.tags
			dc.l	rt_window,0
			dc.l	rt_screen,0
			dc.l	tag_done
.title			dc.b	"Change Palette...",0
			even
;--------------------------------------------------------------------
JumpToPos0		move.b	prf_data+prf_jump0,aon_patcnt+aon_data+1
			bra	actmarkpos
;--------------------------------------------------------------------
JumpToPos1		move.b	prf_data+prf_jump1,aon_patcnt+aon_data+1
			bra	actmarkpos
;--------------------------------------------------------------------
JumpToPos2		move.b	prf_data+prf_jump2,aon_patcnt+aon_data+1
			bra	actmarkpos
;--------------------------------------------------------------------
JumpToPos3		move.b	prf_data+prf_jump3,aon_patcnt+aon_data+1
			bra	actmarkpos
;--------------------------------------------------------------------
JumpToPos4		move.b	prf_data+prf_jump4,aon_patcnt+aon_data+1
			bra	actmarkpos
;--------------------------------------------------------------------
JumpToPos0andPlay	move.b	prf_data+prf_jump0,aon_patcnt+aon_data+1
			move.b	#replayst_all,replaystatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos1andPlay	move.b	prf_data+prf_jump1,aon_patcnt+aon_data+1
			move.b	#replayst_all,replaystatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos2andPlay	move.b	prf_data+prf_jump2,aon_patcnt+aon_data+1
			move.b	#replayst_all,replaystatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos3andPlay	move.b	prf_data+prf_jump3,aon_patcnt+aon_data+1
			move.b	#replayst_all,replaystatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos4andPlay	move.b	prf_data+prf_jump4,aon_patcnt+aon_data+1
			move.b	#replayst_all,replaystatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos0andRecord	move.b	prf_data+prf_jump0,aon_patcnt+aon_data+1
			move.b	#replayst_pat,replaystatus(a5)
			move.b	#1,patteditstatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos1andRecord	move.b	prf_data+prf_jump1,aon_patcnt+aon_data+1
			move.b	#replayst_pat,replaystatus(a5)
			move.b	#1,patteditstatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos2andRecord	move.b	prf_data+prf_jump2,aon_patcnt+aon_data+1
			move.b	#replayst_pat,replaystatus(a5)
			move.b	#1,patteditstatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos3andRecord	move.b	prf_data+prf_jump3,aon_patcnt+aon_data+1
			move.b	#replayst_pat,replaystatus(a5)
			move.b	#1,patteditstatus(a5)
			rts
;--------------------------------------------------------------------
JumpToPos4andRecord	move.b	prf_data+prf_jump4,aon_patcnt+aon_data+1
			move.b	#replayst_pat,replaystatus(a5)
			move.b	#1,patteditstatus(a5)
			rts
;--------------------------------------------------------------------
SetJumpPos0		move.b	aon_data+aon_patcnt+1,prf_data+prf_jump0
			rts
;--------------------------------------------------------------------
SetJumpPos1		move.b	aon_data+aon_patcnt+1,prf_data+prf_jump1
			rts
;--------------------------------------------------------------------
SetJumpPos2		move.b	aon_data+aon_patcnt+1,prf_data+prf_jump2
			rts
;--------------------------------------------------------------------
SetJumpPos3		move.b	aon_data+aon_patcnt+1,prf_data+prf_jump3
			rts
;--------------------------------------------------------------------
SetJumpPos4		move.b	aon_data+aon_patcnt+1,prf_data+prf_jump4
			rts
;--------------------------------------------------------------------
WildStarReplace:
			tst.b	areamode(a5)
			bne.b	.noblock
			tst.b	markingblock(a5)
			bne.b	.noblock
			lea	msg_patt_markblockfirst,a2
			jmp	displaymessage
.noblock
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			lea	.string(pc),a1
			moveq	#8,d0
			lea	.title(pc),a2
			sub.l	a3,a3
			lea	.tags(pc),a0
			move.l	window2ptr(a5),4(a0)
			move.l	screenptr(a5),12(a0)
			move.l	rtbase(a5),a6
			jsr	rtGetStringA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0
			bne.b	.notcancel1
			rts
.notcancel1			
			clr.l	wildstarMASK(a5)
			clr.l	wildstarMASK2(a5)
			clr.l	wildstarsearchpat(a5)
			clr.l	wildstarreplacepat(a5)

			lea	.string(pc),a0
			move.l	(a0)+,d0
			and.l	#$ffffff00,d0
			cmp.l	#$2d2d2d00,d0
			beq.b	.adash2
			bclr	#29,d0		; aus 'd-3' wird 'D-3'
.adash2
			or.b	#1,d0
			moveq	#0,d1
			lea	txt_notes,a1
			moveq	#38+24-1,d7
.searchGetnote		cmp.l	(a1)+,d0
			beq.b	.found
			addq.b	#1,d1
			dbf	d7,.searchgetnote
			or.b	#%00111111,wildstarmask(a5)
.found			or.b	d1,wildstarsearchpat(a5)

			move.b	-1(a0),d0
			cmp.b	#"*",d0
			bne.b	.searchInstrnr
			or.b	#%00111111,wildstarmask+1(a5)
			bra.b	.searchinstrnrOK
.searchinstrnr		lea	txt_instrnrs,a1
			moveq	#0,d1
			moveq	#63-1,d7
.searchinstrnrloop	cmp.b	(a1)+,d0
			beq.b	.searchinstrnrfound
			addq.b	#1,d1
			dbf	d7,.searchinstrnrloop
			or.b	#%00111111,wildstarmask+1(a5)
.searchinstrnrfound	move.b	d1,wildstarsearchpat+1(a5)
.searchinstrnrOK

			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.searcharpnr
			or.b	#%11000000,wildstarmask+1(a5)
			or.b	#%11000000,wildstarmask+2(a5)
			bra.b	.searcharpok
.searcharpnr		cmp.b	#"a",d0
			blt.b	.searcharpnrnotlc
			bclr	#5,d0
.searcharpnrnotlc
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.searcharpLoop		cmp.b	(a1)+,d0
			beq.b	.searcharpfound
			addq.b	#1,d1
			dbf	d7,.searcharploop
			or.b	#%11000000,wildstarmask+1(a5)
			or.b	#%11000000,wildstarmask+2(a5)
			bra.b	.searcharpok
.searcharpfound		move.b	d1,d0
			lsr.b	#2,d1
			and.b	#3,d0
			ror.b	#2,d0	; 0/1
			ror.b	#2,d1	; 2/3
			or.b	d0,wildstarsearchpat+1(a5)
			or.b	d1,wildstarsearchpat+2(a5)
.searcharpok
			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.searchFxCom
			or.b	#%00111111,wildstarmask+2(a5)
			bra.b	.searchfxcomOK
.searchfxcom		lea	txt_instrnrs,a1
			moveq	#0,d1
			moveq	#63-1,d7
.searchfxcomloop	cmp.b	(a1)+,d0
			beq.b	.searchfxcomfound
			addq.b	#1,d1
			dbf	d7,.searchfxcomloop
			or.b	#%00111111,wildstarmask+2(a5)
			bra.b	.searchfxcomok
.searchfxcomfound	or.b	d1,wildstarsearchpat+2(a5)
.searchfxcomOK

			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.searchFxDat1
			or.b	#%11110000,wildstarmask+3(a5)
			bra.b	.searchfxdat1OK
.searchfxdat1		cmp.b	#97,d0
			blt.b	.searchfxdat1notlC
			bclr	#5,d0
.searchfxdat1notLC
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.searchfxdat1loop	cmp.b	(a1)+,d0
			beq.b	.searchfxdat1found
			addq.b	#1,d1
			dbf	d7,.searchfxdat1loop
			or.b	#%11110000,wildstarmask+3(a5)
			bra.b	.searchfxdat1ok
.searchfxdat1found	lsl.b	#4,d1
			or.b	d1,wildstarsearchpat+3(a5)
.searchfxdat1OK

			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.searchFxDat2
			or.b	#%1111,wildstarmask+3(a5)
			bra.b	.searchfxdat2OK
.searchfxdat2		cmp.b	#97,d0
			blt.b	.searchfxdat2notlC
			bclr	#5,d0
.searchfxdat2notLC
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.searchfxdat2loop	cmp.b	(a1)+,d0
			beq.b	.searchfxdat2found
			addq.b	#1,d1
			dbf	d7,.searchfxdat2loop
			or.b	#%1111,wildstarmask+3(a5)
			bra.b	.searchfxdat2ok
.searchfxdat2found	or.b	d1,wildstarsearchpat+3(a5)
.searchfxdat2OK
; Das gleiche jetzt nochmal für den replace-string

			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			lea	.string(pc),a1
			moveq	#8,d0
			lea	.title2(pc),a2
			sub.l	a3,a3
			lea	.tags(pc),a0
			move.l	window2ptr(a5),4(a0)
			move.l	screenptr(a5),12(a0)
			move.l	rtbase(a5),a6
			jsr	rtGetStringA(a6)
			move.b	#1,itt_adpd_flag(a5)

			tst.l	d0
			bne.b	.notcancel2
			rts
.notcancel2
			lea	.string(pc),a0
			move.l	(a0)+,d0
			and.l	#$ffffff00,d0
			cmp.l	#$2d2d2d00,d0
			beq.b	.adash
			bclr	#29,d0		; aus 'd-3' wird 'D-3'
.adash			or.b	#1,d0
			moveq	#0,d1
			lea	txt_notes,a1
			moveq	#38+24-1,d7
.replaceGetnote		cmp.l	(a1)+,d0
			beq.b	.replacegetnotefound
			addq.b	#1,d1
			dbf	d7,.replacegetnote
			or.b	#%00111111,wildstarmask2(a5)
			moveq	#0,d1
.replacegetnotefound	or.b	d1,wildstarreplacepat(a5)

			move.b	-1(a0),d0
			cmp.b	#"*",d0
			bne.b	.replaceinstrnr
			or.b	#%00111111,wildstarmask2+1(a5)
			bra.b	.replaceinstrnrOK
.replaceinstrnr		lea	txt_instrnrs,a1
			moveq	#0,d1
			moveq	#63-1,d7
.replaceinstrnrloop	cmp.b	(a1)+,d0
			beq.b	.replaceinstrnrfound
			addq.b	#1,d1
			dbf	d7,.replaceinstrnrloop
			or.b	#%00111111,wildstarmask2+1(a5)
			moveq	#0,d1
.replaceinstrnrfound	move.b	d1,wildstarreplacepat+1(a5)
.replaceinstrnrOK

			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.replacearpnr
			or.b	#%11000000,wildstarmask2+1(a5)
			or.b	#%11000000,wildstarmask2+2(a5)
			bra.b	.replacearpok
.replacearpnr		cmp.b	#"a",d0
			blt.b	.replacearpnrNOtLC
			bclr	#5,d0
.replacearpnrNOtLC	lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.replacearpLoop		cmp.b	(a1)+,d0
			beq.b	.replacearpfound
			addq.b	#1,d1
			dbf	d7,.replacearploop
			or.b	#%11000000,wildstarmask2+1(a5)
			or.b	#%11000000,wildstarmask2+2(a5)
			moveq	#0,d1
.replacearpfound	move.b	d1,d0
			lsr.b	#2,d1
			and.b	#3,d0
			ror.b	#2,d0	; 0/1
			ror.b	#2,d1	; 2/3
			or.b	d0,wildstarreplacepat+1(a5)
			or.b	d1,wildstarreplacepat+2(a5)
.replacearpok
			move.b	(a0)+,d0
			cmp.b	#"*",d0
			bne.b	.replaceFxCom
			or.b	#%00111111,wildstarmask2+2(a5)
			bra.b	.replacefxcomOK
.replacefxcom		lea	txt_instrnrs,a1
			moveq	#0,d1
			moveq	#63-1,d7
.replacefxcomloop	cmp.b	(a1)+,d0
			beq.b	.replacefxcomfound
			addq.b	#1,d1
			dbf	d7,.replacefxcomloop
			moveq	#0,d1
.replacefxcomfound	or.b	d1,wildstarreplacepat+2(a5)
.replacefxcomOK

			move.b	(a0)+,d0
.replacefxdat1		cmp.b	#97,d0
			blt.b	.replacefxdat1notlC
			bclr	#5,d0
.replacefxdat1notLC
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.replacefxdat1loop	cmp.b	(a1)+,d0
			beq.b	.replacefxdat1found
			addq.b	#1,d1
			dbf	d7,.replacefxdat1loop
			or.b	#%11110000,wildstarmask2+3(a5)
			bra.b	.replacefxdat1ok
.replacefxdat1found	lsl.b	#4,d1
			or.b	d1,wildstarreplacepat+3(a5)
.replacefxdat1OK

			move.b	(a0)+,d0
.replacefxdat2		cmp.b	#97,d0
			blt.b	.replacefxdat2notlC
			bclr	#5,d0
.replacefxdat2notLC
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#16-1,d7
.replacefxdat2loop	cmp.b	(a1)+,d0
			beq.b	.replacefxdat2found
			addq.b	#1,d1
			dbf	d7,.replacefxdat2loop
			or.b	#%1111,wildstarmask2+3(a5)
			bra.b	.replacefxdat2ok
.replacefxdat2found	or.b	d1,wildstarreplacepat+3(a5)
.replacefxdat2OK

; jetzt kann ich gemütlich die durch Ğwildstarmaskğ angegebenen bits
; austauschen (gesetzt=bleibt gleich)

			tst.b	areamode(a5)
			beq.w	wildstar_block
			cmp.b	#1,areamode(a5)
			beq.w	wildstar_track
			cmp.b	#2,areamode(a5)
			beq.w	wildstar_pattern

			rts
.tags			dc.l	rt_window,0
			dc.l	rt_screen,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,200
			dc.l	rtgl_showdefault,true
			dc.l	tag_done
.string			dc.b	"C-100000",0
.title			dc.b	" nnnIaCpp  Wildstar-Search for what ?",0
.title2			dc.b	" nnnIaCpp  Wildstar-Replace with what ?",0
			even

;------------------------------------------------------------------------
wildstar_block
			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff

			moveq	#0,d0
			move.b	blockstart(a5),d0	; Y-pos
			add	d0,d0
			add	d0,d0
			lea	(a0,d0),a0
			moveq	#0,d1
			move.b	blockstart+1(a5),d1	; x-pos start
			lea	(a0,d1),a0
			moveq	#0,d6
			move.b	blockend+1(a5),d6	; x-pos end
			sub.b	d1,d6		; d6=Anzahl Kanäle -1
			moveq	#12,d5
			sub.b	d6,d5			; modulo

			moveq	#0,d7
			move.b	blockend(a5),d7
			sub.b	blockstart(a5),d7
			lsr.b	#2,d7

			bra.b	wildstarreplaceit
;--------------------------------------------------------------------
wildstar_track
			bsr	getchanneloff
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0
			moveq	#12,d5
			moveq	#1-1,d6
			moveq	#64-1,d7
			bra.b	wildstarreplaceit
;--------------------------------------------------------------------
wildstar_pattern	moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			moveq	#0,d5
			moveq	#4-1,d6
			moveq	#64-1,d7

; a0=Patternadresse
; d5=channeloffset (bei track =12)
; d6=anzahl kanäle-1
; d7=anzahl steps-1
WILDSTARREPLACEIT
			move.l	wildstarmask(a5),d4
.copyblock		move	d6,d0		; anzahl kanäle -1
.innerloop		

; Test, if patstep matches with searchpat

			btst	#31-8,d4
			bne.b	.arpGleich2
			move.b	1(a0),d2
			move.b	wildstarsearchpat+1(a5),d3
			and.b	#%11000000,d2
			and.b	#%11000000,d3
			cmp.b	d2,d3
			bne	.gleich
			move.b	2(a0),d2
			move.b	wildstarsearchpat+2(a5),d3
			and.b	#%11000000,d2
			and.b	#%11000000,d3
			cmp.b	d2,d3
			bne	.gleich
.arpgleich2
			btst	#29,d4
			bne.b	.noteGleich2
			move.b	(a0),d2
			move.b	wildstarsearchpat(a5),d3
			and.b	#%111111,d2
			and.b	#%111111,d3
			cmp.b	d2,d3
			bne	.gleich
.notegleich2
			btst	#21,d4
			bne.b	.instrGleich2
			move.b	1(a0),d2
			move.b	wildstarsearchpat+1(a5),d3
			and.b	#%111111,d2
			and.b	#%111111,d3
			cmp.b	d2,d3
			bne.w	.gleich
.instrgleich2
			btst	#13,d4
			bne.b	.fxcomGleich2
			move.b	2(a0),d2
			move.b	wildstarsearchpat+2(a5),d3
			and.b	#%111111,d2
			and.b	#%111111,d3
			cmp.b	d2,d3
			bne.w	.gleich
.fxcomgleich2
			btst	#7,d4
			bne.b	.fxdat1gleich2
			move.b	3(a0),d2
			move.b	wildstarsearchpat+3(a5),d3
			and.b	#%11110000,d2
			and.b	#%11110000,d3
			cmp.b	d2,d3
			bne.w	.gleich
.fxdat1gleich2
			btst	#2,d4
			bne.b	.fxdat2gleich2
			move.b	3(a0),d2
			move.b	wildstarsearchpat+3(a5),d3
			and.b	#%1111,d2
			and.b	#%1111,d3
			cmp.b	d2,d3
			bne.w	.gleich
.fxdat2gleich2

;	btst	#31,d4
;	beq.b	.NOTarpGleich
			btst	#7,wildstarmask2+1(a5)
			bne.b	.arpgleich
;.NOTarpGleich
			and.b	#%00111111,1(a0)
			and.b	#%00111111,2(a0)
			move.b	wildstarreplacepat+1(a5),d1
			and.b	#%11000000,d1
			or.b	d1,1(a0)
			move.b	wildstarreplacepat+2(a5),d1
			and.b	#%11000000,d1
			or.b	d1,2(a0)
.arpgleich

;	btst	#29,d4
;	beq.b	.notnoteGleich
			btst	#5,wildstarmask2(a5)
			bne.b	.notegleich
;.notnoteGleich
			and.b	#%11000000,(a0)
			move.b	wildstarreplacepat(a5),d1
			and.b	#%00111111,d1
			or.b	d1,(a0)
.notegleich
;	btst	#21,d4
;	beq.b	.NOTinstrGleich
			btst	#5,wildstarmask2+1(a5)
			bne.b	.instrgleich
;.NOTinstrGleich
			and.b	#%11000000,1(a0)
			move.b	wildstarreplacepat+1(a5),d1
			and.b	#%00111111,d1
			or.b	d1,1(a0)
.instrgleich
;	btst	#13,d4
;	beq.b	.notfxcomGleich
			btst	#5,wildstarmask2+2(a5)
			bne.b	.fxcomgleich
;.notfxcomGleich
			and.b	#%11000000,2(a0)
			move.b	wildstarreplacepat+2(a5),d1
			and.b	#%00111111,d1
			or.b	d1,2(a0)
.fxcomgleich
;	btst	#7,d4
;	beq.b	.NOTfxdat1Gleich
			btst	#7,wildstarmask2+3(a5)
			bne.b	.fxdat1gleich
;.NOTfxdat1Gleich
			and.b	#%1111,3(a0)
			move.b	wildstarreplacepat+3(a5),d1
			and.b	#%11110000,d1
			or.b	d1,3(a0)
.fxdat1gleich
;	btst	#2,d4
;	beq.b	.notfxdat2Gleich
			btst	#2,wildstarmask2+3(a5)
			bne.b	.fxdat2gleich
;.NOTfxdat2Gleich
			and.b	#%11110000,3(a0)
			move.b	wildstarreplacepat+3(a5),d1
			and.b	#%1111,d1
			or.b	d1,3(a0)
.fxdat2gleich


.gleich
			addq.l	#4,a0
			dbf	d0,.innerloop
			lea	(a0,d5),a0
			dbf	d7,.copyblock
.exit			move.b	#$f,pattdspreq(a5)
			rts
;--------------------------------------------------------------------
ExChangePATTERNS
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			lea	.tags(pc),a0
			tst.b	chmode(a5)
			beq.b	.4chnr
			move.l	#63,20(a0)
			bra.b	.8chnr
.4chnr			move.l	#127,20(a0)
.8chnr
			move.l	window1ptr(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			lea	.tags(pc),a0
			move.l	window1ptr(a5),4(a0)
			lea	.to(pc),a1
			lea	.toASC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok2
			rts
.ok2
			moveq	#0,d7
			move	.to+2(pc),d7
			jsr	getactpatadr
			move.l	a0,a1
			moveq	#0,d7
			move	.from+2(pc),d7
			jsr	getactpatadr
; a0=Source,a1=dest
			tst.b	chmode(a5)
			beq.b	.4ch
			move	#64*8-1,d7
.ex_it8			move.l	(a0),d0
			move.l	(a1),(a0)+
			move.l	d0,(a1)+
			dbf	d7,.ex_it8
			move.b	#$f,pattdspreq(a5)
			rts
.4ch			move	#64*4-1,d7
.ex_it			move.l	(a0),d0
			move.l	(a1),(a0)+
			move.l	d0,(a1)+
			dbf	d7,.ex_it
			move.b	#$f,pattdspreq(a5)
			rts

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,127
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Exchg Patt (From)",0
.toASC			dc.b	"Exchg Patt (To)",0
			even
.from			dc.l	0
.to			dc.l	0
;--------------------------------------------------------------------
exchangetracks:
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			lea	.tags(pc),a0
			tst.b	chmode(a5)
			beq.b	.4chnr
			move.l	#8,20(a0)
			bra.b	.8chnr
.4chnr			move.l	#4,20(a0)
.8chnr
			move.l	window1ptr(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust
			lea	.tags(pc),a0
			move.l	window1ptr(a5),4(a0)
			lea	.to(pc),a1
			lea	.toASC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok2
			rts
.ok2
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr

			move.l	a0,a1
			move.l	.from(pc),d0
			subq.b	#1,d0
			lsl	#2,d0
			lea	(a0,d0),a0
			move.l	.to(pc),d0
			subq.b	#1,d0
			lsl	#2,d0
			lea	(a1,d0),a1

			tst.b	chmode(a5)
			beq.b	.4ch

; a0=Source,a1=dest
			moveq	#64-1,d7
.ex_it8			move.l	(a0),d0
			move.l	(a1),(a0)
			move.l	d0,(a1)
			lea	32(a0),a0
			lea	32(a1),a1
			dbf	d7,.ex_it8
			move.b	#$f,pattdspreq(a5)
			rts

.4ch
; a0=Source,a1=dest
			moveq	#64-1,d7
.ex_it			move.l	(a0),d0
			move.l	(a1),(a0)
			move.l	d0,(a1)
			lea	16(a0),a0
			lea	16(a1),a1
			dbf	d7,.ex_it
			move.b	#$f,pattdspreq(a5)
			rts

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,1
			dc.l	rtgl_max,4
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Exchg Track (From)",0
.toASC			dc.b	"Exchg Track (To)",0
			even
.from			dc.l	0
.to			dc.l	0

;--------------------------------------------------------------------
EXPANDTRACK:
			tst.b	chmode(a5)
			bne.b	expandtrack8ch

			jsr	getchanneloff
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0	; +choff
			move.l	a0,a4
			lea	32*16(a0),a0
			lEA	iobuffer+1000,a2
			move.l	a2,a3
			lea	62*4(a2),a1

			moveq	#64/4-1,d7	; Clr workbuf
.clrbuf			clr.l	(a2)+
			clr.l	(a2)+
			clr.l	(a2)+
			clr.l	(a2)+
			dbf	d7,.clrbuf

			moveq	#32-1,d7
.loop			move.l	-16(a0),(a1)
			lea	-16(a0),a0
			lea	-4*2(a1),a1
			dbf	d7,.loop

			moveq	#64-1,d7	; Copy workbuf
.copybuf		move.l	(a3)+,(a4)
			lea	16(a4),a4
			dbf	d7,.copybuf

			move.b	#$f,pattdspreq(a5)
			rts
expandtrack8ch:
			jsr	getchanneloff
			moveq	#0,d7
			move	acteditpattern(a5),d7
			jsr	getactpatadr
			add.l	iobuffer,a0	; +choff
			move.l	a0,a4
			lea	32*32(a0),a0
			lEA	iobuffer+1000,a2
			move.l	a2,a3
			lea	62*4(a2),a1

			moveq	#64/4-1,d7	; Clr workbuf
.clrbuf			clr.l	(a2)+
			clr.l	(a2)+
			clr.l	(a2)+
			clr.l	(a2)+
			dbf	d7,.clrbuf

			moveq	#32-1,d7
.loop			move.l	-32(a0),(a1)
			lea	-32(a0),a0
			lea	-4*2(a1),a1
			dbf	d7,.loop

			moveq	#64-1,d7	; Copy workbuf
.copybuf		move.l	(a3)+,(a4)
			lea	32(a4),a4
			dbf	d7,.copybuf

			move.b	#$f,pattdspreq(a5)
			rts
;--------------------------------------------------------------------
DELETEINSTRUMENT:
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			lea	clrinstr_str,a1
			jsr	patchEasyReqArgs

			move.b	#1,itt_adpd_flag(a5)

			tst.b	d0
			beq.w	.cancel
			cmp.b	#1,d0
			beq.b	.instrwave
			cmp.b	#2,d0
			beq.b	.wave
			cmp.b	#3,d0
			beq.b	.instr

.instrwave
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			jsr	freewave
.instr
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)

			bsr	instred_actualdata
			move.l	a0,a1
			move.b	3(a1),d0
			REPT	8
			clr.l	(a0)+
			ENDR
			move.b	d0,3(a1)
			jmp	refresh_instrument
.wave			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			jsr	freewave
			jsr	waveed_setshowall
			jmp	refresh_instrument
.cancel			rts
;--------------------------------------------------------------------
; KEINE Sicherheitsabfrage (nützlich wenn kein Speicher mehr frei ist, um
; irgendwelche Requester zu öffnen (kleines Hintertürchen ;))
KILLINSTRUMENT:
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			jsr	freewave
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)
			bsr	instred_actualdata
			move.l	a0,a1
			move.b	3(a1),d0
			REPT	8
			clr.l	(a0)+
			ENDR
			move.b	d0,3(a1)
			jsr	waveed_setshowall
			jmp	refresh_instrument
;--------------------------------------------------------------------
freechannels:		move.b	#1,chfree(a5)
			LEA	msg_chfree,A2
			jsr	displaymessage
			clr.b	chfree(a5)
			rts
;--------------------------------------------------------------------
set4channels:
			jsr	clrn_song

			move.l	exec,a6
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a4
			moveq	#64-1,d7
.movewaves
			move.l	(a3),d0
			beq.b	.nextwave
			move.l	#$10002,d1
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq.b	.nextwave
			move.l	d0,d6
			move.l	d0,a1
			move.l	(a4),a0	; wavestart
			move.l	(a3),d1	; wavelen
.copyit			move.b	(a0)+,(a1)+	; in chip area kopieren
			subq.l	#1,d1
			bne.b	.copyit

			move.l	(a4),a1
			jsr	exec_freevec(a6)

			move.l	d6,(a4)
.nextwave		addq.l	#4,a3
			addq.l	#4,a4
			dbf	d7,.movewaves

set4channels2:		jsr	clr_patternscreen
			move	#$4000,$dff09a
			move.l	oldaudio,d0
			beq.b	.alreadycleared
			move.l	vbreg(a5),a0
			move.l	d0,$70(a0)
			move	#$0780,$dff09a
.alreadycleared		move	#$c000,$dff09a
			clr.b	chmode(a5)
			clr.b	patcntx(a5)
			move.b	#%1111,ch_enable(a5)
			move.b	#$f,pattdspreq(a5)
			bsr	drawhilitepattern
			jmp	init_newpatterns
oldaudio		dc.l	0
;--------------------------------------------------------------------
set8channels:
			tst.b	extproc(a5)
			bne.b	.isok
			lea	msg_noextproc,a2
			jmp	displaymessage
.isok
			tst.b	chmode(a5)
			bne.b	set8channels3
			bsr	convert28ch
set8channels3:
			movem.l	d0-a6,-(sp)
			move.b	#1,chmode(a5)
			move	#$4000,$dff09a
			jsr	mix_init

			move.l	vbreg(a5),a0
			move.l	$70(a0),oldaudio
			move.l	#mix_play,$70(a0)
			move	#$c780,$dff09a

			jsr	clr_patternscreen
			move.l	#8*8*80,d3
			move	#8*80,d4
			moveq	#0,d2
			lea	txt_pattinit,a0
			jsr	printpattscreenHI
			move.b	#$f,pattdspreq(a5)
			move.b	#%11111111,ch_enable(a5)
			jsr	drawhilitepattern
			movem.l	(sp)+,d0-a6
			rts
;------------------------------------------------------------------------

; 0/1	-0
; 2/3	-1
; 4/5	-2
; 6/7	-3

convert28ch:
			lea	module_patterns+1024*63,a0
			lea	module_patterns+1024*126,a1
			moveq	#63-1,d7
.loop			moveq	#64-1,d6
.copypat		move.l	0*4(a0),0*4(a1)
			move.l	1*4(a0),2*4(a1)
			move.l	2*4(a0),4*4(a1)
			move.l	3*4(a0),6*4(a1)
			clr.l	1*4(a1)
			clr.l	3*4(a1)
			clr.l	5*4(a1)
			clr.l	7*4(a1)
			lea	4*4(a0),a0
			lea	8*4(a1),a1
			dbf	d6,.copypat
			lea	-1024*2(a0),a0
			lea	-2048*2(a1),a1
			dbf	d7,.loop

			lea	iobuffer+1024,a2
			move.l	a2,a3
			move	#256-1,d7
.loopcopy		move.l	(a0)+,(a2)+
			dbf	d7,.loopcopy

			moveq	#64-1,d6
.copypat2		move.l	0*4(a3),0*4(a1)
			move.l	1*4(a3),2*4(a1)
			move.l	2*4(a3),4*4(a1)
			move.l	3*4(a3),6*4(a1)
			clr.l	1*4(a1)
			clr.l	3*4(a1)
			clr.l	5*4(a1)
			clr.l	7*4(a1)
			lea	4*4(a3),a3
			lea	8*4(a1),a1
			dbf	d6,.copypat2

			move.l	exec,a6
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a4
			moveq	#64-1,d7
.movewaves
			move.l	(a3),d0
			beq.b	.nextwave
			move.l	#$10001,d1
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq.b	.nextwave
			move.l	d0,d6
			move.l	d0,a1
			move.l	(a4),a0	; wavestart
			move.l	(a3),d1	; wavelen
.copyit			move.b	(a0)+,(a1)+	; in public area kopieren
			subq.l	#1,d1
			bne.b	.copyit

			move.l	(a4),a1
			jsr	exec_freevec(a6)

			move.l	d6,(a4)
.nextwave		addq.l	#4,a3
			addq.l	#4,a4
			dbf	d7,.movewaves

			rts
;------------------------------------------------------------------------
setmixrate:
			clr.b	itt_adpd_flag(a5)
;	jsr	adpd_realadjust

			lea	.tags(pc),a0
			move.l	window1ptr(a5),4(a0)
			lea	.rate(pc),a1
			lea	.rateaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,itt_adpd_flag(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			move.l	.rate(pc),d2
			lsr.l	#8,d2
			move.l	#29200,d1
			divu	d2,d1
			moveq	#124,d2
			mulu	d1,d2
			lsr.l	#8,d2
			move	d2,mix_mixrate

			move	d2,$dff0a6
			move	d2,$dff0b6
			move	d2,$dff0c6
			move	d2,$dff0d6

			move.l	.rate(pc),d0
			lea	mixrateASC-1,a0
			jsr	integerTOascii6
			move.b	#" ",(a0)
			rts

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,3000
			dc.l	rtgl_max,64000
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.rateASC		dc.b	"Mix-rate? (Hz)",0
			even
.rate			dc.l	15000
;------------------------------------------------------------------------
audirqOFF
			move	$dff01c,d0
			or	#$8000,d0
			move	d0,mro_oldirqs
			move	#$0780,$dff09a
			rts
mro_oldirqs		dc	0
resIrq			move	mro_oldirqs(pc),$dff09a
			rts
;------------------------------------------------------------------------
ShowTrackVols:
			lea	msg_trackvol+11,a0
			lea	aon_channels+aon_trackvol,a4
			moveq	#8-1,d7
.loop			move	(a4),d0
			jsr	integerToascii2
			addq.l	#5,a0
			move	(a4),d0
			jsr	hexToascii2
			lea	aon_chdatasize(a4),a4
			lea	msg_tvlen-5(a0),a0
			dbf	d7,.loop
			lea	msg_trackvol,a2
			jmp	displaymessage
;------------------------------------------------------------------------
showrecord:		tst.b	prf_data+prf_bottomstatusmode
			beq.b	.nost
			tst.b	patteditstatus(a5)
			bne.b	.doit2
			tst.b	replaystatus(a5)
			bne.b	.doit2
.nost
			move.l	bitplane2_startadr(a5),a2
			cmp	#400,win1h
			beq.b	.euro722
			lea	(249-33)*80+74(a2),a2
			bra.b	.pal2
.euro722		lea	(396-33)*80+74(a2),a2
.pal2			bra.b	.clrit
.doit2
			addq.b	#1,recordcnt(a5)
			cmp.b	#3,recordcnt(a5)
			bgt.b	.do
			rts
.do			clr.b	recordcnt(a5)
			bchg	#0,recordstatus(a5)

			move.l	bitplane2_startadr(a5),a2
			cmp	#400,win1h
			beq.b	.euro72
			lea	(249-33)*80+74(a2),a2
			bra.b	.pal
.euro72			lea	(396-33)*80+74(a2),a2
.pal
			tst.b	recordstatus(a5)
			beq.b	.clrit

			tst.b	patteditstatus(a5)
			bne.b	.not
			lea	gfx_play,a0
			bra.b	.play
.not			lea	gfx_record,a0
.play
			moveq	#33-1,d7
.loop			move.l	(a0)+,(a2)+
			lea	80-4(a2),a2
			dbf	d7,.loop
			rts
.clrit			moveq	#33-1,d7
			moveq	#0,d0
.loop2			move.l	d0,(a2)+
			lea	80-4(a2),a2
			dbf	d7,.loop2
			rts
;------------------------------------------------------------------------
togglecheditmode
			bchg	#0,cheditmode(a5)
			lea	mt4_editmodeASC,a0
			tst.b	cheditmode(a5)
			beq.b	.setsingle
			move.b	#"M",(a0)+
			move.b	#"u",(a0)+
			move.b	#"l",(a0)+
			move.b	#"t",(a0)+
			move.b	#"i",(a0)+
			move.b	#" ",(a0)+
			rts
.setsingle		move.b	#"S",(a0)+
			move.b	#"i",(a0)+
			move.b	#"n",(a0)+
			move.b	#"g",(a0)+
			move.b	#"l",(a0)+
			move.b	#"e",(a0)+
			rts
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------


;************************************************************************
blanker:		tst	prf_data+prf_blankertimeout
			bne.b	.notdisabled
			rts
.notdisabled		tst	blankercnt(a5)
			beq	.reset
			move.b	$bfec01,d0
			move	$dff00a,d1
			cmp.b	lastbfec01(a5),d0
			bne	.resetmove
			cmp	lastdff00a(a5),d1
			bne	.resetmove
			subq	#1,blankercnt(a5)
			beq.b	.startblanking
			rts
.startblanking
			bsr	.reset
			lea	blankerpfad,a0
			lea	prf_data+prf_blankername,a1
			jsr	makefilename
			move.l	a2,d7

			move.l	$4.w,a6
			moveq	#1,d0
			swap	d0
			moveq	#2,d1
			jsr	exec_allocvec(a6)
			move.l	d0,blankermodule(a5)
			beq.w	.nomem

			move.l	dosbase(a5),a6
			jsr	dos_getprogramdir(a6)
			move.l	d0,d1
			jsr	dos_currentdir(a6)

			move.l	d7,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,d7
			beq.b	.fileerror
			move.l	d0,d1
			move.l	blankermodule(a5),d2
			moveq	#1,d3
			swap	d3
			jsr	dos_read(a6)
			tst.l	d0
			bmi.b	.loadfailed
			move.l	d7,d1
			jsr	dos_close(a6)
			move.l	blankermodule(a5),a0
			jsr	(a0)
			tst.l	d0
			bne.b	.initfailed

			lea	$bfec01,a3
			lea	$dff00a,a4
			move.b	(a3),d5
			move	(a4),d6
			move.l	dosbase(a5),a6

.blankloop		cmp.b	(a3),d5
			bne.b	.end
			cmp	(a4),d6
			bne.b	.end
			moveq	#1,d1
			jsr	dos_delay(a6)
			bra.b	.blankloop

.end			clr	blankercnt(a5)		; reset blankercnt!!
			move.l	blankermodule(a5),a1
			jsr	4(a1)		; end blankroutine
			bra	.freemem2
			rts
.initfailed		bsr	.freemem
			lea	msg_blanker_initfailed,a2
			jmp	displaymessage
.nomem			lea	msg_blanker_outofmem,a2
			jmp	displaymessage
.fileerror		bsr	.freemem
			lea	msg_blanker_fileerror,a2
			jmp	displaymessage
.loadfailed		bsr	.freemem
			lea	msg_blanker_loadfailed,a2
			jmp	displaymessage

.freemem		move.l	blankermodule(a5),a1
.freemem2		move.l	$4.w,a6
			jmp	exec_freevec(a6)

.resetmove		move.b	d0,lastbfec01(a5)
			move	d1,lastdff00a(a5)
.reset			moveq	#0,d0
			move	prf_data+prf_blankertimeout,d0
			move	d0,d1
			add	d0,d0
			lsl	#3,d1
			add	d0,d1	; *10
			move	d1,blankercnt(a5)
			rts
;************************************************************************
Remark_Edit:		move.l	dosbase(a5),a6
			lea	prf_data+prf_texteditor,a0
			lea	rem_editcall,a1
			move.l	a1,d1
.loop1			move.b	(a0)+,(a1)+
			tst.b	(a0)
			bne.b	.loop1
			move.b	#" ",(a1)+
			lea	rem_filename,a0
.loop2			move.b	(a0)+,(a1)+
			tst.b	-1(a0)
			bne.b	.loop2
			moveq	#0,d2
			moveq	#0,d3
			jmp	dos_execute(a6)
.failed			rts
;************************************************************************
remark_SHOW:
			lea	iobuffer,a0
			move	#3000-1,d7
.clriobuf		clr.l	(a0)+
			dbf	d7,.clriobuf

			move.l	dosbase(a5),a6
			move.l	#rem_filename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			tst.l	d0
			beq.b	.noremark
			move.l	d0,filehandle(a5)
			move.l	d0,d1
			move.l	#iobuffer+10000,d2
			move.l	#1999,d3
			jsr	dos_read(a6)
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

; Convert tabs to spaces
			lea	iobuffer+10000,a0
			tst.b	(a0)
			beq	.noremark

			lea	iobuffer,a1
			moveq	#0,d0
			moveq	#0,d1		; x-line cnt
.convtabs		move.b	(a0)+,d0
			beq.b	.end
			cmp.b	#$a,d0		; end of line?
			bne.b	.noteol
			moveq	#-1,d1		; ja?! dann counter zurück
			bra.b	.notab
.noteol
			cmp.b	#9,d0		; tab?!
			bne.b	.notab
			move	d1,d0		; x-cnt
			addq	#8,d0		; next tabpos
			lsr	#3,d0		; an /8 teilbare pos
			lsl	#3,d0		; rücken
			move	d0,d2
			sub	d1,d0		; wieviele spaces bis dahin?
			move	d2,d1
			subq	#1,d0		; dbf schleife
.fillspc		move.b	#" ",(a1)+
			dbf	d0,.fillspc
			bra.b	.convtabs

.notab			addq	#1,d1
			move.b	d0,(a1)+	; write charcode
			bra.b	.convtabs
.end
			move.l	#iobuffer,a2
			jmp	displaymessage

.noremark		lea	msg_noremark,a2
			jmp	displaymessage
;************************************************************************
Arpeggio_Editor:
			clr.b	itt_adpd_flag(a5)
			move.b	#arpedit,programmode(a5)

			lea	arp_gadget1buf,a0
			move.l	aon_arpdata+aon_data,a1
			lea	convertLongAsciihex(pc),a2
			lea	zapzeros(pc),a3
			moveq	#16-1,d6
.numascii		move.l	(a1)+,d0
			jsr	(a2)
			jsr	(a3)
			lea	arp_gadget2buf-arp_gadget1buf(a0),a0
			dbf	d6,.numascii

			move.l	intbase(a5),a6
			lea	window2struct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window2ptr(a5)
			bne.b	.windowopened
			lea	msg_arp_nowindow,a2
			jsr	displaymessage
			bra	arped_exit
.windowopened
			move.l	d0,a0
			move.l	$32(a0),rastport2(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userport2(a5)

			move.l	gadtoolsbase(a5),a6
			lea	gadgetlist2(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;--------- Gadgets eintragen ------------
			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mp2_gadgetptrs+4,a5
			lea	arp_gadgetstructptrs,a4
.allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.b	.allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	.allocGadgetsLoop
.AllocGadgetsEND	move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

			move.l	gadgetlist2(a5),a0	; Gadgets zeichnen
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)
; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)
arpeded
			clr.b	screen(a5)
; Mainloop-----------------------
arp_mmm
.mmm			move.l	userport2(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.m_messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			jsr	printnewpatterns
			jsr	adjust_pattdisplay
			bra.b	.mmm
.m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#inactivewindow,$14(a0)
			beq	instred_inactivated

			cmp.l	#intuiticks,$14(a0)
			beq	arp_intuiticks
			cmp.l	#rawkey,$14(a0)
			beq	keypressedarped
			moveq	#0,d3
			cmp.l	#closewindow,$14(a0)
			beq.b	.exit
			cmp.l	#gadgetup,$14(a0)
			bne	.yoman
			moveq	#4,d3
			cmp.l	#gadgetdown,$14(a0)
			bne	.mmm
.yoman			bsr	checkgadgets
			bra	.mmm
; Exit---------------------------
.exit
arped_exitfree
			lea	mp2_gadgetptrs+4,a2
			move.l	aon_arpdata+aon_data,a3
			lea	convertasciilonghex(pc),a4
			moveq	#16-1,d7
.checkoutgadgetsloop	move.l	(a2)+,a0
			move.l	$22(a0),a0		; StringInfo
			move.l	(a0),a0			; ptr auf string
			jsr	(a4)
			move.l	d0,(a3)+
			dbf	d7,.checkoutgadgetsloop

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen

			move.l	gadtoolsbase(a5),a6
			move.l	gadgetlist2(a5),a0
			jsr	gadtools_FreeGadgets(a6)

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
arped_exit		move.b	#pattedit,programmode(a5)
			move.b	#1,itt_adpd_flag(a5)
			rts
;_-------------------------------------------------------------------
arp_intuiticks		bsr	blanker
			bra	arp_mmm
;--------------------------------------------------------------------
arped_exitnow		addq.l	#8,sp
			bra	arped_exitfree
;------------------------------------------------------------------------
ActivateArp0		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp0*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp1		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp1*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp2		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp2*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp3		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp3*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp4		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp4*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp5		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp5*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp6		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp6*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp7		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp7*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp8		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp8*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArp9		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arp9*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpA		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpA*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpB		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpB*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpC		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpC*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpD		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpD*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpE		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpE*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;------------------------------------------------------------------------
ActivateArpF		move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_arpF*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;************************************************************************
DrumSequencer:
			clr.b	itt_adpd_flag(a5)

			move.l	intbase(a5),a6
			lea	dseq_windowstruct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window2ptr(a5)
			bne.b	.windowopened
			lea	msg_dseq_nowindow,a2
			jsr	displaymessage
			bra	dseq_exit
.windowopened
 move.b	#drumseq,programmode(a5) ; damit der cursor nicht im falschen window
				; ausgegeben wird!

			move.l	d0,a0
			move.l	$32(a0),rastport2(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userport2(a5)
			move.l	d0,mod_filereqWINPTR2	; Für Filerequester

			move.l	gadtoolsbase(a5),a6
			lea	gadgetlist2(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;--------- Gadgets eintragen ------------
			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mp2_gadgetptrs+4,a5
			lea	dseq_gadgetstructptrs,a4
.allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.b	.allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	.allocGadgetsLoop
.AllocGadgetsEND	move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

			move.l	gadgetlist2(a5),a0	; Gadgets zeichnen
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)
; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)

;--------------- Sequenzen ausgeben -----------------
; SEQUENZ DISPLAY DESIGNEN
			moveq	#0,d3
			move	#8*80,d4
			moveq	#0,d2
			lea	txt_dseq_init,a0
			jsr	printdseqscreen2
			jsr	dseq_printpatterns

;--------- Bevel-Box zeichnen -----------
			move.l	rastport2(a5),a0
			move.l	#234,d0
			moveq	#gyoff+25,d1
			move.l	#49*8+2,d2
			move.l	#ghi*16+2,d3
			lea	bevel_raised_tags,a1
			move.l	getvisual(a5),4(a1)
			jsr	gadtools_drawbevelboxa(a6)

			moveq	#0,d3
			move	#ghi*80,d4
			moveq	#0,d2
			lea	txt_dseq_init3,a0
			jsr	printdseqscreen4

			bsr	dseq_correctSeqlen
			bsr	refresh_dseqnrslider
			jsr	refresh_dseqlenslider
			jsr	refresh_dseqwavegadgets
			jsr	refresh_dseqpitch
			jsr	refresh_dseqspeed
			jsr	refresh_dseqtempo
			jsr	refresh_dseqdestwave

			clr.b	patteditstatus(a5)
			move.b	#1,win2_override(a5)

dseqEd:
			clr.b	screen(a5)

; Mainloop-----------------------
dseq_mmm
.mmm			move.l	userport2(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.m_messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			jsr	printnewpatterns
			jsr	adjust_pattdisplay
			bra.b	.mmm
.m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#intuiticks,$14(a0)
			beq	dseq_intuiticks
			cmp.l	#mousemove,$14(a0)
			bne.b	.not
			cmp	#gad_drumseqnr,lastdownid(a5)
			beq	dseq_seqnrchangeNOW
			cmp	#gad_drumseqlen,lastdownid(a5)
			beq	dseq_seqlenchangeNOW
.not

			cmp.l	#inactivewindow,$14(a0)
			beq	instred_inactivated

			cmp.l	#rawkey,$14(a0)
			beq	keypresseddrumseq
			cmp.l	#closewindow,$14(a0)
			beq.b	.exit
			cmp.l	#mousebuttons,$14(a0)
			beq.b	dseq_setmousecursor

			moveq	#0,d3
			cmp.l	#gadgetup,$14(a0)
			beq.b	.yoman
			moveq	#4,d3
			cmp.l	#gadgetdown,$14(a0)
			bne.b	.noman
.yoman			bsr	checkgadgets
.noman			bra	.mmm
; Exit---------------------------
.exit
dseq_exitfree
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen

			move.l	gadtoolsbase(a5),a6
			move.l	gadgetlist2(a5),a0
			jsr	gadtools_FreeGadgets(a6)
	
	move.b	#pattedit,programmode(a5) ; damit der cursor nicht im falschen
					; window ausgegeben wird!

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
dseq_exit		move.b	#pattedit,programmode(a5)
			move.b	#1,itt_adpd_flag(a5)
			rts
;--------------------------------------------------------------------
dseq_intuiticks		bsr	blanker
			bra	dseq_mmm
;--------------------------------------------------------------------

dseq_setmousecursor	btst	#6,$bfe001
			bne	dseq_mmm
			move.l	window2ptr(a5),a0
			moveq	#0,d0
			move	$c(a0),d0	; mouse-y
			cmp	#gyoff+25+2,d0
			blt	dseq_mmm
			cmp	#gyoff+25+2+ghi*16+2,d0
			bgt	dseq_mmm

			moveq	#0,d1
			move	$e(a0),d1
			cmp	#236,d1
			blt	dseq_mmm
			cmp	#49*8+226,d1
			bgt	dseq_mmm
			sub	#236,d1
			sub	#gyoff+25+2,d0
			beq.b	.nodivbyzero
			divu	#ghi,d0
.nodivbyzero		lsr	#3,d1
			move.b	d1,dseq_cursorx(a5)
			move.b	d0,dseq_cursory(a5)
			bra	dseq_mmm
;--------------------------------------------------------------------
DSEQ_setcursor		tst.b	win2_override(a5)
			bne.b	.ok
			rts
.ok
			move.l	bitplane2_startadr(a5),a2
			moveq	#0,d0
			move.b	dseq_lastcursory(a5),d0
			mulu	#80*ghi,d0
			add	#80*8*5-80,d0
			moveq	#30,d1
			add.b	dseq_lastcursorx(a5),d1
			lea	(a2,d0),a0
			lea	(a0,d1),a0
			moveq	#0,d0
			move.b	d0,(a0)
			move.b	d0,80*1(a0)
			move.b	d0,80*2(a0)
			move.b	d0,80*3(a0)
			move.b	d0,80*4(a0)
			move.b	d0,80*5(a0)
			move.b	d0,80*6(a0)
			move.b	d0,80*7(a0)
			move.b	d0,80*8(a0)

			moveq	#0,d0
			move.b	dseq_cursory(a5),d0
			move.b	d0,dseq_lastcursory(a5)
			mulu	#80*ghi,d0
			add	#80*8*5-80,d0
			moveq	#30,d1
			add.b	dseq_cursorx(a5),d1
			move.b	dseq_cursorx(a5),dseq_lastcursorx(a5)
			lea	(a2,d0),a0
			lea	(a0,d1),a0
			moveq	#-1,d0
			move.b	d0,(a0)
			move.b	d0,80*1(a0)
			move.b	d0,80*2(a0)
			move.b	d0,80*3(a0)
			move.b	d0,80*4(a0)
			move.b	d0,80*5(a0)
			move.b	d0,80*6(a0)
			move.b	d0,80*7(a0)
			move.b	d0,80*8(a0)
			rts
;--------------------------------------------------------------------
DSEQ_cursorup		subq.b	#1,dseq_cursory(a5)
			and.b	#$f,dseq_cursory(a5)
			rts
;--------------------------------------------------------------------
DSEQ_cursordown		addq.b	#1,dseq_cursory(a5)
			and.b	#$f,dseq_cursory(a5)
			rts
;--------------------------------------------------------------------
DSEQ_cursorright2	cmp.b	#$41,scancode+3(a5)
			bne.b	dseq_cursorright
			rts
DSEQ_cursorright	addq.b	#1,dseq_cursorx(a5)
			cmp.b	#48,dseq_cursorx(a5)
			bne.b	.e
			clr.b	dseq_cursorx(a5)
.e			rts
;--------------------------------------------------------------------
DSEQ_cursorleft		subq.b	#1,dseq_cursorx(a5)
			bpl.b	.e
			move.b	#47,dseq_cursorx(a5)
.e			rts
;--------------------------------------------------------------------
DSEQ_del		moveq	#0,d0
			bra.b	dseq_setnibble
DSEQ_set1		moveq	#1,d0
			bra.b	dseq_setnibble
DSEQ_set2		moveq	#2,d0
			bra.b	dseq_setnibble
DSEQ_set3		moveq	#3,d0
			bra.b	dseq_setnibble
DSEQ_set4		moveq	#4,d0
			bra.b	dseq_setnibble
DSEQ_set5		moveq	#5,d0
			bra.b	dseq_setnibble
DSEQ_set6		moveq	#6,d0
			bra.b	dseq_setnibble
DSEQ_set7		moveq	#7,d0
			bra.b	dseq_setnibble
DSEQ_set8		moveq	#8,d0
			bra.b	dseq_setnibble
DSEQ_set9		moveq	#9,d0
			bra.b	dseq_setnibble
DSEQ_seta		moveq	#10,d0
			bra.b	dseq_setnibble
DSEQ_setb		moveq	#11,d0
			bra.b	dseq_setnibble
DSEQ_setc		moveq	#12,d0
			bra.b	dseq_setnibble
DSEQ_setd		moveq	#13,d0
			bra.b	dseq_setnibble
DSEQ_sete		moveq	#14,d0
			bra.b	dseq_setnibble
DSEQ_setf		moveq	#15,d0

; d0=Nibble
dseq_setnibble
			cmp.b	#$41,scancode+3(a5)
			bne.b	.nbs
			bsr	dseq_cursorleft
.nbs

			moveq	#0,d1
			moveq	#0,d2
			move.b	dseq_cursory(a5),d1
			mulu	#24,d1
			move.b	dseq_cursorx(a5),d2

			lea	dseq_patterns,a0
			moveq	#0,d3
			move.b	dseq_actseq(a5),d3
			mulu	#48/2*16,d3
			lea	(a0,d3),a0

			ror	#1,d2
			bcs.b	.lowernibble
			lsl.b	#4,d0
			add	d2,d1
			lea	(a0,d1),a0
			and.b	#$0f,(a0)
			or.b	d0,(a0)
			bsr	dseq_printpatterns
			bra	dseq_cursorright2
.lowernibble		and	#$ff,d2
			add	d2,d1
			lea	(a0,d1),a0
			and.b	#$f0,(a0)
			or.b	d0,(a0)
			bsr	dseq_printpatterns
			bra	dseq_cursorright2
;--------------------------------------------------------------------
dseq_printpatterns
			movem.l	d0-a6,-(sp)
			lea	dseq_patterns,a6
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a6,d0),a6
			lea	txt_2chars,a0
			lea	txt_dseqchars,a4
			lea	printdseqscreen3,a3
			moveq	#0,d3	y
.lineloop		moveq	#2,d2	x
.innerloop		moveq	#0,d5
			moveq	#0,d6
			move.b	(a6)+,d5
			move.b	d5,d6
			lsr.b	#4,d5
			and.b	#$f,d6
			move.b	(a4,d5),(a0)
			move.b	(a4,d6),1(a0)
			jsr	(a3)
			addq	#2,d2
			cmp	#48+2,d2
			bne.b	.innerloop
			add	#ghi*80,d3
			cmp	#16*ghi*80,d3
			bne.b	.lineloop
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
DSEQ_seqnrChange:	move	#gad_drumseqnr,lastdownID(a5)
			move.b	$19(a0),dseq_actseq(a5)
			bsr.b	dseq_correctSeqlen
			bra	refresh_dseqnrslider

dseq_seqnrENTRANCE	bsr.b	dseq_correctSeqlen
			bsr	dseq_printpatterns
			jsr	refresh_dseqwavegadgets
			bra	refresh_dseqnrslider
DSEQ_seqnrChangeNOW:
			move.b	$19(a0),dseq_actseq(a5)
			bsr.b	dseq_correctSeqlen
			bsr	refresh_dseqnrslider
			bra	dseq_mmm
DSEQ_seqnrchangeUP
			move.b	$19(a0),dseq_actseq(a5)
			bsr.b	dseq_correctSeqlen
			bsr	refresh_dseqnrslider
			bsr	dseq_printpatterns
			jmp	refresh_dseqwavegadgets
dseq_correctSeqlen	moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl.b	#4,d0	; *16
			add.b	d1,d0	; +1 = *17 !!
			lea	dseq_addData,a0
			move.b	(a0,d0),dseq_actseqlen(a5)
			bsr	refresh_dseqbytelen
			jmp	refresh_dseqlenslider
;--------------------------------------------------------------------
DSEQ_seqnrADD		addq.b	#1,dseq_actseq(a5)
			and.b	#$f,dseq_actseq(a5)
			bra.b	dseq_seqnrentrance
;--------------------------------------------------------------------
DSEQ_seqnrSUB		subq.b	#1,dseq_actseq(a5)
			and.b	#$f,dseq_actseq(a5)
			bra.b	dseq_seqnrentrance
;--------------------------------------------------------------------
DSEQ_seqlenChange:	move	#gad_drumseqlen,lastdownID(a5)
			move.b	$19(a0),dseq_actseqlen(a5)
			bsr.b	dseq_seqnrStoreChange
			bsr	refresh_dseqbytelen
			jmp	refresh_dseqlenslider
DSEQ_seqlenChangeNOW:
			move.b	$19(a0),dseq_actseqlen(a5)
			bsr.b	dseq_seqnrstorechange
			jsr	refresh_dseqlenslider
			bsr	refresh_dseqbytelen
			bra	dseq_mmm
dseq_seqnrStoreChange
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl.b	#4,d0	; *16
			add.b	d1,d0	; +1 = *17 !!
			lea	dseq_addData,a0
			move.b	dseq_actseqlen(a5),(a0,d0)
			rts
;--------------------------------------------------------------------
DSEQ_seqlenADD		addq.b	#1,dseq_actseqlen(a5)
			cmp.b	#48,dseq_actseqlen(a5)
			bne.b	.not
			clr.b	dseq_actseqlen(a5)
.not			bsr.b	dseq_seqnrStoreChange
			jmp	refresh_dseqlenslider
;--------------------------------------------------------------------
DSEQ_seqlenSUB		subq.b	#1,dseq_actseqlen(a5)
			bpl.b	.not
			move.b	#47,dseq_actseqlen(a5)
.not			bsr.b	dseq_seqnrStoreChange
			jmp	refresh_dseqlenslider
;--------------------------------------------------------------------
DSEQ_deleteSEQ		lea	dseq_patterns,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a0,d0),a0
			moveq	#0,d0
			moveq	#(24*16/4)-1,d7
.clr			move.l	d0,(a0)+
			dbf	d7,.clr

			lea	dseq_adddata,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	(a0,d0),a0
			rept	17
			clr.b	(a0)+
			endr
			jsr	refresh_dseqwavegadgets
			bsr	dseq_correctSeqlen
			bra	dseq_printpatterns
;--------------------------------------------------------------------
DSEQ_copySEQ2buf	lea	dseq_patterns,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a0,d0),a0
			lea	dseq_buf,a1
			moveq	#(24*16/4)-1,d7
.clr			move.l	(a0)+,(a1)+
			dbf	d7,.clr

			lea	dseq_adddata,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	(a0,d0),a0
			lea	dseq_addbuf,a1
			rept	17
			move.b	(a0)+,(a1)+
			endr
			rts
;--------------------------------------------------------------------
DSEQ_cutSEQ2buf		lea	dseq_patterns,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a0,d0),a0
			lea	dseq_buf,a1
			moveq	#0,d0
			moveq	#(24*16/4)-1,d7
.clr			move.l	(a0)+,(a1)+
			move.l	d0,-4(a0)
			dbf	d7,.clr

			lea	dseq_adddata,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	(a0,d0),a0
			lea	dseq_addbuf,a1
			rept	17
			move.b	(a0)+,(a1)+
			clr.b	-1(a0)
			endr
			jsr	refresh_dseqwavegadgets
			bsr	dseq_correctSeqlen
			bra	dseq_printpatterns
;--------------------------------------------------------------------
DSEQ_copybuf2SEQ	lea	dseq_patterns,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a0,d0),a0
			lea	dseq_buf,a1
			moveq	#(24*16/4)-1,d7
.clr			move.l	(a1)+,(a0)+
			dbf	d7,.clr

			lea	dseq_adddata,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	(a0,d0),a0
			lea	dseq_addbuf,a1
			rept	17
			move.b	(a1)+,(a0)+
			endr
			jsr	refresh_dseqwavegadgets
			jsr	dseq_correctSeqlen
			jmp	dseq_printpatterns
;------------------------------------------------------------------------
ActivateDSEQwavenr	move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_dseqoptions0_2*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
dseq_wfc_ch0		moveq	#0,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch1		moveq	#1,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch2		moveq	#2,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch3		moveq	#3,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch4		moveq	#4,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch5		moveq	#5,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch6		moveq	#6,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch7		moveq	#7,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch8		moveq	#8,d3
			bra.b	dseq_waveformchange
dseq_wfc_ch9		moveq	#9,d3
			bra.b	dseq_waveformchange
dseq_wfc_cha		moveq	#10,d3
			bra.b	dseq_waveformchange
dseq_wfc_chb		moveq	#11,d3
			bra.b	dseq_waveformchange
dseq_wfc_chc		moveq	#12,d3
			bra.b	dseq_waveformchange
dseq_wfc_chd		moveq	#13,d3
			bra.b	dseq_waveformchange
dseq_wfc_che		moveq	#14,d3
			bra.b	dseq_waveformchange
dseq_wfc_chf		moveq	#15,d3

dseq_waveformChange
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0	; *16	(1byte waveform,1byte note)
			add	d1,d0	; +1 = *17 !! (1byte für seqlen)
			lea	dseq_addData,a0
			lea	1(a0,d3),a0

			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d2		; LongInt
			subq.b	#1,d2
			and.b	#63,d2
			move.b	d2,(a0,d0)
			jmp	refresh_dseqwavegadgets
;--------------------------------------------------------------------
DSEQ_enterSEQnote
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			move.l	#txt_dseqenternote,$20(a0)
			move.l	$3e(a0),d7	; gadgets sollen nicht mit
			clr.l	$3e(a0)		; refresht werden
			move.l	a0,d6
			jsr	int_refreshwindowframe(a6)
			move.l	d6,a0
			move.l	d7,$3e(a0)	; zeiger auf 1st gadget zurück

.waitmsg		move.l	userport2(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			bra.b	.waitmsg
.MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#rawkey,$14(a0)
			bne.b	.waitmsg

			moveq	#0,d0
			move	$18(a0),d0	; ScanCode
			swap	d0
			move.b	$1b(A0),d0
			swap	d0

			tst.b	octave(a5)
			beq.b	.octave00
			cmp.b	#1,octave(a5)
			beq.b	.octave0
			lea	ne_raw2notetab_oct1,a1
			bra.b	.octave1
.octave0		lea	ne_raw2notetab_oct0,a1
			bra.b	.octave1
.octave00		lea	ne_raw2notetab_oct00,a1
.octave1
			tst	(a1)		; endmark??
			bmi	.waitmsg
			cmp.l	(a1),d0		; compare rawkeycode
			beq.b	.found
			addq.l	#8,a1
			bra.b	.octave1
.found			move.l	4(a1),d3

; d1=note
.enterit
			move.b	d3,dseq_pitch(a5)
	
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			move.l	#dseq_windowtitle,$20(a0)
			jsr	int_refreshwindowframe(a6)

			bsr	refresh_dseqpitch
			bra	refresh_dseqbytelen
;--------------------------------------------------------------------
refresh_dseqpitch
			movem.l	d0-a6,-(sp)
			lea	txt_notes,a3
			move.l	intbase(a5),a6

			move.l	rastport2(a5),a0
			lea	.itext(pc),a1
			moveq	#0,d0
			move.b	dseq_pitch(a5),d0
			add	d0,d0
			add	d0,d0
			move.l	(a3,d0),.text-.itext(a1)
			clr.b	(.text-.itext)+3(a1)
			move.l	#104-12,d0
			move.l	#gyoff+ghi*16+1,d1
			jsr	int_printitext(a6)

			movem.l	(sp)+,d0-a6
			rts
.itext			dc.b	1,0,0
			even
			dc	2
			dc	2
			dc.l	0
			dc.l	.text
			dc.l	0
.text			dc.b	"---",0
;------------------------------------------------------------------------
ActivateDSEQspeed	move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_dseqspeed*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
dseq_speedchange	move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			beq.b	.2big
			cmp	#31,d0
			bgt.b	.2big
			move.b	d0,dseq_speed(a5)
.2big			bsr	refresh_dseqbytelen
			bra	refresh_dseqspeed
;------------------------------------------------------------------------
ActivateDSEQtempo	move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_dseqtempo*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
dseq_tempochange	move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			beq.b	.2big
			cmp	#250,d0
			bgt.b	.2big
			cmp	#32,d0
			blt.b	.2big
			move.b	d0,dseq_tempo(a5)
.2big			bsr	refresh_dseqbytelen
			bra	refresh_dseqtempo
;------------------------------------------------------------------------
ActivateDSEQwave	move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_dseqdestwave*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
dseq_destwavechange	move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			beq.b	.2big
			subq.b	#1,d0
			and.b	#63,d0
			move.b	d0,dseq_destwave(a5)
.2big			bra	refresh_dseqdestwave
;--------------------------------------------------------------------
DSEQ_computedata
			moveq	#0,d0
			move.l	#70100,d2		; feststellen,wieviele
			moveq	#0,d1			; bytes pro step be-
			move.b	dseq_speed(a5),d1	; rechnet werden
			subq	#1,d1
.shitmulu		add.l	d2,d0
			dbf	d1,.shitmulu

			moveq	#0,d1
			move.b	dseq_pitch(a5),d1
			subq.b	#1,d1
			lea	aon_periods,a0
			add	d1,d1
			move	(a0,d1),d1		; d1=periode
			move	d1,dseq_destper(a5)	; c-1 bis b-5

			moveq	#0,d2
			move.b	dseq_tempo(a5),d2
			mulu	d2,d1
			divu	#125,d1
			and.l	#$ffff,d1
			divu	d1,d0
			and.l	#$ffff,d0
; d0=Bytes per step
			move.l	d0,dseq_bytesperstep(a5)
							; anzahl samples/step
			moveq	#0,d1
			move.b	dseq_actseqlen(a5),d1
			addq.b	#1,d1
			mulu	d1,d0
; d0=Bytelänge der gesamten sequenz (8 bit !!)
			move.l	d0,dseq_bytelen(a5)
			rts
;--------------------------------------------------------------------
	rem
 Berechnungsroutine:
 -Feststellen,wieviele Bytes/Step

	erem

DSEQ_computenow
			bsr	dseq_computedata
; alte wellenform freigeben
			move.l	exec,a6
			moveq	#0,d0
			move.b	dseq_destwave(a5),d0
			add	d0,d0
			add	d0,d0	; .l size
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a4
			lea	(a3,d0),a3
			lea	(a4,d0),a4
			move.l	(a4),d0
			beq.b	.emptywave	; wir wolla ma nich abstürzen!
			move.l	d0,a1
			jsr	exec_freevec(a6)
			clr.l	(a3)		; waveform-länge löschen
.emptywave
			move.l	dseq_bytelen(a5),d0	 DESTWAVE!!!!!!!!!!!!!
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1
			bra.b	.8ch
.4ch			move.l	#$10000+memf_chip,d1		; sonst kommt die dma
.8ch			jsr	exec_allocvec(a6)	; nicht ran!
			move.l	d0,(a4)		; wavestart merken
			bne.b	.theresawave	; kein speicher frei ?!?!
			lea	msg_dseq_nowave8,a2
			jmp	displaymessage2
.theresawave
			move.l	d0,dseq_chipwaveadr(a5)
			move.l	dseq_bytelen(a5),d0	 WORKWAVE!!!!!!!!!!!!!
			move.l	d0,(a3)			; wavelen merken
			add.l	d0,d0			; .w size da 16 bit
			move.l	#$10000+memf_public,d1	; im fast läßt sichs
			jsr	exec_allocvec(a6)	; besser rechnen!
			move.l	d0,dseq_workwaveadr(a5)	; adr merken!
			bne.b	.theresAwave2	; kein speicher frei ?!?!
			lea	msg_dseq_nowave16,a2
			jmp	displaymessage2
.theresawave2
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0	; *16	(1byte waveform)
			add	d1,d0	; +1 = *17 !! (1byte für seqlen)
			lea	dseq_addData,a0
			lea	1(a0,d0),a0	; sequenzlänge überspringen

			lea	dseq_wave1data(a5),a1
			lea	module_wavelenlist,a2
			lea	aon_wavestarts+aon_data,a3
			moveq	#16-1,d7
.searchwavedata
			moveq	#0,d0
			move.b	(a0)+,d0	; wave-nr
			add	d0,d0
			add	d0,d0
			move.l	(a3,d0),(a1)	; wave-adr
			tst.l	(a1)		; waveadr=0?!?
			beq.b	.choff
			move.l	(a2,d0),4(a1)	; wave-len
			bra.b	.waveok
.choff			clr.l	(a1)
			clr.l	4(a1)
.waveok
			addq.l	#8,a1
			dbf	d7,.searchwavedata

dseq_makewave
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#24*16,d0
			lea	dseq_patterns,a0
			lea	(a0,d0),a0	; a3=zeiger auf patterns

			lea	iobuffer,a3
			move.l	a3,-(sp)
			move	#24*16-1,d7
.convertnibbles2bytes	move.b	(a0)+,d0
			move.b	d0,d1
			lsr.b	#4,d0
			move.b	d0,(a3)+
			and.b	#$f,d1
			move.b	d1,(a3)+
			dbf	d7,.convertnibbles2bytes
			move.l	(sp)+,a3

			lea	dseq_wave1data(a5),a6
; aufbau datenstruktur a6:	+0	.l	zeiger auf waveform
;				+4	.l	länge der waveform in bytes

			moveq	#16-1,d7	; 16 kanäle
.mainloop
		move.l	dseq_workwaveadr(a5),a4	; zeiger auf destwave 16bit
			move.l	a3,a0		; workpatternzeiger

			move.l	dseq_bytesperstep(a5),d5

			moveq	#-1,d4		; waveformbyteoffset -1=fertig
			move.l	(a6),a2		; adr der wellenform
			cmp.l	#0,a2		; kanal überspringen wenn
			beq	.nextchannel	; keine wellenform da ist

			moveq	#0,d6
			move.b	dseq_actseqlen(a5),d6
; d4=waveform byteoffset
; d5=bytes per step
; d6=anzahl der steps (bereits -1 , also dbf schleifenmäßig!)
; a0=Work-zeiger auf patterns
; a2=Zeiger auf wellenform
; a3=Zeiger auf patterns
; a4=Zeiger auf destwave (16 bit!)
; a6=zeiger auf wavedaten

.innerloop
			moveq	#0,d0
			move.b	(a0)+,d0	; get volume byte
			beq.b	.skipstep
			subq.b	#1,d0

			lea	dseq_volbytetab,a1
			lsl	#8,d0
			lea	(a1,d0),a1
			moveq	#0,d4		; ready to rock
						; neuanschlag des instruments
			bra.b	.mixwords
; /* step unbenutzt */
.skipstep		tst.l	d4		; noch keine note angeschlagen?
			bpl.b	.mixwords	; doch, also weitermixen
.addstepbytes		lea	(a4,d5),a4	; step einfach überspringen
			lea	(a4,d5),a4	; wegen 16 bit !!
			bra.b	.nextstep	; (optimierung)
.mixwords
			move.l	d5,d1		; bytesperstep
			subq	#1,d1		; -1 wegen dbf schleife
.abgehts		moveq	#0,d0
			move.b	(a2,d4.l),d0
			move.b	(a1,d0),d0	; *lautstärke!!!
			ext	d0		; auf .w erweitern
			add	d0,(a4)+	; und zur destwave mischen
			addq.l	#1,d4
			cmp.l	4(a6),d4	; wavesize in bytes
			bne.b	.notwaveend
			moveq	#-1,d4		; flag für waveend setzen
			lea	(a4,d1),a4	; + restlichen bytes des steps
			lea	(a4,d1),a4	; 2* da wordsize
			bra.b	.nextstep
.notwaveend		dbf	d1,.abgehts
.nextstep		dbf	d6,.innerloop
.nextchannel		addq.l	#8,a6		; nächste wavedaten
			lea	48(a3),a3	; nächste patternzeile
			dbf	d7,.mainloop

; jetzt die lauteste stelle in der sequenz heraussuchen
dseq_compsearchloudest
			move.l	dseq_workwaveadr(a5),a0
			moveq	#0,d1
			move.l	dseq_bytelen(a5),d7
.loop			move	(a0)+,d0
			bpl.b	.ok1
			neg	d0
.ok1			cmp	d0,d1
			bgt.b	.old
			move	d0,d1
.old			subq.l	#1,d7
			bne.b	.loop
; d1=Maximale amplitude
			move.l	#$8000*32,d0
			tst.l	d1
			bne.b	.hiho
			moveq	#0,d0
			bra.b	.hihi
.hiho			divu	d1,d0
			and.l	#$ffff,d0
.hihi			move.l	d0,d1

			move.l	dseq_workwaveadr(a5),a0
						   ; volume boosten um maximale
			move.l	dseq_bytelen(a5),d7	; amplitude auszunutzen
.boost			moveq	#0,d0
			move	(a0),d0
			muls	d1,d0
			asr.l	#5,d0
			move	d0,(a0)+
			subq.l	#1,d7
			bne.b	.boost
dseq_compConvert8bit
			move.l	dseq_workwaveadr(a5),a0
			move.l	dseq_chipwaveadr(a5),a1
			move.l	dseq_bytelen(a5),d7
.loop			move	(a0)+,d0
			asr	#8,d0
			move.b	d0,(a1)+
			subq.l	#1,d7
			bne.b	.loop

			move.l	dseq_workwaveadr(a5),a1	; workmem wieder freigeben
			move.l	exec,a6
			jsr	exec_freevec(a6)

			move.b	dseq_destwave(a5),dseq_adjWAVE
			move.l	dseq_bytelen(a5),dseq_adjLEN

;			bra.b	dseq_okadjustwavelens
;
;dseq_adjustwavelens:
;			clr.b	win2_override(a5)
;			move.l	intbase(a5),a6		; Warn-Requester
;			move.l	window2ptr(a5),a0	; ausgeben
;			lea	adjust_str,a1
;			sub.l	a2,a2
;			sub.l	a3,a3
;			jsr	int_easyrequestARGS(a6)
;			move.b	#1,win2_override(a5)
;
;			tst.l	d0
;			bne.b	dseq_okadjustwavelens
;			rts
dseq_okadjustwavelens:
			moveq	#0,d0
			move.b	dseq_adjwave(pc),d0
			move.l	dseq_adjlen(pc),d1
			lsr.l	#1,d1
			moveq	#0,d2
			moveq	#0,d3
			cmp.l	#65535,d1
			ble.b	.small
			move.l	#65536,d2
			move.l	d1,d3
			sub.l	#65535,d3
			move.l	#65535,d1
.small

			lea	module_instruments,a0
			moveq	#62-1,d7
.instrloop		tst.b	instr_control(a0)
			bne.b	.nextone
			cmp.b	instr_waveform(a0),d0
			bne.b	.nextone
			tst.l	sample8_dmalen(a0)
			beq.b	.nextone
			move.l	d1,sample8_dmalen(a0)
; Check loop-sizes
			tst.l	sample8_dmarepoffset(a0)
			bne.b	.rep0k
			cmp.l	sample8_dmareplen(a0),d1
			bgt.b	.rep0k
			move.l	d1,sample8_dmareplen(a0)	; Begrenzen
			bra.b	.nextone
.rep0k
			cmp.l	sample8_dmarepoffset(a0),d1
			bgt.b	.repoffsetOK
			clr.l	sample8_dmarepoffset(a0)
			clr.l	sample8_dmareplen(a0)
			bra.b	.nextone
.repoffsetOK
			move.l	sample8_dmarepoffset(a0),d0
			add.l	sample8_dmareplen(a0),d0
			cmp.l	d1,d0
			ble.b	.replenOK
			move.l	d1,d0
			sub.l	sample8_dmarepoffset(a0),d0
			move.l	d0,sample8_dmareplen(a0)
.replenOK
.nextone		lea	32(a0),a0
			dbf	d7,.instrloop

			jmp	refresh_instrumentED
dseq_adjWAVE		dc.l	0
dseq_adjLEN		dc.l	0
;--------------------------------------------------------------------
REFRESH_DSEQBYTELEN	bsr	dseq_computedata
			move.l	dseq_bytelen(a5),rog_taglist+4
			moveq	#gad_dseqbytelen,d0
			jmp	refresh_number_kind3
;--------------------------------------------------------------------
DSEQ_SAVESEQUENCE
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage2
			else

			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	dseqreqptr(a5),a1
			lea	dseq_filename,a2
			tst.b	(a2)
			bne.b	.not
			move.l	#".dse",(a2)
			move.b	#"q",4(a2)
.not
			lea	dseq_savesequenceTitle,a3
			lea	mod_filereqTAGS2,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	dseqreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	dseq_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.fileopened
			lea	msg_io_filenotfound,a2
			jmp	displaymessage2
.fileopened
			move.l	#"DSEQ",iobuffer
			move.l	#iobuffer,d2
			moveq	#4,d3
			write1		; speed,tempo&pitch

			lea	iobuffer,a0
			move.b	dseq_speed(a5),(a0)
			move.b	dseq_tempo(a5),1(a0)
			move.b	dseq_pitch(a5),2(a0)
			clr.b	3(a0)
			move.l	a0,d2
			moveq	#4,d3
			write1		; speed,tempo&pitch

			lea	iobuffer,a0
			move.l	a0,d2
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	dseq_adddata,a1
			lea	1(a1,d0),a1
			move.l	a1,-(sp)
			lea	module_wavelenlist,a2
			lea	aon_wavestarts+aon_data,a3
			move.l	a0,a4
			moveq	#16-1,d7
.clrallwaves		clr.l	64(a4)
			clr.l	(a4)+
			dbf	d7,.clrallwaves

			moveq	#16-1,d7
.searchlens		moveq	#0,d0
			move.b	(a1)+,d0	; wavenr. holen
			add	d0,d0
			add	d0,d0
			move.l	(a3,d0),64(a0)	; waveadr.
			lea	iobuffer,a4
			move.l	(a2,d0),d0	; kommt diese wellenform
			moveq	#16-1,d1	; schon einmal vor ?!
.searchdoublelen	cmp.l	(a4)+,d0
			beq.b	.clrwavelen
			dbf	d1,.searchdoublelen
			bra.b	.newwave
.clrwavelen		moveq	#0,d0
.newwave		move.l	d0,(a0)+	; länge saven
			dbf	d7,.searchlens

			move.l	(sp)+,a4
			moveq	#16*4,d3
			write1			; Wavelängen speichern

			subq.l	#1,a4
			move.l	a4,d2
			moveq	#17,d3
			write1			; Additional sequencedata

			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#384,d0
			lea	dseq_patterns,a0
			lea	(a0,d0),a0
			move.l	a0,d2
			move	#24*16,d3
			write1			; Sequencepattern

			lea	iobuffer,a4
			moveq	#16-1,d7
.savewaves
			move.l	64(a4),d2
			move.l	(a4)+,d3	; länge
			beq.b	.savenext
			write1			; Additional sequencedata

.savenext		dbf	d7,.savewaves
			closefile

.ioerror		move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			lea	msg_io_fileerror,a2
			jmp	displaymessage2
			endif
;--------------------------------------------------------------------
DSEQ_LOADSEQUENCE
			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	dseqreqptr(a5),a1
			lea	dseq_filename,a2
			lea	dseq_loadsequenceTITLE,a3
			lea	mod_filereqTAGS2,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	dseqreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	dseq_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.fileopened
			lea	msg_io_filenotfound,a2
			jmp	displaymessage2
.fileopened
			move.l	#iobuffer,d2
			moveq	#4,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi	.ioerror

			cmp.l	#"DSEQ",iobuffer
			beq.b	.okcheck
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			lea	msg_dseq_wrongformat,a2
			jmp	displaymessage2
.okcheck

			move.l	#iobuffer,d2
			moveq	#4,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi	.ioerror

			move.b	iobuffer,dseq_speed(a5)
			move.b	iobuffer+1,dseq_tempo(a5)
			move.b	iobuffer+2,dseq_pitch(a5)

			move.l	#iobuffer,d2
			moveq	#64,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi	.ioerror

			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0
			add	d1,d0	; *17
			lea	dseq_adddata,a0
			lea	(a0,d0),a0
			move.l	a0,d2
			move.l	d2,d7
			moveq	#17,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi.w	.ioerror

			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move.l	#384,d3
			mulu	d3,d0
			move.l	#dseq_patterns,d2
			add.l	d0,d2
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi.b	.ioerror

			lea	iobuffer,a4	; zeiger auf wavelens
			move.l	d7,a3		; zeiger auf adddata
			addq.l	#1,a3
			moveq	#16-1,d7
.loadwaves		moveq	#0,d0
			move.b	(a3)+,d0	; wavenr.
			move.l	(a4)+,d1	; wavesize in bytes
			beq.b	.loadnextwave
			jsr	freewave	; speicher frei
; d0=(immer noch) wavenr. d1=(immer noch) wavesize in bytes
			jsr	allocwave
; d0=adresse der wellenform,falls sie allokiert werden konnte
			tst.l	d0
			beq.b	.nowavemem
			move.l	d0,d2
			move.l	d1,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi.b	.ioerror
.loadnextwave		dbf	d7,.loadwaves

			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_refreshwindowframe(a6)

			bsr	dseq_correctSeqlen
			bsr	dseq_printpatterns
			bsr	refresh_dseqspeed
			bsr	refresh_dseqtempo
			bsr	refresh_dseqpitch
			bra	refresh_dseqwavegadgets

.ioerror		move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			lea	msg_io_fileerror,a2
			jmp	displaymessage2
.nowavemem		move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			lea	msg_sys_cantloadwave,a2
			jmp	displaymessage2

;--------------------------------------------------------------------
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a5
;--------------------------------------------------------------------
dseq_exitnow		addq.l	#8,sp
			bra	dseq_exitfree
;--------------------------------------------------------------------
dseq_delnotes		lea	dseq_patterns,a0
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			mulu	#48/2*16,d0
			lea	(a0,d0),a0
			moveq	#0,d0
			moveq	#(24*16/4)-1,d7
.clr			move.l	d0,(a0)+
			dbf	d7,.clr

			bra	dseq_printpatterns
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------

;************************************************************************
; 	        I N S T R U M E N T E N   _   E D I T O R   _
INSTRUMENTED:
			move.b	#1,screen(a5)
			clr.b	patteditstatus(a5)
			move.b	#1,winwave_override(a5)
			jsr	waveed_setshowall
			jsr	refresh_instrumentED


; Mainloop-----------------------
instred_mmm
.mmm			move.l	userportwave(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.m_messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			jsr	printnewpatterns
			jsr	adjust_pattdisplay
			bra.b	.mmm
.m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#rawkey,$14(a0)
			beq	instred_keypressed

			cmp.l	#mousemove,$14(a0)
			bne.w	.not
			cmp	#gad_instrchangeinstrnr,lastdownid(a5)
			beq	instred_instrnrchangeNOW
			cmp	#gad_instrchangevolume,lastdownid(a5)
			beq	instred_volumechangeNOW
			cmp	#gad_instrchangefinetune,lastdownid(a5)
			beq	instred_finetunechangeNOW
			cmp	#gad_instrchangewavenr,lastdownid(a5)
			beq	instred_waveformchangeNOW
			cmp	#gad_instrchangesampleoffset,lastdownid(a5)
			beq	instred_sampleoffsetchangeNOW
			cmp	#gad_instrchangesamplelen,lastdownid(a5)
			beq	instred_sampleLenchangeNOW
			cmp	#gad_instrchangerepeatoffset,lastdownid(a5)
			beq	instred_repeatoffsetchangeNOW
			cmp	#gad_instrchangerepeatlen,lastdownid(a5)
			beq	instred_repeatLenchangeNOW
;		cmp	#gad_instrchangeCopyFrom,lastdownid(a5)
;		beq	instred_copyfromChangeNOW
;		cmp	#gad_instrchangeCopyTo,lastdownid(a5)
;		beq	instred_copyToChangeNOW

;		cmp	#gad_wavechangewave,lastdownID(a5)
;		beq	waveed_waveChangeNOW
			cmp	#gad_wavechangepos,lastdownID(a5)
			beq	waveed_posChangeNOW
;		cmp	#gad_wavechangecopyfrom,lastdownID(a5)
;		beq	waveed_copyfromChangeNOW
;		cmp	#gad_wavechangecopyto,lastdownID(a5)
;		beq	waveed_copytoChangeNOW
			cmp	#gad_wavepartwave,lastdownID(a5)
			beq	waveed_partwaveChangeNOW

.not
			tst.b	freemode(A5)
			bne.b	.on
			cmp.l	#mousebuttons,$14(a0)
			beq	waveed_rangemark
.on			cmp.l	#mousebuttons,$14(a0)
			beq	waveed_freestyle

			cmp.l	#intuiticks,$14(a0)
			beq	instred_intuiticks

			cmp.l	#inactiveWindow,$14(a0)
			beq	instred_inactivated

			moveq	#0,d3
			cmp.l	#gadgetup,$14(a0)
			beq.b	.yoman
			moveq	#4,d3
			cmp.l	#gadgetdown,$14(a0)
			bne.b	.noman
.yoman			bsr	checkgadgetsWave
.noman			bra	.mmm

;--------------------------------------------------------------------
Instred_intuiticks	bsr	blanker
			tst.b	freemode(a5)
			bne	waveed_freestyle
			tst.b	rangemark(a5)
			bne	waveed_markrange
			bra	instred_mmm
;--------------------------------------------------------------------
instred_inactivated
.waitscreen		move.l	dosbase(a5),a6
			moveq	#1,d1
			jsr	dos_delay(a6)

			move.l	intbase(a5),a6
			move.l	int_activescreen(a6),d0
			cmp.l	screenptr2(a5),d0
			beq	instrumented
			cmp.l	screenptr(a5),d0
			beq.b	.checkwindow
			bra.b	.waitscreen
.checkwindow		moveq	#0,d0
			move.b	programmode(a5),d0
			cmp.b	#pattedit,d0
			beq	patterned
			cmp.b	#arpedit,d0
			beq	arpeded
			cmp.b	#drumseq,d0
			beq	dseqed
			cmp.b	#setup,d0
			beq	setupeded
			cmp.b	#fmsynthed,d0
			beq	fmeded
			bra	instrumented
;--------------------------------------------------------------------
instred_keypressed
			moveq	#0,d0
			move	$18(a0),d0	; ScanCode
			swap	d0
			move.b	$1b(A0),d0
			swap	d0
			move.l	d0,scancode(a5)
			jsr	check_for_keys2
			bra	instred_mmm
;--------------------------------------------------------------------
; out: a0=Pointer on actual instrument
Instred_actualdata	move.l	d0,-(sp)
			moveq	#0,d0
			move	acteditinstr(a5),d0
			add	d0,d0
			add	d0,d0
			lea	aon_data+aon_instrstarts,a0
			move.l	(a0,d0.l),a0
			move.l	(sp)+,d0
			rts
;--------------------------------------------------------------------
instred_InstrNrChange	move	#gad_instrchangeinstrnr,lastdownID(a5)
			move	$18(a0),acteditinstr(a5)
			jsr	setnewwave
			jsr	refresh_instrument
			bra	Refresh_BaseInstrument
instred_InstrNrChangeUP
			move	$18(a0),acteditinstr(a5)
			move	lastdownID(a5),d0
			clr	lastdownID(a5)
			jsr	setnewwave
			bsr	waveed_setshowall
			jsr	refresh_instrument
			bra	Refresh_instrumented
instred_InstrNrChangeNOW
			move	$18(a0),acteditinstr(a5)
			jsr	setnewwave
			jsr	refresh_instrument
			bsr	Refresh_BaseInstrument
			bra	instred_mmm
;--------------------------------------------------------------------
instred_VolumeChange	move	#gad_instrchangevolume,lastdownID(a5)
instred_VolumeChangeUP	move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),instr_volume(a0)
			bra	refresh_instredvolumeslider
instred_VolumeChangeNOW
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),instr_volume(a0)
			bsr	refresh_instredvolumeslider
			bra	instred_mmm
;--------------------------------------------------------------------
instred_FineTuneChange	move	#gad_instrchangefinetune,lastdownID(a5)
instred_FinetuneChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	$19(a1),d0
			lea	finetuneback_tab,a1
			move.b	(a1,d0),instr_finetune(a0)
			bra	refresh_instredfinetuneslidertxt
instred_FinetuneChangeNOW
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	$19(a1),d0
			lea	finetuneback_tab,a1
			move.b	(a1,d0),instr_finetune(a0)
			bsr	refresh_instredfinetuneslidertxt
			bra	instred_mmm
;--------------------------------------------------------------------
instred_waveformChange	move	#gad_instrchangewavenr,lastdownID(a5)
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),instr_waveform(a0)
			jsr	setnewwave
			bra	refresh_instredwaveformslider
instred_waveformChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),instr_waveform(a0)
			move	lastdownID(a5),d0
			clr	lastdownID(a5)
			jsr	setnewwave
			bra	refresh_instrumented
instred_waveformChangeNOW
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),instr_waveform(a0)
			jsr	setnewwave
			bsr	refresh_instredwaveformslider
			bra	instred_mmm
;------------------------------------------------------------------------
instred_samplelenChange	move.l	$22(a1),a1
			move.l	$1c(a1),d0
			lsr.l	#1,d0
			bsr	instred_actualdata
			moveq	#0,d2
			move.b	instr_waveform(a0),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a2
			move.l	(a2,d2),d2		; d2=max wavelen
			lsr.l	#1,d2			; auf worte
			move.l	sample8_dmaoffset(a0),d1
			sub.l	d1,d2	; d2=maximal mögliche wavelen
			bpl.b	.ok
			clr.l	sample8_dmaoffset(a0)
.ok
			cmp.l	d0,d2
			bgt.b	.nottoolong
			tst.l	d2
			bpl.b	.ok2
			moveq	#0,d2
.ok2			cmp.l	#$ffff,d2
			ble.b	.ok4
			move.l	#$ffff,d2
.ok4			move.l	d2,sample8_dmalen(a0)
			bra.b	.set
.nottoolong		tst.l	d0
			bpl.b	.ok3
			moveq	#0,d0
.ok3			cmp.l	#$ffff,d0
			ble.b	.ok5
			move.l	#$ffff,d0
.ok5			move.l	d0,sample8_dmalen(a0)
.set
			bsr	refresh_instredsampleoffset
			bra	refresh_instredsamplelen
;--------------------------------------------------------------------
instred_playoff		clr.b	replaystatus(a5)
			jmp	equ_resetchannels
;------------------------------------------------------------------------
instred_sampleoffsetChange
			move.l	$22(a1),a1
			move.l	$1c(a1),d0
			lsr.l	#1,d0
			bsr	instred_actualdata
			moveq	#0,d2
			move.b	instr_waveform(a0),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a2
			move.l	(a2,d2),d2		; d2=max wavelen
			lsr.l	#1,d2			; auf worte
			move.l	sample8_dmalen(a0),d1
			sub.l	d1,d2	; d2=maximal möglicher waveoffset
			bpl.b	.ok
			clr.l	sample8_dmalen(a0)
.ok
			cmp.l	d0,d2
			bgt.b	.nottoolong
			tst.l	d2
			bpl.b	.ok2
			moveq	#0,d2
.ok2			move.l	d2,sample8_dmaoffset(a0)
			bra.b	.set
.nottoolong		tst.l	d0
			bpl.b	.ok3
			moveq	#0,d0
.ok3			move.l	d0,sample8_dmaoffset(a0)
.set
			bsr	refresh_instredsampleoffset
			bra	refresh_instredsamplelen

;------------------------------------------------------------------------
instred_repeatlenChange	move.l	$22(a1),a1
			move.l	$1c(a1),d0
			lsr.l	#1,d0
			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	.sample
			cmp	#255,d0
			bgt.b	.set
			move.b	d0,synth8_partwaveDmaLen(a0)
			bra.b	.set
.sample
			moveq	#0,d2
			move.b	instr_waveform(a0),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a2
			move.l	(a2,d2),d2		; d2=max wavelen
			lsr.l	#1,d2			; auf worte
			move.l	sample8_dmarepoffset(a0),d1
			sub.l	d1,d2	; d2=maximal mögliche wavelen
			bpl.b	.ok
			clr.l	sample8_dmarepoffset(a0)
.ok
			cmp.l	d0,d2
			bgt.b	.nottoolong
			tst.l	d2
			bpl.b	.ok2
			moveq	#0,d2
.ok2			move.l	d2,sample8_dmareplen(a0)
			bra.b	.set
.nottoolong		tst.l	d0
			bpl.b	.ok3
			moveq	#0,d0
.ok3			move.l	d0,sample8_dmareplen(a0)
.set
			bsr	setnewrepeat
			bsr	refresh_instredrepeatoffset
			bra	refresh_instredrepeatlen
;--------------------------------------------------------------------
SETNEWREPEAT:		movem.l	d0-a6,-(sp)
			bsr	getchanneloff
			move.l	a4,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	aon_wavestarts+aon_data,a2
			move.l	sample8_dmarepoffset(a0),d2
			add.l	d2,d2
			add.l	(a2,d0.l),d2
			move	sample8_dmareplen+2(a0),d0
			bmi.b	.not
			beq.b	.not
			move	d0,aon_replen(a1)
			move.l	d2,aon_repeatstrt(a1)
.not			movem.l	(sp)+,d0-a6
			rts
;------------------------------------------------------------------------
instred_repeatoffsetChange
			move.l	$22(a1),a1
			move.l	$1c(a1),d0
			lsr.l	#1,d0
			bsr	instred_actualdata
			moveq	#0,d2
			move.b	instr_waveform(a0),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a2
			move.l	(a2,d2),d2		; d2=max wavelen
			lsr.l	#1,d2			; auf worte
			move.l	sample8_dmareplen(a0),d1
			sub.l	d1,d2	; d2=maximal mögliche wavelen
			bpl.b	.ok
			clr.l	sample8_dmareplen(a0)
.ok
			cmp.l	d0,d2
			bgt.b	.nottoolong
			tst.l	d2
			bpl.b	.ok2
			moveq	#0,d2
.ok2			move.l	d2,sample8_dmarepoffset(a0)
			bra.b	.set
.nottoolong		tst.l	d0
			bpl.b	.ok3
			moveq	#0,d0
.ok3			move.l	d0,sample8_dmarepoffset(a0)
.set
			bsr	setnewrepeat
			bsr	refresh_instredrepeatoffset
			bra	refresh_instredrepeatlen
;--------------------------------------------------------------------
;instred_drawwave
;			bsr	instred_clrwavedisplay
;			bsr	instred_actualdata
;			moveq	#0,d2
;			move.b	instr_waveform(a0),d2
;			add	d2,d2
;			add	d2,d2
;			lea	module_wavelenlist,a1
;			move.l	(a1,d2.l),d0		; d0=wavelen
;			lea	aon_wavestarts+aon_data,a1
;			move.l	(a1,d2.l),a1
;
;; a1=Zeiger auf wavedaten
;; d0=Länge der wavedaten in bytes
 ;
;			tst.l	d0
;			bne.b	.notwaveempty
;
;			move.l	bitplane1_startadr2(a5),a4
;			lea	174*80+2(a4),a4
;			lea	gfx_waveempty,a0
;			move.l	(a0)+,0*80(a4)
;			move.l	(a0)+,1*80(a4)
;			move.l	(a0)+,2*80(a4)
;			move.l	(a0)+,3*80(a4)
;			move.l	(a0)+,4*80(a4)
;			move.l	(a0)+,5*80(a4)
;			move.l	(a0)+,6*80(a4)
;			move.l	(a0)+,7*80(a4)
;			bra	waveed_copytodispbuf
;.notwaveempty
;			movem.l	rastportwave(a5),d7
;
;; Farbregister richtig setzen
;			movem.l	d0-a6,-(sp)
;			move.l	gfxbase(a5),a6
;			move.l	d7,a1
;			moveq	#1,d0
;			jsr	gfx_setapen(a6)
;			movem.l	(sp)+,d0-a6
;; Grafikcursor richtig setzen
;			movem.l	d0-a6,-(sp)
;			move.l	gfxbase(a5),a6
;			move.l	d7,a1
;			moveq	#8,d0
;			move.l	#169+25,d1
;			jsr	gfx_move(a6)
;			movem.l	(sp)+,d0-a6
;
;
;			cmp.l	#$ffff,d0
;			ble.b	.fastdraw
;			move.l	d0,d4
;			move.l	a1,a4
;
;			moveq	#0,d3
;			moveq	#8,d6		; x-cnt
;.drawlinesloop
;			move.l	d4,d0
;			move.l	d3,d1
;			bsr	mulu_l
;			move.l	#640-16,d1
;			bsr	divu_l
;			lea	(a4,d0.l),a1
;
;			moveq	#0,d1
;			move.b	(a1),d1
;			addq	#1,d1
;			neg.b	d1
;			asr.b	#2,d1
;			ext	d1
;			add	#169+25,d1
;			move.l	d6,d0
;			bsr	sysline
;
;			addq	#1,d3
;			addq	#1,d6
;			cmp	#640-8,d6
;			bne	.drawlinesloop
;
;			bra	waveed_copytodispbuf
;.fastdraw
;			swap	d0
;			move.l	#640-16,d1
;			jsr	divu_l
;			moveq	#0,d3
;			move	d0,d3		; addx-add
;			moveq	#0,d4		; addx-counter
;			moveq	#0,d5
;			swap	d0		; byteadd
;			move	d0,d5
;			moveq	#0,d2
;			moveq	#8,d6
;.fastloop
;			moveq	#0,d1
;			move.b	(a1,d2.l),d1
;			addq	#1,d1
;			neg.b	d1
;			asr.b	#2,d1
;			ext	d1
;			add	#169+25,d1
;			move.l	d6,d0
;			bsr	sysline
;			add	d3,d4
;			addx.l	d5,d2
;			addq	#1,d6
;			cmp	#640-8,d6
;			bne	.fastloop
;			bra	waveed_copytodispbuf
;--------------------------------------------------------------------
; IN:	d0=endx
; 	d1=endy
;	d7=rastport
SYSLINE			movem.l	d0-a6,-(sp)
			move.l	gfxbase(a5),a6
			move.l	d7,a1
			jsr	gfx_draw(a6)
			movem.l	(sp)+,d0-A6
			rts
;---------------------------------------------------------------------
; IN:	d0=endx
;	d1=endy
;	d7=rastport
OWNLINE			movem.l	d0-a6,-(sp)
;	move.l	gfxbase(a5),a6
;	jsr	
			move.l	d7,a0
			move	$24(a0),lx1
			move	$26(a0),ly1
			move	d0,$24(a0)
			move	d1,$26(a0)
			move	d0,lx2
			move	d1,ly2
			bsr	tronline
			movem.l	(sp)+,d0-a6
			rts
;---------------------------------------------------------------------

lx1	dc	0
ly1	dc	0
lx2	dc	0
ly2	dc	0
; *******************************************
; * This is one of the fastes Line-Routine. *
; * At the moment without clipping.	    *
; *******************************************
;
;
; This Sources is done by MCM/Complex and improved by Tron/Sanity
;
; 


TronLineInit:
	movem.l	d0-a6,-(sp)
	move.l	gfxbase(a5),a6
	jsr	-456(a6)	; ownblitter
	jsr	-228(a6)	; waitblit

	lea	$dff000,a5
	bsr	InitBlitSizes
	bsr	InitYPosTab
	bsr	InitLine
	movem.l	(sp)+,d0-a6
	rts
TronLine:
	lea	$DFF000,A5
	lea	ypostab(pc),a1
	lea	line_blitsizes(pc),a2

	move.l	bitplane1_startadr2+main_data,a0
	moveq	#0,d0
	moveq	#0,d1
	move	lx1(pc),d0
	move	ly1(pc),d1
	moveq	#0,d2
	moveq	#0,d3
	move	lx2(pc),d2
	move	ly2(pc),d3
	bra	BlitLine

	
InitBlitSizes:
	LEA	LINE_BlitSizes(PC),A0
	MOVEQ	#0,D0
	MOVE.W	#$3FF,D2
.loop
	MOVE	D0,D1
	LSL.W	#6,D1
	ADDQ.W	#2,D1
	MOVE	D1,(A0)+
	ADDQ.W	#1,D0
	DBF	D2,.loop
	RTS
	
InitYPosTab:
	LEA	YPosTab(PC),A0
	MOVE	#10*80,D0
	moveq	#80,d2
	MOVE	#356-1,D1
.loop
	MOVE	D0,(A0)+
	ADD	d2,d0
	DBF	D1,.loop
	RTS

InitLine:
.wbl	btst	#6,$2(a5)
	bne.b	.wbl
	MOVEQ	#-1,D0
	MOVE.L	D0,$44(A5)		;BLTAFWM = $FFFF (BLTALWM egal!)
	MOVE.L	#$FFFF8000,$72(A5)	;BLTBDAT = Maske, BLTADAT = $8000
	MOVE.W	#$0050,$60(A5)		;BLTCMOD = Breite der Plane
	MOVE.W	#0,$42(A5)		;BLTCON1 löschen
	RTS

*-------------------------------- BlitLine -----------------------------*
*
*	IN:	D0/D1		x1,y1
*		D2/D3		x2,y3
*		A0		Plane
*		A1	(*)	YPosTab
*		A2	(*)	LINE_BlitSizes
*		A5	(*)	Custom-Base $DFF000
*
*		D4		work register
*
*		(*)		will remain untouched
BlitLine:
	CMP.W	D1,D3		;Blitter im Single-Modus
;BEQ.S	.end		;--> Keine horizontalen Linien!!!
	BGT.S	.y2_gt_y1	;Y2 > Y1 ??? Ja --> branch
	EXG	D0,D2		;Nein --> Oktanten "klappen"
	EXG	D1,D3		;--> Nur Oktanten 4,5,6,7 möglich!!!
.y2_gt_y1
	MOVE	D1,D4
	ADD	D4,D4

;	move.l	d0,-(sp)
;	and.l	#$ffff,d4
;	moveq	#0,d0
;	move	(a1,d4.l),d0
;	lea	(a0,d0.l),a0
;	move.l	(sp)+,d0

	ADD.W	(A1,D4.W),A0

	MOVE	D0,D4
	ASR.W	#3,D4
	LEA	(A0,D4.W),A0

	MOVEQ	#1,D4		;Oktant 6/7
	SUB	D0,D2		;X2 > X1 (DeltaX)
	BPL.S	.x2_gt_x1	;DeltaX positiv --> Oktant 6/7
	NEG	D2		;DeltaX negativ --> Positiv machen
	MOVEQ	#0,D4		;jetzt nur noch Oktanten 4/5 möglich!!! 
.x2_gt_x1
	SUB	D1,D3		;DeltaY


	MOVE	D3,D1
	ADD	D1,D1
	CMP.W	D2,D1
	DBHI	D3,.1
.1
	MOVE	D3,D1		
	SUB	D2,D1		;DeltaY > Delta X ??? (SUB.W wegen X-Flag!!!!)
	BGT.S	.dy_gt_dx	;Ja --> D3 schon GDelta und D2 KDelta
	EXG	D2,D3		;Nein -> D3 zu GroßDelta, D2 zu KDelta machen
.dy_gt_dx
	ADDX	D4,D4		;D4 mit D4 und X-Flag addieren
		;bei Oktant 4/5 (D4=0) und dy>dx -> X-Flag=0 -> D4=0 OKT 5
		;bei Oktant 4/5 (D4=0) und dy<dx -> X-Flag=1 -> D4=1 OKT 4
		;bei Oktant 6/7 (D4=1) und dy>dx -> X-Flag=0 -> D4=2 OKT 6
		;bei Oktant 6/7 (D4=1) und dy<dx -> X-Flag=1 -> D4=3 OKT 7

	ADD	D2,D2		;2*KDelta
	MOVE	D2,D1		
	SUB	D3,D2		;2*KDelta - GDelta
	ADDX	D4,D4		;wenn 2*KDelta - GDelta <0 --> SIGN-Bit setzen!

	ADD	D0,D0
	ANDI.W	#$001F,D0

.wbl2	btst	#6,$2(a5)
	bne.b	.wbl2
	MOVE	BltCon0(PC,D0.W),$40(A5)	;BltCON0 = $xbca
	MOVE.B	BltCon1(PC,D4.W),$43(A5)	;BltCON1 = $00xx
	
	MOVE	D2,$52(A5)	;BLTAPTL = 2*KDelta - GDelta	
	SUB	D3,D2		;D2 = 2*KDelta - 2*GDelta
	ADD	D3,D3
	MOVEM.W	D1/D2,$62(A5)	;BLTBMOD=2*KDelta, BLTAMOD=2*KDelta-2*GDelta
	MOVE.L	A0,$48(A5)
	MOVE.L	A0,$54(A5)
	MOVE	(A2,D3.W),$58(A5)	
.end
	rts

BltCon0:
	DC.W	$0bca,$1bca,$2bca,$3bca,$4bca,$5bca,$6bca,$7bca
	DC.W	$8bca,$9bca,$Abca,$Bbca,$Cbca,$Dbca,$Ebca,$Fbca
BltCon1:
	DC.B	$09	;Sign 0, Oktant 5, Line
	DC.B	$49	;Sign 1, Oktant 5, Line
	DC.B	$15	;Sign 0, Oktant 4, Line
	DC.B	$55	;Sign 1, Oktant 4, Line
	DC.B	$01	;Sign 0, Oktant 6, Line
	DC.B	$41	;Sign 1, Oktant 6, Line
	DC.B	$11	;Sign 0, Oktant 7, Line
	DC.B	$51	;Sign 1, Oktant 7, Line

LINE_BlitSizes:		ds	1024
YPosTab:		ds	356


;---------------------------------------------------------------------
;instred_clrwavedisplay	
;			movem.l	d0-a6,-(sp)
;			move.l	bitplane1_startadr2(a5),a0
;			lea	169*80+1(a0),a0
;			moveq	#64-1,d7
;.loop			moveq	#78-1,d6
;.innerloop		clr.b	(a0)+
;			dbf	d6,.innerloop
;			addq.l	#2,a0
;			dbf	d7,.loop
;			movem.l	(sp)+,d0-a6
;			rts
;--------------------------------------------------------------------
instred_SampleOffsetChange2
			move	#gad_instrchangesampleoffset,lastdownID(a5)
instred_SampleoffsetChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a2
			lea	(a2,d0),a2
			move.l	(a2),d0
; d0=wavelen
			moveq	#0,d1
			move	$18(a1),d1
			bsr	mulu_l
			moveq	#13+1,d1
			lsr.l	d1,d0
; d0=eingestellter waveoffset
			move.l	sample8_dmaoffset(a0),d1
			move.l	d1,d4
			move.l	sample8_dmalen(a0),d5
			move.l	d0,sample8_dmaoffset(a0)
			sub.l	d0,d1
			add.l	d1,sample8_dmalen(a0)
			tst.l	sample8_dmalen(a0)
			bpl.b	.ok
			move.l	d4,sample8_dmaoffset(a0)
			move.l	d5,sample8_dmalen(a0)
.ok
			bsr	refresh_instredsamplelen
			bra	refresh_instredsampleoffsetNOSLIDE
instred_SampleoffsetChangeNOW
			move.l	#instred_mmm,-(sp)
			bra.b	instred_sampleoffsetchangeup
;--------------------------------------------------------------------
instred_SampleLenChange2
			move	#gad_instrchangesamplelen,lastdownID(a5)
instred_SampleLenChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a2
			lea	(a2,d0),a2
			move.l	(a2),d0
; d0=wavelen
			moveq	#0,d1
			move	$18(a1),d1
			bsr	mulu_l
			moveq	#13+1,d1
			lsr.l	d1,d0
; d0=eingestellte wavelen+offset
			sub.l	sample8_dmaoffset(a0),d0
; d0=real wavelen
			move.l	d0,sample8_dmalen(a0)

			bra	refresh_instredsamplelenNOSLIDE
instred_SampleLenChangeNOW
			move.l	#instred_mmm,-(sp)
			bra.b	instred_samplelenchangeup
;--------------------------------------------------------------------
instred_RepeatOffsetChange2
			move	#gad_instrchangerepeatoffset,lastdownID(a5)
instred_RepeatoffsetChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a2
			lea	(a2,d0),a2
			move.l	(a2),d0
; d0=wavelen
			moveq	#0,d1
			move	$18(a1),d1
			bsr	mulu_l
			moveq	#13+1,d1
			lsr.l	d1,d0
; d0=eingestellter waveoffset
			move.l	sample8_dmarepoffset(a0),d1
			move.l	d1,d4
			move.l	sample8_dmareplen(a0),d5
			move.l	d0,sample8_dmarepoffset(a0)
			sub.l	d0,d1
			add.l	d1,sample8_dmareplen(a0)
			tst.l	sample8_dmareplen(a0)
			bpl.b	.ok
			move.l	d4,sample8_dmarepoffset(a0)
			move.l	d5,sample8_dmareplen(a0)
.ok
			bsr	setnewrepeat
			bsr	refresh_instredrepeatlen
			bra	refresh_instredrepeatoffsetNOSLIDE
instred_RepeatOffsetChangeNOW
			move.l	#instred_mmm,-(sp)
			bra.b	instred_repeatoffsetchangeup
;--------------------------------------------------------------------
instred_RepeatLenChange2
			move	#gad_instrchangerepeatlen,lastdownID(a5)
instred_RepeatLenChangeUP
			move.l	a0,a1
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a2
			lea	(a2,d0),a2
			move.l	(a2),d0
; d0=wavelen
			moveq	#0,d1
			move	$18(a1),d1
			bsr	mulu_l
			moveq	#13+1,d1
			lsr.l	d1,d0
; d0=eingestellte wavelen+offset
			sub.l	sample8_dmarepoffset(a0),d0
; d0=real wavelen
			move.l	d0,sample8_dmareplen(a0)

			bsr	setnewrepeat
			bra	refresh_instredrepeatlenNOSLIDE
instred_RepeatLenChangeNOW
			move.l	#instred_mmm,-(sp)
			bra.b	instred_repeatlenchangeup
;--------------------------------------------------------------------
instred_deleteinstrument
			move.l	intbase(a5),a6
			move.l	windowptrwave(a5),a0
			lea	clrinstr_str,a1
			jsr	patchEasyReqArgs


			tst.b	d0
			beq.w	.cancel
			cmp.b	#1,d0
			beq.b	.instrwave
			cmp.b	#2,d0
			beq.b	.wave
			cmp.b	#3,d0
			beq.b	.instr

;			tst.b	d0
;			beq.w	.cancel
;			cmp.b	#1,d0
;			beq.b	.instr
;			cmp.b	#2,d0
;			beq.b	.wave

.instrwave

			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			bsr	freewave
.instr
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)

			bsr	instred_actualdata
			move.l	a0,a1
			move.b	3(a1),d0
			REPT	8
			clr.l	(a0)+
			ENDR
			move.b	d0,3(a1)
			bra	refresh_instrumentED
.wave			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			bsr	freewave
			jsr	waveed_setshowall
			bra	refresh_instrumentED
.cancel			rts
;--------------------------------------------------------------------
; KEINE Sicherheitsabfrage (nützlich wenn kein Speicher mehr frei ist, um
; irgendwelche Requester zu öffnen (kleines Hintertürchen ;))
instred_KILLINSTRUMENT:
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			jsr	freewave
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)
			bsr	instred_actualdata
			move.l	a0,a1
			move.b	3(a1),d0
			REPT	8
			clr.l	(a0)+
			ENDR
			move.b	d0,3(a1)
			jsr	waveed_setshowall
			jmp	refresh_instrumentED
;--------------------------------------------------------------------
instred_cutinstrument
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			lea	instred_copybuf+32,a1
			rept	8
			move.l	(a0),(a1)+
			clr.l	(a0)+
			endr

			bsr	instred_actualdata
			lea	instred_copybuf,a1
			REPT	8
			move.l	(a0),(a1)+
			clr.l	(a0)+
			ENDR
			bra	refresh_instrumentED
;--------------------------------------------------------------------
instred_copyinstrument
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			lea	instred_copybuf+32,a1
			rept	8
			move.l	(a0)+,(a1)+
			endr

			bsr	instred_actualdata
			lea	instred_copybuf,a1
			REPT	8
			move.l	(a0)+,(a1)+
			ENDR

			rts
;--------------------------------------------------------------------
instred_pasteinstrument
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			lea	instred_copybuf+32,a1
			rept	8
			move.l	(a1)+,(a0)+
			endr

			bsr	instred_actualdata
			lea	instred_copybuf,a1
			REPT	8
			move.l	(a1)+,(a0)+
			ENDR
			bra	refresh_instrumentED
;--------------------------------------------------------------------
instred_load
			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	instrreqptr(a5),a1
			lea	instr_filename,a2
			lea	instr_filereqtitleLOAD,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			clr.l	waveed_rangesize(a5)
			clr.l	waveed_wavepos(a5)

			move.l	instrreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	instr_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			bra	displaymessageWave
.notfileerror
			move.l	filehandle(a5),d1
			move.l	#iobuffer,d2
			move.l	#1024,d3
			jsr	dos_read(a6)
			tst.l	d0
			bmi	ioerror2

			lea	iobuffer,a0
			cmp.l	#"FORM",(a0)
			beq	.iffInstrument
;----------------------
; Raw-Instrument
			moveq	#0,d2
			moveq	#-1,d3
			move.l	filehandle(a5),d1
			jsr	dos_seek(a6)

			move.l	#iobuffer+2000,d2
			move.l	filehandle(a5),d1
			jsr	dos_examineFH(a6)
			move.l	iobuffer+2122,d0
; d0=Filelänge

; Instrumentennamen setzen
			movem.l	d0-a6,-(sp)
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a2
			lea	(a2,d0.l),a2
			clr.l	0*4(a2)
			clr.l	1*4(a2)
			clr.l	2*4(a2)
			clr.l	3*4(a2)
			clr.l	4*4(a2)
			clr.l	5*4(a2)
			clr.l	6*4(a2)
			clr.l	7*4(a2)
			lea	instr_filename,a1
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			movem.l	(sp)+,d0-a6

			movem.l	d0/d2-d7/a1-a6,-(sp)

;			move.l	intbase(a5),a6
;			move.l	windowptrwave(a5),a0
;			lea	loadinstr_str,a1
;			sub.l	a2,a2
;			sub.l	a3,a3
;			jsr	int_EasyRequestArgs(a6)

			bsr	instred_actualdata
			moveq	#0,d1
			move.b	instr_waveform(a0),d1
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)

;		tst.b	d0
;		beq.b	.dontoverwriteRAW
			move.l	d1,d0
			bsr	freewave
;		bra.b	.useoldwaveraw

;.dontoverwriteRAW	moveq	#0,d1
;			lea	module_wavelenlist,a1
;			moveq	#64-1,d7
;.searchfreewaveRAW	tst.l	(a1)+
;			beq.b	.freefoundRAW
;			addq.b	#1,d1
;			dbf	d7,.searchfreewaveRAW
;
;			movem.l	(sp)+,d0/d2-d7/a1-a6
;			lea	msg_instred_allwavesUsed,a2
;			bra	displaymessageWave
;.freefoundRAW
;.useoldwaveRAW
			movem.l	(sp)+,d0/d2-d7/a1-a6

			move.l	d0,d2
			lsr.l	#1,d2
			move.l	d2,sample8_dmalen(a0)
			move.b	#64,instr_volume(a0)
			move.b	d1,instr_waveform(a0)
			clr.l	iobuffer+1200
			bsr	.loadwave
			bra	.noaonins
;----------------------
.iffinstrument
			moveq	#127,d7
.search8svx		cmp.l	#"8SVX",(a0)+
			beq.b	.8svxmarkfound
			subq.l	#2,a0
			dbf	d7,.search8svx
			lea	msg_instred_no8svx,a2
			bra	displaymessageWave
.8svxmarkfound
			moveq	#100,d7
.wavelen		cmp.l	#"VHDR",(a0)+
			beq.b	.iffwavelen
			subq.l	#2,a0
			dbf	d7,.wavelen
			lea	msg_instred_noVHDR,a2
			bra	displaymessageWave
.iffwavelen
			move.l	4(a0),d4	; d4=repstart!
			move.l	8(a0),d5	; d5=replen
			moveq	#100,d7
.searchiffdata		cmp.l	#"BODY",(a0)+
			beq.b	.iffdata
			subq.l	#2,a0
			dbf	d7,.searchiffdata
			lea	msg_instred_noBODY,a2
			bra	displaymessageWave
.iffdata
			move.l	(a0)+,d0	; d0=samplelen
			sub.l	#iobuffer,a0
			move.l	a0,iobuffer+1200


			movem.l	d0/d2-d7/a1-a6,-(sp)

;			move.l	intbase(a5),a6
;			move.l	windowptrwave(a5),a0
;			lea	loadinstr_str,a1
;			sub.l	a2,a2
;			sub.l	a3,a3
;			jsr	int_EasyRequestArgs(a6)

			bsr	instred_actualdata
			moveq	#0,d1
			move.b	instr_waveform(a0),d1
			clr.l	0*4(a0)
			clr.l	1*4(a0)
			clr.l	2*4(a0)
			clr.l	3*4(a0)
			clr.l	4*4(a0)
			clr.l	5*4(a0)
			clr.l	6*4(a0)
			clr.l	7*4(a0)

;		tst.b	d0
;		beq.b	.dontoverwrite
			move.l	d1,d0
			bsr	freewave
;		bra.b	.useoldwave

;.dontoverwrite		moveq	#0,d1
;			lea	module_wavelenlist,a1
;			moveq	#64-1,d7
;.searchfreewave		tst.l	(a1)+
;			beq.b	.freefound
;			addq.b	#1,d1
;			dbf	d7,.searchfreewave
;
;			movem.l	(sp)+,d0/d2-d7/a1-a6
;			lea	msg_instred_allwavesUsed,a2
;			bra	displaymessageWave
;.freefound
;.useoldwave
			movem.l	(sp)+,d0/d2-d7/a1-a6
			lsr.l	#1,d4
			lsr.l	#1,d5
			beq.b	.norepeatIFF
			move.l	d4,sample8_dmarepoffset(a0)
			move.l	d5,sample8_dmareplen(a0)
.norepeatiFF		move.l	d0,d2
			lsr.l	#1,d2
			move.l	d2,sample8_dmalen(a0)
			move.b	#64,instr_volume(a0)
			move.b	d1,instr_waveform(a0)

; Instrumentennamen setzen
			movem.l	d0-a6,-(sp)
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a2
			lea	(a2,d0.l),a2
			clr.l	0*4(a2)
			clr.l	1*4(a2)
			clr.l	2*4(a2)
			clr.l	3*4(a2)
			clr.l	4*4(a2)
			clr.l	5*4(a2)
			clr.l	6*4(a2)
			clr.l	7*4(a2)

;		lea	iobuffer,a1
;			moveq	#127,d7
;.searchNAME		cmp.l	#"NAME",(a1)+
;			beq.b	.namefound
;			subq.l	#2,a1
;			dbf	d7,.searchname

			lea	instr_filename,a1
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+
			move.l	(a1)+,(a2)+

;			bra.b	.usefilename
;.namefound		move.l	(a1)+,d7
;.copyIFFNAME		move.b	(a1)+,(a2)+
;			subq.b	#1,d7
;			bne.b	.copyiffname

.usefilename		movem.l	(sp)+,d0-a6

			bsr	.loadwave
; Testen ob extended-instr.data vorliegen (AONI-chunk)
			lea	iobuffer,a1
			moveq	#127,d7
.searchaonChunk		cmp.l	#"AONI",(a1)+
			beq.b	.loadArtOfnOiseInstrument
			subq.l	#2,a1
			dbf	d7,.searchaonchunk
			bra.w	.noAONins
;--------- ART OF NOISE INSTRUMENT LADEN ----------
.loadartofnoiseinstrument
			addq.l	#4,a1
			bsr	instred_actualdata
			move.l	a0,a2
			move.b	instr_waveform(a0),d0
			rept	8
			move.l	(a1)+,(a0)+
			endr
			move.b	d0,instr_waveform(a2)
			move.b	d0,waveed_actwave(a5)

.noaonins
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			bsr	waveed_setshowall
			bra	refresh_instrumentED

.loadwave
; d0=Länge der wavedaten
; d1=wavenr.
			move.l	d0,d6	; save for
			exg.l	d1,d0
			bsr	allocwave
			tst.l	d0
			bne.b	.loadwaveallocated
			lea	msg_instred_outofmemory,a2
			bra	displaymessageWave
.loadwaveallocated
; d0=destadr
			movem.l	d0-d6,-(sp)
			move.l	iobuffer+1200,d2
			moveq	#-1,d3
			move.l	filehandle(a5),d1
			jsr	dos_seek(a6)
			movem.l	(sp)+,d0-d6
			move.l	d0,d2
			move.l	d6,d3
			move.l	filehandle(a5),d1
			jsr	dos_read(a6)
			tst.l	d0
			bmi.b	ioerror2
			rts
;----------------------
.aonInstrument
			rts

ioerror2		move.l	filehandle(a5),d1
			beq.b	.closed
			clr.l	filehandle(a5)
			jsr	dos_close(a6)
.closed			lea	msg_io_fileerror,a2
			bra	displaymessageWave
ioerror			move.l	filehandle(a5),d1
			beq.b	.closed
			clr.l	filehandle(a5)
			jsr	dos_close(a6)
.closed			lea	msg_io_fileerror,a2
			bra	displaymessage
;--------------------------------------------------------------------
INSTRED_SAVEALL
			moveq	#1,d7
			move	acteditinstr(a5),iobuffer+7400
			clr	acteditinstr(a5)
			moveq	#0,d6
.loop			movem.l	d0-a6,-(sp)

			moveq	#0,d0
			move	d6,d0
			lsl	#5,d0
			lea	module_instrnames,a0
			tst.b	(a0,d0.l)
			beq.b	.next
			move	d6,acteditinstr(a5)
			bsr	instred_saveall2
.next			movem.l	(sp)+,d0-a6
			addq	#1,d6
			cmp	#62,d6
			bne.b	.loop
			move	iobuffer+7400,acteditinstr(a5)
			rts

INSTRED_SAVE		moveq	#0,d7
instred_saveall2
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessageWave
			else

			moveq	#0,d0
			move	acteditinstr(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			lea	instr_filename,a1
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			move.l	(a0)+,(a1)+
			clr.b	(a1)+

			tst	d7
			bne.b	.notcanceled

			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	instrreqptr(a5),a1
			lea	instr_filename,a2
			lea	instr_filereqtitleSAVE,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	instrreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	instr_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			bra	displaymessageWave
.notfileerror
			bsr	instred_actualdata
			move.l	a0,a1
			moveq	#0,d0
			move.b	instr_waveform(a1),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a0
			move.l	(a0,d0.l),d4	; Wavelänge in bytes
			lea	aon_data+aon_wavestarts,a0
			move.l	(a0,d0.l),d5	; wavestartadr

			lea	iobuffer,a0
			move.l	#"FORM",(a0)+
			move.l	d4,d0		; wavedatenlänge
			add.l	#156-8,d0	; Dateilänge-8
			move.l	d0,(a0)+	; hier eintragen
			move.l	#"8SVX",(a0)+
			move.l	#"VHDR",(a0)+
			move.l	#$14,(a0)+
			tst.l	sample8_dmareplen(a1)
			beq.b	.norepeat
			cmp.l	#1,sample8_dmareplen(a1)
			beq.b	.norepeat
			move.l	sample8_dmarepoffset(a1),d0
			add.l	d0,d0
			bne.b	.theresarepeat
.norepeat		move.l	sample8_dmalen(a1),d0
			add.l	d0,d0
			move.l	d0,(a0)+
			clr.l	(a0)+
			bra.b	.norepeat2
.theresarepeat		move.l	d0,(a0)+
			move.l	sample8_dmareplen(a1),d0
			add.l	d0,d0
			move.l	d0,(a0)+
.norepeat2		move.l	#$20,(a0)+
			move.l	#$41560100,(a0)+
			move.l	#$10000,(a0)+
			move.l	#"NAME",(a0)+

			moveq	#0,d0
			move	acteditinstr(a5),d0
			lea	module_instrnames,a2
			lsl	#5,d0
			lea	(a2,d0.l),a2
			move.l	#32,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	(a2)+,(a0)+
			move.l	#"ANNO",(a0)+
			move.l	#20,(a0)+
			move.l	#"ĞART",(a0)+
			move.l	#" OF ",(a0)+
			move.l	#"NOIS",(a0)+
			move.l	#"Eğ !",(a0)+
			move.l	#"V1.9",(a0)+
			move.l	#"AONI",(a0)+	; aon-instrumenten-datenCHUNK
			move.l	#32,(a0)+
			move.l	0*4(a1),(a0)+
			move.l	1*4(a1),(a0)+
			move.l	2*4(a1),(a0)+
			move.l	3*4(a1),(a0)+
			move.l	4*4(a1),(a0)+
			move.l	5*4(a1),(a0)+
			move.l	6*4(a1),(a0)+
			move.l	7*4(a1),(a0)+

			move.l	#"BODY",(a0)+
			move.l	d4,(a0)+	; wavesize in bytes

			move.l	#iobuffer,d2	; iff-header schreiben
			move.l	#156,d3
			write2
			move.l	d5,d2		; wavestart
			move.l	d4,d3		; wavelänge
			write2
			closefile
			endif
;--------------------------------------------------------------------
waveed_actsamplepos
			tst.b	itt_adpd_flag(a5)
			beq.b	.raus
			tst.b	winwave_override(a5)
			bne.b	.not
.raus			rts
.not			bsr	waveed_actwavedata
			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			move.l	a0,d4
; d0=wavelen in bytes
; d2=waveformnr
; d4=wavestart(real)
			lea	equ_dATA,a0
			lea	aon_channels,a1
			moveq	#4-1,d7
.searchwave		cmp.b	aon_actwavenr(a1),d2
			beq.b	.wavefound
			lea	aon_chdatasize(a1),a1
			lea	equ_datasize(a0),a0
			dbf	d7,.searchwave
			bra	waveed_clroldsamplepos
.wavefound
; d0=wavelen (still!)
; a1=aon_channels ptr
; a0=equ_data ptr
			cmp.l	#2,d0
			beq	waveed_clroldsamplepos
			move.l	equ_actwaveoff(a0),d3
			beq	waveed_clroldsamplepos
			cmp.l	d0,d3
			bgt	waveed_clroldsamplepos

			move.l	equ_actwaveptr(a0),d5
			sub.l	d4,d5
			add.l	d5,d3


			tst.l	waveed_dispsize(A5)
			beq.b	.nodisp
;			movem.l	d2-a6,-(sp)
;			move.l	d0,d2
;			move.l	#640-16,d1
;			jsr	mulu_l
;			move.l	waveed_dispsize(a5),d1
;			jsr	divu_l
;			move.l	d0,d1
;			move.l	d2,d0
;			movem.l	(sp)+,d2-a6

			move.l	waveed_dispsize(a5),d0
			move.l	d0,d1
			move.l	waveed_off(a5),d1
			cmp.l	d3,d1
			bgt	.nodisp2
			add.l	d0,d1
			cmp.l	d3,d1
			blt	.nodisp2
			sub.l	waveed_off(a5),d3
.nodisp
			

; d0=maximale wavelen
; d3=waveoffset

; waveoffset*(640-8) /maxwavelen = act. pixeloffset
			move.l	#640-16,d1
			exg.l	d0,d3
			bsr	mulu_l
			move.l	d3,d1	; max wavelen
			bsr	divu_l
; d0=pixeloffset
			addq	#8,d0
			bsr	waveed_clroldsamplepos
			move.l	bitplane2_startadr2(a5),a0
			lea	169*80(a0),a0
			move	d0,instred_lastsamplepos(a5)
			addq	#4,d0
			move.l	d0,d1
			lsr	#3,d0
			and.b	#7,d1
			moveq	#7,d2
			sub.b	d1,d2
			moveq	#64-1,d7
.setloop		bset	d2,(a0,d0)
			lea	80(a0),a0
			dbf	d7,.setloop
.nodisp2		rts
waveed_clroldsamplePOS
			tst.b	winwave_override(a5)
			bne.b	.not
			rts
.not			movem.l	d0-a6,-(sp)

			move.l	bitplane2_startadr2(a5),a0
			lea	169*80(a0),a0

			moveq	#0,d0
			move	instred_lastsamplepos(a5),d0
			beq.b	.exit
			addq	#4,d0
			move.l	d0,d1
			lsr	#3,d0
			and.b	#7,d1
			moveq	#7,d2
			sub.b	d1,d2
			moveq	#64-1,d7
.clrloop		bclr	d2,(a0,d0)
			lea	80(a0),a0
			dbf	d7,.clrloop
.exit			movem.l	(sp)+,d0-a6
			rts



;;--------------------------------------------------------------------
;instred_actsamplepos
;			tst.b	winwave_override(a5)
;			bne.b	.not
;			rts
;.not
;
;			bsr	instred_actualdata
;			moveq	#0,d1
;			move.b	instr_waveform(a0),d1
;			move.b	d1,d2
;			lea	module_wavelenlist,a0
;			add	d1,d1
;			add	d1,d1
;			move.l	(a0,d1.l),d0
;			lea	aon_wavestarts+aon_data,a1
;			move.l	(a1,d1.l),d4
;; d0=wavelen in bytes
;; d2=waveformnr
;; d4=wavestart(real)
;			lea	equ_dATA,a0
;			lea	aon_channels,a1
;			moveq	#4-1,d7
;.searchwave		cmp.b	aon_actwavenr(a1),d2
;			beq.b	.wavefound
;			lea	aon_chdatasize(a1),a1
;			lea	equ_datasize(a0),a0
;			dbf	d7,.searchwave
;			bra	instred_clroldsamplepos
;.wavefound
;; d0=wavelen (still!)
;; a1=aon_channels ptr
;; a0=equ_data ptr
;			cmp.l	#2,d0
;			beq	instred_clroldsamplepos
;			move.l	equ_actwaveoff(a0),d3
;			beq	instred_clroldsamplepos
;			cmp.l	d0,d3
;			bgt	instred_clroldsamplepos
;
;			move.l	equ_actwaveptr(a0),d5
;			sub.l	d4,d5
;			add.l	d5,d3
;; d0=maximale wavelen
;; d3=waveoffset
;
;; waveoffset*(640-8) /maxwavelen = act. pixeloffset
;			exg.l	d0,d3
;			move.l	#640-16,d1
;			bsr	mulu_l
;			move.l	d3,d1	; max wavelen
;			bsr	divu_l
;; d0=pixeloffset
;			bsr	instred_clroldsamplepos
;			move.l	bitplane2_startadr2(a5),a0
;			lea	169*80(a0),a0
;			move	d0,instred_lastsamplepos(a5)
;			addq	#4,d0
;			move.l	d0,d1
;			lsr	#3,d0
;			and.b	#7,d1
;			moveq	#7,d2
;			sub.b	d1,d2
;			moveq	#64-1,d7
;.setloop		bset	d2,(a0,d0)
;			lea	80(a0),a0
;			dbf	d7,.setloop
;			rts
;instred_clroldsamplePOS
;			tst.b	winwave_override(a5)
;			bne.b	.not
;			rts
;.not			movem.l	d0-a6,-(sp)
;			move.l	bitplane2_startadr2(a5),a0
;			lea	169*80(a0),a0
;			moveq	#0,d0
;			move	instred_lastsamplepos(a5),d0
;			beq.b	.exit
;			addq	#4,d0
;			move.l	d0,d1
;			lsr	#3,d0
;			and.b	#7,d1
;			moveq	#7,d2
;			sub.b	d1,d2
;			moveq	#64-1,d7
;.clrloop		bclr	d2,(a0,d0)
;			lea	80(a0),a0
;			dbf	d7,.clrloop
;.exit			movem.l	(sp)+,d0-a6
;			rts
;--------------------------------------------------------------------
instred_clrsampleposBPl
			movem.l	a0/d7,-(sp)
			move.l	bitplane2_startadr2(a5),a0
			lea	3*ghi+(165-6-instred_dispoff+2)*80(a0),a0
			moveq	#66-1,d7
.loop			REPT	20
			clr.l	(a0)+
			ENDR
			dbf	d7,.loop
			movem.l	(sp)+,a0/d7
			rts
;;------------------------------------------------------------------------
;instred_copyfromChange
;			move	#gad_instrchangecopyfrom,lastdownID(a5)
;instred_copyfromChangeUP
;			move.b	$19(a0),instred_copyfrom(a5)
;			bra	refresh_instredCopyFrom
;instred_copyfromChangeNOW
;			move.l	#instred_mmm,-(sp)
;			bra.b	instred_copyfromchangeup
;;------------------------------------------------------------------------
;instred_copytoChange
;			move	#gad_instrchangecopyto,lastdownID(a5)
;instred_copytoChangeUP
;			move.b	$19(a0),instred_copyto(a5)
;			bra	refresh_instredCopyto
;instred_copytoChangeNOW
;			move.l	#instred_mmm,-(sp)
;			bra.b	instred_copytochangeup
;--------------------------------------------------------------------
instred_moveFT:
			jsr	GetcopyFromTO

			moveq	#0,d0
			move.b	instred_copyfrom(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			moveq	#0,d1
			move.b	instred_copyto(a5),d1
			lsl	#5,d1
			lea	module_instrnames,a1
			lea	(a1,d1.l),a1
			rept	8
			move.l	(a0),(a1)+
			clr.l	(a0)+
			endr

			move	acteditinstr(a5),-(sp)
			move.b	instred_copyto(a5),acteditinstr+1(a5)
			bsr	instred_actualdata
			move.l	a0,a1
			move.b	instred_copyfrom(a5),acteditinstr+1(a5)
			bsr	instred_actualdata

			REPT	8
			move.l	(a0),(a1)+
			clr.l	(a0)+
			ENDR
			move	(sp)+,acteditinstr(a5)
			bra	refresh_instrumentED
;--------------------------------------------------------------------
instred_copyFT:
			jsr	GetcopyFromTO

			moveq	#0,d0
			move.b	instred_copyfrom(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			moveq	#0,d1
			move.b	instred_copyto(a5),d1
			lsl	#5,d1
			lea	module_instrnames,a1
			lea	(a1,d1.l),a1
			rept	8
			move.l	(a0)+,(a1)+
			endr

			move.b	instred_copyto(a5),acteditinstr+1(a5)
			bsr	instred_actualdata
			move.b	instr_waveform(a0),.clonewave
			move.l	a0,a1
			move.b	instred_copyfrom(a5),acteditinstr+1(a5)
			bsr	instred_actualdata
			move.b	instr_waveform(a0),.destwave

			REPT	8
			move.l	(a0)+,(a1)+
			ENDR

			move.b	instred_copyto(a5),acteditinstr+1(a5)
			move.b	.destwave(pc),waveed_actwave(a5)

			clr.b	winwave_override(a5)
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	windowptrwave(a5),a0	; ausgeben
			lea	copyins_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.yo
			jmp	refresh_instrumentED
.yo
; Wellenform clonen

			moveq	#0,d1
			move.b	.clonewave(pc),d1
;		bsr	searchfreewave
;		tst	d1
;		bpl.b	.freewavefound
;		lea	msg_instred_allwavesused,a2
;		jmp	displaymessageWave
;.freewavefound
			moveq	#0,d0
			move.b	d1,d0
			move.b	d1,.newwave
			moveq	#0,d1
			move.b	.destwave(pc),d1
			add	d1,d1
			add	d1,d1
			lea	module_wavelenlist,a0
			move.l	(a0,d1),d1	; get wavelen
			bsr	allocwave
			tst.l	d0
			bne.b	.allocated
			lea	msg_instred_outofmemoryFT,a2
			jmp	displaymessageWave
.allocated		lea	aon_wavestarts+aon_data,a0
			moveq	#0,d1
			move.b	.newwave(pc),d1
;move.l	d6,d1
			add	d1,d1
			add	d1,d1
			move.l	d0,(a0,d1)	; store wavestart
			
			bsr	instred_actualdata
			move.b	.newwave(pc),instr_waveform(a0)

			lea	aon_data+aon_wavestarts,a0
			lea	module_wavelenlist,a2
			moveq	#0,d0
			move.b	.newwave(pc),d0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0),a1
			move.l	(a2,d0),d7
			moveq	#0,d0
			move.b	.destwave(pc),d0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0),a0
.copywaves		move.b	(a0)+,(a1)+
			subq.l	#1,d7
			bne.b	.copywaves

			jsr	setnewwave
			jsr	refresh_instrument
			bra	Refresh_BaseInstrument

			bra	refresh_instrumentED
.destwave		dc.b	0
.newwave		dc.b	0
.clonewave		dc.b	0
			even

;--------------------------------------------------------------------
instred_exchangeFT:
			jsr	GetcopyFromTO

			moveq	#0,d0
			move.b	instred_copyfrom(a5),d0
			lsl	#5,d0
			lea	module_instrnames,a0
			lea	(a0,d0.l),a0
			moveq	#0,d1
			move.b	instred_copyto(a5),d1
			lsl	#5,d1
			lea	module_instrnames,a1
			lea	(a1,d1.l),a1
			rept	8
			move.l	(a1),d0
			move.l	(a0),(a1)+
			move.l	d0,(a0)+
			endr

			move	acteditinstr(a5),-(sp)
			move.b	instred_copyto(a5),acteditinstr+1(a5)
			bsr	instred_actualdata
			move.l	a0,a1
			move.b	instred_copyfrom(a5),acteditinstr+1(a5)
			bsr	instred_actualdata

			REPT	8
			move.l	(a1),d0
			move.l	(a0),(a1)+
			move.l	d0,(a0)+
			ENDR
			move	(sp)+,acteditinstr(a5)
			bra	refresh_instrumentED
;--------------------------------------------------------------------
instred_modeChange
			move.l	a0,a1
			bsr	instred_actualdata
			clr.l	4(a0)
			clr.l	8(a0)
			clr.l	12(a0)
			clr.l	16(a0)
			clr.l	20(a0)
			clr.l	24(a0)
			clr.l	28(a0)
			move.b	$19(a1),(a0)
			bra	refresh_instrumentED
;--------------------------------------------------------------------
instred_endisable	bsr	instred_actualdata
			tst.b	instr_control(a0)
			bne.b	instred_enableSynth
instred_disablesynth
			moveq	#gad_instrwaveSPD,d7
.loop			move.l	d7,d0
			bsr	disablegadget2
			addq	#1,d7
			cmp	#gad_instrVIBwave+1,d7
			bne.b	.loop

			moveq	#gad_instrsampleoffset,d0
			bsr	enablegadget2
			moveq	#gad_instrsamplelen,d0
			bsr	enablegadget2
			moveq	#gad_instrrepeatoffset,d0
			bra	enablegadget2
;--------------------------------------------------------------------
instred_enablesynth
			moveq	#gad_instrWAVEspd,d7
.loop			move.l	d7,d0
			bsr	enablegadget2
			addq	#1,d7
			cmp	#gad_instrVIBwave+1,d7
			bne.b	.loop

			moveq	#gad_instrsampleoffset,d0
			bsr	disablegadget2
			moveq	#gad_instrsamplelen,d0
			bsr	disablegadget2
			moveq	#gad_instrrepeatoffset,d0
			bra	disablegadget2
;--------------------------------------------------------------------
instred_changeWAVEspd
			move.l	$22(a1),a1
			bsr	instred_actualdata
			cmp	#$ff,$1e(a1)
			bgt	refresh_instredWAVEspd
			move.b	$1f(a1),synth8_wAVEspd(a0)
			bra	refresh_instredWAVEspd
;--------------------------------------------------------------------
instred_changeWAVElen
			move.l	$22(a1),a1
			bsr	instred_actualdata
			cmp	#$ff,$1e(a1)
			bgt	refresh_instredWAVElen2
			move.b	$1f(a1),synth8_WAVElen(a0)
			bra	refresh_instredWAVElen2
;--------------------------------------------------------------------
instred_changeWAVErep
			move.l	$22(a1),a1
			bsr	instred_actualdata
			cmp	#$ff,$1e(a1)
			bgt	refresh_instredWAVErep
			move.b	$1f(a1),synth8_WAVErep(a0)
			bra	refresh_instredWAVErep
;--------------------------------------------------------------------
instred_changeWAVEreplen
			move.l	$22(a1),a1
			bsr	instred_actualdata
			cmp	#$ff,$1e(a1)
			bgt	refresh_instredWAVEreplen
			move.b	$1f(a1),synth8_WAVEreplen(a0)
			bra	refresh_instredWAVEreplen
;--------------------------------------------------------------------
instred_changeVIBdelay
			move.l	$22(a1),a1
			bsr	instred_actualdata
			cmp	#$ff,$1e(a1)
			bgt	refresh_instredVIBdelay
			move.b	$1f(a1),synth8_VIBdelay(a0)
			bra	refresh_instredVIBdelay
;--------------------------------------------------------------------
instred_changeVIBpara
			lea	instred_actVIBparaASC,a0
			lea	txt_hexchars,a1
			moveq	#0,d0
			move.b	(a0)+,d0
			cmp.b	#"a",d0
			blt.b	.lc1
			bclr	#5,d0
.lc1
			moveq	#0,d1
			moveq	#16-1,d7
.srch			cmp.b	(a1)+,d0
			beq.b	.fnd
			addq.b	#1,d1
			dbf	d7,.srch
			bra.b	.set
.fnd			move.b	d1,d5
			lsl.b	#4,d5

			lea	txt_hexchars,a1
			moveq	#0,d0
			move.b	(a0)+,d0
			cmp.b	#"a",d0
			blt.b	.lc2
			bclr	#5,d0
.lc2			moveq	#0,d1
			moveq	#16-1,d7
.srch2			cmp.b	(a1)+,d0
			beq.b	.fnd2
			addq.b	#1,d1
			dbf	d7,.srch2
			bra.b	.set
.fnd2			or.b	d1,d5

			bsr	instred_actualdata
			move.b	d5,synth8_VIBpara(a0)
.set			bra	refresh_instredVIBpara
;--------------------------------------------------------------------
instred_repctrlChange
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),synth8_WAVErepctrl(a0)
			rts
;--------------------------------------------------------------------
instred_VIBwaveChange
			move.l	a0,a1
			bsr	instred_actualdata
			move.b	$19(a1),synth8_VIBwave(a0)
			rts
;--------------------------------------------------------------------
instred_changeAstart	move.l	$22(a1),a1
			bsr	instred_actualdata
			move.b	$1f(a1),d0
			and.b	#$7f,d0
			move.b	d0,instr_Astart(a0)
Refresh_instredAstart	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	instr_Astart(a0),ref_ikind_data2+3
			moveq	#gad_instrAstart,d0
			jmp	refresh_integer_kind2
;--------------------------------------------------------------------
instred_changeAadd	move.l	$22(a1),a1
			bsr	instred_actualdata
			move.b	$1f(a1),d0
			and.b	#$7f,d0
			move.b	d0,instr_Aadd(a0)
Refresh_instredAadd	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	instr_Aadd(a0),ref_ikind_data2+3
			moveq	#gad_instrAadd,d0
			jmp	refresh_integer_kind2
;--------------------------------------------------------------------
instred_changeAend	move.l	$22(a1),a1
			bsr	instred_actualdata
			move.b	$1f(a1),d0
			and.b	#$7f,d0
			move.b	d0,instr_Aend(a0)
Refresh_instredAend	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	instr_Aend(a0),ref_ikind_data2+3
			moveq	#gad_instrAend,d0
			jmp	refresh_integer_kind2
;--------------------------------------------------------------------
instred_changeAsub	move.l	$22(a1),a1
			bsr	instred_actualdata
			move.b	$1f(a1),d0
			and.b	#$7f,d0
			move.b	d0,instr_Asub(a0)
Refresh_instredAsub	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	instr_Asub(a0),ref_ikind_data2+3
			moveq	#gad_instrAsub,d0
			jmp	refresh_integer_kind2
;--------------------------------------------------------------------
instred_LoadWave
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	samplereqptr(a5),a1
			lea	sample_filename,a2
			lea	sample_filereqtitleLOAD,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	samplereqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	sample_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			bra	displaymessageWave
.notfileerror
			move.l	.from(pc),d0
			subq	#1,d0
			bsr	freewave

			move.l	#iobuffer+2000,d2	; filelänge holen
			move.l	filehandle(a5),d1
			jsr	dos_examineFH(a6)

			move.l	.from(pc),d0		; d0=Wavenr
			subq	#1,d0
			move.l	iobuffer+2122,d1	; d1=Filelänge
			bsr	allocwave
			move.l	d0,d2			; waveadr
			bne.b	.stillfree
			lea	msg_instred_outofmemory,a2
			bsr	displaymessageWave
			bra.b	.close
.stillfree
			move.l	filehandle(a5),d1
			move.l	iobuffer+2122,d3
			jsr	dos_read(a6)
			tst.l	d0
			bmi	ioerror2

.close			move.l	filehandle(a5),d1
			jsr	dos_close(a6)
			bra	refresh_instrumentED

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,1
			dc.l	rtgl_max,64
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Load to wave nr.",0
			even
.from			dc.l	1
;--------------------------------------------------------------------
instred_Flushwave
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0
			bne.b	.ok
			rts
.ok			move.l	.from(pc),d0
			subq	#1,d0
			bsr	freewave
			bsr	waveed_setshowall
			bra	refresh_instrumentED

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,1
			dc.l	rtgl_max,64
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Flush wave nr.",0
			even
.from			dc.l	1
;------------------------------------------------------------------------
ActivateinstredName	move.l	intbase(a5),a6
			move.l	mpwave_gadgetptrs+gad_instredname*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)


;************************************************************************
SetupEd:
			clr.b	itt_adpd_flag(a5)
			move.b	#setup,programmode(a5)

			move.l	intbase(a5),a6
			lea	setup_windowstruct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window2ptr(a5)
			bne.b	.windowopened
			lea	msg_setup_nowindow,a2
			jsr	displaymessage
			bra	setup_exit
.windowopened
			move.l	d0,a0
			move.l	$32(a0),rastport2(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userport2(a5)

			move.l	gadtoolsbase(a5),a6
			lea	gadgetlist2(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;--------- Gadgets eintragen ------------
			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mp2_gadgetptrs+4,a5

			lea	setup_gadgetstructptrs,a4
.allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.b	.allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	.allocGadgetsLoop
.AllocGadgetsEND	move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

; String-Gadgets umlenken
			lea	mp2_gadgetptrs,a0
			move.l	gad_setupModpath*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_modulepath,(a2)	; Modpath

			move.l	gad_setupInstrpath*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_instrpath,(a2)	; Instrpath

			move.l	gad_setupDseqpath*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_dseqpath,(a2)	; Dseqpath

			move.l	gad_setupSamplepath*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_samplepath,(a2)	; Samplepath

			move.l	gad_setupTexteditor*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_texteditor,(a2)	; Samplepath

			move.l	gad_setupBlanker*4(a0),a1
			move.l	$22(a1),a2
			move.l	#prf_data+prf_blankername,(a2)	; Samplepath


			move.l	gadgetlist2(a5),a0	; Gadgets zeichnen
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)
; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)


			move.b	prf_data+prf_oversize,aon_data+aon_oversize

			jsr	refresh_setupblankertimeout
			jsr	refresh_setupwavedrawmode
			jsr	refresh_setupfiltermode
			jsr	refresh_setupsaveremarkmode
			jsr	refresh_setupsaveinstrnamesmode
			jsr	refresh_setupcrunchmode
			jsr	refresh_setupaddppmode
			jsr	refresh_setupcruncheffmode
			jsr	refresh_setupcrunchbufmode
			jsr	refresh_setupbottomstatusmode
			jsr	refresh_setupforcepalmode

			bsr	getcolors

setupEDed
			clr.b	screen(a5)
; Mainloop-----------------------
setup_mmm
.mmm			move.l	userport2(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.m_messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			bsr	printnewpatterns
			jsr	adjust_pattdisplay
			bra.b	.mmm
.m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0


			cmp.l	#inactivewindow,$14(a0)
			beq	instred_inactivated

			cmp.l	#intuiticks,$14(a0)
			beq	setup_intuiticks
			cmp.l	#rawkey,$14(a0)
			bne.b	.notkeypressedsetup
			jmp	keypressedsetup
.notkeypressedsetup
			cmp.l	#closewindow,$14(a0)
			beq.b	.exit

			moveq	#0,d3
			cmp.l	#gadgetup,$14(a0)
			beq.b	.yoman
			moveq	#4,d3
			cmp.l	#gadgetdown,$14(a0)
			bne	.mmm
.yoman			
			jsr	checkgadgets
			bra	.mmm
; Exit---------------------------
.exit
			bsr	initprefs
setup_exitfree
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen

			move.l	gadtoolsbase(a5),a6
			move.l	gadgetlist2(a5),a0
			jsr	gadtools_FreeGadgets(a6)

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
setup_exit		move.b	#pattedit,programmode(a5)
			move.b	#1,itt_adpd_flag(a5)
			rts
;--------------------------------------------------------------------
setup_intuiticks	bsr	blanker
			bra	setup_mmm
;--------------------------------------------------------------------
setup_exitnow		addq.l	#8,sp
			bra	setup_exitfree
;--------------------------------------------------------------------
setup_getModpath
			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	modreqptr(a5),a1
			lea	mod_filename,a2
			lea	.title,a3
			lea	mod_dirreqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok			move.l	modreqptr(a5),a4
			move.l	rt_dirname(a4),a4

			lea	.tags(pc),a3
			move.l	a4,4(a3)

			move.l	mp2_gadgetptrs+gad_setupModpath*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
.tags
			dc.l	gtst_string,0
			dc.l	tag_done
			ifeq	lang
.title			dc.b	"Select mod-path...",0
			else
.title			dc.b	"MOD-Pfad wählen...",0
			endif
			even
;--------------------------------------------------------------------
setup_getInstrpath
			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	instrreqptr(a5),a1
			lea	instr_filename,a2
			lea	.title,a3
			lea	mod_dirreqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok			move.l	instrreqptr(a5),a4
			move.l	rt_dirname(a4),a4

			lea	.tags(pc),a3
			move.l	a4,4(a3)

			move.l	mp2_gadgetptrs+gad_setupinstrpath*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
.tags
			dc.l	gtst_string,0
			dc.l	tag_done
			ifeq	lang
.title			dc.b	"Select instr-path...",0
			else
.title			dc.b	"Instr.-Pfad wählen...",0
			endif
			even
;--------------------------------------------------------------------
setup_getsamplepath
			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	samplereqptr(a5),a1
			lea	sample_filename,a2
			lea	.title,a3
			lea	mod_dirreqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok			move.l	samplereqptr(a5),a4
			move.l	rt_dirname(a4),a4

			lea	.tags(pc),a3
			move.l	a4,4(a3)

			move.l	mp2_gadgetptrs+gad_setupsamplepath*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
.tags
			dc.l	gtst_string,0
			dc.l	tag_done
			ifeq	lang
.title			dc.b	"Select wave-path..",0
			else
.title			dc.b	"Wave-Pfad wählen...",0
			endif
			even
;--------------------------------------------------------------------
setup_getdseqpath
			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	dseqreqptr(a5),a1
			lea	dseq_filename,a2
			lea	.title,a3
			lea	mod_dirreqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok			move.l	dseqreqptr(a5),a4
			move.l	rt_dirname(a4),a4

			lea	.tags(pc),a3
			move.l	a4,4(a3)

			move.l	mp2_gadgetptrs+gad_setupdseqpath*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
.tags
			dc.l	gtst_string,0
			dc.l	tag_done
			ifeq	lang
.title			dc.b	"Select dseq-path...",0
			else
.title			dc.b	"DSEQ-Pfad wählen...",0
			endif
			even
;--------------------------------------------------------------------
setup_getBlanker
			move.l	varreqptr(a5),a1
			move.l	rt_dirname(a1),a1
			lea	blankerpfad,a0
.loop			move.b	(a0)+,(a1)+
			tst.b	-1(a0)
			bne.b	.loop

			clr.b	win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			lea	var_filename,a2
			lea	var_blanker_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			lea	var_filename,a4
			lea	.tags(pc),a3
			move.l	a4,4(a3)

			move.l	mp2_gadgetptrs+gad_setupblanker*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jmp	gadtools_gt_setgadgetattrsA(a6)
.tags
			dc.l	gtst_string,0
			dc.l	tag_done
;--------------------------------------------------------------------
setup_blankertimechange
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			and.l	#$7fff,d0
			move	d0,prf_data+prf_blankertimeout
			move	d0,d1
			add	d0,d0
			lsl	#3,d1
			add	d0,d1	; *10
			move	d1,blankercnt(a5)
			bra	refresh_setupblankertimeout
;--------------------------------------------------------------------
setup_wavedrawmodeChange
			move.b	$19(a0),prf_data+prf_splitmode
			rts
;--------------------------------------------------------------------
setup_filtermodeChange
			move.b	$19(a0),d0
			move.b	d0,prf_data+prf_filtermode
			beq.b	.off
			bclr	#1,$bfe001
			jmp	showfilterstatus
.off			bset	#1,$bfe001
			jmp	showfilterstatus
;--------------------------------------------------------------------
setup_togglebottomstatusmode
			bchg	#0,prf_data+prf_bottomstatusmode
			jmp	refresh_setupbottomstatusmode
;--------------------------------------------------------------------
setup_toggleforcepalmode
			bchg	#0,prf_data+prf_forcepal
			jmp	refresh_setupforcepalmode
;--------------------------------------------------------------------
SavePrefs:		move.b	#1,win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1
			move.l	rt_dirname(a1),a2
			clr.b	(a2)
			lea	var_filename,a2
			move.l	#"Chor",0(a2)
			move.l	#"us.c",4(a2)
			move.l	#"onfi",8(a2)
			move	#$6700,12(a2)
			lea	var_prf_filereqtitle,a3
			lea	mod_filereqTAGS,a0
			jsr	rtFileRequestA(a6)
			clr.b	win2_override(a5)
			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled		move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	var_filename,a1
			jsr	makefilename
			move.l	#iofilename,d1
			move.l	#1006,d2
			move.l	dosbase(a5),a6
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.fileopen
			lea	msg_io_filenotfound,a2
			bra	displaymessage2
.fileopen
			move.l	d0,d1
			move.l	#prf_data,d2
			move.l	#prf_datasize,d3
			jsr	dos_write(a6)
			tst.l	d0
			bmi	ioerror2
			closefile
;--------------------------------------------------------------------
getcolors
			movem.l	d0-a6,-(sp)
			lea	prf_data+prf_col0,a4
			move.l	gfxbase(a5),a6
			moveq	#0,d6
			moveq	#4-1,d7
.loop			move.l	viewport(a5),a0
			move.l	4(a0),a0
			move.l	d6,d0
			jsr	gfx_getrgb4(a6)
			move	d0,d1
			move	d0,d2
			and	#$f00,d0
			and	#$0f0,d1
			and	#$00f,d2
			lsr	#8,d0
			lsr	#4,d1
			move.b	d0,(a4)+
			move.b	d1,(a4)+
			move.b	d2,(a4)+
			addq	#1,d6
			dbf	d7,.loop
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
; a4=ptr on coltriplet (.l*3 words)
setcolors:
			rts

			movem.l	d0-a6,-(sp)
			lea	prf_data+prf_col0,a4
			move.l	gfxbase(a5),a6
			moveq	#0,d6
			moveq	#4-1,d7
.loop			move.l	viewport(a5),a0
			move.l	d6,d0
			moveq	#0,d1
			moveq	#0,d2
			moveq	#0,d3
			move.b	(a4)+,d1
			move.b	(a4)+,d2
			move.b	(a4)+,d3
			jsr	gfx_setrgb4(a6)
			addq	#1,d6
			dbf	d7,.loop
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
setup_usekey		bsr	initprefs
			addq.l	#8,sp
			bra	setup_exitfree
;--------------------------------------------------------------------
setup_use		bsr	initprefs
setup_cancel		addq.l	#4,sp
			bra	setup_exitfree
;--------------------------------------------------------------------
activateSetupTextEditor
			move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_setupTexteditor*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;;--------------------------------------------------------------------
;activateSetupBlanker
;			move.l	intbase(a5),a6
;			move.l	mp2_gadgetptrs+gad_setupBlanker*4,a0
;			move.l	window2ptr(a5),a1
;			sub.l	a2,a2
;			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
activateSetupBlankertimeout
			move.l	intbase(a5),a6
			move.l	mp2_gadgetptrs+gad_setupBlankertimeout*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			jmp	int_ActivateGadget(a6)
;--------------------------------------------------------------------
setup_togglewavedrawmode
			bchg	#0,prf_data+prf_splitmode
			bra	refresh_setupwavedrawmode
;--------------------------------------------------------------------
setup_togglefiltermode
			bchg	#0,prf_data+prf_filtermode
			tst.b	prf_data+prf_filtermode
			beq.b	.off
			bclr	#1,$bfe001
			jsr	showfilterstatus
			bra	refresh_setupfiltermode
.off			bset	#1,$bfe001
			jsr	showfilterstatus
			bra	refresh_setupfiltermode
;--------------------------------------------------------------------
setup_saveremarkmodeChange
			move.b	$19(a0),prf_data+prf_saveremark
			rts
;--------------------------------------------------------------------
setup_togglesaveremarkmode
			bchg	#0,prf_data+prf_saveremark
			bra	refresh_setupsaveremarkmode
;--------------------------------------------------------------------
setup_saveinstrnamesModeChange
			move.b	$19(a0),prf_data+prf_saveinstrnames
			rts
;--------------------------------------------------------------------
setup_togglesaveinstrnamesmode
			bchg	#0,prf_data+prf_saveinstrnames
			bra	refresh_setupsaveinstrnamesmode
;--------------------------------------------------------------------
setup_crunchModeChange
			move.b	$19(a0),prf_data+prf_oversize
			move.b	$19(a0),aon_data+aon_oversize
			rts
;--------------------------------------------------------------------
setup_toggleCrunchmode
			bchg	#0,prf_data+prf_oversize
			bchg	#0,aon_data+aon_oversize
			bra	refresh_setupcrunchmode
;--------------------------------------------------------------------
setup_addppModeChange	move.b	$19(a0),prf_data+prf_addpp
			rts
;--------------------------------------------------------------------
setup_toggleAddppmode	bchg	#0,prf_data+prf_addpp
			bra	refresh_setupaddppmode
;--------------------------------------------------------------------
setup_cruncheffmodeChange
			move.b	$19(a0),prf_data+prf_cruncheff
			rts
;--------------------------------------------------------------------
setup_togglecruncheffmode
			cmp.b	#4,prf_data+prf_cruncheff
			bne.b	.add
			clr.b	prf_data+prf_cruncheff
			bra	refresh_setupcruncheffmode
.add			addq.b	#1,prf_data+prf_cruncheff
			bra	refresh_setupcruncheffmode
;--------------------------------------------------------------------
setup_crunchBufmodeChange
			move.b	$19(a0),prf_data+prf_crunchbuf
			rts
;--------------------------------------------------------------------
setup_togglecrunchbufmode
			cmp.b	#2,prf_data+prf_crunchbuf
			bne.b	.add
			clr.b	prf_data+prf_crunchbuf
			bra	refresh_setupcrunchbufmode
.add			addq.b	#1,prf_data+prf_crunchbuf
			bra	refresh_setupcrunchbufmode
;************************************************************************
; 	        I N T R U M E N T E N   _   E D I T O R   _

;--------------------------------------------------------------------
waveed_togglemode	bchg	#0,freemode(a5)
			rts
;--------------------------------------------------------------------
waveed_rangemark
			btst	#6,$bfe001
			beq.b	waveed_startrangemark

waveed_endrange		clr.b	rangemark(a5)
			bra	instred_mmm
waveed_startrangemark
			bsr	waveed_actwavedata
			tst.l	d0
			beq.b	.nomark

			move.l	windowptrwave(a5),a0
			moveq	#0,d1
			move	$e(a0),d1		; x-pos

			move.l	waveed_dispsize(a5),d0
			lsl.l	#8,d0
			move.l	#640-16,d1
			bsr	divu_l
; d0=anzahl der bytes pro pixel (*256)
			moveq	#0,d1
			move	$e(a0),d1
			subq	#8,d1
			bpl.b	.ok1
			moveq	#0,d1
.ok1			cmp	#640-4-12,d1
			ble.b	.ok
			move	#639-4-12,d1
.ok
; d1=pixel-pos
			jsr	mulu_l
			move.l	d0,d1
;	mulu	d0,d1
			lsr.l	#8,d1
			add.l	waveed_off(a5),d1
			move.l	d1,waveed_wavepos(a5)
			move.l	d1,waveed_downpos(a5)
			clr.l	waveed_rangesize(a5)
			move.b	#1,rangemark(a5)


			bsr	refresh_waveedRangeLen
			bsr	refresh_waveedPos
			bsr	waveed_drawrange
.nomark
			bra	instred_mmm
waveed_markrange
			btst	#6,$bfe001
			bne.w	waveed_endrange

			move.l	windowptrwave(a5),a0
			moveq	#0,d1
			move	$e(a0),d1		; x-pos

			move.l	waveed_dispsize(a5),d0
			lsl.l	#8,d0
			move.l	#640-16,d1
			bsr	divu_l
; d0=anzahl der bytes pro pixel (*256)
			moveq	#0,d5

			moveq	#0,d1
			move	$e(a0),d1
			subq	#8,d1
			bpl.b	.ok1
			moveq	#0,d1
.ok1			cmp	#640-4-12,d1
			ble.b	.ok
			move	#640-4-12,d1
			move.l	d0,d5
			lsr.l	#8,d5
			bne.b	.addok
			moveq	#1,d5
.addok
.ok
; d1=pixel-pos
			jsr	mulu_l
			move.l	d0,d1
;		mulu	d0,d1
			lsr.l	#8,d1
			add.l	waveed_off(a5),d1
; d1=current wavepos (in bytes)
			sub.l	waveed_downpos(a5),d1
			bmi.b	.leftmark
			add.l	d5,d1
			move.l	d1,waveed_rangesize(a5)
			move.l	waveed_downpos(a5),waveed_wavepos(a5)

; sicherheitstest
.sectest
			bsr	waveed_actwavedata
			move.l	waveed_rangesize(a5),d1
			add.l	waveed_wavepos(a5),d1
			cmp.l	d1,d0
			bge.b	.ok22
			move.l	d0,d1
			sub.l	waveed_wavepos(a5),d1
			move.l	d1,waveed_rangesize(a5)
.ok22
			tst.l	waveed_rangesize(a5)
			bpl.b	.okpos
			clr.l	waveed_rangesize(a5)
.okpos
			bsr	refresh_waveedpos
			bsr	refresh_waveedRangeLen
			bsr	waveed_drawrange
.nomark
			bra	instred_mmm
; markiert wird von rechts nach links!
.leftmark
			move.l	waveed_downpos(a5),d2
			neg.l	d1
			add.l	d5,d1
			move.l	d1,waveed_rangesize(a5)
			sub.l	d1,d2
			move.l	d2,waveed_wavepos(a5)
			bra.b	.sectest
;--------------------------------------------------------------------
waveed_freestyle
			btst	#6,$bfe001
			bne	instred_mmm
.yes

			bsr	waveed_actwavedata
			tst.l	d0
			beq.b	.nomark

			move.l	windowptrwave(a5),a0
			moveq	#0,d1
			move	$e(a0),d1		; x-pos

			move.l	waveed_dispsize(a5),d0
			lsl.l	#8,d0
			move.l	#640-16,d1
			bsr	divu_l
; d0=anzahl der bytes pro pixel (*256)
			move.l	d0,-(sp)

			moveq	#0,d1
			move	$e(a0),d1
			subq	#8,d1
			bpl.b	.ok1
			moveq	#0,d1
.ok1			cmp	#640-4-12,d1
			ble.b	.ok
			move	#639-4-12,d1
.ok
; d1=pixel-pos
			jsr	mulu_l
			move.l	d0,d1
;	mulu	d0,d1
			lsr.l	#8,d1
			add.l	waveed_off(a5),d1
; d1=wavepos
; d7=bytes to go
			move.l	(sp)+,d7
			moveq	#0,d3
			move	$c(a0),d3	; y-pos
			sub	#162,d3
			bmi.b	.nomark
			cmp	#63,d3
			bgt.b	.nomark
			lea	fs_tab(pc),a0
			move.b	(a0,d3),d3

			jsr	waveed_actwavedata
			lea	(a0,d1.l),a0
; d3=byte to set
; d7=amount of bytes to set
.setthem		move.b	d3,(a0)+
;			subq	#1,d7
;			bne.b	.setthem

			bsr	waveed_drawwave

.nomark
			bra	instred_mmm

fs_tab
 dc.b	127,123,119,115,111,107,103,099,095,091,087,083,079,075,071,067
 dc.b	063,059,055,051,047,043,039,035,031,027,023,019,015,011,007,003
 dc.b	000
 dc.b	-003,-007,-011,-015,-019,-023,-027,-031,-035,-039,-043,-047,-051
 dc.b	-055,-059,-063,-067,-071,-075,-079,-083,-087,-091,-095,-099,-103
 dc.b	-107,-111,-115,-119,-123,-127
			even

;--------------------------------------------------------------------

;--------------------------------------------------------------------
;--------------------------------------------------------------------
;waveed_waveChange	move	#gad_wavechangewave,lastdownID(a5)
;			move.b	$19(a0),waveed_actwave(a5)
;			bsr	waveed_setshowall
;			clr.l	waveed_wavepos(a5)
;			clr.l	waveed_rangesize(a5)
;			clr.b	rangemark(a5)
;			bra	refresh_waveedwaveALL
;waveed_waveChangeUP	move.b	$19(a0),waveed_actwave(a5)
;			move	lastdownID(a5),d0
;			clr	lastdownID(a5)
;			cmp	#gad_wavechangewave,d0
;			beq.b	.our
;			bsr	waveed_setshowall
;			clr.l	waveed_wavepos(a5)
;			clr.l	waveed_rangesize(a5)
;			clr.b	rangemark(a5)
;			bsr	refresh_waveedwaveALL
;.our			rts
;waveed_waveChangeNOW
;			move.b	$19(a0),waveed_actwave(a5)
;			clr.l	waveed_wavepos(a5)
;			clr.l	waveed_rangesize(a5)
;			clr.b	rangemark(a5)
;			bsr	waveed_setshowall
;			bsr	refresh_waveedwaveALL
;			bra	instred_mmm

;--------------------------------------------------------------------
waveed_setshowall:	bsr	waveed_actwavedata
			move.l	d0,waveed_dispsize(a5)
			clr.l	waveed_off(a5)
			rts
;--------------------------------------------------------------------
waveed_zoom:		move.l	waveed_dispsize(a5),d0
			move.l	d0,d1
			lsr.l	#2,d1
			sub.l	d1,d0
			move.l	d0,waveed_dispsize(a5)
			lsr.l	#1,d1
			add.l	d1,waveed_off(a5)
			bra	refresh_waveedWaveALL
;--------------------------------------------------------------------
waveed_tele:		bsr	waveed_actwavedata
			move.l	d0,d2		; max disp

			move.l	waveed_dispsize(a5),d0
			move.l	d0,d1
			lsr.l	#2,d1
			bne.b	.ok
			moveq	#1,d1
.ok			add.l	d1,d0
			cmp.l	d2,d0
			bge	waveed_showall
			move.l	d0,waveed_dispsize(a5)
			lsr.l	#1,d1
			sub.l	d1,waveed_off(a5)
.checkoff		move.l	waveed_off(a5),d0	; über linkem rand?
			bpl.b	.ok1
			clr.l	waveed_off(a5)
			bra.b	.q
.ok1			add.l	waveed_dispsize(a5),d0	; über rechtem rand?
			cmp.l	d2,d0			; rechter rand
			ble.b	.ok2
			sub.l	d2,d0
			sub.l	d0,waveed_off(a5)
			bra.b	.checkoff
.ok2
.q			bra	refresh_waveedWaveALL
;--------------------------------------------------------------------
; out:		a0=ptr on actual wave
;		d0=wavelen
waveed_actwavedata	move.l	a1,-(sp)
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add.b	d0,d0
			add.b	d0,d0
			lea	aon_data+aon_wavestarts,a1
			move.l	(a1,d0.l),a0
			lea	module_wavelenlist,a1
			move.l	(a1,d0.l),d0
			move.l	(sp)+,a1
			rts
;--------------------------------------------------------------------
; out:	d0=wavesize	d7=rangesize	a0=pointer on range
waveed_actrangedata
			bsr	waveed_actwavedata
			add.l	waveed_wavepos(a5),a0
			move.l	waveed_rangesize(a5),d7
			rts
;--------------------------------------------------------------------
waveed_showall		bsr	waveed_setshowall
			bra	refresh_waveedWaveALL
;--------------------------------------------------------------------
waveed_show121
			bsr	waveed_actwavedata
			cmp.l	#632,d0
			blt.b	.smaller
			move.l	#632,d0
.smaller		move.l	d0,waveed_dispsize(a5)
			clr.l	waveed_off(a5)
			bra	refresh_waveedWaveALL
;--------------------------------------------------------------------
waveed_showrange	tst.l	waveed_rangesize(a5)
			bne.b	.ok
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.ok
			move.l	waveed_wavepos(a5),waveed_off(a5)
			move.l	waveed_rangesize(a5),waveed_dispsize(a5)
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_rangeall		bsr	waveed_actwavedata
			move.l	d0,waveed_rangesize(a5)
			clr.l	waveed_wavepos(a5)
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_rangedisplay	bsr	waveed_actwavedata
			move.l	waveed_dispsize(a5),waveed_rangesize(a5)
			move.l	waveed_off(a5),waveed_wavepos(a5)
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_posChange	move	#gad_wavechangepos,lastdownID(a5)

			bsr	waveed_posChangeit
			bsr	refresh_waveedwaveALL
			rts
waveed_posChangeUP
			bsr	waveed_posChangeit
			bra	refresh_waveedwaveALL
waveed_posChangeNOW
			bsr	waveed_posChangeit
			bsr	refresh_waveedwaveALL
			bra	instred_mmm

waveed_posChangeit
			move.l	a0,a1
			bsr	waveed_actwavedata
			move.l	d0,d4
			move.l	#$8000,d3
; d3=total
			moveq	#0,d1
			move	$18(a1),d1	; act off (relativ to total)
; d1=act.
; total=$8000 (d3)
; act=$4000 (d1)
; wavelen=10000 (d4)

			move.l	d4,d0		; wavelen*act
			bsr	mulu_l
			move.l	d3,d1		; /total
			bsr	divu_l
; d0=new wavepos
			move.l	waveed_dispsize(a5),d1
			sub.l	d1,d4
; z.b.2048-640=1408
			cmp.l	d0,d4
			bgt.b	.ok
			rts
.ok			tst.l	waveed_rangesize(a5)
			bne.b	.noposreset
			move.l	d0,waveed_wavepos(a5)
.noposreset		move.l	d0,waveed_off(a5)
			rts

;--------------------------------------------------------------------
waveed_interpolfilter
			move	#$1977,d6	; set flag
;--------------------------------------------------------------------
; Program	:	Ramp-Filter Function for samples
; Author	:	Bastian Spiegel (Twice/Lego)
; Date		:	19.September.94

; my a4ooo is in sight!
waveed_DigiFilter
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			cmp	#$1977,d6	; Interpolationsfilter
			bne.b	.normalfilter	; a la protracker ?!?
			move.l	#64,.from
			move.l	#64,.to
			move.l	#1,.pass
			bra	.ok3
.normalfilter
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.to(pc),a1
			lea	.toASC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok2
			rts
.ok2
			clr.b	winwave_override(a5)
			lea	.tags2(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.pass(pc),a1
			lea	.passASC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok3
			rts
.ok3

			bsr	waveed_actwavedata
			add.l	waveed_wavepos(a5),a0


			move.l	.pass(pc),.passwork
.dopasses
			movem.l	d0-a6,-(sp)

			move.l	waveed_rangesize(a5),d7
			move.l	.from(pc),d0		; Filter start
			move.l	.to(pc),d1		; Filter end
;--------------------------------------------------------------------
; iN:	a0=Sourcesampleadr
.........;	d0=Filterintensität START
;	d1=Filterintensität END
;	d7=Samplelen
			move.l	d0,d6
; d0/d6=start-filter
; d1=end-filter
; d7=bytelen
; d1-d0=delta filter
; delta/bytelen=steigung pro byte
;
			sub	d0,d1	; d3=delta filter
			bpl.b	.deltapos
			neg	d1
			swap	d1
			move.l	d1,d0
			move.l	d7,d1	; durch länge teilen
			bsr	divu_l
			move.l	d0,d4	; d0=addx
			clr	d4
			swap	d4	; byteadd
			moveq	#0,d3
			move	d0,d3	; addx-cntadd
			moveq	#0,d5
			bra	.deltanegloop
.deltapos		swap	d1	; *$10000
			move.l	d1,d0
			move.l	d7,d1	; durch länge teilen
			bsr	divu_l
; d0=addx
			move.l	d0,d4
			clr	d4
			swap	d4	; byteadd

			moveq	#0,d3
			move	d0,d3	; addx-cntadd

			moveq	#0,d5	; cnter

.loop
			moveq	#0,d1
			moveq	#0,d2
			move.b	(a0),d1
			move.b	1(a0),d2
			sub.b	d1,d2
			ext	d2
			muls	d6,d2	; *filter intense
			asr	#7,d2
			add.b	d2,d1
			move.b	d1,(a0)+

			add	d3,d5
			addx	d4,d6

			subq.l	#1,d7
			bne.b	.loop

			movem.l	(sp)+,d0-a6
			subq.l	#1,.passwork
			bne	.dopasses

			bra	refresh_waveedwaveall
.deltanegloop
			moveq	#0,d1
			moveq	#0,d2
			move.b	(a0),d1
			move.b	1(a0),d2
			sub.b	d1,d2
			ext	d2
			muls	d6,d2	; *filter intense
			asr	#7,d2
			add.b	d2,d1
			move.b	d1,(a0)+

			add	d3,d5
			subx	d4,d6

			subq.l	#1,d7
			bne.b	.deltanegloop
			movem.l	(sp)+,d0-a6
			subq.l	#1,.passwork
			bne	.dopasses

			bra	refresh_waveedwaveall
.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,64
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Filter-Depth (Strt)",0
.toASC			dc.b	"Filter-Depth (End)",0
			even
.from			dc.l	0
.to			dc.l	0

.tags2			dc.l	rt_window,0
			dc.l	rtgl_min,1
			dc.l	rtgl_max,999
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.passASC		dc.b	"Filter-Passes",0
			even
.pass			dc.l	0
.passwork		dc.l	0
;--------------------------------------------------------------------
; Program	:	Ramp-Booster function for samples
; Author	:	Bastian Spiegel (Twice/Lego)
; Date		:	4.December 1994

waveed_DigiBooster:
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange

			bsr	waveed_actrangedata

; out:	d0=wavesize	d7=rangesize	a0=pointer on range

booskp1			MOVEQ	#0,D0		; raped from pt2.0 source
booloop			MOVE.B	(A0),D1		; to achieve the original
			EXT.W	D1		; pt-sound !!
			MOVE.W	D1,D2
			SUB.W	D0,D1
			MOVE.W	D2,D0
			TST.W	D1
			BMI	booneg
			ASR.W	#2,D1
			ADD.W	D1,D2
			BRA	booskip
booneg			NEG.W	D1
			ASR.W	#2,D1
			SUB.W	D1,D2
booskip			CMP.W	#127,D2
			BLE	booskp2
			MOVEQ	#127,D2
booskp2			CMP.W	#-128,D2
			BGE	booskp3
			MOVEQ	#-128,D2
booskp3			MOVE.B	D2,(A0)+
			DBRA	D7,booloop

			jmp	refresh_waveedwaveall
;--------------------------------------------------------------------
; Program	:	Ramp-Volume Function for samples
; Author	:	Bastian Spiegel (Twice/Lego)
; Date		:	19.September.94

waveed_RampVolume
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave

.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.to(pc),a1
			lea	.toASC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok2
			rts
.ok2
			bsr	waveed_actwavedata
			add.l	waveed_wavepos(a5),a0
			move.l	waveed_rangesize(a5),d7
			move.l	.from(pc),d0		; Volume start
			move.l	.to(pc),d1		; Volume end

			lsl.l	#7,d0
			beq.b	.zero1
			divu	#100,d0
			and.l	#$ffff,d0
.zero1			lsl.l	#7,d1
			beq.b	.zero2
			divu	#100,d1
			and.l	#$ffff,d1
.zero2
			move.l	d0,d6
			sub	d0,d1	; d3=delta volume
			bpl.b	.deltapos
			neg	d1
			swap	d1
			move.l	d1,d0
			move.l	d7,d1	; durch länge teilen
			bsr	divu_l
			move.l	d0,d4	; d0=addx
			clr	d4
			swap	d4	; byteadd
			moveq	#0,d3
			move	d0,d3	; addx-cntadd
			moveq	#0,d5
			bra	.deltanegloop

.deltapos		swap	d1	; *$10000
			move.l	d1,d0
			move.l	d7,d1	; durch länge teilen
			bsr	divu_l
			move.l	d0,d4	; d0=addx
			clr	d4
			swap	d4	; byteadd
			moveq	#0,d3
			move	d0,d3	; addx-cntadd
			moveq	#0,d5	; cnter

.loop
			moveq	#0,d1
			move.b	(a0),d1
			ext	d1
			muls	d6,d1	; *volume percent
			asr	#7,d1
			bpl.b	.pos
			cmp	#-127,d1
			bge.b	.amplok
			moveq	#-127,d1
.pos			cmp	#127,d1
			ble.b	.amplok
			moveq	#127,d1
.amplok
			move.b	d1,(a0)+

			add	d3,d5
			addx	d4,d6

			subq.l	#1,d7
			bne.b	.loop

			bra	refresh_waveedwaveall
.deltanegloop
			moveq	#0,d1
			move.b	(a0),d1
			ext	d1
			muls	d6,d1	; *volume percent
			asr	#7,d1
			bpl.b	.pos2
			cmp	#-127,d1
			bge.b	.amplok2
			moveq	#-127,d1
.pos2			cmp	#127,d1
			ble.b	.amplok2
			moveq	#127,d1
.amplok2
			move.b	d1,(a0)+

			add	d3,d5
			subx	d4,d6

			subq.l	#1,d7
			bne.b	.deltanegloop

			bra	refresh_waveedwaveall
.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,200
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Vol-Ramp % (Strt)",0
.toASC			dc.b	"Vol-Ramp % (End)",0
			even
.from			dc.l	0
.to			dc.l	0
;--------------------------------------------------------------------
waveed_settozero
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actrangedata
.loop			clr.b	(a0)+
			subq.l	#1,d7
			bne.b	.loop
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_invert
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actrangedata
.loop			neg.b	(a0)+
			subq.l	#1,d7
			bne.b	.loop
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_ypos
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			bsr	waveed_actrangedata
			move.l	.from(pc),d0
.loop			add.b	d0,(a0)+
			subq.l	#1,d7
			bne.b	.loop
			bra	refresh_waveedwaveall

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,-127
			dc.l	rtgl_max,127
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Y-Pos",0
			even
.from			dc.l	0
;--------------------------------------------------------------------
waveed_backwards
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actrangedata
			cmp.l	#2,d7
			blt.b	.invalidrange
			move.l	d7,d6
			lsr.l	#1,d6
.loop			move.b	(a0),d0
			move.b	(a0,d7.l),d1
			move.b	d0,(a0,d7.l)
			move.b	d1,(a0)+
			subq.l	#2,d7
			subq.l	#1,d6
			bne.b	.loop
			bra	refresh_waveedwaveall
.invalidrange		lea	msg_wave_invrange,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------
waveed_maximize
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actrangedata
			move.l	d7,d6
			move.l	a0,a1
			moveq	#0,d0
			moveq	#0,d1
.searchmax		move.b	(a1)+,d1
			bpl.b	.avpos
			neg.b	d1
.avpos			cmp.b	d1,d0
			bge.b	.avsame
			move.b	d1,d0
.avsame			subq.l	#1,d6
			bne.b	.searchmax
; d0=maximale amplitude
; 127/d0=x		; x=volume-boost
; (127*128)/d0=x(*128)
			move.l	#127*128,d1
			tst	d0
			beq.b	.exit
			divu	d0,d1
			and.l	#$ffff,d1
; d1=volboost
.loop			move.b	(a0),d0
			ext	d0
			muls	d1,d0
			asr	#7,d0
			move.b	d0,(a0)+
			subq.l	#1,d7
			bne.b	.loop
			bra	refresh_waveedwaveall
.exit			rts
;--------------------------------------------------------------------
waveed_clearbuf		movem.l	d0-a6,-(sp)
			move.l	exec,a6
			move.l	waveed_bufadr(a5),a1
			cmp.l	#0,a1
			beq.b	.alreadyclrd
			jsr	exec_freevec(a6)
			clr.l	waveed_bufadr(a5)
			clr.l	waveed_buflen(a5)
.alreadyclrd		movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
waveed_mixwithbuf:
			move.l	waveed_bufadr(a5),a1
			move.l	waveed_buflen(a5),d4
			bne.b	.ok22
			lea	msg_wave_bufferempty,a2
			jmp	displaymessageWAVE
.ok22
			bsr	waveed_actwavedata
			move.l	d0,d7
			bne.b	.ok33
			lea	msg_wave_mixnowave,a2
			jmp	displaymessageWAVE
.ok33

			cmp.l	d0,d4
			blt	mix_useoldwave

			movem.l	d1-a6,-(sp)
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			move.l	d4,d0
			jsr	exec_allocvec(a6)
			movem.l	(sp)+,d1-a6
			tst.l	d0
			beq.b	.nomem
			move.l	d0,.newwavestart
			move.l	d0,a2
.loop
			moveq	#0,d2
			moveq	#0,d3
			move.b	(a0)+,d2
			move.b	(a1)+,d3
			ext	d2
			ext	d3
			add	d2,d3
			asr	#1,d3
			move.b	d3,(a2)+
			subq.l	#1,d4
			subq.l	#1,d7
			bne.b	.loop
			tst.l	d4		; kein rest?
			beq.b	.out

.halfrest		move.b	(a1)+,d0
			asr.b	#1,d0
			move.b	d0,(a2)+
			subq.l	#1,d4
			bne.b	.halfrest
.out			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			bsr	freewave
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add	d0,d0
			add	d0,d0
			lea	aon_wavestarts+aon_data,a4
			move.l	.newwavestart(pc),(a4,d0.l)
			lea	module_wavelenlist,a4
			move.l	waveed_buflen(a5),(a4,d0.l)

			bsr	waveed_veradjust
			bsr	refresh_instrumentED
			bsr	waveed_setshowall
			bra	refresh_waveedwaveall
.nomem
			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWAVE
.newwavestart		dc.l	0
;----------------------------------------- ğ · >
mix_useoldwave
			moveq	#0,d2
			moveq	#0,d3
			move.b	(a0),d2
			move.b	(a1)+,d3
			ext	d2
			ext	d3
			add	d2,d3
			asr	#1,d3
			move.b	d3,(a0)+
			subq.l	#1,d0
			subq.l	#1,d4
			bne.b	mix_useoldwave
			tst.l	d0		; kein rest?
			beq.b	.out
.halfrest		move.b	(a0),d1
			asr.b	#1,d1
			move.b	d1,(a0)+
			subq.l	#1,d0
			bne.b	.halfrest
.out			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_freeactwave	movem.l	d0-a6,-(sp)
			move.l	exec,a6
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add	d0,d0
			add	d0,d0
			lea	aon_wavestarts+aon_data,a0
			move.l	(a0,d0.l),a1
			clr.l	(a0,d0.l)
			lea	module_wavelenlist,a0
			clr.l	(a0,d0.l)
			cmp.l	#0,a1
			beq.b	.alreadyempty
			jsr	exec_freevec(a6)
.alreadyempty		movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
waveed_cutbuf
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_clearbuf

			bsr	waveed_actrangedata
			move.l	d7,d0
			move.l	a0,d6
			moveq	#memf_public,d1
			move.l	exec,a6
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq	.nomem
			move.l	d0,waveed_bufadr(A5)
			move.l	d7,waveed_buflen(a5)

			move.l	d0,a1
			move.l	d6,a0
			move.l	d7,d6
.copybuf		move.b	(a0)+,(a1)+
			subq.l	#1,d6
			bne.b	.copybuf
; so, der buffer ist jetzt voll und allokiert, jetzt das sample zurecht-
; schneiden!
			bsr	waveed_actwavedata
			move.l	d0,d4		; old-len
			move.l	a0,d5		; old-start
			bsr	waveed_actrangedata
			sub.l	d7,d0		; d0=new wave-len
			move.l	d0,d6		; store 4 l8r use
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq.w	.nomem2
; d0=adress of new wave
; d6=new wave-len
; d5=old wave-start
; d4=old wave-len
			move.l	d0,a1
			move.l	d5,a0
			move.l	waveed_wavepos(a5),d1	; bis zum range-start
			beq.b	.skip1
.copynormal		move.b	(a0)+,(a1)+		; kopieren
			subq.l	#1,d1
			bne.b	.copynormal
.skip1			add.l	waveed_rangesize(a5),a0	; skip range (=cut!!)
			move.l	d4,d1
			sub.l	waveed_rangesize(a5),d1
			sub.l	waveed_wavepos(a5),d1
			beq.b	.skip2
.copylast		move.b	(a0)+,(a1)+
			subq.l	#1,d1
			bne.b	.copylast
.skip2
			bsr	waveed_freeactwave

			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a0
			move.l	d6,(a0,d2.l)		; len of wave
			lea	aon_wavestarts+aon_data,a0
			move.l	d0,(a0,d2.l)		; start of wave

			move.l	waveed_dispsize(a5),d0
			sub.l	waveed_rangesize(a5),d0
			beq.b	.dispfull
			bpl.b	.dispok
.dispfull		clr.l	waveed_off(a5)
			move.l	d6,d0
.dispok			move.l	d0,waveed_dispsize(a5)
			
			clr.l	waveed_rangesize(a5)

			bsr	waveed_verAdjust
			bra	refresh_waveedwaveall

.nomem			lea	msg_wave_cutbufnomem,a2
			jmp	displaymessageWave
.nomem2			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------
waveed_copybuf
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_clearbuf

			bsr	waveed_actrangedata
			move.l	d7,d0
			move.l	a0,d6
			moveq	#memf_public,d1
			move.l	exec,a6
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq	.nomem
			move.l	d0,waveed_bufadr(A5)
			move.l	d7,waveed_buflen(a5)

			move.l	d0,a1
			move.l	d6,a0
			move.l	d7,d6
.copybuf		move.b	(a0)+,(a1)+
			subq.l	#1,d6
			bne.b	.copybuf
			rts
.nomem			lea	msg_wave_copybufnomem,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------
waveed_insertbuf
			tst.l	waveed_buflen(a5)
			bne.b	.bufmtok
			lea	msg_wave_bufferempty,a2
			jmp	displaymessageWave
.bufmtok
			bsr	waveed_actwavedata
			move.l	d0,d4		; old-len
			move.l	a0,d5		; old-start
			bsr	waveed_actrangedata
			add.l	waveed_buflen(a5),d0	; d0=new wave-len
			move.l	d0,d6		; store 4 l8r use
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			jsr	exec_allocvec(a6)
			tst.l	d0
			beq.w	.nomem2
; d0=adress of new wave
; d6=new wave-len
; d5=old wave-start
; d4=old wave-len
			move.l	d0,a1
			move.l	d5,a0
			move.l	waveed_wavepos(a5),d1	; bis zum range-start
			beq.b	.skip1
.copynormal		move.b	(a0)+,(a1)+		; kopieren
			subq.l	#1,d1
			bne.b	.copynormal
.skip1
			move.l	waveed_bufadr(a5),a2	; dann buffer einfügen
			move.l	waveed_buflen(a5),d1
.copybuf		move.b	(a2)+,(a1)+
			subq.l	#1,d1
			bne.b	.copybuf

			move.l	d4,d1
			sub.l	waveed_wavepos(a5),d1
			beq.b	.skip2
.copylast		move.b	(a0)+,(a1)+
			subq.l	#1,d1
			bne.b	.copylast
.skip2
			bsr	waveed_freeactwave

			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a0
			move.l	d6,(a0,d2.l)		; len of wave
			lea	aon_wavestarts+aon_data,a0
			move.l	d0,(a0,d2.l)		; start of wave

			move.l	waveed_dispsize(a5),d0
			add.l	waveed_buflen(a5),d0
			move.l	d0,waveed_dispsize(a5)

			bsr	waveed_verAdjust
			bra	refresh_waveedwaveall

.nomem2			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------

;--------------------------------------------------------------------
waveed_playoff		clr.b	replaystatus(a5)
			bra	equ_resetchannels
;--------------------------------------------------------------------
waveed_LoadWave
			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	samplereqptr(a5),a1
			lea	sample_filename,a2
			lea	sample_filereqtitleLOAD,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	samplereqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	sample_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			bra	displaymessageWave
.notfileerror
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			bsr	freewave

			lea	iobuffer+200,a4
			move.l	a4,a0
			moveq	#256/4-1,d7
.clrbuf			clr.l	(a0)+
			dbf	d7,.clrbuf
			move.l	a4,d2
			move.l	#256,d3
			read1
			move	#256/2-1,d7
.searchbody		cmp.l	#"BODY",(a4)
			beq.b	.bodyfound
			addq.l	#2,a4
			dbf	d7,.searchbody
			bra.b	.noiff
.bodyfound		move.l	4(a4),iobuffer+2122
			lea	8(a4),a4
			sub.l	#iobuffer+200,a4
			move.l	a4,d2
			move.l	filehandle(a5),d1
			moveq	#-1,d3
			jsr	dos_seek(a6)
			bra.b	.iff

.noiff			moveq	#0,d2
			move.l	filehandle(a5),d1
			moveq	#-1,d3
			jsr	dos_seek(a6)

			move.l	#iobuffer+2000,d2	; filelänge holen
			move.l	filehandle(a5),d1
			jsr	dos_examineFH(a6)
.iff
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0	; d0=Wavenr
			move.l	iobuffer+2122,d1	; d1=Filelänge
			bsr	allocwave
			move.l	d0,d2			; waveadr
			bne.b	.stillfree
			lea	msg_instred_outofmemory,a2
			bsr	displaymessageWave
			bra.b	.close
.stillfree
			move.l	filehandle(a5),d1
			move.l	iobuffer+2122,d3
			jsr	dos_read(a6)
			tst.l	d0
			bmi	ioerror2

.close			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

			bsr	waveed_actwavedata
			move.b	waveed_actwave(a5),dseq_adjwave
			move.l	d0,dseq_adjLEN
			jsr	dseq_okadjustwavelens

			bsr	waveed_setshowall
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_Flushwave
			clr.b	winwave_override(a5)
			move.l	intbase(a5),a6		; Warn-Requester
			move.l	windowptrwave(a5),a0	; ausgeben
			lea	clrwave_str,a1
			jsr	patcheasyreqARGS
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.yo
			rts
.yo			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			bsr	freewave
			bsr	waveed_actwavedata

			bsr	waveed_setshowall
			bra	refresh_waveedwaveall
;--------------------------------------------------------------------
waveed_savewave
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessageWave
			else

			bsr	waveed_actwavedata
			tst.l	d0
			bne.b	.ok
			rts
.ok
			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	samplereqptr(a5),a1
			lea	sample_filename,a2
			lea	sample_filereqtitleSAVE,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	samplereqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	sample_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			jmp	displaymessageWave
.notfileerror
			bsr	waveed_actwavedata
			move.l	d0,d3
			move.l	a0,d2
			move.l	filehandle(a5),d1
			jsr	dos_write(a6)		; write
			tst.l	d0
			bmi	ioerror2
			move.l	filehandle(a5),d1
			jmp	dos_close(a6)
			endif
;--------------------------------------------------------------------
waveed_savebuf
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessageWave
			else

			tst.l	waveed_buflen(a5)
			bne.b	.bufmtok
			lea	msg_wave_bufferempty,a2
			jmp	displaymessageWave
.bufmtok
			clr.b	winwave_override(a5)
			move.l	rtbase(a5),a6
			move.l	samplereqptr(a5),a1
			lea	sample_filename,a2
			lea	sample_filereqtitleSAVEBUF,a3
			lea	mod_filereqTAGSwave,a0
			jsr	rtFileRequestA(a6)
			move.b	#1,winwave_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.notcanceled
			rts
.notcanceled
			move.l	samplereqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	sample_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6
			move.l	a2,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.notfileerror
			lea	msg_io_filenotfound,a2
			jmp	displaymessageWave
.notfileerror
			move.l	waveed_bufadr(a5),d2
			move.l	waveed_buflen(a5),d3
			move.l	filehandle(a5),d1
			jsr	dos_write(a6)		; write
			tst.l	d0
			bmi	ioerror2
			move.l	filehandle(a5),d1
			jmp	dos_close(a6)
			endif
;--------------------------------------------------------------------
waveed_upsample
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actwavedata

			movem.l	d1-d4/d6-d7/a0-a6,-(sp)
			bsr	waveed_actwavedata
			bsr	waveed_actrangedata
			lsr.l	#1,d7
			sub.l	d7,d0		; d0=new wave-len
			move.l	d0,d5
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			jsr	exec_allocvec(a6)
			movem.l	(sp)+,d1-d4/d6-d7/a0-a6
			tst.l	d0
			beq	.nomem
; d0=new waveadr
; d5=new wavelen
			move.l	d0,-(sp)
			move.l	d0,a3
			move.l	a0,a2
			move.l	waveed_wavepos(a5),d6	; bis zum range-start
			beq.b	.wpos0
.copywave		move.b	(a2)+,(a3)+
			subq.l	#1,d6
			bne.b	.copywave
.wpos0
			move.l	waveed_rangesize(a5),d7	; range upsampeln
			lsr.l	#1,d7
			beq.b	.nosamp
			move.l	d7,d6
.shortloop		move.b	(a2),(a3)+
			addq.l	#2,a2
			subq.l	#1,d7
			bne.b	.shortloop
.nosamp
			bsr	waveed_actwavedata
			move.l	d0,d6
			sub.l	waveed_rangesize(a5),d6	; bis zum waveende
			sub.l	waveed_wavepos(a5),d6
			beq.b	.mt
.copywave2		move.b	(a2)+,(a3)+
			subq.l	#1,d6
			bne.b	.copywave2
.mt
			move.l	(sp)+,d0
; wave eintragen
			bsr	waveed_freeactwave
			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a0
			move.l	d5,(a0,d2.l)		; len of wave
			lea	aon_wavestarts+aon_data,a0
			move.l	d0,(a0,d2.l)		; start of wave

			move.l	waveed_rangesize(a5),d0
			lsr.l	#1,d0
			move.l	d0,waveed_rangesize(a5)

			bsr	waveed_verAdjust
			bsr	waveed_setshowall
			bra	refresh_waveedWaveall
.nosamp2

.nomem
			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------
waveed_verAdjust:
			bsr	waveed_actwavedata
			move.b	waveed_actwave(a5),dseq_adjwave
			move.l	d0,dseq_adjLEN
			jmp	dseq_okadjustwavelens
;--------------------------------------------------------------------
; Program	:	Phase-Shifter (PD Phase Distortion)
; Author	:	Bastian Spiegel (Twice/Lego)
; Date		:	26.September 1994

* This little routine was originally invented by Casio with their
* CZ Series , just check it out, sounds nice (best example for
* Phase Distortion is the good old 64er Rectange-Phase-Distortion,
* bet you heard it somewhen ... ;)

Waveed_PhaseDistortion:
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			cmp.l	#512,waveed_rangesize(a5)
			ble.b	.rangeok
			lea	msg_wave_pdrange2big,a2
			jmp	displaymessageWave
.rangeok
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok

			move.l	.from(pc),d1
			bsr	waveed_actrangedata
			move.l	d7,d0
;--------------------------------------------------------------------
; IN:
; a0=Pointer on wave
; d0=Phase Bytelen
; d1=Distortion (128=Normal,256=No second halfphase,0=No first halfphase)
			movem.l	d0-a6,-(sp)
			lea	.wb(pc),a1

			lsr	#1,d0		; size of halfphase
			beq.w	.exitrout	; =0 then exit

			movem.l	d0/d1,-(sp)

			moveq	#0,d2
			move	d0,d2
			mulu	d1,d0
			lsr	#7,d0
			beq.b	.do2ndphase
			
; d0=new first halfphase len
; d2=old first halfphase len			
			swap	d2
			movem.l	d0/d1,-(sp)
			move.l	d2,d1
			exg.l	d0,d1
			jsr	divu_l		; divu.l d0,d2
			move.l	d0,d2
			movem.l	(sp)+,d0/d1

; d2=addx (z.b.$8000)
			move.l	d2,d4
			swap	d4
			and.l	#$ffff,d4
			moveq	#0,d5
			moveq	#0,d6
; d4=byte add
; d5=addx cntr
; d6=byte offset-cntr
; d0=new halfphase len
.loop1			move.b	(a0,d6.l),(a1)+
			add	d2,d5
			addx.l	d4,d6
			subq.l	#1,d0
			bne.b	.loop1

.do2ndphase
			movem.l	(sp)+,d0/d1

			move.l	d0,d6

			move	#256,d2
			sub	d1,d2
			move	d2,d1

			moveq	#0,d2
			move	d0,d2
			mulu	d1,d0
			lsr	#7,d0
			beq.b	.exitrout2
			
; d0=new first halfphase len
; d2=old first halfphase len			
			swap	d2
			movem.l	d0/d1,-(sp)
			move.l	d2,d1
			exg.l	d0,d1
			jsr	divu_l		; divu.l d0,d2
			move.l	d0,d2
			movem.l	(sp)+,d0/d1
; d2=addx (z.b.$8000)
			move.l	d2,d4
			swap	d4
			and.l	#$ffff,d4
			moveq	#0,d5
; d4=byte add
; d5=addx cntr
; d6=byte offset-cntr
; d0=new halfphase len
.loop2			move.b	(a0,d6.l),(a1)+
			add	d2,d5
			addx.l	d4,d6
			subq.l	#1,d0
			bne.b	.loop2
.exitrout2
			movem.l	(sp),d0-a6
			lea	.wb(pc),a1
.copy			move.b	(a1)+,(a0)+
			subq.l	#1,d0
			bne.b	.copy

.exitrout		movem.l	(sp)+,d0-a6
			bra	refresh_waveedwaveALL


.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,256
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Phase-Distortion",0
			even
.from			dc.l	0
.wb
waveed_workbuf		ds.b	512+16	; sicherheit
;------------------------------------------------------------------------
;waveed_copyfromChange	move	#gad_wavechangecopyfrom,lastdownID(a5)
;waveed_copyfromChangeUP	move.b	$19(a0),waveed_copyfrom(a5)
;			bra	refresh_waveedCopyFrom
;waveed_copyfromChangeNOW
;			move.l	#instred_mmm,-(sp)
;			bra.b	waveed_copyfromchangeup
;;------------------------------------------------------------------------
;waveed_copytoChange	move	#gad_wavechangecopyto,lastdownID(a5)
;waveed_copytoChangeUP	move.b	$19(a0),waveed_copyto(a5)
;			bra	refresh_waveedCopyto
;waveed_copytoChangeNOW	move.l	#instred_mmm,-(sp)
;			bra.b	waveed_copytochangeup
;;--------------------------------------------------------------------
;waveed_movewave
;			moveq	#0,d0
;			move.b	waveed_copyto(a5),d0
;			cmp.b	waveed_copyfrom(a5),d0
;			beq.b	.exit
;			bsr	freewave
;
;			moveq	#0,d0
;			move.b	waveed_copyfrom(a5),d0
;			moveq	#0,d1
;			move.b	waveed_copyto(a5),d1
;			add	d0,d0
;			add	d0,d0
;			add	d1,d1
;			add	d1,d1
;			lea	module_wavelenlist,a0
;			move.l	(a0,d0),(a0,d1)
;			clr.l	(a0,d0)
;			lea	aon_wavestarts+aon_data,a0
;			move.l	(a0,d0),(a0,d1)
;			clr.l	(a0,d0)
;			bsr	waveed_setshowall
;			bra	refresh_waveedwaveall
;.exit			rts
;;--------------------------------------------------------------------
;waveed_exchangewave
;			moveq	#0,d0
;			move.b	waveed_copyfrom(a5),d0
;			moveq	#0,d1
;			move.b	waveed_copyto(a5),d1
;			cmp.b	d1,d0
;			beq.b	.exit
;			add	d0,d0
;			add	d0,d0
;			add	d1,d1
;			add	d1,d1
;			lea	module_wavelenlist,a0
;			move.l	(a0,d0),d2
;			move.l	(a0,d1),(a0,d0)
;			move.l	d2,(a0,d1)
;			lea	aon_wavestarts+aon_data,a0
;			move.l	(a0,d0),d2
;			move.l	(a0,d1),(a0,d0)
;			move.l	d2,(a0,d1)
;			bsr	waveed_setshowall
;			bra	refresh_waveedwaveall
;.exit			rts
;;--------------------------------------------------------------------
;waveed_copywave
;			moveq	#0,d0
;			move.b	waveed_copyfrom(a5),d0
;			add	d0,d0
;			add	d0,d0
;			lea	module_wavelenlist,a0
;			move.l	(a0,d0),d1
;			move.l	d1,d6
;			lea	aon_wavestarts+aon_data,a0
;			move.l	(a0,d0),d7
;
;			moveq	#0,d0
;			move.b	waveed_copyto(a5),d0
;			cmp.b	waveed_copyfrom(a5),d0
;			beq.b	.exit
;			bsr	freewave
;			moveq	#0,d0
;			move.b	waveed_copyto(a5),d0
;			bsr	allocwave
;			tst.l	d0
;			beq.b	.nomem
;			move.l	d0,a1
;			move.l	d7,a0
;.copy			move.b	(a0)+,(a1)+
;			subq.l	#1,d6
;			bne.b	.copy
;
;			bsr	waveed_setshowall
;			bra	refresh_waveedwaveall
;.nomem			lea	msg_wave_nonewwave,a2
;			jmp	displaymessageWave
;.exit			rts
;--------------------------------------------------------------------

;--------------------------------------------------------------------
waveed_dnsample:
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			bsr	waveed_actwavedata


			movem.l	d1-d4/d6-d7/a0-a6,-(sp)
			bsr	waveed_actwavedata
			bsr	waveed_actrangedata
			add.l	d7,d0		; d0=new wave-len
			add.l	d7,d7
			move.l	d0,d5
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			jsr	exec_allocvec(a6)
			movem.l	(sp)+,d1-d4/d6-d7/a0-a6
			tst.l	d0
			beq	.nomem
; d0=new waveadr
; d5=new wavelen
			move.l	d0,-(sp)
			move.l	d0,a3
			move.l	a0,a2
			move.l	waveed_wavepos(a5),d6	; bis zum range-start
			beq.b	.wpos0
.copywave		move.b	(a2)+,(a3)+
			subq.l	#1,d6
			bne.b	.copywave
.wpos0
			move.l	waveed_rangesize(a5),d7	; range dnsampeln
			beq.b	.nosamp
			move.l	d7,d6
			movem.l	d0/d1,-(sp)
.shortloop		moveq	#0,d0
			moveq	#0,d1
			move.b	(a2)+,d0
			move.b	d0,(a3)+
			move.b	(a2),d1
			ext	d0
			ext	d1
			add	d0,d1
			asr	#1,d1
			move.b	d1,(a3)+
			subq.l	#1,d7
			bne.b	.shortloop
			movem.l	(sp)+,d0/d1
.nosamp
			bsr	waveed_actwavedata
			move.l	d0,d6
			sub.l	waveed_rangesize(a5),d6	; bis zum waveende
			sub.l	waveed_wavepos(a5),d6
			beq.b	.mt
.copywave2		move.b	(a2)+,(a3)+
			subq.l	#1,d6
			bne.b	.copywave2
.mt
			move.l	(sp)+,d0
; wave eintragen
			bsr	waveed_freeactwave
			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a0
			move.l	d5,(a0,d2.l)		; len of wave
			lea	aon_wavestarts+aon_data,a0
			move.l	d0,(a0,d2.l)		; start of wave

			move.l	waveed_rangesize(a5),d0
			add.l	d0,d0
			move.l	d0,waveed_rangesize(a5)

			bsr	waveed_verAdjust
			bsr	waveed_setshowall
			bra	refresh_waveedWaveall

.nomem
			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave

;--------------------------------------------------------------------
waveed_partwavelenChange
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			move	d0,waveed_partwavelen(a5)
			rts
;------------------------------------------------------------------------
waveed_partwaveChange	move	#gad_wavepartwave,lastdownID(a5)
			bra.b	waveed_pwchnow
waveed_partwaveChangeUP
			cmp	#gad_wavepartwave,lastdownid(a5)
			bne.b	waveed_pwchnow
			rts
waveed_pwchnow
			move.l	a0,a1
			bsr	waveed_actwavedata
			move.l	d0,d2
			moveq	#0,d0
			move.b	$19(a1),d0
			move.b	d0,waveed_actpartwave(a5)
			moveq	#0,d1
			move	waveed_partwavelen(a5),d1
			beq.b	.exit
			mulu	d1,d0

			move.l	d0,d3
			add.l	d1,d3
			cmp.l	d2,d3
			ble.b	.inrange
.exit			rts
.inrange		move.l	d0,waveed_off(a5)
			move.l	d1,waveed_dispsize(a5)
			bsr	refresh_waveedpartwave
			bra	refresh_waveedwaveall
waveed_partwaveChangeNOW
			move.l	#instred_mmm,-(sp)
			bra.b	waveed_pwchnow
;--------------------------------------------------------------------
;;; program	:	Flanger-Effect (Art Of Noise)
;;; author	:	Bastian Spiegel (twice of lego)
waveed_flanger:

			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.dep(pc),a1
			lea	.depaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok

			bsr	waveed_actwavedata

			movem.l	d1-d4/d6-d7/a0-a6,-(sp)
			move.l	d0,d5		; d0=new wave-len
			tst.b	chmode(a5)
			beq.b	.4ch2
			moveq	#memf_public,d1
			bra.b	.8ch2
.4ch2			moveq	#memf_chip,d1
.8ch2			move.l	exec,a6
			jsr	exec_allocvec(a6)
			movem.l	(sp)+,d1-d4/d6-d7/a0-a6
			tst.l	d0
			beq	.nomem
; d0=new waveadr
; d5=new wavelen

			movem.l	d0-a6,-(sp)
			move.l	d0,a3
			move.l	a0,a2
			move.l	d5,d6
.copywave		move.b	(a2)+,(a3)+
			subq.l	#1,d6
			bne.b	.copywave
.wpos0
			movem.l	d0-a6,-(sP)
			move.l	d0,a2
			add.l	waveed_wavepos(A5),a0
			add.l	waveed_wavepos(A5),a2
			move.l	waveed_rangesize(a5),d7
			moveq	#0,d0
			move.l	.dep(pc),d1
			bsr	resofx
			movem.l	(sp)+,d0-a6
			movem.l	(sp)+,d0-a6

; wave eintragen
			bsr	waveed_freeactwave
			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
			lea	module_wavelenlist,a0
			move.l	d5,(a0,d2.l)		; len of wave
			lea	aon_wavestarts+aon_data,a0
			move.l	d0,(a0,d2.l)		; start of wave

			bra	refresh_waveedWaveall
.nomem
			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave
.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,255
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.depASC			dc.b	"Flanger-Depth",0
			even
.dep			dc.l	0
; d0=MixOffset-Start (byteadd)
; d1=floatpoint
; d7=Sample-length
; a0=Pointer on wave
; a2=Pointer on destwave
resofx
			movem.l	d0-a6,-(sp)
			move.l	#256,d3
			sub	d1,d3
			move.l	#$10000,d1
			sub.l	d3,d1
			lea	(a0,d0.l),a1	; add sampleoffset
			moveq	#0,d3		; float-count
.loop
			moveq	#0,d0
			moveq	#0,d2
			move.b	(a0)+,d0
			move.b	(a1),d2
			ext	d0
			ext	d2
			add	d0,d2
			asr	#1,d2
			move.b	d2,(a2)+
			moveq	#0,d2
			add	d1,d3
			addx	d2,d2
			lea	(a1,d2.l),a1
			subq.l	#1,d7
			bne.b	.loop
			movem.l	(Sp)+,d0-a6
			rts
;--------------------------------------------------------------------
waveed_samplefreq:
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			beq.b	refresh_waveedsamplefreq
			move.l	#28876*124,d1
			exg.l	d0,d1
			jsr	divu_l
			move	d0,sample_period(a5)
			rts
refresh_waveedsamplefreq:
			move.l	#28876*124,d0
			moveq	#0,d1
			move	sample_period(a5),d1
			jsr	divu_l

			move.l	d0,ref_ikind_data2
			moveq	#gad_wavesamplefreq,d0
			bra	refresh_integer_kind2
;--------------------------------------------------------------------
waveed_sampledlen:
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			beq.b	refresh_waveedsampledlen
			cmp.l	#262144,d0
			ble.b	.ok
			move.l	#262144,d0
.ok			move.l	d0,sample_len(a5)
			rts
refresh_waveedsampledlen:
			move.l	sample_len(a5),ref_ikind_data2
			moveq	#gad_wavesampledlen,d0
			bra	refresh_integer_kind2
;--------------------------------------------------------------------
waveed_trig:
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			cmp	#127,d0
			ble.b	.ok
			moveq	#127,d0
.ok			move.b	d0,trig_sens(a5)
			rts
refresh_waveedtrig:
			clr.l	ref_ikind_data2
			move.b	trig_sens(a5),ref_ikind_data2+3
			moveq	#gad_wavetrig,d0
			bra	refresh_integer_kind2
;--------------------------------------------------------------------
waveed_sampleitnext:
			addq.b	#1,waveed_actwave(a5)
			addq.b	#1,acteditinstr+1(a5)
waveed_sampleit:	clr.b	samplenext(A5)
			move.l	$4,a6
			move.l	sample_len(a5),d0
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1
			bra.b	.8ch
.4ch			move.l	#$10002,d1
.8ch			jsr	exec_allocvec(a6)
			tst.l	d0		; kein speicher?!
			bne.b	.allocated
			lea	msg_wave_samplenomem,a2
			jmp	displaymessageWave
.allocated
			move.l	d0,samplebuf(a5)
			clr.b	sampledflag(a5)

			moveq	#0,d0
			move	sample_period(a5),d0
			bsr.b	sampler_monitor

			tst.b	sampledflag(a5)
			beq.b	.notsampled

			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			move.l	d0,d6
			bsr	freewave

			add	d6,d6
			add	d6,d6
			lea	aon_wavestarts+aon_data,a0
			move.l	samplebuf(a5),(a0,d6)
			lea	module_wavelenlist,a0
			move.l	sample_len(a5),(a0,d6)

			bsr	waveed_CreateinstrumentFIX
;bsr	waveed_veradjust
			tst.b	samplenext(A5)
			bne.w	waveed_sampleitnext

			bsr	waveed_setshowall
			bra	refresh_waveedWaveall
.notsampled
			move.l	samplebuf(a5),a1
			jmp	exec_freevec(a6)

;--------------------------------------------------------------------
; Art-Of-Noise	:	Sample-Modul
; coded by	:	Twice/Absolute! (adapted from Protracker-Sampler)
; last change	:	05.November.1993

			moveq	#0,d0
			move	sample_period(a5),d0
; d0=Period
SAMPLER_MONITOR
			movem.l	d0-a6,-(sp)

			bsr	samplerr_init

			move.l	#samplemonicop,$dff080
			clr	$dff088

			bsr	samplerr_monitor

.relbut			btst	#6,$bfe001
			beq.b	.relbut

			bsr	samplerr_end

			move.l	gfxbase+main_data,a0
			move.l	$26(a0),$dff080
			clr	$dff088

			movem.l	(sp)+,d0-a6
			tst.b	chmode(a5)
			beq.b	.4ch
			jsr	set8channels3
.4ch
			rts
;----------------------------------------------------
samplerr_init		lea	$dff000,a6
			lea	$bfd000,a5
			lea	$bfe001,a4
			move	#$4000,$9a(a6)
			lsr	#1,d0
			move	d0,$a6(a6)
			move	d0,$b6(a6)	; Sample-Period
			moveq	#$40,d0
			move	d0,$a8(a6)
			move	d0,$b8(a6)	; Monitor-Volume
			moveq	#0,d0
			move	d0,$aa(a6)
			move	d0,$ba(a6)	; Monitor-Ausgang =0
			move.b	#6,$200(a5)
			move.b	#2,(a5)
			move.b	#0,$300(a4)

			move	$2(a6),samplerr_olddmacon
			move	#$3ff,$96(a6)
			move	#$8000+2^5+2^7+2^8+2^9,$96(a6)
			rts
;----------------------------------------------------
samplerr_end		move	samplerr_olddmacon(pc),d0
			ori	#$8000,d0
			move	d0,$96(a6)
			moveq	#0,d0
			move	d0,$a8(a6)
			move	d0,$b8(a6)
			move	#$c000,$9a(a6)
			rts
;----------------------------------------------------
; a6=$dff000
; a5=$bfd000
; a4=$bfe001
samplerr_monitor
			move.l	samplebuf+main_data,a0
			move.l	Sample_len+main_data,d6
			lea	iobuffer+11800,a2

			moveq	#0,d1
			moveq	#0,d2
			moveq	#0,d3		; red-timeout

			move	#$180,d7
.WAITTBE1		btst	d7,$1e(a6)	; Auf Interrupt warten
			beq.s	.waittbe1
			move	d7,$9c(a6)	; Interrupt erledigt
			move.b	$100(a4),d0	; Parallelport-Byte holen
			sub.b	d7,d0		; zurechtrücken
			move.b	d0,$aa(a6)
			move.b	d0,$ba(a6)	; Ausgang zum D/A Wandler!

			tst.b	d3
			bne.b	.notredout
			move	#$0f0,monicol
			bra.b	.res2green
.notredout		subq.b	#1,d3
.res2green
			tst.b	d0
			bpl.b	.okmonipos
			neg.b	d0
.okmonipos		cmp.b	#117,d0
			blt.b	.noredzone
			move	#$f00,monicol
			moveq	#127,d3
.noredzone
			move.b	d0,(a2)+

			addq.b	#1,d2
			cmp.b	#64,d2		; immer aus 16 werten einen
			bne.b	.okeod		; durchschnittswert berechnen
			lea	iobuffer+11800,a2
			moveq	#0,d0
			moveq	#0,d1
			moveq	#64-1,d2
.calcdurch		move.b	(a2)+,d1	; werte zusammenrechnen
			add	d1,d0
			dbf	d2,.calcdurch
			lsr	#6,d0		; / anzahl
			move.b	#$ef,d2
			sub.b	d0,d2
			move.b	d2,monipos1
			lea	iobuffer+11800,a2

.okeod

			btst	#6,(a4)
			beq.b	.out
			btst	#10,$dff016
			beq.b	.sampleforreal
			btst	#6,(a4)
			bne.w	.waittbe1
.out			rts

.sampleforreal
			move	#$3ff,$96(a6)

			moveq	#0,d4
			moveq	#0,d5
			move.b	trig_sens+main_data,d4
			move.b	d4,d5
			neg.b	d5
			move	#$40f,$180(a6)
.WAITTBE5		btst	d7,$1e(a6)	; Auf Interrupt warten
			beq.s	.waittbe5
			move	d7,$9c(a6)	; Interrupt erledigt
			move.b	$100(a4),d0	; Parallelport-Byte holen
			sub.b	d7,d0		; zurechtrücken
			move.b	d0,$aa(a6)
			move.b	d0,$ba(a6)	; Ausgang zum D/A Wandler!
			cmp.b	d4,d0
			bgt.b	.samplestart
			cmp.b	d5,d0
			blt.b	.samplestart
			btst	#6,(a4)
			beq.b	.out3
.WAITTBE6		btst	d7,$1e(a6)	; Auf Interrupt warten
			beq.s	.waittbe6
			move	d7,$9c(a6)	; Interrupt erledigt
			move.b	$100(a4),d0	; Parallelport-Byte holen
			sub.b	d7,d0		; zurechtrücken
			move.b	d0,$ab(a6)
			move.b	d0,$bb(a6)	; Ausgang zum D/A Wandler!
			cmp.b	d4,d0
			bgt.b	.samplestart
			cmp.b	d5,d0
			blt.b	.samplestart
			btst	#6,(a4)
			bne.b	.waittbe5
.out3			btst	#10,$16(a6)
			beq.b	.waittbe5
			rts
.samplestart
			move.b	#1,sampledflag+main_data
			move	#$f00,$180(a6)
.WAITTBE3		btst	d7,$1e(a6)	; Auf Interrupt warten
			beq.s	.waittbe3
			move	d7,$9c(a6)	; Interrupt erledigt
			move.b	$100(a4),d0	; Parallelport-Byte holen
			sub.b	d7,d0		; zurechtrücken
			move.b	d0,$aa(a6)
			move.b	d0,$ba(a6)	; Ausgang zum D/A Wandler!
			move.b	d0,(a0)+
			subq.l	#1,d6
			beq	.out
			btst	#6,(a4)
			beq.b	.out2
.WAITTBE4		btst	d7,$1e(a6)	; Auf Interrupt warten
			beq.s	.waittbe4
			move	d7,$9c(a6)	; Interrupt erledigt
			move.b	$100(a4),d0	; Parallelport-Byte holen
			sub.b	d7,d0		; zurechtrücken
			move.b	d0,$ab(a6)
			move.b	d0,$bb(a6)	; Ausgang zum D/A Wandler!
			move.b	d0,(a0)+
			subq.l	#1,d6
			beq	.out
			btst	#6,(a4)
			bne.b	.waittbe3
.out2			btst	#10,$16(a6)
			beq.b	.nextsample
			rts
.nextsample		move.b	#1,samplenext+main_data
			rts
samplerr_olddmacon	dc	0
;--------------------------------------------------------------------
setnewwave
			clr.l	waveed_rangesize(a5)
			clr.l	waveed_wavepos(a5)
			jsr	instred_actualdata
			move.b	instr_waveform(a0),waveed_actwave(a5)
			jmp	waveed_setshowall
;--------------------------------------------------------------------
; Cut Zeros
waveed_cutzeros:
			bsr	waveed_actwavedata
; a0=act wave
; d0=wavelen
			tst.l	d0
			bne.b	.ok0
			rts
.ok0
			move.l	a0,.oldstart
			move.l	a0,a1
			move.l	d0,d1
.searchzeroend		cmp.b	#6,(a1,d1.l)
			bgt.b	.found
			cmp.b	#-6,(a1,d1.l)
			blt.b	.found
			subq.l	#1,d1
			bne.b	.searchzeroend
			rts
.found
; d1=new wavelen
			move.l	d1,.newlen
			move.l	d1,d0
			move.l	$4,a6
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1
			bra.b	.8ch
.4ch			move.l	#$10002,d1
.8ch			jsr	exec_allocvec(a6)
			tst.l	d0		; kein speicher?!
			bne.b	.free
			lea	msg_wave_nonewwave,a2
			jmp	displaymessageWave
.free
			move.l	.oldstart(pc),a0
			move.l	d0,a1
			move.l	d0,d1
			move.l	.newlen(pc),d7
			move.l	d7,d2
.copyit			move.b	(a0)+,(A1)+
			subq.l	#1,d7
			bne.b	.copyit

			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			bsr	freewave

			lea	module_wavelenlist,a0
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add.b	d0,d0
			add	d0,d0
			move.l	d2,(a0,d0)
			lea	aon_wavestarts+aon_data,a0
			move.l	d1,(a0,d0)

			bsr	waveed_verAdjust
			bsr	waveed_setshowall
			bra	refresh_waveedwaveall

.newlen			dc.l	0
.oldstart		dc.l	0
;--------------------------------------------------------------------
; Erzeugt ein beliebiges Instrument, das die aktuelle waveform benutzt
waveed_Createinstrument:
			lea	module_wavelenlist,a0
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0),d1
			lsr.l	#1,d1

			lea	module_instruments,a0
			moveq	#0,d2
			moveq	#61-1,d7
.instrloop
			tst.b	instr_control(a0)
			bne.b	.next
			tst	sample8_dmalen+2(a0)
			bne.b	.next
			move.b	#64,instr_volume(a0)
			move.b	#0,instr_finetune(a0)
			move.b	waveed_actwave(a5),instr_waveform(a0)
			clr.l	sample8_dmaoffset(a0)
			move.l	d1,sample8_dmalen(a0)
			clr.l	sample8_dmarepoffset(a0)
			clr.l	sample8_dmareplen(a0)
			move.b	d2,acteditinstr+1(a5)

			jsr	setnewwave
			bra	refresh_instrumented
.next			lea	32(a0),a0
			addq.b	#1,d2
			dbf	d7,.instrloop
			lea	msg_wave_nofreeinstr,a2
			jmp	displaymessageWave
;--------------------------------------------------------------------
; Erzeugt ein beliebiges Instrument, das die aktuelle waveform benutzt
fmed_createinstrumentFIX:
			move.b	waveed_actwave(a5),d7
			bsr	fmed_actfmdata
			move.b	fm_destwave(a0),waveed_actwave(a5)
			bsr	waveed_CreateinstrumentFIX
			move.b	d7,waveed_actwave(a5)
			rts
waveed_CreateinstrumentFIX:
			movem.l	d0-a6,-(sp)
			lea	module_wavelenlist,a0
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0),d1		; wavelen
			lsr.l	#1,d1

			lea	module_instruments,a0
			moveq	#0,d2
			move.b	acteditinstr+1(a5),d2
			lsl	#5,d2
			lea	(a0,d2.l),a0		; instrptr
			clr.b	instr_control(a0)
			move.b	#64,instr_volume(a0)
			move.b	#0,instr_finetune(a0)
			move.b	waveed_actwave(a5),instr_waveform(a0)
			clr.l	sample8_dmaoffset(a0)
			move.l	d1,sample8_dmalen(a0)
			clr.l	sample8_dmarepoffset(a0)
			clr.l	sample8_dmareplen(a0)
;move.b	d2,acteditinstr+1(a5)
			jsr	setnewwave
			bsr	refresh_instrumented
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
;
; Program	:	Resample for AONV1.6		NOTEDOWN
; Author	:	Unknown (Ripped from pt2.0 source!!)
; Date		:	??
waveed_resampleDOWN:
		bsr	waveed_actwavedata
		move.l	d0,d6
		beq	.tooshort

;--------------------------------------------------------------------
; a0=Sourcewave		d6=sourcewavelen
		move.l	#$d60,d1
		move.l	#$ca0,d5
; D1=resamperiod, D5=tuneperiod
		move.l	a0,a2
	
		move.l	d5,d0 ; tune
		lsl.l	#8,d0
		lsl.l	#4,d0 ; * 4096
		divu	d1,d0 ; / resample
		moveq	#0,d4	
		move	d0,d4
		lsl.l	#4,d4 ; hi-word=add value, lo-word=fraction

		move	d6,d7
		lsr	#1,d7
		mulu	d1,d7
		divu	d5,d7
		and.l	#$ffff,d7
		cmp	#2,d7
		blo	.tooshort
		cmp	#$7fff,d7
		blo	.resamlo
		move	#$7fff,d7
.resamlo	add.l	d7,d7

		movem.l	a0/a2/d4/d6/d7,-(sp)	; Neue wellenform allokieren
		move.l	exec,a6
		move.l	d7,d0
		move.l	d7,.newwavelen
		tst.b	chmode(a5)
		beq.b	.4ch
		move.l	#$10001,d1
		bra.b	.8ch
.4ch		move.l	#$10002,d1
.8ch		jsr	exec_allocvec(a6)
		tst.l	d0
		beq	.nomem
		move.l	d0,.newwaveadr
		move.l	d0,a1
		move.l	d0,a3
		movem.l	(sp)+,a0/a2/d4/d6/d7

; d4=resample value, d6=old length, d7=new length
; a0/a2=old sample, a1/a3=new sample

		move	#32767,d1
		moveq	#0,d3
		moveq	#0,d5
.loop
		move.b	1(a0),d0
		ext	d0
		muls	d1,d0
		move.b	(a0),d2
		ext	d2
		muls	d3,d2
		add.l	d2,d0
		asr.l	#8,d0
		asr.l	#7,d0
		move.b	d0,(a1)+

		add.l	d4,d5
		swap	d5
		move.l	a2,a0
		moveq	#0,d0
		move	d5,d0
		add.l	d0,a0
		swap	d5
		move	d5,d1
		lsr	#1,d1
		move	#32767,d3
		sub	d1,d3

		move.l	a1,a4
		sub.l	a3,a4
		cmp.l	d7,a4
		bhs.b	.skip
		move.l	a0,a4
		sub.l	a2,a4
		cmp.l	d6,a4
		blo.b	.loop
.skip

		lea	aon_wavestarts+aon_data,a4
		moveq	#0,d6
		move.b	waveed_actwave(a5),d6
		add	d6,d6
		add	d6,d6
		move.l	(a4,d6.l),a1
		move.l	exec,a6
		jsr	exec_freevec(a6)	; alte wellenform rauskicken

		move.l	.newwaveadr(pc),(a4,d6.l)
		lea	module_wavelenlist,a4
		move.l	.newwavelen(pc),(a4,d6.l)

		bsr	waveed_verAdjust
		bsr	waveed_setshowall
		jsr	refresh_instrumentED
		bra	refresh_waveedwaveall
.tooshort
		rts
.nomem
		movem.l	(sp)+,a0/a2/d4/d6/d7
		lea	msg_wave_nonewwave,a2
		jmp	displaymessageWAVE
.newwaveadr	dc.l	0
.newwavelen	dc.l	0
;--------------------------------------------------------------------
;
; Program	:	Resample for AONV1.6		NOTEUP
; Author	:	Unknown (Ripped from pt2.0 source!!)
; Date		:	??
waveed_resampleUP:
		bsr	waveed_actwavedata
		move.l	d0,d6
		beq	.tooshort

;--------------------------------------------------------------------
; a0=Sourcewave		d6=sourcewavelen
		move.l	#$d60,d5
		move.l	#$ca0,d1
; D1=resamperiod, D5=tuneperiod
		move.l	a0,a2
	
		move.l	d5,d0 ; tune
		lsl.l	#8,d0
		lsl.l	#4,d0 ; * 4096
		divu	d1,d0 ; / resample
		moveq	#0,d4	
		move	d0,d4
		lsl.l	#4,d4 ; hi-word=add value, lo-word=fraction

		move	d6,d7
		lsr	#1,d7
		mulu	d1,d7
		divu	d5,d7
		and.l	#$ffff,d7
		cmp	#2,d7
		blo	.tooshort
		cmp	#$7fff,d7
		blo	.resamlo
		move	#$7fff,d7
.resamlo	add.l	d7,d7

		movem.l	a0/a2/d4/d6/d7,-(sp)	; Neue wellenform allokieren
		move.l	exec,a6
		move.l	d7,d0
		move.l	d7,.newwavelen
		tst.b	chmode(a5)
		beq.b	.4ch
		move.l	#$10001,d1
		bra.b	.8ch
.4ch		move.l	#$10002,d1
.8ch		jsr	exec_allocvec(a6)
		tst.l	d0
		beq	.nomem
		move.l	d0,.newwaveadr
		move.l	d0,a1
		move.l	d0,a3
		movem.l	(sp)+,a0/a2/d4/d6/d7

; d4=resample value, d6=old length, d7=new length
; a0/a2=old sample, a1/a3=new sample

		move	#32767,d1
		moveq	#0,d3
		moveq	#0,d5
.loop
		move.b	1(a0),d0
		ext	d0
		muls	d1,d0
		move.b	(a0),d2
		ext	d2
		muls	d3,d2
		add.l	d2,d0
		asr.l	#8,d0
		asr.l	#7,d0
		move.b	d0,(a1)+

		add.l	d4,d5
		swap	d5
		move.l	a2,a0
		moveq	#0,d0
		move	d5,d0
		add.l	d0,a0
		swap	d5
		move	d5,d1
		lsr	#1,d1
		move	#32767,d3
		sub	d1,d3

		move.l	a1,a4
		sub.l	a3,a4
		cmp.l	d7,a4
		bhs.b	.skip
		move.l	a0,a4
		sub.l	a2,a4
		cmp.l	d6,a4
		blo.b	.loop
.skip

		lea	aon_wavestarts+aon_data,a4
		moveq	#0,d6
		move.b	waveed_actwave(a5),d6
		add	d6,d6
		add	d6,d6
		move.l	(a4,d6.l),a1
		move.l	exec,a6
		jsr	exec_freevec(a6)	; alte wellenform rauskicken

		move.l	.newwaveadr(pc),(a4,d6.l)
		lea	module_wavelenlist,a4
		move.l	.newwavelen(pc),(a4,d6.l)

		bsr	waveed_verAdjust
		bsr	waveed_setshowall
		jsr	refresh_instrumentED
		bra	refresh_waveedwaveall
.tooshort
		rts
.nomem
		movem.l	(sp)+,a0/a2/d4/d6/d7
		lea	msg_wave_nonewwave,a2
		jmp	displaymessageWAVE
.newwaveadr	dc.l	0
.newwavelen	dc.l	0
;--------------------------------------------------------------------
PLAYRANGE:
			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			add	d0,d0
			add	d0,d0
			lea	aon_wavestarts+aon_data,a0
			move.l	(a0,d0.l),d0
			add.l	waveed_wavepos(a5),d0

			jsr	getchanneloff
			move.l	a4,a0
			move.l	d0,aon_waveform(a0)
			move.l	waveed_rangesize(a5),d0
			lsr.l	#1,d0
			move	d0,aon_wavelen(a0)
			move.l	#aon_leer,aon_repeatstrt(a0)
			move	#1,aon_replen(a0)
			move.b	#3,aon_chflag(a0)
			rts
;--------------------------------------------------------------------
waveed_changepitch:
			move.l	intbase(a5),a6
			move.l	windowptrWAVE(a5),a0
			move.l	#txt_dseqenternote,$20(a0)
			move.l	$3e(a0),d7	; gadgets sollen nicht mit
			clr.l	$3e(a0)		; refresht werden
			move.l	a0,d6
			jsr	int_refreshwindowframe(a6)
			move.l	d6,a0
			move.l	d7,$3e(a0)	; zeiger auf 1st gadget zurück

.waitmsg		move.l	userportWAVE(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			bra.b	.waitmsg
.MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

			cmp.l	#rawkey,$14(a0)
			bne.b	.waitmsg

			moveq	#0,d0
			move	$18(a0),d0	; ScanCode
			swap	d0
			move.b	$1b(A0),d0
			swap	d0

			tst.b	octave(a5)
			beq.b	.octave00
			cmp.b	#1,octave(a5)
			beq.b	.octave0
			lea	ne_raw2notetab_oct1,a1
			bra.b	.octave1
.octave0		lea	ne_raw2notetab_oct0,a1
			bra.b	.octave1
.octave00		lea	ne_raw2notetab_oct00,a1
.octave1
			tst	(a1)		; endmark??
			bmi	.waitmsg
			cmp.l	(a1),d0		; compare rawkeycode
			beq.b	.found
			addq.l	#8,a1
			bra.b	.octave1
.found			move.l	4(a1),d3
; d1=note
.enterit
			and.l	#$ffff,d3
			move.b	d3,sample_pitch(a5)
			add	d3,d3
			lea	aon_periods-2,a0
			move	(a0,d3.l),sample_period(a5)
	
			move.l	intbase(a5),a6
			move.l	windowptrWAVE(a5),a0
			move.l	#instred_windowtitle,$20(a0)
			jsr	int_refreshwindowframe(a6)
			bsr	refresh_waveedsamplefreq
;--------------------------------------------------------------------
refresh_waveedpitch:
			movem.l	d0-a6,-(sp)
			lea	txt_notes,a3
			move.l	intbase(a5),a6

			move.l	rastportwave(a5),a0
			lea	.itext(pc),a1
			moveq	#0,d0
			move.b	sample_pitch(a5),d0
			add	d0,d0
			add	d0,d0
			move.l	(a3,d0),.text-.itext(a1)
			clr.b	(.text-.itext)+3(a1)
			move.l	#368,d0
			move.l	#387,d1
			jsr	int_printitext(a6)

			movem.l	(sp)+,d0-a6
			rts
.itext			dc.b	1,0,0
			even
			dc	2
			dc	2
			dc.l	0
			dc.l	.text
			dc.l	0
.text			dc.b	"---",0
;--------------------------------------------------------------------
; Program	:	Wrap-Funktion für AON-2
; Author	:	Bastian Spiegel
; Date		:	24-Jun-95
waveed_wrap:
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			bsr	waveed_actrangedata
			move.l	.from(pc),d0
;--------------------------------------------------------------------
; a0=ptr to sample
; d0=wrap-factor (0-8192)
; d7=length of sample

		movem.l	d0-a6,-(sp)
		add	#128,d0
.loop
		moveq	#0,d1
		move.b	(a0),d1
		ext	d1
		muls	d0,d1
		asr	#7,d1

.checkpos	cmp	#127,d1
		ble.b	.posok
		move	#256,d2
		sub	d1,d2
		move	d2,d1
.posok		cmp.b	#$80,d1
		bne.b	.notfuck
		move.b	-1(a0),d1
		bra.b	.negok
.notfuck	cmp	#-127,d1
		bge.b	.negok
		move	#-256,d2
		sub	d1,d2
		move	d2,d1
		bra.b	.checkpos
.negok		move.b	d1,(a0)+
		subq.l	#1,d7
		bne.b	.loop
		movem.l	(sp)+,d0-a6
.raus
			bra	refresh_waveedwaveall

.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,16384
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"Wrap factor",0
			even
.from			dc.l	0

;--------------------------------------------------------------------
; Program	:	LP-Filter
; Author	:	Bastian Spiegel
; Date		:	22-May-1995
waveed_lopass:

			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			bsr	waveed_actrangedata
			move.l	.from(pc),d0
;--------------------------------------------------------------------
; a0=ptr to sourcesample
; d0=filter depth 0-8
; d7=samplelen-1
		movem.l	d0-a6,-(sp)
		move.l	d0,d2
		moveq	#0,d1		; current value
		move.b	(a0,d7.l),d1	; last value=start value
		ext	d1
.loop
		moveq	#0,d0
		move.b	(a0),d0		; neuen wert holen
		ext	d0		; auf 16bit
		ext	d1
		sub	d1,d0		; - alter wert = delta zum neuen
		asr	d2,d0		; delta/16
		add	d0,d1
		move.b	d1,(a0)+
		subq.l	#1,d7
		bne.b	.loop

		movem.l	(sp)+,d0-a6
		bra	refresh_waveedwaveall


.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,7
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"LPF Depth",0
			even
.from			dc.l	0
;--------------------------------------------------------------------
; Program	:	HP-Filter
; Author	:	Bastian Spiegel
; Date		:	22-May-1995
waveed_hipass:


			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			bsr	waveed_rangedisplay
			tst.l	waveed_rangesize(a5)
			bne.b	.okrange
			lea	msg_wave_norange,a2
			jmp	displaymessageWave
.okrange
			clr.b	winwave_override(a5)
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			lea	.from(pc),a1
			lea	.fromaSC(pc),a2
			sub.l	a3,a3
			move.l	rtbase(a5),a6
			jsr	rtgetlonga(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.ok
			rts
.ok
			bsr	waveed_actrangedata
			move.l	.from(pc),d0
;--------------------------------------------------------------------
; a0=ptr to sourcesample
; d7=samplelen-1

		movem.l	d0-a6,-(sp)
		moveq	#6,d3
		sub	d0,d3
		moveq	#0,d1		; current value
		move.b	(a0,d7.l),d1	; last value=start value
		ext	d1
.loop
		moveq	#0,d0
		move.b	(a0),d0		; neuen wert holen
		ext	d0		; auf 16bit
		move	d0,d2
		ext	d1
		sub	d1,d0		; - alter wert = delta zum neuen
		asr	d3,d0		; delta/16
		add	d0,d1
		sub	d1,d2
		cmp	#127,d2
		ble.b	.ok1
		moveq	#127,d2
.ok1		cmp	#-127,d2
		bge.b	.ok2
		moveq	#-127,d2
.ok2
		move.b	d2,(a0)+
		subq.l	#1,d7
		bne.b	.loop

		movem.l	(sp)+,d0-a6
		bra	refresh_waveedwaveall


.tags			dc.l	rt_window,0
			dc.l	rtgl_min,0
			dc.l	rtgl_max,5
			dc.l	rtgl_showdefault,true
			dc.l	rt_reqpos,1
			dc.l	tag_done
.fromASC		dc.b	"HPF Depth",0
			even
.from			dc.l	0
;--------------------------------------------------------------------
waveed_gainadd:
		cmp.b	#7,wavedspgain(a5)
		beq.b	.ok
		addq.b	#1,wavedspgain(a5)
		jsr	refresh_waveedwaveall
		jsr	Refresh_waveedDSPGAIN
.ok		rts
;--------------------------------------------------------------------
waveed_gainsub:
		tst.b	wavedspgain(a5)
		beq.b	.ok
		subq.b	#1,wavedspgain(a5)
		jsr	refresh_waveedwaveall
		jsr	Refresh_waveedDSPGAIN
.ok		rts
;--------------------------------------------------------------------
GetcopyFromTO:
			movem.l	d0-A6,-(sp)

			clr.b	winwave_override(a5)
			lea	.stringFrom(pc),a1
			moveq	#1,d0
			lea	.title1(pc),a2
			sub.l	a3,a3
			lea	.tags(pc),a0
			move.l	windowptrwave(a5),4(a0)
			move.l	screenptr2(a5),12(a0)
			move.l	rtbase(a5),a6
			jsr	rtGetStringA(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			beq.b	.cancel

			clr.b	winwave_override(a5)
			lea	.stringTo(pc),a1
			moveq	#1,d0
			lea	.title2(pc),a2
			sub.l	a3,a3
			lea	.tags(pc),a0
			jsr	rtGetStringA(a6)
			move.b	#1,winwave_override(a5)
			tst.l	d0
			bne.b	.notcancel2
.cancel
			movem.l	(sp)+,d0-a6
			rts
.notcancel2
			lea	txt_instrnrs,a0
			moveq	#0,d0
			move.b	.stringfrom(pc),d1
.search1		tst.b	(a0)
			beq.b	.cancel	
			cmp.b	(a0)+,d1
			beq.b	.found1
			addq	#1,d0
			bra.b	.search1
.found1			subq	#1,d0
			bmi	.cancel
			move.b	d0,instred_copyfrom(a5)

			lea	txt_instrnrs,a0
			moveq	#0,d0
			move.b	.stringto(pc),d1
.search2		tst.b	(a0)
			beq.b	.cancel	
			cmp.b	(a0)+,d1
			beq.b	.found2
			addq	#1,d0
			bra.b	.search2
.found2			subq	#1,d0
			bmi	.cancel
			move.b	d0,instred_copyto(a5)

			movem.l	(sp)+,d0-a6
			rts

.tags			dc.l	rt_window,0
			dc.l	rt_screen,0
			dc.l	rt_reqpos,1
			dc.l	rtgs_width,80
			dc.l	tag_done
.stringFROM		dc.b	"1",0
.stringTO		dc.b	"2",0
			ifeq	lang
.title1			dc.b	"From",0
.title2			dc.b	"To",0
			else
.title1			dc.b	"Von",0
.title2			dc.b	"Nach",0
			endif
			even
;************************************************************************
;ResamplePattern:
;			clr	acteditinstr(a5)	; set parameters
;			move.l	#40000,resample_len(a5)
;			clr	resample_flag(a5)
;
;			moveq	#0,d0
;			move	acteditinstr(a5),d0
;			lsl	#5,d0
;			lea	module_instruments,a0
;			lea	(a0,d0),a0			
;
;			moveq	#0,d0
;			move.b	instr_wave(a0),d0
;			jsr	freewave
;			move.l	resample_len(a5),d1
;
;; in:	d0=Nr der wellenform, (muß leer sein!!)
;; 	d1=wavelen in bytes
;
;			jsr	allocwave
;
;; out:	d0=waveadr (oder null, falls kein speicher mehr frei war)
;
;			move.l	d0,resample_adr(a5)
;			tst.l	d0
;			beq.b	.exit
;
;			move	#1,resample_flag(a5)
;			jsr	StartPatPlay
;.exit			rts
;************************************************************************
; 	        F R E Q U E N Z - M O D U L A T I O N S -  SYNTHESIZER
FMED:
			clr.b	itt_adpd_flag(a5)
			clr.b	patteditstatus(a5)

			move.l	intbase(a5),a6
			lea	fmed_windowstruct,a0
			jsr	-204(a6)		; OpenWindow(int)
			move.l	d0,window2ptr(a5)
			bne.b	.windowopened
			lea	msg_fmed_nowindow,a2
			jsr	displaymessage
			bra	fmed_exit
.windowopened

			movem.l	d0-a6,-(sp)
			lea	gfx_fmsynth+1,a0
			move.l	bitplane1_startadr(a5),a1
			lea	20*80+1(a1),a1
			move.l	bitplane2_startadr(a5),a2
			lea	20*80+1(a2),a2
			move	#177-1,d7
.loop1			MOVEQ	#78-1,d6
.loop2			move.b	80(a0),(a2)+
			move.b	(a0)+,(a1)+
			dbf	d6,.loop2
			lea	80+2(a0),a0
			addq.l	#2,a1
			addq.l	#2,a2
			dbf	d7,.loop1
			movem.l	(sp)+,d0-a6

			move.l	d0,a0
			move.l	$32(a0),rastport2(a5)	; Rast-Port
			move.l	$56(a0),a0		; User-Port
			move.l	a0,userport2(a5)
			move.l	d0,mod_filereqWINPTR2	; Für Filerequester

			move.l	gadtoolsbase(a5),a6
			lea	gadgetlist2(a5),a0	; 1.Unsichtbares
			jsr	gadtools_CreateContext(a6)
			move.l	d0,-(sp)

;--------- Gadgets eintragen ------------
			move.l	(sp)+,d0
			move.l	a5,-(sp)
			lea	mp2_gadgetptrs+4,a5
			lea	fmed_gadgetstructptrs,a4
.allocGadgetsLoop	move.l	4(a4),a1
			cmp.l	#0,a1
			beq.b	.allocgadgetsEND

			move.l	8(a4),a2		; Tags
			move.l	getvisual+main_data,gng_visualinfo(a1)
			move.l	d0,a0		; Ergebnis von CreateContext()
			move.l	(a4),d0		; Gadget-Typ
			jsr	gadtools_CreateGadgetA(a6)
			move.l	d0,(a5)+
			lea	12(a4),a4
			bra.b	.allocGadgetsLoop
.AllocGadgetsEND	move.l	(sp)+,a5
			
;--------- Gadgets eintragen ------------
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			sub.l	a2,a2			; eintragen
			moveq	#-1,d0
			moveq	#-1,d1
			jsr	int_AddGList(a6)

			move.l	gadgetlist2(a5),a0	; Gadgets zeichnen
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_RefreshGlist(a6)

; Gadgets darstellen!
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a0
			sub.l	a1,a1
			jsr	gadtools_GT_RefreshWindow(a6)

;--------------- ???????? -----------------

; Bevel-Box designen
;
;			move.l	rastport2(a5),a0
;			move.l	#640-136-4,d0
;			moveq	#gyoff+ghi*6+7,d1
;			move.l	#136,d2
;			move.l	#ghi*4,d3
;			lea	bevel_recessed_tags,a1
;			move.l	getvisual(a5),4(a1)
;			jsr	gadtools_drawbevelboxa(a6)

			lea	equ_data,a0
			REPT	(16/4)*4
			clr.l	(a0)+
			ENDR

			bsr	sy_inittables

			move.b	#1,win2_override(a5)
			move.b	#fmsynthed,programmode(a5)

			bsr	refresh_fmedall
fmEDed
			clr.b	screen(a5)
; Mainloop-----------------------
fmed_mmm
.mmm			move.l	userport2(a5),a3
			move.l	a3,a0
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_Gt_GetIMsg(a6)	; IntuiMessage abholen
			tst.l	d0			; Ist eine messy da?!
			bne.b	.m_messyDa

			moveq	#-1,d0
			move.l	exec,a6
			move.l	a3,a0			; aus dem
			jsr	exec_waitport(a6)	; 'Faszination
			bsr	printnewpatterns
			jsr	adjust_pattdisplay
			bra.b	.mmm
.m_MessyDa
			lea	intuimessage,a1
			move.l	a1,d7
			move.l	d0,a0			; das war chaos' idee
			moveq	#100-1,d6
.lop23			move.b	(a0)+,(a1)+
			dbf	d6,.lop23

			move.l	d0,a1
			jsr	gadtools_gt_replyimsg(a6)

			move.l	d7,a0

;			cmp.l	#mousemove,$14(a0)
;			bne.b	.fuckyadickhead
;.fuckyadickhead
			cmp.l	#rawkey,$14(a0)
			bne.b	.nokey
			jmp	keypressedfmed
.nokey
			cmp.l	#intuiticks,$14(a0)
			beq	fmed_intuiticks

			cmp.l	#closewindow,$14(a0)
			beq.b	fmed_exitfree

			cmp.l	#inactivewindow,$14(a0)
			beq	instred_inactivated

			moveq	#0,d3
			cmp.l	#gadgetup,$14(a0)
			beq.b	.yoman
			moveq	#4,d3
			cmp.l	#gadgetdown,$14(a0)
			bne.b	.noman
.yoman			jsr	checkgadgets
.noman
			bra	.mmm
; Exit---------------------------
fmed_exitfree
			move.b	#pattedit,programmode(a5)

			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0	; Gadget in
			move.l	gadgetlist2(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen

			move.l	gadtoolsbase(a5),a6
			move.l	gadgetlist2(a5),a0
			jsr	gadtools_FreeGadgets(a6)
	
			move.l	intbase(a5),a6
			move.l	window2ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
fmed_exit
			move.b	#1,itt_adpd_flag(a5)

			bsr	refresh_instrument
			bsr	drawhilitepattern
			rts
;--------------------------------------------------------------------
fmed_intuiticks		bsr	blanker
			bra	fmed_mmm
;--------------------------------------------------------------------
fmed_exitnow		addq.l	#8,sp
			bra	fmed_exitfree
;--------------------------------------------------------------------
fmed_actfmdata		move.l	d0,-(sp)
			lea	module_fmdata,a0
			moveq	#0,d0
			move.b	fmed_actinstr(a5),d0
			lsl	#4,d0
			lea	(a0,d0),a0
			move.l	(sp)+,d0
			rts
;--------------------------------------------------------------------
refresh_fmedall:
			bsr	refresh_fmedPartwavelen
			bsr	refresh_fmedPartwaves
			bsr	refresh_fmedFreq1
			bsr	refresh_fmedFreq2
			bsr	refresh_fmedAttack1
			bsr	refresh_fmedAttack2
			bsr	refresh_fmedDecay1
			bsr	refresh_fmedDecay2
			bsr	refresh_fmedlevel1
			bsr	refresh_fmedlevel2
			bsr	refresh_fmedWaveSel1
			bsr	refresh_fmedWaveSel2
			bra	refresh_fmedDestwave
;--------------------------------------------------------------------
fmed_partwavelenChange
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			cmp	#1,d0
			beq.b	.l0
			cmp	#2,d0
			beq.b	.l1
			cmp	#4,d0
			beq.b	.l2
			cmp	#8,d0
			beq.b	.l3
			cmp	#16,d0
			beq.b	.l4
			cmp	#32,d0
			beq.b	.l5
			cmp	#64,d0
			beq.b	.l6
			cmp	#128,d0
			beq.b	.l7
			cmp	#128,d0
			beq.b	.l7
			cmp	#256,d0
			beq.b	.l8
			bra.b	refresh_fmedpartwavelen
.l0			moveq	#0,d0
			bra.b	.got
.l1			moveq	#1,d0
			bra.b	.got
.l2			moveq	#2,d0
			bra.b	.got
.l3			moveq	#3,d0
			bra.b	.got
.l4			moveq	#4,d0
			bra.b	.got
.l5			moveq	#5,d0
			bra.b	.got
.l6			moveq	#6,d0
			bra.b	.got
.l7			moveq	#7,d0
			bra.b	.got
.l8			moveq	#8,d0
.got
			bsr	fmed_actfmdata
			move.b	d0,fm_plen(a0)
			rts
;--------------------------------------------------------------------
Refresh_fmedPartwavelen
			bsr	fmed_actfmdata
			moveq	#0,d1
			moveq	#1,d0
			move.b	fm_plen(a0),d1
			lsl	d1,d0

			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedpartwavesize,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_partwavesChange
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			move.b	d0,fm_len(a0)
;--------------------------------------------------------------------
Refresh_fmedPartwaves
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_len(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedpartwaves,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_freq1Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			cmp	#16,d0
			bgt.b	.fl1
			tst	d0
			bne.b	.not0
.fl1			moveq	#1,d0
.not0			bsr	fmed_actfmdata
			move.b	d0,fm_freqM(a0)
;--------------------------------------------------------------------
Refresh_fmedFreq1
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_freqM(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedfreq1,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_freq2Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			cmp	#16,d0
			bgt.b	.fl2
			tst	d0
			bne.b	.not0
.fl2			moveq	#1,d0
.not0			bsr	fmed_actfmdata
			move.b	d0,fm_freqC(a0)
;--------------------------------------------------------------------
Refresh_fmedFreq2
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_freqC(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedfreq2,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_attack1Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			move.b	d0,fm_atkM(a0)
;--------------------------------------------------------------------
Refresh_fmedAttack1
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_atkM(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedattack1,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_attack2Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			move.b	d0,fm_atkC(a0)
;--------------------------------------------------------------------
Refresh_fmedAttack2
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_atkC(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedattack2,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_decay1Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			move.b	d0,fm_dcyM(a0)
;--------------------------------------------------------------------
Refresh_fmedDecay1
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_dcyM(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmeddecay1,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_decay2Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			move.b	d0,fm_dcyC(a0)
;--------------------------------------------------------------------
Refresh_fmedDecay2
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_dcyC(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmeddecay2,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_level1Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			and.b	#$7f,d0
			move.b	d0,fm_levelM(a0)
;--------------------------------------------------------------------
Refresh_fmedLevel1
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_levelM(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedlevel1,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_level2Change
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			bsr	fmed_actfmdata
			and.b	#$7f,d0
			move.b	d0,fm_levelC(a0)
;--------------------------------------------------------------------
Refresh_fmedLevel2
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_levelC(a0),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmedlevel2,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_destwaveChange
			move.l	$22(a1),a1		; StringInfo
			move.l	$1c(a1),d0		; LongInt
			tst.b	d0
			beq.b	refresh_fmeddestwave
			bsr	fmed_actfmdata
			subq.b	#1,d0
			and.b	#63,d0
			move.b	d0,fm_destwave(a0)
;--------------------------------------------------------------------
Refresh_fmedDestwave
			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_destwave(a0),d0
			addq.b	#1,d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_fmeddestwave,d0
			bra	refresh_integer_kind3
;--------------------------------------------------------------------
fmed_computeit

; Program	:	SyMonV2
; Author	:	Bastian Spiegel (Twice/Lego)
; Date		:	6-October-1994
; Finished	:	8-October-1994
	REM
This neat little routine emulates an OPL2 FM-Chip (Yamaha). This is
a chip you will find in many of these pc-sound cards (adlib).. The
main advantage is to create complex instruments with just very small
memory usage (instrument-data=16 parameters!)
um die wellenfarbe zu ändern, 'modwaveptr' ändern!!!
	EREM

			bsr	fmed_actfmdata
			moveq	#0,d0
			move.b	fm_destwave(a0),d0
			bsr	freewave

			moveq	#1,d1
			moveq	#0,d0
			bsr	fmed_actfmdata
			move.b	fm_plen(a0),d0
			lsl	d0,d1
			moveq	#0,d0
			move.b	fm_len(a0),d0
			mulu	d0,d1
			tst.l	d1
			bne.b	.notzerolen
			lea	msg_fmed_zerolen,a2
			jmp	displaymessage2
.notzerolen
			move.l	d1,sy_bytelen
			moveq	#0,d0
			bsr	fmed_actfmdata
			move.b	fm_destwave(a0),d0
			bsr	allocwave
			tst.l	d0
			bne.b	.allocated
			lea	msg_fmed_nomem,a2
			jmp	displaymessage2
.allocated
			move.l	d0,a1
			bsr	fmed_actfmdata
;--------------------------------------------------------------------
; a0=pointer on instrdata
; a1=pointer on destwave

syMon2_compute:
		movem.l	d0-a6,-(sp)
; *** waveform setzen
		lea	sy_waveptrs(pc),a2
		moveq	#0,d0
		move.b	fm_waveC(a0),d0
		add	d0,d0
		add	d0,d0
		move.l	(a2,d0),sy_carrierwaveptr
		moveq	#0,d0
		move.b	fm_waveM(a0),d0
		add	d0,d0
		add	d0,d0
		move.l	(a2,d0),sy_modwaveptr
; *** frequenzen setzen
		moveq	#0,d0
		move.b	fm_freqC(a0),d0
		move	d0,sy_carrierfreq
		move.b	fm_freqM(a0),d0
		move	d0,sy_modfreq
; *** modlevel+total level setzen
		moveq	#0,d0
		move.b	fm_levelC(a0),d0
		move	d0,sy_totallevel

		moveq	#0,d0
		move.b	fm_levelM(a0),d0
		move	d0,sy_moddepth
; *** Feedback setzen
		moveq	#0,d0
		move.b	fm_feedback(a0),d0
		move	d0,sy_feedback
; *** Attack setzen
		moveq	#0,d0
		move.b	fm_atkC(a0),d0
		move	d0,sy_carrierattack

		moveq	#0,d0
		move.b	fm_atkm(a0),d0
		move	d0,sy_modattack
; *** Decay setzen
		moveq	#0,d0
		move.b	fm_dcyC(a0),d0
		move	d0,sy_carrierdecay

		moveq	#0,d0
		move.b	fm_dcyM(a0),d0
		move	d0,sy_moddecay
; *** DestWave-Len setzen
		moveq	#0,d0
		move.b	fm_len(a0),d0
		subq	#1,d0
		move	d0,sy_destlen
; *** Partwave_len setzen
		moveq	#1,d1
		moveq	#0,d0
		move.b	fm_plen(a0),d0
		lsl.b	d0,d1
		move	d1,sy_partwavelen
; *** DestWave-Ptr setzen
		move.l	a1,sy_destwaveptr

; sy_carrierwaveptr	=Pointer to carrier-wave (e.g. sinewave)
; sy_modwaveptr		=Pointer to modulation-wave (e.g. sinewave)
; sy_carrierattack	=Attack speed of carrier wave AD (0..512)
; sy_modattack		=Attack speed of modulation wave AD (0..512)
; sy_carrierdecay	=Decay speed of carrier wave AD (0..512)
; sy_moddecay		=Decay speed of modulation wave AD (0..512)
; sy_moddepth		=Modulation depth (0-127)
; sy_feedback		=Feedback-level (0-7)
; sy_carrierfreq	=Carrier-wave frequency (1-16)
; sy_modfreq		=Modulation-wave frequency (1-16)
; sy_totallevel		=Total volume level (0-127)
; sy_destlen		=Amount of partwaves, total bytelen of computed
;			 instrument = 256*sy_destlen
; sy_destwaveptr	=Pointer on memory-area where to compute the instr.
; fm-modulation	: F(t)=A*sin(McWct+I*sin(MmWmt))


;## Instrument structure ##
		rsreset
fm_waveC	rs.b	1	0=sine,1=rect,2=triangle,3=sawtooth,4=whitenoise
fm_freqC	rs.b	1	0..15
fm_levelC	rs.b	1	0..99
fm_atkC		rs.b	1	0..63
fm_dcyC		rs.b	1	0..63
fm_feedback	rs.b	1	0..7
fm_waveM	rs.b	1	same as above..
fm_freqM	rs.b	1	(for modulation-wave)
fm_levelM	rs.b	1
fm_atkM		rs.b	1
fm_dcyM		rs.b	1
fm_len		rs.b	1	0..255
fm_plen		rs.b	1	0..6 (2^fm_plen=partwavelen)
fm_destwave	rs.b	1
fm_free		rs.b	3	fill bytes
fm_instrsize	rs.b	1

		move	sy_carrierattack(pc),d0
		add	d0,d0
		move	d0,.workadsrcarrier
		move	sy_modattack(pc),.d0
		add	d0,d0
		move	d0,.workadsrmod
		move	sy_carrierattack(pc),.workadsrspdcarrier
		move	sy_modattack(pc),.workadsrspdmod

		move.l	sy_carrierwaveptr(pc),a0
		move.l	sy_modwaveptr(pc),a1
		move.l	sy_destwaveptr(pc),a2

		moveq	#6,d4
		sub	sy_feedback(pc),d4
		moveq	#9,d5
		moveq	#0,d7
		move	sy_destlen(pc),d7
.mainloop
		moveq	#0,d6	0..255
.innerloop

		moveq	#0,d2
		move.b	d6,d2			; d6=t
		mulu	sy_modfreq(pc),d2	; *mod-frequency
		and	#$ff,d2
		moveq	#0,d0
		move.b	(a1,d2),d0		; get modulator-byte
		ext	d0

		moveq	#0,d2
		move	.workadsrmod(pc),d2	; *adsr-byte MODULATOR
		muls	d2,d0
		asr.l	d4,d0

		muls	sy_moddepth(pc),d0
		asr	#7,d0

		moveq	#0,d1
		move.b	d6,d1
		mulu	sy_carrierfreq(PC),d1	; *carrier-frequency
		add	d1,d0			; +I*sin(Wmt)
		and.l	#$ff,d0
		move.b	(a0,d0),d0
		ext	d0

		moveq	#0,d2
		move	.workadsrcarrier(pc),d2	; *adsr-byte CARRIER
		muls	d2,d0
		asr.l	d5,d0

		muls	sy_totallevel(pc),d0
		asr	#7,d0

		move.b	d0,(a2)+

		addq.b	#1,d6
		cmp	sy_partwavelen(pc),d6
		bne.b	.innerloop

;---
		move	.workadsrspdcarrier(pc),d0
		add	d0,.workadsrcarrier
		tst	.workadsrcarrier
		bpl.b	.cNend
		clr	.workadsrcarrier
		clr	.workadsrspdcarrier
		bra.b	.cok
.cNend
		cmp	#512,.workadsrcarrier
		blt.b	.cOK
		move	#511,.workadsrcarrier
		move	sy_carrierdecay(pc),d0
		neg	d0
		move	d0,.workadsrspdcarrier
.cOK
;-------
		move	.workadsrspdmod(pc),d0
		add	d0,.workadsrmod
		tst	.workadsrmod
		bpl.b	.mNend
		clr	.workadsrmod
		clr	.workadsrspdmod
		bra.b	.mok
.mNend
		cmp	#512,.workadsrmod
		blt.b	.mOK
		move	#511,.workadsrmod
		move	sy_moddecay(pc),d0
		neg	d0
		move	d0,.workadsrspdmod
.mOK
;---

		dbf	d7,.mainloop
		movem.l	(sp)+,d0-a6

			bsr	fmed_actfmdata
			move.b	fm_destwave(pc),dseq_adjwave
			move.l	sy_bytelen,dseq_adjlen
			jmp	dseq_okadjustwavelens

.workadsrcarrier	dc	0
.workadsrmod		dc	0
.workadsrspdcarrier	dc	0
.workadsrspdmod		dc	0

sy_bytelen		dc.l	0	only for aon-uses!!


sy_carrierwaveptr	dc.l	0
sy_modwaveptr		dc.l	0
sy_moddepth		dc	0
sy_feedback		dc	0
sy_carrierfreq		dc	0
sy_modfreq		dc	0
sy_carrierattack	dc	0
sy_carrierdecay		dc	0
sy_modattack		dc	0
sy_moddecay		dc	0
sy_totallevel		dc	0
sy_destlen		dc	0
sy_partwavelen		dc	0
sy_destwaveptr		dc.l	0

sy_waveptrs		dc.l	sy_sinetable
			dc.l	sy_rectangletable
			dc.l	sy_triangletable
			dc.l	sy_sawtoothtable
			dc.l	sy_whitenoisetable

			dc.l	sy_arc
			dc.l	sy_doublesinus
			dc.l	sy_extremes
			dc.l	sy_heart
			dc.l	sy_linemix
			dc.l	sy_mshape
			dc.l	sy_parabola
			dc.l	sy_sampleexample
			dc.l	sy_turnpoint
			dc.l	sy_updown
			dc.l	sy_pulse

sy_sinetable
	incbin	"dh1:samples/synthetic/sinus256.raw"
sy_rectangletable
	ds.b	256
sy_triangletable
	ds.b	256
sy_sawtoothtable
	ds.b	256
sy_whitenoisetable
	incbin	"dh1:samples/synthetic/whitenoise256.raw"
		incdir	"ch:.include/fm-oscwaves/"
sy_arc		incbin	"arc"
sy_doublesinus	incbin	"doublesinus"
sy_extremes	incbin	"extremes"
sy_heart	incbin	"heart"
sy_linemix	incbin	"linemix"
sy_mshape	incbin	"m-shape"
sy_parabola	incbin	"parabola"
sy_sampleexample	incbin	"sampleexample"
sy_turnpoint	incbin	"turnpoint"
sy_updown	incbin	"up&down"
sy_pulse	incbin	"Pulse"


SY_inittables
; tabellen initalsieren
			lea	sy_rectangletable(pc),a0
			moveq	#128-1,d7
			moveq	#127,d0
.initrectloop1		move.b	d0,(a0)+
			dbf	d7,.initrectloop1
			moveq	#128-1,d7
			moveq	#-127,d0
.initrectloop2		move.b	d0,(a0)+
			dbf	d7,.initrectloop2

			lea	sy_triangletable(pc),a0
			moveq	#127-1,d7
			moveq	#-127,d0
.inittriloop		move.b	d0,(a0)+
			addq.b	#2,d0
			dbf	d7,.inittriloop
			subq.b	#2,d0
			move.b	d0,(a0)+
			move.b	d0,(a0)+
			moveq	#127-1,d7
.inittriloop2		move.b	d0,(a0)+
			subq.b	#2,d0
			dbf	d7,.inittriloop2

			lea	sy_sawtoothtable(pc),a0
			move	#256-1,d7
			moveq	#-127,d0
.initsawloop		move.b	d0,(a0)+
			addq.b	#1,d0
			dbf	d7,.initsawloop
			rts
;--------------------------------------------------------------------
fmed_delete:		bsr	fmed_actfmdata
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			bra	refresh_fmedall
;--------------------------------------------------------------------
fmed_wavesel1
			move.b	$19(a0),d0
			bsr	fmed_aCTfmdata
			move.b	d0,fm_waveM(a0)
			rts
;--------------------------------------------------------------------
fmed_wavesel2
			move.b	$19(a0),d0
			bsr	fmed_aCTfmdata
			move.b	d0,fm_waveC(a0)
			rts
;--------------------------------------------------------------------
fmed_saveinstr
			ifeq	save
			lea	msg_demomode,a2
			jmp	displaymessage2
			else

			move.b	#1,win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1

;	move.l	rt_dirname(a1),a0
;		move.l	#"AON:",(a0)+
;			move.l	#"fm-s",(a0)+
;			move.l	#"ound",(a0)+
;			move	#$7300,(a0)+

			lea	fm_filename,a2

			lea	.title(pc),a3
			lea	mod_filereqTAGS2,a0
			jsr	rtFileRequestA(a6)
			clr.b	win2_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	fm_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6

			move.l	#iofilename,d1
			move.l	#1006,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.theresafile
			lea	msg_io_filenotfound,a2
			jmp	displaymessage2
.theresafile
			move.l	#.header,d2
			moveq	#8,d3
			write2
			bsr	fmed_actfmdata
			move.l	a0,d2
			moveq	#16,d3
			write2
			closefile
.title			dc.b	"Save FM-Sound...",0
.header			dc.b	"AON-FM14"
			even
			endif
;--------------------------------------------------------------------
fmed_loadinstr
			move.b	#1,win2_override(a5)
			move.l	rtbase(a5),a6
			move.l	varreqptr(a5),a1

;		move.l	rt_dirname(a1),a0
;		move.l	#"AON:",(a0)+
;		move.l	#"fm-s",(a0)+
;		move.l	#"ound",(a0)+
;		move	#$7300,(a0)+

			lea	fm_filename,a2

			lea	.title(pc),a3
			lea	mod_filereqTAGS2,a0
			jsr	rtFileRequestA(a6)
			clr.b	win2_override(a5)

			tst.l	d0		; CAnceled?!?!
			bne.b	.ok
			rts
.ok
			move.l	varreqptr(a5),a0
			move.l	rt_dirname(a0),a0
			lea	fm_filename,a1
			jsr	makefilename

			move.l	dosbase(a5),a6

			move.l	#iofilename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			move.l	d0,filehandle(a5)
			bne.b	.theresafile
			lea	msg_io_filenotfound,a2
			jmp	displaymessage2
.theresafile
			move.l	#iobuffer+1000,d2
			moveq	#24,d3
			read2
			move.l	filehandle(a5),d1
			jsr	dos_close(a6)

			lea	iobuffer+1000,a1
			cmp.l	#"AON-",(a1)+
			beq.b	.check1ok
.wrong			lea	msg_fmed_wrong4mat,a2
			jmp	displaymessage2
.check1ok
			cmp.l	#"FM14",(a1)+
			bne.b	.wrong
			bsr	fmed_actfmdata
			move.l	a0,a2
			move.b	fm_destwave(a0),d0
			move.l	(a1)+,(a0)+
			move.l	(a1)+,(a0)+
			move.l	(a1)+,(a0)+
			move.l	(a1)+,(a0)+
			move.b	d0,fm_destwave(a2)
			bra	refresh_fmedall

.title			dc.b	"Load FM-Sound...",0
			even
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------

;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
;---------------------- RAUS HIER!!! ------------------------------------
LEAVEPROGRAM
			move.l	signalnr(a5),d0
			move.l	exec,a6
			jsr	exec_freeSignal(a6)	Signal freigeben

			bsr	waveed_clearbuf

			move.l	dosbase(a5),a6
			move.l	#rem_filename,d1
			jsr	dos_delete(a6)

			move.l	exec,a6

;---------------------- Module End --------------------------------------

			jsr	aon_end

			bsr	freewaves		; Allokierten
				; Speicher für die Wellenformen wieder
				; freigeben

;---------------------- Reset Interrupts --------------------------------

			move	#$0780,$dff09a
			move.l	oldaudio,d0
			beq.b	.empty
			move.l	vbreg(a5),a0
			move.l	d0,$70(a0)
.empty

			move	#$0801,$dff09a
			move.l	old_level1+2,$64
			move.l	old_level5(a5),$74

midi_fail
			lea	vbintserver,a1
			moveq	#5,d0
			move.l	exec,a6
			jsr	exec_remintserver(a6)


			bclr	#0,$bfdf00		; Timer B STOP
			move.l	CiaBBase,a6
			lea	TimerIntServerB,a1
			moveq	#1,d0			; Timer-B
			jsr	cia_RemICRVector(a6)
CiaErrorB

;---------------------- Screen/Window wieder schließen ------------------

			move.l	rtbase(a5),a6		; Filerequester
			move.l	varreqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
var_filereqERROR
			move.l	rtbase(a5),a6		; Filerequester
			move.l	sampleReqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
dseq_filereqError
			move.l	rtbase(a5),a6		; Filerequester
			move.l	dseqReqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
sample_filereqERROR
			move.l	rtbase(a5),a6		; Filerequester
			move.l	instrReqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
instr_filereqERROR
			move.l	rtbase(a5),a6		; Filerequester
			move.l	modreqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
mod_filereqERROR
			move.l	palettereqptr(a5),a1	; freigeben
			jsr	rtFreeRequest(a6)
palette_reqERROR


			move.l	intbase(a5),a6
			move.l	windowptrwave(a5),a0	; Gadget in
			move.l	gadgetlistwave(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen
			move.l	gadtoolsbase(a5),a6
			move.l	gadgetlistwave(a5),a0
			jsr	gadtools_FreeGadgets(a6)
			move.l	intbase(a5),a6
			move.l	windowptrwave(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)
instredwindowerror
			move.l	screenptr2(a5),a0
			move.l	intbase(a5),a6
			jsr	int_closescreen(a6)	; CLoseScreen(int)
errorscreen2

			move.l	intbase(a5),a6

			move.l	window1ptr(a5),a0	; Gadget in
			move.l	gadgetlist(a5),a1	; Windowstruktur
			moveq	#-1,d0			; Alle Gadgets
			jsr	int_RemoveGList(a6)	; GList removen

			move.l	gadtoolsbase(a5),a6

			move.l	getvisual(a5),a0
			jsr	gadtools_FreeVisualInfo(a6)

			move.l	gadgetlist(a5),a0
			jsr	gadtools_FreeGadgets(a6)

			move.l	menuaddr(a5),a0
			jsr	gadtools_FreeMenus(a6)

			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			jsr	int_clearMenuStrip(a6)

			move.l	window1ptr(a5),a0
			jsr	int_closewindow(a6)	; CloseWindow(int)

			bra.b	closewindow1

errorWindow1		lea	msg_noWindow,a2
			jsr	displaymessage

closewindow1		move.l	screenptr(a5),a0
			move.l	intbase(a5),a6
			jsr	int_closescreen(a6)	; CLoseScreen(int)

errorScreen
;---------------------- Speicher wieder freigeben -----------------------
FONTERROR



;---------------------- Libraries schließen -----------------------------

			move.l	exec,a6
			move.l	pp_base(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
pp_error
			move.l	exec,a6
			move.l	dosbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
dos_error
			move.l	exec,a6
			move.l	rtbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
reqtools_error
			move.l	exec,a6
			move.l	gadtoolsbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
gadtools_error
			move.l	gfxbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
gfx_error
			move.l	diskfontbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
diskfont_error
			move.l	utilbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)
util_error
			move.l	exec,a6
			move.l	intbase(a5),a1
			sub.l	a0,a0
			move	#-96,a0
			move.l	old_displaybeep(a5),d0
			jsr	exec_setfunction(A6)
			move.l	intbase(a5),a1
			moveq	#0,d0
			jsr	exec_closelib(a6)


;---------------------- Returncodes fürs CLI setzen und raus! -----------

			move	#$f,$dff096
			move	#0,$dff0a8
			move	#0,$dff0b8
			move	#0,$dff0c8
			move	#0,$dff0d8


			tst.l	wbmsg
			beq.b	.ex

			move.l	wbmsg,a1
			move.l	exec,a6
			jsr	-378(a6)	; Speicher zurück

.ex			moveq	#0,d0
			moveq	#0,d1
			rts
;------------------------------------------------------------------------
Patch_displaybeep	move	#$000,$dff180
			rts
;------------------------------------------------------------------------
; in:	d0=LongInt
; out:	a0=Ascii string
ConvertLongAsciiHEX	movem.l	d0-d2/d7/a1,-(sp)
			lea	txt_hexchars,a1
			moveq	#0,d1
			moveq	#0,d2
			addq.l	#8,a0
			moveq	#4-1,d7
.loop			subq.l	#2,a0
			move.b	d0,d1
			move.b	d1,d2
			lsr.b	#4,d1
			and.b	#$f,d2
			move.b	(a1,d1),(a0)
			move.b	(a1,d2),1(a0)
			lsr.l	#8,d0
			dbf	d7,.loop
			movem.l	(sp)+,d0-d2/d7/a1
			rts
;------------------------------------------------------------------------
; in:	a0=Ascii string
; out:	d0=LongInt
ConvertAsciiLongHEX	movem.l	d1/d6/d7/a1,-(sp)
			lea	txt_hexchars,a1
			moveq	#0,d0
			moveq	#0,d1
			moveq	#8-1,d6
.loop
			lsl.l	#4,d0			; shift one nibble
			move.b	(a0)+,d1		; ende des strings
			beq.b	.tooshort		; erreicht
			cmp.b	#"A",d1
			bls.b	.nolcase
			bclr	#5,d1			; lcase=ucase
.nolcase
			moveq	#16-1,d7
.searchchar		cmp.b	(a1,d7),d1
			beq.b	.charfound
			dbf	d7,.searchchar
			moveq	#0,d0
			bra.b	.exit
.charfound		or.b	d7,d0
			dbf	d6,.loop		; 8 nibbles (chars)
.exit			movem.l	(sp)+,d1/d6/d7/a1
			rts
.tooshort		add.b	d6,d6
			add.b	d6,d6			; *4
			lsl.l	d6,d0
			bra.b	.exit
;------------------------------------------------------------------------
; in:	a0=Ascii-String (ending with 0)
ZapZeros		move.l	a0,-(sp)
.searchzero		tst.b	(a0)+
			bne.b	.searchzero
			subq.l	#1,a0
.loop			cmp.b	#"0",-1(a0)
			bne.b	.exit
			clr.b	-(a0)
			bra.b	.loop
.exit			move.l	(sp)+,a0
			rts
;------------------------------------------------------------------------
; Gerd-Modus
CheckHertzSchmerz:
			move.l	dosbase(a5),a6
			move.l	#.filename,d1
			move.l	#1005,d2
			jsr	dos_open(a6)
			tst.l	d0
			beq.b	.not
			move.l	d0,d1
			jsr	dos_close(a6)
			move.l	#44682,hzticks(a5)
.not			rts
.filename		dc.b	"hertzschmerz",0
			even
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;			 ##### ##### ## ## #### ####
;			   #     #   # # # #    #  #
;   			   #     #   #   # ##   ###
;			   #   ##### #   # #### #  #
;
;---------------------- Timer-Interrupt (B) -----------------------------
VBI:
			tst.b	lockint+main_data
			bne.b	lockvbi


			movem.l	d0-a6,-(sp)
			lea	main_data,a5

			tst.b	midieditstatus(a5)
			beq.b	.nomidi
			jsr	checkout_midiInput
.nomidi
			cmp.b	#drumseq,programmode(a5)
			bne.b	.nodseq
			bsr	dseq_setcursor
.nodseq
			bsr	equalizer_update
			cmp.b	#replayst_all,replaystatus(a5)
			bne.b	np_timeroff
			tst.b	aon_speed+aon_data	; replay aus ?!?!
			beq.b	np_timeroff
			jsr	addtimer
np_timeroff		jsr	printnewpatternsSIG

			bsr	waveed_actsamplepos

			movem.l	(sp)+,d0-a6
lockvbi			moveq	#0,d0
			lea	$dff000,a0
			rts

;soft_vbint		dc.l	0,0
;			dc.b	2
;			dc.b	0	; prioritaet 16
;			dc.l	0,0
;			dc.l	soft_vbintcode,0,0,0,0

;---------------------- Timer-Interrupt (A) -----------------------------
NP_timerIRB:		movem.l	d1-a6,-(sp)

			tst.b	lockint+main_data
			bne.w	lockcia


; Um die Priorität runterzusetzen
; auf	softinterrupt umlenken!
; lea	soft_vbint(pc),a1
; move.l	$4.w,a6
; jsr	exec_cause(a6)

			lea	main_data,a5

			tst.b	chmode(a5)
			beq.b	.4ch
			move	#$4000,$dff09a
			btst	#6,$bfe001
			bne.b	.playnormal1
			btst	#10,$dff016
			beq.b	.notnormal
.playnormal1
			btst	#7,$bfe001
			bne.b	.playnormal
.notnormal		jsr	stopsong
.playnormal
			jsr	aon8_play
			lea	mix_bypass,a0
			moveq	#8-1,d7
			jsr	mix_startsamples
			move	#$c000,$dff09a
			bra.b	.8ch
.4ch			jsr	aon_play
.8ch


			move.l	intbase(a5),a0
			move.l	56(a0),d0
			cmp.l	screenptr(a5),d0
			beq.b	.show
			cmp.l	screenptr2(a5),d0
			bne.b	.ok1
.show
			tst.b	screen(a5)
			bne.w	.ok1

			move.l	mytask(a5),a1
			move.l	signalnr(a5),d1
			moveq	#0,d0
			bset	d1,d0
			move.l	exec,a6
			jsr	exec_Signal(a6)
			move	#1,patdspVIEW(A5)


;	bsr	adjust_pattdisplay
;	tst.b	itt_adpd_flag(a5)
;	beq.b	.ok1
;	btst	#2,$dff016
;	bne.b	.norealadj
;	tst.b	pdwn_alreadypainted(a5)
;	bne.b	.ok1
;;	bsr	adpd_realadjust
;	move.b	#1,pdwn_alreadypainted(a5)
;	bra.b	.ok1
;.norealadj	clr.b	pdwn_alreadypainted(a5)


.ok1
lockcia
			movem.l	(sp)+,d1-a6
			moveq	#0,d0
			rts


;--------------------------------------------------------------------
; in:	a0=Message
ser_startmessage	addq.l	#3,a0
			move.l	a0,ser_sendptr(a5)
			move	-3(a0),ser_sendtogo(a5)
			move	#$100,d0
			move.b	-1(a0),d0
			move	d0,$dff030
			rts
; -------------------------------------------------------------------	MIDI
; -------------------------------------------------------------------	MIDI
rbf			tst.b	lockint+main_data
			bne.b	lockrbf
	
			movem.l	d0-a6,-(sp)
			lea	main_data,a5
			moveq	#0,d0
			move	ser_captureoff+2(a5),d0
			lea	ser_capture,a0
			lea	(a0,d0.l),a0
			move.b	$dff019,d0
			move.b	d0,(a0)
			addq	#1,ser_captureoff+2(a5)
			and	#255,ser_captureoff+2(a5)

			movem.l	(sp)+,d0-a6
lockrbf			move	#$800,$dff09c
			nop
			nop
			rte
; -------------------------------------------------------------------
; -------------------------------------------------------------------
tbe
			btst	#0,$dff01f
			beq.b	old_level1


			tst.b	lockint+main_data
			bne.b	locktbe

			movem.l	d0-a6,-(sp)
			lea	main_data,a5
			move.l	ser_sendptr(a5),a0
			tst	ser_sendtogo(a5)
			beq.b	.sendfinished
			subq	#1,ser_sendtogo(a5)
			move	#$100,d0
			move.b	(a0),d0
			move	d0,$dff030
			addq.l	#1,ser_sendptr(a5)

.sendfinished		movem.l	(sp)+,d0-a6
locktbe			move	#1,$dff09c
			nop
			nop
			nop
			rte
old_level1		jmp	0

;--------------------------------------------------------------------
; d0=Gadgetnr
DisableGadget2		movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			add.l	d0,d0
			add.l	d0,d0
			lea	mpwave_gadgetptrs,a0
			move.l	(a0,d0.l),a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	mp_disabledtags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
; d0=Gadgetnr
EnableGadget2		movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			add.l	d0,d0
			add.l	d0,d0
			lea	mpwave_gadgetptrs,a0
			move.l	(a0,d0.l),a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	mp_enabledtags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts


; -----------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;--------------------------------------------------------------------

;--------------------------------------------------------------------
refresh_waveposslider:
			rts

;		movem.l	d0-a6,-(sp)
;		move.l	gadtoolsbase(a5),a6
;;		bsr	waveed_actwavedata
;;		move.l	mp2_gadgetptrs+gad_waveChangePos*4,a0
;		move.l	window2ptr(a5),a1
;		lea	.tags(pc),a3
;		moveq	#8,d1
;		lsl.l	d1,d0
;		move.l	waveed_dispsize(a5),d1
;		bsr	divu_l
;;	lsr.l	#8,d0
;		move.l	d0,4(a3)
;		sub.l	a2,a2
;		jsr	gadtools_gt_setgadgetattrsa(a6)
;		movem.l	(sp)+,d0-a6
;		rts
;.tags		dc.l	gtsc_total,2
;		dc.l	tag_done
;--------------------------------------------------------------------
refresh_waveedwaveALL:
			movem.l	d0-a6,-(sp)
;bsr	waveed_clrsampleposBPl
;bsr	refresh_waveposslider
			bsr	refresh_wavewaveslider
			bsr	refresh_waveedwaveLen
			bsr	refresh_waveedDisplayLen
			bsr	refresh_waveedRangeLen
			bsr	refresh_waveedPos
			bsr	waveed_drawwave
			bsr	waveed_drawrange
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
Refresh_waveedDSPGAIN:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			moveq	#0,d0
			move.b	wavedspgain(a5),d0
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_waveGainTxt*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtnm_number,0
			dc.l	tag_done
;--------------------------------------------------------------------
Refresh_waveedwavelen:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	waveed_actwavedata
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_waveWavelentxt*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtnm_number,0
			dc.l	tag_done
;--------------------------------------------------------------------
Refresh_waveedDisplayLen:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.l	waveed_dispsize(a5),4(a3)
			move.l	mpwave_gadgetptrs+gad_waveDisplaylentxt*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtnm_number,0
			dc.l	tag_done
;--------------------------------------------------------------------
Refresh_waveedRangeLen:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.l	waveed_rangesize(a5),4(a3)
			move.l	mpwave_gadgetptrs+gad_waveRangelentxt*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtnm_number,0
			dc.l	tag_done
;--------------------------------------------------------------------
Refresh_waveedPos:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.l	waveed_wavepos(a5),4(a3)
			move.l	mpwave_gadgetptrs+gad_wavePostxt*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtnm_number,0
			dc.l	tag_done
;--------------------------------------------------------------------
waveed_drawwave:
			bsr	waveed_clrwavedisplay
			moveq	#0,d2
			move.b	waveed_actwave(a5),d2
			add	d2,d2
			add	d2,d2
;lea	module_wavelenlist,a1
;move.l	(a1,d2.l),d0		; d0=wavelen
			lea	aon_wavestarts+aon_data,a1
			move.l	(a1,d2.l),a1
			add.l	waveed_off(A5),a1
			move.l	waveed_dispsize(a5),d0

; a1=Zeiger auf wavedaten
; d0=Länge der wavedaten in bytes

			tst.l	d0
			bne.b	.notwaveempty

			move.l	bitplane1_startadr2(a5),a4
			lea	172*80+2(a4),a4
;	lea	2+(80*(gyoff+4))(a4),a4
			lea	34+26*80(a4),a4

			lea	gfx_waveempty,a0
			move.l	(a0)+,0*80(a4)
			move.l	(a0)+,1*80(a4)
			move.l	(a0)+,2*80(a4)
			move.l	(a0)+,3*80(a4)
			move.l	(a0)+,4*80(a4)
			move.l	(a0)+,5*80(a4)
			move.l	(a0)+,6*80(a4)
			move.l	(a0)+,7*80(a4)
;
;			move.l	bitplane1_startadr2(a5),a0
;			lea	169*80(a0),a0
;			lea	wavebpl,a1
;			move	#(69*80)/16-1,d7
;.copywave2		rept	4
;			move.l	(a0)+,(a1)+
;			endr
;			dbf	d7,.copywave2
			rts
.notwaveempty
			movem.l	rastportwave(a5),d7

; Farbregister richtig setzen
			movem.l	d0-a6,-(sp)
			move.l	gfxbase(a5),a6
			move.l	d7,a1
			moveq	#1,d0
			jsr	gfx_setapen(a6)
			movem.l	(sp)+,d0-a6
; Grafikcursor richtig setzen
			movem.l	d0-a6,-(sp)
			move.l	gfxbase(a5),a6
			move.l	d7,a1
			moveq	#8,d0
			move.l	#169+25,d1   ;gyoff+32,d1
			jsr	gfx_move(a6)
			movem.l	(sp)+,d0-a6


			move.l	d0,d4
			move.l	a1,a4

; d0=wavelen (sichtbar)
			move	#$4000,$dff09a
			bsr	tronlineinit


			cmp.l	#$ffff,d0
			ble.b	.fastdraw

			moveq	#0,d3
			moveq	#9,d6		; x-cnt
.drawlinesloop
			move.l	d4,d0
			move.l	d3,d1
			bsr	mulu_l
			move.l	#640-16,d1
			bsr	divu_l
			lea	(a4,d0.l),a1

			moveq	#0,d1
			move.b	(a1),d1

			ext	d1
			move.b	wavedspgain(a5),d0
			asl	d0,d1
			cmp	#128,d1
			blt.b	.notmax1
			moveq	#127,d1
.notmax1		cmp	#-128,d1
			bgt.b	.notmax2
			moveq	#-127,d1
.notmax2
			addq	#1,d1
			neg.b	d1
			asr.b	#2,d1

			ext	d1
			add	#169+25,d1	;4+32+gyoff,d1
			move.l	d6,d0
;	bsr	sysline
			bsr	ownline

			addq	#1,d3
			addq	#1,d6
			cmp	#640-8,d6
			bne	.drawlinesloop

.blxy			btst	#6,$dff002
			bne.b	.blxy
			move.l	gfxbase(a5),a6
			jsr	-462(a6)	; Disownblitter
			move	#$c000,$dff09a

;.bmdb			move.l	bitplane1_startadr2(a5),a0
;			lea	169*80(a0),a0
;			lea	wavebpl,a1
;			move	#(69*80)/16-1,d7
;.copywave		rept	4
;			move.l	(a0)+,(a1)+
;			endr
;			dbf	d7,.copywave
			rts
.fastdraw
			swap	d0
			move.l	#640-16,d1
			jsr	divu_l
			moveq	#0,d3
			move	d0,d3		; addx-add
			moveq	#0,d4		; addx-counter
			moveq	#0,d5
			swap	d0		; byteadd
			move	d0,d5
			moveq	#0,d2
			moveq	#9,d6
.fastloop
			moveq	#0,d1
			move.b	(a1,d2.l),d1

			ext	d1
			move.b	wavedspgain(a5),d0
			asl	d0,d1
			cmp	#128,d1
			blt.b	.notmax12
			moveq	#127,d1
.notmax12		cmp	#-128,d1
			bgt.b	.notmax22
			moveq	#-127,d1
.notmax22
			addq	#1,d1
			neg.b	d1
			asr.b	#2,d1
			ext	d1
			add	#169+25,d1
			move.l	d6,d0
;bsr	sysline
			bsr	ownline
			add	d3,d4
			addx.l	d5,d2
			addq	#1,d6
			cmp	#640-8,d6
			bne	.fastloop

.blx			btst	#6,$dff002
			bne.b	.blx

			move.l	gfxbase(a5),a6
			jsr	-462(a6)	; Disownblitter
			move	#$c000,$dff09a
			rts
;--------------------------------------------------------------------
waveed_drawrange

			tst.l	waveed_rangesize(a5)
			beq.w	.norange

; ist die range ueberhaupt zu sehen?!
			move.l	waveed_off(a5),d0
			move.l	d0,d4
			add.l	waveed_dispsize(a5),d4
			move.l	waveed_wavepos(a5),d1
; d4=end of display
			cmp.l	d4,d1		; zu weit rechts?!
			bhs.w	.norange
			move.l	d1,d2
			add.l	waveed_rangesize(a5),d2
; d2=end of range
			cmp.l	d0,d2		; zu weit links?!
			bls.w	.norange
;  d0
;d1  |--------|	display
; ********	range
; d6=is going contain the visible size of the range (after this rout..)
			cmp.l	d0,d1		, muß links geclippt werden?!
			bhs.b	.noleftclip
			cmp.l	d2,d4		; ist das gesamte display
			bhs.b	.notwholedisp	; ausgefüllt?!
			move.l	waveed_dispsize(a5),d6
			move.l	d0,d7		; draw-dispoffset
			bra.b	.drawrange
.notwholedisp		move.l	d2,d6		; end of range-dispoffset
			sub.l	d0,d6		; =new visible rangelen
			move.l	d0,d7		; draw-dispoffset
			bra.b	.drawrange
.noleftclip
;   |--------|
;       *********
			cmp.l	d2,d4
			bhs.b	.norightclip
			move.l	d4,d6		; end of display
			sub.l	d1,d6		; -range offset
			move.l	d1,d7		; draw-dispoffset
			bra.b	.drawrange
.norightclip
			move.l	waveed_rangesize(a5),d6
			move.l	d1,d7		; draw-dispoffset

; d6=visible size of range!! (as bytelen in wave)
; d7=drawoffset (as byteoffset in wave)
.drawrange
;0	      300
; |------------|
;     ******
;   100    200
; wieviele bytes kommen auf einen pixel?!
			move.l	waveed_dispsize(a5),d0
			lsl.l	#8,d0
			move.l	#640-16,d1	; abzüglich der border!!!!
			bsr	divu_l
; d0=anzahl der bytes pro pixel*256
			move.l	d0,d5
			move.l	d6,d0
			lsl.l	#8,d0
			move.l	d5,d1
			bsr	divu_l
			lsr.l	#8,d6
			move.l	d0,d6
; d6=visible size of range in pixels!!
			move.l	d7,d0	; drawoffset in bytes
			sub.l	waveed_off(a5),d0	- dispstart in bytes
			lsl.l	#8,d0
			move.l	d5,d1
			bsr	divu_l
			lsr.l	#8,d7
			move.l	d0,d7
			addq	#4,d7	; wir wollen doch den rand
					; nicht vollmalen
; d7=drawoffset as pixels on screen!

			move.l	bitplane3_startadr2(a5),a0
			lea	169*80(a0),a0
			move.l	a0,a1
			moveq	#0,d0
			moveq	#73-1,d1
.clrllop		rept	20
			move.l	d0,(a1)+
			endr
			dbf	d1,.clrllop
; draw left border
			move.l	d7,d0
			subq	#4,d0
			move.b	d0,d1
			not.b	d1
			lsr	#3,d0
			moveq	#67-1,d2
.leftborder		bset	d1,1(a0,d0.l)
			add.l	#80,d0
			dbf	d2,.leftborder
; draw right border
			move.l	d7,d0
			add.l	d6,d0
			subq	#4,d0
			cmp	#640-12,d0
			blt.b	.clipright
			move	#640-12,d0
.clipright
			move.b	d0,d1
			not.b	d1
			lsr	#3,d0
			moveq	#67-1,d2
.rightborder		bchg	d1,1(a0,d0.l)
			add.l	#80,d0
			dbf	d2,.rightborder
			
			move	#$4000,$dff09a

			btst	#6,$dff002
.waitblit		btst	#6,$dff002
			bne.b	.waitblit

			moveq	#-1,d0
			move.l	d0,$dff044

			move.l	d7,d0
			lsr	#4,d0
			add	d0,d0
			add.l	#67*80+78,d0
			lea	(a0,d0.l),a1
			move.l	a1,$dff050
			move.l	a1,$dff054

			move	#%0000100111110000,$dff040
			move	#10,$dff042

			move.l	#0,$dff064

			move	#(64*67)+40,$dff058

.invertdisp

			btst	#6,$dff002
.waitblit2		btst	#6,$dff002
			bne.b	.waitblit2

			move	#$c000,$dff09a
			rts
.norange
			move.l	bitplane3_startadr2(a5),a0
			lea	169*80(a0),a0
			moveq	#0,d0
			moveq	#73-1,d1
.clrllop2		rept	20
			move.l	d0,(a0)+
			endr
			dbf	d1,.clrllop2
			rts
;--------------------------------------------------------------------
waveed_clrwavedisplay	
			movem.l	d0-a6,-(sp)
			move.l	bitplane1_startadr2(a5),a0
			lea	168*80(a0),a0
			moveq	#0,d0
			moveq	#70-1,d7
.loop			rept	20
			move.l	d0,(a0)+
			endr
			dbf	d7,.loop
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
; 32-Bit Multiplikation !!
; d0=1.Multiplikant
; d1=2.Multiplikant
; --
; d0=Ergebnis
mulu_l
			tst.b	extproc(a5)
			beq.b	.none
			mulu.l	d1,d0
			rts
.none
			movem.l	d1/a6,-(sp)
			move.l	utilbase(a5),a6
			jsr	util_umult32(a6)
			movem.l	(sp)+,d1/a6
			rts
;--------------------------------------------------------------------
; d0=1.Faktor
; d1=2.Faktor
; OUT:	d0=Ergebnis
divu_L:
			tst.b	extproc(a5)
			beq.b	.none

			tst.l	d0
			beq.b	.ndbz1
			tst.l	d1
			beq.b	.ndbz
			divu.l	d1,d0
			rts
.ndbz			moveq	#0,d0
.ndbz1			rts

.none			movem.l	d1/a6,-(sp)
			tst.l	d0
			beq.b	.fail2
			tst.l	d1
			beq.b	.fail
			move.l	utilbase(a5),a6
			jsr	util_udivmod32(a6)
			movem.l	(sp)+,d1/a6
			rts
.fail			moveq	#0,d0
.fail2			movem.l	(sp)+,d1/a6
			rts
;--------------------------------------------------------------------
; -->d0= gadget-nr.
; -->evtl. cbox_taglist+4 neu setzen
refresh_checkbox	move.l	a6,-(sp)
			lea	mp_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	cbox_taglist,a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
cbox_taglist		dc.l	gtcb_checked,false
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_dseqnrslider	movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	mp2_gadgetptrs+gad_drumseqnr*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.b	dseq_actseq(a5),7(a3)
			jsr	gadtools_gt_setgadgetattrsa(a6)

			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			lea	txt_hexchars,a2
			move.b	(a2,d0),txt_actseqnr
			move.l	mp2_gadgetptrs+gad_drumseqnrTXT*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	dseq_gadget1txttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_wavewaveslider	movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6

;			move.l	mpwave_gadgetptrs+gad_wavechangewave*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	.tags(pc),a3
;			move.b	waveed_actwave(a5),7(a3)
;			jsr	gadtools_gt_setgadgetattrsa(a6)

			moveq	#0,d0
			move.b	waveed_actwave(a5),d0
			addq.b	#1,d0
			add.b	d0,d0
			add	d0,d0
			lea	txt_2charsnrs,a2
			move	(a2,d0),txt_waveactwave
			move.l	mpwave_gadgetptrs+gad_wavechangewaveTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	waveed_gad_changewavetxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
;.tags			dc.l	gtsc_top,0
;			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredwaveformslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			bsr	instred_actualdata
			moveq	#0,d7
			move.b	instr_waveform(a0),d7
			move.b	d7,7(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangewavenr*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			lea	txt_2charsnrs,a2
			addq.b	#1,d7
			add	d7,d7
			add	d7,d7
			move	(a2,d7),txt_instredactwavenr
			move.l	mpwave_gadgetptrs+gad_instrchangewavenrTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	instred_gad_changewavenrtxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredvolumeslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			bsr	instred_actualdata
			moveq	#0,d7
			move.b	instr_volume(a0),d7
			move.b	d7,7(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangevolume*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			lea	txt_2charsnrs,a2
			add	d7,d7
			add	d7,d7
			move	(a2,d7),txt_instredactvolume
			move.l	mpwave_gadgetptrs+gad_instrchangevolumeTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	instred_gad_changevolumetxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredsampleoffsetslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a1
			move.l	(a1,d0),d1		; wavesize
			lsr.l	#1,d1		;in worte
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmaoffset(a0),d0
.synth
			moveq	#13,d2
			lsl.l	d2,d0		; *$2000
			bsr	divu_l

			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangesampleoffset*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredsamplelenslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a1
			move.l	(a1,d0),d1		; wavesize
			lsr.l	#1,d1		;in worte
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmaoffset(a0),d0
			add.l	sample8_dmalen(a0),d0
.synth
			moveq	#13,d2
			lsl.l	d2,d0		; *$2000
			bsr	divu_l

			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangesamplelen*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredrepeatoffsetslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a1
			move.l	(a1,d0),d1		; wavesize
			lsr.l	#1,d1		;in worte
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmarepoffset(a0),d0
.synth
			moveq	#13,d2
			lsl.l	d2,d0		; *$2000
			bsr	divu_l

			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangerepeatoffset*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredrepeatlenslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_waveform(a0),d0
			add	d0,d0
			add	d0,d0
			lea	module_wavelenlist,a1
			move.l	(a1,d0),d1		; wavesize
			lsr.l	#1,d1		;in worte
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmarepoffset(a0),d0
			add.l	sample8_dmareplen(a0),d0
.synth
			moveq	#13,d2
			lsl.l	d2,d0		; *$2000
			bsr	divu_l

			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.l	d0,4(a3)
			move.l	mpwave_gadgetptrs+gad_instrchangerepeatlen*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredfinetuneslider
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			bsr	instred_actualdata
			moveq	#0,d7
			move.b	instr_finetune(a0),d7
			lea	finetuneback_tab(pc),a0	; slider auf die mitte
			move.b	(a0,d7),7(a3)		; justieren
			move.l	mpwave_gadgetptrs+gad_instrchangefinetune*4,a0
			jsr	gadtools_gt_setgadgetattrsa(a6)

			lea	txt_finetunes,a2
			add	d7,d7
			move	(a2,d7),txt_instredactfinetune
			move.l	mpwave_gadgetptrs+gad_instrchangefinetuneTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	instred_gad_changefinetunetxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
finetuneback_tab	dc.b	8,9,10,11,12,13,14,15
			dc.b	0,1,2,3,4,5,6,7
;--------------------------------------------------------------------
Refresh_instredfinetuneslidertxt
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			lea	txt_finetunes,a2
			bsr	instred_actualdata
			moveq	#0,d0
			move.b	instr_finetune(a0),d0
			add	d0,d0
			move	(a2,d0),txt_instredactfinetune
			move.l	mpwave_gadgetptrs+gad_instrchangefinetuneTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	instred_gad_changefinetunetxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts
;------------------------------------------------------------------------
Refresh_instredMode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	instred_actualdata
			move.b	instr_control(a0),7(a3)
			move.l	mpwave_gadgetptrs+gad_instrmode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupWavedrawmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_splitmode,7(a3)
			move.l	mp2_gadgetptrs+gad_setupWavedrawmode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupSaveRemarkmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_saveremark,7(a3)
			move.l	mp2_gadgetptrs+gad_setupSaveRemarkMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupSaveInstrnamesmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_saveinstrnames,7(a3)
			move.l	mp2_gadgetptrs+gad_setupSaveInstrnamesMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupCrunchmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_oversize,7(a3)
			move.l	mp2_gadgetptrs+gad_setupCrunchMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupAddppmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_addpp,7(a3)
			move.l	mp2_gadgetptrs+gad_setupAddppMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupCrunchEFFmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_cruncheff,7(a3)
			move.l	mp2_gadgetptrs+gad_setupCruncheffMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupCrunchBuFmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_crunchbuf,7(a3)
			move.l	mp2_gadgetptrs+gad_setupCrunchBufMode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupBottomStatusMode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_bottomstatusmode,7(a3)
			move.l	mp2_gadgetptrs+gad_setupBottomStatusmode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupForcePALmode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_forcepal,7(a3)
			move.l	mp2_gadgetptrs+gad_setupForcePalmode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_fmedWaveSel1
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	fmed_actfmdata
			move.b	fm_waveM(a0),7(a3)
			move.l	mp2_gadgetptrs+gad_fmedwavesel1*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_fmedWaveSel2
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	fmed_actfmdata
			move.b	fm_waveC(a0),7(a3)
			move.l	mp2_gadgetptrs+gad_fmedwavesel2*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_setupFiltermode
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			move.b	prf_data+prf_filtermode,7(a3)
			move.l	mp2_gadgetptrs+gad_setupFiltermode*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredWAVErepctrl
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	instred_actualdata
			move.b	synth8_WAVErepctrl(a0),7(a3)
			move.l	mpwave_gadgetptrs+gad_instrWAVErepctrl*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredVIBwave
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags,a3
			bsr	instred_actualdata
			move.b	synth8_VIBwave(a0),7(a3)
			move.l	mpwave_gadgetptrs+gad_instrVIBwave*4,a0
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtcy_active,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_dseqspeed	clr.l	ref_ikind_data2
			move.b	dseq_speed(a5),ref_ikind_data2+3
			moveq	#gad_dseqspeed,d0
			bra	refresh_integer_kind3
;------------------------------------------------------------------------
Refresh_dseqtempo	clr.l	ref_ikind_data2
			move.b	dseq_tempo(a5),ref_ikind_data2+3
			moveq	#gad_dseqtempo,d0
			bra	refresh_integer_kind3
;------------------------------------------------------------------------
Refresh_dseqdestwave	clr.l	ref_ikind_data2
			move.b	dseq_destwave(a5),ref_ikind_data2+3
			addq.b	#1,ref_ikind_data2+3
			moveq	#gad_dseqdestwave,d0
			bra	refresh_integer_kind3
;------------------------------------------------------------------------
Refresh_instredsampleoffset
			bsr	Refresh_instredsampleoffsetslider
Refresh_instredsampleoffsetNOSLIDE
			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmaoffset(a0),d0
.synth
			add.l	d0,d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_instrsampleoffset,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredsamplelen
			bsr	refresh_instredsamplelenslider
Refresh_instredsamplelenNOSLIDE
			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmalen(a0),d0
.synth
			add.l	d0,d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_instrsamplelen,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_waveedPartwavelen
			moveq	#0,d0
			move	waveed_partwavelen(a5),d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_wavepartwavesize,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredrepeatoffset
			bsr	Refresh_instredrepeatoffsetslider
Refresh_instredrepeatoffsetNOSLIDE
			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			bra.b	.synth
.sample			move.l	sample8_dmarepoffset(a0),d0
.synth
			add.l	d0,d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_instrrepeatoffset,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredrepeatlen
			bsr	Refresh_instredrepeatlenslider
Refresh_instredrepeatlenNOSLIDE
			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	.sample
			moveq	#0,d0
			move.b	synth8_partwaveDmaLen(a0),d0
			bra.b	.synth
.sample			move.l	sample8_dmareplen(a0),d0
.synth
			add.l	d0,d0
			move.l	d0,ref_ikind_data2
			moveq	#gad_instrrepeatlen,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_dseqwavegadgets
			clr.l	ref_ikind_data2
			moveq	#0,d0
			move.b	dseq_actseq(a5),d0
			move	d0,d1
			lsl	#4,d0	; *16	(1byte waveform,1byte note)
			add	d1,d0	; +1 = *17 !! (1byte für seqlen)
			lea	dseq_addData,a0
			lea	1(a0,d0),a0

			moveq	#gad_dseqoptions0_2,d0
			moveq	#16-1,d7
.loop			movem.l	d0-a6,-(sp)
			move.b	(a0),ref_ikind_data2+3
			addq.b	#1,ref_ikind_data2+3
			bsr	refresh_integer_kind3
			movem.l	(sp)+,d0-a6
			addq.l	#1,a0
			addq	#1,d0
			dbf	d7,.loop
			rts
;------------------------------------------------------------------------
Refresh_dseqlenslider	movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	mp2_gadgetptrs+gad_drumseqlen*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move.b	dseq_actseqlen(a5),7(a3)
			jsr	gadtools_gt_setgadgetattrsa(a6)

			moveq	#0,d0
			move.b	dseq_actseqlen(a5),d0
			lea	txt_2charsnrs,a2
			add	d0,d0
			add	d0,d0
			move	4(a2,d0),txt_seqlen
			move.l	mp2_gadgetptrs+gad_drumseqlenTXT*4,a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	dseq_gadget2txttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instrslider	movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	mp_gadgetptrs+gad_changeinstrnr*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move	acteditinstr(a5),6(a3)
			jsr	gadtools_gt_setgadgetattrsa(a6)
			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instrsliderED	movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			move.l	mpwave_gadgetptrs+gad_instrchangeinstrnr*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	.tags(pc),a3
			move	acteditinstr(a5),6(a3)
			jsr	gadtools_gt_setgadgetattrsa(a6)
			movem.l	(sp)+,d0-a6
			rts
.tags			dc.l	gtsc_top,0
			dc.l	tag_done
;------------------------------------------------------------------------
Refresh_instredWAVEspd	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	synth8_WAVEspd(a0),ref_ikind_data2+3
			moveq	#gad_instrWAVEspd,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredWAVElen2	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	synth8_WAVElen(a0),ref_ikind_data2+3
			moveq	#gad_instrWAVElen,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredWAVErep	clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	synth8_WAVErep(a0),ref_ikind_data2+3
			moveq	#gad_instrWAVErep,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredWAVEreplen
			clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	synth8_WAVEreplen(a0),ref_ikind_data2+3
			moveq	#gad_instrWAVEreplen,d0
			bra	refresh_integer_kind2
;------------------------------------------------------------------------
Refresh_instredVIBdelay
			clr.l	ref_ikind_data2
			bsr	instred_actualdata
			move.b	synth8_VIBdelay(a0),ref_ikind_data2+3
			moveq	#gad_instrVIBdelay,d0
			bra	refresh_integer_kind2
;--------------------------------------------------------------------
Refresh_instredVIBpara
			movem.l	d0-a6,-(sp)
			bsr	instred_actualdata
			moveq	#0,d0
			moveq	#0,d1
			move.b	synth8_VIBpara(a0),d0
			move.b	d0,d1
			lsr.b	#4,d0
			and.b	#$f,d1
			lea	txt_hexchars,a1
			lea	instred_actVIBparaASC,a2
			move.b	(a1,d0),(a2)
			move.b	(a1,d1),1(a2)
			lea	.tags(pc),a3
			move.l	gad_instrVIBpara*4+mpwave_gadgetptrs,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts

.tags			dc.l	gtst_string,instred_actvibparaASC
			dc.l	tag_done
;--------------------------------------------------------------------
Refresh_instrument:
;tst.b	screen(a5)
;beq.b	.notwaveed


;.notwaveed
			bsr	refresh_instrslider
			move.l	a6,-(sp)
			move.l	mp_gadgetptrs+gad_instrumentname*4,a0
			move.l	a0,a1
			move.l	$22(a1),a1
			moveq	#0,d0
			move	acteditinstr(a5),d0
			move.l	d0,-(sp)
			lea	txt_instrnrs,a2
			move.b	1(a2,d0),txt_actinstrnr

			lsl.l	#5,d0
			add.l	#module_instrnames,d0
			move.l	d0,(a1)
			move.l	d0,refins_taglist+4
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	refins_taglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)

			move.l	mp_gadgetptrs+rog_instrnr*4,a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	mp_rog7tags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			move.l	(sp)+,d0
			add	d0,d0
			add	d0,d0
			lea	aon_data+aon_instrstarts,a0
			move.l	(a0,d0.l),a0

			tst.b	(a0)			; sample8 ?!?!
			beq.b	.sample8len
			moveq	#0,d0
			move.b	synth8_partwaveDMALen(a0),d0
			bra.b	.synth8len
.sample8len		move.l	sample8_dmalen(a0),d0
.synth8len		add.l	d0,d0
			move.l	d0,rog_taglist+4
			moveq	#rog_wavesize,d0
			move.l	a0,-(sp)
			bsr	refresh_number_kind
			move.l	(sp)+,a0
			moveq	#0,d0
			moveq	#0,d1
			move.b	instr_volume(a0),d0
			move.b	d0,d1
			lsr.b	#4,d0
			and.b	#$f,d1
			lea	txt_actvolume,a1
			lea	txt_hexchars,a2
			move.b	(a2,d0),(a1)
			move.b	(a2,d1),1(a1)
			moveq	#rog_volume,d0
			move.l	a1,rog_texttaglist+4
			bsr	refresh_text_kind
.unknowntype

			move.l	(sp)+,a6
			rts
refins_taglist		dc.l	gtst_string,0		; Ptr auf Textpuffer
			dc.l	TAG_DONE
;------------------------------------------------------------------------
Refresh_BaseInstrument
			bsr	refresh_instrsliderED
			bsr	refresh_instrnameED
			bsr	refresh_instredwaveformslider
			bsr	refresh_instredvolumeslider
			bsr	refresh_instredfinetuneslider
			bra	refresh_instredmode
;------------------------------------------------------------------------
Refresh_instrumentED:
			bsr	refresh_waveedwaveall

Refresh_instrumentED2:	bsr	instred_endisable
			bsr	refresh_instrsliderED
			bsr	refresh_instrnameED

			bsr	refresh_instredwaveformslider
			bsr	refresh_instredvolumeslider
			bsr	refresh_instredfinetuneslider
			bsr	refresh_instredmode

			bsr	refresh_instredSampleoffset
			bsr	refresh_instredSampleLen
			bsr	refresh_instredRepeatoffset
			bsr	refresh_instredRepeatLen

			bsr	refresh_instredAstart
			bsr	refresh_instredAadd
			bsr	refresh_instredAend
			bsr	refresh_instredAsub

			bsr	instred_actualdata
			tst.b	instr_control(a0)
			beq.b	refresh_sampleED
			bsr	refresh_instredWAVEspd
			bsr	refresh_instredWAVElen2
			bsr	refresh_instredWAVErep
			bsr	refresh_instredWAVEreplen
			bsr	refresh_instredVIBdelay
			bsr	refresh_instredVIBpara
			bsr	refresh_instredWAVErepctrl
			bsr	refresh_instredVIBwave
			rts
refresh_sampleED
			rts
;--------------------------------------------------------------------
refresh_instrnameED:
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			moveq	#0,d0
			move	acteditinstr(a5),d0
			lea	txt_instrnrs,a2
			move.b	1(a2,d0),txt_instredactinstrnr

			move.l	mpwave_gadgetptrs+gad_instredname*4,a0
			move.l	a0,a1
			move.l	$22(a1),a1
			lsl.l	#5,d0
			add.l	#module_instrnames,d0
			move.l	d0,(a1)
			lea	refins_taglist(pc),a3
			move.l	d0,4(a3)
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			jsr	gadtools_gt_setgadgetattrsA(a6)

			move.l	mpwave_gadgetptrs+gad_instrchangeinstrnrTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	instred_gad_changeinstrnrtxttags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)

			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
refresh_waveedpartwave
			movem.l	d0-a6,-(sp)
			move.l	gadtoolsbase(a5),a6
			moveq	#0,d0
			move.b	waveed_actpartwave(a5),d0
			lea	txt_3charsnrs,a2
			add	d0,d0
			add	d0,d0
			move.l	(a2,d0),txt_waveedactpartwave
			clr.b	txt_waveedactpartwave+3

			move.l	mpwave_gadgetptrs+gad_wavepartwaveTXT*4,a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	waveed_gad_partwaveTXTtags,a3
			jsr	gadtools_gt_setgadgetattrsA(a6)
			movem.l	(sp)+,d0-a6
			rts
;;--------------------------------------------------------------------
;refresh_instredCopyFrom:
;			movem.l	d0-a6,-(sp)
;			move.l	gadtoolsbase(a5),a6
;			move.l	mpwave_gadgetptrs+gad_instrchangecopyfrom*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	.tags(pc),a3
;			move.b	instred_copyfrom(a5),7(a3)
;			jsr	gadtools_gt_setgadgetattrsa(a6)
;
;			move.l	gadtoolsbase(a5),a6
;			moveq	#0,d0
;			move.b	instred_copyfrom(a5),d0
;			lea	txt_instrnrs,a2
;			move.b	1(a2,d0),txt_instredactcopyfrom
;
;			move.l	mpwave_gadgetptrs+gad_instrchangeCopyfromTXT*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	instred_gad_changeCopyFromTXTtags,a3
;			jsr	gadtools_gt_setgadgetattrsA(a6)
;			movem.l	(sp)+,d0-a6
;			rts
;.tags			dc.l	gtsc_top,0
;			dc.l	tag_done
;;--------------------------------------------------------------------
;refresh_instredCopyto:
;			movem.l	d0-a6,-(sp)
;			move.l	gadtoolsbase(a5),a6
;			move.l	mpwave_gadgetptrs+gad_instrchangecopyto*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	.tags(pc),a3
;			move.b	instred_copyto(a5),7(a3)
;			jsr	gadtools_gt_setgadgetattrsa(a6)
;
;			move.l	gadtoolsbase(a5),a6
;			moveq	#0,d0
;			move.b	instred_copyto(a5),d0
;			lea	txt_instrnrs,a2
;			move.b	1(a2,d0),txt_instredactcopyto
;
;			move.l	mpwave_gadgetptrs+gad_instrchangeCopytoTXT*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	instred_gad_changeCopytoTXTtags,a3
;			jsr	gadtools_gt_setgadgetattrsA(a6)
;			movem.l	(sp)+,d0-a6
;			rts
;.tags			dc.l	gtsc_top,0
;			dc.l	tag_done
;--------------------------------------------------------------------
;refresh_waveedCopyFrom:
;			movem.l	d0-a6,-(sp)
;			move.l	gadtoolsbase(a5),a6
;			move.l	mpwave_gadgetptrs+gad_wavechangecopyfrom*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	.tags(pc),a3
;			move.b	waveed_copyfrom(a5),7(a3)
;			jsr	gadtools_gt_setgadgetattrsa(a6)
;
;			move.l	gadtoolsbase(a5),a6
;			moveq	#0,d0
;			move.b	waveed_copyfrom(a5),d0
;			addq.b	#1,d0
;			lea	txt_2charsnrs,a2
;			add	d0,d0
;			add	d0,d0
;			move	(a2,d0),txt_waveedactcopyfrom
;
;			move.l	mpwave_gadgetptrs+gad_wavechangeCopyfromTXT*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	waveed_gad_changeCopyFromTXTtags,a3
;			jsr	gadtools_gt_setgadgetattrsA(a6)
;			movem.l	(sp)+,d0-a6
;			rts
;.tags			dc.l	gtsc_top,0
;			dc.l	tag_done
;;--------------------------------------------------------------------
;refresh_waveedCopyto:
;			movem.l	d0-a6,-(sp)
;			move.l	gadtoolsbase(a5),a6
;			move.l	mpwave_gadgetptrs+gad_wavechangecopyto*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	.tags(pc),a3
;			move.b	waveed_copyto(a5),7(a3)
;			jsr	gadtools_gt_setgadgetattrsa(a6)
;
;			move.l	gadtoolsbase(a5),a6
;			moveq	#0,d0
;			move.b	waveed_copyto(a5),d0
;			addq.b	#1,d0
;			lea	txt_2charsnrs,a2
;			add	d0,d0
;			add	d0,d0
;			move	(a2,d0),txt_waveedactcopyto
;
;			move.l	mpwave_gadgetptrs+gad_wavechangeCopytoTXT*4,a0
;			move.l	windowptrwave(a5),a1
;			sub.l	a2,a2
;			lea	waveed_gad_changeCopytoTXTtags,a3
;			jsr	gadtools_gt_setgadgetattrsA(a6)
;			movem.l	(sp)+,d0-a6
;			rts
;.tags			dc.l	gtsc_top,0
;			dc.l	tag_done
;--------------------------------------------------------------------

Refresh_editpat		moveq	#gad_editpat,d0
			clr.l	ref_ikind_data
			move	acteditpattern(a5),ref_ikind_data+2
			bra.b	refresh_integer_kind
;------------------------------------------------------------------------
Refresh_setupblankertimeout
			moveq	#gad_setupblankertimeout,d0
			clr	ref_ikind_data
			move	prf_data+prf_blankertimeout,ref_ikind_data2+2
			bra	refresh_integer_kind3
;------------------------------------------------------------------------
Refresh_pos
			jsr	poslistsetgadget
			jsr	printposlist
			moveq	#gad_pos,d0
			clr.l	ref_ikind_data
			move.b	aon_data+aon_pos,ref_ikind_data+3
			bra.b	refresh_integer_kind
;------------------------------------------------------------------------
Refresh_pat		moveq	#gad_pat,d0
			clr.l	ref_ikind_data
			moveq	#0,d1
			move.b	aon_data+aon_pos,d1
			move.l	aon_data+aon_posdata,a0
			move.b	(a0,d1.l),ref_ikind_data+3

		;;;;;;;ATTTTTEEENNTTTIIONN!;;;;;;;;;

;-----------------------------------------------------	Integer-Gadget refresh
; -->d0=Gadget-Nr
; -->ref_ikind_data	neu setzen!
Refresh_INTEGER_KIND	move.l	a6,-(sp)
			lea	mp_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	ref_ikind_taglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
ref_ikind_taglist	dc.l	gtin_number
ref_ikind_data		dc.l	0
			dc.l	tag_done
;-----------------------------------------------------	Integer-Gadget refresh
; -->d0=Gadget-Nr
; -->ref_ikind_data	neu setzen!
; das gleiche nochmal nur für window 2
Refresh_INTEGER_KIND3	move.l	a6,-(sp)
			lea	mp2_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	ref_ikind_taglist2(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
ref_ikind_taglist2	dc.l	gtin_number
ref_ikind_data2		dc.l	0
			dc.l	tag_done
;-----------------------------------------------------	Integer-Gadget refresh
; -->d0=Gadget-Nr
; -->ref_ikind_data	neu setzen!
; das gleiche nochmal nur für window 2
Refresh_INTEGER_KIND2	move.l	a6,-(sp)
			lea	mpwave_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	ref_ikind_taglist2(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
;------------------------------------------------------------------------
; -->d0=Gadget-Nr.
; -->rog_taglist+4	neu setzen!
Refresh_NUMBER_KIND	move.l	a6,-(sp)
			lea	mp_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	rog_taglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
rog_TAGlist		dc.l	gtnm_number,0
			dc.l	TAG_DONE
;------------------------------------------------------------------------
; -->d0=Gadget-Nr.
; -->rog_taglist+4	neu setzen!
Refresh_NUMBER_KIND3	move.l	a6,-(sp)
			lea	mp2_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window2ptr(a5),a1
			sub.l	a2,a2
			lea	rog_taglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
;------------------------------------------------------------------------
; -->d0=Gadget-Nr.
; -->rog_taglist+4	neu setzen!
Refresh_NUMBER_KIND2	move.l	a6,-(sp)
			lea	mpwave_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	windowptrwave(a5),a1
			sub.l	a2,a2
			lea	rog_taglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
;------------------------------------------------------------------------
; in:	d0=gadget-nr
;	rog_texttaglist+4 auf stringadr setzen
Refresh_TEXT_KIND	move.l	a6,-(sp)
			lea	mp_gadgetptrs,a0
			add	d0,d0
			add	d0,d0
			move.l	(a0,d0.l),a0
			move.l	window1ptr(a5),a1
			sub.l	a2,a2
			lea	rog_texttaglist(pc),a3
			move.l	gadtoolsbase(a5),a6
			jsr	gadtools_gt_setgadgetattrsA(a6)
			move.l	(sp)+,a6
			rts
rog_textTAGlist		dc.l	gttx_text,txt_actvolume
			dc.l	TAG_DONE
;------------------------------------------------------------------------
Refresh_max		moveq	#gad_max,d0
			clr.l	ref_ikind_data
			move.l	aon_data+aon_statdata,a0
			move.b	aon.songinfo_maxpos(a0),ref_ikind_data+3
			bra.w	refresh_integer_kind
;------------------------------------------------------------------------
Refresh_res		moveq	#gad_res,d0
			clr.l	ref_ikind_data
			move.l	aon_data+aon_statdata,a0
			move.b	aon.songinfo_respos(a0),ref_ikind_data+3
			bra	refresh_integer_kind
;------------------------------------------------------------------------
Refreshgadgets		move.l	a6,-(sp)
			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a1
			move.l	gadgetlist(a5),a0
			sub.l	a2,a2
			moveq	#-1,d0
			jsr	int_refreshGlist(a6)
			move.l	(sp)+,a6
			rts
;------------------------------------------------------------------------
; a0=Zeiger auf Dirname
; a1=Zeiger auf Filename
; <-- a2=Zeiger auf IO_Filename
MAKEFILENAME
			lea	ioFilename,a2
			move.l	a2,-(sp)
			tst.b	(a0)
			beq.s	mfn_lfnloop
mfn_loop		tst.b	(a0)
			beq.s	mfn_linkfilename
			move.b	(a0)+,(a2)+
			bra.b	mfn_loop
mfn_linkfilename	cmp.b	#":",-1(a0)
			beq.s	mfn_lfnloop
			move.b	#"/",(a2)+
mfn_lfnLoop		move.b	(a1)+,(a2)+
			tst.b	-1(a1)
			bne.s	mfn_lfnLoop
			move.l	(sp)+,a2
			rts
; -----------------------------------------------------------------------
ChecK_MEM
			subq.b	#1,update_memcntdn(a5)
			and.b	#15,update_memcntdn(a5)
			beq.b	update_mem_now
			rts
update_mem_now
			move.l	$4,a6
			moveq	#memf_chip,d1
			jsr	exec_availmem(a6)
			move.l	d0,free_chipmem(a5)
			moveq	#memf_fast,d1
			jsr	exec_availmem(a6)
			move.l	d0,free_fastmem(a5)
			add.l	free_chipmem(a5),d0
			move.l	d0,free_publicmem(a5)

			cmp.l	last_free_publicmem(a5),d0
			beq	cm_nopubmemrefresh
			move.l	d0,last_free_publicmem(a5)
			lea	cm_publicasc+2,a0
			bsr	integertoascii7
cm_nopubmemrefresh
			move.l	free_fastmem(a5),d0
			cmp.l	last_free_fastmem(a5),d0
			beq.b	cm_nofastmemrefresh
			move.l	d0,last_free_fastmem(a5)
			lea	cm_fastasc+2,a0
			bsr	integertoascii7
cm_nofastmemrefresh

			move.l	free_chipmem(a5),d0
			cmp.l	last_free_chipmem(a5),d0
			beq.s	cm_nochipmemrefresh
			move.l	d0,last_free_chipmem(a5)
			lea	cm_chipasc+2,a0
			bsr	integertoascii7
cm_nochipmemrefresh

			move.l	aon_data+aon_posdata,a0
			moveq	#128-1,d7
			moveq	#0,d1			; Cnt für maxpat.
cm_searchmaxpos		move.b	(a0)+,d0
			cmp.b	d0,d1
			bhi.s	cm_findmaxNOT
			move.b	d0,d1
cm_findmaxnot		dbf	d7,cm_searchmaxpos

			addq.b	#1,d1
			moveq	#10,d2
			lsl.l	d2,d1
			
			move.l	d1,-(sp)
			cmp.l	last_songmem(a5),d1
			beq.s	cm_nosongmemrefresh
			move.l	d1,last_songmem(a5)
			move.l	d1,d0
			lea	cm_songasc+2,a0
			bsr	integertoascii7
cm_nosongmemrefresh

			moveq	#0,d1
			lea	module_wavelenlist,a0		; WLEN start
			move.l	(a0)+,d1
			REPT	64-1
			add.l	(a0)+,d1
			ENDR
			move.l	d1,-(sp)
			cmp.l	last_wavemem(a5),d1
			beq.s	cm_nowavememRefresh
			move.l	d1,last_wavemem(a5)
			move.l	d1,d0
			lea	cm_waveasc+2,a0
			bsr	integertoascii7
cm_nowavememRefresh

			move.l	(sp)+,d1
			add.l	(sp)+,d1
			cmp.l	last_modulemem(a5),d1
			beq.s	cm_nomodulememrefresh
			move.l	d1,last_modulemem(a5)
			move.l	d1,d0
			lea	cm_moduleasc+2,a0
			bsr	integertoascii7
cm_nomodulememrefresh
			tst.b	markingblock(a5)
			bne.b	.cancel

			move.l	intbase(a5),a6
			move.l	window1ptr(a5),a0
			move.l	#window1title,$20(a0)
			move.l	$3e(a0),d7	; gadgets sollen nicht mit
			clr.l	$3e(a0)		; refresht werden
			move.l	a0,d6
			jsr	int_refreshwindowframe(a6)
			move.l	d6,a0
			move.l	d7,$3e(a0)	; zeiger auf 1st gadget zurück
.cancel			rts
; -----------------------------------------------------------------------
;  ##### ###### #####      ##  ##
;    #   #    #   #        ##  ##
;    #   #    #   #      
;  ##### #    #   #   ##   ##  ##

; -----------------------------------------------------------------------
INIT_mainpanelscreen
;	lea	txt_mainpanel,a0
;			moveq	#0,d2
;			move	#12*82,d3
;			move	#8*82,d4		; Step
;			bsr	printmainscreenfx
			rts
; -----------------------------------------------------------------------
; initalize the module................. (clear it!)
INIT_MODULE
			bsr	init_song
			bsr	init_instruments
			bra	freewaves
;------------------------------------------------------------------------
init_song		movem.l	d0-d7/a0-a6,-(sp)

			clr.b	replaystatus+main_data

			lea	module_songname,a0
			moveq	#16-1,d7
initm_clrsongname	clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,initm_clrsongname
			lea	module_songauthor,a0
			moveq	#16-1,d7
initm_clrsongauthor	clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,initm_clrsongauthor
			lea	module_songdate,a0
			moveq	#16-1,d7
initm_clrsongdate	clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,initm_clrsongdate
			lea	module_songinfo,a0
			move.b	#$34,aon.songinfo_mfver(a0)
			move.b	#$1,aon.songinfo_maxpos(a0)
			clr	aon.songinfo_respos(a0)	+ 1 fillbyte
			lea	module_arptab,a0
			moveq	#0,d7
			REPT	16
			move.l	d7,(a0)+
			ENDR
			lea	module_postab,a0
			moveq	#16-1,d7
initm_clrpostab		clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,initm_clrpostab
			lea	module_patterns,a0
			move	#(128*64)-1,d7
initm_clrpatterns	clr.l	(a0)+
			clr.l	(a0)+	; 4 channels
			clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,initm_clrpatterns

			movem.l	(sp)+,d0-d7/a0-a6
			rts
; -----------------------------------------------------------------------
FreeWaves		movem.l	a1/a4/a6,-(sp)
			move.l	exec,a6		; Alle allokierten
			lea	aon_wavestarts+aon_data,a4
			moveq	#64-1,d7	; wellenformen
im_freeWaves		move.l	(a4)+,a1	; wieder freigeben
			cmp.l	#0,a1		; Nicht benutzte
			beq.s	im_skipwave	; Überspringen
			jsr	exec_freevec(a6)
			clr.l	-4(a4)		; waveptr löschen
im_skipwave		dbf	d7,im_freewaves
			lea	module_wavelenlist,a4
			moveq	#64/4-1,d7
.clrwavelens		clr.l	(a4)+
			clr.l	(a4)+
			clr.l	(a4)+
			clr.l	(a4)+
			dbf	d7,.clrwavelens
			movem.l	(sp)+,a1/a4/a6
			rts
; -----------------------------------------------------------------------
; d0=Nr der wellenform, dessen speicher freigegeben werden soll
FreeWave:		movem.l	d0-a6,-(sp)
			move.l	exec,a6		; Alle allokierten
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a4
			add	d0,d0
			add	d0,d0
			lea	(a4,d0),a4
			clr.l	(a3,d0)		; wavesize löschen
			move.l	(a4),a1	; wieder freigeben
			cmp.l	#0,a1		; Nicht benutzte
			beq.b	.skipwave	; Überspringen
			jsr	exec_freevec(a6)
			clr.l	(a4)		; waveptr löschen
.skipwave		movem.l	(sp)+,d0-a6
			rts
; -----------------------------------------------------------------------
; in:	d0=Nr der wellenform, (muß leer sein!!)
; 	d1=wavelen in bytes
; out:	d0=waveadr (oder null, falls kein speicher mehr frei war)
AllocWave:		movem.l	d1-a6,-(sp)
			move.l	exec,a6		; Alle allokierten
			lea	module_wavelenlist,a3
			lea	aon_wavestarts+aon_data,a4
			add	d0,d0
			add	d0,d0
			lea	(a3,d0),a3
			lea	(a4,d0),a4
			tst.l	(a3)		; wavesize löschen
			bne.b	.skipwave	; wave nicht leer ?!?!
			move.l	d1,d0
			move.l	d0,d7
			tst.b	chmode(a5)
			beq.b	.4ch
			move.l	#$10001,d1
			bra.b	.8ch
.4ch			move.l	#$10002,d1
.8ch
			jsr	exec_allocvec(a6)
			tst.l	d0		; kein speicher?!
			beq.b	.skipwave
			move.l	d0,(a4)
			move.l	d7,(a3)
			bra.b	.waveallocated
.skipwave		moveq	#0,d0
.waveallocated		movem.l	(sp)+,d1-a6
			rts
;--------------------------------------------------------------------
; out:	d1=nr. der freien waveform oder -1 falls keine mehr frei war!
SearchFreeWave:
			movem.l	d7/a0,-(sp)
			moveq	#0,d1			; freie wave suchen
			moveq	#64-1,d7
			lea	module_wavelenlist,a0
.search			tst.l	(a0)+
			beq.b	.found
			addq.b	#1,d1
			dbf	d7,.search
			moveq	#-1,d1
.found			movem.l	(sp)+,d7/a0
			rts
;_-------------------------------------------------------------------
init_instruments	lea	module_instruments,a0
			lea	module_instrnames,a1
			moveq	#61-1,d7
			moveq	#0,d1
			moveq	#0,d0
.loop			move.l	d0,(a0)
			move.b	d1,3(a0)	; wavenr
			move.l	d0,4(a0)
			move.l	d0,8(a0)
			move.l	d0,12(a0)
			move.l	d0,16(a0)
			move.l	d0,20(a0)
			move.l	d0,24(a0)
			move.l	d0,28(a0)
			move.l	d0,(a1)
			move.l	d0,4(a1)
			move.l	d0,8(a1)
			move.l	d0,12(a1)
			move.l	d0,16(a1)
			move.l	d0,20(a1)
			move.l	d0,24(a1)
			move.l	d0,28(a1)
			addq.b	#1,d1
			lea	32(a0),a0
			lea	32(a1),a1
			dbf	d7,.loop
			rts
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; ##### ##  # ##### ##### ##### ##### #####     ##### ##### ##### ##### #####
;   #   # # #   #   #     #     #     #   #     #   # ##    #       #     #
;   #   # # #   #   ###   #   # ###   ####  ### #####   ### #       #     #
; ##### #  ##   #   ##### ##### ##### #   #     #   # ##### ##### ##### #####
;                             #

; -----------------------------------------------------------------------
; ---> d0= Value
; ---> a0= Ptr on ascii-string
; uses the fastInt2Asc tab to speed up the routine a LITTLE bit (!!)
integerTOascii7
			and.l	#$0ffffff,d0
			beq	ita7_allzero

			cmp.l	#1024*1024,d0
			blt.b	.bytedisp

			moveq	#10,d1
			lsr.l	d1,d0
			bsr	integertoAscii6
			move.b	#"k",6(a0)
			rts
.bytedisp
			move.l	a1,-(sp)
			lea	txt_3charsnrs,a1
			divu	#10000,d0	; e.g d0=7654321
			moveq	#0,d1		; d0=765
			move	d0,d1
			add	d1,d1
			add	d1,d1
			move.b	0(a1,d1),0(a0)
			move.b	1(a1,d1),1(a0)
			move.b	2(a1,d1),2(a0)
			clr	d0
			swap	d0		; d0=rest=4321
			beq.s	ita7_zero1
			divu	#10,d0
ita7_zero1		move	d0,d1		; d0=432
			add	d1,d1
			add	d1,d1
			move.b	0(a1,d1),3(a0)
			move.b	1(a1,d1),4(a0)
			move.b	2(a1,d1),5(a0)
			clr	d0
			swap	d0		; d0=rest=1
			add.b	#"0",d0
			move.b	d0,6(a0)
			move.l	(sp)+,a1
			rts
;----------------------------------------------------
ita7_allzero		move.b	#"0",6(a0)
ita6_allzero		move.b	#"0",5(a0)
			move.b	#"0",4(a0)
			move.b	#"0",3(a0)
			move.b	#"0",2(a0)	; a0 isn't odd !
ita2_allzero		move.b	#"0",1(a0)	; you can never know if
			move.b	#"0",0(a0)	; Only .b size used because
			rts
;----------------------------------------------------
integerTOascii6
			and.l	#$0ffffff,d0
			beq	ita6_allzero
			move.l	a1,-(sp)
			lea	txt_3charsnrs,a1
			divu	#1000,d0	; e.g d0=654321
			moveq	#0,d1		; d0=654
			move	d0,d1
			add	d1,d1
			add	d1,d1
			move.b	0(a1,d1),0(a0)
			move.b	1(a1,d1),1(a0)
			move.b	2(a1,d1),2(a0)
			clr	d0
			swap	d0		; d0=rest=321
			add	d0,d0
			add	d0,d0
			move.b	0(a1,d0),3(a0)
			move.b	1(a1,d0),4(a0)
			move.b	2(a1,d0),5(a0)
			move.l	(sp)+,a1
			rts
;----------------------------------------------------
integerTOascii2		and.l	#$ff,d0
			beq	ita2_allzero
			move.l	a1,-(sp)
			lea	txt_2charsnrs,a1
			add.b	d0,d0
			add	d0,d0
			move.b	0(a1,d0),0(a0)
			move.b	1(a1,d0),1(a0)
			move.l	(sp)+,a1
			rts
;----------------------------------------------------
hexTOascii2		and.l	#$ff,d0
			beq	ita2_allzero
			movem.l	d1/a1,-(sp)
			lea	txt_hexchars,a1
			move	d0,d1
			and.b	#$f,d1
			move.b	(a1,d1),1(a0)
			lsr	#4,d0
			move.b	(a1,d0),0(a0)
			movem.l	(sp)+,d1/a1
			rts
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; 			##### ##### #   # ##### #####
; 			# # # #   # #   # ##    #
; 			# # # #   # #   #   ### ###
; 			# # # ##### ##### ##### #####
;
;------------------------------------------------------------------------
ADJUST_PATTDISPLAY:

			tst	patdspVIEW(a5)
			beq.b	.noview

			tst	freezedsp(a5)
			beq.b	.oknotfreezed
.noview			rts
.oknotfreezed:
			clr	patdspVIEW(a5)

			cmp	#400,win1h
			beq.b	.euro
			bsr	adjust_cursorXpal
			bra.b	.pal
.euro			bsr	adjust_cursorXeuro72
.pal
;
;			tst	patalertflag(a5)
;			bne.b	adjust_pattdisplayNOW
;
;			move	oldpatcnt2(a5),d0
;			cmp	aon_data+aon_patcnt,d0
;			bne.b	ADJUST_PATTDISPLAYNOW
;			rts
ADJUST_PATTDISPLAyNOW
			tst	freezedsp(a5)
			beq.b	.oknotfreezed
			rts
.oknotfreezed:
			btst	#2,$dff016
			beq.b	.menupick
			tst.b	itt_adpd_flag(a5)	; Keine intuiticks?
			bne.b	adpd_cumonJerk
.menupick
.blitsplit		rts

adpd_cumonjerk
;			clr	patalertflag(a5)


adpd_doblitsplit	
			move.l	#bpl_patterns,d0
			moveq	#0,d1
			tst.b	replaystatus(a5)
			beq.b	.takeeditstep
			move.b	disppatcnt(a5),d1
			bra.b	.takeplaystep
.takeeditstep		move.b	aon_data+aon_patcnt+1,d1
.takeplaystep
			move	d1,oldpatcnt2(a5)

			cmp	#400,win1h
			bne.b	.pal
			mulu	#8*80/2,d1
			bra.b	.euro
.pal			mulu	#8*80/4,d1	; patcnt ist *4!!!
.euro			add.l	d1,d0

			move.l	bitplane1_startadr(a5),d1
			add.l	#(patbploff-1)*80,d1
; d0=bpladr
; d1=adr in viewplane
			move.l	d0,a0
			move.l	d1,a1
			cmp	#400,win1h
			beq.b	.euro72bl
			move	#136-1,d7
			bra.b	.wbpal
.euro72bl		move	#283-1,d7
.wbpal
			addq.l	#2,a1
			rept	19
			move.l	(a0)+,(a1)+
			endr
			addq.l	#2,a1
			addq.l	#4,a0

;			move.l	(a0)+,(a1)+	4
;			addq.l	#2,a0		2
;				addq.l	#2,a1		2
;			move.l	(a0)+,(a1)+	4
;			move.l	(a0)+,(a1)+	4
;			move.l	(a0)+,(a1)+	4
;			move.l	(a0)+,(a1)+	4
;			addq.l	#2,a0		2
;				addq.l	#2,a1		2
;	
;			rept	14
;			move.l	(a0)+,(a1)+	52
;			endr
;
;;		lea	80-26(a0),a0
;;		lea	80-26(a1),a1
;			rept	20
;			move.l	(a0)+,(a1)+	52
;			endr

			dbf	d7,.wbpal
			rts

adjust_cursorXpal
			btst	#2,$dff016
			beq.b	.menupick
			tst.b	itt_adpd_flag(a5)	; Keine intuiticks?
			bne.b	.doit
.menupick
			rts
.doit
			tst.b	chmode(a5)
			beq.w	.4ch
			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions8,a1	;24entries,.b size
			moveq	#-1,d0
			moveq	#0,d1
			move.b	oldpatcntx(a5),d1
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			clr.b	-80(a0)
			REPT	8-1
			move.b	d0,(a0)
			lea	80(a0),a0
			ENDR
			move.b	d0,(a0)
			clr.b	80(a0)

			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions8,a1	;24entries,.b size
			moveq	#0,d0
			moveq	#0,d1
			move.b	patcntx(a5),d1
			move.b	d1,oldpatcntx(a5)
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			move.b	#-1,-80(a0)
			REPT	8-1
			move.b	d0,(a0)
			lea	80(a0),a0
			ENDR
			move.b	d0,(a0)
			move.b	#-1,80(a0)
			bra.w	.8ch
.4ch
			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions,a1	;24entries,.b size
			moveq	#-1,d0
			moveq	#0,d1
			move.b	oldpatcntx(a5),d1
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			clr	-80(a0)
			REPT	8-1
			move	d0,(a0)
			lea	80(a0),a0
			ENDR
			move	d0,(a0)
			clr	80(a0)

			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions,a1	;24entries,.b size
			moveq	#0,d0
			moveq	#0,d1
			move.b	patcntx(a5),d1
			move.b	d1,oldpatcntx(a5)
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			move	#-1,-80(a0)
			REPT	8-1
			move	d0,(a0)
			lea	80(a0),a0
			ENDR
			move	d0,(a0)
			move	#-1,80(a0)

.8ch			rts

adjust_cursorXeuro72
			btst	#2,$dff016
			beq.b	.menupick
			tst.b	itt_adpd_flag(a5)	; Keine intuiticks?
			bne.b	.doit
.menupick
			rts
.doit
			tst.b	chmode(a5)
			beq.w	.4ch
			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions8,a1	;24entries,.b size
			moveq	#-1,d0
			moveq	#0,d1
			move.b	oldpatcntx(a5),d1
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			clr.b	-160(a0)
			clr.b	-80(a0)
			REPT	16-1
			move.b	d0,(a0)
			lea	80(a0),a0
			ENDR
			move.b	d0,(a0)
			clr.b	80(a0)
			clr.b	160(a0)

			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions8,a1	;24entries,.b size
			moveq	#0,d0
			moveq	#0,d1
			move.b	patcntx(a5),d1
			move.b	d1,oldpatcntx(a5)
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			move.b	#-1,-160(a0)
			move.b	#-1,-80(a0)
			REPT	16-1
			move.b	d0,(a0)
			lea	80(a0),a0
			ENDR
			move.b	d0,(a0)
			move.b	#-1,80(a0)
			move.b	#-1,160(a0)
			bra.w	.8ch
.4ch
			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions,a1	;24entries,.b size
			moveq	#-1,d0
			moveq	#0,d1
			move.b	oldpatcntx(a5),d1
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			clr	-160(a0)
			clr	-80(a0)
			REPT	16-1
			move	d0,(a0)
			lea	80(a0),a0
			ENDR
			move	d0,(a0)
			clr	80(a0)
			clr	160(a0)

			move.l	bitplane2_barstartadr(a5),a0
			lea	cursorpositions,a1	;24entries,.b size
			moveq	#0,d0
			moveq	#0,d1
			move.b	patcntx(a5),d1
			move.b	d1,oldpatcntx(a5)
			lsr.b	#1,d1
			move.b	(a1,d1),d1
			addq	#2,d1
			lea	(a0,d1),a0
			move	#-1,-160(a0)
			move	#-1,-80(a0)
			REPT	16-1
			move	d0,(a0)
			lea	80(a0),a0
			ENDR
			move	d0,(a0)
			move	#-1,80(a0)
			move	#-1,160(a0)

.8ch			rts
; -----------------------------------------------------------------------
;adpd_RealAdjust:
;			rts

;			movem.l	d0-a6,-(sp)
;			move.l	bitplane1_startadr(a5),d0
;			add.l	#patbploff*80,d0
;			move.l	d0,a1
;
;			move.l	#bpl_patterns,d0
;			moveq	#0,d1
;			move.b	aon_data+aon_patcnt+1,d1
;			cmp	#400,win1h
;			beq.b	.euro
;			mulu	#8*80/4,d1	; patcnt ist *4!!!
;			add.l	d1,d0
;			move.l	d0,a0
;
;			move	#136-1,d7
;.raLoop			REPT	20
;			move.l	(a0)+,(a1)+
;			ENDR
;			dbf	d7,.raloop
;			movem.l	(sp)+,d0-a6
;			rts
;.euro			mulu	#8*80/2,d1	; patcnt ist *4!!!
;			add.l	d1,d0
;			move.l	d0,a0
;
;			move	#(136*2)+11-1,d7
;.raLoop2		REPT	20
;			move.l	(a0)+,(a1)+
;			ENDR
;			dbf	d7,.raloop2
;			movem.l	(sp)+,d0-a6
			rts
; -----------------------------------------------------------------------
; 		#####  ###  #   #  ###  #     ##### ##### ##### ####
; 		Ż#ŻŻŻ #ŻŻŻ# #   # #ŻŻŻ# #     ŻŻ#ŻŻ ŻŻŻ#Ż Ż#ŻŻŻ #ŻŻŻ#
; 		 Ż### #   # #   # ##### #       #    ###   Ż### ####Ż
; 		 #ŻŻŻ # # # #   # #ŻŻŻ# #   #   #    #ŻŻ   #ŻŻŻ #ŻŻ#
; 		##### Ż#### Ż###Ż #   # ##### ##### ##### ##### #  Ż#
;		ŻŻŻŻŻ  ŻŻŻŻ  ŻŻŻ  Ż   Ż ŻŻŻŻŻ ŻŻŻŻŻ ŻŻŻŻŻ ŻŻŻŻŻ Ż   Ż
EQUALIZER_UPDATE
			move.l	bitplane2_startadr(a5),a2
			moveq	#80,d0
			cmp	#400,win1h
			beq.b	.euro
			mulu	#115,d0
			bra.b	.pal
.euro			mulu	#179,d0
.pal			lea	10(a2,d0.l),a2
			
			moveq	#0,d5
			lea	equ_data,a3
			lea	aon_channels,a4
			lea	equalizer_dodideldum(pc),a1
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
;----------------------------------------------------
equalizer_dodideldum
			btst	#10,$dff016		; Bei menupick kein
			beq	equ_normalout		; equalizer

			tst.b	screen(a5)
			bne.b	.quad

			tst.b	replaystatus(a5)	; KEIN REplay?!
			beq	equ_notyetinitalized	; kein equalizer!
.quad
			cmp.l	#2,equ_wavelen(a3)
			beq	equ_notyetinitalized2
			cmp.l	#128,equ_wavelen(a3)
			bhi.b	equ_nochipsound

			move.l	equ_wavelen(a3),d7
			beq	equ_notyetinitalized
			move.l	d7,d6
			move.l	equ_actwaveptr(a3),a0
			moveq	#0,d0
			moveq	#0,d1
equ_calcChipVol		move.b	(a0)+,d0
			add.l	d0,d1
			dbf	d7,equ_calcChipVol
			divu	d6,d1
			and.l	#$ff,d1
			bra.b	equ_storewavebyte

equ_nochipsound
			moveq	#0,d2
			move.l	hzticks(a5),d1	;#52980,d1
			move	equ_actper(a3),d2
			beq	equ_notyetinitalized
			divu	d2,d1
			swap	d1
			clr	d1			; clear rest
			swap	d1
; d1=Bytes to add each frame
			move.l	equ_actwaveptr(a3),a0
			move.l	equ_actwaveoff(a3),d0
			add.l	d1,d0			; + FrameAdd
			move.l	equ_wavelen(a3),d2	; wordsize
			cmp.l	d0,d2			; restart wave?!?!
			bhi.s	equalizer_withinRange
			move.l	aon_repeatstrt(a4),a0
			move.l	a0,equ_actwaveptr(a3)
			moveq	#0,d0
			move	aon_replen(a4),d0
			add.l	d0,d0
			move.l	d0,equ_wavelen(a3)
			moveq	#0,d0
equalizer_withinrange
			lea	(a0,d0.l),a0
			move.l	d0,equ_actwaveoff(a3)

			moveq	#0,d0
			moveq	#0,d1
			moveq	#16-1,d7
equalizer_compAverage	move.b	(a0)+,d0
			bpl.s	equ_compVolnotNeg
			neg.b	d0
equ_compvolnotneg	cmp.b	d0,d1
			bgt.s	equ_compvolNotBigger
			move.b	d0,d1
equ_compvolNotBigger	dbf	d7,equalizer_compaverage
equ_storewavebyte	move.b	d1,equ_actbyte(a3)
; Equalizer zeichnen!
equ_drawequNOW
			btst	d5,ch_enable(a5)
			bne.b	equ_chenabled
			moveq	#0,d1
			bra.b	equ_chdisabled

equ_chenabled		moveq	#0,d0
			move.b	equ_actvolume(a3),d0

			mulu	d0,d1
			lsr	#7,d1

equ_chdisabled
			tst.b	itt_adpd_flag(a5)
			beq.b	equ_normalout

			moveq	#64-1,d2
			sub	d1,d2
			bmi	equ_normalout	; sonst evtl. absturz!!!!
			move.l	a2,a0
			moveq	#0,d0
equ_fillwithZero	move	d0,(a0)
			lea	80(a0),a0
			dbf	d2,equ_fillwithzero
			moveq	#-1,d0
equ_drawBytes		move	d0,(a0)
			lea	80(a0),a0
			dbf	d1,equ_drawbytes

equ_normalout
			addq.b	#1,d5
			lea	18(a2),a2
			lea	equ_datasize(a3),a3
			lea	aon_chdatasize(a4),a4
			rts
equ_notyetinitalized2
			clr.b	equ_actvolume(a3)
equ_notyetinitalized
			clr.b	equ_actbyte(a3)
			tst.b	itt_adpd_flag(a5)
			beq.b	equ_normalout
			move.l	a2,a0
			moveq	#16-1,d1
			moveq	#0,d0
equ_clrONEch		move	d0,(a0)
			move	d0,80(a0)
			move	d0,160(a0)
			move	d0,240(a0)
			lea	320(a0),a0
			dbf	d1,equ_clronech
			bra.b	equ_normalout
;----------------------------------------------------
equ_resetchannels
			move.l	a0,-(sp)
			lea	equ_data,a0
			REPT	(16/4)*4
			clr.l	(a0)+
			ENDR
			jsr	aon_end
			lea	aon_channels,a0

			tst.b	chmode(a5)
			beq.w	.not

			moveq	#8-1,d7
.loop8			clr.l	aon_waveform(a0)
			clr	aon_wavelen(a0)
			clr	aon_oldwavelen(a0)
			clr.l	aon_repeatstrt(a0)
			clr	aon_replen(a0)
			clr.l	aon_instrptr(a0)
			clr.b	aon_volume(a0)
			clr	aon_perslide(a0)
			clr	aon_period(a0)
			clr.l	aon_synthWAVErepptr(a0)
			clr.l	aon_synthWAVErependptr(a0)
			clr.l	aon_synthWAVEactptr(a0)
			clr.l	aon_synthWAVEendptr(a0)
			clr.b	aon_synthWAVErepctrl(a0)
			clr.b	aon_synthWAVEspd(a0)
			clr.b	aon_synthWAVEcnt(a0)
			clr.b	aon_synthWAVESTOP(a0)
			lea	aon_chdatasize(a0),a0
			dbf	d7,.loop8

			lea	mix_data,a0
			move	#8*mix_datasize-1,d7
.loop8mix		clr.b	(a0)+
			dbf	d7,.loop8mix

			lea	mix_buff1data,a0
			move	#(128)-1,d7
.clr8chbuf		clr.l	(a0)+
			clr.l	(a0)+
			dbf	d7,.clr8chbuf



.exit			move.l	(sp)+,a0
			rts
.not
			moveq	#4-1,d7
.loop4			clr.l	aon_waveform(a0)
			clr	aon_wavelen(a0)
			clr	aon_oldwavelen(a0)
			clr.l	aon_repeatstrt(a0)
			clr	aon_replen(a0)
			clr.l	aon_instrptr(a0)
			clr.b	aon_volume(a0)
			clr	aon_perslide(a0)
;	clr	aon_period(a0)
			clr.l	aon_synthWAVErepptr(a0)
			clr.l	aon_synthWAVErependptr(a0)
			clr.l	aon_synthWAVEactptr(a0)
			clr.l	aon_synthWAVEendptr(a0)
			clr.b	aon_synthWAVErepctrl(a0)
			clr.b	aon_synthWAVEspd(a0)
			clr.b	aon_synthWAVEcnt(a0)
			clr.b	aon_synthWAVESTOP(a0)
			lea	aon_chdatasize(a0),a0
			dbf	d7,.loop4
			move.l	(sp)+,a0
			rts
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
INIT_PATTERNDISPLAY	bsr	clr_patternscreen

;			lea	txt_pattinit,a0
;			moveq	#0,d2
;			move	#(9*7*42)+(42*1),d3
;			move	#8*42,d4
;			jmp	printpattscreen
			rts

; -----------------------------------------------------------------------
clr_patternscreen
			lea	bpl_patterns,a0
			cmp	#400,win1h
			beq.b	.euro
			move	#(640*20)-1,d7
.loop			clr.l	(a0)+
			dbf	d7,.loop
			rts
.euro			move	#(640*40)-1,d7
.loop2			clr.l	(a0)+
			dbf	d7,.loop2
			rts
; -----------------------------------------------------------------------
;------------------------------------------------------------------------
PRINTDSEQSCREEN4:	movem.l	d2/d3/a0-a4,-(sp)
			move.l	bitplane2_startadr(a5),a2
			lea	40*80+28(a2),a2
			lea	gfx_numbers,a1
			bra.b	pnf_mainloop2
PRINTDSEQSCREEN3:	movem.l	d2/d3/a0-a4,-(sp)
			move.l	bitplane1_startadr(a5),a2
			lea	40*80+28(a2),a2
			lea	gfx_numbers,a1
			bra.b	pnf_mainloop2
PRINTDSEQSCREEN2:	movem.l	d2/d3/a0-a4,-(sp)
			move.l	bitplane2_startadr(a5),a2
			lea	15*80+28(a2),a2
			lea	gfx_numbers,a1
			bra.b	pnf_mainloop2
PRINTDSEQSCREEN:	movem.l	d2/d3/a0-a4,-(sp)
			move.l	bitplane1_startadr(a5),a2
			lea	14*80+1(a2),a2
			lea	gfx_numbers,a1
pnf_mainloop2		moveq	#0,d0
			move.b	(a0)+,d0
			bne.s	.notskipline2
			moveq	#0,d2
			add	d4,d3
			bra.b	pnf_mainloop2
.notskipline2		cmp.b	#1,d0
			beq.s	.exitrout2
			cmp.b	#"-",d0
			bne.b	.notspace
			move.b	#16,d0
			bra.b	.nothex
.notspace
			sub.b	#48,d0
			bmi.b	.skip
			move	d0,d1
			sub.b	#65-48,d1
			bmi.b	.nothex
			add.b	#10,d1
			move	d1,d0
.nothex			lea	(a1,d0.l),a3
			lea	(a2,d2.l),a4
			lea	(a4,d3.l),a4
			move.b	0*17(a3),0*80(a4)
			move.b	1*17(a3),1*80(a4)
			move.b	2*17(a3),2*80(a4)
			move.b	3*17(a3),3*80(a4)
			move.b	4*17(a3),4*80(a4)
			move.b	5*17(a3),5*80(a4)
			move.b	6*17(a3),6*80(a4)
			clr.b	7*80(a4)
.skip			addq	#1,d2
			bra.b	pnf_mainloop2
.exitrout2		movem.l	(sp)+,d2/d3/a0-a4
			rts




PRINTPOSSCREEN:		movem.l	d2/d3/a0-a4,-(sp)
			move.l	bitplane1_startadr(a5),a2
			lea	26*80+62(a2),a2
			lea	gfx_font,a1
			bra.b	pms_mainloop2
PRINTPATTSCREEN:	cmp.l	#euro72_productivity,screenmode
			beq.w	printpattscreen72
			movem.l	d2/d3/a0-a4,-(sp)
			lea	bpl_patterns,a2
			lea	gfx_font,a1
pms_mainloop2		moveq	#0,d0
			move.b	(a0)+,d0
			bne.s	pms_notskipline2
			moveq	#0,d2
			add	d4,d3
			bra.b	pms_mainloop2
pms_notskipline2	cmp.b	#1,d0
			beq.s	pms_exitrout2
			sub.b	#32,d0
			add	d0,d0
			lea	(a1,d0.l),a3
			lea	(a2,d2.l),a4
			lea	(a4,d3.l),a4

			move.b	0*480(a3),0*80(a4)
			move.b	0*480+1(a3),0*80+1(a4)
			move.b	1*480(a3),1*80(a4)
			move.b	1*480+1(a3),1*80+1(a4)
			move.b	2*480(a3),2*80(a4)
			move.b	2*480+1(a3),2*80+1(a4)
			move.b	3*480(a3),3*80(a4)
			move.b	3*480+1(a3),3*80+1(a4)
			move.b	4*480(a3),4*80(a4)
			move.b	4*480+1(a3),4*80+1(a4)
			move.b	5*480(a3),5*80(a4)
			move.b	5*480+1(a3),5*80+1(a4)
			move.b	6*480(a3),6*80(a4)
			move.b	6*480+1(a3),6*80+1(a4)
			clr.b	7*80(a4)
			clr.b	7*80+1(a4)

;	move	0*480(a3),0*80(a4)
;	move	1*480(a3),1*80(a4)
;	move	2*480(a3),2*80(a4)
;	move	3*480(a3),3*80(a4)
;	move	4*480(a3),4*80(a4)
;	move	5*480(a3),5*80(a4)
;	move	6*480(a3),6*80(a4)
;	clr	7*80(a4)

			addq	#2,d2
			bra.w	pms_mainloop2
pms_exitrout2		movem.l	(sp)+,d2/d3/a0-a4
			rts
PRINTPATTSCREEN72:	movem.l	d2/d3/a0-a4,-(sp)
			lea	bpl_patterns,a2
			lea	gfx_font,a1
.mainloop2		moveq	#0,d0
			move.b	(a0)+,d0
			bne.s	.notskipline2
			moveq	#0,d2
			add	d4,d3
			bra.b	.mainloop2
.notskipline2		cmp.b	#1,d0
			beq.s	.exitrout2
			sub.b	#32,d0
			add	d0,d0
			lea	(a1,d0.l),a3
			lea	(a2,d2.l),a4
			move.l	d3,d0
			add.l	d0,d0
			lea	(a4,d0.l),a4
			move	0*480(a3),0*80(a4)
			move	0*480(a3),1*80(a4)
			move	1*480(a3),2*80(a4)
			move	1*480(a3),3*80(a4)
			move	2*480(a3),4*80(a4)
			move	2*480(a3),5*80(a4)
			move	3*480(a3),6*80(a4)
			move	3*480(a3),7*80(a4)
			move	4*480(a3),8*80(a4)
			move	4*480(a3),9*80(a4)
			move	5*480(a3),10*80(a4)
			move	5*480(a3),11*80(a4)
			move	6*480(a3),12*80(a4)
			move	6*480(a3),13*80(a4)
			clr	14*80(a4)
			clr	15*80(a4)
			addq	#2,d2
			bra.w	.mainloop2
.exitrout2		movem.l	(sp)+,d2/d3/a0-a4
			rts
PRINTPATTSCREENHI:	cmp	#400,win1h
			beq.b	printpattscreenhi72
			movem.l	d2/d3/a0-a4,-(sp)
			lea	bpl_patterns,a2
			lea	gfx_fontHI,a1
.mainloop2		moveq	#0,d0
			move.b	(a0)+,d0
			bne.s	.notskipline2
			moveq	#0,d2
			add	d4,d3
			bra.b	.mainloop2
.notskipline2		cmp.b	#1,d0
			beq.b	.exitrout2
			sub.b	#32,d0
			lea	(a1,d0.l),a3
			lea	(a2,d2.l),a4
			lea	(a4,d3.l),a4
			move.b	0*91(a3),0*80(a4)
			move.b	1*91(a3),1*80(a4)
			move.b	2*91(a3),2*80(a4)
			move.b	3*91(a3),3*80(a4)
			move.b	4*91(a3),4*80(a4)
			move.b	5*91(a3),5*80(a4)
			move.b	6*91(a3),6*80(a4)
			clr.b	7*80(a4)
			addq	#1,d2
			bra.b	.mainloop2
.exitrout2		movem.l	(sp)+,d2/d3/a0-a4
			rts
PRINTPATTSCREENHI72:	movem.l	d2/d3/a0-a4,-(sp)
			lea	bpl_patterns,a2
			lea	gfx_fontHI,a1
.mainloop2		moveq	#0,d0
			move.b	(a0)+,d0
			bne.s	.notskipline2
			moveq	#0,d2
			add	d4,d3
			bra.b	.mainloop2
.notskipline2		cmp.b	#1,d0
			beq.b	.exitrout2
			sub.b	#32,d0
			lea	(a1,d0.l),a3
			lea	(a2,d2.l),a4
			move.l	d3,d0
			add.l	d0,d0
			lea	(a4,d0.l),a4
			move.b	0*91(a3),0*80(a4)
			move.b	0*91(a3),1*80(a4)
			move.b	1*91(a3),2*80(a4)
			move.b	1*91(a3),3*80(a4)
			move.b	2*91(a3),4*80(a4)
			move.b	2*91(a3),5*80(a4)
			move.b	3*91(a3),6*80(a4)
			move.b	3*91(a3),7*80(a4)
			move.b	4*91(a3),8*80(a4)
			move.b	4*91(a3),9*80(a4)
			move.b	5*91(a3),10*80(a4)
			move.b	5*91(a3),11*80(a4)
			move.b	6*91(a3),12*80(a4)
			move.b	6*91(a3),13*80(a4)
			clr.b	14*80(a4)
			clr.b	15*80(a4)
			addq	#1,d2
			bra.w	.mainloop2
.exitrout2		movem.l	(sp)+,d2/d3/a0-a4
			rts
;------------------------------------------------------------------------
INIT_NEWPATTERNS	move.l	#8*8*80,d3
			move	#8*80,d4
			moveq	#0,d2
			lea	txt_pattinit,a0
			bra	printpattscreen
;------------------------------------------------------------------------
txt_doppelpunkt		dc.b	":",1,0,0
PRINTNEWPATTERNSSIG:

;			tst.b	stepdspreq(a5)
;			bne.b	.set
;			tst.b	pattdspreq(a5)
;			beq	pnp_setNOsig
;.set
;	move.l	exec,a6
;	move.l	userport1(a5),a3	; messyport adresse
;	moveq	#0,d0
;	move.b	mp_sigbit(a3),d0	; signalbit holen
;	beq.b	pnp_setNOsig
;	move.l	mytask(a5),a1
;	jmp	exec_signal(a6)
;pnp_setNOsig

			rts

; d0=step, der neu ausgegeben werden soll
PRINTNEWPATTERNS.step
			move	#$4000,$dff09a
			move.b	aon_data+aon_patcnt+1,d1
			move.b	d0,aon_data+aon_patcnt+1
			movem.l	d0-a6,-(sp)
			bsr	printnewpatterns
			movem.l	(sp)+,d0-a6
			move.b	d1,aon_data+aoN_patcnt+1

			tst.b	replaystatus(a5)
			bne.b	.recordison
			move.b	addstep(a5),d0
		add.b	d0,aon_patcnt+aon_data+1 xSteps aufrücken
			jsr	actmarkpos
.recordison
			move	#$c000,$dff09a
			rts
PRINTNEWPATTERNS:
			tst.b	stepdspreq(a5)
			bne.b	.printstep
			tst.b	pattdspreq(a5)
			bne.s	pnp_printsumthing
			rts
.printstep		clr.b	stepdspreq(a5)
			bra.b	pnp_printline
pnp_printsumthing	
			cmp.b	#$f,pattdspreq(a5)
			beq	pnp_allpatt

;pnp_printline
			bsr	refresh_pos
			bsr	refresh_pat
pnp_printline
			lea	aon_data,a6
			tst.b	chmode(a5)
			bne	pnp_8channels2

			lea	cursorpositions,a4
			lea	txt_notes,a2
			lea	txt_hexchars,a3
			lea	txt_instrnrs,a1

			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	aon_data+aon_patcnt+1,d0
			add	d0,d0
			add	d0,d0
			lea	(a0,d0.l),a0
			move.l	a0,a6
			moveq	#0,d2
			move.l	#8*80*8,d3
			moveq	#0,d0
			move.b	aon_data+aon_patcnt+1,d0
			mulu	#2*80,d0
			add	d0,d3

			moveq	#4-1,d5
pnp_4channels2		moveq	#0,d0
			move.b	0(a6),d0
			and.b	#63,d0
			bne.b	.nopause
			move.b	1(a6),d0	; instrumentennr.
			and.b	#63,d0
			beq.b	.pause
			lea	-4(a2),a0
			bra.b	.print
.nopause		add	d0,d0
			add	d0,d0
.pause			lea	(a2,d0),a0
.print			move.b	0(a4),d2
			bsr	printpattscreen

			lea	txt_1char,a0
			moveq	#0,d0
			move.b	1(a6),d0	; Instrumentnr	6bits
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	1(a4),d2
			bsr	printpattscreen

			moveq	#0,d0		; Arpeggio	4bits
			move.b	2(a6),d0
			lsl	#2,d0		; bits ins obere byte schieben
			move.b	1(a6),d0
			and.b	#$c0,d0
			lsr	#6,d0
			move.b	(a3,d0),(a0)
			move.b	2(a4),d2
			bsr	printpattscreen

			moveq	#0,d0
			move.b	2(a6),d0	; Effect	6bits
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	3(a4),d2
			bsr	printpattscreen

			moveq	#0,d0
			move.b	3(a6),d0
			move	d0,-(sp)
			lsr	#4,d0
			move.b	(a3,d0),(a0)
			move.b	4(a4),d2
			bsr	printpattscreen
			move	(sp)+,d0
			and	#$0f,d0
			move.b	(a3,d0),(a0)
			move.b	5(a4),d2
			bsr	printpattscreen

			addq.l	#4,a6
			addq.l	#6,a4
			dbf	d5,pnp_4channels2
pnp_4channels2EX
			tst.b	replaystatus(a5)
			bne.b	pnp_recordison
			move.b	addstep(a5),d0
		add.b	d0,aon_patcnt+aon_data+1 xSteps aufrücken
			jsr	actmarkpos
pnp_recordison
;	move	#1,patalertflag(a5)
;jsr	adjust_pattdisplayNOW
			rts


pnp_8channels2
			lea	cursorpositions8,a4
			lea	txt_notes,a2
			lea	txt_hexchars,a3
			lea	txt_instrnrs,a1

			move	acteditpattern(a5),d7
			jsr	getactpatadr	; d7=Postaboff
			moveq	#0,d0
			move.b	aon_data+aon_patcnt+1,d0
			lsl	#3,d0
;	add	d0,d0
;	add	d0,d0
			lea	(a0,d0.l),a0
			move.l	a0,a6
			moveq	#0,d2
			move.l	#8*80*8,d3
			moveq	#0,d0
			move.b	aon_data+aon_patcnt+1,d0
			mulu	#2*80,d0
			add	d0,d3

			moveq	#8-1,d5
pnp_8channels22		moveq	#0,d0
			move.b	0(a6),d0
			and.b	#63,d0
			bne.b	.nopause
			move.b	1(a6),d0	; instrumentennr.
			and.b	#63,d0
			beq.b	.pause
			lea	-4(a2),a0
			bra.b	.print
.nopause		add	d0,d0
			add	d0,d0
.pause			lea	(a2,d0),a0
.print			move.b	0(a4),d2
			bsr	printpattscreenHI

			lea	txt_1char,a0
			moveq	#0,d0
			move.b	1(a6),d0	; Instrumentnr	6bits
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	1(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0		; Arpeggio	4bits
			move.b	2(a6),d0
			lsl	#2,d0		; bits ins obere byte schieben
			move.b	1(a6),d0
			and.b	#$c0,d0
			lsr	#6,d0
			move.b	(a3,d0),(a0)
			move.b	2(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0
			move.b	2(a6),d0	; Effect	6bits
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	3(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0
			move.b	3(a6),d0
			move	d0,-(sp)
			lsr	#4,d0
			move.b	(a3,d0),(a0)
			move.b	4(a4),d2
			bsr	printpattscreenHI
			move	(sp)+,d0
			and	#$0f,d0
			move.b	(a3,d0),(a0)
			move.b	5(a4),d2
			bsr	printpattscreenHI

			addq.l	#4,a6
			addq.l	#6,a4
			dbf	d5,pnp_8channels22

			bra	pnp_4channels2ex


pnp_allpatt
			clr.b	pattdspreq(a5)

			bsr	refresh_pos
			bsr	refresh_pat

			lea	aon_data,a6

			tst.b	chmode(a5)
			bne	pnp_all8

			lea	cursorpositions,a4
			lea	txt_notes,a2
			lea	txt_hexchars,a3
			lea	txt_instrnrs,a1
	
			moveq	#0,d7
			move	acteditpattern(a5),d7
			bsr	getactpatadr	; d7=Postaboff
			move.l	a0,a6

			moveq	#0,d2
			moveq	#64-1,d6
			move.l	#8*80*8,d3
pnp_allsteps		moveq	#4-1,d5
pnp_4channels		moveq	#0,d0
			move.b	0(a6),d0
			and.b	#63,d0
			bne.b	.nopause
			move.b	1(a6),d0	; instrumentennr.
			and.b	#63,d0
			beq.b	.pause
			lea	-4(a2),a0
			bra.b	.print
.nopause		add	d0,d0
			add	d0,d0
.pause			lea	(a2,d0),a0
.print			move.b	0(a4),d2
			bsr	printpattscreen

			lea	txt_1char,a0
			moveq	#0,d0
			move.b	1(a6),d0	; Instrumentnr
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	1(a4),d2
			bsr	printpattscreen

			moveq	#0,d0		; Arpeggio
			move.b	2(a6),d0
			lsl	#2,d0
			move.b	1(a6),d0
			and.b	#$c0,d0
			lsr	#6,d0
			move.b	(a3,d0),(a0)
			move.b	2(a4),d2
			bsr	printpattscreen

			moveq	#0,d0
			move.b	2(a6),d0
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	3(a4),d2
			bsr	printpattscreen

			moveq	#0,d0
			move.b	3(a6),d0
			move	d0,-(sp)
			lsr	#4,d0
			move.b	(a3,d0),(a0)
			move.b	4(a4),d2
			bsr	printpattscreen
			move	(sp)+,d0
			and	#$0f,d0
			move.b	(a3,d0),(a0)
			move.b	5(a4),d2
			bsr	printpattscreen

			addq.l	#4,a6
			addq.l	#6,a4

		tst	patdspVIEW(a5)	; damit der cursor beim abspielen
		beq.b	.notview	; nicht bei step 63 kurz
		movem.l	d0-a6,-(sp)	; hängenbleibt (pattern wird dort
		jsr	adjust_pattdisplay	; neu gezeichnet!!)
		movem.l	(sp)+,d0-a6
.notview

			dbf	d5,pnp_4channels
			lea	-6*4(a4),a4
			add	#8*80,d3
			dbf	d6,pnp_allsteps

;	move	#1,patalertflag(a5)
;jsr	adjust_pattdisplayNOW
			rts
pnp_all8		lea	cursorpositions8,a4
			lea	txt_notes,a2
			lea	txt_hexchars,a3
			lea	txt_instrnrs,a1
	
			moveq	#0,d7
			move	acteditpattern(a5),d7
			bsr	getactpatadr	; d7=Postaboff
			move.l	a0,a6

			moveq	#0,d2
			moveq	#64-1,d6
			move.l	#8*80*8,d3
pnp_allsteps8		moveq	#8-1,d5
pnp_8channels		moveq	#0,d0
			move.b	0(a6),d0
			and.b	#63,d0
			bne.b	.nopause
			move.b	1(a6),d0	; instrumentennr.
			and.b	#63,d0
			beq.b	.pause
			lea	-4(a2),a0
			bra.b	.print
.nopause		add	d0,d0
			add	d0,d0
.pause			lea	(a2,d0),a0
.print			move.b	0(a4),d2
			bsr	printpattscreenHI

			lea	txt_1char,a0
			moveq	#0,d0
			move.b	1(a6),d0	; Instrumentnr
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	1(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0		; Arpeggio
			move.b	2(a6),d0
			lsl	#2,d0
			move.b	1(a6),d0
			and.b	#$c0,d0
			lsr	#6,d0
			move.b	(a3,d0),(a0)
			move.b	2(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0
			move.b	2(a6),d0
			and.b	#63,d0
			move.b	(a1,d0),(a0)
			move.b	3(a4),d2
			bsr	printpattscreenHI

			moveq	#0,d0
			move.b	3(a6),d0
			move	d0,-(sp)
			lsr	#4,d0
			move.b	(a3,d0),(a0)
			move.b	4(a4),d2
			bsr	printpattscreenHI
			move	(sp)+,d0
			and	#$0f,d0
			move.b	(a3,d0),(a0)
			move.b	5(a4),d2
			bsr	printpattscreenHI

			addq.l	#4,a6
			addq.l	#6,a4

		tst	patdspVIEW(a5)	; damit der cursor beim abspielen
		beq.b	.notview	; nicht bei step 63 kurz
		movem.l	d0-a6,-(sp)	; hängenbleibt (pattern wird dort
		jsr	adjust_pattdisplay	; neu gezeichnet!!)
		movem.l	(sp)+,d0-a6
.notview
			dbf	d5,pnp_8channels
			lea	-6*8(a4),a4
			add	#8*80,d3
			dbf	d6,pnp_allsteps8

;	move	#1,patalertflag(a5)
;jsr	adjust_pattdisplayNOW
			rts
;------------------------------------------------------------------------
; a1=ptr to easyreq struct
; a0=windowptr
PATCHeasyreqargs:
		movem.l	d1-a6,-(sp)

		lea	.tags(pc),a3
		move.l	a0,4(a3)	; setwinptr

		move.l	8(a1),20(a3)	; set title
		move.l	16(a1),a2	; gadgets
		move.l	12(a1),a1	; bodytext
		move.l	a3,a0		; ptr to taglist

		movem.l	d1-d6/a0-a6,-(sp)
		moveq	#1,d0
		sub.l	a0,a0
		move.l	rtbase(a5),a6
		jsr	rtAllocRequestA(a6)
		move.l	d0,d7
		movem.l	(sp)+,d1-d6/a0-a6
		move.l	d0,a3

		sub.l	a4,a4
		move.l	rtbase(a5),a6
		jsr	rtEZRequestA(a6)
		move.l	d0,d6

		move.l	d7,a1
		move.l	rtbase(a5),a6
		jsr	rtFreeRequest(a6)

		move.l	d6,d0
		movem.l	(sp)+,d1-a6
		rts
.tags		dc.l	rt_window,0
		dc.l	rt_reqpos,1
		dc.l	rtez_reqtitle,0
		dc.l	0
		even
;------------------------------------------------------------------------
; a2=Pointer on message string (terminated with zero)
DisplayMEssage:
			movem.l	d0-a6,-(sp)
			clr.b	itt_adpd_flag(a5)
;	bsr	adpd_realadjust

		moveq	#1,d0
		sub.l	a0,a0 
		move.l	rtbase(a5),a6
		jsr	rtAllocRequestA(a6)
		move.l	d0,-(sp)
		move.l	d0,a3
		move.l	a2,a1
		lea	.gadfmt(pc),a2
		sub.l	a4,a4
		lea	.tags(pc),a0
		move.l	window1ptr(a5),4(a0)
		lea	.wintitle(pc),a5
		move.l	a5,20(a0)
		jsr	rtEZRequestA(a6)

		move.l	(sp)+,a1
		jsr	rtFreeRequest(a6)

		move.b	#1,itt_adpd_flag(a5)

		movem.l	(sp)+,d0-a6
		rts
.tags		dc.l	rt_window,0
		dc.l	rt_reqpos,1
		dc.l	rtez_reqtitle,0
		dc.l	0

.gadfmt		dc.b	"Ok",0
		ifeq	lang
.wintitle	dc.b	"Program Message",0
		else
.wintitle	dc.b	"Programm Nachricht",0
		endif
		even
;------------------------------------------------------------------------
; a2=Pointer on message string (terminated with zero)
DisplayMEssage2:
			movem.l	d0-a6,-(sp)
			clr.b	win2_override(a5)

		moveq	#1,d0
		sub.l	a0,a0 
		move.l	rtbase(a5),a6
		jsr	rtAllocRequestA(a6)
		move.l	d0,-(sp)
		move.l	d0,a3
		move.l	a2,a1
		lea	.gadfmt(pc),a2
		sub.l	a4,a4
		lea	.tags(pc),a0
		move.l	window2ptr(a5),4(a0)
		lea	.wintitle(pc),a5
		move.l	a5,20(a0)
		jsr	rtEZRequestA(a6)

		move.l	(sp)+,a1
		jsr	rtFreeRequest(a6)

		move.b	#1,win2_override(a5)

		movem.l	(sp)+,d0-a6
		rts
.tags		dc.l	rt_window,0
		dc.l	rt_reqpos,1
		dc.l	rtez_reqtitle,0
		dc.l	0

.gadfmt		dc.b	"Ok",0
		ifeq	lang
.wintitle	dc.b	"Program Message",0
		else
.wintitle	dc.b	"Programm Nachricht",0
		endif
		even
;------------------------------------------------------------------------
; a2=Pointer on message string (terminated with zero)
DisplayMEssageWave:
			movem.l	d0-a6,-(sp)
			clr.b	winwave_override(a5)

		moveq	#1,d0
		sub.l	a0,a0 
		move.l	rtbase(a5),a6
		jsr	rtAllocRequestA(a6)
		move.l	d0,-(sp)
		move.l	d0,a3
		move.l	a2,a1
		lea	.gadfmt(pc),a2
		sub.l	a4,a4
		lea	.tags(pc),a0
		move.l	windowptrWAVE(a5),4(a0)
		lea	.wintitle(pc),a5
		move.l	a5,20(a0)
		jsr	rtEZRequestA(a6)

		move.l	(sp)+,a1
		jsr	rtFreeRequest(a6)

		move.b	#1,winwave_override(a5)

		movem.l	(sp)+,d0-a6
		rts
.tags		dc.l	rt_window,0
		dc.l	rt_reqpos,1
		dc.l	rtez_reqtitle,0
		dc.l	0

.gadfmt		dc.b	"Ok",0
		ifeq	lang
.wintitle	dc.b	"Program Message",0
		else
.wintitle	dc.b	"Programm Nachricht",0
		endif
		even
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
;		      ##### ##### ####  ##### ##### ##### #####
;		      #     #   # #   # #     #       #   ##
;		      #   # ##### #   # #   # ###     #     ###
;		      ##### #   # ####  ##### #####   #   #####
;		          #                 #
;               	! s  u  b  r  o  u  t  i  n  e  s  !
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; 			# # ### # # ### ### ##  ### ###
;			##Ż #ŻŻ ### #ŻŻ #Ż# #Ż# #ŻŻ ##Ż
;			#Ż# ##  Ż#Ż #   # # # # ##  ŻŻ#
; 			# # ###  #  ### ### ### ### ###
;			Ż Ż ŻŻŻ  Ż  ŻŻŻ ŻŻŻ ŻŻŻ ŻŻŻ ŻŻŻ
CHECK_FOR_KEYS
			lea	key_static,a0		; general keyevents
			bsr	checkkeylist

			lea	keylist_list,a1
			moveq	#0,d4
			move.b	programmode(a5),d4	; lower-screenmode
			move.l	(a1,d4.l),a0
			bsr	checkkeylist

			move.l	scancode(a5),d0
			swap	d0
			tst.b	d0
			beq.b	.ok1
			cmp.b	#1,d0			; shift ?!
			bne.b	.other
.ok1			swap	d0
			jmp	noteedit_key2int
.other			swap	d0
			rts
;--------------------------------------------------------------------
CHECK_FOR_KEYS2
			lea	key_static,a0		; general keyevents
			bsr	checkkeylist

			lea	key_instred,a0
			moveq	#0,d4
			bsr	checkkeylist

			move.l	scancode(a5),d0
			swap	d0
			tst.b	d0
			beq.b	.ok1
			cmp.b	#1,d0			; shift ?!
			bne.b	.other
.ok1			swap	d0
			jmp	noteedit_key2int
.other			swap	d0
			rts
; -----------------------------------------------------------------------
; a0=Ptr on keylist
CheckKeylist:		move.l	scancode(a5),d0
cfk_static.loop		cmp	#-1,(a0)		; end of list ?!
			beq.s	cfk_static.end

			cmp.l	(a0),d0
			bne.s	cfk_static.next

			move.l	4(a0),a0	; get subroutine address
			jmp	(a0)		; join subroutine...
cfk_static.next		addq.l	#8,a0		; try it with next key..
			bra.b	cfk_static.loop
cfk_static.end		rts
; -----------------------------------------------------------------------
; --> d7= Pattern-Nr.
; <-- a0= Pointer on actual pattern
GETACTPATADR:		movem.l	d1/a6,-(sp)
			lea	aon_data,a6
			move.l	aon_pattdata(a6),a0	; get start of patdat
			ext.l	d7
			tst.b	chmode(a5)
			beq.b	.ch4
			moveq	#11,d1
			bra.b	.ch8
.ch4			moveq	#10,d1
.ch8			lsl.l	d1,d7			; patnr*1024=patoff
			add.l	d7,a0			; add to start of data
			movem.l	(sp)+,d1/a6
			rts
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<
		dc.b	"      .oO CODED BY TWICE/LEGO IN 1993-95      "
	dc.b	"  ...>> GET YOUR HANDS OFF MY PROGRAM !!!!!  Oo.      "
			Section	art.of.noise.publicdata,data
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
;MIDI

mmsg_alloff		dc	mmsg_alloffe-mmsg_alloff-1
			dc.b	$90,$30,0
			REPT	31
			dc.b	$30,0
			ENDR
mmsg_alloffe		even

; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; Tastatur
keylist_list		dc.l	key_credits,key_pattedit
			dc.l	key_arpedit,key_drumseq
			dc.l	key_setup
			dc.l	key_fmedit

; bit0:	1=LeftShift pressed	$01
; bit1: 1=RightShift pressed	$02 REMOVED BECAUSe OF PT COMPATIBILITY
; bit2: 1=Leftalt pressed	$04
; bit3: 1=Rightalt pressed	$08 REMOVED BECAUSe OF PT COMPATIBILITY
; bit4: 1=Leftamiga pressed	$10
; bit5: 1=Rightamiga pressed	$20 REMOVED BECAUSe OF PT COMPATIBILITY
; bit6: 1=Ctrl pressed		$40
key_static		;dc.l	00xx00yy,subroutine	;xx=Keylevel,yy=Keycode


			dc.l	$00100040,freezedisplay		; lalt+space

			dc.l	$00000000,togglescreen		; '`'
			dc.l	$00200065,startAllPlay		; RAlt
			dc.l	$00210065,startAllPlayCONT	; Lshift+Ralt
			dc.l	$00800067,startPatPlay		; RAmiga
			dc.l	$00810067,startPatPlayCONT	; Lshift+RAmi
			dc.l	$00000030,equ_resetchannels	; <

			dc.l	$0008004e,instrNrADD		; Ctrl+"->"
			dc.l	$0008004f,instrNrSUB		; Ctrl+"<-"
			dc.l	$0001004e,songposadd		; Shift+->
			dc.l	$0001004f,songpossub		; shift+<-

			dc.l	$00000042,jumpchannel		; <tab>
			dc.l	$00010042,jumpchannelbk		; shift+<tab>

			dc.l	$00010050,setoctave0		; shift+f1
			dc.l	$00000050,setoctave1		; f1
			dc.l	$00000051,setoctave2		; f2


; Direktanwahl der Instrumente
			dc.l	$00400001,set_instr1
			dc.l	$00400002,set_instr2
			dc.l	$00400003,set_instr3
			dc.l	$00400004,set_instr4
			dc.l	$00400005,set_instr5
			dc.l	$00400006,set_instr6
			dc.l	$00400007,set_instr7
			dc.l	$00400008,set_instr8
			dc.l	$00400009,set_instr9
			dc.l	$00400020,set_instra
			dc.l	$00400035,set_instrb
			dc.l	$00400033,set_instrc
			dc.l	$00400022,set_instrd
			dc.l	$00400012,set_instre
			dc.l	$00400023,set_instrf
			dc.l	$00400024,set_instrg
			dc.l	$00400025,set_instrh
			dc.l	$00400017,set_instri
			dc.l	$00400026,set_instrj
			dc.l	$00400027,set_instrk
			dc.l	$00400028,set_instrl
			dc.l	$00400037,set_instrm
			dc.l	$00400036,set_instrn
			dc.l	$00400018,set_instro
			dc.l	$00400019,set_instrp
			dc.l	$00400010,set_instrq
			dc.l	$00400013,set_instrr
			dc.l	$00400021,set_instrs
			dc.l	$00400014,set_instrt
			dc.l	$00400016,set_instru
			dc.l	$00400034,set_instrv
			dc.l	$00400011,set_instrw
			dc.l	$00400032,set_instrx
			dc.l	$00400031,set_instry
			dc.l	$00400015,set_instrz
			dc.l	$00410020,set_instra2
			dc.l	$00410035,set_instrb2
			dc.l	$00410033,set_instrc2
			dc.l	$00410022,set_instrd2
			dc.l	$00410012,set_instre2
			dc.l	$00410023,set_instrf2
			dc.l	$00410024,set_instrg2
			dc.l	$00410025,set_instrh2
			dc.l	$00410017,set_instri2
			dc.l	$00410026,set_instrj2
			dc.l	$00410027,set_instrk2
			dc.l	$00410028,set_instrl2
			dc.l	$00410037,set_instrm2
			dc.l	$00410036,set_instrn2
			dc.l	$00410018,set_instro2
			dc.l	$00410019,set_instrp2
			dc.l	$00410010,set_instrq2
			dc.l	$00410013,set_instrr2
			dc.l	$00410021,set_instrs2
			dc.l	$00410014,set_instrt2
			dc.l	$00410016,set_instru2
			dc.l	$00410034,set_instrv2
			dc.l	$00410011,set_instrw2
			dc.l	$00410032,set_instrx2
			dc.l	$00410031,set_instry2
			dc.l	$00410015,set_instrz2

			dc.l	$0000005a,set_instrnx1	[
			dc.l	$0000005b,set_instrnx2	]
			dc.l	$0000005c,set_instrnx3	/
			dc.l	$0000005d,set_instrnx4	*
			dc.l	$0000003d,set_instrnx5	7
			dc.l	$0000003e,set_instrnx6	8
			dc.l	$0000003f,set_instrnx7	9
			dc.l	$0000004a,set_instrnx8	-
			dc.l	$0000002d,set_instrnx9	4
			dc.l	$0000002e,set_instrnxa	5
			dc.l	$0000002f,set_instrnxb	6
			dc.l	$0000005e,set_instrnxc	+
			dc.l	$0000001d,set_instrnxd	1
			dc.l	$0000001e,set_instrnxe	2
			dc.l	$0000001f,set_instrnxf	3
			dc.l	$00000043,set_instrnxg	<enter>
			dc.l	$0001005a,set_instrnxh	[
			dc.l	$0001005b,set_instrnxi	]
			dc.l	$0001005c,set_instrnxj	/
			dc.l	$0001005d,set_instrnxk	*
			dc.l	$0001003d,set_instrnxl	7
			dc.l	$0001003e,set_instrnxm	8
			dc.l	$0001003f,set_instrnxn	9
			dc.l	$0001004a,set_instrnxo	-
			dc.l	$0001002d,set_instrnxp	4
			dc.l	$0001002e,set_instrnxq	5
			dc.l	$0001002f,set_instrnxr	6
			dc.l	$0001005e,set_instrnxs	+
			dc.l	$0001001d,set_instrnxt	1
			dc.l	$0001001e,set_instrnxu	2
			dc.l	$0001001f,set_instrnxv	3
			dc.l	$00010043,set_instrtrp	<enter>

			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_credits		dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_pattedit
			dc.l	$00000040,stopSongEditOnOff	; Space
			dc.l	$0000004e,movePatCursorRIGHT	; Csrright
			dc.l	$0000004f,movePatCursorLEFT	; Csrleft
			dc.l	$0000004d,movePatCursordown	; CsrDown
			dc.l	$0000004c,movepatcursorup
			dc.l	$0010004e,editpatADD		; LAlt+CsrRght
			dc.l	$0010004f,editpatSUB		; LAlt+CsrLft

			dc.l	$00020061,startrecord		; Rshift
			dc.l	$00030061,startrecordCONT	; Lshift+Rshift

			dc.l	$0001004c,move16stepsup		; lalt+csrdown
			dc.l	$0001004d,move16stepsdown	; lalt+csrup

			dc.l	$00000046,ne_deletestep		; Delete
			dc.l	$00010046,ne_deletestep		; Delete+shft

			dc.l	$0008000a,quant0		; ctrl+0
			dc.l	$00080001,quant1		; ctrl+1
			dc.l	$00080002,quant2		; ctrl+2
			dc.l	$00080003,quant3		; ctrl+3
			dc.l	$00080004,quant4		; ctrl+4
			dc.l	$00080005,quant5		; ctrl+5
			dc.l	$00080006,quant6		; ctrl+6
			dc.l	$00080007,quant7		; ctrl+7
			dc.l	$00080008,quant8		; ctrl+8
			dc.l	$00080009,quant9		; ctrl+9
			dc.l	$00100052,cutPattern2Buf	; lalt+f3
			dc.l	$00100053,copyPattern2Buf	; lalt+f4
			dc.l	$00100054,copyBuf2Pattern	; lalt+f5
			dc.l	$00010052,cutTrack2Buf		; lsft+f3
			dc.l	$00010053,copyTrack2Buf		; lsft+f4
			dc.l	$00010054,copyBuf2Track		; lsft+f5
			dc.l	$00080052,cutcmds2buf		; ctrl+f3
			dc.l	$00080053,copycmds2buf		; ctrl+f4
			dc.l	$00080054,copybuf2trackCMD	; ctrl+f5
			dc.l	$00010044,insertstep		; lshft+return
			dc.l	$00010041,deletestep		; lshft+backspc
			dc.l	$00000044,playstep		; Return
			dc.l	$00080035,markblock		; ctrl+b
			dc.l	$00080033,copyblock2buf		; ctrl+c
			dc.l	$00080032,moveblock2buf		; ctrl+x
			dc.l	$00080017,copybuf2block		; ctrl+i

			dc.l	$00000055,jumptopos0		; f6
			dc.l	$00000056,jumptopos1		; f7
			dc.l	$00000057,jumptopos2		; f8
			dc.l	$00000058,jumptopos3		; f9
			dc.l	$00000059,jumptopos4		; f10
			dc.l	$00100055,jumptopos0andplay	; lalt+f6
			dc.l	$00100056,jumptopos1andplay	; lalt+f7
			dc.l	$00100057,jumptopos2andplay	; lalt+f8
			dc.l	$00100058,jumptopos3andplay	; lalt+f9
			dc.l	$00100059,jumptopos4andplay	; lalt+f10
			dc.l	$00080055,jumptopos0andrecord	; ctrl+f6
			dc.l	$00080056,jumptopos1andrecord	; ctrl+f7
			dc.l	$00080057,jumptopos2andrecord	; ctrl+f8
			dc.l	$00080058,jumptopos3andrecord	; ctrl+f9
			dc.l	$00080059,jumptopos4andrecord	; ctrl+f10
			dc.l	$00010055,setjumppos0		; lsft+f6
			dc.l	$00010056,setjumppos1		; lsft+f7
			dc.l	$00010057,setjumppos2		; lsft+f8
			dc.l	$00010058,setjumppos3		; lsft+f9
			dc.l	$00010059,setjumppos4		; lsft+f10
			dc.l	$00080013,wildstarreplace	; ctrl+r
			dc.l	$00080028,changevolume		; ctrl+l
			dc.l	$00100001,areamode_block	; lalt+1
			dc.l	$00100002,areamode_track	; lalt+2
			dc.l	$00100003,areamode_pattern	; lalt+3
			dc.l	$00100028,loadsong		; lalt+l
			dc.l	$00100021,savesong		; lalt+s

			dc.l	$00080020,noteup		; ctrl+a
			dc.l	$00080021,notedown		; ctrl+s
			dc.l	$00080022,octaveup		; ctrl+d
			dc.l	$00080023,octavedown		; ctrl+f
			dc.l	$00080012,exchangepatterns	; ctrl+e
			dc.l	$00080014,exchangetracks	; ctrl+t

			dc.l	$0011004e,patadd		; lalt+lsft+->
			dc.l	$0011004f,patsub		; lalt+lsft+<-

			dc.l	$00100027,remark_edit		; lalt+'k'
			dc.l	$00100020,arpeggio_editor	; lalt+'a'
			dc.l	$00100022,drumsequencer		; lalt+'d'
;dc.l	$00100017,instrumentEd		; lalt+'i'
			dc.l	$00100016,setuped		; lalt+'u'
;dc.l	$00100011,waveed		; lalt+'w'

			dc.l	$00100019,activateEditPat	; lalt+'p'
			dc.l	$00100037,activateMaxPos	; lalt+'m'
			dc.l	$00100018,activateSongPos	; lalt+'o'
			dc.l	$00100013,activateResPos	; lalt+'r'
			dc.l	$00100014,activatePat		; lalt+'t'
			dc.l	$00100024,activateSongName	; lalt+'g'
			dc.l	$00100025,activateAuthor	; lalt+'h'
			dc.l	$00100012,activateDate		; lalt+'e'

			dc.l	$00100036,activateINSTRname	; lalt+'n'

			dc.l	$00100031,togglech1now		; lalt+y
			dc.l	$00100032,togglech2now		; lalt+x
			dc.l	$00100033,togglech3now		; lalt+c
			dc.l	$00100034,togglech4now		; lalt+v
			dc.l	$00110035,togglech5now		; lalt+lsft+b
			dc.l	$00110036,togglech6now		; lalt+lsft+n
			dc.l	$00110037,togglech7now		; lalt+lsft+m
			dc.l	$00110038,togglech8now		; lalt+lsft+,

			dc.l	$00100046,deletepos		; lalt+del
			dc.l	$0010005f,insertpos		; lalt+help

			dc.l	$0010003a,fxpage		; lalt+'-'
			dc.l	$0010002b,ppcrunchfile		; lalt+'#'

			dc.l	$0010003c,killinstrument	; lalt+'.'
			dc.l	$0000003c,deleteinstrument	; '.'
			dc.l	$00100023,freechannels		; lalt+f
			dc.l	$00100015,showtrackvols		; lalt+z

			dc.l	$00080046,deletestepcmds	; ctrl+del
			dc.l	$0008005f,replacestepcmds	; ctrl+help
			dc.l	$00080037,togglecheditmode	; ctrl+m

			dc.l	$00080018,expandtrack		; ctrl+o

			dc.l	$00100039,remark_show		; lalt+.

			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_arpedit
			dc.l	$00000045,arped_exitnow		; ESC
			dc.l	$0010000a,activatearp0		; lalt+'0'
			dc.l	$00100001,activatearp1		; lalt+'1'
			dc.l	$00100002,activatearp2		; lalt+'2'
			dc.l	$00100003,activatearp3		; lalt+'3'
			dc.l	$00100004,activatearp4		; lalt+'4'
			dc.l	$00100005,activatearp5		; lalt+'5'
			dc.l	$00100006,activatearp6		; lalt+'6'
			dc.l	$00100007,activatearp7		; lalt+'7'
			dc.l	$00100008,activatearp8		; lalt+'8'
			dc.l	$00100009,activatearp9		; lalt+'9'
			dc.l	$00100020,activatearpa		; lalt+'a'
			dc.l	$00100035,activatearpb		; lalt+'b'
			dc.l	$00100033,activatearpc		; lalt+'c'
			dc.l	$00100022,activatearpd		; lalt+'d'
			dc.l	$00100012,activatearpe		; lalt+'e'
			dc.l	$00100023,activatearpf		; lalt+'f'
			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_drumseq
			dc.l	$00000045,dseq_exitnow		; ESC
			dc.l	$0000004c,dseq_Cursorup		; CsrUP
			dc.l	$0000004d,dseq_Cursordown	; CsrDOWN
			dc.l	$0000004f,dseq_Cursorleft	; Csrleft
			dc.l	$0000004e,dseq_CursorrIGHT	; Csrright

			dc.l	$00000001,dseq_set1		; 1
			dc.l	$00000002,dseq_set2		; 2
			dc.l	$00000003,dseq_set3		; 3
			dc.l	$00000004,dseq_set4		; 4
			dc.l	$00000005,dseq_set5		; 5
			dc.l	$00000006,dseq_set6		; 6
			dc.l	$00000007,dseq_set7		; 7
			dc.l	$00000008,dseq_set8		; 8
			dc.l	$00000009,dseq_set9		; 9
			dc.l	$00000020,dseq_seta		; A
			dc.l	$00000035,dseq_setb		; B
			dc.l	$00000033,dseq_setc		; C
			dc.l	$00000022,dseq_setd		; D
			dc.l	$00000012,dseq_sete		; E
			dc.l	$00000023,dseq_setf		; F
			dc.l	$00000046,dseq_del		; -	delete
			dc.l	$00000041,dseq_del		; -	bckspc

			dc.l	$0010004e,dseq_seqnrADD		; LAlt+CsrRght
			dc.l	$0010004f,dseq_seqnrSUB		; LAlt+CsrLft
			dc.l	$0001004e,dseq_seqlenADD	; LSFT+CsrRght
			dc.l	$0001004f,dseq_seqlenSUB	; LSFT+CsrLft

			dc.l	$00100052,dseq_cutseq2Buf	; lalt+f3
			dc.l	$00100053,dseq_copyseq2buf	; lalt+f4
			dc.l	$00100054,dseq_copybuf2seq	; lalt+f5
			dc.l	$00100055,dseq_deleteseq	; lalt+f6
			dc.l	$00000040,instred_playoff	; space
			dc.l	$00100028,dseq_loadsequence	; lalt+'l'
			dc.l	$00100021,dseq_savesequence	; lalt+'s'
			dc.l	$00100019,dseq_enterSEQnote	; lalt+'p'
			dc.l	$00100022,activateDSEQspeed	; lalt+'d'
			dc.l	$00100014,activateDSEQtempo	; lalt+'t'
			dc.l	$00100011,activateDSEQwave	; lalt+'t'
			dc.l	$00100010,dseq_computeNOW	; lalt+'q'
			dc.l	$00100034,activateDSEQwavenr	; lalt+'v'
			dc.l	$00100036,dseq_delnotes		; lalt+'n'
			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_instred
			dc.l	$00000045,togglescreen
			dc.l	$00000040,instred_playoff	; space
			dc.l	$00100052,instred_cutinstrument	; lalt+f3
			dc.l	$00100053,instred_copyinstrument; lalt+f4
			dc.l	$00100054,instred_pasteinstrument ; lalt+f5
			dc.l	$00100055,instred_deleteinstrument ; lalt+f6
			dc.l	$0000003c,instred_deleteinstrument ; '.'
			dc.l	$0010003c,instred_killinstrument ; lalt+'.'
			dc.l	$0010004e,instrNrADD		; lalt+"->"
			dc.l	$0010004f,instrNrSUB		; lalt+"<-"

			dc.l	$00100028,instred_load		;lalt+'l'
			dc.l	$00100021,instred_save		;lalt+'s'
			dc.l	$00100011,instred_loadwave	; lalt+'w'
			dc.l	$00100023,instred_flushwave	; lalt+'f'
			dc.l	$00100036,activateInstredName	; lalt+'n'

			dc.l	$00100015,instred_saveall	; lalt+z
			dc.l	$0000005f,waveed_createinstrumentFIX ; HELP

			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_setup
			dc.l	$00000045,setup_exitnow		; esc
			dc.l	$00100037,setup_getmodpath	; lalt+'m'
			dc.l	$00100017,setup_getinstrpath	; lalt+'i'
			dc.l	$00100011,setup_getsamplepath	; lalt+'w'
			dc.l	$00100022,setup_getdseqpath	; lalt+'d'
			dc.l	$00100014,activatesetupTextEditor ;alt+'t'
			dc.l	$00100035,setup_getBLanker	; lalt+'b'
			dc.l	$00100036,activateSetupBlankertimeout +'n'
			dc.l	$00100034,setup_togglewavedrawmode lalt+'v'
			dc.l	$00100023,setup_togglefiltermode   lalt+'f'
			dc.l	$00100033,setup_exitnow		; lalt+'c'
			dc.l	$00100016,setup_useKEY		; lalt+'u'
			dc.l	$00100028,loadprefs		; lalt+'l'
			dc.l	$00100021,saveprefs		; lalt+'s'
			dc.l	$00100013,setup_togglesaveremarkmode ; lalt+'r'
			dc.l	$00100012,setup_togglesaveinstrnamesmode ; lalt+'e'
			dc.l	$00100027,setup_togglecrunchmode ; lalt+'k'
			dc.l	$00100019,setup_toggleaddppmode	; lalt+'p'
			dc.l	$00100031,setup_togglecruncheffmode ; lalt+'y'
			dc.l	$00100025,setup_togglecrunchbufmode ; lalt+'h'
			dc.l	$00100018,setup_togglebottomstatusmode ; lalt+o
			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
key_fmedit
			dc.l	$00000045,fmed_exitnow	; esc
			dc.l	$00000040,waveed_playoff	; space
			dc.l	$0000005f,fmed_createinstrumentFIX ; HELP
			dc	-1
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
;ĞğĞğĞğĞğĞğĞğĞğĞĞğĞğĞğĞğĞğĞğĞğ×ĞğĞğĞğĞğĞğ×ĞğĞğĞğĞ×ĞğĞğĞğĞ×ĞğĞğĞğ×ĞğĞğ×ĞğĞğĞğ×
; -----------------------------------------------------------------------
;stacksave		dc.l	0
utilname		dc.b	"utility.library",0
gfxname			dc.b	"graphics.library",0
intname			dc.b	"intuition.library",0
gadtoolsname		dc.b	"gadtools.library",0
reqtoolsname		dc.b	"reqtools.library",0
dosname			dc.b	"dos.library",0
powerpackername		dc.b	"powerpacker.library",0
diskfontname		dc.b	"diskfont.library",0
			even
; ---------------------------------------------------- Filerequester
mod_filename		ds.b	108
			ifeq	lang
mod_filereqtitle	dc.b	"Select module to load...",0
mod_filereqtitleSAVE	dc.b	"Select file to save module to...",0
			else
mod_filereqtitle	dc.b	"Modul laden...",0
mod_filereqtitleSAVE	dc.b	"Modul speichern...",0
			endif
			even
mod_filereqTAGS		dc.l	rt_window
mod_filereqWINPTR	dc.l	0
			dc.l	rt_reqpos,reqpos_pointer
			dc.l	rtfi_flags,freqf_patgad
			dc.l	rt_lockwindow,true
			dc.l	rtfi_height
filereqH		dc.l	240
			dc.l	TAG_DONE

mod_dirreqTAGS		dc.l	rt_window
mod_dirreqWINPTR	dc.l	0
			dc.l	rt_reqpos,reqpos_pointer
			dc.l	rtfi_flags,freqf_patgad+2^3+2^12
			dc.l	rt_lockwindow,true
			dc.l	rtfi_height
dirreqH			dc.l	240
			dc.l	TAG_DONE



mod_filereqTAGS2	dc.l	rt_window
mod_filereqWINPTR2	dc.l	0
			dc.l	rt_reqpos,reqpos_pointer
			dc.l	rtfi_flags,freqf_patgad
			dc.l	rt_lockwindow,true
			dc.l	rtfi_height
filereqH2		dc.l	240
			dc.l	TAG_DONE
mod_filereqTAGSwave	dc.l	rt_window
mod_filereqWINPTRwave	dc.l	0
			dc.l	rt_reqpos,reqpos_pointer
			dc.l	rtfi_flags,freqf_patgad
			dc.l	rt_lockwindow,true
			dc.l	rtfi_height
			dc.l	240
			dc.l	TAG_DONE

iofilename		ds.b	256
; -----------------------------------------------------------------------
dseq_filename		ds.b	108
			ifeq	lang
dseq_savesequencetitle	dc.b	"Select File to save sequence to",0
dseq_loadsequencetitle	dc.b	"Select DSequence File to load",0
			else
dseq_savesequencetitle	dc.b	"Sequenz abspeichern...",0
dseq_loadsequencetitle	dc.b	"Sequenz laden...",0
			endif

sample_filename		ds.b	108
			ifeq	lang
sample_filereqtitleLOAD	dc.b	"Select waveform to load...",0
sample_filereqtitleSAVE	dc.b	"Select file to save waveform to...",0
sample_filereqtitleSAVEBUF
			dc.b	"Select file to save buffer to...",0
			else
sample_filereqtitleLOAD	dc.b	"Wellenform laden...",0
sample_filereqtitleSAVE	dc.b	"Wellenform speichern...",0
sample_filereqtitleSAVEBUF
			dc.b	"Editier-Buffer speichern...",0
			endif

instr_filename		ds.b	108
			ifeq	lang
instr_filereqtitleLOAD	dc.b	"Select instrument to load...",0
instr_filereqtitleSAVE	dc.b	"Select file to save instrument to...",0
			else
instr_filereqtitleLOAD	dc.b	"Instrument laden...",0
instr_filereqtitleSAVE	dc.b	"Instrument speichern...",0
			endif

fm_filename		ds.b	108

var_filename		ds.b	108
			ifeq	lang
var_blanker_filereqtitle	dc.b	"Select screenblanker-module",0
var_prf_filereqtitle	dc.b	"Select Preferences File",0
var_ul_filereqtitle	dc.b	"Select MIDI-Dump (Downloaded) File",0
var_dl_filereqtitle	dc.b	"Select File to save MIDI-Dump to",0
var_img_filereqtitle	dc.b	"Select File to save IMAGE-Data to",0
var_exe_filereqtitle	dc.b	"Select File to save EXECUTABLE to",0
			else
var_blanker_filereqtitle	dc.b	"Screenblanker-Modul wählen...",0
var_prf_filereqtitle	dc.b	"Preference-Datei wählen...",0
var_ul_filereqtitle	dc.b	"Select MIDI-Dump (Downloaded) File",0
var_dl_filereqtitle	dc.b	"Select File to save MIDI-Dump to",0
var_img_filereqtitle	dc.b	"IMAGE-Datei speichern...",0
var_exe_filereqtitle	dc.b	"Executable-Datei speichern...",0
			endif
			even

; -----------------------------------------------------------------------
con_name		dc.b	"CON:10/10/310/64/ArtOfNoise - Output Window",0
			even
rem_editcall		ds.b	108
rem_filename		dc.b	"ram:aon.moduleRemark.txt",0
			even
; -----------------------------------------------------------------------
;ScreenBlankerDaten
blankerpfad		dc.b	"blankermodules",0
			even

; -----------------------------------------------------------------------
prf_filename		dc.b	"ArtOfNoise.config",0
			even
PRF_default

			incbin	"ch:.include/ArtOfNoise.configDEF"

;
;			dc.l	"AONP"
;			dc.l	0		; screenmode
;			dc.b	0,0		; filter,splitmode
;	dc.b	"demomods"
;		ds.b	32-16
;	ds.b	32
;	ds.b	32
;	ds.b	32
;	dc.b	"c:ed"
;		ds.b	32-4
;	ds.b	32
;	dc	242
;	dc.b	10,10,12	; col0
;	dc.b	0,0,0
;	dc.b	15,15,15
;	dc.b	6,8,12		; col3
;	dc.b	0,16*4,32*4,48*4,63*4
;	dc.b	1,1,1,1,4,0
;	dc.b	1	; botstat
;	dc.b	0	; forcePal
prfend
		even

; -----------------------------------------------------------------------
authtxt	dc.b	"Converted by AON.      ",0	; Für Pro/Noise>AON Converter-
		even
datetxt	dc.b	"???        ",0			; Routine

newgadgetattr		dc.l	gtst_string,0
			dc.l	tag_done
; -----------------------------------------------------------------------
CiaBName		dc.b	"ciab.resource",0
CiaBBase		dc.l	0

			even
;_----------
TimerIntServerB
			dc.l	0,0
			dc.b	2,5 ; type, priority
			dc.l	TimerIntnameB
			dc.l	0,np_timerIRB	; PTR auf Assembler-Prg.
TimerIntnameB		dc.b	"ArtOfNoise- player V4",0
			even
VBIntServer
			dc.l	0,0
			dc.b	2,5 ; type, priority
			dc.l	vbIntname
			dc.l	0,vbi		; PTR auf Assembler-Prg.
vbIntname		dc.b	"ArtOfNoise-Player V4",0
			even

;---------------------- Screens/Windows/Gadgets -------------------------
			even
VisualInfo_Tag		dc.l	TAG_DONE

;-----------------------------------------------------



screendata1		dc	0,0
			dc	640
screenheigth		dc	400
			dc	2
			dc.b	1,0
			dc	$8024	;$8024
			dc	$f		; Identify WB-Screen
			dc.l	topaz8
			dc.l	screentitle
			dc.l	0
			dc.l	0

screentitle
 dc.b	"ArtOfNoise V1.9DW by Bastian Spiegel - İ 1993-96. The Lego Club!"
 dc.b	"            ",0
			even
screendata2		dc	0,0
			dc	640
			dc	425
			dc	3
			dc.b	1,0
			dc	$8024	;$8024
			dc	$f
			dc.l	topaz8
			dc.l	screentitle
			dc.l	0
			dc.l	0


topaz8			dc.l	topazname	; Font-Struktur
			dc	8,0		; .............
topazname		dc.b	"AON.font",0
;		dc.b	"topaz.font",0
			even

screentags2
			dc.l	SA_Colors,colorspecs
;dc.l	SA_FullPalette,True
			dc.l	SA_pens,pens_3d
			dc.l	SA_DisplayID
screenmode2		dc.l	0
;dc.l	SA_FullPalette,True
			dc.l	SA_Interleaved,FALSE
			dc.l	SA_Autoscroll,TRUE
			dc.l	SA_Overscan,OSCAN_Standard
			dc.l	TAG_DONE

screentags1		dc.l	SA_pens,pens_3d
			dc.l	SA_DisplayID
screenmode		dc.l	0
			dc.l	SA_Interleaved,FALSE
			dc.l	SA_Colors,colorspecs
			dc.l	TAG_DONE
pens_3d			dc	0,1,1,2,1,3,1,0,2,1,2,1,-1

colorspecs		dc	0
			dc	$a
			dc	$a
			dc	$a

			dc	1
			dc	$0
			dc	$0
			dc	$0

			dc	2
			dc	$c
			dc	$c
			dc	$c

			dc	3
			dc	$8
			dc	$9
			dc	$a

			dc	4
			dc	$a
			dc	$a
			dc	$b

;			dc	5
;			dc	$c
;			dc	$6
;			dc	$8

			dc	5
			dc	$d
			dc	$d
			dc	$8

			dc	6
			dc	$f
			dc	$f
			dc	$f

			dc	7
			dc	$7
			dc	$8
			dc	$b

			dc	-1
			dc	0
			dc	0
			dc	0

;-----------------------------------------------------
window1struct		dc	0,11
			dc	640
win1h3			dc	255
			dc.b	1,4
 dc.l	MENUPICK+RAWKEY+GADGETUP+GADGETDOWN+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW+MOUSEBUTTONS+MOUSEMOVE
	; IDCMP-Flags
			dc.l	$00001800+256	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	window1title
window1screenptr	dc.l	0
			dc.l	0
			dc	640
win1h			dc	255
			dc	640
win1h2			dc	255
			dc	15

window1title
		ifeq	lang
		dc.b	"Memory:    "
		else
		dc.b	"Speicher: "
		endif
cm_chipasc 	dc.b	"C:0000000   "
cm_fastasc	dc.b	"F:0000000   "
cm_publicasc 	dc.b	"P:0000000   "
cm_songasc	dc.b	"S:0000000   "
cm_waveasc	dc.b	"W:0000000   "
cm_moduleasc	dc.b	"M:0000000",0
			even
;-----------------------------------------------------
window2struct		dc	0,100
			dc	640,72
			dc.b	1,4
 dc.l	RAWKEY+GADGETUP+CLOSEWINDOW+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW	; IDCMP-Flags
			dc.l	$00001008+256	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	window2title
window2screenptr	dc.l	0
			dc.l	0
			dc	640,72
			dc	640,72
			dc	15
window2title
 dc.b	"ArtOfNoise Arpeggio-Editor V1.0",0
			even
;-----------------------------------------------------
dseq_windowstruct	dc	0,0
			dc	640,252
			dc.b	1,4
 dc.l	RAWKEY+GADGETUP+GADGETDOWN+CLOSEWINDOW+MOUSEMOVE+MOUSEBUTTONS+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW
; IDCMP-Flags
			dc.l	$00001008	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	dseq_windowtitle
dseq_windowscreenptr	dc.l	0
			dc.l	0
			dc	640,252
			dc	640,252
			dc	15
dseq_windowtitle
 dc.b	"ArtOfNoise Drum-Sequencer V1.3",0
			even
;-----------------------------------------------------
instred_windowstruct	dc	0,11
			dc	640,413
			dc.b	1,4
 dc.l	RAWKEY+GADGETUP+GADGETDOWN+CLOSEWINDOW+MOUSEMOVE+MOUSEBUTTONS+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW
; IDCMP-Flags
			dc.l	$00001800	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	instred_windowtitle
instred_windowscreenptr	dc.l	0
			dc.l	0
			dc	640,413
			dc	640,413
			dc	15
instred_windowtitle
 dc.b	"Instrument/Wave-Editor V2.0"
 dcb.b	81-27," "
 dc.b	0
			even
;-----------------------------------------------------
setup_windowstruct	dc	0,gyoff
			dc	640,195
			dc.b	1,4
 dc.l	RAWKEY+GADGETUP+GADGETDOWN+CLOSEWINDOW+MOUSEMOVE+MOUSEBUTTONS+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW
; IDCMP-Flags
			dc.l	$00001008	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	setup_windowtitle
setup_windowscreenptr	dc.l	0
			dc.l	0
			dc	640,195
			dc	640,195
			dc	15
setup_windowtitle
 dc.b	"ArtOfNoise Preferences-Editor V1.3",0
			even
;-----------------------------------------------------
pp_windowstruct		dc	100,80
			dc	288,36
			dc.b	1,4
 dc.l	0
; IDCMP-Flags
			dc.l	$00001000	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	pp_windowtitle
pp_windowscreenptr	dc.l	0
			dc.l	0
			dc	288,36
			dc	288,36
			dc	15
pp_windowtitle
	ifeq	lang
 dc.b	"Press both mousebuttons to abort...",0
	else
 dc.b	"Beide Maustasten für Abbruch...",0
	endif
			even
;-----------------------------------------------------
fmed_windowstruct	dc	0,0
			dc	640,252
			dc.b	1,4
  dc.l	RAWKEY+GADGETUP+GADGETDOWN+CLOSEWINDOW+MOUSEMOVE+MOUSEBUTTONS+INTUITICKS+ACTIVEWINDOW+INACTIVEWINDOW
; IDCMP-Flags
			dc.l	$00001008	; Window-Flags
			dc.l	0
			dc.l	0
			dc.l	fmed_windowtitle
fmed_windowscreenptr	dc.l	0
			dc.l	0
			dc	640,252
			dc	640,252
			dc	15
fmed_windowtitle
 dc.b	"ArtOfNoise FMSynth-Editor V1.4",0
			even
;----------------------------------------------------	BEVEL-BOXEN
bevel_recessed_tags	dc.l	gt_visualinfo,0
			dc.l	gtbb_recessed,true
			dc.l	tag_done
bevel_raised_tags	dc.l	gt_visualinfo,0
			dc.l	tag_done
;----------------------------------------------------
;------------------------------------------------------------------------
; Main-panel gadgets

;----------------------------------------------------- Gadget-Routines
GadgetRoutinePtrs	dc.l	0,mp_gadgetroutines
			dc.l	arp_gadgetroutines
			dc.l	dseq_gadgetroutines
			dc.l	setup_gadgetroutines
			dc.l	fmed_gadgetroutines


mp_GadgetRoutines	dc.l	gad_quit,cg_quit,0
			dc.l	gad_playsong,startallplay,0
			dc.l	gad_contsong,startallplayCONT,0
			dc.l	gad_playpat,startPatPlay,0
			dc.l	gad_contpat,startPatPlayCONT,0
			dc.l	gad_record,startrecord,0
			dc.l	gad_contrecord,startrecordCONT,0
			dc.l	gad_stop,stopSong,0
			dc.l	gad_pos,songPosChange,0
			dc.l	gad_addpos,SongPosADD,0
			dc.l	gad_subpos,SongPosSUB,0
			dc.l	gad_max,MaxPosChange,0
			dc.l	gad_addmax,MaxPosADD,0
			dc.l	gad_submax,MaxPosSUB,0
			dc.l	gad_res,ResPosChange,0
			dc.l	gad_addres,ResPosADD,0
			dc.l	gad_subres,ResPosSUB,0
			dc.l	gad_pat,patChange,0
			dc.l	gad_addpat,PatADD,0
			dc.l	gad_subpat,PatSUB,0
			dc.l	gad_insertpos,InsertPos,0
			dc.l	gad_deletepos,DeletePos,0
			dc.l	gad_edit,editstatusChange,0
			dc.l	gad_editpat,EditPatChange,0
			dc.l	gad_addeditpat,EditPatADD,0
			dc.l	gad_subeditpat,EditPatSUB,0
			dc.l	gad_changeinstrnr,InstrNrChange,InstrNrChange
			dc.l	gad_resettimer,resettimer,0
			dc.l	gad_about,fmed,0
			dc.l	gad_clear,clr.new,0
			dc.l	gad_remark,remark_edit,0
			dc.l	gad_arped,arpeggio_editor,0
			dc.l	gad_changepos,poslistchanged,0
			dc.l	gad_drumseq,DrumSequencer,0
			dc.l	gad_instred,togglescreen,0
			dc.l	gad_setup,setupED,0
;	dc.l	gad_waveed,waveed,0
			dc.l	0	; Ende der Liste
	
MP_GADGETstructPTRS
			;  Kind,GadPtr,Tags
		dc.l	button_kind,mp_gadget1,underscoretags
		dc.l	button_kind,mp_gadget2,underscoretags
		dc.l	button_kind,mp_gadget3,underscoretags
		dc.l	button_kind,mp_gadget4,underscoretags
		dc.l	button_kind,mp_gadget5,underscoretags
		dc.l	button_kind,mp_gadget6,underscoretags
		dc.l	button_kind,mp_gadget7,0
		dc.l	button_kind,mp_gadget8,underscoretags
		dc.l	button_kind,mp_gadget9,underscoretags
		dc.l	button_kind,mp_gadget10,underscoretags
		dc.l	button_kind,mp_gadget11,underscoretags
		dc.l	button_kind,mp_gadget12,underscoretags
		dc.l	button_kind,mp_gadget13,underscoretags
		dc.l	button_kind,mp_gadget14,underscoretags
		dc.l	checkbox_kind,mp_gadget15,underscoretags
		dc.l	button_kind,mp_gadget16,underscoretags
		dc.l	button_kind,mp_gadget17,underscoretags
		dc.l	string_kind,mp_gadget18,mp_gadget18TAGS
		dc.l	string_kind,mp_gadget19,mp_gadget19TAGS
		dc.l	string_kind,mp_gadget20,mp_gadget20TAGS
		dc.l	string_kind,mp_gadget21,mp_gadget21TAGS
		dc.l	integer_kind,mp_gadget22,mp_gadget22TAGS
		dc.l	integer_kind,mp_gadget23,mp_gadget22TAGS
		dc.l	integer_kind,mp_gadget24,mp_gadget22TAGS
		dc.l	button_kind,mp_gadget25,underscoretags
		dc.l	button_kind,mp_gadget26,underscoretags
		dc.l	button_kind,mp_gadget27,underscoretags
		dc.l	button_kind,mp_gadget28,underscoretags
		dc.l	button_kind,mp_gadget29,underscoretags
		dc.l	button_kind,mp_gadget30,underscoretags
		dc.l	integer_kind,mp_gadget31,mp_gadget22TAGS
		dc.l	button_kind,mp_gadget32,underscoretags
		dc.l	button_kind,mp_gadget33,underscoretags
		dc.l	button_kind,mp_gadget34,underscoretags
		dc.l	button_kind,mp_gadget35,underscoretags
		dc.l	integer_kind,mp_gadget36,mp_gadget22tags
		dc.l	button_kind,mp_gadget37,underscoretags
		dc.l	button_kind,mp_gadget38,underscoretags
		dc.l	scroller_kind,mp_gadget39,mp_gadget39tags
		dc.l	button_kind,mp_gadget49,underscoretags	; resettimer
		dc.l	scroller_kind,mp_gadget50,mp_gadget50tags

		dc.l	text_kind,mp_rog7,mp_rog7TAGS
		dc.l	text_kind,mp_rog8,mp_rog8TAGS
		dc.l	number_kind,mp_rog9,0		; speed
		dc.l	number_kind,mp_rog10,0		; tempo
		dc.l	number_kind,mp_rog11,mp_rog11tags	; wavesize
		dc.l	text_kind,mp_rog12,mp_rog12tags	; instrvolume

		dc.l	0,0,0		; Ende der Liste

;mp_gadgettest	
;	dc	510+40,3*ghi+gyoff,60,ghi
;	dc.l	testtitle,topaz8		; Label,textattr
;	dc	gad_test		; Gadget-ID
;	dc.l	PLACETEXT_LEFT		; Center Text!
;	dc.l	0			; VisualInfo
;	dc.l	0			; UserData
;mp_gadgettesttags
;	dc.l	ga_relverify,true
;	dc.l	gtsl_levelplace,placetext_right
;	dc.l	gtsl_levelformat,testformat
;	dc.l	gtsl_maxlevellen,4
;	dc.l	gtsl_level,5
;	dc.l	gtsl_min,0
;	dc.l	gtsl_max,44
;	dc.l	tag_done
;testformat	dc.b	"%ld",0
;testtitle	dc.b	"Test!!",0
;	even

;-----------------------------------------------------	Gadget-Strukturen

; NewGadget-Struktur (V37>)
MP_disabledTags
	dc.l	GA_disabled,TRUE
	dc.l	TAG_DONE
MP_enabledTags
	dc.l	GA_disabled,FALSE
	dc.l	TAG_DONE

MP_GADGET1
	dc	0,3*ghi+gyoff,80,ghi	; x,y,breite,hoehe
	dc.l	mp_gadget1asc,topaz8	; Label,textattr
	dc	gad_quit		; Gadget-ID
	dc.l	PLACETEXT_IN		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
MP_GADGET2
	dc	80,3*ghi+gyoff,80,ghi
	dc.l	mp_gadget2asc,topaz8
	dc	gad_remark
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
MP_GADGET3
	dc	160,3*ghi+gyoff,80,ghi
	dc.l	mp_gadget3asc,topaz8
	dc	gad_instred
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET4
	dc	0,4*ghi+gyoff,80,ghi
	dc.l	mp_gadget4asc,topaz8
	dc	gad_clear
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET5
	dc	80,4*ghi+gyoff,80,ghi
	dc.l	mp_gadget5asc,topaz8
	dc	gad_setup
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET6
	dc	160,4*ghi+gyoff,80,ghi
	dc.l	mp_gadget6asc,topaz8
	dc	gad_waveed
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET7
	dc	0,5*ghi+gyoff,80,ghi
	dc.l	mp_gadget7asc,topaz8
	dc	gad_about
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET8
	dc	80,5*ghi+gyoff,80,ghi
	dc.l	mp_gadget8asc,topaz8
	dc	gad_drumseq
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET9
	dc	160,5*ghi+gyoff,80,ghi
	dc.l	mp_gadget9asc,topaz8
	dc	gad_arped
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET10
	dc	240,3*ghi+gyoff,80,ghi
	dc.l	mp_gadget10asc,topaz8
	dc	gad_playsong
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET11
	dc	320,3*ghi+gyoff,80,ghi
	dc.l	mp_gadget11asc,topaz8
	dc	gad_contsong
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET12
	dc	400,3*ghi+gyoff,80,ghi
	dc.l	mp_gadget12asc,topaz8
	dc	gad_stop
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET13
	dc	240,4*ghi+gyoff,80,ghi
	dc.l	mp_gadget13asc,topaz8
	dc	gad_playpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET14
	dc	320,4*ghi+gyoff,80,ghi
	dc.l	mp_gadget14asc,topaz8
	dc	gad_contpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET15
	dc	454,4*ghi+gyoff+1,80,ghi
	dc.l	mp_gadget15asc,topaz8
	dc	gad_edit
	dc.l	PLACETEXT_LEFT
	dc.l	0
MP_GADGET16
	dc	240,5*ghi+gyoff,80,ghi
	dc.l	mp_gadget16asc,topaz8
	dc	gad_record
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET17
	dc	320,5*ghi+gyoff,80,ghi
	dc.l	mp_gadget17asc,topaz8
	dc	gad_contrecord
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET25
	dc	320,0*ghi+gyoff,20,ghi
	dc.l	mp_plusasc,topaz8
	dc	gad_addpos
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET26
	dc	340,0*ghi+gyoff,20,ghi
	dc.l	mp_minusasc,topaz8
	dc	gad_subpos
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET27
	dc	320,2*ghi+gyoff,20,ghi
	dc.l	mp_plusasc,topaz8
	dc	gad_addmax
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET28
	dc	340,2*ghi+gyoff,20,ghi
	dc.l	mp_minusasc,topaz8
	dc	gad_submax
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET29
	dc	440,2*ghi+gyoff,20,ghi
	dc.l	mp_plusasc,topaz8
	dc	gad_addres
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET30
	dc	460,2*ghi+gyoff,20,ghi
	dc.l	mp_minusasc,topaz8
	dc	gad_subres
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET32
	dc	360,0*ghi+gyoff,40,ghi*2
	dc.l	mp_gadget32asc,topaz8
	dc	gad_insertPos
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET33
	dc	400,0*ghi+gyoff,40,ghi*2
	dc.l	mp_gadget33asc,topaz8
	dc	gad_deletePos
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET34
	dc	320,1*ghi+gyoff,20,ghi
	dc.l	mp_plusasc,topaz8
	dc	gad_addpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET35
	dc	340,1*ghi+gyoff,20,ghi
	dc.l	mp_minusasc,topaz8
	dc	gad_subpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET37
	dc	80,6*ghi+gyoff,20,ghi
	dc.l	mp_plusasc,topaz8
	dc	gad_addeditpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET38
	dc	100,6*ghi+gyoff,20,ghi
	dc.l	mp_minusasc,topaz8
	dc	gad_subeditpat
	dc.l	PLACETEXT_IN
	dc.l	0
MP_GADGET39	
	dc	320,6*ghi+gyoff,80,ghi
	dc.l	0,topaz8		; Label,textattr
	dc	gad_changeinstrnr	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
mp_gadget39tags
	dc.l	gtsc_total,62
	dc.l	gtsc_arrows,14
	dc.l	ga_followmouse,true
	dc.l	ga_relverify,true
	dc.l	ga_immediate,true
	dc.l	tag_done


mp_gadget49
	dc	460,5*ghi+gyoff,20,ghi
	dc.l	mp_gadget49ASC,topaz8
	dc	gad_resettimer
	dc.l	PLACETEXT_IN
	dc.l	0

MP_GADGET50
	dc	620,0*ghi+gyoff,20,6*ghi
	dc.l	0,topaz8		; Label,textattr
	dc	gad_changepos		; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
mp_gadget50tags
	dc.l	gtsc_total,257
	dc.l	gtsc_arrows,10
	dc.l	ga_followmouse,true
	dc.l	ga_relverify,true
	dc.l	ga_immediate,true
	dc.l	pga_freedom,lorient_vert
	dc.l	tag_done

;----------------------------------------------------	String-Gadgets
MP_GADGET18
	dc	48,0*ghi+gyoff,192,ghi
	dc.l	mp_gadget18asc,topaz8
	dc	gad_songname
	dc.l	PLACETEXT_LEFT
	dc.l	0
MP_Gadget18TAGS
		dc.l	gtst_string
mp_songnameptr	dc.l	0			; Ptr auf Textpuffer
		dc.l	gtst_maxchars,255	; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE

MP_GADGET19
	dc	48,1*ghi+gyoff,192,ghi
	dc.l	mp_gadget19asc,topaz8
	dc	gad_songauthor
	dc.l	PLACETEXT_LEFT
	dc.l	0
MP_Gadget19TAGS
		dc.l	gtst_string
mp_authorptr	dc.l	0
		dc.l	gtst_maxchars,255
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
MP_GADGET20
	dc	48,2*ghi+gyoff,192,ghi
	dc.l	mp_gadget20asc,topaz8
	dc	gad_songdate
	dc.l	PLACETEXT_LEFT
	dc.l	0
MP_Gadget20TAGS
		dc.l	gtst_string
mp_dateptr	dc.l	0
		dc.l	gtst_maxchars,255
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
MP_GADGET21
	dc	80+40,6*ghi+gyoff,180,ghi
	dc.l	0,topaz8
	dc	gad_instrumentname
	dc.l	PLACETEXT_LEFT
	dc.l	0
MP_Gadget21TAGS
		dc.l	gtst_string,0		; Ptr auf Textpuffer
		dc.l	gtst_maxchars,32	; Maximale Anzahl Zeichen
		dc.l	TAG_DONE

;----------------------------------------------------	Integer-Gadget
mp_gadget22
	dc	240+80-40,0*ghi+gyoff,40,ghi
	dc.l	mp_gadget22asc,topaz8
	dc	gad_pos
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_gadget22TAGS
		dc.l	gt_underscore,"_"
		dc.l	ga_tabcycle,TRUE
		dc.l	gtin_number,0
		dc.l	gtin_maxchars,3
		dc.l	stringa_replacemode,true
		dc.l	tag_done
mp_gadget23
	dc	240+80-40,2*ghi+gyoff,40,ghi
	dc.l	mp_gadget23asc,topaz8
	dc	gad_max
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_gadget24
	dc	360+80-40,2*ghi+gyoff,40,ghi
	dc.l	mp_gadget24asc,topaz8
	dc	gad_res
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_gadget31
	dc	240+80-40,1*ghi+gyoff,40,ghi
	dc.l	mp_gadget31asc,topaz8
	dc	gad_pat
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_gadget36
	dc	0+80-40,6*ghi+gyoff,40,ghi
	dc.l	mp_gadget31asc2,topaz8
	dc	gad_editpat
	dc.l	PLACETEXT_LEFT
	dc.l	0
;----------------------------------------------------	Read-Only Gadgets
; 'r'ead 'o'nly 'g'adgets!
mp_rog7
	dc	300,6*ghi+gyoff,20,ghi
	dc.l	0,topaz8
	dc	rog_instrnr
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_rog7tags
		dc.l	gttx_text,txt_actinstrnr
		dc.l	gttx_border,true
		dc.l	tag_done
txt_actinstrnr	dc.b	"1",0
mp_rog8
	dc	400,5*ghi+gyoff,60,ghi
	dc.l	0,topaz8
	dc	rog_modtimer
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_rog8tags
		dc.l	gttx_text,txt_acttimer
		dc.l	gttx_border,true
		dc.l	tag_done
txt_acttimer	dc.b	"00:00",0
mp_rog9
	dc	456,0*ghi+gyoff,40,ghi
	dc.l	0,topaz8
	dc	rog_speed
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_rog10
	dc	448,1*ghi+gyoff,40,ghi
	dc.l	0,topaz8
	dc	rog_tempo
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_rog11
	dc	402,6*ghi+gyoff,60,ghi
	dc.l	0,topaz8
	dc	rog_wavesize
	dc.l	PLACETEXT_LEFT
	dc.l	0
mp_rog11tags
		dc.l	gttx_border,true
		dc.l	tag_done
mp_rog12
	dc	455,6*ghi+gyoff,25,ghi
	dc.l	0,topaz8
	dc	rog_volume
	dc.l	PLACETEXT_IN
	dc.l	0
mp_rog12tags
		dc.l	gttx_text,txt_actvolume
		dc.l	gttx_border,true
		dc.l	tag_done
txt_actvolume	dc.b	"00",0,0

underscoretags
		dc.l	gt_underscore,"_"
		dc.l	tag_done

;----------------------------------------------------
mp_gadget1asc	dc.b	"Quit",0
mp_gadget2asc	dc.b	"Remar_k",0
mp_gadget3asc	dc.b	"Sampler",0	instred
mp_gadget4asc	dc.b	"Clear",0
mp_gadget5asc	dc.b	"Set_up",0
mp_gadget6asc	dc.b	0	waveed
mp_gadget7asc	dc.b	"FMSynth",0
mp_gadget8asc	dc.b	"_Drumseq.",0
mp_gadget9asc	dc.b	"_Arp.Ed",0
mp_gadget10asc	dc.b	"PlaySong",0
mp_gadget11asc	dc.b	"ContSong",0
mp_gadget12asc	dc.b	"Stop_ ",0
mp_gadget13asc	dc.b	"PlayPat",0
mp_gadget14asc	dc.b	"ContPat",0
mp_gadget15asc	dc.b	"Edit:",0
mp_gadget16asc	dc.b	"Record",0
mp_gadget17asc	dc.b	"ContRec.",0
mp_gadget18asc	dc.b	"Son_g:",0
mp_gadget19asc	dc.b	"Aut_h:",0
mp_gadget20asc	dc.b	"Dat_e:",0
mp_gadget21asc	dc.b	"Ins:",0
mp_gadget22asc	dc.b	"P_os:",0
mp_gadget23asc	dc.b	"_Max:",0
mp_gadget24asc	dc.b	"_Res:",0
mp_gadget31asc	dc.b	"Pa_t:",0
mp_gadget31asc2	dc.b	"_Pat:",0
mp_gadget32asc	dc.b	"Ins",0
mp_gadget33asc	dc.b	"Del",0
mp_gadget49asc	dc.b	"R",0


mp_plusAsc	dc.b	"+",0
mp_minusAsc	dc.b	"-",0

mp_rog1asc	dc.b	"Chipmem:",0
mp_rog2asc	dc.b	"Fastmem:",0
mp_rog3asc	dc.b	"Publicmem:",0
mp_rog4asc	dc.b	"Songmem:",0
mp_rog5asc	dc.b	"Wavemem:",0
mp_rog6asc	dc.b	"Modulemem:",0
		even


***************** ARPEGGIO-EDITOR*********************************
***************** ARPEGGIO-EDITOR*********************************
***************** ARPEGGIO-EDITOR*********************************
***************** ARPEGGIO-EDITOR*********************************
***************** ARPEGGIO-EDITOR*********************************

;----------------------------------------------------- Gadget-Routines
ARP_GADGETROUTINES
		dc.l	0,0,0
ARP_GADGETstructPTRS
		dc.l	string_kind,arp_gadget1,arp_gadget1tags
		dc.l	string_kind,arp_gadget2,arp_gadget2tags
		dc.l	string_kind,arp_gadget3,arp_gadget3tags
		dc.l	string_kind,arp_gadget4,arp_gadget4tags
		dc.l	string_kind,arp_gadget5,arp_gadget5tags
		dc.l	string_kind,arp_gadget6,arp_gadget6tags
		dc.l	string_kind,arp_gadget7,arp_gadget7tags
		dc.l	string_kind,arp_gadget8,arp_gadget8tags
		dc.l	string_kind,arp_gadget9,arp_gadget9tags
		dc.l	string_kind,arp_gadget10,arp_gadget10tags
		dc.l	string_kind,arp_gadget11,arp_gadget11tags
		dc.l	string_kind,arp_gadget12,arp_gadget12tags
		dc.l	string_kind,arp_gadget13,arp_gadget13tags
		dc.l	string_kind,arp_gadget14,arp_gadget14tags
		dc.l	string_kind,arp_gadget15,arp_gadget15tags
		dc.l	string_kind,arp_gadget16,arp_gadget16tags
		dc.l	0,0,0		; Ende der Liste
;-----------------------------------------------------	Gadget-Strukturen
ARP_GADGET1
	dc	80,0*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget1asc,topaz8
	dc	gad_arp0
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget1TAGS
		dc.l	gtst_string,arp_gadget1buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	ga_tabcycle,true
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget1buf	dc.b	"00000000",0
		even
ARP_GADGET2
	dc	230,0*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget2asc,topaz8
	dc	gad_arp1
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget2TAGS
		dc.l	gtst_string,arp_gadget2buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget2buf	dc.b	"00000000",0
		even
ARP_GADGET3
	dc	390,0*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget3asc,topaz8
	dc	gad_arp2
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget3TAGS
		dc.l	gtst_string,arp_gadget3buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget3buf	dc.b	"00000000",0
		even
ARP_GADGET4
	dc	550,0*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget4asc,topaz8
	dc	gad_arp3
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget4TAGS
		dc.l	gtst_string,arp_gadget4buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget4buf	dc.b	"00000000",0
		even
ARP_GADGET5
	dc	80,1*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget5asc,topaz8
	dc	gad_arp4
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget5TAGS
		dc.l	gtst_string,arp_gadget5buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget5buf	dc.b	"00000000",0
		even
ARP_GADGET6
	dc	230,1*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget6asc,topaz8
	dc	gad_arp5
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget6TAGS
		dc.l	gtst_string,arp_gadget6buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget6buf	dc.b	"00000000",0
		even
ARP_GADGET7
	dc	390,1*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget7asc,topaz8
	dc	gad_arp6
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget7TAGS
		dc.l	gtst_string,arp_gadget7buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget7buf	dc.b	"00000000",0
		even
ARP_GADGET8
	dc	550,1*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget8asc,topaz8
	dc	gad_arp7
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget8TAGS
		dc.l	gtst_string,arp_gadget8buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget8buf	dc.b	"00000000",0
		even
ARP_GADGET9
	dc	80,2*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget9asc,topaz8
	dc	gad_arp8
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget9TAGS
		dc.l	gtst_string,arp_gadget9buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget9buf	dc.b	"00000000",0
		even
ARP_GADGET10
	dc	230,2*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget10asc,topaz8
	dc	gad_arp9
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget10TAGS
		dc.l	gtst_string,arp_gadget10buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget10buf	dc.b	"00000000",0
		even
ARP_GADGET11
	dc	390,2*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget11asc,topaz8
	dc	gad_arpa
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget11TAGS
		dc.l	gtst_string,arp_gadget11buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget11buf	dc.b	"00000000",0
		even
ARP_GADGET12
	dc	550,2*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget12asc,topaz8
	dc	gad_arpb
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget12TAGS
		dc.l	gtst_string,arp_gadget12buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget12buf	dc.b	"00000000",0
		even
ARP_GADGET13
	dc	80,3*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget13asc,topaz8
	dc	gad_arpc
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget13TAGS
		dc.l	gtst_string,arp_gadget13buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget13buf	dc.b	"00000000",0
		even
ARP_GADGET14
	dc	230,3*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget14asc,topaz8
	dc	gad_arpd
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget14TAGS
		dc.l	gtst_string,arp_gadget14buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget14buf	dc.b	"00000000",0
		even
ARP_GADGET15
	dc	390,3*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget15asc,topaz8
	dc	gad_arpe
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget15TAGS
		dc.l	gtst_string,arp_gadget15buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget15buf	dc.b	"00000000",0
		even
ARP_GADGET16
	dc	550,3*ghi+gyoff+4,90,ghi
	dc.l	arp_gadget16asc,topaz8
	dc	gad_arpf
	dc.l	PLACETEXT_LEFT
	dc.l	0
ARP_Gadget16TAGS
		dc.l	gtst_string,arp_gadget16buf	; Ptr auf Textpuffer
		dc.l	gtst_maxchars,8		; Maximale Anzahl Zeichen
		dc.l	gt_underscore,"_"
		dc.l	TAG_DONE
arp_gadget16buf	dc.b	"00000000",0
		even

;----------------------------------------------------
arp_gadget1asc	dc.b	"Arp _0",0
arp_gadget2asc	dc.b	"Arp _1",0
arp_gadget3asc	dc.b	"Arp _2",0
arp_gadget4asc	dc.b	"Arp _3",0
arp_gadget5asc	dc.b	"Arp _4",0
arp_gadget6asc	dc.b	"Arp _5",0
arp_gadget7asc	dc.b	"Arp _6",0
arp_gadget8asc	dc.b	"Arp _7",0
arp_gadget9asc	dc.b	"Arp _8",0
arp_gadget10asc	dc.b	"Arp _9",0
arp_gadget11asc	dc.b	"Arp _A",0
arp_gadget12asc	dc.b	"Arp _B",0
arp_gadget13asc	dc.b	"Arp _C",0
arp_gadget14asc	dc.b	"Arp _D",0
arp_gadget15asc	dc.b	"Arp _E",0
arp_gadget16asc	dc.b	"Arp _F",0
		even
;----------------------------------------------------
;*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
DSEQ_GADGETROUTINES
		dc.l	gad_drumseqnr,dseq_seqnrchangeUP,dseq_seqnrchange
		dc.l	gad_drumseqlen,dseq_seqlenchange,dseq_seqlenchange
		dc.l	gad_dseqdelete,dseq_deleteSEQ,0
		dc.l	gad_dseqcut2buffer,dseq_cutseq2buf,0
		dc.l	gad_dseqcopy2buffer,dseq_copyseq2buf,0
		dc.l	gad_dseqpastebuffer,dseq_copybuf2seq,0
		dc.l	gad_dseqoptions0_2,dseq_wfc_ch0,0
		dc.l	gad_dseqoptions1_2,dseq_wfc_ch1,0
		dc.l	gad_dseqoptions2_2,dseq_wfc_ch2,0
		dc.l	gad_dseqoptions3_2,dseq_wfc_ch3,0
		dc.l	gad_dseqoptions4_2,dseq_wfc_ch4,0
		dc.l	gad_dseqoptions5_2,dseq_wfc_ch5,0
		dc.l	gad_dseqoptions6_2,dseq_wfc_ch6,0
		dc.l	gad_dseqoptions7_2,dseq_wfc_ch7,0
		dc.l	gad_dseqoptions8_2,dseq_wfc_ch8,0
		dc.l	gad_dseqoptions9_2,dseq_wfc_ch9,0
		dc.l	gad_dseqoptions10_2,dseq_wfc_cha,0
		dc.l	gad_dseqoptions11_2,dseq_wfc_chb,0
		dc.l	gad_dseqoptions12_2,dseq_wfc_chc,0
		dc.l	gad_dseqoptions13_2,dseq_wfc_chd,0
		dc.l	gad_dseqoptions14_2,dseq_wfc_che,0
		dc.l	gad_dseqoptions15_2,dseq_wfc_chf,0
		dc.l	gad_dseqnote,dseq_enterseqnote,0
		dc.l	gad_dseqspeed,dseq_speedchange,0
		dc.l	gad_dseqtempo,dseq_tempochange,0
		dc.l	gad_dseqdestwave,dseq_destwavechange,0
		dc.l	gad_dseqcompute,dseq_computenow,0
		dc.l	gad_saveseq,dseq_savesequence,0
		dc.l	gad_loadseq,dseq_loadsequence,0
		dc.l	gad_dseqdelnotes,dseq_delnotes,0
		dc.l	0,0,0

DSEQ_GADGETstructPTRS
		dc.l	scroller_kind,dseq_gadget1,dseq_gadget1tags
		dc.l	text_kind,dseq_gadget1txt,dseq_gadget1txttags
		dc.l	scroller_kind,dseq_gadget2,dseq_gadget2tags
		dc.l	text_kind,dseq_gadget2txt,dseq_gadget2txttags
		dc.l	integer_kind,dseq_gadget32,dseq_options2tags
		dc.l	integer_kind,dseq_gadget42,dseq_options2tags
		dc.l	integer_kind,dseq_gadget52,dseq_options2tags
		dc.l	integer_kind,dseq_gadget62,dseq_options2tags
		dc.l	integer_kind,dseq_gadget72,dseq_options2tags
		dc.l	integer_kind,dseq_gadget82,dseq_options2tags
		dc.l	integer_kind,dseq_gadget92,dseq_options2tags
		dc.l	integer_kind,dseq_gadget102,dseq_options2tags
		dc.l	integer_kind,dseq_gadget112,dseq_options2tags
		dc.l	integer_kind,dseq_gadget122,dseq_options2tags
		dc.l	integer_kind,dseq_gadget132,dseq_options2tags
		dc.l	integer_kind,dseq_gadget142,dseq_options2tags
		dc.l	integer_kind,dseq_gadget152,dseq_options2tags
		dc.l	integer_kind,dseq_gadget162,dseq_options2tags
		dc.l	integer_kind,dseq_gadget172,dseq_options2tags
		dc.l	integer_kind,dseq_gadget182,dseq_options2tags

		dc.l	button_kind,dseq_gadget19,underscoretags
		dc.l	button_kind,dseq_gadget20,underscoretags
		dc.l	button_kind,dseq_GAD_delnotes,underscoretags
		dc.l	button_kind,dseq_gadget21,underscoretags
		dc.l	button_kind,dseq_gadget22,underscoretags
		dc.l	button_kind,dseq_gadget23,underscoretags
		dc.l	button_kind,dseq_gadget24,underscoretags
		dc.l	button_kind,dseq_gadget25,underscoretags
		dc.l	integer_kind,dseq_gadget26,dseq_options2tags
		dc.l	integer_kind,dseq_gadget27,dseq_options2tags3
		dc.l	integer_kind,dseq_gadget28,dseq_options2tags
		dc.l	button_kind,dseq_gadget29,underscoretags
		dc.l	number_kind,dseq_gadget30,0

		dc.l	0,0,0		; Ende der Liste
DSEQ_GADGET1
	dc	80,0*ghi+gyoff,80+30,1*ghi
	dc.l	dseq_gadget1asc,topaz8		; Label,textattr
	dc	gad_drumseqnr		; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
DSEQ_gadget1tags
	dc.l	gtsc_total,15+2
	dc.l	gtsc_arrows,14
	dc.l	ga_followmouse,true
	dc.l	ga_relverify,true
	dc.l	ga_immediate,true
	dc.l	tag_done
DSEQ_GADGET1TXT
	dc	160+30,0*ghi+gyoff,30,ghi
	dc.l	0,topaz8
	dc	gad_drumseqnrTXT
	dc.l	PLACETEXT_IN
	dc.l	0
dseq_gadget1txttags
		dc.l	gttx_text,txt_actseqnr
		dc.l	gttx_border,true
		dc.l	tag_done
txt_actseqnr	dc.b	"0",0


DSEQ_GADGET2
	dc	80,1*ghi+gyoff,80+30,1*ghi
	dc.l	dseq_gadget2asc,topaz8
	dc	gad_drumseqlen
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
DSEQ_gadget2tags
	dc.l	gtsc_total,47+2
	dc.l	gtsc_arrows,14
	dc.l	ga_followmouse,true
	dc.l	ga_relverify,true
	dc.l	ga_immediate,true
	dc.l	tag_done
DSEQ_GADGET2TXT
	dc	160+30,1*ghi+gyoff,30,ghi
	dc.l	0,topaz8
	dc	gad_drumseqlenTXT
	dc.l	PLACETEXT_IN
	dc.l	0
dseq_gadget2txttags
		dc.l	gttx_text,txt_seqlen
		dc.l	gttx_border,true
		dc.l	tag_done
txt_seqlen	dc.b	"00",0,0





DSEQ_GADGET32
	dc	180,2*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC2,topaz8
	dc	gad_dseqoptions0_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET42
	dc	180,3*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions1_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET52
	dc	180,4*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions2_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET62
	dc	180,5*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions3_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET72
	dc	180,6*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions4_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET82
	dc	180,7*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions5_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET92
	dc	180,8*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions6_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET102
	dc	180,9*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions7_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET112
	dc	180,10*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions8_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET122
	dc	180,11*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions9_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET132
	dc	180,12*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions10_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET142
	dc	180,13*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions11_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET152
	dc	180,14*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions12_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET162
	dc	180,15*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions13_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET172
	dc	180,16*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions14_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET182
	dc	180,17*ghi+gyoff,40,ghi
	dc.l	dseq_wfcASC,topaz8
	dc	gad_dseqoptions15_2
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_OPTIONS2TAGS
	dc.l	ga_tabcycle,true
	dc.l	gtin_maxchars,2
	dc.l	gt_underscore,"_"
	dc.l	tag_done
DSEQ_OPTIONS2TAGS3
	dc.l	ga_tabcycle,true
	dc.l	gtin_maxchars,3
	dc.l	gt_underscore,"_"
	dc.l	tag_done




DSEQ_GADGET19
	dc	4,17*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget19asc,topaz8
	dc	gad_dseqcompute
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET20
	dc	4,4*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget20asc,topaz8
	dc	gad_dseqdelete
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GAD_DELNOTES
	dc	4,5*ghi+gyoff,140-8,ghi
	dc.l	dseq_delnotesasc,topaz8
	dc	gad_dseqdelnotes
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET21
	dc	4,6*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget21asc,topaz8
	dc	gad_dseqcut2buffer
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET22
	dc	4,7*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget22asc,topaz8
	dc	gad_dseqcopy2buffer
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET23
	dc	4,8*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget23asc,topaz8
	dc	gad_dseqpastebuffer
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET24
	dc	4,2*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget24asc,topaz8
	dc	gad_loadseq
	dc.l	PLACETEXT_IN
	dc.l	0
DSEQ_GADGET25
	dc	4,3*ghi+gyoff,140-8,ghi
	dc.l	dseq_gadget25asc,topaz8
	dc	gad_saveseq
	dc.l	PLACETEXT_IN
	dc.l	0

DSEQ_GADGET26
	dc	80-4,13*ghi+gyoff,60,ghi
	dc.l	dseq_speedasc,topaz8
	dc	gad_dseqspeed
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET27
	dc	80-4,14*ghi+gyoff,60,ghi
	dc.l	dseq_tempoasc,topaz8
	dc	gad_dseqtempo
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET28
	dc	80-4,15*ghi+gyoff,60,ghi
	dc.l	dseq_destwaveasc,topaz8
	dc	gad_dseqdestwave
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET29
	dc	80-4,16*ghi+gyoff,60,ghi
	dc.l	dseq_noteasc,topaz8
	dc	gad_dseqnote
	dc.l	PLACETEXT_LEFT
	dc.l	0
DSEQ_GADGET30
	dc	80-4+12,12*ghi+gyoff,60,ghi
	dc.l	dseq_bytelenasc,topaz8
	dc	gad_dseqbytelen
	dc.l	PLACETEXT_LEFT
	dc.l	0
	


		ifeq	lang
dseq_gadget1asc	dc.b	"Sequence",0
dseq_gadget2asc	dc.b	"Length",0
dseq_gadget3asc	dc.b	"Opt",0
dseq_gadget19asc dc.b	"Comp Se_q",0
dseq_gadget20asc dc.b	"Del Seq",0
dseq_delnotesASC	dc.b	"Del _Notes",0
dseq_gadget21asc dc.b	"Cut Seq>Buf",0
dseq_gadget22asc dc.b	"Copy Seq>Buf",0
dseq_gadget23asc dc.b	"Copy Buf>Seq",0
dseq_gadget24asc dc.b	"_Load Seq",0
dseq_gadget25asc dc.b	"_Save Seq",0
dseq_speedasc	dc.b	"Spee_d",0
dseq_tempoasc	dc.b	"_Tempo",0
dseq_destwaveasc	dc.b	"To _Wave",0
dseq_noteasc	dc.b	"_Pitch",0
dseq_wfcasc	dc.b	"Wave",0
dseq_wfcasc2	dc.b	"Wa_ve",0
dseq_bytelenasc	dc.b	"Bytelen ",0
			even

		else
dseq_gadget1asc	dc.b	"Sequenz",0
dseq_gadget2asc	dc.b	"Länge",0
dseq_gadget3asc	dc.b	"Opt",0
dseq_gadget19asc dc.b	"Berechne Se_q",0
dseq_gadget20asc dc.b	"Lösch Seq",0
dseq_delnotesASC	dc.b	"Lösch _Noten",0
dseq_gadget21asc dc.b	"Cut Seq>Buf",0
dseq_gadget22asc dc.b	"Copy Seq>Buf",0
dseq_gadget23asc dc.b	"Copy Buf>Seq",0
dseq_gadget24asc dc.b	"_Lade Seq",0
dseq_gadget25asc dc.b	"_Speicher Seq",0
dseq_speedasc	dc.b	"Spee_d",0
dseq_tempoasc	dc.b	"_Tempo",0
dseq_destwaveasc	dc.b	"Zu _Wave",0
dseq_noteasc	dc.b	"_Pitch",0
dseq_wfcasc	dc.b	"Wave",0
dseq_wfcasc2	dc.b	"Wa_ve",0
dseq_bytelenasc	dc.b	"Bytelen ",0
			even
		endif
;-------------------------------------------------------------------------!!!!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
; INSTRUMENTEN-EDITOR

INSTRED_gadgetroutines
 dc.l	gad_instrchangeinstrnr,instred_InstrNrChangeUP,instred_InstrNrChange
 dc.l	gad_instrchangevolume,instred_volumeChangeUP,instred_volumeChange
 dc.l	gad_instrchangefinetune,instred_finetuneChangeUP,instred_finetuneChange
 dc.l	gad_instrchangewavenr,instred_waveformChangeUP,instred_waveformChange
 dc.l	gad_instrsamplelen,instred_samplelenchange,0
 dc.l	gad_instrsampleoffset,instred_sampleoffsetchange,0
 dc.l	gad_instrrepeatlen,instred_repeatlenchange,0
 dc.l	gad_instrrepeatoffset,instred_repeatoffsetchange,0
 dc.l	gad_instrchangesampleoffset,instred_sampleoffsetchangeUP,instred_sampleoffsetchange2
 dc.l	gad_instrchangesamplelen,instred_samplelenchangeUP,instred_samplelenchange2
 dc.l	gad_instrchangerepeatoffset,instred_repeatoffsetchangeUP,instred_repeatoffsetchange2
 dc.l	gad_instrchangerepeatlen,instred_repeatlenchangeUP,instred_repeatlenchange2
 dc.l	gad_instrdelete,instred_deleteinstrument,0
; dc.l	gad_instrcut,instred_cutinstrument,0
; dc.l	gad_instrcopy,instred_copyinstrument,0
; dc.l	gad_instrpaste,instred_pasteinstrument,0
 dc.l	gad_instrload,instred_load,0
 dc.l	gad_instrsave,instred_save,0
; dc.l	gad_instrchangecopyfrom,instred_copyfromChangeUP,instred_copyfromchange
; dc.l	gad_instrchangecopyto,instred_copytoChangeUP,instred_copytochange
 dc.l	gad_instrMoveFT,instred_moveFT,0
 dc.l	gad_instrCopyFT,instred_copyFT,0
 dc.l	gad_instrExchangeFT,instred_ExchangeFT,0
 dc.l	gad_instrmode,instred_ModeChange,0
 dc.l	gad_instrWAVEspd,instred_changeWAVEspd,0
 dc.l	gad_instrWAVElen,instred_changeWAVElen,0
 dc.l	gad_instrWAVErep,instred_changeWAVErep,0
 dc.l	gad_instrWAVEreplen,instred_changeWAVEreplen,0
 dc.l	gad_instrVIBdelay,instred_changeVIBdelay,0
 dc.l	gad_instrVIBpara,instred_changeVIBpara,0
 dc.l	gad_instrWAVErepctrl,instred_repctrlChange,0
 dc.l	gad_instrVIBwave,instred_VIBwavechange,0
; dc.l	gad_instrLoadWave,instred_Loadwave,0
; dc.l	gad_instrFlushWave,instred_Flushwave,0
 dc.l	gad_instrsaveall,instred_saveALL,0
 dc.l	gad_instrAstart,instred_changeAstart,0
 dc.l	gad_instrAadd,instred_changeAadd,0
 dc.l	gad_instrAsub,instred_changeAsub,0
 dc.l	gad_instrAend,instred_changeAend,0
 dc.l	gad_instrreturn,togglescreen,0

;dc.l	gad_waveChangewave,waveed_wavechangeUP,waveed_waveChange
	dc.l	gad_waveShowAll,waveed_showall,0
	dc.l	gad_waveShow121,waveed_show121,0
	dc.l	gad_waveChangepos,waveed_poschangeUP,waveed_posChange
	dc.l	gad_waveshowrange,waveed_showrange,0
	dc.l	gad_waverangeall,waveed_rangeall,0
	dc.l	gad_waverangedisplay,waveed_rangedisplay,0
	dc.l	gad_wavedigifilter,waveed_digifilter,0
	dc.l	gad_wavechangevol,waveed_RampVolume,0
	dc.l	gad_wavesettozero,waveed_settozero,0
	dc.l	gad_waveinvert,waveed_invert,0
	dc.l	gad_wavebackwards,waveed_backwards,0
	dc.l	gad_wavemaximize,waveed_maximize,0
	dc.l	gad_waveclrbuf,waveed_clearbuf,0
	dc.l	gad_wavecut,waveed_cutbuf,0
	dc.l	gad_wavecopy,waveed_copybuf,0
	dc.l	gad_wavepaste,waveed_insertbuf,0
	dc.l	gad_waveload,waveed_loadwave,0
	dc.l	gad_wavesave,waveed_savewave,0
;dc.l	gad_wavedelete,waveed_flushwave,0
	dc.l	gad_wavesavebuf,waveed_savebuf,0
	dc.l	gad_waveinvertbuf,waveed_mixwithbuf,0
	dc.l	gad_waveoctup,waveed_upsample,0
	dc.l	gad_waveoctdn,waveed_dnsample,0
;dc.l	gad_waveadjust,waveed_veradjust,0
	dc.l	gad_wavelfo,waveed_phasedistortion,0
;dc.l	gad_waveChangecopyfrom,waveed_copyfromchangeUP,waveed_copyfromChange
;dc.l	gad_waveChangecopyto,waveed_copytochangeUP,waveed_copytoChange
;dc.l	gad_wavemoveFT,waveed_movewave,0
;dc.l	gad_wavecopyFT,waveed_copywave,0
;dc.l	gad_waveexchangeFT,waveed_exchangewave,0
	dc.l	gad_wavepartwave,waveed_partwavechangeUP,waveed_partwavechange
	dc.l	gad_wavepartwaveSIZE,waveed_partwavelenchange,0
	dc.l	gad_wavephaser,waveed_flanger,0
	dc.l	gad_wavey,waveed_Ypos,0
	dc.l	gad_wavesample,waveed_sampleit,0
	dc.l	gad_wavesamplefreq,waveed_samplefreq,0
	dc.l	gad_wavesampledlen,waveed_sampledlen,0
	dc.l	gad_wavetrig,waveed_trig,0
	dc.l	gad_wavecutzeros,waveed_cutzeros,0
	dc.l	gad_wavecreateinstr,waveed_createinstrument,0
	dc.l	gad_wavecreateinstrFIX,waveed_createinstrumentFIX,0
;dc.l	gad_wavedelinstr,instred_deleteinstrument,0
	dc.l	gad_waveeditmode,waveed_togglemode,0
	dc.l	gad_waveinterpol,waveed_digibooster,0
	dc.l	gad_waveresampleDOWN,waveed_resampleDOWN,0
	dc.l	gad_waveresampleUP,waveed_resampleUP,0
	dc.l	gad_waveplayrange,playrange,0
	dc.l	gad_wavepitch,waveed_changepitch,0
	dc.l	gad_waveboost,waveed_interpolfilter,0
	dc.l	gad_wavestop,equ_resetchannels,0
	dc.l	gad_wavezoom,waveed_zoom,0
	dc.l	gad_wavetele,waveed_tele,0
	dc.l	gad_wavenoiselimiter,waveed_lopass,0
	dc.l	gad_wavemixwithbuf,waveed_hipass,0
	dc.l	gad_wavelopass,waveed_wrap,0
	dc.l	gad_wavegainADD,waveed_gainadd,0
	dc.l	gad_wavegainSUB,waveed_gainSUB,0
		dc.l	0,0,0


INSTRED_GADGETstructPTRS
		dc.l	scroller_kind,instred_gad_changeinstrnr,mp_gadget39tags
		dc.l	text_kind,instred_gad_changeinstrnrTXT,instred_gad_changeinstrnrTXTtags
		dc.l	string_kind,instred_gad_instrname,instred_gad_instrnametags
		dc.l	scroller_kind,instred_gad_changewavenr,instred_gad_changewavenrtags
		dc.l	text_kind,instred_gad_changewavenrTXT,instred_gad_changewavenrTXTtags
		dc.l	integer_kind,instred_gad_sampleoffset,instred_gad_sampleoffsettags
		dc.l	integer_kind,instred_gad_samplelen,instred_gad_sampleoffsettags
		dc.l	integer_kind,instred_gad_repeatoffset,instred_gad_sampleoffsettags
		dc.l	integer_kind,instred_gad_repeatlen,instred_gad_sampleoffsettags
		dc.l	scroller_kind,instred_gad_changevolume,instred_gad_changevolumetags
		dc.l	text_kind,instred_gad_changevolumeTXT,instred_gad_changevolumeTXTtags
		dc.l	scroller_kind,instred_gad_changefinetune,instred_gad_changefinetunetags
		dc.l	text_kind,instred_gad_changefinetuneTXT,instred_gad_changefinetuneTXTtags
		dc.l	cycle_kind,instred_gad_instrmode,instred_gad_instrmodetags
		dc.l	scroller_kind,instred_gad_changesampleoffset,instred_gad_changesampleoffsettags
		dc.l	scroller_kind,instred_gad_changesamplelen,instred_gad_changesampleoffsettags
		dc.l	scroller_kind,instred_gad_changerepeatoffset,instred_gad_changesampleoffsettags
		dc.l	scroller_kind,instred_gad_changerepeatlen,instred_gad_changesampleoffsettags
		dc.l	button_kind,instred_gad_load,underscoretags
		dc.l	button_kind,instred_gad_save,underscoretags
		dc.l	button_kind,instred_gad_delete,0
;	dc.l	button_kind,instred_gad_cut,0
;	dc.l	button_kind,instred_gad_copy,0
;	dc.l	button_kind,instred_gad_paste,0
;	dc.l	scroller_kind,instred_gad_changeCopyFrom,mp_gadget39tags
;	dc.l	text_kind,instred_gad_changeCopyFromTXT,instred_gad_changeCopyToTXTtags
;	dc.l	scroller_kind,instred_gad_changeCopyTo,mp_gadget39tags
;	dc.l	text_kind,instred_gad_changeCopytoTXT,instred_gad_changeCopyToTXTtags
		dc.l	button_kind,instred_gad_moveFT,0
		dc.l	button_kind,instred_gad_copyFT,0
		dc.l	button_kind,instred_gad_exchangeFT,0
		dc.l	integer_kind,instred_gad_synthspd,instred_gad_synthbytetags
		dc.l	integer_kind,instred_gad_synthlen,instred_gad_synthbytetags
		dc.l	integer_kind,instred_gad_synthrep,instred_gad_synthbytetags
		dc.l	integer_kind,instred_gad_synthreplen,instred_gad_synthbytetags
		dc.l	cycle_kind,instred_gad_synthrepctrl,instred_gad_synthrepctrltags
		dc.l	integer_kind,instred_gad_vibdelay,instred_gad_synthbytetags
		dc.l	string_kind,instred_gad_vibpara,instred_gad_vibparatags
		dc.l	cycle_kind,instred_gad_VIBwave,instred_gad_VIBwavetags
;	dc.l	button_kind,instred_gad_loadwave,underscoretags
;	dc.l	button_kind,instred_gad_flushwave,underscoretags
		dc.l	button_kind,instred_gad_saveALL,0
	dc.l	integer_kind,instred_gad_Astart,instred_gad_synthbytetags
	dc.l	integer_kind,instred_gad_Aadd,instred_gad_synthbytetags
	dc.l	integer_kind,instred_gad_Asub,instred_gad_synthbytetags
	dc.l	integer_kind,instred_gad_Aend,instred_gad_synthbytetags
	dc.l	button_kind,instred_gad_return,0
	dc.l	button_kind,instred_gad_mixFT,mp_disabledtags


	dc.l	number_kind,waveed_gad_wavelentxt,0
	dc.l	button_kind,waveed_gad_load,underscoretags
	dc.l	button_kind,waveed_gad_save,underscoretags
;dc.l	button_kind,waveed_gad_delete,0
	dc.l	button_kind,waveed_gad_cut,0
	dc.l	button_kind,waveed_gad_copy,0
	dc.l	button_kind,waveed_gad_paste,0
	dc.l	button_kind,waveed_gad_savebuf,0
	dc.l	button_kind,waveed_gad_clrbuf,0
	dc.l	button_kind,waveed_gad_invertbuf,0
;dc.l	scroller_kind,waveed_gad_changeCopyFrom,waveed_gad_changecopyfromtags
;dc.l	text_kind,waveed_gad_changeCopyFromTXT,waveed_gad_changeCopyToTXTtags
;dc.l	scroller_kind,waveed_gad_changeCopyTo,waveed_gad_changecopyfromtags
;dc.l	text_kind,waveed_gad_changeCopytoTXT,waveed_gad_changeCopyToTXTtags
;dc.l	button_kind,waveed_gad_moveFT,0
;dc.l	button_kind,waveed_gad_copyFT,0
;dc.l	button_kind,waveed_gad_exchangeFT,0
	dc.l	number_kind,waveed_gad_wavedisplaylenTXT,0
	dc.l	number_kind,waveed_gad_waverangelenTXT,0
	dc.l	number_kind,waveed_gad_waveposTXT,0
	dc.l	button_kind,waveed_gad_waveshowrange,0
	dc.l	button_kind,waveed_gad_waveZoom,0
	dc.l	button_kind,waveed_gad_waveTele,0
;dc.l	button_kind,waveed_gad_playwave,0
;dc.l	button_kind,waveed_gad_playdisplay,0
	dc.l	button_kind,waveed_gad_playrange,0
	dc.l	button_kind,waveed_gad_rangedisplay,0
	dc.l	button_kind,waveed_gad_stop,0
	dc.l	button_kind,waveed_gad_showall,0
	dc.l	button_kind,waveed_gad_show121,0
	dc.l	button_kind,waveed_gad_rangeall,0
	dc.l	cycle_kind,waveed_gad_editmode,waveed_gad_editmodeTAGS
	dc.l	scroller_kind,waveed_gad_partwave,waveed_gad_partwavetags
	dc.l	text_kind,waveed_gad_partwaveTXT,waveed_gad_partwaveTXTtags
	dc.l	integer_kind,waveed_gad_partwaveSIZE,instred_gad_SYNTHbytetags
	dc.l	button_kind,waveed_gad_settozero,0
	dc.l	button_kind,waveed_gad_changevol,0
	dc.l	button_kind,waveed_gad_phaser,0
	dc.l	button_kind,waveed_gad_boost,0
	dc.l	button_kind,waveed_gad_interpol,0
	dc.l	button_kind,waveed_gad_octup,0
	dc.l	button_kind,waveed_gad_octdn,0
	dc.l	button_kind,waveed_gad_invert,0
	dc.l	button_kind,waveed_gad_backwards,0
	dc.l	button_kind,waveed_gad_y,0
	dc.l	button_kind,waveed_gad_noiselimiter,0
	dc.l	button_kind,waveed_gad_digifilter,0
	dc.l	button_kind,waveed_gad_resampleDOWN,0
	dc.l	button_kind,waveed_gad_resampleUP,0
;dc.l	button_kind,waveed_gad_hipass,0
	dc.l	button_kind,waveed_gad_lopass,0
	dc.l	button_kind,waveed_gad_lfo,0
	dc.l	button_kind,waveed_gad_mixwithbuf,0
	dc.l	button_kind,waveed_gad_maximize,0
	dc.l	button_kind,waveed_gad_cutzeros,0
;dc.l	scroller_kind,waveed_gad_changeWave,waveed_gad_changeCopyFromTAGS
	dc.l	text_kind,waveed_gad_changeWaveTXT,waveed_gad_changeWaveTXTtags
	dc.l	scroller_kind,waveed_gad_changePos,waveed_gad_changePostags
;dc.l	button_kind,waveed_gad_adjust,0
	dc.l	button_kind,waveed_gad_sample,0
	dc.l	integer_kind,waveed_gad_samplefreq,waveed_gad_samplefreqtags
	dc.l	integer_kind,waveed_gad_sampledlen,waveed_gad_sampledlentags
	dc.l	integer_kind,waveed_gad_trig,waveed_gad_trigtags
	dc.l	button_kind,waveed_gad_createinstr,0
	dc.l	button_kind,waveed_gad_createinstrFIX,0
;dc.l	button_kind,waveed_gad_delinstr,0
	dc.l	button_kind,waveed_gad_pitch,0
	dc.l	number_kind,waveed_gad_GainTXT,0
	dc.l	button_kind,waveed_gad_gainADD,0
	dc.l	button_kind,waveed_gad_gainSUB,0
	dc.l	button_kind,waveed_gad_rangeLoop,MP_disabledTags
	dc.l	button_kind,waveed_gad_seekzero,MP_disabledTags
	dc.l	button_kind,waveed_gad_Echo,MP_disabledTags
	dc.l	button_kind,waveed_gad_Vibrato,MP_disabledTags
	dc.l	button_kind,waveed_gad_FM,MP_disabledTags
	dc.l	button_kind,waveed_gad_NormalDC,MP_disabledTags
	dc.l	button_kind,waveed_gad_HQHPF,MP_disabledTags
	dc.l	button_kind,waveed_gad_add,MP_disabledTags
	dc.l	button_kind,waveed_gad_sub,MP_disabledTags
	dc.l	button_kind,waveed_gad_mul,MP_disabledTags
	dc.l	button_kind,waveed_gad_mix,MP_disabledTags
	dc.l	button_kind,waveed_gad_AM,MP_disabledTags
	dc.l	button_kind,waveed_gad_logicFREE,MP_disabledTags
	dc.l	button_kind,waveed_gad_hardSync,MP_disabledTags
	dc.l	button_kind,waveed_gad_wave2wt,MP_disabledTags
	dc.l	button_kind,waveed_gad_wt2wave,MP_disabledTags
	dc.l	button_kind,waveed_gad_variousfree,MP_disabledTags
	dc.l	button_kind,waveed_gad_addspace,MP_disabledTags
	dc.l	button_kind,waveed_gad_timewrap,MP_disabledTags
	dc.l	button_kind,waveed_gad_pitchCng,MP_disabledTags

		dc.l	0,0,0


INSTRED_GAD_changeinstrnr
	dc	140,1*ghi+gyoff,160,ghi
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangeinstrnr	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
INSTRED_GAD_changeinstrnrTXT
	dc	100,1*ghi+gyoff,40,ghi
	dc.l	instred_instrnrASC,topaz8
	dc	gad_instrchangeinstrnrTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
INSTRED_GAD_changeinstrnrTXTtags
		dc.l	gttx_text,txt_instredactinstrnr
		dc.l	gttx_border,true
		dc.l	tag_done
txt_instredactinstrnr	dc.b	"1",0


instred_gad_instrname
	dc	40,0*ghi+gyoff,260,ghi
	dc.l	0,topaz8
	dc	gad_instredname
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_instrnametags
		dc.l	gtst_string,0			; Ptr auf Textpuffer
		dc.l	gtst_maxchars,32	; Maximale Anzahl Zeichen
		dc.l	TAG_DONE
instred_gad_changewavenr
	dc	140,2*ghi+gyoff,160,ghi
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangewavenr	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
instred_gad_changewavenrTAGS
		dc.l	gtsc_total,65
		dc.l	gtsc_arrows,14
		dc.l	ga_followmouse,true
		dc.l	ga_relverify,true
		dc.l	ga_immediate,true
		dc.l	tag_done
instred_gad_changewavenrtxt
	dc	100,2*ghi+gyoff,40,ghi
	dc.l	instred_wavenrASC,topaz8
	dc	gad_instrchangewavenrTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_changewavenrtxttags
		dc.l	gttx_text,txt_instredactwavenr
		dc.l	gttx_border,true
		dc.l	tag_done
txt_instredactwavenr	dc.b	"00",0,0

instred_gad_sampleoffset
	dc	440,1*ghi+gyoff,70,ghi
	dc.l	instred_sampleoffsetASC,topaz8
	dc	gad_instrsampleoffset
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_sampleoffsettags
		dc.l	ga_tabcycle,true
		dc.l	gtin_maxchars,6
		dc.l	stringa_replacemode,true
		dc.l	tag_done

instred_gad_samplelen
	dc	570,1*ghi+gyoff,70,ghi
	dc.l	instred_samplelenASC,topaz8
	dc	gad_instrsamplelen
	dc.l	PLACETEXT_LEFT
	dc.l	0

instred_gad_repeatoffset
	dc	440,2*ghi+gyoff,70,ghi
	dc.l	instred_repeatoffsetASC,topaz8
	dc	gad_instrrepeatoffset
	dc.l	PLACETEXT_LEFT
	dc.l	0

instred_gad_repeatlen
	dc	570,2*ghi+gyoff,70,ghi
	dc.l	instred_repeatlenASC,topaz8
	dc	gad_instrrepeatlen
	dc.l	PLACETEXT_LEFT
	dc.l	0

instred_gad_changevolume
	dc	140,3*ghi+gyoff,160,ghi
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangevolume	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
instred_gad_changevolumeTAGS
		dc.l	gtsc_total,66
		dc.l	gtsc_arrows,14
		dc.l	ga_followmouse,true
		dc.l	ga_relverify,true
		dc.l	ga_immediate,true
		dc.l	tag_done
instred_gad_changevolumetxt
	dc	100,3*ghi+gyoff,40,ghi
	dc.l	instred_volumeASC,topaz8
	dc	gad_instrchangevolumeTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_changevolumetxtTAGS
		dc.l	gttx_text,txt_instredactvolume
		dc.l	gttx_border,true
		dc.l	tag_done
txt_instredactvolume	dc.b	"00",0,0

instred_gad_changefinetune
	dc	140,4*ghi+gyoff,160,ghi
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangefinetune	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
instred_gad_changefinetuneTAGS
		dc.l	gtsc_total,17
		dc.l	gtsc_arrows,14
		dc.l	ga_followmouse,true
		dc.l	ga_relverify,true
		dc.l	ga_immediate,true
		dc.l	tag_done
instred_gad_changefinetunetxt
	dc	100,4*ghi+gyoff,40,ghi
	dc.l	instred_finetuneASC,topaz8
	dc	gad_instrchangefinetuneTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_changefinetunetxtTAGS
		dc.l	gttx_text,txt_instredactfinetune
		dc.l	gttx_border,true
		dc.l	tag_done
txt_instredactfinetune	dc.b	"+0",0,0


instred_gad_instrmode
	dc	0,5*ghi+gyoff,300,ghi
	dc.l	0,topaz8
	dc	gad_instrmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_instrmodeTAGS
	dc.l	gtcy_labels,instred_modes
	dc.l	tag_done
instred_modes	dc.l	.mode1
		dc.l	.mode2
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Sample (8Bit)",0
.mode2		dc.b	"Wavetable Synthesis (8Bit)",0
		else
.mode1		dc.b	"Sample (8Bit)",0
.mode2		dc.b	"Wavetable Synthese (8Bit)",0
		endif
		even

instred_gad_changesampleoffset
	dc	0,14*ghi+gyoff-5-6-instred_dispoff,640,8
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangesampleoffset	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
instred_gad_changesampleoffsetTAGS
		dc.l	gtsc_total,$2002
		dc.l	ga_followmouse,true
		dc.l	ga_relverify,true
		dc.l	ga_immediate,true
		dc.l	tag_done
instred_gad_changesamplelen
	dc	0,14*ghi+gyoff+8-5-6-instred_dispoff,640,8
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangesamplelen	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData

instred_gad_changerepeatoffset
	dc	0,20*ghi+gyoff+5-6-instred_dispoff,640,8
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangerepeatoffset	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData
instred_gad_changerepeatlen
	dc	0,20*ghi+gyoff+8+5-6-instred_dispoff,640,8
	dc.l	0,topaz8	; Label,textattr
	dc	gad_instrchangerepeatlen	; Gadget-ID
	dc.l	PLACETEXT_LEFT		; Center Text!
	dc.l	0			; VisualInfo
	dc.l	0			; UserData

instred_gad_load
	dc	0,6*ghi+gyoff,200,ghi
	dc.l	instred_loadASC,topaz8
	dc	gad_instrload
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_save
	dc	0,7*ghi+gyoff,200,ghi
	dc.l	instred_saveASC,topaz8
	dc	gad_instrsave
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_saveALL
	dc	0,8*ghi+gyoff,200,ghi
	dc.l	instred_saveALLASC,topaz8
	dc	gad_instrsaveALL
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_delete
	dc	0,9*ghi+gyoff,200,ghi
	dc.l	instred_deleteASC,topaz8
	dc	gad_instrdelete
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;instred_gad_cut
;	dc	200,6*ghi+gyoff,100,ghi
;	dc.l	instred_cutASC,topaz8
;	dc	gad_instrCut
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
;instred_gad_copy
;	dc	200,7*ghi+gyoff,100,ghi
;	dc.l	instred_copyASC,topaz8
;	dc	gad_instrcopy
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
;instred_gad_paste
;	dc	200,8*ghi+gyoff,100,ghi
;	dc.l	instred_pasteASC,topaz8
;	dc	gad_instrpaste
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
;instred_gad_changeCopyFrom
;	dc	140,7*ghi+gyoff,160,ghi
;	dc.l	0,topaz8	; Label,textattr
;	dc	gad_instrchangeCopyFrom	; Gadget-ID
;	dc.l	PLACETEXT_LEFT		; Center Text!
;	dc.l	0			; VisualInfo
;	dc.l	0			; UserData
;instred_gad_changeCopyFromTAGS
;		dc.l	gtsc_total,63
;		dc.l	ga_followmouse,true
;		dc.l	ga_relverify,true
;		dc.l	ga_immediate,true
;		dc.l	tag_done
;instred_gad_changeCopyFromTXT
;	dc	100,7*ghi+gyoff,40,ghi
;	dc.l	instred_copyfromASC,topaz8
;	dc	gad_instrchangeCopyFromTXT
;	dc.l	PLACETEXT_LEFT
;	dc.l	0
;instred_gad_changeCopyFromTXTtags
;		dc.l	gttx_text,txt_instredactcopyfrom
;		dc.l	gttx_border,true
;		dc.l	tag_done
;txt_instredactcopyfrom	dc.b	" ",0
;
;instred_gad_changeCopyto
;	dc	140,8*ghi+gyoff,160,ghi
;	dc.l	0,topaz8	; Label,textattr
;	dc	gad_instrchangeCopyto	; Gadget-ID
;	dc.l	PLACETEXT_LEFT		; Center Text!
;	dc.l	0			; VisualInfo
;	dc.l	0			; UserData
;instred_gad_changeCopytoTXT
;	dc	100,8*ghi+gyoff,40,ghi
;	dc.l	instred_copytoASC,topaz8
;	dc	gad_instrchangeCopytoTXT
;	dc.l	PLACETEXT_LEFT
;	dc.l	0
;instred_gad_changeCopytoTXTtags
;		dc.l	gttx_text,txt_instredactcopyto
;		dc.l	gttx_border,true
;		dc.l	tag_done
;txt_instredactcopyto	dc.b	" ",0

instred_gad_moveFT
	dc	200,6*ghi+gyoff,100,ghi
	dc.l	instred_moveFTASC,topaz8
	dc	gad_instrmoveFT
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_copyFT
	dc	200,7*ghi+gyoff,100,ghi
	dc.l	instred_copyFTASC,topaz8
	dc	gad_instrCopyFT
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_exchangeFT
	dc	200,8*ghi+gyoff,100,ghi
	dc.l	instred_exchangeFTASC,topaz8
	dc	gad_instrExchangeFT
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
instred_gad_mixFT
	dc	200,9*ghi+gyoff,100,ghi
	dc.l	instred_mixFTASC,topaz8
	dc	gad_instrMixFT
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0

;/////////////////////////// synthetisch \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;/////////////////////////// sYNTHETISCh \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;/////////////////////////// sYNTHETISCh \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;/////////////////////////// synthetisch \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
instred_gad_SYNTHbytetags
		dc.l	gt_underscore,"_"
		dc.l	ga_tabcycle,true
		dc.l	gtin_maxchars,3
		dc.l	stringa_replacemode,true
		dc.l	tag_done
instred_gad_SYNTHspd
	dc	440,4*ghi+gyoff,70,ghi
	dc.l	instred_synthspdASC,topaz8
	dc	gad_instrWAVEspd
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_SYNTHlen
	dc	570,4*ghi+gyoff,70,ghi
	dc.l	instred_adsrlenASC,topaz8
	dc	gad_instrWAVElen
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_SYNTHrep
	dc	440,5*ghi+gyoff,70,ghi
	dc.l	instred_adsrrepASC,topaz8
	dc	gad_instrWAVErep
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_SYNTHreplen
	dc	570,5*ghi+gyoff,70,ghi
	dc.l	instred_adsrlenASC,topaz8
	dc	gad_instrWAVEreplen
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_SYNTHrepctrl
	dc	440,6*ghi+gyoff,200,ghi
	dc.l	instred_SYNTHrepctrlASC,topaz8
	dc	gad_instrWAVErepctrl
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_synthrepctrlTAGS
	dc.l	gtcy_labels,instred_synthrepctrlmodes
	dc.l	tag_done
instred_synthrepctrlmodes
		dc.l	.mode1
		dc.l	.mode2
		dc.l	.mode3
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Forward",0
.mode2		dc.b	"Backward",0
.mode3		dc.b	"Alternate",0
		else
.mode1		dc.b	"Vorwärts",0
.mode2		dc.b	"Rückwärts",0
.mode3		dc.b	"Abwechselnd",0
		endif
		even
instred_gad_VIBDelay
	dc	440,7*ghi+gyoff,35,ghi
	dc.l	instred_vibdelayASC,topaz8
	dc	gad_instrVIBdelay
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_VIBpara
	dc	475,7*ghi+gyoff,35,ghi
	dc.l	0,topaz8
	dc	gad_instrVIBpara
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_VIBparatags
		dc.l	ga_tabcycle,true
		dc.l	gtst_maxchars,2
		dc.l	stringa_replacemode,true
		dc.l	gtst_string,instred_actvibparaASC
		dc.l	tag_done
instred_actVIBparaASC	dc.b	"00",0,0

instred_gad_VIBwave
	dc	570,7*ghi+gyoff,70,ghi
	dc.l	instred_vibWaveASC,topaz8
	dc	gad_instrVIBwave
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_VIBwaveTAGS
	dc.l	gtcy_labels,instred_VIBwaves
	dc.l	tag_done
instred_VIBwaves
		dc.l	.mode1
		dc.l	.mode2
		dc.l	.mode3
		dc.l	.mode4
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Sine",0
.mode2		dc.b	"/\/",0
.mode3		dc.b	"Ż|_",0
.mode4		dc.b	"Off",0
		else
.mode1		dc.b	"Sinus",0
.mode2		dc.b	"/\/",0
.mode3		dc.b	"Ż|_",0
.mode4		dc.b	"Aus",0
		endif
		even
; ///////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

;instred_gad_loadwave
;	dc	4+280+66+68+66,7*ghi+gyoff,152,ghi*2
;	dc.l	instred_loadwaveASC,topaz8
;	dc	gad_instrLoadwave
;	dc.l	PLACETEXT_IN
;	dc.l	0
;instred_gad_flushwave
;	dc	4+280+66+68+66,9*ghi+gyoff,152,ghi
;	dc.l	instred_flushwaveASC,topaz8
;	dc	gad_instrFlushwave
;	dc.l	PLACETEXT_IN
;	dc.l	0
instred_gad_Astart
	dc	300+20,9*ghi+gyoff,65,ghi
	dc.l	instred_AstartASC,topaz8
	dc	gad_instrAstart
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_Aadd
	dc	300+105,9*ghi+gyoff,65,ghi
	dc.l	instred_AaddASC,topaz8
	dc	gad_instrAadd
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_Asub
	dc	300+190,9*ghi+gyoff,65,ghi
	dc.l	instred_AsubASC,topaz8
	dc	gad_instrAsub
	dc.l	PLACETEXT_LEFT
	dc.l	0
instred_gad_Aend
	dc	300+275,9*ghi+gyoff,65,ghi
	dc.l	instred_AendASC,topaz8
	dc	gad_instrAend
	dc.l	PLACETEXT_LEFT
	dc.l	0
	
*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
*############################################################################*
*----------------------------------------------------------------------------*


waveed_gad_wavelenTXT
	dc	166,0*ghi+wgoff,60,ghi
	dc.l	waveed_wavelenASC,topaz8
	dc	gad_wavewavelenTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0

waveed_gad_wavedisplaylenTXT
	dc	300,0*ghi+wgoff,60,ghi
	dc.l	waveed_displaylenASC,topaz8
	dc	gad_wavedisplaylenTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_waveposTXT
	dc	400,0*ghi+wgoff,60,ghi
	dc.l	waveed_posASC,topaz8
	dc	gad_waveposTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_waverangelenTXT
	dc	516,0*ghi+wgoff,60,ghi
	dc.l	waveed_rangelenASC,topaz8
	dc	gad_waverangelenTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_gainTXT
	dc	622,0*ghi+wgoff,10,ghi
	dc.l	waveed_gainASC,topaz8
	dc	gad_waveGainTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_gainADD
	dc	5*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_gainADDASC,topaz8
	dc	gad_wavegainADD
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_gainSUB
	dc	6*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_gainSUBASC,topaz8
	dc	gad_wavegainSUB
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0

waveed_gad_load
	dc	80*7,3*ghi+wgoff,80,ghi
	dc.l	waveed_loadASC,topaz8
	dc	gad_waveload
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_save
	dc	80*7,4*ghi+wgoff,80,ghi
	dc.l	waveed_saveASC,topaz8
	dc	gad_wavesave
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;waveed_gad_delete
;	dc	0,0,160,ghi
;	dc.l	waveed_deleteASC,topaz8
;	dc	gad_wavedelete
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
waveed_gad_cut
	dc	1*80,3*ghi+wgoff,80,ghi
	dc.l	instred_cutASC,topaz8
	dc	gad_waveCut
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_copy
	dc	1*80,4*ghi+wgoff,80,ghi
	dc.l	instred_copyASC,topaz8
	dc	gad_wavecopy
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_paste
	dc	1*80,5*ghi+wgoff,80,ghi
	dc.l	instred_pasteASC,topaz8
	dc	gad_wavepaste
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_savebuf
	dc	1*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_savebufASC,topaz8
	dc	gad_wavesavebuf
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_clrbuf
	dc	1*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_clrbufASC,topaz8
	dc	gad_waveclrbuf
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_invertbuf
	dc	1*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_invertbufASC,topaz8
	dc	gad_waveinvertbuf
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;waveed_gad_changeCopyFrom
;	dc	0,0,160,ghi
;	dc.l	0,topaz8	; Label,textattr
;	dc	gad_wavechangeCopyFrom	; Gadget-ID
;	dc.l	PLACETEXT_LEFT		; Center Text!
;	dc.l	0			; VisualInfo
;	dc.l	0			; UserData
;waveed_gad_changeCopyFromTAGS
;	dc.l	gtsc_total,65
;	dc.l	gtsc_arrows,14
;	dc.l	ga_followmouse,true
;	dc.l	ga_relverify,true
;	dc.l	ga_immediate,true
;	dc.l	tag_done
;waveed_gad_changeCopyFromTXT
;	dc	0,0,40,ghi
;	dc.l	instred_copyfromASC,topaz8
;	dc	gad_wavechangeCopyFromTXT
;	dc.l	PLACETEXT_LEFT
;	dc.l	0
waveed_gad_changeCopyFromTXTtags
		dc.l	gttx_text,txt_waveedactcopyfrom
		dc.l	gttx_border,true
		dc.l	tag_done
txt_waveedactcopyfrom	dc.b	"  ",0,0

;waveed_gad_changeCopyto
;	dc	0,0,160,ghi
;	dc.l	0,topaz8	; Label,textattr
;	dc	gad_wavechangeCopyto	; Gadget-ID
;	dc.l	PLACETEXT_LEFT		; Center Text!
;	dc.l	0			; VisualInfo
;	dc.l	0			; UserData
;waveed_gad_changeCopytoTXT
;	dc	0,0,40,ghi
;	dc.l	instred_copytoASC,topaz8
;	dc	gad_wavechangeCopytoTXT
;	dc.l	PLACETEXT_LEFT
;	dc.l	0
;waveed_gad_changeCopytoTXTtags
;		dc.l	gttx_text,txt_waveedactcopyto
;		dc.l	gttx_border,true
;		dc.l	tag_done
;txt_waveedactcopyto	dc.b	"  ",0,0

;waveed_gad_moveFT
;	dc	0,0,66,ghi
;	dc.l	instred_moveFTASC,topaz8
;	dc	gad_wavemoveFT
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
;waveed_gad_copyFT
;	dc	0,0,68,ghi
;	dc.l	instred_copyFTASC,topaz8
;	dc	gad_waveCopyFT
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
;waveed_gad_exchangeFT
;	dc	0,0,66,ghi
;	dc.l	instred_exchangeFTASC,topaz8
;	dc	gad_waveExchangeFT
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0

waveed_gad_waveshowrange
	dc	1*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_showrangeASC,topaz8
	dc	gad_waveshowrange
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_waveZoom
	dc	3*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_zoomASC,topaz8
	dc	gad_wavezoom
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_waveTele
	dc	4*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_teleASC,topaz8
	dc	gad_wavetele
	dc.l	PLACETEXT_IN
	dc.l	0
;waveed_gad_playwave
;	dc	0,0,80,ghi
;	dc.l	waveed_playASC,topaz8
;	dc	gad_waveplaywave
;	dc.l	PLACETEXT_IN
;	dc.l	0
;waveed_gad_playdisplay
;	dc	0,0,80,ghi
;	dc.l	waveed_playASC,topaz8
;	dc	gad_waveplaydisplay
;	dc.l	PLACETEXT_IN
;	dc.l	0
waveed_gad_playrange
	dc	0*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_playrangeASC,topaz8
	dc	gad_waveplayrange
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_rangedisplay
	dc	0*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_rangedisplayASC,topaz8
	dc	gad_waverangedisplay
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_rangeALL
	dc	0*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_rangeALLASC,topaz8
	dc	gad_waverangeALL
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_rangeLoop
	dc	0*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_rangeLoopASC,topaz8
	dc	gad_waverangeLoop
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_seekzero
	dc	7*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_seekzeroASC,topaz8
	dc	gad_waveSeekZero
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_stop
	dc	0*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_stopASC,topaz8
	dc	gad_wavestop
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_showall
	dc	0*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_showallASC,topaz8
	dc	gad_waveshowall
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_show121
	dc	2*80,1*ghi+wgoff,80,ghi
	dc.l	waveed_show121ASC,topaz8
	dc	gad_waveshow121
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_editmode
	dc	0*80,6*ghi+wgoff,80,ghi
	dc.l	0,topaz8
	dc	gad_waveeditmode
	dc.l	PLACETEXT_IN
	dc.l	0
waveed_gad_editmodeTAGS
	dc.l	gtcy_labels,.labels
	dc.l	tag_done
.labels	dc.l	.l1
	dc.l	.l2
;dc.l	.l3
	dc.l	0
	ifeq	lang
.l1	dc.b	"Range",0
.l2	dc.b	"Paint",0
	else
.l1	dc.b	"Range",0
.l2	dc.b	"Malen",0
	endif

;.l3	dc.b	"Linedraw Editmode",0
	even

waveed_gad_partwave
	dc	120,10*ghi+wgoff,200,ghi
	dc.l	0,topaz8
	dc	gad_wavepartwave
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
waveed_gad_partwavetags
	dc.l	gtsc_total,257
	dc.l	gtsc_arrows,14
	dc.l	ga_followmouse,true
	dc.l	ga_relverify,true
	dc.l	ga_immediate,true
	dc.l	tag_done

waveed_gad_partwaveTXT
	dc	1*80,10*ghi+wgoff,40,ghi
	dc.l	waveed_partwaveASC,topaz8
	dc	gad_wavepartwaveTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_partwaveTXTtags
		dc.l	gttx_text,txt_waveedactpartwave
		dc.l	gttx_border,true
		dc.l	tag_done
txt_waveedactpartwave	dc.b	"000",0

waveed_gad_partwaveSIZE
	dc	40,11*ghi+wgoff,40,ghi
	dc.l	waveed_pwsizeASC,topaz8	; Label,textattr
	dc	gad_wavepartwaveSIZE
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0

waveed_gad_settozero
	dc	3*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_settozeroASC,topaz8
	dc	gad_wavesettozero
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_changevol
	dc	5*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_changevolASC,topaz8
	dc	gad_wavechangevol
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_phaser
	dc	3*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_phaserASC,topaz8
	dc	gad_wavephaser
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_boost
	dc	6*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_boostASC,topaz8
	dc	gad_waveboost
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_interpol
	dc	6*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_interpolASC,topaz8
	dc	gad_waveinterpol
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_octup
	dc	2*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_octupASC,topaz8
	dc	gad_waveoctup
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_octdn
	dc	2*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_octdnASC,topaz8
	dc	gad_waveoctdn
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_invert
	dc	5*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_invertASC,topaz8
	dc	gad_waveinvert
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_backwards
	dc	5*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_backwardsASC,topaz8
	dc	gad_wavebackwards
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_y
	dc	3*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_yASC,topaz8
	dc	gad_wavey
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_noiselimiter
	dc	6*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_noiselimiterASC,topaz8
	dc	gad_wavenoiselimiter
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_digifilter
	dc	6*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_digifilterASC,topaz8
	dc	gad_wavedigifilter
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_resampleDOWN
	dc	2*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_resampleDOWNASC,topaz8
	dc	gad_waveresampleDOWN
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_resampleUP
	dc	2*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_resampleUPASC,topaz8
	dc	gad_waveresampleUP
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;waveed_gad_hipass
;	dc	0,0,80,ghi
;	dc.l	waveed_hipassASC,topaz8
;	dc	gad_wavehipass
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
waveed_gad_lopass
	dc	3*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_lopassASC,topaz8
	dc	gad_wavelopass
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_lfo
	dc	3*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_lfoASC,topaz8
	dc	gad_wavelfo
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_mixwithbuf
	dc	6*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_mixwithbufASC,topaz8
	dc	gad_wavemixwithbuf
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_maximize
	dc	5*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_maximizeASC,topaz8
	dc	gad_wavemaximize
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_cutzeros
	dc	5*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_cutzerosASC,topaz8
	dc	gad_wavecutzeros
 	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;waveed_gad_changeWave
;	dc	0,0,136,ghi
;	dc.l	0,topaz8
;	dc	gad_wavechangeWave
;	dc.l	PLACETEXT_LEFT
;	dc.l	0
;	dc.l	0
waveed_gad_changeWaveTXT
	dc	60,0*ghi+wgoff,40,ghi
	dc.l	waveed_waveASC,topaz8
	dc	gad_wavechangeWaveTXT
	dc.l	PLACETEXT_LEFT
	dc.l	0
waveed_gad_changeWaveTXTtags
		dc.l	gttx_text,txt_waveactwave
		dc.l	gttx_border,true
		dc.l	tag_done
txt_waveactwave	dc.b	"  ",0
		even

waveed_gad_changePos
	dc	0,5*ghi+gyoff+woff+8,640,ghi-2
	dc.l	0,topaz8
	dc	gad_wavechangePos
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
waveed_gad_changePosTAGS
		dc.l	gtsc_total,$8000
		dc.l	gtsc_arrows,14
		dc.l	ga_followmouse,true
		dc.l	ga_relverify,true
		dc.l	ga_immediate,true
		dc.l	tag_done
;waveed_gad_adjust
;	dc	0,0,30,ghi
;	dc.l	waveed_adjustASC,topaz8
;	dc	gad_waveadjust
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
waveed_gad_createinstr
	dc	6*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_instrASC,topaz8
	dc	gad_wavecreateinstr
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_createinstrFIX
	dc	7*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_instrfixASC,topaz8
	dc	gad_wavecreateinstrfix
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
;waveed_gad_delinstr
;	dc	0,0,40,ghi
;	dc.l	waveed_delinstrASC,topaz8
;	dc	gad_wavedelinstr
;	dc.l	PLACETEXT_IN
;	dc.l	0
;	dc.l	0
waveed_gad_sample
	dc	7*80,10*ghi+wgoff,80,ghi
	dc.l	waveed_sampleASC,topaz8
	dc	gad_waveSample
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_samplefreq
	dc	5*80,10*ghi+wgoff,80,ghi
	dc.l	0,topaz8
	dc	gad_waveSamplefreq
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
waveed_gad_samplefreqtags
	dc.l	gtin_number,16727
	dc.l	tag_done
waveed_gad_sampledlen
	dc	5*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_sampledlenASC,topaz8
	dc	gad_waveSampledlen
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
waveed_gad_sampledlentags
	dc.l	gtin_number,65536
	dc.l	tag_done
waveed_gad_trig
	dc	6*80+40,10*ghi+wgoff,40,ghi
	dc.l	waveed_trigASC,topaz8
	dc	gad_wavetrig
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
waveed_gad_trigtags
	dc.l	gtin_number,10
	dc.l	tag_done
waveed_gad_pitch
	dc	4*80+44,10*ghi+wgoff,36,ghi
	dc.l	waveed_pitchASC,topaz8
	dc	gad_wavepitch
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
instred_gad_return
	dc	0,11,40,ghi
	dc.l	instred_returnASC,topaz8
	dc	gad_instrreturn
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_Echo
	dc	3*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_echoASC,topaz8
	dc	gad_waveEcho
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_Vibrato
	dc	2*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_vibratoASC,topaz8
	dc	gad_waveVibrato
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_FM
	dc	2*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_fmASC,topaz8
	dc	gad_waveFM
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_NormalDC
	dc	5*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_normalDCASC,topaz8
	dc	gad_wavenormalDC
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_HQHPF
	dc	6*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_HQHPFASC,topaz8
	dc	gad_wavehqhpf
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_add
	dc	4*80,3*ghi+wgoff,80,ghi
	dc.l	waveed_addASC,topaz8
	dc	gad_waveAdd
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_sub
	dc	4*80,4*ghi+wgoff,80,ghi
	dc.l	waveed_subASC,topaz8
	dc	gad_waveSub
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_mul
	dc	4*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_mulASC,topaz8
	dc	gad_waveMul
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_mix
	dc	4*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_mixASC,topaz8
	dc	gad_waveMix
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_AM
	dc	4*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_AMASC,topaz8
	dc	gad_waveAM
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_LogicFree
	dc	4*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_logicFreeASC,topaz8
	dc	gad_waveLogicFree
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_hardSync
	dc	1*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_hardsyncASC,topaz8
	dc	gad_waveHardSync
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_Wave2WT
	dc	2*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_wave2wtASC,topaz8
	dc	gad_waveWave2WT
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_WT2Wave
	dc	3*80,11*ghi+wgoff,80,ghi
	dc.l	waveed_wt2waveASC,topaz8
	dc	gad_waveWT2Wave
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_VariousFree
	dc	7*80,5*ghi+wgoff,80,ghi
	dc.l	waveed_variousFreeASC,topaz8
	dc	gad_waveVariousFree
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_AddSpace
	dc	7*80,6*ghi+wgoff,80,ghi
	dc.l	waveed_addspaceASC,topaz8
	dc	gad_waveAddSpace
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_TimeWrap
	dc	7*80,7*ghi+wgoff,80,ghi
	dc.l	waveed_timewrapASC,topaz8
	dc	gad_waveTimeWrap
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
waveed_gad_PitchCng
	dc	7*80,8*ghi+wgoff,80,ghi
	dc.l	waveed_pitchcngASC,topaz8
	dc	gad_wavePitchCng
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
	


;----------------

			ifeq	lang
instred_instrnrASC	dc.b	"Instrument",0
instred_wavelenASC	dc.b	"Wave Len :",0
instred_wavenrASC	dc.b	"Waveform",0
instred_sampleoffsetASC	dc.b	"Sample Offset",0
instred_samplelenASC	dc.b	"Len",0
instred_repeatoffsetASC	dc.b	"Repeat Offset",0
instred_repeatlenASC	dc.b	"Len",0
instred_volumeASC	dc.b	"Volume",0
instred_finetuneASC	dc.b	"Finetune",0
instred_loadASC		dc.b	"_Load Instrument",0
instred_saveASC		dc.b	"_Save Instrument",0
instred_saveALLASC	dc.b	"Save All Instruments",0
instred_deleteASC	dc.b	"Delete Instrument",0
instred_cutASC		dc.b	"Cut",0
instred_copyASC		dc.b	"Copy",0
instred_pasteASC	dc.b	"Paste",0
;instred_copyfromASC	dc.b	"From",0
;instred_copytoASC	dc.b	"To",0
instred_moveFTASC	dc.b	"Move",0
instred_copyFTASC	dc.b	"Copy",0
instred_exchangeFTASC	dc.b	"Exchg",0
instred_mixFTASC	dc.b	"Mix",0
instred_ADSRwaveASC	dc.b	"ADSR",0
instred_ADSRlenASC	dc.b	"Len",0
instred_ADSRspdASC	dc.b	"Spd",0
instred_ADSRrepASC	dc.b	"Rep",0
instred_SYNTHspdASC	dc.b	"WAVE Spd",0
instred_SYNTHrepctrlASC	dc.b	"RepCtrl",0
instred_VIBdelayASC	dc.b	"LFO Delay/Param",0
;instred_VIBparaASC	dc.b	"Vib Param",0
instred_vibwaveASC	dc.b	"Wave",0
instred_LoadwaveASC	dc.b	"Load _wave",0
instred_FlushWaveASC	dc.b	"_Flush wave",0
instred_AstartASC	dc.b	"B",0
instred_AendASC		dc.b	"E",0
instred_AaddASC		dc.b	"A",0
instred_AsubASC		dc.b	"S",0
instred_returnASC	dc.b	"<",0


waveed_loadASC		dc.b	"_Load wave",0
waveed_saveASC		dc.b	"_Save wave",0
;waveed_deleteASC	dc.b	"_Del. wave",0
waveed_wavelenASC	dc.b	"Wave:",0
waveed_displaylenASC	dc.b	"Display:",0
waveed_rangelenASC	dc.b	"Range:",0
waveed_posASC		dc.b	"Pos:",0
waveed_showrangeASC	dc.b	"ShowRange",0
waveed_zoomASC		dc.b	"Zoom",0
waveed_teleASC		dc.b	"Tele",0
waveed_pitchASC		dc.b	"Note",0
waveed_playASC		dc.b	0
waveed_playrangeASC	dc.b	"Play",0
waveed_stopASC		dc.b	"Stop",0
waveed_rangedisplayASC	dc.b	"Range Dsp",0
waveed_rangeALLASC	dc.b	"Range All",0
waveed_showallASC	dc.b	"Show All",0
waveed_show121ASC	dc.b	"Show 1:1",0
waveed_partwaveASC	dc.b	"Partwave",0
waveed_savebufASC	dc.b	"Save",0
waveed_clrbufASC	dc.b	"Clr Buf",0
waveed_invertbufASC	dc.b	"Mix Buf",0
waveed_settozeroASC	dc.b	"SetTOZero",0
waveed_changevolASC	dc.b	"ChangeVol",0
waveed_phaserASC	dc.b	"Flanger",0
waveed_boostASC		dc.b	"Interpol",0
waveed_backwardsASC	dc.b	"Backwards",0
waveed_yASC		dc.b	"MoveYAxis",0
waveed_mixwithbufASC	dc.b	"HighPass",0 *****
waveed_interpolASC	dc.b	"Boost",0
waveed_invertASC	dc.b	"Invert",0
waveed_noiselimiterASC	dc.b	"LowPass",0 **
waveed_lfoASC		dc.b	"Phase-Dst",0
;waveed_hipassASC	dc.b	0	; NI
waveed_lopassASC	dc.b	"Wrap",0	; NI
waveed_doubleASC	dc.b	"Double",0
waveed_resampleDOWNASC	dc.b	"Note Dn",0
waveed_resampleUPASC	dc.b	"Note Up",0
waveed_digifilterASC	dc.b	"Filter",0
waveed_octupASC		dc.b	"OctUp",0
waveed_octdnASC		dc.b	"OctDn",0
waveed_maximizeASC	dc.b	"Maximize",0
waveed_cutzerosASC	dc.b	"Cut Zeros",0
waveed_waveASC		dc.b	"WaveNr",0
waveed_instrASC		dc.b	"Alloc Ins",0
waveed_instrfixASC	dc.b	"Make Ins",0
;waveed_adjustASC	dc.b	"A",0
;waveed_delinstrASC	dc.b	"DelI",0
waveed_sampleASC	dc.b	"Mon/Smple",0
waveed_trigASC		dc.b	"Trig",0
waveed_samplefreqASC	dc.b	"Hz",0
waveed_sampledlenASC	dc.b	"Len",0
waveed_pwsizeASC	dc.b	"Size",0
waveed_gainASC		dc.b	"Gain:",0
waveed_gainADDASC	dc.b	"Gain+",0
waveed_gainSUBASC	dc.b	"Gain-",0
waveed_rangeloopASC	dc.b	"Range Lop",0
waveed_seekzeroASC	dc.b	"Seek Zero",0
waveed_echoASC		dc.b	"Echo",0
waveed_vibratoASC	dc.b	"Vibrato",0
waveed_fmASC		dc.b	"Freq-Mod",0
waveed_normalDCASC	dc.b	"Normal DC",0
waveed_hqhpfASC		dc.b	"HQ-HPF",0
waveed_addASC		dc.b	"Add",0
waveed_subASC		dc.b	"Sub",0
waveed_mulASC		dc.b	"Mul",0
waveed_mixASC		dc.b	"Mix",0
waveed_AMASC		dc.b	"Ampl-Mod",0
waveed_logicFreeASC	dc.b	0	;NI
waveed_hardSyncASC	dc.b	"HardSync",0
waveed_wave2wtASC	dc.b	"Wave>WT",0
waveed_wt2waveASC	dc.b	"WT>Wave",0
waveed_variousfreeASC	dc.b	0	; NI
waveed_addspaceASC	dc.b	"Add Space",0
waveed_timewrapASC	dc.b	"Time Wrap",0
waveed_pitchcngASC	dc.b	"Pitch Cng",0

			else

instred_instrnrASC	dc.b	"Instrument",0
instred_wavelenASC	dc.b	"Wave Länge:",0
instred_wavenrASC	dc.b	"Waveform",0
instred_sampleoffsetASC	dc.b	"Sample Offset",0
instred_samplelenASC	dc.b	"Len",0
instred_repeatoffsetASC	dc.b	"Repeat Offset",0
instred_repeatlenASC	dc.b	"Len",0
instred_volumeASC	dc.b	"Lautstärke",0
instred_finetuneASC	dc.b	"Finetune",0
instred_loadASC		dc.b	"_Lade Instrument",0
instred_saveASC		dc.b	"_Speicher Instrument",0
instred_saveALLASC	dc.b	"Speicher alle Instr.",0
instred_deleteASC	dc.b	"Lösche Instrument",0
instred_cutASC		dc.b	"Cut",0
instred_copyASC		dc.b	"Kopiere",0
instred_pasteASC	dc.b	"Einfügen",0
;instred_copyfromASC	dc.b	"Von",0
;instred_copytoASC	dc.b	"Nach",0
instred_moveFTASC	dc.b	"Bewege",0
instred_copyFTASC	dc.b	"Kopiere",0
instred_exchangeFTASC	dc.b	"Austausch",0
instred_mixFTASC	dc.b	"Mischen",0
instred_ADSRwaveASC	dc.b	"ADSR",0
instred_ADSRlenASC	dc.b	"Len",0
instred_ADSRspdASC	dc.b	"Spd",0
instred_ADSRrepASC	dc.b	"Rep",0
instred_SYNTHspdASC	dc.b	"WAVE Spd",0
instred_SYNTHrepctrlASC	dc.b	"RepModus",0
instred_VIBdelayASC	dc.b	"LFO Verzög/Param",0
;instred_VIBparaASC	dc.b	"Vib Param",0
instred_vibwaveASC	dc.b	"Wave",0
instred_LoadwaveASC	dc.b	"Lade _Wave",0
instred_FlushWaveASC	dc.b	"Entferne Wave",0
instred_AstartASC	dc.b	"B",0
instred_AendASC		dc.b	"E",0
instred_AaddASC		dc.b	"A",0
instred_AsubASC		dc.b	"S",0
instred_returnASC	dc.b	"<",0


waveed_loadASC		dc.b	"_Lade wave",0
waveed_saveASC		dc.b	"_Save wave",0
;waveed_deleteASC	dc.b	"_Del. wave",0
waveed_wavelenASC	dc.b	"Wave:",0
waveed_displaylenASC	dc.b	"Anzeige:",0
waveed_rangelenASC	dc.b	"Range:",0
waveed_posASC		dc.b	"Pos:",0
waveed_showrangeASC	dc.b	"ZeigRange",0
waveed_zoomASC		dc.b	"Zoom+",0
waveed_teleASC		dc.b	"Zoom-",0
waveed_pitchASC		dc.b	"Note",0
waveed_playASC		dc.b	0
waveed_playrangeASC	dc.b	"Spiel",0
waveed_stopASC		dc.b	"Stop",0
waveed_rangedisplayASC	dc.b	"Range Dsp",0
waveed_rangeALLASC	dc.b	"Range All",0
waveed_showallASC	dc.b	"Zeig all",0
waveed_show121ASC	dc.b	"Zeig 1:1",0
waveed_partwaveASC	dc.b	"Partwave",0
waveed_savebufASC	dc.b	"Speicher",0
waveed_clrbufASC	dc.b	"Clr Buf",0
waveed_invertbufASC	dc.b	"Mix Buf",0
waveed_settozeroASC	dc.b	"SetTOZero",0
waveed_changevolASC	dc.b	"ChangeVol",0
waveed_phaserASC	dc.b	"Flanger",0
waveed_boostASC		dc.b	"Interpol",0
waveed_backwardsASC	dc.b	"Rückwärts",0
waveed_yASC		dc.b	"MoveYAxis",0
waveed_mixwithbufASC	dc.b	"HighPass",0 *****
waveed_interpolASC	dc.b	"Boost",0
waveed_invertASC	dc.b	"Invert",0
waveed_noiselimiterASC	dc.b	"LowPass",0 **
waveed_lfoASC		dc.b	"Phase-Dst",0
;waveed_hipassASC	dc.b	0	; NI
waveed_lopassASC	dc.b	"Wrap",0	; NI
waveed_doubleASC	dc.b	"Double",0
waveed_resampleDOWNASC	dc.b	"Note Dn",0
waveed_resampleUPASC	dc.b	"Note Up",0
waveed_digifilterASC	dc.b	"Filter",0
waveed_octupASC		dc.b	"OctUp",0
waveed_octdnASC		dc.b	"OctDn",0
waveed_maximizeASC	dc.b	"Maximize",0
waveed_cutzerosASC	dc.b	"Cut Zeros",0
waveed_waveASC		dc.b	"WaveNr",0
waveed_instrASC		dc.b	"Alloc Ins",0
waveed_instrfixASC	dc.b	"Make Ins",0
;waveed_adjustASC	dc.b	"A",0
;waveed_delinstrASC	dc.b	"DelI",0
waveed_sampleASC	dc.b	"Mon/Smple",0
waveed_trigASC		dc.b	"Trig",0
waveed_samplefreqASC	dc.b	"Hz",0
waveed_sampledlenASC	dc.b	"Len",0
waveed_pwsizeASC	dc.b	"Size",0
waveed_gainASC		dc.b	"Gain:",0
waveed_gainADDASC	dc.b	"Gain+",0
waveed_gainSUBASC	dc.b	"Gain-",0
waveed_rangeloopASC	dc.b	"Range Lop",0
waveed_seekzeroASC	dc.b	"Such Null",0
waveed_echoASC		dc.b	"Echo",0
waveed_vibratoASC	dc.b	"Vibrato",0
waveed_fmASC		dc.b	"Freq-Mod",0
waveed_normalDCASC	dc.b	"Normal DC",0
waveed_hqhpfASC		dc.b	"HQ-HPF",0
waveed_addASC		dc.b	"Add",0
waveed_subASC		dc.b	"Sub",0
waveed_mulASC		dc.b	"Mul",0
waveed_mixASC		dc.b	"Mix",0
waveed_AMASC		dc.b	"Ampl-Mod",0
waveed_logicFreeASC	dc.b	0	;NI
waveed_hardSyncASC	dc.b	"HardSync",0
waveed_wave2wtASC	dc.b	"Wave>WT",0
waveed_wt2waveASC	dc.b	"WT>Wave",0
waveed_variousfreeASC	dc.b	0	; NI
waveed_addspaceASC	dc.b	"Add Space",0
waveed_timewrapASC	dc.b	"Time Wrap",0
waveed_pitchcngASC	dc.b	"Pitch Cng",0
		endif

		even

;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
setup_gadgetroutines
	dc.l	gad_setupModpathGET,setuP_getmodpath,0
	dc.l	gad_setupinstrpathGET,setuP_getinstrpath,0
	dc.l	gad_setupsamplepathGET,setuP_getsamplepath,0
	dc.l	gad_setupdseqpathGET,setuP_getdseqpath,0
	dc.l	gad_setupblankerGET,setup_getBlanker,0
	dc.l	gad_setupblankertimeout,setup_blankertimechange,0
	dc.l	gad_setupwavedrawmode,setup_wavedrawmodeChange,0
	dc.l	gad_setupfiltermode,setup_filtermodeChange,0
	dc.l	gad_setupload,loadprefs,0
	dc.l	gad_setupsave,saveprefs,0
	dc.l	gad_setupuse,setup_use,0
	dc.l	gad_setupabort,setup_cancel,0
	dc.l	gad_setupsaveinstrnamesmode,setup_saveinstrnamesModeChange,0
	dc.l	gad_setupsaveremarkmode,setup_saveremarkModeChange,0
	dc.l	gad_setupcrunchmode,setup_crunchModeChange,0
	dc.l	gad_setupaddppmode,setup_addppModeChange,0
	dc.l	gad_setupcrunchbufmode,setup_crunchbufmodechange,0
	dc.l	gad_setupcruncheffmode,setup_cruncheffmodechange,0
	dc.l	gad_setupbottomstatusmode,setup_togglebottomstatusmode,0
	dc.l	gad_setupforcepalmode,setup_toggleforcepalmode,0
			dc.l	0,0,0

setup_gadgetstructptrs

	dc.l	string_kind,setup_gad_modpath,setup_gad_pathtags
	dc.l	button_kind,setup_gad_modpathGET,underscoretags
	dc.l	string_kind,setup_gad_samplepath,setup_gad_pathtags
	dc.l	button_kind,setup_gad_samplepathGET,underscoretags
	dc.l	string_kind,setup_gad_instrpath,setup_gad_pathtags
	dc.l	button_kind,setup_gad_instrpathGET,underscoretags
	dc.l	string_kind,setup_gad_dseqpath,setup_gad_pathtags
	dc.l	button_kind,setup_gad_dseqpathGET,underscoretags
	dc.l	string_kind,setup_gad_texteditor,setup_gad_pathtags
	dc.l	string_kind,setup_gad_blanker,setup_gad_pathtags
	dc.l	button_kind,setup_gad_blankerGET,underscoretags
	dc.l	integer_kind,setup_gad_blankertimeout,mp_gadget22tags
	dc.l	cycle_kind,setup_gad_filtermode,setup_gad_filtermodetags
	dc.l	cycle_kind,setup_gad_wavedrawmode,setup_gad_wavedrawmodetags
	dc.l	button_kind,setup_gad_load,underscoretags
	dc.l	button_kind,setup_gad_save,underscoretags
	dc.l	button_kind,setup_gad_use,underscoretags
	dc.l	button_kind,setup_gad_abort,underscoretags
	dc.l	cycle_kind,setup_gad_saveremarkmode,setup_gad_yesnotags
	dc.l	cycle_kind,setup_gad_saveinstrnamesmode,setup_gad_yesnotags
	dc.l	cycle_kind,setup_gad_addppmode,setup_gad_yesnotags
	dc.l	cycle_kind,setup_gad_cruncheffmode,setup_gad_cruncheffmodetags
	dc.l	cycle_kind,setup_gad_crunchmode,setup_gad_yesnotags
	dc.l	cycle_kind,setup_gad_crunchbufmode,setup_gad_crunchbufmodetags
	dc.l	cycle_kind,setup_gad_bottomstatusmode,setup_gad_onofftags
	dc.l	cycle_kind,setup_gad_forcepalmode,setup_gad_onofftags

			dc.l	0,0,0


setup_gad_modpath
	dc	160,0*ghi+gyoff,320-4,ghi
	dc.l	setup_modpathASC,topaz8
	dc	gad_SETUPmodpath
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_modpathGET
	dc	476,0*ghi+gyoff,160,ghi
	dc.l	setup_getASC,topaz8
	dc	gad_SETUPmodpathGET
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_samplepath
	dc	160,1*ghi+gyoff,320-4,ghi
	dc.l	setup_samplepathASC,topaz8
	dc	gad_SETUPsamplepath
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_samplepathGET
	dc	476,1*ghi+gyoff,160,ghi
	dc.l	setup_getASC,topaz8
	dc	gad_SETUPsamplepathGET
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_instrpath
	dc	160,2*ghi+gyoff,320-4,ghi
	dc.l	setup_instrpathASC,topaz8
	dc	gad_SETUPinstrpath
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_instrpathGET
	dc	476,2*ghi+gyoff,160,ghi
	dc.l	setup_getASC,topaz8
	dc	gad_SETUPinstrpathGET
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_dseqpath
	dc	160,3*ghi+gyoff,320-4,ghi
	dc.l	setup_dseqpathASC,topaz8
	dc	gad_SETUPdseqpath
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_dseqpathGET
	dc	476,3*ghi+gyoff,160,ghi
	dc.l	setup_getASC,topaz8
	dc	gad_SETUPdseqpathGET
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_pathtags
		dc.l	gt_underscore,"_"
		dc.l	gtst_string,0			; Ptr auf Textpuffer
		dc.l	gtst_maxchars,31	; Maximale Anzahl Zeichen
		dc.l	TAG_DONE
setup_gad_texteditor
	dc	160,4*ghi+gyoff,320-4,ghi
	dc.l	setup_texteditorASC,topaz8
	dc	gad_setuptexteditor
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_blanker
	dc	160,5*ghi+gyoff,320-4,ghi
	dc.l	setup_blankerASC,topaz8
	dc	gad_setupblanker
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_blankerGET
	dc	476,5*ghi+gyoff,40,ghi
	dc.l	setup_blankerGETASC,topaz8
	dc	gad_setupblankerGET
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_blankerTimeout
	dc	586,5*ghi+gyoff,50,ghi
	dc.l	setup_blankertimeoutASC,topaz8
	dc	gad_setupblankertimeout
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_filtermode
	dc	400-4,6*ghi+gyoff,240,ghi
	dc.l	setup_filterASC,topaz8
	dc	gad_setupfiltermode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_filtermodeTAGS
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Off",0
.mode2		dc.b	"On",0
		else
.mode1		dc.b	"Aus",0
.mode2		dc.b	"An",0
		endif
		even
setup_gad_wavedrawmode
	dc	400-4,7*ghi+gyoff,240,ghi
	dc.l	setup_wavedrawASC,topaz8
	dc	gad_setupwavedrawmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_wavedrawmodeTAGS
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	0
.mode1		dc.b	"Copper",0
.mode2		dc.b	"CPU",0
		even


setup_gad_load
	dc	4,13*ghi+gyoff,158,ghi
	dc.l	setup_loadASC,topaz8
	dc	gad_setupload
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_save
	dc	4+158*1,13*ghi+gyoff,158,ghi
	dc.l	setup_saveASC,topaz8
	dc	gad_setupsave
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_use
	dc	4+158*2,13*ghi+gyoff,158,ghi
	dc.l	setup_useASC,topaz8
	dc	gad_setupuse
	dc.l	PLACETEXT_IN
	dc.l	0
setup_gad_abort
	dc	4+158*3,13*ghi+gyoff,158,ghi
	dc.l	setup_abortASC,topaz8
	dc	gad_setupabort
	dc.l	PLACETEXT_IN
	dc.l	0

setup_gad_saveremarkmode
	dc	160,7*ghi+gyoff,80,ghi
	dc.l	setup_saveremarkASC,topaz8
	dc	gad_setupsaveremarkmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_yesnoTAGS
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	0
		ifeq	lang
.mode1		dc.b	"No",0
.mode2		dc.b	"Yes",0
		else
.mode1		dc.b	"Nein",0
.mode2		dc.b	"Ja",0
		endif
		even
setup_gad_saveinstrnamesmode
	dc	160,6*ghi+gyoff,80,ghi
	dc.l	setup_saveinstrnamesASC,topaz8
	dc	gad_setupsaveinstrnamesmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_addppmode
	dc	160,9*ghi+gyoff,80,ghi
	dc.l	setup_addppASC,topaz8
	dc	gad_setupaddppmode
	dc.l	PLACETEXT_LEFT
	dc.l	0

setup_gad_cruncheffmode
	dc	400-4,8*ghi+gyoff,240,ghi
	dc.l	setup_cruncheffASC,topaz8
	dc	gad_setupcruncheffmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_cruncheffmodeTAGS
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	.mode3
		dc.l	.mode4
		dc.l	.mode5
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Fast",0
.mode2		dc.b	"Mediocre",0
.mode3		dc.b	"Good",0
.mode4		dc.b	"Very good",0
.mode5		dc.b	"Best",0
		else
.mode1		dc.b	"Schnell",0
.mode2		dc.b	"Mittelmäßig",0
.mode3		dc.b	"Gut",0
.mode4		dc.b	"Sehr gut",0
.mode5		dc.b	"Bestmöglich",0
		endif
		even
setup_gad_crunchmode
	dc	160,8*ghi+gyoff,80,ghi
	dc.l	setup_crunchASC,topaz8
	dc	gad_setupcrunchmode
	dc.l	PLACETEXT_LEFT
	dc.l	0

setup_gad_crunchbufmode
	dc	400-4,9*ghi+gyoff,240,ghi
	dc.l	setup_crunchbufASC,topaz8
	dc	gad_setupcrunchbufmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_crunchbufmodeTAGS
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode3
		dc.l	.mode2
		dc.l	.mode1
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Small",0
.mode2		dc.b	"Medium",0
.mode3		dc.b	"Large",0
		else
.mode1		dc.b	"Klein",0
.mode2		dc.b	"Mittel",0
.mode3		dc.b	"Groß",0
		endif
		even
setup_gad_bottomstatusmode
	dc	160,10*ghi+gyoff,80,ghi
	dc.l	setup_bottomstatusASC,topaz8
	dc	gad_setupbottomstatusmode
	dc.l	PLACETEXT_LEFT
	dc.l	0
setup_gad_onofftags
	dc.l	gt_underscore,"_"
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Off",0
.mode2		dc.b	"On",0
		else
.mode1		dc.b	"Aus",0
.mode2		dc.b	"An",0
		endif
		even
setup_gad_forcepalmode
	dc	160,11*ghi+gyoff,80,ghi
	dc.l	setup_forcepalASC,topaz8
	dc	gad_setupforcepalmode
	dc.l	PLACETEXT_LEFT
	dc.l	0



			ifeq	lang
setup_modpathASC	dc.b	"_Module path",0
setup_samplepathASC	dc.b	"_Waveform path",0
setup_instrpathASC	dc.b	"_Instrument path",0
setup_dseqpathASC	dc.b	"_DrumSeq. path",0
setup_getASC		dc.b	"Get dir",0
setup_texteditorASC	dc.b	"_Texteditor",0
setup_blankerASC	dc.b	"Screen_blanker",0
setup_blankerGETASC	dc.b	"Get",0
setup_blankertimeoutASC	dc.b	"Seco_nds",0
setup_filterASC		dc.b	"_Filter",0
setup_wavedrawASC	dc.b	"_View-Splitmode",0
setup_loadASC		dc.b	"_Load",0
setup_saveASC		dc.b	"_Save",0
setup_useASC		dc.b	"_Use",0
setup_abortASC		dc.b	"_Cancel",0
setup_saveremarkASC	dc.b	"Save song-_remarks",0
setup_saveinstrnamesASC	dc.b	"Sav_e instr.names",0
setup_crunchASC		dc.b	"Play samples >128_k",0
setup_addppASC		dc.b	"Add ._pp",0
setup_cruncheffASC	dc.b	"Crunch efficenc_y",0
setup_crunchbufASC	dc.b	"Crunc_h buffersize",0
setup_bottomstatusASC	dc.b	"B_ottom status",0
setup_forcepalASC	dc.b	"Force PAL on start",0

			else
setup_modpathASC	dc.b	"_Modul Pfad",0
setup_samplepathASC	dc.b	"_Wellenform Pfad",0
setup_instrpathASC	dc.b	"_Instrument Pfad",0
setup_dseqpathASC	dc.b	"_DrumSeq. Pfad",0
setup_getASC		dc.b	"Verz. wählen",0
setup_texteditorASC	dc.b	"_Texteditor",0
setup_blankerASC	dc.b	"Screen_blanker",0
setup_blankerGETASC	dc.b	"Sel",0
setup_blankertimeoutASC	dc.b	"Seco_nds",0
setup_filterASC		dc.b	"_Filter",0
setup_wavedrawASC	dc.b	"_View-Splitmode",0
setup_loadASC		dc.b	"_Laden",0
setup_saveASC		dc.b	"_Speichern",0
setup_useASC		dc.b	"Ben_utzen",0
setup_abortASC		dc.b	"_Cancel",0
setup_saveremarkASC	dc.b	"Save Song-_remarks",0
setup_saveinstrnamesASC	dc.b	"Sav_e Instr.Namen",0
setup_crunchASC		dc.b	"Play Samples >128_k",0
setup_addppASC		dc.b	"Add ._pp",0
setup_cruncheffASC	dc.b	"Crunch Efficenc_y",0
setup_crunchbufASC	dc.b	"Crunc_h Buffergröße",0
setup_bottomstatusASC	dc.b	"Status Symb_ole",0
setup_forcepalASC	dc.b	"PALHires erzwingen",0
			endif

			even

;-----------------------------------------------------------------------
; FM-SYNTHEDITOR!!!!!!!!!!!!!!!

fmed_gadgetroutines
	dc.l	gad_fmedpartwavesize,fmed_partwavelenChange,0
	dc.l	gad_fmedpartwaves,fmed_partwavesChange,0
	dc.l	gad_fmedfreq1,fmed_freq1Change,0
	dc.l	gad_fmedfreq2,fmed_freq2Change,0
	dc.l	gad_fmedattack1,fmed_attack1Change,0
	dc.l	gad_fmedattack2,fmed_attack2Change,0
	dc.l	gad_fmeddecay1,fmed_decay1Change,0
	dc.l	gad_fmeddecay2,fmed_decay2Change,0
	dc.l	gad_fmedlevel1,fmed_level1change,0
	dc.l	gad_fmedlevel2,fmed_level2change,0
	dc.l	gad_fmeddestwave,fmed_destwavechange,0
	dc.l	gad_fmeddo,fmed_computeit,0
	dc.l	gad_fmeddelete,fmed_delete,0
	dc.l	gad_fmedwavesel1,fmed_wavesel1,0
	dc.l	gad_fmedwavesel2,fmed_wavesel2,0
	dc.l	gad_fmedsave,fmed_saveinstr,0
	dc.l	gad_fmedload,fmed_loadinstr,0
	dc.l	gad_fmedmake,fmed_createinstrumentFIX,0
			dc.l	0,0,0
fmed_gadgetstructptrs
		dc.l	integer_kind,fmed_gad_freq1,fmed_2tags
		dc.l	integer_kind,fmed_gad_attack1,fmed_3tags
		dc.l	integer_kind,fmed_gad_decay1,fmed_3tags
		dc.l	integer_kind,fmed_gad_level1,fmed_3tags

		dc.l	integer_kind,fmed_gad_freq2,fmed_2tags
		dc.l	integer_kind,fmed_gad_attack2,fmed_3tags
		dc.l	integer_kind,fmed_gad_decay2,fmed_3tags
		dc.l	integer_kind,fmed_gad_level2,fmed_3tags

		dc.l	integer_kind,fmed_gad_partwavesize,fmed_3tags
		dc.l	integer_kind,fmed_gad_partwaves,fmed_3tags

	dc.l	button_kind,fmed_gad_load,underscoretags
	dc.l	button_kind,fmed_gad_save,underscoretags
	dc.l	button_kind,fmed_gad_delete,underscoretags
		dc.l	button_kind,fmed_gad_do,underscoretags
		dc.l	integer_kind,fmed_gad_destwave,fmed_2tags
		dc.l	cycle_kind,fmed_gad_wavesel1,fmed_gad_wavesel1tags
		dc.l	cycle_kind,fmed_gad_wavesel2,fmed_gad_wavesel1tags
		dc.l	button_kind,fmed_gad_make,0
		dc.l	0,0,0

fmed_gad_freq1
	dc	492,-6+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedfreq1
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_decay1
	dc	376,254-237+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmeddecay1
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_freq2
	dc	492,79+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedfreq2
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_decay2
	dc	376,254-237+85+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmeddecay2
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_attack1
	dc	210,254-233+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedattack1
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_attack2
	dc	210,254-233+85+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedattack2
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_level1
	dc	341,254-198+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedlevel1
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_level2
	dc	341,254-198+85+20,40,ghi
	dc.l	0,topaz8
	dc	gad_fmedlevel2
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_partwavesize
	dc	404+120,15*ghi+gyoff,40,ghi
	dc.l	fmed_pwsizeASC,topaz8
	dc	gad_fmedpartwavesize
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
fmed_gad_partwaves
	dc	404+120,16*ghi+gyoff,40,ghi
	dc.l	fmed_pwamtASC,topaz8
	dc	gad_fmedpartwaves
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
fmed_gad_destwave
	dc	404+120,17*ghi+gyoff,40,ghi
	dc.l	fmed_destwaveASC,topaz8
	dc	gad_fmeddestwave
	dc.l	PLACETEXT_LEFT
	dc.l	0
	dc.l	0
fmed_2tags
	dc.l	ga_tabcycle,true
	dc.l	gtin_maxchars,2
	dc.l	gt_underscore,"_"
	dc.l	stringa_replacemode,true
	dc.l	tag_done
fmed_3tags
	dc.l	ga_tabcycle,true
	dc.l	gtin_maxchars,3
	dc.l	gt_underscore,"_"
	dc.l	stringa_replacemode,true
	dc.l	tag_done


fmed_gad_load
	dc	4,15*ghi+gyoff,160,ghi
	dc.l	fmed_loadASC,topaz8
	dc	gad_fmedload
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_save
	dc	4,16*ghi+gyoff,160,ghi
	dc.l	fmed_saveASC,topaz8
	dc	gad_fmedsave
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_delete
	dc	4,17*ghi+gyoff,160,ghi
	dc.l	fmed_deleteASC,topaz8
	dc	gad_fmeddelete
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_make
	dc	4+160,17*ghi+gyoff,160,ghi
	dc.l	fmed_makeASC,topaz8
	dc	gad_fmedmake
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_do
	dc	404+160,15*ghi+gyoff,72,ghi*3
	dc.l	fmed_computeASC,topaz8
	dc	gad_fmeddo
	dc.l	PLACETEXT_IN
	dc.l	0
	dc.l	0
fmed_gad_wavesel1
	dc	4+70,1*ghi+gyoff+3,120,ghi*3-2
	dc.l	0,topaz8
	dc	gad_fmedwavesel1
	dc.l	PLACETEXT_LEFT
	dc.l	0
fmed_gad_wavesel2
	dc	4+70,1*ghi+gyoff+3+85,120,ghi*3-2
	dc.l	0,topaz8
	dc	gad_fmedwavesel2
	dc.l	PLACETEXT_LEFT
	dc.l	0
fmed_gad_wavesel1TAGS
	dc.l	gtcy_labels,.modes
	dc.l	tag_done
.modes		dc.l	.mode1
		dc.l	.mode2
		dc.l	.mode3
		dc.l	.mode4
		dc.l	.mode5
		dc.l	.mode6
		dc.l	.mode7
		dc.l	.mode8
		dc.l	.mode9
		dc.l	.mode10
		dc.l	.mode11
		dc.l	.mode12
		dc.l	.mode13
		dc.l	.mode14
		dc.l	.mode15
		dc.l	.mode16
		dc.l	0
		ifeq	lang
.mode1		dc.b	"Sinus",0
.mode2		dc.b	"Square",0
.mode3		dc.b	"Triangle",0
.mode4		dc.b	"Sawtooth",0
.mode5		dc.b	"White Noise",0
.mode6		dc.b	"Arc",0
.mode7		dc.b	"DoubleSin",0
.mode8		dc.b	"Extremes",0
.mode9		dc.b	"Heart",0
.mode10		dc.b	"Linemix",0
.mode11		dc.b	"M-Shape",0
.mode12		dc.b	"Parabola",0
.mode13		dc.b	"Sample",0
.mode14		dc.b	"Turnpoint",0
.mode15		dc.b	"Up&Down",0
.mode16		dc.b	"Pulse",0
		else
.mode1		dc.b	"Sinus",0
.mode2		dc.b	"Rechteck",0
.mode3		dc.b	"Dreieck",0
.mode4		dc.b	"Sägezahn",0
.mode5		dc.b	"Rauschen",0
.mode6		dc.b	"Arc",0
.mode7		dc.b	"Doppel-Sin",0
.mode8		dc.b	"Extremes",0
.mode9		dc.b	"Herz",0
.mode10		dc.b	"Linienmix",0
.mode11		dc.b	"M-Shape",0
.mode12		dc.b	"Parabola",0
.mode13		dc.b	"Sample",0
.mode14		dc.b	"Turnpoint",0
.mode15		dc.b	"Up&Down",0
.mode16		dc.b	"Puls",0
		endif

		even
			ifeq	lang
fmed_pwsizeASC		dc.b	"Partwavesize",0
fmed_pwamtASC		dc.b	"Partwaves",0
fmed_loadASC		dc.b	"_Load instrument",0
fmed_saveASC		dc.b	"_Save instrument",0
fmed_deleteASC		dc.b	"_Delete instrument",0
fmed_computeASC		dc.b	"DO",0
fmed_destwaveASC	dc.b	"Destwave",0
fmed_makeASC		dc.b	"Create Instr.",0

			else
fmed_pwsizeASC		dc.b	"Partwavesize",0
fmed_pwamtASC		dc.b	"Partwaves",0
fmed_loadASC		dc.b	"_Lade Instrument",0
fmed_saveASC		dc.b	"_Speicher Instrument",0
fmed_deleteASC		dc.b	"_Delete Instrument",0
fmed_computeASC		dc.b	"DO",0
fmed_destwaveASC	dc.b	"Zielwave",0
fmed_makeASC		dc.b	"Instr. erzeugen",0
		endif
		even
;---------------------------------------------------- Multiselect-Reqs
; easyreq -requester
overwrite_str:		dc.l	overwrite_strE-overwrite_str	; sizeOf
			dc.l	0				; flax
			dc.l	overwrite_title			; title
			dc.l	overwrite_messy			; body-text
			dc.l	overwrite_gadgets			; Gadgets!
overwrite_strE
overwrite_title		dc.b	"Program Request",0


			ifne	spasti
overwrite_messy
	dc.b	"Tommy, bist Du wieder son SPASTI und willst wieder Deine",$a
	dc.b	"eigenen MODs löschen ?!",0
overwrite_gadgets		dc.b	"NNNEEEIIN!|JA,ICH BINN SPASTI!",0
			else
	ifeq	lang
overwrite_messy
	dc.b	"File already exists!!!!!!",0
overwrite_gadgets		dc.b	"CANCEL!|OVERWRITE!",0

	else
overwrite_messy
	dc.b	"Eine Datei unter diesem Namen existiert bereits!!",0
overwrite_gadgets		dc.b	"Abbruch!|Überschreiben!",0
	endif

			endif


			even
vquit_str:		dc.l	vquit_strE-vquit_str	; sizeOf
			dc.l	0				; flax
			dc.l	vquit_title			; title
			dc.l	vquit_messy			; body-text
			dc.l	vquit_gadgets			; Gadgets!
vquit_strE
			ifeq	lang
vquit_title		dc.b	"Program Request",0
vquit_messy		dc.b	"Love it or leave it ?!",0
vquit_gadgets		dc.b	"Leave it|Love it",0
			even
			else
vquit_title		dc.b	"Program Request",0
vquit_messy		dc.b	"Programm wirklich verlassen ?!",0
vquit_gadgets		dc.b	"Ja|Nein",0
			even
			endif

vload_str:		dc.l	vload_strE-vload_str	; sizeOf
			dc.l	0				; flax
			dc.l	vload_title			; title
			dc.l	vload_messy			; body-text
			dc.l	vload_gadgets			; Gadgets!
vload_strE
vload_title		dc.b	"Program Request",0
			ifne	lang
vload_messy		dc.b	"Song ist noch nicht gesichert!",0
vload_gadgets		dc.b	"Egal|Abbruch",0
			even
			else
vload_messy		dc.b	"Current song is not saved!",0
vload_gadgets		dc.b	"Continue|Cancel",0
			even
			endif

adjust_str:		dc.l	adjust_strE-adjust_str	; sizeOf
			dc.l	0				; flax
			dc.l	adjust_title			; title
			dc.l	adjust_messy			; body-text
			dc.l	adjust_gadgets			; Gadgets!
adjust_strE
adjust_title		dc.b	"Program Request",0
adjust_messy		dc.b	"Adjust instruments to new sample-len ?",0
adjust_gadgets		dc.b	"Yes|No",0
			even


clrwhat_str		dc.l	clrwhat_strE-clrwhat_str	; sizeOf
			dc.l	0				; flax
			dc.l	clrwhat_title			; title
			dc.l	clrwhat_messy			; body-text
			dc.l	clrwhat_gadgets			; Gadgets!
clrwhat_strE
clrwhat_title		dc.b	"ArtOfNoise V1.9",0
			ifeq	lang
clrwhat_messy		dc.b	"Clear what ?",0
clrwhat_gadgets		dc.b	"All|Song|Instrs&Waves|Instrs|Waves|Cancel",0
			even
			else
clrwhat_messy		dc.b	"Was soll ich löschen ?",0
clrwhat_gadgets		dc.b	"Alles|Song|Instrs&Waves|Instrs|Waves|Abbruch",0
			even
			endif

clrinstr_str		dc.l	clrinstr_strE-clrinstr_str
			dc.l	0
			dc.l	clrinstr_title
			dc.l	clrinstr_messy
			dc.l	clrinstr_gadgets
clrinstr_strE
clrinstr_title		dc.b	"ArtOfNoise V1.9",0
			ifeq	lang
clrinstr_messy		dc.b	"Delete what ?!",0
clrinstr_gadgets	dc.b	"Instr&Wave|Wave|Instr|Nothing",0
			even
			else
clrinstr_messy		dc.b	"Was soll ich löschen ?!",0
clrinstr_gadgets	dc.b	"Instr&Wave|Wave|Instr|Nichts",0
			even
			endif

loadinstr_str		dc.l	loadinstr_strE-loadinstr_str
			dc.l	0
			dc.l	loadinstr_title
			dc.l	loadinstr_messy
			dc.l	loadinstr_gadgets
loadinstr_strE
loadinstr_title		dc.b	"ArtOfNoise V1.9",0
			ifeq	lang
loadinstr_messy		dc.b	"Overwrite old waveform ?",0
loadinstr_gadgets	dc.b	"Yes|No",0
			even
			else
loadinstr_messy		dc.b	"Alte Wellenform überschreiben ?",0
loadinstr_gadgets	dc.b	"Ja|Nein",0
			even
			endif

vdel_str:		dc.l	vdel_strE-vdel_str	; sizeOf
			dc.l	0				; flax
			dc.l	vdel_title			; title
			dc.l	vdel_messy			; body-text
			dc.l	vdel_gadgets			; Gadgets!
vdel_strE
vdel_title		dc.b	"Program Request",0
			ifeq	lang
vdel_messy		dc.b	"Are you really sure to delete the file",$a
vdel_name		dcb.b	75," "
vdel_gadgets		dc.b	"Yep|Oh No!",0
			even
			else
vdel_messy		dc.b	"Willst Du diese Datei wirklich löschen ?",$a
vdel_name		dcb.b	75," "
vdel_gadgets		dc.b	"Ja|Nein!",0
			even
			endif

clrwave_str		dc.l	clrwave_strE-clrwave_str
			dc.l	0
			dc.l	loadinstr_title
			dc.l	clrwave_messy
			dc.l	clrwave_gadgets
clrwave_strE
			ifeq	lang
clrwave_messy		dc.b	"Really delete waveform?!",0
clrwave_gadgets	dc.b	"Yes|Noooo!",0
			even
			else
clrwave_messy		dc.b	"Willst Du diese Wellenform wirklich löschen ?",0
clrwave_gadgets	dc.b	"Ja|Nein!",0
			even
			endif

copyins_str		dc.l	copyins_strE-copyins_str
			dc.l	0
			dc.l	loadinstr_title
			dc.l	copyins_messy
			dc.l	copyins_gadgets
copyins_strE
			ifeq	lang
copyins_messy		dc.b	"Clone waveform ?!",0
copyins_gadgets	dc.b	"Yes|No",0
			even
			else
copyins_messy
	dc.b	"Soll eine neue Wellenform (Clone) erzeugt werden ?",0
copyins_gadgets	dc.b	"Ja|Nein",0
			even
			endif

;----------------------------------------------------	Pull-Down-Menus
; Für Abfrage des angewählten Menupunkts
MenuPtrs	dc.l	menu_project
		dc.l	menu_help
		dc.l	menu_env
		dc.l	menu_ch
		dc.l	menu_pattedit
		dc.l	menu_instr131
		dc.l	menu_instr3262

Menu_Project	dc.l	clr.new
		dc.l	0
		dc.l	LoadSong
		dc.l	0
		dc.l	savesong
		dc.l	saveplayermod
		dc.l	saveexecutable
		dc.l	0
		dc.l	ppcrunchfile
		dc.l	0
		dc.l	deletefile
		dc.l	0
		dc.l	cg_quit


menu_help	dc.l	fxpage
		dc.l	freqpage
		dc.l	aboutaon
		dc.l	remark_show


menu_instr131	dc.l	set_instr1
		dc.l	set_instr2
		dc.l	set_instr3
		dc.l	set_instr4
		dc.l	set_instr5
		dc.l	set_instr6
		dc.l	set_instr7
		dc.l	set_instr8
		dc.l	set_instr9
		dc.l	set_instra
		dc.l	set_instrb
		dc.l	set_instrc
		dc.l	set_instrd
		dc.l	set_instre
		dc.l	set_instrf
		dc.l	set_instrg
		dc.l	set_instrh
		dc.l	set_instri
		dc.l	set_instrj
		dc.l	set_instrk
		dc.l	set_instrl
		dc.l	set_instrm
		dc.l	set_instrn
		dc.l	set_instro
		dc.l	set_instrp
		dc.l	set_instrq
		dc.l	set_instrr
		dc.l	set_instrs
		dc.l	set_instrt
		dc.l	set_instru
		dc.l	set_instrv

menu_instr3262	dc.l	set_instrw
		dc.l	set_instrx
		dc.l	set_instry
		dc.l	set_instrz
		dc.l	set_instra2
		dc.l	set_instrb2
		dc.l	set_instrc2
		dc.l	set_instrd2
		dc.l	set_instre2
		dc.l	set_instrf2
		dc.l	set_instrg2
		dc.l	set_instrh2
		dc.l	set_instri2
		dc.l	set_instrj2
		dc.l	set_instrk2
		dc.l	set_instrl2
		dc.l	set_instrm2
		dc.l	set_instrn2
		dc.l	set_instro2
		dc.l	set_instrp2
		dc.l	set_instrq2
		dc.l	set_instrr2
		dc.l	set_instrs2
		dc.l	set_instrt2
		dc.l	set_instru2
		dc.l	set_instrv2
		dc.l	set_instrw2
		dc.l	set_instrx2
		dc.l	set_instry2
		dc.l	set_instrz2
menu_pattedit	dc.l	submenu_20pattedit
		dc.l	markblock
		dc.l	cutarea
		dc.l	copyarea
		dc.l	pastearea
		dc.l	submenu_6pattedit
		dc.l	changevolume
		dc.l	wildstarReplace
		dc.l	0
		dc.l	exchangepatterns
		dc.l	exchangetracks
		dc.l	expandtrack
		dc.l	0
		dc.l	submenu_11pattedit
		dc.l	0
		dc.l	submenu_13pattedit
		dc.l	0
		dc.l	togglecheditmode
		dc.l	0
		dc.l	togglemidiinputstatus	; input onoff
submenu_6pattedit
		dc.l	noteup
		dc.l	notedown
		dc.l	octaveup
		dc.l	octavedown
submenu_20pattedit
		dc.l	areamode_block
		dc.l	areamode_track
		dc.l	areamode_pattern
submenu_11pattedit
		dc.l	quant0
		dc.l	quant1
		dc.l	quant2
		dc.l	quant3
		dc.l	quant4
		dc.l	quant5
		dc.l	quant6
		dc.l	quant7
		dc.l	quant8
		dc.l	quant9
submenu_13pattedit
		dc.l	setoctave0
		dc.l	setoctave1
		dc.l	setoctave2

MENU_env
		dc.l	togglescreen
		dc.l	drumsequencer
		dc.l	arpeggio_editor
		dc.l	fmed
		dc.l	0	; etc
		dc.l	togglefilter
		dc.l	0		
		dc.l	setuped
		dc.l	changepalette
		dc.l	0
		dc.l	freezedisplay

MENU_ch
		dc.l	togglech1NOW
		dc.l	togglech2NOW
		dc.l	togglech3NOW
		dc.l	togglech4NOW
		dc.l	togglech5NOW
		dc.l	togglech6NOW
		dc.l	togglech7NOW
		dc.l	togglech8NOW
		dc.l	0
		dc.l	freechannels
		dc.l	showtrACKvols
		dc.l	0
		dc.l	set4channels
		dc.l	set8channels
		dc.l	setmixrate


MENU		MACRO
		dc.b	\1,0
		dc.l	\2,0
		dc	\3
		dc.l	0,0
		ENDM
MenuStruct
		MENU	NM_title,menutitle1,ITEMTEXT
		MENU	NM_item,mt1_item1,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt1_item2,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt1_3_item1,ITEMTEXT
		MENU	NM_item,mt1_3_item2,ITEMTEXT
		MENU	NM_item,mt1_3_item3,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt1_item8,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt1_item4,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt1_item6,ITEMTEXT

		MENU	NM_title,helptitle,ITEMTEXT
		MENU	NM_item,mt1_item7,ITEMTEXT
		MENU	NM_item,help_itemfreqs,ITEMTEXT
		MENU	NM_item,mt1_item5,ITEMTEXT
		MENU	NM_item,mt1_readrem,ITEMTEXT

		MENU	NM_title,env_title,itemtext
		MENU	NM_item,env_item1,itemtext
		MENU	NM_item,env_item3,itemtext
		MENU	NM_item,env_item4,itemtext
		MENU	NM_item,env_fmed,itemtext
		MENU	NM_item,nm_barlabel,itemtext
		MENU	NM_item,env_item6,itemtext
		MENU	NM_item,nm_barlabel,itemtext
		MENU	NM_item,env_item8,itemtext
		MENU	NM_item,env_item9,itemtext
		MENU	NM_item,nm_barlabel,itemtext
		MENU	NM_item,env_freeze,itemtext

		MENU	NM_title,ch_title,itemtext
		MENU	NM_item,ch_item1,itemtext
		MENU	NM_item,ch_item2,itemtext
		MENU	NM_item,ch_item3,itemtext
		MENU	NM_item,ch_item4,itemtext
		MENU	NM_item,ch_item5,itemtext
		MENU	NM_item,ch_item6,itemtext
		MENU	NM_item,ch_item7,itemtext
		MENU	NM_item,ch_item8,itemtext
		MENU	NM_item,nm_barlabel,itemtext
		MENU	NM_item,ch_item9,itemtext
		MENU	NM_item,ch_item10,itemtext
		MENU	NM_item,nm_barlabel,itemtext
		MENU	NM_item,ch_item11,itemtext
		MENU	NM_item,ch_item12,itemtext
		MENU	NM_item,ch_item13,itemtext


		MENU	NM_title,menutitle4,ITEMTEXT
		MENU	NM_item,mt4_item1,ITEMTEXT
		MENU	NM_sub,mt4_1_item1,ITEMTEXT
		MENU	NM_sub,mt4_1_item2,ITEMTEXT
		MENU	NM_sub,mt4_1_item3,ITEMTEXT
		MENU	NM_item,mt4_item2,ITEMTEXT
		MENU	NM_item,mt4_item3,ITEMTEXT
		MENU	NM_item,mt4_item4,ITEMTEXT
		MENU	NM_item,mt4_item5,ITEMTEXT
		MENU	NM_item,mt4_item6,ITEMTEXT
		MENU	NM_sub,mt4_6_item1,ITEMTEXT
		MENU	NM_sub,mt4_6_item2,ITEMTEXT
		MENU	NM_sub,mt4_6_item3,ITEMTEXT
		MENU	NM_sub,mt4_6_item4,ITEMTEXT
		MENU	NM_item,mt4_item7,ITEMTEXT
		MENU	NM_item,mt4_item8,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt4_item9,ITEMTEXT
		MENU	NM_item,mt4_item10,ITEMTEXT
		MENU	NM_item,mt4_expand,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt4_item11,ITEMTEXT
		MENU	NM_sub,mt4_11_item1,ITEMTEXT
		MENU	NM_sub,mt4_11_item2,ITEMTEXT
		MENU	NM_sub,mt4_11_item3,ITEMTEXT
		MENU	NM_sub,mt4_11_item4,ITEMTEXT
		MENU	NM_sub,mt4_11_item5,ITEMTEXT
		MENU	NM_sub,mt4_11_item6,ITEMTEXT
		MENU	NM_sub,mt4_11_item7,ITEMTEXT
		MENU	NM_sub,mt4_11_item8,ITEMTEXT
		MENU	NM_sub,mt4_11_item9,ITEMTEXT
		MENU	NM_sub,mt4_11_item10,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt4_item13,ITEMTEXT
		MENU	NM_sub,mt4_13_item1,ITEMTEXT
		MENU	NM_sub,mt4_13_item2,ITEMTEXT
		MENU	NM_sub,mt4_13_item3,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt4_editmode,ITEMTEXT
		MENU	NM_item,nm_barlabel,ITEMTEXT
		MENU	NM_item,mt4_item12,ITEMTEXT



		MENU	NM_title,menutitle2,ITEMTEXT
		MENU	NM_item,module_instrnames+0*32,ITEMTEXT
		MENU	NM_item,module_instrnames+1*32,ITEMTEXT
		MENU	NM_item,module_instrnames+2*32,ITEMTEXT
		MENU	NM_item,module_instrnames+3*32,ITEMTEXT
		MENU	NM_item,module_instrnames+4*32,ITEMTEXT
		MENU	NM_item,module_instrnames+5*32,ITEMTEXT
		MENU	NM_item,module_instrnames+6*32,ITEMTEXT
		MENU	NM_item,module_instrnames+7*32,ITEMTEXT
		MENU	NM_item,module_instrnames+8*32,ITEMTEXT
		MENU	NM_item,module_instrnames+9*32,ITEMTEXT
		MENU	NM_item,module_instrnames+10*32,ITEMTEXT
		MENU	NM_item,module_instrnames+11*32,ITEMTEXT
		MENU	NM_item,module_instrnames+12*32,ITEMTEXT
		MENU	NM_item,module_instrnames+13*32,ITEMTEXT
		MENU	NM_item,module_instrnames+14*32,ITEMTEXT
		MENU	NM_item,module_instrnames+15*32,ITEMTEXT
		MENU	NM_item,module_instrnames+16*32,ITEMTEXT
		MENU	NM_item,module_instrnames+17*32,ITEMTEXT
		MENU	NM_item,module_instrnames+18*32,ITEMTEXT
		MENU	NM_item,module_instrnames+19*32,ITEMTEXT
		MENU	NM_item,module_instrnames+20*32,ITEMTEXT
		MENU	NM_item,module_instrnames+21*32,ITEMTEXT
		MENU	NM_item,module_instrnames+22*32,ITEMTEXT
		MENU	NM_item,module_instrnames+23*32,ITEMTEXT
		MENU	NM_item,module_instrnames+24*32,ITEMTEXT
		MENU	NM_item,module_instrnames+25*32,ITEMTEXT
		MENU	NM_item,module_instrnames+26*32,ITEMTEXT
		MENU	NM_item,module_instrnames+27*32,ITEMTEXT
		MENU	NM_item,module_instrnames+28*32,ITEMTEXT
		MENU	NM_item,module_instrnames+29*32,ITEMTEXT
		MENU	NM_item,module_instrnames+30*32,ITEMTEXT

		MENU	NM_title,menutitle3,ITEMTEXT
		MENU	NM_item,module_instrnames+31*32,ITEMTEXT
		MENU	NM_item,module_instrnames+32*32,ITEMTEXT
		MENU	NM_item,module_instrnames+33*32,ITEMTEXT
		MENU	NM_item,module_instrnames+34*32,ITEMTEXT
		MENU	NM_item,module_instrnames+35*32,ITEMTEXT
		MENU	NM_item,module_instrnames+36*32,ITEMTEXT
		MENU	NM_item,module_instrnames+37*32,ITEMTEXT
		MENU	NM_item,module_instrnames+38*32,ITEMTEXT
		MENU	NM_item,module_instrnames+39*32,ITEMTEXT
		MENU	NM_item,module_instrnames+40*32,ITEMTEXT
		MENU	NM_item,module_instrnames+41*32,ITEMTEXT
		MENU	NM_item,module_instrnames+42*32,ITEMTEXT
		MENU	NM_item,module_instrnames+43*32,ITEMTEXT
		MENU	NM_item,module_instrnames+44*32,ITEMTEXT
		MENU	NM_item,module_instrnames+45*32,ITEMTEXT
		MENU	NM_item,module_instrnames+46*32,ITEMTEXT
		MENU	NM_item,module_instrnames+47*32,ITEMTEXT
		MENU	NM_item,module_instrnames+48*32,ITEMTEXT
		MENU	NM_item,module_instrnames+49*32,ITEMTEXT
		MENU	NM_item,module_instrnames+50*32,ITEMTEXT
		MENU	NM_item,module_instrnames+51*32,ITEMTEXT
		MENU	NM_item,module_instrnames+52*32,ITEMTEXT
		MENU	NM_item,module_instrnames+53*32,ITEMTEXT
		MENU	NM_item,module_instrnames+54*32,ITEMTEXT
		MENU	NM_item,module_instrnames+55*32,ITEMTEXT
		MENU	NM_item,module_instrnames+56*32,ITEMTEXT
		MENU	NM_item,module_instrnames+57*32,ITEMTEXT
		MENU	NM_item,module_instrnames+58*32,ITEMTEXT
		MENU	NM_item,module_instrnames+59*32,ITEMTEXT
		MENU	NM_item,module_instrnames+60*32,ITEMTEXT

		MENU	NM_end,0,0
MenuTags
		dc.l	GTMN_frontPen,2
		dc.l	GTMN_fullmenu,TRUE
		dc.l	Tag_Done
LayoutTags	
		dc.l	GTMN_textattr,topaz8
		dc.l	Tag_Done

emptyitem	dc.b	0
		ifeq	lang
MenuTitle1	dc.b	"Project  ",0
helptitle	dc.b	"?  ",0
MenuTitle4	dc.b	"Pattern-Editor  ",0
env_title	dc.b	"Environment  ",0
ch_title	dc.b	"Channels  ",0
MenuTitle2	dc.b	"1-V  ",0
MenuTitle3	dc.b	"W-z  ",0

mt1_item7	dc.b	"Player commands  lalt+-",0
help_itemfreqs	dc.b	"Sample-Frequency",0


mt1_item1	dc.b	"New",0
mt1_item2	dc.b	"Load Module      lalt+l",0
mt1_3_item1	dc.b	"Save Module      lalt+s",0
mt1_3_item2	dc.b	"Save Player+Module",0
mt1_3_item3	dc.b	"Save Executable",0
mt1_item8	dc.b	"PP-Crunch file   lalt+#",0
mt1_item4	dc.b	"Delete file",0
mt1_item5	dc.b	"About",0
;mt1_itempublic	dc.b	"Public message",0
mt1_readrem	dc.b	"Show remark      lalt+.",0
mt1_item6	dc.b	"Quit AON",0

env_item1	dc.b	"Instr/Wave-Editor    esc & `",0
env_item3	dc.b	"Drum-Sequencer       lalt+d",0
env_item4	dc.b	"Arpeggio-Editor      lalt+a",0
env_fmed	dc.b	"FM-Synthesizer",0
env_item6	dc.b	"Filter   : "
filteronoff_txt	dc.b	"Off",0
env_item8	dc.b	"Setup                lalt+u",0
env_item9	dc.b	"Palette",0
env_freeze	dc.b	"Freeze Display: "
freezeASC	dc.b	"Off  lalt+space",0

ch_item1	dc.b	"Toggle Ch1                 lalt+y",0
ch_item2	dc.b	"Toggle Ch2                 lalt+x",0
ch_item3	dc.b	"Toggle Ch3                 lalt+c",0
ch_item4	dc.b	"Toggle Ch4                 lalt+v",0
ch_item5	dc.b	"Toggle Ch5            lsft+lalt+y",0
ch_item6	dc.b	"Toggle Ch6            lsft+lalt+x",0
ch_item7	dc.b	"Toggle Ch7            lsft+lalt+c",0
ch_item8	dc.b	"Toggle Ch8            lsft+lalt+v",0
ch_item9	dc.b	"Free channels              lalt+f",0
ch_item10	dc.b	"Show Trackvolumes          lalt+z",0
ch_item11	dc.b	"4 channels",0
ch_item12	dc.b	"8 channels",0
ch_item13	dc.b	"Mixrate         : "
mixrateASC	dc.b	"15000 Hz",0


mt4_item1	dc.b	"Area     : "
areamodeasc	dc.b	"Block  ",0
mt4_1_item1	dc.b	"Block    lalt+1",0
mt4_1_item2	dc.b	"Track    lalt+2",0
mt4_1_item3	dc.b	"Pattern  lalt+3",0
mt4_item2	dc.b	"Mark Block        ctrl+b",0
mt4_item3	dc.b	"Cut               ctrl+x",0
mt4_item4	dc.b	"Copy              ctrl+c",0
mt4_item5	dc.b	"Paste             ctrl+i",0
mt4_item6	dc.b	"Transpose",0
mt4_6_item1	dc.b	"Note Up      ctrl+a",0
mt4_6_item2	dc.b	"Note Down    ctrl+s",0
mt4_6_item3	dc.b	"Octave Up    ctrl+d",0
mt4_6_item4	dc.b	"Octave Down  ctrl+f",0
mt4_item7	dc.b	"Change volume     ctrl+l",0
mt4_item8	dc.b	"Wildstar Replace  ctrl+r",0

mt4_item9	dc.b	"Exchange patterns ctrl+e",0
mt4_item10	dc.b	"Exchange tracks   ctrl+t",0
mt4_expand	dc.b	"Expand track      ctrl+o",0

mt4_item11	dc.b	"Quantisize",0
mt4_11_item1	dc.b	"Quant=0  ctrl+0",0
mt4_11_item2	dc.b	"Quant=1  ctrl+1",0
mt4_11_item3	dc.b	"Quant=2  ctrl+2",0
mt4_11_item4	dc.b	"Quant=3  ctrl+3",0
mt4_11_item5	dc.b	"Quant=4  ctrl+4",0
mt4_11_item6	dc.b	"Quant=5  ctrl+5",0
mt4_11_item7	dc.b	"Quant=6  ctrl+6",0
mt4_11_item8	dc.b	"Quant=7  ctrl+7",0
mt4_11_item9	dc.b	"Quant=8  ctrl+8",0
mt4_11_item10	dc.b	"Quant=9  ctrl+9",0

mt4_item13	dc.b	"Edit octave",0
mt4_13_item1	dc.b	"Octave C-1>G#3  shift+f1",0
mt4_13_item2	dc.b	"Octave C-3>G#5        f1",0
mt4_13_item3	dc.b	"Octave C-4>B-5        f2",0

mt4_editmode	dc.b	"Ch-Ed     : "
mt4_editmodeASC	dc.b	"Single",0

mt4_item12	dc.b	"MIDI-input: "
midi_inputst.txt dc.b	"Off",0



		else

MenuTitle1	dc.b	"Projekt  ",0
helptitle	dc.b	"?  ",0
MenuTitle4	dc.b	"Pattern-Editor  ",0
env_title	dc.b	"Umgebung  ",0
ch_title	dc.b	"Kanäle  ",0
MenuTitle2	dc.b	"1-V  ",0
MenuTitle3	dc.b	"W-z  ",0

mt1_item7	dc.b	"Player Befehle  lalt+-",0
help_itemfreqs	dc.b	"Sample-Frequenzen",0


mt1_item1	dc.b	"Neu",0
mt1_item2	dc.b	"Lade Modul            lalt+l",0
mt1_3_item1	dc.b	"Speicher Modul        lalt+s",0
mt1_3_item2	dc.b	"Speicher Player+Modul",0
mt1_3_item3	dc.b	"Speicher Executable",0
mt1_item8	dc.b	"PP-Crunch Datei       lalt+#",0
mt1_item4	dc.b	"Lösche Datei",0
mt1_item5	dc.b	"Über",0

;mt1_itempublic	dc.b	"Nachricht an alle...",0
mt1_readrem	dc.b	"Zeige Remark      lalt+.",0
mt1_item6	dc.b	"Verlasse AON",0

env_item1	dc.b	"Instr/Wave-Editor        esc & `",0
env_item3	dc.b	"Drum-Sequencer           lalt+d",0
env_item4	dc.b	"Arpeggio-Editor          lalt+a",0
env_fmed	dc.b	"FM-Synthesizer",0
env_item6	dc.b	"Filter   : "
filteronoff_txt	dc.b	"Aus",0
env_item8	dc.b	"Setup                    lalt+u",0
env_item9	dc.b	"Palette",0
env_freeze	dc.b	"Anzeige einfrieren: "
freezeASC	dc.b	"Aus  lalt+space",0

ch_item1	dc.b	"Ch1 an/aus                 lalt+y",0
ch_item2	dc.b	"Ch2 an/aus                 lalt+x",0
ch_item3	dc.b	"Ch3 an/aus                 lalt+c",0
ch_item4	dc.b	"Ch4 an/aus                 lalt+v",0
ch_item5	dc.b	"Ch5 an/aus            lsft+lalt+y",0
ch_item6	dc.b	"Ch6 an/aus            lsft+lalt+x",0
ch_item7	dc.b	"Ch7 an/aus            lsft+lalt+c",0
ch_item8	dc.b	"Ch8 an/aus            lsft+lalt+v",0
ch_item9	dc.b	"Kanäle freigeben           lalt+f",0
ch_item10	dc.b	"Zeige Tracklautstärken     lalt+z",0
ch_item11	dc.b	"4 Kanäle",0
ch_item12	dc.b	"8 Kanäle",0
ch_item13	dc.b	"Mischrate       : "
mixrateASC	dc.b	"15000 Hz",0


mt4_item1	dc.b	"Bereich  : "
areamodeasc	dc.b	"Block  ",0
mt4_1_item1	dc.b	"Block    lalt+1",0
mt4_1_item2	dc.b	"Track    lalt+2",0
mt4_1_item3	dc.b	"Pattern  lalt+3",0
mt4_item2	dc.b	"Markiere Block    ctrl+b",0
mt4_item3	dc.b	"Cut               ctrl+x",0
mt4_item4	dc.b	"Copy              ctrl+c",0
mt4_item5	dc.b	"Paste             ctrl+i",0
mt4_item6	dc.b	"Transponieren",0
mt4_6_item1	dc.b	"Note hoch      ctrl+a",0
mt4_6_item2	dc.b	"Note runter    ctrl+s",0
mt4_6_item3	dc.b	"Oktave hoch    ctrl+d",0
mt4_6_item4	dc.b	"Oktave runter  ctrl+f",0
mt4_item7	dc.b	"Ändere Lautstärke ctrl+l",0
mt4_item8	dc.b	"Wildstar Replace  ctrl+r",0

mt4_item9	dc.b	"Pattern-Austausch ctrl+e",0
mt4_item10	dc.b	"Track-Austausch   ctrl+t",0
mt4_expand	dc.b	"Track expandieren ctrl+o",0

mt4_item11	dc.b	"Quantisieren",0
mt4_11_item1	dc.b	"Quant=0  ctrl+0",0
mt4_11_item2	dc.b	"Quant=1  ctrl+1",0
mt4_11_item3	dc.b	"Quant=2  ctrl+2",0
mt4_11_item4	dc.b	"Quant=3  ctrl+3",0
mt4_11_item5	dc.b	"Quant=4  ctrl+4",0
mt4_11_item6	dc.b	"Quant=5  ctrl+5",0
mt4_11_item7	dc.b	"Quant=6  ctrl+6",0
mt4_11_item8	dc.b	"Quant=7  ctrl+7",0
mt4_11_item9	dc.b	"Quant=8  ctrl+8",0
mt4_11_item10	dc.b	"Quant=9  ctrl+9",0

mt4_item13	dc.b	"Editier Oktave",0
mt4_13_item1	dc.b	"Oktave C-1>G#3  shift+f1",0
mt4_13_item2	dc.b	"Oktave C-3>G#5        f1",0
mt4_13_item3	dc.b	"Oktave C-4>B-5        f2",0

mt4_editmode	dc.b	"Ch-Ed     : "
mt4_editmodeASC	dc.b	"Single",0

mt4_item12	dc.b	"MIDI-Eingabe: "
midi_inputst.txt dc.b	"Aus",0

		endif

		even





;----------------------------------------------------
;----------------------------------------------------- Message requester
freqs_str		dc.l	freqs_strE-freqs_str	; sizeOf
			dc.l	0				; flax
			dc.l	freqs_title			; title
			dc.l	freqs_messy			; body-text
			dc.l	freqs_gadgets			; Gadgets!
freqs_strE

			ifne	lang
freqs_title
 dc.b "ArtOfNoise V1.9  -  Sample-Frequenz Info Seite",0
freqs_messy
 dc.b	"Oft benutzte Sample-Frequenzen:",$a
 dc.b	$a
 dc.b	"C-1= 1045 D-1= 1174 E-1= 1320 F-1= 1398 G-1= 1570 A-1= 1762 B-1= 1975",$a
 dc.b	"C-2= 2091 D-2= 2349 E-2= 2640 F-2= 2796 G-2= 3140 A-2= 3523 B-2= 3951",$a
 dc.b	"C-3= 4182 D-3= 4698 E-3= 5280 F-3= 5593 G-3= 6280 A-3= 7046 B-3= 7902",$a
 dc.b	"C-4= 8363 D-4= 9396 E-4=10559 F-4=11186 G-4=12560 A-4=14093 B-4=15804",$a
 dc.b	"C-5=16727 D-5=18792 E-5=21118 F-5=22371 G-5=25120 A-5=28185 B-5=31607",$a
 dc.b 	$a
 dc.b	"Achtung: Sample-Frequenzen oberhalb von 28867Hz sind nur mit einem",$a
 dc.b	"Multiscan oder VGA-Monitor möglich. Dazu sollte CH dann im Euro72",$a
 dc.b	"Productivity Screen-Modus laufen.",$a
 dc.b	0
freqs_gadgets	dc.b	"Zurück",0

			else
freqs_title
 dc.b "ArtOfNoise V1.9  -  Sample-Frequency info page",0
freqs_messy
 dc.b	"Frequently used sample-frequencies..:",$a
 dc.b	$a
 dc.b	"C-1= 1045 D-1= 1174 E-1= 1320 F-1= 1398 G-1= 1570 A-1= 1762 B-1= 1975",$a
 dc.b	"C-2= 2091 D-2= 2349 E-2= 2640 F-2= 2796 G-2= 3140 A-2= 3523 B-2= 3951",$a
 dc.b	"C-3= 4182 D-3= 4698 E-3= 5280 F-3= 5593 G-3= 6280 A-3= 7046 B-3= 7902",$a
 dc.b	"C-4= 8363 D-4= 9396 E-4=10559 F-4=11186 G-4=12560 A-4=14093 B-4=15804",$a
 dc.b	"C-5=16727 D-5=18792 E-5=21118 F-5=22371 G-5=25120 A-5=28185 B-5=31607",$a
 dc.b 	$a
 dc.b	"Note that replaying sample-frequencies above 28867 Hz is only possible",$a
 dc.b	"when using a multiscan-monitor (and euro72 productivity screenmode) !!",$a
 dc.b	0
freqs_gadgets	dc.b	"Return",0
			endif

			even

effects_str		dc.l	effects_strE-effects_str	; sizeOf
			dc.l	0				; flax
			dc.l	effects_title			; title
			dc.l	effects_messy			; body-text
			dc.l	effects_gadgets			; Gadgets!
effects_strE

effects_title
 dc.b "ArtOfNoise V1.9  -  Player commands page 1/3",0


effects_messy

 dc.b "0 - normal play or Arpeggio       0xy : x-first halfnote add, y-second",$a
 dc.b "1 - slide Up                      1xx : upspeed                       ",$a
 dc.b "2 - slide Down                    2xx : downspeed                     ",$a
 dc.b "3 - tone Portamento               3xx : up/down speed		     ",$a
 dc.b "4 - vibrato                       4xy : x-speed,   y-depth	     ",$a
 dc.b "5 - tone Portamento + Vol. Slide  5xy : x-upspeed, y-downspeed	     ",$a
 dc.b "6 - vibrato + Volume Slide        6xy : x-upspeed, y-downspeed	     ",$a
 dc.b "7 - tremolo                       7xy : x-speed,   y-depth            ",$a
 dc.b "8 - NOT USED                                                          ",$a
 dc.b "9 - set SampleOffset              9xx : offset (23 -> 2300)           ",$a
 dc.b "A - volumeSlide                   Axy : x-upspeed, y-downspeed        ",$a
 dc.b "B - position Jump                 Bxx : songposition                  ",$a
 dc.b "C - set Volume                    Cxx : volume, 00-40                 ",$a
 dc.b "D - pattern Break                 Dxx : break position in next patt   ",$a
 dc.b "E0- set Filter                    E0x : 0-filter on, 1-filter off     ",$a
 dc.b "E1- fineSlide Up                  E1x : value                         ",$a
 dc.b "E2- fineSlide Down                E2x : value                         ",$a
 dc.b "E3- glissando Control             E3x : 0-off, 1-on (use with tonep.) ",$a
 dc.b "E4- set Vibrato Waveform          E4x : 0-sine, 1-ramp down, 2-square ",$a
 dc.b "E5- set Loop                      E5x : set loop point                ",$a
 dc.b "E6- jump to Loop                  E6x : jump to loop, play x times    ",$a
 dc.b	0
effects_gadgets	dc.b	"Next page...",0

			even
effects2_str		dc.l	effects2_strE-effects2_str	; sizeOf
			dc.l	0				; flax
			dc.l	effects2_title			; title
			dc.l	effects2_messy			; body-text
			dc.l	effects2_gadgets		; Gadgets!
effects2_strE

effects2_title
 dc.b "ArtOfNoise V1.9  -  Player commands page 2/3",0
effects2_messy
 dc.b "E7- set Tremolo Waveform          E7x : 0-sine, 1-ramp down. 2-square ",$a
 dc.b "E8- NOT USED                                                          ",$a
 dc.b "E9- retrig Note                   E9x : retrig from note + x vblanks  ",$a
 dc.b "EA- fine VolumeSlide Up           EAx : add x to volume               ",$a
 dc.b "EB- fine VolumeSlide Down         EBx : subtract x from volume        ",$a
 dc.b "EC- noteCut                       ECx : cut from note + x vblanks     ",$a
 dc.b "ED- noteDelay                     EDx : delay note x vblanks          ",$a
 dc.b "EE- patternDelay                  EEx : delay pattern x notes         ",$a
 dc.b "F - Set Speed                     Fxx : speed (00-1F) / tempo (20-FF) ",$a
 dc.b "G - new volume                    Gxy : set vol. to 4+(x*$4)+y vblanks",$a
 dc.b "H - synth control                 Hxy : x<>0=Keep wave, y<>0=Keep Env.",$a
 dc.b "I - wavetable speedcontrol        Ixy : wavespeed=x                   ",$a
 dc.b "J - set arpspeed                  Jxy : Set arpspd=y                  ",$a
 dc.b "K - set volume &do vibrato        Kxx : set volume=xx                 ",$a
 dc.b "L - fineslide&portamento UP       Lxy : volslide=x  , portamento=y    ",$a
 dc.b "M - fineslide&portamento DOWN     Mxy : volslide=x  , portamento=y    ",$a
 dc.b "N - avoid noise (wave<512bytes)   Nxy : y<>0=noiseavoid on y=0=off    ",$a
 dc.b "O - play samples >128k            Oxy : y<>0=on y=0=off               ",$a
 dc.b "P - fine volslide&vibrato         Pxy : x=up , y=down                 ",$a
 dc.b "Q - vol&portdown-slide (syndrums) Qxy : x=portdown , y=volslidedown   ",$a
 dc.b "R - set volume & tone portamento  Rxx : xx=new volume                 ",$a
 dc.b 0
effects2_gadgets	dc.b	"Next page...",0
			even

effects3_str		dc.l	effects3_strE-effects3_str	; sizeOf
			dc.l	0				; flax
			dc.l	effects3_title			; title
			dc.l	effects3_messy			; body-text
			dc.l	effects3_gadgets		; Gadgets!
effects3_strE

effects3_title
 dc.b "ArtOfNoise V1.9  -  Player commands page 3/3",0
effects3_messy
 dc.b "S - finevolslide & tone portam.   Sxy : x=finevol up , y=finevol down",$a
 dc.b "T - set track-volume              Txx : xx=new track-volume",$a
 dc.b "U - set wavetable-mode            Uxy : x<>0=freeze wavetable",$a
 dc.b "                                        y<>0=never reset wavetable",$a
 dc.b "V - unused",$a
 dc.b "W - unused",$a
 dc.b "X - external event 1 (synchro)    Xxx : Event #1 set to xx",$a
 dc.b "Y - external event 2 (synchro)    Yxx : Event #2 set to xx",$a
 dc.b "Z - external event 3 (synchro)    Zxx : Event #3 set to xx",$a
 dc.b 0
effects3_gadgets	dc.b	"Return",0
		even

msg_cracks:
 dc.b	"First a big **THANKS** to all who bought AON. As you know: ",$a
 dc.b	"A program worth using is a program worth buying!!",$a
 dc.b	$a
 dc.b	"Now a small notice to all people who COPIED ArtOfNoise:",$a
 dc.b	$a
 dc.b	"If CH should be a 'flop' (too few copies sold) for me, there",$a
 dc.b	"will probably be NO MORE UPDATES. This means that all future",$a
 dc.b	"versions of CH will only be for MY private use, so I hope",$a
 dc.b	"you know what you are doing if you copy this program without",$a
 dc.b	"paying me.",$a
 dc.b	$a
 dc.b	"Features of CH-2 ?",$a
 dc.b	$a
 dc.b	"  - A new look (protracker-speed and system-look!)",$a
 dc.b	"  - Full MIDI-Support!!!",$a
 dc.b	"  - Up to 32 channels including some very astonishing features!!",$a
 dc.b	"  - Soundcard-Support",$a
 dc.b	"  - Many new features like timestretching, multisampling, many new",$a
 dc.b	"    envelopes, new (advanced) wavetable instruments etc..",$a
 dc.b	"  - Will be able to load SMF,XM (Fasttracker ][), Screamtracker3",$a
 dc.b	"    and many more!",$a
 dc.b	$a
 dc.b	"So, fasten your seatbelts and get ready for take-off...",0

; ·------------------------------------------------------------------------·


;----------------------------------------------------- Message requester
			even

messy_str		dc.l	messy_strE-messy_str	; sizeOf
			dc.l	0				; flax
			dc.l	messy_title			; title
			dc.l	0				; body-text
			dc.l	messy_gadgets			; Gadgets!
messy_strE
			ifeq	lang
messy_title		dc.b	"Program message",0
			else
messy_title		dc.b	"Programm Nachricht",0
			endif
messy_gadgets		dc.b	"OK",0


			ifeq	lang

msg_noremark		dc.b	"No remark attached to song!!",0

msg_sys_notimerB	dc.b	"Can't allocate TIMER-B !!!!",0

msg_nowindow		dc.b	"Fatal error! Can't open main-window!!",0

msg_pp_outofmemload	dc.b	"Can't allocate memory for unpacked file!!!",0
msg_pp_canceled		dc.b	"Crunching aborted...",0
msg_pp_overflow		dc.b	"Crunchbuffer overflow !!!",0
msg_pp_alreadypacked	dc.b	"File is already powerpacked!!!",0

msg_io_filenotfound	dc.b	"Error locking to selected file...",0
msg_io_fileerror	dc.b	"Error accessing file...",0
msg_sys_notimplentedyet	dc.b	"Sorry!! Function not implented yet!!",0
msg_sys_cantloadwave	dc.b	"Can't allocate memory for wave!!",0

msg_blanker_outofmem	dc.b	"Couldn't allocate memory for screenblanker",$a
			dc.b	"module (64k chip) .. ",0
msg_blanker_fileerror	dc.b	"Couldn't open selected screenblanker module!",0
msg_blanker_initfailed	dc.b	"Screenblanker-Module-Initalization failed !!",0
msg_blanker_loadfailed	dc.b	"Error while loading screenblanker-module!!",0

msg_ss_remerror		dc.b	"Error accessing remark-file !!",$a
			dc.b	"('ram:aon.moduleRemark.txt')",0

msg_ls_outofmem		dc.b	"Can't load selected module:",$a
			dc.b	"Out of memory !!",0
msg_ls_unknownformat	dc.b	"Unknown module-format!!",$a
			dc.b	$a
			dc.b	"Supported formats:   - AON/ArtOfNoise ;)",$a
			dc.b	"                     - Protracker",$a
			dc.b	"                     - Noisetracker",$a
			dc.b	$a
		dc.b	"Supported packer:    - Powerpacker (lib)",$a
		dc.b	"                     - Stonecracker (S404!!)",$a
		dc.b	0
msg_ls_noSTCmem	dc.b	"Not enough memory to decrunch",$a
		dc.b	"STONECRACKER'S404' module !",0

msg_arp_nowindow	dc.b	"Couldn't open arpeggio-editor window !!!",0

msg_prf_usingdefault
		dc.b	"Can't find your preferences file :",$a
		dc.b	"'ArtOfNoise.config'",$a
		dc.b	$a
		dc.b	"Using defaults now...",0
msg_prf_noconfigfile
		dc.b	"Selected file is not a preferences file!!",$a
		dc.b	$a
		dc.b	"Using defaults now...",0

msg_midi_noserial	dc.b	"RBF & TBE Irqs in use !",$a
			dc.b	"Abort serial transfer(s) and come back !",$a

msg_dseq_nowindow	dc.b	"Couldn't open drum-sequencer window !!!",0
msg_dseq_nowave8	dc.b	"Not enough memory for 8Bit sequenced wave!!!",0
msg_dseq_nowave16	dc.b	"Not enough memory for 16Bit sequenced wave!!!",0
msg_dseq_wrongformat	dc.b	"No AON-Drumsequence-File !!",0


msg_instred_nowindow	dc.b	"Couldn't open instrument-editor window !!!",0
msg_instred_no8svx	dc.b	"No 8SVX-IF-FORMAT ! Loading aborted...",0
msg_instred_noVHDR	dc.b	"Missing 'VHDR' chunk in 8SVX-file !!!",0
msg_instred_noBODY	dc.b	"Missing 'BODY' chunk in 8SVX-file !!!",0
msg_instred_allwavesused
			dc.b	"No free waveform !!",0
msg_instred_outofmemory	dc.b	"Out of memory !!",0
msg_instred_outofmemoryFT dc.b	"Can't alloc new wave, because destination",$a
			dc.b	"instrument may already contain used",$a
			dc.b	"wave or your memory is full ..",0

msg_patt_markblockfirst	dc.b	"Please mark a block first!!",0

msg_setup_nowindow	dc.b	"Couldn't open setup window !!!",0

msg_chfree
 dc.b "Channels are now unused..",$a
 dc.b "You can now use another player",$a
 dc.b "(note: CIA-Interrupt B is NOT free!)",$a
 dc.b 0

msg_waveed_nowindow	dc.b	"Couldn't open waveform-editor window !!!",0

msg_fmed_nowindow	dc.b	"Couldn't open FMSynth-editor window !!!",0


msg_trackvol
		dc.b	"Track 1  : 64 ($40)",$a
msg_tvlen	=*-msg_trackvol
		dc.b	"Track 2  : 64 ($40)",$a
		dc.b	"Track 3  : 64 ($40)",$a
		dc.b	"Track 4  : 64 ($40)",$a
		dc.b	"Track 5  : 64 ($40)",$a
		dc.b	"Track 6  : 64 ($40)",$a
		dc.b	"Track 7  : 64 ($40)",$a
		dc.b	"Track 8  : 64 ($40)",0

msg_noextproc
		dc.b	"You need at least an MC68020 to use 8 Channels!!",0


msg_wave_mixnowave
		dc.b	"Current waveform is empty! Use Ğpasteğ!",0
msg_wave_norange
		dc.b	"No range set !!!",0
msg_wave_invrange
		dc.b	"Invalid range !!!",0
msg_wave_cutbufnomem
		dc.b	"Couldn't cut buf: No workmem free!!",0
msg_wave_copybufnomem
		dc.b	"Couldn't copy buf: No workmem free!!",0
msg_wave_nonewwave
		dc.b	"Couldn't allocate new wave!!",0
msg_wave_bufferempty
		dc.b	"Edit-Buffer is empty !!",0
msg_wave_pdrange2big
		dc.b	"Maximal rangesize = 512 bytes!!",0
msg_wave_samplenomem
		dc.b	"Can't allocate memory for sampling !!",0
msg_wave_nofreeinstr
		dc.b	"Instrument creation failed: No free instrument found!",0
msg_fmed_nomem
		dc.b	"Not enough memory for fm-wave!!",0
msg_fmed_zerolen
		dc.b	"Destination wavelength must not be zero!!",0
msg_fmed_wrong4mat
		dc.b	"No AON-FMSynthV1.4 format!!",0

msg_nofont	dc.b	"Can't open AON.font ! CU..",0

msg_nodiskfontlib	dc.b	"Can't open diskfont.library! CU..",0

msg_noutillib	dc.b	"Can't open utility.library! CU..",0

msg_noreqlib	dc.b	"Can't open reqtools.library! CU..",0

msg_nopplib	dc.b	"Can't open powerpacker.library! CU..",0



		else

msg_noremark		dc.b	"Song enthält keine Bemerkung!!",0

msg_sys_notimerB	dc.b	"Kann TIMER-B nicht allokieren !!!!",0

msg_nowindow		dc.b	"Fehler! Kann Main-Window nicht öffnen!!",0

msg_pp_outofmemload	dc.b	"Kann Speicher für ungepacktes File nicht allokieren!!!",0
msg_pp_canceled		dc.b	"Crunchen abgebrochen...",0
msg_pp_overflow		dc.b	"Crunchbuffer overflow !!!",0
msg_pp_alreadypacked	dc.b	"Datei ist bereits gepowerpackt!!!",0

msg_io_filenotfound	dc.b	"Datei kann leider nicht geöffnet werden...",0
msg_io_fileerror	dc.b	"Fehler beim Zugriff auf Datei...",0
msg_sys_notimplentedyet	dc.b	"Sorry!! Die Funktion gibts leider noch nicht!!",0
msg_sys_cantloadwave	dc.b	"Kann Speicher für Wellenform nicht allokieren!!",0

msg_blanker_outofmem	dc.b	"Kann Speicher für Screenblankermodul nicht",$a
			dc.b	"allokieren (64k Chip)",0
msg_blanker_fileerror	dc.b	"Kann Screenblankermodul nicht öffnen!",0
msg_blanker_initfailed	dc.b	"Screenblankermodul-Initalisierung fehlgeschlagen!!",0
msg_blanker_loadfailed	dc.b	"Fehler beim Lesen des Screenblankermodul!!",0

msg_ss_remerror		dc.b	"Fehler beim Zugriff auf das Remark-File !!",$a
			dc.b	"('ram:aon.moduleRemark.txt')",0

msg_ls_outofmem		dc.b	"Kann Modul nicht laden:",$a
			dc.b	"Kein Speicher mehr!!",0
msg_ls_unknownformat	dc.b	"Unbekanntes Modul-Format!!",$a
			dc.b	$a
			dc.b	"Unterstützte Formate:  - AON/ArtOfNoise ;)",$a
			dc.b	"                       - Protracker",$a
			dc.b	"                       - Noisetracker",$a
			dc.b	$a
		dc.b	"Unterstützte Packer:           - Powerpacker (lib)",$a
		dc.b	"                               - Stonecracker (S404!!)",$a
		dc.b	0
msg_ls_noSTCmem	dc.b	"Nicht genug Speicher um",$a
		dc.b	"STONECRACKER'S404' Datei zu entpacken!!",0

msg_arp_nowindow	dc.b	"Kann Arpeggio-Editor Fenster nicht öffnen!!!",0

msg_prf_usingdefault
	dc.b	"Kann Preference-Datei 'ArtOfNoise.config' ",$a
	dc.b	"nicht finden !",$a
	dc.b	$a
	dc.b	"Ich benutze die Default-Einstellungen!",0

msg_prf_noconfigfile
		dc.b	"Das ist doch keine Preference-Datei!!",$a
		dc.b	$a
		dc.b	"Ich benutze die Default-Einstellungen!",0

msg_midi_noserial
	dc.b	"RBF & TBE Irqs werden benutzt!",$a
	dc.b	"Beende serielle Übertragung und komm dann wieder!",$a

msg_dseq_nowindow	dc.b	"Kann Drum-Sequenzer Fenster nicht öffnen!!!",0
msg_dseq_nowave8	dc.b	"Nicht genug Speicher für 8Bit Wellenform!!!",0
msg_dseq_nowave16	dc.b	"Nicht genug Speicher für 16Bit Wellenform!!",0
msg_dseq_wrongformat	dc.b	"Keine AON-Drumsequenz-Datei !!",0

msg_instred_nowindow	dc.b	"Kann Instrument-Editor Fenster nicht öffnen!!!",0
msg_instred_no8svx	dc.b	"Kein 8SVX-IF-FORMAT ! Ladevorgang abgebrochen...",0
msg_instred_noVHDR	dc.b	"'VHDR' Chunk fehlt in der 8SVX-Datei !!!",0
msg_instred_noBODY	dc.b	"'BODY' Chunk fehlt in der 8SVX-Datei !!!",0
msg_instred_allwavesused
			dc.b	"Alle Wellenformen sind belegt!!",0
msg_instred_outofmemory	dc.b	"Kein Speicher mehr !!",0
msg_instred_outofmemoryFT
	dc.b	"Kann neue Wellenform nicht allokieren, da das Ziel",$a
	dc.b	"Instrument bereits eine benutzte Wellenform enthält.",$a
	dc.b	$a
	dc.b	"Vielleicht ist Dein Speicher auch nur einfach voll?!",0

msg_patt_markblockfirst	dc.b	"Bitte zuerst einen Block markieren!!",0

msg_setup_nowindow	dc.b	"Kann Setup-Fenster nicht öffnen!!!",0

msg_chfree
 dc.b "Kanäle sind jetzt unbenutzt..",$a
 dc.b "Du kannst jetzt einen anderen Player benutzen",$a
 dc.b "(Achtung: Der CIA-Interrupt B ist NICHT frei!)",$a
 dc.b 0

msg_waveed_nowindow	dc.b	"Kann Wellenform-Editor Fenster nicht öffnen !!!",0

msg_fmed_nowindow	dc.b	"Kann FMSynth-Fenster nicht öffnen!!!",0


msg_trackvol
		dc.b	"Track 1  : 64 ($40)",$a
msg_tvlen	=*-msg_trackvol
		dc.b	"Track 2  : 64 ($40)",$a
		dc.b	"Track 3  : 64 ($40)",$a
		dc.b	"Track 4  : 64 ($40)",$a
		dc.b	"Track 5  : 64 ($40)",$a
		dc.b	"Track 6  : 64 ($40)",$a
		dc.b	"Track 7  : 64 ($40)",$a
		dc.b	"Track 8  : 64 ($40)",0

msg_noextproc
 dc.b	"Du brauchst mindestens einen MC68020 um 8 Kanäle benutzen zu können!!",0


msg_wave_mixnowave
		dc.b	"Die aktuelle Wellenform ist nicht leer! Benutz' Ğpasteğ!",0
msg_wave_norange
		dc.b	"Keine Range gesetzt !!!",0
msg_wave_invrange
		dc.b	"Ungültige Range !!!",0
msg_wave_cutbufnomem
		dc.b	"Kann Buffer nicht ausschneiden: Kein Speicher frei!!",0
msg_wave_copybufnomem
		dc.b	"Kann Buffer nicht kopieren: Kein Speicher frei!!",0
msg_wave_nonewwave
		dc.b	"Kann neue Wellenform nicht allokieren!!",0
msg_wave_bufferempty
		dc.b	"Editier-Buffer ist leer !!",0
msg_wave_pdrange2big
		dc.b	"Maximale Rangegröße = 512 bytes!!",0
msg_wave_samplenomem
		dc.b	"Kann Speicher für Sampling nicht allokieren !!",0
msg_wave_nofreeinstr
	dc.b	"Instrument-Erstellung fehlgeschlagen: Kein freies Instrument verfügbar!",0
msg_fmed_nomem
		dc.b	"Nicht genug Speicher für FM-Wellenform!!",0
msg_fmed_zerolen
		dc.b	"Ziel-Wellenlänge darf nicht Null sein!!",0
msg_fmed_wrong4mat
		dc.b	"Kein AON-FMSynthV1.4 Format!!",0

msg_nofont	dc.b	"Kann AON.font nicht öffnen ! Ciao..",0

msg_nodiskfontlib	dc.b	"Kann diskfont.library nicht öffnen ! Ciao..",0

msg_noutillib	dc.b	"Kann utility.library nicht öffnen ! Ciao..",0

msg_noreqlib	dc.b	"Kann reqtools.library nicht öffnen ! Ciao..",0

msg_nopplib	dc.b	"Kann powerpacker.library nicht öffnen ! Ciao..",0

		endif
		even

			ifne save
msg_betatester:
			ifne lang

 dc.b	"Registriert für:                                              ",$a
 dc.b	"                    Georg Conrad                              ",$a
 dc.b	"                    Friedrich-Ebert Str. 160                  ",$a
 dc.b	$a
 dc.b	"Dieses ist ein KOMMERZIELLES Programm",$a
 dc.b	"und daher KEIN Public Domain !",$a
 dc.b	"Dem Autor sind alle Rechte an diesem Programm",$a
 dc.b	"vorbehalten und urheberrechtlich geschützt.",$a
 dc.b   "Vervielfältigung oder Weitervertrieb sind nicht",$a
 dc.b	"gestattet.",$a
 dc.b	"Der Autor übernimmt keine Haftung für evtl. Schäden",$a
 dc.b	"die durch Gebrauch dieses Programms enstehen könnten.",$a
 dc.b	"Benutzung auf eigene Gefahr!",$a
 dc.b	$a
 dc.b	"Falls Sie sich registrieren lassen möchten:",$a
 dc.b	$a
 dc.b	"Die Vollversion kostet 70DM (+Versand)",$a
 dc.b	"und beinhaltet 4 Disks + Anleitung als",$a
 dc.b	"AmigaGuide-Datei !",$a
 dc.b	"                   Bastian Spiegel",$a
 dc.b	"                   Trupermoorer Landstrasse 17a",$a
 dc.b	"                   28865 Lilienthal",$a
 dc.b	"                   TEL: 04298-30731",0

			else

 dc.b	"This version of AON is DRUG-WARE and thus FREELY DISTRIBUTABLE.",$a
 dc.b	$a
 dc.b	"If you like this piece of software, please send your favourite",$a
 dc.b	"drug (e.g. cigarettes, beer, cannabis, your girlfriend (?), your ",$a
 dc.b	"favourite music-tape or whatever) to:",$a
 dc.b	$a
 dc.b	"                   Bastian Spiegel",$a
 dc.b	"                   Trupermoorer Landstrasse 17a",$a
 dc.b	"                   28865 Lilienthal",$a
 dc.b	"                   TEL: 04298-30731",$a
 dc.b	$a
 dc.b	"Note that the author takes no responsibilty for any harm the use of",$a
 dc.b	"this program might cause. Use at own risk!",$a
 dc.b	$a
 dc.b	"Send your ideas and suggestions for the next version to the address",$a
 dc.b	"above!! See you in AON-2 !",$a
 dc.b	$a
 dc.b	0
		endif




		else

msg_demomode
		ifne lang

 dc.b	"Dies ist nur eine DEMO-Version!",$a
 dc.b	"Alle Speicher-Funktionen sind gesperrt!",$a
 dc.b	$a
 dc.b	"Die Vollversion kostet 70DM (+Versand)",$a
 dc.b	"und beinhaltet 4 Disks + Anleitung als",$a
 dc.b	"AmigaGuide-Datei !",$a
 dc.b	$a
 dc.b	"       Bastian Spiegel",$a
 dc.b	"       Trupermoorer Landstrasse 17a",$a
 dc.b	"       28865 Lilienthal",$a
 dc.b	"       TEL: 04298-30731",$a
 dc.b	0

		else

 dc.b	"This is only a demo-version!",$a
 dc.b	"All save-functions are disabled!",$a
 dc.b	$a
 dc.b	"Contact the author at:",$a
 dc.b	$a
 dc.b	"                   Bastian Spiegel",$a
 dc.b	"                   Trupermoorer Landstrasse 17a",$a
 dc.b	"                   28865 Lilienthal",$a
 dc.b	"                   TEL: 04298-30731",$a
 dc.b	$a
 dc.b	"The full version includes 4 Disks + (german) manual as amigaguide",$a
 dc.b	"file.",$a
 dc.b	0

		endif



		endif


msg_nicetry:
 dc.b	"Sorry, man. Trying to change the register-text doesn't work",$a
 dc.b	"that easy!! This version is UNUSUABLE from now on!",$a
 dc.b	$a
 dc.b	"Get YOUR copy of AON from:",$a
 dc.b	$a
 dc.b	"       Bastian Spiegel",$a
 dc.b	"       Trupermoorer Landstrasse 17a",$a
 dc.b	"       28865 Lilienthal",$a
 dc.b	"       TEL: 04298-30731",$a
 dc.b	$a
 dc.b	"(4Disks,Amigaguide-Doc, costs 70DM)",$a
 dc.b	$a
 dc.b	0

		even

;msg_copyright
; dc.b	"This program is --NO-- public domain!",$a
; dc.b	$a
; dc.b	"It is FORBIDDEN to copy/spread this program & its documentation!",$a
; dc.b	$a
; dc.b	"The demosong&instrument-disks are freely distributable.",$a
; dc.b	$a
; dc.b	$a
; dc.b	"The author of this program is in NO way responsible for ANY damage",$a
; dc.b	"that this program might cause !! Use at own risk..",$a
; dc.b	$a
; dc.b	$a
; dc.b	$a
; dc.b	$a
; dc.b	"ArtOfNoise IS COPYRIGHT İ 1995 SONIC SYSTEMS / BASTIAN SPIEGEL.",$a
; dc.b	0



			even
;-------------------------------------------------------------------- key2int
key2int_tab
			dc.l	$0000000a,0
			dc.l	$00000001,1
			dc.l	$00000002,2 
			dc.l	$00000003,3
			dc.l	$00000004,4 
			dc.l	$00000005,5
			dc.l	$00000006,6
			dc.l	$00000007,7
			dc.l	$00000008,8
			dc.l	$00000009,9
			dc.l	$00000020,10
			dc.l	$00000035,11
			dc.l	$00000033,12
			dc.l	$00000022,13
			dc.l	$00000012,14
			dc.l	$00000023,15 
			dc.l	$00000024,16
			dc.l	$00000025,17
			dc.l	$00000017,18
			dc.l	$00000026,19
			dc.l	$00000027,20
			dc.l	$00000028,21
			dc.l	$00000037,22
			dc.l	$00000036,23
			dc.l	$00000018,24
			dc.l	$00000019,25
			dc.l	$00000010,26
			dc.l	$00000013,27
			dc.l	$00000021,28
			dc.l	$00000014,29
			dc.l	$00000016,30
			dc.l	$00000034,31
			dc.l	$00000011,32
			dc.l	$00000032,33
			dc.l	$00000031,34
			dc.l	$00000015,35
			dc.l	$00010020,36
			dc.l	$00010035,37
			dc.l	$00010033,38
			dc.l	$00010022,39
			dc.l	$00010012,40
			dc.l	$00010023,41
			dc.l	$00010024,42
			dc.l	$00010025,43
			dc.l	$00010017,44
			dc.l	$00010026,45
			dc.l	$00010027,46
			dc.l	$00010028,47
			dc.l	$00010037,48
			dc.l	$00010036,49
			dc.l	$00010018,50
			dc.l	$00010019,51
			dc.l	$00010010,52
			dc.l	$00010013,53
			dc.l	$00010021,54
			dc.l	$00010014,55
			dc.l	$00010016,56
			dc.l	$00010034,57
			dc.l	$00010011,58
			dc.l	$00010032,59
			dc.l	$00010031,60
			dc.l	$00010015,61
			dc	-1
ne_raw2notetab_oct0
			dc.l	$00000031,1+24	C-3
			dc.l	$00000021,2+24	C#3
			dc.l	$00000032,3+24	D-3
			dc.l	$00000022,4+24	D#3
			dc.l	$00000033,5+24	E-3
			dc.l	$00000034,6+24	F-3
			dc.l	$00000024,7+24	F#3
			dc.l	$00000035,8+24	G-3
			dc.l	$00000025,9+24	G#3
			dc.l	$00000036,10+24	A-3
			dc.l	$00000026,11+24	A#3
			dc.l	$00000037,12+24	B-3
			dc.l	$00000038,13+24	C-4
			dc.l	$00000028,14+24	C#4
			dc.l	$00000039,15+24	D-4
			dc.l	$00000029,16+24	D#4
			dc.l	$0000003a,17+24	E-4
			dc.l	$00000010,13+24	C-4
			dc.l	$00000002,14+24	C#4
			dc.l	$00000011,15+24	D-4
			dc.l	$00000003,16+24	D#4
			dc.l	$00000012,17+24	E-4
			dc.l	$00000013,18+24	F-4
			dc.l	$00000005,19+24	F#4
			dc.l	$00000014,20+24	G-4
			dc.l	$00000006,21+24	G#4
			dc.l	$00000015,22+24	A-4
			dc.l	$00000007,23+24	A#4
			dc.l	$00000016,24+24	B-4
			dc.l	$00000017,25+24	C-5
			dc.l	$00000009,26+24	C#5
			dc.l	$00000018,27+24	D-5
			dc.l	$0000000a,28+24	D#5
			dc.l	$00000019,29+24	E-5
			dc.l	$0000001a,30+24	F-5
			dc.l	$0000000c,31+24	F#5
			dc.l	$0000001b,32+24	G-5
			dc.l	$0000000d,33+24	G#5
			dc	-1
ne_raw2notetab_oct1
			dc.l	$00000031,13+24	C-4
			dc.l	$00000021,14+24	C#4
			dc.l	$00000032,15+24	D-4
			dc.l	$00000022,16+24	D#4
			dc.l	$00000033,17+24	E-4
			dc.l	$00000034,18+24	F-4
			dc.l	$00000024,19+24	F#4
			dc.l	$00000035,20+24	G-4
			dc.l	$00000025,21+24	G#4
			dc.l	$00000036,22+24	A-4
			dc.l	$00000026,23+24	A#4
			dc.l	$00000037,24+24	B-4
			dc.l	$00000038,25+24	C-5
			dc.l	$00000028,26+24	C#5
			dc.l	$00000039,27+24	D-5
			dc.l	$00000029,28+24	D#5
			dc.l	$0000003a,29+24	E-5
			dc.l	$00000010,25+24	C-5
			dc.l	$00000002,26+24	C#5
			dc.l	$00000011,27+24	D-5
			dc.l	$00000003,28+24	D#5
			dc.l	$00000012,29+24	E-5
			dc.l	$00000013,30+24	F-5
			dc.l	$00000005,31+24	F#5
			dc.l	$00000014,32+24	G-5
			dc.l	$00000006,33+24	G#5
			dc.l	$00000015,34+24	A-5
			dc.l	$00000007,35+24	A#5
			dc.l	$00000016,36+24	B-5
			dc	-1
ne_raw2notetab_oct00
			dc.l	$00000031,1	C-1
			dc.l	$00000021,2	C#1
			dc.l	$00000032,3	D-1
			dc.l	$00000022,4	D#1
			dc.l	$00000033,5	E-1
			dc.l	$00000034,6	F-1
			dc.l	$00000024,7	F#1
			dc.l	$00000035,8	G-1
			dc.l	$00000025,9	G#1
			dc.l	$00000036,10	A-1
			dc.l	$00000026,11	A#1
			dc.l	$00000037,12	B-1
			dc.l	$00000038,13	C-2
			dc.l	$00000028,14	C#2
			dc.l	$00000039,15	D-2
			dc.l	$00000029,16	D#2
			dc.l	$0000003a,17	E-2
			dc.l	$00000010,13	C-2
			dc.l	$00000002,14	C#2
			dc.l	$00000011,15	D-2
			dc.l	$00000003,16	D#2
			dc.l	$00000012,17	E-2
			dc.l	$00000013,18	F-2
			dc.l	$00000005,19	F#2
			dc.l	$00000014,20	G-2
			dc.l	$00000006,21	G#2
			dc.l	$00000015,22	A-2
			dc.l	$00000007,23	A#2
			dc.l	$00000016,24	B-2
			dc.l	$00000017,25	C-3
			dc.l	$00000009,26	C#3
			dc.l	$00000018,27	D-3
			dc.l	$0000000a,28	D#3
			dc.l	$00000019,29	E-3
			dc.l	$0000001a,30	F-3
			dc.l	$0000000c,31	F#3
			dc.l	$0000001b,32	G-3
			dc.l	$0000000d,33	G#3
			dc	-1
; -----------------------------------------------------------------------
cursorpositions		dc.b	06,04+8,04+10,04+12,04+14,04+16
			dc.b	24,22+8,22+10,22+12,22+14,22+16
			dc.b	42,40+8,40+10,40+12,40+14,40+16
			dc.b	60,58+8,58+10,58+12,58+14,58+16
; -----------------------------------------------------------------------
cursorpositions8	dc.b	03,02+4,02+5,02+6,02+7,02+8
			dc.b	12,11+4,11+5,11+6,11+7,11+8
			dc.b	21,20+4,20+5,20+6,20+7,20+8
			dc.b	30,29+4,29+5,29+6,29+7,29+8
			dc.b	39,38+4,38+5,38+6,38+7,38+8
			dc.b	48,47+4,47+5,47+6,47+7,47+8
			dc.b	57,56+4,56+5,56+6,56+7,56+8
			dc.b	66,65+4,65+5,65+6,65+7,65+8
; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
			even
; TEXTE!
; -----------------------------------------------------------------------

txt_dseqEnterNote
 dc.b	"Press notekey (on amiga-keyboard)                                                 ",0
	even


txt_dseq_init
 dc.b "            11111111112222222222333333333344444444",0
 dc.b "  012345678901234567890123456789012345678901234567",1
txt_dseq_init3
 dc.b "0",0
 dc.b "1",0
 dc.b "2",0
 dc.b "3",0
 dc.b "4",0
 dc.b "5",0
 dc.b "6",0
 dc.b "7",0
 dc.b "8",0
 dc.b "9",0
 dc.b "A",0
 dc.b "B",0
 dc.b "C",0
 dc.b "D",0
 dc.b "E",0
 dc.b "F",1

			ifeq	lang
txt_markblock		dc.b	"Marking block "
			else
txt_markblock		dc.b	"Markiere Block "
			endif
txt_blockstart		dc.b	"00:0 - "
txt_blockend		dc.b	"00:0            "
			dc.b	"                                          ",0

txt_1char		dc.b	" ",1
			even
txt_2chars		dc.b	"  ",1
			even
txt_3chars		dc.b	"   ",1
			even
txt_4chars		dc.b	"    ",1
			even
txt_5chars		dc.b	"     ",1
			even
txt_6chars		dc.b	"      ",1
			even
txt_7chars		dc.b	"       ",1
			even
txt_8chars		dc.b	"        ",1
			even
txt_dseqchars		dc.b	"-123456789ABCDEF"
txt_hexchars:		dc.b	"0123456789ABCDEF"
txt_instrnrs:		dc.b	"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			dc.b	"abcdefghijklmnopqrstuvwxyz"
			dc.b	0

			even
			dc.b	"-F",1,1,"-E",1,1,"-D",1,1
			dc.b	"-C",1,1,"-B",1,1,"-A",1,1,"-9",1,1,"-8",1,1
			dc.b	"-7",1,1,"-6",1,1,"-5",1,1,"-4",1,1,"-3",1,1
			dc.b	"-2",1,1,"-1",1,1
txt_transpose		dc.b	" 0",1,1,"+1",1,1,"+2",1,1
			dc.b	"+3",1,1,"+4",1,1,"+5",1,1,"+6",1,1,"+7",1,1
			dc.b	"+8",1,1,"+9",1,1,"+A",1,1,"+B",1,1,"+C",1,1
			dc.b	"+D",1,1,"+E",1,1,"+F",1,1

			even

			dc.b	"-|-",1
txt_notes		dc.b	"---",1
			dc.b	"C-1",1,"C#1",1,"D-1",1,"D#1",1,"E-1",1,"F-1",1
			dc.b	"F#1",1,"G-1",1,"G#1",1,"A-1",1,"A#1",1,"B-1",1
			dc.b	"C-2",1,"C#2",1,"D-2",1,"D#2",1,"E-2",1,"F-2",1
			dc.b	"F#2",1,"G-2",1,"G#2",1,"A-2",1,"A#2",1,"B-2",1
			dc.b	"C-3",1,"C#3",1,"D-3",1,"D#3",1,"E-3",1,"F-3",1
			dc.b	"F#3",1,"G-3",1,"G#3",1,"A-3",1,"A#3",1,"B-3",1
			dc.b	"C-4",1,"C#4",1,"D-4",1,"D#4",1,"E-4",1,"F-4",1
			dc.b	"F#4",1,"G-4",1,"G#4",1,"A-4",1,"A#4",1,"B-4",1
			dc.b	"C-5",1,"C#5",1,"D-5",1,"D#5",1,"E-5",1,"F-5",1
			dc.b	"F#5",1,"G-5",1,"G#5",1,"A-5",1,"A#5",1,"B-5",1
			dc.b	"C-6",1,"C#6",1,"D-6",1,"D#6",1,"E-6",1,"F-6",1
			dc.b	"F#6",1,"G-6",1,"G#6",1,"A-6",1,"A#6",1,"B-6",1
			dc.b	"C-7",1,"C#7",1,"D-7",1,"D#7",1,"E-7",1,"F-7",1
			dc.b	"F#7",1,"G-7",1,"G#7",1,"A-7",1,"A#7",1,"B-7",1

txt_dseqnotes		dc.b	"---",0
			dc.b	"C-1",0,"C#1",0,"D-1",0,"D#1",0,"E-1",0,"F-1",0
			dc.b	"F#1",0,"G-1",0,"G#1",0,"A-1",0,"A#1",0,"B-1",0
			dc.b	"C-2",0,"C#2",0,"D-2",0,"D#2",0,"E-2",0,"F-2",0
			dc.b	"F#2",0,"G-2",0,"G#2",0,"A-2",0,"A#2",0,"B-2",0
			dc.b	"C-3",0,"C#3",0,"D-3",0,"D#3",0,"E-3",0,"F-3",0
			dc.b	"F#3",0,"G-3",0,"G#3",0,"A-3",0,"A#3",0,"B-3",0
txt_finetunes
			dc.b	" 0","+1","+2","+3","+4","+5","+6","+7"
			dc.b	"-8","-7","-6","-5","-4","-3","-2","-1"

			even
;------------------------------------------------------------------------
; -----------------------------------------------------------------------
txt_pATTiNIT
 TEXT
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 ETEXT
		dc.b	1
			even
; -----------------------------------------------------------------------
gfx_waveempty
			ifeq	lang
			dc.l	%1111101100110111110011110110011
			dc.l	%1100001111110110011001100110011
			dc.l	%1100001100110110011001100110011
			dc.l	%1100001100110110011001100110011
			dc.l	%1111001100110111110001100011110
			dc.l	%1100001100110110000001100001100
			dc.l	%1100001100110110000001100001100
			dc.l	%1111101100110110000001100001100
			else

			dc.l	%1100001111110111111011111000000
			dc.l	%1100001100000110000011001100000
			dc.l	%1100001100000110000011001100000
			dc.l	%1100001100000110000011001100000
			dc.l	%1100001111100111110011111000000
			dc.l	%1100001100000110000011011000000
			dc.l	%1100001100000110000011001100000
			dc.l	%1111101111110111111011001100000
			endif

gfx_numbers		incbin	"dh1:gfx/raw/artofnoise/aon.numbers.RAw" 136*7 8*7
			even
gfx_fontor		incbin	"dh1:gfx/raw/artofnoise/aon.font2 new xxl"
			even
gfx_fontHI		incbin	"dh1:gfx/raw/artofnoise/aon.font2 new"
			even
gfx_record		incbin	"dh1:gfx/raw/artofnoise/aon.record32x33.raw"
			even
gfx_play		incbin	"dh1:gfx/raw/artofnoise/aon.play32x33.raw"
			even
gfx_fmsynth		incbin	"dh1:gfx/raw/artofnoise/aon.fm640x177.raw"
			even
gfx_wavelogo		incbin	"dh1:gfx/raw/artofnoise/aon.wavelogo400x19.raw"
			even
gfx_about		incbin	"dh1:gfx/raw/artofnoise/aon.about624x215x2.raw"
			even
			ifeq	lang
gfx_wavetitles1		incbin	"dh1:gfx/raw/artofnoise/wavetitles1.raw"
			even
gfx_wavetitles2		incbin	"dh1:gfx/raw/artofnoise/wavetitles2.raw"
			even
			else
gfx_wavetitles1		incbin	"dh1:gfx/raw/artofnoise/wavetitles1DEUTSCH.raw"
			even
gfx_wavetitles2		incbin	"dh1:gfx/raw/artofnoise/wavetitles2DEUTSCH.raw"
			even
			endif

sinustab:		incbin	"ch:.include/sinus192W.flt"
sinustabvol:		incbin	"ch:.include/sinus90vol.flt"
			even

;------------------------------------------------------------------------
player4ch		incbin	"ch:.include/player4ch"
player4chlen		=*-player4ch
exe4ch			incbin	"ch:.include/exe4ch"
exe4chlen		=*-exe4ch
exe4chrel
;incbin	"ch:exe4ch.reloc32"
			dc.l	$000003f2
exe4chrellen		=*-exe4chrel
;------------------------------------------------------------------------

; -----------------------------------------------------------------------
; -----------------------------------------------------------------------
; -<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<
; -----------------------------------------------------------------------
			SECTION	art.of.noisedatac,bss_c
			even
BPL_patterns		ds.b	(64*8*80+14*8*80)*2
			ds.b	4000
			even
mix_buff1data		ds	mix_buflen
mix_buff2data		ds	mix_buflen
mix_buff3data		ds	mix_buflen
mix_buff4data		ds	mix_buflen

wavebpl			ds.b	70*80

; -----------------------------------------------------------------------
			section	leerdata,bss

dseq_volbytetab		ds.b	256*15

dseq_addData		ds.b	16*17
			even
dseq_patterns		ds.b	24*16*16	; 16 seqs,16 channels
dseq_buf		ds.b	24*16
dseq_addbuf		ds.b	17		; additional sequencedata
			even
instred_copybuf		ds.b	32+32		; +32 bytes für instrnamen

fastosctab		ds	17*128

intuimessage		ds.b	100

MIDImsg_freemsg		ds.b	2+16
ser_capture		ds.b	256

cmdbuf			ds.l	64
trackbuf		ds.l	64
patternbuf		ds.l	64*4*2

			ds.b	2	; kanäle+höhe (-1 jeweils!)
blockbuf		ds.l	64*4*2

txt_3charsnrs		ds.l	1000
txt_2charsnrs		ds.l	100

ne_playstep		ds.b	4

gfx_font		ds.b	1280/8*24

iobuffer		ds.b	12000

module_songname		ds.b	256
module_songauthor	ds.b	256
module_songdate		ds.b	256
module_songinfo		ds.b	4
module_arptab		ds.l	16
module_postab		ds.b	256
module_patterns		ds.b	128*256*4
module_instruments	ds.b	61*32
module_instrnames	ds.b	61*32
module_wavelenlist	ds.l	64
module_fmdata		ds.b	64*16

MP_gadgetptrs		ds.l	1		; Erstes Gadget ist Nr.1
		; daher 1 dummi-zeiger einfügen!!!!!!!!!!
			ds.l	100		; max 100 gadgets!
MP2_gadgetptrs		ds.l	100+1
MPwave_gadgetptrs	ds.l	200+1


;---------------------- Main-Dataliste ----------------------------------

			even
			rsreset
equ_actwaveptr		rs.l	1
equ_wavelen		rs.l	1
equ_actwaveoff		rs.l	1
equ_actper		rs	1
equ_actbyte		rs.b	1
equ_actvolume		rs.b	1
equ_datasize		rs	1

			even
EQU_DATA		ds.b	equ_datasize*8

			rsreset
prf_checkmark		rs.b	4	; "AONP"
prf_screenmode		rs.l	1	; 0=PalHires,1=Euro72 Productivity
prf_filtermode		rs.b	1	; 0=Off,1=On
prf_splitmode		rs.b	1	; 0=Copper,1=Processor
prf_modulepath		rs.b	32	; terminated with 0
prf_samplepath		rs.b	32	; terminated with 0
prf_instrpath		rs.b	32	; terminated with 0
prf_dseqpath		rs.b	32	; terminated with 0
prf_texteditor		rs.b	32	; text-editor (viewer!)
prf_blankername		rs.b	32	; Screenblanker-Modul
prf_blankertimeout	rs	1	; Anzahl sekunden (-546 min!!)
prf_col0		rs.b	3
prf_col1		rs.b	3
prf_col2		rs.b	3
prf_col3		rs.b	3
prf_jump0		rs.b	1	; pos-jump
prf_jump1		rs.b	1
prf_jump2		rs.b	1
prf_jump3		rs.b	1
prf_jump4		rs.b	1
prf_saveremark		rs.b	1
prf_saveinstrnames	rs.b	1
prf_addpp		rs.b	1
prf_oversize		rs.b	1
prf_cruncheff		rs.b	1
prf_crunchbuf		rs.b	1
prf_bottomstatusmode	rs.b	1
prf_forcepal		rs.b	1
;prf_fillbyte		rs.b	1
prf_datasize		rs	1

			even
PRF_DATA		ds.b	prf_datasize

			even
			rsreset
pattdspreq		rs	1
replaystatus		rs	1
patteditstatus		rs	1	; 1=Pattedit ON,0=Off
programmode		rs	1	; programmode!
silence			rs.b	1	; <>0=Stop replayer while loading!
chfree			rs.b	1	; <>0=Total replay-stop

itt_adpd_flag		rs	1	; <>1=Patterns kopieren!

utilbase		rs.l	1
dosbase			rs.l	1	; Zeiger auf dosbase
gfxbase			rs.l	1
intbase			rs.l	1
screenptr		rs.l	1
rastport1		rs.l	1	; Rast-Port des Main.windows
viewport		rs.l	1

rastportwave		rs.l	1
screenptr2		rs.l	1
viewport2		rs.l	1
windowptrwave		rs.l	1	; Zeiger auf Wave-Window
userportwave		rs.l	1	; Zeiger auf User-Port vom Wave-Window


stepdspreq		rs	1	; <>0 wenn neuer step ausgegeben werden
					; soll
disppatcnt		rs	1	; Step, der gerade ausgeführt wird
					; AON_DATA+AON_PATCNT=POINTER AUF
					; NÄCHSTEN STEP!!!!!!!!!!!!!
ch_enable		rs	1	; bit0=1=ch0On,bit1=1=ch1On usw..
ch_oldenable		rs	1

instrtrp		rs	1	; Instr-transpose numeric pad

oldpatcnt		rs	1	; used for pattdisplay adjust.

oldspeed		rs	1
oldtempo		rs	1

;SPEED ANZEIGEN UND NEHMEN

octave			rs	1	; 0=C-1>G#3 , 1=C-2>B-3
patcntX			rs	1	; Horizontaler Pattcnt! (channels)
free_chipmem		rs.l	1	; Freies Chipmem
free_fastmem		rs.l	1	; Freies Fastmem
free_publicmem		rs.l	1	; Freies Publicmem

filehandle		rs.l	1	; Zeiger auf akt. IO-Filehandle
filehandleREM		rs.l	1	; for loading the remark file (ram:)

last_edpat		rs	1	; Editpattern im letzten frame

update_memCntDn		rs	1	; Memory-Display-Refresh CountDown
actEditPattern		rs	1	; Pattern,der gerade bearbeitet wird

oldpatcntx		rs	1

acteditinstr		rs	1	; Instrument,das gerade benutzt wird
instrDspReq		rs	1+1	; Neue Instrumentendaten ausgeben?!
					; $0f=Nur Werte,$f0=Nur Wellenform

diskfontbase		rs.l	1
pp_base			rs.l	1

window1ptr		rs.l	1	; Zeiger auf Window Nr.1
userport1		rs.l	1	; Zeiger auf User-Port von Window1

gadtoolsbase		rs.l	1	; Library-Base
getvisual		rs.l	1	; Ergebnis von GetVisualInfoA() SCR1
getvisual2		rs.l	1	; Ergebnis von GetVisualInfoA() SCR2
gadgetlist		rs.l	1	; Zeiger auf Gadgetliste

menuaddr		rs.l	1	; Zeiger auf Menu-Zeile

rtbase			rs.l	1	; Reqtools-Base

modreqptr		rs.l	1	; Ptr auf Module-Filerequester
varreqptr		rs.l	1	; Pointer on filereq-struct (various)
instrReqptr		rs.l	1
sampleReqptr		rs.l	1
dseqReqptr		rs.l	1
palettereqptr		rs.l	1	; Pointer on filereq-struct (palette)


pt_sampledataadr	rs.l	1	; Ptr on Protracker-Patterns

bitplane1_startadr	rs.l	1	; StartAdresse der 1.Bitplane
bitplane2_startadr	rs.l	1	; StartAdresse der 2.Bitplane
bitplane1_startadr2	rs.l	1	; StartAdresse der 1.Bitplane 2.Screen
bitplane2_startadr2	rs.l	1	; StartAdresse der 2.Bitplane 2.Screen
bitplane3_startadr2	rs.l	1	; der 3.plane

last_free_chipmem	rs.l	1
last_free_fastmem	rs.l	1
last_free_publicmem	rs.l	1
last_songmem		rs.l	1
last_wavemem		rs.l	1
last_modulemem		rs.l	1

old_displaybeep		rs.l	1

pp_loadadr		rs.l	1	; Ladeadresse für powerpacker-files
pp_loadlen		rs.l	1	; länge der ungepackten Daten
stc_origdata		rs.l	1	; adresse des ungepackten stc-files
stc_origlen		rs.l	1	; länge des ungepackten stc-files

scancode		rs.l	1	; 1.word=keylevel,2.word=keycode

bitplane2_barStartadr	rs.l	1

myclist			rs.l	1	; ptr auf Ucopperlist

addstep			rs	1	; jump down x steps after stepedit

framecnt		rs	1	; counts from 0-49 (used for playtimer)
playtimer		rs	1	; 1.byte=minuten, 2.byte = sekunden
oldtimer		rs	1	; aenderung des playtimers ?!?!

blankercnt		rs	1	; counts the frames (countdown)
blankermodule		rs.l	1	; ptr auf blankermod (chipmem!!)
lastbfec01		rs	1+1
lastdff00a		rs	1

mytask			rs.l	1	; pointer on aon-task

window2ptr		rs.l	1	; pointer to second opened window
userport2		rs.l	1	; Zeiger auf User-Port von Window2
gadgetlist2		rs.l	1	; Zeiger auf Gadgetliste von Window 2
rastport2		rs.l	1	; Zeiger auf rastport von win.2
gadgetlistwave		rs.l	1	; Zeiger auf Gadgetliste von Window 3

defpref			rs	1	; Auf 1 wenn preferencesfile nicht
					; geladen werden konnte
markingblock		rs	1	; <>0= Block wird gerade markiert
blockstart		rs	1	; Anfang des blocks
blockend		rs	1	; endes des blocks
					; haben!
ser_sendptr		rs.l	1	; Pointer on messy to send
ser_sendtogo		rs	1	; Length of the messy
old_level5		rs.l	1
ser_captureoff		rs.l	1	; Pointer on midi-capture (size=65536)

lastmidicmd		rs	1	; Letzter eingegangener MIDI-Befehl
midieditstatus		rs	1	; <>0=Midi-Input an

pdwn_alreadypainted	rs	1+1	; <>0 wenn adpd_realadjust ausgeführt

lastdownID		rs	1

midimode		rs	1	; <>0 editing&playing midi-patterns!
;midipatterns		rs.l	1	; pointer on midi-patterns

areamode		rs.b	1	; 0=Block,1=Track,2=Pattern
win2_override		rs.b	1	; 1=Normal,0=sys-requester aufm screen

winwave_override	rs.b	1	; dito, nur für wave/instrument-editor
dseq_cursorx		rs.b	1

dseq_cursory		rs.b	1
dseq_lastcursorx	rs.b	1

dseq_lastcursory	rs.b	1
dseq_actseq		rs.b	1

dseq_actseqlen		rs.b	1
dseq_pitch		rs.b	1

dseq_destwave		rs.b	1
dseq_speed		rs.b	1

dseq_tempo		rs.b	1+1

dseq_bytesperstep	rs.l	1
dseq_bytelen		rs.l	1
dseq_wave1data		rs.l	16*2	; wavestartadr+wavelen
dseq_destper		rs	1
dseq_workwaveadr	rs.l	1
dseq_chipwaveadr	rs.l	1

linedraw_lastx		rs	1
linedraw_lasty		rs	1

instred_lastsamplePos	rs	1

wildstarSEARCHpat	rs.l	1
wildstarREPLACEpat	rs.l	1
wildstarMASK		rs.l	1
wildstarMASK2		rs.l	1

instred_copyfrom	rs.b	1
instred_copyto		rs.b	1

waveed_actwave		rs.b	1
waveed_actpartwave	rs.b	1
waveed_off		rs.l	1
waveed_dispsize		rs.l	1
waveed_rangesize	rs.l	1
waveed_wavepos		rs.l	1
waveed_downpos		rs.l	1	; wellenform-pos beim range-start set
waveed_bufadr		rs.l	1
waveed_buflen		rs.l	1
waveed_copyfrom		rs.b	1
waveed_copyto		rs.b	1
waveed_partwavelen	rs	1

sample_period		rs	1
sample_len		rs.l	1
samplebuf		rs.l	1	; pointer on sample-workbuf
sampledflag		rs.b	1	; gets <>0 when rmb was pressed
trig_sens		rs.b	1	; trig sensitivity

freemode		rs.b	1	; 1=freestyle mode
sample_pitch		rs.b	1	; sample-note (c-1 - b-5)

samplenext		rs.b	1	; <>0=sample next sample..
screen			rs.b	1	; 0=screen1, 1=screen 2 für refresh

chmode			rs.b	1
lockint			rs.b	1	; 1=keine interrupts auslösen

recordcnt		rs.b	1
recordstatus		rs.b	1

extproc			rs.b	1
rangemark		rs.b	1	; 0=no mark, 1=marking area

fmed_actinstr		rs.b	1	;0-63
cheditmode		rs.b	1	; 0=single, 1=multi

hzticks			rs.l	1	; 52980=euro72, 74172=palhires

exeSTARTOFRELOC		rs.l	1	; seek-pos, an der der reloc-teil
					; des exe-files starten SOLLTE
songchanged		rs	1	; <>0=song altered
blitcnt			rs	1	; 0=NEW PATTADJUST

oldpatcnt2		rs	1
patalertflag		rs	1
freezedsp		rs	1
wavedspgain		rs	1

resample_len		rs.l	1
resample_adr		rs.l	1
resample_flag		rs	1

signalnr		rs.l	1
patdspview		rs	1	; 1=adjust_pattdisplay aufrufen!

vbreg			rs.l	1

maindatasize		rs	1

			even
MAIN_DATA		ds.b	maindatasize
			even

			section	chipstiu,data_C
samplemonicop:
			dc	$180,0,$100,0
			dc	$6f0f,-2
			dc	$180,$fff,$6fe1,-2,$180,0
monipos1:		dc	$700f,-2,$180
monicol:		dc	$0f0
			dc	$f00f,-2,$180,$fff,$f0e1,-2,$180,0
			dc	-1,-2



****************************************************************************
****************************************************************************
****************************************************************************
; ________________________________________________________________________
; 									
;                      -<>-O art.of.noise.replay.v1.2 O-<>-		
; 			   coded by twice/lego! '93/4		
; ________________________________________________________________________

; last change : 06-Feb-1994
; last error: 

; well,this moduleplayer is actually not very optimized and as a matter
; of fact,it isn't very fast,too! perhaps when art of noise is totally
; complete,i'll code a FAST replayer , but this will have to wait,so
; perhaps someone else will do so (so that i can concentrate on the main
; program ;-)!).Well,however,to replay a music,just call ĞĞaon_initğğ
; at the beginning (with the parameters  A0=songadr , D0=startpos)
; and ĞĞaon_playğğ every frame . To stop the music , call ĞĞaon_endğğ.
; And what's the speed you may ask ?! Well,on my 1200er the play-routine
; needs an average of ..hmm let's say 13+12 rasterlines (why +12 ? in these
; 12 lines the routine does NOTHING ELSE BUT WAITING FOR THE DMA!!! , so
; you can put your own routines there instead of the 'dma_wait' routine!

;------------------------------------------------------------------------
aon_timerval		=1773447		PAL!!

; $EF0 fehlt (lame effect... use synth-fx instead)
;------------------------------------------------------------------------
			section	aonreplayer1.0,code_c
;========================================================================
; IN:	d0=Startpos
; OUT:	d0= result (0=ok,-1=error occured)
AON_INIT
			movem.l	d1-d7/a0-a6,-(sp)	; global stacksave
			lea	aon_data,a6
			move.b	#6,aon_speed(a6)
			bsr	aon_resettimer
			move.b	d0,aon_pos(a6)
			move.l	a0,aon_modulestart(a6)

			move.l	#module_songinfo,aon_statdata(a6)
			move.l	#module_arptab,aon_arpdata(a6)
			move.l	#module_postab,aon_posdata(a6)
			move.l	#module_patterns,aon_pattdata(a6)

			lea	module_instruments,a0
			lea	aon_instrstarts(a6),a1
			moveq	#61-1,d7
aon_initinstradrtab	move.l	a0,(a1)+
			lea	32(a0),a0
			dbf	d7,aon_initinstradrtab

			lea	aon_leer(pc),a0
			move.l	#$00022222,d0
			lea	$dff000,a5
			move.l	a0,$a0(a5)
			move.l	a0,$b0(a5)
			move.l	a0,$c0(a5)
			move.l	a0,$d0(a5)
			move.l	d0,$a4(a5)	; no disturbing noises
			move.l	d0,$b4(a5)	; at the beginning!!!
			move.l	d0,$c4(a5)
			move.l	d0,$d4(a5)

			lea	aon_channels(pc),a0
			moveq	#8-1,d7
.chloop			move	#64,aon_trackvol(a0)
			move	#400,aon_period(a0)
			lea	aon_chdatasize(a0),a0
			dbf	d7,.chloop
; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

			bsr	aon_end		; channels OFF

			move.b	$6(a5),d0
			add.b	#20,d0
aon_initdma		cmp.b	$6(a5),d0
			bne.s	aon_initdma
			move	#$800f,$96(a5)

			movem.l	(sp)+,d1-d7/a0-a6
			moveq	#0,d0
			rts
AON_NOTINITALIZED	movem.l	(sp)+,d1-d7/a0-a6
			moveq	#-1,d0		; yep,seems that an error
			rts			; has occured... bad luck..!
;========================================================================
AON_END
			tst.b	chmode+main_data
			beq.b	.ok
			rts
.ok
			move	#$ff,$dff09e	; no modulation
			move	#$f,$dff096	; DMA off
			move	#0,$dff0a8
			move	#0,$dff0b8
			move	#0,$dff0c8
			move	#0,$dff0d8
			rts
;========================================================================
AON_PLAY		
		TST.B	CHFREE+MAIN_DATA
		BEQ.B	.NOT
		RTS
.NOT

		TST.B	SILENCE+MAIN_DATA
		BNE.B	AON_END

			movem.l	d0-d7/a0-a6,-(sp)
			lea	aon_data(pc),a6

			addq.b	#1,aon_framecnt(a6)
			move.b	aon_speed(a6),d0
			beq.b	aon_playcurrent_nonewpos2
			cmp.b	aon_framecnt(a6),d0
			bhi	aon_playcurrent_nonewpos2
			clr.b	aon_framecnt(a6)

			bsr	aon_playnewstep
aon_playcurrent_nonewpos2
			bsr	aon_playfx

			movem.l	(sp)+,d0-d7/a0-a6
			rts

;---------------------- Effekte & Samplestarts ----------------------
AON_PLAYFX		
			moveq	#0,d7
			move.b	aon_pos(a6),d7
			move.l	aon_posdata(a6),a1	; get start of posdat
			moveq	#0,d0
			move.b	(a1,d7),d0		; d7=act. pos + choff
		CMP.B	#REPLAYST_ALL,REPLAYSTATUS+MAIN_DATA
		BNE.S	AON_DONTSETPATNR
		MOVE.B	D0,ACTEDITPATTERN+MAIN_DATA+1
AON_DONTSETPATNR

			lea	aon_dofx(pc),a1
			lea	aon_channels(pc),a4	; do effect command
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)

			moveq	#0,d1			; Make channel-mask
			moveq	#0,d7
			lea	aon_startinstr.1-aon_dofx(a1),a1

	LEA	EQU_DATA,A3

			lea	aon_channels(pc),a4	; do effect command
			lea	$dff0a0,a5
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)

			lea	-$40(a5),a5
			move	d1,-$a(a5)		; Channels off
			bsr	aon_waitdma
			or	#$8000,d1		; Set/CLr bit !

			move	d1,-$a(a5)		; Channels on
			bsr	aon_waitdma

			lea	-(4*aon_chdatasize)(a4),a4

	LEA	EQU_DATA,A3
			moveq	#0,d7

			lea	aon_startinstr.2-aon_startinstr.1(a1),a1
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)

			rts

;========================================================================
;---------------------- Neuen Step auslesen -------------------------
aon_playnewstep
			TST.B	REPLAYSTATUS+MAIN_DATA
			BEQ	AON_PLAYCURRENT_NONEWPOSX

			cmp.b	#$ff,aon_patcnt(a6)
			beq	aon_breakpat

; read new step
aon_getstep
			tst.b	aon_patdelaycnt+1(a6)
			bmi.s	aon_nopatdelay
			beq.s	aon_nopatdelay
			subq.b	#1,aon_patdelaycnt+1(a6)
			bra.w	aon_playcurrent_nonewposX
aon_nopatdelay		move.b	#-1,aon_patdelaycnt+1(a6)
	
			lea	aon_channels(pc),a4
			lea	aon_multab120(pc),a5	; needed for periodtab

			moveq	#0,d0
			move.b	acteditpattern+main_data+1,d0
			move.l	aon_pattdata(a6),a0	; get start of patdat

			moveq	#10,d1
			lsl.l	d1,d0			; patnr*1024=patoff
			lea	(a0,d0.l),a0		; add to start of data
			move	aon_patcnt(a6),d1

		MOVE.B	D1,DISPPATCNT+MAIN_DATA

			add	d1,d1			; *4 bcoz 1 Pattern
			add	d1,d1			; =4 Channels
			lea	(a0,d1.l),a0		; add pattcounter

; a0=pointer on actual step
			bsr	aon_getdachannel	; get first channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			bsr	aon_getdachannel	; get second channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			bsr	aon_getdachannel	; get third channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			bsr	aon_getdachannel	; get fourth channel

			tst.b	aon_loopflag(a6)
			beq.s	aon_nolooping
			clr.b	aon_loopflag(a6)
			move.b	aon_looppoint(a6),aon_patcnt+1(a6)
			bra.b	aon_playcurrent_nonewposX
aon_nolooping		addq.b	#4,aon_patcnt+1(a6)
			bne.b	aon_playcurrent_nonewposX  ; End of pattern??
aon_breakpat		
		MOVE.B	#%1111,PATTDSPREQ+MAIN_DATA

			clr.b	aon_patdelaycnt+1(a6)
			clr	aon_looppoint(a6)
		CMP.B	#REPLAYST_PAT,REPLAYSTATUS+MAIN_DATA
		BEQ.B	AON_PLAYCURRENT2
			addq.b	#1,aon_pos(a6)	; pos=pos+1
			move.l	aon_statdata(a6),a3
			move.b	aon.songinfo_maxpos(a3),d0	; get maxpos
			cmp.b	aon_pos(a6),d0	; End of song ??
			bhi	aon_playcurrent2
			move.b	aon.songinfo_respos(a3),aon_pos(a6) ; Get restart pos!
aon_playcurrent2	tst.b	aon_patcnt(a6)
			beq.b	aon_playcurrent_nonewposX
			clr.b	aon_patcnt(a6)

			moveq	#0,d7
			move.b	aon_pos(a6),d7
			move.l	aon_posdata(a6),a1	; get start of posdat
			moveq	#0,d0
			move.b	(a1,d7),d0		; d7=act. pos + choff
		CMP.B	#REPLAYST_ALL,REPLAYSTATUS+MAIN_DATA
		BNE.S	AON_DONTSETPATNR2
		MOVE.B	D0,ACTEDITPATTERN+MAIN_DATA+1
AON_DONTSETPATNR2
			bra	aon_getstep
aon_playcurrent_nonewposX
			rts
;========================================================================
; a6=data
; get new step ...!
AON_GETDACHANNEL
			move.b	2(a0),aon_fxCOM(a4)	; needed l8r on
			and.b	#$3f,aon_fxcom(a4)
			move	2(a0),d0
			and	#$3fff,d0
			move.b	d0,d1
			move.b	d0,aon_fxDAT(a4)
			cmp.b	#$d,aon_fxcom(a4)
			bne.b	.nobreak
			cmp.b	#$100-4,aon_patcnt+1(a6)
			bne.b	.nobreak
			move.b	#$100-8,aon_patcnt+1(a6)
.nobreak

			and.b	#$f0,d0
			and.b	#$0f,d1

			clr.b	aon_stepfxcnt(a4)

			cmp.b	#16,aon_fxcom(a4)	; 'g' volset
			bne.b	.novoldel
			move.b	aon_fxdat(a4),d2
			and.b	#$f,d2
			move.b	d2,aon_stepfxcnt(a4)
			bra.b	aon_gdc_nomoreFX
.novoldel
			cmp	#$0ec0,d0
			bne.s	aon_gdc_nonotecut	; note cut ?
			move.b	d1,aon_stepfxcnt(a4)
			bra.b	aon_gdc_nomoreFX
aon_gdc_nonotecut
			cmp	#$0ee0,d0		; pattern delay?
			bne.s	aon_gdc_nopatdelay
			tst.b	aon_patdelaycnt+1(a6)	; delaying ?
			bpl.s	aon_gdc_nopatdelay
			move.b	d1,aon_patdelaycnt+1(a6) ; start delay!
			bra.b	aon_gdc_nomoreFX
aon_gdc_nopatdelay
			cmp	#$0e60,d0		; pattern loop?
			bne.s	aon_gdc_noloopreset
			cmp.b	#$f0,aon_loopcnt(a6)	; loop over flag set ?
			beq.s	aon_gdc_noloopreset
			tst.b	d1			; no loop?
			beq.s	aon_gdc_noloopreset

			tst.b	aon_loopcnt(a6)
			bne.s	aon_gdc_dothatloopin
			move.b	d1,aon_loopcnt(a6)	; write counter
aon_gdc_dothatloopin	subq.b	#1,aon_loopcnt(a6)	; continue looping!
			bne.s	aon_gdc_notjustlooped
			move.b	#$f0,aon_loopcnt(a6)	; loop over flag
aon_gdc_notjustlooped	move.b	#-1,aon_loopflag(a6)
aon_gdc_noloopreset

aon_gdc_nomoreFX
			moveq	#0,d0
			moveq	#0,d1
			moveq	#0,d5			; flag for useoldinstr
			move.b	1(a0),d1		; Get Instrnr.
			and.b	#%00111111,d1		; skip unused bits
			subq.b	#1,d1
			bpl.s	aon_gdc_notoldinstr	; -1-> old instr
			tst.l	aon_instrptr(a4)	; get last instrptr
			beq	aon_gdc_nonewnote	; no instrument ?!!
							; then exit
			move.l	aon_instrptr(a4),a2	; last instrptr
			move.b	(a0),d2
			and.b	#63,d2			; no note?
			beq	aon_gdc_nonewinstr	; then pause !
			moveq	#1,d5			; flag for useoldinstr
			cmp.b	#3,aon_fxcom(a4)
			beq	aon_gdc_nonewinstr
			cmp.b	#5,aon_fxcom(a4)
			beq	aon_gdc_nonewinstr
			cmp.b	#27,aon_fxcom(a4)
			beq	aon_gdc_nonewinstr
			cmp.b	#28,aon_fxcom(a4)
			beq	aon_gdc_nonewinstr
			bra.b	aon_gdc_useoldinstr
aon_gdc_notoldinstr	move.b	(a0),d2
			and.b	#63,d2			; no note?
			bne.s	aon_gdc_notchangerepeat	; then only set repeat

			add.b	d1,d1
			add.b	d1,d1
			lea	aon_instrstarts(a6),a2
			move.l	(a2,d1),a2

			tst.b	instr_control(a2)
			bne.w	aon_gdc_resetvolume.etc		;aon_gdc_notsameinstr


			cmp.l	aon_instrptr(a4),a2
			beq	aon_gdc_resetvolume.etc
			move.l	a2,aon_instrptr(a4)	; save in channeldata
			move.b	#01,aon_chflag(a4)	; 01=NEW REPEATWAVE
			bra.w	aon_startrepeat
aon_gdc_notchangerepeat
			clr.l	aon_oldsampoff(a4)

			add.b	d1,d1
			add.b	d1,d1
			lea	aon_instrstarts(a6),a2
			move.l	(a2,d1),a2

			cmp.l	aon_instrptr(a4),a2
			bne.s	aon_gdc_notsameinstr
			cmp.b	#3,aon_fxcom(a4)
			beq	aon_gdc_resetvolume.etc
			cmp.b	#5,aon_fxcom(a4)
			beq	aon_gdc_resetvolume.etc
			cmp.b	#27,aon_fxcom(a4)
			beq	aon_gdc_resetvolume.etc
			cmp.b	#28,aon_fxcom(a4)
			beq	aon_gdc_resetvolume.etc
aon_gdc_notsameinstr
			move.l	a2,aon_instrptr(a4)	; save in channeldata
aon_gdc_useoldinstr

			clr.b	aon_vibCONT(a4)
			bsr	aon_initADSR

			tst.b	instr_control(a2)	; Synthmode on??
			beq	aon_startsample
************* HIER NACH INSTRUMENTEN-TYPEN UNTERSCHEIDEN!!!!!!!!!!!!!********
************* HIER NACH INSTRUMENTEN-TYPEN UNTERSCHEIDEN!!!!!!!!!!!!!********
************* HIER NACH INSTRUMENTEN-TYPEN UNTERSCHEIDEN!!!!!!!!!!!!!********

; ---- INIT SYNTHETIC INSTRUMENT ---------------	16-juli-1994
aon_gdc_initsynth

			move.b	#1,aon_chMODE(a4)

			move	aon_fxcom(a4),d0
			move.b	d0,d1
			and.b	#$f0,d0

			cmp	#$0e90,d0		; retrig note?
			bne.s	.noretrigging
			and.b	#$0f,d1
			move.b	d1,aon_stepfxcnt(a4)
.noretrigging

			lea	aon_wavestarts(a6),a3

			move.b	(a0),d2			; Alter Fehler: Bei
			and.b	#63,d2			; Wechsel des Instr.
			beq	aon_gdc_resetvolume.etc	; wurde Ğperslideğ re-
			clr	aon_perslide(a4)	; settet!

			moveq	#0,d3
			cmp.b	#17,aon_fxcom(a4)	; 'h'  synthcontrol?!
			bne.b	.noth
			move.b	aon_fxdat(a4),d3
.noth
			btst	#4,d3
			bne	.initvib

			cmp	#$0ed0,d0		; delay note?
			bne.s	.notdelaynote
			and.b	#$0f,d1
			move.b	d1,aon_stepfxcnt(a4)
			bra.b	.startrepeat
.notdelaynote		move.b	#3,aon_chflag(a4)	; 3=New WAVE
.startrepeat

			moveq	#0,d0
			move.b	instr_waveform(a2),d0	; Nr. of waveform
			move.b	d0,aon_actwavenr(a4)
			add	d0,d0
			add	d0,d0			; *4 (longword!)
			move.l	(a3,d0.l),d1		; Get address..
; d1=Address of actual waveform
			cmp.l	aon_waveform(a4),d1
			bne.b	.notsamewaveU
			clr.b	aon_chflag(a4)

			tst.b	aon_synthWAVECONT(a4)	; Wave
			bne	.initVIB		; NICHT resetten!!

.notsamewaveU		move.l	d1,aon_waveform(a4)

.checkoffset
			moveq	#0,d0
			move.b	synth8_partwaveDMALen(a2),d0

			cmp.b	#9,aon_fxcom(a4)
			bne.b	.notoffset
			moveq	#0,d2
			move.b	aon_fxdat(a4),d2
			mulu	d0,d2
			add.l	d1,d2
			move.l	d2,d1
;aon_synthwaveactptr(a4)
			tst.b	aon_synthWAVESTOP(a4)
			beq.b	.notoffset
			move.l	d1,aon_synthwaveactptr(a4)
			move.l	d1,aon_repeatstrt(a4)
			bra	.initVIB
.notoffset
			tst.b	aon_synthWAVESTOP(a4)
			bne.b	.initVIB

			move.l	d1,aon_synthwaveactptr(a4)


			move	aon_wavelen(a4),aon_oldwavelen(a4)

			move	d0,aon_wavelen(a4)
			move	d0,aon_replen(a4)

			add	d0,d0
			move.l	d0,aon_synthWAVEaddbytes(a4)

			moveq	#0,d2
			move.b	synth8_WAVErep(a2),d2
			mulu	d0,d2
			add.l	d1,d2
			move.l	d2,aon_repeatstrt(a4)

			moveq	#0,d2
			move.b	synth8_WAVElen(a2),d2
			mulu	d0,d2
			add.l	d1,d2
			move.l	d2,aon_synthWAVEendptr(a4)

			moveq	#0,d2
			move.b	synth8_WAVErep(a2),d2
			mulu	d0,d2
			add.l	d1,d2
			move.l	d2,aon_synthWAVErepptr(a4)

			moveq	#0,d2
			move.b	synth8_WAVEreplen(a2),d2
			add.b	synth8_WAVErep(a2),d2
			mulu	d0,d2
			add.l	d1,d2
			move.l	d2,aon_synthWAVErependptr(a4)

			move.b	synth8_WAVEspd(a2),aon_synthWAVEcnt(a4)
			move.b	synth8_WAVEspd(a2),aon_synthWAVEspd(a4)
			move.b	synth8_WAVErepctrl(a2),aon_synthWAVERepctrl(a4)


; Vibrato initalisieren
.initvib
;			btst	#0,d3			; Restart
;			beq.b	.vibke			; Volume
;			clr.b	aon_synthENV(a4)	; Envelope ?!?
;.vibke
			clr.b	aon_vibON(a4)
			cmp.b	#3,synth8_vibwave(a2)	; 'Off' ?!
			beq.b	.vibOFF

			moveq	#0,d1
			move.b	synth8_vibdelay(a2),d1
			move	d1,aon_vibratotrigdelay(a4)
			moveq	#0,d1
			move.b	synth8_vibpara(a2),d1
			bne.b	.vib
			move	#-2,aon_vibratotrigdelay(a4)
			bra.b	.novib
.vib			move.l	a2,-(sp)
			bsr	aon_dofx_vibratoPARAM	; set parameters
			move.l	(sp)+,a2
			move.b	synth8_vibwave(a2),d0
			ror.b	#3,d0
			and.b	#%10011111,aon_vibratoampl(a4)
			or.b	d0,aon_vibratoampl(a4)
			move.b	#1,aon_vibCONT(a4)
			
.novib
			bra	aon_gdc_resetvolume.etc
.vibOFF			move.b	#"!",aon_vibon(a4)
			bra	aon_gdc_resetvolume.etc

; --------------------- INIT SAMPLE8BIT INSTRUMENT ----------------------
aon_startsample

			move.b	#"!",aon_vibON(a4)
			clr.b	aon_chMODE(a4)
			move	aon_fxcom(a4),d0
			move.b	d0,d1
			and.b	#$f0,d0

			cmp	#$0ed0,d0		; delay note?
			bne.s	aon_gdc_notdelaynote
			and.b	#$0f,d1
			move.b	d1,aon_stepfxcnt(a4)
			bra.b	aon_startrepeat
aon_gdc_notdelaynote
			cmp	#$0e90,d0		; retrig note?
			bne.s	aon_gdc_noretrigging
			and.b	#$0f,d1
			move.b	d1,aon_stepfxcnt(a4)
aon_gdc_noretrigging
			move.b	#03,aon_chflag(a4)	; 03=New SAMPLEWAVE
aon_startrepeat		lea	aon_wavestarts(a6),a3

;			cmp.b	#$3,aon_fxcom(a4)
;			beq.w	.resetper
;		cmp.b	#$5,aon_fxcom(a4)
;		bne.b	.noresetper
;.resetper
			move.b	(a0),d2			; Alter Fehler: Bei
			and.b	#63,d2			; Wechsel des Instr.
			beq.b	.noresetper		; wurde Ğperslideğ re-
			clr	aon_perslide(a4)	; settet!
.noresetper			

			moveq	#0,d0
			move.b	instr_waveform(a2),d0	; Nr. of waveform
			move.b	d0,aon_actwavenr(a4)
			add	d0,d0
			add	d0,d0			; *4 (longword!)
			move.l	(a3,d0.l),d1		; Get address..
; d1=Address of actual waveform

			move.l	sample8_dmalen(a2),d4
			move	aon_wavelen(a4),aon_oldwavelen(a4)
			move	d4,aon_wavelen(a4)

			tst.l	sample8_dmareplen(a2)	; Is there any repeat?!
			bne.b	sample8_TheresARepeat
			move.l	#aon_leer,aon_repeatstrt(a4)
			move	#1,aon_replen(a4)
			bra.b	sample8_theresNoRepeat
sample8_theresARepeat

			move.l	sample8_dmarepoffset(a2),d2

		tst.b	aon_oversize(a6)
		bne.b	sample8_notzerorep
		tst.l	d2
		bne.b	sample8_NotzeroRep	; sonst sind keine
						; samples >128k möglich
		move.l	d1,aon_repeatstrt(a4)	;!!!!!!!!!!!!!!!!
		move	sample8_dmareplen+2(a2),aon_replen(a4)
		bra.b	sample8_zeroRep
sample8_NotzeroRep
			move.l	d2,d3		; save repeatstart in WORDS
			add.l	d2,d2
			add.l	d1,d2
			move.l	d2,aon_repeatstrt(a4)
			moveq	#0,d2
			move	sample8_dmareplen+2(a2),d2	; get repeatlen
			move	d2,aon_replen(a4)	; replen in WORDS

		tst.b	aon_oversize(a6)
		bne.b	sample8_zerorep
		add	d3,d2		; replen+repstart=wavelen
		move	d2,aon_wavelen(a4)

sample8_zeroRep
sample8_theresNorepeat
			move.l	sample8_dmaoffset(a2),d2
			add.l	d2,d2			; get bytesize!

			move.l	aon_oldsampoff(a4),d4
			lsr.l	#1,d4
			sub	d4,aon_wavelen(a4)	; offset from last com

			cmp.b	#9,aon_fxcom(a4)	; effect 'SAMPOFF'
			bne.s	aon_gdc_nonewsampoff	; no ??

			moveq	#0,d3
			move.b	aon_fxdat(a4),d3	; get offset
			lsl	#8,d3			; ->*256

			move.l	d3,d4
			lsr.l	#1,d4
			sub	d4,aon_wavelen(a4)
			bpl.s	aon_gdc_usesampoff
			move.l	aon_repeatstrt(a4),aon_waveform(a4)
			move	aon_replen(a4),aon_wavelen(a4)
			bra.b	aon_gdc_offendofsample
aon_gdc_usesampoff	add.l	d3,aon_oldsampoff(a4)
aon_gdc_nonewsampoff	
			add.l	d1,d2			; Realstart of wave
			add.l	aon_oldsampoff(a4),d2	; add offset
			move.l	d2,aon_waveform(a4)
aon_gdc_offendofsample
aon_gdc_resetvolume.etc

			tst.b	d5
			bne.s	aon_gdc_nonewinstr
			move.b	instr_volume(a2),aon_volume(a4)
; -----------------------------------

aon_gdc_nonewinstr

			moveq	#0,d0
			move.b	(a0),d0			; Get note
			and.b	#%00111111,d0
			bne.s	aon_gdc_notefound	; 0=Pause

			move.b	aon_lastnote(a4),d0	; Use last note!
			beq	aon_gdc_nonewnote
			cmp	#60,d0
			bgt	aon_gdc_nonewnote	; >B-3? -->pause!!!
			bra.b	aon_gdc_getarpeggio	; no instr retrig!!

aon_gdc_notefound	
			clr.b	aon_slideflag(a4)
			move.b	d0,aon_lastnote(a4)
			cmp	#60,d0
			bgt	aon_gdc_nonewnote	; >B-3? -->pause!!!

aon_gdc_getarpeggio
			move.l	aon_arpdata(a6),a3
			moveq	#0,d2
			moveq	#0,d3
			move.b	2(a0),d2
			move.b	1(a0),d3
			and.b	#%11000000,d2		; upper
			and.b	#%11000000,d3		; and lower 2 bits
			rol.b	#6,d2			; of arp.nr to use
			rol.b	#4,d3
			or.b	d2,d3			; *4 (4bytes/arp)

			lea	(a3,d3.l),a3		; get pointer on arpdat

			moveq	#0,d2
			move.b	instr_finetune(a2),d2	; get da finetune!!
			add	d2,d2
			move	(a5,d2.l),d2		; *120 (pertabsize)

			subq.b	#1,d0			; skip 'pause' mark
			add	d0,d0
			add	d0,d2			; offset in pertab

			cmp.b	#27,aon_fxcom(a4)
			beq	aon_arpslide
			cmp.b	#28,aon_fxcom(a4)
			beq	aon_arpslide
			cmp.b	#5,aon_fxcom(a4)
			beq.b	aon_arpslide
			cmp.b	#3,aon_fxcom(a4)
			bne.b	aon_notarpslide
aon_arpslide		move.b	(a0),d0
			and.b	#$3f,d0
			beq.b	aon_notarpslide
			move.b	#1,aon_slideflag(a4)
			lea	aon_periods(pc),a1
			move	(a1,d2.l),d1

			move	aon_period(a4),d0
			add	aon_perslide(a4),d0
			sub	d1,d0			; -actual periode=diff.
			move	d0,aon_perslide(a4)

;;;;;bra	aon_notarpslide

AON_notarpslide
			lea	aon_arpeggiotab(a4),a1
			cmp	#-1,2(a1)		; arpeggio im letzten
			bne.b	aon_NoArpReset		; step aktiv ?!
			clr	aon_arpeggiooff(a4)
			clr.b	aon_arpeggiocnt(a4)
aon_noarpreset
			tst.b	aon_fxcom(a4)
			bne.b	aon_gdc_noproarp
			tst.b	aon_fxdat(a4)
			beq.s	aon_gdc_noproarp
; Protracker-Arpeggio (fxcom=0) auslesen
			moveq	#0,d0
			moveq	#0,d1
			move.b	aon_fxdat(a4),d0
			move.b	d0,d1
			and.b	#$f0,d0
			and.b	#$0f,d1
			lsr.b	#4,d0
			add	d0,d0
			add	d1,d1
			move	d2,(a1)+
			add	d2,d0
			add	d2,d1
			move	d0,(a1)+
			move	d1,(a1)+
			bra.b	aon_gdc_arpend
aon_gdc_noproarp
; Professional arpeggio
			moveq	#0,d0
			moveq	#0,d1
			move.b	(a3)+,d0	; 1.nibble=anzahl arpeggios
			move.b	d0,d1
			lsr.b	#4,d0
			beq.b	aon_gdc_emptyarp	; arp_entry leer?!?!
			and.b	#$f,d1
			add	d1,d1
			add	d2,d1
			move	d1,(a1)+
			subq.b	#1,d0
			beq.b	aon_gdc_arpend
AON_GDC_writearps	moveq	#0,d1
			moveq	#0,d3
			move.b	(a3)+,d1	; 2 nibbles holen
			move.b	d1,d3
			lsr.b	#4,d1
			and.b	#$f,d3
			add	d1,d1
			add	d3,d3
			add	d2,d1
			move	d1,(a1)+
			subq.b	#1,d0
			beq.b	aon_gdc_arpend
			add	d2,d3
			move	d3,(a1)+
			subq.b	#1,d0
			bne.b	aon_gdc_writearps
aon_gdc_arpend		move	#-1,(a1)
aon_gdc_nonewnote	rts
aon_gdc_emptyarp
			clr	aon_arpeggiooff(a4)
			move.b	aon_arpeggiospd(a4),aon_arpeggiocnt(a4)
			subq.b	#1,aon_arpeggiocnt(a4)
			move	d2,(a1)+
			bra.b	aon_gdc_arpend
;========================================================================
; Vol-Envelope initalisieren
;
; Start		0-255
; Add 0-255 bis	255
; Sub 0-255 bis
; End		0-255

;
; a2=Instrumentdata
; a4=Channeldata
aon_initADSR:		
			cmp.b	#17,aon_fxcom(a4)
			bne.b	.notH
			move.b	aon_fxdat(a4),d3
			btst	#0,d3
			bne.b	.exit
.notH
			move.b	instr_Astart(a2),aon_synthVOL(a4)
			move.b	instr_Aadd(a2),d0
			beq.b	.noADSR
			move.b	d0,aon_synthADD(a4)
			move.b	instr_Asub(a2),aon_synthSUB(a4)
			move.b	instr_Aend(a2),aon_synthEND(a4)

			move.b	#1,aon_synthENV(a4)	; Envelope ADD
.exit			rts

.noADSR			move.b	#127,aon_synthVOL(a4)
			clr.b	aon_synthENV(a4)	; Envelope OFF
			rts

;========================================================================
; dont change a1!!!!!!1
; a4=chptr
AON_DOSYNTH
			clr.b	aon_vibDONE(a4)
			tst.b	aon_chflag(a4)
			bne	.exit
			tst.b	aon_chMODE(a4)		; isssees n sample?!
			beq	.exitSMPL
			tst.l	aon_waveform(a4)	; keine wellenform !?!
			beq	.exit

			tst.b	aon_synthwaveSTOP(a4)
			bne.w	.nonewwave


			addq.b	#1,aon_synthWAVEcnt(a4)
			move.b	aon_synthWAVEspd(a4),d0
			cmp.b	aon_synthWAVEcnt(a4),d0	; framecnt
			bgt	.nonewWAVE
			clr.b	aon_synthWAVEcnt(a4)
			move.l	aon_synthWAVEaddbytes(a4),d0
			add.l	d0,aon_synthWAVEactptr(a4)

			tst.l	d0	; partwave wandert nach links?!?!
			bpl.b	.rightloop
			move.l	aon_synthWAVErepptr(a4),d0	; links clippen
			cmp.l	aon_synthWAVEactptr(a4),d0
			ble.b	.notwaveend
			bra.b	.jumprepeat
.rightloop
			move.l	aon_synthWAVEendptr(a4),d0	;rechts clippen
			cmp.l	aon_synthWAVEactptr(a4),d0
			bgt.b	.notwaveend
.jumprepeat		tst.b	aon_synthWAVERepctrl(a4)
			beq.b	.normalrep
			cmp.b	#1,aon_synthWAVERepctrl(a4)
			beq.b	.backrep

.pingpong
		move.l	aon_synthWAVErependptr(a4),aon_synthWAVEendptr(a4)
			move.l	aon_synthwaveaddbytes(a4),d0
			sub.l	d0,aon_synthWAVEactptr(a4)
			neg.l	d0
			move.l	d0,aon_synthwaveaddbytes(a4)
			bra.b	.notwaveend

.normalrep		move.l	aon_synthWAVErepptr(a4),aon_synthWAVEactptr(a4)
		move.l	aon_synthWAVErependptr(a4),aon_synthWAVEendptr(a4)
			bra.b	.notwaveend
.backrep	move.l	aon_synthwaveRependptr(a4),aon_synthwaveActptr(a4)
			move.l	aon_synthwaveaddbytes(a4),d0
			bmi.b	.alreadyNeg
			neg.l	d0
			tst.b	aon_synthWAVESTOP(a4)
			bne.b	.notwaveend
.alreadyNeg		add.l	d0,aon_synthWAVEactptr(a4)
			move.l	d0,aon_synthwaveaddbytes(a4)
.notwaveend
			move.b	#1,aon_chflag(a4)	; new repoff

;		cmp.b	#9,aon_fxcom(a4)
;		beq.b	.setit
.setit			move.l	aon_synthWAVEactptr(a4),aon_repeatstrt(a4)
.nonewWAVE


.exitSMPL
; DO Envelope

			tst.b	aon_synthENV(a4)
			beq.b	.dovib
			moveq	#0,d0
			move.b	aon_synthVOL(a4),d0
			cmp.b	#1,aon_synthENV(a4)
			bne.b	.decay
			add.b	aon_synthADD(a4),d0
			bpl.b	.newVOL
			moveq	#127,d0
			move.b	#2,aon_synthENV(A4)
			bra.b	.newVOL
.decay			sub.b	aon_synthSUB(a4),d0
			cmp.b	aon_synthEND(a4),d0
			bgt.b	.newVOL
			move.b	aon_synthEND(a4),d0
			clr.b	aon_synthENV(a4)
.newVOL			move.b	d0,aon_synthVOL(a4)


; Vibrato
.dovib
			cmp.b	#"!",aon_vibON(a4)
			beq.b	.vibok
			cmp	#-1,aon_vibratoTRIGdelay(a4)
			bne	.delayvib
			move.b	#1,aon_vibON(a4)
			bra.b	.vibok
.delayvib		subq	#1,aon_vibratoTRIGdelay(a4)
.vibok

.exit
			cmp.b	#1,aon_vibON(a4)
			bne.b	.VIBoff
			bra	aon_dofx_viboldampl
.VIBoff			rts
;========================================================================
; a4=channelptr
; don't use a1
AON_DOFX
			tst.b	aon_vibCONT(a4)
			bne.b	.dauervibrato
			move.b	#"!",aon_vibON(a4)
.dauervibrato

			addq.b	#1,aon_arpeggiocnt(a4)
			move.b	aon_arpeggiospd(a4),d0	; time for arpeggio
			cmp.b	aon_arpeggiocnt(a4),d0	; tone-change ?!
			bgt.s	aon_dofx_nonewarpval

			clr.b	aon_arpeggiocnt(a4)	; clear counter

aon_dofx_newarpval	move	aon_arpeggiooff(a4),d1	; offset in tab
			lea	aon_arpeggiotab(a4),a3
			moveq	#0,d7
			move	(a3,d1),d7		; get act. note
			bpl.s	aon_dofx_notarpend
			clr	aon_arpeggiooff(a4)
			bra.b	aon_dofx_newarpval
aon_dofx_notarpend
			lea	aon_periods(pc),a3
			move	(a3,d7.l),d0		; get periode
			move	d0,aon_period(a4)	; store in chdata
			addq.b	#2,aon_arpeggiooff+1(a4) ; next value
			and.b	#$0f,aon_arpeggiooff+1(a4)
aon_dofx_nonewarpval

			move.l	#aon_doSYNTH,-(sp)
;bsr	aon_dosynth

			moveq	#0,d0
			moveq	#0,d1
			move.b	aon_fxdat(a4),d1

			move.b	aon_fxcom(a4),d0
			beq.w	aon_dofx_end

			tst.b	aon_framecnt(a6)
			beq.b	aon_dofx_atonce

			cmp.b	#1,d0
			beq.w	aon_dofx_portamentoup
			cmp.b	#$2,d0
			beq.w	aon_dofx_portamentodown
			cmp.b	#$3,d0
			beq.w	aon_dofx_toneslide
			cmp.b	#$4,d0
			beq	aon_dofx_vibrato
			cmp.b	#$5,d0
			beq	aon_dofx_glissvolumeslide
			cmp.b	#$6,d0
			beq	aon_dofx_vibvolumeslide
			cmp.b	#$a,d0
			beq	aon_dofx_volumeslide
aon_dofx_atonce
			cmp.b	#$b,d0
			beq	aon_dofx_breakto
			cmp.b	#$c,d0
			beq	aon_dofx_setvolume
			cmp.b	#$d,d0
			beq	aon_dofx_breakpat
			cmp.b	#$e,d0
			beq	aon_dofx_ecommands
			cmp.b	#$f,d0
			beq	aon_dofx_setspd
			cmp.b	#16,d0		'g'
			beq	aon_dofx_setvoldel
			cmp.b	#18,d0		'i'
			beq	aon_dofx_setwaveadsrspd
			cmp.b	#19,d0		'j'
			beq	aon_dofx_setarpspd
			cmp.b	#20,d0		'k'
			beq	aon_dofx_vibsetvolume
			cmp.b	#21,d0		'l'
			beq	aon_dofx_portvolslideUP
			cmp.b	#22,d0		'm'
			beq	aon_dofx_portvolslideDOWN
			cmp.b	#23,d0		'n'
			beq	aon_dofx_togglenoiseavoid
			cmp.b	#24,d0		'o'
			beq	aon_dofx_toggleoversize
			cmp.b	#25,d0		'p'
			beq	aon_dofx_fineVOLslidevib
			cmp.b	#26,d0		'q'
			beq	aon_dofx_synthdrums
			cmp.b	#27,d0		'r'
			beq	aon_dofx_setvolumePort
			cmp.b	#28,d0		's'
			beq	aon_dofx_finevolslidePort
			cmp.b	#29,d0		't'
			beq	aon_dofx_settrackvol
			cmp.b	#30,d0		'u'
			beq	aon_dofx_setwavecont
			cmp.b	#33,d0		'x'
			beq	aon_dofx_externalevent
aon_dofx_end		rts
; --------------------------------------------------------------------
; $1
aon_dofx_portamentoup
			sub	d1,aon_perslide(a4)
			rts
; --------------------------------------------------------------------
; $2
aon_dofx_portamentodown
			add	d1,aon_perslide(a4)
			rts
; --------------------------------------------------------------------
; $3
aon_dofx_toneslide	tst.b	d1
			beq.b	aon_dofx_toneslideNOW
			move.b	d1,aon_glissspd(a4)
aon_dofx_toneslideNOW
			tst.b	aon_slideflag(a4)
			beq.b	.exit
			move.b	aon_glissspd(a4),d1
			tst	aon_perslide(a4)
			beq.b	aon_dofx_end
			bpl.b	.sub
			add	d1,aon_perslide(a4)
			bmi.b	aon_dofx_end
			clr	aon_perslide(a4)
			rts
.sub			sub	d1,aon_perslide(a4)
			bpl.b	aon_dofx_end
			clr	aon_perslide(a4)
.exit			rts
; --------------------------------------------------------------------
; $4
aon_dofx_vibrato
			move.b	#1,aon_vibON(a4)
aon_dofx_vibratoPARAM
			tst.b	d1
			beq.b	.goon		; Vibrato-Parameter
			move.b	d1,d2		; setzen!!
			and.b	#$f0,d1
			lsr.b	#4,d1
			beq.b	.oldspd
			move.b	d1,aon_vibratospd(a4)
.oldspd			and.b	#$0f,d2
			beq.s	.goon
			and.b	#$f0,aon_vibratoampl(a4)
			or.b	d2,aon_vibratoampl(a4)
.goon			rts

; Einsprung um Vibrato-Effekt zu erzeugen
aon_dofx_viboldampl	
			tst.b	aon_vibdone(a4)	; Nur ·1· Vibrato zur Zeit
			bne.b	aon_dofx_vibnotend
			move.b	#1,aon_vibdone(a4)

			moveq	#0,d2
			move.b	aon_vibratoampl(a4),d2
			and.b	#%01100000,d2
			beq.s	aon_dofx_vibSINE
			cmp.b	#32,d2
			beq.s	aon_dofx_vibRAMPDOWN
			lea	aon_vibrato_square(pc),a2
			bra.b	aon_dofx_vibSQUARE
aon_dofx_vibRAMPDOWN	lea	aon_vibrato_rampdown(pc),a2
			bra.b	aon_dofx_vibsquare
aon_dofx_vibSINE	lea	aon_vibrato_sine(pc),a2
aon_dofx_vibSQUARE
			move.b	aon_vibratopos(a4),d2
			moveq	#0,d0

			move.b	(a2,d2),d2		; vibrato-value
			move.b	aon_vibratoampl(a4),d0
			and.b	#$f,d0
			mulu	d0,d2			; *vibrato amplitude
			lsr	#7,d2

			move	aon_period(a4),d0	; period (smaller)

			btst	#7,aon_vibratoampl(a4)	; negativ ?
			beq.s	aon_dofx_vibpositiv
			sub	d2,d0
			bra.b	aon_dofx_vibnegativ
aon_dofx_vibpositiv
			add	d2,d0
aon_dofx_vibnegativ
			move	d0,aon_period(a4)

			move.b	aon_vibratospd(a4),d0
			add.b	d0,aon_vibratopos(a4)
			btst	#5,aon_vibratopos(a4)
			beq.s	aon_dofx_vibnotend
			and.b	#$1f,aon_vibratopos(a4)
			bchg	#7,aon_vibratoampl(a4)	; toggle pos/neg
aon_dofx_vibnotend	rts
; --------------------------------------------------------------------
; $5
aon_dofx_glissvolumeslide
			move	d1,-(sp)
			moveq	#0,d1
			bsr	aon_dofx_toneslideNOW
			move	(sp)+,d1
			bra.b	aon_dofx_volumeslide
; --------------------------------------------------------------------
; $6
aon_dofx_vibvolumeslide	move	d1,-(sp)
			bsr	aon_dofx_viboldampl
			move	(sp)+,d1
			bra	aon_dofx_volumeslide
; --------------------------------------------------------------------
; $A
aon_dofx_volumeslide	move.b	d1,d2
			and.b	#$0f,d1
			and.b	#$f0,d2
			lsr.b	#4,d2
			tst.b	d2	; Protracker-Kompatibilität:
			bne.s	aon_dofx_vsok1	; Wenn volume slide up <>0
			; dann volume slide down nicht beachten!!
			sub.b	d1,aon_volume(a4)
			bpl.s	aon_dofx_vsok1
			clr.b	aon_volume(a4)
aon_dofx_vsok1		add.b	d2,aon_volume(a4)
			cmp.b	#64,aon_volume(a4)
			bls.s	aon_dofx_vsOK2
			move.b	#64,aon_volume(a4)
aon_dofx_vsok2		rts
; --------------------------------------------------------------------
; $B
aon_dofx_breakto
		CMP.B	#REPLAYST_PAT,REPLAYSTATUS+MAIN_DATA
		BEQ.B	AON_DOFX_NOPATPLAYBREAK
			subq.b	#1,d1
			move.b	d1,aon_pos(a6)
AON_DOFX_NOPATPLAYBREAK	move	#$ff00,aon_patcnt(a6)
			rts
; --------------------------------------------------------------------
; $C
aon_dofx_setvolume	move.b	d1,aon_volume(a4)
			rts
; --------------------------------------------------------------------
; $D
aon_dofx_breakpat
			move.b	d1,d0		; e.g	$32 -> #32
			and.b	#$0f,d1
			and.b	#$f0,d0
			lsr.b	#1,d0		; -> $30->$18=#24
			move.b	d0,d2
			lsr.b	#3,d2		; -> $18/8->$03
			add.b	d2,d0		; #24+3
			add.b	d2,d0		; #27+3 (=#30)
			add.b	d1,d0		; +2!
			add.b	d0,d0		; =#32
			add.b	d0,d0		; ->*4
			or	#$ff00,d0	; add breakflag
			move	d0,aon_patcnt(a6)
			rts
; --------------------------------------------------------------------
; $F
aon_dofx_setspd
			tst.b	d1
			beq.b	aon_dofx_replayend

			cmp.b	#32,d1
			bhi.b	.settempo2
			move.b	d1,aon_speed(a6)
.quit			rts

.settempo2		cmp.b	#200,d1
			bhi.b	.quit
			move.l	#aon_timerval,d0
			divu	d1,d0

			move.b	d1,aon_tempo(a6)
aon_dofx_settempo		
			move.b	d0,$bfd600	; MSB	Timer setzen
			lsr	#8,d0		; 8-15
			move.b	d0,$bfd700	; LSB
aon_dofx_vbireplay
			rts
aon_dofx_replayend	clr.b	aon_speed(a6)
aon_resettimer		move.b	#125,aon_tempo(a6)
			move.b	#$6c,$bfd600	600
			move.b	#$37,$bfd700	700
			rts
; --------------------------------------------------------------------
; | E1- FineSlide Up                  E1x : value			   |
; | E2- FineSlide Down                E2x : value			   |
; | E3- Glissando Control             E3x : 0-off, 1-on (use with tonep.)  |
; | E4- Set Vibrato Waveform          E4x : 0-sine, 1-ramp down, 2-square  |
; | E5- Set Loop                      E5x : set loop point		   |
; | E6- Jump to Loop                  E6x : jump to loop, play x times	   |
; | E7- Set Tremolo Waveform          E7x : 0-sine, 1-ramp down. 2-square  |
; | E8- NOT USED							   |
; | E9- Retrig Note                   E9x : retrig from note + x vblanks   |
; | EA- Fine VolumeSlide Up           EAx : add x to volume		   |
; | EB- Fine VolumeSlide Down         EBx : subtract x from volume	   |
; | EC- NoteCut                       ECx : cut from note + x vblanks	   |
; | ED- NoteDelay                     EDx : delay note x vblanks	   |
; | EE- PatternDelay                  EEx : delay pattern x notes	   |
; | EF- Invert Loop                   EFx : speed			   |
; $Ex
aon_dofx_ECOMMANDS	move.b	d1,d0
			and.b	#$0f,d1
			and.b	#$f0,d0
			beq.s	aon_dofx_setfilter
			cmp.b	#$10,d0
			beq.s	aon_dofx_fineportamentoup
			cmp.b	#$20,d0
			beq.s	aon_dofx_fineportamentodn
			cmp.b	#$40,d0
			beq.s	aon_dofx_setvibratowave
			cmp.b	#$50,d0
			beq.w	aon_dofx_setlooppoint
			cmp.b	#$60,d0
			beq	aon_dofx_jump2loop
			cmp.b	#$90,d0
			beq	aon_dofx_retrignote
			cmp.b	#$a0,d0
			beq	aon_dofx_finevolup
			cmp.b	#$b0,d0
			beq	aon_dofx_finevoldn
			cmp.b	#$c0,d0
			beq	aon_dofx_notecut
			cmp.b	#$d0,d0
			beq	aon_dofx_retrignote
			rts
; --------------------------------------------------------------------
; $E0
aon_dofx_setfilter	tst.b	d1
			beq.s	aon_dofx_filteron
			bset	#1,$bfe001

	JSR	SHOWFILTERSTATUS

			rts
aon_dofx_filteron	bclr	#1,$bfe001

	JSR	SHOWFILTERSTATUS
			rts
; --------------------------------------------------------------------
; $E1
aon_dofx_fineportamentoup
			tst.b	aon_framecnt(a6)
			bne.s	aon_dofx_tool8
			sub	d1,aon_perslide(a4)
aon_dofx_tool8		rts
; --------------------------------------------------------------------
; $E2
aon_dofx_fineportamentodn
			tst.b	aon_framecnt(a6)
			bne.s	aon_dofx_tool82
			add	d1,aon_perslide(a4)
aon_dofx_tool82		rts
; --------------------------------------------------------------------
; $E4
aon_dofx_setvibratowave
			and.b	#3,d1
			ror.b	#3,d1
			and.b	#%10011111,aon_vibratoampl(a4)
			or.b	d1,aon_vibratoampl(a4)
			rts
; --------------------------------------------------------------------
; $E5
aon_dofx_setlooppoint
			move.b	aon_patcnt+1(a6),d0
			subq.b	#4,d0
			cmp.b	aon_looppoint(a6),d0
			beq.s	aon_dofx_justloopin
			move.b	d0,aon_looppoint(a6)
			clr.b	aon_loopcnt(a6)
aon_dofx_justloopin	rts
; --------------------------------------------------------------------
; $E6
aon_dofx_jump2loop
			tst.b	d1
			beq.s	aon_dofx_setlooppoint
			rts
; --------------------------------------------------------------------
; $E9
aon_dofx_retrignote	tst.b	aon_stepfxcnt(a4)
			bne.s	aon_dofx_noretrig
			move.b	#3,aon_chflag(a4)
			move.b	#$ef,aon_fxcom(a4)
			rts
aon_dofx_noretrig	subq.b	#1,aon_stepfxcnt(a4)
			rts
; --------------------------------------------------------------------
; $EA
aon_dofx_finevolup
			tst.b	aon_framecnt(a6)
			bne.s	aon_dofx_volresisup
			add.b	d1,aon_volume(a4)
			cmp.b	#64,aon_volume(a4)
			ble.s	aon_dofx_volresisup
			move.b	#64,aon_volume(a4)
aon_dofx_volresisup	rts
; --------------------------------------------------------------------
; $EB
aon_dofx_finevoldn	tst.b	aon_framecnt(a6)
			bne.s	aon_dofx_volresisdn
			sub.b	d1,aon_volume(a4)
			bpl.s	aon_dofx_volresisdn
			clr.b	aon_volume(a4)
aon_dofx_volresisdn	rts
; --------------------------------------------------------------------
; $EC
aon_dofx_notecut	tst.b	aon_stepfxcnt(a4)
			bne.s	.nonotecut
			clr.b	aon_volume(a4)
			rts
.nonotecut		subq.b	#1,aon_stepfxcnt(a4)
			rts
; --------------------------------------------------------------------
; 'g'
aon_dofx_setvoldel
			tst.b	aon_stepfxcnt(a4)
			bne.b	.novolset
			and.b	#$f0,d1
			lsr.b	#4,d1
			add.b	d1,d1
			add.b	d1,d1
			addq.b	#4,d1
			move.b	d1,aon_volume(a4)
			rts
.novolset		subq.b	#1,aon_stepfxcnt(a4)
			rts
; --------------------------------------------------------------------
; 'i'
aon_dofx_setwaveadsrspd
			move.b	d1,d2
			and.b	#$f0,d1
			lsr.b	#4,d1
			move.b	d1,aon_synthWAVEspd(a4)
			rts
; --------------------------------------------------------------------
; 'j'
aon_dofx_setarpspd	and.b	#$f,d1
			beq.b	.not
			move.b	d1,aon_arpeggiospd(a4)
.not			rts
; --------------------------------------------------------------------
; 'k'
aon_dofx_vibsetvolume	move	d1,-(sp)
			bsr	aon_dofx_viboldampl
			move	(sp)+,d1
			bra	aon_dofx_setvolume
; --------------------------------------------------------------------
; 'l'
aon_dofx_portvolslideUP
			lea	aon_nibbletab(pc),a0
			move	d1,d2
			lsr.b	#4,d1
			and.b	#$f,d2
			move.b	(a0,d1),d1
			bpl.b	.up1
			neg.b	d1
			bsr	aon_dofx_finevolDN
			bra.b	.down1
.up1			bsr	aon_dofx_finevolUP
.down1
			tst.b	aon_framecnt(a6)
			beq.b	.out
			moveq	#0,d1
			move.b	d2,d1
			bsr	aon_dofx_portamentoup

.out			rts

aoN_nibbletab		dc.b	0,1,2,3,4,5,6,7,-8,-7,-6,-5,-4,-3,-2,-1
; --------------------------------------------------------------------
; 'm'
aon_dofx_portvolslideDOWN
			lea	aon_nibbletab(pc),a0
			move	d1,d2
			lsr.b	#4,d1
			and.b	#$f,d2
			move.b	(a0,d1),d1
			bpl.b	.up1
			neg.b	d1
			bsr	aon_dofx_finevolDN
			bra.b	.down1
.up1			bsr	aon_dofx_finevolUP
.down1
			tst.b	aon_framecnt(a6)
			beq.b	.out
			moveq	#0,d1
			move.b	d2,d1
			bsr	aon_dofx_portamentoDOWN

.out			rts
; --------------------------------------------------------------------
; 'n'
aon_dofx_togglenoiseavoid
			move.b	d1,aon_noiseavoid(a6)
			rts
; --------------------------------------------------------------------
; 'o'
aon_dofx_toggleoversize
			move.b	d1,aon_oversize(a6)
			rts
; --------------------------------------------------------------------
; 'p'
aon_dofx_fineVOLslidevib
			move	d1,-(sp)
			bsr	aon_dofx_viboldampl
			move	(sp)+,d1
aon_dofx_fineVOlUpDown	moveq	#0,d2
			move.b	d1,d2
			lsr.b	#4,d2
			beq.b	.no
			move	d2,d1
			bra	aon_dofx_finevolup
.no			and.b	#$f,d1
			bra	aon_dofx_finevoldn
; --------------------------------------------------------------------
; 'q'
aon_dofx_synthdrums
			move	d1,d2
			lsr	#4,d1
			lsl	#3,d1
			bsr	aon_dofx_portamentodown
			move	d2,d1
			and	#$f,d1
			bra	aon_dofx_volumeslide
; --------------------------------------------------------------------
; 'r'
aon_dofx_setvolumePort
			move	d1,-(sp)
			bsr	aon_dofx_toneslideNOW
			move	(sp)+,d1
			bra	aon_dofx_setvolume
; --------------------------------------------------------------------
; 's'
aon_dofx_finevolslidePort
			move	d1,-(sp)
			bsr	aon_dofx_toneslideNOW
			move	(sP)+,d1
			bra	aon_dofx_fineVOlUpDown
; --------------------------------------------------------------------
; 't'
aon_dofx_settrackvol
			move	d1,aon_trackvol(a4)
			rts
; --------------------------------------------------------------------
; 'u'
;
aon_dofx_setwavecont	move.b	d1,d2
			and.b	#$f,d1
			move.b	d1,aon_synthWAVECONT(a4)
			lsr.b	#4,d2
			move.b	d2,aon_synthWAVESTOP(a4)
			rts
; --------------------------------------------------------------------
; 'v'
; --------------------------------------------------------------------
; 'w'
; --------------------------------------------------------------------
; 'x'
aon_dofx_externalevent
			tst.b	aon_framecnt(a6)	; nur 1* aufrufen!!!
			beq.b	.yo
			rts
.yo			lea	aon_event(pc),a0	; pc-relativ bleiben
			move.b	d1,(a0)
			rts
; --------------------------------------------------------------------
; 'y'
aon_dofx_externalevent2
			tst.b	aon_framecnt(a6)	; nur 1* aufrufen!!!
			beq.b	.yo
			rts
.yo			lea	aon_event+1(pc),a0	; pc-relativ bleiben
			move.b	d1,(a0)
			rts
; --------------------------------------------------------------------
; 'z'
aon_dofx_externalevent3
			tst.b	aon_framecnt(a6)	; nur 1* aufrufen!!!
			beq.b	.yo
			rts
.yo			lea	aon_event+2(pc),a0	; pc-relativ bleiben
			move.b	d1,(a0)
			rts
; --------------------------------------------------------------------

; =======================================================================
AON_WAITDMA
			IFEQ	rasttime-1
			move	#$aac,$dff180
			ENDIF
			move.b	$dff006,d0
			add.b	aon_dmawait,d0
aon_waitdmaloop		cmp.b	$dff006,d0
			bne.s	aon_waitdmaloop
			IFEQ	rasttime-1
			move	#$f00,$dff180
			ENDIF
			rts
;========================================================================
AON_STARTINSTR.1
			move	aon_fxcom(a4),d0
			and	#$0ff0,d0
			cmp	#$0ed0,d0
			beq.w	aon_strtinsonlyrep.1

			btst	#1,aon_chflag(a4)	; bit1= aonflag=2 or 3
			beq.b	aon_strtins.notset1

		tst.b	aon_noiseavoid(a6)
		beq.b	.letsknack
		cmp	#255,aon_oldwavelen(a4)
		bhi.b	.letsknack
		tst	aon_oldwavelen(a4)
		beq.b	.letsknack
		cmp	#255,aon_wavelen(a4)
		ble.b	aon_strtins.notset1
.letsknack		bset	d7,d1
aon_strtins.notset1

			move	aon_period(a4),d0	; baseper+arpeggio
			add	aon_perslide(a4),d0	; portamento value
.checkhiper
			cmp	#103,d0
			bhs.b	.noperalert
			moveq	#103,d0
.noperalert		move	d0,$6(a5)

	MOVE	D0,EQU_ACTPER(A3)

			moveq	#0,d0
			move.b	aon_volume(a4),d0
			moveq	#0,d2
			move.b	aon_synthVOL(a4),d2
			lsr.b	#1,d2
			mulu	d2,d0
			lsr	#6,d0
			mulu	aon_trackvol(a4),d0
			lsr	#6,d0
		BTST	D7,CH_ENABLE+MAIN_DATA
		BEQ.B	.choff
			move.b	d0,$9(a5)
		BRA.B	.CHON
.choff			move.b	#0,$9(a5)
.CHON		MOVE.B	D0,EQU_ACTVOLUME(A3)


			btst	#1,aon_chflag(a4)
			beq.s	aon_strtinsonlyrep.1
			move.l	aon_waveform(a4),$0(a5)

			move	aon_wavelen(a4),$4(a5)

	MOVEQ	#0,D0
	MOVE	AON_WAVELEN(A4),D0
	ADD.L	D0,D0
	MOVE.L	D0,EQU_WAVELEN(A3)
	MOVE.L	AON_WAVEFORM(A4),EQU_ACTWAVEPTR(A3)	; Für EQUALIZER!!!!!!
	CLR.L	EQU_ACTWAVEOFF(A3)

aon_strtinsonlyrep.1
			addq.b	#1,d7
aon_strtinsonlyrep.2	lea	aon_chdatasize(a4),a4
			lea	$10(a5),a5
	LEA	EQU_DATASIZE(A3),A3
			rts
AON_STARTINSTR.2
			move	aon_fxcom(a4),d0
			and	#$0ff0,d0
			cmp	#$0ed0,d0
			beq.s	aon_strtinsonlyrep.1


			move.l	aon_repeatstrt(a4),(a5)
			move	aon_replen(a4),$4(a5)
			clr.b	aon_chflag(a4)
			bra.b	aon_strtinsonlyrep.1
;========================================================================
aon_dmawait		dc.b	40,0				; rastlines

aon_event		dc.b	0,0,0	; z.b für demo-synchronisation
			even

	even
AON_leer		ds.b	256
	even
AON_hi			dc.b	64,64
	even
AON_multab120	dc	120*0,120*1,120*2,120*3,120*4,120*5,120*6,120*7
		dc	120*8,120*9,120*10,120*11,120*12,120*13,120*14,120*15
	even
AON_PERIODS
	DC.B	$0D,$60,$0C,$A0,$0B,$E8,$0B,$40		16 finetunes,5 octaves
	DC.B	$0A,$98,$0A,$00,$09,$70,$08,$E8
	DC.B	$08,$68,$07,$F0,$07,$80,$07,$14
	DC.B	$06,$B0,$06,$50,$05,$F4,$05,$A0
	DC.B	$05,$4C,$05,$00,$04,$B8,$04,$74
	DC.B	$04,$34,$03,$F8,$03,$C0,$03,$8A
	DC.B	$03,$58,$03,$28,$02,$FA,$02,$D0
	DC.B	$02,$A6,$02,$80,$02,$5C,$02,$3A
	DC.B	$02,$1A,$01,$FC,$01,$E0,$01,$C5
	DC.B	$01,$AC,$01,$94,$01,$7D,$01,$68
	DC.B	$01,$53,$01,$40,$01,$2E,$01,$1D
	DC.B	$01,$0D,$00,$FE,$00,$F0,$00,$E2
	DC.B	$00,$D6,$00,$CA,$00,$BE,$00,$B4
	DC.B	$00,$AA,$00,$A0,$00,$97,$00,$8F
	DC.B	$00,$87,$00,$7F,$00,$78,$00,$71
	DC.B	$0D,$48,$0C,$88,$0B,$D4,$0B,$2C
	DC.B	$0A,$88,$09,$F4,$09,$64,$08,$DC
	DC.B	$08,$5C,$07,$E4,$07,$74,$07,$08
	DC.B	$06,$A4,$06,$44,$05,$EA,$05,$96
	DC.B	$05,$44,$04,$FA,$04,$B2,$04,$6E
	DC.B	$04,$2E,$03,$F2,$03,$BA,$03,$84
	DC.B	$03,$52,$03,$22,$02,$F5,$02,$CB
	DC.B	$02,$A2,$02,$7D,$02,$59,$02,$37
	DC.B	$02,$17,$01,$F9,$01,$DD,$01,$C2
	DC.B	$01,$A9,$01,$91,$01,$7B,$01,$65
	DC.B	$01,$51,$01,$3E,$01,$2C,$01,$1C
	DC.B	$01,$0C,$00,$FD,$00,$EF,$00,$E1
	DC.B	$00,$D5,$00,$C9,$00,$BD,$00,$B3
	DC.B	$00,$A9,$00,$9F,$00,$96,$00,$8E
	DC.B	$00,$86,$00,$7E,$00,$77,$00,$71
	DC.B	$0D,$30,$0C,$70,$0B,$C0,$0B,$14
	DC.B	$0A,$78,$09,$E0,$09,$54,$08,$CC
	DC.B	$08,$50,$07,$D8,$07,$68,$06,$FC
	DC.B	$06,$98,$06,$38,$05,$E0,$05,$8A
	DC.B	$05,$3C,$04,$F0,$04,$AA,$04,$66
	DC.B	$04,$28,$03,$EC,$03,$B4,$03,$7E
	DC.B	$03,$4C,$03,$1C,$02,$F0,$02,$C5
	DC.B	$02,$9E,$02,$78,$02,$55,$02,$33
	DC.B	$02,$14,$01,$F6,$01,$DA,$01,$BF
	DC.B	$01,$A6,$01,$8E,$01,$78,$01,$63
	DC.B	$01,$4F,$01,$3C,$01,$2A,$01,$1A
	DC.B	$01,$0A,$00,$FB,$00,$ED,$00,$E0
	DC.B	$00,$D3,$00,$C7,$00,$BC,$00,$B1
	DC.B	$00,$A7,$00,$9E,$00,$95,$00,$8D
	DC.B	$00,$85,$00,$7D,$00,$76,$00,$70
	DC.B	$0D,$18,$0C,$5C,$0B,$A8,$0B,$00
	DC.B	$0A,$64,$09,$D0,$09,$40,$08,$BC
	DC.B	$08,$40,$07,$C8,$07,$58,$06,$F0
	DC.B	$06,$8C,$06,$2E,$05,$D4,$05,$80
	DC.B	$05,$32,$04,$E8,$04,$A0,$04,$5E
	DC.B	$04,$20,$03,$E4,$03,$AC,$03,$78
	DC.B	$03,$46,$03,$17,$02,$EA,$02,$C0
	DC.B	$02,$99,$02,$74,$02,$50,$02,$2F
	DC.B	$02,$10,$01,$F2,$01,$D6,$01,$BC
	DC.B	$01,$A3,$01,$8B,$01,$75,$01,$60
	DC.B	$01,$4C,$01,$3A,$01,$28,$01,$18
	DC.B	$01,$08,$00,$F9,$00,$EB,$00,$DE
	DC.B	$00,$D1,$00,$C6,$00,$BB,$00,$B0
	DC.B	$00,$A6,$00,$9D,$00,$94,$00,$8C
	DC.B	$00,$84,$00,$7D,$00,$76,$00,$6F
	DC.B	$0D,$00,$0C,$44,$0B,$94,$0A,$EC
	DC.B	$0A,$50,$09,$BC,$09,$30,$08,$AC
	DC.B	$08,$30,$07,$BC,$07,$4C,$06,$E4
	DC.B	$06,$80,$06,$22,$05,$CA,$05,$76
	DC.B	$05,$28,$04,$DE,$04,$98,$04,$56
	DC.B	$04,$18,$03,$DE,$03,$A6,$03,$72
	DC.B	$03,$40,$03,$11,$02,$E5,$02,$BB
	DC.B	$02,$94,$02,$6F,$02,$4C,$02,$2B
	DC.B	$02,$0C,$01,$EF,$01,$D3,$01,$B9
	DC.B	$01,$A0,$01,$88,$01,$72,$01,$5E
	DC.B	$01,$4A,$01,$38,$01,$26,$01,$16
	DC.B	$01,$06,$00,$F7,$00,$E9,$00,$DC
	DC.B	$00,$D0,$00,$C4,$00,$B9,$00,$AF
	DC.B	$00,$A5,$00,$9C,$00,$93,$00,$8B
	DC.B	$00,$83,$00,$7C,$00,$75,$00,$6E
	DC.B	$0C,$E8,$0C,$2C,$0B,$80,$0A,$D8
	DC.B	$0A,$3C,$09,$AC,$09,$20,$08,$9C
	DC.B	$08,$20,$07,$AC,$07,$3C,$06,$D4
	DC.B	$06,$74,$06,$16,$05,$C0,$05,$6C
	DC.B	$05,$1E,$04,$D6,$04,$90,$04,$4E
	DC.B	$04,$10,$03,$D6,$03,$9E,$03,$6A
	DC.B	$03,$3A,$03,$0B,$02,$E0,$02,$B6
	DC.B	$02,$8F,$02,$6B,$02,$48,$02,$27
	DC.B	$02,$08,$01,$EB,$01,$CF,$01,$B5
	DC.B	$01,$9D,$01,$86,$01,$70,$01,$5B
	DC.B	$01,$48,$01,$35,$01,$24,$01,$14
	DC.B	$01,$04,$00,$F5,$00,$E8,$00,$DB
	DC.B	$00,$CE,$00,$C3,$00,$B8,$00,$AE
	DC.B	$00,$A4,$00,$9B,$00,$92,$00,$8A
	DC.B	$00,$82,$00,$7B,$00,$74,$00,$6D
	DC.B	$0C,$D0,$0C,$18,$0B,$68,$0A,$C4
	DC.B	$0A,$2C,$09,$98,$09,$10,$08,$8C
	DC.B	$08,$10,$07,$9C,$07,$30,$06,$C8
	DC.B	$06,$68,$06,$0C,$05,$B4,$05,$62
	DC.B	$05,$16,$04,$CC,$04,$88,$04,$46
	DC.B	$04,$08,$03,$CE,$03,$98,$03,$64
	DC.B	$03,$34,$03,$06,$02,$DA,$02,$B1
	DC.B	$02,$8B,$02,$66,$02,$44,$02,$23
	DC.B	$02,$04,$01,$E7,$01,$CC,$01,$B2
	DC.B	$01,$9A,$01,$83,$01,$6D,$01,$59
	DC.B	$01,$45,$01,$33,$01,$22,$01,$12
	DC.B	$01,$02,$00,$F4,$00,$E6,$00,$D9
	DC.B	$00,$CD,$00,$C1,$00,$B7,$00,$AC
	DC.B	$00,$A3,$00,$9A,$00,$91,$00,$89
	DC.B	$00,$81,$00,$7A,$00,$73,$00,$6D
	DC.B	$0C,$B8,$0C,$00,$0B,$54,$0A,$B0
	DC.B	$0A,$18,$09,$88,$08,$FC,$08,$7C
	DC.B	$08,$04,$07,$90,$07,$24,$06,$BC
	DC.B	$06,$5C,$06,$00,$05,$AA,$05,$58
	DC.B	$05,$0C,$04,$C4,$04,$7E,$04,$3E
	DC.B	$04,$02,$03,$C8,$03,$92,$03,$5E
	DC.B	$03,$2E,$03,$00,$02,$D5,$02,$AC
	DC.B	$02,$86,$02,$62,$02,$3F,$02,$1F
	DC.B	$02,$01,$01,$E4,$01,$C9,$01,$AF
	DC.B	$01,$97,$01,$80,$01,$6B,$01,$56
	DC.B	$01,$43,$01,$31,$01,$20,$01,$10
	DC.B	$01,$00,$00,$F2,$00,$E4,$00,$D8
	DC.B	$00,$CC,$00,$C0,$00,$B5,$00,$AB
	DC.B	$00,$A1,$00,$98,$00,$90,$00,$88
	DC.B	$00,$80,$00,$79,$00,$72,$00,$6C
	DC.B	$0E,$2C,$0D,$60,$0C,$A0,$0B,$E8
	DC.B	$0B,$40,$0A,$98,$0A,$00,$09,$70
	DC.B	$08,$E8,$08,$68,$07,$F0,$07,$80
	DC.B	$07,$16,$06,$B0,$06,$50,$05,$F4
	DC.B	$05,$A0,$05,$4C,$05,$00,$04,$B8
	DC.B	$04,$74,$04,$34,$03,$F8,$03,$C0
	DC.B	$03,$8B,$03,$58,$03,$28,$02,$FA
	DC.B	$02,$D0,$02,$A6,$02,$80,$02,$5C
	DC.B	$02,$3A,$02,$1A,$01,$FC,$01,$E0
	DC.B	$01,$C5,$01,$AC,$01,$94,$01,$7D
	DC.B	$01,$68,$01,$53,$01,$40,$01,$2E
	DC.B	$01,$1D,$01,$0D,$00,$FE,$00,$F0
	DC.B	$00,$E2,$00,$D6,$00,$CA,$00,$BE
	DC.B	$00,$B4,$00,$AA,$00,$A0,$00,$97
	DC.B	$00,$8F,$00,$87,$00,$7F,$00,$78
	DC.B	$0E,$10,$0D,$48,$0C,$88,$0B,$D4
	DC.B	$0B,$2C,$0A,$8C,$09,$F0,$09,$64
	DC.B	$08,$DC,$08,$5C,$07,$E4,$07,$74
	DC.B	$07,$08,$06,$A4,$06,$44,$05,$EA
	DC.B	$05,$96,$05,$46,$04,$F8,$04,$B2
	DC.B	$04,$6E,$04,$2E,$03,$F2,$03,$BA
	DC.B	$03,$84,$03,$52,$03,$22,$02,$F5
	DC.B	$02,$CB,$02,$A3,$02,$7C,$02,$59
	DC.B	$02,$37,$02,$17,$01,$F9,$01,$DD
	DC.B	$01,$C2,$01,$A9,$01,$91,$01,$7B
	DC.B	$01,$65,$01,$51,$01,$3E,$01,$2C
	DC.B	$01,$1C,$01,$0C,$00,$FD,$00,$EE
	DC.B	$00,$E1,$00,$D4,$00,$C8,$00,$BD
	DC.B	$00,$B3,$00,$A9,$00,$9F,$00,$96
	DC.B	$00,$8E,$00,$86,$00,$7E,$00,$77
	DC.B	$0D,$F8,$0D,$30,$0C,$70,$0B,$C0
	DC.B	$0B,$14,$0A,$78,$09,$E0,$09,$54
	DC.B	$08,$CC,$08,$50,$07,$D8,$07,$68
	DC.B	$06,$FC,$06,$98,$06,$38,$05,$E0
	DC.B	$05,$8A,$05,$3C,$04,$F0,$04,$AA
	DC.B	$04,$66,$04,$28,$03,$EC,$03,$B4
	DC.B	$03,$7E,$03,$4C,$03,$1C,$02,$F0
	DC.B	$02,$C5,$02,$9E,$02,$78,$02,$55
	DC.B	$02,$33,$02,$14,$01,$F6,$01,$DA
	DC.B	$01,$BF,$01,$A6,$01,$8E,$01,$78
	DC.B	$01,$63,$01,$4F,$01,$3C,$01,$2A
	DC.B	$01,$1A,$01,$0A,$00,$FB,$00,$ED
	DC.B	$00,$DF,$00,$D3,$00,$C7,$00,$BC
	DC.B	$00,$B1,$00,$A7,$00,$9E,$00,$95
	DC.B	$00,$8D,$00,$85,$00,$7D,$00,$76
	DC.B	$0D,$DC,$0D,$18,$0C,$5C,$0B,$A8
	DC.B	$0B,$00,$0A,$64,$09,$D0,$09,$40
	DC.B	$08,$BC,$08,$40,$07,$C8,$07,$58
	DC.B	$06,$EE,$06,$8C,$06,$2E,$05,$D4
	DC.B	$05,$80,$05,$32,$04,$E8,$04,$A0
	DC.B	$04,$5E,$04,$20,$03,$E4,$03,$AC
	DC.B	$03,$77,$03,$46,$03,$17,$02,$EA
	DC.B	$02,$C0,$02,$99,$02,$74,$02,$50
	DC.B	$02,$2F,$02,$10,$01,$F2,$01,$D6
	DC.B	$01,$BC,$01,$A3,$01,$8B,$01,$75
	DC.B	$01,$60,$01,$4C,$01,$3A,$01,$28
	DC.B	$01,$18,$01,$08,$00,$F9,$00,$EB
	DC.B	$00,$DE,$00,$D1,$00,$C6,$00,$BB
	DC.B	$00,$B0,$00,$A6,$00,$9D,$00,$94
	DC.B	$00,$8C,$00,$84,$00,$7D,$00,$76
	DC.B	$0D,$C4,$0D,$00,$0C,$44,$0B,$94
	DC.B	$0A,$EC,$0A,$50,$09,$BC,$09,$30
	DC.B	$08,$AC,$08,$30,$07,$B8,$07,$4C
	DC.B	$06,$E2,$06,$80,$06,$22,$05,$CA
	DC.B	$05,$76,$05,$28,$04,$DE,$04,$98
	DC.B	$04,$56,$04,$18,$03,$DC,$03,$A6
	DC.B	$03,$71,$03,$40,$03,$11,$02,$E5
	DC.B	$02,$BB,$02,$94,$02,$6F,$02,$4C
	DC.B	$02,$2B,$02,$0C,$01,$EE,$01,$D3
	DC.B	$01,$B9,$01,$A0,$01,$88,$01,$72
	DC.B	$01,$5E,$01,$4A,$01,$38,$01,$26
	DC.B	$01,$16,$01,$06,$00,$F7,$00,$E9
	DC.B	$00,$DC,$00,$D0,$00,$C4,$00,$B9
	DC.B	$00,$AF,$00,$A5,$00,$9C,$00,$93
	DC.B	$00,$8B,$00,$83,$00,$7B,$00,$75
	DC.B	$0D,$AC,$0C,$E8,$0C,$2C,$0B,$80
	DC.B	$0A,$D8,$0A,$3C,$09,$AC,$09,$20
	DC.B	$08,$9C,$08,$20,$07,$AC,$07,$3C
	DC.B	$06,$D6,$06,$74,$06,$16,$05,$C0
	DC.B	$05,$6C,$05,$1E,$04,$D6,$04,$90
	DC.B	$04,$4E,$04,$10,$03,$D6,$03,$9E
	DC.B	$03,$6B,$03,$3A,$03,$0B,$02,$E0
	DC.B	$02,$B6,$02,$8F,$02,$6B,$02,$48
	DC.B	$02,$27,$02,$08,$01,$EB,$01,$CF
	DC.B	$01,$B5,$01,$9D,$01,$86,$01,$70
	DC.B	$01,$5B,$01,$48,$01,$35,$01,$24
	DC.B	$01,$14,$01,$04,$00,$F5,$00,$E8
	DC.B	$00,$DB,$00,$CE,$00,$C3,$00,$B8
	DC.B	$00,$AE,$00,$A4,$00,$9B,$00,$92
	DC.B	$00,$8A,$00,$82,$00,$7B,$00,$74
	DC.B	$0D,$90,$0C,$D0,$0C,$18,$0B,$68
	DC.B	$0A,$C4,$0A,$2C,$09,$98,$09,$10
	DC.B	$08,$8C,$08,$10,$07,$9C,$07,$30
	DC.B	$06,$C8,$06,$68,$06,$0C,$05,$B4
	DC.B	$05,$62,$05,$16,$04,$CC,$04,$88
	DC.B	$04,$46,$04,$08,$03,$CE,$03,$98
	DC.B	$03,$64,$03,$34,$03,$06,$02,$DA
	DC.B	$02,$B1,$02,$8B,$02,$66,$02,$44
	DC.B	$02,$23,$02,$04,$01,$E7,$01,$CC
	DC.B	$01,$B2,$01,$9A,$01,$83,$01,$6D
	DC.B	$01,$59,$01,$45,$01,$33,$01,$22
	DC.B	$01,$12,$01,$02,$00,$F4,$00,$E6
	DC.B	$00,$D9,$00,$CD,$00,$C1,$00,$B7
	DC.B	$00,$AC,$00,$A3,$00,$9A,$00,$91
	DC.B	$00,$89,$00,$81,$00,$7A,$00,$73
	DC.B	$0D,$78,$0C,$B8,$0C,$00,$0B,$54
	DC.B	$0A,$B0,$0A,$18,$09,$88,$08,$FC
	DC.B	$08,$7C,$08,$04,$07,$90,$07,$24
	DC.B	$06,$BC,$06,$5C,$06,$00,$05,$AA
	DC.B	$05,$58,$05,$0C,$04,$C4,$04,$7E
	DC.B	$04,$3E,$04,$02,$03,$C8,$03,$92
	DC.B	$03,$5E,$03,$2E,$03,$00,$02,$D5
	DC.B	$02,$AC,$02,$86,$02,$62,$02,$3F
	DC.B	$02,$1F,$02,$01,$01,$E4,$01,$C9
	DC.B	$01,$AF,$01,$97,$01,$80,$01,$6B
	DC.B	$01,$56,$01,$43,$01,$31,$01,$20
	DC.B	$01,$10,$01,$00,$00,$F2,$00,$E4
	DC.B	$00,$D8,$00,$CB,$00,$C0,$00,$B5
	DC.B	$00,$AB,$00,$A1,$00,$98,$00,$90
	DC.B	$00,$88,$00,$80,$00,$79,$00,$72


;========================================================================
	even
AON_vibrato_sine
; ripped from ptreplay2.3
	dc.b	0,24,49,74,97,120,141,161
	dc.b	180,197,212,224,235,244,250,253
	dc.b	255,253,250,244,235,224,212,197
	dc.b	180,161,141,120,97,74,49,24	; ->32 bytes
	even
AON_vibrato_rampdown
	dc.b	255,248,240,232,224,216,208,200,192,184,176,168,160,152,144
	dc.b	136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8
		even
AON_vibrato_square	dcb.b	32,255

;========================================================================
;ŻŻŻŻŻŻŻ
aon_speed		rs.b	1	0=off , 1-255
aon_framecnt		rs.b	1	0-aon_speed
aon_patcnt		rs	1	-1= break pat
aon_looppoint		rs.b	1
aon_loopcnt		rs.b	1
aon_loopflag		rs.b	1
aon_pos			rs.b	1	actual pos while replaying 
aon_statdata		rs.l	1	address of static data in module
aon_arpdata		rs.l	1	Pointer on arpeggio lists
aon_posdata		rs.l	1	address of position tab
aon_pattdata		rs.l	1	Pointer on patterns	(1st)
aon_patdelaycnt		rs	1
aon_wavestarts		rs.b	256	adrs of waveforms (0-63)
aon_instrstarts		rs.b	256	adrs of instruments (1-61)
aon_modulestart		rs.l	1	Start of module
aon_replayMode		rs.b	1	0=VBI,1=CIA A&B
aon_tempo		rs.b	1	tempo 32-255 (bei cia-use speed=6)
aon_noiseavoid		rs.b	1
aon_oversize		rs.b	1+1
aon_datasize		rs	1

			even
AON_DATA		dcb.b	aon_datasize

;ŻŻŻŻŻŻŻŻŻŻŻ
			rsreset
aon_chflag		rs.b	1	<>0 = new wave! (1=sample,2=synth)
aon_lastnote		rs.b	1	well,the last note I guess ?!!!!
aon_waveform		rs.l	1	wavestart
aon_wavelen		rs	1	wavelen/2 (dma!)
aon_oldwavelen		rs	1	to avoid noise when using rep <512bytes
aon_repeatstrt		rs.l	1	repeatwavestart
aon_replen		rs	1	repeat-lenght/2 (dma!)
aon_instrptr		rs.l	1	POINTER oN ACT. INSTRDATA
aon_volume		rs.b	1	Act.Volume (written into register)

aon_stepfxcnt		rs.b	1	notecut/delay/retrig

aon_chMODE		rs.b	1	0=sample8,1=synth8
aon_vibratospd		rs.b	1
aon_vibratoampl		rs.b	1
aon_vibratopos		rs.b	1
aon_vibratotrigdelay	rs	1	-1=already triggered

aon_period		rs	1	Act.periode (written into register)
				;	(including slide up/down etc..)
aon_perslide		rs	1	Added to periode (e.g. 4 portamento)

aon_arpeggiooff		rs	1
aon_arpeggiotab		rs.b	16	7 ĝffsets (+ endmark) in per.tab
aon_arpeggiospd		rs.b	1	Frame-Change-Speed
aon_arpeggiocnt		rs.b	1	Countdown

aon_synthWAVEactPTR	rs.l	1	actptr	(absolute waveform-adressen!!)
aon_synthWAVEendPTR	rs.l	1	endwaveptr
aon_synthWAVErepPTR	rs.l	1	anfang des repeat-teils
aon_synthWAVErependPTR	rs.l	1	ende des repeat teils
aon_synthWAVEaddbytes	rs.l	1	addiere/subtrahiere xxxx bytes
aon_synthWAVEcnt	rs.b	1	framecnt
aon_synthWAVEspd	rs.b	1	wechsel der waveform jeden n-ten frame
aon_synthWAVErepctrl	rs.b	1	0=normal,1=back,2=pingpong
aon_synthWAVECONT	rs.b	1	0=normal,1=wave durchlaufen lassen
aon_synthADD		rs.b	1
aon_synthSUB		rs.b	1
aon_synthEND		rs.b	1
aon_synthENV		rs.b	1	0=NO AR envelope
aon_synthVOL		rs.b	1	akt. adsr byte (*volume/64=abs vol!!)
aon_vibON		rs.b	1	1=Do Vibrato!
aon_synthwaveSTOP	rs.b	1	1=dont continue wave until U10
aon_vibDONE		rs.b	1	1=Vibrato done
aon_vibCONT		rs.b	1+1	1=Dauervibrato(wavetable),0=Only '4'etc


aon_fxCOM		rs.b	1	Effect-Command
aon_fxDAT		rs.b	1	Effect-Parameter

aon_oldsampoff		rs.l	1	used for '9' effect
aon_glissspd		rs	1	speed for '3' effect

aon_slideflag		rs.b	1	<>0=Sliding active
aon_actwavenr		rs.b	1

aon_trackvol		rs	1	64=max,0=track mute

aon_chdatasize		rs	1


			even
AON_CHANNELS		ds.b	aon_chdatasize*8

;========================================================================
playersize		=*-aon_init


;; program	:	8-Channelmix-Test (7bit)
;; author	:	Bastian Spiegel (twice of lego)
;; date		:	- 23.Jan.1995
;; equ		:	68020+ is recommended!

	rem
-mixrate 1-64khz
-7-Bit Sampleauflösung
-Freie Lautstärkeeinstellung für JEDEN Kanal
-Repeat für jeden Kanal
	erem


loop			=1	; if loop is on,the routine needs about 4
				; rastlines more for every channel

;--------------------------------------------------------------------

			section	mixer,code

mix_INIT2
			MOVEM.L	D0-A6,-(SP)
			LEA	$DFF000,A5
			BRA.B	mix_INIT22

mix_init

			movem.l	d0-a6,-(sp)

			lea	$dff000,a5

			lea	mix_multab64(pc),a0
			moveq	#0,d6	; 0-$40
			moveq	#0,d7	; 0-255
mix_in_mtab		moveq	#0,d1
			move.b	d7,d1
			ext	d1
			muls	d6,d1
			asr.l	#6+1,d1	; /2 teilen!!!!!
			move.b	d1,(a0)+
			addq.b	#1,d7
			bne.s	mix_in_mtab
			addq.b	#1,d6
			cmp.b	#$41,d6
			bne.s	mix_in_mtab

mix_INIT22
			move	#$f,$96(a5)

			move.l	#64000,d7
.rastwait1		dbf	d7,.rastwait1

			move.l	mix_buff1(pc),$a0(a5)
			move.l	mix_buff2(pc),$b0(a5)
			move.l	mix_buff3(pc),$c0(a5)
			move.l	mix_buff3(pc),$d0(a5)
			move	#mix_buflen/2,d0
			move	d0,$a4(a5)
			move	d0,$b4(a5)
			move	d0,$c4(a5)
			move	d0,$d4(a5)
			move	mix_mixrate(pc),d0
			move	d0,$a6(a5)
			move	d0,$b6(a5)
			move	d0,$c6(a5)
			move	d0,$d6(a5)
			moveq	#64,d0
			move	d0,$a8(a5)
			move	d0,$b8(a5)
			move	d0,$c8(a5)
			move	d0,$d8(a5)

			move.l	#64000,d7
.rastwait2		dbf	d7,.rastwait2

			move	#$ff,$dff09e	; no modulation
			move	#$800f,$96(a5)

			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
; IN:	a0=bypass-ch
;	d7=anzahl kanäle (bis zu 8 !)
mix_startsamples
			moveq	#0,d6
.loop
			moveq	#0,d4
			move	6(a0),d4	; period
			moveq	#0,d5
			move.b	9(a0),d5	; volume
			cmp	#$40,d5
			ble.b	.volok
			moveq	#$40,d5
.volok			move.l	(a0),d0		; samplestart
			moveq	#0,d1
			move	4(a0),d1	; sampledmalen
			add.l	d1,d1		; *2 für bytes
			move.l	10(a0),d2	; repeatstart
			moveq	#0,d3
			move	14(a0),d3	; repeatdmalen
			add.l	d3,d3		; *2 für bytes
			bsr	mix_startsample
.nonewsample		lea	$10(a0),a0
			addq	#1,d6
			dbf	d7,.loop
			rts
;--------------------------------------------------------------------
; IN:	d0=wavestart
;	d1=wavelen
;	d2=repoff
;	d3=replen
;	d4=period
;	d5=volume
;	d6=channel (0-7)
mix_startsample
			movem.l	d0-a6,-(sp)
			lea	mix_data,a1
			mulu	#mix_datasize,d6
			lea	(a1,d6),a1

			btst	#1,8(a0)
			beq.b	.repeat

			clr	mix_lastfloat(a1)
			move.b	#1,mix_status(a1)
			move.l	d0,mix_wavestart(a1)
			clr.l	mix_waveoff(a1)
			move.l	d1,mix_wavelen(a1)
.repeat			btst	#0,8(a0)
			beq.b	.norepeat

			move.l	d2,mix_repstrt(a1)
			move.l	d3,mix_replen(a1)

.norepeat		lsl.l	#8,d5
			add.l	#mix_multab64,d5
			move.l	d5,mix_volumeptr(a1)

			tst	d4
			beq.b	.noper
			move	d4,mix_period(a1)
			moveq	#0,d0
			move	mix_mixrate(pc),d0
			swap	d0
			divu.l	d4,d0
			tst	d0
			bne.b	.ok
			move	#$ffff,mix_period.float(a1)
			swap	d0
			tst	d0
			beq.b	.set
			subq	#1,d0
			bra.b	.set
.ok			move	d0,mix_period.float(a1)
			swap	d0
.set			move	d0,mix_norm.add(a1)
.noper			clr.b	8(a0)
			movem.l	(sp)+,d0-a6
			rts
;--------------------------------------------------------------------
; durch audioirqs aufrufen
mix_play
			btst	#7,$dff01f
			bne.b	mix_play0
			btst	#0,$dff01e
			bne.w	mix_play1
			btst	#1,$dff01e
			bne.w	mix_play2
			btst	#2,$dff01e
			bne.w	mix_play3
			nop
			nop
			nop
			rte
mix_play0		movem.l	d0-a6,-(sp)
			move	#$4000,$dff09a
			lea	mix_buff1(pc),a0
			move.l	(a0),d0
			move.l	16(a0),(a0)	
			move.l	d0,16(a0)	
			move.l	d0,$dff0a0
			lea	mix_data+mix_datasize*0,a5
			lea	mix_data+mix_datasize*1,a6
			move.l	16(a0),a4
			bsr	mix_channels
			move	#$c000,$dff09a
			movem.l	(sp)+,d0-a6
			move	#$80,$dff09c
			nop
			nop
			nop
			rte
mix_play1		movem.l	d0-a6,-(sp)
			move	#$4000,$dff09a
			lea	mix_buff2(pc),a0
			move.l	(a0),d0
			move.l	16(a0),(a0)	
			move.l	d0,16(a0)	
			move.l	d0,$dff0b0
			lea	mix_data+mix_datasize*2,a5
			lea	mix_data+mix_datasize*3,a6
			move.l	16(a0),a4
			bsr	mix_channels
			move	#$c000,$dff09a
			movem.l	(sp)+,d0-a6
			move	#$100,$dff09c
			nop
			nop
			nop
			rte
mix_play2		movem.l	d0-a6,-(sp)
			move	#$4000,$dff09a
			lea	mix_buff3(pc),a0
			move.l	(a0),d0
			move.l	16(a0),(a0)	
			move.l	d0,16(a0)	
			move.l	d0,$dff0c0
			lea	mix_data+mix_datasize*4,a5
			lea	mix_data+mix_datasize*5,a6
			move.l	16(a0),a4
			bsr	mix_channels
			move	#$c000,$dff09a
			movem.l	(sp)+,d0-a6
			move	#$200,$dff09c
			nop
			nop
			nop
			rte
mix_play3		movem.l	d0-a6,-(sp)
			move	#$4000,$dff09a
			lea	mix_buff4(pc),a0
			move.l	(a0),d0
			move.l	16(a0),(a0)	
			move.l	d0,16(a0)	
			move.l	d0,$dff0d0
			lea	mix_data+mix_datasize*6,a5
			lea	mix_data+mix_datasize*7,a6
			move.l	16(a0),a4
			bsr	mix_channels
			move	#$c000,$dff09a
			movem.l	(sp)+,d0-a6
			move	#$400,$dff09c
			ifne	rasttime
			move	#$aab,$dff180
			endif
			nop
			nop
			nop
			rte
;--------------------------------------------------------------------
; a5=ptr on chdata1
; a6=ptr on chdata2
; a4=ptr on destbuffer (chipmem!)
mix_channels:
;			bsr	mix_mix_mix
;
;			rts
;
;			move.l	a4,a3
;			moveq	#128/4-1,d7
;.interpol		rept	4
;			move.b	(a4),d1
;			move.b	1(a4),d2	; interpol-dreck
;			sub.b	d1,d2
;			asr.b	#2,d2
;			add.b	d2,d1
;			move.b	d1,(a4)+
;			endr
;			dbf	d7,.interpol
;			rts
;
;			rept	3
;			move.b	(a4),d1
;			move.b	1(a4),d2
;			sub.b	d1,d2
;			asr.b	#1,d2
;			add.b	d2,d1
;			move.b	d1,(a4)+
;			endr
;			move.b	(a4),d1
;			move.b	(a3),d2
;			sub.b	d1,d2
;			asr.b	#1,d2
;			add.b	d2,d1
;			move.b	d1,(a4)
;			rts


mix_mix_mix:		movem.l	a4-a6,-(sp)

			move.l	mix_wavestart(a5),a0	; wave1 startadr
			move.l	mix_wavestart(a6),a1	; wave2 startadr
			move.l	mix_waveoff(a5),d0	; wave1 mixoff
			move.l	mix_waveoff(a6),d1	; wave2 mixoff
			move.l	mix_volumeptr(a5),a2	; wave1 volumeptr
			move.l	mix_volumeptr(a6),a3	; wave2 volumeptr
			moveq	#0,d2
			move	mix_period.float(a5),d2
			swap	d2			; wave1 addx-add
			moveq	#0,d3			; wave1 addx-cnt
			move	mix_lastfloat(a5),d3
			swap	d3
			moveq	#0,d4
			move	mix_norm.add(a5),d4	; wave1 integer-add
			moveq	#0,d5
			move	mix_period.float(a6),d5	; wave2 addx-add
			moveq	#0,d6			; wave2 addx-cnt
			move	mix_lastfloat(a6),d6
			moveq	#0,d7
			move	mix_norm.add(a6),d7	; wave2 integer-add
			
			move	#mix_buflen/2,mix_cnt(a5)

			tst.b	mix_status(a5)
			beq	mix_RIGHT
			tst.b	mix_status(a6)
			beq	mix_LEFT

mix_BOTH

.loop


			rept	2

 move.b	(a0,d0.l),d2	; Ein Byte aus Wave 1 holen		14

 add	d5,d6		; Add float WAVE2			4

 move.b	(a1,d1.l),d3	; Ein Byte aus Wave 2 holen		14

 addx.l	d7,d1		; Floating-Point WAVE2			8

 move.b	(a2,d2.W),d2	; *Volume & div 2			14

 add.b	(a3,d3.W),d2	; *Volume & div 2			14

 swap	d2		; HI-Word holen				4
 swap	d3		; HI-Word holen				4
 add	d2,d3		; addx-trick				4
 swap	d2		; LO-Word holen				4
 swap	d3		; LO-Word holen				4

 move.b	d2,(a4)+	; Write to buffer			8

 addx.l	d4,d0		; Floating-Point WAVE1			8

			endr


			cmp.l	mix_wavelen(a5),d0
			bge.b	.resetwave1
.set1
			cmp.l	mix_wavelen(a6),d1
			bge.b	.resetwave2
.set2
			sub	#1,mix_cnt(a5)
			cmp	#0,mix_cnt(a5)
			bne.b	.loop

			swap	d3
			move	d3,mix_lastfloat(a5)
			move	d6,mix_lastfloat(a6)

			move.l	d0,mix_waveoff(a5)
			move.l	d1,mix_waveoff(a6)
			movem.l	(sp)+,a4-a6
			rts
.resetwave1		move.l	mix_repstrt(a5),a0
			move.l	a0,mix_wavestart(a5)
			moveq	#0,d0
			move.l	mix_replen(a5),mix_wavelen(a5)
			cmp.l	#2,mix_wavelen(a5)
			ble	mix_RIGHT.leftOFF
			bra.b	.set1
.resetwave2		move.l	mix_repstrt(a6),a1
			move.l	a1,mix_wavestart(a6)
			moveq	#0,d1
			move.l	mix_replen(a6),mix_wavelen(a6)
			cmp.l	#2,mix_wavelen(a6)
			ble.b	mix_LEFT.rightOFF
			bra.b	.set2
.d4			dc.l	0
.d7			dc.l	0
;----------------------------------------
mix_NOTHING.leftoff	clr.b	mix_status(a5)
			bra.b	mix_nothing
mix_NOTHING.rightoff	clr.b	mix_status(a6)
mix_NOTHING

.loop			clr	(a4)+
			subq	#1,mix_cnt(a5)
			tst	mix_cnt(a5)
			bne.b	.loop
			

			movem.l	(sp)+,a4-a6
			rts
;----------------------------------------
mix_LEFT.rightoff	clr.b	mix_status(a6)
mix_LEFT
			cmp.l	#2,mix_wavelen(a5)
			ble.b	mix_NOTHING

.loop

			rept	2
 move.b	(a0,d0.l),d2	; Ein Byte aus Wave 1 holen		14
 swap	d2
 swap	d3
 add	d2,d3		; Mix-Bytes & Add float WAVE1		6
 swap	d2
 swap	d3
 move.b	(a2,d2),(a4)+	; *Volume & div 2			14
 addx.l	d4,d0		; Floating-Point WAVE1			8
			endr



			cmp.l	mix_wavelen(a5),d0
			bge.b	.resetwave1
.set1
			subq	#1,mix_cnt(a5)
			tst	mix_cnt(a5)
			bne.b	.loop

			swap	d3
			move	d3,mix_lastfloat(a5)

			move.l	d0,mix_waveoff(a5)
			movem.l	(sp)+,a4-a6
			rts
.resetwave1
			move.l	mix_repstrt(a5),a0
			move.l	a0,mix_wavestart(a5)
			moveq	#0,d0
			move.l	mix_replen(a5),mix_wavelen(a5)
			cmp.l	#2,mix_wavelen(a5)
			ble	mix_NOTHING.leftoff
			bra.b	.set1
;----------------------------------------
mix_RIGHT.leftoff	clr.b	mix_status(a5)
mix_RIGHT
			tst.b	mix_status(a6)
			beq	mix_NOTHING

			cmp.l	#0,a1
			beq	mix_NOTHING
			cmp.l	#2,mix_wavelen(a6)
			ble.w	mix_NOTHING

			moveq	#0,d3
.loop
			rept	2
 move.b	(a1,d1.l),d3	; Ein Byte aus Wave 2 holen		14
 add	d5,d6		; Add float WAVE2			4
 move.b	(a3,d3),(a4)+	; *Volume & div 2			14
 addx.l	d7,d1		; Floating-Point WAVE2			8
			endr

			cmp.l	mix_wavelen(a6),d1
			bge.b	.resetwave2
.set2
			subq	#1,mix_cnt(a5)
			tst	mix_cnt(a5)
			bne.b	.loop

			move	d6,mix_lastfloat(a6)
			move.l	d1,mix_waveoff(a6)
			movem.l	(sp)+,a4-a6
			rts
.resetwave2		move.l	mix_repstrt(a6),a1
			move.l	a1,mix_wavestart(a6)
			moveq	#0,d1
			move.l	mix_replen(a6),mix_wavelen(a6)
			cmp.l	#2,mix_wavelen(a6)
			ble	mix_NOTHING.rightoff
			bra.b	.set2
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
mix_buff1		dc.l	0	; diese Buffer werden gerade berechnet
mix_buff2		dc.l	0
mix_buff3		dc.l	0
mix_buff4		dc.l	0
mix_buff1hear		dc.l	0	; diese Buffer werden gerade angehört
mix_buff2hear		dc.l	0
mix_buff3hear		dc.l	0
mix_buff4hear		dc.l	0

mix_multab64		ds.b	256*65
mix_mixrate		ds	1	; Period

mix_DATA
			rsreset
mix_wavestart		rs.l	1
mix_waveoff		rs.l	1
mix_wavelen		rs.l	1
mix_repstrt		rs.l	1
mix_replen		rs.l	1
mix_period		rs	1
mix_period.float	rs	1	umgerechnet auf mixrate/addx trick-add
;					float-cnt
;					$ffff= period  125
;					$8000= ...     250
;					$4000= ...     500
;					$2000= ...    1000
mix_norm.add		rs	1
mix_cnt			rs	1
mix_lastfloat		rs	1
mix_status		rs.b	1+1	0=Ch off , 1=Ch plays
mix_volumeptr		rs.l	1
mix_datasize		rs	1
			ds.b	mix_datasize*8


mix_bypass		ds.b	$10*8
;--------------------------------------------------------------------


;--------------------------------------------------------------------


;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################
;########################################################################

			section	player,code

****************************************************************************
; ________________________________________________________________________
; 									
;                      -<>-O art.of.noise.replay v1.6 O-<>-		
; 			   coded by twice/lego! '93/4		
; ________________________________________________________________________

;========================================================================
AON8_PLAY		
			movem.l	d0-d7/a0-a6,-(sp)
			lea	aon_data,a6

			addq.b	#1,aon_framecnt(a6)
			move.b	aon_speed(a6),d0
			beq.b	aon8_playcurrent_nonewpos2
			cmp.b	aon_framecnt(a6),d0
			bhi	aon8_playcurrent_nonewpos2
			clr.b	aon_framecnt(a6)

			bsr	aon8_playnewstep
aon8_playcurrent_nonewpos2
			bsr	aon8_playfx

			movem.l	(sp)+,d0-d7/a0-a6
			rts

;---------------------- Effekte & Samplestarts ----------------------
AON8_PLAYFX		
			moveq	#0,d7
			move.b	aon_pos(a6),d7
			move.l	aon_posdata(a6),a1	; get start of posdat
			moveq	#0,d0
			move.b	(a1,d7),d0		; d7=act. pos + choff

		CMP.B	#REPLAYST_ALL,REPLAYSTATUS+MAIN_DATA
		BNE.S	.DONTSETPATNR
		MOVE.B	D0,ACTEDITPATTERN+MAIN_DATA+1
.DONTSETPATNR

			lea	aon_dofx,a1
			lea	aon_channels,a4	; do effect command
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)
			lea	aon_chdatasize(a4),a4
			jsr	(a1)

			moveq	#0,d1			; Make channel-mask
			moveq	#0,d7
			lea	aon8_startinstr.1(pc),a1


			lea	aon_channels,a4	; do effect command
			lea	mix_bypass,a5
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)

			lea	-8*$10(a5),a5

			lea	-(8*aon_chdatasize)(a4),a4

			moveq	#0,d7

			lea	aon8_startinstr.2(pc),a1
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)
			jsr	(a1)

			moveq	#0,d0
			move.b	ch_ENABLE+MAIN_DATA,d1
			moveq	#0,d2
			lea	mix_bypass,a0
.loop			btst	d0,d1
			bne.b	.sty
			move.b	d2,$9(a0)
.sty			lea	$10(a0),a0
			addq.b	#1,d0
			cmp.b	#8,d0
			bne.b	.loop
			rts


;========================================================================
;---------------------- Neuen Step auslesen -------------------------
aon8_playnewstep
			TST.B	REPLAYSTATUS+MAIN_DATA
			BEQ	AON8_PLAYCURRENT_NONEWPOSX

			cmp.b	#$ff,aon_patcnt(a6)
			beq	aon8_breakpat

; read new step
aon8_getstep
			tst.b	aon_patdelaycnt+1(a6)
			bmi.s	aon8_nopatdelay
			beq.s	aon8_nopatdelay
			subq.b	#1,aon_patdelaycnt+1(a6)
			bra.w	aon8_playcurrent_nonewposX
aon8_nopatdelay		move.b	#-1,aon_patdelaycnt+1(a6)
	
			lea	aon_channels,a4
			lea	aon_multab120,a5	; needed for periodtab

			moveq	#0,d0
			MOVE	ACTEDITPATTERN+MAIN_DATA,D0

;move.b	aon_actpat(a6),d0
			move.l	aon_pattdata(a6),a0	; get start of patdat

			moveq	#11,d1
			lsl.l	d1,d0			; patnr*1024=patoff
			lea	(a0,d0.l),a0		; add to start of data
			move	aon_patcnt(a6),d1

		MOVE.B	D1,DISPPATCNT+MAIN_DATA

			lsl	#3,d1			; *8
			lea	(a0,d1.l),a0		; add pattcounter

; a0=pointer on actual step
			jsr	aon_getdachannel	; get first channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get second channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get third channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get fourth channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get fifth channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get sixth channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get seventh channel
			lea	aon_chdatasize(a4),a4
			addq.l	#4,a0
			jsr	aon_getdachannel	; get eighth channel

			tst.b	aon_loopflag(a6)
			beq.s	aon8_nolooping
			clr.b	aon_loopflag(a6)
			move.b	aon_looppoint(a6),aon_patcnt+1(a6)
			bra.b	aon8_playcurrent_nonewposX
aon8_nolooping		addq.b	#4,aon_patcnt+1(a6)
			bne.b	aon8_playcurrent_nonewposX  ; End of pattern??
aon8_breakpat		
		MOVE.B	#%1111,PATTDSPREQ+MAIN_DATA

			clr.b	aon_patdelaycnt+1(a6)
			clr	aon_looppoint(a6)
		CMP.B	#REPLAYST_PAT,REPLAYSTATUS+MAIN_DATA
		BEQ.B	AON8_PLAYCURRENT2
			addq.b	#1,aon_pos(a6)	; pos=pos+1
			move.l	aon_statdata(a6),a3
			move.b	aon.songinfo_maxpos(a3),d0	; get maxpos
			cmp.b	aon_pos(a6),d0	; End of song ??
			bhi	aon8_playcurrent2
			move.b	aon.songinfo_respos(a3),aon_pos(a6) ; Get restart pos!
aon8_playcurrent2	tst.b	aon_patcnt(a6)
			beq.b	aon8_playcurrent_nonewposX
			clr.b	aon_patcnt(a6)

			moveq	#0,d7
			move.b	aon_pos(a6),d7
			move.l	aon_posdata(a6),a1	; get start of posdat
			moveq	#0,d0
			move.b	(a1,d7),d0		; d7=act. pos + choff
		CMP.B	#REPLAYST_ALL,REPLAYSTATUS+MAIN_DATA
		BNE.S	AON8_DONTSETPATNR2
		MOVE.B	D0,ACTEDITPATTERN+MAIN_DATA+1
AON8_DONTSETPATNR2
			bra	aon8_getstep
aon8_playcurrent_nonewposX
			rts
;========================================================================
AON8_STARTINSTR.1
			move	aon_fxcom(a4),d0
			and	#$0ff0,d0
			cmp	#$0ed0,d0
			beq.b	aon8_strtinsonlyrep.1

			move	aon_period(a4),d0	; baseper+arpeggio
			add	aon_perslide(a4),d0	; portamento value
.checkhiper
			cmp	#103,d0
			bhs.b	.noperalert
			moveq	#103,d0
.noperalert		move	d0,$6(a5)


			move.b	aon_chflag(a4),$8(a5)

			move.l	aon_waveform(a4),$0(a5)

			move	aon_wavelen(a4),$4(a5)

aon8_strtinsonlyrep.1
			addq.b	#1,d7
aon8_strtinsonlyrep.2	lea	aon_chdatasize(a4),a4
			lea	$10(a5),a5
			rts
AON8_STARTINSTR.2
			move	aon_fxcom(a4),d0
			and	#$0ff0,d0
			cmp	#$0ed0,d0
			beq.b	aon8_strtinsonlyrep.1

			moveq	#0,d0
			move.b	aon_volume(a4),d0
			moveq	#0,d2
			move.b	aon_synthVOL(a4),d2
			lsr.b	#1,d2
			mulu	d2,d0
			lsr	#6,d0
			mulu	aon_trackvol(a4),d0
			lsr	#6,d0
			move.b	d0,$9(a5)
.sample2

			move.l	aon_repeatstrt(a4),10(a5)
			move	aon_replen(a4),14(a5)
			clr.b	aon_chflag(a4)
			bra.b	aon8_strtinsonlyrep.1
;--------------------------------------------------------------------
