#ifndef HIDEDEVICE20_H
#define HIDEDEVICE20_H  (1)

/*****************************************************************
 *                                                               *
 *  Filename:   hidedevice20.h                                   *
 *  Release:    1.62                                             *
 *  Date:       13.11.1991 17:09                                 *
 *                                                               *
 *  'hidedisk.device' definitions and global constants.          *
 *  20 Sectors GCR version.                                      *
 *                                                               *
 *  (C) Copyright 1991 Stefan Klensch All Rights Reserved        *
 *                                                               *
 *****************************************************************/

#ifndef HIDESECS20_H
#include "hidesecs20.h"
#endif

#ifndef HIDEUNITS20_H
#include "hideunits20.h"
#endif

/*****************************************************************
 * Unitnumber specifications.                                    *
 *****************************************************************/

#define DEV_REALUNITS   (4)                 /* real # of units              */
#define DEV_ALLUNITS    (8)                 /* real + emulated              */

#define DEV_DDUNITS     (4)                 /* # dd units                   */
#define DEV_DDMINUNIT   (0)                 /* min. DD unit                 */
#define DEV_DDMAXUNIT   (3)                 /* max. DD unit                 */

#define DEV_HDUNITS     (4)                 /* # hd units                   */
#define DEV_HDMINUNIT   (4)                 /* min. HD unit                 */
#define DEV_HDMAXUNIT   (7)                 /* max. HD unit                 */

#define DEV_MAXUNIT     (DEV_HDMAXUNIT)     /* last possible unit           */

/*****************************************************************
 * These are the technical constants valid for both modes        *
 *****************************************************************/

#define DEV_SECTOR          (512)           /* #bytes in sector             */
#define DEV_SECSHIFT        (9)             /* shift (for 512)              */
#define DEV_NUMHEADS        (2)             /* #heads                       */
#define DEV_RETRIES         (10)            /* max. retries errorcase       */
#define DEV_STEPDELAY       (3000)          /* delay for step               */
#define DEV_SEEK000DELAY    (4000)          /* delay for recalibrate        */
#define DEV_SETTLEDELAY     (15000)         /* delay after dirchange        */

/*****************************************************************
 * These are the technical constants valid for DD or HD          *
 *****************************************************************/

#define DD_NUMSECS      (MFM_SECTORS)       
#define DD_NUMCYLS      (80)
#define DD_NUMTRACKS    (DD_NUMCYLS*DEV_NUMHEADS)
#define DD_MAXOFFSET    (DD_NUMTRACKS*DD_NUMSECS*DEV_SECTOR)
#define DD_TIMEOUT      (300000)
#define DD_READSZ       (MFM_READSZ)
#define DD_WRITESZ      (MFM_WRITESZ)
#define DD_PRECOMP01    (80)
#define DD_READBUFOFF   (6)
#define DD_UNITID       (0x78787878)

#define HD_NUMSECS      (GCR_SECTORS)       
#define HD_NUMCYLS      (82)
#define HD_NUMTRACKS    (HD_NUMCYLS*DEV_NUMHEADS)
#define HD_MAXOFFSET    (HD_NUMTRACKS*HD_NUMSECS*DEV_SECTOR)
#define HD_TIMEOUT      (400000)
#define HD_READSZ       (GCR_READSZ)
#define HD_WRITESZ      (GCR_WRITESZ)
#define HD_PRECOMP01    (88)
#define HD_READBUFOFF   (2)
#define HD_UNITID       (0x66666666)

/*****************************************************************
 * Version/revision/pri of dev.                                  *
 *****************************************************************/

#define DEV_VERSION     (1)                 /*  1. version                  */
#define DEV_REVISION    (62)                /* 62. revision                 */
#define DEV_PRI         (0)                 /* no pri                       */

/*****************************************************************
 * HideDevice                                                    *
 *****************************************************************
 * Master device structure for hide.device.                      *
 *****************************************************************/

