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).

Provides one implementation of the pieces every format parser duplicated:

  • 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 hierarchySidParseError, SidFormatError, EmulatorUnavailable.
  • detect_playroutine / PlayroutineKind — the untrustworthy-header detector: static signature recognition first, then an emulated init run to classify DIRECT / RELOCATED / PACKED / UNKNOWN playroutines.
  • BaseSidParser — the class each format subclasses for a consistent read / parse / detect API.
  • CodePattern / find_code_all / find_code_first — masked 6502 code-fragment search with operand capture: locate a player fingerprint by its opcode skeleton (per-tune operand bytes wildcarded) and read the captured immediate/address. The one primitive every relocatable player's reader needs.
  • registers — documented C64 hardware register map (SID/CIA/VIC, IRQ/NMI and CPU vectors) with predicates (is_sid_reg, is_cia_timer, …) and find_register_stores, a scanner for absolute stores to a set of addresses.
  • trace_init / InitTrace — run a tune's init in py65 under a write observer and report where it programs the CIA timer latch (cadence) and the IRQ/NMI vectors (the real play routine an IRQ-driven header hides).

Install

pip install pysidtracker          # core (stdlib only)
pip install pysidtracker[emu]     # + py65, to unpack packed/relocating tunes
pip install pysidtracker[fast]    # + numpy, to accelerate the image scan

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)
        ...                                    # decode image.mem into a model

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

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

Development

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

Apache-2.0 licensed.

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.2.0.tar.gz (35.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.2.0-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysidtracker-0.2.0.tar.gz
  • Upload date:
  • Size: 35.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.2.0.tar.gz
Algorithm Hash digest
SHA256 6abbb5b112fe7f8e0d4aaa5644617e5a437902e10b2e065c17ce00c6f6bc7819
MD5 c4e39f65d99c6d6f8d54b60a10c9a80f
BLAKE2b-256 c70c7fc217675920ef41cc2c80396124b20b337d74bd7c5ff3c8e9ef0a196246

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysidtracker-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: pysidtracker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd4362654a3b1ab79295bd213243bc8189f1842afb8d716ace83e2ff163e73ea
MD5 11d31e83652074fa51519d32d055c573
BLAKE2b-256 fecbdf4f18a264a020d071bb6914d4bf6dad8e59759942d82d298158154048ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysidtracker-0.2.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