/* Copyright (c) 2006 Dirk Jagdmann <doj@cubic.org>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

    1. The origin of this software must not be misrepresented; you
       must not claim that you wrote the original software. If you use
       this software in a product, an acknowledgment in the product
       documentation would be appreciated but is not required.

    2. Altered source versions must be plainly marked as such, and
       must not be misrepresented as being the original software.

    3. This notice may not be removed or altered from any source
       distribution. */

/* $Header: /home/doj/code/cbmfs/d71.hpp,v 1.4 2006-07-21 14:46:04 doj Exp $ */

#pragma once

#include "cbmdisk.hpp"

class D71 : public CBMdisk
{
public:

#pragma pack(push, 1)
  struct bam_71 {
    /*0x00*/ TS dir;
    /*0x02*/ BYTE version;		/* should be 0x41 */
    /*0x03*/ BYTE onesided;
    /*0x04*/ bamentry entry[35];
    /*0x90*/ BYTE diskname[16];
    /*0xA0*/ BYTE unused1[2];		/* should be 0xA0 */
    /*0xA2*/ BYTE id[2];
    /*0xA4*/ BYTE unused2;		/* should be 0xA0 */
    /*0xA5*/ BYTE DOStype[2];		/* should be "2A" */
    /*0xA7*/ BYTE unused3[4];		/* should be 0xA0 */
    /*0xAB*/ BYTE unused4[0xDD-0xAB];	/* should be 0 */
    /*0xDD*/ BYTE free_sector[71-36];	/* free sector count for tracks 36-70 */
  };
  static_assert(sizeof(bam_71) == SECTOR_SIZE, "wrong packed size");
#pragma pack(pop)

  D71(BYTE *disk_);
  virtual TS dir();
  virtual int maxblocks();
  virtual void bam_set(const BYTE t, const BYTE s, const bool b);
  virtual void printbam();
  virtual int track_max();

  const BYTE* diskId() const override;
  const BYTE* diskName() const override;
  int format() override { return -1; }

protected:
  virtual bool bam_get(const BYTE t, const BYTE s);
  virtual const int* sectorsPerTrack();
  virtual void fix(bamentry*, const BYTE t);
  virtual bamentry* getbamentry(const BYTE t);
  virtual void printbaminfo();
  virtual bool reserved_track(const BYTE t);

  int dir_interleave() const override { return 3; }
  int file_interleave() const override { return 6; }

private:
  D71();
  D71(const D71&);
  D71& operator= (const D71&);
};
