# The Simpsons (MAME set 'simpsons') - Z80 sound program symbols (072-e03.6g)
#
# Addresses and names only: no game data lives in this file. Format: ADDRESS KIND NAME [...] (see
# tools/core/z80/analysis.py and tools/core/sound_coverage.py). Addresses are the Z80's, 0000-7FFF.
#   func     a function entry (one nothing calls is decompiled too: code the entry points never reach)
#   loop     the main loop's top, a function entry: where the program waits for the board (runtime/src/sound_cpu.c
#            runs the main loop from there while the board's time is ahead)
#   file     PATH: the functions from ADDRESS up to the next file line go to src/sound/PATH.c (the comment of a
#            file's first line is its description)
#   comment FUNCTION TEXT: what the C says above the function; register RN NAME: a register the whole program keeps
#   (game_profile's SOUND_CONTEXT), a global variable in C; unread FUNCTION RN: the function reads RN before setting
#   it only on a path the program never takes (it is no parameter)
#
# The driver (read from the listing, build/sound/listing.s): the 053248 writes a command and its argument to the
# K053260's ports (1FC6-1FC7, which the Z80 reads at FC00-FC01) and raises the Z80's IRQ by reading 1FC4; the Z80
# takes it only in the main loop's four NOPs with interrupts on (sound_command, 0038): F0-FF the self test's answers
# (FC02-FC03) and the reset, 3F and 7F with the argument, the rest a sound and the argument's count of the ones after
# it (start_sound): 00 stops everything, 01-38 an FM effect, 40-7E a PCM effect, 80-AF a song, C0-EF a song after a
# fade. The main loop waits for the YM2151's timer B (some 2 ms), then runs 12 channel records of 50h bytes from F003:
# 8 for the YM2151's channels (chip_channel, +40, 0-7) and 4 for the K053260's voices (8-B), each through the handler
# it keeps at +43 (run_channel, JP (HL) at 0C21) after the music's tick (music_tick); +41 is the sound a record plays
# (bit 7: music), +42 its priority (struct channel below). A PCM voice is keyed on after a HALT that waits for the
# K053260's NMI (pcm_key_on).

# ======== the driver ========
0000  file  main  # the reset and its self test, the commands from the 053248, the main loop
0000  func  sound_reset
comment sound_reset The reset: interrupt mode 1, the stack at the top of the RAM, no answer to the 053248 yet; the RAM test (55, then AA, written and read back in every byte: bit 0 of self_test_failures when one fails), then check_rom.
0038  func  sound_command
comment sound_command The interrupt the 053248 raises: its command and argument from the K053260's ports (unless held_command holds one, which nothing sets). F0 answers 30, F1 to F7 hand back self_test_failures and the bytes of the three sums, FE adds the two sample ROMs up again, FF resets; while the RAM test has failed nothing else runs (self_test_failed); F8 counts in command_f8_count, FD fades the music out. 3F starts the PCM effect of effect_handlers_2 the argument picks on a K053260 record, 7F hands the argument to the record playing effect 7F; any other command goes to start_sound, and so do as many commands after it as the argument says.
0066  func  nmi_return
comment nmi_return The NMI (the K053260's, armed by a write to the NMI's port): returns at once; it only ends pcm_key_on's wait.
# Odd: the commands after the first one (008D-0096 "inc b; push af; push bc; call $0099; pop bc; pop af; inc a; djnz")
# skip sound_command's own tests, so a 3E with an argument of 1 would hand 3F to start_sound, which plays the unused
# group's effect 3F (01E5) rather than a PCM effect of the third group; no command the game sends does that
0099  func  start_sound
comment start_sound A command 00 to EF. 00: stop_all_channels. 01-38: an FM effect, on the YM2151 record already playing it, else on the one of the lowest priority if the effect's (effect_priorities) is not below it: its sound and priority, its handler from effect_handlers, the loudest volume, no LFO, keyed off, released at the fastest, no noise. 3C-3F: the unused group on FM_7 (no such command is sent). 40-7E: a PCM effect the same way on the K053260's records (effect_priorities_40, effect_handlers_40). 80-AF: start_song. C0-EF: the song 40 below, at once when no record plays music, else once the music has faded out (fade, fade_next_song).
00B2  func  stop_all_channels
comment stop_all_channels Command 00: stops every record but those of priority C0 or more (stop_channel_unless_kept), then the music (stop_music).
# Odd: stop_music leaves 0 in A (015A "xor a"), and the main loop compares the fade's attenuation in A after it
# (0BC7-0BCE "cp $7F; call z,$0106; cp $30"): at the fade's end the test for 30 sees 0, so stopping the music never
# also starts fade_next_song (the two cannot meet anyway: 30 comes before 7F)
0106  func  stop_music
comment stop_music The music off on all 12 records (stop_music_channel) and the fade cleared: at the fade's end, and after command 00.
016B  func  stop_channel_unless_kept
comment stop_channel_unless_kept stop_channel, unless the record's priority is C0 or more (PCM effects 40 to 42).
034E  func  start_song
comment start_song A song, commands 80-AF: its bank (song_banks_by_sound) into the bank register, each record's track from the song's header (start_music_channel, FM_0 to PCM_3), the fade cleared.
03CF  func  start_music_channel
comment start_music_channel The record's track from the song header's next word (start_music_track); hands back the place of the word after it.
095C  func  check_rom
comment check_rom The ROM test: adds up the program's 32 KB and the banks 2 to 7 into program_rom_sum; a sum other than 072E sets bit 1 of self_test_failures; then sound_main. The game's sound board puts its own in its place (the game has no ROM to add up: it takes the time good chips take).
09FB  func  sound_main
comment sound_main Clears the RAM, sets the K053260 up (its voices' registers cleared, every key off), gives each record its chip_channel and the K053260's records their voice's registers and bits; then, unless the RAM test failed, stops every channel and starts the YM2151's timer B: the main loop follows.
0B28  func  self_test_failed
comment self_test_failed The RAM test failed: forever a delay and a window with interrupts on, where the 053248's commands come in (and end here again).
0B3D  loop  sound_main_loop
comment sound_main_loop A pass of the main loop: waits for the YM2151's timer B and starts it again; runs the 8 YM2151 records (run_channel) and the 4 K053260 ones (run_pcm_channel); the fade between songs (every fade_period passes fade_attenuation one more: at 30 fade_next_song starts, at 7F the music stops; a fade other than 1 only counts fade_hold down); then a window of four instructions with interrupts on, where the 053248's command comes in, sound_command again if command_held says so (nothing sets it), and pass_count.
0BF3  func  run_pcm_channel
comment run_pcm_channel A K053260 record's pass: on one pass in 16 (its own, by its chip_channel), while its voice is not keyed, the decay one decay_step quieter (up to 7F) and update_volume; then run_channel.
0C18  func  run_channel
comment run_channel A record's pass: its music (music_tick), then its handler.
0C22  file  chips  # the records' handlers and the chips: the YM2151's registers, patches, volumes, pitches, keys, LFO and pan; the K053260's voices
0C22  func  stop_channel
comment stop_channel Stops what the record plays: key off, the fastest release, its sound and priority 0, its handler channel_idle.
0C33  func  set_channel_handler
comment set_channel_handler The routine that runs the record from its next pass on.
0C39  func  channel_idle
comment channel_idle A free record's handler: nothing.
0C3A  func  write_fm_channel_register
comment write_fm_channel_register Writes a register of the record's YM2151 channel: the register given plus its chip_channel.
0C3F  func  write_fm_register
comment write_fm_register Writes a register of the YM2151, each byte once the chip's busy flag is clear.
0C56  func  restart_frame_timer
comment restart_frame_timer Starts the YM2151's timer B again (register 12 at F9: some 2 ms) and clears its flag: the main loop's pace.
0C68  func  load_patch
comment load_patch Loads a patch into the record's channel: on the YM2151 (keyed off and released at the fastest first) its 25 bytes into the operators' registers, the connection, the total levels and the release rates kept in the record, then update_volume; on the K053260, pcm_load_patch.
# each chip routine's K053260 half, past its "ld a,(ix+$40); sub $08; jp nc" (or "cp $08"): a function of its own, so
# that what it reads in the record reads as a K053260 voice's (scoped channel pcm)
0D2E  func  pcm_load_patch
comment pcm_load_patch A K053260 voice's patch: the voice keyed off, its sample's registers (samples) into the voice's, the voice's KADPCM bit as the sample's kadpcm says, the patch's level and decay_step into the record, then update_volume.
0D72  func  set_volume
comment set_volume The record's volume (an attenuation: 0 the loudest, 7F silent), then update_volume.
0D75  func  update_volume
comment update_volume The record's volume to its chip: on the YM2151 the four operators' total levels, the volume added to the carriers' (carrier_masks, by the algorithm in connection); on the K053260, pcm_update_volume.
0DC0  func  pcm_update_volume
comment pcm_update_volume A K053260 voice's volume register: 7F less the volume, the patch's level and the decay (each sum at most 7F), and 0 below 4.
0DA7  func  write_operator_level
comment write_operator_level One operator's total level: the volume added (at most 7F) when the carriers' mask says it is a carrier; hands the mask back shifted for the next operator.
0DE8  func  set_pitch
comment set_pitch The record's pitch to its chip: on the YM2151 the key fraction and the key code (note_codes; its high byte's octaves wrap past 8); on the K053260, pcm_set_pitch.
0E70  func  pcm_set_pitch
comment pcm_set_pitch A K053260 voice's pitch registers.
0E7B  func  key_on
comment key_on Keys the record's channel on: on the YM2151 its four operators; on the K053260, pcm_key_on.
0E8B  func  pcm_key_on
comment pcm_key_on Keys a K053260 voice on, unless pcm_keyed says it is: its key bit off, then the NMI armed and a wait for it (the chip takes the new sample), the key bit on, pcm_keyed set, the decay back to 0 and update_volume.
0EBE  func  key_off
comment key_off Keys the record's channel off: on the YM2151 its four operators; on the K053260, pcm_key_off.
0ECC  func  pcm_key_off
comment pcm_key_off Clears a K053260 voice's bit of pcm_keyed, if set: its sample plays on to its end.
0EDD  func  fast_release
comment fast_release On the YM2151 the four operators' release at its fastest; on the K053260, pcm_fast_release.
0F01  func  pcm_fast_release
comment pcm_fast_release A K053260 voice's decay at 7F: silent at the next volume.
0F06  func  restore_release
comment restore_release Unused: puts a YM2151 channel's release rates back as its patch had them (after fast_release).
0F2C  func  set_lfo_pm_depth
comment set_lfo_pm_depth The YM2151's LFO phase modulation depth (register 19 with bit 7).
0F34  func  set_lfo_am_depth
comment set_lfo_am_depth The YM2151's LFO amplitude modulation depth (register 19 without bit 7).
0F3C  func  set_channel_pm_sensitivity
comment set_channel_pm_sensitivity A YM2151 channel's phase modulation sensitivity (register 38's bits 4-6), kept in lfo_sensitivity; nothing on the K053260.
0F58  func  set_channel_am_sensitivity
comment set_channel_am_sensitivity A YM2151 channel's amplitude modulation sensitivity (register 38's bits 0-1), kept in lfo_sensitivity; nothing on the K053260.
0F70  func  set_lfo_frequency
comment set_lfo_frequency The YM2151's LFO frequency (register 18).
0F76  func  set_lfo_waveform
comment set_lfo_waveform The YM2151's LFO waveform (register 1B).
0F7C  func  set_pan
comment set_pan The record's pan: a YM2151 channel's outputs (1 left, 2 right, 3 both: register 20's bits 6-7, kept in connection), or a K053260 voice's pan (1 left to 7 right) in its pan register, kept in pcm_pans_1 or pcm_pans_2.
0FE5  func  noise_off
comment noise_off On FM_7, the YM2151's noise off (register 0F).
0FF2  func  noise_on
comment noise_on Unused: on FM_7, the YM2151's noise on at the frequency given (register 0F).
1000  func  pcm_voice_playing
comment pcm_voice_playing Whether the record's K053260 voice still plays (its bit of the chip's status); a YM2151 record says it does.
100D  func  next_pointer_byte
comment next_pointer_byte Unused: the byte at byte_pointer, which moves on by one within its page (sound_main points it at the program's bytes).

# the self test's results, which the commands F1-F7 hand to the 053248: failures (bit 0 the RAM, 0958; bit 1 the program
# ROM, 09F8; bits 2 and 3 the sample ROMs, 0783 and 0831), the program ROM's sum (09E6-09ED, 072E on good chips) and the
# two sample ROMs' sums (0771-0778 and 081F-0826)
register a_alt self_test_failures
register bc_alt program_rom_sum
register de_alt sample_rom_1_sum
register hl_alt sample_rom_2_sum
# the lowest priority channel's record goes to HL from the first channel on (019C, 02B0, 0251, 0310: any priority is at
# most FF), so HL is never read as it came in (01A6, 02BA, 025B, 031A)
unread sound_command hl
unread start_sound hl

# ======== the sound effects ========
# the handler a sound effect's channel runs, by the effect's number, 01-38 (01BB "SLA C; LD B,0; LD HL,$1014; ADD
# HL,BC", into the channel's word at 43; kref --sound-rom-reads: 01C3 reads 1016-1085), and the effect's priority
# (01AC "LD HL,$1085; ADD HL,DE", compared with the channel's at 42: 01B0 reads 1086-10BD); entry 0 is no effect
1014  jumps  effect_handlers  57  first=1
1086  data   effect_priorities  u8[56]
# the same for the effects 40-7F (02BD-02DD, 032F-033D: the table at 3570 and the priorities at 3630, from entry 40
# on: 02D7 reads 35F0-366D, 0337 366E-366F, 02C4 3670-36AE)
3570  jumps  effect_handlers_40  128  first=64
3670  data   effect_priorities_40  u8[64]
# and a third group (0270-027E: the table at 2E01, the priorities at 2E79 from 0261; 0278 reads 2E01-2E78, 0265
# 2E79-2EB4: 60 of each)
2E01  jumps  effect_handlers_2  60
2E79  data   effect_priorities_2  u8[60]
# start_sound takes the commands 3C-3E at 01E5 (sound_command takes 3F first, 0083): a handler at 26FC plus twice the
# command and a priority at 2740 plus the command (01F0, 0205), which are unused_effect_group and
# unused_effect_priorities below; the table from 26FC is the code there (26FC's words 0C22 0CFC 1F28...) up to them, a
# table of no entries here. No command the game sends reaches it (kref --sound-rom-reads: nothing reads them)
26FC  jumps  unused_effect_handlers  0

# ======== the music ========
# a sequence's commands E0-FF (4659 "LD L,C; LD H,0; ADD HL,HL; LD DE,$44A6; ADD HL,DE", then 4665 "JP (HL)"): the table
# the code indexes starts at 44A6, its entries from E0 on (kref --sound-rom-reads: 4661 reads 4666-46A4)
44A6  jumps  music_commands  256  first=224
4665  via    music_commands
# an instrument's 16 routines, by the low 4 bits of a note (45FD "AND $0F; RLCA", 4604 "LD L,(IX+$28)", 460B "LD
# A,(HL)", then 460F "CALL $0C33", which stores it at 43 in the channel): the table of the channel's instrument
# (46BB "LD DE,$4E4E", its field 12 times 32: 46C9 "LD (IX+$28),L"); instrument 0's would be the code before 4E6E, and
# each one's routine 0 is none (0000). kref --sound-rom-reads: 460B reads 4E70-4FCC (instruments 1-11)
4E4E  jumps  instrument_routines  192  first=16  slot=43
# two more instruments' routines before them, at 496C and 498C (16 each, routine 0 none): a channel's pointer at 28 is
# 496C or 498C by a way the walk does not see (4E4E plus 32 times its field 12 never is); kref --sound-rom-reads: 460B
# reads 4970, and the routines it leads to run (4A18...)
496C  jumps  instrument_routines_low  32  slot=43
# a song, by the command 80-AF (034E "CP $B0"): its header's address (0362 "LD DE,$5CB2", "ADD HL,HL": entries 80 on)
# and the bank it is in (0355 "LD DE,$5D92", into FE00); kref --sound-rom-reads: 0366 reads 5DB2-5E11, 0359
# 5E12-5E41 (tools/sound_data_walk.py walks the songs)
5DB2  data   song_headers  u16[48]
5E12  data   song_banks  u8[48]

# ======== the YM2151 ========
# which of the 4 operators an algorithm's carriers are, a bit each (0D80 "AND $07; ...; LD HL,$0DB8; ADD HL,BC",
# shifted out by 0DA7 "SLA L": the operators whose volume the channel's adds to)
0DB8  data   carrier_masks  u8[8]
# the YM2151's key code by note (0E06 "LD HL,$0E10; ADD HL,BC", into register 28): 8 octaves of 12
0E10  data   note_codes  u8[96]
# a YM2151 patch: load_patch 0C76-0D23 reads it a byte at a time ("inc hl; ld c,(hl)") and writes each to its register
# of the record's channel (the "ld b,$NN" before write_fm_channel_register), operators M1, C1, M2, C2; the total
# levels it keeps in the record instead (update_volume writes them with the volume), the release rates as well
struct fm_patch 19 rom
# 0C76 "ld c,(hl); ld (ix+$46),c; ld b,$20": register 20, the outputs, the feedback and the algorithm
field fm_patch 00 connection u8
# 0C80-0CA5 (registers 40; total level into +47; 80, A0, C0; E0 into +4B)
field fm_patch 01 m1_detune_multiple u8
field fm_patch 02 m1_total_level u8
field fm_patch 03 m1_attack u8
field fm_patch 04 m1_decay_1 u8
field fm_patch 05 m1_decay_2 u8
field fm_patch 06 m1_release u8
# 0CAB-0CD0 (50; +48; 90, B0, D0; F0 into +4C)
field fm_patch 07 c1_detune_multiple u8
field fm_patch 08 c1_total_level u8
field fm_patch 09 c1_attack u8
field fm_patch 0A c1_decay_1 u8
field fm_patch 0B c1_decay_2 u8
field fm_patch 0C c1_release u8
# 0CD6-0CFB (48; +49; 88, A8, C8; E8 into +4D)
field fm_patch 0D m2_detune_multiple u8
field fm_patch 0E m2_total_level u8
field fm_patch 0F m2_attack u8
field fm_patch 10 m2_decay_1 u8
field fm_patch 11 m2_decay_2 u8
field fm_patch 12 m2_release u8
# 0D01-0D26 (58; +4A; 98, B8, D8; F8 into +4E)
field fm_patch 13 c2_detune_multiple u8
field fm_patch 14 c2_total_level u8
field fm_patch 15 c2_attack u8
field fm_patch 16 c2_decay_1 u8
field fm_patch 17 c2_decay_2 u8
field fm_patch 18 c2_release u8
# a K053260 patch (pcm_load_patch 0D3B "ld l,(hl)": its sample, of samples; then two bytes into the record: 0D66 "ld
# (ix+$46),a", 0D6C "ld (ix+$47),a", the level and the decay's step)
struct pcm_patch 03 rom
field pcm_patch 00 sample u8
field pcm_patch 01 level u8
field pcm_patch 02 decay_step u8
# a sample of the K053260 (pcm_load_patch 0D3B-0D4E "LD L,(HL); ...; ADD HL,HL x3; LD DE,$28E9; ADD HL,DE; LD BC,7;
# LDIR" into its voice's registers: pitch, length, start), and bit 0 of the 8th (0D56 "bit 0,(hl)"): the voice's KADPCM
# bit of FC2A (MAME's k053260.cpp, register 2A: bits 0-3 the voices' loop, 4-7 their KADPCM); it is 1 for the samples
# assets/sounds/samples.txt calls kadpcm, and no sample loops (no code sets a loop bit)
struct sample 08 rom
field sample 00 registers u8[7]
field sample 07 kadpcm u8
# the music's instruments (46E0-4704, by the command that sets one): an FM channel's patch (46E2 "LD HL,$5E42"), a
# PCM channel's (46FA "LD HL,$63F4") and its transposition (46ED "LD HL,$642C"), into the channel's 19 and 26
5E42  data   music_fm_patches  u16[54]  fm_patch
63F4  data   music_pcm_patches  u16[28]  pcm_patch
642C  data   music_pcm_transpositions  s16[28]
28E9  data   samples  sample[163]
# the pitches by note and octave (42FE "LD HL,$448B" for an FM channel, 4309 "LD HL,$4533" for a PCM one; then the
# note's low nibble twice, its octave's offset and the transposition): kref --sound-rom-reads, 431E reads 44A5-45DB;
# the FM table's first 13 words would be the code before 44A5, the PCM one runs up to the code at 45F5
44A5  data   fm_pitches  u16[71]
4533  data   pcm_pitches  u16[97]
# a note's length by its high nibble (48DC "AND $F0; RRCA x3; ...; LD HL,$48FA; ADD HL,DE"): notes are 00-DF, 14 of
# them (the code at 4916 follows)
48FA  data   note_lengths  u16[14]
# by an effect's level 1-7 (4198-41A5 "LD DE,$4166; ADD HL,DE" by twice the level: 41A5 reads 4168-4174; level 0
# ends the effect first, 419A), two bytes: a pan (41A7 "CALL $0F7C", set_pan) and a volume (41AB "JP $0D72",
# set_volume)
4168  data   effect_levels  u16[7]
struct effect_level 02 rom
field effect_level 00 pan u8
field effect_level 01 volume u8
# the pitches FM effect 08 steps through, one every 24 passes (fm_effect_08_retrigger 1323-1330, from the record's word
# at 00; kref --sound-rom-reads: 1329 reads 12E1-12EF); the PCM effects 40-42's lists of notes are below, with them
12E1  data   fm_effect_08_pitches  u16[8]

# ======== what nothing reaches ========
# 6 bytes after the last routine before the 0xFF fill (D1 F8 54 6C 5A 5A): only the ROM check (0962) sums them,
# with every other byte; and a 1A and zeros after the fill, up to the code the reset jumps to (0923): nothing reads them
089D  fill   6
08D6  fill   77
# routines nothing calls (Unused: no call, jump or table leads to them)
358A  func   set_volume_stop_at_7f
# a group of 4 FM effects on channel 7 (the record F233) no command the game sends reaches: their handlers (2774:
# commands 3C-3F, of which 3C-3E would reach them, 01E5) and their priorities after them (277C); each handler sets the
# patch before it (2799 "LD HL,$2780; CALL $0C68")
2774  data   unused_effect_group  u16[4]
277C  data   unused_effect_priorities  u8[4]
2799  func   unused_effect_3c
280E  func   unused_effect_3d
2856  func   unused_effect_3e
289F  func   unused_effect_3f

# ======== the driver's variables ========
# (ADDRESS var NAME TYPE: in the Z80's RAM; the 12 channel records are F003-F3C2, 50h bytes each)
# a command and its argument sound_command takes instead of the ports' when not 0 (0068 "LD BC,($F000)"), and a flag
# that makes the main loop run sound_command again (0BDE): only the RAM's clearing writes them (09FB)
F000  var  held_command  u16
F002  var  command_held  u8
# the K053260's registers the program keeps a copy of, to change a voice's bits: its keys (FC28: load_patch 0D2E,
# key_on 0E92, the reset 0A45), its loop and KADPCM bits (FC2A: load_patch 0D50-0D61, the KADPCM ones only: a sample's
# kadpcm bit), its pans (FC2C-FC2D: set_pan 0FAB-0FDE, two voices each)
F3C3  var  pcm_keys  u8
F3C4  var  pcm_modes  u8
F3C5  var  pcm_pans_1  u8
F3C6  var  pcm_pans_2  u8
# the PCM voices keyed on (key_on 0EA1 sets the voice's bit, key_off 0ED6 clears it): run_pcm_channel moves only a
# free voice's volume (0BFE), key_on does nothing to a keyed one (0E8B)
F3C7  var  pcm_keyed  u8
# where next_pointer_byte reads its next byte (the reset sets 0100: 0B14)
F3C8  var  byte_pointer  u16
# the fade between songs (start_sound's C0-EF, 0458-0466; command FD, 088F): on (1), the attenuation it adds to the
# music's volume (set_music_volume 494B), every so many passes (F3CC, counted down in F3CD) one more; at 30 the next song
# starts (0BCC-0BD5), at 7F the music stops (0BC7); F3CF counts down a fade of another kind (0BA7), which nothing starts
F3CA  var  fade  u8
F3CB  var  fade_attenuation  u8
F3CC  var  fade_period  u8
F3CD  var  fade_timer  u8
F3CE  var  fade_next_song  u8
F3CF  var  fade_hold  u8
# the main loop's passes (0BEC), which spread the music's ticks (music_tick 428E, one pass in 8 a record) and the PCM
# records' volume steps (run_pcm_channel 0BF3, one pass in 16) over the records
F3D0  var  pass_count  u8
# counted up by command F8 (088A), read by nothing
F3D1  var  command_f8_count  u8

# ======== the channel records ========
# The 12 channel records (F003-F3C2, 50h bytes each): F003-F233 the YM2151's channels 0-7, F283-F373 the K053260's
# voices 0-3 (sound_main 0A4D-0AF4 "ld ix,$F003; ld (ix+$40),$00" up to "ld ix,$F373; ld (ix+$40),$0B"); the C names
# each by its chip's channel (game_profile's SOUND_NAMED_BASES: CHANNEL(FM_7)->sound). The main loop runs every one
# through run_channel (0B47-0B98, "ld ix,$F003; call $0C18"...): the song's track it plays (+10-+3F, music_tick) and
# the handler it keeps (+43): an effect's or a drum's, whose own bytes are +00-+07 (each family's scoped lines say
# what its handlers keep there; the fields below are what most of them keep), or the music's note. +40-+4F are the
# chip's: what the YM2151's channel was loaded with, or (scoped channel pcm) where the K053260's voice is.
struct  channel 50
array   channel F003 12
# fm_effect_02 10D7 "ld (ix+$00),$30", 10E1 "dec (ix+$00); ret nz": passes before the effect goes on; fm_effect_05 1212
# "ld (ix+$00),$04", 125C "dec (ix+$00); jp nz,$1216": the times a step plays
field   channel 00 count u8
# fm_effect_01 1131-114E "ld (ix+$01),$20", fm_effect_01_move_pitch 1160 "dec (ix+$01)": the passes left of a step
field   channel 01 timer u8
# fm_effect_05_retrigger 1219 "ld (ix+$02),l; ld (ix+$03),h" then "call $0DE8" (set_pitch); fm_effect_05_slide 122F-123C
# "ld l,(ix+$02); ld h,(ix+$03); ld de,$0010; add hl,de; ld (ix+$02),l; ld (ix+$03),h": the pitch the effect moves
field   channel 02 pitch u16
# fm_effect_2c 2206 "ld (ix+$04),$05", fm_effect_2c_step_down 225B "dec (ix+$04); jp nz,$220A": the times the whole
# sequence of steps plays (fm_effect_30 2497, 24DF; and seven more)
field   channel 04 rounds u8
# only FM kit 2's drum 4 uses the bytes after it (fm_drum_2_4 4D6F-4D81 "ld (ix+$05),h ... ld (ix+$06),l; ld (ix+$07),h":
# its family's scoped lines say what they hold there, the high byte of its pitch and a word of passes)
field   channel 05 extra_byte u8
field   channel 06 extra_word u16
# The music's: start_music_track (41AE-4268) clears +11-+39 and sets the rest; music_tick (4289) reads the track
# 41AE "ld (ix+$10),a" (start_music_channel's: the song's command, 80-AF); 4289 music_tick "ld a,(ix+$10); or a; ret
# z": the track plays while it is set; stop_music_channel 4278 and the track's FF (48C9) clear it
field   channel 10 song u8
# 48B6-48C3 music_tick (command FE) "ld (ix+$11),a ... ld (ix+$42),a"; 42C5 "ld a,(ix+$11); cp (ix+$42); ret c": the
# music's priority, which takes the record's sound over when it is not lower
field   channel 11 music_priority u8
# 46A6-46C9 music_tick (command E0) "ld (ix+$12),a", then 494C (FM) or 4E4E (PCM) plus 32 times it into +28; 42CC "ld
# a,(ix+$12); or a; jp nz,$45F5": not 0, a note runs a drum routine of the kit instead
field   channel 12 drum_kit u8
# 46D2 music_tick (command E1) "ld (ix+$13),a"; 42A1 "ld e,(ix+$13) ... add hl,de": units added to time each turn
field   channel 13 tempo u8
# 472E music_tick (command E4) "ld (ix+$14),a"; set_note_gate 4919 "ld a,(ix+$14)": the part (of 256) of a note keyed on
field   channel 14 gate u8
# 4649-4653 music_tick (commands 01-0F) "ld (ix+$15),a" (the octave times 24); 4310 "add a,(ix+$15)": the bytes into the
# pitch tables
field   channel 15 octave u8
# 4767 music_tick (command E6) "ld (ix+$16),a"; 4321 "ld l,(ix+$16); ld h,$00; add hl,de": added to the note's pitch
field   channel 16 detune u8
# 471E music_tick (command E3) "ld (ix+$17),a"; update_music_volume 4947 "ld a,(ix+$17)": the music's volume on the record
field   channel 17 music_volume u8
# 47DC music_tick (command EF) "ld (ix+$18),a"; 42EA, 4712 "ld a,(ix+$18); call $0F7C" (set_pan)
field   channel 18 music_pan u8
# 4701 music_tick (command E2) "ld (ix+$19),e; ld (ix+$1a),d" from music_fm_patches or music_pcm_patches; 42DB "ld
# l,(ix+$19); ld h,(ix+$1a); call $0C68" (load_patch): the instrument's patch
field   channel 19 patch u16
# 47D3 music_tick (command EE) "ld (ix+$1b),a"; music_note_tick 447E "ld a,(ix+$1b); ld (ix+$2e),a": passes between
# the steps of the LFO's sensitivity after a note starts (0: none)
field   channel 1B lfo_ramp u8
# The pitch envelope (command E7, 4770-47A3: +24, then +1C-+23 a byte each): a note starts its first segment (434C-4355
# "ld a,(ix+$24); ld (ix+$2a),a; ld a,(ix+$1c); ld (ix+$2b),a"); each segment adds its step to the pitch every period
# passes, its count times (music_pitch_envelope_1 437C "ld e,(ix+$1d)", 439B "ld a,(ix+$1e); ld (ix+$2b),a" ...)
field   channel 1C envelope_count_1 u8
field   channel 1D envelope_step_1 s8
field   channel 1E envelope_count_2 u8
field   channel 1F envelope_step_2 s8
field   channel 20 envelope_count_3 u8
field   channel 21 envelope_step_3 s8
field   channel 22 envelope_count_4 u8
field   channel 23 envelope_step_4 s8
field   channel 24 envelope_period u8
# 4201 start_music_track "ld (ix+$25),$00": nothing else reads or writes it
field   channel 25 spare u8
# 46F4 music_tick (command E2 on a PCM record) "ld (ix+$26),e; ld (ix+$27),d" from music_pcm_transpositions; 4317 "ld
# e,(ix+$26); ld d,(ix+$27); add hl,de": bytes into the pitch table
field   channel 26 transposition s16
# 46C9 music_tick (command E0) "ld (ix+$28),l; ld (ix+$29),h"; 4604 "ld l,(ix+$28); ld h,(ix+$29); add hl,de" then the
# routine there into the handler: the kit's 16 drum routines (instrument_routines)
field   channel 28 drum_routines u16
# 434F "ld (ix+$2a),a" (the period); music_pitch_envelope_1 4372 "dec (ix+$2a); ret nz": passes to the next step
field   channel 2A envelope_timer u8
# 4355 "ld (ix+$2b),a"; music_pitch_envelope_1 4397 "dec (ix+$2b); ret nz": steps left of the segment
field   channel 2B envelope_count u8
# 4327 music_tick "ld (ix+$2c),l; ld (ix+$2d),h" then set_pitch; music_pitch_envelope_1 4387-4391 adds the step to it
field   channel 2C note_pitch u16
# 433A "ld (ix+$2e),a" (lfo_ramp); music_note_tick 445F "dec (ix+$2e)": passes to the LFO sensitivity's next step
field   channel 2E lfo_ramp_timer u8
# 433D "ld (ix+$2f),$00"; music_note_tick 4465-4479 "inc (ix+$2f); ld a,(ix+$2f); call $0F3C ... cp $07": the
# sensitivity's step, up to 7
field   channel 2F lfo_ramp_step u8
# 47FC music_tick (command F1) "inc (ix+$30) ... cp (ix+$30)": the times the command was read, up to its count
field   channel 30 jump_count u8
# 4818 music_tick (command F2) "ld (ix+$31),a", 482D (F3) "dec (ix+$31)"; 481E-4827 the track's place into +32
field   channel 31 loop_count u8
field   channel 32 loop_start u16
# 4842 (command F4) "ld (ix+$34),a", 4857 (F5) "dec (ix+$34)"; 4848-4851 the track's place into +35
field   channel 34 loop_2_count u8
field   channel 35 loop_2_start u16
# 486C (command F6) "ld (ix+$37),a; ... ld (ix+$38),l; ld (ix+$39),h", 488E-48A1 (F7) "ld l,(ix+$38) ... dec (ix+$37)":
# a part played its count of times, and where the track goes on after it
field   channel 37 part_count u8
field   channel 38 part_return u16
# 4255 start_music_track "ld (ix+$3a),$FF; ld (ix+$3b),$FF"; 429B-42AD "ld l,(ix+$3a) ... add hl,de; ld (ix+$3a),l;
# ld (ix+$3b),h; ret nc": the tempo added each turn, the next step read at its carry; add_note_length 48EC subtracts
# a note's length (note_lengths are negative)
field   channel 3A time u16
# set_note_gate 4940 "ld (ix+$3c),l; ld (ix+$3d),h"; music_note_tick 449A "ld e,(ix+$3c) ... add hl,de; ret nc; jp
# $0EBE": the note is keyed off when time is that close to its end
field   channel 3C gate_time u16
# 4265 start_music_track "ld (ix+$3e),e; ld (ix+$3f),d"; next_track_byte 4957-4962: the place of the track's next byte
field   channel 3E track u16
# The chip's: sound_main 0A51 "ld (ix+$40),$00" ... 0AF4 "ld (ix+$40),$0B"; write_fm_channel_register 0C3A "ld
# a,(ix+$40); add a,b": the YM2151's channel 0-7, or 8-B the K053260's voice 0-3
field   channel 40 chip_channel u8
# start_sound 01B5 "ld (ix+$41),c"; 4358 music_tick "ld a,(ix+$10); ld (ix+$41),a": the sound it plays (an effect, or
# the music's song: bit 7); stop_channel 0C28 "ld (ix+$41),$00"
field   channel 41 sound u8
# start_sound 01B1 "cp (ix+$42); ret c", 01B8 "ld (ix+$42),a": the priority of what it plays (effect_priorities,
# music_priority); stop_channel_unless_kept 016B "ld a,(ix+$42); cp $C0"
field   channel 42 priority u8
# set_channel_handler 0C33 "ld (ix+$43),l; ld (ix+$44),h"; run_channel 0C1B "ld l,(ix+$43); ld h,(ix+$44); jp (hl)":
# what runs the record each pass
field   channel 43 handler u16
# set_volume 0D72 "ld (ix+$45),a"; write_operator_level 0DAC "add a,(ix+$45)" (the carriers' total levels: 0 loudest,
# 7F silent), 0DC0 "ld a,(ix+$45)" (the K053260's volume is 7F less it)
field   channel 45 volume u8
# What the YM2151's channel was loaded with (load_patch 0C76-0D23, its patch's bytes between the register writes): the
# connection (register 20: 0C77 "ld (ix+$46),c"; update_volume 0D7D "and $07": the algorithm; set_pan 0F89-0F8F its
# bits 6-7), the operators' total levels (0C88, 0CB3, 0CDE, 0D09; update_volume 0D8A-0DA2 writes them to registers 60,
# 70, 68, 78 with the volume), their release rates (registers E0, F0, E8, F8: 0CA2, 0CCD, 0CF8, 0D23; restore_release puts
# them back) and the LFO's sensitivities (register 38: set_channel_pm_sensitivity 0F49-0F4F, bits 4-6 PMS, 0-1 AMS)
field   channel 46 connection u8
field   channel 47 m1_total_level u8
field   channel 48 c1_total_level u8
field   channel 49 m2_total_level u8
field   channel 4A c2_total_level u8
field   channel 4B m1_release u8
field   channel 4C c1_release u8
field   channel 4D m2_release u8
field   channel 4E c2_release u8
field   channel 4F lfo_sensitivity u8
# What a K053260 voice's record keeps there instead (the pcm_ functions, and run_pcm_channel's): pcm_load_patch 0D66
# "ld (ix+$46),a" (the patch's level), pcm_update_volume 0DC3 "add a,(ix+$46)"
scoped  channel pcm 46 level u8
# pcm_load_patch 0D6C "ld (ix+$47),a"; run_pcm_channel 0C07-0C12 "ld a,(ix+$48); add a,(ix+$47) ... ld (ix+$48),a":
# how much quieter the voice gets every 16 passes while it is not keyed
scoped  channel pcm 47 decay_step u8
# pcm_key_on 0EB7 "ld (ix+$48),$00", pcm_fast_release 0F01 "ld (ix+$48),$7F"; pcm_update_volume 0DCB "add a,(ix+$48)":
# the attenuation the decay has reached
scoped  channel pcm 48 decay u8
# sound_main 0A95-0A9B "ld hl,$FC08; ld (ix+$4a),l; ld (ix+$4b),h" (FC10, FC18, FC20 for the others); pcm_set_pitch
# 0E71 "ld l,(ix+$4a); ld h,(ix+$4b); ld (hl),e": where the voice's 8 registers are (pitch, length, start, volume at +7)
scoped  channel pcm 4A registers u16
# sound_main 0A9E "ld (ix+$4c),$FE", 0AA2 "ld (ix+$4d),$01" (FD 02, FB 04, F7 08 for the others): the voice's bit of the
# K053260's key register (FC28) and the mask that clears it (pcm_key_on 0E8B-0EAD, pcm_key_off 0ECC-0ED9)
scoped  channel pcm 4C key_mask u8
scoped  channel pcm 4D key_bit u8
# sound_main 0AA6 "ld (ix+$4e),$EF", 0AAA "ld (ix+$4f),$10" (DF 20, BF 40, 7F 80): the voice's KADPCM bit of FC2A
# (pcm_modes; bits 4-7 of the K053260's register 2A, MAME's k053260.cpp) and the mask that clears it (pcm_load_patch
# 0D50-0D5B: set when the sample's kadpcm bit is)
scoped  channel pcm 4E kadpcm_mask u8
scoped  channel pcm 4F kadpcm_bit u8
# run_pcm_channel only runs on the K053260's records (sound_main_loop 0B7F-0B98): what it reads through the record
# are the pcm family's fields
param   run_pcm_channel ix channel channel.pcm

# ======== what the driver's routines take ========
# start_sound 00A0 "cp $80; jp nc,$034E" (and 0455, 0BD5 "ld a,($F3CE)"): the song's command, 80-AF
param   start_song a song
# start_song 0369 "ex de,hl" (the header's address), then 03D0-03D3 "ld e,(hl); inc hl; ld d,(hl); inc hl": the
# header's word for this record's track, HL past it for the next record
param   start_music_channel hl header_entry
# write_fm_channel_register 0C3A-0C3E "ld a,(ix+$40); add a,b; ld b,a"; write_fm_register 0C46 "ld a,b; ld ($F800),a",
# 0C51 "ld a,c; ld ($F801),a": B the YM2151's register, C its value
param   write_fm_channel_register bc fm_write
param   write_fm_register bc fm_write
# 0C76 load_patch "ld c,(hl)" and on (fm_patch); pcm_load_patch 0D3B "ld l,(hl)" (pcm_patch); the callers' "ld hl,$NNNN;
# call $0C68" (fm_effect_01 10E5 "ld hl,$10BE"), music_tick 42DB "ld l,(ix+$19); ld h,(ix+$1a)"
param   load_patch hl patch fm_patch
param   pcm_load_patch hl patch pcm_patch
# update_volume 0D85-0D89 "ld hl,$0DB8; add hl,bc; ld l,(hl)" (carrier_masks), 0D8A "ld a,(ix+$47); ld b,$60; call
# $0DA7"; write_operator_level 0DA7 "sla l; jp nc", 0DAC "add a,(ix+$45)", 0DB4 "ld c,a; jp $0C3A": the carriers'
# mask shifted a bit per operator, the operator's total level, its register
param   write_operator_level hl carriers
param   write_operator_level a level
param   write_operator_level bc fm_write
# set_pitch 0DF0-0E0D "ld a,h; and $1F ... ld c,l; ld b,$30" (key fraction) and the key code of note_codes;
# pcm_set_pitch 0E70-0E79 "ex de,hl; ... ld (hl),e; inc hl; ld (hl),d" (the K053260 voice's pitch registers)
param   set_pitch hl pitch
param   pcm_set_pitch hl pitch
# nothing calls restore_release: its IX is a record as everywhere else (0F06 "ld a,(ix+$40)")
param   restore_release ix channel channel
# set_lfo_pm_depth 0F2C "or $80; ld c,a; ld b,$19"; set_lfo_am_depth 0F34 "and $7F" (YM2151 register 19: PMD with
# bit 7, AMD without); music_tick 47C1, 47C7 (command ED)
param   set_lfo_pm_depth a depth
param   set_lfo_am_depth a depth
# set_channel_am_sensitivity 0F58 "and $03"; set_channel_pm_sensitivity 0F3C "and $07; rlca x4" (register 38)
param   set_channel_am_sensitivity a sensitivity
param   set_channel_pm_sensitivity a sensitivity
# set_lfo_frequency 0F70 "ld c,a; ld b,$18"; set_lfo_waveform 0F76 "ld c,a; ld b,$1B"
param   set_lfo_frequency a frequency
param   set_lfo_waveform a waveform
# set_pan 0F7C "ld c,a", 0F85 "rrc c; rrc c" (an FM channel's bits 6-7 of register 20: 1 left, 2 right, 3 both),
# 0FA5 "sla c x3" (a K053260 voice's pan 1-7)
param   set_pan a pan
# add_note_length 48DC "ld a,c; and $F0; rrca x3": the track's byte, its high nibble the length's code
param   add_note_length bc step
# the walks over the records that look for the effect's own or the one of the lowest priority (start_sound 0178-01A7
# FM, 028C-02BB PCM; sound_command 022D-025C command 3F, 02E7-031B command 7F): "ld ix,$F003; ld de,$0050; ld b,$08;
# cp (ix+$41) ... add ix,de; djnz", "push ix; pop hl" the lowest so far, "push hl; pop ix": a record each time
local   start_sound 0178,0187,018B,01A2,01A7,028C,029B,029F,02B6,02BB ix channel channel
local   sound_command 022D,023C,0240,0257,025C,02E7,02F6,02FF,0316,031B ix channel channel
# self_test_failed 0B28 "ld bc,$1000; dec bc; ld a,b; or c; jr nz": a count of the delay, no address
constant self_test_failed 1000 FAILED_DELAY
# nothing calls noise_on: 0FF2 "or $80; ld c,a ... ld b,$0F": A the noise's frequency (register 0F, bit 7 the noise on)
param   noise_on a noise_frequency
# nothing calls next_pointer_byte: 1010 "ld a,(hl)" the byte at byte_pointer, which it hands back
result  next_pointer_byte a value

# ======== the tables the C reads by name ========
# (ADDRESS table NAME TYPE: the game loads the asset piece of that name.) Some are indexed by the sound's number from
# well before their first element: the priorities of the effects 40-7F (02C0 "LD HL,$3630; ADD HL,DE", 0320) and
# their handlers (02D3, 0333 "LD HL,$3570"), the unused group 3C-3E's priorities (01F0 "LD HL,$2740") and handlers
# (0205 "LD HL,$26FC"), the songs' banks (0355 "LD DE,$5D92") and headers (0362 "LD DE,$5CB2"): their bases are tables
# of their own, by the sound (the elements before the sounds' first are the code and data there, never read). An FM
# channel's pitches are indexed by the note's number from 13 (42FE "LD HL,$448B"), the same way
3630  table  effect_priorities_40_by_sound  u8
3570  table  effect_handlers_40_by_sound  u16
2740  table  unused_effect_priorities_by_sound  u8
26FC  table  unused_effect_handlers_by_sound  u16
5D92  table  song_banks_by_sound  u8
5CB2  table  song_headers_by_sound  u16
448B  table  fm_pitches_by_note  u16
# the PCM patch pcm_drum_b_4 hands load_patch (5CB3 "LD HL,$5CB0"), 3 bytes just before the code (and two bytes
# before song_headers_by_sound, whose base it would read as without a name of its own)
5CB0  table  pcm_drum_b_4_patch  pcm_patch
# fm_effect_01 10E5 "ld hl,$10BE; call $0C68": the patch just before it
10BE  table  fm_effect_01_patch  fm_patch
1016  table  effect_handlers  u16
1086  table  effect_priorities  u8
2774  table  unused_effect_group  u16
277C  table  unused_effect_priorities  u8
2E01  table  effect_handlers_2  u16
2E79  table  effect_priorities_2  u8
3670  table  effect_priorities_40  u8
0DB8  table  carrier_masks  u8
0E10  table  note_codes  u8
4168  table  effect_levels  u16
44A5  table  fm_pitches  u16
4533  table  pcm_pitches  u16
48FA  table  note_lengths  u16
5E12  table  song_banks  u8
5E42  table  music_fm_patches  u16
63F4  table  music_pcm_patches  u16
642C  table  music_pcm_transpositions  s16
28E9  table  samples  u8
# what the code reads through a pointer it worked out, by the instruction that sets the pointer: an entry of
# music_fm_patches or music_pcm_patches (music_tick 46FD, by the channel's kind: the patch's address), of
# fm_pitches_by_note or pcm_pitches (431D), of music_commands (4660, the command's handler: read in the block the
# other ways into the switch join), of song_headers_by_sound (start_song 0365, by the song the stack kept), a sample's
# record (pcm_load_patch 0D44) and an effect's level (41A4)
elements patch_address u16
elements pitch u16
elements music_command_handler u16
elements song_header_address u16
local music_tick 46FD hl patch_entry patch_address
local music_tick 431D hl pitch_entry pitch
local music_tick 4660 hl command_entry music_command_handler
local start_song 0365 hl header_entry song_header_address
local pcm_load_patch 0D44 hl sample_entry sample
local pcm_effect_7f_set_volume 41A4 hl level effect_level

# ======== the music's functions ========
41AE  file  music  # the music: a song's tracks, their notes and commands, the pitch envelope, the gate, the fade's volume
41AE  func  start_music_track
comment start_music_track Starts the record's track: the song's command in song, the music's state cleared (tempo 1, time FFFF so that the first pass reads, gate_time 1), the track's place; a music sound playing on the record is stopped.
4278  func  stop_music_channel
comment stop_music_channel No more track on the record (song 0); a music sound playing on it is stopped.
4284  func  music_channel_song
comment music_channel_song Whether the record plays a track: its song.
4289  func  music_tick
comment music_tick The record's music, on one pass in 8 (by its chip_channel): the tempo added to time, and at its carry the track's next steps up to one that takes time: a note (its length; unless a sound of a higher priority has the record, the patch, volume and pan when the music did not have it, the gate, the pitch of fm_pitches_by_note or pcm_pitches by the note, octave, transposition and detune, key on but for a legato note, the pitch envelope and the LFO ramp from their start, the record's sound and priority the music's and music_pitch_envelope_1 its handler), a drum (the kit's routine for the note as the handler), a rest, an octave, or a command E0-FF (music_commands).
# music_tick's track commands E0-FF, where music_commands sends each (4659-4665 "ld l,c; ld h,$00; add hl,hl; ld
# de,$44A6; add hl,de ... jp (hl)"; the table's words from E0 on): the switch's cases by name
46A6  code  track_set_drum_kit          # E0: drum_kit, and drum_routines from it
46D2  code  track_set_tempo             # E1: tempo
46DB  code  track_set_instrument        # E2: patch (and transposition on the K053260), loaded at once if the music has the record
471E  code  track_set_volume            # E3: music_volume
472E  code  track_set_gate              # E4: gate
4737  code  track_held_note             # E5: a note and the lengths after it
4767  code  track_set_detune            # E6: detune
4770  code  track_set_pitch_envelope    # E7: envelope_period and the four segments' counts and steps
47A9  code  track_reset_e8              # E8: jp $0000, the reset (no track has it); E9-EC the same
47AC  code  track_reset_e9
47AF  code  track_reset_ea
47B2  code  track_reset_eb
47B5  code  track_reset_ec
47B8  code  track_set_lfo               # ED: the YM2151's LFO frequency, depths and waveform
47D3  code  track_set_lfo_ramp          # EE: lfo_ramp
47DC  code  track_set_pan               # EF: music_pan
47EC  code  track_jump                  # F0: track from the next two bytes
47FC  code  track_jump_counted          # F1: the jump on the count's read (jump_count)
4818  code  track_loop_start            # F2: loop_count, loop_start
482D  code  track_loop_end              # F3
4842  code  track_loop_2_start          # F4: loop_2_count, loop_2_start
4857  code  track_loop_2_end            # F5
486C  code  track_call_part             # F6: part_count, part_return
488E  code  track_part_return           # F7
48B0  code  track_reset_f8              # F8-FC: jp $0000, the reset (no track has them)
48B3  code  track_reset_fd              # FD: the same
48B6  code  track_set_priority          # FE: music_priority (and the record's priority while the music has it)
48C9  code  track_end                   # FF: song 0, the record's sound and priority cleared if the music had it
436A  func  music_pitch_envelope_1
comment music_pitch_envelope_1 A music note's handler while the pitch envelope's first segment runs: music_note_tick, then every envelope_period passes envelope_step_1 added to note_pitch, envelope_count_1 times; then the second segment.
43A7  func  music_pitch_envelope_2
comment music_pitch_envelope_2 The second segment: music_note_tick, then every envelope_period passes envelope_step_2 added to note_pitch, envelope_count_2 times; then the third.
43E4  func  music_pitch_envelope_3
comment music_pitch_envelope_3 The third segment: music_note_tick, then every envelope_period passes envelope_step_3 added to note_pitch, envelope_count_3 times; then the fourth.
4421  func  music_pitch_envelope_4
comment music_pitch_envelope_4 The fourth segment: music_note_tick, then every envelope_period passes envelope_step_4 added to note_pitch, envelope_count_4 times; then music_note_tick alone.
4458  func  music_note_tick
comment music_note_tick A music note's handler: the LFO ramp (every lfo_ramp passes the channel's sensitivities a step up, to 7); on the record's own pass in 16 the fade's volume when a fade runs, and key off once the time left is no more than gate_time.
48DC  func  add_note_length
comment add_note_length Adds a step's length (note_lengths, by its high nibble: negative, so it counts time down) to time; hands back the carry, set when the step ends before the time counted so far.
4916  func  set_note_gate
comment set_note_gate The note's gate_time: gate 256ths of what is left of time, at least 1; 0 when gate is 0 (the next note legato).
4947  func  update_music_volume
comment update_music_volume set_music_volume with the record's music_volume.
494A  func  set_music_volume
comment set_music_volume The music's volume on the record: the volume given plus fade_attenuation (at most 7F), then set_volume.
4957  func  next_track_byte
comment next_track_byte The track's next byte; track moves on.
4966  func  drum_done
comment drum_done A drum routine's end: the record's handler channel_idle, the note left to ring.

# ======== the effects' and the drums' steps ========
# Every effect and every drum routine is a chain of handlers: each runs on its record one main loop pass at a time
# and sets the next one with set_channel_handler (the record's +43), until the last stops the channel (stop_channel)
# or leaves the note ringing (drum_done). The first of a chain is named by the table that starts it: fm_effect_NN
# (effect_handlers[NN], command NN), pcm_effect_NN (effect_handlers_40[NN], command NN), pcm_effect_3f_NN
# (effect_handlers_2[NN], command 3F with the argument NN), pcm_drum_K_N (instrument_routines: kit K, note N) and
# fm_drum_K_N (instrument_routines_low); the rest by the chain they belong to (the first that reaches them) and what
# each does, found from the driver routines it reaches (directly or through the chain's own helpers):
#   note        loads a patch (load_patch) and plays it;       retrigger  keys the channel off and on again (key_on)
#   wait_sample waits for the PCM voice to end (pcm_voice_playing), then ends;  slide  moves the pitch a step at a time
#   pitch       sets a pitch;  transpose  moves the kept pitch without setting it;  fade  changes the volume
#   modulate    the pan or the LFO;  hold  counts down, then ends the sound;  end  ends the sound
#   delay       counts down, then goes on;  setup  sets the record's counters and goes on to the next
#   and for a helper the chain calls: move_pitch (adds DE to the pitch and sets it), set_pitch, set_volume, play,
#   update. A second step of the same kind in one chain is NAME_2, and so on.
10D7  file  fm_effects  # the FM effects (commands 01-38), each a chain of handlers its record runs one pass at a time
10D7  func  fm_effect_02
10E1  func  fm_effect_02_delay
10E5  func  fm_effect_01
1108  func  fm_effect_01_retrigger
1131  func  fm_effect_01_pitch
1149  func  fm_effect_01_move_pitch
1176  func  fm_effect_04
1180  func  fm_effect_04_delay
1184  func  fm_effect_03
11AB  func  fm_effect_03_pitch
11C6  func  fm_effect_03_move_pitch
11EF  func  fm_effect_06
1201  func  fm_effect_06_delay
1208  func  fm_effect_05
120C  func  fm_effect_05_note
1216  func  fm_effect_05_retrigger
122F  func  fm_effect_05_slide
127E  func  fm_effect_07
12A2  func  fm_effect_07_slide
12F1  func  fm_effect_09
12FB  func  fm_effect_09_delay
12FF  func  fm_effect_08
1318  func  fm_effect_08_retrigger
134A  func  fm_effect_08_hold
136A  func  fm_effect_0d
1374  func  fm_effect_0d_delay
1378  func  fm_effect_0c
139B  func  fm_effect_0c_retrigger
13AB  func  fm_effect_0c_retrigger_2
13CB  func  fm_effect_0c_hold
13D2  func  fm_effect_0c_move_pitch
1405  func  fm_effect_0e
1428  func  fm_effect_0e_pitch
1439  func  fm_effect_0e_pitch_2
1440  func  fm_effect_0e_round
145D  func  fm_effect_0e_pitch_3
146D  func  fm_effect_0e_move_pitch
14A5  func  fm_effect_0f
14C8  func  fm_effect_0f_slide
1522  func  fm_effect_10
1545  func  fm_effect_10_slide
159F  func  fm_effect_11
15C3  func  fm_effect_11_pitch
15DC  func  fm_effect_11_move_pitch
1610  func  fm_effect_12
1633  func  fm_effect_12_delay
1651  func  fm_effect_12_slide
1698  func  fm_effect_13
16BF  func  fm_effect_13_slide
1705  func  fm_effect_13_hold
173C  func  fm_effect_13_fall
1787  func  fm_effect_14
17AD  func  fm_effect_14_slide
17F4  func  fm_effect_14_hold
184C  func  fm_effect_15
1869  func  fm_effect_15_note
189B  func  fm_effect_15_slide
18D8  func  fm_effect_17
18E7  func  fm_effect_17_delay
18EB  func  fm_effect_16
1912  func  fm_effect_16_pitch
192D  func  fm_effect_16_move_pitch
1956  func  fm_effect_18
1975  func  fm_effect_18_slide
19B2  func  fm_effect_19
19C0  func  fm_effect_19_retrigger
19D9  func  fm_effect_19_slide
1A28  func  fm_effect_1a
1A32  func  fm_effect_1a_retrigger
1A4B  func  fm_effect_1a_slide
1A8F  func  fm_effect_1b
1AAE  func  fm_effect_1b_pitch
1ABF  func  fm_effect_1b_pitch_2
1AC9  func  fm_effect_1b_move_pitch
1B01  func  fm_effect_1c
1B24  func  fm_effect_1c_pitch
1B35  func  fm_effect_1c_pitch_2
1B3C  func  fm_effect_1c_round
1B59  func  fm_effect_1c_pitch_3
1B69  func  fm_effect_1c_move_pitch
1BA1  func  fm_effect_1d
1BC0  func  fm_effect_1d_pitch
1BCB  func  fm_effect_1d_pitch_2
1BE1  func  fm_effect_1d_pitch_3
1BF1  func  fm_effect_1d_move_pitch
1C29  func  fm_effect_1e
1C48  func  fm_effect_1e_slide
1C85  func  fm_effect_1f
1C9E  func  fm_effect_1f_retrigger
1CBD  func  fm_effect_1f_end
1CE9  func  fm_effect_20
1D08  func  fm_effect_20_pitch
1D19  func  fm_effect_20_pitch_2
1D23  func  fm_effect_20_move_pitch
1D5B  func  fm_effect_21
1D79  func  fm_effect_21_end
1DA5  func  fm_effect_22
1DC8  func  fm_effect_22_slide
1E0C  func  fm_effect_23
1E16  func  fm_effect_23_retrigger
1E2F  func  fm_effect_23_slide
1E73  func  fm_effect_24
1E96  func  fm_effect_24_retrigger
1EC7  func  fm_effect_24_hold
1EE7  func  fm_effect_25
1EF1  func  fm_effect_25_note
1F18  func  fm_effect_25_retrigger
1F49  func  fm_effect_25_hold
1F69  func  fm_effect_26
1F82  func  fm_effect_26_transpose
1F9C  func  fm_effect_26_slide
1FBA  func  fm_effect_26_pitch
1FC7  func  fm_effect_26_move_pitch
1FF7  func  fm_effect_27
201A  func  fm_effect_27_retrigger
204B  func  fm_effect_27_hold
206B  func  fm_effect_28
208E  func  fm_effect_28_slide
20E4  func  fm_effect_29
2103  func  fm_effect_29_pitch
210E  func  fm_effect_29_setup
2118  func  fm_effect_29_slide
2138  func  fm_effect_29_move_pitch
2165  func  fm_effect_2b
216F  func  fm_effect_2b_delay
2173  func  fm_effect_2a
2196  func  fm_effect_2a_retrigger
21A6  func  fm_effect_2a_retrigger_2
21C6  func  fm_effect_2a_hold
21CD  func  fm_effect_2a_move_pitch
2200  func  fm_effect_2c
220A  func  fm_effect_2c_retrigger
2227  func  fm_effect_2c_step_up
2248  func  fm_effect_2c_step_down
2264  func  fm_effect_2c_transpose
2274  func  fm_effect_2c_play
227A  func  fm_effect_2c_set_pitch
22A1  func  fm_effect_2d
22AB  func  fm_effect_2d_note
22B9  func  fm_effect_2d_retrigger
22D6  func  fm_effect_2d_step_up
22F7  func  fm_effect_2d_step_down
2313  func  fm_effect_2d_transpose
2323  func  fm_effect_2d_play
2329  func  fm_effect_2d_set_pitch
2350  func  fm_effect_2e
235A  func  fm_effect_2e_note
2368  func  fm_effect_2e_retrigger
2385  func  fm_effect_2e_step_up
23A6  func  fm_effect_2e_step_down
23C2  func  fm_effect_2e_transpose
23D2  func  fm_effect_2e_play
23D8  func  fm_effect_2e_set_pitch
23FF  func  fm_effect_2f
240D  func  fm_effect_2f_retrigger
2426  func  fm_effect_2f_slide
2475  func  fm_effect_32
247F  func  fm_effect_32_delay
2483  func  fm_effect_31
248D  func  fm_effect_31_delay
2491  func  fm_effect_30
249B  func  fm_effect_30_retrigger
24B8  func  fm_effect_30_retrigger_2
2501  func  fm_effect_33
250B  func  fm_effect_33_retrigger
2528  func  fm_effect_33_retrigger_2
2571  func  fm_effect_34
257B  func  fm_effect_34_setup
257F  func  fm_effect_34_retrigger
2598  func  fm_effect_34_slide
25DA  func  fm_effect_35
25E4  func  fm_effect_35_note
25F2  func  fm_effect_35_setup
25F6  func  fm_effect_35_retrigger
260F  func  fm_effect_35_slide
2651  func  fm_effect_36
265B  func  fm_effect_36_retrigger
2674  func  fm_effect_36_slide
26AD  func  fm_effect_37
26B7  func  fm_effect_37_retrigger
26D4  func  fm_effect_37_slide
2717  func  fm_effect_38
2725  func  fm_effect_38_retrigger
273E  func  fm_effect_38_slide
27C0  func  unused_effect_3c_slide
2829  func  unused_effect_3d_lower_noise
2873  func  unused_effect_3e_end
28BC  func  unused_effect_3f_step
28D2  func  unused_effect_3f_end
28D9  func  unused_effect_3f_update
2EB8  file  pcm_effects  # the PCM effects (commands 40-7E, and 3F by its argument): samples of the K053260
2EB8  func  pcm_effect_3f_00
2ECC  func  pcm_effect_3f_00_wait_sample
2ED6  func  pcm_effect_3f_01
2EEA  func  pcm_effect_3f_01_wait_sample
2EF4  func  pcm_effect_3f_02
2F08  func  pcm_effect_3f_02_wait_sample
2F12  func  pcm_effect_3f_03
2F26  func  pcm_effect_3f_03_wait_sample
2F30  func  pcm_effect_3f_04
2F44  func  pcm_effect_3f_04_wait_sample
2F4E  func  pcm_effect_3f_05
2F62  func  pcm_effect_3f_05_wait_sample
2F6C  func  pcm_effect_3f_06
2F80  func  pcm_effect_3f_06_wait_sample
2F8A  func  pcm_effect_3f_07
2F9E  func  pcm_effect_3f_07_wait_sample
2FA8  func  pcm_effect_3f_08
2FBC  func  pcm_effect_3f_08_wait_sample
2FC6  func  pcm_effect_3f_09
2FDA  func  pcm_effect_3f_09_wait_sample
2FE4  func  pcm_effect_3f_0a
2FF8  func  pcm_effect_3f_0a_wait_sample
3002  func  pcm_effect_3f_0b
3016  func  pcm_effect_3f_0b_wait_sample
3020  func  pcm_effect_3f_0c
3034  func  pcm_effect_3f_0c_wait_sample
303E  func  pcm_effect_3f_0d
3052  func  pcm_effect_3f_0d_wait_sample
305C  func  pcm_effect_3f_0e
3070  func  pcm_effect_3f_0e_wait_sample
307A  func  pcm_effect_3f_0f
308E  func  pcm_effect_3f_0f_wait_sample
3098  func  pcm_effect_3f_10
30AC  func  pcm_effect_3f_10_wait_sample
30B6  func  pcm_effect_3f_11
30CA  func  pcm_effect_3f_11_wait_sample
30D4  func  pcm_effect_3f_12
30E8  func  pcm_effect_3f_12_wait_sample
30F2  func  pcm_effect_3f_13
3106  func  pcm_effect_3f_13_wait_sample
3110  func  pcm_effect_3f_14
3124  func  pcm_effect_3f_14_wait_sample
312E  func  pcm_effect_3f_15
3142  func  pcm_effect_3f_15_wait_sample
314C  func  pcm_effect_3f_16
3160  func  pcm_effect_3f_16_wait_sample
316A  func  pcm_effect_3f_17
317E  func  pcm_effect_3f_17_wait_sample
3188  func  pcm_effect_3f_18
319C  func  pcm_effect_3f_18_wait_sample
31A6  func  pcm_effect_3f_19
31BA  func  pcm_effect_3f_19_wait_sample
31C4  func  pcm_effect_3f_1a
31D8  func  pcm_effect_3f_1a_wait_sample
31E2  func  pcm_effect_3f_1b
31F6  func  pcm_effect_3f_1b_wait_sample
3200  func  pcm_effect_3f_1c
3214  func  pcm_effect_3f_1c_wait_sample
321E  func  pcm_effect_3f_1d
3232  func  pcm_effect_3f_1d_wait_sample
323C  func  pcm_effect_3f_1e
3250  func  pcm_effect_3f_1e_wait_sample
325A  func  pcm_effect_3f_1f
326E  func  pcm_effect_3f_1f_wait_sample
3278  func  pcm_effect_3f_20
328C  func  pcm_effect_3f_20_wait_sample
3296  func  pcm_effect_3f_21
32AA  func  pcm_effect_3f_21_wait_sample
32B4  func  pcm_effect_3f_22
32C8  func  pcm_effect_3f_22_wait_sample
32D2  func  pcm_effect_3f_23
32E6  func  pcm_effect_3f_23_wait_sample
32F0  func  pcm_effect_3f_24
3304  func  pcm_effect_3f_24_wait_sample
330E  func  pcm_effect_3f_25
3322  func  pcm_effect_3f_25_wait_sample
332C  func  pcm_effect_3f_26
3340  func  pcm_effect_3f_26_wait_sample
334A  func  pcm_effect_3f_27
335E  func  pcm_effect_3f_27_wait_sample
3368  func  pcm_effect_3f_28
337C  func  pcm_effect_3f_28_wait_sample
3386  func  pcm_effect_3f_29
339A  func  pcm_effect_3f_29_wait_sample
33A4  func  pcm_effect_3f_2a
33B8  func  pcm_effect_3f_2a_wait_sample
33C2  func  pcm_effect_3f_2b
33D6  func  pcm_effect_3f_2b_wait_sample
33E0  func  pcm_effect_3f_2c
33FA  func  pcm_effect_3f_2c_wait_sample
3404  func  pcm_effect_3f_2d
341E  func  pcm_effect_3f_2d_wait_sample
3428  func  pcm_effect_3f_2e
3442  func  pcm_effect_3f_2e_wait_sample
3449  func  pcm_effect_3f_2f
344F  func  pcm_effect_3f_30
3469  func  pcm_effect_3f_30_wait_sample
3473  func  pcm_effect_3f_31
348D  func  pcm_effect_3f_31_wait_sample
3497  func  pcm_effect_3f_32
34B1  func  pcm_effect_3f_32_wait_sample
34BB  func  pcm_effect_3f_33
34D5  func  pcm_effect_3f_33_wait_sample
34DF  func  pcm_effect_3f_34
34F9  func  pcm_effect_3f_34_wait_sample
3503  func  pcm_effect_3f_35
351D  func  pcm_effect_3f_35_wait_sample
3527  func  pcm_effect_3f_36
3541  func  pcm_effect_3f_36_wait_sample
354B  func  pcm_effect_3f_37
3565  func  pcm_effect_3f_37_wait_sample
356F  func  pcm_effect_3f_38
3583  func  pcm_effect_3f_38_wait_sample
3599  func  pcm_effect_3f_39
35AD  func  pcm_effect_3f_39_wait_sample
35B7  func  pcm_effect_3f_3a
35CB  func  pcm_effect_3f_3a_wait_sample
35D5  func  pcm_effect_3f_3b
35E9  func  pcm_effect_3f_3b_wait_sample
3719  func  pcm_effect_42
372A  func  pcm_effect_41
373B  func  pcm_effect_40
3749  func  pcm_effect_42_setup
375D  func  pcm_effect_42_next_note
378F  func  pcm_effect_42_rest
37B2  func  pcm_effect_42_update
37C5  func  pcm_effect_43
37D9  func  pcm_effect_43_wait_sample
37E3  func  pcm_effect_44
37F7  func  pcm_effect_44_wait_sample
3801  func  pcm_effect_45
3815  func  pcm_effect_45_wait_sample
381F  func  pcm_effect_46
3837  func  pcm_effect_46_retrigger
384A  func  pcm_effect_47
385E  func  pcm_effect_47_wait_sample
3868  func  pcm_effect_48
387C  func  pcm_effect_48_wait_sample
3886  func  pcm_effect_49
389A  func  pcm_effect_49_wait_sample
38A4  func  pcm_effect_4a
38B8  func  pcm_effect_4a_wait_sample
38C2  func  pcm_effect_4b
38D6  func  pcm_effect_4b_wait_sample
38E0  func  pcm_effect_4c
38F4  func  pcm_effect_4c_wait_sample
38FE  func  pcm_effect_4d
3912  func  pcm_effect_4d_wait_sample
391C  func  pcm_effect_4e
3930  func  pcm_effect_4e_wait_sample
393A  func  pcm_effect_4f
394E  func  pcm_effect_4f_wait_sample
3958  func  pcm_effect_50
397E  func  pcm_effect_50_fade
399A  func  pcm_effect_50_wait_sample
39A4  func  pcm_effect_51
39BE  func  pcm_effect_51_wait_sample
39C8  func  pcm_effect_52
39E6  func  pcm_effect_52_delay
39F7  func  pcm_effect_52_hold
3A01  func  pcm_effect_53
3A15  func  pcm_effect_53_wait_sample
3A1F  func  pcm_effect_54
3A3A  func  pcm_effect_54_modulate
3A57  func  pcm_effect_54_wait_sample
3A61  func  pcm_effect_55
3A7B  func  pcm_effect_55_wait_sample
3A85  func  pcm_effect_56
3AA4  func  pcm_effect_56_retrigger
3ABE  func  pcm_effect_56_retrigger_2
3AD8  func  pcm_effect_56_wait_sample
3AE5  func  pcm_effect_57
3B08  func  pcm_effect_57_retrigger
3B2A  func  pcm_effect_57_note
3B48  func  pcm_effect_57_wait_sample
3B4F  func  pcm_effect_57_update
3B62  func  pcm_effect_58
3B80  func  pcm_effect_58_retrigger
3B93  func  pcm_effect_59
3BA7  func  pcm_effect_59_wait_sample
3BB1  func  pcm_effect_5a
3BC5  func  pcm_effect_5a_wait_sample
3BCF  func  pcm_effect_5b
3BE6  func  pcm_effect_5b_wait_sample
3BF0  func  pcm_effect_5c
3C0E  func  pcm_effect_5c_delay
3C1F  func  pcm_effect_5c_hold
3C29  func  pcm_effect_5d
3C41  func  pcm_effect_5d_delay
3C52  func  pcm_effect_5d_hold
3C5C  func  pcm_effect_5e
3C70  func  pcm_effect_5e_wait_sample
3C7A  func  pcm_effect_5f
3C8E  func  pcm_effect_5f_wait_sample
3C98  func  pcm_effect_60
3CAC  func  pcm_effect_60_wait_sample
3CB6  func  pcm_effect_61
3CCA  func  pcm_effect_61_wait_sample
3CD4  func  pcm_effect_62
3CE8  func  pcm_effect_62_wait_sample
3CF2  func  pcm_effect_63
3D06  func  pcm_effect_63_wait_sample
3D10  func  pcm_effect_64
3D24  func  pcm_effect_64_wait_sample
3D2E  func  pcm_effect_65
3D42  func  pcm_effect_65_wait_sample
3D4C  func  pcm_effect_66
3D60  func  pcm_effect_66_wait_sample
3D6A  func  pcm_effect_67
3D7E  func  pcm_effect_67_wait_sample
3D88  func  pcm_effect_68
3D9C  func  pcm_effect_68_wait_sample
3DA6  func  pcm_effect_69
3DBA  func  pcm_effect_69_wait_sample
3DC4  func  pcm_effect_6a
3DD8  func  pcm_effect_6a_wait_sample
3DE2  func  pcm_effect_6b
3DF6  func  pcm_effect_6b_wait_sample
3E00  func  pcm_effect_6c
3E14  func  pcm_effect_6c_wait_sample
3E1E  func  pcm_effect_6d
3E32  func  pcm_effect_6d_wait_sample
3E3C  func  pcm_effect_6e
3E50  func  pcm_effect_6e_wait_sample
3E5A  func  pcm_effect_6f
3E6E  func  pcm_effect_6f_wait_sample
3E78  func  pcm_effect_70
3E8C  func  pcm_effect_70_wait_sample
3E96  func  pcm_effect_71
3EAA  func  pcm_effect_71_wait_sample
3EB4  func  pcm_effect_72
3EC8  func  pcm_effect_72_wait_sample
3ED2  func  pcm_effect_73
3EE6  func  pcm_effect_73_wait_sample
3EF0  func  pcm_effect_74
3F04  func  pcm_effect_74_wait_sample
3F0E  func  pcm_effect_75
3F22  func  pcm_effect_75_wait_sample
3F2C  func  pcm_effect_76
3F40  func  pcm_effect_76_wait_sample
3F4A  func  pcm_effect_77
3F62  func  pcm_effect_77_delay
3F73  func  pcm_effect_77_hold
3F7A  func  pcm_effect_78
3F80  func  pcm_effect_79
3F94  func  pcm_effect_79_wait_sample
3F9E  func  pcm_effect_7a
3FBE  func  pcm_effect_7a_fade_in
3FE6  func  pcm_effect_7a_delay
4007  func  pcm_effect_7a_fade_out
4024  func  pcm_effect_7a_replay
4031  func  pcm_effect_7b
4045  func  pcm_effect_7b_wait_sample
404F  func  pcm_effect_7c
406F  func  pcm_effect_7c_fade_in
4097  func  pcm_effect_7c_delay
40B8  func  pcm_effect_7c_fade_out
40D5  func  pcm_effect_7c_replay
40E2  func  pcm_effect_7d
40F6  func  pcm_effect_7d_wait_sample
4100  func  pcm_effect_7e
411D  func  pcm_effect_7e_delay
413E  func  pcm_effect_7e_fade_out
415B  func  pcm_effect_7e_replay
4176  func  pcm_effect_7f
4188  func  pcm_effect_7f_retrigger
4194  func  pcm_effect_7f_set_volume
49C5  file  drums  # the drum routines: a music note's low nibble on a channel with a drum kit (+12) runs one
49C5  func  fm_drum_1_1
49E4  func  fm_drum_1_1_slide
4A18  func  fm_drum_1_2
4A31  func  fm_drum_1_2_hold
4A51  func  fm_drum_1_3
4A6A  func  fm_drum_1_3_hold
4A8A  func  fm_drum_1_4
4AA3  func  fm_drum_1_4_hold
4AC3  func  fm_drum_1_5
4AE7  func  fm_drum_1_5_slide
4B26  func  fm_drum_1_6
4B4A  func  fm_drum_1_6_slide
4B89  func  fm_drum_1_7
4BAD  func  fm_drum_1_7_slide
4BEC  func  fm_drum_1_8
4C10  func  fm_drum_1_8_slide
4C36  func  fm_drum_1_9
4C52  func  fm_drum_2_1
4C58  func  fm_drum_2_1_setup
4C5C  func  fm_drum_2_1_retrigger
4C75  func  fm_drum_2_1_slide
4CB1  func  fm_drum_2_2
4CB7  func  fm_drum_2_2_setup
4CBB  func  fm_drum_2_2_retrigger
4CD4  func  fm_drum_2_2_slide
4D10  func  fm_drum_2_3
4D16  func  fm_drum_2_3_retrigger
4D2F  func  fm_drum_2_3_slide
4D62  func  fm_drum_2_4
4D78  func  fm_drum_2_4_retrigger
4D8D  func  fm_drum_2_4_slide
4DCF  func  fm_drum_2_4_random_step
4DE2  func  fm_drum_2_4_random_step_down
4DE5  func  fm_drum_2_4_reverse
4DF8  func  fm_drum_2_4_random_turn
4E04  func  fm_drum_2_4_next_random
4E27  func  fm_drum_2_5
4E2D  func  fm_drum_2_5_retrigger
4E4A  func  fm_drum_2_5_slide
4E6B  func  fm_drum_2_6
4FD1  func  pcm_drum_1_1
4FE5  func  pcm_drum_1_2
4FF9  func  pcm_drum_1_3
5013  func  pcm_drum_1_4
502D  func  pcm_drum_1_5
5047  func  pcm_drum_1_6
5061  func  pcm_drum_1_7
5075  func  pcm_drum_1_8
5089  func  pcm_drum_1_9
509D  func  pcm_drum_1_a
50B7  func  pcm_drum_1_b
50CB  func  pcm_drum_1_b_note
50DE  func  pcm_drum_1_b_note_2
50F7  func  pcm_drum_1_c
5101  func  pcm_drum_1_c_note
5119  func  pcm_drum_1_c_note_2
512C  func  pcm_drum_1_c_note_3
513C  func  pcm_drum_1_d
5142  func  pcm_drum_1_f
5156  func  pcm_drum_2_1
516A  func  pcm_drum_2_2
517E  func  pcm_drum_2_3
5198  func  pcm_drum_2_4
51B2  func  pcm_drum_2_5
51CC  func  pcm_drum_2_6
51E6  func  pcm_drum_2_7
51FA  func  pcm_drum_2_8
520E  func  pcm_drum_2_9
5222  func  pcm_drum_2_a
5236  func  pcm_drum_2_b
524A  func  pcm_drum_2_c
525E  func  pcm_drum_2_d
5272  func  pcm_drum_2_e
5286  func  pcm_drum_2_f
529A  func  pcm_drum_3_1
52AE  func  pcm_drum_3_2
52C2  func  pcm_drum_3_3
52DC  func  pcm_drum_3_4
52F6  func  pcm_drum_3_5
5310  func  pcm_drum_3_6
532A  func  pcm_drum_3_7
533E  func  pcm_drum_3_8
5352  func  pcm_drum_3_9
5366  func  pcm_drum_3_a
537A  func  pcm_drum_3_b
538E  func  pcm_drum_3_c
53A2  func  pcm_drum_3_d
53B6  func  pcm_drum_3_e
53CA  func  pcm_drum_3_f
53DE  func  pcm_drum_4_1
53F2  func  pcm_drum_4_2
5406  func  pcm_drum_4_3
541A  func  pcm_drum_4_4
5434  func  pcm_drum_4_5
544E  func  pcm_drum_4_6
5468  func  pcm_drum_4_7
547C  func  pcm_drum_4_8
5490  func  pcm_drum_4_9
54A4  func  pcm_drum_4_a
54B8  func  pcm_drum_4_b
54CC  func  pcm_drum_4_c
54E0  func  pcm_drum_4_d
54F4  func  pcm_drum_4_e
5508  func  pcm_drum_4_f
551C  func  pcm_drum_5_1
5530  func  pcm_drum_5_2
5544  func  pcm_drum_5_3
555E  func  pcm_drum_5_4
5578  func  pcm_drum_5_5
5592  func  pcm_drum_5_6
55AC  func  pcm_drum_5_7
55C0  func  pcm_drum_5_8
55D4  func  pcm_drum_5_9
55E8  func  pcm_drum_5_a
55FC  func  pcm_drum_5_b
5610  func  pcm_drum_5_c
5624  func  pcm_drum_5_d
5638  func  pcm_drum_5_e
564C  func  pcm_drum_5_f
5660  func  pcm_drum_6_1
5674  func  pcm_drum_6_2
5688  func  pcm_drum_6_3
56A2  func  pcm_drum_6_4
56BC  func  pcm_drum_6_5
56D6  func  pcm_drum_6_6
56F0  func  pcm_drum_6_7
5704  func  pcm_drum_6_8
5718  func  pcm_drum_6_9
572C  func  pcm_drum_6_a
5740  func  pcm_drum_6_b
5754  func  pcm_drum_6_c
5768  func  pcm_drum_6_d
577C  func  pcm_drum_6_e
5790  func  pcm_drum_6_f
57A4  func  pcm_drum_7_1
57B8  func  pcm_drum_7_2
57CC  func  pcm_drum_7_3
57E0  func  pcm_drum_7_4
57FA  func  pcm_drum_7_5
5814  func  pcm_drum_7_6
582E  func  pcm_drum_7_7
5842  func  pcm_drum_7_8
5856  func  pcm_drum_7_9
586A  func  pcm_drum_7_a
587E  func  pcm_drum_7_b
5892  func  pcm_drum_7_c
58A6  func  pcm_drum_7_d
58BA  func  pcm_drum_7_e
58CE  func  pcm_drum_7_f
58E2  func  pcm_drum_8_1
58F6  func  pcm_drum_8_2
590A  func  pcm_drum_8_3
5924  func  pcm_drum_8_4
593E  func  pcm_drum_8_5
5958  func  pcm_drum_8_6
5972  func  pcm_drum_8_7
5986  func  pcm_drum_8_8
599A  func  pcm_drum_8_9
59AE  func  pcm_drum_8_a
59C2  func  pcm_drum_8_b
59D6  func  pcm_drum_8_c
59EA  func  pcm_drum_8_d
59FE  func  pcm_drum_8_e
5A12  func  pcm_drum_8_f
5A26  func  pcm_drum_9_1
5A3A  func  pcm_drum_9_2
5A4E  func  pcm_drum_9_3
5A62  func  pcm_drum_9_4
5A76  func  pcm_drum_9_5
5A8A  func  pcm_drum_9_6
5A9E  func  pcm_drum_9_7
5AB2  func  pcm_drum_9_8
5AC6  func  pcm_drum_9_9
5ADA  func  pcm_drum_9_a
5AEE  func  pcm_drum_9_b
5B02  func  pcm_drum_9_c
5B16  func  pcm_drum_9_d
5B27  func  pcm_drum_9_e
5B2D  func  pcm_drum_a_1
5B41  func  pcm_drum_a_2
5B55  func  pcm_drum_a_3
5B6F  func  pcm_drum_a_4
5B89  func  pcm_drum_a_5
5BA3  func  pcm_drum_a_6
5BBD  func  pcm_drum_a_7
5BD1  func  pcm_drum_a_8
5BE5  func  pcm_drum_a_9
5BF9  func  pcm_drum_a_a
5C0D  func  pcm_drum_a_b
5C21  func  pcm_drum_a_c
5C35  func  pcm_drum_a_d
5C49  func  pcm_drum_a_e
5C5D  func  pcm_drum_a_f
5C71  func  pcm_drum_b_1
5C85  func  pcm_drum_b_2
5C99  func  pcm_drum_b_3
5CB3  func  pcm_drum_b_4
5CCD  func  pcm_drum_b_5
5CE7  func  pcm_drum_b_6
5D01  func  pcm_drum_b_7
5D15  func  pcm_drum_b_8
5D29  func  pcm_drum_b_9
5D3D  func  pcm_drum_b_a
5D51  func  pcm_drum_b_b
5D65  func  pcm_drum_b_c
5D79  func  pcm_drum_b_d
5D8D  func  pcm_drum_b_e
5DA1  func  pcm_drum_b_f
2799  file  unused_effects  # a group of four FM effects no command reaches (unused_effect_group)

# ======== the FM effects (fm_effects.c) and the unused group 3C-3F (unused_effects.c): the names, families, patches and comments ========
# ======== the FM effects (fm_effects.c) and the unused group (unused_effects.c): proposed lines ========
# How the chains' numbers read (set_pitch 0DF0-0E0D "ld a,h; and $1F; sub $18 ... add hl,hl; add hl,hl; ld c,l; ld b,$30
# ... ld c,h; ld hl,$0E10; add hl,bc"): the pitch word is in 64ths of a semitone. Its top 10 bits are the note of
# note_codes (8 octaves of 12: the high byte's 5 low bits wrap at 24, 4 notes each), its low 6 bits the key fraction
# (register 30). So 40 is a semitone, 300 an octave, 600 two octaves; past the 8 octaves the note wraps to the bottom.
# The comments give pitches and attenuations as the C prints them, in hex (pitch C00, attenuation 2C), and the steps
# and counts in decimal (a quarter semitone, 24 quieter, 48 passes).
# A key on while the channel's key is still on does not start the YM2151's envelope again (ymfm keys an operator on
# when its key bit changes): the chains that key on again without a key off (the retrigger of fm_effect_05, 19, 1a,
# 23, 2c-2e, 2f, 30, 33, 34-38) go on with the sounding note at its new pitch, they do not strike it again.
# start_sound (01CC-01E2) gives every FM effect volume 0 (the loudest), keyed off, released at the fastest.

# ---- FM effect 01 (and 02: 01 after 48 passes) ----
comment fm_effect_02 Effect 01's sound after 48 passes.
comment fm_effect_02_delay Counts down the 48 passes, then starts effect 01 (fm_effect_01).
comment fm_effect_01 Loads fm_effect_01_patch and keys on pitch 600, for 42 rounds of 32 passes that climb (fm_effect_01_retrigger) and then 42 that fall (fm_effect_01_pitch).
comment fm_effect_01_retrigger The climbing half: the pitch an eighth of a semitone higher each pass; after each 32 passes it drops 3 1/4 semitones, so that each round starts 3/4 of a semitone above the last. After 42 rounds the note is keyed off and on again for the falling half (fm_effect_01_pitch).
comment fm_effect_01_pitch The falling half, the mirror of the climbing one: an eighth of a semitone lower each pass and 3 1/4 semitones up after each 32, for 42 rounds; then stop_channel.
comment fm_effect_01_move_pitch Adds the step to the pitch and sets it; counts the timer down and tells whether it ran out.
# 1108 "ld de,$0008; call $1149", 110F "ld de,$FF30", 1131 "ld de,$FFF8", 1138 "ld de,$00D0"; 1149-1156 "ld l,(ix+$02); ld
# h,(ix+$03); add hl,de; ld (ix+$02),l; ld (ix+$03),h; call $0DE8": DE is added to the pitch (the step)
param fm_effect_01_move_pitch de step

# ---- FM effect 03 (and 04: 03 after 16 passes) ----
# fm_effect_01 10E5 "ld hl,$10BE; call $0C68" and the same in each chain below: the patch load_patch reads (25 bytes,
# connection C4: algorithm 4, both outputs)
115D  table  fm_effect_03_patch  fm_patch
comment fm_effect_04 Effect 03's sound after 16 passes.
comment fm_effect_04_delay Counts down the 16 passes, then starts effect 03 (fm_effect_03).
comment fm_effect_03 Loads fm_effect_03_patch and keys on pitch F00, for 16 rounds of 32 passes (fm_effect_03_pitch).
# 11A1 "ld (ix+$04),$00": the rounds, which no handler of the chain reads (fm_effect_03_pitch counts its rounds in the
# count: 11BF "dec (ix+$00)")
comment fm_effect_03_pitch Each pass the pitch an eighth of a semitone lower; after each 32 passes it jumps 2 3/4 semitones up, so that each round starts 1 1/4 semitones below the last; after 16 rounds stop_channel.
comment fm_effect_03_move_pitch Adds the step to the pitch and sets it.
# 11AB "ld de,$FFF8; call $11C6", 11B9 "ld de,$00B0"; 11C6-11D3 "ld l,(ix+$02) ... add hl,de ... jp $0DE8"
param fm_effect_03_move_pitch de step

# ---- FM effect 05 (and 06: its notes 112 passes later, from attenuation 20) ----
# fm_effect_05_note 120C "ld hl,$11D6; call $0C68" (connection FC: algorithm 4, feedback 7)
11D6  table  fm_effect_05_patch  fm_patch
# fm_effect_05 1208 "ld (ix+$04),$18", fm_effect_06 11EF-11F4 "ld a,$20; ld (ix+$04),a; call $0D72"; fm_effect_05_slide
# 1251-1259 "ld a,(ix+$04); add a,$18; ld (ix+$04),a; call $0D72" (set_volume): the attenuation the notes step through
scoped  channel fm_effect_05 04 attenuation u8
# fm_effect_06 11EF-11F4 (above), then 1205 "jp $120C" into fm_effect_05_note: the same byte
scoped  channel fm_effect_06 04 attenuation u8
comment fm_effect_06 Effect 05's notes after 112 passes, from attenuation 20 (then 38, 50 and 68).
comment fm_effect_06_delay Counts down the 112 passes, then effect 05's notes (fm_effect_05_note).
comment fm_effect_05 Four notes, at the volume start_sound leaves (0) and then at attenuations 30, 48 and 60 (fm_effect_05_note, the attenuation set at 18).
comment fm_effect_05_note Loads fm_effect_05_patch, then the note four times (fm_effect_05_retrigger).
comment fm_effect_05_retrigger Sets pitch 800 and keys on, for 128 passes of fm_effect_05_slide.
comment fm_effect_05_slide The pitch a quarter semitone higher each pass, played 28 semitones higher in turn every 32 passes; after the 128 passes 24 quieter (set_volume) and the next time (fm_effect_05_retrigger), and stop_channel after the fourth.

# ---- FM effect 07 ----
1265  table  fm_effect_07_patch  fm_patch
# fm_effect_07 1293-1299 "ld hl,$0400; ld (ix+$00),l; ld (ix+$01),h"; fm_effect_07_slide 12B5-12C4 "ld l,(ix+$00); ld
# h,(ix+$01); dec hl; ld (ix+$00),l; ld (ix+$01),h; ld a,l; or h; ret nz": the passes left, a word
scoped  channel fm_effect_07 00 passes u16
comment fm_effect_07 Loads fm_effect_07_patch and keys on pitch 1800, for 1024 passes of fm_effect_07_slide.
comment fm_effect_07_slide The pitch a 64th of a semitone lower each pass (16 semitones in the 1024 passes); then stop_channel.

# ---- FM effect 08 (and 09: 08 after 12 passes) ----
12C8  table  fm_effect_08_patch  fm_patch
# fm_effect_08 1305-130B "ld hl,$12E1; ld (ix+$00),l; ld (ix+$01),h"; fm_effect_08_retrigger 1323-1330 "ld l,(ix+$00);
# ld h,(ix+$01); ld e,(hl); inc hl; ld d,(hl); inc hl; ld (ix+$00),l; ld (ix+$01),h", 1339 "ex de,hl; call $0DE8":
# the place of the next pitch the effect plays (kref --sound-rom-reads: 1329 reads 12E1-12EF)
scoped  channel fm_effect_08 00 next_pitch u16
# fm_effect_08 130E "ld (ix+$02),$01", fm_effect_08_retrigger 1318 "dec (ix+$02); ret nz", 131F "ld (ix+$02),$18",
# fm_effect_08_hold 134A "dec (ix+$02)": the passes left of a note, one byte
scoped  channel fm_effect_08 02 timer u8
# fm_effect_09 12F1 "ld (ix+$02),$0C", fm_effect_09_delay 12FB "dec (ix+$02); ret nz", then fm_effect_08: the same byte
scoped  channel fm_effect_09 02 timer u8
# the pitches fm_effect_08_retrigger plays (1305 "ld hl,$12E1", 1329-132B "ld e,(hl); inc hl; ld d,(hl)"): 0BC0 0D80
# 0E80 0EC0 0D80 0EC0 0FC0, and FFFF, which ends them (1333 "ld a,d; cp $FF"); one effect steps through them, not two
comment fm_effect_09 Effect 08's notes after 12 passes.
comment fm_effect_09_delay Counts down the 12 passes (in the timer effect 08 then uses), then starts effect 08 (fm_effect_08).
comment fm_effect_08 Loads fm_effect_08_patch and plays the 7 notes of fm_effect_08_pitches from the next pass (fm_effect_08_retrigger).
comment fm_effect_08_retrigger Every 24 passes, key off and the next pitch of fm_effect_08_pitches keyed on; at the list's end (a word FFxx) the last note's release for 256 passes (fm_effect_08_hold).
comment fm_effect_08_hold Counts down the 256 passes, then stop_channel.
# 1329 "ld e,(hl)", 132B "ld d,(hl)", then 1333 "ld a,d; cp $FF" and 1339 "ex de,hl; call $0DE8": the next pitch's bytes
local fm_effect_08_retrigger 1329 e pitch_low
local fm_effect_08_retrigger 132B d pitch_high

# ---- FM effect 0C (and 0D: 0C after 16 passes) ----
1351  table  fm_effect_0c_patch  fm_patch
comment fm_effect_0d Effect 0C's notes after 16 passes.
comment fm_effect_0d_delay Counts down the 16 passes, then starts effect 0C (fm_effect_0c).
comment fm_effect_0c Loads fm_effect_0c_patch and keys on pitch 1300: six notes of 24 passes, 8 semitones down and 2 up in turn (fm_effect_0c_retrigger), the last one held.
comment fm_effect_0c_retrigger After the 24 passes, the note 8 semitones lower (fm_effect_0c_move_pitch); then fm_effect_0c_retrigger_2.
comment fm_effect_0c_retrigger_2 After the 24 passes, the note 2 semitones higher and fm_effect_0c_retrigger again; the third time the note instead goes on 256 passes more (fm_effect_0c_hold).
comment fm_effect_0c_hold Counts down the 256 passes, then stop_channel.
comment fm_effect_0c_move_pitch Keys off, moves the pitch by the step, sets it and keys on again, for 24 passes.
# 139F "ld de,$FE00; call $13D2", 13B5 "ld de,$0080"; 13D5-13E2 "ld l,(ix+$02) ... add hl,de ... call $0DE8"
param fm_effect_0c_move_pitch de step

# ---- FM effect 0E ----
13EC  table  fm_effect_0e_patch  fm_patch
# 1440-1450 "ld de,$FA00 ... add hl,de ... call $0DE8; ld (ix+$01),$40": a jump 24 semitones down that starts each of the
# rising sweeps (fm_effect_0e_pitch_3 1467 "jp nz,$1440"), no slide
comment fm_effect_0e Loads fm_effect_0e_patch and keys on pitch 1400: a dive of 4 octaves, a climb, then 8 rising sweeps of 2 octaves (fm_effect_0e_pitch).
comment fm_effect_0e_pitch The dive: a semitone lower each pass for 48 passes; then 96 passes of fm_effect_0e_pitch_2.
comment fm_effect_0e_pitch_2 The climb: 3/8 of a semitone higher each pass for the 96 passes, the first 33 played 28 semitones higher; then the first sweep (fm_effect_0e_round).
comment fm_effect_0e_round Starts a sweep: the pitch 24 semitones lower, for 64 passes of fm_effect_0e_pitch_3.
comment fm_effect_0e_pitch_3 The sweep: 3/8 of a semitone higher each pass for the 64 passes (back where it started), the first pass 28 semitones higher; after 8 sweeps (fm_effect_0e_round) stop_channel.
comment fm_effect_0e_move_pitch Adds the step to the pitch and sets it, 28 semitones higher while the timer is 64 or more; counts the timer down and tells whether it ran out.
# 1428 "ld de,$FFC0; call $146D", 1439 "ld de,$0018", 145D "ld de,$0018"; 146D-1473 "ld l,(ix+$02) ... add hl,de"
param fm_effect_0e_move_pitch de step

# ---- FM effect 0F ----
# 14A5 "ld hl,$148C; call $0C68": the same 25 bytes as fm_effect_0e_patch
148C  table  fm_effect_0f_patch  fm_patch
comment fm_effect_0f Loads fm_effect_0f_patch (fm_effect_0e_patch's bytes) and keys on pitch C00, for 8 rounds of 64 passes (fm_effect_0f_slide).
comment fm_effect_0f_slide The pitch 3/8 of a semitone higher each pass, played 16 semitones higher in turn every 16 passes; after each 64 passes it drops 16 semitones, so that each round starts 7 5/8 semitones above the last; after 8 rounds stop_channel.

# ---- FM effect 10 ----
1509  table  fm_effect_10_patch  fm_patch
comment fm_effect_10 Loads fm_effect_10_patch and keys on pitch 1000, for 8 rounds of 64 passes (fm_effect_10_slide).
comment fm_effect_10_slide The pitch a semitone higher each pass, played 4 semitones higher in turn every 8 passes; after each 64 passes it drops 16 semitones; after 8 rounds stop_channel. It climbs past the top of the 8 octaves, where set_pitch starts again from the bottom.

# ---- FM effect 11 ----
1586  table  fm_effect_11_patch  fm_patch
# fm_effect_11 15B4-15BA "ld hl,$0200; ld (ix+$00),l; ld (ix+$01),h"; fm_effect_11_pitch 15C9-15D8 "ld l,(ix+$00) ...
# dec hl ... ld a,h; or l; ret nz": the passes left, a word; fm_effect_11_move_pitch 15E9 "bit 1,(ix+$00)" reads its
# low byte alone
scoped  channel fm_effect_11 00 passes u16
scoped  channel fm_effect_11 00 passes_low u8
comment fm_effect_11 Loads fm_effect_11_patch and keys on pitch 1700, for 512 passes of fm_effect_11_pitch.
comment fm_effect_11_pitch A trill sliding down: the pitch an eighth of a semitone lower each pass (64 semitones in the 512 passes, fm_effect_11_move_pitch); then stop_channel.
comment fm_effect_11_move_pitch Adds the step to the pitch and sets it, 4 semitones higher in turn every 2 passes (by the passes left).
# 15C3 "ld de,$FFF8; call $15DC"; 15DC-15E2 "ld l,(ix+$02); ld h,(ix+$03); add hl,de"
param fm_effect_11_move_pitch de step

# ---- FM effect 12 ----
15F7  table  fm_effect_12_patch  fm_patch
# fm_effect_12 1616-161F "ld hl,$0400; ld (ix+$00),l; ld (ix+$01),h; call $0DE8"; fm_effect_12_slide 1651-1669 "ld
# l,(ix+$00); ld h,(ix+$01); dec hl; dec hl; ld (ix+$00),l; ld (ix+$01),h ... call $0DE8": the pitch is at 00 here
scoped  channel fm_effect_12 00 pitch u16
# fm_effect_12 1625-1629 "ld (ix+$02),$00; ld (ix+$03),$03"; fm_effect_12_delay 1633-1642 "ld l,(ix+$02); ld
# h,(ix+$03); dec hl ... ret nz", 1643-1647 "ld (ix+$02),$A0; ld (ix+$03),$01"; fm_effect_12_slide 165F "bit
# 0,(ix+$02)", 166C-167B "dec hl ... ret nz": the passes left, a word, its low byte read alone
scoped  channel fm_effect_12 02 passes u16
scoped  channel fm_effect_12 02 passes_low u8
comment fm_effect_12 Loads fm_effect_12_patch and keys on pitch 400, held 768 passes (fm_effect_12_delay).
comment fm_effect_12_delay Counts down the 768 passes, then 416 passes of fm_effect_12_slide.
comment fm_effect_12_slide The pitch a 32nd of a semitone lower each pass (13 semitones in the 416 passes), played 3 semitones lower every other pass; then stop_channel.

# ---- FM effect 13 ----
167F  table  fm_effect_13_patch  fm_patch
# fm_effect_13 169E-16A8 "ld hl,$0700; ld (ix+$00),$00; ld (ix+$01),l; ld (ix+$02),h; call $0DE8": the pitch at 01, a
# word, and below it a byte of fraction; fm_effect_13_slide 16BF-16D1 "ld l,(ix+$00); ld h,(ix+$01); ld de,$01E0; add
# hl,de; ld (ix+$00),l; ld (ix+$01),h; jr nc; inc (ix+$02)": fraction and pitch climb as one number; 16D4-16E4 "ld
# l,(ix+$01); ld h,(ix+$02) ... call $0DE8"
scoped  channel fm_effect_13 00 pitch_fraction u8
scoped  channel fm_effect_13 01 pitch u16
# fm_effect_13 16B1-16B5 "ld (ix+$03),$00; ld (ix+$04),$01"; 16DA "bit 0,(ix+$03)", 16E7-16F6 "ld l,(ix+$03); ld
# h,(ix+$04); dec hl; ld a,l; or h ... ret nz": the passes left, a word, its low byte read alone
scoped  channel fm_effect_13 03 passes u16
scoped  channel fm_effect_13 03 passes_low u8
# 1705-1733: it holds the trill without moving it (no add to the pitch) for 320 passes, then keys off: a hold, no slide;
# 173C-1758: the trill falls after the key off
comment fm_effect_13 Loads fm_effect_13_patch and keys on pitch 700, for 256 passes of fm_effect_13_slide.
comment fm_effect_13_slide A rising trill: the pitch with its fraction up 1E0 each pass (7 1/2 semitones in the 256 passes), played 8 semitones higher every other pass; then 320 passes of fm_effect_13_hold.
comment fm_effect_13_hold The trill held for the 320 passes; then key off, and 192 passes of fm_effect_13_fall while the note dies away.
comment fm_effect_13_fall The trill falls: the pitch 6 lower each pass (18 semitones in the 192 passes), 8 semitones higher every other pass; then stop_channel.

# ---- FM effect 14 ----
176E  table  fm_effect_14_patch  fm_patch
# fm_effect_14 178D-1796 "ld hl,$0200; ld (ix+$00),l; ld (ix+$01),l; ld (ix+$02),h", 179F-17A3 "ld (ix+$03),$00; ld
# (ix+$04),$02"; fm_effect_14_slide 17AD-17C3 "ld de,$00C0; add hl,de; jr nc; inc (ix+$02) ... ld l,h; ld h,(ix+$02)",
# 17C6 "bit 0,(ix+$03)", 17D3-17E2 "dec hl ... ret nz": the layout of fm_effect_13
scoped  channel fm_effect_14 00 pitch_fraction u8
scoped  channel fm_effect_14 01 pitch u16
scoped  channel fm_effect_14 03 passes u16
scoped  channel fm_effect_14 03 passes_low u8
# 17F4-1817: the trill without moving the pitch, after the key off (17E3): a hold, no slide
comment fm_effect_14 Loads fm_effect_14_patch and keys on pitch 200, for 512 passes of fm_effect_14_slide.
comment fm_effect_14_slide A rising trill: the pitch with its fraction up C0 each pass (6 semitones in the 512 passes), played 2 semitones higher every other pass; then key off and 2560 passes of fm_effect_14_hold.
comment fm_effect_14_hold The trill goes on without moving while the note dies away, for the 2560 passes; then stop_channel.

# ---- FM effect 15 ----
181A  table  fm_effect_15_patch  fm_patch
# fm_effect_15_note 187C "ld hl,$1833; call $0C68"
1833  table  fm_effect_15_patch_2  fm_patch
# fm_effect_15 185B-185F "ld (ix+$00),$00; ld (ix+$01),$03"; fm_effect_15_note 1869-1878 "ld l,(ix+$00); ld
# h,(ix+$01); dec hl ... ret nz": the passes before the second note, a word
scoped  channel fm_effect_15 00 passes u16
# fm_effect_15_note 1891 "ld (ix+$02),$B0"; fm_effect_15_slide 18AB "bit 0,(ix+$02)", 18B8 "dec (ix+$02); jp z,$0C22":
# the passes left of the slide, one byte
scoped  channel fm_effect_15 02 timer u8
# fm_effect_15_note 1882-188B "ld hl,$0300; ld (ix+$00),l; ld (ix+$01),h; call $0DE8"; fm_effect_15_slide 189B-18B5 "ld
# l,(ix+$00); ld h,(ix+$01); ld de,$FFFC; add hl,de ... call $0DE8": the same word then holds the second note's pitch
scoped  channel fm_effect_15_slide 00 pitch u16
# (fm_effect_15_note writes the second note's pitch into the passes' word: the same two bytes are a count, then a pitch)
comment fm_effect_15 Loads fm_effect_15_patch and keys on pitch 400 for 768 passes (fm_effect_15_note).
comment fm_effect_15_note After the 768 passes, key off and a second note: fm_effect_15_patch_2 at pitch 300 (kept in the word that counted the passes), for 176 passes of fm_effect_15_slide.
comment fm_effect_15_slide The pitch a 16th of a semitone lower each pass, played 10 semitones higher every other pass; after the 176 passes stop_channel.

# ---- FM effect 16 (and 17: 16 after 44 passes, at attenuation 0A) ----
18BF  table  fm_effect_16_patch  fm_patch
comment fm_effect_17 Effect 16's sound after 44 passes, at attenuation 0A.
comment fm_effect_17_delay Counts down the 44 passes, then starts effect 16 (fm_effect_16).
# 1908 "ld (ix+$04),$00": the rounds, which no handler of the chain reads (fm_effect_16_pitch counts in the count)
comment fm_effect_16 Loads fm_effect_16_patch and keys on pitch 600, for 11 rounds of 48 passes (fm_effect_16_pitch).
comment fm_effect_16_pitch The pitch a quarter semitone higher each pass; after each 48 passes (an octave) it drops 8 semitones, so that each round starts 4 semitones above the last; after 11 rounds stop_channel.
comment fm_effect_16_move_pitch Adds the step to the pitch and sets it.
# 1912 "ld de,$0010; call $192D", 1920 "ld de,$FE00"; 192D-1933 "ld l,(ix+$02) ... add hl,de"
param fm_effect_16_move_pitch de step

# ---- FM effect 18 ----
193D  table  fm_effect_18_patch  fm_patch
# fm_effect_18 195C-1965 "ld hl,$0800; ld (ix+$01),l; ld (ix+$02),h; call $0DE8"; fm_effect_18_slide 197B-1996 "ld
# l,(ix+$01); ld h,(ix+$02); ld de,$0020; add hl,de; ld (ix+$01),l; ld (ix+$02),h ... jp $0DE8": the pitch at 01 here
scoped  channel fm_effect_18 01 pitch u16
comment fm_effect_18 Loads fm_effect_18_patch and keys on pitch 800, for 112 passes of fm_effect_18_slide.
comment fm_effect_18_slide The pitch half a semitone higher each pass, played an octave higher in turn every 16 passes; after the 112 passes stop_channel.

# ---- FM effect 19 ----
1999  table  fm_effect_19_patch  fm_patch
# fm_effect_19 19BC "ld (ix+$04),$0B"; fm_effect_19_slide 19FB-1A03 "ld a,(ix+$04); add a,$0B; ld (ix+$04),a; call
# $0D72" (set_volume): the attenuation
scoped  channel fm_effect_19 04 attenuation u8
comment fm_effect_19 Loads fm_effect_19_patch: a falling note four times (fm_effect_19_retrigger), at the volume start_sound leaves (0) and then at attenuations 16, 21 and 2C.
comment fm_effect_19_retrigger Sets pitch 1300 and keys on, for 64 passes of fm_effect_19_slide.
comment fm_effect_19_slide The pitch a quarter semitone lower each pass, played an octave higher in turn every 16 passes; after the 64 passes 11 quieter (set_volume) and the next time (fm_effect_19_retrigger), and stop_channel after the fourth.

# ---- FM effect 1A ----
1A0F  table  fm_effect_1a_patch  fm_patch
comment fm_effect_1a Loads fm_effect_1a_patch: a falling note three times (fm_effect_1a_retrigger).
comment fm_effect_1a_retrigger Sets pitch 1400 and keys on, for 256 passes of fm_effect_1a_slide.
comment fm_effect_1a_slide The pitch an eighth of a semitone lower each pass (32 semitones in the 256 passes), played an octave higher in turn every 32 passes; then the next time (fm_effect_1a_retrigger), and stop_channel after the third.

# ---- FM effect 1B ----
1A76  table  fm_effect_1b_patch  fm_patch
comment fm_effect_1b Loads fm_effect_1b_patch and keys on pitch 1400, for 64 passes of fm_effect_1b_pitch.
comment fm_effect_1b_pitch A fast fall: the pitch 7/8 of a semitone lower each pass (56 semitones in the 64 passes); then 224 passes of fm_effect_1b_pitch_2.
comment fm_effect_1b_pitch_2 A slow climb back to where it started: a quarter semitone higher each pass for the 224 passes; then stop_channel.
comment fm_effect_1b_move_pitch Adds the step to the pitch and sets it, an octave higher in turn every 32 passes (while bit 5 of the timer is clear); counts the timer down and tells whether it ran out.
# 1AAE "ld de,$FFC8; call $1AC9", 1ABF "ld de,$0010"; 1AC9-1ACF "ld l,(ix+$02) ... add hl,de"
param fm_effect_1b_move_pitch de step

# ---- FM effect 1C ----
1AE8  table  fm_effect_1c_patch  fm_patch
# 1B3C-1B4C "ld de,$FE00 ... add hl,de ... call $0DE8; ld (ix+$01),$40": a jump 8 semitones down that starts each of
# the short rises (fm_effect_1c_pitch_3 1B63 "jp nz,$1B3C"), no slide
comment fm_effect_1c Loads fm_effect_1c_patch and keys on pitch 1500: a fall, a climb and 4 short rises (fm_effect_1c_pitch).
comment fm_effect_1c_pitch The fall: 1 1/4 semitones lower each pass for 48 passes; then 64 passes of fm_effect_1c_pitch_2.
comment fm_effect_1c_pitch_2 The climb: half a semitone higher each pass for the 64 passes; then the first short rise (fm_effect_1c_round).
comment fm_effect_1c_round Starts a short rise: the pitch 8 semitones lower, for 64 passes of fm_effect_1c_pitch_3.
comment fm_effect_1c_pitch_3 An eighth of a semitone higher each pass for the 64 passes (back where it started); after 4 rises (fm_effect_1c_round) stop_channel.
comment fm_effect_1c_move_pitch Adds the step to the pitch and sets it, 28 semitones higher in turn every 16 passes (while bit 4 of the timer is set); counts the timer down and tells whether it ran out.
# 1B24 "ld de,$FFB0; call $1B69", 1B35 "ld de,$0020", 1B59 "ld de,$0008"; 1B69-1B6F "ld l,(ix+$02) ... add hl,de"
param fm_effect_1c_move_pitch de step

# ---- FM effect 1D ----
1B88  table  fm_effect_1d_patch  fm_patch
comment fm_effect_1d Loads fm_effect_1d_patch and keys on pitch 1500: a fall, then 10 short falls from pitch C00 (fm_effect_1d_pitch).
comment fm_effect_1d_pitch The fall: 1 1/4 semitones lower each pass for 48 passes; then the first of 10 short falls (fm_effect_1d_pitch_2).
comment fm_effect_1d_pitch_2 Starts a short fall: pitch C00, for 32 passes of fm_effect_1d_pitch_3.
comment fm_effect_1d_pitch_3 A quarter semitone lower each pass for the 32 passes; after 10 falls (fm_effect_1d_pitch_2) stop_channel.
comment fm_effect_1d_move_pitch Adds the step to the pitch and sets it, 4 semitones higher while bit 5 of the timer is set; counts the timer down and tells whether it ran out.
# 1BC0 "ld de,$FFB0; call $1BF1", 1BE1 "ld de,$FFF0"; 1BF1-1BF7 "ld l,(ix+$02) ... add hl,de"
param fm_effect_1d_move_pitch de step

# ---- FM effect 1E ----
# 1C29 "ld hl,$1C10; call $0C68": the same 25 bytes as fm_effect_18_patch
1C10  table  fm_effect_1e_patch  fm_patch
# fm_effect_1e 1C2F-1C38 "ld hl,$1500; ld (ix+$01),l; ld (ix+$02),h; call $0DE8"; fm_effect_1e_slide 1C4E-1C69 "ld
# l,(ix+$01); ld h,(ix+$02); ld de,$FFD8; add hl,de; ld (ix+$01),l; ld (ix+$02),h ... jp $0DE8": the pitch at 01
scoped  channel fm_effect_1e 01 pitch u16
comment fm_effect_1e Loads fm_effect_1e_patch (fm_effect_18_patch's bytes) and keys on pitch 1500, for 128 passes of fm_effect_1e_slide: effect 18's sound falling instead of rising.
comment fm_effect_1e_slide The pitch 5/8 of a semitone lower each pass, played an octave higher in turn every 16 passes; after the 128 passes stop_channel.

# ---- FM effect 1F ----
1C6C  table  fm_effect_1f_patch  fm_patch
# fm_effect_1f_retrigger 1CAE-1CB4 "ld hl,$0200; ld (ix+$00),l; ld (ix+$01),h"; fm_effect_1f_end 1CBD-1CCC "ld
# l,(ix+$00); ld h,(ix+$01); dec hl ... ret nz": the passes left, a word; before it fm_effect_1f 1C94 "ld
# (ix+$00),$40" and fm_effect_1f_retrigger 1C9E "dec (ix+$00); ret nz" count the first note's passes in its low byte
# alone
scoped  channel fm_effect_1f 00 passes u16
scoped  channel fm_effect_1f 00 passes_low u8
comment fm_effect_1f Loads fm_effect_1f_patch and keys on pitch D00 for 64 passes (fm_effect_1f_retrigger).
comment fm_effect_1f_retrigger After the 64 passes, key off and pitch 1000 keyed on, for 512 passes of fm_effect_1f_end.
comment fm_effect_1f_end Counts down the 512 passes, then stop_channel.

# ---- FM effect 20 ----
1CD0  table  fm_effect_20_patch  fm_patch
# fm_effect_20 1CEF-1CF8 "ld hl,$1700; ld (ix+$01),l; ld (ix+$02),h; call $0DE8"; fm_effect_20_move_pitch 1D23-1D3B "ld
# l,(ix+$01); ld h,(ix+$02); add hl,de; ld (ix+$01),l; ld (ix+$02),h ... call $0DE8": the pitch at 01
scoped  channel fm_effect_20 01 pitch u16
comment fm_effect_20 Loads fm_effect_20_patch and keys on pitch 1700, for 48 passes of fm_effect_20_pitch.
comment fm_effect_20_pitch The fall: 1 1/2 semitones lower each pass for the 48 passes; then 64 passes of fm_effect_20_pitch_2.
comment fm_effect_20_pitch_2 The climb: a semitone higher each pass for the 64 passes; then stop_channel.
comment fm_effect_20_move_pitch Adds the step to the pitch and sets it, 8 semitones higher in turn every 8 passes; counts the count down and tells whether it ran out.
# 1D08 "ld de,$FFA0; call $1D23", 1D19 "ld de,$0040"; 1D23-1D29 "ld l,(ix+$01); ld h,(ix+$02); add hl,de"
param fm_effect_20_move_pitch de step

# ---- FM effect 21 ----
1D42  table  fm_effect_21_patch  fm_patch
# fm_effect_21 1D6A-1D70 "ld hl,$0180; ld (ix+$00),l; ld (ix+$01),h"; fm_effect_21_end 1D79-1D88 "ld l,(ix+$00); ld
# h,(ix+$01); dec hl; ld (ix+$01),h; ld (ix+$00),l; ld a,l; or h; ret nz": the passes left, a word
scoped  channel fm_effect_21 00 passes u16
comment fm_effect_21 Loads fm_effect_21_patch and keys on pitch 600 for 384 passes (fm_effect_21_end).
comment fm_effect_21_end Counts down the 384 passes, then stop_channel.

# ---- FM effect 22 ----
1D8C  table  fm_effect_22_patch  fm_patch
# fm_effect_22 1DBA "ld (ix+$00),$18", 1DBE "ld (ix+$01),$0A"; fm_effect_22_slide 1DC8 "dec (ix+$00); jp nz" (the
# passes of a fall), 1DCE-1DD5 "ld (ix+$00),$18; dec (ix+$01); jp z,$0C22" (the falls): the other way round from
# the count and timer of most chains
scoped  channel fm_effect_22 00 timer u8
scoped  channel fm_effect_22 01 count u8
comment fm_effect_22 Loads fm_effect_22_patch and keys on pitch 1500: 10 falls of 24 passes (fm_effect_22_slide).
comment fm_effect_22_slide The pitch 4 3/4 semitones lower each pass; every 24 passes back to pitch 1500, 10 times; then stop_channel.

# ---- FM effect 23 ----
1DF3  table  fm_effect_23_patch  fm_patch
comment fm_effect_23 Loads fm_effect_23_patch: a falling trill three times (fm_effect_23_retrigger).
comment fm_effect_23_retrigger Sets pitch 1400 and keys on, for 128 passes of fm_effect_23_slide.
comment fm_effect_23_slide The pitch 5/16 of a semitone lower each pass (40 semitones in the 128 passes), played 4 semitones higher in turn every 2 passes; then the next time (fm_effect_23_retrigger), and stop_channel after the third.

# ---- FM effect 24 (and 25: its copy, 8 passes later and an eighth of a semitone higher) ----
1E5A  table  fm_effect_24_patch  fm_patch
# fm_effect_24 1E88 "ld (ix+$00),$20", 1E8C "ld (ix+$01),$08"; fm_effect_24_retrigger 1E96 "dec (ix+$00); ret nz" (the
# passes of a note), 1E9D "dec (ix+$01); jp z,$1EBD" (the notes): the other way round from most chains
scoped  channel fm_effect_24 00 timer u8
scoped  channel fm_effect_24 01 count u8
comment fm_effect_24 Loads fm_effect_24_patch and keys on pitch B00: 8 notes of 32 passes, each 5 semitones higher (fm_effect_24_retrigger).
comment fm_effect_24_retrigger Every 32 passes, key off and the next note 5 semitones higher, keyed on; after the eighth, its release for 256 passes (fm_effect_24_hold).
comment fm_effect_24_hold Counts down the 256 passes, then stop_channel.
# fm_effect_25_note 1EF5 "ld hl,$1ECE; call $0C68": the same 25 bytes as fm_effect_24_patch
1ECE  table  fm_effect_25_patch  fm_patch
# fm_effect_25 1EE7 "ld (ix+$00),$08", fm_effect_25_note 1EF1 "dec (ix+$00)", 1F0A-1F0E "ld (ix+$00),$20; ld
# (ix+$01),$08"; fm_effect_25_retrigger 1F18 "dec (ix+$00)", 1F1F "dec (ix+$01)": fm_effect_24's layout
scoped  channel fm_effect_25 00 timer u8
scoped  channel fm_effect_25 01 count u8
comment fm_effect_25 Effect 24's notes 8 passes later and an eighth of a semitone higher (its own copy of the chain, and of the patch).
comment fm_effect_25_note After the 8 passes, loads fm_effect_25_patch and keys on pitch B08: 8 notes of 32 passes, each 5 semitones higher (fm_effect_25_retrigger).
comment fm_effect_25_retrigger Every 32 passes, key off and the next note 5 semitones higher, keyed on; after the eighth, its release for 256 passes (fm_effect_25_hold).
comment fm_effect_25_hold Counts down the 256 passes, then stop_channel.

# ---- FM effect 26 ----
1F50  table  fm_effect_26_patch  fm_patch
comment fm_effect_26 Loads fm_effect_26_patch and keys on pitch 1200: 3 rounds of two rises (fm_effect_26_transpose).
comment fm_effect_26_transpose Starts a round: the pitch 44 semitones lower, for 48 passes of fm_effect_26_slide.
comment fm_effect_26_slide A rise of 7/16 of a semitone a pass (fm_effect_26_move_pitch) for the 48 passes; then 4 semitones up and the second rise (fm_effect_26_pitch).
comment fm_effect_26_pitch The second rise, 48 passes more; after 3 rounds, each 2 semitones above the last, stop_channel.
comment fm_effect_26_move_pitch The pitch 7/16 of a semitone higher, set; counts the timer down and tells whether it ran out.

# ---- FM effect 27 ----
1FDE  table  fm_effect_27_patch  fm_patch
comment fm_effect_27 Loads fm_effect_27_patch and keys on pitch 17D8: 6 notes of 48 passes, each a semitone lower (fm_effect_27_retrigger).
comment fm_effect_27_retrigger Every 48 passes, key off and the next note a semitone lower, keyed on; after the sixth, its release for 128 passes (fm_effect_27_hold).
comment fm_effect_27_hold Counts down the 128 passes, then stop_channel.

# ---- FM effect 28 ----
2052  table  fm_effect_28_patch  fm_patch
comment fm_effect_28 Loads fm_effect_28_patch and keys on pitch 600, for 16 rounds of 32 passes (fm_effect_28_slide).
comment fm_effect_28_slide The pitch half a semitone higher each pass, played 8 semitones higher in turn every 16 passes; after each 32 passes it drops 15 5/8 semitones, so that each round starts 3/8 of a semitone above the last; after 16 rounds stop_channel.

# ---- FM effect 29 ----
20CB  table  fm_effect_29_patch  fm_patch
comment fm_effect_29 Loads fm_effect_29_patch and keys on pitch 1400: a fall, then 3 rises (fm_effect_29_pitch).
comment fm_effect_29_pitch The fall: 1 1/8 semitones lower each pass for 48 passes; then the 3 rises (fm_effect_29_setup).
comment fm_effect_29_setup Starts a rise of 64 passes (fm_effect_29_slide).
comment fm_effect_29_slide Half a semitone higher each pass for the 64 passes; then 24 semitones lower and the next rise (fm_effect_29_setup), each 8 semitones above the last; after the third stop_channel.
comment fm_effect_29_move_pitch Adds the step to the pitch and sets it; counts the timer down and tells whether it ran out.
# 2103 "ld de,$FFB8; call $2138", 2118 "ld de,$0020"; 2138-213E "ld l,(ix+$02) ... add hl,de"
param fm_effect_29_move_pitch de step

# ---- FM effect 2A (and 2B: 2A after 48 passes) ----
214C  table  fm_effect_2a_patch  fm_patch
comment fm_effect_2b Effect 2A's notes after 48 passes.
comment fm_effect_2b_delay Counts down the 48 passes, then starts effect 2A (fm_effect_2a).
comment fm_effect_2a Loads fm_effect_2a_patch and keys on pitch 1000: six notes of 24 passes, 6 semitones up and 2 down in turn (fm_effect_2a_retrigger), the last one held; effect 0C's figure, climbing.
comment fm_effect_2a_retrigger After the 24 passes, the note 6 semitones higher (fm_effect_2a_move_pitch); then fm_effect_2a_retrigger_2.
comment fm_effect_2a_retrigger_2 After the 24 passes, the note 2 semitones lower and fm_effect_2a_retrigger again; the third time the note instead goes on 256 passes more (fm_effect_2a_hold).
comment fm_effect_2a_hold Counts down the 256 passes, then stop_channel.
comment fm_effect_2a_move_pitch Keys off, moves the pitch by the step, sets it and keys on again, for 24 passes.
# 219A "ld de,$0180; call $21CD", 21B0 "ld de,$FF80"; 21D0-21D6 "ld l,(ix+$02) ... add hl,de"
param fm_effect_2a_move_pitch de step

# ---- FM effects 2C, 2D and 2E: one figure, 2D 32 passes later on the left, 2E 64 passes later on the right ----
21E7  table  fm_effect_2c_patch  fm_patch
# fm_effect_2d_note 22AF "ld hl,$2288; call $0C68": fm_effect_2c_patch's bytes but the connection 7C (left output only)
# and the first carrier's total level 12 (06): quieter
2288  table  fm_effect_2d_patch  fm_patch
# fm_effect_2e_note 235E "ld hl,$2337; call $0C68": as fm_effect_2d_patch, but the connection BC (right output only)
2337  table  fm_effect_2e_patch  fm_patch
# 2227-2245: every 48 passes the note 3 semitones higher (2234 "ld de,$00C0; jp nz,$2264"), and after 3 steps the last
# note; it plays the note every pass (222A "jp nz,$2274"): no delay
# 2248-2261: the note 4 semitones lower (2255 "ld de,$FF00") for 48 passes, then the next round (225E "jp nz,$220A")
# or stop_channel: the round's last step, no hold
# 2274-2277 "ld l,(ix+$02); ld h,(ix+$03)" then fm_effect_2c_slide: plays the kept pitch, sets nothing up
# 227A-2285 "bit 5,(ix+$01); jp z; ld de,$0700; add hl,de; jp $0DE8": sets the pitch it is given (28 semitones higher
# in each note's first 17 passes), no slide
comment fm_effect_2c Loads fm_effect_2c_patch: 5 rounds of a five-note figure (fm_effect_2c_retrigger).
comment fm_effect_2c_retrigger Starts a round: pitch C00 keyed on, 48 passes a note (fm_effect_2c_step_up).
comment fm_effect_2c_step_up Plays the note (fm_effect_2c_play); every 48 passes the next, 3 semitones higher (fm_effect_2c_transpose), three times; then the round's last note (fm_effect_2c_step_down).
comment fm_effect_2c_step_down The round's last note, 4 semitones lower, for 48 passes; then the next round (fm_effect_2c_retrigger), and stop_channel after the fifth.
comment fm_effect_2c_transpose Moves the pitch by the step and sets it (fm_effect_2c_set_pitch).
comment fm_effect_2c_play Sets the pitch (fm_effect_2c_set_pitch).
comment fm_effect_2c_set_pitch Sets the pitch it is given, 28 semitones higher while bit 5 of the timer is set: a high blip over the first 17 passes of each note.
comment fm_effect_2d Effect 2C's figure 32 passes later, a 16th of a semitone higher, quieter and on the left output only (fm_effect_2d_patch): its own copy of the chain.
comment fm_effect_2d_note After the 32 passes, loads fm_effect_2d_patch: 5 rounds of the figure (fm_effect_2d_retrigger).
comment fm_effect_2d_retrigger Starts a round: pitch C04 keyed on, 48 passes a note (fm_effect_2d_step_up).
comment fm_effect_2d_step_up Plays the note (fm_effect_2d_play); every 48 passes the next, 3 semitones higher (fm_effect_2d_transpose), three times; then the round's last note (fm_effect_2d_step_down).
comment fm_effect_2d_step_down The round's last note, 4 semitones lower, for 48 passes; then the next round (fm_effect_2d_retrigger), and stop_channel after the fifth.
comment fm_effect_2d_transpose Moves the pitch by the step and sets it (fm_effect_2d_set_pitch).
comment fm_effect_2d_play Sets the pitch (fm_effect_2d_set_pitch).
comment fm_effect_2d_set_pitch Sets the pitch it is given, 28 semitones higher while bit 5 of the timer is set: a high blip over the first 17 passes of each note.
# fm_effect_2e_patch sends the channel to the right output only, and the board wires only the YM2151's left one (MAME's
# simpsons.cpp; CLAUDE.md): effect 2E is never heard. The same for fm_effect_34_patch
comment fm_effect_2e Effect 2C's figure 64 passes later, an eighth of a semitone higher, quieter and on the right output only (fm_effect_2e_patch): its own copy of the chain.
comment fm_effect_2e_note After the 64 passes, loads fm_effect_2e_patch: 5 rounds of the figure (fm_effect_2e_retrigger).
comment fm_effect_2e_retrigger Starts a round: pitch C08 keyed on, 48 passes a note (fm_effect_2e_step_up).
comment fm_effect_2e_step_up Plays the note (fm_effect_2e_play); every 48 passes the next, 3 semitones higher (fm_effect_2e_transpose), three times; then the round's last note (fm_effect_2e_step_down).
comment fm_effect_2e_step_down The round's last note, 4 semitones lower, for 48 passes; then the next round (fm_effect_2e_retrigger), and stop_channel after the fifth.
comment fm_effect_2e_transpose Moves the pitch by the step and sets it (fm_effect_2e_set_pitch).
comment fm_effect_2e_play Sets the pitch (fm_effect_2e_set_pitch).
comment fm_effect_2e_set_pitch Sets the pitch it is given, 28 semitones higher while bit 5 of the timer is set: a high blip over the first 17 passes of each note.
# fm_effect_2c_step_up 2234 "ld de,$00C0; jp nz,$2264", fm_effect_2c_step_down 2255 "ld de,$FF00"; 2264-226A "ld
# l,(ix+$02); ld h,(ix+$03); add hl,de": added to the pitch
param fm_effect_2c_transpose de step
param fm_effect_2d_transpose de step
param fm_effect_2e_transpose de step
# 2271 "jp $227A" with HL the pitch just stored (2264-226E), 2274-2277 "ld l,(ix+$02); ld h,(ix+$03)"; 227A-2285 "...
# add hl,de; jp $0DE8" (set_pitch)
param fm_effect_2c_set_pitch hl pitch
param fm_effect_2d_set_pitch hl pitch
param fm_effect_2e_set_pitch hl pitch

# ---- FM effect 2F ----
23E6  table  fm_effect_2f_patch  fm_patch
# fm_effect_2f 2409 "ld (ix+$04),$0B"; fm_effect_2f_slide 2448-2450 "ld a,(ix+$04); add a,$0B; ld (ix+$04),a; call
# $0D72" (set_volume): the attenuation
scoped  channel fm_effect_2f 04 attenuation u8
comment fm_effect_2f Loads fm_effect_2f_patch: a falling note four times (fm_effect_2f_retrigger), at the volume start_sound leaves (0) and then at attenuations 16, 21 and 2C; effect 19's figure from pitch 1400, falling slower.
comment fm_effect_2f_retrigger Sets pitch 1400 and keys on, for 64 passes of fm_effect_2f_slide.
comment fm_effect_2f_slide The pitch 3/16 of a semitone lower each pass (an octave in the 64 passes), played an octave higher in turn every 16 passes; then 11 quieter (set_volume) and the next time (fm_effect_2f_retrigger), and stop_channel after the fourth.

# ---- FM effect 30 (and 31: 30 after 80 passes; 32: 31 after 32 more; 33: 30's copy an eighth of a semitone higher) ----
245C  table  fm_effect_30_patch  fm_patch
comment fm_effect_32 Effect 30's notes after 112 passes: 32 passes, then effect 31's 80.
comment fm_effect_32_delay Counts down the 32 passes, then starts effect 31 (fm_effect_31).
comment fm_effect_31 Effect 30's notes after 80 passes.
comment fm_effect_31_delay Counts down the 80 passes, then starts effect 30 (fm_effect_30).
comment fm_effect_30 Loads fm_effect_30_patch: 4 rounds of 8 notes, each a whole tone lower (fm_effect_30_retrigger).
comment fm_effect_30_retrigger Starts a round: pitch 1200 keyed on, 8 notes of 48 passes (fm_effect_30_retrigger_2).
comment fm_effect_30_retrigger_2 Every 48 passes, key off and the next note 2 semitones lower, keyed on; after the eighth the next round (fm_effect_30_retrigger), and stop_channel after the fourth.
# fm_effect_33 2501 "ld hl,$24E8; call $0C68": the same 25 bytes as fm_effect_30_patch
24E8  table  fm_effect_33_patch  fm_patch
comment fm_effect_33 Effect 30's notes an eighth of a semitone higher (its own copy of the chain, and of the patch).
comment fm_effect_33_retrigger Starts a round: pitch 1208 keyed on, 8 notes of 48 passes (fm_effect_33_retrigger_2).
comment fm_effect_33_retrigger_2 Every 48 passes, key off and the next note 2 semitones lower, keyed on; after the eighth the next round (fm_effect_33_retrigger), and stop_channel after the fourth.

# ---- FM effects 34 and 35: 35 its copy 32 passes later, on the left ----
# fm_effect_34 2571 "ld hl,$2558; call $0C68": connection BC, the right output only (never heard: see effect 2E)
2558  table  fm_effect_34_patch  fm_patch
# fm_effect_35_note 25E8 "ld hl,$25C1; call $0C68": fm_effect_34_patch's bytes but the connection 7C, the left output
25C1  table  fm_effect_35_patch  fm_patch
comment fm_effect_34 Loads fm_effect_34_patch (the right output only): 2 rounds of 8 slow rises (fm_effect_34_setup).
comment fm_effect_34_setup Starts a round of 8 rises (fm_effect_34_retrigger).
comment fm_effect_34_retrigger Sets pitch C00 and keys on, for 192 passes of fm_effect_34_slide.
comment fm_effect_34_slide The pitch a 32nd of a semitone higher each pass (6 semitones in the 192 passes); then the next rise (fm_effect_34_retrigger); after the eighth, key off and the next round (fm_effect_34_setup), and stop_channel after the second.
comment fm_effect_35 Effect 34's rises 32 passes later, on the left output only (fm_effect_35_patch): its own copy of the chain.
comment fm_effect_35_note After the 32 passes, loads fm_effect_35_patch: 2 rounds of 8 slow rises (fm_effect_35_setup).
comment fm_effect_35_setup Starts a round of 8 rises (fm_effect_35_retrigger).
comment fm_effect_35_retrigger Sets pitch C00 and keys on, for 192 passes of fm_effect_35_slide.
comment fm_effect_35_slide The pitch a 32nd of a semitone higher each pass (6 semitones in the 192 passes); then the next rise (fm_effect_35_retrigger); after the eighth, key off and the next round (fm_effect_35_setup), and stop_channel after the second.

# ---- FM effect 36 ----
2638  table  fm_effect_36_patch  fm_patch
comment fm_effect_36 Loads fm_effect_36_patch: 24 slow rises from pitch 600 (fm_effect_36_retrigger).
comment fm_effect_36_retrigger Sets pitch 600 and keys on, for 128 passes of fm_effect_36_slide.
comment fm_effect_36_slide The pitch a 32nd of a semitone higher each pass (4 semitones in the 128 passes); then the next rise (fm_effect_36_retrigger), and stop_channel after the 24th.

# ---- FM effect 37 ----
2694  table  fm_effect_37_patch  fm_patch
comment fm_effect_37 Loads fm_effect_37_patch: 5 rounds of a rising chromatic scale (fm_effect_37_retrigger).
comment fm_effect_37_retrigger Starts a round: pitch 1500 keyed on, 12 notes of 64 passes (fm_effect_37_slide).
comment fm_effect_37_slide Every 64 passes the pitch a semitone higher, not keyed again; after the twelfth note the next round (fm_effect_37_retrigger), and stop_channel after the fifth.

# ---- FM effect 38 ----
# 2717 "ld hl,$26FE; call $0C68": the same 25 bytes as fm_effect_19_patch; its first two bytes are also the second
# word of unused_effect_handlers_by_sound (26FC), whose elements before 2774 nothing reads
26FE  table  fm_effect_38_patch  fm_patch
# fm_effect_38 2721 "ld (ix+$04),$08"; fm_effect_38_slide 2760-2768 "ld a,(ix+$04); add a,$08; ld (ix+$04),a; call
# $0D72" (set_volume): the attenuation
scoped  channel fm_effect_38 04 attenuation u8
comment fm_effect_38 Loads fm_effect_38_patch (fm_effect_19_patch's bytes): a falling note four times (fm_effect_38_retrigger), at the volume start_sound leaves (0) and then at attenuations 10, 18 and 20; effect 19's figure from pitch 1000, fading slower.
comment fm_effect_38_retrigger Sets pitch 1000 and keys on, for 64 passes of fm_effect_38_slide.
comment fm_effect_38_slide The pitch a quarter semitone lower each pass, played an octave higher in turn every 16 passes; after the 64 passes 8 quieter (set_volume) and the next time (fm_effect_38_retrigger), and stop_channel after the fourth.

# ======== the unused group (unused_effects.c): commands 3C-3F on FM channel 7, with the YM2151's noise ========
# start_sound 01E5-0225 takes the commands 3C-3E on the record F233 (FM_7, the only channel the YM2151's noise plays
# on) and their handlers from unused_effect_group; 3F never gets there (sound_command takes 3F first, 0083): no command
# reaches unused_effect_3f, and the game sends none of 3C-3E. Unlike the commands 01-38 (01DE), these do not turn the
# noise off first, and nothing turns it off when they end (stop_channel), until the next FM effect 01-38 starts
# unused_effect_3c 2799 "ld hl,$2780; call $0C68" and the same in the other three: the patch before each
2780  table  unused_effect_3c_patch  fm_patch
27F5  table  unused_effect_3d_patch  fm_patch
283D  table  unused_effect_3e_patch  fm_patch
2886  table  unused_effect_3f_patch  fm_patch
# nothing calls them (unused_effect_group is data to the walk): their IX is a record as everywhere else (279F-27A1 "ld
# a,$00; ld (ix+$01),a", 27B6 "ld (ix+$00),$10")
param unused_effect_3c ix channel channel
param unused_effect_3d ix channel channel
param unused_effect_3e ix channel channel
param unused_effect_3f ix channel channel
# unused_effect_3c 279F-27A4 "ld a,$00; ld (ix+$01),a; call $0FF2" (noise_on); unused_effect_3c_slide 27D0 "bit
# 0,(ix+$01)", 27E6-27F2 "ld a,(ix+$01); inc a; cp $20; jp nc,$0C22; ld (ix+$01),a; jp $0FF2": the noise's frequency
scoped  channel unused_effect_3c 01 noise_frequency u8
# unused_effect_3d 2814-2819 "ld a,$0A; ld (ix+$01),a; call $0FF2"; 2831-283A "dec (ix+$01); jp z,$0C22; ld
# a,(ix+$01); jp $0FF2": the noise's frequency
scoped  channel unused_effect_3d 01 noise_frequency u8
# unused_effect_3e 2864-286A "ld hl,$0400; ld (ix+$00),l; ld (ix+$01),h"; unused_effect_3e_end 2873-2882 "dec hl ...
# ret nz": the passes left, a word
scoped  channel unused_effect_3e 00 passes u16
# unused_effect_3f 28AD-28B3 "ld hl,$1600 ...", 28C3-28C9 "ld hl,$0200 ..."; unused_effect_3f_update 28D9-28E7 "dec
# hl ... or h": the passes left, a word
scoped  channel unused_effect_3f 00 passes u16
# 2829-283A: every 16 passes the noise's frequency one lower (noise_on), stop_channel at 0: no hold
comment unused_effect_3c Unused: command 3C's handler (unused_effect_group). Loads unused_effect_3c_patch on FM channel 7, the noise on at frequency 0, and keys on pitch 800: 32 steps of 16 passes (unused_effect_3c_slide).
comment unused_effect_3c_slide The pitch a 16th of a semitone higher each pass, 2 semitones higher while the noise's frequency is odd; every 16 passes the noise's frequency one higher (noise_on), and stop_channel when it reaches 32.
comment unused_effect_3d Unused: command 3D's handler (unused_effect_group). Loads unused_effect_3d_patch on FM channel 7, the noise on at frequency 0A, and keys on at the pitch the channel has: unused_effect_3d_lower_noise.
comment unused_effect_3d_lower_noise Every 16 passes the noise's frequency one lower (noise_on); stop_channel when it reaches 0.
comment unused_effect_3e Unused: command 3E's handler (unused_effect_group). Loads unused_effect_3e_patch on FM channel 7, the noise on at frequency 12, and keys on at the pitch the channel has, for 1024 passes (unused_effect_3e_end).
comment unused_effect_3e_end Counts down the 1024 passes, then stop_channel.
comment unused_effect_3f Unused: command 3F's handler in unused_effect_group, which no command reaches. Loads unused_effect_3f_patch on FM channel 7, the noise on at frequency 1F, and keys on at the pitch the channel has, for 5632 passes (unused_effect_3f_step).
comment unused_effect_3f_step After the 5632 passes (unused_effect_3f_update), key off and 512 passes of unused_effect_3f_end.
comment unused_effect_3f_end Counts down the 512 passes (unused_effect_3f_update), then stop_channel.
comment unused_effect_3f_update Counts the passes down and tells whether they ran out.

# ======== the bytes the handlers split their words into ========
# The handlers that count a word of passes down ("ld l,(ix+$00); ld h,(ix+$01); dec hl; ld (ix+$00),l; ld (ix+$01),h; ld
# a,l; or h; ret nz"): L and H its bytes. E.g. fm_effect_07_slide 12B5-12C4, fm_effect_13_slide 16E7-16F6
local fm_effect_11_pitch 15CF h passes_high
local fm_effect_12_delay 1639 h passes_high
local fm_effect_1f_end 1CC3 h passes_high
local fm_effect_21_end 1D7F l passes_low
local fm_effect_21_end 1D7F h passes_high
local unused_effect_3e_end 2879 l passes_low
local unused_effect_3e_end 2879 h passes_high
local unused_effect_3f_update 28DF l passes_low
local unused_effect_3f_update 28DF h passes_high

# ======== pitches the C would print as places ========
# A pitch an effect sets with "ld hl,$NNNN" is an address to the C when a function or a table's record holds that place:
# 1000 is pcm_voice_playing's entry, 1208 fm_effect_05's, 1400 the column 14 of fm_effect_0e_patch's record (13EC-1404),
# and the C read "pitch = pcm_voice_playing_ADDRESS" (fm_effect_10 1528, fm_effect_1f_retrigger 1CA5, fm_effect_2a
# 2179, fm_effect_38_retrigger 2725), "pitch = fm_effect_05_ADDRESS" (fm_effect_33_retrigger 250B) and, with the patches
# named, "pitch = fm_effect_0e_patch_ADDRESS + 0x14u" (fm_effect_0e 140B, fm_effect_1a_retrigger 1A32, fm_effect_1b 1A95,
# fm_effect_23_retrigger 1E16, fm_effect_29 20EA, fm_effect_2f_retrigger 240D). Each goes to set_pitch (param set_pitch
# hl pitch): a number. Named here so that the C prints a number; better would be the decompiler taking what set_pitch
# is handed as a number

# ======== the PCM effects (pcm_effects.c): the names, families, patches and comments ========
# The PCM effects (pcm_effects.c, 2EB8-41AD): proposals for sound_symbols.txt
# (every value below read from the listing and the program ROM 072-e03.6g)

# ======== renames (apply to the func lines and every other use) ========
# pcm_effect_42_retrigger 375D-378C: no key off before its key on; it reads the list's next note (pitch, length) and keys it on
# pcm_effect_42_setup_2 378F-37AF: no setup; it reads the rest's length and keys the note off
# pcm_effect_7a/7c/7e: the heuristic called every handler retrigger because each calls the helper that keys the sample off and on when it has ended (4024, 40D5, 415B); the handlers themselves fade in (3FBE "dec (ix+$00); call $0D72"), hold (3FE6 "dec hl" on the u16 at 00), fade out (4007 "inc (ix+$00); call $0D72; cp $7F")
# effect_steps_36b9 (36B9 data u16[48]) is three lists of notes, 32 bytes each: pcm_effect_40 3746 "ld hl,$36B9", pcm_effect_41 3735 "ld hl,$36D9", pcm_effect_42 3724 "ld hl,$36F9"; each five notes of three words (pitch, the passes keyed on, the passes of the rest: pcm_effect_42_next_note 3767-3779, pcm_effect_42_rest 3799-379C) and a pitch 0 (376B "ld a,e; or d; jp z,$0C22")
36B9  data   pcm_effect_40_notes  u16[16]
36D9  data   pcm_effect_41_notes  u16[16]
36F9  data   pcm_effect_42_notes  u16[16]
# no sample loops: pcm_load_patch 0D50-0D5B puts bit 0 of the sample's flags into FC2A's bits 4-7 (the pcm family's kadpcm_bit 10/20/40/80), which are the K053260's KADPCM bits (runtime/src/k053260.c REG_LOOP_KADPCM: bits 0-3 loop, 4-7 KADPCM; the flag is 1 for the 101 samples assets/sounds/samples.txt calls kadpcm); so every wait_sample ends

# ======== the PCM patches (load_patch, 3 bytes: sample, level, decay_step) ========
# pcm_effect_3f_00 2EB8 "ld hl,$2EB5; call $0C68": 10 00 00 (sample 16)
2EB5  table  pcm_effect_3f_00_patch  pcm_patch
# pcm_effect_3f_01 2ED6 "ld hl,$2ED3; call $0C68": 11 00 00 (sample 17)
2ED3  table  pcm_effect_3f_01_patch  pcm_patch
# pcm_effect_3f_02 2EF4 "ld hl,$2EF1; call $0C68": 12 00 00 (sample 18)
2EF1  table  pcm_effect_3f_02_patch  pcm_patch
# pcm_effect_3f_03 2F12 "ld hl,$2F0F; call $0C68": 13 00 00 (sample 19)
2F0F  table  pcm_effect_3f_03_patch  pcm_patch
# pcm_effect_3f_04 2F30 "ld hl,$2F2D; call $0C68": 14 00 00 (sample 20)
2F2D  table  pcm_effect_3f_04_patch  pcm_patch
# pcm_effect_3f_05 2F4E "ld hl,$2F4B; call $0C68": 15 00 00 (sample 21)
2F4B  table  pcm_effect_3f_05_patch  pcm_patch
# pcm_effect_3f_06 2F6C "ld hl,$2F69; call $0C68": 16 00 00 (sample 22)
2F69  table  pcm_effect_3f_06_patch  pcm_patch
# pcm_effect_3f_07 2F8A "ld hl,$2F87; call $0C68": 17 00 00 (sample 23)
2F87  table  pcm_effect_3f_07_patch  pcm_patch
# pcm_effect_3f_08 2FA8 "ld hl,$2FA5; call $0C68": 18 00 00 (sample 24)
2FA5  table  pcm_effect_3f_08_patch  pcm_patch
# pcm_effect_3f_09 2FC6 "ld hl,$2FC3; call $0C68": 19 00 00 (sample 25)
2FC3  table  pcm_effect_3f_09_patch  pcm_patch
# pcm_effect_3f_0a 2FE4 "ld hl,$2FE1; call $0C68": 1A 00 00 (sample 26)
2FE1  table  pcm_effect_3f_0a_patch  pcm_patch
# pcm_effect_3f_0b 3002 "ld hl,$2FFF; call $0C68": 1B 00 00 (sample 27)
2FFF  table  pcm_effect_3f_0b_patch  pcm_patch
# pcm_effect_3f_0c 3020 "ld hl,$301D; call $0C68": 1C 00 00 (sample 28)
301D  table  pcm_effect_3f_0c_patch  pcm_patch
# pcm_effect_3f_0d 303E "ld hl,$303B; call $0C68": 1D 00 00 (sample 29)
303B  table  pcm_effect_3f_0d_patch  pcm_patch
# pcm_effect_3f_0e 305C "ld hl,$3059; call $0C68": 1E 00 00 (sample 30)
3059  table  pcm_effect_3f_0e_patch  pcm_patch
# pcm_effect_3f_0f 307A "ld hl,$3077; call $0C68": 1F 00 00 (sample 31)
3077  table  pcm_effect_3f_0f_patch  pcm_patch
# pcm_effect_3f_10 3098 "ld hl,$3095; call $0C68": 20 00 00 (sample 32)
3095  table  pcm_effect_3f_10_patch  pcm_patch
# pcm_effect_3f_11 30B6 "ld hl,$30B3; call $0C68": 21 00 00 (sample 33)
30B3  table  pcm_effect_3f_11_patch  pcm_patch
# pcm_effect_3f_12 30D4 "ld hl,$30D1; call $0C68": 22 00 00 (sample 34)
30D1  table  pcm_effect_3f_12_patch  pcm_patch
# pcm_effect_3f_13 30F2 "ld hl,$30EF; call $0C68": 23 00 00 (sample 35)
30EF  table  pcm_effect_3f_13_patch  pcm_patch
# pcm_effect_3f_14 3110 "ld hl,$310D; call $0C68": 24 00 00 (sample 36)
310D  table  pcm_effect_3f_14_patch  pcm_patch
# pcm_effect_3f_15 312E "ld hl,$312B; call $0C68": 25 00 00 (sample 37)
312B  table  pcm_effect_3f_15_patch  pcm_patch
# pcm_effect_3f_16 314C "ld hl,$3149; call $0C68": 26 00 00 (sample 38)
3149  table  pcm_effect_3f_16_patch  pcm_patch
# pcm_effect_3f_17 316A "ld hl,$3167; call $0C68": 27 00 00 (sample 39)
3167  table  pcm_effect_3f_17_patch  pcm_patch
# pcm_effect_3f_18 3188 "ld hl,$3185; call $0C68": 00 00 00 (sample 0)
3185  table  pcm_effect_3f_18_patch  pcm_patch
# pcm_effect_3f_19 31A6 "ld hl,$31A3; call $0C68": 01 00 00 (sample 1)
31A3  table  pcm_effect_3f_19_patch  pcm_patch
# pcm_effect_3f_1a 31C4 "ld hl,$31C1; call $0C68": 02 00 00 (sample 2)
31C1  table  pcm_effect_3f_1a_patch  pcm_patch
# pcm_effect_3f_1b 31E2 "ld hl,$31DF; call $0C68": 03 00 00 (sample 3)
31DF  table  pcm_effect_3f_1b_patch  pcm_patch
# pcm_effect_3f_1c 3200 "ld hl,$31FD; call $0C68": 28 00 00 (sample 40)
31FD  table  pcm_effect_3f_1c_patch  pcm_patch
# pcm_effect_3f_1d 321E "ld hl,$321B; call $0C68": 29 00 00 (sample 41)
321B  table  pcm_effect_3f_1d_patch  pcm_patch
# pcm_effect_3f_1e 323C "ld hl,$3239; call $0C68": 2A 00 00 (sample 42)
3239  table  pcm_effect_3f_1e_patch  pcm_patch
# pcm_effect_3f_1f 325A "ld hl,$3257; call $0C68": 2B 00 00 (sample 43)
3257  table  pcm_effect_3f_1f_patch  pcm_patch
# pcm_effect_3f_20 3278 "ld hl,$3275; call $0C68": 04 50 00 (sample 4)
3275  table  pcm_effect_3f_20_patch  pcm_patch
# pcm_effect_3f_21 3296 "ld hl,$3293; call $0C68": 05 38 00 (sample 5)
3293  table  pcm_effect_3f_21_patch  pcm_patch
# pcm_effect_3f_22 32B4 "ld hl,$32B1; call $0C68": 06 50 00 (sample 6)
32B1  table  pcm_effect_3f_22_patch  pcm_patch
# pcm_effect_3f_23 32D2 "ld hl,$32CF; call $0C68": 07 58 00 (sample 7)
32CF  table  pcm_effect_3f_23_patch  pcm_patch
# pcm_effect_3f_24 32F0 "ld hl,$32ED; call $0C68": 08 00 00 (sample 8)
32ED  table  pcm_effect_3f_24_patch  pcm_patch
# pcm_effect_3f_25 330E "ld hl,$330B; call $0C68": 09 30 00 (sample 9)
330B  table  pcm_effect_3f_25_patch  pcm_patch
# pcm_effect_3f_26 332C "ld hl,$3329; call $0C68": 0A 10 00 (sample 10)
3329  table  pcm_effect_3f_26_patch  pcm_patch
# pcm_effect_3f_27 334A "ld hl,$3347; call $0C68": 0B 10 00 (sample 11)
3347  table  pcm_effect_3f_27_patch  pcm_patch
# pcm_effect_3f_28 3368 "ld hl,$3365; call $0C68": 0C 00 00 (sample 12)
3365  table  pcm_effect_3f_28_patch  pcm_patch
# pcm_effect_3f_29 3386 "ld hl,$3383; call $0C68": 0D 20 00 (sample 13)
3383  table  pcm_effect_3f_29_patch  pcm_patch
# pcm_effect_3f_2a 33A4 "ld hl,$33A1; call $0C68": 0E 20 00 (sample 14)
33A1  table  pcm_effect_3f_2a_patch  pcm_patch
# pcm_effect_3f_2b 33C2 "ld hl,$33BF; call $0C68": 0F 20 00 (sample 15)
33BF  table  pcm_effect_3f_2b_patch  pcm_patch
# pcm_effect_3f_2c 33E0 "ld hl,$33DD; call $0C68": 64 00 00 (sample 100)
33DD  table  pcm_effect_3f_2c_patch  pcm_patch
# pcm_effect_3f_2d 3404 "ld hl,$3401; call $0C68": 65 00 00 (sample 101)
3401  table  pcm_effect_3f_2d_patch  pcm_patch
# pcm_effect_3f_2e 3428 "ld hl,$3425; call $0C68": 65 00 00 (sample 101)
3425  table  pcm_effect_3f_2e_patch  pcm_patch
# pcm_effect_3f_30 344F "ld hl,$344C; call $0C68": 2D 00 00 (sample 45)
344C  table  pcm_effect_3f_30_patch  pcm_patch
# pcm_effect_3f_31 3473 "ld hl,$3470; call $0C68": 2E 00 00 (sample 46)
3470  table  pcm_effect_3f_31_patch  pcm_patch
# pcm_effect_3f_32 3497 "ld hl,$3494; call $0C68": 2F 00 00 (sample 47)
3494  table  pcm_effect_3f_32_patch  pcm_patch
# pcm_effect_3f_33 34BB "ld hl,$34B8; call $0C68": 30 00 00 (sample 48)
34B8  table  pcm_effect_3f_33_patch  pcm_patch
# pcm_effect_3f_34 34DF "ld hl,$34DC; call $0C68": 32 00 00 (sample 50)
34DC  table  pcm_effect_3f_34_patch  pcm_patch
# pcm_effect_3f_35 3503 "ld hl,$3500; call $0C68": 33 00 00 (sample 51)
3500  table  pcm_effect_3f_35_patch  pcm_patch
# pcm_effect_3f_36 3527 "ld hl,$3524; call $0C68": 34 00 00 (sample 52)
3524  table  pcm_effect_3f_36_patch  pcm_patch
# pcm_effect_3f_37 354B "ld hl,$3548; call $0C68": 31 40 00 (sample 49)
3548  table  pcm_effect_3f_37_patch  pcm_patch
# pcm_effect_3f_38 356F "ld hl,$356C; call $0C68": 62 00 00 (sample 98)
356C  table  pcm_effect_3f_38_patch  pcm_patch
# pcm_effect_3f_39 3599 "ld hl,$3596; call $0C68": 61 00 00 (sample 97)
3596  table  pcm_effect_3f_39_patch  pcm_patch
# pcm_effect_3f_3a 35BC "ld hl,$35B4; call $0C68": 4E 10 00 (sample 78)
35B4  table  pcm_effect_3f_3a_patch  pcm_patch
# pcm_effect_3f_3b 35DA "ld hl,$35D2; call $0C68": 5F 10 00 (sample 95)
35D2  table  pcm_effect_3f_3b_patch  pcm_patch
# pcm_effect_40 373B "ld hl,$36B0; call $0C68": 73 30 00 (sample 115)
36B0  table  pcm_effect_40_patch  pcm_patch
# pcm_effect_41 372A "ld hl,$36B3; call $0C68": 69 10 00 (sample 105)
36B3  table  pcm_effect_41_patch  pcm_patch
# pcm_effect_42 3719 "ld hl,$36B6; call $0C68": 72 10 06 (sample 114)
36B6  table  pcm_effect_42_patch  pcm_patch
# pcm_effect_43 37C5 "ld hl,$37C2; call $0C68": 91 40 00 (sample 145)
37C2  table  pcm_effect_43_patch  pcm_patch
# pcm_effect_44 37E3 "ld hl,$37E0; call $0C68": 35 00 00 (sample 53)
37E0  table  pcm_effect_44_patch  pcm_patch
# pcm_effect_45 3801 "ld hl,$37FE; call $0C68": 36 00 00 (sample 54)
37FE  table  pcm_effect_45_patch  pcm_patch
# pcm_effect_46 381F "ld hl,$381C; call $0C68": 3B 38 00 (sample 59)
381C  table  pcm_effect_46_patch  pcm_patch
# pcm_effect_47 384A "ld hl,$3847; call $0C68": 51 10 00 (sample 81)
3847  table  pcm_effect_47_patch  pcm_patch
# pcm_effect_48 3868 "ld hl,$3865; call $0C68": 46 10 00 (sample 70)
3865  table  pcm_effect_48_patch  pcm_patch
# pcm_effect_49 3886 "ld hl,$3883; call $0C68": 5B 00 00 (sample 91)
3883  table  pcm_effect_49_patch  pcm_patch
# pcm_effect_4a 38A4 "ld hl,$38A1; call $0C68": 36 40 00 (sample 54)
38A1  table  pcm_effect_4a_patch  pcm_patch
# pcm_effect_4b 38C2 "ld hl,$38BF; call $0C68": 2C 00 00 (sample 44)
38BF  table  pcm_effect_4b_patch  pcm_patch
# pcm_effect_4c 38E0 "ld hl,$38DD; call $0C68": 48 00 00 (sample 72)
38DD  table  pcm_effect_4c_patch  pcm_patch
# pcm_effect_4d 38FE "ld hl,$38FB; call $0C68": 49 20 00 (sample 73)
38FB  table  pcm_effect_4d_patch  pcm_patch
# pcm_effect_4e 391C "ld hl,$3919; call $0C68": 5A 20 00 (sample 90)
3919  table  pcm_effect_4e_patch  pcm_patch
# pcm_effect_4f 393A "ld hl,$3937; call $0C68": 45 00 00 (sample 69)
3937  table  pcm_effect_4f_patch  pcm_patch
# pcm_effect_50 3958 "ld hl,$3955; call $0C68": 93 00 00 (sample 147)
3955  table  pcm_effect_50_patch  pcm_patch
# pcm_effect_51 39A4 "ld hl,$39A1; call $0C68": 92 00 00 (sample 146)
39A1  table  pcm_effect_51_patch  pcm_patch
# pcm_effect_52 39C8 "ld hl,$39C5; call $0C68": 5E 20 08 (sample 94)
39C5  table  pcm_effect_52_patch  pcm_patch
# pcm_effect_53 3A01 "ld hl,$39FE; call $0C68": 5C 00 00 (sample 92)
39FE  table  pcm_effect_53_patch  pcm_patch
# pcm_effect_54 3A1F "ld hl,$3A1C; call $0C68": 37 00 00 (sample 55)
3A1C  table  pcm_effect_54_patch  pcm_patch
# pcm_effect_55 3A61 "ld hl,$3A5E; call $0C68": 44 00 00 (sample 68)
3A5E  table  pcm_effect_55_patch  pcm_patch
# pcm_effect_56 3A85 "ld hl,$3A82; call $0C68": 4F 00 00 (sample 79)
3A82  table  pcm_effect_56_patch  pcm_patch
# pcm_effect_57 3AE5 "ld hl,$3ADF; call $0C68": 4A 00 09 (sample 74)
3ADF  table  pcm_effect_57_patch  pcm_patch
# pcm_effect_57_note 3B2E "ld hl,$3AE2; call $0C68": 11 10 00 (sample 17)
3AE2  table  pcm_effect_57_patch_2  pcm_patch
# pcm_effect_58 3B62 "ld hl,$3B5F; call $0C68": 4D 00 00 (sample 77)
3B5F  table  pcm_effect_58_patch  pcm_patch
# pcm_effect_59 3B93 "ld hl,$3B90; call $0C68": 90 00 00 (sample 144)
3B90  table  pcm_effect_59_patch  pcm_patch
# pcm_effect_5a 3BB1 "ld hl,$3BAE; call $0C68": 4A 00 00 (sample 74)
3BAE  table  pcm_effect_5a_patch  pcm_patch
# pcm_effect_5b 3BCF "ld hl,$3BCC; call $0C68": 4A 00 08 (sample 74)
3BCC  table  pcm_effect_5b_patch  pcm_patch
# pcm_effect_5c 3BF0 "ld hl,$3BED; call $0C68": 5E 00 10 (sample 94)
3BED  table  pcm_effect_5c_patch  pcm_patch
# pcm_effect_5d 3C29 "ld hl,$3C26; call $0C68": 5E 00 08 (sample 94)
3C26  table  pcm_effect_5d_patch  pcm_patch
# pcm_effect_5e 3C5C "ld hl,$3C59; call $0C68": 4D 00 00 (sample 77)
3C59  table  pcm_effect_5e_patch  pcm_patch
# pcm_effect_5f 3C7A "ld hl,$3C77; call $0C68": 3A 00 00 (sample 58)
3C77  table  pcm_effect_5f_patch  pcm_patch
# pcm_effect_60 3C98 "ld hl,$3C95; call $0C68": 39 00 00 (sample 57)
3C95  table  pcm_effect_60_patch  pcm_patch
# pcm_effect_61 3CB6 "ld hl,$3CB3; call $0C68": 3C 10 00 (sample 60)
3CB3  table  pcm_effect_61_patch  pcm_patch
# pcm_effect_62 3CD4 "ld hl,$3CD1; call $0C68": 4C 00 00 (sample 76)
3CD1  table  pcm_effect_62_patch  pcm_patch
# pcm_effect_63 3CF2 "ld hl,$3CEF; call $0C68": 38 30 00 (sample 56)
3CEF  table  pcm_effect_63_patch  pcm_patch
# pcm_effect_64 3D10 "ld hl,$3D0D; call $0C68": 40 10 00 (sample 64)
3D0D  table  pcm_effect_64_patch  pcm_patch
# pcm_effect_65 3D2E "ld hl,$3D2B; call $0C68": 7A 30 00 (sample 122)
3D2B  table  pcm_effect_65_patch  pcm_patch
# pcm_effect_66 3D4C "ld hl,$3D49; call $0C68": 66 10 00 (sample 102)
3D49  table  pcm_effect_66_patch  pcm_patch
# pcm_effect_67 3D6A "ld hl,$3D67; call $0C68": 3D 10 00 (sample 61)
3D67  table  pcm_effect_67_patch  pcm_patch
# pcm_effect_68 3D88 "ld hl,$3D85; call $0C68": 3E 10 00 (sample 62)
3D85  table  pcm_effect_68_patch  pcm_patch
# pcm_effect_69 3DA6 "ld hl,$3DA3; call $0C68": 3F 20 00 (sample 63)
3DA3  table  pcm_effect_69_patch  pcm_patch
# pcm_effect_6a 3DC4 "ld hl,$3DC1; call $0C68": 53 10 00 (sample 83)
3DC1  table  pcm_effect_6a_patch  pcm_patch
# pcm_effect_6b 3DE2 "ld hl,$3DDF; call $0C68": 42 30 00 (sample 66)
3DDF  table  pcm_effect_6b_patch  pcm_patch
# pcm_effect_6c 3E00 "ld hl,$3DFD; call $0C68": 43 40 00 (sample 67)
3DFD  table  pcm_effect_6c_patch  pcm_patch
# pcm_effect_6d 3E1E "ld hl,$3E1B; call $0C68": 4B 00 00 (sample 75)
3E1B  table  pcm_effect_6d_patch  pcm_patch
# pcm_effect_6e 3E3C "ld hl,$3E39; call $0C68": 5E 00 00 (sample 94)
3E39  table  pcm_effect_6e_patch  pcm_patch
# pcm_effect_6f 3E5A "ld hl,$3E57; call $0C68": 41 00 00 (sample 65)
3E57  table  pcm_effect_6f_patch  pcm_patch
# pcm_effect_70 3E78 "ld hl,$3E75; call $0C68": 54 00 00 (sample 84)
3E75  table  pcm_effect_70_patch  pcm_patch
# pcm_effect_71 3E96 "ld hl,$3E93; call $0C68": 5D 00 00 (sample 93)
3E93  table  pcm_effect_71_patch  pcm_patch
# pcm_effect_72 3EB9 "ld hl,$3EB1; call $0C68": 50 20 00 (sample 80)
3EB1  table  pcm_effect_72_patch  pcm_patch
# pcm_effect_73 3ED7 "ld hl,$3ECF; call $0C68": 55 30 00 (sample 85)
3ECF  table  pcm_effect_73_patch  pcm_patch
# pcm_effect_74 3EF5 "ld hl,$3EED; call $0C68": 56 30 00 (sample 86)
3EED  table  pcm_effect_74_patch  pcm_patch
# pcm_effect_75 3F13 "ld hl,$3F0B; call $0C68": 57 10 00 (sample 87)
3F0B  table  pcm_effect_75_patch  pcm_patch
# pcm_effect_76 3F31 "ld hl,$3F29; call $0C68": 60 20 00 (sample 96)
3F29  table  pcm_effect_76_patch  pcm_patch
# pcm_effect_77 3F4A "ld hl,$3F47; call $0C68": 5E 00 04 (sample 94)
3F47  table  pcm_effect_77_patch  pcm_patch
# pcm_effect_79 3F80 "ld hl,$3F7D; call $0C68": 44 00 00 (sample 68)
3F7D  table  pcm_effect_79_patch  pcm_patch
# pcm_effect_7a 3F9E "ld hl,$3F9B; call $0C68": 58 20 00 (sample 88)
3F9B  table  pcm_effect_7a_patch  pcm_patch
# pcm_effect_7b 4031 "ld hl,$402E; call $0C68": 47 00 00 (sample 71)
402E  table  pcm_effect_7b_patch  pcm_patch
# pcm_effect_7c 404F "ld hl,$404C; call $0C68": 52 40 00 (sample 82)
404C  table  pcm_effect_7c_patch  pcm_patch
# pcm_effect_7d 40E2 "ld hl,$40DF; call $0C68": 63 00 00 (sample 99)
40DF  table  pcm_effect_7d_patch  pcm_patch
# pcm_effect_7e 4100 "ld hl,$40FD; call $0C68": 59 50 00 (sample 89)
40FD  table  pcm_effect_7e_patch  pcm_patch
# pcm_effect_7f 4176 "ld hl,$4165; call $0C68": 59 30 00 (sample 89)
4165  table  pcm_effect_7f_patch  pcm_patch

# ======== families: the chains whose record bytes +00-+03 differ from count, timer, pitch ========
# effects 40, 41 and 42 (pcm_effect_40 and 41 jump into pcm_effect_42_setup with their list in HL): 3749-374C
# pcm_effect_42_setup "ld (ix+$00),l; ld (ix+$01),h"; pcm_effect_42_next_note 3761-3769 "ld l,(ix+$00); ld h,(ix+$01);
# ld e,(hl); inc hl; ld d,(hl)", 3780-3783 "ld (ix+$00),l; ld (ix+$01),h": the place of the list's next word
scoped  channel pcm_effect_42 00 notes u16
# 374F-3753 pcm_effect_42_setup "ld (ix+$02),$01; ld (ix+$03),$00"; 377A-377D, 379D-37A0 "ld (ix+$02),e; ld (ix+$03),d"
# (a note's length, a rest's); pcm_effect_42_update 37B2-37C0 "ld e,(ix+$02); ld d,(ix+$03); dec de; ...; ld a,e; or d":
# the passes left of the note or the rest
scoped  channel pcm_effect_42 02 passes u16
# 3969-396B pcm_effect_50 "ld a,$7F; ld (ix+$00),a; call $0D72"; pcm_effect_50_fade 3986-398C "dec (ix+$00); ld
# a,(ix+$00); call $0D72": the volume it fades in (set_volume's)
scoped  channel pcm_effect_50 00 attenuation u8
# 3A30 pcm_effect_54 "ld (ix+$00),$90"; pcm_effect_54_modulate 3A3A-3A3E "dec (ix+$00); ret nz; ld (ix+$00),$90": the
# passes left of a step of the pan
scoped  channel pcm_effect_54 00 timer u8
# 3A25-3A2A pcm_effect_54 "ld a,$06; ld (ix+$01),a; call $0F7C"; pcm_effect_54_modulate 3A42-3A4E "dec (ix+$01); ld
# a,(ix+$01); call $0F7C; ld a,(ix+$01); cp $02": the pan it moves
scoped  channel pcm_effect_54 01 pan u8
# 3AF9-3AFF pcm_effect_57 "ld hl,$0200; ld (ix+$00),l; ld (ix+$01),h", 3B1B-3B21 "ld hl,$0280"; pcm_effect_57_update
# 3B4F-3B5D "ld l,(ix+$00); ld h,(ix+$01); dec hl; ...; ld a,h; or l": the passes left
scoped  channel pcm_effect_57 00 passes u16
# effects 7A, 7C and 7E, the same layout. The timer first: the u16 at 00 holds its byte, and the decompiler takes a
# family's fields in the order of these lines (decompiler/pointers.py scoped_field): 3FB4 pcm_effect_7a "ld
# (ix+$01),$01"; pcm_effect_7a_fade_in 3FC1-3FC5 "dec (ix+$01); ret nz; ld (ix+$01),$01"; pcm_effect_7a_fade_out
# 400A-400E "dec (ix+$01); ret nz; ld (ix+$01),$08" (7C: 4072-4076 "ld (ix+$01),$04", 40BB-40BF; 7E: 4141-4145): the
# passes left of a step of the fade
scoped  channel pcm_effect_7a 01 timer u8
scoped  channel pcm_effect_7c 01 timer u8
scoped  channel pcm_effect_7e 01 timer u8
# 3FD7-3FDD pcm_effect_7a_fade_in "ld hl,$0A00; ld (ix+$00),l; ld (ix+$01),h"; pcm_effect_7a_delay 3FE9-3FF7 "ld
# l,(ix+$00); ld h,(ix+$01); dec hl; ...; ld a,l; or h" (7C: 4088-408E "ld hl,$1100", 409A-40A8; 7E: pcm_effect_7e
# 410E-4114 "ld hl,$0600", pcm_effect_7e_delay 4120-412E): the passes the sound holds
scoped  channel pcm_effect_7a 00 passes u16
scoped  channel pcm_effect_7c 00 passes u16
scoped  channel pcm_effect_7e 00 passes u16
# 3FA9-3FAE pcm_effect_7a "ld a,$60; ld (ix+$00),a; call $0D72"; pcm_effect_7a_fade_in 3FC9-3FCF "dec (ix+$00); ld
# a,(ix+$00); call $0D72"; pcm_effect_7a_delay 3FF9 "ld (ix+$00),$00"; pcm_effect_7a_fade_out 4012-401E "inc (ix+$00);
# ld a,(ix+$00); call $0D72; ld a,(ix+$00); cp $7F" (7C: 405A-405F "ld a,$40", 407A-4080, 40AA, 40C3-40CF; 7E: 4130,
# 4149-4155): the volume of the fades
scoped  channel pcm_effect_7a 00 attenuation u8
scoped  channel pcm_effect_7c 00 attenuation u8
scoped  channel pcm_effect_7e 00 attenuation u8
# (the word's stores are byte stores of constants, 3FDA-3FDD "ld (ix+$00),l; ld (ix+$01),h" after "ld hl,$0A00": the C
# writes them as attenuation = 0 and timer = 0x0A; z80/pairs.py joined_stores only joins the two bytes of one value, as
# it does for pcm_effect_42_setup's notes. The same makes pcm_effect_57's and pcm_effect_42's stores of passes
# AS8/AT8: of constants, 3AF9-3AFF, 3B1B-3B21, 374F-3753, or of the bytes of DE and HL whose zero test reads them
# again, 37B9-37C0, 3B56-3B5D)
# sound_command 0347-034A "ld a,($FC01); ld (ix+$00),a" (command 7F: its argument, into the record playing effect 7F or
# the one it takes); pcm_effect_7f_set_volume 4194-41A4 "ld a,(ix+$00); and $07; or a; jp z,$0C22; ld l,a; ld h,$00;
# add hl,hl; ld de,$4166; add hl,de": the position 1-7 (effect_levels: pan 7 to 1, the volume 30 at the sides, 0 at 4),
# 0 the end
scoped  channel pcm_effect_7f 00 position u8

# ======== the functions ========
# command 3F keeps its argument as the record's sound (sound_command 026A "ld (ix+$41),c"): 3F 00's is 00, a free record's, so the walk for the record already playing it (022D-0239 "cp (ix+$41)") stops at the first PCM record whose sound is 00, free or playing 3F 00: a second 3F 00 may start on another voice where any other effect starts again on its own
comment pcm_effect_3f_00 Command 3F 00: sample 16 (pcm_effect_3f_00_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_00_wait_sample.
comment pcm_effect_3f_00_wait_sample When sample 16 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_01 Command 3F 01: sample 17 (pcm_effect_3f_01_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_01_wait_sample.
comment pcm_effect_3f_01_wait_sample When sample 17 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_02 Command 3F 02: sample 18 (pcm_effect_3f_02_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_02_wait_sample.
comment pcm_effect_3f_02_wait_sample When sample 18 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_03 Command 3F 03: sample 19 (pcm_effect_3f_03_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_03_wait_sample.
comment pcm_effect_3f_03_wait_sample When sample 19 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_04 Command 3F 04: sample 20 (pcm_effect_3f_04_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_04_wait_sample.
comment pcm_effect_3f_04_wait_sample When sample 20 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_05 Command 3F 05: sample 21 (pcm_effect_3f_05_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_05_wait_sample.
comment pcm_effect_3f_05_wait_sample When sample 21 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_06 Command 3F 06: sample 22 (pcm_effect_3f_06_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_06_wait_sample.
comment pcm_effect_3f_06_wait_sample When sample 22 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_07 Command 3F 07: sample 23 (pcm_effect_3f_07_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_07_wait_sample.
comment pcm_effect_3f_07_wait_sample When sample 23 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_08 Command 3F 08: sample 24 (pcm_effect_3f_08_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_08_wait_sample.
comment pcm_effect_3f_08_wait_sample When sample 24 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_09 Command 3F 09: sample 25 (pcm_effect_3f_09_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_09_wait_sample.
comment pcm_effect_3f_09_wait_sample When sample 25 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0a Command 3F 0A: sample 26 (pcm_effect_3f_0a_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0a_wait_sample.
comment pcm_effect_3f_0a_wait_sample When sample 26 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0b Command 3F 0B: sample 27 (pcm_effect_3f_0b_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0b_wait_sample.
comment pcm_effect_3f_0b_wait_sample When sample 27 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0c Command 3F 0C: sample 28 (pcm_effect_3f_0c_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0c_wait_sample.
comment pcm_effect_3f_0c_wait_sample When sample 28 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0d Command 3F 0D: sample 29 (pcm_effect_3f_0d_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0d_wait_sample.
comment pcm_effect_3f_0d_wait_sample When sample 29 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0e Command 3F 0E: sample 30 (pcm_effect_3f_0e_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0e_wait_sample.
comment pcm_effect_3f_0e_wait_sample When sample 30 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_0f Command 3F 0F: sample 31 (pcm_effect_3f_0f_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_0f_wait_sample.
comment pcm_effect_3f_0f_wait_sample When sample 31 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_10 Command 3F 10: sample 32 (pcm_effect_3f_10_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_10_wait_sample.
comment pcm_effect_3f_10_wait_sample When sample 32 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_11 Command 3F 11: sample 33 (pcm_effect_3f_11_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_11_wait_sample.
comment pcm_effect_3f_11_wait_sample When sample 33 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_12 Command 3F 12: sample 34 (pcm_effect_3f_12_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_12_wait_sample.
comment pcm_effect_3f_12_wait_sample When sample 34 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_13 Command 3F 13: sample 35 (pcm_effect_3f_13_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_13_wait_sample.
comment pcm_effect_3f_13_wait_sample When sample 35 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_14 Command 3F 14: sample 36 (pcm_effect_3f_14_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_14_wait_sample.
comment pcm_effect_3f_14_wait_sample When sample 36 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_15 Command 3F 15: sample 37 (pcm_effect_3f_15_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_15_wait_sample.
comment pcm_effect_3f_15_wait_sample When sample 37 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_16 Command 3F 16: sample 38 (pcm_effect_3f_16_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_16_wait_sample.
comment pcm_effect_3f_16_wait_sample When sample 38 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_17 Command 3F 17: sample 39 (pcm_effect_3f_17_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_17_wait_sample.
comment pcm_effect_3f_17_wait_sample When sample 39 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_18 Command 3F 18: sample 0 (pcm_effect_3f_18_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_18_wait_sample.
comment pcm_effect_3f_18_wait_sample When sample 0 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_19 Command 3F 19: sample 1 (pcm_effect_3f_19_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_19_wait_sample.
comment pcm_effect_3f_19_wait_sample When sample 1 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1a Command 3F 1A: sample 2 (pcm_effect_3f_1a_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1a_wait_sample.
comment pcm_effect_3f_1a_wait_sample When sample 2 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1b Command 3F 1B: sample 3 (pcm_effect_3f_1b_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1b_wait_sample.
comment pcm_effect_3f_1b_wait_sample When sample 3 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1c Command 3F 1C: sample 40 (pcm_effect_3f_1c_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1c_wait_sample.
comment pcm_effect_3f_1c_wait_sample When sample 40 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1d Command 3F 1D: sample 41 (pcm_effect_3f_1d_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1d_wait_sample.
comment pcm_effect_3f_1d_wait_sample When sample 41 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1e Command 3F 1E: sample 42 (pcm_effect_3f_1e_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1e_wait_sample.
comment pcm_effect_3f_1e_wait_sample When sample 42 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_1f Command 3F 1F: sample 43 (pcm_effect_3f_1f_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_1f_wait_sample.
comment pcm_effect_3f_1f_wait_sample When sample 43 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_20 Command 3F 20: sample 4 (pcm_effect_3f_20_patch, level 50) at its own pitch, pan 2 (to the left), keyed on; then pcm_effect_3f_20_wait_sample.
comment pcm_effect_3f_20_wait_sample When sample 4 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_21 Command 3F 21: sample 5 (pcm_effect_3f_21_patch, level 38) at its own pitch, pan 3 (a little to the left), keyed on; then pcm_effect_3f_21_wait_sample.
comment pcm_effect_3f_21_wait_sample When sample 5 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_22 Command 3F 22: sample 6 (pcm_effect_3f_22_patch, level 50) at its own pitch, pan 5 (a little to the right), keyed on; then pcm_effect_3f_22_wait_sample.
comment pcm_effect_3f_22_wait_sample When sample 6 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_23 Command 3F 23: sample 7 (pcm_effect_3f_23_patch, level 58) at its own pitch, pan 6 (to the right), keyed on; then pcm_effect_3f_23_wait_sample.
comment pcm_effect_3f_23_wait_sample When sample 7 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_24 Command 3F 24: sample 8 (pcm_effect_3f_24_patch, level 0) at its own pitch, pan 2 (to the left), keyed on; then pcm_effect_3f_24_wait_sample.
comment pcm_effect_3f_24_wait_sample When sample 8 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_25 Command 3F 25: sample 9 (pcm_effect_3f_25_patch, level 30) at its own pitch, pan 3 (a little to the left), keyed on; then pcm_effect_3f_25_wait_sample.
comment pcm_effect_3f_25_wait_sample When sample 9 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_26 Command 3F 26: sample 10 (pcm_effect_3f_26_patch, level 10) at its own pitch, pan 5 (a little to the right), keyed on; then pcm_effect_3f_26_wait_sample.
comment pcm_effect_3f_26_wait_sample When sample 10 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_27 Command 3F 27: sample 11 (pcm_effect_3f_27_patch, level 10) at its own pitch, pan 6 (to the right), keyed on; then pcm_effect_3f_27_wait_sample.
comment pcm_effect_3f_27_wait_sample When sample 11 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_28 Command 3F 28: sample 12 (pcm_effect_3f_28_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_28_wait_sample.
comment pcm_effect_3f_28_wait_sample When sample 12 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_29 Command 3F 29: sample 13 (pcm_effect_3f_29_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_29_wait_sample.
comment pcm_effect_3f_29_wait_sample When sample 13 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_2a Command 3F 2A: sample 14 (pcm_effect_3f_2a_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_2a_wait_sample.
comment pcm_effect_3f_2a_wait_sample When sample 14 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_2b Command 3F 2B: sample 15 (pcm_effect_3f_2b_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_2b_wait_sample.
comment pcm_effect_3f_2b_wait_sample When sample 15 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_2c Command 3F 2C: sample 100 (pcm_effect_3f_2c_patch, level 0) at pitch EA0, pan 4 (centred), keyed on; then pcm_effect_3f_2c_wait_sample.
comment pcm_effect_3f_2c_wait_sample When sample 100 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_2d Command 3F 2D: sample 101 (pcm_effect_3f_2d_patch, level 0) at pitch E40, pan 4 (centred), keyed on; then pcm_effect_3f_2d_wait_sample.
comment pcm_effect_3f_2d_wait_sample When sample 101 has ended (pcm_voice_playing), stop_channel.
# 3F 2D and 3F 2E differ by the pitch only (E40, EE0: the same sample 101, level 0, pan 4)
comment pcm_effect_3f_2e Command 3F 2E: sample 101 (pcm_effect_3f_2e_patch, level 0) at pitch EE0, pan 4 (centred), keyed on; then pcm_effect_3f_2e_wait_sample.
comment pcm_effect_3f_2e_wait_sample When sample 101 has ended (pcm_voice_playing), stop_channel.
# effect_priorities_2[2F] is 00; sound_test_effects (the 053248's 05E739) lists 3F 00-3B but 3F 2F, and no scenario starts it (kref --sound-rom-reads: 0278 never reads effect_handlers_2's entry 2F)
comment pcm_effect_3f_2f Command 3F 2F: stop_channel at once. Its priority is 0 (effect_priorities_2), so it only takes a free record: an empty slot, which the sound test leaves out (sound_test_effects).
comment pcm_effect_3f_30 Command 3F 30: sample 45 (pcm_effect_3f_30_patch, level 0) at pitch EE0, pan 4 (centred), keyed on; then pcm_effect_3f_30_wait_sample.
comment pcm_effect_3f_30_wait_sample When sample 45 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_31 Command 3F 31: sample 46 (pcm_effect_3f_31_patch, level 0) at pitch EE0, pan 4 (centred), keyed on; then pcm_effect_3f_31_wait_sample.
comment pcm_effect_3f_31_wait_sample When sample 46 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_32 Command 3F 32: sample 47 (pcm_effect_3f_32_patch, level 0) at pitch EE0, pan 4 (centred), keyed on; then pcm_effect_3f_32_wait_sample.
comment pcm_effect_3f_32_wait_sample When sample 47 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_33 Command 3F 33: sample 48 (pcm_effect_3f_33_patch, level 0) at pitch EE0, pan 4 (centred), keyed on; then pcm_effect_3f_33_wait_sample.
comment pcm_effect_3f_33_wait_sample When sample 48 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_34 Command 3F 34: sample 50 (pcm_effect_3f_34_patch, level 0) at pitch EF0, pan 4 (centred), keyed on; then pcm_effect_3f_34_wait_sample.
comment pcm_effect_3f_34_wait_sample When sample 50 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_35 Command 3F 35: sample 51 (pcm_effect_3f_35_patch, level 0) at pitch EF0, pan 4 (centred), keyed on; then pcm_effect_3f_35_wait_sample.
comment pcm_effect_3f_35_wait_sample When sample 51 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_36 Command 3F 36: sample 52 (pcm_effect_3f_36_patch, level 0) at pitch EF0, pan 4 (centred), keyed on; then pcm_effect_3f_36_wait_sample.
comment pcm_effect_3f_36_wait_sample When sample 52 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_37 Command 3F 37: sample 49 (pcm_effect_3f_37_patch, level 40) at pitch EF0, pan 4 (centred), keyed on; then pcm_effect_3f_37_wait_sample.
comment pcm_effect_3f_37_wait_sample When sample 49 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_38 Command 3F 38: sample 98 (pcm_effect_3f_38_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_38_wait_sample.
comment pcm_effect_3f_38_wait_sample When sample 98 has ended (pcm_voice_playing), stop_channel.
# nothing calls it (build/sound/index.txt): it sits between pcm_effect_3f_38 and pcm_effect_3f_39, the fade outs it would end (pcm_effect_7a_fade_out 4018-4021) do the same inline
comment set_volume_stop_at_7f Unused: set_volume with the volume it is given, then stop_channel once the record's attenuation is 7F: the end of a fade out, which pcm_effect_7a_fade_out, pcm_effect_7c_fade_out and pcm_effect_7e_fade_out do on their own.
comment pcm_effect_3f_39 Command 3F 39: sample 97 (pcm_effect_3f_39_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_39_wait_sample.
comment pcm_effect_3f_39_wait_sample When sample 97 has ended (pcm_voice_playing), stop_channel.
# 3f_3a, 3f_3b and 72-76 set the pan before the patch (35B7 "ld a,$04; call $0F7C; ld hl,$35B4; call $0C68"), the others after it: the same result
comment pcm_effect_3f_3a Command 3F 3A: sample 78 (pcm_effect_3f_3a_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_3a_wait_sample.
comment pcm_effect_3f_3a_wait_sample When sample 78 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_3f_3b Command 3F 3B: sample 95 (pcm_effect_3f_3b_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_3f_3b_wait_sample.
comment pcm_effect_3f_3b_wait_sample When sample 95 has ended (pcm_voice_playing), stop_channel.
# its last note is shorter than the other two parts' (pcm_effect_42_notes: 0EE2 for 32 passes, a rest of 480; effects 40 and 41: 192 and 192)
comment pcm_effect_42 Command 42: sample 114 (pcm_effect_42_patch, level 10, decay step 6), pan 4 (centred), then pcm_effect_42_setup with pcm_effect_42_notes: the third part of the jingle of effects 40, 41 and 42, whose notes fade in their rests.
comment pcm_effect_41 Command 41: sample 105 (pcm_effect_41_patch, level 10), pan 4 (centred), then pcm_effect_42_setup with pcm_effect_41_notes: the second part of the jingle of effects 40, 41 and 42.
# started together: sound_test_effects' word 4002 (command 40, argument 2: start_sound for 40, 41 and 42), and they run in the same 16 scenarios; effect_priorities_40 40-42 are C0, which stop_channel_unless_kept keeps through command 00
comment pcm_effect_40 Command 40: sample 115 (pcm_effect_40_patch, level 30), pan 4 (centred), then pcm_effect_42_setup with pcm_effect_40_notes: the first part of a jingle of five notes in the same rhythm on three voices (command 40 with argument 2 starts 40, 41 and 42; their priority C0 outlasts command 00).
comment pcm_effect_42_setup The list of notes of effect 40, 41 or 42 into notes, 1 pass to wait, then pcm_effect_42_next_note.
comment pcm_effect_42_next_note When the passes have run out (pcm_effect_42_update), the list's next note: its pitch (0 ends the effect: stop_channel) and its length into passes, keyed on (the sample from its start); then pcm_effect_42_rest.
# 37A9 "call $0EBE": key off only lets run_pcm_channel decay the voice; with the decay step 0 of pcm_effect_40_patch and pcm_effect_41_patch it changes nothing, and the note plays on until the sample ends or the next note restarts it
comment pcm_effect_42_rest When the note's passes have run out, the rest's length from the list into passes and key off (the voice decays by its patch's decay step every 16 passes); then pcm_effect_42_next_note.
comment pcm_effect_42_update One pass less of the note or the rest (passes); true when none is left.
comment pcm_effect_43 Command 43: sample 145 (pcm_effect_43_patch, level 40) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_43_wait_sample.
comment pcm_effect_43_wait_sample When sample 145 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_44 Command 44: sample 53 (pcm_effect_44_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_44_wait_sample.
comment pcm_effect_44_wait_sample When sample 53 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_45 Command 45: sample 54 (pcm_effect_45_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_45_wait_sample.
comment pcm_effect_45_wait_sample When sample 54 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_46 Command 46: sample 59 (pcm_effect_46_patch, level 38) at its own pitch, pan 4 (centred), keyed on, to play 4 times (count); then pcm_effect_46_retrigger.
comment pcm_effect_46_retrigger Each time the sample ends (pcm_voice_playing), one play less: after the last, stop_channel; before, key off and on (the sample again from its start).
comment pcm_effect_47 Command 47: sample 81 (pcm_effect_47_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_47_wait_sample.
comment pcm_effect_47_wait_sample When sample 81 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_48 Command 48: sample 70 (pcm_effect_48_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_48_wait_sample.
comment pcm_effect_48_wait_sample When sample 70 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_49 Command 49: sample 91 (pcm_effect_49_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_49_wait_sample.
comment pcm_effect_49_wait_sample When sample 91 has ended (pcm_voice_playing), stop_channel.
# 45 and 4A differ by the patch's level only (sample 54: 0, 40)
comment pcm_effect_4a Command 4A: sample 54 (pcm_effect_4a_patch, level 40) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4a_wait_sample.
comment pcm_effect_4a_wait_sample When sample 54 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_4b Command 4B: sample 44 (pcm_effect_4b_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4b_wait_sample.
comment pcm_effect_4b_wait_sample When sample 44 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_4c Command 4C: sample 72 (pcm_effect_4c_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4c_wait_sample.
comment pcm_effect_4c_wait_sample When sample 72 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_4d Command 4D: sample 73 (pcm_effect_4d_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4d_wait_sample.
comment pcm_effect_4d_wait_sample When sample 73 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_4e Command 4E: sample 90 (pcm_effect_4e_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4e_wait_sample.
comment pcm_effect_4e_wait_sample When sample 90 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_4f Command 4F: sample 69 (pcm_effect_4f_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_4f_wait_sample.
comment pcm_effect_4f_wait_sample When sample 69 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_50 Command 50: sample 147 (pcm_effect_50_patch, level 0) at pitch F00, pan 4 (centred), keyed on silent (attenuation 7F, set_volume), timer 1; then pcm_effect_50_fade.
comment pcm_effect_50_fade Fades the sample in: every pass the attenuation one less (set_volume), down to 0 (127 passes); then pcm_effect_50_wait_sample.
comment pcm_effect_50_wait_sample When sample 147 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_51 Command 51: sample 146 (pcm_effect_51_patch, level 0) at pitch F00, pan 4 (centred), keyed on; then pcm_effect_51_wait_sample.
comment pcm_effect_51_wait_sample When sample 146 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_52 Command 52: sample 94 (pcm_effect_52_patch, level 20, decay step 8) at pitch F00, pan 4 (centred), keyed on for 112 passes (count); then pcm_effect_52_delay.
comment pcm_effect_52_delay When the count runs out, key off (the sample fades, 8 more attenuation every 16 passes) and a count of 256 passes; then pcm_effect_52_hold.
comment pcm_effect_52_hold After 256 passes, stop_channel, whether the sample has ended or not.
comment pcm_effect_53 Command 53: sample 92 (pcm_effect_53_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_53_wait_sample.
comment pcm_effect_53_wait_sample When sample 92 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_54 Command 54: sample 55 (pcm_effect_54_patch, level 0) at its own pitch, pan 6 (to the right), keyed on, timer 144; then pcm_effect_54_modulate.
comment pcm_effect_54_modulate Every 144 passes the pan one step to the left, from 6 down to 2 (the sound crosses from right to left in 576 passes); then pcm_effect_54_wait_sample.
comment pcm_effect_54_wait_sample When sample 55 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_55 Command 55: sample 68 (pcm_effect_55_patch, level 0) at pitch E40, pan 4 (centred), keyed on; then pcm_effect_55_wait_sample.
comment pcm_effect_55_wait_sample When sample 68 has ended (pcm_voice_playing), stop_channel.
# 3A91 "ld a,$00; call $0D72": the volume start_sound and sound_command set already (02E3, 0343 "xor a; call $0D72")
comment pcm_effect_56 Command 56: sample 79 (pcm_effect_56_patch, level 0) at pitch E00, volume 0 (set_volume), pan 6 (to the right), keyed on; then pcm_effect_56_retrigger.
comment pcm_effect_56_retrigger When the sample ends (pcm_voice_playing), key off and on again at volume 60, pan 3 (a little to the left): an echo; then pcm_effect_56_retrigger_2.
comment pcm_effect_56_retrigger_2 When it ends, a third time at volume 70, pan 2 (to the left); then pcm_effect_56_wait_sample.
comment pcm_effect_56_wait_sample When sample 79 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_57 Command 57: sample 74 (pcm_effect_57_patch, level 0, decay step 9) at pitch F00, pan 4 (centred), keyed on for 512 passes; then pcm_effect_57_retrigger.
# 3B15-3B18 "call $0E7B; call $0EBE": key_on restarts the sample (its HALT waits for the K053260), key_off only clears the voice's bit of pcm_keyed, so that run_pcm_channel decays it
comment pcm_effect_57_retrigger When the passes run out (pcm_effect_57_update), sample 74 again from its start at pitch EC0 (lower), keyed off at once so that it fades (9 more attenuation every 16 passes), for 640 passes; then pcm_effect_57_note.
comment pcm_effect_57_note When the passes run out, sample 17 (pcm_effect_57_patch_2, level 10) at pitch F60, pan 4 (centred), keyed on; then pcm_effect_57_wait_sample.
comment pcm_effect_57_wait_sample When sample 17 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_57_update One pass less (passes); true when none is left.
comment pcm_effect_58 Command 58: sample 77 (pcm_effect_58_patch, level 0) at pitch FA0, pan 4 (centred), keyed on, to play 5 times (count); then pcm_effect_58_retrigger.
comment pcm_effect_58_retrigger Each time the sample ends (pcm_voice_playing), one play less: after the last, stop_channel; before, key off and on (the sample again from its start).
comment pcm_effect_59 Command 59: sample 144 (pcm_effect_59_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_59_wait_sample.
comment pcm_effect_59_wait_sample When sample 144 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_5a Command 5A: sample 74 (pcm_effect_5a_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_5a_wait_sample.
comment pcm_effect_5a_wait_sample When sample 74 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_5b Command 5B: sample 74 (pcm_effect_5b_patch, level 0, decay step 8) at its own pitch, pan 4 (centred), keyed on and off at once, so that it fades from its start (8 more attenuation every 16 passes); then pcm_effect_5b_wait_sample.
comment pcm_effect_5b_wait_sample When sample 74 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_5c Command 5C: sample 94 (pcm_effect_5c_patch, level 0, decay step 10) at pitch F40, pan 4 (centred), keyed on for 64 passes (count); then pcm_effect_5c_delay.
comment pcm_effect_5c_delay When the count runs out, key off (the sample fades, 10 more attenuation every 16 passes) and a count of 256 passes; then pcm_effect_5c_hold.
comment pcm_effect_5c_hold After 256 passes, stop_channel, whether the sample has ended or not.
comment pcm_effect_5d Command 5D: sample 94 (pcm_effect_5d_patch, level 0, decay step 8) at its own pitch, pan 4 (centred), keyed on for 128 passes (count); then pcm_effect_5d_delay.
comment pcm_effect_5d_delay When the count runs out, key off (the sample fades, 8 more attenuation every 16 passes) and a count of 256 passes; then pcm_effect_5d_hold.
comment pcm_effect_5d_hold After 256 passes, stop_channel, whether the sample has ended or not.
comment pcm_effect_5e Command 5E: sample 77 (pcm_effect_5e_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_5e_wait_sample.
comment pcm_effect_5e_wait_sample When sample 77 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_5f Command 5F: sample 58 (pcm_effect_5f_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_5f_wait_sample.
comment pcm_effect_5f_wait_sample When sample 58 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_60 Command 60: sample 57 (pcm_effect_60_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_60_wait_sample.
comment pcm_effect_60_wait_sample When sample 57 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_61 Command 61: sample 60 (pcm_effect_61_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_61_wait_sample.
comment pcm_effect_61_wait_sample When sample 60 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_62 Command 62: sample 76 (pcm_effect_62_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_62_wait_sample.
comment pcm_effect_62_wait_sample When sample 76 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_63 Command 63: sample 56 (pcm_effect_63_patch, level 30) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_63_wait_sample.
comment pcm_effect_63_wait_sample When sample 56 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_64 Command 64: sample 64 (pcm_effect_64_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_64_wait_sample.
comment pcm_effect_64_wait_sample When sample 64 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_65 Command 65: sample 122 (pcm_effect_65_patch, level 30) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_65_wait_sample.
comment pcm_effect_65_wait_sample When sample 122 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_66 Command 66: sample 102 (pcm_effect_66_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_66_wait_sample.
comment pcm_effect_66_wait_sample When sample 102 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_67 Command 67: sample 61 (pcm_effect_67_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_67_wait_sample.
comment pcm_effect_67_wait_sample When sample 61 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_68 Command 68: sample 62 (pcm_effect_68_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_68_wait_sample.
comment pcm_effect_68_wait_sample When sample 62 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_69 Command 69: sample 63 (pcm_effect_69_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_69_wait_sample.
comment pcm_effect_69_wait_sample When sample 63 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6a Command 6A: sample 83 (pcm_effect_6a_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6a_wait_sample.
comment pcm_effect_6a_wait_sample When sample 83 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6b Command 6B: sample 66 (pcm_effect_6b_patch, level 30) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6b_wait_sample.
comment pcm_effect_6b_wait_sample When sample 66 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6c Command 6C: sample 67 (pcm_effect_6c_patch, level 40) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6c_wait_sample.
comment pcm_effect_6c_wait_sample When sample 67 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6d Command 6D: sample 75 (pcm_effect_6d_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6d_wait_sample.
comment pcm_effect_6d_wait_sample When sample 75 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6e Command 6E: sample 94 (pcm_effect_6e_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6e_wait_sample.
comment pcm_effect_6e_wait_sample When sample 94 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_6f Command 6F: sample 65 (pcm_effect_6f_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_6f_wait_sample.
comment pcm_effect_6f_wait_sample When sample 65 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_70 Command 70: sample 84 (pcm_effect_70_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_70_wait_sample.
comment pcm_effect_70_wait_sample When sample 84 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_71 Command 71: sample 93 (pcm_effect_71_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_71_wait_sample.
comment pcm_effect_71_wait_sample When sample 93 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_72 Command 72: sample 80 (pcm_effect_72_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_72_wait_sample.
comment pcm_effect_72_wait_sample When sample 80 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_73 Command 73: sample 85 (pcm_effect_73_patch, level 30) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_73_wait_sample.
comment pcm_effect_73_wait_sample When sample 85 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_74 Command 74: sample 86 (pcm_effect_74_patch, level 30) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_74_wait_sample.
comment pcm_effect_74_wait_sample When sample 86 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_75 Command 75: sample 87 (pcm_effect_75_patch, level 10) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_75_wait_sample.
comment pcm_effect_75_wait_sample When sample 87 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_76 Command 76: sample 96 (pcm_effect_76_patch, level 20) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_76_wait_sample.
comment pcm_effect_76_wait_sample When sample 96 has ended (pcm_voice_playing), stop_channel.
# 5D and 77 differ by the patch's decay step only (sample 94, 128 passes: 8, 4)
comment pcm_effect_77 Command 77: sample 94 (pcm_effect_77_patch, level 0, decay step 4) at its own pitch, pan 4 (centred), keyed on for 128 passes (count); then pcm_effect_77_delay.
comment pcm_effect_77_delay When the count runs out, key off (the sample fades, 4 more attenuation every 16 passes) and a count of 256 passes; then pcm_effect_77_hold.
comment pcm_effect_77_hold After 256 passes, stop_channel, whether the sample has ended or not.
# effect_priorities_40[78] is 00; sound_test_effects lists 40-7F but 78, and no scenario starts it (02D7 never reads effect_handlers_40's entry 78)
comment pcm_effect_78 Command 78: stop_channel at once. Its priority is 0 (effect_priorities_40), so it only takes a free record: an empty slot, which the sound test leaves out (sound_test_effects).
# 55 and 79 differ by the pitch only (sample 68: E40, its own)
comment pcm_effect_79 Command 79: sample 68 (pcm_effect_79_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_79_wait_sample.
comment pcm_effect_79_wait_sample When sample 68 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_7a Command 7A: sample 88 (pcm_effect_7a_patch, level 20) at its own pitch, pan 4 (centred), keyed on at attenuation 60 (set_volume), timer 1; then pcm_effect_7a_fade_in.
comment pcm_effect_7a_fade_in Fades in: every pass the attenuation one less (set_volume), down to 0 (96 passes), the sample played again whenever it ends (pcm_effect_7a_replay); then passes 2560 (the word over the attenuation and the timer) and pcm_effect_7a_delay.
comment pcm_effect_7a_delay Holds the sound until passes runs out, played again whenever it ends; then attenuation 0, timer 1 and pcm_effect_7a_fade_out.
comment pcm_effect_7a_fade_out Fades out: every 8 passes the attenuation one more (set_volume), the sample played again whenever it ends; at 7F, stop_channel.
comment pcm_effect_7a_replay When the sample has ended (pcm_voice_playing), key off and on: the sample again from its start.
comment pcm_effect_7b Command 7B: sample 71 (pcm_effect_7b_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_7b_wait_sample.
comment pcm_effect_7b_wait_sample When sample 71 has ended (pcm_voice_playing), stop_channel.
comment pcm_effect_7c Command 7C: sample 82 (pcm_effect_7c_patch, level 40) at its own pitch, pan 4 (centred), keyed on at attenuation 40 (set_volume), timer 1; then pcm_effect_7c_fade_in.
comment pcm_effect_7c_fade_in Fades in: every 4 passes the attenuation one less (set_volume), down to 0 (256 passes), the sample played again whenever it ends (pcm_effect_7c_replay); then passes 4352 (the word over the attenuation and the timer) and pcm_effect_7c_delay.
comment pcm_effect_7c_delay Holds the sound until passes runs out, played again whenever it ends; then attenuation 0, timer 1 and pcm_effect_7c_fade_out.
comment pcm_effect_7c_fade_out Fades out: every 8 passes the attenuation one more (set_volume), the sample played again whenever it ends; at 7F, stop_channel.
comment pcm_effect_7c_replay When the sample has ended (pcm_voice_playing), key off and on: the sample again from its start.
comment pcm_effect_7d Command 7D: sample 99 (pcm_effect_7d_patch, level 0) at its own pitch, pan 4 (centred), keyed on; then pcm_effect_7d_wait_sample.
comment pcm_effect_7d_wait_sample When sample 99 has ended (pcm_voice_playing), stop_channel.
# 7E and 7F play the same sample (89), 7E at level 50, 7F at level 30; both only in stage5
comment pcm_effect_7e Command 7E: sample 89 (pcm_effect_7e_patch, level 50) at its own pitch, pan 4 (centred), keyed on, passes 1536 (the word over the attenuation and the timer); then pcm_effect_7e_delay.
comment pcm_effect_7e_delay Holds the sound until passes runs out, the sample played again whenever it ends (pcm_effect_7e_replay); then attenuation 0, timer 1 and pcm_effect_7e_fade_out.
comment pcm_effect_7e_fade_out Fades out: every 8 passes the attenuation one more (set_volume), the sample played again whenever it ends; at 7F, stop_channel.
comment pcm_effect_7e_replay When the sample has ended (pcm_voice_playing), key off and on: the sample again from its start.
comment pcm_effect_7f Command 7F: sample 89 (pcm_effect_7f_patch, level 30) at its own pitch, its pan and volume by the position the command hands (pcm_effect_7f_set_volume), keyed on; then pcm_effect_7f_retrigger.
comment pcm_effect_7f_retrigger Every pass: when the sample has ended (pcm_voice_playing), key off and on (the sample again: it plays until position 0); then pcm_effect_7f_set_volume.
# effect_levels' entry 0 (4166-4167) would be pcm_effect_7f_patch's last two bytes: never read (position 0 stops the channel first, 419A)
comment pcm_effect_7f_set_volume The record's position (its low 3 bits; a command 7F while the effect plays changes it): 0 stops the channel, 1-7 set the pan and the volume of effect_levels (from the right, pan 7, to the left, pan 1, loudest at 4 in the centre).

# ======== parameters and locals ========
# nothing calls set_volume_stop_at_7f: its IX is a record as everywhere else (358D "ld a,(ix+$00); cp $7F", the
# attenuation the fade outs of pcm_effect_7a, 7c and 7e compare with 7F)
param   set_volume_stop_at_7f ix channel channel.pcm_effect_7a
# pcm_effect_7f_set_volume 4194-4199 "ld a,(ix+$00); and $07; or a": the position, then 419D "ld l,a" its entry
local   pcm_effect_7f_set_volume 4197 a position
# pcm_effect_42_next_note 3761-376A "ld l,(ix+$00); ld h,(ix+$01); ld e,(hl); inc hl; ld d,(hl); inc hl": the place
# of the note's pitch in the list, and the word's two bytes (the pitch; then 3776-3778, the note's length)
local   pcm_effect_42_next_note 3764,3768,376A hl note
local   pcm_effect_42_next_note 3767,3776 e word_low
local   pcm_effect_42_next_note 3769,3778 d word_high
# 3770 "push hl" around set_pitch: the place of the note's length
local   pcm_effect_42_next_note 3770 s2 saved_note
# pcm_effect_42_rest 3799-379B "ld e,(hl); inc hl; ld d,(hl)": the rest's length
local   pcm_effect_42_rest 3799 e word_low
local   pcm_effect_42_rest 379B d word_high
# pcm_effect_42_update 37B8 "dec de", then "ld (ix+$02),e; ld (ix+$03),d; ld a,e; or d": the passes left
local   pcm_effect_42_update 37B8 e passes_low
local   pcm_effect_42_update 37B8 d passes_high
# pcm_effect_57_update 3B55 "dec hl", then "ld (ix+$00),l; ld (ix+$01),h; ld a,h; or l"; the same in the delays of
# 7A, 7C and 7E (3FEF, 40A0, 4126 "dec hl"): the passes left, not the attenuation and the timer whose bytes they are
local   pcm_effect_57_update 3B55 l passes_low
local   pcm_effect_57_update 3B55 h passes_high
local   pcm_effect_7a_delay 3FEF l passes_low
local   pcm_effect_7a_delay 3FEF h passes_high
local   pcm_effect_7c_delay 40A0 l passes_low
local   pcm_effect_7c_delay 40A0 h passes_high
local   pcm_effect_7e_delay 4126 l passes_low
local   pcm_effect_7e_delay 4126 h passes_high
# pcm_effect_7f_set_volume 419D-41A4 "ld l,a; ld h,$00; add hl,hl; ld de,$4166; add hl,de": effect_levels by the
# position from 1 (its entry 0, 4166, would be the last two bytes of pcm_effect_7f_patch, which without this base
# names it: "pcm_effect_7f_patch_ADDRESS + 0x1u")
4166  table  effect_levels_by_position  u16

# ======== the drum routines (drums.c): the names, families, patches and comments ========
# ======== proposal: the drum routines (drums.c, fm_drum_1_1 49C5 to pcm_drum_b_f 5DA1) ========
# How they run: a track's E0 sets the record's drum_kit (music_tick 46A6-46C9: drum_routines = 494C + 32 x kit on an FM
# record, 4E4E + 32 x kit on a PCM one); then a note's low nibble N (45F5-4632) puts the kit's routine N in the record's
# handler, after key_off, set_music_volume, noise_off and the LFO sensitivities at 0. The routine runs at once (run_channel
# 0C18-0C21 reads the handler after music_tick), then every pass, until it leaves the note ringing (drum_done) or the
# track's next note takes the record over (its key_off: an FM note's release; a PCM voice only loses pcm_keyed, 0ECC-0ED9,
# and its sample plays out). An FM pitch is 40 a semitone (set_pitch 0DF0-0E0A: the high byte's low 5 bits modulo 24,
# times 4, and the top 2 bits of the low byte index note_codes, one semitone each; the low byte's other 6 bits are the
# key fraction); a PCM pitch is the K053260's (pcm_set_pitch), and a PCM drum that sets none plays its sample at the
# pitch of the sample's record (pcm_load_patch 0D3B-0D4E). PCM pans: 1 left, 4 the middle, 7 right (set_pan 0FA5, MAME's
# k053260 pan_mul).
# Which drums the songs play (scratch kits_used.py: every song's 12 tracks walked as the driver reads them, through F0,
# F1 and F6, with the kit E0 sets): of the FM kits only kit 1's drum 2 (song 80, the attract); no song sets FM kit 2. PCM
# drums no song plays: 1_D/E and 9_E/F (rests), 3_E, 5_F, 6_E, 6_F, 7_1, 7_4 to 7_D, A_3, A_4, A_E, A_F, B_E; PCM kits
# 1-11 are all set by some song.
# The PCM kits share a layout: drum 1 sample 125 or 126, drum 2 one of 127 to 130, drums 3 to 6 sample 133 or 134 at the
# pitches F40, F20, F00 and EE0 (kits 4 and 7: sample 68 on drum 3, the three lower pitches on 4 to 6), drum 7 sample 131
# or 132, drum 8 135, drum 9 139; kit 9 is another: samples 148 to 159 on drums 1 to C.

# ---- FM kit 1 (instrument_routines_low, 496C: drums 9 to F all fm_drum_1_9)
comment fm_drum_1_1 FM kit 1's drum 1: its patch at pitch D00, keyed on; fm_drum_1_1_slide then takes the pitch down for 80 passes.
comment fm_drum_1_1_slide The pitch 20 lower each pass (half a semitone), 79 times; at the 80th pass, drum_done.
comment fm_drum_1_2 FM kit 1's drum 2: its patch at pitch C70, keyed on; fm_drum_1_2_hold then counts 255 passes.
# fm_drum_1_2_hold, fm_drum_1_3_hold and fm_drum_1_4_hold only put drum_done off: the note rings on all the while, and
# only run_channel reads the record's handler (0C1B), so the count changes nothing heard
comment fm_drum_1_2_hold Counts the passes down, then drum_done; the note rings on all the while.
comment fm_drum_1_3 FM kit 1's drum 3: its patch at pitch E00, keyed on; fm_drum_1_3_hold then counts 128 passes.
comment fm_drum_1_3_hold Counts the passes down, then drum_done; the note rings on all the while.
comment fm_drum_1_4 FM kit 1's drum 4: drum 3 with another patch (the same connection, other operators) at pitch E00, keyed on; fm_drum_1_4_hold then counts 128 passes.
comment fm_drum_1_4_hold Counts the passes down, then drum_done; the note rings on all the while.
# fm_drum_1_5 to fm_drum_1_7: 768 steps of 0C take the pitch 2400 lower, past 0, and set_pitch keeps the high byte's low 5
# bits modulo 24: the slide jumps up where the high byte runs below 00 and below F8, three falls in all
comment fm_drum_1_5 FM kit 1's drum 5: its patch at pitch E00, keyed on; fm_drum_1_5_slide then takes the pitch down for 768 passes.
comment fm_drum_1_5_slide The pitch 0C lower each pass (3/16 of a semitone), for 768 passes, then drum_done; it runs off the bottom of set_pitch's range twice, and the wrap takes it back up each time.
comment fm_drum_1_6 FM kit 1's drum 6: drum 5 a major third lower (pitch D00), its patch drum 5's on both outputs; then fm_drum_1_6_slide.
comment fm_drum_1_6_slide The pitch 0C lower each pass, for 768 passes, then drum_done; it runs off the bottom of set_pitch's range twice, and the wrap takes it back up each time.
comment fm_drum_1_7 FM kit 1's drum 7: drum 5 two major thirds lower (pitch C00), its patch drum 5's on both outputs with less feedback; then fm_drum_1_7_slide.
comment fm_drum_1_7_slide The pitch 0C lower each pass, for 768 passes, then drum_done; it runs off the bottom of set_pitch's range twice, and the wrap takes it back up each time.
comment fm_drum_1_8 FM kit 1's drum 8: its patch at pitch 900, keyed on; fm_drum_1_8_slide then takes the pitch down for 768 passes.
comment fm_drum_1_8_slide The pitch 2 lower each pass (1/32 of a semitone), for 768 passes (two octaves, down to 300), then drum_done.
comment fm_drum_1_9 FM kit 1's drums 9 to F: nothing played (drum_done at once): the note is a rest.

# ---- FM kit 2 (498C: drums 6 to F all fm_drum_2_6); no song sets it. Its drums 1 to 5 never end: each goes on until
# the track's next note (or an effect) takes the record over
comment fm_drum_2_1 FM kit 2's drum 1: its patch (the right output only), then rising sweeps until the track's next note (fm_drum_2_1_setup).
comment fm_drum_2_1_setup Ten sweeps to go (count), then fm_drum_2_1_retrigger.
comment fm_drum_2_1_retrigger A sweep: the pitch from C00, keyed on, 192 passes (timer) of fm_drum_2_1_slide.
comment fm_drum_2_1_slide The pitch 2 higher each pass (six semitones in a sweep); at the sweep's end the next one (fm_drum_2_1_retrigger), and after the tenth, key off and ten more (fm_drum_2_1_setup).
# fm_drum_2_1 and fm_drum_2_2 are the same but for their patches' outputs (fm_drum_2_1_patch the right one only,
# fm_drum_2_2_patch the left one only: a stereo pair)
comment fm_drum_2_2 FM kit 2's drum 2: drum 1 on the left output (its patch is drum 1's but for that), rising sweeps until the track's next note (fm_drum_2_2_setup).
comment fm_drum_2_2_setup Ten sweeps to go (count), then fm_drum_2_2_retrigger.
comment fm_drum_2_2_retrigger A sweep: the pitch from C00, keyed on, 192 passes (timer) of fm_drum_2_2_slide.
comment fm_drum_2_2_slide The pitch 2 higher each pass (six semitones in a sweep); at the sweep's end the next one (fm_drum_2_2_retrigger), and after the tenth, key off and ten more (fm_drum_2_2_setup).
comment fm_drum_2_3 FM kit 2's drum 3: its patch, then rising sweeps until the track's next note (fm_drum_2_3_retrigger).
comment fm_drum_2_3_retrigger A sweep: the pitch from 600, keyed on, 128 passes (timer) of fm_drum_2_3_slide.
comment fm_drum_2_3_slide The pitch 2 higher each pass (four semitones in a sweep), then the next sweep (fm_drum_2_3_retrigger).
comment fm_drum_2_4 FM kit 2's drum 4: a note that wanders up and down at random until the track's next note: the random numbers from their start, its patch at pitch 1700, then fm_drum_2_4_retrigger.
comment fm_drum_2_4_retrigger Keys the note on for 6144 passes, a first random turn (fm_drum_2_4_random_turn), then fm_drum_2_4_slide.
comment fm_drum_2_4_slide The pitch_step added to the pitch each pass; below 800 a new random step up (fm_drum_2_4_random_step), from 1700 up a new one down (fm_drum_2_4_random_step_down), and a random turn when the timer runs out; after the 6144 passes, key off and fm_drum_2_4_retrigger again.
comment fm_drum_2_4_random_step A new timer and a new pitch_step up, 0 to 1F, from the next two random numbers (fm_drum_2_4_next_random).
comment fm_drum_2_4_random_step_down A new timer and pitch_step (fm_drum_2_4_random_step), turned down (fm_drum_2_4_reverse).
comment fm_drum_2_4_reverse The pitch_step negated: the wandering turns the other way.
comment fm_drum_2_4_random_turn A new timer and pitch_step (fm_drum_2_4_random_step), turned down when the next random number is odd (fm_drum_2_4_reverse).
comment fm_drum_2_4_next_random The next random number: the byte of the program's own code at random_index, which moves on by one (the same 256 bytes over and over).
comment fm_drum_2_5 FM kit 2's drum 5: its patch, then a note that climbs a semitone at a time, over and over until the track's next note (fm_drum_2_5_retrigger).
comment fm_drum_2_5_retrigger The pitch from 1500, keyed on: twelve steps (count) of 64 passes (timer) in fm_drum_2_5_slide.
comment fm_drum_2_5_slide Every 64 passes the pitch 40 higher (a semitone), 11 times; at the twelfth, fm_drum_2_5_retrigger again.
comment fm_drum_2_6 FM kit 2's drums 6 to F: nothing played (drum_done at once): the note is a rest.

# ---- the renames: fm_drum_2_4's helpers, which the guess named update, update_2... and transpose: they draw random
# steps and turn the step round (4DE5 negates +02, the step, not a pitch)
# 4DCF "call $4E04; ld (ix+$01),a; call $4E04; and $1F; ld (ix+$02),a; ld (ix+$03),$00": a timer and a step up, at random
# 4DE2 "call $4DCF", then into 4DE5 (the step negated): a random step down
# 4DE5-4DF4 "ld e,(ix+$02); ld d,(ix+$03); ld hl,$0000; xor a; sbc hl,de; ld (ix+$02),l; ld (ix+$03),h": the step negated
# 4DF8 "call $4DCF; call $4E04; bit 0,a; ret z; jp $4DE5": a random step, down when the next random byte is odd
# 4E04-4E0D "ld l,(ix+$00); ld h,$02; ld a,(hl); inc (ix+$00); ret": the next byte of the program's code at 0200-02FF

# ---- families: the chains that keep +00-+07 otherwise than the record's generic fields
# fm_drum_1_1 49CB-49D1 "ld hl,$0D00; ld (ix+$01),l; ld (ix+$02),h"; fm_drum_1_1_slide 49EA-49F9 "ld l,(ix+$01); ld
# h,(ix+$02); ld de,$0020; or a; sbc hl,de; ld (ix+$01),l; ld (ix+$02),h": the sliding pitch, at +01 (the generic one is at +02)
scoped  channel fm_drum_1_1 01 pitch u16
# fm_drum_1_5 4AD8-4ADE "ld hl,$0300; ld (ix+$00),l; ld (ix+$01),h"; fm_drum_1_5_slide 4AFA-4B09 "ld l,(ix+$00); ld
# h,(ix+$01); dec hl; ld (ix+$00),l; ld (ix+$01),h; ld a,l; or h; ret nz": the passes left of the slide, a word (768)
scoped  channel fm_drum_1_5 00 passes u16
# fm_drum_1_6 4B3B-4B41, fm_drum_1_6_slide 4B5D-4B6C: the same
scoped  channel fm_drum_1_6 00 passes u16
# fm_drum_1_7 4B9E-4BA4, fm_drum_1_7_slide 4BC0-4BCF: the same
scoped  channel fm_drum_1_7 00 passes u16
# fm_drum_1_8 4C01-4C07, fm_drum_1_8_slide 4C23-4C32: the same
scoped  channel fm_drum_1_8 00 passes u16
# fm_drum_2_4 4D62 "ld (ix+$00),$00"; fm_drum_2_4_next_random 4E04-4E0A "ld l,(ix+$00); ld h,$02; ld a,(hl); inc
# (ix+$00)": where in the program's bytes 0200-02FF the next random number is read
scoped  channel fm_drum_2_4 00 random_index u8
# fm_drum_2_4_random_step 4DD5-4DDD "and $1F; ld (ix+$02),a; ld (ix+$03),$00"; fm_drum_2_4_reverse 4DE5-4DF4 (negated);
# fm_drum_2_4_slide 4D8D-4D99 "ld e,(ix+$02); ld d,(ix+$03); ld l,(ix+$04); ld h,(ix+$05); add hl,de": what the pitch
# moves each pass, up or down
scoped  channel fm_drum_2_4 02 pitch_step s16
# fm_drum_2_4 4D6C-4D72 "ld hl,$1700; ld (ix+$04),l; ld (ix+$05),h"; fm_drum_2_4_slide 4D9A-4DAE "ld (ix+$04),l; ld
# (ix+$05),h; call $0DE8; ld a,(ix+$05); cp $08 ... cp $17": the wandering pitch
scoped  channel fm_drum_2_4 04 pitch u16
# fm_drum_2_4_retrigger 4D7B-4D81 "ld hl,$1800; ld (ix+$06),l; ld (ix+$07),h"; fm_drum_2_4_slide 4DB9-4DC8 "... dec hl
# ... ld a,l; or h; ret nz; call $0EBE": the passes before the note is keyed off and on again (6144)
scoped  channel fm_drum_2_4 06 passes u16

# fm_drum_2_4_random_step 4DD5 and fm_drum_2_4_random_turn 4DFB "call $4E04" (fm_drum_2_4_next_random), whose 4E09 "ld
# a,(hl)" reads the program's own byte: a random number
local   fm_drum_2_4_random_step 4DD5 a random
local   fm_drum_2_4_random_turn 4DFB a random
local   fm_drum_2_4_next_random 4E09 a random
# fm_drum_2_4_next_random 4E04-4E09 "ld l,(ix+$00); ld h,$02; ld a,(hl)": the program's 256 bytes from 0200 (sound_command's
# and start_sound's code) are the random numbers
constant fm_drum_2_4_next_random 200 RANDOM_BYTES

# ---- the FM drums' patches (load_patch 0C76-0D23: 25 bytes; the first, the connection: bit 7 the right output, bit 6
# the left, then the feedback and the algorithm. MAME wires only the YM2151's left output: a right-only patch is not heard)
# fm_drum_1_1 49C5 "ld hl,$49AC; call $0C68": the 25 bytes just before it (connection FC: both outputs, feedback 7, algorithm 4)
49AC  table  fm_drum_1_1_patch  fm_patch
# fm_drum_1_2 4A18 "ld hl,$49FF; call $0C68": the 25 bytes just before it (FC)
49FF  table  fm_drum_1_2_patch  fm_patch
# fm_drum_1_3 4A51 "ld hl,$4A38; call $0C68": the 25 bytes just before it (B8: the right output only, algorithm 0)
4A38  table  fm_drum_1_3_patch  fm_patch
# fm_drum_1_4 4A8A "ld hl,$4A71; call $0C68": the 25 bytes just before it (B8, other operators than drum 3's)
4A71  table  fm_drum_1_4_patch  fm_patch
# fm_drum_1_5 4AC3 "ld hl,$4AAA; call $0C68": the 25 bytes just before it (BC: the right output only)
4AAA  table  fm_drum_1_5_patch  fm_patch
# fm_drum_1_6 4B26 "ld hl,$4B0D; call $0C68": the 25 bytes just before it, fm_drum_1_5_patch's but for the connection (FC)
4B0D  table  fm_drum_1_6_patch  fm_patch
# fm_drum_1_7 4B89 "ld hl,$4B70; call $0C68": the 25 bytes just before it, fm_drum_1_5_patch's but for the connection (EC:
# both outputs, feedback 5)
4B70  table  fm_drum_1_7_patch  fm_patch
# fm_drum_1_8 4BEC "ld hl,$4BD3; call $0C68": the 25 bytes just before it (FC)
4BD3  table  fm_drum_1_8_patch  fm_patch
# fm_drum_2_1 4C52 "ld hl,$4C39; call $0C68": the 25 bytes just before it (BC: the right output only)
4C39  table  fm_drum_2_1_patch  fm_patch
# fm_drum_2_2 4CB1 "ld hl,$4C98; call $0C68": the 25 bytes just before it, fm_drum_2_1_patch's on the left output only (7C)
4C98  table  fm_drum_2_2_patch  fm_patch
# fm_drum_2_3 4D10 "ld hl,$4CF7; call $0C68": the 25 bytes just before it (F7: both outputs, feedback 6, algorithm 7)
4CF7  table  fm_drum_2_3_patch  fm_patch
# fm_drum_2_4 4D66 "ld hl,$4D49; call $0C68": the 25 bytes just before it (FC)
4D49  table  fm_drum_2_4_patch  fm_patch
# fm_drum_2_5 4E27 "ld hl,$4E0E; call $0C68": the 25 bytes just before it (ED: both outputs, feedback 5, algorithm 5)
4E0E  table  fm_drum_2_5_patch  fm_patch

# ---- PCM kit 1's odd ones (instrument_routines 4E6E: drum E is pcm_drum_1_d as well)
# pcm_drum_1_b and pcm_drum_1_c play three samples one after the other, but only the first is heard: key_on (0E8B "ld
# a,($F3C7); and (ix+$4d); ret nz") does nothing to a voice pcm_keyed holds, and only key_off (0ED6) lets it go, which
# neither chain calls (music_tick's key_off comes before the chain, 4612): samples 161 and 162 are loaded (pcm_load_patch
# keys the voice off on the chip, 0D2E-0D37) and never keyed. Songs 80, 81, 8B, 99, AB and AF play them
comment pcm_drum_1_b PCM kit 1's drum B: sample 160, panned 6, keyed on; then pcm_drum_1_b_note for sample 161 and then 162, neither of them heard.
comment pcm_drum_1_b_note When the voice has ended (pcm_voice_playing): sample 161, whose key_on does nothing (pcm_keyed still holds the voice), then pcm_drum_1_b_note_2.
comment pcm_drum_1_b_note_2 When the voice has ended: sample 162, whose key_on does nothing either, then drum_done.
comment pcm_drum_1_c PCM kit 1's drum C: drum B 16 passes later (count) and panned 2, in pcm_drum_1_c_note.
comment pcm_drum_1_c_note After the 16 passes, sample 160, panned 2, keyed on; then pcm_drum_1_c_note_2 for sample 161 and then 162, neither of them heard.
comment pcm_drum_1_c_note_2 When the voice has ended (pcm_voice_playing): sample 161, whose key_on does nothing (pcm_keyed still holds the voice), then pcm_drum_1_c_note_3.
comment pcm_drum_1_c_note_3 When the voice has ended: sample 162, whose key_on does nothing either, then drum_done.
comment pcm_drum_1_d PCM kit 1's drums D and E: nothing played (drum_done at once).
comment pcm_drum_9_e PCM kit 9's drums E and F: nothing played (drum_done at once).
# pcm_drum_1_b 50B7 "ld hl,$50AE; call $0C68": the first of the three patches just before it (sample 160, level 33)
50AE  table  pcm_drum_1_b_patch  pcm_patch
# pcm_drum_1_b_note 50CF "ld hl,$50B1; call $0C68": the second (sample 161, level 33)
50B1  table  pcm_drum_1_b_patch_2  pcm_patch
# pcm_drum_1_b_note_2 50E2 "ld hl,$50B4; call $0C68": the third (sample 162, level 33)
50B4  table  pcm_drum_1_b_patch_3  pcm_patch
# pcm_drum_1_c_note 5105 "ld hl,$50EE; call $0C68": the first of the three patches before pcm_drum_1_c (sample 160, level 33)
50EE  table  pcm_drum_1_c_patch  pcm_patch
# pcm_drum_1_c_note_2 511D "ld hl,$50F1; call $0C68": the second (sample 161, level 33)
50F1  table  pcm_drum_1_c_patch_2  pcm_patch
# pcm_drum_1_c_note_3 5130 "ld hl,$50F4; call $0C68": the third (sample 162, level 33)
50F4  table  pcm_drum_1_c_patch_3  pcm_patch
# every PCM drum's patch has a decay step of 0: the voice's volume never decays (run_pcm_channel 0C07-0C12 adds 0)

# ---- the alike PCM drums: a patch just before each, maybe a pitch, a pan, key_on, drum_done
comment pcm_drum_1_1 PCM kit 1's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_1_2 PCM kit 1's drum 2: sample 127 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_1_3 PCM kit 1's drum 3: sample 133 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_1_4 PCM kit 1's drum 4: sample 133 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_1_5 PCM kit 1's drum 5: sample 133 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_1_6 PCM kit 1's drum 6: sample 133 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_1_7 PCM kit 1's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_1_8 PCM kit 1's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_1_9 PCM kit 1's drum 9: sample 139 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_1_a PCM kit 1's drum A: sample 141 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_1_f PCM kit 1's drum F: sample 98 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_1 PCM kit 2's drum 1: sample 126 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_2 PCM kit 2's drum 2: sample 128 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_3 PCM kit 2's drum 3: sample 134 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_2_4 PCM kit 2's drum 4: sample 134 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_5 PCM kit 2's drum 5: sample 134 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_2_6 PCM kit 2's drum 6: sample 134 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_2_7 PCM kit 2's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_2_8 PCM kit 2's drum 8: sample 135 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_9 PCM kit 2's drum 9: sample 139 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_2_a PCM kit 2's drum A: sample 131 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_2_b PCM kit 2's drum B: sample 136 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_2_c PCM kit 2's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_2_d PCM kit 2's drum D: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_2_e PCM kit 2's drum E: sample 146 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_2_f PCM kit 2's drum F: sample 147 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_3_1 PCM kit 3's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_3_2 PCM kit 3's drum 2: sample 129 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_3_3 PCM kit 3's drum 3: sample 133 at pitch F40, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_3_4 PCM kit 3's drum 4: sample 133 at pitch F20, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_3_5 PCM kit 3's drum 5: sample 133 at pitch F00, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_3_6 PCM kit 3's drum 6: sample 133 at pitch EE0, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_3_7 PCM kit 3's drum 7: sample 131 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_3_8 PCM kit 3's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_3_9 PCM kit 3's drum 9: sample 139 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_3_a PCM kit 3's drum A: sample 128 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_3_b PCM kit 3's drum B: sample 136 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_3_c PCM kit 3's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_3_d PCM kit 3's drum D: sample 143 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_3_e PCM kit 3's drum E: sample 61 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_3_f PCM kit 3's drum F: sample 63 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_4_1 PCM kit 4's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_4_2 PCM kit 4's drum 2: sample 129 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_4_3 PCM kit 4's drum 3: sample 68 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_4_4 PCM kit 4's drum 4: sample 133 at pitch F20, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_4_5 PCM kit 4's drum 5: sample 133 at pitch F00, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_4_6 PCM kit 4's drum 6: sample 133 at pitch EE0, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_4_7 PCM kit 4's drum 7: sample 131 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_4_8 PCM kit 4's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_4_9 PCM kit 4's drum 9: sample 139 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_4_a PCM kit 4's drum A: sample 140 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_4_b PCM kit 4's drum B: sample 137 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_4_c PCM kit 4's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_4_d PCM kit 4's drum D: sample 143 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_4_e PCM kit 4's drum E: sample 147 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_4_f PCM kit 4's drum F: sample 72 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_5_1 PCM kit 5's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_5_2 PCM kit 5's drum 2: sample 127 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_5_3 PCM kit 5's drum 3: sample 133 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_5_4 PCM kit 5's drum 4: sample 133 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_5_5 PCM kit 5's drum 5: sample 133 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_5_6 PCM kit 5's drum 6: sample 133 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_5_7 PCM kit 5's drum 7: sample 131 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_5_8 PCM kit 5's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_5_9 PCM kit 5's drum 9: sample 139 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_5_a PCM kit 5's drum A: sample 128 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_5_b PCM kit 5's drum B: sample 136 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_5_c PCM kit 5's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_5_d PCM kit 5's drum D: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_5_e PCM kit 5's drum E: sample 146 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_5_f PCM kit 5's drum F: sample 147 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_6_1 PCM kit 6's drum 1: sample 126 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_6_2 PCM kit 6's drum 2: sample 127 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_6_3 PCM kit 6's drum 3: sample 133 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_6_4 PCM kit 6's drum 4: sample 133 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_6_5 PCM kit 6's drum 5: sample 133 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_6_6 PCM kit 6's drum 6: sample 133 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_6_7 PCM kit 6's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_6_8 PCM kit 6's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_6_9 PCM kit 6's drum 9: sample 139 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_6_a PCM kit 6's drum A: sample 130 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_6_b PCM kit 6's drum B: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_6_c PCM kit 6's drum C: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_6_d PCM kit 6's drum D: sample 146 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_6_e PCM kit 6's drum E: sample 53 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_6_f PCM kit 6's drum F: sample 54 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_7_1 PCM kit 7's drum 1: sample 126 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_7_2 PCM kit 7's drum 2: sample 127 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_7_3 PCM kit 7's drum 3: sample 68 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_7_4 PCM kit 7's drum 4: sample 133 at pitch F20, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_7_5 PCM kit 7's drum 5: sample 133 at pitch F00, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_7_6 PCM kit 7's drum 6: sample 133 at pitch EE0, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_7_7 PCM kit 7's drum 7: sample 131 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_7_8 PCM kit 7's drum 8: sample 135 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_7_9 PCM kit 7's drum 9: sample 139 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_7_a PCM kit 7's drum A: sample 140 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_7_b PCM kit 7's drum B: sample 137 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_7_c PCM kit 7's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_7_d PCM kit 7's drum D: sample 143 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_7_e PCM kit 7's drum E: sample 147 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_7_f PCM kit 7's drum F: sample 72 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_1 PCM kit 8's drum 1: sample 126 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_2 PCM kit 8's drum 2: sample 130 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_3 PCM kit 8's drum 3: sample 134 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_8_4 PCM kit 8's drum 4: sample 133 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_5 PCM kit 8's drum 5: sample 133 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_8_6 PCM kit 8's drum 6: sample 133 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_8_7 PCM kit 8's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_8_8 PCM kit 8's drum 8: sample 135 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_9 PCM kit 8's drum 9: sample 139 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_8_a PCM kit 8's drum A: sample 131 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_8_b PCM kit 8's drum B: sample 136 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_8_c PCM kit 8's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_8_d PCM kit 8's drum D: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_8_e PCM kit 8's drum E: sample 146 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_8_f PCM kit 8's drum F: sample 147 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_9_1 PCM kit 9's drum 1: sample 148 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_9_2 PCM kit 9's drum 2: sample 149 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_9_3 PCM kit 9's drum 3: sample 150 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_9_4 PCM kit 9's drum 4: sample 151 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_9_5 PCM kit 9's drum 5: sample 152 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_9_6 PCM kit 9's drum 6: sample 153 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_9_7 PCM kit 9's drum 7: sample 154 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_9_8 PCM kit 9's drum 8: sample 155 at its own pitch, panned 5, keyed on and left ringing (drum_done).
comment pcm_drum_9_9 PCM kit 9's drum 9: sample 156 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_9_a PCM kit 9's drum A: sample 157 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_9_b PCM kit 9's drum B: sample 158 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_9_c PCM kit 9's drum C: sample 159 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_9_d PCM kit 9's drum D: sample 95 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_1 PCM kit A's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_2 PCM kit A's drum 2: sample 128 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_3 PCM kit A's drum 3: sample 134 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_a_4 PCM kit A's drum 4: sample 134 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_5 PCM kit A's drum 5: sample 134 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_a_6 PCM kit A's drum 6: sample 134 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_a_7 PCM kit A's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_a_8 PCM kit A's drum 8: sample 135 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_9 PCM kit A's drum 9: sample 139 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_a_a PCM kit A's drum A: sample 131 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_a_b PCM kit A's drum B: sample 136 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_a_c PCM kit A's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_a_d PCM kit A's drum D: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_a_e PCM kit A's drum E: sample 146 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_a_f PCM kit A's drum F: sample 147 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_b_1 PCM kit B's drum 1: sample 125 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_b_2 PCM kit B's drum 2: sample 130 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_b_3 PCM kit B's drum 3: sample 134 at pitch F40, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_b_4 PCM kit B's drum 4: sample 133 at pitch F20, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_b_5 PCM kit B's drum 5: sample 133 at pitch F00, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_b_6 PCM kit B's drum 6: sample 133 at pitch EE0, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_b_7 PCM kit B's drum 7: sample 132 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_b_8 PCM kit B's drum 8: sample 135 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_b_9 PCM kit B's drum 9: sample 139 at its own pitch, panned 7, keyed on and left ringing (drum_done).
comment pcm_drum_b_a PCM kit B's drum A: sample 131 at its own pitch, panned 1, keyed on and left ringing (drum_done).
comment pcm_drum_b_b PCM kit B's drum B: sample 136 at its own pitch, panned 6, keyed on and left ringing (drum_done).
comment pcm_drum_b_c PCM kit B's drum C: sample 142 at its own pitch, panned 2, keyed on and left ringing (drum_done).
comment pcm_drum_b_d PCM kit B's drum D: sample 143 at its own pitch, panned 3, keyed on and left ringing (drum_done).
comment pcm_drum_b_e PCM kit B's drum E: sample 146 at its own pitch, panned 4, keyed on and left ringing (drum_done).
comment pcm_drum_b_f PCM kit B's drum F: sample 147 at its own pitch, panned 3, keyed on and left ringing (drum_done).

# ---- their patches
# pcm_drum_1_1 4FD1 "ld hl,$4FCE; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2C, decay step 0
4FCE  table  pcm_drum_1_1_patch  pcm_patch
# pcm_drum_1_2 4FE5 "ld hl,$4FE2; call $0C68" (load_patch): the 3 bytes just before it, sample 127, level 36, decay step 0
4FE2  table  pcm_drum_1_2_patch  pcm_patch
# pcm_drum_1_3 4FF9 "ld hl,$4FF6; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
4FF6  table  pcm_drum_1_3_patch  pcm_patch
# pcm_drum_1_4 5013 "ld hl,$5010; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5010  table  pcm_drum_1_4_patch  pcm_patch
# pcm_drum_1_5 502D "ld hl,$502A; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
502A  table  pcm_drum_1_5_patch  pcm_patch
# pcm_drum_1_6 5047 "ld hl,$5044; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5044  table  pcm_drum_1_6_patch  pcm_patch
# pcm_drum_1_7 5061 "ld hl,$505E; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 30, decay step 0
505E  table  pcm_drum_1_7_patch  pcm_patch
# pcm_drum_1_8 5075 "ld hl,$5072; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
5072  table  pcm_drum_1_8_patch  pcm_patch
# pcm_drum_1_9 5089 "ld hl,$5086; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
5086  table  pcm_drum_1_9_patch  pcm_patch
# pcm_drum_1_a 509D "ld hl,$509A; call $0C68" (load_patch): the 3 bytes just before it, sample 141, level 60, decay step 0
509A  table  pcm_drum_1_a_patch  pcm_patch
# pcm_drum_1_f 5142 "ld hl,$513F; call $0C68" (load_patch): the 3 bytes just before it, sample 98, level 00, decay step 0
513F  table  pcm_drum_1_f_patch  pcm_patch
# pcm_drum_2_1 5156 "ld hl,$5153; call $0C68" (load_patch): the 3 bytes just before it, sample 126, level 30, decay step 0
5153  table  pcm_drum_2_1_patch  pcm_patch
# pcm_drum_2_2 516A "ld hl,$5167; call $0C68" (load_patch): the 3 bytes just before it, sample 128, level 21, decay step 0
5167  table  pcm_drum_2_2_patch  pcm_patch
# pcm_drum_2_3 517E "ld hl,$517B; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
517B  table  pcm_drum_2_3_patch  pcm_patch
# pcm_drum_2_4 5198 "ld hl,$5195; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5195  table  pcm_drum_2_4_patch  pcm_patch
# pcm_drum_2_5 51B2 "ld hl,$51AF; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
51AF  table  pcm_drum_2_5_patch  pcm_patch
# pcm_drum_2_6 51CC "ld hl,$51C9; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
51C9  table  pcm_drum_2_6_patch  pcm_patch
# pcm_drum_2_7 51E6 "ld hl,$51E3; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 30, decay step 0
51E3  table  pcm_drum_2_7_patch  pcm_patch
# pcm_drum_2_8 51FA "ld hl,$51F7; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 30, decay step 0
51F7  table  pcm_drum_2_8_patch  pcm_patch
# pcm_drum_2_9 520E "ld hl,$520B; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 4A, decay step 0
520B  table  pcm_drum_2_9_patch  pcm_patch
# pcm_drum_2_a 5222 "ld hl,$521F; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 43, decay step 0
521F  table  pcm_drum_2_a_patch  pcm_patch
# pcm_drum_2_b 5236 "ld hl,$5233; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 20, decay step 0
5233  table  pcm_drum_2_b_patch  pcm_patch
# pcm_drum_2_c 524A "ld hl,$5247; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
5247  table  pcm_drum_2_c_patch  pcm_patch
# pcm_drum_2_d 525E "ld hl,$525B; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 20, decay step 0
525B  table  pcm_drum_2_d_patch  pcm_patch
# pcm_drum_2_e 5272 "ld hl,$526F; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 44, decay step 0
526F  table  pcm_drum_2_e_patch  pcm_patch
# pcm_drum_2_f 5286 "ld hl,$5283; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 30, decay step 0
5283  table  pcm_drum_2_f_patch  pcm_patch
# pcm_drum_3_1 529A "ld hl,$5297; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2E, decay step 0
5297  table  pcm_drum_3_1_patch  pcm_patch
# pcm_drum_3_2 52AE "ld hl,$52AB; call $0C68" (load_patch): the 3 bytes just before it, sample 129, level 13, decay step 0
52AB  table  pcm_drum_3_2_patch  pcm_patch
# pcm_drum_3_3 52C2 "ld hl,$52BF; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
52BF  table  pcm_drum_3_3_patch  pcm_patch
# pcm_drum_3_4 52DC "ld hl,$52D9; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
52D9  table  pcm_drum_3_4_patch  pcm_patch
# pcm_drum_3_5 52F6 "ld hl,$52F3; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
52F3  table  pcm_drum_3_5_patch  pcm_patch
# pcm_drum_3_6 5310 "ld hl,$530D; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
530D  table  pcm_drum_3_6_patch  pcm_patch
# pcm_drum_3_7 532A "ld hl,$5327; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 33, decay step 0
5327  table  pcm_drum_3_7_patch  pcm_patch
# pcm_drum_3_8 533E "ld hl,$533B; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
533B  table  pcm_drum_3_8_patch  pcm_patch
# pcm_drum_3_9 5352 "ld hl,$534F; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
534F  table  pcm_drum_3_9_patch  pcm_patch
# pcm_drum_3_a 5366 "ld hl,$5363; call $0C68" (load_patch): the 3 bytes just before it, sample 128, level 19, decay step 0
5363  table  pcm_drum_3_a_patch  pcm_patch
# pcm_drum_3_b 537A "ld hl,$5377; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 2C, decay step 0
5377  table  pcm_drum_3_b_patch  pcm_patch
# pcm_drum_3_c 538E "ld hl,$538B; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
538B  table  pcm_drum_3_c_patch  pcm_patch
# pcm_drum_3_d 53A2 "ld hl,$539F; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 2E, decay step 0
539F  table  pcm_drum_3_d_patch  pcm_patch
# pcm_drum_3_e 53B6 "ld hl,$53B3; call $0C68" (load_patch): the 3 bytes just before it, sample 61, level 30, decay step 0
53B3  table  pcm_drum_3_e_patch  pcm_patch
# pcm_drum_3_f 53CA "ld hl,$53C7; call $0C68" (load_patch): the 3 bytes just before it, sample 63, level 30, decay step 0
53C7  table  pcm_drum_3_f_patch  pcm_patch
# pcm_drum_4_1 53DE "ld hl,$53DB; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2F, decay step 0
53DB  table  pcm_drum_4_1_patch  pcm_patch
# pcm_drum_4_2 53F2 "ld hl,$53EF; call $0C68" (load_patch): the 3 bytes just before it, sample 129, level 11, decay step 0
53EF  table  pcm_drum_4_2_patch  pcm_patch
# pcm_drum_4_3 5406 "ld hl,$5403; call $0C68" (load_patch): the 3 bytes just before it, sample 68, level 2C, decay step 0
5403  table  pcm_drum_4_3_patch  pcm_patch
# pcm_drum_4_4 541A "ld hl,$5417; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5417  table  pcm_drum_4_4_patch  pcm_patch
# pcm_drum_4_5 5434 "ld hl,$5431; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5431  table  pcm_drum_4_5_patch  pcm_patch
# pcm_drum_4_6 544E "ld hl,$544B; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
544B  table  pcm_drum_4_6_patch  pcm_patch
# pcm_drum_4_7 5468 "ld hl,$5465; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 33, decay step 0
5465  table  pcm_drum_4_7_patch  pcm_patch
# pcm_drum_4_8 547C "ld hl,$5479; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
5479  table  pcm_drum_4_8_patch  pcm_patch
# pcm_drum_4_9 5490 "ld hl,$548D; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
548D  table  pcm_drum_4_9_patch  pcm_patch
# pcm_drum_4_a 54A4 "ld hl,$54A1; call $0C68" (load_patch): the 3 bytes just before it, sample 140, level 35, decay step 0
54A1  table  pcm_drum_4_a_patch  pcm_patch
# pcm_drum_4_b 54B8 "ld hl,$54B5; call $0C68" (load_patch): the 3 bytes just before it, sample 137, level 38, decay step 0
54B5  table  pcm_drum_4_b_patch  pcm_patch
# pcm_drum_4_c 54CC "ld hl,$54C9; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 39, decay step 0
54C9  table  pcm_drum_4_c_patch  pcm_patch
# pcm_drum_4_d 54E0 "ld hl,$54DD; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 32, decay step 0
54DD  table  pcm_drum_4_d_patch  pcm_patch
# pcm_drum_4_e 54F4 "ld hl,$54F1; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 24, decay step 0
54F1  table  pcm_drum_4_e_patch  pcm_patch
# pcm_drum_4_f 5508 "ld hl,$5505; call $0C68" (load_patch): the 3 bytes just before it, sample 72, level 00, decay step 0
5505  table  pcm_drum_4_f_patch  pcm_patch
# pcm_drum_5_1 551C "ld hl,$5519; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2C, decay step 0
5519  table  pcm_drum_5_1_patch  pcm_patch
# pcm_drum_5_2 5530 "ld hl,$552D; call $0C68" (load_patch): the 3 bytes just before it, sample 127, level 1F, decay step 0
552D  table  pcm_drum_5_2_patch  pcm_patch
# pcm_drum_5_3 5544 "ld hl,$5541; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5541  table  pcm_drum_5_3_patch  pcm_patch
# pcm_drum_5_4 555E "ld hl,$555B; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
555B  table  pcm_drum_5_4_patch  pcm_patch
# pcm_drum_5_5 5578 "ld hl,$5575; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5575  table  pcm_drum_5_5_patch  pcm_patch
# pcm_drum_5_6 5592 "ld hl,$558F; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
558F  table  pcm_drum_5_6_patch  pcm_patch
# pcm_drum_5_7 55AC "ld hl,$55A9; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 43, decay step 0
55A9  table  pcm_drum_5_7_patch  pcm_patch
# pcm_drum_5_8 55C0 "ld hl,$55BD; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
55BD  table  pcm_drum_5_8_patch  pcm_patch
# pcm_drum_5_9 55D4 "ld hl,$55D1; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
55D1  table  pcm_drum_5_9_patch  pcm_patch
# pcm_drum_5_a 55E8 "ld hl,$55E5; call $0C68" (load_patch): the 3 bytes just before it, sample 128, level 19, decay step 0
55E5  table  pcm_drum_5_a_patch  pcm_patch
# pcm_drum_5_b 55FC "ld hl,$55F9; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 20, decay step 0
55F9  table  pcm_drum_5_b_patch  pcm_patch
# pcm_drum_5_c 5610 "ld hl,$560D; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
560D  table  pcm_drum_5_c_patch  pcm_patch
# pcm_drum_5_d 5624 "ld hl,$5621; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 2E, decay step 0
5621  table  pcm_drum_5_d_patch  pcm_patch
# pcm_drum_5_e 5638 "ld hl,$5635; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 44, decay step 0
5635  table  pcm_drum_5_e_patch  pcm_patch
# pcm_drum_5_f 564C "ld hl,$5649; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 30, decay step 0
5649  table  pcm_drum_5_f_patch  pcm_patch
# pcm_drum_6_1 5660 "ld hl,$565D; call $0C68" (load_patch): the 3 bytes just before it, sample 126, level 29, decay step 0
565D  table  pcm_drum_6_1_patch  pcm_patch
# pcm_drum_6_2 5674 "ld hl,$5671; call $0C68" (load_patch): the 3 bytes just before it, sample 127, level 2B, decay step 0
5671  table  pcm_drum_6_2_patch  pcm_patch
# pcm_drum_6_3 5688 "ld hl,$5685; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5685  table  pcm_drum_6_3_patch  pcm_patch
# pcm_drum_6_4 56A2 "ld hl,$569F; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
569F  table  pcm_drum_6_4_patch  pcm_patch
# pcm_drum_6_5 56BC "ld hl,$56B9; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
56B9  table  pcm_drum_6_5_patch  pcm_patch
# pcm_drum_6_6 56D6 "ld hl,$56D3; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
56D3  table  pcm_drum_6_6_patch  pcm_patch
# pcm_drum_6_7 56F0 "ld hl,$56ED; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 30, decay step 0
56ED  table  pcm_drum_6_7_patch  pcm_patch
# pcm_drum_6_8 5704 "ld hl,$5701; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
5701  table  pcm_drum_6_8_patch  pcm_patch
# pcm_drum_6_9 5718 "ld hl,$5715; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
5715  table  pcm_drum_6_9_patch  pcm_patch
# pcm_drum_6_a 572C "ld hl,$5729; call $0C68" (load_patch): the 3 bytes just before it, sample 130, level 2A, decay step 0
5729  table  pcm_drum_6_a_patch  pcm_patch
# pcm_drum_6_b 5740 "ld hl,$573D; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
573D  table  pcm_drum_6_b_patch  pcm_patch
# pcm_drum_6_c 5754 "ld hl,$5751; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 2E, decay step 0
5751  table  pcm_drum_6_c_patch  pcm_patch
# pcm_drum_6_d 5768 "ld hl,$5765; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 3A, decay step 0
5765  table  pcm_drum_6_d_patch  pcm_patch
# pcm_drum_6_e 577C "ld hl,$5779; call $0C68" (load_patch): the 3 bytes just before it, sample 53, level 00, decay step 0
5779  table  pcm_drum_6_e_patch  pcm_patch
# pcm_drum_6_f 5790 "ld hl,$578D; call $0C68" (load_patch): the 3 bytes just before it, sample 54, level 10, decay step 0
578D  table  pcm_drum_6_f_patch  pcm_patch
# pcm_drum_7_1 57A4 "ld hl,$57A1; call $0C68" (load_patch): the 3 bytes just before it, sample 126, level 29, decay step 0
57A1  table  pcm_drum_7_1_patch  pcm_patch
# pcm_drum_7_2 57B8 "ld hl,$57B5; call $0C68" (load_patch): the 3 bytes just before it, sample 127, level 22, decay step 0
57B5  table  pcm_drum_7_2_patch  pcm_patch
# pcm_drum_7_3 57CC "ld hl,$57C9; call $0C68" (load_patch): the 3 bytes just before it, sample 68, level 2C, decay step 0
57C9  table  pcm_drum_7_3_patch  pcm_patch
# pcm_drum_7_4 57E0 "ld hl,$57DD; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
57DD  table  pcm_drum_7_4_patch  pcm_patch
# pcm_drum_7_5 57FA "ld hl,$57F7; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
57F7  table  pcm_drum_7_5_patch  pcm_patch
# pcm_drum_7_6 5814 "ld hl,$5811; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5811  table  pcm_drum_7_6_patch  pcm_patch
# pcm_drum_7_7 582E "ld hl,$582B; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 33, decay step 0
582B  table  pcm_drum_7_7_patch  pcm_patch
# pcm_drum_7_8 5842 "ld hl,$583F; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 23, decay step 0
583F  table  pcm_drum_7_8_patch  pcm_patch
# pcm_drum_7_9 5856 "ld hl,$5853; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 56, decay step 0
5853  table  pcm_drum_7_9_patch  pcm_patch
# pcm_drum_7_a 586A "ld hl,$5867; call $0C68" (load_patch): the 3 bytes just before it, sample 140, level 35, decay step 0
5867  table  pcm_drum_7_a_patch  pcm_patch
# pcm_drum_7_b 587E "ld hl,$587B; call $0C68" (load_patch): the 3 bytes just before it, sample 137, level 38, decay step 0
587B  table  pcm_drum_7_b_patch  pcm_patch
# pcm_drum_7_c 5892 "ld hl,$588F; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 39, decay step 0
588F  table  pcm_drum_7_c_patch  pcm_patch
# pcm_drum_7_d 58A6 "ld hl,$58A3; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 32, decay step 0
58A3  table  pcm_drum_7_d_patch  pcm_patch
# pcm_drum_7_e 58BA "ld hl,$58B7; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 24, decay step 0
58B7  table  pcm_drum_7_e_patch  pcm_patch
# pcm_drum_7_f 58CE "ld hl,$58CB; call $0C68" (load_patch): the 3 bytes just before it, sample 72, level 00, decay step 0
58CB  table  pcm_drum_7_f_patch  pcm_patch
# pcm_drum_8_1 58E2 "ld hl,$58DF; call $0C68" (load_patch): the 3 bytes just before it, sample 126, level 2D, decay step 0
58DF  table  pcm_drum_8_1_patch  pcm_patch
# pcm_drum_8_2 58F6 "ld hl,$58F3; call $0C68" (load_patch): the 3 bytes just before it, sample 130, level 2B, decay step 0
58F3  table  pcm_drum_8_2_patch  pcm_patch
# pcm_drum_8_3 590A "ld hl,$5907; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5907  table  pcm_drum_8_3_patch  pcm_patch
# pcm_drum_8_4 5924 "ld hl,$5921; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5921  table  pcm_drum_8_4_patch  pcm_patch
# pcm_drum_8_5 593E "ld hl,$593B; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
593B  table  pcm_drum_8_5_patch  pcm_patch
# pcm_drum_8_6 5958 "ld hl,$5955; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5955  table  pcm_drum_8_6_patch  pcm_patch
# pcm_drum_8_7 5972 "ld hl,$596F; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 38, decay step 0
596F  table  pcm_drum_8_7_patch  pcm_patch
# pcm_drum_8_8 5986 "ld hl,$5983; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 30, decay step 0
5983  table  pcm_drum_8_8_patch  pcm_patch
# pcm_drum_8_9 599A "ld hl,$5997; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 3E, decay step 0
5997  table  pcm_drum_8_9_patch  pcm_patch
# pcm_drum_8_a 59AE "ld hl,$59AB; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 40, decay step 0
59AB  table  pcm_drum_8_a_patch  pcm_patch
# pcm_drum_8_b 59C2 "ld hl,$59BF; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 1E, decay step 0
59BF  table  pcm_drum_8_b_patch  pcm_patch
# pcm_drum_8_c 59D6 "ld hl,$59D3; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
59D3  table  pcm_drum_8_c_patch  pcm_patch
# pcm_drum_8_d 59EA "ld hl,$59E7; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 20, decay step 0
59E7  table  pcm_drum_8_d_patch  pcm_patch
# pcm_drum_8_e 59FE "ld hl,$59FB; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 44, decay step 0
59FB  table  pcm_drum_8_e_patch  pcm_patch
# pcm_drum_8_f 5A12 "ld hl,$5A0F; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 30, decay step 0
5A0F  table  pcm_drum_8_f_patch  pcm_patch
# pcm_drum_9_1 5A26 "ld hl,$5A23; call $0C68" (load_patch): the 3 bytes just before it, sample 148, level 1C, decay step 0
5A23  table  pcm_drum_9_1_patch  pcm_patch
# pcm_drum_9_2 5A3A "ld hl,$5A37; call $0C68" (load_patch): the 3 bytes just before it, sample 149, level 22, decay step 0
5A37  table  pcm_drum_9_2_patch  pcm_patch
# pcm_drum_9_3 5A4E "ld hl,$5A4B; call $0C68" (load_patch): the 3 bytes just before it, sample 150, level 20, decay step 0
5A4B  table  pcm_drum_9_3_patch  pcm_patch
# pcm_drum_9_4 5A62 "ld hl,$5A5F; call $0C68" (load_patch): the 3 bytes just before it, sample 151, level 20, decay step 0
5A5F  table  pcm_drum_9_4_patch  pcm_patch
# pcm_drum_9_5 5A76 "ld hl,$5A73; call $0C68" (load_patch): the 3 bytes just before it, sample 152, level 30, decay step 0
5A73  table  pcm_drum_9_5_patch  pcm_patch
# pcm_drum_9_6 5A8A "ld hl,$5A87; call $0C68" (load_patch): the 3 bytes just before it, sample 153, level 20, decay step 0
5A87  table  pcm_drum_9_6_patch  pcm_patch
# pcm_drum_9_7 5A9E "ld hl,$5A9B; call $0C68" (load_patch): the 3 bytes just before it, sample 154, level 20, decay step 0
5A9B  table  pcm_drum_9_7_patch  pcm_patch
# pcm_drum_9_8 5AB2 "ld hl,$5AAF; call $0C68" (load_patch): the 3 bytes just before it, sample 155, level 20, decay step 0
5AAF  table  pcm_drum_9_8_patch  pcm_patch
# pcm_drum_9_9 5AC6 "ld hl,$5AC3; call $0C68" (load_patch): the 3 bytes just before it, sample 156, level 20, decay step 0
5AC3  table  pcm_drum_9_9_patch  pcm_patch
# pcm_drum_9_a 5ADA "ld hl,$5AD7; call $0C68" (load_patch): the 3 bytes just before it, sample 157, level 20, decay step 0
5AD7  table  pcm_drum_9_a_patch  pcm_patch
# pcm_drum_9_b 5AEE "ld hl,$5AEB; call $0C68" (load_patch): the 3 bytes just before it, sample 158, level 20, decay step 0
5AEB  table  pcm_drum_9_b_patch  pcm_patch
# pcm_drum_9_c 5B02 "ld hl,$5AFF; call $0C68" (load_patch): the 3 bytes just before it, sample 159, level 20, decay step 0
5AFF  table  pcm_drum_9_c_patch  pcm_patch
# pcm_drum_9_d 5B16 "ld hl,$5B13; call $0C68" (load_patch): the 3 bytes just before it, sample 95, level 20, decay step 0
5B13  table  pcm_drum_9_d_patch  pcm_patch
# pcm_drum_a_1 5B2D "ld hl,$5B2A; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2E, decay step 0
5B2A  table  pcm_drum_a_1_patch  pcm_patch
# pcm_drum_a_2 5B41 "ld hl,$5B3E; call $0C68" (load_patch): the 3 bytes just before it, sample 128, level 1F, decay step 0
5B3E  table  pcm_drum_a_2_patch  pcm_patch
# pcm_drum_a_3 5B55 "ld hl,$5B52; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5B52  table  pcm_drum_a_3_patch  pcm_patch
# pcm_drum_a_4 5B6F "ld hl,$5B6C; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5B6C  table  pcm_drum_a_4_patch  pcm_patch
# pcm_drum_a_5 5B89 "ld hl,$5B86; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5B86  table  pcm_drum_a_5_patch  pcm_patch
# pcm_drum_a_6 5BA3 "ld hl,$5BA0; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5BA0  table  pcm_drum_a_6_patch  pcm_patch
# pcm_drum_a_7 5BBD "ld hl,$5BBA; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 30, decay step 0
5BBA  table  pcm_drum_a_7_patch  pcm_patch
# pcm_drum_a_8 5BD1 "ld hl,$5BCE; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 30, decay step 0
5BCE  table  pcm_drum_a_8_patch  pcm_patch
# pcm_drum_a_9 5BE5 "ld hl,$5BE2; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 4A, decay step 0
5BE2  table  pcm_drum_a_9_patch  pcm_patch
# pcm_drum_a_a 5BF9 "ld hl,$5BF6; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 43, decay step 0
5BF6  table  pcm_drum_a_a_patch  pcm_patch
# pcm_drum_a_b 5C0D "ld hl,$5C0A; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 20, decay step 0
5C0A  table  pcm_drum_a_b_patch  pcm_patch
# pcm_drum_a_c 5C21 "ld hl,$5C1E; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
5C1E  table  pcm_drum_a_c_patch  pcm_patch
# pcm_drum_a_d 5C35 "ld hl,$5C32; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 20, decay step 0
5C32  table  pcm_drum_a_d_patch  pcm_patch
# pcm_drum_a_e 5C49 "ld hl,$5C46; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 44, decay step 0
5C46  table  pcm_drum_a_e_patch  pcm_patch
# pcm_drum_a_f 5C5D "ld hl,$5C5A; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 30, decay step 0
5C5A  table  pcm_drum_a_f_patch  pcm_patch
# pcm_drum_b_1 5C71 "ld hl,$5C6E; call $0C68" (load_patch): the 3 bytes just before it, sample 125, level 2E, decay step 0
5C6E  table  pcm_drum_b_1_patch  pcm_patch
# pcm_drum_b_2 5C85 "ld hl,$5C82; call $0C68" (load_patch): the 3 bytes just before it, sample 130, level 29, decay step 0
5C82  table  pcm_drum_b_2_patch  pcm_patch
# pcm_drum_b_3 5C99 "ld hl,$5C96; call $0C68" (load_patch): the 3 bytes just before it, sample 134, level 40, decay step 0
5C96  table  pcm_drum_b_3_patch  pcm_patch
# pcm_drum_b_5 5CCD "ld hl,$5CCA; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5CCA  table  pcm_drum_b_5_patch  pcm_patch
# pcm_drum_b_6 5CE7 "ld hl,$5CE4; call $0C68" (load_patch): the 3 bytes just before it, sample 133, level 30, decay step 0
5CE4  table  pcm_drum_b_6_patch  pcm_patch
# pcm_drum_b_7 5D01 "ld hl,$5CFE; call $0C68" (load_patch): the 3 bytes just before it, sample 132, level 38, decay step 0
5CFE  table  pcm_drum_b_7_patch  pcm_patch
# pcm_drum_b_8 5D15 "ld hl,$5D12; call $0C68" (load_patch): the 3 bytes just before it, sample 135, level 30, decay step 0
5D12  table  pcm_drum_b_8_patch  pcm_patch
# pcm_drum_b_9 5D29 "ld hl,$5D26; call $0C68" (load_patch): the 3 bytes just before it, sample 139, level 3E, decay step 0
5D26  table  pcm_drum_b_9_patch  pcm_patch
# pcm_drum_b_a 5D3D "ld hl,$5D3A; call $0C68" (load_patch): the 3 bytes just before it, sample 131, level 40, decay step 0
5D3A  table  pcm_drum_b_a_patch  pcm_patch
# pcm_drum_b_b 5D51 "ld hl,$5D4E; call $0C68" (load_patch): the 3 bytes just before it, sample 136, level 1E, decay step 0
5D4E  table  pcm_drum_b_b_patch  pcm_patch
# pcm_drum_b_c 5D65 "ld hl,$5D62; call $0C68" (load_patch): the 3 bytes just before it, sample 142, level 31, decay step 0
5D62  table  pcm_drum_b_c_patch  pcm_patch
# pcm_drum_b_d 5D79 "ld hl,$5D76; call $0C68" (load_patch): the 3 bytes just before it, sample 143, level 20, decay step 0
5D76  table  pcm_drum_b_d_patch  pcm_patch
# pcm_drum_b_e 5D8D "ld hl,$5D8A; call $0C68" (load_patch): the 3 bytes just before it, sample 146, level 44, decay step 0
5D8A  table  pcm_drum_b_e_patch  pcm_patch
# pcm_drum_b_f 5DA1 "ld hl,$5D9E; call $0C68" (load_patch): the 3 bytes just before it, sample 147, level 30, decay step 0
5D9E  table  pcm_drum_b_f_patch  pcm_patch

# ======== the driver's variables still named after a register, by what they hold ========
# the RAM test (0930-094F "ld hl,$F000; ld bc,$0800; ld a,$55; ld (hl),a; cp (hl) ... inc hl; dec bc"): the place tested and the bytes left; the ROM test (095C-09DF "ld hl,$0000; ld bc,$0000; ld a,(bc); ld e,a; ld d,$00; add hl,de; inc bc"): the sum and the place added; self_test_failed 0B2B "ld bc,$1000; dec bc": a delay
local   sound_reset 092D,093A,0941,094E hl address
local   sound_reset 0930,093B,0944,094F bc bytes_left
local   check_rom 095C,0966,097A,098E,09A2,09B6,09CA,09DE,09E9 hl sum
local   check_rom 095F,0967,0973,097B,0987,098F,099B,09A3,09AF,09B7,09C3,09CB,09D7,09DF bc address
local   self_test_failed 0B2B,0B2E bc delay
# sound_command 0075 "ld a,c" the command; 007B/049C... "ex af,af'; ld e,a; ex af,af'; bit 0,e": the self test's failures (the other bank's A); 04CE-0523 "exx; ld a,c; exx" the sums the commands F2-F7 hand back; 0534-0826 (FE) "ld bc,$0000 ... add hl,de; dec bc" the sample ROMs' sums and the bytes left; 0231 "ld de,$0050; add ix,de" the records' stride
local   sound_command 0075 a command
local   sound_command 049C,049E,04B5,04BE,04C5,007B,04D6,04E7,04F8,0509,051A,052B,0881 a failures
local   sound_command 049D,007C de failure_bits
local   sound_command 04CE,04DF bc program_sum
local   sound_command 0554,055E,0577,0581,059A,05A4,05BD,05C7,05E0,05EA,0603,060D,0626,0630,0649,0653,066C,0676,068F,0699,06B2,06BC,06D5,06DF,06F8,0702,071B,0725,073E,0748,0761,076B,07A6,07B0,07C9,07D3,07EC,07F6,080F,0819 bc bytes_left
local   sound_command 04F0,0501 de sample_1_sum
local   sound_command 0231,0244,02EB,0303 de stride
local   sound_command 0512,0523 hl sample_2_sum
local   sound_command 053E,055D,0580,05A3,05C6,05E9,060C,062F,0652,0675,0698,06BB,06DE,0701,0724,0747,076A,0774,0790,07AF,07D2,07F5,0818,0822,0256,0315 hl sum
# start_sound 017C "ld de,$0050; add ix,de" the records' stride; 019F-01A1 "push ix; pop hl" the record of the lowest priority so far (01A6 "push hl; pop ix"); 03D9 "sub $40; ld c,a" (C0-EF) the song to play after the fade
local   start_sound 017C,018F,0290,02A3 de stride
local   start_sound 01A1,02B5 hl lowest
local   start_sound 03DB c next_song
# stop_all_channels 0103 runs into stop_music, which leaves the last record in IX (0153 "ld ix,$F373") and 0 in A (015A "xor a", what it clears the fade with), which the main loop's fade compares on (0BC9-0BCC "call z,$0106; cp $30"); sound_main 0B1F hands IX back; sound_main 0B17 "ex af,af'; ld e,a" the failures
local   stop_all_channels 0103 ix last_channel
local   stop_music 0153 ix last_channel
local   stop_music 015A a cleared
local   sound_main 0B17 a failures
local   sound_main 0B1F ix last_channel
# start_song 035D "pop af": the command again (0351 "push af"), for the song's header
local   start_song 035D a command
# sound_main_loop 0B9B "ld a,($F3CA)" (fade), 0BC0-0BC4 "ld a,($F3CB); inc a; ld ($F3CB),a" (the attenuation), 0BD1 "ld a,($F3CE)" (the next song), 0BB5 "ld hl,$F3CD; dec (hl)" (fade_timer's place)
local   sound_main_loop 0B9B a fade_kind
local   sound_main_loop 0BC3,0BC9 a attenuation
local   sound_main_loop 0BD1 a next_song
local   sound_main_loop 0BB5 hl timer_address
# pcm_load_patch 0D2E-0D34 "ld a,($F3C3); and (ix+$4c); ld ($F3C3),a" the keys; 0D50-0D5B "ld a,($F3C4); and (ix+$4e) ... or (ix+$4f)" the modes; write_operator_level 0DA7 "sla l" the carriers' mask, shifted; pcm_update_volume 0DC0-0DDB the attenuation; set_pitch 0DF0-0DF8 "ld a,h; and $1F; sub $18" the note (the high byte modulo 24); pcm_set_pitch 0E70 "ex de,hl" the pitch; pcm_key_on 0E92/0EA7 the keys; the sensitivities' bits (0F3C-0F42, 0F58-0F5A); set_pan's pans (0FAB-0FDE) and bits (0F7C-0F87); noise_on 0FF2-0FF4 "or $80; ld c,a"; next_pointer_byte 100D-1010 "ld hl,($F3C8); ld a,(hl)"
local   pcm_load_patch 0D31 a keys
local   pcm_load_patch 0D53,0D5B a modes
local   write_operator_level 0DA7 l mask
local   write_operator_level 0DB5 hl next_carriers
local   pcm_update_volume 0DC3,0DC9,0DCB,0DD1,0DD4,0DDB a attenuation
local   set_pitch 0DF1,0DF3 a note
local   pcm_set_pitch 0E70 de voice_pitch
local   pcm_key_on 0E95,0EAA a keys
local   set_channel_pm_sensitivity 0F42 c bits
local   set_channel_am_sensitivity 0F5A c bits
local   set_pan 0FB0,0FBD,0FD0,0FDD a pans
local   set_pan 0F7C,0F85 c bits
local   noise_on 0FF4 c noise
local   next_pointer_byte 1010 a value
local   next_pointer_byte 100D hl pointer
# fm_effect_13_slide 16BF-16CC "ld l,(ix+$00); ld h,(ix+$01); ld de,$01E0; add hl,de; ld (ix+$00),l; ld (ix+$01),h": the pitch's fraction and its low byte, a word of the 24-bit pitch
local   fm_effect_13_slide 16C2,16C8 hl fraction_word
# music_tick: next_track_byte's byte (42AE "call $4957"...) and the step it is kept as (42B1 "ld c,a"); 46E0 "ld b,$00" the index's high byte; 46B0/46BB "ld de,$494C"/"ld de,$4E4E" the kits' routines; 460A "ld a,(hl)" the routine's entry; the envelopes' 437F-4386 "ld d,$00; bit 7,e; dec d" the step's high byte; add_note_length 48DC-48E9 the length's code (twice the high nibble) and the length; set_note_gate 4919 "ld a,(ix+$14)" the gate, rotated out a bit at a time (4933 "rlca"), 4929 "ex de,hl" the time left, halved each turn (492F "srl d; rr e"); next_track_byte 495D "ld a,(hl)"
local   music_tick 42AE,430D,45FE,46DB,4737,473F,47B8,47BE,47C4,47CA,47EC,47F0,487E,4882,489A,489E,48B6 a byte
local   music_tick 42B1,42F3,464D,46DF,473A,4742,4763,47EF,4881,489D c step
local   music_tick 46E0 b index_high
local   music_tick 46B0,46BB de kit_routines
local   music_tick 460A hl routine_entry
local   music_pitch_envelope_1 437F,4386 d step_high
local   music_pitch_envelope_2 43BC,43C3 d step_high
local   music_pitch_envelope_3 43F9,4400 d step_high
local   music_pitch_envelope_4 4436,443D d step_high
local   add_note_length 48DD,48DF,48E0 a code
local   add_note_length 48E3,48EB de length
local   set_note_gate 4919,4933 a ratio
local   set_note_gate 4929,492F d left_high
local   set_note_gate 4929,4931 e left_low
local   next_track_byte 495D a byte
# stop_music hands back IX and A (stop_all_channels and the main loop read them): the last record and the 0
param   stop_music ix last_channel
param   stop_music a cleared
# the passes' low byte, tested with the high one (15D6 "ld a,h; or l", 1640, 1CC9)
local   fm_effect_11_pitch 15CF l passes_low
local   fm_effect_12_delay 1639 l passes_low
local   fm_effect_1f_end 1CC3 l passes_low
# start_music_channel 03D0-03D2 "ld e,(hl); inc hl; ld d,(hl)": the track's place in the song's header, a byte at a time
local   start_music_channel 03D0 e track_low
local   start_music_channel 03D2 d track_high
# sound_main runs on from the reset with the IX it was left (it hands it back when the RAM test failed: 0B1C "jp
# nz,$0B28"), else the last record stop_all_channels leaves there
local   sound_main entry ix channel

# ======== what the sound program's flags say, its temporaries ========
# sound: names for the flags' variables and the temporaries of src/sound/ (sound_symbols.txt syntax)
# (evidence: the listing and the C of src/sound/; the callers listed in work_sound.txt as "caller"
# take a source's name by themselves: none needs a line of its own)

# ======== flag sources ========

# pcm_voice_playing 1000-100C "ld a,(ix+$40); cp $08; ret c; ld a,($FC29); and (ix+$4d); ret": Z set when the
# voice's bit of the K053260's status (FC29) is clear, the sample has ended (a YM2151 record: cp $08 with A < 8 leaves
# NZ, "still playing"); the callers' "call $1000; ret nz" then stop_channel or key the sample again
# (pcm_effect_3f_00_wait_sample 2ECC: "When sample 16 has ended (pcm_voice_playing), stop_channel"; the drums' "when
# the voice has ended")
flag pcm_voice_playing z voice_ended
# the move_pitch routines end "dec (ix+$01); ret" (fm_effect_01_move_pitch 1159, 0e 1488, 1b 1AE4, 1c 1B84, 1d 1C0C,
# 26 1FDA, 29 2148): Z when the timer reaches 0 ("counts the timer down and tells whether it ran out"); the callers'
# "ret nz" go on to the next round or stop_channel only then
flag fm_effect_01_move_pitch z timer_ran_out
flag fm_effect_0e_move_pitch z timer_ran_out
flag fm_effect_1b_move_pitch z timer_ran_out
flag fm_effect_1c_move_pitch z timer_ran_out
flag fm_effect_1d_move_pitch z timer_ran_out
flag fm_effect_26_move_pitch z timer_ran_out
flag fm_effect_29_move_pitch z timer_ran_out
# fm_effect_20_move_pitch 1D3E "dec (ix+$00); ret": the same on count ("counts the count down and tells whether it ran
# out")
flag fm_effect_20_move_pitch z count_ran_out
# music_channel_song 4284 "ld a,(ix+$10); or a; ret": Z when the record plays no song; start_sound's C0-EF walk
# (zero = music_channel_song(FM_0); if (zero) ... FM_1 ...) starts the song at once only when every record says so
flag music_channel_song z no_song
# add_note_length 48EC-48F9 "ld l,(ix+$3a); ld h,(ix+$3b); add hl,de; ... ret": the length is negative (note_lengths),
# so the carry is set when time is still past 0 after the step: the next step is due at once; music_tick's rests
# (4633 "call $48DC; jp c,$42AE", back to the next byte) read on only then, as at the tempo's carry (42AD "ret nc")
flag add_note_length cy next_step_due
# pcm_effect_42_update 37B8 "dec de ... ld a,e; or d; ret" (pcm_effect_57_update 3B55, unused_effect_3f_update 28DF
# "dec hl ... ld a,l; or h"): Z when the passes are down to 0 ("true when none is left"); the callers' "ret nz"
flag pcm_effect_42_update z passes_ran_out
flag pcm_effect_57_update z passes_ran_out
flag unused_effect_3f_update z passes_ran_out

# ======== local flags ========

# write_operator_level 0DA7 "sla l; jp nc,$0DB4": the carriers' mask's top bit, set when this operator is a carrier
# (then 0DAC "add a,(ix+$45)": the volume added to its total level)
flag write_operator_level cy carrier
# fm_effect_13_slide 16BF.. and fm_effect_14_slide 17AD..: the pitch's fraction and low byte as a word plus 1E0 / C0
# ("add hl,de"), and at its carry "inc" of the pitch's high byte (AT8(...pitch, 1)++): a 24-bit sum done in parts,
# its carry into the pitch's high byte
# (left: an arithmetic carry) flag fm_effect_13_slide cy pitch_high_carry
# (left: an arithmetic carry) flag fm_effect_14_slide cy pitch_high_carry
# music_tick 42F4-42FA "ld a,(ix+$3c); or (ix+$3d); push af": Z when the previous note's gate_time is 0, which
# set_note_gate gives when gate is 0 ("the next note legato"); the AF popped after set_pitch (stack bit 6) skips the
# key off and key on and the envelope's restart: the note slurs on ("key on but for a legato note")
flag music_tick z legato
# music_tick 429B-42AD "ld l,(ix+$3a) ... add hl,de; ld (ix+$3a),l; ld (ix+$3b),h; ret nc": the tempo added to time,
# the track's next step read at its carry (field time: "the next step read at its carry"); the rests' add_note_length
# carry the same: read on while it is set (the "carry = 0u" of 42F7's "or" only goes into the pushed AF)
flag music_tick cy next_step_due
# music_note_tick 4494-44A2 "ld l,(ix+$3a) ... ld e,(ix+$3c) ... add hl,de; ret nc; jp $0EBE": time plus gate_time
# carries once the time left is no more than gate_time: then key_off ("key off once the time left is no more than
# gate_time")
flag music_note_tick cy key_off_due
# set_note_gate 492F "srl d; rr e": the time left halved, the bit that srl moves out of its high byte into the top of
# its low byte (left_low = (left_low >> 1) | (carry << 7))
# (left: the bit of a 16-bit shift) flag set_note_gate cy bit_into_low

# ======== temporaries ========

# write_operator_level 0DAC "add a,(ix+$45)": the operator's total level plus the record's volume (an attenuation),
# 7F at most (0DAF "jp p")
local write_operator_level 0DAC t3 attenuated_level
# pcm_update_volume 0DC0-0DC3 "ld a,(ix+$45); add a,(ix+$46)": the volume plus the patch's level (scoped pcm level),
# 7F at most; 0DCB "add a,(ix+$48)": that plus the decay, 7F at most
local pcm_update_volume 0DC3 t3 patch_attenuation
local pcm_update_volume 0DCB t3 decayed_attenuation
# set_pitch 0DF3-0DF5 "sub $18; jp nc,$0DF3": the pitch's high byte before 18 (8 octaves) is taken off it once more
local set_pitch 0DF3 t1 unwrapped_note
# the move_pitch routines' "dec (ix+$01)" (fm_effect_20_move_pitch "dec (ix+$00)"): the timer (count) after this pass,
# stored back and tested for 0
local fm_effect_01_move_pitch 1159 t2 timer_left
local fm_effect_0e_move_pitch 1488 t2 timer_left
local fm_effect_1b_move_pitch 1AE4 t2 timer_left
local fm_effect_1c_move_pitch 1B84 t2 timer_left
local fm_effect_1d_move_pitch 1C0C t2 timer_left
local fm_effect_20_move_pitch 1D3E t2 count_left
local fm_effect_26_move_pitch 1FDA t2 timer_left
local fm_effect_29_move_pitch 2148 t2 timer_left
# the pass counters' "ld l,(ix+$00); ld h,(ix+$01); dec hl" (pcm_effect_42_update 37B2-37B8 "ld e,(ix+$02); ld
# d,(ix+$03); dec de"): the passes after this one, stored back and tested for 0 ("ld a,l; or h")
local fm_effect_11_pitch 15CF p1 passes_left
local fm_effect_12_delay 1639 p1 passes_left
local fm_effect_1f_end 1CC3 p1 passes_left
local fm_effect_21_end 1D7F p1 passes_left
local unused_effect_3e_end 2879 p1 passes_left
local unused_effect_3f_update 28DF p1 passes_left
local pcm_effect_42_update 37B8 p1 passes_left
local pcm_effect_57_update 3B55 p1 passes_left
local pcm_effect_7a_delay 3FEF p1 passes_left
local pcm_effect_7c_delay 40A0 p1 passes_left
local pcm_effect_7e_delay 4126 p1 passes_left
# sound_main_loop 0BB5-0BB8 "ld hl,$F3CD; dec (hl); jp nz" and 0BA7-0BAA "ld hl,$F3CF; dec (hl); jp nz": fade_timer
# and fade_hold before the pass takes one off (the C tests the old value against 1)
# (left as comments: sound_main_loop is a "loop" line, not a "func" one, and check_sound_lines.py only knows func
# lines; decompile_sound.py keys local sites by place and value alone, and its names include the loop's, so the two
# lines would work once the check takes loop lines too)
local sound_main_loop 0BB8 t1 old_fade_timer
local sound_main_loop 0BAA t1 old_fade_hold
# run_pcm_channel 0C07-0C0A "ld a,(ix+$48); add a,(ix+$47)": the decay one decay_step on, 7F at most (0C0D "jp p")
local run_pcm_channel 0C0A t3 next_decay
# music_tick 42F4-42F7 "ld a,(ix+$3c); or (ix+$3d)": the previous note's gate_time, its two bytes or-ed (0 for a legato
# note)
local music_tick 42F7 t2 previous_gate_bits
# set_note_gate 4933 "rlca; jp nc,$4938": gate before this turn's rotation, whose top bit says whether the halved time
# left is added in
local set_note_gate 4933 t1 unrotated_ratio
# set_music_volume 494B-494E "ld a,($F3CB); add a,c": the music's volume plus fade_attenuation, 7F at most (494F "jp p")
local set_music_volume 494E t3 faded_volume
# check_rom 09E6-09ED "ld a,l; exx; ld c,a; exx; ld a,h; exx; ld b,a; exx" (the C's BOARD_ORIGINAL(check_rom)): the sum
# in HL while its low byte goes to program_rom_sum's (BC'), sample_rom_2_sum (HL') held while the main set is back, the
# sum again while its high byte goes over (then 09EE "ld de,$072E; sbc hl,de": the one checked), sample_rom_2_sum back
local check_rom 09E7 t3 sum_for_low_byte
local check_rom 09E9 t3 sample_2_sum_aside
local check_rom 09EB t3 final_sum
local check_rom 09ED t3 sample_2_sum_back
# sound_command F2-F7 (04CE "exx; ld a,c; exx; ld c,a; ld ($FC02),bc", 04DF b, 04F0 e, 0501 d, 0512 l, 0523 h): the
# command word in BC (its high byte the argument, echoed to FC03) set aside while a byte of the alternate set's sums
# is read, and program_rom_sum (BC') put back by the second exx
local sound_command 04CE t1 f2_command_aside
local sound_command 04D0 t1 f2_program_sum_back
local sound_command 04DF t1 f3_command_aside
local sound_command 04E1 t1 f3_program_sum_back
local sound_command 04F0 t1 f4_command_aside
local sound_command 04F2 t1 f4_program_sum_back
local sound_command 0501 t1 f5_command_aside
local sound_command 0503 t1 f5_program_sum_back
local sound_command 0512 t1 f6_command_aside
local sound_command 0514 t1 f6_program_sum_back
local sound_command 0523 t1 f7_command_aside
local sound_command 0525 t1 f7_program_sum_back
# sound_command FE 0771-0778 "ld a,l; exx; ld e,a; exx; ld a,h; exx; ld d,a; exx" (then 0779 "ld de,$93AB; sbc
# hl,de"): the sample ROM 1's sum while its low byte goes to sample_rom_1_sum (DE'), sample_rom_2_sum (HL') held while
# the main set is back, the sum again while its high byte goes over (the one checked), sample_rom_2_sum back
local sound_command 0772 t3 sample_1_sum_for_low_byte
local sound_command 0774 t3 sample_2_sum_aside
local sound_command 0776 t3 final_sample_1_sum
local sound_command 0778 t3 sample_2_sum_back
# sound_command FE 081F-0826 "ld a,l; exx; ld l,a; exx; ld a,h; exx; ld h,a; exx" (then 0827 "ld de,$A5A5; sbc
# hl,de"): the sample ROM 2's sum, its low byte for HL', the sum checked, the new sample_rom_2_sum
local sound_command 0822 t3 sample_2_sum_low_byte
local sound_command 0824 t3 final_sample_2_sum
local sound_command 0826 t3 new_sample_2_sum
# sound_command 049C-049F "ex af,af'; ld e,a; ex af,af'; bit 0,e" (F8-FD) and 007B-007E (a sound command): the
# command in A set aside while self_test_failures (A') is read, and A' put back
local sound_command 049C t1 f8_fd_command_aside
local sound_command 049E t1 f8_fd_failures_back
local sound_command 007B t1 sound_aside
local sound_command 007D t1 sound_failures_back

# ======== the last stack slots ========
# sound_command and start_sound: the channel found moved from one register to another through the stack
# (0254/0313 "push ix" ... "pop hl", 025B/031A "push hl" ... "pop ix"; 019F/01A6, 02B3/02BA the same)
local sound_command 0254,025B,0313,031A s2 channel_copy
local start_sound 019F,01A6,02B3,02BA s2 channel_copy
# music_tick: the flags kept while the note is set up (42FA "push af"), their legato bit read after
local music_tick 42FA s2 saved_flags
