[dialects]
dialect key  envelope
channel    bare status bytes
classic    F0 52 00 {dev} .. F7
file       F0 52 00 {dev} .. F7
four       F0 52 00 {dev} .. F7
loader     F0 52 00 {dev} .. F7
plus       F0 52 00 {dev} .. F7
universal  F0 7E .. F7

[owners]
owner key    what
every-image  the MIDI standard's universal identity
loader       the pedal's update-mode loader, honouring what its release's updater sends

[image-sets]
set key      images:list@images.image
classic      g1on-1.21 ms-50g-3.10 ms-60b-2.10 ms-70cdr-2.10 ms-100bt-1.30
classic-ms   ms-50g-3.10 ms-60b-2.10 ms-70cdr-2.10
classic-usb  g1on-1.21 ms-50g-3.10 ms-60b-2.10 ms-70cdr-2.10
four-n       four-2.00 n-2.20
plus         ms-50g-plus-1.40 ms-70cdr-plus-1.20 ms-200d-plus-1.30

[stores]
store key  every:name  what
buffer     no          the edit buffer, here loaded whole (a select, a reselect); a handler that edits it changes `buffer-edit`
effects    no          the effect list, loaded from the files at boot or on a flush
errorlog   yes         the flash error log; the firmware writes it only on its own failure paths
files      no          the effect store
flash      no          the flash
mode       no          normal, editor, tuner, file session, loader
pairing    yes         the Bluetooth pairing file (PAIR.DAT); an MS-100BT rewrites it when its Bluetooth controller reports a paired device, from whatever pumps Bluetooth events, and every frame it sends does, so no MS-100BT row repeats it
selected   no          the record of which patch is selected, kept across power
settings   no          the pedal's settings
stored     no          one stored patch: stored(addr) the addressed slot, stored(cur) the selected one
unread     no          whatever else the handler reaches that nothing names; taken as changing
unsaved    yes         settings the pedal's own controls changed and it has not stored (a tuner's calibration); it stores them when the screen they changed on closes, as leaving that screen on the pedal does

[arguments]
argument key  store:name@stores.store  what
addr          stored     the slot the frame addresses
auto-save     settings   the Auto Save setting
cur           stored     the slot selected when the frame arrives
handle        files      the file an open on this connection answered the frame's handle for
name          files      the file the frame names

[edits]
edit key     store:name@stores.store  also
buffer-edit  buffer                   stored(cur) unless autosave-off

[states]
state key      known
autosave-off   only from a frame the pedal sent
buffer-stored  only from frames the pedal sent: the selected slot, its stored patch and the edit buffer, each received since a send last may have changed it, with the buffer holding that stored patch
guard          never: a condition in the handler not yet read

[needs]
need key        meaning
buffer-read     the exact buffer was read here; the frame changes only qualified controls
chain-read      the exact buffer was read here; the frame changes only the chain's slots
editor          the session is in editor mode
effects-stored  every effect the patch holds is one the stored patches, read here, already hold
file-session    a file session is open
flash-range     the address and length fit the image's longest whole flash reply and the handler's address reach
flash-readable  the verified loader can read flash, or this is its known boot-version probe
loader          the session is the loader
read-first      the addressed slot was read on this connection; this exact frame is sent once
slot            the address is the first slot, one the geometry read on this connection names, or a ZDL index below its model's patch count; a select's bank and program, a slot the pedal's own grouping holds
swap-read       the edit buffer was read here since anything last changed it, and the cell holds an effect other than the replacement
tempo-read      the exact buffer was read here; the frame changes only the patch tempo

