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 (includes py65 for init emulation)
pip install pysidtracker[fast]    # + numpy, to accelerate the image scan

py65 is a required dependency (detection runs a tune's 6502 init routine to unpack packed/relocating playroutines). numpy is optional (a pure-stdlib scan fallback 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)
        ...                                    # 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.1.tar.gz (35.8 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.1-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysidtracker-0.2.1.tar.gz
  • Upload date:
  • Size: 35.8 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.1.tar.gz
Algorithm Hash digest
SHA256 e82a5cd71e54a63209a64f8f571ad6ec8d14460dfa6218861a106575ae924dec
MD5 c98a04be057221c481ecf25dfdd58bdd
BLAKE2b-256 b71a6995a8070d182241c4a218ed9f4bf6682fe986c0c3c60bcefd47df281878

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pysidtracker-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 31.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac11e98d5f723e3ede611c3be9864513e05d32de253f12989b09cb6a2d7508d
MD5 d2fe16b4d564666fabf70fc12d4b0cfc
BLAKE2b-256 e1e018fb76e24763f1375a716098826fee8f8c3bde15cceaffa4dcc47814de72

See more details on using hashes here.

Provenance

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