home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quakeworld_src / client / twfsound_cd.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-17  |  6.2 KB  |  168 lines

  1. //     ___       ___
  2. //   _/  /_______\  \_     ___ ___ __ _                       _ __ ___ ___
  3. //__//  / _______ \  \\___/                                               \___
  4. //_/ | '  \__ __/  ` | \_/        © Copyright 1998, Christopher Page       \__
  5. // \ | |    | |__  | | / \               All Rights Reserved               /
  6. //  >| .    |  _/  . |<   >--- --- -- -                       - -- --- ---<
  7. // / \  \   | |   /  / \ / This file may not be distributed, reproduced or \
  8. // \  \  \_/   \_/  /  / \  altered, in full or in part, without written   /
  9. //  \  \           /  /   \    permission from Christopher Page. Legal    /
  10. // //\  \_________/  /\\ //\     action will be taken in cases where     /
  11. //¯ ¯¯\   _______   /¯¯ ¯ ¯¯\        this notice is not obeyed.         /¯¯¯¯¯
  12. //¯¯¯¯¯\_/       \_/¯¯¯¯¯¯¯¯¯\   ___________________________________   /¯¯¯¯¯¯
  13. //                            \_/                                   \_/
  14. //
  15. // Description:
  16. //
  17. //  Sound library header (development version).
  18. //
  19. // Detail:
  20. //
  21. //  This file contains the structyres, defines and includes used by the
  22. //  TWFSound library and it's routines.
  23. //
  24. // Vesion:
  25. //
  26. //  $VER: twfsound_cd.h 3.12 (17/10/1999)
  27. //
  28. // Fold Markers:
  29. //
  30. //  Start: /*GFS*/
  31. //    End: /*GFE*/
  32.  
  33. #include<exec/exec.h>
  34. #include<dos/dos.h>
  35. #include<dos/dostags.h>
  36. #include<dos/dosextens.h>
  37. #include<devices/scsidisk.h>
  38. #include<utility/utility.h>
  39. #include<utility/tagitem.h>
  40.  
  41. #include<clib/exec_protos.h>
  42. #include<clib/dos_protos.h>
  43. #include<clib/alib_protos.h>
  44. #include<clib/utility_protos.h>
  45.  
  46. #include <proto/exec.h>
  47. #include <proto/dos.h>
  48. #include <proto/utility.h>
  49.  
  50. #define REG(x)
  51.  
  52. // General Codes
  53. #define TWFCD_OK                       0x1000
  54.  
  55. // Error Codes
  56. #define TWFCD_FAIL                     0x2000
  57. #define TWFCD_FAIL_OPEN_DEVICE         0x2001
  58. #define TWFCD_FAIL_NOT_AUDIO           0x2002
  59. #define TWFCD_NOAUDIO                     255
  60.  
  61. // Structure sizes
  62. #define CDBUFFER_SIZE                     252
  63. #define CDSENSE_SIZE                      252
  64. #define CDTOC_SIZE                        804  // Allows for 200 track descriptors
  65. #define PAD                                 0
  66.  
  67. // SCSI-2 CD-ROM command codes
  68. #define SCSI_CMD_READSUB_CHANNEL          0x42
  69. #define SCSI_CMD_READTOC                  0x43
  70. #define SCSI_CMD_PLAYAUDIO10              0x45
  71. #define SCSI_CMD_PLAYAUDIO12              0xA5
  72. #define SCSI_CMD_PLAYAUDIO_TRACKINDEX     0x48
  73. #define SCSI_CMD_PAUSE_RESUME             0x4B
  74. #define SCSI_CMD_START_STOP_UNIT          0x1B
  75.  
  76. // values which can be passed to TWFCD_MotorControl()
  77. #define TWFCD_MOTOR_STOP                  0x00
  78. #define TWFCD_MOTOR_START                 0x01
  79. #define TWFCD_MOTOR_EJECT                 0x02
  80. #define TWFCD_MOTOR_LOAD                  0x03
  81.  
  82. // Tags
  83. // Index of the first track to play, default is first audio track
  84. #define TWFCD_Track_Start         (TAG_USER|(128<<16)|0x0000)   // (UBYTE)
  85.  
  86. // Index of the last track to play, default is 99
  87. #define TWFCD_Track_End           (TAG_USER|(128<<16)|0x0001)   // (UBYTE)
  88.  
  89. // Number of tracks to play (overrides TWFCD_Track_End). Default 99
  90. #define TWFCD_Track_Count         (TAG_USER|(128<<16)|0x0002)   // (UBYTE)
  91.  
  92. // Play mode, use one of the SCSI_CMD_PLAYAUDIO#?s above. Def is PLAYAUDIO12
  93. #define TWFCD_Track_PlayMode      (TAG_USER|(128<<16)|0x0003)   // (UBYTE)
  94.  
  95.  
  96. struct TWFCD_Command
  97. {
  98.     struct MsgPort  *cdc_MsgPort      ;  // Used to reply to the program from the device
  99.     struct IOStdReq *cdc_IOStdReq     ;  // Used to send cmds to the device
  100.     struct SCSICmd   cdc_SCSICmd      ;  // Direct access to the CD through the SCSI device
  101.  
  102.     // Generic buffers in chip ram
  103.     UBYTE *cdc_SCSIData;  // Buffer for scsi_Data field
  104.     UBYTE *cdc_SCSISense;  // Buffer for scsi_Sense [ERRORS!]
  105.     UBYTE *cdc_TOCBuffer;  // Stores the table of contents for the CD-ROM disc
  106. };
  107.  
  108. struct TWFCD_Track
  109. {
  110.     ULONG cdt_Address; // Logical address on the CD
  111.     BOOL  cdt_Audio  ; // TRUE if the track is an audio track
  112.     ULONG cdt_Length ; // Length in logical blocks, divide by 75 to get approximate
  113.                        // length in seconds
  114. };
  115.  
  116. struct TWFCD_Attrs
  117. {
  118.            BOOL        cda_GotTOC    ;      // TRUE if TOC has been read
  119.            BOOL        cda_Paused    ;      // Go on, have a guess.
  120.            UBYTE       cda_FirstTrack;      // # of first real track
  121.            UBYTE       cda_FirstAudio;      // # of first audio track
  122.            UBYTE       cda_LastTrack ;      // maximum track number
  123.            ULONG       cda_CDLength  ;      // Length of the CD, divide by 75 to get length in seconds
  124.            ULONG       cda_AudioLen  ;      // Length of the audio tracks, divide by 75 for seconds
  125.            char        cda_DiskId[20];      // MCDPlayer compatible!
  126.     struct TWFCD_Track cda_TrackData[100];  // 1+ indexed, 0 is not used (easier to deal with 1-indexed CD drive)
  127. };
  128.  
  129. #define TWFCD_AUDIOSTATUS_INVALID   0x00
  130. #define TWFCD_AUDIOSTATUS_PLAYING   0x11
  131. #define TWFCD_AUDIOSTATUS_PAUSED    0x12
  132. #define TWFCD_AUDIOSTATUS_FINISHED  0x13
  133. #define TWFCD_AUDIOSTATUS_ERROR     0x14
  134. #define TWFCD_AUDIOSTATUS_NOSTATUS  0x15
  135.  
  136. struct TWFCD_SubData
  137. {
  138.     UBYTE  cds_AudioStatus;
  139.     UBYTE  cds_PlayTrack  ; // not valid if audio status is INVALID or NOSTATUS
  140.     ULONG  cds_RelAddress ; // Divide the following 4 fields by 75 to get the seconds equivalents
  141.     ULONG  cds_RelRemain  ;
  142.     ULONG  cds_AbsAddress ;
  143.     ULONG  cds_AbsRemain  ;
  144. };
  145.  
  146. struct TWFCDData
  147. {
  148.     struct TWFCD_Command TWFCD_Cmd;
  149.     struct TWFCD_Attrs   TWFCD_Table;
  150.     struct TWFCD_SubData TWFCD_Track;
  151. };
  152.  
  153. extern struct TWFCDData * TWFCD_Setup         (STRPTR DeviceName           , UBYTE UnitNum);
  154. extern ULONG              TWFCD_Shutdown      (struct TWFCDData *tcs_OldData);
  155. extern ULONG              TWFCD_ReadTOC       (struct TWFCDData *tcrt_CDData);
  156. extern ULONG              TWFCD_PlayTracks    (struct TWFCDData *tcpt_CDData, struct TagItem *pt_Tags);
  157. extern ULONG              TWFCD_StopPlay      (struct TWFCDData *tcsp_CDData);
  158. extern ULONG              TWFCD_PausePlay     (struct TWFCDData *tcpp_CDData);
  159. extern ULONG              TWFCD_MotorControl  (struct TWFCDData *tcet_CDData, UBYTE newStatus);
  160. extern ULONG              TWFCD_ReadSubChannel(struct TWFCDData *tcrs_CDData);
  161.  
  162. #ifndef NDEBUG
  163.     extern void kprintf(UBYTE *fmt,...);
  164.     #define DEBUGLOG(x) x
  165. #else
  166.     #define DEBUGLOG(x)
  167. #endif
  168.