[templates]
name key      template:template@templates.name
classic-name      {position choice 00 01 02 03 04 05 06 07 08 09} {character u7} 00
classic-patch     28 {patch septets msb rest}
classic-settings  2a {settings septets msb rest}
file-block    {len u7le 5 = byte_len block} {block septets msb len} {sum u7le 5 = jamcrc32 block}
file-entry    25 {_ bytes 8} {name text 12 ascii nul} {_ bytes 3} {size u7le 5} {_ rest}
file-status   60 03 {status u7le 5 i32}
flash-data    60 04 30 {_ bytes 2} {len u7le 2 = byte_len data} {data septets msb len} {sum u7le 5 = jamcrc32 data}
panel-ack     64 20 01 {target u7} {param u7} {value u7le 5 u32}
panel-name-ack  64 20 01 5f {position u7} {character u7le 5 u32}
patch-record  {len u7le 2 = byte_len record} {record septets msb len} {sum u7le 5 = jamcrc32 record}
status        00 {code u7}
stored-patch  45 {a u7le 2} {b u7le 2} {c u7le 2} =patch-record

[keys]
kind key     key key     cells                                               many  meaning
command      admits      name                                                no    the Rust predicate the arguments must also satisfy
command      echoes      list                                                no    the holes a reply repeats from its request, which say which request a reply answers
command      handled-by  list@images.image|image-sets.set|owners.owner text..  yes   the images or image sets whose handler receives it, and what it changes
command      needs       list@needs.need                                     no    what must hold first
command      qualified   list@images.image|image-sets.set                      no    the images whose cited handler an execution case ran on these bytes; on any other image a frame stands on its builder's own evidence
command      reply       template@templates.name                             yes   a form of the reply
command      send        template@templates.name                             yes   the frame sent
command      speaks      list@dialects.dialect                               no    the dialects
command      uncited     list@images.image|image-sets.set text..  yes   images of a dialect it is cited in whose handler is not cited, and why
event        reply       template@templates.name                             yes   a form of the frame
event        reports     name@states.state                                   no    the state the event reports: its `value` hole reads zero when the state holds, and a frame of its form that does not read says it does not
event        sent-by     list@images.image|image-sets.set                      no    the images it was traced being sent from; a report from any other is not believed
event        speaks      list@dialects.dialect                               no    the dialects

[command identity]
speaks      universal
send        7f 06 01
reply       {ch u7} 06 02 52 {code bytes 4} {version text 4 ascii nul}
handled-by  every-image  -

[command select]
speaks      channel
needs       slot
send        b0 00 00 b0 20 {bank u7} c0 {program u7}
qualified   plus g2-four-1.00
handled-by  four-n g5n-3.00 plus  buffer  selected  unread unless autosave-off
handled-by  g2-four-1.00  buffer  selected  stored(cur) unless autosave-off  unread unless autosave-off
handled-by  classic  buffer  selected  stored(cur) unless buffer-stored

[command classic-tuner]
speaks      channel
send        b0 4a {on choice 00 41}
handled-by  classic  mode

[command editor-on]
speaks      classic four plus
send        50
reply       =status
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  mode

[command editor-off]
speaks      classic four plus
send        51
reply       =status
handled-by  classic  mode  buffer  selected
handled-by  plus four-n g2-four-1.00 g5n-3.00  mode

[command info]
speaks      classic plus
send        07
reply       06 {patches u7le 2} {record u7le 2}
handled-by  classic plus g2-four-1.00  -

[command read-stored]
speaks      four plus
needs       slot
send        46 {a u7le 2} {b u7le 2} {c u7le 2}
reply       =stored-patch
echoes      a b c
handled-by  four-n g5n-3.00 g2-four-1.00 plus  -

[command write-stored]
speaks      four plus
needs       read-first
send        =stored-patch
reply       =status
qualified   four-n g5n-3.00
handled-by  plus four-n g2-four-1.00 g5n-3.00  stored(addr)

[command read-current]
speaks      four plus
send        64 13
reply       64 12 01 =patch-record
qualified   four-n g2-four-1.00 g5n-3.00
handled-by  plus four-n g2-four-1.00 g5n-3.00  -

