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

int qdisk_format ( const struct comm comm,
FILE *  file,
const char *  name,
char  id1,
char  id2 
)

fast format a 1541 disk

Parameters:
comm the communication primitives
file output file for disk status message
name disk name (16 characters, not NUL terminated)
id1 first ID byte
id2 second ID byte
Returns:
zero on success, nonzero on error

start address of the drive code

Definition at line 186 of file qdisk.c.

References format1541, format_entry, m_w(), rdfile_raw(), and workbuf.

Referenced by main().

{
  /** start address of the drive code */
  unsigned start;
  int status;
  char* buf = malloc ((sizeof format1541) + 16);
  /* copy the code */
  memcpy (buf, format1541, sizeof format1541);
  /* copy the disk name */
  memcpy (buf + sizeof format1541, name, 16);
  /* copy the disk ID */
  for (start = 0; start < (sizeof format1541) - 9; start++) {
    if (memcmp (buf + start, format_entry, sizeof format_entry))
      continue;
    buf[start + 3] = id1, buf[start + 5] = id2;
    break;
  }
  start += 0x400;
  status = m_w (comm, buf, (sizeof format1541) + 16, 0x400);
  free (buf);
  if (!status) {
    memcpy (workbuf, "\5M-E", 4);
    workbuf[4] = start, workbuf[5] = start >> 8;
    status = rdfile_raw (comm, file, workbuf);
  }
  return status;
}


Generated by  Doxygen 1.6.0   Back to index