diskimage.c
/* free a block in the BAM */
free a block in the BAM
free a block in the BAM
void di_free_ts(DiskImage *di, TrackSector ts) {
  unsigned char mask;
  unsigned char *bam;
  di->modified = 1;
  switch (di->type) {
  case D64:
    mask = 1<<(ts.sector & 7);
    bam = get_ts_addr(di, di->bam);
    bam[ts.track * 4 + ts.sector / 8 + 1] |= mask;
    bam[ts.track * 4] += 1;
    break;
  case D71:
    mask = 1<<(ts.sector & 7);
    if (ts.track < 36) {
      bam = get_ts_addr(di, di->bam);
      bam[ts.track * 4 + ts.sector / 8 + 1] |= mask;
      bam[ts.track * 4] += 1;
    } else {
      bam = get_ts_addr(di, di->bam);
      bam[ts.track + 185] += 1;
      bam = get_ts_addr(di, di->bam2);
      bam[(ts.track - 35) * 3 + ts.sector / 8 - 3] |= mask;
    }
    break;
  case D81:
    if (ts.track < 41) {
      bam = get_ts_addr(di, di->bam);
    } else {
      bam = get_ts_addr(di, di->bam2);
      ts.track -= 40;
    }
    mask = 1<<(ts.sector & 7);
    bam[ts.track * 6 + ts.sector / 8 + 11] |= mask;
    bam[ts.track * 6 + 10] += 1;
    break;
  default:
    break;
  }
}
void di_free_ts ( DiskImage * di , TrackSector ts ) { unsigned char mask ; unsigned char * bam ; di -> modified = 1 ; switch ( di -> type ) { case D64 : mask = 1 << ( ts . sector & 7 ) ; bam = get_ts_addr ( di , di -> bam ) ; bam [ ts . track * 4 + ts . sector / 8 + 1 ] |= mask ; bam [ ts . track * 4 ] += 1 ; break ; case D71 : mask = 1 << ( ts . sector & 7 ) ; if ( ts . track < 36 ) { bam = get_ts_addr ( di , di -> bam ) ; bam [ ts . track * 4 + ts . sector / 8 + 1 ] |= mask ; bam [ ts . track * 4 ] += 1 ; } else { bam = get_ts_addr ( di , di -> bam ) ; bam [ ts . track + 185 ] += 1 ; bam = get_ts_addr ( di , di -> bam2 ) ; bam [ ( ts . track - 35 ) * 3 + ts . sector / 8 - 3 ] |= mask ; } break ; case D81 : if ( ts . track < 41 ) { bam = get_ts_addr ( di , di -> bam ) ; } else { bam = get_ts_addr ( di , di -> bam2 ) ; ts . track -= 40 ; } mask = 1 << ( ts . sector & 7 ) ; bam [ ts . track * 6 + ts . sector / 8 + 11 ] |= mask ; bam [ ts . track * 6 + 10 ] += 1 ; break ; default : break ; } }
free a block in the BAM
free a block in the BAM