{"id":50825024,"url":"https://github.com/fstark/png2mo5","last_synced_at":"2026-06-13T17:33:54.468Z","repository":{"id":358343634,"uuid":"1239178086","full_name":"fstark/png2mo5","owner":"fstark","description":"Convert any PNG to a Thomson MO5 image — CIELAB dithering, ZX0 compression, 6809 viewer, cassette tape output. C++23.","archived":false,"fork":false,"pushed_at":"2026-05-16T22:38:23.000Z","size":1355,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-16T23:42:10.901Z","etag":null,"topics":["6809","6809-assembly","color-quantization","color-quantization-algorithms","dithering","image-processing","mo5","retro-computing","thomson","thomson-mo5","vintage-computer","vintage-computers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fstark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-14T20:54:16.000Z","updated_at":"2026-05-16T22:38:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fstark/png2mo5","commit_stats":null,"previous_names":["fstark/png2mo5"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/fstark/png2mo5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstark%2Fpng2mo5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstark%2Fpng2mo5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstark%2Fpng2mo5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstark%2Fpng2mo5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fstark","download_url":"https://codeload.github.com/fstark/png2mo5/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstark%2Fpng2mo5/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34294413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["6809","6809-assembly","color-quantization","color-quantization-algorithms","dithering","image-processing","mo5","retro-computing","thomson","thomson-mo5","vintage-computer","vintage-computers"],"created_at":"2026-06-13T17:33:54.342Z","updated_at":"2026-06-13T17:33:54.462Z","avatar_url":"https://github.com/fstark.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# png2mo5\n\nhttps://github.com/user-attachments/assets/ce33dc24-45bc-4362-9a23-4df7d69dfb26\n\nConvert any PNG into something a 1984 Thomson MO5 can actually display.\n\nMore details at the [companion blog post](https://stark.fr/blog/png2mo5/)\n\nThe MO5 has a fixed 16-color palette and a brutal constraint: each group of 8 horizontal pixels can only use 2 colors. That's it. No tricks, no workarounds, just 2 colors per block.\n\nAnd the palette looks like this:\n\n![MO5 palette](assets/mo5_palette.png)\n\nThe converter optionally works in CIELAB perceptual color space — it brute-forces all 136 possible color pairs for every 8-pixel block, simulating Floyd-Steinberg error diffusion inside each candidate to find the pair that minimizes outgoing perceptual error. Then it commits the winner and diffuses the quantization error (damped ~90%) across the image. The result is surprisingly good for 16 KB of video RAM.\n\nC++23. Single-file tools. No dependencies beyond stb headers and a ZX0 compressor.\n\n## Examples\n\n| Original | MO5 (320×200, 16 colors, 2 per block) |\n|----------|----------------------------------------|\n| ![lena](assets/lena.png) | ![lena mo5](assets/lena_preview.png) |\n| ![birds](assets/birds.jpg) | ![birds mo5](assets/birds_preview.png) |\n\nCompressed sizes (ZX0, from 16 KB raw):\n\n| Image | `.mo5z` size |\n|-------|-------------|\n| lena  | 10.3 KB     |\n| birds | 12.6 KB     |\n\nThe `.mo5z` format splits color and pixel data into three separate ZX0-compressed streams — colors first, so a viewer on real hardware can progressively reveal the image during decompression.\n\n## What's in the repo\n\n| Tool | What it does |\n|------|-------------|\n| **png2mo5** | Image -\u003e MO5. Handles resize, palette quantization, dithering, outputs raw bins + preview PNG |\n| **mo5z** | Compresses MO5 pixel+color banks into a single `.mo5z` file (three ZX0 streams) |\n| **mo5z2png** | Decompresses a `.mo5z` back to a viewable PNG |\n| **k7tool** | Creates and inspects `.k7` cassette tape images for the MO5 |\n| **mo5zviewer** | 6809 assembly viewer (309 bytes) — boots from tape, decompresses, displays. That's it |\n\nThe full pipeline: `png2mo5` -\u003e `mo5z` -\u003e `k7tool` bundles the viewer + compressed image into a `.k7` cassette file you can load in an emulator.\n\n## Doing your own images\n\n```bash\n# 0. (optional) Preview the conversion before committing\n#    -\u003e lena_preview.png (preview is the default, no flags needed)\npng2mo5/png2mo5 lena.png\n\n# 1. Convert PNG to MO5 raw banks (8000 bytes each)\n#    -\u003e lena_pixels.bin, lena_colors.bin\npng2mo5/png2mo5 lena.png --bin\n\n# 2. Compress into a .mo5z (three ZX0 streams, ~10 KB)\n#    -\u003e lena.mo5z\nmo5z/mo5z lena_pixels.bin lena_colors.bin -o lena\n\n# 3. Glue the viewer + compressed image into a single binary\n#    -\u003e lena.bin (stanalone binary, loads at $2800, exec at $2800)\ncat mo5zviewer/mo5zviewer.bin lena.mo5z \u003e lena.bin\n\n# 4. (optional) Wrap it in a .k7 cassette file for use in an emulator\nk7tool/k7tool -o lena.k7 lena.bin:0x2800:0x2800\n```\n\n---\n\n\u003csub\u003eAll the code in this repo — including the 6809 assembly — was written by Claude Opus 4.6 under my supervision.\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffstark%2Fpng2mo5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffstark%2Fpng2mo5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffstark%2Fpng2mo5/lists"}