Logo Search packages:      
Sourcecode: cbmconvert version File versions  Download package

static bool isFreeBlock ( const struct Image image,
byte_t  track,
byte_t  sector 
) [static]

Determine if the block at the specified track and sector is free.

Parameters:
image the disk image
track the track number
sector the sector number
Returns:
true if the block is available

Definition at line 293 of file image.c.

References Image::buf, Image::dirtrack, getBlock(), getGeometry(), Im1541, Im1571, Im1581, ImUnknown, Image::partTops, and Image::type.

Referenced by deleteInode(), findNextFree(), freeBlock(), mapInode(), and readInode().

{
  const struct DiskGeometry* geom;

  if (!image || !image->buf || !(geom = getGeometry (image->type)))
    return false;

  if (track < 1 || track > geom->tracks || sector >= geom->sectors[track])
    return false; /* illegal track or sector */

  switch (image->type) {
    const byte_t* BAM;

  case ImUnknown:
    return false;
  case Im1571:
    if (track > 35) {
      track -= 36;

      if (!(BAM = getBlock ((struct Image*) image, image->dirtrack + 35, 0)))
      return false;

      return true && BAM[(track * 3) + (sector >> 3)] & (1 << (sector & 7));
    }
    /* fall through: track <= 35 */
  case Im1541:
    if (!(BAM = getBlock ((struct Image*) image, image->dirtrack, 0)))
      return false;

    return true && BAM[(track << 2) + 1 + (sector >> 3)] & (1 << (sector & 7));

  case Im1581:
    if(track > image->partTops[image->dirtrack - 1] ||
       track < image->partBots[image->dirtrack - 1])
      return false;

    if (!(BAM = getBlock ((struct Image*) image, image->dirtrack, 1)))
      return false;

    if(track > 40) {
      if (!(BAM = getBlock ((struct Image*) image, BAM[0], BAM[1])))
      return false;

      track -= 40;
    }

    return true && (BAM[16 + (track - 1) * 6 + (sector >> 3) + 1] &
                (1 << (sector & 7)));
  }

  return false;
}


Generated by  Doxygen 1.6.0   Back to index