ii.AscendancyLib
0.7.7-alpha.1
This is a prerelease version of ii.AscendancyLib.
dotnet add package ii.AscendancyLib --version 0.7.7-alpha.1
NuGet\Install-Package ii.AscendancyLib -Version 0.7.7-alpha.1
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="ii.AscendancyLib" Version="0.7.7-alpha.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ii.AscendancyLib" Version="0.7.7-alpha.1" />
<PackageReference Include="ii.AscendancyLib" />
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 ii.AscendancyLib --version 0.7.7-alpha.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ii.AscendancyLib, 0.7.7-alpha.1"
#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 ii.AscendancyLib@0.7.7-alpha.1
#: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=ii.AscendancyLib&version=0.7.7-alpha.1&prerelease
#tool nuget:?package=ii.AscendancyLib&version=0.7.7-alpha.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
iiAscendancyLib
iiAscendancyLib is a C# library targetting .NET8, supporting the modification of files relating to Ascendancy, the 1995 4X science fiction turn-based strategy computer game. The library supports:
Name | Read | Write | Comment |
---|---|---|---|
COB | ✔ | ✔ | |
RAW | ✔ | ✗ | |
SAV | ✔ | ✔ | File format is not fully decoded |
SHP | ✔ | ✗ | |
WAV | ✔ | ✗ | |
VOC | ✔ | ✗ |
Usage
Sample code to use the library is provided below.
var gameDir = @"D:\Games\ascendancy\ASCEND\";
var assetDir = @"D:\data\Ascendancy\";
//----------------------------------------------------------------------
//----------------------------------------------------------------------
Console.WriteLine($"Extracting all files to {assetDir}");
// Open a COB file
var cobFiles = new string[] { "ASCEND00.COB", "ASCEND01.COB", "ASCEND02.COB" };
var cr = new CobReader();
foreach (var cobFile in cobFiles)
{
var file = cr.Read(Path.Combine(gameDir, cobFile));
Console.WriteLine($"{cobFile} contains {file.files.Count} files");
// Save all files to disk
for (int i = 0; i < file.files.Count; i++)
{
var fileName = string.Join("", file.fileNames[i].filename).Split('\0')[0].ToString();
fileName = fileName.StartsWith("\\") ? fileName.Substring(1) : fileName;
fileName = Path.Combine(assetDir, Path.GetFileNameWithoutExtension(cobFile), fileName);
var directory = Path.GetDirectoryName(fileName);
Directory.CreateDirectory(directory);
using var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
fs.Write(file.files[i], 0, file.files[i].Length);
fs.Flush(flushToDisk: true);
}
}
// Create a new COB file from the files just extracted
Console.WriteLine($"Repacing ASCEND00.COB into 00COPY.COB");
var cobWriter = new CobWriter();
cobWriter.Write(Path.Combine(assetDir, "00COPY.COB"), Path.Combine(assetDir, "ASCEND00"), Path.Combine(assetDir, "ASCEND00\\"), "*.*");
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Convert a VOC to a WAV
Console.WriteLine($"Converting VOC to WAV");
var vc = new VocConverter();
vc.ConvertVoc(Path.Combine(assetDir, "ASCEND01", "data", "blueexit.voc"), Path.Combine(assetDir, "ASCEND01", "blueexit.wav"), true);
// Convert a RAW to a WAV
Console.WriteLine($"Converting RAW to WAV");
var rawConverter = new RawConverter();
rawConverter.ConvertRaw(Path.Combine(assetDir, "ASCEND01", "data", "shield.voc"), Path.Combine(assetDir, "ASCEND01", "shield.wav"));
// Convert a RAW to a WAV and play it
Console.WriteLine($"Converting RAW to WAV and playing it");
rawConverter.ConvertRaw(Path.Combine(assetDir, "ASCEND02", "data", "theme04.raw"), Path.Combine(assetDir, "ASCEND02", "theme04.raw.wav"));
var player = new SoundPlayer { SoundLocation = Path.Combine(assetDir, "ASCEND02", "theme04.raw.wav") };
player.Play();
Console.WriteLine("Playing theme04 - press [Enter] key to stop");
Console.ReadLine();
player.Stop();
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Convert all SHP files
Console.WriteLine($"Converting all SHP files in ASCEND01.COB and saving the first frame");
var converter = new ShpConverter();
List<string> shps = new List<string>(Directory.EnumerateFiles(Path.Combine(assetDir, "ASCEND01", "data"), "*.shp"));
foreach (var shp in shps)
{
try
{
var shpFile = converter.ConvertShp(shp);
shpFile.Images.First().Save(Path.Combine(assetDir, "ASCEND01", $"{Path.GetFileNameWithoutExtension(shp)}.bmp"), ImageFormat.Bmp);
}
catch (Exception ex)
{
Console.WriteLine(shp + " " + ex.ToString());
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
}
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
Console.WriteLine($"Loading resume.gam");
var savReader = new SavReader();
var savegame = savReader.Load(Path.Combine(gameDir, "resume.gam"));
Console.WriteLine($"Saving resume.new");
var savWriter = new SavWriter();
savWriter.Save(Path.Combine(assetDir, "resume.new"), savegame);
Compiling
To clone and run this application, you'll need Git and .NET installed on your computer. From your command line:
# Clone this repository
$ git clone https://github.com/btigi/iiAscendancyLib
# Go into the repository
$ cd src
# Build the app
$ dotnet build
Licencing
iiAscendancyLib is licenced under the MIT License. Full licence details are available in licence.md
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net9.0
- SixLabors.ImageSharp (>= 3.1.8)
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 |
---|---|---|
0.7.7-alpha.1 | 135 | 5/20/2025 |
0.7.0-alpha.1 | 116 | 3/27/2025 |