Skip to content

Instantly share code, notes, and snippets.

@JettMonstersGoBoom
Last active December 28, 2022 19:44
Show Gist options
  • Save JettMonstersGoBoom/55cbebd4b913cdf4908b28a1dc5dfb7c to your computer and use it in GitHub Desktop.
Save JettMonstersGoBoom/55cbebd4b913cdf4908b28a1dc5dfb7c to your computer and use it in GitHub Desktop.
NCM plugin code for Mega65 NCM
using System;
using System.Drawing;
using CharactorLib.Common;
using CharactorLib.Format;
namespace ncm_16x8
{
public class ncm_16x8 : FormatBase
{
public ncm_16x8()
{
base.FormatText = "[16][8]";
base.Name = "4BPP NCM 16x8";
base.Extension = "ncm";
base.Author = "MGB";
base.Url = "httt://none";
// Flags
base.Readonly = false;
base.IsCompressed = false;
base.EnableAdf = true;
base.IsSupportMirror = true;
base.IsSupportRotate = false;
// Settings
base.ColorBit = 4;
base.ColorNum = 16;
base.CharWidth = 16;
base.CharHeight = 8;
// Settings for"Image Convert
base.Width = 128;
base.Height = 128;
}
//for display
public override void ConvertMemToChr(Byte[] data, int addr, Bytemap bytemap, int px, int py)
{
for (int i = 0; i < base.CharHeight; i++)
{
int index = (i * 8) + addr;
int pointAddress = bytemap.GetPointAddress(px, py + i);
for (int j = 0; j < 8; j++)
{
byte b = data[index+j];
bytemap.Data[pointAddress++] = (byte)(b &0xf);
bytemap.Data[pointAddress++] = (byte)((b >>4 )& 0xf);
}
}
}
//for editing
public override void ConvertChrToMem(Byte[] data, int addr, Bytemap bytemap, int px, int py)
{
for (int i = 0; i < base.CharHeight; i++)
{
int index = (i * 8) + addr;
int pointAddress = bytemap.GetPointAddress(px, py + i);
for (int j = 0; j < 8; j++)
{
byte a = (byte)(bytemap.Data[pointAddress++]&0xf);
byte b = (byte)(bytemap.Data[pointAddress++] & 0xf);
data[index + j] = (byte)((b << 4) | (a));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment