@ GNU AS assembler header file for CD
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:44:51 2012
@ Simon Middleton, Uniqueway Ltd; Jonathan Coxhead, jonathan@doves.demon.co.uk, 12 July 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 CD_Hdr
#  define CD_Hdr

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

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

#  ifndef Get_SCSI
#    define Get_SCSI
#    include "oslib/SCSI.Hdr"
#  endif

@Symbols for constants
#  define Error_CDBase 0x803400
#  define Error_CDBadAlignment 0x803401
#  define Error_CDDriveNotSupported 0x803402
#  define Error_CDBadMode 0x803403
#  define Error_CDInvalidParameter 0x803404
#  define Error_CDNotAudioTrack 0x803405
#  define Error_CDNoCaddy 0x803406
#  define Error_CDNoDrive 0x803407
#  define Error_CDInvalidFormat 0x803408
#  define Error_CDBadMinutes 0x803409
#  define Error_CDBadSeconds 0x80340a
#  define Error_CDBadBlocks 0x80340b
#  define Error_CDPhysicalBlockBad 0x80340c
#  define Error_CDDrawerLocked 0x80340d
#  define Error_CDWrongDataMode 0x80340e
#  define Error_CDChannelNotSupported 0x80340f
#  define Error_CDBadDeviceID 0x803410
#  define Error_CDBadCardNumber 0x803411
#  define Error_CDBadLUNNumber 0x803412
#  define Error_CDNoSuchTrack 0x803413
#  define Error_CDFaultyDisc 0x803414
#  define Error_CDNoSuchBlock 0x803415
#  define Error_CDNotSupported 0x803416
#  define Error_CDDriverNotPresent 0x803417
#  define Error_CD_SWINotSupported 0x803418
#  define Error_CDTooManyDrivers 0x803419
#  define Error_CDNotRegistered 0x80341a
#  define CD_LogicalBlockAddressing 0x0
#  define CD_RedBookAddressing 0x1
#  define CD_PhysicalBlockAddressing 0x2
#  define CD_AUDIO 0x0
#  define CD_Data 0x1
#  define CD_FourChannel 0x0
#  define CD_TwoChannel 0x2
#  define CD_ReadAudioRead 0x0
#  define CD_ReadAudioReasonMask 0xff
#  define CD_DriveStatusOK 0x1
#  define CD_DriveStatusBusy 0x2
#  define CD_DriveStatusNotReady 0x4
#  define CD_DriveStatusUnavailable 0x8
#  define CD_DriveREADY 0x0
#  define CD_DriveNotReady 0x1
#  define CD_MultiplierDefault 0x0
#  define CD_MultiplierEighthSec 0x1
#  define CD_MultiplierQuarterSec 0x2
#  define CD_MultiplierHalfSec 0x3
#  define CD_MultiplierOneSec 0x4
#  define CD_MultiplierTwoSec 0x5
#  define CD_MultiplierFourSec 0x6
#  define CD_MultiplierEightSec 0x7
#  define CD_MultiplierSixteenSec 0x8
#  define CD_MultiplierThirtyTwoSec 0x9
#  define CD_MultiplierOneMin 0xa
#  define CD_MultiplierTwoMin 0xb
#  define CD_MultiplierFourMin 0xc
#  define CD_MultiplierEightMin 0xd
#  define CD_MultiplierSixteenMin 0xe
#  define CD_MultiplierThirtyTwoMin 0xf
#  define CD_ModeAudio 0x0
#  define CD_Mode1 0x1
#  define CD_Mode2Form2 0x2
#  define CD_Mode2Form1 0x3
#  define CD_SpeedUnchanged 0x0
#  define CD_SpeedStandard 0x1
#  define CD_SpeedDouble 0x2
#  define CD_SpeedMax 0xff
#  define CD_PlayToEndOfTrack 0xfe
#  define CD_PlayToEndOfDisc 0xff
#  define CD_AudioPlaying 0x0
#  define CD_AudioPaused 0x1
#  define CD_AudioCompleted 0x3
#  define CD_AudioError 0x4
#  define CD_AudioStopped 0x5
#  define CD_CheckError 0x0
#  define CD_CheckSense 0x1
#  define CD_CheckRetry 0x2
#  define CD_SupportedAudioControl 0x7
#  define CD_SupportedPrefetch 0x8
#  define CD_SupportedCloseDrawer 0x10
#  define CD_SupportedAudioLevel 0x20
#  define CD_SupportedSpeedMultiplier 0x3fc0
#  define CD_SupportedReadAudio 0x4000
#  define CD_SupportedAudioParams 0x8000
#  define CD_UseOldRead 0x40
#  define CD_UseOldSeek 0x80
#  define CD_UseOldInquiry 0x100
#  define CD_UseOldCapacity 0x200
#  define CD_UseOldReady 0x400
#  define CD_UseOldStopOpen 0x800
#  define CD_UseOldCheck 0x1000
#  define CD_UseOldStatus 0x2000
#  define CD_UseOldControl 0x4000
#  define CD_UseOldPrefetch 0x8000
#  define CD_UseOldReset 0x10000
#  define CD_UseReadDataProprietary 0x20000
#  define CD_UseReadDataScatter 0x40000
#  define CD_UseSeekDataProprietary 0x80000
#  define CD_UseSeekDataScatter 0x100000
#  define CD_UseSCSIOp 0x200000
#  define CD_DriveTypeUnknown 0xffffffff
#  define CD_AudioDone 0xffffffff
#  define CD_VolumeLimit 0xffff

@Symbols for structure offsets and sizes
        .struct 0
        .skip   Bits
CD_Address                     : 

        .struct 0
        .skip   Int
CD_AddressMode                 : 

        .struct 0
CD_ControlBlock_reserved       : .skip   5*Int
CD_ControlBlock                : 

        .struct 0
        .skip   Byte
CD_AudioFlags                  : 

        .struct 0
CD_VersionBlock_version_number : .skip   Int
CD_VersionBlock_version_string : .skip   256*Char
CD_VersionBlock                : 

        .struct 0
        .skip   Int
CD_Status                      : 

        .struct 0
        .skip   Int
CD_Readiness                   : 

        .struct 0
        .skip   Int
CD_Multiplier                  : 

        .struct 0
        .skip   Int
CD_DataMode                    : 

        .struct 0
        .skip   Int
CD_Speed                       : 

        .struct 0
CD_ParameterBlock_inactivity_timer: .skip   CD_Multiplier
CD_ParameterBlock_retry_count  : .skip   Int
CD_ParameterBlock_mode         : .skip   CD_DataMode
CD_ParameterBlock_speed        : .skip   CD_Speed
CD_ParameterBlock              : 

        .struct 0
        .skip   Int
CD_PlayToWhat                  : 

        .struct 0
CD_EnquireAllTracksBlock_first_track: .skip   Byte
CD_EnquireAllTracksBlock_last_track: .skip   Byte
CD_EnquireAllTracksBlock_reserved0: .skip   Byte
CD_EnquireAllTracksBlock_reserved1: .skip   Byte
CD_EnquireAllTracksBlock_reserved2: .skip   Byte
CD_EnquireAllTracksBlock       : 

        .struct 0
CD_EnquireOneTrackBlock_address: .skip   CD_Address
CD_EnquireOneTrackBlock_audio_control: .skip   CD_AudioFlags
CD_EnquireOneTrackBlock        : 

        .struct 0
CD_SubChannelBlock_relative_lba: .skip   CD_Address
CD_SubChannelBlock_absolute_lba: .skip   CD_Address
CD_SubChannelBlock_audio_control: .skip   CD_AudioFlags
CD_SubChannelBlock_track_number: .skip   Byte
CD_SubChannelBlock_index_number: .skip   Byte
CD_SubChannelBlock             : 

        .struct 0
CD_DiscUsedBlock_block_count   : .skip   Int
CD_DiscUsedBlock_block_size    : .skip   Int
CD_DiscUsedBlock               : 

        .struct 0
        .skip   Int
CD_Audio                       : 

        .struct 0
CD_InquiryBlock_i              : .skip   36*Byte
CD_InquiryBlock                : 

        .struct 0
        .skip   Int
CD_ErrorResponseLevel          : 

        .struct 0
        .skip   Bits
CD_Flags                       : 

        .struct 0
        .skip   Bits
CD_RegisterFlags               : 

        .struct 0
CD_RegisterBlock_flags         : .skip   CD_RegisterFlags
CD_RegisterBlock_registration_count: .skip   Int
CD_RegisterBlock_drive_type_count: .skip   Int
CD_RegisterBlock               : 

        .struct 0
        .skip   Int
CD_DriveType                   : 

        .struct 0
        .skip   Int
CD_AudioCompletion             : 

        .struct 0
CD_VolumeBlock_volume          : .skip   2*Int
CD_VolumeBlock                 : 


@Symbols for SWI's and SWI reason codes
.set XCD_Version,0x61240
.set CD_Version,0x41240
   @Exit
   @  R0 -> version (CD_VersionBlock)

