

// Modes supported - yeah we should register them
#define FLOPPYAUDIO_HW_ID       0x0FA00000UL
#define FLOPPYAUDIO_ID_MONO     (FLOPPYAUDIO_HW_ID | 0x0001) 
#define FLOPPYAUDIO_ID_STEREO   (FLOPPYAUDIO_HW_ID | 0x0002) 

// This is actually calculated from Paula clocking at 500kb/s, so 500000/8 = 62500 Hz. Seeing as Stereo8 and Mono16 use DWORDs, we divide by two and end up with this!
#define FLOPPYAUDIO_SAMPLE_RATE 31250   

// Max Paula DMA buffer size for DSKLEN
#define DMA_BUF_BYTES           32766
#define DMA_BUF_WORDS           (DMA_BUF_BYTES / 2)

// To hold some stuff for the system floppy drives
struct SysFloppyDrive {
    struct MsgPort*     port;
    struct IOExtTD*     io;
    BOOL                isOpen;
};

#define NUM_BUFFERS 2


// Driver base
struct FloppyData {

    // Save data about the four drives
    struct SysFloppyDrive   drives[4];

    //struct FloppyAudioBase* ahisubbase;     // library base access
    ULONG                   audioid;        // Mode currently in use

    UWORD*                  dmaBuffers[NUM_BUFFERS];  // buffers we will use for playback, in CHIP ram
    UWORD                   bufferPlaying;            // Which buffer is actually playing right now
    UWORD*                  bufferWritePosition;      // What position we're currently at in the buffer
    UWORD                   bufferWordsLeft;          // How many words are left in the buffer

    APTR                    mixBuffer;          // Mixing buffer from AHI

    struct Process*         mainTask;       // Main task
    struct Process*         mixerTask;      // Mixer process
    struct AHIAudioCtrlDrv* audioCtrl;      // Need this!

    BYTE                    mixerReady;     // Signal from the Mixer when it's started
    BYTE                    mixerAbort;     // Signal from main to close mixer
    UBYTE                   oldCIA;         // Old value of CIABPRB before we messed with it
    volatile BOOL           playing;        

};

#define CIABPRB     (*(volatile UBYTE*)0xBFD100)
#define DSKPTH      (*(volatile UWORD*)0xDFF020)
#define DSKPTL      (*(volatile UWORD*)0xDFF022)
#define DSKLEN      (*(volatile UWORD*)0xDFF024)
#define DMACON      (*(volatile UWORD*)0xDFF096)
#define DMACONR     (*(volatile UWORD*)0xDFF002)
#define INTREQ      (*(volatile UWORD*)0xDFF09C)
#define INTREQR     (*(volatile UWORD*)0xDFF01E)
#define INTENA      (*(volatile UWORD*)0xDFF09A)
#define INTENAR     (*(volatile UWORD*)0xDFF01C)