2013-05-07 04:23:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-12-19 14:11:03 +00:00
|
|
|
"fmt"
|
2013-05-07 04:23:36 +00:00
|
|
|
|
|
|
|
"github.com/gonuts/commander"
|
|
|
|
"github.com/zellyn/goapple2/disk"
|
|
|
|
)
|
|
|
|
|
|
|
|
var cmdDiskConvert = &commander.Command{
|
|
|
|
Run: runDiskConvert,
|
|
|
|
UsageLine: "diskconvert infile outfile",
|
|
|
|
Short: "convert apple II disk images",
|
|
|
|
Long: `
|
|
|
|
DiskConvert is a simple disk conversion utility.
|
|
|
|
`,
|
|
|
|
}
|
|
|
|
|
|
|
|
var diskVolume uint
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdDiskConvert.Flag.UintVar(&diskVolume, "v", 0, "The volume of the disk, or 0 for default.")
|
|
|
|
}
|
|
|
|
|
2013-12-19 14:11:03 +00:00
|
|
|
func runDiskConvert(cmd *commander.Command, args []string) error {
|
2013-05-07 04:23:36 +00:00
|
|
|
if len(args) != 2 {
|
|
|
|
cmd.Usage()
|
2013-12-19 14:11:03 +00:00
|
|
|
return nil
|
2013-05-07 04:23:36 +00:00
|
|
|
}
|
|
|
|
if diskVolume > 254 {
|
2013-12-19 14:11:03 +00:00
|
|
|
return fmt.Errorf("disk volume must be 0-254, got %d", diskVolume)
|
2013-05-07 04:23:36 +00:00
|
|
|
}
|
|
|
|
nyb, err := disk.DiskFromFile(args[0], byte(diskVolume))
|
|
|
|
if err != nil {
|
2013-12-19 14:11:03 +00:00
|
|
|
return err
|
2013-05-07 04:23:36 +00:00
|
|
|
}
|
|
|
|
if err = disk.DiskToFile(args[1], nyb); err != nil {
|
2013-12-19 14:11:03 +00:00
|
|
|
return err
|
2013-05-07 04:23:36 +00:00
|
|
|
}
|
2013-12-19 14:11:03 +00:00
|
|
|
|
|
|
|
return err
|
2013-05-07 04:23:36 +00:00
|
|
|
}
|