.set XCD_ReadData,0x61241
.set CD_ReadData,0x41241
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = start_address (CD_Address)
   @  R2 = block_count (Int)
   @  R3 = buffer (pointer to data)
   @  R4 = size (Int)
   @  R7 -> control (CD_ControlBlock)

.set XCD_SeekTo,0x61242
.set CD_SeekTo,0x41242
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = seek (CD_Address)
   @  R7 -> control (CD_ControlBlock)

.set XCD_DriveStatus,0x61243
.set CD_DriveStatus,0x41243
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = status (CD_Status)
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 corrupted
   @  R5 corrupted
   @  R6 corrupted
   @  R7 corrupted
   @  R8 corrupted
   @  R9 corrupted

.set XCD_DriveReady,0x61244
.set CD_DriveReady,0x41244
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = ready (CD_Readiness)

.set XCD_GetParameters,0x61245
.set CD_GetParameters,0x41245
   @Entry
   @  R0 = params (pointer to CD_ParameterBlock)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 corrupted
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 corrupted
   @  R5 corrupted
   @  R6 corrupted
   @  R7 corrupted
   @  R8 corrupted
   @  R9 corrupted

.set XCD_SetParameters,0x61246
.set CD_SetParameters,0x41246
   @Entry
   @  R0 -> params (CD_ParameterBlock)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 corrupted
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 corrupted
   @  R5 corrupted
   @  R6 corrupted
   @  R7 corrupted
   @  R8 corrupted
   @  R9 corrupted

.set XCD_OpenDrawer,0x61247
.set CD_OpenDrawer,0x41247
   @Entry
   @  R7 -> control (CD_ControlBlock)

.set XCD_EjectButton,0x61248
.set CD_EjectButton,0x41248
   @Entry
   @  R0 = disable (Bool)
   @  R7 -> control (CD_ControlBlock)

.set XCD_EnquireAddress,0x61249
.set CD_EnquireAddress,0x41249
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = address (CD_Address)

.set XCD_EnquireDataMode,0x6124a
.set CD_EnquireDataMode,0x4124a
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = data_mode (CD_DataMode)

.set XCD_PlayAudio,0x6124b
.set CD_PlayAudio,0x4124b
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = start (CD_Address)
   @  R2 = end (CD_Address)
   @  R7 -> control (CD_ControlBlock)

.set XCD_PlayTrack,0x6124c
.set CD_PlayTrack,0x4124c
   @Entry
   @  R0 = track (Int)
   @  R1 = play_to (CD_PlayToWhat)
   @  R7 -> control (CD_ControlBlock)

.set XCD_AudioPause,0x6124d
.set CD_AudioPause,0x4124d
   @Entry
   @  R0 = pause (Bool)
   @  R7 -> control (CD_ControlBlock)

.set XCD_EnquireTrack,0x6124e
.set CD_EnquireTrack,0x4124e

#  define CD_EnquireAllTracks 0x0
   @Entry
   @  R0 = &0
   @  R1 = info (pointer to CD_EnquireAllTracksBlock)
   @  R7 -> control (CD_ControlBlock)

.set XCD_EnquireOneTrack,0x6124e
.set CD_EnquireOneTrack,0x4124e
   @Entry
   @  R0 = track (Int)
   @  R1 = info (pointer to CD_EnquireOneTrackBlock)
   @  R7 -> control (CD_ControlBlock)

.set XCD_ReadSubChannel,0x6124f
.set CD_ReadSubChannel,0x4124f
   @Entry
   @  R0 = &40
   @  R1 = block (pointer to CD_SubChannelBlock)
   @  R7 -> control (CD_ControlBlock)

.set XCD_CheckDrive,0x61250
.set CD_CheckDrive,0x41250
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = status (Bits)

.set XCD_DiscChanged,0x61251
.set CD_DiscChanged,0x41251
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = changed (Bool)

.set XCD_StopDisc,0x61252
.set CD_StopDisc,0x41252
   @Entry
   @  R7 -> control (CD_ControlBlock)

.set XCD_DiscUsed,0x61253
.set CD_DiscUsed,0x41253
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = info (pointer to CD_DiscUsedBlock)
   @  R7 -> control (CD_ControlBlock)

.set XCD_AudioStatus,0x61254
.set CD_AudioStatus,0x41254
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = status (CD_Audio)

.set XCD_Inquiry,0x61255
.set CD_Inquiry,0x41255
   @Entry
   @  R0 = data (pointer to CD_InquiryBlock)
   @  R7 -> control (CD_ControlBlock)

