Casasoft.Commodore
1.0.5
dotnet add package Casasoft.Commodore --version 1.0.5
NuGet\Install-Package Casasoft.Commodore -Version 1.0.5
<PackageReference Include="Casasoft.Commodore" Version="1.0.5" />
<PackageVersion Include="Casasoft.Commodore" Version="1.0.5" />
<PackageReference Include="Casasoft.Commodore" />
paket add Casasoft.Commodore --version 1.0.5
#r "nuget: Casasoft.Commodore, 1.0.5"
#:package Casasoft.Commodore@1.0.5
#addin nuget:?package=Casasoft.Commodore&version=1.0.5
#tool nuget:?package=Casasoft.Commodore&version=1.0.5
Casasoft Commodore
A small .NET library for Commodore 64 development: ASCII ↔ PETSCII text conversion, PETSCII control codes as readable tags, and reading, writing and generating Commodore PRG files.
Installation
dotnet add package Casasoft.Commodore
Requires .NET 10.0. All types are in the Casasoft.Commodore namespace.
Features
- Convert text between ASCII and PETSCII, with optional lowercase (shifted) character set mapping.
- Write PETSCII control codes (colors, reverse, clear/home, cursor movement) as readable tags such as
[red]or[clr], and convert them back. - Read and write PRG files (two-byte little-endian load address followed by data).
- Build PRG payloads from a list of strings: a pointer table followed by null-terminated PETSCII strings, with pointer relocation.
- Generate Commodore BASIC
DATAlines plus a loader to embed a PRG in a BASIC listing. - Little-endian 16-bit helpers.
Usage
using Casasoft.Commodore;
PETSCII text conversion
string pet = Charset.PETSCII("Hello World", LowerCase: true);
byte[] bytes = Charset.PETSCIIBytes("Hello World", LowerCase: true);
string text = Charset.ASCII(File.ReadAllBytes("file.seq"), LowerCase: true);
Control code tags
// "[clr][red]HELLO" -> 0x93 0x1C 'H' 'E' 'L' 'L' 'O'
string raw = Charset.TagsToControlCodes("[clr][red]HELLO");
// and back
string tagged = Charset.ControlCodesToTags(raw);
Tags are case-insensitive; unknown tags are left unchanged. Supported tags:
| Group | Tags |
|---|---|
| Colors | black white red cyan purple green blue yellow orange brown lightred darkgrey grey lightgreen lightblue lightgrey |
| Reverse | rvson rvsoff |
| Screen | clr home |
| Cursor | up down left right |
The full mapping is available in Charset.ControlCodesTable.
PRG files
var prg = new PrgFile("myprogram.prg");
Console.WriteLine($"Load address: ${prg.LoadAddress:X4}, {prg.Data.Length} bytes");
var copy = new PrgFile(0xC000, prg.Data);
copy.Save("out.prg");
String tables
var strings = new List<string> { "HELLO", "WORLD" };
var table = new Strings2Prg(0xC000, strings, LowerCase: false, AddIndex: true);
table.Save("strings.prg");
// Move the pointer table to a new load address
Strings2Prg.RelocatePointers(table.Data, newLoadAddress: 0x1000, oldLoadAddress: 0xC000);
The generated data starts with the number of strings (16-bit), followed by one 16-bit pointer per string, then the null-terminated PETSCII strings. Strings2Prg.CreateArrays() returns the pointer table and the string bytes separately.
BASIC DATA lines
string basic = prg.CreateDataLines(bytesPerLine: 8, targetFilename: "OUT.PRG");
The result contains a short BASIC loader that POKEs the data into memory and saves it to disk as OUT.PRG, followed by the DATA lines.
Little-endian helpers
ushort addr = Conversions.ToUShort(0x00, 0xC0); // 0xC000
var (lo, hi) = Conversions.ToBytes(0xC000); // (0x00, 0xC0)
Conversions.InsertUShort(buffer, 0, 0xC000);
ushort value = Conversions.ReadUShort(buffer, 0);
Main types
Charset: ASCII ↔ PETSCII conversion, character predicates, control code tags.IPrgFile/PrgFile: PRG file withLoadAddressandData,Save()andCreateDataLines().Strings2Prg: PRG built from a list of strings with a pointer table;CreateArrays()andRelocatePointers().Conversions: little-endian 16-bit helpers.
See the XML documentation comments for details and edge cases.
Related
- Casasoft.CommodoreImages: image to C64 multicolor/hires bitmap conversion.
- Command-line tools (A2Petscii, Pet2Ascii, Text2Prg, Prg2Data, ...) built on this library: https://github.com/strawberryfield/CommodoreUtils
License
GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).
Copyright (c) 2025-2026 Roberto Ceccarelli - Casasoft (http://strawberryfield.altervista.org)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.