Casasoft.Commodore 1.0.5

dotnet add package Casasoft.Commodore --version 1.0.5
                    
NuGet\Install-Package Casasoft.Commodore -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Casasoft.Commodore" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Casasoft.Commodore" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Casasoft.Commodore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Casasoft.Commodore --version 1.0.5
                    
#r "nuget: Casasoft.Commodore, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Casasoft.Commodore@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Casasoft.Commodore&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Casasoft.Commodore&version=1.0.5
                    
Install as a Cake Tool

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 DATA lines 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 with LoadAddress and Data, Save() and CreateDataLines().
  • Strings2Prg: PRG built from a list of strings with a pointer table; CreateArrays() and RelocatePointers().
  • Conversions: little-endian 16-bit helpers.

See the XML documentation comments for details and edge cases.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.5 89 11/3/2026
1.0.2 146 3/15/2026