package turgen.plugin.plturbo;
import java.io.File;
import turgen.Turgen;

import turgen.dtb.DOS2Binary;
import turgen.generator.PulseCrate;

import turgen.playlist.AbstractPlayListItem;
import turgen.plugin.BinaryConvertor;
import turgen.plugin.Plugin;


public class PlLowerSilesiaTurbo2000BinaryLoadABinaryConvertor implements BinaryConvertor {

    private final Plugin plugin;

    public PlLowerSilesiaTurbo2000BinaryLoadABinaryConvertor(PlLowerSilesiaTurbo2000Plugin p) {
        this.plugin=p;
    }


    public boolean acceptsBinary(DOS2Binary bf) {
       if (bf.coversMemory(0x700, 0x92D)) return false;
       return true;
    }

    public int getPilotToneCount(DOS2Binary bf) {
        return 2+bf.getTotalSegmentCount()*2;
    }

    public String getDescription() {
        return "Lower Silesia Turbo 2000 - UE Protected Binary";
    }

    public boolean hasLoader() {
        return true;
    }

    public AbstractPlayListItem getPlaylistItem(DOS2Binary bf, String inFile, String outFile,PulseCrate speed) {
        
        File f = new File(inFile);
        String sName = f.getName();
        if (sName.length()>10) sName=sName.substring(0,10);
        PlLowerSilesiaTurbo2000PlaylistItem pi = new PlLowerSilesiaTurbo2000PlaylistItem(inFile, outFile, speed, sName, PlLowerSilesiaTurbo2000PlaylistItem.CV_BINARY_BINLOAD_A, new int[0]);
        pi.pluginClass=Turgen.pluginManager.getPluginClassName(plugin);
        return pi;
        

    }

    public PulseCrate[] getSpeeds(int recorderModification) {
            return Turgen.pulseCache.getPulsesForPlugin(plugin.getClass().getName());
    }

     public boolean acceptsRecorderModification(int recorderModification) {

        /*Lower Silesia Turbo 2000*/
        if (recorderModification==BinaryConvertor.REC_MOD_PL_LOWER_SILESIA_2000) return true;
        /*Ohters are not*/
        return false;
    }

    public boolean exhaustsRecorderModification(int recorderModification) {

        /*Turbo 2000 is exhausted always*/
        if (recorderModification==REC_MOD_PL_LOWER_SILESIA_2000) return true;
        /*Ohters are not*/
        return false;

    }

    public boolean requiresPulses() {
        return true;
    }


}
