17.5.4. DiskWriter Plugins

With disk writers you can write disks in a format you decide. Before reading further, read about the the standard disk writer to see what they are able to do. To create a writer you implement a class of the interface IDiskWriter:

public interface IDiskWriter extends IPlugin {
   DiskWriterDefinition getDefinition();
   void execute(IDiskData disk, IEngine engine);

public class DiskWriterDefinition {
   private String name;
   private Set<String> allDiskParameters;
   private Set<String> nonOptionalDiskParameters;
   private Set<String> allFileParameters;
   private Set<String> nonOptionalFileParameters;

Recall the format of the .disk directive to understand the definition properties:


When WRITERNAME matches the name given in the definition the writer is called. Then we have two kinds of parameters: disk and file parameters. For each of these is a set of all possible parameters and a set of non-optional parameters. If a parameter is give that is not included in the allParameters set Kick Assembler will generate an error. The same will happen if a non optional parameter is missing.

The execute method has parameters of two new interfaces:

public interface IDiskData {
   IParameterMap getParameters();
   List<IDiskFileData> getFiles();

public interface IDiskFileData {
   IParameterMap getParameters();
   List<IMemoryBlock> getMemoryBlocks();

These represent the given parameters and provides the values and the bytes which should be stored in each file.

When creating the output file, use the IEngine object to open an output stream for storing the bytes. For details, refer to the example project.