; Assembler header file for Sound
; Written by DefMod (Dec  9 2012) on Sun Dec  9 15:43:51 2012
; Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995

; OSLib---efficient, type-safe, transparent, extensible,
; register-safe API coverage of RISC OS
; 
; Copyright (c) 1994-2012 Jonathan Coxhead and OSLib maintainers
; 
; Licence:
; 
;    OSLib is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 1, or (at your option)
; any later version - and this with the following clarification and
; special exception:
; 
;    Linking this library statically or dynamically with other modules
; is making a combined work based on this library. Thus, the terms
; and conditions of the GNU General Public License cover the whole
; combination.
; 
;    As a special exception, the copyright holders of this library
; give you permission to link this library with independent modules
; to produce an executable, regardless of the license terms of these
; independent modules, and to copy and distribute the resulting
; executable under terms of your choice, provided that you also meet,
; for each linked independent module, the terms and conditions of the
; license of that module. An independent module is a module which is
; not derived from or based on this library. If you modify this
; library, you may extend this exception to your version of the library,
; but you are not obliged to do so. If you do not wish to do so, delete
; this exception statement from your version.
; 
;    OSLib is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
; 
;    You should have received a copy of the GNU General Public License
; along with this programme; if not, write to the Free Software
; Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

        [       :LNOT: :DEF: Sound_Hdr
        GBLS    Sound_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

;Symbols for constants
Sound_InstallCode               *       -390234112
Sound_StateRead                 *       &0
Sound_StateOff                  *       &1
Sound_StateOn                   *       &2
Sound_ConfigurationFormat       *       &F
Sound_ConfigurationFormat16BitAny *       &1
Sound_ConfigurationFormat16BitMuLaw *       &2
Sound_ConfigurationOversamplingEnabled *       &10
Sound_DataFlags                 *       &7
Sound_DataInvalid               *       &0
Sound_DataNonNought             *       &1
Sound_DataNought                *       &2
Sound_ReservedFlags             *       &F8
Sound_Hz                        *       1024

;Symbols for structure offsets and sizes
        ^       0
Sound_LogTable_log              #       8192*Byte
Sound_LogTable                  *       @

        ^       0
Sound_LogScaleTable_log_scale   #       256*Byte
Sound_LogScaleTable             *       @

        ^       0
Sound_ChannelHandler_fill_code  #       Ptr
Sound_ChannelHandler_overrun_fixup_code #       Ptr
Sound_ChannelHandler_log_table  #       Ptr
Sound_ChannelHandler_log_scale_table #       Ptr
Sound_ChannelHandler            *       @

        ^       0
Sound_SCCB_amplitude            #       Byte
Sound_SCCB_voice_no             #       Byte
Sound_SCCB_voice_instance       #       Byte
Sound_SCCB_flags                #       Byte
Sound_SCCB_pitch                #       Int
Sound_SCCB_timbre               #       Int
Sound_SCCB_buffer_fill_count    #       Int
Sound_SCCB_r4                   #       Int
Sound_SCCB_r5                   #       Int
Sound_SCCB_r6                   #       Int
Sound_SCCB_r7                   #       Int
Sound_SCCB_r8                   #       Int
Sound_SCCB_reserved             #       7*Int
Sound_SCCB_available            #       48*Int
Sound_SCCB                      *       @

        ^       0
Sound_Scheduler_scheduler       #       Ptr
Sound_Scheduler                 *       @

        ^       0
Sound_VoiceGenerator_fill_code  #       Int
Sound_VoiceGenerator_update_code #       Int
Sound_VoiceGenerator_gate_on_code #       Int
Sound_VoiceGenerator_gate_off_code #       Int
Sound_VoiceGenerator_instantiate_code #       Int
Sound_VoiceGenerator_free_code  #       Int
Sound_VoiceGenerator_install_code #       Int
Sound_VoiceGenerator_voice_name_offset #       Int
Sound_VoiceGenerator            *       @

        ^       0
        #       Int
Sound_State                     *       @

        ^       0
        #       Bits
Sound_Configuration             *       @

        ^       0
        #       Bits
Sound_LinearHandlerFlags        *       @


;Symbols for SWI's and SWI reason codes
XSound_Configure                *       &60140
Sound_Configure                 *       &40140
   ;Entry
   ;  R0 = channel_count (Int)
   ;  R1 = sample_size (Int)
   ;  R2 = sample_period (Int)
   ;  R3 -> channel_handler (Sound_ChannelHandler)
   ;  R4 -> scheduler (Sound_Scheduler)
   ;Exit
   ;  R0 = channel_count_out (Int)
   ;  R1 = sample_size_out (Int)
   ;  R2 = sample_period_out (Int)
   ;  R3 -> channel_handler_out (Sound_ChannelHandler)
   ;  R4 -> scheduler_out (Sound_Scheduler)

XSound_Enable                   *       &60141
Sound_Enable                    *       &40141
   ;Entry
   ;  R0 = state (Sound_State)
   ;Exit
   ;  R0 = state_out (Sound_State)

XSound_Stereo                   *       &60142
Sound_Stereo                    *       &40142
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 = position (Int)
   ;Exit
   ;  R1 = position_out (Int)

XSound_Speaker                  *       &60143
Sound_Speaker                   *       &40143
   ;Entry
   ;  R0 = state (Sound_State)
   ;Exit
   ;  R0 = state_out (Sound_State)

XSound_Mode                     *       &60144
Sound_Mode                      *       &40144

SoundMode_ReadConfiguration     *       &0
   ;Entry
   ;  R0 = &0
   ;Exit
   ;  R0 = has_16bit (Bool)
   ;  R1 = configuration (Sound_Configuration)

SoundMode_SetOversampling       *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 = oversample (Bool)
   ;Exit
   ;  R1 = old_oversample (Bool)

XSound_LinearHandler            *       &60145
Sound_LinearHandler             *       &40145
   ;Entry
   ;  R0 = install (Bool)
   ;  R1 = new_handler_code (pointer to code)
   ;  R2 = new_workspace (pointer to Void)
   ;Exit
   ;  R1 = old_handler_code (pointer to code)
   ;  R2 = old_workspace (pointer to Void)

XSound_SampleRate               *       &60146
Sound_SampleRate                *       &40146

SoundSampleRate_ReadCount       *       &0
   ;Entry
   ;  R0 = &0
   ;Exit
   ;  R1 = rate_count (Int)

SoundSampleRate_ReadCurrent     *       &1
   ;Entry
   ;  R0 = &1
   ;Exit
   ;  R1 = rate_index (Int)
   ;  R2 = rate (Int)

SoundSampleRate_Lookup          *       &2
   ;Entry
   ;  R0 = &2
   ;  R1 = rate_index (Int)
   ;Exit
   ;  R2 = rate (Int)

SoundSampleRate_Select          *       &3
   ;Entry
   ;  R0 = &3
   ;  R1 = rate_index (Int)
   ;Exit
   ;  R1 = old_rate_index (Int)
   ;  R2 = old_rate (Int)

XSound_Volume                   *       &60180
Sound_Volume                    *       &40180
   ;Entry
   ;  R0 = volume (Int)
   ;Exit
   ;  R0 = volume_out (Int)

XSound_SoundLog                 *       &60181
Sound_SoundLog                  *       &40181
   ;Entry
   ;  R0 = linear (Int)
   ;Exit
   ;  R0 = log (Int)

XSound_LogScale                 *       &60182
Sound_LogScale                  *       &40182
   ;Entry
   ;  R0 = log (Int)
   ;Exit
   ;  R0 = linear (Int)

XSound_InstallVoice             *       &60183
Sound_InstallVoice              *       &40183
   ;Entry
   ;  R0 -> voice_generator (Sound_VoiceGenerator)
   ;  R1 = voice_no (Int)
   ;Exit
   ;  R0 -> voice_name_out (String)
   ;  R1 = voice_no_out (Int)

SoundInstallVoice_ReadName      *       &0
   ;Entry
   ;  R0 = &0
   ;  R1 = voice_no (Int)
   ;Exit
   ;  R0 -> voice_name (String)

SoundInstallVoice_AddNamedVoice *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 = voice_no (Int)
   ;  R2 -> voice_generator (Sound_VoiceGenerator)
   ;  R3 -> voice_name (String)
   ;Exit
   ;  R1 = voice_no_out (Int)
   ;  R2 -> voice_name_out (String)

SoundInstallVoice_ReadLocalName *       &2
   ;Entry
   ;  R0 = &2
   ;  R1 = voice_no (Int)
   ;Exit
   ;  R2 -> voice_name_out (String)
   ;  R3 -> voice_local_name_out (String)

SoundInstallVoice_ChangeLocalName *       &3
   ;Entry
   ;  R0 = &3
   ;  R1 = voice_no (Int)
   ;  R2 = &0
   ;  R3 -> voice_local_name (String)

XSound_RemoveVoice              *       &60184
Sound_RemoveVoice               *       &40184
   ;Entry
   ;  R1 = voice_no (Int)
   ;Exit
   ;  R0 -> voice_name_out (String)
   ;  R1 = voice_no_out (Int)

XSound_AttachVoice              *       &60185
Sound_AttachVoice               *       &40185
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 = voice_no (Int)
   ;Exit
   ;  R0 = channel_no_out (Int)
   ;  R1 = voice_no_out (Int)

XSound_ControlPacked            *       &60186
Sound_ControlPacked             *       &40186
   ;Entry
   ;  R0 = amp_and_channel (Bits)
   ;  R1 = duration_and_pitch (Bits)

XSound_Tuning                   *       &60187
Sound_Tuning                    *       &40187
   ;Entry
   ;  R0 = tuning (Int)
   ;Exit
   ;  R0 = tuning_out (Int)

XSound_Pitch                    *       &60188
Sound_Pitch                     *       &40188
   ;Entry
   ;  R0 = pitch (Int)
   ;Exit
   ;  R0 = accumulator (Int)

XSound_Control                  *       &60189
Sound_Control                   *       &40189
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 = amplitude (Int)
   ;  R2 = pitch (Int)
   ;  R3 = duration (Int)

XSound_AttachNamedVoice         *       &6018A
Sound_AttachNamedVoice          *       &4018A
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 -> voice_name (String)

XSound_ReadControlBlock         *       &6018B
Sound_ReadControlBlock          *       &4018B
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 = offset (Int)
   ;Exit
   ;  R0 = channel_no_out (Int)
   ;  R2 = word (Int)

XSound_WriteControlBlock        *       &6018C
Sound_WriteControlBlock         *       &4018C
   ;Entry
   ;  R0 = channel_no (Int)
   ;  R1 = offset (Int)
   ;  R2 = word (Int)
   ;Exit
   ;  R0 = channel_no_out (Int)
   ;  R2 = word_out (Int)

XSound_QInit                    *       &601C0
Sound_QInit                     *       &401C0
   ;Exit
   ;  R0 corrupted

XSound_QSchedule                *       &601C1
Sound_QSchedule                 *       &401C1
   ;Entry
   ;  R0 = period (Int)
   ;  R1 = swi_no (Int)
   ;  R2 = swi_r0 (Int)
   ;  R3 = swi_r1 (Int)
   ;Exit
   ;  R0 = failed (Bool)

XSound_QRemove                  *       &601C2
Sound_QRemove                   *       &401C2

XSound_QFree                    *       &601C3
Sound_QFree                     *       &401C3
   ;Exit
   ;  R0 = free_count (Int)

XSound_QSDispatch               *       &601C4
Sound_QSDispatch                *       &401C4

XSound_QTempo                   *       &601C5
Sound_QTempo                    *       &401C5
   ;Entry
   ;  R0 = tempo (Int)
   ;Exit
   ;  R0 = tempo_out (Int)

XSound_QBeat                    *       &601C6
Sound_QBeat                     *       &401C6
   ;Entry
   ;  R0 = bar_length (Int)
   ;Exit
   ;  R0 = bar_length_out (Int)

XSound_QInterface               *       &601C7
Sound_QInterface                *       &401C7

XSound_QSchedule32              *       &601C8
Sound_QSchedule32               *       &401C8

SoundQSchedule32_CallControlPacked *       &0
   ;Entry
   ;  R0 = period (Int)
   ;  R1 = &0
   ;  R2 = data1 (Int)
   ;  R3 = data2 (Int)
   ;Exit
   ;  R0 = error (Int)
   ;  R1 = api_check (Int)

SoundQSchedule32_CallRoutine    *       &0
   ;Entry
   ;  R0 = period (Int)
   ;  R1 = &0 :OR: routine (pointer to code)
   ;  R2 = data1 (Int)
   ;  R3 = data2 (Int)
   ;Exit
   ;  R0 = error (Int)
   ;  R1 = api_check (Int)

SoundQSchedule32_CallSWI        *       &1
   ;Entry
   ;  R0 = period (Int)
   ;  R1 = &1 :OR: swi_number_shift_by_8 (Int)
   ;  R2 = data1 (Int)
   ;  R3 = data2 (Int)
   ;Exit
   ;  R0 = error (Int)
   ;  R1 = api_check (Int)

Service_Sound                   *       &54
   ;Entry
   ;  R0 = part (Int)
   ;  R1 = &54

Event_StartOfBar                *       &C
   ;Entry
   ;  R0 = &C
   ;  R1 = &2
   ;  R2 = &0

        ]
        END
