Skip to main content

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.
  • emu — the shared jennings host every init/replay path runs on: wire_mpu (native NMOS illegal opcodes + cycle-derived VIC/SID reads) and run_to_rts.
  • playroutine_cadence / Cadence / TriggerSource — derive the play-routine cadence (PAL/NTSC video frame vs CIA-timer latch) from what init programs, not the header.
  • native_decrunch — native exomizer unpack (pydexomizer), an init-free alternative depack path; opt-in via detect_playroutine(..., native=True).
  • reglog — RegWrite 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 (jennings), the stdlib grid_from_writes framer, read_sidwr (preframr-sidtrace .sidwr.bin), aligned_match, and the sidtrace (sidplayfp) oracle bridge — run_sidtrace, read_sidtrace, sidtrace_cadence, sidtrace_grid.
  • testing — HVSC tune fetch/resolve for test suites (fetch_tune, resolve_tune, make_tune_fixtures), and make_oracle_fixtures / oracle_grid — a reusable byte-exact player-vs-sidtrace-oracle test (docs/oracle-testing.md).
  • survey — whole-song HVSC survey and failure triage of any format's renderer against the sidtrace oracle; sidid — pure-Python SIDId with the bundled sidid.cfg (pysidid CLI). pip install "pysidtracker[survey]", docs/survey.md.
  • roms — C64 KERNAL/BASIC/CHARGEN ROM fetch + SHA-256 verified cache (fetch_rom, resolve_rom, roms_available) and 64 KiB mapping (rom_image, apply_roms) for tunes that cannot run without the ROMs. The ROMs are copyright works: fetched into a gitignored cache, never committed (docs/c64-roms.md).
  • audio — render_player_wav / render_player_samples drive a MemPlayer straight to WAV through an emulated SID (pyresidfp, a core dependency); the lower-level render_wav / render_samples take a bare write stream, plus resolve_device / seconds_to_frames.
  • Writers — SidHeader.to_bytes / write_psid / SidImage.to_prg (the inverse of the parsers), parse_prg, and encode_cstr / decode_cstr.
  • SidImage absolute-address accessors — byte_at / word_at / contains / poke, relocation-safe and bounds-checked.
  • mos6502 — shared 6502 primitives: OP_LEN, opcode-class sets, s8 / adc / sbc, SidWriteCapturingMemory, walk_until.
  • MemPlayer — per-frame register-diff player scaffold; subclasses implement _init / _frame. register_writes_from_player drives it to a reglog.
  • notefreq — NoteFreqTable, computed PAL/NTSC pitch tables, and locate_note_freq (find hi/lo tables from paired absolute-indexed reads).
  • make_package_errors — per-package error hierarchy factory whose *ParseError / *FormatError subclass the base ones, so base except clauses catch them.
  • formats / maincli — the one pysidtracker CLI (info / reglog / wav) that discovers installed formats through the pysidtracker.formats entry-point group and runs against each format's parser + player, plus any subcommands it contributes. A format package registers a SidFormat instead of shipping its own CLI. cli holds the underlying argparse scaffold (run_cli, print_info, add_reglog_command, add_wav_command).
  • registers additions — SID_VOICES, voice/global register indices, and the attack_decay / sustain_release ADSR nibble packers.
  • resolve_entry_points / is_jmp_vector, cadence_from_latch, and the ByteCursor / check / byte_range parse helpers.

Install

pip install pysidtracker   # core: jennings (init emulation), numpy, pyresidfp (WAV render)

All dependencies are core: jennings (detection runs a tune's 6502 init), pydexomizer (native_decrunch unpacks exomizer-packed images natively), pyresidfp (the emulated SID the WAV render drives), and numpy (sample buffers and the image anchor 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)          # .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.

License

Apache 2.0 — see LICENSE.

Metadata

Release files for pysidtracker 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysidtracker 0.11.0
File Size Uploaded
pysidtracker-0.11.0.tar.gz 144.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysidtracker 0.11.0
File Interpreter ABI Platform
pysidtracker-0.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 259.3 kB

Release files / pysidtracker-0.11.0.tar.gz

Download URL pysidtracker-0.11.0.tar.gz
Size 144.7 kB
Tags Source
SHA-256 checksum
How to use checksums
098e4695a9d6ed3ac565011835036aa17caa520be59d4ec78b2906cbe754b766
BLAKE2b-256 checksum
How to use checksums
01ee4a139e777317f251680059f58a91a3a2b069ca874edec23ab7acf2622ecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / pysidtracker-0.11.0-py3-none-any.whl

Download URL pysidtracker-0.11.0-py3-none-any.whl
Size 114.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e829c868deaa7046f548777c1c429ad29f2fe7c556d084f048f8de4735f08006
BLAKE2b-256 checksum
How to use checksums
cea2f6cd4290b6f2f7c4b1dff9d4bc3ff5325f7deb3220ee3eac87914189eaa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

0.11.2

2 release files

0.11.1

2 release files

This release

0.11.0 This release

2 release files

0.10.1

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page