@ GNU AS assembler header file for Sound
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:45:18 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.

#ifndef Sound_Hdr
#  define Sound_Hdr

#  ifndef Get_Types
#    define Get_Types
#    include "oslib/Types.Hdr"
#  endif

#  ifndef Get_OS
#    define Get_OS
#    include "oslib/OS.Hdr"
#  endif

@Symbols for constants
#  define Sound_InstallCode 0xe8bd8000
#  define Sound_StateRead 0x0
#  define Sound_StateOff 0x1
#  define Sound_StateOn 0x2
#  define Sound_ConfigurationFormat 0xf
#  define Sound_ConfigurationFormat16BitAny 0x1
#  define Sound_ConfigurationFormat16BitMuLaw 0x2
#  define Sound_ConfigurationOversamplingEnabled 0x10
#  define Sound_DataFlags 0x7
#  define Sound_DataInvalid 0x0
#  define Sound_DataNonNought 0x1
#  define Sound_DataNought 0x2
#  define Sound_ReservedFlags 0xf8
#  define Sound_Hz 0x400

@Symbols for structure offsets and sizes
        .struct 0
Sound_LogTable_log             : .skip   8192*Byte
Sound_LogTable                 : 

        .struct 0
Sound_LogScaleTable_log_scale  : .skip   256*Byte
Sound_LogScaleTable            : 

        .struct 0
Sound_ChannelHandler_fill_code : .skip   Ptr
Sound_ChannelHandler_overrun_fixup_code: .skip   Ptr
Sound_ChannelHandler_log_table : .skip   Ptr
Sound_ChannelHandler_log_scale_table: .skip   Ptr
Sound_ChannelHandler           : 

        .struct 0
Sound_SCCB_amplitude           : .skip   Byte
Sound_SCCB_voice_no            : .skip   Byte
Sound_SCCB_voice_instance      : .skip   Byte
Sound_SCCB_flags               : .skip   Byte
Sound_SCCB_pitch               : .skip   Int
Sound_SCCB_timbre              : .skip   Int
Sound_SCCB_buffer_fill_count   : .skip   Int
Sound_SCCB_r4                  : .skip   Int
Sound_SCCB_r5                  : .skip   Int
Sound_SCCB_r6                  : .skip   Int
Sound_SCCB_r7                  : .skip   Int
Sound_SCCB_r8                  : .skip   Int
Sound_SCCB_reserved            : .skip   7*Int
Sound_SCCB_available           : .skip   48*Int
Sound_SCCB                     : 

        .struct 0
Sound_Scheduler_scheduler      : .skip   Ptr
Sound_Scheduler                : 

        .struct 0
Sound_VoiceGenerator_fill_code : .skip   Int
Sound_VoiceGenerator_update_code: .skip   Int
Sound_VoiceGenerator_gate_on_code: .skip   Int
Sound_VoiceGenerator_gate_off_code: .skip   Int
Sound_VoiceGenerator_instantiate_code: .skip   Int
Sound_VoiceGenerator_free_code : .skip   Int
Sound_VoiceGenerator_install_code: .skip   Int
Sound_VoiceGenerator_voice_name_offset: .skip   Int
Sound_VoiceGenerator           : 

        .struct 0
        .skip   Int
Sound_State                    : 

        .struct 0
        .skip   Bits
Sound_Configuration            : 

        .struct 0
        .skip   Bits
Sound_LinearHandlerFlags       : 


@Symbols for SWI's and SWI reason codes
.set XSound_Configure,0x60140
.set Sound_Configure,0x40140
   @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)

.set XSound_Enable,0x60141
.set Sound_Enable,0x40141
   @Entry
   @  R0 = state (Sound_State)
   @Exit
   @  R0 = state_out (Sound_State)

.set XSound_Stereo,0x60142
.set Sound_Stereo,0x40142
   @Entry
   @  R0 = channel_no (Int)
   @  R1 = position (Int)
   @Exit
   @  R1 = position_out (Int)

.set XSound_Speaker,0x60143
.set Sound_Speaker,0x40143
   @Entry
   @  R0 = state (Sound_State)
   @Exit
   @  R0 = state_out (Sound_State)

.set XSound_Mode,0x60144
.set Sound_Mode,0x40144

#  define SoundMode_ReadConfiguration 0x0
   @Entry
   @  R0 = &0
   @Exit
   @  R0 = has_16bit (Bool)
   @  R1 = configuration (Sound_Configuration)

#  define SoundMode_SetOversampling 0x1
   @Entry
   @  R0 = &1
   @  R1 = oversample (Bool)
   @Exit
   @  R1 = old_oversample (Bool)

.set XSound_LinearHandler,0x60145
.set Sound_LinearHandler,0x40145
   @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)

.set XSound_SampleRate,0x60146
.set Sound_SampleRate,0x40146

#  define SoundSampleRate_ReadCount 0x0
   @Entry
   @  R0 = &0
   @Exit
   @  R1 = rate_count (Int)

#  define SoundSampleRate_ReadCurrent 0x1
   @Entry
   @  R0 = &1
   @Exit
   @  R1 = rate_index (Int)
   @  R2 = rate (Int)

#  define SoundSampleRate_Lookup 0x2
   @Entry
   @  R0 = &2
   @  R1 = rate_index (Int)
   @Exit
   @  R2 = rate (Int)

#  define SoundSampleRate_Select 0x3
   @Entry
   @  R0 = &3
   @  R1 = rate_index (Int)
   @Exit
   @  R1 = old_rate_index (Int)
   @  R2 = old_rate (Int)

.set XSound_Volume,0x60180
.set Sound_Volume,0x40180
   @Entry
   @  R0 = volume (Int)
   @Exit
   @  R0 = volume_out (Int)