[command effect-edit]
speaks      four
needs       editor
admits      edit-parameter
send        64 03 00 {cell choice 00 01 02 03 04 05 06 07 08} {param u7} {value u7le 5 u32}
reply       64 03 01 {cell choice 00 01 02 03 04 05 06 07 08} {param u7} {value u7le 5 u32}
echoes      cell param
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  buffer-edit

[command effect-swap]
speaks      four
needs       editor
send        64 03 00 {cell choice 00 01 02 03 04 05 06 07 08} 01 {effect u7le 5 u32}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  buffer-edit

[command name-edit]
speaks      four
needs       editor
admits      name-character
send        64 03 00 09 {position choice 00 01 02 03 04 05 06 07 08 09} {character u7le 5 u32}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  buffer-edit

[command panel-edit]
speaks      plus
needs       editor
admits      edit-parameter
send        64 20 00 {target choice 00 01 02 03 04 05} {param u7} {value u7le 5 u32}
reply       =panel-ack
echoes      target param
handled-by  plus g2-four-1.00  buffer-edit  errorlog

[command panel-name]
speaks      plus
needs       editor
admits      name-character
send        64 20 00 5f {position choice 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f} {character u7le 5 u32}
reply       =panel-name-ack
echoes      position
handled-by  plus g2-four-1.00  buffer-edit  errorlog

[command panel-swap]
speaks      plus
needs       editor swap-read
admits      swap-effect
send        64 20 00 {target choice 00 01 02 03 04 05} 01 {effect u7le 5 u32}
reply       =panel-ack
echoes      target
handled-by  ms-50g-plus-1.40 ms-70cdr-plus-1.20 g2-four-1.00  buffer-edit  errorlog
uncited     ms-200d-plus-1.30  its swap's effect load is not compared with the others'

[command auto-save-off]
speaks      plus
needs       editor
send        64 20 00 64 0f 00 00 00 00 00
reply       =panel-ack
qualified   g2-four-1.00
handled-by  plus g2-four-1.00  settings(auto-save)

[command tuner]
speaks      four plus
send        64 {on choice 0b 0c}
reply       64 {on choice 0b 0c}
qualified   four-n g5n-3.00
handled-by  plus four-n g2-four-1.00 g5n-3.00  mode

[command classic-read-stored]
speaks      classic
needs       slot
send        09 00 00 {index u7}
reply       08 {_ bytes 2} {index u7} {_ bytes 2} {patch septets family rest}
echoes      index
handled-by  classic  -

[command classic-read-current]
speaks      classic
needs       editor
send        29
reply       =classic-patch
handled-by  classic  -

[command classic-global-data]
speaks      classic
needs       editor
send        2b
reply       =classic-settings
qualified   classic
handled-by  classic  -

[command classic-write-current]
speaks      classic
needs       effects-stored
send        =classic-patch
reply       =status
handled-by  classic-ms  mode  buffer-edit  unsaved
handled-by  g1on-1.21  mode  buffer-edit  unsaved  errorlog
handled-by  ms-100bt-1.30  mode  buffer-edit

[command classic-bank-program]
speaks      classic
needs       editor
send        33
reply       b0 00 {msb u7} b0 20 {lsb u7} c0 {program u7}
handled-by  classic  -

[command classic-flash-read]
speaks      classic four
needs       flash-range
send        60 30 {addr u7le 5} {len u7le 5}
reply       =flash-data
qualified   classic-ms ms-100bt-1.30 four-n g5n-3.00
handled-by  classic-ms ms-100bt-1.30 four-n g5n-3.00  -
uncited     g1on-1.21  its running handler takes flash-read

[command pc-mode-on]
speaks      four
send        52
qualified   four-n g5n-3.00
handled-by  four-2.00  mode  buffer-edit  selected  settings  unread
handled-by  n-2.20 g5n-3.00  mode  buffer  selected  unread

[command pc-mode-off]
speaks      four
send        53
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  mode  buffer  selected  unread

[command effect-support]
speaks      four
send        55
reply       54 {format u7le 5} {features u7le 10} {levels bits7 64 8} {level u7}
handled-by  four-n g5n-3.00  -