.set XCD_DiscHasChanged,0x61256
.set CD_DiscHasChanged,0x41256
   @Entry
   @  R7 -> control (CD_ControlBlock)

.set XCD_Control,0x61257
.set CD_Control,0x41257
   @Entry
   @  R0 = level (CD_ErrorResponseLevel)
   @  R7 -> control (CD_ControlBlock)

.set XCD_Supported,0x61258
.set CD_Supported,0x41258
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = flags (CD_Flags)

.set XCD_Prefetch,0x61259
.set CD_Prefetch,0x41259
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @  R7 -> control (CD_ControlBlock)

.set XCD_Reset,0x6125a
.set CD_Reset,0x4125a
   @Entry
   @  R7 -> control (CD_ControlBlock)

.set XCD_CloseDrawer,0x6125b
.set CD_CloseDrawer,0x4125b
   @Entry
   @  R7 -> control (CD_ControlBlock)

.set XCD_IsDrawerLocked,0x6125c
.set CD_IsDrawerLocked,0x4125c
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = locked (Bool)

.set XCD_AudioControl,0x6125d
.set CD_AudioControl,0x4125d
   @Entry
   @  R0 = &0
   @  R1 = control (Int)
   @  R7 -> control_block (CD_ControlBlock)

.set XCD_LastError,0x6125e
.set CD_LastError,0x4125e
   @Exit
   @  R0 = errnum (Int)

.set XCD_AudioLevel,0x6125f
.set CD_AudioLevel,0x4125f
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 -> error (OS_Error)

.set XCD_Register,0x61260
.set CD_Register,0x41260
   @Entry
   @  R0 -> info (CD_RegisterBlock)
   @  R1 = driver_code (pointer to code)
   @  R2 = driver_workspace (pointer to Void)

.set XCD_Unregister,0x61261
.set CD_Unregister,0x41261
   @Entry
   @  R0 -> info (CD_RegisterBlock)
   @  R1 = driver_code (pointer to code)

.set XCD_ByteCopy,0x61262
.set CD_ByteCopy,0x41262
   @Entry
   @  R1 -> source (Byte)
   @  R2 = destination (pointer to Byte)
   @  R3 = size (Int)

.set XCD_Identify,0x61263
.set CD_Identify,0x41263
   @Entry
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R2 = drive_type (CD_DriveType)

.set XCD_ConvertToLBA,0x61264
.set CD_ConvertToLBA,0x41264
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @Exit
   @  R1 = new_address (CD_Address)

.set XCD_ConvertToMSF,0x61265
.set CD_ConvertToMSF,0x41265
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @Exit
   @  R1 = new_address (CD_Address)

.set XCD_ReadAudio,0x61266
.set CD_ReadAudio,0x41266
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @  R2 = block_count (Int)
   @  R3 = buffer (pointer to data)
   @  R4 = flags (Bits)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 corrupted
   @  R1 corrupted
   @  R2 = drive_type (CD_DriveType)
   @  R3 corrupted
   @  R4 corrupted
   @  R5 corrupted
   @  R6 corrupted
   @  R7 corrupted
   @  R8 corrupted
   @  R9 corrupted

.set XCD_ReadUserData,0x61267
.set CD_ReadUserData,0x41267
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @  R2 = size (Int)
   @  R3 = buffer (pointer to data)
   @  R4 = offset (Int)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R1 = last (CD_Address)
   @  R4 = next_offset (Int)

.set XCD_SeekUserData,0x61268
.set CD_SeekUserData,0x41268
   @Entry
   @  R0 = address_mode (CD_AddressMode)
   @  R1 = address (CD_Address)
   @  R2 = offset (Int)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R1 = found (CD_Address)
   @  R4 = offset_out (Int)

.set XCD_GetAudioParms,0x61269
.set CD_GetAudioParms,0x41269

#  define CDGetAudioParms_VolumeBlock 0x0
   @Entry
   @  R0 = &0
   @  R1 = block (pointer to CD_VolumeBlock)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R0 = cmp (CD_AudioCompletion)

.set XCD_SetAudioParms,0x6126a
.set CD_SetAudioParms,0x4126a

.set XCD_SCSIUserOp,0x6126b
.set CD_SCSIUserOp,0x4126b
   @Entry
   @  R0 = op (Bits)
   @  R1 = block_size (Int)
   @  R2 -> block (SCSI_OpBlock)
   @  R3 = start_addr (pointer to data)
   @  R4 = length (Int)
   @  R5 = timeout (Int)
   @  R7 -> control (CD_ControlBlock)
   @Exit
   @  R3 = next_addr (pointer to data)
   @  R4 = undone (Int)

#endif
