cd.h

// imWare
// Wednesday, February 14, 1990
// James Beninghaus
 
#ifndef __FILES__
    #include    <Files.h>
#endif
#ifndef __DEVICES__
    #include    <Devices.h>
#endif
 
#define csDiscStatus    8
#define csWhoIsThere    97
#define csReadTOC       100
#define csReadQ         101
#define csATrkSearch    103
#define csAPlay         104
#define csAPause        105
#define csAStop         106
#define csAStatus       107
#define csAScan         108
 
#define BLOCKADDR       0
#define MSFADDR         1
#define TRACKADDR       2
 
#define TOCTRACKS       1
#define TOCENDOFDISK    2
#define TOCSTARTADDR    3
 
#define STEREO          9
#define MONO            15
 
#define START           0
#define STOP            1
 
#define PAUSE           1
#define CONTINUE        0
 
#define PLAYING         0
#define PAUSED          1
 
//typedef   unsigned char   Byte;
typedef unsigned short  Word;
typedef unsigned long   Long;
 
typedef struct WhoIsThereRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Byte    fill;
        Byte    SCSIMask;
    } csParam;
} WhoIsThereRec;
 
typedef struct AStatusRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Byte    audioStatus;
        Byte    playMode;
        Byte    cntlField;
        Byte    minutes;
        Byte    seconds;
        Byte    frames;
    } csParam;
} AStatusRec;
 
typedef struct {
    Byte        cntlField;
    Byte        minutes;
    Byte        seconds;
    Byte        frames;
} StartAddrRec;
 
typedef struct ReadTOCRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    union {
        Word    type;
        Byte    addr[3];
        struct {
            Word    fill;
            Long    data;
            Word    length;
            Byte    track;
        } buffer;
    } csParam;
} ReadTOCRec;
 
typedef struct APlayRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Word    type;
        Byte    addr[4];
        Word    startStop;
        Byte    fill;
        Byte    playMode;
    } csParam;
} APlayRec;
 
typedef struct ATrkSearchRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Word    type;
        Byte    addr[4];
        Word    playFlag;
        Byte    fill;
        Byte    playMode;
    } csParam;
} ATrkSearchRec;
 
typedef struct AStopRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Word    type;
        Byte    addr[4];
    } csParam;
} AStopRec;
 
typedef struct APauseRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Long    state;
    } csParam;
} APauseRec;
 
typedef struct DiscStatusRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Word    track;
        Byte    writeProtect;
        Byte    discInPlace;
        Byte    installed;
        Byte    side;
        Long    qLink;
        Word    qType;
        Word    dQDrive;
        Word    dQRefNum;
        Word    dQFSID;
        Byte    twoSideFormat;
        Byte    needsFlush;
        Byte    diskErrs;
    } csParam;
} DiscStatusRec;
 
typedef struct ReadQRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Byte    cntlField;
        Byte    track;
        Byte    index;
        Byte    trackMinutes;
        Byte    trackSeconds;
        Byte    trackFrames;
        Byte    discMinutes;
        Byte    discSeconds;
        Byte    discFrames;
    } csParam;
} ReadQRec;
 
typedef struct AScanRec {
    ParamBlockHeader
    short       ioRefNum;
    short       csCode;
    struct {
        Word    type;
        Byte    addr[4];
        Word    direction;
    } csParam;
} AScanRec;
 
void            Usage       (void);
pascal  Byte    Decimal2BCD (Byte n);
pascal  Byte    BCD2Decimal (Byte n);
pascal  OSErr   EjectCD     (short ioRefNum);
pascal  OSErr   OpenCD      (Byte CDDrive, short *ioRefNum);
pascal  OSErr   APlay       (short ioRefNum, Byte startTrack, Byte playMode);
pascal  OSErr   AScan       (short ioRefNum, Byte minutes, Byte seconds, Byte frames, Byte direction);
pascal  OSErr   APause      (short ioRefNum, Long state);
pascal  OSErr   AStop       (short ioRefNum, Byte stopTrack);
pascal  OSErr   ATrkSearch  (short ioRefNum, Byte track, Byte playFlag, Byte playMode);
pascal  OSErr   AStatus     (short ioRefNum, Byte *audioStatus, Byte *playMode, Byte *cntlField, Byte *minutes, Byte *seconds, Byte *frames);
pascal  OSErr   TrackCount  (short ioRefNum, Byte *lastTrack);
pascal  OSErr   TrackInfo   (short ioRefNum, Byte track, Byte *cntlField, Byte *minutes, Byte *seconds, Byte *frames);
pascal  OSErr   DiscStatus  (short ioRefNum, Boolean *discInPlace);
pascal  OSErr   ReadQ       (short ioRefNum, Byte *cntlField, Byte *track, Byte *index, Byte *trackMinutes, Byte *trackSeconds, Byte *trackFrames, Byte *discMinutes, Byte *discSeconds, Byte *discFrames);