Skip to main content

Shared base for pure-Python C64 SID tracker parsers: PSID/RSID container, loaded-image model, and packed/relocating playroutine detection

Project description

pysidtracker

Shared base for the pure-Python C64 SID tracker parsers (pygoattracker, pysidwizard, pydmcsid, pyfuturecomposer, pymusicassembler, pydefmon, pyjch, pysoundmonitor).

Reads .sid containers (PSID/RSID) and bare .prg images into a 64 KiB C64 memory model, and detects packed/relocating playroutines by running the tune's init in a 6502 emulator — container headers are not trusted. Each format package subclasses BaseSidParser for a consistent read / parse / detect API.

Components

  • parse_sid_header / SidHeader — PSID/RSID container header parsing.
  • SidImage — a loaded 64 KiB C64 memory image with absolute-addressed accessors, from a .sid container or a bare .prg.
  • read_bytes — path / bytes / file-like source dispatch.
  • SidError hierarchy — SidParseError, SidFormatError, EmulatorUnavailable.
  • detect_playroutine / PlayroutineKind — static signature recognition, then an emulated init run to classify DIRECT / RELOCATED / PACKED / UNKNOWN.
  • BaseSidParser — the base class each format subclasses.
  • CodePattern / find_code_all / find_code_first — masked 6502 code-fragment search with operand capture.
  • registers — C64 hardware register map (SID/CIA/VIC, IRQ/NMI and CPU vectors) with predicates and find_register_stores.
  • trace_init / InitTrace — run a tune's init under a write observer to report CIA timer cadence and the IRQ/NMI vectors an IRQ-driven header hides.
  • reglogRegWrite register-log format (read_reglog / write_reglog) and frame_writes, the shared per-frame SID-write framing loop.
  • oracle — per-frame SID register grids: register_grid (py65), the stdlib grid_from_writes framer, read_sidwr (preframr-sidtrace .sidwr.bin), and aligned_match.
  • testing — HVSC tune fetch/resolve for test suites (fetch_tune, resolve_tune, make_tune_fixtures).
  • audiorender_samples / render_wav through an emulated SID (pyresidfp, audio extra).

Install

pip install pysidtracker          # core (includes py65 for init emulation)
pip install pysidtracker[fast]    # + numpy, to accelerate the image scan
pip install pysidtracker[audio]   # + pyresidfp, for WAV/sample rendering

py65 is required (detection runs a tune's 6502 init to unpack packed/relocating playroutines). numpy is optional; a pure-stdlib scan is used when it is absent.

Usage

from pysidtracker import BaseSidParser, PlayroutineKind

class MyParser(BaseSidParser):
    def recognize(self, image):
        return image.find(b"MYSIG")            # truthy anchor when found
    def parse(self, data, **kw):
        image = self.load_image(data)          # .sid or .prg -> SidImage
        ...                                    # decode image.mem into a model

det = MyParser().detect("tune.sid")
if det.kind is PlayroutineKind.PACKED:
    ...                                        # header was not trustworthy

Development

pip install -e ".[dev]"
pytest --cov=pysidtracker

See docs/design.md for the detection model and shared primitives, and docs/adoption.md for how the format packages consume this base.

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

pysidtracker-0.3.0.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

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

pysidtracker-0.3.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file pysidtracker-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for pysidtracker-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c6387fe589038c39da22c5f0479b2c04f8af13ccdf10f18fd903536632f4ea23
MD5 4ede61e02f337c24dcb6be6d67bb1eae
BLAKE2b-256 dc80b19eb99aa59b44332bf0fc000d70846d5780ffbb136533fa140bd42ba7ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysidtracker-0.3.0.tar.gz:

Publisher: publish.yml on anarkiwi/pysidtracker

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

File details

Details for the file pysidtracker-0.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pysidtracker-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b9a02b65798deaa37bde6f27a033b99d9dd5c6139abafa5a903748a1cc3f422
MD5 00bf2e619f253daa048b1b7a8f81ad8f
BLAKE2b-256 b245ff0133f41819234a007f7719a067fc0b6499d3495c8e3f003c05c910e91c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysidtracker-0.3.0-py3-none-any.whl:

Publisher: publish.yml on anarkiwi/pysidtracker

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