.set XSound_SoundLog,0x60181
.set Sound_SoundLog,0x40181
   @Entry
   @  R0 = linear (Int)
   @Exit
   @  R0 = log (Int)

.set XSound_LogScale,0x60182
.set Sound_LogScale,0x40182
   @Entry
   @  R0 = log (Int)
   @Exit
   @  R0 = linear (Int)

.set XSound_InstallVoice,0x60183
.set Sound_InstallVoice,0x40183
   @Entry
   @  R0 -> voice_generator (Sound_VoiceGenerator)
   @  R1 = voice_no (Int)
   @Exit
   @  R0 -> voice_name_out (String)
   @  R1 = voice_no_out (Int)

#  define SoundInstallVoice_ReadName 0x0
   @Entry
   @  R0 = &0
   @  R1 = voice_no (Int)
   @Exit
   @  R0 -> voice_name (String)

#  define SoundInstallVoice_AddNamedVoice 0x1
   @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)

#  define SoundInstallVoice_ReadLocalName 0x2
   @Entry
   @  R0 = &2
   @  R1 = voice_no (Int)
   @Exit
   @  R2 -> voice_name_out (String)
   @  R3 -> voice_local_name_out (String)

#  define SoundInstallVoice_ChangeLocalName 0x3
   @Entry
   @  R0 = &3
   @  R1 = voice_no (Int)
   @  R2 = &0
   @  R3 -> voice_local_name (String)

.set XSound_RemoveVoice,0x60184
.set Sound_RemoveVoice,0x40184
   @Entry
   @  R1 = voice_no (Int)
   @Exit
   @  R0 -> voice_name_out (String)
   @  R1 = voice_no_out (Int)

.set XSound_AttachVoice,0x60185
.set Sound_AttachVoice,0x40185
   @Entry
   @  R0 = channel_no (Int)
   @  R1 = voice_no (Int)
   @Exit
   @  R0 = channel_no_out (Int)
   @  R1 = voice_no_out (Int)

.set XSound_ControlPacked,0x60186
.set Sound_ControlPacked,0x40186
   @Entry
   @  R0 = amp_and_channel (Bits)
   @  R1 = duration_and_pitch (Bits)

.set XSound_Tuning,0x60187
.set Sound_Tuning,0x40187
   @Entry
   @  R0 = tuning (Int)
   @Exit
   @  R0 = tuning_out (Int)

.set XSound_Pitch,0x60188
.set Sound_Pitch,0x40188
   @Entry
   @  R0 = pitch (Int)
   @Exit
   @  R0 = accumulator (Int)

.set XSound_Control,0x60189
.set Sound_Control,0x40189
   @Entry
   @  R0 = channel_no (Int)
   @  R1 = amplitude (Int)
   @  R2 = pitch (Int)
   @  R3 = duration (Int)

.set XSound_AttachNamedVoice,0x6018a
.set Sound_AttachNamedVoice,0x4018a
   @Entry
   @  R0 = channel_no (Int)
   @  R1 -> voice_name (String)

.set XSound_ReadControlBlock,0x6018b
.set Sound_ReadControlBlock,0x4018b
   @Entry
   @  R0 = channel_no (Int)
   @  R1 = offset (Int)
   @Exit
   @  R0 = channel_no_out (Int)
   @  R2 = word (Int)

.set XSound_WriteControlBlock,0x6018c
.set Sound_WriteControlBlock,0x4018c
   @Entry
   @  R0 = channel_no (Int)
   @  R1 = offset (Int)
   @  R2 = word (Int)
   @Exit
   @  R0 = channel_no_out (Int)
   @  R2 = word_out (Int)

.set XSound_QInit,0x601c0
.set Sound_QInit,0x401c0
   @Exit
   @  R0 corrupted

.set XSound_QSchedule,0x601c1
.set Sound_QSchedule,0x401c1
   @Entry
   @  R0 = period (Int)
   @  R1 = swi_no (Int)
   @  R2 = swi_r0 (Int)
   @  R3 = swi_r1 (Int)
   @Exit
   @  R0 = failed (Bool)

.set XSound_QRemove,0x601c2
.set Sound_QRemove,0x401c2

.set XSound_QFree,0x601c3
.set Sound_QFree,0x401c3
   @Exit
   @  R0 = free_count (Int)

.set XSound_QSDispatch,0x601c4
.set Sound_QSDispatch,0x401c4

.set XSound_QTempo,0x601c5
.set Sound_QTempo,0x401c5
   @Entry
   @  R0 = tempo (Int)
   @Exit
   @  R0 = tempo_out (Int)

.set XSound_QBeat,0x601c6
.set Sound_QBeat,0x401c6
   @Entry
   @  R0 = bar_length (Int)
   @Exit
   @  R0 = bar_length_out (Int)

.set XSound_QInterface,0x601c7
.set Sound_QInterface,0x401c7

.set XSound_QSchedule32,0x601c8
.set Sound_QSchedule32,0x401c8

#  define SoundQSchedule32_CallControlPacked 0x0
   @Entry
   @  R0 = period (Int)
   @  R1 = &0
   @  R2 = data1 (Int)
   @  R3 = data2 (Int)
   @Exit
   @  R0 = error (Int)
   @  R1 = api_check (Int)

#  define SoundQSchedule32_CallRoutine 0x0
   @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)

#  define SoundQSchedule32_CallSWI 0x1
   @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)

#  define Service_Sound 0x54
   @Entry
   @  R0 = part (Int)
   @  R1 = &54

#  define Event_StartOfBar 0xc
   @Entry
   @  R0 = &C
   @  R1 = &2
   @  R2 = &0

#endif