struct HideDevice {                         /* startof                      */
    struct  Library hd_LibNode;             /* std libnode                  */
    struct  PrivateUnit *hd_PrivUnits[8];   /* table private units          */

/*****************************************************************
 * Seglist and libs/devs/resources                               *
 *****************************************************************/

    BPTR    hd_SegList;                     /* segment list load            */
    struct  ExecBase *hd_ExecBase;          /* ptr exec.library             */
    struct  DiskResource *hd_DiskResBase;   /* ptr disk.resource            */
    APTR    hd_CiabResBase;                 /* ptr ciab.resource            */
    struct  GfxBase *hd_GfxBase;            /* ptr graphics.library         */

    struct  Device *hd_VBTimerDev;          /* ptr timerdev vblank          */
    struct  Unit *hd_VBTimerUnit;           /* unit that timer              */
    struct  Device *hd_MHTimerDev;          /* ptr timerdev microhz         */
    struct  Unit *hd_MHTimerUnit;           /* unit that timer              */

/*****************************************************************
 * Keyboard stuff for resethandler.                              *
 *****************************************************************/

    struct  IOStdReq hd_KeyBoardIO;         /* keyboard iosr                */
    struct  Interrupt hd_KeyBoardIr;        /* keyboard interrupt           */

/*****************************************************************
 * Global master flags.                                          *
 *****************************************************************/

    UBYTE   hd_Flags;                       /* extended device flags        */

/*****************************************************************
 * Turbo is easy reference for Unit-init, set if >= 68020        *
 * Important for CPU-en/decoding in HD mode and odd data address *
 * processing in both modes.                                     *
 *****************************************************************/

    UBYTE   hd_Turbo;                       /* true, if >= 68020            */
    };                                      /* endof                        */

/*****************************************************************
 * Using macros instead of real names.                           *
 *****************************************************************/

#define DEV_NAME    ("hidedisk.device")

/*****************************************************************
 * Defines for hd_Flags                                          *
 *                                                               *
 * DEVB_INRESET will be set by our Keyboard-Resethandler to      *
 * inhibit new writing after CTRL-A-A.                           *
 *                                                               *
 * DEVB_WRITING will (try to) delay reset-processing of          *
 * 'keyboard.device' to finish current write-request.            *
 *                                                               *
 *****************************************************************/

#define DEVB_INRESET    (0)                 /* resethandler sets this       */
#define DEVF_INRESET    (1 << 0)

#define DEVB_WRITING    (1)                 /* device writes, if 1          */
#define DEVF_WRITING    (1 << 1)

/*****************************************************************
 * Following bits usable with TD_RAWREAD/TD_RAWWRITE. Bits have  *
 * to be set in IO_FLAGS.                                        *
 *                                                               *
 * IOHDB_INDEXSYNC will use index-sync detection to start DMA.   *
 * IOHDB_WORDSYNC will use dsksync-value to start DMA.           *
 * IOHDB_ALTWORDSYNC will use alternate syncword coming in       *
 * IOTD_SECLABEL:16.                                             *
 *****************************************************************
 * See 'developer.doc' for more details.                         *
 *****************************************************************/

#define IOHDB_INDEXSYNC     (4)             /* indexsync raw                */
#define IOHDF_INDEXSYNC     (1 << 4)

#define IOHDB_WORDSYNC      (5)             /* wordsync raw                 */
#define IOHDF_WORDSYNC      (1 << 5)

#define IOHDB_ALTWORDSYNC   (6)             /* alternate wordsync raw       */
#define IOHDF_ALTWORDSYNC   (1 << 6)

/*****************************************************************
 * Flags for device-internal motor-management.                   *
 *****************************************************************/

#define MOTOR_ON            (1)             /* turn motor on                */
#define MOTOR_OFF           (0)             /* turn motor off               */

/*****************************************************************
 * New type for GetDriveType.                                    *
 * In DD mode, DRIVE3_5 from 'devices/trackdisk.h' is returned.  *
 *****************************************************************/

#define DRIVE3_5HD20        (101)           /* hi-density 3.5 20 secs       */

/*****************************************************************
 * END of hidedevice20.h                                         *
 *****************************************************************/

#endif