[command patch-geometry]
speaks      four
send        44
reply       43 {patches u7le 2} {record u7le 2} {divisor-a u7le 2} {divisor-b u7le 2} {tail rest}
handled-by  four-n g5n-3.00  -

[command patch-support]
speaks      four
send        48
reply       47 {format u7le 5} {features u7le 10} {level u7}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  -

[command display]
speaks      four
send        64 02 {first choice 00 01 02 03 04 05 06 07 08} {last choice 00 01 02 03 04 05 06 07 08} {values-only u7}
reply       64 01 {body rest}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  -

[command global-data]
speaks      four
send        64 0a
reply       64 09 {tempo u7le 2} {between bits7 5 7} {auto-save choice 00 01}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  -

[command product-info]
speaks      four
send        64 11
reply       64 10 {lead bits7 3 7} {cells u7} {state u7} {tail rest}
qualified   four-n g5n-3.00
handled-by  four-n g5n-3.00  -

[command classic-name-on]
speaks      classic
admits      name-character
send        31 05 =classic-name
qualified   g1on-1.21
handled-by  g1on-1.21  buffer-edit
uncited     classic-ms ms-100bt-1.30  its handler takes classic-name-ms

[command classic-name-ms]
speaks      classic
admits      name-character
send        31 04 =classic-name
qualified   classic-ms ms-100bt-1.30
handled-by  classic-ms ms-100bt-1.30  buffer-edit
uncited     g1on-1.21  its handler takes classic-name-on

[command classic-switch-on]
speaks      classic
send        31 {slot choice 00 01 02 03 04} 00 {enabled choice 00 01} 00
qualified   g1on-1.21
handled-by  g1on-1.21  buffer-edit
uncited     classic-ms ms-100bt-1.30  its handler takes classic-switch-ms

[command classic-switch-ms]
speaks      classic
send        31 {slot choice 00 01 02} 00 {enabled choice 00 01} 00
qualified   classic-ms ms-100bt-1.30
handled-by  classic-ms ms-100bt-1.30  buffer-edit
uncited     g1on-1.21  its handler takes classic-switch-on

[command classic-knob-on]
speaks      classic
send        31 {slot choice 00 01 02 03 04} {parameter choice 02 03 04 05 06 07 08 09 0a} {value u7le 2}
qualified   g1on-1.21
handled-by  g1on-1.21  buffer-edit
uncited     classic-ms ms-100bt-1.30  its handler takes classic-knob-ms

[command classic-knob-ms]
speaks      classic
send        31 {slot choice 00 01 02} {parameter choice 02 03 04 05 06 07 08 09 0a} {value u7le 2}
qualified   classic-ms ms-100bt-1.30
handled-by  classic-ms ms-100bt-1.30  buffer-edit
uncited     g1on-1.21  its handler takes classic-knob-on

[command classic-level-on]
speaks      classic
send        31 06 00 {level u7le 2}
qualified   g1on-1.21
handled-by  g1on-1.21  buffer-edit
handled-by  classic-ms ms-100bt-1.30  -

[command classic-control-buffer]
speaks      classic
needs       buffer-read effects-stored
send        =classic-patch
qualified   classic
handled-by  classic  buffer-edit

[command classic-chain-buffer]
speaks      classic
needs       chain-read effects-stored
send        =classic-patch
qualified   classic
handled-by  classic  buffer-edit

[command classic-tempo-buffer]
speaks      classic
needs       tempo-read effects-stored
send        =classic-patch
qualified   classic-ms ms-100bt-1.30
handled-by  classic-ms ms-100bt-1.30  buffer-edit
uncited     g1on-1.21  the G1 family's buffer holds no tempo

[command write-current]
speaks      four plus
needs       editor
send        28 {record septets msb rest}
reply       =status
qualified   four-n g5n-3.00
handled-by  plus g2-four-1.00  buffer-edit  errorlog
handled-by  four-n g5n-3.00  buffer-edit

