Skip to main content

Python automation framework for driving defMON (a Commodore 64 cross-platform music editor) inside asid-vice via the binary monitor.

Project description

defmon-driver

CI License: Apache 2.0

defmon-driver is a Python automation framework for driving defMON — the Commodore 64 cross-platform music editor by Ilkke / defcom — running inside asid-vice, an extension of the VICE C64 emulator that exposes a binary monitor with key-matrix tap and screen- scrape opcodes.

It is designed for the case where you want to programmatically:

  • boot defMON in an emulator,
  • load a tune from disk,
  • press keys (chords, super-commands, modal switches),
  • read the screen back as text or screencode bytes,
  • edit pattern / sidTAB / seqLIST fields,
  • and snapshot CPU state, RAM, or per-instruction code coverage.

The driver's defMON-specific layer is pure-Python and depends only on vice-driver (which itself has no runtime dependencies beyond the standard library). vice-driver provides the binary-monitor wire client, key matrix, screen scrape, container management, coverage harness, and state-assertion helpers; defmon-driver provides everything specific to defMON (mode handlers, field setters, sidTAB calibration, tune navigation, etc.).

defMON is a property of its authors; this project is an independent automation harness and is not affiliated with the defMON project.

Requirements

  • Python ≥ 3.10
  • Docker, with a built asid-vice:latest image — see anarkiwi/asid-vice for the Dockerfile and build instructions.
  • A defMON-formatted .d64 disk image (e.g. defmon-20201008.d64 or defmon-withtunes.d64, both available from csdb.dk).

The package itself does not bundle defMON or any disk image — the user provides their own copy in line with the original distribution terms.

Installation

pip install defmon-driver

Or, for development:

git clone https://github.com/anarkiwi/defmon-driver
cd defmon-driver
pip install -e ".[dev]"
pytest tests/unit

Quick start

import logging
from vice_driver import BinMon, DiskMount, ViceContainer
from defmon_driver import Defmon

logging.basicConfig(level=logging.INFO)

# Spin up an asid-vice container that autostarts the defMON disk image.
container = ViceContainer(
    autostart="/work/defmon.d64",
    mounts=[DiskMount("/host/path/to/defmon.d64", "/work/defmon.d64", read_only=True)],
)

with container:
    bm = BinMon("127.0.0.1", 6502)
    bm.connect(timeout=10.0, attempts=80, retry_delay=0.25)
    # Drain the initial halt and resume the CPU.
    bm.exit()

    d = Defmon(bm)
    d.wait_for_defmon_loaded(timeout=90.0)

    # Press F1 to start playback from cursor.
    d.play_from_cursor()
    # Scrape the screen back as 25 lines of ASCII.
    print(d.screen().text())
    d.stop_playback()

    bm.close()

For higher-level workflows there are dedicated sub-modules. The transport / emulator-control layer lives in vice-driver; everything below is defMON-specific.

Module Purpose
vice_driver.binmon Binary-monitor wire client + checkpoint / cpuhistory wrappers
vice_driver.keys C64 key-matrix names + ASCII → chord conversion
vice_driver.screen SCREEN_GET parsing, screencode → ASCII, find_text()
vice_driver.vice_docker One-shot Docker container management
vice_driver.coverage Per-action code-coverage harness using CHECK_EXEC + cpuhistory
vice_driver.expect Expect predicate + verify polling helper for post-action state assertions
defmon_driver.defmon Every documented defMON keyboard shortcut as a Python method
defmon_driver.keyhandler Direct-call keyboard injection (bypasses matrix scan / debounce)
defmon_driver.field_setter High-level "set any UI field" API on top of keyhandler
defmon_driver.sidtab sidTAB cell-level editing API driven by a calibration JSON
defmon_driver.keycode_table name → $0E44 keycode resolver built from defMON's $0F90 LUT
defmon_driver.calibrate_sidtab Auto-discover the sidTAB column → screen layout for a tune
defmon_driver.tune_manifest Static manifest of example tunes shipped with the defMON d64s
defmon_driver.tune_navigation Cursor-walk a tune off the disk menu by dir_index

CLI smoke tests

Several modules expose a python -m … entry point that drives a real asid-vice container end-to-end. They are not part of the CI unit-test suite (CI is offline-only); they exist for manual validation against a local Docker setup:

# End-to-end driver smoke: every documented chord + disk-menu round-trip.
python -m defmon_driver.smoke /path/to/defmon-20201008.d64

# Coverage harness smoke: install 176 page checkpoints, fire F1, verify the
# $80-$9F player band lights up.
python -m defmon_driver.smoke_coverage /path/to/defmon-20201008.d64

# Checkpoint + cpuhistory smoke.
python -m defmon_driver.smoke_checkpoint_cpuhistory /path/to/defmon-20201008.d64

# sidTAB calibration: discover the column → screen-cell mapping for a tune.
python -m defmon_driver.calibrate_sidtab \
    --d64 /path/to/defmon-withtunes.d64 \
    --tune ".GLOW WORM" \
    --out sidtab_calibration.json

# sidTAB driving smoke: load .GLOW WORM, write JP/AD/SR/ACID cells.
python -m defmon_driver.smoke_sidtab \
    --d64 /path/to/defmon-withtunes.d64 \
    --tune ".GLOW WORM" \
    --cal sidtab_calibration.json

# Chord-driven note write smoke: write_note_chord for Z..M, verify the
# expected note byte ($30..$3B) actually lands in pattern memory.
python -m defmon_driver.smoke_note_chord /path/to/defmon-20201008.d64

# Chord-driven sidcall1 smoke: cross-product V0/V1/V2 × {step 0,3,7} ×
# {0x00, 0x57, 0xAB, 0xFF}, verify each chord-driven write lands at the
# runtime cell address (catches the BUGS.md #2 regression class).
python -m defmon_driver.smoke_sidcall /path/to/defmon-20201008.d64

Known limitations

See BUGS.md for outstanding issues, FUTURE.md for features that another contributor could pick up, and CHANGELOG.md for behavioural changes — including any breaking renames or fixes whose impact downstream callers should review.

License

Apache 2.0 — see LICENSE.

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

defmon_driver-0.2.0.tar.gz (76.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

defmon_driver-0.2.0-py3-none-any.whl (83.5 kB view details)

Uploaded Python 3

File details

Details for the file defmon_driver-0.2.0.tar.gz.

File metadata

  • Download URL: defmon_driver-0.2.0.tar.gz
  • Upload date:
  • Size: 76.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for defmon_driver-0.2.0.tar.gz
Algorithm Hash digest
SHA256 47e2f77db43182cabbd5a7fe56d5d0882cb5bb83840501a8f1094f0d82d64368
MD5 8fd1fb43bbf420492f39629637f0128d
BLAKE2b-256 81e863767c1a26d48e0615b1d3201f232e50cc7016feddf7592e05a55d56d559

See more details on using hashes here.

Provenance

The following attestation bundles were made for defmon_driver-0.2.0.tar.gz:

Publisher: release.yml on anarkiwi/defmon-driver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file defmon_driver-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: defmon_driver-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 83.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for defmon_driver-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 608014481ea1e1ddfb82bb4f86ca0ba075b11cc8f1aa403b67a0a3adcdf449ec
MD5 2ae0eea0e509fbfd17c2ac5aa2c351f2
BLAKE2b-256 63909cc34cda05c4c8f146a2105deffb845aa9cd661130256a77223dd42b5406

See more details on using hashes here.

Provenance

The following attestation bundles were made for defmon_driver-0.2.0-py3-none-any.whl:

Publisher: release.yml on anarkiwi/defmon-driver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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