        SUBT    Exported Sound constants => &.Hdr.Sound

OldOpt  SETA    {OPT}
        OPT     OptNoList+OptNoP1List

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------
; 21-Jun-88  SKS   Added Service sub-rc's, corrected SoundCMOS definition
;                  to fit reality

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Software base pointers

SoundLevel0Base         * SoundWorkSpace
SoundLevel0Reserved     * 16*4
SoundLevel1Base         * SoundLevel0Base + SoundLevel0Reserved

SoundPhysChannels       * 8
MaxNVoices              * 32
SoundSystemNIL          * &FC000003


; SCCB Sound Channel Control Block
; 8 words (for LDMIA R9,{R0-R7}) is reasonable
; size constrained to exactly 256 bytes
                        ^ 0
SoundChannelAmpGateB    # 1 ; gate + 7-bit log amp.
SoundChannelVoiceIndexB # 1 ; index to voice table
SoundChannelInstanceB   # 1 ; Voice instance no.
SoundChannelFlagsB      # 1 ; control/status bit flags
SoundChannelPitch       # 4 ; phase acc
SoundChannelTimbre      # 4 ; phase acc
SoundChannelDuration    # 4 ; no. uS? (dec counter)
SoundChannelUserParam1  # 4 ;
SoundChannelUserParam2  # 4 ;
SoundChannelUserParam3  # 4 ;
SoundChannelUserParam4  # 4 ;
SoundChannelExtension   # 0 ; START HERE -> 256 BYTES
SoundChannelCBSize * 256
SoundChannelCBLSL * 8 ; SHIFT value to index SCCBs

; Level 1 data structure
; Level1 Sound DMA Control Block
                        ^ 0 ; SoundLevel1Base
SoundLevel1FillPtr      # 4 ; code^
SoundLevel1FixupPtr     # 4 ; code^
SoundLevel1LogTable     # 4
SoundLevel1AmpTable     # 4
SoundLevel1NChannels    # 1
SoundLevel1MaxAmp       # 1
SoundLevel1NVoices      # 1
SoundLevel1reservedB    # 1
SoundLevel1MasterPitch  # 4
SoundLevel1Queue        # 4
SoundLevel1SPARE        # 4 * 8
SoundLevel1VoiceTable   # 4 * (1 + MaxNVoices)
SoundLevel1ChannelTable    # SoundPhysChannels * SoundChannelCBSize
SoundLevel1ChannelTableEnd # 0


; Level 2 (VOICE) data structure
; SVCB Sound Voice Control Block
                        ^ 0
SoundVoiceFill          # 4 ; fill continuation entry
SoundVoiceUpdate        # 4 ; fill (with new params) coroutine entry
SoundVoiceGateOn        # 4 ; initiallise and fill
SoundVoiceGateOff       # 4 ; kill/release coroutine entry
SoundVoiceInst          # 4 ; instantiate voice
SoundVoiceFree          # 4 ; instance control
SoundVoiceInstall       # 4 ; code install
SoundVoiceTitle         # 4 ; name string
SoundVoiceDSize         # 4 ; instance data segment size
SoundVoiceIndex         # 4 ; table install segment size
SoundVoiceCBSize        # 0


; Channel Flags Byte: (31:24 of control word)
;
;   7                           0
; +---+---+---+---+---+---+---+---+
; | Q | K | I | F | A | V | F2| F1|
; +---+---+---+---+---+---+---+---+
; Z - Quiet (inactive)
; K - Kill Pending
; I - Initialise Pending
; F - Fill Pending
; A - Active Flag
; V - oVerrun Flag
; F2,F1 - 2-bit Flush Pending counter

SoundChannelGateOff      * 2_10000000 ; carefully priority-encoded
SoundChannelGateOn       * 2_01000000
SoundChannelUpdate       * 2_00100000
SoundChannelReserved     * 2_00010000
SoundChannelActive       * 2_00001000
SoundChannelOverrun      * 2_00000100
SoundChannelFlush2       * 2_00000010
SoundChannelFlush1       * 2_00000001
; composites
SoundChannelFlushPending * 2_00000011
SoundChannelForceFlush   * 2_00000010


; SoundCMOS bit allocation

;   7   6   5   4   3   2   1   0
; +---+---+---+---+---+---+---+---+
; | S |     L     |       V       |
; +---+---+---+---+---+---+---+---+

; S = 0/1 -> speaker off/on
; L = 3-bit 'loudness' field, 0..7 -> &01..&7F
; V = 4-bit default channel 0 voice, 0..15 -> 1..16


SWIClass SETS "Sound"

        ^       Module_SWISystemBase + Sound0SWI * Module_SWIChunkSize

        AddSWI  Configure
        AddSWI  Enable
        AddSWI  Stereo
        AddSWI  Speaker

        ^       Module_SWISystemBase + Sound1SWI * Module_SWIChunkSize

        AddSWI  Volume
        AddSWI  SoundLog
        AddSWI  LogScale
        AddSWI  InstallVoice
        AddSWI  RemoveVoice
        AddSWI  AttachVoice
        AddSWI  ControlPacked ; was 'Sound' but not in module!
        AddSWI  Tuning
        AddSWI  Pitch
        AddSWI  Control
        AddSWI  AttachNamedVoice
        AddSWI  ReadControlBlock
        AddSWI  WriteControlBlock

        ^       Module_SWISystemBase + Sound2SWI * Module_SWIChunkSize

        AddSWI  QInit
        AddSWI  QSchedule
        AddSWI  QRemove
        AddSWI  QSpace
        AddSWI  QDispatch
        AddSWI  QTempo
        AddSWI  QBeats


                                ^       0 ; Sound system service sub-rc's
Service_SoundLevel0Alive        #       1
Service_SoundLevel0Dying        #       1
Service_SoundLevel1Alive        #       1
Service_SoundLevel1Dying        #       1
Service_SoundLevel2Alive        #       1
Service_SoundLevel2Dying        #       1


        OPT     OldOpt
        END
