<commit_before>package ucesoft.c64.peripheral.drive

/**
 * @author ealeame
 */
trait Floppy {
  type TrackListener = (Int,Boolean,Option[Int]) => Unit
  val isReadOnly : Boolean
  val totalTracks : Int
  
  def nextBit : Int
  def writeByte(value:Int)
  def prepareToWrite
  def canWrite : Boolean
  
  def currentTrack : Int
  def currentSector : Option[Int]
  def changeTrack(trackSteps:Int)
  def setTrackChangeListener(l:TrackListener)
  def notifyTrackSectorChangeListener
  
  def format(diskName:String)
  
  def defaultZoneFor(track:Int) : Int = {
    if (track <= 17) 0
    else if (track <= 24) 1
    else if (track <= 30) 2
    else 3
  }
  
  def close
  def reset
}

object EmptyFloppy extends Floppy {
  val isReadOnly = false
  val totalTracks = 42
  private[this] var track = 1
  
  def nextBit = 0
  def writeByte(value:Int) {}
  def prepareToWrite {}
  def canWrite = false
  
  def currentTrack = track
  def currentSector = None
  def changeTrack(trackSteps:Int) {
    val isOnTrack = (trackSteps & 1) == 0
    if (isOnTrack) {
      track = trackSteps >> 1
    }
  }
  def setTrackChangeListener(l:TrackListener) {}
  def notifyTrackSectorChangeListener {}
  
  def format(diskName:String) = throw new IllegalArgumentException("Empty disk. Can't format")
  
  def close {}<commit_msg>Interface changed: now the writing is performed bit by bit.<commit_after>package ucesoft.c64.peripheral.drive

/**
 * @author ealeame
 */
trait Floppy {
  type TrackListener = (Int,Boolean,Option[Int]) => Unit
  val isReadOnly : Boolean
  val isFormattable : Boolean
  val totalTracks : Int
  
  def nextBit : Int
  def writeNextBit(bit:Boolean)
  
  def currentTrack : Int
  def currentSector : Option[Int]
  def changeTrack(trackSteps:Int)
  def setTrackChangeListener(l:TrackListener)
  def notifyTrackSectorChangeListener
  
  def format(diskName:String)
  
  def defaultZoneFor(track:Int) : Int = {
    if (track <= 17) 0
    else if (track <= 24) 1
    else if (track <= 30) 2
    else 3
  }
  
  def close
  def reset
}

object EmptyFloppy extends Floppy {
  val isReadOnly = false
  val isFormattable = false
  val totalTracks = 42
  private[this] var track = 1
  
  def nextBit = 0
  def writeNextBit(bit:Boolean) {}
  
  def currentTrack = track
  def currentSector = None
  def changeTrack(trackSteps:Int) {
    val isOnTrack = (trackSteps & 1) == 0
    if (isOnTrack) {
      track = trackSteps >> 1
    }
  }
  def setTrackChangeListener(l:TrackListener) {}
  def notifyTrackSectorChangeListener {}
  
  def format(diskName:String) = throw new IllegalArgumentException("Empty disk. Can't format")
  
  def close {}
{'fraction_non_alphanumeric': 0.08887200911507785, 'fraction_numerical': 0.014432206608431447, 'mean_word_length': 3.4343434343434343, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7146208', 'n_tokens_mistral': 906, 'n_tokens_neox': 865, 'n_words': 243}