Skip to content
/ d64 Public

Commodore 64 .d64 diskimage library written in Go

Notifications You must be signed in to change notification settings

staD020/d64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

d64

d64 is a Commodore 64 .d64 diskimage library written in Go.

Install Library

go get github.com/staD020/d64

Features

  • Create a .d64
  • Add PRG files to a new or existing .d64
  • Custom sector interleave (guesses based on existing files)
  • Disk Label and 5 char Disk ID
  • Extract all PRGs from a .d64

Bugs & Missing Features

  • DEL/REL/SEQ/USR files are ignored, they will be overwritten
  • You can add files with the same filename
  • Scratch/delete
  • 36+ tracks
  • Per file sector interleave
  • DirArt
  • Optional file storage on the DirTrack

I'm actually not planning on handling these or other features, unless I need them myself. There are other d64 tools around with far more capabilities, check cc1541 for example.

Pull requests are welcome though.

Command-line Interface

go install github.com/staD020/d64/cmd/d64@latest

Build from source

go test -v -cover -bench . -benchmem && go build -v ./cmd/d64

Examples

A couple of common examples, error-handling omitted.

package main

import (
	"fmt"
	"github.com/staD020/d64"
)

func main() {
	exampleNewDisk()
	exampleLoadDisk()
	exampleExtract()
}

func exampleNewDisk() {
	d := d64.NewDisk("a new disk", "01 2a", d64.DefaultSectorInterleave)
	_ = d.AddFile("foo.prg", "foo")
	_ = d.AddFile("bar.prg", "bar")
	_ = d.WriteFile("foo.d64")

	fmt.Println("Directory:\n", d)
}

func exampleLoadDisk() {
	d, _ := d64.LoadDisk("foo.d64")
	_ = d.AddFile("baz.prg", "baz")
	_ = d.WriteFile("foo.d64")

	fmt.Println("Directory:\n", d)
}

func exampleExtract() {
	d, _ := d64.LoadDisk("foo.d64")
	_, _ = d.ExtractToPath(".")
}

func exampleReaderWriter() {
	d := d64.NewDisk("a new disk", "01 2a", d64.DefaultSectorInterleave)
	r, _ := os.Open("foo.prg")
	defer r.Close()
	_ = d.AddPrgFromReader("foo", r)
	w, _ := os.Create("foo.d64")
	defer w.Close()
	_, _ = d.WriteTo(w)

	fmt.Println("Directory:\n", d)
}

About

Commodore 64 .d64 diskimage library written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages