; Octamed Echo by Invect

HIDEDEBUG
DEBUGOFF
; SHOWDEBUG

; Init
SETACTIVESCREEN PATTERN
ACTIVATE
UPDATEPATTERN
setstring NumRows ROWS
setstring NumTracks TRACKS

QUESTION Echo Setting?
COMPARE Dialog 1
mtoff
ISLESS SkipScript
setstring EchoSetting Dialog
setstring SettingNumRows ROWS
SUBTRACT EchoSetting SettingNumRows

FINDCOLUMN Note NoteX

FINDVOLUME VolumeX

; Main Loop
vbkey {HOME}{HOME}{HOME}{HOME}
setstring TickNum 0
LABEL BeginEcho

GOTOCOLUMN NoteX

; Read Note Value
setstring NoteValue ActiveNote
CONVERTTOKEYS NoteValue NoteValueKeys

; If note = -1 then skip.
COMPARE NoteValue -1
ISEQUAL NextNote
; (with no UPS)

; Check if Echo Note is Empty
;
setstring count 0
LABEL EchoSettingCheckNote
ADD 1 count
key {DOWN}
COMPARE EchoSetting count
ISGREATER EchoSettingCheckNote
;
setstring EchoNoteValue ActiveNote
COMPARE EchoNoteValue -1
ISGREATER NextNote2
; (with 2 UPS)

SETSTEP 0
; Key in the Note
vbkey NoteValueKeys
;key {UP}
SETSTEP 1

; Return to Original Note Position
setstring count 0
LABEL EchoSettingReturnToPosition
ADD 1 count
key {UP}
COMPARE EchoSetting count
ISGREATER EchoSettingReturnToPosition

; Move to Volume Position
GOTOCOLUMN VolumeX

; Read Volume Value
GETPARAM
setstring VolumeValue ParamValue
COMPARE VolumeValue -1
ISGREATER SkipSet128
setstring VolumeValue 128
LABEL SkipSet128

; Half Volume Value and Convert to Hex
DIVIDE 2 VolumeValue
HEX VolumeValueHEX VolumeValue

; Move to Echo Volume Position
setstring count 0
LABEL EchoSettingMoveDown
ADD 1 count
key {DOWN}
COMPARE EchoSetting count
ISGREATER EchoSettingMoveDown

;info BREAK

; Enter Echo Volume Value
ENTERPARAM VolumeValueHEX

LABEL NextNote2

setstring count 0
LABEL EchoSettingMoveUp
ADD 1 count
key {UP}
COMPARE EchoSetting count
ISGREATER EchoSettingMoveUp

LABEL NextNote

; Paste Loop
key {DOWN}

ADD 1 TickNum
COMPARE SettingNumRows TickNum
ISGREATER BeginEcho

LABEL SkipScript
mton
ENDSCRIPT