[command file-poll]
speaks      file
needs       file-session
send        60 05 00
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  -

[command file-info]
speaks      file
send        60 11
reply       60 04 11 {_ rest}
handled-by  plus four-n g2-four-1.00 g5n-3.00  -

[command file-descriptor]
speaks      file
send        60 02
reply       60 04 02 {_ rest}
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  -

[command file-stat-end]
speaks      file
needs       file-session
send        60 27
reply       =file-status
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  -

[command stat]
speaks      file
needs       file-session
send        60 25 00 00 {name filename nul}
reply       60 04 =file-entry
handled-by  plus four-n g2-four-1.00 g5n-3.00  -

[command classic-stat]
speaks      file
needs       file-session
send        60 25 00 00 {name filename 13}
reply       60 04 =file-entry
handled-by  classic  -

[command dir-next]
speaks      file
needs       file-session
send        60 26 00 00 {pattern filename nul}
reply       60 04 =file-entry
handled-by  plus four-n g2-four-1.00 g5n-3.00  -

[command classic-dir-next]
speaks      file
needs       file-session
send        60 26
reply       60 04 =file-entry
handled-by  classic  -

[command open]
speaks      file
needs       file-session
send        60 20 02 00*9 {name filename nul}
reply       60 04 20 {_ bytes 4} {handle u7le 5 u32} {_ rest}
handled-by  plus four-n g2-four-1.00 g5n-3.00  -

[command classic-open]
speaks      file
needs       file-session
send        60 20 02 00*9 {name filename 12}
reply       60 04 20 {_ bytes 4} {handle u7le 5 u32} {_ rest}
handled-by  classic  -

[command open-write]
speaks      file
needs       file-session
send        60 20 01 00*9 {name filename nul}
reply       60 04 20 {_ bytes 4} {handle u7le 5 u32} {_ rest}
qualified   plus four-n g2-four-1.00 g5n-3.00
handled-by  plus four-n g2-four-1.00 g5n-3.00  files(name)

[command classic-open-write]
speaks      file
needs       file-session
send        60 20 01 00*9 {name filename 12}
reply       60 04 20 {_ bytes 4} {handle u7le 5 u32} {_ rest}
qualified   classic
handled-by  classic  files(name)

[command write]
speaks      file
needs       file-session
send        60 23 {handle u7le 5} =file-block
reply       60 04 23 {seq u7le 2} 04 00 {written u7le 5} 00*5
qualified   classic plus four-n g2-four-1.00 g5n-3.00
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  files(handle)

[command read]
speaks      file
needs       file-session
send        60 22 {handle u7le 5} {size u7le 5}
reply       60 04 22 00 {_ rest}
reply       60 04 22 01 {_ u7} {len u7le 2 = byte_len block} {block septets msb len} {sum u7le 5 = jamcrc32 block}
handled-by  classic-ms plus four-n ms-100bt-1.30 g2-four-1.00 g5n-3.00  -
uncited     g1on-1.21  its poll sends no block after a read's header

[command close]
speaks      file
needs       file-session
send        60 21 {handle u7le 5}
reply       =file-status
qualified   classic plus four-n g2-four-1.00 g5n-3.00
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  -

[command delete]
speaks      file
needs       file-session
send        60 24 {name filename 13}
reply       =file-status
qualified   classic plus four-n g2-four-1.00 g5n-3.00
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  files(name)

[command flush]
speaks      file
send        60 09
reply       60 05 00
qualified   classic plus four-n g2-four-1.00 g5n-3.00
handled-by  plus four-n g2-four-1.00 g5n-3.00  effects  buffer
handled-by  classic-usb  effects  files
handled-by  ms-100bt-1.30  effects  files  buffer-edit

[command storage-usage]
speaks      file
send        60 29
reply       60 04 29 {seq u7le 2} 08 00 {maximum u7le 5} {available u7le 5} {_ rest}
handled-by  classic plus four-n g2-four-1.00 g5n-3.00  -

