package turgen.plugin.standard;

import java.io.File;
import turgen.Turgen;
import turgen.Utils;
import turgen.dtb.DOS2Binary;
import turgen.generator.PulseCrate;
import turgen.playlist.AbstractPlayListItem;
import turgen.plugin.BinaryConvertor;
import turgen.plugin.Plugin;


public class StandardBinaryFileConvertor implements BinaryConvertor {

    private Plugin plugin;

    public StandardBinaryFileConvertor(Plugin p) {
        this.plugin=p;
    }


    public boolean acceptsBinary(DOS2Binary bf) {
       if (bf.getTotalSegmentCount()>254) return false;
       if (bf.coversMemory(0x6f2, 0x085d)) return false;
       return true;
      
    }

    public int getPilotToneCount(DOS2Binary bf) {
        return 2+bf.getInitLocations().length;
    }

    public String getDescription() {
        
        return "Standard - binary";
        
    }

    public boolean hasLoader() {
        return true;
    }

    public AbstractPlayListItem getPlaylistItem(DOS2Binary bf, String inFile, String outFile,PulseCrate speed) {
        
        File f = new File(inFile);
        String fn = f.getName();
        if (fn.length()>10) fn=fn.substring(0,10);
        
        StandardPlaylistItem spi = new StandardPlaylistItem(inFile,outFile,fn,StandardPlaylistItem.IT_BINARY,Utils.parseNumberList(""),true);
        spi.pluginClass=Turgen.pluginManager.getPluginClassName(plugin);
        return spi;

    }

    public PulseCrate[] getSpeeds(int recorderModification) {
        return new PulseCrate[0];
    }

     public boolean acceptsRecorderModification(int recorderModification) {

        if (recorderModification==BinaryConvertor.REC_MOD_UN_STANDARD) return true;
        return false;
    }

    public boolean exhaustsRecorderModification(int recorderModification) {

        if (recorderModification==BinaryConvertor.REC_MOD_UN_STANDARD) return true;
        return false;
    }

    public boolean requiresPulses() {
        return false;
    }


}
