Skip to content

Instantly share code, notes, and snippets.

@ogarvey
ogarvey / Cmp.cs
Created September 2, 2025 10:33
I.M Meen/Chill Manor Cmp Decoding Method
public static Image<Rgba32> DecodeCmp(byte[] cmpData, byte[] originalPalette)
{
var width = BitConverter.ToUInt16(cmpData.Take(2).ToArray(), 0);
var height = BitConverter.ToUInt16(cmpData.Skip(2).Take(2).ToArray(), 0);
var firstNonTransparentRow = BitConverter.ToUInt16(cmpData.Skip(4).Take(2).ToArray(), 0);
var lastNonTransparentRow = BitConverter.ToUInt16(cmpData.Skip(6).Take(2).ToArray(), 0);
var firstNonTransparentColumn = BitConverter.ToUInt16(cmpData.Skip(8).Take(2).ToArray(), 0);
var lastNonTransparentColumn = BitConverter.ToUInt16(cmpData.Skip(0xa).Take(2).ToArray(), 0);
var colourCount = cmpData[0xc];
@ogarvey
ogarvey / Decompress.c
Created March 22, 2024 13:30
CD-i Lords Of The Rising Sun decompress method
byte * FUN_0001bea4(undefined4 param_1,undefined4 param_2,byte *param_3,
uint param_4,ushort param_5)
{
byte bVar1;
byte bVar2;
byte *pbVar3;
int iVar4;
ushort uVar5;
short sVar6;
@ogarvey
ogarvey / BodySlamSpriteExtraction.cs
Created March 12, 2024 15:25
Small c# script to extract all sprites from Mutant Rampage - BodySlam (CD-i) -- Requires OGCDiLib
var mainDataFile = @"C:\Dev\Projects\Gaming\CD-i\Disc Images\Extracted\BODYSLAM\data.rtr";
var mainCdiFile = new CdiFile(mainDataFile);
var dataSectors = mainCdiFile.Sectors.Where(x => x.SubMode.IsData).OrderBy(x => x.Channel)
.ThenBy(x => x.SectorIndex).Select(x => x.GetSectorData()).ToList();
var mainData = dataSectors.SelectMany(x => x).ToArray();
File.WriteAllBytes(@"C:\Dev\Projects\Gaming\CD-i\Disc Images\Extracted\BODYSLAM\Output\mainData.bin", mainData);
var offsets = FileHelpers.FindSequenceOffsets(mainData, [0x43, 0x50, 0x4c, 0x32]);
@ogarvey
ogarvey / Decompress.cpp
Created March 6, 2024 11:16
Decompiled Tetris Decompress method
byte * Decompress(undefined4 param_1,undefined4 param_2,byte *param_3,
uint param_4,ushort param_5)
{
ushort uVar2;
uint uVar1;
int iVar3;
byte bVar4;
uint uVar5;