[command file-mode-enter]
speaks      file
send        60 00 {mode choice 01 02}
handled-by  ms-50g-3.10 ms-100bt-1.30  mode
handled-by  g1on-1.21 ms-60b-2.10 ms-70cdr-2.10  -

[command file-mode-leave]
speaks      file
send        60 01 {mode choice 01 02}
handled-by  ms-50g-3.10 ms-100bt-1.30  mode
handled-by  g1on-1.21 ms-60b-2.10 ms-70cdr-2.10  -

[command lock]
speaks      file
send        60 06
handled-by  classic-usb  -
handled-by  ms-100bt-1.30  mode  buffer  unsaved

[command unlock]
speaks      file
send        60 07
handled-by  classic-usb  -
handled-by  ms-100bt-1.30  mode

[command file-length]
speaks      file
needs       file-session
send        60 28 {name filename 12}
reply       60 04 28 {seq u7le 2} 04 00 {length u7le 5} 00*5

[command hello]
speaks      loader plus
send        01
reply       =status
qualified   plus
handled-by  loader  -
handled-by  plus  flash
uncited     g2-four-1.00  its running image's hello is unread

[command loader-pc-mode]
speaks      loader plus
send        52
reply       =status
qualified   plus
handled-by  loader  -
handled-by  plus  mode  buffer  selected  unread unless autosave-off
uncited     g2-four-1.00  its running image's handler is unread

[command loader-version]
speaks      loader plus
send        64 44
reply       64 45 {version text 4 ascii nul} 00
qualified   plus
handled-by  loader plus  -
uncited     g2-four-1.00  its running image's handler is unread

[command loader-mask]
speaks      loader plus
send        12 {mask u7le 2}
reply       =status
qualified   plus
handled-by  loader plus  -
uncited     g2-four-1.00  its running image's handler is unread

[command write-setup]
speaks      loader
needs       loader
send        0a {base u7le 5} {len u7le 5}
reply       =status
handled-by  loader  flash

[command data-block]
speaks      loader
needs       loader
send        02 {addr u7le 5} {len u7le 2 = byte_len data} {data septets msb len} {sum u7le 5 = jamcrc32 data}
reply       =status
handled-by  loader  flash

[command finalize]
speaks      loader
needs       loader
send        04
reply       =status
handled-by  loader  flash

[command flash-read]
speaks      loader classic
needs       flash-readable
send        60 30 {addr u7le 5} {len u7le 5}
reply       =flash-data
handled-by  loader g1on-1.21  -
uncited     classic-ms ms-100bt-1.30  their running handler takes classic-flash-read

[event parameter-edit]
speaks      classic
reply       31 {body rest}

[event panel-edit]
speaks      four
reply       64 03 00 {target u7} {param u7} {value u7le 5 u32}

[event four-window]
speaks      four
sent-by     four-2.00
reply       64 03 01 0a 01 {cell u7le 5 u32}

[event four-auto-save]
speaks      four
reports     autosave-off
sent-by     four-n g5n-3.00
reply       64 03 00 0a 0f {value u7le 5}

[event plus-auto-save]
speaks      plus
reports     autosave-off
sent-by     plus g2-four-1.00
reply       64 20 {flag choice 00 01} 64 0f {value u7le 5}

[event tuner]
speaks      four plus
reply       64 {on choice 0b 0c}

[event tuner-data]
speaks      channel
reply       b0 {cc choice 62 63} {value u7}

[event bank]
speaks      channel
reply       b0 20 {bank u7}

[event program]
speaks      channel
reply       c0 {program u7}

[event current-dump]
speaks      plus
reply       64 12 00 =patch-record

[event status]
speaks      classic four plus file loader
reply       =status

[event file-status]
speaks      file
reply       60 03 {code u7le 5 i32}

[event session-status]
speaks      file
reply       60 05 {status u7}
