Skip to main content

Cenbe's Commodore 64 Disk Image Library

Project description

This project is a Python library for writing programs to explore Commodore 64 disk images; my Disk Wrangler (q.v.) is based on it. It's particularly good at dissecting GEOS disks. Here's how to get started:

Create a DiskImage object. Just pass a Path to the constructor; he'll detect the image type (or raise an Exception if it's not one):

from pathlib import Path
from d64py.base.DiskImage import DiskImage
from d64py.base.Constants import CharSet

path = Path("/your/image/here.d64")
image = DiskImage(path)

Now you can read the directory:

dirEntries = image.getDirectory()
for dirEntry in dirEntries:
    print(f"{dirEntry.getDisplayFileName()}")

If you have a GEOS file, you can access the fields in the file header:

    if dirEntry.isGeosFile():
        geosFileHeader = dirEntry.getGeosFileHeader()
        print(f"permanent name string: {geosFileHeader.getPermanentNameString()}")

Say there's a geoWrite file on the disk, and you'd like to quickly see what's in it. We can ask the disk image to find the directory entry for us (if we specify CharSet.PETSCII, the filename will be translated to PETSCII first). All the routines that return lines of text return TextLine objects, which is just a helper class that includes a line of text and an error flag (for e.g. printing in red). geoWrite files return a list of pages, each of which is a list of TextLines.

dirEntry = image.findDirEntry("firstBootSrc", CharSet.ASCII)
pages = image.getGeoWriteFileAsLines(dirEntry)
for page in pages:
    for line in page:
        print(line.text)

Don't forget to release the image's resources when you're through with it (the entire image gets memory-mapped):

image.close()

To dig deeper, you can find the API docs here and the revision history here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d64py-3.0.4.tar.gz (240.8 kB view details)

Uploaded Source

Built Distribution

d64py-3.0.4-py3-none-any.whl (241.4 kB view details)

Uploaded Python 3

File details

Details for the file d64py-3.0.4.tar.gz.

File metadata

  • Download URL: d64py-3.0.4.tar.gz
  • Upload date:
  • Size: 240.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for d64py-3.0.4.tar.gz
Algorithm Hash digest
SHA256 551a854c15dab2894fca77203004678d5f38e8c0e0f770fff145f0ef45928124
MD5 db5e8d3988ba5bb7e71d5ce58c210255
BLAKE2b-256 a43c505facd542613d89a6bbfdbc2d240ebdb9a5ea7273722aaa6e7ad315f073

See more details on using hashes here.

File details

Details for the file d64py-3.0.4-py3-none-any.whl.

File metadata

  • Download URL: d64py-3.0.4-py3-none-any.whl
  • Upload date:
  • Size: 241.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for d64py-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cede18552473446ca17b192c377fde818557bf80745e8b5f7258208d9fc4bda0
MD5 da1e81467c5dc945d3315b47a52904b5
BLAKE2b-256 b53afabcdd902b4fd5ab31a2fd1afd944e9e8a0658a1f88630f0360c49ff5035

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page